diff mbox

[net-next,v2,03/14] i40e: Add PF reset when Malicious driver event for PF

Message ID 1403659585-32055-4-git-send-email-jeffrey.t.kirsher@intel.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Kirsher, Jeffrey T June 25, 2014, 1:26 a.m. UTC
From: Neerav Parikh <neerav.parikh@intel.com>

As per the spec when the PF driver receives a Malicious driver event
the queue that caused the event is already stopped and it is expected
that the function that owns the queue will reset the queue.
In some cases it may not be possible to determine the queue and it is
suggested to reset the whole function.

This patch takes the later approach when the event is owned by the PF
that owns it.

Change-ID: I40f9764a6a5e068c0ef8438db00c5aa9c2c6c1c8
Signed-off-by: Neerav Parikh <neerav.parikh@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
v2: added punctuation to print statements and code comment

 drivers/net/ethernet/intel/i40e/i40e_main.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

Comments

Joe Perches June 25, 2014, 2:16 a.m. UTC | #1
On Tue, 2014-06-24 at 18:26 -0700, Jeff Kirsher wrote:
> From: Neerav Parikh <neerav.parikh@intel.com>
> 
> As per the spec when the PF driver receives a Malicious driver event
> the queue that caused the event is already stopped and it is expected
> that the function that owns the queue will reset the queue.
> In some cases it may not be possible to determine the queue and it is
> suggested to reset the whole function.
> 
> This patch takes the later approach when the event is owned by the PF
> that owns it.
> 
> Change-ID: I40f9764a6a5e068c0ef8438db00c5aa9c2c6c1c8
> Signed-off-by: Neerav Parikh <neerav.parikh@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> ---
> v2: added punctuation to print statements and code comment

Comments are good, but I'd suggest removing trailing
periods from messages as close to 95% of the messages
in this driver do not use them.

$ grep -rP --include=*.[ch] -oh '.\\n"' drivers/net/ethernet/intel/i40e/| \
  sed 's/[^\.]\\n/X\\n/' | sort | uniq -c | sort -rn
    621 X\n"
     41 .\n"


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Kirsher, Jeffrey T June 25, 2014, 2:35 a.m. UTC | #2
On Tue, 2014-06-24 at 19:16 -0700, Joe Perches wrote:
> On Tue, 2014-06-24 at 18:26 -0700, Jeff Kirsher wrote:
> > From: Neerav Parikh <neerav.parikh@intel.com>
> > 
> > As per the spec when the PF driver receives a Malicious driver event
> > the queue that caused the event is already stopped and it is expected
> > that the function that owns the queue will reset the queue.
> > In some cases it may not be possible to determine the queue and it is
> > suggested to reset the whole function.
> > 
> > This patch takes the later approach when the event is owned by the PF
> > that owns it.
> > 
> > Change-ID: I40f9764a6a5e068c0ef8438db00c5aa9c2c6c1c8
> > Signed-off-by: Neerav Parikh <neerav.parikh@intel.com>
> > Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> > ---
> > v2: added punctuation to print statements and code comment
> 
> Comments are good, but I'd suggest removing trailing
> periods from messages as close to 95% of the messages
> in this driver do not use them.
> 
> $ grep -rP --include=*.[ch] -oh '.\\n"' drivers/net/ethernet/intel/i40e/| \
>   sed 's/[^\.]\\n/X\\n/' | sort | uniq -c | sort -rn
>     621 X\n"
>      41 .\n"
> 
> 

Just to note, the punctuation that was added was a comma and not a
trailing period.  I know that we have tried to clean up the trailing
periods, I will see about going through the driver and put together a
cleanup patch.  Thanks Joe.
diff mbox

Patch

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 3f60976..80c5d55 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -5827,6 +5827,7 @@  static void i40e_handle_mdd_event(struct i40e_pf *pf)
 {
 	struct i40e_hw *hw = &pf->hw;
 	bool mdd_detected = false;
+	bool pf_mdd_detected = false;
 	struct i40e_vf *vf;
 	u32 reg;
 	int i;
@@ -5866,6 +5867,30 @@  static void i40e_handle_mdd_event(struct i40e_pf *pf)
 		mdd_detected = true;
 	}
 
+	if (mdd_detected) {
+		reg = rd32(hw, I40E_PF_MDET_TX);
+		if (reg & I40E_PF_MDET_TX_VALID_MASK) {
+			wr32(hw, I40E_PF_MDET_TX, 0xFFFF);
+			dev_info(&pf->pdev->dev,
+				 "MDD TX event is for this function 0x%08x, requesting PF reset.\n",
+				 reg);
+			pf_mdd_detected = true;
+		}
+		reg = rd32(hw, I40E_PF_MDET_RX);
+		if (reg & I40E_PF_MDET_RX_VALID_MASK) {
+			wr32(hw, I40E_PF_MDET_RX, 0xFFFF);
+			dev_info(&pf->pdev->dev,
+				 "MDD RX event is for this function 0x%08x, requesting PF reset.\n",
+				 reg);
+			pf_mdd_detected = true;
+		}
+		/* Queue belongs to the PF, initiate a reset */
+		if (pf_mdd_detected) {
+			set_bit(__I40E_PF_RESET_REQUESTED, &pf->state);
+			i40e_service_event_schedule(pf);
+		}
+	}
+
 	/* see if one of the VFs needs its hand slapped */
 	for (i = 0; i < pf->num_alloc_vfs && mdd_detected; i++) {
 		vf = &(pf->vf[i]);