linux/drivers/net/ethernet/qualcomm/emac/emac-mac.c

// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
 */

/* Qualcomm Technologies, Inc. EMAC Ethernet Controller MAC layer support
 */

#include <linux/tcp.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/crc32.h>
#include <linux/if_vlan.h>
#include <linux/jiffies.h>
#include <linux/phy.h>
#include <linux/of.h>
#include <net/ip6_checksum.h>
#include "emac.h"
#include "emac-sgmii.h"

/* EMAC_MAC_CTRL */
#define SINGLE_PAUSE_MODE
#define DEBUG_MODE
#define BROAD_EN
#define MULTI_ALL
#define RX_CHKSUM_EN
#define HUGE
#define SPEED(x)
#define SPEED_MASK
#define SIMR
#define TPAUSE
#define PROM_MODE
#define VLAN_STRIP
#define PRLEN_BMSK
#define PRLEN_SHFT
#define HUGEN
#define FLCHK
#define PCRCE
#define CRCE
#define FULLD
#define MAC_LP_EN
#define RXFC
#define TXFC
#define RXEN
#define TXEN

/* EMAC_DESC_CTRL_3 */
#define RFD_RING_SIZE_BMSK

/* EMAC_DESC_CTRL_4 */
#define RX_BUFFER_SIZE_BMSK

/* EMAC_DESC_CTRL_6 */
#define RRD_RING_SIZE_BMSK

/* EMAC_DESC_CTRL_9 */
#define TPD_RING_SIZE_BMSK

/* EMAC_TXQ_CTRL_0 */
#define NUM_TXF_BURST_PREF_BMSK
#define NUM_TXF_BURST_PREF_SHFT
#define LS_8023_SP
#define TXQ_MODE
#define TXQ_EN
#define IP_OP_SP
#define NUM_TPD_BURST_PREF_BMSK
#define NUM_TPD_BURST_PREF_SHFT

/* EMAC_TXQ_CTRL_1 */
#define JUMBO_TASK_OFFLOAD_THRESHOLD_BMSK

/* EMAC_TXQ_CTRL_2 */
#define TXF_HWM_BMSK
#define TXF_LWM_BMSK

/* EMAC_RXQ_CTRL_0 */
#define RXQ_EN
#define CUT_THRU_EN
#define RSS_HASH_EN
#define NUM_RFD_BURST_PREF_BMSK
#define NUM_RFD_BURST_PREF_SHFT
#define IDT_TABLE_SIZE_BMSK
#define IDT_TABLE_SIZE_SHFT
#define SP_IPV6

/* EMAC_RXQ_CTRL_1 */
#define JUMBO_1KAH_BMSK
#define JUMBO_1KAH_SHFT
#define RFD_PREF_LOW_TH
#define RFD_PREF_LOW_THRESHOLD_BMSK
#define RFD_PREF_LOW_THRESHOLD_SHFT
#define RFD_PREF_UP_TH
#define RFD_PREF_UP_THRESHOLD_BMSK
#define RFD_PREF_UP_THRESHOLD_SHFT

/* EMAC_RXQ_CTRL_2 */
#define RXF_DOF_THRESFHOLD
#define RXF_DOF_THRESHOLD_BMSK
#define RXF_DOF_THRESHOLD_SHFT
#define RXF_UOF_THRESFHOLD
#define RXF_UOF_THRESHOLD_BMSK
#define RXF_UOF_THRESHOLD_SHFT

/* EMAC_RXQ_CTRL_3 */
#define RXD_TIMER_BMSK
#define RXD_THRESHOLD_BMSK
#define RXD_THRESHOLD_SHFT

/* EMAC_DMA_CTRL */
#define DMAW_DLY_CNT_BMSK
#define DMAW_DLY_CNT_SHFT
#define DMAR_DLY_CNT_BMSK
#define DMAR_DLY_CNT_SHFT
#define DMAR_REQ_PRI
#define REGWRBLEN_BMSK
#define REGWRBLEN_SHFT
#define REGRDBLEN_BMSK
#define REGRDBLEN_SHFT
#define OUT_ORDER_MODE
#define ENH_ORDER_MODE
#define IN_ORDER_MODE

/* EMAC_MAILBOX_13 */
#define RFD3_PROC_IDX_BMSK
#define RFD3_PROC_IDX_SHFT
#define RFD3_PROD_IDX_BMSK
#define RFD3_PROD_IDX_SHFT

/* EMAC_MAILBOX_2 */
#define NTPD_CONS_IDX_BMSK
#define NTPD_CONS_IDX_SHFT

/* EMAC_MAILBOX_3 */
#define RFD0_CONS_IDX_BMSK
#define RFD0_CONS_IDX_SHFT

