aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/i40e/i40e_main.c
diff options
context:
space:
mode:
authorAnjali Singhai Jain <anjali.singhai@intel.com>2014-01-17 18:36:35 -0500
committerDavid S. Miller <davem@davemloft.net>2014-01-17 22:13:04 -0500
commitcbf613252496ed00f8669328bbd94296a03bcc79 (patch)
tree9c3601ab1bc0d7a2affb8a5e4b05697bcd97719e /drivers/net/ethernet/intel/i40e/i40e_main.c
parent60ea5f83cddf538a4509f2214ffd50d8d69952a5 (diff)
i40e: refactor flow director
The i40e hardware was generating some inconsistent results when using current programming methods. This refactor fixes the inconsistencies that were preventing clean unloads of the driver, and moves the queues for handling flow director errors into their own hardware VSI. This patch also implements a corrected version of the basic ethtool add ntuple rule, which will disable the driver's automatic flow programming. A future patch adds remove/replay/list support for ntuple. Signed-off-by: Anjali Singhai Jain <anjali.singhai@intel.com> Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com> Tested-by: Kavindya Deegala <kavindya.s.deegala@intel.com> Signed-off-by: Aaron Brown <aaron.f.brown@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/intel/i40e/i40e_main.c')
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c341
1 files changed, 183 insertions, 158 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 0ca98777c1a1..0dd578f5d803 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -54,6 +54,7 @@ static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit);
54static int i40e_setup_misc_vector(struct i40e_pf *pf); 54static int i40e_setup_misc_vector(struct i40e_pf *pf);
55static void i40e_determine_queue_usage(struct i40e_pf *pf); 55static void i40e_determine_queue_usage(struct i40e_pf *pf);
56static int i40e_setup_pf_filter_control(struct i40e_pf *pf); 56static int i40e_setup_pf_filter_control(struct i40e_pf *pf);
57static void i40e_fdir_sb_setup(struct i40e_pf *pf);
57 58
58/* i40e_pci_tbl - PCI Device ID Table 59/* i40e_pci_tbl - PCI Device ID Table
59 * 60 *
@@ -2636,23 +2637,6 @@ static irqreturn_t i40e_msix_clean_rings(int irq, void *data)
2636} 2637}
2637 2638
2638/** 2639/**
2639 * i40e_fdir_clean_rings - Interrupt Handler for FDIR rings
2640 * @irq: interrupt number
2641 * @data: pointer to a q_vector
2642 **/
2643static irqreturn_t i40e_fdir_clean_rings(int irq, void *data)
2644{
2645 struct i40e_q_vector *q_vector = data;
2646
2647 if (!q_vector->tx.ring && !q_vector->rx.ring)
2648 return IRQ_HANDLED;
2649
2650 pr_info("fdir ring cleaning needed\n");
2651
2652 return IRQ_HANDLED;
2653}
2654
2655/**
2656 * i40e_vsi_request_irq_msix - Initialize MSI-X interrupts 2640 * i40e_vsi_request_irq_msix - Initialize MSI-X interrupts
2657 * @vsi: the VSI being configured 2641 * @vsi: the VSI being configured
2658 * @basename: name for the vector 2642 * @basename: name for the vector
@@ -2903,6 +2887,94 @@ enable_intr:
2903} 2887}
2904 2888
2905/** 2889/**
2890 * i40e_clean_fdir_tx_irq - Reclaim resources after transmit completes
2891 * @tx_ring: tx ring to clean
2892 * @budget: how many cleans we're allowed
2893 *
2894 * Returns true if there's any budget left (e.g. the clean is finished)
2895 **/
2896static bool i40e_clean_fdir_tx_irq(struct i40e_ring *tx_ring, int budget)
2897{
2898 struct i40e_vsi *vsi = tx_ring->vsi;
2899 u16 i = tx_ring->next_to_clean;
2900 struct i40e_tx_buffer *tx_buf;
2901 struct i40e_tx_desc *tx_desc;
2902
2903 tx_buf = &tx_ring->tx_bi[i];
2904 tx_desc = I40E_TX_DESC(tx_ring, i);
2905 i -= tx_ring->count;
2906
2907 do {
2908 struct i40e_tx_desc *eop_desc = tx_buf->next_to_watch;
2909
2910 /* if next_to_watch is not set then there is no work pending */
2911 if (!eop_desc)
2912 break;
2913
2914 /* prevent any other reads prior to eop_desc */
2915 read_barrier_depends();
2916
2917 /* if the descriptor isn't done, no work yet to do */
2918 if (!(eop_desc->cmd_type_offset_bsz &
2919 cpu_to_le64(I40E_TX_DESC_DTYPE_DESC_DONE)))
2920 break;
2921
2922 /* clear next_to_watch to prevent false hangs */
2923 tx_buf->next_to_watch = NULL;
2924
2925 /* unmap skb header data */
2926 dma_unmap_single(tx_ring->dev,
2927 dma_unmap_addr(tx_buf, dma),
2928 dma_unmap_len(tx_buf, len),
2929 DMA_TO_DEVICE);
2930
2931 dma_unmap_len_set(tx_buf, len, 0);
2932
2933
2934 /* move to the next desc and buffer to clean */
2935 tx_buf++;
2936 tx_desc++;
2937 i++;
2938 if (unlikely(!i)) {
2939 i -= tx_ring->count;
2940 tx_buf = tx_ring->tx_bi;
2941 tx_desc = I40E_TX_DESC(tx_ring, 0);
2942 }
2943
2944 /* update budget accounting */
2945 budget--;
2946 } while (likely(budget));
2947
2948 i += tx_ring->count;
2949 tx_ring->next_to_clean = i;
2950
2951 if (vsi->back->flags & I40E_FLAG_MSIX_ENABLED) {
2952 i40e_irq_dynamic_enable(vsi,
2953 tx_ring->q_vector->v_idx + vsi->base_vector);
2954 }
2955 return budget > 0;
2956}
2957
2958/**
2959 * i40e_fdir_clean_ring - Interrupt Handler for FDIR SB ring
2960 * @irq: interrupt number
2961 * @data: pointer to a q_vector
2962 **/
2963static irqreturn_t i40e_fdir_clean_ring(int irq, void *data)
2964{
2965 struct i40e_q_vector *q_vector = data;
2966 struct i40e_vsi *vsi;
2967
2968 if (!q_vector->tx.ring)
2969 return IRQ_HANDLED;
2970
2971 vsi = q_vector->tx.ring->vsi;
2972 i40e_clean_fdir_tx_irq(q_vector->tx.ring, vsi->work_limit);
2973
2974 return IRQ_HANDLED;
2975}
2976
2977/**
2906 * i40e_map_vector_to_qp - Assigns the queue pair to the vector 2978 * i40e_map_vector_to_qp - Assigns the queue pair to the vector
2907 * @vsi: the VSI being configured 2979 * @vsi: the VSI being configured
2908 * @v_idx: vector index 2980 * @v_idx: vector index
@@ -4730,54 +4802,77 @@ static int i40e_get_capabilities(struct i40e_pf *pf)
4730 return 0; 4802 return 0;
4731} 4803}
4732 4804
4805static int i40e_vsi_clear(struct i40e_vsi *vsi);
4806
4733/** 4807/**
4734 * i40e_fdir_setup - initialize the Flow Director resources 4808 * i40e_fdir_sb_setup - initialize the Flow Director resources for Sideband
4735 * @pf: board private structure 4809 * @pf: board private structure
4736 **/ 4810 **/
4737static void i40e_fdir_setup(struct i40e_pf *pf) 4811static void i40e_fdir_sb_setup(struct i40e_pf *pf)
4738{ 4812{
4739 struct i40e_vsi *vsi; 4813 struct i40e_vsi *vsi;
4740 bool new_vsi = false; 4814 bool new_vsi = false;
4741 int err, i; 4815 int err, i;
4742 4816
4743 if (!(pf->flags & (I40E_FLAG_FD_SB_ENABLED | 4817 if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED))
4744 I40E_FLAG_FD_ATR_ENABLED)))
4745 return; 4818 return;
4746 4819
4747 pf->atr_sample_rate = I40E_DEFAULT_ATR_SAMPLE_RATE; 4820 /* find existing VSI and see if it needs configuring */
4748
4749 /* find existing or make new FDIR VSI */
4750 vsi = NULL; 4821 vsi = NULL;
4751 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) 4822 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) {
4752 if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) 4823 if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) {
4753 vsi = pf->vsi[i]; 4824 vsi = pf->vsi[i];
4825 break;
4826 }
4827 }
4828
4829 /* create a new VSI if none exists */
4754 if (!vsi) { 4830 if (!vsi) {
4755 vsi = i40e_vsi_setup(pf, I40E_VSI_FDIR, pf->mac_seid, 0); 4831 vsi = i40e_vsi_setup(pf, I40E_VSI_FDIR,
4832 pf->vsi[pf->lan_vsi]->seid, 0);
4756 if (!vsi) { 4833 if (!vsi) {
4757 dev_info(&pf->pdev->dev, "Couldn't create FDir VSI\n"); 4834 dev_info(&pf->pdev->dev, "Couldn't create FDir VSI\n");
4758 pf->flags &= ~I40E_FLAG_FD_SB_ENABLED; 4835 goto err_vsi;
4759 return;
4760 } 4836 }
4761 new_vsi = true; 4837 new_vsi = true;
4762 } 4838 }
4763 WARN_ON(vsi->base_queue != I40E_FDIR_RING); 4839 i40e_vsi_setup_irqhandler(vsi, i40e_fdir_clean_ring);
4764 i40e_vsi_setup_irqhandler(vsi, i40e_fdir_clean_rings);
4765 4840
4766 err = i40e_vsi_setup_tx_resources(vsi); 4841 err = i40e_vsi_setup_tx_resources(vsi);
4767 if (!err) 4842 if (err)
4768 err = i40e_vsi_setup_rx_resources(vsi); 4843 goto err_setup_tx;
4769 if (!err) 4844 err = i40e_vsi_setup_rx_resources(vsi);
4770 err = i40e_vsi_configure(vsi); 4845 if (err)
4771 if (!err && new_vsi) { 4846 goto err_setup_rx;
4847
4848 if (new_vsi) {
4772 char int_name[IFNAMSIZ + 9]; 4849 char int_name[IFNAMSIZ + 9];
4850 err = i40e_vsi_configure(vsi);
4851 if (err)
4852 goto err_setup_rx;
4773 snprintf(int_name, sizeof(int_name) - 1, "%s-fdir", 4853 snprintf(int_name, sizeof(int_name) - 1, "%s-fdir",
4774 dev_driver_string(&pf->pdev->dev)); 4854 dev_driver_string(&pf->pdev->dev));
4775 err = i40e_vsi_request_irq(vsi, int_name); 4855 err = i40e_vsi_request_irq(vsi, int_name);
4776 } 4856 if (err)
4777 if (!err) 4857 goto err_setup_rx;
4778 err = i40e_up_complete(vsi); 4858 err = i40e_up_complete(vsi);
4859 if (err)
4860 goto err_up_complete;
4861 }
4779 4862
4780 clear_bit(__I40E_NEEDS_RESTART, &vsi->state); 4863 clear_bit(__I40E_NEEDS_RESTART, &vsi->state);
4864 return;
4865
4866err_up_complete:
4867 i40e_down(vsi);
4868 i40e_vsi_free_irq(vsi);
4869err_setup_rx:
4870 i40e_vsi_free_rx_resources(vsi);
4871err_setup_tx:
4872 i40e_vsi_free_tx_resources(vsi);
4873err_vsi:
4874 pf->flags &= ~I40E_FLAG_FD_SB_ENABLED;
4875 i40e_vsi_clear(vsi);
4781} 4876}
4782 4877
4783/** 4878/**
@@ -5865,6 +5960,7 @@ static int i40e_sw_init(struct i40e_pf *pf)
5865 if (pf->hw.func_caps.rss) { 5960 if (pf->hw.func_caps.rss) {
5866 pf->flags |= I40E_FLAG_RSS_ENABLED; 5961 pf->flags |= I40E_FLAG_RSS_ENABLED;
5867 pf->rss_size = min_t(int, pf->rss_size_max, num_online_cpus()); 5962 pf->rss_size = min_t(int, pf->rss_size_max, num_online_cpus());
5963 pf->rss_size = rounddown_pow_of_two(pf->rss_size);
5868 } else { 5964 } else {
5869 pf->rss_size = 1; 5965 pf->rss_size = 1;
5870 } 5966 }
@@ -5880,21 +5976,25 @@ static int i40e_sw_init(struct i40e_pf *pf)
5880 else 5976 else
5881 pf->num_tc_qps = 0; 5977 pf->num_tc_qps = 0;
5882 5978
5883 if (pf->hw.func_caps.fd) { 5979 /* FW/NVM is not yet fixed in this regard */
5884 /* FW/NVM is not yet fixed in this regard */ 5980 if ((pf->hw.func_caps.fd_filters_guaranteed > 0) ||
5885 if ((pf->hw.func_caps.fd_filters_guaranteed > 0) || 5981 (pf->hw.func_caps.fd_filters_best_effort > 0)) {
5886 (pf->hw.func_caps.fd_filters_best_effort > 0)) { 5982 pf->flags |= I40E_FLAG_FD_ATR_ENABLED;
5887 pf->flags |= I40E_FLAG_FD_ATR_ENABLED; 5983 pf->atr_sample_rate = I40E_DEFAULT_ATR_SAMPLE_RATE;
5888 dev_info(&pf->pdev->dev, 5984 dev_info(&pf->pdev->dev,
5889 "Flow Director ATR mode Enabled\n"); 5985 "Flow Director ATR mode Enabled\n");
5986 if (!(pf->flags & I40E_FLAG_MFP_ENABLED)) {
5890 pf->flags |= I40E_FLAG_FD_SB_ENABLED; 5987 pf->flags |= I40E_FLAG_FD_SB_ENABLED;
5891 dev_info(&pf->pdev->dev, 5988 dev_info(&pf->pdev->dev,
5892 "Flow Director Side Band mode Enabled\n"); 5989 "Flow Director Side Band mode Enabled\n");
5893 pf->fdir_pf_filter_count = 5990 } else {
5894 pf->hw.func_caps.fd_filters_guaranteed; 5991 dev_info(&pf->pdev->dev,
5992 "Flow Director Side Band mode Disabled in MFP mode\n");
5895 } 5993 }
5896 } else { 5994 pf->fdir_pf_filter_count =
5897 pf->fdir_pf_filter_count = 0; 5995 pf->hw.func_caps.fd_filters_guaranteed;
5996 pf->hw.fdir_shared_filter_count =
5997 pf->hw.func_caps.fd_filters_best_effort;
5898 } 5998 }
5899 5999
5900 if (pf->hw.func_caps.vmdq) { 6000 if (pf->hw.func_caps.vmdq) {
@@ -6185,10 +6285,6 @@ static void i40e_vsi_delete(struct i40e_vsi *vsi)
6185 if (vsi == vsi->back->vsi[vsi->back->lan_vsi]) 6285 if (vsi == vsi->back->vsi[vsi->back->lan_vsi])
6186 return; 6286 return;
6187 6287
6188 /* there is no HW VSI for FDIR */
6189 if (vsi->type == I40E_VSI_FDIR)
6190 return;
6191
6192 i40e_aq_delete_element(&vsi->back->hw, vsi->seid, NULL); 6288 i40e_aq_delete_element(&vsi->back->hw, vsi->seid, NULL);
6193 return; 6289 return;
6194} 6290}
@@ -6272,12 +6368,12 @@ static int i40e_add_vsi(struct i40e_vsi *vsi)
6272 break; 6368 break;
6273 6369
6274 case I40E_VSI_FDIR: 6370 case I40E_VSI_FDIR:
6275 /* no queue mapping or actual HW VSI needed */ 6371 ctxt.pf_num = hw->pf_id;
6276 vsi->info.valid_sections = 0; 6372 ctxt.vf_num = 0;
6277 vsi->seid = 0; 6373 ctxt.uplink_seid = vsi->uplink_seid;
6278 vsi->id = 0; 6374 ctxt.connection_type = 0x1; /* regular data port */
6375 ctxt.flags = I40E_AQ_VSI_TYPE_PF;
6279 i40e_vsi_setup_queue_map(vsi, &ctxt, enabled_tc, true); 6376 i40e_vsi_setup_queue_map(vsi, &ctxt, enabled_tc, true);
6280 return 0;
6281 break; 6377 break;
6282 6378
6283 case I40E_VSI_VMDQ2: 6379 case I40E_VSI_VMDQ2:
@@ -6646,6 +6742,8 @@ struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type,
6646 if (v_idx < 0) 6742 if (v_idx < 0)
6647 goto err_alloc; 6743 goto err_alloc;
6648 vsi = pf->vsi[v_idx]; 6744 vsi = pf->vsi[v_idx];
6745 if (!vsi)
6746 goto err_alloc;
6649 vsi->type = type; 6747 vsi->type = type;
6650 vsi->veb_idx = (veb ? veb->idx : I40E_NO_VEB); 6748 vsi->veb_idx = (veb ? veb->idx : I40E_NO_VEB);
6651 6749
@@ -6654,7 +6752,8 @@ struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type,
6654 else if (type == I40E_VSI_SRIOV) 6752 else if (type == I40E_VSI_SRIOV)
6655 vsi->vf_id = param1; 6753 vsi->vf_id = param1;
6656 /* assign it some queues */ 6754 /* assign it some queues */
6657 ret = i40e_get_lump(pf, pf->qp_pile, vsi->alloc_queue_pairs, vsi->idx); 6755 ret = i40e_get_lump(pf, pf->qp_pile, vsi->alloc_queue_pairs,
6756 vsi->idx);
6658 if (ret < 0) { 6757 if (ret < 0) {
6659 dev_info(&pf->pdev->dev, "VSI %d get_lump failed %d\n", 6758 dev_info(&pf->pdev->dev, "VSI %d get_lump failed %d\n",
6660 vsi->seid, ret); 6759 vsi->seid, ret);
@@ -7228,12 +7327,6 @@ static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit)
7228 } 7327 }
7229 i40e_pf_reset_stats(pf); 7328 i40e_pf_reset_stats(pf);
7230 7329
7231 /* fdir VSI must happen first to be sure it gets queue 0, but only
7232 * if there is enough room for the fdir VSI
7233 */
7234 if (pf->num_lan_qps > 1)
7235 i40e_fdir_setup(pf);
7236
7237 /* first time setup */ 7330 /* first time setup */
7238 if (pf->lan_vsi == I40E_NO_VSI || reinit) { 7331 if (pf->lan_vsi == I40E_NO_VSI || reinit) {
7239 struct i40e_vsi *vsi = NULL; 7332 struct i40e_vsi *vsi = NULL;
@@ -7264,6 +7357,8 @@ static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit)
7264 } 7357 }
7265 i40e_vlan_stripping_disable(pf->vsi[pf->lan_vsi]); 7358 i40e_vlan_stripping_disable(pf->vsi[pf->lan_vsi]);
7266 7359
7360 i40e_fdir_sb_setup(pf);
7361
7267 /* Setup static PF queue filter control settings */ 7362 /* Setup static PF queue filter control settings */
7268 ret = i40e_setup_pf_filter_control(pf); 7363 ret = i40e_setup_pf_filter_control(pf);
7269 if (ret) { 7364 if (ret) {
@@ -7347,33 +7442,15 @@ fc_complete:
7347} 7442}
7348 7443
7349/** 7444/**
7350 * i40e_set_rss_size - helper to set rss_size
7351 * @pf: board private structure
7352 * @queues_left: how many queues
7353 */
7354static u16 i40e_set_rss_size(struct i40e_pf *pf, int queues_left)
7355{
7356 int num_tc0;
7357
7358 num_tc0 = min_t(int, queues_left, pf->rss_size_max);
7359 num_tc0 = min_t(int, num_tc0, num_online_cpus());
7360 num_tc0 = rounddown_pow_of_two(num_tc0);
7361
7362 return num_tc0;
7363}
7364
7365/**
7366 * i40e_determine_queue_usage - Work out queue distribution 7445 * i40e_determine_queue_usage - Work out queue distribution
7367 * @pf: board private structure 7446 * @pf: board private structure
7368 **/ 7447 **/
7369static void i40e_determine_queue_usage(struct i40e_pf *pf) 7448static void i40e_determine_queue_usage(struct i40e_pf *pf)
7370{ 7449{
7371 int accum_tc_size;
7372 int queues_left; 7450 int queues_left;
7373 7451
7374 pf->num_lan_qps = 0; 7452 pf->num_lan_qps = 0;
7375 pf->num_tc_qps = rounddown_pow_of_two(pf->num_tc_qps); 7453 pf->num_tc_qps = rounddown_pow_of_two(pf->num_tc_qps);
7376 accum_tc_size = (I40E_MAX_TRAFFIC_CLASS - 1) * pf->num_tc_qps;
7377 7454
7378 /* Find the max queues to be put into basic use. We'll always be 7455 /* Find the max queues to be put into basic use. We'll always be
7379 * using TC0, whether or not DCB is running, and TC0 will get the 7456 * using TC0, whether or not DCB is running, and TC0 will get the
@@ -7381,81 +7458,15 @@ static void i40e_determine_queue_usage(struct i40e_pf *pf)
7381 */ 7458 */
7382 queues_left = pf->hw.func_caps.num_tx_qp; 7459 queues_left = pf->hw.func_caps.num_tx_qp;
7383 7460
7384 if (!(pf->flags & I40E_FLAG_MSIX_ENABLED) || 7461 if ((queues_left == 1) ||
7385 !(pf->flags & (I40E_FLAG_RSS_ENABLED | 7462 !(pf->flags & I40E_FLAG_MSIX_ENABLED) ||
7386 I40E_FLAG_FD_SB_ENABLED | I40E_FLAG_DCB_ENABLED)) || 7463 !(pf->flags & (I40E_FLAG_RSS_ENABLED | I40E_FLAG_FD_SB_ENABLED |
7387 (queues_left == 1)) { 7464 I40E_FLAG_DCB_ENABLED))) {
7388
7389 /* one qp for PF, no queues for anything else */ 7465 /* one qp for PF, no queues for anything else */
7390 queues_left = 0; 7466 queues_left = 0;
7391 pf->rss_size = pf->num_lan_qps = 1; 7467 pf->rss_size = pf->num_lan_qps = 1;
7392 7468
7393 /* make sure all the fancies are disabled */ 7469 /* make sure all the fancies are disabled */
7394
7395 } else if (pf->flags & I40E_FLAG_RSS_ENABLED &&
7396 !(pf->flags & I40E_FLAG_FD_SB_ENABLED) &&
7397 !(pf->flags & I40E_FLAG_DCB_ENABLED)) {
7398
7399 pf->rss_size = i40e_set_rss_size(pf, queues_left);
7400
7401 queues_left -= pf->rss_size;
7402 pf->num_lan_qps = pf->rss_size_max;
7403
7404 } else if (pf->flags & I40E_FLAG_RSS_ENABLED &&
7405 !(pf->flags & I40E_FLAG_FD_SB_ENABLED) &&
7406 (pf->flags & I40E_FLAG_DCB_ENABLED)) {
7407
7408 /* save num_tc_qps queues for TCs 1 thru 7 and the rest
7409 * are set up for RSS in TC0
7410 */
7411 queues_left -= accum_tc_size;
7412
7413 pf->rss_size = i40e_set_rss_size(pf, queues_left);
7414
7415 queues_left -= pf->rss_size;
7416 if (queues_left < 0) {
7417 dev_info(&pf->pdev->dev, "not enough queues for DCB\n");
7418 return;
7419 }
7420
7421 pf->num_lan_qps = pf->rss_size_max + accum_tc_size;
7422
7423 } else if (pf->flags & I40E_FLAG_RSS_ENABLED &&
7424 (pf->flags & I40E_FLAG_FD_SB_ENABLED) &&
7425 !(pf->flags & I40E_FLAG_DCB_ENABLED)) {
7426
7427 queues_left -= 1; /* save 1 queue for FD */
7428
7429 pf->rss_size = i40e_set_rss_size(pf, queues_left);
7430
7431 queues_left -= pf->rss_size;
7432 if (queues_left < 0) {
7433 dev_info(&pf->pdev->dev, "not enough queues for Flow Director\n");
7434 return;
7435 }
7436
7437 pf->num_lan_qps = pf->rss_size_max;
7438
7439 } else if (pf->flags & I40E_FLAG_RSS_ENABLED &&
7440 (pf->flags & I40E_FLAG_FD_SB_ENABLED) &&
7441 (pf->flags & I40E_FLAG_DCB_ENABLED)) {
7442
7443 /* save 1 queue for TCs 1 thru 7,
7444 * 1 queue for flow director,
7445 * and the rest are set up for RSS in TC0
7446 */
7447 queues_left -= 1;
7448 queues_left -= accum_tc_size;
7449
7450 pf->rss_size = i40e_set_rss_size(pf, queues_left);
7451 queues_left -= pf->rss_size;
7452 if (queues_left < 0) {
7453 dev_info(&pf->pdev->dev, "not enough queues for DCB and Flow Director\n");
7454 return;
7455 }
7456
7457 pf->num_lan_qps = pf->rss_size_max + accum_tc_size;
7458
7459 pf->flags &= ~(I40E_FLAG_RSS_ENABLED | 7470 pf->flags &= ~(I40E_FLAG_RSS_ENABLED |
7460 I40E_FLAG_FD_SB_ENABLED | 7471 I40E_FLAG_FD_SB_ENABLED |
7461 I40E_FLAG_FD_ATR_ENABLED | 7472 I40E_FLAG_FD_ATR_ENABLED |
@@ -7463,15 +7474,29 @@ static void i40e_determine_queue_usage(struct i40e_pf *pf)
7463 I40E_FLAG_SRIOV_ENABLED | 7474 I40E_FLAG_SRIOV_ENABLED |
7464 I40E_FLAG_VMDQ_ENABLED); 7475 I40E_FLAG_VMDQ_ENABLED);
7465 } else { 7476 } else {
7466 dev_info(&pf->pdev->dev, 7477 /* Not enough queues for all TCs */
7467 "Invalid configuration, flags=0x%08llx\n", pf->flags); 7478 if ((pf->flags & I40E_FLAG_DCB_ENABLED) &&
7468 return; 7479 (queues_left < I40E_MAX_TRAFFIC_CLASS)) {
7480 pf->flags &= ~I40E_FLAG_DCB_ENABLED;
7481 dev_info(&pf->pdev->dev, "not enough queues for DCB. DCB is disabled.\n");
7482 }
7483 pf->num_lan_qps = pf->rss_size_max;
7484 queues_left -= pf->num_lan_qps;
7485 }
7486
7487 if (pf->flags & I40E_FLAG_FD_SB_ENABLED) {
7488 if (queues_left > 1) {
7489 queues_left -= 1; /* save 1 queue for FD */
7490 } else {
7491 pf->flags &= ~I40E_FLAG_FD_SB_ENABLED;
7492 dev_info(&pf->pdev->dev, "not enough queues for Flow Director. Flow Director feature is disabled\n");
7493 }
7469 } 7494 }
7470 7495
7471 if ((pf->flags & I40E_FLAG_SRIOV_ENABLED) && 7496 if ((pf->flags & I40E_FLAG_SRIOV_ENABLED) &&
7472 pf->num_vf_qps && pf->num_req_vfs && queues_left) { 7497 pf->num_vf_qps && pf->num_req_vfs && queues_left) {
7473 pf->num_req_vfs = min_t(int, pf->num_req_vfs, (queues_left / 7498 pf->num_req_vfs = min_t(int, pf->num_req_vfs,
7474 pf->num_vf_qps)); 7499 (queues_left / pf->num_vf_qps));
7475 queues_left -= (pf->num_req_vfs * pf->num_vf_qps); 7500 queues_left -= (pf->num_req_vfs * pf->num_vf_qps);
7476 } 7501 }
7477 7502