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 B18E7A0542;
	Mon, 29 Aug 2022 20:31:27 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id DECC342670;
	Mon, 29 Aug 2022 20:31:23 +0200 (CEST)
Received: from mga05.intel.com (mga05.intel.com [192.55.52.43])
 by mails.dpdk.org (Postfix) with ESMTP id C432B4003C
 for <dev@dpdk.org>; Mon, 29 Aug 2022 20:31:21 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
 t=1661797882; x=1693333882;
 h=from:to:cc:subject:date:message-id:in-reply-to: references;
 bh=aP1yZ1eVoOoP4tXxfwjcIlI1H3nTVAk/ngncb9GfKHs=;
 b=j4ky6pyljL8Z96NLfn+p3efFTD6PWW7/v+pPEnKsO3+xG/RpTHoOEf3j
 1o44WoxRkTbQwqDkj3ksEd8EN7fZEXi9ppUbfyrqxC5YxhlTnsMRgFMQl
 FMtuWmbN3Nggbm1GIt2VZlkVpGP3uxCNksw3OchdK99XTDrEh1GZsShWZ
 I5s9m6LYXaTB1oh8vNGt35KQzdQlMIh1jQ7fnMoPAQOcDw/MSO+dr7F72
 YNFEs12kD72hdskLAJm1mdf2dsBCkLqbZKY995wthzb0QfW6nwses7nWE
 0pPk/dnNdqesDNPbnbw2fxJq8QVJIAxgpF0TSC8y1FqNygUsE2KrG/qyx A==;
X-IronPort-AV: E=McAfee;i="6500,9779,10454"; a="381267877"
X-IronPort-AV: E=Sophos;i="5.93,273,1654585200"; d="scan'208";a="381267877"
Received: from orsmga002.jf.intel.com ([10.7.209.21])
 by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 29 Aug 2022 11:28:16 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.93,273,1654585200"; d="scan'208";a="611396748"
Received: from skx-5gnr-sc12-4.sc.intel.com ([172.25.69.210])
 by orsmga002.jf.intel.com with ESMTP; 29 Aug 2022 11:28:16 -0700
From: Nicolas Chautru <nicolas.chautru@intel.com>
To: dev@dpdk.org, thomas@monjalon.net, gakhil@marvell.com,
 hemant.agrawal@nxp.com
Cc: maxime.coquelin@redhat.com, trix@redhat.com, mdr@ashroe.eu,
 bruce.richardson@intel.com, david.marchand@redhat.com,
 stephen@networkplumber.org, mingshan.zhang@intel.com,
 Nicolas Chautru <nicolas.chautru@intel.com>
Subject: [PATCH v7 1/7] bbdev: allow operation type enum for growth
Date: Mon, 29 Aug 2022 11:07:12 -0700
Message-Id: <1661796438-204861-2-git-send-email-nicolas.chautru@intel.com>
X-Mailer: git-send-email 1.8.3.1
In-Reply-To: <1661796438-204861-1-git-send-email-nicolas.chautru@intel.com>
References: <1655491040-183649-6-git-send-email-nicolas.chautru@intel.com>
 <1661796438-204861-1-git-send-email-nicolas.chautru@intel.com>
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

Updating the enum for rte_bbdev_op_type
to allow to keep ABI compatible for enum insertion
while adding padded maximum value for array need.
Removing RTE_BBDEV_OP_TYPE_COUNT and instead exposing
RTE_BBDEV_OP_TYPE_PADDED_MAX.

Signed-off-by: Nicolas Chautru <nicolas.chautru@intel.com>
Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 app/test-bbdev/test_bbdev.c      | 2 +-
 app/test-bbdev/test_bbdev_perf.c | 4 ++--
 examples/bbdev_app/main.c        | 2 +-
 lib/bbdev/rte_bbdev.c            | 8 +++++---
 lib/bbdev/rte_bbdev_op.h         | 2 +-
 5 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/app/test-bbdev/test_bbdev.c b/app/test-bbdev/test_bbdev.c
index ac06d73..1063f6e 100644
--- a/app/test-bbdev/test_bbdev.c
+++ b/app/test-bbdev/test_bbdev.c
@@ -521,7 +521,7 @@ struct bbdev_testsuite_params {
 	rte_mempool_free(mp);
 
 	TEST_ASSERT((mp = rte_bbdev_op_pool_create("Test_INV",
-			RTE_BBDEV_OP_TYPE_COUNT, size, cache_size, 0)) == NULL,
+			RTE_BBDEV_OP_TYPE_PADDED_MAX, size, cache_size, 0)) == NULL,
 			"Failed test for rte_bbdev_op_pool_create: "
 			"returned value is not NULL for invalid type");
 
