From patchwork Tue Dec 8 10:21:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 57841 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp1698959lbb; Tue, 8 Dec 2015 02:23:29 -0800 (PST) X-Received: by 10.140.216.14 with SMTP id m14mr3502259qhb.90.1449570206843; Tue, 08 Dec 2015 02:23:26 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id y15si2767550qka.77.2015.12.08.02.23.26; Tue, 08 Dec 2015 02:23:26 -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.20150623.gappssmtp.com Received: by lists.linaro.org (Postfix, from userid 109) id 6C0AA61CC9; Tue, 8 Dec 2015 10:23:26 +0000 (UTC) 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 2ADB361CC5; Tue, 8 Dec 2015 10:22:50 +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 93ED061CC9; Tue, 8 Dec 2015 10:22:41 +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 3A70D61CC5 for ; Tue, 8 Dec 2015 10:22:15 +0000 (UTC) Received: by pfu207 with SMTP id 207so10165476pfu.2 for ; Tue, 08 Dec 2015 02:22:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cenKlxJHdyrtJI+AgUlDf95Nbazfh0/7okJ2OXviHKU=; b=aQLJ4jP2Lu5YzTD94/w94uJkm62r93QE63K/XxUF0P1T/Sg0UBIAosmzF8S2FAnA+S g9HRxkMJsPBb9rVYH0n52JwBpilZEHyT8BXTdxEZr2E59zhdkPuxccm6YSNspBewaiVU XQrUnoyljlPdlFztXD+dj7ptWZO5BSfZDaitx6MIuzm+1mTQc2oowUyJlCozFkfYB08s eZgNE6SWdmui/bq4PYCdhOrWTTJYgx2bdRUk855nMbL717LtLAbiIDpD7J+fQceluEsF btjRWq1Rh8DIuVdKrEal2XBXfYzDkYs58GAqJTz4WfEVL+SJfGpQnVS7EU2XH7fPWhWY L1hg== 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=cenKlxJHdyrtJI+AgUlDf95Nbazfh0/7okJ2OXviHKU=; b=En5XVBqq0MucQxrxJ6GhHteKgdh8pau6+0wHOBlpTPP76q1hkWxlIh27qvUE6Ks9zD SuC/gNI4JCodXqXhoXUwvPaHa5zzn6cgEGPH4fJzlqe84xAN84wQNtwYV3qAMf6yYAza zbykb8dNNY56j1+GCZGQL9pmGZF/R4B4vaYPad/KfducwewasFfNPLYnCu+zwfSx62up geHi/1t0VPmCzc4gFxG6Sae9g3gChE1JMbsGk9YziKBmVF5K+MQxyvmUKlKpojWpeFp1 XnHffX0z/DzyTA00BXET5t7NpPLARcc99Cxk7zoxfR5vJhczV35qnU06CLPwkh1mKW9f 0KMw== X-Gm-Message-State: ALoCoQk1qb+QIwVoq7drrVnGckRdJBcD8DN0HeU2zL2w+7z+ebk+e50t++ijXPyw5PPb55HqtRHbYLikZ3RQVRmFKicy6MGF3w== X-Received: by 10.98.12.205 with SMTP id 74mr3680950pfm.53.1449570134586; Tue, 08 Dec 2015 02:22:14 -0800 (PST) Received: from localhost.localdomain ([122.166.219.57]) by smtp.gmail.com with ESMTPSA id ah10sm3802119pad.23.2015.12.08.02.22.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Dec 2015 02:22:14 -0800 (PST) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Tue, 8 Dec 2015 15:51:52 +0530 Message-Id: <1449570112-5486-4-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1449570112-5486-1-git-send-email-bala.manoharan@linaro.org> References: <1449570112-5486-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: add class of service 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" Replaces odp_cos_create() function with odp_cls_cos_create() function Signed-off-by: Balasubramanian Manoharan --- example/classifier/odp_classifier.c | 42 +++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/example/classifier/odp_classifier.c b/example/classifier/odp_classifier.c index 2ecf733..481f763 100644 --- a/example/classifier/odp_classifier.c +++ b/example/classifier/odp_classifier.c @@ -357,16 +357,16 @@ static void *pktio_receive_thread(void *arg) static void configure_default_cos(odp_pktio_t pktio, appl_args_t *args) { odp_queue_param_t qparam; - odp_cos_t cos_default; const char *queue_name = "DefaultQueue"; const char *pool_name = "DefaultPool"; const char *cos_name = "DefaultCos"; odp_queue_t queue_default; odp_pool_t pool_default; + odp_cos_t cos_default; odp_pool_param_t pool_params; + odp_cls_cos_param_t cls_param; global_statistics *stats = args->stats; - cos_default = odp_cos_create(cos_name); odp_queue_param_init(&qparam); qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT; @@ -374,9 +374,8 @@ static void configure_default_cos(odp_pktio_t pktio, appl_args_t *args) qparam.sched.group = ODP_SCHED_GROUP_ALL; queue_default = odp_queue_create(queue_name, ODP_QUEUE_TYPE_SCHED, &qparam); - - if (0 > odp_cos_queue_set(cos_default, queue_default)) { - EXAMPLE_ERR("odp_cos_queue_set failed"); + if (queue_default == ODP_QUEUE_INVALID) { + EXAMPLE_ERR("Error: default queue create failed.\n"); exit(EXIT_FAILURE); } @@ -385,7 +384,6 @@ static void configure_default_cos(odp_pktio_t pktio, appl_args_t *args) pool_params.pkt.len = SHM_PKT_POOL_BUF_SIZE; pool_params.pkt.num = SHM_PKT_POOL_SIZE / SHM_PKT_POOL_BUF_SIZE; pool_params.type = ODP_POOL_PACKET; - pool_default = odp_pool_create(pool_name, &pool_params); if (pool_default == ODP_POOL_INVALID) { @@ -393,8 +391,14 @@ static void configure_default_cos(odp_pktio_t pktio, appl_args_t *args) exit(EXIT_FAILURE); } - if (0 > odp_cls_cos_pool_set(cos_default, pool_default)) { - EXAMPLE_ERR("odp_cls_cos_pool_set failed"); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool_default; + cls_param.queue = queue_default; + cls_param.drop_policy = ODP_COS_DROP_POOL; + cos_default = odp_cls_cos_create(cos_name, &cls_param); + + if (cos_default == ODP_COS_INVALID) { + EXAMPLE_ERR("Error: default cos create failed.\n"); exit(EXIT_FAILURE); } @@ -420,15 +424,13 @@ static void configure_cos(odp_pktio_t pktio, appl_args_t *args) char queue_name[ODP_QUEUE_NAME_LEN]; char pool_name[ODP_POOL_NAME_LEN]; odp_pool_param_t pool_params; + odp_cls_cos_param_t cls_param; int i; global_statistics *stats; odp_queue_param_t qparam; for (i = 0; i < args->policy_count; i++) { stats = &args->stats[i]; - snprintf(cos_name, sizeof(cos_name), "CoS%s", - stats->cos_name); - stats->cos = odp_cos_create(cos_name); const odp_pmr_match_t match = { .term = stats->rule.term, @@ -454,11 +456,6 @@ static void configure_cos(odp_pktio_t pktio, appl_args_t *args) exit(EXIT_FAILURE); } - if (0 > odp_cos_queue_set(stats->cos, stats->queue)) { - EXAMPLE_ERR("odp_cos_queue_set failed"); - exit(EXIT_FAILURE); - } - odp_pool_param_init(&pool_params); pool_params.pkt.seg_len = SHM_PKT_POOL_BUF_SIZE; pool_params.pkt.len = SHM_PKT_POOL_BUF_SIZE; @@ -470,11 +467,19 @@ static void configure_cos(odp_pktio_t pktio, appl_args_t *args) args->stats[i].cos_name, i); stats->pool = odp_pool_create(pool_name, &pool_params); - if (0 > odp_cls_cos_pool_set(stats->cos, stats->pool)) { - EXAMPLE_ERR("odp_cls_cos_pool_set failed"); + if (stats->pool == ODP_POOL_INVALID) { + EXAMPLE_ERR("Error: default pool create failed.\n"); exit(EXIT_FAILURE); } + snprintf(cos_name, sizeof(cos_name), "CoS%s", + stats->cos_name); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = stats->pool; + cls_param.queue = stats->queue; + 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)) { EXAMPLE_ERR("odp_pktio_pmr_cos failed"); exit(EXIT_FAILURE); @@ -602,6 +607,7 @@ int main(int argc, char *argv[]) for (i = 0; i < args->policy_count; i++) { odp_cos_destroy(args->stats[i].cos); + odp_pool_destroy(args->stats[i].pool); odp_queue_destroy(args->stats[i].queue); odp_pool_destroy(args->stats[i].pool); }