From: Reshma Pattan <reshma.pattan@intel.com>
To: dev@dpdk.org
Cc: Cristian Dumitrescu <cristian.dumitrescu@intel.com>,
Reshma Pattan <reshma.pattan@intel.com>
Subject: [dpdk-dev] [PATCH v2 04/15] net/softnic: replace some pointers with arrays
Date: Tue, 11 Sep 2018 15:20:34 +0100 [thread overview]
Message-ID: <1536675645-10105-5-git-send-email-reshma.pattan@intel.com> (raw)
In-Reply-To: <1536251222-17275-1-git-send-email-reshma.pattan@intel.com>
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 <cristian.dumitrescu@intel.com>
Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
---
drivers/net/softnic/rte_eth_softnic_cli.c | 34 +++++++++++--------------
drivers/net/softnic/rte_eth_softnic_internals.h | 18 ++++++-------
drivers/net/softnic/rte_eth_softnic_pipeline.c | 4 +--
3 files changed, 26 insertions(+), 30 deletions(-)
diff --git a/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c
index 8f5f82555..dc8ccdc73 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 d1996c469..f40215dfe 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 45136a4a2..dacf7bc9a 100644
--- a/drivers/net/softnic/rte_eth_softnic_pipeline.c
+++ b/drivers/net/softnic/rte_eth_softnic_pipeline.c
@@ -213,7 +213,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)
@@ -730,7 +730,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)
--
2.14.4
next prev parent reply other threads:[~2018-09-11 14:20 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-06 16:26 [dpdk-dev] [PATCH 00/15] add flow API support to softnic Reshma Pattan
2018-09-06 16:26 ` [dpdk-dev] [PATCH 01/15] net/softnic: add infrastructure for flow API Reshma Pattan
2018-09-06 16:26 ` [dpdk-dev] [PATCH 02/15] net/softnic: rte flow attr mapping to pipeline Reshma Pattan
2018-09-06 16:26 ` [dpdk-dev] [PATCH 03/15] net/softnic: add new cli for flow attribute map Reshma Pattan
2018-09-06 16:26 ` [dpdk-dev] [PATCH 04/15] net/softnic: various data type changes Reshma Pattan
2018-09-06 16:26 ` [dpdk-dev] [PATCH 05/15] net/softnic: add free table and find out port functions Reshma Pattan
2018-09-06 16:26 ` [dpdk-dev] [PATCH 06/15] net/softnic: add function to get eth device from softnic Reshma Pattan
2018-09-06 16:26 ` [dpdk-dev] [PATCH 07/15] net/softnic: flow API validate support Reshma Pattan
2018-09-06 16:26 ` [dpdk-dev] [PATCH 08/15] net/softnic: validate and map flow rule with acl table match Reshma Pattan
2018-09-06 16:26 ` [dpdk-dev] [PATCH 09/15] net/softnic: parse flow protocol for " Reshma Pattan
2018-09-06 16:26 ` [dpdk-dev] [PATCH 10/15] net/softnic: validate and map flow with hash " Reshma Pattan
2018-09-06 16:26 ` [dpdk-dev] [PATCH 11/15] net/softnic: validate and map flow action with table action Reshma Pattan
2018-09-06 16:26 ` [dpdk-dev] [PATCH 12/15] net/softnic: add flow create API Reshma Pattan
2018-09-06 16:27 ` [dpdk-dev] [PATCH 13/15] net/softnic: add flow destroy API Reshma Pattan
2018-09-06 16:27 ` [dpdk-dev] [PATCH 14/15] net/softnic: add flow query API Reshma Pattan
2018-09-06 16:27 ` [dpdk-dev] [PATCH 15/15] net/softnic: add parsing for raw flow item Reshma Pattan
2018-09-11 14:20 ` [dpdk-dev] [PATCH v2 00/15] add flow API support to softnic Reshma Pattan
2018-09-28 10:36 ` Dumitrescu, Cristian
2018-09-11 14:20 ` [dpdk-dev] [PATCH v2 01/15] net/softnic: add infrastructure for flow API Reshma Pattan
2018-09-11 14:20 ` [dpdk-dev] [PATCH v2 02/15] net/softnic: map flow attributes to pipeline table Reshma Pattan
2018-09-11 14:20 ` [dpdk-dev] [PATCH v2 03/15] net/softnic: add new cli for flow attribute map Reshma Pattan
2018-09-11 14:20 ` Reshma Pattan [this message]
2018-09-11 14:20 ` [dpdk-dev] [PATCH v2 05/15] net/softnic: add free table and find out port functions Reshma Pattan
2018-09-11 14:20 ` [dpdk-dev] [PATCH v2 06/15] net/softnic: add function to get eth device from softnic Reshma Pattan
2018-09-11 14:20 ` [dpdk-dev] [PATCH v2 07/15] net/softnic: implement flow validate API Reshma Pattan
2018-09-11 14:20 ` [dpdk-dev] [PATCH v2 08/15] net/softnic: validate and map flow rule with acl table match Reshma Pattan
2018-09-11 14:20 ` [dpdk-dev] [PATCH v2 09/15] net/softnic: parse flow protocol for " Reshma Pattan
2018-09-11 14:20 ` [dpdk-dev] [PATCH v2 10/15] net/softnic: validate and map flow with hash " Reshma Pattan
2018-09-11 14:20 ` [dpdk-dev] [PATCH v2 11/15] net/softnic: validate and map flow action with table action Reshma Pattan
2018-09-11 14:20 ` [dpdk-dev] [PATCH v2 12/15] net/softnic: add flow create API Reshma Pattan
2018-09-11 14:20 ` [dpdk-dev] [PATCH v2 13/15] net/softnic: add flow destroy API Reshma Pattan
2018-09-11 14:20 ` [dpdk-dev] [PATCH v2 14/15] net/softnic: add flow query API Reshma Pattan
2018-09-11 14:20 ` [dpdk-dev] [PATCH v2 15/15] net/softnic: add parsing for raw flow item Reshma Pattan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1536675645-10105-5-git-send-email-reshma.pattan@intel.com \
--to=reshma.pattan@intel.com \
--cc=cristian.dumitrescu@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).