linux/drivers/net/ethernet/realtek/rtase/rtase_main.c

// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
/*
 *  rtase is the Linux device driver released for Realtek Automotive Switch
 *  controllers with PCI-Express interface.
 *
 *  Copyright(c) 2024 Realtek Semiconductor Corp.
 *
 *  Below is a simplified block diagram of the chip and its relevant interfaces.
 *
 *               *************************
 *               *                       *
 *               *  CPU network device   *
 *               *                       *
 *               *   +-------------+     *
 *               *   |  PCIE Host  |     *
 *               ***********++************
 *                          ||
 *                         PCIE
 *                          ||
 *      ********************++**********************
 *      *            | PCIE Endpoint |             *
 *      *            +---------------+             *
 *      *                | GMAC |                  *
 *      *                +--++--+  Realtek         *
 *      *                   ||     RTL90xx Series  *
 *      *                   ||                     *
 *      *     +-------------++----------------+    *
 *      *     |           | MAC |             |    *
 *      *     |           +-----+             |    *
 *      *     |                               |    *
 *      *     |     Ethernet Switch Core      |    *
 *      *     |                               |    *
 *      *     |   +-----+           +-----+   |    *
 *      *     |   | MAC |...........| MAC |   |    *
 *      *     +---+-----+-----------+-----+---+    *
 *      *         | PHY |...........| PHY |        *
 *      *         +--++-+           +--++-+        *
 *      *************||****************||***********
 *
 *  The block of the Realtek RTL90xx series is our entire chip architecture,
 *  the GMAC is connected to the switch core, and there is no PHY in between.
 *  In addition, this driver is mainly used to control GMAC, but does not
 *  control the switch core, so it is not the same as DSA. Linux only plays
 *  the role of a normal leaf node in this model.
 */

#include <linux/crc32.h>
#include <linux/dma-mapping.h>
#include <linux/etherdevice.h>
#include <linux/if_vlan.h>
#include <linux/in.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/mdio.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/pci.h>
#include <linux/pm_runtime.h>
#include <linux/prefetch.h>
#include <linux/rtnetlink.h>
#include <linux/tcp.h>
#include <asm/irq.h>
#include <net/ip6_checksum.h>
#include <net/netdev_queues.h>
#include <net/page_pool/helpers.h>
#include <net/pkt_cls.h>

#include "rtase.h"

#define RTK_OPTS1_DEBUG_VALUE
#define RTK_MAGIC_NUMBER

static const struct pci_device_id rtase_pci_tbl[] =;

MODULE_DEVICE_TABLE(pci, rtase_pci_tbl);

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

struct rtase_counters {} __packed;

static void rtase_w8(const struct rtase_private *tp, u16 reg, u8 val8)
{}

static void rtase_w16(const struct rtase_private *tp, u16 reg, u16 val16)
{}

static void rtase_w32(const struct rtase_private *tp, u16 reg, u32 val32)
{}

static u8 rtase_r8(const struct rtase_private *tp, u16 reg)
{}

static u16 rtase_r16(const struct rtase_private *tp, u16 reg)
{}

static u32 rtase_r32(const struct rtase_private *tp, u16 reg)
{}

static void rtase_free_desc(struct rtase_private *tp)
{}

static int rtase_alloc_desc(struct rtase_private *tp)
{}

static void rtase_unmap_tx_skb(struct pci_dev *pdev, u32 len,
			       struct rtase_tx_desc *desc)
{}

static void rtase_tx_clear_range(struct rtase_ring *ring, u32 start, u32 n)
{}

static void rtase_tx_clear(struct rtase_private *tp)
{}

static void rtase_mark_to_asic(union rtase_rx_desc *desc, u32 rx_buf_sz)
{}

static u32 rtase_tx_avail(struct rtase_ring *ring)
{}

static int tx_handler(struct rtase_ring *ring, int budget)
{}

static void rtase_tx_desc_init(struct rtase_private *tp, u16 idx)
{}

static void rtase_map_to_asic(union rtase_rx_desc *desc, dma_addr_t mapping,
			      u32 rx_buf_sz)
{}

static void rtase_make_unusable_by_asic(union rtase_rx_desc *desc)
{}

static int rtase_alloc_rx_data_buf(struct rtase_ring *ring,
				   void **p_data_buf,
				   union rtase_rx_desc *desc,
				   dma_addr_t *rx_phy_addr)
{}

static u32 rtase_rx_ring_fill(struct rtase_ring *ring, u32 ring_start,
			      u32 ring_end)
{}

static void rtase_mark_as_last_descriptor(union rtase_rx_desc *desc)
{}

static void rtase_rx_ring_clear(struct page_pool *page_pool,
				struct rtase_ring *ring)
{}

static int rtase_fragmented_frame(u32 status)
{}

static void rtase_rx_csum(const struct rtase_private *tp, struct sk_buff *skb,
			  const union rtase_rx_desc *desc)
{}

static void rtase_rx_vlan_skb(union rtase_rx_desc *desc, struct sk_buff *skb)
{}

static void rtase_rx_skb(const struct rtase_ring *ring, struct sk_buff *skb)
{}

static int rx_handler(struct rtase_ring *ring, int budget)
{}

