if_ixl.c (cf1509179cd14a34ef5fa7492f62b1082cfae2b2) if_ixl.c (b4a7ce0690aedd9763b3b47ee7fcdb421f0434c7)
1/******************************************************************************
2
3 Copyright (c) 2013-2018, Intel Corporation
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8

--- 34 unchanged lines hidden (view full) ---

43#ifdef PCI_IOV
44#include "ixl_pf_iov.h"
45#endif
46
47/*********************************************************************
48 * Driver version
49 *********************************************************************/
50#define IXL_DRIVER_VERSION_MAJOR 2
1/******************************************************************************
2
3 Copyright (c) 2013-2018, Intel Corporation
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8

--- 34 unchanged lines hidden (view full) ---

43#ifdef PCI_IOV
44#include "ixl_pf_iov.h"
45#endif
46
47/*********************************************************************
48 * Driver version
49 *********************************************************************/
50#define IXL_DRIVER_VERSION_MAJOR 2
51#define IXL_DRIVER_VERSION_MINOR 1
51#define IXL_DRIVER_VERSION_MINOR 2
52#define IXL_DRIVER_VERSION_BUILD 0
53
54#define IXL_DRIVER_VERSION_STRING \
55 __XSTRING(IXL_DRIVER_VERSION_MAJOR) "." \
56 __XSTRING(IXL_DRIVER_VERSION_MINOR) "." \
57 __XSTRING(IXL_DRIVER_VERSION_BUILD) "-k"
58
59/*********************************************************************

--- 61 unchanged lines hidden (view full) ---

121#ifdef PCI_IOV
122static void ixl_if_vflr_handle(if_ctx_t ctx);
123#endif
124
125/*** Other ***/
126static u_int ixl_mc_filter_apply(void *, struct sockaddr_dl *, u_int);
127static void ixl_save_pf_tunables(struct ixl_pf *);
128static int ixl_allocate_pci_resources(struct ixl_pf *);
52#define IXL_DRIVER_VERSION_BUILD 0
53
54#define IXL_DRIVER_VERSION_STRING \
55 __XSTRING(IXL_DRIVER_VERSION_MAJOR) "." \
56 __XSTRING(IXL_DRIVER_VERSION_MINOR) "." \
57 __XSTRING(IXL_DRIVER_VERSION_BUILD) "-k"
58
59/*********************************************************************

--- 61 unchanged lines hidden (view full) ---

121#ifdef PCI_IOV
122static void ixl_if_vflr_handle(if_ctx_t ctx);
123#endif
124
125/*** Other ***/
126static u_int ixl_mc_filter_apply(void *, struct sockaddr_dl *, u_int);
127static void ixl_save_pf_tunables(struct ixl_pf *);
128static int ixl_allocate_pci_resources(struct ixl_pf *);
129static void ixl_setup_ssctx(struct ixl_pf *pf);
130static void ixl_admin_timer(void *arg);
129
130/*********************************************************************
131 * FreeBSD Device Interface Entry Points
132 *********************************************************************/
133
134static device_method_t ixl_methods[] = {
135 /* Device interface */
136 DEVMETHOD(device_register, ixl_register),

--- 69 unchanged lines hidden (view full) ---

206
207/*
208** TUNEABLE PARAMETERS:
209*/
210
211static SYSCTL_NODE(_hw, OID_AUTO, ixl, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
212 "ixl driver parameters");
213
131
132/*********************************************************************
133 * FreeBSD Device Interface Entry Points
134 *********************************************************************/
135
136static device_method_t ixl_methods[] = {
137 /* Device interface */
138 DEVMETHOD(device_register, ixl_register),

--- 69 unchanged lines hidden (view full) ---

208
209/*
210** TUNEABLE PARAMETERS:
211*/
212
213static SYSCTL_NODE(_hw, OID_AUTO, ixl, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
214 "ixl driver parameters");
215
216#ifdef IXL_DEBUG_FC
214/*
215 * Leave this on unless you need to send flow control
216 * frames (or other control frames) from software
217 */
218static int ixl_enable_tx_fc_filter = 1;
219TUNABLE_INT("hw.ixl.enable_tx_fc_filter",
220 &ixl_enable_tx_fc_filter);
221SYSCTL_INT(_hw_ixl, OID_AUTO, enable_tx_fc_filter, CTLFLAG_RDTUN,
222 &ixl_enable_tx_fc_filter, 0,
223 "Filter out packets with Ethertype 0x8808 from being sent out by non-HW sources");
217/*
218 * Leave this on unless you need to send flow control
219 * frames (or other control frames) from software
220 */
221static int ixl_enable_tx_fc_filter = 1;
222TUNABLE_INT("hw.ixl.enable_tx_fc_filter",
223 &ixl_enable_tx_fc_filter);
224SYSCTL_INT(_hw_ixl, OID_AUTO, enable_tx_fc_filter, CTLFLAG_RDTUN,
225 &ixl_enable_tx_fc_filter, 0,
226 "Filter out packets with Ethertype 0x8808 from being sent out by non-HW sources");
227#endif
224
228
229#ifdef IXL_DEBUG
230static int ixl_debug_recovery_mode = 0;
231TUNABLE_INT("hw.ixl.debug_recovery_mode",
232 &ixl_debug_recovery_mode);
233SYSCTL_INT(_hw_ixl, OID_AUTO, debug_recovery_mode, CTLFLAG_RDTUN,
234 &ixl_debug_recovery_mode, 0,
235 "Act like when FW entered recovery mode (for debuging)");
236#endif
237
225static int ixl_i2c_access_method = 0;
226TUNABLE_INT("hw.ixl.i2c_access_method",
227 &ixl_i2c_access_method);
228SYSCTL_INT(_hw_ixl, OID_AUTO, i2c_access_method, CTLFLAG_RDTUN,
229 &ixl_i2c_access_method, 0,
230 IXL_SYSCTL_HELP_I2C_METHOD);
231
232static int ixl_enable_vf_loopback = 1;

--- 117 unchanged lines hidden (view full) ---

350 device_t dev = iflib_get_dev(pf->vsi.ctx);
351 struct i40e_hw *hw = &pf->hw;
352 int rid;
353
354 /* Map BAR0 */
355 rid = PCIR_BAR(0);
356 pf->pci_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
357 &rid, RF_ACTIVE);
238static int ixl_i2c_access_method = 0;
239TUNABLE_INT("hw.ixl.i2c_access_method",
240 &ixl_i2c_access_method);
241SYSCTL_INT(_hw_ixl, OID_AUTO, i2c_access_method, CTLFLAG_RDTUN,
242 &ixl_i2c_access_method, 0,
243 IXL_SYSCTL_HELP_I2C_METHOD);
244
245static int ixl_enable_vf_loopback = 1;

--- 117 unchanged lines hidden (view full) ---

363 device_t dev = iflib_get_dev(pf->vsi.ctx);
364 struct i40e_hw *hw = &pf->hw;
365 int rid;
366
367 /* Map BAR0 */
368 rid = PCIR_BAR(0);
369 pf->pci_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
370 &rid, RF_ACTIVE);
358
371
359 if (!(pf->pci_mem)) {
360 device_printf(dev, "Unable to allocate bus resource: PCI memory\n");
361 return (ENXIO);
362 }
363
364 /* Save off the PCI information */
365 hw->vendor_id = pci_get_vendor(dev);
366 hw->device_id = pci_get_device(dev);

