All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [next PATCH S5 01/10] i40e: let untrusted VF to create up to 16 VLANs
@ 2019-04-24 12:20 Alice Michael
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 02/10] i40e: add constraints for accessing veb array Alice Michael
                   ` (9 more replies)
  0 siblings, 10 replies; 20+ messages in thread
From: Alice Michael @ 2019-04-24 12:20 UTC (permalink / raw)
  To: intel-wired-lan

From: Piotr Kwapulinski <piotr.kwapulinski@intel.com>

This patch lets untrusted VF to create up to 16 VLANs.
It was implemented by increasing I40E_VC_MAX_VLAN_PER_VF up to 16.
Without this patch untrusted VF could create only up to 8 VLANs.

Signed-off-by: Piotr Kwapulinski <piotr.kwapulinski@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index 479bc60c8f71..8b07614ca568 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -2509,7 +2509,7 @@ static int i40e_vc_get_stats_msg(struct i40e_vf *vf, u8 *msg)
  * MAC filters: 16 for multicast, 1 for MAC, 1 for broadcast
  */
 #define I40E_VC_MAX_MAC_ADDR_PER_VF (16 + 1 + 1)
-#define I40E_VC_MAX_VLAN_PER_VF 8
+#define I40E_VC_MAX_VLAN_PER_VF 16
 
 /**
  * i40e_check_vf_permission
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [next PATCH S5 02/10] i40e: add constraints for accessing veb array
  2019-04-24 12:20 [Intel-wired-lan] [next PATCH S5 01/10] i40e: let untrusted VF to create up to 16 VLANs Alice Michael
@ 2019-04-24 12:20 ` Alice Michael
  2019-05-03 23:35   ` Bowers, AndrewX
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 03/10] i40e: Use signed variable Alice Michael
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 20+ messages in thread
From: Alice Michael @ 2019-04-24 12:20 UTC (permalink / raw)
  To: intel-wired-lan

From: Piotr Kwapulinski <piotr.kwapulinski@intel.com>

Add veb array access boundary checks.
Ensure veb array index is smaller than I40E_MAX_VEB.

Signed-off-by: Piotr Kwapulinski <piotr.kwapulinski@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 4e1aacd72b02..5716f8fe06ed 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -9042,7 +9042,7 @@ static void i40e_link_event(struct i40e_pf *pf)
 	/* Notify the base of the switch tree connected to
 	 * the link.  Floating VEBs are not notified.
 	 */
-	if (pf->lan_veb != I40E_NO_VEB && pf->veb[pf->lan_veb])
+	if (pf->lan_veb < I40E_MAX_VEB && pf->veb[pf->lan_veb])
 		i40e_veb_link_event(pf->veb[pf->lan_veb], new_link);
 	else
 		i40e_vsi_link_event(vsi, new_link);
@@ -13001,7 +13001,7 @@ int i40e_is_vsi_uplink_mode_veb(struct i40e_vsi *vsi)
 	struct i40e_pf *pf = vsi->back;
 
 	/* Uplink is not a bridge so default to VEB */
-	if (vsi->veb_idx == I40E_NO_VEB)
+	if (vsi->veb_idx >= I40E_MAX_VEB)
 		return 1;
 
 	veb = pf->veb[vsi->veb_idx];
@@ -14059,7 +14059,7 @@ static void i40e_setup_pf_switch_element(struct i40e_pf *pf,
 		/* Main VEB? */
 		if (uplink_seid != pf->mac_seid)
 			break;
-		if (pf->lan_veb == I40E_NO_VEB) {
+		if (pf->lan_veb >= I40E_MAX_VEB) {
 			int v;
 
 			/* find existing or else empty VEB */
@@ -14069,13 +14069,15 @@ static void i40e_setup_pf_switch_element(struct i40e_pf *pf,
 					break;
 				}
 			}
-			if (pf->lan_veb == I40E_NO_VEB) {
+			if (pf->lan_veb >= I40E_MAX_VEB) {
 				v = i40e_veb_mem_alloc(pf);
 				if (v < 0)
 					break;
 				pf->lan_veb = v;
 			}
 		}
+		if (pf->lan_veb >= I40E_MAX_VEB)
+			break;
 
 		pf->veb[pf->lan_veb]->seid = seid;
 		pf->veb[pf->lan_veb]->uplink_seid = pf->mac_seid;
@@ -14229,7 +14231,7 @@ static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit)
 		/* Set up the PF VSI associated with the PF's main VSI
 		 * that is already in the HW switch
 		 */
-		if (pf->lan_veb != I40E_NO_VEB && pf->veb[pf->lan_veb])
+		if (pf->lan_veb < I40E_MAX_VEB && pf->veb[pf->lan_veb])
 			uplink_seid = pf->veb[pf->lan_veb]->seid;
 		else
 			uplink_seid = pf->mac_seid;
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [next PATCH S5 03/10] i40e: Use signed variable
  2019-04-24 12:20 [Intel-wired-lan] [next PATCH S5 01/10] i40e: let untrusted VF to create up to 16 VLANs Alice Michael
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 02/10] i40e: add constraints for accessing veb array Alice Michael
@ 2019-04-24 12:20 ` Alice Michael
  2019-05-03 23:36   ` Bowers, AndrewX
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 04/10] i40e: Add bounds check for ch[] array Alice Michael
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 20+ messages in thread
From: Alice Michael @ 2019-04-24 12:20 UTC (permalink / raw)
  To: intel-wired-lan

From: Mitch Williams <mitch.a.williams@intel.com>

The counter variable in i40e_clean_tx_irq starts out negative and climbs
to 0. So it should not be defined as a u16. This was working by accident
due to the fact the u16 overflows and underflows predictably.

Replace the u16 with int, which is signed and can handle the negativity.

Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_txrx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
index edd6532c943f..ef41de9faa26 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
@@ -774,7 +774,7 @@ void i40e_detect_recover_hung(struct i40e_vsi *vsi)
 static bool i40e_clean_tx_irq(struct i40e_vsi *vsi,
 			      struct i40e_ring *tx_ring, int napi_budget)
 {
-	u16 i = tx_ring->next_to_clean;
+	int i = tx_ring->next_to_clean;
 	struct i40e_tx_buffer *tx_buf;
 	struct i40e_tx_desc *tx_head;
 	struct i40e_tx_desc *tx_desc;
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [next PATCH S5 04/10] i40e: Add bounds check for ch[] array
  2019-04-24 12:20 [Intel-wired-lan] [next PATCH S5 01/10] i40e: let untrusted VF to create up to 16 VLANs Alice Michael
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 02/10] i40e: add constraints for accessing veb array Alice Michael
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 03/10] i40e: Use signed variable Alice Michael
@ 2019-04-24 12:20 ` Alice Michael
  2019-05-03 23:37   ` Bowers, AndrewX
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 05/10] i40e: Improve AQ log granularity Alice Michael
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 20+ messages in thread
From: Alice Michael @ 2019-04-24 12:20 UTC (permalink / raw)
  To: intel-wired-lan

From: Piotr Kwapulinski <piotr.kwapulinski@intel.com>

Add bounds check for ch[] array.
Use ARRAY_SIZE() to ensure that idx is within the range.

Signed-off-by: Piotr Kwapulinski <piotr.kwapulinski@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index 8b07614ca568..4061da6c9dcb 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -2135,8 +2135,13 @@ static int i40e_vc_config_queues_msg(struct i40e_vf *vf, u8 *msg)
 			}
 		}
 
-		if (vf->adq_enabled)
+		if (vf->adq_enabled) {
+			if (idx >= ARRAY_SIZE(vf->ch)) {
+				aq_ret = I40E_ERR_NO_AVAILABLE_VSI;
+				goto error_param;
+			}
 			vsi_id = vf->ch[idx].vsi_id;
+		}
 
 		if (i40e_config_vsi_rx_queue(vf, vsi_id, vsi_queue_id,
 					     &qpi->rxq) ||
@@ -2152,6 +2157,10 @@ static int i40e_vc_config_queues_msg(struct i40e_vf *vf, u8 *msg)
 		 * to its appropriate VSIs based on TC mapping
 		 **/
 		if (vf->adq_enabled) {
+			if (idx >= ARRAY_SIZE(vf->ch)) {
+				aq_ret = I40E_ERR_NO_AVAILABLE_VSI;
+				goto error_param;
+			}
 			if (j == (vf->ch[idx].num_qps - 1)) {
 				idx++;
 				j = 0; /* resetting the queue count */
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [next PATCH S5 05/10] i40e: Improve AQ log granularity
  2019-04-24 12:20 [Intel-wired-lan] [next PATCH S5 01/10] i40e: let untrusted VF to create up to 16 VLANs Alice Michael
                   ` (2 preceding siblings ...)
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 04/10] i40e: Add bounds check for ch[] array Alice Michael
@ 2019-04-24 12:20 ` Alice Michael
  2019-05-03 23:38   ` Bowers, AndrewX
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 06/10] i40e: add input validation for virtchnl handlers Alice Michael
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 20+ messages in thread
From: Alice Michael @ 2019-04-24 12:20 UTC (permalink / raw)
  To: intel-wired-lan

