]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
devlink: Support setting port function ipsec_packet cap
authorDima Chumak <dchumak@nvidia.com>
Mon, 2 Oct 2023 10:43:49 +0000 (13:43 +0300)
committerDavid Ahern <dsahern@kernel.org>
Wed, 4 Oct 2023 15:23:11 +0000 (09:23 -0600)
Support 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

Signed-off-by: Dima Chumak <dchumak@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
devlink/devlink.c
man/man8/devlink-port.8

index 7852a47fc98a92ba6c107abbeb7ce4e412b29256..3baad355759e353d06fdc08d45834d4a0018cf04 100644 (file)
@@ -2283,6 +2283,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;
@@ -4656,7 +4668,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");
@@ -4786,6 +4798,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)
@@ -4977,7 +4993,7 @@ static void cmd_port_function_help(void)
 {
        pr_err("Usage: 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");
 }
 
index 534d2cbe8fa9398c8553ac7bb0212792f246fe8b..70d8837eabc0a200b9811d86f5c409a9488c168e 100644 (file)
@@ -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