diff --git a/app/test-bbdev/test_bbdev_perf.c b/app/test-bbdev/test_bbdev_perf.c
index fad3b1e..1abda2d 100644
--- a/app/test-bbdev/test_bbdev_perf.c
+++ b/app/test-bbdev/test_bbdev_perf.c
@@ -2428,13 +2428,13 @@ typedef int (test_case_function)(struct active_device *ad,
 
 	/* Find capabilities */
 	const struct rte_bbdev_op_cap *cap = info.drv.capabilities;
-	for (i = 0; i < RTE_BBDEV_OP_TYPE_COUNT; i++) {
+	do {
 		if (cap->type == test_vector.op_type) {
 			capabilities = cap;
 			break;
 		}
 		cap++;
-	}
+	} while (cap->type != RTE_BBDEV_OP_NONE);
 	TEST_ASSERT_NOT_NULL(capabilities,
 			"Couldn't find capabilities");
 
diff --git a/examples/bbdev_app/main.c b/examples/bbdev_app/main.c
index fc7e8b8..ef0ba76 100644
--- a/examples/bbdev_app/main.c
+++ b/examples/bbdev_app/main.c
@@ -1041,7 +1041,7 @@ uint16_t bbdev_parse_number(const char *mask)
 	void *sigret;
 	struct app_config_params app_params = def_app_config;
 	struct rte_mempool *ethdev_mbuf_mempool, *bbdev_mbuf_mempool;
-	struct rte_mempool *bbdev_op_pools[RTE_BBDEV_OP_TYPE_COUNT];
+	struct rte_mempool *bbdev_op_pools[RTE_BBDEV_OP_TYPE_PADDED_MAX];
 	struct lcore_conf lcore_conf[RTE_MAX_LCORE] = { {0} };
 	struct lcore_statistics lcore_stats[RTE_MAX_LCORE] = { {0} };
 	struct stats_lcore_params stats_lcore;
diff --git a/lib/bbdev/rte_bbdev.c b/lib/bbdev/rte_bbdev.c
index aaee7b7..4da8047 100644
--- a/lib/bbdev/rte_bbdev.c
+++ b/lib/bbdev/rte_bbdev.c
@@ -23,6 +23,8 @@
 
 #define DEV_NAME "BBDEV"
 
+/* Number of supported operation types */
+#define BBDEV_OP_TYPE_COUNT 5
 
 /* BBDev library logging ID */
 RTE_LOG_REGISTER_DEFAULT(bbdev_logtype, NOTICE);
@@ -890,10 +892,10 @@ struct rte_mempool *
 		return NULL;
 	}
 
-	if (type >= RTE_BBDEV_OP_TYPE_COUNT) {
+	if (type >= BBDEV_OP_TYPE_COUNT) {
 		rte_bbdev_log(ERR,
 				"Invalid op type (%u), should be less than %u",
-				type, RTE_BBDEV_OP_TYPE_COUNT);
+				type, BBDEV_OP_TYPE_COUNT);
 		return NULL;
 	}
 
@@ -1125,7 +1127,7 @@ struct rte_mempool *
 		"RTE_BBDEV_OP_LDPC_ENC",
 	};
 
-	if (op_type < RTE_BBDEV_OP_TYPE_COUNT)
+	if (op_type < BBDEV_OP_TYPE_COUNT)
 		return op_types[op_type];
 
 	rte_bbdev_log(ERR, "Invalid operation type");
diff --git a/lib/bbdev/rte_bbdev_op.h b/lib/bbdev/rte_bbdev_op.h
index 6d56133..cd82418 100644
--- a/lib/bbdev/rte_bbdev_op.h
+++ b/lib/bbdev/rte_bbdev_op.h
@@ -748,7 +748,7 @@ enum rte_bbdev_op_type {
 	RTE_BBDEV_OP_TURBO_ENC,  /**< Turbo encode */
 	RTE_BBDEV_OP_LDPC_DEC,  /**< LDPC decode */
 	RTE_BBDEV_OP_LDPC_ENC,  /**< LDPC encode */
-	RTE_BBDEV_OP_TYPE_COUNT,  /**< Count of different op types */
+	RTE_BBDEV_OP_TYPE_PADDED_MAX = 8,  /**< Maximum op type number including padding */
 };
 
 /** Bit indexes of possible errors reported through status field */
-- 
1.8.3.1