Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2014-2023 Broadcom
3 : : * All rights reserved.
4 : : */
5 : :
6 : : #include <unistd.h>
7 : :
8 : : #include <rte_byteorder.h>
9 : : #include <rte_common.h>
10 : : #include <rte_cycles.h>
11 : : #include <rte_malloc.h>
12 : : #include <rte_memzone.h>
13 : : #include <rte_version.h>
14 : : #include <rte_io.h>
15 : :
16 : : #include "bnxt.h"
17 : : #include "bnxt_filter.h"
18 : : #include "bnxt_hwrm.h"
19 : : #include "bnxt_rxq.h"
20 : : #include "bnxt_rxr.h"
21 : : #include "bnxt_ring.h"
22 : : #include "bnxt_txq.h"
23 : : #include "bnxt_txr.h"
24 : : #include "bnxt_vnic.h"
25 : : #include "hsi_struct_def_dpdk.h"
26 : :
27 : : struct bnxt_plcmodes_cfg {
28 : : uint32_t flags;
29 : : uint16_t jumbo_thresh;
30 : : uint16_t hds_offset;
31 : : uint16_t hds_threshold;
32 : : };
33 : :
34 : : const char *bnxt_backing_store_types[] = {
35 : : "Queue pair",
36 : : "Shared receive queue",
37 : : "Completion queue",
38 : : "Virtual NIC",
39 : : "Statistic context",
40 : : "Slow-path TQM ring",
41 : : "Fast-path TQM ring",
42 : : "Unused",
43 : : "Unused",
44 : : "Unused",
45 : : "Unused",
46 : : "Unused",
47 : : "Unused",
48 : : "Unused",
49 : : "MR and MAV Context",
50 : : "TIM",
51 : : "Unused",
52 : : "Unused",
53 : : "Unused",
54 : : "Tx key context",
55 : : "Rx key context",
56 : : "Mid-path TQM ring",
57 : : "SQ Doorbell shadow region",
58 : : "RQ Doorbell shadow region",
59 : : "SRQ Doorbell shadow region",
60 : : "CQ Doorbell shadow region",
61 : : "QUIC Tx key context",
62 : : "QUIC Rx key context",
63 : : "Invalid type",
64 : : "Invalid type",
65 : : "Invalid type",
66 : : "Invalid type",
67 : : "Invalid type",
68 : : "Invalid type"
69 : : };
70 : :
71 : : const char *media_type[] = { "Unknown", "Twisted Pair",
72 : : "Direct Attached Copper", "Fiber"
73 : : };
74 : :
75 : : #define MAX_MEDIA_TYPE (sizeof(media_type) / sizeof(const char *))
76 : :
77 : : const char *link_status_str[] = { "Down. No link or cable detected.",
78 : : "Down. No link, but a cable has been detected.", "Up.",
79 : : };
80 : :
81 : : #define MAX_LINK_STR (sizeof(link_status_str) / sizeof(const char *))
82 : :
83 : : const char *fec_mode[] = {
84 : : "No active FEC",
85 : : "FEC CLAUSE 74 (Fire Code).",
86 : : "FEC CLAUSE 91 RS(528,514).",
87 : : "FEC RS544_1XN",
88 : : "FEC RS(544,528)",
89 : : "FEC RS272_1XN",
90 : : "FEC RS(272,257)"
91 : : };
92 : :
93 : : #define MAX_FEC_MODE (sizeof(fec_mode) / sizeof(const char *))
94 : :
95 : : const char *signal_mode[] = {
96 : : "NRZ", "PAM4", "PAM4_112"
97 : : };
98 : :
99 : : #define MAX_SIG_MODE (sizeof(signal_mode) / sizeof(const char *))
100 : :
101 : : /* multi-purpose multi-key table container.
102 : : * Add a unique entry for a new PHY attribs as per HW CAS.
103 : : * Query it using a helper functions.
104 : : */
105 : : struct link_speeds2_tbl {
106 : : uint16_t force_val;
107 : : uint16_t auto_val;
108 : : uint32_t rte_speed;
109 : : uint32_t rte_speed_num;
110 : : uint16_t hwrm_speed;
111 : : uint16_t sig_mode;
112 : : const char *desc;
113 : : } link_speeds2_tbl[] = {
114 : : {
115 : : 10,
116 : : 0,
117 : : RTE_ETH_LINK_SPEED_1G,
118 : : RTE_ETH_SPEED_NUM_1G,
119 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_1GB,
120 : : BNXT_SIG_MODE_NRZ,
121 : : "1Gb NRZ",
122 : : }, {
123 : : 100,
124 : : 1,
125 : : RTE_ETH_LINK_SPEED_10G,
126 : : RTE_ETH_SPEED_NUM_10G,
127 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_10GB,
128 : : BNXT_SIG_MODE_NRZ,
129 : : "10Gb NRZ",
130 : : }, {
131 : : 250,
132 : : 2,
133 : : RTE_ETH_LINK_SPEED_25G,
134 : : RTE_ETH_SPEED_NUM_25G,
135 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_25GB,
136 : : BNXT_SIG_MODE_NRZ,
137 : : "25Gb NRZ",
138 : : }, {
139 : : 400,
140 : : 3,
141 : : RTE_ETH_LINK_SPEED_40G,
142 : : RTE_ETH_SPEED_NUM_40G,
143 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_40GB,
144 : : BNXT_SIG_MODE_NRZ,
145 : : "40Gb NRZ",
146 : : }, {
147 : : 500,
148 : : 4,
149 : : RTE_ETH_LINK_SPEED_50G,
150 : : RTE_ETH_SPEED_NUM_50G,
151 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_50GB,
152 : : BNXT_SIG_MODE_NRZ,
153 : : "50Gb NRZ",
154 : : }, {
155 : : 1000,
156 : : 5,
157 : : RTE_ETH_LINK_SPEED_100G,
158 : : RTE_ETH_SPEED_NUM_100G,
159 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_100GB,
160 : : BNXT_SIG_MODE_NRZ,
161 : : "100Gb NRZ",
162 : : }, {
163 : : 501,
164 : : 6,
165 : : RTE_ETH_LINK_SPEED_50G,
166 : : RTE_ETH_SPEED_NUM_50G,
167 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_50GB_PAM4_56,
168 : : BNXT_SIG_MODE_PAM4,
169 : : "50Gb (PAM4-56: 50G per lane)",
170 : : }, {
171 : : 1001,
172 : : 7,
173 : : RTE_ETH_LINK_SPEED_100G,
174 : : RTE_ETH_SPEED_NUM_100G,
175 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_100GB_PAM4_56,
176 : : BNXT_SIG_MODE_PAM4,
177 : : "100Gb (PAM4-56: 50G per lane)",
178 : : }, {
179 : : 2001,
180 : : 8,
181 : : RTE_ETH_LINK_SPEED_200G,
182 : : RTE_ETH_SPEED_NUM_200G,
183 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_200GB_PAM4_56,
184 : : BNXT_SIG_MODE_PAM4,
185 : : "200Gb (PAM4-56: 50G per lane)",
186 : : }, {
187 : : 4001,
188 : : 9,
189 : : RTE_ETH_LINK_SPEED_400G,
190 : : RTE_ETH_SPEED_NUM_400G,
191 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_400GB_PAM4_56,
192 : : BNXT_SIG_MODE_PAM4,
193 : : "400Gb (PAM4-56: 50G per lane)",
194 : : }, {
195 : : 1002,
196 : : 10,
197 : : RTE_ETH_LINK_SPEED_100G,
198 : : RTE_ETH_SPEED_NUM_100G,
199 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_100GB_PAM4_112,
200 : : BNXT_SIG_MODE_PAM4_112,
201 : : "100Gb (PAM4-112: 100G per lane)",
202 : : }, {
203 : : 2002,
204 : : 11,
205 : : RTE_ETH_LINK_SPEED_200G,
206 : : RTE_ETH_SPEED_NUM_200G,
207 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_200GB_PAM4_112,
208 : : BNXT_SIG_MODE_PAM4_112,
209 : : "200Gb (PAM4-112: 100G per lane)",
210 : : }, {
211 : : 4002,
212 : : 12,
213 : : RTE_ETH_LINK_SPEED_400G,
214 : : RTE_ETH_SPEED_NUM_400G,
215 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_400GB_PAM4_112,
216 : : BNXT_SIG_MODE_PAM4_112,
217 : : "400Gb (PAM4-112: 100G per lane)",
218 : : }, {
219 : : 0,
220 : : 13,
221 : : RTE_ETH_LINK_SPEED_AUTONEG, /* None matches, AN is default 0 */
222 : : RTE_ETH_SPEED_NUM_NONE, /* None matches, No speed */
223 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_1GB, /* Placeholder for wrong HWRM */
224 : : BNXT_SIG_MODE_NRZ, /* default sig */
225 : : "Unknown",
226 : : },
227 : : };
228 : :
229 : : #define BNXT_SPEEDS2_TBL_SZ (sizeof(link_speeds2_tbl) / sizeof(*link_speeds2_tbl))
230 : :
231 : : /* In hwrm_phy_qcfg reports trained up speeds in link_speed(offset:0x8[31:16]) */
232 : : struct link_speeds_tbl {
233 : : uint16_t hwrm_speed;
234 : : uint32_t rte_speed_num;
235 : : const char *desc;
236 : : } link_speeds_tbl[] = {
237 : : {
238 : : HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100MB,
239 : : RTE_ETH_SPEED_NUM_100M, "100 MB",
240 : : }, {
241 : : HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_1GB,
242 : : RTE_ETH_SPEED_NUM_1G, "1 GB",
243 : : }, {
244 : : HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2_5GB,
245 : : RTE_ETH_SPEED_NUM_2_5G, "25 GB",
246 : : }, {
247 : : HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_10GB,
248 : : RTE_ETH_SPEED_NUM_10G, "10 GB",
249 : : }, {
250 : : HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_20GB,
251 : : RTE_ETH_SPEED_NUM_20G, "20 GB",
252 : : }, {
253 : : HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_40GB,
254 : : RTE_ETH_SPEED_NUM_40G, "40 GB",
255 : : }, {
256 : : HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_50GB,
257 : : RTE_ETH_SPEED_NUM_50G, "50 GB",
258 : : }, {
259 : : HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100GB,
260 : : RTE_ETH_SPEED_NUM_100G, "100 GB",
261 : : }, {
262 : : HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_200GB,
263 : : RTE_ETH_SPEED_NUM_200G, "200 GB",
264 : : }, {
265 : : HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_400GB,
266 : : RTE_ETH_SPEED_NUM_400G, "400 GB",
267 : : }, {
268 : : 0, RTE_ETH_SPEED_NUM_NONE, "None",
269 : : },
270 : : };
271 : :
272 : : #define BNXT_SPEEDS_TBL_SZ (sizeof(link_speeds_tbl) / sizeof(*link_speeds_tbl))
273 : :
274 : : static const char *bnxt_get_xcvr_type(uint32_t xcvr_identifier_type_tx_lpi_timer)
275 : : {
276 : 0 : uint32_t xcvr_type = HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_MASK &
277 : : xcvr_identifier_type_tx_lpi_timer;
278 : :
279 : : /* Addressing only known CMIS types */
280 : 0 : switch (xcvr_type) {
281 : : case HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_SFP:
282 : : return "SFP";
283 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_QSFP:
284 : 0 : return "QSFP";
285 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_QSFPPLUS:
286 : 0 : return "QSFP+";
287 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_QSFP28:
288 : 0 : return "QSFP28";
289 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_QSFPDD:
290 : 0 : return "QSFP112";
291 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_QSFP112:
292 : 0 : return "QSFP-DD";
293 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_UNKNOWN:
294 : 0 : return "Unknown";
295 : 0 : default:
296 : : /* All other/new CMIS variants belong here */
297 : 0 : return "QSFP-xx new CMIS variant";
298 : : }
299 : : }
300 : :
301 : : /* Utility function to lookup speeds2 table and
302 : : * return a rte to hwrm speed matching row to the client
303 : : */
304 : : static
305 : : struct link_speeds2_tbl *bnxt_get_rte_hwrm_speeds2_entry(uint32_t speed)
306 : : {
307 : : int i, max;
308 : :
309 : : max = BNXT_SPEEDS2_TBL_SZ - 1;
310 : 0 : speed &= ~RTE_ETH_LINK_SPEED_FIXED;
311 [ # # ]: 0 : for (i = 0; i < max; i++) {
312 [ # # ]: 0 : if (speed == link_speeds2_tbl[i].rte_speed)
313 : : break;
314 : : }
315 : : return (struct link_speeds2_tbl *)&link_speeds2_tbl[i];
316 : : }
317 : :
318 : : /* Utility function to lookup speeds2 table and
319 : : * return a hwrm to rte speed matching row to the client
320 : : */
321 : : static struct link_speeds2_tbl *bnxt_get_hwrm_to_rte_speeds2_entry(uint16_t speed)
322 : : {
323 : : int i, max;
324 : :
325 : : max = BNXT_SPEEDS2_TBL_SZ - 1;
326 [ # # # # ]: 0 : for (i = 0; i < max; i++) {
327 [ # # # # ]: 0 : if (speed == link_speeds2_tbl[i].hwrm_speed)
328 : : break;
329 : : }
330 : : return (struct link_speeds2_tbl *)&link_speeds2_tbl[i];
331 : : }
332 : :
333 : : /* Helper function to lookup auto link_speed table */
334 : : static struct link_speeds_tbl *bnxt_get_hwrm_to_rte_speeds_entry(uint16_t speed)
335 : : {
336 : : int i, max;
337 : :
338 : : max = BNXT_SPEEDS_TBL_SZ - 1;
339 : :
340 [ # # ]: 0 : for (i = 0; i < max ; i++) {
341 [ # # ]: 0 : if (speed == link_speeds_tbl[i].hwrm_speed)
342 : : break;
343 : : }
344 : : return (struct link_speeds_tbl *)&link_speeds_tbl[i];
345 : : }
346 : :
347 : 0 : static int page_getenum(size_t size)
348 : : {
349 [ # # ]: 0 : if (size <= 1 << 4)
350 : : return 4;
351 [ # # ]: 0 : if (size <= 1 << 12)
352 : : return 12;
353 [ # # ]: 0 : if (size <= 1 << 13)
354 : : return 13;
355 [ # # ]: 0 : if (size <= 1 << 16)
356 : : return 16;
357 [ # # ]: 0 : if (size <= 1 << 21)
358 : : return 21;
359 [ # # ]: 0 : if (size <= 1 << 22)
360 : : return 22;
361 [ # # ]: 0 : if (size <= 1 << 30)
362 : : return 30;
363 : 0 : PMD_DRV_LOG(ERR, "Page size %zu out of range\n", size);
364 : 0 : return sizeof(int) * 8 - 1;
365 : : }
366 : :
367 : : static int page_roundup(size_t size)
368 : : {
369 : 0 : return 1 << page_getenum(size);
370 : : }
371 : :
372 : : static void bnxt_hwrm_set_pg_attr(struct bnxt_ring_mem_info *rmem,
373 : : uint8_t *pg_attr,
374 : : uint64_t *pg_dir)
375 : : {
376 : 0 : if (rmem->nr_pages == 0)
377 : : return;
378 : :
379 [ # # # # : 0 : if (rmem->nr_pages > 1) {
# # # # #
# # # # #
# # ]
380 : 0 : *pg_attr = 1;
381 : 0 : *pg_dir = rte_cpu_to_le_64(rmem->pg_tbl_map);
382 : : } else {
383 : 0 : *pg_dir = rte_cpu_to_le_64(rmem->dma_arr[0]);
384 : : }
385 : : }
386 : :
387 : : static struct bnxt_cp_ring_info*
388 : 0 : bnxt_get_ring_info_by_id(struct bnxt *bp, uint16_t rid, uint16_t type)
389 : : {
390 : : struct bnxt_cp_ring_info *cp_ring = NULL;
391 : : uint16_t i;
392 : :
393 [ # # # ]: 0 : switch (type) {
394 : : case HWRM_RING_FREE_INPUT_RING_TYPE_RX:
395 : : case HWRM_RING_FREE_INPUT_RING_TYPE_RX_AGG:
396 : : /* FALLTHROUGH */
397 [ # # ]: 0 : for (i = 0; i < bp->rx_cp_nr_rings; i++) {
398 : 0 : struct bnxt_rx_queue *rxq = bp->rx_queues[i];
399 : :
400 [ # # ]: 0 : if (rxq->cp_ring->cp_ring_struct->fw_ring_id ==
401 : : rte_cpu_to_le_16(rid)) {
402 : 0 : return rxq->cp_ring;
403 : : }
404 : : }
405 : : break;
406 : : case HWRM_RING_FREE_INPUT_RING_TYPE_TX:
407 [ # # ]: 0 : for (i = 0; i < bp->tx_cp_nr_rings; i++) {
408 : 0 : struct bnxt_tx_queue *txq = bp->tx_queues[i];
409 : :
410 [ # # ]: 0 : if (txq->cp_ring->cp_ring_struct->fw_ring_id ==
411 : : rte_cpu_to_le_16(rid)) {
412 : 0 : return txq->cp_ring;
413 : : }
414 : : }
415 : : break;
416 : : default:
417 : : return cp_ring;
418 : : }
419 : : return cp_ring;
420 : : }
421 : :
422 : : /* Complete a sweep of the CQ ring for the corresponding Tx/Rx/AGG ring.
423 : : * If the CMPL_BASE_TYPE_HWRM_DONE is not encountered by the last pass,
424 : : * before timeout, we force the done bit for the cleanup to proceed.
425 : : * Also if cpr is null, do nothing.. The HWRM command is not for a
426 : : * Tx/Rx/AGG ring cleanup.
427 : : */
428 : : static int
429 : 0 : bnxt_check_cq_hwrm_done(struct bnxt_cp_ring_info *cpr,
430 : : bool tx, bool rx, bool timeout)
431 : : {
432 : : int done = 0;
433 : :
434 [ # # ]: 0 : if (cpr != NULL) {
435 [ # # ]: 0 : if (tx)
436 : 0 : done = bnxt_flush_tx_cmp(cpr);
437 : :
438 [ # # ]: 0 : if (rx)
439 : 0 : done = bnxt_flush_rx_cmp(cpr);
440 : :
441 [ # # ]: 0 : if (done)
442 [ # # ]: 0 : PMD_DRV_LOG(DEBUG, "HWRM DONE for %s ring\n",
443 : : rx ? "Rx" : "Tx");
444 : :
445 : : /* We are about to timeout and still haven't seen the
446 : : * HWRM done for the Ring free. Force the cleanup.
447 : : */
448 [ # # ]: 0 : if (!done && timeout) {
449 : : done = 1;
450 [ # # ]: 0 : PMD_DRV_LOG(DEBUG, "Timing out for %s ring\n",
451 : : rx ? "Rx" : "Tx");
452 : : }
453 : : } else {
454 : : /* This HWRM command is not for a Tx/Rx/AGG ring cleanup.
455 : : * Otherwise the cpr would have been valid. So do nothing.
456 : : */
457 : : done = 1;
458 : : }
459 : :
460 : 0 : return done;
461 : : }
462 : :
463 : : /*
464 : : * HWRM Functions (sent to HWRM)
465 : : * These are named bnxt_hwrm_*() and return 0 on success or -110 if the
466 : : * HWRM command times out, or a negative error code if the HWRM
467 : : * command was failed by the FW.
468 : : */
469 : :
470 : 0 : static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg,
471 : : uint32_t msg_len, bool use_kong_mb)
472 : : {
473 : : unsigned int i;
474 : : struct input *req = msg;
475 : 0 : struct output *resp = bp->hwrm_cmd_resp_addr;
476 : : uint32_t *data = msg;
477 : : uint8_t *bar;
478 : : uint8_t *valid;
479 : 0 : uint16_t max_req_len = bp->max_req_len;
480 : 0 : struct hwrm_short_input short_input = { 0 };
481 [ # # ]: 0 : uint16_t bar_offset = use_kong_mb ?
482 : : GRCPF_REG_KONG_CHANNEL_OFFSET : GRCPF_REG_CHIMP_CHANNEL_OFFSET;
483 [ # # ]: 0 : uint16_t mb_trigger_offset = use_kong_mb ?
484 : : GRCPF_REG_KONG_COMM_TRIGGER : GRCPF_REG_CHIMP_COMM_TRIGGER;
485 : : struct bnxt_cp_ring_info *cpr = NULL;
486 : : bool is_rx = false;
487 : : bool is_tx = false;
488 : : uint32_t timeout;
489 : :
490 : : /* Do not send HWRM commands to firmware in error state */
491 [ # # ]: 0 : if (bp->flags & BNXT_FLAG_FATAL_ERROR)
492 : : return 0;
493 : :
494 : : /* If previous HWRM command timed out, do not send new HWRM command */
495 [ # # ]: 0 : if (bp->flags & BNXT_FLAG_FW_TIMEDOUT)
496 : : return 0;
497 : :
498 : 0 : timeout = bp->hwrm_cmd_timeout;
499 : :
500 : : /* Update the message length for backing store config for new FW. */
501 [ # # ]: 0 : if (bp->fw_ver >= HWRM_VERSION_1_10_2_13 &&
502 [ # # ]: 0 : rte_cpu_to_le_16(req->req_type) == HWRM_FUNC_BACKING_STORE_CFG)
503 : : msg_len = BNXT_BACKING_STORE_CFG_LEGACY_LEN;
504 : :
505 [ # # ]: 0 : if (bp->flags & BNXT_FLAG_SHORT_CMD ||
506 [ # # ]: 0 : msg_len > bp->max_req_len) {
507 : 0 : void *short_cmd_req = bp->hwrm_short_cmd_req_addr;
508 : :
509 : 0 : memset(short_cmd_req, 0, bp->hwrm_max_ext_req_len);
510 : 0 : memcpy(short_cmd_req, req, msg_len);
511 : :
512 : 0 : short_input.req_type = rte_cpu_to_le_16(req->req_type);
513 : 0 : short_input.signature = rte_cpu_to_le_16(
514 : : HWRM_SHORT_INPUT_SIGNATURE_SHORT_CMD);
515 : 0 : short_input.size = rte_cpu_to_le_16(msg_len);
516 : 0 : short_input.req_addr =
517 : 0 : rte_cpu_to_le_64(bp->hwrm_short_cmd_req_dma_addr);
518 : :
519 : : data = (uint32_t *)&short_input;
520 : : msg_len = sizeof(short_input);
521 : :
522 : : max_req_len = BNXT_HWRM_SHORT_REQ_LEN;
523 : : }
524 : :
525 : : /* Write request msg to hwrm channel */
526 [ # # ]: 0 : for (i = 0; i < msg_len; i += 4) {
527 : 0 : bar = (uint8_t *)bp->bar0 + bar_offset + i;
528 : 0 : rte_write32(*data, bar);
529 : 0 : data++;
530 : : }
531 : :
532 : : /* Zero the rest of the request space */
533 [ # # ]: 0 : for (; i < max_req_len; i += 4) {
534 : 0 : bar = (uint8_t *)bp->bar0 + bar_offset + i;
535 : : rte_write32(0, bar);
536 : : }
537 : :
538 : : /* Ring channel doorbell */
539 : 0 : bar = (uint8_t *)bp->bar0 + mb_trigger_offset;
540 : : rte_write32(1, bar);
541 : : /*
542 : : * Make sure the channel doorbell ring command complete before
543 : : * reading the response to avoid getting stale or invalid
544 : : * responses.
545 : : */
546 : : rte_io_mb();
547 : :
548 : : /* Check ring flush is done.
549 : : * This is valid only for Tx and Rx rings (including AGG rings).
550 : : * The Tx and Rx rings should be freed once the HW confirms all
551 : : * the internal buffers and BDs associated with the rings are
552 : : * consumed and the corresponding DMA is handled.
553 : : */
554 [ # # ]: 0 : if (rte_cpu_to_le_16(req->cmpl_ring) != INVALID_HW_RING_ID) {
555 : : /* Check if the TxCQ matches. If that fails check if RxCQ
556 : : * matches. And if neither match, is_rx = false, is_tx = false.
557 : : */
558 : 0 : cpr = bnxt_get_ring_info_by_id(bp, req->cmpl_ring,
559 : : HWRM_RING_FREE_INPUT_RING_TYPE_TX);
560 [ # # ]: 0 : if (cpr == NULL) {
561 : : /* Not a TxCQ. Check if the RxCQ matches. */
562 : : cpr =
563 : 0 : bnxt_get_ring_info_by_id(bp, req->cmpl_ring,
564 : : HWRM_RING_FREE_INPUT_RING_TYPE_RX);
565 [ # # ]: 0 : if (cpr != NULL)
566 : : is_rx = true;
567 : : } else {
568 : : is_tx = true;
569 : : }
570 : : }
571 : :
572 : : /* Poll for the valid bit */
573 [ # # ]: 0 : for (i = 0; i < timeout; i++) {
574 : : int done;
575 : :
576 : 0 : done = bnxt_check_cq_hwrm_done(cpr, is_tx, is_rx,
577 : 0 : i == timeout - 1);
578 : : /* Sanity check on the resp->resp_len */
579 : 0 : rte_io_rmb();
580 [ # # # # ]: 0 : if (resp->resp_len && resp->resp_len <= bp->max_resp_len) {
581 : : /* Last byte of resp contains the valid key */
582 : 0 : valid = (uint8_t *)resp + resp->resp_len - 1;
583 [ # # # # ]: 0 : if (*valid == HWRM_RESP_VALID_KEY && done)
584 : : break;
585 : : }
586 : 0 : rte_delay_us(1);
587 : : }
588 : :
589 [ # # ]: 0 : if (i >= timeout) {
590 : : /* Suppress VER_GET timeout messages during reset recovery */
591 [ # # ]: 0 : if (bp->flags & BNXT_FLAG_FW_RESET &&
592 [ # # ]: 0 : rte_cpu_to_le_16(req->req_type) == HWRM_VER_GET)
593 : : return -ETIMEDOUT;
594 : :
595 : 0 : PMD_DRV_LOG(ERR,
596 : : "Error(timeout) sending msg 0x%04x, seq_id %d\n",
597 : : req->req_type, req->seq_id);
598 : 0 : bp->flags |= BNXT_FLAG_FW_TIMEDOUT;
599 : 0 : return -ETIMEDOUT;
600 : : }
601 : : return 0;
602 : : }
603 : :
604 : : /*
605 : : * HWRM_PREP() should be used to prepare *ALL* HWRM commands. It grabs the
606 : : * spinlock, and does initial processing.
607 : : *
608 : : * HWRM_CHECK_RESULT() returns errors on failure and may not be used. It
609 : : * releases the spinlock only if it returns. If the regular int return codes
610 : : * are not used by the function, HWRM_CHECK_RESULT() should not be used
611 : : * directly, rather it should be copied and modified to suit the function.
612 : : *
613 : : * HWRM_UNLOCK() must be called after all response processing is completed.
614 : : */
615 : : #define HWRM_PREP(req, type, kong) do { \
616 : : rte_spinlock_lock(&bp->hwrm_lock); \
617 : : if (bp->hwrm_cmd_resp_addr == NULL) { \
618 : : rte_spinlock_unlock(&bp->hwrm_lock); \
619 : : return -EACCES; \
620 : : } \
621 : : memset(bp->hwrm_cmd_resp_addr, 0, bp->max_resp_len); \
622 : : (req)->req_type = rte_cpu_to_le_16(type); \
623 : : (req)->cmpl_ring = rte_cpu_to_le_16(-1); \
624 : : (req)->seq_id = kong ? rte_cpu_to_le_16(bp->kong_cmd_seq++) :\
625 : : rte_cpu_to_le_16(bp->chimp_cmd_seq++); \
626 : : (req)->target_id = rte_cpu_to_le_16(0xffff); \
627 : : (req)->resp_addr = rte_cpu_to_le_64(bp->hwrm_cmd_resp_dma_addr); \
628 : : } while (0)
629 : :
630 : : #define HWRM_CHECK_RESULT_SILENT() do {\
631 : : if (rc) { \
632 : : rte_spinlock_unlock(&bp->hwrm_lock); \
633 : : return rc; \
634 : : } \
635 : : if (resp->error_code) { \
636 : : rc = rte_le_to_cpu_16(resp->error_code); \
637 : : rte_spinlock_unlock(&bp->hwrm_lock); \
638 : : return rc; \
639 : : } \
640 : : } while (0)
641 : :
642 : : #define HWRM_CHECK_RESULT() do {\
643 : : if (rc) { \
644 : : PMD_DRV_LOG(ERR, "failed rc:%d\n", rc); \
645 : : rte_spinlock_unlock(&bp->hwrm_lock); \
646 : : if (rc == HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED) \
647 : : rc = -EACCES; \
648 : : else if (rc == HWRM_ERR_CODE_RESOURCE_ALLOC_ERROR) \
649 : : rc = -ENOSPC; \
650 : : else if (rc == HWRM_ERR_CODE_INVALID_PARAMS) \
651 : : rc = -EINVAL; \
652 : : else if (rc == HWRM_ERR_CODE_CMD_NOT_SUPPORTED) \
653 : : rc = -ENOTSUP; \
654 : : else if (rc == HWRM_ERR_CODE_HOT_RESET_PROGRESS) \
655 : : rc = -EAGAIN; \
656 : : else if (rc > 0) \
657 : : rc = -EIO; \
658 : : return rc; \
659 : : } \
660 : : if (resp->error_code) { \
661 : : rc = rte_le_to_cpu_16(resp->error_code); \
662 : : if (resp->resp_len >= 16) { \
663 : : struct hwrm_err_output *tmp_hwrm_err_op = \
664 : : (void *)resp; \
665 : : PMD_DRV_LOG(ERR, \
666 : : "error %d:%d:%08x:%04x\n", \
667 : : rc, tmp_hwrm_err_op->cmd_err, \
668 : : rte_le_to_cpu_32(\
669 : : tmp_hwrm_err_op->opaque_0), \
670 : : rte_le_to_cpu_16(\
671 : : tmp_hwrm_err_op->opaque_1)); \
672 : : } else { \
673 : : PMD_DRV_LOG(ERR, "error %d\n", rc); \
674 : : } \
675 : : rte_spinlock_unlock(&bp->hwrm_lock); \
676 : : if (rc == HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED) \
677 : : rc = -EACCES; \
678 : : else if (rc == HWRM_ERR_CODE_RESOURCE_ALLOC_ERROR) \
679 : : rc = -ENOSPC; \
680 : : else if (rc == HWRM_ERR_CODE_INVALID_PARAMS) \
681 : : rc = -EINVAL; \
682 : : else if (rc == HWRM_ERR_CODE_CMD_NOT_SUPPORTED) \
683 : : rc = -ENOTSUP; \
684 : : else if (rc == HWRM_ERR_CODE_HOT_RESET_PROGRESS) \
685 : : rc = -EAGAIN; \
686 : : else if (rc > 0) \
687 : : rc = -EIO; \
688 : : return rc; \
689 : : } \
690 : : } while (0)
691 : :
692 : : #define HWRM_UNLOCK() rte_spinlock_unlock(&bp->hwrm_lock)
693 : :
694 : 0 : int bnxt_hwrm_tf_message_direct(struct bnxt *bp,
695 : : bool use_kong_mb,
696 : : uint16_t msg_type,
697 : : void *msg,
698 : : uint32_t msg_len,
699 : : void *resp_msg,
700 : : uint32_t resp_len)
701 : : {
702 : : int rc = 0;
703 : : bool mailbox = BNXT_USE_CHIMP_MB;
704 : : struct input *req = msg;
705 : 0 : struct output *resp = bp->hwrm_cmd_resp_addr;
706 : :
707 [ # # ]: 0 : if (use_kong_mb)
708 : 0 : mailbox = BNXT_USE_KONG(bp);
709 : :
710 [ # # # # ]: 0 : HWRM_PREP(req, msg_type, mailbox);
711 : :
712 : 0 : rc = bnxt_hwrm_send_message(bp, req, msg_len, mailbox);
713 : :
714 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
715 : :
716 [ # # ]: 0 : if (resp_msg)
717 : 0 : memcpy(resp_msg, resp, resp_len);
718 : :
719 : : HWRM_UNLOCK();
720 : :
721 : 0 : return rc;
722 : : }
723 : :
724 : 0 : int bnxt_hwrm_cfa_l2_clear_rx_mask(struct bnxt *bp, struct bnxt_vnic_info *vnic)
725 : : {
726 : : int rc = 0;
727 : 0 : struct hwrm_cfa_l2_set_rx_mask_input req = {.req_type = 0 };
728 : 0 : struct hwrm_cfa_l2_set_rx_mask_output *resp = bp->hwrm_cmd_resp_addr;
729 : :
730 [ # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_L2_SET_RX_MASK, BNXT_USE_CHIMP_MB);
731 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
732 : 0 : req.mask = 0;
733 : :
734 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
735 : :
736 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
737 : : HWRM_UNLOCK();
738 : :
739 : 0 : return rc;
740 : : }
741 : :
742 : 0 : int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp,
743 : : struct bnxt_vnic_info *vnic,
744 : : uint16_t vlan_count,
745 : : struct bnxt_vlan_table_entry *vlan_table)
746 : : {
747 : : int rc = 0;
748 : 0 : struct hwrm_cfa_l2_set_rx_mask_input req = {.req_type = 0 };
749 : 0 : struct hwrm_cfa_l2_set_rx_mask_output *resp = bp->hwrm_cmd_resp_addr;
750 : : uint32_t mask = 0;
751 : :
752 [ # # ]: 0 : if (vnic->fw_vnic_id == INVALID_HW_RING_ID)
753 : : return rc;
754 : :
755 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_L2_SET_RX_MASK, BNXT_USE_CHIMP_MB);
756 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
757 : :
758 [ # # ]: 0 : if (vnic->flags & BNXT_VNIC_INFO_BCAST)
759 : : mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_BCAST;
760 [ # # ]: 0 : if (vnic->flags & BNXT_VNIC_INFO_UNTAGGED)
761 : 0 : mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_VLAN_NONVLAN;
762 : :
763 [ # # ]: 0 : if (vnic->flags & BNXT_VNIC_INFO_PROMISC)
764 : 0 : mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_PROMISCUOUS;
765 : :
766 [ # # ]: 0 : if (vnic->flags & BNXT_VNIC_INFO_ALLMULTI) {
767 : 0 : mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST;
768 [ # # ]: 0 : } else if (vnic->flags & BNXT_VNIC_INFO_MCAST) {
769 : 0 : mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_MCAST;
770 : 0 : req.num_mc_entries = rte_cpu_to_le_32(bp->nb_mc_addr);
771 : 0 : req.mc_tbl_addr = rte_cpu_to_le_64(bp->mc_list_dma_addr);
772 : : }
773 [ # # ]: 0 : if (vlan_table) {
774 [ # # ]: 0 : if (!(mask & HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_VLAN_NONVLAN))
775 : 0 : mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_VLANONLY;
776 : 0 : req.vlan_tag_tbl_addr =
777 : 0 : rte_cpu_to_le_64(rte_malloc_virt2iova(vlan_table));
778 : 0 : req.num_vlan_tags = rte_cpu_to_le_32((uint32_t)vlan_count);
779 : : }
780 : 0 : req.mask = rte_cpu_to_le_32(mask);
781 : :
782 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
783 : :
784 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
785 : : HWRM_UNLOCK();
786 : :
787 : 0 : return rc;
788 : : }
789 : :
790 : 0 : int bnxt_hwrm_cfa_vlan_antispoof_cfg(struct bnxt *bp, uint16_t fid,
791 : : uint16_t vlan_count,
792 : : struct bnxt_vlan_antispoof_table_entry *vlan_table)
793 : : {
794 : : int rc = 0;
795 : 0 : struct hwrm_cfa_vlan_antispoof_cfg_input req = {.req_type = 0 };
796 : 0 : struct hwrm_cfa_vlan_antispoof_cfg_output *resp =
797 : : bp->hwrm_cmd_resp_addr;
798 : :
799 : : /*
800 : : * Older HWRM versions did not support this command, and the set_rx_mask
801 : : * list was used for anti-spoof. In 1.8.0, the TX path configuration was
802 : : * removed from set_rx_mask call, and this command was added.
803 : : *
804 : : * This command is also present from 1.7.8.11 and higher,
805 : : * as well as 1.7.8.0
806 : : */
807 [ # # ]: 0 : if (bp->fw_ver < ((1 << 24) | (8 << 16))) {
808 [ # # ]: 0 : if (bp->fw_ver != ((1 << 24) | (7 << 16) | (8 << 8))) {
809 [ # # ]: 0 : if (bp->fw_ver < ((1 << 24) | (7 << 16) | (8 << 8) |
810 : : (11)))
811 : : return 0;
812 : : }
813 : : }
814 [ # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_VLAN_ANTISPOOF_CFG, BNXT_USE_CHIMP_MB);
815 : 0 : req.fid = rte_cpu_to_le_16(fid);
816 : :
817 : 0 : req.vlan_tag_mask_tbl_addr =
818 : 0 : rte_cpu_to_le_64(rte_malloc_virt2iova(vlan_table));
819 : 0 : req.num_vlan_entries = rte_cpu_to_le_32((uint32_t)vlan_count);
820 : :
821 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
822 : :
823 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
824 : : HWRM_UNLOCK();
825 : :
826 : 0 : return rc;
827 : : }
828 : :
829 : 0 : int bnxt_hwrm_clear_l2_filter(struct bnxt *bp,
830 : : struct bnxt_filter_info *filter)
831 : : {
832 : : int rc = 0;
833 : : struct bnxt_filter_info *l2_filter = filter;
834 : : struct bnxt_vnic_info *vnic = NULL;
835 : 0 : struct hwrm_cfa_l2_filter_free_input req = {.req_type = 0 };
836 : 0 : struct hwrm_cfa_l2_filter_free_output *resp = bp->hwrm_cmd_resp_addr;
837 : :
838 [ # # ]: 0 : if (filter->fw_l2_filter_id == UINT64_MAX)
839 : : return 0;
840 : :
841 [ # # ]: 0 : if (filter->matching_l2_fltr_ptr)
842 : : l2_filter = filter->matching_l2_fltr_ptr;
843 : :
844 : 0 : PMD_DRV_LOG(DEBUG, "filter: %p l2_filter: %p ref_cnt: %d\n",
845 : : filter, l2_filter, l2_filter->l2_ref_cnt);
846 : :
847 [ # # ]: 0 : if (l2_filter->l2_ref_cnt == 0)
848 : : return 0;
849 : :
850 : : if (l2_filter->l2_ref_cnt > 0)
851 : 0 : l2_filter->l2_ref_cnt--;
852 : :
853 [ # # ]: 0 : if (l2_filter->l2_ref_cnt > 0)
854 : : return 0;
855 : :
856 [ # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_L2_FILTER_FREE, BNXT_USE_CHIMP_MB);
857 : :
858 : 0 : req.l2_filter_id = rte_cpu_to_le_64(filter->fw_l2_filter_id);
859 : :
860 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
861 : :
862 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
863 : : HWRM_UNLOCK();
864 : :
865 : 0 : filter->fw_l2_filter_id = UINT64_MAX;
866 [ # # ]: 0 : if (l2_filter->l2_ref_cnt == 0) {
867 : 0 : vnic = l2_filter->vnic;
868 [ # # ]: 0 : if (vnic) {
869 [ # # # # : 0 : STAILQ_REMOVE(&vnic->filter, l2_filter,
# # # # ]
870 : : bnxt_filter_info, next);
871 : 0 : bnxt_free_filter(bp, l2_filter);
872 : : }
873 : : }
874 : :
875 : : return 0;
876 : : }
877 : :
878 : 0 : int bnxt_hwrm_set_l2_filter(struct bnxt *bp,
879 : : uint16_t dst_id,
880 : : struct bnxt_filter_info *filter)
881 : : {
882 : : int rc = 0;
883 : 0 : struct hwrm_cfa_l2_filter_alloc_input req = {.req_type = 0 };
884 : 0 : struct hwrm_cfa_l2_filter_alloc_output *resp = bp->hwrm_cmd_resp_addr;
885 : 0 : struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf;
886 : : const struct rte_eth_vmdq_rx_conf *conf =
887 : : &dev_conf->rx_adv_conf.vmdq_rx_conf;
888 : : uint32_t enables = 0;
889 : 0 : uint16_t j = dst_id - 1;
890 : :
891 : : //TODO: Is there a better way to add VLANs to each VNIC in case of VMDQ
892 [ # # ]: 0 : if ((dev_conf->rxmode.mq_mode & RTE_ETH_MQ_RX_VMDQ_FLAG) &&
893 [ # # ]: 0 : conf->pool_map[j].pools & (1UL << j)) {
894 : 0 : PMD_DRV_LOG(DEBUG,
895 : : "Add vlan %u to vmdq pool %u\n",
896 : : conf->pool_map[j].vlan_id, j);
897 : :
898 : 0 : filter->l2_ivlan = conf->pool_map[j].vlan_id;
899 : 0 : filter->enables |=
900 : : HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN |
901 : : HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN_MASK;
902 : : }
903 : :
904 [ # # ]: 0 : if (filter->fw_l2_filter_id != UINT64_MAX)
905 : 0 : bnxt_hwrm_clear_l2_filter(bp, filter);
906 : :
907 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_L2_FILTER_ALLOC, BNXT_USE_CHIMP_MB);
908 : :
909 : : /* PMD does not support XDP and RoCE */
910 : 0 : filter->flags |= HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_XDP_DISABLE |
911 : : HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_TRAFFIC_L2;
912 : 0 : req.flags = rte_cpu_to_le_32(filter->flags);
913 : :
914 : 0 : enables = filter->enables |
915 : : HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_DST_ID;
916 : 0 : req.dst_id = rte_cpu_to_le_16(dst_id);
917 : :
918 [ # # ]: 0 : if (enables &
919 : : HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR)
920 : : memcpy(req.l2_addr, filter->l2_addr,
921 : : RTE_ETHER_ADDR_LEN);
922 [ # # ]: 0 : if (enables &
923 : : HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR_MASK)
924 : : memcpy(req.l2_addr_mask, filter->l2_addr_mask,
925 : : RTE_ETHER_ADDR_LEN);
926 [ # # ]: 0 : if (enables &
927 : : HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_OVLAN)
928 : 0 : req.l2_ovlan = filter->l2_ovlan;
929 [ # # ]: 0 : if (enables &
930 : : HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN)
931 : 0 : req.l2_ivlan = filter->l2_ivlan;
932 [ # # ]: 0 : if (enables &
933 : : HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_OVLAN_MASK)
934 : 0 : req.l2_ovlan_mask = filter->l2_ovlan_mask;
935 [ # # ]: 0 : if (enables &
936 : : HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN_MASK)
937 : 0 : req.l2_ivlan_mask = filter->l2_ivlan_mask;
938 [ # # ]: 0 : if (enables & HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_SRC_ID)
939 : 0 : req.src_id = rte_cpu_to_le_32(filter->src_id);
940 [ # # ]: 0 : if (enables & HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_SRC_TYPE)
941 : 0 : req.src_type = filter->src_type;
942 [ # # ]: 0 : if (filter->pri_hint) {
943 : 0 : req.pri_hint = filter->pri_hint;
944 : 0 : req.l2_filter_id_hint =
945 : 0 : rte_cpu_to_le_64(filter->l2_filter_id_hint);
946 : : }
947 : :
948 : 0 : req.enables = rte_cpu_to_le_32(enables);
949 : :
950 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
951 : :
952 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
953 : :
954 : 0 : filter->fw_l2_filter_id = rte_le_to_cpu_64(resp->l2_filter_id);
955 : 0 : filter->flow_id = rte_le_to_cpu_32(resp->flow_id);
956 : : HWRM_UNLOCK();
957 : :
958 : 0 : filter->l2_ref_cnt++;
959 : :
960 : 0 : return rc;
961 : : }
962 : :
963 : 0 : int bnxt_hwrm_ptp_cfg(struct bnxt *bp)
964 : : {
965 : 0 : struct hwrm_port_mac_cfg_input req = {.req_type = 0};
966 : 0 : struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
967 : : uint32_t flags = 0;
968 : : int rc;
969 : :
970 [ # # ]: 0 : if (!ptp)
971 : : return 0;
972 : :
973 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_MAC_CFG, BNXT_USE_CHIMP_MB);
974 : :
975 [ # # ]: 0 : if (ptp->rx_filter)
976 : : flags |= HWRM_PORT_MAC_CFG_INPUT_FLAGS_PTP_RX_TS_CAPTURE_ENABLE;
977 : : else
978 : : flags |=
979 : : HWRM_PORT_MAC_CFG_INPUT_FLAGS_PTP_RX_TS_CAPTURE_DISABLE;
980 [ # # ]: 0 : if (ptp->tx_tstamp_en)
981 : 0 : flags |= HWRM_PORT_MAC_CFG_INPUT_FLAGS_PTP_TX_TS_CAPTURE_ENABLE;
982 : : else
983 : 0 : flags |=
984 : : HWRM_PORT_MAC_CFG_INPUT_FLAGS_PTP_TX_TS_CAPTURE_DISABLE;
985 : :
986 [ # # ]: 0 : if (ptp->filter_all)
987 : 0 : flags |= HWRM_PORT_MAC_CFG_INPUT_FLAGS_ALL_RX_TS_CAPTURE_ENABLE;
988 [ # # ]: 0 : else if (bp->fw_cap & BNXT_FW_CAP_RX_ALL_PKT_TS)
989 : 0 : flags |= HWRM_PORT_MAC_CFG_INPUT_FLAGS_ALL_RX_TS_CAPTURE_DISABLE;
990 : :
991 : 0 : req.flags = rte_cpu_to_le_32(flags);
992 : 0 : req.enables = rte_cpu_to_le_32
993 : : (HWRM_PORT_MAC_CFG_INPUT_ENABLES_RX_TS_CAPTURE_PTP_MSG_TYPE);
994 : 0 : req.rx_ts_capture_ptp_msg_type = rte_cpu_to_le_16(ptp->rxctl);
995 : :
996 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
997 : : HWRM_UNLOCK();
998 : :
999 : 0 : return rc;
1000 : : }
1001 : :
1002 : 0 : static int bnxt_hwrm_ptp_qcfg(struct bnxt *bp)
1003 : : {
1004 : : int rc = 0;
1005 : 0 : struct hwrm_port_mac_ptp_qcfg_input req = {.req_type = 0};
1006 : 0 : struct hwrm_port_mac_ptp_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
1007 : 0 : struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
1008 : :
1009 [ # # ]: 0 : if (ptp)
1010 : : return 0;
1011 : :
1012 [ # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_MAC_PTP_QCFG, BNXT_USE_CHIMP_MB);
1013 : :
1014 : 0 : req.port_id = rte_cpu_to_le_16(bp->pf->port_id);
1015 : :
1016 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1017 : :
1018 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1019 : :
1020 [ # # ]: 0 : if (BNXT_CHIP_P5(bp)) {
1021 [ # # ]: 0 : if (!(resp->flags & HWRM_PORT_MAC_PTP_QCFG_OUTPUT_FLAGS_HWRM_ACCESS))
1022 : : return 0;
1023 : : } else {
1024 [ # # ]: 0 : if (!(resp->flags & HWRM_PORT_MAC_PTP_QCFG_OUTPUT_FLAGS_DIRECT_ACCESS))
1025 : : return 0;
1026 : : }
1027 : :
1028 [ # # ]: 0 : if (resp->flags & HWRM_PORT_MAC_PTP_QCFG_OUTPUT_FLAGS_ONE_STEP_TX_TS)
1029 : 0 : bp->flags |= BNXT_FLAG_FW_CAP_ONE_STEP_TX_TS;
1030 : :
1031 : 0 : ptp = rte_zmalloc("ptp_cfg", sizeof(*ptp), 0);
1032 [ # # ]: 0 : if (!ptp)
1033 : : return -ENOMEM;
1034 : :
1035 [ # # ]: 0 : if (!BNXT_CHIP_P5(bp)) {
1036 : 0 : ptp->rx_regs[BNXT_PTP_RX_TS_L] =
1037 : 0 : rte_le_to_cpu_32(resp->rx_ts_reg_off_lower);
1038 : 0 : ptp->rx_regs[BNXT_PTP_RX_TS_H] =
1039 : 0 : rte_le_to_cpu_32(resp->rx_ts_reg_off_upper);
1040 : 0 : ptp->rx_regs[BNXT_PTP_RX_SEQ] =
1041 : 0 : rte_le_to_cpu_32(resp->rx_ts_reg_off_seq_id);
1042 : 0 : ptp->rx_regs[BNXT_PTP_RX_FIFO] =
1043 : 0 : rte_le_to_cpu_32(resp->rx_ts_reg_off_fifo);
1044 : 0 : ptp->rx_regs[BNXT_PTP_RX_FIFO_ADV] =
1045 : 0 : rte_le_to_cpu_32(resp->rx_ts_reg_off_fifo_adv);
1046 : 0 : ptp->tx_regs[BNXT_PTP_TX_TS_L] =
1047 : 0 : rte_le_to_cpu_32(resp->tx_ts_reg_off_lower);
1048 : 0 : ptp->tx_regs[BNXT_PTP_TX_TS_H] =
1049 : 0 : rte_le_to_cpu_32(resp->tx_ts_reg_off_upper);
1050 : 0 : ptp->tx_regs[BNXT_PTP_TX_SEQ] =
1051 : 0 : rte_le_to_cpu_32(resp->tx_ts_reg_off_seq_id);
1052 : 0 : ptp->tx_regs[BNXT_PTP_TX_FIFO] =
1053 : 0 : rte_le_to_cpu_32(resp->tx_ts_reg_off_fifo);
1054 : : }
1055 : :
1056 : 0 : ptp->bp = bp;
1057 : 0 : bp->ptp_cfg = ptp;
1058 : :
1059 : 0 : return 0;
1060 : : }
1061 : :
1062 : 0 : void bnxt_free_vf_info(struct bnxt *bp)
1063 : : {
1064 : : int i;
1065 : :
1066 [ # # ]: 0 : if (bp->pf == NULL)
1067 : : return;
1068 : :
1069 [ # # ]: 0 : if (bp->pf->vf_info == NULL)
1070 : : return;
1071 : :
1072 [ # # ]: 0 : for (i = 0; i < bp->pf->max_vfs; i++) {
1073 : 0 : rte_free(bp->pf->vf_info[i].vlan_table);
1074 : 0 : bp->pf->vf_info[i].vlan_table = NULL;
1075 : 0 : rte_free(bp->pf->vf_info[i].vlan_as_table);
1076 : 0 : bp->pf->vf_info[i].vlan_as_table = NULL;
1077 : : }
1078 : 0 : rte_free(bp->pf->vf_info);
1079 : 0 : bp->pf->vf_info = NULL;
1080 : : }
1081 : :
1082 : 0 : static int bnxt_alloc_vf_info(struct bnxt *bp, uint16_t max_vfs)
1083 : : {
1084 : 0 : struct bnxt_child_vf_info *vf_info = bp->pf->vf_info;
1085 : : int i;
1086 : :
1087 [ # # ]: 0 : if (vf_info)
1088 : 0 : bnxt_free_vf_info(bp);
1089 : :
1090 : 0 : vf_info = rte_zmalloc("bnxt_vf_info", sizeof(*vf_info) * max_vfs, 0);
1091 [ # # ]: 0 : if (vf_info == NULL) {
1092 : 0 : PMD_DRV_LOG(ERR, "Failed to alloc vf info\n");
1093 : 0 : return -ENOMEM;
1094 : : }
1095 : :
1096 : 0 : bp->pf->max_vfs = max_vfs;
1097 [ # # ]: 0 : for (i = 0; i < max_vfs; i++) {
1098 : 0 : vf_info[i].fid = bp->pf->first_vf_id + i;
1099 : 0 : vf_info[i].vlan_table = rte_zmalloc("VF VLAN table",
1100 : 0 : getpagesize(), getpagesize());
1101 [ # # ]: 0 : if (vf_info[i].vlan_table == NULL) {
1102 : 0 : PMD_DRV_LOG(ERR, "Failed to alloc VLAN table for VF %d\n", i);
1103 : 0 : goto err;
1104 : : }
1105 : 0 : rte_mem_lock_page(vf_info[i].vlan_table);
1106 : :
1107 : 0 : vf_info[i].vlan_as_table = rte_zmalloc("VF VLAN AS table",
1108 : : getpagesize(), getpagesize());
1109 [ # # ]: 0 : if (vf_info[i].vlan_as_table == NULL) {
1110 : 0 : PMD_DRV_LOG(ERR, "Failed to alloc VLAN AS table for VF %d\n", i);
1111 : 0 : goto err;
1112 : : }
1113 : 0 : rte_mem_lock_page(vf_info[i].vlan_as_table);
1114 : :
1115 : 0 : STAILQ_INIT(&vf_info[i].filter);
1116 : : }
1117 : :
1118 : 0 : bp->pf->vf_info = vf_info;
1119 : :
1120 : 0 : return 0;
1121 : 0 : err:
1122 : 0 : bnxt_free_vf_info(bp);
1123 : 0 : return -ENOMEM;
1124 : : }
1125 : :
1126 : 0 : static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
1127 : : {
1128 : : int rc = 0;
1129 : 0 : struct hwrm_func_qcaps_input req = {.req_type = 0 };
1130 : 0 : struct hwrm_func_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
1131 : : uint16_t new_max_vfs;
1132 : : uint32_t flags, flags_ext2;
1133 : :
1134 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QCAPS, BNXT_USE_CHIMP_MB);
1135 : :
1136 : 0 : req.fid = rte_cpu_to_le_16(0xffff);
1137 : :
1138 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1139 : :
1140 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1141 : :
1142 : 0 : bp->max_ring_grps = rte_le_to_cpu_32(resp->max_hw_ring_grps);
1143 : 0 : flags = rte_le_to_cpu_32(resp->flags);
1144 [ # # ]: 0 : if (BNXT_PF(bp)) {
1145 : 0 : bp->pf->port_id = resp->port_id;
1146 : 0 : bp->pf->first_vf_id = rte_le_to_cpu_16(resp->first_vf_id);
1147 : 0 : bp->pf->total_vfs = rte_le_to_cpu_16(resp->max_vfs);
1148 : 0 : new_max_vfs = bp->pdev->max_vfs;
1149 [ # # ]: 0 : if (new_max_vfs != bp->pf->max_vfs) {
1150 : 0 : rc = bnxt_alloc_vf_info(bp, new_max_vfs);
1151 [ # # ]: 0 : if (rc)
1152 : 0 : goto unlock;
1153 : : }
1154 : : }
1155 : :
1156 : 0 : bp->fw_fid = rte_le_to_cpu_32(resp->fid);
1157 [ # # ]: 0 : if (!bnxt_check_zero_bytes(resp->mac_address, RTE_ETHER_ADDR_LEN)) {
1158 : 0 : bp->flags |= BNXT_FLAG_DFLT_MAC_SET;
1159 : 0 : memcpy(bp->mac_addr, &resp->mac_address, RTE_ETHER_ADDR_LEN);
1160 : : } else {
1161 : 0 : bp->flags &= ~BNXT_FLAG_DFLT_MAC_SET;
1162 : : }
1163 : 0 : bp->max_rsscos_ctx = rte_le_to_cpu_16(resp->max_rsscos_ctx);
1164 : 0 : bp->max_cp_rings = rte_le_to_cpu_16(resp->max_cmpl_rings);
1165 : 0 : bp->max_tx_rings = rte_le_to_cpu_16(resp->max_tx_rings);
1166 : 0 : bp->max_rx_rings = rte_le_to_cpu_16(resp->max_rx_rings);
1167 : 0 : bp->first_vf_id = rte_le_to_cpu_16(resp->first_vf_id);
1168 : 0 : bp->max_rx_em_flows = rte_le_to_cpu_16(resp->max_rx_em_flows);
1169 : 0 : bp->max_l2_ctx = rte_le_to_cpu_16(resp->max_l2_ctxs);
1170 [ # # # # ]: 0 : if (!BNXT_CHIP_P5_P7(bp) && !bp->pdev->max_vfs)
1171 : 0 : bp->max_l2_ctx += bp->max_rx_em_flows;
1172 [ # # ]: 0 : if (bp->vnic_cap_flags & BNXT_VNIC_CAP_COS_CLASSIFY)
1173 : 0 : bp->max_vnics = rte_le_to_cpu_16(BNXT_MAX_VNICS_COS_CLASSIFY);
1174 : : else
1175 : 0 : bp->max_vnics = rte_le_to_cpu_16(resp->max_vnics);
1176 : 0 : PMD_DRV_LOG(DEBUG, "Max l2_cntxts is %d vnics is %d\n",
1177 : : bp->max_l2_ctx, bp->max_vnics);
1178 : 0 : bp->max_stat_ctx = rte_le_to_cpu_16(resp->max_stat_ctx);
1179 : 0 : bp->max_mcast_addr = rte_le_to_cpu_32(resp->max_mcast_filters);
1180 [ # # ]: 0 : if (!bp->max_mcast_addr)
1181 : 0 : bp->max_mcast_addr = BNXT_DFLT_MAX_MC_ADDR;
1182 [ # # ]: 0 : memcpy(bp->dsn, resp->device_serial_number, sizeof(bp->dsn));
1183 : :
1184 [ # # ]: 0 : if (BNXT_PF(bp))
1185 : 0 : bp->pf->total_vnics = rte_le_to_cpu_16(resp->max_vnics);
1186 : :
1187 [ # # ]: 0 : if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_PTP_SUPPORTED) {
1188 [ # # ]: 0 : if (BNXT_CHIP_P5(bp) || BNXT_PF(bp)) {
1189 : 0 : bp->flags |= BNXT_FLAG_PTP_SUPPORTED;
1190 : 0 : PMD_DRV_LOG(DEBUG, "PTP SUPPORTED\n");
1191 : : HWRM_UNLOCK();
1192 : 0 : bnxt_hwrm_ptp_qcfg(bp);
1193 : : }
1194 : : }
1195 : :
1196 [ # # ]: 0 : if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_STATS_SUPPORTED)
1197 : 0 : bp->flags |= BNXT_FLAG_EXT_STATS_SUPPORTED;
1198 : :
1199 [ # # ]: 0 : if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERROR_RECOVERY_CAPABLE) {
1200 : 0 : bp->fw_cap |= BNXT_FW_CAP_ERROR_RECOVERY;
1201 : 0 : PMD_DRV_LOG(DEBUG, "Adapter Error recovery SUPPORTED\n");
1202 : : }
1203 : :
1204 [ # # ]: 0 : if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERR_RECOVER_RELOAD)
1205 : 0 : bp->fw_cap |= BNXT_FW_CAP_ERR_RECOVER_RELOAD;
1206 : :
1207 [ # # ]: 0 : if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_HOT_RESET_CAPABLE)
1208 : 0 : bp->fw_cap |= BNXT_FW_CAP_HOT_RESET;
1209 : :
1210 [ # # ]: 0 : if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_LINK_ADMIN_STATUS_SUPPORTED)
1211 : 0 : bp->fw_cap |= BNXT_FW_CAP_LINK_ADMIN;
1212 : :
1213 [ # # ]: 0 : if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_BS_V2_SUPPORTED) {
1214 : 0 : PMD_DRV_LOG(DEBUG, "Backing store v2 supported\n");
1215 [ # # ]: 0 : if (BNXT_CHIP_P7(bp))
1216 : 0 : bp->fw_cap |= BNXT_FW_CAP_BACKING_STORE_V2;
1217 : : }
1218 [ # # ]: 0 : if (!(flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_VLAN_ACCELERATION_TX_DISABLED)) {
1219 : 0 : bp->fw_cap |= BNXT_FW_CAP_VLAN_TX_INSERT;
1220 : 0 : PMD_DRV_LOG(DEBUG, "VLAN acceleration for TX is enabled\n");
1221 : : }
1222 : :
1223 : 0 : bp->tunnel_disable_flag = rte_le_to_cpu_16(resp->tunnel_disable_flag);
1224 [ # # ]: 0 : if (bp->tunnel_disable_flag)
1225 : 0 : PMD_DRV_LOG(DEBUG, "Tunnel parsing capability is disabled, flags : %#x\n",
1226 : : bp->tunnel_disable_flag);
1227 : :
1228 : 0 : flags_ext2 = rte_le_to_cpu_32(resp->flags_ext2);
1229 [ # # ]: 0 : if (flags_ext2 & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_RX_ALL_PKTS_TIMESTAMPS_SUPPORTED)
1230 : 0 : bp->fw_cap |= BNXT_FW_CAP_RX_ALL_PKT_TS;
1231 [ # # ]: 0 : if (flags_ext2 & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_UDP_GSO_SUPPORTED)
1232 : 0 : bp->fw_cap |= BNXT_FW_CAP_UDP_GSO;
1233 : :
1234 : 0 : unlock:
1235 : : HWRM_UNLOCK();
1236 : :
1237 : 0 : return rc;
1238 : : }
1239 : :
1240 : 0 : int bnxt_hwrm_func_qcaps(struct bnxt *bp)
1241 : : {
1242 : : int rc;
1243 : :
1244 : 0 : rc = __bnxt_hwrm_func_qcaps(bp);
1245 [ # # ]: 0 : if (rc == -ENOMEM)
1246 : : return rc;
1247 : :
1248 [ # # # # ]: 0 : if (!rc && bp->hwrm_spec_code >= HWRM_SPEC_CODE_1_8_3) {
1249 : 0 : rc = bnxt_alloc_ctx_mem(bp);
1250 [ # # ]: 0 : if (rc)
1251 : : return rc;
1252 : :
1253 : : /* On older FW,
1254 : : * bnxt_hwrm_func_resc_qcaps can fail and cause init failure.
1255 : : * But the error can be ignored. Return success.
1256 : : */
1257 : 0 : rc = bnxt_hwrm_func_resc_qcaps(bp);
1258 [ # # ]: 0 : if (!rc)
1259 : 0 : bp->flags |= BNXT_FLAG_NEW_RM;
1260 : : }
1261 : :
1262 : : return 0;
1263 : : }
1264 : :
1265 : : /* VNIC cap covers capability of all VNICs. So no need to pass vnic_id */
1266 : 0 : int bnxt_hwrm_vnic_qcaps(struct bnxt *bp)
1267 : : {
1268 : : int rc = 0;
1269 : : uint32_t flags;
1270 : 0 : struct hwrm_vnic_qcaps_input req = {.req_type = 0 };
1271 : 0 : struct hwrm_vnic_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
1272 : :
1273 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_QCAPS, BNXT_USE_CHIMP_MB);
1274 : :
1275 : : req.target_id = rte_cpu_to_le_16(0xffff);
1276 : :
1277 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1278 : :
1279 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1280 : :
1281 : 0 : flags = rte_le_to_cpu_32(resp->flags);
1282 : :
1283 [ # # ]: 0 : if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_COS_ASSIGNMENT_CAP) {
1284 : 0 : bp->vnic_cap_flags |= BNXT_VNIC_CAP_COS_CLASSIFY;
1285 : 0 : PMD_DRV_LOG(INFO, "CoS assignment capability enabled\n");
1286 : : }
1287 : :
1288 [ # # ]: 0 : if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_OUTERMOST_RSS_CAP)
1289 : 0 : bp->vnic_cap_flags |= BNXT_VNIC_CAP_OUTER_RSS;
1290 : :
1291 [ # # ]: 0 : if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_OUTERMOST_RSS_TRUSTED_VF_CAP) {
1292 : 0 : bp->vnic_cap_flags |= BNXT_VNIC_CAP_OUTER_RSS_TRUSTED_VF;
1293 : 0 : PMD_DRV_LOG(DEBUG, "Trusted VF's outer RSS capability is enabled\n");
1294 : : }
1295 : :
1296 [ # # ]: 0 : if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RX_CMPL_V2_CAP)
1297 : 0 : bp->vnic_cap_flags |= BNXT_VNIC_CAP_RX_CMPL_V2;
1298 : :
1299 [ # # ]: 0 : if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_VLAN_STRIP_CAP) {
1300 : 0 : bp->vnic_cap_flags |= BNXT_VNIC_CAP_VLAN_RX_STRIP;
1301 : 0 : PMD_DRV_LOG(DEBUG, "Rx VLAN strip capability enabled\n");
1302 : : }
1303 : :
1304 [ # # ]: 0 : if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RING_SELECT_MODE_XOR_CAP)
1305 : 0 : bp->vnic_cap_flags |= BNXT_VNIC_CAP_XOR_MODE;
1306 : :
1307 [ # # ]: 0 : if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RING_SELECT_MODE_TOEPLITZ_CHKSM_CAP)
1308 : 0 : bp->vnic_cap_flags |= BNXT_VNIC_CAP_CHKSM_MODE;
1309 : :
1310 [ # # ]: 0 : if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_L2_CQE_MODE_CAP)
1311 : 0 : bp->vnic_cap_flags |= BNXT_VNIC_CAP_L2_CQE_MODE;
1312 : :
1313 [ # # ]: 0 : if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RSS_IPSEC_AH_SPI_IPV4_CAP)
1314 : 0 : bp->vnic_cap_flags |= BNXT_VNIC_CAP_AH_SPI4_CAP;
1315 : :
1316 [ # # ]: 0 : if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RSS_IPSEC_AH_SPI_IPV6_CAP)
1317 : 0 : bp->vnic_cap_flags |= BNXT_VNIC_CAP_AH_SPI6_CAP;
1318 : :
1319 [ # # ]: 0 : if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RSS_IPSEC_ESP_SPI_IPV4_CAP)
1320 : 0 : bp->vnic_cap_flags |= BNXT_VNIC_CAP_ESP_SPI4_CAP;
1321 : :
1322 [ # # ]: 0 : if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RSS_IPSEC_ESP_SPI_IPV6_CAP)
1323 : 0 : bp->vnic_cap_flags |= BNXT_VNIC_CAP_ESP_SPI6_CAP;
1324 : :
1325 [ # # ]: 0 : if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_HW_TUNNEL_TPA_CAP)
1326 : 0 : bp->vnic_cap_flags |= BNXT_VNIC_CAP_VNIC_TUNNEL_TPA;
1327 : :
1328 : 0 : bp->max_tpa_v2 = rte_le_to_cpu_16(resp->max_aggs_supported);
1329 : :
1330 : : HWRM_UNLOCK();
1331 : :
1332 : 0 : return rc;
1333 : : }
1334 : :
1335 : 0 : int bnxt_hwrm_func_reset(struct bnxt *bp)
1336 : : {
1337 : : int rc = 0;
1338 : 0 : struct hwrm_func_reset_input req = {.req_type = 0 };
1339 : 0 : struct hwrm_func_reset_output *resp = bp->hwrm_cmd_resp_addr;
1340 : :
1341 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_RESET, BNXT_USE_CHIMP_MB);
1342 : :
1343 : 0 : req.enables = rte_cpu_to_le_32(0);
1344 : :
1345 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1346 : :
1347 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1348 : : HWRM_UNLOCK();
1349 : :
1350 : 0 : return rc;
1351 : : }
1352 : :
1353 : 0 : int bnxt_hwrm_func_driver_register(struct bnxt *bp)
1354 : : {
1355 : : int rc;
1356 : : uint32_t flags = 0;
1357 : 0 : struct hwrm_func_drv_rgtr_input req = {.req_type = 0 };
1358 : 0 : struct hwrm_func_drv_rgtr_output *resp = bp->hwrm_cmd_resp_addr;
1359 : :
1360 [ # # ]: 0 : if (bp->flags & BNXT_FLAG_REGISTERED)
1361 : : return 0;
1362 : :
1363 [ # # ]: 0 : if (bp->fw_cap & BNXT_FW_CAP_HOT_RESET)
1364 : : flags = HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_HOT_RESET_SUPPORT;
1365 [ # # ]: 0 : if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)
1366 : 0 : flags |= HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_ERROR_RECOVERY_SUPPORT;
1367 : :
1368 : : /* PFs and trusted VFs should indicate the support of the
1369 : : * Master capability on non Stingray platform
1370 : : */
1371 [ # # # # ]: 0 : if ((BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp)) && !BNXT_STINGRAY(bp))
1372 : 0 : flags |= HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_MASTER_SUPPORT;
1373 : :
1374 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_DRV_RGTR, BNXT_USE_CHIMP_MB);
1375 : 0 : req.enables = rte_cpu_to_le_32(HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_VER |
1376 : : HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_ASYNC_EVENT_FWD);
1377 : 0 : req.ver_maj_8b = RTE_VER_YEAR;
1378 : 0 : req.ver_min_8b = RTE_VER_MONTH;
1379 : 0 : req.ver_upd_8b = RTE_VER_MINOR;
1380 : :
1381 [ # # ]: 0 : if (BNXT_PF(bp)) {
1382 : 0 : req.enables |= rte_cpu_to_le_32(
1383 : : HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_VF_REQ_FWD);
1384 : 0 : memcpy(req.vf_req_fwd, bp->pf->vf_req_fwd,
1385 : : RTE_MIN(sizeof(req.vf_req_fwd),
1386 : : sizeof(bp->pf->vf_req_fwd)));
1387 : : }
1388 : :
1389 : 0 : req.flags = rte_cpu_to_le_32(flags);
1390 : :
1391 : 0 : req.async_event_fwd[0] |=
1392 : : rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_LINK_STATUS_CHANGE |
1393 : : ASYNC_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED |
1394 : : ASYNC_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE |
1395 : : ASYNC_CMPL_EVENT_ID_LINK_SPEED_CHANGE |
1396 : : ASYNC_CMPL_EVENT_ID_RESET_NOTIFY);
1397 [ # # ]: 0 : if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)
1398 : 0 : req.async_event_fwd[0] |=
1399 : : rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_ERROR_RECOVERY);
1400 : 0 : req.async_event_fwd[1] |=
1401 : : rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_PF_DRVR_UNLOAD |
1402 : : ASYNC_CMPL_EVENT_ID_VF_CFG_CHANGE);
1403 [ # # ]: 0 : if (BNXT_PF(bp))
1404 : 0 : req.async_event_fwd[1] |=
1405 : : rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_DBG_NOTIFICATION);
1406 : :
1407 [ # # ]: 0 : if (BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp)) {
1408 : 0 : req.async_event_fwd[1] |=
1409 : : rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_DEFAULT_VNIC_CHANGE |
1410 : : ASYNC_CMPL_EVENT_ID_VF_FLR);
1411 : : }
1412 : :
1413 : 0 : req.async_event_fwd[2] |=
1414 : : rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_ECHO_REQUEST |
1415 : : ASYNC_CMPL_EVENT_ID_ERROR_REPORT);
1416 : :
1417 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1418 : :
1419 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1420 : :
1421 : 0 : flags = rte_le_to_cpu_32(resp->flags);
1422 [ # # ]: 0 : if (flags & HWRM_FUNC_DRV_RGTR_OUTPUT_FLAGS_IF_CHANGE_SUPPORTED)
1423 : 0 : bp->fw_cap |= BNXT_FW_CAP_IF_CHANGE;
1424 : :
1425 : : HWRM_UNLOCK();
1426 : :
1427 : 0 : bp->flags |= BNXT_FLAG_REGISTERED;
1428 : :
1429 : 0 : return rc;
1430 : : }
1431 : :
1432 : 0 : int bnxt_hwrm_check_vf_rings(struct bnxt *bp)
1433 : : {
1434 [ # # ]: 0 : if (!(BNXT_VF(bp) && (bp->flags & BNXT_FLAG_NEW_RM)))
1435 : : return 0;
1436 : :
1437 : 0 : return bnxt_hwrm_func_reserve_vf_resc(bp, true);
1438 : : }
1439 : :
1440 : 0 : int bnxt_hwrm_func_reserve_vf_resc(struct bnxt *bp, bool test)
1441 : : {
1442 : : int rc;
1443 : : uint32_t flags = 0;
1444 : : uint32_t enables;
1445 : 0 : struct hwrm_func_vf_cfg_output *resp = bp->hwrm_cmd_resp_addr;
1446 : 0 : struct hwrm_func_vf_cfg_input req = {0};
1447 : :
1448 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_VF_CFG, BNXT_USE_CHIMP_MB);
1449 : :
1450 : : enables = HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_RX_RINGS |
1451 : : HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_TX_RINGS |
1452 : : HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_STAT_CTXS |
1453 : : HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_CMPL_RINGS |
1454 : : HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_VNICS;
1455 : :
1456 [ # # ]: 0 : if (BNXT_HAS_RING_GRPS(bp)) {
1457 : : enables |= HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_HW_RING_GRPS;
1458 : 0 : req.num_hw_ring_grps = rte_cpu_to_le_16(bp->rx_nr_rings);
1459 : : }
1460 : :
1461 : 0 : req.num_tx_rings = rte_cpu_to_le_16(bp->tx_nr_rings);
1462 : 0 : req.num_rx_rings = rte_cpu_to_le_16(bp->rx_nr_rings *
1463 : : AGG_RING_MULTIPLIER);
1464 : 0 : req.num_stat_ctxs = rte_cpu_to_le_16(bp->rx_nr_rings + bp->tx_nr_rings);
1465 : 0 : req.num_cmpl_rings = rte_cpu_to_le_16(bp->rx_nr_rings +
1466 : : bp->tx_nr_rings +
1467 : : BNXT_NUM_ASYNC_CPR(bp));
1468 [ # # ]: 0 : if (BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp)) {
1469 : 0 : req.num_vnics = rte_cpu_to_le_16(RTE_MIN(BNXT_VNIC_MAX_SUPPORTED_ID,
1470 : : bp->max_vnics));
1471 : 0 : enables |= HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_RSSCOS_CTXS;
1472 : 0 : req.num_rsscos_ctxs = rte_cpu_to_le_16(RTE_MIN(BNXT_VNIC_MAX_SUPPORTED_ID,
1473 : : bp->max_rsscos_ctx));
1474 : : } else {
1475 : 0 : req.num_vnics = rte_cpu_to_le_16(bp->rx_nr_rings);
1476 : : }
1477 : :
1478 [ # # ]: 0 : if (bp->vf_resv_strategy ==
1479 : : HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESV_STRATEGY_MINIMAL_STATIC) {
1480 : 0 : enables |= HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_VNICS |
1481 : : HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_L2_CTXS |
1482 : : HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_RSSCOS_CTXS;
1483 : 0 : req.num_rsscos_ctxs = rte_cpu_to_le_16(BNXT_VF_RSV_NUM_RSS_CTX);
1484 : 0 : req.num_l2_ctxs = rte_cpu_to_le_16(BNXT_VF_RSV_NUM_L2_CTX);
1485 : 0 : req.num_vnics = rte_cpu_to_le_16(BNXT_VF_RSV_NUM_VNIC);
1486 [ # # ]: 0 : } else if (bp->vf_resv_strategy ==
1487 : : HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESV_STRATEGY_MAXIMAL) {
1488 : 0 : enables |= HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_RSSCOS_CTXS;
1489 : 0 : req.num_rsscos_ctxs = rte_cpu_to_le_16(bp->max_rsscos_ctx);
1490 : : }
1491 : :
1492 [ # # ]: 0 : if (test)
1493 : : flags = HWRM_FUNC_VF_CFG_INPUT_FLAGS_TX_ASSETS_TEST |
1494 : : HWRM_FUNC_VF_CFG_INPUT_FLAGS_RX_ASSETS_TEST |
1495 : : HWRM_FUNC_VF_CFG_INPUT_FLAGS_CMPL_ASSETS_TEST |
1496 : : HWRM_FUNC_VF_CFG_INPUT_FLAGS_RING_GRP_ASSETS_TEST |
1497 : : HWRM_FUNC_VF_CFG_INPUT_FLAGS_STAT_CTX_ASSETS_TEST |
1498 : : HWRM_FUNC_VF_CFG_INPUT_FLAGS_VNIC_ASSETS_TEST;
1499 : :
1500 [ # # # # ]: 0 : if (test && BNXT_HAS_RING_GRPS(bp))
1501 : 0 : flags |= HWRM_FUNC_VF_CFG_INPUT_FLAGS_RING_GRP_ASSETS_TEST;
1502 : :
1503 : 0 : req.flags = rte_cpu_to_le_32(flags);
1504 : 0 : req.enables |= rte_cpu_to_le_32(enables);
1505 : :
1506 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1507 : :
1508 [ # # ]: 0 : if (test)
1509 [ # # # # ]: 0 : HWRM_CHECK_RESULT_SILENT();
1510 : : else
1511 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1512 : :
1513 : : HWRM_UNLOCK();
1514 : 0 : return rc;
1515 : : }
1516 : :
1517 : 0 : int bnxt_hwrm_func_resc_qcaps(struct bnxt *bp)
1518 : : {
1519 : : int rc;
1520 : 0 : struct hwrm_func_resource_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
1521 : 0 : struct hwrm_func_resource_qcaps_input req = {0};
1522 : :
1523 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_RESOURCE_QCAPS, BNXT_USE_CHIMP_MB);
1524 : 0 : req.fid = rte_cpu_to_le_16(0xffff);
1525 : :
1526 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1527 : :
1528 [ # # # # ]: 0 : HWRM_CHECK_RESULT_SILENT();
1529 : :
1530 : 0 : bp->max_rsscos_ctx = rte_le_to_cpu_16(resp->max_rsscos_ctx);
1531 : 0 : bp->max_cp_rings = rte_le_to_cpu_16(resp->max_cmpl_rings);
1532 : 0 : bp->max_tx_rings = rte_le_to_cpu_16(resp->max_tx_rings);
1533 : 0 : bp->max_rx_rings = rte_le_to_cpu_16(resp->max_rx_rings);
1534 : 0 : bp->max_ring_grps = rte_le_to_cpu_32(resp->max_hw_ring_grps);
1535 : : /* func_resource_qcaps does not return max_rx_em_flows.
1536 : : * So use the value provided by func_qcaps.
1537 : : */
1538 : 0 : bp->max_l2_ctx = rte_le_to_cpu_16(resp->max_l2_ctxs);
1539 [ # # # # ]: 0 : if (!BNXT_CHIP_P5_P7(bp) && !bp->pdev->max_vfs)
1540 : 0 : bp->max_l2_ctx += bp->max_rx_em_flows;
1541 [ # # ]: 0 : if (bp->vnic_cap_flags & BNXT_VNIC_CAP_COS_CLASSIFY)
1542 : 0 : bp->max_vnics = rte_le_to_cpu_16(BNXT_MAX_VNICS_COS_CLASSIFY);
1543 : : else
1544 : 0 : bp->max_vnics = rte_le_to_cpu_16(resp->max_vnics);
1545 : 0 : bp->max_stat_ctx = rte_le_to_cpu_16(resp->max_stat_ctx);
1546 [ # # ]: 0 : if (BNXT_CHIP_P7(bp))
1547 : 0 : bp->max_nq_rings = BNXT_P7_MAX_NQ_RING_CNT;
1548 : : else
1549 : 0 : bp->max_nq_rings = rte_le_to_cpu_16(resp->max_msix);
1550 : 0 : bp->vf_resv_strategy = rte_le_to_cpu_16(resp->vf_reservation_strategy);
1551 [ # # ]: 0 : if (bp->vf_resv_strategy >
1552 : : HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESV_STRATEGY_MINIMAL_STATIC)
1553 : 0 : bp->vf_resv_strategy =
1554 : : HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESERVATION_STRATEGY_MAXIMAL;
1555 : :
1556 : : HWRM_UNLOCK();
1557 : 0 : return rc;
1558 : : }
1559 : :
1560 : 0 : int bnxt_hwrm_ver_get(struct bnxt *bp, uint32_t timeout)
1561 : : {
1562 : : int rc = 0;
1563 : 0 : struct hwrm_ver_get_input req = {.req_type = 0 };
1564 : 0 : struct hwrm_ver_get_output *resp = bp->hwrm_cmd_resp_addr;
1565 : : uint32_t fw_version;
1566 : : uint16_t max_resp_len;
1567 : : char type[RTE_MEMZONE_NAMESIZE];
1568 : : uint32_t dev_caps_cfg;
1569 : :
1570 : 0 : bp->max_req_len = HWRM_MAX_REQ_LEN;
1571 : 0 : bp->hwrm_cmd_timeout = timeout;
1572 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VER_GET, BNXT_USE_CHIMP_MB);
1573 : :
1574 : 0 : req.hwrm_intf_maj = HWRM_VERSION_MAJOR;
1575 : 0 : req.hwrm_intf_min = HWRM_VERSION_MINOR;
1576 : 0 : req.hwrm_intf_upd = HWRM_VERSION_UPDATE;
1577 : :
1578 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1579 : :
1580 [ # # ]: 0 : if (bp->flags & BNXT_FLAG_FW_RESET)
1581 [ # # # # ]: 0 : HWRM_CHECK_RESULT_SILENT();
1582 : : else
1583 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1584 : :
1585 : 0 : PMD_DRV_LOG(INFO, "%d.%d.%d:%d.%d.%d.%d\n",
1586 : : resp->hwrm_intf_maj_8b, resp->hwrm_intf_min_8b,
1587 : : resp->hwrm_intf_upd_8b, resp->hwrm_fw_maj_8b,
1588 : : resp->hwrm_fw_min_8b, resp->hwrm_fw_bld_8b,
1589 : : resp->hwrm_fw_rsvd_8b);
1590 : 0 : bp->fw_ver = ((uint32_t)resp->hwrm_fw_maj_8b << 24) |
1591 : 0 : ((uint32_t)resp->hwrm_fw_min_8b << 16) |
1592 : 0 : ((uint32_t)resp->hwrm_fw_bld_8b << 8) |
1593 : 0 : resp->hwrm_fw_rsvd_8b;
1594 : 0 : PMD_DRV_LOG(INFO, "Driver HWRM version: %d.%d.%d\n",
1595 : : HWRM_VERSION_MAJOR, HWRM_VERSION_MINOR, HWRM_VERSION_UPDATE);
1596 : :
1597 : 0 : fw_version = resp->hwrm_intf_maj_8b << 16;
1598 : 0 : fw_version |= resp->hwrm_intf_min_8b << 8;
1599 : 0 : fw_version |= resp->hwrm_intf_upd_8b;
1600 : 0 : bp->hwrm_spec_code = fw_version;
1601 : :
1602 : : /* def_req_timeout value is in milliseconds */
1603 : 0 : bp->hwrm_cmd_timeout = rte_le_to_cpu_16(resp->def_req_timeout);
1604 : : /* convert timeout to usec */
1605 : 0 : bp->hwrm_cmd_timeout *= 1000;
1606 [ # # ]: 0 : if (!bp->hwrm_cmd_timeout)
1607 : 0 : bp->hwrm_cmd_timeout = DFLT_HWRM_CMD_TIMEOUT;
1608 : :
1609 [ # # ]: 0 : if (resp->hwrm_intf_maj_8b != HWRM_VERSION_MAJOR) {
1610 : 0 : PMD_DRV_LOG(ERR, "Unsupported firmware API version\n");
1611 : : rc = -EINVAL;
1612 : 0 : goto error;
1613 : : }
1614 : :
1615 [ # # ]: 0 : if (bp->max_req_len > resp->max_req_win_len) {
1616 : 0 : PMD_DRV_LOG(ERR, "Unsupported request length\n");
1617 : : rc = -EINVAL;
1618 : 0 : goto error;
1619 : : }
1620 : :
1621 : 0 : bp->chip_num = rte_le_to_cpu_16(resp->chip_num);
1622 : :
1623 : 0 : bp->max_req_len = rte_le_to_cpu_16(resp->max_req_win_len);
1624 : 0 : bp->hwrm_max_ext_req_len = rte_le_to_cpu_16(resp->max_ext_req_len);
1625 [ # # ]: 0 : if (bp->hwrm_max_ext_req_len < HWRM_MAX_REQ_LEN)
1626 : 0 : bp->hwrm_max_ext_req_len = HWRM_MAX_REQ_LEN;
1627 : :
1628 : 0 : max_resp_len = rte_le_to_cpu_16(resp->max_resp_len);
1629 : 0 : dev_caps_cfg = rte_le_to_cpu_32(resp->dev_caps_cfg);
1630 : :
1631 [ # # ]: 0 : RTE_VERIFY(max_resp_len <= bp->max_resp_len);
1632 : 0 : bp->max_resp_len = max_resp_len;
1633 : :
1634 : 0 : if ((dev_caps_cfg &
1635 [ # # ]: 0 : HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_SUPPORTED) &&
1636 : : (dev_caps_cfg &
1637 : : HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_REQUIRED)) {
1638 : 0 : PMD_DRV_LOG(DEBUG, "Short command supported\n");
1639 : 0 : bp->flags |= BNXT_FLAG_SHORT_CMD;
1640 : : }
1641 : :
1642 [ # # ]: 0 : if (((dev_caps_cfg &
1643 : : HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_SUPPORTED) &&
1644 : : (dev_caps_cfg &
1645 : 0 : HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_REQUIRED)) ||
1646 [ # # ]: 0 : bp->hwrm_max_ext_req_len > HWRM_MAX_REQ_LEN) {
1647 : 0 : sprintf(type, "bnxt_hwrm_short_" PCI_PRI_FMT,
1648 : 0 : bp->pdev->addr.domain, bp->pdev->addr.bus,
1649 : 0 : bp->pdev->addr.devid, bp->pdev->addr.function);
1650 : :
1651 : 0 : rte_free(bp->hwrm_short_cmd_req_addr);
1652 : :
1653 : 0 : bp->hwrm_short_cmd_req_addr =
1654 : 0 : rte_malloc(type, bp->hwrm_max_ext_req_len, 0);
1655 [ # # ]: 0 : if (bp->hwrm_short_cmd_req_addr == NULL) {
1656 : : rc = -ENOMEM;
1657 : 0 : goto error;
1658 : : }
1659 : 0 : bp->hwrm_short_cmd_req_dma_addr =
1660 : 0 : rte_malloc_virt2iova(bp->hwrm_short_cmd_req_addr);
1661 [ # # ]: 0 : if (bp->hwrm_short_cmd_req_dma_addr == RTE_BAD_IOVA) {
1662 : 0 : rte_free(bp->hwrm_short_cmd_req_addr);
1663 : 0 : PMD_DRV_LOG(ERR,
1664 : : "Unable to map buffer to physical memory.\n");
1665 : : rc = -ENOMEM;
1666 : 0 : goto error;
1667 : : }
1668 : : }
1669 [ # # ]: 0 : if (dev_caps_cfg &
1670 : : HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_KONG_MB_CHNL_SUPPORTED) {
1671 : 0 : bp->flags |= BNXT_FLAG_KONG_MB_EN;
1672 : 0 : PMD_DRV_LOG(DEBUG, "Kong mailbox channel enabled\n");
1673 : : }
1674 [ # # ]: 0 : if (dev_caps_cfg &
1675 : : HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_TRUSTED_VF_SUPPORTED)
1676 : 0 : PMD_DRV_LOG(DEBUG, "FW supports Trusted VFs\n");
1677 [ # # ]: 0 : if (dev_caps_cfg &
1678 : : HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_CFA_ADV_FLOW_MGNT_SUPPORTED) {
1679 : 0 : bp->fw_cap |= BNXT_FW_CAP_ADV_FLOW_MGMT;
1680 : 0 : PMD_DRV_LOG(DEBUG, "FW supports advanced flow management\n");
1681 : : }
1682 : :
1683 [ # # ]: 0 : if (dev_caps_cfg &
1684 : : HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_ADV_FLOW_COUNTERS_SUPPORTED) {
1685 : 0 : PMD_DRV_LOG(DEBUG, "FW supports advanced flow counters\n");
1686 : 0 : bp->fw_cap |= BNXT_FW_CAP_ADV_FLOW_COUNTERS;
1687 : : }
1688 : :
1689 [ # # ]: 0 : if (dev_caps_cfg &
1690 : : HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_CFA_TRUFLOW_SUPPORTED) {
1691 : 0 : PMD_DRV_LOG(DEBUG, "Host-based truflow feature enabled.\n");
1692 : 0 : bp->fw_cap |= BNXT_FW_CAP_TRUFLOW_EN;
1693 : : }
1694 : :
1695 : 0 : error:
1696 : : HWRM_UNLOCK();
1697 : 0 : return rc;
1698 : : }
1699 : :
1700 : 0 : int bnxt_hwrm_func_driver_unregister(struct bnxt *bp)
1701 : : {
1702 : : int rc;
1703 : 0 : struct hwrm_func_drv_unrgtr_input req = {.req_type = 0 };
1704 : 0 : struct hwrm_func_drv_unrgtr_output *resp = bp->hwrm_cmd_resp_addr;
1705 : :
1706 [ # # ]: 0 : if (!(bp->flags & BNXT_FLAG_REGISTERED))
1707 : : return 0;
1708 : :
1709 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_DRV_UNRGTR, BNXT_USE_CHIMP_MB);
1710 : :
1711 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1712 : :
1713 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1714 : : HWRM_UNLOCK();
1715 : :
1716 : 0 : PMD_DRV_LOG(DEBUG, "Port %u: Unregistered with fw\n",
1717 : : bp->eth_dev->data->port_id);
1718 : :
1719 : 0 : return rc;
1720 : : }
1721 : :
1722 : 0 : static int bnxt_hwrm_port_phy_cfg(struct bnxt *bp, struct bnxt_link_info *conf)
1723 : : {
1724 : : int rc = 0;
1725 : 0 : struct hwrm_port_phy_cfg_input req = {0};
1726 : 0 : struct hwrm_port_phy_cfg_output *resp = bp->hwrm_cmd_resp_addr;
1727 : : uint32_t enables = 0;
1728 : :
1729 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_PHY_CFG, BNXT_USE_CHIMP_MB);
1730 : :
1731 [ # # ]: 0 : if (conf->link_up) {
1732 : : /* Setting Fixed Speed. But AutoNeg is ON, So disable it */
1733 [ # # # # ]: 0 : if (bp->link_info->auto_mode && conf->link_speed) {
1734 : 0 : req.auto_mode = HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_NONE;
1735 : 0 : PMD_DRV_LOG(DEBUG, "Disabling AutoNeg\n");
1736 : : }
1737 : :
1738 : 0 : req.flags = rte_cpu_to_le_32(conf->phy_flags);
1739 : : /*
1740 : : * Note, ChiMP FW 20.2.1 and 20.2.2 return an error when we set
1741 : : * any auto mode, even "none".
1742 : : */
1743 [ # # ]: 0 : if (!conf->link_speed) {
1744 : : /* No speeds specified. Enable AutoNeg - all speeds */
1745 : : enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_MODE;
1746 : 0 : req.auto_mode =
1747 : : HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_ALL_SPEEDS;
1748 : : } else {
1749 [ # # ]: 0 : if (bp->link_info->link_signal_mode) {
1750 : : enables |=
1751 : : HWRM_PORT_PHY_CFG_IN_EN_FORCE_PAM4_LINK_SPEED;
1752 : 0 : req.force_pam4_link_speed =
1753 : : rte_cpu_to_le_16(conf->link_speed);
1754 : : } else {
1755 : 0 : req.force_link_speed =
1756 : : rte_cpu_to_le_16(conf->link_speed);
1757 : : }
1758 : : }
1759 : : /* AutoNeg - Advertise speeds specified. */
1760 [ # # # # ]: 0 : if ((conf->auto_link_speed_mask || conf->auto_pam4_link_speed_mask) &&
1761 [ # # ]: 0 : !(conf->phy_flags & HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE)) {
1762 : 0 : req.auto_mode =
1763 : : HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_SPEED_MASK;
1764 [ # # ]: 0 : if (conf->auto_pam4_link_speed_mask) {
1765 : 0 : enables |=
1766 : : HWRM_PORT_PHY_CFG_IN_EN_AUTO_PAM4_LINK_SPD_MASK;
1767 : 0 : req.auto_link_pam4_speed_mask =
1768 : : rte_cpu_to_le_16(conf->auto_pam4_link_speed_mask);
1769 : : }
1770 [ # # ]: 0 : if (conf->auto_link_speed_mask) {
1771 : 0 : enables |=
1772 : : HWRM_PORT_PHY_CFG_IN_EN_AUTO_LINK_SPEED_MASK;
1773 : 0 : req.auto_link_speed_mask =
1774 : : rte_cpu_to_le_16(conf->auto_link_speed_mask);
1775 : : }
1776 : : }
1777 [ # # ]: 0 : if (conf->auto_link_speed &&
1778 [ # # ]: 0 : !(conf->phy_flags & HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE))
1779 : 0 : enables |=
1780 : : HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_LINK_SPEED;
1781 : :
1782 : 0 : req.auto_duplex = conf->duplex;
1783 : : enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_DUPLEX;
1784 : 0 : req.auto_pause = conf->auto_pause;
1785 : 0 : req.force_pause = conf->force_pause;
1786 : : /* Set force_pause if there is no auto or if there is a force */
1787 [ # # # # ]: 0 : if (req.auto_pause && !req.force_pause)
1788 : 0 : enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_PAUSE;
1789 : : else
1790 : 0 : enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_FORCE_PAUSE;
1791 : :
1792 : 0 : req.enables = rte_cpu_to_le_32(enables);
1793 : : } else {
1794 : 0 : req.flags =
1795 : : rte_cpu_to_le_32(HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE_LINK_DWN);
1796 : 0 : PMD_DRV_LOG(INFO, "Force Link Down\n");
1797 : : }
1798 : :
1799 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1800 : :
1801 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1802 : : HWRM_UNLOCK();
1803 : :
1804 : 0 : return rc;
1805 : : }
1806 : :
1807 : 0 : static int bnxt_hwrm_port_phy_qcfg(struct bnxt *bp,
1808 : : struct bnxt_link_info *link_info)
1809 : : {
1810 : : int rc = 0;
1811 : 0 : struct hwrm_port_phy_qcfg_input req = {0};
1812 : 0 : struct hwrm_port_phy_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
1813 : :
1814 [ # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_PHY_QCFG, BNXT_USE_CHIMP_MB);
1815 : :
1816 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1817 : :
1818 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1819 : :
1820 : 0 : link_info->phy_link_status = resp->link;
1821 : 0 : link_info->link_up =
1822 : : (link_info->phy_link_status ==
1823 : 0 : HWRM_PORT_PHY_QCFG_OUTPUT_LINK_LINK) ? 1 : 0;
1824 : 0 : link_info->link_speed = rte_le_to_cpu_16(resp->link_speed);
1825 : 0 : link_info->duplex = resp->duplex_cfg;
1826 : 0 : link_info->pause = resp->pause;
1827 : 0 : link_info->auto_pause = resp->auto_pause;
1828 : 0 : link_info->force_pause = resp->force_pause;
1829 : 0 : link_info->auto_mode = resp->auto_mode;
1830 : 0 : link_info->phy_type = resp->phy_type;
1831 : 0 : link_info->media_type = resp->media_type;
1832 : :
1833 : 0 : link_info->support_speeds = rte_le_to_cpu_16(resp->support_speeds);
1834 : 0 : link_info->auto_link_speed = rte_le_to_cpu_16(resp->auto_link_speed);
1835 : 0 : link_info->auto_link_speed_mask = rte_le_to_cpu_16(resp->auto_link_speed_mask);
1836 : 0 : link_info->preemphasis = rte_le_to_cpu_32(resp->preemphasis);
1837 : 0 : link_info->force_link_speed = rte_le_to_cpu_16(resp->force_link_speed);
1838 : 0 : link_info->phy_ver[0] = resp->phy_maj;
1839 : 0 : link_info->phy_ver[1] = resp->phy_min;
1840 : 0 : link_info->phy_ver[2] = resp->phy_bld;
1841 : 0 : link_info->link_signal_mode =
1842 : 0 : resp->active_fec_signal_mode & HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_MASK;
1843 : 0 : link_info->option_flags = resp->option_flags;
1844 : 0 : link_info->force_pam4_link_speed =
1845 : 0 : rte_le_to_cpu_16(resp->force_pam4_link_speed);
1846 : 0 : link_info->support_pam4_speeds =
1847 : 0 : rte_le_to_cpu_16(resp->support_pam4_speeds);
1848 : 0 : link_info->auto_pam4_link_speed_mask =
1849 : 0 : rte_le_to_cpu_16(resp->auto_pam4_link_speed_mask);
1850 : : /* P7 uses speeds2 fields */
1851 [ # # # # : 0 : if (BNXT_LINK_SPEEDS_V2(bp) && BNXT_LINK_SPEEDS_V2_OPTIONS(link_info->option_flags)) {
# # # # #
# ]
1852 : 0 : link_info->support_speeds2 = rte_le_to_cpu_16(resp->support_speeds2);
1853 : 0 : link_info->force_link_speeds2 = rte_le_to_cpu_16(resp->force_link_speeds2);
1854 : 0 : link_info->auto_link_speeds2 = rte_le_to_cpu_16(resp->auto_link_speeds2);
1855 : 0 : link_info->active_lanes = resp->active_lanes;
1856 [ # # ]: 0 : if (!link_info->auto_mode)
1857 : 0 : link_info->link_speed = link_info->force_link_speeds2;
1858 : : }
1859 : 0 : link_info->module_status = resp->module_status;
1860 : : HWRM_UNLOCK();
1861 : :
1862 : : /* Display the captured P7 phy details */
1863 [ # # # # : 0 : if (BNXT_LINK_SPEEDS_V2(bp)) {
# # # # ]
1864 : 0 : PMD_DRV_LOG(DEBUG, "Phytype:%d, Media_type:%d, Status: %d, Link Signal:%d\n"
1865 : : "Active Fec: %d Support_speeds2:%x, Force_link_speedsv2:%x\n"
1866 : : "Auto_link_speedsv2:%x, Active_lanes:%d\n",
1867 : : link_info->phy_type,
1868 : : link_info->media_type,
1869 : : link_info->phy_link_status,
1870 : : link_info->link_signal_mode,
1871 : : (resp->active_fec_signal_mode &
1872 : : HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_MASK) >> 4,
1873 : : link_info->support_speeds2, link_info->force_link_speeds2,
1874 : : link_info->auto_link_speeds2,
1875 : : link_info->active_lanes);
1876 : :
1877 : : const char *desc;
1878 : :
1879 [ # # ]: 0 : if (link_info->auto_mode)
1880 : 0 : desc = ((struct link_speeds_tbl *)
1881 : 0 : bnxt_get_hwrm_to_rte_speeds_entry(link_info->link_speed))->desc;
1882 : : else
1883 : 0 : desc = ((struct link_speeds2_tbl *)
1884 : 0 : bnxt_get_hwrm_to_rte_speeds2_entry(link_info->link_speed))->desc;
1885 : :
1886 [ # # # # : 0 : PMD_DRV_LOG(INFO, "Link Speed: %s %s, Status: %s Signal-mode: %s\n"
# # # # #
# ]
1887 : : "Media type: %s, Xcvr type: %s, Active FEC: %s Lanes: %d\n",
1888 : : desc,
1889 : : !(link_info->auto_mode) ? "Forced" : "AutoNegotiated",
1890 : : link_status_str[link_info->phy_link_status % MAX_LINK_STR],
1891 : : signal_mode[link_info->link_signal_mode % MAX_SIG_MODE],
1892 : : media_type[link_info->media_type % MAX_MEDIA_TYPE],
1893 : : bnxt_get_xcvr_type(rte_le_to_cpu_32
1894 : : (resp->xcvr_identifier_type_tx_lpi_timer)),
1895 : : fec_mode[((resp->active_fec_signal_mode &
1896 : : HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_MASK) >> 4) %
1897 : : MAX_FEC_MODE], link_info->active_lanes);
1898 : 0 : return rc;
1899 : : }
1900 : :
1901 : 0 : PMD_DRV_LOG(DEBUG, "Link Speed:%d,Auto:%d:%x:%x,Support:%x,Force:%x\n",
1902 : : link_info->link_speed, link_info->auto_mode,
1903 : : link_info->auto_link_speed, link_info->auto_link_speed_mask,
1904 : : link_info->support_speeds, link_info->force_link_speed);
1905 : 0 : PMD_DRV_LOG(DEBUG, "Link Signal:%d,PAM::Auto:%x,Support:%x,Force:%x\n",
1906 : : link_info->link_signal_mode,
1907 : : link_info->auto_pam4_link_speed_mask,
1908 : : link_info->support_pam4_speeds,
1909 : : link_info->force_pam4_link_speed);
1910 : 0 : return rc;
1911 : : }
1912 : :
1913 : 0 : int bnxt_hwrm_port_phy_qcaps(struct bnxt *bp)
1914 : : {
1915 : : int rc = 0;
1916 : 0 : struct hwrm_port_phy_qcaps_input req = {0};
1917 : 0 : struct hwrm_port_phy_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
1918 : 0 : struct bnxt_link_info *link_info = bp->link_info;
1919 : :
1920 [ # # ]: 0 : if (BNXT_VF(bp) && !BNXT_VF_IS_TRUSTED(bp))
1921 : : return 0;
1922 : :
1923 [ # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_PHY_QCAPS, BNXT_USE_CHIMP_MB);
1924 : :
1925 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1926 : :
1927 [ # # # # ]: 0 : HWRM_CHECK_RESULT_SILENT();
1928 : :
1929 : 0 : bp->port_cnt = resp->port_cnt;
1930 [ # # ]: 0 : if (resp->supported_speeds_auto_mode)
1931 : 0 : link_info->support_auto_speeds =
1932 : : rte_le_to_cpu_16(resp->supported_speeds_auto_mode);
1933 [ # # ]: 0 : if (resp->supported_pam4_speeds_auto_mode)
1934 : 0 : link_info->support_pam4_auto_speeds =
1935 : : rte_le_to_cpu_16(resp->supported_pam4_speeds_auto_mode);
1936 : : /* P7 chips now report all speeds here */
1937 [ # # ]: 0 : if (resp->flags2 & HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS2_SPEEDS2_SUPPORTED)
1938 : 0 : link_info->support_speeds_v2 = true;
1939 [ # # ]: 0 : if (link_info->support_speeds_v2) {
1940 : 0 : link_info->supported_speeds2_force_mode =
1941 : 0 : rte_le_to_cpu_16(resp->supported_speeds2_force_mode);
1942 : 0 : link_info->supported_speeds2_auto_mode =
1943 : 0 : rte_le_to_cpu_16(resp->supported_speeds2_auto_mode);
1944 : : }
1945 : :
1946 : : HWRM_UNLOCK();
1947 : :
1948 : : /* Older firmware does not have supported_auto_speeds, so assume
1949 : : * that all supported speeds can be autonegotiated.
1950 : : */
1951 [ # # # # ]: 0 : if (link_info->auto_link_speed_mask && !link_info->support_auto_speeds)
1952 : 0 : link_info->support_auto_speeds = link_info->support_speeds;
1953 : :
1954 : : return 0;
1955 : : }
1956 : :
1957 : : static bool _bnxt_find_lossy_profile(struct bnxt *bp)
1958 : : {
1959 : : int i = 0;
1960 : :
1961 [ # # ]: 0 : for (i = BNXT_COS_QUEUE_COUNT - 1; i >= 0; i--) {
1962 [ # # ]: 0 : if (bp->tx_cos_queue[i].profile ==
1963 : : HWRM_QUEUE_SERVICE_PROFILE_LOSSY) {
1964 : 0 : bp->tx_cosq_id[0] = bp->tx_cos_queue[i].id;
1965 : 0 : return true;
1966 : : }
1967 : : }
1968 : : return false;
1969 : : }
1970 : :
1971 : 0 : static bool _bnxt_find_lossy_nic_profile(struct bnxt *bp)
1972 : : {
1973 : : int i = 0, j = 0;
1974 : :
1975 [ # # ]: 0 : for (i = 0; i < BNXT_COS_QUEUE_COUNT; i++) {
1976 [ # # ]: 0 : for (j = 0; j < BNXT_COS_QUEUE_COUNT; j++) {
1977 [ # # ]: 0 : if (bp->tx_cos_queue[i].profile ==
1978 : 0 : HWRM_QUEUE_SERVICE_PROFILE_LOSSY &&
1979 [ # # ]: 0 : bp->tx_cos_queue[j].profile_type ==
1980 : : HWRM_QUEUE_SERVICE_PROFILE_TYPE_NIC) {
1981 : 0 : bp->tx_cosq_id[0] = bp->tx_cos_queue[i].id;
1982 : 0 : return true;
1983 : : }
1984 : : }
1985 : : }
1986 : : return false;
1987 : : }
1988 : :
1989 : 0 : static bool bnxt_find_lossy_profile(struct bnxt *bp, bool use_prof_type)
1990 : : {
1991 : : int i;
1992 : :
1993 [ # # ]: 0 : for (i = 0; i < BNXT_COS_QUEUE_COUNT; i++) {
1994 : 0 : PMD_DRV_LOG(DEBUG, "profile %d, profile_id %d, type %d\n",
1995 : : bp->tx_cos_queue[i].profile,
1996 : : bp->tx_cos_queue[i].id,
1997 : : bp->tx_cos_queue[i].profile_type);
1998 : : }
1999 : :
2000 [ # # ]: 0 : if (use_prof_type)
2001 : 0 : return _bnxt_find_lossy_nic_profile(bp);
2002 : : else
2003 : 0 : return _bnxt_find_lossy_profile(bp);
2004 : : }
2005 : :
2006 : : static void bnxt_find_first_valid_profile(struct bnxt *bp)
2007 : : {
2008 : : int i = 0;
2009 : :
2010 [ # # ]: 0 : for (i = BNXT_COS_QUEUE_COUNT - 1; i >= 0; i--) {
2011 [ # # ]: 0 : if (bp->tx_cos_queue[i].profile !=
2012 : 0 : HWRM_QUEUE_SERVICE_PROFILE_UNKNOWN &&
2013 [ # # ]: 0 : bp->tx_cos_queue[i].id !=
2014 : : HWRM_QUEUE_SERVICE_PROFILE_UNKNOWN) {
2015 : 0 : bp->tx_cosq_id[0] = bp->tx_cos_queue[i].id;
2016 : 0 : break;
2017 : : }
2018 : : }
2019 : : }
2020 : :
2021 : 0 : int bnxt_hwrm_queue_qportcfg(struct bnxt *bp)
2022 : : {
2023 : : int rc = 0;
2024 : 0 : struct hwrm_queue_qportcfg_input req = {.req_type = 0 };
2025 : 0 : struct hwrm_queue_qportcfg_output *resp = bp->hwrm_cmd_resp_addr;
2026 : : uint32_t dir = HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_TX;
2027 : : bool use_prof_type = false;
2028 : : int i;
2029 : :
2030 : 0 : get_rx_info:
2031 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_QUEUE_QPORTCFG, BNXT_USE_CHIMP_MB);
2032 : :
2033 : 0 : req.flags = rte_cpu_to_le_32(dir);
2034 : : /* HWRM Version >= 1.9.1 only if COS Classification is not required. */
2035 [ # # ]: 0 : if (bp->hwrm_spec_code >= HWRM_VERSION_1_9_1 &&
2036 [ # # ]: 0 : !(bp->vnic_cap_flags & BNXT_VNIC_CAP_COS_CLASSIFY))
2037 : 0 : req.drv_qmap_cap =
2038 : : HWRM_QUEUE_QPORTCFG_INPUT_DRV_QMAP_CAP_ENABLED;
2039 : :
2040 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2041 : :
2042 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2043 : :
2044 [ # # ]: 0 : if (resp->queue_cfg_info &
2045 : : HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_CFG_INFO_USE_PROFILE_TYPE)
2046 : : use_prof_type = true;
2047 : :
2048 [ # # ]: 0 : if (dir == HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_TX) {
2049 : 0 : GET_TX_QUEUE_INFO(0);
2050 : 0 : GET_TX_QUEUE_INFO(1);
2051 : 0 : GET_TX_QUEUE_INFO(2);
2052 : 0 : GET_TX_QUEUE_INFO(3);
2053 : 0 : GET_TX_QUEUE_INFO(4);
2054 : 0 : GET_TX_QUEUE_INFO(5);
2055 : 0 : GET_TX_QUEUE_INFO(6);
2056 : 0 : GET_TX_QUEUE_INFO(7);
2057 [ # # ]: 0 : if (use_prof_type) {
2058 : 0 : GET_TX_QUEUE_TYPE_INFO(0);
2059 : 0 : GET_TX_QUEUE_TYPE_INFO(1);
2060 : 0 : GET_TX_QUEUE_TYPE_INFO(2);
2061 : 0 : GET_TX_QUEUE_TYPE_INFO(3);
2062 : 0 : GET_TX_QUEUE_TYPE_INFO(4);
2063 : 0 : GET_TX_QUEUE_TYPE_INFO(5);
2064 : 0 : GET_TX_QUEUE_TYPE_INFO(6);
2065 : 0 : GET_TX_QUEUE_TYPE_INFO(7);
2066 : : }
2067 : : } else {
2068 : 0 : GET_RX_QUEUE_INFO(0);
2069 : 0 : GET_RX_QUEUE_INFO(1);
2070 : 0 : GET_RX_QUEUE_INFO(2);
2071 : 0 : GET_RX_QUEUE_INFO(3);
2072 : 0 : GET_RX_QUEUE_INFO(4);
2073 : 0 : GET_RX_QUEUE_INFO(5);
2074 : 0 : GET_RX_QUEUE_INFO(6);
2075 : 0 : GET_RX_QUEUE_INFO(7);
2076 : : }
2077 : :
2078 : : HWRM_UNLOCK();
2079 : :
2080 [ # # ]: 0 : if (dir == HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_RX)
2081 : 0 : goto done;
2082 : :
2083 [ # # ]: 0 : if (bp->hwrm_spec_code < HWRM_VERSION_1_9_1) {
2084 : 0 : bp->tx_cosq_id[0] = bp->tx_cos_queue[0].id;
2085 : : } else {
2086 : : int j;
2087 : :
2088 : : /* iterate and find the COSq profile to use for Tx */
2089 [ # # ]: 0 : if (bp->vnic_cap_flags & BNXT_VNIC_CAP_COS_CLASSIFY) {
2090 [ # # ]: 0 : for (j = 0, i = 0; i < BNXT_COS_QUEUE_COUNT; i++) {
2091 [ # # ]: 0 : if (bp->tx_cos_queue[i].id != 0xff)
2092 : 0 : bp->tx_cosq_id[j++] =
2093 : : bp->tx_cos_queue[i].id;
2094 : : }
2095 : : } else {
2096 : : /* When CoS classification is disabled, for normal NIC
2097 : : * operations, ideally we should look to use LOSSY.
2098 : : * If not found, fallback to the first valid profile
2099 : : */
2100 [ # # ]: 0 : if (!bnxt_find_lossy_profile(bp, use_prof_type))
2101 : : bnxt_find_first_valid_profile(bp);
2102 : :
2103 : : }
2104 : : }
2105 : 0 : PMD_DRV_LOG(DEBUG, "Tx COS Queue ID %d\n", bp->tx_cosq_id[0]);
2106 : :
2107 : 0 : bp->max_tc = resp->max_configurable_queues;
2108 : 0 : bp->max_lltc = resp->max_configurable_lossless_queues;
2109 [ # # ]: 0 : if (bp->max_tc > BNXT_MAX_QUEUE)
2110 : 0 : bp->max_tc = BNXT_MAX_QUEUE;
2111 : 0 : bp->max_q = bp->max_tc;
2112 : :
2113 : : if (dir == HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_TX) {
2114 : : dir = HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_RX;
2115 : 0 : goto get_rx_info;
2116 : : }
2117 : :
2118 : : done:
2119 : 0 : return rc;
2120 : : }
2121 : :
2122 : 0 : int bnxt_hwrm_ring_alloc(struct bnxt *bp,
2123 : : struct bnxt_ring *ring,
2124 : : uint32_t ring_type, uint32_t map_index,
2125 : : uint32_t stats_ctx_id, uint32_t cmpl_ring_id,
2126 : : uint16_t tx_cosq_id)
2127 : : {
2128 : : int rc = 0;
2129 : : uint32_t enables = 0;
2130 : 0 : struct hwrm_ring_alloc_input req = {.req_type = 0 };
2131 : 0 : struct hwrm_ring_alloc_output *resp = bp->hwrm_cmd_resp_addr;
2132 : : struct rte_mempool *mb_pool;
2133 : : uint16_t rx_buf_size;
2134 : :
2135 [ # # # # : 0 : HWRM_PREP(&req, HWRM_RING_ALLOC, BNXT_USE_CHIMP_MB);
# # # # ]
2136 : :
2137 : 0 : req.page_tbl_addr = rte_cpu_to_le_64(ring->bd_dma);
2138 : 0 : req.fbo = rte_cpu_to_le_32(0);
2139 : : /* Association of ring index with doorbell index */
2140 : 0 : req.logical_id = rte_cpu_to_le_16(map_index);
2141 : 0 : req.length = rte_cpu_to_le_32(ring->ring_size);
2142 : :
2143 [ # # # # : 0 : switch (ring_type) {
# # ]
2144 : 0 : case HWRM_RING_ALLOC_INPUT_RING_TYPE_TX:
2145 : 0 : req.ring_type = ring_type;
2146 : 0 : req.cmpl_ring_id = rte_cpu_to_le_16(cmpl_ring_id);
2147 : 0 : req.stat_ctx_id = rte_cpu_to_le_32(stats_ctx_id);
2148 : 0 : req.queue_id = rte_cpu_to_le_16(tx_cosq_id);
2149 [ # # ]: 0 : if (stats_ctx_id != INVALID_STATS_CTX_ID)
2150 : : enables |=
2151 : : HWRM_RING_ALLOC_INPUT_ENABLES_STAT_CTX_ID_VALID;
2152 : : break;
2153 : 0 : case HWRM_RING_ALLOC_INPUT_RING_TYPE_RX:
2154 : 0 : req.ring_type = ring_type;
2155 : 0 : req.cmpl_ring_id = rte_cpu_to_le_16(cmpl_ring_id);
2156 : 0 : req.stat_ctx_id = rte_cpu_to_le_32(stats_ctx_id);
2157 [ # # ]: 0 : if (BNXT_CHIP_P5_P7(bp)) {
2158 [ # # ]: 0 : mb_pool = bp->rx_queues[0]->mb_pool;
2159 : 0 : rx_buf_size = rte_pktmbuf_data_room_size(mb_pool) -
2160 : : RTE_PKTMBUF_HEADROOM;
2161 : 0 : rx_buf_size = RTE_MIN(BNXT_MAX_PKT_LEN, rx_buf_size);
2162 : 0 : req.rx_buf_size = rte_cpu_to_le_16(rx_buf_size);
2163 : : enables |=
2164 : : HWRM_RING_ALLOC_INPUT_ENABLES_RX_BUF_SIZE_VALID;
2165 : : }
2166 [ # # ]: 0 : if (stats_ctx_id != INVALID_STATS_CTX_ID)
2167 : 0 : enables |=
2168 : : HWRM_RING_ALLOC_INPUT_ENABLES_STAT_CTX_ID_VALID;
2169 : : break;
2170 : 0 : case HWRM_RING_ALLOC_INPUT_RING_TYPE_L2_CMPL:
2171 : 0 : req.ring_type = ring_type;
2172 [ # # ]: 0 : if (BNXT_HAS_NQ(bp)) {
2173 : : /* Association of cp ring with nq */
2174 : 0 : req.nq_ring_id = rte_cpu_to_le_16(cmpl_ring_id);
2175 : : enables |=
2176 : : HWRM_RING_ALLOC_INPUT_ENABLES_NQ_RING_ID_VALID;
2177 : : }
2178 : 0 : req.int_mode = HWRM_RING_ALLOC_INPUT_INT_MODE_MSIX;
2179 : 0 : break;
2180 : 0 : case HWRM_RING_ALLOC_INPUT_RING_TYPE_NQ:
2181 : 0 : req.ring_type = ring_type;
2182 : 0 : req.page_size = BNXT_PAGE_SHFT;
2183 : 0 : req.int_mode = HWRM_RING_ALLOC_INPUT_INT_MODE_MSIX;
2184 : 0 : break;
2185 : 0 : case HWRM_RING_ALLOC_INPUT_RING_TYPE_RX_AGG:
2186 : 0 : req.ring_type = ring_type;
2187 : 0 : req.rx_ring_id = rte_cpu_to_le_16(ring->fw_rx_ring_id);
2188 : :
2189 [ # # ]: 0 : mb_pool = bp->rx_queues[0]->mb_pool;
2190 : 0 : rx_buf_size = rte_pktmbuf_data_room_size(mb_pool) -
2191 : : RTE_PKTMBUF_HEADROOM;
2192 : 0 : rx_buf_size = RTE_MIN(BNXT_MAX_PKT_LEN, rx_buf_size);
2193 : 0 : req.rx_buf_size = rte_cpu_to_le_16(rx_buf_size);
2194 : :
2195 : 0 : req.stat_ctx_id = rte_cpu_to_le_32(stats_ctx_id);
2196 : : enables |= HWRM_RING_ALLOC_INPUT_ENABLES_RX_RING_ID_VALID |
2197 : : HWRM_RING_ALLOC_INPUT_ENABLES_RX_BUF_SIZE_VALID |
2198 : : HWRM_RING_ALLOC_INPUT_ENABLES_STAT_CTX_ID_VALID;
2199 : 0 : break;
2200 : 0 : default:
2201 : 0 : PMD_DRV_LOG(ERR, "hwrm alloc invalid ring type %d\n",
2202 : : ring_type);
2203 : : HWRM_UNLOCK();
2204 : 0 : return -EINVAL;
2205 : : }
2206 : 0 : req.enables = rte_cpu_to_le_32(enables);
2207 : :
2208 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2209 : :
2210 [ # # # # ]: 0 : if (rc || resp->error_code) {
2211 [ # # # # ]: 0 : if (rc == 0 && resp->error_code)
2212 : 0 : rc = rte_le_to_cpu_16(resp->error_code);
2213 [ # # # # : 0 : switch (ring_type) {
# # ]
2214 : 0 : case HWRM_RING_ALLOC_INPUT_RING_TYPE_L2_CMPL:
2215 : 0 : PMD_DRV_LOG(ERR,
2216 : : "hwrm_ring_alloc cp failed. rc:%d\n", rc);
2217 : : HWRM_UNLOCK();
2218 : 0 : return rc;
2219 : 0 : case HWRM_RING_ALLOC_INPUT_RING_TYPE_RX:
2220 : 0 : PMD_DRV_LOG(ERR,
2221 : : "hwrm_ring_alloc rx failed. rc:%d\n", rc);
2222 : : HWRM_UNLOCK();
2223 : 0 : return rc;
2224 : 0 : case HWRM_RING_ALLOC_INPUT_RING_TYPE_RX_AGG:
2225 : 0 : PMD_DRV_LOG(ERR,
2226 : : "hwrm_ring_alloc rx agg failed. rc:%d\n",
2227 : : rc);
2228 : : HWRM_UNLOCK();
2229 : 0 : return rc;
2230 : 0 : case HWRM_RING_ALLOC_INPUT_RING_TYPE_TX:
2231 : 0 : PMD_DRV_LOG(ERR,
2232 : : "hwrm_ring_alloc tx failed. rc:%d\n", rc);
2233 : : HWRM_UNLOCK();
2234 : 0 : return rc;
2235 : 0 : case HWRM_RING_ALLOC_INPUT_RING_TYPE_NQ:
2236 : 0 : PMD_DRV_LOG(ERR,
2237 : : "hwrm_ring_alloc nq failed. rc:%d\n", rc);
2238 : : HWRM_UNLOCK();
2239 : 0 : return rc;
2240 : 0 : default:
2241 : 0 : PMD_DRV_LOG(ERR, "Invalid ring. rc:%d\n", rc);
2242 : : HWRM_UNLOCK();
2243 : 0 : return rc;
2244 : : }
2245 : : }
2246 : :
2247 : 0 : ring->fw_ring_id = rte_le_to_cpu_16(resp->ring_id);
2248 : : HWRM_UNLOCK();
2249 : 0 : return rc;
2250 : : }
2251 : :
2252 : 0 : int bnxt_hwrm_ring_free(struct bnxt *bp,
2253 : : struct bnxt_ring *ring, uint32_t ring_type,
2254 : : uint16_t cp_ring_id)
2255 : : {
2256 : : int rc;
2257 : 0 : struct hwrm_ring_free_input req = {.req_type = 0 };
2258 : 0 : struct hwrm_ring_free_output *resp = bp->hwrm_cmd_resp_addr;
2259 : :
2260 [ # # ]: 0 : if (ring->fw_ring_id == INVALID_HW_RING_ID)
2261 : : return -EINVAL;
2262 : :
2263 [ # # ]: 0 : HWRM_PREP(&req, HWRM_RING_FREE, BNXT_USE_CHIMP_MB);
2264 : :
2265 : 0 : req.ring_type = ring_type;
2266 : 0 : req.ring_id = rte_cpu_to_le_16(ring->fw_ring_id);
2267 : 0 : req.cmpl_ring = rte_cpu_to_le_16(cp_ring_id);
2268 : :
2269 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2270 : 0 : ring->fw_ring_id = INVALID_HW_RING_ID;
2271 : :
2272 [ # # # # ]: 0 : if (rc || resp->error_code) {
2273 [ # # # # ]: 0 : if (rc == 0 && resp->error_code)
2274 : 0 : rc = rte_le_to_cpu_16(resp->error_code);
2275 : : HWRM_UNLOCK();
2276 : :
2277 [ # # # # : 0 : switch (ring_type) {
# # ]
2278 : 0 : case HWRM_RING_FREE_INPUT_RING_TYPE_L2_CMPL:
2279 : 0 : PMD_DRV_LOG(ERR, "hwrm_ring_free cp failed. rc:%d\n",
2280 : : rc);
2281 : 0 : return rc;
2282 : 0 : case HWRM_RING_FREE_INPUT_RING_TYPE_RX:
2283 : 0 : PMD_DRV_LOG(ERR, "hwrm_ring_free rx failed. rc:%d\n",
2284 : : rc);
2285 : 0 : return rc;
2286 : 0 : case HWRM_RING_FREE_INPUT_RING_TYPE_TX:
2287 : 0 : PMD_DRV_LOG(ERR, "hwrm_ring_free tx failed. rc:%d\n",
2288 : : rc);
2289 : 0 : return rc;
2290 : 0 : case HWRM_RING_FREE_INPUT_RING_TYPE_NQ:
2291 : 0 : PMD_DRV_LOG(ERR,
2292 : : "hwrm_ring_free nq failed. rc:%d\n", rc);
2293 : 0 : return rc;
2294 : 0 : case HWRM_RING_FREE_INPUT_RING_TYPE_RX_AGG:
2295 : 0 : PMD_DRV_LOG(ERR,
2296 : : "hwrm_ring_free agg failed. rc:%d\n", rc);
2297 : 0 : return rc;
2298 : 0 : default:
2299 : 0 : PMD_DRV_LOG(ERR, "Invalid ring, rc:%d\n", rc);
2300 : 0 : return rc;
2301 : : }
2302 : : }
2303 : : HWRM_UNLOCK();
2304 : 0 : return 0;
2305 : : }
2306 : :
2307 : 0 : int bnxt_hwrm_ring_grp_alloc(struct bnxt *bp, unsigned int idx)
2308 : : {
2309 : : int rc = 0;
2310 : 0 : struct hwrm_ring_grp_alloc_input req = {.req_type = 0 };
2311 : 0 : struct hwrm_ring_grp_alloc_output *resp = bp->hwrm_cmd_resp_addr;
2312 : :
2313 : : /* Don't attempt to re-create the ring group if it is already created */
2314 [ # # ]: 0 : if (bp->grp_info[idx].fw_grp_id != INVALID_HW_RING_ID)
2315 : : return 0;
2316 : :
2317 [ # # ]: 0 : HWRM_PREP(&req, HWRM_RING_GRP_ALLOC, BNXT_USE_CHIMP_MB);
2318 : :
2319 : 0 : req.cr = rte_cpu_to_le_16(bp->grp_info[idx].cp_fw_ring_id);
2320 : 0 : req.rr = rte_cpu_to_le_16(bp->grp_info[idx].rx_fw_ring_id);
2321 : 0 : req.ar = rte_cpu_to_le_16(bp->grp_info[idx].ag_fw_ring_id);
2322 : 0 : req.sc = rte_cpu_to_le_16(bp->grp_info[idx].fw_stats_ctx);
2323 : :
2324 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2325 : :
2326 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2327 : :
2328 : 0 : bp->grp_info[idx].fw_grp_id = rte_le_to_cpu_16(resp->ring_group_id);
2329 : :
2330 : : HWRM_UNLOCK();
2331 : :
2332 : 0 : return rc;
2333 : : }
2334 : :
2335 : 0 : int bnxt_hwrm_ring_grp_free(struct bnxt *bp, unsigned int idx)
2336 : : {
2337 : : int rc;
2338 : 0 : struct hwrm_ring_grp_free_input req = {.req_type = 0 };
2339 : 0 : struct hwrm_ring_grp_free_output *resp = bp->hwrm_cmd_resp_addr;
2340 : :
2341 [ # # ]: 0 : if (bp->grp_info[idx].fw_grp_id == INVALID_HW_RING_ID)
2342 : : return 0;
2343 : :
2344 [ # # ]: 0 : HWRM_PREP(&req, HWRM_RING_GRP_FREE, BNXT_USE_CHIMP_MB);
2345 : :
2346 : 0 : req.ring_group_id = rte_cpu_to_le_16(bp->grp_info[idx].fw_grp_id);
2347 : :
2348 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2349 : :
2350 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2351 : : HWRM_UNLOCK();
2352 : :
2353 : 0 : bp->grp_info[idx].fw_grp_id = INVALID_HW_RING_ID;
2354 : 0 : return rc;
2355 : : }
2356 : :
2357 : 0 : int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
2358 : : {
2359 : : int rc = 0;
2360 : 0 : struct hwrm_stat_ctx_clr_stats_input req = {.req_type = 0 };
2361 : 0 : struct hwrm_stat_ctx_clr_stats_output *resp = bp->hwrm_cmd_resp_addr;
2362 : :
2363 [ # # ]: 0 : if (cpr->hw_stats_ctx_id == HWRM_NA_SIGNATURE)
2364 : : return rc;
2365 : :
2366 [ # # ]: 0 : HWRM_PREP(&req, HWRM_STAT_CTX_CLR_STATS, BNXT_USE_CHIMP_MB);
2367 : :
2368 : 0 : req.stat_ctx_id = rte_cpu_to_le_32(cpr->hw_stats_ctx_id);
2369 : :
2370 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2371 : :
2372 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2373 : : HWRM_UNLOCK();
2374 : :
2375 : 0 : return rc;
2376 : : }
2377 : :
2378 : 0 : int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
2379 : : {
2380 : : int rc;
2381 : 0 : struct hwrm_stat_ctx_alloc_input req = {.req_type = 0 };
2382 : 0 : struct hwrm_stat_ctx_alloc_output *resp = bp->hwrm_cmd_resp_addr;
2383 : :
2384 [ # # ]: 0 : if (cpr->hw_stats_ctx_id != HWRM_NA_SIGNATURE)
2385 : : return 0;
2386 : :
2387 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_STAT_CTX_ALLOC, BNXT_USE_CHIMP_MB);
2388 : :
2389 [ # # # # ]: 0 : req.stats_dma_length = rte_cpu_to_le_16(BNXT_HWRM_CTX_GET_SIZE(bp));
2390 : :
2391 : 0 : req.update_period_ms = rte_cpu_to_le_32(0);
2392 : :
2393 : 0 : req.stats_dma_addr = rte_cpu_to_le_64(cpr->hw_stats_map);
2394 : :
2395 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2396 : :
2397 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2398 : :
2399 : 0 : cpr->hw_stats_ctx_id = rte_le_to_cpu_32(resp->stat_ctx_id);
2400 : :
2401 : : HWRM_UNLOCK();
2402 : :
2403 : 0 : return rc;
2404 : : }
2405 : :
2406 : 0 : static int bnxt_hwrm_stat_ctx_free(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
2407 : : {
2408 : : int rc;
2409 : 0 : struct hwrm_stat_ctx_free_input req = {.req_type = 0 };
2410 : 0 : struct hwrm_stat_ctx_free_output *resp = bp->hwrm_cmd_resp_addr;
2411 : :
2412 [ # # ]: 0 : if (cpr->hw_stats_ctx_id == HWRM_NA_SIGNATURE)
2413 : : return 0;
2414 : :
2415 [ # # ]: 0 : HWRM_PREP(&req, HWRM_STAT_CTX_FREE, BNXT_USE_CHIMP_MB);
2416 : :
2417 : 0 : req.stat_ctx_id = rte_cpu_to_le_32(cpr->hw_stats_ctx_id);
2418 : :
2419 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2420 : :
2421 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2422 : : HWRM_UNLOCK();
2423 : :
2424 : 0 : cpr->hw_stats_ctx_id = HWRM_NA_SIGNATURE;
2425 : :
2426 : 0 : return rc;
2427 : : }
2428 : :
2429 : 0 : int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic)
2430 : : {
2431 : : int rc = 0;
2432 : 0 : struct hwrm_vnic_alloc_input req = { 0 };
2433 : 0 : struct hwrm_vnic_alloc_output *resp = bp->hwrm_cmd_resp_addr;
2434 : :
2435 : 0 : vnic->mru = BNXT_VNIC_MRU(bp->eth_dev->data->mtu);
2436 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_ALLOC, BNXT_USE_CHIMP_MB);
2437 : :
2438 [ # # ]: 0 : if (vnic->func_default)
2439 : 0 : req.flags =
2440 : : rte_cpu_to_le_32(HWRM_VNIC_ALLOC_INPUT_FLAGS_DEFAULT);
2441 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2442 : :
2443 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2444 : :
2445 : 0 : vnic->fw_vnic_id = rte_le_to_cpu_16(resp->vnic_id);
2446 : : HWRM_UNLOCK();
2447 : 0 : PMD_DRV_LOG(DEBUG, "VNIC ID %x\n", vnic->fw_vnic_id);
2448 : 0 : return rc;
2449 : : }
2450 : :
2451 : 0 : static int bnxt_hwrm_vnic_plcmodes_qcfg(struct bnxt *bp,
2452 : : struct bnxt_vnic_info *vnic,
2453 : : struct bnxt_plcmodes_cfg *pmode)
2454 : : {
2455 : : int rc = 0;
2456 : 0 : struct hwrm_vnic_plcmodes_qcfg_input req = {.req_type = 0 };
2457 : 0 : struct hwrm_vnic_plcmodes_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
2458 : :
2459 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_PLCMODES_QCFG, BNXT_USE_CHIMP_MB);
2460 : :
2461 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
2462 : :
2463 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2464 : :
2465 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2466 : :
2467 : 0 : pmode->flags = rte_le_to_cpu_32(resp->flags);
2468 : : /* dflt_vnic bit doesn't exist in the _cfg command */
2469 : 0 : pmode->flags &= ~(HWRM_VNIC_PLCMODES_QCFG_OUTPUT_FLAGS_DFLT_VNIC);
2470 : 0 : pmode->jumbo_thresh = rte_le_to_cpu_16(resp->jumbo_thresh);
2471 : 0 : pmode->hds_offset = rte_le_to_cpu_16(resp->hds_offset);
2472 : 0 : pmode->hds_threshold = rte_le_to_cpu_16(resp->hds_threshold);
2473 : :
2474 : : HWRM_UNLOCK();
2475 : :
2476 : 0 : return rc;
2477 : : }
2478 : :
2479 : 0 : static int bnxt_hwrm_vnic_plcmodes_cfg(struct bnxt *bp,
2480 : : struct bnxt_vnic_info *vnic,
2481 : : struct bnxt_plcmodes_cfg *pmode)
2482 : : {
2483 : : int rc = 0;
2484 : 0 : struct hwrm_vnic_plcmodes_cfg_input req = {.req_type = 0 };
2485 : 0 : struct hwrm_vnic_plcmodes_cfg_output *resp = bp->hwrm_cmd_resp_addr;
2486 : :
2487 [ # # ]: 0 : if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
2488 : 0 : PMD_DRV_LOG(DEBUG, "VNIC ID %x\n", vnic->fw_vnic_id);
2489 : 0 : return rc;
2490 : : }
2491 : :
2492 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_PLCMODES_CFG, BNXT_USE_CHIMP_MB);
2493 : :
2494 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
2495 : 0 : req.flags = rte_cpu_to_le_32(pmode->flags);
2496 : 0 : req.jumbo_thresh = rte_cpu_to_le_16(pmode->jumbo_thresh);
2497 : 0 : req.hds_offset = rte_cpu_to_le_16(pmode->hds_offset);
2498 : 0 : req.hds_threshold = rte_cpu_to_le_16(pmode->hds_threshold);
2499 : 0 : req.enables = rte_cpu_to_le_32(
2500 : : HWRM_VNIC_PLCMODES_CFG_INPUT_ENABLES_HDS_THRESHOLD_VALID |
2501 : : HWRM_VNIC_PLCMODES_CFG_INPUT_ENABLES_HDS_OFFSET_VALID |
2502 : : HWRM_VNIC_PLCMODES_CFG_INPUT_ENABLES_JUMBO_THRESH_VALID
2503 : : );
2504 : :
2505 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2506 : :
2507 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2508 : : HWRM_UNLOCK();
2509 : :
2510 : 0 : return rc;
2511 : : }
2512 : :
2513 : 0 : int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic)
2514 : : {
2515 : : int rc = 0;
2516 : 0 : struct hwrm_vnic_cfg_input req = {.req_type = 0 };
2517 : 0 : struct hwrm_vnic_cfg_output *resp = bp->hwrm_cmd_resp_addr;
2518 : 0 : struct bnxt_plcmodes_cfg pmodes = { 0 };
2519 : : uint32_t ctx_enable_flag = 0;
2520 : : uint32_t enables = 0;
2521 : :
2522 [ # # ]: 0 : if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
2523 : 0 : PMD_DRV_LOG(DEBUG, "VNIC ID %x\n", vnic->fw_vnic_id);
2524 : 0 : return rc;
2525 : : }
2526 : :
2527 : 0 : rc = bnxt_hwrm_vnic_plcmodes_qcfg(bp, vnic, &pmodes);
2528 [ # # ]: 0 : if (rc)
2529 : : return rc;
2530 : :
2531 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_CFG, BNXT_USE_CHIMP_MB);
2532 : :
2533 [ # # ]: 0 : if (BNXT_CHIP_P5_P7(bp)) {
2534 : 0 : int dflt_rxq = vnic->start_grp_id;
2535 : : struct bnxt_rx_ring_info *rxr;
2536 : : struct bnxt_cp_ring_info *cpr;
2537 : : struct bnxt_rx_queue *rxq;
2538 : : int i;
2539 : :
2540 : : /*
2541 : : * The first active receive ring is used as the VNIC
2542 : : * default receive ring. If there are no active receive
2543 : : * rings (all corresponding receive queues are stopped),
2544 : : * the first receive ring is used.
2545 : : */
2546 [ # # ]: 0 : for (i = vnic->start_grp_id; i < vnic->end_grp_id; i++) {
2547 : 0 : rxq = bp->eth_dev->data->rx_queues[i];
2548 [ # # # # ]: 0 : if (rxq->rx_started &&
2549 : 0 : bnxt_vnic_queue_id_is_valid(vnic, i)) {
2550 : : dflt_rxq = i;
2551 : : break;
2552 : : }
2553 : : }
2554 : :
2555 : 0 : rxq = bp->eth_dev->data->rx_queues[dflt_rxq];
2556 : 0 : rxr = rxq->rx_ring;
2557 : 0 : cpr = rxq->cp_ring;
2558 : :
2559 : 0 : req.default_rx_ring_id =
2560 : 0 : rte_cpu_to_le_16(rxr->rx_ring_struct->fw_ring_id);
2561 : 0 : req.default_cmpl_ring_id =
2562 : 0 : rte_cpu_to_le_16(cpr->cp_ring_struct->fw_ring_id);
2563 : : enables = HWRM_VNIC_CFG_INPUT_ENABLES_DEFAULT_RX_RING_ID |
2564 : : HWRM_VNIC_CFG_INPUT_ENABLES_DEFAULT_CMPL_RING_ID;
2565 [ # # ]: 0 : if (bp->vnic_cap_flags & BNXT_VNIC_CAP_RX_CMPL_V2) {
2566 : : enables |= HWRM_VNIC_CFG_INPUT_ENABLES_RX_CSUM_V2_MODE;
2567 : 0 : req.rx_csum_v2_mode =
2568 : : HWRM_VNIC_CFG_INPUT_RX_CSUM_V2_MODE_ALL_OK;
2569 : : }
2570 : 0 : goto config_mru;
2571 : : }
2572 : :
2573 : : /* Only RSS support for now TBD: COS & LB */
2574 : : enables = HWRM_VNIC_CFG_INPUT_ENABLES_DFLT_RING_GRP;
2575 [ # # ]: 0 : if (vnic->lb_rule != 0xffff)
2576 : : ctx_enable_flag |= HWRM_VNIC_CFG_INPUT_ENABLES_LB_RULE;
2577 [ # # ]: 0 : if (vnic->cos_rule != 0xffff)
2578 : 0 : ctx_enable_flag |= HWRM_VNIC_CFG_INPUT_ENABLES_COS_RULE;
2579 [ # # ]: 0 : if (vnic->rss_rule != (uint16_t)HWRM_NA_SIGNATURE) {
2580 : : ctx_enable_flag |= HWRM_VNIC_CFG_INPUT_ENABLES_MRU;
2581 : 0 : ctx_enable_flag |= HWRM_VNIC_CFG_INPUT_ENABLES_RSS_RULE;
2582 : : }
2583 [ # # ]: 0 : if (bp->vnic_cap_flags & BNXT_VNIC_CAP_COS_CLASSIFY) {
2584 : 0 : ctx_enable_flag |= HWRM_VNIC_CFG_INPUT_ENABLES_QUEUE_ID;
2585 : 0 : req.queue_id = rte_cpu_to_le_16(vnic->cos_queue_id);
2586 : : }
2587 : :
2588 : 0 : enables |= ctx_enable_flag;
2589 : 0 : req.dflt_ring_grp = rte_cpu_to_le_16(vnic->dflt_ring_grp);
2590 : 0 : req.rss_rule = rte_cpu_to_le_16(vnic->rss_rule);
2591 : 0 : req.cos_rule = rte_cpu_to_le_16(vnic->cos_rule);
2592 : 0 : req.lb_rule = rte_cpu_to_le_16(vnic->lb_rule);
2593 : :
2594 : 0 : config_mru:
2595 [ # # ]: 0 : if (bnxt_compressed_rx_cqe_mode_enabled(bp)) {
2596 : 0 : req.l2_cqe_mode = HWRM_VNIC_CFG_INPUT_L2_CQE_MODE_COMPRESSED;
2597 : 0 : enables |= HWRM_VNIC_CFG_INPUT_ENABLES_L2_CQE_MODE;
2598 : 0 : PMD_DRV_LOG(DEBUG, "Enabling compressed Rx CQE\n");
2599 : : }
2600 : :
2601 : 0 : req.enables = rte_cpu_to_le_32(enables);
2602 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
2603 : 0 : req.mru = rte_cpu_to_le_16(vnic->mru);
2604 : : /* Configure default VNIC only once. */
2605 [ # # # # ]: 0 : if (vnic->func_default && !(bp->flags & BNXT_FLAG_DFLT_VNIC_SET)) {
2606 : 0 : req.flags |=
2607 : : rte_cpu_to_le_32(HWRM_VNIC_CFG_INPUT_FLAGS_DEFAULT);
2608 : 0 : bp->flags |= BNXT_FLAG_DFLT_VNIC_SET;
2609 : : }
2610 [ # # ]: 0 : if (vnic->vlan_strip)
2611 : 0 : req.flags |=
2612 : : rte_cpu_to_le_32(HWRM_VNIC_CFG_INPUT_FLAGS_VLAN_STRIP_MODE);
2613 [ # # ]: 0 : if (vnic->bd_stall)
2614 : 0 : req.flags |=
2615 : : rte_cpu_to_le_32(HWRM_VNIC_CFG_INPUT_FLAGS_BD_STALL_MODE);
2616 [ # # ]: 0 : if (vnic->rss_dflt_cr)
2617 : 0 : req.flags |= rte_cpu_to_le_32(
2618 : : HWRM_VNIC_QCFG_OUTPUT_FLAGS_RSS_DFLT_CR_MODE);
2619 : :
2620 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2621 : :
2622 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2623 : : HWRM_UNLOCK();
2624 : :
2625 : 0 : rc = bnxt_hwrm_vnic_plcmodes_cfg(bp, vnic, &pmodes);
2626 : :
2627 : 0 : return rc;
2628 : : }
2629 : :
2630 : 0 : int bnxt_hwrm_vnic_qcfg(struct bnxt *bp, struct bnxt_vnic_info *vnic,
2631 : : int16_t fw_vf_id)
2632 : : {
2633 : : int rc = 0;
2634 : 0 : struct hwrm_vnic_qcfg_input req = {.req_type = 0 };
2635 : 0 : struct hwrm_vnic_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
2636 : :
2637 [ # # ]: 0 : if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
2638 : 0 : PMD_DRV_LOG(DEBUG, "VNIC QCFG ID %d\n", vnic->fw_vnic_id);
2639 : 0 : return rc;
2640 : : }
2641 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_QCFG, BNXT_USE_CHIMP_MB);
2642 : :
2643 : 0 : req.enables =
2644 : : rte_cpu_to_le_32(HWRM_VNIC_QCFG_INPUT_ENABLES_VF_ID_VALID);
2645 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
2646 : 0 : req.vf_id = rte_cpu_to_le_16(fw_vf_id);
2647 : :
2648 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2649 : :
2650 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2651 : :
2652 : 0 : vnic->dflt_ring_grp = rte_le_to_cpu_16(resp->dflt_ring_grp);
2653 : 0 : vnic->rss_rule = rte_le_to_cpu_16(resp->rss_rule);
2654 : 0 : vnic->cos_rule = rte_le_to_cpu_16(resp->cos_rule);
2655 : 0 : vnic->lb_rule = rte_le_to_cpu_16(resp->lb_rule);
2656 : 0 : vnic->mru = rte_le_to_cpu_16(resp->mru);
2657 : 0 : vnic->func_default = rte_le_to_cpu_32(
2658 : 0 : resp->flags) & HWRM_VNIC_QCFG_OUTPUT_FLAGS_DEFAULT;
2659 : 0 : vnic->vlan_strip = rte_le_to_cpu_32(resp->flags) &
2660 : : HWRM_VNIC_QCFG_OUTPUT_FLAGS_VLAN_STRIP_MODE;
2661 : 0 : vnic->bd_stall = rte_le_to_cpu_32(resp->flags) &
2662 : : HWRM_VNIC_QCFG_OUTPUT_FLAGS_BD_STALL_MODE;
2663 : 0 : vnic->rss_dflt_cr = rte_le_to_cpu_32(resp->flags) &
2664 : : HWRM_VNIC_QCFG_OUTPUT_FLAGS_RSS_DFLT_CR_MODE;
2665 : :
2666 : : HWRM_UNLOCK();
2667 : :
2668 : 0 : return rc;
2669 : : }
2670 : :
2671 : 0 : int bnxt_hwrm_vnic_ctx_alloc(struct bnxt *bp,
2672 : : struct bnxt_vnic_info *vnic, uint16_t ctx_idx)
2673 : : {
2674 : : int rc = 0;
2675 : : uint16_t ctx_id;
2676 : 0 : struct hwrm_vnic_rss_cos_lb_ctx_alloc_input req = {.req_type = 0 };
2677 : 0 : struct hwrm_vnic_rss_cos_lb_ctx_alloc_output *resp =
2678 : : bp->hwrm_cmd_resp_addr;
2679 : :
2680 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_RSS_COS_LB_CTX_ALLOC, BNXT_USE_CHIMP_MB);
2681 : :
2682 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2683 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2684 : :
2685 : 0 : ctx_id = rte_le_to_cpu_16(resp->rss_cos_lb_ctx_id);
2686 [ # # ]: 0 : if (!BNXT_HAS_RING_GRPS(bp))
2687 : 0 : vnic->fw_grp_ids[ctx_idx] = ctx_id;
2688 [ # # ]: 0 : else if (ctx_idx == 0)
2689 : 0 : vnic->rss_rule = ctx_id;
2690 : :
2691 : : HWRM_UNLOCK();
2692 : :
2693 : 0 : return rc;
2694 : : }
2695 : :
2696 : : static
2697 : 0 : int _bnxt_hwrm_vnic_ctx_free(struct bnxt *bp,
2698 : : struct bnxt_vnic_info *vnic, uint16_t ctx_idx)
2699 : : {
2700 : : int rc = 0;
2701 : 0 : struct hwrm_vnic_rss_cos_lb_ctx_free_input req = {.req_type = 0 };
2702 : 0 : struct hwrm_vnic_rss_cos_lb_ctx_free_output *resp =
2703 : : bp->hwrm_cmd_resp_addr;
2704 : :
2705 [ # # ]: 0 : if (ctx_idx == (uint16_t)HWRM_NA_SIGNATURE) {
2706 : 0 : PMD_DRV_LOG(DEBUG, "VNIC RSS Rule %x\n", vnic->rss_rule);
2707 : 0 : return rc;
2708 : : }
2709 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_RSS_COS_LB_CTX_FREE, BNXT_USE_CHIMP_MB);
2710 : :
2711 : 0 : req.rss_cos_lb_ctx_id = rte_cpu_to_le_16(ctx_idx);
2712 : :
2713 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2714 : :
2715 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2716 : : HWRM_UNLOCK();
2717 : :
2718 : 0 : return rc;
2719 : : }
2720 : :
2721 : 0 : int bnxt_hwrm_vnic_ctx_free(struct bnxt *bp, struct bnxt_vnic_info *vnic)
2722 : : {
2723 : : int rc = 0;
2724 : :
2725 [ # # ]: 0 : if (BNXT_CHIP_P5_P7(bp)) {
2726 : : int j;
2727 : :
2728 [ # # ]: 0 : for (j = 0; j < vnic->num_lb_ctxts; j++) {
2729 : 0 : rc = _bnxt_hwrm_vnic_ctx_free(bp,
2730 : : vnic,
2731 : 0 : vnic->fw_grp_ids[j]);
2732 : 0 : vnic->fw_grp_ids[j] = INVALID_HW_RING_ID;
2733 : : }
2734 : 0 : vnic->num_lb_ctxts = 0;
2735 : : } else {
2736 : 0 : rc = _bnxt_hwrm_vnic_ctx_free(bp, vnic, vnic->rss_rule);
2737 : 0 : vnic->rss_rule = INVALID_HW_RING_ID;
2738 : : }
2739 : :
2740 : 0 : return rc;
2741 : : }
2742 : :
2743 : 0 : int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic)
2744 : : {
2745 : : int rc = 0;
2746 : 0 : struct hwrm_vnic_free_input req = {.req_type = 0 };
2747 : 0 : struct hwrm_vnic_free_output *resp = bp->hwrm_cmd_resp_addr;
2748 : :
2749 [ # # ]: 0 : if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
2750 : 0 : PMD_DRV_LOG(DEBUG, "VNIC FREE ID %x\n", vnic->fw_vnic_id);
2751 : 0 : return rc;
2752 : : }
2753 : :
2754 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_FREE, BNXT_USE_CHIMP_MB);
2755 : :
2756 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
2757 : :
2758 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2759 : :
2760 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2761 : : HWRM_UNLOCK();
2762 : :
2763 : 0 : vnic->fw_vnic_id = INVALID_HW_RING_ID;
2764 : : /* Configure default VNIC again if necessary. */
2765 [ # # # # ]: 0 : if (vnic->func_default && (bp->flags & BNXT_FLAG_DFLT_VNIC_SET))
2766 : 0 : bp->flags &= ~BNXT_FLAG_DFLT_VNIC_SET;
2767 : :
2768 : : return rc;
2769 : : }
2770 : :
2771 : 0 : static uint32_t bnxt_sanitize_rss_type(struct bnxt *bp, uint32_t types)
2772 : : {
2773 : : uint32_t hwrm_type = types;
2774 : :
2775 [ # # ]: 0 : if (types & HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_ESP_SPI_IPV4 &&
2776 [ # # ]: 0 : !(bp->vnic_cap_flags & BNXT_VNIC_CAP_ESP_SPI4_CAP))
2777 : 0 : hwrm_type &= ~HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_ESP_SPI_IPV4;
2778 [ # # ]: 0 : if (types & HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_ESP_SPI_IPV6 &&
2779 [ # # ]: 0 : !(bp->vnic_cap_flags & BNXT_VNIC_CAP_ESP_SPI6_CAP))
2780 : 0 : hwrm_type &= ~HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_ESP_SPI_IPV6;
2781 : :
2782 [ # # ]: 0 : if (types & HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_AH_SPI_IPV4 &&
2783 [ # # ]: 0 : !(bp->vnic_cap_flags & BNXT_VNIC_CAP_AH_SPI4_CAP))
2784 : 0 : hwrm_type &= ~HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_AH_SPI_IPV4;
2785 : :
2786 [ # # ]: 0 : if (types & HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_AH_SPI_IPV6 &&
2787 [ # # ]: 0 : !(bp->vnic_cap_flags & BNXT_VNIC_CAP_AH_SPI6_CAP))
2788 : 0 : hwrm_type &= ~HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_AH_SPI_IPV6;
2789 : :
2790 : 0 : return hwrm_type;
2791 : : }
2792 : :
2793 : : #ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
2794 : : static int
2795 : : bnxt_hwrm_vnic_rss_qcfg_p5(struct bnxt *bp)
2796 : : {
2797 : : struct hwrm_vnic_rss_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
2798 : : struct hwrm_vnic_rss_qcfg_input req = {0};
2799 : : int rc;
2800 : :
2801 : : HWRM_PREP(&req, HWRM_VNIC_RSS_QCFG, BNXT_USE_CHIMP_MB);
2802 : : /* vnic_id and rss_ctx_idx must be set to INVALID to read the
2803 : : * global hash mode.
2804 : : */
2805 : : req.vnic_id = rte_cpu_to_le_16(BNXT_DFLT_VNIC_ID_INVALID);
2806 : : req.rss_ctx_idx = rte_cpu_to_le_16(BNXT_RSS_CTX_IDX_INVALID);
2807 : : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req),
2808 : : BNXT_USE_CHIMP_MB);
2809 : : HWRM_CHECK_RESULT();
2810 : : HWRM_UNLOCK();
2811 : : PMD_DRV_LOG(DEBUG, "RSS QCFG: Hash level %d\n", resp->hash_mode_flags);
2812 : :
2813 : : return rc;
2814 : : }
2815 : : #endif
2816 : :
2817 : : static int
2818 : 0 : bnxt_hwrm_vnic_rss_cfg_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic)
2819 : : {
2820 : : int i;
2821 : : int rc = 0;
2822 : 0 : int nr_ctxs = vnic->num_lb_ctxts;
2823 : 0 : struct hwrm_vnic_rss_cfg_input req = {.req_type = 0 };
2824 : 0 : struct hwrm_vnic_rss_cfg_output *resp = bp->hwrm_cmd_resp_addr;
2825 : :
2826 [ # # ]: 0 : for (i = 0; i < nr_ctxs; i++) {
2827 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_RSS_CFG, BNXT_USE_CHIMP_MB);
2828 : :
2829 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
2830 : 0 : req.hash_type = rte_cpu_to_le_32(bnxt_sanitize_rss_type(bp, vnic->hash_type));
2831 : : /* Update req with vnic ring_select_mode for P7 */
2832 [ # # ]: 0 : if (BNXT_CHIP_P7(bp))
2833 : 0 : req.ring_select_mode = vnic->ring_select_mode;
2834 : : /* When the vnic_id in the request field is a valid
2835 : : * one, the hash_mode_flags in the request field must
2836 : : * be set to DEFAULT. And any request to change the
2837 : : * default behavior must be done in a separate call
2838 : : * to HWRM_VNIC_RSS_CFG by exclusively setting hash
2839 : : * mode and vnic_id, rss_ctx_idx to INVALID.
2840 : : */
2841 : 0 : req.hash_mode_flags = BNXT_HASH_MODE_DEFAULT;
2842 : :
2843 : 0 : req.hash_key_tbl_addr =
2844 : 0 : rte_cpu_to_le_64(vnic->rss_hash_key_dma_addr);
2845 : :
2846 : 0 : req.ring_grp_tbl_addr =
2847 : 0 : rte_cpu_to_le_64(vnic->rss_table_dma_addr +
2848 : : i * BNXT_RSS_ENTRIES_PER_CTX_P5 *
2849 : : 2 * sizeof(uint16_t));
2850 : 0 : req.ring_table_pair_index = i;
2851 : 0 : req.rss_ctx_idx = rte_cpu_to_le_16(vnic->fw_grp_ids[i]);
2852 : :
2853 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req),
2854 : : BNXT_USE_CHIMP_MB);
2855 : :
2856 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2857 : : HWRM_UNLOCK();
2858 : 0 : PMD_DRV_LOG(DEBUG, "RSS CFG: Hash level %d\n", req.hash_mode_flags);
2859 : : }
2860 : :
2861 : : return rc;
2862 : : }
2863 : :
2864 : : static int
2865 : 0 : bnxt_hwrm_vnic_rss_cfg_hash_mode_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic)
2866 : : {
2867 : 0 : struct hwrm_vnic_rss_cfg_output *resp = bp->hwrm_cmd_resp_addr;
2868 : 0 : struct hwrm_vnic_rss_cfg_input req = {.req_type = 0 };
2869 : : int rc = 0;
2870 : :
2871 : : /* The reason we are returning success here is that this
2872 : : * call is in the context of user/stack RSS configuration.
2873 : : * Even though OUTER RSS is not supported, the normal RSS
2874 : : * configuration should continue to work.
2875 : : */
2876 [ # # # # : 0 : if ((BNXT_CHIP_P5(bp) && BNXT_VNIC_OUTER_RSS_UNSUPPORTED(bp)) ||
# # # # #
# # # #
# ]
2877 [ # # ]: 0 : (!BNXT_CHIP_P5(bp) && !(bp->vnic_cap_flags & BNXT_VNIC_CAP_OUTER_RSS)))
2878 : : return 0;
2879 : :
2880 : : /* Don't call RSS hash level configuration if the current
2881 : : * hash level is the same as the hash level that is requested.
2882 : : */
2883 [ # # ]: 0 : if (vnic->prev_hash_mode == vnic->hash_mode)
2884 : : return 0;
2885 : :
2886 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_RSS_CFG, BNXT_USE_CHIMP_MB);
2887 : :
2888 : : /* For FW, hash_mode == DEFAULT means that
2889 : : * the FW is capable of doing INNER & OUTER RSS as well.
2890 : : * DEFAULT doesn't mean that the FW is
2891 : : * going to change the hash_mode to INNER. However, for
2892 : : * the USER, DEFAULT means, change the hash mode to the
2893 : : * NIC's DEFAULT hash mode which is INNER.
2894 : : *
2895 : : * Hence, driver should make the translation of hash_mode
2896 : : * to INNERMOST when hash_mode from the dpdk stack is
2897 : : * DEFAULT.
2898 : : */
2899 [ # # ]: 0 : if (vnic->hash_mode == BNXT_HASH_MODE_DEFAULT)
2900 : 0 : req.hash_mode_flags = BNXT_HASH_MODE_INNERMOST;
2901 : : else
2902 : 0 : req.hash_mode_flags = vnic->hash_mode;
2903 : 0 : req.vnic_id = rte_cpu_to_le_16(BNXT_DFLT_VNIC_ID_INVALID);
2904 : 0 : req.rss_ctx_idx = rte_cpu_to_le_16(BNXT_RSS_CTX_IDX_INVALID);
2905 : :
2906 : 0 : PMD_DRV_LOG(DEBUG, "RSS CFG: Hash level %d\n", req.hash_mode_flags);
2907 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req),
2908 : : BNXT_USE_CHIMP_MB);
2909 : :
2910 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2911 : : /* Store the programmed hash_mode in prev_hash_mode so that
2912 : : * it can checked against the next user requested hash mode.
2913 : : */
2914 : : if (!rc)
2915 : 0 : vnic->prev_hash_mode = vnic->hash_mode;
2916 : : HWRM_UNLOCK();
2917 : 0 : return rc;
2918 : : }
2919 : :
2920 : : static int
2921 : 0 : bnxt_hwrm_vnic_rss_cfg_non_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic)
2922 : : {
2923 : 0 : struct hwrm_vnic_rss_cfg_input req = {.req_type = 0 };
2924 : 0 : struct hwrm_vnic_rss_cfg_output *resp = bp->hwrm_cmd_resp_addr;
2925 : : int rc = 0;
2926 : :
2927 [ # # ]: 0 : if (vnic->num_lb_ctxts == 0)
2928 : : return rc;
2929 : :
2930 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_RSS_CFG, BNXT_USE_CHIMP_MB);
2931 : :
2932 : 0 : req.hash_type = rte_cpu_to_le_32(bnxt_sanitize_rss_type(bp, vnic->hash_type));
2933 : 0 : req.hash_mode_flags = vnic->hash_mode;
2934 : :
2935 : 0 : req.ring_grp_tbl_addr =
2936 : 0 : rte_cpu_to_le_64(vnic->rss_table_dma_addr);
2937 : 0 : req.hash_key_tbl_addr =
2938 : 0 : rte_cpu_to_le_64(vnic->rss_hash_key_dma_addr);
2939 : 0 : req.rss_ctx_idx = rte_cpu_to_le_16(vnic->rss_rule);
2940 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
2941 : :
2942 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2943 : :
2944 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2945 : : HWRM_UNLOCK();
2946 : :
2947 : 0 : return rc;
2948 : : }
2949 : :
2950 : 0 : int bnxt_hwrm_vnic_rss_cfg(struct bnxt *bp,
2951 : : struct bnxt_vnic_info *vnic)
2952 : : {
2953 : : int rc = 0;
2954 : :
2955 [ # # ]: 0 : if (!vnic->rss_table)
2956 : : return 0;
2957 : :
2958 : : /* Handle all the non-thor skus rss here */
2959 [ # # ]: 0 : if (!BNXT_CHIP_P5_P7(bp))
2960 : 0 : return bnxt_hwrm_vnic_rss_cfg_non_p5(bp, vnic);
2961 : :
2962 : : /* Handle Thor2 and Thor skus rss here */
2963 : 0 : rc = bnxt_hwrm_vnic_rss_cfg_p5(bp, vnic);
2964 : :
2965 : : /* configure hash mode for Thor/Thor2 */
2966 [ # # ]: 0 : if (!rc)
2967 : 0 : return bnxt_hwrm_vnic_rss_cfg_hash_mode_p5(bp, vnic);
2968 : :
2969 : : return rc;
2970 : : }
2971 : :
2972 : 0 : int bnxt_hwrm_vnic_plcmode_cfg(struct bnxt *bp,
2973 : : struct bnxt_vnic_info *vnic)
2974 : : {
2975 : : int rc = 0;
2976 : 0 : struct hwrm_vnic_plcmodes_cfg_input req = {.req_type = 0 };
2977 : 0 : struct hwrm_vnic_plcmodes_cfg_output *resp = bp->hwrm_cmd_resp_addr;
2978 : : uint16_t size;
2979 : :
2980 [ # # ]: 0 : if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
2981 : 0 : PMD_DRV_LOG(DEBUG, "VNIC ID %x\n", vnic->fw_vnic_id);
2982 : 0 : return rc;
2983 : : }
2984 : :
2985 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_PLCMODES_CFG, BNXT_USE_CHIMP_MB);
2986 : :
2987 : 0 : req.flags = rte_cpu_to_le_32(
2988 : : HWRM_VNIC_PLCMODES_CFG_INPUT_FLAGS_JUMBO_PLACEMENT);
2989 : :
2990 : 0 : req.enables = rte_cpu_to_le_32(
2991 : : HWRM_VNIC_PLCMODES_CFG_INPUT_ENABLES_JUMBO_THRESH_VALID);
2992 : :
2993 [ # # ]: 0 : size = rte_pktmbuf_data_room_size(bp->rx_queues[0]->mb_pool);
2994 : 0 : size -= RTE_PKTMBUF_HEADROOM;
2995 : 0 : size = RTE_MIN(BNXT_MAX_PKT_LEN, size);
2996 : :
2997 : 0 : req.jumbo_thresh = rte_cpu_to_le_16(size);
2998 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
2999 : :
3000 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3001 : :
3002 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
3003 : : HWRM_UNLOCK();
3004 : :
3005 : 0 : return rc;
3006 : : }
3007 : :
3008 : : #define BNXT_DFLT_TUNL_TPA_BMAP \
3009 : : (HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_GRE | \
3010 : : HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_IPV4 | \
3011 : : HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_IPV6)
3012 : :
3013 : : static void bnxt_vnic_update_tunl_tpa_bmap(struct bnxt *bp,
3014 : : struct hwrm_vnic_tpa_cfg_input *req)
3015 : : {
3016 : : uint32_t tunl_tpa_bmap = BNXT_DFLT_TUNL_TPA_BMAP;
3017 : :
3018 [ # # ]: 0 : if (!(bp->vnic_cap_flags & BNXT_VNIC_CAP_VNIC_TUNNEL_TPA))
3019 : : return;
3020 : :
3021 [ # # ]: 0 : if (bp->vxlan_port_cnt)
3022 : : tunl_tpa_bmap |= HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_VXLAN |
3023 : : HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_VXLAN_GPE;
3024 : :
3025 [ # # ]: 0 : if (bp->geneve_port_cnt)
3026 : 0 : tunl_tpa_bmap |= HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_GENEVE;
3027 : :
3028 : 0 : req->enables |= rte_cpu_to_le_32(HWRM_VNIC_TPA_CFG_INPUT_ENABLES_TNL_TPA_EN);
3029 : 0 : req->tnl_tpa_en_bitmap = rte_cpu_to_le_32(tunl_tpa_bmap);
3030 : : }
3031 : :
3032 : 0 : int bnxt_hwrm_vnic_tpa_cfg(struct bnxt *bp,
3033 : : struct bnxt_vnic_info *vnic, bool enable)
3034 : : {
3035 : : int rc = 0;
3036 : 0 : struct hwrm_vnic_tpa_cfg_input req = {.req_type = 0 };
3037 : 0 : struct hwrm_vnic_tpa_cfg_output *resp = bp->hwrm_cmd_resp_addr;
3038 : :
3039 [ # # ]: 0 : if (bnxt_compressed_rx_cqe_mode_enabled(bp)) {
3040 : : /* Don't worry if disabling TPA */
3041 [ # # ]: 0 : if (!enable)
3042 : : return 0;
3043 : :
3044 : : /* Return an error if enabling TPA w/ compressed Rx CQE. */
3045 : 0 : PMD_DRV_LOG(ERR, "No HW support for LRO with compressed Rx\n");
3046 : 0 : return -ENOTSUP;
3047 : : }
3048 : :
3049 [ # # # # ]: 0 : if ((BNXT_CHIP_P5(bp) || BNXT_CHIP_P7(bp)) && !bp->max_tpa_v2) {
3050 [ # # ]: 0 : if (enable)
3051 : 0 : PMD_DRV_LOG(ERR, "No HW support for LRO\n");
3052 : 0 : return -ENOTSUP;
3053 : : }
3054 : :
3055 [ # # ]: 0 : if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
3056 : 0 : PMD_DRV_LOG(DEBUG, "Invalid vNIC ID\n");
3057 : 0 : return 0;
3058 : : }
3059 : :
3060 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_TPA_CFG, BNXT_USE_CHIMP_MB);
3061 : :
3062 [ # # ]: 0 : if (enable) {
3063 : 0 : req.enables = rte_cpu_to_le_32(
3064 : : HWRM_VNIC_TPA_CFG_INPUT_ENABLES_MAX_AGG_SEGS |
3065 : : HWRM_VNIC_TPA_CFG_INPUT_ENABLES_MAX_AGGS |
3066 : : HWRM_VNIC_TPA_CFG_INPUT_ENABLES_MIN_AGG_LEN);
3067 : 0 : req.flags = rte_cpu_to_le_32(
3068 : : HWRM_VNIC_TPA_CFG_INPUT_FLAGS_TPA |
3069 : : HWRM_VNIC_TPA_CFG_INPUT_FLAGS_ENCAP_TPA |
3070 : : HWRM_VNIC_TPA_CFG_INPUT_FLAGS_RSC_WND_UPDATE |
3071 : : HWRM_VNIC_TPA_CFG_INPUT_FLAGS_GRO |
3072 : : HWRM_VNIC_TPA_CFG_INPUT_FLAGS_AGG_WITH_ECN |
3073 : : HWRM_VNIC_TPA_CFG_INPUT_FLAGS_AGG_WITH_SAME_GRE_SEQ);
3074 [ # # ]: 0 : req.max_aggs = rte_cpu_to_le_16(BNXT_TPA_MAX_AGGS(bp));
3075 [ # # ]: 0 : req.max_agg_segs = rte_cpu_to_le_16(BNXT_TPA_MAX_SEGS(bp));
3076 : 0 : req.min_agg_len = rte_cpu_to_le_32(512);
3077 : :
3078 [ # # ]: 0 : if (BNXT_CHIP_P5_P7(bp))
3079 : 0 : req.max_aggs = rte_cpu_to_le_16(bp->max_tpa_v2);
3080 : :
3081 : : /* For tpa v2 handle as per spec mss and log2 units */
3082 [ # # ]: 0 : if (BNXT_CHIP_P7(bp)) {
3083 : : uint32_t nsegs, n, segs = 0;
3084 : 0 : uint16_t mss = bp->eth_dev->data->mtu - 40;
3085 : 0 : size_t page_size = rte_mem_page_size();
3086 : 0 : uint32_t max_mbuf_frags =
3087 : 0 : BNXT_TPA_MAX_PAGES / (rte_mem_page_size() + 1);
3088 : :
3089 : : /* Calculate the number of segs based on mss */
3090 [ # # ]: 0 : if (mss <= page_size) {
3091 : 0 : n = page_size / mss;
3092 : 0 : nsegs = (max_mbuf_frags - 1) * n;
3093 : : } else {
3094 : 0 : n = mss / page_size;
3095 [ # # ]: 0 : if (mss & (page_size - 1))
3096 : 0 : n++;
3097 : 0 : nsegs = (max_mbuf_frags - n) / n;
3098 : : }
3099 : : segs = rte_log2_u32(nsegs);
3100 : 0 : req.max_agg_segs = rte_cpu_to_le_16(segs);
3101 : : }
3102 : : bnxt_vnic_update_tunl_tpa_bmap(bp, &req);
3103 : : }
3104 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
3105 : :
3106 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3107 : :
3108 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
3109 : : HWRM_UNLOCK();
3110 : :
3111 : 0 : return rc;
3112 : : }
3113 : :
3114 : 0 : int bnxt_hwrm_func_vf_mac(struct bnxt *bp, uint16_t vf, const uint8_t *mac_addr)
3115 : : {
3116 : 0 : struct hwrm_func_cfg_input req = {0};
3117 : 0 : struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
3118 : : int rc;
3119 : :
3120 : 0 : req.flags = rte_cpu_to_le_32(bp->pf->vf_info[vf].func_cfg_flags);
3121 : 0 : req.enables = rte_cpu_to_le_32(
3122 : : HWRM_FUNC_CFG_INPUT_ENABLES_DFLT_MAC_ADDR);
3123 : : memcpy(req.dflt_mac_addr, mac_addr, sizeof(req.dflt_mac_addr));
3124 : 0 : req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
3125 : :
3126 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
3127 : :
3128 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3129 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
3130 : : HWRM_UNLOCK();
3131 : :
3132 : 0 : bp->pf->vf_info[vf].random_mac = false;
3133 : :
3134 : 0 : return rc;
3135 : : }
3136 : :
3137 : 0 : int bnxt_hwrm_func_qstats_tx_drop(struct bnxt *bp, uint16_t fid,
3138 : : uint64_t *dropped)
3139 : : {
3140 : : int rc = 0;
3141 : 0 : struct hwrm_func_qstats_input req = {.req_type = 0};
3142 : 0 : struct hwrm_func_qstats_output *resp = bp->hwrm_cmd_resp_addr;
3143 : :
3144 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QSTATS, BNXT_USE_CHIMP_MB);
3145 : :
3146 : 0 : req.fid = rte_cpu_to_le_16(fid);
3147 : :
3148 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3149 : :
3150 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
3151 : :
3152 [ # # ]: 0 : if (dropped)
3153 : 0 : *dropped = rte_le_to_cpu_64(resp->tx_drop_pkts);
3154 : :
3155 : : HWRM_UNLOCK();
3156 : :
3157 : 0 : return rc;
3158 : : }
3159 : :
3160 : 0 : int bnxt_hwrm_func_qstats(struct bnxt *bp, uint16_t fid,
3161 : : struct rte_eth_stats *stats,
3162 : : struct hwrm_func_qstats_output *func_qstats)
3163 : : {
3164 : : int rc = 0;
3165 : 0 : struct hwrm_func_qstats_input req = {.req_type = 0};
3166 : 0 : struct hwrm_func_qstats_output *resp = bp->hwrm_cmd_resp_addr;
3167 : :
3168 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QSTATS, BNXT_USE_CHIMP_MB);
3169 : :
3170 : 0 : req.fid = rte_cpu_to_le_16(fid);
3171 : :
3172 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3173 : :
3174 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
3175 [ # # ]: 0 : if (func_qstats)
3176 : : memcpy(func_qstats, resp,
3177 : : sizeof(struct hwrm_func_qstats_output));
3178 : :
3179 [ # # ]: 0 : if (!stats)
3180 : 0 : goto exit;
3181 : :
3182 : 0 : stats->ipackets = rte_le_to_cpu_64(resp->rx_ucast_pkts);
3183 : 0 : stats->ipackets += rte_le_to_cpu_64(resp->rx_mcast_pkts);
3184 : 0 : stats->ipackets += rte_le_to_cpu_64(resp->rx_bcast_pkts);
3185 : 0 : stats->ibytes = rte_le_to_cpu_64(resp->rx_ucast_bytes);
3186 : 0 : stats->ibytes += rte_le_to_cpu_64(resp->rx_mcast_bytes);
3187 : 0 : stats->ibytes += rte_le_to_cpu_64(resp->rx_bcast_bytes);
3188 : :
3189 : 0 : stats->opackets = rte_le_to_cpu_64(resp->tx_ucast_pkts);
3190 : 0 : stats->opackets += rte_le_to_cpu_64(resp->tx_mcast_pkts);
3191 : 0 : stats->opackets += rte_le_to_cpu_64(resp->tx_bcast_pkts);
3192 : 0 : stats->obytes = rte_le_to_cpu_64(resp->tx_ucast_bytes);
3193 : 0 : stats->obytes += rte_le_to_cpu_64(resp->tx_mcast_bytes);
3194 : 0 : stats->obytes += rte_le_to_cpu_64(resp->tx_bcast_bytes);
3195 : :
3196 : 0 : stats->imissed = rte_le_to_cpu_64(resp->rx_discard_pkts);
3197 : 0 : stats->ierrors = rte_le_to_cpu_64(resp->rx_drop_pkts);
3198 : 0 : stats->oerrors = rte_le_to_cpu_64(resp->tx_discard_pkts);
3199 : :
3200 : 0 : exit:
3201 : : HWRM_UNLOCK();
3202 : :
3203 : 0 : return rc;
3204 : : }
3205 : :
3206 : 0 : int bnxt_hwrm_func_clr_stats(struct bnxt *bp, uint16_t fid)
3207 : : {
3208 : : int rc = 0;
3209 : 0 : struct hwrm_func_clr_stats_input req = {.req_type = 0};
3210 : 0 : struct hwrm_func_clr_stats_output *resp = bp->hwrm_cmd_resp_addr;
3211 : :
3212 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CLR_STATS, BNXT_USE_CHIMP_MB);
3213 : :
3214 : 0 : req.fid = rte_cpu_to_le_16(fid);
3215 : :
3216 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3217 : :
3218 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
3219 : : HWRM_UNLOCK();
3220 : :
3221 : 0 : return rc;
3222 : : }
3223 : :
3224 : 0 : int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp)
3225 : : {
3226 : : unsigned int i;
3227 : : int rc = 0;
3228 : :
3229 [ # # ]: 0 : for (i = 0; i < bp->rx_cp_nr_rings + bp->tx_cp_nr_rings; i++) {
3230 : : struct bnxt_tx_queue *txq;
3231 : : struct bnxt_rx_queue *rxq;
3232 : : struct bnxt_cp_ring_info *cpr;
3233 : :
3234 [ # # ]: 0 : if (i >= bp->rx_cp_nr_rings) {
3235 : 0 : txq = bp->tx_queues[i - bp->rx_cp_nr_rings];
3236 : 0 : cpr = txq->cp_ring;
3237 : : } else {
3238 : 0 : rxq = bp->rx_queues[i];
3239 : 0 : cpr = rxq->cp_ring;
3240 : : }
3241 : :
3242 : 0 : rc = bnxt_hwrm_stat_clear(bp, cpr);
3243 [ # # ]: 0 : if (rc)
3244 : 0 : return rc;
3245 : : }
3246 : : return 0;
3247 : : }
3248 : :
3249 : : static int
3250 : 0 : bnxt_free_all_hwrm_stat_ctxs(struct bnxt *bp)
3251 : : {
3252 : : int rc;
3253 : : unsigned int i;
3254 : : struct bnxt_cp_ring_info *cpr;
3255 : :
3256 [ # # ]: 0 : for (i = 0; i < bp->rx_cp_nr_rings; i++) {
3257 : :
3258 : 0 : cpr = bp->rx_queues[i]->cp_ring;
3259 [ # # ]: 0 : if (BNXT_HAS_RING_GRPS(bp))
3260 : 0 : bp->grp_info[i].fw_stats_ctx = -1;
3261 [ # # ]: 0 : if (cpr == NULL)
3262 : 0 : continue;
3263 : 0 : rc = bnxt_hwrm_stat_ctx_free(bp, cpr);
3264 [ # # ]: 0 : if (rc)
3265 : 0 : return rc;
3266 : : }
3267 : :
3268 [ # # ]: 0 : for (i = 0; i < bp->tx_cp_nr_rings; i++) {
3269 : 0 : cpr = bp->tx_queues[i]->cp_ring;
3270 [ # # ]: 0 : if (cpr == NULL)
3271 : 0 : continue;
3272 : 0 : rc = bnxt_hwrm_stat_ctx_free(bp, cpr);
3273 [ # # ]: 0 : if (rc)
3274 : 0 : return rc;
3275 : : }
3276 : :
3277 : : return 0;
3278 : : }
3279 : :
3280 : : static int
3281 : 0 : bnxt_free_all_hwrm_ring_grps(struct bnxt *bp)
3282 : : {
3283 : : uint16_t idx;
3284 : : uint32_t rc = 0;
3285 : :
3286 [ # # ]: 0 : if (!BNXT_HAS_RING_GRPS(bp))
3287 : : return 0;
3288 : :
3289 [ # # ]: 0 : for (idx = 0; idx < bp->rx_cp_nr_rings; idx++) {
3290 : :
3291 [ # # ]: 0 : if (bp->grp_info[idx].fw_grp_id == INVALID_HW_RING_ID)
3292 : 0 : continue;
3293 : :
3294 : 0 : rc = bnxt_hwrm_ring_grp_free(bp, idx);
3295 : :
3296 [ # # ]: 0 : if (rc)
3297 : 0 : return rc;
3298 : : }
3299 : 0 : return rc;
3300 : : }
3301 : :
3302 : 0 : void bnxt_free_nq_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
3303 : : {
3304 : 0 : struct bnxt_ring *cp_ring = cpr->cp_ring_struct;
3305 : :
3306 : 0 : bnxt_hwrm_ring_free(bp, cp_ring,
3307 : : HWRM_RING_FREE_INPUT_RING_TYPE_NQ,
3308 : : INVALID_HW_RING_ID);
3309 : 0 : memset(cpr->cp_desc_ring, 0,
3310 : 0 : cpr->cp_ring_struct->ring_size * sizeof(*cpr->cp_desc_ring));
3311 : 0 : cpr->cp_raw_cons = 0;
3312 : 0 : }
3313 : :
3314 : 0 : void bnxt_free_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
3315 : : {
3316 : 0 : struct bnxt_ring *cp_ring = cpr->cp_ring_struct;
3317 : :
3318 : 0 : bnxt_hwrm_ring_free(bp, cp_ring,
3319 : : HWRM_RING_FREE_INPUT_RING_TYPE_L2_CMPL,
3320 : : INVALID_HW_RING_ID);
3321 : 0 : memset(cpr->cp_desc_ring, 0,
3322 : 0 : cpr->cp_ring_struct->ring_size * sizeof(*cpr->cp_desc_ring));
3323 : 0 : cpr->cp_raw_cons = 0;
3324 : 0 : }
3325 : :
3326 : 0 : void bnxt_free_hwrm_rx_ring(struct bnxt *bp, int queue_index)
3327 : : {
3328 : 0 : struct bnxt_rx_queue *rxq = bp->rx_queues[queue_index];
3329 [ # # ]: 0 : struct bnxt_rx_ring_info *rxr = rxq ? rxq->rx_ring : NULL;
3330 [ # # ]: 0 : struct bnxt_ring *ring = rxr ? rxr->rx_ring_struct : NULL;
3331 [ # # ]: 0 : struct bnxt_cp_ring_info *cpr = rxq ? rxq->cp_ring : NULL;
3332 : :
3333 [ # # ]: 0 : if (BNXT_HAS_RING_GRPS(bp))
3334 : 0 : bnxt_hwrm_ring_grp_free(bp, queue_index);
3335 : :
3336 [ # # ]: 0 : if (ring != NULL && cpr != NULL)
3337 : 0 : bnxt_hwrm_ring_free(bp, ring,
3338 : : HWRM_RING_FREE_INPUT_RING_TYPE_RX,
3339 : 0 : cpr->cp_ring_struct->fw_ring_id);
3340 [ # # ]: 0 : if (BNXT_HAS_RING_GRPS(bp))
3341 : 0 : bp->grp_info[queue_index].rx_fw_ring_id = INVALID_HW_RING_ID;
3342 : :
3343 : : /* Check agg ring struct explicitly.
3344 : : * bnxt_need_agg_ring() returns the current state of offload flags,
3345 : : * but we may have to deal with agg ring struct before the offload
3346 : : * flags are updated.
3347 : : */
3348 [ # # # # ]: 0 : if (!bnxt_need_agg_ring(bp->eth_dev) ||
3349 [ # # ]: 0 : (rxr && rxr->ag_ring_struct == NULL))
3350 : 0 : goto no_agg;
3351 : :
3352 [ # # ]: 0 : ring = rxr ? rxr->ag_ring_struct : NULL;
3353 [ # # ]: 0 : if (ring != NULL && cpr != NULL) {
3354 : 0 : bnxt_hwrm_ring_free(bp, ring,
3355 : 0 : BNXT_CHIP_P5_P7(bp) ?
3356 : : HWRM_RING_FREE_INPUT_RING_TYPE_RX_AGG :
3357 : : HWRM_RING_FREE_INPUT_RING_TYPE_RX,
3358 [ # # ]: 0 : cpr->cp_ring_struct->fw_ring_id);
3359 : : }
3360 [ # # ]: 0 : if (BNXT_HAS_RING_GRPS(bp))
3361 : 0 : bp->grp_info[queue_index].ag_fw_ring_id = INVALID_HW_RING_ID;
3362 : :
3363 : 0 : no_agg:
3364 [ # # ]: 0 : if (cpr != NULL) {
3365 : 0 : bnxt_hwrm_stat_ctx_free(bp, cpr);
3366 : 0 : bnxt_free_cp_ring(bp, cpr);
3367 : : }
3368 : :
3369 [ # # ]: 0 : if (BNXT_HAS_RING_GRPS(bp))
3370 : 0 : bp->grp_info[queue_index].cp_fw_ring_id = INVALID_HW_RING_ID;
3371 : 0 : }
3372 : :
3373 : 0 : int bnxt_hwrm_rx_ring_reset(struct bnxt *bp, int queue_index)
3374 : : {
3375 : : int rc;
3376 : 0 : struct hwrm_ring_reset_input req = {.req_type = 0 };
3377 : 0 : struct hwrm_ring_reset_output *resp = bp->hwrm_cmd_resp_addr;
3378 : :
3379 [ # # ]: 0 : HWRM_PREP(&req, HWRM_RING_RESET, BNXT_USE_CHIMP_MB);
3380 : :
3381 : 0 : req.ring_type = HWRM_RING_RESET_INPUT_RING_TYPE_RX_RING_GRP;
3382 : 0 : req.ring_id = rte_cpu_to_le_16(bp->grp_info[queue_index].fw_grp_id);
3383 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3384 : :
3385 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
3386 : :
3387 : : HWRM_UNLOCK();
3388 : :
3389 : 0 : return rc;
3390 : : }
3391 : :
3392 : : static int
3393 : 0 : bnxt_free_all_hwrm_rings(struct bnxt *bp)
3394 : : {
3395 : : unsigned int i;
3396 : :
3397 [ # # ]: 0 : for (i = 0; i < bp->tx_cp_nr_rings; i++)
3398 : 0 : bnxt_free_hwrm_tx_ring(bp, i);
3399 : :
3400 [ # # ]: 0 : for (i = 0; i < bp->rx_cp_nr_rings; i++)
3401 : 0 : bnxt_free_hwrm_rx_ring(bp, i);
3402 : :
3403 : 0 : return 0;
3404 : : }
3405 : :
3406 : 0 : int bnxt_alloc_all_hwrm_ring_grps(struct bnxt *bp)
3407 : : {
3408 : : uint16_t i;
3409 : : uint32_t rc = 0;
3410 : :
3411 [ # # ]: 0 : if (!BNXT_HAS_RING_GRPS(bp))
3412 : : return 0;
3413 : :
3414 [ # # ]: 0 : for (i = 0; i < bp->rx_cp_nr_rings; i++) {
3415 : 0 : rc = bnxt_hwrm_ring_grp_alloc(bp, i);
3416 [ # # ]: 0 : if (rc)
3417 : 0 : return rc;
3418 : : }
3419 : : return rc;
3420 : : }
3421 : :
3422 : : /*
3423 : : * HWRM utility functions
3424 : : */
3425 : :
3426 : 0 : void bnxt_free_hwrm_resources(struct bnxt *bp)
3427 : : {
3428 : : /* Release memzone */
3429 : 0 : rte_free(bp->hwrm_cmd_resp_addr);
3430 : 0 : rte_free(bp->hwrm_short_cmd_req_addr);
3431 : 0 : bp->hwrm_cmd_resp_addr = NULL;
3432 : 0 : bp->hwrm_short_cmd_req_addr = NULL;
3433 : 0 : bp->hwrm_cmd_resp_dma_addr = 0;
3434 : 0 : bp->hwrm_short_cmd_req_dma_addr = 0;
3435 : 0 : }
3436 : :
3437 : 0 : int bnxt_alloc_hwrm_resources(struct bnxt *bp)
3438 : : {
3439 : 0 : struct rte_pci_device *pdev = bp->pdev;
3440 : : char type[RTE_MEMZONE_NAMESIZE];
3441 : :
3442 : 0 : sprintf(type, "bnxt_hwrm_" PCI_PRI_FMT, pdev->addr.domain,
3443 : 0 : pdev->addr.bus, pdev->addr.devid, pdev->addr.function);
3444 : 0 : bp->max_resp_len = BNXT_PAGE_SIZE;
3445 : 0 : bp->hwrm_cmd_resp_addr = rte_malloc(type, bp->max_resp_len, 0);
3446 [ # # ]: 0 : if (bp->hwrm_cmd_resp_addr == NULL)
3447 : : return -ENOMEM;
3448 : 0 : bp->hwrm_cmd_resp_dma_addr =
3449 : 0 : rte_malloc_virt2iova(bp->hwrm_cmd_resp_addr);
3450 [ # # ]: 0 : if (bp->hwrm_cmd_resp_dma_addr == RTE_BAD_IOVA) {
3451 : 0 : PMD_DRV_LOG(ERR,
3452 : : "unable to map response address to physical memory\n");
3453 : 0 : return -ENOMEM;
3454 : : }
3455 : : rte_spinlock_init(&bp->hwrm_lock);
3456 : :
3457 : 0 : return 0;
3458 : : }
3459 : :
3460 : : int
3461 : 0 : bnxt_clear_one_vnic_filter(struct bnxt *bp, struct bnxt_filter_info *filter)
3462 : : {
3463 : : int rc = 0;
3464 : :
3465 [ # # ]: 0 : if (filter->filter_type == HWRM_CFA_EM_FILTER) {
3466 : 0 : rc = bnxt_hwrm_clear_em_filter(bp, filter);
3467 [ # # ]: 0 : if (rc)
3468 : : return rc;
3469 [ # # ]: 0 : } else if (filter->filter_type == HWRM_CFA_NTUPLE_FILTER) {
3470 : 0 : rc = bnxt_hwrm_clear_ntuple_filter(bp, filter);
3471 [ # # ]: 0 : if (rc)
3472 : : return rc;
3473 : : }
3474 : :
3475 : 0 : rc = bnxt_hwrm_clear_l2_filter(bp, filter);
3476 : 0 : return rc;
3477 : : }
3478 : :
3479 : : static int
3480 : 0 : bnxt_clear_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic)
3481 : : {
3482 : : struct bnxt_filter_info *filter;
3483 : : int rc = 0;
3484 : :
3485 [ # # ]: 0 : STAILQ_FOREACH(filter, &vnic->filter, next) {
3486 : 0 : rc = bnxt_clear_one_vnic_filter(bp, filter);
3487 [ # # # # : 0 : STAILQ_REMOVE(&vnic->filter, filter, bnxt_filter_info, next);
# # # # ]
3488 : 0 : bnxt_free_filter(bp, filter);
3489 : : }
3490 : 0 : return rc;
3491 : : }
3492 : :
3493 : : static int
3494 : 0 : bnxt_clear_hwrm_vnic_flows(struct bnxt *bp, struct bnxt_vnic_info *vnic)
3495 : : {
3496 : : struct bnxt_filter_info *filter;
3497 : : struct rte_flow *flow;
3498 : : int rc = 0;
3499 : :
3500 [ # # ]: 0 : while (!STAILQ_EMPTY(&vnic->flow_list)) {
3501 : : flow = STAILQ_FIRST(&vnic->flow_list);
3502 : 0 : filter = flow->filter;
3503 : 0 : PMD_DRV_LOG(DEBUG, "filter type %d\n", filter->filter_type);
3504 : 0 : rc = bnxt_clear_one_vnic_filter(bp, filter);
3505 : :
3506 [ # # # # : 0 : STAILQ_REMOVE(&vnic->flow_list, flow, rte_flow, next);
# # # # ]
3507 : 0 : rte_free(flow);
3508 : : }
3509 : 0 : return rc;
3510 : : }
3511 : :
3512 : 0 : int bnxt_set_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic)
3513 : : {
3514 : : struct bnxt_filter_info *filter;
3515 : : int rc = 0;
3516 : :
3517 [ # # ]: 0 : STAILQ_FOREACH(filter, &vnic->filter, next) {
3518 [ # # ]: 0 : if (filter->filter_type == HWRM_CFA_EM_FILTER)
3519 : 0 : rc = bnxt_hwrm_set_em_filter(bp, filter->dst_id,
3520 : : filter);
3521 [ # # ]: 0 : else if (filter->filter_type == HWRM_CFA_NTUPLE_FILTER)
3522 : 0 : rc = bnxt_hwrm_set_ntuple_filter(bp, filter->dst_id,
3523 : : filter);
3524 : : else
3525 : 0 : rc = bnxt_hwrm_set_l2_filter(bp, vnic->fw_vnic_id,
3526 : : filter);
3527 [ # # ]: 0 : if (rc)
3528 : : break;
3529 : : }
3530 : 0 : return rc;
3531 : : }
3532 : :
3533 : : static void
3534 : 0 : bnxt_free_tunnel_ports(struct bnxt *bp)
3535 : : {
3536 [ # # ]: 0 : if (bp->vxlan_port_cnt)
3537 : 0 : bnxt_hwrm_tunnel_dst_port_free(bp, bp->vxlan_fw_dst_port_id,
3538 : : HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_VXLAN);
3539 : :
3540 [ # # ]: 0 : if (bp->geneve_port_cnt)
3541 : 0 : bnxt_hwrm_tunnel_dst_port_free(bp, bp->geneve_fw_dst_port_id,
3542 : : HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_GENEVE);
3543 : :
3544 [ # # ]: 0 : if (bp->ecpri_port_cnt)
3545 : 0 : bnxt_hwrm_tunnel_dst_port_free(bp, bp->ecpri_fw_dst_port_id,
3546 : : HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_ECPRI);
3547 : 0 : }
3548 : :
3549 : 0 : void bnxt_free_all_hwrm_resources(struct bnxt *bp)
3550 : : {
3551 : : int i;
3552 : :
3553 [ # # ]: 0 : if (bp->vnic_info == NULL)
3554 : : return;
3555 : :
3556 : : /*
3557 : : * Cleanup VNICs in reverse order, to make sure the L2 filter
3558 : : * from vnic0 is last to be cleaned up.
3559 : : */
3560 [ # # ]: 0 : for (i = bp->max_vnics - 1; i >= 0; i--) {
3561 : 0 : struct bnxt_vnic_info *vnic = &bp->vnic_info[i];
3562 : :
3563 [ # # ]: 0 : if (vnic->fw_vnic_id == INVALID_HW_RING_ID)
3564 : 0 : continue;
3565 : :
3566 [ # # # # ]: 0 : if (vnic->func_default && (bp->flags & BNXT_FLAG_DFLT_VNIC_SET))
3567 : 0 : bnxt_hwrm_cfa_l2_clear_rx_mask(bp, vnic);
3568 : 0 : bnxt_clear_hwrm_vnic_flows(bp, vnic);
3569 : :
3570 : 0 : bnxt_clear_hwrm_vnic_filters(bp, vnic);
3571 : :
3572 : 0 : bnxt_hwrm_vnic_tpa_cfg(bp, vnic, false);
3573 : :
3574 : 0 : bnxt_hwrm_vnic_free(bp, vnic);
3575 : :
3576 : 0 : bnxt_hwrm_vnic_ctx_free(bp, vnic);
3577 : :
3578 : 0 : rte_free(vnic->fw_grp_ids);
3579 : 0 : vnic->fw_grp_ids = NULL;
3580 [ # # # # ]: 0 : if (vnic->ref_cnt && !vnic->rx_queue_cnt)
3581 : 0 : vnic->ref_cnt--;
3582 : : }
3583 : : /* Ring resources */
3584 : 0 : bnxt_free_all_hwrm_rings(bp);
3585 : 0 : bnxt_free_all_hwrm_ring_grps(bp);
3586 : 0 : bnxt_free_all_hwrm_stat_ctxs(bp);
3587 : 0 : bnxt_free_tunnel_ports(bp);
3588 : : }
3589 : :
3590 : : static uint16_t bnxt_parse_eth_link_duplex(uint32_t conf_link_speed)
3591 : : {
3592 : : uint8_t hw_link_duplex = HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_BOTH;
3593 : :
3594 : 0 : if ((conf_link_speed & RTE_ETH_LINK_SPEED_FIXED) == RTE_ETH_LINK_SPEED_AUTONEG)
3595 : : return HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_BOTH;
3596 : :
3597 [ # # # # ]: 0 : switch (conf_link_speed) {
3598 : : case RTE_ETH_LINK_SPEED_10M_HD:
3599 : : case RTE_ETH_LINK_SPEED_100M_HD:
3600 : : /* FALLTHROUGH */
3601 : : return HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_HALF;
3602 : : }
3603 : 0 : return hw_link_duplex;
3604 : : }
3605 : :
3606 : : static uint16_t bnxt_check_eth_link_autoneg(uint32_t conf_link)
3607 : : {
3608 : 0 : return !conf_link;
3609 : : }
3610 : :
3611 : : static uint16_t bnxt_parse_eth_link_speed_v2(uint32_t conf_link_speed)
3612 : : {
3613 : : /* get bitmap value based on speed */
3614 : : return ((struct link_speeds2_tbl *)
3615 : 0 : bnxt_get_rte_hwrm_speeds2_entry(conf_link_speed))->force_val;
3616 : : }
3617 : :
3618 : 0 : static uint16_t bnxt_parse_eth_link_speed(struct bnxt *bp, uint32_t conf_link_speed,
3619 : : struct bnxt_link_info *link_info)
3620 : : {
3621 : 0 : uint16_t support_pam4_speeds = link_info->support_pam4_speeds;
3622 : 0 : uint16_t support_speeds = link_info->support_speeds;
3623 : : uint16_t eth_link_speed = 0;
3624 : :
3625 [ # # ]: 0 : if (conf_link_speed == RTE_ETH_LINK_SPEED_AUTONEG)
3626 : : return RTE_ETH_LINK_SPEED_AUTONEG;
3627 : :
3628 : : /* Handle P7 chips saperately. It got enhanced phy attribs to choose from */
3629 [ # # # # : 0 : if (BNXT_LINK_SPEEDS_V2(bp))
# # # # ]
3630 : 0 : return bnxt_parse_eth_link_speed_v2(conf_link_speed);
3631 : :
3632 [ # # # # : 0 : switch (conf_link_speed & ~RTE_ETH_LINK_SPEED_FIXED) {
# # # # #
# # ]
3633 : : case RTE_ETH_LINK_SPEED_100M:
3634 : : case RTE_ETH_LINK_SPEED_100M_HD:
3635 : : /* FALLTHROUGH */
3636 : : eth_link_speed =
3637 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_100MB;
3638 : : break;
3639 : 0 : case RTE_ETH_LINK_SPEED_1G:
3640 : : eth_link_speed =
3641 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_1GB;
3642 : 0 : break;
3643 : 0 : case RTE_ETH_LINK_SPEED_2_5G:
3644 : : eth_link_speed =
3645 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_2_5GB;
3646 : 0 : break;
3647 : 0 : case RTE_ETH_LINK_SPEED_10G:
3648 : : eth_link_speed =
3649 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_10GB;
3650 : 0 : break;
3651 : 0 : case RTE_ETH_LINK_SPEED_20G:
3652 : : eth_link_speed =
3653 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_20GB;
3654 : 0 : break;
3655 : 0 : case RTE_ETH_LINK_SPEED_25G:
3656 : : eth_link_speed =
3657 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_25GB;
3658 : 0 : link_info->link_signal_mode = BNXT_SIG_MODE_NRZ;
3659 : 0 : break;
3660 : 0 : case RTE_ETH_LINK_SPEED_40G:
3661 : : eth_link_speed =
3662 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_40GB;
3663 : 0 : break;
3664 : 0 : case RTE_ETH_LINK_SPEED_50G:
3665 [ # # ]: 0 : if (support_speeds & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_50GB) {
3666 : : eth_link_speed = HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_50GB;
3667 : 0 : link_info->link_signal_mode = BNXT_SIG_MODE_NRZ;
3668 [ # # ]: 0 : } else if (support_pam4_speeds &
3669 : : HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_PAM4_SPEEDS_50G) {
3670 : : eth_link_speed = HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_50GB;
3671 : 0 : link_info->link_signal_mode = BNXT_SIG_MODE_PAM4;
3672 : : }
3673 : : break;
3674 : 0 : case RTE_ETH_LINK_SPEED_100G:
3675 [ # # ]: 0 : if (support_speeds & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_100GB) {
3676 : : eth_link_speed = HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_100GB;
3677 : 0 : link_info->link_signal_mode = BNXT_SIG_MODE_NRZ;
3678 [ # # ]: 0 : } else if (support_pam4_speeds &
3679 : : HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_PAM4_SPEEDS_100G) {
3680 : : eth_link_speed = HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_100GB;
3681 : 0 : link_info->link_signal_mode = BNXT_SIG_MODE_PAM4;
3682 : : }
3683 : : break;
3684 : 0 : case RTE_ETH_LINK_SPEED_200G:
3685 : : eth_link_speed =
3686 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_200GB;
3687 : 0 : link_info->link_signal_mode = BNXT_SIG_MODE_PAM4;
3688 : 0 : break;
3689 : 0 : default:
3690 : 0 : PMD_DRV_LOG(ERR,
3691 : : "Unsupported link speed %d; default to AUTO\n",
3692 : : conf_link_speed);
3693 : 0 : break;
3694 : : }
3695 : : return eth_link_speed;
3696 : : }
3697 : :
3698 : : #define BNXT_SUPPORTED_SPEEDS (RTE_ETH_LINK_SPEED_100M | RTE_ETH_LINK_SPEED_100M_HD | \
3699 : : RTE_ETH_LINK_SPEED_1G | RTE_ETH_LINK_SPEED_2_5G | \
3700 : : RTE_ETH_LINK_SPEED_10G | RTE_ETH_LINK_SPEED_20G | RTE_ETH_LINK_SPEED_25G | \
3701 : : RTE_ETH_LINK_SPEED_40G | RTE_ETH_LINK_SPEED_50G | \
3702 : : RTE_ETH_LINK_SPEED_100G | RTE_ETH_LINK_SPEED_200G)
3703 : : #define BNXT_SUPPORTED_SPEEDS2 ((BNXT_SUPPORTED_SPEEDS | RTE_ETH_LINK_SPEED_400G) & \
3704 : : ~(RTE_ETH_LINK_SPEED_100M | RTE_ETH_LINK_SPEED_100M_HD | \
3705 : : RTE_ETH_LINK_SPEED_2_5G | RTE_ETH_LINK_SPEED_20G))
3706 : :
3707 : 0 : static int bnxt_validate_link_speed(struct bnxt *bp)
3708 : : {
3709 : 0 : uint32_t link_speed = bp->eth_dev->data->dev_conf.link_speeds;
3710 : 0 : uint16_t port_id = bp->eth_dev->data->port_id;
3711 : : uint32_t link_speed_capa;
3712 : : uint32_t one_speed;
3713 : :
3714 [ # # ]: 0 : if (link_speed == RTE_ETH_LINK_SPEED_AUTONEG)
3715 : : return 0;
3716 : :
3717 : 0 : link_speed_capa = bnxt_get_speed_capabilities(bp);
3718 : :
3719 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_FIXED) {
3720 : 0 : one_speed = link_speed & ~RTE_ETH_LINK_SPEED_FIXED;
3721 : :
3722 [ # # ]: 0 : if (one_speed & (one_speed - 1)) {
3723 : 0 : PMD_DRV_LOG(ERR,
3724 : : "Invalid advertised speeds (%u) for port %u\n",
3725 : : link_speed, port_id);
3726 : 0 : return -EINVAL;
3727 : : }
3728 [ # # ]: 0 : if ((one_speed & link_speed_capa) != one_speed) {
3729 : 0 : PMD_DRV_LOG(ERR,
3730 : : "Unsupported advertised speed (%u) for port %u\n",
3731 : : link_speed, port_id);
3732 : 0 : return -EINVAL;
3733 : : }
3734 : : } else {
3735 [ # # ]: 0 : if (!(link_speed & link_speed_capa)) {
3736 : 0 : PMD_DRV_LOG(ERR,
3737 : : "Unsupported advertised speeds (%u) for port %u\n",
3738 : : link_speed, port_id);
3739 : 0 : return -EINVAL;
3740 : : }
3741 : : }
3742 : : return 0;
3743 : : }
3744 : :
3745 : : static uint16_t
3746 : : bnxt_parse_eth_link_speed_mask_v2(struct bnxt *bp, uint32_t link_speed)
3747 : : {
3748 : : uint16_t ret = 0;
3749 : :
3750 [ # # ]: 0 : if (link_speed == RTE_ETH_LINK_SPEED_AUTONEG)
3751 : 0 : return bp->link_info->supported_speeds2_auto_mode;
3752 : :
3753 : : return ret;
3754 : : }
3755 : :
3756 : : static uint16_t
3757 : 0 : bnxt_parse_eth_link_speed_mask(struct bnxt *bp, uint32_t link_speed)
3758 : : {
3759 : : uint16_t ret = 0;
3760 : :
3761 [ # # # # : 0 : if (BNXT_LINK_SPEEDS_V2(bp))
# # # # ]
3762 : 0 : return bnxt_parse_eth_link_speed_mask_v2(bp, link_speed);
3763 : :
3764 [ # # ]: 0 : if (link_speed == RTE_ETH_LINK_SPEED_AUTONEG) {
3765 [ # # ]: 0 : if (bp->link_info->support_speeds)
3766 : : return bp->link_info->support_speeds;
3767 : : link_speed = BNXT_SUPPORTED_SPEEDS;
3768 : : }
3769 : :
3770 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_100M)
3771 : : ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_100MB;
3772 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_100M_HD)
3773 : : ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_100MB;
3774 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_1G)
3775 : 0 : ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_1GB;
3776 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_2_5G)
3777 : 0 : ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_2_5GB;
3778 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_10G)
3779 : 0 : ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_10GB;
3780 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_20G)
3781 : 0 : ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_20GB;
3782 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_25G)
3783 : 0 : ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_25GB;
3784 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_40G)
3785 : 0 : ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_40GB;
3786 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_50G)
3787 : 0 : ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_50GB;
3788 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_100G)
3789 : 0 : ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_100GB;
3790 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_200G)
3791 : 0 : ret |= HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_200GB;
3792 : : return ret;
3793 : : }
3794 : :
3795 : : static uint32_t bnxt_parse_hw_link_speed_v2(uint16_t hw_link_speed)
3796 : : {
3797 : : return ((struct link_speeds2_tbl *)
3798 : 0 : bnxt_get_hwrm_to_rte_speeds2_entry(hw_link_speed))->rte_speed_num;
3799 : : }
3800 : :
3801 : 0 : static uint32_t bnxt_parse_hw_link_speed(struct bnxt *bp, uint16_t hw_link_speed)
3802 : : {
3803 : : uint32_t eth_link_speed = RTE_ETH_SPEED_NUM_NONE;
3804 : :
3805 : : /* query fixed speed2 table if not autoneg */
3806 [ # # # # : 0 : if (BNXT_LINK_SPEEDS_V2(bp) && !bp->link_info->auto_mode)
# # # # #
# ]
3807 : 0 : return bnxt_parse_hw_link_speed_v2(hw_link_speed);
3808 : :
3809 : : /* for P7 and earlier nics link_speed carries AN'd speed */
3810 [ # # # # : 0 : switch (hw_link_speed) {
# # # # #
# # # ]
3811 : : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100MB:
3812 : : eth_link_speed = RTE_ETH_SPEED_NUM_100M;
3813 : : break;
3814 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_1GB:
3815 : : eth_link_speed = RTE_ETH_SPEED_NUM_1G;
3816 : 0 : break;
3817 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2_5GB:
3818 : : eth_link_speed = RTE_ETH_SPEED_NUM_2_5G;
3819 : 0 : break;
3820 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_10GB:
3821 : : eth_link_speed = RTE_ETH_SPEED_NUM_10G;
3822 : 0 : break;
3823 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_20GB:
3824 : : eth_link_speed = RTE_ETH_SPEED_NUM_20G;
3825 : 0 : break;
3826 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_25GB:
3827 : : eth_link_speed = RTE_ETH_SPEED_NUM_25G;
3828 : 0 : break;
3829 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_40GB:
3830 : : eth_link_speed = RTE_ETH_SPEED_NUM_40G;
3831 : 0 : break;
3832 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_50GB:
3833 : : eth_link_speed = RTE_ETH_SPEED_NUM_50G;
3834 : 0 : break;
3835 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100GB:
3836 : : eth_link_speed = RTE_ETH_SPEED_NUM_100G;
3837 : 0 : break;
3838 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_200GB:
3839 : : eth_link_speed = RTE_ETH_SPEED_NUM_200G;
3840 : 0 : break;
3841 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_400GB:
3842 : : eth_link_speed = RTE_ETH_SPEED_NUM_400G;
3843 : 0 : break;
3844 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2GB:
3845 : : default:
3846 : 0 : PMD_DRV_LOG(ERR, "HWRM link speed %d not defined\n",
3847 : : hw_link_speed);
3848 : 0 : break;
3849 : : }
3850 : : return eth_link_speed;
3851 : : }
3852 : :
3853 : 0 : static uint16_t bnxt_parse_hw_link_duplex(uint16_t hw_link_duplex)
3854 : : {
3855 : : uint16_t eth_link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
3856 : :
3857 [ # # # ]: 0 : switch (hw_link_duplex) {
3858 : : case HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_BOTH:
3859 : : case HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_FULL:
3860 : : /* FALLTHROUGH */
3861 : : eth_link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
3862 : : break;
3863 : 0 : case HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_HALF:
3864 : : eth_link_duplex = RTE_ETH_LINK_HALF_DUPLEX;
3865 : 0 : break;
3866 : 0 : default:
3867 : 0 : PMD_DRV_LOG(ERR, "HWRM link duplex %d not defined\n",
3868 : : hw_link_duplex);
3869 : 0 : break;
3870 : : }
3871 : 0 : return eth_link_duplex;
3872 : : }
3873 : :
3874 : 0 : int bnxt_get_hwrm_link_config(struct bnxt *bp, struct rte_eth_link *link)
3875 : : {
3876 : : int rc = 0;
3877 : 0 : struct bnxt_link_info *link_info = bp->link_info;
3878 : :
3879 : 0 : rc = bnxt_hwrm_port_phy_qcaps(bp);
3880 [ # # ]: 0 : if (rc)
3881 : 0 : PMD_DRV_LOG(ERR, "Get link config failed with rc %d\n", rc);
3882 : :
3883 : 0 : rc = bnxt_hwrm_port_phy_qcfg(bp, link_info);
3884 [ # # ]: 0 : if (rc) {
3885 : 0 : PMD_DRV_LOG(ERR, "Get link config failed with rc %d\n", rc);
3886 : 0 : goto exit;
3887 : : }
3888 : :
3889 [ # # ]: 0 : if (link_info->link_speed)
3890 : 0 : link->link_speed = bnxt_parse_hw_link_speed(bp, link_info->link_speed);
3891 : : else
3892 : 0 : link->link_speed = RTE_ETH_SPEED_NUM_NONE;
3893 : 0 : link->link_duplex = bnxt_parse_hw_link_duplex(link_info->duplex);
3894 : 0 : link->link_status = link_info->link_up;
3895 : 0 : link->link_autoneg = link_info->auto_mode ==
3896 : : HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_NONE ?
3897 : 0 : RTE_ETH_LINK_FIXED : RTE_ETH_LINK_AUTONEG;
3898 : 0 : exit:
3899 : 0 : return rc;
3900 : : }
3901 : :
3902 : 0 : static int bnxt_hwrm_port_phy_cfg_v2(struct bnxt *bp, struct bnxt_link_info *conf)
3903 : : {
3904 : 0 : struct hwrm_port_phy_cfg_output *resp = bp->hwrm_cmd_resp_addr;
3905 : 0 : struct hwrm_port_phy_cfg_input req = {0};
3906 : : uint32_t enables = 0;
3907 : : int rc = 0;
3908 : :
3909 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_PHY_CFG, BNXT_USE_CHIMP_MB);
3910 : :
3911 [ # # ]: 0 : if (!conf->link_up) {
3912 : 0 : req.flags =
3913 : : rte_cpu_to_le_32(HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE_LINK_DWN);
3914 : 0 : PMD_DRV_LOG(ERR, "Force Link Down\n");
3915 : 0 : goto link_down;
3916 : : }
3917 : :
3918 : : /* Setting Fixed Speed. But AutoNeg is ON, So disable it */
3919 [ # # # # ]: 0 : if (bp->link_info->auto_mode && conf->link_speed) {
3920 : 0 : req.auto_mode = HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_NONE;
3921 : 0 : PMD_DRV_LOG(DEBUG, "Disabling AutoNeg\n");
3922 : : }
3923 : 0 : req.flags = rte_cpu_to_le_32(conf->phy_flags);
3924 [ # # ]: 0 : if (!conf->link_speed) {
3925 : : /* No speeds specified. Enable AutoNeg - all speeds */
3926 : : enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_LINK_SPEEDS2_MASK;
3927 : : enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_MODE;
3928 : 0 : req.auto_mode = HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_SPEED_MASK;
3929 : 0 : req.auto_link_speeds2_mask =
3930 : 0 : rte_cpu_to_le_16(bp->link_info->supported_speeds2_auto_mode);
3931 : : } else {
3932 : : enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_FORCE_LINK_SPEEDS2;
3933 : 0 : req.force_link_speeds2 = rte_cpu_to_le_16(conf->link_speed);
3934 : : }
3935 : :
3936 : : /* Fill rest of the req message */
3937 : 0 : req.auto_duplex = conf->duplex;
3938 [ # # ]: 0 : if (req.auto_mode != HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_SPEED_MASK)
3939 : 0 : enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_DUPLEX;
3940 : 0 : req.auto_pause = conf->auto_pause;
3941 : 0 : req.force_pause = conf->force_pause;
3942 [ # # ]: 0 : if (req.auto_pause)
3943 : 0 : req.force_pause = 0;
3944 : : /* Set force_pause if there is no auto or if there is a force */
3945 [ # # # # ]: 0 : if (req.auto_pause && !req.force_pause)
3946 : 0 : enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_PAUSE;
3947 : : else
3948 : 0 : enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_FORCE_PAUSE;
3949 : 0 : req.enables = rte_cpu_to_le_32(enables);
3950 : :
3951 : 0 : link_down:
3952 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3953 : :
3954 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
3955 : : HWRM_UNLOCK();
3956 : 0 : return rc;
3957 : : }
3958 : :
3959 : 0 : static int bnxt_set_hwrm_link_config_v2(struct bnxt *bp, bool link_up)
3960 : : {
3961 [ # # ]: 0 : struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf;
3962 : : struct bnxt_link_info link_req;
3963 : : uint16_t speed, autoneg;
3964 : : int rc = 0;
3965 : :
3966 : : memset(&link_req, 0, sizeof(link_req));
3967 : 0 : link_req.link_up = link_up;
3968 [ # # ]: 0 : if (!link_up)
3969 : 0 : goto port_phy_cfg;
3970 : :
3971 : 0 : autoneg = bnxt_check_eth_link_autoneg(dev_conf->link_speeds);
3972 : 0 : speed = bnxt_parse_eth_link_speed(bp, dev_conf->link_speeds,
3973 : : bp->link_info);
3974 : 0 : link_req.phy_flags = HWRM_PORT_PHY_CFG_INPUT_FLAGS_RESET_PHY;
3975 [ # # ]: 0 : if (autoneg == 1) {
3976 : 0 : link_req.phy_flags |=
3977 : : HWRM_PORT_PHY_CFG_INPUT_FLAGS_RESTART_AUTONEG;
3978 : 0 : link_req.cfg_auto_link_speeds2_mask =
3979 : 0 : bnxt_parse_eth_link_speed_mask(bp, dev_conf->link_speeds);
3980 : : } else {
3981 : 0 : if (bp->link_info->phy_type ==
3982 [ # # ]: 0 : HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASET ||
3983 : : bp->link_info->phy_type ==
3984 : 0 : HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASETE ||
3985 [ # # ]: 0 : bp->link_info->media_type ==
3986 : : HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_TP) {
3987 : 0 : PMD_DRV_LOG(ERR, "10GBase-T devices must autoneg\n");
3988 : 0 : return -EINVAL;
3989 : : }
3990 : :
3991 : 0 : link_req.phy_flags |= HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE;
3992 : : /* If user wants a particular speed try that first. */
3993 : 0 : link_req.link_speed = speed;
3994 : : }
3995 [ # # ]: 0 : link_req.duplex = bnxt_parse_eth_link_duplex(dev_conf->link_speeds);
3996 : 0 : link_req.auto_pause = bp->link_info->auto_pause;
3997 : 0 : link_req.force_pause = bp->link_info->force_pause;
3998 : :
3999 : 0 : port_phy_cfg:
4000 : 0 : rc = bnxt_hwrm_port_phy_cfg_v2(bp, &link_req);
4001 [ # # ]: 0 : if (rc)
4002 : 0 : PMD_DRV_LOG(ERR, "Set link config failed with rc %d\n", rc);
4003 : :
4004 : : return rc;
4005 : : }
4006 : :
4007 : 0 : int bnxt_set_hwrm_link_config(struct bnxt *bp, bool link_up)
4008 : : {
4009 : : int rc = 0;
4010 : 0 : struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf;
4011 : : struct bnxt_link_info link_req;
4012 : : uint16_t speed, autoneg;
4013 : :
4014 [ # # ]: 0 : if (!BNXT_SINGLE_PF(bp) || BNXT_VF(bp))
4015 : : return 0;
4016 : :
4017 : 0 : rc = bnxt_validate_link_speed(bp);
4018 [ # # ]: 0 : if (rc)
4019 : 0 : goto error;
4020 : :
4021 [ # # # # : 0 : if (BNXT_LINK_SPEEDS_V2(bp))
# # # # ]
4022 : 0 : return bnxt_set_hwrm_link_config_v2(bp, link_up);
4023 : :
4024 : : memset(&link_req, 0, sizeof(link_req));
4025 : 0 : link_req.link_up = link_up;
4026 [ # # ]: 0 : if (!link_up)
4027 : 0 : goto port_phy_cfg;
4028 : :
4029 : : /* Get user requested autoneg setting */
4030 : 0 : autoneg = bnxt_check_eth_link_autoneg(dev_conf->link_speeds);
4031 [ # # ]: 0 : if (BNXT_CHIP_P5_P7(bp) &&
4032 [ # # ]: 0 : dev_conf->link_speeds & RTE_ETH_LINK_SPEED_40G) {
4033 : : /* 40G is not supported as part of media auto detect.
4034 : : * The speed should be forced and autoneg disabled
4035 : : * to configure 40G speed.
4036 : : */
4037 : 0 : PMD_DRV_LOG(INFO, "Disabling autoneg for 40G\n");
4038 : : autoneg = 0;
4039 : : }
4040 : :
4041 : : /* Override based on current Autoneg setting in PHY for 200G */
4042 [ # # # # : 0 : if (autoneg == 1 && BNXT_CHIP_P5(bp) && bp->link_info->auto_mode == 0 &&
# # ]
4043 [ # # ]: 0 : bp->link_info->force_pam4_link_speed ==
4044 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_200GB) {
4045 : : autoneg = 0;
4046 : 0 : PMD_DRV_LOG(DEBUG, "Disabling autoneg for 200G\n");
4047 : : }
4048 : :
4049 : 0 : speed = bnxt_parse_eth_link_speed(bp, dev_conf->link_speeds,
4050 : : bp->link_info);
4051 : 0 : link_req.phy_flags = HWRM_PORT_PHY_CFG_INPUT_FLAGS_RESET_PHY;
4052 : : /* Autoneg can be done only when the FW allows. */
4053 [ # # ]: 0 : if (autoneg == 1 &&
4054 [ # # # # ]: 0 : (bp->link_info->support_auto_speeds || bp->link_info->support_pam4_auto_speeds)) {
4055 : 0 : link_req.phy_flags |=
4056 : : HWRM_PORT_PHY_CFG_INPUT_FLAGS_RESTART_AUTONEG;
4057 : 0 : link_req.auto_link_speed_mask =
4058 : 0 : bnxt_parse_eth_link_speed_mask(bp,
4059 : : dev_conf->link_speeds);
4060 : 0 : link_req.auto_pam4_link_speed_mask =
4061 : 0 : bp->link_info->auto_pam4_link_speed_mask;
4062 : : } else {
4063 : 0 : if (bp->link_info->phy_type ==
4064 [ # # ]: 0 : HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASET ||
4065 : : bp->link_info->phy_type ==
4066 : 0 : HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASETE ||
4067 [ # # ]: 0 : bp->link_info->media_type ==
4068 : : HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_TP) {
4069 : 0 : PMD_DRV_LOG(ERR, "10GBase-T devices must autoneg\n");
4070 : 0 : return -EINVAL;
4071 : : }
4072 : :
4073 : 0 : link_req.phy_flags |= HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE;
4074 : : /* If user wants a particular speed try that first. */
4075 [ # # ]: 0 : if (speed)
4076 : 0 : link_req.link_speed = speed;
4077 [ # # ]: 0 : else if (bp->link_info->force_pam4_link_speed)
4078 : 0 : link_req.link_speed =
4079 : : bp->link_info->force_pam4_link_speed;
4080 [ # # ]: 0 : else if (bp->link_info->force_link_speed)
4081 : 0 : link_req.link_speed = bp->link_info->force_link_speed;
4082 [ # # ]: 0 : else if (bp->link_info->auto_pam4_link_speed_mask)
4083 : 0 : link_req.link_speed =
4084 : : bp->link_info->auto_pam4_link_speed_mask;
4085 [ # # ]: 0 : else if (bp->link_info->support_pam4_speeds)
4086 : 0 : link_req.link_speed =
4087 : : bp->link_info->support_pam4_speeds;
4088 : : else
4089 : 0 : link_req.link_speed = bp->link_info->auto_link_speed;
4090 : : /* Auto PAM4 link speed is zero, but auto_link_speed is not
4091 : : * zero. Use the auto_link_speed.
4092 : : */
4093 [ # # ]: 0 : if (bp->link_info->auto_link_speed != 0 &&
4094 [ # # ]: 0 : bp->link_info->auto_pam4_link_speed_mask == 0)
4095 : 0 : link_req.link_speed = bp->link_info->auto_link_speed;
4096 : : }
4097 [ # # ]: 0 : link_req.duplex = bnxt_parse_eth_link_duplex(dev_conf->link_speeds);
4098 : 0 : link_req.auto_pause = bp->link_info->auto_pause;
4099 : 0 : link_req.force_pause = bp->link_info->force_pause;
4100 : :
4101 : 0 : port_phy_cfg:
4102 : 0 : rc = bnxt_hwrm_port_phy_cfg(bp, &link_req);
4103 [ # # ]: 0 : if (rc) {
4104 : 0 : PMD_DRV_LOG(ERR,
4105 : : "Set link config failed with rc %d\n", rc);
4106 : : }
4107 : :
4108 : 0 : error:
4109 : : return rc;
4110 : : }
4111 : :
4112 : 0 : int bnxt_hwrm_func_qcfg(struct bnxt *bp, uint16_t *mtu)
4113 : : {
4114 : 0 : struct hwrm_func_qcfg_input req = {0};
4115 : 0 : struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
4116 : : uint16_t flags;
4117 : : int rc = 0;
4118 : 0 : bp->func_svif = BNXT_SVIF_INVALID;
4119 : : uint16_t svif_info;
4120 : :
4121 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
4122 : 0 : req.fid = rte_cpu_to_le_16(0xffff);
4123 : :
4124 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4125 : :
4126 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4127 : :
4128 : 0 : bp->vlan = rte_le_to_cpu_16(resp->vlan) & RTE_ETH_VLAN_ID_MAX;
4129 : :
4130 : 0 : svif_info = rte_le_to_cpu_16(resp->svif_info);
4131 [ # # ]: 0 : if (svif_info & HWRM_FUNC_QCFG_OUTPUT_SVIF_INFO_SVIF_VALID)
4132 : 0 : bp->func_svif = svif_info &
4133 : : HWRM_FUNC_QCFG_OUTPUT_SVIF_INFO_SVIF_MASK;
4134 : :
4135 : 0 : flags = rte_le_to_cpu_16(resp->flags);
4136 [ # # # # ]: 0 : if (BNXT_PF(bp) && (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_MULTI_HOST))
4137 : 0 : bp->flags |= BNXT_FLAG_MULTI_HOST;
4138 : :
4139 [ # # ]: 0 : if (BNXT_VF(bp) &&
4140 [ # # ]: 0 : !BNXT_VF_IS_TRUSTED(bp) &&
4141 : : (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_TRUSTED_VF)) {
4142 : 0 : bp->flags |= BNXT_FLAG_TRUSTED_VF_EN;
4143 : 0 : PMD_DRV_LOG(INFO, "Trusted VF cap enabled\n");
4144 [ # # ]: 0 : } else if (BNXT_VF(bp) &&
4145 [ # # ]: 0 : BNXT_VF_IS_TRUSTED(bp) &&
4146 : : !(flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_TRUSTED_VF)) {
4147 : 0 : bp->flags &= ~BNXT_FLAG_TRUSTED_VF_EN;
4148 : 0 : PMD_DRV_LOG(INFO, "Trusted VF cap disabled\n");
4149 : : }
4150 : :
4151 [ # # ]: 0 : if (mtu)
4152 : 0 : *mtu = rte_le_to_cpu_16(resp->admin_mtu);
4153 : :
4154 [ # # ]: 0 : switch (resp->port_partition_type) {
4155 : 0 : case HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR1_0:
4156 : : case HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR1_5:
4157 : : case HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR2_0:
4158 : : /* FALLTHROUGH */
4159 : 0 : bp->flags |= BNXT_FLAG_NPAR_PF;
4160 : 0 : break;
4161 : 0 : default:
4162 : 0 : bp->flags &= ~BNXT_FLAG_NPAR_PF;
4163 : 0 : break;
4164 : : }
4165 : :
4166 : 0 : bp->legacy_db_size =
4167 : 0 : rte_le_to_cpu_16(resp->legacy_l2_db_size_kb) * 1024;
4168 : :
4169 : : HWRM_UNLOCK();
4170 : :
4171 : 0 : return rc;
4172 : : }
4173 : :
4174 : 0 : int bnxt_hwrm_parent_pf_qcfg(struct bnxt *bp)
4175 : : {
4176 : 0 : struct hwrm_func_qcfg_input req = {0};
4177 : 0 : struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
4178 : : uint16_t flags;
4179 : : int rc;
4180 : :
4181 [ # # ]: 0 : if (!BNXT_VF_IS_TRUSTED(bp))
4182 : : return 0;
4183 : :
4184 [ # # ]: 0 : if (!bp->parent)
4185 : : return -EINVAL;
4186 : :
4187 : 0 : bp->parent->fid = BNXT_PF_FID_INVALID;
4188 : :
4189 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
4190 : :
4191 : 0 : req.fid = rte_cpu_to_le_16(0xfffe); /* Request parent PF information. */
4192 : :
4193 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4194 : :
4195 [ # # # # ]: 0 : HWRM_CHECK_RESULT_SILENT();
4196 : :
4197 [ # # ]: 0 : memcpy(bp->parent->mac_addr, resp->mac_address, RTE_ETHER_ADDR_LEN);
4198 : 0 : bp->parent->vnic = rte_le_to_cpu_16(resp->dflt_vnic_id);
4199 : 0 : bp->parent->fid = rte_le_to_cpu_16(resp->fid);
4200 : 0 : bp->parent->port_id = rte_le_to_cpu_16(resp->port_id);
4201 : :
4202 : 0 : flags = rte_le_to_cpu_16(resp->flags);
4203 : :
4204 : : /* check for the mulit-host support */
4205 [ # # ]: 0 : if (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_MULTI_HOST) {
4206 : 0 : bp->flags |= BNXT_FLAG_MULTI_HOST;
4207 : 0 : bp->multi_host_pf_pci_id = resp->pci_id;
4208 : 0 : PMD_DRV_LOG(INFO, "Mult-Host system Parent PCI-ID: 0x%x\n", resp->pci_id);
4209 : : }
4210 : :
4211 : : /* check for the multi-root support */
4212 [ # # ]: 0 : if (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_MULTI_ROOT) {
4213 : 0 : bp->flags2 |= BNXT_FLAGS2_MULTIROOT_EN;
4214 : 0 : PMD_DRV_LOG(DEBUG, "PF enabled with multi root capability\n");
4215 : : }
4216 : :
4217 : : HWRM_UNLOCK();
4218 : :
4219 : 0 : return 0;
4220 : : }
4221 : :
4222 : 0 : int bnxt_hwrm_get_dflt_vnic_svif(struct bnxt *bp, uint16_t fid,
4223 : : uint16_t *vnic_id, uint16_t *svif)
4224 : : {
4225 : 0 : struct hwrm_func_qcfg_input req = {0};
4226 : 0 : struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
4227 : : uint16_t svif_info;
4228 : : int rc = 0;
4229 : :
4230 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
4231 : 0 : req.fid = rte_cpu_to_le_16(fid);
4232 : :
4233 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4234 : :
4235 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4236 : :
4237 [ # # ]: 0 : if (vnic_id)
4238 : 0 : *vnic_id = rte_le_to_cpu_16(resp->dflt_vnic_id);
4239 : :
4240 : 0 : svif_info = rte_le_to_cpu_16(resp->svif_info);
4241 [ # # ]: 0 : if (svif && (svif_info & HWRM_FUNC_QCFG_OUTPUT_SVIF_INFO_SVIF_VALID))
4242 : 0 : *svif = svif_info & HWRM_FUNC_QCFG_OUTPUT_SVIF_INFO_SVIF_MASK;
4243 : :
4244 : : HWRM_UNLOCK();
4245 : :
4246 : 0 : return rc;
4247 : : }
4248 : :
4249 : 0 : int bnxt_hwrm_port_mac_qcfg(struct bnxt *bp)
4250 : : {
4251 : 0 : struct hwrm_port_mac_qcfg_input req = {0};
4252 : 0 : struct hwrm_port_mac_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
4253 : : uint16_t port_svif_info;
4254 : : int rc;
4255 : :
4256 : 0 : bp->port_svif = BNXT_SVIF_INVALID;
4257 : :
4258 [ # # ]: 0 : if (BNXT_VF(bp) && !BNXT_VF_IS_TRUSTED(bp))
4259 : : return 0;
4260 : :
4261 [ # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_MAC_QCFG, BNXT_USE_CHIMP_MB);
4262 : :
4263 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4264 : :
4265 [ # # # # ]: 0 : HWRM_CHECK_RESULT_SILENT();
4266 : :
4267 : 0 : port_svif_info = rte_le_to_cpu_16(resp->port_svif_info);
4268 [ # # ]: 0 : if (port_svif_info &
4269 : : HWRM_PORT_MAC_QCFG_OUTPUT_PORT_SVIF_INFO_PORT_SVIF_VALID)
4270 : 0 : bp->port_svif = port_svif_info &
4271 : : HWRM_PORT_MAC_QCFG_OUTPUT_PORT_SVIF_INFO_PORT_SVIF_MASK;
4272 : :
4273 : : HWRM_UNLOCK();
4274 : :
4275 : 0 : return 0;
4276 : : }
4277 : :
4278 : 0 : static int bnxt_hwrm_pf_func_cfg(struct bnxt *bp,
4279 : : struct bnxt_pf_resource_info *pf_resc)
4280 : : {
4281 : 0 : struct hwrm_func_cfg_input req = {0};
4282 : 0 : struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
4283 : : uint32_t enables;
4284 : : int rc;
4285 : :
4286 : : enables = HWRM_FUNC_CFG_INPUT_ENABLES_ADMIN_MTU |
4287 : : HWRM_FUNC_CFG_INPUT_ENABLES_HOST_MTU |
4288 : : HWRM_FUNC_CFG_INPUT_ENABLES_MRU |
4289 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_RSSCOS_CTXS |
4290 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_STAT_CTXS |
4291 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_CMPL_RINGS |
4292 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_TX_RINGS |
4293 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_RX_RINGS |
4294 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_L2_CTXS |
4295 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_VNICS;
4296 : :
4297 [ # # ]: 0 : if (BNXT_HAS_RING_GRPS(bp)) {
4298 : : enables |= HWRM_FUNC_CFG_INPUT_ENABLES_NUM_HW_RING_GRPS;
4299 : 0 : req.num_hw_ring_grps =
4300 : 0 : rte_cpu_to_le_16(pf_resc->num_hw_ring_grps);
4301 : : } else if (BNXT_HAS_NQ(bp)) {
4302 : : enables |= HWRM_FUNC_CFG_INPUT_ENABLES_NUM_MSIX;
4303 : 0 : req.num_msix = rte_cpu_to_le_16(pf_resc->num_nq_rings);
4304 : : }
4305 : :
4306 : 0 : req.flags = rte_cpu_to_le_32(bp->pf->func_cfg_flags);
4307 : 0 : req.admin_mtu = rte_cpu_to_le_16(BNXT_MAX_MTU);
4308 : 0 : req.host_mtu = rte_cpu_to_le_16(bp->eth_dev->data->mtu);
4309 : 0 : req.mru = rte_cpu_to_le_16(BNXT_VNIC_MRU(bp->eth_dev->data->mtu));
4310 : 0 : req.num_rsscos_ctxs = rte_cpu_to_le_16(pf_resc->num_rsscos_ctxs);
4311 : 0 : req.num_stat_ctxs = rte_cpu_to_le_16(pf_resc->num_stat_ctxs);
4312 : 0 : req.num_cmpl_rings = rte_cpu_to_le_16(pf_resc->num_cp_rings);
4313 : 0 : req.num_tx_rings = rte_cpu_to_le_16(pf_resc->num_tx_rings);
4314 : 0 : req.num_rx_rings = rte_cpu_to_le_16(pf_resc->num_rx_rings);
4315 : 0 : req.num_l2_ctxs = rte_cpu_to_le_16(pf_resc->num_l2_ctxs);
4316 : 0 : req.num_vnics = rte_cpu_to_le_16(pf_resc->num_vnics);
4317 : 0 : req.fid = rte_cpu_to_le_16(0xffff);
4318 : 0 : req.enables = rte_cpu_to_le_32(enables);
4319 : :
4320 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
4321 : :
4322 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4323 : :
4324 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4325 : : HWRM_UNLOCK();
4326 : :
4327 : 0 : return rc;
4328 : : }
4329 : :
4330 : : /* min values are the guaranteed resources and max values are subject
4331 : : * to availability. The strategy for now is to keep both min & max
4332 : : * values the same.
4333 : : */
4334 : : static void
4335 : 0 : bnxt_fill_vf_func_cfg_req_new(struct bnxt *bp,
4336 : : struct hwrm_func_vf_resource_cfg_input *req,
4337 : : int num_vfs)
4338 : : {
4339 : 0 : req->max_rsscos_ctx = rte_cpu_to_le_16(bp->max_rsscos_ctx /
4340 : : (num_vfs + 1));
4341 : 0 : req->min_rsscos_ctx = req->max_rsscos_ctx;
4342 : 0 : req->max_stat_ctx = rte_cpu_to_le_16(bp->max_stat_ctx / (num_vfs + 1));
4343 : 0 : req->min_stat_ctx = req->max_stat_ctx;
4344 : 0 : req->max_cmpl_rings = rte_cpu_to_le_16(bp->max_cp_rings /
4345 : : (num_vfs + 1));
4346 : 0 : req->min_cmpl_rings = req->max_cmpl_rings;
4347 : 0 : req->max_tx_rings = rte_cpu_to_le_16(bp->max_tx_rings / (num_vfs + 1));
4348 : 0 : req->min_tx_rings = req->max_tx_rings;
4349 : 0 : req->max_rx_rings = rte_cpu_to_le_16(bp->max_rx_rings / (num_vfs + 1));
4350 : 0 : req->min_rx_rings = req->max_rx_rings;
4351 : 0 : req->max_l2_ctxs = rte_cpu_to_le_16(bp->max_l2_ctx / (num_vfs + 1));
4352 : 0 : req->min_l2_ctxs = req->max_l2_ctxs;
4353 : 0 : req->max_vnics = rte_cpu_to_le_16(bp->max_vnics / (num_vfs + 1));
4354 : 0 : req->min_vnics = req->max_vnics;
4355 : 0 : req->max_hw_ring_grps = rte_cpu_to_le_16(bp->max_ring_grps /
4356 : : (num_vfs + 1));
4357 : 0 : req->min_hw_ring_grps = req->max_hw_ring_grps;
4358 : 0 : req->max_msix = rte_cpu_to_le_16(bp->max_nq_rings / (num_vfs + 1));
4359 : 0 : }
4360 : :
4361 : : static void
4362 : 0 : bnxt_fill_vf_func_cfg_req_old(struct bnxt *bp,
4363 : : struct hwrm_func_cfg_input *req,
4364 : : int num_vfs)
4365 : : {
4366 : 0 : req->enables = rte_cpu_to_le_32(HWRM_FUNC_CFG_INPUT_ENABLES_ADMIN_MTU |
4367 : : HWRM_FUNC_CFG_INPUT_ENABLES_MRU |
4368 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_RSSCOS_CTXS |
4369 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_STAT_CTXS |
4370 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_CMPL_RINGS |
4371 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_TX_RINGS |
4372 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_RX_RINGS |
4373 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_L2_CTXS |
4374 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_VNICS |
4375 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_HW_RING_GRPS);
4376 : :
4377 : 0 : req->admin_mtu = rte_cpu_to_le_16(bp->eth_dev->data->mtu + RTE_ETHER_HDR_LEN +
4378 : : RTE_ETHER_CRC_LEN + RTE_VLAN_HLEN *
4379 : : BNXT_NUM_VLANS);
4380 : 0 : req->mru = rte_cpu_to_le_16(BNXT_VNIC_MRU(bp->eth_dev->data->mtu));
4381 : 0 : req->num_rsscos_ctxs = rte_cpu_to_le_16(bp->max_rsscos_ctx /
4382 : : (num_vfs + 1));
4383 : 0 : req->num_stat_ctxs = rte_cpu_to_le_16(bp->max_stat_ctx / (num_vfs + 1));
4384 : 0 : req->num_cmpl_rings = rte_cpu_to_le_16(bp->max_cp_rings /
4385 : : (num_vfs + 1));
4386 : 0 : req->num_tx_rings = rte_cpu_to_le_16(bp->max_tx_rings / (num_vfs + 1));
4387 : 0 : req->num_rx_rings = rte_cpu_to_le_16(bp->max_rx_rings / (num_vfs + 1));
4388 : 0 : req->num_l2_ctxs = rte_cpu_to_le_16(bp->max_l2_ctx / (num_vfs + 1));
4389 : : /* TODO: For now, do not support VMDq/RFS on VFs. */
4390 : 0 : req->num_vnics = rte_cpu_to_le_16(1);
4391 : 0 : req->num_hw_ring_grps = rte_cpu_to_le_16(bp->max_ring_grps /
4392 : : (num_vfs + 1));
4393 : 0 : }
4394 : :
4395 : : /* Update the port wide resource values based on how many resources
4396 : : * got allocated to the VF.
4397 : : */
4398 : 0 : static int bnxt_update_max_resources(struct bnxt *bp,
4399 : : int vf)
4400 : : {
4401 : 0 : struct hwrm_func_qcfg_input req = {0};
4402 : 0 : struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
4403 : : int rc;
4404 : :
4405 : : /* Get the actual allocated values now */
4406 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
4407 : 0 : req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
4408 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4409 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4410 : :
4411 : 0 : bp->max_rsscos_ctx -= rte_le_to_cpu_16(resp->alloc_rsscos_ctx);
4412 : 0 : bp->max_stat_ctx -= rte_le_to_cpu_16(resp->alloc_stat_ctx);
4413 : 0 : bp->max_cp_rings -= rte_le_to_cpu_16(resp->alloc_cmpl_rings);
4414 : 0 : bp->max_tx_rings -= rte_le_to_cpu_16(resp->alloc_tx_rings);
4415 : 0 : bp->max_rx_rings -= rte_le_to_cpu_16(resp->alloc_rx_rings);
4416 : 0 : bp->max_l2_ctx -= rte_le_to_cpu_16(resp->alloc_l2_ctx);
4417 : 0 : bp->max_ring_grps -= rte_le_to_cpu_16(resp->alloc_hw_ring_grps);
4418 : 0 : bp->max_nq_rings -= rte_le_to_cpu_16(resp->alloc_msix);
4419 : 0 : bp->max_vnics -= rte_le_to_cpu_16(resp->alloc_vnics);
4420 : :
4421 : : HWRM_UNLOCK();
4422 : :
4423 : 0 : return 0;
4424 : : }
4425 : :
4426 : : /* Update the PF resource values based on how many resources
4427 : : * got allocated to it.
4428 : : */
4429 : 0 : static int bnxt_update_max_resources_pf_only(struct bnxt *bp)
4430 : : {
4431 : 0 : struct hwrm_func_qcfg_input req = {0};
4432 : 0 : struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
4433 : : int rc;
4434 : :
4435 : : /* Get the actual allocated values now */
4436 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
4437 : 0 : req.fid = rte_cpu_to_le_16(0xffff);
4438 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4439 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4440 : :
4441 : 0 : bp->max_rsscos_ctx = rte_le_to_cpu_16(resp->alloc_rsscos_ctx);
4442 : 0 : bp->max_stat_ctx = rte_le_to_cpu_16(resp->alloc_stat_ctx);
4443 : 0 : bp->max_cp_rings = rte_le_to_cpu_16(resp->alloc_cmpl_rings);
4444 : 0 : bp->max_tx_rings = rte_le_to_cpu_16(resp->alloc_tx_rings);
4445 : 0 : bp->max_rx_rings = rte_le_to_cpu_16(resp->alloc_rx_rings);
4446 : 0 : bp->max_l2_ctx = rte_le_to_cpu_16(resp->alloc_l2_ctx);
4447 : 0 : bp->max_ring_grps = rte_le_to_cpu_16(resp->alloc_hw_ring_grps);
4448 : 0 : bp->max_vnics = rte_le_to_cpu_16(resp->alloc_vnics);
4449 : :
4450 : : HWRM_UNLOCK();
4451 : :
4452 : 0 : return 0;
4453 : : }
4454 : :
4455 : 0 : int bnxt_hwrm_func_qcfg_current_vf_vlan(struct bnxt *bp, int vf)
4456 : : {
4457 : 0 : struct hwrm_func_qcfg_input req = {0};
4458 : 0 : struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
4459 : : int rc;
4460 : :
4461 : : /* Check for zero MAC address */
4462 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
4463 : 0 : req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
4464 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4465 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4466 : 0 : rc = rte_le_to_cpu_16(resp->vlan);
4467 : :
4468 : : HWRM_UNLOCK();
4469 : :
4470 : 0 : return rc;
4471 : : }
4472 : :
4473 : 0 : static int bnxt_query_pf_resources(struct bnxt *bp,
4474 : : struct bnxt_pf_resource_info *pf_resc)
4475 : : {
4476 : 0 : struct hwrm_func_qcfg_input req = {0};
4477 : 0 : struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
4478 : : int rc;
4479 : :
4480 : : /* And copy the allocated numbers into the pf struct */
4481 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
4482 : 0 : req.fid = rte_cpu_to_le_16(0xffff);
4483 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4484 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4485 : :
4486 : 0 : pf_resc->num_tx_rings = rte_le_to_cpu_16(resp->alloc_tx_rings);
4487 : 0 : pf_resc->num_rsscos_ctxs = rte_le_to_cpu_16(resp->alloc_rsscos_ctx);
4488 : 0 : pf_resc->num_stat_ctxs = rte_le_to_cpu_16(resp->alloc_stat_ctx);
4489 : 0 : pf_resc->num_cp_rings = rte_le_to_cpu_16(resp->alloc_cmpl_rings);
4490 : 0 : pf_resc->num_rx_rings = rte_le_to_cpu_16(resp->alloc_rx_rings);
4491 : 0 : pf_resc->num_l2_ctxs = rte_le_to_cpu_16(resp->alloc_l2_ctx);
4492 : 0 : pf_resc->num_hw_ring_grps = rte_le_to_cpu_32(resp->alloc_hw_ring_grps);
4493 : 0 : pf_resc->num_nq_rings = rte_le_to_cpu_32(resp->alloc_msix);
4494 : 0 : pf_resc->num_vnics = rte_le_to_cpu_16(resp->alloc_vnics);
4495 : 0 : bp->pf->evb_mode = resp->evb_mode;
4496 : :
4497 : : HWRM_UNLOCK();
4498 : :
4499 : 0 : return rc;
4500 : : }
4501 : :
4502 : : static void
4503 : 0 : bnxt_calculate_pf_resources(struct bnxt *bp,
4504 : : struct bnxt_pf_resource_info *pf_resc,
4505 : : int num_vfs)
4506 : : {
4507 [ # # ]: 0 : if (!num_vfs) {
4508 : 0 : pf_resc->num_rsscos_ctxs = bp->max_rsscos_ctx;
4509 : 0 : pf_resc->num_stat_ctxs = bp->max_stat_ctx;
4510 : 0 : pf_resc->num_cp_rings = bp->max_cp_rings;
4511 : 0 : pf_resc->num_tx_rings = bp->max_tx_rings;
4512 : 0 : pf_resc->num_rx_rings = bp->max_rx_rings;
4513 : 0 : pf_resc->num_l2_ctxs = bp->max_l2_ctx;
4514 : 0 : pf_resc->num_hw_ring_grps = bp->max_ring_grps;
4515 : 0 : pf_resc->num_nq_rings = bp->max_nq_rings;
4516 : 0 : pf_resc->num_vnics = bp->max_vnics;
4517 : :
4518 : 0 : return;
4519 : : }
4520 : :
4521 : 0 : pf_resc->num_rsscos_ctxs = bp->max_rsscos_ctx / (num_vfs + 1) +
4522 : 0 : bp->max_rsscos_ctx % (num_vfs + 1);
4523 : 0 : pf_resc->num_stat_ctxs = bp->max_stat_ctx / (num_vfs + 1) +
4524 : 0 : bp->max_stat_ctx % (num_vfs + 1);
4525 : 0 : pf_resc->num_cp_rings = bp->max_cp_rings / (num_vfs + 1) +
4526 : 0 : bp->max_cp_rings % (num_vfs + 1);
4527 : 0 : pf_resc->num_tx_rings = bp->max_tx_rings / (num_vfs + 1) +
4528 : 0 : bp->max_tx_rings % (num_vfs + 1);
4529 : 0 : pf_resc->num_rx_rings = bp->max_rx_rings / (num_vfs + 1) +
4530 : 0 : bp->max_rx_rings % (num_vfs + 1);
4531 : 0 : pf_resc->num_l2_ctxs = bp->max_l2_ctx / (num_vfs + 1) +
4532 : 0 : bp->max_l2_ctx % (num_vfs + 1);
4533 : 0 : pf_resc->num_hw_ring_grps = bp->max_ring_grps / (num_vfs + 1) +
4534 : 0 : bp->max_ring_grps % (num_vfs + 1);
4535 : 0 : pf_resc->num_nq_rings = bp->max_nq_rings / (num_vfs + 1) +
4536 : 0 : bp->max_nq_rings % (num_vfs + 1);
4537 : 0 : pf_resc->num_vnics = bp->max_vnics / (num_vfs + 1) +
4538 : 0 : bp->max_vnics % (num_vfs + 1);
4539 : : }
4540 : :
4541 : 0 : int bnxt_hwrm_allocate_pf_only(struct bnxt *bp)
4542 : : {
4543 : 0 : struct bnxt_pf_resource_info pf_resc = { 0 };
4544 : : int rc;
4545 : :
4546 [ # # ]: 0 : if (!BNXT_PF(bp)) {
4547 : 0 : PMD_DRV_LOG(ERR, "Attempt to allocate VFs on a VF!\n");
4548 : 0 : return -EINVAL;
4549 : : }
4550 : :
4551 : 0 : rc = bnxt_hwrm_func_qcaps(bp);
4552 [ # # ]: 0 : if (rc)
4553 : : return rc;
4554 : :
4555 : : bnxt_calculate_pf_resources(bp, &pf_resc, 0);
4556 : :
4557 : 0 : bp->pf->func_cfg_flags &=
4558 : : ~(HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_ENABLE |
4559 : : HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_DISABLE);
4560 : 0 : bp->pf->func_cfg_flags |=
4561 : : HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_DISABLE;
4562 : :
4563 : 0 : rc = bnxt_hwrm_pf_func_cfg(bp, &pf_resc);
4564 [ # # ]: 0 : if (rc)
4565 : : return rc;
4566 : :
4567 : 0 : rc = bnxt_update_max_resources_pf_only(bp);
4568 : :
4569 : 0 : return rc;
4570 : : }
4571 : :
4572 : : static int
4573 : 0 : bnxt_configure_vf_req_buf(struct bnxt *bp, int num_vfs)
4574 : : {
4575 : : size_t req_buf_sz, sz;
4576 : : int i, rc;
4577 : :
4578 : 0 : req_buf_sz = num_vfs * HWRM_MAX_REQ_LEN;
4579 : 0 : bp->pf->vf_req_buf = rte_malloc("bnxt_vf_fwd", req_buf_sz,
4580 : : page_roundup(num_vfs * HWRM_MAX_REQ_LEN));
4581 [ # # ]: 0 : if (bp->pf->vf_req_buf == NULL) {
4582 : : return -ENOMEM;
4583 : : }
4584 : :
4585 [ # # ]: 0 : for (sz = 0; sz < req_buf_sz; sz += getpagesize())
4586 : 0 : rte_mem_lock_page(((char *)bp->pf->vf_req_buf) + sz);
4587 : :
4588 [ # # ]: 0 : for (i = 0; i < num_vfs; i++)
4589 : 0 : bp->pf->vf_info[i].req_buf = ((char *)bp->pf->vf_req_buf) +
4590 : 0 : (i * HWRM_MAX_REQ_LEN);
4591 : :
4592 : 0 : rc = bnxt_hwrm_func_buf_rgtr(bp, num_vfs);
4593 [ # # ]: 0 : if (rc)
4594 : 0 : rte_free(bp->pf->vf_req_buf);
4595 : :
4596 : : return rc;
4597 : : }
4598 : :
4599 : : static int
4600 : 0 : bnxt_process_vf_resc_config_new(struct bnxt *bp, int num_vfs)
4601 : : {
4602 : 0 : struct hwrm_func_vf_resource_cfg_output *resp = bp->hwrm_cmd_resp_addr;
4603 : 0 : struct hwrm_func_vf_resource_cfg_input req = {0};
4604 : : int i, rc = 0;
4605 : :
4606 : 0 : bnxt_fill_vf_func_cfg_req_new(bp, &req, num_vfs);
4607 : 0 : bp->pf->active_vfs = 0;
4608 [ # # ]: 0 : for (i = 0; i < num_vfs; i++) {
4609 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_VF_RESOURCE_CFG, BNXT_USE_CHIMP_MB);
4610 : 0 : req.vf_id = rte_cpu_to_le_16(bp->pf->vf_info[i].fid);
4611 : 0 : rc = bnxt_hwrm_send_message(bp,
4612 : : &req,
4613 : : sizeof(req),
4614 : : BNXT_USE_CHIMP_MB);
4615 [ # # # # ]: 0 : if (rc || resp->error_code) {
4616 : 0 : PMD_DRV_LOG(ERR,
4617 : : "Failed to initialize VF %d\n", i);
4618 : 0 : PMD_DRV_LOG(ERR,
4619 : : "Not all VFs available. (%d, %d)\n",
4620 : : rc, resp->error_code);
4621 : : HWRM_UNLOCK();
4622 : :
4623 : : /* If the first VF configuration itself fails,
4624 : : * unregister the vf_fwd_request buffer.
4625 : : */
4626 [ # # ]: 0 : if (i == 0)
4627 : 0 : bnxt_hwrm_func_buf_unrgtr(bp);
4628 : : break;
4629 : : }
4630 : : HWRM_UNLOCK();
4631 : :
4632 : : /* Update the max resource values based on the resource values
4633 : : * allocated to the VF.
4634 : : */
4635 : 0 : bnxt_update_max_resources(bp, i);
4636 : 0 : bp->pf->active_vfs++;
4637 : 0 : bnxt_hwrm_func_clr_stats(bp, bp->pf->vf_info[i].fid);
4638 : : }
4639 : :
4640 : : return 0;
4641 : : }
4642 : :
4643 : : static int
4644 : 0 : bnxt_process_vf_resc_config_old(struct bnxt *bp, int num_vfs)
4645 : : {
4646 : 0 : struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
4647 : 0 : struct hwrm_func_cfg_input req = {0};
4648 : : int i, rc;
4649 : :
4650 : 0 : bnxt_fill_vf_func_cfg_req_old(bp, &req, num_vfs);
4651 : :
4652 : 0 : bp->pf->active_vfs = 0;
4653 [ # # ]: 0 : for (i = 0; i < num_vfs; i++) {
4654 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
4655 : 0 : req.flags = rte_cpu_to_le_32(bp->pf->vf_info[i].func_cfg_flags);
4656 : 0 : req.fid = rte_cpu_to_le_16(bp->pf->vf_info[i].fid);
4657 : 0 : rc = bnxt_hwrm_send_message(bp,
4658 : : &req,
4659 : : sizeof(req),
4660 : : BNXT_USE_CHIMP_MB);
4661 : :
4662 : : /* Clear enable flag for next pass */
4663 : 0 : req.enables &= ~rte_cpu_to_le_32(
4664 : : HWRM_FUNC_CFG_INPUT_ENABLES_DFLT_MAC_ADDR);
4665 : :
4666 [ # # # # ]: 0 : if (rc || resp->error_code) {
4667 : 0 : PMD_DRV_LOG(ERR,
4668 : : "Failed to initialize VF %d\n", i);
4669 : 0 : PMD_DRV_LOG(ERR,
4670 : : "Not all VFs available. (%d, %d)\n",
4671 : : rc, resp->error_code);
4672 : : HWRM_UNLOCK();
4673 : :
4674 : : /* If the first VF configuration itself fails,
4675 : : * unregister the vf_fwd_request buffer.
4676 : : */
4677 [ # # ]: 0 : if (i == 0)
4678 : 0 : bnxt_hwrm_func_buf_unrgtr(bp);
4679 : : break;
4680 : : }
4681 : :
4682 : : HWRM_UNLOCK();
4683 : :
4684 : : /* Update the max resource values based on the resource values
4685 : : * allocated to the VF.
4686 : : */
4687 : 0 : bnxt_update_max_resources(bp, i);
4688 : 0 : bp->pf->active_vfs++;
4689 : 0 : bnxt_hwrm_func_clr_stats(bp, bp->pf->vf_info[i].fid);
4690 : : }
4691 : :
4692 : : return 0;
4693 : : }
4694 : :
4695 : : static void
4696 : 0 : bnxt_configure_vf_resources(struct bnxt *bp, int num_vfs)
4697 : : {
4698 [ # # ]: 0 : if (bp->flags & BNXT_FLAG_NEW_RM)
4699 : 0 : bnxt_process_vf_resc_config_new(bp, num_vfs);
4700 : : else
4701 : 0 : bnxt_process_vf_resc_config_old(bp, num_vfs);
4702 : 0 : }
4703 : :
4704 : : static void
4705 : : bnxt_update_pf_resources(struct bnxt *bp,
4706 : : struct bnxt_pf_resource_info *pf_resc)
4707 : : {
4708 : 0 : bp->max_rsscos_ctx = pf_resc->num_rsscos_ctxs;
4709 : 0 : bp->max_stat_ctx = pf_resc->num_stat_ctxs;
4710 : 0 : bp->max_cp_rings = pf_resc->num_cp_rings;
4711 : 0 : bp->max_tx_rings = pf_resc->num_tx_rings;
4712 : 0 : bp->max_rx_rings = pf_resc->num_rx_rings;
4713 : 0 : bp->max_ring_grps = pf_resc->num_hw_ring_grps;
4714 : 0 : bp->max_nq_rings = pf_resc->num_nq_rings;
4715 : 0 : bp->max_vnics = pf_resc->num_vnics;
4716 : : }
4717 : :
4718 : : static int32_t
4719 : : bnxt_configure_pf_resources(struct bnxt *bp,
4720 : : struct bnxt_pf_resource_info *pf_resc)
4721 : : {
4722 : : /*
4723 : : * We're using STD_TX_RING_MODE here which will limit the TX
4724 : : * rings. This will allow QoS to function properly. Not setting this
4725 : : * will cause PF rings to break bandwidth settings.
4726 : : */
4727 : 0 : bp->pf->func_cfg_flags &=
4728 : : ~(HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_ENABLE |
4729 : : HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_DISABLE);
4730 : 0 : bp->pf->func_cfg_flags |=
4731 : : HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_ENABLE;
4732 : 0 : return bnxt_hwrm_pf_func_cfg(bp, pf_resc);
4733 : : }
4734 : :
4735 : 0 : int bnxt_hwrm_allocate_vfs(struct bnxt *bp, int num_vfs)
4736 : : {
4737 : 0 : struct bnxt_pf_resource_info pf_resc = { 0 };
4738 : : int rc;
4739 : :
4740 [ # # ]: 0 : if (!BNXT_PF(bp)) {
4741 : 0 : PMD_DRV_LOG(ERR, "Attempt to allocate VFs on a VF!\n");
4742 : 0 : return -EINVAL;
4743 : : }
4744 : :
4745 : 0 : rc = bnxt_hwrm_func_qcaps(bp);
4746 [ # # ]: 0 : if (rc)
4747 : : return rc;
4748 : :
4749 : 0 : bnxt_calculate_pf_resources(bp, &pf_resc, num_vfs);
4750 : :
4751 : : rc = bnxt_configure_pf_resources(bp, &pf_resc);
4752 [ # # ]: 0 : if (rc)
4753 : : return rc;
4754 : :
4755 : 0 : rc = bnxt_query_pf_resources(bp, &pf_resc);
4756 [ # # ]: 0 : if (rc)
4757 : : return rc;
4758 : :
4759 : : /*
4760 : : * Now, create and register a buffer to hold forwarded VF requests
4761 : : */
4762 : 0 : rc = bnxt_configure_vf_req_buf(bp, num_vfs);
4763 [ # # ]: 0 : if (rc)
4764 : : return rc;
4765 : :
4766 : 0 : bnxt_configure_vf_resources(bp, num_vfs);
4767 : :
4768 : : bnxt_update_pf_resources(bp, &pf_resc);
4769 : :
4770 : 0 : return 0;
4771 : : }
4772 : :
4773 : 0 : int bnxt_hwrm_pf_evb_mode(struct bnxt *bp)
4774 : : {
4775 : 0 : struct hwrm_func_cfg_input req = {0};
4776 : 0 : struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
4777 : : int rc;
4778 : :
4779 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
4780 : :
4781 : 0 : req.fid = rte_cpu_to_le_16(0xffff);
4782 : 0 : req.enables = rte_cpu_to_le_32(HWRM_FUNC_CFG_INPUT_ENABLES_EVB_MODE);
4783 : 0 : req.evb_mode = bp->pf->evb_mode;
4784 : :
4785 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4786 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4787 : : HWRM_UNLOCK();
4788 : :
4789 : 0 : return rc;
4790 : : }
4791 : :
4792 : 0 : static int bnxt_hwrm_set_tpa(struct bnxt *bp)
4793 : : {
4794 : 0 : struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf;
4795 : 0 : uint64_t rx_offloads = dev_conf->rxmode.offloads;
4796 : : bool tpa_flags = 0;
4797 : : int rc, i;
4798 : :
4799 : 0 : tpa_flags = (rx_offloads & RTE_ETH_RX_OFFLOAD_TCP_LRO) ? true : false;
4800 [ # # ]: 0 : for (i = 0; i < bp->max_vnics; i++) {
4801 : 0 : struct bnxt_vnic_info *vnic = &bp->vnic_info[i];
4802 : :
4803 [ # # ]: 0 : if (vnic->fw_vnic_id == INVALID_HW_RING_ID)
4804 : 0 : continue;
4805 : :
4806 : 0 : rc = bnxt_hwrm_vnic_tpa_cfg(bp, vnic, tpa_flags);
4807 [ # # ]: 0 : if (rc)
4808 : 0 : return rc;
4809 : : }
4810 : : return 0;
4811 : : }
4812 : :
4813 : 0 : int bnxt_hwrm_tunnel_dst_port_alloc(struct bnxt *bp, uint16_t port,
4814 : : uint8_t tunnel_type)
4815 : : {
4816 : 0 : struct hwrm_tunnel_dst_port_alloc_input req = {0};
4817 : 0 : struct hwrm_tunnel_dst_port_alloc_output *resp = bp->hwrm_cmd_resp_addr;
4818 : : int rc = 0;
4819 : :
4820 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_TUNNEL_DST_PORT_ALLOC, BNXT_USE_CHIMP_MB);
4821 : 0 : req.tunnel_type = tunnel_type;
4822 [ # # ]: 0 : req.tunnel_dst_port_val = rte_cpu_to_be_16(port);
4823 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4824 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4825 : :
4826 [ # # # # ]: 0 : switch (tunnel_type) {
4827 : 0 : case HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_VXLAN:
4828 : 0 : bp->vxlan_fw_dst_port_id =
4829 : 0 : rte_le_to_cpu_16(resp->tunnel_dst_port_id);
4830 : 0 : bp->vxlan_port = port;
4831 : 0 : break;
4832 : 0 : case HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_GENEVE:
4833 : 0 : bp->geneve_fw_dst_port_id =
4834 : 0 : rte_le_to_cpu_16(resp->tunnel_dst_port_id);
4835 : 0 : bp->geneve_port = port;
4836 : 0 : break;
4837 : 0 : case HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_ECPRI:
4838 : 0 : bp->ecpri_fw_dst_port_id =
4839 : 0 : rte_le_to_cpu_16(resp->tunnel_dst_port_id);
4840 : 0 : bp->ecpri_port = port;
4841 : 0 : bp->ecpri_upar_in_use = resp->upar_in_use;
4842 : 0 : break;
4843 : : default:
4844 : : break;
4845 : : }
4846 : :
4847 : : HWRM_UNLOCK();
4848 : :
4849 : 0 : bnxt_hwrm_set_tpa(bp);
4850 : :
4851 : 0 : return rc;
4852 : : }
4853 : :
4854 : 0 : int bnxt_hwrm_tunnel_upar_id_get(struct bnxt *bp, uint8_t *upar_id,
4855 : : uint8_t tunnel_type)
4856 : : {
4857 : 0 : struct hwrm_tunnel_dst_port_query_input req = {0};
4858 : 0 : struct hwrm_tunnel_dst_port_query_output *resp = bp->hwrm_cmd_resp_addr;
4859 : : int rc = 0;
4860 : :
4861 [ # # ]: 0 : HWRM_PREP(&req, HWRM_TUNNEL_DST_PORT_QUERY, BNXT_USE_CHIMP_MB);
4862 : 0 : req.tunnel_type = tunnel_type;
4863 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4864 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4865 : :
4866 [ # # # ]: 0 : switch (tunnel_type) {
4867 : 0 : case HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_ECPRI:
4868 : 0 : *upar_id = resp->upar_in_use;
4869 : 0 : break;
4870 : 0 : case HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_SRV6:
4871 : 0 : *upar_id = resp->upar_in_use;
4872 : 0 : break;
4873 : 0 : default:
4874 : : /* INVALID UPAR Id if another tunnel type tries to retrieve */
4875 : 0 : *upar_id = 0xff;
4876 : 0 : break;
4877 : : }
4878 : :
4879 : : HWRM_UNLOCK();
4880 : :
4881 : 0 : return rc;
4882 : : }
4883 : :
4884 : 0 : int bnxt_hwrm_tunnel_dst_port_free(struct bnxt *bp, uint16_t port,
4885 : : uint8_t tunnel_type)
4886 : : {
4887 : 0 : struct hwrm_tunnel_dst_port_free_input req = {0};
4888 : 0 : struct hwrm_tunnel_dst_port_free_output *resp = bp->hwrm_cmd_resp_addr;
4889 : : int rc = 0;
4890 : :
4891 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_TUNNEL_DST_PORT_FREE, BNXT_USE_CHIMP_MB);
4892 : :
4893 : 0 : req.tunnel_type = tunnel_type;
4894 [ # # ]: 0 : req.tunnel_dst_port_id = rte_cpu_to_be_16(port);
4895 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4896 : :
4897 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4898 : : HWRM_UNLOCK();
4899 : :
4900 [ # # ]: 0 : if (tunnel_type ==
4901 : : HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_VXLAN) {
4902 : 0 : bp->vxlan_port = 0;
4903 : 0 : bp->vxlan_port_cnt = 0;
4904 : : }
4905 : :
4906 [ # # ]: 0 : if (tunnel_type ==
4907 : : HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_GENEVE) {
4908 : 0 : bp->geneve_port = 0;
4909 : 0 : bp->geneve_port_cnt = 0;
4910 : : }
4911 : :
4912 [ # # ]: 0 : if (tunnel_type ==
4913 : : HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_ECPRI) {
4914 : 0 : bp->ecpri_port = 0;
4915 : 0 : bp->ecpri_upar_in_use = 0;
4916 : 0 : bp->ecpri_port_cnt = 0;
4917 : : }
4918 : :
4919 : 0 : bnxt_hwrm_set_tpa(bp);
4920 : 0 : return rc;
4921 : : }
4922 : :
4923 : 0 : int bnxt_hwrm_func_cfg_vf_set_flags(struct bnxt *bp, uint16_t vf,
4924 : : uint32_t flags)
4925 : : {
4926 : 0 : struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
4927 : 0 : struct hwrm_func_cfg_input req = {0};
4928 : : int rc;
4929 : :
4930 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
4931 : :
4932 : 0 : req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
4933 : 0 : req.flags = rte_cpu_to_le_32(flags);
4934 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4935 : :
4936 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4937 : : HWRM_UNLOCK();
4938 : :
4939 : 0 : return rc;
4940 : : }
4941 : :
4942 : 0 : void vf_vnic_set_rxmask_cb(struct bnxt_vnic_info *vnic, void *flagp)
4943 : : {
4944 : : uint32_t *flag = flagp;
4945 : :
4946 : 0 : vnic->flags = *flag;
4947 : 0 : }
4948 : :
4949 : 0 : int bnxt_set_rx_mask_no_vlan(struct bnxt *bp, struct bnxt_vnic_info *vnic)
4950 : : {
4951 : 0 : return bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic, 0, NULL);
4952 : : }
4953 : :
4954 : 0 : int bnxt_hwrm_func_buf_rgtr(struct bnxt *bp, int num_vfs)
4955 : : {
4956 : 0 : struct hwrm_func_buf_rgtr_output *resp = bp->hwrm_cmd_resp_addr;
4957 : 0 : struct hwrm_func_buf_rgtr_input req = {.req_type = 0 };
4958 : : int rc;
4959 : :
4960 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_BUF_RGTR, BNXT_USE_CHIMP_MB);
4961 : :
4962 : 0 : req.req_buf_num_pages = rte_cpu_to_le_16(1);
4963 : 0 : req.req_buf_page_size =
4964 : 0 : rte_cpu_to_le_16(page_getenum(num_vfs * HWRM_MAX_REQ_LEN));
4965 : 0 : req.req_buf_len = rte_cpu_to_le_16(HWRM_MAX_REQ_LEN);
4966 : 0 : req.req_buf_page_addr0 =
4967 : 0 : rte_cpu_to_le_64(rte_malloc_virt2iova(bp->pf->vf_req_buf));
4968 [ # # ]: 0 : if (req.req_buf_page_addr0 == RTE_BAD_IOVA) {
4969 : 0 : PMD_DRV_LOG(ERR,
4970 : : "unable to map buffer address to physical memory\n");
4971 : : HWRM_UNLOCK();
4972 : 0 : return -ENOMEM;
4973 : : }
4974 : :
4975 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4976 : :
4977 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4978 : : HWRM_UNLOCK();
4979 : :
4980 : 0 : return rc;
4981 : : }
4982 : :
4983 : 0 : int bnxt_hwrm_func_buf_unrgtr(struct bnxt *bp)
4984 : : {
4985 : : int rc = 0;
4986 : 0 : struct hwrm_func_buf_unrgtr_input req = {.req_type = 0 };
4987 : 0 : struct hwrm_func_buf_unrgtr_output *resp = bp->hwrm_cmd_resp_addr;
4988 : :
4989 [ # # # # ]: 0 : if (!(BNXT_PF(bp) && bp->pdev->max_vfs))
4990 : : return 0;
4991 : :
4992 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_BUF_UNRGTR, BNXT_USE_CHIMP_MB);
4993 : :
4994 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4995 : :
4996 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4997 : : HWRM_UNLOCK();
4998 : :
4999 : 0 : return rc;
5000 : : }
5001 : :
5002 : 0 : int bnxt_hwrm_func_cfg_def_cp(struct bnxt *bp)
5003 : : {
5004 : 0 : struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
5005 : 0 : struct hwrm_func_cfg_input req = {0};
5006 : : int rc;
5007 : :
5008 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
5009 : :
5010 : 0 : req.fid = rte_cpu_to_le_16(0xffff);
5011 : 0 : req.flags = rte_cpu_to_le_32(bp->pf->func_cfg_flags);
5012 : 0 : req.enables = rte_cpu_to_le_32(
5013 : : HWRM_FUNC_CFG_INPUT_ENABLES_ASYNC_EVENT_CR);
5014 : 0 : req.async_event_cr = rte_cpu_to_le_16(
5015 : : bp->async_cp_ring->cp_ring_struct->fw_ring_id);
5016 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5017 : :
5018 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5019 : : HWRM_UNLOCK();
5020 : :
5021 : 0 : return rc;
5022 : : }
5023 : :
5024 : 0 : int bnxt_hwrm_vf_func_cfg_def_cp(struct bnxt *bp)
5025 : : {
5026 : 0 : struct hwrm_func_vf_cfg_output *resp = bp->hwrm_cmd_resp_addr;
5027 : 0 : struct hwrm_func_vf_cfg_input req = {0};
5028 : : int rc;
5029 : :
5030 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_VF_CFG, BNXT_USE_CHIMP_MB);
5031 : :
5032 : 0 : req.enables = rte_cpu_to_le_32(
5033 : : HWRM_FUNC_VF_CFG_INPUT_ENABLES_ASYNC_EVENT_CR);
5034 : 0 : req.async_event_cr = rte_cpu_to_le_16(
5035 : : bp->async_cp_ring->cp_ring_struct->fw_ring_id);
5036 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5037 : :
5038 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5039 : : HWRM_UNLOCK();
5040 : :
5041 : 0 : return rc;
5042 : : }
5043 : :
5044 : 0 : int bnxt_hwrm_set_default_vlan(struct bnxt *bp, int vf, uint8_t is_vf)
5045 : : {
5046 : 0 : struct hwrm_func_cfg_input req = {0};
5047 : 0 : struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
5048 : : uint16_t dflt_vlan, fid;
5049 : : uint32_t func_cfg_flags;
5050 : : int rc = 0;
5051 : :
5052 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
5053 : :
5054 [ # # ]: 0 : if (is_vf) {
5055 : 0 : dflt_vlan = bp->pf->vf_info[vf].dflt_vlan;
5056 : 0 : fid = bp->pf->vf_info[vf].fid;
5057 : 0 : func_cfg_flags = bp->pf->vf_info[vf].func_cfg_flags;
5058 : : } else {
5059 : : fid = rte_cpu_to_le_16(0xffff);
5060 : 0 : func_cfg_flags = bp->pf->func_cfg_flags;
5061 : 0 : dflt_vlan = bp->vlan;
5062 : : }
5063 : :
5064 : 0 : req.flags = rte_cpu_to_le_32(func_cfg_flags);
5065 : 0 : req.fid = rte_cpu_to_le_16(fid);
5066 : 0 : req.enables |= rte_cpu_to_le_32(HWRM_FUNC_CFG_INPUT_ENABLES_DFLT_VLAN);
5067 : 0 : req.dflt_vlan = rte_cpu_to_le_16(dflt_vlan);
5068 : :
5069 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5070 : :
5071 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5072 : : HWRM_UNLOCK();
5073 : :
5074 : 0 : return rc;
5075 : : }
5076 : :
5077 : 0 : int bnxt_hwrm_func_bw_cfg(struct bnxt *bp, uint16_t vf,
5078 : : uint16_t max_bw, uint16_t enables)
5079 : : {
5080 : 0 : struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
5081 : 0 : struct hwrm_func_cfg_input req = {0};
5082 : : int rc;
5083 : :
5084 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
5085 : :
5086 : 0 : req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
5087 : 0 : req.enables |= rte_cpu_to_le_32(enables);
5088 : 0 : req.flags = rte_cpu_to_le_32(bp->pf->vf_info[vf].func_cfg_flags);
5089 : 0 : req.max_bw = rte_cpu_to_le_32(max_bw);
5090 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5091 : :
5092 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5093 : : HWRM_UNLOCK();
5094 : :
5095 : 0 : return rc;
5096 : : }
5097 : :
5098 : 0 : int bnxt_hwrm_set_vf_vlan(struct bnxt *bp, int vf)
5099 : : {
5100 : 0 : struct hwrm_func_cfg_input req = {0};
5101 : 0 : struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
5102 : : int rc = 0;
5103 : :
5104 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
5105 : :
5106 : 0 : req.flags = rte_cpu_to_le_32(bp->pf->vf_info[vf].func_cfg_flags);
5107 : 0 : req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
5108 : 0 : req.enables |= rte_cpu_to_le_32(HWRM_FUNC_CFG_INPUT_ENABLES_DFLT_VLAN);
5109 : 0 : req.dflt_vlan = rte_cpu_to_le_16(bp->pf->vf_info[vf].dflt_vlan);
5110 : :
5111 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5112 : :
5113 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5114 : : HWRM_UNLOCK();
5115 : :
5116 : 0 : return rc;
5117 : : }
5118 : :
5119 : 0 : int bnxt_hwrm_set_async_event_cr(struct bnxt *bp)
5120 : : {
5121 : : int rc;
5122 : :
5123 [ # # ]: 0 : if (BNXT_PF(bp))
5124 : 0 : rc = bnxt_hwrm_func_cfg_def_cp(bp);
5125 : : else
5126 : 0 : rc = bnxt_hwrm_vf_func_cfg_def_cp(bp);
5127 : :
5128 : 0 : return rc;
5129 : : }
5130 : :
5131 : 0 : int bnxt_hwrm_reject_fwd_resp(struct bnxt *bp, uint16_t target_id,
5132 : : void *encaped, size_t ec_size)
5133 : : {
5134 : : int rc = 0;
5135 : 0 : struct hwrm_reject_fwd_resp_input req = {.req_type = 0};
5136 : 0 : struct hwrm_reject_fwd_resp_output *resp = bp->hwrm_cmd_resp_addr;
5137 : :
5138 [ # # ]: 0 : if (ec_size > sizeof(req.encap_request))
5139 : : return -1;
5140 : :
5141 [ # # ]: 0 : HWRM_PREP(&req, HWRM_REJECT_FWD_RESP, BNXT_USE_CHIMP_MB);
5142 : :
5143 : 0 : req.encap_resp_target_id = rte_cpu_to_le_16(target_id);
5144 : : memcpy(req.encap_request, encaped, ec_size);
5145 : :
5146 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5147 : :
5148 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5149 : : HWRM_UNLOCK();
5150 : :
5151 : 0 : return rc;
5152 : : }
5153 : :
5154 : 0 : int bnxt_hwrm_func_qcfg_vf_default_mac(struct bnxt *bp, uint16_t vf,
5155 : : struct rte_ether_addr *mac)
5156 : : {
5157 : 0 : struct hwrm_func_qcfg_input req = {0};
5158 : 0 : struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
5159 : : int rc;
5160 : :
5161 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
5162 : :
5163 : 0 : req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
5164 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5165 : :
5166 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5167 : :
5168 : 0 : memcpy(mac->addr_bytes, resp->mac_address, RTE_ETHER_ADDR_LEN);
5169 : :
5170 : : HWRM_UNLOCK();
5171 : :
5172 : 0 : return rc;
5173 : : }
5174 : :
5175 : 0 : int bnxt_hwrm_exec_fwd_resp(struct bnxt *bp, uint16_t target_id,
5176 : : void *encaped, size_t ec_size)
5177 : : {
5178 : : int rc = 0;
5179 : 0 : struct hwrm_exec_fwd_resp_input req = {.req_type = 0};
5180 : 0 : struct hwrm_exec_fwd_resp_output *resp = bp->hwrm_cmd_resp_addr;
5181 : :
5182 [ # # ]: 0 : if (ec_size > sizeof(req.encap_request))
5183 : : return -1;
5184 : :
5185 [ # # ]: 0 : HWRM_PREP(&req, HWRM_EXEC_FWD_RESP, BNXT_USE_CHIMP_MB);
5186 : :
5187 : 0 : req.encap_resp_target_id = rte_cpu_to_le_16(target_id);
5188 : : memcpy(req.encap_request, encaped, ec_size);
5189 : :
5190 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5191 : :
5192 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5193 : : HWRM_UNLOCK();
5194 : :
5195 : 0 : return rc;
5196 : : }
5197 : :
5198 : : static void bnxt_update_prev_stat(uint64_t *cntr, uint64_t *prev_cntr)
5199 : : {
5200 : : /* One of the HW stat values that make up this counter was zero as
5201 : : * returned by HW in this iteration, so use the previous
5202 : : * iteration's counter value
5203 : : */
5204 : 0 : if (!cntr || !prev_cntr)
5205 : : return;
5206 [ # # # # : 0 : if (*prev_cntr && *cntr == 0)
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # ]
5207 : 0 : *cntr = *prev_cntr;
5208 : : else
5209 : 0 : *prev_cntr = *cntr;
5210 : : }
5211 : :
5212 : 0 : int bnxt_hwrm_ring_stats(struct bnxt *bp, uint32_t cid, int idx,
5213 : : struct bnxt_ring_stats *ring_stats, bool rx)
5214 : : {
5215 : : int rc = 0;
5216 : 0 : struct hwrm_stat_ctx_query_input req = {.req_type = 0};
5217 : 0 : struct hwrm_stat_ctx_query_output *resp = bp->hwrm_cmd_resp_addr;
5218 : :
5219 [ # # ]: 0 : HWRM_PREP(&req, HWRM_STAT_CTX_QUERY, BNXT_USE_CHIMP_MB);
5220 : :
5221 : 0 : req.stat_ctx_id = rte_cpu_to_le_32(cid);
5222 : :
5223 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5224 : :
5225 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5226 : :
5227 [ # # ]: 0 : if (rx) {
5228 : 0 : struct bnxt_ring_stats *prev_stats = &bp->prev_rx_ring_stats[idx];
5229 : :
5230 [ # # ]: 0 : ring_stats->rx_ucast_pkts = rte_le_to_cpu_64(resp->rx_ucast_pkts);
5231 : : bnxt_update_prev_stat(&ring_stats->rx_ucast_pkts,
5232 : : &prev_stats->rx_ucast_pkts);
5233 : :
5234 [ # # ]: 0 : ring_stats->rx_mcast_pkts = rte_le_to_cpu_64(resp->rx_mcast_pkts);
5235 : : bnxt_update_prev_stat(&ring_stats->rx_mcast_pkts,
5236 : : &prev_stats->rx_mcast_pkts);
5237 : :
5238 [ # # ]: 0 : ring_stats->rx_bcast_pkts = rte_le_to_cpu_64(resp->rx_bcast_pkts);
5239 : : bnxt_update_prev_stat(&ring_stats->rx_bcast_pkts,
5240 : : &prev_stats->rx_bcast_pkts);
5241 : :
5242 [ # # ]: 0 : ring_stats->rx_ucast_bytes = rte_le_to_cpu_64(resp->rx_ucast_bytes);
5243 : : bnxt_update_prev_stat(&ring_stats->rx_ucast_bytes,
5244 : : &prev_stats->rx_ucast_bytes);
5245 : :
5246 [ # # ]: 0 : ring_stats->rx_mcast_bytes = rte_le_to_cpu_64(resp->rx_mcast_bytes);
5247 : : bnxt_update_prev_stat(&ring_stats->rx_mcast_bytes,
5248 : : &prev_stats->rx_mcast_bytes);
5249 : :
5250 [ # # ]: 0 : ring_stats->rx_bcast_bytes = rte_le_to_cpu_64(resp->rx_bcast_bytes);
5251 : : bnxt_update_prev_stat(&ring_stats->rx_bcast_bytes,
5252 : : &prev_stats->rx_bcast_bytes);
5253 : :
5254 [ # # ]: 0 : ring_stats->rx_discard_pkts = rte_le_to_cpu_64(resp->rx_discard_pkts);
5255 : : bnxt_update_prev_stat(&ring_stats->rx_discard_pkts,
5256 : : &prev_stats->rx_discard_pkts);
5257 : :
5258 [ # # ]: 0 : ring_stats->rx_error_pkts = rte_le_to_cpu_64(resp->rx_error_pkts);
5259 : : bnxt_update_prev_stat(&ring_stats->rx_error_pkts,
5260 : : &prev_stats->rx_error_pkts);
5261 : :
5262 [ # # ]: 0 : ring_stats->rx_agg_pkts = rte_le_to_cpu_64(resp->rx_agg_pkts);
5263 : : bnxt_update_prev_stat(&ring_stats->rx_agg_pkts,
5264 : : &prev_stats->rx_agg_pkts);
5265 : :
5266 [ # # ]: 0 : ring_stats->rx_agg_bytes = rte_le_to_cpu_64(resp->rx_agg_bytes);
5267 : : bnxt_update_prev_stat(&ring_stats->rx_agg_bytes,
5268 : : &prev_stats->rx_agg_bytes);
5269 : :
5270 [ # # ]: 0 : ring_stats->rx_agg_events = rte_le_to_cpu_64(resp->rx_agg_events);
5271 : : bnxt_update_prev_stat(&ring_stats->rx_agg_events,
5272 : : &prev_stats->rx_agg_events);
5273 : :
5274 [ # # ]: 0 : ring_stats->rx_agg_aborts = rte_le_to_cpu_64(resp->rx_agg_aborts);
5275 : : bnxt_update_prev_stat(&ring_stats->rx_agg_aborts,
5276 : : &prev_stats->rx_agg_aborts);
5277 : : } else {
5278 : 0 : struct bnxt_ring_stats *prev_stats = &bp->prev_tx_ring_stats[idx];
5279 : :
5280 : 0 : ring_stats->tx_ucast_pkts = rte_le_to_cpu_64(resp->tx_ucast_pkts);
5281 [ # # ]: 0 : bnxt_update_prev_stat(&ring_stats->tx_ucast_pkts,
5282 : : &prev_stats->tx_ucast_pkts);
5283 : :
5284 [ # # ]: 0 : ring_stats->tx_mcast_pkts = rte_le_to_cpu_64(resp->tx_mcast_pkts);
5285 : : bnxt_update_prev_stat(&ring_stats->tx_mcast_pkts,
5286 : : &prev_stats->tx_mcast_pkts);
5287 : :
5288 [ # # ]: 0 : ring_stats->tx_bcast_pkts = rte_le_to_cpu_64(resp->tx_bcast_pkts);
5289 : : bnxt_update_prev_stat(&ring_stats->tx_bcast_pkts,
5290 : : &prev_stats->tx_bcast_pkts);
5291 : :
5292 [ # # ]: 0 : ring_stats->tx_ucast_bytes = rte_le_to_cpu_64(resp->tx_ucast_bytes);
5293 : : bnxt_update_prev_stat(&ring_stats->tx_ucast_bytes,
5294 : : &prev_stats->tx_ucast_bytes);
5295 : :
5296 [ # # ]: 0 : ring_stats->tx_mcast_bytes = rte_le_to_cpu_64(resp->tx_mcast_bytes);
5297 : : bnxt_update_prev_stat(&ring_stats->tx_mcast_bytes,
5298 : : &prev_stats->tx_mcast_bytes);
5299 : :
5300 [ # # ]: 0 : ring_stats->tx_bcast_bytes = rte_le_to_cpu_64(resp->tx_bcast_bytes);
5301 : : bnxt_update_prev_stat(&ring_stats->tx_bcast_bytes,
5302 : : &prev_stats->tx_bcast_bytes);
5303 : :
5304 [ # # ]: 0 : ring_stats->tx_discard_pkts = rte_le_to_cpu_64(resp->tx_discard_pkts);
5305 : : bnxt_update_prev_stat(&ring_stats->tx_discard_pkts,
5306 : : &prev_stats->tx_discard_pkts);
5307 : : }
5308 : :
5309 : : HWRM_UNLOCK();
5310 : :
5311 : 0 : return rc;
5312 : : }
5313 : :
5314 : 0 : int bnxt_hwrm_ring_stats_ext(struct bnxt *bp, uint32_t cid, int idx,
5315 : : struct bnxt_ring_stats_ext *ring_stats, bool rx)
5316 : : {
5317 : : int rc = 0;
5318 : 0 : struct hwrm_stat_ext_ctx_query_input req = {.req_type = 0};
5319 : 0 : struct hwrm_stat_ext_ctx_query_output *resp = bp->hwrm_cmd_resp_addr;
5320 : :
5321 [ # # ]: 0 : HWRM_PREP(&req, HWRM_STAT_EXT_CTX_QUERY, BNXT_USE_CHIMP_MB);
5322 : :
5323 : 0 : req.stat_ctx_id = rte_cpu_to_le_32(cid);
5324 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5325 : :
5326 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5327 : :
5328 [ # # ]: 0 : if (rx) {
5329 : 0 : struct bnxt_ring_stats_ext *prev_stats = &bp->prev_rx_ring_stats_ext[idx];
5330 : :
5331 : 0 : ring_stats->rx_ucast_pkts = rte_le_to_cpu_64(resp->rx_ucast_pkts);
5332 [ # # ]: 0 : bnxt_update_prev_stat(&ring_stats->rx_ucast_pkts,
5333 : : &prev_stats->rx_ucast_pkts);
5334 : :
5335 [ # # ]: 0 : ring_stats->rx_mcast_pkts = rte_le_to_cpu_64(resp->rx_mcast_pkts);
5336 : : bnxt_update_prev_stat(&ring_stats->rx_mcast_pkts,
5337 : : &prev_stats->rx_mcast_pkts);
5338 : :
5339 [ # # ]: 0 : ring_stats->rx_bcast_pkts = rte_le_to_cpu_64(resp->rx_bcast_pkts);
5340 : : bnxt_update_prev_stat(&ring_stats->rx_bcast_pkts,
5341 : : &prev_stats->rx_bcast_pkts);
5342 : :
5343 [ # # ]: 0 : ring_stats->rx_ucast_bytes = rte_le_to_cpu_64(resp->rx_ucast_bytes);
5344 : : bnxt_update_prev_stat(&ring_stats->rx_ucast_bytes,
5345 : : &prev_stats->rx_ucast_bytes);
5346 : :
5347 [ # # ]: 0 : ring_stats->rx_mcast_bytes = rte_le_to_cpu_64(resp->rx_mcast_bytes);
5348 : : bnxt_update_prev_stat(&ring_stats->rx_mcast_bytes,
5349 : : &prev_stats->rx_mcast_bytes);
5350 : :
5351 [ # # ]: 0 : ring_stats->rx_bcast_bytes = rte_le_to_cpu_64(resp->rx_bcast_bytes);
5352 : : bnxt_update_prev_stat(&ring_stats->rx_bcast_bytes,
5353 : : &prev_stats->rx_bcast_bytes);
5354 : :
5355 [ # # ]: 0 : ring_stats->rx_discard_pkts = rte_le_to_cpu_64(resp->rx_discard_pkts);
5356 : : bnxt_update_prev_stat(&ring_stats->rx_discard_pkts,
5357 : : &prev_stats->rx_discard_pkts);
5358 : :
5359 [ # # ]: 0 : ring_stats->rx_error_pkts = rte_le_to_cpu_64(resp->rx_error_pkts);
5360 : : bnxt_update_prev_stat(&ring_stats->rx_error_pkts,
5361 : : &prev_stats->rx_error_pkts);
5362 : :
5363 [ # # ]: 0 : ring_stats->rx_tpa_eligible_pkt = rte_le_to_cpu_64(resp->rx_tpa_eligible_pkt);
5364 : : bnxt_update_prev_stat(&ring_stats->rx_tpa_eligible_pkt,
5365 : : &prev_stats->rx_tpa_eligible_pkt);
5366 : :
5367 [ # # ]: 0 : ring_stats->rx_tpa_eligible_bytes = rte_le_to_cpu_64(resp->rx_tpa_eligible_bytes);
5368 : : bnxt_update_prev_stat(&ring_stats->rx_tpa_eligible_bytes,
5369 : : &prev_stats->rx_tpa_eligible_bytes);
5370 : :
5371 [ # # ]: 0 : ring_stats->rx_tpa_pkt = rte_le_to_cpu_64(resp->rx_tpa_pkt);
5372 : : bnxt_update_prev_stat(&ring_stats->rx_tpa_pkt,
5373 : : &prev_stats->rx_tpa_pkt);
5374 : :
5375 [ # # ]: 0 : ring_stats->rx_tpa_bytes = rte_le_to_cpu_64(resp->rx_tpa_bytes);
5376 : : bnxt_update_prev_stat(&ring_stats->rx_tpa_bytes,
5377 : : &prev_stats->rx_tpa_bytes);
5378 : :
5379 [ # # ]: 0 : ring_stats->rx_tpa_errors = rte_le_to_cpu_64(resp->rx_tpa_errors);
5380 : : bnxt_update_prev_stat(&ring_stats->rx_tpa_errors,
5381 : : &prev_stats->rx_tpa_errors);
5382 : :
5383 [ # # ]: 0 : ring_stats->rx_tpa_events = rte_le_to_cpu_64(resp->rx_tpa_events);
5384 : : bnxt_update_prev_stat(&ring_stats->rx_tpa_events,
5385 : : &prev_stats->rx_tpa_events);
5386 : : } else {
5387 : 0 : struct bnxt_ring_stats_ext *prev_stats = &bp->prev_tx_ring_stats_ext[idx];
5388 : :
5389 [ # # ]: 0 : ring_stats->tx_ucast_pkts = rte_le_to_cpu_64(resp->tx_ucast_pkts);
5390 : : bnxt_update_prev_stat(&ring_stats->tx_ucast_pkts,
5391 : : &prev_stats->tx_ucast_pkts);
5392 : :
5393 [ # # ]: 0 : ring_stats->tx_mcast_pkts = rte_le_to_cpu_64(resp->tx_mcast_pkts);
5394 : : bnxt_update_prev_stat(&ring_stats->tx_mcast_pkts,
5395 : : &prev_stats->tx_mcast_pkts);
5396 : :
5397 [ # # ]: 0 : ring_stats->tx_bcast_pkts = rte_le_to_cpu_64(resp->tx_bcast_pkts);
5398 : : bnxt_update_prev_stat(&ring_stats->tx_bcast_pkts,
5399 : : &prev_stats->tx_bcast_pkts);
5400 : :
5401 [ # # ]: 0 : ring_stats->tx_ucast_bytes = rte_le_to_cpu_64(resp->tx_ucast_bytes);
5402 : : bnxt_update_prev_stat(&ring_stats->tx_ucast_bytes,
5403 : : &prev_stats->tx_ucast_bytes);
5404 : :
5405 [ # # ]: 0 : ring_stats->tx_mcast_bytes = rte_le_to_cpu_64(resp->tx_mcast_bytes);
5406 : : bnxt_update_prev_stat(&ring_stats->tx_mcast_bytes,
5407 : : &prev_stats->tx_mcast_bytes);
5408 : :
5409 [ # # ]: 0 : ring_stats->tx_bcast_bytes = rte_le_to_cpu_64(resp->tx_bcast_bytes);
5410 : : bnxt_update_prev_stat(&ring_stats->tx_bcast_bytes,
5411 : : &prev_stats->tx_bcast_bytes);
5412 : :
5413 [ # # ]: 0 : ring_stats->tx_discard_pkts = rte_le_to_cpu_64(resp->tx_discard_pkts);
5414 : : bnxt_update_prev_stat(&ring_stats->tx_discard_pkts,
5415 : : &prev_stats->tx_discard_pkts);
5416 : :
5417 [ # # ]: 0 : ring_stats->tx_error_pkts = rte_le_to_cpu_64(resp->tx_error_pkts);
5418 : : bnxt_update_prev_stat(&ring_stats->tx_error_pkts,
5419 : : &prev_stats->tx_error_pkts);
5420 : : }
5421 : :
5422 : : HWRM_UNLOCK();
5423 : :
5424 : 0 : return rc;
5425 : : }
5426 : :
5427 : 0 : int bnxt_hwrm_port_qstats(struct bnxt *bp)
5428 : : {
5429 : 0 : struct hwrm_port_qstats_input req = {0};
5430 : 0 : struct hwrm_port_qstats_output *resp = bp->hwrm_cmd_resp_addr;
5431 : 0 : struct bnxt_pf_info *pf = bp->pf;
5432 : : int rc;
5433 : :
5434 [ # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_QSTATS, BNXT_USE_CHIMP_MB);
5435 : :
5436 : 0 : req.port_id = rte_cpu_to_le_16(pf->port_id);
5437 : 0 : req.tx_stat_host_addr = rte_cpu_to_le_64(bp->hw_tx_port_stats_map);
5438 : 0 : req.rx_stat_host_addr = rte_cpu_to_le_64(bp->hw_rx_port_stats_map);
5439 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5440 : :
5441 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5442 : : HWRM_UNLOCK();
5443 : :
5444 : 0 : return rc;
5445 : : }
5446 : :
5447 : 0 : int bnxt_hwrm_port_clr_stats(struct bnxt *bp)
5448 : : {
5449 : 0 : struct hwrm_port_clr_stats_input req = {0};
5450 : 0 : struct hwrm_port_clr_stats_output *resp = bp->hwrm_cmd_resp_addr;
5451 : 0 : struct bnxt_pf_info *pf = bp->pf;
5452 : : int rc;
5453 : :
5454 : : /* Not allowed on NS2 device, NPAR, MultiHost, VF */
5455 [ # # ]: 0 : if (!(bp->flags & BNXT_FLAG_PORT_STATS) || BNXT_VF(bp) ||
5456 [ # # ]: 0 : BNXT_NPAR(bp) || BNXT_MH(bp) || BNXT_TOTAL_VFS(bp))
5457 : : return 0;
5458 : :
5459 [ # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_CLR_STATS, BNXT_USE_CHIMP_MB);
5460 : :
5461 : 0 : req.port_id = rte_cpu_to_le_16(pf->port_id);
5462 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5463 : :
5464 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5465 : : HWRM_UNLOCK();
5466 : :
5467 : 0 : return rc;
5468 : : }
5469 : :
5470 : 0 : int bnxt_hwrm_port_led_qcaps(struct bnxt *bp)
5471 : : {
5472 : 0 : struct hwrm_port_led_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
5473 : 0 : struct hwrm_port_led_qcaps_input req = {0};
5474 : : int rc;
5475 : :
5476 [ # # ]: 0 : if (BNXT_VF(bp))
5477 : : return 0;
5478 : :
5479 [ # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_LED_QCAPS, BNXT_USE_CHIMP_MB);
5480 : 0 : req.port_id = bp->pf->port_id;
5481 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5482 : :
5483 [ # # # # ]: 0 : HWRM_CHECK_RESULT_SILENT();
5484 : :
5485 [ # # ]: 0 : if (resp->num_leds > 0 && resp->num_leds < BNXT_MAX_LED) {
5486 : : unsigned int i;
5487 : :
5488 : 0 : bp->leds->num_leds = resp->num_leds;
5489 : 0 : memcpy(bp->leds, &resp->led0_id,
5490 : 0 : sizeof(bp->leds[0]) * bp->leds->num_leds);
5491 [ # # ]: 0 : for (i = 0; i < bp->leds->num_leds; i++) {
5492 : 0 : struct bnxt_led_info *led = &bp->leds[i];
5493 : :
5494 : 0 : uint16_t caps = led->led_state_caps;
5495 : :
5496 [ # # # # ]: 0 : if (!led->led_group_id ||
5497 : : !BNXT_LED_ALT_BLINK_CAP(caps)) {
5498 : 0 : bp->leds->num_leds = 0;
5499 : 0 : break;
5500 : : }
5501 : : }
5502 : : }
5503 : :
5504 : : HWRM_UNLOCK();
5505 : :
5506 : 0 : return rc;
5507 : : }
5508 : :
5509 : 0 : int bnxt_hwrm_port_led_cfg(struct bnxt *bp, bool led_on)
5510 : : {
5511 : 0 : struct hwrm_port_led_cfg_output *resp = bp->hwrm_cmd_resp_addr;
5512 : 0 : struct hwrm_port_led_cfg_input req = {0};
5513 : : struct bnxt_led_cfg *led_cfg;
5514 : : uint8_t led_state = HWRM_PORT_LED_QCFG_OUTPUT_LED0_STATE_DEFAULT;
5515 : : uint16_t duration = 0;
5516 : : int rc, i;
5517 : :
5518 [ # # # # : 0 : if (BNXT_VF(bp) || !bp->leds || !bp->leds->num_leds)
# # ]
5519 : : return -EOPNOTSUPP;
5520 : :
5521 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_LED_CFG, BNXT_USE_CHIMP_MB);
5522 : :
5523 [ # # ]: 0 : if (led_on) {
5524 : : led_state = HWRM_PORT_LED_CFG_INPUT_LED0_STATE_BLINKALT;
5525 : : duration = rte_cpu_to_le_16(500);
5526 : : }
5527 : 0 : req.port_id = bp->pf->port_id;
5528 : 0 : req.num_leds = bp->leds->num_leds;
5529 : : led_cfg = (struct bnxt_led_cfg *)&req.led0_id;
5530 [ # # ]: 0 : for (i = 0; i < bp->leds->num_leds; i++, led_cfg++) {
5531 : 0 : req.enables |= BNXT_LED_DFLT_ENABLES(i);
5532 : 0 : led_cfg->led_id = bp->leds[i].led_id;
5533 : 0 : led_cfg->led_state = led_state;
5534 : 0 : led_cfg->led_blink_on = duration;
5535 : 0 : led_cfg->led_blink_off = duration;
5536 : 0 : led_cfg->led_group_id = bp->leds[i].led_group_id;
5537 : : }
5538 : :
5539 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5540 : :
5541 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5542 : : HWRM_UNLOCK();
5543 : :
5544 : 0 : return rc;
5545 : : }
5546 : :
5547 : 0 : int bnxt_hwrm_nvm_get_dir_info(struct bnxt *bp, uint32_t *entries,
5548 : : uint32_t *length)
5549 : : {
5550 : : int rc;
5551 : 0 : struct hwrm_nvm_get_dir_info_input req = {0};
5552 : 0 : struct hwrm_nvm_get_dir_info_output *resp = bp->hwrm_cmd_resp_addr;
5553 : :
5554 [ # # ]: 0 : HWRM_PREP(&req, HWRM_NVM_GET_DIR_INFO, BNXT_USE_CHIMP_MB);
5555 : :
5556 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5557 : :
5558 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5559 : :
5560 : 0 : *entries = rte_le_to_cpu_32(resp->entries);
5561 : 0 : *length = rte_le_to_cpu_32(resp->entry_length);
5562 : :
5563 : : HWRM_UNLOCK();
5564 : 0 : return rc;
5565 : : }
5566 : :
5567 : 0 : int bnxt_get_nvram_directory(struct bnxt *bp, uint32_t len, uint8_t *data)
5568 : : {
5569 : : int rc;
5570 : : uint32_t dir_entries;
5571 : : uint32_t entry_length;
5572 : : uint8_t *buf;
5573 : : size_t buflen;
5574 : : rte_iova_t dma_handle;
5575 : 0 : struct hwrm_nvm_get_dir_entries_input req = {0};
5576 : 0 : struct hwrm_nvm_get_dir_entries_output *resp = bp->hwrm_cmd_resp_addr;
5577 : :
5578 : 0 : rc = bnxt_hwrm_nvm_get_dir_info(bp, &dir_entries, &entry_length);
5579 [ # # ]: 0 : if (rc != 0)
5580 : : return rc;
5581 : :
5582 : 0 : *data++ = dir_entries;
5583 : 0 : *data++ = entry_length;
5584 : 0 : len -= 2;
5585 : 0 : memset(data, 0xff, len);
5586 : :
5587 : 0 : buflen = dir_entries * entry_length;
5588 : 0 : buf = rte_malloc("nvm_dir", buflen, 0);
5589 [ # # ]: 0 : if (buf == NULL)
5590 : : return -ENOMEM;
5591 : 0 : dma_handle = rte_malloc_virt2iova(buf);
5592 [ # # ]: 0 : if (dma_handle == RTE_BAD_IOVA) {
5593 : 0 : rte_free(buf);
5594 : 0 : PMD_DRV_LOG(ERR,
5595 : : "unable to map response address to physical memory\n");
5596 : 0 : return -ENOMEM;
5597 : : }
5598 [ # # ]: 0 : HWRM_PREP(&req, HWRM_NVM_GET_DIR_ENTRIES, BNXT_USE_CHIMP_MB);
5599 : 0 : req.host_dest_addr = rte_cpu_to_le_64(dma_handle);
5600 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5601 : :
5602 [ # # ]: 0 : if (rc == 0)
5603 : 0 : memcpy(data, buf, len > buflen ? buflen : len);
5604 : :
5605 : 0 : rte_free(buf);
5606 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5607 : : HWRM_UNLOCK();
5608 : :
5609 : 0 : return rc;
5610 : : }
5611 : :
5612 : 0 : int bnxt_hwrm_get_nvram_item(struct bnxt *bp, uint32_t index,
5613 : : uint32_t offset, uint32_t length,
5614 : : uint8_t *data)
5615 : : {
5616 : : int rc;
5617 : : uint8_t *buf;
5618 : : rte_iova_t dma_handle;
5619 : 0 : struct hwrm_nvm_read_input req = {0};
5620 : 0 : struct hwrm_nvm_read_output *resp = bp->hwrm_cmd_resp_addr;
5621 : :
5622 : 0 : buf = rte_malloc("nvm_item", length, 0);
5623 [ # # ]: 0 : if (!buf)
5624 : : return -ENOMEM;
5625 : :
5626 : 0 : dma_handle = rte_malloc_virt2iova(buf);
5627 [ # # ]: 0 : if (dma_handle == RTE_BAD_IOVA) {
5628 : 0 : rte_free(buf);
5629 : 0 : PMD_DRV_LOG(ERR,
5630 : : "unable to map response address to physical memory\n");
5631 : 0 : return -ENOMEM;
5632 : : }
5633 [ # # ]: 0 : HWRM_PREP(&req, HWRM_NVM_READ, BNXT_USE_CHIMP_MB);
5634 : 0 : req.host_dest_addr = rte_cpu_to_le_64(dma_handle);
5635 : 0 : req.dir_idx = rte_cpu_to_le_16(index);
5636 : 0 : req.offset = rte_cpu_to_le_32(offset);
5637 : 0 : req.len = rte_cpu_to_le_32(length);
5638 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5639 [ # # ]: 0 : if (rc == 0)
5640 : : memcpy(data, buf, length);
5641 : :
5642 : 0 : rte_free(buf);
5643 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5644 : : HWRM_UNLOCK();
5645 : :
5646 : 0 : return rc;
5647 : : }
5648 : :
5649 : 0 : int bnxt_hwrm_erase_nvram_directory(struct bnxt *bp, uint8_t index)
5650 : : {
5651 : : int rc;
5652 : 0 : struct hwrm_nvm_erase_dir_entry_input req = {0};
5653 : 0 : struct hwrm_nvm_erase_dir_entry_output *resp = bp->hwrm_cmd_resp_addr;
5654 : :
5655 [ # # ]: 0 : HWRM_PREP(&req, HWRM_NVM_ERASE_DIR_ENTRY, BNXT_USE_CHIMP_MB);
5656 : 0 : req.dir_idx = rte_cpu_to_le_16(index);
5657 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5658 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5659 : : HWRM_UNLOCK();
5660 : :
5661 : 0 : return rc;
5662 : : }
5663 : :
5664 : 0 : int bnxt_hwrm_flash_nvram(struct bnxt *bp, uint16_t dir_type,
5665 : : uint16_t dir_ordinal, uint16_t dir_ext,
5666 : : uint16_t dir_attr, const uint8_t *data,
5667 : : size_t data_len)
5668 : : {
5669 : : int rc;
5670 : 0 : struct hwrm_nvm_write_input req = {0};
5671 : 0 : struct hwrm_nvm_write_output *resp = bp->hwrm_cmd_resp_addr;
5672 : : rte_iova_t dma_handle;
5673 : : uint8_t *buf;
5674 : :
5675 : 0 : buf = rte_malloc("nvm_write", data_len, 0);
5676 [ # # ]: 0 : if (!buf)
5677 : : return -ENOMEM;
5678 : :
5679 : 0 : dma_handle = rte_malloc_virt2iova(buf);
5680 [ # # ]: 0 : if (dma_handle == RTE_BAD_IOVA) {
5681 : 0 : rte_free(buf);
5682 : 0 : PMD_DRV_LOG(ERR,
5683 : : "unable to map response address to physical memory\n");
5684 : 0 : return -ENOMEM;
5685 : : }
5686 : : memcpy(buf, data, data_len);
5687 : :
5688 [ # # ]: 0 : HWRM_PREP(&req, HWRM_NVM_WRITE, BNXT_USE_CHIMP_MB);
5689 : :
5690 : 0 : req.dir_type = rte_cpu_to_le_16(dir_type);
5691 : 0 : req.dir_ordinal = rte_cpu_to_le_16(dir_ordinal);
5692 : 0 : req.dir_ext = rte_cpu_to_le_16(dir_ext);
5693 : 0 : req.dir_attr = rte_cpu_to_le_16(dir_attr);
5694 : 0 : req.dir_data_length = rte_cpu_to_le_32(data_len);
5695 : 0 : req.host_src_addr = rte_cpu_to_le_64(dma_handle);
5696 : :
5697 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5698 : :
5699 : 0 : rte_free(buf);
5700 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5701 : : HWRM_UNLOCK();
5702 : :
5703 : 0 : return rc;
5704 : : }
5705 : :
5706 : : static void
5707 : 0 : bnxt_vnic_count(struct bnxt_vnic_info *vnic __rte_unused, void *cbdata)
5708 : : {
5709 : : uint32_t *count = cbdata;
5710 : :
5711 : 0 : *count = *count + 1;
5712 : 0 : }
5713 : :
5714 : 0 : static int bnxt_vnic_count_hwrm_stub(struct bnxt *bp __rte_unused,
5715 : : struct bnxt_vnic_info *vnic __rte_unused)
5716 : : {
5717 : 0 : return 0;
5718 : : }
5719 : :
5720 : 0 : int bnxt_vf_vnic_count(struct bnxt *bp, uint16_t vf)
5721 : : {
5722 : 0 : uint32_t count = 0;
5723 : :
5724 : 0 : bnxt_hwrm_func_vf_vnic_query_and_config(bp, vf, bnxt_vnic_count,
5725 : : &count, bnxt_vnic_count_hwrm_stub);
5726 : :
5727 : 0 : return count;
5728 : : }
5729 : :
5730 : 0 : static int bnxt_hwrm_func_vf_vnic_query(struct bnxt *bp, uint16_t vf,
5731 : : uint16_t *vnic_ids)
5732 : : {
5733 : 0 : struct hwrm_func_vf_vnic_ids_query_input req = {0};
5734 : 0 : struct hwrm_func_vf_vnic_ids_query_output *resp =
5735 : : bp->hwrm_cmd_resp_addr;
5736 : : int rc;
5737 : :
5738 : : /* First query all VNIC ids */
5739 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_VF_VNIC_IDS_QUERY, BNXT_USE_CHIMP_MB);
5740 : :
5741 : 0 : req.vf_id = rte_cpu_to_le_16(bp->pf->first_vf_id + vf);
5742 : 0 : req.max_vnic_id_cnt = rte_cpu_to_le_32(bp->pf->total_vnics);
5743 : 0 : req.vnic_id_tbl_addr = rte_cpu_to_le_64(rte_malloc_virt2iova(vnic_ids));
5744 : :
5745 [ # # ]: 0 : if (req.vnic_id_tbl_addr == RTE_BAD_IOVA) {
5746 : : HWRM_UNLOCK();
5747 : 0 : PMD_DRV_LOG(ERR,
5748 : : "unable to map VNIC ID table address to physical memory\n");
5749 : 0 : return -ENOMEM;
5750 : : }
5751 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5752 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5753 : 0 : rc = rte_le_to_cpu_32(resp->vnic_id_cnt);
5754 : :
5755 : : HWRM_UNLOCK();
5756 : :
5757 : 0 : return rc;
5758 : : }
5759 : :
5760 : : /*
5761 : : * This function queries the VNIC IDs for a specified VF. It then calls
5762 : : * the vnic_cb to update the necessary field in vnic_info with cbdata.
5763 : : * Then it calls the hwrm_cb function to program this new vnic configuration.
5764 : : */
5765 : 0 : int bnxt_hwrm_func_vf_vnic_query_and_config(struct bnxt *bp, uint16_t vf,
5766 : : void (*vnic_cb)(struct bnxt_vnic_info *, void *), void *cbdata,
5767 : : int (*hwrm_cb)(struct bnxt *bp, struct bnxt_vnic_info *vnic))
5768 : : {
5769 : : struct bnxt_vnic_info vnic;
5770 : : int rc = 0;
5771 : : int i, num_vnic_ids;
5772 : : uint16_t *vnic_ids;
5773 : : size_t vnic_id_sz;
5774 : : size_t sz;
5775 : :
5776 : : /* First query all VNIC ids */
5777 : 0 : vnic_id_sz = bp->pf->total_vnics * sizeof(*vnic_ids);
5778 : 0 : vnic_ids = rte_malloc("bnxt_hwrm_vf_vnic_ids_query", vnic_id_sz,
5779 : : RTE_CACHE_LINE_SIZE);
5780 [ # # ]: 0 : if (vnic_ids == NULL)
5781 : : return -ENOMEM;
5782 : :
5783 [ # # ]: 0 : for (sz = 0; sz < vnic_id_sz; sz += getpagesize())
5784 : 0 : rte_mem_lock_page(((char *)vnic_ids) + sz);
5785 : :
5786 : 0 : num_vnic_ids = bnxt_hwrm_func_vf_vnic_query(bp, vf, vnic_ids);
5787 : :
5788 [ # # ]: 0 : if (num_vnic_ids < 0)
5789 : : return num_vnic_ids;
5790 : :
5791 : : /* Retrieve VNIC, update bd_stall then update */
5792 : :
5793 [ # # ]: 0 : for (i = 0; i < num_vnic_ids; i++) {
5794 : : memset(&vnic, 0, sizeof(struct bnxt_vnic_info));
5795 : 0 : vnic.fw_vnic_id = rte_le_to_cpu_16(vnic_ids[i]);
5796 : 0 : rc = bnxt_hwrm_vnic_qcfg(bp, &vnic, bp->pf->first_vf_id + vf);
5797 [ # # ]: 0 : if (rc)
5798 : : break;
5799 [ # # ]: 0 : if (vnic.mru <= 4) /* Indicates unallocated */
5800 : 0 : continue;
5801 : :
5802 : 0 : vnic_cb(&vnic, cbdata);
5803 : :
5804 : 0 : rc = hwrm_cb(bp, &vnic);
5805 [ # # ]: 0 : if (rc)
5806 : : break;
5807 : : }
5808 : :
5809 : 0 : rte_free(vnic_ids);
5810 : :
5811 : 0 : return rc;
5812 : : }
5813 : :
5814 : 0 : int bnxt_hwrm_func_cfg_vf_set_vlan_anti_spoof(struct bnxt *bp, uint16_t vf,
5815 : : bool on)
5816 : : {
5817 : 0 : struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
5818 : 0 : struct hwrm_func_cfg_input req = {0};
5819 : : int rc;
5820 : :
5821 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
5822 : :
5823 : 0 : req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
5824 : 0 : req.enables |= rte_cpu_to_le_32(
5825 : : HWRM_FUNC_CFG_INPUT_ENABLES_VLAN_ANTISPOOF_MODE);
5826 [ # # ]: 0 : req.vlan_antispoof_mode = on ?
5827 : : HWRM_FUNC_CFG_INPUT_VLAN_ANTISPOOF_MODE_VALIDATE_VLAN :
5828 : : HWRM_FUNC_CFG_INPUT_VLAN_ANTISPOOF_MODE_NOCHECK;
5829 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5830 : :
5831 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5832 : : HWRM_UNLOCK();
5833 : :
5834 : 0 : return rc;
5835 : : }
5836 : :
5837 : 0 : int bnxt_hwrm_func_qcfg_vf_dflt_vnic_id(struct bnxt *bp, int vf)
5838 : : {
5839 : : struct bnxt_vnic_info vnic;
5840 : : uint16_t *vnic_ids;
5841 : : size_t vnic_id_sz;
5842 : : int num_vnic_ids, i;
5843 : : size_t sz;
5844 : : int rc;
5845 : :
5846 : 0 : vnic_id_sz = bp->pf->total_vnics * sizeof(*vnic_ids);
5847 : 0 : vnic_ids = rte_malloc("bnxt_hwrm_vf_vnic_ids_query", vnic_id_sz,
5848 : : RTE_CACHE_LINE_SIZE);
5849 [ # # ]: 0 : if (vnic_ids == NULL)
5850 : : return -ENOMEM;
5851 : :
5852 [ # # ]: 0 : for (sz = 0; sz < vnic_id_sz; sz += getpagesize())
5853 : 0 : rte_mem_lock_page(((char *)vnic_ids) + sz);
5854 : :
5855 : 0 : rc = bnxt_hwrm_func_vf_vnic_query(bp, vf, vnic_ids);
5856 [ # # ]: 0 : if (rc <= 0)
5857 : 0 : goto exit;
5858 : : num_vnic_ids = rc;
5859 : :
5860 : : /*
5861 : : * Loop through to find the default VNIC ID.
5862 : : * TODO: The easier way would be to obtain the resp->dflt_vnic_id
5863 : : * by sending the hwrm_func_qcfg command to the firmware.
5864 : : */
5865 [ # # ]: 0 : for (i = 0; i < num_vnic_ids; i++) {
5866 : : memset(&vnic, 0, sizeof(struct bnxt_vnic_info));
5867 : 0 : vnic.fw_vnic_id = rte_le_to_cpu_16(vnic_ids[i]);
5868 : 0 : rc = bnxt_hwrm_vnic_qcfg(bp, &vnic,
5869 : 0 : bp->pf->first_vf_id + vf);
5870 [ # # ]: 0 : if (rc)
5871 : 0 : goto exit;
5872 [ # # ]: 0 : if (vnic.func_default) {
5873 : 0 : rte_free(vnic_ids);
5874 : 0 : return vnic.fw_vnic_id;
5875 : : }
5876 : : }
5877 : : /* Could not find a default VNIC. */
5878 : 0 : PMD_DRV_LOG(ERR, "No default VNIC\n");
5879 : 0 : exit:
5880 : 0 : rte_free(vnic_ids);
5881 : 0 : return rc;
5882 : : }
5883 : :
5884 : 0 : int bnxt_hwrm_set_em_filter(struct bnxt *bp,
5885 : : uint16_t dst_id,
5886 : : struct bnxt_filter_info *filter)
5887 : : {
5888 : : int rc = 0;
5889 : 0 : struct hwrm_cfa_em_flow_alloc_input req = {.req_type = 0 };
5890 : 0 : struct hwrm_cfa_em_flow_alloc_output *resp = bp->hwrm_cmd_resp_addr;
5891 : : uint32_t enables = 0;
5892 : :
5893 [ # # ]: 0 : if (filter->fw_em_filter_id != UINT64_MAX)
5894 : 0 : bnxt_hwrm_clear_em_filter(bp, filter);
5895 : :
5896 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_EM_FLOW_ALLOC, BNXT_USE_KONG(bp));
5897 : :
5898 : 0 : req.flags = rte_cpu_to_le_32(filter->flags);
5899 : :
5900 : 0 : enables = filter->enables |
5901 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_DST_ID;
5902 : 0 : req.dst_id = rte_cpu_to_le_16(dst_id);
5903 : :
5904 [ # # ]: 0 : if (filter->ip_addr_type) {
5905 : 0 : req.ip_addr_type = filter->ip_addr_type;
5906 : 0 : enables |= HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_IPADDR_TYPE;
5907 : : }
5908 [ # # ]: 0 : if (enables &
5909 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_L2_FILTER_ID)
5910 : 0 : req.l2_filter_id = rte_cpu_to_le_64(filter->fw_l2_filter_id);
5911 [ # # ]: 0 : if (enables &
5912 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_SRC_MACADDR)
5913 : : memcpy(req.src_macaddr, filter->src_macaddr,
5914 : : RTE_ETHER_ADDR_LEN);
5915 [ # # ]: 0 : if (enables &
5916 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_DST_MACADDR)
5917 : : memcpy(req.dst_macaddr, filter->dst_macaddr,
5918 : : RTE_ETHER_ADDR_LEN);
5919 [ # # ]: 0 : if (enables &
5920 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_OVLAN_VID)
5921 : 0 : req.ovlan_vid = filter->l2_ovlan;
5922 [ # # ]: 0 : if (enables &
5923 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_IVLAN_VID)
5924 : 0 : req.ivlan_vid = filter->l2_ivlan;
5925 [ # # ]: 0 : if (enables &
5926 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_ETHERTYPE)
5927 [ # # ]: 0 : req.ethertype = rte_cpu_to_be_16(filter->ethertype);
5928 [ # # ]: 0 : if (enables &
5929 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_IP_PROTOCOL)
5930 : 0 : req.ip_protocol = filter->ip_protocol;
5931 [ # # ]: 0 : if (enables &
5932 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_SRC_IPADDR)
5933 [ # # ]: 0 : req.src_ipaddr[0] = rte_cpu_to_be_32(filter->src_ipaddr[0]);
5934 [ # # ]: 0 : if (enables &
5935 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_DST_IPADDR)
5936 [ # # ]: 0 : req.dst_ipaddr[0] = rte_cpu_to_be_32(filter->dst_ipaddr[0]);
5937 [ # # ]: 0 : if (enables &
5938 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_SRC_PORT)
5939 [ # # ]: 0 : req.src_port = rte_cpu_to_be_16(filter->src_port);
5940 [ # # ]: 0 : if (enables &
5941 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_DST_PORT)
5942 [ # # ]: 0 : req.dst_port = rte_cpu_to_be_16(filter->dst_port);
5943 [ # # ]: 0 : if (enables &
5944 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_MIRROR_VNIC_ID)
5945 : 0 : req.mirror_vnic_id = filter->mirror_vnic_id;
5946 : :
5947 : 0 : req.enables = rte_cpu_to_le_32(enables);
5948 : :
5949 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
5950 : :
5951 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5952 : :
5953 : 0 : filter->fw_em_filter_id = rte_le_to_cpu_64(resp->em_filter_id);
5954 : : HWRM_UNLOCK();
5955 : :
5956 : 0 : return rc;
5957 : : }
5958 : :
5959 : 0 : int bnxt_hwrm_clear_em_filter(struct bnxt *bp, struct bnxt_filter_info *filter)
5960 : : {
5961 : : int rc = 0;
5962 : 0 : struct hwrm_cfa_em_flow_free_input req = {.req_type = 0 };
5963 : 0 : struct hwrm_cfa_em_flow_free_output *resp = bp->hwrm_cmd_resp_addr;
5964 : :
5965 [ # # ]: 0 : if (filter->fw_em_filter_id == UINT64_MAX)
5966 : : return 0;
5967 : :
5968 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_EM_FLOW_FREE, BNXT_USE_KONG(bp));
5969 : :
5970 : 0 : req.em_filter_id = rte_cpu_to_le_64(filter->fw_em_filter_id);
5971 : :
5972 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
5973 : :
5974 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5975 : : HWRM_UNLOCK();
5976 : :
5977 : 0 : filter->fw_em_filter_id = UINT64_MAX;
5978 : 0 : filter->fw_l2_filter_id = UINT64_MAX;
5979 : :
5980 : 0 : return 0;
5981 : : }
5982 : :
5983 : 0 : int bnxt_hwrm_set_ntuple_filter(struct bnxt *bp,
5984 : : uint16_t dst_id,
5985 : : struct bnxt_filter_info *filter)
5986 : : {
5987 : : int rc = 0;
5988 : 0 : struct hwrm_cfa_ntuple_filter_alloc_input req = {.req_type = 0 };
5989 : 0 : struct hwrm_cfa_ntuple_filter_alloc_output *resp =
5990 : : bp->hwrm_cmd_resp_addr;
5991 : : uint32_t enables = 0;
5992 : :
5993 [ # # ]: 0 : if (filter->fw_ntuple_filter_id != UINT64_MAX)
5994 : 0 : bnxt_hwrm_clear_ntuple_filter(bp, filter);
5995 : :
5996 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_NTUPLE_FILTER_ALLOC, BNXT_USE_CHIMP_MB);
5997 : :
5998 : 0 : req.flags = rte_cpu_to_le_32(filter->flags);
5999 : :
6000 : 0 : enables = filter->enables |
6001 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_ID;
6002 : 0 : req.dst_id = rte_cpu_to_le_16(dst_id);
6003 : :
6004 [ # # ]: 0 : if (filter->ip_addr_type) {
6005 : 0 : req.ip_addr_type = filter->ip_addr_type;
6006 : 0 : enables |=
6007 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_IPADDR_TYPE;
6008 : : }
6009 [ # # ]: 0 : if (enables &
6010 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_L2_FILTER_ID)
6011 : 0 : req.l2_filter_id = rte_cpu_to_le_64(filter->fw_l2_filter_id);
6012 [ # # ]: 0 : if (enables &
6013 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_MACADDR)
6014 : : memcpy(req.src_macaddr, filter->src_macaddr,
6015 : : RTE_ETHER_ADDR_LEN);
6016 [ # # ]: 0 : if (enables &
6017 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_ETHERTYPE)
6018 [ # # ]: 0 : req.ethertype = rte_cpu_to_be_16(filter->ethertype);
6019 [ # # ]: 0 : if (enables &
6020 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_IP_PROTOCOL)
6021 : 0 : req.ip_protocol = filter->ip_protocol;
6022 [ # # ]: 0 : if (enables &
6023 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_IPADDR)
6024 : 0 : req.src_ipaddr[0] = rte_cpu_to_le_32(filter->src_ipaddr[0]);
6025 [ # # ]: 0 : if (enables &
6026 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_IPADDR_MASK)
6027 : 0 : req.src_ipaddr_mask[0] =
6028 : 0 : rte_cpu_to_le_32(filter->src_ipaddr_mask[0]);
6029 [ # # ]: 0 : if (enables &
6030 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_IPADDR)
6031 : 0 : req.dst_ipaddr[0] = rte_cpu_to_le_32(filter->dst_ipaddr[0]);
6032 [ # # ]: 0 : if (enables &
6033 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_IPADDR_MASK)
6034 : 0 : req.dst_ipaddr_mask[0] =
6035 [ # # ]: 0 : rte_cpu_to_be_32(filter->dst_ipaddr_mask[0]);
6036 [ # # ]: 0 : if (enables &
6037 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_PORT)
6038 : 0 : req.src_port = rte_cpu_to_le_16(filter->src_port);
6039 [ # # ]: 0 : if (enables &
6040 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_PORT_MASK)
6041 : 0 : req.src_port_mask = rte_cpu_to_le_16(filter->src_port_mask);
6042 [ # # ]: 0 : if (enables &
6043 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_PORT)
6044 : 0 : req.dst_port = rte_cpu_to_le_16(filter->dst_port);
6045 [ # # ]: 0 : if (enables &
6046 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_PORT_MASK)
6047 : 0 : req.dst_port_mask = rte_cpu_to_le_16(filter->dst_port_mask);
6048 : :
6049 : 0 : req.enables = rte_cpu_to_le_32(enables);
6050 : :
6051 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6052 : :
6053 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6054 : :
6055 : 0 : filter->fw_ntuple_filter_id = rte_le_to_cpu_64(resp->ntuple_filter_id);
6056 : 0 : filter->flow_id = rte_le_to_cpu_32(resp->flow_id);
6057 : : HWRM_UNLOCK();
6058 : :
6059 : 0 : return rc;
6060 : : }
6061 : :
6062 : 0 : int bnxt_hwrm_clear_ntuple_filter(struct bnxt *bp,
6063 : : struct bnxt_filter_info *filter)
6064 : : {
6065 : : int rc = 0;
6066 : 0 : struct hwrm_cfa_ntuple_filter_free_input req = {.req_type = 0 };
6067 : 0 : struct hwrm_cfa_ntuple_filter_free_output *resp =
6068 : : bp->hwrm_cmd_resp_addr;
6069 : :
6070 [ # # ]: 0 : if (filter->fw_ntuple_filter_id == UINT64_MAX)
6071 : : return 0;
6072 : :
6073 [ # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_NTUPLE_FILTER_FREE, BNXT_USE_CHIMP_MB);
6074 : :
6075 : 0 : req.ntuple_filter_id = rte_cpu_to_le_64(filter->fw_ntuple_filter_id);
6076 : :
6077 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6078 : :
6079 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6080 : : HWRM_UNLOCK();
6081 : :
6082 : 0 : filter->fw_ntuple_filter_id = UINT64_MAX;
6083 : :
6084 : 0 : return 0;
6085 : : }
6086 : :
6087 : : int
6088 : 0 : bnxt_vnic_rss_configure_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic)
6089 : : {
6090 : 0 : struct hwrm_vnic_rss_cfg_output *resp = bp->hwrm_cmd_resp_addr;
6091 : 0 : uint8_t *rxq_state = bp->eth_dev->data->rx_queue_state;
6092 : 0 : struct hwrm_vnic_rss_cfg_input req = {.req_type = 0 };
6093 : 0 : struct bnxt_rx_queue **rxqs = bp->rx_queues;
6094 : 0 : uint16_t *ring_tbl = vnic->rss_table;
6095 : 0 : int nr_ctxs = vnic->num_lb_ctxts;
6096 : 0 : int max_rings = bp->rx_nr_rings;
6097 : : int i, j, k, cnt;
6098 : : int rc = 0;
6099 : :
6100 [ # # ]: 0 : for (i = 0, k = 0; i < nr_ctxs; i++) {
6101 : : struct bnxt_rx_ring_info *rxr;
6102 : : struct bnxt_cp_ring_info *cpr;
6103 : :
6104 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_RSS_CFG, BNXT_USE_CHIMP_MB);
6105 : :
6106 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
6107 : 0 : req.hash_type = rte_cpu_to_le_32(bnxt_sanitize_rss_type(bp, vnic->hash_type));
6108 : 0 : req.hash_mode_flags = vnic->hash_mode;
6109 : 0 : req.ring_select_mode = vnic->ring_select_mode;
6110 : :
6111 : 0 : req.ring_grp_tbl_addr =
6112 : 0 : rte_cpu_to_le_64(vnic->rss_table_dma_addr +
6113 : : i * BNXT_RSS_ENTRIES_PER_CTX_P5 *
6114 : : 2 * sizeof(*ring_tbl));
6115 : 0 : req.hash_key_tbl_addr =
6116 : 0 : rte_cpu_to_le_64(vnic->rss_hash_key_dma_addr);
6117 : :
6118 : 0 : req.ring_table_pair_index = i;
6119 : 0 : req.rss_ctx_idx = rte_cpu_to_le_16(vnic->fw_grp_ids[i]);
6120 : :
6121 [ # # ]: 0 : for (j = 0; j < 64; j++) {
6122 : : uint16_t ring_id;
6123 : :
6124 : : /* Find next active ring. */
6125 [ # # ]: 0 : for (cnt = 0; cnt < max_rings; cnt++) {
6126 [ # # ]: 0 : if (rxq_state[k] != RTE_ETH_QUEUE_STATE_STOPPED)
6127 : : break;
6128 [ # # ]: 0 : if (++k == max_rings)
6129 : : k = 0;
6130 : : }
6131 : :
6132 : : /* Return if no rings are active. */
6133 [ # # ]: 0 : if (cnt == max_rings) {
6134 : : HWRM_UNLOCK();
6135 : 0 : return 0;
6136 : : }
6137 : :
6138 : : /* Add rx/cp ring pair to RSS table. */
6139 : 0 : rxr = rxqs[k]->rx_ring;
6140 : 0 : cpr = rxqs[k]->cp_ring;
6141 : :
6142 : 0 : ring_id = rxr->rx_ring_struct->fw_ring_id;
6143 : 0 : *ring_tbl++ = rte_cpu_to_le_16(ring_id);
6144 : 0 : ring_id = cpr->cp_ring_struct->fw_ring_id;
6145 : 0 : *ring_tbl++ = rte_cpu_to_le_16(ring_id);
6146 : :
6147 [ # # ]: 0 : if (++k == max_rings)
6148 : : k = 0;
6149 : : }
6150 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req),
6151 : : BNXT_USE_CHIMP_MB);
6152 : :
6153 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6154 : : HWRM_UNLOCK();
6155 : : }
6156 : :
6157 : : return rc;
6158 : : }
6159 : :
6160 : 0 : int bnxt_vnic_rss_configure(struct bnxt *bp, struct bnxt_vnic_info *vnic)
6161 : : {
6162 : : unsigned int rss_idx, fw_idx, i;
6163 : :
6164 [ # # ]: 0 : if (vnic->fw_vnic_id == INVALID_HW_RING_ID)
6165 : : return 0;
6166 : :
6167 [ # # # # ]: 0 : if (!(vnic->rss_table && vnic->hash_type))
6168 : : return 0;
6169 : :
6170 [ # # ]: 0 : if (BNXT_CHIP_P5_P7(bp))
6171 : 0 : return bnxt_vnic_rss_configure_p5(bp, vnic);
6172 : :
6173 : : /*
6174 : : * Fill the RSS hash & redirection table with
6175 : : * ring group ids for all VNICs
6176 : : */
6177 [ # # ]: 0 : for (rss_idx = 0, fw_idx = 0; rss_idx < HW_HASH_INDEX_SIZE;
6178 : 0 : rss_idx++, fw_idx++) {
6179 [ # # ]: 0 : for (i = 0; i < bp->rx_cp_nr_rings; i++) {
6180 : 0 : fw_idx %= bp->rx_cp_nr_rings;
6181 [ # # ]: 0 : if (vnic->fw_grp_ids[fw_idx] != INVALID_HW_RING_ID)
6182 : : break;
6183 : 0 : fw_idx++;
6184 : : }
6185 : :
6186 [ # # ]: 0 : if (i == bp->rx_cp_nr_rings)
6187 : : return 0;
6188 : :
6189 : 0 : vnic->rss_table[rss_idx] = vnic->fw_grp_ids[fw_idx];
6190 : : }
6191 : :
6192 : 0 : return bnxt_hwrm_vnic_rss_cfg(bp, vnic);
6193 : : }
6194 : :
6195 : : static void bnxt_hwrm_set_coal_params(struct bnxt_coal *hw_coal,
6196 : : struct hwrm_ring_cmpl_ring_cfg_aggint_params_input *req)
6197 : : {
6198 : : uint16_t flags;
6199 : :
6200 : 0 : req->num_cmpl_aggr_int = rte_cpu_to_le_16(hw_coal->num_cmpl_aggr_int);
6201 : :
6202 : : /* This is a 6-bit value and must not be 0, or we'll get non stop IRQ */
6203 : 0 : req->num_cmpl_dma_aggr = rte_cpu_to_le_16(hw_coal->num_cmpl_dma_aggr);
6204 : :
6205 : : /* This is a 6-bit value and must not be 0, or we'll get non stop IRQ */
6206 : 0 : req->num_cmpl_dma_aggr_during_int =
6207 : 0 : rte_cpu_to_le_16(hw_coal->num_cmpl_dma_aggr_during_int);
6208 : :
6209 : 0 : req->int_lat_tmr_max = rte_cpu_to_le_16(hw_coal->int_lat_tmr_max);
6210 : :
6211 : : /* min timer set to 1/2 of interrupt timer */
6212 : 0 : req->int_lat_tmr_min = rte_cpu_to_le_16(hw_coal->int_lat_tmr_min);
6213 : :
6214 : : /* buf timer set to 1/4 of interrupt timer */
6215 : 0 : req->cmpl_aggr_dma_tmr = rte_cpu_to_le_16(hw_coal->cmpl_aggr_dma_tmr);
6216 : :
6217 : 0 : req->cmpl_aggr_dma_tmr_during_int =
6218 : 0 : rte_cpu_to_le_16(hw_coal->cmpl_aggr_dma_tmr_during_int);
6219 : :
6220 : : flags = HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_TIMER_RESET |
6221 : : HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_RING_IDLE;
6222 : 0 : req->flags = rte_cpu_to_le_16(flags);
6223 : 0 : }
6224 : :
6225 : 0 : static int bnxt_hwrm_set_coal_params_p5(struct bnxt *bp,
6226 : : struct hwrm_ring_cmpl_ring_cfg_aggint_params_input *agg_req)
6227 : : {
6228 : 0 : struct hwrm_ring_aggint_qcaps_input req = {0};
6229 : 0 : struct hwrm_ring_aggint_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
6230 : : uint32_t enables;
6231 : : uint16_t flags;
6232 : : int rc;
6233 : :
6234 [ # # ]: 0 : HWRM_PREP(&req, HWRM_RING_AGGINT_QCAPS, BNXT_USE_CHIMP_MB);
6235 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6236 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6237 : :
6238 : 0 : agg_req->num_cmpl_dma_aggr = resp->num_cmpl_dma_aggr_max;
6239 : 0 : agg_req->cmpl_aggr_dma_tmr = resp->cmpl_aggr_dma_tmr_min;
6240 : :
6241 : : flags = HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_TIMER_RESET |
6242 : : HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_RING_IDLE;
6243 : 0 : agg_req->flags = rte_cpu_to_le_16(flags);
6244 : : enables =
6245 : : HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_ENABLES_CMPL_AGGR_DMA_TMR |
6246 : : HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_ENABLES_NUM_CMPL_DMA_AGGR;
6247 : 0 : agg_req->enables = rte_cpu_to_le_32(enables);
6248 : :
6249 : : HWRM_UNLOCK();
6250 : 0 : return rc;
6251 : : }
6252 : :
6253 : 0 : int bnxt_hwrm_set_ring_coal(struct bnxt *bp,
6254 : : struct bnxt_coal *coal, uint16_t ring_id)
6255 : : {
6256 : 0 : struct hwrm_ring_cmpl_ring_cfg_aggint_params_input req = {0};
6257 : 0 : struct hwrm_ring_cmpl_ring_cfg_aggint_params_output *resp =
6258 : : bp->hwrm_cmd_resp_addr;
6259 : : int rc;
6260 : :
6261 : : /* Set ring coalesce parameters only for 100G NICs */
6262 [ # # ]: 0 : if (BNXT_CHIP_P5_P7(bp)) {
6263 [ # # ]: 0 : if (bnxt_hwrm_set_coal_params_p5(bp, &req))
6264 : : return -1;
6265 [ # # ]: 0 : } else if (bnxt_stratus_device(bp)) {
6266 : : bnxt_hwrm_set_coal_params(coal, &req);
6267 : : } else {
6268 : : return 0;
6269 : : }
6270 : :
6271 [ # # ]: 0 : HWRM_PREP(&req,
6272 : : HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS,
6273 : : BNXT_USE_CHIMP_MB);
6274 : 0 : req.ring_id = rte_cpu_to_le_16(ring_id);
6275 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6276 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6277 : : HWRM_UNLOCK();
6278 : 0 : return 0;
6279 : : }
6280 : :
6281 : : static void bnxt_init_ctx_initializer(struct bnxt_ctx_mem *ctxm,
6282 : : uint8_t init_val,
6283 : : uint8_t init_offset,
6284 : : bool init_mask_set)
6285 : : {
6286 : 0 : ctxm->init_value = init_val;
6287 : 0 : ctxm->init_offset = BNXT_CTX_INIT_INVALID_OFFSET;
6288 : 0 : if (init_mask_set)
6289 : 0 : ctxm->init_offset = init_offset * 4;
6290 : : else
6291 : 0 : ctxm->init_value = 0;
6292 : : }
6293 : :
6294 : 0 : static int bnxt_alloc_all_ctx_pg_info(struct bnxt *bp)
6295 : : {
6296 : 0 : struct bnxt_ctx_mem_info *ctx = bp->ctx;
6297 : : char name[RTE_MEMZONE_NAMESIZE];
6298 : : uint16_t type;
6299 : :
6300 [ # # ]: 0 : for (type = 0; type < ctx->types; type++) {
6301 : 0 : struct bnxt_ctx_mem *ctxm = &ctx->ctx_arr[type];
6302 : : int n = 1;
6303 : :
6304 [ # # # # ]: 0 : if (!ctxm->max_entries || ctxm->pg_info)
6305 : 0 : continue;
6306 : :
6307 [ # # ]: 0 : if (ctxm->instance_bmap)
6308 : 0 : n = hweight32(ctxm->instance_bmap);
6309 : :
6310 : 0 : sprintf(name, "bnxt_ctx_pgmem_%d_%d",
6311 : 0 : bp->eth_dev->data->port_id, type);
6312 : 0 : ctxm->pg_info = rte_malloc(name, sizeof(*ctxm->pg_info) * n,
6313 : : RTE_CACHE_LINE_SIZE);
6314 [ # # ]: 0 : if (!ctxm->pg_info)
6315 : : return -ENOMEM;
6316 : : }
6317 : : return 0;
6318 : : }
6319 : :
6320 : : static void bnxt_init_ctx_v2_driver_managed(struct bnxt *bp __rte_unused,
6321 : : struct bnxt_ctx_mem *ctxm)
6322 : : {
6323 [ # # ]: 0 : switch (ctxm->type) {
6324 : 0 : case HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_SQ_DB_SHADOW:
6325 : : case HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_RQ_DB_SHADOW:
6326 : : case HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_SRQ_DB_SHADOW:
6327 : : case HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_CQ_DB_SHADOW:
6328 : : /* FALLTHROUGH */
6329 : 0 : ctxm->entry_size = 0;
6330 : 0 : ctxm->min_entries = 1;
6331 : 0 : ctxm->max_entries = 1;
6332 : 0 : break;
6333 : : }
6334 : : }
6335 : :
6336 : 0 : int bnxt_hwrm_func_backing_store_qcaps_v2(struct bnxt *bp)
6337 : : {
6338 : 0 : struct hwrm_func_backing_store_qcaps_v2_input req = {0};
6339 : 0 : struct hwrm_func_backing_store_qcaps_v2_output *resp =
6340 : : bp->hwrm_cmd_resp_addr;
6341 : 0 : struct bnxt_ctx_mem_info *ctx = bp->ctx;
6342 : : uint16_t last_valid_type = BNXT_CTX_INV;
6343 : : uint16_t last_valid_idx = 0;
6344 : : uint16_t types, type;
6345 : : int rc;
6346 : :
6347 [ # # # # ]: 0 : for (types = 0, type = 0; types < bp->ctx->types && type != BNXT_CTX_INV; types++) {
6348 : 0 : struct bnxt_ctx_mem *ctxm = &bp->ctx->ctx_arr[types];
6349 : : uint8_t init_val, init_off, i;
6350 : : uint32_t *p;
6351 : : uint32_t flags;
6352 : :
6353 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_BACKING_STORE_QCAPS_V2, BNXT_USE_CHIMP_MB);
6354 : 0 : req.type = rte_cpu_to_le_16(type);
6355 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6356 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6357 : :
6358 : 0 : flags = rte_le_to_cpu_32(resp->flags);
6359 : 0 : type = rte_le_to_cpu_16(resp->next_valid_type);
6360 [ # # ]: 0 : if (!(flags & HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_FLAGS_TYPE_VALID))
6361 : 0 : goto next;
6362 : :
6363 : 0 : ctxm->type = rte_le_to_cpu_16(resp->type);
6364 : :
6365 : 0 : ctxm->flags = flags;
6366 [ # # ]: 0 : if (flags &
6367 : : HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_FLAGS_DRIVER_MANAGED_MEMORY) {
6368 : : bnxt_init_ctx_v2_driver_managed(bp, ctxm);
6369 : 0 : goto next;
6370 : : }
6371 : 0 : ctxm->entry_size = rte_le_to_cpu_16(resp->entry_size);
6372 : :
6373 [ # # ]: 0 : if (ctxm->entry_size == 0)
6374 : 0 : goto next;
6375 : :
6376 : 0 : ctxm->instance_bmap = rte_le_to_cpu_32(resp->instance_bit_map);
6377 : 0 : ctxm->entry_multiple = resp->entry_multiple;
6378 : 0 : ctxm->max_entries = rte_le_to_cpu_32(resp->max_num_entries);
6379 : 0 : ctxm->min_entries = rte_le_to_cpu_32(resp->min_num_entries);
6380 : 0 : init_val = resp->ctx_init_value;
6381 : 0 : init_off = resp->ctx_init_offset;
6382 : 0 : bnxt_init_ctx_initializer(ctxm, init_val, init_off,
6383 [ # # ]: 0 : BNXT_CTX_INIT_VALID(flags));
6384 : 0 : ctxm->split_entry_cnt = RTE_MIN(resp->subtype_valid_cnt,
6385 : : BNXT_MAX_SPLIT_ENTRY);
6386 [ # # ]: 0 : for (i = 0, p = &resp->split_entry_0; i < ctxm->split_entry_cnt;
6387 : 0 : i++, p++)
6388 : 0 : ctxm->split[i] = rte_le_to_cpu_32(*p);
6389 : :
6390 : 0 : PMD_DRV_LOG(DEBUG,
6391 : : "type:%s size:%d multiple:%d max:%d min:%d split:%d init_val:%d init_off:%d init:%d bmap:0x%x\n",
6392 : : bnxt_backing_store_types[ctxm->type], ctxm->entry_size,
6393 : : ctxm->entry_multiple, ctxm->max_entries, ctxm->min_entries,
6394 : : ctxm->split_entry_cnt, init_val, init_off,
6395 : : BNXT_CTX_INIT_VALID(flags), ctxm->instance_bmap);
6396 : 0 : last_valid_type = ctxm->type;
6397 : : last_valid_idx = types;
6398 : 0 : next:
6399 : : HWRM_UNLOCK();
6400 : : }
6401 : 0 : ctx->ctx_arr[last_valid_idx].last = true;
6402 : 0 : PMD_DRV_LOG(DEBUG, "Last valid type 0x%x\n", last_valid_type);
6403 : :
6404 : 0 : rc = bnxt_alloc_all_ctx_pg_info(bp);
6405 [ # # ]: 0 : if (rc == 0)
6406 : 0 : rc = bnxt_alloc_ctx_pg_tbls(bp);
6407 : : return rc;
6408 : : }
6409 : :
6410 : 0 : int bnxt_hwrm_func_backing_store_types_count(struct bnxt *bp)
6411 : : {
6412 : 0 : struct hwrm_func_backing_store_qcaps_v2_input req = {0};
6413 : 0 : struct hwrm_func_backing_store_qcaps_v2_output *resp =
6414 : : bp->hwrm_cmd_resp_addr;
6415 : : uint16_t type = 0;
6416 : : int types = 0;
6417 : : int rc;
6418 : :
6419 : : /* Calculate number of valid context types */
6420 : : do {
6421 : : uint32_t flags;
6422 : :
6423 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_BACKING_STORE_QCAPS_V2, BNXT_USE_CHIMP_MB);
6424 : 0 : req.type = rte_cpu_to_le_16(type);
6425 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6426 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6427 : :
6428 : 0 : flags = rte_le_to_cpu_32(resp->flags);
6429 : 0 : type = rte_le_to_cpu_16(resp->next_valid_type);
6430 : : HWRM_UNLOCK();
6431 : :
6432 [ # # ]: 0 : if (flags & HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_FLAGS_TYPE_VALID) {
6433 : 0 : PMD_DRV_LOG(DEBUG, "Valid types 0x%x - %s\n",
6434 : : req.type, bnxt_backing_store_types[req.type]);
6435 : 0 : types++;
6436 : : }
6437 [ # # ]: 0 : } while (type != HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_INVALID);
6438 : 0 : PMD_DRV_LOG(DEBUG, "Number of valid types %d\n", types);
6439 : :
6440 : 0 : return types;
6441 : : }
6442 : :
6443 : 0 : int bnxt_hwrm_func_backing_store_ctx_alloc(struct bnxt *bp, uint16_t types)
6444 : : {
6445 : : int alloc_len = sizeof(struct bnxt_ctx_mem_info);
6446 : :
6447 [ # # ]: 0 : if (!BNXT_CHIP_P5_P7(bp) ||
6448 [ # # # # ]: 0 : bp->hwrm_spec_code < HWRM_VERSION_1_9_2 ||
6449 : 0 : BNXT_VF(bp) ||
6450 [ # # ]: 0 : bp->ctx)
6451 : : return 0;
6452 : :
6453 : 0 : bp->ctx = rte_zmalloc("bnxt_ctx_mem", alloc_len,
6454 : : RTE_CACHE_LINE_SIZE);
6455 [ # # ]: 0 : if (bp->ctx == NULL)
6456 : : return -ENOMEM;
6457 : :
6458 : 0 : alloc_len = sizeof(struct bnxt_ctx_mem) * types;
6459 : 0 : bp->ctx->ctx_arr = rte_zmalloc("bnxt_ctx_mem_arr",
6460 : : alloc_len,
6461 : : RTE_CACHE_LINE_SIZE);
6462 [ # # ]: 0 : if (bp->ctx->ctx_arr == NULL)
6463 : : return -ENOMEM;
6464 : :
6465 : 0 : bp->ctx->types = types;
6466 : 0 : return 0;
6467 : : }
6468 : :
6469 : 0 : int bnxt_hwrm_func_backing_store_qcaps(struct bnxt *bp)
6470 : : {
6471 : 0 : struct hwrm_func_backing_store_qcaps_input req = {0};
6472 : 0 : struct hwrm_func_backing_store_qcaps_output *resp =
6473 : : bp->hwrm_cmd_resp_addr;
6474 : : struct bnxt_ctx_pg_info *ctx_pg;
6475 : : struct bnxt_ctx_mem_info *ctx;
6476 : : int rc, i, tqm_rings;
6477 : :
6478 [ # # ]: 0 : if (!BNXT_CHIP_P5_P7(bp) ||
6479 [ # # # # ]: 0 : bp->hwrm_spec_code < HWRM_VERSION_1_9_2 ||
6480 : 0 : BNXT_VF(bp) ||
6481 [ # # ]: 0 : bp->ctx->flags & BNXT_CTX_FLAG_INITED)
6482 : : return 0;
6483 : :
6484 : : ctx = bp->ctx;
6485 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_BACKING_STORE_QCAPS, BNXT_USE_CHIMP_MB);
6486 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6487 [ # # # # ]: 0 : HWRM_CHECK_RESULT_SILENT();
6488 : :
6489 : 0 : ctx->qp_max_entries = rte_le_to_cpu_32(resp->qp_max_entries);
6490 : 0 : ctx->qp_min_qp1_entries =
6491 : 0 : rte_le_to_cpu_16(resp->qp_min_qp1_entries);
6492 : 0 : ctx->qp_max_l2_entries =
6493 : 0 : rte_le_to_cpu_16(resp->qp_max_l2_entries);
6494 : 0 : ctx->qp_entry_size = rte_le_to_cpu_16(resp->qp_entry_size);
6495 : 0 : ctx->srq_max_l2_entries =
6496 : 0 : rte_le_to_cpu_16(resp->srq_max_l2_entries);
6497 : 0 : ctx->srq_max_entries = rte_le_to_cpu_32(resp->srq_max_entries);
6498 : 0 : ctx->srq_entry_size = rte_le_to_cpu_16(resp->srq_entry_size);
6499 [ # # ]: 0 : if (BNXT_CHIP_P7(bp))
6500 : 0 : ctx->cq_max_l2_entries =
6501 : 0 : RTE_MIN(BNXT_P7_CQ_MAX_L2_ENT,
6502 : : rte_le_to_cpu_16(resp->cq_max_l2_entries));
6503 : : else
6504 : 0 : ctx->cq_max_l2_entries =
6505 : 0 : rte_le_to_cpu_16(resp->cq_max_l2_entries);
6506 : 0 : ctx->cq_max_entries = rte_le_to_cpu_32(resp->cq_max_entries);
6507 : 0 : ctx->cq_entry_size = rte_le_to_cpu_16(resp->cq_entry_size);
6508 : 0 : ctx->vnic_max_vnic_entries =
6509 : 0 : rte_le_to_cpu_16(resp->vnic_max_vnic_entries);
6510 : 0 : ctx->vnic_max_ring_table_entries =
6511 : 0 : rte_le_to_cpu_16(resp->vnic_max_ring_table_entries);
6512 : 0 : ctx->vnic_entry_size = rte_le_to_cpu_16(resp->vnic_entry_size);
6513 : 0 : ctx->stat_max_entries =
6514 : 0 : rte_le_to_cpu_32(resp->stat_max_entries);
6515 : 0 : ctx->stat_entry_size = rte_le_to_cpu_16(resp->stat_entry_size);
6516 : 0 : ctx->tqm_entry_size = rte_le_to_cpu_16(resp->tqm_entry_size);
6517 : 0 : ctx->tqm_min_entries_per_ring =
6518 : 0 : rte_le_to_cpu_32(resp->tqm_min_entries_per_ring);
6519 : 0 : ctx->tqm_max_entries_per_ring =
6520 : 0 : rte_le_to_cpu_32(resp->tqm_max_entries_per_ring);
6521 : 0 : ctx->tqm_entries_multiple = resp->tqm_entries_multiple;
6522 [ # # ]: 0 : if (!ctx->tqm_entries_multiple)
6523 : 0 : ctx->tqm_entries_multiple = 1;
6524 : 0 : ctx->mrav_max_entries =
6525 : 0 : rte_le_to_cpu_32(resp->mrav_max_entries);
6526 : 0 : ctx->mrav_entry_size = rte_le_to_cpu_16(resp->mrav_entry_size);
6527 : 0 : ctx->tim_entry_size = rte_le_to_cpu_16(resp->tim_entry_size);
6528 : 0 : ctx->tim_max_entries = rte_le_to_cpu_32(resp->tim_max_entries);
6529 : 0 : ctx->tqm_fp_rings_count = resp->tqm_fp_rings_count;
6530 : :
6531 [ # # ]: 0 : ctx->tqm_fp_rings_count = ctx->tqm_fp_rings_count ?
6532 : 0 : RTE_MIN(ctx->tqm_fp_rings_count,
6533 : : BNXT_MAX_TQM_FP_LEGACY_RINGS) :
6534 : : bp->max_q;
6535 : :
6536 : : /* Check if the ext ring count needs to be counted.
6537 : : * Ext ring count is available only with new FW so we should not
6538 : : * look at the field on older FW.
6539 : : */
6540 [ # # ]: 0 : if (ctx->tqm_fp_rings_count == BNXT_MAX_TQM_FP_LEGACY_RINGS &&
6541 [ # # ]: 0 : bp->hwrm_max_ext_req_len >= BNXT_BACKING_STORE_CFG_LEN) {
6542 : 0 : ctx->tqm_fp_rings_count += resp->tqm_fp_rings_count_ext;
6543 : 0 : ctx->tqm_fp_rings_count = RTE_MIN(BNXT_MAX_TQM_FP_RINGS,
6544 : : ctx->tqm_fp_rings_count);
6545 : : }
6546 : :
6547 : 0 : tqm_rings = ctx->tqm_fp_rings_count + 1;
6548 : :
6549 : 0 : ctx_pg = rte_malloc("bnxt_ctx_pg_mem",
6550 : : sizeof(*ctx_pg) * tqm_rings,
6551 : : RTE_CACHE_LINE_SIZE);
6552 [ # # ]: 0 : if (!ctx_pg) {
6553 : : rc = -ENOMEM;
6554 : 0 : goto ctx_err;
6555 : : }
6556 [ # # ]: 0 : for (i = 0; i < tqm_rings; i++, ctx_pg++)
6557 : 0 : ctx->tqm_mem[i] = ctx_pg;
6558 : :
6559 : 0 : ctx_err:
6560 : : HWRM_UNLOCK();
6561 : 0 : return rc;
6562 : : }
6563 : :
6564 : 0 : int bnxt_hwrm_func_backing_store_cfg_v2(struct bnxt *bp,
6565 : : struct bnxt_ctx_mem *ctxm)
6566 : : {
6567 : 0 : struct hwrm_func_backing_store_cfg_v2_input req = {0};
6568 : 0 : struct hwrm_func_backing_store_cfg_v2_output *resp =
6569 : : bp->hwrm_cmd_resp_addr;
6570 : : struct bnxt_ctx_pg_info *ctx_pg;
6571 : : int i, j, k;
6572 : : uint32_t *p;
6573 : : int rc = 0;
6574 : : int w = 1;
6575 : : int b = 1;
6576 : :
6577 [ # # ]: 0 : if (!BNXT_PF(bp)) {
6578 : 0 : PMD_DRV_LOG(INFO,
6579 : : "Backing store config V2 can be issued on PF only\n");
6580 : 0 : return 0;
6581 : : }
6582 : :
6583 [ # # # # ]: 0 : if (!(ctxm->flags & BNXT_CTX_MEM_TYPE_VALID) || !ctxm->pg_info)
6584 : : return 0;
6585 : :
6586 : 0 : if (ctxm->instance_bmap)
6587 : : b = ctxm->instance_bmap;
6588 : :
6589 : 0 : w = hweight32(b);
6590 : :
6591 [ # # ]: 0 : for (i = 0, j = 0; i < w && rc == 0; i++) {
6592 [ # # ]: 0 : if (!(b & (1 << i)))
6593 : 0 : continue;
6594 : :
6595 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_BACKING_STORE_CFG_V2, BNXT_USE_CHIMP_MB);
6596 : 0 : req.type = rte_cpu_to_le_16(ctxm->type);
6597 : 0 : req.entry_size = rte_cpu_to_le_16(ctxm->entry_size);
6598 : 0 : req.subtype_valid_cnt = ctxm->split_entry_cnt;
6599 [ # # ]: 0 : for (k = 0, p = &req.split_entry_0; k < ctxm->split_entry_cnt; k++)
6600 : 0 : p[k] = rte_cpu_to_le_32(ctxm->split[k]);
6601 : :
6602 : 0 : req.instance = rte_cpu_to_le_16(i);
6603 : 0 : ctx_pg = &ctxm->pg_info[j++];
6604 [ # # ]: 0 : if (!ctx_pg->entries)
6605 : 0 : goto unlock;
6606 : :
6607 [ # # ]: 0 : req.num_entries = rte_cpu_to_le_32(ctx_pg->entries);
6608 : : bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
6609 : : &req.page_size_pbl_level,
6610 : : &req.page_dir);
6611 : 0 : PMD_DRV_LOG(DEBUG,
6612 : : "Backing store config V2 type:%s last %d, instance %d, hw %d\n",
6613 : : bnxt_backing_store_types[req.type], ctxm->last, j, w);
6614 [ # # # # ]: 0 : if (ctxm->last && i == (w - 1))
6615 : 0 : req.flags =
6616 : : rte_cpu_to_le_32(BACKING_STORE_CFG_V2_IN_FLG_CFG_ALL_DONE);
6617 : :
6618 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6619 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6620 : 0 : unlock:
6621 : : HWRM_UNLOCK();
6622 : : }
6623 : : return rc;
6624 : : }
6625 : :
6626 : 0 : int bnxt_hwrm_func_backing_store_cfg(struct bnxt *bp, uint32_t enables)
6627 : : {
6628 : 0 : struct hwrm_func_backing_store_cfg_input req = {0};
6629 : 0 : struct hwrm_func_backing_store_cfg_output *resp =
6630 : : bp->hwrm_cmd_resp_addr;
6631 : 0 : struct bnxt_ctx_mem_info *ctx = bp->ctx;
6632 : : struct bnxt_ctx_pg_info *ctx_pg;
6633 : : uint32_t *num_entries;
6634 : : uint64_t *pg_dir;
6635 : : uint8_t *pg_attr;
6636 : : uint32_t ena;
6637 : : int i, rc;
6638 : :
6639 [ # # ]: 0 : if (!ctx)
6640 : : return 0;
6641 : :
6642 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_BACKING_STORE_CFG, BNXT_USE_CHIMP_MB);
6643 : 0 : req.enables = rte_cpu_to_le_32(enables);
6644 : :
6645 [ # # ]: 0 : if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_QP) {
6646 : : ctx_pg = &ctx->qp_mem;
6647 : 0 : req.qp_num_entries = rte_cpu_to_le_32(ctx_pg->entries);
6648 : 0 : req.qp_num_qp1_entries =
6649 : 0 : rte_cpu_to_le_16(ctx->qp_min_qp1_entries);
6650 : 0 : req.qp_num_l2_entries =
6651 : 0 : rte_cpu_to_le_16(ctx->qp_max_l2_entries);
6652 [ # # ]: 0 : req.qp_entry_size = rte_cpu_to_le_16(ctx->qp_entry_size);
6653 : : bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
6654 : : &req.qpc_pg_size_qpc_lvl,
6655 : : &req.qpc_page_dir);
6656 : : }
6657 : :
6658 [ # # ]: 0 : if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_SRQ) {
6659 : : ctx_pg = &ctx->srq_mem;
6660 : 0 : req.srq_num_entries = rte_cpu_to_le_32(ctx_pg->entries);
6661 : 0 : req.srq_num_l2_entries =
6662 : 0 : rte_cpu_to_le_16(ctx->srq_max_l2_entries);
6663 [ # # ]: 0 : req.srq_entry_size = rte_cpu_to_le_16(ctx->srq_entry_size);
6664 : : bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
6665 : : &req.srq_pg_size_srq_lvl,
6666 : : &req.srq_page_dir);
6667 : : }
6668 : :
6669 [ # # ]: 0 : if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_CQ) {
6670 : : ctx_pg = &ctx->cq_mem;
6671 : 0 : req.cq_num_entries = rte_cpu_to_le_32(ctx_pg->entries);
6672 : 0 : req.cq_num_l2_entries =
6673 : 0 : rte_cpu_to_le_16(ctx->cq_max_l2_entries);
6674 [ # # ]: 0 : req.cq_entry_size = rte_cpu_to_le_16(ctx->cq_entry_size);
6675 : : bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
6676 : : &req.cq_pg_size_cq_lvl,
6677 : : &req.cq_page_dir);
6678 : : }
6679 : :
6680 [ # # ]: 0 : if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_VNIC) {
6681 : : ctx_pg = &ctx->vnic_mem;
6682 : 0 : req.vnic_num_vnic_entries =
6683 : 0 : rte_cpu_to_le_16(ctx->vnic_max_vnic_entries);
6684 : 0 : req.vnic_num_ring_table_entries =
6685 : 0 : rte_cpu_to_le_16(ctx->vnic_max_ring_table_entries);
6686 [ # # ]: 0 : req.vnic_entry_size = rte_cpu_to_le_16(ctx->vnic_entry_size);
6687 : : bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
6688 : : &req.vnic_pg_size_vnic_lvl,
6689 : : &req.vnic_page_dir);
6690 : : }
6691 : :
6692 [ # # ]: 0 : if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_STAT) {
6693 : : ctx_pg = &ctx->stat_mem;
6694 : 0 : req.stat_num_entries = rte_cpu_to_le_16(ctx->stat_max_entries);
6695 [ # # ]: 0 : req.stat_entry_size = rte_cpu_to_le_16(ctx->stat_entry_size);
6696 : : bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
6697 : : &req.stat_pg_size_stat_lvl,
6698 : : &req.stat_page_dir);
6699 : : }
6700 : :
6701 : 0 : req.tqm_entry_size = rte_cpu_to_le_16(ctx->tqm_entry_size);
6702 : : num_entries = &req.tqm_sp_num_entries;
6703 : : pg_attr = &req.tqm_sp_pg_size_tqm_sp_lvl;
6704 : : pg_dir = &req.tqm_sp_page_dir;
6705 : : ena = HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_SP;
6706 [ # # ]: 0 : for (i = 0; i < 9; i++, num_entries++, pg_attr++, pg_dir++, ena <<= 1) {
6707 [ # # ]: 0 : if (!(enables & ena))
6708 : 0 : continue;
6709 : :
6710 : 0 : req.tqm_entry_size = rte_cpu_to_le_16(ctx->tqm_entry_size);
6711 : :
6712 : 0 : ctx_pg = ctx->tqm_mem[i];
6713 [ # # ]: 0 : *num_entries = rte_cpu_to_le_16(ctx_pg->entries);
6714 : : bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, pg_attr, pg_dir);
6715 : : }
6716 : :
6717 [ # # ]: 0 : if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING8) {
6718 : : /* DPDK does not need to configure MRAV and TIM type.
6719 : : * So we are skipping over MRAV and TIM. Skip to configure
6720 : : * HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING8.
6721 : : */
6722 : 0 : ctx_pg = ctx->tqm_mem[BNXT_MAX_TQM_LEGACY_RINGS];
6723 [ # # ]: 0 : req.tqm_ring8_num_entries = rte_cpu_to_le_16(ctx_pg->entries);
6724 : : bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
6725 : : &req.tqm_ring8_pg_size_tqm_ring_lvl,
6726 : : &req.tqm_ring8_page_dir);
6727 : : }
6728 : :
6729 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6730 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6731 : : HWRM_UNLOCK();
6732 : :
6733 : 0 : return rc;
6734 : : }
6735 : :
6736 : 0 : int bnxt_hwrm_ext_port_qstats(struct bnxt *bp)
6737 : : {
6738 : 0 : struct hwrm_port_qstats_ext_input req = {0};
6739 : 0 : struct hwrm_port_qstats_ext_output *resp = bp->hwrm_cmd_resp_addr;
6740 : 0 : struct bnxt_pf_info *pf = bp->pf;
6741 : : int rc;
6742 : :
6743 [ # # ]: 0 : if (!(bp->flags & BNXT_FLAG_EXT_RX_PORT_STATS ||
6744 : : bp->flags & BNXT_FLAG_EXT_TX_PORT_STATS))
6745 : : return 0;
6746 : :
6747 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_QSTATS_EXT, BNXT_USE_CHIMP_MB);
6748 : :
6749 : 0 : req.port_id = rte_cpu_to_le_16(pf->port_id);
6750 [ # # ]: 0 : if (bp->flags & BNXT_FLAG_EXT_TX_PORT_STATS) {
6751 : 0 : req.tx_stat_host_addr =
6752 : 0 : rte_cpu_to_le_64(bp->hw_tx_port_stats_ext_map);
6753 : 0 : req.tx_stat_size =
6754 : : rte_cpu_to_le_16(sizeof(struct tx_port_stats_ext));
6755 : : }
6756 [ # # ]: 0 : if (bp->flags & BNXT_FLAG_EXT_RX_PORT_STATS) {
6757 : 0 : req.rx_stat_host_addr =
6758 : 0 : rte_cpu_to_le_64(bp->hw_rx_port_stats_ext_map);
6759 : 0 : req.rx_stat_size =
6760 : : rte_cpu_to_le_16(sizeof(struct rx_port_stats_ext));
6761 : : }
6762 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6763 : :
6764 [ # # ]: 0 : if (rc) {
6765 : 0 : bp->fw_rx_port_stats_ext_size = 0;
6766 : 0 : bp->fw_tx_port_stats_ext_size = 0;
6767 : : } else {
6768 : 0 : bp->fw_rx_port_stats_ext_size =
6769 : 0 : rte_le_to_cpu_16(resp->rx_stat_size);
6770 : 0 : bp->fw_tx_port_stats_ext_size =
6771 : 0 : rte_le_to_cpu_16(resp->tx_stat_size);
6772 : : }
6773 : :
6774 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6775 : : HWRM_UNLOCK();
6776 : :
6777 : 0 : return rc;
6778 : : }
6779 : :
6780 : : int
6781 : 0 : bnxt_hwrm_tunnel_redirect(struct bnxt *bp, uint8_t type)
6782 : : {
6783 : 0 : struct hwrm_cfa_redirect_tunnel_type_alloc_input req = {0};
6784 : 0 : struct hwrm_cfa_redirect_tunnel_type_alloc_output *resp =
6785 : : bp->hwrm_cmd_resp_addr;
6786 : : int rc = 0;
6787 : :
6788 [ # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC, BNXT_USE_CHIMP_MB);
6789 : 0 : req.tunnel_type = type;
6790 : 0 : req.dest_fid = bp->fw_fid;
6791 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6792 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6793 : :
6794 : : HWRM_UNLOCK();
6795 : :
6796 : 0 : return rc;
6797 : : }
6798 : :
6799 : : int
6800 : 0 : bnxt_hwrm_tunnel_redirect_free(struct bnxt *bp, uint8_t type)
6801 : : {
6802 : 0 : struct hwrm_cfa_redirect_tunnel_type_free_input req = {0};
6803 : 0 : struct hwrm_cfa_redirect_tunnel_type_free_output *resp =
6804 : : bp->hwrm_cmd_resp_addr;
6805 : : int rc = 0;
6806 : :
6807 [ # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE, BNXT_USE_CHIMP_MB);
6808 : 0 : req.tunnel_type = type;
6809 : 0 : req.dest_fid = bp->fw_fid;
6810 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6811 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6812 : :
6813 : : HWRM_UNLOCK();
6814 : :
6815 : 0 : return rc;
6816 : : }
6817 : :
6818 : 0 : int bnxt_hwrm_tunnel_redirect_query(struct bnxt *bp, uint32_t *type)
6819 : : {
6820 : 0 : struct hwrm_cfa_redirect_query_tunnel_type_input req = {0};
6821 : 0 : struct hwrm_cfa_redirect_query_tunnel_type_output *resp =
6822 : : bp->hwrm_cmd_resp_addr;
6823 : : int rc = 0;
6824 : :
6825 [ # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE, BNXT_USE_CHIMP_MB);
6826 : 0 : req.src_fid = bp->fw_fid;
6827 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6828 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6829 : :
6830 [ # # ]: 0 : if (type)
6831 : 0 : *type = rte_le_to_cpu_32(resp->tunnel_mask);
6832 : :
6833 : : HWRM_UNLOCK();
6834 : :
6835 : 0 : return rc;
6836 : : }
6837 : :
6838 : 0 : int bnxt_hwrm_tunnel_redirect_info(struct bnxt *bp, uint8_t tun_type,
6839 : : uint16_t *dst_fid)
6840 : : {
6841 : 0 : struct hwrm_cfa_redirect_tunnel_type_info_input req = {0};
6842 : 0 : struct hwrm_cfa_redirect_tunnel_type_info_output *resp =
6843 : : bp->hwrm_cmd_resp_addr;
6844 : : int rc = 0;
6845 : :
6846 [ # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO, BNXT_USE_CHIMP_MB);
6847 : 0 : req.src_fid = bp->fw_fid;
6848 : 0 : req.tunnel_type = tun_type;
6849 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6850 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6851 : :
6852 [ # # ]: 0 : if (dst_fid)
6853 : 0 : *dst_fid = rte_le_to_cpu_16(resp->dest_fid);
6854 : :
6855 : 0 : PMD_DRV_LOG(DEBUG, "dst_fid: %x\n", resp->dest_fid);
6856 : :
6857 : : HWRM_UNLOCK();
6858 : :
6859 : 0 : return rc;
6860 : : }
6861 : :
6862 : 0 : int bnxt_hwrm_set_mac(struct bnxt *bp)
6863 : : {
6864 : 0 : struct hwrm_func_vf_cfg_output *resp = bp->hwrm_cmd_resp_addr;
6865 : 0 : struct hwrm_func_vf_cfg_input req = {0};
6866 : : int rc = 0;
6867 : :
6868 [ # # ]: 0 : if (!BNXT_VF(bp))
6869 : : return 0;
6870 : :
6871 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_VF_CFG, BNXT_USE_CHIMP_MB);
6872 : :
6873 : 0 : req.enables =
6874 : : rte_cpu_to_le_32(HWRM_FUNC_VF_CFG_INPUT_ENABLES_DFLT_MAC_ADDR);
6875 : : memcpy(req.dflt_mac_addr, bp->mac_addr, RTE_ETHER_ADDR_LEN);
6876 : :
6877 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6878 : :
6879 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6880 : :
6881 : : HWRM_UNLOCK();
6882 : :
6883 : 0 : return rc;
6884 : : }
6885 : :
6886 : 0 : int bnxt_hwrm_if_change(struct bnxt *bp, bool up)
6887 : : {
6888 : 0 : struct hwrm_func_drv_if_change_output *resp = bp->hwrm_cmd_resp_addr;
6889 : 0 : struct hwrm_func_drv_if_change_input req = {0};
6890 : : uint32_t flags;
6891 : : int rc;
6892 : :
6893 [ # # ]: 0 : if (!(bp->fw_cap & BNXT_FW_CAP_IF_CHANGE))
6894 : : return 0;
6895 : :
6896 : : /* Do not issue FUNC_DRV_IF_CHANGE during reset recovery.
6897 : : * If we issue FUNC_DRV_IF_CHANGE with flags down before
6898 : : * FUNC_DRV_UNRGTR, FW resets before FUNC_DRV_UNRGTR
6899 : : */
6900 [ # # # # ]: 0 : if (!up && (bp->flags & BNXT_FLAG_FW_RESET))
6901 : : return 0;
6902 : :
6903 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_DRV_IF_CHANGE, BNXT_USE_CHIMP_MB);
6904 : :
6905 [ # # ]: 0 : if (up)
6906 : 0 : req.flags =
6907 : : rte_cpu_to_le_32(HWRM_FUNC_DRV_IF_CHANGE_INPUT_FLAGS_UP);
6908 : :
6909 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6910 : :
6911 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6912 : 0 : flags = rte_le_to_cpu_32(resp->flags);
6913 : : HWRM_UNLOCK();
6914 : :
6915 [ # # ]: 0 : if (!up)
6916 : : return 0;
6917 : :
6918 [ # # ]: 0 : if (flags & HWRM_FUNC_DRV_IF_CHANGE_OUTPUT_FLAGS_HOT_FW_RESET_DONE) {
6919 : 0 : PMD_DRV_LOG(INFO, "FW reset happened while port was down\n");
6920 : 0 : bp->flags |= BNXT_FLAG_IF_CHANGE_HOT_FW_RESET_DONE;
6921 : : }
6922 : :
6923 : : return 0;
6924 : : }
6925 : :
6926 : 0 : int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp)
6927 : : {
6928 : 0 : struct hwrm_error_recovery_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
6929 : 0 : struct bnxt_error_recovery_info *info = bp->recovery_info;
6930 : 0 : struct hwrm_error_recovery_qcfg_input req = {0};
6931 : : uint32_t flags = 0;
6932 : : unsigned int i;
6933 : : int rc;
6934 : :
6935 : : /* Older FW does not have error recovery support */
6936 [ # # ]: 0 : if (!(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY))
6937 : : return 0;
6938 : :
6939 [ # # ]: 0 : HWRM_PREP(&req, HWRM_ERROR_RECOVERY_QCFG, BNXT_USE_CHIMP_MB);
6940 : :
6941 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6942 : :
6943 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6944 : :
6945 : 0 : flags = rte_le_to_cpu_32(resp->flags);
6946 [ # # ]: 0 : if (flags & HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FLAGS_HOST)
6947 : 0 : info->flags |= BNXT_FLAG_ERROR_RECOVERY_HOST;
6948 [ # # ]: 0 : else if (flags & HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FLAGS_CO_CPU)
6949 : 0 : info->flags |= BNXT_FLAG_ERROR_RECOVERY_CO_CPU;
6950 : :
6951 [ # # ]: 0 : if ((info->flags & BNXT_FLAG_ERROR_RECOVERY_CO_CPU) &&
6952 [ # # ]: 0 : !(bp->flags & BNXT_FLAG_KONG_MB_EN)) {
6953 : : rc = -EINVAL;
6954 : 0 : goto err;
6955 : : }
6956 : :
6957 : : /* FW returned values are in units of 100msec */
6958 : 0 : info->driver_polling_freq =
6959 : 0 : rte_le_to_cpu_32(resp->driver_polling_freq) * 100;
6960 : 0 : info->primary_func_wait_period =
6961 : 0 : rte_le_to_cpu_32(resp->master_func_wait_period) * 100;
6962 : 0 : info->normal_func_wait_period =
6963 : 0 : rte_le_to_cpu_32(resp->normal_func_wait_period) * 100;
6964 : 0 : info->primary_func_wait_period_after_reset =
6965 : 0 : rte_le_to_cpu_32(resp->master_func_wait_period_after_reset) * 100;
6966 : 0 : info->max_bailout_time_after_reset =
6967 : 0 : rte_le_to_cpu_32(resp->max_bailout_time_after_reset) * 100;
6968 : 0 : info->status_regs[BNXT_FW_STATUS_REG] =
6969 : 0 : rte_le_to_cpu_32(resp->fw_health_status_reg);
6970 : 0 : info->status_regs[BNXT_FW_HEARTBEAT_CNT_REG] =
6971 : 0 : rte_le_to_cpu_32(resp->fw_heartbeat_reg);
6972 : 0 : info->status_regs[BNXT_FW_RECOVERY_CNT_REG] =
6973 : 0 : rte_le_to_cpu_32(resp->fw_reset_cnt_reg);
6974 : 0 : info->status_regs[BNXT_FW_RESET_INPROG_REG] =
6975 : 0 : rte_le_to_cpu_32(resp->reset_inprogress_reg);
6976 : 0 : info->reg_array_cnt =
6977 : 0 : rte_le_to_cpu_32(resp->reg_array_cnt);
6978 : :
6979 [ # # ]: 0 : if (info->reg_array_cnt >= BNXT_NUM_RESET_REG) {
6980 : : rc = -EINVAL;
6981 : 0 : goto err;
6982 : : }
6983 : :
6984 [ # # ]: 0 : for (i = 0; i < info->reg_array_cnt; i++) {
6985 : 0 : info->reset_reg[i] =
6986 : 0 : rte_le_to_cpu_32(resp->reset_reg[i]);
6987 : 0 : info->reset_reg_val[i] =
6988 : 0 : rte_le_to_cpu_32(resp->reset_reg_val[i]);
6989 : 0 : info->delay_after_reset[i] =
6990 : 0 : resp->delay_after_reset[i];
6991 : : }
6992 : 0 : err:
6993 : : HWRM_UNLOCK();
6994 : :
6995 : : /* Map the FW status registers */
6996 [ # # ]: 0 : if (!rc)
6997 : 0 : rc = bnxt_map_fw_health_status_regs(bp);
6998 : :
6999 [ # # ]: 0 : if (rc) {
7000 : 0 : rte_free(bp->recovery_info);
7001 : 0 : bp->recovery_info = NULL;
7002 : : }
7003 : : return rc;
7004 : : }
7005 : :
7006 : 0 : int bnxt_hwrm_fw_reset(struct bnxt *bp)
7007 : : {
7008 : 0 : struct hwrm_fw_reset_output *resp = bp->hwrm_cmd_resp_addr;
7009 : 0 : struct hwrm_fw_reset_input req = {0};
7010 : : int rc;
7011 : :
7012 [ # # ]: 0 : if (!BNXT_PF(bp))
7013 : : return -EOPNOTSUPP;
7014 : :
7015 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_FW_RESET, BNXT_USE_KONG(bp));
7016 : :
7017 : 0 : req.embedded_proc_type =
7018 : : HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_CHIP;
7019 : 0 : req.selfrst_status =
7020 : : HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTASAP;
7021 : 0 : req.flags = HWRM_FW_RESET_INPUT_FLAGS_RESET_GRACEFUL;
7022 : :
7023 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req),
7024 : : BNXT_USE_KONG(bp));
7025 : :
7026 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
7027 : : HWRM_UNLOCK();
7028 : :
7029 : 0 : return rc;
7030 : : }
7031 : :
7032 : 0 : int bnxt_hwrm_port_ts_query(struct bnxt *bp, uint8_t path, uint64_t *timestamp)
7033 : : {
7034 : 0 : struct hwrm_port_ts_query_output *resp = bp->hwrm_cmd_resp_addr;
7035 : 0 : struct hwrm_port_ts_query_input req = {0};
7036 : 0 : struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
7037 : : uint32_t flags = 0;
7038 : : int rc;
7039 : :
7040 [ # # ]: 0 : if (!ptp)
7041 : : return 0;
7042 : :
7043 [ # # # # : 0 : HWRM_PREP(&req, HWRM_PORT_TS_QUERY, BNXT_USE_CHIMP_MB);
# ]
7044 : :
7045 [ # # # ]: 0 : switch (path) {
7046 : : case BNXT_PTP_FLAGS_PATH_TX:
7047 : : flags |= HWRM_PORT_TS_QUERY_INPUT_FLAGS_PATH_TX;
7048 : : break;
7049 : 0 : case BNXT_PTP_FLAGS_PATH_RX:
7050 : : flags |= HWRM_PORT_TS_QUERY_INPUT_FLAGS_PATH_RX;
7051 : 0 : break;
7052 : 0 : case BNXT_PTP_FLAGS_CURRENT_TIME:
7053 : : flags |= HWRM_PORT_TS_QUERY_INPUT_FLAGS_CURRENT_TIME;
7054 : 0 : break;
7055 : : }
7056 : :
7057 : 0 : req.flags = rte_cpu_to_le_32(flags);
7058 : 0 : req.port_id = rte_cpu_to_le_16(bp->pf->port_id);
7059 : :
7060 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
7061 : :
7062 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
7063 : :
7064 [ # # ]: 0 : if (timestamp) {
7065 : 0 : *timestamp = rte_le_to_cpu_32(resp->ptp_msg_ts[0]);
7066 : 0 : *timestamp |=
7067 : 0 : (uint64_t)(rte_le_to_cpu_32(resp->ptp_msg_ts[1])) << 32;
7068 : : }
7069 : : HWRM_UNLOCK();
7070 : :
7071 : 0 : return rc;
7072 : : }
7073 : :
7074 : 0 : int bnxt_hwrm_cfa_counter_qcaps(struct bnxt *bp, uint16_t *max_fc)
7075 : : {
7076 : : int rc = 0;
7077 : :
7078 : 0 : struct hwrm_cfa_counter_qcaps_input req = {0};
7079 : 0 : struct hwrm_cfa_counter_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
7080 : :
7081 [ # # ]: 0 : if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
7082 : 0 : PMD_DRV_LOG(DEBUG,
7083 : : "Not a PF or trusted VF. Command not supported\n");
7084 : 0 : return 0;
7085 : : }
7086 : :
7087 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_COUNTER_QCAPS, BNXT_USE_KONG(bp));
7088 : 0 : req.target_id = rte_cpu_to_le_16(bp->fw_fid);
7089 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
7090 : :
7091 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
7092 [ # # ]: 0 : if (max_fc)
7093 : 0 : *max_fc = rte_le_to_cpu_16(resp->max_rx_fc);
7094 : : HWRM_UNLOCK();
7095 : :
7096 : 0 : return 0;
7097 : : }
7098 : :
7099 : 0 : int bnxt_hwrm_ctx_rgtr(struct bnxt *bp, rte_iova_t dma_addr, uint16_t *ctx_id)
7100 : : {
7101 : : int rc = 0;
7102 : 0 : struct hwrm_cfa_ctx_mem_rgtr_input req = {.req_type = 0 };
7103 : 0 : struct hwrm_cfa_ctx_mem_rgtr_output *resp = bp->hwrm_cmd_resp_addr;
7104 : :
7105 [ # # ]: 0 : if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
7106 : 0 : PMD_DRV_LOG(DEBUG,
7107 : : "Not a PF or trusted VF. Command not supported\n");
7108 : 0 : return 0;
7109 : : }
7110 : :
7111 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_CTX_MEM_RGTR, BNXT_USE_KONG(bp));
7112 : :
7113 : 0 : req.page_level = HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_LEVEL_LVL_0;
7114 : 0 : req.page_size = HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_2M;
7115 : 0 : req.page_dir = rte_cpu_to_le_64(dma_addr);
7116 : :
7117 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
7118 : :
7119 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
7120 [ # # ]: 0 : if (ctx_id) {
7121 : 0 : *ctx_id = rte_le_to_cpu_16(resp->ctx_id);
7122 : 0 : PMD_DRV_LOG(DEBUG, "ctx_id = %d\n", *ctx_id);
7123 : : }
7124 : : HWRM_UNLOCK();
7125 : :
7126 : 0 : return 0;
7127 : : }
7128 : :
7129 : 0 : int bnxt_hwrm_ctx_unrgtr(struct bnxt *bp, uint16_t ctx_id)
7130 : : {
7131 : : int rc = 0;
7132 : 0 : struct hwrm_cfa_ctx_mem_unrgtr_input req = {.req_type = 0 };
7133 : 0 : struct hwrm_cfa_ctx_mem_unrgtr_output *resp = bp->hwrm_cmd_resp_addr;
7134 : :
7135 [ # # ]: 0 : if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
7136 : 0 : PMD_DRV_LOG(DEBUG,
7137 : : "Not a PF or trusted VF. Command not supported\n");
7138 : 0 : return 0;
7139 : : }
7140 : :
7141 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_CTX_MEM_UNRGTR, BNXT_USE_KONG(bp));
7142 : :
7143 : 0 : req.ctx_id = rte_cpu_to_le_16(ctx_id);
7144 : :
7145 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
7146 : :
7147 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
7148 : : HWRM_UNLOCK();
7149 : :
7150 : 0 : return rc;
7151 : : }
7152 : :
7153 : 0 : int bnxt_hwrm_cfa_counter_cfg(struct bnxt *bp, enum bnxt_flow_dir dir,
7154 : : uint16_t cntr, uint16_t ctx_id,
7155 : : uint32_t num_entries, bool enable)
7156 : : {
7157 : 0 : struct hwrm_cfa_counter_cfg_input req = {0};
7158 : 0 : struct hwrm_cfa_counter_cfg_output *resp = bp->hwrm_cmd_resp_addr;
7159 : : uint16_t flags = 0;
7160 : : int rc;
7161 : :
7162 [ # # ]: 0 : if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
7163 : 0 : PMD_DRV_LOG(DEBUG,
7164 : : "Not a PF or trusted VF. Command not supported\n");
7165 : 0 : return 0;
7166 : : }
7167 : :
7168 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_COUNTER_CFG, BNXT_USE_KONG(bp));
7169 : :
7170 : 0 : req.target_id = rte_cpu_to_le_16(bp->fw_fid);
7171 : 0 : req.counter_type = rte_cpu_to_le_16(cntr);
7172 [ # # ]: 0 : flags = enable ? HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_CFG_MODE_ENABLE :
7173 : : HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_CFG_MODE_DISABLE;
7174 : 0 : flags |= HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_DATA_TRANSFER_MODE_PULL;
7175 [ # # ]: 0 : if (dir == BNXT_DIR_RX)
7176 : 0 : flags |= HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_PATH_RX;
7177 : : else if (dir == BNXT_DIR_TX)
7178 : : flags |= HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_PATH_TX;
7179 : 0 : req.flags = rte_cpu_to_le_16(flags);
7180 : 0 : req.ctx_id = rte_cpu_to_le_16(ctx_id);
7181 : 0 : req.num_entries = rte_cpu_to_le_32(num_entries);
7182 : :
7183 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
7184 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
7185 : : HWRM_UNLOCK();
7186 : :
7187 : 0 : return 0;
7188 : : }
7189 : :
7190 : 0 : int bnxt_hwrm_cfa_counter_qstats(struct bnxt *bp,
7191 : : enum bnxt_flow_dir dir,
7192 : : uint16_t cntr,
7193 : : uint16_t num_entries)
7194 : : {
7195 : 0 : struct hwrm_cfa_counter_qstats_output *resp = bp->hwrm_cmd_resp_addr;
7196 : 0 : struct hwrm_cfa_counter_qstats_input req = {0};
7197 : : uint16_t flow_ctx_id = 0;
7198 : : uint16_t flags = 0;
7199 : : int rc = 0;
7200 : :
7201 [ # # ]: 0 : if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
7202 : 0 : PMD_DRV_LOG(DEBUG,
7203 : : "Not a PF or trusted VF. Command not supported\n");
7204 : 0 : return 0;
7205 : : }
7206 : :
7207 [ # # ]: 0 : if (dir == BNXT_DIR_RX) {
7208 : 0 : flow_ctx_id = bp->flow_stat->rx_fc_in_tbl.ctx_id;
7209 : : flags = HWRM_CFA_COUNTER_QSTATS_INPUT_FLAGS_PATH_RX;
7210 [ # # ]: 0 : } else if (dir == BNXT_DIR_TX) {
7211 : 0 : flow_ctx_id = bp->flow_stat->tx_fc_in_tbl.ctx_id;
7212 : : flags = HWRM_CFA_COUNTER_QSTATS_INPUT_FLAGS_PATH_TX;
7213 : : }
7214 : :
7215 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_COUNTER_QSTATS, BNXT_USE_KONG(bp));
7216 : 0 : req.target_id = rte_cpu_to_le_16(bp->fw_fid);
7217 : 0 : req.counter_type = rte_cpu_to_le_16(cntr);
7218 : 0 : req.input_flow_ctx_id = rte_cpu_to_le_16(flow_ctx_id);
7219 : 0 : req.num_entries = rte_cpu_to_le_16(num_entries);
7220 : 0 : req.flags = rte_cpu_to_le_16(flags);
7221 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
7222 : :
7223 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
7224 : : HWRM_UNLOCK();
7225 : :
7226 : 0 : return 0;
7227 : : }
7228 : :
7229 : 0 : int bnxt_hwrm_first_vf_id_query(struct bnxt *bp, uint16_t fid,
7230 : : uint16_t *first_vf_id)
7231 : : {
7232 : : int rc = 0;
7233 : 0 : struct hwrm_func_qcaps_input req = {.req_type = 0 };
7234 : 0 : struct hwrm_func_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
7235 : :
7236 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QCAPS, BNXT_USE_CHIMP_MB);
7237 : :
7238 : 0 : req.fid = rte_cpu_to_le_16(fid);
7239 : :
7240 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
7241 : :
7242 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
7243 : :
7244 [ # # ]: 0 : if (first_vf_id)
7245 : 0 : *first_vf_id = rte_le_to_cpu_16(resp->first_vf_id);
7246 : :
7247 : : HWRM_UNLOCK();
7248 : :
7249 : 0 : return rc;
7250 : : }
7251 : :
7252 : 0 : int bnxt_hwrm_cfa_pair_exists(struct bnxt *bp, struct bnxt_representor *rep_bp)
7253 : : {
7254 : 0 : struct hwrm_cfa_pair_info_output *resp = bp->hwrm_cmd_resp_addr;
7255 : 0 : struct hwrm_cfa_pair_info_input req = {0};
7256 : : int rc = 0;
7257 : :
7258 [ # # ]: 0 : if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
7259 : 0 : PMD_DRV_LOG(DEBUG,
7260 : : "Not a PF or trusted VF. Command not supported\n");
7261 : 0 : return 0;
7262 : : }
7263 : :
7264 [ # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_PAIR_INFO, BNXT_USE_CHIMP_MB);
7265 : 0 : snprintf(req.pair_name, sizeof(req.pair_name), "%svfr%d",
7266 : 0 : bp->eth_dev->data->name, rep_bp->vf_id);
7267 : 0 : req.flags =
7268 : : rte_cpu_to_le_32(HWRM_CFA_PAIR_INFO_INPUT_FLAGS_LOOKUP_TYPE);
7269 : :
7270 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
7271 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
7272 [ # # ]: 0 : if (rc == HWRM_ERR_CODE_SUCCESS && strlen(resp->pair_name)) {
7273 : : HWRM_UNLOCK();
7274 : 0 : return !rc;
7275 : : }
7276 : : HWRM_UNLOCK();
7277 : 0 : return rc;
7278 : : }
7279 : :
7280 : 0 : int bnxt_hwrm_cfa_pair_alloc(struct bnxt *bp, struct bnxt_representor *rep_bp)
7281 : : {
7282 : 0 : struct hwrm_cfa_pair_alloc_output *resp = bp->hwrm_cmd_resp_addr;
7283 : 0 : struct hwrm_cfa_pair_alloc_input req = {0};
7284 : : int rc;
7285 : :
7286 [ # # ]: 0 : if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
7287 : 0 : PMD_DRV_LOG(DEBUG,
7288 : : "Not a PF or trusted VF. Command not supported\n");
7289 : 0 : return 0;
7290 : : }
7291 : :
7292 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_PAIR_ALLOC, BNXT_USE_CHIMP_MB);
7293 : 0 : req.pair_mode = HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_REP2FN_TRUFLOW;
7294 : 0 : snprintf(req.pair_name, sizeof(req.pair_name), "%svfr%d",
7295 [ # # ]: 0 : bp->eth_dev->data->name, rep_bp->vf_id);
7296 : :
7297 : 0 : req.pf_b_id = rep_bp->parent_pf_idx;
7298 [ # # ]: 0 : req.vf_b_id = BNXT_REP_PF(rep_bp) ? rte_cpu_to_le_16(((uint16_t)-1)) :
7299 : : rte_cpu_to_le_16(rep_bp->vf_id);
7300 : 0 : req.vf_a_id = rte_cpu_to_le_16(bp->fw_fid);
7301 : 0 : req.host_b_id = 1; /* TBD - Confirm if this is OK */
7302 : :
7303 : 0 : req.enables |= rep_bp->flags & BNXT_REP_Q_R2F_VALID ?
7304 : 0 : HWRM_CFA_PAIR_ALLOC_INPUT_ENABLES_Q_AB_VALID : 0;
7305 : 0 : req.enables |= rep_bp->flags & BNXT_REP_Q_F2R_VALID ?
7306 : 0 : HWRM_CFA_PAIR_ALLOC_INPUT_ENABLES_Q_BA_VALID : 0;
7307 : 0 : req.enables |= rep_bp->flags & BNXT_REP_FC_R2F_VALID ?
7308 : 0 : HWRM_CFA_PAIR_ALLOC_INPUT_ENABLES_FC_AB_VALID : 0;
7309 : 0 : req.enables |= rep_bp->flags & BNXT_REP_FC_F2R_VALID ?
7310 : 0 : HWRM_CFA_PAIR_ALLOC_INPUT_ENABLES_FC_BA_VALID : 0;
7311 : :
7312 : 0 : req.q_ab = rep_bp->rep_q_r2f;
7313 : 0 : req.q_ba = rep_bp->rep_q_f2r;
7314 : 0 : req.fc_ab = rep_bp->rep_fc_r2f;
7315 : 0 : req.fc_ba = rep_bp->rep_fc_f2r;
7316 : :
7317 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
7318 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
7319 : :
7320 : : HWRM_UNLOCK();
7321 [ # # ]: 0 : PMD_DRV_LOG(DEBUG, "%s %d allocated\n",
7322 : : BNXT_REP_PF(rep_bp) ? "PFR" : "VFR", rep_bp->vf_id);
7323 : 0 : return rc;
7324 : : }
7325 : :
7326 : 0 : int bnxt_hwrm_cfa_pair_free(struct bnxt *bp, struct bnxt_representor *rep_bp)
7327 : : {
7328 : 0 : struct hwrm_cfa_pair_free_output *resp = bp->hwrm_cmd_resp_addr;
7329 : 0 : struct hwrm_cfa_pair_free_input req = {0};
7330 : : int rc;
7331 : :
7332 [ # # ]: 0 : if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
7333 : 0 : PMD_DRV_LOG(DEBUG,
7334 : : "Not a PF or trusted VF. Command not supported\n");
7335 : 0 : return 0;
7336 : : }
7337 : :
7338 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_PAIR_FREE, BNXT_USE_CHIMP_MB);
7339 : 0 : snprintf(req.pair_name, sizeof(req.pair_name), "%svfr%d",
7340 [ # # ]: 0 : bp->eth_dev->data->name, rep_bp->vf_id);
7341 : 0 : req.pf_b_id = rep_bp->parent_pf_idx;
7342 : 0 : req.pair_mode = HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_REP2FN_TRUFLOW;
7343 [ # # ]: 0 : req.vf_id = BNXT_REP_PF(rep_bp) ? rte_cpu_to_le_16(((uint16_t)-1)) :
7344 : : rte_cpu_to_le_16(rep_bp->vf_id);
7345 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
7346 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
7347 : : HWRM_UNLOCK();
7348 [ # # ]: 0 : PMD_DRV_LOG(DEBUG, "%s %d freed\n", BNXT_REP_PF(rep_bp) ? "PFR" : "VFR",
7349 : : rep_bp->vf_id);
7350 : 0 : return rc;
7351 : : }
7352 : :
7353 : 0 : int bnxt_hwrm_fw_echo_reply(struct bnxt *bp, uint32_t echo_req_data1,
7354 : : uint32_t echo_req_data2)
7355 : : {
7356 : 0 : struct hwrm_func_echo_response_input req = {0};
7357 : 0 : struct hwrm_func_echo_response_output *resp = bp->hwrm_cmd_resp_addr;
7358 : : int rc;
7359 : :
7360 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_ECHO_RESPONSE, BNXT_USE_CHIMP_MB);
7361 : 0 : req.event_data1 = rte_cpu_to_le_32(echo_req_data1);
7362 : 0 : req.event_data2 = rte_cpu_to_le_32(echo_req_data2);
7363 : :
7364 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
7365 : :
7366 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
7367 : : HWRM_UNLOCK();
7368 : :
7369 : 0 : return rc;
7370 : : }
7371 : :
7372 : 0 : int bnxt_hwrm_poll_ver_get(struct bnxt *bp)
7373 : : {
7374 : 0 : struct hwrm_ver_get_input req = {.req_type = 0 };
7375 : 0 : struct hwrm_ver_get_output *resp = bp->hwrm_cmd_resp_addr;
7376 : : int rc = 0;
7377 : :
7378 : 0 : bp->max_req_len = HWRM_MAX_REQ_LEN;
7379 : 0 : bp->max_resp_len = BNXT_PAGE_SIZE;
7380 : 0 : bp->hwrm_cmd_timeout = SHORT_HWRM_CMD_TIMEOUT;
7381 : :
7382 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VER_GET, BNXT_USE_CHIMP_MB);
7383 : 0 : req.hwrm_intf_maj = HWRM_VERSION_MAJOR;
7384 : 0 : req.hwrm_intf_min = HWRM_VERSION_MINOR;
7385 : 0 : req.hwrm_intf_upd = HWRM_VERSION_UPDATE;
7386 : :
7387 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
7388 : :
7389 [ # # # # ]: 0 : HWRM_CHECK_RESULT_SILENT();
7390 : : HWRM_UNLOCK();
7391 : :
7392 : 0 : return rc;
7393 : : }
7394 : :
7395 : 0 : int bnxt_hwrm_read_sfp_module_eeprom_info(struct bnxt *bp, uint16_t i2c_addr,
7396 : : uint16_t page_number, uint16_t start_addr,
7397 : : uint16_t data_length, uint8_t *buf)
7398 : : {
7399 : 0 : struct hwrm_port_phy_i2c_read_output *resp = bp->hwrm_cmd_resp_addr;
7400 : 0 : struct hwrm_port_phy_i2c_read_input req = {0};
7401 : : uint32_t enables = HWRM_PORT_PHY_I2C_READ_INPUT_ENABLES_PAGE_OFFSET;
7402 : : int rc, byte_offset = 0;
7403 : :
7404 : : do {
7405 : : uint16_t xfer_size;
7406 : :
7407 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_PHY_I2C_READ, BNXT_USE_CHIMP_MB);
7408 : 0 : req.i2c_slave_addr = i2c_addr;
7409 : 0 : req.page_number = rte_cpu_to_le_16(page_number);
7410 : 0 : req.port_id = rte_cpu_to_le_16(bp->pf->port_id);
7411 : :
7412 : 0 : xfer_size = RTE_MIN(data_length, BNXT_MAX_PHY_I2C_RESP_SIZE);
7413 : 0 : req.page_offset = rte_cpu_to_le_16(start_addr + byte_offset);
7414 : 0 : req.data_length = xfer_size;
7415 [ # # ]: 0 : req.enables = rte_cpu_to_le_32(start_addr + byte_offset ? enables : 0);
7416 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
7417 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
7418 : :
7419 : 0 : memcpy(buf + byte_offset, resp->data, xfer_size);
7420 : :
7421 : 0 : data_length -= xfer_size;
7422 : 0 : byte_offset += xfer_size;
7423 : :
7424 : : HWRM_UNLOCK();
7425 [ # # ]: 0 : } while (data_length > 0);
7426 : :
7427 : : return rc;
7428 : : }
7429 : :
7430 : 0 : void bnxt_free_hwrm_tx_ring(struct bnxt *bp, int queue_index)
7431 : : {
7432 : 0 : struct bnxt_tx_queue *txq = bp->tx_queues[queue_index];
7433 : 0 : struct bnxt_tx_ring_info *txr = txq->tx_ring;
7434 : 0 : struct bnxt_ring *ring = txr->tx_ring_struct;
7435 : 0 : struct bnxt_cp_ring_info *cpr = txq->cp_ring;
7436 : :
7437 : 0 : bnxt_hwrm_ring_free(bp, ring,
7438 : : HWRM_RING_FREE_INPUT_RING_TYPE_TX,
7439 : 0 : cpr->cp_ring_struct->fw_ring_id);
7440 : 0 : txr->tx_raw_prod = 0;
7441 : 0 : txr->tx_raw_cons = 0;
7442 : 0 : memset(txr->tx_desc_ring, 0,
7443 : 0 : txr->tx_ring_struct->ring_size * sizeof(*txr->tx_desc_ring));
7444 : 0 : memset(txr->tx_buf_ring, 0,
7445 : 0 : txr->tx_ring_struct->ring_size * sizeof(*txr->tx_buf_ring));
7446 : :
7447 : 0 : bnxt_hwrm_stat_ctx_free(bp, cpr);
7448 : :
7449 : 0 : bnxt_free_cp_ring(bp, cpr);
7450 : 0 : }
7451 : :
7452 : 0 : int bnxt_hwrm_config_host_mtu(struct bnxt *bp)
7453 : : {
7454 : 0 : struct hwrm_func_cfg_input req = {0};
7455 : 0 : struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
7456 : : int rc;
7457 : :
7458 [ # # ]: 0 : if (!BNXT_PF(bp))
7459 : : return 0;
7460 : :
7461 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
7462 : :
7463 : 0 : req.fid = rte_cpu_to_le_16(0xffff);
7464 : 0 : req.enables = rte_cpu_to_le_32(HWRM_FUNC_CFG_INPUT_ENABLES_HOST_MTU);
7465 : 0 : req.host_mtu = rte_cpu_to_le_16(bp->eth_dev->data->mtu);
7466 : :
7467 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
7468 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
7469 : : HWRM_UNLOCK();
7470 : :
7471 : 0 : return rc;
7472 : : }
7473 : :
7474 : : int
7475 : 0 : bnxt_vnic_rss_clear_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic)
7476 : : {
7477 : 0 : struct hwrm_vnic_rss_cfg_output *resp = bp->hwrm_cmd_resp_addr;
7478 : 0 : struct hwrm_vnic_rss_cfg_input req = {0};
7479 : 0 : int nr_ctxs = vnic->num_lb_ctxts;
7480 : : int i, rc = 0;
7481 : :
7482 [ # # ]: 0 : for (i = 0; i < nr_ctxs; i++) {
7483 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_RSS_CFG, BNXT_USE_CHIMP_MB);
7484 : :
7485 : 0 : req.rss_ctx_idx = rte_cpu_to_le_16(vnic->fw_grp_ids[i]);
7486 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
7487 : :
7488 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
7489 : :
7490 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
7491 : : HWRM_UNLOCK();
7492 : : }
7493 : :
7494 : : return rc;
7495 : : }
|