i40e/i40evf: Fix mixed size frags and linearization
Subsystems (2)
PATCH 1/2 i40e/i40evf: Fix mixed size frags and linearization
From: Anjali Singhai Jain <[email protected]>
This patch fixes a bug where the i40e tx queue will hang if this skb is passed to the driver.
With mixed size fragments while using TSO there was a corner case where we needed to linearize but we were not. This was seen with iSCSI traffic and could be reproduced with a frag list that looks like this:
num_frags = 17, gso_segs = 17, hdr_len = 66, skb_shinfo(skb)->gso_size = 1448
size = 3002, j = 1, frag_size = 2936, num_frags = 17 size = 4268, j = 1, frag_size = 4096, num_frags = 16 size = 5534, j = 1, frag_size = 4096, num_frags = 15 size = 5352, j = 1, frag_size = 4096, num_frags = 14 size = 5170, j = 1, frag_size = 4096, num_frags = 13 size = 3468, j = 1, frag_size = 2576, num_frags = 12 size = 750, j = 1, frag_size = 112, num_frags = 11 size = 862, j = 2, frag_size = 112, num_frags = 10 size = 974, j = 3, frag_size = 112, num_frags = 9 size = 1126, j = 4, frag_size = 152, num_frags = 8 size = 1330, j = 5, frag_size = 204, num_frags = 7 size = 1534, j = 6, frag_size = 204, num_frags = 6 size = 356, j = 1, frag_size = 204, num_frags = 5 size = 560, j = 2, frag_size = 204, num_frags = 4 size = 764, j = 3, frag_size = 204, num_frags = 3 size = 968, j = 4, frag_size = 204, num_frags = 2 size = 1140, j = 5, frag_size = 172, num_frags = 1
result: linearize = 0, j = 6
--- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 25 ++++++++++--------------- drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 25 ++++++++++--------------- 2 files changed, 20 insertions(+), 30 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_txrx.c +10 -15
@@ -2410,14 +2410,12 @@ static int i40e_maybe_stop_tx(struct i40e_ring *tx_ring, int size)* i40e_chk_linearize - Check if there are more than 8 fragments per packet * @skb: send buffer * @tx_flags: collected send information -* @hdr_len: size of the packet header * * Note: Our HW can't scatter-gather more than 8 fragments to build * a packet on the wire and so we need to figure out the cases where we * need to linearize the skb. **/ -static bool i40e_chk_linearize (struct sk_buff *skb,u32 tx_flags, -const u8 hdr_len) +static bool i40e_chk_linearize (struct sk_buff *skb,u32 tx_flags) {struct skb_frag_struct *frag;bool linearize = false;
@@ -2429,7 +2427,7 @@ static bool i40e_chk_linearize(struct sk_buff *skb, u32 tx_flags, gso_segs =skb_shinfo (skb)->gso_segs;if (tx_flags & (I40E_TX_FLAGS_TSO |I40E_TX_FLAGS_FSO )) { -u16 j =1 ; +u16 j =0 ;if (num_frags < (I40E_MAX_BUFFER_TXD )) goto linearize_chk_done;
@@ -2440,21 +2438,18 @@ static bool i40e_chk_linearize(struct sk_buff *skb, u32 tx_flags, goto linearize_chk_done; } frag = &skb_shinfo (skb)->frags[0 ]; - size = hdr_len;/* we might still have more fragments per segment */ do { size +=skb_frag_size (frag); frag++; j++; +if ((size >=skb_shinfo (skb)->gso_size) && + (j <I40E_MAX_BUFFER_TXD )) { + size = (size %skb_shinfo (skb)->gso_size); + j = (size) ?1 :0 ; + }if (j ==I40E_MAX_BUFFER_TXD ) { -if (size <skb_shinfo (skb)->gso_size) { - linearize = true; -break ; - } - j =1 ; - size -=skb_shinfo (skb)->gso_size; -if (size) - j++; - size += hdr_len; + linearize = true; +break ; } num_frags--; }while (num_frags);
@@ -2724,7 +2719,7 @@ static netdev_tx_t i40e_xmit_frame_ring(struct sk_buff *skb,if (tsyn) tx_flags |=I40E_TX_FLAGS_TSYN ; -if (i40e_chk_linearize (skb, tx_flags, hdr_len)) +if (i40e_chk_linearize (skb, tx_flags))if (skb_linearize (skb)) goto out_drop;
drivers/net/ethernet/intel/i40evf/i40e_txrx.c +10 -15
@@ -1619,14 +1619,12 @@ static void i40e_create_tx_ctx(struct i40e_ring *tx_ring,* i40e_chk_linearize - Check if there are more than 8 fragments per packet * @skb: send buffer * @tx_flags: collected send information -* @hdr_len: size of the packet header * * Note: Our HW can't scatter-gather more than 8 fragments to build * a packet on the wire and so we need to figure out the cases where we * need to linearize the skb. **/ -static bool i40e_chk_linearize (struct sk_buff *skb,u32 tx_flags, -const u8 hdr_len) +static bool i40e_chk_linearize (struct sk_buff *skb,u32 tx_flags) {struct skb_frag_struct *frag;bool linearize = false;
@@ -1638,7 +1636,7 @@ static bool i40e_chk_linearize(struct sk_buff *skb, u32 tx_flags, gso_segs =skb_shinfo (skb)->gso_segs;if (tx_flags & (I40E_TX_FLAGS_TSO |I40E_TX_FLAGS_FSO )) { -u16 j =1 ; +u16 j =0 ;if (num_frags < (I40E_MAX_BUFFER_TXD )) goto linearize_chk_done;
@@ -1649,21 +1647,18 @@ static bool i40e_chk_linearize(struct sk_buff *skb, u32 tx_flags, goto linearize_chk_done; } frag = &skb_shinfo (skb)->frags[0 ]; - size = hdr_len;/* we might still have more fragments per segment */ do { size +=skb_frag_size (frag); frag++; j++; +if ((size >=skb_shinfo (skb)->gso_size) && + (j <I40E_MAX_BUFFER_TXD )) { + size = (size %skb_shinfo (skb)->gso_size); + j = (size) ?1 :0 ; + }if (j ==I40E_MAX_BUFFER_TXD ) { -if (size <skb_shinfo (skb)->gso_size) { - linearize = true; -break ; - } - j =1 ; - size -=skb_shinfo (skb)->gso_size; -if (size) - j++; - size += hdr_len; + linearize = true; +break ; } num_frags--; }while (num_frags);
@@ -1950,7 +1945,7 @@ static netdev_tx_t i40e_xmit_frame_ring(struct sk_buff *skb,else if (tso) tx_flags |=I40E_TX_FLAGS_TSO ; -if (i40e_chk_linearize (skb, tx_flags, hdr_len)) +if (i40e_chk_linearize (skb, tx_flags))if (skb_linearize (skb)) goto out_drop;
PATCH 2/2 i40e: start up in VEPA mode by default
From: Anjali Singhai Jain <[email protected]>
The patch fixes a bug in the default configuration which prevented a software bridge loaded on the PF interface from working correctly because broadcast packets are incorrectly looped back.
Fix the general case, by loading the driver in VEPA mode Until a VF or VMDq VSI is added. This way loopback on the Main VSI is turned off until needed and can resolve the issue of unnecessary reflection for users that do not have VF or VMDq VSIs setup.
The driver must now coordinate the loopback setting for the Flow Director (FDIR) VSI to make sure it is in sync with the current VEB or VEPA mode setting.
The user can still switch bridge modes from the bridge commands and choose to be in VEPA mode with VF VSIs. Because of hardware requirements, the call to switch to VEB mode when no VF/VMDqs are present will be rejected.
NOTE: This patch uses BIT_ULL as that is preferred going forward, a followup patch in the lower priority queue to net-next will fix up the remaining 1 << usages.
--- drivers/net/ethernet/intel/i40e/i40e.h | 1 + drivers/net/ethernet/intel/i40e/i40e_debugfs.c | 9 +++++++++ drivers/net/ethernet/intel/i40e/i40e_main.c | 21 ++++++++++++++++---- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 10 +++++++++- 4 files changed, 36 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +1 -0
@@ -317,6 +317,7 @@ struct i40e_pf {#endif #define I40E_FLAG_PORT_ID_VALID (u64)(1 << 28)#define I40E_FLAG_DCB_CAPABLE (u64)(1 << 29) +#define I40E_FLAG_VEB_MODE_ENABLED BIT_ULL(40)/* tracks features that get auto disabled by errors */ u64 auto_disable_flags;
drivers/net/ethernet/intel/i40e/i40e_debugfs.c +9 -0
@@ -1021,6 +1021,15 @@ static ssize_t i40e_dbg_command_write(struct file *filp, goto command_write_done; } +/* By default we are in VEPA mode, if this is the first VF/VMDq +* VSI to be added switch to VEB mode. +*/ +if (!(pf->flags &I40E_FLAG_VEB_MODE_ENABLED )) { + pf->flags |=I40E_FLAG_VEB_MODE_ENABLED ; +i40e_do_reset_safe (pf, +BIT_ULL (__I40E_PF_RESET_REQUESTED)); + } + vsi =i40e_vsi_setup (pf,I40E_VSI_VMDQ2 , vsi_seid,0 );if (vsi) dev_info(&pf->pdev->dev, "added VSI %d to relay %d\n",
drivers/net/ethernet/intel/i40e/i40e_main.c +17 -4
@@ -6097,6 +6097,10 @@ static int i40e_reconstitute_veb(struct i40e_veb *veb)if (ret) goto end_reconstitute; +if (pf->flags &I40E_FLAG_VEB_MODE_ENABLED ) + veb->bridge_mode =BRIDGE_MODE_VEB ; +else + veb->bridge_mode =BRIDGE_MODE_VEPA ;i40e_config_bridge_mode (veb);/* create the remaining VSIs attached to this VEB */
@@ -8031,7 +8035,12 @@ static int i40e_ndo_bridge_setlink(struct net_device *dev, }else if (mode != veb->bridge_mode) {/* Existing HW bridge but different mode needs reset */ veb->bridge_mode = mode; -i40e_do_reset (pf, (1 << __I40E_PF_RESET_REQUESTED)); +/* TODO: If no VFs or VMDq VSIs, disallow VEB mode */ +if (mode ==BRIDGE_MODE_VEB ) + pf->flags |=I40E_FLAG_VEB_MODE_ENABLED ; +else + pf->flags &= ~I40E_FLAG_VEB_MODE_ENABLED ; +i40e_do_reset (pf,BIT_ULL (__I40E_PF_RESET_REQUESTED));break ; } }
@@ -8343,11 +8352,12 @@ static int i40e_add_vsi(struct i40e_vsi *vsi) ctxt.uplink_seid = vsi->uplink_seid; ctxt.connection_type =I40E_AQ_VSI_CONN_TYPE_NORMAL ; ctxt.flags =I40E_AQ_VSI_TYPE_PF ; -if (i40e_is_vsi_uplink_mode_veb (vsi)) { +if ((pf->flags &I40E_FLAG_VEB_MODE_ENABLED ) && + (i40e_is_vsi_uplink_mode_veb (vsi))) { ctxt.info.valid_sections |= -cpu_to_le16 (I40E_AQ_VSI_PROP_SWITCH_VALID ); +cpu_to_le16 (I40E_AQ_VSI_PROP_SWITCH_VALID ); ctxt.info.switch_id = -cpu_to_le16 (I40E_AQ_VSI_SW_ID_FLAG_ALLOW_LB ); +cpu_to_le16 (I40E_AQ_VSI_SW_ID_FLAG_ALLOW_LB ); }i40e_vsi_setup_queue_map (vsi, &ctxt, enabled_tc, true);break ;
@@ -8746,6 +8756,9 @@ struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type, __func__);return NULL ; } +/* We come up by default in VEPA mode */ + veb->bridge_mode =BRIDGE_MODE_VEPA ; + pf->flags &= ~I40E_FLAG_VEB_MODE_ENABLED ;i40e_config_bridge_mode (veb); }for (i =0 ; i <I40E_MAX_VEB && !veb; i++) {
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +9 -1
@@ -1018,11 +1018,19 @@ int i40e_pci_sriov_configure(struct pci_dev *pdev, int num_vfs) {struct i40e_pf *pf =pci_get_drvdata (pdev); -if (num_vfs) +if (num_vfs) { +if (!(pf->flags &I40E_FLAG_VEB_MODE_ENABLED )) { + pf->flags |=I40E_FLAG_VEB_MODE_ENABLED ; +i40e_do_reset_safe (pf, +BIT_ULL (__I40E_PF_RESET_REQUESTED)); + }return i40e_pci_sriov_enable (pdev, num_vfs); + }if (!pci_vfs_assigned (pf->pdev)) {i40e_free_vfs (pf); + pf->flags &= ~I40E_FLAG_VEB_MODE_ENABLED ; +i40e_do_reset_safe (pf,BIT_ULL (__I40E_PF_RESET_REQUESTED)); }else {dev_warn (&pdev->dev,"Unable to free VFs because some are assigned to VMs.\n" );return -EINVAL ;
PATCH 2/2 i40e: start up in VEPA mode by default
Quoted 28 lines · Jesse Brandeburg
From: Anjali Singhai Jain <[email protected]>
The patch fixes a bug in the default configuration which prevented a software bridge loaded on the PF interface from working correctly because broadcast packets are incorrectly looped back.
Fix the general case, by loading the driver in VEPA mode Until a VF or VMDq VSI is added. This way loopback on the Main VSI is turned off until needed and can resolve the issue of unnecessary reflection for users that do not have VF or VMDq VSIs setup.
The driver must now coordinate the loopback setting for the Flow Director (FDIR) VSI to make sure it is in sync with the current VEB or VEPA mode setting.
The user can still switch bridge modes from the bridge commands and choose to be in VEPA mode with VF VSIs. Because of hardware requirements, the call to switch to VEB mode when no VF/VMDqs are present will be rejected.
NOTE: This patch uses
BIT_ULLas that is preferred going forward, a followup patch in the lower priority queue to net-next will fix up the remaining 1 << usages.Change-ID Ib121ddb18fe4b3c4f52e9deda6fcbeb9105683d1Signed-off-by Anjali Singhai Jain <[email protected]>Signed-off-by Jesse Brandeburg <[email protected]>
Quoted 7 lines
--- drivers/net/ethernet/intel/i40e/i40e.h | 1 + drivers/net/ethernet/intel/i40e/i40e_debugfs.c | 9 +++++++++ drivers/net/ethernet/intel/i40e/i40e_main.c | 21 ++++++++++++++++---- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 10 +++++++++- 4 files changed, 36 insertions(+), 5 deletions(-)
Applied to my net-queue tree
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20150516/cd7a0b94/attachment.asc>
Young
PATCH 2/2 i40e: start up in VEPA mode by default
In reply to Jesse BrandeburgQuoted 35 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jesse Brandeburg
Sent: Friday, May 08, 2015 3:36 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [net PATCH 2/2] i40e: start up in VEPA mode by defaultFrom: Anjali Singhai Jain <[email protected]>
The patch fixes a bug in the default configuration which prevented a software bridge loaded on the PF interface from working correctly because broadcast packets are incorrectly looped back.
Fix the general case, by loading the driver in VEPA mode Until a VF or VMDq VSI is added. This way loopback on the Main VSI is turned off until needed and can resolve the issue of unnecessary reflection for users that do not have VF or VMDq VSIs setup.
The driver must now coordinate the loopback setting for the Flow Director (FDIR) VSI to make sure it is in sync with the current VEB or VEPA mode setting.
The user can still switch bridge modes from the bridge commands and choose to be in VEPA mode with VF VSIs. Because of hardware requirements, the call to switch to VEB mode when no VF/VMDqs are present will be rejected.
NOTE: This patch uses
BIT_ULLas that is preferred going forward, a followup patch in the lower priority queue to net-next will fix up the remaining 1 << usages.Change-ID Ib121ddb18fe4b3c4f52e9deda6fcbeb9105683d1Signed-off-by Anjali Singhai Jain <[email protected]>Signed-off-by Jesse Brandeburg <[email protected]>
Quoted 8 lines
--- drivers/net/ethernet/intel/i40e/i40e.h | 1 + drivers/net/ethernet/intel/i40e/i40e_debugfs.c | 9 +++++++++ drivers/net/ethernet/intel/i40e/i40e_main.c | 21 ++++++++++++++++- --- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 10 +++++++++- 4 files changed, 36 insertions(+), 5 deletions(-)
Tested with sriov turned on, and sriov enabled in the bios, bridging works.
PATCH 1/2 i40e/i40evf: Fix mixed size frags and linearization
In reply to Jesse BrandeburgQuoted 34 lines · Jesse Brandeburg
From: Anjali Singhai Jain <[email protected]>
This patch fixes a bug where the i40e tx queue will hang if this skb is passed to the driver.
With mixed size fragments while using TSO there was a corner case where we needed to linearize but we were not. This was seen with iSCSI traffic and could be reproduced with a frag list that looks like this:
num_frags= 17,gso_segs= 17,hdr_len= 66, skb_shinfo(skb)->gso_size = 1448
size = 3002, j = 1,frag_size= 2936,num_frags= 17 size = 4268, j = 1,frag_size= 4096,num_frags= 16 size = 5534, j = 1,frag_size= 4096,num_frags= 15 size = 5352, j = 1,frag_size= 4096,num_frags= 14 size = 5170, j = 1,frag_size= 4096,num_frags= 13 size = 3468, j = 1,frag_size= 2576,num_frags= 12 size = 750, j = 1,frag_size= 112,num_frags= 11 size = 862, j = 2,frag_size= 112,num_frags= 10 size = 974, j = 3,frag_size= 112,num_frags= 9 size = 1126, j = 4,frag_size= 152,num_frags= 8 size = 1330, j = 5,frag_size= 204,num_frags= 7 size = 1534, j = 6,frag_size= 204,num_frags= 6 size = 356, j = 1,frag_size= 204,num_frags= 5 size = 560, j = 2,frag_size= 204,num_frags= 4 size = 764, j = 3,frag_size= 204,num_frags= 3 size = 968, j = 4,frag_size= 204,num_frags= 2 size = 1140, j = 5,frag_size= 172,num_frags= 1
result: linearize = 0, j = 6Change-ID I79bb1aeab0af255fe2ce28e93672a85d85bf47e8Signed-off-by Anjali Singhai Jain <[email protected]>Signed-off-by Jesse Brandeburg <[email protected]>
Quoted 6 lines
--- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 25 ++++++++++--------------- drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 25 ++++++++++--------------- 2 files changed, 20 insertions(+), 30 deletions(-)
Applied to my net-queue tree
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20150516/49bd464b/attachment.asc>