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 /* need update link, bit flag */
10 #define NGBE_FLAG_NEED_LINK_UPDATE ((uint32_t)(1 << 0))
11 #define NGBE_FLAG_MAILBOX ((uint32_t)(1 << 1))
12 #define NGBE_FLAG_PHY_INTERRUPT ((uint32_t)(1 << 2))
13 #define NGBE_FLAG_MACSEC ((uint32_t)(1 << 3))
14 #define NGBE_FLAG_NEED_LINK_CONFIG ((uint32_t)(1 << 4))
16 #define NGBE_QUEUE_ITR_INTERVAL_DEFAULT 500 /* 500us */
18 #define NGBE_MISC_VEC_ID RTE_INTR_VEC_ZERO_OFFSET
19 #define NGBE_RX_VEC_START RTE_INTR_VEC_RXTX_OFFSET
21 /* structure for interrupt relative data */
22 struct ngbe_interrupt {
25 uint32_t mask_misc_orig; /* save mask during delayed handler */
27 uint64_t mask_orig; /* save mask during delayed handler */
31 * Structure to store private data for each driver instance (for each port).
35 struct ngbe_interrupt intr;
36 bool rx_bulk_alloc_allowed;
39 static inline struct ngbe_adapter *
40 ngbe_dev_adapter(struct rte_eth_dev *dev)
42 struct ngbe_adapter *ad = dev->data->dev_private;
47 static inline struct ngbe_hw *
48 ngbe_dev_hw(struct rte_eth_dev *dev)
50 struct ngbe_adapter *ad = ngbe_dev_adapter(dev);
51 struct ngbe_hw *hw = &ad->hw;
56 static inline struct ngbe_interrupt *
57 ngbe_dev_intr(struct rte_eth_dev *dev)
59 struct ngbe_adapter *ad = ngbe_dev_adapter(dev);
60 struct ngbe_interrupt *intr = &ad->intr;
66 * Rx/Tx function prototypes
68 void ngbe_dev_clear_queues(struct rte_eth_dev *dev);
70 void ngbe_dev_free_queues(struct rte_eth_dev *dev);
72 void ngbe_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
74 void ngbe_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
76 int ngbe_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
77 uint16_t nb_rx_desc, unsigned int socket_id,
78 const struct rte_eth_rxconf *rx_conf,
79 struct rte_mempool *mb_pool);
81 int ngbe_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
82 uint16_t nb_tx_desc, unsigned int socket_id,
83 const struct rte_eth_txconf *tx_conf);
85 int ngbe_dev_rx_init(struct rte_eth_dev *dev);
87 void ngbe_dev_tx_init(struct rte_eth_dev *dev);
89 int ngbe_dev_rxtx_start(struct rte_eth_dev *dev);
91 void ngbe_dev_save_rx_queue(struct ngbe_hw *hw, uint16_t rx_queue_id);
92 void ngbe_dev_store_rx_queue(struct ngbe_hw *hw, uint16_t rx_queue_id);
93 void ngbe_dev_save_tx_queue(struct ngbe_hw *hw, uint16_t tx_queue_id);
94 void ngbe_dev_store_tx_queue(struct ngbe_hw *hw, uint16_t tx_queue_id);
96 int ngbe_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
98 int ngbe_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
100 int ngbe_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
102 int ngbe_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
104 uint16_t ngbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
107 uint16_t ngbe_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
110 void ngbe_set_ivar_map(struct ngbe_hw *hw, int8_t direction,
111 uint8_t queue, uint8_t msix_vector);
114 ngbe_dev_link_update_share(struct rte_eth_dev *dev,
115 int wait_to_complete);
117 #define NGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
118 #define NGBE_LINK_UP_CHECK_TIMEOUT 1000 /* ms */
119 #define NGBE_VMDQ_NUM_UC_MAC 4096 /* Maximum nb. of UC MAC addr. */
122 * Default values for Rx/Tx configuration
124 #define NGBE_DEFAULT_RX_FREE_THRESH 32
125 #define NGBE_DEFAULT_RX_PTHRESH 8
126 #define NGBE_DEFAULT_RX_HTHRESH 8
127 #define NGBE_DEFAULT_RX_WTHRESH 0
129 #define NGBE_DEFAULT_TX_FREE_THRESH 32
130 #define NGBE_DEFAULT_TX_PTHRESH 32
131 #define NGBE_DEFAULT_TX_HTHRESH 0
132 #define NGBE_DEFAULT_TX_WTHRESH 0
134 #endif /* _NGBE_ETHDEV_H_ */