drivers/net/ethernet/netronome/nfp/nic/dcb.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/netronome/nfp/nic/dcb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/netronome/nfp/nic/dcb.c- Extension
.c- Size
- 13626 bytes
- Lines
- 572
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/netdevice.hnet/dcbnl.h../nfp_app.h../nfp_net.h../nfp_main.h../nfpcore/nfp_cpp.h../nfpcore/nfp_nffw.h../nfp_net_sriov.hmain.h
Detected Declarations
function nfp_tsa_ieee2nfpfunction nfp_nic_dcbnl_ieee_getetsfunction nfp_refresh_tc2idxfunction nfp_fill_maxratefunction update_dscp_maxratefunction nfp_nic_set_trustfunction nfp_nic_set_enablefunction dcb_ets_checkfunction nfp_nic_fill_etsfunction nfp_nic_ets_initfunction nfp_nic_dcbnl_ieee_setetsfunction nfp_nic_dcbnl_ieee_getmaxratefunction nfp_nic_dcbnl_ieee_setmaxratefunction nfp_nic_set_trust_statusfunction nfp_nic_set_dscp2priofunction nfp_nic_dcbnl_ieee_setappfunction nfp_nic_dcbnl_ieee_delappfunction nfp_nic_dcb_initfunction nfp_nic_dcb_clean
Annotated Snippet
if (dcb->tc2idx[j] != tc2idx[j]) {
change = true;
dcb->tc2idx[j] = tc2idx[j];
}
}
return change;
}
static int nfp_fill_maxrate(struct nfp_net *nn, u64 *max_rate_array)
{
struct nfp_app *app = nn->app;
struct nfp_dcb *dcb;
u32 ratembps;
dcb = get_dcb_priv(nn);
for (unsigned int i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
/* Convert bandwidth from kbps to mbps. */
ratembps = max_rate_array[i] / 1024;
/* Reject input values >= NFP_DCB_TC_RATE_MAX */
if (ratembps >= NFP_DCB_TC_RATE_MAX) {
nfp_warn(app->cpp, "ratembps(%d) must less than %d.",
ratembps, NFP_DCB_TC_RATE_MAX);
return -EINVAL;
}
/* Input value 0 mapped to NFP_DCB_TC_RATE_MAX for firmware. */
if (ratembps == 0)
ratembps = NFP_DCB_TC_RATE_MAX;
writew((u16)ratembps, dcb->dcbcfg_tbl +
dcb->cfg_offset + NFP_DCB_DATA_OFF_RATE + dcb->tc2idx[i] * 2);
/* for rate value from user space, need to sync to dcb structure */
if (dcb->tc_maxrate != max_rate_array)
dcb->tc_maxrate[i] = max_rate_array[i];
}
return 0;
}
static int update_dscp_maxrate(struct net_device *dev, u32 *update)
{
struct nfp_net *nn = netdev_priv(dev);
struct nfp_dcb *dcb;
int err;
dcb = get_dcb_priv(nn);
err = nfp_fill_maxrate(nn, dcb->tc_maxrate);
if (err)
return err;
*update |= NFP_DCB_MSG_MSK_RATE;
/* We only refresh dscp in dscp trust mode. */
if (dcb->dscp_cnt > 0) {
for (unsigned int i = 0; i < NFP_NET_MAX_DSCP; i++) {
writeb(dcb->tc2idx[dcb->prio2tc[dcb->dscp2prio[i]]],
dcb->dcbcfg_tbl + dcb->cfg_offset +
NFP_DCB_DATA_OFF_DSCP2IDX + i);
}
*update |= NFP_DCB_MSG_MSK_DSCP;
}
return 0;
}
static void nfp_nic_set_trust(struct nfp_net *nn, u32 *update)
{
struct nfp_dcb *dcb;
u8 trust;
dcb = get_dcb_priv(nn);
if (dcb->trust_status != NFP_DCB_TRUST_INVALID)
return;
trust = dcb->dscp_cnt > 0 ? NFP_DCB_TRUST_DSCP : NFP_DCB_TRUST_PCP;
writeb(trust, dcb->dcbcfg_tbl + dcb->cfg_offset +
NFP_DCB_DATA_OFF_TRUST);
dcb->trust_status = trust;
*update |= NFP_DCB_MSG_MSK_TRUST;
}
static void nfp_nic_set_enable(struct nfp_net *nn, u32 enable, u32 *update)
{
struct nfp_dcb *dcb;
u32 value = 0;
Annotation
- Immediate include surface: `linux/device.h`, `linux/netdevice.h`, `net/dcbnl.h`, `../nfp_app.h`, `../nfp_net.h`, `../nfp_main.h`, `../nfpcore/nfp_cpp.h`, `../nfpcore/nfp_nffw.h`.
- Detected declarations: `function nfp_tsa_ieee2nfp`, `function nfp_nic_dcbnl_ieee_getets`, `function nfp_refresh_tc2idx`, `function nfp_fill_maxrate`, `function update_dscp_maxrate`, `function nfp_nic_set_trust`, `function nfp_nic_set_enable`, `function dcb_ets_check`, `function nfp_nic_fill_ets`, `function nfp_nic_ets_init`.
- 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.