Skip to contentSkip to conversation

devlink: Add port function attribute for IO EQs

PATCH Superseded Parav Pandit 2 participants 5 messages Apr 1, 2024

Subsystems (6)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover devlink: Add port function attribute for IO EQs

Currently, PCI SFs and VFs use IO event queues to deliver netdev per channel events. The number of netdev channels is a function of IO event queues. In the second scenario of an RDMA device, the completion vectors are also a function of IO event queues. Currently, an administrator on the hypervisor has no means to provision the number of IO event queues for the SF device or the VF device. Device/firmware determines some arbitrary value for these IO event queues. Due to this, the SF netdev channels are unpredictable, and consequently, the performance is too.

This short series introduces a new port function attribute: max_io_eqs. The goal is to provide administrators at the hypervisor level with the ability to provision the maximum number of IO event queues for a function. This gives the control to the administrator to provision right number of IO event queues and have predictable performance.

Examples of when an administrator provisions (set) maximum number of IO event queues when using switchdev mode:

  $ 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 max_io_eqs 10
  $ devlink port function set pci/0000:06:00.0/1 max_io_eqs 20
  $ 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 max_io_eqs 20

This sets the corresponding maximum IO event queues of the function before it is enumerated. Thus, when the VF/SF driver reads the capability from the device, it sees the value provisioned by the hypervisor. The driver is then able to configure the number of channels for the net device, as well as the number of completion vectors for the RDMA device. The device/firmware also honors the provisioned value, hence any VF/SF driver attempting to create IO EQs beyond provisioned value results in an error.

With above setting now, the administrator is able to achieve the 2x performance on SFs with 20 channels. In second example when SF was provisioned for a container with 2 cpus, the administrator provisioned only 2 IO event queues, thereby saving device resources.

With the above settings now in place, the administrator achieved 2x performance with the SF device with 20 channels. In the second example, when the SF was provisioned for a container with 2 CPUs, the administrator provisioned only 2 IO event queues, thereby saving device resources.

Parav Pandit (2):
devlink: Support setting max_io_eqs
mlx5/core: Support max_io_eqs for a function

 .../networking/devlink/devlink-port.rst       | 25 +++++
 .../mellanox/mlx5/core/esw/devlink_port.c     |  2 +
 .../net/ethernet/mellanox/mlx5/core/eswitch.h |  7 ++
 .../mellanox/mlx5/core/eswitch_offloads.c     | 94 +++++++++++++++++++
 include/net/devlink.h                         | 14 +++
 include/uapi/linux/devlink.h                  |  1 +
 net/devlink/port.c                            | 52 ++++++++++
 7 files changed, 195 insertions(+)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/2 devlink: Support setting max_io_eqs

Many devices send event notifications for the IO queues, such as tx and rx queues, through event queues.

Enable a privileged owner, such as a hypervisor PF, to set the number of IO event queues for the VF and SF during the provisioning stage.

example:
Get maximum IO event queues of the VF device::

  $ devlink port show pci/0000:06:00.0/2
  pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1
      function:
          hw_addr 00:00:00:00:00:00 ipsec_packet disabled max_io_eqs 10

Set maximum IO event queues of the VF device::

  $ devlink port function set pci/0000:06:00.0/2 max_io_eqs 32
  $ devlink port show pci/0000:06:00.0/2
  pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1
      function:
          hw_addr 00:00:00:00:00:00 ipsec_packet disabled max_io_eqs 32
---
 .../networking/devlink/devlink-port.rst       | 25 +++++++++
 include/net/devlink.h                         | 14 +++++
 include/uapi/linux/devlink.h                  |  1 +
 net/devlink/port.c                            | 52 +++++++++++++++++++
 4 files changed, 92 insertions(+)
Documentation/networking/devlink/devlink-port.rst +25 -0
index 562f46b41274..451f57393f11 100644
@@ -134,6 +134,9 @@ Users may also set the IPsec crypto capability of the function using
 Users may also set the IPsec packet capability of the function using
 `devlink port function set ipsec_packet` command.
 
+Users may also set the maximum IO event queues of the function
+using `devlink port function set max_io_eqs` command.
+
 Function attributes
 ===================
 
