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 #define NGBE_MISC_VEC_ID RTE_INTR_VEC_ZERO_OFFSET
21 #define NGBE_RX_VEC_START RTE_INTR_VEC_RXTX_OFFSET
23 /* structure for interrupt relative data */
24 struct ngbe_interrupt {
27 uint32_t mask_misc_orig; /* save mask during delayed handler */
29 uint64_t mask_orig; /* save mask during delayed handler */
33 * Structure to store private data for each driver instance (for each port).
37 struct ngbe_interrupt intr;
38 bool rx_bulk_alloc_allowed;
41 static inline struct ngbe_adapter *
42 ngbe_dev_adapter(struct rte_eth_dev *dev)
44 struct ngbe_adapter *ad = dev->data->dev_private;
49 static inline struct ngbe_hw *
50 ngbe_dev_hw(struct rte_eth_dev *dev)
52 struct ngbe_adapter *ad = ngbe_dev_adapter(dev);
53 struct ngbe_hw *hw = &ad->hw;
58 static inline struct ngbe_interrupt *
59 ngbe_dev_intr(struct rte_eth_dev *dev)
61 struct ngbe_adapter *ad = ngbe_dev_adapter(dev);
62 struct ngbe_interrupt *intr = &ad->intr;
68 * Rx/Tx function prototypes
70 void ngbe_dev_clear_queues(struct rte_eth_dev *dev);
72 void ngbe_dev_free_queues(struct rte_eth_dev *dev);
74 void ngbe_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
76 void ngbe_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
78 int ngbe_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
79 uint16_t nb_rx_desc, unsigned int socket_id,
80 const struct rte_eth_rxconf *rx_conf,
81 struct rte_mempool *mb_pool);
83 int ngbe_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
84 uint16_t nb_tx_desc, unsigned int socket_id,
85 const struct rte_eth_txconf *tx_conf);
87 int ngbe_dev_rx_init(struct rte_eth_dev *dev);
89 void ngbe_dev_tx_init(struct rte_eth_dev *dev);
91 int ngbe_dev_rxtx_start(struct rte_eth_dev *dev);
93 void ngbe_dev_save_rx_queue(struct ngbe_hw *hw, uint16_t rx_queue_id);
94 void ngbe_dev_store_rx_queue(struct ngbe_hw *hw, uint16_t rx_queue_id);
95 void ngbe_dev_save_tx_queue(struct ngbe_hw *hw, uint16_t tx_queue_id);
96 void ngbe_dev_store_tx_queue(struct ngbe_hw *hw, uint16_t tx_queue_id);
98 int ngbe_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
100 int ngbe_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
102 int ngbe_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
104 int ngbe_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
106 uint16_t ngbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
109 uint16_t ngbe_recv_pkts_bulk_alloc(void *rx_queue, struct rte_mbuf **rx_pkts,
112 uint16_t ngbe_recv_pkts_sc_single_alloc(void *rx_queue,
113 struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
114 uint16_t ngbe_recv_pkts_sc_bulk_alloc(void *rx_queue,
115 struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
117 uint16_t ngbe_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
120 void ngbe_set_ivar_map(struct ngbe_hw *hw, int8_t direction,
121 uint8_t queue, uint8_t msix_vector);
124 ngbe_dev_link_update_share(struct rte_eth_dev *dev,
125 int wait_to_complete);
127 #define NGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
128 #define NGBE_LINK_UP_CHECK_TIMEOUT 1000 /* ms */
129 #define NGBE_VMDQ_NUM_UC_MAC 4096 /* Maximum nb. of UC MAC addr. */
132 * Default values for Rx/Tx configuration
134 #define NGBE_DEFAULT_RX_FREE_THRESH 32
135 #define NGBE_DEFAULT_RX_PTHRESH 8
136 #define NGBE_DEFAULT_RX_HTHRESH 8
137 #define NGBE_DEFAULT_RX_WTHRESH 0
139 #define NGBE_DEFAULT_TX_FREE_THRESH 32
140 #define NGBE_DEFAULT_TX_PTHRESH 32
141 #define NGBE_DEFAULT_TX_HTHRESH 0
142 #define NGBE_DEFAULT_TX_WTHRESH 0
144 const uint32_t *ngbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
146 #endif /* _NGBE_ETHDEV_H_ */