linux/drivers/net/ethernet/socionext/netsec.c

// SPDX-License-Identifier: GPL-2.0+

#include <linux/types.h>
#include <linux/clk.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/acpi.h>
#include <linux/of_mdio.h>
#include <linux/of_net.h>
#include <linux/etherdevice.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/netlink.h>
#include <linux/bpf.h>
#include <linux/bpf_trace.h>

#include <net/tcp.h>
#include <net/page_pool/helpers.h>
#include <net/ip6_checksum.h>

#define NETSEC_REG_SOFT_RST
#define NETSEC_REG_COM_INIT

#define NETSEC_REG_TOP_STATUS
#define NETSEC_IRQ_RX
#define NETSEC_IRQ_TX

#define NETSEC_REG_TOP_INTEN
#define NETSEC_REG_INTEN_SET
#define NETSEC_REG_INTEN_CLR

#define NETSEC_REG_NRM_TX_STATUS
#define NETSEC_REG_NRM_TX_INTEN
#define NETSEC_REG_NRM_TX_INTEN_SET
#define NETSEC_REG_NRM_TX_INTEN_CLR
#define NRM_TX_ST_NTOWNR
#define NRM_TX_ST_TR_ERR
#define NRM_TX_ST_TXDONE
#define NRM_TX_ST_TMREXP

#define NETSEC_REG_NRM_RX_STATUS
#define NETSEC_REG_NRM_RX_INTEN
#define NETSEC_REG_NRM_RX_INTEN_SET
#define NETSEC_REG_NRM_RX_INTEN_CLR
#define NRM_RX_ST_RC_ERR
#define NRM_RX_ST_PKTCNT
#define NRM_RX_ST_TMREXP

#define NETSEC_REG_PKT_CMD_BUF

#define NETSEC_REG_CLK_EN

#define NETSEC_REG_PKT_CTRL

#define NETSEC_REG_DMA_TMR_CTRL
#define NETSEC_REG_F_TAIKI_MC_VER
#define NETSEC_REG_F_TAIKI_VER
#define NETSEC_REG_DMA_HM_CTRL
#define NETSEC_REG_DMA_MH_CTRL
#define NETSEC_REG_ADDR_DIS_CORE
#define NETSEC_REG_DMAC_HM_CMD_BUF
#define NETSEC_REG_DMAC_MH_CMD_BUF

#define NETSEC_REG_NRM_TX_PKTCNT

#define NETSEC_REG_NRM_TX_DONE_PKTCNT
#define NETSEC_REG_NRM_TX_DONE_TXINT_PKTCNT

#define NETSEC_REG_NRM_TX_TMR

#define NETSEC_REG_NRM_RX_PKTCNT
#define NETSEC_REG_NRM_RX_RXINT_PKTCNT
#define NETSEC_REG_NRM_TX_TXINT_TMR
#define NETSEC_REG_NRM_RX_RXINT_TMR

#define NETSEC_REG_NRM_RX_TMR

#define NETSEC_REG_NRM_TX_DESC_START_UP
#define NETSEC_REG_NRM_TX_DESC_START_LW
#define NETSEC_REG_NRM_RX_DESC_START_UP
#define NETSEC_REG_NRM_RX_DESC_START_LW

#define NETSEC_REG_NRM_TX_CONFIG
#define NETSEC_REG_NRM_RX_CONFIG

#define MAC_REG_STATUS
#define MAC_REG_DATA
#define MAC_REG_CMD
#define MAC_REG_FLOW_TH
#define MAC_REG_INTF_SEL
#define MAC_REG_DESC_INIT
#define MAC_REG_DESC_SOFT_RST
#define NETSEC_REG_MODE_TRANS_COMP_STATUS

#define GMAC_REG_MCR
#define GMAC_REG_MFFR
#define GMAC_REG_GAR
#define GMAC_REG_GDR
#define GMAC_REG_FCR
#define GMAC_REG_BMR
#define GMAC_REG_RDLAR
#define GMAC_REG_TDLAR
#define GMAC_REG_OMR

#define MHZ(n)

#define NETSEC_TX_SHIFT_OWN_FIELD
#define NETSEC_TX_SHIFT_LD_FIELD
#define NETSEC_TX_SHIFT_DRID_FIELD
#define NETSEC_TX_SHIFT_PT_FIELD
#define NETSEC_TX_SHIFT_TDRID_FIELD
#define NETSEC_TX_SHIFT_CC_FIELD
#define NETSEC_TX_SHIFT_FS_FIELD
#define NETSEC_TX_LAST
#define NETSEC_TX_SHIFT_CO
#define NETSEC_TX_SHIFT_SO
#define NETSEC_TX_SHIFT_TRS_FIELD

