From patchwork Wed Sep 11 14:09:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Obrembski X-Patchwork-Id: 1161009 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46T3kp16KRz9s4Y for ; Thu, 12 Sep 2019 00:12:34 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4FE6A146A; Wed, 11 Sep 2019 14:11:57 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id AB0971430 for ; Wed, 11 Sep 2019 14:11:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 3DF3A896 for ; Wed, 11 Sep 2019 14:11:55 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Sep 2019 07:11:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,493,1559545200"; d="scan'208";a="200528243" Received: from mobrembx-mobl.ger.corp.intel.com ([10.103.104.26]) by fmsmga001.fm.intel.com with ESMTP; 11 Sep 2019 07:11:53 -0700 From: Michal Obrembski To: dev@openvswitch.org Date: Wed, 11 Sep 2019 16:09:59 +0200 Message-Id: <20190911141005.1346-2-michalx.obrembski@intel.com> X-Mailer: git-send-email 2.23.0.windows.1 In-Reply-To: <20190911141005.1346-1-michalx.obrembski@intel.com> References: <20190911141005.1346-1-michalx.obrembski@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v4 1/7] netdev-dpdk: Validate packets burst before Tx. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Tiago Lam Given that multi-segment mbufs might be sent between interfaces that support different capabilities, and may even support different layouts of mbufs, outgoing packets should be validated before sent on the egress interface. Thus, netdev_dpdk_eth_tx_burst() now calls DPDK's rte_eth_tx_prepare() function, if and only multi-segments is enbaled, in order to validate the following (taken from the DPDK documentation), on a device specific manner: - Check if packet meets devices requirements for tx offloads. - Check limitations about number of segments. - Check additional requirements when debug is enabled. - Update and/or reset required checksums when tx offload is set for packet. Signed-off-by: Tiago Lam --- lib/netdev-dpdk.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 084a54e..6797081 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -2106,6 +2106,10 @@ netdev_dpdk_rxq_dealloc(struct netdev_rxq *rxq) /* Tries to transmit 'pkts' to txq 'qid' of device 'dev'. Takes ownership of * 'pkts', even in case of failure. + * In case multi-segment mbufs / TSO is being used, it also prepares. In such + * cases, only the prepared packets will be sent to Tx burst, meaning that if + * an invalid packet appears in 'pkts'[3] only the validated packets in indices + * 0, 1 and 2 will be sent. * * Returns the number of packets that weren't transmitted. */ static inline int @@ -2113,11 +2117,24 @@ netdev_dpdk_eth_tx_burst(struct netdev_dpdk *dev, int qid, struct rte_mbuf **pkts, int cnt) { uint32_t nb_tx = 0; + uint16_t nb_prep = cnt; + + /* If multi-segments is enabled, validate the burst of packets for Tx. */ + if (OVS_UNLIKELY(dpdk_multi_segment_mbufs)) { + nb_prep = rte_eth_tx_prepare(dev->port_id, qid, pkts, cnt); + if (nb_prep != cnt) { + VLOG_WARN_RL(&rl, "%s: Preparing packet tx burst failed (%u/%u " + "packets valid): %s", dev->up.name, nb_prep, cnt, + rte_strerror(rte_errno)); + } + } - while (nb_tx != cnt) { + /* Tx the validated burst of packets only. */ + while (nb_tx != nb_prep) { uint32_t ret; - ret = rte_eth_tx_burst(dev->port_id, qid, pkts + nb_tx, cnt - nb_tx); + ret = rte_eth_tx_burst(dev->port_id, qid, pkts + nb_tx, + nb_prep - nb_tx); if (!ret) { break; }