[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231225174148.GL5962@kernel.org>
Date: Mon, 25 Dec 2023 17:41:48 +0000
From: Simon Horman <horms@...nel.org>
To: Michael Chan <michael.chan@...adcom.com>
Cc: davem@...emloft.net, netdev@...r.kernel.org, edumazet@...gle.com,
kuba@...nel.org, pabeni@...hat.com, pavan.chebbi@...adcom.com,
andrew.gospodarek@...adcom.com
Subject: Re: [PATCH net-next v2 13/13] bnxt_en: Add support for ntuple filter
deletion by ethtool.
On Fri, Dec 22, 2023 at 08:22:10PM -0800, Michael Chan wrote:
> Add logic to delete a user specified ntuple filter from ethtool.
>
> Reviewed-by: Vasundhara Volam <vasundhara-v.volam@...adcom.com>
> Reviewed-by: Andy Gospodarek <andrew.gospodarek@...adcom.com>
> Reviewed-by: Pavan Chebbi <pavan.chebbi@...adcom.com>
> Signed-off-by: Michael Chan <michael.chan@...adcom.com>
> ---
> .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 29 +++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
> index c3b9be328b87..5629ba9f4b2e 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
> @@ -1341,6 +1341,31 @@ static int bnxt_srxclsrlins(struct bnxt *bp, struct ethtool_rxnfc *cmd)
> return rc;
> }
>
> +static int bnxt_srxclsrldel(struct bnxt *bp, struct ethtool_rxnfc *cmd)
> +{
> + struct ethtool_rx_flow_spec *fs = &cmd->fs;
> + struct bnxt_filter_base *fltr_base;
> +
> + rcu_read_lock();
> + fltr_base = bnxt_get_one_fltr_rcu(bp, bp->ntp_fltr_hash_tbl,
> + BNXT_NTP_FLTR_HASH_SIZE,
> + fs->location);
> + if (fltr_base) {
> + struct bnxt_ntuple_filter *fltr;
> +
> + fltr = container_of(fltr_base, struct bnxt_ntuple_filter, base);
> + rcu_read_unlock();
> + if (!(fltr->base.flags & BNXT_ACT_NO_AGING))
> + return -EINVAL;
> + bnxt_hwrm_cfa_ntuple_filter_free(bp, fltr);
> + bnxt_del_ntp_filter(bp, fltr);
> + return 0;
> + }
> +
> + rcu_read_unlock();
> + return -ENOENT;
> +}
> +
Hi Michael,
FWIIW, I think it would be more idoiomatic to handle
the error case inside the if condition.
(Completely untested!)
static int bnxt_srxclsrldel(struct bnxt *bp, struct ethtool_rxnfc *cmd)
{
struct ethtool_rx_flow_spec *fs = &cmd->fs;
struct bnxt_filter_base *fltr_base;
struct bnxt_ntuple_filter *fltr;
rcu_read_lock();
fltr_base = bnxt_get_one_fltr_rcu(bp, bp->ntp_fltr_hash_tbl,
BNXT_NTP_FLTR_HASH_SIZE,
fs->location);
if (!fltr_base) {
rcu_read_unlock();
return -ENOENT;
}
fltr = container_of(fltr_base, struct bnxt_ntuple_filter, base);
rcu_read_unlock();
if (!(fltr->base.flags & BNXT_ACT_NO_AGING))
return -EINVAL;
bnxt_hwrm_cfa_ntuple_filter_free(bp, fltr);
bnxt_del_ntp_filter(bp, fltr);
return 0;
}
...
Powered by blists - more mailing lists