Skip to content

Commit 975b992

Browse files
Paul BlakeySaeed Mahameed
authored andcommitted
net/mlx5: Add new chain for netfilter flow table offload
Netfilter tables (nftables) implements a software datapath that comes after tc ingress datapath. The datapath supports offloading such rules via the flow table offload API. This API is currently only used by NFT and it doesn't provide the global priority in regards to tc offload, so we assume offloading such rules must come after tc. It does provide a flow table priority parameter, so we need to provide some supported priority range. For that, split fastpath prio to two, flow table offload and tc offload, with one dedicated priority chain for flow table offload. Next patch will re-use the multi chain API to access this chain by allowing access to this chain by the fdb_sub_namespace. Signed-off-by: Paul Blakey <[email protected]> Reviewed-by: Mark Bloch <[email protected]> Acked-by: Pablo Neira Ayuso <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 439e843 commit 975b992

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@
4444
#include "lib/mpfs.h"
4545

4646
#define FDB_TC_MAX_CHAIN 3
47-
#define FDB_TC_SLOW_PATH_CHAIN (FDB_TC_MAX_CHAIN + 1)
47+
#define FDB_FT_CHAIN (FDB_TC_MAX_CHAIN + 1)
48+
#define FDB_TC_SLOW_PATH_CHAIN (FDB_FT_CHAIN + 1)
49+
50+
/* The index of the last real chain (FT) + 1 as chain zero is valid as well */
51+
#define FDB_NUM_CHAINS (FDB_FT_CHAIN + 1)
52+
4853
#define FDB_TC_MAX_PRIO 16
4954
#define FDB_TC_LEVELS_PER_PRIO 2
5055

@@ -173,7 +178,7 @@ struct mlx5_eswitch_fdb {
173178
struct {
174179
struct mlx5_flow_table *fdb;
175180
u32 num_rules;
176-
} fdb_prio[FDB_TC_MAX_CHAIN + 1][FDB_TC_MAX_PRIO + 1][FDB_TC_LEVELS_PER_PRIO];
181+
} fdb_prio[FDB_NUM_CHAINS][FDB_TC_MAX_PRIO + 1][FDB_TC_LEVELS_PER_PRIO];
177182
/* Protects fdb_prio table */
178183
struct mutex fdb_prio_lock;
179184

drivers/net/ethernet/mellanox/mlx5/core/fs_core.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2624,16 +2624,19 @@ static int create_fdb_chains(struct mlx5_flow_steering *steering,
26242624

26252625
static int create_fdb_fast_path(struct mlx5_flow_steering *steering)
26262626
{
2627-
const int total_chains = FDB_TC_MAX_CHAIN + 1;
26282627
int err;
26292628

2630-
steering->fdb_sub_ns = kcalloc(total_chains,
2629+
steering->fdb_sub_ns = kcalloc(FDB_NUM_CHAINS,
26312630
sizeof(*steering->fdb_sub_ns),
26322631
GFP_KERNEL);
26332632
if (!steering->fdb_sub_ns)
26342633
return -ENOMEM;
26352634

2636-
err = create_fdb_chains(steering, FDB_FAST_PATH, FDB_TC_MAX_CHAIN + 1);
2635+
err = create_fdb_chains(steering, FDB_TC_OFFLOAD, FDB_TC_MAX_CHAIN + 1);
2636+
if (err)
2637+
return err;
2638+
2639+
err = create_fdb_chains(steering, FDB_FT_OFFLOAD, 1);
26372640
if (err)
26382641
return err;
26392642

include/linux/mlx5/fs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ enum mlx5_flow_namespace_type {
8080

8181
enum {
8282
FDB_BYPASS_PATH,
83-
FDB_FAST_PATH,
83+
FDB_TC_OFFLOAD,
84+
FDB_FT_OFFLOAD,
8485
FDB_SLOW_PATH,
8586
};
8687

0 commit comments

Comments
 (0)