Show a patch.

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

{
    "id": 417,
    "url": "https://patches.dpdk.org/api/patches/417/",
    "web_url": "https://patches.dpdk.org/patch/417/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/",
        "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": "<1410961612-8571-21-git-send-email-david.marchand@6wind.com>",
    "date": "2014-09-17T13:46:52",
    "name": "[dpdk-dev,v3,20/20] eal: set log level from command line",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "39eb3de8e47590b79e6594ff774f5f4876ce5393",
    "submitter": {
        "id": 3,
        "url": "https://patches.dpdk.org/api/people/3/",
        "name": "David Marchand",
        "email": "david.marchand@6wind.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/patch/417/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/417/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/417/checks/",
    "tags": {},
    "headers": {
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "X-Gm-Message-State": "ALoCoQkzcQw7uM5JE/7PBiEHOs6plRS17cPQ6vlo4fD0ikyGf6VavmhI8/mPB5Nz/OogeqZ6giJW",
        "X-Original-To": "patchwork@dpdk.org",
        "List-Post": "<mailto:dev@dpdk.org>",
        "References": "<1410961612-8571-1-git-send-email-david.marchand@6wind.com>",
        "X-BeenThere": "dev@dpdk.org",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "Subject": "[dpdk-dev] [PATCH v3 20/20] eal: set log level from command line",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 3B43CB3FA;\n\tWed, 17 Sep 2014 15:41:58 +0200 (CEST)",
            "from mail-we0-f170.google.com (mail-we0-f170.google.com\n\t[74.125.82.170]) by dpdk.org (Postfix) with ESMTP id EF661B3F3\n\tfor <dev@dpdk.org>; Wed, 17 Sep 2014 15:41:54 +0200 (CEST)",
            "by mail-we0-f170.google.com with SMTP id u57so1470611wes.1\n\tfor <dev@dpdk.org>; Wed, 17 Sep 2014 06:47:36 -0700 (PDT)",
            "from alcyon.dev.6wind.com (guy78-3-82-239-227-177.fbx.proxad.net.\n\t[82.239.227.177]) by mx.google.com with ESMTPSA id\n\tfa20sm5712872wic.1.2014.09.17.06.47.34 for <multiple recipients>\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tWed, 17 Sep 2014 06:47:35 -0700 (PDT)"
        ],
        "To": "dev@dpdk.org",
        "X-Mailer": "git-send-email 1.7.10.4",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20130820;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=anyAQz1Z+VvDGU917BidXD9WYDPrx1uIuP4pyXzudp4=;\n\tb=akDY2NM5/PIpO6za9IXnsMOHVkWZEDO7MicetjIWfFRDbSDv4JTIlsTA1HiKGiXpD6\n\tF+PezYib+FheOBeu1+xhp6KmZPQX8e0gcfsEifRw91fsaXvCdVaWCmfQZD5p3QyeRjPO\n\tJf4dloW02iFHEtvOt0MvMCAnwxnPptjnhKwF1JTlxYhzdGBca9KRJYTujwh9GJE3qgs8\n\tNs9XBeSKq4LFq1vTWJ4eSOlndc4IpKFZvgIlJUj5f1dp++BY28qt6wPpJCNp+NFjZ2Ih\n\tiMy4axCLPO/FT22ZjyTbV7cF1AWsRq8nzZpa2+HXujXR7f5tURr1407EeEE0jJM0oUzj\n\toGcQ==",
        "Date": "Wed, 17 Sep 2014 15:46:52 +0200",
        "X-Received": "by 10.180.36.15 with SMTP id m15mr41727499wij.6.1410961656110;\n\tWed, 17 Sep 2014 06:47:36 -0700 (PDT)",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "From": "David Marchand <david.marchand@6wind.com>",
        "In-Reply-To": "<1410961612-8571-1-git-send-email-david.marchand@6wind.com>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Message-Id": "<1410961612-8571-21-git-send-email-david.marchand@6wind.com>",
        "Return-Path": "<dev-bounces@dpdk.org>"
    },
    "content": "Add a --log-level option to set the default eal log level.\n\nSigned-off-by: David Marchand <david.marchand@6wind.com>\nAcked-by: Bruce Richardson <bruce.richardson@intel.com>\n---\n lib/librte_eal/bsdapp/eal/eal.c                    |   42 +++++++++++++++++++\n .../bsdapp/eal/include/eal_internal_cfg.h          |    1 +\n lib/librte_eal/linuxapp/eal/eal.c                  |   44 +++++++++++++++++++-\n .../linuxapp/eal/include/eal_internal_cfg.h        |    1 +\n 4 files changed, 87 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c\nindex 71f93e0..2f84742 100644\n--- a/lib/librte_eal/bsdapp/eal/eal.c\n+++ b/lib/librte_eal/bsdapp/eal/eal.c\n@@ -94,6 +94,7 @@\n #define OPT_PCI_BLACKLIST \"pci-blacklist\"\n #define OPT_VDEV        \"vdev\"\n #define OPT_SYSLOG      \"syslog\"\n+#define OPT_LOG_LEVEL   \"log-level\"\n \n #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL)\n \n@@ -293,6 +294,7 @@ eal_usage(const char *prgname)\n \t       \"  -v           : Display version information on startup\\n\"\n \t       \"  -m MB        : memory to allocate\\n\"\n \t       \"  -r NUM       : force number of memory ranks (don't detect)\\n\"\n+\t       \"  --\"OPT_LOG_LEVEL\"  : set default log level\\n\"\n \t       \"  --\"OPT_PROC_TYPE\"  : type of this process\\n\"\n \t       \"  --\"OPT_PCI_BLACKLIST\", -b: add a PCI device in black list.\\n\"\n \t       \"               Prevent EAL from using this PCI device. The argument\\n\"\n@@ -440,6 +442,28 @@ eal_parse_syslog(const char *facility)\n \treturn -1;\n }\n \n+static int\n+eal_parse_log_level(const char *level, uint32_t *log_level)\n+{\n+\tchar *end;\n+\tunsigned long tmp;\n+\n+\terrno = 0;\n+\ttmp = strtoul(level, &end, 0);\n+\n+\t/* check for errors */\n+\tif ((errno != 0) || (level[0] == '\\0') ||\n+\t    end == NULL || (*end != '\\0'))\n+\t\treturn -1;\n+\n+\t/* log_level is a uint32_t */\n+\tif (tmp >= UINT32_MAX)\n+\t\treturn -1;\n+\n+\t*log_level = tmp;\n+\treturn 0;\n+}\n+\n static inline size_t\n eal_get_hugepage_mem_size(void)\n {\n@@ -494,6 +518,7 @@ eal_parse_args(int argc, char **argv)\n \t\t{OPT_PCI_BLACKLIST, 1, 0, 0},\n \t\t{OPT_VDEV, 1, 0, 0},\n \t\t{OPT_SYSLOG, 1, NULL, 0},\n+\t\t{OPT_LOG_LEVEL, 1, NULL, 0},\n \t\t{0, 0, 0, 0}\n \t};\n \n@@ -506,6 +531,8 @@ eal_parse_args(int argc, char **argv)\n \tinternal_config.hugepage_dir = NULL;\n \tinternal_config.force_sockets = 0;\n \tinternal_config.syslog_facility = LOG_DAEMON;\n+\t/* default value from build option */\n+\tinternal_config.log_level = RTE_LOG_LEVEL;\n #ifdef RTE_LIBEAL_USE_HPET\n \tinternal_config.no_hpet = 0;\n #else\n@@ -652,6 +679,18 @@ eal_parse_args(int argc, char **argv)\n \t\t\t\t\teal_usage(prgname);\n \t\t\t\t\treturn -1;\n \t\t\t\t}\n+\t\t\t} else if (!strcmp(lgopts[option_index].name,\n+\t\t\t\t\t OPT_LOG_LEVEL)) {\n+\t\t\t\tuint32_t log;\n+\n+\t\t\t\tif (eal_parse_log_level(optarg, &log) < 0) {\n+\t\t\t\t\tRTE_LOG(ERR, EAL,\n+\t\t\t\t\t\t\"invalid parameters for --\"\n+\t\t\t\t\t\tOPT_LOG_LEVEL \"\\n\");\n+\t\t\t\t\teal_usage(prgname);\n+\t\t\t\t\treturn -1;\n+\t\t\t\t}\n+\t\t\t\tinternal_config.log_level = log;\n \t\t\t}\n \t\t\tbreak;\n \n@@ -793,6 +832,9 @@ rte_eal_init(int argc, char **argv)\n \tif (fctret < 0)\n \t\texit(1);\n \n+\t/* set log level as early as possible */\n+\trte_set_log_level(internal_config.log_level);\n+\n \tif (internal_config.no_hugetlbfs == 0 &&\n \t\t\tinternal_config.process_type != RTE_PROC_SECONDARY &&\n \t\t\teal_hugepage_info_init() < 0)\ndiff --git a/lib/librte_eal/bsdapp/eal/include/eal_internal_cfg.h b/lib/librte_eal/bsdapp/eal/include/eal_internal_cfg.h\nindex 2d06c7f..24cefc2 100644\n--- a/lib/librte_eal/bsdapp/eal/include/eal_internal_cfg.h\n+++ b/lib/librte_eal/bsdapp/eal/include/eal_internal_cfg.h\n@@ -75,6 +75,7 @@ struct internal_config {\n \tvolatile uint64_t socket_mem[RTE_MAX_NUMA_NODES]; /**< amount of memory per socket */\n \tuintptr_t base_virtaddr;          /**< base address to try and reserve memory from */\n \tvolatile int syslog_facility;\t  /**< facility passed to openlog() */\n+\tvolatile uint32_t log_level;\t  /**< default log level */\n \tconst char *hugefile_prefix;      /**< the base filename of hugetlbfs files */\n \tconst char *hugepage_dir;         /**< specific hugetlbfs directory to use */\n \ndiff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c\nindex 4869e7c..38cace6 100644\n--- a/lib/librte_eal/linuxapp/eal/eal.c\n+++ b/lib/librte_eal/linuxapp/eal/eal.c\n@@ -97,6 +97,7 @@\n #define OPT_PCI_BLACKLIST \"pci-blacklist\"\n #define OPT_VDEV        \"vdev\"\n #define OPT_SYSLOG      \"syslog\"\n+#define OPT_LOG_LEVEL   \"log-level\"\n #define OPT_BASE_VIRTADDR   \"base-virtaddr\"\n #define OPT_XEN_DOM0    \"xen-dom0\"\n #define OPT_CREATE_UIO_DEV \"create-uio-dev\"\n@@ -384,7 +385,8 @@ eal_usage(const char *prgname)\n \t       \"  --\"OPT_XEN_DOM0\" : support application running on Xen Domain0 \"\n \t\t\t   \"without hugetlbfs\\n\"\n \t       \"  --\"OPT_SYSLOG\"     : set syslog facility\\n\"\n-\t       \"  --\"OPT_SOCKET_MEM\" : memory to allocate on specific \\n\"\n+\t       \"  --\"OPT_LOG_LEVEL\"  : set default log level\\n\"\n+\t       \"  --\"OPT_SOCKET_MEM\" : memory to allocate on specific\\n\"\n \t\t   \"                 sockets (use comma separated values)\\n\"\n \t       \"  --\"OPT_HUGE_DIR\"   : directory where hugetlbfs is mounted\\n\"\n \t       \"  --\"OPT_PROC_TYPE\"  : type of this process\\n\"\n@@ -548,6 +550,28 @@ eal_parse_syslog(const char *facility)\n }\n \n static int\n+eal_parse_log_level(const char *level, uint32_t *log_level)\n+{\n+\tchar *end;\n+\tunsigned long tmp;\n+\n+\terrno = 0;\n+\ttmp = strtoul(level, &end, 0);\n+\n+\t/* check for errors */\n+\tif ((errno != 0) || (level[0] == '\\0') ||\n+\t    end == NULL || (*end != '\\0'))\n+\t\treturn -1;\n+\n+\t/* log_level is a uint32_t */\n+\tif (tmp >= UINT32_MAX)\n+\t\treturn -1;\n+\n+\t*log_level = tmp;\n+\treturn 0;\n+}\n+\n+static int\n eal_parse_socket_mem(char *socket_mem)\n {\n \tchar * arg[RTE_MAX_NUMA_NODES];\n@@ -699,6 +723,7 @@ eal_parse_args(int argc, char **argv)\n \t\t{OPT_PCI_BLACKLIST, 1, 0, 0},\n \t\t{OPT_VDEV, 1, 0, 0},\n \t\t{OPT_SYSLOG, 1, NULL, 0},\n+\t\t{OPT_LOG_LEVEL, 1, NULL, 0},\n \t\t{OPT_VFIO_INTR, 1, NULL, 0},\n \t\t{OPT_BASE_VIRTADDR, 1, 0, 0},\n \t\t{OPT_XEN_DOM0, 0, 0, 0},\n@@ -716,6 +741,8 @@ eal_parse_args(int argc, char **argv)\n \tinternal_config.hugepage_dir = NULL;\n \tinternal_config.force_sockets = 0;\n \tinternal_config.syslog_facility = LOG_DAEMON;\n+\t/* default value from build option */\n+\tinternal_config.log_level = RTE_LOG_LEVEL;\n \tinternal_config.xen_dom0_support = 0;\n \t/* if set to NONE, interrupt mode is determined automatically */\n \tinternal_config.vfio_intr_mode = RTE_INTR_MODE_NONE;\n@@ -887,6 +914,18 @@ eal_parse_args(int argc, char **argv)\n \t\t\t\t\teal_usage(prgname);\n \t\t\t\t\treturn -1;\n \t\t\t\t}\n+\t\t\t} else if (!strcmp(lgopts[option_index].name,\n+\t\t\t\t\t OPT_LOG_LEVEL)) {\n+\t\t\t\tuint32_t log;\n+\n+\t\t\t\tif (eal_parse_log_level(optarg, &log) < 0) {\n+\t\t\t\t\tRTE_LOG(ERR, EAL,\n+\t\t\t\t\t\t\"invalid parameters for --\"\n+\t\t\t\t\t\tOPT_LOG_LEVEL \"\\n\");\n+\t\t\t\t\teal_usage(prgname);\n+\t\t\t\t\treturn -1;\n+\t\t\t\t}\n+\t\t\t\tinternal_config.log_level = log;\n \t\t\t}\n \t\t\telse if (!strcmp(lgopts[option_index].name, OPT_BASE_VIRTADDR)) {\n \t\t\t\tif (eal_parse_base_virtaddr(optarg) < 0) {\n@@ -1054,6 +1093,9 @@ rte_eal_init(int argc, char **argv)\n \tif (fctret < 0)\n \t\texit(1);\n \n+\t/* set log level as early as possible */\n+\trte_set_log_level(internal_config.log_level);\n+\n \tif (internal_config.no_hugetlbfs == 0 &&\n \t\t\tinternal_config.process_type != RTE_PROC_SECONDARY &&\n \t\t\tinternal_config.xen_dom0_support == 0 &&\ndiff --git a/lib/librte_eal/linuxapp/eal/include/eal_internal_cfg.h b/lib/librte_eal/linuxapp/eal/include/eal_internal_cfg.h\nindex 498ade2..8749390 100644\n--- a/lib/librte_eal/linuxapp/eal/include/eal_internal_cfg.h\n+++ b/lib/librte_eal/linuxapp/eal/include/eal_internal_cfg.h\n@@ -77,6 +77,7 @@ struct internal_config {\n \tvolatile uint64_t socket_mem[RTE_MAX_NUMA_NODES]; /**< amount of memory per socket */\n \tuintptr_t base_virtaddr;          /**< base address to try and reserve memory from */\n \tvolatile int syslog_facility;\t  /**< facility passed to openlog() */\n+\tvolatile uint32_t log_level;\t  /**< default log level */\n \t/** default interrupt mode for VFIO */\n \tvolatile enum rte_intr_mode vfio_intr_mode;\n \tconst char *hugefile_prefix;      /**< the base filename of hugetlbfs files */\n",
    "prefixes": [
        "dpdk-dev",
        "v3",
        "20/20"
    ]
}