Soft Patch Panel
 help / color / mirror / Atom feed
From: ogawa.yasufumi@lab.ntt.co.jp
To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp
Subject: [spp] [PATCH 4/5] shared/sec: rename struct for attrs of classify
Date: Fri, 10 May 2019 17:35:26 +0900	[thread overview]
Message-ID: <1557477327-11611-5-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <1557477327-11611-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp>

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

Struct `spp_port_class_identifier` has members of MAC address and VLAN
tag used for classifying, so the name is not appropriate because it is
not an identifier but a set of attributes. This update is to fix the
issue.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 .../secondary/spp_worker_th/cmd_parser.c      | 31 +++++++++----------
 .../secondary/spp_worker_th/cmd_parser.h      |  4 +--
 .../secondary/spp_worker_th/command_proc.c    | 28 ++++++++---------
 src/shared/secondary/spp_worker_th/spp_proc.c | 24 +++++++-------
 src/shared/secondary/spp_worker_th/spp_proc.h | 12 +++----
 src/vf/classifier_mac.c                       |  8 ++---
 6 files changed, 53 insertions(+), 54 deletions(-)

diff --git a/src/shared/secondary/spp_worker_th/cmd_parser.c b/src/shared/secondary/spp_worker_th/cmd_parser.c
index b9e3fbe..6e536eb 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.c
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.c
@@ -61,18 +61,17 @@ const char *PORT_ABILITY_LIST[] = {
 	"",  /* termination */
 };
 
-/* Check mac address used on the port for registering or removing */
+/* Return 1 as true if port is used with given mac_addr and vid. */
 static int
