drivers/infiniband/hw/hfi1/qsfp.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/hfi1/qsfp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/hfi1/qsfp.c- Extension
.c- Size
- 20594 bytes
- Lines
- 797
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- 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.
- 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/delay.hlinux/pci.hlinux/vmalloc.hhfi.h
Detected Declarations
function Copyrightfunction i2c_oe_csrfunction hfi1_setsdafunction hfi1_setsclfunction hfi1_getsdafunction hfi1_getsclfunction set_up_i2cfunction clean_i2c_busfunction clean_up_i2cfunction i2c_bus_writefunction i2c_bus_readfunction __i2c_writefunction i2c_writefunction __i2c_readfunction i2c_readfunction qsfp_writefunction qsfp_readfunction one_qsfp_readfunction bytefunction integerfunction qsfp_mod_presentfunction get_cable_infofunction qsfp_dump
Annotated Snippet
if (ret) {
hfi1_dev_porterr(ppd->dd, ppd->port,
"QSFP chain %d can't write QSFP_PAGE_SELECT_BYTE: %d\n",
target, ret);
break;
}
offset = addr % QSFP_PAGESIZE;
nwrite = len - count;
/* truncate write to boundary if crossing boundary */
if (((addr % QSFP_RW_BOUNDARY) + nwrite) > QSFP_RW_BOUNDARY)
nwrite = QSFP_RW_BOUNDARY - (addr % QSFP_RW_BOUNDARY);
ret = __i2c_write(ppd, target, QSFP_DEV | QSFP_OFFSET_SIZE,
offset, bp + count, nwrite);
/* QSFPs require a 5-10msec delay after write operations */
mdelay(5);
if (ret) /* stop on error */
break;
count += nwrite;
addr += nwrite;
}
if (ret < 0)
return ret;
return count;
}
/*
* Access page n, offset m of QSFP memory as defined by SFF 8636
* by reading @addr = ((256 * n) + m)
*
* Caller must hold the i2c chain resource.
*
* Return the number of bytes read or -errno.
*/
int qsfp_read(struct hfi1_pportdata *ppd, u32 target, int addr, void *bp,
int len)
{
int count = 0;
int offset;
int nread;
int ret = 0;
u8 page;
if (!check_chip_resource(ppd->dd, i2c_target(target), __func__))
return -EACCES;
while (count < len) {
/*
* Set the qsfp page based on a zero-based address
* and a page size of QSFP_PAGESIZE bytes.
*/
page = (u8)(addr / QSFP_PAGESIZE);
ret = __i2c_write(ppd, target, QSFP_DEV | QSFP_OFFSET_SIZE,
QSFP_PAGE_SELECT_BYTE_OFFS, &page, 1);
/* QSFPs require a 5-10msec delay after write operations */
mdelay(5);
if (ret) {
hfi1_dev_porterr(ppd->dd, ppd->port,
"QSFP chain %d can't write QSFP_PAGE_SELECT_BYTE: %d\n",
target, ret);
break;
}
offset = addr % QSFP_PAGESIZE;
nread = len - count;
/* truncate read to boundary if crossing boundary */
if (((addr % QSFP_RW_BOUNDARY) + nread) > QSFP_RW_BOUNDARY)
nread = QSFP_RW_BOUNDARY - (addr % QSFP_RW_BOUNDARY);
ret = __i2c_read(ppd, target, QSFP_DEV | QSFP_OFFSET_SIZE,
offset, bp + count, nread);
if (ret) /* stop on error */
break;
count += nread;
addr += nread;
}
if (ret < 0)
return ret;
return count;
}
/*
* Perform a stand-alone single QSFP read. Acquire the resource, do the
* read, then release the resource.
*/
Annotation
- Immediate include surface: `linux/delay.h`, `linux/pci.h`, `linux/vmalloc.h`, `hfi.h`.
- Detected declarations: `function Copyright`, `function i2c_oe_csr`, `function hfi1_setsda`, `function hfi1_setscl`, `function hfi1_getsda`, `function hfi1_getscl`, `function set_up_i2c`, `function clean_i2c_bus`, `function clean_up_i2c`, `function i2c_bus_write`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: source 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.