// SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2019 - 2022 Beijing WangXun Technology Co., Ltd. */ #include <linux/types.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/netdevice.h> #include <linux/string.h> #include <linux/etherdevice.h> #include <net/ip.h> #include <linux/phy.h> #include <linux/if_vlan.h> #include "../libwx/wx_type.h" #include "../libwx/wx_hw.h" #include "../libwx/wx_lib.h" #include "ngbe_type.h" #include "ngbe_mdio.h" #include "ngbe_hw.h" #include "ngbe_ethtool.h" char ngbe_driver_name[] = …; /* ngbe_pci_tbl - PCI Device ID Table * * { Vendor ID, Device ID, SubVendor ID, SubDevice ID, * Class, Class Mask, private data (not used) } */ static const struct pci_device_id ngbe_pci_tbl[] = …; /** * ngbe_init_type_code - Initialize the shared code * @wx: pointer to hardware structure **/ static void ngbe_init_type_code(struct wx *wx) { … } /** * ngbe_sw_init - Initialize general software structures * @wx: board private structure to initialize **/ static int ngbe_sw_init(struct wx *wx) { … } /** * ngbe_irq_enable - Enable default interrupt generation settings * @wx: board private structure * @queues: enable all queues interrupts **/ static void ngbe_irq_enable(struct wx *wx, bool queues) { … } /** * ngbe_intr - msi/legacy mode Interrupt Handler * @irq: interrupt number * @data: pointer to a network interface device structure **/ static irqreturn_t ngbe_intr(int __always_unused irq, void *data) { … } static irqreturn_t ngbe_msix_other(int __always_unused irq, void *data) { … } /** * ngbe_request_msix_irqs - Initialize MSI-X interrupts * @wx: board private structure * * ngbe_request_msix_irqs allocates MSI-X vectors and requests * interrupts from the kernel. **/ static int ngbe_request_msix_irqs(struct wx *wx) { … } /** * ngbe_request_irq - initialize interrupts * @wx: board private structure * * Attempts to configure interrupts using the best available * capabilities of the hardware and kernel. **/ static int ngbe_request_irq(struct wx *wx) { … } static void ngbe_disable_device(struct wx *wx) { … } void ngbe_down(struct wx *wx) { … } void ngbe_up(struct wx *wx) { … } /** * ngbe_open - Called when a network interface is made active * @netdev: network interface device structure * * Returns 0 on success, negative value on failure * * The open entry point is called when a network interface is made * active by the system (IFF_UP). **/ static int ngbe_open(struct net_device *netdev) { … } /** * ngbe_close - Disables a network interface * @netdev: network interface device structure * * Returns 0, this is not allowed to fail * * The close entry point is called when an interface is de-activated * by the OS. The hardware is still under the drivers control, but * needs to be disabled. A global MAC reset is issued to stop the * hardware, and all transmit and receive resources are freed. **/ static int ngbe_close(struct net_device *netdev) { … } static void ngbe_dev_shutdown(struct pci_dev *pdev, bool *enable_wake) { … } static void ngbe_shutdown(struct pci_dev *pdev) { … } /** * ngbe_setup_tc - routine to configure net_device for multiple traffic * classes. * * @dev: net device to configure * @tc: number of traffic classes to enable */ int ngbe_setup_tc(struct net_device *dev, u8 tc) { … } static const struct net_device_ops ngbe_netdev_ops = …; /** * ngbe_probe - Device Initialization Routine * @pdev: PCI device information struct * @ent: entry in ngbe_pci_tbl * * Returns 0 on success, negative on failure * * ngbe_probe initializes an wx identified by a pci_dev structure. * The OS initialization, configuring of the wx private structure, * and a hardware reset occur. **/ static int ngbe_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent) { … } /** * ngbe_remove - Device Removal Routine * @pdev: PCI device information struct * * ngbe_remove is called by the PCI subsystem to alert the driver * that it should release a PCI device. The could be caused by a * Hot-Plug event, or because the driver is going to be removed from * memory. **/ static void ngbe_remove(struct pci_dev *pdev) { … } static int ngbe_suspend(struct pci_dev *pdev, pm_message_t state) { … } static int ngbe_resume(struct pci_dev *pdev) { … } static struct pci_driver ngbe_driver = …; module_pci_driver(…) …; MODULE_DEVICE_TABLE(pci, ngbe_pci_tbl); MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …;