drivers/net/ethernet/intel/ice/ice_lag.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/ice/ice_lag.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/ice/ice_lag.c- Extension
.c- Size
- 74246 bytes
- Lines
- 2785
- 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
ice.hice_lib.hice_lag.h
Detected Declarations
function ice_lag_set_primaryfunction ice_lag_set_bkupfunction netif_is_same_icefunction metadatafunction ice_lag_find_hw_by_lportfunction list_for_each_entryfunction ice_pkg_has_lport_extractfunction list_for_eachfunction ice_lag_cfg_fltrfunction ice_lag_cfg_dflt_fltrfunction ice_lag_cfg_drop_fltrfunction ice_lag_cfg_pf_fltrs_act_bkupfunction ice_lag_cfg_lp_fltrfunction ice_lag_cfg_pf_fltrsfunction ice_display_lag_infofunction ice_lag_qbuf_recfgfunction ice_lag_get_sched_parentfunction ice_lag_move_vf_node_tcfunction ice_lag_build_netdev_listfunction ice_lag_destroy_netdev_listfunction ice_lag_move_single_vf_nodesfunction ice_lag_move_vf_nodesfunction ice_lag_move_vf_nodes_cfgfunction ice_lag_prepare_vf_resetfunction ice_lag_complete_vf_resetfunction tofunction ice_lag_aa_qbuf_recfgfunction ice_lag_aa_move_vf_qsfunction ice_lag_aa_failoverfunction ice_lag_reclaim_vf_tcfunction ice_lag_reclaim_vf_nodesfunction ice_lag_linkfunction ice_lag_act_bkup_unlinkfunction ice_lag_aa_unlinkfunction ice_lag_link_unlinkfunction ice_lag_set_swidfunction ice_lag_primary_swidfunction ice_lag_add_prune_listfunction ice_lag_del_prune_listfunction ice_lag_init_feature_support_flagfunction ice_lag_changeupper_eventfunction ice_lag_monitor_linkfunction ice_lag_monitor_act_bkupfunction ice_lag_aa_clear_spooffunction ice_lag_monitor_act_actfunction ice_for_each_vffunction ice_lag_monitor_infofunction ice_lag_chk_comp
Annotated Snippet
if (tmp_lag && tmp_lag->primary) {
primary_lag = tmp_lag;
break;
}
}
return primary_lag;
}
/**
* ice_lag_cfg_fltr - Add/Remove rule for LAG
* @lag: lag struct for local interface
* @act: rule action
* @recipe_id: recipe id for the new rule
* @rule_idx: pointer to rule index
* @direction: ICE_FLTR_RX or ICE_FLTR_TX
* @add: boolean on whether we are adding filters
*/
static int
ice_lag_cfg_fltr(struct ice_lag *lag, u32 act, u16 recipe_id, u16 *rule_idx,
u8 direction, bool add)
{
struct ice_sw_rule_lkup_rx_tx *s_rule;
struct ice_hw *hw = &lag->pf->hw;
u16 s_rule_sz, vsi_num;
u8 *eth_hdr;
u32 opc;
int err;
vsi_num = ice_get_hw_vsi_num(hw, 0);
s_rule_sz = ICE_SW_RULE_RX_TX_ETH_HDR_SIZE(s_rule);
s_rule = kzalloc(s_rule_sz, GFP_KERNEL);
if (!s_rule) {
dev_err(ice_pf_to_dev(lag->pf), "error allocating rule for LAG\n");
return -ENOMEM;
}
if (add) {
eth_hdr = s_rule->hdr_data;
ice_fill_eth_hdr(eth_hdr);
act |= FIELD_PREP(ICE_SINGLE_ACT_VSI_ID_M, vsi_num);
s_rule->recipe_id = cpu_to_le16(recipe_id);
if (direction == ICE_FLTR_RX) {
s_rule->hdr.type =
cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_RX);
s_rule->src = cpu_to_le16(hw->port_info->lport);
} else {
s_rule->hdr.type =
cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_TX);
s_rule->src = cpu_to_le16(vsi_num);
}
s_rule->act = cpu_to_le32(act);
s_rule->hdr_len = cpu_to_le16(DUMMY_ETH_HDR_LEN);
opc = ice_aqc_opc_add_sw_rules;
} else {
s_rule->index = cpu_to_le16(*rule_idx);
opc = ice_aqc_opc_remove_sw_rules;
}
err = ice_aq_sw_rules(&lag->pf->hw, s_rule, s_rule_sz, 1, opc, NULL);
if (err)
goto dflt_fltr_free;
if (add)
*rule_idx = le16_to_cpu(s_rule->index);
else
*rule_idx = 0;
dflt_fltr_free:
kfree(s_rule);
return err;
}
/**
* ice_lag_cfg_dflt_fltr - Add/Remove default VSI rule for LAG
* @lag: lag struct for local interface
* @add: boolean on whether to add filter
*/
static int
ice_lag_cfg_dflt_fltr(struct ice_lag *lag, bool add)
{
u32 act = ICE_SINGLE_ACT_VSI_FORWARDING |
ICE_SINGLE_ACT_VALID_BIT | ICE_SINGLE_ACT_LAN_ENABLE;
int err;
err = ice_lag_cfg_fltr(lag, act, lag->pf_recipe, &lag->pf_rx_rule_id,
ICE_FLTR_RX, add);
Annotation
- Immediate include surface: `ice.h`, `ice_lib.h`, `ice_lag.h`.
- Detected declarations: `function ice_lag_set_primary`, `function ice_lag_set_bkup`, `function netif_is_same_ice`, `function metadata`, `function ice_lag_find_hw_by_lport`, `function list_for_each_entry`, `function ice_pkg_has_lport_extract`, `function list_for_each`, `function ice_lag_cfg_fltr`, `function ice_lag_cfg_dflt_fltr`.
- 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.