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