/* EMAC_MAILBOX_11 */
#define H3TPD_PROD_IDX_BMSK
#define H3TPD_PROD_IDX_SHFT

/* EMAC_AXI_MAST_CTRL */
#define DATA_BYTE_SWAP
#define MAX_BOUND
#define MAX_BTYPE

/* EMAC_MAILBOX_12 */
#define H3TPD_CONS_IDX_BMSK
#define H3TPD_CONS_IDX_SHFT

/* EMAC_MAILBOX_9 */
#define H2TPD_PROD_IDX_BMSK
#define H2TPD_PROD_IDX_SHFT

/* EMAC_MAILBOX_10 */
#define H1TPD_CONS_IDX_BMSK
#define H1TPD_CONS_IDX_SHFT
#define H2TPD_CONS_IDX_BMSK
#define H2TPD_CONS_IDX_SHFT

/* EMAC_ATHR_HEADER_CTRL */
#define HEADER_CNT_EN
#define HEADER_ENABLE

/* EMAC_MAILBOX_0 */
#define RFD0_PROC_IDX_BMSK
#define RFD0_PROC_IDX_SHFT
#define RFD0_PROD_IDX_BMSK
#define RFD0_PROD_IDX_SHFT

/* EMAC_MAILBOX_5 */
#define RFD1_PROC_IDX_BMSK
#define RFD1_PROC_IDX_SHFT
#define RFD1_PROD_IDX_BMSK
#define RFD1_PROD_IDX_SHFT

/* EMAC_MISC_CTRL */
#define RX_UNCPL_INT_EN

/* EMAC_MAILBOX_7 */
#define RFD2_CONS_IDX_BMSK
#define RFD2_CONS_IDX_SHFT
#define RFD1_CONS_IDX_BMSK
#define RFD1_CONS_IDX_SHFT

/* EMAC_MAILBOX_8 */
#define RFD3_CONS_IDX_BMSK
#define RFD3_CONS_IDX_SHFT

/* EMAC_MAILBOX_15 */
#define NTPD_PROD_IDX_BMSK
#define NTPD_PROD_IDX_SHFT

/* EMAC_MAILBOX_16 */
#define H1TPD_PROD_IDX_BMSK
#define H1TPD_PROD_IDX_SHFT

#define RXQ0_RSS_HSTYP_IPV6_TCP_EN
#define RXQ0_RSS_HSTYP_IPV6_EN
#define RXQ0_RSS_HSTYP_IPV4_TCP_EN
#define RXQ0_RSS_HSTYP_IPV4_EN

/* EMAC_EMAC_WRAPPER_TX_TS_INX */
#define EMAC_WRAPPER_TX_TS_EMPTY
#define EMAC_WRAPPER_TX_TS_INX_BMSK

struct emac_skb_cb {};

#define EMAC_SKB_CB(skb)
#define EMAC_RSS_IDT_SIZE
#define JUMBO_1KAH
#define RXD_TH
#define EMAC_TPD_LAST_FRAGMENT
#define EMAC_TPD_TSTAMP_SAVE

/* EMAC Errors in emac_rrd.word[3] */
#define EMAC_RRD_L4F
#define EMAC_RRD_IPF
#define EMAC_RRD_CRC
#define EMAC_RRD_FAE
#define EMAC_RRD_TRN
#define EMAC_RRD_RNT
#define EMAC_RRD_INC
#define EMAC_RRD_FOV
#define EMAC_RRD_LEN

/* Error bits that will result in a received frame being discarded */
#define EMAC_RRD_ERROR
#define EMAC_RRD_STATS_DW_IDX

#define EMAC_RRD(RXQ, SIZE, IDX)
#define EMAC_RFD(RXQ, SIZE, IDX)
#define EMAC_TPD(TXQ, SIZE, IDX)

#define GET_RFD_BUFFER(RXQ, IDX)
#define GET_TPD_BUFFER(RTQ, IDX)

#define EMAC_TX_POLL_HWTXTSTAMP_THRESHOLD

#define ISR_RX_PKT

void emac_mac_multicast_addr_set(struct emac_adapter *adpt, u8 *addr)
{}

void emac_mac_multicast_addr_clear(struct emac_adapter *adpt)
{}

/* definitions for RSS */
#define EMAC_RSS_KEY(_i, _type)
#define EMAC_RSS_TBL(_i, _type)

/* Config MAC modes */
void emac_mac_mode_config(struct emac_adapter *adpt)
{}

/* Config descriptor rings */
static void emac_mac_dma_rings_config(struct emac_adapter *adpt)
{}

/* Config transmit parameters */
static void emac_mac_tx_config(struct emac_adapter *adpt)
{}

/* Config receive parameters */
static void emac_mac_rx_config(struct emac_adapter *adpt)
{}

