Re: [Intel-wired-lan] [iwl-next v3 3/4] ixgbe: add Tx hang detection unhandled MDD

2025-06-27 Thread Romanowski, Rafal
> -Original Message-
> From: Intel-wired-lan  On Behalf Of Simon
> Horman
> Sent: Tuesday, February 18, 2025 8:37 PM
> To: Michal Swiatkowski 
> Cc: [email protected]; [email protected];
> [email protected]; Jagielski, Jedrzej 
> ;
> Kitszel, Przemyslaw ; Kwapulinski, Piotr
> ; Nguyen, Anthony L
> ; Osuchowski, Dawid
> ; [email protected]
> Subject: Re: [Intel-wired-lan] [iwl-next v3 3/4] ixgbe: add Tx hang detection
> unhandled MDD
> 
> On Mon, Feb 17, 2025 at 10:06:35AM +0100, Michal Swiatkowski wrote:
> > From: Slawomir Mrozowicz 
> >
> > Add Tx Hang detection due to an unhandled MDD Event.
> >
> > Previously, a malicious VF could disable the entire port causing TX to
> > hang on the E610 card.
> > Those events that caused PF to freeze were not detected as an MDD
> > event and usually required a Tx Hang watchdog timer to catch the
> > suspension, and perform a physical function reset.
> >
> > Implement flows in the affected PF driver in such a way to check the
> > cause of the hang, detect it as an MDD event and log an entry of the
> > malicious VF that caused the Hang.
> >
> > The PF blocks the malicious VF, if it continues to be the source of
> > several MDD events.
> >
> > Reviewed-by: Przemek Kitszel 
> > Reviewed-by: Marcin Szycik 
> > Signed-off-by: Slawomir Mrozowicz 
> > Co-developed-by: Michal Swiatkowski
> > 
> > Signed-off-by: Michal Swiatkowski 
> 
> Reviewed-by: Simon Horman 

Tested-by: Rafal Romanowski 




Re: [Intel-wired-lan] [iwl-next v3 3/4] ixgbe: add Tx hang detection unhandled MDD

2025-02-18 Thread Simon Horman
On Mon, Feb 17, 2025 at 10:06:35AM +0100, Michal Swiatkowski wrote:
> From: Slawomir Mrozowicz 
> 
> Add Tx Hang detection due to an unhandled MDD Event.
> 
> Previously, a malicious VF could disable the entire port causing
> TX to hang on the E610 card.
> Those events that caused PF to freeze were not detected
> as an MDD event and usually required a Tx Hang watchdog timer
> to catch the suspension, and perform a physical function reset.
> 
> Implement flows in the affected PF driver in such a way to check
> the cause of the hang, detect it as an MDD event and log an
> entry of the malicious VF that caused the Hang.
> 
> The PF blocks the malicious VF, if it continues to be the source
> of several MDD events.
> 
> Reviewed-by: Przemek Kitszel 
> Reviewed-by: Marcin Szycik 
> Signed-off-by: Slawomir Mrozowicz 
> Co-developed-by: Michal Swiatkowski 
> Signed-off-by: Michal Swiatkowski 

Reviewed-by: Simon Horman 



[Intel-wired-lan] [iwl-next v3 3/4] ixgbe: add Tx hang detection unhandled MDD

2025-02-17 Thread Michal Swiatkowski
From: Slawomir Mrozowicz 

Add Tx Hang detection due to an unhandled MDD Event.

Previously, a malicious VF could disable the entire port causing
TX to hang on the E610 card.
Those events that caused PF to freeze were not detected
as an MDD event and usually required a Tx Hang watchdog timer
to catch the suspension, and perform a physical function reset.

Implement flows in the affected PF driver in such a way to check
the cause of the hang, detect it as an MDD event and log an
entry of the malicious VF that caused the Hang.

The PF blocks the malicious VF, if it continues to be the source
of several MDD events.

Reviewed-by: Przemek Kitszel 
Reviewed-by: Marcin Szycik 
Signed-off-by: Slawomir Mrozowicz 
Co-developed-by: Michal Swiatkowski 
Signed-off-by: Michal Swiatkowski 
---
 drivers/net/ethernet/intel/ixgbe/ixgbe.h  |   5 +
 drivers/net/ethernet/intel/ixgbe/ixgbe_type.h |  12 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c  |   3 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 211 --
 4 files changed, 209 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h 
