[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241015225712.65071-1-kuniyu@amazon.com>
Date: Tue, 15 Oct 2024 15:57:12 -0700
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <gnaaman@...venets.com>
CC: <davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
<kuniyu@...zon.com>, <netdev@...r.kernel.org>, <pabeni@...hat.com>
Subject: Re: [PATCH net-next v4 2/6] Define neigh_for_each
From: Gilad Naaman <gnaaman@...venets.com>
Date: Tue, 15 Oct 2024 16:59:22 +0000
> diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
> index 800dfb64ec83..0bb46aba2502 100644
> --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
> +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
> @@ -3006,6 +3006,27 @@ static void mlxsw_sp_neigh_rif_made_sync_each(struct neighbour *n, void *data)
> rms->err = -ENOMEM;
> }
>
> +static void mlxsw_sp_neigh_for_each(struct neigh_table *tbl,
> + void (*cb)(struct neighbour *, void *),
The function pointer is no longer needed as cb() is always
mlxsw_sp_neigh_rif_made_sync_each().
Also, please CC this driver's maintainers next time.
git show --format=email | ./scripts/get_maintainer.pl
> + void *cookie)
> +{
> + int chain;
> + struct neigh_hash_table *nht;
nit: reverse xmas tree order.
> +
> + rcu_read_lock();
> + nht = rcu_dereference(tbl->nht);
> +
> + read_lock_bh(&tbl->lock); /* avoid resizes */
> + for (chain = 0; chain < (1 << nht->hash_shift); chain++) {
> + struct neighbour *n;
> +
> + neigh_for_each(n, &nht->hash_heads[chain])
> + cb(n, cookie);
This can be a direct call.
> + }
> + read_unlock_bh(&tbl->lock);
> + rcu_read_unlock();
> +}
> +
> static int mlxsw_sp_neigh_rif_made_sync(struct mlxsw_sp *mlxsw_sp,
> struct mlxsw_sp_rif *rif)
> {
> @@ -3014,12 +3035,12 @@ static int mlxsw_sp_neigh_rif_made_sync(struct mlxsw_sp *mlxsw_sp,
> .rif = rif,
> };
>
> - neigh_for_each(&arp_tbl, mlxsw_sp_neigh_rif_made_sync_each, &rms);
> + mlxsw_sp_neigh_for_each(&arp_tbl, mlxsw_sp_neigh_rif_made_sync_each, &rms);
> if (rms.err)
> goto err_arp;
>
> #if IS_ENABLED(CONFIG_IPV6)
> - neigh_for_each(&nd_tbl, mlxsw_sp_neigh_rif_made_sync_each, &rms);
> + mlxsw_sp_neigh_for_each(&nd_tbl, mlxsw_sp_neigh_rif_made_sync_each, &rms);
> #endif
> if (rms.err)
> goto err_nd;
Powered by blists - more mailing lists