Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2015-2020 Beijing WangXun Technology Co., Ltd.
3 : : * Copyright(c) 2010-2017 Intel Corporation
4 : : */
5 : :
6 : : #include <stdio.h>
7 : : #include <errno.h>
8 : : #include <stdint.h>
9 : : #include <string.h>
10 : : #include <rte_common.h>
11 : : #include <ethdev_pci.h>
12 : :
13 : : #include <rte_interrupts.h>
14 : : #include <rte_log.h>
15 : : #include <rte_debug.h>
16 : : #include <rte_pci.h>
17 : : #include <rte_memory.h>
18 : : #include <rte_eal.h>
19 : : #include <rte_alarm.h>
20 : : #include <rte_kvargs.h>
21 : :
22 : : #include "txgbe_logs.h"
23 : : #include "base/txgbe.h"
24 : : #include "txgbe_ethdev.h"
25 : : #include "txgbe_rxtx.h"
26 : : #include "txgbe_regs_group.h"
27 : :
28 : : static const struct reg_info txgbe_regs_general[] = {
29 : : {TXGBE_RST, 1, 1, "TXGBE_RST"},
30 : : {TXGBE_STAT, 1, 1, "TXGBE_STAT"},
31 : : {TXGBE_PORTCTL, 1, 1, "TXGBE_PORTCTL"},
32 : : {TXGBE_SDP, 1, 1, "TXGBE_SDP"},
33 : : {TXGBE_SDPCTL, 1, 1, "TXGBE_SDPCTL"},
34 : : {TXGBE_LEDCTL, 1, 1, "TXGBE_LEDCTL"},
35 : : {0, 0, 0, ""}
36 : : };
37 : :
38 : : static const struct reg_info txgbe_regs_nvm[] = {
39 : : {0, 0, 0, ""}
40 : : };
41 : :
42 : : static const struct reg_info txgbe_regs_interrupt[] = {
43 : : {0, 0, 0, ""}
44 : : };
45 : :
46 : : static const struct reg_info txgbe_regs_fctl_others[] = {
47 : : {0, 0, 0, ""}
48 : : };
49 : :
50 : : static const struct reg_info txgbe_regs_rxdma[] = {
51 : : {0, 0, 0, ""}
52 : : };
53 : :
54 : : static const struct reg_info txgbe_regs_rx[] = {
55 : : {0, 0, 0, ""}
56 : : };
57 : :
58 : : static struct reg_info txgbe_regs_tx[] = {
59 : : {0, 0, 0, ""}
60 : : };
61 : :
62 : : static const struct reg_info txgbe_regs_wakeup[] = {
63 : : {0, 0, 0, ""}
64 : : };
65 : :
66 : : static const struct reg_info txgbe_regs_dcb[] = {
67 : : {0, 0, 0, ""}
68 : : };
69 : :
70 : : static const struct reg_info txgbe_regs_mac[] = {
71 : : {0, 0, 0, ""}
72 : : };
73 : :
74 : : static const struct reg_info txgbe_regs_diagnostic[] = {
75 : : {0, 0, 0, ""},
76 : : };
77 : :
78 : : /* PF registers */
79 : : static const struct reg_info *txgbe_regs_others[] = {
80 : : txgbe_regs_general,
81 : : txgbe_regs_nvm,
82 : : txgbe_regs_interrupt,
83 : : txgbe_regs_fctl_others,
84 : : txgbe_regs_rxdma,
85 : : txgbe_regs_rx,
86 : : txgbe_regs_tx,
87 : : txgbe_regs_wakeup,
88 : : txgbe_regs_dcb,
89 : : txgbe_regs_mac,
90 : : txgbe_regs_diagnostic,
91 : : NULL};
92 : :
93 : : static int txgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev);
94 : : static int txgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev);
95 : : static int txgbe_dev_set_link_up(struct rte_eth_dev *dev);
96 : : static int txgbe_dev_set_link_down(struct rte_eth_dev *dev);
97 : : static int txgbe_dev_close(struct rte_eth_dev *dev);
98 : : static int txgbe_dev_link_update(struct rte_eth_dev *dev,
99 : : int wait_to_complete);
100 : : static int txgbe_dev_stats_reset(struct rte_eth_dev *dev);
101 : : static void txgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue);
102 : : static void txgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev,
103 : : uint16_t queue);
104 : :
105 : : static void txgbe_dev_link_status_print(struct rte_eth_dev *dev);
106 : : static int txgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev, uint8_t on);
107 : : static int txgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev);
108 : : static int txgbe_dev_misc_interrupt_setup(struct rte_eth_dev *dev);
109 : : static int txgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
110 : : static int txgbe_dev_interrupt_get_status(struct rte_eth_dev *dev,
111 : : struct rte_intr_handle *handle);
112 : : static int txgbe_dev_interrupt_action(struct rte_eth_dev *dev,
113 : : struct rte_intr_handle *handle);
114 : : static void txgbe_dev_interrupt_handler(void *param);
115 : : static void txgbe_dev_detect_sfp(void *param);
116 : : static void txgbe_dev_interrupt_delayed_handler(void *param);
117 : : static void txgbe_configure_msix(struct rte_eth_dev *dev);
118 : :
119 : : static int txgbe_filter_restore(struct rte_eth_dev *dev);
120 : : static void txgbe_l2_tunnel_conf(struct rte_eth_dev *dev);
121 : :
122 : : #define TXGBE_SET_HWSTRIP(h, q) do {\
123 : : uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
124 : : uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
125 : : (h)->bitmap[idx] |= 1 << bit;\
126 : : } while (0)
127 : :
128 : : #define TXGBE_CLEAR_HWSTRIP(h, q) do {\
129 : : uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
130 : : uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
131 : : (h)->bitmap[idx] &= ~(1 << bit);\
132 : : } while (0)
133 : :
134 : : #define TXGBE_GET_HWSTRIP(h, q, r) do {\
135 : : uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
136 : : uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
137 : : (r) = (h)->bitmap[idx] >> bit & 1;\
138 : : } while (0)
139 : :
140 : : /*
141 : : * The set of PCI devices this driver supports
142 : : */
143 : : static const struct rte_pci_id pci_id_txgbe_map[] = {
144 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, TXGBE_DEV_ID_SP1000) },
145 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, TXGBE_DEV_ID_WX1820) },
146 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, TXGBE_DEV_ID_AML) },
147 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, TXGBE_DEV_ID_AML5025) },
148 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, TXGBE_DEV_ID_AML5125) },
149 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, TXGBE_DEV_ID_AML5040) },
150 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, TXGBE_DEV_ID_AML5140) },
151 : : { .vendor_id = 0, /* sentinel */ },
152 : : };
153 : :
154 : : static const struct rte_eth_desc_lim rx_desc_lim = {
155 : : .nb_max = TXGBE_RING_DESC_MAX,
156 : : .nb_min = TXGBE_RING_DESC_MIN,
157 : : .nb_align = TXGBE_RXD_ALIGN,
158 : : };
159 : :
160 : : static const struct rte_eth_desc_lim tx_desc_lim = {
161 : : .nb_max = TXGBE_RING_DESC_MAX,
162 : : .nb_min = TXGBE_RING_DESC_MIN,
163 : : .nb_align = TXGBE_TXD_ALIGN,
164 : : .nb_seg_max = TXGBE_TX_MAX_SEG,
165 : : .nb_mtu_seg_max = TXGBE_TX_MAX_SEG,
166 : : };
167 : :
168 : : static const struct eth_dev_ops txgbe_eth_dev_ops;
169 : :
170 : : #define HW_XSTAT(m) {#m, offsetof(struct txgbe_hw_stats, m)}
171 : : #define HW_XSTAT_NAME(m, n) {n, offsetof(struct txgbe_hw_stats, m)}
172 : : static const struct rte_txgbe_xstats_name_off rte_txgbe_stats_strings[] = {
173 : : /* MNG RxTx */
174 : : HW_XSTAT(mng_bmc2host_packets),
175 : : HW_XSTAT(mng_host2bmc_packets),
176 : : /* Basic RxTx */
177 : : HW_XSTAT(rx_packets),
178 : : HW_XSTAT(tx_packets),
179 : : HW_XSTAT(rx_bytes),
180 : : HW_XSTAT(tx_bytes),
181 : : HW_XSTAT(rx_total_bytes),
182 : : HW_XSTAT(rx_total_packets),
183 : : HW_XSTAT(tx_total_packets),
184 : : HW_XSTAT(rx_total_missed_packets),
185 : : HW_XSTAT(rx_broadcast_packets),
186 : : HW_XSTAT(tx_broadcast_packets),
187 : : HW_XSTAT(rx_multicast_packets),
188 : : HW_XSTAT(tx_multicast_packets),
189 : : HW_XSTAT(rx_management_packets),
190 : : HW_XSTAT(tx_management_packets),
191 : : HW_XSTAT(rx_management_dropped),
192 : : HW_XSTAT(rx_dma_drop),
193 : :
194 : : /* Basic Error */
195 : : HW_XSTAT(rx_rdb_drop),
196 : : HW_XSTAT(rx_crc_errors),
197 : : HW_XSTAT(rx_illegal_byte_errors),
198 : : HW_XSTAT(rx_error_bytes),
199 : : HW_XSTAT(rx_mac_short_packet_dropped),
200 : : HW_XSTAT(rx_length_errors),
201 : : HW_XSTAT(rx_undersize_errors),
202 : : HW_XSTAT(rx_fragment_errors),
203 : : HW_XSTAT(rx_oversize_cnt),
204 : : HW_XSTAT(rx_jabber_errors),
205 : : HW_XSTAT(rx_l3_l4_xsum_error),
206 : : HW_XSTAT(mac_local_errors),
207 : : HW_XSTAT(mac_remote_errors),
208 : :
209 : : /* Flow Director */
210 : : HW_XSTAT(flow_director_added_filters),
211 : : HW_XSTAT(flow_director_removed_filters),
212 : : HW_XSTAT(flow_director_filter_add_errors),
213 : : HW_XSTAT(flow_director_filter_remove_errors),
214 : : HW_XSTAT(flow_director_matched_filters),
215 : : HW_XSTAT(flow_director_missed_filters),
216 : :
217 : : /* FCoE */
218 : : HW_XSTAT(rx_fcoe_crc_errors),
219 : : HW_XSTAT(rx_fcoe_mbuf_allocation_errors),
220 : : HW_XSTAT(rx_fcoe_dropped),
221 : : HW_XSTAT(rx_fcoe_packets),
222 : : HW_XSTAT(tx_fcoe_packets),
223 : : HW_XSTAT(rx_fcoe_bytes),
224 : : HW_XSTAT(tx_fcoe_bytes),
225 : : HW_XSTAT(rx_fcoe_no_ddp),
226 : : HW_XSTAT(rx_fcoe_no_ddp_ext_buff),
227 : :
228 : : /* MACSEC */
229 : : HW_XSTAT(tx_macsec_pkts_untagged),
230 : : HW_XSTAT(tx_macsec_pkts_encrypted),
231 : : HW_XSTAT(tx_macsec_pkts_protected),
232 : : HW_XSTAT(tx_macsec_octets_encrypted),
233 : : HW_XSTAT(tx_macsec_octets_protected),
234 : : HW_XSTAT(rx_macsec_pkts_untagged),
235 : : HW_XSTAT(rx_macsec_pkts_badtag),
236 : : HW_XSTAT(rx_macsec_pkts_nosci),
237 : : HW_XSTAT(rx_macsec_pkts_unknownsci),
238 : : HW_XSTAT(rx_macsec_octets_decrypted),
239 : : HW_XSTAT(rx_macsec_octets_validated),
240 : : HW_XSTAT(rx_macsec_sc_pkts_unchecked),
241 : : HW_XSTAT(rx_macsec_sc_pkts_delayed),
242 : : HW_XSTAT(rx_macsec_sc_pkts_late),
243 : : HW_XSTAT(rx_macsec_sa_pkts_ok),
244 : : HW_XSTAT(rx_macsec_sa_pkts_invalid),
245 : : HW_XSTAT(rx_macsec_sa_pkts_notvalid),
246 : : HW_XSTAT(rx_macsec_sa_pkts_unusedsa),
247 : : HW_XSTAT(rx_macsec_sa_pkts_notusingsa),
248 : :
249 : : /* MAC RxTx */
250 : : HW_XSTAT(rx_size_64_packets),
251 : : HW_XSTAT(rx_size_65_to_127_packets),
252 : : HW_XSTAT(rx_size_128_to_255_packets),
253 : : HW_XSTAT(rx_size_256_to_511_packets),
254 : : HW_XSTAT(rx_size_512_to_1023_packets),
255 : : HW_XSTAT(rx_size_1024_to_max_packets),
256 : : HW_XSTAT(tx_size_64_packets),
257 : : HW_XSTAT(tx_size_65_to_127_packets),
258 : : HW_XSTAT(tx_size_128_to_255_packets),
259 : : HW_XSTAT(tx_size_256_to_511_packets),
260 : : HW_XSTAT(tx_size_512_to_1023_packets),
261 : : HW_XSTAT(tx_size_1024_to_max_packets),
262 : :
263 : : /* Flow Control */
264 : : HW_XSTAT_NAME(tx_xon_packets, "tx_flow_control_xon_packets"),
265 : : HW_XSTAT_NAME(rx_xon_packets, "rx_flow_control_xon_packets"),
266 : : HW_XSTAT_NAME(tx_xoff_packets, "tx_flow_control_xoff_packets"),
267 : : HW_XSTAT_NAME(rx_xoff_packets, "rx_flow_control_xoff_packets"),
268 : : };
269 : :
270 : : #define TXGBE_NB_HW_STATS (sizeof(rte_txgbe_stats_strings) / \
271 : : sizeof(rte_txgbe_stats_strings[0]))
272 : :
273 : : /* Per-priority statistics */
274 : : #define UP_XSTAT(m) {#m, offsetof(struct txgbe_hw_stats, up[0].m)}
275 : : static const struct rte_txgbe_xstats_name_off rte_txgbe_up_strings[] = {
276 : : UP_XSTAT(rx_up_packets),
277 : : UP_XSTAT(tx_up_packets),
278 : : UP_XSTAT(rx_up_bytes),
279 : : UP_XSTAT(tx_up_bytes),
280 : : UP_XSTAT(rx_up_drop_packets),
281 : :
282 : : UP_XSTAT(tx_up_xon_packets),
283 : : UP_XSTAT(rx_up_xon_packets),
284 : : UP_XSTAT(tx_up_xoff_packets),
285 : : UP_XSTAT(rx_up_xoff_packets),
286 : : UP_XSTAT(rx_up_dropped),
287 : : UP_XSTAT(rx_up_mbuf_alloc_errors),
288 : : UP_XSTAT(tx_up_xon2off_packets),
289 : : };
290 : :
291 : : #define TXGBE_NB_UP_STATS (sizeof(rte_txgbe_up_strings) / \
292 : : sizeof(rte_txgbe_up_strings[0]))
293 : :
294 : : /* Per-queue statistics */
295 : : #define QP_XSTAT(m) {#m, offsetof(struct txgbe_hw_stats, qp[0].m)}
296 : : static const struct rte_txgbe_xstats_name_off rte_txgbe_qp_strings[] = {
297 : : QP_XSTAT(rx_qp_packets),
298 : : QP_XSTAT(tx_qp_packets),
299 : : QP_XSTAT(rx_qp_bytes),
300 : : QP_XSTAT(tx_qp_bytes),
301 : : QP_XSTAT(rx_qp_mc_packets),
302 : : };
303 : :
304 : : #define TXGBE_NB_QP_STATS (sizeof(rte_txgbe_qp_strings) / \
305 : : sizeof(rte_txgbe_qp_strings[0]))
306 : :
307 : : static inline int
308 : : txgbe_is_sfp(struct txgbe_hw *hw)
309 : : {
310 [ # # # # ]: 0 : switch (hw->phy.type) {
311 : : case txgbe_phy_sfp_avago:
312 : : case txgbe_phy_sfp_ftl:
313 : : case txgbe_phy_sfp_intel:
314 : : case txgbe_phy_sfp_unknown:
315 : : case txgbe_phy_sfp_tyco_passive:
316 : : case txgbe_phy_sfp_unknown_passive:
317 : : return 1;
318 : : default:
319 : : return 0;
320 : : }
321 : : }
322 : :
323 : : static inline int32_t
324 : 0 : txgbe_pf_reset_hw(struct txgbe_hw *hw)
325 : : {
326 : : uint32_t ctrl_ext;
327 : : int32_t status;
328 : :
329 : 0 : status = hw->mac.reset_hw(hw);
330 : :
331 : : ctrl_ext = rd32(hw, TXGBE_PORTCTL);
332 : : /* let hardware know driver is loaded */
333 : : ctrl_ext |= TXGBE_PORTCTL_DRVLOAD;
334 : : /* Set PF Reset Done bit so PF/VF Mail Ops can work */
335 : 0 : ctrl_ext |= TXGBE_PORTCTL_RSTDONE;
336 : : wr32(hw, TXGBE_PORTCTL, ctrl_ext);
337 : : txgbe_flush(hw);
338 : :
339 [ # # ]: 0 : if (status == TXGBE_ERR_SFP_NOT_PRESENT)
340 : : status = 0;
341 : 0 : return status;
342 : : }
343 : :
344 : : static inline void
345 : 0 : txgbe_enable_intr(struct rte_eth_dev *dev)
346 : : {
347 : 0 : struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
348 : : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
349 : : uint32_t gpie;
350 : :
351 : 0 : wr32(hw, TXGBE_IENMISC, intr->mask_misc);
352 : : wr32(hw, TXGBE_IMC(0), TXGBE_IMC_MASK);
353 : : wr32(hw, TXGBE_IMC(1), TXGBE_IMC_MASK);
354 : : txgbe_flush(hw);
355 : :
356 : : /* To avoid gpio intr lost, enable pcie intr first. Then enable gpio intr. */
357 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml) {
358 : : gpie = rd32(hw, TXGBE_GPIOINTEN);
359 : 0 : gpie |= TXGBE_GPIOBIT_2 | TXGBE_GPIOBIT_3 | TXGBE_GPIOBIT_6;
360 : : wr32(hw, TXGBE_GPIOINTEN, gpie);
361 : :
362 : : gpie = rd32(hw, TXGBE_GPIOINTTYPE);
363 : 0 : gpie |= TXGBE_GPIOBIT_2 | TXGBE_GPIOBIT_3 | TXGBE_GPIOBIT_6;
364 : : wr32(hw, TXGBE_GPIOINTTYPE, gpie);
365 : : }
366 : :
367 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml40) {
368 : : gpie = rd32(hw, TXGBE_GPIOINTEN);
369 : 0 : gpie |= TXGBE_GPIOBIT_4;
370 : : wr32(hw, TXGBE_GPIOINTEN, gpie);
371 : :
372 : : gpie = rd32(hw, TXGBE_GPIOINTTYPE);
373 : 0 : gpie |= TXGBE_GPIOBIT_4;
374 : : wr32(hw, TXGBE_GPIOINTTYPE, gpie);
375 : : }
376 : 0 : }
377 : :
378 : : static void
379 : 0 : txgbe_disable_intr(struct txgbe_hw *hw)
380 : : {
381 : 0 : PMD_INIT_FUNC_TRACE();
382 : :
383 : : wr32(hw, TXGBE_IENMISC, ~BIT_MASK32);
384 : : wr32(hw, TXGBE_IMS(0), TXGBE_IMC_MASK);
385 : : wr32(hw, TXGBE_IMS(1), TXGBE_IMC_MASK);
386 : : txgbe_flush(hw);
387 : 0 : }
388 : :
389 : : static void
390 : 0 : txgbe_dcb_init(struct txgbe_hw *hw, struct txgbe_dcb_config *dcb_config)
391 : : {
392 : : int i;
393 : : u8 bwgp;
394 : : struct txgbe_dcb_tc_config *tc;
395 : :
396 : : UNREFERENCED_PARAMETER(hw);
397 : :
398 : 0 : dcb_config->num_tcs.pg_tcs = TXGBE_DCB_TC_MAX;
399 : 0 : dcb_config->num_tcs.pfc_tcs = TXGBE_DCB_TC_MAX;
400 : : bwgp = (u8)(100 / TXGBE_DCB_TC_MAX);
401 [ # # ]: 0 : for (i = 0; i < TXGBE_DCB_TC_MAX; i++) {
402 : : tc = &dcb_config->tc_config[i];
403 : 0 : tc->path[TXGBE_DCB_TX_CONFIG].bwg_id = i;
404 : 0 : tc->path[TXGBE_DCB_TX_CONFIG].bwg_percent = bwgp + (i & 1);
405 : 0 : tc->path[TXGBE_DCB_RX_CONFIG].bwg_id = i;
406 : 0 : tc->path[TXGBE_DCB_RX_CONFIG].bwg_percent = bwgp + (i & 1);
407 : 0 : tc->pfc = txgbe_dcb_pfc_disabled;
408 : : }
409 : :
410 : : /* Initialize default user to priority mapping, UPx->TC0 */
411 : : tc = &dcb_config->tc_config[0];
412 : 0 : tc->path[TXGBE_DCB_TX_CONFIG].up_to_tc_bitmap = 0xFF;
413 : 0 : tc->path[TXGBE_DCB_RX_CONFIG].up_to_tc_bitmap = 0xFF;
414 [ # # ]: 0 : for (i = 0; i < TXGBE_DCB_BWG_MAX; i++) {
415 : 0 : dcb_config->bw_percentage[i][TXGBE_DCB_TX_CONFIG] = 100;
416 : 0 : dcb_config->bw_percentage[i][TXGBE_DCB_RX_CONFIG] = 100;
417 : : }
418 : 0 : dcb_config->rx_pba_cfg = txgbe_dcb_pba_equal;
419 : 0 : dcb_config->pfc_mode_enable = false;
420 : 0 : dcb_config->vt_mode = true;
421 : 0 : dcb_config->round_robin_enable = false;
422 : : /* support all DCB capabilities */
423 : 0 : dcb_config->support.capabilities = 0xFF;
424 : 0 : }
425 : :
426 : : /*
427 : : * Ensure that all locks are released before first NVM or PHY access
428 : : */
429 : : static void
430 : 0 : txgbe_swfw_lock_reset(struct txgbe_hw *hw)
431 : : {
432 : : uint16_t mask;
433 : :
434 : : /*
435 : : * These ones are more tricky since they are common to all ports; but
436 : : * swfw_sync retries last long enough (1s) to be almost sure that if
437 : : * lock can not be taken it is due to an improper lock of the
438 : : * semaphore.
439 : : */
440 : : mask = TXGBE_MNGSEM_SWPHY |
441 : : TXGBE_MNGSEM_SWMBX |
442 : : TXGBE_MNGSEM_SWFLASH;
443 [ # # ]: 0 : if (hw->mac.acquire_swfw_sync(hw, mask) < 0)
444 : 0 : PMD_DRV_LOG(DEBUG, "SWFW common locks released");
445 : :
446 : 0 : hw->mac.release_swfw_sync(hw, mask);
447 : 0 : }
448 : :
449 : : static int
450 : 0 : txgbe_handle_devarg(__rte_unused const char *key, const char *value,
451 : : void *extra_args)
452 : : {
453 : : uint16_t *arg = extra_args;
454 : : char *endp;
455 : : unsigned long num;
456 : :
457 [ # # ]: 0 : if (value == NULL || extra_args == NULL)
458 : : return -EINVAL;
459 : :
460 : 0 : errno = 0;
461 : 0 : num = strtoul(value, &endp, 10);
462 [ # # # # ]: 0 : if (*value == '\0' || *endp != '\0')
463 : : return -EINVAL;
464 : :
465 [ # # # # ]: 0 : if (num > UINT16_MAX || errno == ERANGE)
466 : : return -ERANGE;
467 : 0 : *arg = (uint16_t)num;
468 : 0 : return 0;
469 : : }
470 : :
471 : : static void
472 : 0 : txgbe_parse_devargs(struct rte_eth_dev *dev)
473 : : {
474 : 0 : struct rte_eth_fdir_conf *fdir_conf = TXGBE_DEV_FDIR_CONF(dev);
475 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
476 : 0 : struct rte_devargs *devargs = pci_dev->device.devargs;
477 : : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
478 : : struct rte_kvargs *kvlist;
479 : 0 : u16 auto_neg = 1;
480 : 0 : u16 poll = 0;
481 : 0 : u16 present = 0;
482 : 0 : u16 sgmii = 0;
483 : 0 : u16 ffe_set = 0;
484 : 0 : u16 ffe_main = 27;
485 : 0 : u16 ffe_pre = 8;
486 : 0 : u16 ffe_post = 44;
487 : : /* FDIR args */
488 : 0 : u16 pballoc = 0;
489 : 0 : u16 drop_queue = 127;
490 : : /* New devargs for amberlite config */
491 : 0 : u16 tx_headwb = 1;
492 : 0 : u16 tx_headwb_size = 16;
493 : 0 : u16 rx_desc_merge = 1;
494 : :
495 [ # # ]: 0 : if (devargs == NULL)
496 : 0 : goto null;
497 : :
498 : 0 : kvlist = rte_kvargs_parse(devargs->args, txgbe_valid_arguments);
499 [ # # ]: 0 : if (kvlist == NULL)
500 : 0 : goto null;
501 : :
502 : 0 : rte_kvargs_process(kvlist, TXGBE_DEVARG_BP_AUTO,
503 : : &txgbe_handle_devarg, &auto_neg);
504 : 0 : rte_kvargs_process(kvlist, TXGBE_DEVARG_KR_POLL,
505 : : &txgbe_handle_devarg, &poll);
506 : 0 : rte_kvargs_process(kvlist, TXGBE_DEVARG_KR_PRESENT,
507 : : &txgbe_handle_devarg, &present);
508 : 0 : rte_kvargs_process(kvlist, TXGBE_DEVARG_KX_SGMII,
509 : : &txgbe_handle_devarg, &sgmii);
510 : 0 : rte_kvargs_process(kvlist, TXGBE_DEVARG_FFE_SET,
511 : : &txgbe_handle_devarg, &ffe_set);
512 : 0 : rte_kvargs_process(kvlist, TXGBE_DEVARG_FFE_MAIN,
513 : : &txgbe_handle_devarg, &ffe_main);
514 : 0 : rte_kvargs_process(kvlist, TXGBE_DEVARG_FFE_PRE,
515 : : &txgbe_handle_devarg, &ffe_pre);
516 : 0 : rte_kvargs_process(kvlist, TXGBE_DEVARG_FFE_POST,
517 : : &txgbe_handle_devarg, &ffe_post);
518 : 0 : rte_kvargs_process(kvlist, TXGBE_DEVARG_FDIR_PBALLOC,
519 : : &txgbe_handle_devarg, &pballoc);
520 : 0 : rte_kvargs_process(kvlist, TXGBE_DEVARG_FDIR_DROP_QUEUE,
521 : : &txgbe_handle_devarg, &drop_queue);
522 : 0 : rte_kvargs_process(kvlist, TXGBE_DEVARG_TX_HEAD_WB,
523 : : &txgbe_handle_devarg, &tx_headwb);
524 : 0 : rte_kvargs_process(kvlist, TXGBE_DEVARG_TX_HEAD_WB_SIZE,
525 : : &txgbe_handle_devarg, &tx_headwb_size);
526 : 0 : rte_kvargs_process(kvlist, TXGBE_DEVARG_RX_DESC_MERGE,
527 : : &txgbe_handle_devarg, &rx_desc_merge);
528 : 0 : rte_kvargs_free(kvlist);
529 : :
530 : 0 : null:
531 : 0 : hw->devarg.auto_neg = auto_neg;
532 : 0 : hw->devarg.poll = poll;
533 : 0 : hw->devarg.present = present;
534 : 0 : hw->devarg.sgmii = sgmii;
535 : 0 : hw->devarg.tx_headwb = tx_headwb;
536 : 0 : hw->devarg.tx_headwb_size = tx_headwb_size;
537 : 0 : hw->devarg.rx_desc_merge = rx_desc_merge;
538 : 0 : hw->phy.ffe_set = ffe_set;
539 : 0 : hw->phy.ffe_main = ffe_main;
540 : 0 : hw->phy.ffe_pre = ffe_pre;
541 : 0 : hw->phy.ffe_post = ffe_post;
542 : :
543 : 0 : fdir_conf->pballoc = pballoc;
544 : 0 : fdir_conf->drop_queue = drop_queue;
545 : 0 : }
546 : :
547 : : static void
548 : : txgbe_override_mac_ops(struct txgbe_hw *hw)
549 : : {
550 : : struct txgbe_mac_info *mac = &hw->mac;
551 : :
552 [ # # ]: 0 : if (hw->phy.multispeed_fiber)
553 : 0 : mac->setup_mac_link = txgbe_setup_mac_link_aml;
554 : : else
555 : 0 : mac->setup_link = txgbe_setup_mac_link_aml;
556 : : }
557 : :
558 : : static int
559 : 0 : eth_txgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
560 : : {
561 : 0 : struct txgbe_adapter *ad = eth_dev->data->dev_private;
562 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(eth_dev, *pci_dev);
563 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(eth_dev);
564 : 0 : struct txgbe_vfta *shadow_vfta = TXGBE_DEV_VFTA(eth_dev);
565 : 0 : struct txgbe_hwstrip *hwstrip = TXGBE_DEV_HWSTRIP(eth_dev);
566 : 0 : struct txgbe_dcb_config *dcb_config = TXGBE_DEV_DCB_CONFIG(eth_dev);
567 : 0 : struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(eth_dev);
568 : 0 : struct txgbe_bw_conf *bw_conf = TXGBE_DEV_BW_CONF(eth_dev);
569 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
570 : : const struct rte_memzone *mz;
571 : : uint32_t ctrl_ext;
572 : : uint16_t csum;
573 : : int err, i, ret;
574 : :
575 : 0 : PMD_INIT_FUNC_TRACE();
576 : :
577 : 0 : eth_dev->dev_ops = &txgbe_eth_dev_ops;
578 : 0 : eth_dev->rx_queue_count = txgbe_dev_rx_queue_count;
579 : 0 : eth_dev->rx_descriptor_status = txgbe_dev_rx_descriptor_status;
580 : 0 : eth_dev->tx_descriptor_status = txgbe_dev_tx_descriptor_status;
581 : 0 : eth_dev->rx_pkt_burst = &txgbe_recv_pkts;
582 : 0 : eth_dev->tx_pkt_burst = &txgbe_xmit_pkts;
583 : 0 : eth_dev->tx_pkt_prepare = &txgbe_prep_pkts;
584 : :
585 : : /*
586 : : * For secondary processes, we don't initialise any further as primary
587 : : * has already done this work. Only check we don't need a different
588 : : * RX and TX function.
589 : : */
590 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
591 : : struct txgbe_tx_queue *txq;
592 : : /* TX queue function in primary, set by last queue initialized
593 : : * Tx queue may not initialized by primary process
594 : : */
595 [ # # ]: 0 : if (eth_dev->data->tx_queues) {
596 : 0 : uint16_t nb_tx_queues = eth_dev->data->nb_tx_queues;
597 : 0 : txq = eth_dev->data->tx_queues[nb_tx_queues - 1];
598 : 0 : txgbe_set_tx_function(eth_dev, txq);
599 : : } else {
600 : : /* Use default TX function if we get here */
601 : 0 : PMD_INIT_LOG(NOTICE, "No TX queues configured yet. "
602 : : "Using default TX function.");
603 : : }
604 : :
605 : 0 : txgbe_set_rx_function(eth_dev);
606 : :
607 : 0 : return 0;
608 : : }
609 : :
610 : 0 : rte_atomic_store_explicit(&ad->link_thread_running, 0, rte_memory_order_seq_cst);
611 : 0 : rte_eth_copy_pci_info(eth_dev, pci_dev);
612 : :
613 : 0 : hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
614 : :
615 : : /* Vendor and Device ID need to be set before init of shared code */
616 : 0 : hw->back = pci_dev;
617 : 0 : hw->dev_back = eth_dev;
618 : 0 : hw->port_id = eth_dev->data->port_id;
619 : 0 : hw->device_id = pci_dev->id.device_id;
620 : 0 : hw->vendor_id = pci_dev->id.vendor_id;
621 [ # # ]: 0 : if (pci_dev->id.subsystem_vendor_id == PCI_VENDOR_ID_WANGXUN) {
622 : 0 : hw->subsystem_device_id = pci_dev->id.subsystem_device_id;
623 : : } else {
624 : 0 : u32 ssid = 0;
625 : :
626 : 0 : err = txgbe_flash_read_dword(hw, 0xFFFDC, &ssid);
627 [ # # ]: 0 : if (err) {
628 : 0 : PMD_INIT_LOG(ERR,
629 : : "Read of internal subsystem device id failed");
630 : 0 : return -ENODEV;
631 : : }
632 : 0 : hw->subsystem_device_id = (u16)ssid >> 8 | (u16)ssid << 8;
633 : : }
634 : 0 : hw->allow_unsupported_sfp = 1;
635 : :
636 : : /* Reserve memory for interrupt status block */
637 : 0 : mz = rte_eth_dma_zone_reserve(eth_dev, "txgbe_driver", -1,
638 : : 16, TXGBE_ALIGN, SOCKET_ID_ANY);
639 [ # # ]: 0 : if (mz == NULL)
640 : : return -ENOMEM;
641 : :
642 : 0 : hw->isb_dma = TMZ_PADDR(mz);
643 : 0 : hw->isb_mem = TMZ_VADDR(mz);
644 : :
645 : 0 : txgbe_parse_devargs(eth_dev);
646 : : /* Initialize the shared code (base driver) */
647 : 0 : err = txgbe_init_shared_code(hw);
648 [ # # ]: 0 : if (err != 0) {
649 : 0 : PMD_INIT_LOG(ERR, "Shared code init failed: %d", err);
650 : 0 : return -EIO;
651 : : }
652 : :
653 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml)
654 : : txgbe_override_mac_ops(hw);
655 : :
656 : : /* Unlock any pending hardware semaphore */
657 : 0 : txgbe_swfw_lock_reset(hw);
658 : :
659 : : #ifdef RTE_LIB_SECURITY
660 : : /* Initialize security_ctx only for primary process*/
661 [ # # ]: 0 : if (txgbe_ipsec_ctx_create(eth_dev))
662 : : return -ENOMEM;
663 : : #endif
664 : :
665 : : /* Initialize DCB configuration*/
666 : : memset(dcb_config, 0, sizeof(struct txgbe_dcb_config));
667 : 0 : txgbe_dcb_init(hw, dcb_config);
668 : :
669 : : /* Get Hardware Flow Control setting */
670 : 0 : hw->fc.requested_mode = txgbe_fc_full;
671 : 0 : hw->fc.current_mode = txgbe_fc_full;
672 : 0 : hw->fc.pause_time = TXGBE_FC_PAUSE_TIME;
673 [ # # ]: 0 : for (i = 0; i < TXGBE_DCB_TC_MAX; i++) {
674 : 0 : hw->fc.low_water[i] = TXGBE_FC_XON_LOTH;
675 : 0 : hw->fc.high_water[i] = TXGBE_FC_XOFF_HITH;
676 : : }
677 : 0 : hw->fc.send_xon = 1;
678 : :
679 : 0 : err = hw->rom.init_params(hw);
680 [ # # ]: 0 : if (err != 0) {
681 : 0 : PMD_INIT_LOG(ERR, "The EEPROM init failed: %d", err);
682 : 0 : return -EIO;
683 : : }
684 : :
685 : : /* Make sure we have a good EEPROM before we read from it */
686 : 0 : err = hw->rom.validate_checksum(hw, &csum);
687 [ # # ]: 0 : if (err != 0) {
688 : 0 : PMD_INIT_LOG(ERR, "The EEPROM checksum is not valid: %d", err);
689 : 0 : return -EIO;
690 : : }
691 : :
692 : 0 : err = hw->mac.init_hw(hw);
693 : :
694 : : /*
695 : : * Devices with copper phys will fail to initialise if txgbe_init_hw()
696 : : * is called too soon after the kernel driver unbinding/binding occurs.
697 : : * The failure occurs in txgbe_identify_phy() for all devices,
698 : : * but for non-copper devies, txgbe_identify_sfp_module() is
699 : : * also called. See txgbe_identify_phy(). The reason for the
700 : : * failure is not known, and only occuts when virtualisation features
701 : : * are disabled in the bios. A delay of 200ms was found to be enough by
702 : : * trial-and-error, and is doubled to be safe.
703 : : */
704 [ # # # # ]: 0 : if (err && hw->phy.media_type == txgbe_media_type_copper) {
705 : : rte_delay_ms(200);
706 : 0 : err = hw->mac.init_hw(hw);
707 : : }
708 : :
709 [ # # ]: 0 : if (err == TXGBE_ERR_SFP_NOT_PRESENT)
710 : : err = 0;
711 : :
712 [ # # ]: 0 : if (err == TXGBE_ERR_EEPROM_VERSION) {
713 : 0 : PMD_INIT_LOG(ERR, "This device is a pre-production adapter/"
714 : : "LOM. Please be aware there may be issues associated "
715 : : "with your hardware.");
716 : 0 : PMD_INIT_LOG(ERR, "If you are experiencing problems "
717 : : "please contact your hardware representative "
718 : : "who provided you with this hardware.");
719 [ # # ]: 0 : } else if (err == TXGBE_ERR_SFP_NOT_SUPPORTED) {
720 : 0 : PMD_INIT_LOG(ERR, "Unsupported SFP+ Module");
721 : : }
722 [ # # ]: 0 : if (err) {
723 : 0 : PMD_INIT_LOG(ERR, "Hardware Initialization Failure: %d", err);
724 : 0 : return -EIO;
725 : : }
726 : :
727 : : /* Reset the hw statistics */
728 : 0 : txgbe_dev_stats_reset(eth_dev);
729 : :
730 : : /* disable interrupt */
731 : 0 : txgbe_disable_intr(hw);
732 : :
733 : : /* Allocate memory for storing MAC addresses */
734 : 0 : eth_dev->data->mac_addrs = rte_zmalloc("txgbe", RTE_ETHER_ADDR_LEN *
735 : 0 : hw->mac.num_rar_entries, 0);
736 [ # # ]: 0 : if (eth_dev->data->mac_addrs == NULL) {
737 : 0 : PMD_INIT_LOG(ERR,
738 : : "Failed to allocate %u bytes needed to store "
739 : : "MAC addresses",
740 : : RTE_ETHER_ADDR_LEN * hw->mac.num_rar_entries);
741 : 0 : return -ENOMEM;
742 : : }
743 : :
744 : : /* Copy the permanent MAC address */
745 : : rte_ether_addr_copy((struct rte_ether_addr *)hw->mac.perm_addr,
746 : : ð_dev->data->mac_addrs[0]);
747 : :
748 : : /* Allocate memory for storing hash filter MAC addresses */
749 : 0 : eth_dev->data->hash_mac_addrs = rte_zmalloc("txgbe",
750 : : RTE_ETHER_ADDR_LEN * TXGBE_VMDQ_NUM_UC_MAC, 0);
751 [ # # ]: 0 : if (eth_dev->data->hash_mac_addrs == NULL) {
752 : 0 : PMD_INIT_LOG(ERR,
753 : : "Failed to allocate %d bytes needed to store MAC addresses",
754 : : RTE_ETHER_ADDR_LEN * TXGBE_VMDQ_NUM_UC_MAC);
755 : 0 : rte_free(eth_dev->data->mac_addrs);
756 : 0 : eth_dev->data->mac_addrs = NULL;
757 : 0 : return -ENOMEM;
758 : : }
759 : :
760 : : /* initialize the vfta */
761 : : memset(shadow_vfta, 0, sizeof(*shadow_vfta));
762 : :
763 : : /* initialize the hw strip bitmap*/
764 : : memset(hwstrip, 0, sizeof(*hwstrip));
765 : :
766 : : /* initialize PF if max_vfs not zero */
767 : 0 : ret = txgbe_pf_host_init(eth_dev);
768 [ # # ]: 0 : if (ret) {
769 : 0 : rte_free(eth_dev->data->mac_addrs);
770 : 0 : eth_dev->data->mac_addrs = NULL;
771 : 0 : rte_free(eth_dev->data->hash_mac_addrs);
772 : 0 : eth_dev->data->hash_mac_addrs = NULL;
773 : 0 : return ret;
774 : : }
775 : :
776 : : ctrl_ext = rd32(hw, TXGBE_PORTCTL);
777 : : /* let hardware know driver is loaded */
778 : : ctrl_ext |= TXGBE_PORTCTL_DRVLOAD;
779 : : /* Set PF Reset Done bit so PF/VF Mail Ops can work */
780 : 0 : ctrl_ext |= TXGBE_PORTCTL_RSTDONE;
781 : : wr32(hw, TXGBE_PORTCTL, ctrl_ext);
782 : : txgbe_flush(hw);
783 : :
784 [ # # ]: 0 : if (txgbe_is_sfp(hw) && hw->phy.sfp_type != txgbe_sfp_type_not_present)
785 : 0 : PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d, SFP+: %d",
786 : : (int)hw->mac.type, (int)hw->phy.type,
787 : : (int)hw->phy.sfp_type);
788 : : else
789 : 0 : PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d",
790 : : (int)hw->mac.type, (int)hw->phy.type);
791 : :
792 : 0 : PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x",
793 : : eth_dev->data->port_id, pci_dev->id.vendor_id,
794 : : pci_dev->id.device_id);
795 : :
796 : 0 : rte_intr_callback_register(intr_handle,
797 : : txgbe_dev_interrupt_handler, eth_dev);
798 : :
799 : : /* enable uio/vfio intr/eventfd mapping */
800 : 0 : rte_intr_enable(intr_handle);
801 : :
802 : : /* enable support intr */
803 : 0 : txgbe_enable_intr(eth_dev);
804 : :
805 : : /* initialize filter info */
806 : : memset(filter_info, 0,
807 : : sizeof(struct txgbe_filter_info));
808 : :
809 : : /* initialize 5tuple filter list */
810 : 0 : TAILQ_INIT(&filter_info->fivetuple_list);
811 : :
812 : : /* initialize flow director filter list & hash */
813 : 0 : txgbe_fdir_filter_init(eth_dev);
814 : :
815 : : /* initialize l2 tunnel filter list & hash */
816 : 0 : txgbe_l2_tn_filter_init(eth_dev);
817 : :
818 : : /* initialize flow filter lists */
819 : 0 : txgbe_filterlist_init();
820 : :
821 : : /* initialize bandwidth configuration info */
822 : : memset(bw_conf, 0, sizeof(struct txgbe_bw_conf));
823 : :
824 : : /* initialize Traffic Manager configuration */
825 : 0 : txgbe_tm_conf_init(eth_dev);
826 : :
827 : 0 : return 0;
828 : : }
829 : :
830 : : static int
831 : 0 : eth_txgbe_dev_uninit(struct rte_eth_dev *eth_dev)
832 : : {
833 : 0 : PMD_INIT_FUNC_TRACE();
834 : :
835 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY)
836 : : return 0;
837 : :
838 : 0 : txgbe_dev_close(eth_dev);
839 : :
840 : 0 : return 0;
841 : : }
842 : :
843 : 0 : int txgbe_ntuple_filter_uninit(struct rte_eth_dev *eth_dev)
844 : : {
845 : 0 : struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(eth_dev);
846 : : struct txgbe_5tuple_filter *p_5tuple;
847 : :
848 [ # # ]: 0 : while ((p_5tuple = TAILQ_FIRST(&filter_info->fivetuple_list))) {
849 [ # # ]: 0 : TAILQ_REMOVE(&filter_info->fivetuple_list,
850 : : p_5tuple,
851 : : entries);
852 : 0 : rte_free(p_5tuple);
853 : : }
854 : 0 : memset(filter_info->fivetuple_mask, 0,
855 : : sizeof(uint32_t) * TXGBE_5TUPLE_ARRAY_SIZE);
856 : 0 : filter_info->ntuple_is_full = false;
857 : :
858 : 0 : return 0;
859 : : }
860 : :
861 : 0 : int txgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev)
862 : : {
863 : 0 : struct txgbe_hw_fdir_info *fdir_info = TXGBE_DEV_FDIR(eth_dev);
864 : : struct txgbe_fdir_filter *fdir_filter;
865 : :
866 : 0 : rte_free(fdir_info->hash_map);
867 : 0 : rte_hash_free(fdir_info->hash_handle);
868 : :
869 [ # # ]: 0 : while ((fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list))) {
870 [ # # ]: 0 : TAILQ_REMOVE(&fdir_info->fdir_list,
871 : : fdir_filter,
872 : : entries);
873 : 0 : rte_free(fdir_filter);
874 : : }
875 : :
876 : 0 : return 0;
877 : : }
878 : :
879 : 0 : static int txgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev)
880 : : {
881 : 0 : struct txgbe_l2_tn_info *l2_tn_info = TXGBE_DEV_L2_TN(eth_dev);
882 : : struct txgbe_l2_tn_filter *l2_tn_filter;
883 : :
884 : 0 : rte_free(l2_tn_info->hash_map);
885 : 0 : rte_hash_free(l2_tn_info->hash_handle);
886 : :
887 [ # # ]: 0 : while ((l2_tn_filter = TAILQ_FIRST(&l2_tn_info->l2_tn_list))) {
888 [ # # ]: 0 : TAILQ_REMOVE(&l2_tn_info->l2_tn_list,
889 : : l2_tn_filter,
890 : : entries);
891 : 0 : rte_free(l2_tn_filter);
892 : : }
893 : :
894 : 0 : return 0;
895 : : }
896 : :
897 : 0 : int txgbe_fdir_filter_init(struct rte_eth_dev *eth_dev)
898 : : {
899 : 0 : struct rte_eth_fdir_conf *fdir_conf = TXGBE_DEV_FDIR_CONF(eth_dev);
900 : : struct txgbe_hw_fdir_info *fdir_info = TXGBE_DEV_FDIR(eth_dev);
901 : : char fdir_hash_name[RTE_HASH_NAMESIZE];
902 : 0 : u16 max_fdir_num = (1024 << (fdir_conf->pballoc + 1)) - 2;
903 : 0 : struct rte_hash_parameters fdir_hash_params = {
904 : : .name = fdir_hash_name,
905 : : .entries = max_fdir_num,
906 : : .key_len = sizeof(struct txgbe_atr_input),
907 : : .hash_func = rte_hash_crc,
908 : : .hash_func_init_val = 0,
909 : 0 : .socket_id = rte_socket_id(),
910 : : };
911 : :
912 : 0 : TAILQ_INIT(&fdir_info->fdir_list);
913 : 0 : snprintf(fdir_hash_name, RTE_HASH_NAMESIZE,
914 : 0 : "fdir_%s", TDEV_NAME(eth_dev));
915 : 0 : fdir_info->hash_handle = rte_hash_create(&fdir_hash_params);
916 [ # # ]: 0 : if (!fdir_info->hash_handle) {
917 : 0 : PMD_INIT_LOG(ERR, "Failed to create fdir hash table!");
918 : 0 : return -EINVAL;
919 : : }
920 : 0 : fdir_info->hash_map = rte_zmalloc("txgbe",
921 : : sizeof(struct txgbe_fdir_filter *) *
922 : : max_fdir_num,
923 : : 0);
924 [ # # ]: 0 : if (!fdir_info->hash_map) {
925 : 0 : PMD_INIT_LOG(ERR,
926 : : "Failed to allocate memory for fdir hash map!");
927 : 0 : rte_hash_free(fdir_info->hash_handle);
928 : 0 : return -ENOMEM;
929 : : }
930 : 0 : fdir_info->mask_added = FALSE;
931 : :
932 : 0 : return 0;
933 : : }
934 : :
935 : 0 : static int txgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev)
936 : : {
937 : 0 : struct txgbe_l2_tn_info *l2_tn_info = TXGBE_DEV_L2_TN(eth_dev);
938 : : char l2_tn_hash_name[RTE_HASH_NAMESIZE];
939 : 0 : struct rte_hash_parameters l2_tn_hash_params = {
940 : : .name = l2_tn_hash_name,
941 : : .entries = TXGBE_MAX_L2_TN_FILTER_NUM,
942 : : .key_len = sizeof(struct txgbe_l2_tn_key),
943 : : .hash_func = rte_hash_crc,
944 : : .hash_func_init_val = 0,
945 : 0 : .socket_id = rte_socket_id(),
946 : : };
947 : :
948 : 0 : TAILQ_INIT(&l2_tn_info->l2_tn_list);
949 : 0 : snprintf(l2_tn_hash_name, RTE_HASH_NAMESIZE,
950 : 0 : "l2_tn_%s", TDEV_NAME(eth_dev));
951 : 0 : l2_tn_info->hash_handle = rte_hash_create(&l2_tn_hash_params);
952 [ # # ]: 0 : if (!l2_tn_info->hash_handle) {
953 : 0 : PMD_INIT_LOG(ERR, "Failed to create L2 TN hash table!");
954 : 0 : return -EINVAL;
955 : : }
956 : 0 : l2_tn_info->hash_map = rte_zmalloc("txgbe",
957 : : sizeof(struct txgbe_l2_tn_filter *) *
958 : : TXGBE_MAX_L2_TN_FILTER_NUM,
959 : : 0);
960 [ # # ]: 0 : if (!l2_tn_info->hash_map) {
961 : 0 : PMD_INIT_LOG(ERR,
962 : : "Failed to allocate memory for L2 TN hash map!");
963 : 0 : rte_hash_free(l2_tn_info->hash_handle);
964 : 0 : return -ENOMEM;
965 : : }
966 : 0 : l2_tn_info->e_tag_en = FALSE;
967 : 0 : l2_tn_info->e_tag_fwd_en = FALSE;
968 : 0 : l2_tn_info->e_tag_ether_type = RTE_ETHER_TYPE_ETAG;
969 : :
970 : 0 : return 0;
971 : : }
972 : :
973 : : static int
974 : 0 : eth_txgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
975 : : struct rte_pci_device *pci_dev)
976 : : {
977 : 0 : return rte_eth_dev_create(&pci_dev->device, pci_dev->device.name,
978 : : sizeof(struct txgbe_adapter),
979 : : eth_dev_pci_specific_init, pci_dev,
980 : : eth_txgbe_dev_init, NULL);
981 : : }
982 : :
983 : 0 : static int eth_txgbe_pci_remove(struct rte_pci_device *pci_dev)
984 : : {
985 : : struct rte_eth_dev *ethdev;
986 : :
987 : 0 : ethdev = rte_eth_dev_allocated(pci_dev->device.name);
988 [ # # ]: 0 : if (!ethdev)
989 : : return 0;
990 : :
991 : 0 : return rte_eth_dev_pci_generic_remove(pci_dev, eth_txgbe_dev_uninit);
992 : : }
993 : :
994 : : static struct rte_pci_driver rte_txgbe_pmd = {
995 : : .id_table = pci_id_txgbe_map,
996 : : .drv_flags = RTE_PCI_DRV_NEED_MAPPING |
997 : : RTE_PCI_DRV_INTR_LSC,
998 : : .probe = eth_txgbe_pci_probe,
999 : : .remove = eth_txgbe_pci_remove,
1000 : : };
1001 : :
1002 : : static int
1003 : 0 : txgbe_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
1004 : : {
1005 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1006 : : struct txgbe_vfta *shadow_vfta = TXGBE_DEV_VFTA(dev);
1007 : : uint32_t vfta;
1008 : : uint32_t vid_idx;
1009 : : uint32_t vid_bit;
1010 : :
1011 : 0 : vid_idx = (uint32_t)((vlan_id >> 5) & 0x7F);
1012 : 0 : vid_bit = (uint32_t)(1 << (vlan_id & 0x1F));
1013 : 0 : vfta = rd32(hw, TXGBE_VLANTBL(vid_idx));
1014 [ # # ]: 0 : if (on)
1015 : 0 : vfta |= vid_bit;
1016 : : else
1017 : 0 : vfta &= ~vid_bit;
1018 : : wr32(hw, TXGBE_VLANTBL(vid_idx), vfta);
1019 : :
1020 : : /* update local VFTA copy */
1021 : 0 : shadow_vfta->vfta[vid_idx] = vfta;
1022 : :
1023 : 0 : return 0;
1024 : : }
1025 : :
1026 : : static void
1027 : 0 : txgbe_vlan_strip_q_set(struct rte_eth_dev *dev, uint16_t queue, int on)
1028 : : {
1029 [ # # ]: 0 : if (on)
1030 : 0 : txgbe_vlan_hw_strip_enable(dev, queue);
1031 : : else
1032 : 0 : txgbe_vlan_hw_strip_disable(dev, queue);
1033 : 0 : }
1034 : :
1035 : : static void
1036 : 0 : txgbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
1037 : : {
1038 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1039 : :
1040 [ # # ]: 0 : if (!hw->adapter_stopped) {
1041 : 0 : PMD_DRV_LOG(ERR, "Please stop port first");
1042 : 0 : return;
1043 : : }
1044 : :
1045 : 0 : txgbe_vlan_strip_q_set(dev, queue, on);
1046 : : }
1047 : :
1048 : : static int
1049 : 0 : txgbe_vlan_tpid_set(struct rte_eth_dev *dev,
1050 : : enum rte_vlan_type vlan_type,
1051 : : uint16_t tpid)
1052 : : {
1053 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1054 : : int ret = 0;
1055 : : uint32_t portctrl, vlan_ext, qinq;
1056 : :
1057 : : portctrl = rd32(hw, TXGBE_PORTCTL);
1058 : :
1059 : 0 : vlan_ext = (portctrl & TXGBE_PORTCTL_VLANEXT);
1060 [ # # # # ]: 0 : qinq = vlan_ext && (portctrl & TXGBE_PORTCTL_QINQ);
1061 [ # # # ]: 0 : switch (vlan_type) {
1062 : 0 : case RTE_ETH_VLAN_TYPE_INNER:
1063 [ # # ]: 0 : if (vlan_ext) {
1064 : 0 : wr32m(hw, TXGBE_VLANCTL,
1065 : : TXGBE_VLANCTL_TPID_MASK,
1066 : : TXGBE_VLANCTL_TPID(tpid));
1067 : 0 : wr32m(hw, TXGBE_DMATXCTRL,
1068 : : TXGBE_DMATXCTRL_TPID_MASK,
1069 : : TXGBE_DMATXCTRL_TPID(tpid));
1070 : : } else {
1071 : : ret = -ENOTSUP;
1072 : 0 : PMD_DRV_LOG(ERR, "Inner type is not supported"
1073 : : " by single VLAN");
1074 : : }
1075 : :
1076 [ # # ]: 0 : if (qinq) {
1077 : 0 : wr32m(hw, TXGBE_TAGTPID(0),
1078 : : TXGBE_TAGTPID_LSB_MASK,
1079 : : TXGBE_TAGTPID_LSB(tpid));
1080 : : }
1081 : : break;
1082 : 0 : case RTE_ETH_VLAN_TYPE_OUTER:
1083 [ # # ]: 0 : if (vlan_ext) {
1084 : : /* Only the high 16-bits is valid */
1085 : 0 : wr32m(hw, TXGBE_EXTAG,
1086 : : TXGBE_EXTAG_VLAN_MASK,
1087 : 0 : TXGBE_EXTAG_VLAN(tpid));
1088 : : } else {
1089 : 0 : wr32m(hw, TXGBE_VLANCTL,
1090 : : TXGBE_VLANCTL_TPID_MASK,
1091 : : TXGBE_VLANCTL_TPID(tpid));
1092 : 0 : wr32m(hw, TXGBE_DMATXCTRL,
1093 : : TXGBE_DMATXCTRL_TPID_MASK,
1094 : : TXGBE_DMATXCTRL_TPID(tpid));
1095 : : }
1096 : :
1097 [ # # ]: 0 : if (qinq) {
1098 : 0 : wr32m(hw, TXGBE_TAGTPID(0),
1099 : : TXGBE_TAGTPID_MSB_MASK,
1100 : 0 : TXGBE_TAGTPID_MSB(tpid));
1101 : : }
1102 : : break;
1103 : 0 : default:
1104 : 0 : PMD_DRV_LOG(ERR, "Unsupported VLAN type %d", vlan_type);
1105 : 0 : return -EINVAL;
1106 : : }
1107 : :
1108 : : return ret;
1109 : : }
1110 : :
1111 : : void
1112 : 0 : txgbe_vlan_hw_filter_disable(struct rte_eth_dev *dev)
1113 : : {
1114 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1115 : : uint32_t vlnctrl;
1116 : :
1117 : 0 : PMD_INIT_FUNC_TRACE();
1118 : :
1119 : : /* Filter Table Disable */
1120 : : vlnctrl = rd32(hw, TXGBE_VLANCTL);
1121 : 0 : vlnctrl &= ~TXGBE_VLANCTL_VFE;
1122 : : wr32(hw, TXGBE_VLANCTL, vlnctrl);
1123 : 0 : }
1124 : :
1125 : : void
1126 : 0 : txgbe_vlan_hw_filter_enable(struct rte_eth_dev *dev)
1127 : : {
1128 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1129 : : struct txgbe_vfta *shadow_vfta = TXGBE_DEV_VFTA(dev);
1130 : : uint32_t vlnctrl;
1131 : : uint16_t i;
1132 : :
1133 : 0 : PMD_INIT_FUNC_TRACE();
1134 : :
1135 : : /* Filter Table Enable */
1136 : : vlnctrl = rd32(hw, TXGBE_VLANCTL);
1137 : 0 : vlnctrl &= ~TXGBE_VLANCTL_CFIENA;
1138 : 0 : vlnctrl |= TXGBE_VLANCTL_VFE;
1139 : : wr32(hw, TXGBE_VLANCTL, vlnctrl);
1140 : :
1141 : : /* write whatever is in local vfta copy */
1142 [ # # ]: 0 : for (i = 0; i < TXGBE_VFTA_SIZE; i++)
1143 : 0 : wr32(hw, TXGBE_VLANTBL(i), shadow_vfta->vfta[i]);
1144 : 0 : }
1145 : :
1146 : : void
1147 : 0 : txgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev, uint16_t queue, bool on)
1148 : : {
1149 : 0 : struct txgbe_hwstrip *hwstrip = TXGBE_DEV_HWSTRIP(dev);
1150 : : struct txgbe_rx_queue *rxq;
1151 : :
1152 [ # # ]: 0 : if (queue >= TXGBE_MAX_RX_QUEUE_NUM)
1153 : : return;
1154 : :
1155 [ # # ]: 0 : if (on)
1156 : 0 : TXGBE_SET_HWSTRIP(hwstrip, queue);
1157 : : else
1158 : 0 : TXGBE_CLEAR_HWSTRIP(hwstrip, queue);
1159 : :
1160 [ # # ]: 0 : if (queue >= dev->data->nb_rx_queues)
1161 : : return;
1162 : :
1163 : 0 : rxq = dev->data->rx_queues[queue];
1164 : :
1165 [ # # ]: 0 : if (on) {
1166 : 0 : rxq->vlan_flags = RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
1167 : 0 : rxq->offloads |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
1168 : : } else {
1169 : 0 : rxq->vlan_flags = RTE_MBUF_F_RX_VLAN;
1170 : 0 : rxq->offloads &= ~RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
1171 : : }
1172 : : }
1173 : :
1174 : : static void
1175 : 0 : txgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, uint16_t queue)
1176 : : {
1177 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1178 : : uint32_t ctrl;
1179 : :
1180 : 0 : PMD_INIT_FUNC_TRACE();
1181 : :
1182 : 0 : ctrl = rd32(hw, TXGBE_RXCFG(queue));
1183 : 0 : ctrl &= ~TXGBE_RXCFG_VLAN;
1184 : : wr32(hw, TXGBE_RXCFG(queue), ctrl);
1185 : :
1186 : : /* record those setting for HW strip per queue */
1187 : 0 : txgbe_vlan_hw_strip_bitmap_set(dev, queue, 0);
1188 : 0 : }
1189 : :
1190 : : static void
1191 : 0 : txgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue)
1192 : : {
1193 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1194 : : uint32_t ctrl;
1195 : :
1196 : 0 : PMD_INIT_FUNC_TRACE();
1197 : :
1198 : 0 : ctrl = rd32(hw, TXGBE_RXCFG(queue));
1199 : 0 : ctrl |= TXGBE_RXCFG_VLAN;
1200 : : wr32(hw, TXGBE_RXCFG(queue), ctrl);
1201 : :
1202 : : /* record those setting for HW strip per queue */
1203 : 0 : txgbe_vlan_hw_strip_bitmap_set(dev, queue, 1);
1204 : 0 : }
1205 : :
1206 : : static void
1207 : 0 : txgbe_vlan_hw_extend_disable(struct rte_eth_dev *dev)
1208 : : {
1209 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1210 : : uint32_t ctrl;
1211 : :
1212 : 0 : PMD_INIT_FUNC_TRACE();
1213 : :
1214 : : ctrl = rd32(hw, TXGBE_PORTCTL);
1215 : 0 : ctrl &= ~TXGBE_PORTCTL_VLANEXT;
1216 : : wr32(hw, TXGBE_PORTCTL, ctrl);
1217 : 0 : }
1218 : :
1219 : : static void
1220 : 0 : txgbe_vlan_hw_extend_enable(struct rte_eth_dev *dev)
1221 : : {
1222 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1223 : : uint32_t ctrl;
1224 : :
1225 : 0 : PMD_INIT_FUNC_TRACE();
1226 : :
1227 : : ctrl = rd32(hw, TXGBE_PORTCTL);
1228 : 0 : ctrl |= TXGBE_PORTCTL_VLANEXT;
1229 : : wr32(hw, TXGBE_PORTCTL, ctrl);
1230 : 0 : }
1231 : :
1232 : : static void
1233 : 0 : txgbe_qinq_hw_strip_disable(struct rte_eth_dev *dev)
1234 : : {
1235 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1236 : : uint32_t ctrl;
1237 : :
1238 : 0 : PMD_INIT_FUNC_TRACE();
1239 : :
1240 : : ctrl = rd32(hw, TXGBE_PORTCTL);
1241 : 0 : ctrl &= ~TXGBE_PORTCTL_QINQ;
1242 : : wr32(hw, TXGBE_PORTCTL, ctrl);
1243 : 0 : }
1244 : :
1245 : : static void
1246 : 0 : txgbe_qinq_hw_strip_enable(struct rte_eth_dev *dev)
1247 : : {
1248 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1249 : : uint32_t ctrl;
1250 : :
1251 : 0 : PMD_INIT_FUNC_TRACE();
1252 : :
1253 : : ctrl = rd32(hw, TXGBE_PORTCTL);
1254 : 0 : ctrl |= TXGBE_PORTCTL_QINQ | TXGBE_PORTCTL_VLANEXT;
1255 : : wr32(hw, TXGBE_PORTCTL, ctrl);
1256 : 0 : }
1257 : :
1258 : : void
1259 : 0 : txgbe_vlan_hw_strip_config(struct rte_eth_dev *dev)
1260 : : {
1261 : : struct txgbe_rx_queue *rxq;
1262 : : uint16_t i;
1263 : :
1264 : 0 : PMD_INIT_FUNC_TRACE();
1265 : :
1266 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
1267 : 0 : rxq = dev->data->rx_queues[i];
1268 : :
1269 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)
1270 : 0 : txgbe_vlan_strip_q_set(dev, i, 1);
1271 : : else
1272 : 0 : txgbe_vlan_strip_q_set(dev, i, 0);
1273 : : }
1274 : 0 : }
1275 : :
1276 : : void
1277 : 0 : txgbe_config_vlan_strip_on_all_queues(struct rte_eth_dev *dev, int mask)
1278 : : {
1279 : : uint16_t i;
1280 : : struct rte_eth_rxmode *rxmode;
1281 : : struct txgbe_rx_queue *rxq;
1282 : :
1283 [ # # ]: 0 : if (mask & RTE_ETH_VLAN_STRIP_MASK) {
1284 : 0 : rxmode = &dev->data->dev_conf.rxmode;
1285 [ # # ]: 0 : if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)
1286 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
1287 : 0 : rxq = dev->data->rx_queues[i];
1288 : 0 : rxq->offloads |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
1289 : : }
1290 : : else
1291 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
1292 : 0 : rxq = dev->data->rx_queues[i];
1293 : 0 : rxq->offloads &= ~RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
1294 : : }
1295 : : }
1296 : 0 : }
1297 : :
1298 : : static int
1299 : 0 : txgbe_vlan_offload_config(struct rte_eth_dev *dev, int mask)
1300 : : {
1301 : : struct rte_eth_rxmode *rxmode;
1302 : 0 : rxmode = &dev->data->dev_conf.rxmode;
1303 : :
1304 [ # # ]: 0 : if (mask & RTE_ETH_VLAN_STRIP_MASK)
1305 : 0 : txgbe_vlan_hw_strip_config(dev);
1306 : :
1307 [ # # ]: 0 : if (mask & RTE_ETH_VLAN_FILTER_MASK) {
1308 [ # # ]: 0 : if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_FILTER)
1309 : 0 : txgbe_vlan_hw_filter_enable(dev);
1310 : : else
1311 : 0 : txgbe_vlan_hw_filter_disable(dev);
1312 : : }
1313 : :
1314 [ # # ]: 0 : if (mask & RTE_ETH_VLAN_EXTEND_MASK) {
1315 [ # # ]: 0 : if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_EXTEND)
1316 : 0 : txgbe_vlan_hw_extend_enable(dev);
1317 : : else
1318 : 0 : txgbe_vlan_hw_extend_disable(dev);
1319 : : }
1320 : :
1321 [ # # ]: 0 : if (mask & RTE_ETH_QINQ_STRIP_MASK) {
1322 [ # # ]: 0 : if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_QINQ_STRIP)
1323 : 0 : txgbe_qinq_hw_strip_enable(dev);
1324 : : else
1325 : 0 : txgbe_qinq_hw_strip_disable(dev);
1326 : : }
1327 : :
1328 : 0 : return 0;
1329 : : }
1330 : :
1331 : : static int
1332 : 0 : txgbe_vlan_offload_set(struct rte_eth_dev *dev, int mask)
1333 : : {
1334 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1335 : :
1336 [ # # # # ]: 0 : if (!hw->adapter_stopped && (mask & RTE_ETH_VLAN_STRIP_MASK)) {
1337 : 0 : PMD_DRV_LOG(ERR, "Please stop port first");
1338 : 0 : return -EPERM;
1339 : : }
1340 : :
1341 : 0 : txgbe_config_vlan_strip_on_all_queues(dev, mask);
1342 : :
1343 : 0 : txgbe_vlan_offload_config(dev, mask);
1344 : :
1345 : 0 : return 0;
1346 : : }
1347 : :
1348 : : static void
1349 : : txgbe_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)
1350 : : {
1351 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1352 : : /* VLNCTL: enable vlan filtering and allow all vlan tags through */
1353 : : uint32_t vlanctrl = rd32(hw, TXGBE_VLANCTL);
1354 : :
1355 : 0 : vlanctrl |= TXGBE_VLANCTL_VFE; /* enable vlan filters */
1356 : : wr32(hw, TXGBE_VLANCTL, vlanctrl);
1357 : 0 : }
1358 : :
1359 : : static int
1360 : : txgbe_check_vf_rss_rxq_num(struct rte_eth_dev *dev, uint16_t nb_rx_q)
1361 : : {
1362 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
1363 : :
1364 [ # # # ]: 0 : switch (nb_rx_q) {
1365 : 0 : case 1:
1366 : : case 2:
1367 : 0 : RTE_ETH_DEV_SRIOV(dev).active = RTE_ETH_64_POOLS;
1368 : 0 : break;
1369 : 0 : case 4:
1370 : 0 : RTE_ETH_DEV_SRIOV(dev).active = RTE_ETH_32_POOLS;
1371 : 0 : break;
1372 : : default:
1373 : : return -EINVAL;
1374 : : }
1375 : :
1376 : 0 : RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool =
1377 : 0 : TXGBE_MAX_RX_QUEUE_NUM / RTE_ETH_DEV_SRIOV(dev).active;
1378 : 0 : RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx =
1379 : 0 : pci_dev->max_vfs * RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool;
1380 : : return 0;
1381 : : }
1382 : :
1383 : : static int
1384 : 0 : txgbe_check_mq_mode(struct rte_eth_dev *dev)
1385 : : {
1386 : 0 : struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
1387 : 0 : uint16_t nb_rx_q = dev->data->nb_rx_queues;
1388 : 0 : uint16_t nb_tx_q = dev->data->nb_tx_queues;
1389 : :
1390 [ # # ]: 0 : if (RTE_ETH_DEV_SRIOV(dev).active != 0) {
1391 : : /* check multi-queue mode */
1392 [ # # # # : 0 : switch (dev_conf->rxmode.mq_mode) {
# ]
1393 : 0 : case RTE_ETH_MQ_RX_VMDQ_DCB:
1394 : 0 : PMD_INIT_LOG(INFO, "RTE_ETH_MQ_RX_VMDQ_DCB mode supported in SRIOV");
1395 : 0 : break;
1396 : 0 : case RTE_ETH_MQ_RX_VMDQ_DCB_RSS:
1397 : : /* DCB/RSS VMDQ in SRIOV mode, not implement yet */
1398 : 0 : PMD_INIT_LOG(ERR, "SRIOV active,"
1399 : : " unsupported mq_mode rx %d.",
1400 : : dev_conf->rxmode.mq_mode);
1401 : 0 : return -EINVAL;
1402 : 0 : case RTE_ETH_MQ_RX_RSS:
1403 : : case RTE_ETH_MQ_RX_VMDQ_RSS:
1404 : 0 : dev->data->dev_conf.rxmode.mq_mode = RTE_ETH_MQ_RX_VMDQ_RSS;
1405 [ # # ]: 0 : if (nb_rx_q <= RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)
1406 : : if (txgbe_check_vf_rss_rxq_num(dev, nb_rx_q)) {
1407 : 0 : PMD_INIT_LOG(ERR, "SRIOV is active,"
1408 : : " invalid queue number"
1409 : : " for VMDQ RSS, allowed"
1410 : : " value are 1, 2 or 4.");
1411 : 0 : return -EINVAL;
1412 : : }
1413 : : break;
1414 : 0 : case RTE_ETH_MQ_RX_VMDQ_ONLY:
1415 : : case RTE_ETH_MQ_RX_NONE:
1416 : : /* if nothing mq mode configure, use default scheme */
1417 : 0 : dev->data->dev_conf.rxmode.mq_mode =
1418 : : RTE_ETH_MQ_RX_VMDQ_ONLY;
1419 : 0 : break;
1420 : 0 : default: /* RTE_ETH_MQ_RX_DCB, RTE_ETH_MQ_RX_DCB_RSS or RTE_ETH_MQ_TX_DCB*/
1421 : : /* SRIOV only works in VMDq enable mode */
1422 : 0 : PMD_INIT_LOG(ERR, "SRIOV is active,"
1423 : : " wrong mq_mode rx %d.",
1424 : : dev_conf->rxmode.mq_mode);
1425 : 0 : return -EINVAL;
1426 : : }
1427 : :
1428 [ # # ]: 0 : switch (dev_conf->txmode.mq_mode) {
1429 : 0 : case RTE_ETH_MQ_TX_VMDQ_DCB:
1430 : 0 : PMD_INIT_LOG(INFO, "RTE_ETH_MQ_TX_VMDQ_DCB mode supported in SRIOV");
1431 : 0 : dev->data->dev_conf.txmode.mq_mode = RTE_ETH_MQ_TX_VMDQ_DCB;
1432 : 0 : break;
1433 : 0 : default: /* RTE_ETH_MQ_TX_VMDQ_ONLY or RTE_ETH_MQ_TX_NONE */
1434 : 0 : dev->data->dev_conf.txmode.mq_mode =
1435 : : RTE_ETH_MQ_TX_VMDQ_ONLY;
1436 : 0 : break;
1437 : : }
1438 : :
1439 : : /* check valid queue number */
1440 [ # # # # ]: 0 : if ((nb_rx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool) ||
1441 : : (nb_tx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)) {
1442 : 0 : PMD_INIT_LOG(ERR, "SRIOV is active,"
1443 : : " nb_rx_q=%d nb_tx_q=%d queue number"
1444 : : " must be less than or equal to %d.",
1445 : : nb_rx_q, nb_tx_q,
1446 : : RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool);
1447 : 0 : return -EINVAL;
1448 : : }
1449 : : } else {
1450 [ # # ]: 0 : if (dev_conf->rxmode.mq_mode == RTE_ETH_MQ_RX_VMDQ_DCB_RSS) {
1451 : 0 : PMD_INIT_LOG(ERR, "VMDQ+DCB+RSS mq_mode is"
1452 : : " not supported.");
1453 : 0 : return -EINVAL;
1454 : : }
1455 : : /* check configuration for vmdb+dcb mode */
1456 [ # # ]: 0 : if (dev_conf->rxmode.mq_mode == RTE_ETH_MQ_RX_VMDQ_DCB) {
1457 : : const struct rte_eth_vmdq_dcb_conf *conf;
1458 : :
1459 [ # # ]: 0 : if (nb_rx_q != TXGBE_VMDQ_DCB_NB_QUEUES) {
1460 : 0 : PMD_INIT_LOG(ERR, "VMDQ+DCB, nb_rx_q != %d.",
1461 : : TXGBE_VMDQ_DCB_NB_QUEUES);
1462 : 0 : return -EINVAL;
1463 : : }
1464 : : conf = &dev_conf->rx_adv_conf.vmdq_dcb_conf;
1465 [ # # ]: 0 : if (!(conf->nb_queue_pools == RTE_ETH_16_POOLS ||
1466 : : conf->nb_queue_pools == RTE_ETH_32_POOLS)) {
1467 : 0 : PMD_INIT_LOG(ERR, "VMDQ+DCB selected,"
1468 : : " nb_queue_pools must be %d or %d.",
1469 : : RTE_ETH_16_POOLS, RTE_ETH_32_POOLS);
1470 : 0 : return -EINVAL;
1471 : : }
1472 : : }
1473 [ # # ]: 0 : if (dev_conf->txmode.mq_mode == RTE_ETH_MQ_TX_VMDQ_DCB) {
1474 : : const struct rte_eth_vmdq_dcb_tx_conf *conf;
1475 : :
1476 [ # # ]: 0 : if (nb_tx_q != TXGBE_VMDQ_DCB_NB_QUEUES) {
1477 : 0 : PMD_INIT_LOG(ERR, "VMDQ+DCB, nb_tx_q != %d",
1478 : : TXGBE_VMDQ_DCB_NB_QUEUES);
1479 : 0 : return -EINVAL;
1480 : : }
1481 : : conf = &dev_conf->tx_adv_conf.vmdq_dcb_tx_conf;
1482 [ # # ]: 0 : if (!(conf->nb_queue_pools == RTE_ETH_16_POOLS ||
1483 : : conf->nb_queue_pools == RTE_ETH_32_POOLS)) {
1484 : 0 : PMD_INIT_LOG(ERR, "VMDQ+DCB selected,"
1485 : : " nb_queue_pools != %d and"
1486 : : " nb_queue_pools != %d.",
1487 : : RTE_ETH_16_POOLS, RTE_ETH_32_POOLS);
1488 : 0 : return -EINVAL;
1489 : : }
1490 : : }
1491 : :
1492 : : /* For DCB mode check our configuration before we go further */
1493 [ # # ]: 0 : if (dev_conf->rxmode.mq_mode == RTE_ETH_MQ_RX_DCB) {
1494 : : const struct rte_eth_dcb_rx_conf *conf;
1495 : :
1496 : : conf = &dev_conf->rx_adv_conf.dcb_rx_conf;
1497 [ # # ]: 0 : if (!(conf->nb_tcs == RTE_ETH_4_TCS ||
1498 : : conf->nb_tcs == RTE_ETH_8_TCS)) {
1499 : 0 : PMD_INIT_LOG(ERR, "DCB selected, nb_tcs != %d"
1500 : : " and nb_tcs != %d.",
1501 : : RTE_ETH_4_TCS, RTE_ETH_8_TCS);
1502 : 0 : return -EINVAL;
1503 : : }
1504 : : }
1505 : :
1506 [ # # ]: 0 : if (dev_conf->txmode.mq_mode == RTE_ETH_MQ_TX_DCB) {
1507 : : const struct rte_eth_dcb_tx_conf *conf;
1508 : :
1509 : : conf = &dev_conf->tx_adv_conf.dcb_tx_conf;
1510 [ # # ]: 0 : if (!(conf->nb_tcs == RTE_ETH_4_TCS ||
1511 : : conf->nb_tcs == RTE_ETH_8_TCS)) {
1512 : 0 : PMD_INIT_LOG(ERR, "DCB selected, nb_tcs != %d"
1513 : : " and nb_tcs != %d.",
1514 : : RTE_ETH_4_TCS, RTE_ETH_8_TCS);
1515 : 0 : return -EINVAL;
1516 : : }
1517 : : }
1518 : :
1519 : : /*
1520 : : * When DCB/VT is off, maximum number of queues changes
1521 : : */
1522 [ # # ]: 0 : if (dev_conf->txmode.mq_mode == RTE_ETH_MQ_TX_NONE) {
1523 [ # # ]: 0 : if (nb_tx_q > TXGBE_NONE_MODE_TX_NB_QUEUES) {
1524 : 0 : PMD_INIT_LOG(ERR,
1525 : : "Neither VT nor DCB are enabled, "
1526 : : "nb_tx_q > %d.",
1527 : : TXGBE_NONE_MODE_TX_NB_QUEUES);
1528 : 0 : return -EINVAL;
1529 : : }
1530 : : }
1531 : : }
1532 : : return 0;
1533 : : }
1534 : :
1535 : : static int
1536 : 0 : txgbe_dev_configure(struct rte_eth_dev *dev)
1537 : : {
1538 : 0 : struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
1539 : : struct txgbe_adapter *adapter = TXGBE_DEV_ADAPTER(dev);
1540 : : int ret;
1541 : :
1542 : 0 : PMD_INIT_FUNC_TRACE();
1543 : :
1544 [ # # ]: 0 : if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
1545 : 0 : dev->data->dev_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
1546 : :
1547 : : /* multiple queue mode checking */
1548 : 0 : ret = txgbe_check_mq_mode(dev);
1549 [ # # ]: 0 : if (ret != 0) {
1550 : 0 : PMD_DRV_LOG(ERR, "txgbe_check_mq_mode fails with %d.",
1551 : : ret);
1552 : 0 : return ret;
1553 : : }
1554 : :
1555 : : /* set flag to update link status after init */
1556 : 0 : intr->flags |= TXGBE_FLAG_NEED_LINK_UPDATE;
1557 : :
1558 : : /*
1559 : : * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
1560 : : * allocation Rx preconditions we will reset it.
1561 : : */
1562 : 0 : adapter->rx_bulk_alloc_allowed = true;
1563 : 0 : adapter->rx_vec_allowed = true;
1564 : :
1565 : 0 : return 0;
1566 : : }
1567 : :
1568 : 0 : static void txgbe_reinit_gpio_intr(struct txgbe_hw *hw)
1569 : : {
1570 : : u32 reg;
1571 : :
1572 : : wr32(hw, TXGBE_GPIOINTMASK, 0xFF);
1573 : : reg = rd32(hw, TXGBE_GPIORAWINTSTAT);
1574 : :
1575 [ # # ]: 0 : if (reg & TXGBE_GPIOBIT_0)
1576 : : wr32(hw, TXGBE_GPIOEOI, TXGBE_GPIOBIT_0);
1577 : :
1578 [ # # ]: 0 : if (reg & TXGBE_GPIOBIT_2)
1579 : : wr32(hw, TXGBE_GPIOEOI, TXGBE_GPIOBIT_2);
1580 : :
1581 [ # # ]: 0 : if (reg & TXGBE_GPIOBIT_3)
1582 : : wr32(hw, TXGBE_GPIOEOI, TXGBE_GPIOBIT_3);
1583 : :
1584 [ # # ]: 0 : if (reg & TXGBE_GPIOBIT_6)
1585 : : wr32(hw, TXGBE_GPIOEOI, TXGBE_GPIOBIT_6);
1586 : :
1587 : : wr32(hw, TXGBE_GPIOINTMASK, 0);
1588 : 0 : }
1589 : :
1590 : : static void
1591 : 0 : txgbe_dev_phy_intr_setup(struct rte_eth_dev *dev)
1592 : : {
1593 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1594 : : struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
1595 : 0 : u8 device_type = hw->subsystem_device_id & 0xF0;
1596 : : uint32_t gpie;
1597 : :
1598 : 0 : if (device_type != TXGBE_DEV_ID_MAC_XAUI &&
1599 [ # # ]: 0 : device_type != TXGBE_DEV_ID_MAC_SGMII) {
1600 : : gpie = rd32(hw, TXGBE_GPIOINTEN);
1601 : 0 : gpie |= TXGBE_GPIOBIT_2 | TXGBE_GPIOBIT_3 | TXGBE_GPIOBIT_6;
1602 : : wr32(hw, TXGBE_GPIOINTEN, gpie);
1603 : :
1604 : : gpie = rd32(hw, TXGBE_GPIOINTTYPE);
1605 : 0 : gpie |= TXGBE_GPIOBIT_2 | TXGBE_GPIOBIT_3 | TXGBE_GPIOBIT_6;
1606 : : wr32(hw, TXGBE_GPIOINTTYPE, gpie);
1607 : : }
1608 : :
1609 : 0 : intr->mask_misc |= TXGBE_ICRMISC_GPIO;
1610 : 0 : intr->mask_misc |= TXGBE_ICRMISC_ANDONE;
1611 : 0 : intr->mask_misc |= TXGBE_ICRMISC_HEAT;
1612 : 0 : }
1613 : :
1614 : : int
1615 : 0 : txgbe_set_vf_rate_limit(struct rte_eth_dev *dev, uint16_t vf,
1616 : : uint16_t tx_rate, uint64_t q_msk)
1617 : : {
1618 : : struct txgbe_hw *hw;
1619 : : struct txgbe_vf_info *vfinfo;
1620 : : struct rte_eth_link link;
1621 : : uint8_t nb_q_per_pool;
1622 : : uint32_t queue_stride;
1623 : : uint32_t queue_idx, idx = 0, vf_idx;
1624 : : uint32_t queue_end;
1625 : : uint16_t total_rate = 0;
1626 : : struct rte_pci_device *pci_dev;
1627 : : int ret;
1628 : :
1629 : 0 : pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
1630 : 0 : ret = rte_eth_link_get_nowait(dev->data->port_id, &link);
1631 [ # # ]: 0 : if (ret < 0)
1632 : : return ret;
1633 : :
1634 [ # # ]: 0 : if (vf >= pci_dev->max_vfs)
1635 : : return -EINVAL;
1636 : :
1637 [ # # ]: 0 : if (tx_rate > link.link_speed)
1638 : : return -EINVAL;
1639 : :
1640 [ # # ]: 0 : if (q_msk == 0)
1641 : : return 0;
1642 : :
1643 : 0 : hw = TXGBE_DEV_HW(dev);
1644 : 0 : vfinfo = *(TXGBE_DEV_VFDATA(dev));
1645 : 0 : nb_q_per_pool = RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool;
1646 : 0 : queue_stride = TXGBE_MAX_RX_QUEUE_NUM / RTE_ETH_DEV_SRIOV(dev).active;
1647 : 0 : queue_idx = vf * queue_stride;
1648 : 0 : queue_end = queue_idx + nb_q_per_pool - 1;
1649 [ # # ]: 0 : if (queue_end >= hw->mac.max_tx_queues)
1650 : : return -EINVAL;
1651 : :
1652 [ # # ]: 0 : if (vfinfo) {
1653 [ # # ]: 0 : for (vf_idx = 0; vf_idx < pci_dev->max_vfs; vf_idx++) {
1654 [ # # ]: 0 : if (vf_idx == vf)
1655 : 0 : continue;
1656 [ # # ]: 0 : for (idx = 0; idx < RTE_DIM(vfinfo[vf_idx].tx_rate);
1657 : 0 : idx++)
1658 : 0 : total_rate += vfinfo[vf_idx].tx_rate[idx];
1659 : : }
1660 : : } else {
1661 : : return -EINVAL;
1662 : : }
1663 : :
1664 : : /* Store tx_rate for this vf. */
1665 [ # # ]: 0 : for (idx = 0; idx < nb_q_per_pool; idx++) {
1666 [ # # ]: 0 : if (((uint64_t)0x1 << idx) & q_msk) {
1667 [ # # ]: 0 : if (vfinfo[vf].tx_rate[idx] != tx_rate)
1668 : 0 : vfinfo[vf].tx_rate[idx] = tx_rate;
1669 : 0 : total_rate += tx_rate;
1670 : : }
1671 : : }
1672 : :
1673 [ # # ]: 0 : if (total_rate > dev->data->dev_link.link_speed) {
1674 : : /* Reset stored TX rate of the VF if it causes exceed
1675 : : * link speed.
1676 : : */
1677 : 0 : memset(vfinfo[vf].tx_rate, 0, sizeof(vfinfo[vf].tx_rate));
1678 : 0 : return -EINVAL;
1679 : : }
1680 : :
1681 : : /* Set ARBTXRATE of each queue/pool for vf X */
1682 [ # # ]: 0 : for (; queue_idx <= queue_end; queue_idx++) {
1683 [ # # ]: 0 : if (0x1 & q_msk)
1684 : 0 : txgbe_set_queue_rate_limit(dev, queue_idx, tx_rate);
1685 : 0 : q_msk = q_msk >> 1;
1686 : : }
1687 : :
1688 : : return 0;
1689 : : }
1690 : :
1691 : : /*
1692 : : * Configure device link speed and setup link.
1693 : : * It returns 0 on success.
1694 : : */
1695 : : static int
1696 : 0 : txgbe_dev_start(struct rte_eth_dev *dev)
1697 : : {
1698 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1699 : 0 : struct txgbe_hw_stats *hw_stats = TXGBE_DEV_STATS(dev);
1700 : 0 : struct txgbe_vf_info *vfinfo = *TXGBE_DEV_VFDATA(dev);
1701 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
1702 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
1703 : : uint32_t intr_vector = 0;
1704 : : int err;
1705 : 0 : bool link_up = false, negotiate = 0;
1706 : 0 : uint32_t speed = 0;
1707 : : uint32_t allowed_speeds = 0;
1708 : : int mask = 0;
1709 : : int status;
1710 : : uint16_t vf, idx;
1711 : : uint32_t *link_speeds;
1712 : : struct txgbe_tm_conf *tm_conf = TXGBE_DEV_TM_CONF(dev);
1713 : : u32 links_reg;
1714 : :
1715 : 0 : PMD_INIT_FUNC_TRACE();
1716 : :
1717 : : /* Stop the link setup handler before resetting the HW. */
1718 : 0 : rte_eal_alarm_cancel(txgbe_dev_detect_sfp, dev);
1719 : 0 : txgbe_dev_wait_setup_link_complete(dev, 0);
1720 : :
1721 : : /* disable uio/vfio intr/eventfd mapping */
1722 : 0 : rte_intr_disable(intr_handle);
1723 : :
1724 : : /* stop adapter */
1725 : 0 : hw->adapter_stopped = 0;
1726 : 0 : txgbe_stop_hw(hw);
1727 : :
1728 : : /* reinitialize adapter
1729 : : * this calls reset and start
1730 : : */
1731 : 0 : hw->nb_rx_queues = dev->data->nb_rx_queues;
1732 : 0 : hw->nb_tx_queues = dev->data->nb_tx_queues;
1733 : 0 : status = txgbe_pf_reset_hw(hw);
1734 [ # # ]: 0 : if (status != 0)
1735 : : return -1;
1736 : 0 : hw->mac.start_hw(hw);
1737 : 0 : hw->mac.get_link_status = true;
1738 : 0 : hw->dev_start = true;
1739 : :
1740 : 0 : txgbe_set_pcie_master(hw, true);
1741 : :
1742 : : /* workaround for GPIO intr lost when mng_veto bit is set */
1743 [ # # ]: 0 : if (txgbe_check_reset_blocked(hw))
1744 : 0 : txgbe_reinit_gpio_intr(hw);
1745 : :
1746 : : /* configure PF module if SRIOV enabled */
1747 : 0 : txgbe_pf_host_configure(dev);
1748 : :
1749 : 0 : txgbe_dev_phy_intr_setup(dev);
1750 : :
1751 : : /* check and configure queue intr-vector mapping */
1752 [ # # ]: 0 : if ((rte_intr_cap_multiple(intr_handle) ||
1753 [ # # ]: 0 : !RTE_ETH_DEV_SRIOV(dev).active) &&
1754 [ # # ]: 0 : dev->data->dev_conf.intr_conf.rxq != 0) {
1755 : 0 : intr_vector = dev->data->nb_rx_queues;
1756 [ # # ]: 0 : if (rte_intr_efd_enable(intr_handle, intr_vector))
1757 : : return -1;
1758 : : }
1759 : :
1760 [ # # ]: 0 : if (rte_intr_dp_is_en(intr_handle)) {
1761 [ # # ]: 0 : if (rte_intr_vec_list_alloc(intr_handle, "intr_vec",
1762 : 0 : dev->data->nb_rx_queues)) {
1763 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
1764 : : " intr_vec", dev->data->nb_rx_queues);
1765 : 0 : return -ENOMEM;
1766 : : }
1767 : : }
1768 : : /* configure msix for sleep until rx interrupt */
1769 : 0 : txgbe_configure_msix(dev);
1770 : :
1771 : : /* initialize transmission unit */
1772 : 0 : txgbe_dev_tx_init(dev);
1773 : :
1774 : : /* This can fail when allocating mbufs for descriptor rings */
1775 : 0 : err = txgbe_dev_rx_init(dev);
1776 [ # # ]: 0 : if (err) {
1777 : 0 : PMD_INIT_LOG(ERR, "Unable to initialize RX hardware");
1778 : 0 : goto error;
1779 : : }
1780 : :
1781 : : mask = RTE_ETH_VLAN_STRIP_MASK | RTE_ETH_VLAN_FILTER_MASK |
1782 : : RTE_ETH_VLAN_EXTEND_MASK;
1783 : 0 : err = txgbe_vlan_offload_config(dev, mask);
1784 [ # # ]: 0 : if (err) {
1785 : 0 : PMD_INIT_LOG(ERR, "Unable to set VLAN offload");
1786 : 0 : goto error;
1787 : : }
1788 : :
1789 [ # # ]: 0 : if (dev->data->dev_conf.rxmode.mq_mode == RTE_ETH_MQ_RX_VMDQ_ONLY) {
1790 : : /* Enable vlan filtering for VMDq */
1791 : : txgbe_vmdq_vlan_hw_filter_enable(dev);
1792 : : }
1793 : :
1794 : : /* Configure DCB hw */
1795 : 0 : txgbe_configure_pb(dev);
1796 : 0 : txgbe_configure_port(dev);
1797 : 0 : txgbe_configure_dcb(dev);
1798 : :
1799 [ # # ]: 0 : if (TXGBE_DEV_FDIR_CONF(dev)->mode != RTE_FDIR_MODE_NONE) {
1800 : 0 : err = txgbe_fdir_configure(dev);
1801 [ # # ]: 0 : if (err)
1802 : 0 : goto error;
1803 : : }
1804 : :
1805 : : /* Restore vf rate limit */
1806 [ # # ]: 0 : if (vfinfo != NULL) {
1807 [ # # ]: 0 : for (vf = 0; vf < pci_dev->max_vfs; vf++)
1808 [ # # ]: 0 : for (idx = 0; idx < TXGBE_MAX_QUEUE_NUM_PER_VF; idx++)
1809 [ # # ]: 0 : if (vfinfo[vf].tx_rate[idx] != 0)
1810 : 0 : txgbe_set_vf_rate_limit(dev, vf,
1811 : : vfinfo[vf].tx_rate[idx],
1812 : 0 : 1 << idx);
1813 : : }
1814 : :
1815 : 0 : err = txgbe_dev_rxtx_start(dev);
1816 [ # # ]: 0 : if (err < 0) {
1817 : 0 : PMD_INIT_LOG(ERR, "Unable to start rxtx queues");
1818 : 0 : goto error;
1819 : : }
1820 : :
1821 : : /* Skip link setup if loopback mode is enabled. */
1822 [ # # ]: 0 : if (txgbe_is_pf(hw) &&
1823 [ # # ]: 0 : dev->data->dev_conf.lpbk_mode)
1824 : 0 : goto skip_link_setup;
1825 : :
1826 [ # # ]: 0 : if (txgbe_is_sfp(hw) && hw->phy.multispeed_fiber) {
1827 : 0 : err = hw->mac.setup_sfp(hw);
1828 [ # # ]: 0 : if (err)
1829 : 0 : goto error;
1830 : : }
1831 : :
1832 [ # # ]: 0 : if (hw->phy.media_type == txgbe_media_type_copper) {
1833 : : /* Turn on the copper */
1834 : 0 : hw->phy.set_phy_power(hw, true);
1835 : : } else {
1836 : : /* Turn on the laser */
1837 : 0 : hw->mac.enable_tx_laser(hw);
1838 : : }
1839 : :
1840 [ # # ]: 0 : if ((hw->subsystem_device_id & 0xFF) != TXGBE_DEV_ID_KR_KX_KX4)
1841 : 0 : err = hw->mac.check_link(hw, &speed, &link_up, 0);
1842 [ # # ]: 0 : if (err)
1843 : 0 : goto error;
1844 : 0 : dev->data->dev_link.link_status = link_up;
1845 : :
1846 : 0 : err = hw->mac.get_link_capabilities(hw, &speed, &negotiate);
1847 [ # # ]: 0 : if (err)
1848 : 0 : goto error;
1849 : :
1850 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml40)
1851 : : allowed_speeds = RTE_ETH_LINK_SPEED_40G;
1852 [ # # ]: 0 : else if (hw->mac.type == txgbe_mac_aml)
1853 : : allowed_speeds = RTE_ETH_LINK_SPEED_10G | RTE_ETH_LINK_SPEED_25G;
1854 : : else
1855 : : allowed_speeds = RTE_ETH_LINK_SPEED_100M | RTE_ETH_LINK_SPEED_1G |
1856 : : RTE_ETH_LINK_SPEED_10G;
1857 : :
1858 : 0 : link_speeds = &dev->data->dev_conf.link_speeds;
1859 [ # # ]: 0 : if (((*link_speeds) >> 1) & ~(allowed_speeds >> 1)) {
1860 : 0 : PMD_INIT_LOG(ERR, "Invalid link setting");
1861 : 0 : goto error;
1862 : : }
1863 : :
1864 : 0 : speed = 0x0;
1865 [ # # ]: 0 : if (*link_speeds == RTE_ETH_LINK_SPEED_AUTONEG) {
1866 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml40) {
1867 : 0 : speed = TXGBE_LINK_SPEED_40GB_FULL;
1868 [ # # ]: 0 : } else if (hw->mac.type == txgbe_mac_aml) {
1869 : 0 : speed = (TXGBE_LINK_SPEED_10GB_FULL |
1870 : : TXGBE_LINK_SPEED_25GB_FULL);
1871 : : } else {
1872 : 0 : speed = (TXGBE_LINK_SPEED_100M_FULL |
1873 : : TXGBE_LINK_SPEED_1GB_FULL |
1874 : : TXGBE_LINK_SPEED_10GB_FULL);
1875 : : }
1876 : 0 : hw->autoneg = true;
1877 : : } else {
1878 [ # # ]: 0 : if (*link_speeds & RTE_ETH_LINK_SPEED_40G)
1879 : 0 : speed |= TXGBE_LINK_SPEED_40GB_FULL;
1880 [ # # ]: 0 : if (*link_speeds & RTE_ETH_LINK_SPEED_25G)
1881 : 0 : speed |= TXGBE_LINK_SPEED_25GB_FULL;
1882 [ # # ]: 0 : if (*link_speeds & RTE_ETH_LINK_SPEED_10G)
1883 : 0 : speed |= TXGBE_LINK_SPEED_10GB_FULL;
1884 [ # # ]: 0 : if (*link_speeds & RTE_ETH_LINK_SPEED_1G)
1885 : 0 : speed |= TXGBE_LINK_SPEED_1GB_FULL;
1886 [ # # ]: 0 : if (*link_speeds & RTE_ETH_LINK_SPEED_100M)
1887 : 0 : speed |= TXGBE_LINK_SPEED_100M_FULL;
1888 : 0 : hw->autoneg = false;
1889 : : }
1890 : :
1891 : 0 : err = hw->mac.setup_link(hw, speed, link_up);
1892 [ # # ]: 0 : if (err)
1893 : 0 : goto error;
1894 : :
1895 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml) {
1896 : : links_reg = rd32(hw, TXGBE_PORT);
1897 [ # # ]: 0 : if (links_reg & TXGBE_PORT_LINKUP) {
1898 [ # # ]: 0 : if (links_reg & TXGBE_CFG_PORT_ST_AML_LINK_25G) {
1899 : 0 : wr32(hw, TXGBE_MACTXCFG,
1900 : 0 : (rd32(hw, TXGBE_MACTXCFG) &
1901 : : ~TXGBE_MAC_TX_CFG_AML_SPEED_MASK) |
1902 : : TXGBE_MAC_TX_CFG_AML_SPEED_25G);
1903 [ # # ]: 0 : } else if (links_reg & TXGBE_CFG_PORT_ST_AML_LINK_10G) {
1904 : 0 : wr32(hw, TXGBE_MACTXCFG,
1905 : 0 : (rd32(hw, TXGBE_MACTXCFG) &
1906 : : ~TXGBE_MAC_TX_CFG_AML_SPEED_MASK) |
1907 : : TXGBE_MAC_TX_CFG_AML_SPEED_10G);
1908 : : }
1909 : : }
1910 : :
1911 : : /* amlite: restart gpio */
1912 : : wr32(hw, TXGBE_GPIODIR, TXGBE_GPIOBIT_0 | TXGBE_GPIOBIT_1 |
1913 : : TXGBE_GPIOBIT_4 | TXGBE_GPIOBIT_5);
1914 : : wr32(hw, TXGBE_GPIODATA, TXGBE_GPIOBIT_4 | TXGBE_GPIOBIT_5);
1915 : : msleep(10);
1916 : : wr32(hw, TXGBE_GPIODATA, TXGBE_GPIOBIT_0);
1917 : : wr32m(hw, TXGBE_GPIO_INT_POLARITY, TXGBE_GPIO_INT_POLARITY_3, 0x0);
1918 [ # # ]: 0 : } else if (hw->mac.type == txgbe_mac_aml40) {
1919 : : links_reg = rd32(hw, TXGBE_PORT);
1920 [ # # ]: 0 : if (links_reg & TXGBE_PORT_LINKUP) {
1921 [ # # ]: 0 : if (links_reg & TXGBE_CFG_PORT_ST_AML_LINK_40G) {
1922 : 0 : wr32(hw, TXGBE_MACTXCFG,
1923 : : (rd32(hw, TXGBE_MACTXCFG) &
1924 : : ~TXGBE_MAC_TX_CFG_AML_SPEED_MASK) |
1925 : : TXGBE_MAC_TX_CFG_AML_SPEED_40G);
1926 : : }
1927 : : }
1928 : :
1929 : : wr32(hw, TXGBE_GPIODIR, TXGBE_GPIOBIT_0 | TXGBE_GPIOBIT_1
1930 : : | TXGBE_GPIOBIT_3);
1931 : : wr32(hw, TXGBE_GPIODATA, TXGBE_GPIOBIT_1);
1932 : : }
1933 : 0 : skip_link_setup:
1934 : :
1935 [ # # ]: 0 : if (rte_intr_allow_others(intr_handle)) {
1936 : : txgbe_dev_misc_interrupt_setup(dev);
1937 : : /* check if lsc interrupt is enabled */
1938 : 0 : if (dev->data->dev_conf.intr_conf.lsc != 0)
1939 : : txgbe_dev_lsc_interrupt_setup(dev, TRUE);
1940 : : else
1941 : : txgbe_dev_lsc_interrupt_setup(dev, FALSE);
1942 : : txgbe_dev_macsec_interrupt_setup(dev);
1943 : 0 : txgbe_set_ivar_map(hw, -1, 1, TXGBE_MISC_VEC_ID);
1944 : : } else {
1945 : 0 : rte_intr_callback_unregister(intr_handle,
1946 : : txgbe_dev_interrupt_handler, dev);
1947 [ # # ]: 0 : if (dev->data->dev_conf.intr_conf.lsc != 0)
1948 : 0 : PMD_INIT_LOG(INFO, "lsc won't enable because of"
1949 : : " no intr multiplex");
1950 : : }
1951 : :
1952 : : /* check if rxq interrupt is enabled */
1953 [ # # # # ]: 0 : if (dev->data->dev_conf.intr_conf.rxq != 0 &&
1954 : 0 : rte_intr_dp_is_en(intr_handle))
1955 : : txgbe_dev_rxq_interrupt_setup(dev);
1956 : :
1957 : : /* enable uio/vfio intr/eventfd mapping */
1958 : 0 : rte_intr_enable(intr_handle);
1959 : :
1960 : : /* resume enabled intr since hw reset */
1961 : 0 : txgbe_enable_intr(dev);
1962 : 0 : txgbe_l2_tunnel_conf(dev);
1963 : 0 : txgbe_filter_restore(dev);
1964 : :
1965 : 0 : hw->bp_event_interval = 100 * 1000;
1966 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) {
1967 : 0 : rte_eal_alarm_set(hw->bp_event_interval, txgbe_dev_e56_check_bp_event, dev);
1968 : 0 : rte_eal_alarm_set(1000 * 1000 * 2, txgbe_dev_check_aml_temp_event, dev);
1969 : : }
1970 : :
1971 [ # # # # ]: 0 : if (tm_conf->root && !tm_conf->committed)
1972 : 0 : PMD_DRV_LOG(WARNING,
1973 : : "please call hierarchy_commit() "
1974 : : "before starting the port");
1975 : :
1976 : : /*
1977 : : * Update link status right before return, because it may
1978 : : * start link configuration process in a separate thread.
1979 : : */
1980 : : txgbe_dev_link_update(dev, 0);
1981 : :
1982 : : wr32m(hw, TXGBE_LEDCTL, 0xFFFFFFFF, TXGBE_LEDCTL_ORD_MASK);
1983 : :
1984 : 0 : txgbe_read_stats_registers(hw, hw_stats);
1985 : 0 : hw->offset_loaded = 1;
1986 : :
1987 : 0 : return 0;
1988 : :
1989 : 0 : error:
1990 : 0 : PMD_INIT_LOG(ERR, "failure in dev start: %d", err);
1991 : 0 : txgbe_dev_clear_queues(dev);
1992 : 0 : return -EIO;
1993 : : }
1994 : :
1995 : : /*
1996 : : * Stop device: disable rx and tx functions to allow for reconfiguring.
1997 : : */
1998 : : static int
1999 : 0 : txgbe_dev_stop(struct rte_eth_dev *dev)
2000 : : {
2001 : : struct rte_eth_link link;
2002 : 0 : struct txgbe_adapter *adapter = TXGBE_DEV_ADAPTER(dev);
2003 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2004 : 0 : struct txgbe_vf_info *vfinfo = *TXGBE_DEV_VFDATA(dev);
2005 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
2006 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
2007 : : int vf;
2008 : : struct txgbe_tm_conf *tm_conf = TXGBE_DEV_TM_CONF(dev);
2009 : :
2010 [ # # ]: 0 : if (hw->adapter_stopped)
2011 : 0 : goto out;
2012 : :
2013 : 0 : PMD_INIT_FUNC_TRACE();
2014 : :
2015 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) {
2016 : 0 : rte_eal_alarm_cancel(txgbe_dev_e56_check_bp_event, dev);
2017 : 0 : rte_eal_alarm_cancel(txgbe_dev_check_aml_temp_event, dev);
2018 : 0 : rte_eal_alarm_cancel(txgbe_dev_setup_link_alarm_handler_aml, hw);
2019 : : }
2020 : :
2021 : 0 : rte_eal_alarm_cancel(txgbe_dev_detect_sfp, dev);
2022 : 0 : rte_eal_alarm_cancel(txgbe_tx_queue_clear_error, dev);
2023 : 0 : txgbe_dev_wait_setup_link_complete(dev, 0);
2024 : :
2025 : : /* disable interrupts */
2026 : 0 : txgbe_disable_intr(hw);
2027 : :
2028 : : /* workaround for GPIO intr lost when mng_veto bit is set */
2029 [ # # ]: 0 : if (txgbe_check_reset_blocked(hw))
2030 : 0 : txgbe_reinit_gpio_intr(hw);
2031 : :
2032 : : /* reset the NIC */
2033 : 0 : txgbe_pf_reset_hw(hw);
2034 : 0 : hw->adapter_stopped = 0;
2035 : :
2036 : : /* stop adapter */
2037 : 0 : txgbe_stop_hw(hw);
2038 : :
2039 [ # # # # ]: 0 : for (vf = 0; vfinfo != NULL && vf < pci_dev->max_vfs; vf++)
2040 : 0 : vfinfo[vf].clear_to_send = false;
2041 : :
2042 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml)
2043 : : wr32m(hw, TXGBE_AML_EPCS_MISC_CTL,
2044 : : TXGBE_AML_LINK_STATUS_OVRD_EN, 0x0);
2045 : :
2046 : 0 : txgbe_dev_clear_queues(dev);
2047 : :
2048 : : /* Clear stored conf */
2049 : 0 : dev->data->scattered_rx = 0;
2050 : 0 : dev->data->lro = 0;
2051 : :
2052 : : /* Clear recorded link status */
2053 : : memset(&link, 0, sizeof(link));
2054 : 0 : rte_eth_linkstatus_set(dev, &link);
2055 : :
2056 [ # # ]: 0 : if (!rte_intr_allow_others(intr_handle))
2057 : : /* resume to the default handler */
2058 : 0 : rte_intr_callback_register(intr_handle,
2059 : : txgbe_dev_interrupt_handler,
2060 : : (void *)dev);
2061 : :
2062 : : /* Clean datapath event and queue/vec mapping */
2063 : 0 : rte_intr_efd_disable(intr_handle);
2064 : 0 : rte_intr_vec_list_free(intr_handle);
2065 : :
2066 : : /* reset hierarchy commit */
2067 : 0 : tm_conf->committed = false;
2068 : :
2069 : 0 : adapter->rss_reta_updated = 0;
2070 : : wr32m(hw, TXGBE_LEDCTL, 0xFFFFFFFF, TXGBE_LEDCTL_SEL_MASK);
2071 : :
2072 : 0 : txgbe_set_pcie_master(hw, true);
2073 : :
2074 : 0 : hw->adapter_stopped = true;
2075 : 0 : dev->data->dev_started = 0;
2076 : 0 : hw->dev_start = false;
2077 : :
2078 : 0 : out:
2079 : : /* close phy to prevent reset in dev_close from restarting physical link */
2080 [ # # ]: 0 : if (hw->phy.media_type == txgbe_media_type_copper) {
2081 : : /* Turn off the copper */
2082 : 0 : hw->phy.set_phy_power(hw, false);
2083 : : } else {
2084 : : /* Turn off the laser */
2085 : 0 : hw->mac.disable_tx_laser(hw);
2086 : : }
2087 : :
2088 : 0 : return 0;
2089 : : }
2090 : :
2091 : : /*
2092 : : * Set device link up: enable tx.
2093 : : */
2094 : : static int
2095 : 0 : txgbe_dev_set_link_up(struct rte_eth_dev *dev)
2096 : : {
2097 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2098 : :
2099 [ # # ]: 0 : if (hw->phy.media_type == txgbe_media_type_copper) {
2100 : : /* Turn on the copper */
2101 : 0 : hw->phy.set_phy_power(hw, true);
2102 : : } else {
2103 : : /* Turn on the laser */
2104 : 0 : hw->mac.enable_tx_laser(hw);
2105 : 0 : hw->dev_start = true;
2106 : : txgbe_dev_link_update(dev, 0);
2107 : : }
2108 : :
2109 : 0 : return 0;
2110 : : }
2111 : :
2112 : : /*
2113 : : * Set device link down: disable tx.
2114 : : */
2115 : : static int
2116 : 0 : txgbe_dev_set_link_down(struct rte_eth_dev *dev)
2117 : : {
2118 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2119 : :
2120 [ # # ]: 0 : if (hw->phy.media_type == txgbe_media_type_copper) {
2121 : : /* Turn off the copper */
2122 : 0 : hw->phy.set_phy_power(hw, false);
2123 : : } else {
2124 : : /* Turn off the laser */
2125 : 0 : hw->mac.disable_tx_laser(hw);
2126 : 0 : hw->dev_start = false;
2127 : : txgbe_dev_link_update(dev, 0);
2128 : : }
2129 : :
2130 : 0 : return 0;
2131 : : }
2132 : :
2133 : : /*
2134 : : * Reset and stop device.
2135 : : */
2136 : : static int
2137 : 0 : txgbe_dev_close(struct rte_eth_dev *dev)
2138 : : {
2139 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2140 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
2141 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
2142 : : int retries = 0;
2143 : : int ret;
2144 : :
2145 : 0 : PMD_INIT_FUNC_TRACE();
2146 : :
2147 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY)
2148 : : return 0;
2149 : :
2150 : 0 : txgbe_pf_reset_hw(hw);
2151 : :
2152 : 0 : ret = txgbe_dev_stop(dev);
2153 : :
2154 : : /* Let firmware take over control of hardware */
2155 : : wr32m(hw, TXGBE_PORTCTL, TXGBE_PORTCTL_DRVLOAD, 0);
2156 : :
2157 : 0 : txgbe_dev_free_queues(dev);
2158 : :
2159 : 0 : txgbe_set_pcie_master(hw, false);
2160 : :
2161 : : /* reprogram the RAR[0] in case user changed it. */
2162 : 0 : txgbe_set_rar(hw, 0, hw->mac.addr, 0, true);
2163 : :
2164 : : /* Unlock any pending hardware semaphore */
2165 : 0 : txgbe_swfw_lock_reset(hw);
2166 : :
2167 : : /* disable uio intr before callback unregister */
2168 : 0 : rte_intr_disable(intr_handle);
2169 : :
2170 : : do {
2171 : 0 : ret = rte_intr_callback_unregister(intr_handle,
2172 : : txgbe_dev_interrupt_handler, dev);
2173 [ # # ]: 0 : if (ret >= 0 || ret == -ENOENT) {
2174 : : break;
2175 [ # # ]: 0 : } else if (ret != -EAGAIN) {
2176 : 0 : PMD_INIT_LOG(ERR,
2177 : : "intr callback unregister failed: %d",
2178 : : ret);
2179 : : }
2180 : : rte_delay_ms(100);
2181 [ # # ]: 0 : } while (retries++ < (10 + TXGBE_LINK_UP_TIME));
2182 : :
2183 : : /* cancel all alarm handler before remove dev */
2184 : 0 : rte_eal_alarm_cancel(txgbe_dev_interrupt_delayed_handler, dev);
2185 : 0 : rte_eal_alarm_cancel(txgbe_dev_detect_sfp, dev);
2186 : 0 : rte_eal_alarm_cancel(txgbe_dev_setup_link_alarm_handler, dev);
2187 : :
2188 : : /* uninitialize PF if max_vfs not zero */
2189 : 0 : txgbe_pf_host_uninit(dev);
2190 : :
2191 : 0 : rte_free(dev->data->mac_addrs);
2192 : 0 : dev->data->mac_addrs = NULL;
2193 : :
2194 : 0 : rte_free(dev->data->hash_mac_addrs);
2195 : 0 : dev->data->hash_mac_addrs = NULL;
2196 : :
2197 : : /* remove all the fdir filters & hash */
2198 : 0 : txgbe_fdir_filter_uninit(dev);
2199 : :
2200 : : /* remove all the L2 tunnel filters & hash */
2201 : 0 : txgbe_l2_tn_filter_uninit(dev);
2202 : :
2203 : : /* Remove all ntuple filters of the device */
2204 : 0 : txgbe_ntuple_filter_uninit(dev);
2205 : :
2206 : : /* clear all the filters list */
2207 : 0 : txgbe_filterlist_flush();
2208 : :
2209 : : /* Remove all Traffic Manager configuration */
2210 : 0 : txgbe_tm_conf_uninit(dev);
2211 : :
2212 : : #ifdef RTE_LIB_SECURITY
2213 : 0 : rte_free(dev->security_ctx);
2214 : 0 : dev->security_ctx = NULL;
2215 : : #endif
2216 : :
2217 : 0 : return ret;
2218 : : }
2219 : :
2220 : : /*
2221 : : * Reset PF device.
2222 : : */
2223 : : static int
2224 : 0 : txgbe_dev_reset(struct rte_eth_dev *dev)
2225 : : {
2226 : : int ret;
2227 : :
2228 : : /* When a DPDK PMD PF begin to reset PF port, it should notify all
2229 : : * its VF to make them align with it. The detailed notification
2230 : : * mechanism is PMD specific. As to txgbe PF, it is rather complex.
2231 : : * To avoid unexpected behavior in VF, currently reset of PF with
2232 : : * SR-IOV activation is not supported. It might be supported later.
2233 : : */
2234 [ # # ]: 0 : if (dev->data->sriov.active)
2235 : : return -ENOTSUP;
2236 : :
2237 : 0 : ret = eth_txgbe_dev_uninit(dev);
2238 [ # # ]: 0 : if (ret)
2239 : : return ret;
2240 : :
2241 : 0 : ret = eth_txgbe_dev_init(dev, NULL);
2242 : :
2243 : 0 : return ret;
2244 : : }
2245 : :
2246 : : #define TXGBE_UPDATE_COUNTER_32BIT_GENERIC(reg, last, count, reset) \
2247 : : do { \
2248 : : uint32_t current = rd32(hw, reg); \
2249 : : if ((current) < (last)) \
2250 : : current += 0x100000000ULL; \
2251 : : if (reset) \
2252 : : (last) = current; \
2253 : : (count) = (uint32_t)((current) - (last)); \
2254 : : } while (0)
2255 : :
2256 : : #define UPDATE_QP_COUNTER_32bit(reg, last_counter, counter) \
2257 : : TXGBE_UPDATE_COUNTER_32BIT_GENERIC(reg, last_counter, counter, !hw->offset_loaded)
2258 : :
2259 : : #define UPDATE_QP_COUNTER_36bit(reg_lsb, reg_msb, last_counter, counter) \
2260 : : { \
2261 : : uint64_t current_counter_lsb = rd32(hw, reg_lsb); \
2262 : : uint64_t current_counter_msb = rd32(hw, reg_msb); \
2263 : : uint64_t current_counter = (current_counter_msb << 32) | \
2264 : : current_counter_lsb; \
2265 : : if (current_counter < last_counter) \
2266 : : current_counter += 0x1000000000LL; \
2267 : : if (!hw->offset_loaded) \
2268 : : last_counter = current_counter; \
2269 : : counter = current_counter - last_counter; \
2270 : : counter &= 0xFFFFFFFFFLL; \
2271 : : }
2272 : :
2273 : : void
2274 : 0 : txgbe_read_stats_registers(struct txgbe_hw *hw,
2275 : : struct txgbe_hw_stats *hw_stats)
2276 : : {
2277 : : unsigned int i;
2278 : :
2279 : : /* QP Stats */
2280 [ # # ]: 0 : for (i = 0; i < hw->nb_rx_queues; i++) {
2281 [ # # ]: 0 : UPDATE_QP_COUNTER_32bit(TXGBE_QPRXPKT(i),
2282 : : hw->qp_last[i].rx_qp_packets,
2283 : : hw_stats->qp[i].rx_qp_packets);
2284 [ # # # # ]: 0 : UPDATE_QP_COUNTER_36bit(TXGBE_QPRXOCTL(i), TXGBE_QPRXOCTH(i),
2285 : : hw->qp_last[i].rx_qp_bytes,
2286 : : hw_stats->qp[i].rx_qp_bytes);
2287 [ # # ]: 0 : UPDATE_QP_COUNTER_32bit(TXGBE_QPRXMPKT(i),
2288 : : hw->qp_last[i].rx_qp_mc_packets,
2289 : : hw_stats->qp[i].rx_qp_mc_packets);
2290 : : }
2291 : :
2292 [ # # ]: 0 : for (i = 0; i < hw->nb_tx_queues; i++) {
2293 [ # # ]: 0 : UPDATE_QP_COUNTER_32bit(TXGBE_QPTXPKT(i),
2294 : : hw->qp_last[i].tx_qp_packets,
2295 : : hw_stats->qp[i].tx_qp_packets);
2296 [ # # # # ]: 0 : UPDATE_QP_COUNTER_36bit(TXGBE_QPTXOCTL(i), TXGBE_QPTXOCTH(i),
2297 : : hw->qp_last[i].tx_qp_bytes,
2298 : : hw_stats->qp[i].tx_qp_bytes);
2299 : : }
2300 : : /* PB Stats */
2301 [ # # ]: 0 : for (i = 0; i < TXGBE_MAX_UP; i++) {
2302 : 0 : hw_stats->up[i].rx_up_xon_packets +=
2303 : 0 : rd32(hw, TXGBE_PBRXUPXON(i));
2304 : 0 : hw_stats->up[i].rx_up_xoff_packets +=
2305 : 0 : rd32(hw, TXGBE_PBRXUPXOFF(i));
2306 : 0 : hw_stats->up[i].tx_up_xon_packets +=
2307 : 0 : rd32(hw, TXGBE_PBTXUPXON(i));
2308 : 0 : hw_stats->up[i].tx_up_xoff_packets +=
2309 : 0 : rd32(hw, TXGBE_PBTXUPXOFF(i));
2310 : 0 : hw_stats->up[i].tx_up_xon2off_packets +=
2311 : 0 : rd32(hw, TXGBE_PBTXUPOFF(i));
2312 : 0 : hw_stats->up[i].rx_up_dropped +=
2313 : 0 : rd32(hw, TXGBE_PBRXMISS(i));
2314 : : }
2315 : :
2316 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) {
2317 [ # # ]: 0 : TXGBE_UPDATE_COUNTER_32BIT_GENERIC(TXGBE_PBRXLNKXON_AML,
2318 : : hw->last_stats.rx_xon_packets,
2319 : : hw_stats->rx_xon_packets, !hw->offset_loaded);
2320 [ # # ]: 0 : TXGBE_UPDATE_COUNTER_32BIT_GENERIC(TXGBE_PBRXLNKXOFF_AML,
2321 : : hw->last_stats.rx_xoff_packets,
2322 : : hw_stats->rx_xoff_packets, !hw->offset_loaded);
2323 : : } else {
2324 : 0 : hw_stats->rx_xon_packets += rd32(hw, TXGBE_PBRXLNKXON);
2325 : 0 : hw_stats->rx_xoff_packets += rd32(hw, TXGBE_PBRXLNKXOFF);
2326 : : }
2327 : 0 : hw_stats->tx_xon_packets += rd32(hw, TXGBE_PBTXLNKXON);
2328 : 0 : hw_stats->tx_xoff_packets += rd32(hw, TXGBE_PBTXLNKXOFF);
2329 : :
2330 : : /* DMA Stats */
2331 : 0 : hw_stats->rx_packets += rd32(hw, TXGBE_DMARXPKT);
2332 : 0 : hw_stats->tx_packets += rd32(hw, TXGBE_DMATXPKT);
2333 : :
2334 : 0 : hw_stats->rx_bytes += rd64(hw, TXGBE_DMARXOCTL);
2335 : 0 : hw_stats->tx_bytes += rd64(hw, TXGBE_DMATXOCTL);
2336 : 0 : hw_stats->rx_dma_drop += rd32(hw, TXGBE_DMARXDROP);
2337 : 0 : hw_stats->rx_rdb_drop += rd32(hw, TXGBE_PBRXDROP);
2338 : :
2339 : : /* MAC Stats */
2340 : 0 : hw_stats->rx_crc_errors += rd64(hw, TXGBE_MACRXERRCRCL);
2341 : 0 : hw_stats->rx_multicast_packets += rd64(hw, TXGBE_MACRXMPKTL);
2342 : 0 : hw_stats->tx_multicast_packets += rd64(hw, TXGBE_MACTXMPKTL);
2343 : :
2344 : 0 : hw_stats->rx_total_packets += rd64(hw, TXGBE_MACRXPKTL);
2345 : 0 : hw_stats->tx_total_packets += rd64(hw, TXGBE_MACTXPKTL);
2346 : 0 : hw_stats->rx_total_bytes += rd64(hw, TXGBE_MACRXGBOCTL);
2347 : :
2348 : 0 : hw_stats->rx_broadcast_packets += rd64(hw, TXGBE_MACRXOCTL);
2349 : 0 : hw_stats->tx_broadcast_packets += rd64(hw, TXGBE_MACTXOCTL);
2350 : :
2351 : 0 : hw_stats->rx_size_64_packets += rd64(hw, TXGBE_MACRX1TO64L);
2352 : 0 : hw_stats->rx_size_65_to_127_packets += rd64(hw, TXGBE_MACRX65TO127L);
2353 : 0 : hw_stats->rx_size_128_to_255_packets += rd64(hw, TXGBE_MACRX128TO255L);
2354 : 0 : hw_stats->rx_size_256_to_511_packets += rd64(hw, TXGBE_MACRX256TO511L);
2355 : 0 : hw_stats->rx_size_512_to_1023_packets +=
2356 : : rd64(hw, TXGBE_MACRX512TO1023L);
2357 : 0 : hw_stats->rx_size_1024_to_max_packets +=
2358 : : rd64(hw, TXGBE_MACRX1024TOMAXL);
2359 : 0 : hw_stats->tx_size_64_packets += rd64(hw, TXGBE_MACTX1TO64L);
2360 : 0 : hw_stats->tx_size_65_to_127_packets += rd64(hw, TXGBE_MACTX65TO127L);
2361 : 0 : hw_stats->tx_size_128_to_255_packets += rd64(hw, TXGBE_MACTX128TO255L);
2362 : 0 : hw_stats->tx_size_256_to_511_packets += rd64(hw, TXGBE_MACTX256TO511L);
2363 : 0 : hw_stats->tx_size_512_to_1023_packets +=
2364 : : rd64(hw, TXGBE_MACTX512TO1023L);
2365 : 0 : hw_stats->tx_size_1024_to_max_packets +=
2366 : : rd64(hw, TXGBE_MACTX1024TOMAXL);
2367 : :
2368 : 0 : hw_stats->rx_length_errors += rd64(hw, TXGBE_MACRXERRLENL);
2369 : 0 : hw_stats->rx_undersize_errors += rd32(hw, TXGBE_MACRXUNDERSIZE);
2370 : 0 : hw_stats->rx_oversize_cnt += rd32(hw, TXGBE_MACRXOVERSIZE);
2371 : 0 : hw_stats->rx_jabber_errors += rd32(hw, TXGBE_MACRXJABBER);
2372 : :
2373 : : /* MNG Stats */
2374 : 0 : hw_stats->mng_bmc2host_packets = rd32(hw, TXGBE_MNGBMC2OS);
2375 : 0 : hw_stats->mng_host2bmc_packets = rd32(hw, TXGBE_MNGOS2BMC);
2376 : 0 : hw_stats->rx_management_packets = rd32(hw, TXGBE_DMARXMNG);
2377 : 0 : hw_stats->tx_management_packets = rd32(hw, TXGBE_DMATXMNG);
2378 : :
2379 : : /* FCoE Stats */
2380 : 0 : hw_stats->rx_fcoe_crc_errors += rd32(hw, TXGBE_FCOECRC);
2381 : 0 : hw_stats->rx_fcoe_mbuf_allocation_errors += rd32(hw, TXGBE_FCOELAST);
2382 : 0 : hw_stats->rx_fcoe_dropped += rd32(hw, TXGBE_FCOERPDC);
2383 : 0 : hw_stats->rx_fcoe_packets += rd32(hw, TXGBE_FCOEPRC);
2384 : 0 : hw_stats->tx_fcoe_packets += rd32(hw, TXGBE_FCOEPTC);
2385 : 0 : hw_stats->rx_fcoe_bytes += rd32(hw, TXGBE_FCOEDWRC);
2386 : 0 : hw_stats->tx_fcoe_bytes += rd32(hw, TXGBE_FCOEDWTC);
2387 : :
2388 : : /* Flow Director Stats */
2389 : 0 : hw_stats->flow_director_matched_filters += rd32(hw, TXGBE_FDIRMATCH);
2390 : 0 : hw_stats->flow_director_missed_filters += rd32(hw, TXGBE_FDIRMISS);
2391 : 0 : hw_stats->flow_director_added_filters +=
2392 : 0 : TXGBE_FDIRUSED_ADD(rd32(hw, TXGBE_FDIRUSED));
2393 : 0 : hw_stats->flow_director_removed_filters +=
2394 : 0 : TXGBE_FDIRUSED_REM(rd32(hw, TXGBE_FDIRUSED));
2395 : 0 : hw_stats->flow_director_filter_add_errors +=
2396 : 0 : TXGBE_FDIRFAIL_ADD(rd32(hw, TXGBE_FDIRFAIL));
2397 : 0 : hw_stats->flow_director_filter_remove_errors +=
2398 : 0 : TXGBE_FDIRFAIL_REM(rd32(hw, TXGBE_FDIRFAIL));
2399 : :
2400 : : /* MACsec Stats */
2401 : 0 : hw_stats->tx_macsec_pkts_untagged += rd32(hw, TXGBE_LSECTX_UTPKT);
2402 : 0 : hw_stats->tx_macsec_pkts_encrypted +=
2403 : 0 : rd32(hw, TXGBE_LSECTX_ENCPKT);
2404 : 0 : hw_stats->tx_macsec_pkts_protected +=
2405 : 0 : rd32(hw, TXGBE_LSECTX_PROTPKT);
2406 : 0 : hw_stats->tx_macsec_octets_encrypted +=
2407 : 0 : rd32(hw, TXGBE_LSECTX_ENCOCT);
2408 : 0 : hw_stats->tx_macsec_octets_protected +=
2409 : 0 : rd32(hw, TXGBE_LSECTX_PROTOCT);
2410 : 0 : hw_stats->rx_macsec_pkts_untagged += rd32(hw, TXGBE_LSECRX_UTPKT);
2411 : 0 : hw_stats->rx_macsec_pkts_badtag += rd32(hw, TXGBE_LSECRX_BTPKT);
2412 : 0 : hw_stats->rx_macsec_pkts_nosci += rd32(hw, TXGBE_LSECRX_NOSCIPKT);
2413 : 0 : hw_stats->rx_macsec_pkts_unknownsci += rd32(hw, TXGBE_LSECRX_UNSCIPKT);
2414 : 0 : hw_stats->rx_macsec_octets_decrypted += rd32(hw, TXGBE_LSECRX_DECOCT);
2415 : 0 : hw_stats->rx_macsec_octets_validated += rd32(hw, TXGBE_LSECRX_VLDOCT);
2416 : 0 : hw_stats->rx_macsec_sc_pkts_unchecked +=
2417 : 0 : rd32(hw, TXGBE_LSECRX_UNCHKPKT);
2418 : 0 : hw_stats->rx_macsec_sc_pkts_delayed += rd32(hw, TXGBE_LSECRX_DLYPKT);
2419 : 0 : hw_stats->rx_macsec_sc_pkts_late += rd32(hw, TXGBE_LSECRX_LATEPKT);
2420 [ # # ]: 0 : for (i = 0; i < 2; i++) {
2421 : 0 : hw_stats->rx_macsec_sa_pkts_ok +=
2422 : 0 : rd32(hw, TXGBE_LSECRX_OKPKT(i));
2423 : 0 : hw_stats->rx_macsec_sa_pkts_invalid +=
2424 : 0 : rd32(hw, TXGBE_LSECRX_INVPKT(i));
2425 : 0 : hw_stats->rx_macsec_sa_pkts_notvalid +=
2426 : 0 : rd32(hw, TXGBE_LSECRX_BADPKT(i));
2427 : : }
2428 : 0 : hw_stats->rx_macsec_sa_pkts_unusedsa +=
2429 : 0 : rd32(hw, TXGBE_LSECRX_INVSAPKT);
2430 : 0 : hw_stats->rx_macsec_sa_pkts_notusingsa +=
2431 : 0 : rd32(hw, TXGBE_LSECRX_BADSAPKT);
2432 : :
2433 : 0 : hw_stats->rx_total_missed_packets = 0;
2434 [ # # ]: 0 : for (i = 0; i < TXGBE_MAX_UP; i++) {
2435 : 0 : hw_stats->rx_total_missed_packets +=
2436 : 0 : hw_stats->up[i].rx_up_dropped;
2437 : : }
2438 : 0 : }
2439 : :
2440 : : static int
2441 : 0 : txgbe_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats,
2442 : : struct eth_queue_stats *qstats)
2443 : : {
2444 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2445 : 0 : struct txgbe_hw_stats *hw_stats = TXGBE_DEV_STATS(dev);
2446 : : struct txgbe_tx_queue *txq;
2447 : : unsigned int i;
2448 : :
2449 : 0 : txgbe_read_stats_registers(hw, hw_stats);
2450 : :
2451 [ # # ]: 0 : if (stats == NULL)
2452 : : return -EINVAL;
2453 : :
2454 : : /* Fill out the rte_eth_stats statistics structure */
2455 : 0 : stats->ipackets = hw_stats->rx_packets;
2456 : 0 : stats->ibytes = hw_stats->rx_bytes;
2457 : 0 : stats->opackets = hw_stats->tx_packets;
2458 : 0 : stats->obytes = hw_stats->tx_bytes;
2459 : :
2460 [ # # ]: 0 : if (qstats != NULL) {
2461 [ # # # # ]: 0 : for (i = 0; i < TXGBE_MAX_QP && i < dev->data->nb_rx_queues; i++) {
2462 : 0 : qstats[i].q_ipackets += hw_stats->qp[i].rx_qp_packets;
2463 : 0 : qstats[i].q_ibytes += hw_stats->qp[i].rx_qp_bytes;
2464 : : }
2465 [ # # # # ]: 0 : for (i = 0; i < TXGBE_MAX_QP && i < dev->data->nb_tx_queues; i++) {
2466 : 0 : qstats[i].q_opackets += hw_stats->qp[i].tx_qp_packets;
2467 : 0 : qstats[i].q_obytes += hw_stats->qp[i].tx_qp_bytes;
2468 : : }
2469 : : }
2470 : :
2471 : : /* Rx Errors */
2472 : 0 : stats->imissed = hw_stats->rx_total_missed_packets +
2473 : 0 : hw_stats->rx_dma_drop;
2474 : 0 : stats->ierrors = hw_stats->rx_crc_errors +
2475 : 0 : hw_stats->rx_mac_short_packet_dropped +
2476 : 0 : hw_stats->rx_length_errors +
2477 : 0 : hw_stats->rx_undersize_errors +
2478 : 0 : hw_stats->rx_rdb_drop +
2479 : 0 : hw_stats->rx_illegal_byte_errors +
2480 : 0 : hw_stats->rx_error_bytes +
2481 : 0 : hw_stats->rx_fragment_errors +
2482 : 0 : hw_stats->rx_fcoe_crc_errors +
2483 : 0 : hw_stats->rx_fcoe_mbuf_allocation_errors;
2484 : :
2485 : : /* Tx Errors */
2486 : 0 : stats->oerrors = 0;
2487 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
2488 : 0 : txq = dev->data->tx_queues[i];
2489 : 0 : stats->oerrors += txq->desc_error;
2490 : : }
2491 : :
2492 : : return 0;
2493 : : }
2494 : :
2495 : : static int
2496 : 0 : txgbe_dev_stats_reset(struct rte_eth_dev *dev)
2497 : : {
2498 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2499 : 0 : struct txgbe_hw_stats *hw_stats = TXGBE_DEV_STATS(dev);
2500 : : struct txgbe_tx_queue *txq;
2501 : : uint32_t i;
2502 : :
2503 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
2504 : 0 : txq = dev->data->tx_queues[i];
2505 : 0 : txq->desc_error = 0;
2506 : : }
2507 : :
2508 : : /* HW registers are cleared on read */
2509 : 0 : hw->offset_loaded = 0;
2510 : : txgbe_dev_stats_get(dev, NULL, NULL);
2511 : 0 : hw->offset_loaded = 1;
2512 : :
2513 : : /* Reset software totals */
2514 : : memset(hw_stats, 0, sizeof(*hw_stats));
2515 : :
2516 : 0 : return 0;
2517 : : }
2518 : :
2519 : : /* This function calculates the number of xstats based on the current config */
2520 : : static unsigned
2521 : : txgbe_xstats_calc_num(struct rte_eth_dev *dev)
2522 : : {
2523 : 0 : int nb_queues = max(dev->data->nb_rx_queues, dev->data->nb_tx_queues);
2524 : : return TXGBE_NB_HW_STATS +
2525 : 0 : TXGBE_NB_UP_STATS * TXGBE_MAX_UP +
2526 : : TXGBE_NB_QP_STATS * nb_queues;
2527 : : }
2528 : :
2529 : : static inline int
2530 : 0 : txgbe_get_name_by_id(uint32_t id, char *name, uint32_t size)
2531 : : {
2532 : : int nb, st;
2533 : :
2534 : : /* Extended stats from txgbe_hw_stats */
2535 [ # # ]: 0 : if (id < TXGBE_NB_HW_STATS) {
2536 : 0 : snprintf(name, size, "[hw]%s",
2537 : 0 : rte_txgbe_stats_strings[id].name);
2538 : 0 : return 0;
2539 : : }
2540 : 0 : id -= TXGBE_NB_HW_STATS;
2541 : :
2542 : : /* Priority Stats */
2543 [ # # ]: 0 : if (id < TXGBE_NB_UP_STATS * TXGBE_MAX_UP) {
2544 : 0 : nb = id / TXGBE_NB_UP_STATS;
2545 : 0 : st = id % TXGBE_NB_UP_STATS;
2546 : 0 : snprintf(name, size, "[p%u]%s", nb,
2547 : 0 : rte_txgbe_up_strings[st].name);
2548 : 0 : return 0;
2549 : : }
2550 : 0 : id -= TXGBE_NB_UP_STATS * TXGBE_MAX_UP;
2551 : :
2552 : : /* Queue Stats */
2553 [ # # ]: 0 : if (id < TXGBE_NB_QP_STATS * TXGBE_MAX_QP) {
2554 : 0 : nb = id / TXGBE_NB_QP_STATS;
2555 : 0 : st = id % TXGBE_NB_QP_STATS;
2556 : 0 : snprintf(name, size, "[q%u]%s", nb,
2557 : 0 : rte_txgbe_qp_strings[st].name);
2558 : 0 : return 0;
2559 : : }
2560 : : id -= TXGBE_NB_QP_STATS * TXGBE_MAX_QP;
2561 : :
2562 : 0 : return -(int)(id + 1);
2563 : : }
2564 : :
2565 : : static inline int
2566 : 0 : txgbe_get_offset_by_id(uint32_t id, uint32_t *offset)
2567 : : {
2568 : : int nb, st;
2569 : :
2570 : : /* Extended stats from txgbe_hw_stats */
2571 [ # # ]: 0 : if (id < TXGBE_NB_HW_STATS) {
2572 : 0 : *offset = rte_txgbe_stats_strings[id].offset;
2573 : 0 : return 0;
2574 : : }
2575 : 0 : id -= TXGBE_NB_HW_STATS;
2576 : :
2577 : : /* Priority Stats */
2578 [ # # ]: 0 : if (id < TXGBE_NB_UP_STATS * TXGBE_MAX_UP) {
2579 : 0 : nb = id / TXGBE_NB_UP_STATS;
2580 : 0 : st = id % TXGBE_NB_UP_STATS;
2581 : 0 : *offset = rte_txgbe_up_strings[st].offset +
2582 : : nb * (TXGBE_NB_UP_STATS * sizeof(uint64_t));
2583 : 0 : return 0;
2584 : : }
2585 : 0 : id -= TXGBE_NB_UP_STATS * TXGBE_MAX_UP;
2586 : :
2587 : : /* Queue Stats */
2588 [ # # ]: 0 : if (id < TXGBE_NB_QP_STATS * TXGBE_MAX_QP) {
2589 : 0 : nb = id / TXGBE_NB_QP_STATS;
2590 : 0 : st = id % TXGBE_NB_QP_STATS;
2591 : 0 : *offset = rte_txgbe_qp_strings[st].offset +
2592 : : nb * (TXGBE_NB_QP_STATS * sizeof(uint64_t));
2593 : 0 : return 0;
2594 : : }
2595 : :
2596 : : return -1;
2597 : : }
2598 : :
2599 : 0 : static int txgbe_dev_xstats_get_names(struct rte_eth_dev *dev,
2600 : : struct rte_eth_xstat_name *xstats_names, unsigned int limit)
2601 : : {
2602 : : unsigned int i, count;
2603 : :
2604 : : count = txgbe_xstats_calc_num(dev);
2605 [ # # ]: 0 : if (xstats_names == NULL)
2606 : 0 : return count;
2607 : :
2608 : : /* Note: limit >= cnt_stats checked upstream
2609 : : * in rte_eth_xstats_names()
2610 : : */
2611 : 0 : limit = min(limit, count);
2612 : :
2613 : : /* Extended stats from txgbe_hw_stats */
2614 [ # # ]: 0 : for (i = 0; i < limit; i++) {
2615 [ # # ]: 0 : if (txgbe_get_name_by_id(i, xstats_names[i].name,
2616 : : sizeof(xstats_names[i].name))) {
2617 : 0 : PMD_INIT_LOG(WARNING, "id value %d isn't valid", i);
2618 : 0 : break;
2619 : : }
2620 : : }
2621 : :
2622 : 0 : return i;
2623 : : }
2624 : :
2625 : 0 : static int txgbe_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
2626 : : const uint64_t *ids,
2627 : : struct rte_eth_xstat_name *xstats_names,
2628 : : unsigned int limit)
2629 : : {
2630 : : unsigned int i;
2631 : :
2632 [ # # ]: 0 : if (ids == NULL)
2633 : 0 : return txgbe_dev_xstats_get_names(dev, xstats_names, limit);
2634 : :
2635 [ # # ]: 0 : for (i = 0; i < limit; i++) {
2636 [ # # ]: 0 : if (txgbe_get_name_by_id(ids[i], xstats_names[i].name,
2637 : : sizeof(xstats_names[i].name))) {
2638 : 0 : PMD_INIT_LOG(WARNING, "id value %d isn't valid", i);
2639 : 0 : return -1;
2640 : : }
2641 : : }
2642 : :
2643 : 0 : return i;
2644 : : }
2645 : :
2646 : : static int
2647 : 0 : txgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
2648 : : unsigned int limit)
2649 : : {
2650 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2651 : 0 : struct txgbe_hw_stats *hw_stats = TXGBE_DEV_STATS(dev);
2652 : : struct txgbe_rx_queue *rxq;
2653 : : uint64_t rx_csum_err = 0;
2654 : : unsigned int i, count;
2655 : :
2656 : 0 : txgbe_read_stats_registers(hw, hw_stats);
2657 : :
2658 : : /* If this is a reset xstats is NULL, and we have cleared the
2659 : : * registers by reading them.
2660 : : */
2661 : : count = txgbe_xstats_calc_num(dev);
2662 [ # # ]: 0 : if (xstats == NULL)
2663 : 0 : return count;
2664 : :
2665 : 0 : limit = min(limit, txgbe_xstats_calc_num(dev));
2666 : :
2667 : : /* Rx Checksum Errors */
2668 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
2669 : 0 : rxq = dev->data->rx_queues[i];
2670 : 0 : rx_csum_err += rxq->csum_err;
2671 : : }
2672 : 0 : hw_stats->rx_l3_l4_xsum_error = rx_csum_err;
2673 : :
2674 : : /* Extended stats from txgbe_hw_stats */
2675 [ # # ]: 0 : for (i = 0; i < limit; i++) {
2676 : 0 : uint32_t offset = 0;
2677 : :
2678 [ # # ]: 0 : if (txgbe_get_offset_by_id(i, &offset)) {
2679 : 0 : PMD_INIT_LOG(WARNING, "id value %d isn't valid", i);
2680 : 0 : break;
2681 : : }
2682 : 0 : xstats[i].value = *(uint64_t *)(((char *)hw_stats) + offset);
2683 : 0 : xstats[i].id = i;
2684 : : }
2685 : :
2686 : 0 : return i;
2687 : : }
2688 : :
2689 : : static int
2690 : 0 : txgbe_dev_xstats_get_(struct rte_eth_dev *dev, uint64_t *values,
2691 : : unsigned int limit)
2692 : : {
2693 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2694 : 0 : struct txgbe_hw_stats *hw_stats = TXGBE_DEV_STATS(dev);
2695 : : unsigned int i, count;
2696 : :
2697 : 0 : txgbe_read_stats_registers(hw, hw_stats);
2698 : :
2699 : : /* If this is a reset xstats is NULL, and we have cleared the
2700 : : * registers by reading them.
2701 : : */
2702 : : count = txgbe_xstats_calc_num(dev);
2703 [ # # ]: 0 : if (values == NULL)
2704 : 0 : return count;
2705 : :
2706 : 0 : limit = min(limit, txgbe_xstats_calc_num(dev));
2707 : :
2708 : : /* Extended stats from txgbe_hw_stats */
2709 [ # # ]: 0 : for (i = 0; i < limit; i++) {
2710 : : uint32_t offset;
2711 : :
2712 [ # # ]: 0 : if (txgbe_get_offset_by_id(i, &offset)) {
2713 : 0 : PMD_INIT_LOG(WARNING, "id value %d isn't valid", i);
2714 : 0 : break;
2715 : : }
2716 : 0 : values[i] = *(uint64_t *)(((char *)hw_stats) + offset);
2717 : : }
2718 : :
2719 : 0 : return i;
2720 : : }
2721 : :
2722 : : static int
2723 : 0 : txgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
2724 : : uint64_t *values, unsigned int limit)
2725 : : {
2726 : 0 : struct txgbe_hw_stats *hw_stats = TXGBE_DEV_STATS(dev);
2727 : : unsigned int i;
2728 : :
2729 [ # # ]: 0 : if (ids == NULL)
2730 : 0 : return txgbe_dev_xstats_get_(dev, values, limit);
2731 : :
2732 [ # # ]: 0 : for (i = 0; i < limit; i++) {
2733 : : uint32_t offset;
2734 : :
2735 [ # # ]: 0 : if (txgbe_get_offset_by_id(ids[i], &offset)) {
2736 : 0 : PMD_INIT_LOG(WARNING, "id value %d isn't valid", i);
2737 : 0 : break;
2738 : : }
2739 : 0 : values[i] = *(uint64_t *)(((char *)hw_stats) + offset);
2740 : : }
2741 : :
2742 : 0 : return i;
2743 : : }
2744 : :
2745 : : static int
2746 : 0 : txgbe_dev_xstats_reset(struct rte_eth_dev *dev)
2747 : : {
2748 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2749 : 0 : struct txgbe_hw_stats *hw_stats = TXGBE_DEV_STATS(dev);
2750 : : struct txgbe_rx_queue *rxq;
2751 : : int i = 0;
2752 : :
2753 : : /* HW registers are cleared on read */
2754 : 0 : hw->offset_loaded = 0;
2755 : 0 : txgbe_read_stats_registers(hw, hw_stats);
2756 : 0 : hw->offset_loaded = 1;
2757 : :
2758 : : /* Reset software totals */
2759 : : memset(hw_stats, 0, sizeof(*hw_stats));
2760 : :
2761 : : /* Reset rxq checksum errors */
2762 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
2763 : 0 : rxq = dev->data->rx_queues[i];
2764 : 0 : rxq->csum_err = 0;
2765 : : }
2766 : :
2767 : 0 : return 0;
2768 : : }
2769 : :
2770 : : static int
2771 : 0 : txgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
2772 : : {
2773 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2774 : : u32 etrack_id;
2775 : : int ret;
2776 : :
2777 : 0 : hw->phy.get_fw_version(hw, &etrack_id);
2778 : :
2779 [ # # ]: 0 : ret = snprintf(fw_version, fw_size, "0x%08x", etrack_id);
2780 [ # # ]: 0 : if (ret < 0)
2781 : : return -EINVAL;
2782 : :
2783 : 0 : ret += 1; /* add the size of '\0' */
2784 [ # # ]: 0 : if (fw_size < (size_t)ret)
2785 : : return ret;
2786 : : else
2787 : 0 : return 0;
2788 : : }
2789 : :
2790 : : static int
2791 : 0 : txgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
2792 : : {
2793 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
2794 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2795 : :
2796 : 0 : dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
2797 : 0 : dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
2798 : 0 : dev_info->min_rx_bufsize = 1024;
2799 : 0 : dev_info->max_rx_pktlen = TXGBE_MAX_MTU + TXGBE_ETH_OVERHEAD;
2800 : 0 : dev_info->min_mtu = RTE_ETHER_MIN_MTU;
2801 : 0 : dev_info->max_mtu = TXGBE_MAX_MTU;
2802 : 0 : dev_info->max_mac_addrs = hw->mac.num_rar_entries;
2803 : 0 : dev_info->max_hash_mac_addrs = TXGBE_VMDQ_NUM_UC_MAC;
2804 : 0 : dev_info->max_vfs = pci_dev->max_vfs;
2805 : 0 : dev_info->max_vmdq_pools = RTE_ETH_64_POOLS;
2806 : 0 : dev_info->vmdq_queue_num = dev_info->max_rx_queues;
2807 : 0 : dev_info->dev_capa &= ~RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP;
2808 : 0 : dev_info->rx_queue_offload_capa = txgbe_get_rx_queue_offloads(dev);
2809 : 0 : dev_info->rx_offload_capa = (txgbe_get_rx_port_offloads(dev) |
2810 : 0 : dev_info->rx_queue_offload_capa);
2811 : 0 : dev_info->tx_queue_offload_capa = txgbe_get_tx_queue_offloads(dev);
2812 : 0 : dev_info->tx_offload_capa = txgbe_get_tx_port_offloads(dev);
2813 : :
2814 : 0 : dev_info->default_rxconf = (struct rte_eth_rxconf) {
2815 : : .rx_thresh = {
2816 : : .pthresh = TXGBE_DEFAULT_RX_PTHRESH,
2817 : : .hthresh = TXGBE_DEFAULT_RX_HTHRESH,
2818 : : .wthresh = TXGBE_DEFAULT_RX_WTHRESH,
2819 : : },
2820 : : .rx_free_thresh = TXGBE_DEFAULT_RX_FREE_THRESH,
2821 : : .rx_drop_en = 0,
2822 : : .offloads = 0,
2823 : : };
2824 : :
2825 : 0 : dev_info->default_txconf = (struct rte_eth_txconf) {
2826 : : .tx_thresh = {
2827 : : .pthresh = TXGBE_DEFAULT_TX_PTHRESH,
2828 : : .hthresh = TXGBE_DEFAULT_TX_HTHRESH,
2829 : : .wthresh = TXGBE_DEFAULT_TX_WTHRESH,
2830 : : },
2831 : : .tx_free_thresh = TXGBE_DEFAULT_TX_FREE_THRESH,
2832 : : .offloads = 0,
2833 : : };
2834 : :
2835 : 0 : dev_info->rx_desc_lim = rx_desc_lim;
2836 : 0 : dev_info->tx_desc_lim = tx_desc_lim;
2837 : :
2838 : 0 : dev_info->hash_key_size = TXGBE_HKEY_MAX_INDEX * sizeof(uint32_t);
2839 : 0 : dev_info->reta_size = RTE_ETH_RSS_RETA_SIZE_128;
2840 : 0 : dev_info->flow_type_rss_offloads = TXGBE_RSS_OFFLOAD_ALL;
2841 : :
2842 : : dev_info->speed_capa = RTE_ETH_LINK_SPEED_1G | RTE_ETH_LINK_SPEED_10G;
2843 : 0 : dev_info->speed_capa |= RTE_ETH_LINK_SPEED_100M;
2844 : :
2845 : : /* Driver-preferred Rx/Tx parameters */
2846 : 0 : dev_info->default_rxportconf.burst_size = 32;
2847 : 0 : dev_info->default_txportconf.burst_size = 32;
2848 : 0 : dev_info->default_rxportconf.nb_queues = 1;
2849 : 0 : dev_info->default_txportconf.nb_queues = 1;
2850 : 0 : dev_info->default_rxportconf.ring_size = 256;
2851 : 0 : dev_info->default_txportconf.ring_size = 256;
2852 : :
2853 : 0 : return 0;
2854 : : }
2855 : :
2856 : : const uint32_t *
2857 : 0 : txgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev, size_t *no_of_elements)
2858 : : {
2859 [ # # # # ]: 0 : if (dev->rx_pkt_burst == txgbe_recv_pkts ||
2860 : : #if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM)
2861 [ # # ]: 0 : dev->rx_pkt_burst == txgbe_recv_pkts_vec ||
2862 [ # # ]: 0 : dev->rx_pkt_burst == txgbe_recv_scattered_pkts_vec ||
2863 : : #endif
2864 [ # # ]: 0 : dev->rx_pkt_burst == txgbe_recv_pkts_lro_single_alloc ||
2865 [ # # ]: 0 : dev->rx_pkt_burst == txgbe_recv_pkts_lro_bulk_alloc ||
2866 : : dev->rx_pkt_burst == txgbe_recv_pkts_bulk_alloc)
2867 : 0 : return txgbe_get_supported_ptypes(no_of_elements);
2868 : :
2869 : : return NULL;
2870 : : }
2871 : :
2872 : 0 : void txgbe_dev_check_aml_temp_event(void *param)
2873 : : {
2874 : : struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
2875 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2876 : : uint32_t link_speed = 0, val = 0;
2877 : : s32 status = 0;
2878 : : int temp;
2879 : :
2880 [ # # ]: 0 : if (hw == NULL)
2881 : 0 : return;
2882 : :
2883 : 0 : status = txgbe_e56_get_temp(hw, &temp);
2884 [ # # ]: 0 : if (status)
2885 : 0 : temp = DEFAULT_TEMP;
2886 : :
2887 [ # # ]: 0 : if (!(temp - hw->temperature > 4 ||
2888 [ # # ]: 0 : hw->temperature - temp > 4))
2889 : 0 : goto out;
2890 : :
2891 : 0 : hw->temperature = temp;
2892 : : val = rd32(hw, TXGBE_PORT);
2893 [ # # ]: 0 : if (val & TXGBE_AMLITE_LED_LINK_40G)
2894 : : link_speed = TXGBE_LINK_SPEED_40GB_FULL;
2895 [ # # ]: 0 : else if (val & TXGBE_AMLITE_LED_LINK_25G)
2896 : : link_speed = TXGBE_LINK_SPEED_25GB_FULL;
2897 : : else
2898 : : link_speed = TXGBE_LINK_SPEED_10GB_FULL;
2899 : :
2900 : 0 : rte_spinlock_lock(&hw->phy_lock);
2901 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml)
2902 : 0 : txgbe_temp_track_seq(hw, link_speed);
2903 [ # # ]: 0 : else if (hw->mac.type == txgbe_mac_aml40)
2904 : 0 : txgbe_temp_track_seq_40g(hw, link_speed);
2905 : : rte_spinlock_unlock(&hw->phy_lock);
2906 : :
2907 : 0 : out:
2908 : 0 : rte_eal_alarm_set(1000 * 1000 * 2, txgbe_dev_check_aml_temp_event, dev);
2909 : : }
2910 : :
2911 : 0 : void txgbe_dev_e56_check_bp_event(void *param)
2912 : : {
2913 : : struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
2914 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2915 : : u32 an_int1 = 0, value = 0, fsm = 0;
2916 : : u32 __rte_unused an_int = 0;
2917 : : int ret = 0;
2918 : : bool need_link_update = false;
2919 : :
2920 [ # # ]: 0 : if (!hw)
2921 : : return;
2922 : :
2923 [ # # ]: 0 : if (!(txgbe_xpcs_an_enabled(hw)))
2924 : : return;
2925 : :
2926 [ # # ]: 0 : if (!hw->devarg.auto_neg)
2927 : : return;
2928 : :
2929 : : /* only continue if link is down */
2930 [ # # ]: 0 : if (dev->data->dev_link.link_status)
2931 : 0 : goto out;
2932 : :
2933 : : value = rd32_epcs(hw, VR_AN_INTR);
2934 : : an_int = value;
2935 [ # # ]: 0 : if (value & 0xF)
2936 : 0 : hw->bp_event_interval = 100 * 1000;
2937 : :
2938 [ # # ]: 0 : if (value & VR_AN_INTR_CMPLT) {
2939 : 0 : hw->an_done = true;
2940 : : need_link_update = true;
2941 : 0 : value &= ~VR_AN_INTR_CMPLT;
2942 : : wr32_epcs(hw, VR_AN_INTR, value);
2943 : : }
2944 : :
2945 [ # # ]: 0 : if (value & VR_AN_INTR_LINK) {
2946 : 0 : value &= ~VR_AN_INTR_LINK;
2947 : : wr32_epcs(hw, VR_AN_INTR, value);
2948 : : }
2949 : :
2950 [ # # ]: 0 : if (value & TXGBE_E56_AN_TXDIS) {
2951 : 0 : value &= ~TXGBE_E56_AN_TXDIS;
2952 : : wr32_epcs(hw, VR_AN_INTR, value);
2953 : 0 : rte_spinlock_lock(&hw->phy_lock);
2954 : 0 : txgbe_e56_set_phy_link_mode(hw, 10, hw->bypass_ctle);
2955 : : rte_spinlock_unlock(&hw->phy_lock);
2956 : 0 : goto an_status;
2957 : : }
2958 : :
2959 [ # # ]: 0 : if (value & VR_AN_INTR_PG_RCV) {
2960 : 0 : BP_LOG("%d Enter training\n", hw->port_id);
2961 : 0 : ret = txgbe_handle_e56_bkp_an73_flow(hw);
2962 : : if (!AN_TRAINING_MODE) {
2963 : : fsm = rd32_epcs(hw, 0x78010);
2964 [ # # ]: 0 : if (fsm & 0x8)
2965 : 0 : goto an_status;
2966 [ # # ]: 0 : if (ret) {
2967 : 0 : BP_LOG("Training FAILED, do reset\n");
2968 : 0 : rte_spinlock_lock(&hw->phy_lock);
2969 : 0 : txgbe_e56_set_phy_link_mode(hw, 10, hw->bypass_ctle);
2970 : : rte_spinlock_unlock(&hw->phy_lock);
2971 : : } else {
2972 : 0 : BP_LOG("ALL SUCCEEDED\n");
2973 : : }
2974 : : } else {
2975 : : if (ret) {
2976 : : BP_LOG("Training FAILED, do reset\n");
2977 : : rte_spinlock_lock(&hw->phy_lock);
2978 : : txgbe_e56_set_phy_link_mode(hw, 10, hw->bypass_ctle);
2979 : : rte_spinlock_unlock(&hw->phy_lock);
2980 : : } else {
2981 : : hw->an_done = true;
2982 : : }
2983 : : }
2984 : : }
2985 : :
2986 : 0 : an_status:
2987 : : an_int1 = rd32_epcs(hw, 0x78002);
2988 [ # # ]: 0 : if (an_int1 & VR_AN_INTR_CMPLT) {
2989 : 0 : hw->an_done = true;
2990 : : need_link_update = true;
2991 : : }
2992 : :
2993 : 0 : BP_LOG("%d RLU:%x MLU:%x INT:%x-%x CTL:%x fsm:%x pmd_cfg0:%x an_done:%d\n",
2994 : : hw->port_id, rd32_epcs(hw, 0x30001), rd32(hw, 0x14404),
2995 : : an_int, an_int1,
2996 : : rd32_epcs(hw, 0x70000),
2997 : : rd32_epcs(hw, 0x78010),
2998 : : rd32_ephy(hw, 0x1400),
2999 : : hw->an_done);
3000 : :
3001 [ # # ]: 0 : if (need_link_update)
3002 : : txgbe_dev_link_update(dev, 0);
3003 : :
3004 [ # # ]: 0 : if (dev->data->dev_link.link_status)
3005 : 0 : hw->bp_event_interval = 2000 * 1000;
3006 : :
3007 : 0 : out:
3008 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40)
3009 : 0 : rte_eal_alarm_set(hw->bp_event_interval, txgbe_dev_e56_check_bp_event, dev);
3010 : : }
3011 : :
3012 : : static void
3013 : 0 : txgbe_dev_detect_sfp(void *param)
3014 : : {
3015 : : struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
3016 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3017 : : u32 value = 0;
3018 : : s32 err;
3019 : :
3020 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml40) {
3021 : : value = rd32(hw, TXGBE_GPIOEXT);
3022 [ # # ]: 0 : if (value & TXGBE_SFP1_MOD_PRST_LS) {
3023 : : err = TXGBE_ERR_SFP_NOT_PRESENT;
3024 : 0 : goto out;
3025 : : }
3026 : : }
3027 : :
3028 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml) {
3029 : : value = rd32(hw, TXGBE_GPIOEXT);
3030 [ # # ]: 0 : if (value & TXGBE_SFP1_MOD_ABS_LS) {
3031 : : err = TXGBE_ERR_SFP_NOT_PRESENT;
3032 : 0 : goto out;
3033 : : }
3034 : : }
3035 : :
3036 : : /* wait for sfp module ready*/
3037 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40)
3038 : : msec_delay(200);
3039 : :
3040 : 0 : err = hw->phy.identify_sfp(hw);
3041 : : out:
3042 [ # # ]: 0 : if (err == TXGBE_ERR_SFP_NOT_SUPPORTED) {
3043 : 0 : PMD_DRV_LOG(ERR, "Unsupported SFP+ module type was detected.");
3044 [ # # ]: 0 : } else if (err == TXGBE_ERR_SFP_NOT_PRESENT) {
3045 : 0 : PMD_DRV_LOG(INFO, "SFP not present.");
3046 [ # # ]: 0 : } else if (err == 0) {
3047 : 0 : hw->mac.setup_sfp(hw);
3048 : 0 : PMD_DRV_LOG(INFO, "detected SFP+: %d", hw->phy.sfp_type);
3049 : 0 : txgbe_dev_setup_link_alarm_handler(dev);
3050 : : txgbe_dev_link_update(dev, 0);
3051 : : }
3052 : 0 : }
3053 : :
3054 : : static void
3055 : 0 : txgbe_dev_sfp_event(struct rte_eth_dev *dev)
3056 : : {
3057 : 0 : struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
3058 : : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3059 : : u32 reg;
3060 : :
3061 : : wr32(hw, TXGBE_GPIOINTMASK, 0xFF);
3062 : : reg = rd32(hw, TXGBE_GPIORAWINTSTAT);
3063 : :
3064 [ # # ]: 0 : if (reg & TXGBE_GPIOBIT_0)
3065 : : wr32(hw, TXGBE_GPIOEOI, TXGBE_GPIOBIT_0);
3066 [ # # ]: 0 : if (reg & TXGBE_GPIOBIT_2) {
3067 : : wr32(hw, TXGBE_GPIOEOI, TXGBE_GPIOBIT_2);
3068 : 0 : rte_eal_alarm_set(1000 * 100, txgbe_dev_detect_sfp, dev);
3069 : : }
3070 [ # # ]: 0 : if (reg & TXGBE_GPIOBIT_3) {
3071 : : wr32(hw, TXGBE_GPIOEOI, TXGBE_GPIOBIT_3);
3072 : 0 : intr->flags |= TXGBE_FLAG_NEED_LINK_UPDATE;
3073 : : }
3074 [ # # ]: 0 : if (reg & TXGBE_GPIOBIT_6) {
3075 : : wr32(hw, TXGBE_GPIOEOI, TXGBE_GPIOBIT_6);
3076 : 0 : intr->flags |= TXGBE_FLAG_NEED_LINK_UPDATE;
3077 : : }
3078 : :
3079 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml40) {
3080 [ # # ]: 0 : if (reg & TXGBE_GPIOBIT_4) {
3081 : : wr32(hw, TXGBE_GPIOEOI, TXGBE_GPIOBIT_4);
3082 : 0 : rte_eal_alarm_set(1000 * 100, txgbe_dev_detect_sfp, dev);
3083 : : }
3084 [ # # ]: 0 : } else if (hw->mac.type == txgbe_mac_sp || hw->mac.type == txgbe_mac_aml) {
3085 [ # # ]: 0 : if (reg & TXGBE_GPIOBIT_0)
3086 : : wr32(hw, TXGBE_GPIOEOI, TXGBE_GPIOBIT_0);
3087 [ # # ]: 0 : if (reg & TXGBE_GPIOBIT_2) {
3088 : : wr32(hw, TXGBE_GPIOEOI, TXGBE_GPIOBIT_2);
3089 : 0 : rte_eal_alarm_set(1000 * 100, txgbe_dev_detect_sfp, dev);
3090 : : }
3091 [ # # ]: 0 : if (reg & TXGBE_GPIOBIT_3) {
3092 : : wr32(hw, TXGBE_GPIOEOI, TXGBE_GPIOBIT_3);
3093 : 0 : intr->flags |= TXGBE_FLAG_NEED_LINK_UPDATE;
3094 : : }
3095 [ # # ]: 0 : if (reg & TXGBE_GPIOBIT_6) {
3096 : : wr32(hw, TXGBE_GPIOEOI, TXGBE_GPIOBIT_6);
3097 : 0 : intr->flags |= TXGBE_FLAG_NEED_LINK_UPDATE;
3098 : : }
3099 : : }
3100 : : wr32(hw, TXGBE_GPIOINTMASK, 0);
3101 : 0 : }
3102 : :
3103 : : static void
3104 : 0 : txgbe_dev_overheat(struct rte_eth_dev *dev)
3105 : : {
3106 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3107 : : s32 temp_state;
3108 : :
3109 : 0 : temp_state = hw->phy.check_overtemp(hw);
3110 [ # # ]: 0 : if (!temp_state)
3111 : : return;
3112 : :
3113 [ # # ]: 0 : if (temp_state == TXGBE_ERR_UNDERTEMP) {
3114 : 0 : PMD_DRV_LOG(CRIT, "Network adapter has been started again, "
3115 : : "since the temperature has been back to normal state.");
3116 : : wr32m(hw, TXGBE_PBRXCTL, TXGBE_PBRXCTL_ENA, TXGBE_PBRXCTL_ENA);
3117 : 0 : txgbe_dev_set_link_up(dev);
3118 [ # # ]: 0 : } else if (temp_state == TXGBE_ERR_OVERTEMP) {
3119 : 0 : PMD_DRV_LOG(CRIT, "Network adapter has been stopped because it has over heated.");
3120 : : wr32m(hw, TXGBE_PBRXCTL, TXGBE_PBRXCTL_ENA, 0);
3121 : 0 : txgbe_dev_set_link_down(dev);
3122 : : }
3123 : : }
3124 : :
3125 : : void
3126 : 0 : txgbe_dev_setup_link_alarm_handler(void *param)
3127 : : {
3128 : : struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
3129 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3130 : : struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
3131 : : u32 speed;
3132 : 0 : bool autoneg = false;
3133 : :
3134 : 0 : speed = hw->phy.autoneg_advertised;
3135 [ # # ]: 0 : if (!speed)
3136 : 0 : hw->mac.get_link_capabilities(hw, &speed, &autoneg);
3137 : :
3138 : 0 : hw->mac.setup_link(hw, speed, true);
3139 : :
3140 : 0 : intr->flags &= ~TXGBE_FLAG_NEED_LINK_CONFIG;
3141 : 0 : }
3142 : :
3143 : : static void
3144 : 0 : txgbe_do_reset(struct rte_eth_dev *dev)
3145 : : {
3146 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3147 : : struct txgbe_tx_queue *txq;
3148 : : u32 i;
3149 : :
3150 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
3151 : 0 : txq = dev->data->tx_queues[i];
3152 : 0 : txq->resetting = true;
3153 : : }
3154 : :
3155 : : rte_delay_ms(1);
3156 : 0 : wr32(hw, TXGBE_RST, TXGBE_RST_LAN(hw->bus.lan_id));
3157 : : txgbe_flush(hw);
3158 : :
3159 : 0 : PMD_DRV_LOG(ERR, "Please manually restart the port %d",
3160 : : dev->data->port_id);
3161 : 0 : }
3162 : :
3163 : : static void
3164 : 0 : txgbe_tx_ring_recovery(struct rte_eth_dev *dev)
3165 : : {
3166 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3167 : 0 : u32 desc_error[4] = {0, 0, 0, 0};
3168 : : struct txgbe_tx_queue *txq;
3169 : : u32 i;
3170 : :
3171 : : /* check tdm fatal error */
3172 [ # # ]: 0 : for (i = 0; i < 4; i++) {
3173 : 0 : desc_error[i] = rd32(hw, TXGBE_TDM_DESC_FATAL(i));
3174 [ # # ]: 0 : if (desc_error[i] != 0) {
3175 : 0 : PMD_DRV_LOG(ERR, "TDM fatal error reg[%d]: 0x%x", i, desc_error[i]);
3176 : 0 : txgbe_do_reset(dev);
3177 : 0 : return;
3178 : : }
3179 : : }
3180 : :
3181 : : /* check tdm non-fatal error */
3182 [ # # ]: 0 : for (i = 0; i < 4; i++)
3183 : 0 : desc_error[i] = rd32(hw, TXGBE_TDM_DESC_NONFATAL(i));
3184 : :
3185 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
3186 [ # # ]: 0 : if (desc_error[i / 32] & (1 << i % 32)) {
3187 : 0 : PMD_DRV_LOG(ERR, "TDM non-fatal error, reset port[%d] queue[%d]",
3188 : : dev->data->port_id, i);
3189 : 0 : dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
3190 : 0 : txq = dev->data->tx_queues[i];
3191 : 0 : txq->resetting = true;
3192 : 0 : rte_eal_alarm_set(1000, txgbe_tx_queue_clear_error, (void *)dev);
3193 : : }
3194 : : }
3195 : : }
3196 : :
3197 : : void
3198 : 0 : txgbe_dev_setup_link_alarm_handler_aml(void *param)
3199 : : {
3200 : : struct txgbe_hw *hw = (struct txgbe_hw *)param;
3201 : :
3202 [ # # ]: 0 : if (!hw)
3203 : 0 : return;
3204 : :
3205 : 0 : struct rte_eth_dev *dev = (struct rte_eth_dev *)hw->dev_back;
3206 : 0 : struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
3207 : : u32 speed;
3208 : 0 : bool autoneg = false;
3209 : 0 : u32 gssr = hw->phy.phy_semaphore_mask;
3210 : :
3211 : 0 : speed = hw->phy.autoneg_advertised;
3212 [ # # ]: 0 : if (!speed)
3213 : 0 : hw->mac.get_link_capabilities(hw, &speed, &autoneg);
3214 : :
3215 : : /* firmware is configuring phy now, delay host driver config action */
3216 [ # # ]: 0 : if (hw->mac.acquire_swfw_sync(hw, gssr) != 0) {
3217 : 0 : rte_eal_alarm_set(1000 * 1000 * 2,
3218 : : txgbe_dev_setup_link_alarm_handler_aml, hw);
3219 : 0 : PMD_DRV_LOG(DEBUG, "delay config ephy");
3220 : 0 : return;
3221 : : }
3222 : :
3223 : 0 : hw->mac.setup_link(hw, speed, true);
3224 : :
3225 : 0 : u32 link_speed = TXGBE_LINK_SPEED_UNKNOWN;
3226 : 0 : bool link_up = false;
3227 : :
3228 : 0 : hw->mac.check_link(hw, &link_speed, &link_up, false);
3229 [ # # ]: 0 : if (link_up) {
3230 : 0 : PMD_DRV_LOG(DEBUG, "LINK UP IN HANDLER");
3231 : 0 : intr->flags &= ~TXGBE_FLAG_NEED_LINK_CONFIG;
3232 : 0 : txgbe_dev_link_update_share(dev, 0);
3233 : : }
3234 : :
3235 : 0 : hw->mac.release_swfw_sync(hw, gssr);
3236 : :
3237 : 0 : intr->flags &= ~TXGBE_FLAG_NEED_LINK_CONFIG;
3238 : : }
3239 : :
3240 : 0 : s32 txgbe_setup_mac_link_aml(struct txgbe_hw *hw,
3241 : : u32 speed,
3242 : : bool autoneg_wait_to_complete)
3243 : : {
3244 : 0 : bool need_reset = false;
3245 : : s32 status = 0;
3246 : :
3247 : 0 : status = hw->phy.setup_link_core(hw, speed, autoneg_wait_to_complete, &need_reset);
3248 [ # # ]: 0 : if (status)
3249 : : return status;
3250 : :
3251 [ # # # # ]: 0 : if (!hw->adapter_stopped && need_reset)
3252 : 0 : rte_eal_alarm_set(2000 * 1000, txgbe_dev_setup_link_alarm_handler_aml, hw);
3253 : :
3254 : : return status;
3255 : : }
3256 : :
3257 : : /*
3258 : : * If @timeout_ms was 0, it means that it will not return until link complete.
3259 : : * It returns 1 on complete, return 0 on timeout.
3260 : : */
3261 : : int
3262 : 0 : txgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev, uint32_t timeout_ms)
3263 : : {
3264 : : #define WARNING_TIMEOUT 9000 /* 9s in total */
3265 : 0 : struct txgbe_adapter *ad = TXGBE_DEV_ADAPTER(dev);
3266 [ # # ]: 0 : uint32_t timeout = timeout_ms ? timeout_ms : WARNING_TIMEOUT;
3267 : :
3268 [ # # ]: 0 : while (rte_atomic_load_explicit(&ad->link_thread_running, rte_memory_order_seq_cst)) {
3269 : : msec_delay(1);
3270 : 0 : timeout--;
3271 : :
3272 [ # # ]: 0 : if (timeout_ms) {
3273 [ # # ]: 0 : if (!timeout)
3274 : : return 0;
3275 [ # # ]: 0 : } else if (!timeout) {
3276 : : /* It will not return until link complete */
3277 : : timeout = WARNING_TIMEOUT;
3278 : 0 : PMD_DRV_LOG(ERR, "TXGBE link thread not complete too long time!");
3279 : : }
3280 : : }
3281 : :
3282 : : return 1;
3283 : : }
3284 : :
3285 : : static uint32_t
3286 : 0 : txgbe_dev_setup_link_thread_handler(void *param)
3287 : : {
3288 : : struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
3289 : 0 : struct txgbe_adapter *ad = TXGBE_DEV_ADAPTER(dev);
3290 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3291 : :
3292 : 0 : rte_thread_detach(rte_thread_self());
3293 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40)
3294 : 0 : txgbe_dev_setup_link_alarm_handler_aml(hw);
3295 : : else
3296 : 0 : txgbe_dev_setup_link_alarm_handler(dev);
3297 : 0 : rte_atomic_store_explicit(&ad->link_thread_running, 0, rte_memory_order_seq_cst);
3298 : 0 : return 0;
3299 : : }
3300 : :
3301 : : /* return 0 means link status changed, -1 means not changed */
3302 : : int
3303 : 0 : txgbe_dev_link_update_share(struct rte_eth_dev *dev,
3304 : : int wait_to_complete)
3305 : : {
3306 : 0 : struct txgbe_adapter *ad = TXGBE_DEV_ADAPTER(dev);
3307 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3308 : : struct rte_eth_link link;
3309 [ # # ]: 0 : u32 link_speed = TXGBE_LINK_SPEED_UNKNOWN;
3310 : : struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
3311 : : bool link_up;
3312 : : int err;
3313 : : int wait = 1;
3314 : : u32 reg;
3315 : :
3316 : : memset(&link, 0, sizeof(link));
3317 : : link.link_status = RTE_ETH_LINK_DOWN;
3318 : : link.link_speed = RTE_ETH_SPEED_NUM_NONE;
3319 : : link.link_duplex = RTE_ETH_LINK_HALF_DUPLEX;
3320 : 0 : link.link_autoneg = !(dev->data->dev_conf.link_speeds &
3321 : : RTE_ETH_LINK_SPEED_FIXED);
3322 : :
3323 : 0 : hw->mac.get_link_status = true;
3324 : :
3325 [ # # # # ]: 0 : if (intr->flags & TXGBE_FLAG_NEED_LINK_CONFIG ||
3326 [ # # ]: 0 : (txgbe_is_vf(hw) && !rte_atomic_load_explicit(&hw->pf_running,
3327 : : rte_memory_order_acquire)))
3328 : 0 : return rte_eth_linkstatus_set(dev, &link);
3329 : :
3330 : : /* check if it needs to wait to complete, if lsc interrupt is enabled */
3331 [ # # # # ]: 0 : if (wait_to_complete == 0 || dev->data->dev_conf.intr_conf.lsc != 0)
3332 : : wait = 0;
3333 : :
3334 : 0 : err = hw->mac.check_link(hw, &link_speed, &link_up, wait);
3335 : :
3336 [ # # ]: 0 : if (err != 0) {
3337 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_100M;
3338 [ # # ]: 0 : link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
3339 : 0 : return rte_eth_linkstatus_set(dev, &link);
3340 : : }
3341 : :
3342 [ # # ]: 0 : if (link_up == 0) {
3343 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml)
3344 : : wr32m(hw, TXGBE_GPIO_INT_POLARITY,
3345 : : TXGBE_GPIO_INT_POLARITY_3, 0x0);
3346 [ # # ]: 0 : if ((hw->subsystem_device_id & 0xFF) ==
3347 : : TXGBE_DEV_ID_KR_KX_KX4) {
3348 : 0 : hw->mac.bp_down_event(hw);
3349 [ # # ]: 0 : } else if (hw->phy.media_type == txgbe_media_type_fiber &&
3350 [ # # ]: 0 : dev->data->dev_conf.intr_conf.lsc != 0) {
3351 : 0 : txgbe_dev_wait_setup_link_complete(dev, 0);
3352 [ # # ]: 0 : if (!rte_atomic_exchange_explicit(&ad->link_thread_running, 1,
3353 : : rte_memory_order_seq_cst)) {
3354 : : /* To avoid race condition between threads, set
3355 : : * the TXGBE_FLAG_NEED_LINK_CONFIG flag only
3356 : : * when there is no link thread running.
3357 : : */
3358 : 0 : intr->flags |= TXGBE_FLAG_NEED_LINK_CONFIG;
3359 [ # # ]: 0 : if (rte_thread_create_internal_control(&ad->link_thread_tid,
3360 : : "txgbe-link",
3361 : : txgbe_dev_setup_link_thread_handler, dev) < 0) {
3362 : 0 : PMD_DRV_LOG(ERR, "Create link thread failed!");
3363 : 0 : rte_atomic_store_explicit(&ad->link_thread_running, 0,
3364 : : rte_memory_order_seq_cst);
3365 : : }
3366 : : } else {
3367 : 0 : PMD_DRV_LOG(ERR,
3368 : : "Other link thread is running now!");
3369 : : }
3370 : : }
3371 : 0 : return rte_eth_linkstatus_set(dev, &link);
3372 [ # # ]: 0 : } else if (!hw->dev_start) {
3373 : 0 : return rte_eth_linkstatus_set(dev, &link);
3374 : : }
3375 : :
3376 : 0 : intr->flags &= ~TXGBE_FLAG_NEED_LINK_CONFIG;
3377 : 0 : link.link_status = RTE_ETH_LINK_UP;
3378 : 0 : link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
3379 : :
3380 [ # # # # : 0 : switch (link_speed) {
# # # # ]
3381 : 0 : default:
3382 : : case TXGBE_LINK_SPEED_UNKNOWN:
3383 : : link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
3384 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_100M;
3385 : 0 : break;
3386 : :
3387 : 0 : case TXGBE_LINK_SPEED_100M_FULL:
3388 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_100M;
3389 : 0 : break;
3390 : :
3391 : 0 : case TXGBE_LINK_SPEED_1GB_FULL:
3392 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_1G;
3393 : 0 : break;
3394 : :
3395 : 0 : case TXGBE_LINK_SPEED_2_5GB_FULL:
3396 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_2_5G;
3397 : 0 : break;
3398 : :
3399 : 0 : case TXGBE_LINK_SPEED_5GB_FULL:
3400 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_5G;
3401 : 0 : break;
3402 : :
3403 : 0 : case TXGBE_LINK_SPEED_10GB_FULL:
3404 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_10G;
3405 : 0 : break;
3406 : :
3407 : 0 : case TXGBE_LINK_SPEED_25GB_FULL:
3408 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_25G;
3409 : 0 : break;
3410 : :
3411 : 0 : case TXGBE_LINK_SPEED_40GB_FULL:
3412 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_40G;
3413 : 0 : break;
3414 : : }
3415 : :
3416 : : /* enable mac receiver */
3417 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) {
3418 : 0 : txgbe_reconfig_mac(hw);
3419 : : wr32m(hw, TXGBE_MACRXCFG, TXGBE_MACRXCFG_ENA, TXGBE_MACRXCFG_ENA);
3420 : : }
3421 : :
3422 : : /* Re configure MAC RX */
3423 [ # # ]: 0 : if (txgbe_is_pf(hw)) {
3424 : : reg = rd32(hw, TXGBE_MACRXCFG);
3425 : : wr32(hw, TXGBE_MACRXCFG, reg);
3426 : : wr32m(hw, TXGBE_MACRXFLT, TXGBE_MACRXFLT_PROMISC,
3427 : : TXGBE_MACRXFLT_PROMISC);
3428 : : reg = rd32(hw, TXGBE_MAC_WDG_TIMEOUT);
3429 : : wr32(hw, TXGBE_MAC_WDG_TIMEOUT, reg);
3430 : : }
3431 : :
3432 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) {
3433 : : reg = rd32(hw, TXGBE_PORT);
3434 [ # # ]: 0 : if (reg & TXGBE_PORT_LINKUP) {
3435 [ # # ]: 0 : if (reg & TXGBE_CFG_PORT_ST_AML_LINK_40G) {
3436 : 0 : wr32(hw, TXGBE_MACTXCFG,
3437 : : (rd32(hw, TXGBE_MACTXCFG) &
3438 : 0 : ~TXGBE_MAC_TX_CFG_AML_SPEED_MASK) | TXGBE_MACTXCFG_TXE |
3439 : : TXGBE_MAC_TX_CFG_AML_SPEED_40G);
3440 [ # # ]: 0 : } else if (reg & TXGBE_CFG_PORT_ST_AML_LINK_25G) {
3441 : 0 : wr32(hw, TXGBE_MACTXCFG,
3442 : : (rd32(hw, TXGBE_MACTXCFG) &
3443 : 0 : ~TXGBE_MAC_TX_CFG_AML_SPEED_MASK) | TXGBE_MACTXCFG_TXE |
3444 : : TXGBE_MAC_TX_CFG_AML_SPEED_25G);
3445 [ # # ]: 0 : } else if (reg & TXGBE_CFG_PORT_ST_AML_LINK_10G) {
3446 : 0 : wr32(hw, TXGBE_MACTXCFG,
3447 : : (rd32(hw, TXGBE_MACTXCFG) &
3448 : 0 : ~TXGBE_MAC_TX_CFG_AML_SPEED_MASK) | TXGBE_MACTXCFG_TXE |
3449 : : TXGBE_MAC_TX_CFG_AML_SPEED_10G);
3450 : : }
3451 : : }
3452 : : }
3453 : :
3454 : : return rte_eth_linkstatus_set(dev, &link);
3455 : : }
3456 : :
3457 : : static int
3458 : 0 : txgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
3459 : : {
3460 : 0 : return txgbe_dev_link_update_share(dev, wait_to_complete);
3461 : : }
3462 : :
3463 : : static int
3464 : 0 : txgbe_dev_promiscuous_enable(struct rte_eth_dev *dev)
3465 : : {
3466 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3467 : : uint32_t fctrl;
3468 : :
3469 : : fctrl = rd32(hw, TXGBE_PSRCTL);
3470 : 0 : fctrl |= (TXGBE_PSRCTL_UCP | TXGBE_PSRCTL_MCP);
3471 : : wr32(hw, TXGBE_PSRCTL, fctrl);
3472 : :
3473 : 0 : return 0;
3474 : : }
3475 : :
3476 : : static int
3477 : 0 : txgbe_dev_promiscuous_disable(struct rte_eth_dev *dev)
3478 : : {
3479 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3480 : : uint32_t fctrl;
3481 : :
3482 : : fctrl = rd32(hw, TXGBE_PSRCTL);
3483 : 0 : fctrl &= (~TXGBE_PSRCTL_UCP);
3484 [ # # ]: 0 : if (dev->data->all_multicast == 1)
3485 : 0 : fctrl |= TXGBE_PSRCTL_MCP;
3486 : : else
3487 : 0 : fctrl &= (~TXGBE_PSRCTL_MCP);
3488 : : wr32(hw, TXGBE_PSRCTL, fctrl);
3489 : :
3490 : 0 : return 0;
3491 : : }
3492 : :
3493 : : static int
3494 : 0 : txgbe_dev_allmulticast_enable(struct rte_eth_dev *dev)
3495 : : {
3496 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3497 : : uint32_t fctrl;
3498 : :
3499 : : fctrl = rd32(hw, TXGBE_PSRCTL);
3500 : 0 : fctrl |= TXGBE_PSRCTL_MCP;
3501 : : wr32(hw, TXGBE_PSRCTL, fctrl);
3502 : :
3503 : 0 : return 0;
3504 : : }
3505 : :
3506 : : static int
3507 : 0 : txgbe_dev_allmulticast_disable(struct rte_eth_dev *dev)
3508 : : {
3509 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3510 : : uint32_t fctrl;
3511 : :
3512 [ # # ]: 0 : if (dev->data->promiscuous == 1)
3513 : : return 0; /* must remain in all_multicast mode */
3514 : :
3515 : : fctrl = rd32(hw, TXGBE_PSRCTL);
3516 : 0 : fctrl &= (~TXGBE_PSRCTL_MCP);
3517 : : wr32(hw, TXGBE_PSRCTL, fctrl);
3518 : :
3519 : 0 : return 0;
3520 : : }
3521 : :
3522 : : /**
3523 : : * It clears the interrupt causes and enables the interrupt.
3524 : : * It will be called once only during nic initialized.
3525 : : *
3526 : : * @param dev
3527 : : * Pointer to struct rte_eth_dev.
3528 : : * @param on
3529 : : * Enable or Disable.
3530 : : *
3531 : : * @return
3532 : : * - On success, zero.
3533 : : * - On failure, a negative value.
3534 : : */
3535 : : static int
3536 : : txgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev, uint8_t on)
3537 : : {
3538 : : struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
3539 : :
3540 : 0 : txgbe_dev_link_status_print(dev);
3541 : : if (on)
3542 : 0 : intr->mask_misc |= TXGBE_ICRMISC_LSC;
3543 : : else
3544 : 0 : intr->mask_misc &= ~TXGBE_ICRMISC_LSC;
3545 : :
3546 : : return 0;
3547 : : }
3548 : :
3549 : : static int
3550 : : txgbe_dev_misc_interrupt_setup(struct rte_eth_dev *dev)
3551 : : {
3552 : 0 : struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
3553 : : u64 mask;
3554 : :
3555 : : mask = TXGBE_ICR_MASK;
3556 : : mask &= (1ULL << TXGBE_MISC_VEC_ID);
3557 : 0 : intr->mask |= mask;
3558 : 0 : intr->mask_misc |= TXGBE_ICRMISC_GPIO;
3559 : : intr->mask_misc |= TXGBE_ICRMISC_ANDONE;
3560 [ # # ]: 0 : intr->mask_misc |= TXGBE_ICRMISC_TXDESC;
3561 : : return 0;
3562 : : }
3563 : :
3564 : : /**
3565 : : * It clears the interrupt causes and enables the interrupt.
3566 : : * It will be called once only during nic initialized.
3567 : : *
3568 : : * @param dev
3569 : : * Pointer to struct rte_eth_dev.
3570 : : *
3571 : : * @return
3572 : : * - On success, zero.
3573 : : * - On failure, a negative value.
3574 : : */
3575 : : static int
3576 : : txgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev)
3577 : : {
3578 : 0 : struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
3579 : : u64 mask;
3580 : :
3581 : : mask = TXGBE_ICR_MASK;
3582 : : mask &= ~((1ULL << TXGBE_RX_VEC_START) - 1);
3583 : 0 : intr->mask |= mask;
3584 : :
3585 : 0 : return 0;
3586 : : }
3587 : :
3588 : : /**
3589 : : * It clears the interrupt causes and enables the interrupt.
3590 : : * It will be called once only during nic initialized.
3591 : : *
3592 : : * @param dev
3593 : : * Pointer to struct rte_eth_dev.
3594 : : *
3595 : : * @return
3596 : : * - On success, zero.
3597 : : * - On failure, a negative value.
3598 : : */
3599 : : static int
3600 : : txgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev)
3601 : : {
3602 : 0 : struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
3603 : :
3604 : 0 : intr->mask_misc |= TXGBE_ICRMISC_LNKSEC;
3605 : :
3606 : : return 0;
3607 : : }
3608 : :
3609 : : /*
3610 : : * It reads ICR and sets flag (TXGBE_ICRMISC_LSC) for the link_update.
3611 : : *
3612 : : * @param dev
3613 : : * Pointer to struct rte_eth_dev.
3614 : : *
3615 : : * @return
3616 : : * - On success, zero.
3617 : : * - On failure, a negative value.
3618 : : */
3619 : : static int
3620 : 0 : txgbe_dev_interrupt_get_status(struct rte_eth_dev *dev,
3621 : : struct rte_intr_handle *intr_handle)
3622 : : {
3623 : : uint32_t eicr;
3624 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3625 : : struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
3626 : :
3627 [ # # # # ]: 0 : if (rte_intr_type_get(intr_handle) != RTE_INTR_HANDLE_UIO &&
3628 : 0 : rte_intr_type_get(intr_handle) != RTE_INTR_HANDLE_VFIO_MSIX)
3629 : : wr32(hw, TXGBE_PX_INTA, 1);
3630 : :
3631 : : /* read-on-clear nic registers here */
3632 : 0 : eicr = ((u32 *)hw->isb_mem)[TXGBE_ISB_MISC];
3633 : 0 : PMD_DRV_LOG(DEBUG, "eicr %x", eicr);
3634 : :
3635 : 0 : intr->flags = 0;
3636 : :
3637 : : /* set flag for async link update */
3638 [ # # ]: 0 : if (eicr & TXGBE_ICRMISC_LSC)
3639 : 0 : intr->flags |= TXGBE_FLAG_NEED_LINK_UPDATE;
3640 : :
3641 [ # # ]: 0 : if (eicr & TXGBE_ICRMISC_ANDONE)
3642 : 0 : intr->flags |= TXGBE_FLAG_NEED_AN_CONFIG;
3643 : :
3644 [ # # ]: 0 : if (eicr & TXGBE_ICRMISC_VFMBX)
3645 : 0 : intr->flags |= TXGBE_FLAG_MAILBOX;
3646 : :
3647 [ # # ]: 0 : if (eicr & TXGBE_ICRMISC_LNKSEC)
3648 : 0 : intr->flags |= TXGBE_FLAG_MACSEC;
3649 : :
3650 [ # # ]: 0 : if (eicr & TXGBE_ICRMISC_GPIO)
3651 : 0 : intr->flags |= TXGBE_FLAG_PHY_INTERRUPT;
3652 : :
3653 [ # # ]: 0 : if (eicr & TXGBE_ICRMISC_HEAT)
3654 : 0 : intr->flags |= TXGBE_FLAG_OVERHEAT;
3655 : :
3656 [ # # ]: 0 : if (eicr & TXGBE_ICRMISC_TXDESC)
3657 : 0 : intr->flags |= TXGBE_FLAG_TX_DESC_ERR;
3658 : :
3659 : 0 : ((u32 *)hw->isb_mem)[TXGBE_ISB_MISC] = 0;
3660 : :
3661 : 0 : return 0;
3662 : : }
3663 : :
3664 : : /**
3665 : : * It gets and then prints the link status.
3666 : : *
3667 : : * @param dev
3668 : : * Pointer to struct rte_eth_dev.
3669 : : *
3670 : : * @return
3671 : : * - On success, zero.
3672 : : * - On failure, a negative value.
3673 : : */
3674 : : static void
3675 : 0 : txgbe_dev_link_status_print(struct rte_eth_dev *dev)
3676 : : {
3677 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
3678 : : struct rte_eth_link link;
3679 : :
3680 : 0 : rte_eth_linkstatus_get(dev, &link);
3681 : :
3682 [ # # ]: 0 : if (link.link_status) {
3683 [ # # ]: 0 : PMD_INIT_LOG(INFO, "Port %d: Link Up - speed %u Mbps - %s",
3684 : : (int)(dev->data->port_id),
3685 : : (unsigned int)link.link_speed,
3686 : : link.link_duplex == RTE_ETH_LINK_FULL_DUPLEX ?
3687 : : "full-duplex" : "half-duplex");
3688 : : } else {
3689 : 0 : PMD_INIT_LOG(INFO, " Port %d: Link Down",
3690 : : (int)(dev->data->port_id));
3691 : : }
3692 : 0 : PMD_INIT_LOG(DEBUG, "PCI Address: " PCI_PRI_FMT,
3693 : : pci_dev->addr.domain,
3694 : : pci_dev->addr.bus,
3695 : : pci_dev->addr.devid,
3696 : : pci_dev->addr.function);
3697 : 0 : }
3698 : :
3699 : : /*
3700 : : * It executes link_update after knowing an interrupt occurred.
3701 : : *
3702 : : * @param dev
3703 : : * Pointer to struct rte_eth_dev.
3704 : : *
3705 : : * @return
3706 : : * - On success, zero.
3707 : : * - On failure, a negative value.
3708 : : */
3709 : : static int
3710 : 0 : txgbe_dev_interrupt_action(struct rte_eth_dev *dev,
3711 : : struct rte_intr_handle *intr_handle)
3712 : : {
3713 : 0 : struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
3714 : : int64_t timeout;
3715 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3716 : :
3717 : 0 : PMD_DRV_LOG(DEBUG, "intr action type %d", intr->flags);
3718 : :
3719 [ # # ]: 0 : if (intr->flags & TXGBE_FLAG_MAILBOX) {
3720 : 0 : txgbe_pf_mbx_process(dev);
3721 : 0 : intr->flags &= ~TXGBE_FLAG_MAILBOX;
3722 : : }
3723 : :
3724 [ # # ]: 0 : if (intr->flags & TXGBE_FLAG_PHY_INTERRUPT) {
3725 : 0 : txgbe_dev_sfp_event(dev);
3726 : 0 : intr->flags &= ~TXGBE_FLAG_PHY_INTERRUPT;
3727 : : }
3728 : :
3729 [ # # ]: 0 : if (intr->flags & TXGBE_FLAG_NEED_AN_CONFIG) {
3730 [ # # # # ]: 0 : if (hw->devarg.auto_neg == 1 && hw->devarg.poll == 0) {
3731 : 0 : hw->mac.kr_handle(hw);
3732 : 0 : intr->flags &= ~TXGBE_FLAG_NEED_AN_CONFIG;
3733 : : }
3734 : : }
3735 : :
3736 [ # # ]: 0 : if (intr->flags & TXGBE_FLAG_NEED_LINK_UPDATE) {
3737 : : struct rte_eth_link link;
3738 : :
3739 : : /*get the link status before link update, for predicting later*/
3740 : 0 : rte_eth_linkstatus_get(dev, &link);
3741 : :
3742 : : txgbe_dev_link_update(dev, 0);
3743 : :
3744 : : /* likely to up */
3745 [ # # ]: 0 : if (!link.link_status)
3746 : : /* handle it 1 sec later, wait it being stable */
3747 : : timeout = TXGBE_LINK_UP_CHECK_TIMEOUT;
3748 : : /* likely to down */
3749 [ # # ]: 0 : else if ((hw->subsystem_device_id & 0xFF) ==
3750 : 0 : TXGBE_DEV_ID_KR_KX_KX4 &&
3751 [ # # ]: 0 : hw->devarg.auto_neg == 1)
3752 : : /* handle it 2 sec later for backplane AN73 */
3753 : : timeout = 2000;
3754 : : else
3755 : : /* handle it 4 sec later, wait it being stable */
3756 : : timeout = TXGBE_LINK_DOWN_CHECK_TIMEOUT;
3757 : :
3758 : 0 : txgbe_dev_link_status_print(dev);
3759 [ # # ]: 0 : if (rte_eal_alarm_set(timeout * 1000,
3760 : : txgbe_dev_interrupt_delayed_handler,
3761 : : (void *)dev) < 0) {
3762 : 0 : PMD_DRV_LOG(ERR, "Error setting alarm");
3763 : : } else {
3764 : : /* only disable lsc interrupt */
3765 : 0 : intr->mask_misc &= ~TXGBE_ICRMISC_LSC;
3766 : :
3767 : 0 : intr->mask_orig = intr->mask;
3768 : : /* only disable all misc interrupts */
3769 : 0 : intr->mask &= ~(1ULL << TXGBE_MISC_VEC_ID);
3770 : : }
3771 : : }
3772 : :
3773 [ # # ]: 0 : if (intr->flags & TXGBE_FLAG_OVERHEAT) {
3774 : 0 : txgbe_dev_overheat(dev);
3775 : 0 : intr->flags &= ~TXGBE_FLAG_OVERHEAT;
3776 : : }
3777 : :
3778 [ # # ]: 0 : if (intr->flags & TXGBE_FLAG_TX_DESC_ERR) {
3779 : 0 : txgbe_tx_ring_recovery(dev);
3780 : 0 : intr->flags &= ~TXGBE_FLAG_TX_DESC_ERR;
3781 : : }
3782 : :
3783 : 0 : PMD_DRV_LOG(DEBUG, "enable intr immediately");
3784 : 0 : txgbe_enable_intr(dev);
3785 : 0 : rte_intr_enable(intr_handle);
3786 : :
3787 : 0 : return 0;
3788 : : }
3789 : :
3790 : : /**
3791 : : * Interrupt handler which shall be registered for alarm callback for delayed
3792 : : * handling specific interrupt to wait for the stable nic state. As the
3793 : : * NIC interrupt state is not stable for txgbe after link is just down,
3794 : : * it needs to wait 4 seconds to get the stable status.
3795 : : *
3796 : : * @param handle
3797 : : * Pointer to interrupt handle.
3798 : : * @param param
3799 : : * The address of parameter (struct rte_eth_dev *) registered before.
3800 : : *
3801 : : * @return
3802 : : * void
3803 : : */
3804 : : static void
3805 : 0 : txgbe_dev_interrupt_delayed_handler(void *param)
3806 : : {
3807 : : struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
3808 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
3809 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
3810 : 0 : struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
3811 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3812 : : uint32_t eicr;
3813 : :
3814 : 0 : txgbe_disable_intr(hw);
3815 : :
3816 : 0 : eicr = ((u32 *)hw->isb_mem)[TXGBE_ISB_MISC];
3817 [ # # ]: 0 : if (eicr & TXGBE_ICRMISC_VFMBX)
3818 : 0 : txgbe_pf_mbx_process(dev);
3819 : :
3820 [ # # ]: 0 : if (intr->flags & TXGBE_FLAG_PHY_INTERRUPT) {
3821 : 0 : hw->phy.handle_lasi(hw);
3822 : 0 : intr->flags &= ~TXGBE_FLAG_PHY_INTERRUPT;
3823 : : }
3824 : :
3825 [ # # ]: 0 : if (intr->flags & TXGBE_FLAG_NEED_LINK_UPDATE) {
3826 : : txgbe_dev_link_update(dev, 0);
3827 : 0 : intr->flags &= ~TXGBE_FLAG_NEED_LINK_UPDATE;
3828 : 0 : txgbe_dev_link_status_print(dev);
3829 : 0 : rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
3830 : : NULL);
3831 : : }
3832 : :
3833 [ # # ]: 0 : if (intr->flags & TXGBE_FLAG_MACSEC) {
3834 : 0 : rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_MACSEC,
3835 : : NULL);
3836 : 0 : intr->flags &= ~TXGBE_FLAG_MACSEC;
3837 : : }
3838 : :
3839 : : /* restore original mask */
3840 [ # # ]: 0 : if (dev->data->dev_conf.intr_conf.lsc == 1)
3841 : 0 : intr->mask_misc |= TXGBE_ICRMISC_LSC;
3842 : :
3843 : 0 : intr->mask = intr->mask_orig;
3844 : 0 : intr->mask_orig = 0;
3845 : :
3846 : 0 : PMD_DRV_LOG(DEBUG, "enable intr in delayed handler S[%08x]", eicr);
3847 : 0 : txgbe_enable_intr(dev);
3848 : 0 : rte_intr_enable(intr_handle);
3849 : 0 : }
3850 : :
3851 : : /**
3852 : : * Interrupt handler triggered by NIC for handling
3853 : : * specific interrupt.
3854 : : *
3855 : : * @param handle
3856 : : * Pointer to interrupt handle.
3857 : : * @param param
3858 : : * The address of parameter (struct rte_eth_dev *) registered before.
3859 : : *
3860 : : * @return
3861 : : * void
3862 : : */
3863 : : static void
3864 : 0 : txgbe_dev_interrupt_handler(void *param)
3865 : : {
3866 : : struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
3867 : :
3868 : 0 : txgbe_dev_interrupt_get_status(dev, dev->intr_handle);
3869 : 0 : txgbe_dev_interrupt_action(dev, dev->intr_handle);
3870 : 0 : }
3871 : :
3872 : : static int
3873 : 0 : txgbe_dev_led_on(struct rte_eth_dev *dev)
3874 : : {
3875 : : struct txgbe_hw *hw;
3876 : :
3877 : 0 : hw = TXGBE_DEV_HW(dev);
3878 [ # # ]: 0 : return txgbe_led_on(hw, TXGBE_LEDCTL_ACTIVE) == 0 ? 0 : -ENOTSUP;
3879 : : }
3880 : :
3881 : : static int
3882 : 0 : txgbe_dev_led_off(struct rte_eth_dev *dev)
3883 : : {
3884 : : struct txgbe_hw *hw;
3885 : :
3886 : 0 : hw = TXGBE_DEV_HW(dev);
3887 [ # # ]: 0 : return txgbe_led_off(hw, TXGBE_LEDCTL_ACTIVE) == 0 ? 0 : -ENOTSUP;
3888 : : }
3889 : :
3890 : : static int
3891 : 0 : txgbe_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
3892 : : {
3893 : : struct txgbe_hw *hw;
3894 : : uint32_t mflcn_reg;
3895 : : uint32_t fccfg_reg;
3896 : : int rx_pause;
3897 : : int tx_pause;
3898 : :
3899 : 0 : hw = TXGBE_DEV_HW(dev);
3900 : :
3901 : 0 : fc_conf->pause_time = hw->fc.pause_time;
3902 : 0 : fc_conf->high_water = hw->fc.high_water[0];
3903 : 0 : fc_conf->low_water = hw->fc.low_water[0];
3904 : 0 : fc_conf->send_xon = hw->fc.send_xon;
3905 : 0 : fc_conf->autoneg = !hw->fc.disable_fc_autoneg;
3906 : :
3907 : : /*
3908 : : * Return rx_pause status according to actual setting of
3909 : : * RXFCCFG register.
3910 : : */
3911 : : mflcn_reg = rd32(hw, TXGBE_RXFCCFG);
3912 [ # # ]: 0 : if (mflcn_reg & (TXGBE_RXFCCFG_FC | TXGBE_RXFCCFG_PFC))
3913 : : rx_pause = 1;
3914 : : else
3915 : : rx_pause = 0;
3916 : :
3917 : : /*
3918 : : * Return tx_pause status according to actual setting of
3919 : : * TXFCCFG register.
3920 : : */
3921 : : fccfg_reg = rd32(hw, TXGBE_TXFCCFG);
3922 [ # # ]: 0 : if (fccfg_reg & (TXGBE_TXFCCFG_FC | TXGBE_TXFCCFG_PFC))
3923 : : tx_pause = 1;
3924 : : else
3925 : : tx_pause = 0;
3926 : :
3927 [ # # ]: 0 : if (rx_pause && tx_pause)
3928 : 0 : fc_conf->mode = RTE_ETH_FC_FULL;
3929 [ # # ]: 0 : else if (rx_pause)
3930 : 0 : fc_conf->mode = RTE_ETH_FC_RX_PAUSE;
3931 [ # # ]: 0 : else if (tx_pause)
3932 : 0 : fc_conf->mode = RTE_ETH_FC_TX_PAUSE;
3933 : : else
3934 : 0 : fc_conf->mode = RTE_ETH_FC_NONE;
3935 : :
3936 : 0 : return 0;
3937 : : }
3938 : :
3939 : : static int
3940 : 0 : txgbe_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
3941 : : {
3942 : : struct txgbe_hw *hw;
3943 : : int err;
3944 : : uint32_t rx_buf_size;
3945 : : uint32_t max_high_water;
3946 : 0 : enum txgbe_fc_mode rte_fcmode_2_txgbe_fcmode[] = {
3947 : : txgbe_fc_none,
3948 : : txgbe_fc_rx_pause,
3949 : : txgbe_fc_tx_pause,
3950 : : txgbe_fc_full
3951 : : };
3952 : :
3953 : 0 : PMD_INIT_FUNC_TRACE();
3954 : :
3955 : 0 : hw = TXGBE_DEV_HW(dev);
3956 : : rx_buf_size = rd32(hw, TXGBE_PBRXSIZE(0));
3957 : 0 : PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
3958 : :
3959 : : /*
3960 : : * At least reserve one Ethernet frame for watermark
3961 : : * high_water/low_water in kilo bytes for txgbe
3962 : : */
3963 : 0 : max_high_water = (rx_buf_size - RTE_ETHER_MAX_LEN) >> 10;
3964 [ # # ]: 0 : if (fc_conf->high_water > max_high_water ||
3965 [ # # ]: 0 : fc_conf->high_water < fc_conf->low_water) {
3966 : 0 : PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
3967 : 0 : PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
3968 : 0 : return -EINVAL;
3969 : : }
3970 : :
3971 : 0 : hw->fc.requested_mode = rte_fcmode_2_txgbe_fcmode[fc_conf->mode];
3972 : 0 : hw->fc.pause_time = fc_conf->pause_time;
3973 : 0 : hw->fc.high_water[0] = fc_conf->high_water;
3974 : 0 : hw->fc.low_water[0] = fc_conf->low_water;
3975 : 0 : hw->fc.send_xon = fc_conf->send_xon;
3976 : 0 : hw->fc.disable_fc_autoneg = !fc_conf->autoneg;
3977 : 0 : hw->fc.mac_ctrl_frame_fwd = fc_conf->mac_ctrl_frame_fwd;
3978 : :
3979 : 0 : err = txgbe_fc_enable(hw);
3980 : :
3981 : : /* Not negotiated is not an error case */
3982 [ # # ]: 0 : if (err == 0 || err == TXGBE_ERR_FC_NOT_NEGOTIATED) {
3983 : 0 : wr32m(hw, TXGBE_MACRXFLT, TXGBE_MACRXFLT_CTL_MASK,
3984 [ # # ]: 0 : (fc_conf->mac_ctrl_frame_fwd
3985 : : ? TXGBE_MACRXFLT_CTL_NOPS : TXGBE_MACRXFLT_CTL_DROP));
3986 : : txgbe_flush(hw);
3987 : :
3988 : 0 : return 0;
3989 : : }
3990 : :
3991 : 0 : PMD_INIT_LOG(ERR, "txgbe_fc_enable = 0x%x", err);
3992 : 0 : return -EIO;
3993 : : }
3994 : :
3995 : : static int
3996 : 0 : txgbe_priority_flow_ctrl_set(struct rte_eth_dev *dev,
3997 : : struct rte_eth_pfc_conf *pfc_conf)
3998 : : {
3999 : : int err;
4000 : : uint32_t rx_buf_size;
4001 : : uint32_t max_high_water;
4002 : : uint8_t tc_num;
4003 : 0 : uint8_t map[TXGBE_DCB_UP_MAX] = { 0 };
4004 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4005 : 0 : struct txgbe_dcb_config *dcb_config = TXGBE_DEV_DCB_CONFIG(dev);
4006 : :
4007 : 0 : enum txgbe_fc_mode rte_fcmode_2_txgbe_fcmode[] = {
4008 : : txgbe_fc_none,
4009 : : txgbe_fc_rx_pause,
4010 : : txgbe_fc_tx_pause,
4011 : : txgbe_fc_full
4012 : : };
4013 : :
4014 : 0 : PMD_INIT_FUNC_TRACE();
4015 : :
4016 : 0 : txgbe_dcb_unpack_map_cee(dcb_config, TXGBE_DCB_RX_CONFIG, map);
4017 : 0 : tc_num = map[pfc_conf->priority];
4018 : 0 : rx_buf_size = rd32(hw, TXGBE_PBRXSIZE(tc_num));
4019 : 0 : PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
4020 : : /*
4021 : : * At least reserve one Ethernet frame for watermark
4022 : : * high_water/low_water in kilo bytes for txgbe
4023 : : */
4024 : 0 : max_high_water = (rx_buf_size - RTE_ETHER_MAX_LEN) >> 10;
4025 [ # # ]: 0 : if (pfc_conf->fc.high_water > max_high_water ||
4026 [ # # ]: 0 : pfc_conf->fc.high_water <= pfc_conf->fc.low_water) {
4027 : 0 : PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
4028 : 0 : PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
4029 : 0 : return -EINVAL;
4030 : : }
4031 : :
4032 : 0 : hw->fc.requested_mode = rte_fcmode_2_txgbe_fcmode[pfc_conf->fc.mode];
4033 : 0 : hw->fc.pause_time = pfc_conf->fc.pause_time;
4034 : 0 : hw->fc.send_xon = pfc_conf->fc.send_xon;
4035 : 0 : hw->fc.low_water[tc_num] = pfc_conf->fc.low_water;
4036 : 0 : hw->fc.high_water[tc_num] = pfc_conf->fc.high_water;
4037 : :
4038 : 0 : err = txgbe_dcb_pfc_enable(hw, tc_num);
4039 : :
4040 : : /* Not negotiated is not an error case */
4041 [ # # ]: 0 : if (err == 0 || err == TXGBE_ERR_FC_NOT_NEGOTIATED)
4042 : : return 0;
4043 : :
4044 : 0 : PMD_INIT_LOG(ERR, "txgbe_dcb_pfc_enable = 0x%x", err);
4045 : 0 : return -EIO;
4046 : : }
4047 : :
4048 : : int
4049 : 0 : txgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
4050 : : struct rte_eth_rss_reta_entry64 *reta_conf,
4051 : : uint16_t reta_size)
4052 : : {
4053 : : uint8_t i, j, mask;
4054 : : uint32_t reta;
4055 : : uint16_t idx, shift;
4056 : 0 : struct txgbe_adapter *adapter = TXGBE_DEV_ADAPTER(dev);
4057 : : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4058 : :
4059 : 0 : PMD_INIT_FUNC_TRACE();
4060 : :
4061 [ # # ]: 0 : if (!txgbe_rss_update(hw->mac.type)) {
4062 : 0 : PMD_DRV_LOG(ERR, "RSS reta update is not supported on this "
4063 : : "NIC.");
4064 : 0 : return -ENOTSUP;
4065 : : }
4066 : :
4067 [ # # ]: 0 : if (reta_size != RTE_ETH_RSS_RETA_SIZE_128) {
4068 : 0 : PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
4069 : : "(%d) doesn't match the number hardware can supported "
4070 : : "(%d)", reta_size, RTE_ETH_RSS_RETA_SIZE_128);
4071 : 0 : return -EINVAL;
4072 : : }
4073 : :
4074 [ # # ]: 0 : for (i = 0; i < reta_size; i += 4) {
4075 : 0 : idx = i / RTE_ETH_RETA_GROUP_SIZE;
4076 : : shift = i % RTE_ETH_RETA_GROUP_SIZE;
4077 : 0 : mask = (uint8_t)RS64(reta_conf[idx].mask, shift, 0xF);
4078 [ # # ]: 0 : if (!mask)
4079 : 0 : continue;
4080 : :
4081 : 0 : reta = rd32at(hw, TXGBE_REG_RSSTBL, i >> 2);
4082 [ # # ]: 0 : for (j = 0; j < 4; j++) {
4083 [ # # ]: 0 : if (RS8(mask, j, 0x1)) {
4084 : 0 : reta &= ~(MS32(8 * j, 0xFF));
4085 : 0 : reta |= LS32(reta_conf[idx].reta[shift + j],
4086 : : 8 * j, 0xFF);
4087 : : }
4088 : : }
4089 : 0 : wr32at(hw, TXGBE_REG_RSSTBL, i >> 2, reta);
4090 : : }
4091 : 0 : adapter->rss_reta_updated = 1;
4092 : :
4093 : 0 : return 0;
4094 : : }
4095 : :
4096 : : int
4097 : 0 : txgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
4098 : : struct rte_eth_rss_reta_entry64 *reta_conf,
4099 : : uint16_t reta_size)
4100 : : {
4101 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4102 : : uint8_t i, j, mask;
4103 : : uint32_t reta;
4104 : : uint16_t idx, shift;
4105 : :
4106 : 0 : PMD_INIT_FUNC_TRACE();
4107 : :
4108 [ # # ]: 0 : if (reta_size != RTE_ETH_RSS_RETA_SIZE_128) {
4109 : 0 : PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
4110 : : "(%d) doesn't match the number hardware can supported "
4111 : : "(%d)", reta_size, RTE_ETH_RSS_RETA_SIZE_128);
4112 : 0 : return -EINVAL;
4113 : : }
4114 : :
4115 [ # # ]: 0 : for (i = 0; i < reta_size; i += 4) {
4116 : 0 : idx = i / RTE_ETH_RETA_GROUP_SIZE;
4117 : : shift = i % RTE_ETH_RETA_GROUP_SIZE;
4118 : 0 : mask = (uint8_t)RS64(reta_conf[idx].mask, shift, 0xF);
4119 [ # # ]: 0 : if (!mask)
4120 : 0 : continue;
4121 : :
4122 : 0 : reta = rd32at(hw, TXGBE_REG_RSSTBL, i >> 2);
4123 [ # # ]: 0 : for (j = 0; j < 4; j++) {
4124 [ # # ]: 0 : if (RS8(mask, j, 0x1))
4125 : 0 : reta_conf[idx].reta[shift + j] =
4126 : 0 : (uint16_t)RS32(reta, 8 * j, 0xFF);
4127 : : }
4128 : : }
4129 : :
4130 : : return 0;
4131 : : }
4132 : :
4133 : : static int
4134 : 0 : txgbe_add_rar(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
4135 : : uint32_t index, uint32_t pool)
4136 : : {
4137 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4138 : : uint32_t enable_addr = 1;
4139 : :
4140 : 0 : return txgbe_set_rar(hw, index, mac_addr->addr_bytes,
4141 : : pool, enable_addr);
4142 : : }
4143 : :
4144 : : static void
4145 : 0 : txgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index)
4146 : : {
4147 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4148 : :
4149 : 0 : txgbe_clear_rar(hw, index);
4150 : 0 : }
4151 : :
4152 : : static int
4153 : 0 : txgbe_set_default_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *addr)
4154 : : {
4155 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
4156 : :
4157 : : txgbe_remove_rar(dev, 0);
4158 : 0 : txgbe_add_rar(dev, addr, 0, pci_dev->max_vfs);
4159 : :
4160 : 0 : return 0;
4161 : : }
4162 : :
4163 : : static int
4164 : 0 : txgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
4165 : : {
4166 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4167 : : uint32_t frame_size = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
4168 : : struct rte_eth_dev_data *dev_data = dev->data;
4169 : :
4170 : : /* If device is started, refuse mtu that requires the support of
4171 : : * scattered packets when this feature has not been enabled before.
4172 : : */
4173 [ # # ]: 0 : if (dev_data->dev_started && !dev_data->scattered_rx &&
4174 : 0 : (frame_size + 2 * RTE_VLAN_HLEN >
4175 [ # # ]: 0 : dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM)) {
4176 : 0 : PMD_INIT_LOG(ERR, "Stop port first.");
4177 : 0 : return -EINVAL;
4178 : : }
4179 : :
4180 : 0 : wr32m(hw, TXGBE_FRMSZ, TXGBE_FRMSZ_MAX_MASK,
4181 : 0 : TXGBE_FRMSZ_MAX(frame_size));
4182 : :
4183 : 0 : return 0;
4184 : : }
4185 : :
4186 : : static uint32_t
4187 : 0 : txgbe_uta_vector(struct txgbe_hw *hw, struct rte_ether_addr *uc_addr)
4188 : : {
4189 : : uint32_t vector = 0;
4190 : :
4191 [ # # # # : 0 : switch (hw->mac.mc_filter_type) {
# ]
4192 : 0 : case 0: /* use bits [47:36] of the address */
4193 : 0 : vector = ((uc_addr->addr_bytes[4] >> 4) |
4194 : 0 : (((uint16_t)uc_addr->addr_bytes[5]) << 4));
4195 : 0 : break;
4196 : 0 : case 1: /* use bits [46:35] of the address */
4197 : 0 : vector = ((uc_addr->addr_bytes[4] >> 3) |
4198 : 0 : (((uint16_t)uc_addr->addr_bytes[5]) << 5));
4199 : 0 : break;
4200 : 0 : case 2: /* use bits [45:34] of the address */
4201 : 0 : vector = ((uc_addr->addr_bytes[4] >> 2) |
4202 : 0 : (((uint16_t)uc_addr->addr_bytes[5]) << 6));
4203 : 0 : break;
4204 : 0 : case 3: /* use bits [43:32] of the address */
4205 : 0 : vector = ((uc_addr->addr_bytes[4]) |
4206 : 0 : (((uint16_t)uc_addr->addr_bytes[5]) << 8));
4207 : 0 : break;
4208 : : default: /* Invalid mc_filter_type */
4209 : : break;
4210 : : }
4211 : :
4212 : : /* vector can only be 12-bits or boundary will be exceeded */
4213 : 0 : vector &= 0xFFF;
4214 : 0 : return vector;
4215 : : }
4216 : :
4217 : : static int
4218 : 0 : txgbe_uc_hash_table_set(struct rte_eth_dev *dev,
4219 : : struct rte_ether_addr *mac_addr, uint8_t on)
4220 : : {
4221 : : uint32_t vector;
4222 : : uint32_t uta_idx;
4223 : : uint32_t reg_val;
4224 : : uint32_t uta_mask;
4225 : : uint32_t psrctl;
4226 : :
4227 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4228 : : struct txgbe_uta_info *uta_info = TXGBE_DEV_UTA_INFO(dev);
4229 : :
4230 : : /* The UTA table only exists on pf hardware */
4231 [ # # ]: 0 : if (hw->mac.type < txgbe_mac_sp)
4232 : : return -ENOTSUP;
4233 : :
4234 : 0 : vector = txgbe_uta_vector(hw, mac_addr);
4235 : 0 : uta_idx = (vector >> 5) & 0x7F;
4236 : 0 : uta_mask = 0x1UL << (vector & 0x1F);
4237 : :
4238 [ # # ]: 0 : if (!!on == !!(uta_info->uta_shadow[uta_idx] & uta_mask))
4239 : : return 0;
4240 : :
4241 : 0 : reg_val = rd32(hw, TXGBE_UCADDRTBL(uta_idx));
4242 [ # # ]: 0 : if (on) {
4243 : 0 : uta_info->uta_in_use++;
4244 : 0 : reg_val |= uta_mask;
4245 : 0 : uta_info->uta_shadow[uta_idx] |= uta_mask;
4246 : : } else {
4247 : 0 : uta_info->uta_in_use--;
4248 : 0 : reg_val &= ~uta_mask;
4249 : 0 : uta_info->uta_shadow[uta_idx] &= ~uta_mask;
4250 : : }
4251 : :
4252 : : wr32(hw, TXGBE_UCADDRTBL(uta_idx), reg_val);
4253 : :
4254 : : psrctl = rd32(hw, TXGBE_PSRCTL);
4255 [ # # ]: 0 : if (uta_info->uta_in_use > 0)
4256 : 0 : psrctl |= TXGBE_PSRCTL_UCHFENA;
4257 : : else
4258 : 0 : psrctl &= ~TXGBE_PSRCTL_UCHFENA;
4259 : :
4260 : 0 : psrctl &= ~TXGBE_PSRCTL_ADHF12_MASK;
4261 : 0 : psrctl |= TXGBE_PSRCTL_ADHF12(hw->mac.mc_filter_type);
4262 : : wr32(hw, TXGBE_PSRCTL, psrctl);
4263 : :
4264 : 0 : return 0;
4265 : : }
4266 : :
4267 : : static int
4268 : 0 : txgbe_uc_all_hash_table_set(struct rte_eth_dev *dev, uint8_t on)
4269 : : {
4270 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4271 : : struct txgbe_uta_info *uta_info = TXGBE_DEV_UTA_INFO(dev);
4272 : : uint32_t psrctl;
4273 : : int i;
4274 : :
4275 : : /* The UTA table only exists on pf hardware */
4276 [ # # ]: 0 : if (hw->mac.type < txgbe_mac_sp)
4277 : : return -ENOTSUP;
4278 : :
4279 [ # # ]: 0 : if (on) {
4280 [ # # ]: 0 : for (i = 0; i < RTE_ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
4281 : 0 : uta_info->uta_shadow[i] = ~0;
4282 : 0 : wr32(hw, TXGBE_UCADDRTBL(i), ~0);
4283 : : }
4284 : : } else {
4285 [ # # ]: 0 : for (i = 0; i < RTE_ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
4286 : 0 : uta_info->uta_shadow[i] = 0;
4287 : 0 : wr32(hw, TXGBE_UCADDRTBL(i), 0);
4288 : : }
4289 : : }
4290 : :
4291 : : psrctl = rd32(hw, TXGBE_PSRCTL);
4292 [ # # ]: 0 : if (on)
4293 : 0 : psrctl |= TXGBE_PSRCTL_UCHFENA;
4294 : : else
4295 : 0 : psrctl &= ~TXGBE_PSRCTL_UCHFENA;
4296 : :
4297 : 0 : psrctl &= ~TXGBE_PSRCTL_ADHF12_MASK;
4298 : 0 : psrctl |= TXGBE_PSRCTL_ADHF12(hw->mac.mc_filter_type);
4299 : : wr32(hw, TXGBE_PSRCTL, psrctl);
4300 : :
4301 : 0 : return 0;
4302 : : }
4303 : :
4304 : : uint32_t
4305 : 0 : txgbe_convert_vm_rx_mask_to_val(uint16_t rx_mask, uint32_t orig_val)
4306 : : {
4307 : : uint32_t new_val = orig_val;
4308 : :
4309 [ # # ]: 0 : if (rx_mask & RTE_ETH_VMDQ_ACCEPT_UNTAG)
4310 : 0 : new_val |= TXGBE_POOLETHCTL_UTA;
4311 [ # # ]: 0 : if (rx_mask & RTE_ETH_VMDQ_ACCEPT_HASH_MC)
4312 : 0 : new_val |= TXGBE_POOLETHCTL_MCHA;
4313 [ # # ]: 0 : if (rx_mask & RTE_ETH_VMDQ_ACCEPT_HASH_UC)
4314 : 0 : new_val |= TXGBE_POOLETHCTL_UCHA;
4315 [ # # ]: 0 : if (rx_mask & RTE_ETH_VMDQ_ACCEPT_BROADCAST)
4316 : 0 : new_val |= TXGBE_POOLETHCTL_BCA;
4317 [ # # ]: 0 : if (rx_mask & RTE_ETH_VMDQ_ACCEPT_MULTICAST)
4318 : 0 : new_val |= TXGBE_POOLETHCTL_MCP;
4319 : :
4320 : 0 : return new_val;
4321 : : }
4322 : :
4323 : : static int
4324 : 0 : txgbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
4325 : : {
4326 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
4327 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
4328 : : uint32_t mask;
4329 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4330 : :
4331 [ # # ]: 0 : if (queue_id < 32) {
4332 : : mask = rd32(hw, TXGBE_IMC(0));
4333 : 0 : mask |= (1 << queue_id);
4334 : : wr32(hw, TXGBE_IMC(0), mask);
4335 [ # # ]: 0 : } else if (queue_id < 64) {
4336 : : mask = rd32(hw, TXGBE_IMC(1));
4337 : 0 : mask |= (1 << (queue_id - 32));
4338 : : wr32(hw, TXGBE_IMC(1), mask);
4339 : : }
4340 : 0 : rte_intr_enable(intr_handle);
4341 : :
4342 : 0 : return 0;
4343 : : }
4344 : :
4345 : : static int
4346 : 0 : txgbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
4347 : : {
4348 : : uint32_t mask;
4349 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4350 : :
4351 [ # # ]: 0 : if (queue_id < 32) {
4352 : : mask = rd32(hw, TXGBE_IMS(0));
4353 : 0 : mask |= (1 << queue_id);
4354 : : wr32(hw, TXGBE_IMS(0), mask);
4355 [ # # ]: 0 : } else if (queue_id < 64) {
4356 : : mask = rd32(hw, TXGBE_IMS(1));
4357 : 0 : mask |= (1 << (queue_id - 32));
4358 : : wr32(hw, TXGBE_IMS(1), mask);
4359 : : }
4360 : :
4361 : 0 : return 0;
4362 : : }
4363 : :
4364 : : /**
4365 : : * set the IVAR registers, mapping interrupt causes to vectors
4366 : : * @param hw
4367 : : * pointer to txgbe_hw struct
4368 : : * @direction
4369 : : * 0 for Rx, 1 for Tx, -1 for other causes
4370 : : * @queue
4371 : : * queue to map the corresponding interrupt to
4372 : : * @msix_vector
4373 : : * the vector to map to the corresponding queue
4374 : : */
4375 : : void
4376 : 0 : txgbe_set_ivar_map(struct txgbe_hw *hw, int8_t direction,
4377 : : uint8_t queue, uint8_t msix_vector)
4378 : : {
4379 : : uint32_t tmp, idx;
4380 : :
4381 [ # # ]: 0 : if (direction == -1) {
4382 : : /* other causes */
4383 : 0 : msix_vector |= TXGBE_IVARMISC_VLD;
4384 : : idx = 0;
4385 : : tmp = rd32(hw, TXGBE_IVARMISC);
4386 : 0 : tmp &= ~(0xFF << idx);
4387 : 0 : tmp |= (msix_vector << idx);
4388 : : wr32(hw, TXGBE_IVARMISC, tmp);
4389 : : } else {
4390 : : /* rx or tx causes */
4391 : 0 : msix_vector |= TXGBE_IVAR_VLD; /* Workaround for ICR lost */
4392 : 0 : idx = ((16 * (queue & 1)) + (8 * direction));
4393 : 0 : tmp = rd32(hw, TXGBE_IVAR(queue >> 1));
4394 : 0 : tmp &= ~(0xFF << idx);
4395 : 0 : tmp |= (msix_vector << idx);
4396 : : wr32(hw, TXGBE_IVAR(queue >> 1), tmp);
4397 : : }
4398 : 0 : }
4399 : :
4400 : : /**
4401 : : * Sets up the hardware to properly generate MSI-X interrupts
4402 : : * @hw
4403 : : * board private structure
4404 : : */
4405 : : static void
4406 : 0 : txgbe_configure_msix(struct rte_eth_dev *dev)
4407 : : {
4408 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
4409 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
4410 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4411 : : uint32_t queue_id, base = TXGBE_MISC_VEC_ID;
4412 : : uint32_t vec = TXGBE_MISC_VEC_ID;
4413 : : uint32_t gpie;
4414 : :
4415 : : /* won't configure msix register if no mapping is done
4416 : : * between intr vector and event fd
4417 : : * but if misx has been enabled already, need to configure
4418 : : * auto clean, auto mask and throttling.
4419 : : */
4420 : : gpie = rd32(hw, TXGBE_GPIE);
4421 [ # # ]: 0 : if (!rte_intr_dp_is_en(intr_handle) &&
4422 [ # # ]: 0 : !(gpie & TXGBE_GPIE_MSIX))
4423 : : return;
4424 : :
4425 [ # # ]: 0 : if (rte_intr_allow_others(intr_handle)) {
4426 : : base = TXGBE_RX_VEC_START;
4427 : : vec = base;
4428 : : }
4429 : :
4430 : : /* setup GPIE for MSI-x mode */
4431 : : gpie = rd32(hw, TXGBE_GPIE);
4432 : 0 : gpie |= TXGBE_GPIE_MSIX;
4433 : : wr32(hw, TXGBE_GPIE, gpie);
4434 : :
4435 : : /* Populate the IVAR table and set the ITR values to the
4436 : : * corresponding register.
4437 : : */
4438 [ # # ]: 0 : if (rte_intr_dp_is_en(intr_handle)) {
4439 [ # # ]: 0 : for (queue_id = 0; queue_id < dev->data->nb_rx_queues;
4440 : 0 : queue_id++) {
4441 : : /* by default, 1:1 mapping */
4442 : 0 : txgbe_set_ivar_map(hw, 0, queue_id, vec);
4443 : 0 : rte_intr_vec_list_index_set(intr_handle,
4444 : : queue_id, vec);
4445 : 0 : if (vec < base + rte_intr_nb_efd_get(intr_handle)
4446 [ # # ]: 0 : - 1)
4447 : 0 : vec++;
4448 : : }
4449 : :
4450 : 0 : txgbe_set_ivar_map(hw, -1, 1, TXGBE_MISC_VEC_ID);
4451 : : }
4452 : : wr32(hw, TXGBE_ITR(TXGBE_MISC_VEC_ID),
4453 : : TXGBE_ITR_IVAL_10G(TXGBE_QUEUE_ITR_INTERVAL_DEFAULT)
4454 : : | TXGBE_ITR_WRDSA);
4455 : : }
4456 : :
4457 : : static u16 txgbe_frac_to_bi(u16 frac, u16 denom, int max_bits)
4458 : : {
4459 : : u16 value = 0;
4460 : :
4461 [ # # ]: 0 : while (frac > 0 && max_bits > 0) {
4462 : 0 : max_bits -= 1;
4463 : 0 : frac *= 2;
4464 [ # # ]: 0 : if (frac >= denom) {
4465 : 0 : value |= BIT(max_bits);
4466 : 0 : frac -= denom;
4467 : : }
4468 : : }
4469 : :
4470 : : return value;
4471 : : }
4472 : :
4473 : : int
4474 : 0 : txgbe_set_queue_rate_limit(struct rte_eth_dev *dev,
4475 : : uint16_t queue_idx, uint32_t tx_rate)
4476 : : {
4477 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4478 : : uint32_t bcnrc_val;
4479 : : int factor_int, factor_fra;
4480 : : uint32_t link_speed;
4481 : :
4482 [ # # ]: 0 : if (queue_idx >= hw->mac.max_tx_queues)
4483 : : return -EINVAL;
4484 : :
4485 : : /*
4486 : : * Set global transmit compensation time to the MMW_SIZE in ARBTXMMW
4487 : : * register. MMW_SIZE=0x014 if 9728-byte jumbo is supported.
4488 : : */
4489 : : wr32(hw, TXGBE_ARBTXMMW, 0x14);
4490 : :
4491 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) {
4492 [ # # ]: 0 : if (tx_rate) {
4493 : : u16 frac;
4494 : :
4495 : 0 : link_speed = dev->data->dev_link.link_speed;
4496 : : /* Calculate the rate factor values to set */
4497 : 0 : factor_int = link_speed / tx_rate;
4498 : 0 : frac = (link_speed % tx_rate) * 10000 / tx_rate;
4499 : 0 : factor_fra = txgbe_frac_to_bi(frac, 10000, 14);
4500 [ # # ]: 0 : if (tx_rate > link_speed) {
4501 : : factor_int = 1;
4502 : : factor_fra = 0;
4503 : : }
4504 : :
4505 : : wr32(hw, TXGBE_TDM_RL_ADJ, TXGBE_FRAME_OVERHEAD);
4506 : : wr32(hw, TXGBE_TDM_RL_QUEUE_IDX, queue_idx);
4507 : 0 : wr32m(hw, TXGBE_TDM_RL_QUEUE_CFG,
4508 : 0 : TXGBE_TDM_FACTOR_INT_MASK, factor_int << TXGBE_TDM_FACTOR_INT_SHIFT);
4509 : 0 : wr32m(hw, TXGBE_TDM_RL_QUEUE_CFG,
4510 : 0 : TXGBE_TDM_FACTOR_FRA_MASK, factor_fra << TXGBE_TDM_FACTOR_FRA_SHIFT);
4511 : : wr32m(hw, TXGBE_TDM_RL_QUEUE_CFG,
4512 : : TXGBE_TDM_RL_EN, TXGBE_TDM_RL_EN);
4513 : : } else {
4514 : : wr32(hw, TXGBE_TDM_RL_QUEUE_IDX, queue_idx);
4515 : : wr32m(hw, TXGBE_TDM_RL_QUEUE_CFG,
4516 : : TXGBE_TDM_RL_EN, 0);
4517 : : }
4518 : : } else {
4519 [ # # ]: 0 : if (tx_rate != 0) {
4520 : 0 : bcnrc_val = TXGBE_ARBTXRATE_MAX(tx_rate);
4521 : 0 : bcnrc_val |= TXGBE_ARBTXRATE_MIN(tx_rate / 2);
4522 : : } else {
4523 : : bcnrc_val = 0;
4524 : : }
4525 : :
4526 : : /* Set ARBTXRATE of queue X */
4527 : : wr32(hw, TXGBE_ARBPOOLIDX, queue_idx);
4528 : : wr32(hw, TXGBE_ARBTXRATE, bcnrc_val);
4529 : : txgbe_flush(hw);
4530 : : }
4531 : :
4532 : : return 0;
4533 : : }
4534 : :
4535 : : int
4536 : 0 : txgbe_syn_filter_set(struct rte_eth_dev *dev,
4537 : : struct rte_eth_syn_filter *filter,
4538 : : bool add)
4539 : : {
4540 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4541 : : struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(dev);
4542 : : uint32_t syn_info;
4543 : : uint32_t synqf;
4544 : : uint16_t queue;
4545 : :
4546 [ # # ]: 0 : if (filter->queue >= TXGBE_MAX_RX_QUEUE_NUM)
4547 : : return -EINVAL;
4548 : :
4549 : 0 : syn_info = filter_info->syn_info;
4550 : :
4551 [ # # ]: 0 : if (add) {
4552 [ # # ]: 0 : if (syn_info & TXGBE_SYNCLS_ENA)
4553 : : return -EINVAL;
4554 [ # # ]: 0 : if (RTE_ETH_DEV_SRIOV(dev).active)
4555 : 0 : queue = RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx + filter->queue;
4556 : : else
4557 : : queue = filter->queue;
4558 : 0 : synqf = (uint32_t)TXGBE_SYNCLS_QPID(queue);
4559 : 0 : synqf |= TXGBE_SYNCLS_ENA;
4560 : :
4561 [ # # ]: 0 : if (filter->hig_pri)
4562 : 0 : synqf |= TXGBE_SYNCLS_HIPRIO;
4563 : : else
4564 : : synqf &= ~TXGBE_SYNCLS_HIPRIO;
4565 : : } else {
4566 : : synqf = rd32(hw, TXGBE_SYNCLS);
4567 [ # # ]: 0 : if (!(syn_info & TXGBE_SYNCLS_ENA))
4568 : : return -ENOENT;
4569 : 0 : synqf &= ~(TXGBE_SYNCLS_QPID_MASK | TXGBE_SYNCLS_ENA);
4570 : : }
4571 : :
4572 : 0 : filter_info->syn_info = synqf;
4573 : : wr32(hw, TXGBE_SYNCLS, synqf);
4574 : : txgbe_flush(hw);
4575 : : return 0;
4576 : : }
4577 : :
4578 : : static inline enum txgbe_5tuple_protocol
4579 : : convert_protocol_type(uint8_t protocol_value)
4580 : : {
4581 : 0 : if (protocol_value == IPPROTO_TCP)
4582 : : return TXGBE_5TF_PROT_TCP;
4583 [ # # ]: 0 : else if (protocol_value == IPPROTO_UDP)
4584 : : return TXGBE_5TF_PROT_UDP;
4585 [ # # ]: 0 : else if (protocol_value == IPPROTO_SCTP)
4586 : : return TXGBE_5TF_PROT_SCTP;
4587 : : else
4588 : 0 : return TXGBE_5TF_PROT_NONE;
4589 : : }
4590 : :
4591 : : /* inject a 5-tuple filter to HW */
4592 : : static inline void
4593 : 0 : txgbe_inject_5tuple_filter(struct rte_eth_dev *dev,
4594 : : struct txgbe_5tuple_filter *filter)
4595 : : {
4596 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4597 : : int i;
4598 : : uint32_t ftqf, sdpqf;
4599 : : uint32_t l34timir = 0;
4600 : : uint32_t mask = TXGBE_5TFCTL0_MASK;
4601 : :
4602 : 0 : i = filter->index;
4603 [ # # ]: 0 : sdpqf = TXGBE_5TFPORT_DST(be_to_le16(filter->filter_info.dst_port));
4604 [ # # ]: 0 : sdpqf |= TXGBE_5TFPORT_SRC(be_to_le16(filter->filter_info.src_port));
4605 : :
4606 : 0 : ftqf = TXGBE_5TFCTL0_PROTO(filter->filter_info.proto);
4607 : 0 : ftqf |= TXGBE_5TFCTL0_PRI(filter->filter_info.priority);
4608 [ # # ]: 0 : if (filter->filter_info.src_ip_mask == 0) /* 0 means compare. */
4609 : : mask &= ~TXGBE_5TFCTL0_MSADDR;
4610 [ # # ]: 0 : if (filter->filter_info.dst_ip_mask == 0)
4611 : 0 : mask &= ~TXGBE_5TFCTL0_MDADDR;
4612 [ # # ]: 0 : if (filter->filter_info.src_port_mask == 0)
4613 : 0 : mask &= ~TXGBE_5TFCTL0_MSPORT;
4614 [ # # ]: 0 : if (filter->filter_info.dst_port_mask == 0)
4615 : 0 : mask &= ~TXGBE_5TFCTL0_MDPORT;
4616 [ # # ]: 0 : if (filter->filter_info.proto_mask == 0)
4617 : 0 : mask &= ~TXGBE_5TFCTL0_MPROTO;
4618 : 0 : ftqf |= mask;
4619 : : ftqf |= TXGBE_5TFCTL0_MPOOL;
4620 : 0 : ftqf |= TXGBE_5TFCTL0_ENA;
4621 : :
4622 [ # # ]: 0 : wr32(hw, TXGBE_5TFDADDR(i), be_to_le32(filter->filter_info.dst_ip));
4623 [ # # ]: 0 : wr32(hw, TXGBE_5TFSADDR(i), be_to_le32(filter->filter_info.src_ip));
4624 : 0 : wr32(hw, TXGBE_5TFPORT(i), sdpqf);
4625 : 0 : wr32(hw, TXGBE_5TFCTL0(i), ftqf);
4626 : :
4627 [ # # ]: 0 : if (RTE_ETH_DEV_SRIOV(dev).active)
4628 : 0 : l34timir |= TXGBE_5TFCTL1_QP(RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx + filter->queue);
4629 : : else
4630 : 0 : l34timir |= TXGBE_5TFCTL1_QP(filter->queue);
4631 : 0 : wr32(hw, TXGBE_5TFCTL1(i), l34timir);
4632 : 0 : }
4633 : :
4634 : : /*
4635 : : * add a 5tuple filter
4636 : : *
4637 : : * @param
4638 : : * dev: Pointer to struct rte_eth_dev.
4639 : : * index: the index the filter allocates.
4640 : : * filter: pointer to the filter that will be added.
4641 : : * rx_queue: the queue id the filter assigned to.
4642 : : *
4643 : : * @return
4644 : : * - On success, zero.
4645 : : * - On failure, a negative value.
4646 : : */
4647 : : static int
4648 : 0 : txgbe_add_5tuple_filter(struct rte_eth_dev *dev,
4649 : : struct txgbe_5tuple_filter *filter)
4650 : : {
4651 : 0 : struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(dev);
4652 : : int i, idx, shift;
4653 : : int err;
4654 : :
4655 : : /*
4656 : : * look for an unused 5tuple filter index,
4657 : : * and insert the filter to list.
4658 : : */
4659 [ # # ]: 0 : for (i = 0; i < TXGBE_MAX_FTQF_FILTERS; i++) {
4660 : 0 : idx = i / (sizeof(uint32_t) * NBBY);
4661 : 0 : shift = i % (sizeof(uint32_t) * NBBY);
4662 [ # # ]: 0 : if (!(filter_info->fivetuple_mask[idx] & (1 << shift))) {
4663 : 0 : filter_info->fivetuple_mask[idx] |= 1 << shift;
4664 : 0 : filter->index = i;
4665 : 0 : TAILQ_INSERT_TAIL(&filter_info->fivetuple_list,
4666 : : filter,
4667 : : entries);
4668 : 0 : break;
4669 : : }
4670 : : }
4671 [ # # ]: 0 : if (i >= TXGBE_MAX_FTQF_FILTERS) {
4672 : 0 : PMD_DRV_LOG(INFO, "5tuple filters are full, switch to FDIR");
4673 : 0 : filter_info->ntuple_is_full = true;
4674 : 0 : return -ENOSYS;
4675 : : }
4676 : :
4677 [ # # ]: 0 : if (txgbe_is_pf(TXGBE_DEV_HW(dev))) {
4678 : 0 : txgbe_inject_5tuple_filter(dev, filter);
4679 : 0 : return 0;
4680 : : }
4681 : :
4682 : 0 : err = txgbevf_inject_5tuple_filter(dev, filter);
4683 [ # # ]: 0 : if (err) {
4684 : 0 : filter_info->fivetuple_mask[i / (sizeof(uint32_t) * NBBY)] &=
4685 : 0 : ~(1 << (i % (sizeof(uint32_t) * NBBY)));
4686 [ # # ]: 0 : TAILQ_REMOVE(&filter_info->fivetuple_list, filter, entries);
4687 : : }
4688 : :
4689 : : return err;
4690 : : }
4691 : :
4692 : : /*
4693 : : * remove a 5tuple filter
4694 : : *
4695 : : * @param
4696 : : * dev: Pointer to struct rte_eth_dev.
4697 : : * filter: the pointer of the filter will be removed.
4698 : : */
4699 : : static void
4700 : 0 : txgbe_remove_5tuple_filter(struct rte_eth_dev *dev,
4701 : : struct txgbe_5tuple_filter *filter)
4702 : : {
4703 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4704 : : struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(dev);
4705 : 0 : uint16_t index = filter->index;
4706 : :
4707 : 0 : filter_info->fivetuple_mask[index / (sizeof(uint32_t) * NBBY)] &=
4708 : 0 : ~(1 << (index % (sizeof(uint32_t) * NBBY)));
4709 [ # # ]: 0 : TAILQ_REMOVE(&filter_info->fivetuple_list, filter, entries);
4710 : 0 : rte_free(filter);
4711 : 0 : filter_info->ntuple_is_full = false;
4712 : :
4713 [ # # ]: 0 : if (!txgbe_is_pf(TXGBE_DEV_HW(dev))) {
4714 : 0 : txgbevf_remove_5tuple_filter(dev, index);
4715 : 0 : return;
4716 : : }
4717 : :
4718 : 0 : wr32(hw, TXGBE_5TFDADDR(index), 0);
4719 : 0 : wr32(hw, TXGBE_5TFSADDR(index), 0);
4720 : 0 : wr32(hw, TXGBE_5TFPORT(index), 0);
4721 : 0 : wr32(hw, TXGBE_5TFCTL0(index), 0);
4722 : 0 : wr32(hw, TXGBE_5TFCTL1(index), 0);
4723 : : }
4724 : :
4725 : : static inline struct txgbe_5tuple_filter *
4726 : : txgbe_5tuple_filter_lookup(struct txgbe_5tuple_filter_list *filter_list,
4727 : : struct txgbe_5tuple_filter_info *key)
4728 : : {
4729 : : struct txgbe_5tuple_filter *it;
4730 : :
4731 [ # # ]: 0 : TAILQ_FOREACH(it, filter_list, entries) {
4732 [ # # ]: 0 : if (memcmp(key, &it->filter_info,
4733 : : sizeof(struct txgbe_5tuple_filter_info)) == 0) {
4734 : : return it;
4735 : : }
4736 : : }
4737 : : return NULL;
4738 : : }
4739 : :
4740 : : /* translate elements in struct rte_eth_ntuple_filter
4741 : : * to struct txgbe_5tuple_filter_info
4742 : : */
4743 : : static inline int
4744 : 0 : ntuple_filter_to_5tuple(struct rte_eth_ntuple_filter *filter,
4745 : : struct txgbe_5tuple_filter_info *filter_info)
4746 : : {
4747 [ # # ]: 0 : if (filter->queue >= TXGBE_MAX_RX_QUEUE_NUM ||
4748 [ # # # # ]: 0 : filter->priority > TXGBE_5TUPLE_MAX_PRI ||
4749 : : filter->priority < TXGBE_5TUPLE_MIN_PRI)
4750 : : return -EINVAL;
4751 : :
4752 [ # # # ]: 0 : switch (filter->dst_ip_mask) {
4753 : 0 : case UINT32_MAX:
4754 : 0 : filter_info->dst_ip_mask = 0;
4755 : 0 : filter_info->dst_ip = filter->dst_ip;
4756 : 0 : break;
4757 : 0 : case 0:
4758 : 0 : filter_info->dst_ip_mask = 1;
4759 : 0 : break;
4760 : 0 : default:
4761 : 0 : PMD_DRV_LOG(ERR, "invalid dst_ip mask.");
4762 : 0 : return -EINVAL;
4763 : : }
4764 : :
4765 [ # # # ]: 0 : switch (filter->src_ip_mask) {
4766 : 0 : case UINT32_MAX:
4767 : 0 : filter_info->src_ip_mask = 0;
4768 : 0 : filter_info->src_ip = filter->src_ip;
4769 : 0 : break;
4770 : 0 : case 0:
4771 : 0 : filter_info->src_ip_mask = 1;
4772 : 0 : break;
4773 : 0 : default:
4774 : 0 : PMD_DRV_LOG(ERR, "invalid src_ip mask.");
4775 : 0 : return -EINVAL;
4776 : : }
4777 : :
4778 [ # # # ]: 0 : switch (filter->dst_port_mask) {
4779 : 0 : case UINT16_MAX:
4780 : 0 : filter_info->dst_port_mask = 0;
4781 : 0 : filter_info->dst_port = filter->dst_port;
4782 : 0 : break;
4783 : 0 : case 0:
4784 : 0 : filter_info->dst_port_mask = 1;
4785 : 0 : break;
4786 : 0 : default:
4787 : 0 : PMD_DRV_LOG(ERR, "invalid dst_port mask.");
4788 : 0 : return -EINVAL;
4789 : : }
4790 : :
4791 [ # # # ]: 0 : switch (filter->src_port_mask) {
4792 : 0 : case UINT16_MAX:
4793 : 0 : filter_info->src_port_mask = 0;
4794 : 0 : filter_info->src_port = filter->src_port;
4795 : 0 : break;
4796 : 0 : case 0:
4797 : 0 : filter_info->src_port_mask = 1;
4798 : 0 : break;
4799 : 0 : default:
4800 : 0 : PMD_DRV_LOG(ERR, "invalid src_port mask.");
4801 : 0 : return -EINVAL;
4802 : : }
4803 : :
4804 [ # # # ]: 0 : switch (filter->proto_mask) {
4805 : 0 : case UINT8_MAX:
4806 : 0 : filter_info->proto_mask = 0;
4807 : 0 : filter_info->proto =
4808 [ # # ]: 0 : convert_protocol_type(filter->proto);
4809 : 0 : break;
4810 : 0 : case 0:
4811 : 0 : filter_info->proto_mask = 1;
4812 : 0 : break;
4813 : 0 : default:
4814 : 0 : PMD_DRV_LOG(ERR, "invalid protocol mask.");
4815 : 0 : return -EINVAL;
4816 : : }
4817 : :
4818 : 0 : filter_info->priority = (uint8_t)filter->priority;
4819 : 0 : return 0;
4820 : : }
4821 : :
4822 : : /*
4823 : : * add or delete a ntuple filter
4824 : : *
4825 : : * @param
4826 : : * dev: Pointer to struct rte_eth_dev.
4827 : : * ntuple_filter: Pointer to struct rte_eth_ntuple_filter
4828 : : * add: if true, add filter, if false, remove filter
4829 : : *
4830 : : * @return
4831 : : * - On success, zero.
4832 : : * - On failure, a negative value.
4833 : : */
4834 : : int
4835 : 0 : txgbe_add_del_ntuple_filter(struct rte_eth_dev *dev,
4836 : : struct rte_eth_ntuple_filter *ntuple_filter,
4837 : : bool add)
4838 : : {
4839 : 0 : struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(dev);
4840 : : struct txgbe_5tuple_filter_info filter_5tuple;
4841 : : struct txgbe_5tuple_filter *filter;
4842 : : int ret;
4843 : :
4844 [ # # ]: 0 : if (ntuple_filter->flags != RTE_5TUPLE_FLAGS) {
4845 : 0 : PMD_DRV_LOG(ERR, "only 5tuple is supported.");
4846 : 0 : return -EINVAL;
4847 : : }
4848 : :
4849 : : memset(&filter_5tuple, 0, sizeof(struct txgbe_5tuple_filter_info));
4850 : 0 : ret = ntuple_filter_to_5tuple(ntuple_filter, &filter_5tuple);
4851 [ # # ]: 0 : if (ret < 0)
4852 : : return ret;
4853 : :
4854 : : filter = txgbe_5tuple_filter_lookup(&filter_info->fivetuple_list,
4855 : : &filter_5tuple);
4856 [ # # ]: 0 : if (filter != NULL && add) {
4857 : 0 : PMD_DRV_LOG(ERR, "filter exists.");
4858 : 0 : return -EEXIST;
4859 : : }
4860 [ # # ]: 0 : if (filter == NULL && !add) {
4861 : 0 : PMD_DRV_LOG(ERR, "filter doesn't exist.");
4862 : 0 : return -ENOENT;
4863 : : }
4864 : :
4865 [ # # ]: 0 : if (add) {
4866 : 0 : filter = rte_zmalloc("txgbe_5tuple_filter",
4867 : : sizeof(struct txgbe_5tuple_filter), 0);
4868 [ # # ]: 0 : if (filter == NULL)
4869 : : return -ENOMEM;
4870 : : rte_memcpy(&filter->filter_info,
4871 : : &filter_5tuple,
4872 : : sizeof(struct txgbe_5tuple_filter_info));
4873 : 0 : filter->queue = ntuple_filter->queue;
4874 : 0 : ret = txgbe_add_5tuple_filter(dev, filter);
4875 [ # # ]: 0 : if (ret < 0) {
4876 : 0 : rte_free(filter);
4877 : 0 : return ret;
4878 : : }
4879 : : } else {
4880 : 0 : txgbe_remove_5tuple_filter(dev, filter);
4881 : : }
4882 : :
4883 : : return 0;
4884 : : }
4885 : :
4886 : : int
4887 : 0 : txgbe_add_del_ethertype_filter(struct rte_eth_dev *dev,
4888 : : struct rte_eth_ethertype_filter *filter,
4889 : : bool add)
4890 : : {
4891 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4892 : 0 : struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(dev);
4893 : : uint32_t etqf = 0;
4894 : : uint32_t etqs = 0;
4895 : : int ret;
4896 : : struct txgbe_ethertype_filter ethertype_filter;
4897 : :
4898 [ # # ]: 0 : if (filter->queue >= TXGBE_MAX_RX_QUEUE_NUM)
4899 : : return -EINVAL;
4900 : :
4901 [ # # ]: 0 : if (filter->ether_type == RTE_ETHER_TYPE_IPV4 ||
4902 : : filter->ether_type == RTE_ETHER_TYPE_IPV6) {
4903 : 0 : PMD_DRV_LOG(ERR, "unsupported ether_type(0x%04x) in"
4904 : : " ethertype filter.", filter->ether_type);
4905 : 0 : return -EINVAL;
4906 : : }
4907 : :
4908 [ # # ]: 0 : if (filter->flags & RTE_ETHTYPE_FLAGS_MAC) {
4909 : 0 : PMD_DRV_LOG(ERR, "mac compare is unsupported.");
4910 : 0 : return -EINVAL;
4911 : : }
4912 [ # # ]: 0 : if (filter->flags & RTE_ETHTYPE_FLAGS_DROP) {
4913 : 0 : PMD_DRV_LOG(ERR, "drop option is unsupported.");
4914 : 0 : return -EINVAL;
4915 : : }
4916 : :
4917 : 0 : ret = txgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
4918 [ # # ]: 0 : if (ret >= 0 && add) {
4919 : 0 : PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter exists.",
4920 : : filter->ether_type);
4921 : 0 : return -EEXIST;
4922 : : }
4923 [ # # ]: 0 : if (ret < 0 && !add) {
4924 : 0 : PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
4925 : : filter->ether_type);
4926 : 0 : return -ENOENT;
4927 : : }
4928 : :
4929 [ # # ]: 0 : if (add) {
4930 : : etqf = TXGBE_ETFLT_ENA;
4931 : 0 : etqf |= TXGBE_ETFLT_ETID(filter->ether_type);
4932 [ # # ]: 0 : if (RTE_ETH_DEV_SRIOV(dev).active) {
4933 : : int pool, queue;
4934 : :
4935 : 0 : pool = RTE_ETH_DEV_SRIOV(dev).def_vmdq_idx;
4936 : 0 : queue = RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx + filter->queue;
4937 : 0 : etqf |= TXGBE_ETFLT_POOLENA;
4938 : 0 : etqf |= TXGBE_ETFLT_POOL(pool);
4939 : 0 : etqs |= TXGBE_ETCLS_QPID(queue);
4940 : : } else {
4941 : 0 : etqs |= TXGBE_ETCLS_QPID(filter->queue);
4942 : : }
4943 : 0 : etqs |= TXGBE_ETCLS_QENA;
4944 : :
4945 : 0 : ethertype_filter.ethertype = filter->ether_type;
4946 : 0 : ethertype_filter.etqf = etqf;
4947 : 0 : ethertype_filter.etqs = etqs;
4948 : 0 : ethertype_filter.conf = FALSE;
4949 : 0 : ret = txgbe_ethertype_filter_insert(filter_info,
4950 : : ðertype_filter);
4951 [ # # ]: 0 : if (ret < 0) {
4952 : 0 : PMD_DRV_LOG(ERR, "ethertype filters are full.");
4953 : 0 : return -ENOSPC;
4954 : : }
4955 : : } else {
4956 [ # # ]: 0 : ret = txgbe_ethertype_filter_remove(filter_info, (uint8_t)ret);
4957 : : if (ret < 0)
4958 : : return -ENOSYS;
4959 : : }
4960 : 0 : wr32(hw, TXGBE_ETFLT(ret), etqf);
4961 : 0 : wr32(hw, TXGBE_ETCLS(ret), etqs);
4962 : : txgbe_flush(hw);
4963 : :
4964 : : return 0;
4965 : : }
4966 : :
4967 : : static int
4968 : 0 : txgbe_dev_flow_ops_get(__rte_unused struct rte_eth_dev *dev,
4969 : : const struct rte_flow_ops **ops)
4970 : : {
4971 : 0 : *ops = &txgbe_flow_ops;
4972 : 0 : return 0;
4973 : : }
4974 : :
4975 : : static u8 *
4976 : 0 : txgbe_dev_addr_list_itr(__rte_unused struct txgbe_hw *hw,
4977 : : u8 **mc_addr_ptr, u32 *vmdq)
4978 : : {
4979 : : u8 *mc_addr;
4980 : :
4981 : 0 : *vmdq = 0;
4982 : 0 : mc_addr = *mc_addr_ptr;
4983 : 0 : *mc_addr_ptr = (mc_addr + sizeof(struct rte_ether_addr));
4984 : 0 : return mc_addr;
4985 : : }
4986 : :
4987 : : int
4988 : 0 : txgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
4989 : : struct rte_ether_addr *mc_addr_set,
4990 : : uint32_t nb_mc_addr)
4991 : : {
4992 : : struct txgbe_hw *hw;
4993 : : u8 *mc_addr_list;
4994 : :
4995 : 0 : hw = TXGBE_DEV_HW(dev);
4996 : : mc_addr_list = (u8 *)mc_addr_set;
4997 : 0 : return hw->mac.update_mc_addr_list(hw, mc_addr_list, nb_mc_addr,
4998 : : txgbe_dev_addr_list_itr, TRUE);
4999 : : }
5000 : :
5001 : : static uint64_t
5002 : : txgbe_read_systime_cyclecounter(struct rte_eth_dev *dev)
5003 : : {
5004 : : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
5005 : : uint64_t systime_cycles;
5006 : :
5007 : 0 : systime_cycles = (uint64_t)rd32(hw, TXGBE_TSTIMEL);
5008 [ # # ]: 0 : systime_cycles |= (uint64_t)rd32(hw, TXGBE_TSTIMEH) << 32;
5009 : :
5010 : : return systime_cycles;
5011 : : }
5012 : :
5013 : : static uint64_t
5014 : : txgbe_read_rx_tstamp_cyclecounter(struct rte_eth_dev *dev)
5015 : : {
5016 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
5017 : : uint64_t rx_tstamp_cycles;
5018 : :
5019 : : /* TSRXSTMPL stores ns and TSRXSTMPH stores seconds. */
5020 : 0 : rx_tstamp_cycles = (uint64_t)rd32(hw, TXGBE_TSRXSTMPL);
5021 [ # # ]: 0 : rx_tstamp_cycles |= (uint64_t)rd32(hw, TXGBE_TSRXSTMPH) << 32;
5022 : :
5023 : : return rx_tstamp_cycles;
5024 : : }
5025 : :
5026 : : static uint64_t
5027 : : txgbe_read_tx_tstamp_cyclecounter(struct rte_eth_dev *dev)
5028 : : {
5029 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
5030 : : uint64_t tx_tstamp_cycles;
5031 : :
5032 : : /* TSTXSTMPL stores ns and TSTXSTMPH stores seconds. */
5033 : 0 : tx_tstamp_cycles = (uint64_t)rd32(hw, TXGBE_TSTXSTMPL);
5034 [ # # ]: 0 : tx_tstamp_cycles |= (uint64_t)rd32(hw, TXGBE_TSTXSTMPH) << 32;
5035 : :
5036 : : return tx_tstamp_cycles;
5037 : : }
5038 : :
5039 : : static void
5040 : 0 : txgbe_start_timecounters(struct rte_eth_dev *dev)
5041 : : {
5042 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
5043 : : struct txgbe_adapter *adapter = TXGBE_DEV_ADAPTER(dev);
5044 : : struct rte_eth_link link;
5045 : : uint32_t incval = 0;
5046 : : uint32_t shift = 0;
5047 : :
5048 : : /* Get current link speed. */
5049 : : txgbe_dev_link_update(dev, 1);
5050 : 0 : rte_eth_linkstatus_get(dev, &link);
5051 : :
5052 [ # # # ]: 0 : switch (link.link_speed) {
5053 : : case RTE_ETH_SPEED_NUM_100M:
5054 : : incval = TXGBE_INCVAL_100;
5055 : : shift = TXGBE_INCVAL_SHIFT_100;
5056 : : break;
5057 : 0 : case RTE_ETH_SPEED_NUM_1G:
5058 : : incval = TXGBE_INCVAL_1GB;
5059 : : shift = TXGBE_INCVAL_SHIFT_1GB;
5060 : 0 : break;
5061 : 0 : case RTE_ETH_SPEED_NUM_10G:
5062 : : default:
5063 : : incval = TXGBE_INCVAL_10GB;
5064 : : shift = TXGBE_INCVAL_SHIFT_10GB;
5065 : 0 : break;
5066 : : }
5067 : :
5068 : 0 : wr32(hw, TXGBE_TSTIMEINC, TXGBE_TSTIMEINC_VP(incval, 2));
5069 : :
5070 : 0 : memset(&adapter->systime_tc, 0, sizeof(struct rte_timecounter));
5071 : 0 : memset(&adapter->rx_tstamp_tc, 0, sizeof(struct rte_timecounter));
5072 : 0 : memset(&adapter->tx_tstamp_tc, 0, sizeof(struct rte_timecounter));
5073 : :
5074 : 0 : adapter->systime_tc.cc_mask = TXGBE_CYCLECOUNTER_MASK;
5075 : 0 : adapter->systime_tc.cc_shift = shift;
5076 : 0 : adapter->systime_tc.nsec_mask = (1ULL << shift) - 1;
5077 : :
5078 : 0 : adapter->rx_tstamp_tc.cc_mask = TXGBE_CYCLECOUNTER_MASK;
5079 : 0 : adapter->rx_tstamp_tc.cc_shift = shift;
5080 : 0 : adapter->rx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
5081 : :
5082 : 0 : adapter->tx_tstamp_tc.cc_mask = TXGBE_CYCLECOUNTER_MASK;
5083 : 0 : adapter->tx_tstamp_tc.cc_shift = shift;
5084 : 0 : adapter->tx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
5085 : 0 : }
5086 : :
5087 : : static int
5088 : 0 : txgbe_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta)
5089 : : {
5090 : 0 : struct txgbe_adapter *adapter = TXGBE_DEV_ADAPTER(dev);
5091 : :
5092 : 0 : adapter->systime_tc.nsec += delta;
5093 : 0 : adapter->rx_tstamp_tc.nsec += delta;
5094 : 0 : adapter->tx_tstamp_tc.nsec += delta;
5095 : :
5096 : 0 : return 0;
5097 : : }
5098 : :
5099 : : static int
5100 : 0 : txgbe_timesync_write_time(struct rte_eth_dev *dev, const struct timespec *ts)
5101 : : {
5102 : : uint64_t ns;
5103 : 0 : struct txgbe_adapter *adapter = TXGBE_DEV_ADAPTER(dev);
5104 : :
5105 : : ns = rte_timespec_to_ns(ts);
5106 : : /* Set the timecounters to a new value. */
5107 : 0 : adapter->systime_tc.nsec = ns;
5108 : 0 : adapter->rx_tstamp_tc.nsec = ns;
5109 : 0 : adapter->tx_tstamp_tc.nsec = ns;
5110 : :
5111 : 0 : return 0;
5112 : : }
5113 : :
5114 : : static int
5115 : 0 : txgbe_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts)
5116 : : {
5117 : : uint64_t ns, systime_cycles;
5118 : 0 : struct txgbe_adapter *adapter = TXGBE_DEV_ADAPTER(dev);
5119 : :
5120 : : systime_cycles = txgbe_read_systime_cyclecounter(dev);
5121 : : ns = rte_timecounter_update(&adapter->systime_tc, systime_cycles);
5122 : 0 : *ts = rte_ns_to_timespec(ns);
5123 : :
5124 : 0 : return 0;
5125 : : }
5126 : :
5127 : : static int
5128 : 0 : txgbe_timesync_enable(struct rte_eth_dev *dev)
5129 : : {
5130 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
5131 : : uint32_t tsync_ctl;
5132 : :
5133 : : /* Stop the timesync system time. */
5134 : : wr32(hw, TXGBE_TSTIMEINC, 0x0);
5135 : : /* Reset the timesync system time value. */
5136 : : wr32(hw, TXGBE_TSTIMEL, 0x0);
5137 : : wr32(hw, TXGBE_TSTIMEH, 0x0);
5138 : :
5139 : 0 : txgbe_start_timecounters(dev);
5140 : :
5141 : : /* Enable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
5142 : : wr32(hw, TXGBE_ETFLT(TXGBE_ETF_ID_1588),
5143 : : RTE_ETHER_TYPE_1588 | TXGBE_ETFLT_ENA | TXGBE_ETFLT_1588);
5144 : :
5145 : : /* Enable timestamping of received PTP packets. */
5146 : : tsync_ctl = rd32(hw, TXGBE_TSRXCTL);
5147 : 0 : tsync_ctl |= TXGBE_TSRXCTL_ENA;
5148 : : wr32(hw, TXGBE_TSRXCTL, tsync_ctl);
5149 : :
5150 : : /* Enable timestamping of transmitted PTP packets. */
5151 : : tsync_ctl = rd32(hw, TXGBE_TSTXCTL);
5152 : 0 : tsync_ctl |= TXGBE_TSTXCTL_ENA;
5153 : : wr32(hw, TXGBE_TSTXCTL, tsync_ctl);
5154 : :
5155 : : txgbe_flush(hw);
5156 : :
5157 : 0 : return 0;
5158 : : }
5159 : :
5160 : : static int
5161 : 0 : txgbe_timesync_disable(struct rte_eth_dev *dev)
5162 : : {
5163 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
5164 : : uint32_t tsync_ctl;
5165 : :
5166 : : /* Disable timestamping of transmitted PTP packets. */
5167 : : tsync_ctl = rd32(hw, TXGBE_TSTXCTL);
5168 : 0 : tsync_ctl &= ~TXGBE_TSTXCTL_ENA;
5169 : : wr32(hw, TXGBE_TSTXCTL, tsync_ctl);
5170 : :
5171 : : /* Disable timestamping of received PTP packets. */
5172 : : tsync_ctl = rd32(hw, TXGBE_TSRXCTL);
5173 : 0 : tsync_ctl &= ~TXGBE_TSRXCTL_ENA;
5174 : : wr32(hw, TXGBE_TSRXCTL, tsync_ctl);
5175 : :
5176 : : /* Disable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
5177 : : wr32(hw, TXGBE_ETFLT(TXGBE_ETF_ID_1588), 0);
5178 : :
5179 : : /* Stop incrementing the System Time registers. */
5180 : : wr32(hw, TXGBE_TSTIMEINC, 0);
5181 : :
5182 : 0 : return 0;
5183 : : }
5184 : :
5185 : : static int
5186 : 0 : txgbe_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
5187 : : struct timespec *timestamp,
5188 : : uint32_t flags __rte_unused)
5189 : : {
5190 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
5191 : : struct txgbe_adapter *adapter = TXGBE_DEV_ADAPTER(dev);
5192 : : uint32_t tsync_rxctl;
5193 : : uint64_t rx_tstamp_cycles;
5194 : : uint64_t ns;
5195 : :
5196 : : tsync_rxctl = rd32(hw, TXGBE_TSRXCTL);
5197 [ # # ]: 0 : if ((tsync_rxctl & TXGBE_TSRXCTL_VLD) == 0)
5198 : : return -EINVAL;
5199 : :
5200 : : rx_tstamp_cycles = txgbe_read_rx_tstamp_cyclecounter(dev);
5201 : : ns = rte_timecounter_update(&adapter->rx_tstamp_tc, rx_tstamp_cycles);
5202 : 0 : *timestamp = rte_ns_to_timespec(ns);
5203 : :
5204 : 0 : return 0;
5205 : : }
5206 : :
5207 : : static int
5208 : 0 : txgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
5209 : : struct timespec *timestamp)
5210 : : {
5211 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
5212 : : struct txgbe_adapter *adapter = TXGBE_DEV_ADAPTER(dev);
5213 : : uint32_t tsync_txctl;
5214 : : uint64_t tx_tstamp_cycles;
5215 : : uint64_t ns;
5216 : :
5217 : : tsync_txctl = rd32(hw, TXGBE_TSTXCTL);
5218 [ # # ]: 0 : if ((tsync_txctl & TXGBE_TSTXCTL_VLD) == 0)
5219 : : return -EINVAL;
5220 : :
5221 : : tx_tstamp_cycles = txgbe_read_tx_tstamp_cyclecounter(dev);
5222 : : ns = rte_timecounter_update(&adapter->tx_tstamp_tc, tx_tstamp_cycles);
5223 : 0 : *timestamp = rte_ns_to_timespec(ns);
5224 : :
5225 : 0 : return 0;
5226 : : }
5227 : :
5228 : : static int
5229 : : txgbe_get_reg_length(struct rte_eth_dev *dev __rte_unused)
5230 : : {
5231 : : int count = 0;
5232 : : int g_ind = 0;
5233 : : const struct reg_info *reg_group;
5234 : : const struct reg_info **reg_set = txgbe_regs_others;
5235 : :
5236 [ # # # # ]: 0 : while ((reg_group = reg_set[g_ind++]))
5237 : 0 : count += txgbe_regs_group_count(reg_group);
5238 : :
5239 : : return count;
5240 : : }
5241 : :
5242 : : static int
5243 : 0 : txgbe_get_regs(struct rte_eth_dev *dev,
5244 : : struct rte_dev_reg_info *regs)
5245 : : {
5246 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
5247 : 0 : uint32_t *data = regs->data;
5248 : : int g_ind = 0;
5249 : : int count = 0;
5250 : : const struct reg_info *reg_group;
5251 : : const struct reg_info **reg_set = txgbe_regs_others;
5252 : :
5253 [ # # ]: 0 : if (data == NULL) {
5254 : 0 : regs->length = txgbe_get_reg_length(dev);
5255 : 0 : regs->width = sizeof(uint32_t);
5256 : 0 : return 0;
5257 : : }
5258 : :
5259 : : /* Support only full register dump */
5260 [ # # ]: 0 : if (regs->length == 0 ||
5261 [ # # ]: 0 : regs->length == (uint32_t)txgbe_get_reg_length(dev)) {
5262 : 0 : regs->version = hw->mac.type << 24 |
5263 : 0 : hw->revision_id << 16 |
5264 : 0 : hw->device_id;
5265 [ # # ]: 0 : while ((reg_group = reg_set[g_ind++]))
5266 : 0 : count += txgbe_read_regs_group(dev, &data[count],
5267 : : reg_group);
5268 : : return 0;
5269 : : }
5270 : :
5271 : : return -ENOTSUP;
5272 : : }
5273 : :
5274 : : static int
5275 : 0 : txgbe_get_eeprom_length(struct rte_eth_dev *dev)
5276 : : {
5277 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
5278 : :
5279 : : /* Return unit is byte count */
5280 : 0 : return hw->rom.word_size * 2;
5281 : : }
5282 : :
5283 : : static int
5284 : 0 : txgbe_get_eeprom(struct rte_eth_dev *dev,
5285 : : struct rte_dev_eeprom_info *in_eeprom)
5286 : : {
5287 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
5288 : : struct txgbe_rom_info *eeprom = &hw->rom;
5289 : 0 : uint16_t *data = in_eeprom->data;
5290 : : int first, length;
5291 : :
5292 : 0 : first = in_eeprom->offset >> 1;
5293 : 0 : length = in_eeprom->length >> 1;
5294 [ # # ]: 0 : if (first > hw->rom.word_size ||
5295 [ # # ]: 0 : ((first + length) > hw->rom.word_size))
5296 : : return -EINVAL;
5297 : :
5298 : 0 : in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
5299 : :
5300 : 0 : return eeprom->readw_buffer(hw, first, length, data);
5301 : : }
5302 : :
5303 : : static int
5304 : 0 : txgbe_set_eeprom(struct rte_eth_dev *dev,
5305 : : struct rte_dev_eeprom_info *in_eeprom)
5306 : : {
5307 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
5308 : : struct txgbe_rom_info *eeprom = &hw->rom;
5309 : 0 : uint16_t *data = in_eeprom->data;
5310 : : int first, length;
5311 : :
5312 : 0 : first = in_eeprom->offset >> 1;
5313 : 0 : length = in_eeprom->length >> 1;
5314 [ # # ]: 0 : if (first > hw->rom.word_size ||
5315 [ # # ]: 0 : ((first + length) > hw->rom.word_size))
5316 : : return -EINVAL;
5317 : :
5318 : 0 : in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
5319 : :
5320 : 0 : return eeprom->writew_buffer(hw, first, length, data);
5321 : : }
5322 : :
5323 : : static int
5324 : 0 : txgbe_get_module_info(struct rte_eth_dev *dev,
5325 : : struct rte_eth_dev_module_info *modinfo)
5326 : : {
5327 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
5328 : : uint32_t status;
5329 : : uint8_t sff8472_rev, addr_mode;
5330 : : uint8_t identifier;
5331 : : uint8_t sff8636_rev;
5332 : : bool page_swap = false;
5333 : : uint32_t value;
5334 : :
5335 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml40) {
5336 : : value = rd32(hw, TXGBE_GPIOEXT);
5337 [ # # ]: 0 : if (value & TXGBE_SFP1_MOD_PRST_LS) {
5338 : 0 : PMD_DRV_LOG(WARNING, "QSFP module not present, cannot get module info.");
5339 : 0 : return -EINVAL;
5340 : : }
5341 : : }
5342 : :
5343 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml) {
5344 : : value = rd32(hw, TXGBE_GPIOEXT);
5345 [ # # ]: 0 : if (value & TXGBE_SFP1_MOD_ABS_LS) {
5346 : 0 : PMD_DRV_LOG(WARNING, "SFP module not present, cannot get module info.");
5347 : 0 : return -EINVAL;
5348 : : }
5349 : : }
5350 : :
5351 : 0 : status = hw->mac.acquire_swfw_sync(hw, TXGBE_MNGSEM_SWPHY);
5352 [ # # ]: 0 : if (status != 0)
5353 : : return -EBUSY;
5354 : :
5355 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml40) {
5356 : 0 : status = hw->phy.read_i2c_sff8636(hw, 0,
5357 : : TXGBE_SFF_IDENTIFIER,
5358 : : &identifier);
5359 : : } else {
5360 : 0 : status = hw->phy.read_i2c_eeprom(hw,
5361 : : TXGBE_SFF_IDENTIFIER,
5362 : : &identifier);
5363 : : }
5364 : :
5365 [ # # ]: 0 : if (status != 0)
5366 : 0 : goto ERROR_IO;
5367 : :
5368 [ # # # ]: 0 : switch (identifier) {
5369 : 0 : case TXGBE_SFF_IDENTIFIER_SFP:
5370 : : /* Check whether we support SFF-8472 or not */
5371 : 0 : status = hw->phy.read_i2c_eeprom(hw,
5372 : : TXGBE_SFF_SFF_8472_COMP,
5373 : : &sff8472_rev);
5374 [ # # ]: 0 : if (status != 0)
5375 : 0 : goto ERROR_IO;
5376 : :
5377 : : /* addressing mode is not supported */
5378 : 0 : status = hw->phy.read_i2c_eeprom(hw,
5379 : : TXGBE_SFF_SFF_8472_SWAP,
5380 : : &addr_mode);
5381 [ # # ]: 0 : if (status != 0)
5382 : 0 : goto ERROR_IO;
5383 : :
5384 [ # # ]: 0 : if (addr_mode & TXGBE_SFF_ADDRESSING_MODE) {
5385 : 0 : PMD_DRV_LOG(ERR,
5386 : : "Address change required to access page 0xA2, "
5387 : : "but not supported. Please report the module "
5388 : : "type to the driver maintainers.");
5389 : : page_swap = true;
5390 : : }
5391 : :
5392 [ # # # # ]: 0 : if (sff8472_rev == TXGBE_SFF_SFF_8472_UNSUP || page_swap ||
5393 [ # # ]: 0 : !(addr_mode & TXGBE_SFF_DDM_IMPLEMENTED)) {
5394 : : /* We have a SFP, but it does not support SFF-8472 */
5395 : 0 : modinfo->type = RTE_ETH_MODULE_SFF_8079;
5396 : 0 : modinfo->eeprom_len = RTE_ETH_MODULE_SFF_8079_LEN;
5397 : : } else {
5398 : : /* We have a SFP which supports a revision of SFF-8472. */
5399 : 0 : modinfo->type = RTE_ETH_MODULE_SFF_8472;
5400 : 0 : modinfo->eeprom_len = RTE_ETH_MODULE_SFF_8472_LEN;
5401 : : }
5402 : : break;
5403 : 0 : case TXGBE_SFF_IDENTIFIER_QSFP:
5404 : : case TXGBE_SFF_IDENTIFIER_QSFP_PLUS:
5405 : 0 : status = hw->phy.read_i2c_sff8636(hw, 0,
5406 : : TXGBE_SFF_SFF_REVISION_ADDR,
5407 : : &sff8636_rev);
5408 [ # # ]: 0 : if (status != 0)
5409 : 0 : goto ERROR_IO;
5410 : : /* Check revision compliance */
5411 [ # # ]: 0 : if (sff8636_rev > 0x02) {
5412 : : /* Module is SFF-8636 compliant */
5413 : 0 : modinfo->type = RTE_ETH_MODULE_SFF_8636;
5414 : 0 : modinfo->eeprom_len = TXGBE_MODULE_QSFP_MAX_LEN;
5415 : : } else {
5416 : 0 : modinfo->type = RTE_ETH_MODULE_SFF_8436;
5417 : 0 : modinfo->eeprom_len = TXGBE_MODULE_QSFP_MAX_LEN;
5418 : : }
5419 : : break;
5420 : 0 : default:
5421 : 0 : PMD_DRV_LOG(ERR, "SFF Module Type not recognized, identifier=0x%x", identifier);
5422 : 0 : hw->mac.release_swfw_sync(hw, TXGBE_MNGSEM_SWPHY);
5423 : 0 : return -EINVAL;
5424 : : }
5425 : :
5426 : 0 : hw->mac.release_swfw_sync(hw, TXGBE_MNGSEM_SWPHY);
5427 : 0 : return 0;
5428 : :
5429 : 0 : ERROR_IO:
5430 : 0 : PMD_DRV_LOG(ERR, "I2C IO ERROR.");
5431 : 0 : hw->mac.release_swfw_sync(hw, TXGBE_MNGSEM_SWPHY);
5432 : 0 : return -EIO;
5433 : : }
5434 : :
5435 : : static int
5436 : 0 : txgbe_get_module_eeprom(struct rte_eth_dev *dev,
5437 : : struct rte_dev_eeprom_info *info)
5438 : : {
5439 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
5440 : : uint32_t status = TXGBE_ERR_PHY_ADDR_INVALID;
5441 : 0 : uint8_t databyte = 0xFF;
5442 : 0 : uint8_t *data = info->data;
5443 : : uint32_t i = 0;
5444 : : bool is_sfp = false;
5445 : : uint32_t value;
5446 : 0 : uint8_t identifier = 0;
5447 : : uint16_t offset;
5448 : : uint8_t page = 0;
5449 : : bool is_flat_mem = false;
5450 : :
5451 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml40) {
5452 : : value = rd32(hw, TXGBE_GPIOEXT);
5453 [ # # ]: 0 : if (value & TXGBE_SFP1_MOD_PRST_LS)
5454 : : return -EIO;
5455 : : }
5456 : :
5457 [ # # ]: 0 : if (hw->mac.type == txgbe_mac_aml) {
5458 : : value = rd32(hw, TXGBE_GPIOEXT);
5459 [ # # ]: 0 : if (value & TXGBE_SFP1_MOD_ABS_LS)
5460 : : return -EIO;
5461 : : }
5462 : :
5463 [ # # ]: 0 : if (info->length == 0)
5464 : : return -EINVAL;
5465 : :
5466 : 0 : status = hw->mac.acquire_swfw_sync(hw, TXGBE_MNGSEM_SWPHY);
5467 [ # # ]: 0 : if (status)
5468 : : return -EBUSY;
5469 : :
5470 : 0 : status = hw->phy.read_i2c_eeprom(hw,
5471 : : TXGBE_SFF_IDENTIFIER,
5472 : : &identifier);
5473 [ # # ]: 0 : if (status != 0)
5474 : 0 : goto ERROR_IO;
5475 : :
5476 [ # # ]: 0 : if (identifier == TXGBE_SFF_IDENTIFIER_SFP) {
5477 : : is_sfp = true;
5478 : : } else {
5479 : 0 : uint8_t rdata = 0;
5480 : :
5481 : 0 : status = hw->phy.read_i2c_sff8636(hw, 0,
5482 : : TXGBE_SFF_8636_STATUS_OFFSET,
5483 : : &rdata);
5484 [ # # ]: 0 : if (status != 0)
5485 : 0 : goto ERROR_IO;
5486 : :
5487 [ # # ]: 0 : if (rdata & 0x4)
5488 : : is_flat_mem = true;
5489 : : }
5490 : :
5491 : 0 : memset(data, 0, info->length);
5492 : :
5493 [ # # ]: 0 : for (i = info->offset; i < info->offset + info->length; i++) {
5494 : 0 : databyte = 0;
5495 : :
5496 [ # # ]: 0 : if (is_sfp) {
5497 [ # # ]: 0 : if (i < RTE_ETH_MODULE_SFF_8079_LEN)
5498 : 0 : status = hw->phy.read_i2c_eeprom(hw, i,
5499 : : &databyte);
5500 : : else
5501 : 0 : status = hw->phy.read_i2c_sff8472(hw, i,
5502 : : &databyte);
5503 : :
5504 [ # # ]: 0 : if (status != 0)
5505 : 0 : goto ERROR_IO;
5506 : : } else {
5507 : 0 : offset = i;
5508 : : page = 0;
5509 [ # # ]: 0 : while (offset >= RTE_ETH_MODULE_SFF_8436_LEN) {
5510 : 0 : offset -= RTE_ETH_MODULE_SFF_8436_LEN / 2;
5511 : 0 : page++;
5512 : : }
5513 [ # # ]: 0 : if (page == 0 || !is_flat_mem) {
5514 : 0 : status = hw->phy.read_i2c_sff8636(hw, page, offset,
5515 : : &databyte);
5516 [ # # ]: 0 : if (status != 0)
5517 : 0 : goto ERROR_IO;
5518 : : }
5519 : : }
5520 : 0 : data[i - info->offset] = databyte;
5521 : : }
5522 : :
5523 : 0 : hw->mac.release_swfw_sync(hw, TXGBE_MNGSEM_SWPHY);
5524 : 0 : return 0;
5525 : :
5526 : 0 : ERROR_IO:
5527 : 0 : PMD_DRV_LOG(ERR, "I2C IO ERROR.");
5528 : 0 : hw->mac.release_swfw_sync(hw, TXGBE_MNGSEM_SWPHY);
5529 : 0 : return -EIO;
5530 : : }
5531 : :
5532 : : bool
5533 : 0 : txgbe_rss_update(enum txgbe_mac_type mac_type)
5534 : : {
5535 [ # # ]: 0 : switch (mac_type) {
5536 : : case txgbe_mac_sp:
5537 : : case txgbe_mac_sp_vf:
5538 : : case txgbe_mac_aml:
5539 : : case txgbe_mac_aml40:
5540 : : case txgbe_mac_aml_vf:
5541 : : case txgbe_mac_aml40_vf:
5542 : : return 1;
5543 : 0 : default:
5544 : 0 : return 0;
5545 : : }
5546 : : }
5547 : :
5548 : : static int
5549 : 0 : txgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
5550 : : struct rte_eth_dcb_info *dcb_info)
5551 : : {
5552 : 0 : struct txgbe_dcb_config *dcb_config = TXGBE_DEV_DCB_CONFIG(dev);
5553 : : struct txgbe_dcb_tc_config *tc;
5554 : : struct rte_eth_dcb_tc_queue_mapping *tc_queue;
5555 : : uint8_t nb_tcs;
5556 : : uint8_t i, j;
5557 : :
5558 [ # # ]: 0 : if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_DCB_FLAG)
5559 : 0 : dcb_info->nb_tcs = dcb_config->num_tcs.pg_tcs;
5560 : : else
5561 : 0 : dcb_info->nb_tcs = 1;
5562 : :
5563 : : tc_queue = &dcb_info->tc_queue;
5564 : 0 : nb_tcs = dcb_info->nb_tcs;
5565 : :
5566 [ # # ]: 0 : if (dcb_config->vt_mode) { /* vt is enabled */
5567 : : struct rte_eth_vmdq_dcb_conf *vmdq_rx_conf =
5568 : : &dev->data->dev_conf.rx_adv_conf.vmdq_dcb_conf;
5569 [ # # ]: 0 : for (i = 0; i < RTE_ETH_DCB_NUM_USER_PRIORITIES; i++)
5570 : 0 : dcb_info->prio_tc[i] = vmdq_rx_conf->dcb_tc[i];
5571 [ # # ]: 0 : if (RTE_ETH_DEV_SRIOV(dev).active > 0) {
5572 [ # # ]: 0 : for (j = 0; j < nb_tcs; j++) {
5573 : 0 : tc_queue->tc_rxq[0][j].base = j;
5574 : 0 : tc_queue->tc_rxq[0][j].nb_queue = 1;
5575 : 0 : tc_queue->tc_txq[0][j].base = j;
5576 : 0 : tc_queue->tc_txq[0][j].nb_queue = 1;
5577 : : }
5578 : : } else {
5579 [ # # ]: 0 : for (i = 0; i < vmdq_rx_conf->nb_queue_pools; i++) {
5580 [ # # ]: 0 : for (j = 0; j < nb_tcs; j++) {
5581 : 0 : tc_queue->tc_rxq[i][j].base =
5582 : 0 : i * nb_tcs + j;
5583 : 0 : tc_queue->tc_rxq[i][j].nb_queue = 1;
5584 : 0 : tc_queue->tc_txq[i][j].base =
5585 : : i * nb_tcs + j;
5586 : 0 : tc_queue->tc_txq[i][j].nb_queue = 1;
5587 : : }
5588 : : }
5589 : : }
5590 : : } else { /* vt is disabled */
5591 : : struct rte_eth_dcb_rx_conf *rx_conf =
5592 : : &dev->data->dev_conf.rx_adv_conf.dcb_rx_conf;
5593 [ # # ]: 0 : for (i = 0; i < RTE_ETH_DCB_NUM_USER_PRIORITIES; i++)
5594 : 0 : dcb_info->prio_tc[i] = rx_conf->dcb_tc[i];
5595 [ # # ]: 0 : if (dcb_info->nb_tcs == RTE_ETH_4_TCS) {
5596 [ # # ]: 0 : for (i = 0; i < dcb_info->nb_tcs; i++) {
5597 : 0 : dcb_info->tc_queue.tc_rxq[0][i].base = i * 32;
5598 : 0 : dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
5599 : : }
5600 : 0 : dcb_info->tc_queue.tc_txq[0][0].base = 0;
5601 : 0 : dcb_info->tc_queue.tc_txq[0][1].base = 64;
5602 : 0 : dcb_info->tc_queue.tc_txq[0][2].base = 96;
5603 : 0 : dcb_info->tc_queue.tc_txq[0][3].base = 112;
5604 : 0 : dcb_info->tc_queue.tc_txq[0][0].nb_queue = 64;
5605 : 0 : dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
5606 : 0 : dcb_info->tc_queue.tc_txq[0][2].nb_queue = 16;
5607 : 0 : dcb_info->tc_queue.tc_txq[0][3].nb_queue = 16;
5608 [ # # ]: 0 : } else if (dcb_info->nb_tcs == RTE_ETH_8_TCS) {
5609 [ # # ]: 0 : for (i = 0; i < dcb_info->nb_tcs; i++) {
5610 : 0 : dcb_info->tc_queue.tc_rxq[0][i].base = i * 16;
5611 : 0 : dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
5612 : : }
5613 : 0 : dcb_info->tc_queue.tc_txq[0][0].base = 0;
5614 : 0 : dcb_info->tc_queue.tc_txq[0][1].base = 32;
5615 : 0 : dcb_info->tc_queue.tc_txq[0][2].base = 64;
5616 : 0 : dcb_info->tc_queue.tc_txq[0][3].base = 80;
5617 : 0 : dcb_info->tc_queue.tc_txq[0][4].base = 96;
5618 : 0 : dcb_info->tc_queue.tc_txq[0][5].base = 104;
5619 : 0 : dcb_info->tc_queue.tc_txq[0][6].base = 112;
5620 : 0 : dcb_info->tc_queue.tc_txq[0][7].base = 120;
5621 : 0 : dcb_info->tc_queue.tc_txq[0][0].nb_queue = 32;
5622 : 0 : dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
5623 : 0 : dcb_info->tc_queue.tc_txq[0][2].nb_queue = 16;
5624 : 0 : dcb_info->tc_queue.tc_txq[0][3].nb_queue = 16;
5625 : 0 : dcb_info->tc_queue.tc_txq[0][4].nb_queue = 8;
5626 : 0 : dcb_info->tc_queue.tc_txq[0][5].nb_queue = 8;
5627 : 0 : dcb_info->tc_queue.tc_txq[0][6].nb_queue = 8;
5628 : 0 : dcb_info->tc_queue.tc_txq[0][7].nb_queue = 8;
5629 : : }
5630 : : }
5631 [ # # ]: 0 : for (i = 0; i < dcb_info->nb_tcs; i++) {
5632 : 0 : tc = &dcb_config->tc_config[i];
5633 : 0 : dcb_info->tc_bws[i] = tc->path[TXGBE_DCB_TX_CONFIG].bwg_percent;
5634 : : }
5635 : 0 : return 0;
5636 : : }
5637 : :
5638 : : /* Update e-tag ether type */
5639 : : static int
5640 : 0 : txgbe_update_e_tag_eth_type(struct txgbe_hw *hw,
5641 : : uint16_t ether_type)
5642 : : {
5643 : : uint32_t etag_etype;
5644 : :
5645 : : etag_etype = rd32(hw, TXGBE_EXTAG);
5646 : 0 : etag_etype &= ~TXGBE_EXTAG_ETAG_MASK;
5647 : 0 : etag_etype |= ether_type;
5648 : : wr32(hw, TXGBE_EXTAG, etag_etype);
5649 : : txgbe_flush(hw);
5650 : :
5651 : 0 : return 0;
5652 : : }
5653 : :
5654 : : /* Enable e-tag tunnel */
5655 : : static int
5656 : 0 : txgbe_e_tag_enable(struct txgbe_hw *hw)
5657 : : {
5658 : : uint32_t etag_etype;
5659 : :
5660 : : etag_etype = rd32(hw, TXGBE_PORTCTL);
5661 : 0 : etag_etype |= TXGBE_PORTCTL_ETAG;
5662 : : wr32(hw, TXGBE_PORTCTL, etag_etype);
5663 : : txgbe_flush(hw);
5664 : :
5665 : 0 : return 0;
5666 : : }
5667 : :
5668 : : static int
5669 : 0 : txgbe_e_tag_filter_del(struct rte_eth_dev *dev,
5670 : : struct txgbe_l2_tunnel_conf *l2_tunnel)
5671 : : {
5672 : : int ret = 0;
5673 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
5674 : : uint32_t i, rar_entries;
5675 : : uint32_t rar_low, rar_high;
5676 : :
5677 : 0 : rar_entries = hw->mac.num_rar_entries;
5678 : :
5679 [ # # ]: 0 : for (i = 1; i < rar_entries; i++) {
5680 : : wr32(hw, TXGBE_ETHADDRIDX, i);
5681 : : rar_high = rd32(hw, TXGBE_ETHADDRH);
5682 : : rar_low = rd32(hw, TXGBE_ETHADDRL);
5683 [ # # ]: 0 : if ((rar_high & TXGBE_ETHADDRH_VLD) &&
5684 [ # # ]: 0 : (rar_high & TXGBE_ETHADDRH_ETAG) &&
5685 : 0 : (TXGBE_ETHADDRL_ETAG(rar_low) ==
5686 [ # # ]: 0 : l2_tunnel->tunnel_id)) {
5687 : : wr32(hw, TXGBE_ETHADDRL, 0);
5688 : : wr32(hw, TXGBE_ETHADDRH, 0);
5689 : :
5690 : 0 : txgbe_clear_vmdq(hw, i, BIT_MASK32);
5691 : :
5692 : 0 : return ret;
5693 : : }
5694 : : }
5695 : :
5696 : : return ret;
5697 : : }
5698 : :
5699 : : static int
5700 : 0 : txgbe_e_tag_filter_add(struct rte_eth_dev *dev,
5701 : : struct txgbe_l2_tunnel_conf *l2_tunnel)
5702 : : {
5703 : : int ret = 0;
5704 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
5705 : : uint32_t i, rar_entries;
5706 : : uint32_t rar_low, rar_high;
5707 : :
5708 : : /* One entry for one tunnel. Try to remove potential existing entry. */
5709 : 0 : txgbe_e_tag_filter_del(dev, l2_tunnel);
5710 : :
5711 : 0 : rar_entries = hw->mac.num_rar_entries;
5712 : :
5713 [ # # ]: 0 : for (i = 1; i < rar_entries; i++) {
5714 : : wr32(hw, TXGBE_ETHADDRIDX, i);
5715 : : rar_high = rd32(hw, TXGBE_ETHADDRH);
5716 [ # # ]: 0 : if (rar_high & TXGBE_ETHADDRH_VLD) {
5717 : : continue;
5718 : : } else {
5719 : 0 : txgbe_set_vmdq(hw, i, l2_tunnel->pool);
5720 : : rar_high = TXGBE_ETHADDRH_VLD | TXGBE_ETHADDRH_ETAG;
5721 : 0 : rar_low = l2_tunnel->tunnel_id;
5722 : :
5723 : : wr32(hw, TXGBE_ETHADDRL, rar_low);
5724 : : wr32(hw, TXGBE_ETHADDRH, rar_high);
5725 : :
5726 : 0 : return ret;
5727 : : }
5728 : : }
5729 : :
5730 : 0 : PMD_INIT_LOG(NOTICE, "The table of E-tag forwarding rule is full."
5731 : : " Please remove a rule before adding a new one.");
5732 : 0 : return -EINVAL;
5733 : : }
5734 : :
5735 : : static inline struct txgbe_l2_tn_filter *
5736 : : txgbe_l2_tn_filter_lookup(struct txgbe_l2_tn_info *l2_tn_info,
5737 : : struct txgbe_l2_tn_key *key)
5738 : : {
5739 : : int ret;
5740 : :
5741 : 0 : ret = rte_hash_lookup(l2_tn_info->hash_handle, (const void *)key);
5742 [ # # ]: 0 : if (ret < 0)
5743 : : return NULL;
5744 : :
5745 : 0 : return l2_tn_info->hash_map[ret];
5746 : : }
5747 : :
5748 : : static inline int
5749 : 0 : txgbe_insert_l2_tn_filter(struct txgbe_l2_tn_info *l2_tn_info,
5750 : : struct txgbe_l2_tn_filter *l2_tn_filter)
5751 : : {
5752 : : int ret;
5753 : :
5754 : 0 : ret = rte_hash_add_key(l2_tn_info->hash_handle,
5755 : 0 : &l2_tn_filter->key);
5756 : :
5757 [ # # ]: 0 : if (ret < 0) {
5758 : 0 : PMD_DRV_LOG(ERR,
5759 : : "Failed to insert L2 tunnel filter"
5760 : : " to hash table %d!",
5761 : : ret);
5762 : 0 : return ret;
5763 : : }
5764 : :
5765 : 0 : l2_tn_info->hash_map[ret] = l2_tn_filter;
5766 : :
5767 : 0 : TAILQ_INSERT_TAIL(&l2_tn_info->l2_tn_list, l2_tn_filter, entries);
5768 : :
5769 : 0 : return 0;
5770 : : }
5771 : :
5772 : : static inline int
5773 : 0 : txgbe_remove_l2_tn_filter(struct txgbe_l2_tn_info *l2_tn_info,
5774 : : struct txgbe_l2_tn_key *key)
5775 : : {
5776 : : int ret;
5777 : : struct txgbe_l2_tn_filter *l2_tn_filter;
5778 : :
5779 : 0 : ret = rte_hash_del_key(l2_tn_info->hash_handle, key);
5780 : :
5781 [ # # ]: 0 : if (ret < 0) {
5782 : 0 : PMD_DRV_LOG(ERR,
5783 : : "No such L2 tunnel filter to delete %d!",
5784 : : ret);
5785 : 0 : return ret;
5786 : : }
5787 : :
5788 : 0 : l2_tn_filter = l2_tn_info->hash_map[ret];
5789 : 0 : l2_tn_info->hash_map[ret] = NULL;
5790 : :
5791 [ # # ]: 0 : TAILQ_REMOVE(&l2_tn_info->l2_tn_list, l2_tn_filter, entries);
5792 : 0 : rte_free(l2_tn_filter);
5793 : :
5794 : 0 : return 0;
5795 : : }
5796 : :
5797 : : /* Add l2 tunnel filter */
5798 : : int
5799 : 0 : txgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev,
5800 : : struct txgbe_l2_tunnel_conf *l2_tunnel,
5801 : : bool restore)
5802 : : {
5803 : : int ret;
5804 : 0 : struct txgbe_l2_tn_info *l2_tn_info = TXGBE_DEV_L2_TN(dev);
5805 : : struct txgbe_l2_tn_key key;
5806 : : struct txgbe_l2_tn_filter *node;
5807 : :
5808 [ # # ]: 0 : if (!restore) {
5809 : 0 : key.l2_tn_type = l2_tunnel->l2_tunnel_type;
5810 : 0 : key.tn_id = l2_tunnel->tunnel_id;
5811 : :
5812 : : node = txgbe_l2_tn_filter_lookup(l2_tn_info, &key);
5813 : :
5814 [ # # ]: 0 : if (node) {
5815 : 0 : PMD_DRV_LOG(ERR,
5816 : : "The L2 tunnel filter already exists!");
5817 : 0 : return -EINVAL;
5818 : : }
5819 : :
5820 : 0 : node = rte_zmalloc("txgbe_l2_tn",
5821 : : sizeof(struct txgbe_l2_tn_filter),
5822 : : 0);
5823 [ # # ]: 0 : if (!node)
5824 : : return -ENOMEM;
5825 : :
5826 : : rte_memcpy(&node->key,
5827 : : &key,
5828 : : sizeof(struct txgbe_l2_tn_key));
5829 : 0 : node->pool = l2_tunnel->pool;
5830 : 0 : ret = txgbe_insert_l2_tn_filter(l2_tn_info, node);
5831 [ # # ]: 0 : if (ret < 0) {
5832 : 0 : rte_free(node);
5833 : 0 : return ret;
5834 : : }
5835 : : }
5836 : :
5837 [ # # ]: 0 : switch (l2_tunnel->l2_tunnel_type) {
5838 : 0 : case RTE_ETH_L2_TUNNEL_TYPE_E_TAG:
5839 : 0 : ret = txgbe_e_tag_filter_add(dev, l2_tunnel);
5840 : 0 : break;
5841 : 0 : default:
5842 : 0 : PMD_DRV_LOG(ERR, "Invalid tunnel type");
5843 : : ret = -EINVAL;
5844 : 0 : break;
5845 : : }
5846 : :
5847 [ # # ]: 0 : if (!restore && ret < 0)
5848 : 0 : (void)txgbe_remove_l2_tn_filter(l2_tn_info, &key);
5849 : :
5850 : : return ret;
5851 : : }
5852 : :
5853 : : /* Delete l2 tunnel filter */
5854 : : int
5855 : 0 : txgbe_dev_l2_tunnel_filter_del(struct rte_eth_dev *dev,
5856 : : struct txgbe_l2_tunnel_conf *l2_tunnel)
5857 : : {
5858 : : int ret;
5859 : 0 : struct txgbe_l2_tn_info *l2_tn_info = TXGBE_DEV_L2_TN(dev);
5860 : : struct txgbe_l2_tn_key key;
5861 : :
5862 : 0 : key.l2_tn_type = l2_tunnel->l2_tunnel_type;
5863 : 0 : key.tn_id = l2_tunnel->tunnel_id;
5864 : 0 : ret = txgbe_remove_l2_tn_filter(l2_tn_info, &key);
5865 [ # # ]: 0 : if (ret < 0)
5866 : : return ret;
5867 : :
5868 [ # # ]: 0 : switch (l2_tunnel->l2_tunnel_type) {
5869 : 0 : case RTE_ETH_L2_TUNNEL_TYPE_E_TAG:
5870 : 0 : ret = txgbe_e_tag_filter_del(dev, l2_tunnel);
5871 : 0 : break;
5872 : 0 : default:
5873 : 0 : PMD_DRV_LOG(ERR, "Invalid tunnel type");
5874 : : ret = -EINVAL;
5875 : 0 : break;
5876 : : }
5877 : :
5878 : : return ret;
5879 : : }
5880 : :
5881 : : static int
5882 : : txgbe_e_tag_forwarding_en_dis(struct rte_eth_dev *dev, bool en)
5883 : : {
5884 : : int ret = 0;
5885 : : uint32_t ctrl;
5886 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
5887 : :
5888 : : ctrl = rd32(hw, TXGBE_POOLCTL);
5889 : 0 : ctrl &= ~TXGBE_POOLCTL_MODE_MASK;
5890 : : if (en)
5891 : 0 : ctrl |= TXGBE_PSRPOOL_MODE_ETAG;
5892 : : wr32(hw, TXGBE_POOLCTL, ctrl);
5893 : :
5894 : 0 : return ret;
5895 : : }
5896 : :
5897 : : /* Add UDP tunneling port */
5898 : : static int
5899 : 0 : txgbe_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
5900 : : struct rte_eth_udp_tunnel *udp_tunnel)
5901 : : {
5902 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
5903 : : int ret = 0;
5904 : :
5905 [ # # ]: 0 : if (udp_tunnel == NULL)
5906 : : return -EINVAL;
5907 : :
5908 [ # # # # : 0 : switch (udp_tunnel->prot_type) {
# ]
5909 : 0 : case RTE_ETH_TUNNEL_TYPE_VXLAN:
5910 [ # # ]: 0 : if (udp_tunnel->udp_port == 0) {
5911 : 0 : PMD_DRV_LOG(ERR, "Add VxLAN port 0 is not allowed.");
5912 : : ret = -EINVAL;
5913 : 0 : break;
5914 : : }
5915 : 0 : wr32(hw, TXGBE_VXLANPORT, udp_tunnel->udp_port);
5916 : : break;
5917 : 0 : case RTE_ETH_TUNNEL_TYPE_GENEVE:
5918 [ # # ]: 0 : if (udp_tunnel->udp_port == 0) {
5919 : 0 : PMD_DRV_LOG(ERR, "Add Geneve port 0 is not allowed.");
5920 : : ret = -EINVAL;
5921 : 0 : break;
5922 : : }
5923 : 0 : wr32(hw, TXGBE_GENEVEPORT, udp_tunnel->udp_port);
5924 : : break;
5925 : 0 : case RTE_ETH_TUNNEL_TYPE_TEREDO:
5926 [ # # ]: 0 : if (udp_tunnel->udp_port == 0) {
5927 : 0 : PMD_DRV_LOG(ERR, "Add Teredo port 0 is not allowed.");
5928 : : ret = -EINVAL;
5929 : 0 : break;
5930 : : }
5931 : 0 : wr32(hw, TXGBE_TEREDOPORT, udp_tunnel->udp_port);
5932 : : break;
5933 : 0 : case RTE_ETH_TUNNEL_TYPE_VXLAN_GPE:
5934 [ # # ]: 0 : if (udp_tunnel->udp_port == 0) {
5935 : 0 : PMD_DRV_LOG(ERR, "Add VxLAN port 0 is not allowed.");
5936 : : ret = -EINVAL;
5937 : 0 : break;
5938 : : }
5939 : 0 : wr32(hw, TXGBE_VXLANPORTGPE, udp_tunnel->udp_port);
5940 : : break;
5941 : 0 : default:
5942 : 0 : PMD_DRV_LOG(ERR, "Invalid tunnel type");
5943 : : ret = -EINVAL;
5944 : 0 : break;
5945 : : }
5946 : :
5947 : : txgbe_flush(hw);
5948 : :
5949 : : return ret;
5950 : : }
5951 : :
5952 : : /* Remove UDP tunneling port */
5953 : : static int
5954 : 0 : txgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
5955 : : struct rte_eth_udp_tunnel *udp_tunnel)
5956 : : {
5957 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
5958 : : int ret = 0;
5959 : : uint16_t cur_port;
5960 : :
5961 [ # # ]: 0 : if (udp_tunnel == NULL)
5962 : : return -EINVAL;
5963 : :
5964 [ # # # # : 0 : switch (udp_tunnel->prot_type) {
# ]
5965 : : case RTE_ETH_TUNNEL_TYPE_VXLAN:
5966 : 0 : cur_port = (uint16_t)rd32(hw, TXGBE_VXLANPORT);
5967 [ # # ]: 0 : if (cur_port != udp_tunnel->udp_port) {
5968 : 0 : PMD_DRV_LOG(ERR, "Port %u does not exist.",
5969 : : udp_tunnel->udp_port);
5970 : : ret = -EINVAL;
5971 : 0 : break;
5972 : : }
5973 : : wr32(hw, TXGBE_VXLANPORT, 0);
5974 : : break;
5975 : : case RTE_ETH_TUNNEL_TYPE_GENEVE:
5976 : 0 : cur_port = (uint16_t)rd32(hw, TXGBE_GENEVEPORT);
5977 [ # # ]: 0 : if (cur_port != udp_tunnel->udp_port) {
5978 : 0 : PMD_DRV_LOG(ERR, "Port %u does not exist.",
5979 : : udp_tunnel->udp_port);
5980 : : ret = -EINVAL;
5981 : 0 : break;
5982 : : }
5983 : : wr32(hw, TXGBE_GENEVEPORT, 0);
5984 : : break;
5985 : : case RTE_ETH_TUNNEL_TYPE_TEREDO:
5986 : 0 : cur_port = (uint16_t)rd32(hw, TXGBE_TEREDOPORT);
5987 [ # # ]: 0 : if (cur_port != udp_tunnel->udp_port) {
5988 : 0 : PMD_DRV_LOG(ERR, "Port %u does not exist.",
5989 : : udp_tunnel->udp_port);
5990 : : ret = -EINVAL;
5991 : 0 : break;
5992 : : }
5993 : : wr32(hw, TXGBE_TEREDOPORT, 0);
5994 : : break;
5995 : : case RTE_ETH_TUNNEL_TYPE_VXLAN_GPE:
5996 : 0 : cur_port = (uint16_t)rd32(hw, TXGBE_VXLANPORTGPE);
5997 [ # # ]: 0 : if (cur_port != udp_tunnel->udp_port) {
5998 : 0 : PMD_DRV_LOG(ERR, "Port %u does not exist.",
5999 : : udp_tunnel->udp_port);
6000 : : ret = -EINVAL;
6001 : 0 : break;
6002 : : }
6003 : : wr32(hw, TXGBE_VXLANPORTGPE, 0);
6004 : : break;
6005 : 0 : default:
6006 : 0 : PMD_DRV_LOG(ERR, "Invalid tunnel type");
6007 : : ret = -EINVAL;
6008 : 0 : break;
6009 : : }
6010 : :
6011 : : txgbe_flush(hw);
6012 : :
6013 : : return ret;
6014 : : }
6015 : :
6016 : : /* restore n-tuple filter */
6017 : : static inline void
6018 : : txgbe_ntuple_filter_restore(struct rte_eth_dev *dev)
6019 : : {
6020 : 0 : struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(dev);
6021 : : struct txgbe_5tuple_filter *node;
6022 : :
6023 [ # # ]: 0 : TAILQ_FOREACH(node, &filter_info->fivetuple_list, entries) {
6024 : 0 : txgbe_inject_5tuple_filter(dev, node);
6025 : : }
6026 : : }
6027 : :
6028 : : /* restore ethernet type filter */
6029 : : static inline void
6030 : 0 : txgbe_ethertype_filter_restore(struct rte_eth_dev *dev)
6031 : : {
6032 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
6033 : : struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(dev);
6034 : : int i;
6035 : :
6036 [ # # ]: 0 : for (i = 0; i < TXGBE_ETF_ID_MAX; i++) {
6037 [ # # ]: 0 : if (filter_info->ethertype_mask & (1 << i)) {
6038 : 0 : wr32(hw, TXGBE_ETFLT(i),
6039 : : filter_info->ethertype_filters[i].etqf);
6040 : 0 : wr32(hw, TXGBE_ETCLS(i),
6041 : : filter_info->ethertype_filters[i].etqs);
6042 : : txgbe_flush(hw);
6043 : : }
6044 : : }
6045 : 0 : }
6046 : :
6047 : : /* restore SYN filter */
6048 : : static inline void
6049 : 0 : txgbe_syn_filter_restore(struct rte_eth_dev *dev)
6050 : : {
6051 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
6052 : : struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(dev);
6053 : : uint32_t synqf;
6054 : :
6055 : 0 : synqf = filter_info->syn_info;
6056 : :
6057 [ # # ]: 0 : if (synqf & TXGBE_SYNCLS_ENA) {
6058 : : wr32(hw, TXGBE_SYNCLS, synqf);
6059 : : txgbe_flush(hw);
6060 : : }
6061 : 0 : }
6062 : :
6063 : : /* restore L2 tunnel filter */
6064 : : static inline void
6065 : 0 : txgbe_l2_tn_filter_restore(struct rte_eth_dev *dev)
6066 : : {
6067 : 0 : struct txgbe_l2_tn_info *l2_tn_info = TXGBE_DEV_L2_TN(dev);
6068 : : struct txgbe_l2_tn_filter *node;
6069 : : struct txgbe_l2_tunnel_conf l2_tn_conf;
6070 : :
6071 [ # # ]: 0 : TAILQ_FOREACH(node, &l2_tn_info->l2_tn_list, entries) {
6072 : 0 : l2_tn_conf.l2_tunnel_type = node->key.l2_tn_type;
6073 : 0 : l2_tn_conf.tunnel_id = node->key.tn_id;
6074 : 0 : l2_tn_conf.pool = node->pool;
6075 : 0 : (void)txgbe_dev_l2_tunnel_filter_add(dev, &l2_tn_conf, TRUE);
6076 : : }
6077 : 0 : }
6078 : :
6079 : : /* restore rss filter */
6080 : : static inline void
6081 : : txgbe_rss_filter_restore(struct rte_eth_dev *dev)
6082 : : {
6083 : 0 : struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(dev);
6084 : :
6085 [ # # ]: 0 : if (filter_info->rss_info.conf.queue_num)
6086 : 0 : txgbe_config_rss_filter(dev,
6087 : : &filter_info->rss_info, TRUE);
6088 : : }
6089 : :
6090 : : static int
6091 : 0 : txgbe_filter_restore(struct rte_eth_dev *dev)
6092 : : {
6093 : : txgbe_ntuple_filter_restore(dev);
6094 : 0 : txgbe_ethertype_filter_restore(dev);
6095 : 0 : txgbe_syn_filter_restore(dev);
6096 : 0 : txgbe_fdir_filter_restore(dev);
6097 : 0 : txgbe_l2_tn_filter_restore(dev);
6098 : : txgbe_rss_filter_restore(dev);
6099 : :
6100 : 0 : return 0;
6101 : : }
6102 : :
6103 : : static void
6104 : 0 : txgbe_l2_tunnel_conf(struct rte_eth_dev *dev)
6105 : : {
6106 : 0 : struct txgbe_l2_tn_info *l2_tn_info = TXGBE_DEV_L2_TN(dev);
6107 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
6108 : :
6109 [ # # ]: 0 : if (l2_tn_info->e_tag_en)
6110 : 0 : (void)txgbe_e_tag_enable(hw);
6111 : :
6112 [ # # ]: 0 : if (l2_tn_info->e_tag_fwd_en)
6113 : : (void)txgbe_e_tag_forwarding_en_dis(dev, 1);
6114 : :
6115 : 0 : (void)txgbe_update_e_tag_eth_type(hw, l2_tn_info->e_tag_ether_type);
6116 : 0 : }
6117 : :
6118 : : /* remove all the n-tuple filters */
6119 : : void
6120 : 0 : txgbe_clear_all_ntuple_filter(struct rte_eth_dev *dev)
6121 : : {
6122 : 0 : struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(dev);
6123 : : struct txgbe_5tuple_filter *p_5tuple;
6124 : :
6125 [ # # ]: 0 : while ((p_5tuple = TAILQ_FIRST(&filter_info->fivetuple_list)))
6126 : 0 : txgbe_remove_5tuple_filter(dev, p_5tuple);
6127 : 0 : }
6128 : :
6129 : : /* remove all the ether type filters */
6130 : : void
6131 : 0 : txgbe_clear_all_ethertype_filter(struct rte_eth_dev *dev)
6132 : : {
6133 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
6134 : : struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(dev);
6135 : : int i;
6136 : :
6137 [ # # ]: 0 : for (i = 0; i < TXGBE_ETF_ID_MAX; i++) {
6138 [ # # ]: 0 : if (filter_info->ethertype_mask & (1 << i) &&
6139 [ # # ]: 0 : !filter_info->ethertype_filters[i].conf) {
6140 : : (void)txgbe_ethertype_filter_remove(filter_info,
6141 : : (uint8_t)i);
6142 : 0 : wr32(hw, TXGBE_ETFLT(i), 0);
6143 : 0 : wr32(hw, TXGBE_ETCLS(i), 0);
6144 : : txgbe_flush(hw);
6145 : : }
6146 : : }
6147 : 0 : }
6148 : :
6149 : : /* remove the SYN filter */
6150 : : void
6151 : 0 : txgbe_clear_syn_filter(struct rte_eth_dev *dev)
6152 : : {
6153 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
6154 : : struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(dev);
6155 : :
6156 [ # # ]: 0 : if (filter_info->syn_info & TXGBE_SYNCLS_ENA) {
6157 : 0 : filter_info->syn_info = 0;
6158 : :
6159 : : wr32(hw, TXGBE_SYNCLS, 0);
6160 : : txgbe_flush(hw);
6161 : : }
6162 : 0 : }
6163 : :
6164 : : /* remove all the L2 tunnel filters */
6165 : : int
6166 : 0 : txgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev)
6167 : : {
6168 : 0 : struct txgbe_l2_tn_info *l2_tn_info = TXGBE_DEV_L2_TN(dev);
6169 : : struct txgbe_l2_tn_filter *l2_tn_filter;
6170 : : struct txgbe_l2_tunnel_conf l2_tn_conf;
6171 : : int ret = 0;
6172 : :
6173 [ # # ]: 0 : while ((l2_tn_filter = TAILQ_FIRST(&l2_tn_info->l2_tn_list))) {
6174 : 0 : l2_tn_conf.l2_tunnel_type = l2_tn_filter->key.l2_tn_type;
6175 : 0 : l2_tn_conf.tunnel_id = l2_tn_filter->key.tn_id;
6176 : 0 : l2_tn_conf.pool = l2_tn_filter->pool;
6177 : 0 : ret = txgbe_dev_l2_tunnel_filter_del(dev, &l2_tn_conf);
6178 [ # # ]: 0 : if (ret < 0)
6179 : 0 : return ret;
6180 : : }
6181 : :
6182 : : return 0;
6183 : : }
6184 : :
6185 : : static int txgbe_fec_get_capa_speed_to_fec(struct rte_eth_fec_capa *speed_fec_capa)
6186 : : {
6187 : : int num = 2;
6188 : :
6189 : : if (speed_fec_capa) {
6190 : 0 : speed_fec_capa[0].speed = RTE_ETH_SPEED_NUM_10G;
6191 : 0 : speed_fec_capa[0].capa = RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC);
6192 : 0 : speed_fec_capa[1].speed = RTE_ETH_SPEED_NUM_25G;
6193 : 0 : speed_fec_capa[1].capa = RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC) |
6194 : : RTE_ETH_FEC_MODE_CAPA_MASK(AUTO) |
6195 : : RTE_ETH_FEC_MODE_CAPA_MASK(BASER) |
6196 : : RTE_ETH_FEC_MODE_CAPA_MASK(RS);
6197 : : }
6198 : :
6199 : : return num;
6200 : : }
6201 : :
6202 : 0 : static int txgbe_fec_get_capability(struct rte_eth_dev *dev,
6203 : : struct rte_eth_fec_capa *speed_fec_capa,
6204 : : unsigned int num)
6205 : : {
6206 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
6207 : : u8 num_entries;
6208 : :
6209 [ # # ]: 0 : if (hw->mac.type != txgbe_mac_aml)
6210 : : return -EOPNOTSUPP;
6211 : :
6212 : : num_entries = txgbe_fec_get_capa_speed_to_fec(NULL);
6213 [ # # # # ]: 0 : if (!speed_fec_capa || num < num_entries)
6214 : : return num_entries;
6215 : :
6216 : 0 : return txgbe_fec_get_capa_speed_to_fec(speed_fec_capa);
6217 : : }
6218 : :
6219 : 0 : static int txgbe_fec_get(struct rte_eth_dev *dev, uint32_t *fec_capa)
6220 : : {
6221 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
6222 : 0 : u32 speed = 0;
6223 : 0 : bool negotiate = false;
6224 : : u32 curr_fec_mode;
6225 : :
6226 : 0 : hw->mac.get_link_capabilities(hw, &speed, &negotiate);
6227 : :
6228 [ # # ]: 0 : if (hw->mac.type != txgbe_mac_aml ||
6229 [ # # ]: 0 : !(speed & TXGBE_LINK_SPEED_25GB_FULL))
6230 : : return -EOPNOTSUPP;
6231 : :
6232 [ # # ]: 0 : if (hw->fec_mode == TXGBE_PHY_FEC_AUTO)
6233 : : curr_fec_mode = RTE_ETH_FEC_MODE_CAPA_MASK(AUTO);
6234 [ # # ]: 0 : else if (hw->fec_mode == TXGBE_PHY_FEC_RS)
6235 : : curr_fec_mode = RTE_ETH_FEC_MODE_CAPA_MASK(RS);
6236 [ # # ]: 0 : else if (hw->fec_mode == TXGBE_PHY_FEC_BASER)
6237 : : curr_fec_mode = RTE_ETH_FEC_MODE_CAPA_MASK(BASER);
6238 : : else
6239 : : curr_fec_mode = RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC);
6240 : :
6241 : 0 : *fec_capa = curr_fec_mode;
6242 : 0 : return 0;
6243 : : }
6244 : :
6245 : 0 : static int txgbe_fec_set(struct rte_eth_dev *dev, u32 fec_capa)
6246 : : {
6247 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
6248 : 0 : u32 orig_fec_mode = hw->fec_mode;
6249 : 0 : bool negotiate = false;
6250 : 0 : u32 speed = 0;
6251 : :
6252 : 0 : hw->mac.get_link_capabilities(hw, &speed, &negotiate);
6253 : :
6254 [ # # ]: 0 : if (hw->mac.type != txgbe_mac_aml ||
6255 [ # # ]: 0 : !(speed & TXGBE_LINK_SPEED_25GB_FULL))
6256 : : return -EOPNOTSUPP;
6257 : :
6258 [ # # ]: 0 : if (!fec_capa)
6259 : : return -EINVAL;
6260 : :
6261 [ # # ]: 0 : if (fec_capa & RTE_ETH_FEC_MODE_CAPA_MASK(AUTO))
6262 : 0 : hw->fec_mode = TXGBE_PHY_FEC_AUTO;
6263 : :
6264 [ # # ]: 0 : if (fec_capa & RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC))
6265 : 0 : hw->fec_mode = TXGBE_PHY_FEC_OFF;
6266 : :
6267 [ # # ]: 0 : if (fec_capa & RTE_ETH_FEC_MODE_CAPA_MASK(BASER))
6268 : 0 : hw->fec_mode = TXGBE_PHY_FEC_BASER;
6269 : :
6270 [ # # ]: 0 : if (fec_capa & RTE_ETH_FEC_MODE_CAPA_MASK(RS))
6271 : 0 : hw->fec_mode = TXGBE_PHY_FEC_RS;
6272 : :
6273 [ # # ]: 0 : if (hw->fec_mode != orig_fec_mode) {
6274 : 0 : txgbe_dev_setup_link_alarm_handler(dev);
6275 : : txgbe_dev_link_update(dev, 0);
6276 : : }
6277 : :
6278 : : return 0;
6279 : : }
6280 : :
6281 : : static const struct eth_dev_ops txgbe_eth_dev_ops = {
6282 : : .dev_configure = txgbe_dev_configure,
6283 : : .dev_infos_get = txgbe_dev_info_get,
6284 : : .dev_start = txgbe_dev_start,
6285 : : .dev_stop = txgbe_dev_stop,
6286 : : .dev_set_link_up = txgbe_dev_set_link_up,
6287 : : .dev_set_link_down = txgbe_dev_set_link_down,
6288 : : .dev_close = txgbe_dev_close,
6289 : : .dev_reset = txgbe_dev_reset,
6290 : : .promiscuous_enable = txgbe_dev_promiscuous_enable,
6291 : : .promiscuous_disable = txgbe_dev_promiscuous_disable,
6292 : : .allmulticast_enable = txgbe_dev_allmulticast_enable,
6293 : : .allmulticast_disable = txgbe_dev_allmulticast_disable,
6294 : : .link_update = txgbe_dev_link_update,
6295 : : .stats_get = txgbe_dev_stats_get,
6296 : : .xstats_get = txgbe_dev_xstats_get,
6297 : : .xstats_get_by_id = txgbe_dev_xstats_get_by_id,
6298 : : .stats_reset = txgbe_dev_stats_reset,
6299 : : .xstats_reset = txgbe_dev_xstats_reset,
6300 : : .xstats_get_names = txgbe_dev_xstats_get_names,
6301 : : .xstats_get_names_by_id = txgbe_dev_xstats_get_names_by_id,
6302 : : .fw_version_get = txgbe_fw_version_get,
6303 : : .dev_supported_ptypes_get = txgbe_dev_supported_ptypes_get,
6304 : : .mtu_set = txgbe_dev_mtu_set,
6305 : : .vlan_filter_set = txgbe_vlan_filter_set,
6306 : : .vlan_tpid_set = txgbe_vlan_tpid_set,
6307 : : .vlan_offload_set = txgbe_vlan_offload_set,
6308 : : .vlan_strip_queue_set = txgbe_vlan_strip_queue_set,
6309 : : .rx_queue_start = txgbe_dev_rx_queue_start,
6310 : : .rx_queue_stop = txgbe_dev_rx_queue_stop,
6311 : : .tx_queue_start = txgbe_dev_tx_queue_start,
6312 : : .tx_queue_stop = txgbe_dev_tx_queue_stop,
6313 : : .rx_queue_setup = txgbe_dev_rx_queue_setup,
6314 : : .rx_queue_intr_enable = txgbe_dev_rx_queue_intr_enable,
6315 : : .rx_queue_intr_disable = txgbe_dev_rx_queue_intr_disable,
6316 : : .rx_queue_release = txgbe_dev_rx_queue_release,
6317 : : .tx_queue_setup = txgbe_dev_tx_queue_setup,
6318 : : .tx_queue_release = txgbe_dev_tx_queue_release,
6319 : : .dev_led_on = txgbe_dev_led_on,
6320 : : .dev_led_off = txgbe_dev_led_off,
6321 : : .flow_ctrl_get = txgbe_flow_ctrl_get,
6322 : : .flow_ctrl_set = txgbe_flow_ctrl_set,
6323 : : .priority_flow_ctrl_set = txgbe_priority_flow_ctrl_set,
6324 : : .mac_addr_add = txgbe_add_rar,
6325 : : .mac_addr_remove = txgbe_remove_rar,
6326 : : .mac_addr_set = txgbe_set_default_mac_addr,
6327 : : .uc_hash_table_set = txgbe_uc_hash_table_set,
6328 : : .uc_all_hash_table_set = txgbe_uc_all_hash_table_set,
6329 : : .set_queue_rate_limit = txgbe_set_queue_rate_limit,
6330 : : .reta_update = txgbe_dev_rss_reta_update,
6331 : : .reta_query = txgbe_dev_rss_reta_query,
6332 : : .rss_hash_update = txgbe_dev_rss_hash_update,
6333 : : .rss_hash_conf_get = txgbe_dev_rss_hash_conf_get,
6334 : : .flow_ops_get = txgbe_dev_flow_ops_get,
6335 : : .set_mc_addr_list = txgbe_dev_set_mc_addr_list,
6336 : : .rxq_info_get = txgbe_rxq_info_get,
6337 : : .txq_info_get = txgbe_txq_info_get,
6338 : : .timesync_enable = txgbe_timesync_enable,
6339 : : .timesync_disable = txgbe_timesync_disable,
6340 : : .timesync_read_rx_timestamp = txgbe_timesync_read_rx_timestamp,
6341 : : .timesync_read_tx_timestamp = txgbe_timesync_read_tx_timestamp,
6342 : : .get_reg = txgbe_get_regs,
6343 : : .get_eeprom_length = txgbe_get_eeprom_length,
6344 : : .get_eeprom = txgbe_get_eeprom,
6345 : : .set_eeprom = txgbe_set_eeprom,
6346 : : .get_module_info = txgbe_get_module_info,
6347 : : .get_module_eeprom = txgbe_get_module_eeprom,
6348 : : .get_dcb_info = txgbe_dev_get_dcb_info,
6349 : : .timesync_adjust_time = txgbe_timesync_adjust_time,
6350 : : .timesync_read_time = txgbe_timesync_read_time,
6351 : : .timesync_write_time = txgbe_timesync_write_time,
6352 : : .udp_tunnel_port_add = txgbe_dev_udp_tunnel_port_add,
6353 : : .udp_tunnel_port_del = txgbe_dev_udp_tunnel_port_del,
6354 : : .tm_ops_get = txgbe_tm_ops_get,
6355 : : .tx_done_cleanup = txgbe_dev_tx_done_cleanup,
6356 : : .fec_get_capability = txgbe_fec_get_capability,
6357 : : .fec_get = txgbe_fec_get,
6358 : : .fec_set = txgbe_fec_set,
6359 : : };
6360 : :
6361 : 302 : RTE_PMD_REGISTER_PCI(net_txgbe, rte_txgbe_pmd);
6362 : : RTE_PMD_REGISTER_PCI_TABLE(net_txgbe, pci_id_txgbe_map);
6363 : : RTE_PMD_REGISTER_KMOD_DEP(net_txgbe, "* igb_uio | uio_pci_generic | vfio-pci");
6364 : : RTE_PMD_REGISTER_PARAM_STRING(net_txgbe,
6365 : : TXGBE_DEVARG_BP_AUTO "=<0|1>"
6366 : : TXGBE_DEVARG_KR_POLL "=<0|1>"
6367 : : TXGBE_DEVARG_KR_PRESENT "=<0|1>"
6368 : : TXGBE_DEVARG_KX_SGMII "=<0|1>"
6369 : : TXGBE_DEVARG_FFE_SET "=<0-4>"
6370 : : TXGBE_DEVARG_FFE_MAIN "=<uint16>"
6371 : : TXGBE_DEVARG_FFE_PRE "=<uint16>"
6372 : : TXGBE_DEVARG_FFE_POST "=<uint16>"
6373 : : TXGBE_DEVARG_FDIR_PBALLOC "=<0|1|2>"
6374 : : TXGBE_DEVARG_FDIR_DROP_QUEUE "=<uint8>"
6375 : : TXGBE_DEVARG_TX_HEAD_WB "=<0|1>"
6376 : : TXGBE_DEVARG_TX_HEAD_WB_SIZE "=<1|16>"
6377 : : TXGBE_DEVARG_RX_DESC_MERGE "=<0|1>");
6378 : :
6379 [ - + ]: 302 : RTE_LOG_REGISTER_SUFFIX(txgbe_logtype_init, init, NOTICE);
6380 [ - + ]: 302 : RTE_LOG_REGISTER_SUFFIX(txgbe_logtype_driver, driver, NOTICE);
6381 [ - + ]: 302 : RTE_LOG_REGISTER_SUFFIX(txgbe_logtype_bp, bp, NOTICE);
6382 : :
6383 : : #ifdef RTE_LIBRTE_TXGBE_DEBUG_RX
6384 : : RTE_LOG_REGISTER_SUFFIX(txgbe_logtype_rx, rx, DEBUG);
6385 : : #endif
6386 : : #ifdef RTE_LIBRTE_TXGBE_DEBUG_TX
6387 : : RTE_LOG_REGISTER_SUFFIX(txgbe_logtype_tx, tx, DEBUG);
6388 : : #endif
6389 : :
6390 : : #ifdef RTE_LIBRTE_TXGBE_DEBUG_TX_FREE
6391 : : RTE_LOG_REGISTER_SUFFIX(txgbe_logtype_tx_free, tx_free, DEBUG);
6392 : : #endif
|