1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018-2019 NXP
10 #include "base/enetc_hw.h"
12 #define PCI_VENDOR_ID_FREESCALE 0x1957
14 /* Max TX rings per ENETC. */
15 #define MAX_TX_RINGS 2
17 /* Max RX rings per ENTEC. */
18 #define MAX_RX_RINGS 1
20 /* Max BD counts per Ring. */
21 #define MAX_BD_COUNT 64000
22 /* Min BD counts per Ring. */
23 #define MIN_BD_COUNT 32
27 /* minimum frame size supported */
28 #define ENETC_MAC_MINFRM_SIZE 68
29 /* maximum frame size supported */
30 #define ENETC_MAC_MAXFRM_SIZE 9600
32 /* The max frame size with default MTU */
33 #define ENETC_ETH_MAX_LEN (RTE_ETHER_MTU + \
34 RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN)
37 * upper_32_bits - return bits 32-63 of a number
38 * @n: the number we're accessing
40 * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress
41 * the "right shift count >= width of type" warning when that quantity is
44 #define upper_32_bits(n) ((uint32_t)(((n) >> 16) >> 16))
47 * lower_32_bits - return bits 0-31 of a number
48 * @n: the number we're accessing
50 #define lower_32_bits(n) ((uint32_t)(n))
52 #define ENETC_TXBD(BDR, i) (&(((struct enetc_tx_bd *)((BDR).bd_base))[i]))
53 #define ENETC_RXBD(BDR, i) (&(((union enetc_rx_bd *)((BDR).bd_base))[i]))
56 struct rte_mbuf *buffer_addr;
60 void *bd_base; /* points to Rx or Tx BD ring */
61 struct enetc_swbd *q_swbd;
66 int bd_count; /* # of BDs */
70 uint8_t crc_len; /* 0 if CRC stripped, 4 otherwise */
73 int next_to_alloc; /* Rx */
75 struct rte_mempool *mb_pool; /* mbuf pool to populate RX ring. */
76 struct rte_eth_dev *ndev;
80 * Structure to store private data for each driver instance (for each port).
82 struct enetc_eth_adapter {
83 struct rte_eth_dev *ndev;
84 struct enetc_eth_hw hw;
87 #define ENETC_DEV_PRIVATE(adapter) \
88 ((struct enetc_eth_adapter *)adapter)
90 #define ENETC_DEV_PRIVATE_TO_HW(adapter) \
91 (&((struct enetc_eth_adapter *)adapter)->hw)
93 #define ENETC_DEV_PRIVATE_TO_STATS(adapter) \
94 (&((struct enetc_eth_adapter *)adapter)->stats)
96 #define ENETC_DEV_PRIVATE_TO_INTR(adapter) \
97 (&((struct enetc_eth_adapter *)adapter)->intr)
100 * RX/TX ENETC function prototypes
102 uint16_t enetc_xmit_pkts(void *txq, struct rte_mbuf **tx_pkts,
104 uint16_t enetc_recv_pkts(void *rxq, struct rte_mbuf **rx_pkts,
108 int enetc_refill_rx_ring(struct enetc_bdr *rx_ring, const int buff_cnt);
111 enetc_bd_unused(struct enetc_bdr *bdr)
113 if (bdr->next_to_clean > bdr->next_to_use)
114 return bdr->next_to_clean - bdr->next_to_use - 1;
116 return bdr->bd_count + bdr->next_to_clean - bdr->next_to_use - 1;
118 #endif /* _ENETC_H_ */