Skip to content

Commit 8c894f8

Browse files
PatrisiousHaddadrleon
authored andcommitted
net/mlx5: Implement alias object allow and create functions
Add functions which allow one vhca to access another vhca object, and functions that creates an alias object or destroys it. Together they can be used to create cross vhca flow table that is able jump from the steering domain that is managed by one vport, to the steering domain on a different vport. Signed-off-by: Patrisious Haddad <phaddad@nvidia.com> Reviewed-by: Mark Bloch <mbloch@nvidia.com> Link: https://lore.kernel.org/r/f45a9c85319fa783186b8988abcd64955b5f2a0c.1695296682.git.leon@kernel.org Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent ef36ffc commit 8c894f8

2 files changed

Lines changed: 92 additions & 0 deletions

File tree

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

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op,
525525
case MLX5_CMD_OP_SAVE_VHCA_STATE:
526526
case MLX5_CMD_OP_LOAD_VHCA_STATE:
527527
case MLX5_CMD_OP_SYNC_CRYPTO:
528+
case MLX5_CMD_OP_ALLOW_OTHER_VHCA_ACCESS:
528529
*status = MLX5_DRIVER_STATUS_ABORTED;
529530
*synd = MLX5_DRIVER_SYND;
530531
return -ENOLINK;
@@ -728,6 +729,7 @@ const char *mlx5_command_str(int command)
728729
MLX5_COMMAND_STR_CASE(SAVE_VHCA_STATE);
729730
MLX5_COMMAND_STR_CASE(LOAD_VHCA_STATE);
730731
MLX5_COMMAND_STR_CASE(SYNC_CRYPTO);
732+
MLX5_COMMAND_STR_CASE(ALLOW_OTHER_VHCA_ACCESS);
731733
default: return "unknown command opcode";
732734
}
733735
}
@@ -2090,6 +2092,74 @@ int mlx5_cmd_exec_cb(struct mlx5_async_ctx *ctx, void *in, int in_size,
20902092
}
20912093
EXPORT_SYMBOL(mlx5_cmd_exec_cb);
20922094

