From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2D28C41E78; Sun, 12 Mar 2023 03:00:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C7D63406A2; Sun, 12 Mar 2023 03:00:39 +0100 (CET) Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by mails.dpdk.org (Postfix) with ESMTP id 6F1ED40395 for ; Sun, 12 Mar 2023 03:00:38 +0100 (CET) Received: by mail-pf1-f171.google.com with SMTP id bd34so5810983pfb.3 for ; Sat, 11 Mar 2023 18:00:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678586437; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gYX+582dDtXZyaEc8upN9y2EQPwpWtAQkYbds9zWqQM=; b=gPFIeN48cifC2r/cp34rJJTjRxtTAIRx4KzBqqZd6wZkEd7LONlF1vLjZ13Y/pg8Ry /l/aXJrN6ycd6+42v7fFy8CYS8/6gE2xJUkC2nO1wQxrIsjPo8sH8iq5L/8CHxvkDkFA u5zY62mF7B2B4Gb/QLiylKbKiC0zEPHIlRtkjT8grqC1TzX7wU64UIm9IUmHwzw4cp14 6f5b56RQxL2vsYFhxW6wggZXvKN1H1vwWRb/lTAhzxol1VMxhNveooIqt/D/fPFaGoa0 CX5NqiFhdHGZN8AXGwW0Hsql1oYtszSH/YpsLwsaxOFhZF5JQz93qUMBw4xN5AkzvoiK MECQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678586437; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gYX+582dDtXZyaEc8upN9y2EQPwpWtAQkYbds9zWqQM=; b=eyttMJCyZeNKBh/j1wk6D9F4tD4IYqGRCFuGNjP6yhqNvLOQSgi6pTadyJ5uvxFruF KKiR8802NmPFpcCUtjex8h39GLRxoVpHhXy+PGONU46cG8+jnQyjE3REUIc/psRSs3FH Kl/AZbpenEy6HuzFcD2/X72OHVQ6QLuTvXVAEbjwZLSqg14Gn39cgaYr7MP+v24s/aIV Iu4yIH6qfcciX0EYnX8JedBfWPdc27HE8fYyVfvJ56MZFsAeEJKiyUR9R5JWEcwKgkby mK+h6GIxJSuxRP0D6ja6KHli5PEaOYiV05+0zZZKVTSr0hk7XOVL++QU/+nfm7H3L95f HYmQ== X-Gm-Message-State: AO0yUKWoweZSmNdAjiSUZQZNgwt6w2yjvWUqSNBnnGvAbvHEjW6v00TM 8IJ+m9TRFKLhs6FHRCS24iy2WUn6AGiZYLll X-Google-Smtp-Source: AK7set/qos2fO6xPkdhTYBmowRxzQqTWtaUo6ecXbDpocvNtT+NHD2XgiZmTS7OJdIOp7Ea1lMBPaw== X-Received: by 2002:aa7:9ad0:0:b0:5b6:c62e:7d4f with SMTP id x16-20020aa79ad0000000b005b6c62e7d4fmr24719656pfp.8.1678586437372; Sat, 11 Mar 2023 18:00:37 -0800 (PST) Received: from localhost.localdomain ([111.196.243.64]) by smtp.gmail.com with ESMTPSA id i14-20020aa787ce000000b00580d25a2bb2sm1977297pfo.108.2023.03.11.18.00.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Mar 2023 18:00:34 -0800 (PST) From: Harold Huang To: dev@dpdk.org Cc: Harold Huang , Wisam Jaddo Subject: [PATCH] app/flow-perf: replace RTE_BE32/16 with rte_cpu_to_be_32/16 for variables Date: Sun, 12 Mar 2023 02:00:09 +0000 Message-Id: <20230312020009.288-1-baymaxhuang@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org In DPDK, the macros RTE_BE32 or RTE_BE16 are usually used for constant values. And functions such as rte_cpu_to_be_32 or rte_cpu_to_be_16 are optimized for variables. Signed-off-by: Harold Huang --- app/test-flow-perf/actions_gen.c | 28 ++++++++++++++-------------- app/test-flow-perf/items_gen.c | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/test-flow-perf/actions_gen.c b/app/test-flow-perf/actions_gen.c index f1d5931325..c2499ad2d0 100644 --- a/app/test-flow-perf/actions_gen.c +++ b/app/test-flow-perf/actions_gen.c @@ -262,7 +262,7 @@ add_set_src_ipv4(struct rte_flow_action *actions, ip = 1; /* IPv4 value to be set is random each time */ - set_ipv4[para.core_idx].ipv4_addr = RTE_BE32(ip + 1); + set_ipv4[para.core_idx].ipv4_addr = rte_cpu_to_be_32(ip + 1); actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC; actions[actions_counter].conf = &set_ipv4[para.core_idx]; @@ -281,7 +281,7 @@ add_set_dst_ipv4(struct rte_flow_action *actions, ip = 1; /* IPv4 value to be set is random each time */ - set_ipv4[para.core_idx].ipv4_addr = RTE_BE32(ip + 1); + set_ipv4[para.core_idx].ipv4_addr = rte_cpu_to_be_32(ip + 1); actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_SET_IPV4_DST; actions[actions_counter].conf = &set_ipv4[para.core_idx]; @@ -348,7 +348,7 @@ add_set_src_tp(struct rte_flow_action *actions, /* TP src port is random each time */ tp = tp % 0xffff; - set_tp[para.core_idx].port = RTE_BE16(tp & 0xffff); + set_tp[para.core_idx].port = rte_cpu_to_be_16(tp & 0xffff); actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_SET_TP_SRC; actions[actions_counter].conf = &set_tp[para.core_idx]; @@ -370,7 +370,7 @@ add_set_dst_tp(struct rte_flow_action *actions, if (tp > 0xffff) tp = tp >> 16; - set_tp[para.core_idx].port = RTE_BE16(tp & 0xffff); + set_tp[para.core_idx].port = rte_cpu_to_be_16(tp & 0xffff); actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_SET_TP_DST; actions[actions_counter].conf = &set_tp[para.core_idx]; @@ -388,7 +388,7 @@ add_inc_tcp_ack(struct rte_flow_action *actions, if (!para.unique_data) ack_value = 1; - value[para.core_idx] = RTE_BE32(ack_value); + value[para.core_idx] = rte_cpu_to_be_32(ack_value); actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_INC_TCP_ACK; actions[actions_counter].conf = &value[para.core_idx]; @@ -406,7 +406,7 @@ add_dec_tcp_ack(struct rte_flow_action *actions, if (!para.unique_data) ack_value = 1; - value[para.core_idx] = RTE_BE32(ack_value); + value[para.core_idx] = rte_cpu_to_be_32(ack_value); actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK; actions[actions_counter].conf = &value[para.core_idx]; @@ -424,7 +424,7 @@ add_inc_tcp_seq(struct rte_flow_action *actions, if (!para.unique_data) seq_value = 1; - value[para.core_idx] = RTE_BE32(seq_value); + value[para.core_idx] = rte_cpu_to_be_32(seq_value); actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ; actions[actions_counter].conf = &value[para.core_idx]; @@ -442,7 +442,7 @@ add_dec_tcp_seq(struct rte_flow_action *actions, if (!para.unique_data) seq_value = 1; - value[para.core_idx] = RTE_BE32(seq_value); + value[para.core_idx] = rte_cpu_to_be_32(seq_value); actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ; actions[actions_counter].conf = &value[para.core_idx]; @@ -560,7 +560,7 @@ add_vlan_header(uint8_t **header, uint64_t data, vlan_value = VLAN_VALUE; memset(&vlan_hdr, 0, sizeof(struct rte_vlan_hdr)); - vlan_hdr.vlan_tci = RTE_BE16(vlan_value); + vlan_hdr.vlan_tci = rte_cpu_to_be_16(vlan_value); if (data & FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_IPV4)) vlan_hdr.eth_proto = RTE_BE16(RTE_ETHER_TYPE_IPV4); @@ -586,7 +586,7 @@ add_ipv4_header(uint8_t **header, uint64_t data, memset(&ipv4_hdr, 0, sizeof(struct rte_ipv4_hdr)); ipv4_hdr.src_addr = RTE_IPV4(127, 0, 0, 1); - ipv4_hdr.dst_addr = RTE_BE32(ip_dst); + ipv4_hdr.dst_addr = rte_cpu_to_be_32(ip_dst); ipv4_hdr.version_ihl = RTE_IPV4_VHL_DEF; if (data & FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_UDP)) ipv4_hdr.next_proto_id = RTE_IP_TYPE_UDP; @@ -652,7 +652,7 @@ add_vxlan_header(uint8_t **header, uint64_t data, memset(&vxlan_hdr, 0, sizeof(struct rte_vxlan_hdr)); - vxlan_hdr.vx_vni = (RTE_BE32(vni_value)) >> 16; + vxlan_hdr.vx_vni = (rte_cpu_to_be_32(vni_value)) >> 16; vxlan_hdr.vx_flags = 0x8; memcpy(*header, &vxlan_hdr, sizeof(vxlan_hdr)); @@ -675,7 +675,7 @@ add_vxlan_gpe_header(uint8_t **header, uint64_t data, memset(&vxlan_gpe_hdr, 0, sizeof(struct rte_vxlan_gpe_hdr)); - vxlan_gpe_hdr.vx_vni = (RTE_BE32(vni_value)) >> 16; + vxlan_gpe_hdr.vx_vni = (rte_cpu_to_be_32(vni_value)) >> 16; vxlan_gpe_hdr.vx_flags = 0x0c; memcpy(*header, &vxlan_gpe_hdr, sizeof(vxlan_gpe_hdr)); @@ -739,7 +739,7 @@ add_gtp_header(uint8_t **header, uint64_t data, memset(>p_hdr, 0, sizeof(struct rte_flow_item_gtp)); - gtp_hdr.teid = RTE_BE32(teid_value); + gtp_hdr.teid = rte_cpu_to_be_32(teid_value); gtp_hdr.msg_type = 255; memcpy(*header, >p_hdr, sizeof(gtp_hdr)); @@ -861,7 +861,7 @@ add_vxlan_encap(struct rte_flow_action *actions, items[0].type = RTE_FLOW_ITEM_TYPE_ETH; item_ipv4.hdr.src_addr = RTE_IPV4(127, 0, 0, 1); - item_ipv4.hdr.dst_addr = RTE_BE32(ip_dst); + item_ipv4.hdr.dst_addr = rte_cpu_to_be_32(ip_dst); item_ipv4.hdr.version_ihl = RTE_IPV4_VHL_DEF; items[1].spec = &item_ipv4; items[1].mask = &item_ipv4; diff --git a/app/test-flow-perf/items_gen.c b/app/test-flow-perf/items_gen.c index 85928349ee..b4aa1cfc9c 100644 --- a/app/test-flow-perf/items_gen.c +++ b/app/test-flow-perf/items_gen.c @@ -56,7 +56,7 @@ 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; - ipv4_specs[ti].hdr.src_addr = RTE_BE32(para.src_ip); + ipv4_specs[ti].hdr.src_addr = rte_cpu_to_be_32(para.src_ip); ipv4_masks[ti].hdr.src_addr = RTE_BE32(0xffffffff); items[items_counter].type = RTE_FLOW_ITEM_TYPE_IPV4; -- 2.27.0