From patchwork Wed Feb 3 17:45:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 61114 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp444756lbl; Wed, 3 Feb 2016 09:56:12 -0800 (PST) X-Received: by 10.140.240.87 with SMTP id l84mr3408433qhc.69.1454522171048; Wed, 03 Feb 2016 09:56:11 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id z139si6438760qka.98.2016.02.03.09.56.10; Wed, 03 Feb 2016 09:56:11 -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 9E31B617A4; Wed, 3 Feb 2016 17:56:10 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=G+GSdbxl; 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 8B0F5617F5; Wed, 3 Feb 2016 17:51:16 +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 25804617E5; Wed, 3 Feb 2016 17:51:08 +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 51380617E5 for ; Wed, 3 Feb 2016 17:46:14 +0000 (UTC) Received: by mail-pf0-f171.google.com with SMTP id o185so17343633pfb.1 for ; Wed, 03 Feb 2016 09:46:14 -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=76lJGqqEsD98oIPrIFT/GBnMmwPd3XeB1S+obKS1y3I=; b=G+GSdbxlYRKVlCdIPTCpEHlH5F9kfmf8erarMjNQjmq9kzGtIkTSlU0QJk9KNuih2w z+0RA4CI+aDV4SQF2Duj1g9ANn+7oJyIMM7NF/oEUv8SIAcjZZokRQ9FGr1PCGG/hHS3 y71EpcV0gmEuJTsKHTZjfbc8jZVRyyUkHppmc= 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=76lJGqqEsD98oIPrIFT/GBnMmwPd3XeB1S+obKS1y3I=; b=BI2IavpBR4IOcYx7D9i7nleUlG0sor72vkR2vXellCNDvPJ1gxFwmvDprTQ+3GuM69 eW1UiR/7A3j6RSULBXnipfdVctWRATieqW3HE/aYNd/irryaGS2r4WVBKl1+M+bsmsp3 +ekE27T7iou8xoa9uuIHhIGZbn5ncoZTKqo+cZIwalxXwlPnrL3jH54j7BNV3cfAFg68 9/hgndb6+iFpuEMyynPDh23cTqiF5DSaUY34UzAcc1kQH1a0/iTKwSxqOJz/GN1X8i6h 0z8YicsvbPhRLukS5iBAGe4PnMs5JR/H/GfEL0JszqH/MSc/gnEPqGnjlwdfBMfn9pGJ /ywg== X-Gm-Message-State: AG10YOSrll3DuDvGsNKtC1bu4kShgtHf53UFdcbtkCuoftKrctPQ0qvaTbTwvOLncidWihZ5mxQ= X-Received: by 10.98.70.20 with SMTP id t20mr4186587pfa.110.1454521573633; Wed, 03 Feb 2016 09:46:13 -0800 (PST) Received: from localhost.localdomain ([122.166.219.57]) by smtp.gmail.com with ESMTPSA id d65sm11237089pfb.74.2016.02.03.09.46.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Feb 2016 09:46:13 -0800 (PST) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Wed, 3 Feb 2016 23:15:50 +0530 Message-Id: <1454521550-21579-5-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454521550-21579-1-git-send-email-bala.manoharan@linaro.org> References: <1454521550-21579-1-git-send-email-bala.manoharan@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv5 4/4] example: classifier: modifications for pmr create api 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" Changes for packet match rule create function. Signed-off-by: Balasubramanian Manoharan --- example/classifier/odp_classifier.c | 38 ++++++++++++---------- test/validation/classification/classification.h | 4 +-- .../classification/odp_classification_basic.c | 14 ++++---- .../classification/odp_classification_tests.c | 10 +++--- .../classification/odp_classification_testsuites.h | 2 +- 5 files changed, 36 insertions(+), 32 deletions(-) diff --git a/example/classifier/odp_classifier.c b/example/classifier/odp_classifier.c index 57a58d9..8e0a200 100644 --- a/example/classifier/odp_classifier.c +++ b/example/classifier/odp_classifier.c @@ -87,8 +87,8 @@ static void swap_pkt_addrs(odp_packet_t pkt_tbl[], unsigned len); static void parse_args(int argc, char *argv[], appl_args_t *appl_args); static void print_info(char *progname, appl_args_t *appl_args); static void usage(char *progname); -static void configure_cos(odp_pktio_t pktio, appl_args_t *args); -static void configure_default_cos(odp_pktio_t pktio, appl_args_t *args); +static void configure_cos(odp_cos_t default_cos, appl_args_t *args); +static odp_cos_t configure_default_cos(odp_pktio_t pktio, appl_args_t *args); static int convert_str_to_pmr_enum(char *token, odp_pmr_term_t *term, uint32_t *offset); static int parse_pmr_policy(appl_args_t *appl_args, char *argv[], char *optarg); @@ -355,7 +355,7 @@ static void *pktio_receive_thread(void *arg) return NULL; } -static void configure_default_cos(odp_pktio_t pktio, appl_args_t *args) +static odp_cos_t configure_default_cos(odp_pktio_t pktio, appl_args_t *args) { odp_queue_param_t qparam; const char *queue_name = "DefaultQueue"; @@ -417,9 +417,10 @@ static void configure_default_cos(odp_pktio_t pktio, appl_args_t *args) odp_atomic_init_u64(&stats[args->policy_count].queue_pkt_count, 0); odp_atomic_init_u64(&stats[args->policy_count].pool_pkt_count, 0); args->policy_count++; + return cos_default; } -static void configure_cos(odp_pktio_t pktio, appl_args_t *args) +static void configure_cos(odp_cos_t default_cos, appl_args_t *args) { char cos_name[ODP_COS_NAME_LEN]; char queue_name[ODP_QUEUE_NAME_LEN]; @@ -433,15 +434,6 @@ static void configure_cos(odp_pktio_t pktio, appl_args_t *args) for (i = 0; i < args->policy_count; i++) { stats = &args->stats[i]; - const odp_pmr_match_t match = { - .term = stats->rule.term, - .val = &stats->rule.val, - .mask = &stats->rule.mask, - .val_sz = stats->rule.val_sz, - .offset = stats->rule.offset - }; - - stats->pmr = odp_pmr_create(&match); odp_queue_param_init(&qparam); qparam.type = ODP_QUEUE_TYPE_SCHED; qparam.sched.prio = i % odp_schedule_num_prio(); @@ -480,7 +472,17 @@ static void configure_cos(odp_pktio_t pktio, appl_args_t *args) cls_param.drop_policy = ODP_COS_DROP_POOL; stats->cos = odp_cls_cos_create(cos_name, &cls_param); - if (0 > odp_pktio_pmr_cos(stats->pmr, pktio, stats->cos)) { + const odp_pmr_match_t match = { + .term = stats->rule.term, + .val = &stats->rule.val, + .mask = &stats->rule.mask, + .val_sz = stats->rule.val_sz, + .offset = stats->rule.offset + }; + + stats->pmr = odp_cls_pmr_create(&match, 1, default_cos, + stats->cos); + if (stats->pmr == ODP_PMR_INVAL) { EXAMPLE_ERR("odp_pktio_pmr_cos failed"); exit(EXIT_FAILURE); } @@ -505,6 +507,7 @@ int main(int argc, char *argv[]) odp_pool_param_t params; odp_pktio_t pktio; appl_args_t *args; + odp_cos_t default_cos; odp_queue_t inq; odp_shm_t shm; @@ -576,10 +579,10 @@ int main(int argc, char *argv[]) /* create pktio per interface */ pktio = create_pktio(args->if_name, pool); - configure_cos(pktio, args); - /* configure default Cos */ - configure_default_cos(pktio, args); + default_cos = configure_default_cos(pktio, args); + + configure_cos(default_cos, args); if (odp_pktio_start(pktio)) { EXAMPLE_ERR("Error: unable to start pktio.\n"); @@ -606,6 +609,7 @@ int main(int argc, char *argv[]) print_cls_statistics(args); for (i = 0; i < args->policy_count; i++) { + odp_cls_pmr_destroy(args->stats[i].pmr); odp_cos_destroy(args->stats[i].cos); odp_pool_destroy(args->stats[i].pool); odp_queue_destroy(args->stats[i].queue); diff --git a/test/validation/classification/classification.h b/test/validation/classification/classification.h index c987cca..8645ea5 100644 --- a/test/validation/classification/classification.h +++ b/test/validation/classification/classification.h @@ -62,8 +62,8 @@ void classification_test_create_pmr_match(void); void classification_test_cos_set_queue(void); void classification_test_cos_set_pool(void); void classification_test_cos_set_drop(void); -void classification_test_pmr_match_set_create(void); -void classification_test_pmr_match_set_destroy(void); +void classification_test_pmr_composite_create(void); +void classification_test_pmr_composite_destroy(void); void classification_test_pktio_set_skip(void); void classification_test_pktio_set_headroom(void); diff --git a/test/validation/classification/odp_classification_basic.c b/test/validation/classification/odp_classification_basic.c index 1336955..16be47e 100644 --- a/test/validation/classification/odp_classification_basic.c +++ b/test/validation/classification/odp_classification_basic.c @@ -247,9 +247,9 @@ void classification_test_cos_set_drop(void) odp_queue_destroy(queue); } -void classification_test_pmr_match_set_create(void) +void classification_test_pmr_composite_create(void) { - odp_pmr_t pmr_set; + odp_pmr_t pmr_composite; int retval; odp_pmr_match_t pmr_terms[PMR_SET_NUM]; odp_cos_t default_cos; @@ -295,12 +295,12 @@ void classification_test_pmr_match_set_create(void) pmr_terms[i].val_sz = sizeof(val); } - pmr_set = odp_cls_pmr_create(pmr_terms, PMR_SET_NUM, - default_cos, cos); - CU_ASSERT(odp_pmr_to_u64(pmr_set) != + pmr_composite = odp_cls_pmr_create(pmr_terms, PMR_SET_NUM, + default_cos, cos); + CU_ASSERT(odp_pmr_to_u64(pmr_composite) != odp_pmr_to_u64(ODP_PMR_INVAL)); - retval = odp_cls_pmr_destroy(pmr_set); + retval = odp_cls_pmr_destroy(pmr_composite); CU_ASSERT(retval == 0); odp_queue_destroy(queue); @@ -320,6 +320,6 @@ odp_testinfo_t classification_suite_basic[] = { ODP_TEST_INFO(classification_test_cos_set_queue), ODP_TEST_INFO(classification_test_cos_set_drop), ODP_TEST_INFO(classification_test_cos_set_pool), - ODP_TEST_INFO(classification_test_pmr_match_set_create), + ODP_TEST_INFO(classification_test_pmr_composite_create), ODP_TEST_INFO_NULL, }; diff --git a/test/validation/classification/odp_classification_tests.c b/test/validation/classification/odp_classification_tests.c index f04e910..085bd79 100644 --- a/test/validation/classification/odp_classification_tests.c +++ b/test/validation/classification/odp_classification_tests.c @@ -576,16 +576,16 @@ void configure_pktio_pmr_composite(void) qparam.sched.prio = ODP_SCHED_PRIO_HIGHEST; qparam.sched.sync = ODP_SCHED_SYNC_PARALLEL; qparam.sched.group = ODP_SCHED_GROUP_ALL; - sprintf(queuename, "%s", "cos_pmr_set_queue"); + sprintf(queuename, "%s", "cos_pmr_composite_queue"); queue_list[CLS_PMR_SET] = odp_queue_create(queuename, &qparam); CU_ASSERT_FATAL(queue_list[CLS_PMR_SET] != ODP_QUEUE_INVALID); - sprintf(poolname, "cos_pmr_set_pool"); + sprintf(poolname, "cos_pmr_composite_pool"); pool_list[CLS_PMR_SET] = pool_create(poolname); CU_ASSERT_FATAL(pool_list[CLS_PMR_SET] != ODP_POOL_INVALID); - sprintf(cosname, "cos_pmr_set"); + sprintf(cosname, "cos_pmr_composite"); odp_cls_cos_param_init(&cls_param); cls_param.pool = pool_list[CLS_PMR_SET]; cls_param.queue = queue_list[CLS_PMR_SET]; @@ -612,7 +612,7 @@ void configure_pktio_pmr_composite(void) CU_ASSERT_FATAL(pmr_list[CLS_PMR_SET] != ODP_PMR_INVAL); } -void test_pktio_pmr_match_set_cos(void) +void test_pktio_pmr_composite_cos(void) { uint32_t addr = 0; uint32_t mask; @@ -692,7 +692,7 @@ void classification_test_pktio_test(void) if (TEST_PMR) test_pmr_cos(); if (TEST_PMR_SET) - test_pktio_pmr_match_set_cos(); + test_pktio_pmr_composite_cos(); } odp_testinfo_t classification_suite[] = { diff --git a/test/validation/classification/odp_classification_testsuites.h b/test/validation/classification/odp_classification_testsuites.h index 851f0a3..44577a0 100644 --- a/test/validation/classification/odp_classification_testsuites.h +++ b/test/validation/classification/odp_classification_testsuites.h @@ -47,7 +47,7 @@ void test_cos_with_l2_priority(void); void configure_pmr_cos(void); void test_pmr_cos(void); void configure_pktio_pmr_composite(void); -void test_pktio_pmr_match_set_cos(void); +void test_pktio_pmr_composite_cos(void); int destroy_inq(odp_pktio_t pktio); odp_pmr_term_t find_first_supported_l3_pmr(void); int set_first_supported_pmr_port(odp_packet_t pkt, uint16_t port);