drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c- Extension
.c- Size
- 102659 bytes
- Lines
- 3713
- 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.
- 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/ethtool.hlinux/netdevice.hlinux/types.hlinux/sched.hlinux/crc32.hbnx2x.hbnx2x_cmn.hbnx2x_dump.hbnx2x_init.h
Detected Declarations
struct code_entrystruct crc_pairfunction bnx2x_get_port_typefunction bnx2x_get_vf_link_ksettingsfunction bnx2x_get_link_ksettingsfunction bnx2x_set_link_ksettingsfunction __bnx2x_get_preset_regs_lenfunction __bnx2x_get_regs_lenfunction bnx2x_get_regs_lenfunction __bnx2x_get_page_reg_numfunction __bnx2x_get_page_write_numfunction __bnx2x_get_page_read_numfunction bnx2x_is_reg_in_chipfunction bnx2x_is_wreg_in_chipfunction addressfunction __bnx2x_get_preset_regsfunction IS_REG_IN_PRESETfunction __bnx2x_get_regsfunction bnx2x_get_regsfunction bnx2x_get_preset_regs_lenfunction bnx2x_set_dumpfunction bnx2x_get_dump_flagfunction bnx2x_get_dump_datafunction bnx2x_get_drvinfofunction bnx2x_get_wolfunction bnx2x_set_wolfunction bnx2x_get_msglevelfunction bnx2x_set_msglevelfunction bnx2x_nway_resetfunction bnx2x_get_linkfunction bnx2x_get_eeprom_lenfunction bnx2x_acquire_nvram_lockfunction bnx2x_release_nvram_lockfunction bnx2x_enable_nvram_accessfunction bnx2x_disable_nvram_accessfunction bnx2x_nvram_read_dwordfunction bnx2x_nvram_readfunction bnx2x_nvram_read32function bnx2x_is_nvm_accessiblefunction bnx2x_get_eepromfunction bnx2x_get_module_eepromfunction bnx2x_get_module_infofunction bnx2x_nvram_write_dwordfunction bnx2x_nvram_write1function bnx2x_nvram_writefunction bnx2x_set_eepromfunction bnx2x_get_coalescefunction bnx2x_set_coalesce
Annotated Snippet
struct code_entry {
u32 sram_start_addr;
u32 code_attribute;
#define CODE_IMAGE_TYPE_MASK 0xf0800003
#define CODE_IMAGE_VNTAG_PROFILES_DATA 0xd0000003
#define CODE_IMAGE_LENGTH_MASK 0x007ffffc
#define CODE_IMAGE_TYPE_EXTENDED_DIR 0xe0000000
u32 nvm_start_addr;
};
#define CODE_ENTRY_MAX 16
#define CODE_ENTRY_EXTENDED_DIR_IDX 15
#define MAX_IMAGES_IN_EXTENDED_DIR 64
#define NVRAM_DIR_OFFSET 0x14
#define EXTENDED_DIR_EXISTS(code) \
((code & CODE_IMAGE_TYPE_MASK) == CODE_IMAGE_TYPE_EXTENDED_DIR && \
(code & CODE_IMAGE_LENGTH_MASK) != 0)
#define CRC32_RESIDUAL 0xdebb20e3
#define CRC_BUFF_SIZE 256
static int bnx2x_nvram_crc(struct bnx2x *bp,
int offset,
int size,
u8 *buff)
{
u32 crc = ~0;
int rc = 0, done = 0;
DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
"NVRAM CRC from 0x%08x to 0x%08x\n", offset, offset + size);
while (done < size) {
int count = min_t(int, size - done, CRC_BUFF_SIZE);
rc = bnx2x_nvram_read(bp, offset + done, buff, count);
if (rc)
return rc;
crc = crc32_le(crc, buff, count);
done += count;
}
if (crc != CRC32_RESIDUAL)
rc = -EINVAL;
return rc;
}
static int bnx2x_test_nvram_dir(struct bnx2x *bp,
struct code_entry *entry,
u8 *buff)
{
size_t size = entry->code_attribute & CODE_IMAGE_LENGTH_MASK;
u32 type = entry->code_attribute & CODE_IMAGE_TYPE_MASK;
int rc;
/* Zero-length images and AFEX profiles do not have CRC */
if (size == 0 || type == CODE_IMAGE_VNTAG_PROFILES_DATA)
return 0;
rc = bnx2x_nvram_crc(bp, entry->nvm_start_addr, size, buff);
if (rc)
DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
"image %x has failed crc test (rc %d)\n", type, rc);
return rc;
}
static int bnx2x_test_dir_entry(struct bnx2x *bp, u32 addr, u8 *buff)
{
int rc;
struct code_entry entry;
rc = bnx2x_nvram_read32(bp, addr, (u32 *)&entry, sizeof(entry));
if (rc)
return rc;
return bnx2x_test_nvram_dir(bp, &entry, buff);
}
static int bnx2x_test_nvram_ext_dirs(struct bnx2x *bp, u8 *buff)
{
u32 rc, cnt, dir_offset = NVRAM_DIR_OFFSET;
struct code_entry entry;
int i;
rc = bnx2x_nvram_read32(bp,
Annotation
- Immediate include surface: `linux/ethtool.h`, `linux/netdevice.h`, `linux/types.h`, `linux/sched.h`, `linux/crc32.h`, `bnx2x.h`, `bnx2x_cmn.h`, `bnx2x_dump.h`.
- Detected declarations: `struct code_entry`, `struct crc_pair`, `function bnx2x_get_port_type`, `function bnx2x_get_vf_link_ksettings`, `function bnx2x_get_link_ksettings`, `function bnx2x_set_link_ksettings`, `function __bnx2x_get_preset_regs_len`, `function __bnx2x_get_regs_len`, `function bnx2x_get_regs_len`, `function __bnx2x_get_page_reg_num`.
- 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.