From patchwork Wed Jun 7 09:21:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bodireddy, Bhanuprakash" X-Patchwork-Id: 772303 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3wjNcZ4tDwz9sNS for ; Wed, 7 Jun 2017 19:32:14 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 3BBE2B8E; Wed, 7 Jun 2017 09:29:21 +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 DF7ABB3F for ; Wed, 7 Jun 2017 09:29:16 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 7E9041CE for ; Wed, 7 Jun 2017 09:29:16 +0000 (UTC) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jun 2017 02:29:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.39,310,1493708400"; d="scan'208"; a="1138827799" Received: from silpixa00393942.ir.intel.com (HELO silpixa00393942.ger.corp.intel.com) ([10.237.223.42]) by orsmga001.jf.intel.com with ESMTP; 07 Jun 2017 02:29:15 -0700 From: Bhanuprakash Bodireddy To: dev@openvswitch.org Date: Wed, 7 Jun 2017 10:21:02 +0100 Message-Id: <1496827265-19785-6-git-send-email-bhanuprakash.bodireddy@intel.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1496827265-19785-1-git-send-email-bhanuprakash.bodireddy@intel.com> References: <1496827265-19785-1-git-send-email-bhanuprakash.bodireddy@intel.com> X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD 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 5/8] netdev-dpdk: Add netdev_dpdk_vhost_txq_drain function. 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: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Add netdev_dpdk_vhost_txq_drain(), that flushes packets on vHost User port queues. Also add netdev_dpdk_vhost_tx_burst() function that uses rte_vhost_enqueue_burst() to enqueue burst of packets on vHost User ports. Signed-off-by: Bhanuprakash Bodireddy Signed-off-by: Antonio Fischetti Co-authored-by: Antonio Fischetti --- lib/netdev-dpdk.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 4a9d9aa..dfaa3cd 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -308,10 +308,15 @@ struct dpdk_tx_queue { * to enabled by guest. */ int count; /* Number of buffered packets waiting to be sent. */ + int vhost_pkt_cnt; /* Number of buffered packets waiting to + be sent on vhost port */ struct rte_mbuf *burst_pkts[INTERIM_QUEUE_BURST_THRESHOLD]; /* Intermediate queue where packets can * be buffered to amortize the cost of MMIO * writes. */ + struct dp_packet *pkts[INTERIM_QUEUE_BURST_THRESHOLD]; + /* Intermediate queue where packets can + * be buffered for vhost ports */ }; /* dpdk has no way to remove dpdk ring ethernet devices @@ -1714,6 +1719,63 @@ netdev_dpdk_vhost_update_tx_counters(struct netdev_stats *stats, } } +static int +netdev_dpdk_vhost_tx_burst(struct netdev_dpdk *dev, int qid) +{ + struct dpdk_tx_queue *txq = &dev->tx_q[qid]; + struct rte_mbuf **cur_pkts = (struct rte_mbuf **)txq->pkts; + + int tx_vid = netdev_dpdk_get_vid(dev); + int tx_qid = qid * VIRTIO_QNUM + VIRTIO_RXQ; + uint32_t sent = 0; + uint32_t retries = 0; + uint32_t sum, total_pkts; + + total_pkts = sum = txq->vhost_pkt_cnt; + do { + uint32_t ret; + ret = rte_vhost_enqueue_burst(tx_vid, tx_qid, &cur_pkts[sent], sum); + if (OVS_UNLIKELY(!ret)) { + /* No packets enqueued - do not retry. */ + break; + } else { + /* Packet have been sent */ + sent += ret; + + /* 'sum; packet have to be retransmitted */ + sum -= ret; + } + } while (sum && (retries++ < VHOST_ENQ_RETRY_NUM)); + + for (int i=0; i < total_pkts; i++) { + dp_packet_delete(txq->pkts[i]); + } + + /* Reset pkt count */ + txq->vhost_pkt_cnt = 0; + + /* 'sum' refers to packets dropped */ + return sum; +} + +/* Drain the txq if there are any packets available. + * dynamic_txqs/concurrent_txq is disabled for vHost User ports as + * 'OVS_VHOST_MAX_QUEUE_NUM[1024]' txqs are preallocated. + */ +static int +netdev_dpdk_vhost_txq_drain(struct netdev *netdev, int qid, + bool concurrent_txq OVS_UNUSED) +{ + struct netdev_dpdk *dev = netdev_dpdk_cast(netdev); + struct dpdk_tx_queue *txq = &dev->tx_q[qid]; + + if (OVS_LIKELY(txq->vhost_pkt_cnt)) { + netdev_dpdk_vhost_tx_burst(dev, qid); + } + + return 0; +} + static void __netdev_dpdk_vhost_send(struct netdev *netdev, int qid, struct dp_packet **pkts, int cnt) @@ -3425,7 +3487,8 @@ static const struct netdev_class dpdk_vhost_class = NULL, netdev_dpdk_vhost_reconfigure, netdev_dpdk_vhost_rxq_recv, - NULL); + netdev_dpdk_vhost_txq_drain); + static const struct netdev_class dpdk_vhost_client_class = NETDEV_DPDK_CLASS( "dpdkvhostuserclient", @@ -3441,7 +3504,7 @@ static const struct netdev_class dpdk_vhost_client_class = NULL, netdev_dpdk_vhost_client_reconfigure, netdev_dpdk_vhost_rxq_recv, - NULL); + netdev_dpdk_vhost_txq_drain); void netdev_dpdk_register(void)