Commit 6a48faee authored by Maor Gottlieb's avatar Maor Gottlieb Committed by Saeed Mahameed

net/mlx5: Add direct rule fs_cmd implementation

Add support to create flow steering objects
via direct rule API (SW steering).
New layer is added - fs_dr, this layer translates the command that
fs_core sends to the FW into direct rule API. In case that direct
rule is not supported in some feature then -EOPNOTSUPP is
returned.
Signed-off-by: default avatarMaor Gottlieb <maorg@mellanox.com>
Reviewed-by: default avatarMark Bloch <markb@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent fb86f121
...@@ -73,4 +73,4 @@ mlx5_core-$(CONFIG_MLX5_SW_STEERING) += steering/dr_domain.o steering/dr_table.o ...@@ -73,4 +73,4 @@ mlx5_core-$(CONFIG_MLX5_SW_STEERING) += steering/dr_domain.o steering/dr_table.o
steering/dr_icm_pool.o steering/dr_crc32.o \ steering/dr_icm_pool.o steering/dr_crc32.o \
steering/dr_ste.o steering/dr_send.o \ steering/dr_ste.o steering/dr_send.o \
steering/dr_cmd.o steering/dr_fw.o \ steering/dr_cmd.o steering/dr_fw.o \
steering/dr_action.o steering/dr_action.o steering/fs_dr.o
...@@ -135,6 +135,22 @@ static void mlx5_cmd_stub_modify_header_dealloc(struct mlx5_flow_root_namespace ...@@ -135,6 +135,22 @@ static void mlx5_cmd_stub_modify_header_dealloc(struct mlx5_flow_root_namespace
{ {
} }
static int mlx5_cmd_stub_set_peer(struct mlx5_flow_root_namespace *ns,
struct mlx5_flow_root_namespace *peer_ns)
{
return 0;
}
static int mlx5_cmd_stub_create_ns(struct mlx5_flow_root_namespace *ns)
{
return 0;
}
static int mlx5_cmd_stub_destroy_ns(struct mlx5_flow_root_namespace *ns)
{
return 0;
}
static int mlx5_cmd_update_root_ft(struct mlx5_flow_root_namespace *ns, static int mlx5_cmd_update_root_ft(struct mlx5_flow_root_namespace *ns,
struct mlx5_flow_table *ft, u32 underlay_qpn, struct mlx5_flow_table *ft, u32 underlay_qpn,
bool disconnect) bool disconnect)
...@@ -838,7 +854,10 @@ static const struct mlx5_flow_cmds mlx5_flow_cmds = { ...@@ -838,7 +854,10 @@ static const struct mlx5_flow_cmds mlx5_flow_cmds = {
.packet_reformat_alloc = mlx5_cmd_packet_reformat_alloc, .packet_reformat_alloc = mlx5_cmd_packet_reformat_alloc,
.packet_reformat_dealloc = mlx5_cmd_packet_reformat_dealloc, .packet_reformat_dealloc = mlx5_cmd_packet_reformat_dealloc,
.modify_header_alloc = mlx5_cmd_modify_header_alloc, .modify_header_alloc = mlx5_cmd_modify_header_alloc,
.modify_header_dealloc = mlx5_cmd_modify_header_dealloc .modify_header_dealloc = mlx5_cmd_modify_header_dealloc,
.set_peer = mlx5_cmd_stub_set_peer,
.create_ns = mlx5_cmd_stub_create_ns,
.destroy_ns = mlx5_cmd_stub_destroy_ns,
}; };
static const struct mlx5_flow_cmds mlx5_flow_cmd_stubs = { static const struct mlx5_flow_cmds mlx5_flow_cmd_stubs = {
...@@ -854,10 +873,13 @@ static const struct mlx5_flow_cmds mlx5_flow_cmd_stubs = { ...@@ -854,10 +873,13 @@ static const struct mlx5_flow_cmds mlx5_flow_cmd_stubs = {
.packet_reformat_alloc = mlx5_cmd_stub_packet_reformat_alloc, .packet_reformat_alloc = mlx5_cmd_stub_packet_reformat_alloc,
.packet_reformat_dealloc = mlx5_cmd_stub_packet_reformat_dealloc, .packet_reformat_dealloc = mlx5_cmd_stub_packet_reformat_dealloc,
.modify_header_alloc = mlx5_cmd_stub_modify_header_alloc, .modify_header_alloc = mlx5_cmd_stub_modify_header_alloc,
.modify_header_dealloc = mlx5_cmd_stub_modify_header_dealloc .modify_header_dealloc = mlx5_cmd_stub_modify_header_dealloc,
.set_peer = mlx5_cmd_stub_set_peer,
.create_ns = mlx5_cmd_stub_create_ns,
.destroy_ns = mlx5_cmd_stub_destroy_ns,
}; };
static const struct mlx5_flow_cmds *mlx5_fs_cmd_get_fw_cmds(void) const struct mlx5_flow_cmds *mlx5_fs_cmd_get_fw_cmds(void)
{ {
return &mlx5_flow_cmds; return &mlx5_flow_cmds;
} }
......
...@@ -93,6 +93,12 @@ struct mlx5_flow_cmds { ...@@ -93,6 +93,12 @@ struct mlx5_flow_cmds {
void (*modify_header_dealloc)(struct mlx5_flow_root_namespace *ns, void (*modify_header_dealloc)(struct mlx5_flow_root_namespace *ns,
struct mlx5_modify_hdr *modify_hdr); struct mlx5_modify_hdr *modify_hdr);
int (*set_peer)(struct mlx5_flow_root_namespace *ns,
struct mlx5_flow_root_namespace *peer_ns);
int (*create_ns)(struct mlx5_flow_root_namespace *ns);
int (*destroy_ns)(struct mlx5_flow_root_namespace *ns);
}; };
int mlx5_cmd_fc_alloc(struct mlx5_core_dev *dev, u32 *id); int mlx5_cmd_fc_alloc(struct mlx5_core_dev *dev, u32 *id);
...@@ -108,5 +114,6 @@ int mlx5_cmd_fc_bulk_query(struct mlx5_core_dev *dev, u32 base_id, int bulk_len, ...@@ -108,5 +114,6 @@ int mlx5_cmd_fc_bulk_query(struct mlx5_core_dev *dev, u32 base_id, int bulk_len,
u32 *out); u32 *out);
const struct mlx5_flow_cmds *mlx5_fs_cmd_get_default(enum fs_flow_table_type type); const struct mlx5_flow_cmds *mlx5_fs_cmd_get_default(enum fs_flow_table_type type);
const struct mlx5_flow_cmds *mlx5_fs_cmd_get_fw_cmds(void);
#endif #endif
...@@ -2991,3 +2991,9 @@ void mlx5_packet_reformat_dealloc(struct mlx5_core_dev *dev, ...@@ -2991,3 +2991,9 @@ void mlx5_packet_reformat_dealloc(struct mlx5_core_dev *dev,
kfree(pkt_reformat); kfree(pkt_reformat);
} }
EXPORT_SYMBOL(mlx5_packet_reformat_dealloc); EXPORT_SYMBOL(mlx5_packet_reformat_dealloc);
int mlx5_flow_namespace_set_peer(struct mlx5_flow_root_namespace *ns,
struct mlx5_flow_root_namespace *peer_ns)
{
return ns->cmds->set_peer(ns, peer_ns);
}
...@@ -37,16 +37,23 @@ ...@@ -37,16 +37,23 @@
#include <linux/mlx5/fs.h> #include <linux/mlx5/fs.h>
#include <linux/rhashtable.h> #include <linux/rhashtable.h>
#include <linux/llist.h> #include <linux/llist.h>
#include <steering/fs_dr.h>
struct mlx5_modify_hdr { struct mlx5_modify_hdr {
enum mlx5_flow_namespace_type ns_type; enum mlx5_flow_namespace_type ns_type;
u32 id; union {
struct mlx5_fs_dr_action action;
u32 id;
};
}; };
struct mlx5_pkt_reformat { struct mlx5_pkt_reformat {
enum mlx5_flow_namespace_type ns_type; enum mlx5_flow_namespace_type ns_type;
int reformat_type; /* from mlx5_ifc */ int reformat_type; /* from mlx5_ifc */
u32 id; union {
struct mlx5_fs_dr_action action;
u32 id;
};
}; };
/* FS_TYPE_PRIO_CHAINS is a PRIO that will have namespaces only, /* FS_TYPE_PRIO_CHAINS is a PRIO that will have namespaces only,
...@@ -139,6 +146,7 @@ struct mlx5_flow_handle { ...@@ -139,6 +146,7 @@ struct mlx5_flow_handle {
/* Type of children is mlx5_flow_group */ /* Type of children is mlx5_flow_group */
struct mlx5_flow_table { struct mlx5_flow_table {
struct fs_node node; struct fs_node node;
struct mlx5_fs_dr_table fs_dr_table;
u32 id; u32 id;
u16 vport; u16 vport;
unsigned int max_fte; unsigned int max_fte;
...@@ -179,6 +187,7 @@ struct mlx5_ft_underlay_qp { ...@@ -179,6 +187,7 @@ struct mlx5_ft_underlay_qp {
/* Type of children is mlx5_flow_rule */ /* Type of children is mlx5_flow_rule */
struct fs_fte { struct fs_fte {
struct fs_node node; struct fs_node node;
struct mlx5_fs_dr_rule fs_dr_rule;
u32 val[MLX5_ST_SZ_DW_MATCH_PARAM]; u32 val[MLX5_ST_SZ_DW_MATCH_PARAM];
u32 dests_size; u32 dests_size;
u32 index; u32 index;
...@@ -214,6 +223,7 @@ struct mlx5_flow_group_mask { ...@@ -214,6 +223,7 @@ struct mlx5_flow_group_mask {
/* Type of children is fs_fte */ /* Type of children is fs_fte */
struct mlx5_flow_group { struct mlx5_flow_group {
struct fs_node node; struct fs_node node;
struct mlx5_fs_dr_matcher fs_dr_matcher;
struct mlx5_flow_group_mask mask; struct mlx5_flow_group_mask mask;
u32 start_index; u32 start_index;
u32 max_ftes; u32 max_ftes;
...@@ -225,6 +235,7 @@ struct mlx5_flow_group { ...@@ -225,6 +235,7 @@ struct mlx5_flow_group {
struct mlx5_flow_root_namespace { struct mlx5_flow_root_namespace {
struct mlx5_flow_namespace ns; struct mlx5_flow_namespace ns;
struct mlx5_fs_dr_domain fs_dr_domain;
enum fs_flow_table_type table_type; enum fs_flow_table_type table_type;
struct mlx5_core_dev *dev; struct mlx5_core_dev *dev;
struct mlx5_flow_table *root_ft; struct mlx5_flow_table *root_ft;
...@@ -242,6 +253,11 @@ void mlx5_fc_queue_stats_work(struct mlx5_core_dev *dev, ...@@ -242,6 +253,11 @@ void mlx5_fc_queue_stats_work(struct mlx5_core_dev *dev,
void mlx5_fc_update_sampling_interval(struct mlx5_core_dev *dev, void mlx5_fc_update_sampling_interval(struct mlx5_core_dev *dev,
unsigned long interval); unsigned long interval);
const struct mlx5_flow_cmds *mlx5_fs_cmd_get_fw_cmds(void);
int mlx5_flow_namespace_set_peer(struct mlx5_flow_root_namespace *ns,
struct mlx5_flow_root_namespace *peer_ns);
int mlx5_init_fs(struct mlx5_core_dev *dev); int mlx5_init_fs(struct mlx5_core_dev *dev);
void mlx5_cleanup_fs(struct mlx5_core_dev *dev); void mlx5_cleanup_fs(struct mlx5_core_dev *dev);
......
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
* Copyright (c) 2019 Mellanox Technologies
*/
#ifndef _MLX5_FS_DR_
#define _MLX5_FS_DR_
#include "mlx5dr.h"
struct mlx5_flow_root_namespace;
struct fs_fte;
struct mlx5_fs_dr_action {
struct mlx5dr_action *dr_action;
};
struct mlx5_fs_dr_ns {
struct mlx5_dr_ns *dr_ns;
};
struct mlx5_fs_dr_rule {
struct mlx5dr_rule *dr_rule;
/* Only actions created by fs_dr */
struct mlx5dr_action **dr_actions;
int num_actions;
};
struct mlx5_fs_dr_domain {
struct mlx5dr_domain *dr_domain;
};
struct mlx5_fs_dr_matcher {
struct mlx5dr_matcher *dr_matcher;
};
struct mlx5_fs_dr_table {
struct mlx5dr_table *dr_table;
struct mlx5dr_action *miss_action;
};
#ifdef CONFIG_MLX5_SW_STEERING
bool mlx5_fs_dr_is_supported(struct mlx5_core_dev *dev);
const struct mlx5_flow_cmds *mlx5_fs_cmd_get_dr_cmds(void);
#else
static inline const struct mlx5_flow_cmds *mlx5_fs_cmd_get_dr_cmds(void)
{
return NULL;
}
static inline bool mlx5_fs_dr_is_supported(struct mlx5_core_dev *dev)
{
return false;
}
#endif /* CONFIG_MLX5_SW_STEERING */
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment