Flow actions to mutate packets
Subsystems (6)
cover Flow actions to mutate packets
From: Leon Romanovsky <[email protected]>
Hi,
This series from Mark is marked as RFC due to the fact that it is under final stages of internal review - commit messages, patch reordering and internal agreement if "{net, RDMA}/mlx5: Rename encap to reformat packet" is needed.
Because the main logic and functionality are not expected to change, we would like to post it the mailing list and gather broader feedback than we can achieve internally.
We will resubmit it without RFC tag once review will complete.
Thanks
------------------------------------------------------------------------
Quoted 1 line
From Mark:
This series exposes the ability to create flow actions which can mutate packet headers. We do that by exposing two new verbs:
* modify header - can change existing packet headers. packet
* reformat - can encapsulate or decapsulate a packet.
Once created a flow action must be attached to a steering rule for it to take effect.
Thanks
Mark Bloch (18):
net/mlx5: Add proper NIC TX steering flow tables support net/mlx5: Export modify header alloc/dealloc functions net/mlx5: Add support for more namespaces when allocating modify
header
net/mlx5: Break encap/decap into two separated flags net/mlx5: Move header encap type to IFC header file
{net, RDMA}/mlx5: Rename encap to reformat packet net/mlx5: Expose new packet reformat capabilities net/mlx5: Allow passing a namespace on packet reformat allocation net/mlx5: Export packet reformat alloc/dealloc functions RDMA/mlx5: Add NIC TX steering support
RDMA/mlx5: Add a new flow action verb, modify header RDMA/mlx5: Enable attaching modify header to steering flows RDMA/mlx5: Enable decap and packet reformat on flow tables RDMA/uverbs: Add generic function to fill in flow action object RDMA/mlx5: Add new flow action verb, packet reformat RDMA/mlx5: Enable attaching DECAP action to steering flows RDMA/mlx5: Extend packet reformat verbs
RDMA/mlx5: Enable attaching packet reformat action to steering flows
.../infiniband/core/uverbs_std_types_flow_action.c | 7 +- drivers/infiniband/hw/mlx5/devx.c | 6 +- drivers/infiniband/hw/mlx5/flow.c | 280 +++++++++++++++++++++ drivers/infiniband/hw/mlx5/main.c | 65 +++-- drivers/infiniband/hw/mlx5/mlx5_ib.h | 14 ++ drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 8 +- .../mellanox/mlx5/core/diag/fs_tracepoint.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_rep.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 54 ++-- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 2 +- .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 9 +- drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 87 ++++--- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 57 +++-- .../net/ethernet/mellanox/mlx5/core/mlx5_core.h | 11 - include/linux/mlx5/device.h | 6 + include/linux/mlx5/fs.h | 20 +- include/linux/mlx5/mlx5_ifc.h | 71 ++++-- include/rdma/uverbs_std_types.h | 12 + include/uapi/rdma/mlx5_user_ioctl_cmds.h | 18 ++ include/uapi/rdma/mlx5_user_ioctl_verbs.h | 12 + 21 files changed, 591 insertions(+), 154 deletions(-)
RFC PATCH 1/18 net/mlx5: Add proper NIC TX steering flow tables support
From: Mark Bloch <[email protected]>
Expose the ability to add steering rules to NIC TX flow tables. For now, we are only adding TX bypass (egress) which is used by the RDMA side. While we are here clean the switch logic.
We expose the same number of priorities as the RX bypass.
--- drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 55 ++++++++++++++--------- include/linux/mlx5/device.h | 6 +++ 3 files changed, 41 insertions(+), 22 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +1 -1
@@ -753,8 +753,8 @@ const struct mlx5_flow_cmds *mlx5_fs_cmd_get_default(enum fs_flow_table_type typcase FS_FT_FDB :case FS_FT_SNIFFER_RX :case FS_FT_SNIFFER_TX : -return mlx5_fs_cmd_get_fw_cmds ();case FS_FT_NIC_TX : +return mlx5_fs_cmd_get_fw_cmds ();default :return mlx5_fs_cmd_get_stub_cmds (); }
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +34 -21
107 lines not on this page · raw message
include/linux/mlx5/device.h +6 -0
@@ -1113,6 +1113,12 @@ enum mlx5_qcam_feature_groups {#define MLX5_CAP_FLOWTABLE_NIC_RX_MAX (mdev, cap) \ MLX5_CAP_FLOWTABLE_MAX(mdev, flow_table_properties_nic_receive.cap) +#define MLX5_CAP_FLOWTABLE_NIC_TX (mdev, cap) \ + MLX5_CAP_FLOWTABLE(mdev, flow_table_properties_nic_transmit.cap) + +#define MLX5_CAP_FLOWTABLE_NIC_TX_MAX (mdev, cap) \ + MLX5_CAP_FLOWTABLE_MAX(mdev, flow_table_properties_nic_transmit.cap) +#define MLX5_CAP_FLOWTABLE_SNIFFER_RX (mdev, cap) \ MLX5_CAP_FLOWTABLE(mdev, flow_table_properties_nic_receive_sniffer.cap)
Re: [RFC PATCH mlx5-next 01/18] net/mlx5: Add proper NIC TX steering flow tables support
Quoted 7 lines · Leon Romanovsky
From: Mark Bloch <[email protected]>
Expose the ability to add steering rules to NIC TX flow tables. For now, we are only adding TX bypass (egress) which is used by the RDMA side. While we are here clean the switch logic.
We expose the same number of priorities as the RX bypass.
What is the use-case / model for priorities in TX steering?
Is/where this (tx prios) is used @ downstream patch?
Or.
RFC PATCH 2/18 net/mlx5: Export modify header alloc/dealloc functions
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
Those function will be used by the RDMA side to create modify header actions to be attached to flow steering rules via verbs.
--- drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 2 ++ drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h | 5 ----- include/linux/mlx5/fs.h | 6 ++++++ 3 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +2 -0
@@ -695,6 +695,7 @@ int mlx5_modify_header_alloc(struct mlx5_core_dev *dev,kfree (in);return err; } +EXPORT_SYMBOL (mlx5_modify_header_alloc);void mlx5_modify_header_dealloc (struct mlx5_core_dev *dev,u32 modify_header_id) {
@@ -709,6 +710,7 @@ void mlx5_modify_header_dealloc(struct mlx5_core_dev *dev, u32 modify_header_id)mlx5_cmd_exec (dev, in,sizeof (in), out,sizeof (out)); } +EXPORT_SYMBOL (mlx5_modify_header_dealloc);static const struct mlx5_flow_cmds mlx5_flow_cmds = { .create_flow_table = mlx5_cmd_create_flow_table,
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +0 -5
@@ -177,11 +177,6 @@ int mlx5_encap_alloc(struct mlx5_core_dev *dev, u32 *encap_id);void mlx5_encap_dealloc (struct mlx5_core_dev *dev,u32 encap_id); -int mlx5_modify_header_alloc (struct mlx5_core_dev *dev, -u8 namespace,u8 num_actions, -void *modify_actions,u32 *modify_header_id); -void mlx5_modify_header_dealloc (struct mlx5_core_dev *dev,u32 modify_header_id); -bool mlx5_lag_intf_add (struct mlx5_interface *intf,struct mlx5_priv *priv);int mlx5_query_mtpps (struct mlx5_core_dev *dev,u32 *mtpps,u32 mtpps_size);
include/linux/mlx5/fs.h +6 -0
@@ -194,4 +194,10 @@ int mlx5_fc_query(struct mlx5_core_dev *dev, struct mlx5_fc *counter,int mlx5_fs_add_rx_underlay_qpn (struct mlx5_core_dev *dev,u32 underlay_qpn);int mlx5_fs_remove_rx_underlay_qpn (struct mlx5_core_dev *dev,u32 underlay_qpn); +int mlx5_modify_header_alloc (struct mlx5_core_dev *dev, +u8 namespace,u8 num_actions, +void *modify_actions,u32 *modify_header_id); +void mlx5_modify_header_dealloc (struct mlx5_core_dev *dev, +u32 modify_header_id); +#endif
Re: [RFC PATCH mlx5-next 02/18] net/mlx5: Export modify header alloc/dealloc functions
Quoted 3 lines · Leon Romanovsky
From: Mark Bloch <[email protected]>
Those function will be used by the RDMA side to create modify header
function --> functions
Quoted 1 line
actions to be attached to flow steering rules via verbs.
RFC PATCH 3/18 net/mlx5: Add support for more namespaces when allocating modify header
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
There are RX and TX flow steering namespaces with different number of actions. Initialize them accordingly.
--- drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +5 -0
@@ -660,9 +660,14 @@ int mlx5_modify_header_alloc(struct mlx5_core_dev *dev, table_type =FS_FT_FDB ;break ;case MLX5_FLOW_NAMESPACE_KERNEL : +case MLX5_FLOW_NAMESPACE_BYPASS : max_actions =MLX5_CAP_FLOWTABLE_NIC_RX (dev, max_modify_header_actions); table_type =FS_FT_NIC_RX ;break ; +case MLX5_FLOW_NAMESPACE_EGRESS : + max_actions =MLX5_CAP_FLOWTABLE_NIC_TX (dev, max_modify_header_actions); + table_type =FS_FT_NIC_TX ; +break ;default :return -EOPNOTSUPP ; }
RFC PATCH 4/18 net/mlx5: Break encap/decap into two separated flags
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
Today we are able to attach encap and decap actions only to the FDB. In preparation to enable those actions on the NIC flow tables break the single flag into two.
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 3 ++- drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 7 ++++--- include/linux/mlx5/fs.h | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -1
@@ -524,7 +524,8 @@ static int esw_create_offloads_fast_fdb_table(struct mlx5_eswitch *esw) esw_size >>=1 ;if (esw->offloads.encap !=DEVLINK_ESWITCH_ENCAP_MODE_NONE ) - flags |=MLX5_FLOW_TABLE_TUNNEL_EN ; + flags |= (MLX5_FLOW_TABLE_TUNNEL_EN_ENCAP | +MLX5_FLOW_TABLE_TUNNEL_EN_DECAP ); fdb = mlx5_create_auto_grouped_flow_table(root_ns, FDB_FAST_PATH, esw_size,
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +4 -3
@@ -152,7 +152,8 @@ static int mlx5_cmd_create_flow_table(struct mlx5_core_dev *dev,struct mlx5_flow_table *next_ft, unsigned int *table_id, u32 flags) { - int en_encap_decap = !!(flags & MLX5_FLOW_TABLE_TUNNEL_EN); + int en_encap = !!(flags & MLX5_FLOW_TABLE_TUNNEL_EN_ENCAP); +int en_decap = !!(flags &MLX5_FLOW_TABLE_TUNNEL_EN_DECAP );u32 out[MLX5_ST_SZ_DW (create_flow_table_out)] = {0 };u32 in[MLX5_ST_SZ_DW (create_flow_table_in)] = {0 };int err;
@@ -169,9 +170,9 @@ static int mlx5_cmd_create_flow_table(struct mlx5_core_dev *dev, }MLX5_SET (create_flow_table_in, in, flow_table_context.decap_en, - en_encap_decap); + en_decap);MLX5_SET (create_flow_table_in, in, flow_table_context.encap_en, - en_encap_decap); + en_encap);switch (op_mod) {case FS_FT_OP_MOD_NORMAL :
include/linux/mlx5/fs.h +2 -1
@@ -45,7 +45,8 @@ enum { };enum { -MLX5_FLOW_TABLE_TUNNEL_EN =BIT (0 ), +MLX5_FLOW_TABLE_TUNNEL_EN_ENCAP =BIT (0 ), +MLX5_FLOW_TABLE_TUNNEL_EN_DECAP =BIT (1 ), };#define LEFTOVERS_RULE_NUM 2
Re: [RFC PATCH mlx5-next 04/18] net/mlx5: Break encap/decap into two separated flags
Quoted 4 lines · Leon Romanovsky
From: Mark Bloch <[email protected]>
Today we are able to attach encap and decap actions only to the FDB. In preparation to enable those actions on the NIC flow tables break
tables break --> tables, break
Quoted 1 line
the single flag into two.
RFC PATCH 5/18 net/mlx5: Move header encap type to IFC header file
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
Those bits are hardware specification bits and should be defined at the IFC header file.
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 5 ----- include/linux/mlx5/mlx5_ifc.h | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +0 -5
@@ -100,11 +100,6 @@ struct mlx5e_tc_flow_parse_attr {int mirred_ifindex; }; -enum { -MLX5_HEADER_TYPE_VXLAN =0x0 , -MLX5_HEADER_TYPE_NVGRE =0x1 , -}; -#define MLX5E_TC_TABLE_NUM_GROUPS 4#define MLX5E_TC_TABLE_MAX_GROUP_SIZE BIT(16)
include/linux/mlx5/mlx5_ifc.h +5 -0
@@ -4836,6 +4836,11 @@ struct mlx5_ifc_alloc_encap_header_out_bits {u8 reserved_at_60[0x20 ]; }; +enum { +MLX5_HEADER_TYPE_VXLAN =0x0 , +MLX5_HEADER_TYPE_NVGRE =0x1 , +}; +struct mlx5_ifc_alloc_encap_header_in_bits {u8 opcode[0x10 ];u8 reserved_at_10[0x10 ];
RFC PATCH 6/18 {net, RDMA}/mlx5: Rename encap to reformat packet
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
Renames all encap mlx5_{core,ib} code to use the new naming of packet reformat. No functional change is introduced. This is done because the original naming didn't reflect correctly the operation being done by this action. For example not only can we encapsulate a packet, but also decapsulate it.
--- drivers/infiniband/hw/mlx5/devx.c | 6 +-- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 8 +-- .../mellanox/mlx5/core/diag/fs_tracepoint.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_rep.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 46 ++++++++-------- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 2 +- .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 8 +-- drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 63 ++++++++++++---------- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 2 +- .../net/ethernet/mellanox/mlx5/core/mlx5_core.h | 13 ++--- include/linux/mlx5/fs.h | 4 +- include/linux/mlx5/mlx5_ifc.h | 50 ++++++++--------- 13 files changed, 110 insertions(+), 98 deletions(-)
drivers/infiniband/hw/mlx5/devx.c +3 -3
@@ -286,7 +286,7 @@ static bool devx_is_obj_create_cmd(const void *in)case MLX5_CMD_OP_CREATE_FLOW_TABLE :case MLX5_CMD_OP_CREATE_FLOW_GROUP :case MLX5_CMD_OP_ALLOC_FLOW_COUNTER : -case MLX5_CMD_OP_ALLOC_ENCAP_HEADER : +case MLX5_CMD_OP_ALLOC_PACKET_REFORMAT_CONTEXT :case MLX5_CMD_OP_ALLOC_MODIFY_HEADER_CONTEXT :case MLX5_CMD_OP_CREATE_SCHEDULING_ELEMENT :case MLX5_CMD_OP_ADD_VXLAN_UDP_DPORT :
@@ -629,9 +629,9 @@ static void devx_obj_build_destroy_cmd(void *in, void *out, void *din,MLX5_SET (general_obj_in_cmd_hdr, din, opcode,MLX5_CMD_OP_DEALLOC_FLOW_COUNTER );break ; -case MLX5_CMD_OP_ALLOC_ENCAP_HEADER : +case MLX5_CMD_OP_ALLOC_PACKET_REFORMAT_CONTEXT :MLX5_SET (general_obj_in_cmd_hdr, din, opcode, -MLX5_CMD_OP_DEALLOC_ENCAP_HEADER ); +MLX5_CMD_OP_DEALLOC_PACKET_REFORMAT_CONTEXT );break ;case MLX5_CMD_OP_ALLOC_MODIFY_HEADER_CONTEXT : MLX5_SET(general_obj_in_cmd_hdr, din, opcode,
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +4 -4
@@ -307,7 +307,7 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op,case MLX5_CMD_OP_MODIFY_FLOW_TABLE :case MLX5_CMD_OP_SET_FLOW_TABLE_ENTRY :case MLX5_CMD_OP_SET_FLOW_TABLE_ROOT : -case MLX5_CMD_OP_DEALLOC_ENCAP_HEADER : +case MLX5_CMD_OP_DEALLOC_PACKET_REFORMAT_CONTEXT :case MLX5_CMD_OP_DEALLOC_MODIFY_HEADER_CONTEXT :case MLX5_CMD_OP_FPGA_DESTROY_QP :case MLX5_CMD_OP_DESTROY_GENERAL_OBJECT :
@@ -422,7 +422,7 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op,case MLX5_CMD_OP_QUERY_FLOW_TABLE_ENTRY :case MLX5_CMD_OP_ALLOC_FLOW_COUNTER :case MLX5_CMD_OP_QUERY_FLOW_COUNTER : -case MLX5_CMD_OP_ALLOC_ENCAP_HEADER : +case MLX5_CMD_OP_ALLOC_PACKET_REFORMAT_CONTEXT :case MLX5_CMD_OP_ALLOC_MODIFY_HEADER_CONTEXT :case MLX5_CMD_OP_FPGA_CREATE_QP :case MLX5_CMD_OP_FPGA_MODIFY_QP :
@@ -594,8 +594,8 @@ const char *mlx5_command_str(int command)MLX5_COMMAND_STR_CASE (DEALLOC_FLOW_COUNTER );MLX5_COMMAND_STR_CASE (QUERY_FLOW_COUNTER );MLX5_COMMAND_STR_CASE (MODIFY_FLOW_TABLE ); -MLX5_COMMAND_STR_CASE (ALLOC_ENCAP_HEADER ); -MLX5_COMMAND_STR_CASE (DEALLOC_ENCAP_HEADER ); +MLX5_COMMAND_STR_CASE (ALLOC_PACKET_REFORMAT_CONTEXT ); +MLX5_COMMAND_STR_CASE (DEALLOC_PACKET_REFORMAT_CONTEXT );MLX5_COMMAND_STR_CASE (ALLOC_MODIFY_HEADER_CONTEXT );MLX5_COMMAND_STR_CASE (DEALLOC_MODIFY_HEADER_CONTEXT );MLX5_COMMAND_STR_CASE (FPGA_CREATE_QP );
drivers/net/ethernet/mellanox/mlx5/core/diag/fs_tracepoint.h +1 -1
@@ -133,7 +133,7 @@ TRACE_EVENT(mlx5_fs_del_fg, {MLX5_FLOW_CONTEXT_ACTION_DROP, "DROP"},\ {MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, "FWD"},\ {MLX5_FLOW_CONTEXT_ACTION_COUNT, "CNT"},\ - {MLX5_FLOW_CONTEXT_ACTION_ENCAP, "ENCAP"},\ + {MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT_ID, "PACKET_REFORMAT"},\ {MLX5_FLOW_CONTEXT_ACTION_DECAP, "DECAP"},\ {MLX5_FLOW_CONTEXT_ACTION_MOD_HDR, "MOD_HDR"},\ {MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH, "VLAN_PUSH"},\
drivers/net/ethernet/mellanox/mlx5/core/en_rep.h +1 -1
@@ -123,7 +123,7 @@ struct mlx5e_encap_entry {*/ struct hlist_node encap_hlist;struct list_head flows; -u32 encap_id; +u32 packet_reformat_id;struct ip_tunnel_info tun_info;unsigned char h_dest[ETH_ALEN ];/* destination eth addr */
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +24 -22
154 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +1 -1
@@ -1748,7 +1748,7 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev) esw->enabled_vports =0 ; esw->mode =SRIOV_NONE ; esw->offloads.inline_mode =MLX5_INLINE_MODE_NONE ; -if (MLX5_CAP_ESW_FLOWTABLE_FDB (dev, encap) && +if (MLX5_CAP_ESW_FLOWTABLE_FDB (dev, reformat) &&MLX5_CAP_ESW_FLOWTABLE_FDB (dev, decap)) esw->offloads.encap =DEVLINK_ESWITCH_ENCAP_MODE_BASIC ;else
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +1 -1
@@ -260,7 +260,7 @@ struct mlx5_esw_flow_attr {u16 vlan_vid;u8 vlan_prio;bool vlan_handled; -u32 encap_id; +u32 packet_reformat_id;u32 mod_hdr_id;u8 match_level;struct mlx5e_tc_flow_parse_attr *parse_attr;
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +4 -4
@@ -122,8 +122,8 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,if (flow_act.action &MLX5_FLOW_CONTEXT_ACTION_MOD_HDR ) flow_act.modify_id = attr->mod_hdr_id; -if (flow_act.action &MLX5_FLOW_CONTEXT_ACTION_ENCAP ) - flow_act.encap_id = attr->encap_id; +if (flow_act.action &MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT_ID ) + flow_act.packet_reformat_id = attr->packet_reformat_id; rule =mlx5_add_flow_rules (ft, spec, &flow_act, dest, i);if (IS_ERR (rule))
@@ -524,7 +524,7 @@ static int esw_create_offloads_fast_fdb_table(struct mlx5_eswitch *esw) esw_size >>=1 ;if (esw->offloads.encap !=DEVLINK_ESWITCH_ENCAP_MODE_NONE ) - flags |= (MLX5_FLOW_TABLE_TUNNEL_EN_ENCAP | + flags |= (MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT |MLX5_FLOW_TABLE_TUNNEL_EN_DECAP ); fdb = mlx5_create_auto_grouped_flow_table(root_ns, FDB_FAST_PATH,
@@ -1240,7 +1240,7 @@ int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, u8 encap)return err;if (encap !=DEVLINK_ESWITCH_ENCAP_MODE_NONE && - (!MLX5_CAP_ESW_FLOWTABLE_FDB (dev, encap) || + (!MLX5_CAP_ESW_FLOWTABLE_FDB (dev, reformat) || !MLX5_CAP_ESW_FLOWTABLE_FDB (dev, decap)))return -EOPNOTSUPP ;
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +36 -27
112 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +1 -1
@@ -1398,7 +1398,7 @@ static bool check_conflicting_actions(u32 action1, u32 action2)return false; if (xored_actions & (MLX5_FLOW_CONTEXT_ACTION_DROP | - MLX5_FLOW_CONTEXT_ACTION_ENCAP | + MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT_ID | MLX5_FLOW_CONTEXT_ACTION_DECAP | MLX5_FLOW_CONTEXT_ACTION_MOD_HDR | MLX5_FLOW_CONTEXT_ACTION_VLAN_POP |
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +7 -6
@@ -170,12 +170,13 @@ struct mlx5_core_dev *mlx5_get_next_phys_dev(struct mlx5_core_dev *dev);void mlx5_dev_list_lock (void );void mlx5_dev_list_unlock (void );int mlx5_dev_list_trylock (void ); -int mlx5_encap_alloc (struct mlx5_core_dev *dev, -int header_type, -size_t size, -void *encap_header, -u32 *encap_id); -void mlx5_encap_dealloc (struct mlx5_core_dev *dev,u32 encap_id); +int mlx5_packet_reformat_alloc (struct mlx5_core_dev *dev, +int reformat_type, +size_t size, +void *reformat_data, +u32 *packet_reformat_id); +void mlx5_packet_reformat_dealloc (struct mlx5_core_dev *dev, +u32 packet_reformat_id);bool mlx5_lag_intf_add (struct mlx5_interface *intf,struct mlx5_priv *priv);
include/linux/mlx5/fs.h +2 -2
@@ -45,7 +45,7 @@ enum { };enum { -MLX5_FLOW_TABLE_TUNNEL_EN_ENCAP =BIT (0 ), +MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT =BIT (0 ),MLX5_FLOW_TABLE_TUNNEL_EN_DECAP =BIT (1 ), };
@@ -158,7 +158,7 @@ struct mlx5_flow_act {u32 action;bool has_flow_tag;u32 flow_tag; -u32 encap_id; +u32 packet_reformat_id;u32 modify_id;uintptr_t esp_id;struct mlx5_fs_vlan vlan;
include/linux/mlx5/mlx5_ifc.h +25 -25
149 lines not on this page · raw message
RFC PATCH 7/18 net/mlx5: Expose new packet reformat capabilities
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
Expose new abilities when creating a packet reformat context.
The new types which can be created are:MLX5_REFORMAT_TYPE_L2_TO_L2_TUNNEL: Ability to create generic encap opertion to be done by the HW.
MLX5_REFORMAT_TYPE_L3_TUNNEL_TO_L2: Ability to create generic decap opertion where the inner packet doesn't contain L2.
MLX5_REFORMAT_TYPE_L2_TO_L3_TUNNEL: Ability to create generic encap opertion to be done by the HW. The L2 of the original packet is dropped.
--- include/linux/mlx5/mlx5_ifc.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
include/linux/mlx5/mlx5_ifc.h +17 -3
@@ -341,8 +341,13 @@ struct mlx5_ifc_flow_table_prop_layout_bits {u8 reserved_at_9[0x1 ];u8 pop_vlan[0x1 ];u8 push_vlan[0x1 ]; -u8 reserved_at_c[0x14 ]; - +u8 reserved_at_c[0x3 ]; +u8 reformat_and_vlan_action[0x1 ]; +u8 reserved_at_10[0x2 ]; +u8 reformat_l3_tunnel_to_l2[0x1 ]; +u8 reformat_l2_to_l3_tunnel[0x1 ]; +u8 reformat_and_modify_action[0x1 ]; +u8 reserved_at_15[0xb ];u8 reserved_at_20[0x2 ];u8 log_max_ft_size[0x6 ];u8 log_max_modify_header_context[0x8 ];
@@ -551,7 +556,13 @@ struct mlx5_ifc_flow_table_nic_cap_bits {u8 nic_rx_multi_path_tirs[0x1 ];u8 nic_rx_multi_path_tirs_fts[0x1 ];u8 allow_sniffer_and_nic_rx_shared_tir[0x1 ]; -u8 reserved_at_3[0x1fd ]; +u8 reserved_at_3[0x1d ]; +u8 encap_general_header[0x1 ]; +u8 reserved_at_21[0xa ]; +u8 log_max_packet_reformat_context[0x5 ]; +u8 reserved_at_30[0x6 ]; +u8 max_encap_header_size[0xa ]; +u8 reserved_at_40[0x1c0 ];struct mlx5_ifc_flow_table_prop_layout_bits flow_table_properties_nic_receive;
@@ -4839,6 +4850,9 @@ struct mlx5_ifc_alloc_packet_reformat_context_out_bits {enum {MLX5_REFORMAT_TYPE_L2_TO_VXLAN =0x0 ,MLX5_REFORMAT_TYPE_L2_TO_NVGRE =0x1 , +MLX5_REFORMAT_TYPE_L2_TO_L2_TUNNEL =0x2 , +MLX5_REFORMAT_TYPE_L3_TUNNEL_TO_L2 =0x3 , +MLX5_REFORMAT_TYPE_L2_TO_L3_TUNNEL =0x4 , };struct mlx5_ifc_alloc_packet_reformat_context_in_bits {
Re: [RFC PATCH mlx5-next 07/18] net/mlx5: Expose new packet reformat capabilities
Quoted 7 lines · Leon Romanovsky
From: Mark Bloch <[email protected]>
Expose new abilities when creating a packet reformat context.
The new types which can be created are:
MLX5_REFORMAT_TYPE_L2_TO_L2_TUNNEL: Ability to create generic encap opertion to be done by the HW.
opertion -> fix
Quoted 2 lines
MLX5_REFORMAT_TYPE_L3_TUNNEL_TO_L2: Ability to create generic decap opertion where the inner packet doesn't contain L2.
opertion -> fix
Quoted 3 lines
MLX5_REFORMAT_TYPE_L2_TO_L3_TUNNEL: Ability to create generic encap opertion to be done by the HW. The L2 of the original packet
opertion -> fix
Quoted 13 lines
is dropped.
Signed-off-by Mark Bloch <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>--- include/linux/mlx5/mlx5_ifc.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)include/linux/mlx5/mlx5_ifc.h +0
-0
include/linux/mlx5/mlx5_ifc.h struct mlx5_ifc_flow_table_prop_layout_bits { · line 345
Quoted 7 lines
include/linux/mlx5/mlx5_ifc.h +2
-2@@ -341,8 +341,13 @@ struct mlx5_ifc_flow_table_prop_layout_bits {u8 reserved_at_9[0x1 ];u8 pop_vlan[0x1 ];u8 push_vlan[0x1 ]; -u8 reserved_at_c[0x14 ]; - +u8 reserved_at_c[0x3 ]; +u8 reformat_and_vlan_action[0x1 ];
unused in downstream patches
what is this BTW?
include/linux/mlx5/mlx5_ifc.h struct mlx5_ifc_flow_table_prop_layout_bits { · line 349
Quoted 4 lines
include/linux/mlx5/mlx5_ifc.h +4
-0+u8 reserved_at_10[0x2 ]; +u8 reformat_l3_tunnel_to_l2[0x1 ]; +u8 reformat_l2_to_l3_tunnel[0x1 ]; +u8 reformat_and_modify_action[0x1 ];
unused in downstream patches
what is this BTW?
Quoted 6 lines
include/linux/mlx5/mlx5_ifc.h +1
-0+u8 reserved_at_15[0xb ];u8 reserved_at_20[0x2 ];u8 log_max_ft_size[0x6 ];u8 log_max_modify_header_context[0x8 ];@@ -551,7 +556,13 @@ struct mlx5_ifc_flow_table_nic_cap_bits {u8 nic_rx_multi_path_tirs[0x1 ];
include/linux/mlx5/mlx5_ifc.h struct mlx5_ifc_flow_table_nic_cap_bits { · line 565
Quoted 10 lines
include/linux/mlx5/mlx5_ifc.h +7
-1u8 nic_rx_multi_path_tirs_fts[0x1 ];u8 allow_sniffer_and_nic_rx_shared_tir[0x1 ]; -u8 reserved_at_3[0x1fd ]; +u8 reserved_at_3[0x1d ]; +u8 encap_general_header[0x1 ]; +u8 reserved_at_21[0xa ]; +u8 log_max_packet_reformat_context[0x5 ]; +u8 reserved_at_30[0x6 ]; +u8 max_encap_header_size[0xa ]; +u8 reserved_at_40[0x1c0 ];
we are inconsistent, for some fields the term "encap" remained wheres for other fields we moved to use "reformat" or "packet reformat" etc
RE: [RFC PATCH mlx5-next 07/18] net/mlx5: Expose new packet reformat capabilities
Quoted 29 lines
-----Original Message-----
From: Or Gerlitz [mailto:[email protected]]
Sent: Monday, July 16, 2018 2:33 PM
To: Mark Bloch <[email protected]>
Cc: Doug Ledford <[email protected]>; Jason Gunthorpe <[email protected]>; Leon Romanovsky <[email protected]>; RDMA mailing list <[email protected]>; Saeed Mahameed <[email protected]>; linux-netdev <[email protected]>
Subject: Re: [RFC PATCH mlx5-next 07/18] net/mlx5: Expose new packet reformat capabilitiesQuoted 6 lines · Leon Romanovsky
From: Mark Bloch <[email protected]>
Expose new abilities when creating a packet reformat context.
The new types which can be created are:
MLX5_REFORMAT_TYPE_L2_TO_L2_TUNNEL: Ability to create genericencap
Quoted 1 line
opertion to be done by the HW.
opertion -> fix
Quoted 1 line
MLX5_REFORMAT_TYPE_L3_TUNNEL_TO_L2: Ability to create genericdecap
Quoted 1 line
opertion where the inner packet doesn't contain L2.
Quoted 8 lines
opertion -> fix
Quoted 2 lines
MLX5_REFORMAT_TYPE_L2_TO_L3_TUNNEL: Ability to create genericencap
Quoted 1 line
opertion to be done by the HW. The L2 of the original packet
opertion -> fix
Thx, will be fixed.
Quoted 9 lines
Quoted 9 lines
is dropped.
Signed-off-by Mark Bloch <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>--- include/linux/mlx5/mlx5_ifc.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
Quoted 15 lines
include/linux/mlx5/mlx5_ifc.h struct mlx5_ifc_flow_table_prop_layout_bits { · line 345
Quoted 12 lines
include/linux/mlx5/mlx5_ifc.h +2
-2@@ -341,8 +341,13 @@ struct mlx5_ifc_flow_table_prop_layout_bits {u8 reserved_at_9[0x1 ];u8 pop_vlan[0x1 ];u8 push_vlan[0x1 ]; -u8 reserved_at_c[0x14 ]; - +u8 reserved_at_c[0x3 ]; +u8 reformat_and_vlan_action[0x1 ];unused in downstream patches
what is this BTW?
It's needed for competence for all the bits that deal with packet reformat. The bit itself indicates whatever the flow table supports reformat action with a vlan action (pop/push) in the same rule.
Quoted 8 lines
include/linux/mlx5/mlx5_ifc.h struct mlx5_ifc_flow_table_prop_layout_bits { · line 349
Quoted 5 lines
include/linux/mlx5/mlx5_ifc.h +4
-0+u8 reserved_at_10[0x2 ]; +u8 reformat_l3_tunnel_to_l2[0x1 ]; +u8 reformat_l2_to_l3_tunnel[0x1 ]; +u8 reformat_and_modify_action[0x1 ];unused in downstream patches
what is this BTW?
Bits to indicate whatever the flow table support the new packet reformat modes, and setting reformat action with modify action in the same rule.
Those will be used once a FW which expose them is made available, but as a feature/ cap flags I would like to expose them now.
Mark
Quoted 22 lines
Quoted 9 lines
include/linux/mlx5/mlx5_ifc.h +1
-0+u8 reserved_at_15[0xb ];u8 reserved_at_20[0x2 ];u8 log_max_ft_size[0x6 ];u8 log_max_modify_header_context[0x8 ];@@ -551,7 +556,13 @@ struct mlx5_ifc_flow_table_nic_cap_bits {u8 nic_rx_multi_path_tirs[0x1 ];include/linux/mlx5/mlx5_ifc.h struct mlx5_ifc_flow_table_nic_cap_bits { · line 565
Quoted 10 lines
include/linux/mlx5/mlx5_ifc.h +7
-1u8 nic_rx_multi_path_tirs_fts[0x1 ];u8 allow_sniffer_and_nic_rx_shared_tir[0x1 ]; -u8 reserved_at_3[0x1fd ]; +u8 reserved_at_3[0x1d ]; +u8 encap_general_header[0x1 ]; +u8 reserved_at_21[0xa ]; +u8 log_max_packet_reformat_context[0x5 ]; +u8 reserved_at_30[0x6 ]; +u8 max_encap_header_size[0xa ]; +u8 reserved_at_40[0x1c0 ];we are inconsistent, for some fields the term "encap" remained wheres for other fields we moved to use "reformat" or "packet reformat" etc
RFC PATCH 8/18 net/mlx5: Allow passing a namespace on packet reformat allocation
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
Currently we attach packet reformat actions only to the FDB namespace, in preparation to be able to attach it to different namespaces, add the ability to pass the namespace as a parameter.
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 3 +++ drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +3 -0
@@ -925,6 +925,7 @@ void mlx5e_tc_encap_flows_add(struct mlx5e_priv *priv, err =mlx5_packet_reformat_alloc (priv->mdev, e->tunnel_type, e->encap_size, e->encap_header, +MLX5_FLOW_NAMESPACE_FDB , &e->packet_reformat_id);if (err) { mlx5_core_warn(priv->mdev, "Failed to offload cached encapsulation header, %d\n",
@@ -2314,6 +2315,7 @@ static int mlx5e_create_encap_header_ipv4(struct mlx5e_priv *priv, err =mlx5_packet_reformat_alloc (priv->mdev, e->tunnel_type, ipv4_encap_size, encap_header, +MLX5_FLOW_NAMESPACE_FDB , &e->packet_reformat_id);if (err) goto destroy_neigh_entry;
@@ -2422,6 +2424,7 @@ static int mlx5e_create_encap_header_ipv6(struct mlx5e_priv *priv, err =mlx5_packet_reformat_alloc (priv->mdev, e->tunnel_type, ipv6_encap_size, encap_header, +MLX5_FLOW_NAMESPACE_FDB , &e->packet_reformat_id);if (err) goto destroy_neigh_entry;
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +7 -1
@@ -593,16 +593,22 @@ int mlx5_packet_reformat_alloc(struct mlx5_core_dev *dev,int reformat_type, size_t size, void *reformat_data, + int namespace, u32 *packet_reformat_id) { - int max_encap_size = MLX5_CAP_ESW(dev, max_encap_header_size); u32 out[MLX5_ST_SZ_DW(alloc_packet_reformat_context_out)];void *packet_reformat_context_in; +int max_encap_size;void *reformat;int inlen;int err;u32 *in; +if (namespace ==MLX5_FLOW_NAMESPACE_FDB ) + max_encap_size =MLX5_CAP_ESW (dev, max_encap_header_size); +else + max_encap_size =MLX5_CAP_FLOWTABLE (dev, max_encap_header_size); +if (size > max_encap_size) {mlx5_core_warn (dev,"encap size %zd too big, max supported is %d\n" , size, max_encap_size);
RFC PATCH 9/18 net/mlx5: Export packet reformat alloc/dealloc functions
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
This will allow for the RDMA side to allocate packet reformat context.
--- drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 2 ++ drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h | 7 ------- include/linux/mlx5/fs.h | 9 +++++++++ 3 files changed, 11 insertions(+), 7 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +2 -0
@@ -644,6 +644,7 @@ int mlx5_packet_reformat_alloc(struct mlx5_core_dev *dev,kfree (in);return err; } +EXPORT_SYMBOL (mlx5_packet_reformat_alloc);void mlx5_packet_reformat_dealloc (struct mlx5_core_dev *dev,u32 packet_reformat_id)
@@ -659,6 +660,7 @@ void mlx5_packet_reformat_dealloc(struct mlx5_core_dev *dev,mlx5_cmd_exec (dev, in,sizeof (in), out,sizeof (out)); } +EXPORT_SYMBOL (mlx5_packet_reformat_dealloc); int mlx5_modify_header_alloc(struct mlx5_core_dev *dev, u8 namespace, u8 num_actions,
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +0 -7
@@ -170,13 +170,6 @@ struct mlx5_core_dev *mlx5_get_next_phys_dev(struct mlx5_core_dev *dev);void mlx5_dev_list_lock (void );void mlx5_dev_list_unlock (void );int mlx5_dev_list_trylock (void ); -int mlx5_packet_reformat_alloc (struct mlx5_core_dev *dev, -int reformat_type, -size_t size, -void *reformat_data, -u32 *packet_reformat_id); -void mlx5_packet_reformat_dealloc (struct mlx5_core_dev *dev, -u32 packet_reformat_id);bool mlx5_lag_intf_add (struct mlx5_interface *intf,struct mlx5_priv *priv);
include/linux/mlx5/fs.h +9 -0
@@ -201,4 +201,13 @@ int mlx5_modify_header_alloc(struct mlx5_core_dev *dev,void mlx5_modify_header_dealloc (struct mlx5_core_dev *dev,u32 modify_header_id); +int mlx5_packet_reformat_alloc (struct mlx5_core_dev *dev, +int reformat_type, +size_t size, +void *reformat_data, +int namespace, +u32 *packet_reformat_id); +void mlx5_packet_reformat_dealloc (struct mlx5_core_dev *dev, +u32 packet_reformat_id); +#endif
RFC PATCH 10/18 RDMA/mlx5: Add NIC TX steering support
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
Add support for proper NIC TX (egress) steering with multiple priorities. We expose the same number of priorities as the bypass (NIC RX) steering.
--- drivers/infiniband/hw/mlx5/main.c | 25 +++++++++++++++---------- drivers/infiniband/hw/mlx5/mlx5_ib.h | 1 + 2 files changed, 16 insertions(+), 10 deletions(-)
drivers/infiniband/hw/mlx5/main.c +15 -10
@@ -2885,7 +2885,7 @@ is_valid_esp_aes_gcm(struct mlx5_core_dev *mdev,* rules would be supported, always return VALID_SPEC_NA. */ if (!is_crypto) -return egress ?VALID_SPEC_INVALID :VALID_SPEC_NA ; +return VALID_SPEC_NA ;return is_crypto && is_ipsec && (!egress || (!is_drop && !flow_act->has_flow_tag)) ?
@@ -3060,21 +3060,26 @@ static struct mlx5_ib_flow_prio *get_flow_table(struct mlx5_ib_dev *dev, max_table_size =BIT (MLX5_CAP_FLOWTABLE_NIC_RX (dev->mdev, log_max_ft_size));if (flow_attr->type ==IB_FLOW_ATTR_NORMAL ) { -if (ft_type ==MLX5_IB_FT_TX ) - priority =0 ; -else if (flow_is_multicast_only (flow_attr) && - !dont_trap) +enum mlx5_flow_namespace_type fn_type; + +if (flow_is_multicast_only (flow_attr) && + !dont_trap) priority =MLX5_IB_FLOW_MCAST_PRIO ;else priority =ib_prio_to_core_prio (flow_attr->priority, dont_trap); - ns =mlx5_get_flow_namespace (dev->mdev, - ft_type ==MLX5_IB_FT_TX ? -MLX5_FLOW_NAMESPACE_EGRESS : -MLX5_FLOW_NAMESPACE_BYPASS ); +if (ft_type ==MLX5_IB_FT_RX ) { + fn_type =MLX5_FLOW_NAMESPACE_BYPASS ; + prio = &dev->flow_db->prios[priority]; + }else { + max_table_size =BIT (MLX5_CAP_FLOWTABLE_NIC_TX (dev->mdev, + log_max_ft_size)); + fn_type =MLX5_FLOW_NAMESPACE_EGRESS ; + prio = &dev->flow_db->egress_prios[priority]; + } + ns =mlx5_get_flow_namespace (dev->mdev, fn_type); num_entries =MLX5_FS_MAX_ENTRIES ; num_groups =MLX5_FS_MAX_TYPES ; - prio = &dev->flow_db->prios[priority]; }else if (flow_attr->type ==IB_FLOW_ATTR_ALL_DEFAULT || flow_attr->type ==IB_FLOW_ATTR_MC_DEFAULT ) { ns = mlx5_get_flow_namespace(dev->mdev,
drivers/infiniband/hw/mlx5/mlx5_ib.h +1 -0
@@ -188,6 +188,7 @@ struct mlx5_ib_flow_matcher {struct mlx5_ib_flow_db {struct mlx5_ib_flow_prio prios[MLX5_IB_NUM_FLOW_FT ]; +struct mlx5_ib_flow_prio egress_prios[MLX5_IB_NUM_FLOW_FT ];struct mlx5_ib_flow_prio sniffer[MLX5_IB_NUM_SNIFFER_FTS ];struct mlx5_ib_flow_prio egress[MLX5_IB_NUM_EGRESS_FTS ];struct mlx5_flow_table *lag_demux_ft;
RFC PATCH 11/18 RDMA/mlx5: Add a new flow action verb, modify header
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
Expose the ability to create a flow action which mutates packet headers. The data passed from userspace should be modify header actions as defined by Mellanox's PRM.
--- drivers/infiniband/hw/mlx5/flow.c | 126 ++++++++++++++++++++++++++++++ drivers/infiniband/hw/mlx5/main.c | 5 +- drivers/infiniband/hw/mlx5/mlx5_ib.h | 11 +++ include/uapi/rdma/mlx5_user_ioctl_cmds.h | 10 +++ include/uapi/rdma/mlx5_user_ioctl_verbs.h | 5 ++ 5 files changed, 156 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/flow.c +126 -0
@@ -8,6 +8,7 @@#include <rdma/uverbs_types.h> #include <rdma/uverbs_ioctl.h> #include <rdma/mlx5_user_ioctl_cmds.h> +#include <rdma/mlx5_user_ioctl_verbs.h> #include <rdma/ib_umem.h> #include <linux/mlx5/driver.h> #include <linux/mlx5/fs.h>
@@ -176,6 +177,111 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_MATCHER_CREATE)(struct ib_device *return err; } +static int mlx5_ib_ft_type_to_namespace (u8 table_type,u8 *namespace) +{ +switch (table_type) { +case MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_RX : + *namespace =MLX5_FLOW_NAMESPACE_BYPASS ; +break ; +case MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_TX : + *namespace =MLX5_FLOW_NAMESPACE_EGRESS ; +break ; +default : +return -EINVAL ; + } + +return 0 ; +} + +void mlx5_ib_destroy_flow_action_raw (struct mlx5_ib_flow_action *maction) +{ +switch (maction->flow_action_raw.sub_type) { +case MLX5_IB_FLOW_ACTION_MODIFY_HEADER : +mlx5_modify_header_dealloc (maction->flow_action_raw.dev->mdev, + maction->flow_action_raw.action_id); +break ; +default : +WARN_ON (true); +break ; + } +} + +static struct ib_flow_action * +mlx5_ib_create_modify_header (struct mlx5_ib_dev *dev,u8 ft_type, +u8 num_actions,void *in) +{ +struct mlx5_ib_flow_action *maction; +u8 namespace; +int ret; + + ret =mlx5_ib_ft_type_to_namespace (ft_type, &namespace); +if (ret) +return ERR_PTR (-EINVAL ); + + maction =kzalloc (sizeof (*maction),GFP_KERNEL ); +if (!maction) +return ERR_PTR (-ENOMEM ); + + ret =mlx5_modify_header_alloc (dev->mdev, namespace, num_actions, in, + &maction->flow_action_raw.action_id); + +if (ret) { +kfree (maction); +return ERR_PTR (ret); + } + maction->flow_action_raw.sub_type = +MLX5_IB_FLOW_ACTION_MODIFY_HEADER ; + maction->flow_action_raw.dev = dev; + +return &maction->ib_action; +} + +static bool mlx5_ib_modify_header_supported (struct mlx5_ib_dev *dev) +{ +return MLX5_CAP_FLOWTABLE_NIC_RX (dev->mdev, max_modify_header_actions) || +MLX5_CAP_FLOWTABLE_NIC_TX (dev->mdev, max_modify_header_actions); +} + +static int UVERBS_HANDLER (MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER )(struct ib_device *ib_dev, +struct ib_uverbs_file *file, +struct uverbs_attr_bundle *attrs) +{ +struct ib_uobject *uobj =uverbs_attr_get_uobject (attrs, +MLX5_IB_ATTR_CREATE_MODIFY_HEADER_HANDLE ); +struct mlx5_ib_dev *mdev =to_mdev (uobj->context->device); +struct ib_flow_action *action; +u8 ft_type; +void *in; +int len; + +if (!mlx5_ib_modify_header_supported (mdev)) +return -EOPNOTSUPP ; + + in =uverbs_attr_get_alloced_ptr (attrs, +MLX5_IB_ATTR_CREATE_MODIFY_HEADER_ACTIONS_PRM ); + len =uverbs_attr_get_len (attrs,MLX5_IB_ATTR_CREATE_MODIFY_HEADER_ACTIONS_PRM ); + +if (len %MLX5_UN_SZ_BYTES (set_action_in_add_action_in_auto)) +return -EINVAL ; + +uverbs_copy_from (&ft_type, attrs, +MLX5_IB_ATTR_CREATE_MODIFY_HEADER_FT_TYPE ); + + action =mlx5_ib_create_modify_header (mdev, ft_type, + len /MLX5_UN_SZ_BYTES (set_action_in_add_action_in_auto), + in); +if (IS_ERR (action)) +return PTR_ERR (action); + +atomic_set (&action->usecnt,0 ); + action->device = uobj->context->device; + action->type =IB_FLOW_ACTION_UNSPECIFIED ; + action->uobject = uobj; + uobj->object = action; + +return 0 ; +} + DECLARE_UVERBS_NAMED_METHOD( MLX5_IB_METHOD_CREATE_FLOW, UVERBS_ATTR_IDR(MLX5_IB_ATTR_CREATE_FLOW_HANDLE,
@@ -209,6 +315,25 @@ ADD_UVERBS_METHODS(mlx5_ib_fs, &UVERBS_METHOD (MLX5_IB_METHOD_CREATE_FLOW ), &UVERBS_METHOD(MLX5_IB_METHOD_DESTROY_FLOW)); +DECLARE_UVERBS_NAMED_METHOD ( +MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER , +UVERBS_ATTR_IDR (MLX5_IB_ATTR_CREATE_MODIFY_HEADER_HANDLE , +UVERBS_OBJECT_FLOW_ACTION , +UVERBS_ACCESS_NEW , +UA_MANDATORY ), +UVERBS_ATTR_PTR_IN (MLX5_IB_ATTR_CREATE_MODIFY_HEADER_ACTIONS_PRM , +UVERBS_ATTR_MIN_SIZE (MLX5_UN_SZ_BYTES (set_action_in_add_action_in_auto)), +UA_MANDATORY , +UA_ALLOC_AND_COPY ), +UVERBS_ATTR_PTR_IN (MLX5_IB_ATTR_CREATE_MODIFY_HEADER_FT_TYPE , +/* See enum mlx5_ib_uapi_flow_table_type */ +UVERBS_ATTR_TYPE (u8), +UA_MANDATORY )); + +ADD_UVERBS_METHODS (mlx5_ib_flow_actions, +UVERBS_OBJECT_FLOW_ACTION , + &UVERBS_METHOD (MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER )); + DECLARE_UVERBS_NAMED_METHOD( MLX5_IB_METHOD_FLOW_MATCHER_CREATE, UVERBS_ATTR_IDR(MLX5_IB_ATTR_FLOW_MATCHER_CREATE_HANDLE,
@@ -249,6 +374,7 @@ int mlx5_ib_get_flow_trees(const struct uverbs_object_tree_def **root) root[i++] = &flow_objects; root[i++] = &mlx5_ib_fs; + root[i++] = &mlx5_ib_flow_actions;return i; }
drivers/infiniband/hw/mlx5/main.c +4 -1
@@ -3996,6 +3996,9 @@ static int mlx5_ib_destroy_flow_action(struct ib_flow_action *action)*/ mlx5_accel_esp_destroy_xfrm (maction->esp_aes_gcm.ctx);break ; +case IB_FLOW_ACTION_UNSPECIFIED : +mlx5_ib_destroy_flow_action_raw (maction); +break ;default :WARN_ON (true);break ;
@@ -5532,7 +5535,7 @@ ADD_UVERBS_ATTRIBUTES_SIMPLE(UVERBS_ATTR_FLAGS_IN (MLX5_IB_ATTR_CREATE_FLOW_ACTION_FLAGS , enum mlx5_ib_uapi_flow_action_flags)); -#define NUM_TREES 5 +#define NUM_TREES 6static int populate_specs_root (struct mlx5_ib_dev *dev) {const struct uverbs_object_tree_def *default_root[NUM_TREES +1 ] = {
drivers/infiniband/hw/mlx5/mlx5_ib.h +11 -0
@@ -151,6 +151,10 @@ struct mlx5_ib_pd {u32 pdn; }; +enum { +MLX5_IB_FLOW_ACTION_MODIFY_HEADER , +}; +#define MLX5_IB_FLOW_MCAST_PRIO (MLX5_BY_PASS_NUM_PRIOS - 1)#define MLX5_IB_FLOW_LAST_PRIO (MLX5_BY_PASS_NUM_REGULAR_PRIOS - 1)#if (MLX5_IB_FLOW_LAST_PRIO <=0 )
@@ -815,6 +819,11 @@ struct mlx5_ib_flow_action {u64 ib_flags;struct mlx5_accel_esp_xfrm *ctx; } esp_aes_gcm; +struct { +struct mlx5_ib_dev *dev; +u32 sub_type; +u32 action_id; + } flow_action_raw; }; };
@@ -1240,6 +1249,7 @@ struct mlx5_ib_flow_handler *mlx5_ib_raw_fs_rule_add(struct mlx5_ib_dev *dev, int dest_type);bool mlx5_ib_devx_is_flow_dest (void *obj,int *dest_id,int *dest_type);int mlx5_ib_get_flow_trees (const struct uverbs_object_tree_def **root); +void mlx5_ib_destroy_flow_action_raw (struct mlx5_ib_flow_action *maction);#else static inline int mlx5_ib_devx_create(struct mlx5_ib_dev *dev,
@@ -1259,6 +1269,7 @@ mlx5_ib_devx_is_flow_dest(void *obj, int *dest_id, int *dest_type) { return false; };static inline int mlx5_ib_get_flow_trees (const struct uverbs_object_tree_def **root) {return 0 ; }; +static void mlx5_ib_destroy_flow_action_raw (struct mlx5_ib_flow_action *maction) {return ; };#endif static inline void init_query_mad (struct ib_smp *mad) {
include/uapi/rdma/mlx5_user_ioctl_cmds.h +10 -0
@@ -166,4 +166,14 @@ enum mlx5_ib_flow_methods { MLX5_IB_METHOD_DESTROY_FLOW, }; +enum mlx5_ib_flow_action_methods { +MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER = (1U <<UVERBS_ID_NS_SHIFT ), +}; + +enum mlx5_ib_create_flow_action_create_modify_header_attrs { +MLX5_IB_ATTR_CREATE_MODIFY_HEADER_HANDLE = (1U <<UVERBS_ID_NS_SHIFT ), +MLX5_IB_ATTR_CREATE_MODIFY_HEADER_ACTIONS_PRM , +MLX5_IB_ATTR_CREATE_MODIFY_HEADER_FT_TYPE , +}; +#endif
include/uapi/rdma/mlx5_user_ioctl_verbs.h +5 -0
@@ -39,5 +39,10 @@ enum mlx5_ib_uapi_flow_action_flags { MLX5_IB_UAPI_FLOW_ACTION_FLAGS_REQUIRE_METADATA = 1 << 0, }; +enum mlx5_ib_uapi_flow_table_type { +MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_RX =0x0 , +MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_TX =0x1 , +}; +#endif
RFC PATCH 12/18 RDMA/mlx5: Enable attaching modify header to steering flows
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
When creating a flow steering rule, allow the user to attach a modify header action.
--- drivers/infiniband/hw/mlx5/main.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/infiniband/hw/mlx5/main.c +8 -0
@@ -2468,6 +2468,14 @@ static int parse_flow_flow_action(const union ib_flow_spec *ib_spec, MLX5_FLOW_CONTEXT_ACTION_ENCRYPT :MLX5_FLOW_CONTEXT_ACTION_DECRYPT ;return 0 ; +case IB_FLOW_ACTION_UNSPECIFIED : +if (maction->flow_action_raw.sub_type == +MLX5_IB_FLOW_ACTION_MODIFY_HEADER ) { + action->action |=MLX5_FLOW_CONTEXT_ACTION_MOD_HDR ; + action->modify_id = maction->flow_action_raw.action_id; +return 0 ; + } +/* fall through */ default :return -EOPNOTSUPP ; }
RFC PATCH 13/18 RDMA/mlx5: Enable decap and packet reformat on flow tables
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
If NIC RX flow tables support decap opertion, enable it on creation. If NIC TX flow tables support reformat opertion, enable it on creation.
--- drivers/infiniband/hw/mlx5/main.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/infiniband/hw/mlx5/main.c +11 -4
@@ -3036,14 +3036,15 @@ enum flow_table_type {static struct mlx5_ib_flow_prio *_get_prio (struct mlx5_flow_namespace *ns,struct mlx5_ib_flow_prio *prio,int priority, -int num_entries,int num_groups) +int num_entries,int num_groups, +u32 flags) {struct mlx5_flow_table *ft; ft =mlx5_create_auto_grouped_flow_table (ns, priority, num_entries, num_groups, -0 ,0 ); +0 , flags);if (IS_ERR (ft))return ERR_CAST (ft);
@@ -3063,6 +3064,7 @@ static struct mlx5_ib_flow_prio *get_flow_table(struct mlx5_ib_dev *dev,int max_table_size;int num_entries;int num_groups; +u32 flags =0 ;int priority; max_table_size = BIT(MLX5_CAP_FLOWTABLE_NIC_RX(dev->mdev,
@@ -3079,11 +3081,15 @@ static struct mlx5_ib_flow_prio *get_flow_table(struct mlx5_ib_dev *dev,if (ft_type ==MLX5_IB_FT_RX ) { fn_type =MLX5_FLOW_NAMESPACE_BYPASS ; prio = &dev->flow_db->prios[priority]; +if (MLX5_CAP_FLOWTABLE_NIC_RX (dev->mdev, decap)) + flags |=MLX5_FLOW_TABLE_TUNNEL_EN_DECAP ; }else { max_table_size =BIT (MLX5_CAP_FLOWTABLE_NIC_TX (dev->mdev, log_max_ft_size)); fn_type =MLX5_FLOW_NAMESPACE_EGRESS ; prio = &dev->flow_db->egress_prios[priority]; +if (MLX5_CAP_FLOWTABLE_NIC_RX (dev->mdev, reformat)) + flags |=MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT ; } ns =mlx5_get_flow_namespace (dev->mdev, fn_type); num_entries =MLX5_FS_MAX_ENTRIES ;
@@ -3119,7 +3125,8 @@ static struct mlx5_ib_flow_prio *get_flow_table(struct mlx5_ib_dev *dev, ft = prio->flow_table;if (!ft) -return _get_prio (ns, prio, priority, num_entries, num_groups); +return _get_prio (ns, prio, priority, num_entries, num_groups, + flags);return prio; }
@@ -3694,7 +3701,7 @@ static struct mlx5_ib_flow_prio *_get_flow_table(struct mlx5_ib_dev *dev,return prio;return _get_prio (ns, prio, priority,MLX5_FS_MAX_ENTRIES , -MLX5_FS_MAX_TYPES ); +MLX5_FS_MAX_TYPES ,0 ); } static struct mlx5_ib_flow_handler *
Re: [RFC PATCH rdma-next 13/18] RDMA/mlx5: Enable decap and packet reformat on flow tables
Quoted 3 lines · Leon Romanovsky
From: Mark Bloch <[email protected]>
If NIC RX flow tables support decap opertion, enable it on creation.
opertion --> operation
Quoted 1 line
If NIC TX flow tables support reformat opertion, enable it on creation.
What is the trigger to use the decap flag on RX table or encap flag on TX table?
Please note that we have a short blanket w.r.t mutual usage by NIC vs e-Switch steering, did you consider to do that on demand?
RE: [RFC PATCH rdma-next 13/18] RDMA/mlx5: Enable decap and packet reformat on flow tables
Quoted 16 lines
-----Original Message-----
From: Or Gerlitz [mailto:[email protected]]
Sent: Monday, July 16, 2018 2:24 PM
To: Mark Bloch <[email protected]>
Cc: Doug Ledford <[email protected]>; Jason Gunthorpe <[email protected]>; Leon Romanovsky <[email protected]>; RDMA mailing list <[email protected]>; Saeed Mahameed <[email protected]>; linux-netdev <[email protected]>
Subject: Re: [RFC PATCH rdma-next 13/18] RDMA/mlx5: Enable decap and packet reformat on flow tablesQuoted 2 lines · Leon Romanovsky
From: Mark Bloch <[email protected]>
Quoted 9 lines
Quoted 1 line
If NIC RX flow tables support decap opertion, enable it on creation.
opertion --> operation
Quoted 1 line
If NIC TX flow tables support reformat opertion, enable it on creation.
What is the trigger to use the decap flag on RX table or encap flag on TX table?
It has no performance penalty to always enable that, so that's what I do if supported.
Quoted 1 line
Please note that we have a short blanket w.r.t mutual usage by
FDB and NIC steering tables have different limitations, so encap/decap on NIC steering have nothing to do with the limitations the FDB has with those operations.
Quoted 1 line
NIC vs e-Switch steering, did you consider to do that on demand?
The flow table needs to be created with those flags set if we want to attach decap/packet reformat action to it. BTW, there is no modify action for those bits so that's why I'm doing it on creation.
Mark
Re: [RFC PATCH rdma-next 13/18] RDMA/mlx5: Enable decap and packet reformat on flow tables
Quoted 4 lines · Mark Bloch
Quoted 4 lines
From: Or Gerlitz [mailto:[email protected]]
Quoted 1 line
If NIC RX flow tables support decap opertion, enable it on creation.
opertion --> operation
saw it?
Quoted 1 line
Quoted 1 line
Quoted 1 line
If NIC TX flow tables support reformat opertion, enable it on creation.
opertion --> operation
Quoted 4 lines
Quoted 2 lines
What is the trigger to use the decap flag on RX table or encap flag on TX table?
It has no performance penalty to always enable that, so that's what I do if supported.
I was not referring to performance, see below
Quoted 4 lines
Quoted 1 line
Please note that we have a short blanket w.r.t mutual usage by
FDB and NIC steering tables have different limitations, so encap/decap on NIC steering have nothing to do with the limitations the FDB has with those operations.
no! AFAIK it has to do, the FW maintains three states for encap(decap) NONE, FDB or NIC
if the state is NIC, an FDB table can't be created with encap set, and the other way around, if the
state is FDB, NIC TX table can't be created with encap set, etc. This is the short blanket I was
referring too, you can check me.
Quoted 5 lines
Quoted 1 line
NIC vs e-Switch steering, did you consider to do that on demand?
The flow table needs to be created with those flags set if we want to attach decap/packet reformat action to it. BTW, there is no modify action for those bits so that's why I'm doing it on creation.
The question was if you can let the application tell you that they want to use rules with encap/decap, as we did in the devlink switchdev API (encap enabled)
RE: [RFC PATCH rdma-next 13/18] RDMA/mlx5: Enable decap and packet reformat on flow tables
Quoted 14 lines
-----Original Message-----
From: [email protected] [mailto:linux-rdma- [email protected]] On Behalf Of Or Gerlitz
Sent: Tuesday, July 17, 2018 5:47 AM
To: Mark Bloch <[email protected]>
Cc: Doug Ledford <[email protected]>; Jason Gunthorpe <[email protected]>; Leon Romanovsky <[email protected]>; RDMA mailing list <[email protected]>; Saeed Mahameed <[email protected]>; linux-netdev <[email protected]>
Subject: Re: [RFC PATCH rdma-next 13/18] RDMA/mlx5: Enable decap and packet reformat on flow tables
Quoted 7 lines
Quoted 4 lines · Mark Bloch
Quoted 4 lines
From: Or Gerlitz [mailto:[email protected]]
Quoted 1 line
If NIC RX flow tables support decap opertion, enable it on creation.
opertion --> operation
saw it?
yes, sorry I didn't say so 😊
Quoted 19 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
If NIC TX flow tables support reformat opertion, enable it on creation.
opertion --> operation
Quoted 4 lines
Quoted 2 lines
What is the trigger to use the decap flag on RX table or encap flag on TX table?
It has no performance penalty to always enable that, so that's what I do if
supported.
I was not referring to performance, see below
Quoted 3 lines
Quoted 1 line
Please note that we have a short blanket w.r.t mutual usage by
FDB and NIC steering tables have different limitations, so encap/decap on
NIC steering
Quoted 1 line
have nothing to do with the limitations the FDB has with those operations.
Quoted 7 lines
no! AFAIK it has to do, the FW maintains three states for encap(decap) NONE, FDB or NIC
if the state is NIC, an FDB table can't be created with encap set, and the other way around, if the
state is FDB, NIC TX table can't be created with encap set, etc. This is the short blanket I was
referring too, you can check me.
Or I'm sorry, just realized you don't see the updated version of the patch set. (will be sent without RFC tag) The updated one doesn't allow TX steering to be done when in switchdev mode as today
we lack the API (on the RDMA side) to specify to which rep the rules should be applied.
Also once in switchdev mode, the FW turns off the cap flag for encap, which means the VFs won't create a flow table with the encap flag set, and because we require the VFs won't be binded when moving to switchdev mode they will always see the updated caps.
Does that address your concerns?
Mark.
Quoted 15 lines
Quoted 5 lines
Quoted 2 lines
NIC vs e-Switch steering, did you consider to do that on demand?
The flow table needs to be created with those flags set if we want to attach decap/packet reformat action to it. BTW, there is no modify action for
those bits
Quoted 1 line
so that's why I'm doing it on creation.
The question was if you can let the application tell you that they want to use rules with encap/decap, as we did in the devlink switchdev API (encap enabled)
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH 14/18 RDMA/uverbs: Add generic function to fill in flow action object
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
Refactor the initialization of a flow action object to a common function.
--- drivers/infiniband/core/uverbs_std_types_flow_action.c | 7 ++----- drivers/infiniband/hw/mlx5/flow.c | 8 +++----- include/rdma/uverbs_std_types.h | 12 ++++++++++++ 3 files changed, 17 insertions(+), 10 deletions(-)
drivers/infiniband/core/uverbs_std_types_flow_action.c +2 -5
@@ -327,11 +327,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_FLOW_ACTION_ESP_CREATE)(struct ib_deviceif (IS_ERR (action))return PTR_ERR (action); -atomic_set (&action->usecnt,0 ); - action->device = ib_dev; - action->type =IB_FLOW_ACTION_ESP ; - action->uobject = uobj; - uobj->object = action; +uverbs_flow_action_fill_action (action, uobj, ib_dev, +IB_FLOW_ACTION_ESP );return 0 ; }
drivers/infiniband/hw/mlx5/flow.c +3 -5
@@ -7,6 +7,7 @@#include <rdma/ib_verbs.h> #include <rdma/uverbs_types.h> #include <rdma/uverbs_ioctl.h> +#include <rdma/uverbs_std_types.h> #include <rdma/mlx5_user_ioctl_cmds.h> #include <rdma/mlx5_user_ioctl_verbs.h> #include <rdma/ib_umem.h>
@@ -273,11 +274,8 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER)(strucif (IS_ERR (action))return PTR_ERR (action); -atomic_set (&action->usecnt,0 ); - action->device = uobj->context->device; - action->type =IB_FLOW_ACTION_UNSPECIFIED ; - action->uobject = uobj; - uobj->object = action; +uverbs_flow_action_fill_action (action, uobj, uobj->context->device, +IB_FLOW_ACTION_UNSPECIFIED );return 0 ; }
include/rdma/uverbs_std_types.h +12 -0
@@ -125,5 +125,17 @@ static inline struct ib_uobject *__uobj_alloc(const struct uverbs_obj_type *type#define uobj_alloc (_type, _ufile) __uobj_alloc(uobj_get_type(_type), _ufile) +static inline void uverbs_flow_action_fill_action (struct ib_flow_action *action, +struct ib_uobject *uobj, +struct ib_device *ib_dev, +enum ib_flow_action_type type) +{ +atomic_set (&action->usecnt,0 ); + action->device = ib_dev; + action->type = type; + action->uobject = uobj; + uobj->object = action; +} +#endif
RFC PATCH 15/18 RDMA/mlx5: Add new flow action verb, packet reformat
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
Fow now, only add L2_TUNNEL_TO_L2 option, for example this can be used to decap VXLAN packets.
--- drivers/infiniband/hw/mlx5/flow.c | 73 ++++++++++++++++++++++++++++++- drivers/infiniband/hw/mlx5/mlx5_ib.h | 1 + include/uapi/rdma/mlx5_user_ioctl_cmds.h | 7 +++ include/uapi/rdma/mlx5_user_ioctl_verbs.h | 4 ++ 4 files changed, 84 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/flow.c +72 -1
@@ -201,6 +201,8 @@ void mlx5_ib_destroy_flow_action_raw(struct mlx5_ib_flow_action *maction)mlx5_modify_header_dealloc (maction->flow_action_raw.dev->mdev, maction->flow_action_raw.action_id);break ; +case MLX5_IB_FLOW_ACTION_DECAP : +break ;default :WARN_ON (true);break ;
@@ -280,6 +282,59 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER)(strucreturn 0 ; } +static bool mlx5_ib_flow_action_packet_reformat_valid (struct mlx5_ib_dev *ibdev, +u8 packet_reformat_type, +u8 ft_type) +{ +switch (packet_reformat_type) { +case MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TUNNEL_TO_L2 : +if (ft_type ==MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_RX ) +return MLX5_CAP_FLOWTABLE_NIC_RX (ibdev->mdev, decap); +break ; +default : +break ; + } + +return false; +} + +static int UVERBS_HANDLER (MLX5_IB_METHOD_FLOW_ACTION_CREATE_PACKET_REFORMAT )(struct ib_device *ib_dev, +struct ib_uverbs_file *file, +struct uverbs_attr_bundle *attrs) +{ +struct ib_uobject *uobj =uverbs_attr_get_uobject (attrs, +MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_HANDLE ); +struct mlx5_ib_dev *mdev =to_mdev (uobj->context->device); +struct mlx5_ib_flow_action *maction; +u8 ft_type; +u8 dv_prt; + +uverbs_copy_from (&ft_type, attrs, +MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_FT_TYPE ); + +uverbs_copy_from (&dv_prt, attrs, +MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_TYPE ); + +if (!mlx5_ib_flow_action_packet_reformat_valid (mdev, dv_prt, ft_type)) +return -EINVAL ; + + maction =kzalloc (sizeof (*maction),GFP_KERNEL ); +if (!maction) +return -ENOMEM ; + +if (dv_prt == +MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TUNNEL_TO_L2 ) { + maction->flow_action_raw.sub_type = +MLX5_IB_FLOW_ACTION_DECAP ; + maction->flow_action_raw.dev = mdev; + } + +uverbs_flow_action_fill_action (&maction->ib_action, uobj, + uobj->context->device, +IB_FLOW_ACTION_UNSPECIFIED ); +return 0 ; +} + DECLARE_UVERBS_NAMED_METHOD( MLX5_IB_METHOD_CREATE_FLOW, UVERBS_ATTR_IDR(MLX5_IB_ATTR_CREATE_FLOW_HANDLE,
@@ -328,9 +383,25 @@ DECLARE_UVERBS_NAMED_METHOD(UVERBS_ATTR_TYPE (u8), UA_MANDATORY)); +DECLARE_UVERBS_NAMED_METHOD ( +MLX5_IB_METHOD_FLOW_ACTION_CREATE_PACKET_REFORMAT , +UVERBS_ATTR_IDR (MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_HANDLE , +UVERBS_OBJECT_FLOW_ACTION , +UVERBS_ACCESS_NEW , +UA_MANDATORY ), +UVERBS_ATTR_PTR_IN (MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_TYPE , +/* See enum mlx5_ib_uapi_flow_action_packet_reformat_type */ +UVERBS_ATTR_TYPE (u8), +UA_MANDATORY ), +UVERBS_ATTR_PTR_IN (MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_FT_TYPE , +/* See enum mlx5_ib_uapi_flow_table_type */ +UVERBS_ATTR_TYPE (u8), +UA_MANDATORY )); +ADD_UVERBS_METHODS (mlx5_ib_flow_actions,UVERBS_OBJECT_FLOW_ACTION , - &UVERBS_METHOD (MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER )); + &UVERBS_METHOD (MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER ), + &UVERBS_METHOD (MLX5_IB_METHOD_FLOW_ACTION_CREATE_PACKET_REFORMAT )); DECLARE_UVERBS_NAMED_METHOD( MLX5_IB_METHOD_FLOW_MATCHER_CREATE,
drivers/infiniband/hw/mlx5/mlx5_ib.h +1 -0
@@ -153,6 +153,7 @@ struct mlx5_ib_pd {enum {MLX5_IB_FLOW_ACTION_MODIFY_HEADER , +MLX5_IB_FLOW_ACTION_DECAP , };#define MLX5_IB_FLOW_MCAST_PRIO (MLX5_BY_PASS_NUM_PRIOS - 1)
include/uapi/rdma/mlx5_user_ioctl_cmds.h +7 -0
@@ -168,6 +168,7 @@ enum mlx5_ib_flow_methods {enum mlx5_ib_flow_action_methods {MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER = (1U <<UVERBS_ID_NS_SHIFT ), +MLX5_IB_METHOD_FLOW_ACTION_CREATE_PACKET_REFORMAT , };enum mlx5_ib_create_flow_action_create_modify_header_attrs {
@@ -176,4 +177,10 @@ enum mlx5_ib_create_flow_action_create_modify_header_attrs { MLX5_IB_ATTR_CREATE_MODIFY_HEADER_FT_TYPE, }; +enum mlx5_ib_create_flow_action_create_packet_reformat_attrs { +MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_HANDLE = (1U <<UVERBS_ID_NS_SHIFT ), +MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_TYPE , +MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_FT_TYPE , +}; +#endif
include/uapi/rdma/mlx5_user_ioctl_verbs.h +4 -0
@@ -44,5 +44,9 @@ enum mlx5_ib_uapi_flow_table_type { MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_TX = 0x1, }; +enum mlx5_ib_uapi_flow_action_packet_reformat_type { +MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TUNNEL_TO_L2 =0x0 , +}; +#endif
RFC PATCH 16/18 RDMA/mlx5: Enable attaching DECAP action to steering flows
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
Any matching flow will be stripped of it's VXLAN tunnel, only the inner L2 onward is left.
--- drivers/infiniband/hw/mlx5/main.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/infiniband/hw/mlx5/main.c +5 -0
@@ -2475,6 +2475,11 @@ static int parse_flow_flow_action(const union ib_flow_spec *ib_spec, action->modify_id = maction->flow_action_raw.action_id;return 0 ; } +if (maction->flow_action_raw.sub_type == +MLX5_IB_FLOW_ACTION_DECAP ) { + action->action |=MLX5_FLOW_CONTEXT_ACTION_DECAP ; +return 0 ; + }/* fall through */ default :return -EOPNOTSUPP ;
RFC PATCH 17/18 RDMA/mlx5: Extend packet reformat verbs
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
We expose new actions:
L2_TO_L2_TUNNEL - A generic encap from L2 to L2, the data passed should be the encapsulating headers.
L3_TUNNEL_TO_L2 - Will do decap where the inner packet starts from L3, the data should be mac or mac + vlan (14 or 18 bytes).
L2_TO_L3_TUNNEL - Will do encap where is L2 of the original packet will not be included, the data should be the encapsulating header.
--- drivers/infiniband/hw/mlx5/flow.c | 85 +++++++++++++++++++++++++++++++ drivers/infiniband/hw/mlx5/mlx5_ib.h | 1 + include/uapi/rdma/mlx5_user_ioctl_cmds.h | 1 + include/uapi/rdma/mlx5_user_ioctl_verbs.h | 3 ++ 4 files changed, 90 insertions(+)
drivers/infiniband/hw/mlx5/flow.c +85 -0
@@ -201,6 +201,10 @@ void mlx5_ib_destroy_flow_action_raw(struct mlx5_ib_flow_action *maction)mlx5_modify_header_dealloc (maction->flow_action_raw.dev->mdev, maction->flow_action_raw.action_id);break ; +case MLX5_IB_FLOW_ACTION_PACKET_REFORMAT : +mlx5_packet_reformat_dealloc (maction->flow_action_raw.dev->mdev, + maction->flow_action_raw.action_id); +break ;case MLX5_IB_FLOW_ACTION_DECAP :break ;default :
@@ -287,6 +291,11 @@ static bool mlx5_ib_flow_action_packet_reformat_valid(struct mlx5_ib_dev *ibdev, u8 ft_type) {switch (packet_reformat_type) { +case MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L2_TUNNEL : +if (ft_type ==MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_TX ) +return MLX5_CAP_FLOWTABLE (ibdev->mdev, + encap_general_header); +break ;case MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TUNNEL_TO_L2 :if (ft_type ==MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_RX )return MLX5_CAP_FLOWTABLE_NIC_RX (ibdev->mdev, decap);
@@ -298,6 +307,55 @@ static bool mlx5_ib_flow_action_packet_reformat_valid(struct mlx5_ib_dev *ibdev,return false; } +static int mlx5_ib_dv_to_prm_packet_reforamt_type (u8 dv_prt,u8 *prm_prt) +{ +switch (dv_prt) { +case MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L2_TUNNEL : + *prm_prt =MLX5_REFORMAT_TYPE_L2_TO_L2_TUNNEL ; +break ; +case MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2 : + *prm_prt =MLX5_REFORMAT_TYPE_L3_TUNNEL_TO_L2 ; +break ; +case MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L3_TUNNEL : + *prm_prt =MLX5_REFORMAT_TYPE_L2_TO_L3_TUNNEL ; +break ; +default : +return -EINVAL ; + } + +return 0 ; +} + +static int mlx5_ib_flow_action_create_packet_reformat_ctx (struct mlx5_ib_dev *dev, +struct mlx5_ib_flow_action *maction, +u8 ft_type,u8 dv_prt, +void *in,size_t len) +{ +u8 namespace; +u8 prm_prt; +int ret; + + ret =mlx5_ib_ft_type_to_namespace (ft_type, &namespace); +if (ret) +return ret; + + ret =mlx5_ib_dv_to_prm_packet_reforamt_type (dv_prt, &prm_prt); +if (ret) +return ret; + + ret =mlx5_packet_reformat_alloc (dev->mdev, prm_prt, len, + in, namespace, + &maction->flow_action_raw.action_id); +if (ret) +return ret; + + maction->flow_action_raw.sub_type = +MLX5_IB_FLOW_ACTION_PACKET_REFORMAT ; + maction->flow_action_raw.dev = dev; + +return 0 ; +} +static int UVERBS_HANDLER (MLX5_IB_METHOD_FLOW_ACTION_CREATE_PACKET_REFORMAT )(struct ib_device *ib_dev,struct ib_uverbs_file *file,struct uverbs_attr_bundle *attrs)
@@ -306,6 +364,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_ACTION_CREATE_PACKET_REFORMAT)(str MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_HANDLE);struct mlx5_ib_dev *mdev =to_mdev (uobj->context->device);struct mlx5_ib_flow_action *maction; +int ret =0 ;u8 ft_type;u8 dv_prt;
@@ -327,12 +386,35 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_ACTION_CREATE_PACKET_REFORMAT)(str maction->flow_action_raw.sub_type =MLX5_IB_FLOW_ACTION_DECAP ; maction->flow_action_raw.dev = mdev; + }else { +void *in; +int len; + +if (!uverbs_attr_is_valid (attrs, +MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_DATA_PRM )) { + ret = -EINVAL ; + goto free_maction; + } + + in =uverbs_attr_get_alloced_ptr (attrs,MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_DATA_PRM ); + len =uverbs_attr_get_len (attrs,MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_DATA_PRM ); + + ret =mlx5_ib_flow_action_create_packet_reformat_ctx (mdev, maction, + ft_type, + dv_prt, in, + len); +if (ret) + goto free_maction; }uverbs_flow_action_fill_action (&maction->ib_action, uobj, uobj->context->device,IB_FLOW_ACTION_UNSPECIFIED );return 0 ; + +free_maction: +kfree (maction); +return ret; } DECLARE_UVERBS_NAMED_METHOD(
@@ -389,6 +471,9 @@ DECLARE_UVERBS_NAMED_METHOD( UVERBS_OBJECT_FLOW_ACTION, UVERBS_ACCESS_NEW, UA_MANDATORY), +UVERBS_ATTR_PTR_IN (MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_DATA_PRM , +UVERBS_ATTR_MIN_SIZE (1 ), +UA_ALLOC_AND_COPY ), UVERBS_ATTR_PTR_IN(MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_TYPE, /* See enum mlx5_ib_uapi_flow_action_packet_reformat_type */ UVERBS_ATTR_TYPE(u8),
drivers/infiniband/hw/mlx5/mlx5_ib.h +1 -0
@@ -153,6 +153,7 @@ struct mlx5_ib_pd {enum {MLX5_IB_FLOW_ACTION_MODIFY_HEADER , +MLX5_IB_FLOW_ACTION_PACKET_REFORMAT ,MLX5_IB_FLOW_ACTION_DECAP , };
include/uapi/rdma/mlx5_user_ioctl_cmds.h +1 -0
@@ -181,6 +181,7 @@ enum mlx5_ib_create_flow_action_create_packet_reformat_attrs {MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_HANDLE = (1U <<UVERBS_ID_NS_SHIFT ),MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_TYPE ,MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_FT_TYPE , + MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_DATA_PRM, };#endif
include/uapi/rdma/mlx5_user_ioctl_verbs.h +3 -0
@@ -46,6 +46,9 @@ enum mlx5_ib_uapi_flow_table_type {enum mlx5_ib_uapi_flow_action_packet_reformat_type {MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TUNNEL_TO_L2 =0x0 , +MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L2_TUNNEL =0x1 , +MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2 =0x2 , +MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L3_TUNNEL =0x3 , };#endif
RFC PATCH 18/18 RDMA/mlx5: Enable attaching packet reformat action to steering flows
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
Any matching rules will be mutated based on the packet reformat context which is attached to that given flow rule.
--- drivers/infiniband/hw/mlx5/main.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/infiniband/hw/mlx5/main.c +7 -0
@@ -2480,6 +2480,13 @@ static int parse_flow_flow_action(const union ib_flow_spec *ib_spec, action->action |=MLX5_FLOW_CONTEXT_ACTION_DECAP ;return 0 ; } +if (maction->flow_action_raw.sub_type == +MLX5_IB_FLOW_ACTION_PACKET_REFORMAT ) { + action->action |= +MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT_ID ; + action->packet_reformat_id = maction->flow_action_raw.action_id; +return 0 ; + }/* fall through */ default :return -EOPNOTSUPP ;