aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/i40e/i40e_main.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-06-12 17:27:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-12 17:27:40 -0400
commitf9da455b93f6ba076935b4ef4589f61e529ae046 (patch)
tree3c4e69ce1ba1d6bf65915b97a76ca2172105b278 /drivers/net/ethernet/intel/i40e/i40e_main.c
parent0e04c641b199435f3779454055f6a7de258ecdfc (diff)
parente5eca6d41f53db48edd8cf88a3f59d2c30227f8e (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking updates from David Miller: 1) Seccomp BPF filters can now be JIT'd, from Alexei Starovoitov. 2) Multiqueue support in xen-netback and xen-netfront, from Andrew J Benniston. 3) Allow tweaking of aggregation settings in cdc_ncm driver, from Bjørn Mork. 4) BPF now has a "random" opcode, from Chema Gonzalez. 5) Add more BPF documentation and improve test framework, from Daniel Borkmann. 6) Support TCP fastopen over ipv6, from Daniel Lee. 7) Add software TSO helper functions and use them to support software TSO in mvneta and mv643xx_eth drivers. From Ezequiel Garcia. 8) Support software TSO in fec driver too, from Nimrod Andy. 9) Add Broadcom SYSTEMPORT driver, from Florian Fainelli. 10) Handle broadcasts more gracefully over macvlan when there are large numbers of interfaces configured, from Herbert Xu. 11) Allow more control over fwmark used for non-socket based responses, from Lorenzo Colitti. 12) Do TCP congestion window limiting based upon measurements, from Neal Cardwell. 13) Support busy polling in SCTP, from Neal Horman. 14) Allow RSS key to be configured via ethtool, from Venkata Duvvuru. 15) Bridge promisc mode handling improvements from Vlad Yasevich. 16) Don't use inetpeer entries to implement ID generation any more, it performs poorly, from Eric Dumazet. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1522 commits) rtnetlink: fix userspace API breakage for iproute2 < v3.9.0 tcp: fixing TLP's FIN recovery net: fec: Add software TSO support net: fec: Add Scatter/gather support net: fec: Increase buffer descriptor entry number net: fec: Factorize feature setting net: fec: Enable IP header hardware checksum net: fec: Factorize the .xmit transmit function bridge: fix compile error when compiling without IPv6 support bridge: fix smatch warning / potential null pointer dereference via-rhine: fix full-duplex with autoneg disable bnx2x: Enlarge the dorq threshold for VFs bnx2x: Check for UNDI in uncommon branch bnx2x: Fix 1G-baseT link bnx2x: Fix link for KR with swapped polarity lane sctp: Fix sk_ack_backlog wrap-around problem net/core: Add VF link state control policy net/fsl: xgmac_mdio is dependent on OF_MDIO net/fsl: Make xgmac_mdio read error message useful net_sched: drr: warn when qdisc is not work conserving ...
Diffstat (limited to 'drivers/net/ethernet/intel/i40e/i40e_main.c')
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c1124
1 files changed, 718 insertions, 406 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 2e72449f1265..275ca9a1719e 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -38,8 +38,8 @@ static const char i40e_driver_string[] =
38#define DRV_KERN "-k" 38#define DRV_KERN "-k"
39 39
40#define DRV_VERSION_MAJOR 0 40#define DRV_VERSION_MAJOR 0
41#define DRV_VERSION_MINOR 3 41#define DRV_VERSION_MINOR 4
42#define DRV_VERSION_BUILD 36 42#define DRV_VERSION_BUILD 10
43#define DRV_VERSION __stringify(DRV_VERSION_MAJOR) "." \ 43#define DRV_VERSION __stringify(DRV_VERSION_MAJOR) "." \
44 __stringify(DRV_VERSION_MINOR) "." \ 44 __stringify(DRV_VERSION_MINOR) "." \
45 __stringify(DRV_VERSION_BUILD) DRV_KERN 45 __stringify(DRV_VERSION_BUILD) DRV_KERN
@@ -67,12 +67,10 @@ static int i40e_veb_get_bw_info(struct i40e_veb *veb);
67 */ 67 */
68static DEFINE_PCI_DEVICE_TABLE(i40e_pci_tbl) = { 68static DEFINE_PCI_DEVICE_TABLE(i40e_pci_tbl) = {
69 {PCI_VDEVICE(INTEL, I40E_DEV_ID_SFP_XL710), 0}, 69 {PCI_VDEVICE(INTEL, I40E_DEV_ID_SFP_XL710), 0},
70 {PCI_VDEVICE(INTEL, I40E_DEV_ID_SFP_X710), 0},
71 {PCI_VDEVICE(INTEL, I40E_DEV_ID_QEMU), 0}, 70 {PCI_VDEVICE(INTEL, I40E_DEV_ID_QEMU), 0},
72 {PCI_VDEVICE(INTEL, I40E_DEV_ID_KX_A), 0}, 71 {PCI_VDEVICE(INTEL, I40E_DEV_ID_KX_A), 0},
73 {PCI_VDEVICE(INTEL, I40E_DEV_ID_KX_B), 0}, 72 {PCI_VDEVICE(INTEL, I40E_DEV_ID_KX_B), 0},
74 {PCI_VDEVICE(INTEL, I40E_DEV_ID_KX_C), 0}, 73 {PCI_VDEVICE(INTEL, I40E_DEV_ID_KX_C), 0},
75 {PCI_VDEVICE(INTEL, I40E_DEV_ID_KX_D), 0},
76 {PCI_VDEVICE(INTEL, I40E_DEV_ID_QSFP_A), 0}, 74 {PCI_VDEVICE(INTEL, I40E_DEV_ID_QSFP_A), 0},
77 {PCI_VDEVICE(INTEL, I40E_DEV_ID_QSFP_B), 0}, 75 {PCI_VDEVICE(INTEL, I40E_DEV_ID_QSFP_B), 0},
78 {PCI_VDEVICE(INTEL, I40E_DEV_ID_QSFP_C), 0}, 76 {PCI_VDEVICE(INTEL, I40E_DEV_ID_QSFP_C), 0},
@@ -356,6 +354,7 @@ static struct rtnl_link_stats64 *i40e_get_netdev_stats_struct(
356 struct rtnl_link_stats64 *stats) 354 struct rtnl_link_stats64 *stats)
357{ 355{
358 struct i40e_netdev_priv *np = netdev_priv(netdev); 356 struct i40e_netdev_priv *np = netdev_priv(netdev);
357 struct i40e_ring *tx_ring, *rx_ring;
359 struct i40e_vsi *vsi = np->vsi; 358 struct i40e_vsi *vsi = np->vsi;
360 struct rtnl_link_stats64 *vsi_stats = i40e_get_vsi_stats_struct(vsi); 359 struct rtnl_link_stats64 *vsi_stats = i40e_get_vsi_stats_struct(vsi);
361 int i; 360 int i;
@@ -368,7 +367,6 @@ static struct rtnl_link_stats64 *i40e_get_netdev_stats_struct(
368 367
369 rcu_read_lock(); 368 rcu_read_lock();
370 for (i = 0; i < vsi->num_queue_pairs; i++) { 369 for (i = 0; i < vsi->num_queue_pairs; i++) {
371 struct i40e_ring *tx_ring, *rx_ring;
372 u64 bytes, packets; 370 u64 bytes, packets;
373 unsigned int start; 371 unsigned int start;
374 372
@@ -397,7 +395,7 @@ static struct rtnl_link_stats64 *i40e_get_netdev_stats_struct(
397 } 395 }
398 rcu_read_unlock(); 396 rcu_read_unlock();
399 397
400 /* following stats updated by ixgbe_watchdog_task() */ 398 /* following stats updated by i40e_watchdog_subtask() */
401 stats->multicast = vsi_stats->multicast; 399 stats->multicast = vsi_stats->multicast;
402 stats->tx_errors = vsi_stats->tx_errors; 400 stats->tx_errors = vsi_stats->tx_errors;
403 stats->tx_dropped = vsi_stats->tx_dropped; 401 stats->tx_dropped = vsi_stats->tx_dropped;
@@ -530,6 +528,12 @@ void i40e_update_eth_stats(struct i40e_vsi *vsi)
530 i40e_stat_update32(hw, I40E_GLV_RDPC(stat_idx), 528 i40e_stat_update32(hw, I40E_GLV_RDPC(stat_idx),
531 vsi->stat_offsets_loaded, 529 vsi->stat_offsets_loaded,
532 &oes->rx_discards, &es->rx_discards); 530 &oes->rx_discards, &es->rx_discards);
531 i40e_stat_update32(hw, I40E_GLV_RUPP(stat_idx),
532 vsi->stat_offsets_loaded,
533 &oes->rx_unknown_protocol, &es->rx_unknown_protocol);
534 i40e_stat_update32(hw, I40E_GLV_TEPC(stat_idx),
535 vsi->stat_offsets_loaded,
536 &oes->tx_errors, &es->tx_errors);
533 537
534 i40e_stat_update48(hw, I40E_GLV_GORCH(stat_idx), 538 i40e_stat_update48(hw, I40E_GLV_GORCH(stat_idx),
535 I40E_GLV_GORCL(stat_idx), 539 I40E_GLV_GORCL(stat_idx),
@@ -648,10 +652,10 @@ static void i40e_update_link_xoff_rx(struct i40e_pf *pf)
648 return; 652 return;
649 653
650 /* Clear the __I40E_HANG_CHECK_ARMED bit for all Tx rings */ 654 /* Clear the __I40E_HANG_CHECK_ARMED bit for all Tx rings */
651 for (v = 0; v < pf->hw.func_caps.num_vsis; v++) { 655 for (v = 0; v < pf->num_alloc_vsi; v++) {
652 struct i40e_vsi *vsi = pf->vsi[v]; 656 struct i40e_vsi *vsi = pf->vsi[v];
653 657
654 if (!vsi) 658 if (!vsi || !vsi->tx_rings[0])
655 continue; 659 continue;
656 660
657 for (i = 0; i < vsi->num_queue_pairs; i++) { 661 for (i = 0; i < vsi->num_queue_pairs; i++) {
@@ -702,10 +706,10 @@ static void i40e_update_prio_xoff_rx(struct i40e_pf *pf)
702 } 706 }
703 707
704 /* Clear the __I40E_HANG_CHECK_ARMED bit for Tx rings */ 708 /* Clear the __I40E_HANG_CHECK_ARMED bit for Tx rings */
705 for (v = 0; v < pf->hw.func_caps.num_vsis; v++) { 709 for (v = 0; v < pf->num_alloc_vsi; v++) {
706 struct i40e_vsi *vsi = pf->vsi[v]; 710 struct i40e_vsi *vsi = pf->vsi[v];
707 711
708 if (!vsi) 712 if (!vsi || !vsi->tx_rings[0])
709 continue; 713 continue;
710 714
711 for (i = 0; i < vsi->num_queue_pairs; i++) { 715 for (i = 0; i < vsi->num_queue_pairs; i++) {
@@ -720,19 +724,18 @@ static void i40e_update_prio_xoff_rx(struct i40e_pf *pf)
720} 724}
721 725
722/** 726/**
723 * i40e_update_stats - Update the board statistics counters. 727 * i40e_update_vsi_stats - Update the vsi statistics counters.
724 * @vsi: the VSI to be updated 728 * @vsi: the VSI to be updated
725 * 729 *
726 * There are a few instances where we store the same stat in a 730 * There are a few instances where we store the same stat in a
727 * couple of different structs. This is partly because we have 731 * couple of different structs. This is partly because we have
728 * the netdev stats that need to be filled out, which is slightly 732 * the netdev stats that need to be filled out, which is slightly
729 * different from the "eth_stats" defined by the chip and used in 733 * different from the "eth_stats" defined by the chip and used in
730 * VF communications. We sort it all out here in a central place. 734 * VF communications. We sort it out here.
731 **/ 735 **/
732void i40e_update_stats(struct i40e_vsi *vsi) 736static void i40e_update_vsi_stats(struct i40e_vsi *vsi)
733{ 737{
734 struct i40e_pf *pf = vsi->back; 738 struct i40e_pf *pf = vsi->back;
735 struct i40e_hw *hw = &pf->hw;
736 struct rtnl_link_stats64 *ons; 739 struct rtnl_link_stats64 *ons;
737 struct rtnl_link_stats64 *ns; /* netdev stats */ 740 struct rtnl_link_stats64 *ns; /* netdev stats */
738 struct i40e_eth_stats *oes; 741 struct i40e_eth_stats *oes;
@@ -741,8 +744,6 @@ void i40e_update_stats(struct i40e_vsi *vsi)
741 u32 rx_page, rx_buf; 744 u32 rx_page, rx_buf;
742 u64 rx_p, rx_b; 745 u64 rx_p, rx_b;
743 u64 tx_p, tx_b; 746 u64 tx_p, tx_b;
744 u32 val;
745 int i;
746 u16 q; 747 u16 q;
747 748
748 if (test_bit(__I40E_DOWN, &vsi->state) || 749 if (test_bit(__I40E_DOWN, &vsi->state) ||
@@ -804,196 +805,256 @@ void i40e_update_stats(struct i40e_vsi *vsi)
804 ns->tx_packets = tx_p; 805 ns->tx_packets = tx_p;
805 ns->tx_bytes = tx_b; 806 ns->tx_bytes = tx_b;
806 807
807 i40e_update_eth_stats(vsi);
808 /* update netdev stats from eth stats */ 808 /* update netdev stats from eth stats */
809 ons->rx_errors = oes->rx_errors; 809 i40e_update_eth_stats(vsi);
810 ns->rx_errors = es->rx_errors;
811 ons->tx_errors = oes->tx_errors; 810 ons->tx_errors = oes->tx_errors;
812 ns->tx_errors = es->tx_errors; 811 ns->tx_errors = es->tx_errors;
813 ons->multicast = oes->rx_multicast; 812 ons->multicast = oes->rx_multicast;
814 ns->multicast = es->rx_multicast; 813 ns->multicast = es->rx_multicast;
814 ons->rx_dropped = oes->rx_discards;
815 ns->rx_dropped = es->rx_discards;
815 ons->tx_dropped = oes->tx_discards; 816 ons->tx_dropped = oes->tx_discards;
816 ns->tx_dropped = es->tx_discards; 817 ns->tx_dropped = es->tx_discards;
817 818
818 /* Get the port data only if this is the main PF VSI */ 819 /* pull in a couple PF stats if this is the main vsi */
819 if (vsi == pf->vsi[pf->lan_vsi]) { 820 if (vsi == pf->vsi[pf->lan_vsi]) {
820 struct i40e_hw_port_stats *nsd = &pf->stats; 821 ns->rx_crc_errors = pf->stats.crc_errors;
821 struct i40e_hw_port_stats *osd = &pf->stats_offsets; 822 ns->rx_errors = pf->stats.crc_errors + pf->stats.illegal_bytes;
823 ns->rx_length_errors = pf->stats.rx_length_errors;
824 }
825}
822 826
823 i40e_stat_update48(hw, I40E_GLPRT_GORCH(hw->port), 827/**
824 I40E_GLPRT_GORCL(hw->port), 828 * i40e_update_pf_stats - Update the pf statistics counters.
825 pf->stat_offsets_loaded, 829 * @pf: the PF to be updated
826 &osd->eth.rx_bytes, &nsd->eth.rx_bytes); 830 **/
827 i40e_stat_update48(hw, I40E_GLPRT_GOTCH(hw->port), 831static void i40e_update_pf_stats(struct i40e_pf *pf)
828 I40E_GLPRT_GOTCL(hw->port), 832{
829 pf->stat_offsets_loaded, 833 struct i40e_hw_port_stats *osd = &pf->stats_offsets;
830 &osd->eth.tx_bytes, &nsd->eth.tx_bytes); 834 struct i40e_hw_port_stats *nsd = &pf->stats;
831 i40e_stat_update32(hw, I40E_GLPRT_RDPC(hw->port), 835 struct i40e_hw *hw = &pf->hw;
832 pf->stat_offsets_loaded, 836 u32 val;
833 &osd->eth.rx_discards, 837 int i;
834 &nsd->eth.rx_discards);
835 i40e_stat_update32(hw, I40E_GLPRT_TDPC(hw->port),
836 pf->stat_offsets_loaded,
837 &osd->eth.tx_discards,
838 &nsd->eth.tx_discards);
839 i40e_stat_update48(hw, I40E_GLPRT_MPRCH(hw->port),
840 I40E_GLPRT_MPRCL(hw->port),
841 pf->stat_offsets_loaded,
842 &osd->eth.rx_multicast,
843 &nsd->eth.rx_multicast);
844 838
845 i40e_stat_update32(hw, I40E_GLPRT_TDOLD(hw->port), 839 i40e_stat_update48(hw, I40E_GLPRT_GORCH(hw->port),
846 pf->stat_offsets_loaded, 840 I40E_GLPRT_GORCL(hw->port),
847 &osd->tx_dropped_link_down, 841 pf->stat_offsets_loaded,
848 &nsd->tx_dropped_link_down); 842 &osd->eth.rx_bytes, &nsd->eth.rx_bytes);
843 i40e_stat_update48(hw, I40E_GLPRT_GOTCH(hw->port),
844 I40E_GLPRT_GOTCL(hw->port),
845 pf->stat_offsets_loaded,
846 &osd->eth.tx_bytes, &nsd->eth.tx_bytes);
847 i40e_stat_update32(hw, I40E_GLPRT_RDPC(hw->port),
848 pf->stat_offsets_loaded,
849 &osd->eth.rx_discards,
850 &nsd->eth.rx_discards);
851 i40e_stat_update32(hw, I40E_GLPRT_TDPC(hw->port),
852 pf->stat_offsets_loaded,
853 &osd->eth.tx_discards,
854 &nsd->eth.tx_discards);
849 855
850 i40e_stat_update32(hw, I40E_GLPRT_CRCERRS(hw->port), 856 i40e_stat_update48(hw, I40E_GLPRT_UPRCH(hw->port),
851 pf->stat_offsets_loaded, 857 I40E_GLPRT_UPRCL(hw->port),
852 &osd->crc_errors, &nsd->crc_errors); 858 pf->stat_offsets_loaded,
853 ns->rx_crc_errors = nsd->crc_errors; 859 &osd->eth.rx_unicast,
860 &nsd->eth.rx_unicast);
861 i40e_stat_update48(hw, I40E_GLPRT_MPRCH(hw->port),
862 I40E_GLPRT_MPRCL(hw->port),
863 pf->stat_offsets_loaded,
864 &osd->eth.rx_multicast,
865 &nsd->eth.rx_multicast);
866 i40e_stat_update48(hw, I40E_GLPRT_BPRCH(hw->port),
867 I40E_GLPRT_BPRCL(hw->port),
868 pf->stat_offsets_loaded,
869 &osd->eth.rx_broadcast,
870 &nsd->eth.rx_broadcast);
871 i40e_stat_update48(hw, I40E_GLPRT_UPTCH(hw->port),
872 I40E_GLPRT_UPTCL(hw->port),
873 pf->stat_offsets_loaded,
874 &osd->eth.tx_unicast,
875 &nsd->eth.tx_unicast);
876 i40e_stat_update48(hw, I40E_GLPRT_MPTCH(hw->port),
877 I40E_GLPRT_MPTCL(hw->port),
878 pf->stat_offsets_loaded,
879 &osd->eth.tx_multicast,
880 &nsd->eth.tx_multicast);
881 i40e_stat_update48(hw, I40E_GLPRT_BPTCH(hw->port),
882 I40E_GLPRT_BPTCL(hw->port),
883 pf->stat_offsets_loaded,
884 &osd->eth.tx_broadcast,
885 &nsd->eth.tx_broadcast);
854 886
855 i40e_stat_update32(hw, I40E_GLPRT_ILLERRC(hw->port), 887 i40e_stat_update32(hw, I40E_GLPRT_TDOLD(hw->port),
856 pf->stat_offsets_loaded, 888 pf->stat_offsets_loaded,
857 &osd->illegal_bytes, &nsd->illegal_bytes); 889 &osd->tx_dropped_link_down,
858 ns->rx_errors = nsd->crc_errors 890 &nsd->tx_dropped_link_down);
859 + nsd->illegal_bytes;
860 891
861 i40e_stat_update32(hw, I40E_GLPRT_MLFC(hw->port), 892 i40e_stat_update32(hw, I40E_GLPRT_CRCERRS(hw->port),
862 pf->stat_offsets_loaded, 893 pf->stat_offsets_loaded,
863 &osd->mac_local_faults, 894 &osd->crc_errors, &nsd->crc_errors);
864 &nsd->mac_local_faults);
865 i40e_stat_update32(hw, I40E_GLPRT_MRFC(hw->port),
866 pf->stat_offsets_loaded,
867 &osd->mac_remote_faults,
868 &nsd->mac_remote_faults);
869 895
870 i40e_stat_update32(hw, I40E_GLPRT_RLEC(hw->port), 896 i40e_stat_update32(hw, I40E_GLPRT_ILLERRC(hw->port),
871 pf->stat_offsets_loaded, 897 pf->stat_offsets_loaded,
872 &osd->rx_length_errors, 898 &osd->illegal_bytes, &nsd->illegal_bytes);
873 &nsd->rx_length_errors);
874 ns->rx_length_errors = nsd->rx_length_errors;
875 899
876 i40e_stat_update32(hw, I40E_GLPRT_LXONRXC(hw->port), 900 i40e_stat_update32(hw, I40E_GLPRT_MLFC(hw->port),
877 pf->stat_offsets_loaded, 901 pf->stat_offsets_loaded,
878 &osd->link_xon_rx, &nsd->link_xon_rx); 902 &osd->mac_local_faults,
879 i40e_stat_update32(hw, I40E_GLPRT_LXONTXC(hw->port), 903 &nsd->mac_local_faults);
880 pf->stat_offsets_loaded, 904 i40e_stat_update32(hw, I40E_GLPRT_MRFC(hw->port),
881 &osd->link_xon_tx, &nsd->link_xon_tx); 905 pf->stat_offsets_loaded,
882 i40e_update_prio_xoff_rx(pf); /* handles I40E_GLPRT_LXOFFRXC */ 906 &osd->mac_remote_faults,
883 i40e_stat_update32(hw, I40E_GLPRT_LXOFFTXC(hw->port), 907 &nsd->mac_remote_faults);
884 pf->stat_offsets_loaded,
885 &osd->link_xoff_tx, &nsd->link_xoff_tx);
886
887 for (i = 0; i < 8; i++) {
888 i40e_stat_update32(hw, I40E_GLPRT_PXONRXC(hw->port, i),
889 pf->stat_offsets_loaded,
890 &osd->priority_xon_rx[i],
891 &nsd->priority_xon_rx[i]);
892 i40e_stat_update32(hw, I40E_GLPRT_PXONTXC(hw->port, i),
893 pf->stat_offsets_loaded,
894 &osd->priority_xon_tx[i],
895 &nsd->priority_xon_tx[i]);
896 i40e_stat_update32(hw, I40E_GLPRT_PXOFFTXC(hw->port, i),
897 pf->stat_offsets_loaded,
898 &osd->priority_xoff_tx[i],
899 &nsd->priority_xoff_tx[i]);
900 i40e_stat_update32(hw,
901 I40E_GLPRT_RXON2OFFCNT(hw->port, i),
902 pf->stat_offsets_loaded,
903 &osd->priority_xon_2_xoff[i],
904 &nsd->priority_xon_2_xoff[i]);
905 }
906 908
907 i40e_stat_update48(hw, I40E_GLPRT_PRC64H(hw->port), 909 i40e_stat_update32(hw, I40E_GLPRT_RLEC(hw->port),
908 I40E_GLPRT_PRC64L(hw->port), 910 pf->stat_offsets_loaded,
909 pf->stat_offsets_loaded, 911 &osd->rx_length_errors,
910 &osd->rx_size_64, &nsd->rx_size_64); 912 &nsd->rx_length_errors);
911 i40e_stat_update48(hw, I40E_GLPRT_PRC127H(hw->port),
912 I40E_GLPRT_PRC127L(hw->port),
913 pf->stat_offsets_loaded,
914 &osd->rx_size_127, &nsd->rx_size_127);
915 i40e_stat_update48(hw, I40E_GLPRT_PRC255H(hw->port),
916 I40E_GLPRT_PRC255L(hw->port),
917 pf->stat_offsets_loaded,
918 &osd->rx_size_255, &nsd->rx_size_255);
919 i40e_stat_update48(hw, I40E_GLPRT_PRC511H(hw->port),
920 I40E_GLPRT_PRC511L(hw->port),
921 pf->stat_offsets_loaded,
922 &osd->rx_size_511, &nsd->rx_size_511);
923 i40e_stat_update48(hw, I40E_GLPRT_PRC1023H(hw->port),
924 I40E_GLPRT_PRC1023L(hw->port),
925 pf->stat_offsets_loaded,
926 &osd->rx_size_1023, &nsd->rx_size_1023);
927 i40e_stat_update48(hw, I40E_GLPRT_PRC1522H(hw->port),
928 I40E_GLPRT_PRC1522L(hw->port),
929 pf->stat_offsets_loaded,
930 &osd->rx_size_1522, &nsd->rx_size_1522);
931 i40e_stat_update48(hw, I40E_GLPRT_PRC9522H(hw->port),
932 I40E_GLPRT_PRC9522L(hw->port),
933 pf->stat_offsets_loaded,
934 &osd->rx_size_big, &nsd->rx_size_big);
935 913
936 i40e_stat_update48(hw, I40E_GLPRT_PTC64H(hw->port), 914 i40e_stat_update32(hw, I40E_GLPRT_LXONRXC(hw->port),
937 I40E_GLPRT_PTC64L(hw->port), 915 pf->stat_offsets_loaded,
938 pf->stat_offsets_loaded, 916 &osd->link_xon_rx, &nsd->link_xon_rx);
939 &osd->tx_size_64, &nsd->tx_size_64); 917 i40e_stat_update32(hw, I40E_GLPRT_LXONTXC(hw->port),
940 i40e_stat_update48(hw, I40E_GLPRT_PTC127H(hw->port), 918 pf->stat_offsets_loaded,
941 I40E_GLPRT_PTC127L(hw->port), 919 &osd->link_xon_tx, &nsd->link_xon_tx);
942 pf->stat_offsets_loaded, 920 i40e_update_prio_xoff_rx(pf); /* handles I40E_GLPRT_LXOFFRXC */
943 &osd->tx_size_127, &nsd->tx_size_127); 921 i40e_stat_update32(hw, I40E_GLPRT_LXOFFTXC(hw->port),
944 i40e_stat_update48(hw, I40E_GLPRT_PTC255H(hw->port), 922 pf->stat_offsets_loaded,
945 I40E_GLPRT_PTC255L(hw->port), 923 &osd->link_xoff_tx, &nsd->link_xoff_tx);
946 pf->stat_offsets_loaded,
947 &osd->tx_size_255, &nsd->tx_size_255);
948 i40e_stat_update48(hw, I40E_GLPRT_PTC511H(hw->port),
949 I40E_GLPRT_PTC511L(hw->port),
950 pf->stat_offsets_loaded,
951 &osd->tx_size_511, &nsd->tx_size_511);
952 i40e_stat_update48(hw, I40E_GLPRT_PTC1023H(hw->port),
953 I40E_GLPRT_PTC1023L(hw->port),
954 pf->stat_offsets_loaded,
955 &osd->tx_size_1023, &nsd->tx_size_1023);
956 i40e_stat_update48(hw, I40E_GLPRT_PTC1522H(hw->port),
957 I40E_GLPRT_PTC1522L(hw->port),
958 pf->stat_offsets_loaded,
959 &osd->tx_size_1522, &nsd->tx_size_1522);
960 i40e_stat_update48(hw, I40E_GLPRT_PTC9522H(hw->port),
961 I40E_GLPRT_PTC9522L(hw->port),
962 pf->stat_offsets_loaded,
963 &osd->tx_size_big, &nsd->tx_size_big);
964 924
965 i40e_stat_update32(hw, I40E_GLPRT_RUC(hw->port), 925 for (i = 0; i < 8; i++) {
966 pf->stat_offsets_loaded, 926 i40e_stat_update32(hw, I40E_GLPRT_PXONRXC(hw->port, i),
967 &osd->rx_undersize, &nsd->rx_undersize);
968 i40e_stat_update32(hw, I40E_GLPRT_RFC(hw->port),
969 pf->stat_offsets_loaded, 927 pf->stat_offsets_loaded,
970 &osd->rx_fragments, &nsd->rx_fragments); 928 &osd->priority_xon_rx[i],
971 i40e_stat_update32(hw, I40E_GLPRT_ROC(hw->port), 929 &nsd->priority_xon_rx[i]);
930 i40e_stat_update32(hw, I40E_GLPRT_PXONTXC(hw->port, i),
972 pf->stat_offsets_loaded, 931 pf->stat_offsets_loaded,
973 &osd->rx_oversize, &nsd->rx_oversize); 932 &osd->priority_xon_tx[i],
974 i40e_stat_update32(hw, I40E_GLPRT_RJC(hw->port), 933 &nsd->priority_xon_tx[i]);
934 i40e_stat_update32(hw, I40E_GLPRT_PXOFFTXC(hw->port, i),
975 pf->stat_offsets_loaded, 935 pf->stat_offsets_loaded,
976 &osd->rx_jabber, &nsd->rx_jabber); 936 &osd->priority_xoff_tx[i],
977 937 &nsd->priority_xoff_tx[i]);
978 val = rd32(hw, I40E_PRTPM_EEE_STAT); 938 i40e_stat_update32(hw,
979 nsd->tx_lpi_status = 939 I40E_GLPRT_RXON2OFFCNT(hw->port, i),
980 (val & I40E_PRTPM_EEE_STAT_TX_LPI_STATUS_MASK) >>
981 I40E_PRTPM_EEE_STAT_TX_LPI_STATUS_SHIFT;
982 nsd->rx_lpi_status =
983 (val & I40E_PRTPM_EEE_STAT_RX_LPI_STATUS_MASK) >>
984 I40E_PRTPM_EEE_STAT_RX_LPI_STATUS_SHIFT;
985 i40e_stat_update32(hw, I40E_PRTPM_TLPIC,
986 pf->stat_offsets_loaded, 940 pf->stat_offsets_loaded,
987 &osd->tx_lpi_count, &nsd->tx_lpi_count); 941 &osd->priority_xon_2_xoff[i],
988 i40e_stat_update32(hw, I40E_PRTPM_RLPIC, 942 &nsd->priority_xon_2_xoff[i]);
989 pf->stat_offsets_loaded,
990 &osd->rx_lpi_count, &nsd->rx_lpi_count);
991 } 943 }
992 944
945 i40e_stat_update48(hw, I40E_GLPRT_PRC64H(hw->port),
946 I40E_GLPRT_PRC64L(hw->port),
947 pf->stat_offsets_loaded,
948 &osd->rx_size_64, &nsd->rx_size_64);
949 i40e_stat_update48(hw, I40E_GLPRT_PRC127H(hw->port),
950 I40E_GLPRT_PRC127L(hw->port),
951 pf->stat_offsets_loaded,
952 &osd->rx_size_127, &nsd->rx_size_127);
953 i40e_stat_update48(hw, I40E_GLPRT_PRC255H(hw->port),
954 I40E_GLPRT_PRC255L(hw->port),
955 pf->stat_offsets_loaded,
956 &osd->rx_size_255, &nsd->rx_size_255);
957 i40e_stat_update48(hw, I40E_GLPRT_PRC511H(hw->port),
958 I40E_GLPRT_PRC511L(hw->port),
959 pf->stat_offsets_loaded,
960 &osd->rx_size_511, &nsd->rx_size_511);
961 i40e_stat_update48(hw, I40E_GLPRT_PRC1023H(hw->port),
962 I40E_GLPRT_PRC1023L(hw->port),
963 pf->stat_offsets_loaded,
964 &osd->rx_size_1023, &nsd->rx_size_1023);
965 i40e_stat_update48(hw, I40E_GLPRT_PRC1522H(hw->port),
966 I40E_GLPRT_PRC1522L(hw->port),
967 pf->stat_offsets_loaded,
968 &osd->rx_size_1522, &nsd->rx_size_1522);
969 i40e_stat_update48(hw, I40E_GLPRT_PRC9522H(hw->port),
970 I40E_GLPRT_PRC9522L(hw->port),
971 pf->stat_offsets_loaded,
972 &osd->rx_size_big, &nsd->rx_size_big);
973
974 i40e_stat_update48(hw, I40E_GLPRT_PTC64H(hw->port),
975 I40E_GLPRT_PTC64L(hw->port),
976 pf->stat_offsets_loaded,
977 &osd->tx_size_64, &nsd->tx_size_64);
978 i40e_stat_update48(hw, I40E_GLPRT_PTC127H(hw->port),
979 I40E_GLPRT_PTC127L(hw->port),
980 pf->stat_offsets_loaded,
981 &osd->tx_size_127, &nsd->tx_size_127);
982 i40e_stat_update48(hw, I40E_GLPRT_PTC255H(hw->port),
983 I40E_GLPRT_PTC255L(hw->port),
984 pf->stat_offsets_loaded,
985 &osd->tx_size_255, &nsd->tx_size_255);
986 i40e_stat_update48(hw, I40E_GLPRT_PTC511H(hw->port),
987 I40E_GLPRT_PTC511L(hw->port),
988 pf->stat_offsets_loaded,
989 &osd->tx_size_511, &nsd->tx_size_511);
990 i40e_stat_update48(hw, I40E_GLPRT_PTC1023H(hw->port),
991 I40E_GLPRT_PTC1023L(hw->port),
992 pf->stat_offsets_loaded,
993 &osd->tx_size_1023, &nsd->tx_size_1023);
994 i40e_stat_update48(hw, I40E_GLPRT_PTC1522H(hw->port),
995 I40E_GLPRT_PTC1522L(hw->port),
996 pf->stat_offsets_loaded,
997 &osd->tx_size_1522, &nsd->tx_size_1522);
998 i40e_stat_update48(hw, I40E_GLPRT_PTC9522H(hw->port),
999 I40E_GLPRT_PTC9522L(hw->port),
1000 pf->stat_offsets_loaded,
1001 &osd->tx_size_big, &nsd->tx_size_big);
1002
1003 i40e_stat_update32(hw, I40E_GLPRT_RUC(hw->port),
1004 pf->stat_offsets_loaded,
1005 &osd->rx_undersize, &nsd->rx_undersize);
1006 i40e_stat_update32(hw, I40E_GLPRT_RFC(hw->port),
1007 pf->stat_offsets_loaded,
1008 &osd->rx_fragments, &nsd->rx_fragments);
1009 i40e_stat_update32(hw, I40E_GLPRT_ROC(hw->port),
1010 pf->stat_offsets_loaded,
1011 &osd->rx_oversize, &nsd->rx_oversize);
1012 i40e_stat_update32(hw, I40E_GLPRT_RJC(hw->port),
1013 pf->stat_offsets_loaded,
1014 &osd->rx_jabber, &nsd->rx_jabber);
1015
1016 /* FDIR stats */
1017 i40e_stat_update32(hw, I40E_GLQF_PCNT(pf->fd_atr_cnt_idx),
1018 pf->stat_offsets_loaded,
1019 &osd->fd_atr_match, &nsd->fd_atr_match);
1020 i40e_stat_update32(hw, I40E_GLQF_PCNT(pf->fd_sb_cnt_idx),
1021 pf->stat_offsets_loaded,
1022 &osd->fd_sb_match, &nsd->fd_sb_match);
1023
1024 val = rd32(hw, I40E_PRTPM_EEE_STAT);
1025 nsd->tx_lpi_status =
1026 (val & I40E_PRTPM_EEE_STAT_TX_LPI_STATUS_MASK) >>
1027 I40E_PRTPM_EEE_STAT_TX_LPI_STATUS_SHIFT;
1028 nsd->rx_lpi_status =
1029 (val & I40E_PRTPM_EEE_STAT_RX_LPI_STATUS_MASK) >>
1030 I40E_PRTPM_EEE_STAT_RX_LPI_STATUS_SHIFT;
1031 i40e_stat_update32(hw, I40E_PRTPM_TLPIC,
1032 pf->stat_offsets_loaded,
1033 &osd->tx_lpi_count, &nsd->tx_lpi_count);
1034 i40e_stat_update32(hw, I40E_PRTPM_RLPIC,
1035 pf->stat_offsets_loaded,
1036 &osd->rx_lpi_count, &nsd->rx_lpi_count);
1037
993 pf->stat_offsets_loaded = true; 1038 pf->stat_offsets_loaded = true;
994} 1039}
995 1040
996/** 1041/**
1042 * i40e_update_stats - Update the various statistics counters.
1043 * @vsi: the VSI to be updated
1044 *
1045 * Update the various stats for this VSI and its related entities.
1046 **/
1047void i40e_update_stats(struct i40e_vsi *vsi)
1048{
1049 struct i40e_pf *pf = vsi->back;
1050
1051 if (vsi == pf->vsi[pf->lan_vsi])
1052 i40e_update_pf_stats(pf);
1053
1054 i40e_update_vsi_stats(vsi);
1055}
1056
1057/**
997 * i40e_find_filter - Search VSI filter list for specific mac/vlan filter 1058 * i40e_find_filter - Search VSI filter list for specific mac/vlan filter
998 * @vsi: the VSI to be searched 1059 * @vsi: the VSI to be searched
999 * @macaddr: the MAC address 1060 * @macaddr: the MAC address
@@ -1101,6 +1162,30 @@ struct i40e_mac_filter *i40e_put_mac_in_vlan(struct i40e_vsi *vsi, u8 *macaddr,
1101} 1162}
1102 1163
1103/** 1164/**
1165 * i40e_rm_default_mac_filter - Remove the default MAC filter set by NVM
1166 * @vsi: the PF Main VSI - inappropriate for any other VSI
1167 * @macaddr: the MAC address
1168 **/
1169static void i40e_rm_default_mac_filter(struct i40e_vsi *vsi, u8 *macaddr)
1170{
1171 struct i40e_aqc_remove_macvlan_element_data element;
1172 struct i40e_pf *pf = vsi->back;
1173 i40e_status aq_ret;
1174
1175 /* Only appropriate for the PF main VSI */
1176 if (vsi->type != I40E_VSI_MAIN)
1177 return;
1178
1179 ether_addr_copy(element.mac_addr, macaddr);
1180 element.vlan_tag = 0;
1181 element.flags = I40E_AQC_MACVLAN_DEL_PERFECT_MATCH |
1182 I40E_AQC_MACVLAN_DEL_IGNORE_VLAN;
1183 aq_ret = i40e_aq_remove_macvlan(&pf->hw, vsi->seid, &element, 1, NULL);
1184 if (aq_ret)
1185 dev_err(&pf->pdev->dev, "Could not remove default MAC-VLAN\n");
1186}
1187
1188/**
1104 * i40e_add_filter - Add a mac/vlan filter to the VSI 1189 * i40e_add_filter - Add a mac/vlan filter to the VSI
1105 * @vsi: the VSI to be searched 1190 * @vsi: the VSI to be searched
1106 * @macaddr: the MAC address 1191 * @macaddr: the MAC address
@@ -1125,7 +1210,7 @@ struct i40e_mac_filter *i40e_add_filter(struct i40e_vsi *vsi,
1125 if (!f) 1210 if (!f)
1126 goto add_filter_out; 1211 goto add_filter_out;
1127 1212
1128 memcpy(f->macaddr, macaddr, ETH_ALEN); 1213 ether_addr_copy(f->macaddr, macaddr);
1129 f->vlan = vlan; 1214 f->vlan = vlan;
1130 f->changed = true; 1215 f->changed = true;
1131 1216
@@ -1249,7 +1334,7 @@ static int i40e_set_mac(struct net_device *netdev, void *p)
1249 return -EADDRNOTAVAIL; 1334 return -EADDRNOTAVAIL;
1250 } 1335 }
1251 1336
1252 memcpy(vsi->back->hw.mac.addr, addr->sa_data, netdev->addr_len); 1337 ether_addr_copy(vsi->back->hw.mac.addr, addr->sa_data);
1253 } 1338 }
1254 1339
1255 /* In order to be sure to not drop any packets, add the new address 1340 /* In order to be sure to not drop any packets, add the new address
@@ -1263,7 +1348,7 @@ static int i40e_set_mac(struct net_device *netdev, void *p)
1263 i40e_del_filter(vsi, netdev->dev_addr, I40E_VLAN_ANY, false, false); 1348 i40e_del_filter(vsi, netdev->dev_addr, I40E_VLAN_ANY, false, false);
1264 i40e_sync_vsi_filters(vsi); 1349 i40e_sync_vsi_filters(vsi);
1265 1350
1266 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); 1351 ether_addr_copy(netdev->dev_addr, addr->sa_data);
1267 1352
1268 return 0; 1353 return 0;
1269} 1354}
@@ -1313,7 +1398,7 @@ static void i40e_vsi_setup_queue_map(struct i40e_vsi *vsi,
1313 vsi->tc_config.numtc = numtc; 1398 vsi->tc_config.numtc = numtc;
1314 vsi->tc_config.enabled_tc = enabled_tc ? enabled_tc : 1; 1399 vsi->tc_config.enabled_tc = enabled_tc ? enabled_tc : 1;
1315 /* Number of queues per enabled TC */ 1400 /* Number of queues per enabled TC */
1316 num_tc_qps = rounddown_pow_of_two(vsi->alloc_queue_pairs/numtc); 1401 num_tc_qps = vsi->alloc_queue_pairs/numtc;
1317 num_tc_qps = min_t(int, num_tc_qps, I40E_MAX_QUEUES_PER_TC); 1402 num_tc_qps = min_t(int, num_tc_qps, I40E_MAX_QUEUES_PER_TC);
1318 1403
1319 /* Setup queue offset/count for all TCs for given VSI */ 1404 /* Setup queue offset/count for all TCs for given VSI */
@@ -1520,8 +1605,7 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi)
1520 cmd_flags = 0; 1605 cmd_flags = 0;
1521 1606
1522 /* add to delete list */ 1607 /* add to delete list */
1523 memcpy(del_list[num_del].mac_addr, 1608 ether_addr_copy(del_list[num_del].mac_addr, f->macaddr);
1524 f->macaddr, ETH_ALEN);
1525 del_list[num_del].vlan_tag = 1609 del_list[num_del].vlan_tag =
1526 cpu_to_le16((u16)(f->vlan == 1610 cpu_to_le16((u16)(f->vlan ==
1527 I40E_VLAN_ANY ? 0 : f->vlan)); 1611 I40E_VLAN_ANY ? 0 : f->vlan));
@@ -1542,7 +1626,9 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi)
1542 num_del = 0; 1626 num_del = 0;
1543 memset(del_list, 0, sizeof(*del_list)); 1627 memset(del_list, 0, sizeof(*del_list));
1544 1628
1545 if (aq_ret) 1629 if (aq_ret &&
1630 pf->hw.aq.asq_last_status !=
1631 I40E_AQ_RC_ENOENT)
1546 dev_info(&pf->pdev->dev, 1632 dev_info(&pf->pdev->dev,
1547 "ignoring delete macvlan error, err %d, aq_err %d while flushing a full buffer\n", 1633 "ignoring delete macvlan error, err %d, aq_err %d while flushing a full buffer\n",
1548 aq_ret, 1634 aq_ret,
@@ -1554,7 +1640,8 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi)
1554 del_list, num_del, NULL); 1640 del_list, num_del, NULL);
1555 num_del = 0; 1641 num_del = 0;
1556 1642
1557 if (aq_ret) 1643 if (aq_ret &&
1644 pf->hw.aq.asq_last_status != I40E_AQ_RC_ENOENT)
1558 dev_info(&pf->pdev->dev, 1645 dev_info(&pf->pdev->dev,
1559 "ignoring delete macvlan error, err %d, aq_err %d\n", 1646 "ignoring delete macvlan error, err %d, aq_err %d\n",
1560 aq_ret, pf->hw.aq.asq_last_status); 1647 aq_ret, pf->hw.aq.asq_last_status);
@@ -1583,8 +1670,7 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi)
1583 cmd_flags = 0; 1670 cmd_flags = 0;
1584 1671
1585 /* add to add array */ 1672 /* add to add array */
1586 memcpy(add_list[num_add].mac_addr, 1673 ether_addr_copy(add_list[num_add].mac_addr, f->macaddr);
1587 f->macaddr, ETH_ALEN);
1588 add_list[num_add].vlan_tag = 1674 add_list[num_add].vlan_tag =
1589 cpu_to_le16( 1675 cpu_to_le16(
1590 (u16)(f->vlan == I40E_VLAN_ANY ? 0 : f->vlan)); 1676 (u16)(f->vlan == I40E_VLAN_ANY ? 0 : f->vlan));
@@ -1681,7 +1767,7 @@ static void i40e_sync_filters_subtask(struct i40e_pf *pf)
1681 return; 1767 return;
1682 pf->flags &= ~I40E_FLAG_FILTER_SYNC; 1768 pf->flags &= ~I40E_FLAG_FILTER_SYNC;
1683 1769
1684 for (v = 0; v < pf->hw.func_caps.num_vsis; v++) { 1770 for (v = 0; v < pf->num_alloc_vsi; v++) {
1685 if (pf->vsi[v] && 1771 if (pf->vsi[v] &&
1686 (pf->vsi[v]->flags & I40E_VSI_FLAG_FILTER_CHANGED)) 1772 (pf->vsi[v]->flags & I40E_VSI_FLAG_FILTER_CHANGED))
1687 i40e_sync_vsi_filters(pf->vsi[v]); 1773 i40e_sync_vsi_filters(pf->vsi[v]);
@@ -1698,7 +1784,7 @@ static void i40e_sync_filters_subtask(struct i40e_pf *pf)
1698static int i40e_change_mtu(struct net_device *netdev, int new_mtu) 1784static int i40e_change_mtu(struct net_device *netdev, int new_mtu)
1699{ 1785{
1700 struct i40e_netdev_priv *np = netdev_priv(netdev); 1786 struct i40e_netdev_priv *np = netdev_priv(netdev);
1701 int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN; 1787 int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN;
1702 struct i40e_vsi *vsi = np->vsi; 1788 struct i40e_vsi *vsi = np->vsi;
1703 1789
1704 /* MTU < 68 is an error and causes problems on some kernels */ 1790 /* MTU < 68 is an error and causes problems on some kernels */
@@ -2312,6 +2398,8 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
2312 rx_ctx.crcstrip = 1; 2398 rx_ctx.crcstrip = 1;
2313 rx_ctx.l2tsel = 1; 2399 rx_ctx.l2tsel = 1;
2314 rx_ctx.showiv = 1; 2400 rx_ctx.showiv = 1;
2401 /* set the prefena field to 1 because the manual says to */
2402 rx_ctx.prefena = 1;
2315 2403
2316 /* clear the context in the HMC */ 2404 /* clear the context in the HMC */
2317 err = i40e_clear_lan_rx_queue_context(hw, pf_q); 2405 err = i40e_clear_lan_rx_queue_context(hw, pf_q);
@@ -2413,6 +2501,7 @@ static int i40e_vsi_configure_rx(struct i40e_vsi *vsi)
2413 **/ 2501 **/
2414static void i40e_vsi_config_dcb_rings(struct i40e_vsi *vsi) 2502static void i40e_vsi_config_dcb_rings(struct i40e_vsi *vsi)
2415{ 2503{
2504 struct i40e_ring *tx_ring, *rx_ring;
2416 u16 qoffset, qcount; 2505 u16 qoffset, qcount;
2417 int i, n; 2506 int i, n;
2418 2507
@@ -2426,8 +2515,8 @@ static void i40e_vsi_config_dcb_rings(struct i40e_vsi *vsi)
2426 qoffset = vsi->tc_config.tc_info[n].qoffset; 2515 qoffset = vsi->tc_config.tc_info[n].qoffset;
2427 qcount = vsi->tc_config.tc_info[n].qcount; 2516 qcount = vsi->tc_config.tc_info[n].qcount;
2428 for (i = qoffset; i < (qoffset + qcount); i++) { 2517 for (i = qoffset; i < (qoffset + qcount); i++) {
2429 struct i40e_ring *rx_ring = vsi->rx_rings[i]; 2518 rx_ring = vsi->rx_rings[i];
2430 struct i40e_ring *tx_ring = vsi->tx_rings[i]; 2519 tx_ring = vsi->tx_rings[i];
2431 rx_ring->dcb_tc = n; 2520 rx_ring->dcb_tc = n;
2432 tx_ring->dcb_tc = n; 2521 tx_ring->dcb_tc = n;
2433 } 2522 }
@@ -2565,7 +2654,6 @@ static void i40e_enable_misc_int_causes(struct i40e_hw *hw)
2565 I40E_PFINT_ICR0_ENA_PCI_EXCEPTION_MASK | 2654 I40E_PFINT_ICR0_ENA_PCI_EXCEPTION_MASK |
2566 I40E_PFINT_ICR0_ENA_GPIO_MASK | 2655 I40E_PFINT_ICR0_ENA_GPIO_MASK |
2567 I40E_PFINT_ICR0_ENA_TIMESYNC_MASK | 2656 I40E_PFINT_ICR0_ENA_TIMESYNC_MASK |
2568 I40E_PFINT_ICR0_ENA_STORM_DETECT_MASK |
2569 I40E_PFINT_ICR0_ENA_HMC_ERR_MASK | 2657 I40E_PFINT_ICR0_ENA_HMC_ERR_MASK |
2570 I40E_PFINT_ICR0_ENA_VFLR_MASK | 2658 I40E_PFINT_ICR0_ENA_VFLR_MASK |
2571 I40E_PFINT_ICR0_ENA_ADMINQ_MASK; 2659 I40E_PFINT_ICR0_ENA_ADMINQ_MASK;
@@ -2733,6 +2821,7 @@ static int i40e_vsi_request_irq_msix(struct i40e_vsi *vsi, char *basename)
2733 &q_vector->affinity_mask); 2821 &q_vector->affinity_mask);
2734 } 2822 }
2735 2823
2824 vsi->irqs_ready = true;
2736 return 0; 2825 return 0;
2737 2826
2738free_queue_irqs: 2827free_queue_irqs:
@@ -3152,6 +3241,12 @@ static int i40e_vsi_control_tx(struct i40e_vsi *vsi, bool enable)
3152 3241
3153 pf_q = vsi->base_queue; 3242 pf_q = vsi->base_queue;
3154 for (i = 0; i < vsi->num_queue_pairs; i++, pf_q++) { 3243 for (i = 0; i < vsi->num_queue_pairs; i++, pf_q++) {
3244
3245 /* warn the TX unit of coming changes */
3246 i40e_pre_tx_queue_cfg(&pf->hw, pf_q, enable);
3247 if (!enable)
3248 udelay(10);
3249
3155 for (j = 0; j < 50; j++) { 3250 for (j = 0; j < 50; j++) {
3156 tx_reg = rd32(hw, I40E_QTX_ENA(pf_q)); 3251 tx_reg = rd32(hw, I40E_QTX_ENA(pf_q));
3157 if (((tx_reg >> I40E_QTX_ENA_QENA_REQ_SHIFT) & 1) == 3252 if (((tx_reg >> I40E_QTX_ENA_QENA_REQ_SHIFT) & 1) ==
@@ -3160,9 +3255,7 @@ static int i40e_vsi_control_tx(struct i40e_vsi *vsi, bool enable)
3160 usleep_range(1000, 2000); 3255 usleep_range(1000, 2000);
3161 } 3256 }
3162 /* Skip if the queue is already in the requested state */ 3257 /* Skip if the queue is already in the requested state */
3163 if (enable && (tx_reg & I40E_QTX_ENA_QENA_STAT_MASK)) 3258 if (enable == !!(tx_reg & I40E_QTX_ENA_QENA_STAT_MASK))
3164 continue;
3165 if (!enable && !(tx_reg & I40E_QTX_ENA_QENA_STAT_MASK))
3166 continue; 3259 continue;
3167 3260
3168 /* turn on/off the queue */ 3261 /* turn on/off the queue */
@@ -3178,13 +3271,8 @@ static int i40e_vsi_control_tx(struct i40e_vsi *vsi, bool enable)
3178 /* wait for the change to finish */ 3271 /* wait for the change to finish */
3179 for (j = 0; j < 10; j++) { 3272 for (j = 0; j < 10; j++) {
3180 tx_reg = rd32(hw, I40E_QTX_ENA(pf_q)); 3273 tx_reg = rd32(hw, I40E_QTX_ENA(pf_q));
3181 if (enable) { 3274 if (enable == !!(tx_reg & I40E_QTX_ENA_QENA_STAT_MASK))
3182 if ((tx_reg & I40E_QTX_ENA_QENA_STAT_MASK)) 3275 break;
3183 break;
3184 } else {
3185 if (!(tx_reg & I40E_QTX_ENA_QENA_STAT_MASK))
3186 break;
3187 }
3188 3276
3189 udelay(10); 3277 udelay(10);
3190 } 3278 }
@@ -3223,15 +3311,9 @@ static int i40e_vsi_control_rx(struct i40e_vsi *vsi, bool enable)
3223 usleep_range(1000, 2000); 3311 usleep_range(1000, 2000);
3224 } 3312 }
3225 3313
3226 if (enable) { 3314 /* Skip if the queue is already in the requested state */
3227 /* is STAT set ? */ 3315 if (enable == !!(rx_reg & I40E_QRX_ENA_QENA_STAT_MASK))
3228 if ((rx_reg & I40E_QRX_ENA_QENA_STAT_MASK)) 3316 continue;
3229 continue;
3230 } else {
3231 /* is !STAT set ? */
3232 if (!(rx_reg & I40E_QRX_ENA_QENA_STAT_MASK))
3233 continue;
3234 }
3235 3317
3236 /* turn on/off the queue */ 3318 /* turn on/off the queue */
3237 if (enable) 3319 if (enable)
@@ -3244,13 +3326,8 @@ static int i40e_vsi_control_rx(struct i40e_vsi *vsi, bool enable)
3244 for (j = 0; j < 10; j++) { 3326 for (j = 0; j < 10; j++) {
3245 rx_reg = rd32(hw, I40E_QRX_ENA(pf_q)); 3327 rx_reg = rd32(hw, I40E_QRX_ENA(pf_q));
3246 3328
3247 if (enable) { 3329 if (enable == !!(rx_reg & I40E_QRX_ENA_QENA_STAT_MASK))
3248 if ((rx_reg & I40E_QRX_ENA_QENA_STAT_MASK)) 3330 break;
3249 break;
3250 } else {
3251 if (!(rx_reg & I40E_QRX_ENA_QENA_STAT_MASK))
3252 break;
3253 }
3254 3331
3255 udelay(10); 3332 udelay(10);
3256 } 3333 }
@@ -3304,6 +3381,10 @@ static void i40e_vsi_free_irq(struct i40e_vsi *vsi)
3304 if (!vsi->q_vectors) 3381 if (!vsi->q_vectors)
3305 return; 3382 return;
3306 3383
3384 if (!vsi->irqs_ready)
3385 return;
3386
3387 vsi->irqs_ready = false;
3307 for (i = 0; i < vsi->num_q_vectors; i++) { 3388 for (i = 0; i < vsi->num_q_vectors; i++) {
3308 u16 vector = i + base; 3389 u16 vector = i + base;
3309 3390
@@ -3476,7 +3557,7 @@ static void i40e_clear_interrupt_scheme(struct i40e_pf *pf)
3476 int i; 3557 int i;
3477 3558
3478 i40e_put_lump(pf->irq_pile, 0, I40E_PILE_VALID_BIT-1); 3559 i40e_put_lump(pf->irq_pile, 0, I40E_PILE_VALID_BIT-1);
3479 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) 3560 for (i = 0; i < pf->num_alloc_vsi; i++)
3480 if (pf->vsi[i]) 3561 if (pf->vsi[i])
3481 i40e_vsi_free_q_vectors(pf->vsi[i]); 3562 i40e_vsi_free_q_vectors(pf->vsi[i]);
3482 i40e_reset_interrupt_capability(pf); 3563 i40e_reset_interrupt_capability(pf);
@@ -3513,6 +3594,19 @@ static void i40e_napi_disable_all(struct i40e_vsi *vsi)
3513} 3594}
3514 3595
3515/** 3596/**
3597 * i40e_vsi_close - Shut down a VSI
3598 * @vsi: the vsi to be quelled
3599 **/
3600static void i40e_vsi_close(struct i40e_vsi *vsi)
3601{
3602 if (!test_and_set_bit(__I40E_DOWN, &vsi->state))
3603 i40e_down(vsi);
3604 i40e_vsi_free_irq(vsi);
3605 i40e_vsi_free_tx_resources(vsi);
3606 i40e_vsi_free_rx_resources(vsi);
3607}
3608
3609/**
3516 * i40e_quiesce_vsi - Pause a given VSI 3610 * i40e_quiesce_vsi - Pause a given VSI
3517 * @vsi: the VSI being paused 3611 * @vsi: the VSI being paused
3518 **/ 3612 **/
@@ -3525,8 +3619,7 @@ static void i40e_quiesce_vsi(struct i40e_vsi *vsi)
3525 if (vsi->netdev && netif_running(vsi->netdev)) { 3619 if (vsi->netdev && netif_running(vsi->netdev)) {
3526 vsi->netdev->netdev_ops->ndo_stop(vsi->netdev); 3620 vsi->netdev->netdev_ops->ndo_stop(vsi->netdev);
3527 } else { 3621 } else {
3528 set_bit(__I40E_DOWN, &vsi->state); 3622 i40e_vsi_close(vsi);
3529 i40e_down(vsi);
3530 } 3623 }
3531} 3624}
3532 3625
@@ -3543,7 +3636,7 @@ static void i40e_unquiesce_vsi(struct i40e_vsi *vsi)
3543 if (vsi->netdev && netif_running(vsi->netdev)) 3636 if (vsi->netdev && netif_running(vsi->netdev))
3544 vsi->netdev->netdev_ops->ndo_open(vsi->netdev); 3637 vsi->netdev->netdev_ops->ndo_open(vsi->netdev);
3545 else 3638 else
3546 i40e_up(vsi); /* this clears the DOWN bit */ 3639 i40e_vsi_open(vsi); /* this clears the DOWN bit */
3547} 3640}
3548 3641
3549/** 3642/**
@@ -3554,7 +3647,7 @@ static void i40e_pf_quiesce_all_vsi(struct i40e_pf *pf)
3554{ 3647{
3555 int v; 3648 int v;
3556 3649
3557 for (v = 0; v < pf->hw.func_caps.num_vsis; v++) { 3650 for (v = 0; v < pf->num_alloc_vsi; v++) {
3558 if (pf->vsi[v]) 3651 if (pf->vsi[v])
3559 i40e_quiesce_vsi(pf->vsi[v]); 3652 i40e_quiesce_vsi(pf->vsi[v]);
3560 } 3653 }
@@ -3568,7 +3661,7 @@ static void i40e_pf_unquiesce_all_vsi(struct i40e_pf *pf)
3568{ 3661{
3569 int v; 3662 int v;
3570 3663
3571 for (v = 0; v < pf->hw.func_caps.num_vsis; v++) { 3664 for (v = 0; v < pf->num_alloc_vsi; v++) {
3572 if (pf->vsi[v]) 3665 if (pf->vsi[v])
3573 i40e_unquiesce_vsi(pf->vsi[v]); 3666 i40e_unquiesce_vsi(pf->vsi[v]);
3574 } 3667 }
@@ -4009,7 +4102,7 @@ static void i40e_dcb_reconfigure(struct i40e_pf *pf)
4009 } 4102 }
4010 4103
4011 /* Update each VSI */ 4104 /* Update each VSI */
4012 for (v = 0; v < pf->hw.func_caps.num_vsis; v++) { 4105 for (v = 0; v < pf->num_alloc_vsi; v++) {
4013 if (!pf->vsi[v]) 4106 if (!pf->vsi[v])
4014 continue; 4107 continue;
4015 4108
@@ -4028,6 +4121,8 @@ static void i40e_dcb_reconfigure(struct i40e_pf *pf)
4028 pf->vsi[v]->seid); 4121 pf->vsi[v]->seid);
4029 /* Will try to configure as many components */ 4122 /* Will try to configure as many components */
4030 } else { 4123 } else {
4124 /* Re-configure VSI vectors based on updated TC map */
4125 i40e_vsi_map_rings_to_vectors(pf->vsi[v]);
4031 if (pf->vsi[v]->netdev) 4126 if (pf->vsi[v]->netdev)
4032 i40e_dcbnl_set_all(pf->vsi[v]); 4127 i40e_dcbnl_set_all(pf->vsi[v]);
4033 } 4128 }
@@ -4065,14 +4160,69 @@ static int i40e_init_pf_dcb(struct i40e_pf *pf)
4065 /* When status is not DISABLED then DCBX in FW */ 4160 /* When status is not DISABLED then DCBX in FW */
4066 pf->dcbx_cap = DCB_CAP_DCBX_LLD_MANAGED | 4161 pf->dcbx_cap = DCB_CAP_DCBX_LLD_MANAGED |
4067 DCB_CAP_DCBX_VER_IEEE; 4162 DCB_CAP_DCBX_VER_IEEE;
4068 pf->flags |= I40E_FLAG_DCB_ENABLED; 4163
4164 pf->flags |= I40E_FLAG_DCB_CAPABLE;
4165 /* Enable DCB tagging only when more than one TC */
4166 if (i40e_dcb_get_num_tc(&hw->local_dcbx_config) > 1)
4167 pf->flags |= I40E_FLAG_DCB_ENABLED;
4069 } 4168 }
4169 } else {
4170 dev_info(&pf->pdev->dev, "AQ Querying DCB configuration failed: %d\n",
4171 pf->hw.aq.asq_last_status);
4070 } 4172 }
4071 4173
4072out: 4174out:
4073 return err; 4175 return err;
4074} 4176}
4075#endif /* CONFIG_I40E_DCB */ 4177#endif /* CONFIG_I40E_DCB */
4178#define SPEED_SIZE 14
4179#define FC_SIZE 8
4180/**
4181 * i40e_print_link_message - print link up or down
4182 * @vsi: the VSI for which link needs a message
4183 */
4184static void i40e_print_link_message(struct i40e_vsi *vsi, bool isup)
4185{
4186 char speed[SPEED_SIZE] = "Unknown";
4187 char fc[FC_SIZE] = "RX/TX";
4188
4189 if (!isup) {
4190 netdev_info(vsi->netdev, "NIC Link is Down\n");
4191 return;
4192 }
4193
4194 switch (vsi->back->hw.phy.link_info.link_speed) {
4195 case I40E_LINK_SPEED_40GB:
4196 strncpy(speed, "40 Gbps", SPEED_SIZE);
4197 break;
4198 case I40E_LINK_SPEED_10GB:
4199 strncpy(speed, "10 Gbps", SPEED_SIZE);
4200 break;
4201 case I40E_LINK_SPEED_1GB:
4202 strncpy(speed, "1000 Mbps", SPEED_SIZE);
4203 break;
4204 default:
4205 break;
4206 }
4207
4208 switch (vsi->back->hw.fc.current_mode) {
4209 case I40E_FC_FULL:
4210 strncpy(fc, "RX/TX", FC_SIZE);
4211 break;
4212 case I40E_FC_TX_PAUSE:
4213 strncpy(fc, "TX", FC_SIZE);
4214 break;
4215 case I40E_FC_RX_PAUSE:
4216 strncpy(fc, "RX", FC_SIZE);
4217 break;
4218 default:
4219 strncpy(fc, "None", FC_SIZE);
4220 break;
4221 }
4222
4223 netdev_info(vsi->netdev, "NIC Link is Up %s Full Duplex, Flow Control: %s\n",
4224 speed, fc);
4225}
4076 4226
4077/** 4227/**
4078 * i40e_up_complete - Finish the last steps of bringing up a connection 4228 * i40e_up_complete - Finish the last steps of bringing up a connection
@@ -4099,11 +4249,11 @@ static int i40e_up_complete(struct i40e_vsi *vsi)
4099 4249
4100 if ((pf->hw.phy.link_info.link_info & I40E_AQ_LINK_UP) && 4250 if ((pf->hw.phy.link_info.link_info & I40E_AQ_LINK_UP) &&
4101 (vsi->netdev)) { 4251 (vsi->netdev)) {
4102 netdev_info(vsi->netdev, "NIC Link is Up\n"); 4252 i40e_print_link_message(vsi, true);
4103 netif_tx_start_all_queues(vsi->netdev); 4253 netif_tx_start_all_queues(vsi->netdev);
4104 netif_carrier_on(vsi->netdev); 4254 netif_carrier_on(vsi->netdev);
4105 } else if (vsi->netdev) { 4255 } else if (vsi->netdev) {
4106 netdev_info(vsi->netdev, "NIC Link is Down\n"); 4256 i40e_print_link_message(vsi, false);
4107 } 4257 }
4108 4258
4109 /* replay FDIR SB filters */ 4259 /* replay FDIR SB filters */
@@ -4309,24 +4459,32 @@ int i40e_vsi_open(struct i40e_vsi *vsi)
4309 if (err) 4459 if (err)
4310 goto err_setup_rx; 4460 goto err_setup_rx;
4311 4461
4312 if (!vsi->netdev) { 4462 if (vsi->netdev) {
4313 err = EINVAL; 4463 snprintf(int_name, sizeof(int_name) - 1, "%s-%s",
4314 goto err_setup_rx; 4464 dev_driver_string(&pf->pdev->dev), vsi->netdev->name);
4315 } 4465 err = i40e_vsi_request_irq(vsi, int_name);
4316 snprintf(int_name, sizeof(int_name) - 1, "%s-%s", 4466 if (err)
4317 dev_driver_string(&pf->pdev->dev), vsi->netdev->name); 4467 goto err_setup_rx;
4318 err = i40e_vsi_request_irq(vsi, int_name);
4319 if (err)
4320 goto err_setup_rx;
4321 4468
4322 /* Notify the stack of the actual queue counts. */ 4469 /* Notify the stack of the actual queue counts. */
4323 err = netif_set_real_num_tx_queues(vsi->netdev, vsi->num_queue_pairs); 4470 err = netif_set_real_num_tx_queues(vsi->netdev,
4324 if (err) 4471 vsi->num_queue_pairs);
4325 goto err_set_queues; 4472 if (err)
4473 goto err_set_queues;
4326 4474
4327 err = netif_set_real_num_rx_queues(vsi->netdev, vsi->num_queue_pairs); 4475 err = netif_set_real_num_rx_queues(vsi->netdev,
4328 if (err) 4476 vsi->num_queue_pairs);
4329 goto err_set_queues; 4477 if (err)
4478 goto err_set_queues;
4479
4480 } else if (vsi->type == I40E_VSI_FDIR) {
4481 snprintf(int_name, sizeof(int_name) - 1, "%s-fdir",
4482 dev_driver_string(&pf->pdev->dev));
4483 err = i40e_vsi_request_irq(vsi, int_name);
4484 } else {
4485 err = -EINVAL;
4486 goto err_setup_rx;
4487 }
4330 4488
4331 err = i40e_up_complete(vsi); 4489 err = i40e_up_complete(vsi);
4332 if (err) 4490 if (err)
@@ -4383,14 +4541,7 @@ static int i40e_close(struct net_device *netdev)
4383 struct i40e_netdev_priv *np = netdev_priv(netdev); 4541 struct i40e_netdev_priv *np = netdev_priv(netdev);
4384 struct i40e_vsi *vsi = np->vsi; 4542 struct i40e_vsi *vsi = np->vsi;
4385 4543
4386 if (test_and_set_bit(__I40E_DOWN, &vsi->state)) 4544 i40e_vsi_close(vsi);
4387 return 0;
4388
4389 i40e_down(vsi);
4390 i40e_vsi_free_irq(vsi);
4391
4392 i40e_vsi_free_tx_resources(vsi);
4393 i40e_vsi_free_rx_resources(vsi);
4394 4545
4395 return 0; 4546 return 0;
4396} 4547}
@@ -4410,6 +4561,9 @@ void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags)
4410 4561
4411 WARN_ON(in_interrupt()); 4562 WARN_ON(in_interrupt());
4412 4563
4564 if (i40e_check_asq_alive(&pf->hw))
4565 i40e_vc_notify_reset(pf);
4566
4413 /* do the biggest reset indicated */ 4567 /* do the biggest reset indicated */
4414 if (reset_flags & (1 << __I40E_GLOBAL_RESET_REQUESTED)) { 4568 if (reset_flags & (1 << __I40E_GLOBAL_RESET_REQUESTED)) {
4415 4569
@@ -4475,7 +4629,7 @@ void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags)
4475 /* Find the VSI(s) that requested a re-init */ 4629 /* Find the VSI(s) that requested a re-init */
4476 dev_info(&pf->pdev->dev, 4630 dev_info(&pf->pdev->dev,
4477 "VSI reinit requested\n"); 4631 "VSI reinit requested\n");
4478 for (v = 0; v < pf->hw.func_caps.num_vsis; v++) { 4632 for (v = 0; v < pf->num_alloc_vsi; v++) {
4479 struct i40e_vsi *vsi = pf->vsi[v]; 4633 struct i40e_vsi *vsi = pf->vsi[v];
4480 if (vsi != NULL && 4634 if (vsi != NULL &&
4481 test_bit(__I40E_REINIT_REQUESTED, &vsi->state)) { 4635 test_bit(__I40E_REINIT_REQUESTED, &vsi->state)) {
@@ -4565,6 +4719,10 @@ static int i40e_handle_lldp_event(struct i40e_pf *pf,
4565 int ret = 0; 4719 int ret = 0;
4566 u8 type; 4720 u8 type;
4567 4721
4722 /* Not DCB capable or capability disabled */
4723 if (!(pf->flags & I40E_FLAG_DCB_CAPABLE))
4724 return ret;
4725
4568 /* Ignore if event is not for Nearest Bridge */ 4726 /* Ignore if event is not for Nearest Bridge */
4569 type = ((mib->type >> I40E_AQ_LLDP_BRIDGE_TYPE_SHIFT) 4727 type = ((mib->type >> I40E_AQ_LLDP_BRIDGE_TYPE_SHIFT)
4570 & I40E_AQ_LLDP_BRIDGE_TYPE_MASK); 4728 & I40E_AQ_LLDP_BRIDGE_TYPE_MASK);
@@ -4606,6 +4764,12 @@ static int i40e_handle_lldp_event(struct i40e_pf *pf,
4606 if (!need_reconfig) 4764 if (!need_reconfig)
4607 goto exit; 4765 goto exit;
4608 4766
4767 /* Enable DCB tagging only when more than one TC */
4768 if (i40e_dcb_get_num_tc(dcbx_cfg) > 1)
4769 pf->flags |= I40E_FLAG_DCB_ENABLED;
4770 else
4771 pf->flags &= ~I40E_FLAG_DCB_ENABLED;
4772
4609 /* Reconfiguration needed quiesce all VSIs */ 4773 /* Reconfiguration needed quiesce all VSIs */
4610 i40e_pf_quiesce_all_vsi(pf); 4774 i40e_pf_quiesce_all_vsi(pf);
4611 4775
@@ -4709,8 +4873,7 @@ void i40e_fdir_check_and_reenable(struct i40e_pf *pf)
4709 (pf->flags & I40E_FLAG_FD_SB_ENABLED)) 4873 (pf->flags & I40E_FLAG_FD_SB_ENABLED))
4710 return; 4874 return;
4711 fcnt_prog = i40e_get_current_fd_count(pf); 4875 fcnt_prog = i40e_get_current_fd_count(pf);
4712 fcnt_avail = pf->hw.fdir_shared_filter_count + 4876 fcnt_avail = i40e_get_fd_cnt_all(pf);
4713 pf->fdir_pf_filter_count;
4714 if (fcnt_prog < (fcnt_avail - I40E_FDIR_BUFFER_HEAD_ROOM)) { 4877 if (fcnt_prog < (fcnt_avail - I40E_FDIR_BUFFER_HEAD_ROOM)) {
4715 if ((pf->flags & I40E_FLAG_FD_SB_ENABLED) && 4878 if ((pf->flags & I40E_FLAG_FD_SB_ENABLED) &&
4716 (pf->auto_disable_flags & I40E_FLAG_FD_SB_ENABLED)) { 4879 (pf->auto_disable_flags & I40E_FLAG_FD_SB_ENABLED)) {
@@ -4803,7 +4966,7 @@ static void i40e_veb_link_event(struct i40e_veb *veb, bool link_up)
4803 i40e_veb_link_event(pf->veb[i], link_up); 4966 i40e_veb_link_event(pf->veb[i], link_up);
4804 4967
4805 /* ... now the local VSIs */ 4968 /* ... now the local VSIs */
4806 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) 4969 for (i = 0; i < pf->num_alloc_vsi; i++)
4807 if (pf->vsi[i] && (pf->vsi[i]->uplink_seid == veb->seid)) 4970 if (pf->vsi[i] && (pf->vsi[i]->uplink_seid == veb->seid))
4808 i40e_vsi_link_event(pf->vsi[i], link_up); 4971 i40e_vsi_link_event(pf->vsi[i], link_up);
4809} 4972}
@@ -4821,10 +4984,8 @@ static void i40e_link_event(struct i40e_pf *pf)
4821 4984
4822 if (new_link == old_link) 4985 if (new_link == old_link)
4823 return; 4986 return;
4824
4825 if (!test_bit(__I40E_DOWN, &pf->vsi[pf->lan_vsi]->state)) 4987 if (!test_bit(__I40E_DOWN, &pf->vsi[pf->lan_vsi]->state))
4826 netdev_info(pf->vsi[pf->lan_vsi]->netdev, 4988 i40e_print_link_message(pf->vsi[pf->lan_vsi], new_link);
4827 "NIC Link is %s\n", (new_link ? "Up" : "Down"));
4828 4989
4829 /* Notify the base of the switch tree connected to 4990 /* Notify the base of the switch tree connected to
4830 * the link. Floating VEBs are not notified. 4991 * the link. Floating VEBs are not notified.
@@ -4862,7 +5023,7 @@ static void i40e_check_hang_subtask(struct i40e_pf *pf)
4862 * for each q_vector 5023 * for each q_vector
4863 * force an interrupt 5024 * force an interrupt
4864 */ 5025 */
4865 for (v = 0; v < pf->hw.func_caps.num_vsis; v++) { 5026 for (v = 0; v < pf->num_alloc_vsi; v++) {
4866 struct i40e_vsi *vsi = pf->vsi[v]; 5027 struct i40e_vsi *vsi = pf->vsi[v];
4867 int armed = 0; 5028 int armed = 0;
4868 5029
@@ -4912,7 +5073,7 @@ static void i40e_watchdog_subtask(struct i40e_pf *pf)
4912 /* Update the stats for active netdevs so the network stack 5073 /* Update the stats for active netdevs so the network stack
4913 * can look at updated numbers whenever it cares to 5074 * can look at updated numbers whenever it cares to
4914 */ 5075 */
4915 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) 5076 for (i = 0; i < pf->num_alloc_vsi; i++)
4916 if (pf->vsi[i] && pf->vsi[i]->netdev) 5077 if (pf->vsi[i] && pf->vsi[i]->netdev)
4917 i40e_update_stats(pf->vsi[i]); 5078 i40e_update_stats(pf->vsi[i]);
4918 5079
@@ -5018,11 +5179,47 @@ static void i40e_clean_adminq_subtask(struct i40e_pf *pf)
5018 u16 pending, i = 0; 5179 u16 pending, i = 0;
5019 i40e_status ret; 5180 i40e_status ret;
5020 u16 opcode; 5181 u16 opcode;
5182 u32 oldval;
5021 u32 val; 5183 u32 val;
5022 5184
5023 if (!test_bit(__I40E_ADMINQ_EVENT_PENDING, &pf->state)) 5185 if (!test_bit(__I40E_ADMINQ_EVENT_PENDING, &pf->state))
5024 return; 5186 return;
5025 5187
5188 /* check for error indications */
5189 val = rd32(&pf->hw, pf->hw.aq.arq.len);
5190 oldval = val;
5191 if (val & I40E_PF_ARQLEN_ARQVFE_MASK) {
5192 dev_info(&pf->pdev->dev, "ARQ VF Error detected\n");
5193 val &= ~I40E_PF_ARQLEN_ARQVFE_MASK;
5194 }
5195 if (val & I40E_PF_ARQLEN_ARQOVFL_MASK) {
5196 dev_info(&pf->pdev->dev, "ARQ Overflow Error detected\n");
5197 val &= ~I40E_PF_ARQLEN_ARQOVFL_MASK;
5198 }
5199 if (val & I40E_PF_ARQLEN_ARQCRIT_MASK) {
5200 dev_info(&pf->pdev->dev, "ARQ Critical Error detected\n");
5201 val &= ~I40E_PF_ARQLEN_ARQCRIT_MASK;
5202 }
5203 if (oldval != val)
5204 wr32(&pf->hw, pf->hw.aq.arq.len, val);
5205
5206 val = rd32(&pf->hw, pf->hw.aq.asq.len);
5207 oldval = val;
5208 if (val & I40E_PF_ATQLEN_ATQVFE_MASK) {
5209 dev_info(&pf->pdev->dev, "ASQ VF Error detected\n");
5210 val &= ~I40E_PF_ATQLEN_ATQVFE_MASK;
5211 }
5212 if (val & I40E_PF_ATQLEN_ATQOVFL_MASK) {
5213 dev_info(&pf->pdev->dev, "ASQ Overflow Error detected\n");
5214 val &= ~I40E_PF_ATQLEN_ATQOVFL_MASK;
5215 }
5216 if (val & I40E_PF_ATQLEN_ATQCRIT_MASK) {
5217 dev_info(&pf->pdev->dev, "ASQ Critical Error detected\n");
5218 val &= ~I40E_PF_ATQLEN_ATQCRIT_MASK;
5219 }
5220 if (oldval != val)
5221 wr32(&pf->hw, pf->hw.aq.asq.len, val);
5222
5026 event.msg_size = I40E_MAX_AQ_BUF_SIZE; 5223 event.msg_size = I40E_MAX_AQ_BUF_SIZE;
5027 event.msg_buf = kzalloc(event.msg_size, GFP_KERNEL); 5224 event.msg_buf = kzalloc(event.msg_size, GFP_KERNEL);
5028 if (!event.msg_buf) 5225 if (!event.msg_buf)
@@ -5128,7 +5325,7 @@ static int i40e_reconstitute_veb(struct i40e_veb *veb)
5128 int ret; 5325 int ret;
5129 5326
5130 /* build VSI that owns this VEB, temporarily attached to base VEB */ 5327 /* build VSI that owns this VEB, temporarily attached to base VEB */
5131 for (v = 0; v < pf->hw.func_caps.num_vsis && !ctl_vsi; v++) { 5328 for (v = 0; v < pf->num_alloc_vsi && !ctl_vsi; v++) {
5132 if (pf->vsi[v] && 5329 if (pf->vsi[v] &&
5133 pf->vsi[v]->veb_idx == veb->idx && 5330 pf->vsi[v]->veb_idx == veb->idx &&
5134 pf->vsi[v]->flags & I40E_VSI_FLAG_VEB_OWNER) { 5331 pf->vsi[v]->flags & I40E_VSI_FLAG_VEB_OWNER) {
@@ -5158,7 +5355,7 @@ static int i40e_reconstitute_veb(struct i40e_veb *veb)
5158 goto end_reconstitute; 5355 goto end_reconstitute;
5159 5356
5160 /* create the remaining VSIs attached to this VEB */ 5357 /* create the remaining VSIs attached to this VEB */
5161 for (v = 0; v < pf->hw.func_caps.num_vsis; v++) { 5358 for (v = 0; v < pf->num_alloc_vsi; v++) {
5162 if (!pf->vsi[v] || pf->vsi[v] == ctl_vsi) 5359 if (!pf->vsi[v] || pf->vsi[v] == ctl_vsi)
5163 continue; 5360 continue;
5164 5361
@@ -5226,9 +5423,6 @@ static int i40e_get_capabilities(struct i40e_pf *pf)
5226 } 5423 }
5227 } while (err); 5424 } while (err);
5228 5425
5229 /* increment MSI-X count because current FW skips one */
5230 pf->hw.func_caps.num_msix_vectors++;
5231
5232 if (((pf->hw.aq.fw_maj_ver == 2) && (pf->hw.aq.fw_min_ver < 22)) || 5426 if (((pf->hw.aq.fw_maj_ver == 2) && (pf->hw.aq.fw_min_ver < 22)) ||
5233 (pf->hw.aq.fw_maj_ver < 2)) { 5427 (pf->hw.aq.fw_maj_ver < 2)) {
5234 pf->hw.func_caps.num_msix_vectors++; 5428 pf->hw.func_caps.num_msix_vectors++;
@@ -5267,15 +5461,14 @@ static int i40e_vsi_clear(struct i40e_vsi *vsi);
5267static void i40e_fdir_sb_setup(struct i40e_pf *pf) 5461static void i40e_fdir_sb_setup(struct i40e_pf *pf)
5268{ 5462{
5269 struct i40e_vsi *vsi; 5463 struct i40e_vsi *vsi;
5270 bool new_vsi = false; 5464 int i;
5271 int err, i;
5272 5465
5273 if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED)) 5466 if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED))
5274 return; 5467 return;
5275 5468
5276 /* find existing VSI and see if it needs configuring */ 5469 /* find existing VSI and see if it needs configuring */
5277 vsi = NULL; 5470 vsi = NULL;
5278 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) { 5471 for (i = 0; i < pf->num_alloc_vsi; i++) {
5279 if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) { 5472 if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) {
5280 vsi = pf->vsi[i]; 5473 vsi = pf->vsi[i];
5281 break; 5474 break;
@@ -5288,47 +5481,12 @@ static void i40e_fdir_sb_setup(struct i40e_pf *pf)
5288 pf->vsi[pf->lan_vsi]->seid, 0); 5481 pf->vsi[pf->lan_vsi]->seid, 0);
5289 if (!vsi) { 5482 if (!vsi) {
5290 dev_info(&pf->pdev->dev, "Couldn't create FDir VSI\n"); 5483 dev_info(&pf->pdev->dev, "Couldn't create FDir VSI\n");
5291 goto err_vsi; 5484 pf->flags &= ~I40E_FLAG_FD_SB_ENABLED;
5485 return;
5292 } 5486 }
5293 new_vsi = true;
5294 }
5295 i40e_vsi_setup_irqhandler(vsi, i40e_fdir_clean_ring);
5296
5297 err = i40e_vsi_setup_tx_resources(vsi);
5298 if (err)
5299 goto err_setup_tx;
5300 err = i40e_vsi_setup_rx_resources(vsi);
5301 if (err)
5302 goto err_setup_rx;
5303
5304 if (new_vsi) {
5305 char int_name[IFNAMSIZ + 9];
5306 err = i40e_vsi_configure(vsi);
5307 if (err)
5308 goto err_setup_rx;
5309 snprintf(int_name, sizeof(int_name) - 1, "%s-fdir",
5310 dev_driver_string(&pf->pdev->dev));
5311 err = i40e_vsi_request_irq(vsi, int_name);
5312 if (err)
5313 goto err_setup_rx;
5314 err = i40e_up_complete(vsi);
5315 if (err)
5316 goto err_up_complete;
5317 clear_bit(__I40E_NEEDS_RESTART, &vsi->state);
5318 } 5487 }
5319 5488
5320 return; 5489 i40e_vsi_setup_irqhandler(vsi, i40e_fdir_clean_ring);
5321
5322err_up_complete:
5323 i40e_down(vsi);
5324 i40e_vsi_free_irq(vsi);
5325err_setup_rx:
5326 i40e_vsi_free_rx_resources(vsi);
5327err_setup_tx:
5328 i40e_vsi_free_tx_resources(vsi);
5329err_vsi:
5330 pf->flags &= ~I40E_FLAG_FD_SB_ENABLED;
5331 i40e_vsi_clear(vsi);
5332} 5490}
5333 5491
5334/** 5492/**
@@ -5340,7 +5498,7 @@ static void i40e_fdir_teardown(struct i40e_pf *pf)
5340 int i; 5498 int i;
5341 5499
5342 i40e_fdir_filter_exit(pf); 5500 i40e_fdir_filter_exit(pf);
5343 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) { 5501 for (i = 0; i < pf->num_alloc_vsi; i++) {
5344 if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) { 5502 if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) {
5345 i40e_vsi_release(pf->vsi[i]); 5503 i40e_vsi_release(pf->vsi[i]);
5346 break; 5504 break;
@@ -5357,7 +5515,7 @@ static void i40e_fdir_teardown(struct i40e_pf *pf)
5357static int i40e_prep_for_reset(struct i40e_pf *pf) 5515static int i40e_prep_for_reset(struct i40e_pf *pf)
5358{ 5516{
5359 struct i40e_hw *hw = &pf->hw; 5517 struct i40e_hw *hw = &pf->hw;
5360 i40e_status ret; 5518 i40e_status ret = 0;
5361 u32 v; 5519 u32 v;
5362 5520
5363 clear_bit(__I40E_RESET_INTR_RECEIVED, &pf->state); 5521 clear_bit(__I40E_RESET_INTR_RECEIVED, &pf->state);
@@ -5366,13 +5524,10 @@ static int i40e_prep_for_reset(struct i40e_pf *pf)
5366 5524
5367 dev_dbg(&pf->pdev->dev, "Tearing down internal switch for reset\n"); 5525 dev_dbg(&pf->pdev->dev, "Tearing down internal switch for reset\n");
5368 5526
5369 if (i40e_check_asq_alive(hw))
5370 i40e_vc_notify_reset(pf);
5371
5372 /* quiesce the VSIs and their queues that are not already DOWN */ 5527 /* quiesce the VSIs and their queues that are not already DOWN */
5373 i40e_pf_quiesce_all_vsi(pf); 5528 i40e_pf_quiesce_all_vsi(pf);
5374 5529
5375 for (v = 0; v < pf->hw.func_caps.num_vsis; v++) { 5530 for (v = 0; v < pf->num_alloc_vsi; v++) {
5376 if (pf->vsi[v]) 5531 if (pf->vsi[v])
5377 pf->vsi[v]->seid = 0; 5532 pf->vsi[v]->seid = 0;
5378 } 5533 }
@@ -5380,22 +5535,40 @@ static int i40e_prep_for_reset(struct i40e_pf *pf)
5380 i40e_shutdown_adminq(&pf->hw); 5535 i40e_shutdown_adminq(&pf->hw);
5381 5536
5382 /* call shutdown HMC */ 5537 /* call shutdown HMC */
5383 ret = i40e_shutdown_lan_hmc(hw); 5538 if (hw->hmc.hmc_obj) {
5384 if (ret) { 5539 ret = i40e_shutdown_lan_hmc(hw);
5385 dev_info(&pf->pdev->dev, "shutdown_lan_hmc failed: %d\n", ret); 5540 if (ret) {
5386 clear_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state); 5541 dev_warn(&pf->pdev->dev,
5542 "shutdown_lan_hmc failed: %d\n", ret);
5543 clear_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state);
5544 }
5387 } 5545 }
5388 return ret; 5546 return ret;
5389} 5547}
5390 5548
5391/** 5549/**
5550 * i40e_send_version - update firmware with driver version
5551 * @pf: PF struct
5552 */
5553static void i40e_send_version(struct i40e_pf *pf)
5554{
5555 struct i40e_driver_version dv;
5556
5557 dv.major_version = DRV_VERSION_MAJOR;
5558 dv.minor_version = DRV_VERSION_MINOR;
5559 dv.build_version = DRV_VERSION_BUILD;
5560 dv.subbuild_version = 0;
5561 strncpy(dv.driver_string, DRV_VERSION, sizeof(dv.driver_string));
5562 i40e_aq_send_driver_version(&pf->hw, &dv, NULL);
5563}
5564
5565/**
5392 * i40e_reset_and_rebuild - reset and rebuild using a saved config 5566 * i40e_reset_and_rebuild - reset and rebuild using a saved config
5393 * @pf: board private structure 5567 * @pf: board private structure
5394 * @reinit: if the Main VSI needs to re-initialized. 5568 * @reinit: if the Main VSI needs to re-initialized.
5395 **/ 5569 **/
5396static void i40e_reset_and_rebuild(struct i40e_pf *pf, bool reinit) 5570static void i40e_reset_and_rebuild(struct i40e_pf *pf, bool reinit)
5397{ 5571{
5398 struct i40e_driver_version dv;
5399 struct i40e_hw *hw = &pf->hw; 5572 struct i40e_hw *hw = &pf->hw;
5400 i40e_status ret; 5573 i40e_status ret;
5401 u32 v; 5574 u32 v;
@@ -5405,8 +5578,10 @@ static void i40e_reset_and_rebuild(struct i40e_pf *pf, bool reinit)
5405 * because the reset will make them disappear. 5578 * because the reset will make them disappear.
5406 */ 5579 */
5407 ret = i40e_pf_reset(hw); 5580 ret = i40e_pf_reset(hw);
5408 if (ret) 5581 if (ret) {
5409 dev_info(&pf->pdev->dev, "PF reset failed, %d\n", ret); 5582 dev_info(&pf->pdev->dev, "PF reset failed, %d\n", ret);
5583 goto end_core_reset;
5584 }
5410 pf->pfr_count++; 5585 pf->pfr_count++;
5411 5586
5412 if (test_bit(__I40E_DOWN, &pf->state)) 5587 if (test_bit(__I40E_DOWN, &pf->state))
@@ -5426,6 +5601,7 @@ static void i40e_reset_and_rebuild(struct i40e_pf *pf, bool reinit)
5426 i40e_verify_eeprom(pf); 5601 i40e_verify_eeprom(pf);
5427 } 5602 }
5428 5603
5604 i40e_clear_pxe_mode(hw);
5429 ret = i40e_get_capabilities(pf); 5605 ret = i40e_get_capabilities(pf);
5430 if (ret) { 5606 if (ret) {
5431 dev_info(&pf->pdev->dev, "i40e_get_capabilities failed, %d\n", 5607 dev_info(&pf->pdev->dev, "i40e_get_capabilities failed, %d\n",
@@ -5526,13 +5702,7 @@ static void i40e_reset_and_rebuild(struct i40e_pf *pf, bool reinit)
5526 } 5702 }
5527 5703
5528 /* tell the firmware that we're starting */ 5704 /* tell the firmware that we're starting */
5529 dv.major_version = DRV_VERSION_MAJOR; 5705 i40e_send_version(pf);
5530 dv.minor_version = DRV_VERSION_MINOR;
5531 dv.build_version = DRV_VERSION_BUILD;
5532 dv.subbuild_version = 0;
5533 i40e_aq_send_driver_version(&pf->hw, &dv, NULL);
5534
5535 dev_info(&pf->pdev->dev, "reset complete\n");
5536 5706
5537end_core_reset: 5707end_core_reset:
5538 clear_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state); 5708 clear_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state);
@@ -5642,7 +5812,6 @@ static void i40e_handle_mdd_event(struct i40e_pf *pf)
5642 **/ 5812 **/
5643static void i40e_sync_vxlan_filters_subtask(struct i40e_pf *pf) 5813static void i40e_sync_vxlan_filters_subtask(struct i40e_pf *pf)
5644{ 5814{
5645 const int vxlan_hdr_qwords = 4;
5646 struct i40e_hw *hw = &pf->hw; 5815 struct i40e_hw *hw = &pf->hw;
5647 i40e_status ret; 5816 i40e_status ret;
5648 u8 filter_index; 5817 u8 filter_index;
@@ -5660,7 +5829,6 @@ static void i40e_sync_vxlan_filters_subtask(struct i40e_pf *pf)
5660 port = pf->vxlan_ports[i]; 5829 port = pf->vxlan_ports[i];
5661 ret = port ? 5830 ret = port ?
5662 i40e_aq_add_udp_tunnel(hw, ntohs(port), 5831 i40e_aq_add_udp_tunnel(hw, ntohs(port),
5663 vxlan_hdr_qwords,
5664 I40E_AQC_TUNNEL_TYPE_VXLAN, 5832 I40E_AQC_TUNNEL_TYPE_VXLAN,
5665 &filter_index, NULL) 5833 &filter_index, NULL)
5666 : i40e_aq_del_udp_tunnel(hw, i, NULL); 5834 : i40e_aq_del_udp_tunnel(hw, i, NULL);
@@ -5839,15 +6007,15 @@ static int i40e_vsi_mem_alloc(struct i40e_pf *pf, enum i40e_vsi_type type)
5839 * find next empty vsi slot, looping back around if necessary 6007 * find next empty vsi slot, looping back around if necessary
5840 */ 6008 */
5841 i = pf->next_vsi; 6009 i = pf->next_vsi;
5842 while (i < pf->hw.func_caps.num_vsis && pf->vsi[i]) 6010 while (i < pf->num_alloc_vsi && pf->vsi[i])
5843 i++; 6011 i++;
5844 if (i >= pf->hw.func_caps.num_vsis) { 6012 if (i >= pf->num_alloc_vsi) {
5845 i = 0; 6013 i = 0;
5846 while (i < pf->next_vsi && pf->vsi[i]) 6014 while (i < pf->next_vsi && pf->vsi[i])
5847 i++; 6015 i++;
5848 } 6016 }
5849 6017
5850 if (i < pf->hw.func_caps.num_vsis && !pf->vsi[i]) { 6018 if (i < pf->num_alloc_vsi && !pf->vsi[i]) {
5851 vsi_idx = i; /* Found one! */ 6019 vsi_idx = i; /* Found one! */
5852 } else { 6020 } else {
5853 ret = -ENODEV; 6021 ret = -ENODEV;
@@ -5870,6 +6038,7 @@ static int i40e_vsi_mem_alloc(struct i40e_pf *pf, enum i40e_vsi_type type)
5870 vsi->netdev_registered = false; 6038 vsi->netdev_registered = false;
5871 vsi->work_limit = I40E_DEFAULT_IRQ_WORK; 6039 vsi->work_limit = I40E_DEFAULT_IRQ_WORK;
5872 INIT_LIST_HEAD(&vsi->mac_filter_list); 6040 INIT_LIST_HEAD(&vsi->mac_filter_list);
6041 vsi->irqs_ready = false;
5873 6042
5874 ret = i40e_set_num_rings_in_vsi(vsi); 6043 ret = i40e_set_num_rings_in_vsi(vsi);
5875 if (ret) 6044 if (ret)
@@ -5987,14 +6156,12 @@ static void i40e_vsi_clear_rings(struct i40e_vsi *vsi)
5987 **/ 6156 **/
5988static int i40e_alloc_rings(struct i40e_vsi *vsi) 6157static int i40e_alloc_rings(struct i40e_vsi *vsi)
5989{ 6158{
6159 struct i40e_ring *tx_ring, *rx_ring;
5990 struct i40e_pf *pf = vsi->back; 6160 struct i40e_pf *pf = vsi->back;
5991 int i; 6161 int i;
5992 6162
5993 /* Set basic values in the rings to be used later during open() */ 6163 /* Set basic values in the rings to be used later during open() */
5994 for (i = 0; i < vsi->alloc_queue_pairs; i++) { 6164 for (i = 0; i < vsi->alloc_queue_pairs; i++) {
5995 struct i40e_ring *tx_ring;
5996 struct i40e_ring *rx_ring;
5997
5998 /* allocate space for both Tx and Rx in one shot */ 6165 /* allocate space for both Tx and Rx in one shot */
5999 tx_ring = kzalloc(sizeof(struct i40e_ring) * 2, GFP_KERNEL); 6166 tx_ring = kzalloc(sizeof(struct i40e_ring) * 2, GFP_KERNEL);
6000 if (!tx_ring) 6167 if (!tx_ring)
@@ -6052,8 +6219,6 @@ static int i40e_reserve_msix_vectors(struct i40e_pf *pf, int vectors)
6052 vectors = 0; 6219 vectors = 0;
6053 } 6220 }
6054 6221
6055 pf->num_msix_entries = vectors;
6056
6057 return vectors; 6222 return vectors;
6058} 6223}
6059 6224
@@ -6107,6 +6272,16 @@ static int i40e_init_msix(struct i40e_pf *pf)
6107 for (i = 0; i < v_budget; i++) 6272 for (i = 0; i < v_budget; i++)
6108 pf->msix_entries[i].entry = i; 6273 pf->msix_entries[i].entry = i;
6109 vec = i40e_reserve_msix_vectors(pf, v_budget); 6274 vec = i40e_reserve_msix_vectors(pf, v_budget);
6275
6276 if (vec != v_budget) {
6277 /* If we have limited resources, we will start with no vectors
6278 * for the special features and then allocate vectors to some
6279 * of these features based on the policy and at the end disable
6280 * the features that did not get any vectors.
6281 */
6282 pf->num_vmdq_msix = 0;
6283 }
6284
6110 if (vec < I40E_MIN_MSIX) { 6285 if (vec < I40E_MIN_MSIX) {
6111 pf->flags &= ~I40E_FLAG_MSIX_ENABLED; 6286 pf->flags &= ~I40E_FLAG_MSIX_ENABLED;
6112 kfree(pf->msix_entries); 6287 kfree(pf->msix_entries);
@@ -6115,27 +6290,25 @@ static int i40e_init_msix(struct i40e_pf *pf)
6115 6290
6116 } else if (vec == I40E_MIN_MSIX) { 6291 } else if (vec == I40E_MIN_MSIX) {
6117 /* Adjust for minimal MSIX use */ 6292 /* Adjust for minimal MSIX use */
6118 dev_info(&pf->pdev->dev, "Features disabled, not enough MSI-X vectors\n");
6119 pf->flags &= ~I40E_FLAG_VMDQ_ENABLED;
6120 pf->num_vmdq_vsis = 0; 6293 pf->num_vmdq_vsis = 0;
6121 pf->num_vmdq_qps = 0; 6294 pf->num_vmdq_qps = 0;
6122 pf->num_vmdq_msix = 0;
6123 pf->num_lan_qps = 1; 6295 pf->num_lan_qps = 1;
6124 pf->num_lan_msix = 1; 6296 pf->num_lan_msix = 1;
6125 6297
6126 } else if (vec != v_budget) { 6298 } else if (vec != v_budget) {
6299 /* reserve the misc vector */
6300 vec--;
6301
6127 /* Scale vector usage down */ 6302 /* Scale vector usage down */
6128 pf->num_vmdq_msix = 1; /* force VMDqs to only one vector */ 6303 pf->num_vmdq_msix = 1; /* force VMDqs to only one vector */
6129 vec--; /* reserve the misc vector */ 6304 pf->num_vmdq_vsis = 1;
6130 6305
6131 /* partition out the remaining vectors */ 6306 /* partition out the remaining vectors */
6132 switch (vec) { 6307 switch (vec) {
6133 case 2: 6308 case 2:
6134 pf->num_vmdq_vsis = 1;
6135 pf->num_lan_msix = 1; 6309 pf->num_lan_msix = 1;
6136 break; 6310 break;
6137 case 3: 6311 case 3:
6138 pf->num_vmdq_vsis = 1;
6139 pf->num_lan_msix = 2; 6312 pf->num_lan_msix = 2;
6140 break; 6313 break;
6141 default: 6314 default:
@@ -6147,6 +6320,11 @@ static int i40e_init_msix(struct i40e_pf *pf)
6147 } 6320 }
6148 } 6321 }
6149 6322
6323 if ((pf->flags & I40E_FLAG_VMDQ_ENABLED) &&
6324 (pf->num_vmdq_msix == 0)) {
6325 dev_info(&pf->pdev->dev, "VMDq disabled, not enough MSI-X vectors\n");
6326 pf->flags &= ~I40E_FLAG_VMDQ_ENABLED;
6327 }
6150 return err; 6328 return err;
6151} 6329}
6152 6330
@@ -6171,7 +6349,7 @@ static int i40e_vsi_alloc_q_vector(struct i40e_vsi *vsi, int v_idx)
6171 cpumask_set_cpu(v_idx, &q_vector->affinity_mask); 6349 cpumask_set_cpu(v_idx, &q_vector->affinity_mask);
6172 if (vsi->netdev) 6350 if (vsi->netdev)
6173 netif_napi_add(vsi->netdev, &q_vector->napi, 6351 netif_napi_add(vsi->netdev, &q_vector->napi,
6174 i40e_napi_poll, vsi->work_limit); 6352 i40e_napi_poll, NAPI_POLL_WEIGHT);
6175 6353
6176 q_vector->rx.latency_range = I40E_LOW_LATENCY; 6354 q_vector->rx.latency_range = I40E_LOW_LATENCY;
6177 q_vector->tx.latency_range = I40E_LOW_LATENCY; 6355 q_vector->tx.latency_range = I40E_LOW_LATENCY;
@@ -6231,7 +6409,7 @@ static void i40e_init_interrupt_scheme(struct i40e_pf *pf)
6231 if (err) { 6409 if (err) {
6232 pf->flags &= ~(I40E_FLAG_MSIX_ENABLED | 6410 pf->flags &= ~(I40E_FLAG_MSIX_ENABLED |
6233 I40E_FLAG_RSS_ENABLED | 6411 I40E_FLAG_RSS_ENABLED |
6234 I40E_FLAG_DCB_ENABLED | 6412 I40E_FLAG_DCB_CAPABLE |
6235 I40E_FLAG_SRIOV_ENABLED | 6413 I40E_FLAG_SRIOV_ENABLED |
6236 I40E_FLAG_FD_SB_ENABLED | 6414 I40E_FLAG_FD_SB_ENABLED |
6237 I40E_FLAG_FD_ATR_ENABLED | 6415 I40E_FLAG_FD_ATR_ENABLED |
@@ -6364,7 +6542,6 @@ int i40e_reconfig_rss_queues(struct i40e_pf *pf, int queue_count)
6364 return 0; 6542 return 0;
6365 6543
6366 queue_count = min_t(int, queue_count, pf->rss_size_max); 6544 queue_count = min_t(int, queue_count, pf->rss_size_max);
6367 queue_count = rounddown_pow_of_two(queue_count);
6368 6545
6369 if (queue_count != pf->rss_size) { 6546 if (queue_count != pf->rss_size) {
6370 i40e_prep_for_reset(pf); 6547 i40e_prep_for_reset(pf);
@@ -6407,6 +6584,10 @@ static int i40e_sw_init(struct i40e_pf *pf)
6407 I40E_FLAG_MSIX_ENABLED | 6584 I40E_FLAG_MSIX_ENABLED |
6408 I40E_FLAG_RX_1BUF_ENABLED; 6585 I40E_FLAG_RX_1BUF_ENABLED;
6409 6586
6587 /* Set default ITR */
6588 pf->rx_itr_default = I40E_ITR_DYNAMIC | I40E_ITR_RX_DEF;
6589 pf->tx_itr_default = I40E_ITR_DYNAMIC | I40E_ITR_TX_DEF;
6590
6410 /* Depending on PF configurations, it is possible that the RSS 6591 /* Depending on PF configurations, it is possible that the RSS
6411 * maximum might end up larger than the available queues 6592 * maximum might end up larger than the available queues
6412 */ 6593 */
@@ -6416,7 +6597,6 @@ static int i40e_sw_init(struct i40e_pf *pf)
6416 if (pf->hw.func_caps.rss) { 6597 if (pf->hw.func_caps.rss) {
6417 pf->flags |= I40E_FLAG_RSS_ENABLED; 6598 pf->flags |= I40E_FLAG_RSS_ENABLED;
6418 pf->rss_size = min_t(int, pf->rss_size_max, num_online_cpus()); 6599 pf->rss_size = min_t(int, pf->rss_size_max, num_online_cpus());
6419 pf->rss_size = rounddown_pow_of_two(pf->rss_size);
6420 } else { 6600 } else {
6421 pf->rss_size = 1; 6601 pf->rss_size = 1;
6422 } 6602 }
@@ -6432,8 +6612,12 @@ static int i40e_sw_init(struct i40e_pf *pf)
6432 (pf->hw.func_caps.fd_filters_best_effort > 0)) { 6612 (pf->hw.func_caps.fd_filters_best_effort > 0)) {
6433 pf->flags |= I40E_FLAG_FD_ATR_ENABLED; 6613 pf->flags |= I40E_FLAG_FD_ATR_ENABLED;
6434 pf->atr_sample_rate = I40E_DEFAULT_ATR_SAMPLE_RATE; 6614 pf->atr_sample_rate = I40E_DEFAULT_ATR_SAMPLE_RATE;
6615 /* Setup a counter for fd_atr per pf */
6616 pf->fd_atr_cnt_idx = I40E_FD_ATR_STAT_IDX(pf->hw.pf_id);
6435 if (!(pf->flags & I40E_FLAG_MFP_ENABLED)) { 6617 if (!(pf->flags & I40E_FLAG_MFP_ENABLED)) {
6436 pf->flags |= I40E_FLAG_FD_SB_ENABLED; 6618 pf->flags |= I40E_FLAG_FD_SB_ENABLED;
6619 /* Setup a counter for fd_sb per pf */
6620 pf->fd_sb_cnt_idx = I40E_FD_SB_STAT_IDX(pf->hw.pf_id);
6437 } else { 6621 } else {
6438 dev_info(&pf->pdev->dev, 6622 dev_info(&pf->pdev->dev,
6439 "Flow Director Sideband mode Disabled in MFP mode\n"); 6623 "Flow Director Sideband mode Disabled in MFP mode\n");
@@ -6649,6 +6833,96 @@ static void i40e_del_vxlan_port(struct net_device *netdev,
6649} 6833}
6650 6834
6651#endif 6835#endif
6836#ifdef HAVE_FDB_OPS
6837#ifdef USE_CONST_DEV_UC_CHAR
6838static int i40e_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
6839 struct net_device *dev,
6840 const unsigned char *addr,
6841 u16 flags)
6842#else
6843static int i40e_ndo_fdb_add(struct ndmsg *ndm,
6844 struct net_device *dev,
6845 unsigned char *addr,
6846 u16 flags)
6847#endif
6848{
6849 struct i40e_netdev_priv *np = netdev_priv(dev);
6850 struct i40e_pf *pf = np->vsi->back;
6851 int err = 0;
6852
6853 if (!(pf->flags & I40E_FLAG_SRIOV_ENABLED))
6854 return -EOPNOTSUPP;
6855
6856 /* Hardware does not support aging addresses so if a
6857 * ndm_state is given only allow permanent addresses
6858 */
6859 if (ndm->ndm_state && !(ndm->ndm_state & NUD_PERMANENT)) {
6860 netdev_info(dev, "FDB only supports static addresses\n");
6861 return -EINVAL;
6862 }
6863
6864 if (is_unicast_ether_addr(addr) || is_link_local_ether_addr(addr))
6865 err = dev_uc_add_excl(dev, addr);
6866 else if (is_multicast_ether_addr(addr))
6867 err = dev_mc_add_excl(dev, addr);
6868 else
6869 err = -EINVAL;
6870
6871 /* Only return duplicate errors if NLM_F_EXCL is set */
6872 if (err == -EEXIST && !(flags & NLM_F_EXCL))
6873 err = 0;
6874
6875 return err;
6876}
6877
6878#ifndef USE_DEFAULT_FDB_DEL_DUMP
6879#ifdef USE_CONST_DEV_UC_CHAR
6880static int i40e_ndo_fdb_del(struct ndmsg *ndm,
6881 struct net_device *dev,
6882 const unsigned char *addr)
6883#else
6884static int i40e_ndo_fdb_del(struct ndmsg *ndm,
6885 struct net_device *dev,
6886 unsigned char *addr)
6887#endif
6888{
6889 struct i40e_netdev_priv *np = netdev_priv(dev);
6890 struct i40e_pf *pf = np->vsi->back;
6891 int err = -EOPNOTSUPP;
6892
6893 if (ndm->ndm_state & NUD_PERMANENT) {
6894 netdev_info(dev, "FDB only supports static addresses\n");
6895 return -EINVAL;
6896 }
6897
6898 if (pf->flags & I40E_FLAG_SRIOV_ENABLED) {
6899 if (is_unicast_ether_addr(addr))
6900 err = dev_uc_del(dev, addr);
6901 else if (is_multicast_ether_addr(addr))
6902 err = dev_mc_del(dev, addr);
6903 else
6904 err = -EINVAL;
6905 }
6906
6907 return err;
6908}
6909
6910static int i40e_ndo_fdb_dump(struct sk_buff *skb,
6911 struct netlink_callback *cb,
6912 struct net_device *dev,
6913 int idx)
6914{
6915 struct i40e_netdev_priv *np = netdev_priv(dev);
6916 struct i40e_pf *pf = np->vsi->back;
6917
6918 if (pf->flags & I40E_FLAG_SRIOV_ENABLED)
6919 idx = ndo_dflt_fdb_dump(skb, cb, dev, idx);
6920
6921 return idx;
6922}
6923
6924#endif /* USE_DEFAULT_FDB_DEL_DUMP */
6925#endif /* HAVE_FDB_OPS */
6652static const struct net_device_ops i40e_netdev_ops = { 6926static const struct net_device_ops i40e_netdev_ops = {
6653 .ndo_open = i40e_open, 6927 .ndo_open = i40e_open,
6654 .ndo_stop = i40e_close, 6928 .ndo_stop = i40e_close,
@@ -6669,13 +6943,21 @@ static const struct net_device_ops i40e_netdev_ops = {
6669 .ndo_set_features = i40e_set_features, 6943 .ndo_set_features = i40e_set_features,
6670 .ndo_set_vf_mac = i40e_ndo_set_vf_mac, 6944 .ndo_set_vf_mac = i40e_ndo_set_vf_mac,
6671 .ndo_set_vf_vlan = i40e_ndo_set_vf_port_vlan, 6945 .ndo_set_vf_vlan = i40e_ndo_set_vf_port_vlan,
6672 .ndo_set_vf_tx_rate = i40e_ndo_set_vf_bw, 6946 .ndo_set_vf_rate = i40e_ndo_set_vf_bw,
6673 .ndo_get_vf_config = i40e_ndo_get_vf_config, 6947 .ndo_get_vf_config = i40e_ndo_get_vf_config,
6674 .ndo_set_vf_link_state = i40e_ndo_set_vf_link_state, 6948 .ndo_set_vf_link_state = i40e_ndo_set_vf_link_state,
6949 .ndo_set_vf_spoofchk = i40e_ndo_set_vf_spoofck,
6675#ifdef CONFIG_I40E_VXLAN 6950#ifdef CONFIG_I40E_VXLAN
6676 .ndo_add_vxlan_port = i40e_add_vxlan_port, 6951 .ndo_add_vxlan_port = i40e_add_vxlan_port,
6677 .ndo_del_vxlan_port = i40e_del_vxlan_port, 6952 .ndo_del_vxlan_port = i40e_del_vxlan_port,
6678#endif 6953#endif
6954#ifdef HAVE_FDB_OPS
6955 .ndo_fdb_add = i40e_ndo_fdb_add,
6956#ifndef USE_DEFAULT_FDB_DEL_DUMP
6957 .ndo_fdb_del = i40e_ndo_fdb_del,
6958 .ndo_fdb_dump = i40e_ndo_fdb_dump,
6959#endif
6960#endif
6679}; 6961};
6680 6962
6681/** 6963/**
@@ -6720,16 +7002,26 @@ static int i40e_config_netdev(struct i40e_vsi *vsi)
6720 NETIF_F_TSO_ECN | 7002 NETIF_F_TSO_ECN |
6721 NETIF_F_TSO6 | 7003 NETIF_F_TSO6 |
6722 NETIF_F_RXCSUM | 7004 NETIF_F_RXCSUM |
6723 NETIF_F_NTUPLE |
6724 NETIF_F_RXHASH | 7005 NETIF_F_RXHASH |
6725 0; 7006 0;
6726 7007
7008 if (!(pf->flags & I40E_FLAG_MFP_ENABLED))
7009 netdev->features |= NETIF_F_NTUPLE;
7010
6727 /* copy netdev features into list of user selectable features */ 7011 /* copy netdev features into list of user selectable features */
6728 netdev->hw_features |= netdev->features; 7012 netdev->hw_features |= netdev->features;
6729 7013
6730 if (vsi->type == I40E_VSI_MAIN) { 7014 if (vsi->type == I40E_VSI_MAIN) {
6731 SET_NETDEV_DEV(netdev, &pf->pdev->dev); 7015 SET_NETDEV_DEV(netdev, &pf->pdev->dev);
6732 memcpy(mac_addr, hw->mac.perm_addr, ETH_ALEN); 7016 ether_addr_copy(mac_addr, hw->mac.perm_addr);
7017 /* The following two steps are necessary to prevent reception
7018 * of tagged packets - by default the NVM loads a MAC-VLAN
7019 * filter that will accept any tagged packet. This is to
7020 * prevent that during normal operations until a specific
7021 * VLAN tag filter has been set.
7022 */
7023 i40e_rm_default_mac_filter(vsi, mac_addr);
7024 i40e_add_filter(vsi, mac_addr, I40E_VLAN_ANY, false, true);
6733 } else { 7025 } else {
6734 /* relate the VSI_VMDQ name to the VSI_MAIN name */ 7026 /* relate the VSI_VMDQ name to the VSI_MAIN name */
6735 snprintf(netdev->name, IFNAMSIZ, "%sv%%d", 7027 snprintf(netdev->name, IFNAMSIZ, "%sv%%d",
@@ -6739,8 +7031,8 @@ static int i40e_config_netdev(struct i40e_vsi *vsi)
6739 } 7031 }
6740 i40e_add_filter(vsi, brdcast, I40E_VLAN_ANY, false, false); 7032 i40e_add_filter(vsi, brdcast, I40E_VLAN_ANY, false, false);
6741 7033
6742 memcpy(netdev->dev_addr, mac_addr, ETH_ALEN); 7034 ether_addr_copy(netdev->dev_addr, mac_addr);
6743 memcpy(netdev->perm_addr, mac_addr, ETH_ALEN); 7035 ether_addr_copy(netdev->perm_addr, mac_addr);
6744 /* vlan gets same features (except vlan offload) 7036 /* vlan gets same features (except vlan offload)
6745 * after any tweaks for specific VSI types 7037 * after any tweaks for specific VSI types
6746 */ 7038 */
@@ -6772,7 +7064,6 @@ static void i40e_vsi_delete(struct i40e_vsi *vsi)
6772 return; 7064 return;
6773 7065
6774 i40e_aq_delete_element(&vsi->back->hw, vsi->seid, NULL); 7066 i40e_aq_delete_element(&vsi->back->hw, vsi->seid, NULL);
6775 return;
6776} 7067}
6777 7068
6778/** 7069/**
@@ -6898,6 +7189,13 @@ static int i40e_add_vsi(struct i40e_vsi *vsi)
6898 7189
6899 ctxt.info.valid_sections |= cpu_to_le16(I40E_AQ_VSI_PROP_VLAN_VALID); 7190 ctxt.info.valid_sections |= cpu_to_le16(I40E_AQ_VSI_PROP_VLAN_VALID);
6900 ctxt.info.port_vlan_flags |= I40E_AQ_VSI_PVLAN_MODE_ALL; 7191 ctxt.info.port_vlan_flags |= I40E_AQ_VSI_PVLAN_MODE_ALL;
7192 if (pf->vf[vsi->vf_id].spoofchk) {
7193 ctxt.info.valid_sections |=
7194 cpu_to_le16(I40E_AQ_VSI_PROP_SECURITY_VALID);
7195 ctxt.info.sec_flags |=
7196 (I40E_AQ_VSI_SEC_FLAG_ENABLE_VLAN_CHK |
7197 I40E_AQ_VSI_SEC_FLAG_ENABLE_MAC_CHK);
7198 }
6901 /* Setup the VSI tx/rx queue map for TC0 only for now */ 7199 /* Setup the VSI tx/rx queue map for TC0 only for now */
6902 i40e_vsi_setup_queue_map(vsi, &ctxt, enabled_tc, true); 7200 i40e_vsi_setup_queue_map(vsi, &ctxt, enabled_tc, true);
6903 break; 7201 break;
@@ -6982,11 +7280,7 @@ int i40e_vsi_release(struct i40e_vsi *vsi)
6982 unregister_netdev(vsi->netdev); 7280 unregister_netdev(vsi->netdev);
6983 } 7281 }
6984 } else { 7282 } else {
6985 if (!test_and_set_bit(__I40E_DOWN, &vsi->state)) 7283 i40e_vsi_close(vsi);
6986 i40e_down(vsi);
6987 i40e_vsi_free_irq(vsi);
6988 i40e_vsi_free_tx_resources(vsi);
6989 i40e_vsi_free_rx_resources(vsi);
6990 } 7284 }
6991 i40e_vsi_disable_irq(vsi); 7285 i40e_vsi_disable_irq(vsi);
6992 } 7286 }
@@ -7013,7 +7307,7 @@ int i40e_vsi_release(struct i40e_vsi *vsi)
7013 * the orphan VEBs yet. We'll wait for an explicit remove request 7307 * the orphan VEBs yet. We'll wait for an explicit remove request
7014 * from up the network stack. 7308 * from up the network stack.
7015 */ 7309 */
7016 for (n = 0, i = 0; i < pf->hw.func_caps.num_vsis; i++) { 7310 for (n = 0, i = 0; i < pf->num_alloc_vsi; i++) {
7017 if (pf->vsi[i] && 7311 if (pf->vsi[i] &&
7018 pf->vsi[i]->uplink_seid == uplink_seid && 7312 pf->vsi[i]->uplink_seid == uplink_seid &&
7019 (pf->vsi[i]->flags & I40E_VSI_FLAG_VEB_OWNER) == 0) { 7313 (pf->vsi[i]->flags & I40E_VSI_FLAG_VEB_OWNER) == 0) {
@@ -7192,7 +7486,7 @@ struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type,
7192 7486
7193 if (!veb && uplink_seid != pf->mac_seid) { 7487 if (!veb && uplink_seid != pf->mac_seid) {
7194 7488
7195 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) { 7489 for (i = 0; i < pf->num_alloc_vsi; i++) {
7196 if (pf->vsi[i] && pf->vsi[i]->seid == uplink_seid) { 7490 if (pf->vsi[i] && pf->vsi[i]->seid == uplink_seid) {
7197 vsi = pf->vsi[i]; 7491 vsi = pf->vsi[i];
7198 break; 7492 break;
@@ -7435,7 +7729,7 @@ static void i40e_switch_branch_release(struct i40e_veb *branch)
7435 * NOTE: Removing the last VSI on a VEB has the SIDE EFFECT of removing 7729 * NOTE: Removing the last VSI on a VEB has the SIDE EFFECT of removing
7436 * the VEB itself, so don't use (*branch) after this loop. 7730 * the VEB itself, so don't use (*branch) after this loop.
7437 */ 7731 */
7438 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) { 7732 for (i = 0; i < pf->num_alloc_vsi; i++) {
7439 if (!pf->vsi[i]) 7733 if (!pf->vsi[i])
7440 continue; 7734 continue;
7441 if (pf->vsi[i]->uplink_seid == branch_seid && 7735 if (pf->vsi[i]->uplink_seid == branch_seid &&
@@ -7487,7 +7781,7 @@ void i40e_veb_release(struct i40e_veb *veb)
7487 pf = veb->pf; 7781 pf = veb->pf;
7488 7782
7489 /* find the remaining VSI and check for extras */ 7783 /* find the remaining VSI and check for extras */
7490 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) { 7784 for (i = 0; i < pf->num_alloc_vsi; i++) {
7491 if (pf->vsi[i] && pf->vsi[i]->uplink_seid == veb->seid) { 7785 if (pf->vsi[i] && pf->vsi[i]->uplink_seid == veb->seid) {
7492 n++; 7786 n++;
7493 vsi = pf->vsi[i]; 7787 vsi = pf->vsi[i];
@@ -7516,8 +7810,6 @@ void i40e_veb_release(struct i40e_veb *veb)
7516 7810
7517 i40e_aq_delete_element(&pf->hw, veb->seid, NULL); 7811 i40e_aq_delete_element(&pf->hw, veb->seid, NULL);
7518 i40e_veb_clear(veb); 7812 i40e_veb_clear(veb);
7519
7520 return;
7521} 7813}
7522 7814
7523/** 7815/**
@@ -7601,10 +7893,10 @@ struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf, u16 flags,
7601 } 7893 }
7602 7894
7603 /* make sure there is such a vsi and uplink */ 7895 /* make sure there is such a vsi and uplink */
7604 for (vsi_idx = 0; vsi_idx < pf->hw.func_caps.num_vsis; vsi_idx++) 7896 for (vsi_idx = 0; vsi_idx < pf->num_alloc_vsi; vsi_idx++)
7605 if (pf->vsi[vsi_idx] && pf->vsi[vsi_idx]->seid == vsi_seid) 7897 if (pf->vsi[vsi_idx] && pf->vsi[vsi_idx]->seid == vsi_seid)
7606 break; 7898 break;
7607 if (vsi_idx >= pf->hw.func_caps.num_vsis && vsi_seid != 0) { 7899 if (vsi_idx >= pf->num_alloc_vsi && vsi_seid != 0) {
7608 dev_info(&pf->pdev->dev, "vsi seid %d not found\n", 7900 dev_info(&pf->pdev->dev, "vsi seid %d not found\n",
7609 vsi_seid); 7901 vsi_seid);
7610 return NULL; 7902 return NULL;
@@ -7639,6 +7931,8 @@ struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf, u16 flags,
7639 ret = i40e_add_veb(veb, pf->vsi[vsi_idx]); 7931 ret = i40e_add_veb(veb, pf->vsi[vsi_idx]);
7640 if (ret) 7932 if (ret)
7641 goto err_veb; 7933 goto err_veb;
7934 if (vsi_idx == pf->lan_vsi)
7935 pf->lan_veb = veb->idx;
7642 7936
7643 return veb; 7937 return veb;
7644 7938
@@ -7774,15 +8068,6 @@ int i40e_fetch_switch_configuration(struct i40e_pf *pf, bool printconfig)
7774 "header: %d reported %d total\n", 8068 "header: %d reported %d total\n",
7775 num_reported, num_total); 8069 num_reported, num_total);
7776 8070
7777 if (num_reported) {
7778 int sz = sizeof(*sw_config) * num_reported;
7779
7780 kfree(pf->sw_config);
7781 pf->sw_config = kzalloc(sz, GFP_KERNEL);
7782 if (pf->sw_config)
7783 memcpy(pf->sw_config, sw_config, sz);
7784 }
7785
7786 for (i = 0; i < num_reported; i++) { 8071 for (i = 0; i < num_reported; i++) {
7787 struct i40e_aqc_switch_config_element_resp *ele = 8072 struct i40e_aqc_switch_config_element_resp *ele =
7788 &sw_config->element[i]; 8073 &sw_config->element[i];
@@ -7949,9 +8234,7 @@ static void i40e_determine_queue_usage(struct i40e_pf *pf)
7949 queues_left = pf->hw.func_caps.num_tx_qp; 8234 queues_left = pf->hw.func_caps.num_tx_qp;
7950 8235
7951 if ((queues_left == 1) || 8236 if ((queues_left == 1) ||
7952 !(pf->flags & I40E_FLAG_MSIX_ENABLED) || 8237 !(pf->flags & I40E_FLAG_MSIX_ENABLED)) {
7953 !(pf->flags & (I40E_FLAG_RSS_ENABLED | I40E_FLAG_FD_SB_ENABLED |
7954 I40E_FLAG_DCB_ENABLED))) {
7955 /* one qp for PF, no queues for anything else */ 8238 /* one qp for PF, no queues for anything else */
7956 queues_left = 0; 8239 queues_left = 0;
7957 pf->rss_size = pf->num_lan_qps = 1; 8240 pf->rss_size = pf->num_lan_qps = 1;
@@ -7960,14 +8243,27 @@ static void i40e_determine_queue_usage(struct i40e_pf *pf)
7960 pf->flags &= ~(I40E_FLAG_RSS_ENABLED | 8243 pf->flags &= ~(I40E_FLAG_RSS_ENABLED |
7961 I40E_FLAG_FD_SB_ENABLED | 8244 I40E_FLAG_FD_SB_ENABLED |
7962 I40E_FLAG_FD_ATR_ENABLED | 8245 I40E_FLAG_FD_ATR_ENABLED |
7963 I40E_FLAG_DCB_ENABLED | 8246 I40E_FLAG_DCB_CAPABLE |
7964 I40E_FLAG_SRIOV_ENABLED | 8247 I40E_FLAG_SRIOV_ENABLED |
7965 I40E_FLAG_VMDQ_ENABLED); 8248 I40E_FLAG_VMDQ_ENABLED);
8249 } else if (!(pf->flags & (I40E_FLAG_RSS_ENABLED |
8250 I40E_FLAG_FD_SB_ENABLED |
8251 I40E_FLAG_FD_ATR_ENABLED |
8252 I40E_FLAG_DCB_CAPABLE))) {
8253 /* one qp for PF */
8254 pf->rss_size = pf->num_lan_qps = 1;
8255 queues_left -= pf->num_lan_qps;
8256
8257 pf->flags &= ~(I40E_FLAG_RSS_ENABLED |
8258 I40E_FLAG_FD_SB_ENABLED |
8259 I40E_FLAG_FD_ATR_ENABLED |
8260 I40E_FLAG_DCB_ENABLED |
8261 I40E_FLAG_VMDQ_ENABLED);
7966 } else { 8262 } else {
7967 /* Not enough queues for all TCs */ 8263 /* Not enough queues for all TCs */
7968 if ((pf->flags & I40E_FLAG_DCB_ENABLED) && 8264 if ((pf->flags & I40E_FLAG_DCB_CAPABLE) &&
7969 (queues_left < I40E_MAX_TRAFFIC_CLASS)) { 8265 (queues_left < I40E_MAX_TRAFFIC_CLASS)) {
7970 pf->flags &= ~I40E_FLAG_DCB_ENABLED; 8266 pf->flags &= ~I40E_FLAG_DCB_CAPABLE;
7971 dev_info(&pf->pdev->dev, "not enough queues for DCB. DCB is disabled.\n"); 8267 dev_info(&pf->pdev->dev, "not enough queues for DCB. DCB is disabled.\n");
7972 } 8268 }
7973 pf->num_lan_qps = pf->rss_size_max; 8269 pf->num_lan_qps = pf->rss_size_max;
@@ -7998,7 +8294,6 @@ static void i40e_determine_queue_usage(struct i40e_pf *pf)
7998 } 8294 }
7999 8295
8000 pf->queues_left = queues_left; 8296 pf->queues_left = queues_left;
8001 return;
8002} 8297}
8003 8298
8004/** 8299/**
@@ -8055,12 +8350,13 @@ static void i40e_print_features(struct i40e_pf *pf)
8055 8350
8056 if (pf->flags & I40E_FLAG_RSS_ENABLED) 8351 if (pf->flags & I40E_FLAG_RSS_ENABLED)
8057 buf += sprintf(buf, "RSS "); 8352 buf += sprintf(buf, "RSS ");
8058 buf += sprintf(buf, "FDir ");
8059 if (pf->flags & I40E_FLAG_FD_ATR_ENABLED) 8353 if (pf->flags & I40E_FLAG_FD_ATR_ENABLED)
8060 buf += sprintf(buf, "ATR "); 8354 buf += sprintf(buf, "FD_ATR ");
8061 if (pf->flags & I40E_FLAG_FD_SB_ENABLED) 8355 if (pf->flags & I40E_FLAG_FD_SB_ENABLED) {
8356 buf += sprintf(buf, "FD_SB ");
8062 buf += sprintf(buf, "NTUPLE "); 8357 buf += sprintf(buf, "NTUPLE ");
8063 if (pf->flags & I40E_FLAG_DCB_ENABLED) 8358 }
8359 if (pf->flags & I40E_FLAG_DCB_CAPABLE)
8064 buf += sprintf(buf, "DCB "); 8360 buf += sprintf(buf, "DCB ");
8065 if (pf->flags & I40E_FLAG_PTP) 8361 if (pf->flags & I40E_FLAG_PTP)
8066 buf += sprintf(buf, "PTP "); 8362 buf += sprintf(buf, "PTP ");
@@ -8083,13 +8379,13 @@ static void i40e_print_features(struct i40e_pf *pf)
8083 **/ 8379 **/
8084static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 8380static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
8085{ 8381{
8086 struct i40e_driver_version dv;
8087 struct i40e_pf *pf; 8382 struct i40e_pf *pf;
8088 struct i40e_hw *hw; 8383 struct i40e_hw *hw;
8089 static u16 pfs_found; 8384 static u16 pfs_found;
8090 u16 link_status; 8385 u16 link_status;
8091 int err = 0; 8386 int err = 0;
8092 u32 len; 8387 u32 len;
8388 u32 i;
8093 8389
8094 err = pci_enable_device_mem(pdev); 8390 err = pci_enable_device_mem(pdev);
8095 if (err) 8391 if (err)
@@ -8201,6 +8497,10 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
8201 8497
8202 i40e_verify_eeprom(pf); 8498 i40e_verify_eeprom(pf);
8203 8499
8500 /* Rev 0 hardware was never productized */
8501 if (hw->revision_id < 1)
8502 dev_warn(&pdev->dev, "This device is a pre-production adapter/LOM. Please be aware there may be issues with your hardware. If you are experiencing problems please contact your Intel or hardware representative who provided you with this hardware.\n");
8503
8204 i40e_clear_pxe_mode(hw); 8504 i40e_clear_pxe_mode(hw);
8205 err = i40e_get_capabilities(pf); 8505 err = i40e_get_capabilities(pf);
8206 if (err) 8506 if (err)
@@ -8234,7 +8534,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
8234 goto err_mac_addr; 8534 goto err_mac_addr;
8235 } 8535 }
8236 dev_info(&pdev->dev, "MAC address: %pM\n", hw->mac.addr); 8536 dev_info(&pdev->dev, "MAC address: %pM\n", hw->mac.addr);
8237 memcpy(hw->mac.perm_addr, hw->mac.addr, ETH_ALEN); 8537 ether_addr_copy(hw->mac.perm_addr, hw->mac.addr);
8238 8538
8239 pci_set_drvdata(pdev, pf); 8539 pci_set_drvdata(pdev, pf);
8240 pci_save_state(pdev); 8540 pci_save_state(pdev);
@@ -8242,8 +8542,8 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
8242 err = i40e_init_pf_dcb(pf); 8542 err = i40e_init_pf_dcb(pf);
8243 if (err) { 8543 if (err) {
8244 dev_info(&pdev->dev, "init_pf_dcb failed: %d\n", err); 8544 dev_info(&pdev->dev, "init_pf_dcb failed: %d\n", err);
8245 pf->flags &= ~I40E_FLAG_DCB_ENABLED; 8545 pf->flags &= ~I40E_FLAG_DCB_CAPABLE;
8246 goto err_init_dcb; 8546 /* Continue without DCB enabled */
8247 } 8547 }
8248#endif /* CONFIG_I40E_DCB */ 8548#endif /* CONFIG_I40E_DCB */
8249 8549
@@ -8264,10 +8564,18 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
8264 i40e_determine_queue_usage(pf); 8564 i40e_determine_queue_usage(pf);
8265 i40e_init_interrupt_scheme(pf); 8565 i40e_init_interrupt_scheme(pf);
8266 8566
8267 /* Set up the *vsi struct based on the number of VSIs in the HW, 8567 /* The number of VSIs reported by the FW is the minimum guaranteed
8268 * and set up our local tracking of the MAIN PF vsi. 8568 * to us; HW supports far more and we share the remaining pool with
8569 * the other PFs. We allocate space for more than the guarantee with
8570 * the understanding that we might not get them all later.
8269 */ 8571 */
8270 len = sizeof(struct i40e_vsi *) * pf->hw.func_caps.num_vsis; 8572 if (pf->hw.func_caps.num_vsis < I40E_MIN_VSI_ALLOC)
8573 pf->num_alloc_vsi = I40E_MIN_VSI_ALLOC;
8574 else
8575 pf->num_alloc_vsi = pf->hw.func_caps.num_vsis;
8576
8577 /* Set up the *vsi struct and our local tracking of the MAIN PF vsi. */
8578 len = sizeof(struct i40e_vsi *) * pf->num_alloc_vsi;
8271 pf->vsi = kzalloc(len, GFP_KERNEL); 8579 pf->vsi = kzalloc(len, GFP_KERNEL);
8272 if (!pf->vsi) { 8580 if (!pf->vsi) {
8273 err = -ENOMEM; 8581 err = -ENOMEM;
@@ -8279,6 +8587,13 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
8279 dev_info(&pdev->dev, "setup_pf_switch failed: %d\n", err); 8587 dev_info(&pdev->dev, "setup_pf_switch failed: %d\n", err);
8280 goto err_vsis; 8588 goto err_vsis;
8281 } 8589 }
8590 /* if FDIR VSI was set up, start it now */
8591 for (i = 0; i < pf->num_alloc_vsi; i++) {
8592 if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) {
8593 i40e_vsi_open(pf->vsi[i]);
8594 break;
8595 }
8596 }
8282 8597
8283 /* The main driver is (mostly) up and happy. We need to set this state 8598 /* The main driver is (mostly) up and happy. We need to set this state
8284 * before setting up the misc vector or we get a race and the vector 8599 * before setting up the misc vector or we get a race and the vector
@@ -8300,6 +8615,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
8300 } 8615 }
8301 } 8616 }
8302 8617
8618#ifdef CONFIG_PCI_IOV
8303 /* prep for VF support */ 8619 /* prep for VF support */
8304 if ((pf->flags & I40E_FLAG_SRIOV_ENABLED) && 8620 if ((pf->flags & I40E_FLAG_SRIOV_ENABLED) &&
8305 (pf->flags & I40E_FLAG_MSIX_ENABLED) && 8621 (pf->flags & I40E_FLAG_MSIX_ENABLED) &&
@@ -8322,17 +8638,14 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
8322 err); 8638 err);
8323 } 8639 }
8324 } 8640 }
8641#endif /* CONFIG_PCI_IOV */
8325 8642
8326 pfs_found++; 8643 pfs_found++;
8327 8644
8328 i40e_dbg_pf_init(pf); 8645 i40e_dbg_pf_init(pf);
8329 8646
8330 /* tell the firmware that we're starting */ 8647 /* tell the firmware that we're starting */
8331 dv.major_version = DRV_VERSION_MAJOR; 8648 i40e_send_version(pf);
8332 dv.minor_version = DRV_VERSION_MINOR;
8333 dv.build_version = DRV_VERSION_BUILD;
8334 dv.subbuild_version = 0;
8335 i40e_aq_send_driver_version(&pf->hw, &dv, NULL);
8336 8649
8337 /* since everything's happy, start the service_task timer */ 8650 /* since everything's happy, start the service_task timer */
8338 mod_timer(&pf->service_timer, 8651 mod_timer(&pf->service_timer,
@@ -8373,9 +8686,6 @@ err_vsis:
8373err_switch_setup: 8686err_switch_setup:
8374 i40e_reset_interrupt_capability(pf); 8687 i40e_reset_interrupt_capability(pf);
8375 del_timer_sync(&pf->service_timer); 8688 del_timer_sync(&pf->service_timer);
8376#ifdef CONFIG_I40E_DCB
8377err_init_dcb:
8378#endif /* CONFIG_I40E_DCB */
8379err_mac_addr: 8689err_mac_addr:
8380err_configure_lan_hmc: 8690err_configure_lan_hmc:
8381 (void)i40e_shutdown_lan_hmc(hw); 8691 (void)i40e_shutdown_lan_hmc(hw);
@@ -8456,10 +8766,13 @@ static void i40e_remove(struct pci_dev *pdev)
8456 } 8766 }
8457 8767
8458 /* shutdown and destroy the HMC */ 8768 /* shutdown and destroy the HMC */
8459 ret_code = i40e_shutdown_lan_hmc(&pf->hw); 8769 if (pf->hw.hmc.hmc_obj) {
8460 if (ret_code) 8770 ret_code = i40e_shutdown_lan_hmc(&pf->hw);
8461 dev_warn(&pdev->dev, 8771 if (ret_code)
8462 "Failed to destroy the HMC resources: %d\n", ret_code); 8772 dev_warn(&pdev->dev,
8773 "Failed to destroy the HMC resources: %d\n",
8774 ret_code);
8775 }
8463 8776
8464 /* shutdown the adminq */ 8777 /* shutdown the adminq */
8465 ret_code = i40e_shutdown_adminq(&pf->hw); 8778 ret_code = i40e_shutdown_adminq(&pf->hw);
@@ -8470,7 +8783,7 @@ static void i40e_remove(struct pci_dev *pdev)
8470 8783
8471 /* Clear all dynamic memory lists of rings, q_vectors, and VSIs */ 8784 /* Clear all dynamic memory lists of rings, q_vectors, and VSIs */
8472 i40e_clear_interrupt_scheme(pf); 8785 i40e_clear_interrupt_scheme(pf);
8473 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) { 8786 for (i = 0; i < pf->num_alloc_vsi; i++) {
8474 if (pf->vsi[i]) { 8787 if (pf->vsi[i]) {
8475 i40e_vsi_clear_rings(pf->vsi[i]); 8788 i40e_vsi_clear_rings(pf->vsi[i]);
8476 i40e_vsi_clear(pf->vsi[i]); 8789 i40e_vsi_clear(pf->vsi[i]);
@@ -8485,7 +8798,6 @@ static void i40e_remove(struct pci_dev *pdev)
8485 8798
8486 kfree(pf->qp_pile); 8799 kfree(pf->qp_pile);
8487 kfree(pf->irq_pile); 8800 kfree(pf->irq_pile);
8488 kfree(pf->sw_config);
8489 kfree(pf->vsi); 8801 kfree(pf->vsi);
8490 8802
8491 /* force a PF reset to clean anything leftover */ 8803 /* force a PF reset to clean anything leftover */