From patchwork Thu Jan 26 13:34:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 122542 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 54E8542492; Thu, 26 Jan 2023 14:35:33 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DB59942D6C; Thu, 26 Jan 2023 14:35:07 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id D50C542D4A for ; Thu, 26 Jan 2023 14:35:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674740102; x=1706276102; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=g/HXZeMk3Y8/svsqFOnfbkYlNVuMueJa1uuNDtyNlfA=; b=kaQ5hqMn9Z8uxOaXPAmjkBhH5EUTFcdLX2bUkkedxYWzEtsJZd+91b/N iouEoCKtBCL4LwlAGnMfG3Uwoqyz+F0PkEs7kl1Z/+xJ6DooRwf+uV/YE yLuVMJR6UWVLt+D4iWATyT37UVioNGfrBNedz8CTzLkbq2G4GIOf7uSEB H4FKimTd3zkpia3cm2ukwWjiuOjtYU6LVaZThXD5wa60pCZCvyubmVgcd becmuz7rKuQ/G4zeNHdkvbXhFhoJ354l9i5cC9sgVESfbdPpAUEgus17X hJUHIjvvqn0nS1nrGfT8RAzee/F+9vVlnULZZPpiui9uXbMueL9Ek2cQk g==; X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="307155084" X-IronPort-AV: E=Sophos;i="5.97,248,1669104000"; d="scan'208";a="307155084" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2023 05:34:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="612789692" X-IronPort-AV: E=Sophos;i="5.97,248,1669104000"; d="scan'208";a="612789692" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com) ([10.237.222.53]) by orsmga003.jf.intel.com with ESMTP; 26 Jan 2023 05:34:34 -0800 From: Cristian Dumitrescu To: dev@dpdk.org Cc: Kamalakannan R Subject: [PATCH V5 05/11] examples/pipeline: support crypto devices Date: Thu, 26 Jan 2023 13:34:21 +0000 Message-Id: <20230126133427.379941-6-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230126133427.379941-1-cristian.dumitrescu@intel.com> References: <20230111205608.87953-1-cristian.dumitrescu@intel.com> <20230126133427.379941-1-cristian.dumitrescu@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add support for crypto devices in the application. Signed-off-by: Cristian Dumitrescu Signed-off-by: Kamalakannan R --- examples/pipeline/obj.c | 62 +++++++++++++++++++++++++++++++++++++++++ examples/pipeline/obj.h | 11 ++++++++ 2 files changed, 73 insertions(+) diff --git a/examples/pipeline/obj.c b/examples/pipeline/obj.c index 143b968472..d39034ec22 100644 --- a/examples/pipeline/obj.c +++ b/examples/pipeline/obj.c @@ -7,6 +7,7 @@ #include #include +#include #include "obj.h" @@ -190,3 +191,64 @@ ethdev_config(const char *name, struct ethdev_params *params) return 0; } + +/* + * cryptodev + */ +int +cryptodev_config(const char *name, struct cryptodev_params *params) +{ + struct rte_cryptodev_info dev_info; + struct rte_cryptodev_config dev_conf; + struct rte_cryptodev_qp_conf queue_conf; + uint8_t dev_id; + uint32_t socket_id, i; + int status; + + /* Check input parameters. */ + if (!name || + !params->n_queue_pairs || + !params->queue_size) + return -EINVAL; + + /* Find the crypto device. */ + status = rte_cryptodev_get_dev_id(name); + if (status < 0) + return -EINVAL; + + dev_id = (uint8_t)status; + + rte_cryptodev_info_get(dev_id, &dev_info); + if (params->n_queue_pairs > dev_info.max_nb_queue_pairs) + return -EINVAL; + + socket_id = rte_cryptodev_socket_id(dev_id); + + /* Configure the crypto device. */ + memset(&dev_conf, 0, sizeof(dev_conf)); + dev_conf.socket_id = socket_id; + dev_conf.nb_queue_pairs = params->n_queue_pairs; + dev_conf.ff_disable = 0; + + status = rte_cryptodev_configure(dev_id, &dev_conf); + if (status) + return status; + + /* Configure the crypto device queue pairs. */ + memset(&queue_conf, 0, sizeof(queue_conf)); + queue_conf.nb_descriptors = params->queue_size; + queue_conf.mp_session = NULL; + + for (i = 0; i < params->n_queue_pairs; i++) { + status = rte_cryptodev_queue_pair_setup(dev_id, i, &queue_conf, socket_id); + if (status) + return status; + } + + /* Start the crypto device. */ + status = rte_cryptodev_start(dev_id); + if (status) + return status; + + return 0; +} diff --git a/examples/pipeline/obj.h b/examples/pipeline/obj.h index fb091f4ba7..0f103be6a7 100644 --- a/examples/pipeline/obj.h +++ b/examples/pipeline/obj.h @@ -38,4 +38,15 @@ struct ethdev_params { int ethdev_config(const char *name, struct ethdev_params *params); +/* + * cryptodev + */ +struct cryptodev_params { + uint32_t n_queue_pairs; + uint32_t queue_size; +}; + +int +cryptodev_config(const char *name, struct cryptodev_params *params); + #endif /* _INCLUDE_OBJ_H_ */