Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

virtio.h: add some user-friendly apis #622

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

CV-Bowen
Copy link
Contributor

@CV-Bowen CV-Bowen commented Oct 8, 2024

  • virtio.h: add new api virtio_has_feature()
virtio_has_feature() can be easily used to heck if the virtio device
support a specific feature.

And assgin feature to vdev->feature for virtio device role when get
features, so the virtio device side can use virtio_has_featrue() to
check weather the virtio device support a feature.
  • virtio.h: add new feature bit VIRTIO_F_ANY_LAYOUT
Follow the virtio spec, this feature bit indicates that the device
accepts arbitrary descriptor layouts.

@CV-Bowen CV-Bowen force-pushed the virtio-config branch 2 times, most recently from 0d9c1ce to c1646fb Compare October 8, 2024 13:41
@CV-Bowen CV-Bowen force-pushed the virtio-config branch 4 times, most recently from 217ee1d to 56c5db1 Compare October 10, 2024 02:59
@CV-Bowen
Copy link
Contributor Author

@arnopo Hi, I meet a CI issue:

#define virtio_read_config_member(vdev, structname, member, _ptr) \
	virtio_read_config((vdev), metal_offset_of(structname, member), \
			   _ptr, sizeof(*(_ptr)))

This code reports MACRO_ARG_REUSE: Macro argument reuse '_ptr' - possible side-effects?
So can we use typeof to avoid this issue?

return false;

return (vdev->features & (1UL << feature_bit)) != 0;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function return valid value only if virtio_negotiate_features has been called first . That also means that it does not work for virtio device role.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I consider assign back the final features to vdev->features when call virtio_get_feature() for VIRTIO_DEVICE side, so VIRTIO_DEVICE can use this virtio_has_feature() after called virtio_get_feature(). What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, @arnopo Could you review again?

lib/include/openamp/virtio.h Outdated Show resolved Hide resolved
lib/include/openamp/virtio.h Outdated Show resolved Hide resolved
@CV-Bowen CV-Bowen force-pushed the virtio-config branch 2 times, most recently from 60c1fc3 to 3cb3e9c Compare October 18, 2024 11:24
@CV-Bowen
Copy link
Contributor Author

@glneo @arnopo Please review again.

Follow the virtio spec, this feature bit indicates that the device
accepts arbitrary descriptor layouts.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
virtio_has_feature() can be easily used to heck if the virtio device
support a specific feature.

And assgin feature to vdev->feature for virtio device role when get
features, so the virtio device side can use virtio_has_featrue() to
check weather the virtio device support a feature.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
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.

4 participants