[PATCH v6 fwctl 0/2] fwctl/bnxt: DMA buffer support for HWRM commands
Pavan Chebbi <[email protected]>
| Newsgroups | org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
Several HWRM (HardWare Resource Manager) commands used for diagnostics, firmware management, and NVM access carry one or more DMA address fields in their input structures. Until now these commands could not be issued through the fwctl interface because the driver had no mechanism to safely broker the host-side DMA buffers on userspace's behalf. This series adds that mechanism in three steps. In patch #1, the fwctl core UAPI adds a new driver_data field in struct fwctl_rpc. Drivers that need a driver_data payload receive the value and are free to interpret it. Drivers that do not define one will reject any non-zero value with -EOPNOTSUPP. Existing mlx5 and pds fwctl drivers are updated accordingly. In patch #2, the bnxt HSI header is updated to add the missing struct definitions for the HWRM commands that the bnxt fwctl driver will support. In patch #3, the bnxt fwctl driver consumes driver_data as a pointer to a new bnxt UAPI struct fwctl_bnxt_driver_data, which describes indirect DMA buffers. v6: Addressed additional comments from Jason as follows: - Look up each DMA command's required scope from the descriptor table - Fix type punning of a __le64 pointer over a __le32[2] struct field - Change loop counters to unsigned int - Optimize a manual length calculation with check_mul_overflow() - Require the request length to exactly match the expected struct size - Remove the separate userspace buffer descriptor uAPI entirely. This also helps drop the first patch of v5, making driver_data unnecessary - Replace the verbose descriptor table with a small set of macros v5: In patch #3, addressed the issues found by sashiko and Jason as follows: - Simplify the DMA buffer uAPI: drop the len field from struct fwctl_bnxt_buf. The driver will derive each buffer's required length from the HWRM command itself, either the transfer-length field named in the request, or a fixed/maximum size. - Tighten the condition to do a exact match for the DMA buffers' count - Validate in_len against each command's actual HWRM input struct size - Switch DMA bounce buffers from kvzalloc() + dma_map_single() to dma_alloc_coherent() - Use kvzalloc() instead of kzalloc() for response buffer - Reduce FWCTL_BNXT_MAX_DMABUF to 64k as that is sufficient for the commands we are supporting v4: Collected Rb tag from Dave for patch #1. Thanks Dave v3: In patch #3, remove include of linux/sizes.h from UAPI header bnxt.h v2: In patch #1, update all the drivers that implement fw_rpc to check driver_data. In patch #2, add another HWRM command that I had missed in v1. In patch #3, update the allow-list and timeout tables for the additional commands. Pavan Chebbi (2): bnxt_en: Update bnxt firmware spec fwctl/bnxt: add DMA buffer support for HWRM commands drivers/fwctl/bnxt/main.c | 396 +++++++++++++++++++++++++- include/linux/bnxt/hsi.h | 585 ++++++++++++++++++++++++++++++++++++++ include/uapi/fwctl/bnxt.h | 4 + 3 files changed, 980 insertions(+), 5 deletions(-) -- 2.52.0