From: Reshma Pattan Date: Tue, 11 Sep 2018 14:20:34 +0000 (+0100) Subject: net/softnic: replace pointers with arrays X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=b767f8efc8;p=dpdk.git net/softnic: replace pointers with arrays Change dev_name, action_profile_name and key_mask from char* type to arary type of structures softnic_port_in_params, softnic_port_out_params and softnic_table_hash_params. Signed-off-by: Cristian Dumitrescu Signed-off-by: Reshma Pattan --- diff --git a/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c index 8f5f825552..dc8ccdc733 100644 --- a/drivers/net/softnic/rte_eth_softnic_cli.c +++ b/drivers/net/softnic/rte_eth_softnic_cli.c @@ -1697,6 +1697,8 @@ cmd_pipeline_port_in(struct pmd_internals *softnic, uint32_t t0; int enabled, status; + memset(&p, 0, sizeof(p)); + if (n_tokens < 7) { snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); return; @@ -1735,7 +1737,7 @@ cmd_pipeline_port_in(struct pmd_internals *softnic, p.type = PORT_IN_RXQ; - p.dev_name = tokens[t0 + 1]; + strcpy(p.dev_name, tokens[t0 + 1]); if (strcmp(tokens[t0 + 2], "rxq") != 0) { snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rxq"); @@ -1758,7 +1760,7 @@ cmd_pipeline_port_in(struct pmd_internals *softnic, p.type = PORT_IN_SWQ; - p.dev_name = tokens[t0 + 1]; + strcpy(p.dev_name, tokens[t0 + 1]); t0 += 2; } else if (strcmp(tokens[t0], "tmgr") == 0) { @@ -1770,7 +1772,7 @@ cmd_pipeline_port_in(struct pmd_internals *softnic, p.type = PORT_IN_TMGR; - p.dev_name = tokens[t0 + 1]; + strcpy(p.dev_name, tokens[t0 + 1]); t0 += 2; } else if (strcmp(tokens[t0], "tap") == 0) { @@ -1782,7 +1784,7 @@ cmd_pipeline_port_in(struct pmd_internals *softnic, p.type = PORT_IN_TAP; - p.dev_name = tokens[t0 + 1]; + strcpy(p.dev_name, tokens[t0 + 1]); if (strcmp(tokens[t0 + 2], "mempool") != 0) { snprintf(out, out_size, MSG_ARG_NOT_FOUND, @@ -1814,8 +1816,6 @@ cmd_pipeline_port_in(struct pmd_internals *softnic, p.type = PORT_IN_SOURCE; - p.dev_name = NULL; - if (strcmp(tokens[t0 + 1], "mempool") != 0) { snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mempool"); @@ -1851,7 +1851,6 @@ cmd_pipeline_port_in(struct pmd_internals *softnic, return; } - p.action_profile_name = NULL; if (n_tokens > t0 && (strcmp(tokens[t0], "action") == 0)) { if (n_tokens < t0 + 2) { @@ -1859,7 +1858,7 @@ cmd_pipeline_port_in(struct pmd_internals *softnic, return; } - p.action_profile_name = tokens[t0 + 1]; + strcpy(p.action_profile_name, tokens[t0 + 1]); t0 += 2; } @@ -1945,7 +1944,7 @@ cmd_pipeline_port_out(struct pmd_internals *softnic, p.type = PORT_OUT_TXQ; - p.dev_name = tokens[7]; + strcpy(p.dev_name, tokens[7]); if (strcmp(tokens[8], "txq") != 0) { snprintf(out, out_size, MSG_ARG_NOT_FOUND, "txq"); @@ -1966,7 +1965,7 @@ cmd_pipeline_port_out(struct pmd_internals *softnic, p.type = PORT_OUT_SWQ; - p.dev_name = tokens[7]; + strcpy(p.dev_name, tokens[7]); } else if (strcmp(tokens[6], "tmgr") == 0) { if (n_tokens != 8) { snprintf(out, out_size, MSG_ARG_MISMATCH, @@ -1976,7 +1975,7 @@ cmd_pipeline_port_out(struct pmd_internals *softnic, p.type = PORT_OUT_TMGR; - p.dev_name = tokens[7]; + strcpy(p.dev_name, tokens[7]); } else if (strcmp(tokens[6], "tap") == 0) { if (n_tokens != 8) { snprintf(out, out_size, MSG_ARG_MISMATCH, @@ -1986,7 +1985,7 @@ cmd_pipeline_port_out(struct pmd_internals *softnic, p.type = PORT_OUT_TAP; - p.dev_name = tokens[7]; + strcpy(p.dev_name, tokens[7]); } else if (strcmp(tokens[6], "sink") == 0) { if ((n_tokens != 7) && (n_tokens != 11)) { snprintf(out, out_size, MSG_ARG_MISMATCH, @@ -1996,8 +1995,6 @@ cmd_pipeline_port_out(struct pmd_internals *softnic, p.type = PORT_OUT_SINK; - p.dev_name = NULL; - if (n_tokens == 7) { p.sink.file_name = NULL; p.sink.max_n_pkts = 0; @@ -2064,12 +2061,13 @@ cmd_pipeline_table(struct pmd_internals *softnic, char *out, size_t out_size) { - uint8_t key_mask[TABLE_RULE_MATCH_SIZE_MAX]; struct softnic_table_params p; char *pipeline_name; uint32_t t0; int status; + memset(&p, 0, sizeof(p)); + if (n_tokens < 5) { snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); return; @@ -2203,12 +2201,11 @@ cmd_pipeline_table(struct pmd_internals *softnic, } if ((softnic_parse_hex_string(tokens[t0 + 5], - key_mask, &key_mask_size) != 0) || + p.match.hash.key_mask, &key_mask_size) != 0) || key_mask_size != p.match.hash.key_size) { snprintf(out, out_size, MSG_ARG_INVALID, "key_mask"); return; } - p.match.hash.key_mask = key_mask; if (strcmp(tokens[t0 + 6], "offset") != 0) { snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset"); @@ -2295,7 +2292,6 @@ cmd_pipeline_table(struct pmd_internals *softnic, return; } - p.action_profile_name = NULL; if (n_tokens > t0 && (strcmp(tokens[t0], "action") == 0)) { if (n_tokens < t0 + 2) { @@ -2303,7 +2299,7 @@ cmd_pipeline_table(struct pmd_internals *softnic, return; } - p.action_profile_name = tokens[t0 + 1]; + strcpy(p.action_profile_name, tokens[t0 + 1]); t0 += 2; } diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h b/drivers/net/softnic/rte_eth_softnic_internals.h index d1996c4699..f40215dfe3 100644 --- a/drivers/net/softnic/rte_eth_softnic_internals.h +++ b/drivers/net/softnic/rte_eth_softnic_internals.h @@ -308,7 +308,7 @@ enum softnic_port_in_type { struct softnic_port_in_params { /* Read */ enum softnic_port_in_type type; - const char *dev_name; + char dev_name[NAME_SIZE]; union { struct { uint16_t queue_id; @@ -328,7 +328,7 @@ struct softnic_port_in_params { uint32_t burst_size; /* Action */ - const char *action_profile_name; + char action_profile_name[NAME_SIZE]; }; enum softnic_port_out_type { @@ -341,7 +341,7 @@ enum softnic_port_out_type { struct softnic_port_out_params { enum softnic_port_out_type type; - const char *dev_name; + char dev_name[NAME_SIZE]; union { struct { uint16_t queue_id; @@ -376,11 +376,15 @@ struct softnic_table_array_params { uint32_t key_offset; }; +#ifndef TABLE_RULE_MATCH_SIZE_MAX +#define TABLE_RULE_MATCH_SIZE_MAX 256 +#endif + struct softnic_table_hash_params { uint32_t n_keys; uint32_t key_offset; uint32_t key_size; - uint8_t *key_mask; + uint8_t key_mask[TABLE_RULE_MATCH_SIZE_MAX]; uint32_t n_buckets; int extendable_bucket; }; @@ -402,7 +406,7 @@ struct softnic_table_params { } match; /* Action */ - const char *action_profile_name; + char action_profile_name[NAME_SIZE]; }; struct softnic_port_in { @@ -757,10 +761,6 @@ struct softnic_table_rule_match_array { uint32_t pos; }; -#ifndef TABLE_RULE_MATCH_SIZE_MAX -#define TABLE_RULE_MATCH_SIZE_MAX 256 -#endif - struct softnic_table_rule_match_hash { uint8_t key[TABLE_RULE_MATCH_SIZE_MAX]; }; diff --git a/drivers/net/softnic/rte_eth_softnic_pipeline.c b/drivers/net/softnic/rte_eth_softnic_pipeline.c index 0aababe9aa..db83dcced0 100644 --- a/drivers/net/softnic/rte_eth_softnic_pipeline.c +++ b/drivers/net/softnic/rte_eth_softnic_pipeline.c @@ -212,7 +212,7 @@ softnic_pipeline_port_in_create(struct pmd_internals *softnic, return -1; ap = NULL; - if (params->action_profile_name) { + if (strlen(params->action_profile_name)) { ap = softnic_port_in_action_profile_find(softnic, params->action_profile_name); if (ap == NULL) @@ -729,7 +729,7 @@ softnic_pipeline_table_create(struct pmd_internals *softnic, return -1; ap = NULL; - if (params->action_profile_name) { + if (strlen(params->action_profile_name)) { ap = softnic_table_action_profile_find(softnic, params->action_profile_name); if (ap == NULL)