From: Doug Dziggel <douglas.a.dziggel@intel.com>

This patch makes it possible to log only AQ descriptors, without the
entire AQ message buffers being dumped too. It should greatly reduce
kernel log size in cases where a full AQ dump is not needed.
Selection is made by setting flags in hw->debug_mask.

Additionally, some debug messages that preceded an AQ dump have been
moved to I40E_DEBUG_AQ_COMMAND class, which seems more appropriate.

Signed-off-by: Doug Dziggel <douglas.a.dziggel@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_adminq.c |  8 ++--
 drivers/net/ethernet/intel/i40e/i40e_common.c | 40 ++++++++++---------
 2 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq.c b/drivers/net/ethernet/intel/i40e/i40e_adminq.c
index 243dcd4bec19..814acbe79ffd 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_adminq.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_adminq.c
@@ -675,7 +675,7 @@ static u16 i40e_clean_asq(struct i40e_hw *hw)
 	desc = I40E_ADMINQ_DESC(*asq, ntc);
 	details = I40E_ADMINQ_DETAILS(*asq, ntc);
 	while (rd32(hw, hw->aq.asq.head) != ntc) {
-		i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
+		i40e_debug(hw, I40E_DEBUG_AQ_COMMAND,
 			   "ntc %d head %d.\n", ntc, rd32(hw, hw->aq.asq.head));
 
 		if (details->callback) {
@@ -835,7 +835,7 @@ i40e_status i40e_asq_send_command(struct i40e_hw *hw,
 	}
 
 	/* bump the tail */
-	i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE, "AQTX: desc and buffer:\n");
+	i40e_debug(hw, I40E_DEBUG_AQ_COMMAND, "AQTX: desc and buffer:\n");
 	i40e_debug_aq(hw, I40E_DEBUG_AQ_COMMAND, (void *)desc_on_ring,
 		      buff, buff_size);
 	(hw->aq.asq.next_to_use)++;
@@ -886,7 +886,7 @@ i40e_status i40e_asq_send_command(struct i40e_hw *hw,
 		hw->aq.asq_last_status = (enum i40e_admin_queue_err)retval;
 	}
 
-	i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
+	i40e_debug(hw, I40E_DEBUG_AQ_COMMAND,
 		   "AQTX: desc and buffer writeback:\n");
 	i40e_debug_aq(hw, I40E_DEBUG_AQ_COMMAND, (void *)desc, buff, buff_size);
 
@@ -995,7 +995,7 @@ i40e_status i40e_clean_arq_element(struct i40e_hw *hw,
 		memcpy(e->msg_buf, hw->aq.arq.r.arq_bi[desc_idx].va,
 		       e->msg_len);
 
-	i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE, "AQRX: desc and buffer:\n");
+	i40e_debug(hw, I40E_DEBUG_AQ_COMMAND, "AQRX: desc and buffer:\n");
 	i40e_debug_aq(hw, I40E_DEBUG_AQ_COMMAND, (void *)desc, e->msg_buf,
 		      hw->aq.arq_buf_size);
 
diff --git a/drivers/net/ethernet/intel/i40e/i40e_common.c b/drivers/net/ethernet/intel/i40e/i40e_common.c
index ecb1adaa54ec..641b500ad919 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_common.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_common.c
@@ -281,47 +281,49 @@ void i40e_debug_aq(struct i40e_hw *hw, enum i40e_debug_mask mask, void *desc,
 		   void *buffer, u16 buf_len)
 {
 	struct i40e_aq_desc *aq_desc = (struct i40e_aq_desc *)desc;
+	u32 effective_mask = hw->debug_mask & mask;
+	char prefix[27];
 	u16 len;
 	u8 *buf = (u8 *)buffer;
 
-	if ((!(mask & hw->debug_mask)) || (desc == NULL))
+	if (!effective_mask || !desc)
 		return;
 
 	len = le16_to_cpu(aq_desc->datalen);
 
-	i40e_debug(hw, mask,
+	i40e_debug(hw, mask & I40E_DEBUG_AQ_DESCRIPTOR,
 		   "AQ CMD: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n",
 		   le16_to_cpu(aq_desc->opcode),
 		   le16_to_cpu(aq_desc->flags),
 		   le16_to_cpu(aq_desc->datalen),
 		   le16_to_cpu(aq_desc->retval));
-	i40e_debug(hw, mask, "\tcookie (h,l) 0x%08X 0x%08X\n",
+	i40e_debug(hw, mask & I40E_DEBUG_AQ_DESCRIPTOR,
+		   "\tcookie (h,l) 0x%08X 0x%08X\n",
 		   le32_to_cpu(aq_desc->cookie_high),
 		   le32_to_cpu(aq_desc->cookie_low));
-	i40e_debug(hw, mask, "\tparam (0,1)  0x%08X 0x%08X\n",
+	i40e_debug(hw, mask & I40E_DEBUG_AQ_DESCRIPTOR,
+		   "\tparam (0,1)  0x%08X 0x%08X\n",
 		   le32_to_cpu(aq_desc->params.internal.param0),
 		   le32_to_cpu(aq_desc->params.internal.param1));
-	i40e_debug(hw, mask, "\taddr (h,l)   0x%08X 0x%08X\n",
+	i40e_debug(hw, mask & I40E_DEBUG_AQ_DESCRIPTOR,
+		   "\taddr (h,l)   0x%08X 0x%08X\n",
 		   le32_to_cpu(aq_desc->params.external.addr_high),
 		   le32_to_cpu(aq_desc->params.external.addr_low));
 
-	if ((buffer != NULL) && (aq_desc->datalen != 0)) {
+	if (buffer && buf_len != 0 && len != 0 &&
+	    (effective_mask & I40E_DEBUG_AQ_DESC_BUFFER)) {
 		i40e_debug(hw, mask, "AQ CMD Buffer:\n");
 		if (buf_len < len)
 			len = buf_len;
-		/* write the full 16-byte chunks */
-		if (hw->debug_mask & mask) {
-			char prefix[27];
-
-			snprintf(prefix, sizeof(prefix),
-				 "i40e %02x:%02x.%x: \t0x",
-				 hw->bus.bus_id,
-				 hw->bus.device,
-				 hw->bus.func);
-
-			print_hex_dump(KERN_INFO, prefix, DUMP_PREFIX_OFFSET,
-				       16, 1, buf, len, false);
-		}
+
+		snprintf(prefix, sizeof(prefix),
+			 "i40e %02x:%02x.%x: \t0x",
+			 hw->bus.bus_id,
+			 hw->bus.device,
+			 hw->bus.func);
+
+		print_hex_dump(KERN_INFO, prefix, DUMP_PREFIX_OFFSET,
+			       16, 1, buf, len, false);
 	}
 }
 
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [next PATCH S5 06/10] i40e: add input validation for virtchnl handlers
  2019-04-24 12:20 [Intel-wired-lan] [next PATCH S5 01/10] i40e: let untrusted VF to create up to 16 VLANs Alice Michael
                   ` (3 preceding siblings ...)
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 05/10] i40e: Improve AQ log granularity Alice Michael
@ 2019-04-24 12:20 ` Alice Michael
  2019-05-03 23:38   ` Bowers, AndrewX
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 07/10] i40e: Missing response checks in driver when starting/stopping FW LLDP Alice Michael
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 20+ messages in thread
From: Alice Michael @ 2019-04-24 12:20 UTC (permalink / raw)
  To: intel-wired-lan

From: Sergey Nemov <sergey.nemov@intel.com>

Change some data to unsigned int instead of integer when we compare.

Check LUT values in VIRTCHNL_OP_CONFIG_RSS_LUT handler.

Also enhance error/warning messages to print the real values of
I40E_MAX_VF_QUEUES, I40E_MAX_VF_VSI and I40E_DEFAULT_QUEUES_PER_VF
instead of plain text.

Refactor code to comply with 'check first then assign' policy.

Remove duplicate checks for VIRTCHNL_OP_CONFIG_RSS_KEY and
VIRTCHNL_OP_CONFIG_RSS_LUT opcodes in i40e_vc_process_vf_msg(). We have
the very same checks inside the handlers already.

Signed-off-by: Sergey Nemov <sergey.nemov@intel.com>
---
 .../ethernet/intel/i40e/i40e_virtchnl_pf.c    | 74 ++++++++-----------
 1 file changed, 31 insertions(+), 43 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index 4061da6c9dcb..4f4521d39725 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -470,14 +470,15 @@ static int i40e_config_iwarp_qvlist(struct i40e_vf *vf,
 		qv_info = &qvlist_info->qv_info[i];
 		if (!qv_info)
 			continue;
-		v_idx = qv_info->v_idx;
 
 		/* Validate vector id belongs to this vf */
-		if (!i40e_vc_isvalid_vector_id(vf, v_idx)) {
+		if (!i40e_vc_isvalid_vector_id(vf, qv_info->v_idx)) {
 			ret = -EINVAL;
 			goto err_free;
 		}
 
+		v_idx = qv_info->v_idx;
+
 		vf->qvlist_info->qv_info[i] = *qv_info;
 
 		reg_idx = ((msix_vf - 1) * vf->vf_id) + (v_idx - 1);
@@ -2327,7 +2328,6 @@ static int i40e_vc_enable_queues_msg(struct i40e_vf *vf, u8 *msg)
 	struct virtchnl_queue_select *vqs =
 	    (struct virtchnl_queue_select *)msg;
 	struct i40e_pf *pf = vf->pf;
-	u16 vsi_id = vqs->vsi_id;
 	i40e_status aq_ret = 0;
 	int i;
 
@@ -2336,7 +2336,7 @@ static int i40e_vc_enable_queues_msg(struct i40e_vf *vf, u8 *msg)
 		goto error_param;
 	}
 
-	if (!i40e_vc_isvalid_vsi_id(vf, vsi_id)) {
+	if (!i40e_vc_isvalid_vsi_id(vf, vqs->vsi_id)) {
 		aq_ret = I40E_ERR_PARAM;
 		goto error_param;
 	}
@@ -2436,18 +2436,14 @@ static int i40e_vc_request_queues_msg(struct i40e_vf *vf, u8 *msg)
 {
 	struct virtchnl_vf_res_request *vfres =
 		(struct virtchnl_vf_res_request *)msg;
-	int req_pairs = vfres->num_queue_pairs;
-	int cur_pairs = vf->num_queue_pairs;
+	u16 req_pairs = vfres->num_queue_pairs;
+	u8 cur_pairs = vf->num_queue_pairs;
 	struct i40e_pf *pf = vf->pf;
 
 	if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states))
 		return -EINVAL;
 
-	if (req_pairs <= 0) {
-		dev_err(&pf->pdev->dev,
-			"VF %d tried to request %d queues.  Ignoring.\n",
-			vf->vf_id, req_pairs);
-	} else if (req_pairs > I40E_MAX_VF_QUEUES) {
+	if (req_pairs > I40E_MAX_VF_QUEUES) {
 		dev_err(&pf->pdev->dev,
 			"VF %d tried to request more than %d queues.\n",
 			vf->vf_id,
@@ -2596,12 +2592,11 @@ static int i40e_vc_add_mac_addr_msg(struct i40e_vf *vf, u8 *msg)
 	    (struct virtchnl_ether_addr_list *)msg;
 	struct i40e_pf *pf = vf->pf;
 	struct i40e_vsi *vsi = NULL;
-	u16 vsi_id = al->vsi_id;
 	i40e_status ret = 0;
 	int i;
 
 	if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
-	    !i40e_vc_isvalid_vsi_id(vf, vsi_id)) {
+	    !i40e_vc_isvalid_vsi_id(vf, al->vsi_id)) {
 		ret = I40E_ERR_PARAM;
 		goto error_param;
 	}
@@ -2666,12 +2661,11 @@ static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg)
 	    (struct virtchnl_ether_addr_list *)msg;
 	struct i40e_pf *pf = vf->pf;
 	struct i40e_vsi *vsi = NULL;
-	u16 vsi_id = al->vsi_id;
 	i40e_status ret = 0;
 	int i;
 
 	if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
-	    !i40e_vc_isvalid_vsi_id(vf, vsi_id)) {
+	    !i40e_vc_isvalid_vsi_id(vf, al->vsi_id)) {
 		ret = I40E_ERR_PARAM;
 		goto error_param;
 	}
@@ -2735,7 +2729,6 @@ static int i40e_vc_add_vlan_msg(struct i40e_vf *vf, u8 *msg)
 	    (struct virtchnl_vlan_filter_list *)msg;
 	struct i40e_pf *pf = vf->pf;
 	struct i40e_vsi *vsi = NULL;
-	u16 vsi_id = vfl->vsi_id;
 	i40e_status aq_ret = 0;
 	int i;
 
@@ -2746,7 +2739,7 @@ static int i40e_vc_add_vlan_msg(struct i40e_vf *vf, u8 *msg)
 		goto error_param;
 	}
 	if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
-	    !i40e_vc_isvalid_vsi_id(vf, vsi_id)) {
+	    !i40e_vc_isvalid_vsi_id(vf, vfl->vsi_id)) {
 		aq_ret = I40E_ERR_PARAM;
 		goto error_param;
 	}
@@ -2807,12 +2800,11 @@ static int i40e_vc_remove_vlan_msg(struct i40e_vf *vf, u8 *msg)
 	    (struct virtchnl_vlan_filter_list *)msg;
 	struct i40e_pf *pf = vf->pf;
 	struct i40e_vsi *vsi = NULL;
-	u16 vsi_id = vfl->vsi_id;
 	i40e_status aq_ret = 0;
 	int i;
 
 	if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
-	    !i40e_vc_isvalid_vsi_id(vf, vsi_id)) {
+	    !i40e_vc_isvalid_vsi_id(vf, vfl->vsi_id)) {
 		aq_ret = I40E_ERR_PARAM;
 		goto error_param;
 	}
@@ -2929,11 +2921,10 @@ static int i40e_vc_config_rss_key(struct i40e_vf *vf, u8 *msg)
 		(struct virtchnl_rss_key *)msg;
 	struct i40e_pf *pf = vf->pf;
 	struct i40e_vsi *vsi = NULL;
-	u16 vsi_id = vrk->vsi_id;
 	i40e_status aq_ret = 0;
 
 	if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
-	    !i40e_vc_isvalid_vsi_id(vf, vsi_id) ||
+	    !i40e_vc_isvalid_vsi_id(vf, vrk->vsi_id) ||
 	    (vrk->key_len != I40E_HKEY_ARRAY_SIZE)) {
 		aq_ret = I40E_ERR_PARAM;
 		goto err;
@@ -2960,16 +2951,22 @@ static int i40e_vc_config_rss_lut(struct i40e_vf *vf, u8 *msg)
 		(struct virtchnl_rss_lut *)msg;
 	struct i40e_pf *pf = vf->pf;
 	struct i40e_vsi *vsi = NULL;
-	u16 vsi_id = vrl->vsi_id;
 	i40e_status aq_ret = 0;
+	u16 i;
 
 	if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
-	    !i40e_vc_isvalid_vsi_id(vf, vsi_id) ||
+	    !i40e_vc_isvalid_vsi_id(vf, vrl->vsi_id) ||
 	    (vrl->lut_entries != I40E_VF_HLUT_ARRAY_SIZE)) {
 		aq_ret = I40E_ERR_PARAM;
 		goto err;
 	}
 
+	for (i = 0; i < vrl->lut_entries; i++)
+		if (vrl->lut[i] >= vf->num_queue_pairs) {
+			aq_ret = I40E_ERR_PARAM;
+			goto err;
+		}
+
 	vsi = pf->vsi[vf->lan_vsi_idx];
 	aq_ret = i40e_config_rss(vsi, NULL, vrl->lut, I40E_VF_HLUT_ARRAY_SIZE);
 	/* send the response to the VF */
@@ -3050,14 +3047,15 @@ static int i40e_vc_set_rss_hena(struct i40e_vf *vf, u8 *msg)
  **/
 static int i40e_vc_enable_vlan_stripping(struct i40e_vf *vf, u8 *msg)
 {
-	struct i40e_vsi *vsi = vf->pf->vsi[vf->lan_vsi_idx];
 	i40e_status aq_ret = 0;
+	struct i40e_vsi *vsi;
 
 	if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
 		aq_ret = I40E_ERR_PARAM;
 		goto err;
 	}
 
+	vsi = vf->pf->vsi[vf->lan_vsi_idx];
 	i40e_vlan_stripping_enable(vsi);
 
 	/* send the response to the VF */
@@ -3075,14 +3073,15 @@ static int i40e_vc_enable_vlan_stripping(struct i40e_vf *vf, u8 *msg)
  **/
 static int i40e_vc_disable_vlan_stripping(struct i40e_vf *vf, u8 *msg)
 {
-	struct i40e_vsi *vsi = vf->pf->vsi[vf->lan_vsi_idx];
 	i40e_status aq_ret = 0;
+	struct i40e_vsi *vsi;
 
 	if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
 		aq_ret = I40E_ERR_PARAM;
 		goto err;
 	}
 
+	vsi = vf->pf->vsi[vf->lan_vsi_idx];
 	i40e_vlan_stripping_disable(vsi);
 
 	/* send the response to the VF */
@@ -3540,8 +3539,9 @@ static int i40e_vc_add_qch_msg(struct i40e_vf *vf, u8 *msg)
 		(struct virtchnl_tc_info *)msg;
 	struct i40e_pf *pf = vf->pf;
 	struct i40e_link_status *ls = &pf->hw.phy.link_info;
-	int i, adq_request_qps = 0, speed = 0;
+	int i, adq_request_qps = 0;
 	i40e_status aq_ret = 0;
+	u64 speed = 0;
 
 	if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
 		aq_ret = I40E_ERR_PARAM;
@@ -3567,8 +3567,8 @@ static int i40e_vc_add_qch_msg(struct i40e_vf *vf, u8 *msg)
 	/* max number of traffic classes for VF currently capped at 4 */
 	if (!tci->num_tc || tci->num_tc > I40E_MAX_VF_VSI) {
 		dev_err(&pf->pdev->dev,
-			"VF %d trying to set %u TCs, valid range 1-4 TCs per VF\n",
-			vf->vf_id, tci->num_tc);
+			"VF %d trying to set %u TCs, valid range 1-%u TCs per VF\n",
+			vf->vf_id, tci->num_tc, I40E_MAX_VF_VSI);
 		aq_ret = I40E_ERR_PARAM;
 		goto err;
 	}
@@ -3578,8 +3578,9 @@ static int i40e_vc_add_qch_msg(struct i40e_vf *vf, u8 *msg)
 		if (!tci->list[i].count ||
 		    tci->list[i].count > I40E_DEFAULT_QUEUES_PER_VF) {
 			dev_err(&pf->pdev->dev,
-				"VF %d: TC %d trying to set %u queues, valid range 1-4 queues per TC\n",
-				vf->vf_id, i, tci->list[i].count);
+				"VF %d: TC %d trying to set %u queues, valid range 1-%u queues per TC\n",
+				vf->vf_id, i, tci->list[i].count,
+				I40E_DEFAULT_QUEUES_PER_VF);
 			aq_ret = I40E_ERR_PARAM;
 			goto err;
 		}
@@ -3739,19 +3740,6 @@ int i40e_vc_process_vf_msg(struct i40e_pf *pf, s16 vf_id, u32 v_opcode,
 	/* perform basic checks on the msg */
 	ret = virtchnl_vc_validate_vf_msg(&vf->vf_ver, v_opcode, msg, msglen);
 
-	/* perform additional checks specific to this driver */
-	if (v_opcode == VIRTCHNL_OP_CONFIG_RSS_KEY) {
-		struct virtchnl_rss_key *vrk = (struct virtchnl_rss_key *)msg;
-
-		if (vrk->key_len != I40E_HKEY_ARRAY_SIZE)
-			ret = -EINVAL;
-	} else if (v_opcode == VIRTCHNL_OP_CONFIG_RSS_LUT) {
-		struct virtchnl_rss_lut *vrl = (struct virtchnl_rss_lut *)msg;
-
-		if (vrl->lut_entries != I40E_VF_HLUT_ARRAY_SIZE)
-			ret = -EINVAL;
-	}
-
 	if (ret) {
 		i40e_vc_send_resp_to_vf(vf, v_opcode, I40E_ERR_PARAM);
 		dev_err(&pf->pdev->dev, "Invalid message from VF %d, opcode %d, len %d\n",
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [next PATCH S5 07/10] i40e: Missing response checks in driver when starting/stopping FW LLDP
  2019-04-24 12:20 [Intel-wired-lan] [next PATCH S5 01/10] i40e: let untrusted VF to create up to 16 VLANs Alice Michael
                   ` (4 preceding siblings ...)
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 06/10] i40e: add input validation for virtchnl handlers Alice Michael
@ 2019-04-24 12:20 ` Alice Michael
  2019-05-03 23:38   ` Bowers, AndrewX
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 08/10] i40e: Check if the BAR size is large enough before writing to registers Alice Michael
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 20+ messages in thread
From: Alice Michael @ 2019-04-24 12:20 UTC (permalink / raw)
  To: intel-wired-lan

From: Piotr Marczak <piotr.marczak@intel.com>

Driver did not check response on LLDP flag change and always returned
SUCCESS.

This patch now checks for an error and returns an error code and has
additional information in the log.

Signed-off-by: Piotr Marczak <piotr.marczak@intel.com>
---
 .../net/ethernet/intel/i40e/i40e_ethtool.c    | 27 +++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
index 7f7d04ab1515..0837c6b3e15e 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -4852,9 +4852,11 @@ static u32 i40e_get_priv_flags(struct net_device *dev)
 static int i40e_set_priv_flags(struct net_device *dev, u32 flags)
 {
 	struct i40e_netdev_priv *np = netdev_priv(dev);
+	u64 orig_flags, new_flags, changed_flags;
+	enum i40e_admin_queue_err adq_err;
 	struct i40e_vsi *vsi = np->vsi;
 	struct i40e_pf *pf = vsi->back;
-	u64 orig_flags, new_flags, changed_flags;
+	i40e_status status;
 	u32 i, j;
 
 	orig_flags = READ_ONCE(pf->flags);
@@ -5013,7 +5015,28 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)
 			dcbcfg->pfc.willing = 1;
 			dcbcfg->pfc.pfccap = I40E_MAX_TRAFFIC_CLASS;
 		} else {
-			i40e_aq_start_lldp(&pf->hw, false, NULL);
+			status = i40e_aq_start_lldp(&pf->hw, false, NULL);
+			if (status) {
+				adq_err = pf->hw.aq.asq_last_status;
+				switch (adq_err) {
+				case I40E_AQ_RC_EEXIST:
+					dev_warn(&pf->pdev->dev,
+						 "FW LLDP agent is already running\n");
+					return 0;
+				case I40E_AQ_RC_EPERM:
+					dev_warn(&pf->pdev->dev,
+						 "Device configuration forbids SW from starting the LLDP agent.\n");
+					return (-EINVAL);
+				default:
+					dev_warn(&pf->pdev->dev,
+						 "Starting FW LLDP agent failed: error: %s, %s\n",
+						 i40e_stat_str(&pf->hw,
+							       status),
+						 i40e_aq_str(&pf->hw,
+							     adq_err));
+					return (-EINVAL);
+				}
+			}
 		}
 	}
 
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [next PATCH S5 08/10] i40e: Check if the BAR size is large enough before writing to registers
  2019-04-24 12:20 [Intel-wired-lan] [next PATCH S5 01/10] i40e: let untrusted VF to create up to 16 VLANs Alice Michael
                   ` (5 preceding siblings ...)
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 07/10] i40e: Missing response checks in driver when starting/stopping FW LLDP Alice Michael
@ 2019-04-24 12:20 ` Alice Michael
  2019-05-03 23:39   ` Bowers, AndrewX
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 09/10] i40e: remove duplicate stat calculation for tx_errors Alice Michael
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 20+ messages in thread
From: Alice Michael @ 2019-04-24 12:20 UTC (permalink / raw)
  To: intel-wired-lan

From: Adam Ludkiewicz <adam.ludkiewicz@intel.com>

This patch fixes the problem with a kernel panic occurring when trying
to bind the i40e driver to a non-i40e port. The problem is fixed by
checking if the BAR size in the device is large enough by reading the
highest register.

Signed-off-by: Adam Ludkiewicz <adam.ludkiewicz@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 5716f8fe06ed..d640da4a8835 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -14696,7 +14696,17 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	pf->ioremap_len = min_t(int, pci_resource_len(pdev, 0),
 				I40E_MAX_CSR_SPACE);
-
+	/* We believe that the highest register to read is
+	 * I40E_GLGEN_STAT_CLEAR, so we check if the BAR size
+	 * is not less than that before mapping to prevent a
+	 * kernel panic.
+	 */
+	if (pf->ioremap_len < I40E_GLGEN_STAT_CLEAR) {
+		dev_err(&pdev->dev, "Cannot map registers, bar size 0x%X too small, aborting\n",
+			pf->ioremap_len);
+		err = -ENOMEM;
+		goto err_ioremap;
+	}
 	hw->hw_addr = ioremap(pci_resource_start(pdev, 0), pf->ioremap_len);
 	if (!hw->hw_addr) {
 		err = -EIO;
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [next PATCH S5 09/10] i40e: remove duplicate stat calculation for tx_errors
  2019-04-24 12:20 [Intel-wired-lan] [next PATCH S5 01/10] i40e: let untrusted VF to create up to 16 VLANs Alice Michael
                   ` (6 preceding siblings ...)
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 08/10] i40e: Check if the BAR size is large enough before writing to registers Alice Michael
@ 2019-04-24 12:20 ` Alice Michael
  2019-05-03 23:39   ` Bowers, AndrewX
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 10/10] i40e: Missing response checks in driver when starting/stopping FW LLDP Alice Michael
  2019-05-03 23:31 ` [Intel-wired-lan] [next PATCH S5 01/10] i40e: let untrusted VF to create up to 16 VLANs Bowers, AndrewX
  9 siblings, 1 reply; 20+ messages in thread
From: Alice Michael @ 2019-04-24 12:20 UTC (permalink / raw)
  To: intel-wired-lan

From: Jacob Keller <jacob.e.keller@intel.com>

The tx_errors statistic was being calculated twice in
i40e_update_eth_stats.

This appears to be as of commit 201db2898f2c ("i40e: add missing VSI
statistics", 2014-03-25).

Remove the extra i40e_stat_update32 call for GLV_TEPC.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index d640da4a8835..3a0c77cd7a44 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -636,9 +636,6 @@ void i40e_update_eth_stats(struct i40e_vsi *vsi)
 	i40e_stat_update32(hw, I40E_GLV_RUPP(stat_idx),
 			   vsi->stat_offsets_loaded,
 			   &oes->rx_unknown_protocol, &es->rx_unknown_protocol);
-	i40e_stat_update32(hw, I40E_GLV_TEPC(stat_idx),
-			   vsi->stat_offsets_loaded,
-			   &oes->tx_errors, &es->tx_errors);
 
 	i40e_stat_update48(hw, I40E_GLV_GORCH(stat_idx),
 			   I40E_GLV_GORCL(stat_idx),
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [next PATCH S5 10/10] i40e: Missing response checks in driver when starting/stopping FW LLDP
  2019-04-24 12:20 [Intel-wired-lan] [next PATCH S5 01/10] i40e: let untrusted VF to create up to 16 VLANs Alice Michael
                   ` (7 preceding siblings ...)
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 09/10] i40e: remove duplicate stat calculation for tx_errors Alice Michael
@ 2019-04-24 12:20 ` Alice Michael
  2019-05-03 23:40   ` Bowers, AndrewX
  2019-05-03 23:31 ` [Intel-wired-lan] [next PATCH S5 01/10] i40e: let untrusted VF to create up to 16 VLANs Bowers, AndrewX
  9 siblings, 1 reply; 20+ messages in thread
From: Alice Michael @ 2019-04-24 12:20 UTC (permalink / raw)
  To: intel-wired-lan

From: Aleksandr Loktionov <aleksandr.loktionov@intel.com>

Driver updated pf->flags before calling i40e_aq_start_lldp().
This patch moved down updating pf->flags down so flags will be
updated only in case of successful i40e_aq_start_lldp() call.
Also was introduced is_reset_needed local flag to avoid unnecessary h/w
reset in case 40e_aq_start_lldp() didn't change lldp state.

Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
---
 .../net/ethernet/intel/i40e/i40e_ethtool.c    | 45 ++++++++++---------
 1 file changed, 24 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
index 0837c6b3e15e..bc70b0d581a1 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -4856,6 +4856,7 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)
 	enum i40e_admin_queue_err adq_err;
 	struct i40e_vsi *vsi = np->vsi;
 	struct i40e_pf *pf = vsi->back;
+	bool is_reset_needed;
 	i40e_status status;
 	u32 i, j;
 
@@ -4900,6 +4901,10 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)
 flags_complete:
 	changed_flags = orig_flags ^ new_flags;
 
+	is_reset_needed = !!(changed_flags & (I40E_FLAG_VEB_STATS_ENABLED |
+		I40E_FLAG_LEGACY_RX | I40E_FLAG_SOURCE_PRUNING_DISABLED |
+		I40E_FLAG_DISABLE_FW_LLDP));
+
 	/* Before we finalize any flag changes, we need to perform some
 	 * checks to ensure that the changes are supported and safe.
 	 */
@@ -4934,13 +4939,6 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)
 		return -EOPNOTSUPP;
 	}
 
-	/* Now that we've checked to ensure that the new flags are valid, load
-	 * them into place. Since we only modify flags either (a) during
-	 * initialization or (b) while holding the RTNL lock, we don't need
-	 * anything fancy here.
-	 */
-	pf->flags = new_flags;
-
 	/* Process any additional changes needed as a result of flag changes.
 	 * The changed_flags value reflects the list of bits that were
 	 * changed in the code above.
@@ -4948,7 +4946,7 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)
 
 	/* Flush current ATR settings if ATR was disabled */
 	if ((changed_flags & I40E_FLAG_FD_ATR_ENABLED) &&
-	    !(pf->flags & I40E_FLAG_FD_ATR_ENABLED)) {
+	    !(new_flags & I40E_FLAG_FD_ATR_ENABLED)) {
 		set_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state);
 		set_bit(__I40E_FD_FLUSH_REQUESTED, pf->state);
 	}
@@ -4957,7 +4955,7 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)
 		u16 sw_flags = 0, valid_flags = 0;
 		int ret;
 
-		if (!(pf->flags & I40E_FLAG_TRUE_PROMISC_SUPPORT))
+		if (!(new_flags & I40E_FLAG_TRUE_PROMISC_SUPPORT))
 			sw_flags = I40E_AQ_SET_SWITCH_CFG_PROMISC;
 		valid_flags = I40E_AQ_SET_SWITCH_CFG_PROMISC;
 		ret = i40e_aq_set_switch_config(&pf->hw, sw_flags, valid_flags,
@@ -4976,13 +4974,13 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)
 	    (changed_flags & I40E_FLAG_BASE_R_FEC)) {
 		u8 fec_cfg = 0;
 
-		if (pf->flags & I40E_FLAG_RS_FEC &&
-		    pf->flags & I40E_FLAG_BASE_R_FEC) {
+		if (new_flags & I40E_FLAG_RS_FEC &&
+		    new_flags & I40E_FLAG_BASE_R_FEC) {
 			fec_cfg = I40E_AQ_SET_FEC_AUTO;
-		} else if (pf->flags & I40E_FLAG_RS_FEC) {
+		} else if (new_flags & I40E_FLAG_RS_FEC) {
 			fec_cfg = (I40E_AQ_SET_FEC_REQUEST_RS |
 				   I40E_AQ_SET_FEC_ABILITY_RS);
-		} else if (pf->flags & I40E_FLAG_BASE_R_FEC) {
+		} else if (new_flags & I40E_FLAG_BASE_R_FEC) {
 			fec_cfg = (I40E_AQ_SET_FEC_REQUEST_KR |
 				   I40E_AQ_SET_FEC_ABILITY_KR);
 		}
@@ -4990,14 +4988,14 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)
 			dev_warn(&pf->pdev->dev, "Cannot change FEC config\n");
 	}
 
-	if ((changed_flags & pf->flags &
+	if ((changed_flags & new_flags &
 	     I40E_FLAG_LINK_DOWN_ON_CLOSE_ENABLED) &&
-	    (pf->flags & I40E_FLAG_MFP_ENABLED))
+	    (new_flags & I40E_FLAG_MFP_ENABLED))
 		dev_warn(&pf->pdev->dev,
 			 "Turning on link-down-on-close flag may affect other partitions\n");
 
 	if (changed_flags & I40E_FLAG_DISABLE_FW_LLDP) {
-		if (pf->flags & I40E_FLAG_DISABLE_FW_LLDP) {
+		if (new_flags & I40E_FLAG_DISABLE_FW_LLDP) {
 			struct i40e_dcbx_config *dcbcfg;
 
 			i40e_aq_stop_lldp(&pf->hw, true, false, NULL);
@@ -5022,7 +5020,8 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)
 				case I40E_AQ_RC_EEXIST:
 					dev_warn(&pf->pdev->dev,
 						 "FW LLDP agent is already running\n");
-					return 0;
+					is_reset_needed = false;
+					break;
 				case I40E_AQ_RC_EPERM:
 					dev_warn(&pf->pdev->dev,
 						 "Device configuration forbids SW from starting the LLDP agent.\n");
@@ -5040,13 +5039,17 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)
 		}
 	}
 
+	/* Now that we've checked to ensure that the new flags are valid, load
+	 * them into place. Since we only modify flags either (a) during
+	 * initialization or (b) while holding the RTNL lock, we don't need
+	 * anything fancy here.
+	 */
+	pf->flags = new_flags;
+
 	/* Issue reset to cause things to take effect, as additional bits
 	 * are added we will need to create a mask of bits requiring reset
 	 */
-	if (changed_flags & (I40E_FLAG_VEB_STATS_ENABLED |
-			     I40E_FLAG_LEGACY_RX |
-			     I40E_FLAG_SOURCE_PRUNING_DISABLED |
-			     I40E_FLAG_DISABLE_FW_LLDP))
+	if (is_reset_needed)
 		i40e_do_reset(pf, BIT(__I40E_PF_RESET_REQUESTED), true);
 
 	return 0;
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [next PATCH S5 01/10] i40e: let untrusted VF to create up to 16 VLANs
  2019-04-24 12:20 [Intel-wired-lan] [next PATCH S5 01/10] i40e: let untrusted VF to create up to 16 VLANs Alice Michael
                   ` (8 preceding siblings ...)
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 10/10] i40e: Missing response checks in driver when starting/stopping FW LLDP Alice Michael
@ 2019-05-03 23:31 ` Bowers, AndrewX
  9 siblings, 0 replies; 20+ messages in thread
From: Bowers, AndrewX @ 2019-05-03 23:31 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Alice Michael
> Sent: Wednesday, April 24, 2019 5:21 AM
> To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> lan at lists.osuosl.org
> Cc: Kwapulinski, Piotr <piotr.kwapulinski@intel.com>
> Subject: [Intel-wired-lan] [next PATCH S5 01/10] i40e: let untrusted VF to
> create up to 16 VLANs
> 
> From: Piotr Kwapulinski <piotr.kwapulinski@intel.com>
> 
> This patch lets untrusted VF to create up to 16 VLANs.
> It was implemented by increasing I40E_VC_MAX_VLAN_PER_VF up to 16.
> Without this patch untrusted VF could create only up to 8 VLANs.
> 
> Signed-off-by: Piotr Kwapulinski <piotr.kwapulinski@intel.com>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [next PATCH S5 02/10] i40e: add constraints for accessing veb array
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 02/10] i40e: add constraints for accessing veb array Alice Michael
@ 2019-05-03 23:35   ` Bowers, AndrewX
  0 siblings, 0 replies; 20+ messages in thread
