Add mlx5 subfunction support
Subsystems (8)
v5 cover Add mlx5 subfunction support
From: Saeed Mahameed <[email protected]>
Hi Dave, Jakub, Jason,
This series form Parav was the theme of this mlx5 release cycle, we've been waiting anxiously for the auxbus infrastructure to make it into the kernel, and now as the auxbus is in and all the stars are aligned, I can finally submit this V2 of the devlink and mlx5 subfunction support.
Subfunctions came to solve the scaling issue of virtualization and switchdev environments, where SRIOV failed to deliver and users ran out of VFs very quickly as SRIOV demands huge amount of physical resources in both of the servers and the NIC.
Subfunction provide the same functionality as SRIOV but in a very lightweight manner, please see the thorough and detailed documentation from Parav below, in the commit messages and the Networking documentation patches at the end of this series.
Sending V4 as a continuation to V1 that was sent Last month [0],
[0] https://lore.kernel.org/linux-rdma/[email protected]/
---
Changelog:v4->v5:
- Fix some typos in the documentation
v3->v4:
- Fix 32bit compilation issue
v2->v3:
- added header file sf/priv.h to cmd.c to avoid missing prototype warning
- made mlx5_sf_table_disable as static function as its used only in one file
v1->v2:
- added documentation for subfunction and its mlx5 implementation
- add MLX5_SF config option documentation
- rebased
- dropped devlink global lock improvement patch as mlx5 doesn't support reload while SFs are allocated
- dropped devlink reload lock patch as mlx5 doesn't support reload when SFs are allocated
- using updated vhca event from device to add remove auxiliary device
- split sf devlink port allocation and sf hardware context allocation
Parav Pandit Says:
=================
This patchset introduces support for mlx5 subfunction (SF).
A subfunction is a lightweight function that has a parent PCI function on which it is deployed. mlx5 subfunction has its own function capabilities and its own resources. This means a subfunction has its own dedicated queues(txq, rxq, cq, eq). These queues are neither shared nor stolen from the parent PCI function.
When subfunction is RDMA capable, it has its own QP1, GID table and rdma resources neither shared nor stolen from the parent PCI function.
A subfunction has dedicated window in PCI BAR space that is not shared with the other subfunctions or parent PCI function. This ensures that all class devices of the subfunction accesses only assigned PCI BAR space.
A Subfunction supports eswitch representation through which it supports tc offloads. User must configure eswitch to send/receive packets from/to subfunction port.
Subfunctions share PCI level resources such as PCI MSI-X IRQs with their other subfunctions and/or with its parent PCI function.
Patch summary:
--------------
Patch 1 to 4 prepares devlink
patch 5 to 7 mlx5 adds SF device support
Patch 8 to 11 mlx5 adds SF devlink port support
Patch 12 and 14 adds documentation
Patch-1 prepares code to handle multiple port function attributes Patch-2 introduces devlink pcisf port flavour similar to pcipf and pcivf Patch-3 adds port add and delete driver callbacks
Patch-4 adds port function state get and set callbacks Patch-5 mlx5 vhca event notifier support to distribute subfunction
state change notification
Patch-6 adds SF auxiliary device
Patch-7 adds SF auxiliary driver
Patch-8 prepares eswitch to handler SF vport
Patch-9 adds eswitch helpers to add/remove SF vport
Patch-10 implements devlink port add/del callbacks
Patch-11 implements devlink port function get/set callbacks Patch-12 to 14 adds documentation
Patch-12 added mlx5 port function documentation
Patch-13 adds subfunction documentation
Patch-14 adds mlx5 subfunction documentation
Subfunction support is discussed in detail in RFC [1] and [2]. RFC [1] and extension [2] describes requirements, design and proposed plumbing using devlink, auxiliary bus and sysfs for systemd/udev support. Functionality of this patchset is best explained using real examples further below.
overview:
--------
A subfunction can be created and deleted by a user using devlink port add/delete interface.
A subfunction can be configured using devlink port function attribute before its activated.
When a subfunction is activated, it results in an auxiliary device on the host PCI device where it is deployed. A driver binds to the auxiliary device that further creates supported class devices.
example subfunction usage sequence:
-----------------------------------
Change device to switchdev mode:
$ devlink dev eswitch set pci/0000:06:00.0 mode switchdev
Add a devlink port of subfunction flavour:
$ devlink port add pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum 88
Configure mac address of the port function:
$ devlink port function set ens2f0npf0sf88 hw_addr 00:00:00:00:88:88
Now activate the function:
$ devlink port function set ens2f0npf0sf88 state active
Now use the auxiliary device and class devices:
$ devlink dev show pci/0000:06:00.0 auxiliary/mlx5_core.sf.4
$ ip link show
127: ens2f0np0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 24:8a:07:b3:d1:12 brd ff:ff:ff:ff:ff:ff
altname enp6s0f0np0
129: p0sf88: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 00:00:00:00:88:88 brd ff:ff:ff:ff:ff:ff$ rdma dev show 43: rdmap6s0f0: node_type ca fw 16.29.0550 node_guid 248a:0703:00b3:d112 sys_image_guid 248a:0703:00b3:d112 44: mlx5_0: node_type ca fw 16.29.0550 node_guid 0000:00ff:fe00:8888 sys_image_guid 248a:0703:00b3:d112
After use inactivate the function:
$ devlink port function set ens2f0npf0sf88 state inactive
Now delete the subfunction port:
$ devlink port del ens2f0npf0sf88
[1] https://lore.kernel.org/netdev/20200519092258.GF4655@nanopsycho/
[2] https://marc.info/?l=linux-netdev&m=158555928517777&w=2
=================
Parav Pandit (14):
net/mlx5: Fix compilation warning for 32-bit platform
devlink: Prepare code to fill multiple port function attributes
devlink: Introduce PCI SF port flavour and port attribute
devlink: Support add and delete devlink port
devlink: Support get and set state of port function net/mlx5: Introduce vhca state event notifier net/mlx5: SF, Add auxiliary device support
net/mlx5: SF, Add auxiliary device driver
net/mlx5: E-switch, Add eswitch helpers for SF vport net/mlx5: SF, Add port add delete functionality net/mlx5: SF, Port function state change support
devlink: Add devlink port documentation
devlink: Extend devlink port documentation for subfunctions net/mlx5: Add devlink subfunction port documentation
Vu Pham (1):
net/mlx5: E-switch, Prepare eswitch to handle SF vport
Documentation/driver-api/auxiliary_bus.rst | 2 + .../device_drivers/ethernet/mellanox/mlx5.rst | 209 +++++++ .../networking/devlink/devlink-port.rst | 199 +++++++ Documentation/networking/devlink/index.rst | 1 + .../net/ethernet/mellanox/mlx5/core/Kconfig | 19 + .../net/ethernet/mellanox/mlx5/core/Makefile | 9 + drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 8 + .../net/ethernet/mellanox/mlx5/core/devlink.c | 19 + drivers/net/ethernet/mellanox/mlx5/core/eq.c | 5 +- .../mellanox/mlx5/core/esw/acl/egress_ofld.c | 2 +- .../mellanox/mlx5/core/esw/devlink_port.c | 41 ++ .../net/ethernet/mellanox/mlx5/core/eswitch.c | 48 +- .../net/ethernet/mellanox/mlx5/core/eswitch.h | 78 +++ .../mellanox/mlx5/core/eswitch_offloads.c | 47 +- .../net/ethernet/mellanox/mlx5/core/events.c | 7 + .../net/ethernet/mellanox/mlx5/core/main.c | 60 +- .../ethernet/mellanox/mlx5/core/mlx5_core.h | 12 + .../net/ethernet/mellanox/mlx5/core/pci_irq.c | 20 + .../net/ethernet/mellanox/mlx5/core/sf/cmd.c | 49 ++ .../ethernet/mellanox/mlx5/core/sf/dev/dev.c | 271 +++++++++ .../ethernet/mellanox/mlx5/core/sf/dev/dev.h | 55 ++ .../mellanox/mlx5/core/sf/dev/driver.c | 101 ++++ .../ethernet/mellanox/mlx5/core/sf/devlink.c | 552 ++++++++++++++++++ .../ethernet/mellanox/mlx5/core/sf/hw_table.c | 233 ++++++++ .../mlx5/core/sf/mlx5_ifc_vhca_event.h | 82 +++ .../net/ethernet/mellanox/mlx5/core/sf/priv.h | 21 + .../net/ethernet/mellanox/mlx5/core/sf/sf.h | 92 +++ .../mellanox/mlx5/core/sf/vhca_event.c | 189 ++++++ .../mellanox/mlx5/core/sf/vhca_event.h | 57 ++ .../net/ethernet/mellanox/mlx5/core/vport.c | 3 +- include/linux/mlx5/driver.h | 16 +- include/linux/mlx5/mlx5_ifc.h | 6 +- include/net/devlink.h | 79 +++ include/uapi/linux/devlink.h | 26 + net/core/devlink.c | 266 ++++++++- 35 files changed, 2834 insertions(+), 50 deletions(-) create mode 100644 Documentation/networking/devlink/devlink-port.rst create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/sf/cmd.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.h create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/sf/mlx5_ifc_vhca_event.h create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/sf/priv.h create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/sf/sf.h create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/sf/vhca_event.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/sf/vhca_event.h
Signature · 1 line
2.26.2
PATCH v5 3/15 devlink: Introduce PCI SF port flavour and port attribute
From: Parav Pandit <[email protected]>
A PCI sub-function (SF) represents a portion of the device similar to PCI VF.
In an eswitch, PCI SF may have port which is normally represented using a representor netdevice.
To have better visibility of eswitch port, its association with SF, and its representor netdevice, introduce a PCI SF port flavour.
When devlink port flavour is PCI SF, fill up PCI SF attributes of the port.
Extend port name creation using PCI PF and SF number scheme on best effort basis, so that vendor drivers can skip defining their own scheme.
This is done as cApfNSfM, where A, N and M are controller, PCI PF and PCI SF number respectively.
This is similar to existing naming for PCI PF and PCI VF ports.
An example view of a PCI SF port:
$ devlink port show pci/0000:06:00.0/32768
pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
function:
hw_addr 00:00:00:00:88:88 state active opstate attached$ devlink port show pci/0000:06:00.0/32768 -jp
{
"port": {
"pci/0000:06:00.0/32768": {
"type": "eth",
"netdev": "ens2f0npf0sf88",
"flavour": "pcisf",
"controller": 0,
"pfnum": 0,
"sfnum": 88,
"external": false,
"splittable": false,
"function": {
"hw_addr": "00:00:00:00:88:88",
"state": "active",
"opstate": "attached"
}
}
}
}--- include/net/devlink.h | 17 +++++++++++++ include/uapi/linux/devlink.h | 5 ++++ net/core/devlink.c | 46 ++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+)
include/net/devlink.h +17 -0
@@ -93,6 +93,20 @@ struct devlink_port_pci_vf_attrs { u8 external:1; }; +/** +* struct devlink_port_pci_sf_attrs - devlink port's PCI SF attributes +* @controller: Associated controller number +* @pf: Associated PCI PF number for this port. +* @sf: Associated PCI SF for of the PCI PF for this port. +* @external: when set, indicates if a port is for an external controller +*/ +struct devlink_port_pci_sf_attrs { +u32 controller; +u16 pf; +u32 sf; +u8 external:1 ; +}; +/** * struct devlink_port_attrs - devlink port object * @flavour: flavour of the port
@@ -114,6 +128,7 @@ struct devlink_port_attrs {struct devlink_port_phys_attrs phys;struct devlink_port_pci_pf_attrs pci_pf;struct devlink_port_pci_vf_attrs pci_vf; +struct devlink_port_pci_sf_attrs pci_sf; }; };
@@ -1404,6 +1419,8 @@ void devlink_port_attrs_pci_pf_set(struct devlink_port *devlink_port, u32 contro u16 pf, bool external);void devlink_port_attrs_pci_vf_set (struct devlink_port *devlink_port,u32 controller,u16 pf,u16 vf,bool external); +void devlink_port_attrs_pci_sf_set (struct devlink_port *devlink_port,u32 controller, +u16 pf,u32 sf,bool external); int devlink_sb_register(struct devlink *devlink, unsigned int sb_index, u32 size, u16 ingress_pools_count, u16 egress_pools_count, u16 ingress_tc_count,
include/uapi/linux/devlink.h +5 -0
@@ -200,6 +200,10 @@ enum devlink_port_flavour {DEVLINK_PORT_FLAVOUR_UNUSED ,/* Port which exists in the switch, but * is not used in any way. */ + DEVLINK_PORT_FLAVOUR_PCI_SF, /* Represents eswitch port + * for the PCI SF. It is an internal + * port that faces the PCI SF. + */ }; enum devlink_param_cmode {
@@ -529,6 +533,7 @@ enum devlink_attr {DEVLINK_ATTR_RELOAD_ACTION_INFO ,/* nested */ DEVLINK_ATTR_RELOAD_ACTION_STATS ,/* nested */ +DEVLINK_ATTR_PORT_PCI_SF_NUMBER ,/* u32 */ /* add new attributes above here, update the policy in devlink.c */ __DEVLINK_ATTR_MAX,
net/core/devlink.c +46 -0
64 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH v5 4/15 devlink: Support add and delete devlink port
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
Extended devlink interface for the user to add and delete port. Extend devlink to connect user requests to driver to add/delete such port in the device.
When driver routines are invoked, devlink instance lock is not held. This enables driver to perform several devlink objects registration, unregistration such as (port, health reporter, resource etc) by using existing devlink APIs.
This also helps to uniformly use the code for port unregistration during driver unload and during port deletion initiated by user.
Examples of add, show and delete commands:
$ devlink dev eswitch set pci/0000:06:00.0 mode switchdev
$ devlink port show pci/0000:06:00.0/65535: type eth netdev ens2f0np0 flavour physical port 0 splittable false
$ devlink port add pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum 88
$ devlink port show pci/0000:06:00.0/32768
pci/0000:06:00.0/32768: type eth netdev eth0 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
function:
hw_addr 00:00:00:00:88:88 state inactive opstate detached$ udevadm test-builtin net_id /sys/class/net/eth0 Load module index Parsed configuration file /usr/lib/systemd/network/99-default.link Created link configuration context. Using default interface naming scheme 'v245'. ID_NET_NAMING_SCHEME=v245 ID_NET_NAME_PATH=enp6s0f0npf0sf88 ID_NET_NAME_SLOT=ens2f0npf0sf88 Unload module index Unloaded link configuration context.
--- include/net/devlink.h | 39 ++++++++++++++++++++++++ net/core/devlink.c | 71 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+)
include/net/devlink.h +39 -0
@@ -153,6 +153,17 @@ struct devlink_port {struct mutex reporters_lock;/* Protects reporter_list */ }; +struct devlink_port_new_attrs { +enum devlink_port_flavour flavour; +unsigned int port_index; +u32 controller; +u32 sfnum; +u16 pfnum; +u8 port_index_valid:1 , + controller_valid:1 , + sfnum_valid:1 ; +}; +struct devlink_sb_pool_info {enum devlink_sb_pool_type pool_type;u32 size;
@@ -1363,6 +1374,34 @@ struct devlink_ops {int (*port_function_hw_addr_set)(struct devlink *devlink,struct devlink_port *port,const u8 *hw_addr,int hw_addr_len,struct netlink_ext_ack *extack); +/** +* @port_new: Port add function. +* +* Should be used by device driver to let caller add new port of a +* specified flavour with optional attributes. +* Driver should return -EOPNOTSUPP if it doesn't support port addition +* of a specified flavour or specified attributes. Driver should set +* extack error message in case of fail to add the port. Devlink core +* does not hold a devlink instance lock when this callback is invoked. +* Driver must ensures synchronization when adding or deleting a port. +* Driver must register a port with devlink core. +*/ +int (*port_new)(struct devlink *devlink, +const struct devlink_port_new_attrs *attrs, +struct netlink_ext_ack *extack); +/** +* @port_del: Port delete function. +* +* Should be used by device driver to let caller delete port which was +* previously created using port_new() callback. +* Driver should return -EOPNOTSUPP if it doesn't support port deletion. +* Driver should set extack error message in case of fail to delete the +* port. Devlink core does not hold a devlink instance lock when this +* callback is invoked. Driver must ensures synchronization when adding +* or deleting a port. Driver must register a port with devlink core. +*/ +int (*port_del)(struct devlink *devlink,unsigned int port_index, +struct netlink_ext_ack *extack); };static inline void *devlink_priv (struct devlink *devlink)
net/core/devlink.c +71 -0
89 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH v5 1/15 net/mlx5: Fix compilation warning for 32-bit platform
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
MLX5_GENERAL_OBJECT_TYPES types bitfield is 64-bit field.
Defining an enum for such bit fields on 32-bit platform results in below warning.
./include/vdso/bits.h:7:26: warning: left shift count >= width of type [-Wshift-count-overflow]
^
./include/linux/mlx5/mlx5_ifc.h:10716:46: note: in expansion of macro ‘BIT’
MLX5_HCA_CAP_GENERAL_OBJECT_TYPES_SAMPLER = BIT(0x20),
^~~Use 32-bit friendly left shift.
--- include/linux/mlx5/mlx5_ifc.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/mlx5/mlx5_ifc.h +3 -3
@@ -10711,9 +10711,9 @@ struct mlx5_ifc_affiliated_event_header_bits { };enum { -MLX5_HCA_CAP_GENERAL_OBJECT_TYPES_ENCRYPTION_KEY =BIT (0xc ), -MLX5_HCA_CAP_GENERAL_OBJECT_TYPES_IPSEC =BIT (0x13 ), -MLX5_HCA_CAP_GENERAL_OBJECT_TYPES_SAMPLER =BIT (0x20 ), +MLX5_HCA_CAP_GENERAL_OBJECT_TYPES_ENCRYPTION_KEY =1ULL <<0xc , +MLX5_HCA_CAP_GENERAL_OBJECT_TYPES_IPSEC =1ULL <<0x13 , +MLX5_HCA_CAP_GENERAL_OBJECT_TYPES_SAMPLER =1ULL <<0x20 , };enum {
Signature · 1 line
2.26.2
PATCH v5 7/15 net/mlx5: SF, Add auxiliary device support
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
Introduce API to add and delete an auxiliary device for an SF. Each SF has its own dedicated window in the PCI BAR 2.
SF device is similar to PCI PF and VF that supports multiple class of devices such as net, rdma and vdpa.
SF device will be added or removed in subsequent patch during SF devlink port function state change command.
A subfunction device exposes user supplied subfunction number which will be further used by systemd/udev to have deterministic name for its netdevice and rdma device.
An mlx5 subfunction auxiliary device example:
$ devlink dev eswitch set pci/0000:06:00.0 mode switchdev
$ devlink port show pci/0000:06:00.0/65535: type eth netdev ens2f0np0 flavour physical port 0 splittable false
$ devlink port add pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum 88
$ devlink port show ens2f0npf0sf88
pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
function:
hw_addr 00:00:00:00:88:88 state inactive opstate detached$ devlink port function set ens2f0npf0sf88 hw_addr 00:00:00:00:88:88 state active
On activation,
$ ls -l /sys/bus/auxiliary/devices/ mlx5_core.sf.4 -> ../../../devices/pci0000:00/0000:00:03.0/0000:06:00.0/mlx5_core.sf.4
$ cat /sys/bus/auxiliary/devices/mlx5_core.sf.4/sfnum 88
--- .../device_drivers/ethernet/mellanox/mlx5.rst | 5 + .../net/ethernet/mellanox/mlx5/core/Makefile | 2 +- .../net/ethernet/mellanox/mlx5/core/main.c | 4 + .../ethernet/mellanox/mlx5/core/sf/dev/dev.c | 261 ++++++++++++++++++ .../ethernet/mellanox/mlx5/core/sf/dev/dev.h | 35 +++ include/linux/mlx5/driver.h | 2 + 6 files changed, 308 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.h
Documentation/networking/device_drivers/ethernet/mellanox/mlx5.rst +5 -0
@@ -97,6 +97,11 @@ Enabling the driver and kconfig options | Provides low-level InfiniBand/RDMA and `RoCE <https://community.mellanox.com/s/article/recommended-network-configuration-examples-for-roce-deployment>`_ support. +**CONFIG_MLX5_SF=(y/n)** + +| Build support for subfunction. +| Subfunctons are more light weight than PCI SRIOV VFs. Choosing this option +| will enable support for creating subfunction devices. **External options** ( Choose if the corresponding mlx5 feature is required )
drivers/net/ethernet/mellanox/mlx5/core/Makefile +1 -1
@@ -88,4 +88,4 @@ mlx5_core-$(CONFIG_MLX5_SW_STEERING) += steering/dr_domain.o steering/dr_table.o # # SF device # -mlx5_core-$(CONFIG_MLX5_SF) += sf/vhca_event.o +mlx5_core-$(CONFIG_MLX5_SF) += sf/vhca_event.o sf/dev/dev.o
drivers/net/ethernet/mellanox/mlx5/core/main.c +4 -0
@@ -74,6 +74,7 @@#include "lib/hv_vhca.h" #include "diag/rsc_dump.h" #include "sf/vhca_event.h" +#include "sf/dev/dev.h" MODULE_AUTHOR ("Eli Cohen <[email protected]>" );MODULE_DESCRIPTION ("Mellanox 5th generation network adapters (ConnectX series) core driver" );
@@ -1155,6 +1156,8 @@ static int mlx5_load(struct mlx5_core_dev *dev) goto err_sriov; } +mlx5_sf_dev_table_create (dev); +return 0 ; err_sriov:
@@ -1186,6 +1189,7 @@ static int mlx5_load(struct mlx5_core_dev *dev)static void mlx5_unload (struct mlx5_core_dev *dev) { +mlx5_sf_dev_table_destroy (dev);mlx5_sriov_detach (dev);mlx5_ec_cleanup (dev);mlx5_vhca_event_stop (dev);
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c new file +261 -0
261 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.h new file +35 -0
@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* Copyright (c) 2020 Mellanox Technologies Ltd */ + +#ifndef __MLX5_SF_DEV_H__ +#define __MLX5_SF_DEV_H__ + +#ifdef CONFIG_MLX5_SF + +#include <linux/auxiliary_bus.h> + +#define MLX5_SF_DEV_ID_NAME "sf" + +struct mlx5_sf_dev { +struct auxiliary_device adev; +struct mlx5_core_dev *parent_mdev; +phys_addr_t bar_base_addr; +u32 sfnum; +}; + +void mlx5_sf_dev_table_create (struct mlx5_core_dev *dev); +void mlx5_sf_dev_table_destroy (struct mlx5_core_dev *dev); + +#else + +static inline void mlx5_sf_dev_table_create (struct mlx5_core_dev *dev) +{ +} + +static inline void mlx5_sf_dev_table_destroy (struct mlx5_core_dev *dev) +{ +} + +#endif + +#endif
include/linux/mlx5/driver.h +2 -0
@@ -508,6 +508,7 @@ struct mlx5_fw_reset;struct mlx5_eq_table ;struct mlx5_irq_table ;struct mlx5_vhca_state_notifier ; +struct mlx5_sf_dev_table ;struct mlx5_rate_limit {u32 rate;
@@ -606,6 +607,7 @@ struct mlx5_priv {struct mlx5_uars_page *uar;#ifdef CONFIG_MLX5_SF struct mlx5_vhca_state_notifier *vhca_state_notifier; +struct mlx5_sf_dev_table *sf_dev_table;#endif };
Signature · 1 line
2.26.2
PATCH v5 11/15 net/mlx5: SF, Add port add delete functionality
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
To handle SF port management outside of the eswitch as independent software layer, introduce eswitch notifier APIs so that upper layer who wish to support sf port management in switchdev mode can perform its task whenever eswitch mode is set to switchdev or before eswitch is disabled.
Initialize sf port table on such eswitch event.
Add SF port add and delete functionality in switchdev mode. Destroy all SF ports when eswitch is disabled. Expose SF port add and delete to user via devlink commands.
$ devlink dev eswitch set pci/0000:06:00.0 mode switchdev
$ devlink port show pci/0000:06:00.0/65535: type eth netdev ens2f0np0 flavour physical port 0 splittable false
$ devlink port add pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum 88
$ devlink port show ens2f0npf0sf88
pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
function:
hw_addr 00:00:00:00:88:88 state inactive opstate detached$ devlink port show ens2f0npf0sf88 -jp
{
"port": {
"pci/0000:06:00.0/32768": {
"type": "eth",
"netdev": "ens2f0npf0sf88",
"flavour": "pcisf",
"controller": 0,
"pfnum": 0,
"sfnum": 88,
"external": false,
"splittable": false,
"function": {
"hw_addr": "00:00:00:00:88:88",
"state": "inactive",
"opstate": "detached"
}
}
}
}--- .../net/ethernet/mellanox/mlx5/core/Makefile | 5 + drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 4 + .../net/ethernet/mellanox/mlx5/core/devlink.c | 5 + .../net/ethernet/mellanox/mlx5/core/eswitch.c | 25 ++ .../net/ethernet/mellanox/mlx5/core/eswitch.h | 12 + .../net/ethernet/mellanox/mlx5/core/main.c | 18 + .../net/ethernet/mellanox/mlx5/core/sf/cmd.c | 27 ++ .../ethernet/mellanox/mlx5/core/sf/devlink.c | 312 ++++++++++++++++++ .../ethernet/mellanox/mlx5/core/sf/hw_table.c | 125 +++++++ .../net/ethernet/mellanox/mlx5/core/sf/priv.h | 17 + .../net/ethernet/mellanox/mlx5/core/sf/sf.h | 28 ++ include/linux/mlx5/driver.h | 6 + 12 files changed, 584 insertions(+) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/sf/cmd.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/sf/priv.h
drivers/net/ethernet/mellanox/mlx5/core/Makefile +5 -0
@@ -89,3 +89,8 @@ mlx5_core-$(CONFIG_MLX5_SW_STEERING) += steering/dr_domain.o steering/dr_table.o # SF device # mlx5_core-$(CONFIG_MLX5_SF) += sf/vhca_event.o sf/dev/dev.o sf/dev/driver.o + +# +# SF manager +# +mlx5_core-$(CONFIG_MLX5_SF_MANAGER) += sf/cmd.o sf/hw_table.o sf/devlink.o
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +4 -0
@@ -333,6 +333,7 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op,case MLX5_CMD_OP_DEALLOC_MEMIC :case MLX5_CMD_OP_PAGE_FAULT_RESUME :case MLX5_CMD_OP_QUERY_ESW_FUNCTIONS : +case MLX5_CMD_OP_DEALLOC_SF :return MLX5_CMD_STAT_OK ;case MLX5_CMD_OP_QUERY_HCA_CAP :
@@ -466,6 +467,7 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op,case MLX5_CMD_OP_RELEASE_XRQ_ERROR :case MLX5_CMD_OP_QUERY_VHCA_STATE :case MLX5_CMD_OP_MODIFY_VHCA_STATE : +case MLX5_CMD_OP_ALLOC_SF : *status =MLX5_DRIVER_STATUS_ABORTED ; *synd =MLX5_DRIVER_SYND ;return -EIO ;
@@ -661,6 +663,8 @@ const char *mlx5_command_str(int command)MLX5_COMMAND_STR_CASE (MODIFY_XRQ );MLX5_COMMAND_STR_CASE (QUERY_VHCA_STATE );MLX5_COMMAND_STR_CASE (MODIFY_VHCA_STATE ); +MLX5_COMMAND_STR_CASE (ALLOC_SF ); +MLX5_COMMAND_STR_CASE (DEALLOC_SF );default :return "unknown command opcode" ; } }
drivers/net/ethernet/mellanox/mlx5/core/devlink.c +5 -0
@@ -8,6 +8,7 @@#include "fs_core.h" #include "eswitch.h" #include "sf/dev/dev.h" +#include "sf/sf.h" static int mlx5_devlink_flash_update(struct devlink *devlink, struct devlink_flash_update_params *params,
@@ -190,6 +191,10 @@ static const struct devlink_ops mlx5_devlink_ops = { .eswitch_encap_mode_get = mlx5_devlink_eswitch_encap_mode_get, .port_function_hw_addr_get = mlx5_devlink_port_function_hw_addr_get, .port_function_hw_addr_set = mlx5_devlink_port_function_hw_addr_set, +#endif +#ifdef CONFIG_MLX5_SF_MANAGER + .port_new = mlx5_devlink_sf_port_new, + .port_del = mlx5_devlink_sf_port_del, #endif .flash_update = mlx5_devlink_flash_update, .info_get = mlx5_devlink_info_get,
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +25 -0
@@ -1600,6 +1600,15 @@ mlx5_eswitch_update_num_of_vfs(struct mlx5_eswitch *esw, int num_vfs)kvfree (out); } +static void mlx5_esw_mode_change_notify (struct mlx5_eswitch *esw,u16 mode) +{ +struct mlx5_esw_event_info info = {}; + + info.new_mode = mode; + +blocking_notifier_call_chain (&esw->n_head,0 , &info); +} +/** * mlx5_eswitch_enable_locked - Enable eswitch * @esw: Pointer to eswitch
@@ -1660,6 +1669,8 @@ int mlx5_eswitch_enable_locked(struct mlx5_eswitch *esw, int mode, int num_vfs) mode ==MLX5_ESWITCH_LEGACY ?"LEGACY" :"OFFLOADS" , esw->esw_funcs.num_vfs, esw->enabled_vports); +mlx5_esw_mode_change_notify (esw, mode); +return 0 ; abort:
@@ -1716,6 +1727,11 @@ void mlx5_eswitch_disable_locked(struct mlx5_eswitch *esw, bool clear_vf) esw->mode ==MLX5_ESWITCH_LEGACY ?"LEGACY" :"OFFLOADS" , esw->esw_funcs.num_vfs, esw->enabled_vports); +/* Notify eswitch users that it is exiting from current mode. +* So that it can do necessary cleanup before the eswitch is disabled. +*/ +mlx5_esw_mode_change_notify (esw,MLX5_ESWITCH_NONE ); +mlx5_eswitch_event_handlers_unregister (esw);if (esw->mode ==MLX5_ESWITCH_LEGACY )
@@ -1816,6 +1832,7 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev) esw->offloads.inline_mode =MLX5_INLINE_MODE_NONE ; dev->priv.eswitch = esw; +BLOCKING_INIT_NOTIFIER_HEAD (&esw->n_head);return 0 ; abort:if (esw->work_queue)
@@ -2507,4 +2524,12 @@ bool mlx5_esw_multipath_prereq(struct mlx5_core_dev *dev0, dev1->priv.eswitch->mode == MLX5_ESWITCH_OFFLOADS); } +int mlx5_esw_event_notifier_register (struct mlx5_eswitch *esw,struct notifier_block *nb) +{ +return blocking_notifier_chain_register (&esw->n_head, nb); +} +void mlx5_esw_event_notifier_unregister (struct mlx5_eswitch *esw,struct notifier_block *nb) +{ +blocking_notifier_chain_unregister (&esw->n_head, nb); +}
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +12 -0
@@ -278,6 +278,7 @@ struct mlx5_eswitch {struct {u32 large_group_num; } params; +struct blocking_notifier_head n_head; };void esw_offloads_disable (struct mlx5_eswitch *esw);
@@ -733,6 +734,17 @@ int mlx5_esw_offloads_sf_vport_enable(struct mlx5_eswitch *esw, struct devlink_p u16 vport_num, u32 sfnum);void mlx5_esw_offloads_sf_vport_disable (struct mlx5_eswitch *esw,u16 vport_num); +/** +* mlx5_esw_event_info - Indicates eswitch mode changed/changing. +* +* @new_mode: New mode of eswitch. +*/ +struct mlx5_esw_event_info { +u16 new_mode; +}; + +int mlx5_esw_event_notifier_register (struct mlx5_eswitch *esw,struct notifier_block *n); +void mlx5_esw_event_notifier_unregister (struct mlx5_eswitch *esw,struct notifier_block *n);#else /* CONFIG_MLX5_ESWITCH */ /* eswitch API stubs */ static inline int mlx5_eswitch_init (struct mlx5_core_dev *dev) {return 0 ; }
drivers/net/ethernet/mellanox/mlx5/core/main.c +18 -0
@@ -893,6 +893,18 @@ static int mlx5_init_once(struct mlx5_core_dev *dev) goto err_fpga_cleanup; } + err =mlx5_sf_hw_table_init (dev); +if (err) { +mlx5_core_err (dev,"Failed to init SF HW table %d\n" , err); + goto err_sf_hw_table_cleanup; + } + + err =mlx5_sf_table_init (dev); +if (err) { +mlx5_core_err (dev,"Failed to init SF table %d\n" , err); + goto err_sf_table_cleanup; + } + dev->dm =mlx5_dm_create (dev);if (IS_ERR (dev->dm))mlx5_core_warn (dev,"Failed to init device memory%d\n" , err);
@@ -903,6 +915,10 @@ static int mlx5_init_once(struct mlx5_core_dev *dev)return 0 ; +err_sf_table_cleanup: +mlx5_sf_hw_table_cleanup (dev); +err_sf_hw_table_cleanup: +mlx5_vhca_event_cleanup (dev); err_fpga_cleanup:mlx5_fpga_cleanup (dev); err_eswitch_cleanup:
@@ -936,6 +952,8 @@ static void mlx5_cleanup_once(struct mlx5_core_dev *dev)mlx5_hv_vhca_destroy (dev->hv_vhca);mlx5_fw_tracer_destroy (dev->tracer);mlx5_dm_cleanup (dev); +mlx5_sf_table_cleanup (dev); +mlx5_sf_hw_table_cleanup (dev);mlx5_vhca_event_cleanup (dev);mlx5_fpga_cleanup (dev);mlx5_eswitch_cleanup (dev->priv.eswitch);
drivers/net/ethernet/mellanox/mlx5/core/sf/cmd.c new file +27 -0
@@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB +/* Copyright (c) 2020 Mellanox Technologies Ltd */ + +#include <linux/mlx5/driver.h> +#include "priv.h" + +int mlx5_cmd_alloc_sf (struct mlx5_core_dev *dev,u16 function_id) +{ +u32 out[MLX5_ST_SZ_DW (alloc_sf_out)] = {}; +u32 in[MLX5_ST_SZ_DW (alloc_sf_in)] = {}; + +MLX5_SET (alloc_sf_in, in, opcode,MLX5_CMD_OP_ALLOC_SF ); +MLX5_SET (alloc_sf_in, in, function_id, function_id); + +return mlx5_cmd_exec (dev, in,sizeof (in), out,sizeof (out)); +} + +int mlx5_cmd_dealloc_sf (struct mlx5_core_dev *dev,u16 function_id) +{ +u32 out[MLX5_ST_SZ_DW (dealloc_sf_out)] = {}; +u32 in[MLX5_ST_SZ_DW (dealloc_sf_in)] = {}; + +MLX5_SET (dealloc_sf_in, in, opcode,MLX5_CMD_OP_DEALLOC_SF ); +MLX5_SET (dealloc_sf_in, in, function_id, function_id); + +return mlx5_cmd_exec (dev, in,sizeof (in), out,sizeof (out)); +}
drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c new file +312 -0
312 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c new file +125 -0
125 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/sf/priv.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* Copyright (c) 2020 Mellanox Technologies Ltd */ + +#ifndef __MLX5_SF_PRIV_H__ +#define __MLX5_SF_PRIV_H__ + +#include <linux/mlx5/driver.h> + +int mlx5_cmd_alloc_sf (struct mlx5_core_dev *dev,u16 function_id); +int mlx5_cmd_dealloc_sf (struct mlx5_core_dev *dev,u16 function_id); + +u16 mlx5_sf_sw_to_hw_id (const struct mlx5_core_dev *dev,u16 sw_id); + +int mlx5_sf_hw_table_sf_alloc (struct mlx5_core_dev *dev,u32 usr_sfnum); +void mlx5_sf_hw_table_sf_free (struct mlx5_core_dev *dev,u16 id); + +#endif
drivers/net/ethernet/mellanox/mlx5/core/sf/sf.h +28 -0
@@ -28,6 +28,16 @@ static inline u16 mlx5_sf_max_functions(const struct mlx5_core_dev *dev) return 1 << MLX5_CAP_GEN(dev, log_max_sf); } +int mlx5_sf_hw_table_init (struct mlx5_core_dev *dev); +void mlx5_sf_hw_table_cleanup (struct mlx5_core_dev *dev); + +int mlx5_sf_table_init (struct mlx5_core_dev *dev); +void mlx5_sf_table_cleanup (struct mlx5_core_dev *dev); + +int mlx5_devlink_sf_port_new (struct devlink *devlink,const struct devlink_port_new_attrs *add_attr, +struct netlink_ext_ack *extack); +int mlx5_devlink_sf_port_del (struct devlink *devlink,unsigned int port_index, +struct netlink_ext_ack *extack);#else static inline bool mlx5_sf_supported (const struct mlx5_core_dev *dev)
@@ -40,6 +50,24 @@ static inline u16 mlx5_sf_max_functions(const struct mlx5_core_dev *dev)return 0 ; } +static inline int mlx5_sf_hw_table_init (struct mlx5_core_dev *dev) +{ +return 0 ; +} + +static inline void mlx5_sf_hw_table_cleanup (struct mlx5_core_dev *dev) +{ +} + +static inline int mlx5_sf_table_init (struct mlx5_core_dev *dev) +{ +return 0 ; +} + +static inline void mlx5_sf_table_cleanup (struct mlx5_core_dev *dev) +{ +} +#endif #endif
include/linux/mlx5/driver.h +6 -0
@@ -510,6 +510,8 @@ struct mlx5_eq_table;struct mlx5_irq_table ;struct mlx5_vhca_state_notifier ;struct mlx5_sf_dev_table ; +struct mlx5_sf_hw_table ; +struct mlx5_sf_table ;struct mlx5_rate_limit {u32 rate;
@@ -611,6 +613,10 @@ struct mlx5_priv {struct mlx5_sf_dev_table *sf_dev_table;struct mlx5_core_dev *parent_mdev;#endif +#ifdef CONFIG_MLX5_SF_MANAGER +struct mlx5_sf_hw_table *sf_hw_table; +struct mlx5_sf_table *sf_table; +#endif };enum mlx5_device_state {
Signature · 1 line
2.26.2
PATCH v5 6/15 net/mlx5: Introduce vhca state event notifier
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
vhca state events indicates change in the state of the vhca that may occur due to a SF allocation, deallocation or enabling/disabling the SF HCA.
Introduce vhca state event handler which will be used by SF devlink port manager and SF hardware id allocator in subsequent patches to act on the event.
This enables single entity to subscribe, query and rearm the event for a function.
--- .../net/ethernet/mellanox/mlx5/core/Kconfig | 9 + .../net/ethernet/mellanox/mlx5/core/Makefile | 4 + drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 4 + drivers/net/ethernet/mellanox/mlx5/core/eq.c | 3 + .../net/ethernet/mellanox/mlx5/core/events.c | 7 + .../net/ethernet/mellanox/mlx5/core/main.c | 16 ++ .../ethernet/mellanox/mlx5/core/mlx5_core.h | 2 + .../mlx5/core/sf/mlx5_ifc_vhca_event.h | 82 ++++++++ .../net/ethernet/mellanox/mlx5/core/sf/sf.h | 45 +++++ .../mellanox/mlx5/core/sf/vhca_event.c | 189 ++++++++++++++++++ .../mellanox/mlx5/core/sf/vhca_event.h | 57 ++++++ include/linux/mlx5/driver.h | 4 + 12 files changed, 422 insertions(+) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/sf/mlx5_ifc_vhca_event.h create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/sf/sf.h create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/sf/vhca_event.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/sf/vhca_event.h
drivers/net/ethernet/mellanox/mlx5/core/Kconfig +9 -0
@@ -203,3 +203,12 @@ config MLX5_SW_STEERING default y help Build support for software-managed steering in the NIC. + +config MLX5_SF + bool "Mellanox Technologies subfunction device support using auxiliary device" + depends on MLX5_CORE && MLX5_CORE_EN + default n + help + Build support for subfuction device in the NIC. A Mellanox subfunction + device can support RDMA, netdevice and vdpa device. + It is similar to a SRIOV VF but it doesn't require SRIOV support.
drivers/net/ethernet/mellanox/mlx5/core/Makefile +4 -0
@@ -85,3 +85,7 @@ mlx5_core-$(CONFIG_MLX5_SW_STEERING) += steering/dr_domain.o steering/dr_table.o steering/dr_ste.o steering/dr_send.o \ steering/dr_cmd.o steering/dr_fw.o \ steering/dr_action.o steering/fs_dr.o +# +# SF device +# +mlx5_core-$(CONFIG_MLX5_SF) += sf/vhca_event.o
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +4 -0
@@ -464,6 +464,8 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op,case MLX5_CMD_OP_ALLOC_MEMIC :case MLX5_CMD_OP_MODIFY_XRQ :case MLX5_CMD_OP_RELEASE_XRQ_ERROR : +case MLX5_CMD_OP_QUERY_VHCA_STATE : +case MLX5_CMD_OP_MODIFY_VHCA_STATE : *status =MLX5_DRIVER_STATUS_ABORTED ; *synd =MLX5_DRIVER_SYND ;return -EIO ;
@@ -657,6 +659,8 @@ const char *mlx5_command_str(int command)MLX5_COMMAND_STR_CASE (DESTROY_UMEM );MLX5_COMMAND_STR_CASE (RELEASE_XRQ_ERROR );MLX5_COMMAND_STR_CASE (MODIFY_XRQ ); +MLX5_COMMAND_STR_CASE (QUERY_VHCA_STATE ); +MLX5_COMMAND_STR_CASE (MODIFY_VHCA_STATE );default :return "unknown command opcode" ; } }
drivers/net/ethernet/mellanox/mlx5/core/eq.c +3 -0
@@ -595,6 +595,9 @@ static void gather_async_events_mask(struct mlx5_core_dev *dev, u64 mask[4]) async_event_mask |= (1ull <<MLX5_EVENT_TYPE_ESW_FUNCTIONS_CHANGED ); +if (MLX5_CAP_GEN_MAX (dev, vhca_state)) + async_event_mask |= (1ull <<MLX5_EVENT_TYPE_VHCA_STATE_CHANGE ); + mask[0 ] = async_event_mask;if (MLX5_CAP_GEN (dev, event_cap))
drivers/net/ethernet/mellanox/mlx5/core/events.c +7 -0
@@ -110,6 +110,8 @@ static const char *eqe_type_str(u8 type)return "MLX5_EVENT_TYPE_CMD" ;case MLX5_EVENT_TYPE_ESW_FUNCTIONS_CHANGED :return "MLX5_EVENT_TYPE_ESW_FUNCTIONS_CHANGED" ; +case MLX5_EVENT_TYPE_VHCA_STATE_CHANGE : +return "MLX5_EVENT_TYPE_VHCA_STATE_CHANGE" ;case MLX5_EVENT_TYPE_PAGE_REQUEST :return "MLX5_EVENT_TYPE_PAGE_REQUEST" ;case MLX5_EVENT_TYPE_PAGE_FAULT :
@@ -403,3 +405,8 @@ int mlx5_notifier_call_chain(struct mlx5_events *events, unsigned int event, voi {return atomic_notifier_call_chain (&events->nh, event, data); } + +void mlx5_events_work_enqueue (struct mlx5_core_dev *dev,struct work_struct *work) +{ +queue_work (dev->priv.events->wq, work); +}
drivers/net/ethernet/mellanox/mlx5/core/main.c +16 -0
@@ -73,6 +73,7 @@#include "ecpf.h" #include "lib/hv_vhca.h" #include "diag/rsc_dump.h" +#include "sf/vhca_event.h" MODULE_AUTHOR ("Eli Cohen <[email protected]>" );MODULE_DESCRIPTION ("Mellanox 5th generation network adapters (ConnectX series) core driver" );
@@ -567,6 +568,8 @@ static int handle_hca_cap(struct mlx5_core_dev *dev, void *set_ctx)if (MLX5_CAP_GEN_MAX (dev, mkey_by_name))MLX5_SET (cmd_hca_cap, set_hca_cap, mkey_by_name,1 ); +mlx5_vhca_state_cap_handle (dev, set_hca_cap); +return set_caps (dev, set_ctx,MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE ); }
@@ -884,6 +887,12 @@ static int mlx5_init_once(struct mlx5_core_dev *dev) goto err_eswitch_cleanup; } + err =mlx5_vhca_event_init (dev); +if (err) { +mlx5_core_err (dev,"Failed to init vhca event notifier %d\n" , err); + goto err_fpga_cleanup; + } + dev->dm =mlx5_dm_create (dev);if (IS_ERR (dev->dm))mlx5_core_warn (dev,"Failed to init device memory%d\n" , err);
@@ -894,6 +903,8 @@ static int mlx5_init_once(struct mlx5_core_dev *dev)return 0 ; +err_fpga_cleanup: +mlx5_fpga_cleanup (dev); err_eswitch_cleanup:mlx5_eswitch_cleanup (dev->priv.eswitch); err_sriov_cleanup:
@@ -925,6 +936,7 @@ static void mlx5_cleanup_once(struct mlx5_core_dev *dev)mlx5_hv_vhca_destroy (dev->hv_vhca);mlx5_fw_tracer_destroy (dev->tracer);mlx5_dm_cleanup (dev); +mlx5_vhca_event_cleanup (dev);mlx5_fpga_cleanup (dev);mlx5_eswitch_cleanup (dev->priv.eswitch);mlx5_sriov_cleanup (dev);
@@ -1129,6 +1141,8 @@ static int mlx5_load(struct mlx5_core_dev *dev) goto err_sriov; } +mlx5_vhca_event_start (dev); + err =mlx5_ec_init (dev);if (err) {mlx5_core_err (dev,"Failed to init embedded CPU\n" );
@@ -1146,6 +1160,7 @@ static int mlx5_load(struct mlx5_core_dev *dev) err_sriov:mlx5_ec_cleanup (dev); err_ec: +mlx5_vhca_event_stop (dev);mlx5_cleanup_fs (dev); err_fs:mlx5_accel_tls_cleanup (dev);
@@ -1173,6 +1188,7 @@ static void mlx5_unload(struct mlx5_core_dev *dev) {mlx5_sriov_detach (dev);mlx5_ec_cleanup (dev); +mlx5_vhca_event_stop (dev);mlx5_cleanup_fs (dev);mlx5_accel_ipsec_cleanup (dev);mlx5_accel_tls_cleanup (dev);
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +2 -0
@@ -259,4 +259,6 @@ void mlx5_set_nic_state(struct mlx5_core_dev *dev, u8 state);void mlx5_unload_one (struct mlx5_core_dev *dev,bool cleanup);int mlx5_load_one (struct mlx5_core_dev *dev,bool boot); + +void mlx5_events_work_enqueue (struct mlx5_core_dev *dev,struct work_struct *work);#endif /* __MLX5_CORE_H__ */
drivers/net/ethernet/mellanox/mlx5/core/sf/mlx5_ifc_vhca_event.h new file +82 -0
82 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/sf/sf.h new file +45 -0
45 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/sf/vhca_event.c new file +189 -0
189 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/sf/vhca_event.h new file +57 -0
57 lines not on this page · raw message
include/linux/mlx5/driver.h +4 -0
@@ -507,6 +507,7 @@ struct mlx5_devcom;struct mlx5_fw_reset ;struct mlx5_eq_table ;struct mlx5_irq_table ; +struct mlx5_vhca_state_notifier ;struct mlx5_rate_limit {u32 rate;
@@ -603,6 +604,9 @@ struct mlx5_priv {struct mlx5_bfreg_data bfregs;struct mlx5_uars_page *uar; +#ifdef CONFIG_MLX5_SF +struct mlx5_vhca_state_notifier *vhca_state_notifier; +#endif };enum mlx5_device_state {
Signature · 1 line
2.26.2
PATCH v5 15/15 net/mlx5: Add devlink subfunction port documentation
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
Add documentation for subfunction management using devlink port.
--- .../device_drivers/ethernet/mellanox/mlx5.rst | 204 ++++++++++++++++++ 1 file changed, 204 insertions(+)
Documentation/networking/device_drivers/ethernet/mellanox/mlx5.rst +204 -0
@@ -12,6 +12,8 @@ Contents - `Enabling the driver and kconfig options`_ - `Devlink info`_ - `Devlink parameters`_ +- `mlx5 subfunction`_ +- `mlx5 port function`_ - `Devlink health reporters`_ - `mlx5 tracepoints`_
@@ -181,6 +183,208 @@ User command examples: values: cmode driverinit value true +mlx5 subfunction +================ +mlx5 supports subfunctions management using devlink port (see :ref:`Documentation/networking/devlink/devlink-port.rst <devlink_port>`) interface. + +A Subfunction has its own function capabilities and its own resources. This +means a subfunction has its own dedicated queues(txq, rxq, cq, eq). These queues +are neither shared nor stolen from the parent PCI function. + +When subfunction is RDMA capable, it has its own QP1, GID table and rdma +resources neither shared nor stolen from the parent PCI function. + +A subfunction has dedicated window in PCI BAR space that is not shared +with the other subfunctions or parent PCI function. This ensures that all +class devices of the subfunction accesses only assigned PCI BAR space. + +A Subfunction supports eswitch representation through which it supports tc +offloads. User must configure eswitch to send/receive packets from/to +subfunction port. + +Subfunctions share PCI level resources such as PCI MSI-X IRQs with +the other subfunctions and/or with its parent PCI function. + +Example mlx5 software, system and device view:: + + _______ + | admin | + | user |---------- + |_______| | + | | + ____|____ __|______ _________________ + | | | | | | + | devlink | | tc tool | | user | + | tool | |_________| | applications | + |_________| | |_________________| + | | | | + | | | | Userspace + +---------|-------------|-------------------|----------|--------------------+ + | | +----------+ +----------+ Kernel + | | | netdev | | rdma dev | + | | +----------+ +----------+ + (devlink port add/del | ^ ^ + port function set) | | | + | | +---------------| + _____|___ | | _______|_______ + | | | | | mlx5 class | + | devlink | +------------+ | | drivers | + | kernel | | rep netdev | | |(mlx5_core,ib) | + |_________| +------------+ | |_______________| + | | | ^ + (devlink ops) | | (probe/remove) + _________|________ | | ____|________ + | subfunction | | +---------------+ | subfunction | + | management driver|----- | subfunction |---| driver | + | (mlx5_core) | | auxiliary dev | | (mlx5_core) | + |__________________| +---------------+ |_____________| + | ^ + (sf add/del, vhca events) | + | (device add/del) + _____|____ ____|________ + | | | subfunction | + | PCI NIC |---- activate/deactive events---->| host driver | + |__________| | (mlx5_core) | + |_____________| + +Subfunction is created using devlink port interface. + +- Change device to switchdev mode:: + + $ devlink dev eswitch set pci/0000:06:00.0 mode switchdev + +- Add a devlink port of subfunction flavour:: + + $ devlink port add pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum 88 + +- Show a devlink port of the subfunction:: + + $ devlink port show pci/0000:06:00.0/32768 + pci/0000:06:00.0/32768: type eth netdev enp6s0pf0sf88 flavour pcisf pfnum 0 sfnum 88 + function: + hw_addr 00:00:00:00:00:00 + +- Delete a devlink port of subfunction after use:: + + $ devlink port del pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum 88 + +mlx5 port function +================== +mlx5 driver provides mechanism to setup PCI VF/SF port function +attributes in unified way for smartnic and non-smartnic NICs. + +This is supported only when eswitch mode is set to switchdev. Port function +configuration of the PCI VF/SF is supported through devlink eswitch port. + +Port function attributes should be set before PCI VF/SF is enumerated by the +driver. + +MAC address setup +----------------- +mlx5 driver provides mechanism to setup the MAC address of the PCI VF/SF. + +Configured MAC address of the PCI VF/SF will be used by netdevice and rdma +device created for the PCI VF/SF. + +- Get MAC address of the VF identified by its unique devlink port index:: + + $ 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 + +- Set MAC address of the VF identified by its unique devlink port index:: + + $ devlink port function set pci/0000:06:00.0/2 hw_addr 00:11:22:33:44:55 + + $ 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:11:22:33:44:55 + +- Get MAC address of the SF identified by its unique devlink port index:: + + $ devlink port show pci/0000:06:00.0/32768 + pci/0000:06:00.0/32768: type eth netdev enp6s0pf0sf88 flavour pcisf pfnum 0 sfnum 88 + function: + hw_addr 00:00:00:00:00:00 + +- Set MAC address of the VF identified by its unique devlink port index:: + + $ devlink port function set pci/0000:06:00.0/32768 hw_addr 00:00:00:00:88:88 + + $ devlink port show pci/0000:06:00.0/32768 + pci/0000:06:00.0/32768: type eth netdev enp6s0pf0sf88 flavour pcivf pfnum 0 sfnum 88 + function: + hw_addr 00:00:00:00:88:88 + +SF state setup +-------------- +To use the SF, user must active the SF using SF port function state attribute. + +- Get state of the SF identified by its unique devlink port index:: + + $ devlink port show ens2f0npf0sf88 + pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false + function: + hw_addr 00:00:00:00:88:88 state inactive opstate detached + +- Activate the function and verify its state is active:: + + $ devlink port function set ens2f0npf0sf88 state active + + $ devlink port show ens2f0npf0sf88 + pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false + function: + hw_addr 00:00:00:00:88:88 state active opstate detached + +Upon function activation, PF driver instance gets the event from the device that +particular SF was activated. It's the cue to put the device on bus, probe it and +instantiate devlink instance and class specific auxiliary devices for it. + +- Show the auxiliary device and port of the subfunction:: + + $ devlink dev show + devlink dev show auxiliary/mlx5_core.sf.4 + + $ devlink port show auxiliary/mlx5_core.sf.4/1 + auxiliary/mlx5_core.sf.4/1: type eth netdev p0sf88 flavour virtual port 0 splittable false + + $ rdma link show mlx5_0/1 + link mlx5_0/1 state ACTIVE physical_state LINK_UP netdev p0sf88 + + $ rdma dev show + 8: rocep6s0f1: node_type ca fw 16.29.0550 node_guid 248a:0703:00b3:d113 sys_image_guid 248a:0703:00b3:d112 + 13: mlx5_0: node_type ca fw 16.29.0550 node_guid 0000:00ff:fe00:8888 sys_image_guid 248a:0703:00b3:d112 + +- Subfunction auxiliary device and class device hierarchy:: + + mlx5_core.sf.4 + (subfunction auxiliary device) + /\ + / \ + / \ + / \ + / \ + mlx5_core.eth.4 mlx5_core.rdma.4 + (sf eth aux dev) (sf rdma aux dev) + | | + | | + p0sf88 mlx5_0 + (sf netdev) (sf rdma device) + +Additionally SF port also gets the event when the driver attaches to the +auxiliary device of the subfunction. This results in changing the operational +state of the function. This provides visibility to user to decide when it is +safe to delete the SF port for graceful termination of the subfunction. + +- Show the SF port operational state:: + + $ devlink port show ens2f0npf0sf88 + pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false + function: + hw_addr 00:00:00:00:88:88 state active opstate attached + Devlink health reporters ========================
Signature · 1 line
2.26.2
PATCH v5 12/15 net/mlx5: SF, Port function state change support
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
Support changing the state of the SF port's function through devlink. When activating the SF port's function, enable the hca in the device followed by adding its auxiliary device.
When deactivating the SF port's function, delete its auxiliary device followed by disabling the vHCA.
Port function attributes get/set callbacks are invoked with devlink instance lock held. Such callbacks need to synchronize with sf port table getting disabled either via sriov sysfs callback. Such callbacks synchronize with table disable context holding table refcount.
$ devlink dev eswitch set pci/0000:06:00.0 mode switchdev
$ devlink port show pci/0000:06:00.0/65535: type eth netdev ens2f0np0 flavour physical port 0 splittable false
$ devlink port add pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum 88
$ devlink port show ens2f0npf0sf88
pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
function:
hw_addr 00:00:00:00:88:88 state inactive opstate detached$ devlink port function set pci/0000:06:00.0/32768 hw_addr 00:00:00:00:88:88 state active
$ devlink port show ens2f0npf0sf88 -jp
{
"port": {
"pci/0000:06:00.0/32768": {
"type": "eth",
"netdev": "ens2f0npf0sf88",
"flavour": "pcisf",
"controller": 0,
"pfnum": 0,
"sfnum": 88,
"external": false,
"splittable": false,
"function": {
"hw_addr": "00:00:00:00:88:88",
"state": "active",
"opstate": "attached"
}
}
}
}On port function activation, an auxiliary device is created in below example.
$ devlink dev show devlink dev show auxiliary/mlx5_core.sf.4
$ devlink port show auxiliary/mlx5_core.sf.4/1 auxiliary/mlx5_core.sf.4/1: type eth netdev p0sf88 flavour virtual port 0 splittable false
--- .../net/ethernet/mellanox/mlx5/core/devlink.c | 2 + .../net/ethernet/mellanox/mlx5/core/main.c | 10 + .../net/ethernet/mellanox/mlx5/core/sf/cmd.c | 22 ++ .../ethernet/mellanox/mlx5/core/sf/devlink.c | 284 ++++++++++++++++-- .../ethernet/mellanox/mlx5/core/sf/hw_table.c | 116 ++++++- .../net/ethernet/mellanox/mlx5/core/sf/priv.h | 4 + .../net/ethernet/mellanox/mlx5/core/sf/sf.h | 19 ++ 7 files changed, 431 insertions(+), 26 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/devlink.c +2 -0
@@ -195,6 +195,8 @@ static const struct devlink_ops mlx5_devlink_ops = {#ifdef CONFIG_MLX5_SF_MANAGER .port_new = mlx5_devlink_sf_port_new, .port_del = mlx5_devlink_sf_port_del, + .port_function_state_get = mlx5_devlink_sf_port_fn_state_get, + .port_function_state_set = mlx5_devlink_sf_port_fn_state_set, #endif .flash_update = mlx5_devlink_flash_update, .info_get = mlx5_devlink_info_get,
drivers/net/ethernet/mellanox/mlx5/core/main.c +10 -0
@@ -75,6 +75,7 @@#include "diag/rsc_dump.h" #include "sf/vhca_event.h" #include "sf/dev/dev.h" +#include "sf/sf.h" MODULE_AUTHOR ("Eli Cohen <[email protected]>" );MODULE_DESCRIPTION ("Mellanox 5th generation network adapters (ConnectX series) core driver" );
@@ -1161,6 +1162,12 @@ static int mlx5_load(struct mlx5_core_dev *dev)mlx5_vhca_event_start (dev); + err =mlx5_sf_hw_table_create (dev); +if (err) { +mlx5_core_err (dev,"sf table create failed %d\n" , err); + goto err_vhca; + } + err =mlx5_ec_init (dev);if (err) {mlx5_core_err (dev,"Failed to init embedded CPU\n" );
@@ -1180,6 +1187,8 @@ static int mlx5_load(struct mlx5_core_dev *dev) err_sriov:mlx5_ec_cleanup (dev); err_ec: +mlx5_sf_hw_table_destroy (dev); +err_vhca:mlx5_vhca_event_stop (dev);mlx5_cleanup_fs (dev); err_fs:
@@ -1209,6 +1218,7 @@ static void mlx5_unload(struct mlx5_core_dev *dev)mlx5_sf_dev_table_destroy (dev);mlx5_sriov_detach (dev);mlx5_ec_cleanup (dev); +mlx5_sf_hw_table_destroy (dev);mlx5_vhca_event_stop (dev);mlx5_cleanup_fs (dev);mlx5_accel_ipsec_cleanup (dev);
drivers/net/ethernet/mellanox/mlx5/core/sf/cmd.c +22 -0
@@ -25,3 +25,25 @@ int mlx5_cmd_dealloc_sf(struct mlx5_core_dev *dev, u16 function_id)return mlx5_cmd_exec (dev, in,sizeof (in), out,sizeof (out)); } + +int mlx5_cmd_sf_enable_hca (struct mlx5_core_dev *dev,u16 func_id) +{ +u32 out[MLX5_ST_SZ_DW (enable_hca_out)] = {}; +u32 in[MLX5_ST_SZ_DW (enable_hca_in)] = {}; + +MLX5_SET (enable_hca_in, in, opcode,MLX5_CMD_OP_ENABLE_HCA ); +MLX5_SET (enable_hca_in, in, function_id, func_id); +MLX5_SET (enable_hca_in, in, embedded_cpu_function,0 ); +return mlx5_cmd_exec (dev, &in,sizeof (in), &out,sizeof (out)); +} + +int mlx5_cmd_sf_disable_hca (struct mlx5_core_dev *dev,u16 func_id) +{ +u32 out[MLX5_ST_SZ_DW (disable_hca_out)] = {}; +u32 in[MLX5_ST_SZ_DW (disable_hca_in)] = {}; + +MLX5_SET (disable_hca_in, in, opcode,MLX5_CMD_OP_DISABLE_HCA ); +MLX5_SET (disable_hca_in, in, function_id, func_id); +MLX5_SET (enable_hca_in, in, embedded_cpu_function,0 ); +return mlx5_cmd_exec (dev, in,sizeof (in), out,sizeof (out)); +}
drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c +262 -22
395 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c +112 -4
186 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/sf/priv.h +4 -0
@@ -9,9 +9,13 @@int mlx5_cmd_alloc_sf (struct mlx5_core_dev *dev,u16 function_id);int mlx5_cmd_dealloc_sf (struct mlx5_core_dev *dev,u16 function_id); +int mlx5_cmd_sf_enable_hca (struct mlx5_core_dev *dev,u16 func_id); +int mlx5_cmd_sf_disable_hca (struct mlx5_core_dev *dev,u16 func_id); +u16 mlx5_sf_sw_to_hw_id (const struct mlx5_core_dev *dev,u16 sw_id);int mlx5_sf_hw_table_sf_alloc (struct mlx5_core_dev *dev,u32 usr_sfnum);void mlx5_sf_hw_table_sf_free (struct mlx5_core_dev *dev,u16 id); +void mlx5_sf_hw_table_sf_deferred_free (struct mlx5_core_dev *dev,u16 id);#endif
drivers/net/ethernet/mellanox/mlx5/core/sf/sf.h +19 -0
@@ -31,6 +31,9 @@ static inline u16 mlx5_sf_max_functions(const struct mlx5_core_dev *dev)int mlx5_sf_hw_table_init (struct mlx5_core_dev *dev);void mlx5_sf_hw_table_cleanup (struct mlx5_core_dev *dev); +int mlx5_sf_hw_table_create (struct mlx5_core_dev *dev); +void mlx5_sf_hw_table_destroy (struct mlx5_core_dev *dev); +int mlx5_sf_table_init (struct mlx5_core_dev *dev);void mlx5_sf_table_cleanup (struct mlx5_core_dev *dev);
@@ -38,6 +41,13 @@ int mlx5_devlink_sf_port_new(struct devlink *devlink, const struct devlink_port_ struct netlink_ext_ack *extack);int mlx5_devlink_sf_port_del (struct devlink *devlink,unsigned int port_index,struct netlink_ext_ack *extack); +int mlx5_devlink_sf_port_fn_state_get (struct devlink *devlink,struct devlink_port *dl_port, +enum devlink_port_function_state *state, +enum devlink_port_function_opstate *opstate, +struct netlink_ext_ack *extack); +int mlx5_devlink_sf_port_fn_state_set (struct devlink *devlink,struct devlink_port *dl_port, +enum devlink_port_function_state state, +struct netlink_ext_ack *extack);#else static inline bool mlx5_sf_supported (const struct mlx5_core_dev *dev)
@@ -59,6 +69,15 @@ static inline void mlx5_sf_hw_table_cleanup(struct mlx5_core_dev *dev) { } +static inline int mlx5_sf_hw_table_create (struct mlx5_core_dev *dev) +{ +return 0 ; +} + +static inline void mlx5_sf_hw_table_destroy (struct mlx5_core_dev *dev) +{ +} +static inline int mlx5_sf_table_init (struct mlx5_core_dev *dev) {return 0 ;
Signature · 1 line
2.26.2
PATCH v5 9/15 net/mlx5: E-switch, Prepare eswitch to handle SF vport
In reply to Saeed MahameedFrom: Vu Pham <[email protected]>
Prepare eswitch to handle SF vport during
(a) querying eswitch functions
(b) egress ACL creation
(c) account for SF vports in total vports calculation
Assign a dedicated placeholder for SFs vports and their representors. They are placed after VFs vports and before ECPF vports as below:
[PF,VF0,...,VFn,SF0,...SFm,ECPF,UPLINK].
Change functions to map SF's vport numbers to indices when accessing the vports or representors arrays, and vice versa.
--- .../net/ethernet/mellanox/mlx5/core/Kconfig | 10 ++++ .../mellanox/mlx5/core/esw/acl/egress_ofld.c | 2 +- .../net/ethernet/mellanox/mlx5/core/eswitch.c | 11 +++- .../net/ethernet/mellanox/mlx5/core/eswitch.h | 50 +++++++++++++++++++ .../mellanox/mlx5/core/eswitch_offloads.c | 11 ++++ .../net/ethernet/mellanox/mlx5/core/vport.c | 3 +- 6 files changed, 83 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/Kconfig +10 -0
@@ -212,3 +212,13 @@ config MLX5_SF Build support for subfuction device in the NIC. A Mellanox subfunction device can support RDMA, netdevice and vdpa device. It is similar to a SRIOV VF but it doesn't require SRIOV support. + +config MLX5_SF_MANAGER + bool + depends on MLX5_SF && MLX5_ESWITCH + default y + help + Build support for subfuction port in the NIC. A Mellanox subfunction + port is managed through devlink. A subfunction supports RDMA, netdevice + and vdpa device. It is similar to a SRIOV VF but it doesn't require + SRIOV support.
drivers/net/ethernet/mellanox/mlx5/core/esw/acl/egress_ofld.c +1 -1
@@ -150,7 +150,7 @@ static void esw_acl_egress_ofld_groups_destroy(struct mlx5_vport *vport)static bool esw_acl_egress_needed (const struct mlx5_eswitch *esw,u16 vport_num) { -return mlx5_eswitch_is_vf_vport (esw, vport_num); +return mlx5_eswitch_is_vf_vport (esw, vport_num) ||mlx5_esw_is_sf_vport (esw, vport_num); }int esw_acl_egress_ofld_setup (struct mlx5_eswitch *esw,struct mlx5_vport *vport)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +9 -2
@@ -1366,9 +1366,15 @@ const u32 *mlx5_esw_query_functions(struct mlx5_core_dev *dev) {int outlen =MLX5_ST_SZ_BYTES (query_esw_functions_out);u32 in[MLX5_ST_SZ_DW (query_esw_functions_in)] = {}; +u16 max_sf_vports;u32 *out;int err; + max_sf_vports =mlx5_sf_max_functions (dev); +/* Device interface is array of 64-bits */ +if (max_sf_vports) + outlen +=DIV_ROUND_UP (max_sf_vports,BITS_PER_TYPE (__be64)) *sizeof (__be64); + out =kvzalloc (outlen,GFP_KERNEL );if (!out)return ERR_PTR (-ENOMEM );
@@ -1376,7 +1382,7 @@ const u32 *mlx5_esw_query_functions(struct mlx5_core_dev *dev)MLX5_SET (query_esw_functions_in, in, opcode,MLX5_CMD_OP_QUERY_ESW_FUNCTIONS ); - err =mlx5_cmd_exec_inout (dev, query_esw_functions, in, out); + err =mlx5_cmd_exec (dev, in,sizeof (in), out, outlen);if (!err)return out;
@@ -1899,7 +1905,8 @@ static bool is_port_function_supported(const struct mlx5_eswitch *esw, u16 vport_num) {return vport_num ==MLX5_VPORT_PF || -mlx5_eswitch_is_vf_vport (esw, vport_num); +mlx5_eswitch_is_vf_vport (esw, vport_num) || +mlx5_esw_is_sf_vport (esw, vport_num); } int mlx5_devlink_port_function_hw_addr_get(struct devlink *devlink,
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +50 -0
80 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +11 -0
@@ -1800,11 +1800,22 @@ static void __esw_offloads_unload_rep(struct mlx5_eswitch *esw, esw->offloads.rep_ops[rep_type]->unload (rep); } +static void __unload_reps_sf_vport (struct mlx5_eswitch *esw,u8 rep_type) +{ +struct mlx5_eswitch_rep *rep; +int i; + +mlx5_esw_for_each_sf_rep (esw, i, rep) +__esw_offloads_unload_rep (esw, rep, rep_type); +} +static void __unload_reps_all_vport (struct mlx5_eswitch *esw,u8 rep_type) {struct mlx5_eswitch_rep *rep;int i; +__unload_reps_sf_vport (esw, rep_type); +mlx5_esw_for_each_vf_rep_reverse (esw, i, rep, esw->esw_funcs.num_vfs)__esw_offloads_unload_rep (esw, rep, rep_type);
drivers/net/ethernet/mellanox/mlx5/core/vport.c +2 -1
@@ -36,6 +36,7 @@#include <linux/mlx5/vport.h> #include <linux/mlx5/eswitch.h> #include "mlx5_core.h" +#include "sf/sf.h" /* Mutex to hold while enabling or disabling RoCE */ static DEFINE_MUTEX (mlx5_roce_en_lock);
@@ -1160,6 +1161,6 @@ EXPORT_SYMBOL_GPL(mlx5_query_nic_system_image_guid);*/ u16 mlx5_eswitch_get_total_vports (const struct mlx5_core_dev *dev) { -return MLX5_SPECIAL_VPORTS (dev) +mlx5_core_max_vfs (dev); +return MLX5_SPECIAL_VPORTS (dev) +mlx5_core_max_vfs (dev) +mlx5_sf_max_functions (dev); }EXPORT_SYMBOL_GPL (mlx5_eswitch_get_total_vports);
Signature · 1 line
2.26.2
PATCH v5 13/15 devlink: Add devlink port documentation
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
Added documentation for devlink port and port function related commands.
--- .../networking/devlink/devlink-port.rst | 118 ++++++++++++++++++ Documentation/networking/devlink/index.rst | 1 + 2 files changed, 119 insertions(+) create mode 100644 Documentation/networking/devlink/devlink-port.rst
Documentation/networking/devlink/devlink-port.rst new file +118 -0
@@ -0,0 +1,118 @@ +.. SPDX-License-Identifier: GPL-2.0 + +.. _devlink_port: + +============ +Devlink Port +============ + +``devlink-port`` is a port that exists on the device. It has a logically +separate ingress/egress point of the device. A devlink port can be any one +of many flavours. A devlink port flavour along with port attributes +describe what a port represents. + +A device driver that intends to publish a devlink port sets the +devlink port attributes and registers the devlink port. + +Devlink port flavours are described below. + +.. list-table:: List of devlink port flavours + :widths: 33 90 + + * - Flavour + - Description + * - ``DEVLINK_PORT_FLAVOUR_PHYSICAL`` + - Any kind of physical port. This can be an eswitch physical port or any + other physical port on the device. + * - ``DEVLINK_PORT_FLAVOUR_DSA`` + - This indicates a DSA interconnect port. + * - ``DEVLINK_PORT_FLAVOUR_CPU`` + - This indicates a CPU port applicable only to DSA. + * - ``DEVLINK_PORT_FLAVOUR_PCI_PF`` + - This indicates an eswitch port representing a port of PCI + physical function (PF). + * - ``DEVLINK_PORT_FLAVOUR_PCI_VF`` + - This indicates an eswitch port representing a port of PCI + virtual function (VF). + * - ``DEVLINK_PORT_FLAVOUR_VIRTUAL`` + - This indicates a virtual port for the PCI virtual function. + +Devlink port can have a different type based on the link layer described below. + +.. list-table:: List of devlink port types + :widths: 23 90 + + * - Type + - Description + * - ``DEVLINK_PORT_TYPE_ETH`` + - Driver should set this port type when a link layer of the port is + Ethernet. + * - ``DEVLINK_PORT_TYPE_IB`` + - Driver should set this port type when a link layer of the port is + InfiniBand. + * - ``DEVLINK_PORT_TYPE_AUTO`` + - This type is indicated by the user when driver should detect the port + type automatically. + +PCI controllers +--------------- +In most cases a PCI device has only one controller. A controller consists of +potentially multiple physical and virtual functions. Such PCI function consists +of one or more ports. This port of the function is represented by the devlink +eswitch port. + +A PCI Device connected to multiple CPUs or multiple PCI root complexes or +SmartNIC, however, may have multiple controllers. For a device with multiple +controllers, each controller is distinguished by a unique controller number. +An eswitch on the PCI device support ports of multiple controllers. + +An example view of a system with two controllers:: + + --------------------------------------------------------- + | | + | --------- --------- ------- ------- | + ----------- | | vf(s) | | sf(s) | |vf(s)| |sf(s)| | + | server | | ------- ----/---- ---/----- ------- ---/--- ---/--- | + | pci rc |=== | pf0 |______/________/ | pf1 |___/_______/ | + | connect | | ------- ------- | + ----------- | | controller_num=1 (no eswitch) | + ------|-------------------------------------------------- + (internal wire) + | + --------------------------------------------------------- + | devlink eswitch ports and reps | + | ----------------------------------------------------- | + | |ctrl-0 | ctrl-0 | ctrl-0 | ctrl-0 | ctrl-0 |ctrl-0 | | + | |pf0 | pf0vfN | pf0sfN | pf1 | pf1vfN |pf1sfN | | + | ----------------------------------------------------- | + | |ctrl-1 | ctrl-1 | ctrl-1 | ctrl-1 | ctrl-1 |ctrl-1 | | + | |pf0 | pf0vfN | pf0sfN | pf1 | pf1vfN |pf1sfN | | + | ----------------------------------------------------- | + | | + | | + ----------- | --------- --------- ------- ------- | + | smartNIC| | | vf(s) | | sf(s) | |vf(s)| |sf(s)| | + | pci rc |==| ------- ----/---- ---/----- ------- ---/--- ---/--- | + | connect | | | pf0 |______/________/ | pf1 |___/_______/ | + ----------- | ------- ------- | + | | + | local controller_num=0 (eswitch) | + --------------------------------------------------------- + +In above example, external controller (identified by controller number = 1) +doesn't have eswitch. Local controller (identified by controller number = 0) +has the eswitch. Devlink instance on local controller has eswitch devlink +ports representing ports for both the controllers. + +Port function configuration +=========================== + +A user can configure the port function attribute before enumerating the +PCI function. Usually it means, user should configure port function attribute +before a bus specific device for the function is created. However, when +SRIOV is enabled, virtual function devices are created on the PCI bus. +Hence, function attribute should be configured before binding virtual +function device to the driver. + +User may set the hardware address of the function represented by the devlink +port function. For Ethernet port function this means a MAC address.
Documentation/networking/devlink/index.rst +1 -0
@@ -18,6 +18,7 @@ general. devlink-info devlink-flash devlink-params + devlink-port devlink-region devlink-resource devlink-reload
Signature · 1 line
2.26.2
PATCH v5 14/15 devlink: Extend devlink port documentation for subfunctions
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
Add devlink port documentation for subfunction management.
--- Documentation/driver-api/auxiliary_bus.rst | 2 + .../networking/devlink/devlink-port.rst | 89 ++++++++++++++++++- 2 files changed, 87 insertions(+), 4 deletions(-)
Documentation/driver-api/auxiliary_bus.rst +2 -0
@@ -1,5 +1,7 @@ .. SPDX-License-Identifier: GPL-2.0-only +.. _auxiliary_bus: + ============= Auxiliary Bus =============
Documentation/networking/devlink/devlink-port.rst +85 -4
107 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH v5 5/15 devlink: Support get and set state of port function
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
devlink port function can be in active or inactive state. Allow users to get and set port function's state.
When the port function it activated, its operational state may change after a while when the device is created and driver binds to it. Similarly on deactivation flow.
To clearly describe the state of the port function and its device's operational state in the host system, define state and opstate attributes.
Example of a PCI SF port which supports a port function:
Create a device with ID=10 and one physical port.
$ devlink dev eswitch set pci/0000:06:00.0 mode switchdev
$ devlink port show pci/0000:06:00.0/65535: type eth netdev ens2f0np0 flavour physical port 0 splittable false
$ devlink port add pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum 88
$ devlink port show pci/0000:06:00.0/32768
pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
function:
hw_addr 00:00:00:00:88:88 state inactive opstate detached$ devlink port function set pci/0000:06:00.0/32768 hw_addr 00:00:00:00:88:88 state active
$ devlink port show pci/0000:06:00.0/32768 -jp
{
"port": {
"pci/0000:06:00.0/32768": {
"type": "eth",
"netdev": "ens2f0npf0sf88",
"flavour": "pcisf",
"controller": 0,
"pfnum": 0,
"sfnum": 88,
"external": false,
"splittable": false,
"function": {
"hw_addr": "00:00:00:00:88:88",
"state": "active",
"opstate": "attached"
}
}
}
}--- include/net/devlink.h | 23 +++++++++ include/uapi/linux/devlink.h | 21 +++++++++ net/core/devlink.c | 90 +++++++++++++++++++++++++++++++++++- 3 files changed, 133 insertions(+), 1 deletion(-)
include/net/devlink.h +23 -0
@@ -1374,6 +1374,29 @@ struct devlink_ops {int (*port_function_hw_addr_set)(struct devlink *devlink,struct devlink_port *port,const u8 *hw_addr,int hw_addr_len,struct netlink_ext_ack *extack); +/** +* @port_function_state_get: Port function's state get function. +* +* Should be used by device drivers to report the state of a function +* managed by the devlink port. Driver should return -EOPNOTSUPP if it +* doesn't support port function handling for a particular port. +*/ +int (*port_function_state_get)(struct devlink *devlink, +struct devlink_port *port, +enum devlink_port_function_state *state, +enum devlink_port_function_opstate *opstate, +struct netlink_ext_ack *extack); +/** +* @port_function_state_set: Port function's state set function. +* +* Should be used by device drivers to set the state of a function +* managed by the devlink port. Driver should return -EOPNOTSUPP if it +* doesn't support port function handling for a particular port. +*/ +int (*port_function_state_set)(struct devlink *devlink, +struct devlink_port *port, +enum devlink_port_function_state state, +struct netlink_ext_ack *extack);/** * @port_new: Port add function. *
include/uapi/linux/devlink.h +21 -0
@@ -583,9 +583,30 @@ enum devlink_resource_unit {enum devlink_port_function_attr {DEVLINK_PORT_FUNCTION_ATTR_UNSPEC ,DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR ,/* binary */ +DEVLINK_PORT_FUNCTION_ATTR_STATE ,/* u8 */ +DEVLINK_PORT_FUNCTION_ATTR_OPSTATE ,/* u8 */ __DEVLINK_PORT_FUNCTION_ATTR_MAX,DEVLINK_PORT_FUNCTION_ATTR_MAX = __DEVLINK_PORT_FUNCTION_ATTR_MAX -1 }; +enum devlink_port_function_state { +DEVLINK_PORT_FUNCTION_STATE_INACTIVE , +DEVLINK_PORT_FUNCTION_STATE_ACTIVE , +}; + +/** +* enum devlink_port_function_opstate - indicates operational state of port function +* @DEVLINK_PORT_FUNCTION_OPSTATE_ATTACHED: Driver is attached to the function of port, for +* gracefufl tear down of the function, after +* inactivation of the port function, user should wait +* for operational state to turn DETACHED. +* @DEVLINK_PORT_FUNCTION_OPSTATE_DETACHED: Driver is detached from the function of port; it is +* safe to delete the port. +*/ +enum devlink_port_function_opstate { +DEVLINK_PORT_FUNCTION_OPSTATE_DETACHED , +DEVLINK_PORT_FUNCTION_OPSTATE_ATTACHED , +}; +#endif /* _UAPI_LINUX_DEVLINK_H_ */
net/core/devlink.c +89 -1
121 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH v5 10/15 net/mlx5: E-switch, Add eswitch helpers for SF vport
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
Add helpers to enable/disable eswitch port, register its devlink port and load its representor.
--- .../mellanox/mlx5/core/esw/devlink_port.c | 41 +++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/eswitch.c | 12 +++--- .../net/ethernet/mellanox/mlx5/core/eswitch.h | 16 ++++++++ .../mellanox/mlx5/core/eswitch_offloads.c | 36 +++++++++++++++- 4 files changed, 97 insertions(+), 8 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/esw/devlink_port.c +41 -0
@@ -122,3 +122,44 @@ struct devlink_port *mlx5_esw_offloads_devlink_port(struct mlx5_eswitch *esw, u1 vport =mlx5_eswitch_get_vport (esw, vport_num);return vport->dl_port; } + +int mlx5_esw_devlink_sf_port_register (struct mlx5_eswitch *esw,struct devlink_port *dl_port, +u16 vport_num,u32 sfnum) +{ +struct mlx5_core_dev *dev = esw->dev; +struct netdev_phys_item_id ppid = {}; +unsigned int dl_port_index; +struct mlx5_vport *vport; +struct devlink *devlink; +u16 pfnum; +int err; + + vport =mlx5_eswitch_get_vport (esw, vport_num); +if (IS_ERR (vport)) +return PTR_ERR (vport); + + pfnum =PCI_FUNC (dev->pdev->devfn); +mlx5_esw_get_port_parent_id (dev, &ppid); +memcpy (dl_port->attrs.switch_id.id, &ppid.id[0 ], ppid.id_len); + dl_port->attrs.switch_id.id_len = ppid.id_len; +devlink_port_attrs_pci_sf_set (dl_port,0 , pfnum, sfnum, false); + devlink =priv_to_devlink (dev); + dl_port_index =mlx5_esw_vport_to_devlink_port_index (dev, vport_num); + err =devlink_port_register (devlink, dl_port, dl_port_index); +if (err) +return err; + + vport->dl_port = dl_port; +return 0 ; +} + +void mlx5_esw_devlink_sf_port_unregister (struct mlx5_eswitch *esw,u16 vport_num) +{ +struct mlx5_vport *vport; + + vport =mlx5_eswitch_get_vport (esw, vport_num); +if (IS_ERR (vport)) +return ; +devlink_port_unregister (vport->dl_port); + vport->dl_port =NULL ; +}
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +6 -6
@@ -1273,8 +1273,8 @@ static void esw_vport_cleanup(struct mlx5_eswitch *esw, struct mlx5_vport *vportesw_vport_cleanup_acl (esw, vport); } -static int esw_enable_vport (struct mlx5_eswitch *esw,u16 vport_num, -enum mlx5_eswitch_vport_event enabled_events) +int mlx5_esw_vport_enable (struct mlx5_eswitch *esw,u16 vport_num, +enum mlx5_eswitch_vport_event enabled_events) {struct mlx5_vport *vport;int ret;
@@ -1310,7 +1310,7 @@ static int esw_enable_vport(struct mlx5_eswitch *esw, u16 vport_num,return ret; } -static void esw_disable_vport (struct mlx5_eswitch *esw,u16 vport_num) +void mlx5_esw_vport_disable (struct mlx5_eswitch *esw,u16 vport_num) {struct mlx5_vport *vport;
@@ -1432,7 +1432,7 @@ int mlx5_eswitch_load_vport(struct mlx5_eswitch *esw, u16 vport_num, {int err; - err =esw_enable_vport (esw, vport_num, enabled_events); + err =mlx5_esw_vport_enable (esw, vport_num, enabled_events);if (err)return err;
@@ -1443,14 +1443,14 @@ int mlx5_eswitch_load_vport(struct mlx5_eswitch *esw, u16 vport_num,return err; err_rep: -esw_disable_vport (esw, vport_num); +mlx5_esw_vport_disable (esw, vport_num);return err; }void mlx5_eswitch_unload_vport (struct mlx5_eswitch *esw,u16 vport_num) {esw_offloads_unload_rep (esw, vport_num); -esw_disable_vport (esw, vport_num); +mlx5_esw_vport_disable (esw, vport_num); }void mlx5_eswitch_unload_vf_vports (struct mlx5_eswitch *esw,u16 num_vfs)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +16 -0
@@ -688,6 +688,10 @@ mlx5_eswitch_enable_pf_vf_vports(struct mlx5_eswitch *esw, enum mlx5_eswitch_vport_event enabled_events);void mlx5_eswitch_disable_pf_vf_vports (struct mlx5_eswitch *esw); +int mlx5_esw_vport_enable (struct mlx5_eswitch *esw,u16 vport_num, +enum mlx5_eswitch_vport_event enabled_events); +void mlx5_esw_vport_disable (struct mlx5_eswitch *esw,u16 vport_num); +int esw_vport_create_offloads_acl_tables (struct mlx5_eswitch *esw,struct mlx5_vport *vport);
@@ -706,6 +710,9 @@ esw_get_max_restore_tag(struct mlx5_eswitch *esw);int esw_offloads_load_rep (struct mlx5_eswitch *esw,u16 vport_num);void esw_offloads_unload_rep (struct mlx5_eswitch *esw,u16 vport_num); +int mlx5_esw_offloads_rep_load (struct mlx5_eswitch *esw,u16 vport_num); +void mlx5_esw_offloads_rep_unload (struct mlx5_eswitch *esw,u16 vport_num); +int mlx5_eswitch_load_vport (struct mlx5_eswitch *esw,u16 vport_num,enum mlx5_eswitch_vport_event enabled_events);void mlx5_eswitch_unload_vport (struct mlx5_eswitch *esw,u16 vport_num);
@@ -717,6 +724,15 @@ void mlx5_eswitch_unload_vf_vports(struct mlx5_eswitch *esw, u16 num_vfs);int mlx5_esw_offloads_devlink_port_register (struct mlx5_eswitch *esw,u16 vport_num);void mlx5_esw_offloads_devlink_port_unregister (struct mlx5_eswitch *esw,u16 vport_num);struct devlink_port *mlx5_esw_offloads_devlink_port (struct mlx5_eswitch *esw,u16 vport_num); + +int mlx5_esw_devlink_sf_port_register (struct mlx5_eswitch *esw,struct devlink_port *dl_port, +u16 vport_num,u32 sfnum); +void mlx5_esw_devlink_sf_port_unregister (struct mlx5_eswitch *esw,u16 vport_num); + +int mlx5_esw_offloads_sf_vport_enable (struct mlx5_eswitch *esw,struct devlink_port *dl_port, +u16 vport_num,u32 sfnum); +void mlx5_esw_offloads_sf_vport_disable (struct mlx5_eswitch *esw,u16 vport_num); +#else /* CONFIG_MLX5_ESWITCH */ /* eswitch API stubs */ static inline int mlx5_eswitch_init (struct mlx5_core_dev *dev) {return 0 ; }
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +34 -2
@@ -1833,7 +1833,7 @@ static void __unload_reps_all_vport(struct mlx5_eswitch *esw, u8 rep_type)__esw_offloads_unload_rep (esw, rep, rep_type); } -static int mlx5_esw_offloads_rep_load (struct mlx5_eswitch *esw,u16 vport_num) +int mlx5_esw_offloads_rep_load (struct mlx5_eswitch *esw,u16 vport_num) {struct mlx5_eswitch_rep *rep;int rep_type;
@@ -1857,7 +1857,7 @@ static int mlx5_esw_offloads_rep_load(struct mlx5_eswitch *esw, u16 vport_num)return err; } -static void mlx5_esw_offloads_rep_unload (struct mlx5_eswitch *esw,u16 vport_num) +void mlx5_esw_offloads_rep_unload (struct mlx5_eswitch *esw,u16 vport_num) {struct mlx5_eswitch_rep *rep;int rep_type;
@@ -2835,3 +2835,35 @@ u32 mlx5_eswitch_get_vport_metadata_for_match(struct mlx5_eswitch *esw,return vport->metadata << (32 -ESW_SOURCE_PORT_METADATA_BITS ); }EXPORT_SYMBOL (mlx5_eswitch_get_vport_metadata_for_match); + +int mlx5_esw_offloads_sf_vport_enable (struct mlx5_eswitch *esw,struct devlink_port *dl_port, +u16 vport_num,u32 sfnum) +{ +int err; + + err =mlx5_esw_vport_enable (esw, vport_num,MLX5_VPORT_UC_ADDR_CHANGE ); +if (err) +return err; + + err =mlx5_esw_devlink_sf_port_register (esw, dl_port, vport_num, sfnum); +if (err) + goto devlink_err; + + err =mlx5_esw_offloads_rep_load (esw, vport_num); +if (err) + goto rep_err; +return 0 ; + +rep_err: +mlx5_esw_devlink_sf_port_unregister (esw, vport_num); +devlink_err: +mlx5_esw_vport_disable (esw, vport_num); +return err; +} + +void mlx5_esw_offloads_sf_vport_disable (struct mlx5_eswitch *esw,u16 vport_num) +{ +mlx5_esw_offloads_rep_unload (esw, vport_num); +mlx5_esw_devlink_sf_port_unregister (esw, vport_num); +mlx5_esw_vport_disable (esw, vport_num); +}
Signature · 1 line
2.26.2
PATCH v5 8/15 net/mlx5: SF, Add auxiliary device driver
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
Add auxiliary device driver for mlx5 subfunction auxiliary device.
A mlx5 subfunction is similar to PCI PF and VF. For a subfunction an auxiliary device is created.
As a result, when mlx5 SF auxiliary device binds to the driver, its netdev and rdma device are created, they appear as
$ ls -l /sys/bus/auxiliary/devices/ mlx5_core.sf.4 -> ../../../devices/pci0000:00/0000:00:03.0/0000:06:00.0/mlx5_core.sf.4
$ ls -l /sys/class/net/eth1/device /sys/class/net/eth1/device -> ../../../mlx5_core.sf.4
$ cat /sys/bus/auxiliary/devices/mlx5_core.sf.4/sfnum 88
$ devlink dev show pci/0000:06:00.0 auxiliary/mlx5_core.sf.4
$ devlink port show auxiliary/mlx5_core.sf.4/1 auxiliary/mlx5_core.sf.4/1: type eth netdev p0sf88 flavour virtual port 0 splittable false
$ rdma link show mlx5_0/1 link mlx5_0/1 state ACTIVE physical_state LINK_UP netdev p0sf88
$ rdma dev show 8: rocep6s0f1: node_type ca fw 16.29.0550 node_guid 248a:0703:00b3:d113 sys_image_guid 248a:0703:00b3:d112 13: mlx5_0: node_type ca fw 16.29.0550 node_guid 0000:00ff:fe00:8888 sys_image_guid 248a:0703:00b3:d112
In future, devlink device instance name will adapt to have sfnum annotation using either an alias or as devlink instance name described in RFC [1].
[1] https://lore.kernel.org/netdev/20200519092258.GF4655@nanopsycho/
--- .../net/ethernet/mellanox/mlx5/core/Makefile | 2 +- .../net/ethernet/mellanox/mlx5/core/devlink.c | 12 +++ drivers/net/ethernet/mellanox/mlx5/core/eq.c | 2 +- .../net/ethernet/mellanox/mlx5/core/main.c | 12 ++- .../ethernet/mellanox/mlx5/core/mlx5_core.h | 10 ++ .../net/ethernet/mellanox/mlx5/core/pci_irq.c | 20 ++++ .../ethernet/mellanox/mlx5/core/sf/dev/dev.c | 10 ++ .../ethernet/mellanox/mlx5/core/sf/dev/dev.h | 20 ++++ .../mellanox/mlx5/core/sf/dev/driver.c | 101 ++++++++++++++++++ include/linux/mlx5/driver.h | 4 +- 10 files changed, 187 insertions(+), 6 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c
drivers/net/ethernet/mellanox/mlx5/core/Makefile +1 -1
@@ -88,4 +88,4 @@ mlx5_core-$(CONFIG_MLX5_SW_STEERING) += steering/dr_domain.o steering/dr_table.o # # SF device # -mlx5_core-$(CONFIG_MLX5_SF) += sf/vhca_event.o sf/dev/dev.o +mlx5_core-$(CONFIG_MLX5_SF) += sf/vhca_event.o sf/dev/dev.o sf/dev/driver.o
drivers/net/ethernet/mellanox/mlx5/core/devlink.c +12 -0
@@ -7,6 +7,7 @@#include "fw_reset.h" #include "fs_core.h" #include "eswitch.h" +#include "sf/dev/dev.h" static int mlx5_devlink_flash_update(struct devlink *devlink, struct devlink_flash_update_params *params,
@@ -127,6 +128,17 @@ static int mlx5_devlink_reload_down(struct devlink *devlink, bool netns_change, struct netlink_ext_ack *extack) {struct mlx5_core_dev *dev =devlink_priv (devlink); +bool sf_dev_allocated; + + sf_dev_allocated =mlx5_sf_dev_allocated (dev); +if (sf_dev_allocated) { +/* Reload results in deleting SF device which further results in +* unregistering devlink instance while holding devlink_mutext. +* Hence, do not support reload. +*/ +NL_SET_ERR_MSG_MOD (extack,"reload is unsupported when SFs are allocated\n" ); +return -EOPNOTSUPP ; + }switch (action) {case DEVLINK_RELOAD_ACTION_DRIVER_REINIT :
drivers/net/ethernet/mellanox/mlx5/core/eq.c +1 -1
@@ -467,7 +467,7 @@ int mlx5_eq_table_init(struct mlx5_core_dev *dev)for (i =0 ; i <MLX5_EVENT_TYPE_MAX ; i++)ATOMIC_INIT_NOTIFIER_HEAD (&eq_table->nh[i]); - eq_table->irq_table = dev->priv.irq_table; + eq_table->irq_table =mlx5_irq_table_get (dev);return 0 ; }
drivers/net/ethernet/mellanox/mlx5/core/main.c +9 -3
@@ -84,7 +84,6 @@ unsigned int mlx5_core_debug_mask;module_param_named (debug_mask, mlx5_core_debug_mask, uint,0644 );MODULE_PARM_DESC (debug_mask,"debug mask: 1 = dump cmd data, 2 = dump cmd exec time, 3 = both. Default=0" ); -#define MLX5_DEFAULT_PROF 2static unsigned int prof_sel =MLX5_DEFAULT_PROF ;module_param_named (prof_sel, prof_sel, uint,0444 );MODULE_PARM_DESC (prof_sel,"profile selector. Valid range 0 - 2" );
@@ -1303,7 +1302,7 @@ void mlx5_unload_one(struct mlx5_core_dev *dev, bool cleanup)mutex_unlock (&dev->intf_state_mutex); } -static int mlx5_mdev_init (struct mlx5_core_dev *dev,int profile_idx) +int mlx5_mdev_init (struct mlx5_core_dev *dev,int profile_idx) {struct mlx5_priv *priv = &dev->priv;int err;
@@ -1353,7 +1352,7 @@ static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)return err; } -static void mlx5_mdev_uninit (struct mlx5_core_dev *dev) +void mlx5_mdev_uninit (struct mlx5_core_dev *dev) {struct mlx5_priv *priv = &dev->priv;
@@ -1693,6 +1692,10 @@ static int __init init(void)if (err) goto err_debug; + err =mlx5_sf_driver_register (); +if (err) + goto err_sf; +#ifdef CONFIG_MLX5_CORE_EN err =mlx5e_init ();if (err) {
@@ -1703,6 +1706,8 @@ static int __init init(void)return 0 ; +err_sf: +pci_unregister_driver (&mlx5_core_driver); err_debug:mlx5_unregister_debugfs ();return err;
@@ -1713,6 +1718,7 @@ static void __exit cleanup(void)#ifdef CONFIG_MLX5_CORE_EN mlx5e_cleanup ();#endif +mlx5_sf_driver_unregister ();pci_unregister_driver (&mlx5_core_driver);mlx5_unregister_debugfs (); }
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +10 -0
@@ -117,6 +117,8 @@ enum mlx5_semaphore_space_address { MLX5_SEMAPHORE_SW_RESET = 0x20, }; +#define MLX5_DEFAULT_PROF 2 +int mlx5_query_hca_caps (struct mlx5_core_dev *dev);int mlx5_query_board_id (struct mlx5_core_dev *dev);int mlx5_cmd_init (struct mlx5_core_dev *dev);
@@ -176,6 +178,7 @@ struct cpumask * mlx5_irq_get_affinity_mask(struct mlx5_irq_table *irq_table, int vecidx);struct cpu_rmap *mlx5_irq_get_rmap (struct mlx5_irq_table *table);int mlx5_irq_get_num_comp (struct mlx5_irq_table *table); +struct mlx5_irq_table *mlx5_irq_table_get (struct mlx5_core_dev *dev);int mlx5_events_init (struct mlx5_core_dev *dev);void mlx5_events_cleanup (struct mlx5_core_dev *dev);
@@ -257,6 +260,13 @@ enum {u8 mlx5_get_nic_state (struct mlx5_core_dev *dev);void mlx5_set_nic_state (struct mlx5_core_dev *dev,u8 state); +static inline bool mlx5_core_is_sf (const struct mlx5_core_dev *dev) +{ +return dev->coredev_type ==MLX5_COREDEV_SF ; +} + +int mlx5_mdev_init (struct mlx5_core_dev *dev,int profile_idx); +void mlx5_mdev_uninit (struct mlx5_core_dev *dev);void mlx5_unload_one (struct mlx5_core_dev *dev,bool cleanup);int mlx5_load_one (struct mlx5_core_dev *dev,bool boot);
drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c +20 -0
@@ -30,6 +30,9 @@ int mlx5_irq_table_init(struct mlx5_core_dev *dev) {struct mlx5_irq_table *irq_table; +if (mlx5_core_is_sf (dev)) +return 0 ; + irq_table =kvzalloc (sizeof (*irq_table),GFP_KERNEL );if (!irq_table)return -ENOMEM ;
@@ -40,6 +43,9 @@ int mlx5_irq_table_init(struct mlx5_core_dev *dev)void mlx5_irq_table_cleanup (struct mlx5_core_dev *dev) { +if (mlx5_core_is_sf (dev)) +return ; +kvfree (dev->priv.irq_table); }
@@ -268,6 +274,9 @@ int mlx5_irq_table_create(struct mlx5_core_dev *dev)int nvec;int err; +if (mlx5_core_is_sf (dev)) +return 0 ; + nvec =MLX5_CAP_GEN (dev, num_ports) *num_online_cpus () +MLX5_IRQ_VEC_COMP_BASE ; nvec =min_t (int, nvec, num_eqs);
@@ -319,6 +328,9 @@ void mlx5_irq_table_destroy(struct mlx5_core_dev *dev)struct mlx5_irq_table *table = dev->priv.irq_table;int i; +if (mlx5_core_is_sf (dev)) +return ; +/* free_irq requires that affinity and rmap will be cleared * before calling it. This is why there is asymmetry with set_rmap * which should be called after alloc_irq but before request_irq.
@@ -332,3 +344,11 @@ void mlx5_irq_table_destroy(struct mlx5_core_dev *dev)kfree (table->irq); } +struct mlx5_irq_table *mlx5_irq_table_get (struct mlx5_core_dev *dev) +{ +#ifdef CONFIG_MLX5_SF +if (mlx5_core_is_sf (dev)) +return dev->priv.parent_mdev->priv.irq_table; +#endif +return dev->priv.irq_table; +}
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c +10 -0
@@ -24,6 +24,16 @@ static bool mlx5_sf_dev_supported(const struct mlx5_core_dev *dev)return MLX5_CAP_GEN (dev, sf) &&mlx5_vhca_event_supported (dev); } +bool mlx5_sf_dev_allocated (const struct mlx5_core_dev *dev) +{ +struct mlx5_sf_dev_table *table = dev->priv.sf_dev_table; + +if (!mlx5_sf_dev_supported (dev)) +return false; + +return xa_empty (&table->devices); +} +static ssize_t sfnum_show (struct device *dev,struct device_attribute *attr,char *buf) { struct auxiliary_device *adev = container_of(dev, struct auxiliary_device, dev);
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.h +20 -0
@@ -13,6 +13,7 @@struct mlx5_sf_dev {struct auxiliary_device adev;struct mlx5_core_dev *parent_mdev; +struct mlx5_core_dev *mdev;phys_addr_t bar_base_addr;u32 sfnum; };
@@ -20,6 +21,11 @@ struct mlx5_sf_dev {void mlx5_sf_dev_table_create (struct mlx5_core_dev *dev);void mlx5_sf_dev_table_destroy (struct mlx5_core_dev *dev); +int mlx5_sf_driver_register (void ); +void mlx5_sf_driver_unregister (void ); + +bool mlx5_sf_dev_allocated (const struct mlx5_core_dev *dev); +#else static inline void mlx5_sf_dev_table_create (struct mlx5_core_dev *dev)
@@ -30,6 +36,20 @@ static inline void mlx5_sf_dev_table_destroy(struct mlx5_core_dev *dev) { } +static inline int mlx5_sf_driver_register (void ) +{ +return 0 ; +} + +static inline void mlx5_sf_driver_unregister (void ) +{ +} + +static inline bool mlx5_sf_dev_allocated (const struct mlx5_core_dev *dev) +{ +return 0 ; +} +#endif #endif
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c new file +101 -0
101 lines not on this page · raw message
include/linux/mlx5/driver.h +3 -1
@@ -193,7 +193,8 @@ enum port_state_policy {enum mlx5_coredev_type {MLX5_COREDEV_PF , -MLX5_COREDEV_VF +MLX5_COREDEV_VF , +MLX5_COREDEV_SF , };struct mlx5_field_desc {
@@ -608,6 +609,7 @@ struct mlx5_priv {#ifdef CONFIG_MLX5_SF struct mlx5_vhca_state_notifier *vhca_state_notifier;struct mlx5_sf_dev_table *sf_dev_table; +struct mlx5_core_dev *parent_mdev;#endif };
Signature · 1 line
2.26.2
PATCH v5 2/15 devlink: Prepare code to fill multiple port function attributes
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
Prepare code to fill zero or more port function optional attributes. Subsequent patch makes use of this to fill more port function attributes.
--- net/core/devlink.c | 63 +++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 31 deletions(-)
net/core/devlink.c +32 -31
@@ -712,6 +712,31 @@ static int devlink_nl_port_attrs_put(struct sk_buff *msg,return 0 ; } +static int +devlink_port_function_hw_addr_fill (struct devlink *devlink,const struct devlink_ops *ops, +struct devlink_port *port,struct sk_buff *msg, +struct netlink_ext_ack *extack,bool *msg_updated) +{ +u8 hw_addr[MAX_ADDR_LEN ]; +int hw_addr_len; +int err; + +if (!ops->port_function_hw_addr_get) +return 0 ; + + err = ops->port_function_hw_addr_get (devlink, port, hw_addr, &hw_addr_len, extack); +if (err) { +if (err == -EOPNOTSUPP ) +return 0 ; +return err; + } + err =nla_put (msg,DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR , hw_addr_len, hw_addr); +if (err) +return err; + *msg_updated = true; +return 0 ; +} +static int devlink_nl_port_function_attrs_put (struct sk_buff *msg,struct devlink_port *port,struct netlink_ext_ack *extack)
@@ -719,36 +744,16 @@ devlink_nl_port_function_attrs_put(struct sk_buff *msg, struct devlink_port *porstruct devlink *devlink = port->devlink;const struct devlink_ops *ops;struct nlattr *function_attr; -bool empty_nest = true; -int err =0 ; +bool msg_updated = false; +int err; function_attr =nla_nest_start_noflag (msg,DEVLINK_ATTR_PORT_FUNCTION );if (!function_attr)return -EMSGSIZE ; ops = devlink->ops; -if (ops->port_function_hw_addr_get) { -int hw_addr_len; -u8 hw_addr[MAX_ADDR_LEN ]; - - err = ops->port_function_hw_addr_get (devlink, port, hw_addr, &hw_addr_len, extack); -if (err == -EOPNOTSUPP ) { -/* Port function attributes are optional for a port. If port doesn't -* support function attribute, returning -EOPNOTSUPP is not an error. -*/ - err =0 ; - goto out; - }else if (err) { - goto out; - } - err =nla_put (msg,DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR , hw_addr_len, hw_addr); -if (err) - goto out; - empty_nest = false; - } - -out: -if (err || empty_nest) + err =devlink_port_function_hw_addr_fill (devlink, ops, port, msg, extack, &msg_updated); +if (err || !msg_updated)nla_nest_cancel (msg, function_attr);else nla_nest_end (msg, function_attr);
@@ -986,7 +991,6 @@ devlink_port_function_hw_addr_set(struct devlink *devlink, struct devlink_port *const struct devlink_ops *ops;const u8 *hw_addr;int hw_addr_len; -int err; hw_addr =nla_data (attr); hw_addr_len =nla_len (attr);
@@ -1011,12 +1015,7 @@ devlink_port_function_hw_addr_set(struct devlink *devlink, struct devlink_port *return -EOPNOTSUPP ; } - err = ops->port_function_hw_addr_set (devlink, port, hw_addr, hw_addr_len, extack); -if (err) -return err; - -devlink_port_notify (port,DEVLINK_CMD_PORT_NEW ); -return 0 ; +return ops->port_function_hw_addr_set (devlink, port, hw_addr, hw_addr_len, extack); } static int
@@ -1037,6 +1036,8 @@ devlink_port_function_set(struct devlink *devlink, struct devlink_port *port,if (attr) err =devlink_port_function_hw_addr_set (devlink, port, attr, extack); +if (!err) +devlink_port_notify (port,DEVLINK_CMD_PORT_NEW );return err; }
Signature · 1 line
2.26.2
Jakub Kicinski
maintainerRe: [net-next v5 03/15] devlink: Introduce PCI SF port flavour and port attribute
In reply to Saeed MahameedQuoted 15 lines · On Tue, 15 Dec 2020 01:03:46 -0800 Saeed Mahameed wrote:
+ *
devlink_port_attrs_pci_sf_set- Set PCI SF port attributes
+ *
+ * @devlink_port: devlink port
+ * @controller: associated controller number for the devlink port instance
+ * @pf: associated PF for the devlink port instance
+ * @sf: associated SF of a PF for the devlink port instance
+ * @external: indicates if the port is for an external controller
+ */net/core/devlink.c +7
-0+void devlink_port_attrs_pci_sf_set (struct devlink_port *devlink_port,u32 controller, +u16 pf,u32 sf,bool external) +{ +struct devlink_port_attrs *attrs = &devlink_port->attrs; +int ret; + +if (WARN_ON (devlink_port->registered))
net/core/devlink.c void devlink_port_attrs_pci_vf_set(struct devlink_port *devlink_port, u32 contro · line 8410
Quoted 10 lines
net/core/devlink.c +10
-0+return ; + ret =__devlink_port_attrs_set (devlink_port,DEVLINK_PORT_FLAVOUR_PCI_SF ); +if (ret) +return ; + attrs->pci_sf.controller = controller; + attrs->pci_sf.pf = pf; + attrs->pci_sf.sf = sf; + attrs->pci_sf.external = external; +} +EXPORT_SYMBOL_GPL (devlink_port_attrs_pci_sf_set);
So subfunctions don't have a VF id but they may have a controller?
Can you tell us more about the use cases and deployment models you're intending to support? Let's not add attributes and info which will go unused.
How are SFs supposed to be used with SmartNICs? Are you assuming single domain of control? It seems that the way the industry is moving the major use case for SmartNICs is bare metal.
I always assumed nested eswitches when thinking about SmartNICs, what are you intending to do?
What are your plans for enabling this feature in user space project?
Jakub Kicinski
maintainerRe: [net-next v5 04/15] devlink: Support add and delete devlink port
In reply to Saeed MahameedQuoted 47 lines · On Tue, 15 Dec 2020 01:03:47 -0800 Saeed Mahameed wrote:
From: Parav Pandit <[email protected]>
Extended devlink interface for the user to add and delete port. Extend devlink to connect user requests to driver to add/delete such port in the device.
When driver routines are invoked, devlink instance lock is not held. This enables driver to perform several devlink objects registration, unregistration such as (port, health reporter, resource etc) by using existing devlink APIs.
This also helps to uniformly use the code for port unregistration during driver unload and during port deletion initiated by user.Examples of add, show and delete commands:
$ devlink dev eswitch set pci/0000:06:00.0 mode switchdev$ devlink port show pci/0000:06:00.0/65535: type eth netdev ens2f0np0 flavour physical port 0 splittable false$ devlink port add pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum 88$ devlink port show pci/0000:06:00.0/32768 pci/0000:06:00.0/32768: type eth netdev eth0 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false function: hw_addr 00:00:00:00:88:88 state inactive opstate detached$ udevadm test-builtin net_id /sys/class/net/eth0 Load module index Parsed configuration file /usr/lib/systemd/network/99-default.link Created link configuration context. Using default interface naming scheme 'v245'. ID_NET_NAMING_SCHEME=v245 ID_NET_NAME_PATH=enp6s0f0npf0sf88 ID_NET_NAME_SLOT=ens2f0npf0sf88 Unload module index Unloaded link configuration context.Signed-off-by Parav Pandit <[email protected]>Reviewed-by Jiri Pirko <[email protected]>Reviewed-by Vu Pham <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>include/net/devlink.h +0
-0
include/net/devlink.h struct devlink_port { · line 161
Quoted 9 lines
include/net/devlink.h +6
-0@@ -153,6 +153,17 @@ struct devlink_port {struct mutex reporters_lock;/* Protects reporter_list */ }; +struct devlink_port_new_attrs { +enum devlink_port_flavour flavour; +unsigned int port_index; +u32 controller; +u32 sfnum; +u16 pfnum;
Oh. So you had the structure which actually gets stored in memory for the lifetime of the device in patch 3 mispacked (u32 / u16 / u32 / u8). But this one with arguments is packed. Please be consistent.
Quoted 9 lines
include/net/devlink.h +5
-0+ u8 port_index_valid:1, + controller_valid:1, + sfnum_valid:1; +}; +struct devlink_sb_pool_info {enum devlink_sb_pool_type pool_type;u32 size;
include/net/devlink.h struct devlink_ops { · line 1381
Quoted 8 lines
include/net/devlink.h +5
-0@@ -1363,6 +1374,34 @@ struct devlink_ops {int (*port_function_hw_addr_set)(struct devlink *devlink,struct devlink_port *port,const u8 *hw_addr,int hw_addr_len,struct netlink_ext_ack *extack); +/** +* @port_new: Port add function. +* +* Should be used by device driver to let caller add new port of a +* specified flavour with optional attributes.
Add a new port of a specified flavor with optional attributes.
include/net/devlink.h struct devlink_ops { · line 1382
Quoted 1 line
include/net/devlink.h +1
-0+* Driver should return -EOPNOTSUPP if it doesn't support port addition
s/should/must/
include/net/devlink.h struct devlink_ops { · line 1384
Quoted 2 lines
include/net/devlink.h +2
-0+* of a specified flavour or specified attributes. Driver should set +* extack error message in case of fail to add the port. Devlink core
s/fail to add the port/failure/
include/net/devlink.h struct devlink_ops { · line 1385
Quoted 1 line
include/net/devlink.h +1
-0+* does not hold a devlink instance lock when this callback is invoked.
Called without holding the devlink instance lock.
include/net/devlink.h struct devlink_ops { · line 1386
Quoted 1 line
include/net/devlink.h +1
-0+* Driver must ensures synchronization when adding or deleting a port.
s/ensures/ensure/ but really that's pretty obvious from the previous sentence.
include/net/devlink.h struct devlink_ops { · line 1387
Quoted 1 line
include/net/devlink.h +1
-0+* Driver must register a port with devlink core.
s/must/is expected to/
Please make sure your comments and documentation are proof read by someone.
Quoted 11 lines
include/net/devlink.h +11
-0+static int devlink_nl_cmd_port_new_doit (struct sk_buff *skb, +struct genl_info *info) +{ +struct netlink_ext_ack *extack = info->extack; +struct devlink_port_new_attrs new_attrs = {}; +struct devlink *devlink = info->user_ptr[0 ]; + +if (!info->attrs[DEVLINK_ATTR_PORT_FLAVOUR ] || + !info->attrs[DEVLINK_ATTR_PORT_PCI_PF_NUMBER ]) { +NL_SET_ERR_MSG_MOD (extack,"Port flavour or PCI PF are not specified" ); +return -EINVAL ;
include/net/devlink.h struct devlink_ops {
Quoted 10 lines
include/net/devlink.h +10
-0+ } + new_attrs.flavour =nla_get_u16 (info->attrs[DEVLINK_ATTR_PORT_FLAVOUR ]); + new_attrs.pfnum = +nla_get_u16 (info->attrs[DEVLINK_ATTR_PORT_PCI_PF_NUMBER ]); + +if (info->attrs[DEVLINK_ATTR_PORT_INDEX ]) { + new_attrs.port_index = +nla_get_u32 (info->attrs[DEVLINK_ATTR_PORT_INDEX ]); + new_attrs.port_index_valid = true; + }
This is the desired port index of the new port?
Or the index of the parent port?
Let's make it abundantly clear since its a pass-thru argument for the driver to interpret.
include/net/devlink.h
Quoted 12 lines
include/net/devlink.h +12
-0+if (info->attrs[DEVLINK_ATTR_PORT_CONTROLLER_NUMBER ]) { + new_attrs.controller = +nla_get_u16 (info->attrs[DEVLINK_ATTR_PORT_CONTROLLER_NUMBER ]); + new_attrs.controller_valid = true; + } +if (info->attrs[DEVLINK_ATTR_PORT_PCI_SF_NUMBER ]) { + new_attrs.sfnum =nla_get_u32 (info->attrs[DEVLINK_ATTR_PORT_PCI_SF_NUMBER ]); + new_attrs.sfnum_valid = true; + } + +if (!devlink->ops->port_new) +return -EOPNOTSUPP ;
Why is this check not at the beginning of the function? Also should there be an extack on it?
include/net/devlink.h
Quoted 1 line
include/net/devlink.h +1
-0+return devlink->ops->port_new (devlink, &new_attrs, extack);
This should return the identifier of the created port back to user space.
Jakub Kicinski
maintainerRe: [net-next v5 05/15] devlink: Support get and set state of port function
In reply to Saeed MahameedQuoted 8 lines · On Tue, 15 Dec 2020 01:03:48 -0800 Saeed Mahameed wrote:
From: Parav Pandit <[email protected]>
devlink port function can be in active or inactive state. Allow users to get and set port function's state.
When the port function it activated, its operational state may change after a while when the device is created and driver binds to it. Similarly on deactivation flow.
So what's the flow device should implement?
User requests deactivated, the device sends a notification to the driver bound to the device. What if the driver ignores it?
Quoted 12 lines
To clearly describe the state of the port function and its device's operational state in the host system, define state and opstate attributes.
Example of a PCI SF port which supports a port function:
Create a device with ID=10 and one physical port.$ devlink dev eswitch set pci/0000:06:00.0 mode switchdev$ devlink port show pci/0000:06:00.0/65535: type eth netdev ens2f0np0 flavour physical port 0 splittable false
Quoted 8 lines
$ devlink port add pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum 88$ devlink port show pci/0000:06:00.0/32768 pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false function: hw_addr 00:00:00:00:88:88 state inactive opstate detached$ devlink port function set pci/0000:06:00.0/32768 hw_addr 00:00:00:00:88:88 state active
Is request to deactivate done by settings state to inactive?
Quoted 21 lines
$ devlink port show pci/0000:06:00.0/32768 -jp
{
"port": {
"pci/0000:06:00.0/32768": {
"type": "eth",
"netdev": "ens2f0npf0sf88",
"flavour": "pcisf",
"controller": 0,
"pfnum": 0,
"sfnum": 88,
"external": false,
"splittable": false,
"function": {
"hw_addr": "00:00:00:00:88:88",
"state": "active",
"opstate": "attached"
}
}
}
}Quoted 7 lines
Signed-off-by Parav Pandit <[email protected]>Reviewed-by Jiri Pirko <[email protected]>Reviewed-by Vu Pham <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>+ * enum
devlink_port_function_opstate- indicates operational state of port function
+ * @DEVLINK_PORT_FUNCTION_OPSTATE_ATTACHED: Driver is attached to the function of port,
This name definitely needs to be shortened.
Quoted 1 line
+ * gracefufl tear down of the function, after
gracefufl
Quoted 2 lines
+ * inactivation of the port function, user should wait
+ * for operational state to turn DETACHED.
Why do you indent the comment by 40 characters and then go over 80 chars?
include/uapi/linux/devlink.h enum devlink_resource_unit { · line 608
Quoted 5 lines
+ * @DEVLINK_PORT_FUNCTION_OPSTATE_DETACHED: Driver is detached from the function of port; it is
+ * safe to delete the port.
+ */include/uapi/linux/devlink.h +2
-0+enum devlink_port_function_opstate { +DEVLINK_PORT_FUNCTION_OPSTATE_DETACHED ,
The port function must be some Mellanox speak - for the second time - I have no idea what it means. Please use meaningful names.
Quoted 77 lines
include/uapi/linux/devlink.h +3
-0+ DEVLINK_PORT_FUNCTION_OPSTATE_ATTACHED, +}; +#endif /* _UAPI_LINUX_DEVLINK_H_ */ net/core/devlink.c +54
-0@@ -87,6 +87,9 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(devlink_trap_report);static const struct nla_policy devlink_function_nl_policy[DEVLINK_PORT_FUNCTION_ATTR_MAX +1 ] = { [DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR ] = { .type =NLA_BINARY }, + [DEVLINK_PORT_FUNCTION_ATTR_STATE ] = +NLA_POLICY_RANGE (NLA_U8 ,DEVLINK_PORT_FUNCTION_STATE_INACTIVE , +DEVLINK_PORT_FUNCTION_STATE_ACTIVE ), };static LIST_HEAD (devlink_list);@@ -746,6 +749,57 @@ devlink_port_function_hw_addr_fill(struct devlink *devlink, const struct devlinkreturn 0 ; } +static bool +devlink_port_function_state_valid (enum devlink_port_function_state state) +{ +return state ==DEVLINK_PORT_FUNCTION_STATE_INACTIVE || + state ==DEVLINK_PORT_FUNCTION_STATE_ACTIVE ; +} + +static bool +devlink_port_function_opstate_valid (enum devlink_port_function_opstate state) +{ +return state ==DEVLINK_PORT_FUNCTION_OPSTATE_DETACHED || + state ==DEVLINK_PORT_FUNCTION_OPSTATE_ATTACHED ; +} + +static int +devlink_port_function_state_fill (struct devlink *devlink, +const struct devlink_ops *ops, +struct devlink_port *port,struct sk_buff *msg, +struct netlink_ext_ack *extack, +bool *msg_updated) +{ +enum devlink_port_function_opstate opstate; +enum devlink_port_function_state state; +int err; + +if (!ops->port_function_state_get) +return 0 ; + + err = ops->port_function_state_get (devlink, port, &state, &opstate, extack); +if (err) { +if (err == -EOPNOTSUPP ) +return 0 ; +return err; + } +if (!devlink_port_function_state_valid (state)) { +WARN_ON_ONCE (1 ); +NL_SET_ERR_MSG_MOD (extack,"Invalid state value read from driver" ); +return -EINVAL ; + } +if (!devlink_port_function_opstate_valid (opstate)) { +WARN_ON_ONCE (1 ); +NL_SET_ERR_MSG_MOD (extack,"Invalid operational state value read from driver" ); +return -EINVAL ; + } +if (nla_put_u8 (msg,DEVLINK_PORT_FUNCTION_ATTR_STATE , state) || +nla_put_u8 (msg,DEVLINK_PORT_FUNCTION_ATTR_OPSTATE , opstate)) +return -EMSGSIZE ; + *msg_updated = true; +return 0 ; +} +static int devlink_nl_port_function_attrs_put (struct sk_buff *msg,struct devlink_port *port,struct netlink_ext_ack *extack)
net/core/devlink.c devlink_nl_port_function_attrs_put(struct sk_buff *msg, struct devlink_port *por · line 818
Quoted 3 lines
net/core/devlink.c +0
-0@@ -762,6 +816,13 @@ devlink_nl_port_function_attrs_put(struct sk_buff *msg, struct devlink_port *por ops = devlink->ops; err =devlink_port_function_hw_addr_fill (devlink, ops, port, msg, extack, &msg_updated);
Wrap your code, please.
Quoted 10 lines
net/core/devlink.c +7
-0+if (err) + goto out; + err =devlink_port_function_state_fill (devlink, ops, port, msg, extack, + &msg_updated); +if (err) + goto out; +out:if (err || !msg_updated)nla_nest_cancel (msg, function_attr);else
Jakub Kicinski
maintainerRe: [net-next v5 07/15] net/mlx5: SF, Add auxiliary device support
In reply to Saeed MahameedQuoted 12 lines · On Tue, 15 Dec 2020 01:03:50 -0800 Saeed Mahameed wrote:
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c new file +12
-0+static ssize_t sfnum_show (struct device *dev,struct device_attribute *attr,char *buf) +{ + struct auxiliary_device *adev = container_of(dev, struct auxiliary_device, dev); + struct mlx5_sf_dev *sf_dev = container_of(adev, struct mlx5_sf_dev, adev); + +return scnprintf (buf,PAGE_SIZE ,"%u\n" , sf_dev->sfnum); +} +static DEVICE_ATTR_RO (sfnum); + +static struct attribute *sf_device_attrs[] = { + &dev_attr_sfnum.attr, +NULL ,
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c line 48
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c new file +10
-0+}; + +static const struct attribute_group sf_attr_group = { + .attrs = sf_device_attrs, +}; + +static const struct attribute_group *sf_attr_groups[2 ] = { + &sf_attr_group, +NULL +};
Why the sysfs attribute? Devlink should be able to report device name so there's no need for a tie in from the other end.
Jakub Kicinski
maintainerRe: [net-next v5 09/15] net/mlx5: E-switch, Prepare eswitch to handle SF vport
In reply to Saeed MahameedQuoted 27 lines · On Tue, 15 Dec 2020 01:03:52 -0800 Saeed Mahameed wrote:
From: Vu Pham <[email protected]>
Prepare eswitch to handle SF vport during
(a) querying eswitch functions
(b) egress ACL creation
(c) account for SF vports in total vports calculationAssign a dedicated placeholder for SFs vports and their representors. They are placed after VFs vports and before ECPF vports as below:
[PF,VF0,...,VFn,SF0,...SFm,ECPF,UPLINK].Change functions to map SF's vport numbers to indices when accessing the vports or representors arrays, and vice versa.
Signed-off-by Vu Pham <[email protected]>Signed-off-by Parav Pandit <[email protected]>Reviewed-by Roi Dayan <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>drivers/net/ethernet/mellanox/mlx5/core/Kconfig +0
-0@@ -212,3 +212,13 @@ config MLX5_SF Build support for subfuction device in the NIC. A Mellanox subfunction device can support RDMA, netdevice and vdpa device. It is similar to a SRIOV VF but it doesn't require SRIOV support.
drivers/net/ethernet/mellanox/mlx5/core/Kconfig config MLX5_SF · line 224
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/Kconfig +10
-0+ +config MLX5_SF_MANAGER + bool + depends on MLX5_SF && MLX5_ESWITCH + default y + help + Build support for subfuction port in the NIC. A Mellanox subfunction + port is managed through devlink. A subfunction supports RDMA, netdevice + and vdpa device. It is similar to a SRIOV VF but it doesn't require + SRIOV support.
Why is this a separate knob?
And it's not used anywhere AFAICS.
Jakub Kicinski
maintainerRe: [net-next v5 11/15] net/mlx5: SF, Add port add delete functionality
In reply to Saeed MahameedQuoted 3 lines · On Tue, 15 Dec 2020 01:03:54 -0800 Saeed Mahameed wrote:
To handle SF port management outside of the eswitch as independent software layer, introduce eswitch notifier APIs so that upper layer who wish to support sf port management in switchdev mode can perform its
Could you unpack this? What's the "upper layer" software in this context?
Quoted 2 lines
task whenever eswitch mode is set to switchdev or before eswitch is disabled.
How does SF work if eswich is disabled?
Quoted 5 lines
Initialize sf port table on such eswitch event.
Add SF port add and delete functionality in switchdev mode. Destroy all SF ports when eswitch is disabled. Expose SF port add and delete to user via devlink commands.
Jakub Kicinski
maintainerRe: [net-next v5 13/15] devlink: Add devlink port documentation
In reply to Saeed MahameedDocumentation/networking/devlink/devlink-port.rst
Quoted 5 lines · On Tue, 15 Dec 2020 01:03:56 -0800 Saeed Mahameed wrote:
Documentation/networking/devlink/devlink-port.rst new file +5
-0+PCI controllers +--------------- +In most cases a PCI device has only one controller. A controller consists of +potentially multiple physical and virtual functions. Such PCI function consists +of one or more ports.
s/Such//
you say consists in two consecutive sentences.
Quoted 1 line
This port of the function is represented by the devlink eswitch port.
"This port of the function"? Why not just "Each port"?
Quoted 1 line
+A PCI Device connected to multiple CPUs or multiple PCI root complexes or
Why is device capitalized all of the sudden?
Quoted 1 line
+SmartNIC, however, may have multiple controllers. For a device with multiple
a SmartNIC or SmartNICs
Documentation/networking/devlink/devlink-port.rst line 67
Quoted 2 lines
Documentation/networking/devlink/devlink-port.rst new file +2
-0+controllers, each controller is distinguished by a unique controller number. +An eswitch on the PCI device support ports of multiple controllers.
eswitch is on a PCI device?
Quoted 32 lines
Documentation/networking/devlink/devlink-port.rst new file +32
-0+An example view of a system with two controllers:: + + --------------------------------------------------------- + | | + | --------- --------- ------- ------- | + ----------- | | vf(s) | | sf(s) | |vf(s)| |sf(s)| | + | server | | ------- ----/---- ---/----- ------- ---/--- ---/--- | + | pci rc |=== | pf0 |______/________/ | pf1 |___/_______/ | + | connect | | ------- ------- | + ----------- | | controller_num=1 (no eswitch) | + ------|-------------------------------------------------- + (internal wire) + | + --------------------------------------------------------- + | devlink eswitch ports and reps | + | ----------------------------------------------------- | + | |ctrl-0 | ctrl-0 | ctrl-0 | ctrl-0 | ctrl-0 |ctrl-0 | | + | |pf0 | pf0vfN | pf0sfN | pf1 | pf1vfN |pf1sfN | | + | ----------------------------------------------------- | + | |ctrl-1 | ctrl-1 | ctrl-1 | ctrl-1 | ctrl-1 |ctrl-1 | | + | |pf0 | pf0vfN | pf0sfN | pf1 | pf1vfN |pf1sfN | | + | ----------------------------------------------------- | + | | + | | + ----------- | --------- --------- ------- ------- | + | smartNIC| | | vf(s) | | sf(s) | |vf(s)| |sf(s)| | + | pci rc |==| ------- ----/---- ---/----- ------- ---/--- ---/--- | + | connect | | | pf0 |______/________/ | pf1 |___/_______/ | + ----------- | ------- ------- | + | | + | local controller_num=0 (eswitch) | + ---------------------------------------------------------
Documentation/networking/devlink/devlink-port.rst line 110
Quoted 10 lines
Documentation/networking/devlink/devlink-port.rst new file +10
-0+ +In above example, external controller (identified by controller number = 1) +doesn't have eswitch. Local controller (identified by controller number = 0) +has the eswitch. Devlink instance on local controller has eswitch devlink +ports representing ports for both the controllers. + +Port function configuration +=========================== + +A user can configure the port function attribute before enumerating the
s/A user/User/
/port function attribute/$something_meaningful/
Quoted 1 line
+PCI function. Usually it means, user should configure port function attribute
attributes, plural
Quoted 7 lines
Documentation/networking/devlink/devlink-port.rst new file +7
-0+before a bus specific device for the function is created. However, when +SRIOV is enabled, virtual function devices are created on the PCI bus. +Hence, function attribute should be configured before binding virtual +function device to the driver. + +User may set the hardware address of the function represented by the devlink +port function. For Ethernet port function this means a MAC address.
Jakub Kicinski
maintainerRe: [net-next v5 14/15] devlink: Extend devlink port documentation for subfunctions
In reply to Saeed MahameedQuoted 63 lines · On Tue, 15 Dec 2020 01:03:57 -0800 Saeed Mahameed wrote:
Documentation/networking/devlink/devlink-port.rst +63
-0+Subfunctions are lightweight functions that has parent PCI function on which +it is deployed. Subfunctions are created and deployed in unit of 1. Unlike +SRIOV VFs, they don't require their own PCI virtual function. They communicate +with the hardware through the parent PCI function. Subfunctions can possibly +scale better. + +To use a subfunction, 3 steps setup sequence is followed. +(1) create - create a subfunction; +(2) configure - configure subfunction attributes; +(3) deploy - deploy the subfunction; + +Subfunction management is done using devlink port user interface. +User performs setup on the subfunction management device. + +(1) Create +---------- +A subfunction is created using a devlink port interface. User adds the +subfunction by adding a devlink port of subfunction flavour. The devlink +kernel code calls down to subfunction management driver (devlink op) and asks +it to create a subfunction devlink port. Driver then instantiates the +subfunction port and any associated objects such as health reporters and +representor netdevice. + +(2) Configure +------------- +Subfunction devlink port is created but it is not active yet. That means the +entities are created on devlink side, the e-switch port representor is created, +but the subfunction device itself it not created. User might use e-switch port +representor to do settings, putting it into bridge, adding TC rules, etc. User +might as well configure the hardware address (such as MAC address) of the +subfunction while subfunction is inactive. + +(3) Deploy +---------- +Once subfunction is configured, user must activate it to use it. Upon +activation, subfunction management driver asks the subfunction management +device to instantiate the actual subfunction device on particular PCI function. +A subfunction device is created on the :ref:`Documentation/driver-api/auxiliary_bus.rst <auxiliary_bus>`. At this point matching +subfunction driver binds to the subfunction's auxiliary device. + +Terms and Definitions +===================== + +.. list-table:: Terms and Definitions + :widths: 22 90 + + * - Term + - Definitions + * - ``PCI device`` + - A physical PCI device having one or more PCI bus consists of one or + more PCI controllers. + * - ``PCI controller`` + - A controller consists of potentially multiple physical functions, + virtual functions and subfunctions. + * - ``Port function`` + - An object to manage the function of a port. + * - ``Subfunction`` + - A lightweight function that has parent PCI function on which it is + deployed. + * - ``Subfunction device`` + - A bus device of the subfunction, usually on a auxiliary bus. + * - ``Subfunction driver`` + - A device driver for the subfunction auxiliary device.
Documentation/networking/devlink/devlink-port.rst PCI function. Usually it means, user should configure port function attribute · line 199
Quoted 10 lines
Documentation/networking/devlink/devlink-port.rst +10
-0+ * - ``Subfunction management device`` + - A PCI physical function that supports subfunction management. + * - ``Subfunction management driver`` + - A device driver for PCI physical function that supports + subfunction management using devlink port interface. + * - ``Subfunction host driver`` + - A device driver for PCI physical function that host subfunction + devices. In most cases it is same as subfunction management driver. When + subfunction is used on external controller, subfunction management and + host drivers are different.
Would be great if someone from Mellanox could proof read this before we spend cycles on correcting spelling in public review.
RE: [net-next v5 03/15] devlink: Introduce PCI SF port flavour and port attribute
In reply to Jakub KicinskiQuoted 25 lines
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, December 16, 2020 4:58 AMQuoted 4 lines · On Tue, 15 Dec 2020 01:03:46 -0800 Saeed Mahameed wrote:
+ *
devlink_port_attrs_pci_sf_set- Set PCI SF port attributes
+ *
+ * @devlink_port: devlink port
+ * @controller: associated controller number for the devlink portinstance
Quoted 5 lines
+ * @pf: associated PF for the devlink port instance
+ * @sf: associated SF of a PF for the devlink port instance
+ * @external: indicates if the port is for an external controller
+ */
+void devlink_port_attrs_pci_sf_set(structdevlink_port*devlink_port, u32controller,
net/core/devlink.c void devlink_port_attrs_pci_vf_set(struct devlink_port *devlink_port, u32 contro
Quoted 7 lines
net/core/devlink.c +7
-0+ u16 pf, u32 sf, bool external) { + struct devlink_port_attrs *attrs = &devlink_port->attrs; +int ret; + +if (WARN_ON (devlink_port->registered)) +return ; + ret = __devlink_port_attrs_set(devlink_port,
DEVLINK_PORT_FLAVOUR_PCI_SF);
Quoted 11 lines
net/core/devlink.c void devlink_port_attrs_pci_vf_set(struct devlink_port *devlink_port, u32 contro · line 8410
Quoted 8 lines
net/core/devlink.c +8
-0+if (ret) +return ; + attrs->pci_sf.controller = controller; + attrs->pci_sf.pf = pf; + attrs->pci_sf.sf = sf; + attrs->pci_sf.external = external; +} +EXPORT_SYMBOL_GPL (devlink_port_attrs_pci_sf_set);So subfunctions don't have a VF id but they may have a controller?
Right. SF can be on external controller.
Quoted 3 lines
Can you tell us more about the use cases and deployment models you're intending to support? Let's not add attributes and info which will go unused.
External will be used the same way how it is used for PF and VF.
Quoted 2 lines
How are SFs supposed to be used with SmartNICs? Are you assuming single domain of control?
No. it is not assumed. SF can be deployed from smartnic to external host.
A user has to pass appropriate controller number, pf number attributes during creation time.
Quoted 6 lines
It seems that the way the industry is moving the major use case for SmartNICs is bare metal.
I always assumed nested eswitches when thinking about SmartNICs, what are you intending to do?
Mlx5 doesn't support nested eswitch. SF can be deployed on the external controller PCI function. But this interface neither limited nor enforcing nested or flat eswitch.
Quoted 1 line
What are your plans for enabling this feature in user space project?
Do you mean K8s plugin or iproute2? Can you please tell us what user space project? If iproute2, will send the iproute2 patchset like other patchset pointing to kernel uapi headers..
RE: [net-next v5 14/15] devlink: Extend devlink port documentation for subfunctions
In reply to Jakub KicinskiQuoted 81 lines
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, December 16, 2020 6:31 AMQuoted 21 lines · On Tue, 15 Dec 2020 01:03:57 -0800 Saeed Mahameed wrote:
(quoted diff) +21
-0+Subfunctions are lightweight functions that has parent PCI function +on which it is deployed. Subfunctions are created and deployed in +unit of 1. Unlike SRIOV VFs, they don't require their own PCI virtual +function. They communicate with the hardware through the parent PCI +function. Subfunctions can possibly scale better. + +To use a subfunction, 3 steps setup sequence is followed. +(1) create - create a subfunction; +(2) configure - configure subfunction attributes; +(3) deploy - deploy the subfunction; + +Subfunction management is done using devlink port user interface. +User performs setup on the subfunction management device. + +(1) Create +---------- +A subfunction is created using a devlink port interface. User adds +the subfunction by adding a devlink port of subfunction flavour. The +devlink kernel code calls down to subfunction management driver +(devlink op) and asks it to create a subfunction devlink port. Driver +then instantiates the subfunction port and any associated objectsReview
Quoted 10 lines
(quoted diff) +10
-0+such as health reporters and representor netdevice. + +(2) Configure +------------- +Subfunction devlink port is created but it is not active yet. That +means the entities are created on devlink side, the e-switch port +representor is created, but the subfunction device itself it not +created. User might use e-switch port representor to do settings, +putting it into bridge, adding TC rules, etc. User might as well +configure the hardware address (such as MAC address) of the subfunctionwhile subfunction is inactive.
Documentation/networking/devlink/devlink-port.rst PCI function. Usually it means, user should configure port function attribute
Quoted 6 lines
Documentation/networking/devlink/devlink-port.rst +6
-0+ +(3) Deploy +---------- +Once subfunction is configured, user must activate it to use it. Upon +activation, subfunction management driver asks the subfunction +management device to instantiate the actual subfunction device onparticular PCI function.
Quoted 2 lines
+A subfunction device is created on the +:ref:
Documentation/driver-api/auxiliary_bus.rst <auxiliary_bus>. At thispoint matching subfunction driver binds to the subfunction's auxiliary device.
Quoted 22 lines
Documentation/networking/devlink/devlink-port.rst +22
-0+ +Terms and Definitions +===================== + +.. list-table:: Terms and Definitions + :widths: 22 90 + + * - Term + - Definitions + * - ``PCI device`` + - A physical PCI device having one or more PCI bus consists of one or + more PCI controllers. + * - ``PCI controller`` + - A controller consists of potentially multiple physical functions, + virtual functions and subfunctions. + * - ``Port function`` + - An object to manage the function of a port. + * - ``Subfunction`` + - A lightweight function that has parent PCI function on which it is + deployed. + * - ``Subfunction device`` + - A bus device of the subfunction, usually on a auxiliary bus.Documentation/networking/devlink/devlink-port.rst PCI function. Usually it means, user should configure port function attribute
Quoted 10 lines
Documentation/networking/devlink/devlink-port.rst +10
-0+ * - ``Subfunction driver`` + - A device driver for the subfunction auxiliary device. + * - ``Subfunction management device`` + - A PCI physical function that supports subfunction management. + * - ``Subfunction management driver`` + - A device driver for PCI physical function that supports + subfunction management using devlink port interface. + * - ``Subfunction host driver`` + - A device driver for PCI physical function that host subfunction + devices. In most cases it is same as subfunction management driver.When
Quoted 6 lines
Quoted 1 line
+ subfunction is used on external controller, subfunction management
and
Quoted 1 line
+ host drivers are different.
Would be great if someone from Mellanox could proof read this before we spend cycles on correcting spelling in public review.
Will get it done.
RE: [net-next v5 04/15] devlink: Support add and delete devlink port
In reply to Jakub KicinskiQuoted 4 lines
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, December 16, 2020 5:59 AM
Quoted 11 lines
include/net/devlink.h struct devlink_port { · line 161
Quoted 6 lines
include/net/devlink.h +6
-0+struct devlink_port_new_attrs { +enum devlink_port_flavour flavour; +unsigned int port_index; +u32 controller; +u32 sfnum; +u16 pfnum;Oh. So you had the structure which actually gets stored in memory for the lifetime of the device in patch 3 mispacked (u32 / u16 / u32 / u8). But this one with arguments is packed. Please be consistent.
Ok. I will change the packing in patch 3.
Quoted 22 lines
include/net/devlink.h struct devlink_ops { · line 1374
Quoted 10 lines
include/net/devlink.h +5
-0+ u8 port_index_valid:1, + controller_valid:1, + sfnum_valid:1; +}; +struct devlink_sb_pool_info {enum devlink_sb_pool_type pool_type;u32 size;@@ -1363,6 +1374,34 @@ struct devlink_ops { int (*port_function_hw_addr_set)(struct devlink *devlink, struct
devlink_port*port,Review struct devlink_ops { · line 1375
Quoted 1 line
(quoted diff) +0
-0const u8 *hw_addr, int
hw_addr_len,include/net/devlink.h struct devlink_ops { · line 1381
Quoted 6 lines
include/net/devlink.h +5
-0struct netlink_ext_ack *extack); +/** +* @port_new: Port add function. +* +* Should be used by device driver to let caller add new port of a +* specified flavour with optional attributes. Add a new port of a specified flavor with optional attributes.
Quoted 5 lines
Review struct devlink_ops { · line 1383
Quoted 2 lines
(quoted diff) +2
-0+ * Driver should return -EOPNOTSUPP if it doesn't support port +additions/should/must/
Ack.
Quoted 6 lines
Review struct devlink_ops { · line 1386
Quoted 3 lines
(quoted diff) +3
-0+ * of a specified flavour or specified attributes. Driver should set + * extack error message in case of fail to add the port. Devlink +cores/fail to add the port/failure/
Ack.
Quoted 4 lines
include/net/devlink.h struct devlink_ops { · line 1385
Quoted 1 line
include/net/devlink.h +1
-0+* does not hold a devlink instance lock when this callback is invoked. Called without holding the devlink instance lock.
Ack.
Quoted 6 lines
Review struct devlink_ops { · line 1388
Quoted 1 line
(quoted diff) +1
-0+ * Driver must ensures synchronization when adding or deleting aport.
s/ensures/ensure/ but really that's pretty obvious from the previous sentence.
It may be, but this extra clarity helps, so I am going to keep this explicit description.
Quoted 4 lines
include/net/devlink.h struct devlink_ops { · line 1387
Quoted 1 line
include/net/devlink.h +1
-0+* Driver must register a port with devlink core. s/must/is expected to/
Ack.
Quoted 3 lines
Please make sure your comments and documentation are proof read by someone.
Ack.
Quoted 11 lines
net/core/devlink.c static int devlink_nl_cmd_port_unsplit_doit(struct sk_buff *skb,
Quoted 10 lines
net/core/devlink.c +10
-0+static int devlink_nl_cmd_port_new_doit (struct sk_buff *skb, +struct genl_info *info) +{ +struct netlink_ext_ack *extack = info->extack; +struct devlink_port_new_attrs new_attrs = {}; +struct devlink *devlink = info->user_ptr[0 ]; + +if (!info->attrs[DEVLINK_ATTR_PORT_FLAVOUR ] || + !info->attrs[DEVLINK_ATTR_PORT_PCI_PF_NUMBER ]) { + NL_SET_ERR_MSG_MOD(extack, "Port flavour or PCI PF arenot specified");
Quoted 16 lines
Quoted 12 lines
net/core/devlink.c +9
-0+return -EINVAL ; + } + new_attrs.flavour =nla_get_u16 (info- attrs[DEVLINK_ATTR_PORT_FLAVOUR ]); + new_attrs.pfnum = +nla_get_u16 (info- attrs[DEVLINK_ATTR_PORT_PCI_PF_NUMBER ]); + +if (info->attrs[DEVLINK_ATTR_PORT_INDEX ]) { + new_attrs.port_index = + nla_get_u32(info-attrs[DEVLINK_ATTR_PORT_INDEX]);
Review
Quoted 2 lines
(quoted diff) +2
-0+ new_attrs.port_index_valid = true; + }This is the desired port index of the new port?
Yes.
Quoted 3 lines
Let's make it abundantly clear since its a pass-thru argument for the driver to interpret.
Ok. Will add comment here.
Quoted 8 lines
Quoted 8 lines
net/core/devlink.c +3
-0+if (info->attrs[DEVLINK_ATTR_PORT_CONTROLLER_NUMBER ]) { + new_attrs.controller = + nla_get_u16(info-attrs[DEVLINK_ATTR_PORT_CONTROLLER_NUMBER]);
net/core/devlink.c +4
-0+ new_attrs.controller_valid = true; + } +if (info->attrs[DEVLINK_ATTR_PORT_PCI_SF_NUMBER ]) { + new_attrs.sfnum = nla_get_u32(info-
Quoted 8 lines
net/core/devlink.c static int devlink_nl_cmd_port_unsplit_doit(struct sk_buff *skb, · line 1181
Quoted 6 lines
attrs[DEVLINK_ATTR_PORT_PCI_SF_NUMBER]);
net/core/devlink.c +5
-0+ new_attrs.sfnum_valid = true; + } + +if (!devlink->ops->port_new) +return -EOPNOTSUPP ;Why is this check not at the beginning of the function?
Will move it up.
Quoted 2 lines
Also should there be an extack on it?
Will check, and add if required.
Quoted 3 lines
net/core/devlink.c static int devlink_nl_cmd_port_unsplit_doit(struct sk_buff *skb, · line 1183
Quoted 1 line
net/core/devlink.c +1
-0+return devlink->ops->port_new (devlink, &new_attrs, extack);This should return the identifier of the created port back to user space.
Ok. Will add.
RE: [net-next v5 05/15] devlink: Support get and set state of port function
In reply to Jakub KicinskiQuoted 11 lines
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, December 16, 2020 6:08 AMQuoted 5 lines · On Tue, 15 Dec 2020 01:03:48 -0800 Saeed Mahameed wrote:
From: Parav Pandit <[email protected]>
devlink port function can be in active or inactive state. Allow users to get and set port function's state.
Quoted 9 lines
Quoted 3 lines
When the port function it activated, its operational state may change after a while when the device is created and driver binds to it. Similarly on deactivation flow.
So what's the flow device should implement?
User requests deactivated, the device sends a notification to the driver bound to the device. What if the driver ignores it?
If driver ignores it, those devices are marked unusable for new allocation. Device becomes usable only after it has act on the event.
Quoted 5 lines
Quoted 2 lines
$ devlink port function set pci/0000:06:00.0/32768 hw_addr 00:00:00:00:88:88 state activeIs request to deactivate done by settings state to inactive?
Yes.
Quoted 8 lines
Quoted 3 lines
+ * enum
devlink_port_function_opstate- indicates operational state
+ of port function
+ * @DEVLINK_PORT_FUNCTION_OPSTATE_ATTACHED: Driver is attachedto the
Quoted 1 line
+ function of port,
This name definitely needs to be shortened.
DEVLINK_PORT_FUNCTION_OPS_ATTACHED
OrDEVLINK_PF_OPS_ATTACHED
PF - port function
Quoted 5 lines
Quoted 1 line
+ * gracefufl tear down of the function,
after
gracefufl
Quoted 8 lines
Quoted 1 line
+ * inactivation of the port function,
user should wait
Quoted 1 line
+ * for operational state to turn
DETACHED.
Why do you indent the comment by 40 characters and then go over 80 chars?
Will fix it.
Quoted 10 lines
Quoted 1 line
+ * @DEVLINK_PORT_FUNCTION_OPSTATE_DETACHED: Driver is detached
from the function of port; it is
include/uapi/linux/devlink.h enum devlink_resource_unit { · line 608
Quoted 4 lines
+ * safe to delete the port.
+ */include/uapi/linux/devlink.h +2
-0+enum devlink_port_function_opstate { +DEVLINK_PORT_FUNCTION_OPSTATE_DETACHED ,The port function must be some Mellanox speak - for the second time - I have no idea what it means. Please use meaningful names.
It is not a Mellanox term.
Port function object is the one that represents function behind this port.
It is not a new term. Port function already exists in devlink whose operational state attribute is defined here.
Quoted 9 lines
Quoted 6 lines
devlink_nl_port_function_attrs_put(struct
sk_buff*msg, structdevlink_port*por(quoted diff) +0
-0ops = devlink->ops; err = devlink_port_function_hw_addr_fill(devlink, ops, port, msg,extack,
&msg_updated);Wrap your code, please.
Sure, will do.
RE: [net-next v5 07/15] net/mlx5: SF, Add auxiliary device support
In reply to Jakub KicinskiQuoted 24 lines
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, December 16, 2020 6:14 AMReview
Quoted 3 lines · On Tue, 15 Dec 2020 01:03:50 -0800 Saeed Mahameed wrote:
(quoted diff) +3
-0+static ssize_t sfnum_show(struct device *dev, struct device_attribute +*attr, char *buf) { + struct auxiliary_device *adev = container_of(dev, struct
auxiliary_device, dev);Quoted 14 lines
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c new file +14
-0+ struct mlx5_sf_dev *sf_dev = container_of(adev, struct mlx5_sf_dev, +adev); + +return scnprintf (buf,PAGE_SIZE ,"%u\n" , sf_dev->sfnum); }static +DEVICE_ATTR_RO (sfnum); + +static struct attribute *sf_device_attrs[] = { + &dev_attr_sfnum.attr, +NULL , +}; + +static const struct attribute_group sf_attr_group = { + .attrs = sf_device_attrs, +};
Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c line 48
Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c new file +5
-0+ +static const struct attribute_group *sf_attr_groups[2 ] = { + &sf_attr_group, +NULL +};Why the sysfs attribute? Devlink should be able to report device name so there's no need for a tie in from the other end.
There isn't a need to enforce a devlink instance creation either, those mlx5 driver does it.
systemd/udev looks after the sysfs attributes, so its parent device, similar to how phys_port_name etc looked for representor side.
RE: [net-next v5 09/15] net/mlx5: E-switch, Prepare eswitch to handle SF vport
In reply to Jakub KicinskiQuoted 44 lines
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, December 16, 2020 6:18 AMQuoted 25 lines · On Tue, 15 Dec 2020 01:03:52 -0800 Saeed Mahameed wrote:
From: Vu Pham <[email protected]>
Prepare eswitch to handle SF vport during
(a) querying eswitch functions
(b) egress ACL creation
(c) account for SF vports in total vports calculationAssign a dedicated placeholder for SFs vports and their representors. They are placed after VFs vports and before ECPF vports as below:
[PF,VF0,...,VFn,SF0,...SFm,ECPF,UPLINK].Change functions to map SF's vport numbers to indices when accessing the vports or representors arrays, and vice versa.
Signed-off-by Vu Pham <[email protected]>Signed-off-by Parav Pandit <[email protected]>Reviewed-by Roi Dayan <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>drivers/net/ethernet/mellanox/mlx5/core/Kconfig +0
-0drivers/net/ethernet/mellanox/mlx5/core/Kconfig config MLX5_SF · line 212
Quoted 1 line
drivers/net/ethernet/mellanox/mlx5/core/Kconfig +0
-0@@ -212,3 +212,13 @@ config MLX5_SF Build support for subfuction device in the NIC. A Mellanoxsubfunction
drivers/net/ethernet/mellanox/mlx5/core/Kconfig config MLX5_SF
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/Kconfig +8
-0device can support RDMA, netdevice and vdpa device. It is similar to a SRIOV VF but it doesn't require SRIOV support. + +config MLX5_SF_MANAGER + bool + depends on MLX5_SF && MLX5_ESWITCH + default y + help + Build support for subfuction port in the NIC. A Mellanox subfunction + port is managed through devlink. A subfunction supports RDMA,netdevice
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/Kconfig config MLX5_SF · line 224
Quoted 2 lines
drivers/net/ethernet/mellanox/mlx5/core/Kconfig +2
-0+ and vdpa device. It is similar to a SRIOV VF but it doesn't require + SRIOV support.Why is this a separate knob?
And it's not used anywhere AFAICS.
SF device and SF manager are two different sides. SF manager is only supported when eswitch is enabled. It is used in subsequent of sf/devlink.c to disable port add/del callbacks.
I should possibly move this hunk to devlink patch 11.
RE: [net-next v5 11/15] net/mlx5: SF, Add port add delete functionality
In reply to Jakub KicinskiQuoted 5 lines
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, December 16, 2020 6:21 AM
Quoted 8 lines
Quoted 4 lines · On Tue, 15 Dec 2020 01:03:54 -0800 Saeed Mahameed wrote:
To handle SF port management outside of the eswitch as independent software layer, introduce eswitch notifier APIs so that upper layer who wish to support sf port management in switchdev mode can perform its
Could you unpack this? What's the "upper layer" software in this context?
Upper layer in this context = sf management layer within the mlx5 driver which implements devlink port add/del callbacks and state handling.
Quoted 5 lines
Quoted 2 lines
task whenever eswitch mode is set to switchdev or before eswitch is disabled.
How does SF work if eswich is disabled?
It doesn't.
when eswitch is disabled, all SF ports gets destroyed through the eswitch event notifier.
Quoted 5 lines
Quoted 5 lines
Initialize sf port table on such eswitch event.
Add SF port add and delete functionality in switchdev mode. Destroy all SF ports when eswitch is disabled. Expose SF port add and delete to user via devlink commands.
RE: [net-next v5 13/15] devlink: Add devlink port documentation
In reply to Jakub KicinskiQuoted 4 lines
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, December 16, 2020 6:28 AM
Quoted 9 lines
Review
Quoted 5 lines · On Tue, 15 Dec 2020 01:03:56 -0800 Saeed Mahameed wrote:
(quoted diff) +5
-0+PCI controllers +--------------- +In most cases a PCI device has only one controller. A controller +consists of potentially multiple physical and virtual functions. Such +PCI function consists of one or more ports.s/Such//
Ack.
Quoted 4 lines
you say consists in two consecutive sentences.
Quoted 1 line
This port of the function is represented by the devlink eswitch port.
First sentence describe controller. Second sentence describe function. So what is wrong in that?
Quoted 2 lines
"This port of the function"? Why not just "Each port"?
That's fine too. Will simplify.
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+A PCI Device connected to multiple CPUs or multiple PCI root +complexes orWhy is device capitalized all of the sudden?
Will fix.
Quoted 11 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+SmartNIC, however, may have multiple controllers. For a device with +multiplea SmartNIC or SmartNICs
Quoted 1 line
+controllers, each controller is distinguished by a unique controller
number.
Quoted 1 line
+An eswitch on the PCI device support ports of multiple controllers.
eswitch is on a PCI device?
Will change.
Quoted 48 lines
Quoted 28 lines
Documentation/networking/devlink/devlink-port.rst new file +28
-0+An example view of a system with two controllers:: + + --------------------------------------------------------- + | | + | --------- --------- ------- ------- | + ----------- | | vf(s) | | sf(s) | |vf(s)| |sf(s)| | + | server | | ------- ----/---- ---/----- ------- ---/--- ---/--- | + | pci rc |=== | pf0 |______/________/ | pf1 |___/_______/ | + | connect | | ------- ------- | + ----------- | | controller_num=1 (no eswitch) | + ------|-------------------------------------------------- + (internal wire) + | + --------------------------------------------------------- + | devlink eswitch ports and reps | + | ----------------------------------------------------- | + | |ctrl-0 | ctrl-0 | ctrl-0 | ctrl-0 | ctrl-0 |ctrl-0 | | + | |pf0 | pf0vfN | pf0sfN | pf1 | pf1vfN |pf1sfN | | + | ----------------------------------------------------- | + | |ctrl-1 | ctrl-1 | ctrl-1 | ctrl-1 | ctrl-1 |ctrl-1 | | + | |pf0 | pf0vfN | pf0sfN | pf1 | pf1vfN |pf1sfN | | + | ----------------------------------------------------- | + | | + | | + ----------- | --------- --------- ------- ------- | + | smartNIC| | | vf(s) | | sf(s) | |vf(s)| |sf(s)| | + | pci rc |==| ------- ----/---- ---/----- ------- ---/--- ---/--- | + | connect | | | pf0 |______/________/ | pf1 |___/_______/ |Documentation/networking/devlink/devlink-port.rst
Quoted 10 lines
Documentation/networking/devlink/devlink-port.rst new file +10
-0+ ----------- | ------- ------- | + | | + | local controller_num=0 (eswitch) | + + --------------------------------------------------------- + +In above example, external controller (identified by controller +number = 1) doesn't have eswitch. Local controller (identified by +controller number = 0) has the eswitch. Devlink instance on local +controller has eswitch devlink ports representing ports for both thecontrollers.
Documentation/networking/devlink/devlink-port.rst
Quoted 6 lines
Documentation/networking/devlink/devlink-port.rst new file +6
-0+ +Port function configuration +=========================== + +A user can configure the port function attribute before enumerating +thes/A user/User/
Quoted 2 lines
/port function attribute/$something_meaningful/
May be just say function attribute?
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+PCI function. Usually it means, user should configure port function +attributeattributes, plural
Yes, but at present there is only one i.e. mac address, so didn't use plural.
Re: [net-next v5 05/15] devlink: Support get and set state of port function
In reply to Parav PanditQuoted 4 lines · Parav Pandit
Quoted 4 lines
Quoted 3 lines
+ * enum
devlink_port_function_opstate- indicates operational state
+ of port function
+ * @DEVLINK_PORT_FUNCTION_OPSTATE_ATTACHED: Driver is attachedto the
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
+ function of port,
This name definitely needs to be shortened.
DEVLINK_PORT_FUNCTION_OPS_ATTACHED
OrDEVLINK_PF_OPS_ATTACHEDPF - port function
The devlink attribute names need to start using established short names to find that balance between readability and ridiculously long names.
In this case PF for networking has an established link to SRIOV 'physical function'.
FUNCTION can be written as FCN.
ATTACHED can be shortened to ATTCH.
So in this case DEVLINK_PORT_FUNCTION_OPSTATE_ATTACHED (38 chars) drops to DEVLINK_PORT_FCN_OPSTATE_ATTCH (30 chars). That is a step in the right direction.
Jakub Kicinski
maintainerRe: [net-next v5 03/15] devlink: Introduce PCI SF port flavour and port attribute
In reply to Parav PanditQuoted 8 lines · On Wed, 16 Dec 2020 03:42:51 +0000 Parav Pandit wrote:
Quoted 3 lines
From: Jakub Kicinski <[email protected]>
So subfunctions don't have a VF id but they may have a controller?Right. SF can be on external controller.
Quoted 3 lines
Can you tell us more about the use cases and deployment models you're intending to support? Let's not add attributes and info which will go unused.
Quoted 6 lines
External will be used the same way how it is used for PF and VF.
Quoted 2 lines
How are SFs supposed to be used with SmartNICs? Are you assuming single domain of control?
No. it is not assumed. SF can be deployed from smartnic to external host.
A user has to pass appropriate controller number, pf number attributes during creation time.
My problem with this series is that I've gotten some real life application exposure over the last year, and still I have no idea who is going to find this feature useful and why.
That's the point of my questions in the previous email - what are the use cases, how are they going to operate.
It's hard to review an API without knowing the use of it. iproute2 is low level plumbing.
Here the patch is adding the ability to apparently create a SF on a remote controller. If you haven't thought that use case through just don't allow it until you know how it will work.
Quoted 11 lines
Quoted 6 lines
It seems that the way the industry is moving the major use case for SmartNICs is bare metal.
I always assumed nested eswitches when thinking about SmartNICs, what are you intending to do?
Mlx5 doesn't support nested eswitch. SF can be deployed on the external controller PCI function. But this interface neither limited nor enforcing nested or flat eswitch.
Quoted 1 line
What are your plans for enabling this feature in user space project?
Do you mean K8s plugin or iproute2? Can you please tell us what user space project?
That's my question. For SR-IOV it'd be all the virt stacks out there. But this can't do virt. So what can it do?
Quoted 1 line
If iproute2, will send the iproute2 patchset like other patchset pointing to kernel uapi headers..
Jakub Kicinski
maintainerRe: [net-next v5 05/15] devlink: Support get and set state of port function
In reply to Parav PanditQuoted 13 lines · On Wed, 16 Dec 2020 05:15:04 +0000 Parav Pandit wrote:
Quoted 13 lines
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, December 16, 2020 6:08 AMQuoted 8 lines · On Tue, 15 Dec 2020 01:03:48 -0800 Saeed Mahameed wrote:
From: Parav Pandit <[email protected]>
devlink port function can be in active or inactive state. Allow users to get and set port function's state.
When the port function it activated, its operational state may change after a while when the device is created and driver binds to it. Similarly on deactivation flow.
Quoted 7 lines
Quoted 5 lines
So what's the flow device should implement?
User requests deactivated, the device sends a notification to the driver bound to the device. What if the driver ignores it?
If driver ignores it, those devices are marked unusable for new allocation. Device becomes usable only after it has act on the event.
But the device remains fully operational?
So if I'm an admin who wants to unplug a misbehaving "entity"[1] the deactivate is not gonna help me, it's just a graceful hint? Is there no need for a forceful shutdown?
[1] refer to earlier email, IDK what entity is supposed to use this
Quoted 10 lines
Quoted 10 lines
Quoted 1 line
+ * @DEVLINK_PORT_FUNCTION_OPSTATE_DETACHED: Driver is detached
from the function of port; it is
include/uapi/linux/devlink.h enum devlink_resource_unit { · line 608
Quoted 4 lines
+ * safe to delete the port.
+ */include/uapi/linux/devlink.h +2
-0+enum devlink_port_function_opstate { +DEVLINK_PORT_FUNCTION_OPSTATE_DETACHED ,The port function must be some Mellanox speak - for the second time - I have no idea what it means. Please use meaningful names.
Quoted 3 lines
It is not a Mellanox term.
Port function object is the one that represents function behind this port.
It is not a new term. Port function already exists in devlink whose operational state attribute is defined here.
I must have missed that in review. PCI functions can host multiple ports. So "port function" does not compute for me. Can we drop the "function"?
Jakub Kicinski
maintainerRe: [net-next v5 07/15] net/mlx5: SF, Add auxiliary device support
In reply to Parav PanditQuoted 30 lines · On Wed, 16 Dec 2020 05:19:15 +0000 Parav Pandit wrote:
Quoted 22 lines
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, December 16, 2020 6:14 AMReview
Quoted 3 lines · On Tue, 15 Dec 2020 01:03:50 -0800 Saeed Mahameed wrote:
(quoted diff) +3
-0+static ssize_t sfnum_show(struct device *dev, struct device_attribute +*attr, char *buf) { + struct auxiliary_device *adev = container_of(dev, struct
auxiliary_device, dev);Quoted 14 lines
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c new file +14
-0+ struct mlx5_sf_dev *sf_dev = container_of(adev, struct mlx5_sf_dev, +adev); + +return scnprintf (buf,PAGE_SIZE ,"%u\n" , sf_dev->sfnum); }static +DEVICE_ATTR_RO (sfnum); + +static struct attribute *sf_device_attrs[] = { + &dev_attr_sfnum.attr, +NULL , +}; + +static const struct attribute_group sf_attr_group = { + .attrs = sf_device_attrs, +};Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c line 48
Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c new file +5
-0+ +static const struct attribute_group *sf_attr_groups[2 ] = { + &sf_attr_group, +NULL +};Why the sysfs attribute? Devlink should be able to report device name so there's no need for a tie in from the other end.
Quoted 1 line
There isn't a need to enforce a devlink instance creation either,
You mean there isn't a need for the SF to be spawned by devlink?
Quoted 1 line
those mlx5 driver does it.
Really, no idea what you're trying to say. Read your emails before you send them.
Quoted 1 line
systemd/udev looks after the sysfs attributes, so its parent device, similar to how
phys_port_nameetc looked for representor side.
Re: [net-next v5 03/15] devlink: Introduce PCI SF port flavour and port attribute
In reply to Jakub KicinskiQuoted 22 lines · Jakub Kicinski
Quoted 13 lines · On Wed, 16 Dec 2020 03:42:51 +0000 Parav Pandit wrote:
Quoted 4 lines
From: Jakub Kicinski <[email protected]>
So subfunctions don't have a VF id but they may have a controller?Right. SF can be on external controller.
Quoted 5 lines
Can you tell us more about the use cases and deployment models you're
intending to support? Let's not add attributes and info which will go unused.External will be used the same way how it is used for PF and VF.
Quoted 7 lines
Quoted 3 lines
How are SFs supposed to be used with SmartNICs? Are you assuming single
domain of control?No. it is not assumed. SF can be deployed from smartnic to external host.
A user has to pass appropriate controller number, pf number attributes during creation time.
Quoted 7 lines
My problem with this series is that I've gotten some real life application exposure over the last year, and still I have no idea who is going to find this feature useful and why.
That's the point of my questions in the previous email - what are the use cases, how are they going to operate.
The main focus of this feature is scale-ability we want to run thousands of Containers/VMs, this is useful for both smartnic and baremetal hypervisor worlds, where security and control is exclusive to the eswitch manager may it be the smarnic embedded CPU or the x86 Hypervisor.
deployment models is identical to SRIOV, the only difference is the instantiation model of SF, which is the main discussion point of this series (i hope), which to my taste is very modest and minimal. after SF is instantiated from that point nothing is new, the SF is exposing standard linux interfaces netdev/rdma identical to what VF does, most likely you will assign them a namespace and pass them through to a container or assign them (not direct assignment) to a VM via the virt stack, or create a vdpa instance and pass it to a virtio interface.
There are endless usecases for the netdev stack, for customers who want high scale virtualized/containerized environments, with thousands of network functions that can deliver high speed and full offload accelerators, Native XDP, Crypto, encap/decap, and HW filtering and processing pipeline capabilities.
I have a long list of customers with various and different applications and i am not even talking about the rdma and vdpa customers ! those customers just can't wait to leave sriov behind and scale up !
this feature has a lot of value to the netdev users only because of the minimal foot print to the netdev stack (to be honest there is no change in netdev, only a thin API layer in devlink) and the immediate and effortless benefits to deploy multiple (accelerated) netdevs at scale.
Quoted 3 lines
It's hard to review an API without knowing the use of it. iproute2 is low level plumbing.
I don't know how to put this, let me try:
A) SRIOV model
echo 128 > /sys/class/net/eth0/device/sriov_numvfs ubind vf
ip set vf attribute x
configure representor ..
deploy vf/netdev/rdma interface into the container
B) SF model
you do (every thing under the devlink umbrella/switchdev):
for i in {1..1024} ; do
devlink port add pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum $i devlink port sf $i set attribute x
# from here on, it is identical to a VF configure representor deply sf/netdev/rdma interfaces into a container
B is more scale-able and has more visibility and controllability to the user, after you create the SFs deployment and usecases are identical to SRIOV VF usecases.
See the improvement ? :)
Quoted 4 lines
Here the patch is adding the ability to apparently create a SF on a remote controller. If you haven't thought that use case through just don't allow it until you know how it will work.
We have thought the use case through it is not any different from the local controller use case. the code is uniform, we need to work hard to block a remote controller :) ..
Quoted 12 lines
Quoted 12 lines
Quoted 7 lines
It seems that the way the industry is moving the major use case for SmartNICs is bare metal.
I always assumed nested eswitches when thinking about SmartNICs, what
are you intending to do?Mlx5 doesn't support nested eswitch. SF can be deployed on the external controller PCI function.
But this interface neither limited nor enforcing nested or flat eswitch.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
What are your plans for enabling this feature in user space project?
Do you mean K8s plugin or iproute2? Can you please tell us what user space project?
That's my question. For SR-IOV it'd be all the virt stacks out there. But this can't do virt. So what can it do?
you are thinking VF direct assignment. but don't forget virt handles netdev assignment to a vm perfectly fine and SF has a netdev.
And don't get me started on the weird virt handling of SRIOV VF, the whole thing is a big mess :) it shouldn't be a de facto standard that we need to follow..
RE: [net-next v5 07/15] net/mlx5: SF, Add auxiliary device support
In reply to Jakub KicinskiQuoted 36 lines
From: Jakub Kicinski <[email protected]>
Sent: Thursday, December 17, 2020 5:42 AMQuoted 30 lines · On Wed, 16 Dec 2020 05:19:15 +0000 Parav Pandit wrote:
Quoted 30 lines
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, December 16, 2020 6:14 AMReview
Quoted 3 lines · On Tue, 15 Dec 2020 01:03:50 -0800 Saeed Mahameed wrote:
(quoted diff) +3
-0+static ssize_t sfnum_show(struct device *dev, struct +device_attribute *attr, char *buf) { + struct auxiliary_device *adev = container_of(dev, struct
auxiliary_device, dev);Quoted 9 lines
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c new file +9
-0+ struct mlx5_sf_dev *sf_dev = container_of(adev, struct +mlx5_sf_dev, adev); + +return scnprintf (buf,PAGE_SIZE ,"%u\n" , sf_dev->sfnum); } +static DEVICE_ATTR_RO (sfnum); + +static struct attribute *sf_device_attrs[] = { + &dev_attr_sfnum.attr, +NULL ,drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c line 48
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c new file +10
-0+}; + +static const struct attribute_group sf_attr_group = { + .attrs = sf_device_attrs, +}; + +static const struct attribute_group *sf_attr_groups[2 ] = { + &sf_attr_group, +NULL +};Why the sysfs attribute? Devlink should be able to report device name so there's no need for a tie in from the other end.
Quoted 4 lines
Quoted 1 line
There isn't a need to enforce a devlink instance creation either,
You mean there isn't a need for the SF to be spawned by devlink?
No. sorry for the confusion.
Let me list down the sequence and plumbing.
1. Devlink instance having eswitch spawns the SF port (port add, flavour = pcisf [..]).
2. This SF is either for local or external controller. Just like today's VF.
3. When SF port is activated (port function set state), SF auxiliary device is spawned on the hosting PF.
4. This SF auxiliary device when attached to mlx5_core driver it registers devlink instance (auxiliary/mlx5_core.sf.4).
5. When netdev of SF dev is created, it register devlink port of virtual flavour with link to its netdev. /sys/class/net/<sf_netdev>/device points to the auxiliary device. /sys/class/infiniband/<sf_rdma_dev>/device points to the auxiliary device.
6. SF auxiliary device has the sysfs file read by systemd/udev to rename netdev and rdma devices of SF.
Steps 4,5,6 are equivalent to an existing VF.
RE: [net-next v5 05/15] devlink: Support get and set state of port function
In reply to Jakub KicinskiQuoted 24 lines
From: Jakub Kicinski <[email protected]>
Sent: Thursday, December 17, 2020 5:39 AMQuoted 18 lines · On Wed, 16 Dec 2020 05:15:04 +0000 Parav Pandit wrote:
Quoted 18 lines
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, December 16, 2020 6:08 AMQuoted 8 lines · On Tue, 15 Dec 2020 01:03:48 -0800 Saeed Mahameed wrote:
From: Parav Pandit <[email protected]>
devlink port function can be in active or inactive state. Allow users to get and set port function's state.
When the port function it activated, its operational state may change after a while when the device is created and driver binds to it. Similarly on deactivation flow.
So what's the flow device should implement?
User requests deactivated, the device sends a notification to the driver bound to the device. What if the driver ignores it?
Quoted 7 lines
Quoted 2 lines
If driver ignores it, those devices are marked unusable for new allocation. Device becomes usable only after it has act on the event.
But the device remains fully operational?
So if I'm an admin who wants to unplug a misbehaving "entity"[1] the deactivate is not gonna help me, it's just a graceful hint?
Right.
Quoted 1 line
Is there no need for a forceful shutdown?
In this patchset, no. I didn't add the knob for it. It is already at 15 patches. But yes, forceful shutdown extension can be done by the admin in future patchset as,
$ devlink port del pci/0000:06:00.0/<port_index> force true
^^^^^^^^
Above will be the extension in control of the admin.Quoted 3 lines
[1] refer to earlier email, IDK what entity is supposed to use this
While I was replying, Saeed already answered it.
Quoted 5 lines
Quoted 2 lines
Port function object is the one that represents function behind this port. It is not a new term. Port function already exists in devlink whose
operational state attribute is defined here.
I must have missed that in review. PCI functions can host multiple ports.
This is exactly why I had "multiple networking ports" above to differentiate it from devlink port. And you asked me to drop 'networking' because devlink is all networking ports, that creates this confusion.
Anyways, I will rewrite the commit message as 'function', instead of 'port function' as below.
New commit message snippet _start:
A function can be in active or inactive state. Allow users to get and set function's state.
When the function it activated, its operational state may change after a while when the device is created and driver binds to it. Similarly on deactivation flow.
To clearly describe the state of the function and its device's operational state in the host system, define state and opstate attributes. _end.
Quoted 2 lines
So
"port function" does not compute for me. Can we drop the "function"?
No. it is better to keep it. Because it clearly distinguishes the host facing function whose attribute (mac) and state are controlled. But I shorten the names, enums etc in code from port_function to port_fn. So it should be readable now.
Jakub Kicinski
maintainerRe: [net-next v5 03/15] devlink: Introduce PCI SF port flavour and port attribute
In reply to Saeed MahameedQuoted 47 lines · On Wed, 16 Dec 2020 20:44:21 -0800 Saeed Mahameed wrote:
Quoted 22 lines · Jakub Kicinski
Quoted 13 lines · On Wed, 16 Dec 2020 03:42:51 +0000 Parav Pandit wrote:
Quoted 4 lines
From: Jakub Kicinski <[email protected]>
So subfunctions don't have a VF id but they may have a controller?Right. SF can be on external controller.
Quoted 5 lines
Can you tell us more about the use cases and deployment models you're
intending to support? Let's not add attributes and info which will go unused.External will be used the same way how it is used for PF and VF.
Quoted 7 lines
Quoted 3 lines
How are SFs supposed to be used with SmartNICs? Are you assuming single
domain of control?No. it is not assumed. SF can be deployed from smartnic to external host.
A user has to pass appropriate controller number, pf number attributes during creation time.Quoted 7 lines
My problem with this series is that I've gotten some real life application exposure over the last year, and still I have no idea who is going to find this feature useful and why.
That's the point of my questions in the previous email - what are the use cases, how are they going to operate.
The main focus of this feature is scale-ability we want to run thousands of Containers/VMs, this is useful for both smartnic and baremetal hypervisor worlds, where security and control is exclusive to the eswitch manager may it be the smarnic embedded CPU or the x86 Hypervisor.
deployment models is identical to SRIOV, the only difference is the instantiation model of SF, which is the main discussion point of this series (i hope), which to my taste is very modest and minimal. after SF is instantiated from that point nothing is new, the SF is exposing standard linux interfaces netdev/rdma identical to what VF does, most likely you will assign them a namespace and pass them through to a container or assign them (not direct assignment) to a VM via the virt stack, or create a vdpa instance and pass it to a virtio interface.
Quoted 1 line
There are endless usecases for the netdev stack, for customers who want
"endless" :)
Quoted 5 lines
high scale virtualized/containerized environments, with thousands of network functions that can deliver high speed and full offload accelerators, Native XDP, Crypto, encap/decap, and HW filtering and processing pipeline capabilities.
Quoted 8 lines
I have a long list of customers with various and different applications and i am not even talking about the rdma and vdpa customers ! those customers just can't wait to leave sriov behind and scale up !
this feature has a lot of value to the netdev users only because of the minimal foot print to the netdev stack (to be honest there is no change in netdev, only a thin API layer in devlink) and the immediate and effortless benefits to deploy multiple (accelerated) netdevs at scale.
The acceleration can hopefully be plumbed through the software devices.
I think your HW is capable of doing large queue sets so I'm curious how this actually performs. We're probably talking 1000+ queues here - the CPU will have hard time serving so many queues. In my experiments basically the more queues the more cache trashing, the more interrupts, etc. and the lower the performance.
Quoted 11 lines
Quoted 2 lines
It's hard to review an API without knowing the use of it. iproute2 is low level plumbing.
I don't know how to put this, let me try:
A) SRIOV model
echo 128 >/sys/class/net/eth0/device/sriov_numvfsubind vfip set vf attribute x
configure representor ..
deploy vf/netdev/rdma interface into the container
No, no, my point is that for SR-IOV it's OpenStack, libvirt etc. which do this. I understand the manual steps. Often problems pop up when real systems try to string the HW objects together, allocated them, learn their capabilities, etc.
Quoted 16 lines
B) SF model
you do (every thing under the devlink umbrella/switchdev):
for i in {1..1024} ; do
devlink port add pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum $i devlink port sf $i set attribute x# from here on, it is identical to a VF configure representor deply sf/netdev/rdma interfaces into a containerB is more scale-able and has more visibility and controllability to the user, after you create the SFs deployment and usecases are identical to SRIOV VF usecases.
See the improvement ? :)
Quoted 7 lines
Quoted 3 lines
Here the patch is adding the ability to apparently create a SF on a remote controller. If you haven't thought that use case through just don't allow it until you know how it will work.
We have thought the use case through it is not any different from the local controller use case. the code is uniform, we need to work hard to block a remote controller :) ..
So the SF is always created from the eswitch controller side? How does the host side look?
I really think that for ease of merging this we should leave the remote controller out at the beginning - only allow local creation.
Quoted 27 lines
Quoted 12 lines
Quoted 12 lines
Quoted 7 lines
It seems that the way the industry is moving the major use case for SmartNICs is bare metal.
I always assumed nested eswitches when thinking about SmartNICs, what
are you intending to do?Mlx5 doesn't support nested eswitch. SF can be deployed on the external controller PCI function.
But this interface neither limited nor enforcing nested or flat eswitch.Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
What are your plans for enabling this feature in user space project?
Do you mean K8s plugin or iproute2? Can you please tell us what user space project?
That's my question. For SR-IOV it'd be all the virt stacks out there. But this can't do virt. So what can it do?
you are thinking VF direct assignment. but don't forget virt handles netdev assignment to a vm perfectly fine and SF has a netdev.
And don't get me started on the weird virt handling of SRIOV VF, the whole thing is a big mess :) it shouldn't be a de facto standard that we need to follow..
Jakub Kicinski
maintainerRe: [net-next v5 05/15] devlink: Support get and set state of port function
In reply to Parav PanditQuoted 29 lines · On Thu, 17 Dec 2020 05:46:45 +0000 Parav Pandit wrote:
Quoted 22 lines
From: Jakub Kicinski <[email protected]>
Sent: Thursday, December 17, 2020 5:39 AMQuoted 18 lines · On Wed, 16 Dec 2020 05:15:04 +0000 Parav Pandit wrote:
Quoted 18 lines
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, December 16, 2020 6:08 AMQuoted 8 lines · On Tue, 15 Dec 2020 01:03:48 -0800 Saeed Mahameed wrote:
From: Parav Pandit <[email protected]>
devlink port function can be in active or inactive state. Allow users to get and set port function's state.
When the port function it activated, its operational state may change after a while when the device is created and driver binds to it. Similarly on deactivation flow.
So what's the flow device should implement?
User requests deactivated, the device sends a notification to the driver bound to the device. What if the driver ignores it?
Quoted 7 lines
Quoted 2 lines
If driver ignores it, those devices are marked unusable for new allocation. Device becomes usable only after it has act on the event.
But the device remains fully operational?
So if I'm an admin who wants to unplug a misbehaving "entity"[1] the deactivate is not gonna help me, it's just a graceful hint?
Quoted 8 lines
Right.
Quoted 1 line
Is there no need for a forceful shutdown?
In this patchset, no. I didn't add the knob for it. It is already at 15 patches. But yes, forceful shutdown extension can be done by the admin in future patchset as,
$ devlink port del pci/0000:06:00.0/<port_index> force true ^^^^^^^^ Above will be the extension in control of the admin.
Can we come up with operational states that would encompass that?
The "force true" does not look too clean.
And let's document meaning of the states. We don't want the next vendor to just "assume" the states match their own interpretation.
Jakub Kicinski
maintainerRe: [net-next v5 07/15] net/mlx5: SF, Add auxiliary device support
In reply to Parav PanditQuoted 48 lines · On Thu, 17 Dec 2020 05:23:10 +0000 Parav Pandit wrote:
Quoted 34 lines
From: Jakub Kicinski <[email protected]>
Sent: Thursday, December 17, 2020 5:42 AMQuoted 30 lines · On Wed, 16 Dec 2020 05:19:15 +0000 Parav Pandit wrote:
Quoted 30 lines
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, December 16, 2020 6:14 AMReview
Quoted 3 lines · On Tue, 15 Dec 2020 01:03:50 -0800 Saeed Mahameed wrote:
(quoted diff) +3
-0+static ssize_t sfnum_show(struct device *dev, struct +device_attribute *attr, char *buf) { + struct auxiliary_device *adev = container_of(dev, struct
auxiliary_device, dev);Quoted 9 lines
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c new file +9
-0+ struct mlx5_sf_dev *sf_dev = container_of(adev, struct +mlx5_sf_dev, adev); + +return scnprintf (buf,PAGE_SIZE ,"%u\n" , sf_dev->sfnum); } +static DEVICE_ATTR_RO (sfnum); + +static struct attribute *sf_device_attrs[] = { + &dev_attr_sfnum.attr, +NULL ,drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c line 48
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c new file +10
-0+}; + +static const struct attribute_group sf_attr_group = { + .attrs = sf_device_attrs, +}; + +static const struct attribute_group *sf_attr_groups[2 ] = { + &sf_attr_group, +NULL +};Why the sysfs attribute? Devlink should be able to report device name so there's no need for a tie in from the other end.
Quoted 4 lines
Quoted 1 line
There isn't a need to enforce a devlink instance creation either,
You mean there isn't a need for the SF to be spawned by devlink?
No. sorry for the confusion.
Let me list down the sequence and plumbing.
1. Devlink instance having eswitch spawns the SF port (port add, flavour = pcisf [..]).
2. This SF is either for local or external controller. Just like today's VF.
3. When SF port is activated (port function set state), SF auxiliary device is spawned on the hosting PF.
4. This SF auxiliary device when attached tomlx5_coredriver it registers devlink instance (auxiliary/mlx5_core.sf.4).
5. When netdev of SF dev is created, it register devlink port of virtual flavour with link to its netdev. /sys/class/net/<sf_netdev>/device points to the auxiliary device. /sys/class/infiniband/<sf_rdma_dev>/device points to the auxiliary device.
Quoted 1 line
6. SF auxiliary device has the sysfs file read by systemd/udev to rename netdev and rdma devices of SF.
Why can't the SF ID match aux dev ID? You only register one aux dev per SF, right? Or one for RDMA, one for netdev, etc?
Quoted 1 line
Steps 4,5,6 are equivalent to an existing VF.
RE: [net-next v5 03/15] devlink: Introduce PCI SF port flavour and port attribute
In reply to Jakub KicinskiQuoted 7 lines
From: Jakub Kicinski <[email protected]>
Sent: Saturday, December 19, 2020 1:18 AM
So the SF is always created from the eswitch controller side? How does the host side look?
Host side creates the auxiliary device for the SF.
$ ls -l /sys/bus/auxiliary/devices/ mlx5_core.sf.4 -> ../../../devices/pci0000:00/0000:00:03.0/0000:06:00.0/mlx5_core.sf.4
Quoted 3 lines
I really think that for ease of merging this we should leave the remote controller out at the beginning - only allow local creation.
Alright. I will drop remote controller attribute of SF in this patchset.
RE: [net-next v5 07/15] net/mlx5: SF, Add auxiliary device support
In reply to Jakub KicinskiQuoted 54 lines
From: Jakub Kicinski <[email protected]>
Sent: Saturday, December 19, 2020 1:29 AMQuoted 34 lines · On Thu, 17 Dec 2020 05:23:10 +0000 Parav Pandit wrote:
Quoted 34 lines
From: Jakub Kicinski <[email protected]>
Sent: Thursday, December 17, 2020 5:42 AMQuoted 30 lines · On Wed, 16 Dec 2020 05:19:15 +0000 Parav Pandit wrote:
Quoted 30 lines
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, December 16, 2020 6:14 AMReview
Quoted 3 lines · On Tue, 15 Dec 2020 01:03:50 -0800 Saeed Mahameed wrote:
(quoted diff) +3
-0+static ssize_t sfnum_show(struct device *dev, struct +device_attribute *attr, char *buf) { + struct auxiliary_device *adev = container_of(dev, struct
auxiliary_device, dev);Quoted 9 lines
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c new file +9
-0+ struct mlx5_sf_dev *sf_dev = container_of(adev, struct +mlx5_sf_dev, adev); + +return scnprintf (buf,PAGE_SIZE ,"%u\n" , sf_dev->sfnum); } +static DEVICE_ATTR_RO (sfnum); + +static struct attribute *sf_device_attrs[] = { + &dev_attr_sfnum.attr, +NULL ,drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c line 48
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c new file +10
-0+}; + +static const struct attribute_group sf_attr_group = { + .attrs = sf_device_attrs, +}; + +static const struct attribute_group *sf_attr_groups[2 ] = { + &sf_attr_group, +NULL +};Why the sysfs attribute? Devlink should be able to report device name so there's no need for a tie in from the other end.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
There isn't a need to enforce a devlink instance creation either,
You mean there isn't a need for the SF to be spawned by devlink?
No. sorry for the confusion.
Let me list down the sequence and plumbing.
1. Devlink instance having eswitch spawns the SF port (port add, flavour =pcisf [..]).
Quoted 2 lines
2. This SF is either for local or external controller. Just like today's VF.
3. When SF port is activated (port function set state), SF auxiliary device isspawned on the hosting PF.
Quoted 1 line
4. This SF auxiliary device when attached to
mlx5_coredriver it registersdevlink instance (auxiliary/mlx5_core.sf.4).
Quoted 1 line
5. When netdev of SF dev is created, it register devlink port of virtual
Quoted 8 lines
flavour with link to its netdev.
Quoted 4 lines
/sys/class/net/<sf_netdev>/device points to the auxiliary device. /sys/class/infiniband/<sf_rdma_dev>/device points to the auxiliary device.
6. SF auxiliary device has the sysfs file read by systemd/udev to rename
netdev and rdma devices of SF.
Why can't the SF ID match aux dev ID?
Auxiliary bus holds the SFs of multiple PFs.
SF ID can be same for SFs from multiple PFs. Encoding PCI address in SF auxiliary device name doesn't do good. So SF ID attribute of device is more appropriate.
Quoted 1 line
You only register one aux dev per SF right?
Right.
Quoted 2 lines
Or one for RDMA, one for netdev, etc?
These protocol/class specific auxiliary devices are on top of SF's auxiliary devices which are only for matching service purpose. I have covered this detail with actual example in diagram in documentation in patch15 under " Subfunction auxiliary device and class device hierarchy::"
RE: [net-next v5 05/15] devlink: Support get and set state of port function
In reply to Jakub KicinskiQuoted 42 lines
From: Jakub Kicinski <[email protected]>
Sent: Saturday, December 19, 2020 1:21 AMQuoted 7 lines · On Thu, 17 Dec 2020 05:46:45 +0000 Parav Pandit wrote:
Quoted 7 lines
From: Jakub Kicinski <[email protected]>
Sent: Thursday, December 17, 2020 5:39 AMQuoted 3 lines · On Wed, 16 Dec 2020 05:15:04 +0000 Parav Pandit wrote:
Quoted 3 lines
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, December 16, 2020 6:08 AMQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines · On Tue, 15 Dec 2020 01:03:48 -0800 Saeed Mahameed wrote:
Quoted 7 lines
From: Parav Pandit <[email protected]>
devlink port function can be in active or inactive state. Allow users to get and set port function's state.
When the port function it activated, its operational state may change after a while when the device is created and driver binds to
it.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
Similarly on deactivation flow.
So what's the flow device should implement?
User requests deactivated, the device sends a notification to the driver bound to the device. What if the driver ignores it?
If driver ignores it, those devices are marked unusable for new
allocation.
Quoted 12 lines
Quoted 6 lines
Quoted 1 line
Device becomes usable only after it has act on the event.
But the device remains fully operational?
So if I'm an admin who wants to unplug a misbehaving "entity"[1] the deactivate is not gonna help me, it's just a graceful hint?
Right.
Quoted 1 line
Is there no need for a forceful shutdown?
In this patchset, no. I didn't add the knob for it. It is already at 15 patches. But yes, forceful shutdown extension can be done by the admin in future patchset as,
Quoted 6 lines
Quoted 3 lines
$ devlink port del pci/0000:06:00.0/<port_index> force true^^^^^^^^ Above will be the extension in control of the admin.
Can we come up with operational states that would encompass that?
Operational state is read only. Adding more states will likely make user job harder, unless its absolute necessary. Currently state and operational state definitions cover all the scenario needed.
Only exception is user doesn't have the ability of force delete.
$ devlink port shutdown pci/0000:03:00.0/port_index Above command will attempt graceful port deletion.
$ devlink port del pci/0000:03:00.0/port_index Above command will do force deletion.
Quoted 2 lines
The "force true" does not look too clean.
I think notion of force to user is more intuitive than above two commands, as its exist for other parts of the system for example 'reboot'. So no need for flag as true/false. Just force if user wish to do force removal.
Quoted 2 lines
And let's document meaning of the states. We don't want the next vendor to just "assume" the states match their own interpretation.
Oh yes, I did document it in the UAPI header file which will be the first place for vendors to look on how to implement get/set. But I will add this to patch_14 in the devlink 'subfunctions' section documentation.
Jakub Kicinski
maintainerRe: [net-next v5 07/15] net/mlx5: SF, Add auxiliary device support
In reply to Parav PanditQuoted 2 lines · On Sat, 19 Dec 2020 04:53:45 +0000 Parav Pandit wrote:
Quoted 1 line
Why can't the SF ID match aux dev ID?
Auxiliary bus holds the SFs of multiple PFs.
I see it now. Very unfortunate :(
Quoted 2 lines
SF ID can be same for SFs from multiple PFs. Encoding PCI address in SF auxiliary device name doesn't do good. So SF ID attribute of device is more appropriate.