From patchwork Fri Jun 21 13:19:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaolong Ye X-Patchwork-Id: 55156 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 58C731D52A; Fri, 21 Jun 2019 08:47:30 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 2A2211D529 for ; Fri, 21 Jun 2019 08:47:27 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Jun 2019 23:47:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,399,1557212400"; d="scan'208";a="151170704" Received: from yexl-server.sh.intel.com ([10.67.110.186]) by orsmga007.jf.intel.com with ESMTP; 20 Jun 2019 23:37:22 -0700 From: Xiaolong Ye To: John McNamara , Marko Kovacevic , Xiaolong Ye , Qi Zhang Cc: Karlsson Magnus , Topel Bjorn , yuan.peng@intel.com, dev@dpdk.org Date: Fri, 21 Jun 2019 21:19:15 +0800 Message-Id: <20190621131915.46662-1-xiaolong.ye@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190617142303.85240-1-xiaolong.ye@intel.com> References: <20190617142303.85240-1-xiaolong.ye@intel.com> Subject: [dpdk-dev] [PATCH v3] net/af_xdp: support need wakeup feature 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" This patch enables need_wakeup flag for Tx and fill rings, when this flag is set by the driver, it means that the userspace application has to explicitly wake up the kernel Rx or kernel Tx processing by issuing a syscall. Poll() can wake up both and sendto() or its alternatives will wake up Tx processing only. This feature is to provide efficient support for case that application and driver executing on the same core. Signed-off-by: Xiaolong Ye --- v3 changes: 1. add introduction in 19.08 release note v2 changes: 1. remove need_wakeup devarg to make need_wakeup feature enabled unconditionally. 2. add conditional compilation directive to avoid breaking build with kernel which doesn't support need_wakeup feature yet. Note: Original busy poll feature has morphed into need_wakeup flag in kernel side, the main purpose is the same, that is to support both application and driver executing on the same core efficiently. doc/guides/rel_notes/release_19_08.rst | 2 ++ drivers/net/af_xdp/rte_eth_af_xdp.c | 41 +++++++++++++++++++------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/doc/guides/rel_notes/release_19_08.rst b/doc/guides/rel_notes/release_19_08.rst index 8c3932d06..49656c3cc 100644 --- a/doc/guides/rel_notes/release_19_08.rst +++ b/doc/guides/rel_notes/release_19_08.rst @@ -87,6 +87,8 @@ New Features high performance * Added multi-queue support to allow one af_xdp vdev with multiple netdev queues + * Enabled need_wakeup feature which can provide efficient support for case + that application and driver executing on the same core. Removed Items diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c index c638d9227..5ce90a760 100644 --- a/drivers/net/af_xdp/rte_eth_af_xdp.c +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -90,6 +91,7 @@ struct pkt_rx_queue { struct rx_stats stats; struct pkt_tx_queue *pair; + struct pollfd fds[1]; int xsk_queue_idx; }; @@ -206,8 +208,14 @@ eth_af_xdp_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) return 0; rcvd = xsk_ring_cons__peek(rx, nb_pkts, &idx_rx); - if (rcvd == 0) + if (rcvd == 0) { +#if defined(XDP_USE_NEED_WAKEUP) + if (xsk_ring_prod__needs_wakeup(fq)) + (void)poll(rxq->fds, 1, 1000); +#endif + goto out; + } if (xsk_prod_nb_free(fq, free_thresh) >= free_thresh) (void)reserve_fill_queue(umem, ETH_AF_XDP_RX_BATCH_SIZE); @@ -279,16 +287,19 @@ kick_tx(struct pkt_tx_queue *txq) { struct xsk_umem_info *umem = txq->pair->umem; - while (send(xsk_socket__fd(txq->pair->xsk), NULL, - 0, MSG_DONTWAIT) < 0) { - /* some thing unexpected */ - if (errno != EBUSY && errno != EAGAIN && errno != EINTR) - break; - - /* pull from completion queue to leave more space */ - if (errno == EAGAIN) - pull_umem_cq(umem, ETH_AF_XDP_TX_BATCH_SIZE); - } +#if defined(XDP_USE_NEED_WAKEUP) + if (xsk_ring_prod__needs_wakeup(&txq->tx)) +#endif + while (send(xsk_socket__fd(txq->pair->xsk), NULL, + 0, MSG_DONTWAIT) < 0) { + /* some thing unexpected */ + if (errno != EBUSY && errno != EAGAIN && errno != EINTR) + break; + + /* pull from completion queue to leave more space */ + if (errno == EAGAIN) + pull_umem_cq(umem, ETH_AF_XDP_TX_BATCH_SIZE); + } pull_umem_cq(umem, ETH_AF_XDP_TX_BATCH_SIZE); } @@ -622,6 +633,11 @@ xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq, cfg.libbpf_flags = 0; cfg.xdp_flags = XDP_FLAGS_UPDATE_IF_NOEXIST; cfg.bind_flags = 0; + +#if defined(XDP_USE_NEED_WAKEUP) + cfg.bind_flags |= XDP_USE_NEED_WAKEUP; +#endif + ret = xsk_socket__create(&rxq->xsk, internals->if_name, rxq->xsk_queue_idx, rxq->umem->umem, &rxq->rx, &txq->tx, &cfg); @@ -683,6 +699,9 @@ eth_rx_queue_setup(struct rte_eth_dev *dev, goto err; } + rxq->fds[0].fd = xsk_socket__fd(rxq->xsk); + rxq->fds[0].events = POLLIN; + rxq->umem->pmd_zc = internals->pmd_zc; dev->data->rx_queues[rx_queue_id] = rxq;