Deleted Added
full compact
if_ixl.c (292094) if_ixl.c (292095)
1/******************************************************************************
2
1/******************************************************************************
2
3 Copyright (c) 2013-2014, Intel Corporation
3 Copyright (c) 2013-2015, 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
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
11

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

25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
31
32******************************************************************************/
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
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
11

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

25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
31
32******************************************************************************/
33/*$FreeBSD: stable/10/sys/dev/ixl/if_ixl.c 292094 2015-12-11 12:16:05Z smh $*/
33/*$FreeBSD: stable/10/sys/dev/ixl/if_ixl.c 292095 2015-12-11 12:20:58Z smh $*/
34
34
35#ifndef IXL_STANDALONE_BUILD
35#include "opt_inet.h"
36#include "opt_inet6.h"
36#include "opt_inet.h"
37#include "opt_inet6.h"
38#endif
39
37#include "ixl.h"
38#include "ixl_pf.h"
39
40#ifdef RSS
41#include <net/rss_config.h>
42#endif
43
44/*********************************************************************
45 * Driver version
46 *********************************************************************/
40#include "ixl.h"
41#include "ixl_pf.h"
42
43#ifdef RSS
44#include <net/rss_config.h>
45#endif
46
47/*********************************************************************
48 * Driver version
49 *********************************************************************/
47char ixl_driver_version[] = "1.3.1";
50char ixl_driver_version[] = "1.3.6";
48
49/*********************************************************************
50 * PCI Device ID Table
51 *
52 * Used by probe to select devices to load on
53 * Last field stores an index into ixl_strings
54 * Last entry must be all 0s
55 *

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

93static void ixl_init_locked(struct ixl_pf *);
94static void ixl_stop(struct ixl_pf *);
95static void ixl_media_status(struct ifnet *, struct ifmediareq *);
96static int ixl_media_change(struct ifnet *);
97static void ixl_update_link_status(struct ixl_pf *);
98static int ixl_allocate_pci_resources(struct ixl_pf *);
99static u16 ixl_get_bus_info(struct i40e_hw *, device_t);
100static int ixl_setup_stations(struct ixl_pf *);
51
52/*********************************************************************
53 * PCI Device ID Table
54 *
55 * Used by probe to select devices to load on
56 * Last field stores an index into ixl_strings
57 * Last entry must be all 0s
58 *

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

96static void ixl_init_locked(struct ixl_pf *);
97static void ixl_stop(struct ixl_pf *);
98static void ixl_media_status(struct ifnet *, struct ifmediareq *);
99static int ixl_media_change(struct ifnet *);
100static void ixl_update_link_status(struct ixl_pf *);
101static int ixl_allocate_pci_resources(struct ixl_pf *);
102static u16 ixl_get_bus_info(struct i40e_hw *, device_t);
103static int ixl_setup_stations(struct ixl_pf *);
101static int ixl_setup_vsi(struct ixl_vsi *);
104static int ixl_switch_config(struct ixl_pf *);
102static int ixl_initialize_vsi(struct ixl_vsi *);
103static int ixl_assign_vsi_msix(struct ixl_pf *);
104static int ixl_assign_vsi_legacy(struct ixl_pf *);
105static int ixl_init_msix(struct ixl_pf *);
106static void ixl_configure_msix(struct ixl_pf *);
107static void ixl_configure_itr(struct ixl_pf *);
108static void ixl_configure_legacy(struct ixl_pf *);
109static void ixl_free_pci_resources(struct ixl_pf *);

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

493 i40e_clear_hw(hw);
494 error = i40e_pf_reset(hw);
495 if (error) {
496 device_printf(dev,"PF reset failure %x\n", error);
497 error = EIO;
498 goto err_out;
499 }
500
105static int ixl_initialize_vsi(struct ixl_vsi *);
106static int ixl_assign_vsi_msix(struct ixl_pf *);
107static int ixl_assign_vsi_legacy(struct ixl_pf *);
108static int ixl_init_msix(struct ixl_pf *);
109static void ixl_configure_msix(struct ixl_pf *);
110static void ixl_configure_itr(struct ixl_pf *);
111static void ixl_configure_legacy(struct ixl_pf *);
112static void ixl_free_pci_resources(struct ixl_pf *);

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

496 i40e_clear_hw(hw);
497 error = i40e_pf_reset(hw);
498 if (error) {
499 device_printf(dev,"PF reset failure %x\n", error);
500 error = EIO;
501 goto err_out;
502 }
503
501 /* For now always do an initial CORE reset on first device */
502 {
503 static int ixl_dev_count;
504 static int ixl_dev_track[32];
505 u32 my_dev;
506 int i, found = FALSE;
507 u16 bus = pci_get_bus(dev);
508
509 mtx_lock(&ixl_reset_mtx);
510 my_dev = (bus << 8) | hw->bus.device;
511
512 for (i = 0; i < ixl_dev_count; i++) {
513 if (ixl_dev_track[i] == my_dev)
514 found = TRUE;
515 }
516
517 if (!found) {
518 u32 reg;
519
520 ixl_dev_track[ixl_dev_count] = my_dev;
521 ixl_dev_count++;
522
523 INIT_DEBUGOUT("Initial CORE RESET\n");
524 wr32(hw, I40E_GLGEN_RTRIG, I40E_GLGEN_RTRIG_CORER_MASK);
525 ixl_flush(hw);
526 i = 50;
527 do {
528 i40e_msec_delay(50);
529 reg = rd32(hw, I40E_GLGEN_RSTAT);
530 if (!(reg & I40E_GLGEN_RSTAT_DEVSTATE_MASK))
531 break;
532 } while (i--);
533
534 /* paranoia */
535 wr32(hw, I40E_PF_ATQLEN, 0);
536 wr32(hw, I40E_PF_ATQBAL, 0);
537 wr32(hw, I40E_PF_ATQBAH, 0);
538 i40e_clear_pxe_mode(hw);
539 }
540 mtx_unlock(&ixl_reset_mtx);
541 }
542
543 /* Set admin queue parameters */
544 hw->aq.num_arq_entries = IXL_AQ_LEN;
545 hw->aq.num_asq_entries = IXL_AQ_LEN;
546 hw->aq.arq_buf_size = IXL_AQ_BUFSZ;
547 hw->aq.asq_buf_size = IXL_AQ_BUFSZ;
548
549 /* Initialize the shared code */
550 error = i40e_init_shared_code(hw);

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

