Commit aff5b0e6 authored by Xuan Zhuo's avatar Xuan Zhuo Committed by Paolo Abeni

virtio_net: introduce ability to get reply info from device

As the spec https://github.com/oasis-tcs/virtio-spec/commit/42f389989823039724f95bbbd243291ab0064f82

Based on the description provided in the above specification, we have
enabled the virtio-net driver to support acquiring some response
information from the device via the CVQ (Control Virtqueue).
Signed-off-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent dd1941f8
...@@ -2527,11 +2527,12 @@ static int virtnet_tx_resize(struct virtnet_info *vi, ...@@ -2527,11 +2527,12 @@ static int virtnet_tx_resize(struct virtnet_info *vi,
* supported by the hypervisor, as indicated by feature bits, should * supported by the hypervisor, as indicated by feature bits, should
* never fail unless improperly formatted. * never fail unless improperly formatted.
*/ */
static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd, static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd,
struct scatterlist *out) struct scatterlist *out,
struct scatterlist *in)
{ {
struct scatterlist *sgs[4], hdr, stat; struct scatterlist *sgs[5], hdr, stat;
unsigned out_num = 0, tmp; u32 out_num = 0, tmp, in_num = 0;
int ret; int ret;
/* Caller should know better */ /* Caller should know better */
...@@ -2549,10 +2550,13 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd, ...@@ -2549,10 +2550,13 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
/* Add return status. */ /* Add return status. */
sg_init_one(&stat, &vi->ctrl->status, sizeof(vi->ctrl->status)); sg_init_one(&stat, &vi->ctrl->status, sizeof(vi->ctrl->status));
sgs[out_num] = &stat; sgs[out_num + in_num++] = &stat;
BUG_ON(out_num + 1 > ARRAY_SIZE(sgs)); if (in)
ret = virtqueue_add_sgs(vi->cvq, sgs, out_num, 1, vi, GFP_ATOMIC); sgs[out_num + in_num++] = in;
BUG_ON(out_num + in_num > ARRAY_SIZE(sgs));
ret = virtqueue_add_sgs(vi->cvq, sgs, out_num, in_num, vi, GFP_ATOMIC);
if (ret < 0) { if (ret < 0) {
dev_warn(&vi->vdev->dev, dev_warn(&vi->vdev->dev,
"Failed to add sgs for command vq: %d\n.", ret); "Failed to add sgs for command vq: %d\n.", ret);
...@@ -2574,6 +2578,12 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd, ...@@ -2574,6 +2578,12 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
return vi->ctrl->status == VIRTIO_NET_OK; return vi->ctrl->status == VIRTIO_NET_OK;
} }
static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
struct scatterlist *out)
{
return virtnet_send_command_reply(vi, class, cmd, out, NULL);
}
static int virtnet_set_mac_address(struct net_device *dev, void *p) static int virtnet_set_mac_address(struct net_device *dev, void *p)
{ {
struct virtnet_info *vi = netdev_priv(dev); struct virtnet_info *vi = netdev_priv(dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment