1 From ec72823546e39cd486360f44db16cf47f7e8f59e Mon Sep 17 00:00:00 2001
2 From: Henning Schild <henning.schild@siemens.com>
3 Date: Mon, 18 Sep 2017 18:02:08 +0200
4 Subject: [PATCH] ivshmem-net: fill in and check used descriptor chain len
6 We are using chains of len==1 make that explicit and expect that from
9 Signed-off-by: Henning Schild <henning.schild@siemens.com>
10 Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
11 (cherry picked from commit f958c360044184f58605815d428b83fe4329cafd)
13 drivers/net/ivshmem-net.c | 14 ++++++++------
14 1 file changed, 8 insertions(+), 6 deletions(-)
16 --- a/drivers/net/ivshmem-net.c
17 +++ b/drivers/net/ivshmem-net.c
18 @@ -335,10 +335,10 @@ static void ivshm_net_tx_clean(struct ne
20 struct ivshm_net *in = netdev_priv(ndev);
21 struct ivshm_net_queue *tx = &in->tx;
22 + struct vring_used_elem *used;
23 struct vring *vr = &tx->vr;
24 struct vring_desc *desc;
25 struct vring_desc *fdesc;
30 @@ -358,13 +358,14 @@ static void ivshm_net_tx_clean(struct ne
34 - used = vr->used->ring[last & (vr->num - 1)].id;
35 - if (used >= vr->num) {
36 - netdev_err(ndev, "invalid tx used %d\n", used);
37 + used = vr->used->ring + (last % vr->num);
38 + if (used->id >= vr->num || used->len != 1) {
39 + netdev_err(ndev, "invalid tx used->id %d ->len %d\n",
40 + used->id, used->len);
44 - desc = &vr->desc[used];
45 + desc = &vr->desc[used->id];
47 data = ivshm_net_desc_data(in, &in->tx, desc, &len);
49 @@ -383,7 +384,7 @@ static void ivshm_net_tx_clean(struct ne
58 @@ -433,6 +434,7 @@ static void ivshm_net_rx_finish(struct i
60 used = rx->last_used_idx++ & (vr->num - 1);
61 vr->used->ring[used].id = desc_id;
62 + vr->used->ring[used].len = 1;
64 virt_store_release(&vr->used->idx, rx->last_used_idx);