624 /* Set up interrupt routing here */
625 if (pf->msix > 1)
626 error = ixl_assign_vsi_msix(pf);
627 else
628 error = ixl_assign_vsi_legacy(pf);
629 if (error)
630 goto err_late;
631
504 /* Set admin queue parameters */
505 hw->aq.num_arq_entries = IXL_AQ_LEN;
506 hw->aq.num_asq_entries = IXL_AQ_LEN;
507 hw->aq.arq_buf_size = IXL_AQ_BUFSZ;
508 hw->aq.asq_buf_size = IXL_AQ_BUFSZ;
509
510 /* Initialize the shared code */
511 error = i40e_init_shared_code(hw);

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

585 /* Set up interrupt routing here */
586 if (pf->msix > 1)
587 error = ixl_assign_vsi_msix(pf);
588 else
589 error = ixl_assign_vsi_legacy(pf);
590 if (error)
591 goto err_late;
592
632 i40e_msec_delay(75);
633 error = i40e_aq_set_link_restart_an(hw, TRUE, NULL);
634 if (error) {
635 device_printf(dev, "link restart failed, aq_err=%d\n",
636 pf->hw.aq.asq_last_status);
593 if (((hw->aq.fw_maj_ver == 4) && (hw->aq.fw_min_ver < 33)) ||
594 (hw->aq.fw_maj_ver < 4)) {
595 i40e_msec_delay(75);
596 error = i40e_aq_set_link_restart_an(hw, TRUE, NULL);
597 if (error)
598 device_printf(dev, "link restart failed, aq_err=%d\n",
599 pf->hw.aq.asq_last_status);
637 }
600 }
638
601
639 /* Determine link state */
640 vsi->link_up = ixl_config_link(hw);
641
642 /* Report if Unqualified modules are found */
643 if ((vsi->link_up == FALSE) &&
644 (pf->hw.phy.link_info.link_info &
645 I40E_AQ_MEDIA_AVAILABLE) &&
646 (!(pf->hw.phy.link_info.an_info &
647 I40E_AQ_QUALIFIED_MODULE)))
648 device_printf(dev, "Link failed because "
649 "an unqualified module was detected\n");
650
651 /* Setup OS specific network interface */
652 if (ixl_setup_interface(dev, vsi) != 0) {
653 device_printf(dev, "interface setup failed!\n");
654 error = EIO;
655 goto err_late;
656 }
657
602 /* Determine link state */
603 vsi->link_up = ixl_config_link(hw);
604
605 /* Report if Unqualified modules are found */
606 if ((vsi->link_up == FALSE) &&
607 (pf->hw.phy.link_info.link_info &
608 I40E_AQ_MEDIA_AVAILABLE) &&
609 (!(pf->hw.phy.link_info.an_info &
610 I40E_AQ_QUALIFIED_MODULE)))
611 device_printf(dev, "Link failed because "
612 "an unqualified module was detected\n");
613
614 /* Setup OS specific network interface */
615 if (ixl_setup_interface(dev, vsi) != 0) {
616 device_printf(dev, "interface setup failed!\n");
617 error = EIO;
618 goto err_late;
619 }
620
621 error = ixl_switch_config(pf);
622 if (error) {
623 device_printf(dev, "Initial switch config failed: %d\n", error);
624 goto err_mac_hmc;
625 }
626
627 /* Limit phy interrupts to link and modules failure */
628 error = i40e_aq_set_phy_int_mask(hw,
629 I40E_AQ_EVENT_LINK_UPDOWN | I40E_AQ_EVENT_MODULE_QUAL_FAIL, NULL);
630 if (error)
631 device_printf(dev, "set phy mask failed: %d\n", error);
632
658 /* Get the bus configuration and set the shared code */
659 bus = ixl_get_bus_info(hw, dev);
660 i40e_set_pci_config_data(hw, bus);
661
662 /* Initialize statistics */
663 ixl_pf_reset_stats(pf);
664 ixl_update_stats_counters(pf);
665 ixl_add_hw_stats(pf);
666
633 /* Get the bus configuration and set the shared code */
634 bus = ixl_get_bus_info(hw, dev);
635 i40e_set_pci_config_data(hw, bus);
636
637 /* Initialize statistics */
638 ixl_pf_reset_stats(pf);
639 ixl_update_stats_counters(pf);
640 ixl_add_hw_stats(pf);
641
667 /* Reset port's advertised speeds */
668 if (!i40e_is_40G_device(hw->device_id)) {
669 pf->advertised_speed =
670 (hw->device_id == I40E_DEV_ID_10G_BASE_T) ? 0x7 : 0x6;
671 ixl_set_advertised_speeds(pf, pf->advertised_speed);
672 }
673
674 /* Register for VLAN events */
675 vsi->vlan_attach = EVENTHANDLER_REGISTER(vlan_config,
676 ixl_register_vlan, vsi, EVENTHANDLER_PRI_FIRST);
677 vsi->vlan_detach = EVENTHANDLER_REGISTER(vlan_unconfig,
678 ixl_unregister_vlan, vsi, EVENTHANDLER_PRI_FIRST);
679
680
681 INIT_DEBUGOUT("ixl_attach: end");

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

717 INIT_DEBUGOUT("ixl_detach: begin");
718
719 /* Make sure VLANS are not using driver */
720 if (vsi->ifp->if_vlantrunk != NULL) {
721 device_printf(dev,"Vlan in use, detach first\n");
722 return (EBUSY);
723 }
724
642 /* Register for VLAN events */
643 vsi->vlan_attach = EVENTHANDLER_REGISTER(vlan_config,
644 ixl_register_vlan, vsi, EVENTHANDLER_PRI_FIRST);
645 vsi->vlan_detach = EVENTHANDLER_REGISTER(vlan_unconfig,
646 ixl_unregister_vlan, vsi, EVENTHANDLER_PRI_FIRST);
647
648
649 INIT_DEBUGOUT("ixl_attach: end");

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

685 INIT_DEBUGOUT("ixl_detach: begin");
686
687 /* Make sure VLANS are not using driver */
688 if (vsi->ifp->if_vlantrunk != NULL) {
689 device_printf(dev,"Vlan in use, detach first\n");
690 return (EBUSY);
691 }
692
725 IXL_PF_LOCK(pf);
726 ixl_stop(pf);
727 IXL_PF_UNLOCK(pf);
693 ether_ifdetach(vsi->ifp);
694 if (vsi->ifp->if_drv_flags & IFF_DRV_RUNNING) {
695 IXL_PF_LOCK(pf);
696 ixl_stop(pf);
697 IXL_PF_UNLOCK(pf);
698 }
728
729 for (int i = 0; i < vsi->num_queues; i++, que++) {
730 if (que->tq) {
731 taskqueue_drain(que->tq, &que->task);
732 taskqueue_drain(que->tq, &que->tx_task);
733 taskqueue_free(que->tq);
734 }
735 }

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

