From patchwork Thu Mar 29 18:31:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jasvinder Singh X-Patchwork-Id: 36687 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 246F95B1C; Thu, 29 Mar 2018 20:32:27 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 14A2F34F0 for ; Thu, 29 Mar 2018 20:32:14 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Mar 2018 11:32:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,378,1517904000"; d="scan'208";a="216058836" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.222.149]) by fmsmga005.fm.intel.com with ESMTP; 29 Mar 2018 11:32:13 -0700 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com Date: Thu, 29 Mar 2018 19:31:23 +0100 Message-Id: <20180329183208.103844-5-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180329183208.103844-1-jasvinder.singh@intel.com> References: <20180316175906.159198-2-jasvinder.singh@intel.com> <20180329183208.103844-1-jasvinder.singh@intel.com> Subject: [dpdk-dev] [PATCH v4 04/49] pipeline: add traffic manager action 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" Add implementation of traffic manager action. Signed-off-by: Cristian Dumitrescu --- lib/librte_pipeline/Makefile | 2 +- lib/librte_pipeline/meson.build | 2 +- lib/librte_pipeline/rte_table_action.c | 130 ++++++++++++++++++++++++++++++++- lib/librte_pipeline/rte_table_action.h | 24 ++++++ 4 files changed, 155 insertions(+), 3 deletions(-) diff --git a/lib/librte_pipeline/Makefile b/lib/librte_pipeline/Makefile index 72e4c7c..c0eaa09 100644 --- a/lib/librte_pipeline/Makefile +++ b/lib/librte_pipeline/Makefile @@ -12,7 +12,7 @@ CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) LDLIBS += -lrte_eal -lrte_mempool -lrte_mbuf -lrte_table -LDLIBS += -lrte_port -lrte_meter +LDLIBS += -lrte_port -lrte_meter -lrte_sched EXPORT_MAP := rte_pipeline_version.map diff --git a/lib/librte_pipeline/meson.build b/lib/librte_pipeline/meson.build index 71da295..1ee276f 100644 --- a/lib/librte_pipeline/meson.build +++ b/lib/librte_pipeline/meson.build @@ -5,4 +5,4 @@ version = 3 allow_experimental_apis = true sources = files('rte_pipeline.c', 'rte_table_action.c') headers = files('rte_pipeline.h', 'rte_table_action.h') -deps += ['port', 'table', 'meter'] +deps += ['port', 'table', 'meter', 'sched'] diff --git a/lib/librte_pipeline/rte_table_action.c b/lib/librte_pipeline/rte_table_action.c index f3be28a..791fc20 100644 --- a/lib/librte_pipeline/rte_table_action.c +++ b/lib/librte_pipeline/rte_table_action.c @@ -297,6 +297,73 @@ pkt_work_mtr(struct rte_mbuf *mbuf, return drop_mask; } +/** + * RTE_TABLE_ACTION_TM + */ +static int +tm_cfg_check(struct rte_table_action_tm_config *tm) +{ + if ((tm->n_subports_per_port == 0) || + (rte_is_power_of_2(tm->n_subports_per_port) == 0) || + (tm->n_subports_per_port > UINT16_MAX) || + (tm->n_pipes_per_subport == 0) || + (rte_is_power_of_2(tm->n_pipes_per_subport) == 0)) + return -ENOTSUP; + + return 0; +} + +struct tm_data { + uint16_t queue_tc_color; + uint16_t subport; + uint32_t pipe; +} __attribute__((__packed__)); + +static int +tm_apply_check(struct rte_table_action_tm_params *p, + struct rte_table_action_tm_config *cfg) +{ + if ((p->subport_id >= cfg->n_subports_per_port) || + (p->pipe_id >= cfg->n_pipes_per_subport)) + return -EINVAL; + + return 0; +} + +static int +tm_apply(struct tm_data *data, + struct rte_table_action_tm_params *p, + struct rte_table_action_tm_config *cfg) +{ + int status; + + /* Check input arguments */ + status = tm_apply_check(p, cfg); + if (status) + return status; + + /* Apply */ + data->queue_tc_color = 0; + data->subport = (uint16_t) p->subport_id; + data->pipe = p->pipe_id; + + return 0; +} + +static __rte_always_inline void +pkt_work_tm(struct rte_mbuf *mbuf, + struct tm_data *data, + struct dscp_table_data *dscp_table, + uint32_t dscp) +{ + struct dscp_table_entry_data *dscp_entry = &dscp_table->entry[dscp]; + struct tm_data *sched_ptr = (struct tm_data *) &mbuf->hash.sched; + struct tm_data sched; + + sched = *data; + sched.queue_tc_color = dscp_entry->queue_tc_color; + *sched_ptr = sched; +} /** * Action profile @@ -307,6 +374,7 @@ action_valid(enum rte_table_action_type action) switch (action) { case RTE_TABLE_ACTION_FWD: case RTE_TABLE_ACTION_MTR: + case RTE_TABLE_ACTION_TM: return 1; default: return 0; @@ -320,6 +388,7 @@ struct ap_config { uint64_t action_mask; struct rte_table_action_common_config common; struct rte_table_action_mtr_config mtr; + struct rte_table_action_tm_config tm; }; static size_t @@ -328,6 +397,8 @@ action_cfg_size(enum rte_table_action_type action) switch (action) { case RTE_TABLE_ACTION_MTR: return sizeof(struct rte_table_action_mtr_config); + case RTE_TABLE_ACTION_TM: + return sizeof(struct rte_table_action_tm_config); default: return 0; } @@ -341,6 +412,9 @@ action_cfg_get(struct ap_config *ap_config, case RTE_TABLE_ACTION_MTR: return &ap_config->mtr; + case RTE_TABLE_ACTION_TM: + return &ap_config->tm; + default: return NULL; } @@ -375,6 +449,9 @@ action_data_size(enum rte_table_action_type action, case RTE_TABLE_ACTION_MTR: return mtr_data_size(&ap_config->mtr); + case RTE_TABLE_ACTION_TM: + return sizeof(struct tm_data); + default: return 0; } @@ -450,6 +527,10 @@ rte_table_action_profile_action_register(struct rte_table_action_profile *profil status = mtr_cfg_check(action_config); break; + case RTE_TABLE_ACTION_TM: + status = tm_cfg_check(action_config); + break; + default: status = 0; break; @@ -567,6 +648,11 @@ rte_table_action_apply(struct rte_table_action *action, action->mp, RTE_DIM(action->mp)); + case RTE_TABLE_ACTION_TM: + return tm_apply(action_data, + action_params, + &action->cfg.tm); + default: return -EINVAL; } @@ -581,7 +667,8 @@ rte_table_action_dscp_table_update(struct rte_table_action *action, /* Check input arguments */ if ((action == NULL) || - (action->cfg.action_mask & (1LLU << RTE_TABLE_ACTION_MTR)) || + ((action->cfg.action_mask & ((1LLU << RTE_TABLE_ACTION_MTR) | + (1LLU << RTE_TABLE_ACTION_TM))) == 0) || (dscp_mask == 0) || (table == NULL)) return -EINVAL; @@ -773,6 +860,16 @@ pkt_work(struct rte_mbuf *mbuf, total_length); } + if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_TM)) { + void *data = + action_data_get(table_entry, action, RTE_TABLE_ACTION_TM); + + pkt_work_tm(mbuf, + data, + &action->dscp_table, + dscp); + } + return drop_mask; } @@ -886,6 +983,37 @@ pkt4_work(struct rte_mbuf **mbufs, total_length3); } + if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_TM)) { + void *data0 = + action_data_get(table_entry0, action, RTE_TABLE_ACTION_TM); + void *data1 = + action_data_get(table_entry1, action, RTE_TABLE_ACTION_TM); + void *data2 = + action_data_get(table_entry2, action, RTE_TABLE_ACTION_TM); + void *data3 = + action_data_get(table_entry3, action, RTE_TABLE_ACTION_TM); + + pkt_work_tm(mbuf0, + data0, + &action->dscp_table, + dscp0); + + pkt_work_tm(mbuf1, + data1, + &action->dscp_table, + dscp1); + + pkt_work_tm(mbuf2, + data2, + &action->dscp_table, + dscp2); + + pkt_work_tm(mbuf3, + data3, + &action->dscp_table, + dscp3); + } + return drop_mask0 | (drop_mask1 << 1) | (drop_mask2 << 2) | diff --git a/lib/librte_pipeline/rte_table_action.h b/lib/librte_pipeline/rte_table_action.h index c2f4a55..98babc5 100644 --- a/lib/librte_pipeline/rte_table_action.h +++ b/lib/librte_pipeline/rte_table_action.h @@ -70,6 +70,9 @@ enum rte_table_action_type { /** Traffic Metering and Policing. */ RTE_TABLE_ACTION_MTR, + + /** Traffic Management. */ + RTE_TABLE_ACTION_TM, }; /** Common action configuration (per table action profile). */ @@ -256,6 +259,27 @@ struct rte_table_action_mtr_counters { }; /** + * RTE_TABLE_ACTION_TM + */ +/** Traffic management action configuration (per table action profile). */ +struct rte_table_action_tm_config { + /** Number of subports per port. */ + uint32_t n_subports_per_port; + + /** Number of pipes per subport. */ + uint32_t n_pipes_per_subport; +}; + +/** Traffic management action parameters (per table rule). */ +struct rte_table_action_tm_params { + /** Subport ID. */ + uint32_t subport_id; + + /** Pipe ID. */ + uint32_t pipe_id; +}; + +/** * Table action profile. */ struct rte_table_action_profile;