drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c- Extension
.c- Size
- 13293 bytes
- Lines
- 532
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/etherdevice.hlinux/if_vlan.hlinux/netdevice.hlinux/pci.hlinux/phy.hhbg_common.hhbg_diagnose.hhbg_err.hhbg_ethtool.hhbg_hw.hhbg_irq.hhbg_mdio.hhbg_txrx.hhbg_debugfs.h
Detected Declarations
function hbg_all_irq_enablefunction hbg_net_openfunction hbg_hw_txrx_clearfunction hbg_net_stopfunction hbg_update_promisc_modefunction hbg_set_mac_to_mac_tablefunction hbg_get_index_from_mac_tablefunction hbg_add_mac_to_filterfunction hbg_del_mac_from_filterfunction hbg_uc_syncfunction hbg_uc_unsyncfunction hbg_net_set_rx_modefunction hbg_net_set_mac_addressfunction hbg_net_change_mtufunction hbg_net_tx_timeoutfunction hbg_net_get_statsfunction hbg_service_taskfunction hbg_err_reset_task_schedulefunction hbg_np_link_fail_task_schedulefunction hbg_cancel_delayed_work_syncfunction hbg_delaywork_initfunction hbg_mac_filter_initfunction hbg_init_user_deffunction hbg_initfunction hbg_pci_initfunction hbg_probefunction hbg_shutdownfunction hbg_module_initfunction hbg_module_exitmodule init hbg_module_init
Annotated Snippet
static const struct net_device_ops hbg_netdev_ops = {
.ndo_open = hbg_net_open,
.ndo_stop = hbg_net_stop,
.ndo_start_xmit = hbg_net_start_xmit,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = hbg_net_set_mac_address,
.ndo_change_mtu = hbg_net_change_mtu,
.ndo_tx_timeout = hbg_net_tx_timeout,
.ndo_set_rx_mode = hbg_net_set_rx_mode,
.ndo_get_stats64 = hbg_net_get_stats,
.ndo_eth_ioctl = phy_do_ioctl_running,
};
static void hbg_service_task(struct work_struct *work)
{
struct hbg_priv *priv = container_of(work, struct hbg_priv,
service_task.work);
if (test_and_clear_bit(HBG_NIC_STATE_NEED_RESET, &priv->state))
hbg_err_reset(priv);
if (test_and_clear_bit(HBG_NIC_STATE_NP_LINK_FAIL, &priv->state))
hbg_fix_np_link_fail(priv);
hbg_diagnose_message_push(priv);
/* The type of statistics register is u32,
* To prevent the statistics register from overflowing,
* the driver dumps the statistics every 30 seconds.
*/
if (time_after(jiffies, priv->last_update_stats_time + 30 * HZ)) {
hbg_update_stats(priv);
priv->last_update_stats_time = jiffies;
}
schedule_delayed_work(&priv->service_task,
msecs_to_jiffies(MSEC_PER_SEC));
}
void hbg_err_reset_task_schedule(struct hbg_priv *priv)
{
set_bit(HBG_NIC_STATE_NEED_RESET, &priv->state);
schedule_delayed_work(&priv->service_task, 0);
}
void hbg_np_link_fail_task_schedule(struct hbg_priv *priv)
{
set_bit(HBG_NIC_STATE_NP_LINK_FAIL, &priv->state);
schedule_delayed_work(&priv->service_task, 0);
}
static void hbg_cancel_delayed_work_sync(void *data)
{
cancel_delayed_work_sync(data);
}
static int hbg_delaywork_init(struct hbg_priv *priv)
{
INIT_DELAYED_WORK(&priv->service_task, hbg_service_task);
schedule_delayed_work(&priv->service_task, 0);
return devm_add_action_or_reset(&priv->pdev->dev,
hbg_cancel_delayed_work_sync,
&priv->service_task);
}
static int hbg_mac_filter_init(struct hbg_priv *priv)
{
struct hbg_dev_specs *dev_specs = &priv->dev_specs;
struct hbg_mac_filter *filter = &priv->filter;
struct hbg_mac_table_entry *tmp_table;
tmp_table = devm_kcalloc(&priv->pdev->dev, dev_specs->uc_mac_num,
sizeof(*tmp_table), GFP_KERNEL);
if (!tmp_table)
return -ENOMEM;
filter->mac_table = tmp_table;
filter->table_max_len = dev_specs->uc_mac_num;
filter->enabled = true;
hbg_hw_set_mac_filter_enable(priv, filter->enabled);
return 0;
}
static void hbg_init_user_def(struct hbg_priv *priv)
{
struct ethtool_pauseparam *pause_param = &priv->user_def.pause_param;
priv->mac.pause_autoneg = HBG_STATUS_ENABLE;
Annotation
- Immediate include surface: `linux/etherdevice.h`, `linux/if_vlan.h`, `linux/netdevice.h`, `linux/pci.h`, `linux/phy.h`, `hbg_common.h`, `hbg_diagnose.h`, `hbg_err.h`.
- Detected declarations: `function hbg_all_irq_enable`, `function hbg_net_open`, `function hbg_hw_txrx_clear`, `function hbg_net_stop`, `function hbg_update_promisc_mode`, `function hbg_set_mac_to_mac_table`, `function hbg_get_index_from_mac_table`, `function hbg_add_mac_to_filter`, `function hbg_del_mac_from_filter`, `function hbg_uc_sync`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern 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.