2095+
int mlx5_cmd_allow_other_vhca_access(struct mlx5_core_dev *dev,
2096+
struct mlx5_cmd_allow_other_vhca_access_attr *attr)
2097+
{
2098+
u32 out[MLX5_ST_SZ_DW(allow_other_vhca_access_out)] = {};
2099+
u32 in[MLX5_ST_SZ_DW(allow_other_vhca_access_in)] = {};
2100+
void *key;
2101+
2102+
MLX5_SET(allow_other_vhca_access_in,
2103+
in, opcode, MLX5_CMD_OP_ALLOW_OTHER_VHCA_ACCESS);
2104+
MLX5_SET(allow_other_vhca_access_in,
2105+
in, object_type_to_be_accessed, attr->obj_type);
2106+
MLX5_SET(allow_other_vhca_access_in,
2107+
in, object_id_to_be_accessed, attr->obj_id);
2108+
2109+
key = MLX5_ADDR_OF(allow_other_vhca_access_in, in, access_key);
2110+
memcpy(key, attr->access_key, sizeof(attr->access_key));
2111+
2112+
return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
2113+
}
2114+
2115+
int mlx5_cmd_alias_obj_create(struct mlx5_core_dev *dev,
2116+
struct mlx5_cmd_alias_obj_create_attr *alias_attr,
2117+
u32 *obj_id)
2118+
{
2119+
u32 out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)] = {};
2120+
u32 in[MLX5_ST_SZ_DW(create_alias_obj_in)] = {};
2121+
void *param;
2122+
void *attr;
2123+
void *key;
2124+
int ret;
2125+
2126+
attr = MLX5_ADDR_OF(create_alias_obj_in, in, hdr);
2127+
MLX5_SET(general_obj_in_cmd_hdr,
2128+
attr, opcode, MLX5_CMD_OP_CREATE_GENERAL_OBJECT);
2129+
MLX5_SET(general_obj_in_cmd_hdr,
2130+
attr, obj_type, alias_attr->obj_type);
2131+
param = MLX5_ADDR_OF(general_obj_in_cmd_hdr, in, op_param);
2132+
MLX5_SET(general_obj_create_param, param, alias_object, 1);
2133+
2134+
attr = MLX5_ADDR_OF(create_alias_obj_in, in, alias_ctx);
2135+
MLX5_SET(alias_context, attr, vhca_id_to_be_accessed, alias_attr->vhca_id);
2136+
MLX5_SET(alias_context, attr, object_id_to_be_accessed, alias_attr->obj_id);
2137+
2138+
key = MLX5_ADDR_OF(alias_context, attr, access_key);
2139+
memcpy(key, alias_attr->access_key, sizeof(alias_attr->access_key));
2140+
2141+
ret = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
2142+
if (ret)
2143+
return ret;
2144+
2145+
*obj_id = MLX5_GET(general_obj_out_cmd_hdr, out, obj_id);
2146+
2147+
return 0;
2148+
}
2149+
2150+
int mlx5_cmd_alias_obj_destroy(struct mlx5_core_dev *dev, u32 obj_id,
2151+
u16 obj_type)
2152+
{
2153+
u32 out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)] = {};
2154+
u32 in[MLX5_ST_SZ_DW(general_obj_in_cmd_hdr)] = {};
2155+
2156+
MLX5_SET(general_obj_in_cmd_hdr, in, opcode, MLX5_CMD_OP_DESTROY_GENERAL_OBJECT);
2157+
MLX5_SET(general_obj_in_cmd_hdr, in, obj_type, obj_type);
2158+
MLX5_SET(general_obj_in_cmd_hdr, in, obj_id, obj_id);
2159+
2160+
return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
2161+
}
2162+
20932163
static void destroy_msg_cache(struct mlx5_core_dev *dev)
20942164
{
20952165
struct cmd_msg_cache *ch;

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,22 @@ do { \
9797
__func__, __LINE__, current->pid, \
9898
##__VA_ARGS__)
9999

100+
#define ACCESS_KEY_LEN 32
101+
#define FT_ID_FT_TYPE_OFFSET 24
102+
103+
struct mlx5_cmd_allow_other_vhca_access_attr {
104+
u16 obj_type;
105+
u32 obj_id;
106+
u8 access_key[ACCESS_KEY_LEN];
107+
};
108+
109+
struct mlx5_cmd_alias_obj_create_attr {
110+
u32 obj_id;
111+
u16 vhca_id;
112+
u16 obj_type;
113+
u8 access_key[ACCESS_KEY_LEN];
114+
};
115+
100116
static inline void mlx5_printk(struct mlx5_core_dev *dev, int level, const char *format, ...)
101117
{
102118
struct device *device = dev->device;
@@ -343,6 +359,12 @@ bool mlx5_eth_supported(struct mlx5_core_dev *dev);
343359
bool mlx5_rdma_supported(struct mlx5_core_dev *dev);
344360
bool mlx5_vnet_supported(struct mlx5_core_dev *dev);
345361
bool mlx5_same_hw_devs(struct mlx5_core_dev *dev, struct mlx5_core_dev *peer_dev);
362+
int mlx5_cmd_allow_other_vhca_access(struct mlx5_core_dev *dev,
363+
struct mlx5_cmd_allow_other_vhca_access_attr *attr);
364+
int mlx5_cmd_alias_obj_create(struct mlx5_core_dev *dev,
365+
struct mlx5_cmd_alias_obj_create_attr *alias_attr,
366+
u32 *obj_id);
367+
int mlx5_cmd_alias_obj_destroy(struct mlx5_core_dev *dev, u32 obj_id, u16 obj_type);
346368

347369
static inline u16 mlx5_core_ec_vf_vport_base(const struct mlx5_core_dev *dev)
348370
{

0 commit comments

Comments
 (0)