ixgbe: add the ability for the PF to disable VF link state
Subsystems (2)
PATCH v2 1/3 ixgbe: add the ability for the PF to disable VF link state
Add support for ndo_set_vf_link_state the Network Device Option that allows the PF driver to control the virtual link state of the VF devices. Without this change a VF cannot be disabled/enabled by the administrator. In the implementation the auto state takes over PF link state to VF link setting, the enable state is not supported, the disable state shut off the VF link regardless of the PF setting.
--- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 2 + drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 11 +- drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.h | 2 + .../net/ethernet/intel/ixgbe/ixgbe_sriov.c | 207 ++++++++++++++---- .../net/ethernet/intel/ixgbe/ixgbe_sriov.h | 4 +- 5 files changed, 182 insertions(+), 44 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe.h +2 -0
@@ -177,6 +177,8 @@ struct vf_data_storage {u16 pf_vlan;/* When set, guest VLAN config not allowed. */ u16 pf_qos;u16 tx_rate; +int link_enable; +int link_state;u8 spoofchk_enabled;bool rss_query_enabled;u8 trusted;
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +6 -5
@@ -5687,6 +5687,9 @@ static void ixgbe_up_complete(struct ixgbe_adapter *adapter) ctrl_ext =IXGBE_READ_REG (hw,IXGBE_CTRL_EXT ); ctrl_ext |=IXGBE_CTRL_EXT_PFRSTD ;IXGBE_WRITE_REG (hw,IXGBE_CTRL_EXT , ctrl_ext); + +/* update setting rx tx for all active vfs */ +ixgbe_set_all_vfs (adapter); }void ixgbe_reinit_locked (struct ixgbe_adapter *adapter)
@@ -6144,11 +6147,8 @@ void ixgbe_down(struct ixgbe_adapter *adapter)for (i =0 ; i < adapter->num_vfs; i++) adapter->vfinfo[i].clear_to_send = false; -/* ping all the active vfs to let them know we are going down */ -ixgbe_ping_all_vfs (adapter); - -/* Disable all VFTE/VFRE TX/RX */ -ixgbe_disable_tx_rx (adapter); +/* update setting rx tx for all active vfs */ +ixgbe_set_all_vfs (adapter); }/* disable transmits in the hardware now that interrupts are off */
@@ -10284,6 +10284,7 @@ static const struct net_device_ops ixgbe_netdev_ops = { .ndo_set_vf_vlan = ixgbe_ndo_set_vf_vlan, .ndo_set_vf_rate = ixgbe_ndo_set_vf_bw, .ndo_set_vf_spoofchk = ixgbe_ndo_set_vf_spoofchk, + .ndo_set_vf_link_state = ixgbe_ndo_set_vf_link_state, .ndo_set_vf_rss_query_en = ixgbe_ndo_set_vf_rss_query_en, .ndo_set_vf_trust = ixgbe_ndo_set_vf_trust, .ndo_get_vf_config = ixgbe_ndo_get_vf_config,
drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.h +2 -0
@@ -85,6 +85,8 @@ enum ixgbe_pfvf_api_rev {#define IXGBE_VF_IPSEC_ADD 0x0d#define IXGBE_VF_IPSEC_DEL 0x0e +#define IXGBE_VF_GET_LINK_STATE 0x10/* get vf link state */ +/* length of permanent address message returned from PF */ #define IXGBE_VF_PERMADDR_MSG_LEN 4/* word in permanent address message with the current multicast type */
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +169 -38
261 lines not on this page · raw message
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h +3 -1
@@ -17,8 +17,8 @@ void ixgbe_restore_vf_multicasts(struct ixgbe_adapter *adapter);#endif void ixgbe_msg_task (struct ixgbe_adapter *adapter);int ixgbe_vf_configuration (struct pci_dev *pdev,unsigned int event_mask); -void ixgbe_disable_tx_rx (struct ixgbe_adapter *adapter);void ixgbe_ping_all_vfs (struct ixgbe_adapter *adapter); +void ixgbe_set_all_vfs (struct ixgbe_adapter *adapter);int ixgbe_ndo_set_vf_mac (struct net_device *netdev,int queue,u8 *mac);int ixgbe_ndo_set_vf_vlan (struct net_device *netdev,int queue,u16 vlan,u8 qos,__be16 vlan_proto);
@@ -31,7 +31,9 @@ int ixgbe_ndo_set_vf_rss_query_en(struct net_device *netdev, int vf,int ixgbe_ndo_set_vf_trust (struct net_device *netdev,int vf,bool setting);int ixgbe_ndo_get_vf_config (struct net_device *netdev,int vf,struct ifla_vf_info *ivi); +int ixgbe_ndo_set_vf_link_state (struct net_device *netdev,int vf,int state);void ixgbe_check_vf_rate_limit (struct ixgbe_adapter *adapter); +void ixgbe_set_vf_link_state (struct ixgbe_adapter *adapter,int vf,int state);int ixgbe_disable_sriov (struct ixgbe_adapter *adapter);#ifdef CONFIG_PCI_IOV void ixgbe_enable_sriov (struct ixgbe_adapter *adapter,unsigned int max_vfs);
Signature · 1 line
2.17.1
PATCH v2 2/3 ixgbe: add improvement for MDD response functionality
The 82599 PF driver disable VF driver after a special MDD event occurs. Adds the option for administrators to control whether VFs are automatically disabled after several MDD events.
The automatically disabling is now the default mode for 82599 PF driver, as it is more reliable.
This addresses CVE-2021-33061.
--- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 4 +++ .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 21 ++++++++++++++ drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 28 ++++++++++++++++++- 3 files changed, 52 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbe/ixgbe.h +4 -0
@@ -184,6 +184,7 @@ struct vf_data_storage {u8 trusted;int xcast_mode;unsigned int vf_api; +u8 primary_abort_count; };enum ixgbevf_xcast_modes {
@@ -558,6 +559,8 @@ struct ixgbe_mac_addr {#define IXGBE_TRY_LINK_TIMEOUT (4 * HZ)#define IXGBE_SFP_POLL_JIFFIES (2 * HZ)/* SFP poll every 2 seconds */ +#define IXGBE_PRIMARY_ABORT_LIMIT 5 +/* board specific private data structure */ struct ixgbe_adapter {unsigned long active_vlans[BITS_TO_LONGS (VLAN_N_VID )];
@@ -616,6 +619,7 @@ struct ixgbe_adapter {#define IXGBE_FLAG2_RX_LEGACY BIT(16)#define IXGBE_FLAG2_IPSEC_ENABLED BIT(17)#define IXGBE_FLAG2_VF_IPSEC_ENABLED BIT(18) +#define IXGBE_FLAG2_AUTO_DISABLE_VF BIT(19)/* Tx fast path data */ int num_tx_queues;
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +21 -0
@@ -138,6 +138,8 @@ static const char ixgbe_priv_flags_strings[][ETH_GSTRING_LEN] = { "legacy-rx",#define IXGBE_PRIV_FLAGS_VF_IPSEC_EN BIT(1) "vf-ipsec", +#define IXGBE_PRIV_FLAGS_AUTO_DISABLE_VF BIT(2) + "mdd-disable-vf", };#define IXGBE_PRIV_FLAGS_STR_LEN ARRAY_SIZE(ixgbe_priv_flags_strings)
@@ -3510,6 +3512,9 @@ static u32 ixgbe_get_priv_flags(struct net_device *netdev)if (adapter->flags2 &IXGBE_FLAG2_VF_IPSEC_ENABLED ) priv_flags |=IXGBE_PRIV_FLAGS_VF_IPSEC_EN ; +if (adapter->flags2 &IXGBE_FLAG2_AUTO_DISABLE_VF ) + priv_flags |=IXGBE_PRIV_FLAGS_AUTO_DISABLE_VF ; +return priv_flags; }
@@ -3517,6 +3522,7 @@ static int ixgbe_set_priv_flags(struct net_device *netdev, u32 priv_flags) {struct ixgbe_adapter *adapter =netdev_priv (netdev);unsigned int flags2 = adapter->flags2; +unsigned int i; flags2 &= ~IXGBE_FLAG2_RX_LEGACY ;if (priv_flags &IXGBE_PRIV_FLAGS_LEGACY_RX )
@@ -3526,6 +3532,21 @@ static int ixgbe_set_priv_flags(struct net_device *netdev, u32 priv_flags)if (priv_flags &IXGBE_PRIV_FLAGS_VF_IPSEC_EN ) flags2 |=IXGBE_FLAG2_VF_IPSEC_ENABLED ; + flags2 &= ~IXGBE_FLAG2_AUTO_DISABLE_VF ; +if (priv_flags &IXGBE_PRIV_FLAGS_AUTO_DISABLE_VF ) { +if (adapter->hw.mac.type == ixgbe_mac_82599EB) { +/* Reset primary abort counter */ +for (i =0 ; i < adapter->num_vfs; i++) + adapter->vfinfo[i].primary_abort_count =0 ; + + flags2 |=IXGBE_FLAG2_AUTO_DISABLE_VF ; + }else { +e_info (probe, +"Cannot set private flags: Operation not supported\n" ); +return -EOPNOTSUPP ; + } + } +if (flags2 != adapter->flags2) { adapter->flags2 = flags2;
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +27 -1
@@ -7613,6 +7613,27 @@ static void ixgbe_watchdog_flush_tx(struct ixgbe_adapter *adapter) }#ifdef CONFIG_PCI_IOV +static void ixgbe_bad_vf_abort (struct ixgbe_adapter *adapter,u32 vf) +{ +struct ixgbe_hw *hw = &adapter->hw; + +if (adapter->hw.mac.type == ixgbe_mac_82599EB && + adapter->flags2 &IXGBE_FLAG2_AUTO_DISABLE_VF ) { + adapter->vfinfo[vf].primary_abort_count++; +if (adapter->vfinfo[vf].primary_abort_count == +IXGBE_PRIMARY_ABORT_LIMIT ) { +ixgbe_set_vf_link_state (adapter, vf, +IFLA_VF_LINK_STATE_DISABLE ); + adapter->vfinfo[vf].primary_abort_count =0 ; + +e_info (drv, +"Malicious Driver Detection event detected on PF %d VF %d MAC: %pM mdd-disable-vf=on" , + hw->bus.func, vf, + adapter->vfinfo[vf].vf_mac_addresses); + } + } +} +static void ixgbe_check_for_bad_vf (struct ixgbe_adapter *adapter) {struct ixgbe_hw *hw = &adapter->hw;
@@ -7644,8 +7665,10 @@ static void ixgbe_check_for_bad_vf(struct ixgbe_adapter *adapter)continue ;pci_read_config_word (vfdev,PCI_STATUS , &status_reg);if (status_reg !=IXGBE_FAILED_READ_CFG_WORD && - status_reg &PCI_STATUS_REC_MASTER_ABORT ) + status_reg &PCI_STATUS_REC_MASTER_ABORT ) { +ixgbe_bad_vf_abort (adapter, vf);pcie_flr (vfdev); + } } }
@@ -10751,6 +10774,9 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)if (err) goto err_sw_init; +if (adapter->hw.mac.type == ixgbe_mac_82599EB) + adapter->flags2 |=IXGBE_FLAG2_AUTO_DISABLE_VF ; +switch (adapter->hw.mac.type) {case ixgbe_mac_X550:case ixgbe_mac_X550EM_x:
Signature · 1 line
2.17.1
Jankowski
PATCH v2 2/3 ixgbe: add improvement for MDD response functionality
drivers/net/ethernet/intel/ixgbe/ixgbe.h struct vf_data_storage {
Quoted 32 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Slawomir Mrozowicz
Sent: Tuesday, March 1, 2022 12:40 PM
To: intel-wired-lan at lists.osuosl.org
Cc: Mrozowicz, SlawomirX <[email protected]>
Subject: [Intel-wired-lan] [PATCH net v2 2/3] ixgbe: add improvement for MDD response functionalityThe 82599 PF driver disable VF driver after a special MDD event occurs. Adds the option for administrators to control whether VFs are automatically disabled after several MDD events.
The automatically disabling is now the default mode for 82599 PF driver, as it is more reliable.This addresses CVE-2021-33061.
Signed-off-by Slawomir Mrozowicz <[email protected]>--- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 4 +++ .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 21 ++++++++++++++ drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 28 ++++++++++++++++++- 3 files changed, 52 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/ixgbe/ixgbe.h +0
-0@@ -184,6 +184,7 @@ struct vf_data_storage {
PATCH v2 3/3 ixgbevf: add disable link state
In reply to Slawomir MrozowiczAdd possibility to disable link state if it is administratively disabled in PF.
It is part of the general functionality that allows the PF driver to control the state of the virtual link VF devices.
--- drivers/net/ethernet/intel/ixgbevf/ixgbevf.h | 2 + .../net/ethernet/intel/ixgbevf/ixgbevf_main.c | 11 ++++- drivers/net/ethernet/intel/ixgbevf/mbx.h | 2 + drivers/net/ethernet/intel/ixgbevf/vf.c | 42 +++++++++++++++++++ drivers/net/ethernet/intel/ixgbevf/vf.h | 1 + 5 files changed, 57 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbevf/ixgbevf.h +2 -0
@@ -387,6 +387,8 @@ struct ixgbevf_adapter {u32 *rss_key;u8 rss_indir_tbl[IXGBEVF_X550_VFRETA_SIZE ];u32 flags; +bool link_state; +#define IXGBEVF_FLAGS_LEGACY_RX BIT(1)#ifdef CONFIG_XFRM
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +10 -1
@@ -2298,7 +2298,9 @@ static void ixgbevf_negotiate_api(struct ixgbevf_adapter *adapter)static void ixgbevf_up_complete (struct ixgbevf_adapter *adapter) {struct net_device *netdev = adapter->netdev; +struct pci_dev *pdev = adapter->pdev;struct ixgbe_hw *hw = &adapter->hw; +bool state;ixgbevf_configure_msix (adapter);
@@ -2311,6 +2313,11 @@ static void ixgbevf_up_complete(struct ixgbevf_adapter *adapter)spin_unlock_bh (&adapter->mbx_lock); + state = adapter->link_state; + hw->mac.ops.get_link_state (hw, &adapter->link_state); +if (state && state != adapter->link_state) +dev_info (&pdev->dev,"VF is administratively disabled\n" ); +smp_mb__before_atomic ();clear_bit (__IXGBEVF_DOWN, &adapter->state);ixgbevf_napi_enable_all (adapter);
@@ -3081,6 +3088,8 @@ static int ixgbevf_sw_init(struct ixgbevf_adapter *adapter) adapter->tx_ring_count =IXGBEVF_DEFAULT_TXD ; adapter->rx_ring_count =IXGBEVF_DEFAULT_RXD ; + adapter->link_state = true; +set_bit (__IXGBEVF_DOWN, &adapter->state);return 0 ;
@@ -3313,7 +3322,7 @@ static void ixgbevf_watchdog_subtask(struct ixgbevf_adapter *adapter)ixgbevf_watchdog_update_link (adapter); -if (adapter->link_up) +if (adapter->link_up && adapter->link_state)ixgbevf_watchdog_link_is_up (adapter);else ixgbevf_watchdog_link_is_down (adapter);
drivers/net/ethernet/intel/ixgbevf/mbx.h +2 -0
@@ -100,6 +100,8 @@ enum ixgbe_pfvf_api_rev {#define IXGBE_VF_IPSEC_ADD 0x0d#define IXGBE_VF_IPSEC_DEL 0x0e +#define IXGBE_VF_GET_LINK_STATE 0x10/* get vf link state */ +/* length of permanent address message returned from PF */ #define IXGBE_VF_PERMADDR_MSG_LEN 4/* word in permanent address message with the current multicast type */
drivers/net/ethernet/intel/ixgbevf/vf.c +42 -0
60 lines not on this page · raw message
drivers/net/ethernet/intel/ixgbevf/vf.h +1 -0
@@ -39,6 +39,7 @@ struct ixgbe_mac_operations {s32 (*init_rx_addrs)(struct ixgbe_hw *);s32 (*update_mc_addr_list)(struct ixgbe_hw *,struct net_device *);s32 (*update_xcast_mode)(struct ixgbe_hw *,int ); +s32 (*get_link_state)(struct ixgbe_hw *hw,bool *link_state);s32 (*enable_mc)(struct ixgbe_hw *);s32 (*disable_mc)(struct ixgbe_hw *);s32 (*clear_vfta)(struct ixgbe_hw *);
Signature · 1 line
2.17.1
Jankowski
PATCH v2 3/3 ixgbevf: add disable link state
drivers/net/ethernet/intel/ixgbevf/ixgbevf.h struct ixgbevf_adapter {
Quoted 30 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Slawomir Mrozowicz
Sent: Tuesday, March 1, 2022 12:40 PM
To: intel-wired-lan at lists.osuosl.org
Cc: Mrozowicz, SlawomirX <[email protected]>
Subject: [Intel-wired-lan] [PATCH net v2 3/3] ixgbevf: add disable link stateAdd possibility to disable link state if it is administratively disabled in PF.
It is part of the general functionality that allows the PF driver to control the state of the virtual link VF devices.
Signed-off-by Slawomir Mrozowicz <[email protected]>--- drivers/net/ethernet/intel/ixgbevf/ixgbevf.h | 2 + .../net/ethernet/intel/ixgbevf/ixgbevf_main.c | 11 ++++- drivers/net/ethernet/intel/ixgbevf/mbx.h | 2 + drivers/net/ethernet/intel/ixgbevf/vf.c | 42 +++++++++++++++++++ drivers/net/ethernet/intel/ixgbevf/vf.h | 1 + 5 files changed, 57 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/ixgbevf/ixgbevf.h +0
-0@@ -387,6 +387,8 @@ struct ixgbevf_adapter {
Jankowski
PATCH v2 1/3 ixgbe: add the ability for the PF to disable VF link state
In reply to Slawomir MrozowiczQuoted 47 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Slawomir Mrozowicz
Sent: Tuesday, March 1, 2022 12:40 PM
To: intel-wired-lan at lists.osuosl.org
Cc: Mrozowicz, SlawomirX <[email protected]>
Subject: [Intel-wired-lan] [PATCH net v2 1/3] ixgbe: add the ability for the PF to disable VF link stateAdd support for
ndo_set_vf_link_statethe Network Device Option that allows the PF driver to control the virtual link state of the VF devices. Without this change a VF cannot be disabled/enabled by the administrator. In the implementation the auto state takes over PF link state to VF link setting, the enable state is not supported, the disable state shut off the VF link regardless of the PF setting.Signed-off-by Slawomir Mrozowicz <[email protected]>--- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 2 + drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 11 +- drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.h | 2 + .../net/ethernet/intel/ixgbe/ixgbe_sriov.c | 207 ++++++++++++++---- .../net/ethernet/intel/ixgbe/ixgbe_sriov.h | 4 +- 5 files changed, 182 insertions(+), 44 deletions(-)drivers/net/ethernet/intel/ixgbe/ixgbe.h +2
-0@@ -177,6 +177,8 @@ struct vf_data_storage {u16 pf_vlan;/* When set, guest VLAN config not allowed. */ u16 pf_qos;u16 tx_rate; +int link_enable; +int link_state;u8 spoofchk_enabled;bool rss_query_enabled;u8 trusted;drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0
-0
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static void ixgbe_up_complete(struct · line 5687
Quoted 1 line
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0
-0@@ -5687,6 +5687,9 @@ static void ixgbe_up_complete(struct ixgbe_adapter *adapter)