Skip to content

drivers: hv: use new api for channel callbacks with hv drivers #6

Draft
rlmenge wants to merge 4 commits intorust-nextfrom
rlmenge/hyper-v/rust-prep
Draft

drivers: hv: use new api for channel callbacks with hv drivers #6
rlmenge wants to merge 4 commits intorust-nextfrom
rlmenge/hyper-v/rust-prep

Conversation

@rlmenge
Copy link
Copy Markdown
Owner

@rlmenge rlmenge commented Jun 14, 2024

This patchset introduces new function apis for "vmbus_open" and "vmbus_connect_ring". The current api passes the channel as a part of the context. The new functions add an additional parameter for the vmbus channel explicitly. This new function api is in preparation for Rust integration.

Rust code is built to create sound code blocks and to prevent the user from ever entering into undefined behavior. Rust will need a new type state to prevent writing and reading from channels which are not yet open. However, this requires the channel to be separate from the context as the channel may not have been opened yet.

An implementation of this can be seen at https://github.com/wedsonaf/linux/tree/hv

Background
vmbus_channel is given callback function by __vmbus_open
__vmbus_open called by vmbus_open
drvier -> vmbus_add_channel_work -> vmbus_open -> __vmbus_open -> sets channel callback function

API changes
vmbus_open -> vmbus_open_channel
vmbus_connect_ring -> vmbus_connect_ring_channel

internal function changes during trasnsition

  • __vmbus_open

    • accepts a boolean on if it should use the v1 callback api
  • vmbus_channel struct

    • original callback function renamed to onchannel_callback_v1
      void (*onchannel_callback)(void *context); -> void (*onchannel_callback_v1)(void *context);
    • added new callback function which requires context and channel
      typedef void onchannel_t(void *context, struct vmbus_channel *chan);
      void (*onchannel_callback_v1)(void *context);

Checks:

  • Builds with CONFIG_HYPERV
  • Builds without CONFIG_HYPERV

TODO

  • clean up commits to have full messages
  • cleanup printks
  • clean up comments in code (still reference vmbus_open)
  • add comments in code when introducing transition code which later needs to be cleaned up
  • run tests without hyperv-modules enabled
  • run patch cleanup tools
  • send to linux-hyperv

rlmenge and others added 4 commits June 14, 2024 04:52
callbacks today use context to pass around channels.
However, this allows for channels to be openned when these
callbacks are established. Introduce new api which requires
the channel explicitly.
vmbus_open and vmbus_connect_ring have been replaced by
vmbus_open_channel and vmbus_connect_ring_channel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant