drivers/scsi/csiostor/csio_hw.c
Source file repositories/reference/linux-study-clean/drivers/scsi/csiostor/csio_hw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/csiostor/csio_hw.c- Extension
.c- Size
- 114914 bytes
- Lines
- 4435
- 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/pci.hlinux/pci_regs.hlinux/firmware.hlinux/stddef.hlinux/delay.hlinux/string.hlinux/compiler.hlinux/jiffies.hlinux/kernel.hlinux/log2.hcsio_hw.hcsio_lnode.hcsio_rnode.h
Detected Declarations
struct t4_vpd_hdrfunction csio_is_hw_readyfunction csio_is_hw_removingfunction csio_hw_wait_op_done_valfunction csio_hw_tp_wr_bits_indirectfunction csio_set_reg_fieldfunction csio_memory_writefunction csio_hw_seeprom_readfunction csio_hw_get_vpd_keyword_valfunction csio_pci_capabilityfunction csio_hw_get_vpd_paramsfunction csio_hw_sf1_readfunction csio_hw_sf1_writefunction csio_hw_flash_wait_opfunction csio_hw_read_flashfunction datafunction csio_hw_flash_erase_sectorsfunction csio_hw_print_fw_versionfunction csio_hw_get_fw_versionfunction csio_hw_get_tp_versionfunction csio_hw_fw_dloadfunction csio_hw_get_flash_paramsfunction csio_hw_dev_readyfunction csio_do_hellofunction csio_do_byefunction csio_do_resetfunction csio_hw_validate_capsfunction firmwarefunction csio_hw_fw_haltfunction csio_hw_fw_upgradefunction csio_get_device_paramsfunction csio_config_device_capsfunction fwcap_to_cc_fecfunction cc_to_fwcap_pausefunction cc_to_fwcap_fecfunction fwcap_to_fwspeedfunction fwcaps16_to_caps32function fwcaps32_to_caps16function lstatus_to_fwcapfunction csio_init_link_configfunction t4_handle_get_port_infofunction csio_link_l1cfgfunction t4_handle_get_port_infofunction csio_enable_portsfunction csio_get_fcoe_resinfofunction csio_hw_check_fwconfigfunction csio_hw_flash_configfunction csio_hw_use_fwconfig
Annotated Snippet
struct t4_vpd_hdr {
u8 id_tag;
u8 id_len[2];
u8 id_data[ID_LEN];
u8 vpdr_tag;
u8 vpdr_len[2];
};
/*
* csio_hw_get_vpd_keyword_val - Locates an information field keyword in
* the VPD
* @v: Pointer to buffered vpd data structure
* @kw: The keyword to search for
*
* Returns the value of the information field keyword or
* -EINVAL otherwise.
*/
static int
csio_hw_get_vpd_keyword_val(const struct t4_vpd_hdr *v, const char *kw)
{
int32_t i;
int32_t offset , len;
const uint8_t *buf = &v->id_tag;
const uint8_t *vpdr_len = &v->vpdr_tag;
offset = sizeof(struct t4_vpd_hdr);
len = (uint16_t)vpdr_len[1] + ((uint16_t)vpdr_len[2] << 8);
if (len + sizeof(struct t4_vpd_hdr) > VPD_LEN)
return -EINVAL;
for (i = offset; (i + VPD_INFO_FLD_HDR_SIZE) <= (offset + len);) {
if (memcmp(buf + i , kw, 2) == 0) {
i += VPD_INFO_FLD_HDR_SIZE;
return i;
}
i += VPD_INFO_FLD_HDR_SIZE + buf[i+2];
}
return -EINVAL;
}
static int
csio_pci_capability(struct pci_dev *pdev, int cap, int *pos)
{
*pos = pci_find_capability(pdev, cap);
if (*pos)
return 0;
return -1;
}
/*
* csio_hw_get_vpd_params - read VPD parameters from VPD EEPROM
* @hw: HW module
* @p: where to store the parameters
*
* Reads card parameters stored in VPD EEPROM.
*/
static int
csio_hw_get_vpd_params(struct csio_hw *hw, struct csio_vpd *p)
{
int i, ret, ec, sn, addr;
uint8_t *vpd, csum;
const struct t4_vpd_hdr *v;
/* To get around compilation warning from strstrip */
char __always_unused *s;
if (csio_is_valid_vpd(hw))
return 0;
ret = csio_pci_capability(hw->pdev, PCI_CAP_ID_VPD,
&hw->params.pci.vpd_cap_addr);
if (ret)
return -EINVAL;
vpd = kzalloc(VPD_LEN, GFP_ATOMIC);
if (vpd == NULL)
return -ENOMEM;
/*
* Card information normally starts at VPD_BASE but early cards had
* it at 0.
*/
ret = csio_hw_seeprom_read(hw, VPD_BASE, (uint32_t *)(vpd));
addr = *vpd == 0x82 ? VPD_BASE : VPD_BASE_OLD;
for (i = 0; i < VPD_LEN; i += 4) {
ret = csio_hw_seeprom_read(hw, addr + i, (uint32_t *)(vpd + i));
if (ret) {
Annotation
- Immediate include surface: `linux/pci.h`, `linux/pci_regs.h`, `linux/firmware.h`, `linux/stddef.h`, `linux/delay.h`, `linux/string.h`, `linux/compiler.h`, `linux/jiffies.h`.
- Detected declarations: `struct t4_vpd_hdr`, `function csio_is_hw_ready`, `function csio_is_hw_removing`, `function csio_hw_wait_op_done_val`, `function csio_hw_tp_wr_bits_indirect`, `function csio_set_reg_field`, `function csio_memory_write`, `function csio_hw_seeprom_read`, `function csio_hw_get_vpd_keyword_val`, `function csio_pci_capability`.
- 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.