drivers/net/ethernet/qlogic/qed/qed_hw.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/qlogic/qed/qed_hw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/qlogic/qed/qed_hw.c- Extension
.c- Size
- 25685 bytes
- Lines
- 923
- Domain
- Driver Families
- Bucket
- drivers/net
- 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/types.hlinux/io.hlinux/delay.hlinux/dma-mapping.hlinux/errno.hlinux/kernel.hlinux/list.hlinux/mutex.hlinux/pci.hlinux/slab.hlinux/spinlock.hlinux/string.hlinux/qed/qed_chain.hqed.hqed_hsi.hqed_hw.hqed_reg_addr.hqed_sriov.h
Detected Declarations
struct qed_pttstruct qed_ptt_poolfunction qed_ptt_pool_allocfunction qed_ptt_pool_freefunction qed_ptt_releasefunction qed_ptt_get_hw_addrfunction qed_ptt_config_addrfunction qed_ptt_get_bar_addrfunction qed_ptt_set_winfunction qed_set_pttfunction qed_wrfunction qed_rdfunction qed_memcpy_hwfunction qed_memcpy_fromfunction qed_memcpy_tofunction qed_fid_pretendfunction qed_port_pretendfunction qed_port_unpretendfunction qed_port_fid_pretendfunction qed_vfid_to_concretefunction qed_dmae_opcodefunction qed_dmae_idx_to_go_cmdfunction qed_dmae_post_commandfunction qed_dmae_info_allocfunction qed_dmae_info_freefunction qed_dmae_operation_waitfunction qed_dmae_execute_sub_operationfunction qed_dmae_execute_commandfunction qed_dmae_host2grcfunction qed_dmae_grc2hostfunction qed_dmae_host2hostfunction qed_hw_err_notifyfunction qed_dmae_sanity
Annotated Snippet
struct qed_ptt {
struct list_head list_entry;
unsigned int idx;
struct pxp_ptt_entry pxp;
u8 hwfn_id;
};
struct qed_ptt_pool {
struct list_head free_list;
spinlock_t lock; /* ptt synchronized access */
struct qed_ptt ptts[PXP_EXTERNAL_BAR_PF_WINDOW_NUM];
};
int qed_ptt_pool_alloc(struct qed_hwfn *p_hwfn)
{
struct qed_ptt_pool *p_pool = kmalloc_obj(*p_pool);
int i;
if (!p_pool)
return -ENOMEM;
INIT_LIST_HEAD(&p_pool->free_list);
for (i = 0; i < PXP_EXTERNAL_BAR_PF_WINDOW_NUM; i++) {
p_pool->ptts[i].idx = i;
p_pool->ptts[i].pxp.offset = QED_BAR_INVALID_OFFSET;
p_pool->ptts[i].pxp.pretend.control = 0;
p_pool->ptts[i].hwfn_id = p_hwfn->my_id;
if (i >= RESERVED_PTT_MAX)
list_add(&p_pool->ptts[i].list_entry,
&p_pool->free_list);
}
p_hwfn->p_ptt_pool = p_pool;
spin_lock_init(&p_pool->lock);
return 0;
}
void qed_ptt_pool_free(struct qed_hwfn *p_hwfn)
{
kfree(p_hwfn->p_ptt_pool);
p_hwfn->p_ptt_pool = NULL;
}
struct qed_ptt *qed_ptt_acquire(struct qed_hwfn *p_hwfn)
{
return qed_ptt_acquire_context(p_hwfn, false);
}
struct qed_ptt *qed_ptt_acquire_context(struct qed_hwfn *p_hwfn, bool is_atomic)
{
struct qed_ptt *p_ptt;
unsigned int i, count;
if (is_atomic)
count = QED_BAR_ACQUIRE_TIMEOUT_UDELAY_CNT;
else
count = QED_BAR_ACQUIRE_TIMEOUT_USLEEP_CNT;
/* Take the free PTT from the list */
for (i = 0; i < count; i++) {
spin_lock_bh(&p_hwfn->p_ptt_pool->lock);
if (!list_empty(&p_hwfn->p_ptt_pool->free_list)) {
p_ptt = list_first_entry(&p_hwfn->p_ptt_pool->free_list,
struct qed_ptt, list_entry);
list_del(&p_ptt->list_entry);
spin_unlock_bh(&p_hwfn->p_ptt_pool->lock);
DP_VERBOSE(p_hwfn, NETIF_MSG_HW,
"allocated ptt %d\n", p_ptt->idx);
return p_ptt;
}
spin_unlock_bh(&p_hwfn->p_ptt_pool->lock);
if (is_atomic)
udelay(QED_BAR_ACQUIRE_TIMEOUT_UDELAY);
else
usleep_range(QED_BAR_ACQUIRE_TIMEOUT_USLEEP,
QED_BAR_ACQUIRE_TIMEOUT_USLEEP * 2);
}
DP_NOTICE(p_hwfn, "PTT acquire timeout - failed to allocate PTT\n");
return NULL;
}
void qed_ptt_release(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
{
Annotation
- Immediate include surface: `linux/types.h`, `linux/io.h`, `linux/delay.h`, `linux/dma-mapping.h`, `linux/errno.h`, `linux/kernel.h`, `linux/list.h`, `linux/mutex.h`.
- Detected declarations: `struct qed_ptt`, `struct qed_ptt_pool`, `function qed_ptt_pool_alloc`, `function qed_ptt_pool_free`, `function qed_ptt_release`, `function qed_ptt_get_hw_addr`, `function qed_ptt_config_addr`, `function qed_ptt_get_bar_addr`, `function qed_ptt_set_win`, `function qed_set_ptt`.
- Atlas domain: Driver Families / drivers/net.
- 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.