From patchwork Fri Jan 22 11:54:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 60130 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp619299lbb; Fri, 22 Jan 2016 03:55:14 -0800 (PST) X-Received: by 10.140.94.68 with SMTP id f62mr3058389qge.0.1453463714355; Fri, 22 Jan 2016 03:55:14 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id a18si6786445qkb.114.2016.01.22.03.55.14; Fri, 22 Jan 2016 03:55:14 -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 DD201617E5; Fri, 22 Jan 2016 11:55:13 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=TZL8KN7u; 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 89D48616CA; Fri, 22 Jan 2016 11:55: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 9FD2F617AA; Fri, 22 Jan 2016 11:55:02 +0000 (UTC) Received: from mail-pf0-f179.google.com (mail-pf0-f179.google.com [209.85.192.179]) by lists.linaro.org (Postfix) with ESMTPS id 3A3E9617E5 for ; Fri, 22 Jan 2016 11:54:31 +0000 (UTC) Received: by mail-pf0-f179.google.com with SMTP id 65so41244063pff.2 for ; Fri, 22 Jan 2016 03:54:31 -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=aTNnl42GdXhci7EehwNOV/B31zWc/mqVEqItqzwECHU=; b=TZL8KN7u/nliD3pD1saq0revhcYB0RmNJ7cmaMxuUzez2kSM/rCszJmE6IhRvESsFy BVvm8sBgRcAsDlrbQ+zSBl2tlzwj3V598vRLGlxqL2s5VaQjW0TUE6pTKIUn7Wy2jwk9 cYnUVVNUtZOpufmJU6uCpIKXEmIakpqe2sKPQ= 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=aTNnl42GdXhci7EehwNOV/B31zWc/mqVEqItqzwECHU=; b=Uvyketz6YpQVbLVq+2wIdR23vvwfJKvVoMuioRmHmjBomdXgBF09ua7dNOqEPpnmTd 5FTEhcD8uHNZeHpq1cofjEc977huqP9lUdHyZ3ns9tsD6FeO+chPSuDCjDFUS4o0a+1+ PAB12167CX8CDm7ig/myVKF+P62a/ZoUz4OVhb8NBAHqDQAaCdtDWSKJocG2WNOmUi2c zv50jSWILHR6JsCbt6NsRZYR4mFyKoJxSrNQ24mWyp1J46GPf+v36UCgR/jwib/5WgD7 cOwYyuf01LPtOKx1T+Fu4sssHDGStv/9ztLWYLHVLF1MhAF76dZMd4NLq/AWxO1orx5s +1oQ== X-Gm-Message-State: AG10YOQMa6Iu6RFwd6FktbITDjRnTVxwoo4H8bavHs0UEkwtUkh+J21rNr2nqlO2A5FXuYvwDkc= X-Received: by 10.98.11.151 with SMTP id 23mr3757293pfl.93.1453463670516; Fri, 22 Jan 2016 03:54:30 -0800 (PST) Received: from localhost.localdomain ([122.166.219.57]) by smtp.gmail.com with ESMTPSA id t70sm9394825pfi.8.2016.01.22.03.54.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Jan 2016 03:54:30 -0800 (PST) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Fri, 22 Jan 2016 17:24:08 +0530 Message-Id: <1453463648-11158-4-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1453463648-11158-1-git-send-email-bala.manoharan@linaro.org> References: <1453463648-11158-1-git-send-email-bala.manoharan@linaro.org> X-Topics: patch Cc: petri.savolainen@nokia.com Subject: [lng-odp] [API-NEXT PATCHv1 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 5a8cd37..44d84af 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, 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);