xref: /dpdk/app/test-bbdev/test_bbdev_vector.c (revision 795ae2df)
1f714a188SAmr Mokhtar /* SPDX-License-Identifier: BSD-3-Clause
2f714a188SAmr Mokhtar  * Copyright(c) 2017 Intel Corporation
3f714a188SAmr Mokhtar  */
4f714a188SAmr Mokhtar 
5f714a188SAmr Mokhtar #ifdef RTE_EXEC_ENV_BSDAPP
6f714a188SAmr Mokhtar 	#define _WITH_GETLINE
7f714a188SAmr Mokhtar #endif
8f714a188SAmr Mokhtar #include <stdio.h>
9f714a188SAmr Mokhtar #include <stdbool.h>
10f714a188SAmr Mokhtar #include <rte_malloc.h>
11f714a188SAmr Mokhtar 
12f714a188SAmr Mokhtar #include "test_bbdev_vector.h"
13f714a188SAmr Mokhtar 
14f714a188SAmr Mokhtar #define VALUE_DELIMITER ","
15f714a188SAmr Mokhtar #define ENTRY_DELIMITER "="
16f714a188SAmr Mokhtar 
17f714a188SAmr Mokhtar const char *op_data_prefixes[] = {
18f714a188SAmr Mokhtar 	"input",
19f714a188SAmr Mokhtar 	"soft_output",
20f714a188SAmr Mokhtar 	"hard_output",
21f714a188SAmr Mokhtar };
22f714a188SAmr Mokhtar 
23f714a188SAmr Mokhtar /* trim leading and trailing spaces */
24f714a188SAmr Mokhtar static void
25f714a188SAmr Mokhtar trim_space(char *str)
26f714a188SAmr Mokhtar {
27f714a188SAmr Mokhtar 	char *start, *end;
28f714a188SAmr Mokhtar 
29f714a188SAmr Mokhtar 	for (start = str; *start; start++) {
30f714a188SAmr Mokhtar 		if (!isspace((unsigned char) start[0]))
31f714a188SAmr Mokhtar 			break;
32f714a188SAmr Mokhtar 	}
33f714a188SAmr Mokhtar 
34f714a188SAmr Mokhtar 	for (end = start + strlen(start); end > start + 1; end--) {
35f714a188SAmr Mokhtar 		if (!isspace((unsigned char) end[-1]))
36f714a188SAmr Mokhtar 			break;
37f714a188SAmr Mokhtar 	}
38f714a188SAmr Mokhtar 
39f714a188SAmr Mokhtar 	*end = 0;
40f714a188SAmr Mokhtar 
41f714a188SAmr Mokhtar 	/* Shift from "start" to the beginning of the string */
42f714a188SAmr Mokhtar 	if (start > str)
43f714a188SAmr Mokhtar 		memmove(str, start, (end - start) + 1);
44f714a188SAmr Mokhtar }
45f714a188SAmr Mokhtar 
46f714a188SAmr Mokhtar static bool
47f714a188SAmr Mokhtar starts_with(const char *str, const char *pre)
48f714a188SAmr Mokhtar {
49f714a188SAmr Mokhtar 	return strncmp(pre, str, strlen(pre)) == 0;
50f714a188SAmr Mokhtar }
51f714a188SAmr Mokhtar 
52f714a188SAmr Mokhtar /* tokenization test values separated by a comma */
53f714a188SAmr Mokhtar static int
54f714a188SAmr Mokhtar parse_values(char *tokens, uint32_t **data, uint32_t *data_length)
55f714a188SAmr Mokhtar {
56f714a188SAmr Mokhtar 	uint32_t n_tokens = 0;
57f714a188SAmr Mokhtar 	uint32_t data_size = 32;
58f714a188SAmr Mokhtar 
59f714a188SAmr Mokhtar 	uint32_t *values, *values_resized;
60f714a188SAmr Mokhtar 	char *tok, *error = NULL;
61f714a188SAmr Mokhtar 
62f714a188SAmr Mokhtar 	tok = strtok(tokens, VALUE_DELIMITER);
63f714a188SAmr Mokhtar 	if (tok == NULL)
64f714a188SAmr Mokhtar 		return -1;
65f714a188SAmr Mokhtar 
66f714a188SAmr Mokhtar 	values = (uint32_t *)
67f714a188SAmr Mokhtar 			rte_zmalloc(NULL, sizeof(uint32_t) * data_size, 0);
68f714a188SAmr Mokhtar 	if (values == NULL)
69f714a188SAmr Mokhtar 		return -1;
70f714a188SAmr Mokhtar 
71f714a188SAmr Mokhtar 	while (tok != NULL) {
72f714a188SAmr Mokhtar 		values_resized = NULL;
73f714a188SAmr Mokhtar 
74f714a188SAmr Mokhtar 		if (n_tokens >= data_size) {
75f714a188SAmr Mokhtar 			data_size *= 2;
76f714a188SAmr Mokhtar 
77f714a188SAmr Mokhtar 			values_resized = (uint32_t *) rte_realloc(values,
78f714a188SAmr Mokhtar 				sizeof(uint32_t) * data_size, 0);
79f714a188SAmr Mokhtar 			if (values_resized == NULL) {
80f714a188SAmr Mokhtar 				rte_free(values);
81f714a188SAmr Mokhtar 				return -1;
82f714a188SAmr Mokhtar 			}
83f714a188SAmr Mokhtar 			values = values_resized;
84f714a188SAmr Mokhtar 		}
85f714a188SAmr Mokhtar 
86f714a188SAmr Mokhtar 		values[n_tokens] = (uint32_t) strtoul(tok, &error, 0);
87f714a188SAmr Mokhtar 		if ((error == NULL) || (*error != '\0')) {
88f714a188SAmr Mokhtar 			printf("Failed with convert '%s'\n", tok);
89f714a188SAmr Mokhtar 			rte_free(values);
90f714a188SAmr Mokhtar 			return -1;
91f714a188SAmr Mokhtar 		}
92f714a188SAmr Mokhtar 
93f714a188SAmr Mokhtar 		*data_length = *data_length + (strlen(tok) - strlen("0x"))/2;
94f714a188SAmr Mokhtar 
95f714a188SAmr Mokhtar 		tok = strtok(NULL, VALUE_DELIMITER);
96f714a188SAmr Mokhtar 		if (tok == NULL)
97f714a188SAmr Mokhtar 			break;
98f714a188SAmr Mokhtar 
99f714a188SAmr Mokhtar 		n_tokens++;
100f714a188SAmr Mokhtar 	}
101f714a188SAmr Mokhtar 
102f714a188SAmr Mokhtar 	values_resized = (uint32_t *) rte_realloc(values,
103f714a188SAmr Mokhtar 		sizeof(uint32_t) * (n_tokens + 1), 0);
104f714a188SAmr Mokhtar 
105f714a188SAmr Mokhtar 	if (values_resized == NULL) {
106f714a188SAmr Mokhtar 		rte_free(values);
107f714a188SAmr Mokhtar 		return -1;
108f714a188SAmr Mokhtar 	}
109f714a188SAmr Mokhtar 
110f714a188SAmr Mokhtar 	*data = values_resized;
111f714a188SAmr Mokhtar 
112f714a188SAmr Mokhtar 	return 0;
113f714a188SAmr Mokhtar }
114f714a188SAmr Mokhtar 
115f714a188SAmr Mokhtar /* convert turbo decoder flag from string to unsigned long int*/
116f714a188SAmr Mokhtar static int
117f714a188SAmr Mokhtar op_decoder_flag_strtoul(char *token, uint32_t *op_flag_value)
118f714a188SAmr Mokhtar {
119f714a188SAmr Mokhtar 	if (!strcmp(token, "RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE"))
120f714a188SAmr Mokhtar 		*op_flag_value = RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE;
121f714a188SAmr Mokhtar 	else if (!strcmp(token, "RTE_BBDEV_TURBO_CRC_TYPE_24B"))
122f714a188SAmr Mokhtar 		*op_flag_value = RTE_BBDEV_TURBO_CRC_TYPE_24B;
123f714a188SAmr Mokhtar 	else if (!strcmp(token, "RTE_BBDEV_TURBO_EQUALIZER"))
124f714a188SAmr Mokhtar 		*op_flag_value = RTE_BBDEV_TURBO_EQUALIZER;
125f714a188SAmr Mokhtar 	else if (!strcmp(token, "RTE_BBDEV_TURBO_SOFT_OUT_SATURATE"))
126f714a188SAmr Mokhtar 		*op_flag_value = RTE_BBDEV_TURBO_SOFT_OUT_SATURATE;
127f714a188SAmr Mokhtar 	else if (!strcmp(token, "RTE_BBDEV_TURBO_HALF_ITERATION_EVEN"))
128f714a188SAmr Mokhtar 		*op_flag_value = RTE_BBDEV_TURBO_HALF_ITERATION_EVEN;
129f714a188SAmr Mokhtar 	else if (!strcmp(token, "RTE_BBDEV_TURBO_CONTINUE_CRC_MATCH"))
130f714a188SAmr Mokhtar 		*op_flag_value = RTE_BBDEV_TURBO_CONTINUE_CRC_MATCH;
131f714a188SAmr Mokhtar 	else if (!strcmp(token, "RTE_BBDEV_TURBO_SOFT_OUTPUT"))
132f714a188SAmr Mokhtar 		*op_flag_value = RTE_BBDEV_TURBO_SOFT_OUTPUT;
133f714a188SAmr Mokhtar 	else if (!strcmp(token, "RTE_BBDEV_TURBO_EARLY_TERMINATION"))
134f714a188SAmr Mokhtar 		*op_flag_value = RTE_BBDEV_TURBO_EARLY_TERMINATION;
135f714a188SAmr Mokhtar 	else if (!strcmp(token, "RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN"))
136f714a188SAmr Mokhtar 		*op_flag_value = RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN;
137f714a188SAmr Mokhtar 	else if (!strcmp(token, "RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN"))
138f714a188SAmr Mokhtar 		*op_flag_value = RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN;
139f714a188SAmr Mokhtar 	else if (!strcmp(token, "RTE_BBDEV_TURBO_POS_LLR_1_BIT_SOFT_OUT"))
140f714a188SAmr Mokhtar 		*op_flag_value = RTE_BBDEV_TURBO_POS_LLR_1_BIT_SOFT_OUT;
141f714a188SAmr Mokhtar 	else if (!strcmp(token, "RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT"))
142f714a188SAmr Mokhtar 		*op_flag_value = RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT;
143f714a188SAmr Mokhtar 	else if (!strcmp(token, "RTE_BBDEV_TURBO_MAP_DEC"))
144f714a188SAmr Mokhtar 		*op_flag_value = RTE_BBDEV_TURBO_MAP_DEC;
145f714a188SAmr Mokhtar 	else if (!strcmp(token, "RTE_BBDEV_TURBO_DEC_SCATTER_GATHER"))
146f714a188SAmr Mokhtar 		*op_flag_value = RTE_BBDEV_TURBO_DEC_SCATTER_GATHER;
147*795ae2dfSKamil Chalupnik 	else if (!strcmp(token, "RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP"))
148*795ae2dfSKamil Chalupnik 		*op_flag_value = RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP;
149f714a188SAmr Mokhtar 	else {
150f714a188SAmr Mokhtar 		printf("The given value is not a turbo decoder flag\n");
151f714a188SAmr Mokhtar 		return -1;
152f714a188SAmr Mokhtar 	}
153f714a188SAmr Mokhtar 
154f714a188SAmr Mokhtar 	return 0;
155f714a188SAmr Mokhtar }
156f714a188SAmr Mokhtar 
157f714a188SAmr Mokhtar /* convert turbo encoder flag from string to unsigned long int*/
158f714a188SAmr Mokhtar static int
159f714a188SAmr Mokhtar op_encoder_flag_strtoul(char *token, uint32_t *op_flag_value)
160f714a188SAmr Mokhtar {
161f714a188SAmr Mokhtar 	if (!strcmp(token, "RTE_BBDEV_TURBO_RV_INDEX_BYPASS"))
162f714a188SAmr Mokhtar 		*op_flag_value = RTE_BBDEV_TURBO_RV_INDEX_BYPASS;
163f714a188SAmr Mokhtar 	else if (!strcmp(token, "RTE_BBDEV_TURBO_RATE_MATCH"))
164f714a188SAmr Mokhtar 		*op_flag_value = RTE_BBDEV_TURBO_RATE_MATCH;
165f714a188SAmr Mokhtar 	else if (!strcmp(token, "RTE_BBDEV_TURBO_CRC_24B_ATTACH"))
166f714a188SAmr Mokhtar 		*op_flag_value = RTE_BBDEV_TURBO_CRC_24B_ATTACH;
167f714a188SAmr Mokhtar 	else if (!strcmp(token, "RTE_BBDEV_TURBO_CRC_24A_ATTACH"))
168f714a188SAmr Mokhtar 		*op_flag_value = RTE_BBDEV_TURBO_CRC_24A_ATTACH;
169f714a188SAmr Mokhtar 	else if (!strcmp(token, "RTE_BBDEV_TURBO_ENC_SCATTER_GATHER"))
170f714a188SAmr Mokhtar 		*op_flag_value = RTE_BBDEV_TURBO_ENC_SCATTER_GATHER;
171f714a188SAmr Mokhtar 	else {
172f714a188SAmr Mokhtar 		printf("The given value is not a turbo encoder flag\n");
173f714a188SAmr Mokhtar 		return -1;
174f714a188SAmr Mokhtar 	}
175f714a188SAmr Mokhtar 
176f714a188SAmr Mokhtar 	return 0;
177f714a188SAmr Mokhtar }
178f714a188SAmr Mokhtar 
179f714a188SAmr Mokhtar /* tokenization turbo decoder/encoder flags values separated by a comma */
180f714a188SAmr Mokhtar static int
181f714a188SAmr Mokhtar parse_turbo_flags(char *tokens, uint32_t *op_flags,
182f714a188SAmr Mokhtar 		enum rte_bbdev_op_type op_type)
183f714a188SAmr Mokhtar {
184f714a188SAmr Mokhtar 	char *tok = NULL;
185f714a188SAmr Mokhtar 	uint32_t op_flag_value = 0;
186f714a188SAmr Mokhtar 
187f714a188SAmr Mokhtar 	tok = strtok(tokens, VALUE_DELIMITER);
188f714a188SAmr Mokhtar 	if (tok == NULL)
189f714a188SAmr Mokhtar 		return -1;
190f714a188SAmr Mokhtar 
191f714a188SAmr Mokhtar 	while (tok != NULL) {
192f714a188SAmr Mokhtar 		trim_space(tok);
193f714a188SAmr Mokhtar 		if (op_type == RTE_BBDEV_OP_TURBO_DEC) {
194f714a188SAmr Mokhtar 			if (op_decoder_flag_strtoul(tok, &op_flag_value) == -1)
195f714a188SAmr Mokhtar 				return -1;
196f714a188SAmr Mokhtar 		} else if (op_type == RTE_BBDEV_OP_TURBO_ENC) {
197f714a188SAmr Mokhtar 			if (op_encoder_flag_strtoul(tok, &op_flag_value) == -1)
198f714a188SAmr Mokhtar 				return -1;
199f714a188SAmr Mokhtar 		} else {
200f714a188SAmr Mokhtar 			return -1;
201f714a188SAmr Mokhtar 		}
202f714a188SAmr Mokhtar 
203f714a188SAmr Mokhtar 		*op_flags = *op_flags | op_flag_value;
204f714a188SAmr Mokhtar 
205f714a188SAmr Mokhtar 		tok = strtok(NULL, VALUE_DELIMITER);
206f714a188SAmr Mokhtar 		if (tok == NULL)
207f714a188SAmr Mokhtar 			break;
208f714a188SAmr Mokhtar 	}
209f714a188SAmr Mokhtar 
210f714a188SAmr Mokhtar 	return 0;
211f714a188SAmr Mokhtar }
212f714a188SAmr Mokhtar 
213f714a188SAmr Mokhtar /* convert turbo encoder/decoder op_type from string to enum*/
214f714a188SAmr Mokhtar static int
215f714a188SAmr Mokhtar op_turbo_type_strtol(char *token, enum rte_bbdev_op_type *op_type)
216f714a188SAmr Mokhtar {
217f714a188SAmr Mokhtar 	trim_space(token);
218f714a188SAmr Mokhtar 	if (!strcmp(token, "RTE_BBDEV_OP_TURBO_DEC"))
219f714a188SAmr Mokhtar 		*op_type = RTE_BBDEV_OP_TURBO_DEC;
220f714a188SAmr Mokhtar 	else if (!strcmp(token, "RTE_BBDEV_OP_TURBO_ENC"))
221f714a188SAmr Mokhtar 		*op_type = RTE_BBDEV_OP_TURBO_ENC;
222f714a188SAmr Mokhtar 	else if (!strcmp(token, "RTE_BBDEV_OP_NONE"))
223f714a188SAmr Mokhtar 		*op_type = RTE_BBDEV_OP_NONE;
224f714a188SAmr Mokhtar 	else {
225f714a188SAmr Mokhtar 		printf("Not valid turbo op_type: '%s'\n", token);
226f714a188SAmr Mokhtar 		return -1;
227f714a188SAmr Mokhtar 	}
228f714a188SAmr Mokhtar 
229f714a188SAmr Mokhtar 	return 0;
230f714a188SAmr Mokhtar }
231f714a188SAmr Mokhtar 
232f714a188SAmr Mokhtar /* tokenization expected status values separated by a comma */
233f714a188SAmr Mokhtar static int
234f714a188SAmr Mokhtar parse_expected_status(char *tokens, int *status, enum rte_bbdev_op_type op_type)
235f714a188SAmr Mokhtar {
236f714a188SAmr Mokhtar 	char *tok = NULL;
237f714a188SAmr Mokhtar 	bool status_ok = false;
238f714a188SAmr Mokhtar 
239f714a188SAmr Mokhtar 	tok = strtok(tokens, VALUE_DELIMITER);
240f714a188SAmr Mokhtar 	if (tok == NULL)
241f714a188SAmr Mokhtar 		return -1;
242f714a188SAmr Mokhtar 
243f714a188SAmr Mokhtar 	while (tok != NULL) {
244f714a188SAmr Mokhtar 		trim_space(tok);
245f714a188SAmr Mokhtar 		if (!strcmp(tok, "OK"))
246f714a188SAmr Mokhtar 			status_ok = true;
247f714a188SAmr Mokhtar 		else if (!strcmp(tok, "DMA"))
248f714a188SAmr Mokhtar 			*status = *status | (1 << RTE_BBDEV_DRV_ERROR);
249f714a188SAmr Mokhtar 		else if (!strcmp(tok, "FCW"))
250f714a188SAmr Mokhtar 			*status = *status | (1 << RTE_BBDEV_DATA_ERROR);
251f714a188SAmr Mokhtar 		else if (!strcmp(tok, "CRC")) {
252f714a188SAmr Mokhtar 			if (op_type == RTE_BBDEV_OP_TURBO_DEC)
253f714a188SAmr Mokhtar 				*status = *status | (1 << RTE_BBDEV_CRC_ERROR);
254f714a188SAmr Mokhtar 			else {
255f714a188SAmr Mokhtar 				printf(
256f714a188SAmr Mokhtar 						"CRC is only a valid value for turbo decoder\n");
257f714a188SAmr Mokhtar 				return -1;
258f714a188SAmr Mokhtar 			}
259f714a188SAmr Mokhtar 		} else {
260f714a188SAmr Mokhtar 			printf("Not valid status: '%s'\n", tok);
261f714a188SAmr Mokhtar 			return -1;
262f714a188SAmr Mokhtar 		}
263f714a188SAmr Mokhtar 
264f714a188SAmr Mokhtar 		tok = strtok(NULL, VALUE_DELIMITER);
265f714a188SAmr Mokhtar 		if (tok == NULL)
266f714a188SAmr Mokhtar 			break;
267f714a188SAmr Mokhtar 	}
268f714a188SAmr Mokhtar 
269f714a188SAmr Mokhtar 	if (status_ok && *status != 0) {
270f714a188SAmr Mokhtar 		printf(
271f714a188SAmr Mokhtar 				"Not valid status values. Cannot be OK and ERROR at the same time.\n");
272f714a188SAmr Mokhtar 		return -1;
273f714a188SAmr Mokhtar 	}
274f714a188SAmr Mokhtar 
275f714a188SAmr Mokhtar 	return 0;
276f714a188SAmr Mokhtar }
277f714a188SAmr Mokhtar 
278f714a188SAmr Mokhtar /* parse ops data entry (there can be more than 1 input entry, each will be
279f714a188SAmr Mokhtar  * contained in a separate op_data_buf struct)
280f714a188SAmr Mokhtar  */
281f714a188SAmr Mokhtar static int
282f714a188SAmr Mokhtar parse_data_entry(const char *key_token, char *token,
283f714a188SAmr Mokhtar 		struct test_bbdev_vector *vector, enum op_data_type type,
284f714a188SAmr Mokhtar 		const char *prefix)
285f714a188SAmr Mokhtar {
286f714a188SAmr Mokhtar 	int ret;
287f714a188SAmr Mokhtar 	uint32_t data_length = 0;
288f714a188SAmr Mokhtar 	uint32_t *data = NULL;
289f714a188SAmr Mokhtar 	unsigned int id;
290f714a188SAmr Mokhtar 	struct op_data_buf *op_data;
291f714a188SAmr Mokhtar 	unsigned int *nb_ops;
292f714a188SAmr Mokhtar 
29321820350SAmr Mokhtar 	if (type >= DATA_NUM_TYPES) {
294f714a188SAmr Mokhtar 		printf("Unknown op type: %d!\n", type);
295f714a188SAmr Mokhtar 		return -1;
296f714a188SAmr Mokhtar 	}
297f714a188SAmr Mokhtar 
298f714a188SAmr Mokhtar 	op_data = vector->entries[type].segments;
299f714a188SAmr Mokhtar 	nb_ops = &vector->entries[type].nb_segments;
300f714a188SAmr Mokhtar 
301f714a188SAmr Mokhtar 	if (*nb_ops >= RTE_BBDEV_MAX_CODE_BLOCKS) {
302f714a188SAmr Mokhtar 		printf("Too many segments (code blocks defined): %u, max %d!\n",
303f714a188SAmr Mokhtar 				*nb_ops, RTE_BBDEV_MAX_CODE_BLOCKS);
304f714a188SAmr Mokhtar 		return -1;
305f714a188SAmr Mokhtar 	}
306f714a188SAmr Mokhtar 
307f714a188SAmr Mokhtar 	if (sscanf(key_token + strlen(prefix), "%u", &id) != 1) {
308f714a188SAmr Mokhtar 		printf("Missing ID of %s\n", prefix);
309f714a188SAmr Mokhtar 		return -1;
310f714a188SAmr Mokhtar 	}
311f714a188SAmr Mokhtar 	if (id != *nb_ops) {
312f714a188SAmr Mokhtar 		printf(
313f714a188SAmr Mokhtar 			"Please order data entries sequentially, i.e. %s0, %s1, ...\n",
314f714a188SAmr Mokhtar 				prefix, prefix);
315f714a188SAmr Mokhtar 		return -1;
316f714a188SAmr Mokhtar 	}
317f714a188SAmr Mokhtar 
318f714a188SAmr Mokhtar 	/* Clear new op data struct */
319f714a188SAmr Mokhtar 	memset(op_data + *nb_ops, 0, sizeof(struct op_data_buf));
320f714a188SAmr Mokhtar 
321f714a188SAmr Mokhtar 	ret = parse_values(token, &data, &data_length);
322f714a188SAmr Mokhtar 	if (!ret) {
323f714a188SAmr Mokhtar 		op_data[*nb_ops].addr = data;
324f714a188SAmr Mokhtar 		op_data[*nb_ops].length = data_length;
325f714a188SAmr Mokhtar 		++(*nb_ops);
326f714a188SAmr Mokhtar 	}
327f714a188SAmr Mokhtar 
328f714a188SAmr Mokhtar 	return ret;
329f714a188SAmr Mokhtar }
330f714a188SAmr Mokhtar 
331f714a188SAmr Mokhtar /* parses turbo decoder parameters and assigns to global variable */
332f714a188SAmr Mokhtar static int
333f714a188SAmr Mokhtar parse_decoder_params(const char *key_token, char *token,
334f714a188SAmr Mokhtar 		struct test_bbdev_vector *vector)
335f714a188SAmr Mokhtar {
336f714a188SAmr Mokhtar 	int ret = 0, status = 0;
337f714a188SAmr Mokhtar 	uint32_t op_flags = 0;
338f714a188SAmr Mokhtar 	char *err = NULL;
339f714a188SAmr Mokhtar 
340f714a188SAmr Mokhtar 	struct rte_bbdev_op_turbo_dec *turbo_dec = &vector->turbo_dec;
341f714a188SAmr Mokhtar 
342f714a188SAmr Mokhtar 	/* compare keys */
343f714a188SAmr Mokhtar 	if (starts_with(key_token, op_data_prefixes[DATA_INPUT]))
344f714a188SAmr Mokhtar 		ret = parse_data_entry(key_token, token, vector,
345f714a188SAmr Mokhtar 				DATA_INPUT, op_data_prefixes[DATA_INPUT]);
346f714a188SAmr Mokhtar 
347f714a188SAmr Mokhtar 	else if (starts_with(key_token, op_data_prefixes[DATA_SOFT_OUTPUT]))
348f714a188SAmr Mokhtar 		ret = parse_data_entry(key_token, token, vector,
349f714a188SAmr Mokhtar 				DATA_SOFT_OUTPUT,
350f714a188SAmr Mokhtar 				op_data_prefixes[DATA_SOFT_OUTPUT]);
351f714a188SAmr Mokhtar 
352f714a188SAmr Mokhtar 	else if (starts_with(key_token, op_data_prefixes[DATA_HARD_OUTPUT]))
353f714a188SAmr Mokhtar 		ret = parse_data_entry(key_token, token, vector,
354f714a188SAmr Mokhtar 				DATA_HARD_OUTPUT,
355f714a188SAmr Mokhtar 				op_data_prefixes[DATA_HARD_OUTPUT]);
356f714a188SAmr Mokhtar 	else if (!strcmp(key_token, "e")) {
357f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_E;
358f714a188SAmr Mokhtar 		turbo_dec->cb_params.e = (uint32_t) strtoul(token, &err, 0);
359f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "ea")) {
360f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_EA;
361f714a188SAmr Mokhtar 		turbo_dec->tb_params.ea = (uint32_t) strtoul(token, &err, 0);
362f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
363f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "eb")) {
364f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_EB;
365f714a188SAmr Mokhtar 		turbo_dec->tb_params.eb = (uint32_t) strtoul(token, &err, 0);
366f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
367f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "k")) {
368f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_K;
369f714a188SAmr Mokhtar 		turbo_dec->cb_params.k = (uint16_t) strtoul(token, &err, 0);
370f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
371f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "k_pos")) {
372f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_K_POS;
373f714a188SAmr Mokhtar 		turbo_dec->tb_params.k_pos = (uint16_t) strtoul(token, &err, 0);
374f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
375f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "k_neg")) {
376f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_K_NEG;
377f714a188SAmr Mokhtar 		turbo_dec->tb_params.k_neg = (uint16_t) strtoul(token, &err, 0);
378f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
379f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "c")) {
380f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_C;
381f714a188SAmr Mokhtar 		turbo_dec->tb_params.c = (uint16_t) strtoul(token, &err, 0);
382f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
383f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "c_neg")) {
384f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_C_NEG;
385f714a188SAmr Mokhtar 		turbo_dec->tb_params.c_neg = (uint16_t) strtoul(token, &err, 0);
386f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
387f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "cab")) {
388f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_CAB;
389f714a188SAmr Mokhtar 		turbo_dec->tb_params.cab = (uint8_t) strtoul(token, &err, 0);
390f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
391f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "rv_index")) {
392f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_RV_INDEX;
393f714a188SAmr Mokhtar 		turbo_dec->rv_index = (uint8_t) strtoul(token, &err, 0);
394f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
395f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "iter_max")) {
396f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_ITER_MAX;
397f714a188SAmr Mokhtar 		turbo_dec->iter_max = (uint8_t) strtoul(token, &err, 0);
398f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
399f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "iter_min")) {
400f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_ITER_MIN;
401f714a188SAmr Mokhtar 		turbo_dec->iter_min = (uint8_t) strtoul(token, &err, 0);
402f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
403f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "expected_iter_count")) {
404f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_EXPECTED_ITER_COUNT;
405f714a188SAmr Mokhtar 		turbo_dec->iter_count = (uint8_t) strtoul(token, &err, 0);
406f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
407f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "ext_scale")) {
408f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_EXT_SCALE;
409f714a188SAmr Mokhtar 		turbo_dec->ext_scale = (uint8_t) strtoul(token, &err, 0);
410f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
411f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "num_maps")) {
412f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_NUM_MAPS;
413f714a188SAmr Mokhtar 		turbo_dec->num_maps = (uint8_t) strtoul(token, &err, 0);
414f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
415f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "code_block_mode")) {
416f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_CODE_BLOCK_MODE;
417f714a188SAmr Mokhtar 		turbo_dec->code_block_mode = (uint8_t) strtoul(token, &err, 0);
418f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
419f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "op_flags")) {
420f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_OP_FLAGS;
421f714a188SAmr Mokhtar 		ret = parse_turbo_flags(token, &op_flags,
422f714a188SAmr Mokhtar 			vector->op_type);
423f714a188SAmr Mokhtar 		if (!ret)
424f714a188SAmr Mokhtar 			turbo_dec->op_flags = op_flags;
425f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "expected_status")) {
426f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_EXPECTED_STATUS;
427f714a188SAmr Mokhtar 		ret = parse_expected_status(token, &status, vector->op_type);
428f714a188SAmr Mokhtar 		if (!ret)
429f714a188SAmr Mokhtar 			vector->expected_status = status;
430f714a188SAmr Mokhtar 	} else {
431f714a188SAmr Mokhtar 		printf("Not valid dec key: '%s'\n", key_token);
432f714a188SAmr Mokhtar 		return -1;
433f714a188SAmr Mokhtar 	}
434f714a188SAmr Mokhtar 
435f714a188SAmr Mokhtar 	if (ret != 0) {
436f714a188SAmr Mokhtar 		printf("Failed with convert '%s\t%s'\n", key_token, token);
437f714a188SAmr Mokhtar 		return -1;
438f714a188SAmr Mokhtar 	}
439f714a188SAmr Mokhtar 
440f714a188SAmr Mokhtar 	return 0;
441f714a188SAmr Mokhtar }
442f714a188SAmr Mokhtar 
443f714a188SAmr Mokhtar /* parses turbo encoder parameters and assigns to global variable */
444f714a188SAmr Mokhtar static int
445f714a188SAmr Mokhtar parse_encoder_params(const char *key_token, char *token,
446f714a188SAmr Mokhtar 		struct test_bbdev_vector *vector)
447f714a188SAmr Mokhtar {
448f714a188SAmr Mokhtar 	int ret = 0, status = 0;
449f714a188SAmr Mokhtar 	uint32_t op_flags = 0;
450f714a188SAmr Mokhtar 	char *err = NULL;
451f714a188SAmr Mokhtar 
452f714a188SAmr Mokhtar 
453f714a188SAmr Mokhtar 	struct rte_bbdev_op_turbo_enc *turbo_enc = &vector->turbo_enc;
454f714a188SAmr Mokhtar 
455f714a188SAmr Mokhtar 	if (starts_with(key_token, op_data_prefixes[DATA_INPUT]))
456f714a188SAmr Mokhtar 		ret = parse_data_entry(key_token, token, vector,
457f714a188SAmr Mokhtar 				DATA_INPUT, op_data_prefixes[DATA_INPUT]);
458f714a188SAmr Mokhtar 	else if (starts_with(key_token, "output"))
459f714a188SAmr Mokhtar 		ret = parse_data_entry(key_token, token, vector,
460f714a188SAmr Mokhtar 				DATA_HARD_OUTPUT, "output");
461f714a188SAmr Mokhtar 	else if (!strcmp(key_token, "e")) {
462f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_E;
463f714a188SAmr Mokhtar 		turbo_enc->cb_params.e = (uint32_t) strtoul(token, &err, 0);
464f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
465f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "ea")) {
466f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_EA;
467f714a188SAmr Mokhtar 		turbo_enc->tb_params.ea = (uint32_t) strtoul(token, &err, 0);
468f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
469f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "eb")) {
470f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_EB;
471f714a188SAmr Mokhtar 		turbo_enc->tb_params.eb = (uint32_t) strtoul(token, &err, 0);
472f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
473f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "k")) {
474f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_K;
475f714a188SAmr Mokhtar 		turbo_enc->cb_params.k = (uint16_t) strtoul(token, &err, 0);
476f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
477f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "k_neg")) {
478f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_K_NEG;
479f714a188SAmr Mokhtar 		turbo_enc->tb_params.k_neg = (uint16_t) strtoul(token, &err, 0);
480f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
481f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "k_pos")) {
482f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_K_POS;
483f714a188SAmr Mokhtar 		turbo_enc->tb_params.k_pos = (uint16_t) strtoul(token, &err, 0);
484f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
485f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "c_neg")) {
486f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_C_NEG;
487f714a188SAmr Mokhtar 		turbo_enc->tb_params.c_neg = (uint8_t) strtoul(token, &err, 0);
488f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
489f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "c")) {
490f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_C;
491f714a188SAmr Mokhtar 		turbo_enc->tb_params.c = (uint8_t) strtoul(token, &err, 0);
492f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
493f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "cab")) {
494f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_CAB;
495f714a188SAmr Mokhtar 		turbo_enc->tb_params.cab = (uint8_t) strtoul(token, &err, 0);
496f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
497f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "rv_index")) {
498f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_RV_INDEX;
499f714a188SAmr Mokhtar 		turbo_enc->rv_index = (uint8_t) strtoul(token, &err, 0);
500f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
501f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "ncb")) {
502f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_NCB;
503f714a188SAmr Mokhtar 		turbo_enc->cb_params.ncb = (uint16_t) strtoul(token, &err, 0);
504f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
505f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "ncb_neg")) {
506f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_NCB_NEG;
507f714a188SAmr Mokhtar 		turbo_enc->tb_params.ncb_neg =
508f714a188SAmr Mokhtar 				(uint16_t) strtoul(token, &err, 0);
509f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
510f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "ncb_pos")) {
511f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_NCB_POS;
512f714a188SAmr Mokhtar 		turbo_enc->tb_params.ncb_pos =
513f714a188SAmr Mokhtar 				(uint16_t) strtoul(token, &err, 0);
514f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
515f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "r")) {
516f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_R;
517f714a188SAmr Mokhtar 		turbo_enc->tb_params.r = (uint8_t) strtoul(token, &err, 0);
518f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
519f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "code_block_mode")) {
520f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_CODE_BLOCK_MODE;
521f714a188SAmr Mokhtar 		turbo_enc->code_block_mode = (uint8_t) strtoul(token, &err, 0);
522f714a188SAmr Mokhtar 		ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
523f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "op_flags")) {
524f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_OP_FLAGS;
525f714a188SAmr Mokhtar 		ret = parse_turbo_flags(token, &op_flags,
526f714a188SAmr Mokhtar 				vector->op_type);
527f714a188SAmr Mokhtar 		if (!ret)
528f714a188SAmr Mokhtar 			turbo_enc->op_flags = op_flags;
529f714a188SAmr Mokhtar 	} else if (!strcmp(key_token, "expected_status")) {
530f714a188SAmr Mokhtar 		vector->mask |= TEST_BBDEV_VF_EXPECTED_STATUS;
531f714a188SAmr Mokhtar 		ret = parse_expected_status(token, &status, vector->op_type);
532f714a188SAmr Mokhtar 		if (!ret)
533f714a188SAmr Mokhtar 			vector->expected_status = status;
534f714a188SAmr Mokhtar 	} else {
535f714a188SAmr Mokhtar 		printf("Not valid enc key: '%s'\n", key_token);
536f714a188SAmr Mokhtar 		return -1;
537f714a188SAmr Mokhtar 	}
538f714a188SAmr Mokhtar 
539f714a188SAmr Mokhtar 	if (ret != 0) {
540f714a188SAmr Mokhtar 		printf("Failed with convert '%s\t%s'\n", key_token, token);
541f714a188SAmr Mokhtar 		return -1;
542f714a188SAmr Mokhtar 	}
543f714a188SAmr Mokhtar 
544f714a188SAmr Mokhtar 	return 0;
545f714a188SAmr Mokhtar }
546f714a188SAmr Mokhtar 
547f714a188SAmr Mokhtar /* checks the type of key and assigns data */
548f714a188SAmr Mokhtar static int
549f714a188SAmr Mokhtar parse_entry(char *entry, struct test_bbdev_vector *vector)
550f714a188SAmr Mokhtar {
551f714a188SAmr Mokhtar 	int ret = 0;
552f714a188SAmr Mokhtar 	char *token, *key_token;
553f714a188SAmr Mokhtar 	enum rte_bbdev_op_type op_type = RTE_BBDEV_OP_NONE;
554f714a188SAmr Mokhtar 
555f714a188SAmr Mokhtar 	if (entry == NULL) {
556f714a188SAmr Mokhtar 		printf("Expected entry value\n");
557f714a188SAmr Mokhtar 		return -1;
558f714a188SAmr Mokhtar 	}
559f714a188SAmr Mokhtar 
560f714a188SAmr Mokhtar 	/* get key */
561f714a188SAmr Mokhtar 	token = strtok(entry, ENTRY_DELIMITER);
562f714a188SAmr Mokhtar 	key_token = token;
563f714a188SAmr Mokhtar 	/* get values for key */
564f714a188SAmr Mokhtar 	token = strtok(NULL, ENTRY_DELIMITER);
565f714a188SAmr Mokhtar 
566f714a188SAmr Mokhtar 	if (key_token == NULL || token == NULL) {
567f714a188SAmr Mokhtar 		printf("Expected 'key = values' but was '%.40s'..\n", entry);
568f714a188SAmr Mokhtar 		return -1;
569f714a188SAmr Mokhtar 	}
570f714a188SAmr Mokhtar 	trim_space(key_token);
571f714a188SAmr Mokhtar 
572f714a188SAmr Mokhtar 	/* first key_token has to specify type of operation */
573f714a188SAmr Mokhtar 	if (vector->op_type == RTE_BBDEV_OP_NONE) {
574f714a188SAmr Mokhtar 		if (!strcmp(key_token, "op_type")) {
575f714a188SAmr Mokhtar 			ret = op_turbo_type_strtol(token, &op_type);
576f714a188SAmr Mokhtar 			if (!ret)
577f714a188SAmr Mokhtar 				vector->op_type = op_type;
578f714a188SAmr Mokhtar 			return (!ret) ? 0 : -1;
579f714a188SAmr Mokhtar 		}
580f714a188SAmr Mokhtar 		printf("First key_token (%s) does not specify op_type\n",
581f714a188SAmr Mokhtar 				key_token);
582f714a188SAmr Mokhtar 		return -1;
583f714a188SAmr Mokhtar 	}
584f714a188SAmr Mokhtar 
585f714a188SAmr Mokhtar 	/* compare keys */
586f714a188SAmr Mokhtar 	if (vector->op_type == RTE_BBDEV_OP_TURBO_DEC) {
587f714a188SAmr Mokhtar 		if (parse_decoder_params(key_token, token, vector) == -1)
588f714a188SAmr Mokhtar 			return -1;
589f714a188SAmr Mokhtar 	} else if (vector->op_type == RTE_BBDEV_OP_TURBO_ENC) {
590f714a188SAmr Mokhtar 		if (parse_encoder_params(key_token, token, vector) == -1)
591f714a188SAmr Mokhtar 			return -1;
592f714a188SAmr Mokhtar 	}
593f714a188SAmr Mokhtar 
594f714a188SAmr Mokhtar 	return 0;
595f714a188SAmr Mokhtar }
596f714a188SAmr Mokhtar 
597f714a188SAmr Mokhtar static int
598f714a188SAmr Mokhtar check_decoder_segments(struct test_bbdev_vector *vector)
599f714a188SAmr Mokhtar {
600f714a188SAmr Mokhtar 	unsigned char i;
601f714a188SAmr Mokhtar 	struct rte_bbdev_op_turbo_dec *turbo_dec = &vector->turbo_dec;
602f714a188SAmr Mokhtar 
603f714a188SAmr Mokhtar 	if (vector->entries[DATA_INPUT].nb_segments == 0)
604f714a188SAmr Mokhtar 		return -1;
605f714a188SAmr Mokhtar 
606f714a188SAmr Mokhtar 	for (i = 0; i < vector->entries[DATA_INPUT].nb_segments; i++)
607f714a188SAmr Mokhtar 		if (vector->entries[DATA_INPUT].segments[i].addr == NULL)
608f714a188SAmr Mokhtar 			return -1;
609f714a188SAmr Mokhtar 
610f714a188SAmr Mokhtar 	if (vector->entries[DATA_HARD_OUTPUT].nb_segments == 0)
611f714a188SAmr Mokhtar 		return -1;
612f714a188SAmr Mokhtar 
613f714a188SAmr Mokhtar 	for (i = 0; i < vector->entries[DATA_HARD_OUTPUT].nb_segments;
614f714a188SAmr Mokhtar 			i++)
615f714a188SAmr Mokhtar 		if (vector->entries[DATA_HARD_OUTPUT].segments[i].addr == NULL)
616f714a188SAmr Mokhtar 			return -1;
617f714a188SAmr Mokhtar 
618f714a188SAmr Mokhtar 	if ((turbo_dec->op_flags & RTE_BBDEV_TURBO_SOFT_OUTPUT) &&
619f714a188SAmr Mokhtar 			(vector->entries[DATA_SOFT_OUTPUT].nb_segments == 0))
620f714a188SAmr Mokhtar 		return -1;
621f714a188SAmr Mokhtar 
622f714a188SAmr Mokhtar 	for (i = 0; i < vector->entries[DATA_SOFT_OUTPUT].nb_segments;
623f714a188SAmr Mokhtar 			i++)
624f714a188SAmr Mokhtar 		if (vector->entries[DATA_SOFT_OUTPUT].segments[i].addr == NULL)
625f714a188SAmr Mokhtar 			return -1;
626f714a188SAmr Mokhtar 
627f714a188SAmr Mokhtar 	return 0;
628f714a188SAmr Mokhtar }
629f714a188SAmr Mokhtar 
630f714a188SAmr Mokhtar static int
631f714a188SAmr Mokhtar check_decoder_llr_spec(struct test_bbdev_vector *vector)
632f714a188SAmr Mokhtar {
633f714a188SAmr Mokhtar 	struct rte_bbdev_op_turbo_dec *turbo_dec = &vector->turbo_dec;
634f714a188SAmr Mokhtar 
635f714a188SAmr Mokhtar 	/* Check input LLR sign formalism specification */
636f714a188SAmr Mokhtar 	if ((turbo_dec->op_flags & RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN) &&
637f714a188SAmr Mokhtar 			(turbo_dec->op_flags &
638f714a188SAmr Mokhtar 			RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN)) {
639f714a188SAmr Mokhtar 		printf(
640f714a188SAmr Mokhtar 			"Both positive and negative LLR input flags were set!\n");
641f714a188SAmr Mokhtar 		return -1;
642f714a188SAmr Mokhtar 	}
643f714a188SAmr Mokhtar 	if (!(turbo_dec->op_flags & RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN) &&
644f714a188SAmr Mokhtar 			!(turbo_dec->op_flags &
645f714a188SAmr Mokhtar 			RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN)) {
646f714a188SAmr Mokhtar 		printf(
647f714a188SAmr Mokhtar 			"WARNING: input LLR sign formalism was not specified and will be set to negative LLR for '1' bit\n");
648f714a188SAmr Mokhtar 		turbo_dec->op_flags |= RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN;
649f714a188SAmr Mokhtar 	}
650f714a188SAmr Mokhtar 
651f714a188SAmr Mokhtar 	if (!(turbo_dec->op_flags & RTE_BBDEV_TURBO_SOFT_OUTPUT))
652f714a188SAmr Mokhtar 		return 0;
653f714a188SAmr Mokhtar 
654f714a188SAmr Mokhtar 	/* Check output LLR sign formalism specification */
655f714a188SAmr Mokhtar 	if ((turbo_dec->op_flags & RTE_BBDEV_TURBO_POS_LLR_1_BIT_SOFT_OUT) &&
656f714a188SAmr Mokhtar 			(turbo_dec->op_flags &
657f714a188SAmr Mokhtar 			RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT)) {
658f714a188SAmr Mokhtar 		printf(
659f714a188SAmr Mokhtar 			"Both positive and negative LLR output flags were set!\n");
660f714a188SAmr Mokhtar 		return -1;
661f714a188SAmr Mokhtar 	}
662f714a188SAmr Mokhtar 	if (!(turbo_dec->op_flags & RTE_BBDEV_TURBO_POS_LLR_1_BIT_SOFT_OUT) &&
663f714a188SAmr Mokhtar 			!(turbo_dec->op_flags &
664f714a188SAmr Mokhtar 			RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT)) {
665f714a188SAmr Mokhtar 		printf(
666f714a188SAmr Mokhtar 			"WARNING: soft output LLR sign formalism was not specified and will be set to negative LLR for '1' bit\n");
667f714a188SAmr Mokhtar 		turbo_dec->op_flags |=
668f714a188SAmr Mokhtar 				RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT;
669f714a188SAmr Mokhtar 	}
670f714a188SAmr Mokhtar 
671f714a188SAmr Mokhtar 	return 0;
672f714a188SAmr Mokhtar }
673f714a188SAmr Mokhtar 
674f714a188SAmr Mokhtar /* checks decoder parameters */
675f714a188SAmr Mokhtar static int
676f714a188SAmr Mokhtar check_decoder(struct test_bbdev_vector *vector)
677f714a188SAmr Mokhtar {
678f714a188SAmr Mokhtar 	struct rte_bbdev_op_turbo_dec *turbo_dec = &vector->turbo_dec;
679f714a188SAmr Mokhtar 	const int mask = vector->mask;
680f714a188SAmr Mokhtar 
681f714a188SAmr Mokhtar 	if (check_decoder_segments(vector) < 0)
682f714a188SAmr Mokhtar 		return -1;
683f714a188SAmr Mokhtar 
684f714a188SAmr Mokhtar 	if (check_decoder_llr_spec(vector) < 0)
685f714a188SAmr Mokhtar 		return -1;
686f714a188SAmr Mokhtar 
687f714a188SAmr Mokhtar 	/* Check which params were set */
688f714a188SAmr Mokhtar 	if (!(mask & TEST_BBDEV_VF_CODE_BLOCK_MODE)) {
689f714a188SAmr Mokhtar 		printf(
690f714a188SAmr Mokhtar 			"WARNING: code_block_mode was not specified in vector file and will be set to 1 (0 - TB Mode, 1 - CB mode)\n");
691f714a188SAmr Mokhtar 		turbo_dec->code_block_mode = 1;
692f714a188SAmr Mokhtar 	}
693f714a188SAmr Mokhtar 	if (turbo_dec->code_block_mode == 0) {
694f714a188SAmr Mokhtar 		if (!(mask & TEST_BBDEV_VF_EA))
695f714a188SAmr Mokhtar 			printf(
696f714a188SAmr Mokhtar 				"WARNING: ea was not specified in vector file and will be set to 0\n");
697f714a188SAmr Mokhtar 		if (!(mask & TEST_BBDEV_VF_EB))
698f714a188SAmr Mokhtar 			printf(
699f714a188SAmr Mokhtar 				"WARNING: eb was not specified in vector file and will be set to 0\n");
700f714a188SAmr Mokhtar 		if (!(mask & TEST_BBDEV_VF_K_NEG))
701f714a188SAmr Mokhtar 			printf(
702f714a188SAmr Mokhtar 				"WARNING: k_neg was not specified in vector file and will be set to 0\n");
703f714a188SAmr Mokhtar 		if (!(mask & TEST_BBDEV_VF_K_POS))
704f714a188SAmr Mokhtar 			printf(
705f714a188SAmr Mokhtar 				"WARNING: k_pos was not specified in vector file and will be set to 0\n");
706f714a188SAmr Mokhtar 		if (!(mask & TEST_BBDEV_VF_C_NEG))
707f714a188SAmr Mokhtar 			printf(
708f714a188SAmr Mokhtar 				"WARNING: c_neg was not specified in vector file and will be set to 0\n");
709f714a188SAmr Mokhtar 		if (!(mask & TEST_BBDEV_VF_C)) {
710f714a188SAmr Mokhtar 			printf(
711f714a188SAmr Mokhtar 				"WARNING: c was not specified in vector file and will be set to 1\n");
712f714a188SAmr Mokhtar 			turbo_dec->tb_params.c = 1;
713f714a188SAmr Mokhtar 		}
714f714a188SAmr Mokhtar 		if (!(mask & TEST_BBDEV_VF_CAB))
715f714a188SAmr Mokhtar 			printf(
716f714a188SAmr Mokhtar 				"WARNING: cab was not specified in vector file and will be set to 0\n");
717f714a188SAmr Mokhtar 	} else {
718f714a188SAmr Mokhtar 		if (!(mask & TEST_BBDEV_VF_E))
719f714a188SAmr Mokhtar 			printf(
720f714a188SAmr Mokhtar 				"WARNING: e was not specified in vector file and will be set to 0\n");
721f714a188SAmr Mokhtar 		if (!(mask & TEST_BBDEV_VF_K))
722f714a188SAmr Mokhtar 			printf(
723f714a188SAmr Mokhtar 				"WARNING: k was not specified in vector file and will be set to 0\n");
724f714a188SAmr Mokhtar 	}
725f714a188SAmr Mokhtar 	if (!(mask & TEST_BBDEV_VF_RV_INDEX))
726f714a188SAmr Mokhtar 		printf(
727f714a188SAmr Mokhtar 			"WARNING: rv_index was not specified in vector file and will be set to 0\n");
728f714a188SAmr Mokhtar 	if (!(mask & TEST_BBDEV_VF_ITER_MIN))
729f714a188SAmr Mokhtar 		printf(
730f714a188SAmr Mokhtar 			"WARNING: iter_min was not specified in vector file and will be set to 0\n");
731f714a188SAmr Mokhtar 	if (!(mask & TEST_BBDEV_VF_ITER_MAX))
732f714a188SAmr Mokhtar 		printf(
733f714a188SAmr Mokhtar 			"WARNING: iter_max was not specified in vector file and will be set to 0\n");
734f714a188SAmr Mokhtar 	if (!(mask & TEST_BBDEV_VF_EXPECTED_ITER_COUNT))
735f714a188SAmr Mokhtar 		printf(
736f714a188SAmr Mokhtar 			"WARNING: expected_iter_count was not specified in vector file and iter_count will not be validated\n");
737f714a188SAmr Mokhtar 	if (!(mask & TEST_BBDEV_VF_EXT_SCALE))
738f714a188SAmr Mokhtar 		printf(
739f714a188SAmr Mokhtar 			"WARNING: ext_scale was not specified in vector file and will be set to 0\n");
740f714a188SAmr Mokhtar 	if (!(mask & TEST_BBDEV_VF_OP_FLAGS)) {
741f714a188SAmr Mokhtar 		printf(
742f714a188SAmr Mokhtar 			"WARNING: op_flags was not specified in vector file and capabilities will not be validated\n");
743f714a188SAmr Mokhtar 		turbo_dec->num_maps = 0;
744f714a188SAmr Mokhtar 	} else if (!(turbo_dec->op_flags & RTE_BBDEV_TURBO_MAP_DEC) &&
745f714a188SAmr Mokhtar 			mask & TEST_BBDEV_VF_NUM_MAPS) {
746f714a188SAmr Mokhtar 		printf(
747f714a188SAmr Mokhtar 			"WARNING: RTE_BBDEV_TURBO_MAP_DEC was not set in vector file and num_maps will be set to 0\n");
748f714a188SAmr Mokhtar 		turbo_dec->num_maps = 0;
749f714a188SAmr Mokhtar 	}
750f714a188SAmr Mokhtar 	if (!(mask & TEST_BBDEV_VF_EXPECTED_STATUS))
751f714a188SAmr Mokhtar 		printf(
752f714a188SAmr Mokhtar 			"WARNING: expected_status was not specified in vector file and will be set to 0\n");
753f714a188SAmr Mokhtar 	return 0;
754f714a188SAmr Mokhtar }
755f714a188SAmr Mokhtar 
756f714a188SAmr Mokhtar /* checks encoder parameters */
757f714a188SAmr Mokhtar static int
758f714a188SAmr Mokhtar check_encoder(struct test_bbdev_vector *vector)
759f714a188SAmr Mokhtar {
760f714a188SAmr Mokhtar 	unsigned char i;
761f714a188SAmr Mokhtar 	const int mask = vector->mask;
762f714a188SAmr Mokhtar 
763f714a188SAmr Mokhtar 	if (vector->entries[DATA_INPUT].nb_segments == 0)
764f714a188SAmr Mokhtar 		return -1;
765f714a188SAmr Mokhtar 
766f714a188SAmr Mokhtar 	for (i = 0; i < vector->entries[DATA_INPUT].nb_segments; i++)
767f714a188SAmr Mokhtar 		if (vector->entries[DATA_INPUT].segments[i].addr == NULL)
768f714a188SAmr Mokhtar 			return -1;
769f714a188SAmr Mokhtar 
770f714a188SAmr Mokhtar 	if (vector->entries[DATA_HARD_OUTPUT].nb_segments == 0)
771f714a188SAmr Mokhtar 		return -1;
772f714a188SAmr Mokhtar 
773f714a188SAmr Mokhtar 	for (i = 0; i < vector->entries[DATA_HARD_OUTPUT].nb_segments; i++)
774f714a188SAmr Mokhtar 		if (vector->entries[DATA_HARD_OUTPUT].segments[i].addr == NULL)
775f714a188SAmr Mokhtar 			return -1;
776f714a188SAmr Mokhtar 
777f714a188SAmr Mokhtar 	if (!(mask & TEST_BBDEV_VF_CODE_BLOCK_MODE)) {
778f714a188SAmr Mokhtar 		printf(
779f714a188SAmr Mokhtar 			"WARNING: code_block_mode was not specified in vector file and will be set to 1\n");
780f714a188SAmr Mokhtar 		vector->turbo_enc.code_block_mode = 1;
781f714a188SAmr Mokhtar 	}
782f714a188SAmr Mokhtar 	if (vector->turbo_enc.code_block_mode == 0) {
783f714a188SAmr Mokhtar 		if (!(mask & TEST_BBDEV_VF_EA) && (vector->turbo_enc.op_flags &
784f714a188SAmr Mokhtar 				RTE_BBDEV_TURBO_RATE_MATCH))
785f714a188SAmr Mokhtar 			printf(
786f714a188SAmr Mokhtar 				"WARNING: ea was not specified in vector file and will be set to 0\n");
787f714a188SAmr Mokhtar 		if (!(mask & TEST_BBDEV_VF_EB) && (vector->turbo_enc.op_flags &
788f714a188SAmr Mokhtar 				RTE_BBDEV_TURBO_RATE_MATCH))
789f714a188SAmr Mokhtar 			printf(
790f714a188SAmr Mokhtar 				"WARNING: eb was not specified in vector file and will be set to 0\n");
791f714a188SAmr Mokhtar 		if (!(mask & TEST_BBDEV_VF_K_NEG))
792f714a188SAmr Mokhtar 			printf(
793f714a188SAmr Mokhtar 				"WARNING: k_neg was not specified in vector file and will be set to 0\n");
794f714a188SAmr Mokhtar 		if (!(mask & TEST_BBDEV_VF_K_POS))
795f714a188SAmr Mokhtar 			printf(
796f714a188SAmr Mokhtar 				"WARNING: k_pos was not specified in vector file and will be set to 0\n");
797f714a188SAmr Mokhtar 		if (!(mask & TEST_BBDEV_VF_C_NEG))
798f714a188SAmr Mokhtar 			printf(
799f714a188SAmr Mokhtar 				"WARNING: c_neg was not specified in vector file and will be set to 0\n");
800f714a188SAmr Mokhtar 		if (!(mask & TEST_BBDEV_VF_C)) {
801f714a188SAmr Mokhtar 			printf(
802f714a188SAmr Mokhtar 				"WARNING: c was not specified in vector file and will be set to 1\n");
803f714a188SAmr Mokhtar 			vector->turbo_enc.tb_params.c = 1;
804f714a188SAmr Mokhtar 		}
805f714a188SAmr Mokhtar 		if (!(mask & TEST_BBDEV_VF_CAB) && (vector->turbo_enc.op_flags &
806f714a188SAmr Mokhtar 				RTE_BBDEV_TURBO_RATE_MATCH))
807f714a188SAmr Mokhtar 			printf(
808f714a188SAmr Mokhtar 				"WARNING: cab was not specified in vector file and will be set to 0\n");
809f714a188SAmr Mokhtar 		if (!(mask & TEST_BBDEV_VF_NCB_NEG))
810f714a188SAmr Mokhtar 			printf(
811f714a188SAmr Mokhtar 				"WARNING: ncb_neg was not specified in vector file and will be set to 0\n");
812f714a188SAmr Mokhtar 		if (!(mask & TEST_BBDEV_VF_NCB_POS))
813f714a188SAmr Mokhtar 			printf(
814f714a188SAmr Mokhtar 				"WARNING: ncb_pos was not specified in vector file and will be set to 0\n");
815f714a188SAmr Mokhtar 		if (!(mask & TEST_BBDEV_VF_R))
816f714a188SAmr Mokhtar 			printf(
817f714a188SAmr Mokhtar 				"WARNING: r was not specified in vector file and will be set to 0\n");
818f714a188SAmr Mokhtar 	} else {
819f714a188SAmr Mokhtar 		if (!(mask & TEST_BBDEV_VF_E) && (vector->turbo_enc.op_flags &
820f714a188SAmr Mokhtar 				RTE_BBDEV_TURBO_RATE_MATCH))
821f714a188SAmr Mokhtar 			printf(
822f714a188SAmr Mokhtar 				"WARNING: e was not specified in vector file and will be set to 0\n");
823f714a188SAmr Mokhtar 		if (!(mask & TEST_BBDEV_VF_K))
824f714a188SAmr Mokhtar 			printf(
825f714a188SAmr Mokhtar 				"WARNING: k was not specified in vector file and will be set to 0\n");
826f714a188SAmr Mokhtar 		if (!(mask & TEST_BBDEV_VF_NCB))
827f714a188SAmr Mokhtar 			printf(
828f714a188SAmr Mokhtar 				"WARNING: ncb was not specified in vector file and will be set to 0\n");
829f714a188SAmr Mokhtar 	}
830f714a188SAmr Mokhtar 	if (!(mask & TEST_BBDEV_VF_RV_INDEX))
831f714a188SAmr Mokhtar 		printf(
832f714a188SAmr Mokhtar 			"WARNING: rv_index was not specified in vector file and will be set to 0\n");
833f714a188SAmr Mokhtar 	if (!(mask & TEST_BBDEV_VF_OP_FLAGS))
834f714a188SAmr Mokhtar 		printf(
835f714a188SAmr Mokhtar 			"WARNING: op_flags was not specified in vector file and capabilities will not be validated\n");
836f714a188SAmr Mokhtar 	if (!(mask & TEST_BBDEV_VF_EXPECTED_STATUS))
837f714a188SAmr Mokhtar 		printf(
838f714a188SAmr Mokhtar 			"WARNING: expected_status was not specified in vector file and will be set to 0\n");
839f714a188SAmr Mokhtar 
840f714a188SAmr Mokhtar 	return 0;
841f714a188SAmr Mokhtar }
842f714a188SAmr Mokhtar 
843f714a188SAmr Mokhtar static int
844f714a188SAmr Mokhtar bbdev_check_vector(struct test_bbdev_vector *vector)
845f714a188SAmr Mokhtar {
846f714a188SAmr Mokhtar 	if (vector->op_type == RTE_BBDEV_OP_TURBO_DEC) {
847f714a188SAmr Mokhtar 		if (check_decoder(vector) == -1)
848f714a188SAmr Mokhtar 			return -1;
849f714a188SAmr Mokhtar 	} else if (vector->op_type == RTE_BBDEV_OP_TURBO_ENC) {
850f714a188SAmr Mokhtar 		if (check_encoder(vector) == -1)
851f714a188SAmr Mokhtar 			return -1;
852f714a188SAmr Mokhtar 	} else if (vector->op_type != RTE_BBDEV_OP_NONE) {
853f714a188SAmr Mokhtar 		printf("Vector was not filled\n");
854f714a188SAmr Mokhtar 		return -1;
855f714a188SAmr Mokhtar 	}
856f714a188SAmr Mokhtar 
857f714a188SAmr Mokhtar 	return 0;
858f714a188SAmr Mokhtar }
859f714a188SAmr Mokhtar 
860f714a188SAmr Mokhtar int
861f714a188SAmr Mokhtar test_bbdev_vector_read(const char *filename,
862f714a188SAmr Mokhtar 		struct test_bbdev_vector *vector)
863f714a188SAmr Mokhtar {
864f714a188SAmr Mokhtar 	int ret = 0;
865f714a188SAmr Mokhtar 	size_t len = 0;
866f714a188SAmr Mokhtar 
867f714a188SAmr Mokhtar 	FILE *fp = NULL;
868f714a188SAmr Mokhtar 	char *line = NULL;
869f714a188SAmr Mokhtar 	char *entry = NULL;
870f714a188SAmr Mokhtar 
871f714a188SAmr Mokhtar 	fp = fopen(filename, "r");
872f714a188SAmr Mokhtar 	if (fp == NULL) {
873f714a188SAmr Mokhtar 		printf("File %s does not exist\n", filename);
874f714a188SAmr Mokhtar 		return -1;
875f714a188SAmr Mokhtar 	}
876f714a188SAmr Mokhtar 
877f714a188SAmr Mokhtar 	while (getline(&line, &len, fp) != -1) {
878f714a188SAmr Mokhtar 
879f714a188SAmr Mokhtar 		/* ignore comments and new lines */
880f714a188SAmr Mokhtar 		if (line[0] == '#' || line[0] == '/' || line[0] == '\n'
881f714a188SAmr Mokhtar 			|| line[0] == '\r')
882f714a188SAmr Mokhtar 			continue;
883f714a188SAmr Mokhtar 
884f714a188SAmr Mokhtar 		trim_space(line);
885f714a188SAmr Mokhtar 
886f714a188SAmr Mokhtar 		/* buffer for multiline */
887f714a188SAmr Mokhtar 		entry = realloc(entry, strlen(line) + 1);
888f714a188SAmr Mokhtar 		if (entry == NULL) {
889f714a188SAmr Mokhtar 			printf("Fail to realloc %zu bytes\n", strlen(line) + 1);
890f714a188SAmr Mokhtar 			ret = -ENOMEM;
891f714a188SAmr Mokhtar 			goto exit;
892f714a188SAmr Mokhtar 		}
893f714a188SAmr Mokhtar 
894f714a188SAmr Mokhtar 		memset(entry, 0, strlen(line) + 1);
895f714a188SAmr Mokhtar 		strncpy(entry, line, strlen(line));
896f714a188SAmr Mokhtar 
897f714a188SAmr Mokhtar 		/* check if entry ends with , or = */
898f714a188SAmr Mokhtar 		if (entry[strlen(entry) - 1] == ','
899f714a188SAmr Mokhtar 			|| entry[strlen(entry) - 1] == '=') {
900f714a188SAmr Mokhtar 			while (getline(&line, &len, fp) != -1) {
901f714a188SAmr Mokhtar 				trim_space(line);
902f714a188SAmr Mokhtar 
903f714a188SAmr Mokhtar 				/* extend entry about length of new line */
904f714a188SAmr Mokhtar 				char *entry_extended = realloc(entry,
905f714a188SAmr Mokhtar 						strlen(line) +
906f714a188SAmr Mokhtar 						strlen(entry) + 1);
907f714a188SAmr Mokhtar 
908f714a188SAmr Mokhtar 				if (entry_extended == NULL) {
909f714a188SAmr Mokhtar 					printf("Fail to allocate %zu bytes\n",
910f714a188SAmr Mokhtar 							strlen(line) +
911f714a188SAmr Mokhtar 							strlen(entry) + 1);
912f714a188SAmr Mokhtar 					ret = -ENOMEM;
913f714a188SAmr Mokhtar 					goto exit;
914f714a188SAmr Mokhtar 				}
915f714a188SAmr Mokhtar 
916f714a188SAmr Mokhtar 				entry = entry_extended;
917f714a188SAmr Mokhtar 				strncat(entry, line, strlen(line));
918f714a188SAmr Mokhtar 
919f714a188SAmr Mokhtar 				if (entry[strlen(entry) - 1] != ',')
920f714a188SAmr Mokhtar 					break;
921f714a188SAmr Mokhtar 			}
922f714a188SAmr Mokhtar 		}
923f714a188SAmr Mokhtar 		ret = parse_entry(entry, vector);
924f714a188SAmr Mokhtar 		if (ret != 0) {
925f714a188SAmr Mokhtar 			printf("An error occurred while parsing!\n");
926f714a188SAmr Mokhtar 			goto exit;
927f714a188SAmr Mokhtar 		}
928f714a188SAmr Mokhtar 	}
929f714a188SAmr Mokhtar 	ret = bbdev_check_vector(vector);
930f714a188SAmr Mokhtar 	if (ret != 0)
931f714a188SAmr Mokhtar 		printf("An error occurred while checking!\n");
932f714a188SAmr Mokhtar 
933f714a188SAmr Mokhtar exit:
934f714a188SAmr Mokhtar 	fclose(fp);
935f714a188SAmr Mokhtar 	free(line);
936f714a188SAmr Mokhtar 	free(entry);
937f714a188SAmr Mokhtar 
938f714a188SAmr Mokhtar 	return ret;
939f714a188SAmr Mokhtar }
940