DPDK patches and discussions
 help / color / mirror / Atom feed
From: Reshma Pattan <reshma.pattan@intel.com>
To: dev@dpdk.org, cristian.dumitrescu@intel.com,
	jerin.jacob@caviumnetworks.com, jasvinder.singh@intel.com
Cc: Reshma Pattan <reshma.pattan@intel.com>
Subject: [dpdk-dev] [PATCH v2 2/3] eal: add new rte color definition
Date: Fri,  7 Dec 2018 14:31:55 +0000	[thread overview]
Message-ID: <1544193116-7058-2-git-send-email-reshma.pattan@intel.com> (raw)
In-Reply-To: <20181123165423.134922-1-jasvinder.singh@intel.com>

Added new rte_color definition in eal to
consolidate color definition which is currently replicated
in various places such as rte_meter.h, rte_tm.h and rte_mtr.h

Removed rte_tm_color and rte_mtr_color and used the new color
definition in rte_tm* and rte_mtr* files.

Updated softnic and testpmd to use new color definition.

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
---
 app/test-pmd/cmdline_mtr.c                  | 47 +++++++++++----------
 app/test-pmd/cmdline_tm.c                   | 23 +++++-----
 drivers/net/softnic/rte_eth_softnic_flow.c  | 10 +++--
 drivers/net/softnic/rte_eth_softnic_meter.c | 28 ++++++------
 drivers/net/softnic/rte_eth_softnic_tm.c    | 31 ++++++++------
 lib/librte_eal/common/Makefile              |  2 +-
 lib/librte_eal/common/include/rte_color.h   | 18 ++++++++
 lib/librte_ethdev/rte_mtr.c                 |  2 +-
 lib/librte_ethdev/rte_mtr.h                 | 21 +++------
 lib/librte_ethdev/rte_mtr_driver.h          |  2 +-
 lib/librte_ethdev/rte_tm.h                  | 25 ++++-------
 lib/librte_meter/rte_meter.h                |  7 +++
 12 files changed, 118 insertions(+), 98 deletions(-)
 create mode 100644 lib/librte_eal/common/include/rte_color.h

diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c
index c506d87ee..3d7861d14 100644
--- a/app/test-pmd/cmdline_mtr.c
+++ b/app/test-pmd/cmdline_mtr.c
@@ -9,6 +9,7 @@
 #include <rte_ethdev.h>
 #include <rte_flow.h>
 #include <rte_mtr.h>
+#include <rte_color.h>
 
 #include "testpmd.h"
 #include "cmdline_mtr.h"
@@ -74,7 +75,7 @@ parse_uint(uint64_t *value, const char *str)
 }
 
 static int
-parse_dscp_table_entries(char *str, enum rte_mtr_color **dscp_table)
+parse_dscp_table_entries(char *str, enum rte_color **dscp_table)
 {
 	char *token;
 	int i = 0;
@@ -84,21 +85,21 @@ parse_dscp_table_entries(char *str, enum rte_mtr_color **dscp_table)
 		return 0;
 
 	/* Allocate memory for dscp table */
-	*dscp_table = (enum rte_mtr_color *)malloc(MAX_DSCP_TABLE_ENTRIES *
-		sizeof(enum rte_mtr_color));
+	*dscp_table = (enum rte_color *)malloc(MAX_DSCP_TABLE_ENTRIES *
+		sizeof(enum rte_color));
 	if (*dscp_table == NULL)
 		return -1;
 
 	while (1) {
 		if (strcmp(token, "G") == 0 ||
 			strcmp(token, "g") == 0)
-			*dscp_table[i++] = RTE_MTR_GREEN;
+			*dscp_table[i++] = RTE_COLOR_GREEN;
 		else if (strcmp(token, "Y") == 0 ||
 			strcmp(token, "y") == 0)
-			*dscp_table[i++] = RTE_MTR_YELLOW;
+			*dscp_table[i++] = RTE_COLOR_YELLOW;
 		else if (strcmp(token, "R") == 0 ||
 			strcmp(token, "r") == 0)
-			*dscp_table[i++] = RTE_MTR_RED;
+			*dscp_table[i++] = RTE_COLOR_RED;
 		else {
 			free(*dscp_table);
 			return -1;
@@ -117,7 +118,7 @@ parse_dscp_table_entries(char *str, enum rte_mtr_color **dscp_table)
 
 static int
 parse_meter_color_str(char *c_str, uint32_t *use_prev_meter_color,
-	enum rte_mtr_color **dscp_table)
+	enum rte_color **dscp_table)
 {
 	char *token;
 	uint64_t previous_mtr_color = 0;
@@ -182,20 +183,20 @@ parse_policer_action_string(char *p_str, uint32_t action_mask,
 			return -1;
 
 		if (g_color == 0 && (action_mask & 0x1)) {
-			actions[RTE_MTR_GREEN] = action;
+			actions[RTE_COLOR_GREEN] = action;
 			g_color = 1;
 		} else if (y_color == 0 && (action_mask & 0x2)) {
-			actions[RTE_MTR_YELLOW] = action;
+			actions[RTE_COLOR_YELLOW] = action;
 			y_color = 1;
 		} else
-			actions[RTE_MTR_RED] = action;
+			actions[RTE_COLOR_RED] = action;
 	}
 	return 0;
 }
 
 static int
 parse_multi_token_string(char *t_str, uint16_t *port_id,
-	uint32_t *mtr_id, enum rte_mtr_color **dscp_table)
+	uint32_t *mtr_id, enum rte_color **dscp_table)
 {
 	char *token;
 	uint64_t val;
@@ -782,7 +783,7 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
 	uint32_t shared = res->shared;
 	uint32_t use_prev_meter_color = 0;
 	uint16_t port_id = res->port_id;
-	enum rte_mtr_color *dscp_table = NULL;
+	enum rte_color *dscp_table = NULL;
 	char *c_str = res->meter_input_color;
 	int ret;
 
@@ -808,11 +809,11 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
 	else
 		params.meter_enable = 0;
 
-	params.action[RTE_MTR_GREEN] =
+	params.action[RTE_COLOR_GREEN] =
 		string_to_policer_action(res->g_action);
-	params.action[RTE_MTR_YELLOW] =
+	params.action[RTE_COLOR_YELLOW] =
 		string_to_policer_action(res->y_action);
-	params.action[RTE_MTR_RED] =
+	params.action[RTE_COLOR_RED] =
 		string_to_policer_action(res->r_action);
 	params.stats_mask = res->statistics_mask;
 
@@ -1134,7 +1135,7 @@ static void cmd_set_port_meter_dscp_table_parsed(void *parsed_result,
 {
 	struct cmd_set_port_meter_dscp_table_result *res = parsed_result;
 	struct rte_mtr_error error;
-	enum rte_mtr_color *dscp_table = NULL;
+	enum rte_color *dscp_table = NULL;
 	char *t_str = res->token_string;
 	uint32_t mtr_id = 0;
 	uint16_t port_id;
@@ -1245,7 +1246,7 @@ static void cmd_set_port_meter_policer_action_parsed(void *parsed_result,
 	}
 
 	/* Allocate memory for policer actions */
-	actions = (enum rte_mtr_policer_action *)malloc(RTE_MTR_COLORS *
+	actions = (enum rte_mtr_policer_action *)malloc(RTE_COLORS *
 		sizeof(enum rte_mtr_policer_action));
 	if (actions == NULL) {
 		printf("Memory for policer actions not allocated (error)\n");
@@ -1426,22 +1427,22 @@ static void cmd_show_port_meter_stats_parsed(void *parsed_result,
 	/* Display stats */
 	if (stats_mask & RTE_MTR_STATS_N_PKTS_GREEN)
 		printf("\tPkts G: %" PRIu64 "\n",
-			stats.n_pkts[RTE_MTR_GREEN]);
+			stats.n_pkts[RTE_COLOR_GREEN]);
 	if (stats_mask & RTE_MTR_STATS_N_BYTES_GREEN)
 		printf("\tBytes G: %" PRIu64 "\n",
-			stats.n_bytes[RTE_MTR_GREEN]);
+			stats.n_bytes[RTE_COLOR_GREEN]);
 	if (stats_mask & RTE_MTR_STATS_N_PKTS_YELLOW)
 		printf("\tPkts Y: %" PRIu64 "\n",
-			stats.n_pkts[RTE_MTR_YELLOW]);
+			stats.n_pkts[RTE_COLOR_YELLOW]);
 	if (stats_mask & RTE_MTR_STATS_N_BYTES_YELLOW)
 		printf("\tBytes Y: %" PRIu64 "\n",
-			stats.n_bytes[RTE_MTR_YELLOW]);
+			stats.n_bytes[RTE_COLOR_YELLOW]);
 	if (stats_mask & RTE_MTR_STATS_N_PKTS_RED)
 		printf("\tPkts R: %" PRIu64 "\n",
-			stats.n_pkts[RTE_MTR_RED]);
+			stats.n_pkts[RTE_COLOR_RED]);
 	if (stats_mask & RTE_MTR_STATS_N_BYTES_RED)
 		printf("\tBytes R: %" PRIu64 "\n",
-			stats.n_bytes[RTE_MTR_RED]);
+			stats.n_bytes[RTE_COLOR_RED]);
 	if (stats_mask & RTE_MTR_STATS_N_PKTS_DROPPED)
 		printf("\tPkts DROPPED: %" PRIu64 "\n",
 			stats.n_pkts_dropped);
diff --git a/app/test-pmd/cmdline_tm.c b/app/test-pmd/cmdline_tm.c
index 4c763482a..753ea2c99 100644
--- a/app/test-pmd/cmdline_tm.c
+++ b/app/test-pmd/cmdline_tm.c
@@ -9,6 +9,7 @@
 #include <rte_ethdev.h>
 #include <rte_flow.h>
 #include <rte_tm.h>
+#include <rte_color.h>
 
 #include "testpmd.h"
 #include "cmdline_tm.h"
@@ -296,7 +297,7 @@ static void cmd_show_port_tm_cap_parsed(void *parsed_result,
 	printf("cap.cman_wred_context_shared_n_contexts_per_node_max %" PRIu32
 		"\n", cap.cman_wred_context_shared_n_contexts_per_node_max);
 
-	for (i = 0; i < RTE_TM_COLORS; i++) {
+	for (i = 0; i < RTE_COLORS; i++) {
 		printf("cap.mark_vlan_dei_supported %" PRId32 "\n",
 			cap.mark_vlan_dei_supported[i]);
 		printf("cap.mark_ip_ecn_tcp_supported %" PRId32 "\n",
@@ -642,22 +643,22 @@ static void cmd_show_port_tm_node_stats_parsed(void *parsed_result,
 			stats.n_bytes);
 	if (stats_mask & RTE_TM_STATS_N_PKTS_GREEN_DROPPED)
 		printf("\tPkts dropped (green): %" PRIu64 "\n",
-			stats.leaf.n_pkts_dropped[RTE_TM_GREEN]);
+			stats.leaf.n_pkts_dropped[RTE_COLOR_GREEN]);
 	if (stats_mask & RTE_TM_STATS_N_PKTS_YELLOW_DROPPED)
 		printf("\tPkts dropped (yellow): %" PRIu64 "\n",
-			stats.leaf.n_pkts_dropped[RTE_TM_YELLOW]);
+			stats.leaf.n_pkts_dropped[RTE_COLOR_YELLOW]);
 	if (stats_mask & RTE_TM_STATS_N_PKTS_RED_DROPPED)
 		printf("\tPkts dropped (red): %" PRIu64 "\n",
-			stats.leaf.n_pkts_dropped[RTE_TM_RED]);
+			stats.leaf.n_pkts_dropped[RTE_COLOR_RED]);
 	if (stats_mask & RTE_TM_STATS_N_BYTES_GREEN_DROPPED)
 		printf("\tBytes dropped (green): %" PRIu64 "\n",
-			stats.leaf.n_bytes_dropped[RTE_TM_GREEN]);
+			stats.leaf.n_bytes_dropped[RTE_COLOR_GREEN]);
 	if (stats_mask & RTE_TM_STATS_N_BYTES_YELLOW_DROPPED)
 		printf("\tBytes dropped (yellow): %" PRIu64 "\n",
-			stats.leaf.n_bytes_dropped[RTE_TM_YELLOW]);
+			stats.leaf.n_bytes_dropped[RTE_COLOR_YELLOW]);
 	if (stats_mask & RTE_TM_STATS_N_BYTES_RED_DROPPED)
 		printf("\tBytes dropped (red): %" PRIu64 "\n",
-			stats.leaf.n_bytes_dropped[RTE_TM_RED]);
+			stats.leaf.n_bytes_dropped[RTE_COLOR_RED]);
 	if (stats_mask & RTE_TM_STATS_N_PKTS_QUEUED)
 		printf("\tPkts queued: %" PRIu64 "\n",
 			stats.leaf.n_pkts_queued);
