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