2 * Broadcom NetXtreme-C/E network driver.
4 * Copyright (c) 2016 Broadcom, All Rights Reserved.
5 * The term Broadcom refers to Broadcom Limited and/or its subsidiaries
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS'
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26 * THE POSSIBILITY OF SUCH DAMAGE.
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
32 #include <sys/param.h>
33 #include <sys/socket.h>
34 #include <sys/kernel.h>
36 #include <sys/module.h>
38 #include <sys/endian.h>
39 #include <sys/sockio.h>
42 #include <machine/bus.h>
43 #include <machine/resource.h>
45 #include <dev/pci/pcireg.h>
46 #include <dev/pci/pcivar.h>
49 #include <net/if_media.h>
50 #include <net/if_var.h>
51 #include <net/ethernet.h>
52 #include <net/iflib.h>
55 #include "opt_inet6.h"
61 #include "bnxt_hwrm.h"
62 #include "bnxt_ioctl.h"
63 #include "bnxt_sysctl.h"
64 #include "hsi_struct_def.h"
70 static pci_vendor_info_t bnxt_vendor_info_array[] =
72 PVID(BROADCOM_VENDOR_ID, BCM57301,
73 "Broadcom BCM57301 NetXtreme-C 10Gb Ethernet Controller"),
74 PVID(BROADCOM_VENDOR_ID, BCM57302,
75 "Broadcom BCM57302 NetXtreme-C 10Gb/25Gb Ethernet Controller"),
76 PVID(BROADCOM_VENDOR_ID, BCM57304,
77 "Broadcom BCM57304 NetXtreme-C 10Gb/25Gb/40Gb/50Gb Ethernet Controller"),
78 PVID(BROADCOM_VENDOR_ID, BCM57311,
79 "Broadcom BCM57311 NetXtreme-C 10Gb Ethernet"),
80 PVID(BROADCOM_VENDOR_ID, BCM57312,
81 "Broadcom BCM57312 NetXtreme-C 10Gb/25Gb Ethernet"),
82 PVID(BROADCOM_VENDOR_ID, BCM57314,
83 "Broadcom BCM57314 NetXtreme-C 10Gb/25Gb/40Gb/50Gb Ethernet"),
84 PVID(BROADCOM_VENDOR_ID, BCM57402,
85 "Broadcom BCM57402 NetXtreme-E 10Gb Ethernet Controller"),
86 PVID(BROADCOM_VENDOR_ID, BCM57402_NPAR,
87 "Broadcom BCM57402 NetXtreme-E Partition"),
88 PVID(BROADCOM_VENDOR_ID, BCM57404,
89 "Broadcom BCM57404 NetXtreme-E 10Gb/25Gb Ethernet Controller"),
90 PVID(BROADCOM_VENDOR_ID, BCM57404_NPAR,
91 "Broadcom BCM57404 NetXtreme-E Partition"),
92 PVID(BROADCOM_VENDOR_ID, BCM57406,
93 "Broadcom BCM57406 NetXtreme-E 10GBase-T Ethernet Controller"),
94 PVID(BROADCOM_VENDOR_ID, BCM57406_NPAR,
95 "Broadcom BCM57406 NetXtreme-E Partition"),
96 PVID(BROADCOM_VENDOR_ID, BCM57407,
97 "Broadcom BCM57407 NetXtreme-E 10GBase-T Ethernet Controller"),
98 PVID(BROADCOM_VENDOR_ID, BCM57407_NPAR,
99 "Broadcom BCM57407 NetXtreme-E Ethernet Partition"),
100 PVID(BROADCOM_VENDOR_ID, BCM57407_SFP,
101 "Broadcom BCM57407 NetXtreme-E 25Gb Ethernet Controller"),
102 PVID(BROADCOM_VENDOR_ID, BCM57412,
103 "Broadcom BCM57412 NetXtreme-E 10Gb Ethernet"),
104 PVID(BROADCOM_VENDOR_ID, BCM57412_NPAR1,
105 "Broadcom BCM57412 NetXtreme-E Ethernet Partition"),
106 PVID(BROADCOM_VENDOR_ID, BCM57412_NPAR2,
107 "Broadcom BCM57412 NetXtreme-E Ethernet Partition"),
108 PVID(BROADCOM_VENDOR_ID, BCM57414,
109 "Broadcom BCM57414 NetXtreme-E 10Gb/25Gb Ethernet"),
110 PVID(BROADCOM_VENDOR_ID, BCM57414_NPAR1,
111 "Broadcom BCM57414 NetXtreme-E Ethernet Partition"),
112 PVID(BROADCOM_VENDOR_ID, BCM57414_NPAR2,
113 "Broadcom BCM57414 NetXtreme-E Ethernet Partition"),
114 PVID(BROADCOM_VENDOR_ID, BCM57416,
115 "Broadcom BCM57416 NetXtreme-E 10GBase-T Ethernet"),
116 PVID(BROADCOM_VENDOR_ID, BCM57416_NPAR1,
117 "Broadcom BCM57416 NetXtreme-E Ethernet Partition"),
118 PVID(BROADCOM_VENDOR_ID, BCM57416_NPAR2,
119 "Broadcom BCM57416 NetXtreme-E Ethernet Partition"),
120 PVID(BROADCOM_VENDOR_ID, BCM57416_SFP,
121 "Broadcom BCM57416 NetXtreme-E 10Gb Ethernet"),
122 PVID(BROADCOM_VENDOR_ID, BCM57417,
123 "Broadcom BCM57417 NetXtreme-E 10GBase-T Ethernet"),
124 PVID(BROADCOM_VENDOR_ID, BCM57417_NPAR1,
125 "Broadcom BCM57417 NetXtreme-E Ethernet Partition"),
126 PVID(BROADCOM_VENDOR_ID, BCM57417_NPAR2,
127 "Broadcom BCM57417 NetXtreme-E Ethernet Partition"),
128 PVID(BROADCOM_VENDOR_ID, BCM57417_SFP,
129 "Broadcom BCM57417 NetXtreme-E 10Gb/25Gb Ethernet"),
130 PVID(BROADCOM_VENDOR_ID, BCM57454,
131 "Broadcom BCM57454 NetXtreme-E 10Gb/25Gb/40Gb/50Gb/100Gb Ethernet"),
132 PVID(BROADCOM_VENDOR_ID, BCM58700,
133 "Broadcom BCM58700 Nitro 1Gb/2.5Gb/10Gb Ethernet"),
134 PVID(BROADCOM_VENDOR_ID, NETXTREME_C_VF1,
135 "Broadcom NetXtreme-C Ethernet Virtual Function"),
136 PVID(BROADCOM_VENDOR_ID, NETXTREME_C_VF2,
137 "Broadcom NetXtreme-C Ethernet Virtual Function"),
138 PVID(BROADCOM_VENDOR_ID, NETXTREME_C_VF3,
139 "Broadcom NetXtreme-C Ethernet Virtual Function"),
140 PVID(BROADCOM_VENDOR_ID, NETXTREME_E_VF1,
141 "Broadcom NetXtreme-E Ethernet Virtual Function"),
142 PVID(BROADCOM_VENDOR_ID, NETXTREME_E_VF2,
143 "Broadcom NetXtreme-E Ethernet Virtual Function"),
144 PVID(BROADCOM_VENDOR_ID, NETXTREME_E_VF3,
145 "Broadcom NetXtreme-E Ethernet Virtual Function"),
146 /* required last entry */
152 * Function prototypes
155 static void *bnxt_register(device_t dev);
157 /* Soft queue setup and teardown */
158 static int bnxt_tx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs,
159 uint64_t *paddrs, int ntxqs, int ntxqsets);
160 static int bnxt_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs,
161 uint64_t *paddrs, int nrxqs, int nrxqsets);
162 static void bnxt_queues_free(if_ctx_t ctx);
164 /* Device setup and teardown */
165 static int bnxt_attach_pre(if_ctx_t ctx);
166 static int bnxt_attach_post(if_ctx_t ctx);
167 static int bnxt_detach(if_ctx_t ctx);
169 /* Device configuration */
170 static void bnxt_init(if_ctx_t ctx);
171 static void bnxt_stop(if_ctx_t ctx);
172 static void bnxt_multi_set(if_ctx_t ctx);
173 static int bnxt_mtu_set(if_ctx_t ctx, uint32_t mtu);
174 static void bnxt_media_status(if_ctx_t ctx, struct ifmediareq * ifmr);
175 static int bnxt_media_change(if_ctx_t ctx);
176 static int bnxt_promisc_set(if_ctx_t ctx, int flags);
177 static uint64_t bnxt_get_counter(if_ctx_t, ift_counter);
178 static void bnxt_update_admin_status(if_ctx_t ctx);
179 static void bnxt_if_timer(if_ctx_t ctx, uint16_t qid);
181 /* Interrupt enable / disable */
182 static void bnxt_intr_enable(if_ctx_t ctx);
183 static int bnxt_rx_queue_intr_enable(if_ctx_t ctx, uint16_t qid);
184 static int bnxt_tx_queue_intr_enable(if_ctx_t ctx, uint16_t qid);
185 static void bnxt_disable_intr(if_ctx_t ctx);
186 static int bnxt_msix_intr_assign(if_ctx_t ctx, int msix);
189 static void bnxt_vlan_register(if_ctx_t ctx, uint16_t vtag);
190 static void bnxt_vlan_unregister(if_ctx_t ctx, uint16_t vtag);
193 static int bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data);
195 static int bnxt_shutdown(if_ctx_t ctx);
196 static int bnxt_suspend(if_ctx_t ctx);
197 static int bnxt_resume(if_ctx_t ctx);
199 /* Internal support functions */
200 static int bnxt_probe_phy(struct bnxt_softc *softc);
201 static void bnxt_add_media_types(struct bnxt_softc *softc);
202 static int bnxt_pci_mapping(struct bnxt_softc *softc);
203 static void bnxt_pci_mapping_free(struct bnxt_softc *softc);
204 static int bnxt_update_link(struct bnxt_softc *softc, bool chng_link_state);
205 static int bnxt_handle_def_cp(void *arg);
206 static int bnxt_handle_rx_cp(void *arg);
207 static void bnxt_clear_ids(struct bnxt_softc *softc);
208 static void inline bnxt_do_enable_intr(struct bnxt_cp_ring *cpr);
209 static void inline bnxt_do_disable_intr(struct bnxt_cp_ring *cpr);
210 static void bnxt_mark_cpr_invalid(struct bnxt_cp_ring *cpr);
211 static void bnxt_def_cp_task(void *context);
212 static void bnxt_handle_async_event(struct bnxt_softc *softc,
213 struct cmpl_base *cmpl);
214 static uint8_t get_phy_type(struct bnxt_softc *softc);
215 static uint64_t bnxt_get_baudrate(struct bnxt_link_info *link);
216 static void bnxt_get_wol_settings(struct bnxt_softc *softc);
217 static int bnxt_wol_config(if_ctx_t ctx);
220 * Device Interface Declaration
223 static device_method_t bnxt_methods[] = {
224 /* Device interface */
225 DEVMETHOD(device_register, bnxt_register),
226 DEVMETHOD(device_probe, iflib_device_probe),
227 DEVMETHOD(device_attach, iflib_device_attach),
228 DEVMETHOD(device_detach, iflib_device_detach),
229 DEVMETHOD(device_shutdown, iflib_device_shutdown),
230 DEVMETHOD(device_suspend, iflib_device_suspend),
231 DEVMETHOD(device_resume, iflib_device_resume),
235 static driver_t bnxt_driver = {
236 "bnxt", bnxt_methods, sizeof(struct bnxt_softc),
239 devclass_t bnxt_devclass;
240 DRIVER_MODULE(bnxt, pci, bnxt_driver, bnxt_devclass, 0, 0);
242 MODULE_DEPEND(bnxt, pci, 1, 1, 1);
243 MODULE_DEPEND(bnxt, ether, 1, 1, 1);
244 MODULE_DEPEND(bnxt, iflib, 1, 1, 1);
246 IFLIB_PNP_INFO(pci, bnxt, bnxt_vendor_info_array);
248 static device_method_t bnxt_iflib_methods[] = {
249 DEVMETHOD(ifdi_tx_queues_alloc, bnxt_tx_queues_alloc),
250 DEVMETHOD(ifdi_rx_queues_alloc, bnxt_rx_queues_alloc),
251 DEVMETHOD(ifdi_queues_free, bnxt_queues_free),
253 DEVMETHOD(ifdi_attach_pre, bnxt_attach_pre),
254 DEVMETHOD(ifdi_attach_post, bnxt_attach_post),
255 DEVMETHOD(ifdi_detach, bnxt_detach),
257 DEVMETHOD(ifdi_init, bnxt_init),
258 DEVMETHOD(ifdi_stop, bnxt_stop),
259 DEVMETHOD(ifdi_multi_set, bnxt_multi_set),
260 DEVMETHOD(ifdi_mtu_set, bnxt_mtu_set),
261 DEVMETHOD(ifdi_media_status, bnxt_media_status),
262 DEVMETHOD(ifdi_media_change, bnxt_media_change),
263 DEVMETHOD(ifdi_promisc_set, bnxt_promisc_set),
264 DEVMETHOD(ifdi_get_counter, bnxt_get_counter),
265 DEVMETHOD(ifdi_update_admin_status, bnxt_update_admin_status),
266 DEVMETHOD(ifdi_timer, bnxt_if_timer),
268 DEVMETHOD(ifdi_intr_enable, bnxt_intr_enable),
269 DEVMETHOD(ifdi_tx_queue_intr_enable, bnxt_tx_queue_intr_enable),
270 DEVMETHOD(ifdi_rx_queue_intr_enable, bnxt_rx_queue_intr_enable),
271 DEVMETHOD(ifdi_intr_disable, bnxt_disable_intr),
272 DEVMETHOD(ifdi_msix_intr_assign, bnxt_msix_intr_assign),
274 DEVMETHOD(ifdi_vlan_register, bnxt_vlan_register),
275 DEVMETHOD(ifdi_vlan_unregister, bnxt_vlan_unregister),
277 DEVMETHOD(ifdi_priv_ioctl, bnxt_priv_ioctl),
279 DEVMETHOD(ifdi_suspend, bnxt_suspend),
280 DEVMETHOD(ifdi_shutdown, bnxt_shutdown),
281 DEVMETHOD(ifdi_resume, bnxt_resume),
286 static driver_t bnxt_iflib_driver = {
287 "bnxt", bnxt_iflib_methods, sizeof(struct bnxt_softc)
291 * iflib shared context
294 #define BNXT_DRIVER_VERSION "1.0.0.2"
295 char bnxt_driver_version[] = BNXT_DRIVER_VERSION;
296 extern struct if_txrx bnxt_txrx;
297 static struct if_shared_ctx bnxt_sctx_init = {
298 .isc_magic = IFLIB_MAGIC,
299 .isc_driver = &bnxt_iflib_driver,
300 .isc_nfl = 2, // Number of Free Lists
301 .isc_flags = IFLIB_HAS_RXCQ | IFLIB_HAS_TXCQ | IFLIB_NEED_ETHER_PAD,
302 .isc_q_align = PAGE_SIZE,
303 .isc_tx_maxsize = BNXT_TSO_SIZE,
304 .isc_tx_maxsegsize = BNXT_TSO_SIZE,
305 .isc_rx_maxsize = BNXT_TSO_SIZE,
306 .isc_rx_maxsegsize = BNXT_TSO_SIZE,
308 // Only use a single segment to avoid page size constraints
309 .isc_rx_nsegments = 1,
312 .isc_nrxd_min = {16, 16, 16},
313 .isc_nrxd_default = {PAGE_SIZE / sizeof(struct cmpl_base) * 8,
314 PAGE_SIZE / sizeof(struct rx_prod_pkt_bd),
315 PAGE_SIZE / sizeof(struct rx_prod_pkt_bd)},
316 .isc_nrxd_max = {INT32_MAX, INT32_MAX, INT32_MAX},
317 .isc_ntxd_min = {16, 16, 16},
318 .isc_ntxd_default = {PAGE_SIZE / sizeof(struct cmpl_base) * 2,
319 PAGE_SIZE / sizeof(struct tx_bd_short)},
320 .isc_ntxd_max = {INT32_MAX, INT32_MAX, INT32_MAX},
322 .isc_admin_intrcnt = 1,
323 .isc_vendor_info = bnxt_vendor_info_array,
324 .isc_driver_version = bnxt_driver_version,
327 if_shared_ctx_t bnxt_sctx = &bnxt_sctx_init;
334 bnxt_register(device_t dev)
340 * Device Dependent Configuration Functions
343 /* Soft queue setup and teardown */
345 bnxt_tx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs,
346 uint64_t *paddrs, int ntxqs, int ntxqsets)
348 struct bnxt_softc *softc;
352 softc = iflib_get_softc(ctx);
354 softc->tx_cp_rings = malloc(sizeof(struct bnxt_cp_ring) * ntxqsets,
355 M_DEVBUF, M_NOWAIT | M_ZERO);
356 if (!softc->tx_cp_rings) {
357 device_printf(iflib_get_dev(ctx),
358 "unable to allocate TX completion rings\n");
362 softc->tx_rings = malloc(sizeof(struct bnxt_ring) * ntxqsets,
363 M_DEVBUF, M_NOWAIT | M_ZERO);
364 if (!softc->tx_rings) {
365 device_printf(iflib_get_dev(ctx),
366 "unable to allocate TX rings\n");
368 goto ring_alloc_fail;
370 rc = iflib_dma_alloc(ctx, sizeof(struct ctx_hw_stats) * ntxqsets,
371 &softc->tx_stats, 0);
374 bus_dmamap_sync(softc->tx_stats.idi_tag, softc->tx_stats.idi_map,
375 BUS_DMASYNC_PREREAD);
377 for (i = 0; i < ntxqsets; i++) {
378 /* Set up the completion ring */
379 softc->tx_cp_rings[i].stats_ctx_id = HWRM_NA_SIGNATURE;
380 softc->tx_cp_rings[i].ring.phys_id =
381 (uint16_t)HWRM_NA_SIGNATURE;
382 softc->tx_cp_rings[i].ring.softc = softc;
383 softc->tx_cp_rings[i].ring.id =
384 (softc->scctx->isc_nrxqsets * 2) + 1 + i;
385 softc->tx_cp_rings[i].ring.doorbell =
386 softc->tx_cp_rings[i].ring.id * 0x80;
387 softc->tx_cp_rings[i].ring.ring_size =
388 softc->scctx->isc_ntxd[0];
389 softc->tx_cp_rings[i].ring.vaddr = vaddrs[i * ntxqs];
390 softc->tx_cp_rings[i].ring.paddr = paddrs[i * ntxqs];
392 /* Set up the TX ring */
393 softc->tx_rings[i].phys_id = (uint16_t)HWRM_NA_SIGNATURE;
394 softc->tx_rings[i].softc = softc;
395 softc->tx_rings[i].id =
396 (softc->scctx->isc_nrxqsets * 2) + 1 + i;
397 softc->tx_rings[i].doorbell = softc->tx_rings[i].id * 0x80;
398 softc->tx_rings[i].ring_size = softc->scctx->isc_ntxd[1];
399 softc->tx_rings[i].vaddr = vaddrs[i * ntxqs + 1];
400 softc->tx_rings[i].paddr = paddrs[i * ntxqs + 1];
402 bnxt_create_tx_sysctls(softc, i);
405 softc->ntxqsets = ntxqsets;
409 free(softc->tx_rings, M_DEVBUF);
411 free(softc->tx_cp_rings, M_DEVBUF);
417 bnxt_queues_free(if_ctx_t ctx)
419 struct bnxt_softc *softc = iflib_get_softc(ctx);
422 iflib_dma_free(&softc->tx_stats);
423 free(softc->tx_rings, M_DEVBUF);
424 softc->tx_rings = NULL;
425 free(softc->tx_cp_rings, M_DEVBUF);
426 softc->tx_cp_rings = NULL;
430 iflib_dma_free(&softc->rx_stats);
431 iflib_dma_free(&softc->hw_tx_port_stats);
432 iflib_dma_free(&softc->hw_rx_port_stats);
433 free(softc->grp_info, M_DEVBUF);
434 free(softc->ag_rings, M_DEVBUF);
435 free(softc->rx_rings, M_DEVBUF);
436 free(softc->rx_cp_rings, M_DEVBUF);
440 bnxt_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs,
441 uint64_t *paddrs, int nrxqs, int nrxqsets)
443 struct bnxt_softc *softc;
447 softc = iflib_get_softc(ctx);
449 softc->rx_cp_rings = malloc(sizeof(struct bnxt_cp_ring) * nrxqsets,
450 M_DEVBUF, M_NOWAIT | M_ZERO);
451 if (!softc->rx_cp_rings) {
452 device_printf(iflib_get_dev(ctx),
453 "unable to allocate RX completion rings\n");
457 softc->rx_rings = malloc(sizeof(struct bnxt_ring) * nrxqsets,
458 M_DEVBUF, M_NOWAIT | M_ZERO);
459 if (!softc->rx_rings) {
460 device_printf(iflib_get_dev(ctx),
461 "unable to allocate RX rings\n");
463 goto ring_alloc_fail;
465 softc->ag_rings = malloc(sizeof(struct bnxt_ring) * nrxqsets,
466 M_DEVBUF, M_NOWAIT | M_ZERO);
467 if (!softc->ag_rings) {
468 device_printf(iflib_get_dev(ctx),
469 "unable to allocate aggregation rings\n");
473 softc->grp_info = malloc(sizeof(struct bnxt_grp_info) * nrxqsets,
474 M_DEVBUF, M_NOWAIT | M_ZERO);
475 if (!softc->grp_info) {
476 device_printf(iflib_get_dev(ctx),
477 "unable to allocate ring groups\n");
482 rc = iflib_dma_alloc(ctx, sizeof(struct ctx_hw_stats) * nrxqsets,
483 &softc->rx_stats, 0);
485 goto hw_stats_alloc_fail;
486 bus_dmamap_sync(softc->rx_stats.idi_tag, softc->rx_stats.idi_map,
487 BUS_DMASYNC_PREREAD);
490 * Additional 512 bytes for future expansion.
491 * To prevent corruption when loaded with newer firmwares with added counters.
492 * This can be deleted when there will be no further additions of counters.
494 #define BNXT_PORT_STAT_PADDING 512
496 rc = iflib_dma_alloc(ctx, sizeof(struct rx_port_stats) + BNXT_PORT_STAT_PADDING,
497 &softc->hw_rx_port_stats, 0);
499 goto hw_port_rx_stats_alloc_fail;
501 bus_dmamap_sync(softc->hw_rx_port_stats.idi_tag,
502 softc->hw_rx_port_stats.idi_map, BUS_DMASYNC_PREREAD);
504 rc = iflib_dma_alloc(ctx, sizeof(struct tx_port_stats) + BNXT_PORT_STAT_PADDING,
505 &softc->hw_tx_port_stats, 0);
508 goto hw_port_tx_stats_alloc_fail;
510 bus_dmamap_sync(softc->hw_tx_port_stats.idi_tag,
511 softc->hw_tx_port_stats.idi_map, BUS_DMASYNC_PREREAD);
513 softc->rx_port_stats = (void *) softc->hw_rx_port_stats.idi_vaddr;
514 softc->tx_port_stats = (void *) softc->hw_tx_port_stats.idi_vaddr;
516 for (i = 0; i < nrxqsets; i++) {
517 /* Allocation the completion ring */
518 softc->rx_cp_rings[i].stats_ctx_id = HWRM_NA_SIGNATURE;
519 softc->rx_cp_rings[i].ring.phys_id =
520 (uint16_t)HWRM_NA_SIGNATURE;
521 softc->rx_cp_rings[i].ring.softc = softc;
522 softc->rx_cp_rings[i].ring.id = i + 1;
523 softc->rx_cp_rings[i].ring.doorbell =
524 softc->rx_cp_rings[i].ring.id * 0x80;
526 * If this ring overflows, RX stops working.
528 softc->rx_cp_rings[i].ring.ring_size =
529 softc->scctx->isc_nrxd[0];
530 softc->rx_cp_rings[i].ring.vaddr = vaddrs[i * nrxqs];
531 softc->rx_cp_rings[i].ring.paddr = paddrs[i * nrxqs];
533 /* Allocate the RX ring */
534 softc->rx_rings[i].phys_id = (uint16_t)HWRM_NA_SIGNATURE;
535 softc->rx_rings[i].softc = softc;
536 softc->rx_rings[i].id = i + 1;
537 softc->rx_rings[i].doorbell = softc->rx_rings[i].id * 0x80;
538 softc->rx_rings[i].ring_size = softc->scctx->isc_nrxd[1];
539 softc->rx_rings[i].vaddr = vaddrs[i * nrxqs + 1];
540 softc->rx_rings[i].paddr = paddrs[i * nrxqs + 1];
542 /* Allocate the TPA start buffer */
543 softc->rx_rings[i].tpa_start = malloc(sizeof(struct bnxt_full_tpa_start) *
544 (RX_TPA_START_CMPL_AGG_ID_MASK >> RX_TPA_START_CMPL_AGG_ID_SFT),
545 M_DEVBUF, M_NOWAIT | M_ZERO);
546 if (softc->rx_rings[i].tpa_start == NULL) {
548 device_printf(softc->dev,
549 "Unable to allocate space for TPA\n");
553 /* Allocate the AG ring */
554 softc->ag_rings[i].phys_id = (uint16_t)HWRM_NA_SIGNATURE;
555 softc->ag_rings[i].softc = softc;
556 softc->ag_rings[i].id = nrxqsets + i + 1;
557 softc->ag_rings[i].doorbell = softc->ag_rings[i].id * 0x80;
558 softc->ag_rings[i].ring_size = softc->scctx->isc_nrxd[2];
559 softc->ag_rings[i].vaddr = vaddrs[i * nrxqs + 2];
560 softc->ag_rings[i].paddr = paddrs[i * nrxqs + 2];
562 /* Allocate the ring group */
563 softc->grp_info[i].grp_id = (uint16_t)HWRM_NA_SIGNATURE;
564 softc->grp_info[i].stats_ctx =
565 softc->rx_cp_rings[i].stats_ctx_id;
566 softc->grp_info[i].rx_ring_id = softc->rx_rings[i].phys_id;
567 softc->grp_info[i].ag_ring_id = softc->ag_rings[i].phys_id;
568 softc->grp_info[i].cp_ring_id =
569 softc->rx_cp_rings[i].ring.phys_id;
571 bnxt_create_rx_sysctls(softc, i);
575 * When SR-IOV is enabled, avoid each VF sending PORT_QSTATS
576 * HWRM every sec with which firmware timeouts can happen
579 bnxt_create_port_stats_sysctls(softc);
581 /* And finally, the VNIC */
582 softc->vnic_info.id = (uint16_t)HWRM_NA_SIGNATURE;
583 softc->vnic_info.flow_id = (uint16_t)HWRM_NA_SIGNATURE;
584 softc->vnic_info.filter_id = -1;
585 softc->vnic_info.def_ring_grp = (uint16_t)HWRM_NA_SIGNATURE;
586 softc->vnic_info.cos_rule = (uint16_t)HWRM_NA_SIGNATURE;
587 softc->vnic_info.lb_rule = (uint16_t)HWRM_NA_SIGNATURE;
588 softc->vnic_info.rx_mask = HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_BCAST;
589 softc->vnic_info.mc_list_count = 0;
590 softc->vnic_info.flags = BNXT_VNIC_FLAG_DEFAULT;
591 rc = iflib_dma_alloc(ctx, BNXT_MAX_MC_ADDRS * ETHER_ADDR_LEN,
592 &softc->vnic_info.mc_list, 0);
594 goto mc_list_alloc_fail;
596 /* The VNIC RSS Hash Key */
597 rc = iflib_dma_alloc(ctx, HW_HASH_KEY_SIZE,
598 &softc->vnic_info.rss_hash_key_tbl, 0);
600 goto rss_hash_alloc_fail;
601 bus_dmamap_sync(softc->vnic_info.rss_hash_key_tbl.idi_tag,
602 softc->vnic_info.rss_hash_key_tbl.idi_map,
603 BUS_DMASYNC_PREWRITE);
604 memcpy(softc->vnic_info.rss_hash_key_tbl.idi_vaddr,
605 softc->vnic_info.rss_hash_key, HW_HASH_KEY_SIZE);
607 /* Allocate the RSS tables */
608 rc = iflib_dma_alloc(ctx, HW_HASH_INDEX_SIZE * sizeof(uint16_t),
609 &softc->vnic_info.rss_grp_tbl, 0);
611 goto rss_grp_alloc_fail;
612 bus_dmamap_sync(softc->vnic_info.rss_grp_tbl.idi_tag,
613 softc->vnic_info.rss_grp_tbl.idi_map,
614 BUS_DMASYNC_PREWRITE);
615 memset(softc->vnic_info.rss_grp_tbl.idi_vaddr, 0xff,
616 softc->vnic_info.rss_grp_tbl.idi_size);
618 softc->nrxqsets = nrxqsets;
622 iflib_dma_free(&softc->vnic_info.rss_hash_key_tbl);
624 iflib_dma_free(&softc->vnic_info.mc_list);
627 for (i = i - 1; i >= 0; i--)
628 free(softc->rx_rings[i].tpa_start, M_DEVBUF);
629 iflib_dma_free(&softc->hw_tx_port_stats);
630 hw_port_tx_stats_alloc_fail:
631 iflib_dma_free(&softc->hw_rx_port_stats);
632 hw_port_rx_stats_alloc_fail:
633 iflib_dma_free(&softc->rx_stats);
635 free(softc->grp_info, M_DEVBUF);
637 free(softc->ag_rings, M_DEVBUF);
639 free(softc->rx_rings, M_DEVBUF);
641 free(softc->rx_cp_rings, M_DEVBUF);
646 static void bnxt_free_hwrm_short_cmd_req(struct bnxt_softc *softc)
648 if (softc->hwrm_short_cmd_req_addr.idi_vaddr)
649 iflib_dma_free(&softc->hwrm_short_cmd_req_addr);
650 softc->hwrm_short_cmd_req_addr.idi_vaddr = NULL;
653 static int bnxt_alloc_hwrm_short_cmd_req(struct bnxt_softc *softc)
657 rc = iflib_dma_alloc(softc->ctx, softc->hwrm_max_req_len,
658 &softc->hwrm_short_cmd_req_addr, BUS_DMA_NOWAIT);
663 /* Device setup and teardown */
665 bnxt_attach_pre(if_ctx_t ctx)
667 struct bnxt_softc *softc = iflib_get_softc(ctx);
668 if_softc_ctx_t scctx;
672 softc->dev = iflib_get_dev(ctx);
673 softc->media = iflib_get_media(ctx);
674 softc->scctx = iflib_get_softc_ctx(ctx);
675 softc->sctx = iflib_get_sctx(ctx);
676 scctx = softc->scctx;
678 /* TODO: Better way of detecting NPAR/VF is needed */
679 switch (pci_get_device(softc->dev)) {
690 softc->flags |= BNXT_FLAG_NPAR;
692 case NETXTREME_C_VF1:
693 case NETXTREME_C_VF2:
694 case NETXTREME_C_VF3:
695 case NETXTREME_E_VF1:
696 case NETXTREME_E_VF2:
697 case NETXTREME_E_VF3:
698 softc->flags |= BNXT_FLAG_VF;
702 pci_enable_busmaster(softc->dev);
704 if (bnxt_pci_mapping(softc))
707 /* HWRM setup/init */
708 BNXT_HWRM_LOCK_INIT(softc, device_get_nameunit(softc->dev));
709 rc = bnxt_alloc_hwrm_dma_mem(softc);
714 /* Get firmware version and compare with driver */
715 softc->ver_info = malloc(sizeof(struct bnxt_ver_info),
716 M_DEVBUF, M_NOWAIT | M_ZERO);
717 if (softc->ver_info == NULL) {
719 device_printf(softc->dev,
720 "Unable to allocate space for version info\n");
723 /* Default minimum required HWRM version */
724 softc->ver_info->hwrm_min_major = 1;
725 softc->ver_info->hwrm_min_minor = 2;
726 softc->ver_info->hwrm_min_update = 2;
728 rc = bnxt_hwrm_ver_get(softc);
730 device_printf(softc->dev, "attach: hwrm ver get failed\n");
734 if (softc->flags & BNXT_FLAG_SHORT_CMD) {
735 rc = bnxt_alloc_hwrm_short_cmd_req(softc);
737 goto hwrm_short_cmd_alloc_fail;
741 if (BNXT_PF(softc)) {
742 softc->nvm_info = malloc(sizeof(struct bnxt_nvram_info),
743 M_DEVBUF, M_NOWAIT | M_ZERO);
744 if (softc->nvm_info == NULL) {
746 device_printf(softc->dev,
747 "Unable to allocate space for NVRAM info\n");
751 rc = bnxt_hwrm_nvm_get_dev_info(softc, &softc->nvm_info->mfg_id,
752 &softc->nvm_info->device_id, &softc->nvm_info->sector_size,
753 &softc->nvm_info->size, &softc->nvm_info->reserved_size,
754 &softc->nvm_info->available_size);
757 /* Register the driver with the FW */
758 rc = bnxt_hwrm_func_drv_rgtr(softc);
760 device_printf(softc->dev, "attach: hwrm drv rgtr failed\n");
764 rc = bnxt_hwrm_func_rgtr_async_events(softc, NULL, 0);
766 device_printf(softc->dev, "attach: hwrm rgtr async evts failed\n");
770 /* Get the HW capabilities */
771 rc = bnxt_hwrm_func_qcaps(softc);
775 /* Get the current configuration of this function */
776 rc = bnxt_hwrm_func_qcfg(softc);
778 device_printf(softc->dev, "attach: hwrm func qcfg failed\n");
782 iflib_set_mac(ctx, softc->func.mac_addr);
784 scctx->isc_txrx = &bnxt_txrx;
785 scctx->isc_tx_csum_flags = (CSUM_IP | CSUM_TCP | CSUM_UDP |
786 CSUM_TCP_IPV6 | CSUM_UDP_IPV6 | CSUM_TSO);
787 scctx->isc_capenable =
788 /* These are translated to hwassit bits */
789 IFCAP_TXCSUM | IFCAP_TXCSUM_IPV6 | IFCAP_TSO4 | IFCAP_TSO6 |
790 /* These are checked by iflib */
791 IFCAP_LRO | IFCAP_VLAN_HWFILTER |
792 /* These are part of the iflib mask */
793 IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6 | IFCAP_VLAN_MTU |
794 IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_HWTSO |
795 /* These likely get lost... */
796 IFCAP_VLAN_HWCSUM | IFCAP_JUMBO_MTU;
798 if (bnxt_wol_supported(softc))
799 scctx->isc_capenable |= IFCAP_WOL_MAGIC;
801 /* Get the queue config */
802 rc = bnxt_hwrm_queue_qportcfg(softc);
804 device_printf(softc->dev, "attach: hwrm qportcfg failed\n");
808 bnxt_get_wol_settings(softc);
810 /* Now perform a function reset */
811 rc = bnxt_hwrm_func_reset(softc);
812 bnxt_clear_ids(softc);
816 /* Now set up iflib sc */
817 scctx->isc_tx_nsegments = 31,
818 scctx->isc_tx_tso_segments_max = 31;
819 scctx->isc_tx_tso_size_max = BNXT_TSO_SIZE;
820 scctx->isc_tx_tso_segsize_max = BNXT_TSO_SIZE;
821 scctx->isc_vectors = softc->func.max_cp_rings;
822 scctx->isc_min_frame_size = BNXT_MIN_FRAME_SIZE;
823 scctx->isc_txrx = &bnxt_txrx;
825 if (scctx->isc_nrxd[0] <
826 ((scctx->isc_nrxd[1] * 4) + scctx->isc_nrxd[2]))
827 device_printf(softc->dev,
828 "WARNING: nrxd0 (%d) should be at least 4 * nrxd1 (%d) + nrxd2 (%d). Driver may be unstable\n",
829 scctx->isc_nrxd[0], scctx->isc_nrxd[1], scctx->isc_nrxd[2]);
830 if (scctx->isc_ntxd[0] < scctx->isc_ntxd[1] * 2)
831 device_printf(softc->dev,
832 "WARNING: ntxd0 (%d) should be at least 2 * ntxd1 (%d). Driver may be unstable\n",
833 scctx->isc_ntxd[0], scctx->isc_ntxd[1]);
834 scctx->isc_txqsizes[0] = sizeof(struct cmpl_base) * scctx->isc_ntxd[0];
835 scctx->isc_txqsizes[1] = sizeof(struct tx_bd_short) *
837 scctx->isc_rxqsizes[0] = sizeof(struct cmpl_base) * scctx->isc_nrxd[0];
838 scctx->isc_rxqsizes[1] = sizeof(struct rx_prod_pkt_bd) *
840 scctx->isc_rxqsizes[2] = sizeof(struct rx_prod_pkt_bd) *
843 scctx->isc_nrxqsets_max = min(pci_msix_count(softc->dev)-1,
844 softc->fn_qcfg.alloc_completion_rings - 1);
845 scctx->isc_nrxqsets_max = min(scctx->isc_nrxqsets_max,
846 softc->fn_qcfg.alloc_rx_rings);
847 scctx->isc_nrxqsets_max = min(scctx->isc_nrxqsets_max,
848 softc->fn_qcfg.alloc_vnics);
849 scctx->isc_ntxqsets_max = min(softc->fn_qcfg.alloc_tx_rings,
850 softc->fn_qcfg.alloc_completion_rings - scctx->isc_nrxqsets_max - 1);
852 scctx->isc_rss_table_size = HW_HASH_INDEX_SIZE;
853 scctx->isc_rss_table_mask = scctx->isc_rss_table_size - 1;
855 /* iflib will map and release this bar */
856 scctx->isc_msix_bar = pci_msix_table_bar(softc->dev);
859 * Default settings for HW LRO (TPA):
860 * Disable HW LRO by default
861 * Can be enabled after taking care of 'packet forwarding'
863 softc->hw_lro.enable = 0;
864 softc->hw_lro.is_mode_gro = 0;
865 softc->hw_lro.max_agg_segs = 5; /* 2^5 = 32 segs */
866 softc->hw_lro.max_aggs = HWRM_VNIC_TPA_CFG_INPUT_MAX_AGGS_MAX;
867 softc->hw_lro.min_agg_len = 512;
869 /* Allocate the default completion ring */
870 softc->def_cp_ring.stats_ctx_id = HWRM_NA_SIGNATURE;
871 softc->def_cp_ring.ring.phys_id = (uint16_t)HWRM_NA_SIGNATURE;
872 softc->def_cp_ring.ring.softc = softc;
873 softc->def_cp_ring.ring.id = 0;
874 softc->def_cp_ring.ring.doorbell = softc->def_cp_ring.ring.id * 0x80;
875 softc->def_cp_ring.ring.ring_size = PAGE_SIZE /
876 sizeof(struct cmpl_base);
877 rc = iflib_dma_alloc(ctx,
878 sizeof(struct cmpl_base) * softc->def_cp_ring.ring.ring_size,
879 &softc->def_cp_ring_mem, 0);
880 softc->def_cp_ring.ring.vaddr = softc->def_cp_ring_mem.idi_vaddr;
881 softc->def_cp_ring.ring.paddr = softc->def_cp_ring_mem.idi_paddr;
882 iflib_config_gtask_init(ctx, &softc->def_cp_task, bnxt_def_cp_task,
885 rc = bnxt_init_sysctl_ctx(softc);
887 goto init_sysctl_failed;
888 if (BNXT_PF(softc)) {
889 rc = bnxt_create_nvram_sysctls(softc->nvm_info);
894 arc4rand(softc->vnic_info.rss_hash_key, HW_HASH_KEY_SIZE, 0);
895 softc->vnic_info.rss_hash_type =
896 HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4 |
897 HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV4 |
898 HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV4 |
899 HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV6 |
900 HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV6 |
901 HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV6;
902 rc = bnxt_create_config_sysctls_pre(softc);
906 rc = bnxt_create_hw_lro_sysctls(softc);
910 rc = bnxt_create_pause_fc_sysctls(softc);
914 /* Initialize the vlan list */
915 SLIST_INIT(&softc->vnic_info.vlan_tags);
916 softc->vnic_info.vlan_tag_list.idi_vaddr = NULL;
921 bnxt_free_sysctl_ctx(softc);
923 bnxt_hwrm_func_drv_unrgtr(softc, false);
926 free(softc->nvm_info, M_DEVBUF);
928 bnxt_free_hwrm_short_cmd_req(softc);
929 hwrm_short_cmd_alloc_fail:
931 free(softc->ver_info, M_DEVBUF);
933 bnxt_free_hwrm_dma_mem(softc);
935 BNXT_HWRM_LOCK_DESTROY(softc);
936 bnxt_pci_mapping_free(softc);
937 pci_disable_busmaster(softc->dev);
942 bnxt_attach_post(if_ctx_t ctx)
944 struct bnxt_softc *softc = iflib_get_softc(ctx);
945 if_t ifp = iflib_get_ifp(ctx);
948 bnxt_create_config_sysctls_post(softc);
950 /* Update link state etc... */
951 rc = bnxt_probe_phy(softc);
955 /* Needs to be done after probing the phy */
956 bnxt_create_ver_sysctls(softc);
957 bnxt_add_media_types(softc);
958 ifmedia_set(softc->media, IFM_ETHER | IFM_AUTO);
960 softc->scctx->isc_max_frame_size = ifp->if_mtu + ETHER_HDR_LEN +
968 bnxt_detach(if_ctx_t ctx)
970 struct bnxt_softc *softc = iflib_get_softc(ctx);
971 struct bnxt_vlan_tag *tag;
972 struct bnxt_vlan_tag *tmp;
975 bnxt_wol_config(ctx);
976 bnxt_do_disable_intr(&softc->def_cp_ring);
977 bnxt_free_sysctl_ctx(softc);
978 bnxt_hwrm_func_reset(softc);
979 bnxt_clear_ids(softc);
980 iflib_irq_free(ctx, &softc->def_cp_ring.irq);
981 iflib_config_gtask_deinit(&softc->def_cp_task);
982 /* We need to free() these here... */
983 for (i = softc->nrxqsets-1; i>=0; i--) {
984 iflib_irq_free(ctx, &softc->rx_cp_rings[i].irq);
986 iflib_dma_free(&softc->vnic_info.mc_list);
987 iflib_dma_free(&softc->vnic_info.rss_hash_key_tbl);
988 iflib_dma_free(&softc->vnic_info.rss_grp_tbl);
989 if (softc->vnic_info.vlan_tag_list.idi_vaddr)
990 iflib_dma_free(&softc->vnic_info.vlan_tag_list);
991 SLIST_FOREACH_SAFE(tag, &softc->vnic_info.vlan_tags, next, tmp)
993 iflib_dma_free(&softc->def_cp_ring_mem);
994 for (i = 0; i < softc->nrxqsets; i++)
995 free(softc->rx_rings[i].tpa_start, M_DEVBUF);
996 free(softc->ver_info, M_DEVBUF);
998 free(softc->nvm_info, M_DEVBUF);
1000 bnxt_hwrm_func_drv_unrgtr(softc, false);
1001 bnxt_free_hwrm_dma_mem(softc);
1002 bnxt_free_hwrm_short_cmd_req(softc);
1003 BNXT_HWRM_LOCK_DESTROY(softc);
1005 pci_disable_busmaster(softc->dev);
1006 bnxt_pci_mapping_free(softc);
1011 /* Device configuration */
1013 bnxt_init(if_ctx_t ctx)
1015 struct bnxt_softc *softc = iflib_get_softc(ctx);
1016 struct ifmediareq ifmr;
1020 rc = bnxt_hwrm_func_reset(softc);
1023 bnxt_clear_ids(softc);
1025 /* Allocate the default completion ring */
1026 softc->def_cp_ring.cons = UINT32_MAX;
1027 softc->def_cp_ring.v_bit = 1;
1028 bnxt_mark_cpr_invalid(&softc->def_cp_ring);
1029 rc = bnxt_hwrm_ring_alloc(softc,
1030 HWRM_RING_ALLOC_INPUT_RING_TYPE_L2_CMPL,
1031 &softc->def_cp_ring.ring,
1032 (uint16_t)HWRM_NA_SIGNATURE,
1033 HWRM_NA_SIGNATURE, true);
1037 /* And now set the default CP ring as the async CP ring */
1038 rc = bnxt_cfg_async_cr(softc);
1042 for (i = 0; i < softc->nrxqsets; i++) {
1043 /* Allocate the statistics context */
1044 rc = bnxt_hwrm_stat_ctx_alloc(softc, &softc->rx_cp_rings[i],
1045 softc->rx_stats.idi_paddr +
1046 (sizeof(struct ctx_hw_stats) * i));
1050 /* Allocate the completion ring */
1051 softc->rx_cp_rings[i].cons = UINT32_MAX;
1052 softc->rx_cp_rings[i].v_bit = 1;
1053 softc->rx_cp_rings[i].last_idx = UINT32_MAX;
1054 bnxt_mark_cpr_invalid(&softc->rx_cp_rings[i]);
1055 rc = bnxt_hwrm_ring_alloc(softc,
1056 HWRM_RING_ALLOC_INPUT_RING_TYPE_L2_CMPL,
1057 &softc->rx_cp_rings[i].ring, (uint16_t)HWRM_NA_SIGNATURE,
1058 HWRM_NA_SIGNATURE, true);
1062 /* Allocate the RX ring */
1063 rc = bnxt_hwrm_ring_alloc(softc,
1064 HWRM_RING_ALLOC_INPUT_RING_TYPE_RX,
1065 &softc->rx_rings[i], (uint16_t)HWRM_NA_SIGNATURE,
1066 HWRM_NA_SIGNATURE, false);
1069 BNXT_RX_DB(&softc->rx_rings[i], 0);
1070 /* TODO: Cumulus+ doesn't need the double doorbell */
1071 BNXT_RX_DB(&softc->rx_rings[i], 0);
1073 /* Allocate the AG ring */
1074 rc = bnxt_hwrm_ring_alloc(softc,
1075 HWRM_RING_ALLOC_INPUT_RING_TYPE_RX,
1076 &softc->ag_rings[i], (uint16_t)HWRM_NA_SIGNATURE,
1077 HWRM_NA_SIGNATURE, false);
1080 BNXT_RX_DB(&softc->rx_rings[i], 0);
1081 /* TODO: Cumulus+ doesn't need the double doorbell */
1082 BNXT_RX_DB(&softc->ag_rings[i], 0);
1084 /* Allocate the ring group */
1085 softc->grp_info[i].stats_ctx =
1086 softc->rx_cp_rings[i].stats_ctx_id;
1087 softc->grp_info[i].rx_ring_id = softc->rx_rings[i].phys_id;
1088 softc->grp_info[i].ag_ring_id = softc->ag_rings[i].phys_id;
1089 softc->grp_info[i].cp_ring_id =
1090 softc->rx_cp_rings[i].ring.phys_id;
1091 rc = bnxt_hwrm_ring_grp_alloc(softc, &softc->grp_info[i]);
1097 /* Allocate the VNIC RSS context */
1098 rc = bnxt_hwrm_vnic_ctx_alloc(softc, &softc->vnic_info.rss_id);
1102 /* Allocate the vnic */
1103 softc->vnic_info.def_ring_grp = softc->grp_info[0].grp_id;
1104 softc->vnic_info.mru = softc->scctx->isc_max_frame_size;
1105 rc = bnxt_hwrm_vnic_alloc(softc, &softc->vnic_info);
1108 rc = bnxt_hwrm_vnic_cfg(softc, &softc->vnic_info);
1111 rc = bnxt_hwrm_set_filter(softc, &softc->vnic_info);
1115 /* Enable RSS on the VNICs */
1116 for (i = 0, j = 0; i < HW_HASH_INDEX_SIZE; i++) {
1118 softc->vnic_info.rss_grp_tbl.idi_vaddr)[i] =
1119 htole16(softc->grp_info[j].grp_id);
1120 if (++j == softc->nrxqsets)
1124 rc = bnxt_hwrm_rss_cfg(softc, &softc->vnic_info,
1125 softc->vnic_info.rss_hash_type);
1129 rc = bnxt_hwrm_vnic_tpa_cfg(softc);
1133 for (i = 0; i < softc->ntxqsets; i++) {
1134 /* Allocate the statistics context */
1135 rc = bnxt_hwrm_stat_ctx_alloc(softc, &softc->tx_cp_rings[i],
1136 softc->tx_stats.idi_paddr +
1137 (sizeof(struct ctx_hw_stats) * i));
1141 /* Allocate the completion ring */
1142 softc->tx_cp_rings[i].cons = UINT32_MAX;
1143 softc->tx_cp_rings[i].v_bit = 1;
1144 bnxt_mark_cpr_invalid(&softc->tx_cp_rings[i]);
1145 rc = bnxt_hwrm_ring_alloc(softc,
1146 HWRM_RING_ALLOC_INPUT_RING_TYPE_L2_CMPL,
1147 &softc->tx_cp_rings[i].ring, (uint16_t)HWRM_NA_SIGNATURE,
1148 HWRM_NA_SIGNATURE, false);
1152 /* Allocate the TX ring */
1153 rc = bnxt_hwrm_ring_alloc(softc,
1154 HWRM_RING_ALLOC_INPUT_RING_TYPE_TX,
1155 &softc->tx_rings[i], softc->tx_cp_rings[i].ring.phys_id,
1156 softc->tx_cp_rings[i].stats_ctx_id, false);
1159 BNXT_TX_DB(&softc->tx_rings[i], 0);
1160 /* TODO: Cumulus+ doesn't need the double doorbell */
1161 BNXT_TX_DB(&softc->tx_rings[i], 0);
1164 bnxt_do_enable_intr(&softc->def_cp_ring);
1165 bnxt_media_status(softc->ctx, &ifmr);
1166 bnxt_hwrm_cfa_l2_set_rx_mask(softc, &softc->vnic_info);
1170 bnxt_hwrm_func_reset(softc);
1171 bnxt_clear_ids(softc);
1176 bnxt_stop(if_ctx_t ctx)
1178 struct bnxt_softc *softc = iflib_get_softc(ctx);
1180 bnxt_do_disable_intr(&softc->def_cp_ring);
1181 bnxt_hwrm_func_reset(softc);
1182 bnxt_clear_ids(softc);
1187 bnxt_multi_set(if_ctx_t ctx)
1189 struct bnxt_softc *softc = iflib_get_softc(ctx);
1190 if_t ifp = iflib_get_ifp(ctx);
1194 mcnt = if_multiaddr_count(ifp, -1);
1196 if (mcnt > BNXT_MAX_MC_ADDRS) {
1197 softc->vnic_info.rx_mask |=
1198 HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST;
1199 bnxt_hwrm_cfa_l2_set_rx_mask(softc, &softc->vnic_info);
1202 softc->vnic_info.rx_mask &=
1203 ~HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST;
1204 mta = softc->vnic_info.mc_list.idi_vaddr;
1205 bzero(mta, softc->vnic_info.mc_list.idi_size);
1206 if_multiaddr_array(ifp, mta, &cnt, mcnt);
1207 bus_dmamap_sync(softc->vnic_info.mc_list.idi_tag,
1208 softc->vnic_info.mc_list.idi_map, BUS_DMASYNC_PREWRITE);
1209 softc->vnic_info.mc_list_count = cnt;
1210 softc->vnic_info.rx_mask |=
1211 HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_MCAST;
1212 if (bnxt_hwrm_cfa_l2_set_rx_mask(softc, &softc->vnic_info))
1213 device_printf(softc->dev,
1214 "set_multi: rx_mask set failed\n");
1219 bnxt_mtu_set(if_ctx_t ctx, uint32_t mtu)
1221 struct bnxt_softc *softc = iflib_get_softc(ctx);
1223 if (mtu > BNXT_MAX_MTU)
1226 softc->scctx->isc_max_frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
1231 bnxt_media_status(if_ctx_t ctx, struct ifmediareq * ifmr)
1233 struct bnxt_softc *softc = iflib_get_softc(ctx);
1234 struct bnxt_link_info *link_info = &softc->link_info;
1235 struct ifmedia_entry *next;
1236 uint64_t target_baudrate = bnxt_get_baudrate(link_info);
1237 int active_media = IFM_UNKNOWN;
1240 bnxt_update_link(softc, true);
1242 ifmr->ifm_status = IFM_AVALID;
1243 ifmr->ifm_active = IFM_ETHER;
1245 if (link_info->link_up)
1246 ifmr->ifm_status |= IFM_ACTIVE;
1248 ifmr->ifm_status &= ~IFM_ACTIVE;
1250 if (link_info->duplex == HWRM_PORT_PHY_QCFG_OUTPUT_DUPLEX_CFG_FULL)
1251 ifmr->ifm_active |= IFM_FDX;
1253 ifmr->ifm_active |= IFM_HDX;
1256 * Go through the list of supported media which got prepared
1257 * as part of bnxt_add_media_types() using api ifmedia_add().
1259 LIST_FOREACH(next, &(iflib_get_media(ctx)->ifm_list), ifm_list) {
1260 if (ifmedia_baudrate(next->ifm_media) == target_baudrate) {
1261 active_media = next->ifm_media;
1265 ifmr->ifm_active |= active_media;
1267 if (link_info->flow_ctrl.rx)
1268 ifmr->ifm_active |= IFM_ETH_RXPAUSE;
1269 if (link_info->flow_ctrl.tx)
1270 ifmr->ifm_active |= IFM_ETH_TXPAUSE;
1272 bnxt_report_link(softc);
1277 bnxt_media_change(if_ctx_t ctx)
1279 struct bnxt_softc *softc = iflib_get_softc(ctx);
1280 struct ifmedia *ifm = iflib_get_media(ctx);
1281 struct ifmediareq ifmr;
1284 if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
1287 switch (IFM_SUBTYPE(ifm->ifm_media)) {
1289 softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
1290 softc->link_info.req_link_speed =
1291 HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_100MB;
1295 case IFM_1000_SGMII:
1296 softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
1297 softc->link_info.req_link_speed =
1298 HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_1GB;
1302 softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
1303 softc->link_info.req_link_speed =
1304 HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_2_5GB;
1311 softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
1312 softc->link_info.req_link_speed =
1313 HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_10GB;
1316 softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
1317 softc->link_info.req_link_speed =
1318 HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_20GB;
1323 softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
1324 softc->link_info.req_link_speed =
1325 HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_25GB;
1331 softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
1332 softc->link_info.req_link_speed =
1333 HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_40GB;
1337 softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
1338 softc->link_info.req_link_speed =
1339 HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_50GB;
1345 softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
1346 softc->link_info.req_link_speed =
1347 HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_100GB;
1350 device_printf(softc->dev,
1351 "Unsupported media type! Using auto\n");
1355 softc->link_info.autoneg |= BNXT_AUTONEG_SPEED;
1358 rc = bnxt_hwrm_set_link_setting(softc, true, true, true);
1359 bnxt_media_status(softc->ctx, &ifmr);
1364 bnxt_promisc_set(if_ctx_t ctx, int flags)
1366 struct bnxt_softc *softc = iflib_get_softc(ctx);
1367 if_t ifp = iflib_get_ifp(ctx);
1370 if (ifp->if_flags & IFF_ALLMULTI ||
1371 if_multiaddr_count(ifp, -1) > BNXT_MAX_MC_ADDRS)
1372 softc->vnic_info.rx_mask |=
1373 HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST;
1375 softc->vnic_info.rx_mask &=
1376 ~HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST;
1378 if (ifp->if_flags & IFF_PROMISC)
1379 softc->vnic_info.rx_mask |=
1380 HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_PROMISCUOUS |
1381 HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ANYVLAN_NONVLAN;
1383 softc->vnic_info.rx_mask &=
1384 ~(HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_PROMISCUOUS |
1385 HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ANYVLAN_NONVLAN);
1387 rc = bnxt_hwrm_cfa_l2_set_rx_mask(softc, &softc->vnic_info);
1393 bnxt_get_counter(if_ctx_t ctx, ift_counter cnt)
1395 if_t ifp = iflib_get_ifp(ctx);
1397 if (cnt < IFCOUNTERS)
1398 return if_get_counter_default(ifp, cnt);
1404 bnxt_update_admin_status(if_ctx_t ctx)
1406 struct bnxt_softc *softc = iflib_get_softc(ctx);
1409 * When SR-IOV is enabled, avoid each VF sending this HWRM
1410 * request every sec with which firmware timeouts can happen
1412 if (BNXT_PF(softc)) {
1413 bnxt_hwrm_port_qstats(softc);
1420 bnxt_if_timer(if_ctx_t ctx, uint16_t qid)
1423 struct bnxt_softc *softc = iflib_get_softc(ctx);
1424 uint64_t ticks_now = ticks;
1426 /* Schedule bnxt_update_admin_status() once per sec */
1427 if (ticks_now - softc->admin_ticks >= hz) {
1428 softc->admin_ticks = ticks_now;
1429 iflib_admin_intr_deferred(ctx);
1436 bnxt_do_enable_intr(struct bnxt_cp_ring *cpr)
1438 if (cpr->ring.phys_id != (uint16_t)HWRM_NA_SIGNATURE) {
1439 /* First time enabling, do not set index */
1440 if (cpr->cons == UINT32_MAX)
1441 BNXT_CP_ENABLE_DB(&cpr->ring);
1443 BNXT_CP_IDX_ENABLE_DB(&cpr->ring, cpr->cons);
1448 bnxt_do_disable_intr(struct bnxt_cp_ring *cpr)
1450 if (cpr->ring.phys_id != (uint16_t)HWRM_NA_SIGNATURE)
1451 BNXT_CP_DISABLE_DB(&cpr->ring);
1454 /* Enable all interrupts */
1456 bnxt_intr_enable(if_ctx_t ctx)
1458 struct bnxt_softc *softc = iflib_get_softc(ctx);
1461 bnxt_do_enable_intr(&softc->def_cp_ring);
1462 for (i = 0; i < softc->nrxqsets; i++)
1463 bnxt_do_enable_intr(&softc->rx_cp_rings[i]);
1468 /* Enable interrupt for a single queue */
1470 bnxt_tx_queue_intr_enable(if_ctx_t ctx, uint16_t qid)
1472 struct bnxt_softc *softc = iflib_get_softc(ctx);
1474 bnxt_do_enable_intr(&softc->tx_cp_rings[qid]);
1479 bnxt_rx_queue_intr_enable(if_ctx_t ctx, uint16_t qid)
1481 struct bnxt_softc *softc = iflib_get_softc(ctx);
1483 bnxt_do_enable_intr(&softc->rx_cp_rings[qid]);
1487 /* Disable all interrupts */
1489 bnxt_disable_intr(if_ctx_t ctx)
1491 struct bnxt_softc *softc = iflib_get_softc(ctx);
1495 * NOTE: These TX interrupts should never get enabled, so don't
1498 for (i = 0; i < softc->ntxqsets; i++)
1499 bnxt_do_disable_intr(&softc->tx_cp_rings[i]);
1500 for (i = 0; i < softc->nrxqsets; i++)
1501 bnxt_do_disable_intr(&softc->rx_cp_rings[i]);
1507 bnxt_msix_intr_assign(if_ctx_t ctx, int msix)
1509 struct bnxt_softc *softc = iflib_get_softc(ctx);
1514 rc = iflib_irq_alloc_generic(ctx, &softc->def_cp_ring.irq,
1515 softc->def_cp_ring.ring.id + 1, IFLIB_INTR_ADMIN,
1516 bnxt_handle_def_cp, softc, 0, "def_cp");
1518 device_printf(iflib_get_dev(ctx),
1519 "Failed to register default completion ring handler\n");
1523 for (i=0; i<softc->scctx->isc_nrxqsets; i++) {
1524 snprintf(irq_name, sizeof(irq_name), "rxq%d", i);
1525 rc = iflib_irq_alloc_generic(ctx, &softc->rx_cp_rings[i].irq,
1526 softc->rx_cp_rings[i].ring.id + 1, IFLIB_INTR_RX,
1527 bnxt_handle_rx_cp, &softc->rx_cp_rings[i], i, irq_name);
1529 device_printf(iflib_get_dev(ctx),
1530 "Failed to register RX completion ring handler\n");
1536 for (i=0; i<softc->scctx->isc_ntxqsets; i++)
1537 iflib_softirq_alloc_generic(ctx, NULL, IFLIB_INTR_TX, NULL, i, "tx_cp");
1543 iflib_irq_free(ctx, &softc->rx_cp_rings[i].irq);
1544 iflib_irq_free(ctx, &softc->def_cp_ring.irq);
1549 * We're explicitly allowing duplicates here. They will need to be
1550 * removed as many times as they are added.
1553 bnxt_vlan_register(if_ctx_t ctx, uint16_t vtag)
1555 struct bnxt_softc *softc = iflib_get_softc(ctx);
1556 struct bnxt_vlan_tag *new_tag;
1558 new_tag = malloc(sizeof(struct bnxt_vlan_tag), M_DEVBUF, M_NOWAIT);
1559 if (new_tag == NULL)
1561 new_tag->tag = vtag;
1562 new_tag->tpid = 8100;
1563 SLIST_INSERT_HEAD(&softc->vnic_info.vlan_tags, new_tag, next);
1567 bnxt_vlan_unregister(if_ctx_t ctx, uint16_t vtag)
1569 struct bnxt_softc *softc = iflib_get_softc(ctx);
1570 struct bnxt_vlan_tag *vlan_tag;
1572 SLIST_FOREACH(vlan_tag, &softc->vnic_info.vlan_tags, next) {
1573 if (vlan_tag->tag == vtag) {
1574 SLIST_REMOVE(&softc->vnic_info.vlan_tags, vlan_tag,
1575 bnxt_vlan_tag, next);
1576 free(vlan_tag, M_DEVBUF);
1583 bnxt_wol_config(if_ctx_t ctx)
1585 struct bnxt_softc *softc = iflib_get_softc(ctx);
1586 if_t ifp = iflib_get_ifp(ctx);
1591 if (!bnxt_wol_supported(softc))
1594 if (if_getcapabilities(ifp) & IFCAP_WOL_MAGIC) {
1596 if (bnxt_hwrm_alloc_wol_fltr(softc))
1602 if (bnxt_hwrm_free_wol_fltr(softc))
1612 bnxt_shutdown(if_ctx_t ctx)
1614 bnxt_wol_config(ctx);
1619 bnxt_suspend(if_ctx_t ctx)
1621 bnxt_wol_config(ctx);
1626 bnxt_resume(if_ctx_t ctx)
1628 struct bnxt_softc *softc = iflib_get_softc(ctx);
1630 bnxt_get_wol_settings(softc);
1635 bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data)
1637 struct bnxt_softc *softc = iflib_get_softc(ctx);
1638 struct ifreq *ifr = (struct ifreq *)data;
1639 struct ifreq_buffer *ifbuf = &ifr->ifr_ifru.ifru_buffer;
1640 struct bnxt_ioctl_header *ioh =
1641 (struct bnxt_ioctl_header *)(ifbuf->buffer);
1643 struct bnxt_ioctl_data *iod = NULL;
1646 case SIOCGPRIVATE_0:
1647 if ((rc = priv_check(curthread, PRIV_DRIVER)) != 0)
1650 iod = malloc(ifbuf->length, M_DEVBUF, M_NOWAIT | M_ZERO);
1655 copyin(ioh, iod, ifbuf->length);
1657 switch (ioh->type) {
1658 case BNXT_HWRM_NVM_FIND_DIR_ENTRY:
1660 struct bnxt_ioctl_hwrm_nvm_find_dir_entry *find =
1663 rc = bnxt_hwrm_nvm_find_dir_entry(softc, find->type,
1664 &find->ordinal, find->ext, &find->index,
1665 find->use_index, find->search_opt,
1666 &find->data_length, &find->item_length,
1670 copyout(&iod->hdr.rc, &ioh->rc,
1675 copyout(iod, ioh, ifbuf->length);
1681 case BNXT_HWRM_NVM_READ:
1683 struct bnxt_ioctl_hwrm_nvm_read *rd = &iod->read;
1684 struct iflib_dma_info dma_data;
1690 * Some HWRM versions can't read more than 0x8000 bytes
1692 rc = iflib_dma_alloc(softc->ctx,
1693 min(rd->length, 0x8000), &dma_data, BUS_DMA_NOWAIT);
1696 for (remain = rd->length, offset = 0;
1697 remain && offset < rd->length; offset += 0x8000) {
1698 csize = min(remain, 0x8000);
1699 rc = bnxt_hwrm_nvm_read(softc, rd->index,
1700 rd->offset + offset, csize, &dma_data);
1703 copyout(&iod->hdr.rc, &ioh->rc,
1708 copyout(dma_data.idi_vaddr,
1709 rd->data + offset, csize);
1714 if (iod->hdr.rc == 0)
1715 copyout(iod, ioh, ifbuf->length);
1717 iflib_dma_free(&dma_data);
1721 case BNXT_HWRM_FW_RESET:
1723 struct bnxt_ioctl_hwrm_fw_reset *rst =
1726 rc = bnxt_hwrm_fw_reset(softc, rst->processor,
1730 copyout(&iod->hdr.rc, &ioh->rc,
1735 copyout(iod, ioh, ifbuf->length);
1741 case BNXT_HWRM_FW_QSTATUS:
1743 struct bnxt_ioctl_hwrm_fw_qstatus *qstat =
1746 rc = bnxt_hwrm_fw_qstatus(softc, qstat->processor,
1750 copyout(&iod->hdr.rc, &ioh->rc,
1755 copyout(iod, ioh, ifbuf->length);
1761 case BNXT_HWRM_NVM_WRITE:
1763 struct bnxt_ioctl_hwrm_nvm_write *wr =
1766 rc = bnxt_hwrm_nvm_write(softc, wr->data, true,
1767 wr->type, wr->ordinal, wr->ext, wr->attr,
1768 wr->option, wr->data_length, wr->keep,
1769 &wr->item_length, &wr->index);
1772 copyout(&iod->hdr.rc, &ioh->rc,
1777 copyout(iod, ioh, ifbuf->length);
1783 case BNXT_HWRM_NVM_ERASE_DIR_ENTRY:
1785 struct bnxt_ioctl_hwrm_nvm_erase_dir_entry *erase =
1788 rc = bnxt_hwrm_nvm_erase_dir_entry(softc, erase->index);
1791 copyout(&iod->hdr.rc, &ioh->rc,
1796 copyout(iod, ioh, ifbuf->length);
1802 case BNXT_HWRM_NVM_GET_DIR_INFO:
1804 struct bnxt_ioctl_hwrm_nvm_get_dir_info *info =
1807 rc = bnxt_hwrm_nvm_get_dir_info(softc, &info->entries,
1808 &info->entry_length);
1811 copyout(&iod->hdr.rc, &ioh->rc,
1816 copyout(iod, ioh, ifbuf->length);
1822 case BNXT_HWRM_NVM_GET_DIR_ENTRIES:
1824 struct bnxt_ioctl_hwrm_nvm_get_dir_entries *get =
1826 struct iflib_dma_info dma_data;
1828 rc = iflib_dma_alloc(softc->ctx, get->max_size,
1829 &dma_data, BUS_DMA_NOWAIT);
1832 rc = bnxt_hwrm_nvm_get_dir_entries(softc, &get->entries,
1833 &get->entry_length, &dma_data);
1836 copyout(&iod->hdr.rc, &ioh->rc,
1840 copyout(dma_data.idi_vaddr, get->data,
1841 get->entry_length * get->entries);
1843 copyout(iod, ioh, ifbuf->length);
1845 iflib_dma_free(&dma_data);
1850 case BNXT_HWRM_NVM_VERIFY_UPDATE:
1852 struct bnxt_ioctl_hwrm_nvm_verify_update *vrfy =
1855 rc = bnxt_hwrm_nvm_verify_update(softc, vrfy->type,
1856 vrfy->ordinal, vrfy->ext);
1859 copyout(&iod->hdr.rc, &ioh->rc,
1864 copyout(iod, ioh, ifbuf->length);
1870 case BNXT_HWRM_NVM_INSTALL_UPDATE:
1872 struct bnxt_ioctl_hwrm_nvm_install_update *inst =
1875 rc = bnxt_hwrm_nvm_install_update(softc,
1876 inst->install_type, &inst->installed_items,
1877 &inst->result, &inst->problem_item,
1878 &inst->reset_required);
1881 copyout(&iod->hdr.rc, &ioh->rc,
1886 copyout(iod, ioh, ifbuf->length);
1892 case BNXT_HWRM_NVM_MODIFY:
1894 struct bnxt_ioctl_hwrm_nvm_modify *mod = &iod->modify;
1896 rc = bnxt_hwrm_nvm_modify(softc, mod->index,
1897 mod->offset, mod->data, true, mod->length);
1900 copyout(&iod->hdr.rc, &ioh->rc,
1905 copyout(iod, ioh, ifbuf->length);
1911 case BNXT_HWRM_FW_GET_TIME:
1913 struct bnxt_ioctl_hwrm_fw_get_time *gtm =
1916 rc = bnxt_hwrm_fw_get_time(softc, >m->year,
1917 >m->month, >m->day, >m->hour, >m->minute,
1918 >m->second, >m->millisecond, >m->zone);
1921 copyout(&iod->hdr.rc, &ioh->rc,
1926 copyout(iod, ioh, ifbuf->length);
1932 case BNXT_HWRM_FW_SET_TIME:
1934 struct bnxt_ioctl_hwrm_fw_set_time *stm =
1937 rc = bnxt_hwrm_fw_set_time(softc, stm->year,
1938 stm->month, stm->day, stm->hour, stm->minute,
1939 stm->second, stm->millisecond, stm->zone);
1942 copyout(&iod->hdr.rc, &ioh->rc,
1947 copyout(iod, ioh, ifbuf->length);
1959 free(iod, M_DEVBUF);
1967 bnxt_probe_phy(struct bnxt_softc *softc)
1969 struct bnxt_link_info *link_info = &softc->link_info;
1972 rc = bnxt_update_link(softc, false);
1974 device_printf(softc->dev,
1975 "Probe phy can't update link (rc: %x)\n", rc);
1979 /*initialize the ethool setting copy with NVM settings */
1980 if (link_info->auto_mode != HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_NONE)
1981 link_info->autoneg |= BNXT_AUTONEG_SPEED;
1983 link_info->req_duplex = link_info->duplex_setting;
1984 if (link_info->autoneg & BNXT_AUTONEG_SPEED)
1985 link_info->req_link_speed = link_info->auto_link_speed;
1987 link_info->req_link_speed = link_info->force_link_speed;
1992 bnxt_add_media_types(struct bnxt_softc *softc)
1994 struct bnxt_link_info *link_info = &softc->link_info;
1996 uint8_t phy_type = get_phy_type(softc);
1998 supported = link_info->support_speeds;
2000 /* Auto is always supported */
2001 ifmedia_add(softc->media, IFM_ETHER | IFM_AUTO, 0, NULL);
2003 if (softc->flags & BNXT_FLAG_NPAR)
2007 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASECR4:
2008 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_40G_BASECR4:
2009 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_25G_BASECR_CA_L:
2010 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_25G_BASECR_CA_S:
2011 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_25G_BASECR_CA_N:
2012 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASECR:
2013 BNXT_IFMEDIA_ADD(supported, SPEEDS_100GB, IFM_100G_CR4);
2014 BNXT_IFMEDIA_ADD(supported, SPEEDS_50GB, IFM_50G_CR2);
2015 BNXT_IFMEDIA_ADD(supported, SPEEDS_40GB, IFM_40G_CR4);
2016 BNXT_IFMEDIA_ADD(supported, SPEEDS_25GB, IFM_25G_CR);
2017 BNXT_IFMEDIA_ADD(supported, SPEEDS_10GB, IFM_10G_CR1);
2018 BNXT_IFMEDIA_ADD(supported, SPEEDS_1GB, IFM_1000_T);
2021 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASELR4:
2022 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_40G_BASELR4:
2023 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASELR:
2024 BNXT_IFMEDIA_ADD(supported, SPEEDS_100GB, IFM_100G_LR4);
2025 BNXT_IFMEDIA_ADD(supported, SPEEDS_40GB, IFM_40G_LR4);
2026 BNXT_IFMEDIA_ADD(supported, SPEEDS_25GB, IFM_25G_LR);
2027 BNXT_IFMEDIA_ADD(supported, SPEEDS_10GB, IFM_10G_LR);
2028 BNXT_IFMEDIA_ADD(supported, SPEEDS_1GB, IFM_1000_LX);
2031 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASESR10:
2032 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASESR4:
2033 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_40G_BASESR4:
2034 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASESR:
2035 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_40G_BASEER4:
2036 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASEER4:
2037 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_25G_BASESR:
2038 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_1G_BASESX:
2039 BNXT_IFMEDIA_ADD(supported, SPEEDS_100GB, IFM_100G_SR4);
2040 BNXT_IFMEDIA_ADD(supported, SPEEDS_40GB, IFM_40G_SR4);
2041 BNXT_IFMEDIA_ADD(supported, SPEEDS_25GB, IFM_25G_SR);
2042 BNXT_IFMEDIA_ADD(supported, SPEEDS_10GB, IFM_10G_SR);
2043 BNXT_IFMEDIA_ADD(supported, SPEEDS_1GB, IFM_1000_SX);
2046 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR4:
2047 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR2:
2048 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR:
2049 BNXT_IFMEDIA_ADD(supported, SPEEDS_100GB, IFM_100G_KR4);
2050 BNXT_IFMEDIA_ADD(supported, SPEEDS_50GB, IFM_50G_KR2);
2051 BNXT_IFMEDIA_ADD(supported, SPEEDS_40GB, IFM_40G_KR4);
2052 BNXT_IFMEDIA_ADD(supported, SPEEDS_25GB, IFM_25G_KR);
2053 BNXT_IFMEDIA_ADD(supported, SPEEDS_20GB, IFM_20G_KR2);
2054 BNXT_IFMEDIA_ADD(supported, SPEEDS_10GB, IFM_10G_KR);
2055 BNXT_IFMEDIA_ADD(supported, SPEEDS_1GB, IFM_1000_KX);
2058 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_40G_ACTIVE_CABLE:
2059 BNXT_IFMEDIA_ADD(supported, SPEEDS_25GB, IFM_25G_ACC);
2060 BNXT_IFMEDIA_ADD(supported, SPEEDS_10GB, IFM_10G_AOC);
2063 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_1G_BASECX:
2064 BNXT_IFMEDIA_ADD(supported, SPEEDS_1GBHD, IFM_1000_CX);
2067 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_1G_BASET:
2068 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASET:
2069 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASETE:
2070 BNXT_IFMEDIA_ADD(supported, SPEEDS_10GB, IFM_10G_T);
2071 BNXT_IFMEDIA_ADD(supported, SPEEDS_2_5GB, IFM_2500_T);
2072 BNXT_IFMEDIA_ADD(supported, SPEEDS_1GB, IFM_1000_T);
2073 BNXT_IFMEDIA_ADD(supported, SPEEDS_100MB, IFM_100_T);
2074 BNXT_IFMEDIA_ADD(supported, SPEEDS_10MB, IFM_10_T);
2077 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKX:
2078 BNXT_IFMEDIA_ADD(supported, SPEEDS_10GB, IFM_10G_KR);
2079 BNXT_IFMEDIA_ADD(supported, SPEEDS_2_5GB, IFM_2500_KX);
2080 BNXT_IFMEDIA_ADD(supported, SPEEDS_1GB, IFM_1000_KX);
2083 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_SGMIIEXTPHY:
2084 BNXT_IFMEDIA_ADD(supported, SPEEDS_1GB, IFM_1000_SGMII);
2087 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_UNKNOWN:
2088 /* Only Autoneg is supported for TYPE_UNKNOWN */
2089 device_printf(softc->dev, "Unknown phy type\n");
2093 /* Only Autoneg is supported for new phy type values */
2094 device_printf(softc->dev, "phy type %d not supported by driver\n", phy_type);
2102 bnxt_map_bar(struct bnxt_softc *softc, struct bnxt_bar_info *bar, int bar_num, bool shareable)
2106 if (bar->res != NULL) {
2107 device_printf(softc->dev, "Bar %d already mapped\n", bar_num);
2111 bar->rid = PCIR_BAR(bar_num);
2114 flag |= RF_SHAREABLE;
2117 bus_alloc_resource_any(softc->dev,
2121 device_printf(softc->dev,
2122 "PCI BAR%d mapping failure\n", bar_num);
2125 bar->tag = rman_get_bustag(bar->res);
2126 bar->handle = rman_get_bushandle(bar->res);
2127 bar->size = rman_get_size(bar->res);
2133 bnxt_pci_mapping(struct bnxt_softc *softc)
2137 rc = bnxt_map_bar(softc, &softc->hwrm_bar, 0, true);
2141 rc = bnxt_map_bar(softc, &softc->doorbell_bar, 2, false);
2147 bnxt_pci_mapping_free(struct bnxt_softc *softc)
2149 if (softc->hwrm_bar.res != NULL)
2150 bus_release_resource(softc->dev, SYS_RES_MEMORY,
2151 softc->hwrm_bar.rid, softc->hwrm_bar.res);
2152 softc->hwrm_bar.res = NULL;
2154 if (softc->doorbell_bar.res != NULL)
2155 bus_release_resource(softc->dev, SYS_RES_MEMORY,
2156 softc->doorbell_bar.rid, softc->doorbell_bar.res);
2157 softc->doorbell_bar.res = NULL;
2161 bnxt_update_link(struct bnxt_softc *softc, bool chng_link_state)
2163 struct bnxt_link_info *link_info = &softc->link_info;
2164 uint8_t link_up = link_info->link_up;
2167 rc = bnxt_hwrm_port_phy_qcfg(softc);
2171 /* TODO: need to add more logic to report VF link */
2172 if (chng_link_state) {
2173 if (link_info->phy_link_status ==
2174 HWRM_PORT_PHY_QCFG_OUTPUT_LINK_LINK)
2175 link_info->link_up = 1;
2177 link_info->link_up = 0;
2178 if (link_up != link_info->link_up)
2179 bnxt_report_link(softc);
2181 /* always link down if not require to update link state */
2182 link_info->link_up = 0;
2190 bnxt_report_link(struct bnxt_softc *softc)
2192 struct bnxt_link_info *link_info = &softc->link_info;
2193 const char *duplex = NULL, *flow_ctrl = NULL;
2195 if (link_info->link_up == link_info->last_link_up) {
2196 if (!link_info->link_up)
2198 if ((link_info->duplex == link_info->last_duplex) &&
2199 (!(BNXT_IS_FLOW_CTRL_CHANGED(link_info))))
2203 if (link_info->link_up) {
2204 if (link_info->duplex ==
2205 HWRM_PORT_PHY_QCFG_OUTPUT_DUPLEX_CFG_FULL)
2206 duplex = "full duplex";
2208 duplex = "half duplex";
2209 if (link_info->flow_ctrl.tx & link_info->flow_ctrl.rx)
2210 flow_ctrl = "FC - receive & transmit";
2211 else if (link_info->flow_ctrl.tx)
2212 flow_ctrl = "FC - transmit";
2213 else if (link_info->flow_ctrl.rx)
2214 flow_ctrl = "FC - receive";
2216 flow_ctrl = "FC - none";
2217 iflib_link_state_change(softc->ctx, LINK_STATE_UP,
2219 device_printf(softc->dev, "Link is UP %s, %s - %d Mbps \n", duplex,
2220 flow_ctrl, (link_info->link_speed * 100));
2222 iflib_link_state_change(softc->ctx, LINK_STATE_DOWN,
2223 bnxt_get_baudrate(&softc->link_info));
2224 device_printf(softc->dev, "Link is Down\n");
2227 link_info->last_link_up = link_info->link_up;
2228 link_info->last_duplex = link_info->duplex;
2229 link_info->last_flow_ctrl.tx = link_info->flow_ctrl.tx;
2230 link_info->last_flow_ctrl.rx = link_info->flow_ctrl.rx;
2231 link_info->last_flow_ctrl.autoneg = link_info->flow_ctrl.autoneg;
2232 /* update media types */
2233 ifmedia_removeall(softc->media);
2234 bnxt_add_media_types(softc);
2235 ifmedia_set(softc->media, IFM_ETHER | IFM_AUTO);
2239 bnxt_handle_rx_cp(void *arg)
2241 struct bnxt_cp_ring *cpr = arg;
2243 /* Disable further interrupts for this queue */
2244 BNXT_CP_DISABLE_DB(&cpr->ring);
2245 return FILTER_SCHEDULE_THREAD;
2249 bnxt_handle_def_cp(void *arg)
2251 struct bnxt_softc *softc = arg;
2253 BNXT_CP_DISABLE_DB(&softc->def_cp_ring.ring);
2254 GROUPTASK_ENQUEUE(&softc->def_cp_task);
2255 return FILTER_HANDLED;
2259 bnxt_clear_ids(struct bnxt_softc *softc)
2263 softc->def_cp_ring.stats_ctx_id = HWRM_NA_SIGNATURE;
2264 softc->def_cp_ring.ring.phys_id = (uint16_t)HWRM_NA_SIGNATURE;
2265 for (i = 0; i < softc->ntxqsets; i++) {
2266 softc->tx_cp_rings[i].stats_ctx_id = HWRM_NA_SIGNATURE;
2267 softc->tx_cp_rings[i].ring.phys_id =
2268 (uint16_t)HWRM_NA_SIGNATURE;
2269 softc->tx_rings[i].phys_id = (uint16_t)HWRM_NA_SIGNATURE;
2271 for (i = 0; i < softc->nrxqsets; i++) {
2272 softc->rx_cp_rings[i].stats_ctx_id = HWRM_NA_SIGNATURE;
2273 softc->rx_cp_rings[i].ring.phys_id =
2274 (uint16_t)HWRM_NA_SIGNATURE;
2275 softc->rx_rings[i].phys_id = (uint16_t)HWRM_NA_SIGNATURE;
2276 softc->ag_rings[i].phys_id = (uint16_t)HWRM_NA_SIGNATURE;
2277 softc->grp_info[i].grp_id = (uint16_t)HWRM_NA_SIGNATURE;
2279 softc->vnic_info.filter_id = -1;
2280 softc->vnic_info.id = (uint16_t)HWRM_NA_SIGNATURE;
2281 softc->vnic_info.rss_id = (uint16_t)HWRM_NA_SIGNATURE;
2282 memset(softc->vnic_info.rss_grp_tbl.idi_vaddr, 0xff,
2283 softc->vnic_info.rss_grp_tbl.idi_size);
2287 bnxt_mark_cpr_invalid(struct bnxt_cp_ring *cpr)
2289 struct cmpl_base *cmp = (void *)cpr->ring.vaddr;
2292 for (i = 0; i < cpr->ring.ring_size; i++)
2293 cmp[i].info3_v = !cpr->v_bit;
2297 bnxt_handle_async_event(struct bnxt_softc *softc, struct cmpl_base *cmpl)
2299 struct hwrm_async_event_cmpl *ae = (void *)cmpl;
2300 uint16_t async_id = le16toh(ae->event_id);
2301 struct ifmediareq ifmr;
2304 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE:
2305 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CHANGE:
2306 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE:
2307 bnxt_media_status(softc->ctx, &ifmr);
2309 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_MTU_CHANGE:
2310 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DCB_CONFIG_CHANGE:
2311 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED:
2312 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_NOT_ALLOWED:
2313 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_FUNC_DRVR_UNLOAD:
2314 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_FUNC_DRVR_LOAD:
2315 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD:
2316 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_LOAD:
2317 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_FLR:
2318 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_MAC_ADDR_CHANGE:
2319 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_VF_COMM_STATUS_CHANGE:
2320 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_CFG_CHANGE:
2321 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_HWRM_ERROR:
2322 device_printf(softc->dev,
2323 "Unhandled async completion type %u\n", async_id);
2326 device_printf(softc->dev,
2327 "Unknown async completion type %u\n", async_id);
2333 bnxt_def_cp_task(void *context)
2335 if_ctx_t ctx = context;
2336 struct bnxt_softc *softc = iflib_get_softc(ctx);
2337 struct bnxt_cp_ring *cpr = &softc->def_cp_ring;
2339 /* Handle completions on the default completion ring */
2340 struct cmpl_base *cmpl;
2341 uint32_t cons = cpr->cons;
2342 bool v_bit = cpr->v_bit;
2350 NEXT_CP_CONS_V(&cpr->ring, cons, v_bit);
2351 cmpl = &((struct cmpl_base *)cpr->ring.vaddr)[cons];
2353 if (!CMP_VALID(cmpl, v_bit))
2356 type = le16toh(cmpl->type) & CMPL_BASE_TYPE_MASK;
2358 case CMPL_BASE_TYPE_HWRM_ASYNC_EVENT:
2359 bnxt_handle_async_event(softc, cmpl);
2361 case CMPL_BASE_TYPE_TX_L2:
2362 case CMPL_BASE_TYPE_RX_L2:
2363 case CMPL_BASE_TYPE_RX_AGG:
2364 case CMPL_BASE_TYPE_RX_TPA_START:
2365 case CMPL_BASE_TYPE_RX_TPA_END:
2366 case CMPL_BASE_TYPE_STAT_EJECT:
2367 case CMPL_BASE_TYPE_HWRM_DONE:
2368 case CMPL_BASE_TYPE_HWRM_FWD_REQ:
2369 case CMPL_BASE_TYPE_HWRM_FWD_RESP:
2370 case CMPL_BASE_TYPE_CQ_NOTIFICATION:
2371 case CMPL_BASE_TYPE_SRQ_EVENT:
2372 case CMPL_BASE_TYPE_DBQ_EVENT:
2373 case CMPL_BASE_TYPE_QP_EVENT:
2374 case CMPL_BASE_TYPE_FUNC_EVENT:
2375 device_printf(softc->dev,
2376 "Unhandled completion type %u\n", type);
2379 device_printf(softc->dev,
2380 "Unknown completion type %u\n", type);
2385 cpr->cons = last_cons;
2386 cpr->v_bit = last_v_bit;
2387 BNXT_CP_IDX_ENABLE_DB(&cpr->ring, cpr->cons);
2391 get_phy_type(struct bnxt_softc *softc)
2393 struct bnxt_link_info *link_info = &softc->link_info;
2394 uint8_t phy_type = link_info->phy_type;
2397 if (phy_type != HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_UNKNOWN)
2400 /* Deduce the phy type from the media type and supported speeds */
2401 supported = link_info->support_speeds;
2403 if (link_info->media_type ==
2404 HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_TP)
2405 return HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASET;
2406 if (link_info->media_type ==
2407 HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_DAC) {
2408 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_2_5GB)
2409 return HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKX;
2410 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_20GB)
2411 return HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR;
2412 return HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASECR;
2414 if (link_info->media_type ==
2415 HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_FIBRE)
2416 return HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASESR;
2422 bnxt_check_hwrm_version(struct bnxt_softc *softc)
2426 sprintf(buf, "%hhu.%hhu.%hhu", softc->ver_info->hwrm_min_major,
2427 softc->ver_info->hwrm_min_minor, softc->ver_info->hwrm_min_update);
2428 if (softc->ver_info->hwrm_min_major > softc->ver_info->hwrm_if_major) {
2429 device_printf(softc->dev,
2430 "WARNING: HWRM version %s is too old (older than %s)\n",
2431 softc->ver_info->hwrm_if_ver, buf);
2434 else if(softc->ver_info->hwrm_min_major ==
2435 softc->ver_info->hwrm_if_major) {
2436 if (softc->ver_info->hwrm_min_minor >
2437 softc->ver_info->hwrm_if_minor) {
2438 device_printf(softc->dev,
2439 "WARNING: HWRM version %s is too old (older than %s)\n",
2440 softc->ver_info->hwrm_if_ver, buf);
2443 else if (softc->ver_info->hwrm_min_minor ==
2444 softc->ver_info->hwrm_if_minor) {
2445 if (softc->ver_info->hwrm_min_update >
2446 softc->ver_info->hwrm_if_update) {
2447 device_printf(softc->dev,
2448 "WARNING: HWRM version %s is too old (older than %s)\n",
2449 softc->ver_info->hwrm_if_ver, buf);
2458 bnxt_get_baudrate(struct bnxt_link_info *link)
2460 switch (link->link_speed) {
2461 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100MB:
2462 return IF_Mbps(100);
2463 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_1GB:
2465 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2GB:
2467 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2_5GB:
2468 return IF_Mbps(2500);
2469 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_10GB:
2471 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_20GB:
2473 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_25GB:
2475 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_40GB:
2477 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_50GB:
2479 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100GB:
2480 return IF_Gbps(100);
2481 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_10MB:
2484 return IF_Gbps(100);
2488 bnxt_get_wol_settings(struct bnxt_softc *softc)
2490 uint16_t wol_handle = 0;
2492 if (!bnxt_wol_supported(softc))
2496 wol_handle = bnxt_hwrm_get_wol_fltrs(softc, wol_handle);
2497 } while (wol_handle && wol_handle != BNXT_NO_MORE_WOL_FILTERS);