From patchwork Thu Feb 9 09:02:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 93674 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp150516qgi; Thu, 9 Feb 2017 01:03:09 -0800 (PST) X-Received: by 10.200.41.175 with SMTP id 44mr1889603qts.53.1486630989890; Thu, 09 Feb 2017 01:03:09 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id n4si7554463qtb.99.2017.02.09.01.03.09; Thu, 09 Feb 2017 01:03:09 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 3FDB262EB3; Thu, 9 Feb 2017 09:03:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 2287A60D2A; Thu, 9 Feb 2017 09:03:04 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 5AD8960D2E; Thu, 9 Feb 2017 09:02:59 +0000 (UTC) Received: from mail-pf0-f171.google.com (mail-pf0-f171.google.com [209.85.192.171]) by lists.linaro.org (Postfix) with ESMTPS id 4833A60C3A for ; Thu, 9 Feb 2017 09:02:58 +0000 (UTC) Received: by mail-pf0-f171.google.com with SMTP id f144so49055714pfa.2 for ; Thu, 09 Feb 2017 01:02:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=3vzvlGPjLUy3Bu0J7f2F2kIyIw4PQfZ7dHZxiVl5vHw=; b=mAcuPd6UyAdpHYutuJYq+N/L/PyYkMu5XxebBc876ZDLG9T2DgJ1s6cz/kv6alx+Yk 9I0v0xZE1TXJ4pf3hevFU4dowJAQdaCHLxFySKoE4cAN5dMq5L6r2tXX1g7dV0X6xTg6 5yQVj7yIViMuqTUSKh+IsD86i7QScX4r5Qh+RPXWEC6+bUTu8JYzSjp08YUqbFcA/wMr EhbtnxAS9IgjRNWuhyo9PGZ5RrZ/CO/qwcO4nzkjMV+Yc+dcEIorTGo1EtFvo9n5m515 eTrt9DywMafMWbIVI2d+8f4tVGXntcpl548LFL16AIu5MLMk2HQswpXIwAJcm1d4zBtr 8OMQ== X-Gm-Message-State: AMke39kGePFHe5FRapSWden8KdUGryZGeKuHhY412YvBBzKJ/gHG4c20knhDp93ScVLp07vJqzo= X-Received: by 10.98.80.146 with SMTP id g18mr2518258pfj.74.1486630977369; Thu, 09 Feb 2017 01:02:57 -0800 (PST) Received: from localhost.localdomain ([122.171.225.13]) by smtp.gmail.com with ESMTPSA id c64sm26773093pfa.45.2017.02.09.01.02.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Feb 2017 01:02:56 -0800 (PST) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Thu, 9 Feb 2017 14:32:35 +0530 Message-Id: <1486630956-12293-1-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 Subject: [lng-odp] [PATCHv1 1/2] linux-generic: classification: implement vlan id packet matching rule X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Add implementation for outer and inner vlan ID packet matching rule Signed-off-by: Balasubramanian Manoharan --- .../include/odp_classification_inlines.h | 41 +++++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) -- 1.9.1 diff --git a/platform/linux-generic/include/odp_classification_inlines.h b/platform/linux-generic/include/odp_classification_inlines.h index e6f9be9..c9517d6 100644 --- a/platform/linux-generic/include/odp_classification_inlines.h +++ b/platform/linux-generic/include/odp_classification_inlines.h @@ -231,11 +231,26 @@ static inline int verify_pmr_ipv6_daddr(const uint8_t *pkt_addr, return 0; } -static inline int verify_pmr_vlan_id_0(const uint8_t *pkt_addr ODP_UNUSED, - odp_packet_hdr_t *pkt_hdr ODP_UNUSED, - pmr_term_value_t *term_value ODP_UNUSED) +static inline int verify_pmr_vlan_id_0(const uint8_t *pkt_addr, + odp_packet_hdr_t *pkt_hdr, + pmr_term_value_t *term_value) { - ODP_UNIMPLEMENTED(); + const _odp_ethhdr_t *eth; + const _odp_vlanhdr_t *vlan; + uint16_t tci; + uint16_t vlan_id; + + if (!pkt_hdr->p.input_flags.vlan_qinq) + return 0; + + eth = (const _odp_ethhdr_t *)(pkt_addr + pkt_hdr->p.l2_offset); + vlan = (const _odp_vlanhdr_t *)(eth + 1); + tci = odp_be_to_cpu_16(vlan->tci); + vlan_id = tci & 0x0fff; + + if (term_value->match.value == (vlan_id & term_value->match.mask)) + return 1; + return 0; } @@ -243,7 +258,23 @@ static inline int verify_pmr_vlan_id_x(const uint8_t *pkt_addr ODP_UNUSED, odp_packet_hdr_t *pkt_hdr ODP_UNUSED, pmr_term_value_t *term_value ODP_UNUSED) { - ODP_UNIMPLEMENTED(); + const _odp_ethhdr_t *eth; + const _odp_vlanhdr_t *vlan; + uint16_t tci; + uint16_t vlan_id; + + if (!pkt_hdr->p.input_flags.vlan_qinq) + return 0; + + eth = (const _odp_ethhdr_t *)(pkt_addr + pkt_hdr->p.l2_offset); + vlan = (const _odp_vlanhdr_t *)(eth + 1); + vlan++; + tci = odp_be_to_cpu_16(vlan->tci); + vlan_id = tci & 0x0fff; + + if (term_value->match.value == (vlan_id & term_value->match.mask)) + return 1; + return 0; } From patchwork Thu Feb 9 09:02:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 93675 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp150672qgi; Thu, 9 Feb 2017 01:03:37 -0800 (PST) X-Received: by 10.55.126.2 with SMTP id z2mr1745172qkc.178.1486631017038; Thu, 09 Feb 2017 01:03:37 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id d39si7538126qtf.224.2017.02.09.01.03.36; Thu, 09 Feb 2017 01:03:37 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id AE8A660E8A; Thu, 9 Feb 2017 09:03:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 834C560E91; Thu, 9 Feb 2017 09:03:06 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id C92A860D2E; Thu, 9 Feb 2017 09:03:01 +0000 (UTC) Received: from mail-pg0-f50.google.com (mail-pg0-f50.google.com [74.125.83.50]) by lists.linaro.org (Postfix) with ESMTPS id 16A5E60C3A for ; Thu, 9 Feb 2017 09:03:00 +0000 (UTC) Received: by mail-pg0-f50.google.com with SMTP id 204so56374094pge.0 for ; Thu, 09 Feb 2017 01:03:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EQQiDDYHxvVowwBSxa9YVQToLcVYmmStx5vbCmDpKyg=; b=rdFj3N32K/Ib4z85wmBTq+QhIFcJfcbks1g0H7aboFYrhOuy34pvdEJ4YfMUyhrYvg 8ynnhaRMavszghPC+NwxjceNboSRtRUKNiy0PstkeFmaxyRDN8ENxVJUTEZogYu7XTGk pRjV1Tw2QJSLjJY3dsxp9exK8IN8qtu9vQ28Sm/G1PF5sdjrc9Leg5w5D4iow03wXlq6 4U1xcabgJtnnpFXaZRtBi3gIuB7+KflhFMe2Jb8zrYfWfDM7FmXo9DIpWdH35TOQpegd 6dj5523j20Yr1pyIvgET5sTFTwvnsDmrwqGcIQxqNyAQWpJDjM0aEoX1pHUTQgLd8l0k ygNQ== X-Gm-Message-State: AMke39mHgesr+QXCRu7Lxv2xX2g0IeaeGkek445+azFI3oPtM4TdV7qFk4QxnmsJXlcBmnCvcWk= X-Received: by 10.84.245.1 with SMTP id i1mr2794783pll.131.1486630979206; Thu, 09 Feb 2017 01:02:59 -0800 (PST) Received: from localhost.localdomain ([122.171.225.13]) by smtp.gmail.com with ESMTPSA id c64sm26773093pfa.45.2017.02.09.01.02.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Feb 2017 01:02:58 -0800 (PST) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Thu, 9 Feb 2017 14:32:36 +0530 Message-Id: <1486630956-12293-2-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1486630956-12293-1-git-send-email-bala.manoharan@linaro.org> References: <1486630956-12293-1-git-send-email-bala.manoharan@linaro.org> Subject: [lng-odp] [PATCHv1 2/2] validation: classification: add test case for outer and inner vlan id X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Adds test case for outer and inner vlan id packet matching rule Signed-off-by: Balasubramanian Manoharan --- .../validation/api/classification/classification.h | 2 + .../api/classification/odp_classification_common.c | 17 +- .../classification/odp_classification_test_pmr.c | 229 +++++++++++++++++++++ .../classification/odp_classification_testsuites.h | 4 +- 4 files changed, 246 insertions(+), 6 deletions(-) -- 1.9.1 diff --git a/test/common_plat/validation/api/classification/classification.h b/test/common_plat/validation/api/classification/classification.h index 0192e24..66e3208 100644 --- a/test/common_plat/validation/api/classification/classification.h +++ b/test/common_plat/validation/api/classification/classification.h @@ -98,6 +98,8 @@ void classification_test_pmr_term_udp_sport(void); void classification_test_pmr_term_ipproto(void); void classification_test_pmr_term_dmac(void); void classification_test_pmr_term_packet_len(void); +void classification_test_pmr_term_vlan_id_0(void); +void classification_test_pmr_term_vlan_id_x(void); /* test arrays: */ extern odp_testinfo_t classification_suite_basic[]; diff --git a/test/common_plat/validation/api/classification/odp_classification_common.c b/test/common_plat/validation/api/classification/odp_classification_common.c index 0ca9083..3b379c1 100644 --- a/test/common_plat/validation/api/classification/odp_classification_common.c +++ b/test/common_plat/validation/api/classification/odp_classification_common.c @@ -245,6 +245,8 @@ odp_packet_t create_packet(cls_packet_info_t pkt_info) uint16_t l3_hdr_len = 0; uint16_t l4_hdr_len = 0; uint16_t eth_type; + odp_u16be_t *vlan_type; + odph_vlanhdr_t *vlan_hdr; /* 48 bit ethernet address needs to be left shifted for proper value after changing to be*/ @@ -256,6 +258,7 @@ odp_packet_t create_packet(cls_packet_info_t pkt_info) seqno = odp_atomic_fetch_inc_u32(pkt_info.seq); vlan_hdr_len = pkt_info.vlan ? ODPH_VLANHDR_LEN : 0; + vlan_hdr_len = pkt_info.vlan_qinq ? 2 * vlan_hdr_len : vlan_hdr_len; l3_hdr_len = pkt_info.ipv6 ? ODPH_IPV6HDR_LEN : ODPH_IPV4HDR_LEN; l4_hdr_len = pkt_info.udp ? ODPH_UDPHDR_LEN : ODPH_TCPHDR_LEN; eth_type = pkt_info.ipv6 ? ODPH_ETHTYPE_IPV6 : ODPH_ETHTYPE_IPV4; @@ -275,12 +278,20 @@ odp_packet_t create_packet(cls_packet_info_t pkt_info) ethhdr = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL); memcpy(ethhdr->src.addr, &src_mac, ODPH_ETHADDR_LEN); memcpy(ethhdr->dst.addr, &dst_mac_be, ODPH_ETHADDR_LEN); + vlan_type = (odp_u16be_t *)ðhdr->type; + vlan_hdr = (odph_vlanhdr_t *)(ethhdr + 1); + + if (pkt_info.vlan_qinq) { + odp_packet_has_vlan_qinq_set(pkt, 1); + *vlan_type = odp_cpu_to_be_16(ODPH_ETHTYPE_VLAN_OUTER); + vlan_hdr->tci = odp_cpu_to_be_16(0); + vlan_type = (uint16_t *)&vlan_hdr->type; + vlan_hdr++; + } if (pkt_info.vlan) { /* Default vlan header */ - odph_vlanhdr_t *vlan_hdr; odp_packet_has_vlan_set(pkt, 1); - ethhdr->type = odp_cpu_to_be_16(ODPH_ETHTYPE_VLAN); - vlan_hdr = (odph_vlanhdr_t *)(ethhdr + 1); + *vlan_type = odp_cpu_to_be_16(ODPH_ETHTYPE_VLAN); vlan_hdr->tci = odp_cpu_to_be_16(0); vlan_hdr->type = odp_cpu_to_be_16(eth_type); } else { diff --git a/test/common_plat/validation/api/classification/odp_classification_test_pmr.c b/test/common_plat/validation/api/classification/odp_classification_test_pmr.c index c714549..d01f716 100644 --- a/test/common_plat/validation/api/classification/odp_classification_test_pmr.c +++ b/test/common_plat/validation/api/classification/odp_classification_test_pmr.c @@ -870,6 +870,233 @@ void classification_test_pmr_term_packet_len(void) odp_pktio_close(pktio); } +void classification_test_pmr_term_vlan_id_0(void) +{ + odp_packet_t pkt; + uint32_t seqno; + uint16_t val; + uint16_t mask; + int retval; + odp_pktio_t pktio; + odp_queue_t queue; + odp_queue_t retqueue; + odp_queue_t default_queue; + odp_cos_t default_cos; + odp_pool_t default_pool; + odp_pool_t pool; + odp_pool_t recvpool; + odp_pmr_t pmr; + odp_cos_t cos; + char cosname[ODP_COS_NAME_LEN]; + odp_cls_cos_param_t cls_param; + odp_pmr_param_t pmr_param; + odph_ethhdr_t *eth; + odph_vlanhdr_t *vlan_0; + cls_packet_info_t pkt_info; + + val = 1024; + mask = 0xff00; + seqno = 0; + + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool); + CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); + retval = start_pktio(pktio); + CU_ASSERT(retval == 0); + + configure_default_cos(pktio, &default_cos, + &default_queue, &default_pool); + + queue = queue_create("vlan_id_0", true); + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); + + pool = pool_create("vlan_id_0"); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + sprintf(cosname, "vlan_id_0"); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool; + cls_param.queue = queue; + cls_param.drop_policy = ODP_COS_DROP_POOL; + + cos = odp_cls_cos_create(cosname, &cls_param); + CU_ASSERT_FATAL(cos != ODP_COS_INVALID); + + odp_cls_pmr_param_init(&pmr_param); + pmr_param.term = ODP_PMR_VLAN_ID_0; + pmr_param.match.value = &val; + pmr_param.match.mask = &mask; + pmr_param.val_sz = sizeof(val); + + pmr = odp_cls_pmr_create(&pmr_param, 1, default_cos, cos); + CU_ASSERT(pmr != ODP_PMR_INVAL); + + /* create packet of payload length 1024 */ + pkt_info = default_pkt_info; + pkt_info.vlan = true; + pkt_info.vlan_qinq = true; + pkt = create_packet(pkt_info); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + seqno = cls_pkt_get_seq(pkt); + CU_ASSERT(seqno != TEST_SEQ_INVALID); + eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL); + odp_pktio_mac_addr(pktio, eth->src.addr, ODPH_ETHADDR_LEN); + odp_pktio_mac_addr(pktio, eth->dst.addr, ODPH_ETHADDR_LEN); + vlan_0 = (odph_vlanhdr_t *)(eth + 1); + vlan_0->tci = odp_cpu_to_be_16(1024); + enqueue_pktio_interface(pkt, pktio); + + pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); + recvpool = odp_packet_pool(pkt); + CU_ASSERT(recvpool == pool); + CU_ASSERT(retqueue == queue); + odp_packet_free(pkt); + + /* Other packets delivered to default queue */ + pkt = create_packet(default_pkt_info); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + seqno = cls_pkt_get_seq(pkt); + CU_ASSERT(seqno != TEST_SEQ_INVALID); + eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL); + odp_pktio_mac_addr(pktio, eth->src.addr, ODPH_ETHADDR_LEN); + odp_pktio_mac_addr(pktio, eth->dst.addr, ODPH_ETHADDR_LEN); + + enqueue_pktio_interface(pkt, pktio); + + pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); + recvpool = odp_packet_pool(pkt); + CU_ASSERT(recvpool == default_pool); + CU_ASSERT(retqueue == default_queue); + + odp_cos_destroy(cos); + odp_cos_destroy(default_cos); + odp_cls_pmr_destroy(pmr); + odp_packet_free(pkt); + stop_pktio(pktio); + odp_pool_destroy(default_pool); + odp_pool_destroy(pool); + odp_queue_destroy(queue); + odp_queue_destroy(default_queue); + odp_pktio_close(pktio); +} + +void classification_test_pmr_term_vlan_id_x(void) +{ + odp_packet_t pkt; + uint32_t seqno; + uint16_t val; + uint16_t mask; + int retval; + odp_pktio_t pktio; + odp_queue_t queue; + odp_queue_t retqueue; + odp_queue_t default_queue; + odp_cos_t default_cos; + odp_pool_t default_pool; + odp_pool_t pool; + odp_pool_t recvpool; + odp_pmr_t pmr; + odp_cos_t cos; + char cosname[ODP_COS_NAME_LEN]; + odp_cls_cos_param_t cls_param; + odp_pmr_param_t pmr_param; + odph_ethhdr_t *eth; + odph_vlanhdr_t *vlan_x; + cls_packet_info_t pkt_info; + + val = 1024; + mask = 0xff00; + seqno = 0; + + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool); + CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); + retval = start_pktio(pktio); + CU_ASSERT(retval == 0); + + configure_default_cos(pktio, &default_cos, + &default_queue, &default_pool); + + queue = queue_create("vlan_id_x", true); + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); + + pool = pool_create("vlan_id_x"); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + sprintf(cosname, "vlan_id_x"); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool; + cls_param.queue = queue; + cls_param.drop_policy = ODP_COS_DROP_POOL; + + cos = odp_cls_cos_create(cosname, &cls_param); + CU_ASSERT_FATAL(cos != ODP_COS_INVALID); + + odp_cls_pmr_param_init(&pmr_param); + pmr_param.term = ODP_PMR_VLAN_ID_X; + pmr_param.match.value = &val; + pmr_param.match.mask = &mask; + pmr_param.val_sz = sizeof(val); + + pmr = odp_cls_pmr_create(&pmr_param, 1, default_cos, cos); + CU_ASSERT(pmr != ODP_PMR_INVAL); + + /* create packet of payload length 1024 */ + pkt_info = default_pkt_info; + pkt_info.vlan = true; + pkt_info.vlan_qinq = true; + pkt = create_packet(pkt_info); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + seqno = cls_pkt_get_seq(pkt); + CU_ASSERT(seqno != TEST_SEQ_INVALID); + eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL); + odp_pktio_mac_addr(pktio, eth->src.addr, ODPH_ETHADDR_LEN); + odp_pktio_mac_addr(pktio, eth->dst.addr, ODPH_ETHADDR_LEN); + vlan_x = (odph_vlanhdr_t *)(eth + 1); + vlan_x++; + vlan_x->tci = odp_cpu_to_be_16(1024); + enqueue_pktio_interface(pkt, pktio); + + pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); + recvpool = odp_packet_pool(pkt); + CU_ASSERT(recvpool == pool); + CU_ASSERT(retqueue == queue); + odp_packet_free(pkt); + + /* Other packets delivered to default queue */ + pkt = create_packet(default_pkt_info); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + seqno = cls_pkt_get_seq(pkt); + CU_ASSERT(seqno != TEST_SEQ_INVALID); + eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL); + odp_pktio_mac_addr(pktio, eth->src.addr, ODPH_ETHADDR_LEN); + odp_pktio_mac_addr(pktio, eth->dst.addr, ODPH_ETHADDR_LEN); + + enqueue_pktio_interface(pkt, pktio); + + pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); + recvpool = odp_packet_pool(pkt); + CU_ASSERT(recvpool == default_pool); + CU_ASSERT(retqueue == default_queue); + + odp_cos_destroy(cos); + odp_cos_destroy(default_cos); + odp_cls_pmr_destroy(pmr); + odp_packet_free(pkt); + stop_pktio(pktio); + odp_pool_destroy(default_pool); + odp_pool_destroy(pool); + odp_queue_destroy(queue); + odp_queue_destroy(default_queue); + odp_pktio_close(pktio); +} + static void classification_test_pmr_pool_set(void) { odp_packet_t pkt; @@ -1407,5 +1634,7 @@ odp_testinfo_t classification_suite_pmr[] = { ODP_TEST_INFO(classification_test_pmr_term_ipv6saddr), ODP_TEST_INFO(classification_test_pmr_term_ipv6daddr), ODP_TEST_INFO(classification_test_pmr_term_packet_len), + ODP_TEST_INFO(classification_test_pmr_term_vlan_id_0), + ODP_TEST_INFO(classification_test_pmr_term_vlan_id_x), ODP_TEST_INFO_NULL, }; diff --git a/test/common_plat/validation/api/classification/odp_classification_testsuites.h b/test/common_plat/validation/api/classification/odp_classification_testsuites.h index d5ffef7..d296923 100644 --- a/test/common_plat/validation/api/classification/odp_classification_testsuites.h +++ b/test/common_plat/validation/api/classification/odp_classification_testsuites.h @@ -15,6 +15,7 @@ typedef struct cls_packet_info { odp_pool_t pool; bool vlan; + bool vlan_qinq; odp_atomic_u32_t *seq; bool udp; bool ipv6; @@ -32,9 +33,6 @@ int classification_suite_pmr_term(void); int classification_suite_pmr_init(void); odp_packet_t create_packet(cls_packet_info_t pkt_info); -odp_packet_t create_packet_len(odp_pool_t pool, bool vlan, - odp_atomic_u32_t *seq, bool flag_udp, - bool ipv4, uint16_t len); int cls_pkt_set_seq(odp_packet_t pkt); uint32_t cls_pkt_get_seq(odp_packet_t pkt); odp_pktio_t create_pktio(odp_queue_type_t q_type, odp_pool_t pool);