From: Bowers, AndrewX @ 2019-05-03 23:35 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Alice Michael
> Sent: Wednesday, April 24, 2019 5:21 AM
> To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> lan at lists.osuosl.org
> Cc: Kwapulinski, Piotr <piotr.kwapulinski@intel.com>
> Subject: [Intel-wired-lan] [next PATCH S5 02/10] i40e: add constraints for
> accessing veb array
> 
> From: Piotr Kwapulinski <piotr.kwapulinski@intel.com>
> 
> Add veb array access boundary checks.
> Ensure veb array index is smaller than I40E_MAX_VEB.
> 
> Signed-off-by: Piotr Kwapulinski <piotr.kwapulinski@intel.com>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_main.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [next PATCH S5 03/10] i40e: Use signed variable
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 03/10] i40e: Use signed variable Alice Michael
@ 2019-05-03 23:36   ` Bowers, AndrewX
  0 siblings, 0 replies; 20+ messages in thread
From: Bowers, AndrewX @ 2019-05-03 23:36 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Alice Michael
> Sent: Wednesday, April 24, 2019 5:21 AM
> To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> lan at lists.osuosl.org
> Subject: [Intel-wired-lan] [next PATCH S5 03/10] i40e: Use signed variable
> 
> From: Mitch Williams <mitch.a.williams@intel.com>
> 
> The counter variable in i40e_clean_tx_irq starts out negative and climbs to 0.
> So it should not be defined as a u16. This was working by accident due to the
> fact the u16 overflows and underflows predictably.
> 
> Replace the u16 with int, which is signed and can handle the negativity.
> 
> Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_txrx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [next PATCH S5 04/10] i40e: Add bounds check for ch[] array
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 04/10] i40e: Add bounds check for ch[] array Alice Michael
@ 2019-05-03 23:37   ` Bowers, AndrewX
  0 siblings, 0 replies; 20+ messages in thread
