From patchwork Fri Mar 9 18:23:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jasvinder Singh X-Patchwork-Id: 35883 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 E54817CBC; Fri, 9 Mar 2018 19:24:35 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id EBD135F27 for ; Fri, 9 Mar 2018 19:24:32 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2018 10:24:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,446,1515484800"; d="scan'208";a="181382196" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.222.149]) by orsmga004.jf.intel.com with ESMTP; 09 Mar 2018 10:24:31 -0800 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com Date: Fri, 9 Mar 2018 18:23:53 +0000 Message-Id: <20180309182426.135278-5-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180309182426.135278-1-jasvinder.singh@intel.com> References: <20180309182426.135278-1-jasvinder.singh@intel.com> Subject: [dpdk-dev] [PATCH 04/37] 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 b22bf80..09016d1 100644 --- a/lib/librte_pipeline/rte_table_action.c +++ b/lib/librte_pipeline/rte_table_action.c @@ -295,6 +295,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 @@ -305,6 +372,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; @@ -318,6 +386,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 @@ -326,6 +395,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; } @@ -339,6 +410,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; } @@ -373,6 +447,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; } @@ -447,6 +524,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; @@ -564,6 +645,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; } @@ -578,7 +664,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; @@ -770,6 +857,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; } @@ -883,6 +980,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;