linux/drivers/net/ethernet/mediatek/mtk_eth_soc.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 *
 *   Copyright (C) 2009-2016 John Crispin <[email protected]>
 *   Copyright (C) 2009-2016 Felix Fietkau <[email protected]>
 *   Copyright (C) 2013-2016 Michael Lee <[email protected]>
 */

#include <linux/of.h>
#include <linux/of_mdio.h>
#include <linux/of_net.h>
#include <linux/of_address.h>
#include <linux/mfd/syscon.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/clk.h>
#include <linux/pm_runtime.h>
#include <linux/if_vlan.h>
#include <linux/reset.h>
#include <linux/tcp.h>
#include <linux/interrupt.h>
#include <linux/pinctrl/devinfo.h>
#include <linux/phylink.h>
#include <linux/pcs/pcs-mtk-lynxi.h>
#include <linux/jhash.h>
#include <linux/bitfield.h>
#include <net/dsa.h>
#include <net/dst_metadata.h>
#include <net/page_pool/helpers.h>

#include "mtk_eth_soc.h"
#include "mtk_wed.h"

static int mtk_msg_level =;
module_param_named(msg_level, mtk_msg_level, int, 0);
MODULE_PARM_DESC();

#define MTK_ETHTOOL_STAT(x)

#define MTK_ETHTOOL_XDP_STAT(x)

static const struct mtk_reg_map mtk_reg_map =;

static const struct mtk_reg_map mt7628_reg_map =;

static const struct mtk_reg_map mt7986_reg_map =;

static const struct mtk_reg_map mt7988_reg_map =;

/* strings used by ethtool */
static const struct mtk_ethtool_stats {} mtk_ethtool_stats[] =;

static const char * const mtk_clks_source_name[] =;

void mtk_w32(struct mtk_eth *eth, u32 val, unsigned reg)
{}

u32 mtk_r32(struct mtk_eth *eth, unsigned reg)
{}

u32 mtk_m32(struct mtk_eth *eth, u32 mask, u32 set, unsigned int reg)
{}

static int mtk_mdio_busy_wait(struct mtk_eth *eth)
{}

static int _mtk_mdio_write_c22(struct mtk_eth *eth, u32 phy_addr, u32 phy_reg,
			       u32 write_data)
{}

static int _mtk_mdio_write_c45(struct mtk_eth *eth, u32 phy_addr,
			       u32 devad, u32 phy_reg, u32 write_data)
{}

static int _mtk_mdio_read_c22(struct mtk_eth *eth, u32 phy_addr, u32 phy_reg)
{}

static int _mtk_mdio_read_c45(struct mtk_eth *eth, u32 phy_addr,
			      u32 devad, u32 phy_reg)
{}

static int mtk_mdio_write_c22(struct mii_bus *bus, int phy_addr,
			      int phy_reg, u16 val)
{}

static int mtk_mdio_write_c45(struct mii_bus *bus, int phy_addr,
			      int devad, int phy_reg, u16 val)
{}

static int mtk_mdio_read_c22(struct mii_bus *bus, int phy_addr, int phy_reg)
{}

static int mtk_mdio_read_c45(struct mii_bus *bus, int phy_addr, int devad,
			     int phy_reg)
{}

static int mt7621_gmac0_rgmii_adjust(struct mtk_eth *eth,
				     phy_interface_t interface)
{}

static void mtk_gmac0_rgmii_adjust(struct mtk_eth *eth,
				   phy_interface_t interface)
{}

static void mtk_setup_bridge_switch(struct mtk_eth *eth)
{}

static struct phylink_pcs *mtk_mac_select_pcs(struct phylink_config *config,
					      phy_interface_t interface)
{}

static void mtk_mac_config(struct phylink_config *config, unsigned int mode,
			   const struct phylink_link_state *state)
{}

static int mtk_mac_finish(struct phylink_config *config, unsigned int mode,
			  phy_interface_t interface)
{}

static void mtk_mac_link_down(struct phylink_config *config, unsigned int mode,
			      phy_interface_t interface)
{}

static void mtk_set_queue_speed(struct mtk_eth *eth, unsigned int idx,
				int speed)
{}

