aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitch Williams <mitch.a.williams@intel.com>2014-05-20 04:01:37 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2014-06-09 02:11:09 -0400
commit505682cd7baba79b52f6c9df49224307fb6d34ef (patch)
treea19b6881621fc752746c97bdb51840dfd09e1a8b
parent3dd5550f18960deb69884cd935d2aab774e51e4c (diff)
i40e: allow for more VSIs
The number of VSIs that the firmware reports to us is a guaranteed minimum, not an absolute maximum. The hardware actually supports far more than the reported value, which we often need. To allow for this, we allocate space for a larger number of VSIs than is guaranteed by the firmware, with the knowledge that we may fail to get them all in the future. Note that we are just allocating pointers here, the actual (much larger) VSI structures are allocated on demand. Change-ID: I6f4e535ce39d3bf417aef78306e04fbc7505140e Signed-off-by: Mitch Williams <mitch.a.williams@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e.h2
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_dcb_nl.c2
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_debugfs.c6
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c68
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_txrx.c2
5 files changed, 45 insertions, 35 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h
index dc6d7c6fb060..ebeaf95b9521 100644
--- a/drivers/net/ethernet/intel/i40e/i40e.h
+++ b/drivers/net/ethernet/intel/i40e/i40e.h
@@ -72,6 +72,7 @@
72#define I40E_MIN_NUM_DESCRIPTORS 64 72#define I40E_MIN_NUM_DESCRIPTORS 64
73#define I40E_MIN_MSIX 2 73#define I40E_MIN_MSIX 2
74#define I40E_DEFAULT_NUM_VMDQ_VSI 8 /* max 256 VSIs */ 74#define I40E_DEFAULT_NUM_VMDQ_VSI 8 /* max 256 VSIs */
75#define I40E_MIN_VSI_ALLOC 51 /* LAN, ATR, FCOE, 32 VF, 16 VMDQ */
75#define I40E_DEFAULT_QUEUES_PER_VMDQ 2 /* max 16 qps */ 76#define I40E_DEFAULT_QUEUES_PER_VMDQ 2 /* max 16 qps */
76#define I40E_DEFAULT_QUEUES_PER_VF 4 77#define I40E_DEFAULT_QUEUES_PER_VF 4
77#define I40E_DEFAULT_QUEUES_PER_TC 1 /* should be a power of 2 */ 78#define I40E_DEFAULT_QUEUES_PER_TC 1 /* should be a power of 2 */
@@ -215,6 +216,7 @@ struct i40e_pf {
215 u16 rss_size; /* num queues in the RSS array */ 216 u16 rss_size; /* num queues in the RSS array */
216 u16 rss_size_max; /* HW defined max RSS queues */ 217 u16 rss_size_max; /* HW defined max RSS queues */
217 u16 fdir_pf_filter_count; /* num of guaranteed filters for this PF */ 218 u16 fdir_pf_filter_count; /* num of guaranteed filters for this PF */
219 u16 num_alloc_vsi; /* num VSIs this driver supports */
218 u8 atr_sample_rate; 220 u8 atr_sample_rate;
219 bool wol_en; 221 bool wol_en;
220 222
diff --git a/drivers/net/ethernet/intel/i40e/i40e_dcb_nl.c b/drivers/net/ethernet/intel/i40e/i40e_dcb_nl.c
index 6e8103abfd0d..871831a535d0 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_dcb_nl.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_dcb_nl.c
@@ -232,7 +232,7 @@ static void i40e_dcbnl_del_app(struct i40e_pf *pf,
232 struct i40e_ieee_app_priority_table *app) 232 struct i40e_ieee_app_priority_table *app)
233{ 233{
234 int v, err; 234 int v, err;
235 for (v = 0; v < pf->hw.func_caps.num_vsis; v++) { 235 for (v = 0; v < pf->num_alloc_vsi; v++) {
236 if (pf->vsi[v] && pf->vsi[v]->netdev) { 236 if (pf->vsi[v] && pf->vsi[v]->netdev) {
237 err = i40e_dcbnl_vsi_del_app(pf->vsi[v], app); 237 err = i40e_dcbnl_vsi_del_app(pf->vsi[v], app);
238 if (err) 238 if (err)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
index 1bd0adb38735..cffdfc21290f 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
@@ -45,7 +45,7 @@ static struct i40e_vsi *i40e_dbg_find_vsi(struct i40e_pf *pf, int seid)
45 if (seid < 0) 45 if (seid < 0)
46 dev_info(&pf->pdev->dev, "%d: bad seid\n", seid); 46 dev_info(&pf->pdev->dev, "%d: bad seid\n", seid);
47 else 47 else
48 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) 48 for (i = 0; i < pf->num_alloc_vsi; i++)
49 if (pf->vsi[i] && (pf->vsi[i]->seid == seid)) 49 if (pf->vsi[i] && (pf->vsi[i]->seid == seid))
50 return pf->vsi[i]; 50 return pf->vsi[i];
51 51
@@ -843,7 +843,7 @@ static void i40e_dbg_dump_vsi_no_seid(struct i40e_pf *pf)
843{ 843{
844 int i; 844 int i;
845 845
846 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) 846 for (i = 0; i < pf->num_alloc_vsi; i++)
847 if (pf->vsi[i]) 847 if (pf->vsi[i])
848 dev_info(&pf->pdev->dev, "dump vsi[%d]: %d\n", 848 dev_info(&pf->pdev->dev, "dump vsi[%d]: %d\n",
849 i, pf->vsi[i]->seid); 849 i, pf->vsi[i]->seid);
@@ -1526,7 +1526,7 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
1526 cnt = sscanf(&cmd_buf[15], "%i", &vsi_seid); 1526 cnt = sscanf(&cmd_buf[15], "%i", &vsi_seid);
1527 if (cnt == 0) { 1527 if (cnt == 0) {
1528 int i; 1528 int i;
1529 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) 1529 for (i = 0; i < pf->num_alloc_vsi; i++)
1530 i40e_vsi_reset_stats(pf->vsi[i]); 1530 i40e_vsi_reset_stats(pf->vsi[i]);
1531 dev_info(&pf->pdev->dev, "vsi clear stats called for all vsi's\n"); 1531 dev_info(&pf->pdev->dev, "vsi clear stats called for all vsi's\n");
1532 } else if (cnt == 1) { 1532 } else if (cnt == 1) {
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index ab0b6e101c1b..d9a6c692f150 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -652,7 +652,7 @@ static void i40e_update_link_xoff_rx(struct i40e_pf *pf)
652 return; 652 return;
653 653
654 /* Clear the __I40E_HANG_CHECK_ARMED bit for all Tx rings */ 654 /* Clear the __I40E_HANG_CHECK_ARMED bit for all Tx rings */
655 for (v = 0; v < pf->hw.func_caps.num_vsis; v++) { 655 for (v = 0; v < pf->num_alloc_vsi; v++) {
656 struct i40e_vsi *vsi = pf->vsi[v]; 656 struct i40e_vsi *vsi = pf->vsi[v];
657 657
658 if (!vsi || !vsi->tx_rings[0]) 658 if (!vsi || !vsi->tx_rings[0])
@@ -706,7 +706,7 @@ static void i40e_update_prio_xoff_rx(struct i40e_pf *pf)
706 } 706 }
707 707
708 /* Clear the __I40E_HANG_CHECK_ARMED bit for Tx rings */ 708 /* Clear the __I40E_HANG_CHECK_ARMED bit for Tx rings */
709 for (v = 0; v < pf->hw.func_caps.num_vsis; v++) { 709 for (v = 0; v < pf->num_alloc_vsi; v++) {
710 struct i40e_vsi *vsi = pf->vsi[v]; 710 struct i40e_vsi *vsi = pf->vsi[v];
711 711
712 if (!vsi || !vsi->tx_rings[0]) 712 if (!vsi || !vsi->tx_rings[0])
@@ -1734,7 +1734,7 @@ static void i40e_sync_filters_subtask(struct i40e_pf *pf)
1734 return; 1734 return;
1735 pf->flags &= ~I40E_FLAG_FILTER_SYNC; 1735 pf->flags &= ~I40E_FLAG_FILTER_SYNC;
1736 1736
1737 for (v = 0; v < pf->hw.func_caps.num_vsis; v++) { 1737 for (v = 0; v < pf->num_alloc_vsi; v++) {
1738 if (pf->vsi[v] && 1738 if (pf->vsi[v] &&
1739 (pf->vsi[v]->flags & I40E_VSI_FLAG_FILTER_CHANGED)) 1739 (pf->vsi[v]->flags & I40E_VSI_FLAG_FILTER_CHANGED))
1740 i40e_sync_vsi_filters(pf->vsi[v]); 1740 i40e_sync_vsi_filters(pf->vsi[v]);
@@ -3524,7 +3524,7 @@ static void i40e_clear_interrupt_scheme(struct i40e_pf *pf)
3524 int i; 3524 int i;
3525 3525
3526 i40e_put_lump(pf->irq_pile, 0, I40E_PILE_VALID_BIT-1); 3526 i40e_put_lump(pf->irq_pile, 0, I40E_PILE_VALID_BIT-1);
3527 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) 3527 for (i = 0; i < pf->num_alloc_vsi; i++)
3528 if (pf->vsi[i]) 3528 if (pf->vsi[i])
3529 i40e_vsi_free_q_vectors(pf->vsi[i]); 3529 i40e_vsi_free_q_vectors(pf->vsi[i]);
3530 i40e_reset_interrupt_capability(pf); 3530 i40e_reset_interrupt_capability(pf);
@@ -3614,7 +3614,7 @@ static void i40e_pf_quiesce_all_vsi(struct i40e_pf *pf)
3614{ 3614{
3615 int v; 3615 int v;
3616 3616
3617 for (v = 0; v < pf->hw.func_caps.num_vsis; v++) { 3617 for (v = 0; v < pf->num_alloc_vsi; v++) {
3618 if (pf->vsi[v]) 3618 if (pf->vsi[v])
3619 i40e_quiesce_vsi(pf->vsi[v]); 3619 i40e_quiesce_vsi(pf->vsi[v]);
3620 } 3620 }
@@ -3628,7 +3628,7 @@ static void i40e_pf_unquiesce_all_vsi(struct i40e_pf *pf)
3628{ 3628{
3629 int v; 3629 int v;
3630 3630
3631 for (v = 0; v < pf->hw.func_caps.num_vsis; v++) { 3631 for (v = 0; v < pf->num_alloc_vsi; v++) {
3632 if (pf->vsi[v]) 3632 if (pf->vsi[v])
3633 i40e_unquiesce_vsi(pf->vsi[v]); 3633 i40e_unquiesce_vsi(pf->vsi[v]);
3634 } 3634 }
@@ -4069,7 +4069,7 @@ static void i40e_dcb_reconfigure(struct i40e_pf *pf)
4069 } 4069 }
4070 4070
4071 /* Update each VSI */ 4071 /* Update each VSI */
4072 for (v = 0; v < pf->hw.func_caps.num_vsis; v++) { 4072 for (v = 0; v < pf->num_alloc_vsi; v++) {
4073 if (!pf->vsi[v]) 4073 if (!pf->vsi[v])
4074 continue; 4074 continue;
4075 4075
@@ -4592,7 +4592,7 @@ void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags)
4592 /* Find the VSI(s) that requested a re-init */ 4592 /* Find the VSI(s) that requested a re-init */
4593 dev_info(&pf->pdev->dev, 4593 dev_info(&pf->pdev->dev,
4594 "VSI reinit requested\n"); 4594 "VSI reinit requested\n");
4595 for (v = 0; v < pf->hw.func_caps.num_vsis; v++) { 4595 for (v = 0; v < pf->num_alloc_vsi; v++) {
4596 struct i40e_vsi *vsi = pf->vsi[v]; 4596 struct i40e_vsi *vsi = pf->vsi[v];
4597 if (vsi != NULL && 4597 if (vsi != NULL &&
4598 test_bit(__I40E_REINIT_REQUESTED, &vsi->state)) { 4598 test_bit(__I40E_REINIT_REQUESTED, &vsi->state)) {
@@ -4919,7 +4919,7 @@ static void i40e_veb_link_event(struct i40e_veb *veb, bool link_up)
4919 i40e_veb_link_event(pf->veb[i], link_up); 4919 i40e_veb_link_event(pf->veb[i], link_up);
4920 4920
4921 /* ... now the local VSIs */ 4921 /* ... now the local VSIs */
4922 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) 4922 for (i = 0; i < pf->num_alloc_vsi; i++)
4923 if (pf->vsi[i] && (pf->vsi[i]->uplink_seid == veb->seid)) 4923 if (pf->vsi[i] && (pf->vsi[i]->uplink_seid == veb->seid))
4924 i40e_vsi_link_event(pf->vsi[i], link_up); 4924 i40e_vsi_link_event(pf->vsi[i], link_up);
4925} 4925}
@@ -4976,7 +4976,7 @@ static void i40e_check_hang_subtask(struct i40e_pf *pf)
4976 * for each q_vector 4976 * for each q_vector
4977 * force an interrupt 4977 * force an interrupt
4978 */ 4978 */
4979 for (v = 0; v < pf->hw.func_caps.num_vsis; v++) { 4979 for (v = 0; v < pf->num_alloc_vsi; v++) {
4980 struct i40e_vsi *vsi = pf->vsi[v]; 4980 struct i40e_vsi *vsi = pf->vsi[v];
4981 int armed = 0; 4981 int armed = 0;
4982 4982
@@ -5026,7 +5026,7 @@ static void i40e_watchdog_subtask(struct i40e_pf *pf)
5026 /* Update the stats for active netdevs so the network stack 5026 /* Update the stats for active netdevs so the network stack
5027 * can look at updated numbers whenever it cares to 5027 * can look at updated numbers whenever it cares to
5028 */ 5028 */
5029 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) 5029 for (i = 0; i < pf->num_alloc_vsi; i++)
5030 if (pf->vsi[i] && pf->vsi[i]->netdev) 5030 if (pf->vsi[i] && pf->vsi[i]->netdev)
5031 i40e_update_stats(pf->vsi[i]); 5031 i40e_update_stats(pf->vsi[i]);
5032 5032
@@ -5278,7 +5278,7 @@ static int i40e_reconstitute_veb(struct i40e_veb *veb)
5278 int ret; 5278 int ret;
5279 5279
5280 /* build VSI that owns this VEB, temporarily attached to base VEB */ 5280 /* build VSI that owns this VEB, temporarily attached to base VEB */
5281 for (v = 0; v < pf->hw.func_caps.num_vsis && !ctl_vsi; v++) { 5281 for (v = 0; v < pf->num_alloc_vsi && !ctl_vsi; v++) {
5282 if (pf->vsi[v] && 5282 if (pf->vsi[v] &&
5283 pf->vsi[v]->veb_idx == veb->idx && 5283 pf->vsi[v]->veb_idx == veb->idx &&
5284 pf->vsi[v]->flags & I40E_VSI_FLAG_VEB_OWNER) { 5284 pf->vsi[v]->flags & I40E_VSI_FLAG_VEB_OWNER) {
@@ -5308,7 +5308,7 @@ static int i40e_reconstitute_veb(struct i40e_veb *veb)
5308 goto end_reconstitute; 5308 goto end_reconstitute;
5309 5309
5310 /* create the remaining VSIs attached to this VEB */ 5310 /* create the remaining VSIs attached to this VEB */
5311 for (v = 0; v < pf->hw.func_caps.num_vsis; v++) { 5311 for (v = 0; v < pf->num_alloc_vsi; v++) {
5312 if (!pf->vsi[v] || pf->vsi[v] == ctl_vsi) 5312 if (!pf->vsi[v] || pf->vsi[v] == ctl_vsi)
5313 continue; 5313 continue;
5314 5314
@@ -5421,7 +5421,7 @@ static void i40e_fdir_sb_setup(struct i40e_pf *pf)
5421 5421
5422 /* find existing VSI and see if it needs configuring */ 5422 /* find existing VSI and see if it needs configuring */
5423 vsi = NULL; 5423 vsi = NULL;
5424 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) { 5424 for (i = 0; i < pf->num_alloc_vsi; i++) {
5425 if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) { 5425 if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) {
5426 vsi = pf->vsi[i]; 5426 vsi = pf->vsi[i];
5427 break; 5427 break;
@@ -5451,7 +5451,7 @@ static void i40e_fdir_teardown(struct i40e_pf *pf)
5451 int i; 5451 int i;
5452 5452
5453 i40e_fdir_filter_exit(pf); 5453 i40e_fdir_filter_exit(pf);
5454 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) { 5454 for (i = 0; i < pf->num_alloc_vsi; i++) {
5455 if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) { 5455 if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) {
5456 i40e_vsi_release(pf->vsi[i]); 5456 i40e_vsi_release(pf->vsi[i]);
5457 break; 5457 break;
@@ -5480,7 +5480,7 @@ static int i40e_prep_for_reset(struct i40e_pf *pf)
5480 /* quiesce the VSIs and their queues that are not already DOWN */ 5480 /* quiesce the VSIs and their queues that are not already DOWN */
5481 i40e_pf_quiesce_all_vsi(pf); 5481 i40e_pf_quiesce_all_vsi(pf);
5482 5482
5483 for (v = 0; v < pf->hw.func_caps.num_vsis; v++) { 5483 for (v = 0; v < pf->num_alloc_vsi; v++) {
5484 if (pf->vsi[v]) 5484 if (pf->vsi[v])
5485 pf->vsi[v]->seid = 0; 5485 pf->vsi[v]->seid = 0;
5486 } 5486 }
@@ -5960,15 +5960,15 @@ static int i40e_vsi_mem_alloc(struct i40e_pf *pf, enum i40e_vsi_type type)
5960 * find next empty vsi slot, looping back around if necessary 5960 * find next empty vsi slot, looping back around if necessary
5961 */ 5961 */
5962 i = pf->next_vsi; 5962 i = pf->next_vsi;
5963 while (i < pf->hw.func_caps.num_vsis && pf->vsi[i]) 5963 while (i < pf->num_alloc_vsi && pf->vsi[i])
5964 i++; 5964 i++;
5965 if (i >= pf->hw.func_caps.num_vsis) { 5965 if (i >= pf->num_alloc_vsi) {
5966 i = 0; 5966 i = 0;
5967 while (i < pf->next_vsi && pf->vsi[i]) 5967 while (i < pf->next_vsi && pf->vsi[i])
5968 i++; 5968 i++;
5969 } 5969 }
5970 5970
5971 if (i < pf->hw.func_caps.num_vsis && !pf->vsi[i]) { 5971 if (i < pf->num_alloc_vsi && !pf->vsi[i]) {
5972 vsi_idx = i; /* Found one! */ 5972 vsi_idx = i; /* Found one! */
5973 } else { 5973 } else {
5974 ret = -ENODEV; 5974 ret = -ENODEV;
@@ -7229,7 +7229,7 @@ int i40e_vsi_release(struct i40e_vsi *vsi)
7229 * the orphan VEBs yet. We'll wait for an explicit remove request 7229 * the orphan VEBs yet. We'll wait for an explicit remove request
7230 * from up the network stack. 7230 * from up the network stack.
7231 */ 7231 */
7232 for (n = 0, i = 0; i < pf->hw.func_caps.num_vsis; i++) { 7232 for (n = 0, i = 0; i < pf->num_alloc_vsi; i++) {
7233 if (pf->vsi[i] && 7233 if (pf->vsi[i] &&
7234 pf->vsi[i]->uplink_seid == uplink_seid && 7234 pf->vsi[i]->uplink_seid == uplink_seid &&
7235 (pf->vsi[i]->flags & I40E_VSI_FLAG_VEB_OWNER) == 0) { 7235 (pf->vsi[i]->flags & I40E_VSI_FLAG_VEB_OWNER) == 0) {
@@ -7408,7 +7408,7 @@ struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type,
7408 7408
7409 if (!veb && uplink_seid != pf->mac_seid) { 7409 if (!veb && uplink_seid != pf->mac_seid) {
7410 7410
7411 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) { 7411 for (i = 0; i < pf->num_alloc_vsi; i++) {
7412 if (pf->vsi[i] && pf->vsi[i]->seid == uplink_seid) { 7412 if (pf->vsi[i] && pf->vsi[i]->seid == uplink_seid) {
7413 vsi = pf->vsi[i]; 7413 vsi = pf->vsi[i];
7414 break; 7414 break;
@@ -7651,7 +7651,7 @@ static void i40e_switch_branch_release(struct i40e_veb *branch)
7651 * NOTE: Removing the last VSI on a VEB has the SIDE EFFECT of removing 7651 * NOTE: Removing the last VSI on a VEB has the SIDE EFFECT of removing
7652 * the VEB itself, so don't use (*branch) after this loop. 7652 * the VEB itself, so don't use (*branch) after this loop.
7653 */ 7653 */
7654 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) { 7654 for (i = 0; i < pf->num_alloc_vsi; i++) {
7655 if (!pf->vsi[i]) 7655 if (!pf->vsi[i])
7656 continue; 7656 continue;
7657 if (pf->vsi[i]->uplink_seid == branch_seid && 7657 if (pf->vsi[i]->uplink_seid == branch_seid &&
@@ -7703,7 +7703,7 @@ void i40e_veb_release(struct i40e_veb *veb)
7703 pf = veb->pf; 7703 pf = veb->pf;
7704 7704
7705 /* find the remaining VSI and check for extras */ 7705 /* find the remaining VSI and check for extras */
7706 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) { 7706 for (i = 0; i < pf->num_alloc_vsi; i++) {
7707 if (pf->vsi[i] && pf->vsi[i]->uplink_seid == veb->seid) { 7707 if (pf->vsi[i] && pf->vsi[i]->uplink_seid == veb->seid) {
7708 n++; 7708 n++;
7709 vsi = pf->vsi[i]; 7709 vsi = pf->vsi[i];
@@ -7815,10 +7815,10 @@ struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf, u16 flags,
7815 } 7815 }
7816 7816
7817 /* make sure there is such a vsi and uplink */ 7817 /* make sure there is such a vsi and uplink */
7818 for (vsi_idx = 0; vsi_idx < pf->hw.func_caps.num_vsis; vsi_idx++) 7818 for (vsi_idx = 0; vsi_idx < pf->num_alloc_vsi; vsi_idx++)
7819 if (pf->vsi[vsi_idx] && pf->vsi[vsi_idx]->seid == vsi_seid) 7819 if (pf->vsi[vsi_idx] && pf->vsi[vsi_idx]->seid == vsi_seid)
7820 break; 7820 break;
7821 if (vsi_idx >= pf->hw.func_caps.num_vsis && vsi_seid != 0) { 7821 if (vsi_idx >= pf->num_alloc_vsi && vsi_seid != 0) {
7822 dev_info(&pf->pdev->dev, "vsi seid %d not found\n", 7822 dev_info(&pf->pdev->dev, "vsi seid %d not found\n",
7823 vsi_seid); 7823 vsi_seid);
7824 return NULL; 7824 return NULL;
@@ -8484,10 +8484,18 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
8484 i40e_determine_queue_usage(pf); 8484 i40e_determine_queue_usage(pf);
8485 i40e_init_interrupt_scheme(pf); 8485 i40e_init_interrupt_scheme(pf);
8486 8486
8487 /* Set up the *vsi struct based on the number of VSIs in the HW, 8487 /* The number of VSIs reported by the FW is the minimum guaranteed
8488 * and set up our local tracking of the MAIN PF vsi. 8488 * to us; HW supports far more and we share the remaining pool with
8489 * the other PFs. We allocate space for more than the guarantee with
8490 * the understanding that we might not get them all later.
8489 */ 8491 */
8490 len = sizeof(struct i40e_vsi *) * pf->hw.func_caps.num_vsis; 8492 if (pf->hw.func_caps.num_vsis < I40E_MIN_VSI_ALLOC)
8493 pf->num_alloc_vsi = I40E_MIN_VSI_ALLOC;
8494 else
8495 pf->num_alloc_vsi = pf->hw.func_caps.num_vsis;
8496
8497 /* Set up the *vsi struct and our local tracking of the MAIN PF vsi. */
8498 len = sizeof(struct i40e_vsi *) * pf->num_alloc_vsi;
8491 pf->vsi = kzalloc(len, GFP_KERNEL); 8499 pf->vsi = kzalloc(len, GFP_KERNEL);
8492 if (!pf->vsi) { 8500 if (!pf->vsi) {
8493 err = -ENOMEM; 8501 err = -ENOMEM;
@@ -8500,7 +8508,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
8500 goto err_vsis; 8508 goto err_vsis;
8501 } 8509 }
8502 /* if FDIR VSI was set up, start it now */ 8510 /* if FDIR VSI was set up, start it now */
8503 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) { 8511 for (i = 0; i < pf->num_alloc_vsi; i++) {
8504 if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) { 8512 if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) {
8505 i40e_vsi_open(pf->vsi[i]); 8513 i40e_vsi_open(pf->vsi[i]);
8506 break; 8514 break;
@@ -8695,7 +8703,7 @@ static void i40e_remove(struct pci_dev *pdev)
8695 8703
8696 /* Clear all dynamic memory lists of rings, q_vectors, and VSIs */ 8704 /* Clear all dynamic memory lists of rings, q_vectors, and VSIs */
8697 i40e_clear_interrupt_scheme(pf); 8705 i40e_clear_interrupt_scheme(pf);
8698 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) { 8706 for (i = 0; i < pf->num_alloc_vsi; i++) {
8699 if (pf->vsi[i]) { 8707 if (pf->vsi[i]) {
8700 i40e_vsi_clear_rings(pf->vsi[i]); 8708 i40e_vsi_clear_rings(pf->vsi[i]);
8701 i40e_vsi_clear(pf->vsi[i]); 8709 i40e_vsi_clear(pf->vsi[i]);
diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
index d1a9a0512b93..2622a86de64b 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
@@ -62,7 +62,7 @@ int i40e_program_fdir_filter(struct i40e_fdir_filter *fdir_data, u8 *raw_packet,
62 62
63 /* find existing FDIR VSI */ 63 /* find existing FDIR VSI */
64 vsi = NULL; 64 vsi = NULL;
65 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) 65 for (i = 0; i < pf->num_alloc_vsi; i++)
66 if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) 66 if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR)
67 vsi = pf->vsi[i]; 67 vsi = pf->vsi[i];
68 if (!vsi) 68 if (!vsi)