Skip to content

Commit

Permalink
virtio: Add transport feature handling stub for virtio_ring.
Browse files Browse the repository at this point in the history
To prepare for virtio_ring transport feature bits, hook in a call in
all the users to manipulate them.  This currently just clears all the
bits, since it doesn't understand any features.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Jul 25, 2008
1 parent c624896 commit e34f872
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/lguest/lguest_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ static void lg_finalize_features(struct virtio_device *vdev)
/* Second half of bitmap is features we accept. */
u8 *out_features = lg_features(desc) + desc->feature_len;

/* Give virtio_ring a chance to accept features. */
vring_transport_features(vdev);

memset(out_features, 0, desc->feature_len);
bits = min_t(unsigned, desc->feature_len, sizeof(vdev->features)) * 8;
for (i = 0; i < bits; i++) {
Expand Down
3 changes: 3 additions & 0 deletions drivers/s390/kvm/kvm_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ static void kvm_finalize_features(struct virtio_device *vdev)
/* Second half of bitmap is features we accept. */
u8 *out_features = kvm_vq_features(desc) + desc->feature_len;

/* Give virtio_ring a chance to accept features. */
vring_transport_features(vdev);

memset(out_features, 0, desc->feature_len);
bits = min_t(unsigned, desc->feature_len, sizeof(vdev->features)) * 8;
for (i = 0; i < bits; i++) {
Expand Down
3 changes: 3 additions & 0 deletions drivers/virtio/virtio_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ static void vp_finalize_features(struct virtio_device *vdev)
{
struct virtio_pci_device *vp_dev = to_vp_device(vdev);

/* Give virtio_ring a chance to accept features. */
vring_transport_features(vdev);

/* We only support 32 feature bits. */
BUILD_BUG_ON(ARRAY_SIZE(vdev->features) != 1);
iowrite32(vdev->features[0], vp_dev->ioaddr+VIRTIO_PCI_GUEST_FEATURES);
Expand Down
16 changes: 16 additions & 0 deletions drivers/virtio/virtio_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
#include <linux/virtio.h>
#include <linux/virtio_ring.h>
#include <linux/virtio_config.h>
#include <linux/device.h>

#ifdef DEBUG
Expand Down Expand Up @@ -323,4 +324,19 @@ void vring_del_virtqueue(struct virtqueue *vq)
}
EXPORT_SYMBOL_GPL(vring_del_virtqueue);

/* Manipulates transport-specific feature bits. */
void vring_transport_features(struct virtio_device *vdev)
{
unsigned int i;

for (i = VIRTIO_TRANSPORT_F_START; i < VIRTIO_TRANSPORT_F_END; i++) {
switch (i) {
default:
/* We don't understand this bit. */
clear_bit(i, vdev->features);
}
}
}
EXPORT_SYMBOL_GPL(vring_transport_features);

MODULE_LICENSE("GPL");
2 changes: 2 additions & 0 deletions include/linux/virtio_ring.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ struct virtqueue *vring_new_virtqueue(unsigned int num,
void (*notify)(struct virtqueue *vq),
void (*callback)(struct virtqueue *vq));
void vring_del_virtqueue(struct virtqueue *vq);
/* Filter out transport-specific feature bits. */
void vring_transport_features(struct virtio_device *vdev);

irqreturn_t vring_interrupt(int irq, void *_vq);
#endif /* __KERNEL__ */
Expand Down

0 comments on commit e34f872

Please sign in to comment.