Show a patch.

GET /api/patches/386/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 386,
    "url": "https://patches.dpdk.org/api/patches/386/?format=api",
    "web_url": "https://patches.dpdk.org/patch/386/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk"
    },
    "msgid": "<1410869607-16842-3-git-send-email-reshma.pattan@intel.com>",
    "date": "2014-09-16T12:13:26",
    "name": "[dpdk-dev,2/3] distributor_app: code review comments implementation",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "e002788019d0dab21e11d2ba7ed4b4e755400b20",
    "submitter": {
        "id": 70,
        "url": "https://patches.dpdk.org/api/people/70/?format=api",
        "name": "Pattan, Reshma",
        "email": "reshma.pattan@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/patch/386/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/386/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/386/checks/",
    "tags": {},
    "headers": {
        "X-Mailman-Version": "2.1.15",
        "X-ExtLoop1": "1",
        "Errors-To": "dev-bounces@dpdk.org",
        "X-Mailer": "git-send-email 1.7.4.1",
        "Received": [
            "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 5D076B38C;\n\tTue, 16 Sep 2014 14:08:09 +0200 (CEST)",
            "from mga09.intel.com (mga09.intel.com [134.134.136.24])\n\tby dpdk.org (Postfix) with ESMTP id 67DA9B372\n\tfor <dev@dpdk.org>; Tue, 16 Sep 2014 14:08:07 +0200 (CEST)",
            "from azsmga001.ch.intel.com ([10.2.17.19])\n\tby orsmga102.jf.intel.com with ESMTP; 16 Sep 2014 05:07:32 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby azsmga001.ch.intel.com with ESMTP; 16 Sep 2014 05:13:40 -0700",
            "from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com\n\t[10.237.217.46])\n\tby irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id\n\ts8GCDZUr020138; Tue, 16 Sep 2014 13:13:36 +0100",
            "from sivswdev02.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev02.ir.intel.com with ESMTP id s8GCDZZF016911;\n\tTue, 16 Sep 2014 13:13:35 +0100",
            "(from reshmapa@localhost)\n\tby sivswdev02.ir.intel.com with  id s8GCDZDJ016907;\n\tTue, 16 Sep 2014 13:13:35 +0100"
        ],
        "References": "<1410869607-16842-1-git-send-email-reshma.pattan@intel.com>",
        "Delivered-To": "patchwork@dpdk.org",
        "X-BeenThere": "dev@dpdk.org",
        "Message-Id": "<1410869607-16842-3-git-send-email-reshma.pattan@intel.com>",
        "X-IronPort-AV": "E=Sophos;i=\"5.04,534,1406617200\"; d=\"scan'208\";a=\"477854469\"",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Precedence": "list",
        "From": "reshmapa <reshma.pattan@intel.com>",
        "X-Original-To": "patchwork@dpdk.org",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "In-Reply-To": "<1410869607-16842-1-git-send-email-reshma.pattan@intel.com>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "To": "dev@dpdk.org",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "Date": "Tue, 16 Sep 2014 13:13:26 +0100",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "Subject": "[dpdk-dev] [PATCH 2/3] distributor_app: code review comments\n\timplementation"
    },
    "content": "From: Reshma Pattan <reshma.pattan@intel.com>\n\n    * support provided for command-line option portmask.\n    * removed -g option in make file\n    * spacing adjustment in header files inclusion in main.c\n    * removal of const +3 in delcarration of rte_mbuf inside\n      output_buffer structure declaration\n\n    Changes in V2:\n\nSigned-off-by: Reshma Pattan <reshma.pattan@intel.com>\n---\n examples/distributor_app/Makefile |   2 +-\n examples/distributor_app/main.c   | 137 ++++++++++++++++++++++++++++++++++++--\n 2 files changed, 133 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/examples/distributor_app/Makefile b/examples/distributor_app/Makefile\nindex d46746e..394785d 100644\n--- a/examples/distributor_app/Makefile\n+++ b/examples/distributor_app/Makefile\n@@ -52,6 +52,6 @@ ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)\n CFLAGS_main.o += -Wno-return-type\n endif\n \n-EXTRA_CFLAGS += -O3 -g -Wfatal-errors\n+EXTRA_CFLAGS += -O3 -Wfatal-errors\n \n include $(RTE_SDK)/mk/rte.extapp.mk\ndiff --git a/examples/distributor_app/main.c b/examples/distributor_app/main.c\nindex 45d5bc1..fab8199 100644\n--- a/examples/distributor_app/main.c\n+++ b/examples/distributor_app/main.c\n@@ -35,6 +35,7 @@\n #include <inttypes.h>\n #include <unistd.h>\n #include <signal.h>\n+#include <getopt.h>\n \n #include <rte_eal.h>\n #include <rte_ethdev.h>\n@@ -42,6 +43,7 @@\n #include <rte_malloc.h>\n #include <rte_debug.h>\n #include <rte_distributor.h>\n+\n #include \"main.h\"\n \n #define RX_RING_SIZE 256\n@@ -66,6 +68,9 @@\n #define BURST_SIZE 32\n #define RTE_RING_SZ 1024\n \n+/* mask of enabled ports */\n+static uint32_t enabled_port_mask = 0;\n+\n static volatile struct app_stats {\n \tstruct {\n \t\tuint64_t rx_pkts;\n@@ -127,7 +132,7 @@ static const struct rte_eth_txconf tx_conf_default = {\n \n struct output_buffer {\n \tunsigned count;\n-\tstruct rte_mbuf *mbufs[BURST_SIZE + 3];\n+\tstruct rte_mbuf *mbufs[BURST_SIZE];\n };\n \n /*\n@@ -210,16 +215,27 @@ lcore_rx(struct lcore_params *p)\n \tconst int socket_id = rte_socket_id();\n \tuint8_t port;\n \n-\tfor (port = 0; port < nb_ports; port++)\n+\tfor (port = 0; port < nb_ports; port++){\n+\t\t/* skip ports that are not enabled */\n+\t\tif ((enabled_port_mask & (1 << port)) == 0){\n+\t\t\tcontinue;\n+\t\t}\n \t\tif (rte_eth_dev_socket_id(port) > 0 &&\n \t\t\t\trte_eth_dev_socket_id(port) != socket_id)\n \t\t\tprintf(\"WARNING, port %u is on remote NUMA node to \"\n \t\t\t\t\t\"RX thread.\\n\\tPerformance will not \"\n \t\t\t\t\t\"be optimal.\\n\", port);\n+\t}\n \n \tprintf(\"\\nCore %u doing packet RX.\\n\", rte_lcore_id());\n \tport = 0;\n \tfor (;;) {\n+\t\t/* skip ports that are not enabled */ \n+\t\tif ((enabled_port_mask & (1 << port)) == 0){\n+\t\t\tif (++port == nb_ports)\n+\t\t\t\tport = 0;\n+\t\t\tcontinue;\n+\t\t}\n \t\tstruct rte_mbuf *bufs[BURST_SIZE*2];\n \t\tconst uint16_t nb_rx = rte_eth_rx_burst(port, 0, bufs,\n \t\t\t\tBURST_SIZE);\n@@ -265,6 +281,11 @@ flush_all_ports(struct output_buffer *tx_buffers, uint8_t nb_ports)\n {\n \tuint8_t outp;\n \tfor (outp = 0; outp < nb_ports; outp++) {\n+\t\t/* skip ports that are not enabled */\n+\t\tif ((enabled_port_mask & (1 << outp)) == 0){\n+\t\t\tcontinue; \n+\t\t}\n+\n \t\tif (tx_buffers[outp].count == 0)\n \t\t\tcontinue;\n \n@@ -280,16 +301,25 @@ lcore_tx(struct rte_ring *in_r)\n \tconst int socket_id = rte_socket_id();\n \tuint8_t port;\n \n-\tfor (port = 0; port < nb_ports; port++)\n+\tfor (port = 0; port < nb_ports; port++){\n+\t\t/* skip ports that are not enabled */ \n+\t\tif ((enabled_port_mask & (1 << port)) == 0){\n+\t\t\tcontinue;\n+\t\t}\n \t\tif (rte_eth_dev_socket_id(port) > 0 &&\n \t\t\t\trte_eth_dev_socket_id(port) != socket_id)\n \t\t\tprintf(\"WARNING, port %u is on remote NUMA node to \"\n \t\t\t\t\t\"TX thread.\\n\\tPerformance will not \"\n \t\t\t\t\t\"be optimal.\\n\", port);\n+\t}\n \n \tprintf(\"\\nCore %u doing packet TX.\\n\", rte_lcore_id());\n \tfor (;;) {\n \t\tfor (port = 0; port < nb_ports; port++) {\n+\t\t\t/* skip ports that are not enabled */ \n+\t\t\tif ((enabled_port_mask & (1 << port)) == 0){\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tstruct rte_mbuf *bufs[BURST_SIZE];\n \t\t\tconst uint16_t nb_rx = rte_ring_dequeue_burst(in_r,\n \t\t\t\t\t(void *)bufs, BURST_SIZE);\n@@ -313,6 +343,10 @@ lcore_tx(struct rte_ring *in_r)\n \t\t\t\t/* workers should update in_port to hold the\n \t\t\t\t * output port value */\n \t\t\t\toutp = bufs[i]->pkt.in_port;\n+\t\t\t\t/* skip ports that are not enabled */\n+\t\t\t\tif ((enabled_port_mask & (1 << outp)) == 0){\n+\t\t\t\t\tcontinue;\n+\t\t\t\t}\n \t\t\t\toutbuf = &tx_buffers[outp];\n \t\t\t\toutbuf->mbufs[outbuf->count++] = bufs[i];\n \t\t\t\tif (outbuf->count == BURST_SIZE)\n@@ -370,6 +404,77 @@ int_handler(int sig_num)\n \texit(0);\n }\n \n+/* display usage */\n+static void\n+print_usage(const char *prgname)\n+{\n+        printf(\"%s [EAL options] -- -p PORTMASK\\n\"\n+               \"  -p PORTMASK: hexadecimal bitmask of ports to configure\\n\",\n+               prgname);\n+}\n+\n+static int\n+parse_portmask(const char *portmask)\n+{\n+        char *end = NULL;\n+        unsigned long pm;\n+\n+        /* parse hexadecimal string */\n+        pm = strtoul(portmask, &end, 16);\n+        if ((portmask[0] == '\\0') || (end == NULL) || (*end != '\\0'))\n+                return -1;\n+\n+        if (pm == 0)\n+                return -1;\n+\n+        return pm;\n+}\n+\n+/* Parse the argument given in the command line of the application */\n+static int \n+parse_args(int argc, char **argv)\n+{\n+        int opt;\n+        char **argvopt;\n+        int option_index;\n+        char *prgname = argv[0];\n+        static struct option lgopts[] = { \n+                {NULL, 0, 0, 0}\n+        };  \n+\n+        argvopt = argv;\n+\n+        while ((opt = getopt_long(argc, argvopt, \"p:\",\n+                                  lgopts, &option_index)) != EOF) {\n+\n+                switch (opt) {\n+                /* portmask */\n+                case 'p':\n+                        enabled_port_mask = parse_portmask(optarg);\n+                        if (enabled_port_mask == 0) {\n+                                printf(\"invalid portmask\\n\");\n+                                print_usage(prgname);\n+                                return -1; \n+                        }   \n+                        break;\n+\t\t\n+\t\tdefault:\n+\t\t\tprint_usage(prgname);\n+\t\t\treturn -1;\n+\t\t}\n+        }\n+\t\n+\tif (optind <= 1) {\n+\t\tprint_usage(prgname);\n+\t\treturn -1;\n+\t}\n+\n+\targv[optind-1] = prgname;\n+\n+        optind = 0; /* reset getopt lib */\n+        return 0;\n+}\n+\n /* Main function, does initialization and calls the per-lcore functions */\n int\n MAIN(int argc, char *argv[])\n@@ -380,6 +485,7 @@ MAIN(int argc, char *argv[])\n \tunsigned lcore_id, worker_id = 0;\n \tunsigned nb_ports;\n \tuint8_t portid;\n+\tuint8_t nb_ports_available;\n \n \t/* catch ctrl-c so we can print on exit */\n \tsignal(SIGINT, int_handler);\n@@ -391,6 +497,11 @@ MAIN(int argc, char *argv[])\n \targc -= ret;\n \targv += ret;\n \n+        /* parse application arguments (after the EAL ones) */\n+        ret = parse_args(argc, argv);\n+        if (ret < 0) \n+                rte_exit(EXIT_FAILURE, \"Invalid distributor parameters\\n\");\n+\n \tif (rte_lcore_count() < 3)\n \t\trte_exit(EXIT_FAILURE, \"Error, This application needs at \"\n \t\t\t\t\"least 3 logical cores to run:\\n\"\n@@ -417,11 +528,28 @@ MAIN(int argc, char *argv[])\n \tif (mbuf_pool == NULL)\n \t\trte_exit(EXIT_FAILURE, \"Cannot create mbuf pool\\n\");\n \n+\tnb_ports_available = nb_ports;\n+\n \t/* initialize all ports */\n-\tfor (portid = 0; portid < nb_ports; portid++)\n+\tfor (portid = 0; portid < nb_ports; portid++){\n+\t\t/* skip ports that are not enabled */\n+\t\tif ((enabled_port_mask & (1 << portid)) == 0){\n+\t\t\tprintf(\"\\nSkipping disabled port %d\\n\", portid);\n+\t\t\tnb_ports_available--;\n+\t\t\tcontinue;\n+\t\t}\n+\t\t/* init port */\n+                printf(\"Initializing port %u... done\\n\", (unsigned) portid);\n+\n \t\tif (port_init(portid, mbuf_pool) != 0)\n \t\t\trte_exit(EXIT_FAILURE, \"Cannot initialize port %\"PRIu8\"\\n\",\n \t\t\t\t\tportid);\n+\t}\n+\n+        if (!nb_ports_available) {\n+                rte_exit(EXIT_FAILURE,\n+                        \"All available ports are disabled. Please set portmask.\\n\");\n+        }   \n \n \td = rte_distributor_create(\"PKT_DIST\", rte_socket_id(),\n \t\t\trte_lcore_count() - 2);\n@@ -456,4 +584,3 @@ MAIN(int argc, char *argv[])\n \tlcore_rx(&p);\n \treturn 0;\n }\n-\n",
    "prefixes": [
        "dpdk-dev",
        "2/3"
    ]
}