ice: fix FDir IPv6 flexbyte
Subsystems (2)
Tony Nguyen
maintainerPATCH 1/6 ice: fix FDir IPv6 flexbyte
From: Henry Tieman <[email protected]>
The packet classifier would occasionally misrecognize an IPv6 training packet when the next protocol field was 0. The correct value for unspecified protocol is IPPROTO_NONE.
--- drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c +7 -1
@@ -1576,7 +1576,13 @@ ice_set_fdir_input_set(struct ice_vsi *vsi, struct ethtool_rx_flow_spec *fsp, sizeof(struct in6_addr)); input->ip.v6.l4_header = fsp->h_u.usr_ip6_spec.l4_4_bytes; input->ip.v6.tc = fsp->h_u.usr_ip6_spec.tclass; - input->ip.v6.proto = fsp->h_u.usr_ip6_spec.l4_proto; + +/* if no protocol requested, use IPPROTO_NONE */ +if (!fsp->m_u.usr_ip6_spec.l4_proto) + input->ip.v6.proto =IPPROTO_NONE ; +else + input->ip.v6.proto = fsp->h_u.usr_ip6_spec.l4_proto; +memcpy (input->mask.v6.dst_ip, fsp->m_u.usr_ip6_spec.ip6dst,sizeof (struct in6_addr )); memcpy(input->mask.v6.src_ip, fsp->m_u.usr_ip6_spec.ip6src,
Signature · 1 line
2.20.1
Tony Nguyen
maintainerPATCH 2/6 ice: Implement flow for IPv6 next header (extension header)
From: Nick Nunley <[email protected]>
This patch is based on a similar change to i40e by Slawomir Laba:
"i40e: Implement flow for IPv6 next header (extension header)".
When a packet contains an IPv6 header with next header which is an extension header and not a protocol one, the kernel function skb_transport_header called with such sk_buff will return a pointer to the extension header and not to the TCP one.
The above explained call caused a problem with packet processing for skb with encapsulation for tunnel with ICE_TX_CTX_EIPT_IPV6. The extension header was not skipped at all.
The ipv6_skip_exthdr function does check if next header of the IPV6 header is an extension header and doesn't modify the l4_proto pointer if it points to a protocol header value so its safe to omit the comparison of exthdr and l4.hdr pointers. The ipv6_skip_exthdr can return value -1. This means that the skipping process failed and there is something wrong with the packet so it will be dropped.
--- drivers/net/ethernet/intel/ice/ice_txrx.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/ice/ice_txrx.c +6 -3
@@ -1922,12 +1922,15 @@ int ice_tx_csum(struct ice_tx_buf *first, struct ice_tx_offload_params *off)ICE_TX_CTX_EIPT_IPV4_NO_CSUM ; l4_proto = ip.v4->protocol; }else if (first->tx_flags &ICE_TX_FLAGS_IPV6 ) { +int ret; + tunnel |=ICE_TX_CTX_EIPT_IPV6 ; exthdr = ip.hdr +sizeof (*ip.v6); l4_proto = ip.v6->nexthdr; -if (l4.hdr != exthdr) -ipv6_skip_exthdr (skb, exthdr - skb->data, - &l4_proto, &frag_off); + ret =ipv6_skip_exthdr (skb, exthdr - skb->data, + &l4_proto, &frag_off); +if (ret <0 ) +return -1 ; }/* define outer transport */
Signature · 1 line
2.20.1
Tony Nguyen
maintainerPATCH 3/6 ice: update the number of available RSS queues
In reply to Tony NguyenFrom: Henry Tieman <[email protected]>
It was possible to have Rx queues that were not available for use by RSS. This would happen when increasing the number of Rx queues while there was a user defined RSS LUT.
Always update the number of available RSS queues when changing the number of Rx queues.
--- drivers/net/ethernet/intel/ice/ice_ethtool.c | 31 ++++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/ice/ice_ethtool.c +22 -9
@@ -3321,6 +3321,18 @@ ice_get_channels(struct net_device *dev, struct ethtool_channels *ch) ch->max_other = ch->other_count; } +/** +* ice_get_valid_rss_size - return valid number of RSS queues +* @hw: pointer to the HW structure +* @new_size: requested RSS queues +*/ +static int ice_get_valid_rss_size (struct ice_hw *hw,int new_size) +{ +struct ice_hw_common_caps *caps = &hw->func_caps.common_cap; + +return min_t (int, new_size,BIT (caps->rss_table_entry_width)); +} +/** * ice_vsi_set_dflt_rss_lut - set default RSS LUT with requested RSS size * @vsi: VSI to reconfigure RSS LUT on
@@ -3348,14 +3360,10 @@ static int ice_vsi_set_dflt_rss_lut(struct ice_vsi *vsi, int req_rss_size)return -ENOMEM ;/* set RSS LUT parameters */ -if (!test_bit (ICE_FLAG_RSS_ENA , pf->flags)) { +if (!test_bit (ICE_FLAG_RSS_ENA , pf->flags)) vsi->rss_size =1 ; - }else { -struct ice_hw_common_caps *caps = &hw->func_caps.common_cap; - - vsi->rss_size =min_t (int, req_rss_size, -BIT (caps->rss_table_entry_width)); - } +else + vsi->rss_size =ice_get_valid_rss_size (hw, req_rss_size);/* create/set RSS LUT */ ice_fill_rss_lut (lut, vsi->rss_table_size, vsi->rss_size);
@@ -3434,8 +3442,13 @@ static int ice_set_channels(struct net_device *dev, struct ethtool_channels *ch)ice_vsi_recfg_qs (vsi, new_rx, new_tx); -if (new_rx && !netif_is_rxfh_configured (dev)) -return ice_vsi_set_dflt_rss_lut (vsi, new_rx); +if (new_rx) { +if (!netif_is_rxfh_configured (dev)) +return ice_vsi_set_dflt_rss_lut (vsi, new_rx); + +/* Update rss_size due to change in Rx queues */ + vsi->rss_size =ice_get_valid_rss_size (&pf->hw, new_rx); + }return 0 ; }
Signature · 1 line
2.20.1
PATCH 3/6 ice: update the number of available RSS queues
Dear Henry, dear Tony,
Am 21.11.20 um 01:38 schrieb Tony Nguyen:
Quoted 59 lines
From: Henry Tieman <[email protected]>
It was possible to have Rx queues that were not available for use by RSS. This would happen when increasing the number of Rx queues while there was a user defined RSS LUT.
Always update the number of available RSS queues when changing the number of Rx queues.
Fixes 87324e747fde ("ice: Implement ethtool ops for channels")Signed-off-by Henry Tieman <[email protected]>--- drivers/net/ethernet/intel/ice/ice_ethtool.c | 31 ++++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-)drivers/net/ethernet/intel/ice/ice_ethtool.c +15
-7@@ -3321,6 +3321,18 @@ ice_get_channels(struct net_device *dev, struct ethtool_channels *ch) ch->max_other = ch->other_count; } +/** +* ice_get_valid_rss_size - return valid number of RSS queues +* @hw: pointer to the HW structure +* @new_size: requested RSS queues +*/ +static int ice_get_valid_rss_size (struct ice_hw *hw,int new_size) +{ +struct ice_hw_common_caps *caps = &hw->func_caps.common_cap; + +return min_t (int, new_size,BIT (caps->rss_table_entry_width)); +} +/** * ice_vsi_set_dflt_rss_lut - set default RSS LUT with requested RSS size * @vsi: VSI to reconfigure RSS LUT on @@ -3348,14 +3360,10 @@ static int ice_vsi_set_dflt_rss_lut(struct ice_vsi *vsi, int req_rss_size)return -ENOMEM ;/* set RSS LUT parameters */ -if (!test_bit (ICE_FLAG_RSS_ENA , pf->flags)) { +if (!test_bit (ICE_FLAG_RSS_ENA , pf->flags)) vsi->rss_size =1 ; - }else { -struct ice_hw_common_caps *caps = &hw->func_caps.common_cap; - - vsi->rss_size =min_t (int, req_rss_size, -BIT (caps->rss_table_entry_width)); - } +else + vsi->rss_size =ice_get_valid_rss_size (hw, req_rss_size);/* create/set RSS LUT */ ice_fill_rss_lut (lut, vsi->rss_table_size, vsi->rss_size);@@ -3434,8 +3442,13 @@ static int ice_set_channels(struct net_device *dev, struct ethtool_channels *ch)ice_vsi_recfg_qs (vsi, new_rx, new_tx);
drivers/net/ethernet/intel/ice/ice_ethtool.c static int ice_set_channels(struct net_device *dev, struct ethtool_channels *ch) · line 3451
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_ethtool.c +7
-2-if (new_rx && !netif_is_rxfh_configured (dev)) -return ice_vsi_set_dflt_rss_lut (vsi, new_rx); +if (new_rx) { +if (!netif_is_rxfh_configured (dev)) +return ice_vsi_set_dflt_rss_lut (vsi, new_rx); + +/* Update rss_size due to change in Rx queues */ + vsi->rss_size =ice_get_valid_rss_size (&pf->hw, new_rx); + }
Why not unconditionally call
vsi->rss_size = ice_get_valid_rss_size(&pf->hw, new_rx);
as the function handles the case new_rx = 0, right?
ice_vsi_recfg_qs(vsi, new_rx, new_tx); also does not check new_tx for example.
drivers/net/ethernet/intel/ice/ice_ethtool.c static int ice_set_channels(struct net_device *dev, struct ethtool_channels *ch) · line 3454
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_ethtool.c +0
-0return 0 ; }
Kind regards,
Paul
Nguyen
PATCH 3/6 ice: update the number of available RSS queues
Quoted 86 lines · Paul Menzel
Dear Henry, dear Tony,
Am 21.11.20 um 01:38 schrieb Tony Nguyen:
Quoted 69 lines
From: Henry Tieman <[email protected]>
It was possible to have Rx queues that were not available for use by RSS. This would happen when increasing the number of Rx queues while there was a user defined RSS LUT.
Always update the number of available RSS queues when changing the number of Rx queues.
Fixes 87324e747fde ("ice: Implement ethtool ops for channels")Signed-off-by Henry Tieman <[email protected]>--- drivers/net/ethernet/intel/ice/ice_ethtool.c | 31 ++++++++++++++- ----- 1 file changed, 22 insertions(+), 9 deletions(-)drivers/net/ethernet/intel/ice/ice_ethtool.c +12
-0@@ -3321,6 +3321,18 @@ ice_get_channels(struct net_device *dev, struct ethtool_channels *ch) ch->max_other = ch->other_count; } +/** +* ice_get_valid_rss_size - return valid number of RSS queues +* @hw: pointer to the HW structure +* @new_size: requested RSS queues +*/ +static int ice_get_valid_rss_size (struct ice_hw *hw,int new_size) +{ +struct ice_hw_common_caps *caps = &hw->func_caps.common_cap; + +return min_t (int, new_size,BIT (caps->rss_table_entry_width)); +} +/** * ice_vsi_set_dflt_rss_lut - set default RSS LUT with requested RSS size
* @vsi: VSI to reconfigure RSS LUT ondrivers/net/ethernet/intel/ice/ice_ethtool.c +3
-7@@ -3348,14 +3360,10 @@ static int ice_vsi_set_dflt_rss_lut(struct ice_vsi *vsi, int req_rss_size) return -ENOMEM;/* set RSS LUT parameters */ -if (!test_bit (ICE_FLAG_RSS_ENA , pf->flags)) { +if (!test_bit (ICE_FLAG_RSS_ENA , pf->flags)) vsi->rss_size =1 ; - }else { -struct ice_hw_common_caps *caps = &hw- >func_caps.common_cap; - - vsi->rss_size =min_t (int, req_rss_size, -BIT (caps- >rss_table_entry_width)); - } + else + vsi->rss_size = ice_get_valid_rss_size(hw,
req_rss_size);/* create/set RSS LUT */ ice_fill_rss_lut(lut, vsi->rss_table_size, vsi->rss_size);drivers/net/ethernet/intel/ice/ice_ethtool.c +0
-0@@ -3434,8 +3442,13 @@ static int ice_set_channels(struct net_device *dev, struct ethtool_channels *ch)ice_vsi_recfg_qs (vsi ,new_rx ,new_tx );drivers/net/ethernet/intel/ice/ice_ethtool.c static int ice_set_channels(struct · line 3453
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_ethtool.c +7
-2-if (new_rx && !netif_is_rxfh_configured (dev)) -return ice_vsi_set_dflt_rss_lut (vsi, new_rx); +if (new_rx) { +if (!netif_is_rxfh_configured (dev)) +return ice_vsi_set_dflt_rss_lut (vsi, new_rx); + +/* Update rss_size due to change in Rx queues */ + vsi->rss_size =ice_get_valid_rss_size (&pf->hw, new_rx); + }Why not unconditionally call
Quoted 3 lines
vsi->rss_size = ice_get_valid_rss_size(&pf->hw, new_rx);as the function handles the case
new_rx = 0, right?
Yea, that's right. I will update.
Thanks,
Tony
Tony Nguyen
maintainerPATCH 4/6 ice: update dev_addr in ice_set_mac_address even if HW filter exists
In reply to Tony NguyenFrom: Nick Nunley <[email protected]>
Fix the driver to copy the MAC address configured in ndo_set_mac_address into dev_addr, even if the MAC filter already exists in HW. In some situations (e.g. bonding) the netdev's dev_addr could have been modified outside of the driver, with no change to the HW filter, so the driver cannot assume that they match.
--- drivers/net/ethernet/intel/ice/ice_main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_main.c +7 -1
@@ -4887,9 +4887,15 @@ static int ice_set_mac_address(struct net_device *netdev, void *pi) goto err_update_filters; } -/* Add filter for new MAC. If filter exists, just return success */ +/* Add filter for new MAC. If filter exists, return success */ status =ice_fltr_add_mac (vsi, mac,ICE_FWD_TO_VSI );if (status ==ICE_ERR_ALREADY_EXISTS ) { +/* Although this MAC filter is already present in hardware it's +* possible in some cases (e.g. bonding) that dev_addr was +* modified outside of the driver and needs to be restored back +* to this value. +*/ +memcpy (netdev->dev_addr, mac, netdev->addr_len);netdev_dbg (netdev,"filter for MAC %pM already exists\n" , mac);return 0 ; }
Signature · 1 line
2.20.1
Tony Nguyen
maintainerPATCH 5/6 ice: use correct xdp_ring with XDP_TX action
In reply to Tony NguyenFrom: Piotr Raczynski <[email protected]>
XDP queue number for XDP_TX action is used inconsistently and may result with no packets transmitted. Fix queue number used by the driver when doing XDP_TX, i.e. use receive queue number as in ice_finalize_xdp_rx.
Also, using smp_processor_id() is wrong here and won't work with less queues.
--- drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_txrx.c +1 -1
@@ -546,7 +546,7 @@ ice_run_xdp(struct ice_ring *rx_ring, struct xdp_buff *xdp,case XDP_PASS :break ;case XDP_TX : - xdp_ring = rx_ring->vsi->xdp_rings[smp_processor_id ()]; + xdp_ring = rx_ring->vsi->xdp_rings[rx_ring->q_index]; result =ice_xmit_xdp_buff (xdp, xdp_ring);break ;case XDP_REDIRECT :
Signature · 1 line
2.20.1
Kuruvinakunnel
PATCH 5/6 ice: use correct xdp_ring with XDP_TX action
Quoted 12 lines
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Saturday, November 21, 2020 6:09 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [net 5/6] ice: use correctxdp_ringwithXDP_TXactionFrom: Piotr Raczynski <[email protected]>
XDP queue number for
XDP_TXaction is used inconsistently and may result with no packets transmitted. Fix queue number used by the driver when doingXDP_TX, i.e. use receive queue number as inice_finalize_xdp_rx.
Quoted 8 lines
Also, using
smp_processor_id()is wrong here and won't work with less queues.Fixes efc2214b6047 ("ice: Add support for XDP")Signed-off-by Piotr Raczynski <[email protected]>--- drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Tony Nguyen
maintainerPATCH 6/6 ice: Fix state bits on LLDP mode switch
In reply to Tony NguyenFrom: Dave Ertman <[email protected]>
DCBX_CAP bits were not being adjusted when switching between SW and FW controlled LLDP.
Adjust bits to correctly indicate which mode the LLDP logic is in.
--- drivers/net/ethernet/intel/ice/ice.h | 2 -- drivers/net/ethernet/intel/ice/ice_dcb_nl.c | 4 ++++ drivers/net/ethernet/intel/ice/ice_ethtool.c | 7 +++++++ 3 files changed, 11 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +0 -2
@@ -442,9 +442,7 @@ struct ice_pf {struct ice_hw_port_stats stats_prev;struct ice_hw hw; u8 stat_prev_loaded:1; /* has previous stats been loaded */ -#ifdef CONFIG_DCB u16 dcbx_cap; -#endif /* CONFIG_DCB */ u32 tx_timeout_count;unsigned long tx_timeout_last_recovery;u32 tx_timeout_recovery_level;
drivers/net/ethernet/intel/ice/ice_dcb_nl.c +4 -0
@@ -160,6 +160,10 @@ static u8 ice_dcbnl_setdcbx(struct net_device *netdev, u8 mode) {struct ice_pf *pf =ice_netdev_to_pf (netdev); +/* if FW LLDP agent is running, DCBNL not allowed to change mode */ +if (test_bit (ICE_FLAG_FW_LLDP_AGENT , pf->flags)) +return ICE_DCB_NO_HW_CHG ; +/* No support for LLD_MANAGED modes or CEE+IEEE */ if ((mode & DCB_CAP_DCBX_LLD_MANAGED) || ((mode & DCB_CAP_DCBX_VER_IEEE) && (mode & DCB_CAP_DCBX_VER_CEE)) ||
drivers/net/ethernet/intel/ice/ice_ethtool.c +7 -0
@@ -8,6 +8,7 @@#include "ice_fltr.h" #include "ice_lib.h" #include "ice_dcb_lib.h" +#include <net/dcbnl.h> struct ice_stats {char stat_string[ETH_GSTRING_LEN ];
@@ -1238,6 +1239,9 @@ static int ice_set_priv_flags(struct net_device *netdev, u32 flags) status =ice_init_pf_dcb (pf, true);if (status)dev_warn (dev,"Fail to init DCB\n" ); + + pf->dcbx_cap &= ~DCB_CAP_DCBX_LLD_MANAGED ; + pf->dcbx_cap |=DCB_CAP_DCBX_HOST ; }else {enum ice_status status;bool dcbx_agent_status;
@@ -1280,6 +1284,9 @@ static int ice_set_priv_flags(struct net_device *netdev, u32 flags)if (status)dev_dbg (dev,"Fail to enable MIB change events\n" ); + pf->dcbx_cap &= ~DCB_CAP_DCBX_HOST ; + pf->dcbx_cap |=DCB_CAP_DCBX_LLD_MANAGED ; +ice_nway_reset (netdev); } }
Signature · 1 line
2.20.1
PATCH 1/6 ice: fix FDir IPv6 flexbyte
In reply to Tony NguyenDear Henry,
Am 21.11.20 um 01:38 schrieb Tony Nguyen:
Quoted 18 lines
From: Henry Tieman <[email protected]>
The packet classifier would occasionally misrecognize an IPv6 training packet when the next protocol field was 0. The correct value for unspecified protocol is
IPPROTO_NONE.Fixes 165d80d6adab ("ice: Support IPv6 Flow Director filters")Signed-off-by Henry Tieman <[email protected]>--- drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c +0
-0@@ -1576,7 +1576,13 @@ ice_set_fdir_input_set(struct ice_vsi *vsi, struct ethtool_rx_flow_spec *fsp, sizeof(struct in6_addr));
drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c ice_set_fdir_input_set(struct ice_vsi *vsi, struct ethtool_rx_flow_spec *fsp, · line 1585
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c +7
-1input->ip.v6.l4_header = fsp->h_u.usr_ip6_spec.l4_4_bytes; input->ip.v6.tc = fsp->h_u.usr_ip6_spec.tclass; - input->ip.v6.proto = fsp->h_u.usr_ip6_spec.l4_proto; + +/* if no protocol requested, use IPPROTO_NONE */ +if (!fsp->m_u.usr_ip6_spec.l4_proto) + input->ip.v6.proto =IPPROTO_NONE ; +else + input->ip.v6.proto = fsp->h_u.usr_ip6_spec.l4_proto; +
I prefer non-negation and the ternary operator, but it?s subjective.
input->ip.v6.proto = fsp->h_u.usr_ip6_spec.l4_proto ?
fsp->h_u.usr_ip6_spec.l4_proto : IPPROTO_NONE;
(GCC even has the extension a ?: b.)
drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c ice_set_fdir_input_set(struct ice_vsi *vsi, struct ethtool_rx_flow_spec *fsp, · line 1588
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c +0
-0memcpy (input->mask.v6.dst_ip, fsp->m_u.usr_ip6_spec.ip6dst,sizeof (struct in6_addr )); memcpy(input->mask.v6.src_ip, fsp->m_u.usr_ip6_spec.ip6src,
Kind regards,
Paul