// SPDX-License-Identifier: GPL-2.0-only /* * Copyright(c) 2015 EZchip Technologies. */ #include <linux/module.h> #include <linux/etherdevice.h> #include <linux/interrupt.h> #include <linux/mod_devicetable.h> #include <linux/of_net.h> #include <linux/platform_device.h> #include "nps_enet.h" #define DRV_NAME … static inline bool nps_enet_is_tx_pending(struct nps_enet_priv *priv) { … } static void nps_enet_clean_rx_fifo(struct net_device *ndev, u32 frame_len) { … } static void nps_enet_read_rx_fifo(struct net_device *ndev, unsigned char *dst, u32 length) { … } static u32 nps_enet_rx_handler(struct net_device *ndev) { … } static void nps_enet_tx_handler(struct net_device *ndev) { … } /** * nps_enet_poll - NAPI poll handler. * @napi: Pointer to napi_struct structure. * @budget: How many frames to process on one call. * * returns: Number of processed frames */ static int nps_enet_poll(struct napi_struct *napi, int budget) { … } /** * nps_enet_irq_handler - Global interrupt handler for ENET. * @irq: irq number. * @dev_instance: device instance. * * returns: IRQ_HANDLED for all cases. * * EZchip ENET has 2 interrupt causes, and depending on bits raised in * CTRL registers we may tell what is a reason for interrupt to fire up. * We got one for RX and the other for TX (completion). */ static irqreturn_t nps_enet_irq_handler(s32 irq, void *dev_instance) { … } static void nps_enet_set_hw_mac_address(struct net_device *ndev) { … } /** * nps_enet_hw_reset - Reset the network device. * @ndev: Pointer to the network device. * * This function reset the PCS and TX fifo. * The programming model is to set the relevant reset bits * wait for some time for this to propagate and then unset * the reset bits. This way we ensure that reset procedure * is done successfully by device. */ static void nps_enet_hw_reset(struct net_device *ndev) { … } static void nps_enet_hw_enable_control(struct net_device *ndev) { … } static void nps_enet_hw_disable_control(struct net_device *ndev) { … } static void nps_enet_send_frame(struct net_device *ndev, struct sk_buff *skb) { … } /** * nps_enet_set_mac_address - Set the MAC address for this device. * @ndev: Pointer to net_device structure. * @p: 6 byte Address to be written as MAC address. * * This function copies the HW address from the sockaddr structure to the * net_device structure and updates the address in HW. * * returns: -EBUSY if the net device is busy or 0 if the address is set * successfully. */ static s32 nps_enet_set_mac_address(struct net_device *ndev, void *p) { … } /** * nps_enet_set_rx_mode - Change the receive filtering mode. * @ndev: Pointer to the network device. * * This function enables/disables promiscuous mode */ static void nps_enet_set_rx_mode(struct net_device *ndev) { … } /** * nps_enet_open - Open the network device. * @ndev: Pointer to the network device. * * returns: 0, on success or non-zero error value on failure. * * This function sets the MAC address, requests and enables an IRQ * for the ENET device and starts the Tx queue. */ static s32 nps_enet_open(struct net_device *ndev) { … } /** * nps_enet_stop - Close the network device. * @ndev: Pointer to the network device. * * This function stops the Tx queue, disables interrupts for the ENET device. */ static s32 nps_enet_stop(struct net_device *ndev) { … } /** * nps_enet_start_xmit - Starts the data transmission. * @skb: sk_buff pointer that contains data to be Transmitted. * @ndev: Pointer to net_device structure. * * returns: NETDEV_TX_OK, on success * NETDEV_TX_BUSY, if any of the descriptors are not free. * * This function is invoked from upper layers to initiate transmission. */ static netdev_tx_t nps_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev) { … } #ifdef CONFIG_NET_POLL_CONTROLLER static void nps_enet_poll_controller(struct net_device *ndev) { … } #endif static const struct net_device_ops nps_netdev_ops = …; static s32 nps_enet_probe(struct platform_device *pdev) { … } static void nps_enet_remove(struct platform_device *pdev) { … } static const struct of_device_id nps_enet_dt_ids[] = …; MODULE_DEVICE_TABLE(of, nps_enet_dt_ids); static struct platform_driver nps_enet_driver = …; module_platform_driver(…) …; MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …;