#include <linux/module.h>
#include <linux/etherdevice.h>
#include <linux/platform_device.h>
#include <linux/interrupt.h>
#include <linux/ktime.h>
#include <linux/of_address.h>
#include <linux/phy.h>
#include <linux/of_mdio.h>
#include <linux/of_net.h>
#include <linux/mfd/syscon.h>
#include <linux/regmap.h>
#define SC_PPE_RESET_DREQ …
#define PPE_CFG_RX_ADDR …
#define PPE_CFG_POOL_GRP …
#define PPE_CFG_RX_BUF_SIZE …
#define PPE_CFG_RX_FIFO_SIZE …
#define PPE_CURR_BUF_CNT …
#define GE_DUPLEX_TYPE …
#define GE_MAX_FRM_SIZE_REG …
#define GE_PORT_MODE …
#define GE_PORT_EN …
#define GE_SHORT_RUNTS_THR_REG …
#define GE_TX_LOCAL_PAGE_REG …
#define GE_TRANSMIT_CONTROL_REG …
#define GE_CF_CRC_STRIP_REG …
#define GE_MODE_CHANGE_REG …
#define GE_RECV_CONTROL_REG …
#define GE_STATION_MAC_ADDRESS …
#define PPE_CFG_BUS_CTRL_REG …
#define PPE_CFG_RX_CTRL_REG …
#if defined(CONFIG_HI13X1_GMAC)
#define PPE_CFG_CPU_ADD_ADDR …
#define PPE_CFG_MAX_FRAME_LEN_REG …
#define PPE_CFG_RX_PKT_MODE_REG …
#define PPE_CFG_QOS_VMID_GEN …
#define PPE_CFG_RX_PKT_INT …
#define PPE_INTEN …
#define PPE_INTSTS …
#define PPE_RINT …
#define PPE_CFG_STS_MODE …
#else
#define PPE_CFG_CPU_ADD_ADDR …
#define PPE_CFG_MAX_FRAME_LEN_REG …
#define PPE_CFG_RX_PKT_MODE_REG …
#define PPE_CFG_QOS_VMID_GEN …
#define PPE_CFG_RX_PKT_INT …
#define PPE_INTEN …
#define PPE_INTSTS …
#define PPE_RINT …
#define PPE_CFG_STS_MODE …
#endif
#define PPE_HIS_RX_PKT_CNT …
#define RESET_DREQ_ALL …
#define RCV_INT …
#define RCV_NOBUF …
#define RCV_DROP …
#define TX_DROP …
#define DEF_INT_ERR …
#define DEF_INT_MASK …
#define TX_FREE_MEM …
#define TX_READ_ALLOC_L3 …
#if defined(CONFIG_HI13X1_GMAC)
#define TX_CLEAR_WB …
#define TX_RELEASE_TO_PPE …
#define TX_FINISH_CACHE_INV …
#define TX_POOL_SHIFT …
#else
#define TX_CLEAR_WB …
#define TX_FINISH_CACHE_INV …
#endif
#define TX_L3_CHECKSUM …
#define TX_LOOP_BACK …
#define RX_PKT_DROP …
#define RX_L2_ERR …
#define RX_PKT_ERR …
#define SGMII_SPEED_1000 …
#define SGMII_SPEED_100 …
#define SGMII_SPEED_10 …
#define MII_SPEED_100 …
#define MII_SPEED_10 …
#define GE_DUPLEX_FULL …
#define GE_DUPLEX_HALF …
#define GE_MODE_CHANGE_EN …
#define GE_TX_AUTO_NEG …
#define GE_TX_ADD_CRC …
#define GE_TX_SHORT_PAD_THROUGH …
#define GE_RX_STRIP_CRC …
#define GE_RX_STRIP_PAD …
#define GE_RX_PAD_EN …
#define GE_AUTO_NEG_CTL …
#define GE_RX_INT_THRESHOLD …
#define GE_RX_TIMEOUT …
#define GE_RX_PORT_EN …
#define GE_TX_PORT_EN …
#define PPE_CFG_RX_PKT_ALIGN …
#if defined(CONFIG_HI13X1_GMAC)
#define PPE_CFG_QOS_VMID_GRP_SHIFT …
#define PPE_CFG_RX_CTRL_ALIGN_SHIFT …
#define PPE_CFG_STS_RX_PKT_CNT_RC …
#define PPE_CFG_QOS_VMID_MODE …
#define PPE_CFG_BUS_LOCAL_REL …
#define PPE_BUF_SIZE_SHIFT …
#define PPE_TX_BUF_HOLD …
#define SOC_CACHE_LINE_MASK …
#else
#define PPE_CFG_QOS_VMID_GRP_SHIFT …
#define PPE_CFG_RX_CTRL_ALIGN_SHIFT …
#define PPE_CFG_STS_RX_PKT_CNT_RC …
#define PPE_CFG_QOS_VMID_MODE …
#define PPE_CFG_BUS_LOCAL_REL …
#define PPE_BUF_SIZE_SHIFT …
#define PPE_TX_BUF_HOLD …
#endif
#define PPE_CFG_RX_FIFO_FSFU …
#define PPE_CFG_RX_DEPTH_SHIFT …
#define PPE_CFG_RX_START_SHIFT …
#define PPE_CFG_BUS_BIG_ENDIEN …
#define RX_DESC_NUM …
#define TX_DESC_NUM …
#define TX_NEXT(N) …
#define RX_NEXT(N) …
#define GMAC_PPE_RX_PKT_MAX_LEN …
#define GMAC_MAX_PKT_LEN …
#define GMAC_MIN_PKT_LEN …
#define RX_BUF_SIZE …
#define RESET_TIMEOUT …
#define TX_TIMEOUT …
#define DRV_NAME …
#define DRV_VERSION …
#define HIP04_MAX_TX_COALESCE_USECS …
#define HIP04_MIN_TX_COALESCE_USECS …
#define HIP04_MAX_TX_COALESCE_FRAMES …
#define HIP04_MIN_TX_COALESCE_FRAMES …
struct tx_desc { … } __aligned(…);
struct rx_desc { … };
struct hip04_priv { … };
static inline unsigned int tx_count(unsigned int head, unsigned int tail)
{ … }
static void hip04_config_port(struct net_device *ndev, u32 speed, u32 duplex)
{ … }
static void hip04_reset_dreq(struct hip04_priv *priv)
{ … }
static void hip04_reset_ppe(struct hip04_priv *priv)
{ … }
static void hip04_config_fifo(struct hip04_priv *priv)
{ … }
static void hip04_mac_enable(struct net_device *ndev)
{ … }
static void hip04_mac_disable(struct net_device *ndev)
{ … }
static void hip04_set_xmit_desc(struct hip04_priv *priv, dma_addr_t phys)
{ … }
static void hip04_set_recv_desc(struct hip04_priv *priv, dma_addr_t phys)
{ … }
static u32 hip04_recv_cnt(struct hip04_priv *priv)
{ … }
static void hip04_update_mac_address(struct net_device *ndev)
{ … }
static int hip04_set_mac_address(struct net_device *ndev, void *addr)
{ … }
static int hip04_tx_reclaim(struct net_device *ndev, bool force)
{ … }
static void hip04_start_tx_timer(struct hip04_priv *priv)
{ … }
static netdev_tx_t
hip04_mac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
{ … }
static int hip04_rx_poll(struct napi_struct *napi, int budget)
{ … }
static irqreturn_t hip04_mac_interrupt(int irq, void *dev_id)
{ … }
static enum hrtimer_restart tx_done(struct hrtimer *hrtimer)
{ … }
static void hip04_adjust_link(struct net_device *ndev)
{ … }
static int hip04_mac_open(struct net_device *ndev)
{ … }
static int hip04_mac_stop(struct net_device *ndev)
{ … }
static void hip04_timeout(struct net_device *ndev, unsigned int txqueue)
{ … }
static void hip04_tx_timeout_task(struct work_struct *work)
{ … }
static int hip04_get_coalesce(struct net_device *netdev,
struct ethtool_coalesce *ec,
struct kernel_ethtool_coalesce *kernel_coal,
struct netlink_ext_ack *extack)
{ … }
static int hip04_set_coalesce(struct net_device *netdev,
struct ethtool_coalesce *ec,
struct kernel_ethtool_coalesce *kernel_coal,
struct netlink_ext_ack *extack)
{ … }
static void hip04_get_drvinfo(struct net_device *netdev,
struct ethtool_drvinfo *drvinfo)
{ … }
static const struct ethtool_ops hip04_ethtool_ops = …;
static const struct net_device_ops hip04_netdev_ops = …;
static int hip04_alloc_ring(struct net_device *ndev, struct device *d)
{ … }
static void hip04_free_ring(struct net_device *ndev, struct device *d)
{ … }
static int hip04_mac_probe(struct platform_device *pdev)
{ … }
static void hip04_remove(struct platform_device *pdev)
{ … }
static const struct of_device_id hip04_mac_match[] = …;
MODULE_DEVICE_TABLE(of, hip04_mac_match);
static struct platform_driver hip04_mac_driver = …;
module_platform_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;