ethtool flow director fixups
Subsystems (2)
cover ethtool flow director fixups
This series is PART1 of 2 parts, containing some initial fixups for the ethtool ntuple filter API. The first part should be relatively self-contained and each fix should stand on its own. It is textually necessary for this series to land before PART2 can be applied.
Jacob Keller (11):
i40e: send correct port number to AdminQ when enabling UDP tunnels
i40e: don't use arrays for (src|dst)_ip
i40e: rework exit flow of i40e_add_fdir_ethtool
i40e: return immediately when failing to add fdir filter
i40e: exit ATR mode only when adding TCP/IPv4 filter succeeds
i40e: remove redundant check for fd_tcp_rule when restoring filters
i40e: reset fd_tcp_rule count when restoring filters
i40e: don't re-enable ATR when flushing filters if SB has TCP4/IPv4
rules
i40e: add counters for UDP/IPv4 and IPv4 filters
i40e: explicitly fail on extended MAC field for ethtool_rx_flow_spec
i40e: always remove old filter when adding new FDir filter
drivers/net/ethernet/intel/i40e/i40e.h | 16 +++-- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 59 ++++++++---------- drivers/net/ethernet/intel/i40e/i40e_main.c | 43 +++++++------ drivers/net/ethernet/intel/i40e/i40e_txrx.c | 84 ++++++++++++++------------ 4 files changed, 105 insertions(+), 97 deletions(-)
Signature · 1 line
2.12.0.rc0.151.g8a5726c42288
PATCH 1/11 i40e: send correct port number to AdminQ when enabling UDP tunnels
The firmware expects the port numbers for offloaded UDP tunnels in Little Endian format. We accidentally sent the value in Big Endian format which obviously will cause the wrong port number to be put into the UDP tunnels list. This results in VxLAN and Geneve tunnel Rx offloads being essentially disabled, unless the port number happens to be identical after byte swapping. Note that i40e_aq_add_udp_tunnel() will byteswap the parameter from host order into Little Endian so we don't need worry about passing strictly a __le16 value to the command.
This patch essentially reverts b3f5c7bc88ba ("i40e: Fix for extra byte swap in tunnel setup", 2016-08-24), but in a way that makes the result much more clear to the reader.
--- drivers/net/ethernet/intel/i40e/i40e.h | 3 ++- drivers/net/ethernet/intel/i40e/i40e_main.c | 17 ++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +2 -1
@@ -248,7 +248,8 @@ struct i40e_tc_configuration { };struct i40e_udp_port_config { -__be16 index; +/* AdminQ command interface expects port number in Host byte order */ +u16 index;u8 type; };
drivers/net/ethernet/intel/i40e/i40e_main.c +8 -9
@@ -7494,7 +7494,7 @@ static void i40e_sync_udp_filters_subtask(struct i40e_pf *pf) {struct i40e_hw *hw = &pf->hw;i40e_status ret; -__be16 port; +u16 port;int i;if (!(pf->flags &I40E_FLAG_UDP_FILTER_SYNC ))
@@ -7518,7 +7518,7 @@ static void i40e_sync_udp_filters_subtask(struct i40e_pf *pf)"%s %s port %d, index %d failed, err %s aq_err %s\n" , pf->udp_ports[i].type ?"vxlan" :"geneve" , port ?"add" :"delete" , -ntohs (port), i, + port, i,i40e_stat_str (&pf->hw, ret),i40e_aq_str (&pf->hw, pf->hw.aq.asq_last_status));
@@ -9201,7 +9201,7 @@ static int i40e_set_features(struct net_device *netdev,* * Returns the index number or I40E_MAX_PF_UDP_OFFLOAD_PORTS if port not found **/ -static u8 i40e_get_udp_port_idx (struct i40e_pf *pf,__be16 port) +static u8 i40e_get_udp_port_idx (struct i40e_pf *pf,u16 port) {u8 i;
@@ -9224,7 +9224,7 @@ static void i40e_udp_tunnel_add(struct net_device *netdev,struct i40e_netdev_priv *np =netdev_priv (netdev);struct i40e_vsi *vsi = np->vsi;struct i40e_pf *pf = vsi->back; -__be16 port = ti->port; +u16 port =ntohs (ti->port);u8 next_idx;u8 idx;
@@ -9232,8 +9232,7 @@ static void i40e_udp_tunnel_add(struct net_device *netdev,/* Check if port already exists */ if (idx <I40E_MAX_PF_UDP_OFFLOAD_PORTS ) { -netdev_info (netdev,"port %d already offloaded\n" , -ntohs (port)); +netdev_info (netdev,"port %d already offloaded\n" , port);return ; }
@@ -9242,7 +9241,7 @@ static void i40e_udp_tunnel_add(struct net_device *netdev,if (next_idx ==I40E_MAX_PF_UDP_OFFLOAD_PORTS ) {netdev_info (netdev,"maximum number of offloaded UDP ports reached, not adding port %d\n" , -ntohs (port)); + port);return ; }
@@ -9276,7 +9275,7 @@ static void i40e_udp_tunnel_del(struct net_device *netdev,struct i40e_netdev_priv *np =netdev_priv (netdev);struct i40e_vsi *vsi = np->vsi;struct i40e_pf *pf = vsi->back; -__be16 port = ti->port; +u16 port =ntohs (ti->port);u8 idx; idx =i40e_get_udp_port_idx (pf, port);
@@ -9308,7 +9307,7 @@ static void i40e_udp_tunnel_del(struct net_device *netdev,return ; not_found:netdev_warn (netdev,"UDP port %d was not found, not deleting\n" , -ntohs (port)); + port); } static int i40e_get_phys_port_id(struct net_device *netdev,
Signature · 1 line
2.12.0.rc0.151.g8a5726c42288
Bowers
PATCH 1/11 i40e: send correct port number to AdminQ when enabling UDP tunnels
Quoted 21 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Monday, February 6, 2017 2:39 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [PART1 PATCH 01/11] i40e: send correct port number to AdminQ when enabling UDP tunnelsThe firmware expects the port numbers for offloaded UDP tunnels in Little Endian format. We accidentally sent the value in Big Endian format which obviously will cause the wrong port number to be put into the UDP tunnels list. This results in VxLAN and Geneve tunnel Rx offloads being essentially disabled, unless the port number happens to be identical after byte swapping. Note that
i40e_aq_add_udp_tunnel()will byteswap the parameter from host order into Little Endian so we don't need worry about passing strictly a__le16value to the command.This patch essentially reverts
b3f5c7bc88ba("i40e: Fix for extra byte swap in tunnel setup", 2016-08-24), but in a way that makes the result much more clear to the reader.
Quoted 8 lines
Fixes b3f5c7bc88ba ("i40e: Fix for extra byte swap in tunnel setup", 2016-08-24)
Signed-off-by Jacob Keller <[email protected]>Reviewed-by Williams, Mitch A <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e.h | 3 ++- drivers/net/ethernet/intel/i40e/i40e_main.c | 17 ++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-)
PATCH 2/11 i40e: don't use arrays for (src|dst)_ip
In reply to Jacob KellerThe code originally included src_ip and dst_ip with enough space to support ipv6 filters. However, no actual support for ipv6 filters has been implemented. Thus, remove the arrays and just use __be32 values. Should ipv6 support be added in the future, we can replace these with a union that has sizes for both values.
--- drivers/net/ethernet/intel/i40e/i40e.h | 4 ++-- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 12 ++++++------ drivers/net/ethernet/intel/i40e/i40e_txrx.c | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +2 -2
@@ -212,8 +212,8 @@ struct i40e_fdir_filter {u8 flow_type;u8 ip4_proto;/* TX packet view of src and dst */ -__be32 dst_ip[4 ]; -__be32 src_ip[4 ]; +__be32 dst_ip; +__be32 src_ip;__be16 src_port;__be16 dst_port;__be32 sctp_v_tag;
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +6 -6
@@ -2368,8 +2368,8 @@ static int i40e_get_ethtool_fdir_entry(struct i40e_pf *pf,*/ fsp->h_u.tcp_ip4_spec.psrc = rule->dst_port; fsp->h_u.tcp_ip4_spec.pdst = rule->src_port; - fsp->h_u.tcp_ip4_spec.ip4src = rule->dst_ip[0 ]; - fsp->h_u.tcp_ip4_spec.ip4dst = rule->src_ip[0 ]; + fsp->h_u.tcp_ip4_spec.ip4src = rule->dst_ip; + fsp->h_u.tcp_ip4_spec.ip4dst = rule->src_ip;if (rule->dest_ctl ==I40E_FILTER_PROGRAM_DESC_DEST_DROP_PACKET ) fsp->ring_cookie =RX_CLS_FLOW_DISC ;
@@ -2592,8 +2592,8 @@ static int i40e_set_rss_hash_opt(struct i40e_pf *pf, struct ethtool_rxnfc *nfc)static bool i40e_match_fdir_input_set (struct i40e_fdir_filter *rule,struct i40e_fdir_filter *input) { -if ((rule->dst_ip[0 ] != input->dst_ip[0 ]) || - (rule->src_ip[0 ] != input->src_ip[0 ]) || +if ((rule->dst_ip != input->dst_ip) || + (rule->src_ip != input->src_ip) || (rule->dst_port != input->dst_port) || (rule->src_port != input->src_port))return false;
@@ -2769,8 +2769,8 @@ static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi,*/ input->dst_port = fsp->h_u.tcp_ip4_spec.psrc; input->src_port = fsp->h_u.tcp_ip4_spec.pdst; - input->dst_ip[0 ] = fsp->h_u.tcp_ip4_spec.ip4src; - input->src_ip[0 ] = fsp->h_u.tcp_ip4_spec.ip4dst; + input->dst_ip = fsp->h_u.tcp_ip4_spec.ip4src; + input->src_ip = fsp->h_u.tcp_ip4_spec.ip4dst;if (ntohl (fsp->m_ext.data[1 ])) { vf_id =ntohl (fsp->h_ext.data[1 ]);
drivers/net/ethernet/intel/i40e/i40e_txrx.c +6 -6
@@ -220,9 +220,9 @@ static int i40e_add_del_fdir_udpv4(struct i40e_vsi *vsi, udp = (struct udphdr *)(raw_packet +IP_HEADER_OFFSET +sizeof (struct iphdr )); - ip->daddr = fd_data->dst_ip[0 ]; + ip->daddr = fd_data->dst_ip; udp->dest = fd_data->dst_port; - ip->saddr = fd_data->src_ip[0 ]; + ip->saddr = fd_data->src_ip; udp->source = fd_data->src_port; fd_data->pctype =I40E_FILTER_PCTYPE_NONF_IPV4_UDP ;
@@ -282,9 +282,9 @@ static int i40e_add_del_fdir_tcpv4(struct i40e_vsi *vsi, tcp = (struct tcphdr *)(raw_packet +IP_HEADER_OFFSET +sizeof (struct iphdr )); - ip->daddr = fd_data->dst_ip[0 ]; + ip->daddr = fd_data->dst_ip; tcp->dest = fd_data->dst_port; - ip->saddr = fd_data->src_ip[0 ]; + ip->saddr = fd_data->src_ip; tcp->source = fd_data->src_port;if (add) {
@@ -360,8 +360,8 @@ static int i40e_add_del_fdir_ipv4(struct i40e_vsi *vsi,memcpy (raw_packet, packet,I40E_IP_DUMMY_PACKET_LEN ); ip = (struct iphdr *)(raw_packet +IP_HEADER_OFFSET ); - ip->saddr = fd_data->src_ip[0 ]; - ip->daddr = fd_data->dst_ip[0 ]; + ip->saddr = fd_data->src_ip; + ip->daddr = fd_data->dst_ip; ip->protocol =0 ; fd_data->pctype = i;
Signature · 1 line
2.12.0.rc0.151.g8a5726c42288
Bowers
PATCH 2/11 i40e: don't use arrays for (src|dst)_ip
Quoted 14 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Monday, February 6, 2017 2:39 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [PART1 PATCH 02/11] i40e: don't use arrays for (src|dst)_ipThe code originally included
src_ipanddst_ipwith enough space to support ipv6 filters. However, no actual support for ipv6 filters has been implemented. Thus, remove the arrays and just use__be32values. Should ipv6 support be added in the future, we can replace these with a union that has sizes for both values.
Quoted 7 lines
Signed-off-by Jacob Keller <[email protected]>Change-Id I1bc04032244a80eb6ebc8a4e6c723a4a665c1dd5--- drivers/net/ethernet/intel/i40e/i40e.h | 4 ++-- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 12 ++++++------ drivers/net/ethernet/intel/i40e/i40e_txrx.c | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-)
PATCH 3/11 i40e: rework exit flow of i40e_add_fdir_ethtool
In reply to Jacob KellerRefactor the exit flow of the i40e_add_fdir_ethtool function. Move the input_label to the end of the function, removing the dependency on having a non-zero return value. Add a comment explaining why it is ok not to free the fdir data structure, because the structure is now stored in the fdir_filter_list.
--- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +11 -4
@@ -2790,12 +2790,19 @@ static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi, } ret =i40e_add_del_fdir (vsi, input, true); -free_input:if (ret) -kfree (input); -else -i40e_update_ethtool_fdir_entry (vsi, input, fsp->location,NULL ); + goto free_input; +/* Add the input filter to the fdir_input_list, possibly replacing +* a previous filter. Do not free the input structure after adding it +* to the list as this would cause a use-after-free bug. +*/ +i40e_update_ethtool_fdir_entry (vsi, input, fsp->location,NULL ); + +return 0 ; + +free_input: +kfree (input);return ret; }
Signature · 1 line
2.12.0.rc0.151.g8a5726c42288
Bowers
PATCH 3/11 i40e: rework exit flow of i40e_add_fdir_ethtool
Quoted 14 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Monday, February 6, 2017 2:39 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [PART1 PATCH 03/11] i40e: rework exit flow ofi40e_add_fdir_ethtoolRefactor the exit flow of the
i40e_add_fdir_ethtoolfunction. Move theinput_labelto the end of the function, removing the dependency on having a non-zero return value. Add a comment explaining why it is ok not to free the fdir data structure, because the structure is now stored in thefdir_filter_list.
Quoted 5 lines
Signed-off-by Jacob Keller <[email protected]>Change-Id I723342181d59cd0c9f3b31140c37961ba37bb242--- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
PATCH 4/11 i40e: return immediately when failing to add fdir filter
In reply to Jacob KellerInstead of setting err=true and checking this to determine when to free the raw_packet near the end of the function, simply kfree and return immediately. The resulting code is a bit cleaner and has one less variable. This also resolves a subtle bug in the ipv4 case which could fail to add the first filter and then never free the memory, resulting in a small memory leak.
--- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 33 ++++++++++++----------------- 1 file changed, 14 insertions(+), 19 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_txrx.c +14 -19
@@ -204,7 +204,6 @@ static int i40e_add_del_fdir_udpv4(struct i40e_vsi *vsi,struct i40e_pf *pf = vsi->back;struct udphdr *udp;struct iphdr *ip; -bool err = false;u8 *raw_packet;int ret;static char packet[] = {0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x08 ,0 ,
@@ -231,7 +230,9 @@ static int i40e_add_del_fdir_udpv4(struct i40e_vsi *vsi,dev_info (&pf->pdev->dev,"PCTYPE:%d, Filter command send failed for fd_id:%d (ret = %d)\n" , fd_data->pctype, fd_data->fd_id, ret); - err = true; +/* Free the packet buffer since it wasn't added to the ring */ +kfree (raw_packet); +return -EOPNOTSUPP ; }else if (I40E_DEBUG_FD & pf->hw.debug_mask) {if (add) dev_info(&pf->pdev->dev,
@@ -242,10 +243,8 @@ static int i40e_add_del_fdir_udpv4(struct i40e_vsi *vsi,"Filter deleted for PCTYPE %d loc = %d\n" , fd_data->pctype, fd_data->fd_id); } -if (err) -kfree (raw_packet); -return err ? -EOPNOTSUPP :0 ; +return 0 ; }#define I40E_TCPIP_DUMMY_PACKET_LEN 54
@@ -264,7 +263,6 @@ static int i40e_add_del_fdir_tcpv4(struct i40e_vsi *vsi,struct i40e_pf *pf = vsi->back;struct tcphdr *tcp;struct iphdr *ip; -bool err = false;u8 *raw_packet;int ret;/* Dummy packet */
@@ -306,12 +304,13 @@ static int i40e_add_del_fdir_tcpv4(struct i40e_vsi *vsi, fd_data->pctype =I40E_FILTER_PCTYPE_NONF_IPV4_TCP ; ret =i40e_program_fdir_filter (fd_data, raw_packet, pf, add); -if (ret) {dev_info (&pf->pdev->dev,"PCTYPE:%d, Filter command send failed for fd_id:%d (ret = %d)\n" , fd_data->pctype, fd_data->fd_id, ret); - err = true; +/* Free the packet buffer since it wasn't added to the ring */ +kfree (raw_packet); +return -EOPNOTSUPP ; }else if (I40E_DEBUG_FD & pf->hw.debug_mask) {if (add) dev_info(&pf->pdev->dev, "Filter OK for PCTYPE %d loc = %d)\n",
@@ -322,10 +321,7 @@ static int i40e_add_del_fdir_tcpv4(struct i40e_vsi *vsi, fd_data->pctype, fd_data->fd_id); } -if (err) -kfree (raw_packet); - -return err ? -EOPNOTSUPP :0 ; +return 0 ; }#define I40E_IP_DUMMY_PACKET_LEN 34
@@ -344,7 +340,6 @@ static int i40e_add_del_fdir_ipv4(struct i40e_vsi *vsi, {struct i40e_pf *pf = vsi->back;struct iphdr *ip; -bool err = false;u8 *raw_packet;int ret;int i;
@@ -366,12 +361,15 @@ static int i40e_add_del_fdir_ipv4(struct i40e_vsi *vsi, fd_data->pctype = i; ret =i40e_program_fdir_filter (fd_data, raw_packet, pf, add); -if (ret) {dev_info (&pf->pdev->dev,"PCTYPE:%d, Filter command send failed for fd_id:%d (ret = %d)\n" , fd_data->pctype, fd_data->fd_id, ret); - err = true; +/* The packet buffer wasn't added to the ring so we +* need to free it now. +*/ +kfree (raw_packet); +return -EOPNOTSUPP ; }else if (I40E_DEBUG_FD & pf->hw.debug_mask) {if (add) dev_info(&pf->pdev->dev,
@@ -384,10 +382,7 @@ static int i40e_add_del_fdir_ipv4(struct i40e_vsi *vsi, } } -if (err) -kfree (raw_packet); - -return err ? -EOPNOTSUPP :0 ; +return 0 ; }/**
Signature · 1 line
2.12.0.rc0.151.g8a5726c42288
Bowers
PATCH 4/11 i40e: return immediately when failing to add fdir filter
Quoted 19 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Monday, February 6, 2017 2:39 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [PART1 PATCH 04/11] i40e: return immediately when failing to add fdir filterInstead of setting err=true and checking this to determine when to free the
raw_packetnear the end of the function, simply kfree and return immediately. The resulting code is a bit cleaner and has one less variable. This also resolves a subtle bug in the ipv4 case which could fail to add the first filter and then never free the memory, resulting in a small memory leak.Signed-off-by Jacob Keller <[email protected]>Reviewed-by Dayanand, Avinash <[email protected]>Reviewed-by Brady, Alan <[email protected]>Reviewed-by Williams, Mitch A <[email protected]>Change-ID I7583aac033481dc794b4acaa14445059c8930ff1
Quoted 4 lines
--- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 33 ++++++++++++-------------- --- 1 file changed, 14 insertions(+), 19 deletions(-)
PATCH 5/11 i40e: exit ATR mode only when adding TCP/IPv4 filter succeeds
In reply to Jacob KellerMove ATR exit check after we have sent the TCP/IPv4 filter to the ring successfully. This avoids an issue where we potentially update the filter count without actually succeeding in adding the filter. Now, we only increment the fd_tcp_rule after we've succeeded. Additionally, we will re-enable ATR mode only after deletion of the filter is actually posted to the FDIR ring.
--- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 34 ++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_txrx.c +17 -17
@@ -285,23 +285,6 @@ static int i40e_add_del_fdir_tcpv4(struct i40e_vsi *vsi, ip->saddr = fd_data->src_ip; tcp->source = fd_data->src_port; -if (add) { - pf->fd_tcp_rule++; -if ((pf->flags &I40E_FLAG_FD_ATR_ENABLED ) && -I40E_DEBUG_FD & pf->hw.debug_mask) -dev_info (&pf->pdev->dev,"Forcing ATR off, sideband rules for TCP/IPv4 flow being applied\n" ); - pf->auto_disable_flags |=I40E_FLAG_FD_ATR_ENABLED ; - }else { - pf->fd_tcp_rule = (pf->fd_tcp_rule >0 ) ? - (pf->fd_tcp_rule -1 ) :0 ; -if (pf->fd_tcp_rule ==0 ) { -if ((pf->flags &I40E_FLAG_FD_ATR_ENABLED ) && -I40E_DEBUG_FD & pf->hw.debug_mask) -dev_info (&pf->pdev->dev,"ATR re-enabled due to no sideband TCP/IPv4 rules\n" ); - pf->auto_disable_flags &= ~I40E_FLAG_FD_ATR_ENABLED ; - } - } - fd_data->pctype =I40E_FILTER_PCTYPE_NONF_IPV4_TCP ; ret =i40e_program_fdir_filter (fd_data, raw_packet, pf, add);if (ret) {
@@ -321,6 +304,23 @@ static int i40e_add_del_fdir_tcpv4(struct i40e_vsi *vsi, fd_data->pctype, fd_data->fd_id); } +if (add) { + pf->fd_tcp_rule++; +if ((pf->flags &I40E_FLAG_FD_ATR_ENABLED ) && +I40E_DEBUG_FD & pf->hw.debug_mask) +dev_info (&pf->pdev->dev,"Forcing ATR off, sideband rules for TCP/IPv4 flow being applied\n" ); + pf->auto_disable_flags |=I40E_FLAG_FD_ATR_ENABLED ; + }else { + pf->fd_tcp_rule = (pf->fd_tcp_rule >0 ) ? + (pf->fd_tcp_rule -1 ) :0 ; +if (pf->fd_tcp_rule ==0 ) { +if ((pf->flags &I40E_FLAG_FD_ATR_ENABLED ) && +I40E_DEBUG_FD & pf->hw.debug_mask) +dev_info (&pf->pdev->dev,"ATR re-enabled due to no sideband TCP/IPv4 rules\n" ); + pf->auto_disable_flags &= ~I40E_FLAG_FD_ATR_ENABLED ; + } + } +return 0 ; }
Signature · 1 line
2.12.0.rc0.151.g8a5726c42288
Bowers
PATCH 5/11 i40e: exit ATR mode only when adding TCP/IPv4 filter succeeds
Quoted 15 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Monday, February 6, 2017 2:39 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [PART1 PATCH 05/11] i40e: exit ATR mode only when adding TCP/IPv4 filter succeedsMove ATR exit check after we have sent the TCP/IPv4 filter to the ring successfully. This avoids an issue where we potentially update the filter count without actually succeeding in adding the filter. Now, we only increment the
fd_tcp_ruleafter we've succeeded. Additionally, we will re- enable ATR mode only after deletion of the filter is actually posted to the FDIR ring.
Quoted 7 lines
Signed-off-by Jacob Keller <[email protected]>Reviewed-by Williams, Mitch A <[email protected]>Change-ID If5c1dea422081cc5e2de65618b01b4c3bf6bd586--- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 34 ++++++++++++++----------- ---- 1 file changed, 17 insertions(+), 17 deletions(-)
PATCH 6/11 i40e: remove redundant check for fd_tcp_rule when restoring filters
In reply to Jacob Kelleri40e_fdir_filter_restore re-adds all existing filters, which already checks when adding a TCPv4 filter to disable ATR. We don't need to make the check twice, so remove this redundant code.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +0 -6
@@ -5608,12 +5608,6 @@ static int i40e_up_complete(struct i40e_vsi *vsi)if (vsi->type ==I40E_VSI_FDIR ) {/* reset fd counters */ pf->fd_add_err = pf->fd_atr_cnt =0 ; -if (pf->fd_tcp_rule >0 ) { - pf->auto_disable_flags |=I40E_FLAG_FD_ATR_ENABLED ; -if (I40E_DEBUG_FD & pf->hw.debug_mask) -dev_info (&pf->pdev->dev,"Forcing ATR off, sideband rules for TCP/IPv4 exist\n" ); - pf->fd_tcp_rule =0 ; - }i40e_fdir_filter_restore (vsi); }
Signature · 1 line
2.12.0.rc0.151.g8a5726c42288
Bowers
PATCH 6/11 i40e: remove redundant check for fd_tcp_rule when restoring filters
Quoted 12 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Monday, February 6, 2017 2:39 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [PART1 PATCH 06/11] i40e: remove redundant check forfd_tcp_rulewhen restoring filters
i40e_fdir_filter_restorere-adds all existing filters, which already checks when adding a TCPv4 filter to disable ATR. We don't need to make the check twice, so remove this redundant code.
Quoted 5 lines
Signed-off-by Jacob Keller <[email protected]>Change-ID Ia0b0690e23523915199d601494557def135c9d7f--- drivers/net/ethernet/intel/i40e/i40e_main.c | 6 ------ 1 file changed, 6 deletions(-)
PATCH 7/11 i40e: reset fd_tcp_rule count when restoring filters
In reply to Jacob KellerSince we're about to reprogram the filters, we need to ensure that the fd_tcp_rule count is correctly reset to 0. Otherwise, we will keep a stale count that does not accurately reflect the number of programmed TCPv4 filters.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_main.c +3 -0
@@ -3320,6 +3320,9 @@ static void i40e_fdir_filter_restore(struct i40e_vsi *vsi)if (!(pf->flags &I40E_FLAG_FD_SB_ENABLED ))return ; +/* Reset FDir counters as we're replaying all existing filters */ + pf->fd_tcp_rule =0 ; +hlist_for_each_entry_safe (filter, node, &pf->fdir_filter_list, fdir_node) {i40e_add_del_fdir (vsi, filter, true);
Signature · 1 line
2.12.0.rc0.151.g8a5726c42288
Bowers
PATCH 7/11 i40e: reset fd_tcp_rule count when restoring filters
Quoted 13 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Monday, February 6, 2017 2:39 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [PART1 PATCH 07/11] i40e: resetfd_tcp_rulecount when restoring filtersSince we're about to reprogram the filters, we need to ensure that the
fd_tcp_rulecount is correctly reset to 0. Otherwise, we will keep a stale count that does not accurately reflect the number of programmed TCPv4 filters.
Quoted 4 lines
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_main.c | 3 +++ 1 file changed, 3 insertions(+)
PATCH 8/11 i40e: don't re-enable ATR when flushing filters if SB has TCP4/IPv4 rules
In reply to Jacob KellerWhen flushing and replaying FDIR filters, it is possible we would disable ATR, and then re-enable it even though we should have kept it disabled due to existing TCP/IPv4 filters. Fix this by checking whether we have TCP4/IPv4 filters before re-enabling.
Alternatively, we could instead restore ATR and then replay filters, however, this would cause us to rapidly enable and then disable ATR in some cases.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
@@ -6369,7 +6369,7 @@ static void i40e_fdir_flush_and_replay(struct i40e_pf *pf) }else {/* replay sideband filters */ i40e_fdir_filter_restore (pf->vsi[pf->lan_vsi]); -if (!disable_atr) +if (!disable_atr && !pf->fd_tcp_rule) pf->auto_disable_flags &= ~I40E_FLAG_FD_ATR_ENABLED ;clear_bit (__I40E_FD_FLUSH_REQUESTED, &pf->state);if (I40E_DEBUG_FD & pf->hw.debug_mask)
Signature · 1 line
2.12.0.rc0.151.g8a5726c42288
Bowers
PATCH 8/11 i40e: don't re-enable ATR when flushing filters if SB has TCP4/IPv4 rules
Quoted 16 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Monday, February 6, 2017 2:39 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [PART1 PATCH 08/11] i40e: don't re-enable ATR when flushing filters if SB has TCP4/IPv4 rulesWhen flushing and replaying FDIR filters, it is possible we would disable ATR, and then re-enable it even though we should have kept it disabled due to existing TCP/IPv4 filters. Fix this by checking whether we have TCP4/IPv4 filters before re-enabling.
Alternatively, we could instead restore ATR and then replay filters, however, this would cause us to rapidly enable and then disable ATR in some cases.
Quoted 8 lines
Signed-off-by Jacob Keller <[email protected]>Reviewed-by Dayanand, Avinash <[email protected]>Reviewed-by Brady, Alan <[email protected]>Reviewed-by Williams, Mitch A <[email protected]>Change-ID I076e4cc1e4409bce7f98f3c213295433a4ff43d8--- drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH 9/11 i40e: add counters for UDP/IPv4 and IPv4 filters
In reply to Jacob KellerIn preparation for adding code to properly check the mask values, we will need to know the number of active filters for each type. Add counters for each filter type. Rename the already existing fd_tcp_rule to fd_tcp4_filter_cnt to match the style of other names. To avoid style warnings, avoid assigning multiple parameters at once, and fix up one other case where we did so previously.
--- drivers/net/ethernet/intel/i40e/i40e.h | 9 ++++++++- drivers/net/ethernet/intel/i40e/i40e_main.c | 19 +++++++++++++------ drivers/net/ethernet/intel/i40e/i40e_txrx.c | 17 +++++++++++++---- 3 files changed, 34 insertions(+), 11 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +8 -1
@@ -290,7 +290,14 @@ struct i40e_pf {u32 fd_flush_cnt;u32 fd_add_err;u32 fd_atr_cnt; -u32 fd_tcp_rule; + +/* Book-keeping of side-band filter count per flow-type. +* This is used to detect and handle input set changes for +* respective flow-type. +*/ +u16 fd_tcp4_filter_cnt; +u16 fd_udp4_filter_cnt; +u16 fd_ip4_filter_cnt;struct i40e_udp_port_config udp_ports[I40E_MAX_PF_UDP_OFFLOAD_PORTS ];u16 pending_udp_bitmap;
drivers/net/ethernet/intel/i40e/i40e_main.c +13 -6
@@ -3321,7 +3321,9 @@ static void i40e_fdir_filter_restore(struct i40e_vsi *vsi)return ;/* Reset FDir counters as we're replaying all existing filters */ - pf->fd_tcp_rule =0 ; + pf->fd_tcp4_filter_cnt =0 ; + pf->fd_udp4_filter_cnt =0 ; + pf->fd_ip4_filter_cnt =0 ;hlist_for_each_entry_safe (filter, node, &pf->fdir_filter_list, fdir_node) {
@@ -5610,7 +5612,8 @@ static int i40e_up_complete(struct i40e_vsi *vsi)/* replay FDIR SB filters */ if (vsi->type ==I40E_VSI_FDIR ) {/* reset fd counters */ - pf->fd_add_err = pf->fd_atr_cnt =0 ; + pf->fd_add_err =0 ; + pf->fd_atr_cnt =0 ;i40e_fdir_filter_restore (vsi); }
@@ -5892,7 +5895,11 @@ static void i40e_fdir_filter_exit(struct i40e_pf *pf)hlist_del (&filter->fdir_node);kfree (filter); } + pf->fdir_pf_active_filters =0 ; + pf->fd_tcp4_filter_cnt =0 ; + pf->fd_udp4_filter_cnt =0 ; + pf->fd_ip4_filter_cnt =0 ; }/**
@@ -6297,7 +6304,7 @@ void i40e_fdir_check_and_reenable(struct i40e_pf *pf)if (fcnt_prog < (fcnt_avail -I40E_FDIR_BUFFER_HEAD_ROOM *2 )) {if ((pf->flags &I40E_FLAG_FD_ATR_ENABLED ) && (pf->auto_disable_flags &I40E_FLAG_FD_ATR_ENABLED ) && - (pf->fd_tcp_rule ==0 )) { + (pf->fd_tcp4_filter_cnt ==0 )) { pf->auto_disable_flags &= ~I40E_FLAG_FD_ATR_ENABLED ;if (I40E_DEBUG_FD & pf->hw.debug_mask)dev_info (&pf->pdev->dev,"ATR is being enabled since we have space in the table and there are no conflicting ntuple rules\n" );
@@ -6369,7 +6376,7 @@ static void i40e_fdir_flush_and_replay(struct i40e_pf *pf) }else {/* replay sideband filters */ i40e_fdir_filter_restore (pf->vsi[pf->lan_vsi]); -if (!disable_atr && !pf->fd_tcp_rule) +if (!disable_atr && !pf->fd_tcp4_filter_cnt) pf->auto_disable_flags &= ~I40E_FLAG_FD_ATR_ENABLED ;clear_bit (__I40E_FD_FLUSH_REQUESTED, &pf->state);if (I40E_DEBUG_FD & pf->hw.debug_mask)
@@ -9124,8 +9131,8 @@ bool i40e_set_ntuple(struct i40e_pf *pf, netdev_features_t features) pf->flags &= ~I40E_FLAG_FD_SB_ENABLED ; pf->auto_disable_flags &= ~I40E_FLAG_FD_SB_ENABLED ;/* reset fd counters */ - pf->fd_add_err = pf->fd_atr_cnt = pf->fd_tcp_rule =0 ; - pf->fdir_pf_active_filters =0 ; + pf->fd_add_err =0 ; + pf->fd_atr_cnt =0 ;/* if ATR was auto disabled it can be re-enabled. */ if ((pf->flags &I40E_FLAG_FD_ATR_ENABLED ) && (pf->auto_disable_flags &I40E_FLAG_FD_ATR_ENABLED )) {
drivers/net/ethernet/intel/i40e/i40e_txrx.c +13 -4
@@ -244,6 +244,11 @@ static int i40e_add_del_fdir_udpv4(struct i40e_vsi *vsi, fd_data->pctype, fd_data->fd_id); } +if (add) + pf->fd_udp4_filter_cnt++; +else + pf->fd_udp4_filter_cnt--; +return 0 ; }
@@ -305,15 +310,14 @@ static int i40e_add_del_fdir_tcpv4(struct i40e_vsi *vsi, }if (add) { - pf->fd_tcp_rule++; + pf->fd_tcp4_filter_cnt++;if ((pf->flags &I40E_FLAG_FD_ATR_ENABLED ) &&I40E_DEBUG_FD & pf->hw.debug_mask)dev_info (&pf->pdev->dev,"Forcing ATR off, sideband rules for TCP/IPv4 flow being applied\n" ); pf->auto_disable_flags |=I40E_FLAG_FD_ATR_ENABLED ; }else { - pf->fd_tcp_rule = (pf->fd_tcp_rule >0 ) ? - (pf->fd_tcp_rule -1 ) :0 ; -if (pf->fd_tcp_rule ==0 ) { + pf->fd_tcp4_filter_cnt--; +if (pf->fd_tcp4_filter_cnt ==0 ) {if ((pf->flags &I40E_FLAG_FD_ATR_ENABLED ) &&I40E_DEBUG_FD & pf->hw.debug_mask)dev_info (&pf->pdev->dev,"ATR re-enabled due to no sideband TCP/IPv4 rules\n" );
@@ -382,6 +386,11 @@ static int i40e_add_del_fdir_ipv4(struct i40e_vsi *vsi, } } +if (add) + pf->fd_ip4_filter_cnt++; +else + pf->fd_ip4_filter_cnt--; +return 0 ; }
Signature · 1 line
2.12.0.rc0.151.g8a5726c42288
Bowers
PATCH 9/11 i40e: add counters for UDP/IPv4 and IPv4 filters
Quoted 15 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Monday, February 6, 2017 2:39 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [PART1 PATCH 09/11] i40e: add counters for UDP/IPv4 and IPv4 filtersIn preparation for adding code to properly check the mask values, we will need to know the number of active filters for each type. Add counters for each filter type. Rename the already existing
fd_tcp_ruletofd_tcp4_filter_cntto match the style of other names. To avoid style warnings, avoid assigning multiple parameters at once, and fix up one other case where we did so previously.
Quoted 6 lines
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e.h | 9 ++++++++- drivers/net/ethernet/intel/i40e/i40e_main.c | 19 +++++++++++++------ drivers/net/ethernet/intel/i40e/i40e_txrx.c | 17 +++++++++++++---- 3 files changed, 34 insertions(+), 11 deletions(-)