From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id C538F1B776 for ; Wed, 7 Feb 2018 17:47:29 +0100 (CET) Received: by mail-wm0-f68.google.com with SMTP id f3so4597710wmc.1 for ; Wed, 07 Feb 2018 08:47:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QkgK9oKnuSljJBZgo+z9gdEsMUDytRUWtjnxDSyYHhQ=; b=jjsGbzKV2yUkoBvP0ZSI1wMFwmNyZwFvKHYiqfcENIMIJj8x5/SKkOr7dvGbUERl4H G0Xv0oniZV2Vd2osUxyjT1gcZ3uljT18g/UHtfpIzMLvA1pvIUpw5OydVoLX2iUy3Oho aXDWMcGREsSzsmz6rc63qydgnkN8uVN3MsrXlAFzxFK8LSzAgSMvxDy+ZgS/wd+guWtZ ZqQj708znVVa+5RXlKlZs8C/vd4iCOncOiF+JKARg5G8zpu+fvlNwL1i01C8dJZ+Epy9 TubPDYhL0oSHikDn9oMn2sLRjdd0wAb2yH3k9N8aD3kS6hO5qOPdXJpbsTBCkEfAS6m3 Xgdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QkgK9oKnuSljJBZgo+z9gdEsMUDytRUWtjnxDSyYHhQ=; b=PqduNLqp3qtgeIIVNnCBziMAhfFvUOKDhZPi9f6dhoMiBKlUuIr2efOojHE34wDxPh gu8XfXN/mnQ6Av/J6Abd6CbyWfwCjqle7VBpif7Ap9CTmEC83NLFemevetgoZKmqVzPd evz6tmDb97ShD/l3ASLnV4R/cPuprevYGmdbu2cBWi6kcuijjzvcEzr7lyfOJQamezGF YcvPEm514a2vCwBYDL8CV6BcTrtytMpoEV2DM3tgank0yrArZKBbVdy+wZRQrQEkvJjw NQxSymjiDszihYZ5S9ULlu4C3V1GXKHMpFfdrG/y1V/JBsEwipVNceuhgGC4HY7bfsmN kxvQ== X-Gm-Message-State: APf1xPB0yycIQ8lHvgIXD0RCBp6aUSpCrRxKVKJT16mR0EFcfa2zMl5+ ydjrrKa7yzJ1yzI0DraVD0Y= X-Google-Smtp-Source: AH8x2275rWc9d4eD1sdd3F+eLpYGtOmIdyYRbUjn8y5dyWr0AJSOnJtW9P1Yhc4qqThgeoWkOc5QoA== X-Received: by 10.28.165.4 with SMTP id o4mr5135545wme.66.1518022049491; Wed, 07 Feb 2018 08:47:29 -0800 (PST) Received: from localhost ([2a00:23c5:bef3:400:9531:588b:44ae:bec4]) by smtp.gmail.com with ESMTPSA id d125sm1755203wmc.47.2018.02.07.08.47.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 07 Feb 2018 08:47:28 -0800 (PST) From: luca.boccassi@gmail.com To: Olivier Matz Cc: Yuanhan Liu , dpdk stable Date: Wed, 7 Feb 2018 16:46:40 +0000 Message-Id: <20180207164705.29052-9-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180207164705.29052-1-luca.boccassi@gmail.com> References: <20180126131332.15346-62-luca.boccassi@gmail.com> <20180207164705.29052-1-luca.boccassi@gmail.com> Subject: [dpdk-stable] patch 'net/virtio: fix queue flushing with vector Rx enabled' has been queued to LTS release 16.11.5 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Feb 2018 16:47:29 -0000 Hi, FYI, your patch has been queued to LTS release 16.11.5 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/09/18. So please shout if anyone has objections. Thanks. Luca Boccassi --- >>From 4e276c4a94a6f4fd83af2b26f483e6a124304a33 Mon Sep 17 00:00:00 2001 From: Olivier Matz Date: Tue, 23 Jan 2018 16:54:40 +0100 Subject: [PATCH] net/virtio: fix queue flushing with vector Rx enabled [ upstream commit e67ae1e27e27b0fce9974dbf1b5bc6adff27a213 ] When using vector Rx mode (use_simple_rx = 1), vq->vq_descx[] is not kept up to date. To properly detach the mbufs in this case, browse sw_ring[] instead, as it's done in virtqueue_rxvq_flush(). Since we need virtio_get_queue_type(), also move this function in virtqueue.h as a static inline. Fixes: fc3d66212fed ("virtio: add vector Rx") Signed-off-by: Olivier Matz Acked-by: Yuanhan Liu --- drivers/net/virtio/virtio_ethdev.c | 11 ----------- drivers/net/virtio/virtqueue.c | 28 +++++++++++++++++++++++++--- drivers/net/virtio/virtqueue.h | 11 +++++++++++ 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 4d6efd5ac..7e2965549 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -288,17 +288,6 @@ virtio_dev_queue_release(void *queue __rte_unused) /* do nothing */ } -static int -virtio_get_queue_type(struct virtio_hw *hw, uint16_t vtpci_queue_idx) -{ - if (vtpci_queue_idx == hw->max_queue_pairs * 2) - return VTNET_CQ; - else if (vtpci_queue_idx % 2 == 0) - return VTNET_RQ; - else - return VTNET_TQ; -} - static uint16_t virtio_get_nr_vq(struct virtio_hw *hw) { diff --git a/drivers/net/virtio/virtqueue.c b/drivers/net/virtio/virtqueue.c index 0e24194a5..510d746ca 100644 --- a/drivers/net/virtio/virtqueue.c +++ b/drivers/net/virtio/virtqueue.c @@ -59,16 +59,38 @@ struct rte_mbuf * virtqueue_detatch_unused(struct virtqueue *vq) { struct rte_mbuf *cookie; - int idx; + struct virtio_hw *hw; + uint16_t start, end; + int type, idx; - if (vq != NULL) - for (idx = 0; idx < vq->vq_nentries; idx++) { + if (vq == NULL) + return NULL; + + hw = vq->hw; + type = virtio_get_queue_type(hw, vq->vq_queue_index); + start = vq->vq_avail_idx & (vq->vq_nentries - 1); + end = (vq->vq_avail_idx + vq->vq_free_cnt) & (vq->vq_nentries - 1); + + for (idx = 0; idx < vq->vq_nentries; idx++) { + if (hw->use_simple_rxtx && type == VTNET_RQ) { + if (start <= end && idx >= start && idx < end) + continue; + if (start > end && (idx >= start || idx < end)) + continue; + cookie = vq->sw_ring[idx]; + if (cookie != NULL) { + vq->sw_ring[idx] = NULL; + return cookie; + } + } else { cookie = vq->vq_descx[idx].cookie; if (cookie != NULL) { vq->vq_descx[idx].cookie = NULL; return cookie; } } + } + return NULL; } diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h index 421485473..949cbe156 100644 --- a/drivers/net/virtio/virtqueue.h +++ b/drivers/net/virtio/virtqueue.h @@ -299,6 +299,17 @@ virtqueue_full(const struct virtqueue *vq) return vq->vq_free_cnt == 0; } +static inline int +virtio_get_queue_type(struct virtio_hw *hw, uint16_t vtpci_queue_idx) +{ + if (vtpci_queue_idx == hw->max_queue_pairs * 2) + return VTNET_CQ; + else if (vtpci_queue_idx % 2 == 0) + return VTNET_RQ; + else + return VTNET_TQ; +} + #define VIRTQUEUE_NUSED(vq) ((uint16_t)((vq)->vq_ring.used->idx - (vq)->vq_used_cons_idx)) void vq_ring_free_chain(struct virtqueue *vq, uint16_t desc_idx); -- 2.14.2