linux/drivers/net/ethernet/atheros/atl1c/atl1c_main.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Copyright(c) 2008 - 2009 Atheros Corporation. All rights reserved.
 *
 * Derived from Intel e1000 driver
 * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
 */

#include "atl1c.h"

char atl1c_driver_name[] =;

/*
 * atl1c_pci_tbl - PCI Device ID Table
 *
 * Wildcard entries (PCI_ANY_ID) should come last
 * Last entry must be all 0s
 *
 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID,
 *   Class, Class Mask, private data (not used) }
 */
static const struct pci_device_id atl1c_pci_tbl[] =;
MODULE_DEVICE_TABLE(pci, atl1c_pci_tbl);

MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();

struct atl1c_qregs {};

static struct atl1c_qregs atl1c_qregs[AT_MAX_TRANSMIT_QUEUE] =;

static int atl1c_stop_mac(struct atl1c_hw *hw);
static void atl1c_disable_l0s_l1(struct atl1c_hw *hw);
static void atl1c_set_aspm(struct atl1c_hw *hw, u16 link_speed);
static void atl1c_start_mac(struct atl1c_adapter *adapter);
static int atl1c_up(struct atl1c_adapter *adapter);
static void atl1c_down(struct atl1c_adapter *adapter);
static int atl1c_reset_mac(struct atl1c_hw *hw);
static void atl1c_reset_dma_ring(struct atl1c_adapter *adapter);
static int atl1c_configure(struct atl1c_adapter *adapter);
static int atl1c_alloc_rx_buffer(struct atl1c_adapter *adapter, u32 queue,
				 bool napi_mode);


static const u32 atl1c_default_msg =;
static void atl1c_pcie_patch(struct atl1c_hw *hw)
{}

/* FIXME: no need any more ? */
/*
 * atl1c_init_pcie - init PCIE module
 */
static void atl1c_reset_pcie(struct atl1c_hw *hw, u32 flag)
{}

/**
 * atl1c_irq_enable - Enable default interrupt generation settings
 * @adapter: board private structure
 */
static inline void atl1c_irq_enable(struct atl1c_adapter *adapter)
{}

/**
 * atl1c_irq_disable - Mask off interrupt generation on the NIC
 * @adapter: board private structure
 */
static inline void atl1c_irq_disable(struct atl1c_adapter *adapter)
{}

/*
 * atl1c_wait_until_idle - wait up to AT_HW_MAX_IDLE_DELAY reads
 * of the idle status register until the device is actually idle
 */
static u32 atl1c_wait_until_idle(struct atl1c_hw *hw, u32 modu_ctrl)
{}

/**
 * atl1c_phy_config - Timer Call-back
 * @t: timer list containing pointer to netdev cast into an unsigned long
 */
static void atl1c_phy_config(struct timer_list *t)
{}

void atl1c_reinit_locked(struct atl1c_adapter *adapter)
{}

static void atl1c_check_link_status(struct atl1c_adapter *adapter)
{}

static void atl1c_link_chg_event(struct atl1c_adapter *adapter)
{}

static void atl1c_common_task(struct work_struct *work)
{}


static void atl1c_del_timer(struct atl1c_adapter *adapter)
{}


/**
 * atl1c_tx_timeout - Respond to a Tx Hang
 * @netdev: network interface device structure
 * @txqueue: index of hanging tx queue
 */
static void atl1c_tx_timeout(struct net_device *netdev, unsigned int txqueue)
{}

/**
 * atl1c_set_multi - Multicast and Promiscuous mode set
 * @netdev: network interface device structure
 *
 * The set_multi entry point is called whenever the multicast address
 * list or the network interface flags are updated.  This routine is
 * responsible for configuring the hardware for proper multicast,
 * promiscuous mode, and all-multi behavior.
 */
static void atl1c_set_multi(struct net_device *netdev)
{}

static void __atl1c_vlan_mode(netdev_features_t features, u32 *mac_ctrl_data)
{}

