From patchwork Wed Dec 16 09:28:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 58491 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp580145lbb; Wed, 16 Dec 2015 01:35:46 -0800 (PST) X-Received: by 10.55.40.153 with SMTP id o25mr37954453qko.93.1450258545665; Wed, 16 Dec 2015 01:35:45 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id z132si5839274qhc.32.2015.12.16.01.35.45; Wed, 16 Dec 2015 01:35:45 -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 232D361C94; Wed, 16 Dec 2015 09:35:45 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=aSuh/li8; 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 D955061D15; Wed, 16 Dec 2015 09:31:13 +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 E08DA61D0D; Wed, 16 Dec 2015 09:30:47 +0000 (UTC) Received: from mail-ig0-f171.google.com (mail-ig0-f171.google.com [209.85.213.171]) by lists.linaro.org (Postfix) with ESMTPS id 5F6C261B60 for ; Wed, 16 Dec 2015 09:29:16 +0000 (UTC) Received: by mail-ig0-f171.google.com with SMTP id xm8so40525789igb.1 for ; Wed, 16 Dec 2015 01:29:16 -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=k8Gy3N2x9+AHpI/9B3rF6Wf9D+IjXacYbioSwLaqcXw=; b=aSuh/li81NBSiM7B47ufMnFWMb6Wbninx6qOdvn7C50egDDtXPDT1X6CU8B1oiezQz IGujSy5vQ3wfXFp5pHA4TB83OZXPtgtabsys8gL7vVzh6nHqTfk3BaBHHlXkdqKs4Kf9 rQzn9kyjy7EZKO1y7xkdTuSFGxYsmkuYyXQm8= 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=k8Gy3N2x9+AHpI/9B3rF6Wf9D+IjXacYbioSwLaqcXw=; b=GQon+xnQ2xWiRMcYqhCyLTR244vWGGJyHy8sDgcaKr0CepN0wEtlcSGMH0+rw9pnx0 MZzlvRdMKSO4fjyX091i6kOgAbenW7qmCg1nWg74fzV7rciT8JVljgquVzUCWEC0brOc GTwKslDk7dNpKSnkX0txjjQYDq7QlkmWPJcJxY3Jdq2aUUVbkc9cNyArEYSvbl1qWhPa 5WG9U9XlISUPIs7bZcPE/jW/mGq0L/kyMdUgZ6GQml89JivANr8QQzpmM4KwYx4+3yNA +zI6cfmuT/jYJ/m8f4dR+lESOau9LUkpqhr4pfWZweUaJ3zBI8J8NB2WriDQXh5S9Xi7 AE3w== X-Gm-Message-State: ALoCoQn5Uexki+nawxuXMMl1LpV75CzEgn9nXfkSP2kxI4lpblkMn54Fi9kGXuyGURAabMMDrYv0QYEj9g/SZFONC93IHoaLPw== X-Received: by 10.107.158.80 with SMTP id h77mr26544421ioe.114.1450258156033; Wed, 16 Dec 2015 01:29:16 -0800 (PST) Received: from bala-Vostro-2520.caveonetworks.com ([111.93.218.67]) by smtp.gmail.com with ESMTPSA id o86sm2549486ioi.36.2015.12.16.01.29.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Dec 2015 01:29:15 -0800 (PST) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Wed, 16 Dec 2015 14:58:51 +0530 Message-Id: <1450258133-3375-4-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1450258133-3375-1-git-send-email-bala.manoharan@linaro.org> References: <1450258133-3375-1-git-send-email-bala.manoharan@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT/PATCHv2 4/6] 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 0da07e7..8daddd5 100644 --- a/example/classifier/odp_classifier.c +++ b/example/classifier/odp_classifier.c @@ -356,16 +356,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; @@ -373,9 +373,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); } @@ -384,7 +383,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) { @@ -392,8 +390,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); } @@ -419,15 +423,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, @@ -453,11 +455,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; @@ -469,11 +466,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); @@ -601,6 +606,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); }