@@ -295,6 +298,28 @@ policy is processed in software by the kernel.
         function:
             hw_addr 00:00:00:00:00:00 ipsec_packet enabled
 
+Maximum IO events queues setup
+------------------------------
+When user sets maximum number of IO event queues for a SF or
+a VF, such function driver is limited to consume only enforced
+number of IO event queues.
+
+- Get maximum IO event queues of the VF device::
+
+    $ devlink port show pci/0000:06:00.0/2
+    pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1
+        function:
+            hw_addr 00:00:00:00:00:00 ipsec_packet disabled max_io_eqs 10
+
+- Set maximum IO event queues of the VF device::
+
+    $ devlink port function set pci/0000:06:00.0/2 max_io_eqs 32
+
+    $ devlink port show pci/0000:06:00.0/2
+    pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1
+        function:
+            hw_addr 00:00:00:00:00:00 ipsec_packet disabled max_io_eqs 32
+
 Subfunction
 ============
 
include/net/devlink.h +14 -0
index 9ac394bdfbe4..a270e71dee0e 100644
@@ -1602,6 +1602,14 @@ void devlink_free(struct devlink *devlink);
  *			      capability. Should be used by device drivers to
  *			      enable/disable ipsec_packet capability of a
  *			      function managed by the devlink port.
+ * @port_fn_max_io_eqs_get: Callback used to get port function's maximum number of
+ *			    event queues. Should be used by device drivers to
+ *			    report the maximum event queues of a function
+ *			    managed by the devlink port.
+ * @port_fn_max_io_eqs_set: Callback used to set port function's maximum number of
+ *			    event queues. Should be used by device drivers to
+ *			    configure maximum number of event queues
+ *			    of a function managed by the devlink port.
  *
  * Note: Driver should return -EOPNOTSUPP if it doesn't support
  * port function (@port_fn_*) handling for a particular port.
