Flow actions to mutate packets
Subsystems (6)
cover Flow actions to mutate packets
From: Leon Romanovsky <[email protected]>
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.
The first 10 patches refactor mlx5_core code, rename internal structures to better reflect their operation and export needed functions so the RDMA side can allocate the action.
The last 5 patches expose via the IOCTL infrastructure mlx5_ib methods which do the actual allocation of resources and return an handle to the user. A user of this API is expected to know how to work with the device's spec as the input to those function is HW depended.
An example usage of the modify header action is routing, A user can create an action which edits the L2 header and decrease the TTL.
An example usage of the packet reformat action is VXLAN encap/decap which is done by the HW.
Changelog:
v0 -> v1:
* Patch 1: Addressed Saeed's comments and simplified the logic.
* Patch 2: Changed due to changes in patch 1.
Split the 27 patch series into 3, this is the first one which just lets the user create flow action. Other than that styling fixes mainly in the RDMA patches to make sure 80 chars limit isn't exceeded.
RFC -> v0:
* Patch 1 a new patch which refactors the logic
when getting a flow namespace.
* Patch 2 was split into two.
* Patch 3: Fixed a typo in commit message
* Patch 5: Updated commit message
* Patch 7: Updated commit message
Renamed:
- MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT_ID to MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT
- packet_reformat_id to reformat_id in struct mlx5_flow_act
- packet_reformat_id to encap_id in struct mlx5_esw_flow_attr
- packet_reformat_id to encap_id in struct mlx5e_encap_entry
- PACKET_REFORMAT to REFORMAT when printing trace points
* Patch 9: Updated commit message
Updated function declaration in mlx5_core.h, could of lead to compile error on bisection.
* Patch 11: Disallow egress rules insertion when in switchdev mode
* Patch 12: A new patch to deal with passing enum values using the IOCTL infrastructure.
* Patch 13: Use new enum value attribute when passing enum mlx5_ib_uapi_flow_table_type
* Patch 15: Don't set encap flags on flow tables if in switchdev mode
* Patch 17: Use new enum value attribute when passing enum mlx5_ib_uapi_flow_table_type and enum mlx5_ib_uapi_flow_action_packet_reformat_type
* Patch 19: Allow creation of both MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L3_TUNNEL and MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2
packet
reformat actions.
* Patch 20: A new patch which allows attaching packet reformat actions to flow tables on NIC RX.
Thanks
Mark Bloch (15):
net/mlx5: Cleanup flow namespace getter switch logic 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 flow table creation
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: Pass a namespace for packet reformat ID allocation net/mlx5: Export packet reformat alloc/dealloc functions RDMA/uverbs: Add UVERBS_ATTR_CONST_IN to the specs language RDMA/mlx5: Add a new flow action verb - modify header RDMA/uverbs: Add generic function to fill in flow action object RDMA/mlx5: Add new flow action verb - packet reformat RDMA/mlx5: Extend packet reformat verbs
drivers/infiniband/core/uverbs_ioctl.c | 23 ++ .../infiniband/core/uverbs_std_types_flow_action.c | 7 +- drivers/infiniband/hw/mlx5/devx.c | 6 +- drivers/infiniband/hw/mlx5/flow.c | 301 +++++++++++++++++++++ drivers/infiniband/hw/mlx5/main.c | 3 + drivers/infiniband/hw/mlx5/mlx5_ib.h | 19 +- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 8 +- .../mellanox/mlx5/core/diag/fs_tracepoint.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 51 ++-- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 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 | 73 +++-- .../net/ethernet/mellanox/mlx5/core/mlx5_core.h | 12 +- include/linux/mlx5/device.h | 6 + include/linux/mlx5/fs.h | 20 +- include/linux/mlx5/mlx5_ifc.h | 70 +++-- include/rdma/uverbs_ioctl.h | 40 +++ 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, 638 insertions(+), 143 deletions(-)
PATCH 1/15 net/mlx5: Cleanup flow namespace getter switch logic
From: Mark Bloch <[email protected]>
Refactor the switch logic so it's simpler to follow and understand.
--- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 24 ++++++----------------- 1 file changed, 6 insertions(+), 18 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +6 -18
@@ -1986,40 +1986,28 @@ struct mlx5_flow_namespace *mlx5_get_flow_namespace(struct mlx5_core_dev *dev,return NULL ;switch (type) { -case MLX5_FLOW_NAMESPACE_BYPASS : -case MLX5_FLOW_NAMESPACE_LAG : -case MLX5_FLOW_NAMESPACE_OFFLOADS : -case MLX5_FLOW_NAMESPACE_ETHTOOL : -case MLX5_FLOW_NAMESPACE_KERNEL : -case MLX5_FLOW_NAMESPACE_LEFTOVERS : -case MLX5_FLOW_NAMESPACE_ANCHOR : - prio = type; -break ;case MLX5_FLOW_NAMESPACE_FDB :if (steering->fdb_root_ns)return &steering->fdb_root_ns->ns; -else -return NULL ; +return NULL ;case MLX5_FLOW_NAMESPACE_SNIFFER_RX :if (steering->sniffer_rx_root_ns)return &steering->sniffer_rx_root_ns->ns; -else -return NULL ; +return NULL ;case MLX5_FLOW_NAMESPACE_SNIFFER_TX :if (steering->sniffer_tx_root_ns)return &steering->sniffer_tx_root_ns->ns; -else -return NULL ; +return NULL ;case MLX5_FLOW_NAMESPACE_EGRESS :if (steering->egress_root_ns)return &steering->egress_root_ns->ns; -else -return NULL ; -default :return NULL ; +default : +break ; } root_ns = steering->root_ns; + prio = type;if (!root_ns)return NULL ;
Signature · 1 line
2.14.4
PATCH 2/15 net/mlx5: Add proper NIC TX steering flow tables support
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
Extend 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. This will allow to shape outgoing traffic and tweak it if needed, for example performing encapsulation or rewriting headers.
--- drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 51 +++++++++++++++++------ include/linux/mlx5/device.h | 6 +++ 3 files changed, 46 insertions(+), 13 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +1 -1
@@ -760,8 +760,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 +39 -12
97 lines not on this page · raw message
include/linux/mlx5/device.h +6 -0
@@ -1120,6 +1120,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)
Signature · 1 line
2.14.4
PATCH 3/15 net/mlx5: Export modify header alloc/dealloc functions
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
Those functions 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
@@ -702,6 +702,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) {
@@ -716,6 +717,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
@@ -176,11 +176,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
@@ -196,4 +196,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
Signature · 1 line
2.14.4
PATCH 4/15 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
@@ -667,9 +667,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 ; }
Signature · 1 line
2.14.4
PATCH 5/15 net/mlx5: Break encap/decap into two separated flow table creation 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. Those flags control whatever a decap or encap operations can be attached to the flow table created. For FDB, if encapsulation is required, we set both of them.
--- 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
@@ -529,7 +529,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
Signature · 1 line
2.14.4
Re: [PATCH mlx5-next v1 05/15] net/mlx5: Break encap/decap into two separated flow table creation flags
Quoted 34 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 the single flag into two. Those flags control whatever a decap or encap operations can be attached to the flow table created. For FDB, if encapsulation is required, we set both of them.
Signed-off-by Mark Bloch <[email protected]>Reviewed-by Saeed Mahameed <[email protected]>Reviewed-by Or Gerlitz <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>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 +3
-1+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c@@ -529,7 +529,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 +1
-0+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c static int mlx5_cmd_create_flow_table(struct mlx5_core_dev *dev, · line 156
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +2
-1@@ -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 );
Yuk, please don't use !!.
bool en_decap = flags & MLX5_FLOW_TABLE_TUNNEL_EN_DECAP;
Jason
Re: [PATCH mlx5-next v1 05/15] net/mlx5: Break encap/decap into two separated flow table creation flags
Quoted 44 lines · Jason Gunthorpe
Quoted 34 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 the single flag into two. Those flags control whatever a decap or encap operations can be attached to the flow table created. For FDB, if encapsulation is required, we set both of them.
Signed-off-by Mark Bloch <[email protected]>Reviewed-by Saeed Mahameed <[email protected]>Reviewed-by Or Gerlitz <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>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 +3
-1+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c@@ -529,7 +529,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 +1
-0+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.cdrivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c static int mlx5_cmd_create_flow_table(struct mlx5_core_dev *dev, · line 156
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +2
-1@@ -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 );Yuk, please don't use !!.
Quoted 1 line
bool en_decap = flags & MLX5_FLOW_TABLE_TUNNEL_EN_DECAP;
We need to provide en_encap and en_decap as an input to MLX5_SET(...) which is passed to FW as 0 or 1. Boolean type is declared in C as int and treated as zero for false and any other value for true, so we can't pass "bool en_decap" without ensuring before that it is 1.
I'm applying this patch as is.
Thanks
Quoted 2 lines
Jason
Re: [PATCH mlx5-next v1 05/15] net/mlx5: Break encap/decap into two separated flow table creation flags
Quoted 6 lines · Leon Romanovsky
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c static int mlx5_cmd_create_flow_table(struct mlx5_core_dev *dev, · line 156
Quoted 3 lines
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +2
-1-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 );Yuk, please don't use !!.
Quoted 7 lines
Quoted 1 line
bool en_decap = flags & MLX5_FLOW_TABLE_TUNNEL_EN_DECAP;We need to provide
en_encapanden_decapas an input toMLX5_SET(...)which is passed to FW as 0 or 1.Boolean type is declared in C as int and treated as zero for false and any other value for true,
No, that isn't right, the kernel uses C99's _Bool intrinsic type, which is guaranteed to only hold 0 or 1 by the compiler.
See types.h:
typedef _Bool bool;
Jason
Re: [PATCH mlx5-next v1 05/15] net/mlx5: Break encap/decap into two separated flow table creation flags
Quoted 15 lines · Jason Gunthorpe
Quoted 6 lines · Leon Romanovsky
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c static int mlx5_cmd_create_flow_table(struct mlx5_core_dev *dev, · line 156
Quoted 3 lines
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +2
-1-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 );Yuk, please don't use !!.
Quoted 7 lines
Quoted 1 line
bool en_decap = flags & MLX5_FLOW_TABLE_TUNNEL_EN_DECAP;We need to provide
en_encapanden_decapas an input toMLX5_SET(...)which is passed to FW as 0 or 1.Boolean type is declared in C as int and treated as zero for false and any other value for true,
Quoted 6 lines
No, that isn't right, the kernel uses C99's
_Boolintrinsic type, which is guaranteed to only hold 0 or 1 by the compiler.See
types.h:typedef
_Boolbool;
Exciting, it took me a while to find C99 standard and relevant 6.3.1.2. Anyway, this patch didn't change previous functionality, which used "!!" convention.
Thanks
Quoted 2 lines
Jason
Re: [PATCH mlx5-next v1 05/15] net/mlx5: Break encap/decap into two separated flow table creation flags
Quoted 19 lines · Leon Romanovsky
Quoted 18 lines · Jason Gunthorpe
Quoted 6 lines · Leon Romanovsky
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c static int mlx5_cmd_create_flow_table(struct mlx5_core_dev *dev, · line 156
Quoted 3 lines
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +2
-1-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 );Yuk, please don't use !!.
Quoted 7 lines
Quoted 1 line
bool en_decap = flags & MLX5_FLOW_TABLE_TUNNEL_EN_DECAP;We need to provide
en_encapanden_decapas an input toMLX5_SET(...)which is passed to FW as 0 or 1.Boolean type is declared in C as int and treated as zero for false and any other value for true,
No, that isn't right, the kernel uses C99's
_Boolintrinsic type, which is guaranteed to only hold 0 or 1 by the compiler.
Quoted 7 lines
Quoted 3 lines
See
types.h:typedef
_Boolbool;Exciting, it took me a while to find C99 standard and relevant 6.3.1.2. Anyway, this patch didn't change previous functionality, which used "!!" convention.
so? if we didn't do things properly prior to the patch, why not fixing it along with the patch? lets fix
Re: [PATCH mlx5-next v1 05/15] net/mlx5: Break encap/decap into two separated flow table creation flags
Quoted 22 lines · Or Gerlitz
Quoted 21 lines · Leon Romanovsky
Quoted 20 lines · Jason Gunthorpe
Quoted 6 lines · Leon Romanovsky
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c static int mlx5_cmd_create_flow_table(struct mlx5_core_dev *dev, · line 156
Quoted 3 lines
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +2
-1-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 );Yuk, please don't use !!.
Quoted 7 lines
Quoted 1 line
bool en_decap = flags & MLX5_FLOW_TABLE_TUNNEL_EN_DECAP;We need to provide
en_encapanden_decapas an input toMLX5_SET(...)which is passed to FW as 0 or 1.Boolean type is declared in C as int and treated as zero for false and any other value for true,
No, that isn't right, the kernel uses C99's
_Boolintrinsic type, which is guaranteed to only hold 0 or 1 by the compiler.See
types.h:
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
typedef
_Boolbool;Exciting, it took me a while to find C99 standard and relevant 6.3.1.2. Anyway, this patch didn't change previous functionality, which used "!!" convention.
so? if we didn't do things properly prior to the patch, why not fixing it along with the patch? lets fix
Or,
What exactly "to fix"? Both code lines:
1. Have correct syntax
2. Implement proper C99
3. Give same compiler code
4. Have same readability
There is nothing to fix.
And this patch is already merged, so if you truly care about this, please go ahead and prepare patch for whole driver, or better for whole kernel.
kernel git:(rdma-next) git grep "\!\!" |wc -l
8125
Thanks
Re: [PATCH mlx5-next v1 05/15] net/mlx5: Break encap/decap into two separated flow table creation flags
Quoted 40 lines · Leon Romanovsky
Quoted 22 lines · Or Gerlitz
Quoted 21 lines · Leon Romanovsky
Quoted 20 lines · Jason Gunthorpe
Quoted 6 lines · Leon Romanovsky
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +2
-1- 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);Yuk, please don't use !!.
Quoted 7 lines
Quoted 1 line
bool en_decap = flags & MLX5_FLOW_TABLE_TUNNEL_EN_DECAP;We need to provide
en_encapanden_decapas an input toMLX5_SET(...)which is passed to FW as 0 or 1.Boolean type is declared in C as int and treated as zero for false and any other value for true,
No, that isn't right, the kernel uses C99's
_Boolintrinsic type, which is guaranteed to only hold 0 or 1 by the compiler.See
types.h:Quoted 8 lines
Quoted 5 lines
Quoted 1 line
typedef
_Boolbool;Exciting, it took me a while to find C99 standard and relevant 6.3.1.2. Anyway, this patch didn't change previous functionality, which used "!!" convention.
so? if we didn't do things properly prior to the patch, why not fixing it along with the patch? lets fix
Or,
What exactly "to fix"? Both code lines:
1. Have correct syntax
2. Implement proper C99
3. Give same compiler code
4. Have same readability
Quoted 5 lines
There is nothing to fix.
And this patch is already merged, so if you truly care about this, please go ahead and prepare patch for whole driver, or better for whole kernel.
slow down, I was just supporting Jason's suggestion and said there's no reason not to follow it.
If you don't agree with Jason, argue with him.
Quoted 2 lines
kernel git:(rdma-next) git grep "\!\!" |wc -l
8125
PATCH 6/15 net/mlx5: Move header encap type to IFC header file
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
Those bits are hardware specification and should be defined in 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
@@ -4848,6 +4848,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 ];
Signature · 1 line
2.14.4
PATCH 7/15 {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. This change doesn't introduce any function change and is needed to properly reflect 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_tc.c | 43 ++++++++------- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 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 ++++++++--------- 11 files changed, 107 insertions(+), 94 deletions(-)
drivers/infiniband/hw/mlx5/devx.c +3 -3
@@ -284,7 +284,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 :
@@ -627,9 +627,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
@@ -308,7 +308,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 :
@@ -426,7 +426,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 :
@@ -599,8 +599,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, "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_tc.c +23 -20
139 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +1 -1
@@ -1746,7 +1746,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_offloads.c +4 -4
@@ -127,8 +127,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 ) + flow_act.reformat_id = attr->encap_id; rule =mlx5_add_flow_rules (ft, spec, &flow_act, dest, i);if (IS_ERR (rule))
@@ -529,7 +529,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,
@@ -1245,7 +1245,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
@@ -1407,7 +1407,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 | 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
@@ -169,12 +169,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 ), };
@@ -160,7 +160,7 @@ struct mlx5_flow_act {u32 action;bool has_flow_tag;u32 flow_tag; -u32 encap_id; +u32 reformat_id;u32 modify_id;uintptr_t esp_id;struct mlx5_fs_vlan vlan[MLX5_FS_VLAN_DEPTH ];
include/linux/mlx5/mlx5_ifc.h +25 -25
149 lines not on this page · raw message
Signature · 1 line
2.14.4
PATCH 8/15 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 operation to be done by the HW.
MLX5_REFORMAT_TYPE_L3_TUNNEL_TO_L2: Ability to create generic decap operation where the inner packet doesn't contain L2.
MLX5_REFORMAT_TYPE_L2_TO_L3_TUNNEL: Ability to create generic encap operation to be done by the HW. The L2 of the original packet is dropped.
--- include/linux/mlx5/mlx5_ifc.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
include/linux/mlx5/mlx5_ifc.h +16 -3
@@ -344,8 +344,12 @@ struct mlx5_ifc_flow_table_prop_layout_bits {u8 reserved_at_c[0x1 ];u8 pop_vlan_2[0x1 ];u8 push_vlan_2[0x1 ]; -u8 reserved_at_f[0x11 ]; - +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_14[0xb ];u8 reserved_at_20[0x2 ];u8 log_max_ft_size[0x6 ];u8 log_max_modify_header_context[0x8 ];
@@ -554,7 +558,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;
@@ -4851,6 +4861,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 {
Signature · 1 line
2.14.4
PATCH 9/15 net/mlx5: Pass a namespace for packet reformat ID 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 use that for NIC steering, pass the actual namespace as a parameter.
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 3 +++ drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 8 +++++++- drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h | 2 ++ 3 files changed, 12 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->encap_id);if (err) { mlx5_core_warn(priv->mdev, "Failed to offload cached encapsulation header, %d\n",
@@ -2389,6 +2390,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->encap_id);if (err) goto destroy_neigh_entry;
@@ -2500,6 +2502,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->encap_id);if (err) goto destroy_neigh_entry;
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +7 -1
@@ -600,16 +600,22 @@ int mlx5_packet_reformat_alloc(struct mlx5_core_dev *dev,int reformat_type, size_t size, void *reformat_data, + enum mlx5_flow_namespace_type 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);
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +2 -0
@@ -39,6 +39,7 @@#include <linux/if_link.h> #include <linux/firmware.h> #include <linux/mlx5/cq.h> +#include <linux/mlx5/fs.h> #define DRIVER_NAME "mlx5_core"#define DRIVER_VERSION "5.0-0"
@@ -173,6 +174,7 @@ int mlx5_packet_reformat_alloc(struct mlx5_core_dev *dev,int reformat_type, size_t size, void *reformat_data, + enum mlx5_flow_namespace_type namespace, u32 *packet_reformat_id);void mlx5_packet_reformat_dealloc (struct mlx5_core_dev *dev,u32 packet_reformat_id);
Signature · 1 line
2.14.4
PATCH 10/15 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 | 8 -------- include/linux/mlx5/fs.h | 9 +++++++++ 3 files changed, 11 insertions(+), 8 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +2 -0
@@ -651,6 +651,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)
@@ -666,6 +667,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 -8
@@ -170,14 +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, -enum mlx5_flow_namespace_type namespace, -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
@@ -203,4 +203,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, +enum mlx5_flow_namespace_type namespace, +u32 *packet_reformat_id); +void mlx5_packet_reformat_dealloc (struct mlx5_core_dev *dev, +u32 packet_reformat_id); +#endif
Signature · 1 line
2.14.4
PATCH 11/15 RDMA/uverbs: Add UVERBS_ATTR_CONST_IN to the specs language
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
This makes it clear and safe to access constants passed in from user space. We define a consistent ABI of u64 for all constants, and verify that the data passed in can be represented by the type the user supplies.
The expectation is this will always be used with an enum declaring the constant values, and the user will use the enum type as input to the accessor.
To retrieve the attribute value we introduce two helper calls - one standard which may fail if attribute is not valid and one where caller can provide a default value which will be used in case the attribute is not valid (useful when attribute is optional).
--- drivers/infiniband/core/uverbs_ioctl.c | 23 +++++++++++++++++++ include/rdma/uverbs_ioctl.h | 40 ++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+)
drivers/infiniband/core/uverbs_ioctl.c +23 -0
@@ -611,3 +611,26 @@ int uverbs_copy_to(const struct uverbs_attr_bundle *bundle, size_t idx,return 0 ; }EXPORT_SYMBOL (uverbs_copy_to); + +int _uverbs_get_const (s64 *to,const struct uverbs_attr_bundle *attrs_bundle, +size_t idx,s64 lower_bound,u64 upper_bound, +s64 *def_val) +{ +const struct uverbs_attr *attr; + + attr =uverbs_attr_get (attrs_bundle, idx); +if (IS_ERR (attr)) { +if ((PTR_ERR (attr) != -ENOENT ) || !def_val) +return PTR_ERR (attr); + + *to = *def_val; + }else { + *to = attr->ptr_attr.data; + } + +if (*to < lower_bound || (*to >0 && (u64)*to > upper_bound)) +return -EINVAL ; + +return 0 ; +} +EXPORT_SYMBOL (_uverbs_get_const);
include/rdma/uverbs_ioctl.h +40 -0
@@ -365,6 +365,15 @@ struct uverbs_object_tree_def { __VA_ARGS__ }, \ }) +/* An input value that is a member in the enum _enum_type. */ +#define UVERBS_ATTR_CONST_IN (_attr_id, _enum_type, ...) \ + UVERBS_ATTR_PTR_IN( \ + _attr_id, \ + UVERBS_ATTR_SIZE(sizeof(u64) + BUILD_BUG_ON_ZERO( \ + !sizeof(_enum_type)), \ + sizeof(u64)), \ + __VA_ARGS__) +/* * An input value that is a bitwise combination of values of _enum_type. * This permits the flag value to be passed as either a u32 or u64, it must
@@ -603,6 +612,9 @@ static inline __malloc void *uverbs_zalloc(struct uverbs_attr_bundle *bundle, {return _uverbs_alloc (bundle, size,GFP_KERNEL | __GFP_ZERO); } +int _uverbs_get_const (s64 *to,const struct uverbs_attr_bundle *attrs_bundle, +size_t idx,s64 lower_bound,u64 upper_bound, +s64 *def_val);#else static inline int uverbs_get_flags64(u64 *to, const struct uverbs_attr_bundle *attrs_bundle,
@@ -631,6 +643,34 @@ static inline __malloc void *uverbs_zalloc(struct uverbs_attr_bundle *bundle, {return ERR_PTR (-EINVAL ); } +static inline int +_uverbs_get_const (s64 *to,const struct uverbs_attr_bundle *attrs_bundle, +size_t idx,s64 lower_bound,u64 upper_bound, +s64 *def_val) +{ +return -EINVAL ; +}#endif +#define uverbs_get_const (_to, _attrs_bundle, _idx) \ + ({ \ + s64 _val; \ + int _ret = _uverbs_get_const(&_val, _attrs_bundle, _idx, \ + type_min(typeof(*_to)), \ + type_max(typeof(*_to)), NULL); \ + (*_to) = _val; \ + _ret; \ + }) + +#define uverbs_get_const_default (_to, _attrs_bundle, _idx, _default) \ + ({ \ + s64 _val; \ + s64 _def_val = _default; \ + int _ret = \ + _uverbs_get_const(&_val, _attrs_bundle, _idx, \ + type_min(typeof(*_to)), \ + type_max(typeof(*_to)), &_def_val); \ + (*_to) = _val; \ + _ret; \ + })#endif
Signature · 1 line
2.14.4
PATCH 12/15 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 changes packet headers. The data passed from userspace should be modify header actions as defined by HW specification.
--- drivers/infiniband/hw/mlx5/flow.c | 134 ++++++++++++++++++++++++++++++ drivers/infiniband/hw/mlx5/main.c | 3 + drivers/infiniband/hw/mlx5/mlx5_ib.h | 17 +++- include/uapi/rdma/mlx5_user_ioctl_cmds.h | 10 +++ include/uapi/rdma/mlx5_user_ioctl_verbs.h | 5 ++ 5 files changed, 168 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/flow.c +134 -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>
@@ -16,6 +17,24 @@#define UVERBS_MODULE_NAME mlx5_ib#include <rdma/uverbs_named_ioctl.h> +static int +mlx5_ib_ft_type_to_namespace (enum mlx5_ib_uapi_flow_table_type table_type, +enum mlx5_flow_namespace_type *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 ; +} +static const struct uverbs_attr_spec mlx5_ib_flow_type[] = { [MLX5_IB_FLOW_TYPE_NORMAL ] = { .type =UVERBS_ATTR_TYPE_PTR_IN ,
@@ -175,6 +194,100 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_MATCHER_CREATE)(return err; } +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 : +break ; + } +} + +static struct ib_flow_action * +mlx5_ib_create_modify_header (struct mlx5_ib_dev *dev, +enum mlx5_ib_uapi_flow_table_type ft_type, +u8 num_actions,void *in) +{ +enum mlx5_flow_namespace_type namespace; +struct mlx5_ib_flow_action *maction; +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_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); +enum mlx5_ib_uapi_flow_table_type ft_type; +struct ib_flow_action *action; +size_t num_actions; +void *in; +int len; +int ret; + +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 ; + + ret =uverbs_get_const (&ft_type, attrs, +MLX5_IB_ATTR_CREATE_MODIFY_HEADER_FT_TYPE ); +if (ret) +return -EINVAL ; + + num_actions = len /MLX5_UN_SZ_BYTES (set_action_in_add_action_in_auto), + action =mlx5_ib_create_modify_header (mdev, ft_type, num_actions, 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 +322,26 @@ 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_CONST_IN (MLX5_IB_ATTR_CREATE_MODIFY_HEADER_FT_TYPE , + enum mlx5_ib_uapi_flow_table_type, +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,
@@ -247,6 +380,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 +3 -0
@@ -3995,6 +3995,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 ;
drivers/infiniband/hw/mlx5/mlx5_ib.h +16 -1
@@ -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 )
@@ -814,6 +818,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; }; };
@@ -860,7 +869,7 @@ to_mcounters(struct ib_counters *ibcntrs)struct mlx5_ib_dev {struct ib_device ib_dev; -const struct uverbs_object_tree_def *driver_trees[6 ]; +const struct uverbs_object_tree_def *driver_trees[7 ];struct mlx5_core_dev *mdev;struct mlx5_roce roce[MLX5_MAX_PORTS ];int num_ports;
@@ -1238,6 +1247,7 @@ struct mlx5_ib_flow_handler *mlx5_ib_raw_fs_rule_add( void *cmd_in, int inlen, int dest_id, 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,
@@ -1256,6 +1266,11 @@ mlx5_ib_get_flow_trees(const struct uverbs_object_tree_def **root) {return 0 ; } +static inline 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
Signature · 1 line
2.14.4
Re: [PATCH rdma-next v1 12/15] RDMA/mlx5: Add a new flow action verb - modify header
Quoted 19 lines · Leon Romanovsky
drivers/infiniband/hw/mlx5/flow.c +19
-0+static int UVERBS_HANDLER (MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER )( +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); +enum mlx5_ib_uapi_flow_table_type ft_type; +struct ib_flow_action *action; +size_t num_actions; +void *in; +int len; +int ret; + +if (!mlx5_ib_modify_header_supported (mdev)) +return -EOPNOTSUPP ; + + in =uverbs_attr_get_alloced_ptr (attrs, +MLX5_IB_ATTR_CREATE_MODIFY_HEADER_ACTIONS_PRM );
drivers/infiniband/hw/mlx5/flow.c static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_MATCHER_CREATE)( · line 275
Quoted 10 lines
drivers/infiniband/hw/mlx5/flow.c +10
-0+ 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 ; + + ret =uverbs_get_const (&ft_type, attrs, +MLX5_IB_ATTR_CREATE_MODIFY_HEADER_FT_TYPE ); +if (ret) +return -EINVAL ;
This should be
if (ret) return ret;
Every call to uverbs_get_const is wrong in this same way..
I can probably fix it if this is the only thing though..
Jason
Re: [PATCH rdma-next v1 12/15] RDMA/mlx5: Add a new flow action verb - modify header
Quoted 34 lines · Jason Gunthorpe
Quoted 19 lines · Leon Romanovsky
drivers/infiniband/hw/mlx5/flow.c +19
-0+static int UVERBS_HANDLER (MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER )( +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); +enum mlx5_ib_uapi_flow_table_type ft_type; +struct ib_flow_action *action; +size_t num_actions; +void *in; +int len; +int ret; + +if (!mlx5_ib_modify_header_supported (mdev)) +return -EOPNOTSUPP ; + + in =uverbs_attr_get_alloced_ptr (attrs, +MLX5_IB_ATTR_CREATE_MODIFY_HEADER_ACTIONS_PRM );drivers/infiniband/hw/mlx5/flow.c static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_MATCHER_CREATE)( · line 275
Quoted 10 lines
drivers/infiniband/hw/mlx5/flow.c +10
-0+ 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 ; + + ret =uverbs_get_const (&ft_type, attrs, +MLX5_IB_ATTR_CREATE_MODIFY_HEADER_FT_TYPE ); +if (ret) +return -EINVAL ;This should be
Quoted 4 lines
if (ret) return ret;Every call to
uverbs_get_constis wrong in this same way..
Right, from technical point of view uverbs_get_const can return EINVAL only, and it is correct for now, but need to be changed to proper "return ret".
Quoted 3 lines
I can probably fix it if this is the only thing though..
Thanks, I appreciate it.
Quoted 1 line
Jason
Re: [PATCH rdma-next v1 12/15] RDMA/mlx5: Add a new flow action verb - modify header
Quoted 35 lines · Leon Romanovsky
Quoted 34 lines · Jason Gunthorpe
Quoted 19 lines · Leon Romanovsky
drivers/infiniband/hw/mlx5/flow.c +19
-0+static int UVERBS_HANDLER (MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER )( +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); +enum mlx5_ib_uapi_flow_table_type ft_type; +struct ib_flow_action *action; +size_t num_actions; +void *in; +int len; +int ret; + +if (!mlx5_ib_modify_header_supported (mdev)) +return -EOPNOTSUPP ; + + in =uverbs_attr_get_alloced_ptr (attrs, +MLX5_IB_ATTR_CREATE_MODIFY_HEADER_ACTIONS_PRM );drivers/infiniband/hw/mlx5/flow.c static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_MATCHER_CREATE)( · line 275
Quoted 10 lines
drivers/infiniband/hw/mlx5/flow.c +10
-0+ 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 ; + + ret =uverbs_get_const (&ft_type, attrs, +MLX5_IB_ATTR_CREATE_MODIFY_HEADER_FT_TYPE ); +if (ret) +return -EINVAL ;This should be
Quoted 8 lines
Quoted 4 lines
if (ret) return ret;Every call to
uverbs_get_constis wrong in this same way..Right, from technical point of view
uverbs_get_constcan return EINVAL only, and it is correct for now, but need to be changed to proper "return ret".
No, it can return ENOENT as well.
Jason
Re: [PATCH rdma-next v1 12/15] RDMA/mlx5: Add a new flow action verb - modify header
Quoted 39 lines · Jason Gunthorpe
Quoted 38 lines · Leon Romanovsky
Quoted 37 lines · Jason Gunthorpe
Quoted 19 lines · Leon Romanovsky
drivers/infiniband/hw/mlx5/flow.c +19
-0+static int UVERBS_HANDLER (MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER )( +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); +enum mlx5_ib_uapi_flow_table_type ft_type; +struct ib_flow_action *action; +size_t num_actions; +void *in; +int len; +int ret; + +if (!mlx5_ib_modify_header_supported (mdev)) +return -EOPNOTSUPP ; + + in =uverbs_attr_get_alloced_ptr (attrs, +MLX5_IB_ATTR_CREATE_MODIFY_HEADER_ACTIONS_PRM );drivers/infiniband/hw/mlx5/flow.c static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_MATCHER_CREATE)( · line 275
Quoted 10 lines
drivers/infiniband/hw/mlx5/flow.c +10
-0+ 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 ; + + ret =uverbs_get_const (&ft_type, attrs, +MLX5_IB_ATTR_CREATE_MODIFY_HEADER_FT_TYPE ); +if (ret) +return -EINVAL ;This should be
if (ret) return ret;
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Every call to
uverbs_get_constis wrong in this same way..Right, from technical point of view
uverbs_get_constcan return EINVAL only, and it is correct for now, but need to be changed to proper "return ret".No, it can return ENOENT as well.
Ahh, right, the "|| !def_val" part.
Thanks
Quoted 2 lines
Jason
PATCH 13/15 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
@@ -326,11 +326,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_FLOW_ACTION_ESP_CREATE)(if (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>
@@ -279,11 +280,8 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER)(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; +uverbs_flow_action_fill_action (action, uobj, uobj->context->device, +IB_FLOW_ACTION_UNSPECIFIED );return 0 ; }
include/rdma/uverbs_std_types.h +12 -0
@@ -140,5 +140,17 @@ __uobj_alloc(const struct uverbs_api_object *obj, struct ib_uverbs_file *ufile,#define uobj_alloc (_type, _ufile, _ib_dev) \ __uobj_alloc(uobj_get_type(_ufile, _type), _ufile, _ib_dev) +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
Signature · 1 line
2.14.4
PATCH 14/15 RDMA/mlx5: Add new flow action verb - packet reformat
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
For now, only add L2_TUNNEL_TO_L2 option. This will allow to perform generic decap operation if the encapsulating protocol is L2 based, and the inner packet is also L2 based. For example this can be used to decap VXLAN packets.
--- drivers/infiniband/hw/mlx5/flow.c | 76 ++++++++++++++++++++++++++++++- 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, 87 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/flow.c +75 -1
@@ -202,6 +202,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 :break ; }
@@ -286,6 +288,64 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER)(return 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_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); +enum mlx5_ib_uapi_flow_action_packet_reformat_type dv_prt; +enum mlx5_ib_uapi_flow_table_type ft_type; +struct mlx5_ib_flow_action *maction; +int ret; + + ret =uverbs_get_const (&ft_type, attrs, +MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_FT_TYPE ); +if (ret) +return -EINVAL ; + + ret =uverbs_get_const (&dv_prt, attrs, +MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_TYPE ); +if (ret) +return -EINVAL ; + +if (!mlx5_ib_flow_action_packet_reformat_valid (mdev, dv_prt, ft_type)) +return -EOPNOTSUPP ; + + 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,
@@ -335,10 +395,24 @@ DECLARE_UVERBS_NAMED_METHOD( enum mlx5_ib_uapi_flow_table_type, 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_CONST_IN (MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_TYPE , + enum mlx5_ib_uapi_flow_action_packet_reformat_type, +UA_MANDATORY ), +UVERBS_ATTR_CONST_IN (MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_FT_TYPE , + enum mlx5_ib_uapi_flow_table_type, +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
Signature · 1 line
2.14.4
PATCH 15/15 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 | 95 +++++++++++++++++++++++++++++++ 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, 100 insertions(+)
drivers/infiniband/hw/mlx5/flow.c +95 -0
@@ -202,6 +202,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 :
@@ -293,6 +297,21 @@ 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_TO_L3_TUNNEL : +if (ft_type ==MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_TX ) +return MLX5_CAP_FLOWTABLE_NIC_TX (ibdev->mdev, + reformat_l2_to_l3_tunnel); +break ; +case MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2 : +if (ft_type ==MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_RX ) +return MLX5_CAP_FLOWTABLE_NIC_RX (ibdev->mdev, + reformat_l3_tunnel_to_l2); +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);
@@ -304,6 +323,56 @@ 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) +{ +enum mlx5_flow_namespace_type 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_uverbs_file *file,struct uverbs_attr_bundle *attrs)
@@ -338,12 +407,34 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_ACTION_CREATE_PACKET_REFORMAT)( maction->flow_action_raw.sub_type =MLX5_IB_FLOW_ACTION_DECAP ; maction->flow_action_raw.dev = mdev; + }else { +void *in; +int len; + + in =uverbs_attr_get_alloced_ptr (attrs, +MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_DATA_BUF ); +if (IS_ERR (in)) { + ret =PTR_ERR (in); + goto free_maction; + } + + len =uverbs_attr_get_len (attrs, +MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_DATA_BUF ); + + 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(
@@ -401,6 +492,10 @@ DECLARE_UVERBS_NAMED_METHOD( UVERBS_OBJECT_FLOW_ACTION,UVERBS_ACCESS_NEW , UA_MANDATORY), +UVERBS_ATTR_PTR_IN (MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_DATA_BUF , + UVERBS_ATTR_MIN_SIZE(1), +UA_ALLOC_AND_COPY , +UA_OPTIONAL ),UVERBS_ATTR_CONST_IN (MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_TYPE ,enum mlx5_ib_uapi_flow_action_packet_reformat_type , UA_MANDATORY),
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_BUF, };#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
Signature · 1 line
2.14.4
Quoted 105 lines · Leon Romanovsky
From: Leon Romanovsky <[email protected]>
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.The first 10 patches refactor
mlx5_corecode, rename internal structures to better reflect their operation and export needed functions so the RDMA side can allocate the action.The last 5 patches expose via the IOCTL infrastructure
mlx5_ibmethods which do the actual allocation of resources and return an handle to the user. A user of this API is expected to know how to work with the device's spec as the input to those function is HW depended.An example usage of the modify header action is routing, A user can create an action which edits the L2 header and decrease the TTL.
An example usage of the packet reformat action is VXLAN encap/decap which is done by the HW.
Changelog:
v0 -> v1:
* Patch 1: Addressed Saeed's comments and simplified the logic.
* Patch 2: Changed due to changes in patch 1.Split the 27 patch series into 3, this is the first one which just lets the user create flow action. Other than that styling fixes mainly in the RDMA patches to make sure 80 chars limit isn't exceeded.
RFC -> v0:
* Patch 1 a new patch which refactors the logic
when getting a flow namespace.
* Patch 2 was split into two.
* Patch 3: Fixed a typo in commit message
* Patch 5: Updated commit message
* Patch 7: Updated commit message
Renamed:
-MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT_IDtoMLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT
-packet_reformat_idtoreformat_idin structmlx5_flow_act
-packet_reformat_idtoencap_idin structmlx5_esw_flow_attr
-packet_reformat_idtoencap_idin structmlx5e_encap_entry
-PACKET_REFORMATto REFORMAT when printing trace points
* Patch 9: Updated commit message
Updated function declaration inmlx5_core.h, could of lead to compile error on bisection.
* Patch 11: Disallow egress rules insertion when in switchdev mode
* Patch 12: A new patch to deal with passing enum values using the IOCTL infrastructure.
* Patch 13: Use new enum value attribute when passing enummlx5_ib_uapi_flow_table_type
* Patch 15: Don't set encap flags on flow tables if in switchdev mode
* Patch 17: Use new enum value attribute when passing enummlx5_ib_uapi_flow_table_typeand enummlx5_ib_uapi_flow_action_packet_reformat_type
* Patch 19: Allow creation of bothMLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L3_TUNNELandMLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2
packet
reformat actions.
* Patch 20: A new patch which allows attaching packet reformat actions to flow tables on NIC RX.Thanks
Mark Bloch (15):
net/mlx5: Cleanup flow namespace getter switch logic 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 flow table creation
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: Pass a namespace for packet reformat ID allocation net/mlx5: Export packet reformat alloc/dealloc functions RDMA/uverbs: AddUVERBS_ATTR_CONST_INto the specs language RDMA/mlx5: Add a new flow action verb - modify header RDMA/uverbs: Add generic function to fill in flow action object RDMA/mlx5: Add new flow action verb - packet reformat RDMA/mlx5: Extend packet reformat verbsdrivers/infiniband/core/uverbs_ioctl.c | 23 ++ .../infiniband/core/uverbs_std_types_flow_action.c | 7 +- drivers/infiniband/hw/mlx5/devx.c | 6 +- drivers/infiniband/hw/mlx5/flow.c | 301 +++++++++++++++++++++ drivers/infiniband/hw/mlx5/main.c | 3 + drivers/infiniband/hw/mlx5/mlx5_ib.h | 19 +- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 8 +- .../mellanox/mlx5/core/diag/fs_tracepoint.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 51 ++-- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 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 | 73 +++-- .../net/ethernet/mellanox/mlx5/core/mlx5_core.h | 12 +-
Quoted 8 lines
include/linux/mlx5/device.h | 6 + include/linux/mlx5/fs.h | 20 +- include/linux/mlx5/mlx5_ifc.h | 70 +++-- include/rdma/uverbs_ioctl.h | 40 +++ 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, 638 insertions(+), 143 deletions(-)
This looks OK to me, can you make the shared commit please?
Thanks,
Jason
Quoted 115 lines · Jason Gunthorpe
Quoted 105 lines · Leon Romanovsky
From: Leon Romanovsky <[email protected]>
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.The first 10 patches refactor
mlx5_corecode, rename internal structures to better reflect their operation and export needed functions so the RDMA side can allocate the action.The last 5 patches expose via the IOCTL infrastructure
mlx5_ibmethods which do the actual allocation of resources and return an handle to the user. A user of this API is expected to know how to work with the device's spec as the input to those function is HW depended.An example usage of the modify header action is routing, A user can create an action which edits the L2 header and decrease the TTL.
An example usage of the packet reformat action is VXLAN encap/decap which is done by the HW.
Changelog:
v0 -> v1:
* Patch 1: Addressed Saeed's comments and simplified the logic.
* Patch 2: Changed due to changes in patch 1.Split the 27 patch series into 3, this is the first one which just lets the user create flow action. Other than that styling fixes mainly in the RDMA patches to make sure 80 chars limit isn't exceeded.
RFC -> v0:
* Patch 1 a new patch which refactors the logic
when getting a flow namespace.
* Patch 2 was split into two.
* Patch 3: Fixed a typo in commit message
* Patch 5: Updated commit message
* Patch 7: Updated commit message
Renamed:
-MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT_IDtoMLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT
-packet_reformat_idtoreformat_idin structmlx5_flow_act
-packet_reformat_idtoencap_idin structmlx5_esw_flow_attr
-packet_reformat_idtoencap_idin structmlx5e_encap_entry
-PACKET_REFORMATto REFORMAT when printing trace points
* Patch 9: Updated commit message
Updated function declaration inmlx5_core.h, could of lead to compile error on bisection.
* Patch 11: Disallow egress rules insertion when in switchdev mode
* Patch 12: A new patch to deal with passing enum values using the IOCTL infrastructure.
* Patch 13: Use new enum value attribute when passing enummlx5_ib_uapi_flow_table_type
* Patch 15: Don't set encap flags on flow tables if in switchdev mode
* Patch 17: Use new enum value attribute when passing enummlx5_ib_uapi_flow_table_typeand enummlx5_ib_uapi_flow_action_packet_reformat_type
* Patch 19: Allow creation of bothMLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L3_TUNNELandMLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2
packet
reformat actions.
* Patch 20: A new patch which allows attaching packet reformat actions to flow tables on NIC RX.Thanks
Mark Bloch (15):
net/mlx5: Cleanup flow namespace getter switch logic 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 flow table creation
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: Pass a namespace for packet reformat ID allocation net/mlx5: Export packet reformat alloc/dealloc functions RDMA/uverbs: AddUVERBS_ATTR_CONST_INto the specs language RDMA/mlx5: Add a new flow action verb - modify header RDMA/uverbs: Add generic function to fill in flow action object RDMA/mlx5: Add new flow action verb - packet reformat RDMA/mlx5: Extend packet reformat verbsdrivers/infiniband/core/uverbs_ioctl.c | 23 ++ .../infiniband/core/uverbs_std_types_flow_action.c | 7 +- drivers/infiniband/hw/mlx5/devx.c | 6 +- drivers/infiniband/hw/mlx5/flow.c | 301 +++++++++++++++++++++ drivers/infiniband/hw/mlx5/main.c | 3 + drivers/infiniband/hw/mlx5/mlx5_ib.h | 19 +- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 8 +- .../mellanox/mlx5/core/diag/fs_tracepoint.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 51 ++-- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 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 | 73 +++-- .../net/ethernet/mellanox/mlx5/core/mlx5_core.h | 12 +-Quoted 8 lines
include/linux/mlx5/device.h | 6 + include/linux/mlx5/fs.h | 20 +- include/linux/mlx5/mlx5_ifc.h | 70 +++-- include/rdma/uverbs_ioctl.h | 40 +++ 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, 638 insertions(+), 143 deletions(-)
Quoted 1 line
This looks OK to me, can you make the shared commit please?
Thanks, I pushed to mlx5-next
50acec06f392 net/mlx5: Export packet reformat alloc/dealloc functions 31ca3648f01b net/mlx5: Pass a namespace for packet reformat ID allocation bea4e1f6c6c5 net/mlx5: Expose new packet reformat capabilities 60786f0987c0 {net, RDMA}/mlx5: Rename encap to reformat packet e0e7a3861b6c net/mlx5: Move header encap type to IFC header file 61444b458b01 net/mlx5: Break encap/decap into two separated flow table creation flags c3c062f80665 net/mlx5: Add support for more namespaces when allocating modify header 90c1d1b8da67 net/mlx5: Export modify header alloc/dealloc functions 8ce78257965e net/mlx5: Add proper NIC TX steering flow tables support 2226dcb424bf net/mlx5: Cleanup flow namespace getter switch logic
Quoted 3 lines
Thanks,
Jason
Quoted 4 lines · Leon Romanovsky
Quoted 1 line
This looks OK to me, can you make the shared commit please?
Thanks, I pushed to mlx5-next
Quoted 10 lines
50acec06f392net/mlx5: Export packet reformat alloc/dealloc functions31ca3648f01bnet/mlx5: Pass a namespace for packet reformat ID allocationbea4e1f6c6c5net/mlx5: Expose new packet reformat capabilities60786f0987c0{net, RDMA}/mlx5: Rename encap to reformat packete0e7a3861b6cnet/mlx5: Move header encap type to IFC header file61444b458b01net/mlx5: Break encap/decap into two separated flow table creation flagsc3c062f80665net/mlx5: Add support for more namespaces when allocating modify header90c1d1b8da67net/mlx5: Export modify header alloc/dealloc functions8ce78257965enet/mlx5: Add proper NIC TX steering flow tables support2226dcb424bfnet/mlx5: Cleanup flow namespace getter switch logic
Okay, done thanks
Jason