From: Bowers, AndrewX @ 2019-05-03 23:37 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Alice Michael
> Sent: Wednesday, April 24, 2019 5:21 AM
> To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> lan at lists.osuosl.org
> Cc: Kwapulinski, Piotr <piotr.kwapulinski@intel.com>
> Subject: [Intel-wired-lan] [next PATCH S5 04/10] i40e: Add bounds check for
> ch[] array
> 
> From: Piotr Kwapulinski <piotr.kwapulinski@intel.com>
> 
> Add bounds check for ch[] array.
> Use ARRAY_SIZE() to ensure that idx is within the range.
> 
> Signed-off-by: Piotr Kwapulinski <piotr.kwapulinski@intel.com>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [next PATCH S5 05/10] i40e: Improve AQ log granularity
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 05/10] i40e: Improve AQ log granularity Alice Michael
@ 2019-05-03 23:38   ` Bowers, AndrewX
  0 siblings, 0 replies; 20+ messages in thread
From: Bowers, AndrewX @ 2019-05-03 23:38 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Alice Michael
> Sent: Wednesday, April 24, 2019 5:21 AM
> To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> lan at lists.osuosl.org
> Cc: Dziggel, Douglas A <douglas.a.dziggel@intel.com>
> Subject: [Intel-wired-lan] [next PATCH S5 05/10] i40e: Improve AQ log
> granularity
> 
> From: Doug Dziggel <douglas.a.dziggel@intel.com>
> 
> This patch makes it possible to log only AQ descriptors, without the entire AQ
> message buffers being dumped too. It should greatly reduce kernel log size
> in cases where a full AQ dump is not needed.
> Selection is made by setting flags in hw->debug_mask.
> 
> Additionally, some debug messages that preceded an AQ dump have been
> moved to I40E_DEBUG_AQ_COMMAND class, which seems more
> appropriate.
> 
> Signed-off-by: Doug Dziggel <douglas.a.dziggel@intel.com>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_adminq.c |  8 ++--
> drivers/net/ethernet/intel/i40e/i40e_common.c | 40 ++++++++++---------
>  2 files changed, 25 insertions(+), 23 deletions(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [next PATCH S5 06/10] i40e: add input validation for virtchnl handlers
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 06/10] i40e: add input validation for virtchnl handlers Alice Michael
@ 2019-05-03 23:38   ` Bowers, AndrewX
  0 siblings, 0 replies; 20+ messages in thread
