From patchwork Mon Dec 28 09:25:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: taoyunxiang X-Patchwork-Id: 1420953 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cmss.chinamobile.com Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D4QbF5Kmnz9sWL for ; Tue, 29 Dec 2020 05:11:05 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 210CA8710A; Mon, 28 Dec 2020 18:11:04 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tQ+UJ-OeYE0z; Mon, 28 Dec 2020 18:11:00 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 5A3F787027; Mon, 28 Dec 2020 18:11:00 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0DC50C1E03; Mon, 28 Dec 2020 18:11:00 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7A76EC1DA4 for ; Mon, 28 Dec 2020 09:26:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 69BF386C71 for ; Mon, 28 Dec 2020 09:26:06 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lDzHNgoBASAg for ; Mon, 28 Dec 2020 09:26:04 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from cmccmta3.chinamobile.com (cmccmta3.chinamobile.com [221.176.66.81]) by whitealder.osuosl.org (Postfix) with ESMTP id AE6C286C92 for ; Mon, 28 Dec 2020 09:26:03 +0000 (UTC) Received: from spf.mail.chinamobile.com (unknown[172.16.121.3]) by rmmx-syy-dmz-app11-12011 (RichMail) with SMTP id 2eeb5fe9a4a5527-c1bce; Mon, 28 Dec 2020 17:25:57 +0800 (CST) X-RM-TRANSID: 2eeb5fe9a4a5527-c1bce X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from yun.localdomain (unknown[112.25.154.146]) by rmsmtp-syy-appsvr02-12002 (RichMail) with SMTP id 2ee25fe9a48a90b-7b8e7; Mon, 28 Dec 2020 17:25:57 +0800 (CST) X-RM-TRANSID: 2ee25fe9a48a90b-7b8e7 From: Tao YunXiang To: ovs-dev@openvswitch.org Date: Mon, 28 Dec 2020 01:25:07 -0800 Message-Id: <20201228092520.11807-50-taoyunxiang@cmss.chinamobile.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201228092520.11807-1-taoyunxiang@cmss.chinamobile.com> References: <8> <20201228092520.11807-1-taoyunxiang@cmss.chinamobile.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 28 Dec 2020 18:10:34 +0000 Cc: Taoyunxiang Subject: [ovs-dev] [PATCH 49/62] Geneve option data which need transformat u32 to u8_array X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Taoyunxiang Code Source From: Self Code Description: Add Geneve option data which need transformat u32 to u8_array. Jira: #[Optional] 市场项目编号(名称):[Optional] --- lib/netdev-offload-dpdk.c | 48 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index 59ecf88..9dc8ae1 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -67,6 +67,44 @@ struct ufid_to_rte_flow_data { struct dpif_flow_stats stats; }; +/* maybe little-endian */ +/* +static void +u32_to_u8_array(uint32_t var, uint8_t array[]) { + uint8_t len, i; + + len = sizeof (var) / sizeof (array[0]); + ovs_assert(len == 4); + + for (i = 3; i <= 0; i--) { + array[i] = var & 0xFF; + var >>= 8; + } +} +*/ + +/* u32 && u8_array transformation */ +static void +u32_to_u8_array(uint32_t var, uint8_t array[]) { + uint8_t len, i; + + len = sizeof (var) / sizeof (array[0]); + ovs_assert(len == 4); + + for (i = 0; i < 4; i++) { + array[i] = var & 0xFF; + var >>= 8; + } +} + +static uint32_t +u8_array_to_u32(uint8_t array[]) { + uint32_t *var; + + var = (uint32_t *)array; + return *var; +} + /* Find rte_flow with @ufid. */ static struct ufid_to_rte_flow_data * ufid_to_rte_flow_data_find(const ovs_u128 *ufid) @@ -431,7 +469,7 @@ dump_flow_pattern(struct ds *s, const struct rte_flow_item *item) ds_put_format(s, "type spec 0x%02x \n", op_spec->type); ds_put_format(s, "len spec %d \n", op_spec->len); ds_put_format(s, "opdata spec 0x%08x \n", - ntohl(op_spec->option_data)); + u8_array_to_u32(op_spec->option_data)); } else { ds_put_cstr(s, " Spec = null\n"); } @@ -440,7 +478,7 @@ dump_flow_pattern(struct ds *s, const struct rte_flow_item *item) ds_put_format(s, "type mask 0x%02x \n", op_mask->type); ds_put_format(s, "len mask %d \n", op_mask->len); ds_put_format(s, "opdata mask 0x%08x \n", - ntohl(op_mask->option_data)); + u8_array_to_u32(op_mask->option_data)); } else { ds_put_cstr(s, " Mask = null\n"); } @@ -833,7 +871,8 @@ parse_geneve_match(struct flow_patterns *patterns, op_spec->class = opt->opt_class; op_spec->type = opt->type; op_spec->len = opt->length; - op_spec->option_data = htonl(opt_data); + /*op_spec->option_data = &opt_data;*/ + u32_to_u8_array(opt_data, op_spec->option_data); add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_GENEVE_OPTIONS, op_spec, op_mask); } @@ -1632,7 +1671,8 @@ add_geneve_encap_action(struct flow_actions *actions, op_spec->class = opt->opt_class; op_spec->type = opt->type; op_spec->len = opt->length; - op_spec->option_data = htonl(opt_data); + /*op_spec->option_data = htonl(opt_data);*/ + u32_to_u8_array(opt_data, op_spec->option_data); geneve_data->items[field].type = RTE_FLOW_ITEM_TYPE_GENEVE_OPTIONS; geneve_data->items[field].spec = op_spec; geneve_data->items[field].mask = &rte_flow_item_geneve_options_mask;