drivers/net/ethernet/qlogic/qed/qed_ll2.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/qlogic/qed/qed_ll2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/qlogic/qed/qed_ll2.c- Extension
.c- Size
- 78670 bytes
- Lines
- 2822
- 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.hasm/byteorder.hlinux/dma-mapping.hlinux/if_vlan.hlinux/kernel.hlinux/pci.hlinux/slab.hlinux/stddef.hlinux/workqueue.hnet/ipv6.hlinux/bitops.hlinux/delay.hlinux/errno.hlinux/etherdevice.hlinux/io.hlinux/list.hlinux/mutex.hlinux/spinlock.hlinux/string.hlinux/qed/qed_ll2_if.hqed.hqed_cxt.hqed_dev_api.hqed_hsi.hqed_iro_hsi.hqed_hw.hqed_int.hqed_ll2.hqed_mcp.hqed_ooo.hqed_reg_addr.hqed_sp.h
Detected Declarations
struct qed_cb_ll2_infostruct qed_ll2_bufferfunction qed_ll2_handle_to_stats_idfunction qed_ll2b_complete_tx_packetfunction qed_ll2_alloc_bufferfunction qed_ll2_dealloc_bufferfunction qed_ll2_kill_buffersfunction qed_ll2b_complete_rx_packetfunction qed_ll2_txq_flushfunction qed_ll2_txq_completionfunction qed_ll2_rxq_parse_gsifunction qed_ll2_rxq_parse_regfunction qed_ll2_handle_slowpathfunction qed_ll2_rxq_handle_completionfunction qed_ll2_rxq_completionfunction qed_ll2_rxq_flushfunction qed_ll2_lb_rxq_handler_slowpathfunction qed_ll2_lb_rxq_handlerfunction qed_ooo_submit_tx_buffersfunction qed_ooo_submit_rx_buffersfunction qed_ll2_lb_rxq_completionfunction qed_ll2_lb_txq_completionfunction qed_ll2_stop_ooofunction qed_sp_ll2_rx_queue_startfunction qed_sp_ll2_tx_queue_startfunction qed_sp_ll2_rx_queue_stopfunction qed_sp_ll2_tx_queue_stopfunction qed_ll2_acquire_connection_rxfunction qed_ll2_acquire_connection_txfunction qed_ll2_acquire_connection_ooofunction qed_ll2_set_cbsfunction _qed_ll2_calc_allowed_connsfunction qed_ll2_get_error_choicefunction qed_ll2_acquire_connectionfunction qed_ll2_establish_connection_rxfunction qed_ll2_establish_connection_ooofunction qed_ll2_handle_to_queue_idfunction qed_ll2_establish_connectionfunction qed_ll2_post_rx_buffer_notify_fwfunction qed_ll2_post_rx_bufferfunction qed_ll2_prepare_tx_packet_setfunction qed_ll2_prepare_tx_packet_set_bdfunction qed_ll2_tx_packet_notifyfunction qed_ll2_prepare_tx_packetfunction qed_ll2_set_fragment_of_tx_packetfunction qed_ll2_terminate_connectionfunction qed_ll2_release_connection_ooofunction qed_ll2_release_connection
Annotated Snippet
struct qed_cb_ll2_info {
int rx_cnt;
u32 rx_size;
u8 handle;
/* Lock protecting LL2 buffer lists in sleepless context */
spinlock_t lock;
struct list_head list;
const struct qed_ll2_cb_ops *cbs;
void *cb_cookie;
};
struct qed_ll2_buffer {
struct list_head list;
void *data;
dma_addr_t phys_addr;
};
static u8 qed_ll2_handle_to_stats_id(struct qed_hwfn *p_hwfn,
u8 ll2_queue_type, u8 qid)
{
u8 stats_id;
/* For legacy (RAM based) queues, the stats_id will be set as the
* queue_id. Otherwise (context based queue), it will be set to
* the "abs_pf_id" offset from the end of the RAM based queue IDs.
* If the final value exceeds the total counters amount, return
* INVALID value to indicate that the stats for this connection should
* be disabled.
*/
if (ll2_queue_type == QED_LL2_RX_TYPE_LEGACY)
stats_id = qid;
else
stats_id = MAX_NUM_LL2_RX_RAM_QUEUES + p_hwfn->abs_pf_id;
if (stats_id < MAX_NUM_LL2_TX_STATS_COUNTERS)
return stats_id;
else
return QED_LL2_INVALID_STATS_ID;
}
static void qed_ll2b_complete_tx_packet(void *cxt,
u8 connection_handle,
void *cookie,
dma_addr_t first_frag_addr,
bool b_last_fragment,
bool b_last_packet)
{
struct qed_hwfn *p_hwfn = cxt;
struct qed_dev *cdev = p_hwfn->cdev;
struct sk_buff *skb = cookie;
/* All we need to do is release the mapping */
dma_unmap_single(&p_hwfn->cdev->pdev->dev, first_frag_addr,
skb_headlen(skb), DMA_TO_DEVICE);
if (cdev->ll2->cbs && cdev->ll2->cbs->tx_cb)
cdev->ll2->cbs->tx_cb(cdev->ll2->cb_cookie, skb,
b_last_fragment);
dev_kfree_skb_any(skb);
}
static int qed_ll2_alloc_buffer(struct qed_dev *cdev,
u8 **data, dma_addr_t *phys_addr)
{
size_t size = cdev->ll2->rx_size + NET_SKB_PAD +
SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
*data = kmalloc(size, GFP_ATOMIC);
if (!(*data)) {
DP_INFO(cdev, "Failed to allocate LL2 buffer data\n");
return -ENOMEM;
}
*phys_addr = dma_map_single(&cdev->pdev->dev,
((*data) + NET_SKB_PAD),
cdev->ll2->rx_size, DMA_FROM_DEVICE);
if (dma_mapping_error(&cdev->pdev->dev, *phys_addr)) {
DP_INFO(cdev, "Failed to map LL2 buffer data\n");
kfree((*data));
return -ENOMEM;
}
return 0;
}
static int qed_ll2_dealloc_buffer(struct qed_dev *cdev,
struct qed_ll2_buffer *buffer)
Annotation
- Immediate include surface: `linux/types.h`, `asm/byteorder.h`, `linux/dma-mapping.h`, `linux/if_vlan.h`, `linux/kernel.h`, `linux/pci.h`, `linux/slab.h`, `linux/stddef.h`.
- Detected declarations: `struct qed_cb_ll2_info`, `struct qed_ll2_buffer`, `function qed_ll2_handle_to_stats_id`, `function qed_ll2b_complete_tx_packet`, `function qed_ll2_alloc_buffer`, `function qed_ll2_dealloc_buffer`, `function qed_ll2_kill_buffers`, `function qed_ll2b_complete_rx_packet`, `function qed_ll2_txq_flush`, `function qed_ll2_txq_completion`.
- 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.