mlx5dv_get_vfio_device_list(3)
π
mlx5dv_get_vfio_device_list β the mlx5dv girlies' guide to finding your VFIO devices β¨
Okay so bestie, you know how mlx5dv has a whole family of man pages? This is one of them, and it lives in section 3 of the manual. Let me tell you about mlx5dv_get_vfio_device_list π
β¨ NAME β¨
mlx5dv_get_vfio_device_list β get the list of available devices that you can use over VFIO, no cap π
π¦ SYNOPSIS π¦
#include <infiniband/mlx5dv.h>
struct ibv_device **
mlx5dv_get_vfio_device_list(struct mlx5dv_vfio_context_attr *attr);
πΈ DESCRIPTION πΈ
So basically it returns a NULL-terminated array of devices, and which devices show up in that array is decided by the input attr. That's it, that's the vibe. Simple, iconic, does exactly what it says on the tin π
π ARGUMENTS π
attrβ describes which VFIO devices you want back in the list. Like a little wishlist but for devices π«Ά
π§ the attr argument, up close
struct mlx5dv_vfio_context_attr {
const char *pci_name;
uint32_t flags;
uint64_t comp_mask;
};
pci_nameβ the PCI name of the device you actually want. Yes, the real one, be specific πflagsβ a bitwise OR of the various values listed below. Stack 'em up with|like the icon you are β¨MLX5DV_VFIO_CTX_FLAGS_INIT_LINK_DOWN: when the device initializes, the link should stay down. Fr fr, it stays down on purpose π
comp_maskβ a bitmask specifying which fields in the structure are actually valid. It's the "only pay attention to these ones" field, iykyk π
π RETURN VALUE π
Returns the array of the matching devices π β or, if the request fails, it sets errno and returns NULL. So yeah, always check for NULL, bestie, don't just vibe forward and assume π
π₯ NOTES π₯
Heads up! Client code should open all the devices it intends to use withibv_open_device()before callingibv_free_device_list(). Once it frees the array withibv_free_device_list(), it will be able to use only the open devices β pointers to unopened devices will no longer be valid. Not "might not", not "probably", they're just gone ππ¦
So like, open first, free second. Order matters. The way that this is genuinely important π
β SEE ALSO β
ibv_open_device(3) ibv_free_device_list(3) β go read these too, they're part of the lore π«
πΊ AUTHOR πΊ
Yishai Hadas <yishaih@nvidia.com> π
and that's the whole page, bestie!! π«Ά this one comes to you from the mlx5dv_get_vfio_device_list(3) manual page π
go forth and slay your VFIO device lists β¨
π¦ where this page comes from
- alpine 3.24: rdma-core-doc 61.0-r0 Β· GPL-2.0-only OR BSD-2-Clause
- centos-stream 10: rdma-core-devel 62.0-3.el10 Β· GPLv2 or BSD
- centos-stream 9: rdma-core-devel 61.0-3.el9 Β· GPLv2 or BSD
- centos-stream 9: rdma-core-devel 61.0-3.el9 Β· GPLv2 or BSD
- ubuntu jammy: libibverbs-dev 39.0-1 Β· BSD-MIT OR GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms