rte_vhost_device_ops(3)

πŸ“¦ version 26.03, in nixos 26.05, nixpkgs unstable

πŸ¦‹ rte_vhost_device_ops(3) β€” the vhost device ops struct, explained bestie

Okay so real talk, this is the rte_vhost_device_ops struct from the DPDK library manual, and it's literally the whole personality of your vhost device πŸ’…


✨ NAME ✨

rte_vhost_device_ops β€” no cap, that's the name, that's the vibe 🌸


πŸŽ€ SYNOPSIS πŸŽ€

#include <rte_vhost.h>

🌈 Data Fields

So here's the squad β€” all six function pointers, exactly as they live in the struct:

  • int(* new_device )(int vid)
  • void(* destroy_device )(int vid)
  • int(* vring_state_changed )(int vid, uint16_t queue_id, int enable)
  • int(* features_changed )(int vid, uint64_t features)
  • void(* guest_notified )(int vid)
  • bool(* guest_notify )(int vid, uint16_t queue_id)

πŸ’– Detailed Description πŸ’–

Device and vring operations. That's it, that's the whole thing β€” this struct is the collection of callbacks your app gets to hook into for device + vring events πŸ‘‘

Fr fr, the definition lives at line 277 of file rte_vhost.h β€” go look, it's right there 🫢

🌟 Field Documentation 🌟

πŸ“ int(* new_device) (int vid)

Add device. New device just dropped, tell the app πŸ“₯

Definition at line 278 of file rte_vhost.h.

πŸ’€ void(* destroy_device) (int vid)

Remove device. Device said bye, tell the app πŸ“€

Definition at line 279 of file rte_vhost.h.

✨ int(* vring_state_changed) (int vid, uint16_t queue_id, int enable)

Triggered when a vring is enabled or disabled. Like a little status ping for your virtqueue, iykyk πŸ””

Definition at line 281 of file rte_vhost.h.

🧚 int(* features_changed) (int vid, uint64_t features)

Features could be changed after the feature negotiation. For example, VHOST_F_LOG_ALL will be set/cleared at the start/end of live migration, respectively. This callback is used to inform the application on such change.

So yeah β€” feature negotiation finishes, and then stuff can still shift under you. VHOST_F_LOG_ALL gets set at the start of live migration and cleared at the end (respectively, bestie, pay attention to the order 😭). This callback is literally how the app finds out about it.

Definition at line 289 of file rte_vhost.h.

πŸŽ€ void(* guest_notified) (int vid)

This callback gets called each time a guest gets notified about waiting packets. This is the interrupt handling through the eventfd_write(callfd), which can be used for counting these "slow" syscalls.

Translation: every single guest notification about waiting packets = one callback, and behind it is an interrupt handled via eventfd_write(callfd). Those are the "slow" syscalls, and this hook is where you can count them 🐌

Definition at line 300 of file rte_vhost.h.

πŸ‘‘ bool(* guest_notify) (int vid, uint16_t queue_id)

If this callback is registered, notification to the guest can be handled by the front-end calling rte_vhost_notify_guest(). If it's not handled, 'false' should be returned. This can be used to remove the "slow" eventfd_write() syscall from the datapath.

So like β€” register it and the front-end can handle guest notification itself by calling rte_vhost_notify_guest(). If you don't handle it, return 'false', periodt. The whole point? Yeeting that "slow" eventfd_write() syscall right out of the datapath πŸ”₯

Definition at line 308 of file rte_vhost.h.


πŸ’œ Author πŸ’œ

Generated automatically by Doxygen for DPDK from the source code. Not a human, just Doxygen doing its little automagic thing πŸ€–βœ¨


That's the whole page, bestie β€” every field, every line number, every syscall, nothing skipped πŸ’…

Okay bye, this was rte_vhost_device_ops(3) from DPDK, Version 26.03.0 β€” dated with that rte_vhost_device_ops(3) footer energy. Go slay your vhost callbacks πŸ¦‹πŸ’–

πŸ“¦ where this page comes from