@@ -1267,7 +1268,7 @@ static void cmd_add_port_tm_node_wred_profile_parsed(void *parsed_result,
 {
 	struct cmd_add_port_tm_node_wred_profile_result *res = parsed_result;
 	struct rte_tm_wred_params wp;
-	enum rte_tm_color color;
+	enum rte_color color;
 	struct rte_tm_error error;
 	uint32_t wred_profile_id = res->wred_profile_id;
 	portid_t port_id = res->port_id;
@@ -1280,7 +1281,7 @@ static void cmd_add_port_tm_node_wred_profile_parsed(void *parsed_result,
 	memset(&error, 0, sizeof(struct rte_tm_error));
 
 	/* WRED Params  (Green Color)*/
-	color = RTE_TM_GREEN;
+	color = RTE_COLOR_GREEN;
 	wp.red_params[color].min_th = res->min_th_g;
 	wp.red_params[color].max_th = res->max_th_g;
 	wp.red_params[color].maxp_inv = res->maxp_inv_g;
@@ -1288,14 +1289,14 @@ static void cmd_add_port_tm_node_wred_profile_parsed(void *parsed_result,
 
 
 	/* WRED Params  (Yellow Color)*/
-	color = RTE_TM_YELLOW;
+	color = RTE_COLOR_YELLOW;
 	wp.red_params[color].min_th = res->min_th_y;
 	wp.red_params[color].max_th = res->max_th_y;
 	wp.red_params[color].maxp_inv = res->maxp_inv_y;
 	wp.red_params[color].wq_log2 = res->wq_log2_y;
 
 	/* WRED Params  (Red Color)*/
-	color = RTE_TM_RED;
+	color = RTE_COLOR_RED;
 	wp.red_params[color].min_th = res->min_th_r;
 	wp.red_params[color].max_th = res->max_th_r;
 	wp.red_params[color].maxp_inv = res->maxp_inv_r;
diff --git a/drivers/net/softnic/rte_eth_softnic_flow.c b/drivers/net/softnic/rte_eth_softnic_flow.c
index 21e753001..1a4322fef 100644
--- a/drivers/net/softnic/rte_eth_softnic_flow.c
+++ b/drivers/net/softnic/rte_eth_softnic_flow.c
@@ -12,6 +12,7 @@
 #include <rte_flow.h>
 #include <rte_flow_driver.h>
 #include <rte_tailq.h>
+#include <rte_color.h>
 
 #include "rte_eth_softnic_internals.h"
 #include "rte_eth_softnic.h"
@@ -1624,11 +1625,14 @@ flow_rule_action_get(struct pmd_internals *softnic,
 			/* RTE_TABLE_ACTION_METER */
 			rule_action->mtr.mtr[0].meter_profile_id = meter_profile_id;
 			rule_action->mtr.mtr[0].policer[e_RTE_METER_GREEN] =
-				softnic_table_action_policer(m->params.action[RTE_MTR_GREEN]);
+				softnic_table_action_policer
+				(m->params.action[RTE_COLOR_GREEN]);
 			rule_action->mtr.mtr[0].policer[e_RTE_METER_YELLOW] =
-				softnic_table_action_policer(m->params.action[RTE_MTR_YELLOW]);
+				softnic_table_action_policer
+				(m->params.action[RTE_COLOR_YELLOW]);
 			rule_action->mtr.mtr[0].policer[e_RTE_METER_RED] =
-				softnic_table_action_policer(m->params.action[RTE_MTR_RED]);
+				softnic_table_action_policer
+				(m->params.action[RTE_COLOR_RED]);
 			rule_action->mtr.tc_mask = 1;
 			rule_action->action_mask |= 1 << RTE_TABLE_ACTION_MTR;
 			break;
diff --git a/drivers/net/softnic/rte_eth_softnic_meter.c b/drivers/net/softnic/rte_eth_softnic_meter.c
index 7b747ba5d..3a0ec84b1 100644
--- a/drivers/net/softnic/rte_eth_softnic_meter.c
+++ b/drivers/net/softnic/rte_eth_softnic_meter.c
@@ -8,6 +8,7 @@
 
 #include <rte_mtr.h>
 #include <rte_mtr_driver.h>
+#include <rte_color.h>
 
 #include "rte_eth_softnic_internals.h"
 
@@ -458,7 +459,7 @@ pmd_mtr_meter_profile_update(struct rte_eth_dev *dev,
 static int
 pmd_mtr_meter_dscp_table_update(struct rte_eth_dev *dev,
 	uint32_t mtr_id,
-	enum rte_mtr_color *dscp_table,
+	enum rte_color *dscp_table,
 	struct rte_mtr_error *error)
 {
 	struct pmd_internals *p = dev->data->dev_private;
@@ -536,7 +537,7 @@ pmd_mtr_policer_actions_update(struct rte_eth_dev *dev,
 			NULL,
 			"Invalid actions");
 
-	for (i = 0; i < RTE_MTR_COLORS; i++) {
+	for (i = 0; i < RTE_COLORS; i++) {
 		if (action_mask & (1 << i)) {
 			if (actions[i] != MTR_POLICER_ACTION_COLOR_GREEN  &&
 				actions[i] != MTR_POLICER_ACTION_COLOR_YELLOW &&
@@ -560,7 +561,7 @@ pmd_mtr_policer_actions_update(struct rte_eth_dev *dev,
 		memcpy(&action, &m->flow->action, sizeof(action));
 
 		/* Set action */
-		for (i = 0; i < RTE_MTR_COLORS; i++)
+		for (i = 0; i < RTE_COLORS; i++)
 			if (action_mask & (1 << i))
 				action.mtr.mtr[0].policer[i] =
 					softnic_table_action_policer(actions[i]);
@@ -588,7 +589,7 @@ pmd_mtr_policer_actions_update(struct rte_eth_dev *dev,
 	}
 
 	/* Meter: Update policer actions */
-	for (i = 0; i < RTE_MTR_COLORS; i++)
+	for (i = 0; i < RTE_COLORS; i++)
 		if (action_mask & (1 << i))
 			m->params.action[i] = actions[i];
 
@@ -618,15 +619,17 @@ mtr_stats_convert(struct softnic_mtr *m,
 	if (in->n_packets_valid) {
 		uint32_t i;
 
-		for (i = 0; i < RTE_MTR_COLORS; i++) {
+		for (i = 0; i < RTE_COLORS; i++) {
 			if (m->params.action[i] == MTR_POLICER_ACTION_COLOR_GREEN)
-				out->n_pkts[RTE_MTR_GREEN] += in->n_packets[i];
+				out->n_pkts[RTE_COLOR_GREEN] +=
+							in->n_packets[i];
 
 			if (m->params.action[i] == MTR_POLICER_ACTION_COLOR_YELLOW)
-				out->n_pkts[RTE_MTR_YELLOW] += in->n_packets[i];
+				out->n_pkts[RTE_COLOR_YELLOW] +=
+						in->n_packets[i];
 
 			if (m->params.action[i] == MTR_POLICER_ACTION_COLOR_RED)
-				out->n_pkts[RTE_MTR_RED] += in->n_packets[i];
+				out->n_pkts[RTE_COLOR_RED] += in->n_packets[i];
 
 			if (m->params.action[i] == MTR_POLICER_ACTION_DROP)
 				out->n_pkts_dropped += in->n_packets[i];
@@ -638,15 +641,16 @@ mtr_stats_convert(struct softnic_mtr *m,
 	if (in->n_bytes_valid) {
 		uint32_t i;
 
-		for (i = 0; i < RTE_MTR_COLORS; i++) {
+		for (i = 0; i < RTE_COLORS; i++) {
 			if (m->params.action[i] == MTR_POLICER_ACTION_COLOR_GREEN)
-				out->n_bytes[RTE_MTR_GREEN] += in->n_bytes[i];
+				out->n_bytes[RTE_COLOR_GREEN] += in->n_bytes[i];
 
 			if (m->params.action[i] == MTR_POLICER_ACTION_COLOR_YELLOW)
-				out->n_bytes[RTE_MTR_YELLOW] += in->n_bytes[i];
+				out->n_bytes[RTE_COLOR_YELLOW] +=
+						in->n_bytes[i];
 
 			if (m->params.action[i] == MTR_POLICER_ACTION_COLOR_RED)
-				out->n_bytes[RTE_MTR_RED] += in->n_bytes[i];
+				out->n_bytes[RTE_COLOR_RED] += in->n_bytes[i];
 
 			if (m->params.action[i] == MTR_POLICER_ACTION_DROP)
 				out->n_bytes_dropped += in->n_bytes[i];
diff --git a/drivers/net/softnic/rte_eth_softnic_tm.c b/drivers/net/softnic/rte_eth_softnic_tm.c
index baaafbe29..e1012ac3d 100644
--- a/drivers/net/softnic/rte_eth_softnic_tm.c
+++ b/drivers/net/softnic/rte_eth_softnic_tm.c
@@ -8,6 +8,7 @@
 
 #include <rte_malloc.h>
 #include <rte_string_fns.h>
+#include <rte_color.h>
 
 #include "rte_eth_softnic_internals.h"
 #include "rte_eth_softnic.h"
@@ -1204,7 +1205,7 @@ wred_profile_check(struct rte_eth_dev *dev,
 	struct rte_tm_error *error)
 {
 	struct tm_wred_profile *wp;
-	enum rte_tm_color color;
+	enum rte_color color;
 
 	/* WRED profile ID must not be NONE. */
 	if (wred_profile_id == RTE_TM_WRED_PROFILE_ID_NONE)
@@ -1240,7 +1241,7 @@ wred_profile_check(struct rte_eth_dev *dev,
                         rte_strerror(ENOTSUP));
 
 	/* min_th <= max_th, max_th > 0  */
-	for (color = RTE_TM_GREEN; color < RTE_TM_COLORS; color++) {
+	for (color = RTE_COLOR_GREEN; color < RTE_COLORS; color++) {
 		uint32_t min_th = profile->red_params[color].min_th;
 		uint32_t max_th = profile->red_params[color].max_th;
 
@@ -2218,10 +2219,10 @@ wred_profiles_set(struct rte_eth_dev *dev)
 	struct pmd_internals *p = dev->data->dev_private;
 	struct rte_sched_port_params *pp = &p->soft.tm.params.port_params;
 	uint32_t tc_id;
-	enum rte_tm_color color;
+	enum rte_color color;
 
 	for (tc_id = 0; tc_id < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; tc_id++)
-		for (color = RTE_TM_GREEN; color < RTE_TM_COLORS; color++) {
+		for (color = RTE_COLOR_GREEN; color < RTE_COLORS; color++) {
 			struct rte_red_params *dst =
 				&pp->red_params[tc_id][color];
 			struct tm_wred_profile *src_wp =
@@ -3058,9 +3059,9 @@ read_port_stats(struct rte_eth_dev *dev,
 				s.n_pkts_tc[id] - s.n_pkts_tc_dropped[id];
 			nr->stats.n_bytes +=
 				s.n_bytes_tc[id] - s.n_bytes_tc_dropped[id];
-			nr->stats.leaf.n_pkts_dropped[RTE_TM_GREEN] +=
+			nr->stats.leaf.n_pkts_dropped[RTE_COLOR_GREEN] +=
 				s.n_pkts_tc_dropped[id];
-			nr->stats.leaf.n_bytes_dropped[RTE_TM_GREEN] +=
+			nr->stats.leaf.n_bytes_dropped[RTE_COLOR_GREEN] +=
 				s.n_bytes_tc_dropped[id];
 		}
 	}
@@ -3105,9 +3106,9 @@ read_subport_stats(struct rte_eth_dev *dev,
 			s.n_pkts_tc[tc_id] - s.n_pkts_tc_dropped[tc_id];
 		ns->stats.n_bytes +=
 			s.n_bytes_tc[tc_id] - s.n_bytes_tc_dropped[tc_id];
-		ns->stats.leaf.n_pkts_dropped[RTE_TM_GREEN] +=
+		ns->stats.leaf.n_pkts_dropped[RTE_COLOR_GREEN] +=
 			s.n_pkts_tc_dropped[tc_id];
-		ns->stats.leaf.n_bytes_dropped[RTE_TM_GREEN] +=
+		ns->stats.leaf.n_bytes_dropped[RTE_COLOR_GREEN] +=
 			s.n_bytes_tc_dropped[tc_id];
 	}
 
@@ -3162,8 +3163,9 @@ read_pipe_stats(struct rte_eth_dev *dev,
 		/* Stats accumulate */
 		np->stats.n_pkts += s.n_pkts - s.n_pkts_dropped;
 		np->stats.n_bytes += s.n_bytes - s.n_bytes_dropped;
-		np->stats.leaf.n_pkts_dropped[RTE_TM_GREEN] += s.n_pkts_dropped;
-		np->stats.leaf.n_bytes_dropped[RTE_TM_GREEN] +=
+		np->stats.leaf.n_pkts_dropped[RTE_COLOR_GREEN] +=
+			s.n_pkts_dropped;
+		np->stats.leaf.n_bytes_dropped[RTE_COLOR_GREEN] +=
 			s.n_bytes_dropped;
 		np->stats.leaf.n_pkts_queued = qlen;
 	}
@@ -3222,8 +3224,9 @@ read_tc_stats(struct rte_eth_dev *dev,
 		/* Stats accumulate */
 		nt->stats.n_pkts += s.n_pkts - s.n_pkts_dropped;
 		nt->stats.n_bytes += s.n_bytes - s.n_bytes_dropped;
-		nt->stats.leaf.n_pkts_dropped[RTE_TM_GREEN] += s.n_pkts_dropped;
-		nt->stats.leaf.n_bytes_dropped[RTE_TM_GREEN] +=
+		nt->stats.leaf.n_pkts_dropped[RTE_COLOR_GREEN] +=
+			s.n_pkts_dropped;
+		nt->stats.leaf.n_bytes_dropped[RTE_COLOR_GREEN] +=
 			s.n_bytes_dropped;
 		nt->stats.leaf.n_pkts_queued = qlen;
 	}
@@ -3281,8 +3284,8 @@ read_queue_stats(struct rte_eth_dev *dev,
 	/* Stats accumulate */
 	nq->stats.n_pkts += s.n_pkts - s.n_pkts_dropped;
 	nq->stats.n_bytes += s.n_bytes - s.n_bytes_dropped;
-	nq->stats.leaf.n_pkts_dropped[RTE_TM_GREEN] += s.n_pkts_dropped;
-	nq->stats.leaf.n_bytes_dropped[RTE_TM_GREEN] +=
+	nq->stats.leaf.n_pkts_dropped[RTE_COLOR_GREEN] += s.n_pkts_dropped;
+	nq->stats.leaf.n_bytes_dropped[RTE_COLOR_GREEN] +=
 		s.n_bytes_dropped;
 	nq->stats.leaf.n_pkts_queued = qlen;
 
diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile
index 87d8c455d..c76bb2dd7 100644
--- a/lib/librte_eal/common/Makefile
+++ b/lib/librte_eal/common/Makefile
@@ -17,7 +17,7 @@ INC += rte_pci_dev_feature_defs.h rte_pci_dev_features.h
 INC += rte_malloc.h rte_keepalive.h rte_time.h
 INC += rte_service.h rte_service_component.h
 INC += rte_bitmap.h rte_vfio.h rte_hypervisor.h rte_test.h
-INC += rte_reciprocal.h rte_fbarray.h rte_uuid.h
+INC += rte_reciprocal.h rte_fbarray.h rte_uuid.h rte_color.h
 
 GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h rte_prefetch.h
 GENERIC_INC += rte_spinlock.h rte_memcpy.h rte_cpuflags.h rte_rwlock.h
diff --git a/lib/librte_eal/common/include/rte_color.h b/lib/librte_eal/common/include/rte_color.h
new file mode 100644
index 000000000..f4387071b
--- /dev/null
+++ b/lib/librte_eal/common/include/rte_color.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Intel Corporation
+ */
+
+#ifndef _RTE_COLOR_H_
+#define _RTE_COLOR_H_
+
+/**
+ * Color
+ */
+enum rte_color {
+	RTE_COLOR_GREEN = 0, /**< Green */
+	RTE_COLOR_YELLOW, /**< Yellow */
+	RTE_COLOR_RED, /**< Red */
+	RTE_COLORS /**< Number of colors */
+};
+
+#endif /* _RTE_COLOR_H_ */
diff --git a/lib/librte_ethdev/rte_mtr.c b/lib/librte_ethdev/rte_mtr.c
index 1046cb5fd..12b815406 100644
--- a/lib/librte_ethdev/rte_mtr.c
+++ b/lib/librte_ethdev/rte_mtr.c
@@ -153,7 +153,7 @@ rte_mtr_meter_profile_update(uint16_t port_id,
 int __rte_experimental
 rte_mtr_meter_dscp_table_update(uint16_t port_id,
 	uint32_t mtr_id,
-	enum rte_mtr_color *dscp_table,
+	enum rte_color *dscp_table,
 	struct rte_mtr_error *error)
 {
 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
diff --git a/lib/librte_ethdev/rte_mtr.h b/lib/librte_ethdev/rte_mtr.h
index c4819b274..113db06a9 100644
--- a/lib/librte_ethdev/rte_mtr.h
+++ b/lib/librte_ethdev/rte_mtr.h
@@ -76,21 +76,12 @@
 #include <stdint.h>
 #include <rte_compat.h>
 #include <rte_common.h>
+#include <rte_color.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-/**
- * Color
- */
-enum rte_mtr_color {
-	RTE_MTR_GREEN = 0, /**< Green */
-	RTE_MTR_YELLOW, /**< Yellow */
-	RTE_MTR_RED, /**< Red */
-	RTE_MTR_COLORS /**< Number of colors. */
-};
-
 /**
  * Statistics counter type
  */
@@ -125,10 +116,10 @@ enum rte_mtr_stats_type {
  */
 struct rte_mtr_stats {
 	/** Number of packets passed by the policer (per color). */
-	uint64_t n_pkts[RTE_MTR_COLORS];
+	uint64_t n_pkts[RTE_COLORS];
 
 	/** Number of bytes passed by the policer (per color). */
-	uint64_t n_bytes[RTE_MTR_COLORS];
+	uint64_t n_bytes[RTE_COLORS];
 
 	/** Number of packets dropped by the policer. */
 	uint64_t n_pkts_dropped;
@@ -260,7 +251,7 @@ struct rte_mtr_params {
 	 * at least one yellow or red color element, then the color aware mode
 	 * is configured.
 	 */
-	enum rte_mtr_color *dscp_table;
+	enum rte_color *dscp_table;
 
 	/** Non-zero to enable the meter, zero to disable the meter at the time
 	 * of MTR object creation. Ignored when the meter profile indicated by
@@ -270,7 +261,7 @@ struct rte_mtr_params {
 	int meter_enable;
 
 	/** Policer actions (per meter output color). */
-	enum rte_mtr_policer_action action[RTE_MTR_COLORS];
+	enum rte_mtr_policer_action action[RTE_COLORS];
 
 	/** Set of stats counters to be enabled.
 	 * @see enum rte_mtr_stats_type
@@ -636,7 +627,7 @@ rte_mtr_meter_profile_update(uint16_t port_id,
 int __rte_experimental
 rte_mtr_meter_dscp_table_update(uint16_t port_id,
 	uint32_t mtr_id,
-	enum rte_mtr_color *dscp_table,
+	enum rte_color *dscp_table,
 	struct rte_mtr_error *error);
 
 /**
diff --git a/lib/librte_ethdev/rte_mtr_driver.h b/lib/librte_ethdev/rte_mtr_driver.h
index c9a6d7c38..3ec7ffa2a 100644
--- a/lib/librte_ethdev/rte_mtr_driver.h
+++ b/lib/librte_ethdev/rte_mtr_driver.h
@@ -70,7 +70,7 @@ typedef int (*rte_mtr_meter_profile_update_t)(struct rte_eth_dev *dev,
 
 typedef int (*rte_mtr_meter_dscp_table_update_t)(struct rte_eth_dev *dev,
 	uint32_t mtr_id,
-	enum rte_mtr_color *dscp_table,
+	enum rte_color *dscp_table,
 	struct rte_mtr_error *error);
 /**< @internal MTR object meter DSCP table update */
 
diff --git a/lib/librte_ethdev/rte_tm.h b/lib/librte_ethdev/rte_tm.h
index 646ef3880..95f322313 100644
--- a/lib/librte_ethdev/rte_tm.h
+++ b/lib/librte_ethdev/rte_tm.h
@@ -51,6 +51,7 @@
 #include <stdint.h>
 
 #include <rte_common.h>
+#include <rte_color.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -115,16 +116,6 @@ extern "C" {
  */
 #define RTE_TM_NODE_LEVEL_ID_ANY                     UINT32_MAX
 
-/**
- * Color
- */
-enum rte_tm_color {
-	RTE_TM_GREEN = 0, /**< Green */
-	RTE_TM_YELLOW, /**< Yellow */
-	RTE_TM_RED, /**< Red */
-	RTE_TM_COLORS /**< Number of colors */
-};
-
 /**
  * Node statistics counter type
  */
@@ -179,12 +170,12 @@ struct rte_tm_node_stats {
 		/** Number of packets dropped by current leaf node per each
 		 * color.
 		 */
-		uint64_t n_pkts_dropped[RTE_TM_COLORS];
+		uint64_t n_pkts_dropped[RTE_COLORS];
 
 		/** Number of bytes dropped by current leaf node per each
 		 * color.
 		 */
-		uint64_t n_bytes_dropped[RTE_TM_COLORS];
+		uint64_t n_bytes_dropped[RTE_COLORS];
 
 		/** Number of packets currently waiting in the packet queue of
 		 * current leaf node.
@@ -435,16 +426,16 @@ struct rte_tm_capabilities {
 	uint32_t cman_wred_context_shared_n_contexts_per_node_max;
 
 	/** Support for VLAN DEI packet marking (per color). */
-	int mark_vlan_dei_supported[RTE_TM_COLORS];
+	int mark_vlan_dei_supported[RTE_COLORS];
 
 	/** Support for IPv4/IPv6 ECN marking of TCP packets (per color). */
-	int mark_ip_ecn_tcp_supported[RTE_TM_COLORS];
+	int mark_ip_ecn_tcp_supported[RTE_COLORS];
 
 	/** Support for IPv4/IPv6 ECN marking of SCTP packets (per color). */
-	int mark_ip_ecn_sctp_supported[RTE_TM_COLORS];
+	int mark_ip_ecn_sctp_supported[RTE_COLORS];
 
 	/** Support for IPv4/IPv6 DSCP packet marking (per color). */
-	int mark_ip_dscp_supported[RTE_TM_COLORS];
+	int mark_ip_dscp_supported[RTE_COLORS];
 
 	/** Set of supported dynamic update operations.
 	 * @see enum rte_tm_dynamic_update_type
@@ -861,7 +852,7 @@ struct rte_tm_red_params {
  */
 struct rte_tm_wred_params {
 	/** One set of RED parameters per packet color */
-	struct rte_tm_red_params red_params[RTE_TM_COLORS];
+	struct rte_tm_red_params red_params[RTE_COLORS];
 
 	/** When non-zero, the *min_th* and *max_th* thresholds are specified
 	 * in packets (WRED packet mode). When zero, the *min_th* and *max_th*
diff --git a/lib/librte_meter/rte_meter.h b/lib/librte_meter/rte_meter.h
index 58a051583..e6187c49d 100644
--- a/lib/librte_meter/rte_meter.h
+++ b/lib/librte_meter/rte_meter.h
@@ -21,6 +21,7 @@ extern "C" {
 
 #include <stdint.h>
 
+#include <rte_color.h>
 /*
  * Application Programmer's Interface (API)
  *
@@ -34,6 +35,12 @@ enum rte_meter_color {
 	e_RTE_METER_COLORS     /**< Number of available colors */
 };
 
+/* New rte_color is defined and used to deprecate rte_meter_color soon. */
+#define rte_meter_color rte_color
+#define e_RTE_METER_GREEN RTE_COLOR_GREEN
+#define e_RTE_METER_YELLOW RTE_COLOR_YELLOW
+#define e_RTE_METER_RED RTE_COLOR_RED
+
 /** srTCM parameters per metered traffic flow. The CIR, CBS and EBS parameters only
 count bytes of IP packets and do not include link specific headers. At least one of
 the CBS or EBS parameters has to be greater than zero. */
-- 
2.17.1

  parent reply	other threads:[~2018-12-07 14:32 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-23 16:54 [dpdk-dev] [PATCH] mbuf: implement generic format for sched field Jasvinder Singh
2018-11-26 11:37 ` Dumitrescu, Cristian
2018-11-29 10:42   ` Singh, Jasvinder
2018-12-04 17:39     ` Dumitrescu, Cristian
2018-12-05 12:22       ` Singh, Jasvinder
2018-12-01 14:22 ` Jerin Jacob
2018-12-05 11:15   ` Singh, Jasvinder
2018-12-10 17:49   ` Dumitrescu, Cristian
2018-12-07 14:31 ` [dpdk-dev] [PATCH v2 1/3] " Reshma Pattan
2018-12-11 19:02   ` Dumitrescu, Cristian
2018-12-12 18:17   ` Dumitrescu, Cristian
2018-12-13  8:51   ` Rao, Nikhil
2018-12-13 18:08   ` [dpdk-dev] [PATCH v3 1/2] eal: add new rte color definition Reshma Pattan
2018-12-13 18:08     ` [dpdk-dev] [PATCH v3 2/2] mbuf: implement generic format for sched field Reshma Pattan
2018-12-14 22:52       ` Dumitrescu, Cristian
2018-12-20  8:32         ` Olivier Matz
2018-12-20 11:19           ` Dumitrescu, Cristian
2018-12-14 22:19     ` [dpdk-dev] [PATCH v3 1/2] eal: add new rte color definition Dumitrescu, Cristian
2018-12-17 20:35     ` Thomas Monjalon
2018-12-18 15:40     ` [dpdk-dev] [PATCH v4 1/2] meter: " Reshma Pattan
2018-12-18 15:40       ` [dpdk-dev] [PATCH v4 2/2] mbuf: implement generic format for sched field Reshma Pattan
2018-12-19 15:34       ` [dpdk-dev] [PATCH v5 1/2] meter: add new rte color definition Reshma Pattan
2018-12-19 15:34         ` [dpdk-dev] [PATCH v5 2/2] mbuf: implement generic format for sched field Reshma Pattan
2018-12-19 15:42         ` [dpdk-dev] [PATCH v6 1/2] meter: add new rte color definition Reshma Pattan
2018-12-19 15:42           ` [dpdk-dev] [PATCH v6 2/2] mbuf: implement generic format for sched field Reshma Pattan
2018-12-19 18:14             ` Ananyev, Konstantin
2018-12-20  8:29             ` Olivier Matz
2018-12-20 11:28               ` Dumitrescu, Cristian
2018-12-20 12:41                 ` Olivier Matz
2018-12-20 12:16           ` [dpdk-dev] [PATCH v7 1/2] meter: add new rte color definition Reshma Pattan
2018-12-20 12:16             ` [dpdk-dev] [PATCH v7 2/2] mbuf: implement generic format for sched field Reshma Pattan
2018-12-20 12:43               ` Olivier Matz
2018-12-20 19:11                 ` Dumitrescu, Cristian
2018-12-20 14:55               ` Rao, Nikhil
2019-01-15 22:37               ` Stephen Hemminger
2019-01-16  9:19                 ` Pattan, Reshma
2019-01-16  9:33                   ` Dumitrescu, Cristian
2019-01-16 10:09                     ` Singh, Jasvinder
2019-01-15 23:11               ` Stephen Hemminger
2019-01-16  8:41                 ` Thomas Monjalon
2018-12-07 14:31 ` Reshma Pattan [this message]
2018-12-10 18:24   ` [dpdk-dev] [PATCH v2 2/3] eal: add new rte color definition Dumitrescu, Cristian
2018-12-14 23:35   ` Ananyev, Konstantin
2018-12-15  0:16     ` Dumitrescu, Cristian
2018-12-17 11:21       ` Ananyev, Konstantin
2018-12-17 17:15         ` Pattan, Reshma
2018-12-17 18:51           ` Dumitrescu, Cristian
2018-12-17 23:11             ` Thomas Monjalon
2018-12-18 10:30               ` Dumitrescu, Cristian
2018-12-18 11:18               ` Dumitrescu, Cristian
2018-12-18 12:38                 ` Thomas Monjalon
2018-12-18 13:19                   ` Dumitrescu, Cristian
2018-12-18 13:39                     ` Thomas Monjalon
2018-12-18 17:07                       ` Ananyev, Konstantin
2018-12-18 19:34                         ` Dumitrescu, Cristian
2018-12-18 20:19                           ` Thomas Monjalon
2018-12-19 10:47                             ` Dumitrescu, Cristian
2018-12-19 10:50                               ` Thomas Monjalon
2018-12-19 10:52                             ` Ananyev, Konstantin
2018-12-19 10:49                           ` Ananyev, Konstantin
2018-12-19 11:04                             ` Dumitrescu, Cristian
2018-12-18 10:15             ` Ananyev, Konstantin
2018-12-18 10:25               ` Pattan, Reshma
2018-12-18 10:38                 ` Ananyev, Konstantin
2018-12-18 10:41                   ` Pattan, Reshma
2018-12-18 10:52                     ` Singh, Jasvinder
2018-12-18 12:10                       ` Ananyev, Konstantin
2018-12-15 14:15     ` Mattias Rönnblom
2018-12-17  7:27       ` Pattan, Reshma
2018-12-17  9:41       ` Dumitrescu, Cristian
2018-12-17 19:36         ` Mattias Rönnblom
2018-12-17 23:24           ` Ferruh Yigit
2018-12-07 14:31 ` [dpdk-dev] [PATCH v2 3/3] doc: add deprecation notice to remove rte meter color Reshma Pattan
2018-12-11 14:58   ` Dumitrescu, Cristian

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=1544193116-7058-2-git-send-email-reshma.pattan@intel.com \
    --to=reshma.pattan@intel.com \
    --cc=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    --cc=jasvinder.singh@intel.com \
    --cc=jerin.jacob@caviumnetworks.com \
    /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).