static void mtk_mac_link_up(struct phylink_config *config,
			    struct phy_device *phy,
			    unsigned int mode, phy_interface_t interface,
			    int speed, int duplex, bool tx_pause, bool rx_pause)
{}

static const struct phylink_mac_ops mtk_phylink_ops =;

static int mtk_mdio_init(struct mtk_eth *eth)
{}

static void mtk_mdio_cleanup(struct mtk_eth *eth)
{}

static inline void mtk_tx_irq_disable(struct mtk_eth *eth, u32 mask)
{}

static inline void mtk_tx_irq_enable(struct mtk_eth *eth, u32 mask)
{}

static inline void mtk_rx_irq_disable(struct mtk_eth *eth, u32 mask)
{}

static inline void mtk_rx_irq_enable(struct mtk_eth *eth, u32 mask)
{}

static int mtk_set_mac_address(struct net_device *dev, void *p)
{}

void mtk_stats_update_mac(struct mtk_mac *mac)
{}

static void mtk_stats_update(struct mtk_eth *eth)
{}

static void mtk_get_stats64(struct net_device *dev,
			    struct rtnl_link_stats64 *storage)
{}

static inline int mtk_max_frag_size(int mtu)
{}

static inline int mtk_max_buf_size(int frag_size)
{}

static bool mtk_rx_get_desc(struct mtk_eth *eth, struct mtk_rx_dma_v2 *rxd,
			    struct mtk_rx_dma_v2 *dma_rxd)
{}

static void *mtk_max_lro_buf_alloc(gfp_t gfp_mask)
{}

/* the qdma core needs scratch memory to be setup */
static int mtk_init_fq_dma(struct mtk_eth *eth)
{}

static void *mtk_qdma_phys_to_virt(struct mtk_tx_ring *ring, u32 desc)
{}

static struct mtk_tx_buf *mtk_desc_to_tx_buf(struct mtk_tx_ring *ring,
					     void *txd, u32 txd_size)
{}

static struct mtk_tx_dma *qdma_to_pdma(struct mtk_tx_ring *ring,
				       struct mtk_tx_dma *dma)
{}

static int txd_to_idx(struct mtk_tx_ring *ring, void *dma, u32 txd_size)
{}

static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf,
			 struct xdp_frame_bulk *bq, bool napi)
{}

static void setup_tx_buf(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf,
			 struct mtk_tx_dma *txd, dma_addr_t mapped_addr,
			 size_t size, int idx)
{}

static void mtk_tx_set_dma_desc_v1(struct net_device *dev, void *txd,
				   struct mtk_tx_dma_desc_info *info)
{}

static void mtk_tx_set_dma_desc_v2(struct net_device *dev, void *txd,
				   struct mtk_tx_dma_desc_info *info)
{}

static void mtk_tx_set_dma_desc(struct net_device *dev, void *txd,
				struct mtk_tx_dma_desc_info *info)
{}

static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev,
		      int tx_num, struct mtk_tx_ring *ring, bool gso)
{}

static int mtk_cal_txd_req(struct mtk_eth *eth, struct sk_buff *skb)
{}

static int mtk_queue_stopped(struct mtk_eth *eth)
{}

static void mtk_wake_queue(struct mtk_eth *eth)
{}

static netdev_tx_t mtk_start_xmit(struct sk_buff *skb, struct net_device *dev)
{}

static struct mtk_rx_ring *mtk_get_rx_ring(struct mtk_eth *eth)
{}

static void mtk_update_rx_cpu_idx(struct mtk_eth *eth)
{}

static bool mtk_page_pool_enabled(struct mtk_eth *eth)
{}

static struct page_pool *mtk_create_page_pool(struct mtk_eth *eth,
					      struct xdp_rxq_info *xdp_q,
					      int id, int size)
{}

static void *mtk_page_pool_get_buff(struct page_pool *pp, dma_addr_t *dma_addr,
				    gfp_t gfp_mask)
{}

static void mtk_rx_put_buff(struct mtk_rx_ring *ring, void *data, bool napi)
{}

static int mtk_xdp_frame_map(struct mtk_eth *eth, struct net_device *dev,
			     struct mtk_tx_dma_desc_info *txd_info,
			     struct mtk_tx_dma *txd, struct mtk_tx_buf *tx_buf,
			     void *data, u16 headroom, int index, bool dma_map)
{}

