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 3C88AA034E; Fri, 21 Jan 2022 11:33:03 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A21A54279E; Fri, 21 Jan 2022 11:31:50 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 233E642780 for ; Fri, 21 Jan 2022 11:31:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642761108; x=1674297108; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2wiI4pWI4PvoTw8Q2rDPFJLJwm7iFiWlvhUD830pNUg=; b=QjhyLEospPgb2dT5Ear1ayXBXU+ai4c48PKcgg2IzwSR1ypg6LASyELQ K19q3+npiAJ/vwThad69n5Heme5Tq5V/qaRL1DyOKsDbWg6bHuVfftbXW 3hQKqXdf6B386gZ75Yb5pbbdmuTLF6RLsqb13jX6DH9zTSqxfGlgFJEFS nzMpETiAIWZWTQZc/DrgD418L2OjuOSNGXZdCNJpdQAKFpFo4Tw2K3VJo dq8edCSgNtP4r4xMtSliXCnUZGdPlPdy1gP+kvLKozhhpAPx2NJRFEBoP zFDwk9nCKF3DUhK5j6PAEwtwu7PH+PVYFbKAGc01DGMa2NJ2r5Kf8R4Ma g==; X-IronPort-AV: E=McAfee;i="6200,9189,10233"; a="270045161" X-IronPort-AV: E=Sophos;i="5.88,304,1635231600"; d="scan'208";a="270045161" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jan 2022 02:31:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,304,1635231600"; d="scan'208";a="533222808" Received: from silpixa00401120.ir.intel.com ([10.55.128.255]) by orsmga008.jf.intel.com with ESMTP; 21 Jan 2022 02:31:46 -0800 From: Ronan Randles To: dev@dpdk.org Cc: Ronan Randles Subject: [PATCH v2 15/15] gen: add VXLAN support Date: Fri, 21 Jan 2022 10:31:22 +0000 Message-Id: <20220121103122.2926856-16-ronan.randles@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220121103122.2926856-1-ronan.randles@intel.com> References: <20211214141242.3383831-1-ronan.randles@intel.com> <20220121103122.2926856-1-ronan.randles@intel.com> 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 This commit adds VXLAN parsing and logging functionality. Unit test with additional test case to test_gen_packet_parse_string. Signed-off-by: Ronan Randles --- app/test/test_gen.c | 1 + lib/gen/rte_gen.c | 50 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/app/test/test_gen.c b/app/test/test_gen.c index a0b00d6a6e..f05851831a 100644 --- a/app/test/test_gen.c +++ b/app/test/test_gen.c @@ -138,6 +138,7 @@ test_gen_packet_parse_string(void) { .str = "Ether()/IP(src=1.2.3.fail,dst=5.6.7.8)", .expected_to_fail = 1}, { .str = "Ether()/IP()/UDP()"}, + { .str = "Ether()/IP()/UDP()/VXLAN()"}, }; uint32_t i; diff --git a/lib/gen/rte_gen.c b/lib/gen/rte_gen.c index 3a67ce8b6c..431ffc5b2a 100644 --- a/lib/gen/rte_gen.c +++ b/lib/gen/rte_gen.c @@ -12,6 +12,7 @@ #include #include #include +#include RTE_LOG_REGISTER(gen_logtype, lib.gen, NOTICE); @@ -140,6 +141,7 @@ enum GEN_PROTO { GEN_PROTO_ETHER, GEN_PROTO_IPV4, GEN_PROTO_UDP, + GEN_PROTO_VXLAN, /* Must be last. */ GEN_PROTO_COUNT, @@ -472,6 +474,10 @@ gen_parse_udp(struct gen_parser *parser, char *protocol_str) int err = gen_parser_parse_next(parser, &inner); switch (inner) { + case GEN_PROTO_VXLAN: + udp->src_port = rte_cpu_to_be_16(RTE_VXLAN_DEFAULT_PORT); + udp->dst_port = rte_cpu_to_be_16(RTE_VXLAN_DEFAULT_PORT); + break; default: /* default to DNS like other packet generation tools */ udp->src_port = rte_cpu_to_be_16(53); @@ -490,6 +496,44 @@ gen_parse_udp(struct gen_parser *parser, char *protocol_str) return err; } +static int32_t +gen_parse_vxlan(struct gen_parser *parser, char *protocol_str) +{ + RTE_SET_USED(protocol_str); + struct rte_vxlan_hdr *vxlan = gen_parser_get_data_ptr(parser); + memset(vxlan, 0, sizeof(*vxlan)); + + uint32_t input_vni = 1000; + vxlan->vx_vni = rte_cpu_to_be_32(input_vni << 8); + + /* Move up write pointer in packet. */ + parser->buf_write_offset += sizeof(*vxlan); + + enum GEN_PROTO inner; + int err = gen_parser_parse_next(parser, &inner); + + vxlan->vx_flag_bits = RTE_VXLAN_FLAGS_I; + + switch (inner) { + default: + /* Not supporting VXLAN-GPE and next proto today. */ + break; + } + + return err; +} + +static void +gen_log_vxlan(void *data, const char *indent) +{ + struct rte_vxlan_hdr *vxlan = data; + + GEN_LOG_PROTOCOL(DEBUG, + "###[ VXLAN ]###\n%svx_flags= %u\n%svx_vni= %u\n", + indent, rte_be_to_cpu_32(vxlan->vx_flags), + indent, rte_be_to_cpu_32(vxlan->vx_vni)); +} + /* (Name, Function-pointer) pairs for supported parse types */ typedef int32_t (*gen_parse_func)(struct gen_parser *parser, char *protocol_str); @@ -520,6 +564,12 @@ static struct gen_parse_func_t gen_protocols[] = { .proto = GEN_PROTO_UDP, .parse_func = gen_parse_udp, .log_func = gen_log_udp, + }, + { + .name = "VXLAN(", + .proto = GEN_PROTO_VXLAN, + .parse_func = gen_parse_vxlan, + .log_func = gen_log_vxlan, } }; -- 2.25.1