From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6779FA04AF; Fri, 21 Aug 2020 18:32:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 17F251C18E; Fri, 21 Aug 2020 18:30:35 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 79D5E1C12F for ; Fri, 21 Aug 2020 18:30:33 +0200 (CEST) IronPort-SDR: LmLrxCqru8JTcGqT/hYim+s5Bzf+NSxzBCeAJHJx0qE5HPhM7J9SRpUx1Oaa/AtYXJz0IET3TW c/r4Dzcb7I/A== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="173615882" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="173615882" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Aug 2020 09:30:33 -0700 IronPort-SDR: GLPnbFhYlVZ4DYf4a5IvTyMEgchBTDU75MPpoLWV45oj4Zua+I7t2On42JAQm0+V8aVoxPN4+Z bjdb/OWGZIQw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="297992872" Received: from silpixa00399126.ir.intel.com ([10.237.222.56]) by orsmga006.jf.intel.com with ESMTP; 21 Aug 2020 09:30:31 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: cheng1.jiang@intel.com, patrick.fu@intel.com, ping.yu@intel.com, kevin.laatz@intel.com, Bruce Richardson Date: Fri, 21 Aug 2020 17:29:37 +0100 Message-Id: <20200821162944.29840-12-bruce.richardson@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821162944.29840-1-bruce.richardson@intel.com> References: <20200721095140.719297-1-bruce.richardson@intel.com> <20200821162944.29840-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 11/18] raw/ioat: add configure function for idxd devices 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" Add configure function for idxd devices, taking the same parameters as the existing configure function for ioat. The ring_size parameter is used to compute the maximum number of bursts to be supported by the driver, given that the hardware works on individual bursts of descriptors at a time. Signed-off-by: Bruce Richardson --- drivers/raw/ioat/idxd_pci.c | 1 + drivers/raw/ioat/idxd_vdev.c | 1 + drivers/raw/ioat/ioat_common.c | 64 ++++++++++++++++++++++++++ drivers/raw/ioat/ioat_private.h | 3 ++ drivers/raw/ioat/rte_ioat_rawdev_fns.h | 1 + 5 files changed, 70 insertions(+) diff --git a/drivers/raw/ioat/idxd_pci.c b/drivers/raw/ioat/idxd_pci.c index ce238ae04c..98e8668e34 100644 --- a/drivers/raw/ioat/idxd_pci.c +++ b/drivers/raw/ioat/idxd_pci.c @@ -54,6 +54,7 @@ idxd_is_wq_enabled(struct idxd_rawdev *idxd) static const struct rte_rawdev_ops idxd_pci_ops = { .dev_selftest = idxd_rawdev_test, .dump = idxd_dev_dump, + .dev_configure = idxd_dev_configure, }; /* each portal uses 4 x 4k pages */ diff --git a/drivers/raw/ioat/idxd_vdev.c b/drivers/raw/ioat/idxd_vdev.c index 0f9aa48e84..73cb5d938f 100644 --- a/drivers/raw/ioat/idxd_vdev.c +++ b/drivers/raw/ioat/idxd_vdev.c @@ -33,6 +33,7 @@ struct idxd_vdev_args { static const struct rte_rawdev_ops idxd_vdev_ops = { .dev_selftest = idxd_rawdev_test, .dump = idxd_dev_dump, + .dev_configure = idxd_dev_configure, }; static void * diff --git a/drivers/raw/ioat/ioat_common.c b/drivers/raw/ioat/ioat_common.c index fb4f7055de..85b13b0bae 100644 --- a/drivers/raw/ioat/ioat_common.c +++ b/drivers/raw/ioat/ioat_common.c @@ -37,6 +37,70 @@ idxd_dev_dump(struct rte_rawdev *dev, FILE *f) return 0; } +int +idxd_dev_configure(const struct rte_rawdev *dev, + rte_rawdev_obj_t config, size_t config_size) +{ + struct idxd_rawdev *idxd = dev->dev_private; + struct rte_idxd_rawdev *rte_idxd = &idxd->public; + struct rte_ioat_rawdev_config *cfg = config; + uint16_t max_desc = cfg->ring_size; + uint16_t max_batches = max_desc / BATCH_SIZE; + uint16_t i; + + if (config_size != sizeof(*cfg)) + return -EINVAL; + + if (dev->started) { + IOAT_PMD_ERR("%s: Error, device is started.", __func__); + return -EAGAIN; + } + + rte_idxd->hdls_disable = cfg->hdls_disable; + + /* limit the batches to what can be stored in hardware */ + if (max_batches > idxd->max_batches) { + IOAT_PMD_DEBUG("Ring size of %u is too large for this device, need to limit to %u batches of %u", + max_desc, idxd->max_batches, BATCH_SIZE); + max_batches = idxd->max_batches; + max_desc = max_batches * BATCH_SIZE; + } + if (!rte_is_power_of_2(max_desc)) + max_desc = rte_align32pow2(max_desc); + IOAT_PMD_DEBUG("Rawdev %u using %u descriptors in %u batches", + dev->dev_id, max_desc, max_batches); + + /* in case we are reconfiguring a device, free any existing memory */ + rte_free(rte_idxd->batch_ring); + rte_free(rte_idxd->hdl_ring); + + rte_idxd->batch_ring = rte_zmalloc(NULL, + sizeof(*rte_idxd->batch_ring) * max_batches, 0); + if (rte_idxd->batch_ring == NULL) + return -ENOMEM; + + rte_idxd->hdl_ring = rte_zmalloc(NULL, + sizeof(*rte_idxd->hdl_ring) * max_desc, 0); + if (rte_idxd->hdl_ring == NULL) { + rte_free(rte_idxd->batch_ring); + rte_idxd->batch_ring = NULL; + return -ENOMEM; + } + rte_idxd->batch_ring_sz = max_batches; + rte_idxd->hdl_ring_sz = max_desc; + + for (i = 0; i < rte_idxd->batch_ring_sz; i++) { + struct rte_idxd_desc_batch *b = &rte_idxd->batch_ring[i]; + b->batch_desc.completion = rte_mem_virt2iova(&b->comp); + b->batch_desc.desc_addr = rte_mem_virt2iova(&b->null_desc); + b->batch_desc.op_flags = (idxd_op_batch << IDXD_CMD_OP_SHIFT) | + IDXD_FLAG_COMPLETION_ADDR_VALID | + IDXD_FLAG_REQUEST_COMPLETION; + } + + return 0; +} + int idxd_rawdev_create(const char *name, struct rte_device *dev, const struct idxd_rawdev *base_idxd, diff --git a/drivers/raw/ioat/ioat_private.h b/drivers/raw/ioat/ioat_private.h index 974eeb0106..928c9b497c 100644 --- a/drivers/raw/ioat/ioat_private.h +++ b/drivers/raw/ioat/ioat_private.h @@ -57,6 +57,9 @@ extern int idxd_rawdev_create(const char *name, struct rte_device *dev, const struct idxd_rawdev *idxd, const struct rte_rawdev_ops *ops); +extern int idxd_dev_configure(const struct rte_rawdev *dev, + rte_rawdev_obj_t config, size_t config_size); + extern int idxd_rawdev_test(uint16_t dev_id); extern int idxd_dev_dump(struct rte_rawdev *dev, FILE *f); diff --git a/drivers/raw/ioat/rte_ioat_rawdev_fns.h b/drivers/raw/ioat/rte_ioat_rawdev_fns.h index d258ad9fd2..1939437d50 100644 --- a/drivers/raw/ioat/rte_ioat_rawdev_fns.h +++ b/drivers/raw/ioat/rte_ioat_rawdev_fns.h @@ -185,6 +185,7 @@ struct rte_idxd_rawdev { uint16_t next_ret_hdl; /* the next user hdl to return */ uint16_t last_completed_hdl; /* the last user hdl that has completed */ uint16_t next_free_hdl; /* where the handle for next op will go */ + uint16_t hdls_disable; /* disable tracking completion handles */ struct rte_idxd_user_hdl *hdl_ring; struct rte_idxd_desc_batch *batch_ring; -- 2.25.1