From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 2B9FAFACB for ; Mon, 27 Mar 2017 13:26:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490613980; x=1522149980; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=rbFe7cKdO9CYllDeXFT9Al077vRCxKEH2LSK1+oIgf0=; b=jmeKeNmQJn4Wt9huRiI8ml8qMNYLFIIWDNpEJDaegUYKMBNsdfCXrweF Zsa03OoZANVDcvFPXo3Fk2aCgng9hQ==; Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2017 04:26:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,231,1486454400"; d="scan'208";a="79709357" Received: from silpixa00381631.ir.intel.com (HELO silpixa00381631.ger.corp.intel.com) ([10.237.222.122]) by orsmga005.jf.intel.com with ESMTP; 27 Mar 2017 04:26:18 -0700 From: Pablo de Lara To: declan.doherty@intel.com Cc: dev@dpdk.org, Pablo de Lara Date: Mon, 27 Mar 2017 12:25:59 +0100 Message-Id: <1490613966-74180-3-git-send-email-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490613966-74180-1-git-send-email-pablo.de.lara.guarch@intel.com> References: <1488557592-46193-1-git-send-email-pablo.de.lara.guarch@intel.com> <1490613966-74180-1-git-send-email-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v2 2/9] app/crypto-perf: remove unused file X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Mar 2017 11:26:20 -0000 Signed-off-by: Pablo de Lara --- app/test-crypto-perf/cperf_verify_parser.c | 314 ----------------------------- 1 file changed, 314 deletions(-) delete mode 100644 app/test-crypto-perf/cperf_verify_parser.c diff --git a/app/test-crypto-perf/cperf_verify_parser.c b/app/test-crypto-perf/cperf_verify_parser.c deleted file mode 100644 index 5640d84..0000000 --- a/app/test-crypto-perf/cperf_verify_parser.c +++ /dev/null @@ -1,314 +0,0 @@ -#include - -#include -#include "cperf_options.h" -#include "cperf_test_vectors.h" -#include "cperf_verify_parser.h" - -int -free_test_vector(struct cperf_test_vector *vector, struct cperf_options *opts) -{ - if (vector == NULL || opts == NULL) - return -1; - - if (opts->test_file == NULL) { - if (vector->iv.data) - rte_free(vector->iv.data); - if (vector->aad.data) - rte_free(vector->aad.data); - if (vector->digest.data) - rte_free(vector->digest.data); - rte_free(vector); - - } else { - if (vector->plaintext.data) - rte_free(vector->plaintext.data); - if (vector->cipher_key.data) - rte_free(vector->cipher_key.data); - if (vector->auth_key.data) - rte_free(vector->auth_key.data); - if (vector->iv.data) - rte_free(vector->iv.data); - if (vector->ciphertext.data) - rte_free(vector->ciphertext.data); - if (vector->aad.data) - rte_free(vector->aad.data); - if (vector->digest.data) - rte_free(vector->digest.data); - rte_free(vector); - } - - return 0; -} - -/* trim leading and trailing spaces */ -static char * -trim(char *str) -{ - char *start, *end; - - for (start = str; *start; start++) { - if (!isspace((unsigned char) start[0])) - break; - } - - for (end = start + strlen(start); end > start + 1; end--) { - if (!isspace((unsigned char) end[-1])) - break; - } - - *end = 0; - - /* Shift from "start" to the beginning of the string */ - if (start > str) - memmove(str, start, (end - start) + 1); - - return str; -} - -/* tokenization test values separated by a comma */ -static int -parse_values(char *tokens, uint8_t **data, uint32_t *data_length) -{ - uint8_t n_tokens; - uint32_t data_size = 32; - uint8_t *values; - char *tok, *error = NULL; - - tok = strtok(tokens, VALUE_DELIMITER); - if (tok == NULL) - return -1; - - values = (uint8_t *) rte_zmalloc(NULL, sizeof(uint8_t) * data_size, 0); - if (values == NULL) - return -1; - - n_tokens = 0; - while (tok != NULL) { - uint8_t *values_extended = NULL; - - if (n_tokens >= data_size) { - - data_size *= 2; - - values_extended = (uint8_t *) rte_realloc(values, - sizeof(uint8_t) * data_size, 0); - if (values_extended == NULL) { - rte_free(values); - return -1; - } - - values = values_extended; - } - - values[n_tokens] = (uint8_t) strtoul(tok, &error, 0); - if ((error == NULL) || (*error != '\0')) { - printf("Failed with convert '%s'\n", tok); - rte_free(values); - return -1; - } - - tok = strtok(NULL, VALUE_DELIMITER); - if (tok == NULL) - break; - - n_tokens++; - } - - uint8_t *resize_values = (uint8_t *) rte_realloc(values, - sizeof(uint8_t) * (n_tokens + 1), 0); - - if (resize_values == NULL) { - rte_free(values); - return -1; - } - - *data = resize_values; - *data_length = n_tokens + 1; - - return 0; -} - -/* checks the type of key and assigns data */ -static int -parse_entry(char *entry, struct cperf_test_vector *vector) -{ - char *token, *key_token; - uint8_t *data = NULL; - int status; - uint32_t data_length; - - /* get key */ - token = strtok(entry, ENTRY_DELIMITER); - key_token = token; - - /* get values for key */ - token = strtok(NULL, ENTRY_DELIMITER); - - if (token == NULL) { - printf("Expected 'key = values' but was '%.40s'..\n", - key_token); - return -1; - } - - status = parse_values(token, &data, &data_length); - if (status) - return -1; - - /* compare keys */ - if (strstr(key_token, "plaintext")) { - if (vector->plaintext.data) - rte_free(vector->plaintext.data); - vector->plaintext.data = data; - vector->plaintext.length = data_length; - } else if (strstr(key_token, "cipher_key")) { - if (vector->cipher_key.data) - rte_free(vector->cipher_key.data); - vector->cipher_key.data = data; - vector->cipher_key.length = data_length; - } else if (strstr(key_token, "auth_key")) { - if (vector->auth_key.data) - rte_free(vector->auth_key.data); - vector->auth_key.data = data; - vector->auth_key.length = data_length; - } else if (strstr(key_token, "iv")) { - if (vector->iv.data) - rte_free(vector->iv.data); - vector->iv.data = data; - vector->iv.phys_addr = rte_malloc_virt2phy(vector->iv.data); - vector->iv.length = data_length; - } else if (strstr(key_token, "ciphertext")) { - if (vector->ciphertext.data) - rte_free(vector->ciphertext.data); - vector->ciphertext.data = data; - vector->ciphertext.length = data_length; - } else if (strstr(key_token, "aad")) { - if (vector->aad.data) - rte_free(vector->aad.data); - vector->aad.data = data; - vector->aad.phys_addr = rte_malloc_virt2phy(vector->aad.data); - vector->aad.length = data_length; - } else if (strstr(key_token, "digest")) { - if (vector->digest.data) - rte_free(vector->digest.data); - vector->digest.data = data; - vector->digest.phys_addr = rte_malloc_virt2phy( - vector->digest.data); - vector->digest.length = data_length; - } else { - printf("Not valid key: '%s'\n", trim(key_token)); - return -1; - } - - return 0; -} - -/* searches in the file for registry keys and values */ -static int -parse_file(struct cperf_test_vector *v_vec, const char *path) -{ - FILE *fp; - char *line = NULL, *entry = NULL; - ssize_t read; - size_t len = 0; - int status = 0; - - fp = fopen(path, "r"); - if (fp == NULL) { - printf("File %s does not exists\n", path); - return -1; - } - - while ((read = getline(&line, &len, fp)) != -1) { - /* ignore comments and new lines */ - if (line[0] == '#' || line[0] == '/' || line[0] == '\n' - || line[0] == '\r' || line[0] == ' ') - continue; - - trim(line); - - /* buffer for multiline */ - entry = (char *) rte_realloc(entry, - sizeof(char) * strlen(line) + 1, 0); - if (entry == NULL) - return -1; - - memset(entry, 0, strlen(line) + 1); - strncpy(entry, line, strlen(line)); - - /* check if entry ends with , or = */ - if (entry[strlen(entry) - 1] == ',' - || entry[strlen(entry) - 1] == '=') { - while ((read = getline(&line, &len, fp)) != -1) { - trim(line); - - /* extend entry about length of new line */ - char *entry_extended = (char *) rte_realloc( - entry, sizeof(char) - * (strlen(line) + strlen(entry)) - + 1, 0); - - if (entry_extended == NULL) - goto err; - entry = entry_extended; - - strncat(entry, line, strlen(line)); - - if (entry[strlen(entry) - 1] != ',') - break; - } - } - status = parse_entry(entry, v_vec); - if (status) { - printf("An error occurred while parsing!\n"); - goto err; - } - } - - fclose(fp); - free(line); - rte_free(entry); - - return 0; - -err: - if (fp) - fclose(fp); - if (line) - free(line); - if (entry) - rte_free(entry); - - return -1; -} - -struct cperf_test_vector* -cperf_test_vector_get_from_file(struct cperf_options *opts) -{ - int status; - struct cperf_test_vector *test_vector = NULL; - - if (opts == NULL || opts->test_file == NULL) - return test_vector; - - test_vector = (struct cperf_test_vector *) rte_zmalloc(NULL, - sizeof(struct cperf_test_vector), 0); - if (test_vector == NULL) - return test_vector; - - /* filling the vector with data from a file */ - status = parse_file(test_vector, opts->test_file); - if (status) { - free_test_vector(test_vector, opts); - return NULL; - } - - /* other values not included in the file */ - test_vector->data.cipher_offset = 0; - test_vector->data.cipher_length = opts->buffer_sz; - - test_vector->data.auth_offset = 0; - test_vector->data.auth_length = opts->buffer_sz; - - return test_vector; -} -- 2.7.4