drivers/net/ethernet/wangxun/libwx/wx_hw.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/wangxun/libwx/wx_hw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/wangxun/libwx/wx_hw.c- Extension
.c- Size
- 80664 bytes
- Lines
- 3033
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/etherdevice.hlinux/netdevice.hlinux/if_ether.hlinux/if_vlan.hlinux/iopoll.hlinux/pci.hwx_type.hwx_lib.hwx_sriov.hwx_vf.hwx_hw.h
Detected Declarations
function wx_phy_read_reg_mdifunction wx_phy_write_reg_mdifunction wx_phy_read_reg_mdi_c22function wx_phy_write_reg_mdi_c22function wx_phy_read_reg_mdi_c45function wx_phy_write_reg_mdi_c45function wx_intr_disablefunction wx_intr_enablefunction wx_irq_disablefunction wx_fmgr_cmd_opfunction wx_flash_read_dwordfunction wx_check_flash_loadfunction wx_control_hwfunction wx_mng_presentfunction functionfunction functionfunction wx_host_interface_command_sfunction wx_poll_fw_replyfunction wx_host_interface_command_rfunction wx_host_interface_commandfunction wx_set_ppsfunction wx_read_ee_hostif_datafunction wx_read_ee_hostiffunction wordfunction wx_init_eeprom_paramsfunction wx_get_mac_addrfunction wx_set_rarfunction wx_clear_rarfunction wx_clear_vmdqfunction wx_init_uta_tablesfunction wx_init_rx_addrsfunction wx_sync_mac_tablefunction wx_full_sync_mac_tablefunction wx_mac_set_default_filterfunction wx_flush_sw_mac_tablefunction wx_add_mac_filterfunction wx_del_mac_filterfunction wx_available_rarsfunction wx_write_uc_addr_listfunction netdev_for_each_uc_addrfunction wx_mta_vectorfunction wx_set_mtafunction wx_update_mc_addr_listfunction wx_restore_vf_multicastsfunction wx_write_mc_addr_listfunction wx_set_macfunction wx_disable_rxfunction wx_enable_rx
Annotated Snippet
if (status != 0) {
wx_err(wx, "Host interface command failed\n");
goto out;
}
if (!test_bit(WX_FLAG_SWFW_RING, wx->flags))
mbox = WX_MNG_MBOX;
else
mbox = WX_FW2SW_MBOX;
for (i = 0; i < words_to_read; i++) {
u32 reg = mbox + (FW_NVM_DATA_OFFSET << 2) + 2 * i;
value = rd32(wx, reg);
data[current_word] = (u16)(value & 0xffff);
current_word++;
i++;
if (i < words_to_read) {
value >>= 16;
data[current_word] = (u16)(value & 0xffff);
current_word++;
}
}
words -= words_to_read;
}
out:
wx_release_sw_sync(wx, WX_MNG_SWFW_SYNC_SW_FLASH);
return status;
}
EXPORT_SYMBOL(wx_read_ee_hostif_buffer);
/**
* wx_init_eeprom_params - Initialize EEPROM params
* @wx: pointer to hardware structure
*
* Initializes the EEPROM parameters wx_eeprom_info within the
* wx_hw struct in order to set up EEPROM access.
**/
void wx_init_eeprom_params(struct wx *wx)
{
struct wx_eeprom_info *eeprom = &wx->eeprom;
u16 eeprom_size;
u16 data = 0x80;
if (eeprom->type == wx_eeprom_uninitialized) {
eeprom->semaphore_delay = 10;
eeprom->type = wx_eeprom_none;
if (!(rd32(wx, WX_SPI_STATUS) &
WX_SPI_STATUS_FLASH_BYPASS)) {
eeprom->type = wx_flash;
eeprom_size = 4096;
eeprom->word_size = eeprom_size >> 1;
wx_dbg(wx, "Eeprom params: type = %d, size = %d\n",
eeprom->type, eeprom->word_size);
}
}
switch (wx->mac.type) {
case wx_mac_sp:
case wx_mac_aml:
case wx_mac_aml40:
if (wx_read_ee_hostif(wx, WX_SW_REGION_PTR, &data)) {
wx_err(wx, "NVM Read Error\n");
return;
}
data = data >> 1;
break;
default:
break;
}
eeprom->sw_region_offset = data;
}
EXPORT_SYMBOL(wx_init_eeprom_params);
/**
* wx_get_mac_addr - Generic get MAC address
* @wx: pointer to hardware structure
* @mac_addr: Adapter MAC address
*
* Reads the adapter's MAC address from first Receive Address Register (RAR0)
* A reset of the adapter must be performed prior to calling this function
* in order for the MAC address to have been loaded from the EEPROM into RAR0
**/
void wx_get_mac_addr(struct wx *wx, u8 *mac_addr)
{
u32 rar_high;
Annotation
- Immediate include surface: `linux/etherdevice.h`, `linux/netdevice.h`, `linux/if_ether.h`, `linux/if_vlan.h`, `linux/iopoll.h`, `linux/pci.h`, `wx_type.h`, `wx_lib.h`.
- Detected declarations: `function wx_phy_read_reg_mdi`, `function wx_phy_write_reg_mdi`, `function wx_phy_read_reg_mdi_c22`, `function wx_phy_write_reg_mdi_c22`, `function wx_phy_read_reg_mdi_c45`, `function wx_phy_write_reg_mdi_c45`, `function wx_intr_disable`, `function wx_intr_enable`, `function wx_irq_disable`, `function wx_fmgr_cmd_op`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.