Show a patch.

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

{
    "id": 237,
    "url": "https://patches.dpdk.org/api/patches/237/?format=api",
    "web_url": "https://patches.dpdk.org/patch/237/",
    "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": "<1409062162-19575-12-git-send-email-david.marchand@6wind.com>",
    "date": "2014-08-26T14:09:21",
    "name": "[dpdk-dev,11/11] eal: set log level from command line",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "c1a351f35dddbfad87a526f117ef528cc3025574",
    "submitter": {
        "id": 3,
        "url": "https://patches.dpdk.org/api/people/3/?format=api",
        "name": "David Marchand",
        "email": "david.marchand@6wind.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/patch/237/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/237/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/237/checks/",
    "tags": {},
    "headers": {
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "Return-Path": "<david.marchand@6wind.com>",
        "Message-Id": "<1409062162-19575-12-git-send-email-david.marchand@6wind.com>",
        "X-Mailer": "git-send-email 1.7.10.4",
        "X-Gm-Message-State": "ALoCoQkQCPELVhX22pwPQAWai5aJmfhm0JwQ/rnTw+DqZprpQqEiTyxoE6J6B27LIajS76erjghc",
        "To": "dev@dpdk.org",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "X-BeenThere": "dev@dpdk.org",
        "Received": [
            "from mail-we0-f170.google.com (mail-we0-f170.google.com\n\t[74.125.82.170]) by dpdk.org (Postfix) with ESMTP id 00594B3A1\n\tfor <dev@dpdk.org>; Tue, 26 Aug 2014 16:05:45 +0200 (CEST)",
            "by mail-we0-f170.google.com with SMTP id w62so14795429wes.29\n\tfor <dev@dpdk.org>; Tue, 26 Aug 2014 07:09:46 -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\tcy9sm12543569wib.18.2014.08.26.07.09.44 for <dev@dpdk.org>\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tTue, 26 Aug 2014 07:09:45 -0700 (PDT)"
        ],
        "Subject": "[dpdk-dev] [PATCH 11/11] eal: set log level from command line",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "In-Reply-To": "<1409062162-19575-1-git-send-email-david.marchand@6wind.com>",
        "Precedence": "list",
        "From": "David Marchand <david.marchand@6wind.com>",
        "X-Received": "by 10.194.75.138 with SMTP id c10mr30614145wjw.9.1409062186018; \n\tTue, 26 Aug 2014 07:09:46 -0700 (PDT)",
        "References": "<1409062162-19575-1-git-send-email-david.marchand@6wind.com>",
        "X-List-Received-Date": "Tue, 26 Aug 2014 14:05:47 -0000",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "Date": "Tue, 26 Aug 2014 16:09:21 +0200",
        "X-Mailman-Version": "2.1.15",
        "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:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=PJfz22xiwGxWmh4+J79Jn1HAHElqKz7uALoxB+tzOK0=;\n\tb=UTClAv6RRz2G+8P37ktVILXHtsH6XVKf7o3071XFCKlE5HqXiAVuyOwSylHl+L5iNj\n\t8mCLL/Rgo98BFH7FRyIkhGf+lJXDdVXILSeopgwXw0sbffN+3oNqd2QKuaURbMlk56El\n\ttMxqfthzICBywqlFEs/OZfh+BSf0+IhIYpdYuQhfrzRF+ROq68QknnetArVOCbnQm5tu\n\tHe2PJ9MNlEHOEBmzPKtmoDgj+pfCjpR9XrAMe8SiSftnjUa+ARd+bgdOn+ufw0+Uy8zQ\n\t7Q2hK4gHVxgFfjk098Y6M980FmuS24/79hVCT2ZoNnrJRx4eFyGAYz64RDJCHPEV8mNJ\n\tvDlA=="
    },
    "content": "Add a --log-level option to set the default eal log level.\n\nSigned-off-by: David Marchand <david.marchand@6wind.com>\n---\n lib/librte_eal/bsdapp/eal/eal.c                    |   43 ++++++++++++++++++++\n .../bsdapp/eal/include/eal_internal_cfg.h          |    1 +\n lib/librte_eal/linuxapp/eal/eal.c                  |   43 ++++++++++++++++++++\n .../linuxapp/eal/include/eal_internal_cfg.h        |    1 +\n 4 files changed, 88 insertions(+)",
    "diff": "diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c\nindex 38c6cfc..96b54e3 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 RTE_EAL_BLACKLIST_SIZE\t0x100\n \n@@ -311,6 +312,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@@ -458,6 +460,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@@ -512,6 +536,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@@ -524,6 +549,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@@ -671,6 +698,19 @@ eal_parse_args(int argc, char **argv)\n \t\t\t\t\treturn -1;\n \t\t\t\t}\n \t\t\t}\n+\t\t\telse 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 \t\tdefault:\n@@ -811,6 +851,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 ad43914..874209b 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@@ -386,6 +387,7 @@ 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_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@@ -550,6 +552,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@@ -701,6 +725,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@@ -718,6 +743,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@@ -890,6 +917,19 @@ eal_parse_args(int argc, char **argv)\n \t\t\t\t\treturn -1;\n \t\t\t\t}\n \t\t\t}\n+\t\t\telse 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 \t\t\t\t\tRTE_LOG(ERR, EAL, \"invalid parameter for --\"\n@@ -1056,6 +1096,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",
        "11/11"
    ]
}