[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <03c22e72-5cfe-4261-8572-b9951a92d224@nvidia.com>
Date: Wed, 8 Jan 2025 18:54:19 +0200
From: Moshe Shemesh <moshe@...dia.com>
To: Przemek Kitszel <przemyslaw.kitszel@...el.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/2025 4:58 PM, Przemek Kitszel wrote:
>
> 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
Yes, I see what you are saying, it can work here.
But in this case I need the loop to look for the pattern anyway, so once
loop ended without finding the pattern I know what is the next index
instead of having xa_alloc() to find next index.
Powered by blists - more mailing lists