From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E93DE4317C; Mon, 16 Oct 2023 11:01:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CB1F9402DC; Mon, 16 Oct 2023 11:01:13 +0200 (CEST) Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) by mails.dpdk.org (Postfix) with ESMTP id 3A6A8402BD for ; Mon, 16 Oct 2023 11:01:12 +0200 (CEST) Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-777655545aaso48021885a.3 for ; Mon, 16 Oct 2023 02:01:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697446871; x=1698051671; darn=dpdk.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=n5fC7QWDz5QlBDZO1V4XPORRB0QI3rIMYz7zCTnyFVc=; b=YtHnnDMQVtbFDrYDKEFUnAlVR7iEa11j2Y/nYuKG3RKn5J2BjyYggKwaEx0r9rjB4y wsA0VxMm51j3nybnMJSyiy4yoYzHo6uiXc356YRVblaPohzCBxWCcG+EGlahIIonuqA+ UFDP8qhWwA3Pz+qsrUYerADQYmsswFGgQINd0PlK1nOeLCtLCL1kQOY9vPOeDr0XltC4 BLKaaMZs/SmzmDKKptfffXOCKkRRxpp7LO2VMnq/AEcC3z10yjgkvx5NA9zMcrZMguAT jj/UWVJE9mgDRDB2WBmlPQClOqKvSxxFgyG+yaqJ5ZKeGJNNw0Lf5BFaOq4UqjHVbq4P z9Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697446871; x=1698051671; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n5fC7QWDz5QlBDZO1V4XPORRB0QI3rIMYz7zCTnyFVc=; b=TNLlwptIwW+Pf2rbLuZSSTzX66Q7fowOyb+otPEdycEnm+Sau5eGqbBcltI0OcdxWE rIMRWvg3U8r7ckM+82V85Q3Cwr41UKqrVm0sI3yO8z3JVlqzEkGUn8tzrpzN5XKuHzwj sKcrvqHSGSxlO8zvUw6kJQSYCUSiYm30YT2BgB3tlk6QOzSrH7/bPe1dhwDafPw7TMke sfD37QBD5DMatNTfc9G1crvXhxliBumfFAgTh5FT1u9LDeCW17DpLaxuVgptjV78SnSt o/DXtrwgmN/sEywzwCUmGQAa6MzfgHDfNTBM+RFte3wf23SUYTmDDYxY7ZSbsUK878Sl lAOg== X-Gm-Message-State: AOJu0Yyut2w0us9pvAJpvSYAw/hE6Lg38UYL1WRU2e363CrT0r9oVaa3 bLeNOCHaA559MLK4iZ8Xa1sxRuvYCKb3GLQ63UZBOwaj X-Google-Smtp-Source: AGHT+IGNOPjgrWR+yPZkA82PBQ/Na6cMB0OMI5d5I3zlKiMiduRZW+dYZZxLiU2Ouk7PPJhgW4FmhxTixxU7/e5h5/E= X-Received: by 2002:a05:622a:289:b0:419:5be3:d577 with SMTP id z9-20020a05622a028900b004195be3d577mr40298776qtw.36.1697446871413; Mon, 16 Oct 2023 02:01:11 -0700 (PDT) MIME-Version: 1.0 References: <20230927115412.55018-13-skori@marvell.com> <20230929095814.692890-1-skori@marvell.com> <20230929095814.692890-2-skori@marvell.com> In-Reply-To: <20230929095814.692890-2-skori@marvell.com> From: Jerin Jacob Date: Mon, 16 Oct 2023 14:30:45 +0530 Message-ID: Subject: Re: [PATCH v8 01/12] app/graph: add application framework to read CLI To: skori@marvell.com Cc: Thomas Monjalon , Rakesh Kudurumalla , dev@dpdk.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Fri, Sep 29, 2023 at 3:28=E2=80=AFPM wrote: > > From: Sunil Kumar Kori > > It adds base framework to read a given .cli file as a command line > parameter "-s". > > Example: > # ./dpdk-graph -c 0xff -- -s ./app/graph/examples/dummy.cli > > Each .cli file will contain commands to configure different module like > mempool, ethdev, lookup tables, graph etc. Command parsing is backed by > commandline library. > > Each module needs to expose its supported commands & corresponding > callback functions to commandline library to get them parsed. > > Signed-off-by: Sunil Kumar Kori > Signed-off-by: Rakesh Kudurumalla > +cli_script_process(const char *file_name, size_t msg_in_len_max, size_t = msg_out_len_max, void *obj) > +{ > + char *msg_in =3D NULL, *msg_out =3D NULL; > + FILE *f =3D NULL; > + > + /* Check input arguments */ > + if ((file_name =3D=3D NULL) || (strlen(file_name) =3D=3D 0) || (m= sg_in_len_max =3D=3D 0) || > + (msg_out_len_max =3D=3D 0)) > + return -EINVAL; > + > + msg_in =3D malloc(msg_in_len_max + 1); > + msg_out =3D malloc(msg_out_len_max + 1); > + if ((msg_in =3D=3D NULL) || (msg_out =3D=3D NULL)) { Use goto to avod dupliciting this section. > + free(msg_out); > + free(msg_in); > + return -ENOMEM; > + } > + > + /* Open input file */ > + f =3D fopen(file_name, "r"); > + if (f =3D=3D NULL) { > + free(msg_out); > + free(msg_in); > + return -EIO; > + } > + > + /* Read file */ > + while (fgets(msg_in, msg_in_len_max, f) !=3D NULL) { > + msg_out[0] =3D 0; > + > + cli_process(msg_in, msg_out, msg_out_len_max, obj); > + > + if (strlen(msg_out)) > + printf("%s", msg_out); > + } > + > + /* Close file */ > + fclose(f); See above: > + free(msg_out); > + free(msg_in); > + return 0; > +} > new file mode 100644 > index 0000000000..08d0a48cd9 > --- /dev/null > +++ b/app/graph/meson.build > @@ -0,0 +1,15 @@ > +# SPDX-License-Identifier: BSD-3-Clause > +# Copyright(c) 2023 Marvell. > + > +# override default name to drop the hyphen > +name =3D 'graph' > +build =3D cc.has_header('sys/epoll.h') Is this required? > +if not build > + subdir_done() > +endif > + > +deps +=3D ['bus_pci', 'graph', 'eal', 'lpm', 'ethdev', 'node', 'cmdline'= ] Check bus_pci really required? > +sources =3D files( > + 'cli.c', > + 'main.c', > +) > diff --git a/app/graph/module_api.h b/app/graph/module_api.h > new file mode 100644 > index 0000000000..372aeae7e3 > --- /dev/null > +++ b/app/graph/module_api.h > @@ -0,0 +1,16 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2023 Marvell. > + */ > + > +#ifndef APP_GRAPH_MODULE_API_H > +#define APP_GRAPH_MODULE_API_H > + > +#include > +#include Have a new line here. > +#include "cli.h" > +/* > + * Externs > + */ > new file mode 100644 > index 0000000000..271a85896d > --- /dev/null > +++ b/doc/guides/tools/graph.rst > @@ -0,0 +1,82 @@ > +.. SPDX-License-Identifier: BSD-3-Clause > + Copyright(c) 2023 Marvell. > + > +dpdk-graph Application > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > + > +The ``dpdk-graph`` tool is a Data Plane Development Kit (DPDK) > +application that allows exercising various graph use cases. > +This application has a generic framework to add new graph based use case= s to > +verify functionality. Each use case is defined as a ``.cli`` fi= le. > +Based on the input file, application creates a graph to cater the use ca= se. Could you add some detailed text to describe the fact that, due to modular nature this app framework can be used by other graph based application OR SO. > + > +Supported Use cases > +------------------- > + * This * can be removed in this patch. Add it when l3fwd adds it. > + > +Running the Application > +----------------------- > + > +The application has a number of command line options which can be provid= ed in > +following syntax > + > +.. code-block:: console > + > + dpdk-graph [EAL Options] -- [application options] > + > +EAL Options > +~~~~~~~~~~~ > + > +Following are the EAL command-line options that can be used in conjuncti= on > +with the ``dpdk-graph`` application. > +See the DPDK Getting Started Guides for more information on these option= s. > + > +* ``-c `` or ``-l `` > + > + Set the hexadecimal bit mask of the cores to run on. The CORELIS= T is a > + list of cores to be used. > + > +Application Options > +~~~~~~~~~~~~~~~~~~~ > + > +Following are the application command-line options: > + > +* ``-s`` > + > + Script name with absolute path which specifies the use case. It = is > + a mandatory parameter which will be used to create desired graph > + for a given use case. > + > +* ``--help`` > + > + Dumps application usage > + > +Supported CLI commands > +---------------------- > + > +This section provides details on commands which can be used in ``.cli`` > +file to express the requested use case configuration. > + > +.. list-table:: Exposed CLIs > + :widths: 40 40 10 10 > + :header-rows: 1 > + :class: longtable > + > + * - Command > + - Description > + - Dynamic > + - Optional > + * - Dummy command > + - Dummy command description > + - No > + - No Is it possible to make it as more vertical placement ? More horizontal placement is not PDF friendly.