drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c- Extension
.c- Size
- 32534 bytes
- Lines
- 1296
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/netdevice.hlinux/units.hen.hen/port.hen/port_buffer.h
Detected Declarations
function mlx5e_dcbnl_set_dcbx_modefunction mlx5e_dcbnl_switch_to_host_modefunction mlx5e_dcbnl_ieee_getetsfunction mlx5e_build_tc_groupfunction mlx5e_build_tc_tx_bwfunction mlx5e_dcbnl_ieee_setets_corefunction mlx5e_dbcnl_validate_etsfunction mlx5e_dcbnl_ieee_setetsfunction mlx5e_dcbnl_ieee_getpfcfunction mlx5e_dcbnl_ieee_setpfcfunction mlx5e_dcbnl_getdcbxfunction mlx5e_dcbnl_setdcbxfunction mlx5e_dcbnl_ieee_setappfunction mlx5e_dcbnl_ieee_delappfunction mlx5e_dcbnl_ieee_getmaxratefunction mlx5e_dcbnl_ieee_setmaxratefunction mlx5e_dcbnl_setallfunction mlx5e_dcbnl_getstatefunction mlx5e_dcbnl_getpermhwaddrfunction mlx5e_dcbnl_setpgtccfgtxfunction mlx5e_dcbnl_setpgbwgcfgtxfunction mlx5e_dcbnl_getpgtccfgtxfunction mlx5e_dcbnl_getpgbwgcfgtxfunction mlx5e_dcbnl_setpfccfgfunction mlx5e_dcbnl_get_priority_pfcfunction mlx5e_dcbnl_getpfccfgfunction mlx5e_dcbnl_getcapfunction mlx5e_dcbnl_getnumtcsfunction mlx5e_dcbnl_getpfcstatefunction mlx5e_dcbnl_setpfcstatefunction mlx5e_dcbnl_getbufferfunction mlx5e_dcbnl_setbufferfunction mlx5e_dcbnl_build_netdevfunction mlx5e_dcbnl_query_dcbx_modefunction mlx5e_ets_initfunction mlx5e_dcbnl_dscp_appfunction mlx5e_dcbnl_init_appfunction mlx5e_dcbnl_delete_appfunction mlx5e_params_calc_trust_tx_min_inline_modefunction mlx5e_update_trust_state_hwfunction mlx5e_set_trust_statefunction mlx5e_set_dscp2priofunction mlx5e_trust_initializefunction mlx5e_query_port_buffers_cell_sizefunction mlx5e_dcbnl_initialize
Annotated Snippet
if (ets->tc_tsa[i] == IEEE_8021QAZ_TSA_ETS) {
any_tc_mapped_to_ets = true;
if (!ets->tc_tx_bw[i])
ets_zero_bw = true;
}
}
/* strict group has higher priority than ets group */
strict_group = MLX5E_LOWEST_PRIO_GROUP;
if (any_tc_mapped_to_ets)
strict_group++;
if (ets_zero_bw)
strict_group++;
for (i = 0; i <= max_tc; i++) {
switch (ets->tc_tsa[i]) {
case IEEE_8021QAZ_TSA_VENDOR:
tc_group[i] = MLX5E_VENDOR_TC_GROUP_NUM;
break;
case IEEE_8021QAZ_TSA_STRICT:
tc_group[i] = strict_group++;
break;
case IEEE_8021QAZ_TSA_ETS:
tc_group[i] = MLX5E_LOWEST_PRIO_GROUP;
if (ets->tc_tx_bw[i] && ets_zero_bw)
tc_group[i] = MLX5E_LOWEST_PRIO_GROUP + 1;
break;
}
}
}
static void mlx5e_build_tc_tx_bw(struct ieee_ets *ets, u8 *tc_tx_bw,
u8 *tc_group, int max_tc)
{
int bw_for_ets_zero_bw_tc = 0;
int last_ets_zero_bw_tc = -1;
int num_ets_zero_bw = 0;
int i;
for (i = 0; i <= max_tc; i++) {
if (ets->tc_tsa[i] == IEEE_8021QAZ_TSA_ETS &&
!ets->tc_tx_bw[i]) {
num_ets_zero_bw++;
last_ets_zero_bw_tc = i;
}
}
if (num_ets_zero_bw)
bw_for_ets_zero_bw_tc = MLX5E_MAX_BW_ALLOC / num_ets_zero_bw;
for (i = 0; i <= max_tc; i++) {
switch (ets->tc_tsa[i]) {
case IEEE_8021QAZ_TSA_VENDOR:
tc_tx_bw[i] = MLX5E_MAX_BW_ALLOC;
break;
case IEEE_8021QAZ_TSA_STRICT:
tc_tx_bw[i] = MLX5E_MAX_BW_ALLOC;
break;
case IEEE_8021QAZ_TSA_ETS:
tc_tx_bw[i] = ets->tc_tx_bw[i] ?
ets->tc_tx_bw[i] :
bw_for_ets_zero_bw_tc;
break;
}
}
/* Make sure the total bw for ets zero bw group is 100% */
if (last_ets_zero_bw_tc != -1)
tc_tx_bw[last_ets_zero_bw_tc] +=
MLX5E_MAX_BW_ALLOC % num_ets_zero_bw;
}
/* If there are ETS BW 0,
* Set ETS group # to 1 for all ETS non zero BW tcs. Their sum must be 100%.
* Set group #0 to all the ETS BW 0 tcs and
* equally splits the 100% BW between them
* Report both group #0 and #1 as ETS type.
* All the tcs in group #0 will be reported with 0% BW.
*/
static int mlx5e_dcbnl_ieee_setets_core(struct mlx5e_priv *priv, struct ieee_ets *ets)
{
struct mlx5_core_dev *mdev = priv->mdev;
u8 tc_tx_bw[IEEE_8021QAZ_MAX_TCS];
u8 tc_group[IEEE_8021QAZ_MAX_TCS];
int max_tc = mlx5_max_tc(mdev);
int err, i;
mlx5e_build_tc_group(ets, tc_group, max_tc);
mlx5e_build_tc_tx_bw(ets, tc_tx_bw, tc_group, max_tc);
Annotation
- Immediate include surface: `linux/device.h`, `linux/netdevice.h`, `linux/units.h`, `en.h`, `en/port.h`, `en/port_buffer.h`.
- Detected declarations: `function mlx5e_dcbnl_set_dcbx_mode`, `function mlx5e_dcbnl_switch_to_host_mode`, `function mlx5e_dcbnl_ieee_getets`, `function mlx5e_build_tc_group`, `function mlx5e_build_tc_tx_bw`, `function mlx5e_dcbnl_ieee_setets_core`, `function mlx5e_dbcnl_validate_ets`, `function mlx5e_dcbnl_ieee_setets`, `function mlx5e_dcbnl_ieee_getpfc`, `function mlx5e_dcbnl_ieee_setpfc`.
- 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.