-spp_check_classid_used_port(
+is_used_with_addr(
 		int vid, uint64_t mac_addr,
 		enum port_type iface_type, int iface_no)
 {
-	struct sppwk_port_info *port_info = get_iface_info(
+	struct sppwk_port_info *wk_port = get_iface_info(
 			iface_type, iface_no);
 
-	/* Return true if given mac_addr matches with port_info, and vid. */
-	return ((mac_addr == port_info->class_id.mac_addr) &&
-		(vid == port_info->class_id.vlantag.vid));
+	return ((mac_addr == wk_port->cls_attrs.mac_addr) &&
+		(vid == wk_port->cls_attrs.vlantag.vid));
 }
 
 /* Check if port has been added. */
@@ -671,7 +670,7 @@ parse_cls_port(void *cls_cmd_attr, const char *arg_val,
 		int allow_override __attribute__ ((unused)))
 {
 	int ret = SPP_RET_OK;
-	struct sppwk_cls_cmd_attr *cls_attr = cls_cmd_attr;
+	struct sppwk_cls_cmd_attrs *cls_attrs = cls_cmd_attr;
 	struct sppwk_port_idx tmp_port;
 	int64_t mac_addr = 0;
 
@@ -686,23 +685,23 @@ parse_cls_port(void *cls_cmd_attr, const char *arg_val,
 		return SPP_RET_NG;
 	}
 
-	if (cls_attr->type == SPP_CLASSIFIER_TYPE_MAC)
-		cls_attr->vid = ETH_VLAN_ID_MAX;
+	if (cls_attrs->type == SPP_CLASSIFIER_TYPE_MAC)
+		cls_attrs->vid = ETH_VLAN_ID_MAX;
 
-	if (unlikely(cls_attr->wk_action == SPPWK_ACT_ADD)) {
-		if (!spp_check_classid_used_port(ETH_VLAN_ID_MAX, 0,
+	if (unlikely(cls_attrs->wk_action == SPPWK_ACT_ADD)) {
+		if (!is_used_with_addr(ETH_VLAN_ID_MAX, 0,
 				tmp_port.iface_type, tmp_port.iface_no)) {
 			RTE_LOG(ERR, SPP_COMMAND_PROC, "Port in used. "
 					"(classifier_table command) val=%s\n",
 					arg_val);
 			return SPP_RET_NG;
 		}
-	} else if (unlikely(cls_attr->wk_action == SPPWK_ACT_DEL)) {
-		mac_addr = spp_change_mac_str_to_int64(cls_attr->mac);
+	} else if (unlikely(cls_attrs->wk_action == SPPWK_ACT_DEL)) {
+		mac_addr = spp_change_mac_str_to_int64(cls_attrs->mac);
 		if (mac_addr < 0)
 			return SPP_RET_NG;
 
-		if (!spp_check_classid_used_port(cls_attr->vid,
+		if (!is_used_with_addr(cls_attrs->vid,
 				(uint64_t)mac_addr,
 				tmp_port.iface_type, tmp_port.iface_no)) {
 			RTE_LOG(ERR, SPP_COMMAND_PROC, "Port in used. "
@@ -712,8 +711,8 @@ parse_cls_port(void *cls_cmd_attr, const char *arg_val,
 		}
 	}
 
-	cls_attr->port.iface_type = tmp_port.iface_type;
-	cls_attr->port.iface_no   = tmp_port.iface_no;
+	cls_attrs->port.iface_type = tmp_port.iface_type;
+	cls_attrs->port.iface_no   = tmp_port.iface_no;
 	return SPP_RET_OK;
 }
 
diff --git a/src/shared/secondary/spp_worker_th/cmd_parser.h b/src/shared/secondary/spp_worker_th/cmd_parser.h
index b03a920..58e39a9 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.h
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.h
@@ -73,7 +73,7 @@ enum sppwk_cmd_type {
 };
 
 /* `classifier_table` command specific parameters. */
-struct sppwk_cls_cmd_attr {
+struct sppwk_cls_cmd_attrs {
 	enum sppwk_action wk_action;  /**< add or del */
 	enum spp_classifier_type type;  /**< currently only for mac */
 	int vid;  /**< VLAN ID  */
@@ -108,7 +108,7 @@ struct spp_command {
 	enum sppwk_cmd_type type; /**< command type */
 
 	union {  /**< command descriptors */
-		struct sppwk_cls_cmd_attr cls_table;
+		struct sppwk_cls_cmd_attrs cls_table;
 		struct sppwk_cmd_flush flush;
 		struct sppwk_cmd_comp comp;
 		struct sppwk_cmd_port port;
diff --git a/src/shared/secondary/spp_worker_th/command_proc.c b/src/shared/secondary/spp_worker_th/command_proc.c
index 9df4cdc..ab0bbb3 100644
--- a/src/shared/secondary/spp_worker_th/command_proc.c
+++ b/src/shared/secondary/spp_worker_th/command_proc.c
@@ -167,48 +167,48 @@ spp_update_classifier_table(
 
 	if (wk_action == SPPWK_ACT_DEL) {
 		/* Delete */
-		if ((port_info->class_id.vlantag.vid != 0) &&
-				unlikely(port_info->class_id.vlantag.vid !=
+		if ((port_info->cls_attrs.vlantag.vid != 0) &&
+				unlikely(port_info->cls_attrs.vlantag.vid !=
 				vid)) {
 			RTE_LOG(ERR, APP, "VLAN ID is different. "
 					"( vid = %d )\n", vid);
 			return SPP_RET_NG;
 		}
-		if ((port_info->class_id.mac_addr != 0) &&
-			unlikely(port_info->class_id.mac_addr !=
+		if ((port_info->cls_attrs.mac_addr != 0) &&
+			unlikely(port_info->cls_attrs.mac_addr !=
 					mac_addr)) {
 			RTE_LOG(ERR, APP, "MAC address is different. "
 					"( mac = %s )\n", mac_addr_str);
 			return SPP_RET_NG;
 		}
 
-		port_info->class_id.vlantag.vid = ETH_VLAN_ID_MAX;
-		port_info->class_id.mac_addr    = 0;
-		memset(port_info->class_id.mac_addr_str, 0x00,
+		port_info->cls_attrs.vlantag.vid = ETH_VLAN_ID_MAX;
+		port_info->cls_attrs.mac_addr    = 0;
+		memset(port_info->cls_attrs.mac_addr_str, 0x00,
 							SPP_MIN_STR_LEN);
 
 	} else if (wk_action == SPPWK_ACT_ADD) {
 		/* Setting */
-		if (unlikely(port_info->class_id.vlantag.vid !=
+		if (unlikely(port_info->cls_attrs.vlantag.vid !=
 				ETH_VLAN_ID_MAX)) {
 			RTE_LOG(ERR, APP, "Port in used. "
 					"( port = %d:%d, vlan = %d != %d )\n",
 					port->iface_type, port->iface_no,
-					port_info->class_id.vlantag.vid, vid);
+					port_info->cls_attrs.vlantag.vid, vid);
 			return SPP_RET_NG;
 		}
-		if (unlikely(port_info->class_id.mac_addr != 0)) {
+		if (unlikely(port_info->cls_attrs.mac_addr != 0)) {
 			RTE_LOG(ERR, APP, "Port in used. "
 					"( port = %d:%d, mac = %s != %s )\n",
 					port->iface_type, port->iface_no,
-					port_info->class_id.mac_addr_str,
+					port_info->cls_attrs.mac_addr_str,
 					mac_addr_str);
 			return SPP_RET_NG;
 		}
 
-		port_info->class_id.vlantag.vid = vid;
-		port_info->class_id.mac_addr    = mac_addr;
-		strcpy(port_info->class_id.mac_addr_str, mac_addr_str);
+		port_info->cls_attrs.vlantag.vid = vid;
+		port_info->cls_attrs.mac_addr    = mac_addr;
+		strcpy(port_info->cls_attrs.mac_addr_str, mac_addr_str);
 	}
 
 	set_component_change_port(port_info, SPP_PORT_RXTX_TX);
diff --git a/src/shared/secondary/spp_worker_th/spp_proc.c b/src/shared/secondary/spp_worker_th/spp_proc.c
index 18acd64..370f071 100644
--- a/src/shared/secondary/spp_worker_th/spp_proc.c
+++ b/src/shared/secondary/spp_worker_th/spp_proc.c
@@ -355,9 +355,9 @@ dump_interface_info(const struct iface_info *iface_info)
 				"vid = %u, mac=%08lx(%s)\n",
 				cnt, port->iface_type, port->iface_no,
 				port->ethdev_port_id,
-				port->class_id.vlantag.vid,
-				port->class_id.mac_addr,
-				port->class_id.mac_addr_str);
+				port->cls_attrs.vlantag.vid,
+				port->cls_attrs.mac_addr,
+				port->cls_attrs.mac_addr_str);
 	}
 	for (cnt = 0; cnt < RTE_MAX_ETHPORTS; cnt++) {
 		port = &iface_info->vhost[cnt];
@@ -368,9 +368,9 @@ dump_interface_info(const struct iface_info *iface_info)
 				"vid = %u, mac=%08lx(%s)\n",
 				cnt, port->iface_type, port->iface_no,
 				port->ethdev_port_id,
-				port->class_id.vlantag.vid,
-				port->class_id.mac_addr,
-				port->class_id.mac_addr_str);
+				port->cls_attrs.vlantag.vid,
+				port->cls_attrs.mac_addr,
+				port->cls_attrs.mac_addr_str);
 	}
 	for (cnt = 0; cnt < RTE_MAX_ETHPORTS; cnt++) {
 		port = &iface_info->ring[cnt];
@@ -381,9 +381,9 @@ dump_interface_info(const struct iface_info *iface_info)
 				"vid = %u, mac=%08lx(%s)\n",
 				cnt, port->iface_type, port->iface_no,
 				port->ethdev_port_id,
-				port->class_id.vlantag.vid,
-				port->class_id.mac_addr,
-				port->class_id.mac_addr_str);
+				port->cls_attrs.vlantag.vid,
+				port->cls_attrs.mac_addr,
+				port->cls_attrs.mac_addr_str);
 	}
 }
 
@@ -476,17 +476,17 @@ init_iface_info(void)
 		p_iface_info->nic[port_cnt].iface_type = UNDEF;
 		p_iface_info->nic[port_cnt].iface_no = port_cnt;
 		p_iface_info->nic[port_cnt].ethdev_port_id = -1;
-		p_iface_info->nic[port_cnt].class_id.vlantag.vid =
+		p_iface_info->nic[port_cnt].cls_attrs.vlantag.vid =
 			ETH_VLAN_ID_MAX;
 		p_iface_info->vhost[port_cnt].iface_type = UNDEF;
 		p_iface_info->vhost[port_cnt].iface_no = port_cnt;
 		p_iface_info->vhost[port_cnt].ethdev_port_id = -1;
-		p_iface_info->vhost[port_cnt].class_id.vlantag.vid =
+		p_iface_info->vhost[port_cnt].cls_attrs.vlantag.vid =
 			ETH_VLAN_ID_MAX;
 		p_iface_info->ring[port_cnt].iface_type = UNDEF;
 		p_iface_info->ring[port_cnt].iface_no = port_cnt;
 		p_iface_info->ring[port_cnt].ethdev_port_id = -1;
-		p_iface_info->ring[port_cnt].class_id.vlantag.vid =
+		p_iface_info->ring[port_cnt].cls_attrs.vlantag.vid =
 			ETH_VLAN_ID_MAX;
 	}
 }
diff --git a/src/shared/secondary/spp_worker_th/spp_proc.h b/src/shared/secondary/spp_worker_th/spp_proc.h
index bca2c0e..abf16e7 100644
--- a/src/shared/secondary/spp_worker_th/spp_proc.h
+++ b/src/shared/secondary/spp_worker_th/spp_proc.h
@@ -179,11 +179,11 @@ struct spp_port_ability {
 	union spp_ability_data data;   /**< Port ability data */
 };
 
-/** Port class identifier for classifying */
-struct spp_port_class_identifier {
-	uint64_t mac_addr;                      /**< Mac address (binary) */
-	char     mac_addr_str[SPP_MIN_STR_LEN]; /**< Mac address (text) */
-	struct spp_vlantag_info vlantag;        /**< VLAN tag information */
+/* Attributes for classifying . */
+struct sppwk_cls_attrs {
+	uint64_t mac_addr;  /**< Mac address (binary) */
+	char mac_addr_str[SPP_MIN_STR_LEN];  /**< Mac address (text) */
+	struct spp_vlantag_info vlantag;   /**< VLAN tag information */
 };
 
 /**
@@ -200,7 +200,7 @@ struct sppwk_port_info {
 	enum port_type iface_type;  /**< phy, vhost or ring */
 	int iface_no;
 	int ethdev_port_id;  /**< Consistent ID of ethdev */
-	struct spp_port_class_identifier class_id;
+	struct sppwk_cls_attrs cls_attrs;
 	struct spp_port_ability ability[SPP_PORT_ABILITY_MAX];
 };
 
diff --git a/src/vf/classifier_mac.c b/src/vf/classifier_mac.c
index 1e98636..9fd8da1 100644
--- a/src/vf/classifier_mac.c
+++ b/src/vf/classifier_mac.c
@@ -356,7 +356,7 @@ init_component_info(struct component_info *cmp_info,
 	cmp_info->mac_addr_entry = 0;
 	for (i = 0; i < component_info->num_tx_port; i++) {
 		tx_port = component_info->tx_ports[i];
-		vid = tx_port->class_id.vlantag.vid;
+		vid = tx_port->cls_attrs.vlantag.vid;
 
 		/* store ports information */
 		clsd_data_tx[i].iface_type      = tx_port->iface_type;
@@ -365,7 +365,7 @@ init_component_info(struct component_info *cmp_info,
 		clsd_data_tx[i].port            = tx_port->ethdev_port_id;
 		clsd_data_tx[i].num_pkt         = 0;
 
-		if (tx_port->class_id.mac_addr == 0)
+		if (tx_port->cls_attrs.mac_addr == 0)
 			continue;
 
 		/* if mac classification is NULL, make instance */
@@ -389,7 +389,7 @@ init_component_info(struct component_info *cmp_info,
 		cmp_info->mac_addr_entry = 1;
 
 		/* store default classified */
-		if (unlikely(tx_port->class_id.mac_addr ==
+		if (unlikely(tx_port->cls_attrs.mac_addr ==
 				SPP_DEFAULT_CLASSIFIED_DMY_ADDR)) {
 			mac_cls->default_classified = i;
 			RTE_LOG(INFO, SPP_CLASSIFIER_MAC,
@@ -404,7 +404,7 @@ init_component_info(struct component_info *cmp_info,
 		}
 
 		/* add entry to classifier mac table */
-		rte_memcpy(&eth_addr, &tx_port->class_id.mac_addr,
+		rte_memcpy(&eth_addr, &tx_port->cls_attrs.mac_addr,
 				ETHER_ADDR_LEN);
 		ether_format_addr(mac_addr_str, sizeof(mac_addr_str),
 				&eth_addr);
-- 
2.17.1


  parent reply	other threads:[~2019-05-10  8:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-10  8:35 [spp] [PATCH 0/5] Refactor source of cmd parser port utils ogawa.yasufumi
2019-05-10  8:35 ` [spp] [PATCH 1/5] shared/sec: rename src command_dec to cmd_parser ogawa.yasufumi
2019-05-10  8:35 ` [spp] [PATCH 2/5] shared/sec: remove no meaning str defines ogawa.yasufumi
2019-05-10  8:35 ` [spp] [PATCH 3/5] shared/sec: rename lists of fixed strings ogawa.yasufumi
2019-05-10  8:35 ` ogawa.yasufumi [this message]
2019-05-10  8:35 ` [spp] [PATCH 5/5] shared/sec: rename sppwk port util functions ogawa.yasufumi
2019-05-15  5:44 ` [spp] [PATCH v2 0/5] Fix typo of status command ogawa.yasufumi
2019-05-15  5:44   ` [spp] [PATCH v2 1/5] shared/sec: rename src command_dec to cmd_parser ogawa.yasufumi
2019-05-15  5:44   ` [spp] [PATCH v2 2/5] shared/sec: remove no meaning str defines ogawa.yasufumi
2019-05-15  5:44   ` [spp] [PATCH v2 3/5] shared/sec: rename lists of fixed strings ogawa.yasufumi
2019-05-15  5:44   ` [spp] [PATCH v2 4/5] shared/sec: rename struct for attrs of classify ogawa.yasufumi
2019-05-15  5:44   ` [spp] [PATCH v2 5/5] shared/sec: rename sppwk port util functions ogawa.yasufumi

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=1557477327-11611-5-git-send-email-ogawa.yasufumi@lab.ntt.co.jp \
    --to=ogawa.yasufumi@lab.ntt.co.jp \
    --cc=ferruh.yigit@intel.com \
    --cc=spp@dpdk.org \
    /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).