devlink: Add port function attributes
Subsystems (3)
v2 cover devlink: Add port function attributes
Please, see kernel series of the same subject for the overview of these changes.
---
v1 -> v2:
- updated cover letter, no other changes in devlink user-space patches
Dima Chumak (3):
Update kernel headers
devlink: Support setting port function ipsec_crypto cap
devlink: Support setting port function ipsec_packet cap
devlink/devlink.c | 34 ++++++++++++++++++++++++++++++++++ include/uapi/linux/devlink.h | 4 ++++ man/man8/devlink-port.8 | 26 ++++++++++++++++++++++++++ 3 files changed, 64 insertions(+)
Signature · 1 line
2.40.0
PATCH v2 1/3 Update kernel headers
--- include/uapi/linux/devlink.h | 4 ++++ 1 file changed, 4 insertions(+)
include/uapi/linux/devlink.h +4 -0
@@ -661,6 +661,8 @@ enum devlink_resource_unit {enum devlink_port_fn_attr_cap {DEVLINK_PORT_FN_ATTR_CAP_ROCE_BIT ,DEVLINK_PORT_FN_ATTR_CAP_MIGRATABLE_BIT , +DEVLINK_PORT_FN_ATTR_CAP_IPSEC_CRYPTO_BIT , +DEVLINK_PORT_FN_ATTR_CAP_IPSEC_PACKET_BIT ,/* Add new caps above */ __DEVLINK_PORT_FN_ATTR_CAPS_MAX,
@@ -669,6 +671,8 @@ enum devlink_port_fn_attr_cap {#define DEVLINK_PORT_FN_CAP_ROCE _BITUL(DEVLINK_PORT_FN_ATTR_CAP_ROCE_BIT)#define DEVLINK_PORT_FN_CAP_MIGRATABLE \ _BITUL(DEVLINK_PORT_FN_ATTR_CAP_MIGRATABLE_BIT) +#define DEVLINK_PORT_FN_CAP_IPSEC_CRYPTO _BITUL(DEVLINK_PORT_FN_ATTR_CAP_IPSEC_CRYPTO_BIT) +#define DEVLINK_PORT_FN_CAP_IPSEC_PACKET _BITUL(DEVLINK_PORT_FN_ATTR_CAP_IPSEC_PACKET_BIT)enum devlink_port_function_attr {DEVLINK_PORT_FUNCTION_ATTR_UNSPEC ,
Signature · 1 line
2.40.0
PATCH v2 2/3 devlink: Support setting port function ipsec_crypto cap
In reply to Dima ChumakSupport port function commands to enable / disable IPsec crypto offloads, this is used to control the port IPsec device capabilities.
When IPsec crypto capability is disabled for a function of the port (default), function cannot offload IPsec operation. When enabled, IPsec operation can be offloaded by the function of the port.
Enabling IPsec crypto offloads lets the kernel to delegate XFRM state processing and encrypt/decrypt operation to the device hardware.
Example of a PCI VF port which supports IPsec crypto offloads:
$ devlink port show pci/0000:06:00.0/1
pci/0000:06:00.0/1: type eth netdev enp6s0pf0vf0 flavour pcivf pfnum 0 vfnum 0
function:
hw_addr 00:00:00:00:00:00 roce enable ipsec_crypto disable$ devlink port function set pci/0000:06:00.0/1 ipsec_crypto enable
$ devlink port show pci/0000:06:00.0/1
pci/0000:06:00.0/1: type eth netdev enp6s0pf0vf0 flavour pcivf pfnum 0 vfnum 0
function:
hw_addr 00:00:00:00:00:00 roce enable ipsec_crypto enable--- devlink/devlink.c | 18 ++++++++++++++++++ man/man8/devlink-port.8 | 13 +++++++++++++ 2 files changed, 31 insertions(+)
devlink/devlink.c +18 -0
@@ -2258,6 +2258,18 @@ static int dl_argv_parse(struct dl *dl, uint64_t o_required,if (mig) opts->port_fn_caps.value |=DEVLINK_PORT_FN_CAP_MIGRATABLE ; o_found |=DL_OPT_PORT_FN_CAPS ; + }else if (dl_argv_match (dl,"ipsec_crypto" ) && + (o_all &DL_OPT_PORT_FN_CAPS )) { +bool ipsec_crypto; + +dl_arg_inc (dl); + err =dl_argv_bool (dl, &ipsec_crypto); +if (err) +return err; + opts->port_fn_caps.selector |=DEVLINK_PORT_FN_CAP_IPSEC_CRYPTO ; +if (ipsec_crypto) + opts->port_fn_caps.value |=DEVLINK_PORT_FN_CAP_IPSEC_CRYPTO ; + o_found |=DL_OPT_PORT_FN_CAPS ; }else {pr_err ("Unknown option \"%s\"\n" ,dl_argv (dl));return -EINVAL ;
@@ -4536,6 +4548,7 @@ static void cmd_port_help(void)pr_err (" devlink port unsplit DEV/PORT_INDEX\n" );pr_err (" devlink port function set DEV/PORT_INDEX [ hw_addr ADDR ] [ state { active | inactive } ]\n" );pr_err (" [ roce { enable | disable } ] [ migratable { enable | disable } ]\n" ); +pr_err (" [ ipsec_crypto { enable | disable } ]\n" );pr_err (" devlink port function rate { help | show | add | del | set }\n" );pr_err (" devlink port param set DEV/PORT_INDEX name PARAMETER value VALUE cmode { permanent | driverinit | runtime }\n" );pr_err (" devlink port param show [DEV/PORT_INDEX name PARAMETER]\n" );
@@ -4661,6 +4674,10 @@ static void pr_out_port_function(struct dl *dl, struct nlattr **tb_port)print_string (PRINT_ANY ,"migratable" ," migratable %s" , port_fn_caps->value &DEVLINK_PORT_FN_CAP_MIGRATABLE ?"enable" :"disable" ); +if (port_fn_caps->selector &DEVLINK_PORT_FN_CAP_IPSEC_CRYPTO ) +print_string (PRINT_ANY ,"ipsec_crypto" ," ipsec_crypto %s" , + port_fn_caps->value &DEVLINK_PORT_FN_CAP_IPSEC_CRYPTO ? +"enable" :"disable" ); }if (!dl->json_output)
@@ -4857,6 +4874,7 @@ static void cmd_port_function_help(void) {pr_err ("Usage: devlink port function set DEV/PORT_INDEX [ hw_addr ADDR ] [ state STATE ]\n" );pr_err (" [ roce { enable | disable } ] [ migratable { enable | disable } ]\n" ); +pr_err (" [ ipsec_crypto { enable | disable } ]\n" );pr_err (" devlink port function rate { help | show | add | del | set }\n" ); }
man/man8/devlink-port.8 +13 -0
@@ -77,6 +77,9 @@ devlink-port \- devlink port configuration .RI "[ " .BR migratable " { " enable " | " disable " }" .RI "]" +.RI "[ " +.BR ipsec_crypto " { " enable " | " disable " }" +.RI "]" .ti -8 .BR "devlink port function rate "
@@ -222,6 +225,11 @@ Set the RoCE capability of the function. .BR migratable " { " enable " | " disable " } " Set the migratable capability of the function. +.TP +.BR ipsec_crypto " { " enable " | " disable " } " +Set the IPsec crypto offload capability of the function. Controls XFRM state +crypto operation (Encrypt/Decrypt) offload. + .ti -8 .SS devlink port del - delete a devlink port .PP
@@ -351,6 +359,11 @@ devlink port function set pci/0000:01:00.0/1 migratable enable This will enable the migratable functionality of the function. .RE .PP +devlink port function set pci/0000:01:00.0/1 ipsec_crypto enable +.RS 4 +This will enable the IPsec crypto offload functionality of the function. +.RE +.PP devlink port function set pci/0000:01:00.0/1 hw_addr 00:00:00:11:22:33 state active .RS 4 Configure hardware address and also active the function. When a function is
Signature · 1 line
2.40.0
PATCH v2 3/3 devlink: Support setting port function ipsec_packet cap
In reply to Dima ChumakSupport port function commands to enable / disable IPsec packet offloads, this is used to control the port IPsec device capabilities.
When IPsec packet capability is disabled for a function of the port (default), function cannot offload IPsec operation. When enabled, IPsec operation can be offloaded by the function of the port.
Enabling IPsec packet offloads lets the kernel to delegate encrypt/decrypt operations, as well as encapsulation and SA/policy and state to the device hardware.
Example of a PCI VF port which supports IPsec packet offloads:
$ devlink port show pci/0000:06:00.0/1
pci/0000:06:00.0/1: type eth netdev enp6s0pf0vf0 flavour pcivf pfnum 0 vfnum 0
function:
hw_addr 00:00:00:00:00:00 roce enable ipsec_crypto disable ipsec_packet disable$ devlink port function set pci/0000:06:00.0/1 ipsec_packet enable
$ devlink port show pci/0000:06:00.0/1
pci/0000:06:00.0/1: type eth netdev enp6s0pf0vf0 flavour pcivf pfnum 0 vfnum 0
function:
hw_addr 00:00:00:00:00:00 roce enable ipsec_crypto disable ipsec_packet enable--- devlink/devlink.c | 20 ++++++++++++++++++-- man/man8/devlink-port.8 | 13 +++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-)
devlink/devlink.c +18 -2
@@ -2270,6 +2270,18 @@ static int dl_argv_parse(struct dl *dl, uint64_t o_required,if (ipsec_crypto) opts->port_fn_caps.value |=DEVLINK_PORT_FN_CAP_IPSEC_CRYPTO ; o_found |=DL_OPT_PORT_FN_CAPS ; + }else if (dl_argv_match (dl,"ipsec_packet" ) && + (o_all &DL_OPT_PORT_FN_CAPS )) { +bool ipsec_packet; + +dl_arg_inc (dl); + err =dl_argv_bool (dl, &ipsec_packet); +if (err) +return err; + opts->port_fn_caps.selector |=DEVLINK_PORT_FN_CAP_IPSEC_PACKET ; +if (ipsec_packet) + opts->port_fn_caps.value |=DEVLINK_PORT_FN_CAP_IPSEC_PACKET ; + o_found |=DL_OPT_PORT_FN_CAPS ; }else {pr_err ("Unknown option \"%s\"\n" ,dl_argv (dl));return -EINVAL ;
@@ -4548,7 +4560,7 @@ static void cmd_port_help(void)pr_err (" devlink port unsplit DEV/PORT_INDEX\n" );pr_err (" devlink port function set DEV/PORT_INDEX [ hw_addr ADDR ] [ state { active | inactive } ]\n" );pr_err (" [ roce { enable | disable } ] [ migratable { enable | disable } ]\n" ); -pr_err (" [ ipsec_crypto { enable | disable } ]\n" ); +pr_err (" [ ipsec_crypto { enable | disable } ] [ ipsec_packet { enable | disable } ]\n" );pr_err (" devlink port function rate { help | show | add | del | set }\n" );pr_err (" devlink port param set DEV/PORT_INDEX name PARAMETER value VALUE cmode { permanent | driverinit | runtime }\n" );pr_err (" devlink port param show [DEV/PORT_INDEX name PARAMETER]\n" );
@@ -4678,6 +4690,10 @@ static void pr_out_port_function(struct dl *dl, struct nlattr **tb_port)print_string (PRINT_ANY ,"ipsec_crypto" ," ipsec_crypto %s" , port_fn_caps->value &DEVLINK_PORT_FN_CAP_IPSEC_CRYPTO ?"enable" :"disable" ); +if (port_fn_caps->selector &DEVLINK_PORT_FN_CAP_IPSEC_PACKET ) +print_string (PRINT_ANY ,"ipsec_packet" ," ipsec_packet %s" , + port_fn_caps->value &DEVLINK_PORT_FN_CAP_IPSEC_PACKET ? +"enable" :"disable" ); }if (!dl->json_output)
@@ -4874,7 +4890,7 @@ static void cmd_port_function_help(void) {pr_err ("Usage: devlink port function set DEV/PORT_INDEX [ hw_addr ADDR ] [ state STATE ]\n" );pr_err (" [ roce { enable | disable } ] [ migratable { enable | disable } ]\n" ); -pr_err (" [ ipsec_crypto { enable | disable } ]\n" ); +pr_err (" [ ipsec_crypto { enable | disable } ] [ ipsec_packet { enable | disable } ]\n" );pr_err (" devlink port function rate { help | show | add | del | set }\n" ); }
man/man8/devlink-port.8 +13 -0
@@ -80,6 +80,9 @@ devlink-port \- devlink port configuration .RI "[ " .BR ipsec_crypto " { " enable " | " disable " }" .RI "]" +.RI "[ " +.BR ipsec_packet " { " enable " | " disable " }" +.RI "]" .ti -8 .BR "devlink port function rate "
@@ -230,6 +233,11 @@ Set the migratable capability of the function. Set the IPsec crypto offload capability of the function. Controls XFRM state crypto operation (Encrypt/Decrypt) offload. +.TP +.BR ipsec_packet " { " enable " | " disable " } " +Set the IPsec packet offload capability of the function. Controls XFRM state +and policy offload (Encrypt/Decrypt operation and IPsec encapsulation). + .ti -8 .SS devlink port del - delete a devlink port .PP
@@ -364,6 +372,11 @@ devlink port function set pci/0000:01:00.0/1 ipsec_crypto enable This will enable the IPsec crypto offload functionality of the function. .RE .PP +devlink port function set pci/0000:01:00.0/1 ipsec_packet enable +.RS 4 +This will enable the IPsec packet offload functionality of the function. +.RE +.PP devlink port function set pci/0000:01:00.0/1 hw_addr 00:00:00:11:22:33 state active .RS 4 Configure hardware address and also active the function. When a function is
Signature · 1 line
2.40.0