049d8fe71d5bb082e9be706ca9d4f5ae8ba86cf9
[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 /* 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_rx_queue_release(void *rxq);
71
72 void ngbe_dev_tx_queue_release(void *txq);
73
74 int  ngbe_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
75                 uint16_t nb_rx_desc, unsigned int socket_id,
76                 const struct rte_eth_rxconf *rx_conf,
77                 struct rte_mempool *mb_pool);
78
79 int  ngbe_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
80                 uint16_t nb_tx_desc, unsigned int socket_id,
81                 const struct rte_eth_txconf *tx_conf);
82
83 int ngbe_dev_rx_init(struct rte_eth_dev *dev);
84
85 void ngbe_dev_tx_init(struct rte_eth_dev *dev);
86
87 int ngbe_dev_rxtx_start(struct rte_eth_dev *dev);
88
89 void ngbe_dev_save_rx_queue(struct ngbe_hw *hw, uint16_t rx_queue_id);
90 void ngbe_dev_store_rx_queue(struct ngbe_hw *hw, uint16_t rx_queue_id);
91 void ngbe_dev_save_tx_queue(struct ngbe_hw *hw, uint16_t tx_queue_id);
92 void ngbe_dev_store_tx_queue(struct ngbe_hw *hw, uint16_t tx_queue_id);
93
94 int ngbe_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
95
96 int ngbe_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
97
98 int ngbe_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
99
100 int ngbe_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
101
102 void ngbe_set_ivar_map(struct ngbe_hw *hw, int8_t direction,
103                                uint8_t queue, uint8_t msix_vector);
104
105 int
106 ngbe_dev_link_update_share(struct rte_eth_dev *dev,
107                 int wait_to_complete);
108
109 #define NGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
110 #define NGBE_LINK_UP_CHECK_TIMEOUT   1000 /* ms */
111 #define NGBE_VMDQ_NUM_UC_MAC         4096 /* Maximum nb. of UC MAC addr. */
112
113 /*
114  *  Default values for Rx/Tx configuration
115  */
116 #define NGBE_DEFAULT_RX_FREE_THRESH  32
117 #define NGBE_DEFAULT_RX_PTHRESH      8
118 #define NGBE_DEFAULT_RX_HTHRESH      8
119 #define NGBE_DEFAULT_RX_WTHRESH      0
120
121 #define NGBE_DEFAULT_TX_FREE_THRESH  32
122 #define NGBE_DEFAULT_TX_PTHRESH      32
123 #define NGBE_DEFAULT_TX_HTHRESH      0
124 #define NGBE_DEFAULT_TX_WTHRESH      0
125
126 #endif /* _NGBE_ETHDEV_H_ */