net/ngbe: support scattered Rx
[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 #define NGBE_MISC_VEC_ID               RTE_INTR_VEC_ZERO_OFFSET
21 #define NGBE_RX_VEC_START              RTE_INTR_VEC_RXTX_OFFSET
22
23 /* structure for interrupt relative data */
24 struct ngbe_interrupt {
25         uint32_t flags;
26         uint32_t mask_misc;
27         uint32_t mask_misc_orig; /* save mask during delayed handler */
28         uint64_t mask;
29         uint64_t mask_orig; /* save mask during delayed handler */
30 };
31
32 /*
33  * Structure to store private data for each driver instance (for each port).
34  */
35 struct ngbe_adapter {
36         struct ngbe_hw             hw;
37         struct ngbe_interrupt      intr;
38         bool                       rx_bulk_alloc_allowed;
39 };
40
41 static inline struct ngbe_adapter *
42 ngbe_dev_adapter(struct rte_eth_dev *dev)
43 {
44         struct ngbe_adapter *ad = dev->data->dev_private;
45
46         return ad;
47 }
48
49 static inline struct ngbe_hw *
50 ngbe_dev_hw(struct rte_eth_dev *dev)
51 {
52         struct ngbe_adapter *ad = ngbe_dev_adapter(dev);
53         struct ngbe_hw *hw = &ad->hw;
54
55         return hw;
56 }
57
58 static inline struct ngbe_interrupt *
59 ngbe_dev_intr(struct rte_eth_dev *dev)
60 {
61         struct ngbe_adapter *ad = ngbe_dev_adapter(dev);
62         struct ngbe_interrupt *intr = &ad->intr;
63
64         return intr;
65 }
66
67 /*
68  * Rx/Tx function prototypes
69  */
70 void ngbe_dev_clear_queues(struct rte_eth_dev *dev);
71
72 void ngbe_dev_free_queues(struct rte_eth_dev *dev);
73
74 void ngbe_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
75
76 void ngbe_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
77
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);
82
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);
86
87 int ngbe_dev_rx_init(struct rte_eth_dev *dev);
88
89 void ngbe_dev_tx_init(struct rte_eth_dev *dev);
90
91 int ngbe_dev_rxtx_start(struct rte_eth_dev *dev);
92
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);
97
98 int ngbe_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
99
100 int ngbe_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
101
102 int ngbe_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
103
104 int ngbe_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
105
106 uint16_t ngbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
107                 uint16_t nb_pkts);
108
109 uint16_t ngbe_recv_pkts_bulk_alloc(void *rx_queue, struct rte_mbuf **rx_pkts,
110                                     uint16_t nb_pkts);
111
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);
116
117 uint16_t ngbe_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
118                 uint16_t nb_pkts);
119
120 void ngbe_set_ivar_map(struct ngbe_hw *hw, int8_t direction,
121                                uint8_t queue, uint8_t msix_vector);
122
123 int
124 ngbe_dev_link_update_share(struct rte_eth_dev *dev,
125                 int wait_to_complete);
126
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. */
130
131 /*
132  *  Default values for Rx/Tx configuration
133  */
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
138
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
143
144 const uint32_t *ngbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
145
146 #endif /* _NGBE_ETHDEV_H_ */