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