drivers/net/ethernet/wangxun/libwx/wx_sriov.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/wangxun/libwx/wx_sriov.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/wangxun/libwx/wx_sriov.c- Extension
.c- Size
- 22852 bytes
- Lines
- 928
- 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.
- 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/pci.hwx_type.hwx_hw.hwx_mbx.hwx_sriov.h
Detected Declarations
function wx_vf_configurationfunction wx_alloc_vf_macvlansfunction wx_sriov_clear_datafunction __wx_enable_sriovfunction wx_sriov_reinitfunction wx_disable_sriovfunction wx_pci_sriov_enablefunction wx_pci_sriov_disablefunction wx_pci_sriov_configurefunction wx_set_vf_macfunction wx_set_vmolrfunction wx_set_vmvirfunction wx_set_vf_vlanfunction wx_set_vlan_anti_spoofingfunction wx_write_qdefunction wx_clear_vmvirfunction wx_ping_vffunction wx_set_vf_rx_txfunction wx_get_vf_queuesfunction wx_vf_reset_eventfunction wx_vf_reset_msgfunction wx_set_vf_mac_addrfunction wx_set_vf_multicastsfunction wx_set_vf_lpefunction wx_find_vlvf_entryfunction wx_set_vf_macvlanfunction wx_set_vf_vlan_msgfunction wx_set_vf_macvlan_msgfunction wx_negotiate_vf_apifunction wx_get_vf_link_statefunction wx_get_fw_versionfunction wx_update_vf_xcast_modefunction wx_rcv_msg_from_vffunction wx_rcv_ack_from_vffunction wx_msg_taskfunction wx_disable_vf_rx_txfunction wx_ping_all_vfs_with_link_statusfunction wx_set_vf_link_statefunction wx_set_all_vfsexport wx_disable_sriovexport wx_pci_sriov_configureexport wx_msg_taskexport wx_disable_vf_rx_txexport wx_ping_all_vfs_with_link_statusexport wx_set_all_vfs
Annotated Snippet
memcmp(wx->vfinfo[vf].vf_mac_addr, new_mac, ETH_ALEN)) {
wx_err(wx,
"VF %d attempt to set a MAC but it already had a MAC.",
vf);
return -EBUSY;
}
ret = wx_set_vf_mac(wx, vf, new_mac);
if (ret < 0)
return ret;
return 0;
}
static void wx_set_vf_multicasts(struct wx *wx, u32 *msgbuf, u32 vf)
{
struct vf_data_storage *vfinfo = &wx->vfinfo[vf];
u16 entries = (msgbuf[0] & WX_VT_MSGINFO_MASK)
>> WX_VT_MSGINFO_SHIFT;
u32 vmolr = rd32(wx, WX_PSR_VM_L2CTL(vf));
u32 vector_bit, vector_reg, mta_reg, i;
u16 *hash_list = (u16 *)&msgbuf[1];
/* only so many hash values supported */
entries = min_t(u16, entries, WX_MAX_VF_MC_ENTRIES);
vfinfo->num_vf_mc_hashes = entries;
for (i = 0; i < entries; i++)
vfinfo->vf_mc_hashes[i] = hash_list[i];
for (i = 0; i < vfinfo->num_vf_mc_hashes; i++) {
vector_reg = WX_PSR_MC_TBL_REG(vfinfo->vf_mc_hashes[i]);
vector_bit = WX_PSR_MC_TBL_BIT(vfinfo->vf_mc_hashes[i]);
mta_reg = wx->mac.mta_shadow[vector_reg];
mta_reg |= BIT(vector_bit);
wx->mac.mta_shadow[vector_reg] = mta_reg;
wr32(wx, WX_PSR_MC_TBL(vector_reg), mta_reg);
}
vmolr |= WX_PSR_VM_L2CTL_ROMPE;
wr32(wx, WX_PSR_VM_L2CTL(vf), vmolr);
}
static void wx_set_vf_lpe(struct wx *wx, u32 max_frame, u32 vf)
{
u32 index, vf_bit, vfre;
u32 max_frs, reg_val;
/* determine VF receive enable location */
index = WX_VF_REG_OFFSET(vf);
vf_bit = WX_VF_IND_SHIFT(vf);
vfre = rd32(wx, WX_RDM_VF_RE(index));
vfre |= BIT(vf_bit);
wr32(wx, WX_RDM_VF_RE(index), vfre);
/* pull current max frame size from hardware */
max_frs = DIV_ROUND_UP(max_frame, 1024);
reg_val = rd32(wx, WX_MAC_WDG_TIMEOUT) & WX_MAC_WDG_TIMEOUT_WTO_MASK;
if (max_frs > (reg_val + WX_MAC_WDG_TIMEOUT_WTO_DELTA))
wr32(wx, WX_MAC_WDG_TIMEOUT,
max_frs - WX_MAC_WDG_TIMEOUT_WTO_DELTA);
}
static int wx_find_vlvf_entry(struct wx *wx, u32 vlan)
{
int regindex;
u32 vlvf;
/* short cut the special case */
if (vlan == 0)
return 0;
/* Search for the vlan id in the VLVF entries */
for (regindex = 1; regindex < WX_PSR_VLAN_SWC_ENTRIES; regindex++) {
wr32(wx, WX_PSR_VLAN_SWC_IDX, regindex);
vlvf = rd32(wx, WX_PSR_VLAN_SWC);
if ((vlvf & VLAN_VID_MASK) == vlan)
break;
}
/* Return a negative value if not found */
if (regindex >= WX_PSR_VLAN_SWC_ENTRIES)
regindex = -EINVAL;
return regindex;
}
static int wx_set_vf_macvlan(struct wx *wx,
u16 vf, int index, unsigned char *mac_addr)
{
Annotation
- Immediate include surface: `linux/etherdevice.h`, `linux/pci.h`, `wx_type.h`, `wx_hw.h`, `wx_mbx.h`, `wx_sriov.h`.
- Detected declarations: `function wx_vf_configuration`, `function wx_alloc_vf_macvlans`, `function wx_sriov_clear_data`, `function __wx_enable_sriov`, `function wx_sriov_reinit`, `function wx_disable_sriov`, `function wx_pci_sriov_enable`, `function wx_pci_sriov_disable`, `function wx_pci_sriov_configure`, `function wx_set_vf_mac`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration 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.