drivers/net/ethernet/intel/ice/ice_dcb_lib.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/ice/ice_dcb_lib.c- Extension
.c- Size
- 29559 bytes
- Lines
- 1132
- 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_dcb_lib.hice_dcb_nl.hdevlink/devlink.h
Detected Declarations
function ice_dcb_get_ena_tcfunction ice_is_pfc_causing_hung_qfunction ice_dcb_get_modefunction ice_dcb_get_num_tcfunction DCBfunction ice_vsi_set_dcb_tc_cfgfunction ice_dcb_get_tcfunction ice_vsi_cfg_dcb_ringsfunction ice_for_each_rxqfunction ice_for_each_traffic_classfunction ice_for_each_chnl_tcfunction ice_dcb_ena_dis_vsifunction ice_for_each_vsifunction ice_dcb_bwchkfunction ice_pf_dcb_cfgfunction ice_cfg_etsrec_defaultsfunction ice_dcb_need_recfgfunction ice_dcb_rebuildfunction ice_dcb_init_cfgfunction ice_dcb_sw_dflt_cfgfunction ice_dcb_tc_contigfunction ice_dcb_noncontig_cfgfunction ice_pf_dcb_recfgfunction ice_init_pf_dcbfunction ice_update_dcb_statsfunction ice_tx_prepare_vlan_flags_dcbfunction ice_setup_dcb_qos_infofunction ice_dcb_is_mib_change_pendingfunction ice_dcb_process_lldp_set_mib_change
Annotated Snippet
if (num_tc & BIT(i)) {
if (!tc_unused) {
ret++;
} else {
pr_err("Non-contiguous TCs - Disabling DCB\n");
return 1;
}
} else {
tc_unused = true;
}
}
/* There is always at least 1 TC */
if (!ret)
ret = 1;
return ret;
}
/**
* ice_get_first_droptc - returns number of first droptc
* @vsi: used to find the first droptc
*
* This function returns the value of first_droptc.
* When DCB is enabled, first droptc information is derived from enabled_tc
* and PFC enabled bits. otherwise this function returns 0 as there is one
* TC without DCB (tc0)
*/
static u8 ice_get_first_droptc(struct ice_vsi *vsi)
{
struct ice_dcbx_cfg *cfg = &vsi->port_info->qos_cfg.local_dcbx_cfg;
struct device *dev = ice_pf_to_dev(vsi->back);
u8 num_tc, ena_tc_map, pfc_ena_map;
u8 i;
num_tc = ice_dcb_get_num_tc(cfg);
/* get bitmap of enabled TCs */
ena_tc_map = ice_dcb_get_ena_tc(cfg);
/* get bitmap of PFC enabled TCs */
pfc_ena_map = cfg->pfc.pfcena;
/* get first TC that is not PFC enabled */
for (i = 0; i < num_tc; i++) {
if ((ena_tc_map & BIT(i)) && (!(pfc_ena_map & BIT(i)))) {
dev_dbg(dev, "first drop tc = %d\n", i);
return i;
}
}
dev_dbg(dev, "first drop tc = 0\n");
return 0;
}
/**
* ice_vsi_set_dcb_tc_cfg - Set VSI's TC based on DCB configuration
* @vsi: pointer to the VSI instance
*/
void ice_vsi_set_dcb_tc_cfg(struct ice_vsi *vsi)
{
struct ice_dcbx_cfg *cfg = &vsi->port_info->qos_cfg.local_dcbx_cfg;
switch (vsi->type) {
case ICE_VSI_PF:
vsi->tc_cfg.ena_tc = ice_dcb_get_ena_tc(cfg);
vsi->tc_cfg.numtc = ice_dcb_get_num_tc(cfg);
break;
case ICE_VSI_CHNL:
case ICE_VSI_SF:
vsi->tc_cfg.ena_tc = BIT(ice_get_first_droptc(vsi));
vsi->tc_cfg.numtc = 1;
break;
case ICE_VSI_CTRL:
case ICE_VSI_LB:
default:
vsi->tc_cfg.ena_tc = ICE_DFLT_TRAFFIC_CLASS;
vsi->tc_cfg.numtc = 1;
}
}
/**
* ice_dcb_get_tc - Get the TC associated with the queue
* @vsi: ptr to the VSI
* @queue_index: queue number associated with VSI
*/
u8 ice_dcb_get_tc(struct ice_vsi *vsi, int queue_index)
{
return vsi->tx_rings[queue_index]->dcb_tc;
}
Annotation
- Immediate include surface: `ice_dcb_lib.h`, `ice_dcb_nl.h`, `devlink/devlink.h`.
- Detected declarations: `function ice_dcb_get_ena_tc`, `function ice_is_pfc_causing_hung_q`, `function ice_dcb_get_mode`, `function ice_dcb_get_num_tc`, `function DCB`, `function ice_vsi_set_dcb_tc_cfg`, `function ice_dcb_get_tc`, `function ice_vsi_cfg_dcb_rings`, `function ice_for_each_rxq`, `function ice_for_each_traffic_class`.
- 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.