From patchwork Fri Nov 2 11:36:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 47736 X-Patchwork-Delegate: cristian.dumitrescu@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D81E71B439; Fri, 2 Nov 2018 12:37:09 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 6B9B71B3FB for ; Fri, 2 Nov 2018 12:37:07 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Nov 2018 04:37:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,455,1534834800"; d="scan'208";a="105381767" Received: from silpixa00382658.ir.intel.com ([10.237.223.29]) by orsmga002.jf.intel.com with ESMTP; 02 Nov 2018 04:37:05 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: Jasvinder Singh , Hongjun Ni Date: Fri, 2 Nov 2018 11:36:53 +0000 Message-Id: <1541158623-29742-2-git-send-email-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541158623-29742-1-git-send-email-cristian.dumitrescu@intel.com> References: <1541158623-29742-1-git-send-email-cristian.dumitrescu@intel.com> Subject: [dpdk-dev] [PATCH 02/12] examples/ip_pipeline: track table rules on add 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Support table rule tracking on table rule add operation. Signed-off-by: Cristian Dumitrescu Signed-off-by: Jasvinder Singh Signed-off-by: Hongjun Ni --- examples/ip_pipeline/cli.c | 4 +--- examples/ip_pipeline/pipeline.h | 3 +-- examples/ip_pipeline/thread.c | 45 ++++++++++++++++++++++++++++++----------- 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c index d1e5540..65600b7 100644 --- a/examples/ip_pipeline/cli.c +++ b/examples/ip_pipeline/cli.c @@ -4321,7 +4321,6 @@ cmd_pipeline_table_rule_add(char **tokens, struct table_rule_match m; struct table_rule_action a; char *pipeline_name; - void *data; uint32_t table_id, t0, n_tokens_parsed; int status; @@ -4379,8 +4378,7 @@ cmd_pipeline_table_rule_add(char **tokens, return; } - status = pipeline_table_rule_add(pipeline_name, table_id, - &m, &a, &data); + status = pipeline_table_rule_add(pipeline_name, table_id, &m, &a); 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 2034504..58067ed 100644 --- a/examples/ip_pipeline/pipeline.h +++ b/examples/ip_pipeline/pipeline.h @@ -329,8 +329,7 @@ int pipeline_table_rule_add(const char *pipeline_name, uint32_t table_id, struct table_rule_match *match, - struct table_rule_action *action, - void **data); + struct table_rule_action *action); int pipeline_table_rule_add_bulk(const char *pipeline_name, diff --git a/examples/ip_pipeline/thread.c b/examples/ip_pipeline/thread.c index 4bd971f..5019de9 100644 --- a/examples/ip_pipeline/thread.c +++ b/examples/ip_pipeline/thread.c @@ -1210,19 +1210,19 @@ int pipeline_table_rule_add(const char *pipeline_name, uint32_t table_id, struct table_rule_match *match, - 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) || (match == NULL) || - (action == NULL) || - (data == NULL)) + (action == NULL)) return -1; p = pipeline_find(pipeline_name); @@ -1232,16 +1232,26 @@ pipeline_table_rule_add(const char *pipeline_name, action_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->match, match, sizeof(*match)); + memcpy(&rule->action, action, sizeof(*action)); + if (!pipeline_is_running(p)) { - struct rte_table_action *a = p->table[table_id].a; union table_rule_match_low_level match_ll; struct rte_pipeline_table_entry *data_in, *data_out; int key_found; uint8_t *buffer; buffer = calloc(TABLE_RULE_ACTION_SIZE_MAX, sizeof(uint8_t)); - if (buffer == NULL) + if (buffer == NULL) { + free(rule); return -1; + } /* Table match-action rule conversion */ data_in = (struct rte_pipeline_table_entry *)buffer; @@ -1249,12 +1259,14 @@ pipeline_table_rule_add(const char *pipeline_name, status = match_convert(match, &match_ll, 1); if (status) { free(buffer); + free(rule); return -1; } - status = action_convert(a, action, data_in); + status = action_convert(table->a, action, data_in); if (status) { free(buffer); + free(rule); return -1; } @@ -1267,11 +1279,13 @@ pipeline_table_rule_add(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_add(table, rule); free(buffer); return 0; @@ -1279,8 +1293,10 @@ pipeline_table_rule_add(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; @@ -1290,13 +1306,18 @@ pipeline_table_rule_add(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.data; + if (status == 0) { + rule->data = rsp->table_rule_add.data; + table_rule_add(table, rule); + } else + free(rule); /* Free response */ pipeline_msg_free(rsp);