static int mtk_xdp_submit_frame(struct mtk_eth *eth, struct xdp_frame *xdpf,
				struct net_device *dev, bool dma_map)
{}

static int mtk_xdp_xmit(struct net_device *dev, int num_frame,
			struct xdp_frame **frames, u32 flags)
{}

static u32 mtk_xdp_run(struct mtk_eth *eth, struct mtk_rx_ring *ring,
		       struct xdp_buff *xdp, struct net_device *dev)
{}

static int mtk_poll_rx(struct napi_struct *napi, int budget,
		       struct mtk_eth *eth)
{}

struct mtk_poll_state {};

static void
mtk_poll_tx_done(struct mtk_eth *eth, struct mtk_poll_state *state, u8 mac,
		 struct sk_buff *skb)
{}

static int mtk_poll_tx_qdma(struct mtk_eth *eth, int budget,
			    struct mtk_poll_state *state)
{}

static int mtk_poll_tx_pdma(struct mtk_eth *eth, int budget,
			    struct mtk_poll_state *state)
{}

static int mtk_poll_tx(struct mtk_eth *eth, int budget)
{}

static void mtk_handle_status_irq(struct mtk_eth *eth)
{}

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

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

static int mtk_tx_alloc(struct mtk_eth *eth)
{}

static void mtk_tx_clean(struct mtk_eth *eth)
{}

static int mtk_rx_alloc(struct mtk_eth *eth, int ring_no, int rx_flag)
{}

static void mtk_rx_clean(struct mtk_eth *eth, struct mtk_rx_ring *ring, bool in_sram)
{}

static int mtk_hwlro_rx_init(struct mtk_eth *eth)
{}

static void mtk_hwlro_rx_uninit(struct mtk_eth *eth)
{}

static void mtk_hwlro_val_ipaddr(struct mtk_eth *eth, int idx, __be32 ip)
{}

static void mtk_hwlro_inval_ipaddr(struct mtk_eth *eth, int idx)
{}

static int mtk_hwlro_get_ip_cnt(struct mtk_mac *mac)
{}

static int mtk_hwlro_add_ipaddr(struct net_device *dev,
				struct ethtool_rxnfc *cmd)
{}

static int mtk_hwlro_del_ipaddr(struct net_device *dev,
				struct ethtool_rxnfc *cmd)
{}

static void mtk_hwlro_netdev_disable(struct net_device *dev)
{}

static int mtk_hwlro_get_fdir_entry(struct net_device *dev,
				    struct ethtool_rxnfc *cmd)
{}

static int mtk_hwlro_get_fdir_all(struct net_device *dev,
				  struct ethtool_rxnfc *cmd,
				  u32 *rule_locs)
{}

static netdev_features_t mtk_fix_features(struct net_device *dev,
					  netdev_features_t features)
{}

static int mtk_set_features(struct net_device *dev, netdev_features_t features)
{}

/* wait for DMA to finish whatever it is doing before we start using it again */
static int mtk_dma_busy_wait(struct mtk_eth *eth)
{}

static int mtk_dma_init(struct mtk_eth *eth)
{}

static void mtk_dma_free(struct mtk_eth *eth)
{}

static bool mtk_hw_reset_check(struct mtk_eth *eth)
{}

static void mtk_tx_timeout(struct net_device *dev, unsigned int txqueue)
{}

static irqreturn_t mtk_handle_irq_rx(int irq, void *_eth)
{}

static irqreturn_t mtk_handle_irq_tx(int irq, void *_eth)
{}

static irqreturn_t mtk_handle_irq(int irq, void *_eth)
{}

#ifdef CONFIG_NET_POLL_CONTROLLER
static void mtk_poll_controller(struct net_device *dev)
{}
#endif

static int mtk_start_dma(struct mtk_eth *eth)
{}

static void mtk_gdm_config(struct mtk_eth *eth, u32 id, u32 config)
{}


static bool mtk_uses_dsa(struct net_device *dev)
{}

static int mtk_device_event(struct notifier_block *n, unsigned long event, void *ptr)
{}

