1a29281a891e262774897e077e7c747fbca7e81d
[dpdk.git] / drivers / net / txgbe / txgbe_ethdev.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015-2020
3  */
4
5 #ifndef _TXGBE_ETHDEV_H_
6 #define _TXGBE_ETHDEV_H_
7
8 #include "base/txgbe.h"
9
10 /* need update link, bit flag */
11 #define TXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
12 #define TXGBE_FLAG_MAILBOX          (uint32_t)(1 << 1)
13 #define TXGBE_FLAG_PHY_INTERRUPT    (uint32_t)(1 << 2)
14 #define TXGBE_FLAG_MACSEC           (uint32_t)(1 << 3)
15 #define TXGBE_FLAG_NEED_LINK_CONFIG (uint32_t)(1 << 4)
16
17 /*
18  * Defines that were not part of txgbe_type.h as they are not used by the
19  * FreeBSD driver.
20  */
21 #define TXGBE_VLAN_TAG_SIZE 4
22 #define TXGBE_HKEY_MAX_INDEX 10
23 /*Default value of Max Rx Queue*/
24 #define TXGBE_MAX_RX_QUEUE_NUM  128
25 #define TXGBE_VMDQ_DCB_NB_QUEUES     TXGBE_MAX_RX_QUEUE_NUM
26
27 #define TXGBE_QUEUE_ITR_INTERVAL_DEFAULT        500 /* 500us */
28
29 #define TXGBE_RSS_OFFLOAD_ALL ( \
30         ETH_RSS_IPV4 | \
31         ETH_RSS_NONFRAG_IPV4_TCP | \
32         ETH_RSS_NONFRAG_IPV4_UDP | \
33         ETH_RSS_IPV6 | \
34         ETH_RSS_NONFRAG_IPV6_TCP | \
35         ETH_RSS_NONFRAG_IPV6_UDP | \
36         ETH_RSS_IPV6_EX | \
37         ETH_RSS_IPV6_TCP_EX | \
38         ETH_RSS_IPV6_UDP_EX)
39
40 #define TXGBE_MISC_VEC_ID               RTE_INTR_VEC_ZERO_OFFSET
41 #define TXGBE_RX_VEC_START              RTE_INTR_VEC_RXTX_OFFSET
42
43 /* structure for interrupt relative data */
44 struct txgbe_interrupt {
45         uint32_t flags;
46         uint32_t mask_misc;
47         /* to save original mask during delayed handler */
48         uint32_t mask_misc_orig;
49         uint32_t mask[2];
50 };
51
52 struct txgbe_uta_info {
53         uint8_t  uc_filter_type;
54         uint16_t uta_in_use;
55         uint32_t uta_shadow[TXGBE_MAX_UTA];
56 };
57
58 /*
59  * Structure to store private data for each driver instance (for each port).
60  */
61 struct txgbe_adapter {
62         struct txgbe_hw             hw;
63         struct txgbe_interrupt      intr;
64         struct txgbe_uta_info       uta_info;
65         bool rx_bulk_alloc_allowed;
66 };
67
68 #define TXGBE_DEV_ADAPTER(dev) \
69         ((struct txgbe_adapter *)(dev)->data->dev_private)
70
71 #define TXGBE_DEV_HW(dev) \
72         (&((struct txgbe_adapter *)(dev)->data->dev_private)->hw)
73
74 #define TXGBE_DEV_INTR(dev) \
75         (&((struct txgbe_adapter *)(dev)->data->dev_private)->intr)
76
77 #define TXGBE_DEV_UTA_INFO(dev) \
78         (&((struct txgbe_adapter *)(dev)->data->dev_private)->uta_info)
79
80 /*
81  * RX/TX function prototypes
82  */
83 void txgbe_dev_free_queues(struct rte_eth_dev *dev);
84
85 void txgbe_dev_rx_queue_release(void *rxq);
86
87 void txgbe_dev_tx_queue_release(void *txq);
88
89 int  txgbe_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
90                 uint16_t nb_rx_desc, unsigned int socket_id,
91                 const struct rte_eth_rxconf *rx_conf,
92                 struct rte_mempool *mb_pool);
93
94 int  txgbe_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
95                 uint16_t nb_tx_desc, unsigned int socket_id,
96                 const struct rte_eth_txconf *tx_conf);
97
98 int txgbe_dev_rx_init(struct rte_eth_dev *dev);
99
100 void txgbe_dev_tx_init(struct rte_eth_dev *dev);
101
102 void txgbe_dev_save_rx_queue(struct txgbe_hw *hw, uint16_t rx_queue_id);
103 void txgbe_dev_store_rx_queue(struct txgbe_hw *hw, uint16_t rx_queue_id);
104 void txgbe_dev_save_tx_queue(struct txgbe_hw *hw, uint16_t tx_queue_id);
105 void txgbe_dev_store_tx_queue(struct txgbe_hw *hw, uint16_t tx_queue_id);
106
107 int txgbe_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
108
109 int txgbe_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
110
111 int txgbe_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
112
113 int txgbe_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
114
115 void txgbe_set_ivar_map(struct txgbe_hw *hw, int8_t direction,
116                                uint8_t queue, uint8_t msix_vector);
117
118 int
119 txgbe_dev_link_update_share(struct rte_eth_dev *dev,
120                 int wait_to_complete);
121
122 #define TXGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
123 #define TXGBE_LINK_UP_CHECK_TIMEOUT   1000 /* ms */
124 #define TXGBE_VMDQ_NUM_UC_MAC         4096 /* Maximum nb. of UC MAC addr. */
125
126 /*
127  *  Default values for RX/TX configuration
128  */
129 #define TXGBE_DEFAULT_RX_FREE_THRESH  32
130 #define TXGBE_DEFAULT_RX_PTHRESH      8
131 #define TXGBE_DEFAULT_RX_HTHRESH      8
132 #define TXGBE_DEFAULT_RX_WTHRESH      0
133
134 #define TXGBE_DEFAULT_TX_FREE_THRESH  32
135 #define TXGBE_DEFAULT_TX_PTHRESH      32
136 #define TXGBE_DEFAULT_TX_HTHRESH      0
137 #define TXGBE_DEFAULT_TX_WTHRESH      0
138
139 int txgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
140                                       struct rte_ether_addr *mc_addr_set,
141                                       uint32_t nb_mc_addr);
142 void txgbe_dev_setup_link_alarm_handler(void *param);
143
144 #endif /* _TXGBE_ETHDEV_H_ */