@@ -1651,6 +1659,12 @@ struct devlink_port_ops {
 	int (*port_fn_ipsec_packet_set)(struct devlink_port *devlink_port,
 					bool enable,
 					struct netlink_ext_ack *extack);
+	int (*port_fn_max_io_eqs_get)(struct devlink_port *devlink_port,
+				      u32 *max_eqs,
+				      struct netlink_ext_ack *extack);
+	int (*port_fn_max_io_eqs_set)(struct devlink_port *devlink_port,
+				      u32 max_eqs,
+				      struct netlink_ext_ack *extack);
 };
 
 void devlink_port_init(struct devlink *devlink,
include/uapi/linux/devlink.h +1 -0
index 2da0c7eb6710..9401aa343673 100644
@@ -686,6 +686,7 @@ enum devlink_port_function_attr {
 	DEVLINK_PORT_FN_ATTR_OPSTATE,	/* u8 */
 	DEVLINK_PORT_FN_ATTR_CAPS,	/* bitfield32 */
 	DEVLINK_PORT_FN_ATTR_DEVLINK,	/* nested */
+	DEVLINK_PORT_FN_ATTR_MAX_IO_EQS,	/* u32 */
 
 	__DEVLINK_PORT_FUNCTION_ATTR_MAX,
 	DEVLINK_PORT_FUNCTION_ATTR_MAX = __DEVLINK_PORT_FUNCTION_ATTR_MAX - 1
net/devlink/port.c +52 -0

88 lines not on this page · raw message

Signature · 1 line
2.26.2
#2 lore raw

PATCH 2/2 mlx5/core: Support max_io_eqs for a function

In reply to Parav Pandit

Implement get and set for the maximum IO event queues for SF and VF. This enables administrator on the hypervisor to control the maximum IO event queues which are typically used to derive the maximum and default number of net device channels or rdma device completion vectors.

---
 .../mellanox/mlx5/core/esw/devlink_port.c     |  2 +
 .../net/ethernet/mellanox/mlx5/core/eswitch.h |  7 ++
 .../mellanox/mlx5/core/eswitch_offloads.c     | 94 +++++++++++++++++++
 3 files changed, 103 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/esw/devlink_port.c +2 -0
index d8e739cbcbce..76d1ed93c773 100644
@@ -98,6 +98,8 @@ static const struct devlink_port_ops mlx5_esw_pf_vf_dl_port_ops = {
 	.port_fn_ipsec_packet_get = mlx5_devlink_port_fn_ipsec_packet_get,
 	.port_fn_ipsec_packet_set = mlx5_devlink_port_fn_ipsec_packet_set,
 #endif /* CONFIG_XFRM_OFFLOAD */
+	.port_fn_max_io_eqs_get = mlx5_devlink_port_fn_max_io_eqs_get,
+	.port_fn_max_io_eqs_set = mlx5_devlink_port_fn_max_io_eqs_set,
 };
 
 static void mlx5_esw_offloads_sf_devlink_port_attrs_set(struct mlx5_eswitch *esw,
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +7 -0
index 349e28a6dd8d..50ce1ea20dd4 100644
@@ -573,6 +573,13 @@ int mlx5_devlink_port_fn_ipsec_packet_get(struct devlink_port *port, bool *is_en
 int mlx5_devlink_port_fn_ipsec_packet_set(struct devlink_port *port, bool enable,
 					  struct netlink_ext_ack *extack);
 #endif /* CONFIG_XFRM_OFFLOAD */
+int mlx5_devlink_port_fn_max_io_eqs_get(struct devlink_port *port,
+					u32 *max_io_eqs,
+					struct netlink_ext_ack *extack);
+int mlx5_devlink_port_fn_max_io_eqs_set(struct devlink_port *port,
+					u32 max_io_eqs,
+					struct netlink_ext_ack *extack);
+
 void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8 rep_type);
 
 int __mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw,
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +94 -0

103 lines not on this page · raw message

Signature · 1 line
2.26.2
#3 lore raw

Re: [net-next 2/2] mlx5/core: Support max_io_eqs for a function

Quoted 89 lines · Parav Pandit

Implement get and set for the maximum IO event queues for SF and VF. This enables administrator on the hypervisor to control the maximum IO event queues which are typically used to derive the maximum and default number of net device channels or rdma device completion vectors.

---
 .../mellanox/mlx5/core/esw/devlink_port.c     |  2 +
 .../net/ethernet/mellanox/mlx5/core/eswitch.h |  7 ++
 .../mellanox/mlx5/core/eswitch_offloads.c     | 94 +++++++++++++++++++
 3 files changed, 103 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/esw/devlink_port.c +2 -0
index d8e739cbcbce..76d1ed93c773 100644
@@ -98,6 +98,8 @@ static const struct devlink_port_ops mlx5_esw_pf_vf_dl_port_ops = {
        .port_fn_ipsec_packet_get = mlx5_devlink_port_fn_ipsec_packet_get,
        .port_fn_ipsec_packet_set = mlx5_devlink_port_fn_ipsec_packet_set,
 #endif /* CONFIG_XFRM_OFFLOAD */
+       .port_fn_max_io_eqs_get = mlx5_devlink_port_fn_max_io_eqs_get,
+       .port_fn_max_io_eqs_set = mlx5_devlink_port_fn_max_io_eqs_set,
 };
 
 static void mlx5_esw_offloads_sf_devlink_port_attrs_set(struct mlx5_eswitch *esw,
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +7 -0
index 349e28a6dd8d..50ce1ea20dd4 100644
@@ -573,6 +573,13 @@ int mlx5_devlink_port_fn_ipsec_packet_get(struct devlink_port *port, bool *is_en
 int mlx5_devlink_port_fn_ipsec_packet_set(struct devlink_port *port, bool enable,
                                          struct netlink_ext_ack *extack);
 #endif /* CONFIG_XFRM_OFFLOAD */
+int mlx5_devlink_port_fn_max_io_eqs_get(struct devlink_port *port,
+                                       u32 *max_io_eqs,
+                                       struct netlink_ext_ack *extack);
+int mlx5_devlink_port_fn_max_io_eqs_set(struct devlink_port *port,
+                                       u32 max_io_eqs,
+                                       struct netlink_ext_ack *extack);
+
 void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8 rep_type);
 
 int __mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw,
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +29 -0
index baaae628b0a0..9d9a06a25cac 100644
@@ -66,6 +66,8 @@
 
 #define MLX5_ESW_FT_OFFLOADS_DROP_RULE (1)
 
+#define MLX5_ESW_MAX_CTRL_EQS 4
+
 static struct esw_vport_tbl_namespace mlx5_esw_vport_tbl_mirror_ns = {
        .max_fte = MLX5_ESW_VPORT_TBL_SIZE,
        .max_num_groups = MLX5_ESW_VPORT_TBL_NUM_GROUPS,
@@ -4557,3 +4559,95 @@ int mlx5_devlink_port_fn_ipsec_packet_set(struct devlink_port *port,
        return err;
 }
 #endif /* CONFIG_XFRM_OFFLOAD */
+
+int mlx5_devlink_port_fn_max_io_eqs_get(struct devlink_port *port, u32 *max_io_eqs,
+                                       struct netlink_ext_ack *extack)
+{
+       struct mlx5_eswitch *esw = mlx5_devlink_eswitch_nocheck_get(port->devlink);
+       struct mlx5_vport *vport = mlx5_devlink_port_vport_get(port);
+       int query_out_sz = MLX5_ST_SZ_BYTES(query_hca_cap_out);
+       u16 vport_num = vport->vport;
+       void *query_ctx;
+       void *hca_caps;
+       u32 max_eqs;
+       int err;
+
+       if (!MLX5_CAP_GEN(esw->dev, vhca_resource_manager)) {
+               NL_SET_ERR_MSG_MOD(extack, "Device doesn't support VHCA management");
+               return -EOPNOTSUPP;
+       }
+
+       query_ctx = kzalloc(query_out_sz, GFP_KERNEL);
+       if (!query_ctx)
+               return -ENOMEM;
+
+       mutex_lock(&esw->state_lock);
+       err = mlx5_vport_get_other_func_cap(esw->dev, vport_num, query_ctx,
+                                           MLX5_CAP_GENERAL);
+       if (err) {
+               NL_SET_ERR_MSG_MOD(extack, "Failed getting HCA caps");

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c int mlx5_devlink_port_fn_ipsec_packet_set(struct devlink_port *port, · line 4598

Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +10 -0
+               goto out;
+       }
+
+       hca_caps = MLX5_ADDR_OF(query_hca_cap_out, query_ctx, capability);
+       max_eqs = MLX5_GET(cmd_hca_cap, hca_caps, max_num_eqs);
+       if (max_eqs < MLX5_ESW_MAX_CTRL_EQS)
+               *max_io_eqs = 0;
+       else
+               *max_io_eqs = max_eqs - MLX5_ESW_MAX_CTRL_EQS;
+out:

[Kalesh]: Missing " kfree(query_ctx);" here?

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c int mlx5_devlink_port_fn_ipsec_packet_set(struct devlink_port *port, · line 4600

Quoted 2 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -0
+       mutex_unlock(&esw->state_lock);
+       return 0;

[Kalesh] "return err;" to propagate the error back to the caller?

Quoted 57 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +53 -1
+}
+
+int mlx5_devlink_port_fn_max_io_eqs_set(struct devlink_port *port, u32 max_io_eqs,
+                                       struct netlink_ext_ack *extack)
+{
+       struct mlx5_eswitch *esw = mlx5_devlink_eswitch_nocheck_get(port->devlink);
+       struct mlx5_vport *vport = mlx5_devlink_port_vport_get(port);
+       int query_out_sz = MLX5_ST_SZ_BYTES(query_hca_cap_out);
+       u16 vport_num = vport->vport;
+       u16 max_eqs = max_io_eqs + MLX5_ESW_MAX_CTRL_EQS;
+       void *query_ctx;
+       void *hca_caps;
+       int err;
+
+       if (!MLX5_CAP_GEN(esw->dev, vhca_resource_manager)) {
+               NL_SET_ERR_MSG_MOD(extack, "Device doesn't support VHCA management");
+               return -EOPNOTSUPP;
+       }
+
+       if (max_io_eqs + MLX5_ESW_MAX_CTRL_EQS > USHRT_MAX) {
+               NL_SET_ERR_MSG_MOD(extack, "Supplied value out of range");
+               return -EINVAL;
+       }
+
+       mutex_lock(&esw->state_lock);
+
+       query_ctx = kzalloc(query_out_sz, GFP_KERNEL);
+       if (!query_ctx) {
+               err = -ENOMEM;
+               goto out;
+       }
+
+       err = mlx5_vport_get_other_func_cap(esw->dev, vport_num, query_ctx,
+                                           MLX5_CAP_GENERAL);
+       if (err) {
+               NL_SET_ERR_MSG_MOD(extack, "Failed getting HCA caps");
+               goto out_free;
+       }
+
+       hca_caps = MLX5_ADDR_OF(query_hca_cap_out, query_ctx, capability);
+       MLX5_SET(cmd_hca_cap, hca_caps, max_num_eqs, max_eqs);
+
+       err = mlx5_vport_set_other_func_cap(esw->dev, hca_caps, vport_num,
+                                           MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE);
+       if (err)
+               NL_SET_ERR_MSG_MOD(extack, "Failed setting HCA roce cap");
+
+out_free:
+       kfree(query_ctx);
+out:
+       mutex_unlock(&esw->state_lock);
+       return err;
+}
--

2.26.2

Signature · 2 lines
Regards,
Kalesh A P
#4 lore raw

RE: [net-next 2/2] mlx5/core: Support max_io_eqs for a function

Quoted 118 lines

From: Kalesh Anakkur Purayil <[email protected]>
Sent: Monday, April 1, 2024 2:47 PM

Quoted 8 lines · Parav Pandit

Implement get and set for the maximum IO event queues for SF and VF. This enables administrator on the hypervisor to control the maximum IO event queues which are typically used to derive the maximum and default number of net device channels or rdma device completion vectors.

Review

Quoted 7 lines
---
 .../mellanox/mlx5/core/esw/devlink_port.c     |  2 +
 .../net/ethernet/mellanox/mlx5/core/eswitch.h |  7 ++
 .../mellanox/mlx5/core/eswitch_offloads.c     | 94 +++++++++++++++++++
 3 files changed, 103 insertions(+)
(quoted diff) +0 -0

b/drivers/net/ethernet/mellanox/mlx5/core/esw/devlink_port.c

drivers/net/ethernet/mellanox/mlx5/core/esw/devlink_port.c static const struct devlink_port_ops

Quoted 4 lines

index d8e739cbcbce..76d1ed93c773 100644

drivers/net/ethernet/mellanox/mlx5/core/esw/devlink_port.c +0 -0
@@ -98,6 +98,8 @@ static const struct devlink_port_ops

mlx5_esw_pf_vf_dl_port_ops = {

drivers/net/ethernet/mellanox/mlx5/core/esw/devlink_port.c static const struct devlink_port_ops mlx5_esw_pf_vf_dl_port_ops = {

Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/esw/devlink_port.c +2 -0
        .port_fn_ipsec_packet_get = mlx5_devlink_port_fn_ipsec_packet_get,
        .port_fn_ipsec_packet_set = mlx5_devlink_port_fn_ipsec_packet_set,
 #endif /* CONFIG_XFRM_OFFLOAD */
+       .port_fn_max_io_eqs_get = mlx5_devlink_port_fn_max_io_eqs_get,
+       .port_fn_max_io_eqs_set = mlx5_devlink_port_fn_max_io_eqs_set,
 };
 
 static void mlx5_esw_offloads_sf_devlink_port_attrs_set(struct

mlx5_eswitch *esw,

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h int mlx5_devlink_port_fn_ipsec_packet_get(struct

Quoted 4 lines

index 349e28a6dd8d..50ce1ea20dd4 100644

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +0 -0
@@ -573,6 +573,13 @@ int mlx5_devlink_port_fn_ipsec_packet_get(struct

devlink_port *port, bool *is_en

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h int mlx5_devlink_port_fn_ipsec_packet_get(struct · line 573

Quoted 1 line
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +0 -0
 int mlx5_devlink_port_fn_ipsec_packet_set(struct devlink_port *port, bool

enable,

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h int mlx5_devlink_port_fn_ipsec_packet_get(struct devlink_port *port, bool *is_en

Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +7 -0
                                          struct netlink_ext_ack *extack);
 #endif /* CONFIG_XFRM_OFFLOAD */
+int mlx5_devlink_port_fn_max_io_eqs_get(struct devlink_port *port,
+                                       u32 *max_io_eqs,
+                                       struct netlink_ext_ack *extack);
+int mlx5_devlink_port_fn_max_io_eqs_set(struct devlink_port *port,
+                                       u32 max_io_eqs,
+                                       struct netlink_ext_ack *extack);
+
 void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8

rep_type);

Review

Quoted 3 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +0 -0
 int __mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw,
(quoted diff) +0 -0

b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c int

Quoted 13 lines

index baaae628b0a0..9d9a06a25cac 100644

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -0
@@ -66,6 +66,8 @@
 
 #define MLX5_ESW_FT_OFFLOADS_DROP_RULE (1)
 
+#define MLX5_ESW_MAX_CTRL_EQS 4
+
 static struct esw_vport_tbl_namespace mlx5_esw_vport_tbl_mirror_ns = {
        .max_fte = MLX5_ESW_VPORT_TBL_SIZE,
        .max_num_groups = MLX5_ESW_VPORT_TBL_NUM_GROUPS,
@@ -4557,3 +4559,95 @@ int

mlx5_devlink_port_fn_ipsec_packet_set(struct devlink_port *port,

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c int mlx5_devlink_port_fn_ipsec_packet_set(struct devlink_port *port,

Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -0
        return err;
 }
 #endif /* CONFIG_XFRM_OFFLOAD */
+
+int mlx5_devlink_port_fn_max_io_eqs_get(struct devlink_port *port, u32

*max_io_eqs,

Quoted 4 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +3 -0
+                                       struct netlink_ext_ack *extack)
+{
+       struct mlx5_eswitch *esw = mlx5_devlink_eswitch_nocheck_get(port-

devlink);

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c int mlx5_devlink_port_fn_ipsec_packet_set(struct devlink_port *port,

Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +10 -0
+       struct mlx5_vport *vport = mlx5_devlink_port_vport_get(port);
+       int query_out_sz = MLX5_ST_SZ_BYTES(query_hca_cap_out);
+       u16 vport_num = vport->vport;
+       void *query_ctx;
+       void *hca_caps;
+       u32 max_eqs;
+       int err;
+
+       if (!MLX5_CAP_GEN(esw->dev, vhca_resource_manager)) {
+               NL_SET_ERR_MSG_MOD(extack, "Device doesn't support VHCA

management");

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c int mlx5_devlink_port_fn_ipsec_packet_set(struct devlink_port *port,

Quoted 9 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +9 -0
+               return -EOPNOTSUPP;
+       }
+
+       query_ctx = kzalloc(query_out_sz, GFP_KERNEL);
+       if (!query_ctx)
+               return -ENOMEM;
+
+       mutex_lock(&esw->state_lock);
+       err = mlx5_vport_get_other_func_cap(esw->dev, vport_num,

query_ctx,

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c int mlx5_devlink_port_fn_ipsec_packet_set(struct devlink_port *port, · line 4598

Quoted 13 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +13 -0
+                                           MLX5_CAP_GENERAL);
+       if (err) {
+               NL_SET_ERR_MSG_MOD(extack, "Failed getting HCA caps");
+               goto out;
+       }
+
+       hca_caps = MLX5_ADDR_OF(query_hca_cap_out, query_ctx, capability);
+       max_eqs = MLX5_GET(cmd_hca_cap, hca_caps, max_num_eqs);
+       if (max_eqs < MLX5_ESW_MAX_CTRL_EQS)
+               *max_io_eqs = 0;
+       else
+               *max_io_eqs = max_eqs - MLX5_ESW_MAX_CTRL_EQS;
+out:

[Kalesh]: Missing " kfree(query_ctx);" here?

Quoted 4 lines

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c int mlx5_devlink_port_fn_ipsec_packet_set(struct devlink_port *port, · line 4600

Quoted 2 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -0
+       mutex_unlock(&esw->state_lock);
+       return 0;

[Kalesh] "return err;" to propagate the error back to the caller?

Quoted 1 line

+}

Ack. Thanks Kalesh. Fixing both the comments in v1.