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
33 * upper_32_bits - return bits 32-63 of a number
34 * @n: the number we're accessing
36 * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress
37 * the "right shift count >= width of type" warning when that quantity is
40 #define upper_32_bits(n) ((uint32_t)(((n) >> 16) >> 16))
43 * lower_32_bits - return bits 0-31 of a number
44 * @n: the number we're accessing
46 #define lower_32_bits(n) ((uint32_t)(n))
48 #define ENETC_TXBD(BDR, i) (&(((struct enetc_tx_bd *)((BDR).bd_base))[i]))
49 #define ENETC_RXBD(BDR, i) (&(((union enetc_rx_bd *)((BDR).bd_base))[i]))
52 struct rte_mbuf *buffer_addr;
56 void *bd_base; /* points to Rx or Tx BD ring */
57 struct enetc_swbd *q_swbd;
62 int bd_count; /* # of BDs */
66 uint8_t crc_len; /* 0 if CRC stripped, 4 otherwise */
69 int next_to_alloc; /* Rx */
71 struct rte_mempool *mb_pool; /* mbuf pool to populate RX ring. */
72 struct rte_eth_dev *ndev;
76 * Structure to store private data for each driver instance (for each port).
78 struct enetc_eth_adapter {
79 struct rte_eth_dev *ndev;
80 struct enetc_eth_hw hw;
83 #define ENETC_DEV_PRIVATE(adapter) \
84 ((struct enetc_eth_adapter *)adapter)
86 #define ENETC_DEV_PRIVATE_TO_HW(adapter) \
87 (&((struct enetc_eth_adapter *)adapter)->hw)
89 #define ENETC_DEV_PRIVATE_TO_STATS(adapter) \
90 (&((struct enetc_eth_adapter *)adapter)->stats)
92 #define ENETC_DEV_PRIVATE_TO_INTR(adapter) \
93 (&((struct enetc_eth_adapter *)adapter)->intr)
96 * RX/TX ENETC function prototypes
98 uint16_t enetc_xmit_pkts(void *txq, struct rte_mbuf **tx_pkts,
100 uint16_t enetc_recv_pkts(void *rxq, struct rte_mbuf **rx_pkts,
104 int enetc_refill_rx_ring(struct enetc_bdr *rx_ring, const int buff_cnt);
107 enetc_bd_unused(struct enetc_bdr *bdr)
109 if (bdr->next_to_clean > bdr->next_to_use)
110 return bdr->next_to_clean - bdr->next_to_use - 1;
112 return bdr->bd_count + bdr->next_to_clean - bdr->next_to_use - 1;
114 #endif /* _ENETC_H_ */