drivers/scsi/scsi_transport_srp.c
Source file repositories/reference/linux-study-clean/drivers/scsi/scsi_transport_srp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/scsi_transport_srp.c- Extension
.c- Size
- 25146 bytes
- Lines
- 901
- Domain
- Driver Families
- Bucket
- drivers/scsi
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/module.hlinux/jiffies.hlinux/err.hlinux/slab.hlinux/string.hscsi/scsi.hscsi/scsi_cmnd.hscsi/scsi_device.hscsi/scsi_host.hscsi/scsi_transport.hscsi/scsi_transport_srp.hscsi_priv.h
Detected Declarations
struct srp_host_attrsstruct srp_internalfunction find_child_rportfunction srp_tmo_validfunction srp_host_setupfunction show_srp_rport_idfunction show_srp_rport_rolesfunction store_srp_rport_deletefunction show_srp_rport_statefunction srp_show_tmofunction srp_parse_tmofunction show_reconnect_delayfunction store_reconnect_delayfunction show_failed_reconnectsfunction show_srp_rport_fast_io_fail_tmofunction store_srp_rport_fast_io_fail_tmofunction show_srp_rport_dev_loss_tmofunction store_srp_rport_dev_loss_tmofunction srp_rport_set_statefunction srp_reconnect_workfunction scsi_block_targetsfunction rport_fast_io_fail_timedoutfunction rport_dev_loss_timedoutfunction __srp_start_tl_fail_timersfunction srp_rport_set_statefunction srp_start_tl_fail_timersfunction srp_reconnect_rportfunction scsi_target_unblockfunction srp_timed_outfunction srp_rport_releasefunction scsi_is_srp_rportfunction srp_rport_matchfunction srp_host_matchfunction srp_rport_getfunction srp_rport_putfunction srp_rport_delfunction do_srp_rport_delfunction srp_remove_hostfunction srp_remove_hostfunction srp_attach_transportfunction srp_release_transportfunction srp_transport_initfunction srp_transport_exitmodule init srp_transport_initexport srp_tmo_validexport srp_parse_tmoexport srp_start_tl_fail_timersexport srp_reconnect_rport
Annotated Snippet
ret = device_add(&rport->dev);
if (ret) {
transport_destroy_device(&rport->dev);
put_device(&rport->dev);
return ERR_PTR(ret);
}
transport_add_device(&rport->dev);
transport_configure_device(&rport->dev);
return rport;
}
EXPORT_SYMBOL_GPL(srp_rport_add);
/**
* srp_rport_del - remove a SRP remote port
* @rport: SRP remote port to remove
*
* Removes the specified SRP remote port.
*/
void srp_rport_del(struct srp_rport *rport)
{
struct device *dev = &rport->dev;
transport_remove_device(dev);
device_del(dev);
transport_destroy_device(dev);
put_device(dev);
}
EXPORT_SYMBOL_GPL(srp_rport_del);
static int do_srp_rport_del(struct device *dev, void *data)
{
if (scsi_is_srp_rport(dev))
srp_rport_del(dev_to_rport(dev));
return 0;
}
/**
* srp_remove_host - tear down a Scsi_Host's SRP data structures
* @shost: Scsi Host that is torn down
*
* Removes all SRP remote ports for a given Scsi_Host.
* Must be called just before scsi_remove_host for SRP HBAs.
*/
void srp_remove_host(struct Scsi_Host *shost)
{
device_for_each_child(&shost->shost_gendev, NULL, do_srp_rport_del);
}
EXPORT_SYMBOL_GPL(srp_remove_host);
/**
* srp_stop_rport_timers - stop the transport layer recovery timers
* @rport: SRP remote port for which to stop the timers.
*
* Must be called after srp_remove_host() and scsi_remove_host(). The caller
* must hold a reference on the rport (rport->dev) and on the SCSI host
* (rport->dev.parent).
*/
void srp_stop_rport_timers(struct srp_rport *rport)
{
mutex_lock(&rport->mutex);
if (rport->state == SRP_RPORT_BLOCKED)
__rport_fail_io_fast(rport);
srp_rport_set_state(rport, SRP_RPORT_LOST);
mutex_unlock(&rport->mutex);
cancel_delayed_work_sync(&rport->reconnect_work);
cancel_delayed_work_sync(&rport->fast_io_fail_work);
cancel_delayed_work_sync(&rport->dev_loss_work);
}
EXPORT_SYMBOL_GPL(srp_stop_rport_timers);
/**
* srp_attach_transport - instantiate SRP transport template
* @ft: SRP transport class function template
*/
struct scsi_transport_template *
srp_attach_transport(struct srp_function_template *ft)
{
int count;
struct srp_internal *i;
i = kzalloc_obj(*i);
if (!i)
return NULL;
i->t.host_size = sizeof(struct srp_host_attrs);
i->t.host_attrs.ac.attrs = &i->host_attrs[0];
Annotation
- Immediate include surface: `linux/init.h`, `linux/module.h`, `linux/jiffies.h`, `linux/err.h`, `linux/slab.h`, `linux/string.h`, `scsi/scsi.h`, `scsi/scsi_cmnd.h`.
- Detected declarations: `struct srp_host_attrs`, `struct srp_internal`, `function find_child_rport`, `function srp_tmo_valid`, `function srp_host_setup`, `function show_srp_rport_id`, `function show_srp_rport_roles`, `function store_srp_rport_delete`, `function show_srp_rport_state`, `function srp_show_tmo`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.