static int mtk_open(struct net_device *dev)
{}

static void mtk_stop_dma(struct mtk_eth *eth, u32 glo_cfg)
{}

static int mtk_stop(struct net_device *dev)
{}

static int mtk_xdp_setup(struct net_device *dev, struct bpf_prog *prog,
			 struct netlink_ext_ack *extack)
{}

static int mtk_xdp(struct net_device *dev, struct netdev_bpf *xdp)
{}

static void ethsys_reset(struct mtk_eth *eth, u32 reset_bits)
{}

static void mtk_clk_disable(struct mtk_eth *eth)
{}

static int mtk_clk_enable(struct mtk_eth *eth)
{}

static void mtk_dim_rx(struct work_struct *work)
{}

static void mtk_dim_tx(struct work_struct *work)
{}

static void mtk_set_mcr_max_rx(struct mtk_mac *mac, u32 val)
{}

static void mtk_hw_reset(struct mtk_eth *eth)
{}

static u32 mtk_hw_reset_read(struct mtk_eth *eth)
{}

static void mtk_hw_warm_reset(struct mtk_eth *eth)
{}

static bool mtk_hw_check_dma_hang(struct mtk_eth *eth)
{}

static void mtk_hw_reset_monitor_work(struct work_struct *work)
{}

static int mtk_hw_init(struct mtk_eth *eth, bool reset)
{}

static int mtk_hw_deinit(struct mtk_eth *eth)
{}

static void mtk_uninit(struct net_device *dev)
{}

static int mtk_change_mtu(struct net_device *dev, int new_mtu)
{}

static int mtk_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{}

static void mtk_prepare_for_reset(struct mtk_eth *eth)
{}

static void mtk_pending_work(struct work_struct *work)
{}

static int mtk_free_dev(struct mtk_eth *eth)
{}

static int mtk_unreg_dev(struct mtk_eth *eth)
{}

static void mtk_sgmii_destroy(struct mtk_eth *eth)
{}

static int mtk_cleanup(struct mtk_eth *eth)
{}

static int mtk_get_link_ksettings(struct net_device *ndev,
				  struct ethtool_link_ksettings *cmd)
{}

static int mtk_set_link_ksettings(struct net_device *ndev,
				  const struct ethtool_link_ksettings *cmd)
{}

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

static u32 mtk_get_msglevel(struct net_device *dev)
{}

static void mtk_set_msglevel(struct net_device *dev, u32 value)
{}

static int mtk_nway_reset(struct net_device *dev)
{}

static void mtk_get_strings(struct net_device *dev, u32 stringset, u8 *data)
{}

static int mtk_get_sset_count(struct net_device *dev, int sset)
{}

static void mtk_ethtool_pp_stats(struct mtk_eth *eth, u64 *data)
{}

static void mtk_get_ethtool_stats(struct net_device *dev,
				  struct ethtool_stats *stats, u64 *data)
{}

static int mtk_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
			 u32 *rule_locs)
{}

static int mtk_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)
{}

static void mtk_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause)
{}

static int mtk_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause)
{}

static u16 mtk_select_queue(struct net_device *dev, struct sk_buff *skb,
			    struct net_device *sb_dev)
{}

static const struct ethtool_ops mtk_ethtool_ops =;

static const struct net_device_ops mtk_netdev_ops =;

static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
{}

void mtk_eth_set_dma_device(struct mtk_eth *eth, struct device *dma_dev)
{}

static int mtk_sgmii_init(struct mtk_eth *eth)
{}

static int mtk_probe(struct platform_device *pdev)
{}

static void mtk_remove(struct platform_device *pdev)
{}

static const struct mtk_soc_data mt2701_data =;

static const struct mtk_soc_data mt7621_data =;

static const struct mtk_soc_data mt7622_data =;

static const struct mtk_soc_data mt7623_data =;

static const struct mtk_soc_data mt7629_data =;

static const struct mtk_soc_data mt7981_data =;

static const struct mtk_soc_data mt7986_data =;

static const struct mtk_soc_data mt7988_data =;

static const struct mtk_soc_data rt5350_data =;

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

static struct platform_driver mtk_driver =;

module_platform_driver();

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