From patchwork Wed Feb 3 17:15:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 61110 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp434573lbl; Wed, 3 Feb 2016 09:36:48 -0800 (PST) X-Received: by 10.140.22.210 with SMTP id 76mr3137661qgn.70.1454521008277; Wed, 03 Feb 2016 09:36:48 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id z2si6378322qkg.60.2016.02.03.09.36.47; Wed, 03 Feb 2016 09:36:48 -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 BA2CD618DA; Wed, 3 Feb 2016 17:36:47 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=NpINiI/s; 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 ECE55617DC; Wed, 3 Feb 2016 17:21:27 +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 794F7617E2; Wed, 3 Feb 2016 17:21:18 +0000 (UTC) Received: from mail-pa0-f48.google.com (mail-pa0-f48.google.com [209.85.220.48]) by lists.linaro.org (Postfix) with ESMTPS id DD360617E2 for ; Wed, 3 Feb 2016 17:15:58 +0000 (UTC) Received: by mail-pa0-f48.google.com with SMTP id ho8so16488020pac.2 for ; Wed, 03 Feb 2016 09:15:58 -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=jlm4XElke6JBjVCjEI1SM3nxSA9G8dcxAgkWH09GepE=; b=NpINiI/sSCh1bkd9Z8VsgyTYk2u+3DP6nu3gVVdErbSTHE5RuXy4E0Yh1+mAY3aCX2 av0+813nhNEYY3wm1RYcZmjdWGOmCkdTT2/+yVIq1g9y/6o/iPPH8BU5rHGIBeHI+/Ei F5xlsQZVW826E8RDOWsbCoePviB6Pv1vmUbD4= 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=jlm4XElke6JBjVCjEI1SM3nxSA9G8dcxAgkWH09GepE=; b=JgwkJ8g0MUNQ4W6gsL+ajTuHO2bB+u45EDShzGHaWx7wSz1dVKZXSMN/Rxn30bpBRH K2FFOop8CYY9lwD2k9NR8tHdRI2onMzP4YYTY/AgMsDeFJVMXdlwilXwmxjQig8+FOhM YZcRimoUFJvtv9NLSmLG8i+/Lw/SV/GB8Xw6kOjkHsjDBIcPHIrnt2cJ7w1MIkFGKloC rZNIC+zW/S/8O1Sv/xiYNX3ZwvuQgZPmPuWs+IA8jXcP91WJ1gbeXyjmeU/Jj7fTBOj4 VnViNdX6ZWMb4N+XmJ0MuBziwkR+TZk0zxe86mkBUB5Glfc+t3cwk8FBXv8YXIoRMvU9 ECew== X-Gm-Message-State: AG10YOToGJ4CL73tCipib3GrciHMYMPxZrv23RgJcdf7weie+i6HXC3BpNh+8jdEfFM9xZ1jhvM= X-Received: by 10.66.158.129 with SMTP id wu1mr3950658pab.146.1454519758252; Wed, 03 Feb 2016 09:15:58 -0800 (PST) Received: from localhost.localdomain ([122.166.219.57]) by smtp.gmail.com with ESMTPSA id g81sm11226137pfj.1.2016.02.03.09.15.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Feb 2016 09:15:57 -0800 (PST) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Wed, 3 Feb 2016 22:45:27 +0530 Message-Id: <1454519727-31240-5-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454519727-31240-1-git-send-email-bala.manoharan@linaro.org> References: <1454519727-31240-1-git-send-email-bala.manoharan@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv4 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 ++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 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);