b270343a3eed104cced792a6f368c5179724df09
[dpdk.git] / drivers / net / ngbe / ngbe_ethdev.h
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 #include "ngbe_ptypes.h"
10
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))
17
18 #define NGBE_QUEUE_ITR_INTERVAL_DEFAULT 500 /* 500us */
19
20 /* The overhead from MTU to max frame size. */
21 #define NGBE_ETH_OVERHEAD (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN)
22
23 #define NGBE_MISC_VEC_ID               RTE_INTR_VEC_ZERO_OFFSET
24 #define NGBE_RX_VEC_START              RTE_INTR_VEC_RXTX_OFFSET
25
26 /* structure for interrupt relative data */
27 struct ngbe_interrupt {
28         uint32_t flags;
29         uint32_t mask_misc;
30         uint32_t mask_misc_orig; /* save mask during delayed handler */
31         uint64_t mask;
32         uint64_t mask_orig; /* save mask during delayed handler */
33 };
34
35 /*
36  * Structure to store private data for each driver instance (for each port).
37  */
38 struct ngbe_adapter {
39         struct ngbe_hw             hw;
40         struct ngbe_interrupt      intr;
41         bool                       rx_bulk_alloc_allowed;
42 };
43
44 static inline struct ngbe_adapter *
45 ngbe_dev_adapter(struct rte_eth_dev *dev)
46 {
47         struct ngbe_adapter *ad = dev->data->dev_private;
48
49         return ad;
50 }
51
52 static inline struct ngbe_hw *
53 ngbe_dev_hw(struct rte_eth_dev *dev)
54 {
55         struct ngbe_adapter *ad = ngbe_dev_adapter(dev);
56         struct ngbe_hw *hw = &ad->hw;
57
58         return hw;
59 }
60
61 static inline struct ngbe_interrupt *
62 ngbe_dev_intr(struct rte_eth_dev *dev)
63 {
64         struct ngbe_adapter *ad = ngbe_dev_adapter(dev);
65         struct ngbe_interrupt *intr = &ad->intr;
66
67         return intr;
68 }
69
70 /*
71  * Rx/Tx function prototypes
72  */
73 void ngbe_dev_clear_queues(struct rte_eth_dev *dev);
74
75 void ngbe_dev_free_queues(struct rte_eth_dev *dev);
76
77 void ngbe_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
78
79 void ngbe_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
80
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);
85
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);
89
90 int ngbe_dev_rx_init(struct rte_eth_dev *dev);
91
92 void ngbe_dev_tx_init(struct rte_eth_dev *dev);
93
94 int ngbe_dev_rxtx_start(struct rte_eth_dev *dev);
95
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);
100
101 int ngbe_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
102
103 int ngbe_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
104
105 int ngbe_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
106
107 int ngbe_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
108
109 int
110 ngbe_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
111                       struct rte_eth_burst_mode *mode);
112 int
113 ngbe_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
114                       struct rte_eth_burst_mode *mode);
115
116 uint16_t ngbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
117                 uint16_t nb_pkts);
118
119 uint16_t ngbe_recv_pkts_bulk_alloc(void *rx_queue, struct rte_mbuf **rx_pkts,
120                                     uint16_t nb_pkts);
121
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);
126
127 uint16_t ngbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
128                 uint16_t nb_pkts);
129
130 uint16_t ngbe_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
131                 uint16_t nb_pkts);
132
133 uint16_t ngbe_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
134                 uint16_t nb_pkts);
135
136 void ngbe_set_ivar_map(struct ngbe_hw *hw, int8_t direction,
137                                uint8_t queue, uint8_t msix_vector);
138
139 int
140 ngbe_dev_link_update_share(struct rte_eth_dev *dev,
141                 int wait_to_complete);
142
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. */
146
147 /*
148  *  Default values for Rx/Tx configuration
149  */
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
154
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
159
160 const uint32_t *ngbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
161
162 #endif /* _NGBE_ETHDEV_H_ */