/* Config dma */
static void emac_mac_dma_config(struct emac_adapter *adpt)
{}

/* set MAC address */
static void emac_set_mac_address(struct emac_adapter *adpt, const u8 *addr)
{}

static void emac_mac_config(struct emac_adapter *adpt)
{}

void emac_mac_reset(struct emac_adapter *adpt)
{}

static void emac_mac_start(struct emac_adapter *adpt)
{}

void emac_mac_stop(struct emac_adapter *adpt)
{}

/* Free all descriptors of given transmit queue */
static void emac_tx_q_descs_free(struct emac_adapter *adpt)
{}

/* Free all descriptors of given receive queue */
static void emac_rx_q_free_descs(struct emac_adapter *adpt)
{}

/* Free all buffers associated with given transmit queue */
static void emac_tx_q_bufs_free(struct emac_adapter *adpt)
{}

/* Allocate TX descriptor ring for the given transmit queue */
static int emac_tx_q_desc_alloc(struct emac_adapter *adpt,
				struct emac_tx_queue *tx_q)
{}

/* Free all buffers associated with given transmit queue */
static void emac_rx_q_bufs_free(struct emac_adapter *adpt)
{}

/* Allocate RX descriptor rings for the given receive queue */
static int emac_rx_descs_alloc(struct emac_adapter *adpt)
{}

/* Allocate all TX and RX descriptor rings */
int emac_mac_rx_tx_rings_alloc_all(struct emac_adapter *adpt)
{}

/* Free all TX and RX descriptor rings */
void emac_mac_rx_tx_rings_free_all(struct emac_adapter *adpt)
{}

/* Initialize descriptor rings */
static void emac_mac_rx_tx_ring_reset_all(struct emac_adapter *adpt)
{}

/* Produce new receive free descriptor */
static void emac_mac_rx_rfd_create(struct emac_adapter *adpt,
				   struct emac_rx_queue *rx_q,
				   dma_addr_t addr)
{}

/* Fill up receive queue's RFD with preallocated receive buffers */
static void emac_mac_rx_descs_refill(struct emac_adapter *adpt,
				    struct emac_rx_queue *rx_q)
{}

static void emac_adjust_link(struct net_device *netdev)
{}

/* Bringup the interface/HW */
int emac_mac_up(struct emac_adapter *adpt)
{}

/* Bring down the interface/HW */
void emac_mac_down(struct emac_adapter *adpt)
{}

/* Consume next received packet descriptor */
static bool emac_rx_process_rrd(struct emac_adapter *adpt,
				struct emac_rx_queue *rx_q,
				struct emac_rrd *rrd)
{}

/* Produce new transmit descriptor */
static void emac_tx_tpd_create(struct emac_adapter *adpt,
			       struct emac_tx_queue *tx_q, struct emac_tpd *tpd)
{}

/* Mark the last transmit descriptor as such (for the transmit packet) */
static void emac_tx_tpd_mark_last(struct emac_adapter *adpt,
				  struct emac_tx_queue *tx_q)
{}

static void emac_rx_rfd_clean(struct emac_rx_queue *rx_q, struct emac_rrd *rrd)
{}

/* Push the received skb to upper layers */
static void emac_receive_skb(struct emac_rx_queue *rx_q,
			     struct sk_buff *skb,
			     u16 vlan_tag, bool vlan_flag)
{}

/* Process receive event */
void emac_mac_rx_process(struct emac_adapter *adpt, struct emac_rx_queue *rx_q,
			 int *num_pkts, int max_pkts)
{}

/* get the number of free transmit descriptors */
static unsigned int emac_tpd_num_free_descs(struct emac_tx_queue *tx_q)
{}

/* Process transmit event */
void emac_mac_tx_process(struct emac_adapter *adpt, struct emac_tx_queue *tx_q)
{}

/* Initialize all queue data structures */
void emac_mac_rx_tx_ring_init_all(struct platform_device *pdev,
				  struct emac_adapter *adpt)
{}

/* Fill up transmit descriptors with TSO and Checksum offload information */
static int emac_tso_csum(struct emac_adapter *adpt,
			 struct emac_tx_queue *tx_q,
			 struct sk_buff *skb,
			 struct emac_tpd *tpd)
{}

/* Fill up transmit descriptors */
static void emac_tx_fill_tpd(struct emac_adapter *adpt,
			     struct emac_tx_queue *tx_q, struct sk_buff *skb,
			     struct emac_tpd *tpd)
{}

/* Transmit the packet using specified transmit queue */
netdev_tx_t emac_mac_tx_buf_send(struct emac_adapter *adpt,
				 struct emac_tx_queue *tx_q,
				 struct sk_buff *skb)
{}