drivers/scsi/qedi/qedi_main.c
Source file repositories/reference/linux-study-clean/drivers/scsi/qedi/qedi_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/qedi/qedi_main.c- Extension
.c- Size
- 74183 bytes
- Lines
- 2956
- Domain
- Driver Families
- Bucket
- drivers/scsi
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/pci.hlinux/kernel.hlinux/if_arp.hscsi/iscsi_if.hlinux/inet.hnet/arp.hlinux/list.hlinux/kthread.hlinux/mm.hlinux/if_vlan.hlinux/cpu.hlinux/iscsi_boot_sysfs.hscsi/scsi_cmnd.hscsi/scsi_device.hscsi/scsi_eh.hscsi/scsi_host.hscsi/scsi.hqedi.hqedi_gbl.hqedi_iscsi.h
Detected Declarations
function qedi_iscsi_event_cbfunction qedi_uio_openfunction qedi_uio_closefunction __qedi_free_uio_ringsfunction __qedi_free_uiofunction qedi_free_uiofunction qedi_reset_uio_ringsfunction __qedi_alloc_uio_ringsfunction qedi_alloc_uio_ringsfunction list_for_each_entryfunction qedi_init_uiofunction qedi_alloc_and_init_sbfunction qedi_free_sbfunction qedi_free_fpfunction qedi_destroy_fpfunction qedi_alloc_fpfunction qedi_int_fpfunction qedi_prepare_fpfunction qedi_setup_cid_quefunction qedi_release_cid_quefunction qedi_init_id_tblfunction qedi_free_id_tblfunction qedi_alloc_idfunction qedi_alloc_new_idfunction qedi_free_idfunction qedi_cm_free_memfunction qedi_cm_alloc_memfunction qedi_ll2_rxfunction qedi_ll2_process_skbfunction qedi_ll2_free_skbsfunction qedi_ll2_recv_threadfunction list_for_each_entry_safefunction qedi_set_iscsi_pf_paramfunction qedi_free_iscsi_pf_paramfunction qedi_get_boot_tgt_infofunction qedi_find_boot_infofunction qedi_get_generic_tlv_datafunction qedi_get_protocol_tlv_datafunction qedi_schedule_hw_err_handlerfunction qedi_schedule_recovery_handlerfunction qedi_set_conn_recoveryfunction qedi_link_updatefunction qedi_queue_cqefunction qedi_process_completionsfunction qedi_fp_has_workfunction qedi_msix_handlerfunction qedi_simd_int_handlerfunction qedi_sync_free_irqs
Annotated Snippet
static struct pci_driver qedi_pci_driver;
static DEFINE_PER_CPU(struct qedi_percpu_s, qedi_percpu);
static LIST_HEAD(qedi_udev_list);
/* Static function declaration */
static int qedi_alloc_global_queues(struct qedi_ctx *qedi);
static void qedi_free_global_queues(struct qedi_ctx *qedi);
static struct qedi_cmd *qedi_get_cmd_from_tid(struct qedi_ctx *qedi, u32 tid);
static void qedi_reset_uio_rings(struct qedi_uio_dev *udev);
static void qedi_ll2_free_skbs(struct qedi_ctx *qedi);
static struct nvm_iscsi_block *qedi_get_nvram_block(struct qedi_ctx *qedi);
static void qedi_recovery_handler(struct work_struct *work);
static void qedi_schedule_hw_err_handler(void *dev,
enum qed_hw_err_type err_type);
static int qedi_suspend(struct pci_dev *pdev, pm_message_t state);
static int qedi_iscsi_event_cb(void *context, u8 fw_event_code, void *fw_handle)
{
struct qedi_ctx *qedi;
struct qedi_endpoint *qedi_ep;
struct iscsi_eqe_data *data;
int rval = 0;
if (!context || !fw_handle) {
QEDI_ERR(NULL, "Recv event with ctx NULL\n");
return -EINVAL;
}
qedi = (struct qedi_ctx *)context;
QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO,
"Recv Event %d fw_handle %p\n", fw_event_code, fw_handle);
data = (struct iscsi_eqe_data *)fw_handle;
QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO,
"icid=0x%x conn_id=0x%x err-code=0x%x error-pdu-opcode-reserved=0x%x\n",
data->icid, data->conn_id, data->error_code,
data->error_pdu_opcode_reserved);
qedi_ep = qedi->ep_tbl[data->icid];
if (!qedi_ep) {
QEDI_WARN(&qedi->dbg_ctx,
"Cannot process event, ep already disconnected, cid=0x%x\n",
data->icid);
WARN_ON(1);
return -ENODEV;
}
switch (fw_event_code) {
case ISCSI_EVENT_TYPE_ASYN_CONNECT_COMPLETE:
if (qedi_ep->state == EP_STATE_OFLDCONN_START)
qedi_ep->state = EP_STATE_OFLDCONN_COMPL;
wake_up_interruptible(&qedi_ep->tcp_ofld_wait);
break;
case ISCSI_EVENT_TYPE_ASYN_TERMINATE_DONE:
qedi_ep->state = EP_STATE_DISCONN_COMPL;
wake_up_interruptible(&qedi_ep->tcp_ofld_wait);
break;
case ISCSI_EVENT_TYPE_ISCSI_CONN_ERROR:
qedi_process_iscsi_error(qedi_ep, data);
break;
case ISCSI_EVENT_TYPE_ASYN_ABORT_RCVD:
case ISCSI_EVENT_TYPE_ASYN_SYN_RCVD:
case ISCSI_EVENT_TYPE_ASYN_MAX_RT_TIME:
case ISCSI_EVENT_TYPE_ASYN_MAX_RT_CNT:
case ISCSI_EVENT_TYPE_ASYN_MAX_KA_PROBES_CNT:
case ISCSI_EVENT_TYPE_ASYN_FIN_WAIT2:
case ISCSI_EVENT_TYPE_TCP_CONN_ERROR:
qedi_process_tcp_error(qedi_ep, data);
break;
default:
QEDI_ERR(&qedi->dbg_ctx, "Recv Unknown Event %u\n",
fw_event_code);
}
return rval;
}
static int qedi_uio_open(struct uio_info *uinfo, struct inode *inode)
{
struct qedi_uio_dev *udev = uinfo->priv;
struct qedi_ctx *qedi = udev->qedi;
if (!capable(CAP_NET_ADMIN))
return -EPERM;
if (udev->uio_dev != -1)
return -EBUSY;
rtnl_lock();
Annotation
- Immediate include surface: `linux/module.h`, `linux/pci.h`, `linux/kernel.h`, `linux/if_arp.h`, `scsi/iscsi_if.h`, `linux/inet.h`, `net/arp.h`, `linux/list.h`.
- Detected declarations: `function qedi_iscsi_event_cb`, `function qedi_uio_open`, `function qedi_uio_close`, `function __qedi_free_uio_rings`, `function __qedi_free_uio`, `function qedi_free_uio`, `function qedi_reset_uio_rings`, `function __qedi_alloc_uio_rings`, `function qedi_alloc_uio_rings`, `function list_for_each_entry`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: pattern 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.