static void rtase_rx_desc_init(struct rtase_private *tp, u16 idx)
{}

static void rtase_rx_clear(struct rtase_private *tp)
{}

static int rtase_init_ring(const struct net_device *dev)
{}

static void rtase_interrupt_mitigation(const struct rtase_private *tp)
{}

static void rtase_tally_counter_addr_fill(const struct rtase_private *tp)
{}

static void rtase_tally_counter_clear(const struct rtase_private *tp)
{}

static void rtase_desc_addr_fill(const struct rtase_private *tp)
{}

static void rtase_hw_set_features(const struct net_device *dev,
				  netdev_features_t features)
{}

static void rtase_hw_set_rx_packet_filter(struct net_device *dev)
{}

static void rtase_irq_dis_and_clear(const struct rtase_private *tp)
{}

static void rtase_poll_timeout(const struct rtase_private *tp, u32 cond,
			       u32 sleep_us, u64 timeout_us, u16 reg)
{}

static void rtase_nic_reset(const struct net_device *dev)
{}

static void rtase_hw_reset(const struct net_device *dev)
{}

static void rtase_set_rx_queue(const struct rtase_private *tp)
{}

static void rtase_set_tx_queue(const struct rtase_private *tp)
{}

static void rtase_hw_config(struct net_device *dev)
{}

static void rtase_nic_enable(const struct net_device *dev)
{}

static void rtase_enable_hw_interrupt(const struct rtase_private *tp)
{}

static void rtase_hw_start(const struct net_device *dev)
{}

/*  the interrupt handler does RXQ0 and TXQ0, TXQ4~7 interrutp status
 */
static irqreturn_t rtase_interrupt(int irq, void *dev_instance)
{}

/*  the interrupt handler does RXQ1&TXQ1 or RXQ2&TXQ2 or RXQ3&TXQ3 interrupt
 *  status according to interrupt vector
 */
static irqreturn_t rtase_q_interrupt(int irq, void *dev_instance)
{}

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

static int rtase_open(struct net_device *dev)
{}

static void rtase_down(struct net_device *dev)
{}

static int rtase_close(struct net_device *dev)
{}

static u32 rtase_tx_vlan_tag(const struct rtase_private *tp,
			     const struct sk_buff *skb)
{}

static u32 rtase_tx_csum(struct sk_buff *skb, const struct net_device *dev)
{}

static int rtase_xmit_frags(struct rtase_ring *ring, struct sk_buff *skb,
			    u32 opts1, u32 opts2)
{}

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

static void rtase_set_rx_mode(struct net_device *dev)
{}

static void rtase_enable_eem_write(const struct rtase_private *tp)
{}

static void rtase_disable_eem_write(const struct rtase_private *tp)
{}

static void rtase_rar_set(const struct rtase_private *tp, const u8 *addr)
{}

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

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

static void rtase_wait_for_quiescence(const struct net_device *dev)
{}

static void rtase_sw_reset(struct net_device *dev)
{}

static void rtase_dump_tally_counter(const struct rtase_private *tp)
{}

static void rtase_dump_state(const struct net_device *dev)
{}

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

static void rtase_get_stats64(struct net_device *dev,
			      struct rtnl_link_stats64 *stats)
{}

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

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

static const struct net_device_ops rtase_netdev_ops =;

static void rtase_get_mac_address(struct net_device *dev)
{}

static int rtase_get_settings(struct net_device *dev,
			      struct ethtool_link_ksettings *cmd)
{}

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

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

static void rtase_get_eth_mac_stats(struct net_device *dev,
				    struct ethtool_eth_mac_stats *stats)
{}

static const struct ethtool_ops rtase_ethtool_ops =;

static void rtase_init_netdev_ops(struct net_device *dev)
{}

static void rtase_reset_interrupt(struct pci_dev *pdev,
				  const struct rtase_private *tp)
{}

static int rtase_alloc_msix(struct pci_dev *pdev, struct rtase_private *tp)
{}

static int rtase_alloc_interrupt(struct pci_dev *pdev,
				 struct rtase_private *tp)
{}

static void rtase_init_hardware(const struct rtase_private *tp)
{}

static void rtase_init_int_vector(struct rtase_private *tp)
{}

static u16 rtase_calc_time_mitigation(u32 time_us)
{}

static u16 rtase_calc_packet_num_mitigation(u16 pkt_num)
{}

static void rtase_init_software_variable(struct pci_dev *pdev,
					 struct rtase_private *tp)
{}

static bool rtase_check_mac_version_valid(struct rtase_private *tp)
{}

static int rtase_init_board(struct pci_dev *pdev, struct net_device **dev_out,
			    void __iomem **ioaddr_out)
{}

static void rtase_release_board(struct pci_dev *pdev, struct net_device *dev,
				void __iomem *ioaddr)
{}

static int rtase_init_one(struct pci_dev *pdev,
			  const struct pci_device_id *ent)
{}

static void rtase_remove_one(struct pci_dev *pdev)
{}

static void rtase_shutdown(struct pci_dev *pdev)
{}

static int rtase_suspend(struct device *device)
{}

static int rtase_resume(struct device *device)
{}

static const struct dev_pm_ops rtase_pm_ops =;

static struct pci_driver rtase_pci_driver =;

module_pci_driver();