From patchwork Thu Apr 18 17:20:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrien Mazarguil X-Patchwork-Id: 52948 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 37C721BC1D; Thu, 18 Apr 2019 19:20:59 +0200 (CEST) Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by dpdk.org (Postfix) with ESMTP id 03C7E1BC15 for ; Thu, 18 Apr 2019 19:20:57 +0200 (CEST) Received: by mail-wr1-f68.google.com with SMTP id y13so3902128wrd.3 for ; Thu, 18 Apr 2019 10:20:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Ee6F7YLGP6ed/POR9F2AEonwCOIzEWYAuTExUzuqerw=; b=OMTy3zHIhDitrRqeoULwYn6VQZadVQHq9uFOAhFfB1Kmw9wUwrfIP+FcTYL74m/P2G /nhllpMho/bNcre3gBG/34a6mHHOBk5wOVPXIuQzsqt7QbI5vm17n2WwBDUFEiXIbDHd SgjExrE3KTVjzWbpJBUqfCGxqzTFKP2HrEEStYgd68uHgG1TGJynHkPr8r0DG5/tm0zl E8Qo3Z5/NlV9Y4IoVRMBQNuk16XQNNgfIcZq8OwXZn5spSpxscGDy3AhnjdPlNuVlXmm 68Q0UA0QCdHxi3TuXDLbCH2DGsyeg3QidqvnX13TCw8QfbBLH+7Xn1BHhe+eqSe95YEN YfEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Ee6F7YLGP6ed/POR9F2AEonwCOIzEWYAuTExUzuqerw=; b=UrYAUH326MGOnMfhxfY8HGkvaT939G+WPcYAFjZPy0ujMd2XLheshLcaV3Kk2UYLua bCKa5TvdRta8ItEMe/DSu/cc7UMKRCxqgZ/8xpQxR+4zf72dSpbLP5ZW3eLr3TNh6bH4 WrC+rOvNIl/ahnGSlJzbpqWfNdC+dIMmZaOMDPPenXOCKxmHePzyImIhkRE4uiyOfKMK 49n7+1bP0xPHN/5fTUDLnPFHUF8hSQLRiO1pUbOf2Z8zpUNuYHJTYiiBhfegJlK3HxAj Dbmpxq1FyF3aoOVHeYO8CdV73th+GWXcxfyC7W2BkYG6lSQY3eZDjYXWRIyCjGUGC0Bp iHPw== X-Gm-Message-State: APjAAAVK0RWVvUI6AX1pCjD9ITI+mLVjq1VEy6P1qWtI8xz3j70Suxcw ewnBhGO15X+ZxS+ZK1o67ti95Q== X-Google-Smtp-Source: APXvYqy1YCgWypi/65n4ORUJ/kJLKl6+Yly/jsQ/y9tdvI3OYrth/nUDlNoLmeFHYeHFsYRM390gkw== X-Received: by 2002:a5d:434c:: with SMTP id u12mr2015292wrr.92.1555608057778; Thu, 18 Apr 2019 10:20:57 -0700 (PDT) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id c20sm3200878wre.28.2019.04.18.10.20.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Apr 2019 10:20:57 -0700 (PDT) Date: Thu, 18 Apr 2019 19:20:55 +0200 From: Adrien Mazarguil To: Gaetan Rivet Cc: Ferruh Yigit , David Marchand , dev@dpdk.org, stable@dpdk.org Message-ID: <20190418171859.11624-1-adrien.mazarguil@6wind.com> References: <20190418152229.13554-1-adrien.mazarguil@6wind.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190418152229.13554-1-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH v3] net/failsafe: fix source port ID in Rx packets X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When passed to the application, Rx packets retain the port ID value originally set by slave devices. Unfortunately these IDs have no meaning to applications, which are typically unaware of their existence. This confuses those caring about the source port field in mbufs (m->port) which experience issues ranging from traffic drop to crashes. Fixes: a46f8d584eb8 ("net/failsafe: add fail-safe PMD") Cc: stable@dpdk.org Signed-off-by: Adrien Mazarguil Reviewed-by: David Marchand Acked-by: Gaetan Rivet --- v3 changes: Removed unnecessary reference to slavery ("slave" device) for political correctness. Also kept *-by lines as in v2. v2 changes: Modified "rxq->priv->dev->data->port_id" (v18.11-style) to "rxq->priv->data->port_id" (since v19.05) and checked compilation against master this time. Given the limited scope of that change, reviewed-by/acked-by lines were kept. --- drivers/net/failsafe/failsafe_rxtx.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/net/failsafe/failsafe_rxtx.c b/drivers/net/failsafe/failsafe_rxtx.c index 231c83291..fee08fa23 100644 --- a/drivers/net/failsafe/failsafe_rxtx.c +++ b/drivers/net/failsafe/failsafe_rxtx.c @@ -61,6 +61,21 @@ failsafe_set_burst_fn(struct rte_eth_dev *dev, int force_safe) rte_wmb(); } +/* + * Override source port in Rx packets. + * + * Make Rx packets originate from this PMD instance instead of one of its + * sub-devices. This is mandatory to avoid breaking applications. + */ +static void +failsafe_rx_set_port(struct rte_mbuf **rx_pkts, uint16_t nb_pkts, uint16_t port) +{ + unsigned int i; + + for (i = 0; i != nb_pkts; ++i) + rx_pkts[i]->port = port; +} + uint16_t failsafe_rx_burst(void *queue, struct rte_mbuf **rx_pkts, @@ -87,6 +102,9 @@ failsafe_rx_burst(void *queue, sdev = sdev->next; } while (nb_rx == 0 && sdev != rxq->sdev); rxq->sdev = sdev; + if (nb_rx) + failsafe_rx_set_port(rx_pkts, nb_rx, + rxq->priv->data->port_id); return nb_rx; } @@ -112,6 +130,9 @@ failsafe_rx_burst_fast(void *queue, sdev = sdev->next; } while (nb_rx == 0 && sdev != rxq->sdev); rxq->sdev = sdev; + if (nb_rx) + failsafe_rx_set_port(rx_pkts, nb_rx, + rxq->priv->data->port_id); return nb_rx; }