Commit aecd9d10 authored by Moshe Shemesh's avatar Moshe Shemesh Committed by Jakub Kicinski
Browse files

net/mlx5: fs, add HWS packet reformat API function



Add packet reformat alloc and dealloc API functions to provide packet
reformat actions for steering rules.

Add HWS action pools for each of the following packet reformat types:
- decapl3: decapsulate l3 tunnel to l2
- encapl2: encapsulate l2 to tunnel l2
- encapl3: encapsulate l2 to tunnel l3
- insert_hdr: insert header

In addition cache remove header action for remove vlan header as this is
currently the only use case of remove header action in the driver.

Signed-off-by: default avatarMoshe Shemesh <moshe@nvidia.com>
Reviewed-by: default avatarYevgeny Kliteynik <kliteyn@nvidia.com>
Reviewed-by: default avatarMark Bloch <mbloch@nvidia.com>
Signed-off-by: default avatarTariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20250109160546.1733647-6-tariqt@nvidia.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent c7e62a78
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -152,6 +152,7 @@ mlx5_core-$(CONFIG_MLX5_HW_STEERING) += steering/hws/cmd.o \
					steering/hws/debug.o \
					steering/hws/vport.o \
					steering/hws/bwc_complex.o \
					steering/hws/fs_hws_pools.o \
					steering/hws/fs_hws.o

#
+1 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ struct mlx5_pkt_reformat {
	enum mlx5_flow_resource_owner owner;
	union {
		struct mlx5_fs_dr_action fs_dr_action;
		struct mlx5_fs_hws_action fs_hws_action;
		u32 id;
	};
};
+3 −2
Original line number Diff line number Diff line
@@ -449,7 +449,8 @@ static void mlx5_fc_init(struct mlx5_fc *counter, struct mlx5_fc_bulk *bulk,
	counter->id = id;
}

static struct mlx5_fs_bulk *mlx5_fc_bulk_create(struct mlx5_core_dev *dev)
static struct mlx5_fs_bulk *mlx5_fc_bulk_create(struct mlx5_core_dev *dev,
						void *pool_ctx)
{
	enum mlx5_fc_bulk_alloc_bitmask alloc_bitmask;
	struct mlx5_fc_bulk *fc_bulk;
@@ -518,7 +519,7 @@ static const struct mlx5_fs_pool_ops mlx5_fc_pool_ops = {
static void
mlx5_fc_pool_init(struct mlx5_fs_pool *fc_pool, struct mlx5_core_dev *dev)
{
	mlx5_fs_pool_init(fc_pool, dev, &mlx5_fc_pool_ops);
	mlx5_fs_pool_init(fc_pool, dev, &mlx5_fc_pool_ops, NULL);
}

static void mlx5_fc_pool_cleanup(struct mlx5_fs_pool *fc_pool)
+3 −2
Original line number Diff line number Diff line
@@ -56,11 +56,12 @@ static int mlx5_fs_bulk_release_index(struct mlx5_fs_bulk *fs_bulk, int index)
}

void mlx5_fs_pool_init(struct mlx5_fs_pool *pool, struct mlx5_core_dev *dev,
		       const struct mlx5_fs_pool_ops *ops)
		       const struct mlx5_fs_pool_ops *ops, void *pool_ctx)
{
	WARN_ON_ONCE(!ops || !ops->bulk_destroy || !ops->bulk_create ||
		     !ops->update_threshold);
	pool->dev = dev;
	pool->pool_ctx = pool_ctx;
	mutex_init(&pool->pool_lock);
	INIT_LIST_HEAD(&pool->fully_used);
	INIT_LIST_HEAD(&pool->partially_used);
@@ -91,7 +92,7 @@ mlx5_fs_pool_alloc_new_bulk(struct mlx5_fs_pool *fs_pool)
	struct mlx5_core_dev *dev = fs_pool->dev;
	struct mlx5_fs_bulk *new_bulk;

	new_bulk = fs_pool->ops->bulk_create(dev);
	new_bulk = fs_pool->ops->bulk_create(dev, fs_pool->pool_ctx);
	if (new_bulk)
		fs_pool->available_units += new_bulk->bulk_len;
	fs_pool->ops->update_threshold(fs_pool);
+3 −2
Original line number Diff line number Diff line
@@ -21,7 +21,8 @@ struct mlx5_fs_pool;

struct mlx5_fs_pool_ops {
	int (*bulk_destroy)(struct mlx5_core_dev *dev, struct mlx5_fs_bulk *bulk);
	struct mlx5_fs_bulk * (*bulk_create)(struct mlx5_core_dev *dev);
	struct mlx5_fs_bulk * (*bulk_create)(struct mlx5_core_dev *dev,
					     void *pool_ctx);
	void (*update_threshold)(struct mlx5_fs_pool *pool);
};

@@ -44,7 +45,7 @@ void mlx5_fs_bulk_cleanup(struct mlx5_fs_bulk *fs_bulk);
int mlx5_fs_bulk_get_free_amount(struct mlx5_fs_bulk *bulk);

void mlx5_fs_pool_init(struct mlx5_fs_pool *pool, struct mlx5_core_dev *dev,
		       const struct mlx5_fs_pool_ops *ops);
		       const struct mlx5_fs_pool_ops *ops, void *pool_ctx);
void mlx5_fs_pool_cleanup(struct mlx5_fs_pool *pool);
int mlx5_fs_pool_acquire_index(struct mlx5_fs_pool *fs_pool,
			       struct mlx5_fs_pool_index *pool_index);
Loading