drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c- Extension
.c- Size
- 55488 bytes
- Lines
- 2161
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/interrupt.hlinux/pci.hnet/page_pool/helpers.hnet/tso.hlinux/bitfield.hlinux/dcbnl.hnet/xfrm.hotx2_reg.hotx2_common.hotx2_struct.hcn10k.hotx2_xsk.h
Detected Declarations
function Copyrightfunction otx2_nix_rq_op_statsfunction otx2_nix_sq_op_statsfunction otx2_update_lmac_statsfunction otx2_update_lmac_fec_statsfunction otx2_update_rq_statsfunction otx2_update_sq_statsfunction otx2_get_dev_statsfunction otx2_get_stats64function otx2_hw_set_mac_addrfunction otx2_hw_get_mac_addrfunction otx2_set_mac_addressfunction otx2_hw_set_mtufunction otx2_config_pause_frmfunction otx2_set_flowkey_cfgfunction otx2_set_rss_tablefunction otx2_set_rss_keyfunction otx2_rss_initfunction otx2_setup_udp_segmentationfunction otx2_setup_segmentationfunction otx2_config_irq_coalescingfunction otx2_alloc_pool_buffunction __otx2_alloc_rbuffunction otx2_alloc_rbuffunction otx2_alloc_bufferfunction otx2_tx_timeoutfunction otx2_get_mac_from_affunction otx2_txschq_configfunction otx2_smq_flushfunction otx2_txsch_allocfunction otx2_txschq_free_onefunction otx2_txschq_stopfunction otx2_sqb_flushfunction emptinessfunction otx2_sq_aq_initfunction otx2_sq_initfunction otx2_cq_initfunction otx2_pool_refill_taskfunction otx2_config_nix_queuesfunction otx2_config_nixfunction otx2_sq_free_sqbsfunction otx2_free_bufsfunction otx2_free_aura_ptrfunction otx2_aura_pool_freefunction otx2_aura_initfunction otx2_aura_aq_initfunction otx2_pool_initfunction otx2_pool_aq_init
Annotated Snippet
if (!aq) {
/* The shared memory buffer can be full.
* Flush it and retry
*/
err = otx2_sync_mbox_msg(mbox);
if (err) {
mutex_unlock(&mbox->lock);
return err;
}
aq = otx2_mbox_alloc_msg_nix_aq_enq(mbox);
if (!aq) {
mutex_unlock(&mbox->lock);
return -ENOMEM;
}
}
aq->rss.rq = ind_tbl[idx];
/* Fill AQ info */
aq->qidx = index + idx;
aq->ctype = NIX_AQ_CTYPE_RSS;
aq->op = NIX_AQ_INSTOP_INIT;
}
err = otx2_sync_mbox_msg(mbox);
mutex_unlock(&mbox->lock);
return err;
}
void otx2_set_rss_key(struct otx2_nic *pfvf)
{
struct otx2_rss_info *rss = &pfvf->hw.rss_info;
u64 *key = (u64 *)&rss->key[4];
int idx;
/* 352bit or 44byte key needs to be configured as below
* NIX_LF_RX_SECRETX0 = key<351:288>
* NIX_LF_RX_SECRETX1 = key<287:224>
* NIX_LF_RX_SECRETX2 = key<223:160>
* NIX_LF_RX_SECRETX3 = key<159:96>
* NIX_LF_RX_SECRETX4 = key<95:32>
* NIX_LF_RX_SECRETX5<63:32> = key<31:0>
*/
otx2_write64(pfvf, NIX_LF_RX_SECRETX(5),
(u64)(*((u32 *)&rss->key)) << 32);
idx = sizeof(rss->key) / sizeof(u64);
while (idx > 0) {
idx--;
otx2_write64(pfvf, NIX_LF_RX_SECRETX(idx), *key++);
}
}
int otx2_rss_init(struct otx2_nic *pfvf)
{
struct otx2_rss_info *rss = &pfvf->hw.rss_info;
int idx, ret = 0;
rss->rss_size = sizeof(*rss->ind_tbl);
/* Init RSS key if it is not setup already */
if (!rss->enable)
netdev_rss_key_fill(rss->key, sizeof(rss->key));
otx2_set_rss_key(pfvf);
if (!netif_is_rxfh_configured(pfvf->netdev))
for (idx = 0; idx < rss->rss_size; idx++)
rss->ind_tbl[idx] =
ethtool_rxfh_indir_default(idx,
pfvf->hw.rx_queues);
ret = otx2_set_rss_table(pfvf, DEFAULT_RSS_CONTEXT_GROUP, NULL);
if (ret)
return ret;
/* Flowkey or hash config to be used for generating flow tag */
rss->flowkey_cfg = rss->enable ? rss->flowkey_cfg :
NIX_FLOW_KEY_TYPE_IPV4 | NIX_FLOW_KEY_TYPE_IPV6 |
NIX_FLOW_KEY_TYPE_TCP | NIX_FLOW_KEY_TYPE_UDP |
NIX_FLOW_KEY_TYPE_SCTP | NIX_FLOW_KEY_TYPE_VLAN |
NIX_FLOW_KEY_TYPE_IPV4_PROTO;
ret = otx2_set_flowkey_cfg(pfvf);
if (ret)
return ret;
rss->enable = true;
return 0;
}
/* Setup UDP segmentation algorithm in HW */
static void otx2_setup_udp_segmentation(struct nix_lso_format_cfg *lso, bool v4)
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/pci.h`, `net/page_pool/helpers.h`, `net/tso.h`, `linux/bitfield.h`, `linux/dcbnl.h`, `net/xfrm.h`, `otx2_reg.h`.
- Detected declarations: `function Copyright`, `function otx2_nix_rq_op_stats`, `function otx2_nix_sq_op_stats`, `function otx2_update_lmac_stats`, `function otx2_update_lmac_fec_stats`, `function otx2_update_rq_stats`, `function otx2_update_sq_stats`, `function otx2_get_dev_stats`, `function otx2_get_stats64`, `function otx2_hw_set_mac_addr`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration 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.