static void atl1c_vlan_mode(struct net_device *netdev,
	netdev_features_t features)
{}

static void atl1c_restore_vlan(struct atl1c_adapter *adapter)
{}

/**
 * atl1c_set_mac_addr - Change the Ethernet Address of the NIC
 * @netdev: network interface device structure
 * @p: pointer to an address structure
 *
 * Returns 0 on success, negative on failure
 */
static int atl1c_set_mac_addr(struct net_device *netdev, void *p)
{}

static void atl1c_set_rxbufsize(struct atl1c_adapter *adapter,
				struct net_device *dev)
{}

static netdev_features_t atl1c_fix_features(struct net_device *netdev,
	netdev_features_t features)
{}

static int atl1c_set_features(struct net_device *netdev,
	netdev_features_t features)
{}

static void atl1c_set_max_mtu(struct net_device *netdev)
{}

/**
 * atl1c_change_mtu - Change the Maximum Transfer Unit
 * @netdev: network interface device structure
 * @new_mtu: new value for maximum frame size
 *
 * Returns 0 on success, negative on failure
 */
static int atl1c_change_mtu(struct net_device *netdev, int new_mtu)
{}

/*
 *  caller should hold mdio_lock
 */
static int atl1c_mdio_read(struct net_device *netdev, int phy_id, int reg_num)
{}

static void atl1c_mdio_write(struct net_device *netdev, int phy_id,
			     int reg_num, int val)
{}

static int atl1c_mii_ioctl(struct net_device *netdev,
			   struct ifreq *ifr, int cmd)
{}

static int atl1c_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
{}

/**
 * atl1c_alloc_queues - Allocate memory for all rings
 * @adapter: board private structure to initialize
 *
 */
static int atl1c_alloc_queues(struct atl1c_adapter *adapter)
{}

static enum atl1c_nic_type atl1c_get_mac_type(struct pci_dev *pdev,
					      u8 __iomem *hw_addr)
{}

static int atl1c_setup_mac_funcs(struct atl1c_hw *hw)
{}

struct atl1c_platform_patch {};
static const struct atl1c_platform_patch plats[] =;

static void atl1c_patch_assign(struct atl1c_hw *hw)
{}
/**
 * atl1c_sw_init - Initialize general software structures (struct atl1c_adapter)
 * @adapter: board private structure to initialize
 *
 * atl1c_sw_init initializes the Adapter private data structure.
 * Fields are initialized based on PCI device information and
 * OS network device settings (MTU size).
 */
static int atl1c_sw_init(struct atl1c_adapter *adapter)
{}

static inline void atl1c_clean_buffer(struct pci_dev *pdev,
				      struct atl1c_buffer *buffer_info,
				      int budget)
{}
/**
 * atl1c_clean_tx_ring - Free Tx-skb
 * @adapter: board private structure
 * @queue: idx of transmit queue
 */
static void atl1c_clean_tx_ring(struct atl1c_adapter *adapter,
				u32 queue)
{}

/**
 * atl1c_clean_rx_ring - Free rx-reservation skbs
 * @adapter: board private structure
 * @queue: idx of transmit queue
 */
static void atl1c_clean_rx_ring(struct atl1c_adapter *adapter, u32 queue)
{}

/*
 * Read / Write Ptr Initialize:
 */
static void atl1c_init_ring_ptrs(struct atl1c_adapter *adapter)
{}

/**
 * atl1c_free_ring_resources - Free Tx / RX descriptor Resources
 * @adapter: board private structure
 *
 * Free all transmit software resources
 */
static void atl1c_free_ring_resources(struct atl1c_adapter *adapter)
{}

/**
 * atl1c_setup_ring_resources - allocate Tx / RX descriptor resources
 * @adapter: board private structure
 *
 * Return 0 on success, negative on failure
 */
static int atl1c_setup_ring_resources(struct atl1c_adapter *adapter)
{}

static void atl1c_configure_des_ring(struct atl1c_adapter *adapter)
{}

