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 */
47 uint32_t vfta[NGBE_VFTA_SIZE];
51 uint32_t bitmap[NGBE_HWSTRIP_BITMAP_SIZE];
55 * Structure to store private data for each driver instance (for each port).
59 struct ngbe_interrupt intr;
60 struct ngbe_vfta shadow_vfta;
61 struct ngbe_hwstrip hwstrip;
62 bool rx_bulk_alloc_allowed;
65 static inline struct ngbe_adapter *
66 ngbe_dev_adapter(struct rte_eth_dev *dev)
68 struct ngbe_adapter *ad = dev->data->dev_private;
73 static inline struct ngbe_hw *
74 ngbe_dev_hw(struct rte_eth_dev *dev)
76 struct ngbe_adapter *ad = ngbe_dev_adapter(dev);
77 struct ngbe_hw *hw = &ad->hw;
82 static inline struct ngbe_interrupt *
83 ngbe_dev_intr(struct rte_eth_dev *dev)
85 struct ngbe_adapter *ad = ngbe_dev_adapter(dev);
86 struct ngbe_interrupt *intr = &ad->intr;
91 #define NGBE_DEV_VFTA(dev) \
92 (&((struct ngbe_adapter *)(dev)->data->dev_private)->shadow_vfta)
94 #define NGBE_DEV_HWSTRIP(dev) \
95 (&((struct ngbe_adapter *)(dev)->data->dev_private)->hwstrip)
98 * Rx/Tx function prototypes
100 void ngbe_dev_clear_queues(struct rte_eth_dev *dev);
102 void ngbe_dev_free_queues(struct rte_eth_dev *dev);
104 void ngbe_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
106 void ngbe_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
108 int ngbe_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
109 uint16_t nb_rx_desc, unsigned int socket_id,
110 const struct rte_eth_rxconf *rx_conf,
111 struct rte_mempool *mb_pool);
113 int ngbe_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
114 uint16_t nb_tx_desc, unsigned int socket_id,
115 const struct rte_eth_txconf *tx_conf);
117 int ngbe_dev_rx_init(struct rte_eth_dev *dev);
119 void ngbe_dev_tx_init(struct rte_eth_dev *dev);
121 int ngbe_dev_rxtx_start(struct rte_eth_dev *dev);
123 void ngbe_dev_save_rx_queue(struct ngbe_hw *hw, uint16_t rx_queue_id);
124 void ngbe_dev_store_rx_queue(struct ngbe_hw *hw, uint16_t rx_queue_id);
125 void ngbe_dev_save_tx_queue(struct ngbe_hw *hw, uint16_t tx_queue_id);
126 void ngbe_dev_store_tx_queue(struct ngbe_hw *hw, uint16_t tx_queue_id);
128 int ngbe_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
130 int ngbe_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
132 int ngbe_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
134 int ngbe_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
137 ngbe_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
138 struct rte_eth_burst_mode *mode);
140 ngbe_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
141 struct rte_eth_burst_mode *mode);
143 uint16_t ngbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
146 uint16_t ngbe_recv_pkts_bulk_alloc(void *rx_queue, struct rte_mbuf **rx_pkts,
149 uint16_t ngbe_recv_pkts_sc_single_alloc(void *rx_queue,
150 struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
151 uint16_t ngbe_recv_pkts_sc_bulk_alloc(void *rx_queue,
152 struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
154 uint16_t ngbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
157 uint16_t ngbe_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
160 uint16_t ngbe_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
163 void ngbe_set_ivar_map(struct ngbe_hw *hw, int8_t direction,
164 uint8_t queue, uint8_t msix_vector);
166 void ngbe_configure_port(struct rte_eth_dev *dev);
169 ngbe_dev_link_update_share(struct rte_eth_dev *dev,
170 int wait_to_complete);
173 * misc function prototypes
175 void ngbe_vlan_hw_filter_enable(struct rte_eth_dev *dev);
177 void ngbe_vlan_hw_filter_disable(struct rte_eth_dev *dev);
179 void ngbe_vlan_hw_strip_config(struct rte_eth_dev *dev);
181 #define NGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
182 #define NGBE_LINK_UP_CHECK_TIMEOUT 1000 /* ms */
183 #define NGBE_VMDQ_NUM_UC_MAC 4096 /* Maximum nb. of UC MAC addr. */
186 * Default values for Rx/Tx configuration
188 #define NGBE_DEFAULT_RX_FREE_THRESH 32
189 #define NGBE_DEFAULT_RX_PTHRESH 8
190 #define NGBE_DEFAULT_RX_HTHRESH 8
191 #define NGBE_DEFAULT_RX_WTHRESH 0
193 #define NGBE_DEFAULT_TX_FREE_THRESH 32
194 #define NGBE_DEFAULT_TX_PTHRESH 32
195 #define NGBE_DEFAULT_TX_HTHRESH 0
196 #define NGBE_DEFAULT_TX_WTHRESH 0
198 const uint32_t *ngbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
199 void ngbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev,
200 uint16_t queue, bool on);
201 void ngbe_config_vlan_strip_on_all_queues(struct rte_eth_dev *dev,
204 #endif /* _NGBE_ETHDEV_H_ */