1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018-2021 Beijing WangXun Technology Co., Ltd.
3 * Copyright(c) 2010-2017 Intel Corporation
6 #ifndef _NGBE_ETHDEV_H_
7 #define _NGBE_ETHDEV_H_
9 #include "ngbe_ptypes.h"
11 /* need update link, bit flag */
12 #define NGBE_FLAG_NEED_LINK_UPDATE ((uint32_t)(1 << 0))
13 #define NGBE_FLAG_MAILBOX ((uint32_t)(1 << 1))
14 #define NGBE_FLAG_PHY_INTERRUPT ((uint32_t)(1 << 2))
15 #define NGBE_FLAG_MACSEC ((uint32_t)(1 << 3))
16 #define NGBE_FLAG_NEED_LINK_CONFIG ((uint32_t)(1 << 4))
18 #define NGBE_VFTA_SIZE 128
19 #define NGBE_VLAN_TAG_SIZE 4
20 /*Default value of Max Rx Queue*/
21 #define NGBE_MAX_RX_QUEUE_NUM 8
24 #define NBBY 8 /* number of bits in a byte */
26 #define NGBE_HWSTRIP_BITMAP_SIZE \
27 (NGBE_MAX_RX_QUEUE_NUM / (sizeof(uint32_t) * NBBY))
29 #define NGBE_QUEUE_ITR_INTERVAL_DEFAULT 500 /* 500us */
31 /* The overhead from MTU to max frame size. */
32 #define NGBE_ETH_OVERHEAD (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN)
34 #define NGBE_MISC_VEC_ID RTE_INTR_VEC_ZERO_OFFSET
35 #define NGBE_RX_VEC_START RTE_INTR_VEC_RXTX_OFFSET
37 /* structure for interrupt relative data */
38 struct ngbe_interrupt {
41 uint32_t mask_misc_orig; /* save mask during delayed handler */
43 uint64_t mask_orig; /* save mask during delayed handler */
46 #define NGBE_NB_STAT_MAPPING 32
47 #define NB_QMAP_FIELDS_PER_QSM_REG 4
48 #define QMAP_FIELD_RESERVED_BITS_MASK 0x0f
49 struct ngbe_stat_mappings {
50 uint32_t tqsm[NGBE_NB_STAT_MAPPING];
51 uint32_t rqsm[NGBE_NB_STAT_MAPPING];
55 uint32_t vfta[NGBE_VFTA_SIZE];
59 uint32_t bitmap[NGBE_HWSTRIP_BITMAP_SIZE];
63 * Structure to store private data for each driver instance (for each port).
67 struct ngbe_hw_stats stats;
68 struct ngbe_interrupt intr;
69 struct ngbe_stat_mappings stat_mappings;
70 struct ngbe_vfta shadow_vfta;
71 struct ngbe_hwstrip hwstrip;
72 bool rx_bulk_alloc_allowed;
75 static inline struct ngbe_adapter *
76 ngbe_dev_adapter(struct rte_eth_dev *dev)
78 struct ngbe_adapter *ad = dev->data->dev_private;
83 static inline struct ngbe_hw *
84 ngbe_dev_hw(struct rte_eth_dev *dev)
86 struct ngbe_adapter *ad = ngbe_dev_adapter(dev);
87 struct ngbe_hw *hw = &ad->hw;
92 #define NGBE_DEV_STATS(dev) \
93 (&((struct ngbe_adapter *)(dev)->data->dev_private)->stats)
95 static inline struct ngbe_interrupt *
96 ngbe_dev_intr(struct rte_eth_dev *dev)
98 struct ngbe_adapter *ad = ngbe_dev_adapter(dev);
99 struct ngbe_interrupt *intr = &ad->intr;
104 #define NGBE_DEV_STAT_MAPPINGS(dev) \
105 (&((struct ngbe_adapter *)(dev)->data->dev_private)->stat_mappings)
107 #define NGBE_DEV_VFTA(dev) \
108 (&((struct ngbe_adapter *)(dev)->data->dev_private)->shadow_vfta)
110 #define NGBE_DEV_HWSTRIP(dev) \
111 (&((struct ngbe_adapter *)(dev)->data->dev_private)->hwstrip)
114 * Rx/Tx function prototypes
116 void ngbe_dev_clear_queues(struct rte_eth_dev *dev);
118 void ngbe_dev_free_queues(struct rte_eth_dev *dev);
120 void ngbe_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
122 void ngbe_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
124 int ngbe_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
125 uint16_t nb_rx_desc, unsigned int socket_id,
126 const struct rte_eth_rxconf *rx_conf,
127 struct rte_mempool *mb_pool);
129 int ngbe_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
130 uint16_t nb_tx_desc, unsigned int socket_id,
131 const struct rte_eth_txconf *tx_conf);
133 int ngbe_dev_rx_init(struct rte_eth_dev *dev);
135 void ngbe_dev_tx_init(struct rte_eth_dev *dev);
137 int ngbe_dev_rxtx_start(struct rte_eth_dev *dev);
139 void ngbe_dev_save_rx_queue(struct ngbe_hw *hw, uint16_t rx_queue_id);
140 void ngbe_dev_store_rx_queue(struct ngbe_hw *hw, uint16_t rx_queue_id);
141 void ngbe_dev_save_tx_queue(struct ngbe_hw *hw, uint16_t tx_queue_id);
142 void ngbe_dev_store_tx_queue(struct ngbe_hw *hw, uint16_t tx_queue_id);
144 int ngbe_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
146 int ngbe_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
148 int ngbe_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
150 int ngbe_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
153 ngbe_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
154 struct rte_eth_burst_mode *mode);
156 ngbe_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
157 struct rte_eth_burst_mode *mode);
159 uint16_t ngbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
162 uint16_t ngbe_recv_pkts_bulk_alloc(void *rx_queue, struct rte_mbuf **rx_pkts,
165 uint16_t ngbe_recv_pkts_sc_single_alloc(void *rx_queue,
166 struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
167 uint16_t ngbe_recv_pkts_sc_bulk_alloc(void *rx_queue,
168 struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
170 uint16_t ngbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
173 uint16_t ngbe_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
176 uint16_t ngbe_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
179 void ngbe_set_ivar_map(struct ngbe_hw *hw, int8_t direction,
180 uint8_t queue, uint8_t msix_vector);
182 void ngbe_configure_port(struct rte_eth_dev *dev);
185 ngbe_dev_link_update_share(struct rte_eth_dev *dev,
186 int wait_to_complete);
189 * misc function prototypes
191 void ngbe_vlan_hw_filter_enable(struct rte_eth_dev *dev);
193 void ngbe_vlan_hw_filter_disable(struct rte_eth_dev *dev);
195 void ngbe_vlan_hw_strip_config(struct rte_eth_dev *dev);
197 #define NGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
198 #define NGBE_LINK_UP_CHECK_TIMEOUT 1000 /* ms */
199 #define NGBE_VMDQ_NUM_UC_MAC 4096 /* Maximum nb. of UC MAC addr. */
202 * Default values for Rx/Tx configuration
204 #define NGBE_DEFAULT_RX_FREE_THRESH 32
205 #define NGBE_DEFAULT_RX_PTHRESH 8
206 #define NGBE_DEFAULT_RX_HTHRESH 8
207 #define NGBE_DEFAULT_RX_WTHRESH 0
209 #define NGBE_DEFAULT_TX_FREE_THRESH 32
210 #define NGBE_DEFAULT_TX_PTHRESH 32
211 #define NGBE_DEFAULT_TX_HTHRESH 0
212 #define NGBE_DEFAULT_TX_WTHRESH 0
214 /* store statistics names and its offset in stats structure */
215 struct rte_ngbe_xstats_name_off {
216 char name[RTE_ETH_XSTATS_NAME_SIZE];
220 const uint32_t *ngbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
221 void ngbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev,
222 uint16_t queue, bool on);
223 void ngbe_config_vlan_strip_on_all_queues(struct rte_eth_dev *dev,
225 void ngbe_read_stats_registers(struct ngbe_hw *hw,
226 struct ngbe_hw_stats *hw_stats);
228 #endif /* _NGBE_ETHDEV_H_ */