static void atl1c_configure_tx(struct atl1c_adapter *adapter)
{}

static void atl1c_configure_rx(struct atl1c_adapter *adapter)
{}

static void atl1c_configure_dma(struct atl1c_adapter *adapter)
{}

/*
 * Stop the mac, transmit and receive units
 * hw - Struct containing variables accessed by shared code
 * return : 0  or  idle status (if error)
 */
static int atl1c_stop_mac(struct atl1c_hw *hw)
{}

static void atl1c_start_mac(struct atl1c_adapter *adapter)
{}

/*
 * Reset the transmit and receive units; mask and clear all interrupts.
 * hw - Struct containing variables accessed by shared code
 * return : 0  or  idle status (if error)
 */
static int atl1c_reset_mac(struct atl1c_hw *hw)
{}

static void atl1c_disable_l0s_l1(struct atl1c_hw *hw)
{}

/*
 * Set ASPM state.
 * Enable/disable L0s/L1 depend on link state.
 */
static void atl1c_set_aspm(struct atl1c_hw *hw, u16 link_speed)
{}

/**
 * atl1c_configure_mac - Configure Transmit&Receive Unit after Reset
 * @adapter: board private structure
 *
 * Configure the Tx /Rx unit of the MAC after a reset.
 */
static int atl1c_configure_mac(struct atl1c_adapter *adapter)
{}

static int atl1c_configure(struct atl1c_adapter *adapter)
{}

static void atl1c_update_hw_stats(struct atl1c_adapter *adapter)
{}

/**
 * atl1c_get_stats - Get System Network Statistics
 * @netdev: network interface device structure
 *
 * Returns the address of the device statistics structure.
 * The statistics are actually updated from the timer callback.
 */
static struct net_device_stats *atl1c_get_stats(struct net_device *netdev)
{}

static inline void atl1c_clear_phy_int(struct atl1c_adapter *adapter)
{}

static int atl1c_clean_tx(struct napi_struct *napi, int budget)
{}

static void atl1c_intr_rx_tx(struct atl1c_adapter *adapter, u32 status)
{}

/**
 * atl1c_intr - Interrupt Handler
 * @irq: interrupt number
 * @data: pointer to a network interface device structure
 */
static irqreturn_t atl1c_intr(int irq, void *data)
{}

static inline void atl1c_rx_checksum(struct atl1c_adapter *adapter,
		  struct sk_buff *skb, struct atl1c_recv_ret_status *prrs)
{}

static int atl1c_alloc_rx_buffer(struct atl1c_adapter *adapter, u32 queue,
				 bool napi_mode)
{}

static void atl1c_clean_rrd(struct atl1c_rrd_ring *rrd_ring,
			struct	atl1c_recv_ret_status *rrs, u16 num)
{}

static void atl1c_clean_rfd(struct atl1c_rfd_ring *rfd_ring,
	struct atl1c_recv_ret_status *rrs, u16 num)
{}

/**
 * atl1c_clean_rx - NAPI Rx polling callback
 * @napi: napi info
 * @budget: limit of packets to clean
 */
static int atl1c_clean_rx(struct napi_struct *napi, int budget)
{}

#ifdef CONFIG_NET_POLL_CONTROLLER

/*
 * Polling 'interrupt' - used by things like netconsole to send skbs
 * without having to re-enable interrupts. It's not called while
 * the interrupt routine is executing.
 */
static void atl1c_netpoll(struct net_device *netdev)
{}
#endif

static inline u16 atl1c_tpd_avail(struct atl1c_adapter *adapter, u32 queue)
{}

/*
 * get next usable tpd
 * Note: should call atl1c_tdp_avail to make sure
 * there is enough tpd to use
 */
static struct atl1c_tpd_desc *atl1c_get_tpd(struct atl1c_adapter *adapter,
					    u32 queue)
{}

static struct atl1c_buffer *
atl1c_get_tx_buffer(struct atl1c_adapter *adapter, struct atl1c_tpd_desc *tpd)
{}

