drivers/net/ethernet/meta/fbnic/fbnic_mac.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/meta/fbnic/fbnic_mac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/meta/fbnic/fbnic_mac.c- Extension
.c- Size
- 31856 bytes
- Lines
- 1032
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hnet/tcp.hfbnic.hfbnic_mac.hfbnic_netdev.h
Detected Declarations
struct fbnic_fifo_configfunction fbnic_init_readrqfunction fbnic_init_mpsfunction fbnic_mac_init_axifunction fbnic_mac_init_qmfunction fbnic_mac_init_rxbfunction fbnic_mac_init_txbfunction fbnic_mac_init_regsfunction __fbnic_mac_stat_rd64function fbnic_mac_stat_rd32function fbnic_mac_check_tx_pausefunction fbnic_mac_tx_pause_configfunction fbnic_mac_ps_protect_to_resetfunction fbnic_mac_ps_protect_configfunction fbnic_mac_get_link_eventfunction __fbnic_mac_cmd_config_asicfunction fbnic_mac_get_link_statusfunction fbnic_pmd_update_statefunction fbnic_mac_get_linkfunction fbnic_mac_get_fw_settingsfunction fbnic_mac_preparefunction fbnic_mac_link_down_asicfunction fbnic_mac_link_up_asicfunction fbnic_pcs_rsfec_stat_rd32function fbnic_mac_get_fec_statsfunction fbnic_mac_get_pcs_statsfunction fbnic_mac_get_eth_mac_statsfunction fbnic_mac_get_pause_statsfunction fbnic_mac_get_eth_ctrl_statsfunction fbnic_mac_get_rmon_statsfunction fbnic_mac_get_sensor_asicfunction fbnic_mac_initfunction fbnic_mac_ps_protect_to_configfunction fbnic_mac_ps_protect_handler
Annotated Snippet
struct fbnic_fifo_config {
unsigned int addr;
unsigned int size;
};
/* Rx FIFO Configuration
* The table consists of 8 entries, of which only 4 are currently used
* The starting addr is in units of 64B and the size is in 2KB units
* Below is the human readable version of the table defined below:
* Function Addr Size
* ----------------------------------
* Network to Host/BMC 384K 64K
* Unused
* Unused
* Network to BMC 448K 32K
* Network to Host 0 384K
* Unused
* BMC to Host 480K 32K
* Unused
*/
static const struct fbnic_fifo_config fifo_config[] = {
{ .addr = 0x1800, .size = 0x20 }, /* Network to Host/BMC */
{ }, /* Unused */
{ }, /* Unused */
{ .addr = 0x1c00, .size = 0x10 }, /* Network to BMC */
{ .addr = 0x0000, .size = 0xc0 }, /* Network to Host */
{ }, /* Unused */
{ .addr = 0x1e00, .size = 0x10 }, /* BMC to Host */
{ } /* Unused */
};
static void fbnic_mac_init_rxb(struct fbnic_dev *fbd)
{
bool rx_enable;
int i;
rx_enable = !!(rd32(fbd, FBNIC_RPC_RMI_CONFIG) &
FBNIC_RPC_RMI_CONFIG_ENABLE);
for (i = 0; i < 8; i++) {
unsigned int size = fifo_config[i].size;
/* If we are coming up on a system that already has the
* Rx data path enabled we don't need to reconfigure the
* FIFOs. Instead we can check to verify the values are
* large enough to meet our needs, and use the values to
* populate the flow control, ECN, and drop thresholds.
*/
if (rx_enable) {
size = FIELD_GET(FBNIC_RXB_PBUF_SIZE,
rd32(fbd, FBNIC_RXB_PBUF_CFG(i)));
if (size < fifo_config[i].size)
dev_warn(fbd->dev,
"fifo%d size of %d smaller than expected value of %d\n",
i, size << 11,
fifo_config[i].size << 11);
} else {
/* Program RXB Cuthrough */
wr32(fbd, FBNIC_RXB_CT_SIZE(i),
FIELD_PREP(FBNIC_RXB_CT_SIZE_HEADER, 4) |
FIELD_PREP(FBNIC_RXB_CT_SIZE_PAYLOAD, 2));
/* The granularity for the packet buffer size is 2KB
* granularity while the packet buffer base address is
* only 64B granularity
*/
wr32(fbd, FBNIC_RXB_PBUF_CFG(i),
FIELD_PREP(FBNIC_RXB_PBUF_BASE_ADDR,
fifo_config[i].addr) |
FIELD_PREP(FBNIC_RXB_PBUF_SIZE, size));
/* The granularity for the credits is 64B. This is
* based on RXB_PBUF_SIZE * 32 + 4.
*/
wr32(fbd, FBNIC_RXB_PBUF_CREDIT(i),
FIELD_PREP(FBNIC_RXB_PBUF_CREDIT_MASK,
size ? size * 32 + 4 : 0));
}
if (!size)
continue;
/* Pause is size of FIFO with 56KB skid to start/stop */
wr32(fbd, FBNIC_RXB_PAUSE_THLD(i),
!(FBNIC_PAUSE_EN_MASK & (1u << i)) ? 0x1fff :
FIELD_PREP(FBNIC_RXB_PAUSE_THLD_ON,
size * 32 - 0x380) |
FIELD_PREP(FBNIC_RXB_PAUSE_THLD_OFF, 0x380));
/* Enable Drop when only one packet is left in the FIFO */
Annotation
- Immediate include surface: `linux/bitfield.h`, `net/tcp.h`, `fbnic.h`, `fbnic_mac.h`, `fbnic_netdev.h`.
- Detected declarations: `struct fbnic_fifo_config`, `function fbnic_init_readrq`, `function fbnic_init_mps`, `function fbnic_mac_init_axi`, `function fbnic_mac_init_qm`, `function fbnic_mac_init_rxb`, `function fbnic_mac_init_txb`, `function fbnic_mac_init_regs`, `function __fbnic_mac_stat_rd64`, `function fbnic_mac_stat_rd32`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.