#define NETSEC_RX_PKT_OWN_FIELD
#define NETSEC_RX_PKT_LD_FIELD
#define NETSEC_RX_PKT_SDRID_FIELD
#define NETSEC_RX_PKT_FR_FIELD
#define NETSEC_RX_PKT_ER_FIELD
#define NETSEC_RX_PKT_ERR_FIELD
#define NETSEC_RX_PKT_TDRID_FIELD
#define NETSEC_RX_PKT_FS_FIELD
#define NETSEC_RX_PKT_LS_FIELD
#define NETSEC_RX_PKT_CO_FIELD

#define NETSEC_RX_PKT_ERR_MASK

#define NETSEC_MAX_TX_PKT_LEN
#define NETSEC_MAX_TX_JUMBO_PKT_LEN

#define NETSEC_RING_GMAC
#define NETSEC_RING_MAX

#define NETSEC_TCP_SEG_LEN_MAX
#define NETSEC_TCP_JUMBO_SEG_LEN_MAX

#define NETSEC_RX_CKSUM_NOTAVAIL
#define NETSEC_RX_CKSUM_OK
#define NETSEC_RX_CKSUM_NG

#define NETSEC_TOP_IRQ_REG_CODE_LOAD_END
#define NETSEC_IRQ_TRANSITION_COMPLETE

#define NETSEC_MODE_TRANS_COMP_IRQ_N2T
#define NETSEC_MODE_TRANS_COMP_IRQ_T2N

#define NETSEC_INT_PKTCNT_MAX

#define NETSEC_FLOW_START_TH_MAX
#define NETSEC_FLOW_STOP_TH_MAX
#define NETSEC_FLOW_PAUSE_TIME_MIN

#define NETSEC_CLK_EN_REG_DOM_ALL

#define NETSEC_PKT_CTRL_REG_MODE_NRM
#define NETSEC_PKT_CTRL_REG_EN_JUMBO
#define NETSEC_PKT_CTRL_REG_LOG_CHKSUM_ER
#define NETSEC_PKT_CTRL_REG_LOG_HD_INCOMPLETE
#define NETSEC_PKT_CTRL_REG_LOG_HD_ER
#define NETSEC_PKT_CTRL_REG_DRP_NO_MATCH

#define NETSEC_CLK_EN_REG_DOM_G
#define NETSEC_CLK_EN_REG_DOM_C
#define NETSEC_CLK_EN_REG_DOM_D

#define NETSEC_COM_INIT_REG_DB
#define NETSEC_COM_INIT_REG_CLS
#define NETSEC_COM_INIT_REG_ALL

#define NETSEC_SOFT_RST_REG_RESET
#define NETSEC_SOFT_RST_REG_RUN

#define NETSEC_DMA_CTRL_REG_STOP
#define MH_CTRL__MODE_TRANS

#define NETSEC_GMAC_CMD_ST_READ
#define NETSEC_GMAC_CMD_ST_WRITE
#define NETSEC_GMAC_CMD_ST_BUSY

#define NETSEC_GMAC_BMR_REG_COMMON
#define NETSEC_GMAC_BMR_REG_RESET
#define NETSEC_GMAC_BMR_REG_SWR

#define NETSEC_GMAC_OMR_REG_ST
#define NETSEC_GMAC_OMR_REG_SR

#define NETSEC_GMAC_MCR_REG_IBN
#define NETSEC_GMAC_MCR_REG_CST
#define NETSEC_GMAC_MCR_REG_JE
#define NETSEC_MCR_PS
#define NETSEC_GMAC_MCR_REG_FES
#define NETSEC_GMAC_MCR_REG_FULL_DUPLEX_COMMON
#define NETSEC_GMAC_MCR_REG_HALF_DUPLEX_COMMON

#define NETSEC_FCR_RFE
#define NETSEC_FCR_TFE

#define NETSEC_GMAC_GAR_REG_GW
#define NETSEC_GMAC_GAR_REG_GB

#define NETSEC_GMAC_GAR_REG_SHIFT_PA
#define NETSEC_GMAC_GAR_REG_SHIFT_GR
#define GMAC_REG_SHIFT_CR_GAR

#define NETSEC_GMAC_GAR_REG_CR_25_35_MHZ
#define NETSEC_GMAC_GAR_REG_CR_35_60_MHZ
#define NETSEC_GMAC_GAR_REG_CR_60_100_MHZ
#define NETSEC_GMAC_GAR_REG_CR_100_150_MHZ
#define NETSEC_GMAC_GAR_REG_CR_150_250_MHZ
#define NETSEC_GMAC_GAR_REG_CR_250_300_MHZ