/* Calculate the transmit packet descript needed*/
static u16 atl1c_cal_tpd_req(const struct sk_buff *skb)
{}

static int atl1c_tso_csum(struct atl1c_adapter *adapter,
			  struct sk_buff *skb,
			  struct atl1c_tpd_desc **tpd,
			  u32 queue)
{}

static void atl1c_tx_rollback(struct atl1c_adapter *adpt,
			      struct atl1c_tpd_desc *first_tpd,
			      u32 queue)
{}

static int atl1c_tx_map(struct atl1c_adapter *adapter,
			struct sk_buff *skb, struct atl1c_tpd_desc *tpd,
			u32 queue)
{}

static void atl1c_tx_queue(struct atl1c_adapter *adapter, u32 queue)
{}

static netdev_tx_t atl1c_xmit_frame(struct sk_buff *skb,
					  struct net_device *netdev)
{}

static void atl1c_free_irq(struct atl1c_adapter *adapter)
{}

static int atl1c_request_irq(struct atl1c_adapter *adapter)
{}


static void atl1c_reset_dma_ring(struct atl1c_adapter *adapter)
{}

static int atl1c_up(struct atl1c_adapter *adapter)
{}

static void atl1c_down(struct atl1c_adapter *adapter)
{}

/**
 * atl1c_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).  At this point all resources needed
 * for transmit and receive operations are allocated, the interrupt
 * handler is registered with the OS, the watchdog timer is started,
 * and the stack is notified that the interface is ready.
 */
static int atl1c_open(struct net_device *netdev)
{}

/**
 * atl1c_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 atl1c_close(struct net_device *netdev)
{}

static int atl1c_suspend(struct device *dev)
{}

#ifdef CONFIG_PM_SLEEP
static int atl1c_resume(struct device *dev)
{}
#endif

static void atl1c_shutdown(struct pci_dev *pdev)
{}

static const struct net_device_ops atl1c_netdev_ops =;

static int atl1c_init_netdev(struct net_device *netdev, struct pci_dev *pdev)
{}

/**
 * atl1c_probe - Device Initialization Routine
 * @pdev: PCI device information struct
 * @ent: entry in atl1c_pci_tbl
 *
 * Returns 0 on success, negative on failure
 *
 * atl1c_probe initializes an adapter identified by a pci_dev structure.
 * The OS initialization, configuring of the adapter private structure,
 * and a hardware reset occur.
 */
static int atl1c_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{}

/**
 * atl1c_remove - Device Removal Routine
 * @pdev: PCI device information struct
 *
 * atl1c_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 atl1c_remove(struct pci_dev *pdev)
{}

/**
 * atl1c_io_error_detected - called when PCI error is detected
 * @pdev: Pointer to PCI device
 * @state: The current pci connection state
 *
 * This function is called after a PCI bus error affecting
 * this device has been detected.
 */
static pci_ers_result_t atl1c_io_error_detected(struct pci_dev *pdev,
						pci_channel_state_t state)
{}

/**
 * atl1c_io_slot_reset - called after the pci bus has been reset.
 * @pdev: Pointer to PCI device
 *
 * Restart the card from scratch, as if from a cold-boot. Implementation
 * resembles the first-half of the e1000_resume routine.
 */
static pci_ers_result_t atl1c_io_slot_reset(struct pci_dev *pdev)
{}

/**
 * atl1c_io_resume - called when traffic can start flowing again.
 * @pdev: Pointer to PCI device
 *
 * This callback is called when the error recovery driver tells us that
 * its OK to resume normal operation. Implementation resembles the
 * second-half of the atl1c_resume routine.
 */
static void atl1c_io_resume(struct pci_dev *pdev)
{}

static const struct pci_error_handlers atl1c_err_handler =;

static SIMPLE_DEV_PM_OPS(atl1c_pm_ops, atl1c_suspend, atl1c_resume);

static struct pci_driver atl1c_driver =;

module_pci_driver();