DPDK patches and discussions
 help / color / mirror / Atom feed
From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net
Subject: [dpdk-dev] [PATCH 3/4] qos_meter: accommodate meter api changes
Date: Wed, 23 Aug 2017 12:36:25 +0100	[thread overview]
Message-ID: <1503488186-90047-4-git-send-email-cristian.dumitrescu@intel.com> (raw)
In-Reply-To: <1503488186-90047-1-git-send-email-cristian.dumitrescu@intel.com>

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 examples/qos_meter/main.c | 36 +++++++++++++++++++++++++-----------
 examples/qos_meter/main.h | 32 ++++++++++++++++++++------------
 2 files changed, 45 insertions(+), 23 deletions(-)

diff --git a/examples/qos_meter/main.c b/examples/qos_meter/main.c
index b0909f6..420ec5a 100644
--- a/examples/qos_meter/main.c
+++ b/examples/qos_meter/main.c
@@ -121,13 +121,15 @@ static uint8_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
 
@@ -136,12 +138,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 +177,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.7.4

  parent reply	other threads:[~2017-08-23 11:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-23 11:36 [dpdk-dev] [PATCH 0/4] meter: add meter configuration profile api Cristian Dumitrescu
2017-08-23 11:36 ` [dpdk-dev] [PATCH 1/4] meter: add meter configuration profile Cristian Dumitrescu
2017-12-12  9:53   ` [dpdk-dev] [PATCH v2 0/4] meter: add meter configuration profile api Jasvinder Singh
2017-12-12  9:53     ` [dpdk-dev] [PATCH v2 1/4] lib/librte_meter: add meter configuration profile Jasvinder Singh
2018-01-08 10:00       ` [dpdk-dev] [PATCH v3] meter: add meter configuration profile api Jasvinder Singh
2018-01-08 10:00         ` [dpdk-dev] [PATCH v3] lib/librte_meter: add meter configuration profile Jasvinder Singh
2018-01-08 15:43           ` [dpdk-dev] [PATCH v4] " Jasvinder Singh
2018-01-11 13:54             ` Dumitrescu, Cristian
2018-02-19 21:12             ` Thomas Monjalon
2018-04-05 10:12               ` Thomas Monjalon
2018-04-05 11:00                 ` Dumitrescu, Cristian
2017-12-12  9:53     ` [dpdk-dev] [PATCH v2 2/4] test/test_meter: update meter test Jasvinder Singh
2017-12-12  9:53     ` [dpdk-dev] [PATCH v2 3/4] examples/qos_meter: accommodate meter api changes Jasvinder Singh
2017-12-12  9:53     ` [dpdk-dev] [PATCH v2 4/4] examples/ip_pipeline: update flow action pipeline Jasvinder Singh
2017-08-23 11:36 ` [dpdk-dev] [PATCH 2/4] test: meter autotest update Cristian Dumitrescu
2017-08-23 11:36 ` Cristian Dumitrescu [this message]
2017-08-23 11:36 ` [dpdk-dev] [PATCH 4/4] deprecation: removed the librte_meter notice Cristian Dumitrescu
2017-10-12 20:51 ` [dpdk-dev] [PATCH 0/4] meter: add meter configuration profile api Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1503488186-90047-4-git-send-email-cristian.dumitrescu@intel.com \
    --to=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).