From: Bowers, AndrewX @ 2019-05-03 23:38 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Alice Michael
> Sent: Wednesday, April 24, 2019 5:21 AM
> To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> lan at lists.osuosl.org
> Subject: [Intel-wired-lan] [next PATCH S5 06/10] i40e: add input validation for
> virtchnl handlers
> 
> From: Sergey Nemov <sergey.nemov@intel.com>
> 
> Change some data to unsigned int instead of integer when we compare.
> 
> Check LUT values in VIRTCHNL_OP_CONFIG_RSS_LUT handler.
> 
> Also enhance error/warning messages to print the real values of
> I40E_MAX_VF_QUEUES, I40E_MAX_VF_VSI and
> I40E_DEFAULT_QUEUES_PER_VF instead of plain text.
> 
> Refactor code to comply with 'check first then assign' policy.
> 
> Remove duplicate checks for VIRTCHNL_OP_CONFIG_RSS_KEY and
> VIRTCHNL_OP_CONFIG_RSS_LUT opcodes in i40e_vc_process_vf_msg(). We
> have the very same checks inside the handlers already.
> 
> Signed-off-by: Sergey Nemov <sergey.nemov@intel.com>
> ---
>  .../ethernet/intel/i40e/i40e_virtchnl_pf.c    | 74 ++++++++-----------
>  1 file changed, 31 insertions(+), 43 deletions(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [next PATCH S5 07/10] i40e: Missing response checks in driver when starting/stopping FW LLDP
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 07/10] i40e: Missing response checks in driver when starting/stopping FW LLDP Alice Michael
@ 2019-05-03 23:38   ` Bowers, AndrewX
  0 siblings, 0 replies; 20+ messages in thread
From: Bowers, AndrewX @ 2019-05-03 23:38 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Alice Michael
> Sent: Wednesday, April 24, 2019 5:21 AM
> To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> lan at lists.osuosl.org
> Cc: Marczak, Piotr <piotr.marczak@intel.com>
> Subject: [Intel-wired-lan] [next PATCH S5 07/10] i40e: Missing response
> checks in driver when starting/stopping FW LLDP
> 
> From: Piotr Marczak <piotr.marczak@intel.com>
> 
> Driver did not check response on LLDP flag change and always returned
> SUCCESS.
> 
> This patch now checks for an error and returns an error code and has
> additional information in the log.
> 
> Signed-off-by: Piotr Marczak <piotr.marczak@intel.com>
> ---
>  .../net/ethernet/intel/i40e/i40e_ethtool.c    | 27 +++++++++++++++++--
>  1 file changed, 25 insertions(+), 2 deletions(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [next PATCH S5 08/10] i40e: Check if the BAR size is large enough before writing to registers
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 08/10] i40e: Check if the BAR size is large enough before writing to registers Alice Michael
@ 2019-05-03 23:39   ` Bowers, AndrewX
  0 siblings, 0 replies; 20+ messages in thread
