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);
180 /* Interrupt enable / disable */
181 static void bnxt_intr_enable(if_ctx_t ctx);
182 static int bnxt_rx_queue_intr_enable(if_ctx_t ctx, uint16_t qid);
183 static int bnxt_tx_queue_intr_enable(if_ctx_t ctx, uint16_t qid);
184 static void bnxt_disable_intr(if_ctx_t ctx);
185 static int bnxt_msix_intr_assign(if_ctx_t ctx, int msix);
188 static void bnxt_vlan_register(if_ctx_t ctx, uint16_t vtag);
189 static void bnxt_vlan_unregister(if_ctx_t ctx, uint16_t vtag);
192 static int bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data);
194 static int bnxt_shutdown(if_ctx_t ctx);
195 static int bnxt_suspend(if_ctx_t ctx);
196 static int bnxt_resume(if_ctx_t ctx);
198 /* Internal support functions */
199 static int bnxt_probe_phy(struct bnxt_softc *softc);
200 static void bnxt_add_media_types(struct bnxt_softc *softc);
201 static int bnxt_pci_mapping(struct bnxt_softc *softc);
202 static void bnxt_pci_mapping_free(struct bnxt_softc *softc);
203 static int bnxt_update_link(struct bnxt_softc *softc, bool chng_link_state);
204 static int bnxt_handle_def_cp(void *arg);
205 static int bnxt_handle_rx_cp(void *arg);
206 static void bnxt_clear_ids(struct bnxt_softc *softc);
207 static void inline bnxt_do_enable_intr(struct bnxt_cp_ring *cpr);
208 static void inline bnxt_do_disable_intr(struct bnxt_cp_ring *cpr);
209 static void bnxt_mark_cpr_invalid(struct bnxt_cp_ring *cpr);
210 static void bnxt_def_cp_task(void *context);
211 static void bnxt_handle_async_event(struct bnxt_softc *softc,
212 struct cmpl_base *cmpl);
213 static uint8_t get_phy_type(struct bnxt_softc *softc);
214 static uint64_t bnxt_get_baudrate(struct bnxt_link_info *link);
215 static void bnxt_get_wol_settings(struct bnxt_softc *softc);
216 static int bnxt_wol_config(if_ctx_t ctx);
219 * Device Interface Declaration
222 static device_method_t bnxt_methods[] = {
223 /* Device interface */
224 DEVMETHOD(device_register, bnxt_register),
225 DEVMETHOD(device_probe, iflib_device_probe),
226 DEVMETHOD(device_attach, iflib_device_attach),
227 DEVMETHOD(device_detach, iflib_device_detach),
228 DEVMETHOD(device_shutdown, iflib_device_shutdown),
229 DEVMETHOD(device_suspend, iflib_device_suspend),
230 DEVMETHOD(device_resume, iflib_device_resume),
234 static driver_t bnxt_driver = {
235 "bnxt", bnxt_methods, sizeof(struct bnxt_softc),
238 devclass_t bnxt_devclass;
239 DRIVER_MODULE(bnxt, pci, bnxt_driver, bnxt_devclass, 0, 0);
241 MODULE_DEPEND(bnxt, pci, 1, 1, 1);
242 MODULE_DEPEND(bnxt, ether, 1, 1, 1);
243 MODULE_DEPEND(bnxt, iflib, 1, 1, 1);
245 static device_method_t bnxt_iflib_methods[] = {
246 DEVMETHOD(ifdi_tx_queues_alloc, bnxt_tx_queues_alloc),
247 DEVMETHOD(ifdi_rx_queues_alloc, bnxt_rx_queues_alloc),
248 DEVMETHOD(ifdi_queues_free, bnxt_queues_free),
250 DEVMETHOD(ifdi_attach_pre, bnxt_attach_pre),
251 DEVMETHOD(ifdi_attach_post, bnxt_attach_post),
252 DEVMETHOD(ifdi_detach, bnxt_detach),
254 DEVMETHOD(ifdi_init, bnxt_init),
255 DEVMETHOD(ifdi_stop, bnxt_stop),
256 DEVMETHOD(ifdi_multi_set, bnxt_multi_set),
257 DEVMETHOD(ifdi_mtu_set, bnxt_mtu_set),
258 DEVMETHOD(ifdi_media_status, bnxt_media_status),
259 DEVMETHOD(ifdi_media_change, bnxt_media_change),
260 DEVMETHOD(ifdi_promisc_set, bnxt_promisc_set),
261 DEVMETHOD(ifdi_get_counter, bnxt_get_counter),
262 DEVMETHOD(ifdi_update_admin_status, bnxt_update_admin_status),
264 DEVMETHOD(ifdi_intr_enable, bnxt_intr_enable),
265 DEVMETHOD(ifdi_tx_queue_intr_enable, bnxt_tx_queue_intr_enable),
266 DEVMETHOD(ifdi_rx_queue_intr_enable, bnxt_rx_queue_intr_enable),
267 DEVMETHOD(ifdi_intr_disable, bnxt_disable_intr),
268 DEVMETHOD(ifdi_msix_intr_assign, bnxt_msix_intr_assign),
270 DEVMETHOD(ifdi_vlan_register, bnxt_vlan_register),
271 DEVMETHOD(ifdi_vlan_unregister, bnxt_vlan_unregister),
273 DEVMETHOD(ifdi_priv_ioctl, bnxt_priv_ioctl),
275 DEVMETHOD(ifdi_suspend, bnxt_suspend),
276 DEVMETHOD(ifdi_shutdown, bnxt_shutdown),
277 DEVMETHOD(ifdi_resume, bnxt_resume),
282 static driver_t bnxt_iflib_driver = {
283 "bnxt", bnxt_iflib_methods, sizeof(struct bnxt_softc)
287 * iflib shared context
290 #define BNXT_DRIVER_VERSION "1.0.0.0"
291 char bnxt_driver_version[] = BNXT_DRIVER_VERSION;
292 extern struct if_txrx bnxt_txrx;
293 static struct if_shared_ctx bnxt_sctx_init = {
294 .isc_magic = IFLIB_MAGIC,
295 .isc_driver = &bnxt_iflib_driver,
296 .isc_nfl = 2, // Number of Free Lists
297 .isc_flags = IFLIB_HAS_RXCQ | IFLIB_HAS_TXCQ,
298 .isc_q_align = PAGE_SIZE,
299 .isc_tx_maxsize = BNXT_TSO_SIZE,
300 .isc_tx_maxsegsize = BNXT_TSO_SIZE,
301 .isc_rx_maxsize = BNXT_TSO_SIZE,
302 .isc_rx_maxsegsize = BNXT_TSO_SIZE,
304 // Only use a single segment to avoid page size constraints
305 .isc_rx_nsegments = 1,
308 .isc_nrxd_min = {16, 16, 16},
309 .isc_nrxd_default = {PAGE_SIZE / sizeof(struct cmpl_base) * 8,
310 PAGE_SIZE / sizeof(struct rx_prod_pkt_bd),
311 PAGE_SIZE / sizeof(struct rx_prod_pkt_bd)},
312 .isc_nrxd_max = {INT32_MAX, INT32_MAX, INT32_MAX},
313 .isc_ntxd_min = {16, 16, 16},
314 .isc_ntxd_default = {PAGE_SIZE / sizeof(struct cmpl_base) * 2,
315 PAGE_SIZE / sizeof(struct tx_bd_short)},
316 .isc_ntxd_max = {INT32_MAX, INT32_MAX, INT32_MAX},
318 .isc_admin_intrcnt = 1,
319 .isc_vendor_info = bnxt_vendor_info_array,
320 .isc_driver_version = bnxt_driver_version,
323 if_shared_ctx_t bnxt_sctx = &bnxt_sctx_init;
330 bnxt_register(device_t dev)
336 * Device Dependent Configuration Functions
339 /* Soft queue setup and teardown */
341 bnxt_tx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs,
342 uint64_t *paddrs, int ntxqs, int ntxqsets)
344 struct bnxt_softc *softc;
348 softc = iflib_get_softc(ctx);
350 softc->tx_cp_rings = malloc(sizeof(struct bnxt_cp_ring) * ntxqsets,
351 M_DEVBUF, M_NOWAIT | M_ZERO);
352 if (!softc->tx_cp_rings) {
353 device_printf(iflib_get_dev(ctx),
354 "unable to allocate TX completion rings\n");
358 softc->tx_rings = malloc(sizeof(struct bnxt_ring) * ntxqsets,
359 M_DEVBUF, M_NOWAIT | M_ZERO);
360 if (!softc->tx_rings) {
361 device_printf(iflib_get_dev(ctx),
362 "unable to allocate TX rings\n");
364 goto ring_alloc_fail;
366 rc = iflib_dma_alloc(ctx, sizeof(struct ctx_hw_stats) * ntxqsets,
367 &softc->tx_stats, 0);
370 bus_dmamap_sync(softc->tx_stats.idi_tag, softc->tx_stats.idi_map,
371 BUS_DMASYNC_PREREAD);
373 for (i = 0; i < ntxqsets; i++) {
374 /* Set up the completion ring */
375 softc->tx_cp_rings[i].stats_ctx_id = HWRM_NA_SIGNATURE;
376 softc->tx_cp_rings[i].ring.phys_id =
377 (uint16_t)HWRM_NA_SIGNATURE;
378 softc->tx_cp_rings[i].ring.softc = softc;
379 softc->tx_cp_rings[i].ring.id =
380 (softc->scctx->isc_nrxqsets * 2) + 1 + i;
381 softc->tx_cp_rings[i].ring.doorbell =
382 softc->tx_cp_rings[i].ring.id * 0x80;
383 softc->tx_cp_rings[i].ring.ring_size =
384 softc->scctx->isc_ntxd[0];
385 softc->tx_cp_rings[i].ring.vaddr = vaddrs[i * ntxqs];
386 softc->tx_cp_rings[i].ring.paddr = paddrs[i * ntxqs];
388 /* Set up the TX ring */
389 softc->tx_rings[i].phys_id = (uint16_t)HWRM_NA_SIGNATURE;
390 softc->tx_rings[i].softc = softc;
391 softc->tx_rings[i].id =
392 (softc->scctx->isc_nrxqsets * 2) + 1 + i;
393 softc->tx_rings[i].doorbell = softc->tx_rings[i].id * 0x80;
394 softc->tx_rings[i].ring_size = softc->scctx->isc_ntxd[1];
395 softc->tx_rings[i].vaddr = vaddrs[i * ntxqs + 1];
396 softc->tx_rings[i].paddr = paddrs[i * ntxqs + 1];
398 bnxt_create_tx_sysctls(softc, i);
401 softc->ntxqsets = ntxqsets;
405 free(softc->tx_rings, M_DEVBUF);
407 free(softc->tx_cp_rings, M_DEVBUF);
413 bnxt_queues_free(if_ctx_t ctx)
415 struct bnxt_softc *softc = iflib_get_softc(ctx);
418 iflib_dma_free(&softc->tx_stats);
419 free(softc->tx_rings, M_DEVBUF);
420 softc->tx_rings = NULL;
421 free(softc->tx_cp_rings, M_DEVBUF);
422 softc->tx_cp_rings = NULL;
426 iflib_dma_free(&softc->rx_stats);
427 free(softc->grp_info, M_DEVBUF);
428 free(softc->ag_rings, M_DEVBUF);
429 free(softc->rx_rings, M_DEVBUF);
430 free(softc->rx_cp_rings, M_DEVBUF);
434 bnxt_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs,
435 uint64_t *paddrs, int nrxqs, int nrxqsets)
437 struct bnxt_softc *softc;
441 softc = iflib_get_softc(ctx);
443 softc->rx_cp_rings = malloc(sizeof(struct bnxt_cp_ring) * nrxqsets,
444 M_DEVBUF, M_NOWAIT | M_ZERO);
445 if (!softc->rx_cp_rings) {
446 device_printf(iflib_get_dev(ctx),
447 "unable to allocate RX completion rings\n");
451 softc->rx_rings = malloc(sizeof(struct bnxt_ring) * nrxqsets,
452 M_DEVBUF, M_NOWAIT | M_ZERO);
453 if (!softc->rx_rings) {
454 device_printf(iflib_get_dev(ctx),
455 "unable to allocate RX rings\n");
457 goto ring_alloc_fail;
459 softc->ag_rings = malloc(sizeof(struct bnxt_ring) * nrxqsets,
460 M_DEVBUF, M_NOWAIT | M_ZERO);
461 if (!softc->ag_rings) {
462 device_printf(iflib_get_dev(ctx),
463 "unable to allocate aggregation rings\n");
467 softc->grp_info = malloc(sizeof(struct bnxt_grp_info) * nrxqsets,
468 M_DEVBUF, M_NOWAIT | M_ZERO);
469 if (!softc->grp_info) {
470 device_printf(iflib_get_dev(ctx),
471 "unable to allocate ring groups\n");
476 rc = iflib_dma_alloc(ctx, sizeof(struct ctx_hw_stats) * nrxqsets,
477 &softc->rx_stats, 0);
479 goto hw_stats_alloc_fail;
480 bus_dmamap_sync(softc->rx_stats.idi_tag, softc->rx_stats.idi_map,
481 BUS_DMASYNC_PREREAD);
483 for (i = 0; i < nrxqsets; i++) {
484 /* Allocation the completion ring */
485 softc->rx_cp_rings[i].stats_ctx_id = HWRM_NA_SIGNATURE;
486 softc->rx_cp_rings[i].ring.phys_id =
487 (uint16_t)HWRM_NA_SIGNATURE;
488 softc->rx_cp_rings[i].ring.softc = softc;
489 softc->rx_cp_rings[i].ring.id = i + 1;
490 softc->rx_cp_rings[i].ring.doorbell =
491 softc->rx_cp_rings[i].ring.id * 0x80;
493 * If this ring overflows, RX stops working.
495 softc->rx_cp_rings[i].ring.ring_size =
496 softc->scctx->isc_nrxd[0];
497 softc->rx_cp_rings[i].ring.vaddr = vaddrs[i * nrxqs];
498 softc->rx_cp_rings[i].ring.paddr = paddrs[i * nrxqs];
500 /* Allocate the RX ring */
501 softc->rx_rings[i].phys_id = (uint16_t)HWRM_NA_SIGNATURE;
502 softc->rx_rings[i].softc = softc;
503 softc->rx_rings[i].id = i + 1;
504 softc->rx_rings[i].doorbell = softc->rx_rings[i].id * 0x80;
505 softc->rx_rings[i].ring_size = softc->scctx->isc_nrxd[1];
506 softc->rx_rings[i].vaddr = vaddrs[i * nrxqs + 1];
507 softc->rx_rings[i].paddr = paddrs[i * nrxqs + 1];
509 /* Allocate the AG ring */
510 softc->ag_rings[i].phys_id = (uint16_t)HWRM_NA_SIGNATURE;
511 softc->ag_rings[i].softc = softc;
512 softc->ag_rings[i].id = nrxqsets + i + 1;
513 softc->ag_rings[i].doorbell = softc->ag_rings[i].id * 0x80;
514 softc->ag_rings[i].ring_size = softc->scctx->isc_nrxd[2];
515 softc->ag_rings[i].vaddr = vaddrs[i * nrxqs + 2];
516 softc->ag_rings[i].paddr = paddrs[i * nrxqs + 2];
518 /* Allocate the ring group */
519 softc->grp_info[i].grp_id = (uint16_t)HWRM_NA_SIGNATURE;
520 softc->grp_info[i].stats_ctx =
521 softc->rx_cp_rings[i].stats_ctx_id;
522 softc->grp_info[i].rx_ring_id = softc->rx_rings[i].phys_id;
523 softc->grp_info[i].ag_ring_id = softc->ag_rings[i].phys_id;
524 softc->grp_info[i].cp_ring_id =
525 softc->rx_cp_rings[i].ring.phys_id;
527 bnxt_create_rx_sysctls(softc, i);
530 /* And finally, the VNIC */
531 softc->vnic_info.id = (uint16_t)HWRM_NA_SIGNATURE;
532 softc->vnic_info.flow_id = (uint16_t)HWRM_NA_SIGNATURE;
533 softc->vnic_info.filter_id = -1;
534 softc->vnic_info.def_ring_grp = (uint16_t)HWRM_NA_SIGNATURE;
535 softc->vnic_info.cos_rule = (uint16_t)HWRM_NA_SIGNATURE;
536 softc->vnic_info.lb_rule = (uint16_t)HWRM_NA_SIGNATURE;
537 softc->vnic_info.rx_mask = HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_BCAST;
538 softc->vnic_info.mc_list_count = 0;
539 softc->vnic_info.flags = BNXT_VNIC_FLAG_DEFAULT;
540 rc = iflib_dma_alloc(ctx, BNXT_MAX_MC_ADDRS * ETHER_ADDR_LEN,
541 &softc->vnic_info.mc_list, 0);
543 goto mc_list_alloc_fail;
545 /* The VNIC RSS Hash Key */
546 rc = iflib_dma_alloc(ctx, HW_HASH_KEY_SIZE,
547 &softc->vnic_info.rss_hash_key_tbl, 0);
549 goto rss_hash_alloc_fail;
550 bus_dmamap_sync(softc->vnic_info.rss_hash_key_tbl.idi_tag,
551 softc->vnic_info.rss_hash_key_tbl.idi_map,
552 BUS_DMASYNC_PREWRITE);
553 memcpy(softc->vnic_info.rss_hash_key_tbl.idi_vaddr,
554 softc->vnic_info.rss_hash_key, HW_HASH_KEY_SIZE);
556 /* Allocate the RSS tables */
557 rc = iflib_dma_alloc(ctx, HW_HASH_INDEX_SIZE * sizeof(uint16_t),
558 &softc->vnic_info.rss_grp_tbl, 0);
560 goto rss_grp_alloc_fail;
561 bus_dmamap_sync(softc->vnic_info.rss_grp_tbl.idi_tag,
562 softc->vnic_info.rss_grp_tbl.idi_map,
563 BUS_DMASYNC_PREWRITE);
564 memset(softc->vnic_info.rss_grp_tbl.idi_vaddr, 0xff,
565 softc->vnic_info.rss_grp_tbl.idi_size);
567 softc->nrxqsets = nrxqsets;
571 iflib_dma_free(&softc->vnic_info.rss_hash_key_tbl);
573 iflib_dma_free(&softc->vnic_info.mc_list);
575 iflib_dma_free(&softc->rx_stats);
577 free(softc->grp_info, M_DEVBUF);
579 free(softc->ag_rings, M_DEVBUF);
581 free(softc->rx_rings, M_DEVBUF);
583 free(softc->rx_cp_rings, M_DEVBUF);
588 /* Device setup and teardown */
590 bnxt_attach_pre(if_ctx_t ctx)
592 struct bnxt_softc *softc = iflib_get_softc(ctx);
593 if_softc_ctx_t scctx;
597 softc->dev = iflib_get_dev(ctx);
598 softc->media = iflib_get_media(ctx);
599 softc->scctx = iflib_get_softc_ctx(ctx);
600 softc->sctx = iflib_get_sctx(ctx);
601 scctx = softc->scctx;
603 /* TODO: Better way of detecting NPAR/VF is needed */
604 switch (softc->sctx->isc_vendor_info->pvi_device_id) {
615 softc->flags |= BNXT_FLAG_NPAR;
617 case NETXTREME_C_VF1:
618 case NETXTREME_C_VF2:
619 case NETXTREME_C_VF3:
620 case NETXTREME_E_VF1:
621 case NETXTREME_E_VF2:
622 case NETXTREME_E_VF3:
623 softc->flags |= BNXT_FLAG_VF;
627 pci_enable_busmaster(softc->dev);
629 if (bnxt_pci_mapping(softc))
632 /* HWRM setup/init */
633 BNXT_HWRM_LOCK_INIT(softc, device_get_nameunit(softc->dev));
634 rc = bnxt_alloc_hwrm_dma_mem(softc);
638 /* Allocate the TPA start buffer */
639 softc->tpa_start = malloc(sizeof(struct bnxt_full_tpa_start) *
640 (RX_TPA_START_CMPL_AGG_ID_MASK >> RX_TPA_START_CMPL_AGG_ID_SFT),
641 M_DEVBUF, M_NOWAIT | M_ZERO);
642 if (softc->tpa_start == NULL) {
644 device_printf(softc->dev,
645 "Unable to allocate space for TPA\n");
649 /* Get firmware version and compare with driver */
650 softc->ver_info = malloc(sizeof(struct bnxt_ver_info),
651 M_DEVBUF, M_NOWAIT | M_ZERO);
652 if (softc->ver_info == NULL) {
654 device_printf(softc->dev,
655 "Unable to allocate space for version info\n");
658 /* Default minimum required HWRM version */
659 softc->ver_info->hwrm_min_major = 1;
660 softc->ver_info->hwrm_min_minor = 2;
661 softc->ver_info->hwrm_min_update = 2;
663 rc = bnxt_hwrm_ver_get(softc);
665 device_printf(softc->dev, "attach: hwrm ver get failed\n");
670 softc->nvm_info = malloc(sizeof(struct bnxt_nvram_info),
671 M_DEVBUF, M_NOWAIT | M_ZERO);
672 if (softc->nvm_info == NULL) {
674 device_printf(softc->dev,
675 "Unable to allocate space for NVRAM info\n");
678 rc = bnxt_hwrm_nvm_get_dev_info(softc, &softc->nvm_info->mfg_id,
679 &softc->nvm_info->device_id, &softc->nvm_info->sector_size,
680 &softc->nvm_info->size, &softc->nvm_info->reserved_size,
681 &softc->nvm_info->available_size);
683 /* Register the driver with the FW */
684 rc = bnxt_hwrm_func_drv_rgtr(softc);
686 device_printf(softc->dev, "attach: hwrm drv rgtr failed\n");
690 /* Get the HW capabilities */
691 rc = bnxt_hwrm_func_qcaps(softc);
695 iflib_set_mac(ctx, softc->func.mac_addr);
697 scctx->isc_txrx = &bnxt_txrx;
698 scctx->isc_tx_csum_flags = (CSUM_IP | CSUM_TCP | CSUM_UDP |
699 CSUM_TCP_IPV6 | CSUM_UDP_IPV6 | CSUM_TSO);
700 scctx->isc_capenable =
701 /* These are translated to hwassit bits */
702 IFCAP_TXCSUM | IFCAP_TXCSUM_IPV6 | IFCAP_TSO4 | IFCAP_TSO6 |
703 /* These are checked by iflib */
704 IFCAP_LRO | IFCAP_VLAN_HWFILTER |
705 /* These are part of the iflib mask */
706 IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6 | IFCAP_VLAN_MTU |
707 IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_HWTSO |
708 /* These likely get lost... */
709 IFCAP_VLAN_HWCSUM | IFCAP_JUMBO_MTU;
711 if (bnxt_wol_supported(softc))
712 scctx->isc_capenable |= IFCAP_WOL_MAGIC;
714 /* Get the queue config */
715 rc = bnxt_hwrm_queue_qportcfg(softc);
717 device_printf(softc->dev, "attach: hwrm qportcfg failed\n");
721 bnxt_get_wol_settings(softc);
723 /* Now perform a function reset */
724 rc = bnxt_hwrm_func_reset(softc);
725 bnxt_clear_ids(softc);
729 /* Now set up iflib sc */
730 scctx->isc_tx_nsegments = 31,
731 scctx->isc_tx_tso_segments_max = 31;
732 scctx->isc_tx_tso_size_max = BNXT_TSO_SIZE;
733 scctx->isc_tx_tso_segsize_max = BNXT_TSO_SIZE;
734 scctx->isc_vectors = softc->func.max_cp_rings;
735 scctx->isc_txrx = &bnxt_txrx;
737 if (scctx->isc_nrxd[0] <
738 ((scctx->isc_nrxd[1] * 4) + scctx->isc_nrxd[2]))
739 device_printf(softc->dev,
740 "WARNING: nrxd0 (%d) should be at least 4 * nrxd1 (%d) + nrxd2 (%d). Driver may be unstable\n",
741 scctx->isc_nrxd[0], scctx->isc_nrxd[1], scctx->isc_nrxd[2]);
742 if (scctx->isc_ntxd[0] < scctx->isc_ntxd[1] * 2)
743 device_printf(softc->dev,
744 "WARNING: ntxd0 (%d) should be at least 2 * ntxd1 (%d). Driver may be unstable\n",
745 scctx->isc_ntxd[0], scctx->isc_ntxd[1]);
746 scctx->isc_txqsizes[0] = sizeof(struct cmpl_base) * scctx->isc_ntxd[0];
747 scctx->isc_txqsizes[1] = sizeof(struct tx_bd_short) *
749 scctx->isc_rxqsizes[0] = sizeof(struct cmpl_base) * scctx->isc_nrxd[0];
750 scctx->isc_rxqsizes[1] = sizeof(struct rx_prod_pkt_bd) *
752 scctx->isc_rxqsizes[2] = sizeof(struct rx_prod_pkt_bd) *
754 scctx->isc_max_rxqsets = min(pci_msix_count(softc->dev)-1,
755 softc->func.max_cp_rings - 1);
756 scctx->isc_max_rxqsets = min(scctx->isc_max_rxqsets,
757 softc->func.max_rx_rings);
758 scctx->isc_max_txqsets = min(softc->func.max_rx_rings,
759 softc->func.max_cp_rings - scctx->isc_max_rxqsets - 1);
760 scctx->isc_rss_table_size = HW_HASH_INDEX_SIZE;
761 scctx->isc_rss_table_mask = scctx->isc_rss_table_size - 1;
763 /* iflib will map and release this bar */
764 scctx->isc_msix_bar = pci_msix_table_bar(softc->dev);
766 /* Allocate the default completion ring */
767 softc->def_cp_ring.stats_ctx_id = HWRM_NA_SIGNATURE;
768 softc->def_cp_ring.ring.phys_id = (uint16_t)HWRM_NA_SIGNATURE;
769 softc->def_cp_ring.ring.softc = softc;
770 softc->def_cp_ring.ring.id = 0;
771 softc->def_cp_ring.ring.doorbell = softc->def_cp_ring.ring.id * 0x80;
772 softc->def_cp_ring.ring.ring_size = PAGE_SIZE /
773 sizeof(struct cmpl_base);
774 rc = iflib_dma_alloc(ctx,
775 sizeof(struct cmpl_base) * softc->def_cp_ring.ring.ring_size,
776 &softc->def_cp_ring_mem, 0);
777 softc->def_cp_ring.ring.vaddr = softc->def_cp_ring_mem.idi_vaddr;
778 softc->def_cp_ring.ring.paddr = softc->def_cp_ring_mem.idi_paddr;
779 iflib_config_gtask_init(ctx, &softc->def_cp_task, bnxt_def_cp_task,
782 rc = bnxt_init_sysctl_ctx(softc);
784 goto init_sysctl_failed;
785 rc = bnxt_create_nvram_sysctls(softc->nvm_info);
789 arc4rand(softc->vnic_info.rss_hash_key, HW_HASH_KEY_SIZE, 0);
790 softc->vnic_info.rss_hash_type =
791 HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4 |
792 HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV4 |
793 HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV4 |
794 HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV6 |
795 HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV6 |
796 HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV6;
797 rc = bnxt_create_config_sysctls_pre(softc);
801 /* Initialize the vlan list */
802 SLIST_INIT(&softc->vnic_info.vlan_tags);
803 softc->vnic_info.vlan_tag_list.idi_vaddr = NULL;
808 bnxt_free_sysctl_ctx(softc);
810 bnxt_hwrm_func_drv_unrgtr(softc, false);
812 free(softc->nvm_info, M_DEVBUF);
815 free(softc->ver_info, M_DEVBUF);
817 free(softc->tpa_start, M_DEVBUF);
819 bnxt_free_hwrm_dma_mem(softc);
821 BNXT_HWRM_LOCK_DESTROY(softc);
822 bnxt_pci_mapping_free(softc);
823 pci_disable_busmaster(softc->dev);
828 bnxt_attach_post(if_ctx_t ctx)
830 struct bnxt_softc *softc = iflib_get_softc(ctx);
831 if_t ifp = iflib_get_ifp(ctx);
834 bnxt_create_config_sysctls_post(softc);
836 /* Update link state etc... */
837 rc = bnxt_probe_phy(softc);
841 /* Needs to be done after probing the phy */
842 bnxt_create_ver_sysctls(softc);
843 bnxt_add_media_types(softc);
844 ifmedia_set(softc->media, IFM_ETHER | IFM_AUTO);
846 softc->scctx->isc_max_frame_size = ifp->if_mtu + ETHER_HDR_LEN +
854 bnxt_detach(if_ctx_t ctx)
856 struct bnxt_softc *softc = iflib_get_softc(ctx);
857 struct bnxt_vlan_tag *tag;
858 struct bnxt_vlan_tag *tmp;
861 bnxt_wol_config(ctx);
862 bnxt_do_disable_intr(&softc->def_cp_ring);
863 bnxt_free_sysctl_ctx(softc);
864 bnxt_hwrm_func_reset(softc);
865 bnxt_clear_ids(softc);
866 iflib_irq_free(ctx, &softc->def_cp_ring.irq);
867 iflib_config_gtask_deinit(&softc->def_cp_task);
868 /* We need to free() these here... */
869 for (i = softc->nrxqsets-1; i>=0; i--) {
870 iflib_irq_free(ctx, &softc->rx_cp_rings[i].irq);
872 iflib_dma_free(&softc->vnic_info.mc_list);
873 iflib_dma_free(&softc->vnic_info.rss_hash_key_tbl);
874 iflib_dma_free(&softc->vnic_info.rss_grp_tbl);
875 if (softc->vnic_info.vlan_tag_list.idi_vaddr)
876 iflib_dma_free(&softc->vnic_info.vlan_tag_list);
877 SLIST_FOREACH_SAFE(tag, &softc->vnic_info.vlan_tags, next, tmp)
879 iflib_dma_free(&softc->def_cp_ring_mem);
880 free(softc->tpa_start, M_DEVBUF);
881 free(softc->ver_info, M_DEVBUF);
882 free(softc->nvm_info, M_DEVBUF);
884 bnxt_hwrm_func_drv_unrgtr(softc, false);
885 bnxt_free_hwrm_dma_mem(softc);
886 BNXT_HWRM_LOCK_DESTROY(softc);
888 pci_disable_busmaster(softc->dev);
889 bnxt_pci_mapping_free(softc);
894 /* Device configuration */
896 bnxt_init(if_ctx_t ctx)
898 struct bnxt_softc *softc = iflib_get_softc(ctx);
899 struct ifmediareq ifmr;
903 rc = bnxt_hwrm_func_reset(softc);
906 bnxt_clear_ids(softc);
908 /* Allocate the default completion ring */
909 softc->def_cp_ring.cons = UINT32_MAX;
910 softc->def_cp_ring.v_bit = 1;
911 bnxt_mark_cpr_invalid(&softc->def_cp_ring);
912 rc = bnxt_hwrm_ring_alloc(softc,
913 HWRM_RING_ALLOC_INPUT_RING_TYPE_CMPL,
914 &softc->def_cp_ring.ring,
915 (uint16_t)HWRM_NA_SIGNATURE,
916 HWRM_NA_SIGNATURE, true);
920 /* And now set the default CP ring as the async CP ring */
921 rc = bnxt_hwrm_func_cfg(softc);
925 for (i = 0; i < softc->nrxqsets; i++) {
926 /* Allocate the statistics context */
927 rc = bnxt_hwrm_stat_ctx_alloc(softc, &softc->rx_cp_rings[i],
928 softc->rx_stats.idi_paddr +
929 (sizeof(struct ctx_hw_stats) * i));
933 /* Allocate the completion ring */
934 softc->rx_cp_rings[i].cons = UINT32_MAX;
935 softc->rx_cp_rings[i].v_bit = 1;
936 softc->rx_cp_rings[i].last_idx = UINT32_MAX;
937 bnxt_mark_cpr_invalid(&softc->rx_cp_rings[i]);
938 rc = bnxt_hwrm_ring_alloc(softc,
939 HWRM_RING_ALLOC_INPUT_RING_TYPE_CMPL,
940 &softc->rx_cp_rings[i].ring, (uint16_t)HWRM_NA_SIGNATURE,
941 HWRM_NA_SIGNATURE, true);
945 /* Allocate the RX ring */
946 rc = bnxt_hwrm_ring_alloc(softc,
947 HWRM_RING_ALLOC_INPUT_RING_TYPE_RX,
948 &softc->rx_rings[i], (uint16_t)HWRM_NA_SIGNATURE,
949 HWRM_NA_SIGNATURE, false);
952 BNXT_RX_DB(&softc->rx_rings[i], 0);
953 /* TODO: Cumulus+ doesn't need the double doorbell */
954 BNXT_RX_DB(&softc->rx_rings[i], 0);
956 /* Allocate the AG ring */
957 rc = bnxt_hwrm_ring_alloc(softc,
958 HWRM_RING_ALLOC_INPUT_RING_TYPE_RX,
959 &softc->ag_rings[i], (uint16_t)HWRM_NA_SIGNATURE,
960 HWRM_NA_SIGNATURE, false);
963 BNXT_RX_DB(&softc->rx_rings[i], 0);
964 /* TODO: Cumulus+ doesn't need the double doorbell */
965 BNXT_RX_DB(&softc->ag_rings[i], 0);
967 /* Allocate the ring group */
968 softc->grp_info[i].stats_ctx =
969 softc->rx_cp_rings[i].stats_ctx_id;
970 softc->grp_info[i].rx_ring_id = softc->rx_rings[i].phys_id;
971 softc->grp_info[i].ag_ring_id = softc->ag_rings[i].phys_id;
972 softc->grp_info[i].cp_ring_id =
973 softc->rx_cp_rings[i].ring.phys_id;
974 rc = bnxt_hwrm_ring_grp_alloc(softc, &softc->grp_info[i]);
980 /* Allocate the VNIC RSS context */
981 rc = bnxt_hwrm_vnic_ctx_alloc(softc, &softc->vnic_info.rss_id);
985 /* Allocate the vnic */
986 softc->vnic_info.def_ring_grp = softc->grp_info[0].grp_id;
987 softc->vnic_info.mru = softc->scctx->isc_max_frame_size;
988 rc = bnxt_hwrm_vnic_alloc(softc, &softc->vnic_info);
991 rc = bnxt_hwrm_vnic_cfg(softc, &softc->vnic_info);
994 rc = bnxt_hwrm_set_filter(softc, &softc->vnic_info);
998 /* Enable RSS on the VNICs */
999 for (i = 0, j = 0; i < HW_HASH_INDEX_SIZE; i++) {
1001 softc->vnic_info.rss_grp_tbl.idi_vaddr)[i] =
1002 htole16(softc->grp_info[j].grp_id);
1003 if (++j == softc->nrxqsets)
1007 rc = bnxt_hwrm_rss_cfg(softc, &softc->vnic_info,
1008 softc->vnic_info.rss_hash_type);
1013 /* Enable LRO/TPA/GRO */
1014 rc = bnxt_hwrm_vnic_tpa_cfg(softc, &softc->vnic_info,
1015 (if_getcapenable(iflib_get_ifp(ctx)) & IFCAP_LRO) ?
1016 HWRM_VNIC_TPA_CFG_INPUT_FLAGS_TPA : 0);
1021 for (i = 0; i < softc->ntxqsets; i++) {
1022 /* Allocate the statistics context */
1023 rc = bnxt_hwrm_stat_ctx_alloc(softc, &softc->tx_cp_rings[i],
1024 softc->tx_stats.idi_paddr +
1025 (sizeof(struct ctx_hw_stats) * i));
1029 /* Allocate the completion ring */
1030 softc->tx_cp_rings[i].cons = UINT32_MAX;
1031 softc->tx_cp_rings[i].v_bit = 1;
1032 bnxt_mark_cpr_invalid(&softc->tx_cp_rings[i]);
1033 rc = bnxt_hwrm_ring_alloc(softc,
1034 HWRM_RING_ALLOC_INPUT_RING_TYPE_CMPL,
1035 &softc->tx_cp_rings[i].ring, (uint16_t)HWRM_NA_SIGNATURE,
1036 HWRM_NA_SIGNATURE, false);
1040 /* Allocate the TX ring */
1041 rc = bnxt_hwrm_ring_alloc(softc,
1042 HWRM_RING_ALLOC_INPUT_RING_TYPE_TX,
1043 &softc->tx_rings[i], softc->tx_cp_rings[i].ring.phys_id,
1044 softc->tx_cp_rings[i].stats_ctx_id, false);
1047 BNXT_TX_DB(&softc->tx_rings[i], 0);
1048 /* TODO: Cumulus+ doesn't need the double doorbell */
1049 BNXT_TX_DB(&softc->tx_rings[i], 0);
1052 bnxt_do_enable_intr(&softc->def_cp_ring);
1053 bnxt_media_status(softc->ctx, &ifmr);
1057 bnxt_hwrm_func_reset(softc);
1058 bnxt_clear_ids(softc);
1063 bnxt_stop(if_ctx_t ctx)
1065 struct bnxt_softc *softc = iflib_get_softc(ctx);
1067 bnxt_do_disable_intr(&softc->def_cp_ring);
1068 bnxt_hwrm_func_reset(softc);
1069 bnxt_clear_ids(softc);
1074 bnxt_multi_set(if_ctx_t ctx)
1076 struct bnxt_softc *softc = iflib_get_softc(ctx);
1077 if_t ifp = iflib_get_ifp(ctx);
1081 mcnt = if_multiaddr_count(ifp, -1);
1083 if (mcnt > BNXT_MAX_MC_ADDRS) {
1084 softc->vnic_info.rx_mask |=
1085 HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST;
1086 bnxt_hwrm_cfa_l2_set_rx_mask(softc, &softc->vnic_info);
1089 softc->vnic_info.rx_mask &=
1090 ~HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST;
1091 mta = softc->vnic_info.mc_list.idi_vaddr;
1092 bzero(mta, softc->vnic_info.mc_list.idi_size);
1093 if_multiaddr_array(ifp, mta, &cnt, mcnt);
1094 bus_dmamap_sync(softc->vnic_info.mc_list.idi_tag,
1095 softc->vnic_info.mc_list.idi_map, BUS_DMASYNC_PREWRITE);
1096 softc->vnic_info.mc_list_count = cnt;
1097 softc->vnic_info.rx_mask |=
1098 HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_MCAST;
1099 if (bnxt_hwrm_cfa_l2_set_rx_mask(softc, &softc->vnic_info))
1100 device_printf(softc->dev,
1101 "set_multi: rx_mask set failed\n");
1106 bnxt_mtu_set(if_ctx_t ctx, uint32_t mtu)
1108 struct bnxt_softc *softc = iflib_get_softc(ctx);
1110 if (mtu > BNXT_MAX_MTU)
1113 softc->scctx->isc_max_frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
1118 bnxt_media_status(if_ctx_t ctx, struct ifmediareq * ifmr)
1120 struct bnxt_softc *softc = iflib_get_softc(ctx);
1121 struct bnxt_link_info *link_info = &softc->link_info;
1122 uint8_t phy_type = get_phy_type(softc);
1124 bnxt_update_link(softc, true);
1126 ifmr->ifm_status = IFM_AVALID;
1127 ifmr->ifm_active = IFM_ETHER;
1129 if (link_info->link_up)
1130 ifmr->ifm_status |= IFM_ACTIVE;
1132 ifmr->ifm_status &= ~IFM_ACTIVE;
1134 if (link_info->duplex == HWRM_PORT_PHY_QCFG_OUTPUT_DUPLEX_FULL)
1135 ifmr->ifm_active |= IFM_FDX;
1137 ifmr->ifm_active |= IFM_HDX;
1139 switch (link_info->link_speed) {
1140 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100MB:
1141 ifmr->ifm_active |= IFM_100_T;
1143 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_1GB:
1145 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKX:
1146 ifmr->ifm_active |= IFM_1000_KX;
1148 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASET:
1149 ifmr->ifm_active |= IFM_1000_T;
1151 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_SGMIIEXTPHY:
1152 ifmr->ifm_active |= IFM_1000_SGMII;
1155 ifmr->ifm_active |= IFM_UNKNOWN;
1159 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2_5GB:
1161 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKX:
1162 ifmr->ifm_active |= IFM_2500_KX;
1164 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASET:
1165 ifmr->ifm_active |= IFM_2500_T;
1168 ifmr->ifm_active |= IFM_UNKNOWN;
1172 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_10GB:
1174 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASECR:
1175 ifmr->ifm_active |= IFM_10G_CR1;
1177 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR4:
1178 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR2:
1179 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR:
1180 ifmr->ifm_active |= IFM_10G_KR;
1182 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASELR:
1183 ifmr->ifm_active |= IFM_10G_LR;
1185 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASESR:
1186 ifmr->ifm_active |= IFM_10G_SR;
1188 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKX:
1189 ifmr->ifm_active |= IFM_10G_KX4;
1191 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASET:
1192 ifmr->ifm_active |= IFM_10G_T;
1195 ifmr->ifm_active |= IFM_UNKNOWN;
1199 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_20GB:
1200 ifmr->ifm_active |= IFM_20G_KR2;
1202 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_25GB:
1204 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASECR:
1205 ifmr->ifm_active |= IFM_25G_CR;
1207 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR4:
1208 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR2:
1209 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR:
1210 ifmr->ifm_active |= IFM_25G_KR;
1212 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASESR:
1213 ifmr->ifm_active |= IFM_25G_SR;
1216 ifmr->ifm_active |= IFM_UNKNOWN;
1220 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_40GB:
1222 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASECR:
1223 ifmr->ifm_active |= IFM_40G_CR4;
1225 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR4:
1226 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR2:
1227 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR:
1228 ifmr->ifm_active |= IFM_40G_KR4;
1230 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASELR:
1231 ifmr->ifm_active |= IFM_40G_LR4;
1233 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASESR:
1234 ifmr->ifm_active |= IFM_40G_SR4;
1237 ifmr->ifm_active |= IFM_UNKNOWN;
1241 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_50GB:
1243 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASECR:
1244 ifmr->ifm_active |= IFM_50G_CR2;
1246 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR4:
1247 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR2:
1248 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR:
1249 ifmr->ifm_active |= IFM_50G_KR2;
1252 ifmr->ifm_active |= IFM_UNKNOWN;
1256 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100GB:
1258 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASECR:
1259 ifmr->ifm_active |= IFM_100G_CR4;
1261 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR4:
1262 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR2:
1263 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR:
1264 ifmr->ifm_active |= IFM_100G_KR4;
1266 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASELR:
1267 ifmr->ifm_active |= IFM_100G_LR4;
1269 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASESR:
1270 ifmr->ifm_active |= IFM_100G_SR4;
1273 ifmr->ifm_active |= IFM_UNKNOWN;
1280 if (link_info->pause == (HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_TX |
1281 HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_RX))
1282 ifmr->ifm_active |= (IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE);
1283 else if (link_info->pause == HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_TX)
1284 ifmr->ifm_active |= IFM_ETH_TXPAUSE;
1285 else if (link_info->pause == HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_RX)
1286 ifmr->ifm_active |= IFM_ETH_RXPAUSE;
1288 bnxt_report_link(softc);
1293 bnxt_media_change(if_ctx_t ctx)
1295 struct bnxt_softc *softc = iflib_get_softc(ctx);
1296 struct ifmedia *ifm = iflib_get_media(ctx);
1297 struct ifmediareq ifmr;
1300 if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
1303 switch (IFM_SUBTYPE(ifm->ifm_media)) {
1305 softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
1306 softc->link_info.req_link_speed =
1307 HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_100MB;
1311 case IFM_1000_SGMII:
1312 softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
1313 softc->link_info.req_link_speed =
1314 HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_1GB;
1318 softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
1319 softc->link_info.req_link_speed =
1320 HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_2_5GB;
1327 softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
1328 softc->link_info.req_link_speed =
1329 HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_10GB;
1332 softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
1333 softc->link_info.req_link_speed =
1334 HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_20GB;
1339 softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
1340 softc->link_info.req_link_speed =
1341 HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_25GB;
1347 softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
1348 softc->link_info.req_link_speed =
1349 HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_40GB;
1353 softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
1354 softc->link_info.req_link_speed =
1355 HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_50GB;
1361 softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
1362 softc->link_info.req_link_speed =
1363 HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_100GB;
1366 device_printf(softc->dev,
1367 "Unsupported media type! Using auto\n");
1371 softc->link_info.autoneg |= BNXT_AUTONEG_SPEED;
1374 rc = bnxt_hwrm_set_link_setting(softc, true, true);
1375 bnxt_media_status(softc->ctx, &ifmr);
1380 bnxt_promisc_set(if_ctx_t ctx, int flags)
1382 struct bnxt_softc *softc = iflib_get_softc(ctx);
1383 if_t ifp = iflib_get_ifp(ctx);
1386 if (ifp->if_flags & IFF_ALLMULTI ||
1387 if_multiaddr_count(ifp, -1) > BNXT_MAX_MC_ADDRS)
1388 softc->vnic_info.rx_mask |=
1389 HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST;
1391 softc->vnic_info.rx_mask &=
1392 ~HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST;
1394 if (ifp->if_flags & IFF_PROMISC)
1395 softc->vnic_info.rx_mask |=
1396 HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_PROMISCUOUS |
1397 HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ANYVLAN_NONVLAN;
1399 softc->vnic_info.rx_mask &=
1400 ~(HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_PROMISCUOUS |
1401 HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ANYVLAN_NONVLAN);
1403 rc = bnxt_hwrm_cfa_l2_set_rx_mask(softc, &softc->vnic_info);
1409 bnxt_get_counter(if_ctx_t ctx, ift_counter cnt)
1411 if_t ifp = iflib_get_ifp(ctx);
1413 if (cnt < IFCOUNTERS)
1414 return if_get_counter_default(ifp, cnt);
1420 bnxt_update_admin_status(if_ctx_t ctx)
1422 /* TODO: do we need to do anything here? */
1427 bnxt_do_enable_intr(struct bnxt_cp_ring *cpr)
1429 if (cpr->ring.phys_id != (uint16_t)HWRM_NA_SIGNATURE) {
1430 /* First time enabling, do not set index */
1431 if (cpr->cons == UINT32_MAX)
1432 BNXT_CP_ENABLE_DB(&cpr->ring);
1434 BNXT_CP_IDX_ENABLE_DB(&cpr->ring, cpr->cons);
1439 bnxt_do_disable_intr(struct bnxt_cp_ring *cpr)
1441 if (cpr->ring.phys_id != (uint16_t)HWRM_NA_SIGNATURE)
1442 BNXT_CP_DISABLE_DB(&cpr->ring);
1445 /* Enable all interrupts */
1447 bnxt_intr_enable(if_ctx_t ctx)
1449 struct bnxt_softc *softc = iflib_get_softc(ctx);
1452 bnxt_do_enable_intr(&softc->def_cp_ring);
1453 for (i = 0; i < softc->nrxqsets; i++)
1454 bnxt_do_enable_intr(&softc->rx_cp_rings[i]);
1459 /* Enable interrupt for a single queue */
1461 bnxt_tx_queue_intr_enable(if_ctx_t ctx, uint16_t qid)
1463 struct bnxt_softc *softc = iflib_get_softc(ctx);
1465 bnxt_do_enable_intr(&softc->tx_cp_rings[qid]);
1470 bnxt_rx_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->rx_cp_rings[qid]);
1478 /* Disable all interrupts */
1480 bnxt_disable_intr(if_ctx_t ctx)
1482 struct bnxt_softc *softc = iflib_get_softc(ctx);
1486 * NOTE: These TX interrupts should never get enabled, so don't
1489 for (i = 0; i < softc->ntxqsets; i++)
1490 bnxt_do_disable_intr(&softc->tx_cp_rings[i]);
1491 for (i = 0; i < softc->nrxqsets; i++)
1492 bnxt_do_disable_intr(&softc->rx_cp_rings[i]);
1498 bnxt_msix_intr_assign(if_ctx_t ctx, int msix)
1500 struct bnxt_softc *softc = iflib_get_softc(ctx);
1504 rc = iflib_irq_alloc_generic(ctx, &softc->def_cp_ring.irq,
1505 softc->def_cp_ring.ring.id + 1, IFLIB_INTR_ADMIN,
1506 bnxt_handle_def_cp, softc, 0, "def_cp");
1508 device_printf(iflib_get_dev(ctx),
1509 "Failed to register default completion ring handler\n");
1513 for (i=0; i<softc->scctx->isc_nrxqsets; i++) {
1514 rc = iflib_irq_alloc_generic(ctx, &softc->rx_cp_rings[i].irq,
1515 softc->rx_cp_rings[i].ring.id + 1, IFLIB_INTR_RX,
1516 bnxt_handle_rx_cp, &softc->rx_cp_rings[i], i, "rx_cp");
1518 device_printf(iflib_get_dev(ctx),
1519 "Failed to register RX completion ring handler\n");
1525 for (i=0; i<softc->scctx->isc_ntxqsets; i++)
1526 iflib_softirq_alloc_generic(ctx, i + 1, IFLIB_INTR_TX, NULL, i,
1533 iflib_irq_free(ctx, &softc->rx_cp_rings[i].irq);
1534 iflib_irq_free(ctx, &softc->def_cp_ring.irq);
1539 * We're explicitly allowing duplicates here. They will need to be
1540 * removed as many times as they are added.
1543 bnxt_vlan_register(if_ctx_t ctx, uint16_t vtag)
1545 struct bnxt_softc *softc = iflib_get_softc(ctx);
1546 struct bnxt_vlan_tag *new_tag;
1548 new_tag = malloc(sizeof(struct bnxt_vlan_tag), M_DEVBUF, M_NOWAIT);
1549 if (new_tag == NULL)
1551 new_tag->tag = vtag;
1552 new_tag->tpid = 8100;
1553 SLIST_INSERT_HEAD(&softc->vnic_info.vlan_tags, new_tag, next);
1557 bnxt_vlan_unregister(if_ctx_t ctx, uint16_t vtag)
1559 struct bnxt_softc *softc = iflib_get_softc(ctx);
1560 struct bnxt_vlan_tag *vlan_tag;
1562 SLIST_FOREACH(vlan_tag, &softc->vnic_info.vlan_tags, next) {
1563 if (vlan_tag->tag == vtag) {
1564 SLIST_REMOVE(&softc->vnic_info.vlan_tags, vlan_tag,
1565 bnxt_vlan_tag, next);
1566 free(vlan_tag, M_DEVBUF);
1573 bnxt_wol_config(if_ctx_t ctx)
1575 struct bnxt_softc *softc = iflib_get_softc(ctx);
1576 if_t ifp = iflib_get_ifp(ctx);
1581 if (!bnxt_wol_supported(softc))
1584 if (if_getcapabilities(ifp) & IFCAP_WOL_MAGIC) {
1586 if (bnxt_hwrm_alloc_wol_fltr(softc))
1592 if (bnxt_hwrm_free_wol_fltr(softc))
1602 bnxt_shutdown(if_ctx_t ctx)
1604 bnxt_wol_config(ctx);
1609 bnxt_suspend(if_ctx_t ctx)
1611 bnxt_wol_config(ctx);
1616 bnxt_resume(if_ctx_t ctx)
1618 struct bnxt_softc *softc = iflib_get_softc(ctx);
1620 bnxt_get_wol_settings(softc);
1625 bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data)
1627 struct bnxt_softc *softc = iflib_get_softc(ctx);
1628 struct ifreq *ifr = (struct ifreq *)data;
1629 struct ifreq_buffer *ifbuf = &ifr->ifr_ifru.ifru_buffer;
1630 struct bnxt_ioctl_header *ioh =
1631 (struct bnxt_ioctl_header *)(ifbuf->buffer);
1633 struct bnxt_ioctl_data *iod = NULL;
1636 case SIOCGPRIVATE_0:
1637 if ((rc = priv_check(curthread, PRIV_DRIVER)) != 0)
1640 iod = malloc(ifbuf->length, M_DEVBUF, M_NOWAIT | M_ZERO);
1645 copyin(ioh, iod, ifbuf->length);
1647 switch (ioh->type) {
1648 case BNXT_HWRM_NVM_FIND_DIR_ENTRY:
1650 struct bnxt_ioctl_hwrm_nvm_find_dir_entry *find =
1653 rc = bnxt_hwrm_nvm_find_dir_entry(softc, find->type,
1654 &find->ordinal, find->ext, &find->index,
1655 find->use_index, find->search_opt,
1656 &find->data_length, &find->item_length,
1660 copyout(&iod->hdr.rc, &ioh->rc,
1665 copyout(iod, ioh, ifbuf->length);
1671 case BNXT_HWRM_NVM_READ:
1673 struct bnxt_ioctl_hwrm_nvm_read *rd = &iod->read;
1674 struct iflib_dma_info dma_data;
1680 * Some HWRM versions can't read more than 0x8000 bytes
1682 rc = iflib_dma_alloc(softc->ctx,
1683 min(rd->length, 0x8000), &dma_data, BUS_DMA_NOWAIT);
1686 for (remain = rd->length, offset = 0;
1687 remain && offset < rd->length; offset += 0x8000) {
1688 csize = min(remain, 0x8000);
1689 rc = bnxt_hwrm_nvm_read(softc, rd->index,
1690 rd->offset + offset, csize, &dma_data);
1693 copyout(&iod->hdr.rc, &ioh->rc,
1698 copyout(dma_data.idi_vaddr,
1699 rd->data + offset, csize);
1704 if (iod->hdr.rc == 0)
1705 copyout(iod, ioh, ifbuf->length);
1707 iflib_dma_free(&dma_data);
1711 case BNXT_HWRM_FW_RESET:
1713 struct bnxt_ioctl_hwrm_fw_reset *rst =
1716 rc = bnxt_hwrm_fw_reset(softc, rst->processor,
1720 copyout(&iod->hdr.rc, &ioh->rc,
1725 copyout(iod, ioh, ifbuf->length);
1731 case BNXT_HWRM_FW_QSTATUS:
1733 struct bnxt_ioctl_hwrm_fw_qstatus *qstat =
1736 rc = bnxt_hwrm_fw_qstatus(softc, qstat->processor,
1740 copyout(&iod->hdr.rc, &ioh->rc,
1745 copyout(iod, ioh, ifbuf->length);
1751 case BNXT_HWRM_NVM_WRITE:
1753 struct bnxt_ioctl_hwrm_nvm_write *wr =
1756 rc = bnxt_hwrm_nvm_write(softc, wr->data, true,
1757 wr->type, wr->ordinal, wr->ext, wr->attr,
1758 wr->option, wr->data_length, wr->keep,
1759 &wr->item_length, &wr->index);
1762 copyout(&iod->hdr.rc, &ioh->rc,
1767 copyout(iod, ioh, ifbuf->length);
1773 case BNXT_HWRM_NVM_ERASE_DIR_ENTRY:
1775 struct bnxt_ioctl_hwrm_nvm_erase_dir_entry *erase =
1778 rc = bnxt_hwrm_nvm_erase_dir_entry(softc, erase->index);
1781 copyout(&iod->hdr.rc, &ioh->rc,
1786 copyout(iod, ioh, ifbuf->length);
1792 case BNXT_HWRM_NVM_GET_DIR_INFO:
1794 struct bnxt_ioctl_hwrm_nvm_get_dir_info *info =
1797 rc = bnxt_hwrm_nvm_get_dir_info(softc, &info->entries,
1798 &info->entry_length);
1801 copyout(&iod->hdr.rc, &ioh->rc,
1806 copyout(iod, ioh, ifbuf->length);
1812 case BNXT_HWRM_NVM_GET_DIR_ENTRIES:
1814 struct bnxt_ioctl_hwrm_nvm_get_dir_entries *get =
1816 struct iflib_dma_info dma_data;
1818 rc = iflib_dma_alloc(softc->ctx, get->max_size,
1819 &dma_data, BUS_DMA_NOWAIT);
1822 rc = bnxt_hwrm_nvm_get_dir_entries(softc, &get->entries,
1823 &get->entry_length, &dma_data);
1826 copyout(&iod->hdr.rc, &ioh->rc,
1830 copyout(dma_data.idi_vaddr, get->data,
1831 get->entry_length * get->entries);
1833 copyout(iod, ioh, ifbuf->length);
1835 iflib_dma_free(&dma_data);
1840 case BNXT_HWRM_NVM_VERIFY_UPDATE:
1842 struct bnxt_ioctl_hwrm_nvm_verify_update *vrfy =
1845 rc = bnxt_hwrm_nvm_verify_update(softc, vrfy->type,
1846 vrfy->ordinal, vrfy->ext);
1849 copyout(&iod->hdr.rc, &ioh->rc,
1854 copyout(iod, ioh, ifbuf->length);
1860 case BNXT_HWRM_NVM_INSTALL_UPDATE:
1862 struct bnxt_ioctl_hwrm_nvm_install_update *inst =
1865 rc = bnxt_hwrm_nvm_install_update(softc,
1866 inst->install_type, &inst->installed_items,
1867 &inst->result, &inst->problem_item,
1868 &inst->reset_required);
1871 copyout(&iod->hdr.rc, &ioh->rc,
1876 copyout(iod, ioh, ifbuf->length);
1882 case BNXT_HWRM_NVM_MODIFY:
1884 struct bnxt_ioctl_hwrm_nvm_modify *mod = &iod->modify;
1886 rc = bnxt_hwrm_nvm_modify(softc, mod->index,
1887 mod->offset, mod->data, true, mod->length);
1890 copyout(&iod->hdr.rc, &ioh->rc,
1895 copyout(iod, ioh, ifbuf->length);
1901 case BNXT_HWRM_FW_GET_TIME:
1903 struct bnxt_ioctl_hwrm_fw_get_time *gtm =
1906 rc = bnxt_hwrm_fw_get_time(softc, >m->year,
1907 >m->month, >m->day, >m->hour, >m->minute,
1908 >m->second, >m->millisecond, >m->zone);
1911 copyout(&iod->hdr.rc, &ioh->rc,
1916 copyout(iod, ioh, ifbuf->length);
1922 case BNXT_HWRM_FW_SET_TIME:
1924 struct bnxt_ioctl_hwrm_fw_set_time *stm =
1927 rc = bnxt_hwrm_fw_set_time(softc, stm->year,
1928 stm->month, stm->day, stm->hour, stm->minute,
1929 stm->second, stm->millisecond, stm->zone);
1932 copyout(&iod->hdr.rc, &ioh->rc,
1937 copyout(iod, ioh, ifbuf->length);
1949 free(iod, M_DEVBUF);
1957 bnxt_probe_phy(struct bnxt_softc *softc)
1959 struct bnxt_link_info *link_info = &softc->link_info;
1962 rc = bnxt_update_link(softc, false);
1964 device_printf(softc->dev,
1965 "Probe phy can't update link (rc: %x)\n", rc);
1969 /*initialize the ethool setting copy with NVM settings */
1970 if (link_info->auto_mode != HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_NONE)
1971 link_info->autoneg |= BNXT_AUTONEG_SPEED;
1973 if (link_info->auto_pause & (HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_TX |
1974 HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_RX)) {
1975 if (link_info->auto_pause == (
1976 HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_TX |
1977 HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_RX))
1978 link_info->autoneg |= BNXT_AUTONEG_FLOW_CTRL;
1979 link_info->req_flow_ctrl = link_info->auto_pause;
1980 } else if (link_info->force_pause & (
1981 HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_TX |
1982 HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_RX)) {
1983 link_info->req_flow_ctrl = link_info->force_pause;
1985 link_info->req_duplex = link_info->duplex_setting;
1986 if (link_info->autoneg & BNXT_AUTONEG_SPEED)
1987 link_info->req_link_speed = link_info->auto_link_speed;
1989 link_info->req_link_speed = link_info->force_link_speed;
1994 bnxt_add_media_types(struct bnxt_softc *softc)
1996 struct bnxt_link_info *link_info = &softc->link_info;
1998 uint8_t phy_type = get_phy_type(softc);
2000 supported = link_info->support_speeds;
2002 /* Auto is always supported */
2003 ifmedia_add(softc->media, IFM_ETHER | IFM_AUTO, 0, NULL);
2005 if (softc->flags & BNXT_FLAG_NPAR)
2009 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASECR:
2010 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_100GB)
2011 ifmedia_add(softc->media, IFM_ETHER | IFM_100G_CR4, 0,
2013 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_50GB)
2014 ifmedia_add(softc->media, IFM_ETHER | IFM_50G_CR2, 0,
2016 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_40GB)
2017 ifmedia_add(softc->media, IFM_ETHER | IFM_40G_CR4, 0,
2019 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_25GB)
2020 ifmedia_add(softc->media, IFM_ETHER | IFM_25G_CR, 0,
2022 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_10GB)
2023 ifmedia_add(softc->media, IFM_ETHER | IFM_10G_CR1, 0,
2026 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_UNKNOWN:
2029 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR4:
2030 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR2:
2031 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR:
2032 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_100GB)
2033 ifmedia_add(softc->media, IFM_ETHER | IFM_100G_KR4, 0,
2035 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_50GB)
2036 ifmedia_add(softc->media, IFM_ETHER | IFM_50G_KR2, 0,
2038 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_40GB)
2039 ifmedia_add(softc->media, IFM_ETHER | IFM_40G_KR4, 0,
2041 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_25GB)
2042 ifmedia_add(softc->media, IFM_ETHER | IFM_25G_KR, 0,
2044 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_20GB)
2045 ifmedia_add(softc->media, IFM_ETHER | IFM_20G_KR2, 0,
2047 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_10GB)
2048 ifmedia_add(softc->media, IFM_ETHER | IFM_10G_KR, 0,
2051 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASELR:
2052 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_100GB)
2053 ifmedia_add(softc->media, IFM_ETHER | IFM_100G_LR4, 0,
2055 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_40GB)
2056 ifmedia_add(softc->media, IFM_ETHER | IFM_40G_LR4, 0,
2058 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_10GB)
2059 ifmedia_add(softc->media, IFM_ETHER | IFM_10G_LR, 0,
2062 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASESR:
2063 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_100GB)
2064 ifmedia_add(softc->media, IFM_ETHER | IFM_100G_SR4, 0,
2066 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_40GB)
2067 ifmedia_add(softc->media, IFM_ETHER | IFM_40G_SR4, 0,
2069 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_25GB)
2070 ifmedia_add(softc->media, IFM_ETHER | IFM_25G_SR, 0,
2072 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_10GB)
2073 ifmedia_add(softc->media, IFM_ETHER | IFM_10G_SR, 0,
2076 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKX:
2077 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_10GB)
2078 ifmedia_add(softc->media, IFM_ETHER | IFM_10G_KX4, 0,
2080 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_2_5GB)
2081 ifmedia_add(softc->media, IFM_ETHER | IFM_2500_KX, 0,
2083 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_1GB)
2084 ifmedia_add(softc->media, IFM_ETHER | IFM_1000_KX, 0,
2087 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASET:
2088 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASETE:
2089 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_10MB)
2090 ifmedia_add(softc->media, IFM_ETHER | IFM_10_T, 0,
2092 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_100MB)
2093 ifmedia_add(softc->media, IFM_ETHER | IFM_100_T, 0,
2095 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_1GB)
2096 ifmedia_add(softc->media, IFM_ETHER | IFM_1000_T, 0,
2098 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_2_5GB)
2099 ifmedia_add(softc->media, IFM_ETHER | IFM_2500_T, 0,
2101 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_10GB)
2102 ifmedia_add(softc->media, IFM_ETHER | IFM_10G_T, 0,
2105 case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_SGMIIEXTPHY:
2106 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_1GB)
2107 ifmedia_add(softc->media, IFM_ETHER | IFM_1000_SGMII, 0,
2116 bnxt_map_bar(struct bnxt_softc *softc, struct bnxt_bar_info *bar, int bar_num, bool shareable)
2120 if (bar->res != NULL) {
2121 device_printf(softc->dev, "Bar %d already mapped\n", bar_num);
2125 bar->rid = PCIR_BAR(bar_num);
2128 flag |= RF_SHAREABLE;
2131 bus_alloc_resource_any(softc->dev,
2135 device_printf(softc->dev,
2136 "PCI BAR%d mapping failure\n", bar_num);
2139 bar->tag = rman_get_bustag(bar->res);
2140 bar->handle = rman_get_bushandle(bar->res);
2141 bar->size = rman_get_size(bar->res);
2147 bnxt_pci_mapping(struct bnxt_softc *softc)
2151 rc = bnxt_map_bar(softc, &softc->hwrm_bar, 0, true);
2155 rc = bnxt_map_bar(softc, &softc->doorbell_bar, 2, false);
2161 bnxt_pci_mapping_free(struct bnxt_softc *softc)
2163 if (softc->hwrm_bar.res != NULL)
2164 bus_release_resource(softc->dev, SYS_RES_MEMORY,
2165 softc->hwrm_bar.rid, softc->hwrm_bar.res);
2166 softc->hwrm_bar.res = NULL;
2168 if (softc->doorbell_bar.res != NULL)
2169 bus_release_resource(softc->dev, SYS_RES_MEMORY,
2170 softc->doorbell_bar.rid, softc->doorbell_bar.res);
2171 softc->doorbell_bar.res = NULL;
2175 bnxt_update_link(struct bnxt_softc *softc, bool chng_link_state)
2177 struct bnxt_link_info *link_info = &softc->link_info;
2178 uint8_t link_up = link_info->link_up;
2181 rc = bnxt_hwrm_port_phy_qcfg(softc);
2185 /* TODO: need to add more logic to report VF link */
2186 if (chng_link_state) {
2187 if (link_info->phy_link_status ==
2188 HWRM_PORT_PHY_QCFG_OUTPUT_LINK_LINK)
2189 link_info->link_up = 1;
2191 link_info->link_up = 0;
2192 if (link_up != link_info->link_up)
2193 bnxt_report_link(softc);
2195 /* always link down if not require to update link state */
2196 link_info->link_up = 0;
2204 bnxt_report_link(struct bnxt_softc *softc)
2206 const char *duplex = NULL, *flow_ctrl = NULL;
2208 if (softc->link_info.link_up == softc->link_info.last_link_up) {
2209 if (!softc->link_info.link_up)
2211 if (softc->link_info.pause == softc->link_info.last_pause &&
2212 softc->link_info.duplex == softc->link_info.last_duplex)
2216 if (softc->link_info.link_up) {
2217 if (softc->link_info.duplex ==
2218 HWRM_PORT_PHY_QCFG_OUTPUT_DUPLEX_FULL)
2219 duplex = "full duplex";
2221 duplex = "half duplex";
2222 if (softc->link_info.pause == (
2223 HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_TX |
2224 HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_RX))
2225 flow_ctrl = "FC - receive & transmit";
2226 else if (softc->link_info.pause ==
2227 HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_TX)
2228 flow_ctrl = "FC - transmit";
2229 else if (softc->link_info.pause ==
2230 HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_RX)
2231 flow_ctrl = "FC - receive";
2234 iflib_link_state_change(softc->ctx, LINK_STATE_UP,
2236 device_printf(softc->dev, "Link is UP %s, %s\n", duplex,
2239 iflib_link_state_change(softc->ctx, LINK_STATE_DOWN,
2240 bnxt_get_baudrate(&softc->link_info));
2241 device_printf(softc->dev, "Link is Down\n");
2244 softc->link_info.last_link_up = softc->link_info.link_up;
2245 softc->link_info.last_pause = softc->link_info.pause;
2246 softc->link_info.last_duplex = softc->link_info.duplex;
2250 bnxt_handle_rx_cp(void *arg)
2252 struct bnxt_cp_ring *cpr = arg;
2254 /* Disable further interrupts for this queue */
2255 BNXT_CP_DISABLE_DB(&cpr->ring);
2256 return FILTER_SCHEDULE_THREAD;
2260 bnxt_handle_def_cp(void *arg)
2262 struct bnxt_softc *softc = arg;
2264 BNXT_CP_DISABLE_DB(&softc->def_cp_ring.ring);
2265 GROUPTASK_ENQUEUE(&softc->def_cp_task);
2266 return FILTER_HANDLED;
2270 bnxt_clear_ids(struct bnxt_softc *softc)
2274 softc->def_cp_ring.stats_ctx_id = HWRM_NA_SIGNATURE;
2275 softc->def_cp_ring.ring.phys_id = (uint16_t)HWRM_NA_SIGNATURE;
2276 for (i = 0; i < softc->ntxqsets; i++) {
2277 softc->tx_cp_rings[i].stats_ctx_id = HWRM_NA_SIGNATURE;
2278 softc->tx_cp_rings[i].ring.phys_id =
2279 (uint16_t)HWRM_NA_SIGNATURE;
2280 softc->tx_rings[i].phys_id = (uint16_t)HWRM_NA_SIGNATURE;
2282 for (i = 0; i < softc->nrxqsets; i++) {
2283 softc->rx_cp_rings[i].stats_ctx_id = HWRM_NA_SIGNATURE;
2284 softc->rx_cp_rings[i].ring.phys_id =
2285 (uint16_t)HWRM_NA_SIGNATURE;
2286 softc->rx_rings[i].phys_id = (uint16_t)HWRM_NA_SIGNATURE;
2287 softc->ag_rings[i].phys_id = (uint16_t)HWRM_NA_SIGNATURE;
2288 softc->grp_info[i].grp_id = (uint16_t)HWRM_NA_SIGNATURE;
2290 softc->vnic_info.filter_id = -1;
2291 softc->vnic_info.id = (uint16_t)HWRM_NA_SIGNATURE;
2292 softc->vnic_info.rss_id = (uint16_t)HWRM_NA_SIGNATURE;
2293 memset(softc->vnic_info.rss_grp_tbl.idi_vaddr, 0xff,
2294 softc->vnic_info.rss_grp_tbl.idi_size);
2298 bnxt_mark_cpr_invalid(struct bnxt_cp_ring *cpr)
2300 struct cmpl_base *cmp = (void *)cpr->ring.vaddr;
2303 for (i = 0; i < cpr->ring.ring_size; i++)
2304 cmp[i].info3_v = !cpr->v_bit;
2308 bnxt_handle_async_event(struct bnxt_softc *softc, struct cmpl_base *cmpl)
2310 struct hwrm_async_event_cmpl *ae = (void *)cmpl;
2311 uint16_t async_id = le16toh(ae->event_id);
2312 struct ifmediareq ifmr;
2315 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE:
2316 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CHANGE:
2317 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE:
2318 bnxt_media_status(softc->ctx, &ifmr);
2320 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_MTU_CHANGE:
2321 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DCB_CONFIG_CHANGE:
2322 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED:
2323 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_NOT_ALLOWED:
2324 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_FUNC_DRVR_UNLOAD:
2325 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_FUNC_DRVR_LOAD:
2326 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD:
2327 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_LOAD:
2328 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_FLR:
2329 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_MAC_ADDR_CHANGE:
2330 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_VF_COMM_STATUS_CHANGE:
2331 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_CFG_CHANGE:
2332 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_HWRM_ERROR:
2333 device_printf(softc->dev,
2334 "Unhandled async completion type %u\n", async_id);
2337 device_printf(softc->dev,
2338 "Unknown async completion type %u\n", async_id);
2344 bnxt_def_cp_task(void *context)
2346 if_ctx_t ctx = context;
2347 struct bnxt_softc *softc = iflib_get_softc(ctx);
2348 struct bnxt_cp_ring *cpr = &softc->def_cp_ring;
2350 /* Handle completions on the default completion ring */
2351 struct cmpl_base *cmpl;
2352 uint32_t cons = cpr->cons;
2353 bool v_bit = cpr->v_bit;
2361 NEXT_CP_CONS_V(&cpr->ring, cons, v_bit);
2362 cmpl = &((struct cmpl_base *)cpr->ring.vaddr)[cons];
2364 if (!CMP_VALID(cmpl, v_bit))
2367 type = le16toh(cmpl->type) & CMPL_BASE_TYPE_MASK;
2369 case CMPL_BASE_TYPE_HWRM_ASYNC_EVENT:
2370 bnxt_handle_async_event(softc, cmpl);
2372 case CMPL_BASE_TYPE_TX_L2:
2373 case CMPL_BASE_TYPE_RX_L2:
2374 case CMPL_BASE_TYPE_RX_AGG:
2375 case CMPL_BASE_TYPE_RX_TPA_START:
2376 case CMPL_BASE_TYPE_RX_TPA_END:
2377 case CMPL_BASE_TYPE_STAT_EJECT:
2378 case CMPL_BASE_TYPE_HWRM_DONE:
2379 case CMPL_BASE_TYPE_HWRM_FWD_REQ:
2380 case CMPL_BASE_TYPE_HWRM_FWD_RESP:
2381 case CMPL_BASE_TYPE_CQ_NOTIFICATION:
2382 case CMPL_BASE_TYPE_SRQ_EVENT:
2383 case CMPL_BASE_TYPE_DBQ_EVENT:
2384 case CMPL_BASE_TYPE_QP_EVENT:
2385 case CMPL_BASE_TYPE_FUNC_EVENT:
2386 device_printf(softc->dev,
2387 "Unhandled completion type %u\n", type);
2390 device_printf(softc->dev,
2391 "Unknown completion type %u\n", type);
2396 cpr->cons = last_cons;
2397 cpr->v_bit = last_v_bit;
2398 BNXT_CP_IDX_ENABLE_DB(&cpr->ring, cpr->cons);
2402 get_phy_type(struct bnxt_softc *softc)
2404 struct bnxt_link_info *link_info = &softc->link_info;
2405 uint8_t phy_type = link_info->phy_type;
2408 if (phy_type != HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_UNKNOWN)
2411 /* Deduce the phy type from the media type and supported speeds */
2412 supported = link_info->support_speeds;
2414 if (link_info->media_type ==
2415 HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_TP)
2416 return HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASET;
2417 if (link_info->media_type ==
2418 HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_DAC) {
2419 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_2_5GB)
2420 return HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKX;
2421 if (supported & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_20GB)
2422 return HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR;
2423 return HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASECR;
2425 if (link_info->media_type ==
2426 HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_FIBRE)
2427 return HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASESR;
2433 bnxt_check_hwrm_version(struct bnxt_softc *softc)
2437 sprintf(buf, "%hhu.%hhu.%hhu", softc->ver_info->hwrm_min_major,
2438 softc->ver_info->hwrm_min_minor, softc->ver_info->hwrm_min_update);
2439 if (softc->ver_info->hwrm_min_major > softc->ver_info->hwrm_if_major) {
2440 device_printf(softc->dev,
2441 "WARNING: HWRM version %s is too old (older than %s)\n",
2442 softc->ver_info->hwrm_if_ver, buf);
2445 else if(softc->ver_info->hwrm_min_major ==
2446 softc->ver_info->hwrm_if_major) {
2447 if (softc->ver_info->hwrm_min_minor >
2448 softc->ver_info->hwrm_if_minor) {
2449 device_printf(softc->dev,
2450 "WARNING: HWRM version %s is too old (older than %s)\n",
2451 softc->ver_info->hwrm_if_ver, buf);
2454 else if (softc->ver_info->hwrm_min_minor ==
2455 softc->ver_info->hwrm_if_minor) {
2456 if (softc->ver_info->hwrm_min_update >
2457 softc->ver_info->hwrm_if_update) {
2458 device_printf(softc->dev,
2459 "WARNING: HWRM version %s is too old (older than %s)\n",
2460 softc->ver_info->hwrm_if_ver, buf);
2469 bnxt_get_baudrate(struct bnxt_link_info *link)
2471 switch (link->link_speed) {
2472 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100MB:
2473 return IF_Mbps(100);
2474 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_1GB:
2476 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2GB:
2478 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2_5GB:
2479 return IF_Mbps(2500);
2480 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_10GB:
2482 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_20GB:
2484 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_25GB:
2486 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_40GB:
2488 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_50GB:
2490 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100GB:
2491 return IF_Gbps(100);
2492 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_10MB:
2495 return IF_Gbps(100);
2499 bnxt_get_wol_settings(struct bnxt_softc *softc)
2501 uint16_t wol_handle = 0;
2503 if (!bnxt_wol_supported(softc))
2507 wol_handle = bnxt_hwrm_get_wol_fltrs(softc, wol_handle);
2508 } while (wol_handle && wol_handle != BNXT_NO_MORE_WOL_FILTERS);