From patchwork Tue Feb 2 14:07:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 61026 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp755960lbb; Tue, 2 Feb 2016 06:10:51 -0800 (PST) X-Received: by 10.55.74.86 with SMTP id x83mr35051435qka.89.1454422251157; Tue, 02 Feb 2016 06:10:51 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id l62si1123937qhc.126.2016.02.02.06.10.50; Tue, 02 Feb 2016 06:10:51 -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 B2903616B4; Tue, 2 Feb 2016 14:10:50 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=blBScimN; 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 40F54616CE; Tue, 2 Feb 2016 14:08:26 +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 7000761627; Tue, 2 Feb 2016 14:08:11 +0000 (UTC) Received: from mail-pf0-f175.google.com (mail-pf0-f175.google.com [209.85.192.175]) by lists.linaro.org (Postfix) with ESMTPS id 5905C61627 for ; Tue, 2 Feb 2016 14:08:04 +0000 (UTC) Received: by mail-pf0-f175.google.com with SMTP id n128so105101009pfn.3 for ; Tue, 02 Feb 2016 06:08:04 -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=bdpJlevRE2l/WTGUBDYtU+CBFLSfPwJjzCDrMZmyNlc=; b=blBScimNnMqikk5azu1fRr4cgLBqKdwW+5RP4ZZBV+UFNFaRBFmsRwfosfZP1lcGii 9vy5ZHjMxm6VwADH78AD/JlVElyLcyRVlbri99ykls3Hin97pxe9pgjlBuXjNhcA4Pni /xtQFoAIF1DxWC5ZNEN9Z5FN808bEYjgzt5PI= 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=bdpJlevRE2l/WTGUBDYtU+CBFLSfPwJjzCDrMZmyNlc=; b=F1Ehdi8gwxJ3pLR5UfLPG6eNLtykZ/W0ZI0NNDab62OSu56VtsfQ8vsTLxGxSWib2F Rhm3TpB37f5qJfnSbTaL4axYsrzNZ29vPKSk6LUn8OO4L0+lFprx3uaaJse0p+KSelna vSLacwuyWEIjUajP9KCDoHdxaVrP1U54v2cm6DzdDxOrMs80iIB/q9U4CqKquyNAWYXU 0CDzFSfZRTpL77u1b7JGxOdxKcZuMgST/+25QrK0zfOXlrH4XgOYhDmREh4ngjDo+o1e uXgD2jeCnB6vjIyjRjq757yIoVGE/Q2QqZHJmuFgxdzbCfrLr83UW7tF8QSwMK5iQj4D KE9A== X-Gm-Message-State: AG10YORU874Gpt4UzuPZDhOWhm66Yj0eDG+9zt+6OEWSRUwTZHAm5TLiF2h5/FXJQ/SusJkNhEg= X-Received: by 10.98.89.78 with SMTP id n75mr46734325pfb.120.1454422083711; Tue, 02 Feb 2016 06:08:03 -0800 (PST) Received: from localhost.localdomain ([122.166.219.57]) by smtp.gmail.com with ESMTPSA id 85sm3110385pfl.18.2016.02.02.06.08.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Feb 2016 06:08:03 -0800 (PST) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Tue, 2 Feb 2016 19:37:34 +0530 Message-Id: <1454422054-22226-4-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454422054-22226-1-git-send-email-bala.manoharan@linaro.org> References: <1454422054-22226-1-git-send-email-bala.manoharan@linaro.org> X-Topics: patch Cc: petri.savolainen@nokia.com Subject: [lng-odp] [API-NEXT PATCHv3 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" Modifications for packet match rule create function. Signed-off-by: Balasubramanian Manoharan --- example/classifier/odp_classifier.c | 38 ++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/example/classifier/odp_classifier.c b/example/classifier/odp_classifier.c index 9e5bec9..245ab2d 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); @@ -354,7 +354,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"; @@ -416,9 +416,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]; @@ -432,15 +433,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.sched.prio = i % odp_schedule_num_prio(); qparam.sched.sync = ODP_SCHED_SYNC_NONE; @@ -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);