747 "Shutdown Admin queue failed with code %d\n", status);
748
749 /* Unregister VLAN events */
750 if (vsi->vlan_attach != NULL)
751 EVENTHANDLER_DEREGISTER(vlan_config, vsi->vlan_attach);
752 if (vsi->vlan_detach != NULL)
753 EVENTHANDLER_DEREGISTER(vlan_unconfig, vsi->vlan_detach);
754
699
700 for (int i = 0; i < vsi->num_queues; i++, que++) {
701 if (que->tq) {
702 taskqueue_drain(que->tq, &que->task);
703 taskqueue_drain(que->tq, &que->tx_task);
704 taskqueue_free(que->tq);
705 }
706 }

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

718 "Shutdown Admin queue failed with code %d\n", status);
719
720 /* Unregister VLAN events */
721 if (vsi->vlan_attach != NULL)
722 EVENTHANDLER_DEREGISTER(vlan_config, vsi->vlan_attach);
723 if (vsi->vlan_detach != NULL)
724 EVENTHANDLER_DEREGISTER(vlan_unconfig, vsi->vlan_detach);
725
755 ether_ifdetach(vsi->ifp);
756 callout_drain(&pf->timer);
757
758
759 ixl_free_pci_resources(pf);
760 bus_generic_detach(dev);
761 if_free(vsi->ifp);
762 ixl_free_vsi(vsi);
763 IXL_PF_LOCK_DESTROY(pf);

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

1116 filter.enable_fdir = TRUE;
1117#endif
1118 if (i40e_set_filter_control(hw, &filter))
1119 device_printf(dev, "set_filter_control() failed\n");
1120
1121 /* Set up RSS */
1122 ixl_config_rss(vsi);
1123
726 callout_drain(&pf->timer);
727
728
729 ixl_free_pci_resources(pf);
730 bus_generic_detach(dev);
731 if_free(vsi->ifp);
732 ixl_free_vsi(vsi);
733 IXL_PF_LOCK_DESTROY(pf);

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

1086 filter.enable_fdir = TRUE;
1087#endif
1088 if (i40e_set_filter_control(hw, &filter))
1089 device_printf(dev, "set_filter_control() failed\n");
1090
1091 /* Set up RSS */
1092 ixl_config_rss(vsi);
1093
1124 /* Setup the VSI */
1125 ixl_setup_vsi(vsi);
1126
1127 /*
1094 /*
1128 ** Prepare the rings, hmc contexts, etc...
1095 ** Prepare the VSI: rings, hmc contexts, etc...
1129 */
1130 if (ixl_initialize_vsi(vsi)) {
1131 device_printf(dev, "initialize vsi failed!!\n");
1132 return;
1133 }
1134
1135 /* Add protocol filters to list */
1136 ixl_init_filters(vsi);

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

1403 break;
1404 case I40E_PHY_TYPE_1000BASE_SX:
1405 ifmr->ifm_active |= IFM_1000_SX;
1406 break;
1407 case I40E_PHY_TYPE_1000BASE_LX:
1408 ifmr->ifm_active |= IFM_1000_LX;
1409 break;
1410 /* 10 G */
1096 */
1097 if (ixl_initialize_vsi(vsi)) {
1098 device_printf(dev, "initialize vsi failed!!\n");
1099 return;
1100 }
1101
1102 /* Add protocol filters to list */
1103 ixl_init_filters(vsi);

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

1370 break;
1371 case I40E_PHY_TYPE_1000BASE_SX:
1372 ifmr->ifm_active |= IFM_1000_SX;
1373 break;
1374 case I40E_PHY_TYPE_1000BASE_LX:
1375 ifmr->ifm_active |= IFM_1000_LX;
1376 break;
1377 /* 10 G */
1378 case I40E_PHY_TYPE_10GBASE_CR1:
1411 case I40E_PHY_TYPE_10GBASE_CR1_CU:
1412 case I40E_PHY_TYPE_10GBASE_SFPP_CU:
1379 case I40E_PHY_TYPE_10GBASE_CR1_CU:
1380 case I40E_PHY_TYPE_10GBASE_SFPP_CU:
1381 /* Using this until a real KR media type */
1382 case I40E_PHY_TYPE_10GBASE_KR:
1383 case I40E_PHY_TYPE_10GBASE_KX4:
1413 ifmr->ifm_active |= IFM_10G_TWINAX;
1414 break;
1384 ifmr->ifm_active |= IFM_10G_TWINAX;
1385 break;
1415 case I40E_PHY_TYPE_10GBASE_KR:
1416 /*
1417 ** this is not technically correct
1418 ** but FreeBSD does not have the media
1419 ** type defined yet, so its a compromise.
1420 */
1421 case I40E_PHY_TYPE_10GBASE_SR:
1422 ifmr->ifm_active |= IFM_10G_SR;
1423 break;
1424 case I40E_PHY_TYPE_10GBASE_LR:
1425 ifmr->ifm_active |= IFM_10G_LR;
1426 break;
1427 case I40E_PHY_TYPE_10GBASE_T:
1428 ifmr->ifm_active |= IFM_10G_T;

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

1433 ifmr->ifm_active |= IFM_40G_CR4;
1434 break;
1435 case I40E_PHY_TYPE_40GBASE_SR4:
1436 ifmr->ifm_active |= IFM_40G_SR4;
1437 break;
1438 case I40E_PHY_TYPE_40GBASE_LR4:
1439 ifmr->ifm_active |= IFM_40G_LR4;
1440 break;
1386 case I40E_PHY_TYPE_10GBASE_SR:
1387 ifmr->ifm_active |= IFM_10G_SR;
1388 break;
1389 case I40E_PHY_TYPE_10GBASE_LR:
1390 ifmr->ifm_active |= IFM_10G_LR;
1391 break;
1392 case I40E_PHY_TYPE_10GBASE_T:
1393 ifmr->ifm_active |= IFM_10G_T;

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

