ice: Reset VF on Tx MDD event
Subsystems (3)
PATCH v4 1/1 ice: Reset VF on Tx MDD event
In cases when VF sends malformed packets that are classified as malicious, sometimes it causes Tx queue to freeze. This frozen queue can be stuck for several minutes being unusable. This behavior can be reproduced with a faulty userspace app running on VF.
When any Malicious Driver Detection event occurs and the mdd-auto-reset-vf private flag is set, perform a graceful VF reset to quickly bring VF back to operational state. Add a log message to notify about the cause of the reset. Add a helper for this to be reused for both TX and RX events.
---
v4: Only perform auto-reset once per VF
v3 [1]: Only auto reset VF if the mdd-auto-reset-vf flag is set v2 [2]: Revert an unneeded formatting change, fix commit message, fix a log
message with a correct event name
[1] https://lore.kernel.org/intel-wired-lan/[email protected]
[2] https://lore.kernel.org/netdev/[email protected]
--- drivers/net/ethernet/intel/ice/ice_main.c | 57 +++++++++++++++++----- drivers/net/ethernet/intel/ice/ice_sriov.c | 25 +++++++--- drivers/net/ethernet/intel/ice/ice_sriov.h | 2 + 3 files changed, 67 insertions(+), 17 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +46 -11
@@ -1745,6 +1745,39 @@ static void ice_service_timer(struct timer_list *t)ice_service_task_schedule (pf); } +/** +* ice_mdd_maybe_reset_vf - reset VF after MDD event +* @pf: pointer to the PF structure +* @vf: pointer to the VF structure +* @reset_vf_tx: whether Tx MDD has occurred +* @reset_vf_rx: whether Rx MDD has occurred +* +* Since the queue can get stuck on VF MDD events, the PF can be configured to +* automatically reset the VF by enabling the private ethtool flag +* mdd-auto-reset-vf. +*/ +static void ice_mdd_maybe_reset_vf (struct ice_pf *pf,struct ice_vf *vf, +bool reset_vf_tx,bool reset_vf_rx) +{ +struct device *dev =ice_pf_to_dev (pf); + +if (!test_bit (ICE_FLAG_MDD_AUTO_RESET_VF , pf->flags)) +return ; + +/* VF MDD event counters will be cleared by reset, so print the event +* prior to reset. +*/ +if (reset_vf_tx) +ice_print_vf_tx_mdd_event (vf); + +if (reset_vf_rx) +ice_print_vf_rx_mdd_event (vf); + +dev_info (dev,"PF-to-VF reset on PF %d VF %d due to MDD event\n" , + pf->hw.pf_id, vf->vf_id); +ice_reset_vf (vf,ICE_VF_RESET_NOTIFY |ICE_VF_RESET_LOCK ); +} +/** * ice_handle_mdd_event - handle malicious driver detect event * @pf: pointer to the PF structure
@@ -1838,6 +1871,8 @@ static void ice_handle_mdd_event(struct ice_pf *pf)*/ mutex_lock (&pf->vfs.table_lock);ice_for_each_vf (pf, bkt, vf) { +bool reset_vf_tx = false, reset_vf_rx = false; + reg =rd32 (hw,VP_MDET_TX_PQM (vf->vf_id));if (reg &VP_MDET_TX_PQM_VALID_M ) {wr32 (hw,VP_MDET_TX_PQM (vf->vf_id),0xFFFF );
@@ -1846,6 +1881,8 @@ static void ice_handle_mdd_event(struct ice_pf *pf)if (netif_msg_tx_err (pf))dev_info (dev,"Malicious Driver Detection event TX_PQM detected on VF %d\n" , vf->vf_id); + + reset_vf_tx = true; } reg =rd32 (hw,VP_MDET_TX_TCLAN (vf->vf_id));
@@ -1856,6 +1893,8 @@ static void ice_handle_mdd_event(struct ice_pf *pf)if (netif_msg_tx_err (pf))dev_info (dev,"Malicious Driver Detection event TX_TCLAN detected on VF %d\n" , vf->vf_id); + + reset_vf_tx = true; } reg =rd32 (hw,VP_MDET_TX_TDPU (vf->vf_id));
@@ -1866,6 +1905,8 @@ static void ice_handle_mdd_event(struct ice_pf *pf)if (netif_msg_tx_err (pf))dev_info (dev,"Malicious Driver Detection event TX_TDPU detected on VF %d\n" , vf->vf_id); + + reset_vf_tx = true; } reg =rd32 (hw,VP_MDET_RX (vf->vf_id));
@@ -1877,18 +1918,12 @@ static void ice_handle_mdd_event(struct ice_pf *pf)dev_info (dev,"Malicious Driver Detection event RX detected on VF %d\n" , vf->vf_id); -/* Since the queue is disabled on VF Rx MDD events, the -* PF can be configured to reset the VF through ethtool -* private flag mdd-auto-reset-vf. -*/ -if (test_bit (ICE_FLAG_MDD_AUTO_RESET_VF , pf->flags)) { -/* VF MDD event counters will be cleared by -* reset, so print the event prior to reset. -*/ -ice_print_vf_rx_mdd_event (vf); -ice_reset_vf (vf,ICE_VF_RESET_LOCK ); - } + reset_vf_rx = true; } + +if (reset_vf_tx || reset_vf_rx) +ice_mdd_maybe_reset_vf (pf, vf, reset_vf_tx, + reset_vf_rx); }mutex_unlock (&pf->vfs.table_lock);
drivers/net/ethernet/intel/ice/ice_sriov.c +19 -6
@@ -1861,6 +1861,24 @@ void ice_print_vf_rx_mdd_event(struct ice_vf *vf) ? "on" : "off"); } +/** +* ice_print_vf_tx_mdd_event - print VF Tx malicious driver detect event +* @vf: pointer to the VF structure +*/ +void ice_print_vf_tx_mdd_event (struct ice_vf *vf) +{ +struct ice_pf *pf = vf->pf; +struct device *dev; + + dev =ice_pf_to_dev (pf); + +dev_info (dev,"%d Tx Malicious Driver Detection events detected on PF %d VF %d MAC %pM. mdd-auto-reset-vfs=%s\n" , + vf->mdd_tx_events.count, pf->hw.pf_id, vf->vf_id, + vf->dev_lan_addr, +test_bit (ICE_FLAG_MDD_AUTO_RESET_VF , pf->flags) + ?"on" :"off" ); +} +/** * ice_print_vfs_mdd_events - print VFs malicious driver detect event * @pf: pointer to the PF structure
@@ -1869,8 +1887,6 @@ void ice_print_vf_rx_mdd_event(struct ice_vf *vf)*/ void ice_print_vfs_mdd_events (struct ice_pf *pf) { -struct device *dev =ice_pf_to_dev (pf); -struct ice_hw *hw = &pf->hw;struct ice_vf *vf;unsigned int bkt;
@@ -1897,10 +1913,7 @@ void ice_print_vfs_mdd_events(struct ice_pf *pf)if (vf->mdd_tx_events.count != vf->mdd_tx_events.last_printed) { vf->mdd_tx_events.last_printed = vf->mdd_tx_events.count; - -dev_info (dev,"%d Tx Malicious Driver Detection events detected on PF %d VF %d MAC %pM.\n" , - vf->mdd_tx_events.count, hw->pf_id, vf->vf_id, - vf->dev_lan_addr); +ice_print_vf_tx_mdd_event (vf); } }mutex_unlock (&pf->vfs.table_lock);
drivers/net/ethernet/intel/ice/ice_sriov.h +2 -0
@@ -58,6 +58,7 @@ void ice_vf_lan_overflow_event(struct ice_pf *pf, struct ice_rq_event_info *event);void ice_print_vfs_mdd_events (struct ice_pf *pf);void ice_print_vf_rx_mdd_event (struct ice_vf *vf); +void ice_print_vf_tx_mdd_event (struct ice_vf *vf);bool ice_vc_validate_pattern (struct ice_vf *vf,struct virtchnl_proto_hdrs *proto);u32 ice_sriov_get_vf_total_msix (struct pci_dev *pdev);
@@ -69,6 +70,7 @@ static inlinevoid ice_vf_lan_overflow_event (struct ice_pf *pf,struct ice_rq_event_info *event) { }static inline void ice_print_vfs_mdd_events (struct ice_pf *pf) { }static inline void ice_print_vf_rx_mdd_event (struct ice_vf *vf) { } +static inline void ice_print_vf_tx_mdd_event (struct ice_vf *vf) { }static inline void ice_restore_all_vfs_msi_state (struct ice_pf *pf) { } static inline int
Signature · 1 line
2.41.0
Quoted 16 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Marcin Szycik
Sent: Tuesday, April 2, 2024 6:52 PM
To: [email protected]
Cc: Drewek, Wojciech <[email protected]>; Wang, Liang-min <[email protected]>; [email protected]; Chmielewski, Pawel <[email protected]>; Marcin Szycik <[email protected]>; Nguyen, Anthony L <[email protected]>; [email protected]; Kitszel, Przemyslaw <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next v4] ice: Reset VF on Tx MDD event
Please state in the title explicitly the purpose of the patch:
Do you fix a bug? say fix
Do you add functionality? say add
Do you refactor? say refactor
Quoted 11 lines
In cases when VF sends malformed packets that are classified as malicious, sometimes it causes Tx queue to freeze. This frozen queue can be stuck for several minutes being unusable. This behavior can be reproduced with a faulty userspace app running on VF.
When any Malicious Driver Detection event occurs and the mdd-auto- reset-vf private flag is set, perform a graceful VF reset to quickly bring VF back to operational state. Add a log message to notify about the cause of the reset. Add a helper for this to be reused for both TX and RX events.
Please describe your changes explicitly:
Do you just add a helper function without adding a new functionality?
Do you add functionality?
Do you fix?
Please explain what are the changes in driver behavior and the changes in the driver sources you make. Thank you
Quoted 224 lines
Reviewed-by Wojciech Drewek <[email protected]>Reviewed-by Przemek Kitszel <[email protected]>Co-developed-by Liang-Min Wang <[email protected]>Signed-off-by Liang-Min Wang <[email protected]>Signed-off-by Marcin Szycik <[email protected]>---
v4: Only perform auto-reset once per VF
v3 [1]: Only auto reset VF if the mdd-auto-reset-vf flag is set v2 [2]: Revert an unneeded formatting change, fix commit message, fix a log
message with a correct event name[1] https://lore.kernel.org/intel-wired-lan/20240326164455.735739-
[email protected]
[2] https://lore.kernel.org/netdev/20231102155149.2574209-1-
[email protected]--- drivers/net/ethernet/intel/ice/ice_main.c | 57 +++++++++++++++++- ---- drivers/net/ethernet/intel/ice/ice_sriov.c | 25 +++++++--- drivers/net/ethernet/intel/ice/ice_sriov.h | 2 + 3 files changed, 67 insertions(+), 17 deletions(-)drivers/net/ethernet/intel/ice/ice_main.c +20
-0@@ -1745,6 +1745,39 @@ static void ice_service_timer(struct timer_list *t)ice_service_task_schedule (pf ); } +/** +* ice_mdd_maybe_reset_vf - reset VF after MDD event +* @pf: pointer to the PF structure +* @vf: pointer to the VF structure +* @reset_vf_tx: whether Tx MDD has occurred +* @reset_vf_rx: whether Rx MDD has occurred +* +* Since the queue can get stuck on VF MDD events, the PF can be +configured to +* automatically reset the VF by enabling the private ethtool flag +* mdd-auto-reset-vf. +*/ +static void ice_mdd_maybe_reset_vf (struct ice_pf *pf,struct ice_vf *vf, +bool reset_vf_tx,bool reset_vf_rx) { +struct device *dev =ice_pf_to_dev (pf); + +if (!test_bit (ICE_FLAG_MDD_AUTO_RESET_VF , pf->flags)) +return ; + +/* VF MDD event counters will be cleared by reset, so print the event
drivers/net/ethernet/intel/ice/ice_main.c +9
-0+* prior to reset. +*/ +if (reset_vf_tx) +ice_print_vf_tx_mdd_event (vf); + +if (reset_vf_rx) +ice_print_vf_rx_mdd_event (vf); + + dev_info(dev, "PF-to-VF reset on PF %d VF %d due to MDDevent\n",
drivers/net/ethernet/intel/ice/ice_main.c +5
-0+ pf->hw.pf_id, vf->vf_id); +ice_reset_vf (vf,ICE_VF_RESET_NOTIFY |ICE_VF_RESET_LOCK ); } +/** * ice_handle_mdd_event - handle malicious driver detect event * @pf: pointer to the PF structure @@ -1838,6 +1871,8 @@ static void ice_handle_mdd_event(structice_pf *pf) */ mutex_lock (&pf->vfs.table_lock);ice_for_each_vf (pf, bkt, vf) { +bool reset_vf_tx = false, reset_vf_rx = false; + reg =rd32 (hw,VP_MDET_TX_PQM (vf->vf_id));if (reg &VP_MDET_TX_PQM_VALID_M ) {
wr32(hw, VP_MDET_TX_PQM(vf->vf_id), 0xFFFF); @@ -
1846,6 +1881,8 @@ static voidice_handle_mdd_event(struct ice_pf *pf)drivers/net/ethernet/intel/ice/ice_main.c +0
-0if (netif_msg_tx_err (pf)) dev_info(dev, "Malicious Driver Detectionevent
TX_PQMdetected on VF %d\n",drivers/net/ethernet/intel/ice/ice_main.c +3
-0vf->vf_id); + + reset_vf_tx = true; } reg = rd32(hw, VP_MDET_TX_TCLAN(vf->vf_id)); @@ -1856,6 +1893,8 @@ static void ice_handle_mdd_event(struct ice_pf *pf) if (netif_msg_tx_err(pf)) dev_info(dev, "Malicious Driver Detectionevent
TX_TCLANdetected on VF %d\n",drivers/net/ethernet/intel/ice/ice_main.c +3
-0vf->vf_id); + + reset_vf_tx = true; } reg = rd32(hw, VP_MDET_TX_TDPU(vf->vf_id)); @@ -1866,6 +1905,8 @@ static void ice_handle_mdd_event(struct ice_pf *pf) if (netif_msg_tx_err(pf)) dev_info(dev, "Malicious Driver Detectionevent
TX_TDPUdetected on VF %d\n",drivers/net/ethernet/intel/ice/ice_main.c +3
-0vf->vf_id); + + reset_vf_tx = true; } reg = rd32(hw, VP_MDET_RX(vf->vf_id)); @@ -1877,18 +1918,12 @@ static void ice_handle_mdd_event(struct ice_pf *pf) dev_info(dev, "Malicious Driver Detectionevent RX detected on VF %d\n",
drivers/net/ethernet/intel/ice/ice_main.c +0
-1vf->vf_id); -/* Since the queue is disabled on VF Rx MDD events, the
drivers/net/ethernet/intel/ice/ice_main.c +0
-1-* PF can be configured to reset the VF through ethtool
drivers/net/ethernet/intel/ice/ice_main.c +0
-3-* private flag mdd-auto-reset-vf. -*/ - if (test_bit(ICE_FLAG_MDD_AUTO_RESET_VF, pf-Quoted 1 line
flags)) {
drivers/net/ethernet/intel/ice/ice_main.c +0
-2-/* VF MDD event counters will be cleared by -* reset, so print the event prior to reset.
drivers/net/ethernet/intel/ice/ice_main.c +5
-4-*/ -ice_print_vf_rx_mdd_event (vf); -ice_reset_vf (vf,ICE_VF_RESET_LOCK ); - } + reset_vf_rx = true; } + +if (reset_vf_tx || reset_vf_rx) +ice_mdd_maybe_reset_vf (pf, vf, reset_vf_tx, + reset_vf_rx); }mutex_unlock (&pf->vfs.table_lock);drivers/net/ethernet/intel/ice/ice_sriov.c +18
-0@@ -1861,6 +1861,24 @@ void ice_print_vf_rx_mdd_event(struct ice_vf *vf) ? "on" : "off"); } +/** +* ice_print_vf_tx_mdd_event - print VF Tx malicious driver detect +event +* @vf: pointer to the VF structure +*/ +void ice_print_vf_tx_mdd_event (struct ice_vf *vf) { +struct ice_pf *pf = vf->pf; +struct device *dev; + + dev =ice_pf_to_dev (pf); + + dev_info(dev, "%d Tx Malicious Driver Detection events detected on PF %d VF %d MAC %pM. mdd-auto-reset-vfs=%s\n", + vf->mdd_tx_events.count, pf->hw.pf_id, vf->vf_id, + vf->dev_lan_addr, +test_bit (ICE_FLAG_MDD_AUTO_RESET_VF , pf->flags) + ?"on" :"off" ); +} +/** *
ice_print_vfs_mdd_events- print VFs malicious driver detect
event
* @pf: pointer to the PF structuredrivers/net/ethernet/intel/ice/ice_sriov.c +1
-6@@ -1869,8 +1887,6 @@ void ice_print_vf_rx_mdd_event(struct ice_vf*vf) */ void ice_print_vfs_mdd_events (struct ice_pf *pf) { -struct device *dev =ice_pf_to_dev (pf); -struct ice_hw *hw = &pf->hw;struct ice_vf *vf;unsigned int bkt;@@ -1897,10 +1913,7 @@ void ice_print_vfs_mdd_events(struct ice_pf *pf)if (vf->mdd_tx_events.count != vf- >mdd_tx_events.last_printed) { vf->mdd_tx_events.last_printed = vf->mdd_tx_events.count; - - dev_info(dev, "%d Tx Malicious Driver Detection events detected on PF %d VF %d MAC %pM.\n", - vf->mdd_tx_events.count, hw->pf_id, vf- >vf_id, - vf->dev_lan_addr); +ice_print_vf_tx_mdd_event (vf ); } }mutex_unlock (&pf->vfs.table_lock);drivers/net/ethernet/intel/ice/ice_sriov.h +0
-0@@ -58,6 +58,7 @@ void ice_vf_lan_overflow_event(struct ice_pf *pf, struct
ice_rq_event_info*event); voidice_print_vfs_mdd_events(struct ice_pf *pf); voidice_print_vf_rx_mdd_event(struct ice_vf *vf); +voidice_print_vf_tx_mdd_event(struct ice_vf *vf);
bool
ice_vc_validate_pattern(structice_vf*vf, structvirtchnl_proto_hdrs*proto);
u32ice_sriov_get_vf_total_msix(struct pci_dev *pdev); @@ -69,6
+70,7 @@ static inline voidice_vf_lan_overflow_event(struct ice_pf *pf, struct ice_rq_event_info *event){ } static inline voidice_print_vfs_mdd_events(struct ice_pf *pf){ } static inline voidice_print_vf_rx_mdd_event(struct ice_vf *vf){ } +static inline voidice_print_vf_tx_mdd_event(struct ice_vf *vf){ }
static inline void ice_restore_all_vfs_msi_state(structice_pf
*pf) { }static inline int
--
2.41.0
Quoted 16 lines · Aleksandr
Quoted 16 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Marcin Szycik
Sent: Tuesday, April 2, 2024 6:52 PM
To: [email protected]
Cc: Drewek, Wojciech <[email protected]>; Wang, Liang-min <[email protected]>; [email protected]; Chmielewski, Pawel <[email protected]>; Marcin Szycik <[email protected]>; Nguyen, Anthony L <[email protected]>; [email protected]; Kitszel, Przemyslaw <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next v4] ice: Reset VF on Tx MDD event
Quoted 4 lines
Please state in the title explicitly the purpose of the patch:
Do you fix a bug? say fix
Do you add functionality? say add
Do you refactor? say refactor
IMO it's neither of those.
It's not a bugfix because the driver itself doesn't do anything wrong; the patch provides the user with a kind of optional workaround for an userspace app that's behaving incorrectly.
It's not really new functionality, since the mdd-auto-reset-vf flag was already implemented and auto reset was already happening for Rx events. I'm just extending this to Tx as well.
And it's not strictly a refactor because I'm changing behaviour.
Please also note that I've picked up a patch not originally made by me [2], and kept the original title and most of the description. I'm open to suggestions to title though.
Quoted 11 lines
Quoted 11 lines
In cases when VF sends malformed packets that are classified as malicious, sometimes it causes Tx queue to freeze. This frozen queue can be stuck for several minutes being unusable. This behavior can be reproduced with a faulty userspace app running on VF.
When any Malicious Driver Detection event occurs and the mdd-auto- reset-vf private flag is set, perform a graceful VF reset to quickly bring VF back to operational state. Add a log message to notify about the cause of the reset. Add a helper for this to be reused for both TX and RX events.
Quoted 6 lines
Please describe your changes explicitly:
Do you just add a helper function without adding a new functionality?
Do you add functionality?
Do you fix?
Please explain what are the changes in driver behavior and the changes in the driver sources you make. Thank you
I'll try to make the description more explicit.
Thanks,
Marcin
Quoted 225 lines
Quoted 224 lines
Reviewed-by Wojciech Drewek <[email protected]>Reviewed-by Przemek Kitszel <[email protected]>Co-developed-by Liang-Min Wang <[email protected]>Signed-off-by Liang-Min Wang <[email protected]>Signed-off-by Marcin Szycik <[email protected]>---
v4: Only perform auto-reset once per VF
v3 [1]: Only auto reset VF if the mdd-auto-reset-vf flag is set v2 [2]: Revert an unneeded formatting change, fix commit message, fix a log
message with a correct event name[1] https://lore.kernel.org/intel-wired-lan/20240326164455.735739-
[email protected]
[2] https://lore.kernel.org/netdev/20231102155149.2574209-1-
[email protected]--- drivers/net/ethernet/intel/ice/ice_main.c | 57 +++++++++++++++++- ---- drivers/net/ethernet/intel/ice/ice_sriov.c | 25 +++++++--- drivers/net/ethernet/intel/ice/ice_sriov.h | 2 + 3 files changed, 67 insertions(+), 17 deletions(-)drivers/net/ethernet/intel/ice/ice_main.c +20
-0@@ -1745,6 +1745,39 @@ static void ice_service_timer(struct timer_list *t)ice_service_task_schedule (pf ); } +/** +* ice_mdd_maybe_reset_vf - reset VF after MDD event +* @pf: pointer to the PF structure +* @vf: pointer to the VF structure +* @reset_vf_tx: whether Tx MDD has occurred +* @reset_vf_rx: whether Rx MDD has occurred +* +* Since the queue can get stuck on VF MDD events, the PF can be +configured to +* automatically reset the VF by enabling the private ethtool flag +* mdd-auto-reset-vf. +*/ +static void ice_mdd_maybe_reset_vf (struct ice_pf *pf,struct ice_vf *vf, +bool reset_vf_tx,bool reset_vf_rx) { +struct device *dev =ice_pf_to_dev (pf); + +if (!test_bit (ICE_FLAG_MDD_AUTO_RESET_VF , pf->flags)) +return ; + +/* VF MDD event counters will be cleared by reset, so print the event
drivers/net/ethernet/intel/ice/ice_main.c +9
-0+* prior to reset. +*/ +if (reset_vf_tx) +ice_print_vf_tx_mdd_event (vf); + +if (reset_vf_rx) +ice_print_vf_rx_mdd_event (vf); + + dev_info(dev, "PF-to-VF reset on PF %d VF %d due to MDDevent\n",
drivers/net/ethernet/intel/ice/ice_main.c +5
-0+ pf->hw.pf_id, vf->vf_id); +ice_reset_vf (vf,ICE_VF_RESET_NOTIFY |ICE_VF_RESET_LOCK ); } +/** * ice_handle_mdd_event - handle malicious driver detect event * @pf: pointer to the PF structure @@ -1838,6 +1871,8 @@ static void ice_handle_mdd_event(structice_pf *pf) */ mutex_lock (&pf->vfs.table_lock);ice_for_each_vf (pf, bkt, vf) { +bool reset_vf_tx = false, reset_vf_rx = false; + reg =rd32 (hw,VP_MDET_TX_PQM (vf->vf_id));if (reg &VP_MDET_TX_PQM_VALID_M ) {
wr32(hw, VP_MDET_TX_PQM(vf->vf_id), 0xFFFF); @@ -
1846,6 +1881,8 @@ static voidice_handle_mdd_event(struct ice_pf *pf)drivers/net/ethernet/intel/ice/ice_main.c +0
-0if (netif_msg_tx_err (pf)) dev_info(dev, "Malicious Driver Detectionevent
TX_PQMdetected on VF %d\n",drivers/net/ethernet/intel/ice/ice_main.c +3
-0vf->vf_id); + + reset_vf_tx = true; } reg = rd32(hw, VP_MDET_TX_TCLAN(vf->vf_id)); @@ -1856,6 +1893,8 @@ static void ice_handle_mdd_event(struct ice_pf *pf) if (netif_msg_tx_err(pf)) dev_info(dev, "Malicious Driver Detectionevent
TX_TCLANdetected on VF %d\n",drivers/net/ethernet/intel/ice/ice_main.c +3
-0vf->vf_id); + + reset_vf_tx = true; } reg = rd32(hw, VP_MDET_TX_TDPU(vf->vf_id)); @@ -1866,6 +1905,8 @@ static void ice_handle_mdd_event(struct ice_pf *pf) if (netif_msg_tx_err(pf)) dev_info(dev, "Malicious Driver Detectionevent
TX_TDPUdetected on VF %d\n",drivers/net/ethernet/intel/ice/ice_main.c +3
-0vf->vf_id); + + reset_vf_tx = true; } reg = rd32(hw, VP_MDET_RX(vf->vf_id)); @@ -1877,18 +1918,12 @@ static void ice_handle_mdd_event(struct ice_pf *pf) dev_info(dev, "Malicious Driver Detectionevent RX detected on VF %d\n",
drivers/net/ethernet/intel/ice/ice_main.c +0
-1vf->vf_id); -/* Since the queue is disabled on VF Rx MDD events, the
drivers/net/ethernet/intel/ice/ice_main.c +0
-1-* PF can be configured to reset the VF through ethtool
drivers/net/ethernet/intel/ice/ice_main.c +0
-3-* private flag mdd-auto-reset-vf. -*/ - if (test_bit(ICE_FLAG_MDD_AUTO_RESET_VF, pf-Quoted 1 line
flags)) {
drivers/net/ethernet/intel/ice/ice_main.c +0
-2-/* VF MDD event counters will be cleared by -* reset, so print the event prior to reset.
drivers/net/ethernet/intel/ice/ice_main.c +5
-4-*/ -ice_print_vf_rx_mdd_event (vf); -ice_reset_vf (vf,ICE_VF_RESET_LOCK ); - } + reset_vf_rx = true; } + +if (reset_vf_tx || reset_vf_rx) +ice_mdd_maybe_reset_vf (pf, vf, reset_vf_tx, + reset_vf_rx); }mutex_unlock (&pf->vfs.table_lock);drivers/net/ethernet/intel/ice/ice_sriov.c +18
-0@@ -1861,6 +1861,24 @@ void ice_print_vf_rx_mdd_event(struct ice_vf *vf) ? "on" : "off"); } +/** +* ice_print_vf_tx_mdd_event - print VF Tx malicious driver detect +event +* @vf: pointer to the VF structure +*/ +void ice_print_vf_tx_mdd_event (struct ice_vf *vf) { +struct ice_pf *pf = vf->pf; +struct device *dev; + + dev =ice_pf_to_dev (pf); + + dev_info(dev, "%d Tx Malicious Driver Detection events detected on PF %d VF %d MAC %pM. mdd-auto-reset-vfs=%s\n", + vf->mdd_tx_events.count, pf->hw.pf_id, vf->vf_id, + vf->dev_lan_addr, +test_bit (ICE_FLAG_MDD_AUTO_RESET_VF , pf->flags) + ?"on" :"off" ); +} +/** *
ice_print_vfs_mdd_events- print VFs malicious driver detect
event
* @pf: pointer to the PF structuredrivers/net/ethernet/intel/ice/ice_sriov.c +1
-6@@ -1869,8 +1887,6 @@ void ice_print_vf_rx_mdd_event(struct ice_vf*vf) */ void ice_print_vfs_mdd_events (struct ice_pf *pf) { -struct device *dev =ice_pf_to_dev (pf); -struct ice_hw *hw = &pf->hw;struct ice_vf *vf;unsigned int bkt;@@ -1897,10 +1913,7 @@ void ice_print_vfs_mdd_events(struct ice_pf *pf)if (vf->mdd_tx_events.count != vf- > mdd_tx_events.last_printed) { vf->mdd_tx_events.last_printed = vf->mdd_tx_events.count; - - dev_info(dev, "%d Tx Malicious Driver Detection events detected on PF %d VF %d MAC %pM.\n", - vf->mdd_tx_events.count, hw->pf_id, vf- > vf_id, - vf->dev_lan_addr); +ice_print_vf_tx_mdd_event (vf ); } }mutex_unlock (&pf->vfs.table_lock);drivers/net/ethernet/intel/ice/ice_sriov.h +0
-0@@ -58,6 +58,7 @@ void ice_vf_lan_overflow_event(struct ice_pf *pf, struct
ice_rq_event_info*event); voidice_print_vfs_mdd_events(struct ice_pf *pf); voidice_print_vf_rx_mdd_event(struct ice_vf *vf); +voidice_print_vf_tx_mdd_event(struct ice_vf *vf);
bool
ice_vc_validate_pattern(structice_vf*vf, structvirtchnl_proto_hdrs*proto);
u32ice_sriov_get_vf_total_msix(struct pci_dev *pdev); @@ -69,6
+70,7 @@ static inline voidice_vf_lan_overflow_event(struct ice_pf *pf, struct ice_rq_event_info *event){ } static inline voidice_print_vfs_mdd_events(struct ice_pf *pf){ } static inline voidice_print_vf_rx_mdd_event(struct ice_vf *vf){ } +static inline voidice_print_vf_tx_mdd_event(struct ice_vf *vf){ }
static inline void ice_restore_all_vfs_msi_state(structice_pf
*pf) { }static inline int
--
2.41.0
Quoted 45 lines
-----Original Message-----
From: Marcin Szycik <[email protected]>
Sent: Wednesday, April 3, 2024 11:21 AM
To: Loktionov, Aleksandr <[email protected]>; intel- [email protected]
Cc: Drewek, Wojciech <[email protected]>; Wang, Liang-min <[email protected]>; [email protected]; Chmielewski, Pawel <[email protected]>; Nguyen, Anthony L <[email protected]>; [email protected]; Kitszel, Przemyslaw <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v4] ice: Reset VF on Tx MDD eventQuoted 4 lines · Aleksandr
Quoted 4 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> OnBehalf
Quoted 4 lines
Quoted 4 lines
Of Marcin Szycik
Sent: Tuesday, April 2, 2024 6:52 PM
To: [email protected]
Cc: Drewek, Wojciech <[email protected]>; Wang, Liang-min
Quoted 4 lines
Quoted 4 lines
<[email protected]>; [email protected]; Chmielewski, Pawel <[email protected]>; Marcin Szycik <[email protected]>; Nguyen, Anthony L <[email protected]>; [email protected]; Kitszel,
Przemyslaw
Quoted 2 lines
Quoted 2 lines
<[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next v4] ice: Reset VF onTx
Quoted 6 lines
Quoted 2 lines
MDD event
Please state in the title explicitly the purpose of the patch:
Do you fix a bug? say fix
Do you add functionality? say add
Do you refactor? say refactorIMO it's neither of those.
Quoted 7 lines
It's not a bugfix because the driver itself doesn't do anything wrong; the patch provides the user with a kind of optional workaround for an userspace app that's behaving incorrectly.
It's not really new functionality, since the mdd-auto-reset-vf flag was already implemented and auto reset was already happening for Rx events. I'm just extending this to Tx as well.
For me it looks like adding new feature, but I'm not sure yet.
Quoted 2 lines
And it's not strictly a refactor because I'm changing behaviour.
Please describe explicitly what behavior do you change, and the motivation, especially if it's not a bugfix.
Quoted 22 lines
Please also note that I've picked up a patch not originally made by me [2], and kept the original title and most of the description. I'm open to suggestions to title though.
Quoted 2 lines
Quoted 2 lines
In cases when VF sends malformed packets that are classified as malicious, sometimes it causes Tx queue to freeze. This frozen
queue
Quoted 1 line
Quoted 1 line
can be stuck for several minutes being unusable. This behavior
can be
Quoted 3 lines
Quoted 3 lines
reproduced with a faulty userspace app running on VF.
When any Malicious Driver Detection event occurs and the mdd-
auto-
Quoted 1 line
Quoted 1 line
reset-vf private flag is set, perform a graceful VF reset to
quickly
Quoted 1 line
Quoted 1 line
bring VF back to operational state. Add a log message to notify
about
Quoted 1 line
Quoted 1 line
the cause of the reset. Add a helper for this to be reused for
both
Quoted 3 lines
Quoted 1 line
TX and RX events.
Please describe your changes explicitly:
Do you just add a helper function without adding a new
Quoted 8 lines
functionality?
Quoted 3 lines
Do you add functionality?
Do you fix?
Please explain what are the changes in driver behavior and thechanges in the driver sources you make.
Quoted 1 line
Thank you
I'll try to make the description more explicit.
Thank you
Quoted 246 lines
Thanks,
MarcinQuoted 9 lines
Quoted 9 lines
Reviewed-by Wojciech Drewek <[email protected]>Reviewed-by Przemek Kitszel <[email protected]>Co-developed-by Liang-Min Wang <[email protected]>Signed-off-by Liang-Min Wang <[email protected]>Signed-off-by Marcin Szycik <[email protected]>---
v4: Only perform auto-reset once per VF
v3 [1]: Only auto reset VF if the mdd-auto-reset-vf flag is set v2 [2]: Revert an unneeded formatting change, fix commitmessage, fix
Quoted 4 lines
Quoted 4 lines
a log
message with a correct event namelan/20240326164455.735739-
Quoted 5 lines
Quoted 5 lines
[email protected]
[2] https://lore.kernel.org/netdev/20231102155149.2574209-1-
[email protected]--- drivers/net/ethernet/intel/ice/ice_main.c | 57+++++++++++++++++-
Quoted 14 lines
Quoted 14 lines
----
drivers/net/ethernet/intel/ice/ice_sriov.c| 25 +++++++---drivers/net/ethernet/intel/ice/ice_sriov.h| 2 +3 files changed, 67 insertions(+), 17 deletions(-)drivers/net/ethernet/intel/ice/ice_main.c +0
-0@@ -1745,6 +1745,39 @@ static void ice_service_timer(struct timer_list *t)ice_service_task_schedule (pf ); }Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_main.c static void ice_service_timer(struct timer_list *t)
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_main.c +8
-0+/** +* ice_mdd_maybe_reset_vf - reset VF after MDD event +* @pf: pointer to the PF structure +* @vf: pointer to the VF structure +* @reset_vf_tx: whether Tx MDD has occurred +* @reset_vf_rx: whether Rx MDD has occurred +* +* Since the queue can get stuck on VF MDD events, the PF can be
Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_main.c static void ice_service_timer(struct · line 1758
Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_main.c +2
-0+configured to + * automatically reset the VF by enabling the private ethtoolflag
Quoted 21 lines
Quoted 21 lines
drivers/net/ethernet/intel/ice/ice_main.c +10
-0+* mdd-auto-reset-vf. +*/ +static void ice_mdd_maybe_reset_vf (struct ice_pf *pf,struct ice_vf *vf, +bool reset_vf_tx,bool reset_vf_rx) { +struct device *dev =ice_pf_to_dev (pf); + +if (!test_bit (ICE_FLAG_MDD_AUTO_RESET_VF , pf->flags)) +return ; + +/* VF MDD event counters will be cleared by reset, so print the event
drivers/net/ethernet/intel/ice/ice_main.c +9
-0+* prior to reset. +*/ +if (reset_vf_tx) +ice_print_vf_tx_mdd_event (vf); + +if (reset_vf_rx) +ice_print_vf_rx_mdd_event (vf); + + dev_info(dev, "PF-to-VF reset on PF %d VF %d due to MDDQuoted 8 lines
drivers/net/ethernet/intel/ice/ice_main.c static void ice_handle_mdd_event(struct
Quoted 8 lines
event\n",
drivers/net/ethernet/intel/ice/ice_main.c +3
-0+ pf->hw.pf_id, vf->vf_id); +ice_reset_vf (vf,ICE_VF_RESET_NOTIFY |ICE_VF_RESET_LOCK ); } +/** * ice_handle_mdd_event - handle malicious driver detect event * @pf: pointer to the PF structure @@ -1838,6 +1871,8 @@ static void ice_handle_mdd_event(struct
ice_pfQuoted 5 lines
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_main.c +1
-0*pf) */ mutex_lock (&pf->vfs.table_lock);ice_for_each_vf (pf, bkt, vf) { +bool reset_vf_tx = false, reset_vf_rx = false;Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_main.c
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_main.c +1
-0+ reg =rd32 (hw,VP_MDET_TX_PQM (vf->vf_id));if (reg &VP_MDET_TX_PQM_VALID_M ) {
wr32(hw, VP_MDET_TX_PQM(vf->vf_id), 0xFFFF); @@ -
1846,6 +1881,8 @@ static voidice_handle_mdd_event(struct ice_pf *pf)drivers/net/ethernet/intel/ice/ice_main.c +0
-0if (netif_msg_tx_err (pf)) dev_info(dev, "Malicious Driver Detectionevent
TX_PQMdetectedQuoted 10 lines
drivers/net/ethernet/intel/ice/ice_main.c static void ice_handle_mdd_event(struct ice_pf *pf)
Quoted 10 lines
on VF %d\n",
drivers/net/ethernet/intel/ice/ice_main.c +3
-0vf->vf_id); + + reset_vf_tx = true; } reg = rd32(hw, VP_MDET_TX_TCLAN(vf->vf_id)); @@ -1856,6 +1893,8 @@ static void ice_handle_mdd_event(struct ice_pf *pf) if (netif_msg_tx_err(pf)) dev_info(dev, "Malicious Driver Detectionevent
TX_TCLANQuoted 10 lines
drivers/net/ethernet/intel/ice/ice_main.c static void ice_handle_mdd_event(struct ice_pf *pf)
Quoted 10 lines
detected on VF %d\n",
drivers/net/ethernet/intel/ice/ice_main.c +3
-0vf->vf_id); + + reset_vf_tx = true; } reg = rd32(hw, VP_MDET_TX_TDPU(vf->vf_id)); @@ -1866,6 +1905,8 @@ static void ice_handle_mdd_event(struct ice_pf *pf) if (netif_msg_tx_err(pf)) dev_info(dev, "Malicious Driver Detectionevent
TX_TDPUdetectedQuoted 9 lines
drivers/net/ethernet/intel/ice/ice_main.c static void ice_handle_mdd_event(struct ice_pf *pf)
Quoted 9 lines
on VF %d\n",
drivers/net/ethernet/intel/ice/ice_main.c +3
-0vf->vf_id); + + reset_vf_tx = true; } reg = rd32(hw, VP_MDET_RX(vf->vf_id)); @@ -1877,18 +1918,12 @@ static void ice_handle_mdd_event(struct ice_pf *pf) dev_info(dev, "Malicious Driver Detectionevent RX detected on
Quoted 27 lines
Quoted 27 lines
VF %d\n",
drivers/net/ethernet/intel/ice/ice_main.c +0
-1vf->vf_id); -/* Since the queue is disabled on VF Rx MDD events, the
drivers/net/ethernet/intel/ice/ice_main.c +0
-1-* PF can be configured to reset the VF through ethtool
drivers/net/ethernet/intel/ice/ice_main.c +0
-3-* private flag mdd-auto-reset-vf. -*/ - if (test_bit(ICE_FLAG_MDD_AUTO_RESET_VF, pf-Quoted 1 line
flags)) {
drivers/net/ethernet/intel/ice/ice_main.c +0
-2-/* VF MDD event counters will be cleared by -* reset, so print the event prior to reset.
drivers/net/ethernet/intel/ice/ice_main.c +5
-4-*/ -ice_print_vf_rx_mdd_event (vf); -ice_reset_vf (vf,ICE_VF_RESET_LOCK ); - } + reset_vf_rx = true; } + +if (reset_vf_tx || reset_vf_rx) +ice_mdd_maybe_reset_vf (pf, vf, reset_vf_tx, + reset_vf_rx); }mutex_unlock (&pf->vfs.table_lock);Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_sriov.c void ice_print_vf_rx_mdd_event(struct
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_sriov.c +0
-0@@ -1861,6 +1861,24 @@ void ice_print_vf_rx_mdd_event(struct
ice_vfQuoted 6 lines
drivers/net/ethernet/intel/ice/ice_sriov.c void ice_print_vf_rx_mdd_event(struct ice_vf *vf)
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_sriov.c +2
-0*vf) ? "on" : "off"); } +/** +* ice_print_vf_tx_mdd_event - print VF Tx malicious driver detect
Quoted 14 lines
Quoted 14 lines
drivers/net/ethernet/intel/ice/ice_sriov.c +13
-0+event +* @vf: pointer to the VF structure +*/ +void ice_print_vf_tx_mdd_event (struct ice_vf *vf) { +struct ice_pf *pf = vf->pf; +struct device *dev; + + dev =ice_pf_to_dev (pf); + + dev_info(dev, "%d Tx Malicious Driver Detection events detected on PF %d VF %d MAC %pM. mdd-auto-reset-vfs=%s\n", + vf->mdd_tx_events.count, pf->hw.pf_id, vf->vf_id, + vf->dev_lan_addr, + test_bit(ICE_FLAG_MDD_AUTO_RESET_VF, pf->flags)Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_sriov.c void ice_print_vf_rx_mdd_event(struct
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_sriov.c +3
-0+ ? "on" : "off"); +} +/** *
ice_print_vfs_mdd_events- print VFs malicious driver detect
event
* @pf: pointer to the PF structuredrivers/net/ethernet/intel/ice/ice_sriov.c +0
-0@@ -1869,8 +1887,6 @@ void ice_print_vf_rx_mdd_event(struct
ice_vfQuoted 9 lines
drivers/net/ethernet/intel/ice/ice_sriov.c void ice_print_vfs_mdd_events(struct
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_sriov.c +0
-2*vf) */ void ice_print_vfs_mdd_events (struct ice_pf *pf) { -struct device *dev =ice_pf_to_dev (pf); -struct ice_hw *hw = &pf->hw;struct ice_vf *vf;unsigned int bkt;@@ -1897,10 +1913,7 @@ void ice_print_vfs_mdd_events(struct
ice_pfQuoted 23 lines
Quoted 23 lines
drivers/net/ethernet/intel/ice/ice_sriov.c +1
-4*pf)if (vf->mdd_tx_events.count != vf- > mdd_tx_events.last_printed) { vf->mdd_tx_events.last_printed = vf->mdd_tx_events.count; - - dev_info(dev, "%d Tx Malicious Driver Detection events detected on PF %d VF %d MAC %pM.\n", - vf->mdd_tx_events.count, hw->pf_id, vf- > vf_id, - vf->dev_lan_addr); +ice_print_vf_tx_mdd_event (vf ); } }mutex_unlock (&pf->vfs.table_lock);drivers/net/ethernet/intel/ice/ice_sriov.h +0
-0@@ -58,6 +58,7 @@ void ice_vf_lan_overflow_event(struct ice_pf *pf, struct
ice_rq_event_info*event); void ice_print_vfs_mdd_events(structQuoted 8 lines
Quoted 8 lines
ice_pf*pf); voidice_print_vf_rx_mdd_event(struct ice_vf *vf); +voidice_print_vf_tx_mdd_event(struct ice_vf *vf);
bool
ice_vc_validate_pattern(structice_vf*vf, structvirtchnl_proto_hdrs*proto);
u32ice_sriov_get_vf_total_msix(struct pci_dev *pdev); @@ -69,6
+70,7 @@ static inline voidice_vf_lan_overflow_event(struct ice_pf *pf, struct ice_rq_event_info *event){ } static inlinevoid
Quoted 1 line
Quoted 1 line
ice_print_vfs_mdd_events(struct ice_pf *pf){ } static inlinevoid
Quoted 2 lines
Quoted 2 lines
ice_print_vf_rx_mdd_event(struct ice_vf *vf){ } +static inline voidice_print_vf_tx_mdd_event(struct ice_vf *vf){
Quoted 8 lines
Quoted 7 lines
}
static inline void ice_restore_all_vfs_msi_state(structice_pf
*pf) { }static inline int
--
2.41.0