drivers/scsi/qla2xxx/qla_mid.c
Source file repositories/reference/linux-study-clean/drivers/scsi/qla2xxx/qla_mid.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/qla2xxx/qla_mid.c- Extension
.c- Size
- 33450 bytes
- Lines
- 1292
- 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
qla_def.hqla_gbl.hqla_target.hlinux/moduleparam.hlinux/vmalloc.hlinux/slab.hlinux/list.hscsi/scsi_tcq.hscsi/scsicam.hlinux/delay.h
Detected Declarations
function Copyrightfunction qla24xx_allocate_vp_idfunction qla24xx_deallocate_vp_idfunction qla24xx_find_vhost_by_namefunction qla2x00_mark_vp_devices_deadfunction list_for_each_entryfunction qla24xx_disable_vpfunction qla24xx_enable_vpfunction atomic_readfunction qla24xx_configure_vpfunction qla2x00_alert_all_vpsfunction qla2x00_vp_abort_ispfunction qla2x00_do_dpc_vpfunction qla2x00_do_dpc_all_vpsfunction qla24xx_vport_create_req_sanity_checkfunction qla24xx_create_vhostfunction qla25xx_free_req_quefunction qla25xx_free_rsp_quefunction qla25xx_delete_req_quefunction qla25xx_delete_rsp_quefunction qla25xx_delete_queuesfunction qla25xx_create_req_quefunction qla_do_workfunction qla25xx_create_rsp_quefunction qla_ctrlvp_sp_donefunction qla24xx_control_vpfunction qla_update_vp_mapfunction qla_update_host_mapfunction qla_create_buf_poolfunction qla_free_buf_poolfunction qla_get_buffunction qla_trim_buffunction __qla_adjust_buffunction qla_put_buffunction qla_adjust_buf
Annotated Snippet
if (atomic_read(&vha->vref_count) == 0) {
list_del(&vha->list);
qla_update_vp_map(vha, RESET_VP_IDX);
bailout = 1;
}
spin_unlock_irqrestore(&ha->vport_slock, flags);
if (bailout)
break;
else
msleep(20);
}
if (!bailout) {
ql_log(ql_log_info, vha, 0xfffa,
"vha->vref_count=%u timeout\n", vha->vref_count.counter);
spin_lock_irqsave(&ha->vport_slock, flags);
list_del(&vha->list);
qla_update_vp_map(vha, RESET_VP_IDX);
spin_unlock_irqrestore(&ha->vport_slock, flags);
}
vp_id = vha->vp_idx;
ha->num_vhosts--;
clear_bit(vp_id, ha->vp_idx_map);
mutex_unlock(&ha->vport_lock);
}
static scsi_qla_host_t *
qla24xx_find_vhost_by_name(struct qla_hw_data *ha, uint8_t *port_name)
{
scsi_qla_host_t *vha;
struct scsi_qla_host *tvha;
unsigned long flags;
spin_lock_irqsave(&ha->vport_slock, flags);
/* Locate matching device in database. */
list_for_each_entry_safe(vha, tvha, &ha->vp_list, list) {
if (!memcmp(port_name, vha->port_name, WWN_SIZE)) {
spin_unlock_irqrestore(&ha->vport_slock, flags);
return vha;
}
}
spin_unlock_irqrestore(&ha->vport_slock, flags);
return NULL;
}
/*
* qla2x00_mark_vp_devices_dead
* Updates fcport state when device goes offline.
*
* Input:
* ha = adapter block pointer.
* fcport = port structure pointer.
*
* Return:
* None.
*
* Context:
*/
static void
qla2x00_mark_vp_devices_dead(scsi_qla_host_t *vha)
{
/*
* !!! NOTE !!!
* This function, if called in contexts other than vp create, disable
* or delete, please make sure this is synchronized with the
* delete thread.
*/
fc_port_t *fcport;
list_for_each_entry(fcport, &vha->vp_fcports, list) {
ql_dbg(ql_dbg_vport, vha, 0xa001,
"Marking port dead, loop_id=0x%04x : %x.\n",
fcport->loop_id, fcport->vha->vp_idx);
qla2x00_mark_device_lost(vha, fcport, 0);
qla2x00_set_fcport_state(fcport, FCS_UNCONFIGURED);
}
}
int
qla24xx_disable_vp(scsi_qla_host_t *vha)
{
unsigned long flags;
int ret = QLA_SUCCESS;
fc_port_t *fcport;
if (vha->hw->flags.edif_enabled) {
if (DBELL_ACTIVE(vha))
Annotation
- Immediate include surface: `qla_def.h`, `qla_gbl.h`, `qla_target.h`, `linux/moduleparam.h`, `linux/vmalloc.h`, `linux/slab.h`, `linux/list.h`, `scsi/scsi_tcq.h`.
- Detected declarations: `function Copyright`, `function qla24xx_allocate_vp_id`, `function qla24xx_deallocate_vp_id`, `function qla24xx_find_vhost_by_name`, `function qla2x00_mark_vp_devices_dead`, `function list_for_each_entry`, `function qla24xx_disable_vp`, `function qla24xx_enable_vp`, `function atomic_read`, `function qla24xx_configure_vp`.
- 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.