drivers/scsi/mpt3sas/mpt3sas_transport.c
Source file repositories/reference/linux-study-clean/drivers/scsi/mpt3sas/mpt3sas_transport.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/mpt3sas/mpt3sas_transport.c- Extension
.c- Size
- 65098 bytes
- Lines
- 2194
- Domain
- Driver Families
- Bucket
- drivers/scsi
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/module.hlinux/kernel.hlinux/init.hlinux/errno.hlinux/sched.hlinux/workqueue.hlinux/delay.hlinux/pci.hscsi/scsi.hscsi/scsi_cmnd.hscsi/scsi_device.hscsi/scsi_host.hscsi/scsi_transport_sas.hscsi/scsi_dbg.hmpt3sas_base.h
Detected Declarations
struct rep_manu_requeststruct rep_manu_replystruct phy_error_log_requeststruct phy_error_log_replystruct phy_control_requeststruct phy_control_replyfunction _transport_get_port_id_by_sas_phyfunction _transport_sas_node_find_by_sas_addressfunction _transport_get_port_id_by_rphyfunction list_for_each_entryfunction _transport_convert_phy_link_ratefunction _transport_set_identifyfunction mpt3sas_transport_donefunction _transport_expander_report_manufacturefunction _transport_delete_portfunction _transport_delete_phyfunction _transport_add_phyfunction mpt3sas_transport_add_phy_to_an_existing_portfunction list_for_each_entryfunction list_for_each_entryfunction mpt3sas_transport_del_phy_from_an_existing_portfunction list_for_each_entry_safefunction _transport_sanity_checkfunction mpt3sas_transport_port_addfunction list_for_each_entryfunction mpt3sas_transport_port_removefunction list_for_each_entry_safefunction list_for_each_entry_safefunction mpt3sas_transport_add_host_phyfunction mpt3sas_transport_add_expander_phyfunction mpt3sas_transport_update_linksfunction phy_to_iocfunction rphy_to_iocfunction _transport_get_expander_phy_error_logfunction _transport_get_linkerrorsfunction mpt3sas_get_port_by_idfunction _transport_get_enclosure_identifierfunction _transport_get_bay_identifierfunction _transport_expander_phy_controlfunction _transport_phy_resetfunction mpt3sas_get_port_by_idfunction _transport_phy_enablefunction mpt3sas_get_port_by_idfunction _transport_phy_speedfunction mpt3sas_get_port_by_idfunction _transport_map_smp_bufferfunction _transport_unmap_smp_bufferfunction _transport_smp_handler
Annotated Snippet
struct rep_manu_request {
u8 smp_frame_type;
u8 function;
u8 reserved;
u8 request_length;
};
/* report manufacture reply structure */
struct rep_manu_reply {
u8 smp_frame_type; /* 0x41 */
u8 function; /* 0x01 */
u8 function_result;
u8 response_length;
u16 expander_change_count;
u8 reserved0[2];
u8 sas_format;
u8 reserved2[3];
u8 vendor_id[SAS_EXPANDER_VENDOR_ID_LEN] __nonstring;
u8 product_id[SAS_EXPANDER_PRODUCT_ID_LEN] __nonstring;
u8 product_rev[SAS_EXPANDER_PRODUCT_REV_LEN] __nonstring;
u8 component_vendor_id[SAS_EXPANDER_COMPONENT_VENDOR_ID_LEN] __nonstring;
u16 component_id;
u8 component_revision_id;
u8 reserved3;
u8 vendor_specific[8];
};
/**
* _transport_expander_report_manufacture - obtain SMP report_manufacture
* @ioc: per adapter object
* @sas_address: expander sas address
* @edev: the sas_expander_device object
* @port_id: Port ID number
*
* Fills in the sas_expander_device object when SMP port is created.
*
* Return: 0 for success, non-zero for failure.
*/
static int
_transport_expander_report_manufacture(struct MPT3SAS_ADAPTER *ioc,
u64 sas_address, struct sas_expander_device *edev, u8 port_id)
{
Mpi2SmpPassthroughRequest_t *mpi_request;
Mpi2SmpPassthroughReply_t *mpi_reply;
struct rep_manu_reply *manufacture_reply;
struct rep_manu_request *manufacture_request;
int rc;
u16 smid;
void *psge;
u8 issue_reset = 0;
void *data_out = NULL;
dma_addr_t data_out_dma;
dma_addr_t data_in_dma;
size_t data_in_sz;
size_t data_out_sz;
if (ioc->shost_recovery || ioc->pci_error_recovery) {
ioc_info(ioc, "%s: host reset in progress!\n", __func__);
return -EFAULT;
}
mutex_lock(&ioc->transport_cmds.mutex);
if (ioc->transport_cmds.status != MPT3_CMD_NOT_USED) {
ioc_err(ioc, "%s: transport_cmds in use\n", __func__);
rc = -EAGAIN;
goto out;
}
ioc->transport_cmds.status = MPT3_CMD_PENDING;
rc = mpt3sas_wait_for_ioc(ioc, IOC_OPERATIONAL_WAIT_COUNT);
if (rc)
goto out;
smid = mpt3sas_base_get_smid(ioc, ioc->transport_cb_idx);
if (!smid) {
ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
rc = -EAGAIN;
goto out;
}
rc = 0;
mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
ioc->transport_cmds.smid = smid;
data_out_sz = sizeof(struct rep_manu_request);
data_in_sz = sizeof(struct rep_manu_reply);
data_out = dma_alloc_coherent(&ioc->pdev->dev, data_out_sz + data_in_sz,
&data_out_dma, GFP_KERNEL);
if (!data_out) {
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/init.h`, `linux/errno.h`, `linux/sched.h`, `linux/workqueue.h`, `linux/delay.h`, `linux/pci.h`.
- Detected declarations: `struct rep_manu_request`, `struct rep_manu_reply`, `struct phy_error_log_request`, `struct phy_error_log_reply`, `struct phy_control_request`, `struct phy_control_reply`, `function _transport_get_port_id_by_sas_phy`, `function _transport_sas_node_find_by_sas_address`, `function _transport_get_port_id_by_rphy`, `function list_for_each_entry`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.