From: Bowers, AndrewX @ 2019-05-03 23:39 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Alice Michael
> Sent: Wednesday, April 24, 2019 5:21 AM
> To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> lan at lists.osuosl.org
> Cc: Ludkiewicz, Adam <adam.ludkiewicz@intel.com>
> Subject: [Intel-wired-lan] [next PATCH S5 08/10] i40e: Check if the BAR size is
> large enough before writing to registers
> 
> From: Adam Ludkiewicz <adam.ludkiewicz@intel.com>
> 
> This patch fixes the problem with a kernel panic occurring when trying to bind
> the i40e driver to a non-i40e port. The problem is fixed by checking if the BAR
> size in the device is large enough by reading the highest register.
> 
> Signed-off-by: Adam Ludkiewicz <adam.ludkiewicz@intel.com>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_main.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [next PATCH S5 09/10] i40e: remove duplicate stat calculation for tx_errors
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 09/10] i40e: remove duplicate stat calculation for tx_errors Alice Michael
@ 2019-05-03 23:39   ` Bowers, AndrewX
  0 siblings, 0 replies; 20+ messages in thread
From: Bowers, AndrewX @ 2019-05-03 23:39 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Alice Michael
> Sent: Wednesday, April 24, 2019 5:21 AM
> To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> lan at lists.osuosl.org
> Subject: [Intel-wired-lan] [next PATCH S5 09/10] i40e: remove duplicate stat
> calculation for tx_errors
> 
> From: Jacob Keller <jacob.e.keller@intel.com>
> 
> The tx_errors statistic was being calculated twice in i40e_update_eth_stats.
> 
> This appears to be as of commit 201db2898f2c ("i40e: add missing VSI
> statistics", 2014-03-25).
> 
> Remove the extra i40e_stat_update32 call for GLV_TEPC.
> 
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_main.c | 3 ---
>  1 file changed, 3 deletions(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [next PATCH S5 10/10] i40e: Missing response checks in driver when starting/stopping FW LLDP
  2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 10/10] i40e: Missing response checks in driver when starting/stopping FW LLDP Alice Michael
@ 2019-05-03 23:40   ` Bowers, AndrewX
  0 siblings, 0 replies; 20+ messages in thread
