drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c- Extension
.c- Size
- 20482 bytes
- Lines
- 765
- 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.
- 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/if_macvlan.hlinux/list.hlinux/rculist.hlinux/rtnetlink.hlinux/workqueue.hlinux/spinlock.htc.hneigh.hen_rep.heswitch.hlib/fs_chains.hen/tc_ct.hen/mapping.hen/tc_tun.hlib/port_tun.hen/tc/sample.hen_accel/ipsec_rxtx.hen/tc/int_port.hen/tc/act/act.h
Detected Declarations
struct mlx5e_rep_indr_block_privfunction mlx5e_rep_encap_entry_attachfunction mlx5e_rep_encap_entry_detachfunction mlx5e_rep_update_flowsfunction mlx5e_rep_setup_tc_cls_flowerfunction mlx5e_tc_stats_matchallfunction mlx5e_rep_setup_tc_cls_matchallfunction mlx5e_rep_setup_tc_cbfunction mlx5e_rep_setup_ft_cbfunction mlx5e_rep_setup_tcfunction mlx5e_rep_tc_initfunction mlx5e_rep_tc_cleanupfunction mlx5e_rep_tc_enablefunction mlx5e_rep_tc_disablefunction mlx5e_rep_tc_event_port_affinityfunction mlx5e_rep_indr_block_priv_lookupfunction mlx5e_rep_indr_offloadfunction mlx5e_rep_indr_setup_tc_cbfunction mlx5e_rep_indr_setup_ft_cbfunction mlx5e_rep_indr_block_unbindfunction mlx5e_rep_macvlan_mode_supportedfunction mlx5e_rep_check_indr_block_supportedfunction mlx5e_rep_indr_setup_blockfunction mlx5e_rep_indr_replace_actfunction flow_action_for_eachfunction mlx5e_rep_indr_destroy_actfunction mlx5e_rep_indr_stats_actfunction mlx5e_rep_indr_setup_actfunction mlx5e_rep_indr_no_dev_setupfunction mlx5e_rep_indr_setup_cbfunction mlx5e_rep_tc_netdevice_event_registerfunction mlx5e_rep_tc_netdevice_event_unregisterfunction mlx5e_rep_tc_receive
Annotated Snippet
struct mlx5e_rep_indr_block_priv {
struct net_device *netdev;
struct mlx5e_rep_priv *rpriv;
enum flow_block_binder_type binder_type;
struct list_head list;
};
int mlx5e_rep_encap_entry_attach(struct mlx5e_priv *priv,
struct mlx5e_encap_entry *e,
struct mlx5e_neigh *m_neigh,
struct net_device *neigh_dev)
{
struct mlx5e_rep_priv *rpriv = priv->ppriv;
struct mlx5_rep_uplink_priv *uplink_priv = &rpriv->uplink_priv;
struct mlx5_tun_entropy *tun_entropy = &uplink_priv->tun_entropy;
struct mlx5e_neigh_hash_entry *nhe;
int err;
err = mlx5_tun_entropy_refcount_inc(tun_entropy, e->reformat_type);
if (err)
return err;
mutex_lock(&rpriv->neigh_update.encap_lock);
nhe = mlx5e_rep_neigh_entry_lookup(priv, m_neigh);
if (!nhe) {
err = mlx5e_rep_neigh_entry_create(priv, m_neigh, neigh_dev, &nhe);
if (err) {
mutex_unlock(&rpriv->neigh_update.encap_lock);
mlx5_tun_entropy_refcount_dec(tun_entropy,
e->reformat_type);
return err;
}
}
e->nhe = nhe;
spin_lock(&nhe->encap_list_lock);
list_add_rcu(&e->encap_list, &nhe->encap_list);
spin_unlock(&nhe->encap_list_lock);
mutex_unlock(&rpriv->neigh_update.encap_lock);
return 0;
}
void mlx5e_rep_encap_entry_detach(struct mlx5e_priv *priv,
struct mlx5e_encap_entry *e)
{
struct mlx5e_rep_priv *rpriv = priv->ppriv;
struct mlx5_rep_uplink_priv *uplink_priv = &rpriv->uplink_priv;
struct mlx5_tun_entropy *tun_entropy = &uplink_priv->tun_entropy;
if (!e->nhe)
return;
spin_lock(&e->nhe->encap_list_lock);
list_del_rcu(&e->encap_list);
spin_unlock(&e->nhe->encap_list_lock);
mlx5e_rep_neigh_entry_release(e->nhe);
e->nhe = NULL;
mlx5_tun_entropy_refcount_dec(tun_entropy, e->reformat_type);
}
void mlx5e_rep_update_flows(struct mlx5e_priv *priv,
struct mlx5e_encap_entry *e,
bool neigh_connected,
unsigned char ha[ETH_ALEN])
{
struct ethhdr *eth = (struct ethhdr *)e->encap_header;
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
bool encap_connected;
LIST_HEAD(flow_list);
ASSERT_RTNL();
mutex_lock(&esw->offloads.encap_tbl_lock);
encap_connected = !!(e->flags & MLX5_ENCAP_ENTRY_VALID);
if (encap_connected == neigh_connected && ether_addr_equal(e->h_dest, ha))
goto unlock;
mlx5e_take_all_encap_flows(e, &flow_list);
if ((e->flags & MLX5_ENCAP_ENTRY_VALID) &&
(!neigh_connected || !ether_addr_equal(e->h_dest, ha)))
mlx5e_tc_encap_flows_del(priv, e, &flow_list);
if (neigh_connected && !(e->flags & MLX5_ENCAP_ENTRY_VALID)) {
struct net_device *route_dev;
Annotation
- Immediate include surface: `linux/netdevice.h`, `linux/if_macvlan.h`, `linux/list.h`, `linux/rculist.h`, `linux/rtnetlink.h`, `linux/workqueue.h`, `linux/spinlock.h`, `tc.h`.
- Detected declarations: `struct mlx5e_rep_indr_block_priv`, `function mlx5e_rep_encap_entry_attach`, `function mlx5e_rep_encap_entry_detach`, `function mlx5e_rep_update_flows`, `function mlx5e_rep_setup_tc_cls_flower`, `function mlx5e_tc_stats_matchall`, `function mlx5e_rep_setup_tc_cls_matchall`, `function mlx5e_rep_setup_tc_cb`, `function mlx5e_rep_setup_ft_cb`, `function mlx5e_rep_setup_tc`.
- 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.
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.