Midpath channels (MPCs) are rings for hardware control paths. These control paths are used to offload kTLS directly to the hardware without going through firmware. This patch adds the basic information structures for these MPCs. An MPC is basically a TX and completion ring pair with a HW TLS block as the destination. Two MPC channel types are used to offload connections to the TX crypto engine (TCE) and the RX crypto engine (RCE) respectively. In the driver, we re-use the bnxt_tx_ring_info and bnxt_cp_ring_info control structs for the MPCs. This patch also adds the CONFIG_BNXT_TLS Kconfig option to conditionally include the MPC logic. The first few patches in the series add the MPC support. kTLS support will be added later in the series. Reviewed-by: Ajit Khaparde Reviewed-by: Kalesh AP Reviewed-by: Andy Gospodarek Reviewed-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/Kconfig | 9 ++++ drivers/net/ethernet/broadcom/bnxt/Makefile | 1 + drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++++ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 + drivers/net/ethernet/broadcom/bnxt/bnxt_mpc.c | 26 ++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_mpc.h | 47 +++++++++++++++++++ 6 files changed, 93 insertions(+) create mode 100644 drivers/net/ethernet/broadcom/bnxt/bnxt_mpc.c create mode 100644 drivers/net/ethernet/broadcom/bnxt/bnxt_mpc.h diff --git a/drivers/net/ethernet/broadcom/Kconfig b/drivers/net/ethernet/broadcom/Kconfig index 4287edc7ddd6..0114760c3ac4 100644 --- a/drivers/net/ethernet/broadcom/Kconfig +++ b/drivers/net/ethernet/broadcom/Kconfig @@ -254,6 +254,15 @@ config BNXT_HWMON Say Y if you want to expose the thermal sensor data on NetXtreme-C/E devices, via the hwmon sysfs interface. +config BNXT_TLS + bool "Broadcom NetXtreme-C/E TLS offload support" + default y + depends on BNXT && TLS_DEVICE + depends on TLS=y || BNXT=m + help + Say Y if you want to enable Transport Layer Security (TLS) hardware + encryption and decryption offload on supported NetXtreme-C/E devices. + config BNGE tristate "Broadcom ThorUltra Ethernet device support" depends on PCI diff --git a/drivers/net/ethernet/broadcom/bnxt/Makefile b/drivers/net/ethernet/broadcom/bnxt/Makefile index debef78c8b6d..0506574c007a 100644 --- a/drivers/net/ethernet/broadcom/bnxt/Makefile +++ b/drivers/net/ethernet/broadcom/bnxt/Makefile @@ -5,3 +5,4 @@ bnxt_en-y := bnxt.o bnxt_hwrm.o bnxt_sriov.o bnxt_ethtool.o bnxt_dcb.o bnxt_ulp. bnxt_en-$(CONFIG_BNXT_FLOWER_OFFLOAD) += bnxt_tc.o bnxt_en-$(CONFIG_DEBUG_FS) += bnxt_debugfs.o bnxt_en-$(CONFIG_BNXT_HWMON) += bnxt_hwmon.o +bnxt_en-$(CONFIG_BNXT_TLS) += bnxt_mpc.o diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 945a86696f2f..06d0c82b4022 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -76,6 +76,7 @@ #include "bnxt_hwmon.h" #include "bnxt_gso.h" #include +#include "bnxt_mpc.h" #define BNXT_TX_TIMEOUT (5 * HZ) #define BNXT_DEF_MSG_ENABLE (NETIF_MSG_DRV | NETIF_MSG_HW | \ @@ -9937,6 +9938,11 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp) } bp->tso_max_segs = le16_to_cpu(resp->max_tso_segs); + if (resp->mpc_chnls_cap) + bnxt_alloc_mpc_info(bp, resp->mpc_chnls_cap); + else + bnxt_free_mpc_info(bp); + hwrm_func_qcaps_exit: hwrm_req_drop(bp, req); return rc; @@ -16485,6 +16491,7 @@ static void bnxt_remove_one(struct pci_dev *pdev) bp->ptp_cfg = NULL; kfree(bp->fw_health); bp->fw_health = NULL; + bnxt_free_mpc_info(bp); bnxt_cleanup_pci(bp); bnxt_free_ctx_mem(bp, true); bnxt_free_crash_dump_mem(bp); @@ -17156,6 +17163,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) bnxt_ethtool_free(bp); kfree(bp->fw_health); bp->fw_health = NULL; + bnxt_free_mpc_info(bp); bnxt_cleanup_pci(bp); bnxt_free_ctx_mem(bp, true); bnxt_free_crash_dump_mem(bp); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 61c847b36b9f..ab88d96f807c 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2451,6 +2451,8 @@ struct bnxt { u8 tph_mode; + struct bnxt_mpc_info *mpc_info; + unsigned int current_interval; #define BNXT_TIMER_INTERVAL HZ diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_mpc.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_mpc.c new file mode 100644 index 000000000000..86087e538550 --- /dev/null +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_mpc.c @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright (c) 2026 Broadcom Inc. */ + +#include +#include +#include +#include + +#include "bnxt.h" +#include "bnxt_mpc.h" + +void bnxt_alloc_mpc_info(struct bnxt *bp, u8 mpc_chnls_cap) +{ + if (!bp->mpc_info) + bp->mpc_info = kzalloc_obj(*bp->mpc_info); + if (bp->mpc_info) + bp->mpc_info->mpc_chnls_cap = mpc_chnls_cap; + else + netdev_warn(bp->dev, "Unable to allocate MPC info\n"); +} + +void bnxt_free_mpc_info(struct bnxt *bp) +{ + kfree(bp->mpc_info); + bp->mpc_info = NULL; +} diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_mpc.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_mpc.h new file mode 100644 index 000000000000..cd3f268a3a29 --- /dev/null +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_mpc.h @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (c) 2026 Broadcom Inc. */ + +#ifndef BNXT_MPC_H +#define BNXT_MPC_H + +/* Mid path channel (MPC) definitions. An MPC is special TX/completion + * ring pair to send/receive control plane data to the TCE and RCE + * (Transmit/Receive Crypto Engine) HW blocks. + */ + +enum bnxt_mpc_type { + BNXT_MPC_TCE_TYPE = RING_ALLOC_REQ_MPC_CHNLS_TYPE_TCE, + BNXT_MPC_RCE_TYPE = RING_ALLOC_REQ_MPC_CHNLS_TYPE_RCE, + BNXT_MPC_TYPE_MAX, +}; + +#define BNXT_MAX_MPC 8 + +struct bnxt_mpc_info { + u8 mpc_chnls_cap; + u8 mpc_cp_rings; + u8 mpc_ring_count[BNXT_MPC_TYPE_MAX]; + struct bnxt_tx_ring_info *mpc_rings[BNXT_MPC_TYPE_MAX]; +}; + +#define BNXT_MPC_CRYPTO_CAP \ + (FUNC_QCAPS_RESP_MPC_CHNLS_CAP_TCE | FUNC_QCAPS_RESP_MPC_CHNLS_CAP_RCE) + +#define BNXT_MPC_CRYPTO_CAPABLE(bp) \ + ((bp)->mpc_info ? \ + ((bp)->mpc_info->mpc_chnls_cap & BNXT_MPC_CRYPTO_CAP) == \ + BNXT_MPC_CRYPTO_CAP : false) + +#ifdef CONFIG_BNXT_TLS +void bnxt_alloc_mpc_info(struct bnxt *bp, u8 mpc_chnls_cap); +void bnxt_free_mpc_info(struct bnxt *bp); +#else +static inline void bnxt_alloc_mpc_info(struct bnxt *bp, u8 mpc_chnls_cap) +{ +} + +static inline void bnxt_free_mpc_info(struct bnxt *bp) +{ +} +#endif /* CONFIG_BNXT_TLS */ +#endif /* BNXT_MPC_H */ -- 2.51.0