1f714a188SAmr Mokhtar /* SPDX-License-Identifier: BSD-3-Clause 2f714a188SAmr Mokhtar * Copyright(c) 2017 Intel Corporation 3f714a188SAmr Mokhtar */ 4f714a188SAmr Mokhtar 55fbc1d49SBruce Richardson #ifdef RTE_EXEC_ENV_FREEBSD 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", 21d819c083SNicolas Chautru "harq_input", 22d819c083SNicolas Chautru "harq_output", 23f714a188SAmr Mokhtar }; 24f714a188SAmr Mokhtar 25f714a188SAmr Mokhtar /* trim leading and trailing spaces */ 26f714a188SAmr Mokhtar static void 27f714a188SAmr Mokhtar trim_space(char *str) 28f714a188SAmr Mokhtar { 29f714a188SAmr Mokhtar char *start, *end; 30f714a188SAmr Mokhtar 31f714a188SAmr Mokhtar for (start = str; *start; start++) { 32f714a188SAmr Mokhtar if (!isspace((unsigned char) start[0])) 33f714a188SAmr Mokhtar break; 34f714a188SAmr Mokhtar } 35f714a188SAmr Mokhtar 36f714a188SAmr Mokhtar for (end = start + strlen(start); end > start + 1; end--) { 37f714a188SAmr Mokhtar if (!isspace((unsigned char) end[-1])) 38f714a188SAmr Mokhtar break; 39f714a188SAmr Mokhtar } 40f714a188SAmr Mokhtar 41f714a188SAmr Mokhtar *end = 0; 42f714a188SAmr Mokhtar 43f714a188SAmr Mokhtar /* Shift from "start" to the beginning of the string */ 44f714a188SAmr Mokhtar if (start > str) 45f714a188SAmr Mokhtar memmove(str, start, (end - start) + 1); 46f714a188SAmr Mokhtar } 47f714a188SAmr Mokhtar 48f714a188SAmr Mokhtar static bool 49f714a188SAmr Mokhtar starts_with(const char *str, const char *pre) 50f714a188SAmr Mokhtar { 51f714a188SAmr Mokhtar return strncmp(pre, str, strlen(pre)) == 0; 52f714a188SAmr Mokhtar } 53f714a188SAmr Mokhtar 54f714a188SAmr Mokhtar /* tokenization test values separated by a comma */ 55f714a188SAmr Mokhtar static int 56f714a188SAmr Mokhtar parse_values(char *tokens, uint32_t **data, uint32_t *data_length) 57f714a188SAmr Mokhtar { 58f714a188SAmr Mokhtar uint32_t n_tokens = 0; 59f714a188SAmr Mokhtar uint32_t data_size = 32; 60f714a188SAmr Mokhtar 61f714a188SAmr Mokhtar uint32_t *values, *values_resized; 62f714a188SAmr Mokhtar char *tok, *error = NULL; 63f714a188SAmr Mokhtar 64f714a188SAmr Mokhtar tok = strtok(tokens, VALUE_DELIMITER); 65f714a188SAmr Mokhtar if (tok == NULL) 66f714a188SAmr Mokhtar return -1; 67f714a188SAmr Mokhtar 68f714a188SAmr Mokhtar values = (uint32_t *) 69f714a188SAmr Mokhtar rte_zmalloc(NULL, sizeof(uint32_t) * data_size, 0); 70f714a188SAmr Mokhtar if (values == NULL) 71f714a188SAmr Mokhtar return -1; 72f714a188SAmr Mokhtar 73f714a188SAmr Mokhtar while (tok != NULL) { 74f714a188SAmr Mokhtar values_resized = NULL; 75f714a188SAmr Mokhtar 76f714a188SAmr Mokhtar if (n_tokens >= data_size) { 77f714a188SAmr Mokhtar data_size *= 2; 78f714a188SAmr Mokhtar 79f714a188SAmr Mokhtar values_resized = (uint32_t *) rte_realloc(values, 80f714a188SAmr Mokhtar sizeof(uint32_t) * data_size, 0); 81f714a188SAmr Mokhtar if (values_resized == NULL) { 82f714a188SAmr Mokhtar rte_free(values); 83f714a188SAmr Mokhtar return -1; 84f714a188SAmr Mokhtar } 85f714a188SAmr Mokhtar values = values_resized; 86f714a188SAmr Mokhtar } 87f714a188SAmr Mokhtar 88f714a188SAmr Mokhtar values[n_tokens] = (uint32_t) strtoul(tok, &error, 0); 89d819c083SNicolas Chautru 90f714a188SAmr Mokhtar if ((error == NULL) || (*error != '\0')) { 91f714a188SAmr Mokhtar printf("Failed with convert '%s'\n", tok); 92f714a188SAmr Mokhtar rte_free(values); 93f714a188SAmr Mokhtar return -1; 94f714a188SAmr Mokhtar } 95f714a188SAmr Mokhtar 96f714a188SAmr Mokhtar *data_length = *data_length + (strlen(tok) - strlen("0x"))/2; 97f714a188SAmr Mokhtar 98f714a188SAmr Mokhtar tok = strtok(NULL, VALUE_DELIMITER); 99f714a188SAmr Mokhtar if (tok == NULL) 100f714a188SAmr Mokhtar break; 101f714a188SAmr Mokhtar 102f714a188SAmr Mokhtar n_tokens++; 103f714a188SAmr Mokhtar } 104f714a188SAmr Mokhtar 105f714a188SAmr Mokhtar values_resized = (uint32_t *) rte_realloc(values, 106f714a188SAmr Mokhtar sizeof(uint32_t) * (n_tokens + 1), 0); 107f714a188SAmr Mokhtar 108f714a188SAmr Mokhtar if (values_resized == NULL) { 109f714a188SAmr Mokhtar rte_free(values); 110f714a188SAmr Mokhtar return -1; 111f714a188SAmr Mokhtar } 112f714a188SAmr Mokhtar 113f714a188SAmr Mokhtar *data = values_resized; 114f714a188SAmr Mokhtar 115f714a188SAmr Mokhtar return 0; 116f714a188SAmr Mokhtar } 117f714a188SAmr Mokhtar 118f714a188SAmr Mokhtar /* convert turbo decoder flag from string to unsigned long int*/ 119f714a188SAmr Mokhtar static int 120f714a188SAmr Mokhtar op_decoder_flag_strtoul(char *token, uint32_t *op_flag_value) 121f714a188SAmr Mokhtar { 122f714a188SAmr Mokhtar if (!strcmp(token, "RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE")) 123f714a188SAmr Mokhtar *op_flag_value = RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE; 124f714a188SAmr Mokhtar else if (!strcmp(token, "RTE_BBDEV_TURBO_CRC_TYPE_24B")) 125f714a188SAmr Mokhtar *op_flag_value = RTE_BBDEV_TURBO_CRC_TYPE_24B; 126f714a188SAmr Mokhtar else if (!strcmp(token, "RTE_BBDEV_TURBO_EQUALIZER")) 127f714a188SAmr Mokhtar *op_flag_value = RTE_BBDEV_TURBO_EQUALIZER; 128f714a188SAmr Mokhtar else if (!strcmp(token, "RTE_BBDEV_TURBO_SOFT_OUT_SATURATE")) 129f714a188SAmr Mokhtar *op_flag_value = RTE_BBDEV_TURBO_SOFT_OUT_SATURATE; 130f714a188SAmr Mokhtar else if (!strcmp(token, "RTE_BBDEV_TURBO_HALF_ITERATION_EVEN")) 131f714a188SAmr Mokhtar *op_flag_value = RTE_BBDEV_TURBO_HALF_ITERATION_EVEN; 132f714a188SAmr Mokhtar else if (!strcmp(token, "RTE_BBDEV_TURBO_CONTINUE_CRC_MATCH")) 133f714a188SAmr Mokhtar *op_flag_value = RTE_BBDEV_TURBO_CONTINUE_CRC_MATCH; 134f714a188SAmr Mokhtar else if (!strcmp(token, "RTE_BBDEV_TURBO_SOFT_OUTPUT")) 135f714a188SAmr Mokhtar *op_flag_value = RTE_BBDEV_TURBO_SOFT_OUTPUT; 136f714a188SAmr Mokhtar else if (!strcmp(token, "RTE_BBDEV_TURBO_EARLY_TERMINATION")) 137f714a188SAmr Mokhtar *op_flag_value = RTE_BBDEV_TURBO_EARLY_TERMINATION; 138f714a188SAmr Mokhtar else if (!strcmp(token, "RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN")) 139f714a188SAmr Mokhtar *op_flag_value = RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN; 140f714a188SAmr Mokhtar else if (!strcmp(token, "RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN")) 141f714a188SAmr Mokhtar *op_flag_value = RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN; 142f714a188SAmr Mokhtar else if (!strcmp(token, "RTE_BBDEV_TURBO_POS_LLR_1_BIT_SOFT_OUT")) 143f714a188SAmr Mokhtar *op_flag_value = RTE_BBDEV_TURBO_POS_LLR_1_BIT_SOFT_OUT; 144f714a188SAmr Mokhtar else if (!strcmp(token, "RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT")) 145f714a188SAmr Mokhtar *op_flag_value = RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT; 146f714a188SAmr Mokhtar else if (!strcmp(token, "RTE_BBDEV_TURBO_MAP_DEC")) 147f714a188SAmr Mokhtar *op_flag_value = RTE_BBDEV_TURBO_MAP_DEC; 148f714a188SAmr Mokhtar else if (!strcmp(token, "RTE_BBDEV_TURBO_DEC_SCATTER_GATHER")) 149f714a188SAmr Mokhtar *op_flag_value = RTE_BBDEV_TURBO_DEC_SCATTER_GATHER; 150795ae2dfSKamil Chalupnik else if (!strcmp(token, "RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP")) 151795ae2dfSKamil Chalupnik *op_flag_value = RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP; 152f714a188SAmr Mokhtar else { 153f714a188SAmr Mokhtar printf("The given value is not a turbo decoder flag\n"); 154f714a188SAmr Mokhtar return -1; 155f714a188SAmr Mokhtar } 156f714a188SAmr Mokhtar 157f714a188SAmr Mokhtar return 0; 158f714a188SAmr Mokhtar } 159f714a188SAmr Mokhtar 160d819c083SNicolas Chautru /* convert LDPC flag from string to unsigned long int*/ 161d819c083SNicolas Chautru static int 162d819c083SNicolas Chautru op_ldpc_decoder_flag_strtoul(char *token, uint32_t *op_flag_value) 163d819c083SNicolas Chautru { 164d819c083SNicolas Chautru if (!strcmp(token, "RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK")) 165d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK; 166d819c083SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK")) 167d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK; 168d819c083SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP")) 169d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP; 170*cc360fd3SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_LDPC_CRC_TYPE_16_CHECK")) 171*cc360fd3SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_CRC_TYPE_16_CHECK; 172d819c083SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_LDPC_DEINTERLEAVER_BYPASS")) 173d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_DEINTERLEAVER_BYPASS; 174d819c083SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE")) 175d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE; 176d819c083SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE")) 177d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE; 178d819c083SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_LDPC_DECODE_BYPASS")) 179d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_DECODE_BYPASS; 180d819c083SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_LDPC_SOFT_OUT_ENABLE")) 181d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_SOFT_OUT_ENABLE; 182d819c083SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_LDPC_SOFT_OUT_RM_BYPASS")) 183d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_SOFT_OUT_RM_BYPASS; 184d819c083SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_LDPC_SOFT_OUT_DEINTERLEAVER_BYPASS")) 185d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_SOFT_OUT_DEINTERLEAVER_BYPASS; 186d819c083SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE")) 187d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE; 188d819c083SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_LDPC_DEC_INTERRUPTS")) 189d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_DEC_INTERRUPTS; 190d819c083SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_LDPC_DEC_SCATTER_GATHER")) 191d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_DEC_SCATTER_GATHER; 192d819c083SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION")) 193d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION; 194d819c083SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_LDPC_LLR_COMPRESSION")) 195d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_LLR_COMPRESSION; 196d819c083SNicolas Chautru else if (!strcmp(token, 197d819c083SNicolas Chautru "RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE")) 198d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE; 199d819c083SNicolas Chautru else if (!strcmp(token, 200d819c083SNicolas Chautru "RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE")) 201d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE; 202335c11fdSNicolas Chautru else if (!strcmp(token, 203335c11fdSNicolas Chautru "RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK")) 204335c11fdSNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK; 205d819c083SNicolas Chautru else { 206d819c083SNicolas Chautru printf("The given value is not a LDPC decoder flag\n"); 207d819c083SNicolas Chautru return -1; 208d819c083SNicolas Chautru } 209d819c083SNicolas Chautru 210d819c083SNicolas Chautru return 0; 211d819c083SNicolas Chautru } 212d819c083SNicolas Chautru 213f714a188SAmr Mokhtar /* convert turbo encoder flag from string to unsigned long int*/ 214f714a188SAmr Mokhtar static int 215f714a188SAmr Mokhtar op_encoder_flag_strtoul(char *token, uint32_t *op_flag_value) 216f714a188SAmr Mokhtar { 217f714a188SAmr Mokhtar if (!strcmp(token, "RTE_BBDEV_TURBO_RV_INDEX_BYPASS")) 218f714a188SAmr Mokhtar *op_flag_value = RTE_BBDEV_TURBO_RV_INDEX_BYPASS; 219f714a188SAmr Mokhtar else if (!strcmp(token, "RTE_BBDEV_TURBO_RATE_MATCH")) 220f714a188SAmr Mokhtar *op_flag_value = RTE_BBDEV_TURBO_RATE_MATCH; 221f714a188SAmr Mokhtar else if (!strcmp(token, "RTE_BBDEV_TURBO_CRC_24B_ATTACH")) 222f714a188SAmr Mokhtar *op_flag_value = RTE_BBDEV_TURBO_CRC_24B_ATTACH; 223f714a188SAmr Mokhtar else if (!strcmp(token, "RTE_BBDEV_TURBO_CRC_24A_ATTACH")) 224f714a188SAmr Mokhtar *op_flag_value = RTE_BBDEV_TURBO_CRC_24A_ATTACH; 225f714a188SAmr Mokhtar else if (!strcmp(token, "RTE_BBDEV_TURBO_ENC_SCATTER_GATHER")) 226f714a188SAmr Mokhtar *op_flag_value = RTE_BBDEV_TURBO_ENC_SCATTER_GATHER; 227f714a188SAmr Mokhtar else { 228f714a188SAmr Mokhtar printf("The given value is not a turbo encoder flag\n"); 229f714a188SAmr Mokhtar return -1; 230f714a188SAmr Mokhtar } 231f714a188SAmr Mokhtar 232f714a188SAmr Mokhtar return 0; 233f714a188SAmr Mokhtar } 234f714a188SAmr Mokhtar 235d819c083SNicolas Chautru /* convert LDPC encoder flag from string to unsigned long int*/ 236d819c083SNicolas Chautru static int 237d819c083SNicolas Chautru op_ldpc_encoder_flag_strtoul(char *token, uint32_t *op_flag_value) 238d819c083SNicolas Chautru { 239d819c083SNicolas Chautru if (!strcmp(token, "RTE_BBDEV_LDPC_INTERLEAVER_BYPASS")) 240d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_INTERLEAVER_BYPASS; 241d819c083SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_LDPC_RATE_MATCH")) 242d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_RATE_MATCH; 243d819c083SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_LDPC_CRC_24A_ATTACH")) 244d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_CRC_24A_ATTACH; 245d819c083SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_LDPC_CRC_24B_ATTACH")) 246d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_CRC_24B_ATTACH; 247d819c083SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_LDPC_CRC_16_ATTACH")) 248d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_CRC_16_ATTACH; 249d819c083SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_LDPC_ENC_INTERRUPTS")) 250d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_ENC_INTERRUPTS; 251d819c083SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_LDPC_ENC_SCATTER_GATHER")) 252d819c083SNicolas Chautru *op_flag_value = RTE_BBDEV_LDPC_ENC_SCATTER_GATHER; 253d819c083SNicolas Chautru else { 254d819c083SNicolas Chautru printf("The given value is not a turbo encoder flag\n"); 255d819c083SNicolas Chautru return -1; 256d819c083SNicolas Chautru } 257d819c083SNicolas Chautru 258d819c083SNicolas Chautru return 0; 259d819c083SNicolas Chautru } 260d819c083SNicolas Chautru 261f714a188SAmr Mokhtar /* tokenization turbo decoder/encoder flags values separated by a comma */ 262f714a188SAmr Mokhtar static int 263f714a188SAmr Mokhtar parse_turbo_flags(char *tokens, uint32_t *op_flags, 264f714a188SAmr Mokhtar enum rte_bbdev_op_type op_type) 265f714a188SAmr Mokhtar { 266f714a188SAmr Mokhtar char *tok = NULL; 267f714a188SAmr Mokhtar uint32_t op_flag_value = 0; 268f714a188SAmr Mokhtar 269f714a188SAmr Mokhtar tok = strtok(tokens, VALUE_DELIMITER); 270f714a188SAmr Mokhtar if (tok == NULL) 271f714a188SAmr Mokhtar return -1; 272f714a188SAmr Mokhtar 273f714a188SAmr Mokhtar while (tok != NULL) { 274f714a188SAmr Mokhtar trim_space(tok); 275f714a188SAmr Mokhtar if (op_type == RTE_BBDEV_OP_TURBO_DEC) { 276f714a188SAmr Mokhtar if (op_decoder_flag_strtoul(tok, &op_flag_value) == -1) 277f714a188SAmr Mokhtar return -1; 278f714a188SAmr Mokhtar } else if (op_type == RTE_BBDEV_OP_TURBO_ENC) { 279f714a188SAmr Mokhtar if (op_encoder_flag_strtoul(tok, &op_flag_value) == -1) 280f714a188SAmr Mokhtar return -1; 281d819c083SNicolas Chautru } else if (op_type == RTE_BBDEV_OP_LDPC_ENC) { 282d819c083SNicolas Chautru if (op_ldpc_encoder_flag_strtoul(tok, &op_flag_value) 283d819c083SNicolas Chautru == -1) 284d819c083SNicolas Chautru return -1; 285d819c083SNicolas Chautru } else if (op_type == RTE_BBDEV_OP_LDPC_DEC) { 286d819c083SNicolas Chautru if (op_ldpc_decoder_flag_strtoul(tok, &op_flag_value) 287d819c083SNicolas Chautru == -1) 288d819c083SNicolas Chautru return -1; 289f714a188SAmr Mokhtar } else { 290f714a188SAmr Mokhtar return -1; 291f714a188SAmr Mokhtar } 292f714a188SAmr Mokhtar 293f714a188SAmr Mokhtar *op_flags = *op_flags | op_flag_value; 294f714a188SAmr Mokhtar 295f714a188SAmr Mokhtar tok = strtok(NULL, VALUE_DELIMITER); 296f714a188SAmr Mokhtar if (tok == NULL) 297f714a188SAmr Mokhtar break; 298f714a188SAmr Mokhtar } 299f714a188SAmr Mokhtar 300f714a188SAmr Mokhtar return 0; 301f714a188SAmr Mokhtar } 302f714a188SAmr Mokhtar 303f714a188SAmr Mokhtar /* convert turbo encoder/decoder op_type from string to enum*/ 304f714a188SAmr Mokhtar static int 305f714a188SAmr Mokhtar op_turbo_type_strtol(char *token, enum rte_bbdev_op_type *op_type) 306f714a188SAmr Mokhtar { 307f714a188SAmr Mokhtar trim_space(token); 308f714a188SAmr Mokhtar if (!strcmp(token, "RTE_BBDEV_OP_TURBO_DEC")) 309f714a188SAmr Mokhtar *op_type = RTE_BBDEV_OP_TURBO_DEC; 310f714a188SAmr Mokhtar else if (!strcmp(token, "RTE_BBDEV_OP_TURBO_ENC")) 311f714a188SAmr Mokhtar *op_type = RTE_BBDEV_OP_TURBO_ENC; 312d819c083SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_OP_LDPC_ENC")) 313d819c083SNicolas Chautru *op_type = RTE_BBDEV_OP_LDPC_ENC; 314d819c083SNicolas Chautru else if (!strcmp(token, "RTE_BBDEV_OP_LDPC_DEC")) 315d819c083SNicolas Chautru *op_type = RTE_BBDEV_OP_LDPC_DEC; 316f714a188SAmr Mokhtar else if (!strcmp(token, "RTE_BBDEV_OP_NONE")) 317f714a188SAmr Mokhtar *op_type = RTE_BBDEV_OP_NONE; 318f714a188SAmr Mokhtar else { 319f714a188SAmr Mokhtar printf("Not valid turbo op_type: '%s'\n", token); 320f714a188SAmr Mokhtar return -1; 321f714a188SAmr Mokhtar } 322f714a188SAmr Mokhtar 323f714a188SAmr Mokhtar return 0; 324f714a188SAmr Mokhtar } 325f714a188SAmr Mokhtar 326f714a188SAmr Mokhtar /* tokenization expected status values separated by a comma */ 327f714a188SAmr Mokhtar static int 328f714a188SAmr Mokhtar parse_expected_status(char *tokens, int *status, enum rte_bbdev_op_type op_type) 329f714a188SAmr Mokhtar { 330f714a188SAmr Mokhtar char *tok = NULL; 331f714a188SAmr Mokhtar bool status_ok = false; 332f714a188SAmr Mokhtar 333f714a188SAmr Mokhtar tok = strtok(tokens, VALUE_DELIMITER); 334f714a188SAmr Mokhtar if (tok == NULL) 335f714a188SAmr Mokhtar return -1; 336f714a188SAmr Mokhtar 337f714a188SAmr Mokhtar while (tok != NULL) { 338f714a188SAmr Mokhtar trim_space(tok); 339f714a188SAmr Mokhtar if (!strcmp(tok, "OK")) 340f714a188SAmr Mokhtar status_ok = true; 341f714a188SAmr Mokhtar else if (!strcmp(tok, "DMA")) 342f714a188SAmr Mokhtar *status = *status | (1 << RTE_BBDEV_DRV_ERROR); 343f714a188SAmr Mokhtar else if (!strcmp(tok, "FCW")) 344f714a188SAmr Mokhtar *status = *status | (1 << RTE_BBDEV_DATA_ERROR); 345d819c083SNicolas Chautru else if (!strcmp(tok, "SYNCRC")) { 346d819c083SNicolas Chautru *status = *status | (1 << RTE_BBDEV_SYNDROME_ERROR); 347d819c083SNicolas Chautru *status = *status | (1 << RTE_BBDEV_CRC_ERROR); 348d819c083SNicolas Chautru } else if (!strcmp(tok, "SYN")) 349d819c083SNicolas Chautru *status = *status | (1 << RTE_BBDEV_SYNDROME_ERROR); 350f714a188SAmr Mokhtar else if (!strcmp(tok, "CRC")) { 351d819c083SNicolas Chautru if ((op_type == RTE_BBDEV_OP_TURBO_DEC) || 352d819c083SNicolas Chautru (op_type == RTE_BBDEV_OP_LDPC_DEC)) 353f714a188SAmr Mokhtar *status = *status | (1 << RTE_BBDEV_CRC_ERROR); 354f714a188SAmr Mokhtar else { 355f714a188SAmr Mokhtar printf( 356d819c083SNicolas Chautru "CRC is only a valid value for decoder\n"); 357f714a188SAmr Mokhtar return -1; 358f714a188SAmr Mokhtar } 359f714a188SAmr Mokhtar } else { 360f714a188SAmr Mokhtar printf("Not valid status: '%s'\n", tok); 361f714a188SAmr Mokhtar return -1; 362f714a188SAmr Mokhtar } 363f714a188SAmr Mokhtar 364f714a188SAmr Mokhtar tok = strtok(NULL, VALUE_DELIMITER); 365f714a188SAmr Mokhtar if (tok == NULL) 366f714a188SAmr Mokhtar break; 367f714a188SAmr Mokhtar } 368f714a188SAmr Mokhtar 369f714a188SAmr Mokhtar if (status_ok && *status != 0) { 370f714a188SAmr Mokhtar printf( 371f714a188SAmr Mokhtar "Not valid status values. Cannot be OK and ERROR at the same time.\n"); 372f714a188SAmr Mokhtar return -1; 373f714a188SAmr Mokhtar } 374f714a188SAmr Mokhtar 375f714a188SAmr Mokhtar return 0; 376f714a188SAmr Mokhtar } 377f714a188SAmr Mokhtar 378f714a188SAmr Mokhtar /* parse ops data entry (there can be more than 1 input entry, each will be 379f714a188SAmr Mokhtar * contained in a separate op_data_buf struct) 380f714a188SAmr Mokhtar */ 381f714a188SAmr Mokhtar static int 382f714a188SAmr Mokhtar parse_data_entry(const char *key_token, char *token, 383f714a188SAmr Mokhtar struct test_bbdev_vector *vector, enum op_data_type type, 384f714a188SAmr Mokhtar const char *prefix) 385f714a188SAmr Mokhtar { 386f714a188SAmr Mokhtar int ret; 387f714a188SAmr Mokhtar uint32_t data_length = 0; 388f714a188SAmr Mokhtar uint32_t *data = NULL; 389f714a188SAmr Mokhtar unsigned int id; 390f714a188SAmr Mokhtar struct op_data_buf *op_data; 391f714a188SAmr Mokhtar unsigned int *nb_ops; 392f714a188SAmr Mokhtar 39321820350SAmr Mokhtar if (type >= DATA_NUM_TYPES) { 394f714a188SAmr Mokhtar printf("Unknown op type: %d!\n", type); 395f714a188SAmr Mokhtar return -1; 396f714a188SAmr Mokhtar } 397f714a188SAmr Mokhtar 398f714a188SAmr Mokhtar op_data = vector->entries[type].segments; 399f714a188SAmr Mokhtar nb_ops = &vector->entries[type].nb_segments; 400f714a188SAmr Mokhtar 401c4b0d663SNicolas Chautru if (*nb_ops >= RTE_BBDEV_TURBO_MAX_CODE_BLOCKS) { 402f714a188SAmr Mokhtar printf("Too many segments (code blocks defined): %u, max %d!\n", 403c4b0d663SNicolas Chautru *nb_ops, RTE_BBDEV_TURBO_MAX_CODE_BLOCKS); 404f714a188SAmr Mokhtar return -1; 405f714a188SAmr Mokhtar } 406f714a188SAmr Mokhtar 407f714a188SAmr Mokhtar if (sscanf(key_token + strlen(prefix), "%u", &id) != 1) { 408f714a188SAmr Mokhtar printf("Missing ID of %s\n", prefix); 409f714a188SAmr Mokhtar return -1; 410f714a188SAmr Mokhtar } 411f714a188SAmr Mokhtar if (id != *nb_ops) { 412f714a188SAmr Mokhtar printf( 413f714a188SAmr Mokhtar "Please order data entries sequentially, i.e. %s0, %s1, ...\n", 414f714a188SAmr Mokhtar prefix, prefix); 415f714a188SAmr Mokhtar return -1; 416f714a188SAmr Mokhtar } 417f714a188SAmr Mokhtar 418f714a188SAmr Mokhtar /* Clear new op data struct */ 419f714a188SAmr Mokhtar memset(op_data + *nb_ops, 0, sizeof(struct op_data_buf)); 420f714a188SAmr Mokhtar 421f714a188SAmr Mokhtar ret = parse_values(token, &data, &data_length); 422f714a188SAmr Mokhtar if (!ret) { 423f714a188SAmr Mokhtar op_data[*nb_ops].addr = data; 424f714a188SAmr Mokhtar op_data[*nb_ops].length = data_length; 425f714a188SAmr Mokhtar ++(*nb_ops); 426f714a188SAmr Mokhtar } 427f714a188SAmr Mokhtar 428f714a188SAmr Mokhtar return ret; 429f714a188SAmr Mokhtar } 430f714a188SAmr Mokhtar 431f714a188SAmr Mokhtar /* parses turbo decoder parameters and assigns to global variable */ 432f714a188SAmr Mokhtar static int 433f714a188SAmr Mokhtar parse_decoder_params(const char *key_token, char *token, 434f714a188SAmr Mokhtar struct test_bbdev_vector *vector) 435f714a188SAmr Mokhtar { 436f714a188SAmr Mokhtar int ret = 0, status = 0; 437f714a188SAmr Mokhtar uint32_t op_flags = 0; 438f714a188SAmr Mokhtar char *err = NULL; 439f714a188SAmr Mokhtar 440f714a188SAmr Mokhtar struct rte_bbdev_op_turbo_dec *turbo_dec = &vector->turbo_dec; 441f714a188SAmr Mokhtar 442f714a188SAmr Mokhtar /* compare keys */ 443f714a188SAmr Mokhtar if (starts_with(key_token, op_data_prefixes[DATA_INPUT])) 444f714a188SAmr Mokhtar ret = parse_data_entry(key_token, token, vector, 445f714a188SAmr Mokhtar DATA_INPUT, op_data_prefixes[DATA_INPUT]); 446f714a188SAmr Mokhtar 447f714a188SAmr Mokhtar else if (starts_with(key_token, op_data_prefixes[DATA_SOFT_OUTPUT])) 448f714a188SAmr Mokhtar ret = parse_data_entry(key_token, token, vector, 449f714a188SAmr Mokhtar DATA_SOFT_OUTPUT, 450f714a188SAmr Mokhtar op_data_prefixes[DATA_SOFT_OUTPUT]); 451f714a188SAmr Mokhtar 452f714a188SAmr Mokhtar else if (starts_with(key_token, op_data_prefixes[DATA_HARD_OUTPUT])) 453f714a188SAmr Mokhtar ret = parse_data_entry(key_token, token, vector, 454f714a188SAmr Mokhtar DATA_HARD_OUTPUT, 455f714a188SAmr Mokhtar op_data_prefixes[DATA_HARD_OUTPUT]); 456f714a188SAmr Mokhtar else if (!strcmp(key_token, "e")) { 457f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_E; 458f714a188SAmr Mokhtar turbo_dec->cb_params.e = (uint32_t) strtoul(token, &err, 0); 459f714a188SAmr Mokhtar } else if (!strcmp(key_token, "ea")) { 460f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_EA; 461f714a188SAmr Mokhtar turbo_dec->tb_params.ea = (uint32_t) strtoul(token, &err, 0); 462f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 463f714a188SAmr Mokhtar } else if (!strcmp(key_token, "eb")) { 464f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_EB; 465f714a188SAmr Mokhtar turbo_dec->tb_params.eb = (uint32_t) strtoul(token, &err, 0); 466f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 467f714a188SAmr Mokhtar } else if (!strcmp(key_token, "k")) { 468f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_K; 469f714a188SAmr Mokhtar turbo_dec->cb_params.k = (uint16_t) strtoul(token, &err, 0); 470f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 471f714a188SAmr Mokhtar } else if (!strcmp(key_token, "k_pos")) { 472f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_K_POS; 473f714a188SAmr Mokhtar turbo_dec->tb_params.k_pos = (uint16_t) strtoul(token, &err, 0); 474f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 475f714a188SAmr Mokhtar } else if (!strcmp(key_token, "k_neg")) { 476f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_K_NEG; 477f714a188SAmr Mokhtar turbo_dec->tb_params.k_neg = (uint16_t) strtoul(token, &err, 0); 478f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 479f714a188SAmr Mokhtar } else if (!strcmp(key_token, "c")) { 480f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_C; 481f714a188SAmr Mokhtar turbo_dec->tb_params.c = (uint16_t) strtoul(token, &err, 0); 482f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 483f714a188SAmr Mokhtar } else if (!strcmp(key_token, "c_neg")) { 484f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_C_NEG; 485f714a188SAmr Mokhtar turbo_dec->tb_params.c_neg = (uint16_t) strtoul(token, &err, 0); 486f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 487f714a188SAmr Mokhtar } else if (!strcmp(key_token, "cab")) { 488f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_CAB; 489f714a188SAmr Mokhtar turbo_dec->tb_params.cab = (uint8_t) strtoul(token, &err, 0); 490f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 491f714a188SAmr Mokhtar } else if (!strcmp(key_token, "rv_index")) { 492f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_RV_INDEX; 493f714a188SAmr Mokhtar turbo_dec->rv_index = (uint8_t) strtoul(token, &err, 0); 494f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 495f714a188SAmr Mokhtar } else if (!strcmp(key_token, "iter_max")) { 496f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_ITER_MAX; 497f714a188SAmr Mokhtar turbo_dec->iter_max = (uint8_t) strtoul(token, &err, 0); 498f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 499f714a188SAmr Mokhtar } else if (!strcmp(key_token, "iter_min")) { 500f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_ITER_MIN; 501f714a188SAmr Mokhtar turbo_dec->iter_min = (uint8_t) strtoul(token, &err, 0); 502f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 503f714a188SAmr Mokhtar } else if (!strcmp(key_token, "expected_iter_count")) { 504f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_EXPECTED_ITER_COUNT; 505f714a188SAmr Mokhtar turbo_dec->iter_count = (uint8_t) strtoul(token, &err, 0); 506f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 507f714a188SAmr Mokhtar } else if (!strcmp(key_token, "ext_scale")) { 508f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_EXT_SCALE; 509f714a188SAmr Mokhtar turbo_dec->ext_scale = (uint8_t) strtoul(token, &err, 0); 510f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 511f714a188SAmr Mokhtar } else if (!strcmp(key_token, "num_maps")) { 512f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_NUM_MAPS; 513f714a188SAmr Mokhtar turbo_dec->num_maps = (uint8_t) strtoul(token, &err, 0); 514f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 5150b98d574SKamil Chalupnik } else if (!strcmp(key_token, "r")) { 5160b98d574SKamil Chalupnik vector->mask |= TEST_BBDEV_VF_R; 5170b98d574SKamil Chalupnik turbo_dec->tb_params.r = (uint8_t)strtoul(token, &err, 0); 5180b98d574SKamil Chalupnik 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_dec->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_dec->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 dec 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 /* parses turbo encoder parameters and assigns to global variable */ 548f714a188SAmr Mokhtar static int 549f714a188SAmr Mokhtar parse_encoder_params(const char *key_token, char *token, 550f714a188SAmr Mokhtar struct test_bbdev_vector *vector) 551f714a188SAmr Mokhtar { 552f714a188SAmr Mokhtar int ret = 0, status = 0; 553f714a188SAmr Mokhtar uint32_t op_flags = 0; 554f714a188SAmr Mokhtar char *err = NULL; 555f714a188SAmr Mokhtar 556f714a188SAmr Mokhtar 557f714a188SAmr Mokhtar struct rte_bbdev_op_turbo_enc *turbo_enc = &vector->turbo_enc; 558f714a188SAmr Mokhtar 559f714a188SAmr Mokhtar if (starts_with(key_token, op_data_prefixes[DATA_INPUT])) 560f714a188SAmr Mokhtar ret = parse_data_entry(key_token, token, vector, 561f714a188SAmr Mokhtar DATA_INPUT, op_data_prefixes[DATA_INPUT]); 562f714a188SAmr Mokhtar else if (starts_with(key_token, "output")) 563f714a188SAmr Mokhtar ret = parse_data_entry(key_token, token, vector, 564f714a188SAmr Mokhtar DATA_HARD_OUTPUT, "output"); 565f714a188SAmr Mokhtar else if (!strcmp(key_token, "e")) { 566f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_E; 567f714a188SAmr Mokhtar turbo_enc->cb_params.e = (uint32_t) strtoul(token, &err, 0); 568f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 569f714a188SAmr Mokhtar } else if (!strcmp(key_token, "ea")) { 570f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_EA; 571f714a188SAmr Mokhtar turbo_enc->tb_params.ea = (uint32_t) strtoul(token, &err, 0); 572f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 573f714a188SAmr Mokhtar } else if (!strcmp(key_token, "eb")) { 574f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_EB; 575f714a188SAmr Mokhtar turbo_enc->tb_params.eb = (uint32_t) strtoul(token, &err, 0); 576f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 577f714a188SAmr Mokhtar } else if (!strcmp(key_token, "k")) { 578f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_K; 579f714a188SAmr Mokhtar turbo_enc->cb_params.k = (uint16_t) strtoul(token, &err, 0); 580f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 581f714a188SAmr Mokhtar } else if (!strcmp(key_token, "k_neg")) { 582f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_K_NEG; 583f714a188SAmr Mokhtar turbo_enc->tb_params.k_neg = (uint16_t) strtoul(token, &err, 0); 584f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 585f714a188SAmr Mokhtar } else if (!strcmp(key_token, "k_pos")) { 586f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_K_POS; 587f714a188SAmr Mokhtar turbo_enc->tb_params.k_pos = (uint16_t) strtoul(token, &err, 0); 588f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 589f714a188SAmr Mokhtar } else if (!strcmp(key_token, "c_neg")) { 590f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_C_NEG; 591f714a188SAmr Mokhtar turbo_enc->tb_params.c_neg = (uint8_t) strtoul(token, &err, 0); 592f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 593f714a188SAmr Mokhtar } else if (!strcmp(key_token, "c")) { 594f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_C; 595f714a188SAmr Mokhtar turbo_enc->tb_params.c = (uint8_t) strtoul(token, &err, 0); 596f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 597f714a188SAmr Mokhtar } else if (!strcmp(key_token, "cab")) { 598f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_CAB; 599f714a188SAmr Mokhtar turbo_enc->tb_params.cab = (uint8_t) strtoul(token, &err, 0); 600f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 601f714a188SAmr Mokhtar } else if (!strcmp(key_token, "rv_index")) { 602f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_RV_INDEX; 603f714a188SAmr Mokhtar turbo_enc->rv_index = (uint8_t) strtoul(token, &err, 0); 604f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 605f714a188SAmr Mokhtar } else if (!strcmp(key_token, "ncb")) { 606f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_NCB; 607f714a188SAmr Mokhtar turbo_enc->cb_params.ncb = (uint16_t) strtoul(token, &err, 0); 608f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 609f714a188SAmr Mokhtar } else if (!strcmp(key_token, "ncb_neg")) { 610f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_NCB_NEG; 611f714a188SAmr Mokhtar turbo_enc->tb_params.ncb_neg = 612f714a188SAmr Mokhtar (uint16_t) strtoul(token, &err, 0); 613f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 614f714a188SAmr Mokhtar } else if (!strcmp(key_token, "ncb_pos")) { 615f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_NCB_POS; 616f714a188SAmr Mokhtar turbo_enc->tb_params.ncb_pos = 617f714a188SAmr Mokhtar (uint16_t) strtoul(token, &err, 0); 618f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 619f714a188SAmr Mokhtar } else if (!strcmp(key_token, "r")) { 620f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_R; 621f714a188SAmr Mokhtar turbo_enc->tb_params.r = (uint8_t) strtoul(token, &err, 0); 622f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 623f714a188SAmr Mokhtar } else if (!strcmp(key_token, "code_block_mode")) { 624f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_CODE_BLOCK_MODE; 625f714a188SAmr Mokhtar turbo_enc->code_block_mode = (uint8_t) strtoul(token, &err, 0); 626f714a188SAmr Mokhtar ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 627f714a188SAmr Mokhtar } else if (!strcmp(key_token, "op_flags")) { 628f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_OP_FLAGS; 629f714a188SAmr Mokhtar ret = parse_turbo_flags(token, &op_flags, 630f714a188SAmr Mokhtar vector->op_type); 631f714a188SAmr Mokhtar if (!ret) 632f714a188SAmr Mokhtar turbo_enc->op_flags = op_flags; 633f714a188SAmr Mokhtar } else if (!strcmp(key_token, "expected_status")) { 634f714a188SAmr Mokhtar vector->mask |= TEST_BBDEV_VF_EXPECTED_STATUS; 635f714a188SAmr Mokhtar ret = parse_expected_status(token, &status, vector->op_type); 636f714a188SAmr Mokhtar if (!ret) 637f714a188SAmr Mokhtar vector->expected_status = status; 638f714a188SAmr Mokhtar } else { 639f714a188SAmr Mokhtar printf("Not valid enc key: '%s'\n", key_token); 640f714a188SAmr Mokhtar return -1; 641f714a188SAmr Mokhtar } 642f714a188SAmr Mokhtar 643f714a188SAmr Mokhtar if (ret != 0) { 644f714a188SAmr Mokhtar printf("Failed with convert '%s\t%s'\n", key_token, token); 645f714a188SAmr Mokhtar return -1; 646f714a188SAmr Mokhtar } 647f714a188SAmr Mokhtar 648f714a188SAmr Mokhtar return 0; 649f714a188SAmr Mokhtar } 650f714a188SAmr Mokhtar 651d819c083SNicolas Chautru 652d819c083SNicolas Chautru /* parses LDPC encoder parameters and assigns to global variable */ 653d819c083SNicolas Chautru static int 654d819c083SNicolas Chautru parse_ldpc_encoder_params(const char *key_token, char *token, 655d819c083SNicolas Chautru struct test_bbdev_vector *vector) 656d819c083SNicolas Chautru { 657d819c083SNicolas Chautru int ret = 0, status = 0; 658d819c083SNicolas Chautru uint32_t op_flags = 0; 659d819c083SNicolas Chautru char *err = NULL; 660d819c083SNicolas Chautru 661d819c083SNicolas Chautru struct rte_bbdev_op_ldpc_enc *ldpc_enc = &vector->ldpc_enc; 662d819c083SNicolas Chautru 663d819c083SNicolas Chautru if (starts_with(key_token, op_data_prefixes[DATA_INPUT])) 664d819c083SNicolas Chautru ret = parse_data_entry(key_token, token, vector, 665d819c083SNicolas Chautru DATA_INPUT, 666d819c083SNicolas Chautru op_data_prefixes[DATA_INPUT]); 667d819c083SNicolas Chautru else if (starts_with(key_token, "output")) 668d819c083SNicolas Chautru ret = parse_data_entry(key_token, token, vector, 669d819c083SNicolas Chautru DATA_HARD_OUTPUT, 670d819c083SNicolas Chautru "output"); 671d819c083SNicolas Chautru else if (!strcmp(key_token, "e")) { 672d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_E; 673d819c083SNicolas Chautru ldpc_enc->cb_params.e = (uint32_t) strtoul(token, &err, 0); 674d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 675d819c083SNicolas Chautru } else if (!strcmp(key_token, "ea")) { 676d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_EA; 677d819c083SNicolas Chautru ldpc_enc->tb_params.ea = (uint32_t) strtoul(token, &err, 0); 678d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 679d819c083SNicolas Chautru } else if (!strcmp(key_token, "eb")) { 680d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_EB; 681d819c083SNicolas Chautru ldpc_enc->tb_params.eb = (uint32_t) strtoul(token, &err, 0); 682d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 683d819c083SNicolas Chautru } else if (!strcmp(key_token, "c")) { 684d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_C; 685d819c083SNicolas Chautru ldpc_enc->tb_params.c = (uint8_t) strtoul(token, &err, 0); 686d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 687d819c083SNicolas Chautru } else if (!strcmp(key_token, "cab")) { 688d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_CAB; 689d819c083SNicolas Chautru ldpc_enc->tb_params.cab = (uint8_t) strtoul(token, &err, 0); 690d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 691d819c083SNicolas Chautru } else if (!strcmp(key_token, "rv_index")) { 692d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_RV_INDEX; 693d819c083SNicolas Chautru ldpc_enc->rv_index = (uint8_t) strtoul(token, &err, 0); 694d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 695d819c083SNicolas Chautru } else if (!strcmp(key_token, "n_cb")) { 696d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_NCB; 697d819c083SNicolas Chautru ldpc_enc->n_cb = (uint16_t) strtoul(token, &err, 0); 698d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 699d819c083SNicolas Chautru } else if (!strcmp(key_token, "r")) { 700d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_R; 701d819c083SNicolas Chautru ldpc_enc->tb_params.r = (uint8_t) strtoul(token, &err, 0); 702d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 703d819c083SNicolas Chautru } else if (!strcmp(key_token, "q_m")) { 704d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_QM; 705d819c083SNicolas Chautru ldpc_enc->q_m = (uint8_t) strtoul(token, &err, 0); 706d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 707d819c083SNicolas Chautru } else if (!strcmp(key_token, "basegraph")) { 708d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_BG; 709d819c083SNicolas Chautru ldpc_enc->basegraph = (uint8_t) strtoul(token, &err, 0); 710d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 711d819c083SNicolas Chautru } else if (!strcmp(key_token, "z_c")) { 712d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_ZC; 713d819c083SNicolas Chautru ldpc_enc->z_c = (uint16_t) strtoul(token, &err, 0); 714d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 715d819c083SNicolas Chautru } else if (!strcmp(key_token, "n_filler")) { 716d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_F; 717d819c083SNicolas Chautru ldpc_enc->n_filler = (uint16_t) strtoul(token, &err, 0); 718d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 719d819c083SNicolas Chautru } else if (!strcmp(key_token, "code_block_mode")) { 720d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_CODE_BLOCK_MODE; 721d819c083SNicolas Chautru ldpc_enc->code_block_mode = (uint8_t) strtoul(token, &err, 0); 722d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 723d819c083SNicolas Chautru } else if (!strcmp(key_token, "op_flags")) { 724d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_OP_FLAGS; 725d819c083SNicolas Chautru ret = parse_turbo_flags(token, &op_flags, vector->op_type); 726d819c083SNicolas Chautru if (!ret) 727d819c083SNicolas Chautru ldpc_enc->op_flags = op_flags; 728d819c083SNicolas Chautru } else if (!strcmp(key_token, "expected_status")) { 729d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_EXPECTED_STATUS; 730d819c083SNicolas Chautru ret = parse_expected_status(token, &status, vector->op_type); 731d819c083SNicolas Chautru if (!ret) 732d819c083SNicolas Chautru vector->expected_status = status; 733d819c083SNicolas Chautru } else { 734d819c083SNicolas Chautru printf("Not valid ldpc enc key: '%s'\n", key_token); 735d819c083SNicolas Chautru return -1; 736d819c083SNicolas Chautru } 737d819c083SNicolas Chautru 738d819c083SNicolas Chautru if (ret != 0) { 739d819c083SNicolas Chautru printf("Failed with convert '%s\t%s'\n", key_token, token); 740d819c083SNicolas Chautru return -1; 741d819c083SNicolas Chautru } 742d819c083SNicolas Chautru 743d819c083SNicolas Chautru return 0; 744d819c083SNicolas Chautru } 745d819c083SNicolas Chautru 746d819c083SNicolas Chautru /* parses LDPC decoder parameters and assigns to global variable */ 747d819c083SNicolas Chautru static int 748d819c083SNicolas Chautru parse_ldpc_decoder_params(const char *key_token, char *token, 749d819c083SNicolas Chautru struct test_bbdev_vector *vector) 750d819c083SNicolas Chautru { 751d819c083SNicolas Chautru int ret = 0, status = 0; 752d819c083SNicolas Chautru uint32_t op_flags = 0; 753d819c083SNicolas Chautru char *err = NULL; 754d819c083SNicolas Chautru 755d819c083SNicolas Chautru struct rte_bbdev_op_ldpc_dec *ldpc_dec = &vector->ldpc_dec; 756d819c083SNicolas Chautru 757d819c083SNicolas Chautru if (starts_with(key_token, op_data_prefixes[DATA_INPUT])) 758d819c083SNicolas Chautru ret = parse_data_entry(key_token, token, vector, 759d819c083SNicolas Chautru DATA_INPUT, 760d819c083SNicolas Chautru op_data_prefixes[DATA_INPUT]); 761d819c083SNicolas Chautru else if (starts_with(key_token, "output")) 762d819c083SNicolas Chautru ret = parse_data_entry(key_token, token, vector, 763d819c083SNicolas Chautru DATA_HARD_OUTPUT, 764d819c083SNicolas Chautru "output"); 765d819c083SNicolas Chautru else if (starts_with(key_token, op_data_prefixes[DATA_HARQ_INPUT])) 766d819c083SNicolas Chautru ret = parse_data_entry(key_token, token, vector, 767d819c083SNicolas Chautru DATA_HARQ_INPUT, 768d819c083SNicolas Chautru op_data_prefixes[DATA_HARQ_INPUT]); 769d819c083SNicolas Chautru else if (starts_with(key_token, op_data_prefixes[DATA_HARQ_OUTPUT])) 770d819c083SNicolas Chautru ret = parse_data_entry(key_token, token, vector, 771d819c083SNicolas Chautru DATA_HARQ_OUTPUT, 772d819c083SNicolas Chautru op_data_prefixes[DATA_HARQ_OUTPUT]); 773d819c083SNicolas Chautru else if (!strcmp(key_token, "e")) { 774d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_E; 775d819c083SNicolas Chautru ldpc_dec->cb_params.e = (uint32_t) strtoul(token, &err, 0); 776d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 777d819c083SNicolas Chautru } else if (!strcmp(key_token, "ea")) { 778d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_EA; 779d819c083SNicolas Chautru ldpc_dec->tb_params.ea = (uint32_t) strtoul(token, &err, 0); 780d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 781d819c083SNicolas Chautru } else if (!strcmp(key_token, "eb")) { 782d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_EB; 783d819c083SNicolas Chautru ldpc_dec->tb_params.eb = (uint32_t) strtoul(token, &err, 0); 784d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 785d819c083SNicolas Chautru } else if (!strcmp(key_token, "c")) { 786d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_C; 787d819c083SNicolas Chautru ldpc_dec->tb_params.c = (uint8_t) strtoul(token, &err, 0); 788d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 789d819c083SNicolas Chautru } else if (!strcmp(key_token, "cab")) { 790d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_CAB; 791d819c083SNicolas Chautru ldpc_dec->tb_params.cab = (uint8_t) strtoul(token, &err, 0); 792d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 793d819c083SNicolas Chautru } else if (!strcmp(key_token, "rv_index")) { 794d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_RV_INDEX; 795d819c083SNicolas Chautru ldpc_dec->rv_index = (uint8_t) strtoul(token, &err, 0); 796d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 797d819c083SNicolas Chautru } else if (!strcmp(key_token, "n_cb")) { 798d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_NCB; 799d819c083SNicolas Chautru ldpc_dec->n_cb = (uint16_t) strtoul(token, &err, 0); 800d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 801d819c083SNicolas Chautru } else if (!strcmp(key_token, "r")) { 802d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_R; 803d819c083SNicolas Chautru ldpc_dec->tb_params.r = (uint8_t) strtoul(token, &err, 0); 804d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 805d819c083SNicolas Chautru } else if (!strcmp(key_token, "q_m")) { 806d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_QM; 807d819c083SNicolas Chautru ldpc_dec->q_m = (uint8_t) strtoul(token, &err, 0); 808d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 809d819c083SNicolas Chautru } else if (!strcmp(key_token, "basegraph")) { 810d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_BG; 811d819c083SNicolas Chautru ldpc_dec->basegraph = (uint8_t) strtoul(token, &err, 0); 812d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 813d819c083SNicolas Chautru } else if (!strcmp(key_token, "z_c")) { 814d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_ZC; 815d819c083SNicolas Chautru ldpc_dec->z_c = (uint16_t) strtoul(token, &err, 0); 816d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 817d819c083SNicolas Chautru } else if (!strcmp(key_token, "n_filler")) { 818d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_F; 819d819c083SNicolas Chautru ldpc_dec->n_filler = (uint16_t) strtoul(token, &err, 0); 820d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 821d819c083SNicolas Chautru } else if (!strcmp(key_token, "expected_iter_count")) { 822d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_EXPECTED_ITER_COUNT; 823d819c083SNicolas Chautru ldpc_dec->iter_count = (uint8_t) strtoul(token, &err, 0); 824d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 825d819c083SNicolas Chautru } else if (!strcmp(key_token, "iter_max")) { 826d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_ITER_MAX; 827d819c083SNicolas Chautru ldpc_dec->iter_max = (uint8_t) strtoul(token, &err, 0); 828d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 829d819c083SNicolas Chautru } else if (!strcmp(key_token, "code_block_mode")) { 830d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_CODE_BLOCK_MODE; 831d819c083SNicolas Chautru ldpc_dec->code_block_mode = (uint8_t) strtoul(token, &err, 0); 832d819c083SNicolas Chautru ret = ((err == NULL) || (*err != '\0')) ? -1 : 0; 833d819c083SNicolas Chautru } else if (!strcmp(key_token, "op_flags")) { 834d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_OP_FLAGS; 835d819c083SNicolas Chautru ret = parse_turbo_flags(token, &op_flags, vector->op_type); 836d819c083SNicolas Chautru if (!ret) 837d819c083SNicolas Chautru ldpc_dec->op_flags = op_flags; 838d819c083SNicolas Chautru } else if (!strcmp(key_token, "expected_status")) { 839d819c083SNicolas Chautru vector->mask |= TEST_BBDEV_VF_EXPECTED_STATUS; 840d819c083SNicolas Chautru ret = parse_expected_status(token, &status, vector->op_type); 841d819c083SNicolas Chautru if (!ret) 842d819c083SNicolas Chautru vector->expected_status = status; 843d819c083SNicolas Chautru } else { 844d819c083SNicolas Chautru printf("Not valid ldpc dec key: '%s'\n", key_token); 845d819c083SNicolas Chautru return -1; 846d819c083SNicolas Chautru } 847d819c083SNicolas Chautru 848d819c083SNicolas Chautru if (ret != 0) { 849d819c083SNicolas Chautru printf("Failed with convert '%s\t%s'\n", key_token, token); 850d819c083SNicolas Chautru return -1; 851d819c083SNicolas Chautru } 852d819c083SNicolas Chautru 853d819c083SNicolas Chautru return 0; 854d819c083SNicolas Chautru } 855d819c083SNicolas Chautru 856f714a188SAmr Mokhtar /* checks the type of key and assigns data */ 857f714a188SAmr Mokhtar static int 858f714a188SAmr Mokhtar parse_entry(char *entry, struct test_bbdev_vector *vector) 859f714a188SAmr Mokhtar { 860f714a188SAmr Mokhtar int ret = 0; 861f714a188SAmr Mokhtar char *token, *key_token; 862f714a188SAmr Mokhtar enum rte_bbdev_op_type op_type = RTE_BBDEV_OP_NONE; 863f714a188SAmr Mokhtar 864f714a188SAmr Mokhtar if (entry == NULL) { 865f714a188SAmr Mokhtar printf("Expected entry value\n"); 866f714a188SAmr Mokhtar return -1; 867f714a188SAmr Mokhtar } 868f714a188SAmr Mokhtar 869f714a188SAmr Mokhtar /* get key */ 870f714a188SAmr Mokhtar token = strtok(entry, ENTRY_DELIMITER); 871f714a188SAmr Mokhtar key_token = token; 872f714a188SAmr Mokhtar /* get values for key */ 873f714a188SAmr Mokhtar token = strtok(NULL, ENTRY_DELIMITER); 874f714a188SAmr Mokhtar 875f714a188SAmr Mokhtar if (key_token == NULL || token == NULL) { 876f714a188SAmr Mokhtar printf("Expected 'key = values' but was '%.40s'..\n", entry); 877f714a188SAmr Mokhtar return -1; 878f714a188SAmr Mokhtar } 879f714a188SAmr Mokhtar trim_space(key_token); 880f714a188SAmr Mokhtar 881f714a188SAmr Mokhtar /* first key_token has to specify type of operation */ 882f714a188SAmr Mokhtar if (vector->op_type == RTE_BBDEV_OP_NONE) { 883f714a188SAmr Mokhtar if (!strcmp(key_token, "op_type")) { 884f714a188SAmr Mokhtar ret = op_turbo_type_strtol(token, &op_type); 885f714a188SAmr Mokhtar if (!ret) 886f714a188SAmr Mokhtar vector->op_type = op_type; 887f714a188SAmr Mokhtar return (!ret) ? 0 : -1; 888f714a188SAmr Mokhtar } 889f714a188SAmr Mokhtar printf("First key_token (%s) does not specify op_type\n", 890f714a188SAmr Mokhtar key_token); 891f714a188SAmr Mokhtar return -1; 892f714a188SAmr Mokhtar } 893f714a188SAmr Mokhtar 894f714a188SAmr Mokhtar /* compare keys */ 895f714a188SAmr Mokhtar if (vector->op_type == RTE_BBDEV_OP_TURBO_DEC) { 896f714a188SAmr Mokhtar if (parse_decoder_params(key_token, token, vector) == -1) 897f714a188SAmr Mokhtar return -1; 898f714a188SAmr Mokhtar } else if (vector->op_type == RTE_BBDEV_OP_TURBO_ENC) { 899f714a188SAmr Mokhtar if (parse_encoder_params(key_token, token, vector) == -1) 900f714a188SAmr Mokhtar return -1; 901d819c083SNicolas Chautru } else if (vector->op_type == RTE_BBDEV_OP_LDPC_ENC) { 902d819c083SNicolas Chautru if (parse_ldpc_encoder_params(key_token, token, vector) == -1) 903d819c083SNicolas Chautru return -1; 904d819c083SNicolas Chautru } else if (vector->op_type == RTE_BBDEV_OP_LDPC_DEC) { 905d819c083SNicolas Chautru if (parse_ldpc_decoder_params(key_token, token, vector) == -1) 906d819c083SNicolas Chautru return -1; 907f714a188SAmr Mokhtar } 908f714a188SAmr Mokhtar 909f714a188SAmr Mokhtar return 0; 910f714a188SAmr Mokhtar } 911f714a188SAmr Mokhtar 912f714a188SAmr Mokhtar static int 913f714a188SAmr Mokhtar check_decoder_segments(struct test_bbdev_vector *vector) 914f714a188SAmr Mokhtar { 915f714a188SAmr Mokhtar unsigned char i; 916f714a188SAmr Mokhtar struct rte_bbdev_op_turbo_dec *turbo_dec = &vector->turbo_dec; 917f714a188SAmr Mokhtar 918f714a188SAmr Mokhtar if (vector->entries[DATA_INPUT].nb_segments == 0) 919f714a188SAmr Mokhtar return -1; 920f714a188SAmr Mokhtar 921f714a188SAmr Mokhtar for (i = 0; i < vector->entries[DATA_INPUT].nb_segments; i++) 922f714a188SAmr Mokhtar if (vector->entries[DATA_INPUT].segments[i].addr == NULL) 923f714a188SAmr Mokhtar return -1; 924f714a188SAmr Mokhtar 925f714a188SAmr Mokhtar if (vector->entries[DATA_HARD_OUTPUT].nb_segments == 0) 926f714a188SAmr Mokhtar return -1; 927f714a188SAmr Mokhtar 928f714a188SAmr Mokhtar for (i = 0; i < vector->entries[DATA_HARD_OUTPUT].nb_segments; 929f714a188SAmr Mokhtar i++) 930f714a188SAmr Mokhtar if (vector->entries[DATA_HARD_OUTPUT].segments[i].addr == NULL) 931f714a188SAmr Mokhtar return -1; 932f714a188SAmr Mokhtar 933f714a188SAmr Mokhtar if ((turbo_dec->op_flags & RTE_BBDEV_TURBO_SOFT_OUTPUT) && 934f714a188SAmr Mokhtar (vector->entries[DATA_SOFT_OUTPUT].nb_segments == 0)) 935f714a188SAmr Mokhtar return -1; 936f714a188SAmr Mokhtar 937f714a188SAmr Mokhtar for (i = 0; i < vector->entries[DATA_SOFT_OUTPUT].nb_segments; 938f714a188SAmr Mokhtar i++) 939f714a188SAmr Mokhtar if (vector->entries[DATA_SOFT_OUTPUT].segments[i].addr == NULL) 940f714a188SAmr Mokhtar return -1; 941f714a188SAmr Mokhtar 942f714a188SAmr Mokhtar return 0; 943f714a188SAmr Mokhtar } 944f714a188SAmr Mokhtar 945f714a188SAmr Mokhtar static int 946d819c083SNicolas Chautru check_ldpc_decoder_segments(struct test_bbdev_vector *vector) 947d819c083SNicolas Chautru { 948d819c083SNicolas Chautru unsigned char i; 949d819c083SNicolas Chautru struct rte_bbdev_op_ldpc_dec *ldpc_dec = &vector->ldpc_dec; 950d819c083SNicolas Chautru 951d819c083SNicolas Chautru for (i = 0; i < vector->entries[DATA_INPUT].nb_segments; i++) 952d819c083SNicolas Chautru if (vector->entries[DATA_INPUT].segments[i].addr == NULL) 953d819c083SNicolas Chautru return -1; 954d819c083SNicolas Chautru 955d819c083SNicolas Chautru for (i = 0; i < vector->entries[DATA_HARD_OUTPUT].nb_segments; i++) 956d819c083SNicolas Chautru if (vector->entries[DATA_HARD_OUTPUT].segments[i].addr == NULL) 957d819c083SNicolas Chautru return -1; 958d819c083SNicolas Chautru 959d819c083SNicolas Chautru if ((ldpc_dec->op_flags & RTE_BBDEV_LDPC_SOFT_OUT_ENABLE) && 960d819c083SNicolas Chautru (vector->entries[DATA_SOFT_OUTPUT].nb_segments == 0)) 961d819c083SNicolas Chautru return -1; 962d819c083SNicolas Chautru 963d819c083SNicolas Chautru for (i = 0; i < vector->entries[DATA_SOFT_OUTPUT].nb_segments; i++) 964d819c083SNicolas Chautru if (vector->entries[DATA_SOFT_OUTPUT].segments[i].addr == NULL) 965d819c083SNicolas Chautru return -1; 966d819c083SNicolas Chautru 967d819c083SNicolas Chautru if ((ldpc_dec->op_flags & RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE) && 968d819c083SNicolas Chautru (vector->entries[DATA_HARQ_OUTPUT].nb_segments == 0)) 969d819c083SNicolas Chautru return -1; 970d819c083SNicolas Chautru 971d819c083SNicolas Chautru for (i = 0; i < vector->entries[DATA_HARQ_OUTPUT].nb_segments; i++) 972d819c083SNicolas Chautru if (vector->entries[DATA_HARQ_OUTPUT].segments[i].addr == NULL) 973d819c083SNicolas Chautru return -1; 974d819c083SNicolas Chautru 975d819c083SNicolas Chautru return 0; 976d819c083SNicolas Chautru } 977d819c083SNicolas Chautru 978d819c083SNicolas Chautru static int 979f714a188SAmr Mokhtar check_decoder_llr_spec(struct test_bbdev_vector *vector) 980f714a188SAmr Mokhtar { 981f714a188SAmr Mokhtar struct rte_bbdev_op_turbo_dec *turbo_dec = &vector->turbo_dec; 982f714a188SAmr Mokhtar 983f714a188SAmr Mokhtar /* Check input LLR sign formalism specification */ 984f714a188SAmr Mokhtar if ((turbo_dec->op_flags & RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN) && 985f714a188SAmr Mokhtar (turbo_dec->op_flags & 986f714a188SAmr Mokhtar RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN)) { 987f714a188SAmr Mokhtar printf( 988f714a188SAmr Mokhtar "Both positive and negative LLR input flags were set!\n"); 989f714a188SAmr Mokhtar return -1; 990f714a188SAmr Mokhtar } 991f714a188SAmr Mokhtar if (!(turbo_dec->op_flags & RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN) && 992f714a188SAmr Mokhtar !(turbo_dec->op_flags & 993f714a188SAmr Mokhtar RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN)) { 994f714a188SAmr Mokhtar printf( 995d819c083SNicolas Chautru "INFO: input LLR sign formalism was not specified and will be set to negative LLR for '1' bit\n"); 996f714a188SAmr Mokhtar turbo_dec->op_flags |= RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN; 997f714a188SAmr Mokhtar } 998f714a188SAmr Mokhtar 999f714a188SAmr Mokhtar if (!(turbo_dec->op_flags & RTE_BBDEV_TURBO_SOFT_OUTPUT)) 1000f714a188SAmr Mokhtar return 0; 1001f714a188SAmr Mokhtar 1002f714a188SAmr Mokhtar /* Check output LLR sign formalism specification */ 1003f714a188SAmr Mokhtar if ((turbo_dec->op_flags & RTE_BBDEV_TURBO_POS_LLR_1_BIT_SOFT_OUT) && 1004f714a188SAmr Mokhtar (turbo_dec->op_flags & 1005f714a188SAmr Mokhtar RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT)) { 1006f714a188SAmr Mokhtar printf( 1007f714a188SAmr Mokhtar "Both positive and negative LLR output flags were set!\n"); 1008f714a188SAmr Mokhtar return -1; 1009f714a188SAmr Mokhtar } 1010f714a188SAmr Mokhtar if (!(turbo_dec->op_flags & RTE_BBDEV_TURBO_POS_LLR_1_BIT_SOFT_OUT) && 1011f714a188SAmr Mokhtar !(turbo_dec->op_flags & 1012f714a188SAmr Mokhtar RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT)) { 1013f714a188SAmr Mokhtar printf( 1014d819c083SNicolas Chautru "INFO: soft output LLR sign formalism was not specified and will be set to negative LLR for '1' bit\n"); 1015f714a188SAmr Mokhtar turbo_dec->op_flags |= 1016f714a188SAmr Mokhtar RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT; 1017f714a188SAmr Mokhtar } 1018f714a188SAmr Mokhtar 1019f714a188SAmr Mokhtar return 0; 1020f714a188SAmr Mokhtar } 1021f714a188SAmr Mokhtar 1022d819c083SNicolas Chautru static int 1023d819c083SNicolas Chautru check_decoder_op_flags(struct test_bbdev_vector *vector) 1024d819c083SNicolas Chautru { 1025d819c083SNicolas Chautru struct rte_bbdev_op_turbo_dec *turbo_dec = &vector->turbo_dec; 1026d819c083SNicolas Chautru 1027d819c083SNicolas Chautru if ((turbo_dec->op_flags & RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP) && 1028d819c083SNicolas Chautru !(turbo_dec->op_flags & RTE_BBDEV_TURBO_CRC_TYPE_24B)) { 1029d819c083SNicolas Chautru printf( 1030d819c083SNicolas Chautru "WARNING: RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP flag is missing RTE_BBDEV_TURBO_CRC_TYPE_24B\n"); 1031d819c083SNicolas Chautru return -1; 1032d819c083SNicolas Chautru } 1033d819c083SNicolas Chautru 1034d819c083SNicolas Chautru return 0; 1035d819c083SNicolas Chautru } 1036d819c083SNicolas Chautru 1037f714a188SAmr Mokhtar /* checks decoder parameters */ 1038f714a188SAmr Mokhtar static int 1039f714a188SAmr Mokhtar check_decoder(struct test_bbdev_vector *vector) 1040f714a188SAmr Mokhtar { 1041f714a188SAmr Mokhtar struct rte_bbdev_op_turbo_dec *turbo_dec = &vector->turbo_dec; 1042f714a188SAmr Mokhtar const int mask = vector->mask; 1043f714a188SAmr Mokhtar 1044f714a188SAmr Mokhtar if (check_decoder_segments(vector) < 0) 1045f714a188SAmr Mokhtar return -1; 1046f714a188SAmr Mokhtar 1047f714a188SAmr Mokhtar if (check_decoder_llr_spec(vector) < 0) 1048f714a188SAmr Mokhtar return -1; 1049f714a188SAmr Mokhtar 1050d819c083SNicolas Chautru if (check_decoder_op_flags(vector) < 0) 1051d819c083SNicolas Chautru return -1; 1052d819c083SNicolas Chautru 1053f714a188SAmr Mokhtar /* Check which params were set */ 1054f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_CODE_BLOCK_MODE)) { 1055f714a188SAmr Mokhtar printf( 1056f714a188SAmr Mokhtar "WARNING: code_block_mode was not specified in vector file and will be set to 1 (0 - TB Mode, 1 - CB mode)\n"); 105748fc315fSNicolas Chautru turbo_dec->code_block_mode = RTE_BBDEV_CODE_BLOCK; 1058f714a188SAmr Mokhtar } 105948fc315fSNicolas Chautru if (turbo_dec->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) { 1060f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_EA)) 1061f714a188SAmr Mokhtar printf( 1062f714a188SAmr Mokhtar "WARNING: ea was not specified in vector file and will be set to 0\n"); 1063f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_EB)) 1064f714a188SAmr Mokhtar printf( 1065f714a188SAmr Mokhtar "WARNING: eb was not specified in vector file and will be set to 0\n"); 1066f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_K_NEG)) 1067f714a188SAmr Mokhtar printf( 1068f714a188SAmr Mokhtar "WARNING: k_neg was not specified in vector file and will be set to 0\n"); 1069f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_K_POS)) 1070f714a188SAmr Mokhtar printf( 1071f714a188SAmr Mokhtar "WARNING: k_pos was not specified in vector file and will be set to 0\n"); 1072f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_C_NEG)) 1073f714a188SAmr Mokhtar printf( 1074f714a188SAmr Mokhtar "WARNING: c_neg was not specified in vector file and will be set to 0\n"); 1075f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_C)) { 1076f714a188SAmr Mokhtar printf( 1077f714a188SAmr Mokhtar "WARNING: c was not specified in vector file and will be set to 1\n"); 1078f714a188SAmr Mokhtar turbo_dec->tb_params.c = 1; 1079f714a188SAmr Mokhtar } 1080f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_CAB)) 1081f714a188SAmr Mokhtar printf( 1082f714a188SAmr Mokhtar "WARNING: cab was not specified in vector file and will be set to 0\n"); 10830b98d574SKamil Chalupnik if (!(mask & TEST_BBDEV_VF_R)) 10840b98d574SKamil Chalupnik printf( 10850b98d574SKamil Chalupnik "WARNING: r was not specified in vector file and will be set to 0\n"); 1086f714a188SAmr Mokhtar } else { 1087f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_E)) 1088f714a188SAmr Mokhtar printf( 1089f714a188SAmr Mokhtar "WARNING: e was not specified in vector file and will be set to 0\n"); 1090f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_K)) 1091f714a188SAmr Mokhtar printf( 1092f714a188SAmr Mokhtar "WARNING: k was not specified in vector file and will be set to 0\n"); 1093f714a188SAmr Mokhtar } 1094f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_RV_INDEX)) 1095f714a188SAmr Mokhtar printf( 1096d819c083SNicolas Chautru "INFO: rv_index was not specified in vector file and will be set to 0\n"); 1097f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_ITER_MIN)) 1098f714a188SAmr Mokhtar printf( 1099f714a188SAmr Mokhtar "WARNING: iter_min was not specified in vector file and will be set to 0\n"); 1100f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_ITER_MAX)) 1101f714a188SAmr Mokhtar printf( 1102f714a188SAmr Mokhtar "WARNING: iter_max was not specified in vector file and will be set to 0\n"); 1103f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_EXPECTED_ITER_COUNT)) 1104f714a188SAmr Mokhtar printf( 1105f714a188SAmr Mokhtar "WARNING: expected_iter_count was not specified in vector file and iter_count will not be validated\n"); 1106f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_EXT_SCALE)) 1107f714a188SAmr Mokhtar printf( 1108f714a188SAmr Mokhtar "WARNING: ext_scale was not specified in vector file and will be set to 0\n"); 1109f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_OP_FLAGS)) { 1110f714a188SAmr Mokhtar printf( 1111f714a188SAmr Mokhtar "WARNING: op_flags was not specified in vector file and capabilities will not be validated\n"); 1112f714a188SAmr Mokhtar turbo_dec->num_maps = 0; 1113f714a188SAmr Mokhtar } else if (!(turbo_dec->op_flags & RTE_BBDEV_TURBO_MAP_DEC) && 1114f714a188SAmr Mokhtar mask & TEST_BBDEV_VF_NUM_MAPS) { 1115f714a188SAmr Mokhtar printf( 1116d819c083SNicolas Chautru "INFO: RTE_BBDEV_TURBO_MAP_DEC was not set in vector file and num_maps will be set to 0\n"); 1117f714a188SAmr Mokhtar turbo_dec->num_maps = 0; 1118f714a188SAmr Mokhtar } 1119f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_EXPECTED_STATUS)) 1120f714a188SAmr Mokhtar printf( 1121f714a188SAmr Mokhtar "WARNING: expected_status was not specified in vector file and will be set to 0\n"); 1122f714a188SAmr Mokhtar return 0; 1123f714a188SAmr Mokhtar } 1124f714a188SAmr Mokhtar 1125d819c083SNicolas Chautru /* checks LDPC decoder parameters */ 1126d819c083SNicolas Chautru static int 1127d819c083SNicolas Chautru check_ldpc_decoder(struct test_bbdev_vector *vector) 1128d819c083SNicolas Chautru { 1129d819c083SNicolas Chautru struct rte_bbdev_op_ldpc_dec *ldpc_dec = &vector->ldpc_dec; 1130d819c083SNicolas Chautru const int mask = vector->mask; 1131d819c083SNicolas Chautru 1132d819c083SNicolas Chautru if (check_ldpc_decoder_segments(vector) < 0) 1133d819c083SNicolas Chautru return -1; 1134d819c083SNicolas Chautru 1135d819c083SNicolas Chautru /* 1136d819c083SNicolas Chautru * if (check_ldpc_decoder_llr_spec(vector) < 0) 1137d819c083SNicolas Chautru * return -1; 1138d819c083SNicolas Chautru * 1139d819c083SNicolas Chautru * if (check_ldpc_decoder_op_flags(vector) < 0) 1140d819c083SNicolas Chautru * return -1; 1141d819c083SNicolas Chautru */ 1142d819c083SNicolas Chautru 1143d819c083SNicolas Chautru /* Check which params were set */ 1144d819c083SNicolas Chautru if (!(mask & TEST_BBDEV_VF_CODE_BLOCK_MODE)) { 1145d819c083SNicolas Chautru printf( 1146d819c083SNicolas Chautru "WARNING: code_block_mode was not specified in vector file and will be set to 1 (0 - TB Mode, 1 - CB mode)\n"); 114748fc315fSNicolas Chautru ldpc_dec->code_block_mode = RTE_BBDEV_CODE_BLOCK; 1148d819c083SNicolas Chautru } 114948fc315fSNicolas Chautru if (ldpc_dec->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) { 1150d819c083SNicolas Chautru if (!(mask & TEST_BBDEV_VF_EA)) 1151d819c083SNicolas Chautru printf( 1152d819c083SNicolas Chautru "WARNING: ea was not specified in vector file and will be set to 0\n"); 1153d819c083SNicolas Chautru if (!(mask & TEST_BBDEV_VF_EB)) 1154d819c083SNicolas Chautru printf( 1155d819c083SNicolas Chautru "WARNING: eb was not specified in vector file and will be set to 0\n"); 1156d819c083SNicolas Chautru if (!(mask & TEST_BBDEV_VF_C)) { 1157d819c083SNicolas Chautru printf( 1158d819c083SNicolas Chautru "WARNING: c was not specified in vector file and will be set to 1\n"); 1159d819c083SNicolas Chautru ldpc_dec->tb_params.c = 1; 1160d819c083SNicolas Chautru } 1161d819c083SNicolas Chautru if (!(mask & TEST_BBDEV_VF_CAB)) 1162d819c083SNicolas Chautru printf( 1163d819c083SNicolas Chautru "WARNING: cab was not specified in vector file and will be set to 0\n"); 1164d819c083SNicolas Chautru if (!(mask & TEST_BBDEV_VF_R)) 1165d819c083SNicolas Chautru printf( 1166d819c083SNicolas Chautru "WARNING: r was not specified in vector file and will be set to 0\n"); 1167d819c083SNicolas Chautru } else { 1168d819c083SNicolas Chautru if (!(mask & TEST_BBDEV_VF_E)) 1169d819c083SNicolas Chautru printf( 1170d819c083SNicolas Chautru "WARNING: e was not specified in vector file and will be set to 0\n"); 1171d819c083SNicolas Chautru } 1172d819c083SNicolas Chautru if (!(mask & TEST_BBDEV_VF_RV_INDEX)) 1173d819c083SNicolas Chautru printf( 1174d819c083SNicolas Chautru "INFO: rv_index was not specified in vector file and will be set to 0\n"); 1175d819c083SNicolas Chautru if (!(mask & TEST_BBDEV_VF_ITER_MAX)) 1176d819c083SNicolas Chautru printf( 1177d819c083SNicolas Chautru "WARNING: iter_max was not specified in vector file and will be set to 0\n"); 1178d819c083SNicolas Chautru if (!(mask & TEST_BBDEV_VF_EXPECTED_ITER_COUNT)) 1179d819c083SNicolas Chautru printf( 1180d819c083SNicolas Chautru "WARNING: expected_iter_count was not specified in vector file and iter_count will not be validated\n"); 1181d819c083SNicolas Chautru if (!(mask & TEST_BBDEV_VF_OP_FLAGS)) { 1182d819c083SNicolas Chautru printf( 1183d819c083SNicolas Chautru "WARNING: op_flags was not specified in vector file and capabilities will not be validated\n"); 1184d819c083SNicolas Chautru } 1185d819c083SNicolas Chautru if (!(mask & TEST_BBDEV_VF_EXPECTED_STATUS)) 1186d819c083SNicolas Chautru printf( 1187d819c083SNicolas Chautru "WARNING: expected_status was not specified in vector file and will be set to 0\n"); 1188d819c083SNicolas Chautru return 0; 1189d819c083SNicolas Chautru } 1190d819c083SNicolas Chautru 1191f714a188SAmr Mokhtar /* checks encoder parameters */ 1192f714a188SAmr Mokhtar static int 1193f714a188SAmr Mokhtar check_encoder(struct test_bbdev_vector *vector) 1194f714a188SAmr Mokhtar { 1195f714a188SAmr Mokhtar unsigned char i; 1196f714a188SAmr Mokhtar const int mask = vector->mask; 1197f714a188SAmr Mokhtar 1198f714a188SAmr Mokhtar if (vector->entries[DATA_INPUT].nb_segments == 0) 1199f714a188SAmr Mokhtar return -1; 1200f714a188SAmr Mokhtar 1201f714a188SAmr Mokhtar for (i = 0; i < vector->entries[DATA_INPUT].nb_segments; i++) 1202f714a188SAmr Mokhtar if (vector->entries[DATA_INPUT].segments[i].addr == NULL) 1203f714a188SAmr Mokhtar return -1; 1204f714a188SAmr Mokhtar 1205f714a188SAmr Mokhtar if (vector->entries[DATA_HARD_OUTPUT].nb_segments == 0) 1206f714a188SAmr Mokhtar return -1; 1207f714a188SAmr Mokhtar 1208f714a188SAmr Mokhtar for (i = 0; i < vector->entries[DATA_HARD_OUTPUT].nb_segments; i++) 1209f714a188SAmr Mokhtar if (vector->entries[DATA_HARD_OUTPUT].segments[i].addr == NULL) 1210f714a188SAmr Mokhtar return -1; 1211f714a188SAmr Mokhtar 1212f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_CODE_BLOCK_MODE)) { 1213f714a188SAmr Mokhtar printf( 1214f714a188SAmr Mokhtar "WARNING: code_block_mode was not specified in vector file and will be set to 1\n"); 121548fc315fSNicolas Chautru vector->turbo_enc.code_block_mode = RTE_BBDEV_CODE_BLOCK; 1216f714a188SAmr Mokhtar } 121748fc315fSNicolas Chautru if (vector->turbo_enc.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) { 1218f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_EA) && (vector->turbo_enc.op_flags & 1219f714a188SAmr Mokhtar RTE_BBDEV_TURBO_RATE_MATCH)) 1220f714a188SAmr Mokhtar printf( 1221f714a188SAmr Mokhtar "WARNING: ea was not specified in vector file and will be set to 0\n"); 1222f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_EB) && (vector->turbo_enc.op_flags & 1223f714a188SAmr Mokhtar RTE_BBDEV_TURBO_RATE_MATCH)) 1224f714a188SAmr Mokhtar printf( 1225f714a188SAmr Mokhtar "WARNING: eb was not specified in vector file and will be set to 0\n"); 1226f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_K_NEG)) 1227f714a188SAmr Mokhtar printf( 1228f714a188SAmr Mokhtar "WARNING: k_neg was not specified in vector file and will be set to 0\n"); 1229f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_K_POS)) 1230f714a188SAmr Mokhtar printf( 1231f714a188SAmr Mokhtar "WARNING: k_pos was not specified in vector file and will be set to 0\n"); 1232f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_C_NEG)) 1233f714a188SAmr Mokhtar printf( 1234f714a188SAmr Mokhtar "WARNING: c_neg was not specified in vector file and will be set to 0\n"); 1235f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_C)) { 1236f714a188SAmr Mokhtar printf( 1237f714a188SAmr Mokhtar "WARNING: c was not specified in vector file and will be set to 1\n"); 1238f714a188SAmr Mokhtar vector->turbo_enc.tb_params.c = 1; 1239f714a188SAmr Mokhtar } 1240f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_CAB) && (vector->turbo_enc.op_flags & 1241f714a188SAmr Mokhtar RTE_BBDEV_TURBO_RATE_MATCH)) 1242f714a188SAmr Mokhtar printf( 1243f714a188SAmr Mokhtar "WARNING: cab was not specified in vector file and will be set to 0\n"); 1244f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_NCB_NEG)) 1245f714a188SAmr Mokhtar printf( 1246f714a188SAmr Mokhtar "WARNING: ncb_neg was not specified in vector file and will be set to 0\n"); 1247f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_NCB_POS)) 1248f714a188SAmr Mokhtar printf( 1249f714a188SAmr Mokhtar "WARNING: ncb_pos was not specified in vector file and will be set to 0\n"); 1250f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_R)) 1251f714a188SAmr Mokhtar printf( 1252f714a188SAmr Mokhtar "WARNING: r was not specified in vector file and will be set to 0\n"); 1253f714a188SAmr Mokhtar } else { 1254f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_E) && (vector->turbo_enc.op_flags & 1255f714a188SAmr Mokhtar RTE_BBDEV_TURBO_RATE_MATCH)) 1256f714a188SAmr Mokhtar printf( 1257f714a188SAmr Mokhtar "WARNING: e was not specified in vector file and will be set to 0\n"); 1258f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_K)) 1259f714a188SAmr Mokhtar printf( 1260f714a188SAmr Mokhtar "WARNING: k was not specified in vector file and will be set to 0\n"); 1261f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_NCB)) 1262f714a188SAmr Mokhtar printf( 1263f714a188SAmr Mokhtar "WARNING: ncb was not specified in vector file and will be set to 0\n"); 1264f714a188SAmr Mokhtar } 1265f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_RV_INDEX)) 1266f714a188SAmr Mokhtar printf( 1267d819c083SNicolas Chautru "INFO: rv_index was not specified in vector file and will be set to 0\n"); 1268f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_OP_FLAGS)) 1269f714a188SAmr Mokhtar printf( 1270d819c083SNicolas Chautru "INFO: op_flags was not specified in vector file and capabilities will not be validated\n"); 1271d819c083SNicolas Chautru if (!(mask & TEST_BBDEV_VF_EXPECTED_STATUS)) 1272d819c083SNicolas Chautru printf( 1273d819c083SNicolas Chautru "WARNING: expected_status was not specified in vector file and will be set to 0\n"); 1274d819c083SNicolas Chautru 1275d819c083SNicolas Chautru return 0; 1276d819c083SNicolas Chautru } 1277d819c083SNicolas Chautru 1278d819c083SNicolas Chautru 1279d819c083SNicolas Chautru /* checks encoder parameters */ 1280d819c083SNicolas Chautru static int 1281d819c083SNicolas Chautru check_ldpc_encoder(struct test_bbdev_vector *vector) 1282d819c083SNicolas Chautru { 1283d819c083SNicolas Chautru unsigned char i; 1284d819c083SNicolas Chautru const int mask = vector->mask; 1285d819c083SNicolas Chautru 1286d819c083SNicolas Chautru if (vector->entries[DATA_INPUT].nb_segments == 0) 1287d819c083SNicolas Chautru return -1; 1288d819c083SNicolas Chautru 1289d819c083SNicolas Chautru for (i = 0; i < vector->entries[DATA_INPUT].nb_segments; i++) 1290d819c083SNicolas Chautru if (vector->entries[DATA_INPUT].segments[i].addr == NULL) 1291d819c083SNicolas Chautru return -1; 1292d819c083SNicolas Chautru 1293d819c083SNicolas Chautru if (vector->entries[DATA_HARD_OUTPUT].nb_segments == 0) 1294d819c083SNicolas Chautru return -1; 1295d819c083SNicolas Chautru 1296d819c083SNicolas Chautru for (i = 0; i < vector->entries[DATA_HARD_OUTPUT].nb_segments; i++) 1297d819c083SNicolas Chautru if (vector->entries[DATA_HARD_OUTPUT].segments[i].addr == NULL) 1298d819c083SNicolas Chautru return -1; 1299d819c083SNicolas Chautru 1300d819c083SNicolas Chautru if (!(mask & TEST_BBDEV_VF_CODE_BLOCK_MODE)) { 1301d819c083SNicolas Chautru printf( 1302d819c083SNicolas Chautru "WARNING: code_block_mode was not specified in vector file and will be set to 1\n"); 130348fc315fSNicolas Chautru vector->turbo_enc.code_block_mode = RTE_BBDEV_CODE_BLOCK; 1304d819c083SNicolas Chautru } 130548fc315fSNicolas Chautru if (vector->turbo_enc.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) { 1306d819c083SNicolas Chautru } else { 1307d819c083SNicolas Chautru if (!(mask & TEST_BBDEV_VF_E) && (vector->turbo_enc.op_flags & 1308d819c083SNicolas Chautru RTE_BBDEV_TURBO_RATE_MATCH)) 1309d819c083SNicolas Chautru printf( 1310d819c083SNicolas Chautru "WARNING: e was not specified in vector file and will be set to 0\n"); 1311d819c083SNicolas Chautru if (!(mask & TEST_BBDEV_VF_NCB)) 1312d819c083SNicolas Chautru printf( 1313d819c083SNicolas Chautru "WARNING: ncb was not specified in vector file and will be set to 0\n"); 1314d819c083SNicolas Chautru } 1315d819c083SNicolas Chautru if (!(mask & TEST_BBDEV_VF_BG)) 1316d819c083SNicolas Chautru printf( 1317d819c083SNicolas Chautru "WARNING: BG was not specified in vector file and will be set to 0\n"); 1318d819c083SNicolas Chautru if (!(mask & TEST_BBDEV_VF_ZC)) 1319d819c083SNicolas Chautru printf( 1320d819c083SNicolas Chautru "WARNING: Zc was not specified in vector file and will be set to 0\n"); 1321d819c083SNicolas Chautru if (!(mask & TEST_BBDEV_VF_RV_INDEX)) 1322d819c083SNicolas Chautru printf( 1323d819c083SNicolas Chautru "INFO: rv_index was not specified in vector file and will be set to 0\n"); 1324d819c083SNicolas Chautru if (!(mask & TEST_BBDEV_VF_OP_FLAGS)) 1325d819c083SNicolas Chautru printf( 1326d819c083SNicolas Chautru "INFO: op_flags was not specified in vector file and capabilities will not be validated\n"); 1327f714a188SAmr Mokhtar if (!(mask & TEST_BBDEV_VF_EXPECTED_STATUS)) 1328f714a188SAmr Mokhtar printf( 1329f714a188SAmr Mokhtar "WARNING: expected_status was not specified in vector file and will be set to 0\n"); 1330f714a188SAmr Mokhtar 1331f714a188SAmr Mokhtar return 0; 1332f714a188SAmr Mokhtar } 1333f714a188SAmr Mokhtar 1334f714a188SAmr Mokhtar static int 1335f714a188SAmr Mokhtar bbdev_check_vector(struct test_bbdev_vector *vector) 1336f714a188SAmr Mokhtar { 1337f714a188SAmr Mokhtar if (vector->op_type == RTE_BBDEV_OP_TURBO_DEC) { 1338f714a188SAmr Mokhtar if (check_decoder(vector) == -1) 1339f714a188SAmr Mokhtar return -1; 1340f714a188SAmr Mokhtar } else if (vector->op_type == RTE_BBDEV_OP_TURBO_ENC) { 1341f714a188SAmr Mokhtar if (check_encoder(vector) == -1) 1342f714a188SAmr Mokhtar return -1; 1343d819c083SNicolas Chautru } else if (vector->op_type == RTE_BBDEV_OP_LDPC_ENC) { 1344d819c083SNicolas Chautru if (check_ldpc_encoder(vector) == -1) 1345d819c083SNicolas Chautru return -1; 1346d819c083SNicolas Chautru } else if (vector->op_type == RTE_BBDEV_OP_LDPC_DEC) { 1347d819c083SNicolas Chautru if (check_ldpc_decoder(vector) == -1) 1348d819c083SNicolas Chautru return -1; 1349f714a188SAmr Mokhtar } else if (vector->op_type != RTE_BBDEV_OP_NONE) { 1350f714a188SAmr Mokhtar printf("Vector was not filled\n"); 1351f714a188SAmr Mokhtar return -1; 1352f714a188SAmr Mokhtar } 1353f714a188SAmr Mokhtar 1354f714a188SAmr Mokhtar return 0; 1355f714a188SAmr Mokhtar } 1356f714a188SAmr Mokhtar 1357f714a188SAmr Mokhtar int 1358f714a188SAmr Mokhtar test_bbdev_vector_read(const char *filename, 1359f714a188SAmr Mokhtar struct test_bbdev_vector *vector) 1360f714a188SAmr Mokhtar { 1361f714a188SAmr Mokhtar int ret = 0; 1362f714a188SAmr Mokhtar size_t len = 0; 1363f714a188SAmr Mokhtar 1364f714a188SAmr Mokhtar FILE *fp = NULL; 1365f714a188SAmr Mokhtar char *line = NULL; 1366f714a188SAmr Mokhtar char *entry = NULL; 1367f714a188SAmr Mokhtar 1368f714a188SAmr Mokhtar fp = fopen(filename, "r"); 1369f714a188SAmr Mokhtar if (fp == NULL) { 1370f714a188SAmr Mokhtar printf("File %s does not exist\n", filename); 1371f714a188SAmr Mokhtar return -1; 1372f714a188SAmr Mokhtar } 1373f714a188SAmr Mokhtar 1374f714a188SAmr Mokhtar while (getline(&line, &len, fp) != -1) { 1375f714a188SAmr Mokhtar 1376f714a188SAmr Mokhtar /* ignore comments and new lines */ 1377f714a188SAmr Mokhtar if (line[0] == '#' || line[0] == '/' || line[0] == '\n' 1378f714a188SAmr Mokhtar || line[0] == '\r') 1379f714a188SAmr Mokhtar continue; 1380f714a188SAmr Mokhtar 1381f714a188SAmr Mokhtar trim_space(line); 1382f714a188SAmr Mokhtar 1383f714a188SAmr Mokhtar /* buffer for multiline */ 1384f714a188SAmr Mokhtar entry = realloc(entry, strlen(line) + 1); 1385f714a188SAmr Mokhtar if (entry == NULL) { 1386f714a188SAmr Mokhtar printf("Fail to realloc %zu bytes\n", strlen(line) + 1); 1387f714a188SAmr Mokhtar ret = -ENOMEM; 1388f714a188SAmr Mokhtar goto exit; 1389f714a188SAmr Mokhtar } 1390f714a188SAmr Mokhtar 1391f2790f9cSAndy Green strcpy(entry, line); 1392f714a188SAmr Mokhtar 1393f714a188SAmr Mokhtar /* check if entry ends with , or = */ 1394f714a188SAmr Mokhtar if (entry[strlen(entry) - 1] == ',' 1395f714a188SAmr Mokhtar || entry[strlen(entry) - 1] == '=') { 1396f714a188SAmr Mokhtar while (getline(&line, &len, fp) != -1) { 1397f714a188SAmr Mokhtar trim_space(line); 1398f714a188SAmr Mokhtar 1399f714a188SAmr Mokhtar /* extend entry about length of new line */ 1400f714a188SAmr Mokhtar char *entry_extended = realloc(entry, 1401f714a188SAmr Mokhtar strlen(line) + 1402f714a188SAmr Mokhtar strlen(entry) + 1); 1403f714a188SAmr Mokhtar 1404f714a188SAmr Mokhtar if (entry_extended == NULL) { 1405f714a188SAmr Mokhtar printf("Fail to allocate %zu bytes\n", 1406f714a188SAmr Mokhtar strlen(line) + 1407f714a188SAmr Mokhtar strlen(entry) + 1); 1408f714a188SAmr Mokhtar ret = -ENOMEM; 1409f714a188SAmr Mokhtar goto exit; 1410f714a188SAmr Mokhtar } 1411f714a188SAmr Mokhtar 1412f714a188SAmr Mokhtar entry = entry_extended; 1413f2790f9cSAndy Green /* entry has been allocated accordingly */ 1414f2790f9cSAndy Green strcpy(&entry[strlen(entry)], line); 1415f714a188SAmr Mokhtar 1416f714a188SAmr Mokhtar if (entry[strlen(entry) - 1] != ',') 1417f714a188SAmr Mokhtar break; 1418f714a188SAmr Mokhtar } 1419f714a188SAmr Mokhtar } 1420f714a188SAmr Mokhtar ret = parse_entry(entry, vector); 1421f714a188SAmr Mokhtar if (ret != 0) { 1422f714a188SAmr Mokhtar printf("An error occurred while parsing!\n"); 1423f714a188SAmr Mokhtar goto exit; 1424f714a188SAmr Mokhtar } 1425f714a188SAmr Mokhtar } 1426f714a188SAmr Mokhtar ret = bbdev_check_vector(vector); 1427f714a188SAmr Mokhtar if (ret != 0) 1428f714a188SAmr Mokhtar printf("An error occurred while checking!\n"); 1429f714a188SAmr Mokhtar 1430f714a188SAmr Mokhtar exit: 1431f714a188SAmr Mokhtar fclose(fp); 1432f714a188SAmr Mokhtar free(line); 1433f714a188SAmr Mokhtar free(entry); 1434f714a188SAmr Mokhtar 1435f714a188SAmr Mokhtar return ret; 1436f714a188SAmr Mokhtar } 1437