Enable use of PF for switch or bridge when using SR-IOV
Subsystems (2)
cover Enable use of PF for switch or bridge when using SR-IOV
This patch series addresses a number of issues in the configuration of SR-IOV in conjunction with something such as a bridge or OVS. As a result the the functionality should be brought inline with what is now available in ixgbe after recent changes.
It should now be possible to place bridge with tap interfaces on top of the PF and as long as we add the MAC addresses for those interfaces using the command "bridge fdb add ADDR dev DEV" we should be able to then pass traffic between the VFs and those interfaces.
In addition I made one change to the configuration of the MTU. Since we are using page based receive I decided to configure the driver to support always receiving jumbo frames, but only transmitting up to MTU. This way the behavior should be more consistent between SR-IOV and non-SR-IOV modes.
---
Alexander Duyck (11):
igb: clean up code for setting MAC address
igb: Refactor VFTA configuration
igb: Allow asymmetric configuration of MTU versus Rx frame size
igb: Do not factor VLANs into RLPML calculation
igb: Always enable VLAN 0 even if 8021q is not loaded
igb: Merge VLVF configuration into igb_vfta_set
igb: Clean-up configuration of VF port VLANs
igb: Add support for VLAN promiscuous with SR-IOV and NTUPLE
igb: Drop unnecessary checks in transmit path
igb: Enable use of "bridge fdb add" to set unicast table entries
igb: Add workaround for VLAN tag stripping on 82576
drivers/net/ethernet/intel/igb/e1000_82575.c | 39 + drivers/net/ethernet/intel/igb/e1000_defines.h | 3 drivers/net/ethernet/intel/igb/e1000_hw.h | 2 drivers/net/ethernet/intel/igb/e1000_mac.c | 213 ++++--- drivers/net/ethernet/intel/igb/e1000_mac.h | 5 drivers/net/ethernet/intel/igb/igb.h | 2 drivers/net/ethernet/intel/igb/igb_main.c | 764 +++++++++++++----------- 7 files changed, 610 insertions(+), 418 deletions(-)
--
PATCH 1/11 igb: clean up code for setting MAC address
Drop a bunch of hand written byte swapping code in favor of just doing the byte swapping ourselves. The registers are little endian registers storing a big endian value so if we read the MAC address array as little endian then we will get the CPU registers into the proper layout.
--- drivers/net/ethernet/intel/igb/igb_main.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/igb/igb_main.c +4 -5
@@ -7834,15 +7834,14 @@ static void igb_io_resume(struct pci_dev *pdev)static void igb_rar_set_qsel (struct igb_adapter *adapter,u8 *addr,u32 index,u8 qsel) { -u32 rar_low, rar_high;struct e1000_hw *hw = &adapter->hw; +u32 rar_low, rar_high;/* HW expects these in little endian so we reverse the byte order -* from network order (big endian) to little endian +* from network order (big endian) to CPU endian */ - rar_low = ((u32 ) addr[0 ] | ((u32 ) addr[1 ] <<8 ) | - ((u32 ) addr[2 ] <<16 ) | ((u32 ) addr[3 ] <<24 )); - rar_high = ((u32 ) addr[4 ] | ((u32 ) addr[5 ] <<8 )); + rar_low =le32_to_cpup ((__be32 *)(addr)); + rar_high =le16_to_cpup ((__be16 *)(addr +4 ));/* Indicate to hardware the Address is Valid. */ rar_high |=E1000_RAH_AV ;
Brown
PATCH 1/11 igb: clean up code for setting MAC address
Quoted 10 lines
From: Intel-wired-lan [intel-wired-lan-bounces at lists.osuosl.org] on behalf of Alexander Duyck [aduyck at mirantis.com]
Sent: Wednesday, January 06, 2016 11:10 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH 01/11] igb: clean up code for setting MAC addressDrop a bunch of hand written byte swapping code in favor of just doing the byte swapping ourselves. The registers are little endian registers storing a big endian value so if we read the MAC address array as little endian then we will get the CPU registers into the proper layout.
Quoted 4 lines
Signed-off-by Alexander Duyck <[email protected]>--- drivers/net/ethernet/intel/igb/igb_main.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
PATCH 2/11 igb: Refactor VFTA configuration
In reply to Alexander DuyckThis patch starts the clean-up process on the VFTA configuration. Specifically in this patch I attempt to address and simplify several items while also updating the code to bring it more inline with what is already in ixgbe.
--- drivers/net/ethernet/intel/igb/e1000_82575.c | 37 ++++++++- drivers/net/ethernet/intel/igb/e1000_hw.h | 2 - drivers/net/ethernet/intel/igb/e1000_mac.c | 102 ++++++++------------------ drivers/net/ethernet/intel/igb/e1000_mac.h | 2 - 4 files changed, 67 insertions(+), 76 deletions(-)
drivers/net/ethernet/intel/igb/e1000_82575.c +33 -4
@@ -34,6 +34,7 @@#include "e1000_mac.h" #include "e1000_82575.h" #include "e1000_i210.h" +#include "igb.h" static s32 igb_get_invariants_82575 (struct e1000_hw *);static s32 igb_acquire_phy_82575 (struct e1000_hw *);
@@ -71,6 +72,32 @@ static s32 igb_update_nvm_checksum_i350(struct e1000_hw *hw);static const u16 e1000_82580_rxpbs_table[] = {36 ,72 ,144 ,1 ,2 ,4 ,8 ,16 ,35 ,70 ,140 }; +/* Due to a hw errata, if the host tries to configure the VFTA register +* while performing queries from the BMC or DMA, then the VFTA in some +* cases won't be written. +*/ + +/** +* igb_write_vfta_i350 - Write value to VLAN filter table +* @hw: pointer to the HW structure +* @offset: register offset in VLAN filter table +* @value: register value written to VLAN filter table +* +* Writes value at the given offset in the register array which stores +* the VLAN filter table. +**/ +static void igb_write_vfta_i350 (struct e1000_hw *hw,u32 offset,u32 value) +{ +struct igb_adapter *adapter = hw->back; +int i; + +for (i =10 ; i--;) +array_wr32 (E1000_VFTA , offset, value); + +wrfl (); + adapter->shadow_vfta[offset] = value; +} +/** * igb_sgmii_uses_mdio_82575 - Determine if I2C pins are for external MDIO * @hw: pointer to the HW structure
@@ -429,6 +456,11 @@ static s32 igb_init_mac_params_82575(struct e1000_hw *hw) mac->ops.release_swfw_sync = igb_release_swfw_sync_82575; } +if ((hw->mac.type == e1000_i350) || (hw->mac.type == e1000_i354)) + mac->ops.write_vfta = igb_write_vfta_i350; +else + mac->ops.write_vfta = igb_write_vfta; +/* Set if part includes ASF firmware */ mac->asf_firmware_present = true;/* Set if manageability features are enabled. */
@@ -1517,10 +1549,7 @@ static s32 igb_init_hw_82575(struct e1000_hw *hw)/* Disabling VLAN filtering */ hw_dbg ("Initializing the IEEE VLAN\n" ); -if ((hw->mac.type == e1000_i350) || (hw->mac.type == e1000_i354)) -igb_clear_vfta_i350 (hw); -else -igb_clear_vfta (hw); +igb_clear_vfta (hw);/* Setup the receive address */ igb_init_rx_addrs (hw, rar_count);
drivers/net/ethernet/intel/igb/e1000_hw.h +1 -1
@@ -325,7 +325,7 @@ struct e1000_mac_operations {s32 (*get_thermal_sensor_data)(struct e1000_hw *);s32 (*init_thermal_sensor_thresh)(struct e1000_hw *);#endif - +void (*write_vfta)(struct e1000_hw *,u32 ,u32 ); };struct e1000_phy_operations {
drivers/net/ethernet/intel/igb/e1000_mac.c +32 -70
134 lines not on this page · raw message
drivers/net/ethernet/intel/igb/e1000_mac.h +1 -1
@@ -56,7 +56,7 @@ s32 igb_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg,void igb_clear_hw_cntrs_base (struct e1000_hw *hw);void igb_clear_vfta (struct e1000_hw *hw); -void igb_clear_vfta_i350 (struct e1000_hw *hw); +void igb_write_vfta (struct e1000_hw *hw,u32 offset,u32 value);s32 igb_vfta_set (struct e1000_hw *hw,u32 vid,bool add);void igb_config_collision_dist (struct e1000_hw *hw);void igb_init_rx_addrs (struct e1000_hw *hw,u16 rar_count);
Brown
PATCH 2/11 igb: Refactor VFTA configuration
Quoted 10 lines
From: Intel-wired-lan [intel-wired-lan-bounces at lists.osuosl.org] on behalf of Alexander Duyck [aduyck at mirantis.com]
Sent: Wednesday, January 06, 2016 11:10 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH 02/11] igb: Refactor VFTA configurationThis patch starts the clean-up process on the VFTA configuration. Specifically in this patch I attempt to address and simplify several items while also updating the code to bring it more inline with what is already in ixgbe.
Quoted 7 lines
Signed-off-by Alexander Duyck <[email protected]>--- drivers/net/ethernet/intel/igb/e1000_82575.c | 37 ++++++++- drivers/net/ethernet/intel/igb/e1000_hw.h | 2 - drivers/net/ethernet/intel/igb/e1000_mac.c | 102 ++++++++------------------ drivers/net/ethernet/intel/igb/e1000_mac.h | 2 - 4 files changed, 67 insertions(+), 76 deletions(-)
PATCH 3/11 igb: Allow asymmetric configuration of MTU versus Rx frame size
In reply to Alexander DuyckSince the igb driver is using page based receive there is no point in limiting the Rx capabilities of the device. The driver can receive 9K jumbo frames at all times. The only changes needed due to MTU changes are updates for the FIFO sizes and flow-control watermarks.
Update the maximum frame size to reflect the 9.5K limitation of the hardware, and replace all instances of max_frame_size with MAX_JUMBO_FRAME_SIZE when referring to an Rx FIFO or frame.
--- drivers/net/ethernet/intel/igb/e1000_defines.h | 3 - drivers/net/ethernet/intel/igb/igb_main.c | 107 +++++++++--------------- 2 files changed, 42 insertions(+), 68 deletions(-)
drivers/net/ethernet/intel/igb/e1000_defines.h +2 -1
@@ -357,7 +357,8 @@/* Ethertype field values */ #define ETHERNET_IEEE_VLAN_TYPE 0x8100/* 802.3ac packet */ -#define MAX_JUMBO_FRAME_SIZE 0x3F00 +/* As per the EAS the maximum supported size is 9.5KB (9728 bytes) */ +#define MAX_JUMBO_FRAME_SIZE 0x2600/* PBA constants */ #define E1000_PBA_32K 0x0020
drivers/net/ethernet/intel/igb/igb_main.c +40 -67
177 lines not on this page · raw message
PATCH 3/11 igb: Allow asymmetric configuration of MTU versus Rx frame size
Hey Alex, I have a question.
Quoted 44 lines · Alexander Duyck
Since the igb driver is using page based receive there is no point in limiting the Rx capabilities of the device. The driver can receive 9K jumbo frames at all times. The only changes needed due to MTU changes are updates for the FIFO sizes and flow-control watermarks.
Update the maximum frame size to reflect the 9.5K limitation of the hardware, and replace all instances of
max_frame_sizewithMAX_JUMBO_FRAME_SIZEwhen referring to an Rx FIFO or frame.Signed-off-by Alexander Duyck <[email protected]>---
drivers/net/ethernet/intel/igb/e1000_defines.h| 3 -drivers/net/ethernet/intel/igb/igb_main.c| 107 +++++++++---------------2 files changed, 42 insertions(+), 68 deletions(-)drivers/net/ethernet/intel/igb/e1000_defines.h +2
-1@@ -357,7 +357,8 @@/* Ethertype field values */ #define ETHERNET_IEEE_VLAN_TYPE 0x8100/* 802.3ac packet */ -#define MAX_JUMBO_FRAME_SIZE 0x3F00 +/* As per the EAS the maximum supported size is 9.5KB (9728 bytes) */ +#define MAX_JUMBO_FRAME_SIZE 0x2600/* PBA constants */ #define E1000_PBA_32K 0x0020drivers/net/ethernet/intel/igb/igb_main.c +1
-1@@ -1891,7 +1891,7 @@ void igb_reset(struct igb_adapter *adapter)struct e1000_hw *hw = &adapter->hw;struct e1000_mac_info *mac = &hw->mac;struct e1000_fc_info *fc = &hw->fc; -u32 pba =0 , tx_space, min_tx_space, min_rx_space, hwm; +u32 pba, hwm;/* Repartition Pba for greater than 9k mtu * To take effect CTRL.RST is required. @@ -1917,9 +1917,10 @@ void igb_reset(struct igb_adapter *adapter)break ;
drivers/net/ethernet/intel/igb/igb_main.c void igb_reset(struct igb_adapter *adapter) · line 1924
Quoted 10 lines
drivers/net/ethernet/intel/igb/igb_main.c +4
-3} -if ((adapter->max_frame_size >ETH_FRAME_LEN +ETH_FCS_LEN ) && - (mac->type < e1000_82576)) { -/* adjust PBA for jumbo frames */ +if (mac->type == e1000_82575) { +u32 min_rx_space, min_tx_space, needed_tx_space; + +/* write Rx PBA so that hardware can report correct Tx PBA */ wr32 (E1000_PBA , pba);
Aren't you writing a random pba here? Shouldn't it still be "pba = 0" a few lines up?
Quoted 171 lines
drivers/net/ethernet/intel/igb/igb_main.c +35
-63/* To maintain wire speed transmits, the Tx FIFO should be @@ -1929,31 +1930,26 @@ void igb_reset(struct igb_adapter *adapter)* one full receive packet and is similarly rounded up and * expressed in KB. */ - pba =rd32 (E1000_PBA ); -/* upper 16 bits has Tx packet buffer allocation size in KB */ - tx_space = pba >>16 ; -/* lower 16 bits has Rx packet buffer allocation size in KB */ - pba &=0xffff ; -/* the Tx fifo also stores 16 bytes of information about the Tx -* but don't include ethernet FCS because hardware appends it + min_rx_space =DIV_ROUND_UP (MAX_JUMBO_FRAME_SIZE ,1024 ); + +/* The Tx FIFO also stores 16 bytes of information about the Tx +* but don't include Ethernet FCS because hardware appends it. +* We only need to round down to the nearest 512 byte block count +* since the value we care about is 2 frames, not 1. */ - min_tx_space = (adapter->max_frame_size + -sizeof (union e1000_adv_tx_desc ) - -ETH_FCS_LEN ) *2 ; - min_tx_space =ALIGN (min_tx_space,1024 ); - min_tx_space >>=10 ; -/* software strips receive CRC, so leave room for it */ - min_rx_space = adapter->max_frame_size; - min_rx_space =ALIGN (min_rx_space,1024 ); - min_rx_space >>=10 ; + min_tx_space = adapter->max_frame_size; + min_tx_space +=sizeof (union e1000_adv_tx_desc ) -ETH_FCS_LEN ; + min_tx_space =DIV_ROUND_UP (min_tx_space,512 ); + +/* upper 16 bits has Tx packet buffer allocation size in KB */ + needed_tx_space = min_tx_space - (rd32 (E1000_PBA ) >>16 );/* If current Tx allocation is less than the min Tx FIFO size, * and the min Tx FIFO size is less than the current Rx FIFO -* allocation, take space away from current Rx allocation +* allocation, take space away from current Rx allocation. */ -if (tx_space < min_tx_space && - ((min_tx_space - tx_space) < pba)) { - pba = pba - (min_tx_space - tx_space); +if (needed_tx_space < pba) { + pba -= needed_tx_space;/* if short on Rx space, Rx wins and must trump Tx * adjustment @@ -1961,18 +1957,20 @@ void igb_reset(struct igb_adapter *adapter)if (pba < min_rx_space) pba = min_rx_space; } + +/* adjust PBA for jumbo frames */ wr32 (E1000_PBA , pba); } -/* flow control settings */ -/* The high water mark must be low enough to fit one full frame -* (or the size used for early receive) above it in the Rx FIFO. -* Set it to the lower of: -* - 90% of the Rx FIFO size, or -* - the full Rx FIFO size minus one full frame +/* flow control settings +* The high water mark must be low enough to fit one full frame +* after transmitting the pause frame. As such we must have enough +* space to allow for us to complete our current transmit and then +* receive the frame that is in progress from the link partner. +* Set it to: +* - the full Rx FIFO size minus one full Tx plus one full Rx frame */ - hwm =min (((pba <<10 ) *9 /10 ), - ((pba <<10 ) -2 * adapter->max_frame_size)); + hwm = (pba <<10 ) - (adapter->max_frame_size +MAX_JUMBO_FRAME_SIZE ); fc->high_water = hwm &0xFFFFFFF0 ;/* 16-byte granularity */ fc->low_water = fc->high_water -16 ;@@ -3612,7 +3610,7 @@ void igb_setup_rctl(struct igb_adapter *adapter)/* disable store bad packets and clear size bits. */ rctl &= ~(E1000_RCTL_SBP |E1000_RCTL_SZ_256 ); -/* enable LPE to prevent packets larger than max_frame_size */ +/* enable LPE to allow for reception of jumbo frames */ rctl |=E1000_RCTL_LPE ;/* disable queue 0 to prevent tail write w/o re-config */ @@ -3668,32 +3666,6 @@ static inline int igb_set_vf_rlpml(struct igb_adapter *adapter, int size,return 0 ; } -/** -* igb_rlpml_set - set maximum receive packet size -* @adapter: board private structure -* -* Configure maximum receivable packet size. -**/ -static void igb_rlpml_set (struct igb_adapter *adapter) -{ -u32 max_frame_size = adapter->max_frame_size; -struct e1000_hw *hw = &adapter->hw; -u16 pf_id = adapter->vfs_allocated_count; - -if (pf_id) { -igb_set_vf_rlpml (adapter, max_frame_size, pf_id); -/* If we're in VMDQ or SR-IOV mode, then set global RLPML -* to our max jumbo frame size, in case we need to enable -* jumbo frames on one of the rings later. -* This will not pass over-length frames into the default -* queue because it's gated by the VMOLR.RLPML. -*/ - max_frame_size =MAX_JUMBO_FRAME_SIZE ; - } - -wr32 (E1000_RLPML , max_frame_size); -} -static inline void igb_set_vmolr (struct igb_adapter *adapter,int vfn,bool aupe) {@@ -4191,7 +4163,14 @@ static void igb_set_rx_mode(struct net_device *netdev) vmolr |=rd32 (E1000_VMOLR (vfn)) & ~(E1000_VMOLR_ROPE |E1000_VMOLR_MPME |E1000_VMOLR_ROMPE ); + +/* enable Rx jumbo frames, no need for restriction */ + vmolr &= ~E1000_VMOLR_RLPML_MASK ; + vmolr |=MAX_JUMBO_FRAME_SIZE |E1000_VMOLR_LPE ; +wr32 (E1000_VMOLR (vfn), vmolr); +wr32 (E1000_RLPML ,MAX_JUMBO_FRAME_SIZE ); +igb_restore_vf_multicasts (adapter); }@@ -7331,8 +7310,6 @@ static void igb_vlan_mode(struct net_device *netdev, netdev_features_t features) ctrl &= ~E1000_CTRL_VME ;wr32 (E1000_CTRL , ctrl); } - -igb_rlpml_set (adapter); } static int igb_vlan_rx_add_vid(struct net_device *netdev,@@ -8088,9 +8065,7 @@ static void igb_init_dmac(struct igb_adapter *adapter, u32 pba)* than the Rx threshold. Set hwm to PBA - max frame * size in 16B units, capping it at PBA - 6KB. */ - hwm =64 * pba - adapter->max_frame_size /16 ; -if (hwm <64 * (pba -6 )) - hwm =64 * (pba -6 ); + hwm =64 * (pba -6 ); reg =rd32 (E1000_FCRTC ); reg &= ~E1000_FCRTC_RTH_COAL_MASK ; reg |= ((hwm << E1000_FCRTC_RTH_COAL_SHIFT)@@ -8100,9 +8075,7 @@ static void igb_init_dmac(struct igb_adapter *adapter, u32 pba)/* Set the DMA Coalescing Rx threshold to PBA - 2 * max * frame size, capping it at PBA - 10KB. */ - dmac_thr = pba - adapter->max_frame_size /512 ; -if (dmac_thr < pba -10 ) - dmac_thr = pba -10 ; + dmac_thr = pba -10 ; reg =rd32 (E1000_DMACR ); reg &= ~E1000_DMACR_DMACTHR_MASK ; reg |= ((dmac_thr << E1000_DMACR_DMACTHR_SHIFT)_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan at lists.osuosl.org
http://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH 3/11 igb: Allow asymmetric configuration of MTU versus Rx frame size
Quoted 54 lines · Hisashi T Fujinaka
Hey Alex, I have a question.
Quoted 49 lines · Alexander Duyck
Since the igb driver is using page based receive there is no point in limiting the Rx capabilities of the device. The driver can receive 9K jumbo frames at all times. The only changes needed due to MTU changes are updates for the FIFO sizes and flow-control watermarks.
Update the maximum frame size to reflect the 9.5K limitation of the hardware, and replace all instances of
max_frame_sizewithMAX_JUMBO_FRAME_SIZEwhen referring to an Rx FIFO or frame.Signed-off-by Alexander Duyck <[email protected]>---
drivers/net/ethernet/intel/igb/e1000_defines.h| 3 -drivers/net/ethernet/intel/igb/igb_main.c| 107
+++++++++---------------2 files changed, 42 insertions(+), 68 deletions(-)drivers/net/ethernet/intel/igb/e1000_defines.h +2
-1@@ -357,7 +357,8 @@/* Ethertype field values */ #define ETHERNET_IEEE_VLAN_TYPE 0x8100/* 802.3ac packet */ -#define MAX_JUMBO_FRAME_SIZE 0x3F00 +/* As per the EAS the maximum supported size is 9.5KB (9728 bytes) */ +#define MAX_JUMBO_FRAME_SIZE 0x2600/* PBA constants */ #define E1000_PBA_32K 0x0020drivers/net/ethernet/intel/igb/igb_main.c +1
-1@@ -1891,7 +1891,7 @@ void igb_reset(struct igb_adapter *adapter)struct e1000_hw *hw = &adapter->hw;struct e1000_mac_info *mac = &hw->mac;struct e1000_fc_info *fc = &hw->fc; -u32 pba =0 , tx_space, min_tx_space, min_rx_space, hwm; +u32 pba, hwm;/* Repartition Pba for greater than 9k mtu * To take effect CTRL.RST is required. @@ -1917,9 +1917,10 @@ void igb_reset(struct igb_adapter *adapter)break ; }
Quoted 13 lines
drivers/net/ethernet/intel/igb/igb_main.c void igb_reset(struct igb_adapter *adapter) · line 1924
Quoted 9 lines
drivers/net/ethernet/intel/igb/igb_main.c +4
-3-if ((adapter->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN) && -(mac->type < e1000_82576)) { -/* adjust PBA for jumbo frames */ +if (mac->type == e1000_82575) { +u32 min_rx_space, min_tx_space, needed_tx_space; + +/* write Rx PBA so that hardware can report correct Tx PBA */ wr32 (E1000_PBA , pba);Aren't you writing a random pba here? Shouldn't it still be "pba = 0" a few lines up?
If you take a look in the function there is a switch statement just above where pba is set to 34K for the 82575. There are no cases in the switch statement where pba is not set.
- Alex
PATCH 3/11 igb: Allow asymmetric configuration of MTU versus Rx frame size
Quoted 9 lines · Alexander Duyck
Quoted 4 lines · Hisashi T Fujinaka
Hey Alex, I have a question.
Aren't you writing a random pba here? Shouldn't it still be "pba = 0" a few lines up?
If you take a look in the function there is a switch statement just above where pba is set to 34K for the 82575. There are no cases in the switch statement where pba is not set.
Yeah, I need to get my eyes checked. Thanks!
Signature · 2 lines
Hisashi T Fujinaka - htodd at twofifty.com BSEE + BSChem + BAEnglish + MSCS + $2.50 = coffee
Brown
PATCH 3/11 igb: Allow asymmetric configuration of MTU versus Rx frame size
In reply to Alexander DuyckQuoted 14 lines
From: Intel-wired-lan [intel-wired-lan-bounces at lists.osuosl.org] on behalf of Alexander Duyck [aduyck at mirantis.com]
Sent: Wednesday, January 06, 2016 11:10 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH 03/11] igb: Allow asymmetric configuration of MTU versus Rx frame sizeSince the igb driver is using page based receive there is no point in limiting the Rx capabilities of the device. The driver can receive 9K jumbo frames at all times. The only changes needed due to MTU changes are updates for the FIFO sizes and flow-control watermarks.
Update the maximum frame size to reflect the 9.5K limitation of the hardware, and replace all instances of
max_frame_sizewithMAX_JUMBO_FRAME_SIZEwhen referring to an Rx FIFO or frame.
Quoted 5 lines
Signed-off-by Alexander Duyck <[email protected]>--- drivers/net/ethernet/intel/igb/e1000_defines.h | 3 - drivers/net/ethernet/intel/igb/igb_main.c | 107 +++++++++--------------- 2 files changed, 42 insertions(+), 68 deletions(-)
PATCH 4/11 igb: Do not factor VLANs into RLPML calculation
In reply to Alexander DuyckThe RLPML registers already take the size of VLAN headers into account when determining the maximum packet length. This is called out in EAS documents for several parts including the 82576 and the i350. As such we can drop the addition of size to the value programmed into the RLPML registers.
--- drivers/net/ethernet/intel/igb/igb.h | 1 - drivers/net/ethernet/intel/igb/igb_main.c | 43 +---------------------------- 2 files changed, 2 insertions(+), 42 deletions(-)
drivers/net/ethernet/intel/igb/igb.h +0 -1
@@ -97,7 +97,6 @@ struct vf_data_storage {unsigned char vf_mac_addresses[ETH_ALEN ];u16 vf_mc_hashes[IGB_MAX_VF_MC_ENTRIES ];u16 num_vf_mc_hashes; -u16 vlans_enabled;u32 flags;unsigned long last_nack;u16 pf_vlan;/* When set, guest VLAN config not allowed. */
drivers/net/ethernet/intel/igb/igb_main.c +2 -41
67 lines not on this page · raw message
Brown
PATCH 4/11 igb: Do not factor VLANs into RLPML calculation
Quoted 10 lines
From: Intel-wired-lan [intel-wired-lan-bounces at lists.osuosl.org] on behalf of Alexander Duyck [aduyck at mirantis.com]
Sent: Wednesday, January 06, 2016 11:10 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH 04/11] igb: Do not factor VLANs into RLPML calculationThe RLPML registers already take the size of VLAN headers into account when determining the maximum packet length. This is called out in EAS documents for several parts including the 82576 and the i350. As such we can drop the addition of size to the value programmed into the RLPML registers.
Quoted 5 lines
Signed-off-by Alexander Duyck <[email protected]>--- drivers/net/ethernet/intel/igb/igb.h | 1 - drivers/net/ethernet/intel/igb/igb_main.c | 43 +---------------------------- 2 files changed, 2 insertions(+), 42 deletions(-)
PATCH 5/11 igb: Always enable VLAN 0 even if 8021q is not loaded
In reply to Alexander DuyckThis patch makes it so that we always add VLAN 0. This is important as we need to guarantee the PF can receive untagged frames in the case of SR-IOV being enabled but VLAN filtering not being enabled in the kernel.
--- drivers/net/ethernet/intel/igb/igb_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/igb/igb_main.c +3 -2
@@ -7313,11 +7313,12 @@ static int igb_vlan_rx_kill_vid(struct net_device *netdev,static void igb_restore_vlan (struct igb_adapter *adapter) { -u16 vid; +u16 vid =1 ;igb_vlan_mode (adapter->netdev, adapter->netdev->features); +igb_vlan_rx_add_vid (adapter->netdev,htons (ETH_P_8021Q ),0 ); -for_each_set_bit (vid, adapter->active_vlans,VLAN_N_VID ) +for_each_set_bit_from (vid, adapter->active_vlans,VLAN_N_VID )igb_vlan_rx_add_vid (adapter->netdev,htons (ETH_P_8021Q ), vid); }
Brown
PATCH 5/11 igb: Always enable VLAN 0 even if 8021q is not loaded
Quoted 5 lines
From: Intel-wired-lan [intel-wired-lan-bounces at lists.osuosl.org] on behalf of Alexander Duyck [aduyck at mirantis.com]
Sent: Wednesday, January 06, 2016 11:10 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH 05/11] igb: Always enable VLAN 0 even if 8021q is not loaded
Quoted 8 lines
This patch makes it so that we always add VLAN 0. This is important as we need to guarantee the PF can receive untagged frames in the case of SR-IOV being enabled but VLAN filtering not being enabled in the kernel.
Signed-off-by Alexander Duyck <[email protected]>--- drivers/net/ethernet/intel/igb/igb_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
PATCH 6/11 igb: Merge VLVF configuration into igb_vfta_set
In reply to Alexander DuyckThis change makes it so that we can merge the configuration of the VLVF registers into the setting of the VFTA register. By doing this we simplify the logic and make use of similar functionality that we have already added for ixgbe making it easier to maintain both drivers.
--- drivers/net/ethernet/intel/igb/e1000_mac.c | 119 +++++++++++++++++++++++++++- drivers/net/ethernet/intel/igb/e1000_mac.h | 3 - drivers/net/ethernet/intel/igb/igb_main.c | 105 ++++--------------------- 3 files changed, 135 insertions(+), 92 deletions(-)
drivers/net/ethernet/intel/igb/e1000_mac.c +115 -4
@@ -141,21 +141,69 @@ void igb_init_rx_addrs(struct e1000_hw *hw, u16 rar_count) }/** +* igb_find_vlvf_slot - find the vlanid or the first empty slot +* @hw: pointer to hardware structure +* @vlan: VLAN id to write to VLAN filter +* @vlvf_bypass: skip VLVF if no match is found +* +* return the VLVF index where this VLAN id should be placed +* +**/ +static s32 igb_find_vlvf_slot (struct e1000_hw *hw,u32 vlan,bool vlvf_bypass) +{ +s32 regindex, first_empty_slot; +u32 bits; + +/* short cut the special case */ +if (vlan ==0 ) +return 0 ; + +/* if vlvf_bypass is set we don't want to use an empty slot, we +* will simply bypass the VLVF if there are no entries present in the +* VLVF that contain our VLAN +*/ + first_empty_slot = vlvf_bypass ? -E1000_ERR_NO_SPACE :0 ; + +/* Search for the vlan id in the VLVF entries. Save off the first empty +* slot found along the way. +* +* pre-decrement loop covering (IXGBE_VLVF_ENTRIES - 1) .. 1 +*/ +for (regindex =E1000_VLVF_ARRAY_SIZE ; --regindex >0 ;) { + bits =rd32 (E1000_VLVF (regindex)) &E1000_VLVF_VLANID_MASK ; +if (bits == vlan) +return regindex; +if (!first_empty_slot && !bits) + first_empty_slot = regindex; + } + +return first_empty_slot ? : -E1000_ERR_NO_SPACE ; +} + +/** * igb_vfta_set - enable or disable vlan in VLAN filter table * @hw: pointer to the HW structure * @vlan: VLAN id to add or remove +* @vind: VMDq output index that maps queue to VLAN id * @vlan_on: if true add filter, if false remove * * Sets or clears a bit in the VLAN filter table array based on VLAN id * and if we are adding or removing the filter **/ -s32 igb_vfta_set (struct e1000_hw *hw,u32 vlan,bool vlan_on) +s32 igb_vfta_set (struct e1000_hw *hw,u32 vlan,u32 vind, +bool vlan_on,bool vlvf_bypass) {struct igb_adapter *adapter = hw->back; -u32 regidx, vfta_delta, vfta; +u32 regidx, vfta_delta, vfta, bits; +s32 vlvf_index; -if (vlan >4095 ) -return E1000_ERR_PARAM ; +if ((vlan >4095 ) || (vind >7 )) +return -E1000_ERR_PARAM ; + +/* this is a 2 part operation - first the VFTA, then the +* VLVF and VLVFB if VT Mode is set +* We don't write the VFTA until we know the VLVF part succeeded. +*/ /* Part 1 * The VFTA is a bitstring made up of 128 32-bit registers
@@ -174,6 +222,69 @@ s32 igb_vfta_set(struct e1000_hw *hw, u32 vlan, bool vlan_on) vfta_delta &= vlan_on ? ~vfta : vfta; vfta ^= vfta_delta; +/* Part 2 +* If VT Mode is set +* Either vlan_on +* make sure the vlan is in VLVF +* set the vind bit in the matching VLVFB +* Or !vlan_on +* clear the pool bit and possibly the vind +*/ +if (!adapter->vfs_allocated_count) + goto vfta_update; + + vlvf_index =igb_find_vlvf_slot (hw, vlan, vlvf_bypass); +if (vlvf_index <0 ) { +if (vlvf_bypass) + goto vfta_update; +return vlvf_index; + } + + bits =rd32 (E1000_VLVF (vlvf_index)); + +/* set the pool bit */ + bits |=1 << (E1000_VLVF_POOLSEL_SHIFT + vind); +if (vlan_on) + goto vlvf_update; + +/* clear the pool bit */ + bits ^=1 << (E1000_VLVF_POOLSEL_SHIFT + vind); + +if (!(bits &E1000_VLVF_POOLSEL_MASK )) { +/* Clear VFTA first, then disable VLVF. Otherwise +* we run the risk of stray packets leaking into +* the PF via the default pool +*/ +if (vfta_delta) + hw->mac.ops.write_vfta (hw, regidx, vfta); + +/* disable VLVF and clear remaining bit from pool */ +wr32 (E1000_VLVF (vlvf_index),0 ); + +return 0 ; + } + +/* If there are still bits set in the VLVFB registers +* for the VLAN ID indicated we need to see if the +* caller is requesting that we clear the VFTA entry bit. +* If the caller has requested that we clear the VFTA +* entry bit but there are still pools/VFs using this VLAN +* ID entry then ignore the request. We're not worried +* about the case where we're turning the VFTA VLAN ID +* entry bit on, only when requested to turn it off as +* there may be multiple pools and/or VFs using the +* VLAN ID entry. In that case we cannot clear the +* VFTA bit until all pools/VFs using that VLAN ID have also +* been cleared. This will be indicated by "bits" being +* zero. +*/ + vfta_delta =0 ; + +vlvf_update: +/* record pool change and enable VLAN ID if not already enabled */ +wr32 (E1000_VLVF (vlvf_index), bits | vlan |E1000_VLVF_VLANID_ENABLE ); + +vfta_update:/* bit was set/cleared before we started */ if (vfta_delta) hw->mac.ops.write_vfta (hw, regidx, vfta);
drivers/net/ethernet/intel/igb/e1000_mac.h +2 -1
@@ -57,7 +57,8 @@ s32 igb_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg,void igb_clear_hw_cntrs_base (struct e1000_hw *hw);void igb_clear_vfta (struct e1000_hw *hw);void igb_write_vfta (struct e1000_hw *hw,u32 offset,u32 value); -s32 igb_vfta_set (struct e1000_hw *hw,u32 vid,bool add); +s32 igb_vfta_set (struct e1000_hw *hw,u32 vid,u32 vind, +bool vlan_on,bool vlvf_bypass);void igb_config_collision_dist (struct e1000_hw *hw);void igb_init_rx_addrs (struct e1000_hw *hw,u16 rar_count);void igb_mta_set (struct e1000_hw *hw,u32 hash_value);
drivers/net/ethernet/intel/igb/igb_main.c +18 -87
181 lines not on this page · raw message
Brown
PATCH 6/11 igb: Merge VLVF configuration into igb_vfta_set
Quoted 10 lines
From: Intel-wired-lan [intel-wired-lan-bounces at lists.osuosl.org] on behalf of Alexander Duyck [aduyck at mirantis.com]
Sent: Wednesday, January 06, 2016 11:11 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH 06/11] igb: Merge VLVF configuration intoigb_vfta_setThis change makes it so that we can merge the configuration of the VLVF registers into the setting of the VFTA register. By doing this we simplify the logic and make use of similar functionality that we have already added for ixgbe making it easier to maintain both drivers.
Quoted 6 lines
Signed-off-by Alexander Duyck <[email protected]>--- drivers/net/ethernet/intel/igb/e1000_mac.c | 119 +++++++++++++++++++++++++++- drivers/net/ethernet/intel/igb/e1000_mac.h | 3 - drivers/net/ethernet/intel/igb/igb_main.c | 105 ++++--------------------- 3 files changed, 135 insertions(+), 92 deletions(-)
PATCH 7/11 igb: Clean-up configuration of VF port VLANs
In reply to Alexander DuyckThis patch is meant to clean-up the configuration of the VF port based VLAN configuration. The original logic was a bit muddled and had some undesirable side effects such as VLANs being either completely stripped from the port or VLANs being left when they shouldn't be. The idea behind this code is to avoid any events such as spurious spoof notifications when we are removing one VLAN tag and replacing it with another.
--- drivers/net/ethernet/intel/igb/igb_main.c | 181 ++++++++++++++++++----------- 1 file changed, 110 insertions(+), 71 deletions(-)
drivers/net/ethernet/intel/igb/igb_main.c +110 -71
@@ -5914,53 +5914,6 @@ static void igb_clear_vf_vfta(struct igb_adapter *adapter, u32 vf) } } -static void igb_set_vmvir (struct igb_adapter *adapter,u32 vid,u32 vf) -{ -struct e1000_hw *hw = &adapter->hw; - -if (vid) -wr32 (E1000_VMVIR (vf), (vid |E1000_VMVIR_VLANA_DEFAULT )); -else -wr32 (E1000_VMVIR (vf),0 ); -} - -static int igb_ndo_set_vf_vlan (struct net_device *netdev, -int vf,u16 vlan,u8 qos) -{ -struct igb_adapter *adapter =netdev_priv (netdev); -struct e1000_hw *hw = &adapter->hw; -int err =0 ; - -if ((vf >= adapter->vfs_allocated_count) || (vlan >4095 ) || (qos >7 )) -return -EINVAL ; -if (vlan || qos) { - err =igb_vfta_set (hw, vlan, vf, !!vlan, false); -if (err) - goto out; -igb_set_vmvir (adapter, vlan | (qos <<VLAN_PRIO_SHIFT ), vf); -igb_set_vmolr (adapter, vf, !vlan); - adapter->vf_data[vf].pf_vlan = vlan; - adapter->vf_data[vf].pf_qos = qos; -dev_info (&adapter->pdev->dev, -"Setting VLAN %d, QOS 0x%x on VF %d\n" , vlan, qos, vf); -if (test_bit (__IGB_DOWN, &adapter->state)) { -dev_warn (&adapter->pdev->dev, -"The VF VLAN has been set, but the PF device is not up.\n" ); -dev_warn (&adapter->pdev->dev, -"Bring the PF device up before attempting to use the VF device.\n" ); - } - }else { -igb_vfta_set (hw, adapter->vf_data[vf].pf_vlan, vf, - false, false); -igb_set_vmvir (adapter, vlan, vf); -igb_set_vmolr (adapter, vf, true); - adapter->vf_data[vf].pf_vlan =0 ; - adapter->vf_data[vf].pf_qos =0 ; - } -out: -return err; -} -static int igb_find_vlvf_entry (struct igb_adapter *adapter,int vid) {struct e1000_hw *hw = &adapter->hw;
@@ -5981,23 +5934,25 @@ static int igb_find_vlvf_entry(struct igb_adapter *adapter, int vid)return i; } -static int igb_set_vf_vlan (struct igb_adapter *adapter,u32 *msgbuf,u32 vf) +static s32 igb_set_vf_vlan (struct igb_adapter *adapter,u32 vid, +bool add,u32 vf) { +int pf_id = adapter->vfs_allocated_count;struct e1000_hw *hw = &adapter->hw; -int add = (msgbuf[0 ] &E1000_VT_MSGINFO_MASK ) >>E1000_VT_MSGINFO_SHIFT ; -int vid = (msgbuf[1 ] &E1000_VLVF_VLANID_MASK ); -int err =0 ; +int err; -/* If in promiscuous mode we need to make sure the PF also has -* the VLAN filter set. +/* If VLAN overlaps with one the PF is currently monitoring make +* sure that we are able to allocate a VLVF entry. This may be +* redundant but it guarantees PF will maintain visibility to +* the VLAN. */ -if (add && (adapter->netdev->flags &IFF_PROMISC )) - err =igb_vfta_set (hw, vid, adapter->vfs_allocated_count, - true, false); -if (err) - goto out; +if (add && (adapter->netdev->flags &IFF_PROMISC )) { + err =igb_vfta_set (hw, vid, pf_id, true, false); +if (err) +return err; + } - err =igb_vfta_set (hw, vid, vf, !!add, false); + err =igb_vfta_set (hw, vid, vf, add, false);if (err) goto out;
@@ -6032,23 +5987,107 @@ out:return err; } -static inline void igb_vf_reset (struct igb_adapter *adapter,u32 vf) +static void igb_set_vmvir (struct igb_adapter *adapter,u32 vid,u32 vf) { -/* clear flags - except flag that indicates PF has set the MAC */ - adapter->vf_data[vf].flags &=IGB_VF_FLAG_PF_SET_MAC ; - adapter->vf_data[vf].last_nack = jiffies; +struct e1000_hw *hw = &adapter->hw; -/* reset offloads to defaults */ +if (vid) +wr32 (E1000_VMVIR (vf), (vid |E1000_VMVIR_VLANA_DEFAULT )); +else +wr32 (E1000_VMVIR (vf),0 ); +} + +static int igb_enable_port_vlan (struct igb_adapter *adapter,int vf, +u16 vlan,u8 qos) +{ +int err; + + err =igb_set_vf_vlan (adapter, vlan, true, vf); +if (err) +return err; + +igb_set_vmvir (adapter, vlan | (qos <<VLAN_PRIO_SHIFT ), vf); +igb_set_vmolr (adapter, vf, !vlan); + +/* revoke access to previous VLAN */ +if (vlan != adapter->vf_data[vf].pf_vlan) +igb_set_vf_vlan (adapter, adapter->vf_data[vf].pf_vlan, + false, vf); + + adapter->vf_data[vf].pf_vlan = vlan; + adapter->vf_data[vf].pf_qos = qos; +dev_info (&adapter->pdev->dev, +"Setting VLAN %d, QOS 0x%x on VF %d\n" , vlan, qos, vf); +if (test_bit (__IGB_DOWN, &adapter->state)) { +dev_warn (&adapter->pdev->dev, +"The VF VLAN has been set, but the PF device is not up.\n" ); +dev_warn (&adapter->pdev->dev, +"Bring the PF device up before attempting to use the VF device.\n" ); + } + +return err; +} + +static int igb_disable_port_vlan (struct igb_adapter *adapter,int vf) +{ +/* Restore tagless access via VLAN 0 */ +igb_set_vf_vlan (adapter,0 , true, vf); + +igb_set_vmvir (adapter,0 , vf);igb_set_vmolr (adapter, vf, true); +/* Remove any PF assigned VLAN */ +if (adapter->vf_data[vf].pf_vlan) +igb_set_vf_vlan (adapter, adapter->vf_data[vf].pf_vlan, + false, vf); + + adapter->vf_data[vf].pf_vlan =0 ; + adapter->vf_data[vf].pf_qos =0 ; + +return 0 ; +} + +static int igb_ndo_set_vf_vlan (struct net_device *netdev, +int vf,u16 vlan,u8 qos) +{ +struct igb_adapter *adapter =netdev_priv (netdev); + +if ((vf >= adapter->vfs_allocated_count) || (vlan >4095 ) || (qos >7 )) +return -EINVAL ; + +return (vlan || qos) ?igb_enable_port_vlan (adapter, vf, vlan, qos) : +igb_disable_port_vlan (adapter, vf); +} + +static int igb_set_vf_vlan_msg (struct igb_adapter *adapter,u32 *msgbuf,u32 vf) +{ +int add = (msgbuf[0 ] &E1000_VT_MSGINFO_MASK ) >>E1000_VT_MSGINFO_SHIFT ; +int vid = (msgbuf[1 ] &E1000_VLVF_VLANID_MASK ); + +if (adapter->vf_data[vf].pf_vlan) +return -1 ; + +/* VLAN 0 is a special case, don't allow it to be removed */ +if (!vid && !add) +return 0 ; + +return igb_set_vf_vlan (adapter, vid, !!add, vf); +} + +static inline void igb_vf_reset (struct igb_adapter *adapter,u32 vf) +{ +struct vf_data_storage *vf_data = &adapter->vf_data[vf]; + +/* clear flags - except flag that indicates PF has set the MAC */ + vf_data->flags &=IGB_VF_FLAG_PF_SET_MAC ; + vf_data->last_nack = jiffies; +/* reset vlans for device */ igb_clear_vf_vfta (adapter, vf); -if (adapter->vf_data[vf].pf_vlan) -igb_ndo_set_vf_vlan (adapter->netdev, vf, - adapter->vf_data[vf].pf_vlan, - adapter->vf_data[vf].pf_qos); -else -igb_clear_vf_vfta (adapter, vf); +igb_set_vf_vlan (adapter, vf_data->pf_vlan, true, vf); +igb_set_vmvir (adapter, vf_data->pf_vlan | + (vf_data->pf_qos <<VLAN_PRIO_SHIFT ), vf); +igb_set_vmolr (adapter, vf, !vf_data->pf_vlan);/* reset multicast table array for vf */ adapter->vf_data[vf].num_vf_mc_hashes =0 ;
@@ -6193,7 +6232,7 @@ static void igb_rcv_msg_from_vf(struct igb_adapter *adapter, u32 vf)"VF %d attempted to override administratively set VLAN tag\nReload the VF driver to resume operations\n" , vf); else - retval =igb_set_vf_vlan (adapter, msgbuf, vf); + retval =igb_set_vf_vlan_msg (adapter, msgbuf, vf);break ;default :dev_err (&pdev->dev,"Unhandled Msg %08x\n" , msgbuf[0 ]);
Brown
PATCH 7/11 igb: Clean-up configuration of VF port VLANs
Quoted 12 lines
From: Intel-wired-lan [intel-wired-lan-bounces at lists.osuosl.org] on behalf of Alexander Duyck [aduyck at mirantis.com]
Sent: Wednesday, January 06, 2016 11:11 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH 07/11] igb: Clean-up configuration of VF port VLANsThis patch is meant to clean-up the configuration of the VF port based VLAN configuration. The original logic was a bit muddled and had some undesirable side effects such as VLANs being either completely stripped from the port or VLANs being left when they shouldn't be. The idea behind this code is to avoid any events such as spurious spoof notifications when we are removing one VLAN tag and replacing it with another.
Quoted 4 lines
Signed-off-by Alexander Duyck <[email protected]>--- drivers/net/ethernet/intel/igb/igb_main.c | 181 ++++++++++++++++++----------- 1 file changed, 110 insertions(+), 71 deletions(-)
PATCH 8/11 igb: Add support for VLAN promiscuous with SR-IOV and NTUPLE
In reply to Alexander DuyckThis change fixes things so that we can fully support SR-IOV or the recently added NTUPLE filtering while allowing support for VLAN promiscuous mode. By making this change we are able to support possible scenarios such as SR-IOV with the PF connected to a Linux bridge hosting other VMs.
--- drivers/net/ethernet/intel/igb/igb.h | 1 drivers/net/ethernet/intel/igb/igb_main.c | 313 ++++++++++++++++++++++------- 2 files changed, 242 insertions(+), 72 deletions(-)
drivers/net/ethernet/intel/igb/igb.h +1 -0
@@ -543,6 +543,7 @@ struct igb_nfc_filter {#define IGB_FLAG_MAS_ENABLE (1 << 12)#define IGB_FLAG_HAS_MSIX (1 << 13)#define IGB_FLAG_EEE (1 << 14) +#define IGB_FLAG_VLAN_PROMISC BIT(15)/* Media Auto Sense */ #define IGB_MAS_ENABLE_0 0X0001
drivers/net/ethernet/intel/igb/igb_main.c +241 -72
402 lines not on this page · raw message
Brown
PATCH 8/11 igb: Add support for VLAN promiscuous with SR-IOV and NTUPLE
Quoted 10 lines
From: Intel-wired-lan [intel-wired-lan-bounces at lists.osuosl.org] on behalf of Alexander Duyck [aduyck at mirantis.com]
Sent: Wednesday, January 06, 2016 11:11 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH 08/11] igb: Add support for VLAN promiscuous with SR-IOV and NTUPLEThis change fixes things so that we can fully support SR-IOV or the recently added NTUPLE filtering while allowing support for VLAN promiscuous mode. By making this change we are able to support possible scenarios such as SR-IOV with the PF connected to a Linux bridge hosting other VMs.
Quoted 5 lines
Signed-off-by Alexander Duyck <[email protected]>--- drivers/net/ethernet/intel/igb/igb.h | 1 drivers/net/ethernet/intel/igb/igb_main.c | 313 ++++++++++++++++++++++------- 2 files changed, 242 insertions(+), 72 deletions(-)
PATCH 9/11 igb: Drop unnecessary checks in transmit path
In reply to Alexander DuyckThis patch drops several checks that we dropped from ixgbe some ago. It should not be possible for us to be called with either of the conditional statements returning true so we can just drop them from the hot-path.
--- drivers/net/ethernet/intel/igb/igb_main.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/net/ethernet/intel/igb/igb_main.c +0 -10
@@ -5317,16 +5317,6 @@ static netdev_tx_t igb_xmit_frame(struct sk_buff *skb, {struct igb_adapter *adapter =netdev_priv (netdev); -if (test_bit (__IGB_DOWN, &adapter->state)) { -dev_kfree_skb_any (skb); -return NETDEV_TX_OK ; - } - -if (skb->len <=0 ) { -dev_kfree_skb_any (skb); -return NETDEV_TX_OK ; - } -/* The minimum packet size with TCTL.PSP set is 17 so pad the skb * in order to meet this minimum size requirement. */
Brown
PATCH 9/11 igb: Drop unnecessary checks in transmit path
Quoted 5 lines
From: Intel-wired-lan [intel-wired-lan-bounces at lists.osuosl.org] on behalf of Alexander Duyck [aduyck at mirantis.com]
Sent: Wednesday, January 06, 2016 11:11 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH 09/11] igb: Drop unnecessary checks in transmit path
Quoted 8 lines
This patch drops several checks that we dropped from ixgbe some ago. It should not be possible for us to be called with either of the conditional statements returning true so we can just drop them from the hot-path.
Signed-off-by Alexander Duyck <[email protected]>--- drivers/net/ethernet/intel/igb/igb_main.c | 10 ---------- 1 file changed, 10 deletions(-)
PATCH 10/11 igb: Enable use of "bridge fdb add" to set unicast table entries
In reply to Alexander DuyckThis change makes it so that we can use the bridge utility to add a FDB entry for the PF to an igb port. By doing this we can enable the VFs to talk to virtual ports residing on top of the PF.
In addition this should also address issues with MACVLANs trying to reside on top of the PF as well as they would have had similar issues when added to the PF with SR-IOV enabled.
--- drivers/net/ethernet/intel/igb/igb_main.c | 39 ++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/igb/igb_main.c +30 -9
@@ -2126,6 +2126,25 @@ static u16 igb_select_queue(struct net_device *netdev,return fallback (netdev, skb); } +static int igb_ndo_fdb_add (struct ndmsg *ndm,struct nlattr *tb[], +struct net_device *dev, +const unsigned char *addr,u16 vid, +u16 flags) +{ +/* guarantee we can provide a unique filter for the unicast address */ +if (is_unicast_ether_addr (addr) ||is_link_local_ether_addr (addr)) { +struct igb_adapter *adapter =netdev_priv (dev); +struct e1000_hw *hw = &adapter->hw; +int vfn = adapter->vfs_allocated_count; +int rar_entries = hw->mac.rar_entry_count - (vfn +1 ); + +if (netdev_uc_count (dev) >= rar_entries) +return -ENOMEM ; + } + +return ndo_dflt_fdb_add (ndm, tb, dev, addr, vid, flags); +} +static const struct net_device_ops igb_netdev_ops = { .ndo_open = igb_open, .ndo_stop = igb_close,
@@ -2150,6 +2169,7 @@ static const struct net_device_ops igb_netdev_ops = {#endif .ndo_fix_features = igb_fix_features, .ndo_set_features = igb_set_features, + .ndo_fdb_add = igb_ndo_fdb_add, .ndo_features_check = passthru_features_check, };
@@ -4256,15 +4276,16 @@ static void igb_set_rx_mode(struct net_device *netdev) vmolr |=E1000_VMOLR_ROMPE ; } } -/* Write addresses to available RAR registers, if there is not -* sufficient space to store all the addresses then enable -* unicast promiscuous mode -*/ - count =igb_write_uc_addr_list (netdev); -if (count <0 ) { - rctl |=E1000_RCTL_UPE ; - vmolr |=E1000_VMOLR_ROPE ; - } + } + +/* Write addresses to available RAR registers, if there is not +* sufficient space to store all the addresses then enable +* unicast promiscuous mode +*/ + count =igb_write_uc_addr_list (netdev); +if (count <0 ) { + rctl |=E1000_RCTL_UPE ; + vmolr |=E1000_VMOLR_ROPE ; }/* enable VLAN filtering by default */
Brown
PATCH 10/11 igb: Enable use of "bridge fdb add" to set unicast table entries
Quoted 9 lines
From: Intel-wired-lan [intel-wired-lan-bounces at lists.osuosl.org] on behalf of Alexander Duyck [aduyck at mirantis.com]
Sent: Wednesday, January 06, 2016 11:11 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH 10/11] igb: Enable use of "bridge fdb add" to set unicast table entriesThis change makes it so that we can use the bridge utility to add a FDB entry for the PF to an igb port. By doing this we can enable the VFs to talk to virtual ports residing on top of the PF.
Quoted 8 lines
In addition this should also address issues with MACVLANs trying to reside on top of the PF as well as they would have had similar issues when added to the PF with SR-IOV enabled.
Signed-off-by Alexander Duyck <[email protected]>--- drivers/net/ethernet/intel/igb/igb_main.c | 39 ++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 9 deletions(-)
PATCH 11/11 igb: Add workaround for VLAN tag stripping on 82576
In reply to Alexander DuyckThere was a workaround partially implemented for the 82576 that is needed in order for VLAN tag stripping to function correctly. The original code had side effects that would make it so the workaround was active on all MACs. I have updated the code so that the workaround is enabled, but limited to the 82576, or activated if we exceed the available unicast addresses.
The workaround has a side effect of mirroring all of the traffic outgoing from the VFs back to the PF. As such it is not recommended to use the 82576 in promiscuous mode as it will take a performance hit, though this is now consistent with the performance as seen on the out-of-tree igb driver.
I also limited the scope of the UTA bits all being set to only when the VMOLR register is enabled. This should limit the effects of the UTA register so that we don't pick up any excess traffic unless promiscuous mode has been enabled on the PF, whereas before the PF would have ended up in something equivalent to unicast promiscuous mode with VLAN filtering otherwise.
--- drivers/net/ethernet/intel/igb/e1000_82575.c | 2 ++ drivers/net/ethernet/intel/igb/igb_main.c | 26 ++++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/igb/e1000_82575.c +2 -0
@@ -425,6 +425,8 @@ static s32 igb_init_mac_params_82575(struct e1000_hw *hw)/* Set mta register count */ mac->mta_reg_count =128 ; +/* Set uta register count */ + mac->uta_reg_count = (hw->mac.type == e1000_82575) ?0 :128 ;/* Set rar entry count */ switch (mac->type) {case e1000_82576:
drivers/net/ethernet/intel/igb/igb_main.c +14 -12
@@ -141,7 +141,7 @@ static struct rtnl_link_stats64 *igb_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats);static int igb_change_mtu (struct net_device *,int );static int igb_set_mac (struct net_device *,void *); -static void igb_set_uta (struct igb_adapter *adapter); +static void igb_set_uta (struct igb_adapter *adapter,bool set);static irqreturn_t igb_intr (int irq,void *);static irqreturn_t igb_intr_msi (int irq,void *);static irqreturn_t igb_msix_other (int irq,void *);
@@ -3790,9 +3790,6 @@ static void igb_configure_rx(struct igb_adapter *adapter) {int i; -/* set UTA to appropriate mode */ -igb_set_uta (adapter); -/* set the correct pool for the PF default MAC address in entry 0 */ igb_rar_set_qsel (adapter, adapter->hw.mac.addr,0 , adapter->vfs_allocated_count);
@@ -4258,7 +4255,11 @@ static void igb_set_rx_mode(struct net_device *netdev)/* Check for Promiscuous and All Multicast modes */ if (netdev->flags &IFF_PROMISC ) { rctl |=E1000_RCTL_UPE |E1000_RCTL_MPE ; - vmolr |=E1000_VMOLR_ROPE |E1000_VMOLR_MPME ; + vmolr |=E1000_VMOLR_MPME ; + +/* enable use of UTA filter to force packets to default pool */ +if (hw->mac.type == e1000_82576) + vmolr |=E1000_VMOLR_ROPE ; }else {if (netdev->flags &IFF_ALLMULTI ) { rctl |=E1000_RCTL_MPE ;
@@ -4314,6 +4315,9 @@ static void igb_set_rx_mode(struct net_device *netdev)if ((hw->mac.type < e1000_82576) || (hw->mac.type > e1000_i350))return ; +/* set UTA to appropriate mode */ +igb_set_uta (adapter, !!(vmolr &E1000_VMOLR_ROPE )); + vmolr |=rd32 (E1000_VMOLR (vfn)) & ~(E1000_VMOLR_ROPE |E1000_VMOLR_MPME |E1000_VMOLR_ROMPE );
@@ -6451,6 +6455,7 @@ static void igb_msg_task(struct igb_adapter *adapter)/** * igb_set_uta - Set unicast filter table address * @adapter: board private structure +* @set: boolean indicating if we are setting or clearing bits * * The unicast table address is a register array of 32-bit registers. * The table is meant to be used in a way similar to how the MTA is used
@@ -6458,21 +6463,18 @@ static void igb_msg_task(struct igb_adapter *adapter)* set all the hash bits to 1 and use the VMOLR ROPE bit as a promiscuous * enable bit to allow vlan tag stripping when promiscuous mode is enabled **/ -static void igb_set_uta (struct igb_adapter *adapter) +static void igb_set_uta (struct igb_adapter *adapter,bool set) {struct e1000_hw *hw = &adapter->hw; +u32 uta = set ? ~0 :0 ;int i; -/* The UTA table only exists on 82576 hardware and newer */ -if (hw->mac.type < e1000_82576) -return ; -/* we only need to do this if VMDq is enabled */ if (!adapter->vfs_allocated_count)return ; -for (i =0 ; i < hw->mac.uta_reg_count; i++) -array_wr32 (E1000_UTA , i, ~0 ); +for (i = hw->mac.uta_reg_count; i--;) +array_wr32 (E1000_UTA , i, uta); }/**
Brown
PATCH 11/11 igb: Add workaround for VLAN tag stripping on 82576
Quoted 24 lines
From: Intel-wired-lan [intel-wired-lan-bounces at lists.osuosl.org] on behalf of Alexander Duyck [aduyck at mirantis.com]
Sent: Wednesday, January 06, 2016 11:11 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH 11/11] igb: Add workaround for VLAN tag stripping on 82576There was a workaround partially implemented for the 82576 that is needed in order for VLAN tag stripping to function correctly. The original code had side effects that would make it so the workaround was active on all MACs. I have updated the code so that the workaround is enabled, but limited to the 82576, or activated if we exceed the available unicast addresses.
The workaround has a side effect of mirroring all of the traffic outgoing from the VFs back to the PF. As such it is not recommended to use the 82576 in promiscuous mode as it will take a performance hit, though this is now consistent with the performance as seen on the out-of-tree igb driver.
I also limited the scope of the UTA bits all being set to only when the VMOLR register is enabled. This should limit the effects of the UTA register so that we don't pick up any excess traffic unless promiscuous mode has been enabled on the PF, whereas before the PF would have ended up in something equivalent to unicast promiscuous mode with VLAN filtering otherwise.
Quoted 5 lines
Signed-off-by Alexander Duyck <[email protected]>--- drivers/net/ethernet/intel/igb/e1000_82575.c | 2 ++ drivers/net/ethernet/intel/igb/igb_main.c | 26 ++++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-)