platform/mellanox: Add mlxbf_pka driver for BlueField DPU
From: | Ron Li <xiangrongl-AT-nvidia.com> | |
To: | <hdegoede-AT-redhat.com>, <ilpo.jarvinen-AT-linux.intel.com>, <vadimp-AT-nvidia.com>, <alok.a.tiwari-AT-oracle.com>, <kblaiech-AT-nvidia.com>, <davthompson-AT-nvidia.com> | |
Subject: | [PATCH v3 0/3] platform/mellanox: Add mlxbf_pka driver for BlueField DPU | |
Date: | Fri, 19 Sep 2025 19:51:29 +0000 | |
Message-ID: | <20250919195132.1088515-1-xiangrongl@nvidia.com> | |
Cc: | <platform-driver-x86-AT-vger.kernel.org>, <linux-kernel-AT-vger.kernel.org>, <linux-crypto-AT-vger.kernel.org>, Ron Li <xiangrongl-AT-nvidia.com> | |
Archive-link: | Article |
This patch series adds the mlxbf_pka driver to support the BlueField DPU Public Key Acceleration (PKA) hardware. The three patches in this series are: Patch 1: Base implementation that wires up the platform driver and the device/shim layer: Patch 2: Add userspace PKA ring device interface. Patch 3: Add True Random Number Generator support to the BlueField PKA driver and wire it into the HWRNG core to feed kernel entropy (/dev/hwrng). Testing: - Kernel builds for ARM64 - Tested ARM64 build on several Mellanox BlueField 2 and 3 SoC boards that include the PKA hardware. - PKA shim devices probe and remove successfully - The PKA ring devices presented at /dev/mlxbf_pka/. - The PKA device validation test passed. - /dev/hwrng present; rng_available lists mlxbf_pka - Generating random numbers succeeds on BlueField platforms Signed-off-by: Ron Li <xiangrongl@nvidia.com> --- v2->v3: - Split the source code into three patches to improve the readability. Each patch introduces new device features and functions. - The latest kernel APIs are used for each patch in the series. - Updated some variable names to improve the readability. - Fixed the logic in the mlxbf_pka_ring_mem_addr() function. - Update all the pr_xxx() to dev_xxx(). Except for one pr_xxx() print when the PKA device is not available yet. v1->v2: For patch 0001: - Move ioctl related definition to include/uapi/linux/mlxbf-pka.h. - Changed the ioctl number from 0xB7 to 0xBF, to avoid conflict with other drivers. - Remove interrupt related code, since the PKA driver uses polling instread of interrupt. - Use devm_kcalloc() to allocate memory with calculated length. - Use read_poll_timeout() to handle infinite loop checking. - Use lockdep_assert_held() to enforce serialization. - Create mlxbf_pka_drv_verify_bootup_status() to handle duplicated code. - Remove error handling in ***_remove_device functions since nothing useful can be done. - Fix the rollbacks in some functions by adding proper goto rollback path. - Updated all comments to under 80 characters per line. - Upgrade some constant with kernel definitions. - Include missing kernel libraries. - Update some pr_xxx() to dev_xxx(). - Use FIELD_PREP and GENMASK to handle mask and offset of register access. - Refactor some code snippet to improve readability. - Update the comments of some functions and type definitions. - The FRO in the source code stands for Free Running Oscillator. - Fix typos. --- Ron Li (3): platform/mellanox/mlxbf_pka: Add core BlueField PKA platform driver platform/mellanox/mlxbf_pka: Add userspace PKA ring device interface platform/mellanox/mlxbf_pka: Add TRNG support and hwrng integration .../ABI/testing/sysfs-platform-mellanox-pka | 35 + .../userspace-api/ioctl/ioctl-number.rst | 2 + MAINTAINERS | 8 + drivers/platform/mellanox/Kconfig | 10 + drivers/platform/mellanox/Makefile | 1 + drivers/platform/mellanox/mlxbf_pka/Makefile | 12 + .../mellanox/mlxbf_pka/mlxbf_pka_dev.c | 481 ++++++++ .../mellanox/mlxbf_pka/mlxbf_pka_dev.h | 327 ++++++ .../mellanox/mlxbf_pka/mlxbf_pka_drv.c | 1016 +++++++++++++++++ .../mellanox/mlxbf_pka/mlxbf_pka_ring.c | 563 +++++++++ .../mellanox/mlxbf_pka/mlxbf_pka_ring.h | 255 +++++ .../mellanox/mlxbf_pka/mlxbf_pka_trng.c | 874 ++++++++++++++ .../mellanox/mlxbf_pka/mlxbf_pka_trng.h | 152 +++ include/uapi/linux/mlxbf-pka.h | 112 ++ 14 files changed, 3848 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-platform-mellanox-pka create mode 100644 drivers/platform/mellanox/mlxbf_pka/Makefile create mode 100644 drivers/platform/mellanox/mlxbf_pka/mlxbf_pka_dev.c create mode 100644 drivers/platform/mellanox/mlxbf_pka/mlxbf_pka_dev.h create mode 100644 drivers/platform/mellanox/mlxbf_pka/mlxbf_pka_drv.c create mode 100644 drivers/platform/mellanox/mlxbf_pka/mlxbf_pka_ring.c create mode 100644 drivers/platform/mellanox/mlxbf_pka/mlxbf_pka_ring.h create mode 100644 drivers/platform/mellanox/mlxbf_pka/mlxbf_pka_trng.c create mode 100644 drivers/platform/mellanox/mlxbf_pka/mlxbf_pka_trng.h create mode 100644 include/uapi/linux/mlxbf-pka.h -- 2.34.1