diff mbox series

[v2,net-next,5/8] ionic: support ethtool rxhash disable

Message ID 20200304042013.51970-6-snelson@pensando.io
State Superseded
Delegated to: David Miller
Headers show
Series ionic updates | expand

Commit Message

Shannon Nelson March 4, 2020, 4:20 a.m. UTC
We can disable rxhashing by setting rss_types to 0.  The user
can toggle this with "ethtool -K <ethX> rxhash off|on",
which calls into the .ndo_set_features callback with the
NETIF_F_RXHASH feature bit set or cleared.  This patch adds
a check for that bit and updates the FW if necessary.

Signed-off-by: Shannon Nelson <snelson@pensando.io>
---
 drivers/net/ethernet/pensando/ionic/ionic_lif.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Jakub Kicinski March 4, 2020, 7:59 p.m. UTC | #1
On Tue,  3 Mar 2020 20:20:10 -0800 Shannon Nelson wrote:
> We can disable rxhashing by setting rss_types to 0.  The user
> can toggle this with "ethtool -K <ethX> rxhash off|on",
> which calls into the .ndo_set_features callback with the
> NETIF_F_RXHASH feature bit set or cleared.  This patch adds
> a check for that bit and updates the FW if necessary.
> 
> Signed-off-by: Shannon Nelson <snelson@pensando.io>
> ---
>  drivers/net/ethernet/pensando/ionic/ionic_lif.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
> index d1567e477b1f..4b953f9e9084 100644
> --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
> @@ -1094,6 +1094,7 @@ static int ionic_set_nic_features(struct ionic_lif *lif,
>  	u64 vlan_flags = IONIC_ETH_HW_VLAN_TX_TAG |
>  			 IONIC_ETH_HW_VLAN_RX_STRIP |
>  			 IONIC_ETH_HW_VLAN_RX_FILTER;
> +	u64 old_hw_features;
>  	int err;
>  
>  	ctx.cmd.lif_setattr.features = ionic_netdev_features_to_nic(features);
> @@ -1101,9 +1102,13 @@ static int ionic_set_nic_features(struct ionic_lif *lif,
>  	if (err)
>  		return err;
>  
> +	old_hw_features = lif->hw_features;
>  	lif->hw_features = le64_to_cpu(ctx.cmd.lif_setattr.features &
>  				       ctx.comp.lif_setattr.features);
>  
> +	if ((old_hw_features ^ lif->hw_features) & IONIC_ETH_HW_RX_HASH)
> +		ionic_lif_rss_config(lif, lif->rss_types, NULL, NULL);

Is this change coming from the HW or from ethtool? AFAIK hw_features
are what's supported, features is what's enabled..

>  	if ((vlan_flags & features) &&
>  	    !(vlan_flags & le64_to_cpu(ctx.comp.lif_setattr.features)))
>  		dev_info_once(lif->ionic->dev, "NIC is not supporting vlan offload, likely in SmartNIC mode\n");
> @@ -1357,13 +1362,15 @@ int ionic_lif_rss_config(struct ionic_lif *lif, const u16 types,
>  		.cmd.lif_setattr = {
>  			.opcode = IONIC_CMD_LIF_SETATTR,
>  			.attr = IONIC_LIF_ATTR_RSS,
> -			.rss.types = cpu_to_le16(types),
>  			.rss.addr = cpu_to_le64(lif->rss_ind_tbl_pa),
>  		},
>  	};
>  	unsigned int i, tbl_sz;
>  
> -	lif->rss_types = types;
> +	if (lif->hw_features & IONIC_ETH_HW_RX_HASH) {
> +		lif->rss_types = types;
> +		ctx.cmd.lif_setattr.rss.types = cpu_to_le16(types);
> +	}
>  
>  	if (key)
>  		memcpy(lif->rss_hash_key, key, IONIC_RSS_HASH_KEY_SIZE);
Shannon Nelson March 5, 2020, 12:24 a.m. UTC | #2
On 3/4/20 11:59 AM, Jakub Kicinski wrote:
> On Tue,  3 Mar 2020 20:20:10 -0800 Shannon Nelson wrote:
>> We can disable rxhashing by setting rss_types to 0.  The user
>> can toggle this with "ethtool -K <ethX> rxhash off|on",
>> which calls into the .ndo_set_features callback with the
>> NETIF_F_RXHASH feature bit set or cleared.  This patch adds
>> a check for that bit and updates the FW if necessary.
>>
>> Signed-off-by: Shannon Nelson <snelson@pensando.io>
>> ---
>>   drivers/net/ethernet/pensando/ionic/ionic_lif.c | 11 +++++++++--
>>   1 file changed, 9 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
>> index d1567e477b1f..4b953f9e9084 100644
>> --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c
>> +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
>> @@ -1094,6 +1094,7 @@ static int ionic_set_nic_features(struct ionic_lif *lif,
>>   	u64 vlan_flags = IONIC_ETH_HW_VLAN_TX_TAG |
>>   			 IONIC_ETH_HW_VLAN_RX_STRIP |
>>   			 IONIC_ETH_HW_VLAN_RX_FILTER;
>> +	u64 old_hw_features;
>>   	int err;
>>   
>>   	ctx.cmd.lif_setattr.features = ionic_netdev_features_to_nic(features);
>> @@ -1101,9 +1102,13 @@ static int ionic_set_nic_features(struct ionic_lif *lif,
>>   	if (err)
>>   		return err;
>>   
>> +	old_hw_features = lif->hw_features;
>>   	lif->hw_features = le64_to_cpu(ctx.cmd.lif_setattr.features &
>>   				       ctx.comp.lif_setattr.features);
>>   
>> +	if ((old_hw_features ^ lif->hw_features) & IONIC_ETH_HW_RX_HASH)
>> +		ionic_lif_rss_config(lif, lif->rss_types, NULL, NULL);
> Is this change coming from the HW or from ethtool? AFAIK hw_features
> are what's supported, features is what's enabled..

This is looking at the feature bits coming in from ndo_set_features - if 
the RX_HASH bit has been turned off in the incoming features bitmask, 
then I need to disable the hw hashing.

I believe the confusion is between lif->hw_features, describing what is 
currently enabled in the hw, versus the netdev->hw_features, that is 
what we've told the the stack we have available.

sln
Jakub Kicinski March 5, 2020, 1:32 a.m. UTC | #3
On Wed, 4 Mar 2020 16:24:01 -0800 Shannon Nelson wrote:
> On 3/4/20 11:59 AM, Jakub Kicinski wrote:
> > On Tue,  3 Mar 2020 20:20:10 -0800 Shannon Nelson wrote:  
> >> We can disable rxhashing by setting rss_types to 0.  The user
> >> can toggle this with "ethtool -K <ethX> rxhash off|on",
> >> which calls into the .ndo_set_features callback with the
> >> NETIF_F_RXHASH feature bit set or cleared.  This patch adds
> >> a check for that bit and updates the FW if necessary.
> >>
> >> Signed-off-by: Shannon Nelson <snelson@pensando.io>
> >> ---
> >>   drivers/net/ethernet/pensando/ionic/ionic_lif.c | 11 +++++++++--
> >>   1 file changed, 9 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
> >> index d1567e477b1f..4b953f9e9084 100644
> >> --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c
> >> +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
> >> @@ -1094,6 +1094,7 @@ static int ionic_set_nic_features(struct ionic_lif *lif,
> >>   	u64 vlan_flags = IONIC_ETH_HW_VLAN_TX_TAG |
> >>   			 IONIC_ETH_HW_VLAN_RX_STRIP |
> >>   			 IONIC_ETH_HW_VLAN_RX_FILTER;
> >> +	u64 old_hw_features;
> >>   	int err;
> >>   
> >>   	ctx.cmd.lif_setattr.features = ionic_netdev_features_to_nic(features);
> >> @@ -1101,9 +1102,13 @@ static int ionic_set_nic_features(struct ionic_lif *lif,
> >>   	if (err)
> >>   		return err;
> >>   
> >> +	old_hw_features = lif->hw_features;
> >>   	lif->hw_features = le64_to_cpu(ctx.cmd.lif_setattr.features &
> >>   				       ctx.comp.lif_setattr.features);
> >>   
> >> +	if ((old_hw_features ^ lif->hw_features) & IONIC_ETH_HW_RX_HASH)
> >> +		ionic_lif_rss_config(lif, lif->rss_types, NULL, NULL);  
> >
> > Is this change coming from the HW or from ethtool? AFAIK hw_features
> > are what's supported, features is what's enabled..  
> 
> This is looking at the feature bits coming in from ndo_set_features - if 
> the RX_HASH bit has been turned off in the incoming features bitmask, 
> then I need to disable the hw hashing.
> 
> I believe the confusion is between lif->hw_features, describing what is 
> currently enabled in the hw, versus the netdev->hw_features, that is 
> what we've told the the stack we have available.

Ah, you're very right. So the problem is that the current handling only
sends the general IONIC_LIF_ATTR_FEATURES request, but the device also
needs an extra IONIC_LIF_ATTR_RSS to disable RSS? Got it.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
index d1567e477b1f..4b953f9e9084 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
@@ -1094,6 +1094,7 @@  static int ionic_set_nic_features(struct ionic_lif *lif,
 	u64 vlan_flags = IONIC_ETH_HW_VLAN_TX_TAG |
 			 IONIC_ETH_HW_VLAN_RX_STRIP |
 			 IONIC_ETH_HW_VLAN_RX_FILTER;
+	u64 old_hw_features;
 	int err;
 
 	ctx.cmd.lif_setattr.features = ionic_netdev_features_to_nic(features);
@@ -1101,9 +1102,13 @@  static int ionic_set_nic_features(struct ionic_lif *lif,
 	if (err)
 		return err;
 
+	old_hw_features = lif->hw_features;
 	lif->hw_features = le64_to_cpu(ctx.cmd.lif_setattr.features &
 				       ctx.comp.lif_setattr.features);
 
+	if ((old_hw_features ^ lif->hw_features) & IONIC_ETH_HW_RX_HASH)
+		ionic_lif_rss_config(lif, lif->rss_types, NULL, NULL);
+
 	if ((vlan_flags & features) &&
 	    !(vlan_flags & le64_to_cpu(ctx.comp.lif_setattr.features)))
 		dev_info_once(lif->ionic->dev, "NIC is not supporting vlan offload, likely in SmartNIC mode\n");
@@ -1357,13 +1362,15 @@  int ionic_lif_rss_config(struct ionic_lif *lif, const u16 types,
 		.cmd.lif_setattr = {
 			.opcode = IONIC_CMD_LIF_SETATTR,
 			.attr = IONIC_LIF_ATTR_RSS,
-			.rss.types = cpu_to_le16(types),
 			.rss.addr = cpu_to_le64(lif->rss_ind_tbl_pa),
 		},
 	};
 	unsigned int i, tbl_sz;
 
-	lif->rss_types = types;
+	if (lif->hw_features & IONIC_ETH_HW_RX_HASH) {
+		lif->rss_types = types;
+		ctx.cmd.lif_setattr.rss.types = cpu_to_le16(types);
+	}
 
 	if (key)
 		memcpy(lif->rss_hash_key, key, IONIC_RSS_HASH_KEY_SIZE);