-
Notifications
You must be signed in to change notification settings - Fork 288
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: add create_virtqueues and delete_virtqueues in virtio_dispatch #495
Conversation
7394743
to
2f4ef16
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy past issue in virtio.h + "deivce" to fix in commit message
2f4ef16
to
d49315b
Compare
you still need to fix the commit message :
|
d49315b
to
668df7e
Compare
@arnopo Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small question.
lib/include/openamp/virtio.h
Outdated
*/ | ||
static inline void virtio_delete_virtqueues(struct virtio_device *vdev) | ||
{ | ||
return vdev->func->delete_virtqueues(vdev); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question, is guaranteed the func
will be always valid here? It would not be good to check for availabillity of this function before calling, also making this way will obligate the implementor of the dispatch functions to provide this function, is this intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes the point is valid. Vdev
, 'vdev->func' and 'vdev->func->delete_virtqueues' should be checked.
@CV-Bowen: It is acceptable for me to do it in a second step as here the main objective is to create the API. It can also be done by updating the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
The @uLipe comment is valid for all the func
. with a return on "-ENXIO" when requestion a return value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arnopo So I change all the virtio_xxx functions return type to int
and call dispatch function in these functions ?
Like:
static inline int virtio_set_status(struct virtio_device *vdev, uint8_t status)
{
if (!vdev->func->set_status)
return -ENXIO;
vdev->func->set_status(vdev, status);
return 0;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CV-Bowen , yes this is the intention, the dispatch functions have a return type, when it is present just return the result of the dispatch functions, taking the example above slightly modified:
static inline int virtio_set_status(struct virtio_device *vdev, uint8_t status)
{
if (!vdev->func->set_status)
return -ENXIO;
else
return vdev->func->set_status(vdev, status);
}
The idea is all the dispatch function templates have an return value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@uLipe Thanks, I found the vdev->func->set_status
return value change to int
(void
for now) in your example code, should I change all the dispatch functions return type to int
? This is a significant change.
static inline int virtio_set_status(struct virtio_device *vdev, uint8_t status)
{
if (!vdev->func->set_status)
return -ENXIO;
else
return vdev->func->set_status(vdev, status);
}
@danmilea |
375fc2c
to
d70af8b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
few suggestions to increase the APi robustness, else LGTM
lib/virtio/virtio.c
Outdated
if (!vdev->func) | ||
return -ENXIO; | ||
|
||
if (vdev->func->create_virtqueues) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to avoid regression on existing code
remove
if (!vdev->func)
return -ENXIO;
instead use if (vdev-> func && vdev->func->create_virtqueues) {
Please could you also add
if (!vdev || !src)
return -EINVAL;
at the beginning of the function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lib/include/openamp/virtio.h
Outdated
*/ | ||
static inline int virtio_get_status(struct virtio_device *vdev, uint8_t *status) | ||
{ | ||
if (!status) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!vdev || !status)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lib/include/openamp/virtio.h
Outdated
static inline int virtio_get_features(struct virtio_device *vdev, | ||
uint32_t *features) | ||
{ | ||
if (!features) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!vdev || !features)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lib/include/openamp/virtio.h
Outdated
uint32_t features, | ||
uint32_t *final_features) | ||
{ | ||
if (!final_features) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!vdev || !final_features)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
This is the first step to decoupling the virtio device and transport layer. Signed-off-by: Bowen Wang <[email protected]>
d70af8b
to
64ef3d9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to merge.
Merged, thanks for the contribution! |
This is the first step to decoupling the virtio deivce and transport layer.
Related issue: #390 (comment)
@arnopo Could take a look?