1398 ifmr->ifm_active |= IFM_40G_CR4;
1399 break;
1400 case I40E_PHY_TYPE_40GBASE_SR4:
1401 ifmr->ifm_active |= IFM_40G_SR4;
1402 break;
1403 case I40E_PHY_TYPE_40GBASE_LR4:
1404 ifmr->ifm_active |= IFM_40G_LR4;
1405 break;
1406 /*
1407 ** Set these to CR4 because OS does not
1408 ** have types available yet.
1409 */
1410 case I40E_PHY_TYPE_40GBASE_KR4:
1411 case I40E_PHY_TYPE_XLAUI:
1412 case I40E_PHY_TYPE_XLPPI:
1413 case I40E_PHY_TYPE_40GBASE_AOC:
1414 ifmr->ifm_active |= IFM_40G_CR4;
1415 break;
1441 default:
1442 ifmr->ifm_active |= IFM_UNKNOWN;
1443 break;
1444 }
1445 /* Report flow control status as well */
1446 if (hw->phy.link_info.an_info & I40E_AQ_LINK_PAUSE_TX)
1447 ifmr->ifm_active |= IFM_ETH_TXPAUSE;
1448 if (hw->phy.link_info.an_info & I40E_AQ_LINK_PAUSE_RX)

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

1759*/
1760static void
1761ixl_update_link_status(struct ixl_pf *pf)
1762{
1763 struct ixl_vsi *vsi = &pf->vsi;
1764 struct i40e_hw *hw = &pf->hw;
1765 struct ifnet *ifp = vsi->ifp;
1766 device_t dev = pf->dev;
1416 default:
1417 ifmr->ifm_active |= IFM_UNKNOWN;
1418 break;
1419 }
1420 /* Report flow control status as well */
1421 if (hw->phy.link_info.an_info & I40E_AQ_LINK_PAUSE_TX)
1422 ifmr->ifm_active |= IFM_ETH_TXPAUSE;
1423 if (hw->phy.link_info.an_info & I40E_AQ_LINK_PAUSE_RX)

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

