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 with ibv_open_device() before calling ibv_free_device_list(). Once it frees the array with ibv_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