Skip to contentSkip to conversation

net/i40e: add PF MDD event handler

PATCH Superseded [email protected] 3 participants 12 messages Dec 9, 2019 – Jan 17, 2020 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/i40e: add PF MDD event handler

From: Zhu Tao <[email protected]>

This patch adds a handler for malicious driver detection event. We just gave a warning log and a statistical count on the PF.

---
 doc/guides/nics/i40e.rst               |  1 +
 doc/guides/rel_notes/release_20_02.rst |  4 ++
 drivers/net/i40e/i40e_ethdev.c         | 87 +++++++++++++++++++++++++-
 drivers/net/i40e/i40e_ethdev.h         |  1 +
 4 files changed, 91 insertions(+), 2 deletions(-)
doc/guides/nics/i40e.rst +1 -0
index 38acf5906..539ea5c57 100644
@@ -43,6 +43,7 @@ Features of the i40e PMD are:
 - Dynamic Device Personalization (DDP)
 - Queue region configuration
 - Virtual Function Port Representors
+- Malicious Device Drive event catch and notify
 
 Prerequisites
 -------------
doc/guides/rel_notes/release_20_02.rst +4 -0
index 0eaa45a76..5f39006a4 100644
@@ -56,6 +56,10 @@ New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Updated the Intel i40e driver.**
+
+  Added PF support Malicious Device Drive event catch and notify.
+
 
 Removed Items
 -------------
drivers/net/i40e/i40e_ethdev.c +85 -2

107 lines not on this page · raw message

