From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id A80A6423B9;
	Thu, 12 Jan 2023 19:54:19 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 93E1F42DE4;
	Thu, 12 Jan 2023 19:53:47 +0100 (CET)
Received: from mga12.intel.com (mga12.intel.com [192.55.52.136])
 by mails.dpdk.org (Postfix) with ESMTP id 20A9C42DAA
 for <dev@dpdk.org>; Thu, 12 Jan 2023 19:53:43 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
 t=1673549624; x=1705085624;
 h=from:to:cc:subject:date:message-id:in-reply-to:
 references:mime-version:content-transfer-encoding;
 bh=bzOmMugsCc0pjffVlwoR5gQo8EaXD5vBauS4473DygM=;
 b=F5ztvO0xpLaoGac5PFXbEhZwBj66th51UxKwmCdOgHpewFyEvks0tpCs
 zqeSV6gXyiC1haCx7QjbH7j2iEFDNmQF/ETeZT87eA9v0jbomIIfnWOyP
 57i7tw9/w0AMwgY1Jd0i0DHXC0RWh1Y23mAbMj39C+S/JHfFOUwVnYpI5
 zunJbtG+eJVB2XahR9HCHv2hFOfH+T5aiyIeVxt7QuGzQEd0yhLyGEh87
 hiex3w3/EDXw+uR10N9oMmbh/xlmifPdvniBEIe/mPhyNRet5BcgQTvpI
 WLF3/pUbBKR13HPwvWQf8dPxfXj2urkaUUFf55a6rVp8rDEFqqCmllCyL w==;
X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="303492910"
X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="303492910"
Received: from fmsmga003.fm.intel.com ([10.253.24.29])
 by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 12 Jan 2023 10:53:43 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="746648018"
X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="746648018"
Received: from silpixa00400573.ir.intel.com (HELO
 silpixa00400573.ger.corp.intel.com) ([10.237.222.53])
 by FMSMGA003.fm.intel.com with ESMTP; 12 Jan 2023 10:53:42 -0800
From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
To: dev@dpdk.org
Cc: Kamalakannan R <kamalakannan.r@intel.com>
Subject: [PATCH V4 05/11] examples/pipeline: support crypto devices
Date: Thu, 12 Jan 2023 18:53:29 +0000
Message-Id: <20230112185335.247116-6-cristian.dumitrescu@intel.com>
X-Mailer: git-send-email 2.34.1
In-Reply-To: <20230112185335.247116-1-cristian.dumitrescu@intel.com>
References: <20230111205608.87953-1-cristian.dumitrescu@intel.com>
 <20230112185335.247116-1-cristian.dumitrescu@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

Add support for crypto devices in the application.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Kamalakannan R <kamalakannan.r@intel.com>
---
 examples/pipeline/obj.c | 60 +++++++++++++++++++++++++++++++++++++++++
 examples/pipeline/obj.h | 11 ++++++++
 2 files changed, 71 insertions(+)

diff --git a/examples/pipeline/obj.c b/examples/pipeline/obj.c
index 143b968472..25bfd2da4f 100644
--- a/examples/pipeline/obj.c
+++ b/examples/pipeline/obj.c
@@ -7,6 +7,7 @@
 
 #include <rte_mbuf.h>
 #include <rte_ethdev.h>
+#include <rte_cryptodev.h>
 
 #include "obj.h"
 
@@ -190,3 +191,62 @@ 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 = {0};
+	struct rte_cryptodev_qp_conf queue_conf = {0};
+	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. */
+	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. */
+	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_ */
-- 
2.34.1