1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2018-2021 Beijing WangXun Technology Co., Ltd. 3 * Copyright(c) 2010-2017 Intel Corporation 4 */ 5 6 #ifndef _NGBE_ETHDEV_H_ 7 #define _NGBE_ETHDEV_H_ 8 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)) 15 16 #define NGBE_QUEUE_ITR_INTERVAL_DEFAULT 500 /* 500us */ 17 18 #define NGBE_MISC_VEC_ID RTE_INTR_VEC_ZERO_OFFSET 19 #define NGBE_RX_VEC_START RTE_INTR_VEC_RXTX_OFFSET 20 21 /* structure for interrupt relative data */ 22 struct ngbe_interrupt { 23 uint32_t flags; 24 uint32_t mask_misc; 25 uint32_t mask_misc_orig; /* save mask during delayed handler */ 26 uint64_t mask; 27 uint64_t mask_orig; /* save mask during delayed handler */ 28 }; 29 30 /* 31 * Structure to store private data for each driver instance (for each port). 32 */ 33 struct ngbe_adapter { 34 struct ngbe_hw hw; 35 struct ngbe_interrupt intr; 36 bool rx_bulk_alloc_allowed; 37 }; 38 39 static inline struct ngbe_adapter * 40 ngbe_dev_adapter(struct rte_eth_dev *dev) 41 { 42 struct ngbe_adapter *ad = dev->data->dev_private; 43 44 return ad; 45 } 46 47 static inline struct ngbe_hw * 48 ngbe_dev_hw(struct rte_eth_dev *dev) 49 { 50 struct ngbe_adapter *ad = ngbe_dev_adapter(dev); 51 struct ngbe_hw *hw = &ad->hw; 52 53 return hw; 54 } 55 56 static inline struct ngbe_interrupt * 57 ngbe_dev_intr(struct rte_eth_dev *dev) 58 { 59 struct ngbe_adapter *ad = ngbe_dev_adapter(dev); 60 struct ngbe_interrupt *intr = &ad->intr; 61 62 return intr; 63 } 64 65 /* 66 * Rx/Tx function prototypes 67 */ 68 void ngbe_dev_clear_queues(struct rte_eth_dev *dev); 69 70 void ngbe_dev_free_queues(struct rte_eth_dev *dev); 71 72 void ngbe_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid); 73 74 void ngbe_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid); 75 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); 80 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); 84 85 int ngbe_dev_rx_init(struct rte_eth_dev *dev); 86 87 void ngbe_dev_tx_init(struct rte_eth_dev *dev); 88 89 int ngbe_dev_rxtx_start(struct rte_eth_dev *dev); 90 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); 95 96 int ngbe_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id); 97 98 int ngbe_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id); 99 100 int ngbe_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id); 101 102 int ngbe_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id); 103 104 uint16_t ngbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, 105 uint16_t nb_pkts); 106 107 uint16_t ngbe_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts, 108 uint16_t nb_pkts); 109 110 void ngbe_set_ivar_map(struct ngbe_hw *hw, int8_t direction, 111 uint8_t queue, uint8_t msix_vector); 112 113 int 114 ngbe_dev_link_update_share(struct rte_eth_dev *dev, 115 int wait_to_complete); 116 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. */ 120 121 /* 122 * Default values for Rx/Tx configuration 123 */ 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 128 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 133 134 #endif /* _NGBE_ETHDEV_H_ */ 135