From patchwork Wed Jan 13 22:07:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 59685 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp3632221lbb; Wed, 13 Jan 2016 14:07:20 -0800 (PST) X-Received: by 10.140.27.202 with SMTP id 68mr819283qgx.4.1452722840115; Wed, 13 Jan 2016 14:07:20 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id x187si3530909qhb.55.2016.01.13.14.07.19; Wed, 13 Jan 2016 14:07:20 -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 66E68617BD; Wed, 13 Jan 2016 22:07:19 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=EwJ4Mo8V; 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 86EB3617AD; Wed, 13 Jan 2016 22:07:14 +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 74A87617B8; Wed, 13 Jan 2016 22:07:12 +0000 (UTC) Received: from mail-qg0-f45.google.com (mail-qg0-f45.google.com [209.85.192.45]) by lists.linaro.org (Postfix) with ESMTPS id A3F32617A7 for ; Wed, 13 Jan 2016 22:07:10 +0000 (UTC) Received: by mail-qg0-f45.google.com with SMTP id e32so377687203qgf.3 for ; Wed, 13 Jan 2016 14:07:10 -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:mime-version:content-type :content-transfer-encoding; bh=VykC7qg85vxYNEbFCnAg8/H+Wp+EKsmAQPzsXngFM4Y=; b=EwJ4Mo8V9fgdu7lnZsSkj8zAg/q3aB5KorIUkE6IWglJd6UUJY5l5NsiMh5Fpiup8Y JcLQfCfwMK4e0KmhIYu8/YmZw8KxNb8Kru8q6ovhJBP1/0FFjSt926qJ0suLS2vtr8yt iGxaR4WJvwlszNOiwlGU61e4p3HxIVk8479Bg= 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:mime-version :content-type:content-transfer-encoding; bh=VykC7qg85vxYNEbFCnAg8/H+Wp+EKsmAQPzsXngFM4Y=; b=cI+A8DtqVFSATOIoRAyDiL6Fqz/iFP1lp0mtZ64wopEbFUfuflV7yhf0zY4VBZcPQd cOpHQuZUDL6hyYX/lXqqvJoP/HyabDFWZk01Ltnzydfq8FtE5JbdnW1cB/oJuuA8IwY2 SibZEQRMk7j8GPygyAghWXH0vJEFSg66WcQDwctf6RFCLQeUTr0CAaJ1yCr72qSH0JwL zswNOlPU3f0rb3cnyqThVVaE1ZiaXTLGPu4F/p1tYTPQQGhSQYyDRsUhVxFjBY5Wp1JU Fz33BiXWjnOCh0RkDgz0cgN9UjApK2x7CR1ZuZtfHD0pvy1jJAJ7eOyEBsNHTNAo81Iv Yi/Q== X-Gm-Message-State: ALoCoQlMANt0xth3N1byr/iBGbm3XEfaHj5L2nHVfYKE97BrHnAQZ4Rtc18gOuRR8zB9CVBbSJC2xvfT4whC0UYL+tgzZCtaWA== X-Received: by 10.140.167.135 with SMTP id n129mr750157qhn.73.1452722830412; Wed, 13 Jan 2016 14:07:10 -0800 (PST) Received: from localhost.localdomain (c-98-221-136-245.hsd1.nj.comcast.net. [98.221.136.245]) by smtp.gmail.com with ESMTPSA id v74sm1320644qka.7.2016.01.13.14.07.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Jan 2016 14:07:09 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Wed, 13 Jan 2016 17:07:03 -0500 Message-Id: <1452722824-13299-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.5.0 MIME-Version: 1.0 X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH 1/2] doc: users: add TM example 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Signed-off-by: Mike Holmes Reviewed-by: Bill Fischofer --- doc/users-guide/users-guide-tm.adoc | 83 +++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/doc/users-guide/users-guide-tm.adoc b/doc/users-guide/users-guide-tm.adoc index dc0d003..e68157f 100644 --- a/doc/users-guide/users-guide-tm.adoc +++ b/doc/users-guide/users-guide-tm.adoc @@ -262,3 +262,86 @@ This header file defines some constants representing the absolute maximum settings for any TM system, though in most cases a TM system can (and should) be created/instantiated with smaller values, since lower values will often result in faster operation and/or less memory used. + +=== Examples + +.Create a tm_node chain for two nodes and associate the scheduler +[source,c] +---- + + odp_tm_params_init(&tm_params); /* <1> */ + tm_params.pktio = egress_pktio; + tm = odp_tm_create(“Example TM”, &tm_params); + +/* create 5 input queues here – two at priority 1 and three at priority 2. */ + + odp_tm_queue_params_init(&queue_params); + queue_params.priority = 1; + tmq_A1 = odp_tm_queue_create(tm, &queue_params); + tmq_B1 = odp_tm_queue_create(tm, &queue_params); + + queue_params.priority = 2; + tmq_A2 = odp_tm_queue_create(tm, &queue_params); + tmq_B2 = odp_tm_queue_create(tm, &queue_params); + tmq_C2 = odp_tm_queue_create(tm, &queue_params); + + odp_tm_node_params_init(&node_params); /* <2> */ + node_params.level = 1; + tm_node_1 = odp_tm_node_create(tm, “TmNode1”, &node_params); + + odp_tm_queue_connect(tmq_A1, tm_node_1); /* <3> */ + odp_tm_queue_connect(tmq_B1, tm_node_1); + odp_tm_queue_connect(tmq_A2, tm_node_1); + odp_tm_queue_connect(tmq_B2, tm_node_1); + odp_tm_queue_connect(tmq_C2, tm_node_1); + +/* It is IMPORTANT to understand that the following code does NOT create any +schedulers! In fact there is NO call to create a tm scheduler that exists +inside of a tm_node. Such an entity comes into existence as needed. What this +code does is create a scheduler PROFILE, which is effectively a registered set +of common scheduler parameters. NOTE that this uses some pseudocode below +instead of real C code so as to be more concise. */ + + odp_tm_sched_params_init(&sched_params); /* <4> */ + sched_params.sched_modes = { ODP_TM_FRAME_BASED_WEIGHTS, … }; + sched_params.sched_weights = { 8, 8, 8, … }; + sched_profile_RR = odp_tm_sched_create(“SchedProfileRR”, &sched_params); + + sched_params.sched_modes = { ODP_TM_BYTE_BASED_WEIGHTS, … }; + sched_params.sched_weights = { 8, 8, 8, … }; + sched_profile_FQ = odp_tm_sched_create(“SchedProfileFQ”, &sched_params); + + odp_tm_queue_sched_config(tm_node_1, tmq_A1, sched_profile_RR); /* <5> */ + odp_tm_queue_sched_config(tm_node_1, tmq_B1, sched_profile_RR); + odp_tm_queue_sched_config(tm_node_1, tmq_A2, sched_profile_FQ); + odp_tm_queue_sched_config(tm_node_1, tmq_B2, sched_profile_FQ); + odp_tm_queue_sched_config(tm_node_1, tmq_C2, sched_profile_FQ); + + odp_tm_node_params_init(&node_params); /* <6> */ + node_params.level = 2; + tm_node_2 = odp_tm_node_create(tm, “TmNode2”, &node_params); + + odp_tm_node_connect(tm_node_1, tm_node_2); /* <7> */ + + odp_tm_sched_params_init(&sched_params); /* <8> */ + sched_params.sched_modes = { ODP_TM_BYTE_BASED_WEIGHTS, … }; + sched_params.sched_weights = { 8, 16, 24, … }; + sched_profile_WFQ = odp_tm_sched_create(“SchedProfileWFQ”, &sched_params); + + odp_tm_node_sched_config(tm_node_2, tm_node_1, sched_profile_WFQ); /* <9> */ +---- + +<1> Create a tm system, since that is a precursor to creating tm_queues. +<2> Create a Node #1 +<3> Connect the Queue(s) to the Node -> odp_tm_queue_connect() +<4> Create two sets of scheduler params – one implementing Round Robin (since +all weights are the same – namely 8) and the second implementing Fair Queuing. + +<5> Associate the Scheduler to the Node and the Queue(s) -> odp_tm_queue_sched_config() +Use the Round Robin profile for the priority 1 fan-in’s and Fair Queuing +for the priority 2 fan-ins. + +<6> Create a second Node #2 +<7> Connect the first Node #1 to the second Node #2 -> odp_tm_node_connect() +<8> Create a Scheduler Profile +<9> Associate the Scheduler to the Node #1 and #2 -> odp_tm_node_sched_config()