From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id F2E4BA09EF; Wed, 16 Dec 2020 15:26:03 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8282CC9C4; Wed, 16 Dec 2020 15:25:30 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id CD1A9C9B8 for ; Wed, 16 Dec 2020 15:25:26 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from shirik@nvidia.com) with SMTP; 16 Dec 2020 16:25:24 +0200 Received: from nvidia.com (c-236-2-60-065.mtl.labs.mlnx [10.236.2.65]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 0BGEPF6d015188; Wed, 16 Dec 2020 16:25:24 +0200 From: Shiri Kuzin To: dev@dpdk.org Cc: viacheslavo@nvidia.com, adrien.mazarguil@6wind.com, rasland@nvidia.com Date: Wed, 16 Dec 2020 16:25:07 +0200 Message-Id: <20201216142511.13660-3-shirik@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20201216142511.13660-1-shirik@nvidia.com> References: <1599118768-13265-1-git-send-email-shirik@nvidia.com> <20201216142511.13660-1-shirik@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [RFC 2/6] app/testpmd: add GTP PSC option support in raw sets 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" From: Viacheslav Ovsiienko This patch add support for generating GTP PDU container session option for the raw encap and raw decap sets. The generated options is single 32-bit word with minimal length specified as 4, no extra fields in the option are supported. The option item must be preceded with the GTP item itself, and GTP item flags must be set accordingly: - E flag must be set, we are going to provide extension - S flag must be reset, because GTP item does not provide the value for SQN field, we can't fill this one - PN flag must be reset, no N-PDU value provided by GTP item either The raw set example: set raw_encap 2 eth / ipv4 / udp / gtp v_pt_rsv_flags is 0x34 / gtp_psc / end_set Please, note - value 0x34 provides the required flag combination. Signed-off-by: Viacheslav Ovsiienko --- app/test-pmd/cmdline_flow.c | 66 +++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 3 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 585cab98b4..7e84207015 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -7581,6 +7581,7 @@ cmd_set_raw_parsed(const struct buffer *in) uint16_t upper_layer = 0; uint16_t proto = 0; uint16_t idx = in->port; /* We borrow port field as index */ + int gtp_psc = -1; /* GTP PSC option index. */ if (in->command == SET_SAMPLE_ACTIONS) return cmd_set_raw_parsed_sample(in); @@ -7598,6 +7599,8 @@ cmd_set_raw_parsed(const struct buffer *in) /* process hdr from upper layer to low layer (L3/L4 -> L2). */ data_tail = data + ACTION_RAW_ENCAP_MAX_DATA; for (i = n - 1 ; i >= 0; --i) { + const struct rte_flow_item_gtp *gtp; + item = in->args.vc.pattern + i; if (item->spec == NULL) item->spec = flow_item_default_mask(item); @@ -7663,16 +7666,68 @@ cmd_set_raw_parsed(const struct buffer *in) proto = 0x33; break; case RTE_FLOW_ITEM_TYPE_GTP: + if (gtp_psc < 0) { + size = sizeof(struct rte_gtp_hdr); + break; + } + if (gtp_psc != i + 1) { + printf("Error - GTP PSC does not follow GTP\n"); + goto error; + } + gtp = item->spec; + if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) { + /* Only E flag shoudl be set. */ + printf("Error - GTP unsupported flags\n"); + goto error; + } else { + struct rte_gtp_hdr_ext_word ext_word = { + .next_ext = 0x85 + }; + + /* We have to add GTP header extra word. */ + *total_size += sizeof(ext_word); + rte_memcpy(data_tail - (*total_size), + &ext_word, sizeof(ext_word)); + } size = sizeof(struct rte_gtp_hdr); break; + case RTE_FLOW_ITEM_TYPE_GTP_PSC: + if (gtp_psc >= 0) { + printf("Error - Multiple GTP PSC items\n"); + goto error; + } else { + const struct rte_flow_item_gtp_psc + *opt = item->spec; + struct { + uint8_t len; + uint8_t pdu_type; + uint8_t qfi; + uint8_t next; + } psc; + + if (opt->pdu_type & 0x0F) { + /* Support the minimal option only. */ + printf("Error - GTP PSC option with " + "extra fields not supported\n"); + goto error; + } + psc.len = sizeof(psc); + psc.pdu_type = opt->pdu_type; + psc.qfi = opt->qfi; + psc.next = 0; + *total_size += sizeof(psc); + rte_memcpy(data_tail - (*total_size), + &psc, sizeof(psc)); + gtp_psc = i; + size = 0; + } + break; case RTE_FLOW_ITEM_TYPE_PFCP: size = sizeof(struct rte_flow_item_pfcp); break; default: printf("Error - Not supported item\n"); - *total_size = 0; - memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA); - return; + goto error; } *total_size += size; rte_memcpy(data_tail - (*total_size), item->spec, size); @@ -7685,6 +7740,11 @@ cmd_set_raw_parsed(const struct buffer *in) printf("total data size is %zu\n", (*total_size)); RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA); memmove(data, (data_tail - (*total_size)), *total_size); + return; + +error: + *total_size = 0; + memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA); } /** Populate help strings for current token (cmdline API). */ -- 2.21.0