b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
index e6a380d4929b..81ccb4c591ba 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
@@ -427,6 +427,10 @@ enum ixgbe_ring_f_enum {
 #define IXGBE_BAD_L2A_QUEUE3
 #define IXGBE_MAX_MACVLANS 63
 
+#define IXGBE_MAX_TX_QUEUES128
+#define IXGBE_MAX_TX_DESCRIPTORS   40
+#define IXGBE_MAX_TX_VF_HANGS  4
+
 DECLARE_STATIC_KEY_FALSE(ixgbe_xdp_locking_key);
 
 struct ixgbe_ring_feature {
@@ -798,6 +802,7 @@ struct ixgbe_adapter {
u32 timer_event_accumulator;
u32 vferr_refcount;
struct ixgbe_mac_addr *mac_table;
+   u8 tx_hang_count[IXGBE_MAX_TX_QUEUES];
struct kobject *info_kobj;
u16 lse_mask;
 #ifdef CONFIG_IXGBE_HWMON
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
index aa3b498558bc..783e76c0e8a2 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
@@ -1044,6 +1044,7 @@ struct ixgbe_nvm_version {
 #define IXGBE_GCR_EXT_VT_MODE_160x0001
 #define IXGBE_GCR_EXT_VT_MODE_320x0002
 #define IXGBE_GCR_EXT_VT_MODE_640x0003
+#define IXGBE_GCR_EXT_VT_MODE_MASK  0x0003
 #define IXGBE_GCR_EXT_SRIOV (IXGBE_GCR_EXT_MSIX_EN | \
 IXGBE_GCR_EXT_VT_MODE_64)
 
@@ -2935,6 +2936,13 @@ struct ixgbe_adv_tx_context_desc {
__le32 mss_l4len_idx;
 };
 
+enum {
+   IXGBE_VLAN_MACIP_LENS_REG   = 0,
+   IXGBE_FCEOF_SAIDX_REG   = 1,
+   IXGBE_TYPE_TUCMD_MLHL   = 2,
+   IXGBE_MSS_L4LEN_IDX = 3,
+};
+
 /* Adv Transmit Descriptor Config Masks */
 #define IXGBE_ADVTXD_DTALEN_MASK  0x /* Data buf length(bytes) */
 #define IXGBE_ADVTXD_MAC_LINKSEC  0x0004 /* Insert LinkSec */
@@ -2942,7 +2950,7 @@ struct ixgbe_adv_tx_context_desc {
 #define IXGBE_ADVTXD_IPSEC_SA_INDEX_MASK   0x03FF /* IPSec SA index */
 #define IXGBE_ADVTXD_IPSEC_ESP_LEN_MASK0x01FF /* IPSec ESP length */
 #define IXGBE_ADVTXD_DTYP_MASK  0x00F0 /* DTYP mask */
-#define IXGBE_ADVTXD_DTYP_CTXT  0x0020 /* Advanced Context Desc */
+#define IXGBE_ADVTXD_DTYP_CTXT 0x2 /* Advanced Context Desc */
 #define IXGBE_ADVTXD_DTYP_DATA  0x0030 /* Advanced Data Descriptor */
 #define IXGBE_ADVTXD_DCMD_EOP   IXGBE_TXD_CMD_EOP  /* End of Packet */
 #define IXGBE_ADVTXD_DCMD_IFCS  IXGBE_TXD_CMD_IFCS /* Insert FCS */
@@ -2991,6 +2999,8 @@ struct ixgbe_adv_tx_context_desc {
 #define IXGBE_ADVTXD_FCOEF_EOF_MASK  (3u << 10)  /* FC EOF index */
 #define IXGBE_ADVTXD_L4LEN_SHIFT 8  /* Adv ctxt L4LEN shift */
 #define IXGBE_ADVTXD_MSS_SHIFT   16  /* Adv ctxt MSS shift */
+#define IXGBE_ADVTXD_MSS_MASK  GENMASK(31, IXGBE_ADVTXD_MSS_SHIFT)
+#define IXGBE_ADVTXD_HEADER_LEN_MASK   GENMASK(8, 0)
 
 /* Autonegotiation advertised speeds */
 typedef u32 ixgbe_autoneg_advertised;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c
index 336d47ffb95a..54d75cf94cc1 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c
@@ -1293,7 +1293,8 @@ void ixgbe_tx_ctxtdesc(struct ixgbe_ring *tx_ring, u32 
vlan_macip_lens,
tx_ring->next_to_use = (i < tx_ring->count) ? i : 0;
 
/* set bits to identify this as an advanced context descriptor */
-   type_tucmd |= IXGBE_TXD_CMD_DEXT | IXGBE_ADVTXD_DTYP_CTXT;
+   type_tucmd |= IXGBE_TXD_CMD_DEXT |
+   FIELD_PREP(IXGBE_ADVTXD_DTYP_MASK, IXGBE_ADVTXD_DTYP_CTXT);
 
context_desc->vlan_macip_lens   = cpu_to_le32(vlan_macip_lens);
context_desc->fceof_saidx   = cpu_to_le32(fceof_saidx);
diff --git