Skip to content

Commit

Permalink
virtio: fix return type of get_driver_features()
Browse files Browse the repository at this point in the history
The virtio spec defines the features field to be 64 bits. The lower
parts of the virtio drivers (virtio::virtio_driver) treated it as such,
but the interface for each specific driver to override the feature bits
(virtio::virtio_driver::get_driver_features()) limited that to 32 bits
only. This patch rectifies it, changing the function's signature and all
overrides in the various drivers.

Signed-off-by: Fotis Xenakis <[email protected]>
Message-Id: <AM0PR03MB62923C5820454DC1B9887D9AA6EF0@AM0PR03MB6292.eurprd03.prod.outlook.com>
  • Loading branch information
foxeng authored and wkozaczuk committed Nov 8, 2020
1 parent ec8d020 commit 571e8f2
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion drivers/virtio-blk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ int blk::make_request(struct bio* bio)
}
}

u32 blk::get_driver_features()
u64 blk::get_driver_features()
{
auto base = virtio_driver::get_driver_features();
return (base | ( 1 << VIRTIO_BLK_F_SIZE_MAX)
Expand Down
2 changes: 1 addition & 1 deletion drivers/virtio-blk.hh
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public:
virtual std::string get_name() const { return _driver_name; }
void read_config();

virtual u32 get_driver_features();
virtual u64 get_driver_features();

int make_request(struct bio*);

Expand Down
4 changes: 2 additions & 2 deletions drivers/virtio-net.cc
Original file line number Diff line number Diff line change
Expand Up @@ -900,9 +900,9 @@ void net::txq::gc()
vqueue->get_buf_gc();
}

u32 net::get_driver_features()
u64 net::get_driver_features()
{
u32 base = virtio_driver::get_driver_features();
auto base = virtio_driver::get_driver_features();
return (base | (1 << VIRTIO_NET_F_MAC) \
| (1 << VIRTIO_NET_F_MRG_RXBUF) \
| (1 << VIRTIO_NET_F_STATUS) \
Expand Down
2 changes: 1 addition & 1 deletion drivers/virtio-net.hh
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public:
virtual std::string get_name() const { return _driver_name; }
void read_config();

virtual u32 get_driver_features();
virtual u64 get_driver_features();

void wait_for_queue(vring* queue);
bool bad_rx_csum(struct mbuf* m, struct net_hdr* hdr);
Expand Down
2 changes: 1 addition & 1 deletion drivers/virtio-scsi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ int scsi::make_request(struct bio* bio)
}
}

u32 scsi::get_driver_features()
u64 scsi::get_driver_features()
{
auto base = virtio_driver::get_driver_features();
return base | ( 1 << VIRTIO_SCSI_F_INOUT);
Expand Down
2 changes: 1 addition & 1 deletion drivers/virtio-scsi.hh
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public:
virtual std::string get_name() const { return _driver_name; }
void read_config();

virtual u32 get_driver_features();
virtual u64 get_driver_features();

static struct scsi_priv *get_priv(struct bio *bio) {
return reinterpret_cast<struct scsi_priv*>(bio->bio_dev->private_data);
Expand Down
2 changes: 1 addition & 1 deletion drivers/virtio.hh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public:

protected:
// Actual drivers should implement this on top of the basic ring features
virtual u32 get_driver_features() { return 1 << VIRTIO_RING_F_INDIRECT_DESC | 1 << VIRTIO_RING_F_EVENT_IDX; }
virtual u64 get_driver_features() { return 1 << VIRTIO_RING_F_INDIRECT_DESC | 1 << VIRTIO_RING_F_EVENT_IDX; }
void setup_features();
protected:
virtio_device& _dev;
Expand Down

0 comments on commit 571e8f2

Please sign in to comment.