aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2017-03-06 13:31:21 -0500
committerMichael S. Tsirkin <mst@redhat.com>2017-05-09 09:43:15 -0400
commitd45b897b11eaf9847c4b9bc99a91279041b1bbf7 (patch)
tree22a284031dc04036ee72990d8de15af1b1b47ead
parent5a08b04f637921e44ba767c07c74b0535504ab71 (diff)
virtio_net: allow specifying context for rx
With mergeable buffers we never use s/g for rx, so allow specifying context in that case. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r--drivers/net/virtio_net.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 71f447ab440e..108f923f8a69 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -2044,6 +2044,7 @@ static int virtnet_find_vqs(struct virtnet_info *vi)
2044 int ret = -ENOMEM; 2044 int ret = -ENOMEM;
2045 int i, total_vqs; 2045 int i, total_vqs;
2046 const char **names; 2046 const char **names;
2047 bool *ctx;
2047 2048
2048 /* We expect 1 RX virtqueue followed by 1 TX virtqueue, followed by 2049 /* We expect 1 RX virtqueue followed by 1 TX virtqueue, followed by
2049 * possible N-1 RX/TX queue pairs used in multiqueue mode, followed by 2050 * possible N-1 RX/TX queue pairs used in multiqueue mode, followed by
@@ -2062,6 +2063,13 @@ static int virtnet_find_vqs(struct virtnet_info *vi)
2062 names = kmalloc(total_vqs * sizeof(*names), GFP_KERNEL); 2063 names = kmalloc(total_vqs * sizeof(*names), GFP_KERNEL);
2063 if (!names) 2064 if (!names)
2064 goto err_names; 2065 goto err_names;
2066 if (vi->mergeable_rx_bufs) {
2067 ctx = kzalloc(total_vqs * sizeof(*ctx), GFP_KERNEL);
2068 if (!ctx)
2069 goto err_ctx;
2070 } else {
2071 ctx = NULL;
2072 }
2065 2073
2066 /* Parameters for control virtqueue, if any */ 2074 /* Parameters for control virtqueue, if any */
2067 if (vi->has_cvq) { 2075 if (vi->has_cvq) {
@@ -2077,9 +2085,12 @@ static int virtnet_find_vqs(struct virtnet_info *vi)
2077 sprintf(vi->sq[i].name, "output.%d", i); 2085 sprintf(vi->sq[i].name, "output.%d", i);
2078 names[rxq2vq(i)] = vi->rq[i].name; 2086 names[rxq2vq(i)] = vi->rq[i].name;
2079 names[txq2vq(i)] = vi->sq[i].name; 2087 names[txq2vq(i)] = vi->sq[i].name;
2088 if (ctx)
2089 ctx[rxq2vq(i)] = true;
2080 } 2090 }
2081 2091
2082 ret = virtio_find_vqs(vi->vdev, total_vqs, vqs, callbacks, names, NULL); 2092 ret = vi->vdev->config->find_vqs(vi->vdev, total_vqs, vqs, callbacks,
2093 names, ctx, NULL);
2083 if (ret) 2094 if (ret)
2084 goto err_find; 2095 goto err_find;
2085 2096
@@ -2101,6 +2112,8 @@ static int virtnet_find_vqs(struct virtnet_info *vi)
2101 return 0; 2112 return 0;
2102 2113
2103err_find: 2114err_find:
2115 kfree(ctx);
2116err_ctx:
2104 kfree(names); 2117 kfree(names);
2105err_names: 2118err_names:
2106 kfree(callbacks); 2119 kfree(callbacks);