From: Bowers, AndrewX @ 2019-05-03 23:40 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Alice Michael
> Sent: Wednesday, April 24, 2019 5:21 AM
> To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> lan at lists.osuosl.org
> Cc: Loktionov, Aleksandr <aleksandr.loktionov@intel.com>
> Subject: [Intel-wired-lan] [next PATCH S5 10/10] i40e: Missing response
> checks in driver when starting/stopping FW LLDP
> 
> From: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> 
> Driver updated pf->flags before calling i40e_aq_start_lldp().
> This patch moved down updating pf->flags down so flags will be updated
> only in case of successful i40e_aq_start_lldp() call.
> Also was introduced is_reset_needed local flag to avoid unnecessary h/w
> reset in case 40e_aq_start_lldp() didn't change lldp state.
> 
> Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> ---
>  .../net/ethernet/intel/i40e/i40e_ethtool.c    | 45 ++++++++++---------
>  1 file changed, 24 insertions(+), 21 deletions(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2019-05-03 23:40 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24 12:20 [Intel-wired-lan] [next PATCH S5 01/10] i40e: let untrusted VF to create up to 16 VLANs Alice Michael
2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 02/10] i40e: add constraints for accessing veb array Alice Michael
2019-05-03 23:35   ` Bowers, AndrewX
2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 03/10] i40e: Use signed variable Alice Michael
2019-05-03 23:36   ` Bowers, AndrewX
2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 04/10] i40e: Add bounds check for ch[] array Alice Michael
2019-05-03 23:37   ` Bowers, AndrewX
2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 05/10] i40e: Improve AQ log granularity Alice Michael
2019-05-03 23:38   ` Bowers, AndrewX
2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 06/10] i40e: add input validation for virtchnl handlers Alice Michael
2019-05-03 23:38   ` Bowers, AndrewX
2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 07/10] i40e: Missing response checks in driver when starting/stopping FW LLDP Alice Michael
2019-05-03 23:38   ` Bowers, AndrewX
2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 08/10] i40e: Check if the BAR size is large enough before writing to registers Alice Michael
2019-05-03 23:39   ` Bowers, AndrewX
2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 09/10] i40e: remove duplicate stat calculation for tx_errors Alice Michael
2019-05-03 23:39   ` Bowers, AndrewX
2019-04-24 12:20 ` [Intel-wired-lan] [next PATCH S5 10/10] i40e: Missing response checks in driver when starting/stopping FW LLDP Alice Michael
2019-05-03 23:40   ` Bowers, AndrewX
2019-05-03 23:31 ` [Intel-wired-lan] [next PATCH S5 01/10] i40e: let untrusted VF to create up to 16 VLANs Bowers, AndrewX

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.