Message ID | 1459454476-6029-1-git-send-email-rlane@bigswitch.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 03BC19606; Thu, 31 Mar 2016 22:01:33 +0200 (CEST) Received: from mail-pf0-f181.google.com (mail-pf0-f181.google.com [209.85.192.181]) by dpdk.org (Postfix) with ESMTP id D2CBE9604 for <dev@dpdk.org>; Thu, 31 Mar 2016 22:01:31 +0200 (CEST) Received: by mail-pf0-f181.google.com with SMTP id n5so76599904pfn.2 for <dev@dpdk.org>; Thu, 31 Mar 2016 13:01:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bigswitch-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=6QE+w4+WZOFcfFTxwiy3pCVOGhExQzUQBn08wX3wyOg=; b=fXP1ro6tfO6G9JOYgO0MQ4kcNhOH48gjYz6ndEKOdRNYbcWDwu1fuuZzeEOLfftHSe FyeTfilPhusFVJsHdE87daDB6YuxB8f4oTrLSBE5RDqrWqRL1eILKxvZ5vBOEFOIS9Ub TQazodnuUIyPwfkRXV/SlhvCf0qddnjH4DKA87LUYubKepQe9w0lGKsBuV+7F5XY/DFu 2caj75G8Q1onQ+y7c/NHaEuW1APCDdCIbiKnLoy3qHWW4azH9pv46ZRD4oyQ6wHev2Ip AS1JvUutPHN9ZgG1E3ysnTAkjBkPL065/h6rLVUxklUHCaq3nJl5qpd53M3hslF/zkcT 6Zyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=6QE+w4+WZOFcfFTxwiy3pCVOGhExQzUQBn08wX3wyOg=; b=an64AnZDLQaMOacPFG5dFlg5YBB37ymTsH+zteD/iRbXIgrtiU15U3SDFX8SRMdOBI Hds+pUkEufVUuGzsFXFcxGXbVoR5tjsj1fHYyoVeao3baqB8Q4KSe1ougxzSCfi4rvk2 QKsnA4X3YUoFFqxHL6UgynlcHakjTY4m4SsyPnC4d0cDFeHOzV9V00m2rd8wTEiuDHHb S1SKyGylq4KJYqNbyerpckq5Ff5FQX1wQUMluBmzfe5EdaZuCRFqjxxhu/xday80ux5C HBZwNUoQHB0mKyOpVkgusdOWnsVd8wvb3SLDVBiBTBRPn/mQC95Bey21jx0P/TFd/glq o7UA== X-Gm-Message-State: AD7BkJLw1DNkm9vner2Ya49CwSmtJ09BapTaOkQW0o9cRkQneXBnDlCisIUTO+iKoI3ZHCVe X-Received: by 10.98.74.17 with SMTP id x17mr24847103pfa.14.1459454491234; Thu, 31 Mar 2016 13:01:31 -0700 (PDT) Received: from rlane-work.eng.bigswitch.com ([173.227.38.50]) by smtp.gmail.com with ESMTPSA id o7sm15329020pfa.37.2016.03.31.13.01.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 Mar 2016 13:01:30 -0700 (PDT) From: Rich Lane <rich.lane@bigswitch.com> X-Google-Original-From: Rich Lane <rlane@bigswitch.com> To: dev@dpdk.org Cc: Huawei Xie <huawei.xie@intel.com>, Yuanhan Liu <yuanhan.liu@linux.intel.com> Date: Thu, 31 Mar 2016 13:01:16 -0700 Message-Id: <1459454476-6029-1-git-send-email-rlane@bigswitch.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH] virtio: use zeroed memory for simple TX header X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Rich Lane
March 31, 2016, 8:01 p.m. UTC
For simple TX the virtio-net header must be zeroed, but it was using memory
that had been initialized with indirect descriptor tables. This resulted in
"unsupported gso type" errors from librte_vhost.
We can use the same memory for every descriptor to save cachelines in the
vswitch.
Signed-off-by: Rich Lane <rlane@bigswitch.com>
---
drivers/net/virtio/virtio_rxtx.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
Comments
Huawei, Yuanhan, any comment? 2016-03-31 13:01, Rich Lane: > vq->vq_ring.desc[i + mid_idx].next = i; > vq->vq_ring.desc[i + mid_idx].addr = > - vq->virtio_net_hdr_mem + > - i * vq->hw->vtnet_hdr_size; > + vq->virtio_net_hdr_mem; > vq->vq_ring.desc[i + mid_idx].len = > vq->hw->vtnet_hdr_size;
On Mon, Apr 04, 2016 at 03:13:37PM +0200, Thomas Monjalon wrote: > Huawei, Yuanhan, any comment? > > 2016-03-31 13:01, Rich Lane: > > vq->vq_ring.desc[i + mid_idx].next = i; > > vq->vq_ring.desc[i + mid_idx].addr = > > - vq->virtio_net_hdr_mem + > > - i * vq->hw->vtnet_hdr_size; > > + vq->virtio_net_hdr_mem; I could be wrong, but this looks like a special case when i == 0, which is by no way that zeroed memory is guaranteed? Huawei, do you have time to check this patch? Thanks.
On Mon, Apr 4, 2016 at 1:05 PM, Yuanhan Liu <yuanhan.liu@linux.intel.com> wrote: > On Mon, Apr 04, 2016 at 03:13:37PM +0200, Thomas Monjalon wrote: > > Huawei, Yuanhan, any comment? > > > > 2016-03-31 13:01, Rich Lane: > > > vq->vq_ring.desc[i + mid_idx].next = i; > > > vq->vq_ring.desc[i + mid_idx].addr = > > > - vq->virtio_net_hdr_mem + > > > - i * vq->hw->vtnet_hdr_size; > > > + vq->virtio_net_hdr_mem; > > I could be wrong, but this looks like a special case when i == 0, > which is by no way that zeroed memory is guaranteed? Huawei, do > you have time to check this patch? This bug exists because the type of the objects pointed to by virtio_net_hdr_mem changed in 6dc5de3a (virtio: use indirect ring elements), but because it isn't a C pointer the compiler didn't catch the type mismatch. We could also fix it with: vq->virtio_net_hdr_mem + i * sizeof(struct virtio_tx_region) + offsetof(struct virtio_tx_region, tx_hdr) Given that tx_hdr is the first member in struct virtio_tx_region, and using a single header optimizes cache use, that simplifies to the code in my patch. The virtio-net header is never written to by simple TX so it remains zeroed. I can respin the patch using offsetof if that's preferred. Note that right now virtio simple TX is broken with DPDK vhost due to the flood of error messages.
On Mon, Apr 04, 2016 at 03:57:11PM -0700, Rich Lane wrote: > On Mon, Apr 4, 2016 at 1:05 PM, Yuanhan Liu <yuanhan.liu@linux.intel.com> > wrote: > > On Mon, Apr 04, 2016 at 03:13:37PM +0200, Thomas Monjalon wrote: > > Huawei, Yuanhan, any comment? > > > > 2016-03-31 13:01, Rich Lane: > > > vq->vq_ring.desc[i + mid_idx].next = i; > > > vq->vq_ring.desc[i + mid_idx].addr = > > > - vq->virtio_net_hdr_mem + > > > - i * vq->hw->vtnet_hdr_size; > > > + vq->virtio_net_hdr_mem; > > I could be wrong, but this looks like a special case when i == 0, > which is by no way that zeroed memory is guaranteed? Huawei, do > you have time to check this patch? > > > This bug exists because the type of the objects pointed to by > virtio_net_hdr_mem changed in 6dc5de3a (virtio: use indirect ring elements), > but because it isn't a C pointer the compiler didn't catch the type mismatch. > We could also fix it with: > > vq->virtio_net_hdr_mem + i * sizeof(struct virtio_tx_region) + offsetof > (struct virtio_tx_region, tx_hdr) > > Given that tx_hdr is the first member in struct virtio_tx_region, and using a > single header optimizes cache use, that simplifies to the code in my patch. It does. However, it hurts readability. > The > virtio-net header is never written to by simple TX so it remains zeroed. > > I can respin the patch using offsetof if that's preferred. Yes, please. In such way, we could also align with the setting up code at virtio_dev_queue_setup(). BTW, I have one question: will simple Tx work with indirect buf enabled? > Note that right now virtio simple TX is broken with DPDK vhost due to the flood > of error messages. Yes, we need the fix, and thanks for the catching. BTW, it's a regression fix, you'd better add a Fixline into your commit log. --yliu
diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 2b88efd..1df2df6 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -376,8 +376,7 @@ virtio_dev_vring_start(struct virtqueue *vq, int queue_type) vq->vq_ring.avail->ring[i] = i + mid_idx; vq->vq_ring.desc[i + mid_idx].next = i; vq->vq_ring.desc[i + mid_idx].addr = - vq->virtio_net_hdr_mem + - i * vq->hw->vtnet_hdr_size; + vq->virtio_net_hdr_mem; vq->vq_ring.desc[i + mid_idx].len = vq->hw->vtnet_hdr_size; vq->vq_ring.desc[i + mid_idx].flags =