drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c- Extension
.c- Size
- 19277 bytes
- Lines
- 738
- 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.
- 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/string.hlinux/bitops.hnet/dcbnl.hspectrum.hreg.h
Detected Declarations
function mlxsw_sp_dcbnl_getdcbxfunction mlxsw_sp_dcbnl_setdcbxfunction mlxsw_sp_dcbnl_ieee_getetsfunction mlxsw_sp_port_ets_validatefunction mlxsw_sp_port_headroom_ets_setfunction __mlxsw_sp_dcbnl_ieee_setetsfunction mlxsw_sp_dcbnl_ieee_setetsfunction mlxsw_sp_dcbnl_app_validatefunction mlxsw_sp_port_dcb_app_default_priofunction mlxsw_sp_port_dcb_app_dscp_prio_mapfunction mlxsw_sp_port_dcb_app_prio_dscp_mapfunction mlxsw_sp_port_dcb_app_update_qptsfunction mlxsw_sp_port_dcb_app_update_qrwefunction mlxsw_sp_port_dcb_toggle_trustfunction mlxsw_sp_port_dcb_app_update_qpdpfunction mlxsw_sp_port_dcb_app_update_qpdpmfunction mlxsw_sp_port_dcb_app_update_qpdsmfunction mlxsw_sp_port_dcb_app_updatefunction mlxsw_sp_dcbnl_ieee_setappfunction mlxsw_sp_dcbnl_ieee_delappfunction mlxsw_sp_dcbnl_ieee_getmaxratefunction mlxsw_sp_dcbnl_ieee_setmaxratefunction mlxsw_sp_port_pfc_cnt_getfunction mlxsw_sp_dcbnl_ieee_getpfcfunction mlxsw_sp_port_pfc_setfunction mlxsw_sp_dcbnl_ieee_setpfcfunction mlxsw_sp_dcbnl_getbufferfunction mlxsw_sp_dcbnl_setbufferfunction mlxsw_sp_port_ets_initfunction mlxsw_sp_port_ets_finifunction mlxsw_sp_port_maxrate_initfunction mlxsw_sp_port_maxrate_finifunction mlxsw_sp_port_pfc_initfunction mlxsw_sp_port_pfc_finifunction mlxsw_sp_port_dcb_initfunction mlxsw_sp_port_dcb_fini
Annotated Snippet
switch (ets->tc_tsa[i]) {
case IEEE_8021QAZ_TSA_STRICT:
break;
case IEEE_8021QAZ_TSA_ETS:
has_ets_tc = true;
tx_bw_sum += ets->tc_tx_bw[i];
break;
default:
netdev_err(dev, "Only strict priority and ETS are supported\n");
return -EINVAL;
}
if (ets->prio_tc[i] >= IEEE_8021QAZ_MAX_TCS) {
netdev_err(dev, "Invalid TC\n");
return -EINVAL;
}
}
if (has_ets_tc && tx_bw_sum != 100) {
netdev_err(dev, "Total ETS bandwidth should equal 100\n");
return -EINVAL;
}
return 0;
}
static int mlxsw_sp_port_headroom_ets_set(struct mlxsw_sp_port *mlxsw_sp_port,
struct ieee_ets *ets)
{
struct net_device *dev = mlxsw_sp_port->dev;
struct mlxsw_sp_hdroom hdroom;
int prio;
int err;
hdroom = *mlxsw_sp_port->hdroom;
for (prio = 0; prio < IEEE_8021QAZ_MAX_TCS; prio++)
hdroom.prios.prio[prio].ets_buf_idx = ets->prio_tc[prio];
mlxsw_sp_hdroom_prios_reset_buf_idx(&hdroom);
mlxsw_sp_hdroom_bufs_reset_lossiness(&hdroom);
mlxsw_sp_hdroom_bufs_reset_sizes(mlxsw_sp_port, &hdroom);
err = mlxsw_sp_hdroom_configure(mlxsw_sp_port, &hdroom);
if (err) {
netdev_err(dev, "Failed to configure port's headroom\n");
return err;
}
return 0;
}
static int __mlxsw_sp_dcbnl_ieee_setets(struct mlxsw_sp_port *mlxsw_sp_port,
struct ieee_ets *ets)
{
struct ieee_ets *my_ets = mlxsw_sp_port->dcb.ets;
struct net_device *dev = mlxsw_sp_port->dev;
int i, err;
/* Egress configuration. */
for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
bool dwrr = ets->tc_tsa[i] == IEEE_8021QAZ_TSA_ETS;
u8 weight = ets->tc_tx_bw[i];
err = mlxsw_sp_port_ets_set(mlxsw_sp_port,
MLXSW_REG_QEEC_HR_SUBGROUP, i,
0, dwrr, weight);
if (err) {
netdev_err(dev, "Failed to link subgroup ETS element %d to group\n",
i);
goto err_port_ets_set;
}
}
for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
err = mlxsw_sp_port_prio_tc_set(mlxsw_sp_port, i,
ets->prio_tc[i]);
if (err) {
netdev_err(dev, "Failed to map prio %d to TC %d\n", i,
ets->prio_tc[i]);
goto err_port_prio_tc_set;
}
}
/* Ingress configuration. */
err = mlxsw_sp_port_headroom_ets_set(mlxsw_sp_port, ets);
if (err)
goto err_port_headroom_set;
return 0;
err_port_headroom_set:
Annotation
- Immediate include surface: `linux/netdevice.h`, `linux/string.h`, `linux/bitops.h`, `net/dcbnl.h`, `spectrum.h`, `reg.h`.
- Detected declarations: `function mlxsw_sp_dcbnl_getdcbx`, `function mlxsw_sp_dcbnl_setdcbx`, `function mlxsw_sp_dcbnl_ieee_getets`, `function mlxsw_sp_port_ets_validate`, `function mlxsw_sp_port_headroom_ets_set`, `function __mlxsw_sp_dcbnl_ieee_setets`, `function mlxsw_sp_dcbnl_ieee_setets`, `function mlxsw_sp_dcbnl_app_validate`, `function mlxsw_sp_port_dcb_app_default_prio`, `function mlxsw_sp_port_dcb_app_dscp_prio_map`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
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.