summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorCristian Dumitrescu <cristian.dumitrescu@intel.com>2018-10-30 18:09:35 +0000
committerCristian Dumitrescu <cristian.dumitrescu@intel.com>2018-11-02 12:25:12 +0100
commitc348ec0594765c5407e28d1a40e09ad624705cfd (patch)
tree65bccbbb6db361f59266e8adf70abb3beb465912 /examples
parent27b333b232372c37be2f228e71063504e949ba25 (diff)
downloaddpdk-c348ec0594765c5407e28d1a40e09ad624705cfd.zip
dpdk-c348ec0594765c5407e28d1a40e09ad624705cfd.tar.gz
dpdk-c348ec0594765c5407e28d1a40e09ad624705cfd.tar.xz
examples/ip_pipeline: track rules on add default
Support table rule tracking on table rule add default operation. Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com> Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/ip_pipeline/cli.c4
-rw-r--r--examples/ip_pipeline/pipeline.h3
-rw-r--r--examples/ip_pipeline/thread.c39
3 files changed, 31 insertions, 15 deletions
diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c
index 5011cad..54d347c 100644
--- a/examples/ip_pipeline/cli.c
+++ b/examples/ip_pipeline/cli.c
@@ -4407,7 +4407,6 @@ cmd_pipeline_table_rule_add_default(char **tokens,
size_t out_size)
{
struct table_rule_action action;
- void *data;
char *pipeline_name;
uint32_t table_id;
int status;
@@ -4513,8 +4512,7 @@ cmd_pipeline_table_rule_add_default(char **tokens,
status = pipeline_table_rule_add_default(pipeline_name,
table_id,
- &action,
- &data);
+ &action);
if (status) {
snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
return;
diff --git a/examples/ip_pipeline/pipeline.h b/examples/ip_pipeline/pipeline.h
index 8a364a9..15a38fd 100644
--- a/examples/ip_pipeline/pipeline.h
+++ b/examples/ip_pipeline/pipeline.h
@@ -341,8 +341,7 @@ pipeline_table_rule_add_bulk(const char *pipeline_name,
int
pipeline_table_rule_add_default(const char *pipeline_name,
uint32_t table_id,
- struct table_rule_action *action,
- void **data);
+ struct table_rule_action *action);
int
pipeline_table_rule_delete(const char *pipeline_name,
diff --git a/examples/ip_pipeline/thread.c b/examples/ip_pipeline/thread.c
index 2c0570f..d2daacc 100644
--- a/examples/ip_pipeline/thread.c
+++ b/examples/ip_pipeline/thread.c
@@ -1447,18 +1447,18 @@ pipeline_table_rule_add(const char *pipeline_name,
int
pipeline_table_rule_add_default(const char *pipeline_name,
uint32_t table_id,
- struct table_rule_action *action,
- void **data)
+ struct table_rule_action *action)
{
struct pipeline *p;
+ struct table *table;
struct pipeline_msg_req *req;
struct pipeline_msg_rsp *rsp;
+ struct table_rule *rule;
int status;
/* Check input params */
if ((pipeline_name == NULL) ||
- (action == NULL) ||
- (data == NULL))
+ (action == NULL))
return -1;
p = pipeline_find(pipeline_name);
@@ -1467,13 +1467,23 @@ pipeline_table_rule_add_default(const char *pipeline_name,
action_default_check(action, p, table_id))
return -1;
+ table = &p->table[table_id];
+
+ rule = calloc(1, sizeof(struct table_rule));
+ if (rule == NULL)
+ return -1;
+
+ memcpy(&rule->action, action, sizeof(*action));
+
if (!pipeline_is_running(p)) {
struct rte_pipeline_table_entry *data_in, *data_out;
uint8_t *buffer;
buffer = calloc(TABLE_RULE_ACTION_SIZE_MAX, sizeof(uint8_t));
- if (buffer == NULL)
+ if (buffer == NULL) {
+ free(rule);
return -1;
+ }
/* Apply actions */
data_in = (struct rte_pipeline_table_entry *)buffer;
@@ -1491,11 +1501,13 @@ pipeline_table_rule_add_default(const char *pipeline_name,
&data_out);
if (status) {
free(buffer);
+ free(rule);
return -1;
}
/* Write Response */
- *data = data_out;
+ rule->data = data_out;
+ table_rule_default_add(table, rule);
free(buffer);
return 0;
@@ -1503,8 +1515,10 @@ pipeline_table_rule_add_default(const char *pipeline_name,
/* Allocate request */
req = pipeline_msg_alloc();
- if (req == NULL)
+ if (req == NULL) {
+ free(rule);
return -1;
+ }
/* Write request */
req->type = PIPELINE_REQ_TABLE_RULE_ADD_DEFAULT;
@@ -1513,13 +1527,18 @@ pipeline_table_rule_add_default(const char *pipeline_name,
/* Send request and wait for response */
rsp = pipeline_msg_send_recv(p, req);
- if (rsp == NULL)
+ if (rsp == NULL) {
+ free(rule);
return -1;
+ }
/* Read response */
status = rsp->status;
- if (status == 0)
- *data = rsp->table_rule_add_default.data;
+ if (status == 0) {
+ rule->data = rsp->table_rule_add_default.data;
+ table_rule_default_add(table, rule);
+ } else
+ free(rule);
/* Free response */
pipeline_msg_free(rsp);