vfio/mlx5: Rewrite create mkey flow to allow better code reuse
authorLeon Romanovsky <leonro@nvidia.com>
Tue, 20 May 2025 13:46:31 +0000 (16:46 +0300)
committerAlex Williamson <alex.williamson@redhat.com>
Tue, 20 May 2025 14:32:07 +0000 (08:32 -0600)
commitac6c973a480bcbd1161974b6b8ec6fd12e87b506
treeac4366e7ef78c0f05c9560e22aae7ae5d9edabf0
parent674ebb64cd5dc40827b8ac8c95bb72d328ed59ff
vfio/mlx5: Rewrite create mkey flow to allow better code reuse

Change the creation of mkey to be performed in multiple steps:
data allocation, DMA setup and actual call to HW to create that mkey.

In this new flow, the whole input to MKEY command is saved to eliminate
the need to keep array of pointers for DMA addresses for receive list
and in the future patches for send list too.

In addition to memory size reduce and elimination of unnecessary data
movements to set MKEY input, the code is prepared for future reuse.

Tested-by: Jens Axboe <axboe@kernel.dk>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Acked-by: Yishai Hadas <yishaih@nvidia.com>
Link: https://lore.kernel.org/r/d4ad0384fbd1e23a607cbbe9e5756748f3a761d9.1747747694.git.leon@kernel.org
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/pci/mlx5/cmd.c
drivers/vfio/pci/mlx5/cmd.h