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