1734*/
1735static void
1736ixl_update_link_status(struct ixl_pf *pf)
1737{
1738 struct ixl_vsi *vsi = &pf->vsi;
1739 struct i40e_hw *hw = &pf->hw;
1740 struct ifnet *ifp = vsi->ifp;
1741 device_t dev = pf->dev;
1767 enum i40e_fc_mode fc;
1768
1769
1770 if (vsi->link_up){
1771 if (vsi->link_active == FALSE) {
1772 i40e_aq_get_link_info(hw, TRUE, NULL, NULL);
1742
1743
1744 if (vsi->link_up){
1745 if (vsi->link_active == FALSE) {
1746 i40e_aq_get_link_info(hw, TRUE, NULL, NULL);
1747 pf->fc = hw->fc.current_mode;
1773 if (bootverbose) {
1748 if (bootverbose) {
1774 fc = hw->fc.current_mode;
1775 device_printf(dev,"Link is up %d Gbps %s,"
1776 " Flow Control: %s\n",
1777 ((vsi->link_speed == I40E_LINK_SPEED_40GB)? 40:10),
1749 device_printf(dev,"Link is up %d Gbps %s,"
1750 " Flow Control: %s\n",
1751 ((vsi->link_speed == I40E_LINK_SPEED_40GB)? 40:10),
1778 "Full Duplex", ixl_fc_string[fc]);
1752 "Full Duplex", ixl_fc_string[pf->fc]);
1779 }
1780 vsi->link_active = TRUE;
1781 /*
1782 ** Warn user if link speed on NPAR enabled
1783 ** partition is not at least 10GB
1784 */
1785 if (hw->func_caps.npar_enable &&
1786 (hw->phy.link_info.link_speed == I40E_LINK_SPEED_1GB ||

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

2335 /* Display supported media types */
2336 if (phy_type & (1 << I40E_PHY_TYPE_100BASE_TX))
2337 ifmedia_add(&vsi->media, IFM_ETHER | IFM_100_TX, 0, NULL);
2338
2339 if (phy_type & (1 << I40E_PHY_TYPE_1000BASE_T))
2340 ifmedia_add(&vsi->media, IFM_ETHER | IFM_1000_T, 0, NULL);
2341
2342 if (phy_type & (1 << I40E_PHY_TYPE_10GBASE_CR1_CU) ||
1753 }
1754 vsi->link_active = TRUE;
1755 /*
1756 ** Warn user if link speed on NPAR enabled
1757 ** partition is not at least 10GB
1758 */
1759 if (hw->func_caps.npar_enable &&
1760 (hw->phy.link_info.link_speed == I40E_LINK_SPEED_1GB ||

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

2309 /* Display supported media types */
2310 if (phy_type & (1 << I40E_PHY_TYPE_100BASE_TX))
2311 ifmedia_add(&vsi->media, IFM_ETHER | IFM_100_TX, 0, NULL);
2312
2313 if (phy_type & (1 << I40E_PHY_TYPE_1000BASE_T))
2314 ifmedia_add(&vsi->media, IFM_ETHER | IFM_1000_T, 0, NULL);
2315
2316 if (phy_type & (1 << I40E_PHY_TYPE_10GBASE_CR1_CU) ||
2317 phy_type & (1 << I40E_PHY_TYPE_10GBASE_KX4) ||
2318 phy_type & (1 << I40E_PHY_TYPE_10GBASE_KR) ||
2319 phy_type & (1 << I40E_PHY_TYPE_10GBASE_AOC) ||
2320 phy_type & (1 << I40E_PHY_TYPE_XAUI) ||
2321 phy_type & (1 << I40E_PHY_TYPE_XFI) ||
2322 phy_type & (1 << I40E_PHY_TYPE_SFI) ||
2343 phy_type & (1 << I40E_PHY_TYPE_10GBASE_SFPP_CU))
2344 ifmedia_add(&vsi->media, IFM_ETHER | IFM_10G_TWINAX, 0, NULL);
2323 phy_type & (1 << I40E_PHY_TYPE_10GBASE_SFPP_CU))
2324 ifmedia_add(&vsi->media, IFM_ETHER | IFM_10G_TWINAX, 0, NULL);
2325
2345 if (phy_type & (1 << I40E_PHY_TYPE_10GBASE_SR))
2346 ifmedia_add(&vsi->media, IFM_ETHER | IFM_10G_SR, 0, NULL);
2347 if (phy_type & (1 << I40E_PHY_TYPE_10GBASE_LR))
2348 ifmedia_add(&vsi->media, IFM_ETHER | IFM_10G_LR, 0, NULL);
2349 if (phy_type & (1 << I40E_PHY_TYPE_10GBASE_T))
2350 ifmedia_add(&vsi->media, IFM_ETHER | IFM_10G_T, 0, NULL);
2351
2326 if (phy_type & (1 << I40E_PHY_TYPE_10GBASE_SR))
2327 ifmedia_add(&vsi->media, IFM_ETHER | IFM_10G_SR, 0, NULL);
2328 if (phy_type & (1 << I40E_PHY_TYPE_10GBASE_LR))
2329 ifmedia_add(&vsi->media, IFM_ETHER | IFM_10G_LR, 0, NULL);
2330 if (phy_type & (1 << I40E_PHY_TYPE_10GBASE_T))
2331 ifmedia_add(&vsi->media, IFM_ETHER | IFM_10G_T, 0, NULL);
2332
2352 if (phy_type & (1 << I40E_PHY_TYPE_40GBASE_CR4_CU) ||
2353 phy_type & (1 << I40E_PHY_TYPE_40GBASE_CR4))
2333 if (phy_type & (1 << I40E_PHY_TYPE_40GBASE_CR4) ||
2334 phy_type & (1 << I40E_PHY_TYPE_40GBASE_CR4_CU) ||
2335 phy_type & (1 << I40E_PHY_TYPE_40GBASE_AOC) ||
2336 phy_type & (1 << I40E_PHY_TYPE_XLAUI) ||
2337 phy_type & (1 << I40E_PHY_TYPE_XLPPI) ||
2338 /* KR4 uses CR4 until the OS has the real media type */
2339 phy_type & (1 << I40E_PHY_TYPE_40GBASE_KR4))
2354 ifmedia_add(&vsi->media, IFM_ETHER | IFM_40G_CR4, 0, NULL);
2340 ifmedia_add(&vsi->media, IFM_ETHER | IFM_40G_CR4, 0, NULL);
2341
2355 if (phy_type & (1 << I40E_PHY_TYPE_40GBASE_SR4))
2356 ifmedia_add(&vsi->media, IFM_ETHER | IFM_40G_SR4, 0, NULL);
2357 if (phy_type & (1 << I40E_PHY_TYPE_40GBASE_LR4))
2358 ifmedia_add(&vsi->media, IFM_ETHER | IFM_40G_LR4, 0, NULL);
2359}
2360
2361/*********************************************************************
2362 *
2363 * Setup networking device structure and register an interface.
2364 *
2365 **********************************************************************/
2366static int
2367ixl_setup_interface(device_t dev, struct ixl_vsi *vsi)
2368{
2369 struct ifnet *ifp;
2370 struct i40e_hw *hw = vsi->hw;
2371 struct ixl_queue *que = vsi->queues;
2342 if (phy_type & (1 << I40E_PHY_TYPE_40GBASE_SR4))
2343 ifmedia_add(&vsi->media, IFM_ETHER | IFM_40G_SR4, 0, NULL);
2344 if (phy_type & (1 << I40E_PHY_TYPE_40GBASE_LR4))
2345 ifmedia_add(&vsi->media, IFM_ETHER | IFM_40G_LR4, 0, NULL);
2346}
2347
2348/*********************************************************************
2349 *
2350 * Setup networking device structure and register an interface.
2351 *
2352 **********************************************************************/
2353static int
2354ixl_setup_interface(device_t dev, struct ixl_vsi *vsi)
2355{
2356 struct ifnet *ifp;
2357 struct i40e_hw *hw = vsi->hw;
2358 struct ixl_queue *que = vsi->queues;
2372 struct i40e_aq_get_phy_abilities_resp abilities_resp;
2359 struct i40e_aq_get_phy_abilities_resp abilities;
2373 enum i40e_status_code aq_error = 0;
2374
2375 INIT_DEBUGOUT("ixl_setup_interface: begin");
2376
2377 ifp = vsi->ifp = if_alloc(IFT_ETHER);
2378 if (ifp == NULL) {
2379 device_printf(dev, "can not allocate ifnet structure\n");
2380 return (-1);

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

2431
2432 /*
2433 * Specify the media types supported by this adapter and register
2434 * callbacks to update media and link information
2435 */
2436 ifmedia_init(&vsi->media, IFM_IMASK, ixl_media_change,
2437 ixl_media_status);
2438
2360 enum i40e_status_code aq_error = 0;
2361
2362 INIT_DEBUGOUT("ixl_setup_interface: begin");
2363
2364 ifp = vsi->ifp = if_alloc(IFT_ETHER);
2365 if (ifp == NULL) {
2366 device_printf(dev, "can not allocate ifnet structure\n");
2367 return (-1);

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

2418
2419 /*
2420 * Specify the media types supported by this adapter and register
2421 * callbacks to update media and link information
2422 */
2423 ifmedia_init(&vsi->media, IFM_IMASK, ixl_media_change,
2424 ixl_media_status);
2425
2439 aq_error = i40e_aq_get_phy_capabilities(hw, FALSE, TRUE, &abilities_resp, NULL);
2426 aq_error = i40e_aq_get_phy_capabilities(hw,
2427 FALSE, TRUE, &abilities, NULL);
2428 /* May need delay to detect fiber correctly */
2440 if (aq_error == I40E_ERR_UNKNOWN_PHY) {
2429 if (aq_error == I40E_ERR_UNKNOWN_PHY) {
2441 /* Need delay to detect fiber correctly */
2442 i40e_msec_delay(200);
2443 aq_error = i40e_aq_get_phy_capabilities(hw, FALSE,
2430 i40e_msec_delay(200);
2431 aq_error = i40e_aq_get_phy_capabilities(hw, FALSE,
2444 TRUE, &abilities_resp, NULL);
2432 TRUE, &abilities, NULL);
2433 }
2434 if (aq_error) {
2445 if (aq_error == I40E_ERR_UNKNOWN_PHY)
2446 device_printf(dev, "Unknown PHY type detected!\n");
2447 else
2435 if (aq_error == I40E_ERR_UNKNOWN_PHY)
2436 device_printf(dev, "Unknown PHY type detected!\n");
2437 else
2448 ixl_add_ifmedia(vsi, abilities_resp.phy_type);
2449 } else if (aq_error) {
2450 device_printf(dev, "Error getting supported media types, err %d,"
2451 " AQ error %d\n", aq_error, hw->aq.asq_last_status);
2452 } else
2453 ixl_add_ifmedia(vsi, abilities_resp.phy_type);
2438 device_printf(dev,
2439 "Error getting supported media types, err %d,"
2440 " AQ error %d\n", aq_error, hw->aq.asq_last_status);
2441 return (0);
2442 }
2454
2443
2444 ixl_add_ifmedia(vsi, abilities.phy_type);
2445
2455 /* Use autoselect media by default */
2456 ifmedia_add(&vsi->media, IFM_ETHER | IFM_AUTO, 0, NULL);
2457 ifmedia_set(&vsi->media, IFM_ETHER | IFM_AUTO);
2458
2459 ether_ifattach(ifp, hw->mac.addr);
2460
2461 return (0);
2462}

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

2471#ifdef IXL_DEBUG
2472 printf("Link is %s\n", check ? "up":"down");
2473#endif
2474 return (check);
2475}
2476
2477/*********************************************************************
2478 *
2446 /* Use autoselect media by default */
2447 ifmedia_add(&vsi->media, IFM_ETHER | IFM_AUTO, 0, NULL);
2448 ifmedia_set(&vsi->media, IFM_ETHER | IFM_AUTO);
2449
2450 ether_ifattach(ifp, hw->mac.addr);
2451
2452 return (0);
2453}

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

2462#ifdef IXL_DEBUG
2463 printf("Link is %s\n", check ? "up":"down");
2464#endif
2465 return (check);
2466}
2467
2468/*********************************************************************
2469 *
2479 * Initialize this VSI
2470 * Get Firmware Switch configuration
2471 * - this will need to be more robust when more complex
2472 * switch configurations are enabled.
2480 *
2481 **********************************************************************/
2482static int
2473 *
2474 **********************************************************************/
2475static int
2483ixl_setup_vsi(struct ixl_vsi *vsi)
2476ixl_switch_config(struct ixl_pf *pf)
2484{
2477{
2485 struct i40e_hw *hw = vsi->hw;
2478 struct i40e_hw *hw = &pf->hw;
2479 struct ixl_vsi *vsi = &pf->vsi;
2486 device_t dev = vsi->dev;
2487 struct i40e_aqc_get_switch_config_resp *sw_config;
2480 device_t dev = vsi->dev;
2481 struct i40e_aqc_get_switch_config_resp *sw_config;
2488 struct i40e_vsi_context ctxt;
2489 u8 aq_buf[I40E_AQ_LARGE_BUF];
2490 int ret = I40E_SUCCESS;
2491 u16 next = 0;
2492
2482 u8 aq_buf[I40E_AQ_LARGE_BUF];
2483 int ret = I40E_SUCCESS;
2484 u16 next = 0;
2485
2486 memset(&aq_buf, 0, sizeof(aq_buf));
2493 sw_config = (struct i40e_aqc_get_switch_config_resp *)aq_buf;
2494 ret = i40e_aq_get_switch_config(hw, sw_config,
2495 sizeof(aq_buf), &next, NULL);
2496 if (ret) {
2497 device_printf(dev,"aq_get_switch_config failed!!\n");
2498 return (ret);
2499 }
2500#ifdef IXL_DEBUG
2501 printf("Switch config: header reported: %d in structure, %d total\n",
2502 sw_config->header.num_reported, sw_config->header.num_total);
2503 printf("type=%d seid=%d uplink=%d downlink=%d\n",
2504 sw_config->element[0].element_type,
2505 sw_config->element[0].seid,
2506 sw_config->element[0].uplink_seid,
2507 sw_config->element[0].downlink_seid);
2508#endif
2487 sw_config = (struct i40e_aqc_get_switch_config_resp *)aq_buf;
2488 ret = i40e_aq_get_switch_config(hw, sw_config,
2489 sizeof(aq_buf), &next, NULL);
2490 if (ret) {
2491 device_printf(dev,"aq_get_switch_config failed!!\n");
2492 return (ret);
2493 }
2494#ifdef IXL_DEBUG
2495 printf("Switch config: header reported: %d in structure, %d total\n",
2496 sw_config->header.num_reported, sw_config->header.num_total);
2497 printf("type=%d seid=%d uplink=%d downlink=%d\n",
2498 sw_config->element[0].element_type,
2499 sw_config->element[0].seid,
2500 sw_config->element[0].uplink_seid,
2501 sw_config->element[0].downlink_seid);
2502#endif
2509 /* Save off this important value */
2503 /* Simplified due to a single VSI at the moment */
2510 vsi->seid = sw_config->element[0].seid;
2504 vsi->seid = sw_config->element[0].seid;
2505 return (ret);
2506}
2511
2507
2508/*********************************************************************
2509 *
2510 * Initialize the VSI: this handles contexts, which means things
2511 * like the number of descriptors, buffer size,
2512 * plus we init the rings thru this function.
2513 *
2514 **********************************************************************/
2515static int
2516ixl_initialize_vsi(struct ixl_vsi *vsi)
2517{
2518 struct ixl_queue *que = vsi->queues;
2519 device_t dev = vsi->dev;
2520 struct i40e_hw *hw = vsi->hw;
2521 struct i40e_vsi_context ctxt;
2522 int err = 0;
2523
2512 memset(&ctxt, 0, sizeof(ctxt));
2513 ctxt.seid = vsi->seid;
2514 ctxt.pf_num = hw->pf_id;
2524 memset(&ctxt, 0, sizeof(ctxt));
2525 ctxt.seid = vsi->seid;
2526 ctxt.pf_num = hw->pf_id;
2515 ret = i40e_aq_get_vsi_params(hw, &ctxt, NULL);
2516 if (ret) {
2517 device_printf(dev,"get vsi params failed %x!!\n", ret);
2518 return (ret);
2527 err = i40e_aq_get_vsi_params(hw, &ctxt, NULL);
2528 if (err) {
2529 device_printf(dev,"get vsi params failed %x!!\n", err);
2530 return (err);
2519 }
2520#ifdef IXL_DEBUG
2521 printf("get_vsi_params: seid: %d, uplinkseid: %d, vsi_number: %d, "
2522 "vsis_allocated: %d, vsis_unallocated: %d, flags: 0x%x, "
2523 "pfnum: %d, vfnum: %d, stat idx: %d, enabled: %d\n", ctxt.seid,
2524 ctxt.uplink_seid, ctxt.vsi_number,
2525 ctxt.vsis_allocated, ctxt.vsis_unallocated,
2526 ctxt.flags, ctxt.pf_num, ctxt.vf_num,

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

2547 /* Keep copy of VSI info in VSI for statistic counters */
2548 memcpy(&vsi->info, &ctxt.info, sizeof(ctxt.info));
2549
2550 /* Reset VSI statistics */
2551 ixl_vsi_reset_stats(vsi);
2552 vsi->hw_filters_add = 0;
2553 vsi->hw_filters_del = 0;
2554
2531 }
2532#ifdef IXL_DEBUG
2533 printf("get_vsi_params: seid: %d, uplinkseid: %d, vsi_number: %d, "
2534 "vsis_allocated: %d, vsis_unallocated: %d, flags: 0x%x, "
2535 "pfnum: %d, vfnum: %d, stat idx: %d, enabled: %d\n", ctxt.seid,
2536 ctxt.uplink_seid, ctxt.vsi_number,
2537 ctxt.vsis_allocated, ctxt.vsis_unallocated,
2538 ctxt.flags, ctxt.pf_num, ctxt.vf_num,

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

2559 /* Keep copy of VSI info in VSI for statistic counters */
2560 memcpy(&vsi->info, &ctxt.info, sizeof(ctxt.info));
2561
2562 /* Reset VSI statistics */
2563 ixl_vsi_reset_stats(vsi);
2564 vsi->hw_filters_add = 0;
2565 vsi->hw_filters_del = 0;
2566
2555 ret = i40e_aq_update_vsi_params(hw, &ctxt, NULL);
2556 if (ret)
2567 err = i40e_aq_update_vsi_params(hw, &ctxt, NULL);
2568 if (err) {
2557 device_printf(dev,"update vsi params failed %x!!\n",
2558 hw->aq.asq_last_status);
2569 device_printf(dev,"update vsi params failed %x!!\n",
2570 hw->aq.asq_last_status);
2559 return (ret);
2560}
2571 return (err);
2572 }
2561
2573
2562
2563/*********************************************************************
2564 *
2565 * Initialize the VSI: this handles contexts, which means things
2566 * like the number of descriptors, buffer size,
2567 * plus we init the rings thru this function.
2568 *
2569 **********************************************************************/
2570static int
2571ixl_initialize_vsi(struct ixl_vsi *vsi)
2572{
2573 struct ixl_queue *que = vsi->queues;
2574 device_t dev = vsi->dev;
2575 struct i40e_hw *hw = vsi->hw;
2576 int err = 0;
2577
2578
2579 for (int i = 0; i < vsi->num_queues; i++, que++) {
2580 struct tx_ring *txr = &que->txr;
2581 struct rx_ring *rxr = &que->rxr;
2582 struct i40e_hmc_obj_txq tctx;
2583 struct i40e_hmc_obj_rxq rctx;
2584 u32 txctl;
2585 u16 size;
2586

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

3210 if (rss_hash_config & RSS_HASHTYPE_RSS_IPV4)
3211 set_hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_OTHER);
3212 if (rss_hash_config & RSS_HASHTYPE_RSS_TCP_IPV4)
3213 set_hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_TCP);
3214 if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV4)
3215 set_hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_UDP);
3216 if (rss_hash_config & RSS_HASHTYPE_RSS_IPV6)
3217 set_hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_OTHER);
2574 for (int i = 0; i < vsi->num_queues; i++, que++) {
2575 struct tx_ring *txr = &que->txr;
2576 struct rx_ring *rxr = &que->rxr;
2577 struct i40e_hmc_obj_txq tctx;
2578 struct i40e_hmc_obj_rxq rctx;
2579 u32 txctl;
2580 u16 size;
2581

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

3205 if (rss_hash_config & RSS_HASHTYPE_RSS_IPV4)
3206 set_hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_OTHER);
3207 if (rss_hash_config & RSS_HASHTYPE_RSS_TCP_IPV4)
3208 set_hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_TCP);
3209 if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV4)
3210 set_hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_UDP);
3211 if (rss_hash_config & RSS_HASHTYPE_RSS_IPV6)
3212 set_hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_OTHER);
3218 if (rss_hash_config & RSS_HASHTYPE_RSS_IPV6_EX)
3213 if (rss_hash_config & RSS_HASHTYPE_RSS_IPV6_EX)
3219 set_hena |= ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV6);
3220 if (rss_hash_config & RSS_HASHTYPE_RSS_TCP_IPV6)
3221 set_hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_TCP);
3222 if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV6)
3223 set_hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_UDP);
3224#else
3225 set_hena =
3226 ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_UDP) |

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