--- 12 unchanged lines hidden (view full) ---

379 pf->osdep.mem_bus_space_handle =
380 rman_get_bushandle(pf->pci_mem);
381 pf->osdep.mem_bus_space_size = rman_get_size(pf->pci_mem);
382 pf->osdep.flush_reg = I40E_GLGEN_STAT;
383 pf->osdep.dev = dev;
384
385 pf->hw.hw_addr = (u8 *) &pf->osdep.mem_bus_space_handle;
386 pf->hw.back = &pf->osdep;
372 if (!(pf->pci_mem)) {
373 device_printf(dev, "Unable to allocate bus resource: PCI memory\n");
374 return (ENXIO);
375 }
376
377 /* Save off the PCI information */
378 hw->vendor_id = pci_get_vendor(dev);
379 hw->device_id = pci_get_device(dev);

--- 12 unchanged lines hidden (view full) ---

392 pf->osdep.mem_bus_space_handle =
393 rman_get_bushandle(pf->pci_mem);
394 pf->osdep.mem_bus_space_size = rman_get_size(pf->pci_mem);
395 pf->osdep.flush_reg = I40E_GLGEN_STAT;
396 pf->osdep.dev = dev;
397
398 pf->hw.hw_addr = (u8 *) &pf->osdep.mem_bus_space_handle;
399 pf->hw.back = &pf->osdep;
387
400
388 return (0);
401 return (0);
389 }
402}
390
403
404static void
405ixl_setup_ssctx(struct ixl_pf *pf)
406{
407 if_softc_ctx_t scctx = pf->vsi.shared;
408 struct i40e_hw *hw = &pf->hw;
409
410 if (IXL_PF_IN_RECOVERY_MODE(pf)) {
411 scctx->isc_ntxqsets_max = scctx->isc_nrxqsets_max = 1;
412 scctx->isc_ntxqsets = scctx->isc_nrxqsets = 1;
413 } else if (hw->mac.type == I40E_MAC_X722)
414 scctx->isc_ntxqsets_max = scctx->isc_nrxqsets_max = 128;
415 else
416 scctx->isc_ntxqsets_max = scctx->isc_nrxqsets_max = 64;
417
418 if (pf->vsi.enable_head_writeback) {
419 scctx->isc_txqsizes[0] = roundup2(scctx->isc_ntxd[0]
420 * sizeof(struct i40e_tx_desc) + sizeof(u32), DBA_ALIGN);
421 scctx->isc_txrx = &ixl_txrx_hwb;
422 } else {
423 scctx->isc_txqsizes[0] = roundup2(scctx->isc_ntxd[0]
424 * sizeof(struct i40e_tx_desc), DBA_ALIGN);
425 scctx->isc_txrx = &ixl_txrx_dwb;
426 }
427
428 scctx->isc_txrx->ift_legacy_intr = ixl_intr;
429 scctx->isc_rxqsizes[0] = roundup2(scctx->isc_nrxd[0]
430 * sizeof(union i40e_32byte_rx_desc), DBA_ALIGN);
431 scctx->isc_msix_bar = PCIR_BAR(IXL_MSIX_BAR);
432 scctx->isc_tx_nsegments = IXL_MAX_TX_SEGS;
433 scctx->isc_tx_tso_segments_max = IXL_MAX_TSO_SEGS;
434 scctx->isc_tx_tso_size_max = IXL_TSO_SIZE;
435 scctx->isc_tx_tso_segsize_max = IXL_MAX_DMA_SEG_SIZE;
436 scctx->isc_rss_table_size = pf->hw.func_caps.rss_table_size;
437 scctx->isc_tx_csum_flags = CSUM_OFFLOAD;
438 scctx->isc_capabilities = scctx->isc_capenable = IXL_CAPS;
439}
440
441static void
442ixl_admin_timer(void *arg)
443{
444 struct ixl_pf *pf = (struct ixl_pf *)arg;
445
446 /* Fire off the admin task */
447 iflib_admin_intr_deferred(pf->vsi.ctx);
448
449 /* Reschedule the admin timer */
450 callout_schedule(&pf->admin_timer, hz/2);
451}
452
391static int
453static int
454ixl_attach_pre_recovery_mode(struct ixl_pf *pf)
455{
456 struct ixl_vsi *vsi = &pf->vsi;
457 struct i40e_hw *hw = &pf->hw;
458 device_t dev = pf->dev;
459
460 device_printf(dev, "Firmware recovery mode detected. Limiting functionality. Refer to Intel(R) Ethernet Adapters and Devices User Guide for details on firmware recovery mode.\n");
461
462 i40e_get_mac_addr(hw, hw->mac.addr);
463
464 if (vsi->shared->isc_intr == IFLIB_INTR_MSIX) {
465 ixl_configure_intr0_msix(pf);
466 ixl_enable_intr0(hw);
467 }
468
469 ixl_setup_ssctx(pf);
470
471 return (0);
472}
473
474static int
392ixl_if_attach_pre(if_ctx_t ctx)
393{
394 device_t dev;
395 struct ixl_pf *pf;
396 struct i40e_hw *hw;
397 struct ixl_vsi *vsi;
475ixl_if_attach_pre(if_ctx_t ctx)
476{
477 device_t dev;
478 struct ixl_pf *pf;
479 struct i40e_hw *hw;
480 struct ixl_vsi *vsi;
398 if_softc_ctx_t scctx;
481 enum i40e_get_fw_lldp_status_resp lldp_status;
399 struct i40e_filter_control_settings filter;
400 enum i40e_status_code status;
401 int error = 0;
402
403 dev = iflib_get_dev(ctx);
404 pf = iflib_get_softc(ctx);
405
406 INIT_DBG_DEV(dev, "begin");

--- 4 unchanged lines hidden (view full) ---

411 hw = &pf->hw;
412
413 vsi->dev = dev;
414 vsi->hw = &pf->hw;
415 vsi->id = 0;
416 vsi->num_vlans = 0;
417 vsi->ctx = ctx;
418 vsi->media = iflib_get_media(ctx);
482 struct i40e_filter_control_settings filter;
483 enum i40e_status_code status;
484 int error = 0;
485
486 dev = iflib_get_dev(ctx);
487 pf = iflib_get_softc(ctx);
488
489 INIT_DBG_DEV(dev, "begin");

--- 4 unchanged lines hidden (view full) ---

494 hw = &pf->hw;
495
496 vsi->dev = dev;
497 vsi->hw = &pf->hw;
498 vsi->id = 0;
499 vsi->num_vlans = 0;
500 vsi->ctx = ctx;
501 vsi->media = iflib_get_media(ctx);
419 vsi->shared = scctx = iflib_get_softc_ctx(ctx);
502 vsi->shared = iflib_get_softc_ctx(ctx);
420
503
504 snprintf(pf->admin_mtx_name, sizeof(pf->admin_mtx_name),
505 "%s:admin", device_get_nameunit(dev));
506 mtx_init(&pf->admin_mtx, pf->admin_mtx_name, NULL, MTX_DEF);
507 callout_init_mtx(&pf->admin_timer, &pf->admin_mtx, 0);
508
421 /* Save tunable values */
422 ixl_save_pf_tunables(pf);
423
424 /* Do PCI setup - map BAR0, etc */
425 if (ixl_allocate_pci_resources(pf)) {
426 device_printf(dev, "Allocation of PCI resources failed\n");
427 error = ENXIO;
428 goto err_pci_res;
429 }
430
431 /* Establish a clean starting point */
432 i40e_clear_hw(hw);
509 /* Save tunable values */
510 ixl_save_pf_tunables(pf);
511
512 /* Do PCI setup - map BAR0, etc */
513 if (ixl_allocate_pci_resources(pf)) {
514 device_printf(dev, "Allocation of PCI resources failed\n");
515 error = ENXIO;
516 goto err_pci_res;
517 }
518
519 /* Establish a clean starting point */
520 i40e_clear_hw(hw);
433 status = i40e_pf_reset(hw);
434 if (status) {
435 device_printf(dev, "PF reset failure %s\n",
436 i40e_stat_str(hw, status));
437 error = EIO;
521 i40e_set_mac_type(hw);
522
523 error = ixl_pf_reset(pf);
524 if (error)
438 goto err_out;
525 goto err_out;
439 }
440
441 /* Initialize the shared code */
442 status = i40e_init_shared_code(hw);
443 if (status) {
444 device_printf(dev, "Unable to initialize shared code, error %s\n",
445 i40e_stat_str(hw, status));
446 error = EIO;
447 goto err_out;

--- 30 unchanged lines hidden (view full) ---

478 device_printf(dev, "Please install the most recent version "
479 "of the network driver.\n");
480 } else if (hw->aq.api_maj_ver == 1 && hw->aq.api_min_ver < 4) {
481 device_printf(dev, "The driver for the device detected "
482 "an older version of the NVM image than expected.\n");
483 device_printf(dev, "Please update the NVM image.\n");
484 }
485
526
527 /* Initialize the shared code */
528 status = i40e_init_shared_code(hw);
529 if (status) {
530 device_printf(dev, "Unable to initialize shared code, error %s\n",
531 i40e_stat_str(hw, status));
532 error = EIO;
533 goto err_out;

--- 30 unchanged lines hidden (view full) ---

564 device_printf(dev, "Please install the most recent version "
565 "of the network driver.\n");
566 } else if (hw->aq.api_maj_ver == 1 && hw->aq.api_min_ver < 4) {
567 device_printf(dev, "The driver for the device detected "
568 "an older version of the NVM image than expected.\n");
569 device_printf(dev, "Please update the NVM image.\n");
570 }
571
572 if (IXL_PF_IN_RECOVERY_MODE(pf)) {
573 error = ixl_attach_pre_recovery_mode(pf);
574 if (error)
575 goto err_out;
576 return (error);
577 }
578
486 /* Clear PXE mode */
487 i40e_clear_pxe_mode(hw);
488
489 /* Get capabilities from the device */
490 error = ixl_get_hw_capabilities(pf);
491 if (error) {
492 device_printf(dev, "get_hw_capabilities failed: %d\n",
493 error);
494 goto err_get_cap;
495 }
496
497 /* Set up host memory cache */
579 /* Clear PXE mode */
580 i40e_clear_pxe_mode(hw);
581
582 /* Get capabilities from the device */
583 error = ixl_get_hw_capabilities(pf);
584 if (error) {
585 device_printf(dev, "get_hw_capabilities failed: %d\n",
586 error);
587 goto err_get_cap;
588 }
589
590 /* Set up host memory cache */
498 status = i40e_init_lan_hmc(hw, hw->func_caps.num_tx_qp,
499 hw->func_caps.num_rx_qp, 0, 0);
500 if (status) {
501 device_printf(dev, "init_lan_hmc failed: %s\n",
502 i40e_stat_str(hw, status));
503 goto err_get_cap;
504 }
505 status = i40e_configure_lan_hmc(hw, I40E_HMC_MODEL_DIRECT_ONLY);
506 if (status) {
507 device_printf(dev, "configure_lan_hmc failed: %s\n",
508 i40e_stat_str(hw, status));
591 error = ixl_setup_hmc(pf);
592 if (error)
509 goto err_mac_hmc;
593 goto err_mac_hmc;
510 }
511
512 /* Disable LLDP from the firmware for certain NVM versions */
513 if (((pf->hw.aq.fw_maj_ver == 4) && (pf->hw.aq.fw_min_ver < 3)) ||
514 (pf->hw.aq.fw_maj_ver < 4)) {
594
595 /* Disable LLDP from the firmware for certain NVM versions */
596 if (((pf->hw.aq.fw_maj_ver == 4) && (pf->hw.aq.fw_min_ver < 3)) ||
597 (pf->hw.aq.fw_maj_ver < 4)) {
515 i40e_aq_stop_lldp(hw, TRUE, NULL);
598 i40e_aq_stop_lldp(hw, true, false, NULL);
516 pf->state |= IXL_PF_STATE_FW_LLDP_DISABLED;
517 }
518
519 /* Get MAC addresses from hardware */
520 i40e_get_mac_addr(hw, hw->mac.addr);
521 error = i40e_validate_mac_addr(hw->mac.addr);
522 if (error) {
523 device_printf(dev, "validate_mac_addr failed: %d\n", error);

--- 8 unchanged lines hidden (view full) ---

532 filter.enable_ethtype = TRUE;
533 filter.enable_macvlan = TRUE;
534 filter.enable_fdir = FALSE;
535 filter.hash_lut_size = I40E_HASH_LUT_SIZE_512;
536 if (i40e_set_filter_control(hw, &filter))
537 device_printf(dev, "i40e_set_filter_control() failed\n");
538
539 /* Query device FW LLDP status */
599 pf->state |= IXL_PF_STATE_FW_LLDP_DISABLED;
600 }
601
602 /* Get MAC addresses from hardware */
603 i40e_get_mac_addr(hw, hw->mac.addr);
604 error = i40e_validate_mac_addr(hw->mac.addr);
605 if (error) {
606 device_printf(dev, "validate_mac_addr failed: %d\n", error);

--- 8 unchanged lines hidden (view full) ---

615 filter.enable_ethtype = TRUE;
616 filter.enable_macvlan = TRUE;
617 filter.enable_fdir = FALSE;
618 filter.hash_lut_size = I40E_HASH_LUT_SIZE_512;
619 if (i40e_set_filter_control(hw, &filter))
620 device_printf(dev, "i40e_set_filter_control() failed\n");
621
622 /* Query device FW LLDP status */
540 ixl_get_fw_lldp_status(pf);
623 if (i40e_get_fw_lldp_status(hw, &lldp_status) == I40E_SUCCESS) {
624 if (lldp_status == I40E_GET_FW_LLDP_STATUS_DISABLED) {
625 atomic_set_32(&pf->state,
626 IXL_PF_STATE_FW_LLDP_DISABLED);
627 } else {
628 atomic_clear_32(&pf->state,
629 IXL_PF_STATE_FW_LLDP_DISABLED);
630 }
631 }
632
541 /* Tell FW to apply DCB config on link up */
542 i40e_aq_set_dcb_parameters(hw, true, NULL);
543
544 /* Fill out iflib parameters */
633 /* Tell FW to apply DCB config on link up */
634 i40e_aq_set_dcb_parameters(hw, true, NULL);
635
636 /* Fill out iflib parameters */
545 if (hw->mac.type == I40E_MAC_X722)
546 scctx->isc_ntxqsets_max = scctx->isc_nrxqsets_max = 128;
547 else
548 scctx->isc_ntxqsets_max = scctx->isc_nrxqsets_max = 64;
549 if (vsi->enable_head_writeback) {
550 scctx->isc_txqsizes[0] = roundup2(scctx->isc_ntxd[0]
551 * sizeof(struct i40e_tx_desc) + sizeof(u32), DBA_ALIGN);
552 scctx->isc_txrx = &ixl_txrx_hwb;
553 } else {
554 scctx->isc_txqsizes[0] = roundup2(scctx->isc_ntxd[0]
555 * sizeof(struct i40e_tx_desc), DBA_ALIGN);
556 scctx->isc_txrx = &ixl_txrx_dwb;
557 }
558 scctx->isc_txrx->ift_legacy_intr = ixl_intr;
559 scctx->isc_rxqsizes[0] = roundup2(scctx->isc_nrxd[0]
560 * sizeof(union i40e_32byte_rx_desc), DBA_ALIGN);
561 scctx->isc_msix_bar = PCIR_BAR(IXL_MSIX_BAR);
562 scctx->isc_tx_nsegments = IXL_MAX_TX_SEGS;
563 scctx->isc_tx_tso_segments_max = IXL_MAX_TSO_SEGS;
564 scctx->isc_tx_tso_size_max = IXL_TSO_SIZE;
565 scctx->isc_tx_tso_segsize_max = IXL_MAX_DMA_SEG_SIZE;
566 scctx->isc_rss_table_size = pf->hw.func_caps.rss_table_size;
567 scctx->isc_tx_csum_flags = CSUM_OFFLOAD;
568 scctx->isc_capabilities = scctx->isc_capenable = IXL_CAPS;
637 ixl_setup_ssctx(pf);
569
570 INIT_DBG_DEV(dev, "end");
571 return (0);
572
573err_mac_hmc:
638
639 INIT_DBG_DEV(dev, "end");
640 return (0);
641
642err_mac_hmc:
574 i40e_shutdown_lan_hmc(hw);
643 ixl_shutdown_hmc(pf);
575err_get_cap:
576 i40e_shutdown_adminq(hw);
577err_out:
578 ixl_free_pci_resources(pf);
579err_pci_res:
644err_get_cap:
645 i40e_shutdown_adminq(hw);
646err_out:
647 ixl_free_pci_resources(pf);
648err_pci_res:
649 mtx_lock(&pf->admin_mtx);
650 callout_stop(&pf->admin_timer);
651 mtx_unlock(&pf->admin_mtx);
652 mtx_destroy(&pf->admin_mtx);
580 return (error);
581}
582
583static int
584ixl_if_attach_post(if_ctx_t ctx)
585{
586 device_t dev;
587 struct ixl_pf *pf;

--- 17 unchanged lines hidden (view full) ---

605
606 /* Setup OS network interface / ifnet */
607 if (ixl_setup_interface(dev, pf)) {
608 device_printf(dev, "interface setup failed!\n");
609 error = EIO;
610 goto err;
611 }
612
653 return (error);
654}
655
656static int
657ixl_if_attach_post(if_ctx_t ctx)
658{
659 device_t dev;
660 struct ixl_pf *pf;

--- 17 unchanged lines hidden (view full) ---

678
679 /* Setup OS network interface / ifnet */
680 if (ixl_setup_interface(dev, pf)) {
681 device_printf(dev, "interface setup failed!\n");
682 error = EIO;
683 goto err;
684 }
685
686 if (IXL_PF_IN_RECOVERY_MODE(pf)) {
687 /* Keep admin queue interrupts active while driver is loaded */
688 if (vsi->shared->isc_intr == IFLIB_INTR_MSIX) {
689 ixl_configure_intr0_msix(pf);
690 ixl_enable_intr0(hw);
691 }
692
693 ixl_add_sysctls_recovery_mode(pf);
694
695 /* Start the admin timer */
696 mtx_lock(&pf->admin_mtx);
697 callout_reset(&pf->admin_timer, hz/2, ixl_admin_timer, pf);
698 mtx_unlock(&pf->admin_mtx);
699 return (0);
700 }
701
613 /* Determine link state */
614 if (ixl_attach_get_link_status(pf)) {
615 error = EINVAL;
616 goto err;
617 }
618
619 error = ixl_switch_config(pf);
620 if (error) {

--- 74 unchanged lines hidden (view full) ---

695 } else
696 device_printf(dev, "iWARP disabled on this device "
697 "(no MSI-X vectors)\n");
698 } else {
699 pf->iw_enabled = false;
700 device_printf(dev, "The device is not iWARP enabled\n");
701 }
702#endif
702 /* Determine link state */
703 if (ixl_attach_get_link_status(pf)) {
704 error = EINVAL;
705 goto err;
706 }
707
708 error = ixl_switch_config(pf);
709 if (error) {

--- 74 unchanged lines hidden (view full) ---

784 } else
785 device_printf(dev, "iWARP disabled on this device "
786 "(no MSI-X vectors)\n");
787 } else {
788 pf->iw_enabled = false;
789 device_printf(dev, "The device is not iWARP enabled\n");
790 }
791#endif
792 /* Start the admin timer */
793 mtx_lock(&pf->admin_mtx);
794 callout_reset(&pf->admin_timer, hz/2, ixl_admin_timer, pf);
795 mtx_unlock(&pf->admin_mtx);
703
704 INIT_DBG_DEV(dev, "end");
705 return (0);
706
707err:
708 INIT_DEBUGOUT("end: error %d", error);
709 /* ixl_if_detach() is called on error from this */
710 return (error);

--- 12 unchanged lines hidden (view full) ---

723 device_t dev = pf->dev;
724 enum i40e_status_code status;
725#ifdef IXL_IW
726 int error;
727#endif
728
729 INIT_DBG_DEV(dev, "begin");
730
796
797 INIT_DBG_DEV(dev, "end");
798 return (0);
799
800err:
801 INIT_DEBUGOUT("end: error %d", error);
802 /* ixl_if_detach() is called on error from this */
803 return (error);

--- 12 unchanged lines hidden (view full) ---

816 device_t dev = pf->dev;
817 enum i40e_status_code status;
818#ifdef IXL_IW
819 int error;
820#endif
821
822 INIT_DBG_DEV(dev, "begin");
823
824 /* Stop the admin timer */
825 mtx_lock(&pf->admin_mtx);
826 callout_stop(&pf->admin_timer);
827 mtx_unlock(&pf->admin_mtx);
828 mtx_destroy(&pf->admin_mtx);
829
731#ifdef IXL_IW
732 if (ixl_enable_iwarp && pf->iw_enabled) {
733 error = ixl_iw_pf_detach(pf);
734 if (error == EBUSY) {
735 device_printf(dev, "iwarp in use; stop it first.\n");
736 //return (error);
737 }
738 }
739#endif
740 /* Remove all previously allocated media types */
741 ifmedia_removeall(vsi->media);
742
743 /* Shutdown LAN HMC */
830#ifdef IXL_IW
831 if (ixl_enable_iwarp && pf->iw_enabled) {
832 error = ixl_iw_pf_detach(pf);
833 if (error == EBUSY) {
834 device_printf(dev, "iwarp in use; stop it first.\n");
835 //return (error);
836 }
837 }
838#endif
839 /* Remove all previously allocated media types */
840 ifmedia_removeall(vsi->media);
841
842 /* Shutdown LAN HMC */
744 if (hw->hmc.hmc_obj) {
745 status = i40e_shutdown_lan_hmc(hw);
746 if (status)
747 device_printf(dev,
748 "i40e_shutdown_lan_hmc() failed with status %s\n",
749 i40e_stat_str(hw, status));
750 }
843 ixl_shutdown_hmc(pf);
751
752 /* Shutdown admin queue */
753 ixl_disable_intr0(hw);
754 status = i40e_shutdown_adminq(hw);
755 if (status)
756 device_printf(dev,
757 "i40e_shutdown_adminq() failed with status %s\n",
758 i40e_stat_str(hw, status));

--- 55 unchanged lines hidden (view full) ---

814 struct ixl_pf *pf = iflib_get_softc(ctx);
815 struct ixl_vsi *vsi = &pf->vsi;
816 struct i40e_hw *hw = &pf->hw;
817 struct ifnet *ifp = iflib_get_ifp(ctx);
818 device_t dev = iflib_get_dev(ctx);
819 u8 tmpaddr[ETHER_ADDR_LEN];
820 int ret;
821
844
845 /* Shutdown admin queue */
846 ixl_disable_intr0(hw);
847 status = i40e_shutdown_adminq(hw);
848 if (status)
849 device_printf(dev,
850 "i40e_shutdown_adminq() failed with status %s\n",
851 i40e_stat_str(hw, status));

--- 55 unchanged lines hidden (view full) ---

907 struct ixl_pf *pf = iflib_get_softc(ctx);
908 struct ixl_vsi *vsi = &pf->vsi;
909 struct i40e_hw *hw = &pf->hw;
910 struct ifnet *ifp = iflib_get_ifp(ctx);
911 device_t dev = iflib_get_dev(ctx);
912 u8 tmpaddr[ETHER_ADDR_LEN];
913 int ret;
914
915 if (IXL_PF_IN_RECOVERY_MODE(pf))
916 return;
822 /*
823 * If the aq is dead here, it probably means something outside of the driver
824 * did something to the adapter, like a PF reset.
825 * So, rebuild the driver's state here if that occurs.
826 */
827 if (!i40e_check_asq_alive(&pf->hw)) {
828 device_printf(dev, "Admin Queue is down; resetting...\n");
829 ixl_teardown_hw_structs(pf);
917 /*
918 * If the aq is dead here, it probably means something outside of the driver
919 * did something to the adapter, like a PF reset.
920 * So, rebuild the driver's state here if that occurs.
921 */
922 if (!i40e_check_asq_alive(&pf->hw)) {
923 device_printf(dev, "Admin Queue is down; resetting...\n");
924 ixl_teardown_hw_structs(pf);
830 ixl_rebuild_hw_structs_after_reset(pf);
925 ixl_rebuild_hw_structs_after_reset(pf, false);
831 }
832
833 /* Get the latest mac address... User might use a LAA */
834 bcopy(IF_LLADDR(vsi->ifp), tmpaddr, ETH_ALEN);
835 if (!cmp_etheraddr(hw->mac.addr, tmpaddr) &&
836 (i40e_validate_mac_addr(tmpaddr) == I40E_SUCCESS)) {
837 ixl_del_filter(vsi, hw->mac.addr, IXL_VLAN_ANY);
838 bcopy(tmpaddr, hw->mac.addr, ETH_ALEN);

--- 9 unchanged lines hidden (view full) ---

848
849 iflib_set_mac(ctx, hw->mac.addr);
850
851 /* Prepare the VSI: rings, hmc contexts, etc... */
852 if (ixl_initialize_vsi(vsi)) {
853 device_printf(dev, "initialize vsi failed!!\n");
854 return;
855 }
926 }
927
928 /* Get the latest mac address... User might use a LAA */
929 bcopy(IF_LLADDR(vsi->ifp), tmpaddr, ETH_ALEN);
930 if (!cmp_etheraddr(hw->mac.addr, tmpaddr) &&
931 (i40e_validate_mac_addr(tmpaddr) == I40E_SUCCESS)) {
932 ixl_del_filter(vsi, hw->mac.addr, IXL_VLAN_ANY);
933 bcopy(tmpaddr, hw->mac.addr, ETH_ALEN);

--- 9 unchanged lines hidden (view full) ---

943
944 iflib_set_mac(ctx, hw->mac.addr);
945
946 /* Prepare the VSI: rings, hmc contexts, etc... */
947 if (ixl_initialize_vsi(vsi)) {
948 device_printf(dev, "initialize vsi failed!!\n");
949 return;
950 }
856
951
857 /* Reconfigure multicast filters in HW */
858 ixl_if_multi_set(ctx);
859
860 /* Set up RSS */
861 ixl_config_rss(pf);
862
863 /* Set up MSI-X routing and the ITR settings */
864 if (vsi->shared->isc_intr == IFLIB_INTR_MSIX) {

--- 30 unchanged lines hidden (view full) ---

895void
896ixl_if_stop(if_ctx_t ctx)
897{
898 struct ixl_pf *pf = iflib_get_softc(ctx);
899 struct ixl_vsi *vsi = &pf->vsi;
900
901 INIT_DEBUGOUT("ixl_if_stop: begin\n");
902
952 /* Reconfigure multicast filters in HW */
953 ixl_if_multi_set(ctx);
954
955 /* Set up RSS */
956 ixl_config_rss(pf);
957
958 /* Set up MSI-X routing and the ITR settings */
959 if (vsi->shared->isc_intr == IFLIB_INTR_MSIX) {

--- 30 unchanged lines hidden (view full) ---

990void
991ixl_if_stop(if_ctx_t ctx)
992{
993 struct ixl_pf *pf = iflib_get_softc(ctx);
994 struct ixl_vsi *vsi = &pf->vsi;
995
996 INIT_DEBUGOUT("ixl_if_stop: begin\n");
997
998 if (IXL_PF_IN_RECOVERY_MODE(pf))
999 return;
1000
903 // TODO: This may need to be reworked
904#ifdef IXL_IW
905 /* Stop iWARP device */
906 if (ixl_enable_iwarp && pf->iw_enabled)
907 ixl_iw_pf_stop(pf);
908#endif
909
910 ixl_disable_rings_intr(vsi);

--- 149 unchanged lines hidden (view full) ---

1060 MPASS(scctx->isc_ntxqsets == ntxqsets);
1061
1062 /* Allocate queue structure memory */
1063 if (!(vsi->tx_queues =
1064 (struct ixl_tx_queue *) malloc(sizeof(struct ixl_tx_queue) *ntxqsets, M_IXL, M_NOWAIT | M_ZERO))) {
1065 device_printf(iflib_get_dev(ctx), "Unable to allocate TX ring memory\n");
1066 return (ENOMEM);
1067 }
1001 // TODO: This may need to be reworked
1002#ifdef IXL_IW
1003 /* Stop iWARP device */
1004 if (ixl_enable_iwarp && pf->iw_enabled)
1005 ixl_iw_pf_stop(pf);
1006#endif
1007
1008 ixl_disable_rings_intr(vsi);

--- 149 unchanged lines hidden (view full) ---

1158 MPASS(scctx->isc_ntxqsets == ntxqsets);
1159
1160 /* Allocate queue structure memory */
1161 if (!(vsi->tx_queues =
1162 (struct ixl_tx_queue *) malloc(sizeof(struct ixl_tx_queue) *ntxqsets, M_IXL, M_NOWAIT | M_ZERO))) {
1163 device_printf(iflib_get_dev(ctx), "Unable to allocate TX ring memory\n");
1164 return (ENOMEM);
1165 }
1068
1166
1069 for (i = 0, que = vsi->tx_queues; i < ntxqsets; i++, que++) {
1070 struct tx_ring *txr = &que->txr;
1071
1072 txr->me = i;
1073 que->vsi = vsi;
1074
1075 if (!vsi->enable_head_writeback) {
1076 /* Allocate report status array */

--- 7 unchanged lines hidden (view full) ---

1084 txr->tx_rsq[j] = QIDX_INVALID;
1085 }
1086 /* get the virtual and physical address of the hardware queues */
1087 txr->tail = I40E_QTX_TAIL(txr->me);
1088 txr->tx_base = (struct i40e_tx_desc *)vaddrs[i * ntxqs];
1089 txr->tx_paddr = paddrs[i * ntxqs];
1090 txr->que = que;
1091 }
1167 for (i = 0, que = vsi->tx_queues; i < ntxqsets; i++, que++) {
1168 struct tx_ring *txr = &que->txr;
1169
1170 txr->me = i;
1171 que->vsi = vsi;
1172
1173 if (!vsi->enable_head_writeback) {
1174 /* Allocate report status array */

--- 7 unchanged lines hidden (view full) ---

1182 txr->tx_rsq[j] = QIDX_INVALID;
1183 }
1184 /* get the virtual and physical address of the hardware queues */
1185 txr->tail = I40E_QTX_TAIL(txr->me);
1186 txr->tx_base = (struct i40e_tx_desc *)vaddrs[i * ntxqs];
1187 txr->tx_paddr = paddrs[i * ntxqs];
1188 txr->que = que;
1189 }
1092
1190
1093 return (0);
1094fail:
1095 ixl_if_queues_free(ctx);
1096 return (error);
1097}
1098
1099static int
1100ixl_if_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs, int nrxqs, int nrxqsets)

--- 60 unchanged lines hidden (view full) ---

1161 if (vsi->tx_queues != NULL) {
1162 free(vsi->tx_queues, M_IXL);
1163 vsi->tx_queues = NULL;
1164 }
1165 if (vsi->rx_queues != NULL) {
1166 free(vsi->rx_queues, M_IXL);
1167 vsi->rx_queues = NULL;
1168 }
1191 return (0);
1192fail:
1193 ixl_if_queues_free(ctx);
1194 return (error);
1195}
1196
1197static int
1198ixl_if_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs, int nrxqs, int nrxqsets)

--- 60 unchanged lines hidden (view full) ---

1259 if (vsi->tx_queues != NULL) {
1260 free(vsi->tx_queues, M_IXL);
1261 vsi->tx_queues = NULL;
1262 }
1263 if (vsi->rx_queues != NULL) {
1264 free(vsi->rx_queues, M_IXL);
1265 vsi->rx_queues = NULL;
1266 }
1267
1268 if (!IXL_PF_IN_RECOVERY_MODE(pf))
1269 sysctl_ctx_free(&vsi->sysctl_ctx);
1169}
1170
1171void
1172ixl_update_link_status(struct ixl_pf *pf)
1173{
1174 struct ixl_vsi *vsi = &pf->vsi;
1175 struct i40e_hw *hw = &pf->hw;
1176 u64 baudrate;
1177
1270}
1271
1272void
1273ixl_update_link_status(struct ixl_pf *pf)
1274{
1275 struct ixl_vsi *vsi = &pf->vsi;
1276 struct i40e_hw *hw = &pf->hw;
1277 u64 baudrate;
1278
1178 if (pf->link_up) {
1279 if (pf->link_up) {
1179 if (vsi->link_active == FALSE) {
1180 vsi->link_active = TRUE;
1181 baudrate = ixl_max_aq_speed_to_value(hw->phy.link_info.link_speed);
1182 iflib_link_state_change(vsi->ctx, LINK_STATE_UP, baudrate);
1183 ixl_link_up_msg(pf);
1184#ifdef PCI_IOV
1185 ixl_broadcast_link_state(pf);
1186#endif
1280 if (vsi->link_active == FALSE) {
1281 vsi->link_active = TRUE;
1282 baudrate = ixl_max_aq_speed_to_value(hw->phy.link_info.link_speed);
1283 iflib_link_state_change(vsi->ctx, LINK_STATE_UP, baudrate);
1284 ixl_link_up_msg(pf);
1285#ifdef PCI_IOV
1286 ixl_broadcast_link_state(pf);
1287#endif
1187
1188 }
1189 } else { /* Link down */
1190 if (vsi->link_active == TRUE) {
1191 vsi->link_active = FALSE;
1192 iflib_link_state_change(vsi->ctx, LINK_STATE_DOWN, 0);
1193#ifdef PCI_IOV
1194 ixl_broadcast_link_state(pf);
1195#endif

--- 70 unchanged lines hidden (view full) ---

1266 wr32(hw, I40E_PFINT_ICR0_ENA, reg);
1267
1268 return (status);
1269}
1270
1271static void
1272ixl_if_update_admin_status(if_ctx_t ctx)
1273{
1288 }
1289 } else { /* Link down */
1290 if (vsi->link_active == TRUE) {
1291 vsi->link_active = FALSE;
1292 iflib_link_state_change(vsi->ctx, LINK_STATE_DOWN, 0);
1293#ifdef PCI_IOV
1294 ixl_broadcast_link_state(pf);
1295#endif

--- 70 unchanged lines hidden (view full) ---

1366 wr32(hw, I40E_PFINT_ICR0_ENA, reg);
1367
1368 return (status);
1369}
1370
1371static void
1372ixl_if_update_admin_status(if_ctx_t ctx)
1373{
1274 struct ixl_pf *pf = iflib_get_softc(ctx);
1275 struct i40e_hw *hw = &pf->hw;
1276 u16 pending;
1374 struct ixl_pf *pf = iflib_get_softc(ctx);
1375 struct i40e_hw *hw = &pf->hw;
1376 u16 pending;
1277
1278 if (pf->state & IXL_PF_STATE_ADAPTER_RESETTING)
1279 ixl_handle_empr_reset(pf);
1280
1377
1378 if (pf->state & IXL_PF_STATE_ADAPTER_RESETTING)
1379 ixl_handle_empr_reset(pf);
1380
1381 /*
1382 * Admin Queue is shut down while handling reset.
1383 * Don't proceed if it hasn't been re-initialized
1384 * e.g due to an issue with new FW.
1385 */
1386 if (!i40e_check_asq_alive(&pf->hw))
1387 return;
1388
1281 if (pf->state & IXL_PF_STATE_MDD_PENDING)
1282 ixl_handle_mdd_event(pf);
1283
1284 ixl_process_adminq(pf, &pending);
1285 ixl_update_link_status(pf);
1389 if (pf->state & IXL_PF_STATE_MDD_PENDING)
1390 ixl_handle_mdd_event(pf);
1391
1392 ixl_process_adminq(pf, &pending);
1393 ixl_update_link_status(pf);
1286 ixl_update_stats_counters(pf);
1287
1394
1288 /*
1289 * If there are still messages to process, reschedule ourselves.
1290 * Otherwise, re-enable our interrupt and go to sleep.
1291 */
1292 if (pending > 0)
1293 iflib_admin_intr_deferred(ctx);
1294 else
1295 ixl_enable_intr0(hw);

--- 221 unchanged lines hidden (view full) ---

1517 err = i40e_aq_set_vsi_multicast_promiscuous(hw,
1518 vsi->seid, multi, NULL);
1519 return (err);
1520}
1521
1522static void
1523ixl_if_timer(if_ctx_t ctx, uint16_t qid)
1524{
1395 /*
1396 * If there are still messages to process, reschedule ourselves.
1397 * Otherwise, re-enable our interrupt and go to sleep.
1398 */
1399 if (pending > 0)
1400 iflib_admin_intr_deferred(ctx);
1401 else
1402 ixl_enable_intr0(hw);

--- 221 unchanged lines hidden (view full) ---

1624 err = i40e_aq_set_vsi_multicast_promiscuous(hw,
1625 vsi->seid, multi, NULL);
1626 return (err);
1627}
1628
1629static void
1630ixl_if_timer(if_ctx_t ctx, uint16_t qid)
1631{
1632 struct ixl_pf *pf = iflib_get_softc(ctx);
1633
1525 if (qid != 0)
1526 return;
1527
1634 if (qid != 0)
1635 return;
1636
1528 /* Fire off the adminq task */
1529 iflib_admin_intr_deferred(ctx);
1637 ixl_update_stats_counters(pf);
1530}
1531
1532static void
1533ixl_if_vlan_register(if_ctx_t ctx, u16 vtag)
1534{
1535 struct ixl_pf *pf = iflib_get_softc(ctx);
1536 struct ixl_vsi *vsi = &pf->vsi;
1537 struct i40e_hw *hw = vsi->hw;

--- 147 unchanged lines hidden (view full) ---

1685 * Sanity check and save off tunable values.
1686 */
1687static void
1688ixl_save_pf_tunables(struct ixl_pf *pf)
1689{
1690 device_t dev = pf->dev;
1691
1692 /* Save tunable information */
1638}
1639
1640static void
1641ixl_if_vlan_register(if_ctx_t ctx, u16 vtag)
1642{
1643 struct ixl_pf *pf = iflib_get_softc(ctx);
1644 struct ixl_vsi *vsi = &pf->vsi;
1645 struct i40e_hw *hw = vsi->hw;

--- 147 unchanged lines hidden (view full) ---

1793 * Sanity check and save off tunable values.
1794 */
1795static void
1796ixl_save_pf_tunables(struct ixl_pf *pf)
1797{
1798 device_t dev = pf->dev;
1799
1800 /* Save tunable information */
1801#ifdef IXL_DEBUG_FC
1693 pf->enable_tx_fc_filter = ixl_enable_tx_fc_filter;
1802 pf->enable_tx_fc_filter = ixl_enable_tx_fc_filter;
1803#endif
1804#ifdef IXL_DEBUG
1805 pf->recovery_mode = ixl_debug_recovery_mode;
1806#endif
1694 pf->dbg_mask = ixl_core_debug_mask;
1695 pf->hw.debug_mask = ixl_shared_debug_mask;
1696 pf->vsi.enable_head_writeback = !!(ixl_enable_head_writeback);
1697 pf->enable_vf_loopback = !!(ixl_enable_vf_loopback);
1698#if 0
1699 pf->dynamic_rx_itr = ixl_dynamic_rx_itr;
1700 pf->dynamic_tx_itr = ixl_dynamic_tx_itr;
1701#endif

--- 31 unchanged lines hidden ---
1807 pf->dbg_mask = ixl_core_debug_mask;
1808 pf->hw.debug_mask = ixl_shared_debug_mask;
1809 pf->vsi.enable_head_writeback = !!(ixl_enable_head_writeback);
1810 pf->enable_vf_loopback = !!(ixl_enable_vf_loopback);
1811#if 0
1812 pf->dynamic_rx_itr = ixl_dynamic_rx_itr;
1813 pf->dynamic_tx_itr = ixl_dynamic_tx_itr;
1814#endif

--- 31 unchanged lines hidden ---