#define NETSEC_GMAC_RDLAR_REG_COMMON
#define NETSEC_GMAC_TDLAR_REG_COMMON

#define NETSEC_REG_NETSEC_VER_F_TAIKI

#define NETSEC_REG_DESC_RING_CONFIG_CFG_UP
#define NETSEC_REG_DESC_RING_CONFIG_CH_RST
#define NETSEC_REG_DESC_TMR_MODE
#define NETSEC_REG_DESC_ENDIAN

#define NETSEC_MAC_DESC_SOFT_RST_SOFT_RST
#define NETSEC_MAC_DESC_INIT_REG_INIT

#define NETSEC_EEPROM_MAC_ADDRESS
#define NETSEC_EEPROM_HM_ME_ADDRESS_H
#define NETSEC_EEPROM_HM_ME_ADDRESS_L
#define NETSEC_EEPROM_HM_ME_SIZE
#define NETSEC_EEPROM_MH_ME_ADDRESS_H
#define NETSEC_EEPROM_MH_ME_ADDRESS_L
#define NETSEC_EEPROM_MH_ME_SIZE
#define NETSEC_EEPROM_PKT_ME_ADDRESS
#define NETSEC_EEPROM_PKT_ME_SIZE

#define DESC_NUM

#define NETSEC_SKB_PAD
#define NETSEC_RXBUF_HEADROOM
#define NETSEC_RX_BUF_NON_DATA
#define NETSEC_RX_BUF_SIZE

#define DESC_SZ

#define NETSEC_F_NETSEC_VER_MAJOR_NUM(x)

#define NETSEC_XDP_PASS
#define NETSEC_XDP_CONSUMED
#define NETSEC_XDP_TX
#define NETSEC_XDP_REDIR

enum ring_id {};

enum buf_type {};

struct netsec_desc {};

struct netsec_desc_ring {};

struct netsec_priv {};

struct netsec_de {};

struct netsec_tx_pkt_ctrl {};

struct netsec_rx_pkt_info {};

static void netsec_write(struct netsec_priv *priv, u32 reg_addr, u32 val)
{}

static u32 netsec_read(struct netsec_priv *priv, u32 reg_addr)
{}

/************* MDIO BUS OPS FOLLOW *************/

#define TIMEOUT_SPINS_MAC
#define TIMEOUT_SECONDARY_MS_MAC

static u32 netsec_clk_type(u32 freq)
{}

static int netsec_wait_while_busy(struct netsec_priv *priv, u32 addr, u32 mask)
{}

static int netsec_mac_write(struct netsec_priv *priv, u32 addr, u32 value)
{}

static int netsec_mac_read(struct netsec_priv *priv, u32 addr, u32 *read)
{}

static int netsec_mac_wait_while_busy(struct netsec_priv *priv,
				      u32 addr, u32 mask)
{}

static int netsec_mac_update_to_phy_state(struct netsec_priv *priv)
{}

static int netsec_phy_read(struct mii_bus *bus, int phy_addr, int reg_addr);

static int netsec_phy_write(struct mii_bus *bus,
			    int phy_addr, int reg, u16 val)
{}

static int netsec_phy_read(struct mii_bus *bus, int phy_addr, int reg_addr)
{}

/************* ETHTOOL_OPS FOLLOW *************/

static void netsec_et_get_drvinfo(struct net_device *net_device,
				  struct ethtool_drvinfo *info)
{}

static int netsec_et_get_coalesce(struct net_device *net_device,
				  struct ethtool_coalesce *et_coalesce,
				  struct kernel_ethtool_coalesce *kernel_coal,
				  struct netlink_ext_ack *extack)
{}

static int netsec_et_set_coalesce(struct net_device *net_device,
				  struct ethtool_coalesce *et_coalesce,
				  struct kernel_ethtool_coalesce *kernel_coal,
				  struct netlink_ext_ack *extack)
{}

static u32 netsec_et_get_msglevel(struct net_device *dev)
{}

static void netsec_et_set_msglevel(struct net_device *dev, u32 datum)
{}

static const struct ethtool_ops netsec_ethtool_ops =;

/************* NETDEV_OPS FOLLOW *************/


static void netsec_set_rx_de(struct netsec_priv *priv,
			     struct netsec_desc_ring *dring, u16 idx,
			     const struct netsec_desc *desc)
{}

static bool netsec_clean_tx_dring(struct netsec_priv *priv)
{}

static void netsec_process_tx(struct netsec_priv *priv)
{}

