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