-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net/mlx5_core: Introduce flow steering firmware commands
Introduce new Flow Steering (FS) firmware commands, in-order to support the new flow steering infrastructure. Signed-off-by: Maor Gottlieb <maorg@mellanox.com> Signed-off-by: Moni Shoua <monis@mellanox.com> Signed-off-by: Matan Barak <matanb@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Maor Gottlieb
authored and
David S. Miller
committed
Dec 12, 2015
1 parent
108805f
commit 26a8145
Showing
6 changed files
with
455 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,239 @@ | ||
/* | ||
* Copyright (c) 2015, Mellanox Technologies. All rights reserved. | ||
* | ||
* This software is available to you under a choice of one of two | ||
* licenses. You may choose to be licensed under the terms of the GNU | ||
* General Public License (GPL) Version 2, available from the file | ||
* COPYING in the main directory of this source tree, or the | ||
* OpenIB.org BSD license below: | ||
* | ||
* Redistribution and use in source and binary forms, with or | ||
* without modification, are permitted provided that the following | ||
* conditions are met: | ||
* | ||
* - Redistributions of source code must retain the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer. | ||
* | ||
* - Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials | ||
* provided with the distribution. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
#include <linux/mlx5/driver.h> | ||
#include <linux/mlx5/device.h> | ||
#include <linux/mlx5/mlx5_ifc.h> | ||
|
||
#include "fs_core.h" | ||
#include "fs_cmd.h" | ||
#include "mlx5_core.h" | ||
|
||
int mlx5_cmd_create_flow_table(struct mlx5_core_dev *dev, | ||
enum fs_flow_table_type type, unsigned int level, | ||
unsigned int log_size, unsigned int *table_id) | ||
{ | ||
u32 out[MLX5_ST_SZ_DW(create_flow_table_out)]; | ||
u32 in[MLX5_ST_SZ_DW(create_flow_table_in)]; | ||
int err; | ||
|
||
memset(in, 0, sizeof(in)); | ||
|
||
MLX5_SET(create_flow_table_in, in, opcode, | ||
MLX5_CMD_OP_CREATE_FLOW_TABLE); | ||
|
||
MLX5_SET(create_flow_table_in, in, table_type, type); | ||
MLX5_SET(create_flow_table_in, in, level, level); | ||
MLX5_SET(create_flow_table_in, in, log_size, log_size); | ||
|
||
memset(out, 0, sizeof(out)); | ||
err = mlx5_cmd_exec_check_status(dev, in, sizeof(in), out, | ||
sizeof(out)); | ||
|
||
if (!err) | ||
*table_id = MLX5_GET(create_flow_table_out, out, | ||
table_id); | ||
return err; | ||
} | ||
|
||
int mlx5_cmd_destroy_flow_table(struct mlx5_core_dev *dev, | ||
struct mlx5_flow_table *ft) | ||
{ | ||
u32 in[MLX5_ST_SZ_DW(destroy_flow_table_in)]; | ||
u32 out[MLX5_ST_SZ_DW(destroy_flow_table_out)]; | ||
|
||
memset(in, 0, sizeof(in)); | ||
memset(out, 0, sizeof(out)); | ||
|
||
MLX5_SET(destroy_flow_table_in, in, opcode, | ||
MLX5_CMD_OP_DESTROY_FLOW_TABLE); | ||
MLX5_SET(destroy_flow_table_in, in, table_type, ft->type); | ||
MLX5_SET(destroy_flow_table_in, in, table_id, ft->id); | ||
|
||
return mlx5_cmd_exec_check_status(dev, in, sizeof(in), out, | ||
sizeof(out)); | ||
} | ||
|
||
int mlx5_cmd_create_flow_group(struct mlx5_core_dev *dev, | ||
struct mlx5_flow_table *ft, | ||
u32 *in, | ||
unsigned int *group_id) | ||
{ | ||
int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in); | ||
u32 out[MLX5_ST_SZ_DW(create_flow_group_out)]; | ||
int err; | ||
|
||
memset(out, 0, sizeof(out)); | ||
|
||
MLX5_SET(create_flow_group_in, in, opcode, | ||
MLX5_CMD_OP_CREATE_FLOW_GROUP); | ||
MLX5_SET(create_flow_group_in, in, table_type, ft->type); | ||
MLX5_SET(create_flow_group_in, in, table_id, ft->id); | ||
|
||
err = mlx5_cmd_exec_check_status(dev, in, | ||
inlen, out, | ||
sizeof(out)); | ||
if (!err) | ||
*group_id = MLX5_GET(create_flow_group_out, out, | ||
group_id); | ||
|
||
return err; | ||
} | ||
|
||
int mlx5_cmd_destroy_flow_group(struct mlx5_core_dev *dev, | ||
struct mlx5_flow_table *ft, | ||
unsigned int group_id) | ||
{ | ||
u32 out[MLX5_ST_SZ_DW(destroy_flow_group_out)]; | ||
u32 in[MLX5_ST_SZ_DW(destroy_flow_group_in)]; | ||
|
||
memset(in, 0, sizeof(in)); | ||
memset(out, 0, sizeof(out)); | ||
|
||
MLX5_SET(destroy_flow_group_in, in, opcode, | ||
MLX5_CMD_OP_DESTROY_FLOW_GROUP); | ||
MLX5_SET(destroy_flow_group_in, in, table_type, ft->type); | ||
MLX5_SET(destroy_flow_group_in, in, table_id, ft->id); | ||
MLX5_SET(destroy_flow_group_in, in, group_id, group_id); | ||
|
||
return mlx5_cmd_exec_check_status(dev, in, sizeof(in), out, | ||
sizeof(out)); | ||
} | ||
|
||
static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev, | ||
int opmod, int modify_mask, | ||
struct mlx5_flow_table *ft, | ||
unsigned group_id, | ||
struct fs_fte *fte) | ||
{ | ||
unsigned int inlen = MLX5_ST_SZ_BYTES(set_fte_in) + | ||
fte->dests_size * MLX5_ST_SZ_BYTES(dest_format_struct); | ||
u32 out[MLX5_ST_SZ_DW(set_fte_out)]; | ||
struct mlx5_flow_rule *dst; | ||
void *in_flow_context; | ||
void *in_match_value; | ||
void *in_dests; | ||
u32 *in; | ||
int err; | ||
|
||
in = mlx5_vzalloc(inlen); | ||
if (!in) { | ||
mlx5_core_warn(dev, "failed to allocate inbox\n"); | ||
return -ENOMEM; | ||
} | ||
|
||
MLX5_SET(set_fte_in, in, opcode, MLX5_CMD_OP_SET_FLOW_TABLE_ENTRY); | ||
MLX5_SET(set_fte_in, in, op_mod, opmod); | ||
MLX5_SET(set_fte_in, in, modify_enable_mask, modify_mask); | ||
MLX5_SET(set_fte_in, in, table_type, ft->type); | ||
MLX5_SET(set_fte_in, in, table_id, ft->id); | ||
MLX5_SET(set_fte_in, in, flow_index, fte->index); | ||
|
||
in_flow_context = MLX5_ADDR_OF(set_fte_in, in, flow_context); | ||
MLX5_SET(flow_context, in_flow_context, group_id, group_id); | ||
MLX5_SET(flow_context, in_flow_context, flow_tag, fte->flow_tag); | ||
MLX5_SET(flow_context, in_flow_context, action, fte->action); | ||
MLX5_SET(flow_context, in_flow_context, destination_list_size, | ||
fte->dests_size); | ||
in_match_value = MLX5_ADDR_OF(flow_context, in_flow_context, | ||
match_value); | ||
memcpy(in_match_value, &fte->val, MLX5_ST_SZ_BYTES(fte_match_param)); | ||
|
||
in_dests = MLX5_ADDR_OF(flow_context, in_flow_context, destination); | ||
list_for_each_entry(dst, &fte->node.children, node.list) { | ||
unsigned int id; | ||
|
||
MLX5_SET(dest_format_struct, in_dests, destination_type, | ||
dst->dest_attr.type); | ||
if (dst->dest_attr.type == | ||
MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE) | ||
id = dst->dest_attr.ft->id; | ||
else | ||
id = dst->dest_attr.tir_num; | ||
MLX5_SET(dest_format_struct, in_dests, destination_id, id); | ||
in_dests += MLX5_ST_SZ_BYTES(dest_format_struct); | ||
} | ||
memset(out, 0, sizeof(out)); | ||
err = mlx5_cmd_exec_check_status(dev, in, inlen, out, | ||
sizeof(out)); | ||
kvfree(in); | ||
|
||
return err; | ||
} | ||
|
||
int mlx5_cmd_create_fte(struct mlx5_core_dev *dev, | ||
struct mlx5_flow_table *ft, | ||
unsigned group_id, | ||
struct fs_fte *fte) | ||
{ | ||
return mlx5_cmd_set_fte(dev, 0, 0, ft, group_id, fte); | ||
} | ||
|
||
int mlx5_cmd_update_fte(struct mlx5_core_dev *dev, | ||
struct mlx5_flow_table *ft, | ||
unsigned group_id, | ||
struct fs_fte *fte) | ||
{ | ||
int opmod; | ||
int modify_mask; | ||
int atomic_mod_cap = MLX5_CAP_FLOWTABLE(dev, | ||
flow_table_properties_nic_receive. | ||
flow_modify_en); | ||
if (!atomic_mod_cap) | ||
return -ENOTSUPP; | ||
opmod = 1; | ||
modify_mask = 1 << | ||
MLX5_SET_FTE_MODIFY_ENABLE_MASK_DESTINATION_LIST; | ||
|
||
return mlx5_cmd_set_fte(dev, opmod, modify_mask, ft, group_id, fte); | ||
} | ||
|
||
int mlx5_cmd_delete_fte(struct mlx5_core_dev *dev, | ||
struct mlx5_flow_table *ft, | ||
unsigned int index) | ||
{ | ||
u32 out[MLX5_ST_SZ_DW(delete_fte_out)]; | ||
u32 in[MLX5_ST_SZ_DW(delete_fte_in)]; | ||
int err; | ||
|
||
memset(in, 0, sizeof(in)); | ||
memset(out, 0, sizeof(out)); | ||
|
||
MLX5_SET(delete_fte_in, in, opcode, MLX5_CMD_OP_DELETE_FLOW_TABLE_ENTRY); | ||
MLX5_SET(delete_fte_in, in, table_type, ft->type); | ||
MLX5_SET(delete_fte_in, in, table_id, ft->id); | ||
MLX5_SET(delete_fte_in, in, flow_index, index); | ||
|
||
err = mlx5_cmd_exec_check_status(dev, in, sizeof(in), out, sizeof(out)); | ||
|
||
return err; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (c) 2015, Mellanox Technologies. All rights reserved. | ||
* | ||
* This software is available to you under a choice of one of two | ||
* licenses. You may choose to be licensed under the terms of the GNU | ||
* General Public License (GPL) Version 2, available from the file | ||
* COPYING in the main directory of this source tree, or the | ||
* OpenIB.org BSD license below: | ||
* | ||
* Redistribution and use in source and binary forms, with or | ||
* without modification, are permitted provided that the following | ||
* conditions are met: | ||
* | ||
* - Redistributions of source code must retain the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer. | ||
* | ||
* - Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials | ||
* provided with the distribution. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
#ifndef _MLX5_FS_CMD_ | ||
#define _MLX5_FS_CMD_ | ||
|
||
int mlx5_cmd_create_flow_table(struct mlx5_core_dev *dev, | ||
enum fs_flow_table_type type, unsigned int level, | ||
unsigned int log_size, unsigned int *table_id); | ||
|
||
int mlx5_cmd_destroy_flow_table(struct mlx5_core_dev *dev, | ||
struct mlx5_flow_table *ft); | ||
|
||
int mlx5_cmd_create_flow_group(struct mlx5_core_dev *dev, | ||
struct mlx5_flow_table *ft, | ||
u32 *in, unsigned int *group_id); | ||
|
||
int mlx5_cmd_destroy_flow_group(struct mlx5_core_dev *dev, | ||
struct mlx5_flow_table *ft, | ||
unsigned int group_id); | ||
|
||
int mlx5_cmd_create_fte(struct mlx5_core_dev *dev, | ||
struct mlx5_flow_table *ft, | ||
unsigned group_id, | ||
struct fs_fte *fte); | ||
|
||
int mlx5_cmd_update_fte(struct mlx5_core_dev *dev, | ||
struct mlx5_flow_table *ft, | ||
unsigned group_id, | ||
struct fs_fte *fte); | ||
|
||
int mlx5_cmd_delete_fte(struct mlx5_core_dev *dev, | ||
struct mlx5_flow_table *ft, | ||
unsigned int index); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright (c) 2015, Mellanox Technologies. All rights reserved. | ||
* | ||
* This software is available to you under a choice of one of two | ||
* licenses. You may choose to be licensed under the terms of the GNU | ||
* General Public License (GPL) Version 2, available from the file | ||
* COPYING in the main directory of this source tree, or the | ||
* OpenIB.org BSD license below: | ||
* | ||
* Redistribution and use in source and binary forms, with or | ||
* without modification, are permitted provided that the following | ||
* conditions are met: | ||
* | ||
* - Redistributions of source code must retain the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer. | ||
* | ||
* - Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials | ||
* provided with the distribution. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
#ifndef _MLX5_FS_CORE_ | ||
#define _MLX5_FS_CORE_ | ||
|
||
#include <linux/mlx5/fs.h> | ||
|
||
enum fs_node_type { | ||
FS_TYPE_NAMESPACE, | ||
FS_TYPE_PRIO, | ||
FS_TYPE_FLOW_TABLE, | ||
FS_TYPE_FLOW_GROUP, | ||
FS_TYPE_FLOW_ENTRY, | ||
FS_TYPE_FLOW_DEST | ||
}; | ||
|
||
enum fs_flow_table_type { | ||
FS_FT_NIC_RX = 0x0, | ||
}; | ||
|
||
enum fs_fte_status { | ||
FS_FTE_STATUS_EXISTING = 1UL << 0, | ||
}; | ||
|
||
struct fs_node { | ||
struct list_head list; | ||
struct list_head children; | ||
enum fs_node_type type; | ||
}; | ||
|
||
struct mlx5_flow_rule { | ||
struct fs_node node; | ||
struct mlx5_flow_destination dest_attr; | ||
}; | ||
|
||
struct mlx5_flow_table { | ||
struct fs_node node; | ||
u32 id; | ||
enum fs_flow_table_type type; | ||
}; | ||
|
||
struct fs_fte { | ||
struct fs_node node; | ||
u32 val[MLX5_ST_SZ_DW(fte_match_param)]; | ||
u32 dests_size; | ||
u32 flow_tag; | ||
u32 index; | ||
u32 action; | ||
}; | ||
|
||
#endif |
Oops, something went wrong.