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_QUEUE_ITR_INTERVAL_DEFAULT 500 /* 500us */
20 /* The overhead from MTU to max frame size. */
21 #define NGBE_ETH_OVERHEAD (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN)
23 #define NGBE_MISC_VEC_ID RTE_INTR_VEC_ZERO_OFFSET
24 #define NGBE_RX_VEC_START RTE_INTR_VEC_RXTX_OFFSET
26 /* structure for interrupt relative data */
27 struct ngbe_interrupt {
30 uint32_t mask_misc_orig; /* save mask during delayed handler */
32 uint64_t mask_orig; /* save mask during delayed handler */
36 * Structure to store private data for each driver instance (for each port).
40 struct ngbe_interrupt intr;
41 bool rx_bulk_alloc_allowed;
44 static inline struct ngbe_adapter *
45 ngbe_dev_adapter(struct rte_eth_dev *dev)
47 struct ngbe_adapter *ad = dev->data->dev_private;
52 static inline struct ngbe_hw *
53 ngbe_dev_hw(struct rte_eth_dev *dev)
55 struct ngbe_adapter *ad = ngbe_dev_adapter(dev);
56 struct ngbe_hw *hw = &ad->hw;
61 static inline struct ngbe_interrupt *
62 ngbe_dev_intr(struct rte_eth_dev *dev)
64 struct ngbe_adapter *ad = ngbe_dev_adapter(dev);
65 struct ngbe_interrupt *intr = &ad->intr;
71 * Rx/Tx function prototypes
73 void ngbe_dev_clear_queues(struct rte_eth_dev *dev);
75 void ngbe_dev_free_queues(struct rte_eth_dev *dev);
77 void ngbe_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
79 void ngbe_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
81 int ngbe_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
82 uint16_t nb_rx_desc, unsigned int socket_id,
83 const struct rte_eth_rxconf *rx_conf,
84 struct rte_mempool *mb_pool);
86 int ngbe_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
87 uint16_t nb_tx_desc, unsigned int socket_id,
88 const struct rte_eth_txconf *tx_conf);
90 int ngbe_dev_rx_init(struct rte_eth_dev *dev);
92 void ngbe_dev_tx_init(struct rte_eth_dev *dev);
94 int ngbe_dev_rxtx_start(struct rte_eth_dev *dev);
96 void ngbe_dev_save_rx_queue(struct ngbe_hw *hw, uint16_t rx_queue_id);
97 void ngbe_dev_store_rx_queue(struct ngbe_hw *hw, uint16_t rx_queue_id);
98 void ngbe_dev_save_tx_queue(struct ngbe_hw *hw, uint16_t tx_queue_id);
99 void ngbe_dev_store_tx_queue(struct ngbe_hw *hw, uint16_t tx_queue_id);
101 int ngbe_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
103 int ngbe_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
105 int ngbe_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
107 int ngbe_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
110 ngbe_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
111 struct rte_eth_burst_mode *mode);
113 ngbe_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
114 struct rte_eth_burst_mode *mode);
116 uint16_t ngbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
119 uint16_t ngbe_recv_pkts_bulk_alloc(void *rx_queue, struct rte_mbuf **rx_pkts,
122 uint16_t ngbe_recv_pkts_sc_single_alloc(void *rx_queue,
123 struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
124 uint16_t ngbe_recv_pkts_sc_bulk_alloc(void *rx_queue,
125 struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
127 uint16_t ngbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
130 uint16_t ngbe_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
133 uint16_t ngbe_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
136 void ngbe_set_ivar_map(struct ngbe_hw *hw, int8_t direction,
137 uint8_t queue, uint8_t msix_vector);
140 ngbe_dev_link_update_share(struct rte_eth_dev *dev,
141 int wait_to_complete);
143 #define NGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
144 #define NGBE_LINK_UP_CHECK_TIMEOUT 1000 /* ms */
145 #define NGBE_VMDQ_NUM_UC_MAC 4096 /* Maximum nb. of UC MAC addr. */
148 * Default values for Rx/Tx configuration
150 #define NGBE_DEFAULT_RX_FREE_THRESH 32
151 #define NGBE_DEFAULT_RX_PTHRESH 8
152 #define NGBE_DEFAULT_RX_HTHRESH 8
153 #define NGBE_DEFAULT_RX_WTHRESH 0
155 #define NGBE_DEFAULT_TX_FREE_THRESH 32
156 #define NGBE_DEFAULT_TX_PTHRESH 32
157 #define NGBE_DEFAULT_TX_HTHRESH 0
158 #define NGBE_DEFAULT_TX_WTHRESH 0
160 const uint32_t *ngbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
162 #endif /* _NGBE_ETHDEV_H_ */