Subject: Re: [PATCH net 3/3] iavf: enable tc filter configuration only if hw-tc-offload is on

From: Jakub Kicinski <[email-masked]>
Date: Mon, 25 Jul 2022 19:45:47 -0700

On Mon, 25 Jul 2022 10:04:52 -0700 Tony Nguyen wrote:
> From: Sudheer Mogilappagari <[email-masked]>
> 
> Allow configuration of tc filter only if NETIF_F_HW_TC is set for the
> device.
> 
> Fixes: 0075fa0fadd0 ("i40evf: Add support to apply cloud filters")
> Signed-off-by: Sudheer Mogilappagari <[email-masked]>
> Signed-off-by: Jun Zhang <[email-masked]>
> Tested-by: Bharathi Sreenivas <[email-masked]>
> Signed-off-by: Tony Nguyen <[email-masked]>
> ---
>  drivers/net/ethernet/intel/iavf/iavf_main.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
> index 3dbfaead2ac7..9279bb37e4aa 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_main.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
> @@ -3802,6 +3802,12 @@ static int iavf_configure_clsflower(struct iavf_adapter *adapter,
>  		return -EINVAL;
>  	}
>  
> +	if (!(adapter->netdev->features & NETIF_F_HW_TC)) {
> +		dev_err(&adapter->pdev->dev,
> +			"Can't apply TC flower filters, turn ON hw-tc-offload and try again");
> +		return -EOPNOTSUPP;
> +	}
> +
>  	filter = kzalloc(sizeof(*filter), GFP_KERNEL);
>  	if (!filter)
>  		return -ENOMEM;

tc_can_offload() checks this in the core already, no?