From patchwork Mon Nov 23 10:12: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: 57136 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1344656lbb; Mon, 23 Nov 2015 02:18:32 -0800 (PST) X-Received: by 10.140.92.176 with SMTP id b45mr25102346qge.104.1448273912285; Mon, 23 Nov 2015 02:18:32 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 38si10618092qgm.44.2015.11.23.02.18.31; Mon, 23 Nov 2015 02:18:32 -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 CBECA61902; Mon, 23 Nov 2015 10:18:31 +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 78E406157A; Mon, 23 Nov 2015 10:14:31 +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 99B3C610B1; Mon, 23 Nov 2015 10:14:23 +0000 (UTC) Received: from mail-pa0-f41.google.com (mail-pa0-f41.google.com [209.85.220.41]) by lists.linaro.org (Postfix) with ESMTPS id A2183619FB for ; Mon, 23 Nov 2015 10:13:15 +0000 (UTC) Received: by pacej9 with SMTP id ej9so186839494pac.2 for ; Mon, 23 Nov 2015 02:13:15 -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=m2pAlxf/7ZTH4a8JhhRSATsOPzP7FAleCXgr3YpuJ7RNFCiT7BXnjF1VuBV0hhDjvR AH1RT1YaQeNcNuhuhvlSxKwhvpSi/Mz1eyrt0K+nJ2cGbwFCK5D24edvVYJPXV3CkcpN 4kP6BA/WW2Qdn3UsVgqB5jjsmIuOJRIvEhJNt2wHld09l5ecZV2GtWBvYKCtvcA8yHAR SF3cTm/xqwfnZJ8b/Er/1dnEbL1s6TA6hIH0MR8cR6JWxY+oaZY4QgAOf4UXO8aBIowC N7ZtL0aFGWwVz9oDeI4LCyqwzxAX582KJa4EXZaFbBHN2bFskxmUOXqp7Mvb+VqMsVBp xfxg== 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=HN157HSoNdAE/IUh5jSoSElMOCzdP4dqvKRkMc2ky1QjuUNXGTO7LkebM8VcrsrEsV O1AgUjuoyqrrco0/3mKDrMpMg2LxFZvAKVe8OYmyKn+ipAyMGjsZXBO7uMJroWha/wcE Kan1YJQkcVL0a3DVr/Mpx5bOz6mKSQuywZ/rywcAszP4djOwDDq8hHoj7ACdaAx3fejp rGz86uw90wqz0jYzJ1MLMiD65u1RS73fplyckB/fSxt9xu4nbv/3T870Gy8GeE1jsY33 u7cUvxVHrsa+GXO1+4BxyTv83eLfmKAM++GNC6LiSpKRg37hLmFqzKxbg/IApDeivbpQ FrSw== X-Gm-Message-State: ALoCoQly2Hu+sdjzGyq++mFYTFM/++lXFvtShmscl24oVYI1GtEk1k+K2wUc6IMbzIvaZfV0hw0O X-Received: by 10.66.236.201 with SMTP id uw9mr35244284pac.76.1448273594984; Mon, 23 Nov 2015 02:13:14 -0800 (PST) Received: from localhost.localdomain ([122.166.219.57]) by smtp.gmail.com with ESMTPSA id 132sm9247648pfc.63.2015.11.23.02.13.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Nov 2015 02:13:14 -0800 (PST) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Mon, 23 Nov 2015 15:42:52 +0530 Message-Id: <1448273572-27435-5-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1448273572-27435-1-git-send-email-bala.manoharan@linaro.org> References: <1448273572-27435-1-git-send-email-bala.manoharan@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv2 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");