[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9a961e7c-1702-400b-89ed-4dcb2d1ef81e@intel.com>
Date: Wed, 8 Jan 2025 15:58:36 +0100
From: Przemek Kitszel <przemyslaw.kitszel@...el.com>
To: Moshe Shemesh <moshe@...dia.com>
CC: <netdev@...r.kernel.org>, Saeed Mahameed <saeedm@...dia.com>, Tariq Toukan
<tariqt@...dia.com>, Gal Pressman <gal@...dia.com>, Leon Romanovsky
<leonro@...dia.com>, Mark Bloch <mbloch@...dia.com>, Yevgeny Kliteynik
<kliteyn@...dia.com>, "David S. Miller" <davem@...emloft.net>, Jakub Kicinski
<kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, Eric Dumazet
<edumazet@...gle.com>, Andrew Lunn <andrew+netdev@...n.ch>
Subject: Re: [PATCH net-next 06/13] net/mlx5: fs, add HWS modify header API
function
On 1/8/25 13:04, Moshe Shemesh wrote:
>>> +static int mlx5_cmd_hws_modify_header_alloc(struct
>>> mlx5_flow_root_namespace *ns,
>>> + u8 namespace, u8 num_actions,
>>> + void *modify_actions,
>>> + struct mlx5_modify_hdr
>>> *modify_hdr)
>>> +{
>>> + struct mlx5_fs_hws_actions_pool *hws_pool = &ns-
>>> >fs_hws_context.hws_pool;
>>> + struct mlx5hws_action_mh_pattern pattern = {};
>>> + struct mlx5_fs_hws_mh *mh_data = NULL;
>>> + struct mlx5hws_action *hws_action;
>>> + struct mlx5_fs_pool *pool;
>>> + unsigned long i, cnt = 0;
>>> + bool known_pattern;
>>> + int err;
>>> +
>>> + pattern.sz = MLX5_UN_SZ_BYTES(set_add_copy_action_in_auto) *
>>> num_actions;
>>> + pattern.data = modify_actions;
>>> +
>>> + known_pattern = false;
>>> + xa_for_each(&hws_pool->mh_pools, i, pool) {
>>> + if (mlx5_fs_hws_mh_pool_match(pool, &pattern)) {
>>> + known_pattern = true;
>>> + break;
>>> + }
>>> + cnt++;
>>> + }
>>> +
>>> + if (!known_pattern) {
>>> + pool = create_mh_pool(ns->dev, &pattern, &hws_pool-
>>> >mh_pools, cnt);
>>> + if (IS_ERR(pool))
>>> + return PTR_ERR(pool);
>>> + }
>>
>> if, by any chance, .mh_pools was empty, next line has @pool
>> uninitialized
>
> If .mh_pools was empty then known_pattern is false and create_mh_pool()
> is called which returns valid pool or error.
>
oh yeah, sorry for the confusion!
BTW, if you don't need the index in the array for other purposes, then
"allocating xarray" would manage it for you
Powered by blists - more mailing lists