From patchwork Mon Feb 1 12:56:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 60908 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp3056747lbb; Mon, 1 Feb 2016 04:59:56 -0800 (PST) X-Received: by 10.107.14.72 with SMTP id 69mr23565226ioo.145.1454331596172; Mon, 01 Feb 2016 04:59:56 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id a123si44472570ioe.104.2016.02.01.04.59.53; Mon, 01 Feb 2016 04:59:56 -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 D1D18610A9; Mon, 1 Feb 2016 12:59:52 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=SUpfv2pl; 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 00DE9615C7; Mon, 1 Feb 2016 12:57:23 +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 EB7F461610; Mon, 1 Feb 2016 12:57:15 +0000 (UTC) Received: from mail-pf0-f182.google.com (mail-pf0-f182.google.com [209.85.192.182]) by lists.linaro.org (Postfix) with ESMTPS id 54C04616BE for ; Mon, 1 Feb 2016 12:56:31 +0000 (UTC) Received: by mail-pf0-f182.google.com with SMTP id o185so78786342pfb.1 for ; Mon, 01 Feb 2016 04:56: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=J38EQ7vOGBzkRgEUYtsx1F4YQnHgZ/r48chHpRIFxsw=; b=SUpfv2plIBIv4gqzAidiVf2Pg8E4XzbaiTRNefUB6NojsMaTeGpI+kFPkufrOFIuNe 7ULrj1Wt6bjBdJIBlxCbNOTAmZrGXyAW/XlTRCNqlnw2yjFEVyLtczeOYJ8R783ols8o mR7/nUH/seNKb363ECf70ay625Ps/YTaaLcj0= 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=J38EQ7vOGBzkRgEUYtsx1F4YQnHgZ/r48chHpRIFxsw=; b=FWR+dWF38ySy1TyMxeRkRQ77zvL6pr4fgU2valRwIzXHnau8KefZD/8hBAJrReps7L fvNSt5FJfRN023QlGsD/aSsquw30kqtvSBCI7i69ayWPZmRHZNqUFwclrHjP23qpcXgy gCQK/XRX3vm/1RR/zZyPsrFPkCQz0qV5gQ8KfQQy5/AD4xHMRdHsQXCP/X2GLHCcfJHU IhPJ94kBtbKfKePGwEzsg5dgaecUWX7nip/WbEZyA1edkOmzMgqLfSCegnmqObBuL8Eu adMsX8j40mMAXucGnJDKV+oD/1d3bu43Omh+7B2ttxTkdq+vVQgEGjeqQ2lGs4BbVIUB ynOA== X-Gm-Message-State: AG10YOSVWdDyaxwTH88oqLPhWd2Qw66lm65L0qz7aDAKLammcTX/3JIGpGTSg8XreQTwKPnv04k= X-Received: by 10.98.32.76 with SMTP id g73mr38084480pfg.48.1454331390698; Mon, 01 Feb 2016 04:56:30 -0800 (PST) Received: from localhost.localdomain ([122.166.219.57]) by smtp.gmail.com with ESMTPSA id y86sm43188805pfa.26.2016.02.01.04.56.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Feb 2016 04:56:29 -0800 (PST) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Mon, 1 Feb 2016 18:26:00 +0530 Message-Id: <1454331360-16717-4-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454331360-16717-1-git-send-email-bala.manoharan@linaro.org> References: <1454331360-16717-1-git-send-email-bala.manoharan@linaro.org> X-Topics: patch Cc: petri.savolainen@nokia.com Subject: [lng-odp] [API-NEXT PATCHv2 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..da76b3d 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(1, &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);