drivers/net/i40e/i40e_ethdev.h +1 -0
index 295ad593b..b14521017 100644
@@ -426,6 +426,7 @@ struct i40e_pf_vf {
 	/* version of the virtchnl from VF */
 	struct virtchnl_version_info version;
 	uint32_t request_caps; /* offload caps requested from VF */
+	uint64_t num_mdd_events; /* num of mdd events detected */
 
 	/*
 	 * Variables for store the arrival timestamp of VF messages.
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/1 net/i40e: add PF MDD event handler

From: Zhu Tao <[email protected]>

This patch adds a handler for malicious driver detection event. We just gave a warning log and a statistical count on the PF.

---
 doc/guides/nics/i40e.rst               |  1 +
 doc/guides/rel_notes/release_20_02.rst |  4 ++
 drivers/net/i40e/i40e_ethdev.c         | 89 +++++++++++++++++++++++++-
 drivers/net/i40e/i40e_ethdev.h         |  1 +
 4 files changed, 93 insertions(+), 2 deletions(-)
doc/guides/nics/i40e.rst +1 -0
index 38acf5906..539ea5c57 100644
@@ -43,6 +43,7 @@ Features of the i40e PMD are:
 - Dynamic Device Personalization (DDP)
 - Queue region configuration
 - Virtual Function Port Representors
+- Malicious Device Drive event catch and notify
 
 Prerequisites
 -------------
doc/guides/rel_notes/release_20_02.rst +4 -0
index 0eaa45a76..5f39006a4 100644
@@ -56,6 +56,10 @@ New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Updated the Intel i40e driver.**
+
+  Added PF support Malicious Device Drive event catch and notify.
+
 
 Removed Items
 -------------
drivers/net/i40e/i40e_ethdev.c +87 -2

109 lines not on this page · raw message

drivers/net/i40e/i40e_ethdev.h +1 -0
index 295ad593b..b14521017 100644
@@ -426,6 +426,7 @@ struct i40e_pf_vf {
 	/* version of the virtchnl from VF */
 	struct virtchnl_version_info version;
 	uint32_t request_caps; /* offload caps requested from VF */
+	uint64_t num_mdd_events; /* num of mdd events detected */
 
 	/*
 	 * Variables for store the arrival timestamp of VF messages.
Signature · 1 line
2.17.1
#2 lore raw

PATCH v3 1/1 net/i40e: add PF MDD event handler

In reply to [email protected]

From: Zhu Tao <[email protected]>

add warning and counter to handle the maliciouse driver detection event.

---
 doc/guides/nics/i40e.rst               |  1 +
 doc/guides/rel_notes/release_20_02.rst |  4 ++
 drivers/net/i40e/i40e_ethdev.c         | 89 +++++++++++++++++++++++++-
 drivers/net/i40e/i40e_ethdev.h         |  1 +
 4 files changed, 93 insertions(+), 2 deletions(-)
doc/guides/nics/i40e.rst +1 -0
index 38acf5906..539ea5c57 100644
@@ -43,6 +43,7 @@ Features of the i40e PMD are:
 - Dynamic Device Personalization (DDP)
 - Queue region configuration
 - Virtual Function Port Representors
+- Malicious Device Drive event catch and notify
 
 Prerequisites
 -------------
doc/guides/rel_notes/release_20_02.rst +4 -0
index 0eaa45a76..5f39006a4 100644
@@ -56,6 +56,10 @@ New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Updated the Intel i40e driver.**
+
+  Added PF support Malicious Device Drive event catch and notify.
+
 
 Removed Items
 -------------
drivers/net/i40e/i40e_ethdev.c +87 -2

109 lines not on this page · raw message

drivers/net/i40e/i40e_ethdev.h +1 -0
index 295ad593b..b14521017 100644
@@ -426,6 +426,7 @@ struct i40e_pf_vf {
 	/* version of the virtchnl from VF */
 	struct virtchnl_version_info version;
 	uint32_t request_caps; /* offload caps requested from VF */
+	uint64_t num_mdd_events; /* num of mdd events detected */
 
 	/*
 	 * Variables for store the arrival timestamp of VF messages.
Signature · 1 line
2.17.1
Acked-by on v3 1/1
#3 lore raw
Quoted 10 lines

-----Original Message-----
From: Zhu, TaoX <[email protected]>
Sent: Wednesday, January 15, 2020 3:43 AM
To: Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Yang, Qiming <[email protected]>; Ye, Xiaolong <[email protected]>; Zhu, TaoX <[email protected]>
Subject: [PATCH v3] net/i40e: add PF MDD event handler

Quoted 3 lines

From: Zhu Tao <[email protected]>

add warning and counter to handle the maliciouse driver detection event.

Add/add

Quoted 177 lines
---
 doc/guides/nics/i40e.rst               |  1 +
 doc/guides/rel_notes/release_20_02.rst |  4 ++
 drivers/net/i40e/i40e_ethdev.c         | 89 +++++++++++++++++++++++++-
 drivers/net/i40e/i40e_ethdev.h         |  1 +
 4 files changed, 93 insertions(+), 2 deletions(-)
doc/guides/nics/i40e.rst index renamed from doc/guides/nics/i40e.rst +0 -0

38acf5906..539ea5c57 100644

doc/guides/nics/i40e.rst +1 -0
@@ -43,6 +43,7 @@ Features of the i40e PMD are:
 - Dynamic Device Personalization (DDP)
 - Queue region configuration
 - Virtual Function Port Representors
+- Malicious Device Drive event catch and notify
 
 Prerequisites
 -------------
doc/guides/rel_notes/release_20_02.rst +4 -0
index 0eaa45a76..5f39006a4 100644
@@ -56,6 +56,10 @@ New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Updated the Intel i40e driver.**
+
+  Added PF support Malicious Device Drive event catch and notify.
+
 
 Removed Items
 -------------
drivers/net/i40e/i40e_ethdev.c +15 -0
index 5999c964b..a66069b48 100644
@@ -6760,6 +6760,87 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev)
 	rte_free(info.msg_buf);
 }
 
+static void
+i40e_handle_mdd_event(struct rte_eth_dev *dev) {
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data-
 >dev_private);
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data-
 >dev_private);
+	bool mdd_detected = false;
+	struct i40e_pf_vf *vf;
+	uint32_t reg;
+	int i;
+
+	/* find what triggered the MDD event */
+	reg = I40E_READ_REG(hw, I40E_GL_MDET_TX);
+	if (reg & I40E_GL_MDET_TX_VALID_MASK) {
+		uint8_t pf_num = (reg & I40E_GL_MDET_TX_PF_NUM_MASK) >>
+				I40E_GL_MDET_TX_PF_NUM_SHIFT;
+		uint16_t vf_num = (reg &

I40E_GL_MDET_TX_VF_NUM_MASK) >>

drivers/net/i40e/i40e_ethdev.c +7 -0
+				I40E_GL_MDET_TX_VF_NUM_SHIFT;
+		uint8_t event = (reg & I40E_GL_MDET_TX_EVENT_MASK) >>
+				I40E_GL_MDET_TX_EVENT_SHIFT;
+		uint16_t queue = ((reg & I40E_GL_MDET_TX_QUEUE_MASK) >>
+				I40E_GL_MDET_TX_QUEUE_SHIFT) -
+					hw->func_caps.base_queue;
+		PMD_DRV_LOG(WARNING, "Malicious Driver Detection event

0x%02x on TX "

drivers/net/i40e/i40e_ethdev.c +1 -0
+			"queue %d PF number 0x%02x VF number 0x%02x

device %s\n",

drivers/net/i40e/i40e_ethdev.c +1 -0
+				event, queue, pf_num, vf_num, dev->data-
Quoted 1 line

name);

drivers/net/i40e/i40e_ethdev.c +14 -0
+		I40E_WRITE_REG(hw, I40E_GL_MDET_TX, 0xffffffff);
+		mdd_detected = true;
+	}
+	reg = I40E_READ_REG(hw, I40E_GL_MDET_RX);
+	if (reg & I40E_GL_MDET_RX_VALID_MASK) {
+		uint8_t func = (reg & I40E_GL_MDET_RX_FUNCTION_MASK) >>
+				I40E_GL_MDET_RX_FUNCTION_SHIFT;
+		uint8_t event = (reg & I40E_GL_MDET_RX_EVENT_MASK) >>
+				I40E_GL_MDET_RX_EVENT_SHIFT;
+		uint16_t queue = ((reg & I40E_GL_MDET_RX_QUEUE_MASK) >>
+				I40E_GL_MDET_RX_QUEUE_SHIFT) -
+					hw->func_caps.base_queue;
+
+		PMD_DRV_LOG(WARNING, "Malicious Driver Detection event

0x%02x on RX "

drivers/net/i40e/i40e_ethdev.c +11 -0
+				"queue %d of function 0x%02x device %s\n",
+					event, queue, func, dev->data->name);
+		I40E_WRITE_REG(hw, I40E_GL_MDET_RX, 0xffffffff);
+		mdd_detected = true;
+	}
+
+	if (mdd_detected) {
+		reg = I40E_READ_REG(hw, I40E_PF_MDET_TX);
+		if (reg & I40E_PF_MDET_TX_VALID_MASK) {
+			I40E_WRITE_REG(hw, I40E_PF_MDET_TX, 0xFFFF);
+			PMD_DRV_LOG(WARNING, "TX driver issue detected on

PF\n");

drivers/net/i40e/i40e_ethdev.c +5 -0
+		}
+		reg = I40E_READ_REG(hw, I40E_PF_MDET_RX);
+		if (reg & I40E_PF_MDET_RX_VALID_MASK) {
+			I40E_WRITE_REG(hw, I40E_PF_MDET_RX, 0xFFFF);
+			PMD_DRV_LOG(WARNING, "RX driver issue detected

on PF\n");

drivers/net/i40e/i40e_ethdev.c +11 -0
+		}
+	}
+
+	/* see if one of the VFs needs its hand slapped */
+	for (i = 0; i < pf->vf_num && mdd_detected; i++) {
+		vf = &pf->vfs[i];
+		reg = I40E_READ_REG(hw, I40E_VP_MDET_TX(i));
+		if (reg & I40E_VP_MDET_TX_VALID_MASK) {
+			I40E_WRITE_REG(hw, I40E_VP_MDET_TX(i), 0xFFFF);
+			vf->num_mdd_events++;
+			PMD_DRV_LOG(WARNING, "TX driver issue detected on

VF %d %-"

drivers/net/i40e/i40e_ethdev.c +9 -0
+					PRIu64 "times\n",
+					i, vf->num_mdd_events);
+		}
+
+		reg = I40E_READ_REG(hw, I40E_VP_MDET_RX(i));
+		if (reg & I40E_VP_MDET_RX_VALID_MASK) {
+			I40E_WRITE_REG(hw, I40E_VP_MDET_RX(i), 0xFFFF);
+			vf->num_mdd_events++;
+			PMD_DRV_LOG(WARNING, "RX driver issue detected

on VF %d %-"

drivers/net/i40e/i40e_ethdev.c +12 -2
+					PRIu64 "times\n",
+					i, vf->num_mdd_events);
+		}
+	}
+}
+
 /**
  * Interrupt handler triggered by NIC  for handling
  * specific interrupt.
@@ -6792,8 +6873,10 @@ i40e_dev_interrupt_handler(void *param)
 	}
 	if (icr0 & I40E_PFINT_ICR0_ECC_ERR_MASK)
 		PMD_DRV_LOG(ERR, "ICR0: unrecoverable ECC error");
-	if (icr0 & I40E_PFINT_ICR0_MAL_DETECT_MASK)
+	if (icr0 & I40E_PFINT_ICR0_MAL_DETECT_MASK) {
 		PMD_DRV_LOG(ERR, "ICR0: malicious programming detected");
+		i40e_handle_mdd_event(dev);
+	}
 	if (icr0 & I40E_PFINT_ICR0_GRST_MASK)
 		PMD_DRV_LOG(INFO, "ICR0: global reset requested");
 	if (icr0 & I40E_PFINT_ICR0_PCI_EXCEPTION_MASK)
@@ -6837,8 +6920,10 @@ i40e_dev_alarm_handler(void *param)
 		goto done;
 	if (icr0 & I40E_PFINT_ICR0_ECC_ERR_MASK)
 		PMD_DRV_LOG(ERR, "ICR0: unrecoverable ECC error");
-	if (icr0 & I40E_PFINT_ICR0_MAL_DETECT_MASK)
+	if (icr0 & I40E_PFINT_ICR0_MAL_DETECT_MASK) {
 		PMD_DRV_LOG(ERR, "ICR0: malicious programming detected");
+		i40e_handle_mdd_event(dev);
+	}
 	if (icr0 & I40E_PFINT_ICR0_GRST_MASK)
 		PMD_DRV_LOG(INFO, "ICR0: global reset requested");
 	if (icr0 & I40E_PFINT_ICR0_PCI_EXCEPTION_MASK)
drivers/net/i40e/i40e_ethdev.h +1 -1
index 295ad593b..b14521017 100644
@@ -426,6 +426,7 @@ struct i40e_pf_vf {
 	/* version of the virtchnl from VF */
 	struct virtchnl_version_info version;
 	uint32_t request_caps; /* offload caps requested from VF */
+	uint64_t num_mdd_events; /* num of mdd events detected */
 
 	/*
 	 * Variables for store the arrival timestamp of VF messages.
--

2.17.1

#4 lore raw

PATCH v4 1/1 net/i40e: add PF MDD event handler

In reply to [email protected]

From: Zhu Tao <[email protected]>

add warning and counter to handle the maliciouse
driver detection event.
update doc/guides/nics/i40e.rst
update doc/guides/rel_notes/release_20_02.rst

---
 doc/guides/nics/i40e.rst               |  1 +
 doc/guides/rel_notes/release_20_02.rst |  4 +-
 drivers/net/i40e/i40e_ethdev.c         | 89 +++++++++++++++++++++++++-
 drivers/net/i40e/i40e_ethdev.h         |  1 +
 4 files changed, 92 insertions(+), 3 deletions(-)
doc/guides/nics/i40e.rst +1 -0
index c7c34b62f..2bf11e8ca 100644
@@ -43,6 +43,7 @@ Features of the i40e PMD are:
 - Dynamic Device Personalization (DDP)
 - Queue region configuration
 - Virtual Function Port Representors
+- Malicious Device Drive event catch and notify
 
 Prerequisites
 -------------
doc/guides/rel_notes/release_20_02.rst +3 -1
index 1e83e659a..a39f22221 100644
@@ -66,11 +66,13 @@ New Features
 
   * Added support for RSS using L3/L4 source/destination only.
 
-* **Updated i40e driver to support L2TPv3 over IP flows.**
+* **Updated i40e driver.**
 
   Updated the i40e PMD to support L2TPv3 over IP profiles which can be
   programmed by the dynamic device personalization (DDP) process.
 
+  Added PF support Malicious Device Drive event catch and notify.
+
 * **Updated testpmd to support L2TPv3 over IP flows.**
 
   Added support for L2TPv3 over IP rte_flow patterns to the testpmd
drivers/net/i40e/i40e_ethdev.c +87 -2

109 lines not on this page · raw message

drivers/net/i40e/i40e_ethdev.h +1 -0
index bba2b83b4..370e6298f 100644
@@ -426,6 +426,7 @@ struct i40e_pf_vf {
 	/* version of the virtchnl from VF */
 	struct virtchnl_version_info version;
 	uint32_t request_caps; /* offload caps requested from VF */
+	uint64_t num_mdd_events; /* num of mdd events detected */
 
 	/*
 	 * Variables for store the arrival timestamp of VF messages.
Signature · 1 line
2.17.1
#5 lore raw
Quoted 4 lines · On 01/15, [email protected] wrote:

From: Zhu Tao <[email protected]>

add warning and counter to handle the maliciouse
driver detection event.

Better to have more descriptions about the motivation about this patch.

Quoted 2 lines

update doc/guides/nics/i40e.rst
update doc/guides/rel_notes/release_20_02.rst

Above 2 lines are not needed.

Quoted 64 lines

---

doc/guides/nics/i40e.rst               |  1 +
doc/guides/rel_notes/release_20_02.rst |  4 +-
drivers/net/i40e/i40e_ethdev.c         | 89 +++++++++++++++++++++++++-
drivers/net/i40e/i40e_ethdev.h         |  1 +
4 files changed, 92 insertions(+), 3 deletions(-)
doc/guides/nics/i40e.rst +1 -3
index c7c34b62f..2bf11e8ca 100644
@@ -43,6 +43,7 @@ Features of the i40e PMD are:
- Dynamic Device Personalization (DDP)
- Queue region configuration
- Virtual Function Port Representors
+- Malicious Device Drive event catch and notify
 

Prerequisites
-------------

doc/guides/rel_notes/release_20_02.rst +3 -1
index 1e83e659a..a39f22221 100644
@@ -66,11 +66,13 @@ New Features
 
  * Added support for RSS using L3/L4 source/destination only.
 
-* **Updated i40e driver to support L2TPv3 over IP flows.**
+* **Updated i40e driver.**
 
  Updated the i40e PMD to support L2TPv3 over IP profiles which can be
  programmed by the dynamic device personalization (DDP) process.
 
+  Added PF support Malicious Device Drive event catch and notify.
+
 * **Updated testpmd to support L2TPv3 over IP flows.**
 
  Added support for L2TPv3 over IP rte_flow patterns to the testpmd
drivers/net/i40e/i40e_ethdev.c +16 -0
index afb6f554b..95bfed4d9 100644
@@ -6760,6 +6760,87 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev)
 	rte_free(info.msg_buf);
 }
 
+static void
+i40e_handle_mdd_event(struct rte_eth_dev *dev)
+{
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	bool mdd_detected = false;
+	struct i40e_pf_vf *vf;
+	uint32_t reg;
+	int i;
+
+	/* find what triggered the MDD event */
+	reg = I40E_READ_REG(hw, I40E_GL_MDET_TX);
+	if (reg & I40E_GL_MDET_TX_VALID_MASK) {
+		uint8_t pf_num = (reg & I40E_GL_MDET_TX_PF_NUM_MASK) >>
+				I40E_GL_MDET_TX_PF_NUM_SHIFT;
+		uint16_t vf_num = (reg & I40E_GL_MDET_TX_VF_NUM_MASK) >>

drivers/net/i40e/i40e_ethdev.c i40e_dev_handle_aq_msg(struct rte_eth_dev *dev) · line 6788

Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +10 -0
+				I40E_GL_MDET_TX_VF_NUM_SHIFT;
+		uint8_t event = (reg & I40E_GL_MDET_TX_EVENT_MASK) >>
+				I40E_GL_MDET_TX_EVENT_SHIFT;
+		uint16_t queue = ((reg & I40E_GL_MDET_TX_QUEUE_MASK) >>
+				I40E_GL_MDET_TX_QUEUE_SHIFT) -
+					hw->func_caps.base_queue;
+		PMD_DRV_LOG(WARNING, "Malicious Driver Detection event 0x%02x on TX "
+			"queue %d PF number 0x%02x VF number 0x%02x device %s\n",
+				event, queue, pf_num, vf_num, dev->data->name);
+		I40E_WRITE_REG(hw, I40E_GL_MDET_TX, 0xffffffff);

Use Macros for 0xffffffff and below 0xFFFF.

Quoted 97 lines
drivers/net/i40e/i40e_ethdev.c +61 -2
+		mdd_detected = true;
+	}
+	reg = I40E_READ_REG(hw, I40E_GL_MDET_RX);
+	if (reg & I40E_GL_MDET_RX_VALID_MASK) {
+		uint8_t func = (reg & I40E_GL_MDET_RX_FUNCTION_MASK) >>
+				I40E_GL_MDET_RX_FUNCTION_SHIFT;
+		uint8_t event = (reg & I40E_GL_MDET_RX_EVENT_MASK) >>
+				I40E_GL_MDET_RX_EVENT_SHIFT;
+		uint16_t queue = ((reg & I40E_GL_MDET_RX_QUEUE_MASK) >>
+				I40E_GL_MDET_RX_QUEUE_SHIFT) -
+					hw->func_caps.base_queue;
+
+		PMD_DRV_LOG(WARNING, "Malicious Driver Detection event 0x%02x on RX "
+				"queue %d of function 0x%02x device %s\n",
+					event, queue, func, dev->data->name);
+		I40E_WRITE_REG(hw, I40E_GL_MDET_RX, 0xffffffff);
+		mdd_detected = true;
+	}
+
+	if (mdd_detected) {
+		reg = I40E_READ_REG(hw, I40E_PF_MDET_TX);
+		if (reg & I40E_PF_MDET_TX_VALID_MASK) {
+			I40E_WRITE_REG(hw, I40E_PF_MDET_TX, 0xFFFF);
+			PMD_DRV_LOG(WARNING, "TX driver issue detected on PF\n");
+		}
+		reg = I40E_READ_REG(hw, I40E_PF_MDET_RX);
+		if (reg & I40E_PF_MDET_RX_VALID_MASK) {
+			I40E_WRITE_REG(hw, I40E_PF_MDET_RX, 0xFFFF);
+			PMD_DRV_LOG(WARNING, "RX driver issue detected on PF\n");
+		}
+	}
+
+	/* see if one of the VFs needs its hand slapped */
+	for (i = 0; i < pf->vf_num && mdd_detected; i++) {
+		vf = &pf->vfs[i];
+		reg = I40E_READ_REG(hw, I40E_VP_MDET_TX(i));
+		if (reg & I40E_VP_MDET_TX_VALID_MASK) {
+			I40E_WRITE_REG(hw, I40E_VP_MDET_TX(i), 0xFFFF);
+			vf->num_mdd_events++;
+			PMD_DRV_LOG(WARNING, "TX driver issue detected on VF %d %-"
+					PRIu64 "times\n",
+					i, vf->num_mdd_events);
+		}
+
+		reg = I40E_READ_REG(hw, I40E_VP_MDET_RX(i));
+		if (reg & I40E_VP_MDET_RX_VALID_MASK) {
+			I40E_WRITE_REG(hw, I40E_VP_MDET_RX(i), 0xFFFF);
+			vf->num_mdd_events++;
+			PMD_DRV_LOG(WARNING, "RX driver issue detected on VF %d %-"
+					PRIu64 "times\n",
+					i, vf->num_mdd_events);
+		}
+	}
+}
+
 /**
 * Interrupt handler triggered by NIC  for handling
 * specific interrupt.
@@ -6792,8 +6873,10 @@ i40e_dev_interrupt_handler(void *param)
 	}
 	if (icr0 & I40E_PFINT_ICR0_ECC_ERR_MASK)
 		PMD_DRV_LOG(ERR, "ICR0: unrecoverable ECC error");
-	if (icr0 & I40E_PFINT_ICR0_MAL_DETECT_MASK)
+	if (icr0 & I40E_PFINT_ICR0_MAL_DETECT_MASK) {
 		PMD_DRV_LOG(ERR, "ICR0: malicious programming detected");
+		i40e_handle_mdd_event(dev);
+	}
 	if (icr0 & I40E_PFINT_ICR0_GRST_MASK)
 		PMD_DRV_LOG(INFO, "ICR0: global reset requested");
 	if (icr0 & I40E_PFINT_ICR0_PCI_EXCEPTION_MASK)
@@ -6837,8 +6920,10 @@ i40e_dev_alarm_handler(void *param)
 		goto done;
 	if (icr0 & I40E_PFINT_ICR0_ECC_ERR_MASK)
 		PMD_DRV_LOG(ERR, "ICR0: unrecoverable ECC error");
-	if (icr0 & I40E_PFINT_ICR0_MAL_DETECT_MASK)
+	if (icr0 & I40E_PFINT_ICR0_MAL_DETECT_MASK) {
 		PMD_DRV_LOG(ERR, "ICR0: malicious programming detected");
+		i40e_handle_mdd_event(dev);
+	}
 	if (icr0 & I40E_PFINT_ICR0_GRST_MASK)
 		PMD_DRV_LOG(INFO, "ICR0: global reset requested");
 	if (icr0 & I40E_PFINT_ICR0_PCI_EXCEPTION_MASK)
drivers/net/i40e/i40e_ethdev.h +1 -0
index bba2b83b4..370e6298f 100644
@@ -426,6 +426,7 @@ struct i40e_pf_vf {
 	/* version of the virtchnl from VF */
 	struct virtchnl_version_info version;
 	uint32_t request_caps; /* offload caps requested from VF */
+	uint64_t num_mdd_events; /* num of mdd events detected */
 
 	/*
 	 * Variables for store the arrival timestamp of VF messages.
Signature · 1 line
2.17.1
#6 lore raw

PATCH v5 1/1 net/i40e: add PF MDD event handler

In reply to [email protected]

From: Zhu Tao <[email protected]>

add warning and counter to handle the maliciouse driver detection event. When the hardware determines that a VF has maliciouse driver, this VF will become unworkable, the PF records and gives a warning message.

---
 doc/guides/nics/i40e.rst               |  1 +
 doc/guides/rel_notes/release_20_02.rst |  4 +-
 drivers/net/i40e/i40e_ethdev.c         | 89 +++++++++++++++++++++++++-
 drivers/net/i40e/i40e_ethdev.h         |  1 +
 4 files changed, 92 insertions(+), 3 deletions(-)

v5:
- Change commit message
v4:
- Change commit message
- Rebase doc/guides/rel_notes/release_20_02.rst
v3:
- Change commit message

doc/guides/nics/i40e.rst +1 -0
index c7c34b62f..2bf11e8ca 100644
@@ -43,6 +43,7 @@ Features of the i40e PMD are:
 - Dynamic Device Personalization (DDP)
 - Queue region configuration
 - Virtual Function Port Representors
+- Malicious Device Drive event catch and notify
 
 Prerequisites
 -------------
doc/guides/rel_notes/release_20_02.rst +3 -1
index 1e83e659a..a39f22221 100644
@@ -66,11 +66,13 @@ New Features
 
   * Added support for RSS using L3/L4 source/destination only.
 
-* **Updated i40e driver to support L2TPv3 over IP flows.**
+* **Updated i40e driver.**
 
   Updated the i40e PMD to support L2TPv3 over IP profiles which can be
   programmed by the dynamic device personalization (DDP) process.
 
+  Added PF support Malicious Device Drive event catch and notify.
+
 * **Updated testpmd to support L2TPv3 over IP flows.**
 
   Added support for L2TPv3 over IP rte_flow patterns to the testpmd
drivers/net/i40e/i40e_ethdev.c +87 -2

109 lines not on this page · raw message

drivers/net/i40e/i40e_ethdev.h +1 -0
index bba2b83b4..370e6298f 100644
@@ -426,6 +426,7 @@ struct i40e_pf_vf {
 	/* version of the virtchnl from VF */
 	struct virtchnl_version_info version;
 	uint32_t request_caps; /* offload caps requested from VF */
+	uint64_t num_mdd_events; /* num of mdd events detected */
 
 	/*
 	 * Variables for store the arrival timestamp of VF messages.
Signature · 1 line
2.17.1
#7 lore raw

PATCH v5 1/1 net/i40e: add PF MDD event handler

In reply to [email protected]

From: Zhu Tao <[email protected]>

Add warning and counter to handle the malicious driver detection event. When the hardware determines that a malicious driver on VF, this VF will become unworkable, the PF records and gives a warning message.

---
 doc/guides/nics/i40e.rst               |  1 +
 doc/guides/rel_notes/release_20_02.rst |  4 +-
 drivers/net/i40e/i40e_ethdev.c         | 89 +++++++++++++++++++++++++-
 drivers/net/i40e/i40e_ethdev.h         |  1 +
 4 files changed, 92 insertions(+), 3 deletions(-)

v6:
- Change commit message
v5:
- Change commit message
v4:
- Change commit message
- Rebase doc/guides/rel_notes/release_20_02.rst
v3:
- Change commit message

doc/guides/nics/i40e.rst +1 -0
index c7c34b62f..2bf11e8ca 100644
@@ -43,6 +43,7 @@ Features of the i40e PMD are:
 - Dynamic Device Personalization (DDP)
 - Queue region configuration
 - Virtual Function Port Representors
+- Malicious Device Drive event catch and notify
 
 Prerequisites
 -------------
doc/guides/rel_notes/release_20_02.rst +3 -1
index 1e83e659a..a39f22221 100644
@@ -66,11 +66,13 @@ New Features
 
   * Added support for RSS using L3/L4 source/destination only.
 
-* **Updated i40e driver to support L2TPv3 over IP flows.**
+* **Updated i40e driver.**
 
   Updated the i40e PMD to support L2TPv3 over IP profiles which can be
   programmed by the dynamic device personalization (DDP) process.
 
+  Added PF support Malicious Device Drive event catch and notify.
+
 * **Updated testpmd to support L2TPv3 over IP flows.**
 
   Added support for L2TPv3 over IP rte_flow patterns to the testpmd
drivers/net/i40e/i40e_ethdev.c +87 -2

109 lines not on this page · raw message

drivers/net/i40e/i40e_ethdev.h +1 -0
index bba2b83b4..370e6298f 100644
@@ -426,6 +426,7 @@ struct i40e_pf_vf {
 	/* version of the virtchnl from VF */
 	struct virtchnl_version_info version;
 	uint32_t request_caps; /* offload caps requested from VF */
+	uint64_t num_mdd_events; /* num of mdd events detected */
 
 	/*
 	 * Variables for store the arrival timestamp of VF messages.
Signature · 1 line
2.17.1
author
#8 lore raw

Hi ALL,

The name of patch subject has forgotten to be modified. Please ignore this patch and I will resend it.

BR,
Zhu, Tao

Quoted 213 lines

-----Original Message-----
From: Zhu, TaoX
Sent: Friday, January 17, 2020 7:24 PM
To: Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Yang, Qiming <[email protected]>; Ye, Xiaolong <[email protected]>; Zhu, TaoX <[email protected]>
Subject: [PATCH v5] net/i40e: add PF MDD event handler

From: Zhu Tao <[email protected]>

Add warning and counter to handle the malicious driver detection event. When the hardware determines that a malicious driver on VF, this VF will become unworkable, the PF records and gives a warning message.

---
 doc/guides/nics/i40e.rst               |  1 +
 doc/guides/rel_notes/release_20_02.rst |  4 +-
 drivers/net/i40e/i40e_ethdev.c         | 89 +++++++++++++++++++++++++-
 drivers/net/i40e/i40e_ethdev.h         |  1 +
 4 files changed, 92 insertions(+), 3 deletions(-)

v6:
- Change commit message
v5:
- Change commit message
v4:
- Change commit message
- Rebase doc/guides/rel_notes/release_20_02.rst
v3:
- Change commit message

doc/guides/nics/i40e.rst index renamed from doc/guides/nics/i40e.rst +0 -0

c7c34b62f..2bf11e8ca 100644

doc/guides/nics/i40e.rst +1 -0
@@ -43,6 +43,7 @@ Features of the i40e PMD are:
 - Dynamic Device Personalization (DDP)
 - Queue region configuration
 - Virtual Function Port Representors
+- Malicious Device Drive event catch and notify
 
 Prerequisites
 -------------
doc/guides/rel_notes/release_20_02.rst +3 -1
index 1e83e659a..a39f22221 100644
@@ -66,11 +66,13 @@ New Features
 
   * Added support for RSS using L3/L4 source/destination only.
 
-* **Updated i40e driver to support L2TPv3 over IP flows.**
+* **Updated i40e driver.**
 
   Updated the i40e PMD to support L2TPv3 over IP profiles which can be
   programmed by the dynamic device personalization (DDP) process.
 
+  Added PF support Malicious Device Drive event catch and notify.
+
 * **Updated testpmd to support L2TPv3 over IP flows.**
 
   Added support for L2TPv3 over IP rte_flow patterns to the testpmd diff --

git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index afb6f554b..95bfed4d9 100644

drivers/net/i40e/i40e_ethdev.c +13 -0
@@ -6760,6 +6760,87 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev
 *dev)
 	rte_free(info.msg_buf);
 }
 
+static void
+i40e_handle_mdd_event(struct rte_eth_dev *dev) {
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data-
 >dev_private);
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data-
 >dev_private);
+	bool mdd_detected = false;
+	struct i40e_pf_vf *vf;
+	uint32_t reg;
+	int i;
+
+	/* find what triggered the MDD event */
+	reg = I40E_READ_REG(hw, I40E_GL_MDET_TX);
+	if (reg & I40E_GL_MDET_TX_VALID_MASK) {
+		uint8_t pf_num = (reg &

I40E_GL_MDET_TX_PF_NUM_MASK) >>

drivers/net/i40e/i40e_ethdev.c +2 -0
+				I40E_GL_MDET_TX_PF_NUM_SHIFT;
+		uint16_t vf_num = (reg &

I40E_GL_MDET_TX_VF_NUM_MASK) >>

drivers/net/i40e/i40e_ethdev.c +4 -0
+				I40E_GL_MDET_TX_VF_NUM_SHIFT;
+		uint8_t event = (reg & I40E_GL_MDET_TX_EVENT_MASK) >>
+				I40E_GL_MDET_TX_EVENT_SHIFT;
+		uint16_t queue = ((reg &

I40E_GL_MDET_TX_QUEUE_MASK) >>

drivers/net/i40e/i40e_ethdev.c +3 -0
+				I40E_GL_MDET_TX_QUEUE_SHIFT) -
+					hw->func_caps.base_queue;
+		PMD_DRV_LOG(WARNING, "Malicious Driver Detection

event 0x%02x on TX "

drivers/net/i40e/i40e_ethdev.c +1 -0
+			"queue %d PF number 0x%02x VF number 0x%02x

device %s\n",

drivers/net/i40e/i40e_ethdev.c +1 -0
+				event, queue, pf_num, vf_num, dev->data-
Quoted 1 line

name);

drivers/net/i40e/i40e_ethdev.c +6 -0
+		I40E_WRITE_REG(hw, I40E_GL_MDET_TX, 0xffffffff);
+		mdd_detected = true;
+	}
+	reg = I40E_READ_REG(hw, I40E_GL_MDET_RX);
+	if (reg & I40E_GL_MDET_RX_VALID_MASK) {
+		uint8_t func = (reg &

I40E_GL_MDET_RX_FUNCTION_MASK) >>

drivers/net/i40e/i40e_ethdev.c +4 -0
+				I40E_GL_MDET_RX_FUNCTION_SHIFT;
+		uint8_t event = (reg & I40E_GL_MDET_RX_EVENT_MASK) >>
+				I40E_GL_MDET_RX_EVENT_SHIFT;
+		uint16_t queue = ((reg &

I40E_GL_MDET_RX_QUEUE_MASK) >>

drivers/net/i40e/i40e_ethdev.c +4 -0
+				I40E_GL_MDET_RX_QUEUE_SHIFT) -
+					hw->func_caps.base_queue;
+
+		PMD_DRV_LOG(WARNING, "Malicious Driver Detection

event 0x%02x on RX "

drivers/net/i40e/i40e_ethdev.c +2 -0
+				"queue %d of function 0x%02x device %s\n",
+					event, queue, func, dev->data-
Quoted 1 line

name);

drivers/net/i40e/i40e_ethdev.c +9 -0
+		I40E_WRITE_REG(hw, I40E_GL_MDET_RX, 0xffffffff);
+		mdd_detected = true;
+	}
+
+	if (mdd_detected) {
+		reg = I40E_READ_REG(hw, I40E_PF_MDET_TX);
+		if (reg & I40E_PF_MDET_TX_VALID_MASK) {
+			I40E_WRITE_REG(hw, I40E_PF_MDET_TX, 0xFFFF);
+			PMD_DRV_LOG(WARNING, "TX driver issue

detected on PF\n");

drivers/net/i40e/i40e_ethdev.c +5 -0
+		}
+		reg = I40E_READ_REG(hw, I40E_PF_MDET_RX);
+		if (reg & I40E_PF_MDET_RX_VALID_MASK) {
+			I40E_WRITE_REG(hw, I40E_PF_MDET_RX, 0xFFFF);
+			PMD_DRV_LOG(WARNING, "RX driver issue

detected on PF\n");

drivers/net/i40e/i40e_ethdev.c +11 -0
+		}
+	}
+
+	/* see if one of the VFs needs its hand slapped */
+	for (i = 0; i < pf->vf_num && mdd_detected; i++) {
+		vf = &pf->vfs[i];
+		reg = I40E_READ_REG(hw, I40E_VP_MDET_TX(i));
+		if (reg & I40E_VP_MDET_TX_VALID_MASK) {
+			I40E_WRITE_REG(hw, I40E_VP_MDET_TX(i), 0xFFFF);
+			vf->num_mdd_events++;
+			PMD_DRV_LOG(WARNING, "TX driver issue

detected on VF %d %-"

drivers/net/i40e/i40e_ethdev.c +9 -0
+					PRIu64 "times\n",
+					i, vf->num_mdd_events);
+		}
+
+		reg = I40E_READ_REG(hw, I40E_VP_MDET_RX(i));
+		if (reg & I40E_VP_MDET_RX_VALID_MASK) {
+			I40E_WRITE_REG(hw, I40E_VP_MDET_RX(i), 0xFFFF);
+			vf->num_mdd_events++;
+			PMD_DRV_LOG(WARNING, "RX driver issue

detected on VF %d %-"

drivers/net/i40e/i40e_ethdev.c +9 -1
+					PRIu64 "times\n",
+					i, vf->num_mdd_events);
+		}
+	}
+}
+
 /**
  * Interrupt handler triggered by NIC  for handling
  * specific interrupt.
@@ -6792,8 +6873,10 @@ i40e_dev_interrupt_handler(void *param)
 	}
 	if (icr0 & I40E_PFINT_ICR0_ECC_ERR_MASK)
 		PMD_DRV_LOG(ERR, "ICR0: unrecoverable ECC error");
-	if (icr0 & I40E_PFINT_ICR0_MAL_DETECT_MASK)
+	if (icr0 & I40E_PFINT_ICR0_MAL_DETECT_MASK) {
 		PMD_DRV_LOG(ERR, "ICR0: malicious programming
 detected");
+		i40e_handle_mdd_event(dev);
+	}
 	if (icr0 & I40E_PFINT_ICR0_GRST_MASK)
 		PMD_DRV_LOG(INFO, "ICR0: global reset requested");
drivers/net/i40e/i40e_ethdev.c +3 -1
 	if (icr0 & I40E_PFINT_ICR0_PCI_EXCEPTION_MASK)
@@ -6837,8 +6920,10 @@ i40e_dev_alarm_handler(void *param)
 		goto done;
 	if (icr0 & I40E_PFINT_ICR0_ECC_ERR_MASK)
 		PMD_DRV_LOG(ERR, "ICR0: unrecoverable ECC error");
-	if (icr0 & I40E_PFINT_ICR0_MAL_DETECT_MASK)
+	if (icr0 & I40E_PFINT_ICR0_MAL_DETECT_MASK) {
 		PMD_DRV_LOG(ERR, "ICR0: malicious programming
 detected");
+		i40e_handle_mdd_event(dev);
+	}
 	if (icr0 & I40E_PFINT_ICR0_GRST_MASK)
 		PMD_DRV_LOG(INFO, "ICR0: global reset requested");
drivers/net/i40e/i40e_ethdev.c +0 -0
 	if (icr0 & I40E_PFINT_ICR0_PCI_EXCEPTION_MASK)
(quoted diff) +0 -0

b/drivers/net/i40e/i40e_ethdev.h index bba2b83b4..370e6298f 100644

drivers/net/i40e/i40e_ethdev.h +1 -1
@@ -426,6 +426,7 @@ struct i40e_pf_vf {
 	/* version of the virtchnl from VF */
 	struct virtchnl_version_info version;
 	uint32_t request_caps; /* offload caps requested from VF */
+	uint64_t num_mdd_events; /* num of mdd events detected */
 
 	/*
 	 * Variables for store the arrival timestamp of VF messages.
--

2.17.1

#9 lore raw

PATCH v7 1/1 net/i40e: add PF MDD event handler

In reply to [email protected]

From: Zhu Tao <[email protected]>

Add warning and counter to handle the malicious driver detection event. When the hardware determines that a malicious driver on VF, this VF will become unworkable, the PF records and gives a warning message.

---
 doc/guides/nics/i40e.rst               |  1 +
 doc/guides/rel_notes/release_20_02.rst |  4 +-
 drivers/net/i40e/i40e_ethdev.c         | 89 +++++++++++++++++++++++++-
 drivers/net/i40e/i40e_ethdev.h         |  1 +
 4 files changed, 92 insertions(+), 3 deletions(-)

v7:
- fix subject patch version
v6:
- Change commit message
v5:
- Change commit message
v4:
- Change commit message
- Rebase doc/guides/rel_notes/release_20_02.rst
v3:
- Change commit message

doc/guides/nics/i40e.rst +1 -0
index c7c34b62f..2bf11e8ca 100644
@@ -43,6 +43,7 @@ Features of the i40e PMD are:
 - Dynamic Device Personalization (DDP)
 - Queue region configuration
 - Virtual Function Port Representors
+- Malicious Device Drive event catch and notify
 
 Prerequisites
 -------------
doc/guides/rel_notes/release_20_02.rst +3 -1
index 1e83e659a..a39f22221 100644
@@ -66,11 +66,13 @@ New Features
 
   * Added support for RSS using L3/L4 source/destination only.
 
-* **Updated i40e driver to support L2TPv3 over IP flows.**
+* **Updated i40e driver.**
 
   Updated the i40e PMD to support L2TPv3 over IP profiles which can be
   programmed by the dynamic device personalization (DDP) process.
 
+  Added PF support Malicious Device Drive event catch and notify.
+
 * **Updated testpmd to support L2TPv3 over IP flows.**
 
   Added support for L2TPv3 over IP rte_flow patterns to the testpmd
drivers/net/i40e/i40e_ethdev.c +87 -2

109 lines not on this page · raw message

drivers/net/i40e/i40e_ethdev.h +1 -0
index bba2b83b4..370e6298f 100644
@@ -426,6 +426,7 @@ struct i40e_pf_vf {
 	/* version of the virtchnl from VF */
 	struct virtchnl_version_info version;
 	uint32_t request_caps; /* offload caps requested from VF */
+	uint64_t num_mdd_events; /* num of mdd events detected */
 
 	/*
 	 * Variables for store the arrival timestamp of VF messages.
Signature · 1 line
2.17.1
#10 lore raw

PATCH v8 1/1 net/i40e: add PF MDD event handler

In reply to [email protected]

From: Zhu Tao <[email protected]>

Add warning and counter to handle the malicious driver detection event. When the hardware determines that a malicious driver on VF, this VF will become unworkable, the PF records and gives a warning message.

---
 doc/guides/nics/i40e.rst               |  1 +
 doc/guides/rel_notes/release_20_02.rst |  4 +-
 drivers/net/i40e/i40e_ethdev.c         | 94 +++++++++++++++++++++++++-
 drivers/net/i40e/i40e_ethdev.h         |  1 +
 4 files changed, 97 insertions(+), 3 deletions(-)

v8:
- Replace magic number with macros.
v7:
- fix subject patch version
v6:
- Change commit message
v5:
- Change commit message
v4:
- Change commit message
- Rebase doc/guides/rel_notes/release_20_02.rst
v3:
- Change commit message

doc/guides/nics/i40e.rst +1 -0
index c7c34b62f..2bf11e8ca 100644
@@ -43,6 +43,7 @@ Features of the i40e PMD are:
 - Dynamic Device Personalization (DDP)
 - Queue region configuration
 - Virtual Function Port Representors
+- Malicious Device Drive event catch and notify
 
 Prerequisites
 -------------
doc/guides/rel_notes/release_20_02.rst +3 -1
index 1e83e659a..a39f22221 100644
@@ -66,11 +66,13 @@ New Features
 
   * Added support for RSS using L3/L4 source/destination only.
 
-* **Updated i40e driver to support L2TPv3 over IP flows.**
+* **Updated i40e driver.**
 
   Updated the i40e PMD to support L2TPv3 over IP profiles which can be
   programmed by the dynamic device personalization (DDP) process.
 
+  Added PF support Malicious Device Drive event catch and notify.
+
 * **Updated testpmd to support L2TPv3 over IP flows.**
 
   Added support for L2TPv3 over IP rte_flow patterns to the testpmd
drivers/net/i40e/i40e_ethdev.c +92 -2

114 lines not on this page · raw message

drivers/net/i40e/i40e_ethdev.h +1 -0
index bba2b83b4..370e6298f 100644
@@ -426,6 +426,7 @@ struct i40e_pf_vf {
 	/* version of the virtchnl from VF */
 	struct virtchnl_version_info version;
 	uint32_t request_caps; /* offload caps requested from VF */
+	uint64_t num_mdd_events; /* num of mdd events detected */
 
 	/*
 	 * Variables for store the arrival timestamp of VF messages.
Signature · 1 line
2.17.1
Acked-by on v8 1/1 Applied
#11 lore raw
Quoted 196 lines · On 01/17, [email protected] wrote:

From: Zhu Tao <[email protected]>

Add warning and counter to handle the malicious driver detection event. When the hardware determines that a malicious driver on VF, this VF will become unworkable, the PF records and gives a warning message.

---

doc/guides/nics/i40e.rst               |  1 +
doc/guides/rel_notes/release_20_02.rst |  4 +-
drivers/net/i40e/i40e_ethdev.c         | 94 +++++++++++++++++++++++++-
drivers/net/i40e/i40e_ethdev.h         |  1 +
4 files changed, 97 insertions(+), 3 deletions(-)

v8:
- Replace magic number with macros.
v7:
- fix subject patch version
v6:
- Change commit message
v5:
- Change commit message
v4:
- Change commit message
- Rebase doc/guides/rel_notes/release_20_02.rst
v3:
- Change commit message

doc/guides/nics/i40e.rst +1 -3
index c7c34b62f..2bf11e8ca 100644
@@ -43,6 +43,7 @@ Features of the i40e PMD are:
- Dynamic Device Personalization (DDP)
- Queue region configuration
- Virtual Function Port Representors
+- Malicious Device Drive event catch and notify
 

Prerequisites
-------------

doc/guides/rel_notes/release_20_02.rst +3 -1
index 1e83e659a..a39f22221 100644
@@ -66,11 +66,13 @@ New Features
 
  * Added support for RSS using L3/L4 source/destination only.
 
-* **Updated i40e driver to support L2TPv3 over IP flows.**
+* **Updated i40e driver.**
 
  Updated the i40e PMD to support L2TPv3 over IP profiles which can be
  programmed by the dynamic device personalization (DDP) process.
 
+  Added PF support Malicious Device Drive event catch and notify.
+
 * **Updated testpmd to support L2TPv3 over IP flows.**
 
  Added support for L2TPv3 over IP rte_flow patterns to the testpmd
drivers/net/i40e/i40e_ethdev.c +92 -2
index afb6f554b..caca3e88f 100644
@@ -6760,6 +6760,92 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev)
 	rte_free(info.msg_buf);
 }
 
+static void
+i40e_handle_mdd_event(struct rte_eth_dev *dev)
+{
+#define I40E_MDD_CLEAR32 0xFFFFFFFF
+#define I40E_MDD_CLEAR16 0xFFFF
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	bool mdd_detected = false;
+	struct i40e_pf_vf *vf;
+	uint32_t reg;
+	int i;
+
+	/* find what triggered the MDD event */
+	reg = I40E_READ_REG(hw, I40E_GL_MDET_TX);
+	if (reg & I40E_GL_MDET_TX_VALID_MASK) {
+		uint8_t pf_num = (reg & I40E_GL_MDET_TX_PF_NUM_MASK) >>
+				I40E_GL_MDET_TX_PF_NUM_SHIFT;
+		uint16_t vf_num = (reg & I40E_GL_MDET_TX_VF_NUM_MASK) >>
+				I40E_GL_MDET_TX_VF_NUM_SHIFT;
+		uint8_t event = (reg & I40E_GL_MDET_TX_EVENT_MASK) >>
+				I40E_GL_MDET_TX_EVENT_SHIFT;
+		uint16_t queue = ((reg & I40E_GL_MDET_TX_QUEUE_MASK) >>
+				I40E_GL_MDET_TX_QUEUE_SHIFT) -
+					hw->func_caps.base_queue;
+		PMD_DRV_LOG(WARNING, "Malicious Driver Detection event 0x%02x on TX "
+			"queue %d PF number 0x%02x VF number 0x%02x device %s\n",
+				event, queue, pf_num, vf_num, dev->data->name);
+		I40E_WRITE_REG(hw, I40E_GL_MDET_TX, I40E_MDD_CLEAR32);
+		mdd_detected = true;
+	}
+	reg = I40E_READ_REG(hw, I40E_GL_MDET_RX);
+	if (reg & I40E_GL_MDET_RX_VALID_MASK) {
+		uint8_t func = (reg & I40E_GL_MDET_RX_FUNCTION_MASK) >>
+				I40E_GL_MDET_RX_FUNCTION_SHIFT;
+		uint8_t event = (reg & I40E_GL_MDET_RX_EVENT_MASK) >>
+				I40E_GL_MDET_RX_EVENT_SHIFT;
+		uint16_t queue = ((reg & I40E_GL_MDET_RX_QUEUE_MASK) >>
+				I40E_GL_MDET_RX_QUEUE_SHIFT) -
+					hw->func_caps.base_queue;
+
+		PMD_DRV_LOG(WARNING, "Malicious Driver Detection event 0x%02x on RX "
+				"queue %d of function 0x%02x device %s\n",
+					event, queue, func, dev->data->name);
+		I40E_WRITE_REG(hw, I40E_GL_MDET_RX, I40E_MDD_CLEAR32);
+		mdd_detected = true;
+	}
+
+	if (mdd_detected) {
+		reg = I40E_READ_REG(hw, I40E_PF_MDET_TX);
+		if (reg & I40E_PF_MDET_TX_VALID_MASK) {
+			I40E_WRITE_REG(hw, I40E_PF_MDET_TX, I40E_MDD_CLEAR16);
+			PMD_DRV_LOG(WARNING, "TX driver issue detected on PF\n");
+		}
+		reg = I40E_READ_REG(hw, I40E_PF_MDET_RX);
+		if (reg & I40E_PF_MDET_RX_VALID_MASK) {
+			I40E_WRITE_REG(hw, I40E_PF_MDET_RX,
+					I40E_MDD_CLEAR16);
+			PMD_DRV_LOG(WARNING, "RX driver issue detected on PF\n");
+		}
+	}
+
+	/* see if one of the VFs needs its hand slapped */
+	for (i = 0; i < pf->vf_num && mdd_detected; i++) {
+		vf = &pf->vfs[i];
+		reg = I40E_READ_REG(hw, I40E_VP_MDET_TX(i));
+		if (reg & I40E_VP_MDET_TX_VALID_MASK) {
+			I40E_WRITE_REG(hw, I40E_VP_MDET_TX(i),
+					I40E_MDD_CLEAR16);
+			vf->num_mdd_events++;
+			PMD_DRV_LOG(WARNING, "TX driver issue detected on VF %d %-"
+					PRIu64 "times\n",
+					i, vf->num_mdd_events);
+		}
+
+		reg = I40E_READ_REG(hw, I40E_VP_MDET_RX(i));
+		if (reg & I40E_VP_MDET_RX_VALID_MASK) {
+			I40E_WRITE_REG(hw, I40E_VP_MDET_RX(i),
+					I40E_MDD_CLEAR16);
+			vf->num_mdd_events++;
+			PMD_DRV_LOG(WARNING, "RX driver issue detected on VF %d %-"
+					PRIu64 "times\n",
+					i, vf->num_mdd_events);
+		}
+	}
+}
+
 /**
 * Interrupt handler triggered by NIC  for handling
 * specific interrupt.
@@ -6792,8 +6878,10 @@ i40e_dev_interrupt_handler(void *param)
 	}
 	if (icr0 & I40E_PFINT_ICR0_ECC_ERR_MASK)
 		PMD_DRV_LOG(ERR, "ICR0: unrecoverable ECC error");
-	if (icr0 & I40E_PFINT_ICR0_MAL_DETECT_MASK)
+	if (icr0 & I40E_PFINT_ICR0_MAL_DETECT_MASK) {
 		PMD_DRV_LOG(ERR, "ICR0: malicious programming detected");
+		i40e_handle_mdd_event(dev);
+	}
 	if (icr0 & I40E_PFINT_ICR0_GRST_MASK)
 		PMD_DRV_LOG(INFO, "ICR0: global reset requested");
 	if (icr0 & I40E_PFINT_ICR0_PCI_EXCEPTION_MASK)
@@ -6837,8 +6925,10 @@ i40e_dev_alarm_handler(void *param)
 		goto done;
 	if (icr0 & I40E_PFINT_ICR0_ECC_ERR_MASK)
 		PMD_DRV_LOG(ERR, "ICR0: unrecoverable ECC error");
-	if (icr0 & I40E_PFINT_ICR0_MAL_DETECT_MASK)
+	if (icr0 & I40E_PFINT_ICR0_MAL_DETECT_MASK) {
 		PMD_DRV_LOG(ERR, "ICR0: malicious programming detected");
+		i40e_handle_mdd_event(dev);
+	}
 	if (icr0 & I40E_PFINT_ICR0_GRST_MASK)
 		PMD_DRV_LOG(INFO, "ICR0: global reset requested");
 	if (icr0 & I40E_PFINT_ICR0_PCI_EXCEPTION_MASK)
drivers/net/i40e/i40e_ethdev.h +1 -0
index bba2b83b4..370e6298f 100644
@@ -426,6 +426,7 @@ struct i40e_pf_vf {
 	/* version of the virtchnl from VF */
 	struct virtchnl_version_info version;
 	uint32_t request_caps; /* offload caps requested from VF */
+	uint64_t num_mdd_events; /* num of mdd events detected */
 
 	/*
 	 * Variables for store the arrival timestamp of VF messages.
Signature · 1 line
2.17.1

Applied to dpdk-next-net-intel, Thanks.