From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 1F60EA00E6 for ; Wed, 15 May 2019 07:47:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DC8505B1E; Wed, 15 May 2019 07:47:11 +0200 (CEST) Received: from tama50.ecl.ntt.co.jp (tama50.ecl.ntt.co.jp [129.60.39.147]) by dpdk.org (Postfix) with ESMTP id 862A158EC for ; Wed, 15 May 2019 07:47:09 +0200 (CEST) Received: from vc1.ecl.ntt.co.jp (vc1.ecl.ntt.co.jp [129.60.86.153]) by tama50.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id x4F5l7nO015016; Wed, 15 May 2019 14:47:07 +0900 Received: from vc1.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 9BDFCEA75B1; Wed, 15 May 2019 14:47:07 +0900 (JST) Received: from localhost.localdomain (lobster.nslab.ecl.ntt.co.jp [129.60.13.95]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 827AFEA7663; Wed, 15 May 2019 14:47:07 +0900 (JST) From: ogawa.yasufumi@lab.ntt.co.jp To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp Date: Wed, 15 May 2019 14:44:45 +0900 Message-Id: <1557899086-17390-5-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1557899086-17390-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> References: <1557477327-11611-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> <1557899086-17390-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> X-TM-AS-MML: disable Subject: [spp] [PATCH v2 4/5] shared/sec: rename struct for attrs of classify X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spp-bounces@dpdk.org Sender: "spp" From: Yasufumi Ogawa 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 --- .../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 d617276..4c5a9d2 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(ð_addr, &tx_port->class_id.mac_addr, + rte_memcpy(ð_addr, &tx_port->cls_attrs.mac_addr, ETHER_ADDR_LEN); ether_format_addr(mac_addr_str, sizeof(mac_addr_str), ð_addr); -- 2.17.1