static void *netsec_alloc_rx_data(struct netsec_priv *priv,
				  dma_addr_t *dma_handle, u16 *desc_len)

{}

static void netsec_rx_fill(struct netsec_priv *priv, u16 from, u16 num)
{}

static void netsec_xdp_ring_tx_db(struct netsec_priv *priv, u16 pkts)
{}

static void netsec_finalize_xdp_rx(struct netsec_priv *priv, u32 xdp_res,
				   u16 pkts)
{}

static void netsec_set_tx_de(struct netsec_priv *priv,
			     struct netsec_desc_ring *dring,
			     const struct netsec_tx_pkt_ctrl *tx_ctrl,
			     const struct netsec_desc *desc, void *buf)
{}

/* The current driver only supports 1 Txq, this should run under spin_lock() */
static u32 netsec_xdp_queue_one(struct netsec_priv *priv,
				struct xdp_frame *xdpf, bool is_ndo)

{}

static u32 netsec_xdp_xmit_back(struct netsec_priv *priv, struct xdp_buff *xdp)
{}

static u32 netsec_run_xdp(struct netsec_priv *priv, struct bpf_prog *prog,
			  struct xdp_buff *xdp)
{}

static int netsec_process_rx(struct netsec_priv *priv, int budget)
{}

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


static int netsec_desc_used(struct netsec_desc_ring *dring)
{}

static int netsec_check_stop_tx(struct netsec_priv *priv, int used)
{}

static netdev_tx_t netsec_netdev_start_xmit(struct sk_buff *skb,
					    struct net_device *ndev)
{}

static void netsec_uninit_pkt_dring(struct netsec_priv *priv, int id)
{}

static void netsec_free_dring(struct netsec_priv *priv, int id)
{}

static int netsec_alloc_dring(struct netsec_priv *priv, enum ring_id id)
{}

static void netsec_setup_tx_dring(struct netsec_priv *priv)
{}

static int netsec_setup_rx_dring(struct netsec_priv *priv)
{}

static int netsec_netdev_load_ucode_region(struct netsec_priv *priv, u32 reg,
					   u32 addr_h, u32 addr_l, u32 size)
{}

static int netsec_netdev_load_microcode(struct netsec_priv *priv)
{}

static int netsec_reset_hardware(struct netsec_priv *priv,
				 bool load_ucode)
{}

static int netsec_start_gmac(struct netsec_priv *priv)
{}

static int netsec_stop_gmac(struct netsec_priv *priv)
{}

static void netsec_phy_adjust_link(struct net_device *ndev)
{}

static irqreturn_t netsec_irq_handler(int irq, void *dev_id)
{}

static int netsec_netdev_open(struct net_device *ndev)
{}

static int netsec_netdev_stop(struct net_device *ndev)
{}

static int netsec_netdev_init(struct net_device *ndev)
{}

static void netsec_netdev_uninit(struct net_device *ndev)
{}

static int netsec_netdev_set_features(struct net_device *ndev,
				      netdev_features_t features)
{}

static int netsec_xdp_xmit(struct net_device *ndev, int n,
			   struct xdp_frame **frames, u32 flags)
{}

static int netsec_xdp_setup(struct netsec_priv *priv, struct bpf_prog *prog,
			    struct netlink_ext_ack *extack)
{}

static int netsec_xdp(struct net_device *ndev, struct netdev_bpf *xdp)
{}

static const struct net_device_ops netsec_netdev_ops =;

static int netsec_of_probe(struct platform_device *pdev,
			   struct netsec_priv *priv, u32 *phy_addr)
{}

static int netsec_acpi_probe(struct platform_device *pdev,
			     struct netsec_priv *priv, u32 *phy_addr)
{}

static void netsec_unregister_mdio(struct netsec_priv *priv)
{}

static int netsec_register_mdio(struct netsec_priv *priv, u32 phy_addr)
{}

static int netsec_probe(struct platform_device *pdev)
{}

static void netsec_remove(struct platform_device *pdev)
{}

#ifdef CONFIG_PM
static int netsec_runtime_suspend(struct device *dev)
{}

static int netsec_runtime_resume(struct device *dev)
{}
#endif

static const struct dev_pm_ops netsec_pm_ops =;

static const struct of_device_id netsec_dt_ids[] =;
MODULE_DEVICE_TABLE(of, netsec_dt_ids);

#ifdef CONFIG_ACPI
static const struct acpi_device_id netsec_acpi_ids[] =;
MODULE_DEVICE_TABLE(acpi, netsec_acpi_ids);
#endif

static struct platform_driver netsec_driver =;
module_platform_driver();

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