From patchwork Thu Nov 26 11:15:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wisam Monther X-Patchwork-Id: 84574 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C0581A052A; Thu, 26 Nov 2020 12:17:31 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 36B5DC9A6; Thu, 26 Nov 2020 12:16:20 +0100 (CET) Received: from hqnvemgate26.nvidia.com (hqnvemgate26.nvidia.com [216.228.121.65]) by dpdk.org (Postfix) with ESMTP id EEC4FC93C; Thu, 26 Nov 2020 12:16:16 +0100 (CET) Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Thu, 26 Nov 2020 03:16:18 -0800 Received: from nvidia.com (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 26 Nov 2020 11:16:06 +0000 From: Wisam Jaddo To: , , , CC: , , Date: Thu, 26 Nov 2020 13:15:43 +0200 Message-ID: <20201126111543.16928-5-wisamm@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201126111543.16928-1-wisamm@nvidia.com> References: <20201126111543.16928-1-wisamm@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1606389378; bh=yZBO+RlNh8AREJ8hU8jqHuZiiZqLXxLajN3iUjk5S9g=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Type:X-Originating-IP: X-ClientProxiedBy; b=TW2QoVa7Nm82Za9aj80NcV6R3QlhDiko7ijg1XxO+fzsvnrVRpVy1giPWTPNGoRdB PZ4cbz2o0jHCYGYafz0/YyHUD9bvuaHzidrIPBdC9GUH2Imr05lO+954CyL8c4Li/t dva7KfvOSaAcu6eCZMNBzqG6rDqCDffB6BotvG+ynlhAafZfxTBSKll4ek3PFXUhQF /HhJSpVGQPuunk6UBMhkXhBm2CZMcq1150ezMZDrzOZ5oo7nhE6xOg/QuUE8aKbl58 ezh1zumO+2kQHygiNu86lBzXMdr3YSZJWtBiS7sutDb37LXGfY5ebO8SMkUy6x9YIf sc/DobVE834Xw== Subject: [dpdk-dev] [PATCH 4/4] app/flow-perf: remove redundant items memset and vars 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Since items are static then the default values will be zero, thus the memset to zero value is just a redundant code. Also remove the all not needed variables, that can be replaced with direct set to the structure itself. Fixes: bf3688f1e816 ("app/flow-perf: add insertion rate calculation") Cc: wisamm@mellanox.com Cc: stable@dpdk.org Signed-off-by: Wisam Jaddo Reviewed-by: Alexander Kozyrev Reviewed-by: Suanming Mou --- app/test-flow-perf/actions_gen.c | 30 +++----- app/test-flow-perf/items_gen.c | 123 ++++++++----------------------- 2 files changed, 44 insertions(+), 109 deletions(-) diff --git a/app/test-flow-perf/actions_gen.c b/app/test-flow-perf/actions_gen.c index 1364407056..c3545ba32f 100644 --- a/app/test-flow-perf/actions_gen.c +++ b/app/test-flow-perf/actions_gen.c @@ -143,12 +143,10 @@ add_set_meta(struct rte_flow_action *actions, uint8_t actions_counter, __rte_unused struct additional_para para) { - static struct rte_flow_action_set_meta meta_action; - - do { - meta_action.data = RTE_BE32(META_DATA); - meta_action.mask = RTE_BE32(0xffffffff); - } while (0); + static struct rte_flow_action_set_meta meta_action = { + .data = RTE_BE32(META_DATA), + .mask = RTE_BE32(0xffffffff), + }; actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_SET_META; actions[actions_counter].conf = &meta_action; @@ -159,13 +157,11 @@ add_set_tag(struct rte_flow_action *actions, uint8_t actions_counter, __rte_unused struct additional_para para) { - static struct rte_flow_action_set_tag tag_action; - - do { - tag_action.data = RTE_BE32(META_DATA); - tag_action.mask = RTE_BE32(0xffffffff); - tag_action.index = TAG_INDEX; - } while (0); + static struct rte_flow_action_set_tag tag_action = { + .data = RTE_BE32(META_DATA), + .mask = RTE_BE32(0xffffffff), + .index = TAG_INDEX, + }; actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_SET_TAG; actions[actions_counter].conf = &tag_action; @@ -176,11 +172,9 @@ add_port_id(struct rte_flow_action *actions, uint8_t actions_counter, __rte_unused struct additional_para para) { - static struct rte_flow_action_port_id port_id; - - do { - port_id.id = PORT_ID_DST; - } while (0); + static struct rte_flow_action_port_id port_id = { + .id = PORT_ID_DST, + }; actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_PORT_ID; actions[actions_counter].conf = &port_id; diff --git a/app/test-flow-perf/items_gen.c b/app/test-flow-perf/items_gen.c index 0950023608..ccebc08b39 100644 --- a/app/test-flow-perf/items_gen.c +++ b/app/test-flow-perf/items_gen.c @@ -26,9 +26,6 @@ add_ether(struct rte_flow_item *items, static struct rte_flow_item_eth eth_spec; static struct rte_flow_item_eth eth_mask; - memset(ð_spec, 0, sizeof(struct rte_flow_item_eth)); - memset(ð_mask, 0, sizeof(struct rte_flow_item_eth)); - items[items_counter].type = RTE_FLOW_ITEM_TYPE_ETH; items[items_counter].spec = ð_spec; items[items_counter].mask = ð_mask; @@ -39,16 +36,12 @@ add_vlan(struct rte_flow_item *items, uint8_t items_counter, __rte_unused struct additional_para para) { - static struct rte_flow_item_vlan vlan_spec; - static struct rte_flow_item_vlan vlan_mask; - - uint16_t vlan_value = VLAN_VALUE; - - memset(&vlan_spec, 0, sizeof(struct rte_flow_item_vlan)); - memset(&vlan_mask, 0, sizeof(struct rte_flow_item_vlan)); - - vlan_spec.tci = RTE_BE16(vlan_value); - vlan_mask.tci = RTE_BE16(0xffff); + static struct rte_flow_item_vlan vlan_spec = { + .tci = RTE_BE16(VLAN_VALUE), + }; + static struct rte_flow_item_vlan vlan_mask = { + .tci = RTE_BE16(0xffff), + }; items[items_counter].type = RTE_FLOW_ITEM_TYPE_VLAN; items[items_counter].spec = &vlan_spec; @@ -63,9 +56,6 @@ add_ipv4(struct rte_flow_item *items, static struct rte_flow_item_ipv4 ipv4_masks[RTE_MAX_LCORE] __rte_cache_aligned; uint8_t ti = para.core_idx; - memset(&ipv4_specs[ti], 0, sizeof(struct rte_flow_item_ipv4)); - memset(&ipv4_masks[ti], 0, sizeof(struct rte_flow_item_ipv4)); - ipv4_specs[ti].hdr.src_addr = RTE_BE32(para.src_ip); ipv4_masks[ti].hdr.src_addr = RTE_BE32(0xffffffff); @@ -83,9 +73,6 @@ add_ipv6(struct rte_flow_item *items, static struct rte_flow_item_ipv6 ipv6_masks[RTE_MAX_LCORE] __rte_cache_aligned; uint8_t ti = para.core_idx; - memset(&ipv6_specs[ti], 0, sizeof(struct rte_flow_item_ipv6)); - memset(&ipv6_masks[ti], 0, sizeof(struct rte_flow_item_ipv6)); - /** Set ipv6 src **/ memset(&ipv6_specs[ti].hdr.src_addr, para.src_ip, sizeof(ipv6_specs->hdr.src_addr) / 2); @@ -107,9 +94,6 @@ add_tcp(struct rte_flow_item *items, static struct rte_flow_item_tcp tcp_spec; static struct rte_flow_item_tcp tcp_mask; - memset(&tcp_spec, 0, sizeof(struct rte_flow_item_tcp)); - memset(&tcp_mask, 0, sizeof(struct rte_flow_item_tcp)); - items[items_counter].type = RTE_FLOW_ITEM_TYPE_TCP; items[items_counter].spec = &tcp_spec; items[items_counter].mask = &tcp_mask; @@ -123,9 +107,6 @@ add_udp(struct rte_flow_item *items, static struct rte_flow_item_udp udp_spec; static struct rte_flow_item_udp udp_mask; - memset(&udp_spec, 0, sizeof(struct rte_flow_item_udp)); - memset(&udp_mask, 0, sizeof(struct rte_flow_item_udp)); - items[items_counter].type = RTE_FLOW_ITEM_TYPE_UDP; items[items_counter].spec = &udp_spec; items[items_counter].mask = &udp_mask; @@ -144,9 +125,6 @@ add_vxlan(struct rte_flow_item *items, vni_value = VNI_VALUE; - memset(&vxlan_specs[ti], 0, sizeof(struct rte_flow_item_vxlan)); - memset(&vxlan_masks[ti], 0, sizeof(struct rte_flow_item_vxlan)); - /* Set standard vxlan vni */ for (i = 0; i < 3; i++) { vxlan_specs[ti].vni[2 - i] = vni_value >> (i * 8); @@ -174,9 +152,6 @@ add_vxlan_gpe(struct rte_flow_item *items, vni_value = VNI_VALUE; - memset(&vxlan_gpe_specs[ti], 0, sizeof(struct rte_flow_item_vxlan_gpe)); - memset(&vxlan_gpe_masks[ti], 0, sizeof(struct rte_flow_item_vxlan_gpe)); - /* Set vxlan-gpe vni */ for (i = 0; i < 3; i++) { vxlan_gpe_specs[ti].vni[2 - i] = vni_value >> (i * 8); @@ -196,18 +171,12 @@ add_gre(struct rte_flow_item *items, uint8_t items_counter, __rte_unused struct additional_para para) { - static struct rte_flow_item_gre gre_spec; - static struct rte_flow_item_gre gre_mask; - - uint16_t proto; - - proto = RTE_ETHER_TYPE_TEB; - - memset(&gre_spec, 0, sizeof(struct rte_flow_item_gre)); - memset(&gre_mask, 0, sizeof(struct rte_flow_item_gre)); - - gre_spec.protocol = RTE_BE16(proto); - gre_mask.protocol = RTE_BE16(0xffff); + static struct rte_flow_item_gre gre_spec = { + .protocol = RTE_BE16(RTE_ETHER_TYPE_TEB), + }; + static struct rte_flow_item_gre gre_mask = { + .protocol = RTE_BE16(0xffff), + }; items[items_counter].type = RTE_FLOW_ITEM_TYPE_GRE; items[items_counter].spec = &gre_spec; @@ -227,9 +196,6 @@ add_geneve(struct rte_flow_item *items, vni_value = VNI_VALUE; - memset(&geneve_specs[ti], 0, sizeof(struct rte_flow_item_geneve)); - memset(&geneve_masks[ti], 0, sizeof(struct rte_flow_item_geneve)); - for (i = 0; i < 3; i++) { geneve_specs[ti].vni[2 - i] = vni_value >> (i * 8); geneve_masks[ti].vni[2 - i] = 0xff; @@ -245,18 +211,12 @@ add_gtp(struct rte_flow_item *items, uint8_t items_counter, __rte_unused struct additional_para para) { - static struct rte_flow_item_gtp gtp_spec; - static struct rte_flow_item_gtp gtp_mask; - - uint32_t teid_value; - - teid_value = TEID_VALUE; - - memset(>p_spec, 0, sizeof(struct rte_flow_item_gtp)); - memset(>p_mask, 0, sizeof(struct rte_flow_item_gtp)); - - gtp_spec.teid = RTE_BE32(teid_value); - gtp_mask.teid = RTE_BE32(0xffffffff); + static struct rte_flow_item_gtp gtp_spec = { + .teid = RTE_BE32(TEID_VALUE), + }; + static struct rte_flow_item_gtp gtp_mask = { + .teid = RTE_BE32(0xffffffff), + }; items[items_counter].type = RTE_FLOW_ITEM_TYPE_GTP; items[items_counter].spec = >p_spec; @@ -268,18 +228,12 @@ add_meta_data(struct rte_flow_item *items, uint8_t items_counter, __rte_unused struct additional_para para) { - static struct rte_flow_item_meta meta_spec; - static struct rte_flow_item_meta meta_mask; - - uint32_t data; - - data = META_DATA; - - memset(&meta_spec, 0, sizeof(struct rte_flow_item_meta)); - memset(&meta_mask, 0, sizeof(struct rte_flow_item_meta)); - - meta_spec.data = RTE_BE32(data); - meta_mask.data = RTE_BE32(0xffffffff); + static struct rte_flow_item_meta meta_spec = { + .data = RTE_BE32(META_DATA), + }; + static struct rte_flow_item_meta meta_mask = { + .data = RTE_BE32(0xffffffff), + }; items[items_counter].type = RTE_FLOW_ITEM_TYPE_META; items[items_counter].spec = &meta_spec; @@ -292,21 +246,14 @@ add_meta_tag(struct rte_flow_item *items, uint8_t items_counter, __rte_unused struct additional_para para) { - static struct rte_flow_item_tag tag_spec; - static struct rte_flow_item_tag tag_mask; - uint32_t data; - uint8_t index; - - data = META_DATA; - index = TAG_INDEX; - - memset(&tag_spec, 0, sizeof(struct rte_flow_item_tag)); - memset(&tag_mask, 0, sizeof(struct rte_flow_item_tag)); - - tag_spec.data = RTE_BE32(data); - tag_mask.data = RTE_BE32(0xffffffff); - tag_spec.index = index; - tag_mask.index = 0xff; + static struct rte_flow_item_tag tag_spec = { + .data = RTE_BE32(META_DATA), + .index = TAG_INDEX, + }; + static struct rte_flow_item_tag tag_mask = { + .data = RTE_BE32(0xffffffff), + .index = 0xff, + }; items[items_counter].type = RTE_FLOW_ITEM_TYPE_TAG; items[items_counter].spec = &tag_spec; @@ -321,9 +268,6 @@ add_icmpv4(struct rte_flow_item *items, static struct rte_flow_item_icmp icmpv4_spec; static struct rte_flow_item_icmp icmpv4_mask; - memset(&icmpv4_spec, 0, sizeof(struct rte_flow_item_icmp)); - memset(&icmpv4_mask, 0, sizeof(struct rte_flow_item_icmp)); - items[items_counter].type = RTE_FLOW_ITEM_TYPE_ICMP; items[items_counter].spec = &icmpv4_spec; items[items_counter].mask = &icmpv4_mask; @@ -337,9 +281,6 @@ add_icmpv6(struct rte_flow_item *items, static struct rte_flow_item_icmp6 icmpv6_spec; static struct rte_flow_item_icmp6 icmpv6_mask; - memset(&icmpv6_spec, 0, sizeof(struct rte_flow_item_icmp6)); - memset(&icmpv6_mask, 0, sizeof(struct rte_flow_item_icmp6)); - items[items_counter].type = RTE_FLOW_ITEM_TYPE_ICMP6; items[items_counter].spec = &icmpv6_spec; items[items_counter].mask = &icmpv6_mask;