Skip to content

Commit 5f91f2f

Browse files
author
Benjamin Poirier
committed
fwctl/mlx5: Support for communicating with mlx5 fw
JIRA: https://issues.redhat.com/browse/RHEL-86016 Upstream-status: v6.15-rc1 Conflicts: - MAINTAINERS Due to the absence of 3ae5208 media: i2c: gc0308: new driver (v6.8-rc1) -> Adjust context - drivers/fwctl/mlx5/main.c Ajusted for the absence of cdd30eb module: Convert symbol namespace to string literal (v6.13-rc2) -> Remove quotation marks around FWCTL. commit 52929c2 Author: Saeed Mahameed <saeedm@nvidia.com> Date: Thu Feb 27 20:26:35 2025 -0400 fwctl/mlx5: Support for communicating with mlx5 fw mlx5 FW has a built in security context called UID. Each UID has a set of permissions controlled by the kernel when it is created and every command is tagged by the kernel with a particular UID. In general commands cannot reach objects outside of their UID and commands cannot exceed their UID's permissions. These restrictions are enforced by FW. This mechanism has long been used in RDMA for the devx interface where RDMA will sent commands directly to the FW and the UID limitations restrict those commands to a ib_device/verbs security domain. For instance commands that would effect other VFs, or global device resources. The model is suitable for unprivileged userspace to operate the RDMA functionality. The UID has been extended with a "tools resources" permission which allows additional commands and sub-commands that are intended to match with the scope limitations set in FWCTL. This is an alternative design to the "command intent log" where the FW does the enforcement rather than having the FW report the enforcement the kernel should do. Consistent with the fwctl definitions the "tools resources" security context is limited to the FWCTL_RPC_CONFIGURATION, FWCTL_RPC_DEBUG_READ_ONLY, FWCTL_RPC_DEBUG_WRITE, and FWCTL_RPC_DEBUG_WRITE_FULL security scopes. Like RDMA devx, each opened fwctl file descriptor will get a unique UID associated with each file descriptor. The fwctl driver is kept simple and we reject commands that can create objects as the UID mechanism relies on the kernel to track and destroy objects prior to detroying the UID. Filtering into fwctl sub scopes is done inside the driver with a switch statement. This substantially limits what is possible to primarily query functions ad a few limited set operations. mlx5 already has a robust infrastructure for delivering RPC messages to fw. Trivially connect fwctl's RPC mechanism to mlx5_cmd_do(). Enforce the User Context ID in every RPC header accepted from the FD so the FW knows the security context of the issuing ID. Link: https://patch.msgid.link/r/7-v5-642aa0c94070+4447f-fwctl_jgg@nvidia.com Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com> Reviewed-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Benjamin Poirier <bpoirier@redhat.com>
1 parent 339736a commit 5f91f2f

File tree

9 files changed

+476
-0
lines changed

9 files changed

+476
-0
lines changed

Documentation/userspace-api/fwctl/fwctl.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ fwctl User API
149149
==============
150150

151151
.. kernel-doc:: include/uapi/fwctl/fwctl.h
152+
.. kernel-doc:: include/uapi/fwctl/mlx5.h
152153

153154
sysfs Class
154155
-----------

MAINTAINERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7986,6 +7986,13 @@ F: drivers/fwctl/
79867986
F: include/linux/fwctl.h
79877987
F: include/uapi/fwctl/
79887988

7989+
FWCTL MLX5 DRIVER
7990+
M: Saeed Mahameed <saeedm@nvidia.com>
7991+
R: Itay Avraham <itayavr@nvidia.com>
7992+
L: linux-kernel@vger.kernel.org
7993+
S: Maintained
7994+
F: drivers/fwctl/mlx5/
7995+
79897996
GATEWORKS SYSTEM CONTROLLER (GSC) DRIVER
79907997
M: Tim Harvey <tharvey@gateworks.com>
79917998
M: Robert Jones <rjones@gateworks.com>

drivers/fwctl/Kconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,17 @@ menuconfig FWCTL
77
support a wide range of lockdown compatible device behaviors including
88
manipulating device FLASH, debugging, and other activities that don't
99
fit neatly into an existing subsystem.
10+
11+
if FWCTL
12+
config FWCTL_MLX5
13+
tristate "mlx5 ConnectX control fwctl driver"
14+
depends on MLX5_CORE
15+
help
16+
MLX5 provides interface for the user process to access the debug and
17+
configuration registers of the ConnectX hardware family
18+
(NICs, PCI switches and SmartNIC SoCs).
19+
This will allow configuration and debug tools to work out of the box on
20+
mainstream kernel.
21+
22+
If you don't know what to do here, say N.
23+
endif

drivers/fwctl/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# SPDX-License-Identifier: GPL-2.0
22
obj-$(CONFIG_FWCTL) += fwctl.o
3+
obj-$(CONFIG_FWCTL_MLX5) += mlx5/
34

45
fwctl-y += main.o

drivers/fwctl/mlx5/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
obj-$(CONFIG_FWCTL_MLX5) += mlx5_fwctl.o
3+
4+
mlx5_fwctl-y += main.o

0 commit comments

Comments
 (0)