3515 j++;
3516 }
3517 if (j == cnt)
3518 break;
3519 }
3520 if (j > 0) {
3521 err = i40e_aq_add_macvlan(hw, vsi->seid, a, j, NULL);
3522 if (err)
3214 set_hena |= ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV6);
3215 if (rss_hash_config & RSS_HASHTYPE_RSS_TCP_IPV6)
3216 set_hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_TCP);
3217 if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV6)
3218 set_hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_UDP);
3219#else
3220 set_hena =
3221 ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_UDP) |

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

3510 j++;
3511 }
3512 if (j == cnt)
3513 break;
3514 }
3515 if (j > 0) {
3516 err = i40e_aq_add_macvlan(hw, vsi->seid, a, j, NULL);
3517 if (err)
3523 device_printf(dev, "aq_add_macvlan err %d, aq_error %d\n",
3524 err, hw->aq.asq_last_status);
3518 device_printf(dev, "aq_add_macvlan err %d, "
3519 "aq_error %d\n", err, hw->aq.asq_last_status);
3525 else
3526 vsi->hw_filters_add += j;
3527 }
3528 free(a, M_DEVBUF);
3529 return;
3530}
3531
3532/*

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

4301 * priority flow control is enabled
4302 *
4303 * TODO: ensure tx CRC by hardware should be enabled
4304 * if tx flow control is enabled.
4305 */
4306 struct ixl_pf *pf = (struct ixl_pf *)arg1;
4307 struct i40e_hw *hw = &pf->hw;
4308 device_t dev = pf->dev;
3520 else
3521 vsi->hw_filters_add += j;
3522 }
3523 free(a, M_DEVBUF);
3524 return;
3525}
3526
3527/*

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

4296 * priority flow control is enabled
4297 *
4298 * TODO: ensure tx CRC by hardware should be enabled
4299 * if tx flow control is enabled.
4300 */
4301 struct ixl_pf *pf = (struct ixl_pf *)arg1;
4302 struct i40e_hw *hw = &pf->hw;
4303 device_t dev = pf->dev;
4309 int requested_fc = 0, error = 0;
4304 int error = 0;
4310 enum i40e_status_code aq_error = 0;
4311 u8 fc_aq_err = 0;
4312
4305 enum i40e_status_code aq_error = 0;
4306 u8 fc_aq_err = 0;
4307
4313 aq_error = i40e_aq_get_link_info(hw, TRUE, NULL, NULL);
4314 if (aq_error) {
4315 device_printf(dev,
4316 "%s: Error retrieving link info from aq, %d\n",
4317 __func__, aq_error);
4318 return (EAGAIN);
4319 }
4320
4321 /* Read in new mode */
4322 requested_fc = hw->fc.current_mode;
4323 error = sysctl_handle_int(oidp, &requested_fc, 0, req);
4308 /* Get request */
4309 error = sysctl_handle_int(oidp, &pf->fc, 0, req);
4324 if ((error) || (req->newptr == NULL))
4325 return (error);
4310 if ((error) || (req->newptr == NULL))
4311 return (error);
4326 if (requested_fc < 0 || requested_fc > 3) {
4312 if (pf->fc < 0 || pf->fc > 3) {
4327 device_printf(dev,
4328 "Invalid fc mode; valid modes are 0 through 3\n");
4329 return (EINVAL);
4330 }
4331
4332 /*
4333 ** Changing flow control mode currently does not work on
4334 ** 40GBASE-CR4 PHYs
4335 */
4336 if (hw->phy.link_info.phy_type == I40E_PHY_TYPE_40GBASE_CR4
4337 || hw->phy.link_info.phy_type == I40E_PHY_TYPE_40GBASE_CR4_CU) {
4338 device_printf(dev, "Changing flow control mode unsupported"
4339 " on 40GBase-CR4 media.\n");
4340 return (ENODEV);
4341 }
4342
4343 /* Set fc ability for port */
4313 device_printf(dev,
4314 "Invalid fc mode; valid modes are 0 through 3\n");
4315 return (EINVAL);
4316 }
4317
4318 /*
4319 ** Changing flow control mode currently does not work on
4320 ** 40GBASE-CR4 PHYs
4321 */
4322 if (hw->phy.link_info.phy_type == I40E_PHY_TYPE_40GBASE_CR4
4323 || hw->phy.link_info.phy_type == I40E_PHY_TYPE_40GBASE_CR4_CU) {
4324 device_printf(dev, "Changing flow control mode unsupported"
4325 " on 40GBase-CR4 media.\n");
4326 return (ENODEV);
4327 }
4328
4329 /* Set fc ability for port */
4344 hw->fc.requested_mode = requested_fc;
4330 hw->fc.requested_mode = pf->fc;
4345 aq_error = i40e_set_fc(hw, &fc_aq_err, TRUE);
4346 if (aq_error) {
4347 device_printf(dev,
4348 "%s: Error setting new fc mode %d; fc_err %#x\n",
4349 __func__, aq_error, fc_aq_err);
4350 return (EAGAIN);
4351 }
4352
4331 aq_error = i40e_set_fc(hw, &fc_aq_err, TRUE);
4332 if (aq_error) {
4333 device_printf(dev,
4334 "%s: Error setting new fc mode %d; fc_err %#x\n",
4335 __func__, aq_error, fc_aq_err);
4336 return (EAGAIN);
4337 }
4338
4353 if (hw->fc.current_mode != hw->fc.requested_mode) {
4354 device_printf(dev, "%s: FC set failure:\n", __func__);
4355 device_printf(dev, "%s: Current: %s / Requested: %s\n",
4356 __func__,
4357 ixl_fc_string[hw->fc.current_mode],
4358 ixl_fc_string[hw->fc.requested_mode]);
4359 }
4360
4361 return (0);
4362}
4363
4364static int
4365ixl_current_speed(SYSCTL_HANDLER_ARGS)
4366{
4367 struct ixl_pf *pf = (struct ixl_pf *)arg1;
4368 struct i40e_hw *hw = &pf->hw;

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

4411{
4412 struct i40e_hw *hw = &pf->hw;
4413 device_t dev = pf->dev;
4414 struct i40e_aq_get_phy_abilities_resp abilities;
4415 struct i40e_aq_set_phy_config config;
4416 enum i40e_status_code aq_error = 0;
4417
4418 /* Get current capability information */
4339 return (0);
4340}
4341
4342static int
4343ixl_current_speed(SYSCTL_HANDLER_ARGS)
4344{
4345 struct ixl_pf *pf = (struct ixl_pf *)arg1;
4346 struct i40e_hw *hw = &pf->hw;

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

4389{
4390 struct i40e_hw *hw = &pf->hw;
4391 device_t dev = pf->dev;
4392 struct i40e_aq_get_phy_abilities_resp abilities;
4393 struct i40e_aq_set_phy_config config;
4394 enum i40e_status_code aq_error = 0;
4395
4396 /* Get current capability information */
4419 aq_error = i40e_aq_get_phy_capabilities(hw, FALSE, FALSE, &abilities, NULL);
4397 aq_error = i40e_aq_get_phy_capabilities(hw,
4398 FALSE, FALSE, &abilities, NULL);
4420 if (aq_error) {
4399 if (aq_error) {
4421 device_printf(dev, "%s: Error getting phy capabilities %d,"
4400 device_printf(dev,
4401 "%s: Error getting phy capabilities %d,"
4422 " aq error: %d\n", __func__, aq_error,
4423 hw->aq.asq_last_status);
4424 return (EAGAIN);
4425 }
4426
4427 /* Prepare new config */
4428 bzero(&config, sizeof(config));
4429 config.phy_type = abilities.phy_type;

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

4438 if (speeds & 0x2)
4439 config.link_speed |= I40E_LINK_SPEED_1GB;
4440 if (speeds & 0x1)
4441 config.link_speed |= I40E_LINK_SPEED_100MB;
4442
4443 /* Do aq command & restart link */
4444 aq_error = i40e_aq_set_phy_config(hw, &config, NULL);
4445 if (aq_error) {
4402 " aq error: %d\n", __func__, aq_error,
4403 hw->aq.asq_last_status);
4404 return (EAGAIN);
4405 }
4406
4407 /* Prepare new config */
4408 bzero(&config, sizeof(config));
4409 config.phy_type = abilities.phy_type;

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

4418 if (speeds & 0x2)
4419 config.link_speed |= I40E_LINK_SPEED_1GB;
4420 if (speeds & 0x1)
4421 config.link_speed |= I40E_LINK_SPEED_100MB;
4422
4423 /* Do aq command & restart link */
4424 aq_error = i40e_aq_set_phy_config(hw, &config, NULL);
4425 if (aq_error) {
4446 device_printf(dev, "%s: Error setting new phy config %d,"
4426 device_printf(dev,
4427 "%s: Error setting new phy config %d,"
4447 " aq error: %d\n", __func__, aq_error,
4448 hw->aq.asq_last_status);
4449 return (EAGAIN);
4450 }
4451
4452 /*
4453 ** This seems a bit heavy handed, but we
4454 ** need to get a reinit on some devices

--- 494 unchanged lines hidden ---
4428 " aq error: %d\n", __func__, aq_error,
4429 hw->aq.asq_last_status);
4430 return (EAGAIN);
4431 }
4432
4433 /*
4434 ** This seems a bit heavy handed, but we
4435 ** need to get a reinit on some devices

--- 494 unchanged lines hidden ---