drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c- Extension
.c- Size
- 44659 bytes
- Lines
- 1674
- 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.
- 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/netdevice.hlinux/etherdevice.hlinux/inetdevice.hlinux/rhashtable.hlinux/bitfield.hnet/flow_dissector.hnet/pkt_cls.hnet/tc_act/tc_gact.hnet/tc_act/tc_mirred.hnet/tc_act/tc_vlan.hnet/ipv6.hcn10k.hotx2_common.hqos.h
Detected Declarations
function Copyrightfunction otx2_get_egress_rate_cfgfunction otx2_get_txschq_rate_regvalfunction otx2_set_matchall_egress_ratefunction otx2_tc_validate_flowfunction otx2_policer_validatefunction otx2_tc_egress_matchall_installfunction otx2_tc_egress_matchall_deletefunction otx2_tc_act_set_hw_policefunction otx2_tc_act_set_policefunction otx2_tc_update_mcastfunction otx2_tc_parse_actionsfunction flow_action_for_eachfunction otx2_tc_process_vlanfunction flow_action_for_eachfunction otx2_tc_prepare_flowfunction for_each_set_bitfunction otx2_destroy_tc_flow_listfunction list_for_each_entry_safefunction otx2_tc_get_entry_by_cookiefunction list_for_each_entryfunction otx2_tc_get_entry_by_indexfunction list_for_each_entryfunction otx2_tc_del_from_flow_listfunction list_for_each_safefunction otx2_tc_add_to_flow_listfunction list_for_each_safefunction otx2_add_mcam_flow_entryfunction otx2_del_mcam_flow_entryfunction otx2_tc_update_mcam_table_del_reqfunction list_for_each_safefunction otx2_tc_update_mcam_table_add_reqfunction otx2_tc_update_mcam_tablefunction otx2_tc_del_flowfunction otx2_tc_add_flowfunction otx2_tc_get_flow_statsfunction otx2_setup_tc_cls_flowerfunction otx2_tc_ingress_matchall_installfunction otx2_tc_ingress_matchall_deletefunction otx2_setup_tc_ingress_matchallfunction otx2_setup_tc_block_ingress_cbfunction otx2_setup_tc_egress_matchallfunction otx2_setup_tc_block_egress_cbfunction otx2_setup_tc_blockfunction otx2_setup_tcfunction otx2_init_tcfunction otx2_shutdown_tcfunction otx2_tc_config_ingress_rule
Annotated Snippet
if (entry->police.rate_pkt_ps) {
NL_SET_ERR_MSG_MOD(extack, "QoS offload not support packets per second");
return -EOPNOTSUPP;
}
err = otx2_set_matchall_egress_rate(nic, entry->police.burst,
otx2_convert_rate(entry->police.rate_bytes_ps));
if (err)
return err;
nic->flags |= OTX2_FLAG_TC_MATCHALL_EGRESS_ENABLED;
break;
default:
NL_SET_ERR_MSG_MOD(extack,
"Only police action is supported with Egress MATCHALL offload");
return -EOPNOTSUPP;
}
return 0;
}
static int otx2_tc_egress_matchall_delete(struct otx2_nic *nic,
struct tc_cls_matchall_offload *cls)
{
struct netlink_ext_ack *extack = cls->common.extack;
int err;
if (nic->flags & OTX2_FLAG_INTF_DOWN) {
NL_SET_ERR_MSG_MOD(extack, "Interface not initialized");
return -EINVAL;
}
err = otx2_set_matchall_egress_rate(nic, 0, 0);
nic->flags &= ~OTX2_FLAG_TC_MATCHALL_EGRESS_ENABLED;
return err;
}
static int otx2_tc_act_set_hw_police(struct otx2_nic *nic,
struct otx2_tc_flow *node)
{
int rc;
mutex_lock(&nic->mbox.lock);
rc = cn10k_alloc_leaf_profile(nic, &node->leaf_profile);
if (rc) {
mutex_unlock(&nic->mbox.lock);
return rc;
}
rc = cn10k_set_ipolicer_rate(nic, node->leaf_profile,
node->burst, node->rate, node->is_pps);
if (rc)
goto free_leaf;
rc = cn10k_map_unmap_rq_policer(nic, node->rq, node->leaf_profile, true);
if (rc)
goto free_leaf;
mutex_unlock(&nic->mbox.lock);
return 0;
free_leaf:
if (cn10k_free_leaf_profile(nic, node->leaf_profile))
netdev_err(nic->netdev,
"Unable to free leaf bandwidth profile(%d)\n",
node->leaf_profile);
mutex_unlock(&nic->mbox.lock);
return rc;
}
static int otx2_tc_act_set_police(struct otx2_nic *nic,
struct otx2_tc_flow *node,
struct flow_cls_offload *f,
u64 rate, u32 burst, u32 mark,
struct npc_install_flow_req *req, bool pps)
{
struct netlink_ext_ack *extack = f->common.extack;
struct otx2_hw *hw = &nic->hw;
int rq_idx, rc;
rq_idx = find_first_zero_bit(&nic->rq_bmap, hw->rx_queues);
if (rq_idx >= hw->rx_queues) {
NL_SET_ERR_MSG_MOD(extack, "Police action rules exceeded");
return -EINVAL;
}
req->match_id = mark & 0xFFFFULL;
req->index = rq_idx;
req->op = NIX_RX_ACTIONOP_UCAST;
Annotation
- Immediate include surface: `linux/netdevice.h`, `linux/etherdevice.h`, `linux/inetdevice.h`, `linux/rhashtable.h`, `linux/bitfield.h`, `net/flow_dissector.h`, `net/pkt_cls.h`, `net/tc_act/tc_gact.h`.
- Detected declarations: `function Copyright`, `function otx2_get_egress_rate_cfg`, `function otx2_get_txschq_rate_regval`, `function otx2_set_matchall_egress_rate`, `function otx2_tc_validate_flow`, `function otx2_policer_validate`, `function otx2_tc_egress_matchall_install`, `function otx2_tc_egress_matchall_delete`, `function otx2_tc_act_set_hw_police`, `function otx2_tc_act_set_police`.
- 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.
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.