diff options
Diffstat (limited to 'drivers/net/ethernet/intel/i40e/i40e_main.c')
| -rw-r--r-- | drivers/net/ethernet/intel/i40e/i40e_main.c | 546 |
1 files changed, 397 insertions, 149 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index b901371ca361..861b722c2672 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | 26 | ||
| 27 | /* Local includes */ | 27 | /* Local includes */ |
| 28 | #include "i40e.h" | 28 | #include "i40e.h" |
| 29 | #include "i40e_diag.h" | ||
| 29 | #ifdef CONFIG_I40E_VXLAN | 30 | #ifdef CONFIG_I40E_VXLAN |
| 30 | #include <net/vxlan.h> | 31 | #include <net/vxlan.h> |
| 31 | #endif | 32 | #endif |
| @@ -38,7 +39,7 @@ static const char i40e_driver_string[] = | |||
| 38 | 39 | ||
| 39 | #define DRV_VERSION_MAJOR 0 | 40 | #define DRV_VERSION_MAJOR 0 |
| 40 | #define DRV_VERSION_MINOR 3 | 41 | #define DRV_VERSION_MINOR 3 |
| 41 | #define DRV_VERSION_BUILD 30 | 42 | #define DRV_VERSION_BUILD 36 |
| 42 | #define DRV_VERSION __stringify(DRV_VERSION_MAJOR) "." \ | 43 | #define DRV_VERSION __stringify(DRV_VERSION_MAJOR) "." \ |
| 43 | __stringify(DRV_VERSION_MINOR) "." \ | 44 | __stringify(DRV_VERSION_MINOR) "." \ |
| 44 | __stringify(DRV_VERSION_BUILD) DRV_KERN | 45 | __stringify(DRV_VERSION_BUILD) DRV_KERN |
| @@ -305,6 +306,7 @@ static void i40e_tx_timeout(struct net_device *netdev) | |||
| 305 | break; | 306 | break; |
| 306 | default: | 307 | default: |
| 307 | netdev_err(netdev, "tx_timeout recovery unsuccessful\n"); | 308 | netdev_err(netdev, "tx_timeout recovery unsuccessful\n"); |
| 309 | set_bit(__I40E_DOWN, &vsi->state); | ||
| 308 | i40e_down(vsi); | 310 | i40e_down(vsi); |
| 309 | break; | 311 | break; |
| 310 | } | 312 | } |
| @@ -375,20 +377,20 @@ static struct rtnl_link_stats64 *i40e_get_netdev_stats_struct( | |||
| 375 | continue; | 377 | continue; |
| 376 | 378 | ||
| 377 | do { | 379 | do { |
| 378 | start = u64_stats_fetch_begin_bh(&tx_ring->syncp); | 380 | start = u64_stats_fetch_begin_irq(&tx_ring->syncp); |
| 379 | packets = tx_ring->stats.packets; | 381 | packets = tx_ring->stats.packets; |
| 380 | bytes = tx_ring->stats.bytes; | 382 | bytes = tx_ring->stats.bytes; |
| 381 | } while (u64_stats_fetch_retry_bh(&tx_ring->syncp, start)); | 383 | } while (u64_stats_fetch_retry_irq(&tx_ring->syncp, start)); |
| 382 | 384 | ||
| 383 | stats->tx_packets += packets; | 385 | stats->tx_packets += packets; |
| 384 | stats->tx_bytes += bytes; | 386 | stats->tx_bytes += bytes; |
| 385 | rx_ring = &tx_ring[1]; | 387 | rx_ring = &tx_ring[1]; |
| 386 | 388 | ||
| 387 | do { | 389 | do { |
| 388 | start = u64_stats_fetch_begin_bh(&rx_ring->syncp); | 390 | start = u64_stats_fetch_begin_irq(&rx_ring->syncp); |
| 389 | packets = rx_ring->stats.packets; | 391 | packets = rx_ring->stats.packets; |
| 390 | bytes = rx_ring->stats.bytes; | 392 | bytes = rx_ring->stats.bytes; |
| 391 | } while (u64_stats_fetch_retry_bh(&rx_ring->syncp, start)); | 393 | } while (u64_stats_fetch_retry_irq(&rx_ring->syncp, start)); |
| 392 | 394 | ||
| 393 | stats->rx_packets += packets; | 395 | stats->rx_packets += packets; |
| 394 | stats->rx_bytes += bytes; | 396 | stats->rx_bytes += bytes; |
| @@ -739,6 +741,7 @@ void i40e_update_stats(struct i40e_vsi *vsi) | |||
| 739 | u32 rx_page, rx_buf; | 741 | u32 rx_page, rx_buf; |
| 740 | u64 rx_p, rx_b; | 742 | u64 rx_p, rx_b; |
| 741 | u64 tx_p, tx_b; | 743 | u64 tx_p, tx_b; |
| 744 | u32 val; | ||
| 742 | int i; | 745 | int i; |
| 743 | u16 q; | 746 | u16 q; |
| 744 | 747 | ||
| @@ -769,10 +772,10 @@ void i40e_update_stats(struct i40e_vsi *vsi) | |||
| 769 | p = ACCESS_ONCE(vsi->tx_rings[q]); | 772 | p = ACCESS_ONCE(vsi->tx_rings[q]); |
| 770 | 773 | ||
| 771 | do { | 774 | do { |
| 772 | start = u64_stats_fetch_begin_bh(&p->syncp); | 775 | start = u64_stats_fetch_begin_irq(&p->syncp); |
| 773 | packets = p->stats.packets; | 776 | packets = p->stats.packets; |
| 774 | bytes = p->stats.bytes; | 777 | bytes = p->stats.bytes; |
| 775 | } while (u64_stats_fetch_retry_bh(&p->syncp, start)); | 778 | } while (u64_stats_fetch_retry_irq(&p->syncp, start)); |
| 776 | tx_b += bytes; | 779 | tx_b += bytes; |
| 777 | tx_p += packets; | 780 | tx_p += packets; |
| 778 | tx_restart += p->tx_stats.restart_queue; | 781 | tx_restart += p->tx_stats.restart_queue; |
| @@ -781,10 +784,10 @@ void i40e_update_stats(struct i40e_vsi *vsi) | |||
| 781 | /* Rx queue is part of the same block as Tx queue */ | 784 | /* Rx queue is part of the same block as Tx queue */ |
| 782 | p = &p[1]; | 785 | p = &p[1]; |
| 783 | do { | 786 | do { |
| 784 | start = u64_stats_fetch_begin_bh(&p->syncp); | 787 | start = u64_stats_fetch_begin_irq(&p->syncp); |
| 785 | packets = p->stats.packets; | 788 | packets = p->stats.packets; |
| 786 | bytes = p->stats.bytes; | 789 | bytes = p->stats.bytes; |
| 787 | } while (u64_stats_fetch_retry_bh(&p->syncp, start)); | 790 | } while (u64_stats_fetch_retry_irq(&p->syncp, start)); |
| 788 | rx_b += bytes; | 791 | rx_b += bytes; |
| 789 | rx_p += packets; | 792 | rx_p += packets; |
| 790 | rx_buf += p->rx_stats.alloc_buff_failed; | 793 | rx_buf += p->rx_stats.alloc_buff_failed; |
| @@ -971,6 +974,20 @@ void i40e_update_stats(struct i40e_vsi *vsi) | |||
| 971 | i40e_stat_update32(hw, I40E_GLPRT_RJC(hw->port), | 974 | i40e_stat_update32(hw, I40E_GLPRT_RJC(hw->port), |
| 972 | pf->stat_offsets_loaded, | 975 | pf->stat_offsets_loaded, |
| 973 | &osd->rx_jabber, &nsd->rx_jabber); | 976 | &osd->rx_jabber, &nsd->rx_jabber); |
| 977 | |||
| 978 | val = rd32(hw, I40E_PRTPM_EEE_STAT); | ||
| 979 | nsd->tx_lpi_status = | ||
| 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, | ||
| 987 | &osd->tx_lpi_count, &nsd->tx_lpi_count); | ||
| 988 | i40e_stat_update32(hw, I40E_PRTPM_RLPIC, | ||
| 989 | pf->stat_offsets_loaded, | ||
| 990 | &osd->rx_lpi_count, &nsd->rx_lpi_count); | ||
| 974 | } | 991 | } |
| 975 | 992 | ||
| 976 | pf->stat_offsets_loaded = true; | 993 | pf->stat_offsets_loaded = true; |
| @@ -1964,11 +1981,14 @@ static int i40e_vlan_rx_add_vid(struct net_device *netdev, | |||
| 1964 | 1981 | ||
| 1965 | netdev_info(netdev, "adding %pM vid=%d\n", netdev->dev_addr, vid); | 1982 | netdev_info(netdev, "adding %pM vid=%d\n", netdev->dev_addr, vid); |
| 1966 | 1983 | ||
| 1967 | /* If the network stack called us with vid = 0, we should | 1984 | /* If the network stack called us with vid = 0 then |
| 1968 | * indicate to i40e_vsi_add_vlan() that we want to receive | 1985 | * it is asking to receive priority tagged packets with |
| 1969 | * any traffic (i.e. with any vlan tag, or untagged) | 1986 | * vlan id 0. Our HW receives them by default when configured |
| 1987 | * to receive untagged packets so there is no need to add an | ||
| 1988 | * extra filter for vlan 0 tagged packets. | ||
| 1970 | */ | 1989 | */ |
| 1971 | ret = i40e_vsi_add_vlan(vsi, vid ? vid : I40E_VLAN_ANY); | 1990 | if (vid) |
| 1991 | ret = i40e_vsi_add_vlan(vsi, vid); | ||
| 1972 | 1992 | ||
| 1973 | if (!ret && (vid < VLAN_N_VID)) | 1993 | if (!ret && (vid < VLAN_N_VID)) |
| 1974 | set_bit(vid, vsi->active_vlans); | 1994 | set_bit(vid, vsi->active_vlans); |
| @@ -1981,7 +2001,7 @@ static int i40e_vlan_rx_add_vid(struct net_device *netdev, | |||
| 1981 | * @netdev: network interface to be adjusted | 2001 | * @netdev: network interface to be adjusted |
| 1982 | * @vid: vlan id to be removed | 2002 | * @vid: vlan id to be removed |
| 1983 | * | 2003 | * |
| 1984 | * net_device_ops implementation for adding vlan ids | 2004 | * net_device_ops implementation for removing vlan ids |
| 1985 | **/ | 2005 | **/ |
| 1986 | static int i40e_vlan_rx_kill_vid(struct net_device *netdev, | 2006 | static int i40e_vlan_rx_kill_vid(struct net_device *netdev, |
| 1987 | __always_unused __be16 proto, u16 vid) | 2007 | __always_unused __be16 proto, u16 vid) |
| @@ -2177,6 +2197,11 @@ static int i40e_configure_tx_ring(struct i40e_ring *ring) | |||
| 2177 | tx_ctx.fd_ena = !!(vsi->back->flags & (I40E_FLAG_FD_SB_ENABLED | | 2197 | tx_ctx.fd_ena = !!(vsi->back->flags & (I40E_FLAG_FD_SB_ENABLED | |
| 2178 | I40E_FLAG_FD_ATR_ENABLED)); | 2198 | I40E_FLAG_FD_ATR_ENABLED)); |
| 2179 | tx_ctx.timesync_ena = !!(vsi->back->flags & I40E_FLAG_PTP); | 2199 | tx_ctx.timesync_ena = !!(vsi->back->flags & I40E_FLAG_PTP); |
| 2200 | /* FDIR VSI tx ring can still use RS bit and writebacks */ | ||
| 2201 | if (vsi->type != I40E_VSI_FDIR) | ||
| 2202 | tx_ctx.head_wb_ena = 1; | ||
| 2203 | tx_ctx.head_wb_addr = ring->dma + | ||
| 2204 | (ring->count * sizeof(struct i40e_tx_desc)); | ||
| 2180 | 2205 | ||
| 2181 | /* As part of VSI creation/update, FW allocates certain | 2206 | /* As part of VSI creation/update, FW allocates certain |
| 2182 | * Tx arbitration queue sets for each TC enabled for | 2207 | * Tx arbitration queue sets for each TC enabled for |
| @@ -2420,6 +2445,28 @@ static void i40e_set_vsi_rx_mode(struct i40e_vsi *vsi) | |||
| 2420 | } | 2445 | } |
| 2421 | 2446 | ||
| 2422 | /** | 2447 | /** |
| 2448 | * i40e_fdir_filter_restore - Restore the Sideband Flow Director filters | ||
| 2449 | * @vsi: Pointer to the targeted VSI | ||
| 2450 | * | ||
| 2451 | * This function replays the hlist on the hw where all the SB Flow Director | ||
| 2452 | * filters were saved. | ||
| 2453 | **/ | ||
| 2454 | static void i40e_fdir_filter_restore(struct i40e_vsi *vsi) | ||
| 2455 | { | ||
| 2456 | struct i40e_fdir_filter *filter; | ||
| 2457 | struct i40e_pf *pf = vsi->back; | ||
| 2458 | struct hlist_node *node; | ||
| 2459 | |||
| 2460 | if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED)) | ||
| 2461 | return; | ||
| 2462 | |||
| 2463 | hlist_for_each_entry_safe(filter, node, | ||
| 2464 | &pf->fdir_filter_list, fdir_node) { | ||
| 2465 | i40e_add_del_fdir(vsi, filter, true); | ||
| 2466 | } | ||
| 2467 | } | ||
| 2468 | |||
| 2469 | /** | ||
| 2423 | * i40e_vsi_configure - Set up the VSI for action | 2470 | * i40e_vsi_configure - Set up the VSI for action |
| 2424 | * @vsi: the VSI being configured | 2471 | * @vsi: the VSI being configured |
| 2425 | **/ | 2472 | **/ |
| @@ -2557,7 +2604,7 @@ static void i40e_configure_msi_and_legacy(struct i40e_vsi *vsi) | |||
| 2557 | /* FIRSTQ_INDX = 0, FIRSTQ_TYPE = 0 (rx) */ | 2604 | /* FIRSTQ_INDX = 0, FIRSTQ_TYPE = 0 (rx) */ |
| 2558 | wr32(hw, I40E_PFINT_LNKLST0, 0); | 2605 | wr32(hw, I40E_PFINT_LNKLST0, 0); |
| 2559 | 2606 | ||
| 2560 | /* Associate the queue pair to the vector and enable the q int */ | 2607 | /* Associate the queue pair to the vector and enable the queue int */ |
| 2561 | val = I40E_QINT_RQCTL_CAUSE_ENA_MASK | | 2608 | val = I40E_QINT_RQCTL_CAUSE_ENA_MASK | |
| 2562 | (I40E_RX_ITR << I40E_QINT_RQCTL_ITR_INDX_SHIFT) | | 2609 | (I40E_RX_ITR << I40E_QINT_RQCTL_ITR_INDX_SHIFT) | |
| 2563 | (I40E_QUEUE_TYPE_TX << I40E_QINT_TQCTL_NEXTQ_TYPE_SHIFT); | 2610 | (I40E_QUEUE_TYPE_TX << I40E_QINT_TQCTL_NEXTQ_TYPE_SHIFT); |
| @@ -2831,12 +2878,14 @@ static irqreturn_t i40e_intr(int irq, void *data) | |||
| 2831 | val = rd32(hw, I40E_GLGEN_RSTAT); | 2878 | val = rd32(hw, I40E_GLGEN_RSTAT); |
| 2832 | val = (val & I40E_GLGEN_RSTAT_RESET_TYPE_MASK) | 2879 | val = (val & I40E_GLGEN_RSTAT_RESET_TYPE_MASK) |
| 2833 | >> I40E_GLGEN_RSTAT_RESET_TYPE_SHIFT; | 2880 | >> I40E_GLGEN_RSTAT_RESET_TYPE_SHIFT; |
| 2834 | if (val == I40E_RESET_CORER) | 2881 | if (val == I40E_RESET_CORER) { |
| 2835 | pf->corer_count++; | 2882 | pf->corer_count++; |
| 2836 | else if (val == I40E_RESET_GLOBR) | 2883 | } else if (val == I40E_RESET_GLOBR) { |
| 2837 | pf->globr_count++; | 2884 | pf->globr_count++; |
| 2838 | else if (val == I40E_RESET_EMPR) | 2885 | } else if (val == I40E_RESET_EMPR) { |
| 2839 | pf->empr_count++; | 2886 | pf->empr_count++; |
| 2887 | set_bit(__I40E_EMP_RESET_REQUESTED, &pf->state); | ||
| 2888 | } | ||
| 2840 | } | 2889 | } |
| 2841 | 2890 | ||
| 2842 | if (icr0 & I40E_PFINT_ICR0_HMC_ERR_MASK) { | 2891 | if (icr0 & I40E_PFINT_ICR0_HMC_ERR_MASK) { |
| @@ -2866,8 +2915,7 @@ static irqreturn_t i40e_intr(int irq, void *data) | |||
| 2866 | icr0_remaining); | 2915 | icr0_remaining); |
| 2867 | if ((icr0_remaining & I40E_PFINT_ICR0_PE_CRITERR_MASK) || | 2916 | if ((icr0_remaining & I40E_PFINT_ICR0_PE_CRITERR_MASK) || |
| 2868 | (icr0_remaining & I40E_PFINT_ICR0_PCI_EXCEPTION_MASK) || | 2917 | (icr0_remaining & I40E_PFINT_ICR0_PCI_EXCEPTION_MASK) || |
| 2869 | (icr0_remaining & I40E_PFINT_ICR0_ECC_ERR_MASK) || | 2918 | (icr0_remaining & I40E_PFINT_ICR0_ECC_ERR_MASK)) { |
| 2870 | (icr0_remaining & I40E_PFINT_ICR0_MAL_DETECT_MASK)) { | ||
| 2871 | dev_info(&pf->pdev->dev, "device will be reset\n"); | 2919 | dev_info(&pf->pdev->dev, "device will be reset\n"); |
| 2872 | set_bit(__I40E_PF_RESET_REQUESTED, &pf->state); | 2920 | set_bit(__I40E_PF_RESET_REQUESTED, &pf->state); |
| 2873 | i40e_service_event_schedule(pf); | 2921 | i40e_service_event_schedule(pf); |
| @@ -3107,13 +3155,13 @@ static int i40e_vsi_control_tx(struct i40e_vsi *vsi, bool enable) | |||
| 3107 | 3155 | ||
| 3108 | pf_q = vsi->base_queue; | 3156 | pf_q = vsi->base_queue; |
| 3109 | for (i = 0; i < vsi->num_queue_pairs; i++, pf_q++) { | 3157 | for (i = 0; i < vsi->num_queue_pairs; i++, pf_q++) { |
| 3110 | j = 1000; | 3158 | for (j = 0; j < 50; j++) { |
| 3111 | do { | ||
| 3112 | usleep_range(1000, 2000); | ||
| 3113 | tx_reg = rd32(hw, I40E_QTX_ENA(pf_q)); | 3159 | tx_reg = rd32(hw, I40E_QTX_ENA(pf_q)); |
| 3114 | } while (j-- && ((tx_reg >> I40E_QTX_ENA_QENA_REQ_SHIFT) | 3160 | if (((tx_reg >> I40E_QTX_ENA_QENA_REQ_SHIFT) & 1) == |
| 3115 | ^ (tx_reg >> I40E_QTX_ENA_QENA_STAT_SHIFT)) & 1); | 3161 | ((tx_reg >> I40E_QTX_ENA_QENA_STAT_SHIFT) & 1)) |
| 3116 | 3162 | break; | |
| 3163 | usleep_range(1000, 2000); | ||
| 3164 | } | ||
| 3117 | /* Skip if the queue is already in the requested state */ | 3165 | /* Skip if the queue is already in the requested state */ |
| 3118 | if (enable && (tx_reg & I40E_QTX_ENA_QENA_STAT_MASK)) | 3166 | if (enable && (tx_reg & I40E_QTX_ENA_QENA_STAT_MASK)) |
| 3119 | continue; | 3167 | continue; |
| @@ -3123,8 +3171,7 @@ static int i40e_vsi_control_tx(struct i40e_vsi *vsi, bool enable) | |||
| 3123 | /* turn on/off the queue */ | 3171 | /* turn on/off the queue */ |
| 3124 | if (enable) { | 3172 | if (enable) { |
| 3125 | wr32(hw, I40E_QTX_HEAD(pf_q), 0); | 3173 | wr32(hw, I40E_QTX_HEAD(pf_q), 0); |
| 3126 | tx_reg |= I40E_QTX_ENA_QENA_REQ_MASK | | 3174 | tx_reg |= I40E_QTX_ENA_QENA_REQ_MASK; |
| 3127 | I40E_QTX_ENA_QENA_STAT_MASK; | ||
| 3128 | } else { | 3175 | } else { |
| 3129 | tx_reg &= ~I40E_QTX_ENA_QENA_REQ_MASK; | 3176 | tx_reg &= ~I40E_QTX_ENA_QENA_REQ_MASK; |
| 3130 | } | 3177 | } |
| @@ -3171,12 +3218,13 @@ static int i40e_vsi_control_rx(struct i40e_vsi *vsi, bool enable) | |||
| 3171 | 3218 | ||
| 3172 | pf_q = vsi->base_queue; | 3219 | pf_q = vsi->base_queue; |
| 3173 | for (i = 0; i < vsi->num_queue_pairs; i++, pf_q++) { | 3220 | for (i = 0; i < vsi->num_queue_pairs; i++, pf_q++) { |
| 3174 | j = 1000; | 3221 | for (j = 0; j < 50; j++) { |
| 3175 | do { | ||
| 3176 | usleep_range(1000, 2000); | ||
| 3177 | rx_reg = rd32(hw, I40E_QRX_ENA(pf_q)); | 3222 | rx_reg = rd32(hw, I40E_QRX_ENA(pf_q)); |
| 3178 | } while (j-- && ((rx_reg >> I40E_QRX_ENA_QENA_REQ_SHIFT) | 3223 | if (((rx_reg >> I40E_QRX_ENA_QENA_REQ_SHIFT) & 1) == |
| 3179 | ^ (rx_reg >> I40E_QRX_ENA_QENA_STAT_SHIFT)) & 1); | 3224 | ((rx_reg >> I40E_QRX_ENA_QENA_STAT_SHIFT) & 1)) |
| 3225 | break; | ||
| 3226 | usleep_range(1000, 2000); | ||
| 3227 | } | ||
| 3180 | 3228 | ||
| 3181 | if (enable) { | 3229 | if (enable) { |
| 3182 | /* is STAT set ? */ | 3230 | /* is STAT set ? */ |
| @@ -3190,11 +3238,9 @@ static int i40e_vsi_control_rx(struct i40e_vsi *vsi, bool enable) | |||
| 3190 | 3238 | ||
| 3191 | /* turn on/off the queue */ | 3239 | /* turn on/off the queue */ |
| 3192 | if (enable) | 3240 | if (enable) |
| 3193 | rx_reg |= I40E_QRX_ENA_QENA_REQ_MASK | | 3241 | rx_reg |= I40E_QRX_ENA_QENA_REQ_MASK; |
| 3194 | I40E_QRX_ENA_QENA_STAT_MASK; | ||
| 3195 | else | 3242 | else |
| 3196 | rx_reg &= ~(I40E_QRX_ENA_QENA_REQ_MASK | | 3243 | rx_reg &= ~I40E_QRX_ENA_QENA_REQ_MASK; |
| 3197 | I40E_QRX_ENA_QENA_STAT_MASK); | ||
| 3198 | wr32(hw, I40E_QRX_ENA(pf_q), rx_reg); | 3244 | wr32(hw, I40E_QRX_ENA(pf_q), rx_reg); |
| 3199 | 3245 | ||
| 3200 | /* wait for the change to finish */ | 3246 | /* wait for the change to finish */ |
| @@ -3732,8 +3778,8 @@ static int i40e_vsi_configure_bw_alloc(struct i40e_vsi *vsi, u8 enabled_tc, | |||
| 3732 | NULL); | 3778 | NULL); |
| 3733 | if (aq_ret) { | 3779 | if (aq_ret) { |
| 3734 | dev_info(&vsi->back->pdev->dev, | 3780 | dev_info(&vsi->back->pdev->dev, |
| 3735 | "%s: AQ command Config VSI BW allocation per TC failed = %d\n", | 3781 | "AQ command Config VSI BW allocation per TC failed = %d\n", |
| 3736 | __func__, vsi->back->hw.aq.asq_last_status); | 3782 | vsi->back->hw.aq.asq_last_status); |
| 3737 | return -EINVAL; | 3783 | return -EINVAL; |
| 3738 | } | 3784 | } |
| 3739 | 3785 | ||
| @@ -4062,6 +4108,10 @@ static int i40e_up_complete(struct i40e_vsi *vsi) | |||
| 4062 | } else if (vsi->netdev) { | 4108 | } else if (vsi->netdev) { |
| 4063 | netdev_info(vsi->netdev, "NIC Link is Down\n"); | 4109 | netdev_info(vsi->netdev, "NIC Link is Down\n"); |
| 4064 | } | 4110 | } |
| 4111 | |||
| 4112 | /* replay FDIR SB filters */ | ||
| 4113 | if (vsi->type == I40E_VSI_FDIR) | ||
| 4114 | i40e_fdir_filter_restore(vsi); | ||
| 4065 | i40e_service_event_schedule(pf); | 4115 | i40e_service_event_schedule(pf); |
| 4066 | 4116 | ||
| 4067 | return 0; | 4117 | return 0; |
| @@ -4208,15 +4258,40 @@ static int i40e_open(struct net_device *netdev) | |||
| 4208 | struct i40e_netdev_priv *np = netdev_priv(netdev); | 4258 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 4209 | struct i40e_vsi *vsi = np->vsi; | 4259 | struct i40e_vsi *vsi = np->vsi; |
| 4210 | struct i40e_pf *pf = vsi->back; | 4260 | struct i40e_pf *pf = vsi->back; |
| 4211 | char int_name[IFNAMSIZ]; | ||
| 4212 | int err; | 4261 | int err; |
| 4213 | 4262 | ||
| 4214 | /* disallow open during test */ | 4263 | /* disallow open during test or if eeprom is broken */ |
| 4215 | if (test_bit(__I40E_TESTING, &pf->state)) | 4264 | if (test_bit(__I40E_TESTING, &pf->state) || |
| 4265 | test_bit(__I40E_BAD_EEPROM, &pf->state)) | ||
| 4216 | return -EBUSY; | 4266 | return -EBUSY; |
| 4217 | 4267 | ||
| 4218 | netif_carrier_off(netdev); | 4268 | netif_carrier_off(netdev); |
| 4219 | 4269 | ||
| 4270 | err = i40e_vsi_open(vsi); | ||
| 4271 | if (err) | ||
| 4272 | return err; | ||
| 4273 | |||
| 4274 | #ifdef CONFIG_I40E_VXLAN | ||
| 4275 | vxlan_get_rx_port(netdev); | ||
| 4276 | #endif | ||
| 4277 | |||
| 4278 | return 0; | ||
| 4279 | } | ||
| 4280 | |||
| 4281 | /** | ||
| 4282 | * i40e_vsi_open - | ||
| 4283 | * @vsi: the VSI to open | ||
| 4284 | * | ||
| 4285 | * Finish initialization of the VSI. | ||
| 4286 | * | ||
| 4287 | * Returns 0 on success, negative value on failure | ||
| 4288 | **/ | ||
| 4289 | int i40e_vsi_open(struct i40e_vsi *vsi) | ||
| 4290 | { | ||
| 4291 | struct i40e_pf *pf = vsi->back; | ||
| 4292 | char int_name[IFNAMSIZ]; | ||
| 4293 | int err; | ||
| 4294 | |||
| 4220 | /* allocate descriptors */ | 4295 | /* allocate descriptors */ |
| 4221 | err = i40e_vsi_setup_tx_resources(vsi); | 4296 | err = i40e_vsi_setup_tx_resources(vsi); |
| 4222 | if (err) | 4297 | if (err) |
| @@ -4229,18 +4304,22 @@ static int i40e_open(struct net_device *netdev) | |||
| 4229 | if (err) | 4304 | if (err) |
| 4230 | goto err_setup_rx; | 4305 | goto err_setup_rx; |
| 4231 | 4306 | ||
| 4307 | if (!vsi->netdev) { | ||
| 4308 | err = EINVAL; | ||
| 4309 | goto err_setup_rx; | ||
| 4310 | } | ||
| 4232 | snprintf(int_name, sizeof(int_name) - 1, "%s-%s", | 4311 | snprintf(int_name, sizeof(int_name) - 1, "%s-%s", |
| 4233 | dev_driver_string(&pf->pdev->dev), netdev->name); | 4312 | dev_driver_string(&pf->pdev->dev), vsi->netdev->name); |
| 4234 | err = i40e_vsi_request_irq(vsi, int_name); | 4313 | err = i40e_vsi_request_irq(vsi, int_name); |
| 4235 | if (err) | 4314 | if (err) |
| 4236 | goto err_setup_rx; | 4315 | goto err_setup_rx; |
| 4237 | 4316 | ||
| 4238 | /* Notify the stack of the actual queue counts. */ | 4317 | /* Notify the stack of the actual queue counts. */ |
| 4239 | err = netif_set_real_num_tx_queues(netdev, vsi->num_queue_pairs); | 4318 | err = netif_set_real_num_tx_queues(vsi->netdev, vsi->num_queue_pairs); |
| 4240 | if (err) | 4319 | if (err) |
| 4241 | goto err_set_queues; | 4320 | goto err_set_queues; |
| 4242 | 4321 | ||
| 4243 | err = netif_set_real_num_rx_queues(netdev, vsi->num_queue_pairs); | 4322 | err = netif_set_real_num_rx_queues(vsi->netdev, vsi->num_queue_pairs); |
| 4244 | if (err) | 4323 | if (err) |
| 4245 | goto err_set_queues; | 4324 | goto err_set_queues; |
| 4246 | 4325 | ||
| @@ -4248,10 +4327,6 @@ static int i40e_open(struct net_device *netdev) | |||
| 4248 | if (err) | 4327 | if (err) |
| 4249 | goto err_up_complete; | 4328 | goto err_up_complete; |
| 4250 | 4329 | ||
| 4251 | #ifdef CONFIG_I40E_VXLAN | ||
| 4252 | vxlan_get_rx_port(netdev); | ||
| 4253 | #endif | ||
| 4254 | |||
| 4255 | return 0; | 4330 | return 0; |
| 4256 | 4331 | ||
| 4257 | err_up_complete: | 4332 | err_up_complete: |
| @@ -4269,6 +4344,26 @@ err_setup_tx: | |||
| 4269 | } | 4344 | } |
| 4270 | 4345 | ||
| 4271 | /** | 4346 | /** |
| 4347 | * i40e_fdir_filter_exit - Cleans up the Flow Director accounting | ||
| 4348 | * @pf: Pointer to pf | ||
| 4349 | * | ||
| 4350 | * This function destroys the hlist where all the Flow Director | ||
| 4351 | * filters were saved. | ||
| 4352 | **/ | ||
| 4353 | static void i40e_fdir_filter_exit(struct i40e_pf *pf) | ||
| 4354 | { | ||
| 4355 | struct i40e_fdir_filter *filter; | ||
| 4356 | struct hlist_node *node2; | ||
| 4357 | |||
| 4358 | hlist_for_each_entry_safe(filter, node2, | ||
| 4359 | &pf->fdir_filter_list, fdir_node) { | ||
| 4360 | hlist_del(&filter->fdir_node); | ||
| 4361 | kfree(filter); | ||
| 4362 | } | ||
| 4363 | pf->fdir_pf_active_filters = 0; | ||
| 4364 | } | ||
| 4365 | |||
| 4366 | /** | ||
| 4272 | * i40e_close - Disables a network interface | 4367 | * i40e_close - Disables a network interface |
| 4273 | * @netdev: network interface device structure | 4368 | * @netdev: network interface device structure |
| 4274 | * | 4369 | * |
| @@ -4321,7 +4416,7 @@ void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags) | |||
| 4321 | * for the warning interrupt will deal with the shutdown | 4416 | * for the warning interrupt will deal with the shutdown |
| 4322 | * and recovery of the switch setup. | 4417 | * and recovery of the switch setup. |
| 4323 | */ | 4418 | */ |
| 4324 | dev_info(&pf->pdev->dev, "GlobalR requested\n"); | 4419 | dev_dbg(&pf->pdev->dev, "GlobalR requested\n"); |
| 4325 | val = rd32(&pf->hw, I40E_GLGEN_RTRIG); | 4420 | val = rd32(&pf->hw, I40E_GLGEN_RTRIG); |
| 4326 | val |= I40E_GLGEN_RTRIG_GLOBR_MASK; | 4421 | val |= I40E_GLGEN_RTRIG_GLOBR_MASK; |
| 4327 | wr32(&pf->hw, I40E_GLGEN_RTRIG, val); | 4422 | wr32(&pf->hw, I40E_GLGEN_RTRIG, val); |
| @@ -4332,7 +4427,7 @@ void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags) | |||
| 4332 | * | 4427 | * |
| 4333 | * Same as Global Reset, except does *not* include the MAC/PHY | 4428 | * Same as Global Reset, except does *not* include the MAC/PHY |
| 4334 | */ | 4429 | */ |
| 4335 | dev_info(&pf->pdev->dev, "CoreR requested\n"); | 4430 | dev_dbg(&pf->pdev->dev, "CoreR requested\n"); |
| 4336 | val = rd32(&pf->hw, I40E_GLGEN_RTRIG); | 4431 | val = rd32(&pf->hw, I40E_GLGEN_RTRIG); |
| 4337 | val |= I40E_GLGEN_RTRIG_CORER_MASK; | 4432 | val |= I40E_GLGEN_RTRIG_CORER_MASK; |
| 4338 | wr32(&pf->hw, I40E_GLGEN_RTRIG, val); | 4433 | wr32(&pf->hw, I40E_GLGEN_RTRIG, val); |
| @@ -4366,7 +4461,7 @@ void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags) | |||
| 4366 | * the switch, since we need to do all the recovery as | 4461 | * the switch, since we need to do all the recovery as |
| 4367 | * for the Core Reset. | 4462 | * for the Core Reset. |
| 4368 | */ | 4463 | */ |
| 4369 | dev_info(&pf->pdev->dev, "PFR requested\n"); | 4464 | dev_dbg(&pf->pdev->dev, "PFR requested\n"); |
| 4370 | i40e_handle_reset_warning(pf); | 4465 | i40e_handle_reset_warning(pf); |
| 4371 | 4466 | ||
| 4372 | } else if (reset_flags & (1 << __I40E_REINIT_REQUESTED)) { | 4467 | } else if (reset_flags & (1 << __I40E_REINIT_REQUESTED)) { |
| @@ -4415,18 +4510,18 @@ bool i40e_dcb_need_reconfig(struct i40e_pf *pf, | |||
| 4415 | &old_cfg->etscfg.prioritytable, | 4510 | &old_cfg->etscfg.prioritytable, |
| 4416 | sizeof(new_cfg->etscfg.prioritytable))) { | 4511 | sizeof(new_cfg->etscfg.prioritytable))) { |
| 4417 | need_reconfig = true; | 4512 | need_reconfig = true; |
| 4418 | dev_info(&pf->pdev->dev, "ETS UP2TC changed.\n"); | 4513 | dev_dbg(&pf->pdev->dev, "ETS UP2TC changed.\n"); |
| 4419 | } | 4514 | } |
| 4420 | 4515 | ||
| 4421 | if (memcmp(&new_cfg->etscfg.tcbwtable, | 4516 | if (memcmp(&new_cfg->etscfg.tcbwtable, |
| 4422 | &old_cfg->etscfg.tcbwtable, | 4517 | &old_cfg->etscfg.tcbwtable, |
| 4423 | sizeof(new_cfg->etscfg.tcbwtable))) | 4518 | sizeof(new_cfg->etscfg.tcbwtable))) |
| 4424 | dev_info(&pf->pdev->dev, "ETS TC BW Table changed.\n"); | 4519 | dev_dbg(&pf->pdev->dev, "ETS TC BW Table changed.\n"); |
| 4425 | 4520 | ||
| 4426 | if (memcmp(&new_cfg->etscfg.tsatable, | 4521 | if (memcmp(&new_cfg->etscfg.tsatable, |
| 4427 | &old_cfg->etscfg.tsatable, | 4522 | &old_cfg->etscfg.tsatable, |
| 4428 | sizeof(new_cfg->etscfg.tsatable))) | 4523 | sizeof(new_cfg->etscfg.tsatable))) |
| 4429 | dev_info(&pf->pdev->dev, "ETS TSA Table changed.\n"); | 4524 | dev_dbg(&pf->pdev->dev, "ETS TSA Table changed.\n"); |
| 4430 | } | 4525 | } |
| 4431 | 4526 | ||
| 4432 | /* Check if PFC configuration has changed */ | 4527 | /* Check if PFC configuration has changed */ |
| @@ -4434,7 +4529,7 @@ bool i40e_dcb_need_reconfig(struct i40e_pf *pf, | |||
| 4434 | &old_cfg->pfc, | 4529 | &old_cfg->pfc, |
| 4435 | sizeof(new_cfg->pfc))) { | 4530 | sizeof(new_cfg->pfc))) { |
| 4436 | need_reconfig = true; | 4531 | need_reconfig = true; |
| 4437 | dev_info(&pf->pdev->dev, "PFC config change detected.\n"); | 4532 | dev_dbg(&pf->pdev->dev, "PFC config change detected.\n"); |
| 4438 | } | 4533 | } |
| 4439 | 4534 | ||
| 4440 | /* Check if APP Table has changed */ | 4535 | /* Check if APP Table has changed */ |
| @@ -4442,7 +4537,7 @@ bool i40e_dcb_need_reconfig(struct i40e_pf *pf, | |||
| 4442 | &old_cfg->app, | 4537 | &old_cfg->app, |
| 4443 | sizeof(new_cfg->app))) { | 4538 | sizeof(new_cfg->app))) { |
| 4444 | need_reconfig = true; | 4539 | need_reconfig = true; |
| 4445 | dev_info(&pf->pdev->dev, "APP Table change detected.\n"); | 4540 | dev_dbg(&pf->pdev->dev, "APP Table change detected.\n"); |
| 4446 | } | 4541 | } |
| 4447 | 4542 | ||
| 4448 | return need_reconfig; | 4543 | return need_reconfig; |
| @@ -4492,7 +4587,7 @@ static int i40e_handle_lldp_event(struct i40e_pf *pf, | |||
| 4492 | 4587 | ||
| 4493 | /* No change detected in DCBX configs */ | 4588 | /* No change detected in DCBX configs */ |
| 4494 | if (!memcmp(&tmp_dcbx_cfg, dcbx_cfg, sizeof(tmp_dcbx_cfg))) { | 4589 | if (!memcmp(&tmp_dcbx_cfg, dcbx_cfg, sizeof(tmp_dcbx_cfg))) { |
| 4495 | dev_info(&pf->pdev->dev, "No change detected in DCBX configuration.\n"); | 4590 | dev_dbg(&pf->pdev->dev, "No change detected in DCBX configuration.\n"); |
| 4496 | goto exit; | 4591 | goto exit; |
| 4497 | } | 4592 | } |
| 4498 | 4593 | ||
| @@ -4550,8 +4645,8 @@ static void i40e_handle_lan_overflow_event(struct i40e_pf *pf, | |||
| 4550 | struct i40e_vf *vf; | 4645 | struct i40e_vf *vf; |
| 4551 | u16 vf_id; | 4646 | u16 vf_id; |
| 4552 | 4647 | ||
| 4553 | dev_info(&pf->pdev->dev, "%s: Rx Queue Number = %d QTX_CTL=0x%08x\n", | 4648 | dev_dbg(&pf->pdev->dev, "overflow Rx Queue Number = %d QTX_CTL=0x%08x\n", |
| 4554 | __func__, queue, qtx_ctl); | 4649 | queue, qtx_ctl); |
| 4555 | 4650 | ||
| 4556 | /* Queue belongs to VF, find the VF and issue VF reset */ | 4651 | /* Queue belongs to VF, find the VF and issue VF reset */ |
| 4557 | if (((qtx_ctl & I40E_QTX_CTL_PFVF_Q_MASK) | 4652 | if (((qtx_ctl & I40E_QTX_CTL_PFVF_Q_MASK) |
| @@ -4581,6 +4676,54 @@ static void i40e_service_event_complete(struct i40e_pf *pf) | |||
| 4581 | } | 4676 | } |
| 4582 | 4677 | ||
| 4583 | /** | 4678 | /** |
| 4679 | * i40e_get_current_fd_count - Get the count of FD filters programmed in the HW | ||
| 4680 | * @pf: board private structure | ||
| 4681 | **/ | ||
| 4682 | int i40e_get_current_fd_count(struct i40e_pf *pf) | ||
| 4683 | { | ||
| 4684 | int val, fcnt_prog; | ||
| 4685 | val = rd32(&pf->hw, I40E_PFQF_FDSTAT); | ||
| 4686 | fcnt_prog = (val & I40E_PFQF_FDSTAT_GUARANT_CNT_MASK) + | ||
| 4687 | ((val & I40E_PFQF_FDSTAT_BEST_CNT_MASK) >> | ||
| 4688 | I40E_PFQF_FDSTAT_BEST_CNT_SHIFT); | ||
| 4689 | return fcnt_prog; | ||
| 4690 | } | ||
| 4691 | |||
| 4692 | /** | ||
| 4693 | * i40e_fdir_check_and_reenable - Function to reenabe FD ATR or SB if disabled | ||
| 4694 | * @pf: board private structure | ||
| 4695 | **/ | ||
| 4696 | void i40e_fdir_check_and_reenable(struct i40e_pf *pf) | ||
| 4697 | { | ||
| 4698 | u32 fcnt_prog, fcnt_avail; | ||
| 4699 | |||
| 4700 | /* Check if, FD SB or ATR was auto disabled and if there is enough room | ||
| 4701 | * to re-enable | ||
| 4702 | */ | ||
| 4703 | if ((pf->flags & I40E_FLAG_FD_ATR_ENABLED) && | ||
| 4704 | (pf->flags & I40E_FLAG_FD_SB_ENABLED)) | ||
| 4705 | return; | ||
| 4706 | fcnt_prog = i40e_get_current_fd_count(pf); | ||
| 4707 | fcnt_avail = pf->hw.fdir_shared_filter_count + | ||
| 4708 | pf->fdir_pf_filter_count; | ||
| 4709 | if (fcnt_prog < (fcnt_avail - I40E_FDIR_BUFFER_HEAD_ROOM)) { | ||
| 4710 | if ((pf->flags & I40E_FLAG_FD_SB_ENABLED) && | ||
| 4711 | (pf->auto_disable_flags & I40E_FLAG_FD_SB_ENABLED)) { | ||
| 4712 | pf->auto_disable_flags &= ~I40E_FLAG_FD_SB_ENABLED; | ||
| 4713 | dev_info(&pf->pdev->dev, "FD Sideband/ntuple is being enabled since we have space in the table now\n"); | ||
| 4714 | } | ||
| 4715 | } | ||
| 4716 | /* Wait for some more space to be available to turn on ATR */ | ||
| 4717 | if (fcnt_prog < (fcnt_avail - I40E_FDIR_BUFFER_HEAD_ROOM * 2)) { | ||
| 4718 | if ((pf->flags & I40E_FLAG_FD_ATR_ENABLED) && | ||
| 4719 | (pf->auto_disable_flags & I40E_FLAG_FD_ATR_ENABLED)) { | ||
| 4720 | pf->auto_disable_flags &= ~I40E_FLAG_FD_ATR_ENABLED; | ||
| 4721 | dev_info(&pf->pdev->dev, "ATR is being enabled since we have space in the table now\n"); | ||
| 4722 | } | ||
| 4723 | } | ||
| 4724 | } | ||
| 4725 | |||
| 4726 | /** | ||
| 4584 | * i40e_fdir_reinit_subtask - Worker thread to reinit FDIR filter table | 4727 | * i40e_fdir_reinit_subtask - Worker thread to reinit FDIR filter table |
| 4585 | * @pf: board private structure | 4728 | * @pf: board private structure |
| 4586 | **/ | 4729 | **/ |
| @@ -4589,11 +4732,14 @@ static void i40e_fdir_reinit_subtask(struct i40e_pf *pf) | |||
| 4589 | if (!(pf->flags & I40E_FLAG_FDIR_REQUIRES_REINIT)) | 4732 | if (!(pf->flags & I40E_FLAG_FDIR_REQUIRES_REINIT)) |
| 4590 | return; | 4733 | return; |
| 4591 | 4734 | ||
| 4592 | pf->flags &= ~I40E_FLAG_FDIR_REQUIRES_REINIT; | ||
| 4593 | |||
| 4594 | /* if interface is down do nothing */ | 4735 | /* if interface is down do nothing */ |
| 4595 | if (test_bit(__I40E_DOWN, &pf->state)) | 4736 | if (test_bit(__I40E_DOWN, &pf->state)) |
| 4596 | return; | 4737 | return; |
| 4738 | i40e_fdir_check_and_reenable(pf); | ||
| 4739 | |||
| 4740 | if ((pf->flags & I40E_FLAG_FD_ATR_ENABLED) && | ||
| 4741 | (pf->flags & I40E_FLAG_FD_SB_ENABLED)) | ||
| 4742 | pf->flags &= ~I40E_FLAG_FDIR_REQUIRES_REINIT; | ||
| 4597 | } | 4743 | } |
| 4598 | 4744 | ||
| 4599 | /** | 4745 | /** |
| @@ -4903,7 +5049,7 @@ static void i40e_clean_adminq_subtask(struct i40e_pf *pf) | |||
| 4903 | event.msg_size); | 5049 | event.msg_size); |
| 4904 | break; | 5050 | break; |
| 4905 | case i40e_aqc_opc_lldp_update_mib: | 5051 | case i40e_aqc_opc_lldp_update_mib: |
| 4906 | dev_info(&pf->pdev->dev, "ARQ: Update LLDP MIB event received\n"); | 5052 | dev_dbg(&pf->pdev->dev, "ARQ: Update LLDP MIB event received\n"); |
| 4907 | #ifdef CONFIG_I40E_DCB | 5053 | #ifdef CONFIG_I40E_DCB |
| 4908 | rtnl_lock(); | 5054 | rtnl_lock(); |
| 4909 | ret = i40e_handle_lldp_event(pf, &event); | 5055 | ret = i40e_handle_lldp_event(pf, &event); |
| @@ -4911,7 +5057,7 @@ static void i40e_clean_adminq_subtask(struct i40e_pf *pf) | |||
| 4911 | #endif /* CONFIG_I40E_DCB */ | 5057 | #endif /* CONFIG_I40E_DCB */ |
| 4912 | break; | 5058 | break; |
| 4913 | case i40e_aqc_opc_event_lan_overflow: | 5059 | case i40e_aqc_opc_event_lan_overflow: |
| 4914 | dev_info(&pf->pdev->dev, "ARQ LAN queue overflow event received\n"); | 5060 | dev_dbg(&pf->pdev->dev, "ARQ LAN queue overflow event received\n"); |
| 4915 | i40e_handle_lan_overflow_event(pf, &event); | 5061 | i40e_handle_lan_overflow_event(pf, &event); |
| 4916 | break; | 5062 | break; |
| 4917 | case i40e_aqc_opc_send_msg_to_peer: | 5063 | case i40e_aqc_opc_send_msg_to_peer: |
| @@ -4936,6 +5082,31 @@ static void i40e_clean_adminq_subtask(struct i40e_pf *pf) | |||
| 4936 | } | 5082 | } |
| 4937 | 5083 | ||
| 4938 | /** | 5084 | /** |
| 5085 | * i40e_verify_eeprom - make sure eeprom is good to use | ||
| 5086 | * @pf: board private structure | ||
| 5087 | **/ | ||
| 5088 | static void i40e_verify_eeprom(struct i40e_pf *pf) | ||
| 5089 | { | ||
| 5090 | int err; | ||
| 5091 | |||
| 5092 | err = i40e_diag_eeprom_test(&pf->hw); | ||
| 5093 | if (err) { | ||
| 5094 | /* retry in case of garbage read */ | ||
| 5095 | err = i40e_diag_eeprom_test(&pf->hw); | ||
| 5096 | if (err) { | ||
| 5097 | dev_info(&pf->pdev->dev, "eeprom check failed (%d), Tx/Rx traffic disabled\n", | ||
| 5098 | err); | ||
| 5099 | set_bit(__I40E_BAD_EEPROM, &pf->state); | ||
| 5100 | } | ||
| 5101 | } | ||
| 5102 | |||
| 5103 | if (!err && test_bit(__I40E_BAD_EEPROM, &pf->state)) { | ||
| 5104 | dev_info(&pf->pdev->dev, "eeprom check passed, Tx/Rx traffic enabled\n"); | ||
| 5105 | clear_bit(__I40E_BAD_EEPROM, &pf->state); | ||
| 5106 | } | ||
| 5107 | } | ||
| 5108 | |||
| 5109 | /** | ||
| 4939 | * i40e_reconstitute_veb - rebuild the VEB and anything connected to it | 5110 | * i40e_reconstitute_veb - rebuild the VEB and anything connected to it |
| 4940 | * @veb: pointer to the VEB instance | 5111 | * @veb: pointer to the VEB instance |
| 4941 | * | 5112 | * |
| @@ -5053,6 +5224,12 @@ static int i40e_get_capabilities(struct i40e_pf *pf) | |||
| 5053 | /* increment MSI-X count because current FW skips one */ | 5224 | /* increment MSI-X count because current FW skips one */ |
| 5054 | pf->hw.func_caps.num_msix_vectors++; | 5225 | pf->hw.func_caps.num_msix_vectors++; |
| 5055 | 5226 | ||
| 5227 | if (((pf->hw.aq.fw_maj_ver == 2) && (pf->hw.aq.fw_min_ver < 22)) || | ||
| 5228 | (pf->hw.aq.fw_maj_ver < 2)) { | ||
| 5229 | pf->hw.func_caps.num_msix_vectors++; | ||
| 5230 | pf->hw.func_caps.num_msix_vectors_vf++; | ||
| 5231 | } | ||
| 5232 | |||
| 5056 | if (pf->hw.debug_mask & I40E_DEBUG_USER) | 5233 | if (pf->hw.debug_mask & I40E_DEBUG_USER) |
| 5057 | dev_info(&pf->pdev->dev, | 5234 | dev_info(&pf->pdev->dev, |
| 5058 | "pf=%d, num_vfs=%d, msix_pf=%d, msix_vf=%d, fd_g=%d, fd_b=%d, pf_max_q=%d num_vsi=%d\n", | 5235 | "pf=%d, num_vfs=%d, msix_pf=%d, msix_vf=%d, fd_g=%d, fd_b=%d, pf_max_q=%d num_vsi=%d\n", |
| @@ -5132,9 +5309,9 @@ static void i40e_fdir_sb_setup(struct i40e_pf *pf) | |||
| 5132 | err = i40e_up_complete(vsi); | 5309 | err = i40e_up_complete(vsi); |
| 5133 | if (err) | 5310 | if (err) |
| 5134 | goto err_up_complete; | 5311 | goto err_up_complete; |
| 5312 | clear_bit(__I40E_NEEDS_RESTART, &vsi->state); | ||
| 5135 | } | 5313 | } |
| 5136 | 5314 | ||
| 5137 | clear_bit(__I40E_NEEDS_RESTART, &vsi->state); | ||
| 5138 | return; | 5315 | return; |
| 5139 | 5316 | ||
| 5140 | err_up_complete: | 5317 | err_up_complete: |
| @@ -5157,6 +5334,7 @@ static void i40e_fdir_teardown(struct i40e_pf *pf) | |||
| 5157 | { | 5334 | { |
| 5158 | int i; | 5335 | int i; |
| 5159 | 5336 | ||
| 5337 | i40e_fdir_filter_exit(pf); | ||
| 5160 | for (i = 0; i < pf->hw.func_caps.num_vsis; i++) { | 5338 | for (i = 0; i < pf->hw.func_caps.num_vsis; i++) { |
| 5161 | if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) { | 5339 | if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) { |
| 5162 | i40e_vsi_release(pf->vsi[i]); | 5340 | i40e_vsi_release(pf->vsi[i]); |
| @@ -5181,7 +5359,7 @@ static int i40e_prep_for_reset(struct i40e_pf *pf) | |||
| 5181 | if (test_and_set_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state)) | 5359 | if (test_and_set_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state)) |
| 5182 | return 0; | 5360 | return 0; |
| 5183 | 5361 | ||
| 5184 | dev_info(&pf->pdev->dev, "Tearing down internal switch for reset\n"); | 5362 | dev_dbg(&pf->pdev->dev, "Tearing down internal switch for reset\n"); |
| 5185 | 5363 | ||
| 5186 | if (i40e_check_asq_alive(hw)) | 5364 | if (i40e_check_asq_alive(hw)) |
| 5187 | i40e_vc_notify_reset(pf); | 5365 | i40e_vc_notify_reset(pf); |
| @@ -5228,7 +5406,7 @@ static void i40e_reset_and_rebuild(struct i40e_pf *pf, bool reinit) | |||
| 5228 | 5406 | ||
| 5229 | if (test_bit(__I40E_DOWN, &pf->state)) | 5407 | if (test_bit(__I40E_DOWN, &pf->state)) |
| 5230 | goto end_core_reset; | 5408 | goto end_core_reset; |
| 5231 | dev_info(&pf->pdev->dev, "Rebuilding internal switch\n"); | 5409 | dev_dbg(&pf->pdev->dev, "Rebuilding internal switch\n"); |
| 5232 | 5410 | ||
| 5233 | /* rebuild the basics for the AdminQ, HMC, and initial HW switch */ | 5411 | /* rebuild the basics for the AdminQ, HMC, and initial HW switch */ |
| 5234 | ret = i40e_init_adminq(&pf->hw); | 5412 | ret = i40e_init_adminq(&pf->hw); |
| @@ -5237,6 +5415,12 @@ static void i40e_reset_and_rebuild(struct i40e_pf *pf, bool reinit) | |||
| 5237 | goto end_core_reset; | 5415 | goto end_core_reset; |
| 5238 | } | 5416 | } |
| 5239 | 5417 | ||
| 5418 | /* re-verify the eeprom if we just had an EMP reset */ | ||
| 5419 | if (test_bit(__I40E_EMP_RESET_REQUESTED, &pf->state)) { | ||
| 5420 | clear_bit(__I40E_EMP_RESET_REQUESTED, &pf->state); | ||
| 5421 | i40e_verify_eeprom(pf); | ||
| 5422 | } | ||
| 5423 | |||
| 5240 | ret = i40e_get_capabilities(pf); | 5424 | ret = i40e_get_capabilities(pf); |
| 5241 | if (ret) { | 5425 | if (ret) { |
| 5242 | dev_info(&pf->pdev->dev, "i40e_get_capabilities failed, %d\n", | 5426 | dev_info(&pf->pdev->dev, "i40e_get_capabilities failed, %d\n", |
| @@ -5278,7 +5462,7 @@ static void i40e_reset_and_rebuild(struct i40e_pf *pf, bool reinit) | |||
| 5278 | * try to recover minimal use by getting the basic PF VSI working. | 5462 | * try to recover minimal use by getting the basic PF VSI working. |
| 5279 | */ | 5463 | */ |
| 5280 | if (pf->vsi[pf->lan_vsi]->uplink_seid != pf->mac_seid) { | 5464 | if (pf->vsi[pf->lan_vsi]->uplink_seid != pf->mac_seid) { |
| 5281 | dev_info(&pf->pdev->dev, "attempting to rebuild switch\n"); | 5465 | dev_dbg(&pf->pdev->dev, "attempting to rebuild switch\n"); |
| 5282 | /* find the one VEB connected to the MAC, and find orphans */ | 5466 | /* find the one VEB connected to the MAC, and find orphans */ |
| 5283 | for (v = 0; v < I40E_MAX_VEB; v++) { | 5467 | for (v = 0; v < I40E_MAX_VEB; v++) { |
| 5284 | if (!pf->veb[v]) | 5468 | if (!pf->veb[v]) |
| @@ -5331,6 +5515,11 @@ static void i40e_reset_and_rebuild(struct i40e_pf *pf, bool reinit) | |||
| 5331 | /* restart the VSIs that were rebuilt and running before the reset */ | 5515 | /* restart the VSIs that were rebuilt and running before the reset */ |
| 5332 | i40e_pf_unquiesce_all_vsi(pf); | 5516 | i40e_pf_unquiesce_all_vsi(pf); |
| 5333 | 5517 | ||
| 5518 | if (pf->num_alloc_vfs) { | ||
| 5519 | for (v = 0; v < pf->num_alloc_vfs; v++) | ||
| 5520 | i40e_reset_vf(&pf->vf[v], true); | ||
| 5521 | } | ||
| 5522 | |||
| 5334 | /* tell the firmware that we're starting */ | 5523 | /* tell the firmware that we're starting */ |
| 5335 | dv.major_version = DRV_VERSION_MAJOR; | 5524 | dv.major_version = DRV_VERSION_MAJOR; |
| 5336 | dv.minor_version = DRV_VERSION_MINOR; | 5525 | dv.minor_version = DRV_VERSION_MINOR; |
| @@ -5338,7 +5527,7 @@ static void i40e_reset_and_rebuild(struct i40e_pf *pf, bool reinit) | |||
| 5338 | dv.subbuild_version = 0; | 5527 | dv.subbuild_version = 0; |
| 5339 | i40e_aq_send_driver_version(&pf->hw, &dv, NULL); | 5528 | i40e_aq_send_driver_version(&pf->hw, &dv, NULL); |
| 5340 | 5529 | ||
| 5341 | dev_info(&pf->pdev->dev, "PF reset done\n"); | 5530 | dev_info(&pf->pdev->dev, "reset complete\n"); |
| 5342 | 5531 | ||
| 5343 | end_core_reset: | 5532 | end_core_reset: |
| 5344 | clear_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state); | 5533 | clear_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state); |
| @@ -5387,7 +5576,7 @@ static void i40e_handle_mdd_event(struct i40e_pf *pf) | |||
| 5387 | u8 queue = (reg & I40E_GL_MDET_TX_QUEUE_MASK) | 5576 | u8 queue = (reg & I40E_GL_MDET_TX_QUEUE_MASK) |
| 5388 | >> I40E_GL_MDET_TX_QUEUE_SHIFT; | 5577 | >> I40E_GL_MDET_TX_QUEUE_SHIFT; |
| 5389 | dev_info(&pf->pdev->dev, | 5578 | dev_info(&pf->pdev->dev, |
| 5390 | "Malicious Driver Detection TX event 0x%02x on q %d of function 0x%02x\n", | 5579 | "Malicious Driver Detection event 0x%02x on TX queue %d of function 0x%02x\n", |
| 5391 | event, queue, func); | 5580 | event, queue, func); |
| 5392 | wr32(hw, I40E_GL_MDET_TX, 0xffffffff); | 5581 | wr32(hw, I40E_GL_MDET_TX, 0xffffffff); |
| 5393 | mdd_detected = true; | 5582 | mdd_detected = true; |
| @@ -5401,7 +5590,7 @@ static void i40e_handle_mdd_event(struct i40e_pf *pf) | |||
| 5401 | u8 queue = (reg & I40E_GL_MDET_RX_QUEUE_MASK) | 5590 | u8 queue = (reg & I40E_GL_MDET_RX_QUEUE_MASK) |
| 5402 | >> I40E_GL_MDET_RX_QUEUE_SHIFT; | 5591 | >> I40E_GL_MDET_RX_QUEUE_SHIFT; |
| 5403 | dev_info(&pf->pdev->dev, | 5592 | dev_info(&pf->pdev->dev, |
| 5404 | "Malicious Driver Detection RX event 0x%02x on q %d of function 0x%02x\n", | 5593 | "Malicious Driver Detection event 0x%02x on RX queue %d of function 0x%02x\n", |
| 5405 | event, queue, func); | 5594 | event, queue, func); |
| 5406 | wr32(hw, I40E_GL_MDET_RX, 0xffffffff); | 5595 | wr32(hw, I40E_GL_MDET_RX, 0xffffffff); |
| 5407 | mdd_detected = true; | 5596 | mdd_detected = true; |
| @@ -5850,37 +6039,16 @@ err_out: | |||
| 5850 | **/ | 6039 | **/ |
| 5851 | static int i40e_reserve_msix_vectors(struct i40e_pf *pf, int vectors) | 6040 | static int i40e_reserve_msix_vectors(struct i40e_pf *pf, int vectors) |
| 5852 | { | 6041 | { |
| 5853 | int err = 0; | 6042 | vectors = pci_enable_msix_range(pf->pdev, pf->msix_entries, |
| 5854 | 6043 | I40E_MIN_MSIX, vectors); | |
| 5855 | pf->num_msix_entries = 0; | 6044 | if (vectors < 0) { |
| 5856 | while (vectors >= I40E_MIN_MSIX) { | ||
| 5857 | err = pci_enable_msix(pf->pdev, pf->msix_entries, vectors); | ||
| 5858 | if (err == 0) { | ||
| 5859 | /* good to go */ | ||
| 5860 | pf->num_msix_entries = vectors; | ||
| 5861 | break; | ||
| 5862 | } else if (err < 0) { | ||
| 5863 | /* total failure */ | ||
| 5864 | dev_info(&pf->pdev->dev, | ||
| 5865 | "MSI-X vector reservation failed: %d\n", err); | ||
| 5866 | vectors = 0; | ||
| 5867 | break; | ||
| 5868 | } else { | ||
| 5869 | /* err > 0 is the hint for retry */ | ||
| 5870 | dev_info(&pf->pdev->dev, | ||
| 5871 | "MSI-X vectors wanted %d, retrying with %d\n", | ||
| 5872 | vectors, err); | ||
| 5873 | vectors = err; | ||
| 5874 | } | ||
| 5875 | } | ||
| 5876 | |||
| 5877 | if (vectors > 0 && vectors < I40E_MIN_MSIX) { | ||
| 5878 | dev_info(&pf->pdev->dev, | 6045 | dev_info(&pf->pdev->dev, |
| 5879 | "Couldn't get enough vectors, only %d available\n", | 6046 | "MSI-X vector reservation failed: %d\n", vectors); |
| 5880 | vectors); | ||
| 5881 | vectors = 0; | 6047 | vectors = 0; |
| 5882 | } | 6048 | } |
| 5883 | 6049 | ||
| 6050 | pf->num_msix_entries = vectors; | ||
| 6051 | |||
| 5884 | return vectors; | 6052 | return vectors; |
| 5885 | } | 6053 | } |
| 5886 | 6054 | ||
| @@ -5942,7 +6110,7 @@ static int i40e_init_msix(struct i40e_pf *pf) | |||
| 5942 | 6110 | ||
| 5943 | } else if (vec == I40E_MIN_MSIX) { | 6111 | } else if (vec == I40E_MIN_MSIX) { |
| 5944 | /* Adjust for minimal MSIX use */ | 6112 | /* Adjust for minimal MSIX use */ |
| 5945 | dev_info(&pf->pdev->dev, "Features disabled, not enough MSIX vectors\n"); | 6113 | dev_info(&pf->pdev->dev, "Features disabled, not enough MSI-X vectors\n"); |
| 5946 | pf->flags &= ~I40E_FLAG_VMDQ_ENABLED; | 6114 | pf->flags &= ~I40E_FLAG_VMDQ_ENABLED; |
| 5947 | pf->num_vmdq_vsis = 0; | 6115 | pf->num_vmdq_vsis = 0; |
| 5948 | pf->num_vmdq_qps = 0; | 6116 | pf->num_vmdq_qps = 0; |
| @@ -5978,13 +6146,13 @@ static int i40e_init_msix(struct i40e_pf *pf) | |||
| 5978 | } | 6146 | } |
| 5979 | 6147 | ||
| 5980 | /** | 6148 | /** |
| 5981 | * i40e_alloc_q_vector - Allocate memory for a single interrupt vector | 6149 | * i40e_vsi_alloc_q_vector - Allocate memory for a single interrupt vector |
| 5982 | * @vsi: the VSI being configured | 6150 | * @vsi: the VSI being configured |
| 5983 | * @v_idx: index of the vector in the vsi struct | 6151 | * @v_idx: index of the vector in the vsi struct |
| 5984 | * | 6152 | * |
| 5985 | * We allocate one q_vector. If allocation fails we return -ENOMEM. | 6153 | * We allocate one q_vector. If allocation fails we return -ENOMEM. |
| 5986 | **/ | 6154 | **/ |
| 5987 | static int i40e_alloc_q_vector(struct i40e_vsi *vsi, int v_idx) | 6155 | static int i40e_vsi_alloc_q_vector(struct i40e_vsi *vsi, int v_idx) |
| 5988 | { | 6156 | { |
| 5989 | struct i40e_q_vector *q_vector; | 6157 | struct i40e_q_vector *q_vector; |
| 5990 | 6158 | ||
| @@ -6010,13 +6178,13 @@ static int i40e_alloc_q_vector(struct i40e_vsi *vsi, int v_idx) | |||
| 6010 | } | 6178 | } |
| 6011 | 6179 | ||
| 6012 | /** | 6180 | /** |
| 6013 | * i40e_alloc_q_vectors - Allocate memory for interrupt vectors | 6181 | * i40e_vsi_alloc_q_vectors - Allocate memory for interrupt vectors |
| 6014 | * @vsi: the VSI being configured | 6182 | * @vsi: the VSI being configured |
| 6015 | * | 6183 | * |
| 6016 | * We allocate one q_vector per queue interrupt. If allocation fails we | 6184 | * We allocate one q_vector per queue interrupt. If allocation fails we |
| 6017 | * return -ENOMEM. | 6185 | * return -ENOMEM. |
| 6018 | **/ | 6186 | **/ |
| 6019 | static int i40e_alloc_q_vectors(struct i40e_vsi *vsi) | 6187 | static int i40e_vsi_alloc_q_vectors(struct i40e_vsi *vsi) |
| 6020 | { | 6188 | { |
| 6021 | struct i40e_pf *pf = vsi->back; | 6189 | struct i40e_pf *pf = vsi->back; |
| 6022 | int v_idx, num_q_vectors; | 6190 | int v_idx, num_q_vectors; |
| @@ -6031,7 +6199,7 @@ static int i40e_alloc_q_vectors(struct i40e_vsi *vsi) | |||
| 6031 | return -EINVAL; | 6199 | return -EINVAL; |
| 6032 | 6200 | ||
| 6033 | for (v_idx = 0; v_idx < num_q_vectors; v_idx++) { | 6201 | for (v_idx = 0; v_idx < num_q_vectors; v_idx++) { |
| 6034 | err = i40e_alloc_q_vector(vsi, v_idx); | 6202 | err = i40e_vsi_alloc_q_vector(vsi, v_idx); |
| 6035 | if (err) | 6203 | if (err) |
| 6036 | goto err_out; | 6204 | goto err_out; |
| 6037 | } | 6205 | } |
| @@ -6071,7 +6239,7 @@ static void i40e_init_interrupt_scheme(struct i40e_pf *pf) | |||
| 6071 | 6239 | ||
| 6072 | if (!(pf->flags & I40E_FLAG_MSIX_ENABLED) && | 6240 | if (!(pf->flags & I40E_FLAG_MSIX_ENABLED) && |
| 6073 | (pf->flags & I40E_FLAG_MSI_ENABLED)) { | 6241 | (pf->flags & I40E_FLAG_MSI_ENABLED)) { |
| 6074 | dev_info(&pf->pdev->dev, "MSIX not available, trying MSI\n"); | 6242 | dev_info(&pf->pdev->dev, "MSI-X not available, trying MSI\n"); |
| 6075 | err = pci_enable_msi(pf->pdev); | 6243 | err = pci_enable_msi(pf->pdev); |
| 6076 | if (err) { | 6244 | if (err) { |
| 6077 | dev_info(&pf->pdev->dev, "MSI init failed - %d\n", err); | 6245 | dev_info(&pf->pdev->dev, "MSI init failed - %d\n", err); |
| @@ -6080,7 +6248,7 @@ static void i40e_init_interrupt_scheme(struct i40e_pf *pf) | |||
| 6080 | } | 6248 | } |
| 6081 | 6249 | ||
| 6082 | if (!(pf->flags & (I40E_FLAG_MSIX_ENABLED | I40E_FLAG_MSI_ENABLED))) | 6250 | if (!(pf->flags & (I40E_FLAG_MSIX_ENABLED | I40E_FLAG_MSI_ENABLED))) |
| 6083 | dev_info(&pf->pdev->dev, "MSIX and MSI not available, falling back to Legacy IRQ\n"); | 6251 | dev_info(&pf->pdev->dev, "MSI-X and MSI not available, falling back to Legacy IRQ\n"); |
| 6084 | 6252 | ||
| 6085 | /* track first vector for misc interrupts */ | 6253 | /* track first vector for misc interrupts */ |
| 6086 | err = i40e_get_lump(pf, pf->irq_pile, 1, I40E_PILE_VALID_BIT-1); | 6254 | err = i40e_get_lump(pf, pf->irq_pile, 1, I40E_PILE_VALID_BIT-1); |
| @@ -6107,7 +6275,8 @@ static int i40e_setup_misc_vector(struct i40e_pf *pf) | |||
| 6107 | i40e_intr, 0, pf->misc_int_name, pf); | 6275 | i40e_intr, 0, pf->misc_int_name, pf); |
| 6108 | if (err) { | 6276 | if (err) { |
| 6109 | dev_info(&pf->pdev->dev, | 6277 | dev_info(&pf->pdev->dev, |
| 6110 | "request_irq for msix_misc failed: %d\n", err); | 6278 | "request_irq for %s failed: %d\n", |
| 6279 | pf->misc_int_name, err); | ||
| 6111 | return -EFAULT; | 6280 | return -EFAULT; |
| 6112 | } | 6281 | } |
| 6113 | } | 6282 | } |
| @@ -6258,15 +6427,11 @@ static int i40e_sw_init(struct i40e_pf *pf) | |||
| 6258 | (pf->hw.func_caps.fd_filters_best_effort > 0)) { | 6427 | (pf->hw.func_caps.fd_filters_best_effort > 0)) { |
| 6259 | pf->flags |= I40E_FLAG_FD_ATR_ENABLED; | 6428 | pf->flags |= I40E_FLAG_FD_ATR_ENABLED; |
| 6260 | pf->atr_sample_rate = I40E_DEFAULT_ATR_SAMPLE_RATE; | 6429 | pf->atr_sample_rate = I40E_DEFAULT_ATR_SAMPLE_RATE; |
| 6261 | dev_info(&pf->pdev->dev, | ||
| 6262 | "Flow Director ATR mode Enabled\n"); | ||
| 6263 | if (!(pf->flags & I40E_FLAG_MFP_ENABLED)) { | 6430 | if (!(pf->flags & I40E_FLAG_MFP_ENABLED)) { |
| 6264 | pf->flags |= I40E_FLAG_FD_SB_ENABLED; | 6431 | pf->flags |= I40E_FLAG_FD_SB_ENABLED; |
| 6265 | dev_info(&pf->pdev->dev, | ||
| 6266 | "Flow Director Side Band mode Enabled\n"); | ||
| 6267 | } else { | 6432 | } else { |
| 6268 | dev_info(&pf->pdev->dev, | 6433 | dev_info(&pf->pdev->dev, |
| 6269 | "Flow Director Side Band mode Disabled in MFP mode\n"); | 6434 | "Flow Director Sideband mode Disabled in MFP mode\n"); |
| 6270 | } | 6435 | } |
| 6271 | pf->fdir_pf_filter_count = | 6436 | pf->fdir_pf_filter_count = |
| 6272 | pf->hw.func_caps.fd_filters_guaranteed; | 6437 | pf->hw.func_caps.fd_filters_guaranteed; |
| @@ -6287,9 +6452,6 @@ static int i40e_sw_init(struct i40e_pf *pf) | |||
| 6287 | pf->num_req_vfs = min_t(int, | 6452 | pf->num_req_vfs = min_t(int, |
| 6288 | pf->hw.func_caps.num_vfs, | 6453 | pf->hw.func_caps.num_vfs, |
| 6289 | I40E_MAX_VF_COUNT); | 6454 | I40E_MAX_VF_COUNT); |
| 6290 | dev_info(&pf->pdev->dev, | ||
| 6291 | "Number of VFs being requested for PF[%d] = %d\n", | ||
| 6292 | pf->hw.pf_id, pf->num_req_vfs); | ||
| 6293 | } | 6455 | } |
| 6294 | #endif /* CONFIG_PCI_IOV */ | 6456 | #endif /* CONFIG_PCI_IOV */ |
| 6295 | pf->eeprom_version = 0xDEAD; | 6457 | pf->eeprom_version = 0xDEAD; |
| @@ -6326,6 +6488,39 @@ sw_init_done: | |||
| 6326 | } | 6488 | } |
| 6327 | 6489 | ||
| 6328 | /** | 6490 | /** |
| 6491 | * i40e_set_ntuple - set the ntuple feature flag and take action | ||
| 6492 | * @pf: board private structure to initialize | ||
| 6493 | * @features: the feature set that the stack is suggesting | ||
| 6494 | * | ||
| 6495 | * returns a bool to indicate if reset needs to happen | ||
| 6496 | **/ | ||
| 6497 | bool i40e_set_ntuple(struct i40e_pf *pf, netdev_features_t features) | ||
| 6498 | { | ||
| 6499 | bool need_reset = false; | ||
| 6500 | |||
| 6501 | /* Check if Flow Director n-tuple support was enabled or disabled. If | ||
| 6502 | * the state changed, we need to reset. | ||
| 6503 | */ | ||
| 6504 | if (features & NETIF_F_NTUPLE) { | ||
| 6505 | /* Enable filters and mark for reset */ | ||
| 6506 | if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED)) | ||
| 6507 | need_reset = true; | ||
| 6508 | pf->flags |= I40E_FLAG_FD_SB_ENABLED; | ||
| 6509 | } else { | ||
| 6510 | /* turn off filters, mark for reset and clear SW filter list */ | ||
| 6511 | if (pf->flags & I40E_FLAG_FD_SB_ENABLED) { | ||
| 6512 | need_reset = true; | ||
| 6513 | i40e_fdir_filter_exit(pf); | ||
| 6514 | } | ||
| 6515 | pf->flags &= ~I40E_FLAG_FD_SB_ENABLED; | ||
| 6516 | /* if ATR was disabled it can be re-enabled. */ | ||
| 6517 | if (!(pf->flags & I40E_FLAG_FD_ATR_ENABLED)) | ||
| 6518 | pf->flags |= I40E_FLAG_FD_ATR_ENABLED; | ||
| 6519 | } | ||
| 6520 | return need_reset; | ||
| 6521 | } | ||
| 6522 | |||
| 6523 | /** | ||
| 6329 | * i40e_set_features - set the netdev feature flags | 6524 | * i40e_set_features - set the netdev feature flags |
| 6330 | * @netdev: ptr to the netdev being adjusted | 6525 | * @netdev: ptr to the netdev being adjusted |
| 6331 | * @features: the feature set that the stack is suggesting | 6526 | * @features: the feature set that the stack is suggesting |
| @@ -6335,12 +6530,19 @@ static int i40e_set_features(struct net_device *netdev, | |||
| 6335 | { | 6530 | { |
| 6336 | struct i40e_netdev_priv *np = netdev_priv(netdev); | 6531 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 6337 | struct i40e_vsi *vsi = np->vsi; | 6532 | struct i40e_vsi *vsi = np->vsi; |
| 6533 | struct i40e_pf *pf = vsi->back; | ||
| 6534 | bool need_reset; | ||
| 6338 | 6535 | ||
| 6339 | if (features & NETIF_F_HW_VLAN_CTAG_RX) | 6536 | if (features & NETIF_F_HW_VLAN_CTAG_RX) |
| 6340 | i40e_vlan_stripping_enable(vsi); | 6537 | i40e_vlan_stripping_enable(vsi); |
| 6341 | else | 6538 | else |
| 6342 | i40e_vlan_stripping_disable(vsi); | 6539 | i40e_vlan_stripping_disable(vsi); |
| 6343 | 6540 | ||
| 6541 | need_reset = i40e_set_ntuple(pf, features); | ||
| 6542 | |||
| 6543 | if (need_reset) | ||
| 6544 | i40e_do_reset(pf, (1 << __I40E_PF_RESET_REQUESTED)); | ||
| 6545 | |||
| 6344 | return 0; | 6546 | return 0; |
| 6345 | } | 6547 | } |
| 6346 | 6548 | ||
| @@ -6464,6 +6666,7 @@ static const struct net_device_ops i40e_netdev_ops = { | |||
| 6464 | .ndo_set_vf_vlan = i40e_ndo_set_vf_port_vlan, | 6666 | .ndo_set_vf_vlan = i40e_ndo_set_vf_port_vlan, |
| 6465 | .ndo_set_vf_tx_rate = i40e_ndo_set_vf_bw, | 6667 | .ndo_set_vf_tx_rate = i40e_ndo_set_vf_bw, |
| 6466 | .ndo_get_vf_config = i40e_ndo_get_vf_config, | 6668 | .ndo_get_vf_config = i40e_ndo_get_vf_config, |
| 6669 | .ndo_set_vf_link_state = i40e_ndo_set_vf_link_state, | ||
| 6467 | #ifdef CONFIG_I40E_VXLAN | 6670 | #ifdef CONFIG_I40E_VXLAN |
| 6468 | .ndo_add_vxlan_port = i40e_add_vxlan_port, | 6671 | .ndo_add_vxlan_port = i40e_add_vxlan_port, |
| 6469 | .ndo_del_vxlan_port = i40e_del_vxlan_port, | 6672 | .ndo_del_vxlan_port = i40e_del_vxlan_port, |
| @@ -6495,10 +6698,9 @@ static int i40e_config_netdev(struct i40e_vsi *vsi) | |||
| 6495 | np = netdev_priv(netdev); | 6698 | np = netdev_priv(netdev); |
| 6496 | np->vsi = vsi; | 6699 | np->vsi = vsi; |
| 6497 | 6700 | ||
| 6498 | netdev->hw_enc_features = NETIF_F_IP_CSUM | | 6701 | netdev->hw_enc_features |= NETIF_F_IP_CSUM | |
| 6499 | NETIF_F_GSO_UDP_TUNNEL | | 6702 | NETIF_F_GSO_UDP_TUNNEL | |
| 6500 | NETIF_F_TSO | | 6703 | NETIF_F_TSO; |
| 6501 | NETIF_F_SG; | ||
| 6502 | 6704 | ||
| 6503 | netdev->features = NETIF_F_SG | | 6705 | netdev->features = NETIF_F_SG | |
| 6504 | NETIF_F_IP_CSUM | | 6706 | NETIF_F_IP_CSUM | |
| @@ -6512,6 +6714,7 @@ static int i40e_config_netdev(struct i40e_vsi *vsi) | |||
| 6512 | NETIF_F_TSO | | 6714 | NETIF_F_TSO | |
| 6513 | NETIF_F_TSO6 | | 6715 | NETIF_F_TSO6 | |
| 6514 | NETIF_F_RXCSUM | | 6716 | NETIF_F_RXCSUM | |
| 6717 | NETIF_F_NTUPLE | | ||
| 6515 | NETIF_F_RXHASH | | 6718 | NETIF_F_RXHASH | |
| 6516 | 0; | 6719 | 0; |
| 6517 | 6720 | ||
| @@ -6771,8 +6974,6 @@ int i40e_vsi_release(struct i40e_vsi *vsi) | |||
| 6771 | if (vsi->netdev) { | 6974 | if (vsi->netdev) { |
| 6772 | /* results in a call to i40e_close() */ | 6975 | /* results in a call to i40e_close() */ |
| 6773 | unregister_netdev(vsi->netdev); | 6976 | unregister_netdev(vsi->netdev); |
| 6774 | free_netdev(vsi->netdev); | ||
| 6775 | vsi->netdev = NULL; | ||
| 6776 | } | 6977 | } |
| 6777 | } else { | 6978 | } else { |
| 6778 | if (!test_and_set_bit(__I40E_DOWN, &vsi->state)) | 6979 | if (!test_and_set_bit(__I40E_DOWN, &vsi->state)) |
| @@ -6791,6 +6992,10 @@ int i40e_vsi_release(struct i40e_vsi *vsi) | |||
| 6791 | 6992 | ||
| 6792 | i40e_vsi_delete(vsi); | 6993 | i40e_vsi_delete(vsi); |
| 6793 | i40e_vsi_free_q_vectors(vsi); | 6994 | i40e_vsi_free_q_vectors(vsi); |
| 6995 | if (vsi->netdev) { | ||
| 6996 | free_netdev(vsi->netdev); | ||
| 6997 | vsi->netdev = NULL; | ||
| 6998 | } | ||
| 6794 | i40e_vsi_clear_rings(vsi); | 6999 | i40e_vsi_clear_rings(vsi); |
| 6795 | i40e_vsi_clear(vsi); | 7000 | i40e_vsi_clear(vsi); |
| 6796 | 7001 | ||
| @@ -6845,13 +7050,12 @@ static int i40e_vsi_setup_vectors(struct i40e_vsi *vsi) | |||
| 6845 | } | 7050 | } |
| 6846 | 7051 | ||
| 6847 | if (vsi->base_vector) { | 7052 | if (vsi->base_vector) { |
| 6848 | dev_info(&pf->pdev->dev, | 7053 | dev_info(&pf->pdev->dev, "VSI %d has non-zero base vector %d\n", |
| 6849 | "VSI %d has non-zero base vector %d\n", | ||
| 6850 | vsi->seid, vsi->base_vector); | 7054 | vsi->seid, vsi->base_vector); |
| 6851 | return -EEXIST; | 7055 | return -EEXIST; |
| 6852 | } | 7056 | } |
| 6853 | 7057 | ||
| 6854 | ret = i40e_alloc_q_vectors(vsi); | 7058 | ret = i40e_vsi_alloc_q_vectors(vsi); |
| 6855 | if (ret) { | 7059 | if (ret) { |
| 6856 | dev_info(&pf->pdev->dev, | 7060 | dev_info(&pf->pdev->dev, |
| 6857 | "failed to allocate %d q_vector for VSI %d, ret=%d\n", | 7061 | "failed to allocate %d q_vector for VSI %d, ret=%d\n", |
| @@ -6865,7 +7069,7 @@ static int i40e_vsi_setup_vectors(struct i40e_vsi *vsi) | |||
| 6865 | vsi->num_q_vectors, vsi->idx); | 7069 | vsi->num_q_vectors, vsi->idx); |
| 6866 | if (vsi->base_vector < 0) { | 7070 | if (vsi->base_vector < 0) { |
| 6867 | dev_info(&pf->pdev->dev, | 7071 | dev_info(&pf->pdev->dev, |
| 6868 | "failed to get q tracking for VSI %d, err=%d\n", | 7072 | "failed to get queue tracking for VSI %d, err=%d\n", |
| 6869 | vsi->seid, vsi->base_vector); | 7073 | vsi->seid, vsi->base_vector); |
| 6870 | i40e_vsi_free_q_vectors(vsi); | 7074 | i40e_vsi_free_q_vectors(vsi); |
| 6871 | ret = -ENOENT; | 7075 | ret = -ENOENT; |
| @@ -7822,6 +8026,44 @@ static int i40e_setup_pf_filter_control(struct i40e_pf *pf) | |||
| 7822 | return 0; | 8026 | return 0; |
| 7823 | } | 8027 | } |
| 7824 | 8028 | ||
| 8029 | #define INFO_STRING_LEN 255 | ||
| 8030 | static void i40e_print_features(struct i40e_pf *pf) | ||
| 8031 | { | ||
| 8032 | struct i40e_hw *hw = &pf->hw; | ||
| 8033 | char *buf, *string; | ||
| 8034 | |||
| 8035 | string = kzalloc(INFO_STRING_LEN, GFP_KERNEL); | ||
| 8036 | if (!string) { | ||
| 8037 | dev_err(&pf->pdev->dev, "Features string allocation failed\n"); | ||
| 8038 | return; | ||
| 8039 | } | ||
| 8040 | |||
| 8041 | buf = string; | ||
| 8042 | |||
| 8043 | buf += sprintf(string, "Features: PF-id[%d] ", hw->pf_id); | ||
| 8044 | #ifdef CONFIG_PCI_IOV | ||
| 8045 | buf += sprintf(buf, "VFs: %d ", pf->num_req_vfs); | ||
| 8046 | #endif | ||
| 8047 | buf += sprintf(buf, "VSIs: %d QP: %d ", pf->hw.func_caps.num_vsis, | ||
| 8048 | pf->vsi[pf->lan_vsi]->num_queue_pairs); | ||
| 8049 | |||
| 8050 | if (pf->flags & I40E_FLAG_RSS_ENABLED) | ||
| 8051 | buf += sprintf(buf, "RSS "); | ||
| 8052 | buf += sprintf(buf, "FDir "); | ||
| 8053 | if (pf->flags & I40E_FLAG_FD_ATR_ENABLED) | ||
| 8054 | buf += sprintf(buf, "ATR "); | ||
| 8055 | if (pf->flags & I40E_FLAG_FD_SB_ENABLED) | ||
| 8056 | buf += sprintf(buf, "NTUPLE "); | ||
| 8057 | if (pf->flags & I40E_FLAG_DCB_ENABLED) | ||
| 8058 | buf += sprintf(buf, "DCB "); | ||
| 8059 | if (pf->flags & I40E_FLAG_PTP) | ||
| 8060 | buf += sprintf(buf, "PTP "); | ||
| 8061 | |||
| 8062 | BUG_ON(buf > (string + INFO_STRING_LEN)); | ||
| 8063 | dev_info(&pf->pdev->dev, "%s\n", string); | ||
| 8064 | kfree(string); | ||
| 8065 | } | ||
| 8066 | |||
| 7825 | /** | 8067 | /** |
| 7826 | * i40e_probe - Device initialization routine | 8068 | * i40e_probe - Device initialization routine |
| 7827 | * @pdev: PCI device information struct | 8069 | * @pdev: PCI device information struct |
| @@ -7848,17 +8090,14 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 7848 | return err; | 8090 | return err; |
| 7849 | 8091 | ||
| 7850 | /* set up for high or low dma */ | 8092 | /* set up for high or low dma */ |
| 7851 | if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) { | 8093 | err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); |
| 7852 | /* coherent mask for the same size will always succeed if | 8094 | if (err) { |
| 7853 | * dma_set_mask does | 8095 | err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); |
| 7854 | */ | 8096 | if (err) { |
| 7855 | dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64)); | 8097 | dev_err(&pdev->dev, |
| 7856 | } else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) { | 8098 | "DMA configuration failed: 0x%x\n", err); |
| 7857 | dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); | 8099 | goto err_dma; |
| 7858 | } else { | 8100 | } |
| 7859 | dev_err(&pdev->dev, "DMA configuration failed: %d\n", err); | ||
| 7860 | err = -EIO; | ||
| 7861 | goto err_dma; | ||
| 7862 | } | 8101 | } |
| 7863 | 8102 | ||
| 7864 | /* set up pci connections */ | 8103 | /* set up pci connections */ |
| @@ -7946,13 +8185,6 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 7946 | 8185 | ||
| 7947 | err = i40e_init_adminq(hw); | 8186 | err = i40e_init_adminq(hw); |
| 7948 | dev_info(&pdev->dev, "%s\n", i40e_fw_version_str(hw)); | 8187 | dev_info(&pdev->dev, "%s\n", i40e_fw_version_str(hw)); |
| 7949 | if (((hw->nvm.version & I40E_NVM_VERSION_HI_MASK) | ||
| 7950 | >> I40E_NVM_VERSION_HI_SHIFT) != I40E_CURRENT_NVM_VERSION_HI) { | ||
| 7951 | dev_info(&pdev->dev, | ||
| 7952 | "warning: NVM version not supported, supported version: %02x.%02x\n", | ||
| 7953 | I40E_CURRENT_NVM_VERSION_HI, | ||
| 7954 | I40E_CURRENT_NVM_VERSION_LO); | ||
| 7955 | } | ||
| 7956 | if (err) { | 8188 | if (err) { |
| 7957 | dev_info(&pdev->dev, | 8189 | dev_info(&pdev->dev, |
| 7958 | "init_adminq failed: %d expecting API %02x.%02x\n", | 8190 | "init_adminq failed: %d expecting API %02x.%02x\n", |
| @@ -7961,6 +8193,8 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 7961 | goto err_pf_reset; | 8193 | goto err_pf_reset; |
| 7962 | } | 8194 | } |
| 7963 | 8195 | ||
| 8196 | i40e_verify_eeprom(pf); | ||
| 8197 | |||
| 7964 | i40e_clear_pxe_mode(hw); | 8198 | i40e_clear_pxe_mode(hw); |
| 7965 | err = i40e_get_capabilities(pf); | 8199 | err = i40e_get_capabilities(pf); |
| 7966 | if (err) | 8200 | if (err) |
| @@ -8062,7 +8296,8 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 8062 | 8296 | ||
| 8063 | /* prep for VF support */ | 8297 | /* prep for VF support */ |
| 8064 | if ((pf->flags & I40E_FLAG_SRIOV_ENABLED) && | 8298 | if ((pf->flags & I40E_FLAG_SRIOV_ENABLED) && |
| 8065 | (pf->flags & I40E_FLAG_MSIX_ENABLED)) { | 8299 | (pf->flags & I40E_FLAG_MSIX_ENABLED) && |
| 8300 | !test_bit(__I40E_BAD_EEPROM, &pf->state)) { | ||
| 8066 | u32 val; | 8301 | u32 val; |
| 8067 | 8302 | ||
| 8068 | /* disable link interrupts for VFs */ | 8303 | /* disable link interrupts for VFs */ |
| @@ -8070,6 +8305,16 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 8070 | val &= ~I40E_PFGEN_PORTMDIO_NUM_VFLINK_STAT_ENA_MASK; | 8305 | val &= ~I40E_PFGEN_PORTMDIO_NUM_VFLINK_STAT_ENA_MASK; |
| 8071 | wr32(hw, I40E_PFGEN_PORTMDIO_NUM, val); | 8306 | wr32(hw, I40E_PFGEN_PORTMDIO_NUM, val); |
| 8072 | i40e_flush(hw); | 8307 | i40e_flush(hw); |
| 8308 | |||
| 8309 | if (pci_num_vf(pdev)) { | ||
| 8310 | dev_info(&pdev->dev, | ||
| 8311 | "Active VFs found, allocating resources.\n"); | ||
| 8312 | err = i40e_alloc_vfs(pf, pci_num_vf(pdev)); | ||
| 8313 | if (err) | ||
| 8314 | dev_info(&pdev->dev, | ||
| 8315 | "Error %d allocating resources for existing VFs\n", | ||
| 8316 | err); | ||
| 8317 | } | ||
| 8073 | } | 8318 | } |
| 8074 | 8319 | ||
| 8075 | pfs_found++; | 8320 | pfs_found++; |
| @@ -8092,7 +8337,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 8092 | 8337 | ||
| 8093 | i40e_set_pci_config_data(hw, link_status); | 8338 | i40e_set_pci_config_data(hw, link_status); |
| 8094 | 8339 | ||
| 8095 | dev_info(&pdev->dev, "PCI Express: %s %s\n", | 8340 | dev_info(&pdev->dev, "PCI-Express: %s %s\n", |
| 8096 | (hw->bus.speed == i40e_bus_speed_8000 ? "Speed 8.0GT/s" : | 8341 | (hw->bus.speed == i40e_bus_speed_8000 ? "Speed 8.0GT/s" : |
| 8097 | hw->bus.speed == i40e_bus_speed_5000 ? "Speed 5.0GT/s" : | 8342 | hw->bus.speed == i40e_bus_speed_5000 ? "Speed 5.0GT/s" : |
| 8098 | hw->bus.speed == i40e_bus_speed_2500 ? "Speed 2.5GT/s" : | 8343 | hw->bus.speed == i40e_bus_speed_2500 ? "Speed 2.5GT/s" : |
| @@ -8109,6 +8354,9 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 8109 | dev_warn(&pdev->dev, "Please move the device to a different PCI-e link with more lanes and/or higher transfer rate.\n"); | 8354 | dev_warn(&pdev->dev, "Please move the device to a different PCI-e link with more lanes and/or higher transfer rate.\n"); |
| 8110 | } | 8355 | } |
| 8111 | 8356 | ||
| 8357 | /* print a string summarizing features */ | ||
| 8358 | i40e_print_features(pf); | ||
| 8359 | |||
| 8112 | return 0; | 8360 | return 0; |
| 8113 | 8361 | ||
| 8114 | /* Unwind what we've done if something failed in the setup */ | 8362 | /* Unwind what we've done if something failed in the setup */ |
| @@ -8165,16 +8413,16 @@ static void i40e_remove(struct pci_dev *pdev) | |||
| 8165 | 8413 | ||
| 8166 | i40e_ptp_stop(pf); | 8414 | i40e_ptp_stop(pf); |
| 8167 | 8415 | ||
| 8168 | if (pf->flags & I40E_FLAG_SRIOV_ENABLED) { | ||
| 8169 | i40e_free_vfs(pf); | ||
| 8170 | pf->flags &= ~I40E_FLAG_SRIOV_ENABLED; | ||
| 8171 | } | ||
| 8172 | |||
| 8173 | /* no more scheduling of any task */ | 8416 | /* no more scheduling of any task */ |
| 8174 | set_bit(__I40E_DOWN, &pf->state); | 8417 | set_bit(__I40E_DOWN, &pf->state); |
| 8175 | del_timer_sync(&pf->service_timer); | 8418 | del_timer_sync(&pf->service_timer); |
| 8176 | cancel_work_sync(&pf->service_task); | 8419 | cancel_work_sync(&pf->service_task); |
| 8177 | 8420 | ||
| 8421 | if (pf->flags & I40E_FLAG_SRIOV_ENABLED) { | ||
| 8422 | i40e_free_vfs(pf); | ||
| 8423 | pf->flags &= ~I40E_FLAG_SRIOV_ENABLED; | ||
| 8424 | } | ||
| 8425 | |||
| 8178 | i40e_fdir_teardown(pf); | 8426 | i40e_fdir_teardown(pf); |
| 8179 | 8427 | ||
| 8180 | /* If there is a switch structure or any orphans, remove them. | 8428 | /* If there is a switch structure or any orphans, remove them. |
