From patchwork Thu Jan 7 16:25:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 59298 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp17611lbb; Thu, 7 Jan 2016 08:29:42 -0800 (PST) X-Received: by 10.140.28.161 with SMTP id 30mr134851041qgz.36.1452184182419; Thu, 07 Jan 2016 08:29:42 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p17si453222qhb.49.2016.01.07.08.29.40; Thu, 07 Jan 2016 08:29:42 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 8908F61794; Thu, 7 Jan 2016 16:29:40 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=g2RS2hqw; dkim-adsp=none (unprotected policy); dkim-atps=neutral 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=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,T_DKIM_INVALID,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 519AB61BBC; Thu, 7 Jan 2016 16:26:37 +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 2380D616F3; Thu, 7 Jan 2016 16:26:23 +0000 (UTC) Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com [209.85.220.47]) by lists.linaro.org (Postfix) with ESMTPS id 5A0FB61817 for ; Thu, 7 Jan 2016 16:26:13 +0000 (UTC) Received: by mail-pa0-f47.google.com with SMTP id cy9so262310344pac.0 for ; Thu, 07 Jan 2016 08:26:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aA+j9jp9fnfge+SF7e8U0wjTt7WqxRpzt73LLjl0rJk=; b=g2RS2hqwYZL3ohTaPgXxYhlKZaW2hEXHBexYwcGu74xFZfZau7oiRMOnhPEyVK4DUD 7aV2TfiEH3PTJvwx9aCT2C8paqTftPqrY8iDlj6ca6M5K3X8AGBwr9ae/oPRsN9WDuEb AaqyyPTFFPpg+vwL+zSeNqTTZ04M3kpqSp/UM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aA+j9jp9fnfge+SF7e8U0wjTt7WqxRpzt73LLjl0rJk=; b=K1nidnAx8mYHM6Zj95F3Wbnnmq8GkQbwieSsN5DSApIrOUi0zeIsvUCDj0Q47b6hhY ysVqPzlaBVB49ztjDHx9VCKVdcNTYKREaNDjH9O5GN/Yn/LvsIpmHWbjBKcXO2Sm7733 CWyrNrY/NwJay7UPwXnEx00ce4bmqity1MHcLSfzdhLIlujcAqzolrfSiqKJp11lCTzb N7WGdbD+502n3U1OFsMeu2yKAmxuqebC41rl+Yciw+tzpuasYDldbWJNCYoLjC/3XRj8 tS64QDtgr3XDIlEIoYVbfAOUy19ewQnZvOUzEzJib8PEyJnl6aOQJ8MdTbZXD1YD0X+H J58w== X-Gm-Message-State: ALoCoQk/zjgwBLXj+bOVeErYrWbMR0WirF6FqypNMVqYHDoKpGWzAC3MaVydZjverL20bHr3n3pg4M29nGHEjmSzcsFbdvJ/3A== X-Received: by 10.67.24.104 with SMTP id ih8mr152403092pad.124.1452183972668; Thu, 07 Jan 2016 08:26:12 -0800 (PST) Received: from localhost.localdomain ([122.166.219.57]) by smtp.gmail.com with ESMTPSA id d8sm82955093pas.14.2016.01.07.08.26.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Jan 2016 08:26:12 -0800 (PST) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Thu, 7 Jan 2016 21:55:54 +0530 Message-Id: <1452183954-30413-2-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1452183954-30413-1-git-send-email-bala.manoharan@linaro.org> References: <1452183954-30413-1-git-send-email-bala.manoharan@linaro.org> X-Topics: Classification patch Subject: [lng-odp] [API-NEXT PATCH 2/2] validation: classification: add additional PMR term 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: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Fixes https://bugs.linaro.org/show_bug.cgi?id=1541 https://bugs.linaro.org/show_bug.cgi?id=1834 Signed-off-by: Balasubramanian Manoharan --- test/validation/classification/classification.h | 4 + .../classification/odp_classification_common.c | 26 ++- .../classification/odp_classification_test_pmr.c | 207 +++++++++++++++++++++ .../classification/odp_classification_testsuites.h | 3 + 4 files changed, 234 insertions(+), 6 deletions(-) diff --git a/test/validation/classification/classification.h b/test/validation/classification/classification.h index a186339..5728cc5 100644 --- a/test/validation/classification/classification.h +++ b/test/validation/classification/classification.h @@ -19,6 +19,8 @@ #define CLS_DEFAULT_DADDR "10.0.0.100/32" #define CLS_DEFAULT_SPORT 1024 #define CLS_DEFAULT_DPORT 2048 +#define CLS_DEFAULT_DMAC 0x010203040506 +#define CLS_DEFAULT_SMAC 0x060504030201 /* Config values for Error CoS */ #define TEST_ERROR 1 @@ -76,6 +78,8 @@ void classification_test_pmr_term_tcp_sport(void); void classification_test_pmr_term_udp_dport(void); 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); /* test arrays: */ extern odp_testinfo_t classification_suite_basic[]; diff --git a/test/validation/classification/odp_classification_common.c b/test/validation/classification/odp_classification_common.c index 68c4b5a..89fdb89 100644 --- a/test/validation/classification/odp_classification_common.c +++ b/test/validation/classification/odp_classification_common.c @@ -193,21 +193,35 @@ odp_pool_t pool_create(const char *poolname) odp_packet_t create_packet(odp_pool_t pool, bool vlan, odp_atomic_u32_t *seq, bool flag_udp) { + return create_packet_len(pool, vlan, seq, flag_udp, 0); +} + +odp_packet_t create_packet_len(odp_pool_t pool, bool vlan, + odp_atomic_u32_t *seq, bool flag_udp, + uint16_t len) +{ uint32_t seqno; odph_ethhdr_t *ethhdr; odph_udphdr_t *udp; odph_tcphdr_t *tcp; odph_ipv4hdr_t *ip; - uint8_t payload_len; - char src_mac[ODPH_ETHADDR_LEN] = {0}; - char dst_mac[ODPH_ETHADDR_LEN] = {0}; + uint16_t payload_len; + uint64_t src_mac = CLS_DEFAULT_SMAC; + uint64_t dst_mac = CLS_DEFAULT_DMAC; + uint64_t dst_mac_be; uint32_t addr = 0; uint32_t mask; int offset; odp_packet_t pkt; int packet_len = 0; - payload_len = sizeof(cls_test_packet_t); + /* 48 bit ethernet address needs to be left shifted for proper + value after changing to be*/ + dst_mac_be = odp_cpu_to_be_64(dst_mac); + if (dst_mac != dst_mac_be) + dst_mac_be = dst_mac_be >> (64 - 8 * ODPH_ETHADDR_LEN); + + payload_len = sizeof(cls_test_packet_t) + len; packet_len += ODPH_ETHHDR_LEN; packet_len += ODPH_IPV4HDR_LEN; if (flag_udp) @@ -226,8 +240,8 @@ odp_packet_t create_packet(odp_pool_t pool, bool vlan, offset = 0; odp_packet_l2_offset_set(pkt, offset); 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, ODPH_ETHADDR_LEN); + memcpy(ethhdr->src.addr, &src_mac, ODPH_ETHADDR_LEN); + memcpy(ethhdr->dst.addr, &dst_mac_be, ODPH_ETHADDR_LEN); offset += sizeof(odph_ethhdr_t); if (vlan) { /* Default vlan header */ diff --git a/test/validation/classification/odp_classification_test_pmr.c b/test/validation/classification/odp_classification_test_pmr.c index 5101903..5c2a948 100644 --- a/test/validation/classification/odp_classification_test_pmr.c +++ b/test/validation/classification/odp_classification_test_pmr.c @@ -663,6 +663,211 @@ void classification_test_pmr_term_ipproto(void) odp_pktio_close(pktio); } +void classification_test_pmr_term_dmac(void) +{ + odp_packet_t pkt; + uint32_t seqno; + uint64_t val; + uint64_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_match_t match; + odph_ethhdr_t *eth; + + val = CLS_DEFAULT_DMAC; /* 48 bit Ethernet Mac address */ + mask = 0xffffffffffff; + seqno = 0; + + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED); + CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); + retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); + CU_ASSERT(retval == 0); + + match.term = ODP_PMR_DMAC; + match.val = &val; + match.mask = &mask; + match.val_sz = ODPH_ETHADDR_LEN; + + pmr = odp_pmr_create(&match); + CU_ASSERT(pmr != ODP_PMR_INVAL); + + queue = queue_create("dmac", true); + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); + + pool = pool_create("dmac"); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + sprintf(cosname, "dmac"); + 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); + + retval = odp_pktio_pmr_cos(pmr, pktio, cos); + CU_ASSERT(retval == 0); + + configure_default_cos(pktio, &default_cos, + &default_queue, &default_pool); + pkt = create_packet(pkt_pool, false, &seq, true); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + seqno = cls_pkt_get_seq(pkt); + CU_ASSERT(seqno != TEST_SEQ_INVALID); + + 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(pkt_pool, false, &seq, false); + eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL); + memset(eth->dst.addr, 0, ODPH_ETHADDR_LEN); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + seqno = cls_pkt_get_seq(pkt); + CU_ASSERT(seqno != TEST_SEQ_INVALID); + + 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_pmr_destroy(pmr); + odp_packet_free(pkt); + destroy_inq(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_packet_len(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_match_t match; + + val = 1024; + /*Mask value will match any packet of length 1000 - 1099*/ + mask = 0xff00; + seqno = 0; + + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED); + CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); + retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); + CU_ASSERT(retval == 0); + + match.term = ODP_PMR_LEN; + match.val = &val; + match.mask = &mask; + match.val_sz = sizeof(val); + + pmr = odp_pmr_create(&match); + CU_ASSERT(pmr != ODP_PMR_INVAL); + + queue = queue_create("packet_len", true); + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); + + pool = pool_create("packet_len"); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + sprintf(cosname, "packet_len"); + 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); + + retval = odp_pktio_pmr_cos(pmr, pktio, cos); + CU_ASSERT(retval == 0); + + configure_default_cos(pktio, &default_cos, + &default_queue, &default_pool); + /* create packet of payload length 1024 */ + pkt = create_packet_len(pkt_pool, false, &seq, true, 1024); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + seqno = cls_pkt_get_seq(pkt); + CU_ASSERT(seqno != TEST_SEQ_INVALID); + + 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(pkt_pool, false, &seq, false); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + seqno = cls_pkt_get_seq(pkt); + CU_ASSERT(seqno != TEST_SEQ_INVALID); + + 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_pmr_destroy(pmr); + odp_packet_free(pkt); + destroy_inq(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; @@ -955,8 +1160,10 @@ odp_testinfo_t classification_suite_pmr[] = { ODP_TEST_INFO(classification_test_pmr_term_udp_dport), ODP_TEST_INFO(classification_test_pmr_term_udp_sport), ODP_TEST_INFO(classification_test_pmr_term_ipproto), + ODP_TEST_INFO(classification_test_pmr_term_dmac), ODP_TEST_INFO(classification_test_pmr_pool_set), ODP_TEST_INFO(classification_test_pmr_queue_set), ODP_TEST_INFO(classification_test_pmr_term_daddr), + ODP_TEST_INFO(classification_test_pmr_term_packet_len), ODP_TEST_INFO_NULL, }; diff --git a/test/validation/classification/odp_classification_testsuites.h b/test/validation/classification/odp_classification_testsuites.h index 02828e1..397549b 100644 --- a/test/validation/classification/odp_classification_testsuites.h +++ b/test/validation/classification/odp_classification_testsuites.h @@ -22,6 +22,9 @@ int classification_suite_pmr_init(void); odp_packet_t create_packet(odp_pool_t pool, bool vlan, odp_atomic_u32_t *seq, bool udp); +odp_packet_t create_packet_len(odp_pool_t pool, bool vlan, + odp_atomic_u32_t *seq, bool flag_udp, + 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);