Message ID | 20240423084226.25440-2-hengqi@linux.alibaba.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | virtio_net: support getting initial value of irq coalesce | expand |
Tue, Apr 23, 2024 at 10:42:25AM CEST, hengqi@linux.alibaba.com wrote: >From: Xuan Zhuo <xuanzhuo@linux.alibaba.com> > >As the spec https://github.com/oasis-tcs/virtio-spec/commit/42f389989823039724f95bbbd243291ab0064f82 > >The virtnet cvq supports to get result from the device. Is this a statement about current status, cause it sounds so. Could you make it clear by changing the patch subject and description to use imperative mood please. Command the codebase what to do. Thanks! > >Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> >--- > drivers/net/virtio_net.c | 24 +++++++++++++++++------- > 1 file changed, 17 insertions(+), 7 deletions(-) > >diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c >index 7176b956460b..3bc9b1e621db 100644 >--- a/drivers/net/virtio_net.c >+++ b/drivers/net/virtio_net.c >@@ -2527,11 +2527,12 @@ static int virtnet_tx_resize(struct virtnet_info *vi, > * supported by the hypervisor, as indicated by feature bits, should > * never fail unless improperly formatted. > */ >-static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd, >- struct scatterlist *out) >+static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd, >+ struct scatterlist *out, >+ struct scatterlist *in) > { >- struct scatterlist *sgs[4], hdr, stat; >- unsigned out_num = 0, tmp; >+ struct scatterlist *sgs[5], hdr, stat; >+ u32 out_num = 0, tmp, in_num = 0; > int ret; > > /* Caller should know better */ >@@ -2549,10 +2550,13 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd, > > /* Add return 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)); >- ret = virtqueue_add_sgs(vi->cvq, sgs, out_num, 1, vi, GFP_ATOMIC); >+ if (in) >+ 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) { > dev_warn(&vi->vdev->dev, > "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, > 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) > { > struct virtnet_info *vi = netdev_priv(dev); >-- >2.32.0.3.g01195cf9f > >
在 2024/4/23 下午6:17, Jiri Pirko 写道: > Tue, Apr 23, 2024 at 10:42:25AM CEST, hengqi@linux.alibaba.com wrote: >> From: Xuan Zhuo <xuanzhuo@linux.alibaba.com> >> >> As the spec https://github.com/oasis-tcs/virtio-spec/commit/42f389989823039724f95bbbd243291ab0064f82 >> >> The virtnet cvq supports to get result from the device. > Is this a statement about current status, cause it sounds so. Could you > make it clear by changing the patch subject and description to use > imperative mood please. Command the codebase what to do. Sure. Will add more text in v2. > > Thanks! > >> Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> >> --- >> drivers/net/virtio_net.c | 24 +++++++++++++++++------- >> 1 file changed, 17 insertions(+), 7 deletions(-) >> >> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c >> index 7176b956460b..3bc9b1e621db 100644 >> --- a/drivers/net/virtio_net.c >> +++ b/drivers/net/virtio_net.c >> @@ -2527,11 +2527,12 @@ static int virtnet_tx_resize(struct virtnet_info *vi, >> * supported by the hypervisor, as indicated by feature bits, should >> * never fail unless improperly formatted. >> */ >> -static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd, >> - struct scatterlist *out) >> +static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd, >> + struct scatterlist *out, >> + struct scatterlist *in) >> { >> - struct scatterlist *sgs[4], hdr, stat; >> - unsigned out_num = 0, tmp; >> + struct scatterlist *sgs[5], hdr, stat; >> + u32 out_num = 0, tmp, in_num = 0; >> int ret; >> >> /* Caller should know better */ >> @@ -2549,10 +2550,13 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd, >> >> /* Add return 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)); >> - ret = virtqueue_add_sgs(vi->cvq, sgs, out_num, 1, vi, GFP_ATOMIC); >> + if (in) >> + 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) { >> dev_warn(&vi->vdev->dev, >> "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, >> 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) >> { >> struct virtnet_info *vi = netdev_priv(dev); >> -- >> 2.32.0.3.g01195cf9f >> >>
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 7176b956460b..3bc9b1e621db 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -2527,11 +2527,12 @@ static int virtnet_tx_resize(struct virtnet_info *vi, * supported by the hypervisor, as indicated by feature bits, should * never fail unless improperly formatted. */ -static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd, - struct scatterlist *out) +static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd, + struct scatterlist *out, + struct scatterlist *in) { - struct scatterlist *sgs[4], hdr, stat; - unsigned out_num = 0, tmp; + struct scatterlist *sgs[5], hdr, stat; + u32 out_num = 0, tmp, in_num = 0; int ret; /* Caller should know better */ @@ -2549,10 +2550,13 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd, /* Add return 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)); - ret = virtqueue_add_sgs(vi->cvq, sgs, out_num, 1, vi, GFP_ATOMIC); + if (in) + 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) { dev_warn(&vi->vdev->dev, "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, 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) { struct virtnet_info *vi = netdev_priv(dev);