get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 3351,
    "url": "https://patches.dpdk.org/api/patches/3351/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1423970145-31985-20-git-send-email-cunming.liang@intel.com/",
    "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",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<1423970145-31985-20-git-send-email-cunming.liang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1423970145-31985-20-git-send-email-cunming.liang@intel.com",
    "date": "2015-02-15T03:15:45",
    "name": "[dpdk-dev,v7,19/19] timer: add support to non-EAL thread",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "10ad5982681df4b9859dc408e0e496a005c164b6",
    "submitter": {
        "id": 46,
        "url": "https://patches.dpdk.org/api/people/46/?format=api",
        "name": "Cunming Liang",
        "email": "cunming.liang@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1423970145-31985-20-git-send-email-cunming.liang@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/3351/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/3351/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 677B1B563;\n\tSun, 15 Feb 2015 04:17:06 +0100 (CET)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id 0AE64B563\n\tfor <dev@dpdk.org>; Sun, 15 Feb 2015 04:16:46 +0100 (CET)",
            "from orsmga003.jf.intel.com ([10.7.209.27])\n\tby orsmga101.jf.intel.com with ESMTP; 14 Feb 2015 19:16:46 -0800",
            "from shvmail01.sh.intel.com ([10.239.29.42])\n\tby orsmga003.jf.intel.com with ESMTP; 14 Feb 2015 19:08:21 -0800",
            "from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com\n\t[10.239.29.89])\n\tby shvmail01.sh.intel.com with ESMTP id t1F3Ggrg024955;\n\tSun, 15 Feb 2015 11:16:42 +0800",
            "from shecgisg004.sh.intel.com (localhost [127.0.0.1])\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP\n\tid t1F3GeLA032179; Sun, 15 Feb 2015 11:16:42 +0800",
            "(from cliang18@localhost)\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t1F3GetZ032175; \n\tSun, 15 Feb 2015 11:16:40 +0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.09,579,1418112000\"; d=\"scan'208\";a=\"527714966\"",
        "From": "Cunming Liang <cunming.liang@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Sun, 15 Feb 2015 11:15:45 +0800",
        "Message-Id": "<1423970145-31985-20-git-send-email-cunming.liang@intel.com>",
        "X-Mailer": "git-send-email 1.7.4.1",
        "In-Reply-To": "<1423970145-31985-1-git-send-email-cunming.liang@intel.com>",
        "References": "<1423791501-1555-1-git-send-email-cunming.liang@intel.com>\n\t<1423970145-31985-1-git-send-email-cunming.liang@intel.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v7 19/19] timer: add support to non-EAL thread",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "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>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Allow to setup timers only for EAL (lcore) threads (__lcore_id < MAX_LCORE_ID).\nE.g. – dynamically created thread will be able to reset/stop timer for lcore thread,\nbut it will be not allowed to setup timer for itself or another non-lcore thread.\nrte_timer_manage() for non-lcore thread would simply do nothing and return straightway.\n\nSigned-off-by: Cunming Liang <cunming.liang@intel.com>\n---\n v6 changes:\n   use 'RTE_MAX_LCORE' to check the EAL thread with valid lcore_id.\n   use 'LCORE_ID_ANY' for any unspecified lcore_id assignment.\n\n v5 changes:\n   add assert in rte_timer_manage\n   remove duplicate check in timer_set_config_state\n\n lib/librte_timer/rte_timer.c | 32 +++++++++++++++++++++++---------\n lib/librte_timer/rte_timer.h |  4 ++--\n 2 files changed, 25 insertions(+), 11 deletions(-)",
    "diff": "diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c\nindex 269a992..76c9cae 100644\n--- a/lib/librte_timer/rte_timer.c\n+++ b/lib/librte_timer/rte_timer.c\n@@ -35,6 +35,7 @@\n #include <stdio.h>\n #include <stdint.h>\n #include <inttypes.h>\n+#include <assert.h>\n \n #include <rte_atomic.h>\n #include <rte_common.h>\n@@ -79,9 +80,10 @@ static struct priv_timer priv_timer[RTE_MAX_LCORE];\n \n /* when debug is enabled, store some statistics */\n #ifdef RTE_LIBRTE_TIMER_DEBUG\n-#define __TIMER_STAT_ADD(name, n) do {\t\t\t\t\\\n-\t\tunsigned __lcore_id = rte_lcore_id();\t\t\\\n-\t\tpriv_timer[__lcore_id].stats.name += (n);\t\\\n+#define __TIMER_STAT_ADD(name, n) do {\t\t\t\t\t\\\n+\t\tunsigned __lcore_id = rte_lcore_id();\t\t\t\\\n+\t\tif (__lcore_id < RTE_MAX_LCORE)\t\t\t\t\\\n+\t\t\tpriv_timer[__lcore_id].stats.name += (n);\t\\\n \t} while(0)\n #else\n #define __TIMER_STAT_ADD(name, n) do {} while(0)\n@@ -135,7 +137,7 @@ timer_set_config_state(struct rte_timer *tim,\n \n \t\t/* timer is running on another core, exit */\n \t\tif (prev_status.state == RTE_TIMER_RUNNING &&\n-\t\t    (unsigned)prev_status.owner != lcore_id)\n+\t\t    prev_status.owner != (uint16_t)lcore_id)\n \t\t\treturn -1;\n \n \t\t/* timer is being configured on another core */\n@@ -366,9 +368,16 @@ __rte_timer_reset(struct rte_timer *tim, uint64_t expire,\n \n \t/* round robin for tim_lcore */\n \tif (tim_lcore == (unsigned)LCORE_ID_ANY) {\n-\t\ttim_lcore = rte_get_next_lcore(priv_timer[lcore_id].prev_lcore,\n-\t\t\t\t\t       0, 1);\n-\t\tpriv_timer[lcore_id].prev_lcore = tim_lcore;\n+\t\tif (lcore_id < RTE_MAX_LCORE) {\n+\t\t\t/* EAL thread with valid lcore_id */\n+\t\t\ttim_lcore = rte_get_next_lcore(\n+\t\t\t\tpriv_timer[lcore_id].prev_lcore,\n+\t\t\t\t0, 1);\n+\t\t\tpriv_timer[lcore_id].prev_lcore = tim_lcore;\n+\t\t} else\n+\t\t\t/* non-EAL thread do not run rte_timer_manage(),\n+\t\t\t * so schedule the timer on the first enabled lcore. */\n+\t\t\ttim_lcore = rte_get_next_lcore(LCORE_ID_ANY, 0, 1);\n \t}\n \n \t/* wait that the timer is in correct status before update,\n@@ -378,7 +387,8 @@ __rte_timer_reset(struct rte_timer *tim, uint64_t expire,\n \t\treturn -1;\n \n \t__TIMER_STAT_ADD(reset, 1);\n-\tif (prev_status.state == RTE_TIMER_RUNNING) {\n+\tif (prev_status.state == RTE_TIMER_RUNNING &&\n+\t    lcore_id < RTE_MAX_LCORE) {\n \t\tpriv_timer[lcore_id].updated = 1;\n \t}\n \n@@ -455,7 +465,8 @@ rte_timer_stop(struct rte_timer *tim)\n \t\treturn -1;\n \n \t__TIMER_STAT_ADD(stop, 1);\n-\tif (prev_status.state == RTE_TIMER_RUNNING) {\n+\tif (prev_status.state == RTE_TIMER_RUNNING &&\n+\t    lcore_id < RTE_MAX_LCORE) {\n \t\tpriv_timer[lcore_id].updated = 1;\n \t}\n \n@@ -499,6 +510,9 @@ void rte_timer_manage(void)\n \tuint64_t cur_time;\n \tint i, ret;\n \n+\t/* timer manager only runs on EAL thread with valid lcore_id */\n+\tassert(lcore_id < RTE_MAX_LCORE);\n+\n \t__TIMER_STAT_ADD(manage, 1);\n \t/* optimize for the case where per-cpu list is empty */\n \tif (priv_timer[lcore_id].pending_head.sl_next[0] == NULL)\ndiff --git a/lib/librte_timer/rte_timer.h b/lib/librte_timer/rte_timer.h\nindex 4907cf5..35b8719 100644\n--- a/lib/librte_timer/rte_timer.h\n+++ b/lib/librte_timer/rte_timer.h\n@@ -76,7 +76,7 @@ extern \"C\" {\n #define RTE_TIMER_RUNNING 2 /**< State: timer function is running. */\n #define RTE_TIMER_CONFIG  3 /**< State: timer is being configured. */\n \n-#define RTE_TIMER_NO_OWNER -1 /**< Timer has no owner. */\n+#define RTE_TIMER_NO_OWNER -2 /**< Timer has no owner. */\n \n /**\n  * Timer type: Periodic or single (one-shot).\n@@ -310,7 +310,7 @@ int rte_timer_pending(struct rte_timer *tim);\n /**\n  * Manage the timer list and execute callback functions.\n  *\n- * This function must be called periodically from all cores\n+ * This function must be called periodically from EAL lcores\n  * main_loop(). It browses the list of pending timers and runs all\n  * timers that are expired.\n  *\n",
    "prefixes": [
        "dpdk-dev",
        "v7",
        "19/19"
    ]
}