Skip to content

Commit 52929c2

Browse files
Saeed Mahameedjgunthorpe
authored andcommitted
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/[email protected] Reviewed-by: Jonathan Cameron <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 18285ac commit 52929c2

File tree

8 files changed

+475
-0
lines changed

8 files changed

+475
-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
@@ -9568,6 +9568,13 @@ F: drivers/fwctl/
95689568
F: include/linux/fwctl.h
95699569
F: include/uapi/fwctl/
95709570

9571+
FWCTL MLX5 DRIVER
9572+
M: Saeed Mahameed <[email protected]>
9573+
R: Itay Avraham <[email protected]>
9574+
9575+
S: Maintained
9576+
F: drivers/fwctl/mlx5/
9577+
95719578
GALAXYCORE GC0308 CAMERA SENSOR DRIVER
95729579
M: Sebastian Reichel <[email protected]>
95739580

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)