From patchwork Mon Sep 28 16:42:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 79031 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id ED2BBA04DB; Mon, 28 Sep 2020 18:45:51 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 408EE1D717; Mon, 28 Sep 2020 18:43:21 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 90E641D6DA for ; Mon, 28 Sep 2020 18:43:14 +0200 (CEST) IronPort-SDR: 5TmlYoBhRRBIFjaCjKqqnTXIZTiBNM1o50d0BTcW2J6KXLB9E6PHc3kPuDpHtRQcsWDP7l0Sve 9asAs9AN6H/Q== X-IronPort-AV: E=McAfee;i="6000,8403,9758"; a="223619786" X-IronPort-AV: E=Sophos;i="5.77,313,1596524400"; d="scan'208";a="223619786" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2020 09:43:13 -0700 IronPort-SDR: 4augWIdQR4gpr+wmyw2/Bkf+6/6iY+y7kOcml/n+hOiQi5itk1ENkhNyhPwsyv0x8wf0XF4oQI EMPHfdcxQ6VQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,313,1596524400"; d="scan'208";a="338250510" Received: from silpixa00399126.ir.intel.com ([10.237.222.4]) by fmsmga004.fm.intel.com with ESMTP; 28 Sep 2020 09:43:11 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: patrick.fu@intel.com, Bruce Richardson , Kevin Laatz Date: Mon, 28 Sep 2020 17:42:28 +0100 Message-Id: <20200928164245.84997-9-bruce.richardson@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200928164245.84997-1-bruce.richardson@intel.com> References: <20200721095140.719297-1-bruce.richardson@intel.com> <20200928164245.84997-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v4 08/25] raw/ioat: add separate API for fence call 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" Rather than having the fence signalled via a flag on a descriptor - which requires reading the docs to find out whether the flag needs to go on the last descriptor before, or the first descriptor after the fence - we can instead add a separate fence API call. This becomes unambiguous to use, since the fence call explicitly comes between two other enqueue calls. It also allows more freedom of implementation in the driver code. Signed-off-by: Bruce Richardson Reviewed-by: Kevin Laatz --- doc/guides/rawdevs/ioat.rst | 3 +-- doc/guides/rel_notes/release_20_11.rst | 4 ++++ drivers/raw/ioat/ioat_rawdev_test.c | 6 ++---- drivers/raw/ioat/rte_ioat_rawdev.h | 26 ++++++++++++++++++++------ drivers/raw/ioat/rte_ioat_rawdev_fns.h | 22 +++++++++++++++++++--- examples/ioat/ioatfwd.c | 12 ++++-------- 6 files changed, 50 insertions(+), 23 deletions(-) diff --git a/doc/guides/rawdevs/ioat.rst b/doc/guides/rawdevs/ioat.rst index 3db5f5d097..71bca0b28f 100644 --- a/doc/guides/rawdevs/ioat.rst +++ b/doc/guides/rawdevs/ioat.rst @@ -203,8 +203,7 @@ a burst of copies to the device and start the hardware processing of them: dsts[i]->buf_iova + dsts[i]->data_off, length, (uintptr_t)srcs[i], - (uintptr_t)dsts[i], - 0 /* nofence */) != 1) { + (uintptr_t)dsts[i]) != 1) { printf("Error with rte_ioat_enqueue_copy for buffer %u\n", i); return -1; diff --git a/doc/guides/rel_notes/release_20_11.rst b/doc/guides/rel_notes/release_20_11.rst index c99c0b33f5..3868529ac2 100644 --- a/doc/guides/rel_notes/release_20_11.rst +++ b/doc/guides/rel_notes/release_20_11.rst @@ -88,6 +88,10 @@ New Features to better reflect the APIs' purposes, and remove the implication that they are limited to copy operations only. [Note: The old API is still provided but marked as deprecated in the code] + * Added a new API ``rte_ioat_fence()`` to add a fence between operations. + This API replaces the ``fence`` flag parameter in the ``rte_ioat_enqueue_copies()`` function, + and is clearer as there is no ambiguity as to whether the flag should be + set on the last operation before the fence or the first operation after it. Removed Items diff --git a/drivers/raw/ioat/ioat_rawdev_test.c b/drivers/raw/ioat/ioat_rawdev_test.c index bb40eab6b7..8ff5468035 100644 --- a/drivers/raw/ioat/ioat_rawdev_test.c +++ b/drivers/raw/ioat/ioat_rawdev_test.c @@ -57,8 +57,7 @@ test_enqueue_copies(int dev_id) dst->buf_iova + dst->data_off, length, (uintptr_t)src, - (uintptr_t)dst, - 0 /* no fence */) != 1) { + (uintptr_t)dst) != 1) { PRINT_ERR("Error with rte_ioat_enqueue_copy\n"); return -1; } @@ -109,8 +108,7 @@ test_enqueue_copies(int dev_id) dsts[i]->buf_iova + dsts[i]->data_off, length, (uintptr_t)srcs[i], - (uintptr_t)dsts[i], - 0 /* nofence */) != 1) { + (uintptr_t)dsts[i]) != 1) { PRINT_ERR("Error with rte_ioat_enqueue_copy for buffer %u\n", i); return -1; diff --git a/drivers/raw/ioat/rte_ioat_rawdev.h b/drivers/raw/ioat/rte_ioat_rawdev.h index 5b2c47e8c8..6b891cd449 100644 --- a/drivers/raw/ioat/rte_ioat_rawdev.h +++ b/drivers/raw/ioat/rte_ioat_rawdev.h @@ -61,17 +61,31 @@ struct rte_ioat_rawdev_config { * operation has been completed and the user polls for the completion details. * NOTE: If hdls_disable configuration option for the device is set, this * parameter is ignored. - * @param fence - * A flag parameter indicating that hardware should not begin to perform any - * subsequently enqueued copy operations until after this operation has - * completed * @return * Number of operations enqueued, either 0 or 1 */ static inline int rte_ioat_enqueue_copy(int dev_id, phys_addr_t src, phys_addr_t dst, - unsigned int length, uintptr_t src_hdl, uintptr_t dst_hdl, - int fence); + unsigned int length, uintptr_t src_hdl, uintptr_t dst_hdl); + +/** + * Add a fence to force ordering between operations + * + * This adds a fence to a sequence of operations to enforce ordering, such that + * all operations enqueued before the fence must be completed before operations + * after the fence. + * NOTE: Since this fence may be added as a flag to the last operation enqueued, + * this API may not function correctly when called immediately after an + * "rte_ioat_perform_ops" call i.e. before any new operations are enqueued. + * + * @param dev_id + * The rawdev device id of the ioat instance + * @return + * Number of fences enqueued, either 0 or 1 + */ +static inline int +rte_ioat_fence(int dev_id); + /** * Trigger hardware to begin performing enqueued operations diff --git a/drivers/raw/ioat/rte_ioat_rawdev_fns.h b/drivers/raw/ioat/rte_ioat_rawdev_fns.h index b155d79c45..466721a23a 100644 --- a/drivers/raw/ioat/rte_ioat_rawdev_fns.h +++ b/drivers/raw/ioat/rte_ioat_rawdev_fns.h @@ -47,8 +47,7 @@ struct rte_ioat_rawdev { */ static inline int rte_ioat_enqueue_copy(int dev_id, phys_addr_t src, phys_addr_t dst, - unsigned int length, uintptr_t src_hdl, uintptr_t dst_hdl, - int fence) + unsigned int length, uintptr_t src_hdl, uintptr_t dst_hdl) { struct rte_ioat_rawdev *ioat = (struct rte_ioat_rawdev *)rte_rawdevs[dev_id].dev_private; @@ -69,7 +68,7 @@ rte_ioat_enqueue_copy(int dev_id, phys_addr_t src, phys_addr_t dst, desc = &ioat->desc_ring[write]; desc->size = length; /* set descriptor write-back every 16th descriptor */ - desc->u.control_raw = (uint32_t)((!!fence << 4) | (!(write & 0xF)) << 3); + desc->u.control_raw = (uint32_t)((!(write & 0xF)) << 3); desc->src_addr = src; desc->dest_addr = dst; @@ -82,6 +81,23 @@ rte_ioat_enqueue_copy(int dev_id, phys_addr_t src, phys_addr_t dst, return 1; } +/* add fence to last written descriptor */ +static inline int +rte_ioat_fence(int dev_id) +{ + struct rte_ioat_rawdev *ioat = + (struct rte_ioat_rawdev *)rte_rawdevs[dev_id].dev_private; + unsigned short write = ioat->next_write; + unsigned short mask = ioat->ring_size - 1; + struct rte_ioat_generic_hw_desc *desc; + + write = (write - 1) & mask; + desc = &ioat->desc_ring[write]; + + desc->u.control.fence = 1; + return 0; +} + /* * Trigger hardware to begin performing enqueued operations */ diff --git a/examples/ioat/ioatfwd.c b/examples/ioat/ioatfwd.c index 67f75737b6..e6d1d1236e 100644 --- a/examples/ioat/ioatfwd.c +++ b/examples/ioat/ioatfwd.c @@ -361,15 +361,11 @@ ioat_enqueue_packets(struct rte_mbuf **pkts, for (i = 0; i < nb_rx; i++) { /* Perform data copy */ ret = rte_ioat_enqueue_copy(dev_id, - pkts[i]->buf_iova - - addr_offset, - pkts_copy[i]->buf_iova - - addr_offset, - rte_pktmbuf_data_len(pkts[i]) - + addr_offset, + pkts[i]->buf_iova - addr_offset, + pkts_copy[i]->buf_iova - addr_offset, + rte_pktmbuf_data_len(pkts[i]) + addr_offset, (uintptr_t)pkts[i], - (uintptr_t)pkts_copy[i], - 0 /* nofence */); + (uintptr_t)pkts_copy[i]); if (ret != 1) break;