From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 2A6067D52 for ; Tue, 12 Dec 2017 10:40:30 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Dec 2017 01:40:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,394,1508828400"; d="scan'208";a="2059778" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.222.149]) by orsmga007.jf.intel.com with ESMTP; 12 Dec 2017 01:40:29 -0800 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com Date: Tue, 12 Dec 2017 09:53:23 +0000 Message-Id: <20171212095324.35420-4-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20171212095324.35420-1-jasvinder.singh@intel.com> References: <1503488186-90047-2-git-send-email-cristian.dumitrescu@intel.com> <20171212095324.35420-1-jasvinder.singh@intel.com> Subject: [dpdk-dev] [PATCH v2 3/4] examples/qos_meter: accommodate meter api changes 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: , X-List-Received-Date: Tue, 12 Dec 2017 09:40:31 -0000 From: Cristian Dumitrescu Modify the sample application to adapt the api changes. Signed-off-by: Cristian Dumitrescu --- examples/qos_meter/main.c | 39 ++++++++++++++++++++++++++++++--------- examples/qos_meter/main.h | 32 ++++++++++++++++++++------------ 2 files changed, 50 insertions(+), 21 deletions(-) diff --git a/examples/qos_meter/main.c b/examples/qos_meter/main.c index 67b4a75..23908f0 100644 --- a/examples/qos_meter/main.c +++ b/examples/qos_meter/main.c @@ -121,14 +121,23 @@ static uint16_t port_tx; static struct rte_mbuf *pkts_rx[PKT_RX_BURST_MAX]; struct rte_eth_dev_tx_buffer *tx_buffer; -struct rte_meter_srtcm_params app_srtcm_params[] = { - {.cir = 1000000 * 46, .cbs = 2048, .ebs = 2048}, +struct rte_meter_srtcm_params app_srtcm_params = { + .cir = 1000000 * 46, + .cbs = 2048, + .ebs = 2048 }; -struct rte_meter_trtcm_params app_trtcm_params[] = { - {.cir = 1000000 * 46, .pir = 1500000 * 46, .cbs = 2048, .pbs = 2048}, +struct rte_meter_srtcm_profile app_srtcm_profile; + +struct rte_meter_trtcm_params app_trtcm_params = { + .cir = 1000000 * 46, + .pir = 1500000 * 46, + .cbs = 2048, + .pbs = 2048 }; +struct rte_meter_trtcm_profile app_trtcm_profile; + #define APP_FLOWS_MAX 256 FLOW_METER app_flows[APP_FLOWS_MAX]; @@ -136,12 +145,21 @@ FLOW_METER app_flows[APP_FLOWS_MAX]; static int app_configure_flow_table(void) { - uint32_t i, j; + uint32_t i; int ret; - for (i = 0, j = 0; i < APP_FLOWS_MAX; - i ++, j = (j + 1) % RTE_DIM(PARAMS)) { - ret = FUNC_CONFIG(&app_flows[i], &PARAMS[j]); + ret = rte_meter_srtcm_profile_config(&app_srtcm_profile, + &app_srtcm_params); + if (ret) + return ret; + + ret = rte_meter_trtcm_profile_config(&app_trtcm_profile, + &app_trtcm_params); + if (ret) + return ret; + + for (i = 0; i < APP_FLOWS_MAX; i++) { + ret = FUNC_CONFIG(&app_flows[i], &PROFILE); if (ret) return ret; } @@ -166,7 +184,10 @@ app_pkt_handle(struct rte_mbuf *pkt, uint64_t time) enum policer_action action; /* color input is not used for blind modes */ - output_color = (uint8_t) FUNC_METER(&app_flows[flow_id], time, pkt_len, + output_color = (uint8_t) FUNC_METER(&app_flows[flow_id], + &PROFILE, + time, + pkt_len, (enum rte_meter_color) input_color); /* Apply policing and set the output color */ diff --git a/examples/qos_meter/main.h b/examples/qos_meter/main.h index 54867dc..bff97a4 100644 --- a/examples/qos_meter/main.h +++ b/examples/qos_meter/main.h @@ -50,44 +50,52 @@ enum policer_action policer_table[e_RTE_METER_COLORS][e_RTE_METER_COLORS] = #if APP_MODE == APP_MODE_FWD -#define FUNC_METER(a,b,c,d) color, flow_id=flow_id, pkt_len=pkt_len, time=time +#define FUNC_METER(m, p, time, pkt_len, pkt_color) \ +({ \ + void *mp = m; \ + void *pp = p; \ + mp = mp; \ + pp = pp; \ + time = time; \ + pkt_len = pkt_len; \ + pkt_color; \ +}) #define FUNC_CONFIG(a, b) 0 -#define PARAMS app_srtcm_params #define FLOW_METER int +#define PROFILE app_srtcm_profile #elif APP_MODE == APP_MODE_SRTCM_COLOR_BLIND -#define FUNC_METER(a,b,c,d) rte_meter_srtcm_color_blind_check(a,b,c) +#define FUNC_METER(m, p, time, pkt_len, pkt_color) \ + rte_meter_srtcm_color_blind_check(m, p, time, pkt_len) #define FUNC_CONFIG rte_meter_srtcm_config -#define PARAMS app_srtcm_params #define FLOW_METER struct rte_meter_srtcm +#define PROFILE app_srtcm_profile #elif (APP_MODE == APP_MODE_SRTCM_COLOR_AWARE) #define FUNC_METER rte_meter_srtcm_color_aware_check #define FUNC_CONFIG rte_meter_srtcm_config -#define PARAMS app_srtcm_params #define FLOW_METER struct rte_meter_srtcm +#define PROFILE app_srtcm_profile #elif (APP_MODE == APP_MODE_TRTCM_COLOR_BLIND) -#define FUNC_METER(a,b,c,d) rte_meter_trtcm_color_blind_check(a,b,c) +#define FUNC_METER(m, p, time, pkt_len, pkt_color) \ + rte_meter_trtcm_color_blind_check(m, p, time, pkt_len) #define FUNC_CONFIG rte_meter_trtcm_config -#define PARAMS app_trtcm_params #define FLOW_METER struct rte_meter_trtcm +#define PROFILE app_trtcm_profile #elif (APP_MODE == APP_MODE_TRTCM_COLOR_AWARE) -#define FUNC_METER rte_meter_trtcm_color_aware_check +#define FUNC_METER rte_meter_trtcm_color_aware_check #define FUNC_CONFIG rte_meter_trtcm_config -#define PARAMS app_trtcm_params #define FLOW_METER struct rte_meter_trtcm +#define PROFILE app_trtcm_profile #else #error Invalid value for APP_MODE #endif - - - #endif /* _MAIN_H_ */ -- 2.9.3