From patchwork Tue Nov 17 06:16:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 56707 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1742747lbb; Mon, 16 Nov 2015 22:21:33 -0800 (PST) X-Received: by 10.140.31.161 with SMTP id f30mr39054169qgf.95.1447741293370; Mon, 16 Nov 2015 22:21:33 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id c140si28835966qkb.55.2015.11.16.22.21.33; Mon, 16 Nov 2015 22:21:33 -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 0B32461CC8; Tue, 17 Nov 2015 06:21:33 +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_H3, RCVD_IN_MSPIKE_WL, 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 6040A61CE8; Tue, 17 Nov 2015 06:18:19 +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 2928261C7E; Tue, 17 Nov 2015 06:18:09 +0000 (UTC) Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) by lists.linaro.org (Postfix) with ESMTPS id B341F61CD4 for ; Tue, 17 Nov 2015 06:17:14 +0000 (UTC) Received: by pacdm15 with SMTP id dm15so200714083pac.3 for ; Mon, 16 Nov 2015 22:17: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=MlQJXGPAOXusDdm3bh9payk06ZDvvgN/3CBqe0JFDb0=; b=ssROiI/wdt/zdy8VM8YrlBHQayUNJTgAE+QExcyhGRD8ztYDlwfsy+dcVglU8q0RIo mtcsJh2us+9zB6FvAwgZ+CImsgfdg6On0GefkPdQpWqF/GW34uTqgaGf8+N4gtGNSqmp qkh8ijFXJF8BSJj2BOHXqAvYbZ2ZTPJo5PUtAZRyf7CyQh6s/4xzTmIaHs8JuiW/mBeu vO1S3oiJcYof1JfPh4fYVLp1nkKh9OOKEDJTmRKufebj1qoCeudZifxj9ivmci+X8uwB kc8s/su+1ShD08b1ASOqfbJCyD61H7yrBuqywaAvBSeRUriL3tAX1QLixrDeRjsDst2b 6MsQ== 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=MlQJXGPAOXusDdm3bh9payk06ZDvvgN/3CBqe0JFDb0=; b=QQq0dEPAvSRjE/Vg/mB21EXP6dhRmfWOWLJmAxnyYQd4F4B7lXwAbTMmzLF43jKMzI 3VRp63d8hkjRIAu6Zj6qtfv9QixLalGvcVSGg84Ab5N+yjKRXksodlhy7Fo4TswA7t40 EKv69Pia3p7wVDSlYlgss7AGcBJC9ZHoUkIF9gas3a7VlafWIcJ4RWiehm6yLaK3ViY2 WWTwH9rMu+PMwQCQVUDgEOa4GvVpzOoBQnNw5qtNTPmeZVtG/BfVcqkbjTHepMgdGmwD zdvIn4ICCPrwJxGLwYMAzAy+H148LvhARMVtiJo7amvsxT+qOm7GvwCOLrGoYtHUz6nC 0d2Q== X-Gm-Message-State: ALoCoQknP41tiXca2C0s51GeJoAW8QmS6qLXSyZkr/T/vKVBVMFUiYSK9/ZsBPZPFPjk+rEyXGz4 X-Received: by 10.66.100.226 with SMTP id fb2mr324752pab.16.1447741034064; Mon, 16 Nov 2015 22:17:14 -0800 (PST) Received: from localhost.localdomain ([122.166.219.57]) by smtp.gmail.com with ESMTPSA id tp6sm40199084pbc.81.2015.11.16.22.17.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Nov 2015 22:17:13 -0800 (PST) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Tue, 17 Nov 2015 11:46:53 +0530 Message-Id: <1447741013-7333-5-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447741013-7333-1-git-send-email-bala.manoharan@linaro.org> References: <1447741013-7333-1-git-send-email-bala.manoharan@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 5/5] example: classifier: add odp_cls_cos_pool_set() 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" Adds packet pool to CoS using odp_cls_cos_pool_set() api. Signed-off-by: Balasubramanian Manoharan --- example/classifier/odp_classifier.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/example/classifier/odp_classifier.c b/example/classifier/odp_classifier.c index 365c748..fb9f407 100644 --- a/example/classifier/odp_classifier.c +++ b/example/classifier/odp_classifier.c @@ -85,8 +85,12 @@ 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_queue(odp_pktio_t pktio, appl_args_t *args); -static void configure_default_queue(odp_pktio_t pktio, appl_args_t *args); +static void configure_cos_queue(odp_pktio_t pktio, + appl_args_t *args, + odp_pool_t pool); +static void configure_default_queue(odp_pktio_t pktio, + appl_args_t *args, + odp_pool_t pool); static int convert_str_to_pmr_enum(char *token, odp_pmr_term_e *term, uint32_t *offset); static int parse_pmr_policy(appl_args_t *appl_args, char *argv[], char *optarg); @@ -320,7 +324,6 @@ static void *pktio_receive_thread(void *arg) /* Swap Eth MACs and possibly IP-addrs before sending back */ swap_pkt_addrs(&pkt, 1); - for (i = 0; i < MAX_PMR_COUNT; i++) { stats = &appl->stats[i]; if (queue == stats->queue) @@ -341,7 +344,9 @@ static void *pktio_receive_thread(void *arg) return NULL; } -static void configure_default_queue(odp_pktio_t pktio, appl_args_t *args) +static void configure_default_queue(odp_pktio_t pktio, + appl_args_t *args, + odp_pool_t pool) { odp_queue_param_t qparam; odp_cos_t cos_default; @@ -365,6 +370,11 @@ static void configure_default_queue(odp_pktio_t pktio, appl_args_t *args) exit(EXIT_FAILURE); } + if (0 > odp_cls_cos_pool_set(cos_default, pool)) { + EXAMPLE_ERR("odp_cls_cos_pool_set failed"); + exit(EXIT_FAILURE); + } + if (0 > odp_pktio_default_cos_set(pktio, cos_default)) { EXAMPLE_ERR("odp_pktio_default_cos_set failed"); exit(EXIT_FAILURE); @@ -379,7 +389,9 @@ static void configure_default_queue(odp_pktio_t pktio, appl_args_t *args) args->policy_count++; } -static void configure_cos_queue(odp_pktio_t pktio, appl_args_t *args) +static void configure_cos_queue(odp_pktio_t pktio, + appl_args_t *args, + odp_pool_t pool) { char cos_name[ODP_COS_NAME_LEN]; char queue_name[ODP_QUEUE_NAME_LEN]; @@ -402,6 +414,7 @@ static void configure_cos_queue(odp_pktio_t pktio, appl_args_t *args) }; 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; qparam.sched.group = ODP_SCHED_GROUP_ALL; @@ -411,11 +424,21 @@ static void configure_cos_queue(odp_pktio_t pktio, appl_args_t *args) stats->queue = odp_queue_create(queue_name, ODP_QUEUE_TYPE_SCHED, &qparam); + if (ODP_QUEUE_INVALID == stats->queue) { + EXAMPLE_ERR("odp_queue_create failed"); + exit(EXIT_FAILURE); + } + if (0 > odp_cos_queue_set(stats->cos, stats->queue)) { EXAMPLE_ERR("odp_cos_queue_set failed"); exit(EXIT_FAILURE); } + if (0 > odp_cls_cos_pool_set(stats->cos, pool)) { + EXAMPLE_ERR("odp_cls_cos_pool_set failed"); + exit(EXIT_FAILURE); + } + if (0 > odp_pktio_pmr_cos(stats->pmr, pktio, stats->cos)) { EXAMPLE_ERR("odp_pktio_pmr_cos failed"); exit(EXIT_FAILURE); @@ -510,10 +533,10 @@ int main(int argc, char *argv[]) /* create pktio per interface */ pktio = create_pktio(args->if_name, pool); - configure_cos_queue(pktio, args); + configure_cos_queue(pktio, args, pool); /* configure default Cos and default queue */ - configure_default_queue(pktio, args); + configure_default_queue(pktio, args, pool); if (odp_pktio_start(pktio)) { EXAMPLE_ERR("Error: unable to start pktio.\n");