get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 41316,
    "url": "http://patches.dpdk.org/api/patches/41316/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1529505898-6458-2-git-send-email-liang.j.ma@intel.com/",
    "project": {
        "id": 1,
        "url": "http://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": "<1529505898-6458-2-git-send-email-liang.j.ma@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1529505898-6458-2-git-send-email-liang.j.ma@intel.com",
    "date": "2018-06-20T14:44:58",
    "name": "[v3,2/2] examples/l3fwd-power: simple app update to support new API",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "9bbfcdba33a26b158f433485d3806479d4ddee1c",
    "submitter": {
        "id": 904,
        "url": "http://patches.dpdk.org/api/people/904/?format=api",
        "name": "Liang, Ma",
        "email": "liang.j.ma@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1529505898-6458-2-git-send-email-liang.j.ma@intel.com/mbox/",
    "series": [
        {
            "id": 183,
            "url": "http://patches.dpdk.org/api/series/183/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=183",
            "date": "2018-06-20T14:44:57",
            "name": "[v3,1/2] lib/librte_power: traffic pattern aware power control",
            "version": 3,
            "mbox": "http://patches.dpdk.org/series/183/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/41316/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/41316/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 [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 806521B4F2;\n\tWed, 20 Jun 2018 16:45:32 +0200 (CEST)",
            "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n\tby dpdk.org (Postfix) with ESMTP id 671F21B483\n\tfor <dev@dpdk.org>; Wed, 20 Jun 2018 16:45:30 +0200 (CEST)",
            "from fmsmga006.fm.intel.com ([10.253.24.20])\n\tby fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t20 Jun 2018 07:45:29 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby fmsmga006.fm.intel.com with ESMTP; 20 Jun 2018 07:45:28 -0700",
            "from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com\n\t[10.237.217.45])\n\tby irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id\n\tw5KEjROA017125; Wed, 20 Jun 2018 15:45:27 +0100",
            "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w5KEjRvX006751;\n\tWed, 20 Jun 2018 15:45:27 +0100",
            "(from lma25@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w5KEjRtF006747;\n\tWed, 20 Jun 2018 15:45:27 +0100"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.51,247,1526367600\"; d=\"scan'208\";a=\"239110494\"",
        "From": "Liang Ma <liang.j.ma@intel.com>",
        "To": "david.hunt@intel.com",
        "Cc": "dev@dpdk.org, radu.nicolau@intel.com, Liang Ma <liang.j.ma@intel.com>",
        "Date": "Wed, 20 Jun 2018 15:44:58 +0100",
        "Message-Id": "<1529505898-6458-2-git-send-email-liang.j.ma@intel.com>",
        "X-Mailer": "git-send-email 1.7.7.4",
        "In-Reply-To": "<1529505898-6458-1-git-send-email-liang.j.ma@intel.com>",
        "References": "<1528471577-5167-2-git-send-email-liang.j.ma@intel.com>\n\t<1529505898-6458-1-git-send-email-liang.j.ma@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v3 2/2] examples/l3fwd-power: simple app update\n\tto support new API",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Add the support for new traffic pattern aware power control\npower management API.\n\nExample:\n./l3fwd-power -l xxx   -n 4   -w 0000:xx:00.0 -w 0000:xx:00.1 -- -p 0x3\n-P --config=\"(0,0,xx),(1,0,xx)\" --empty-poll\n\nPlease Reference l3fwd-power document for all parameter except\nempty-poll.\n\nOnce enable empty-poll. The system will start with training phase.\nThere should not has any traffic pass-through during training phase.\nWhen training phase complete, system transfer to normal phase.\n\nSystem will running with modest power stat at beginning.\nIf the system busyness percentage above 70%, then system will adjust\npower state move to High power state. If the traffic become lower(eg. The\nsystem busyness percentage drop below 30%), system will fallback\nto the modest power state.\n\nExample code use master thread to monitoring worker thread busyness.\nthe default timer resolution is 10ms.\n\nChangeLog:\nv2 fix some coding style issues\nv3 rename the API.\n\nSigned-off-by: Liang Ma <liang.j.ma@intel.com>\n---\n examples/l3fwd-power/main.c | 232 ++++++++++++++++++++++++++++++++++++++++----\n 1 file changed, 214 insertions(+), 18 deletions(-)",
    "diff": "diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c\nindex 596d645..953a2ed 100644\n--- a/examples/l3fwd-power/main.c\n+++ b/examples/l3fwd-power/main.c\n@@ -42,6 +42,7 @@\n #include <rte_string_fns.h>\n #include <rte_timer.h>\n #include <rte_power.h>\n+#include <rte_power_empty_poll.h>\n #include <rte_spinlock.h>\n \n #define RTE_LOGTYPE_L3FWD_POWER RTE_LOGTYPE_USER1\n@@ -129,6 +130,9 @@ static uint32_t enabled_port_mask = 0;\n static int promiscuous_on = 0;\n /* NUMA is enabled by default. */\n static int numa_on = 1;\n+/* emptypoll is disabled by default. */\n+static bool empty_poll_on;\n+volatile bool empty_poll_stop;\n static int parse_ptype; /**< Parse packet type using rx callback, and */\n \t\t\t/**< disabled by default */\n \n@@ -336,6 +340,10 @@ static inline uint32_t power_idle_heuristic(uint32_t zero_rx_packet_count);\n static inline enum freq_scale_hint_t power_freq_scaleup_heuristic( \\\n \t\tunsigned int lcore_id, uint16_t port_id, uint16_t queue_id);\n \n+static int is_done(void)\n+{\n+\treturn empty_poll_stop;\n+}\n /* exit signal handler */\n static void\n signal_exit_now(int sigtype)\n@@ -344,7 +352,15 @@ signal_exit_now(int sigtype)\n \tunsigned int portid;\n \tint ret;\n \n+\tRTE_SET_USED(lcore_id);\n+\tRTE_SET_USED(portid);\n+\tRTE_SET_USED(ret);\n+\n \tif (sigtype == SIGINT) {\n+\t\tif (empty_poll_on)\n+\t\t\tempty_poll_stop = true;\n+\n+\n \t\tfor (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {\n \t\t\tif (rte_lcore_is_enabled(lcore_id) == 0)\n \t\t\t\tcontinue;\n@@ -353,20 +369,23 @@ signal_exit_now(int sigtype)\n \t\t\tret = rte_power_exit(lcore_id);\n \t\t\tif (ret)\n \t\t\t\trte_exit(EXIT_FAILURE, \"Power management \"\n-\t\t\t\t\t\"library de-initialization failed on \"\n-\t\t\t\t\t\t\t\"core%u\\n\", lcore_id);\n+\t\t\t\t\t\t\"library de-initialization failed on \"\n+\t\t\t\t\t\t\"core%u\\n\", lcore_id);\n \t\t}\n \n-\t\tRTE_ETH_FOREACH_DEV(portid) {\n-\t\t\tif ((enabled_port_mask & (1 << portid)) == 0)\n-\t\t\t\tcontinue;\n+\t\tif (!empty_poll_on) {\n+\t\t\tRTE_ETH_FOREACH_DEV(portid) {\n+\t\t\t\tif ((enabled_port_mask & (1 << portid)) == 0)\n+\t\t\t\t\tcontinue;\n \n-\t\t\trte_eth_dev_stop(portid);\n-\t\t\trte_eth_dev_close(portid);\n+\t\t\t\trte_eth_dev_stop(portid);\n+\t\t\t\trte_eth_dev_close(portid);\n+\t\t\t}\n \t\t}\n \t}\n \n-\trte_exit(EXIT_SUCCESS, \"User forced exit\\n\");\n+\tif (!empty_poll_on)\n+\t\trte_exit(EXIT_SUCCESS, \"User forced exit\\n\");\n }\n \n /*  Freqency scale down timer callback */\n@@ -831,6 +850,107 @@ static int event_register(struct lcore_conf *qconf)\n \n \treturn 0;\n }\n+/* main processing loop */\n+static int\n+main_empty_poll_loop(__attribute__((unused)) void *dummy)\n+{\n+\tstruct rte_mbuf *pkts_burst[MAX_PKT_BURST];\n+\tunsigned int lcore_id;\n+\tuint64_t prev_tsc, diff_tsc, cur_tsc;\n+\tint i, j, nb_rx;\n+\tuint8_t queueid;\n+\tuint16_t portid;\n+\tstruct lcore_conf *qconf;\n+\tstruct lcore_rx_queue *rx_queue;\n+\n+\tconst uint64_t drain_tsc =\n+\t\t(rte_get_tsc_hz() + US_PER_S - 1) / US_PER_S * BURST_TX_DRAIN_US;\n+\n+\tprev_tsc = 0;\n+\n+\tlcore_id = rte_lcore_id();\n+\tqconf = &lcore_conf[lcore_id];\n+\n+\tif (qconf->n_rx_queue == 0) {\n+\t\tRTE_LOG(INFO, L3FWD_POWER, \"lcore %u has nothing to do\\n\", lcore_id);\n+\t\treturn 0;\n+\t}\n+\n+\tfor (i = 0; i < qconf->n_rx_queue; i++) {\n+\t\tportid = qconf->rx_queue_list[i].port_id;\n+\t\tqueueid = qconf->rx_queue_list[i].queue_id;\n+\t\tRTE_LOG(INFO, L3FWD_POWER, \" -- lcoreid=%u portid=%u \"\n+\t\t\t\t\"rxqueueid=%hhu\\n\", lcore_id, portid, queueid);\n+\t}\n+\n+\twhile (!is_done()) {\n+\t\tstats[lcore_id].nb_iteration_looped++;\n+\n+\t\tcur_tsc = rte_rdtsc();\n+\t\t/*\n+\t\t * TX burst queue drain\n+\t\t */\n+\t\tdiff_tsc = cur_tsc - prev_tsc;\n+\t\tif (unlikely(diff_tsc > drain_tsc)) {\n+\t\t\tfor (i = 0; i < qconf->n_tx_port; ++i) {\n+\t\t\t\tportid = qconf->tx_port_id[i];\n+\t\t\t\trte_eth_tx_buffer_flush(portid,\n+\t\t\t\t\t\tqconf->tx_queue_id[portid],\n+\t\t\t\t\t\tqconf->tx_buffer[portid]);\n+\t\t\t}\n+\t\t\tprev_tsc = cur_tsc;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Read packet from RX queues\n+\t\t */\n+\t\tfor (i = 0; i < qconf->n_rx_queue; ++i) {\n+\t\t\trx_queue = &(qconf->rx_queue_list[i]);\n+\t\t\trx_queue->idle_hint = 0;\n+\t\t\tportid = rx_queue->port_id;\n+\t\t\tqueueid = rx_queue->queue_id;\n+\n+\t\t\tnb_rx = rte_eth_rx_burst(portid, queueid, pkts_burst,\n+\t\t\t\t\tMAX_PKT_BURST);\n+\n+\t\t\tstats[lcore_id].nb_rx_processed += nb_rx;\n+\n+\t\t\tif (nb_rx == 0) {\n+\n+\t\t\t\trte_power_empty_poll_stat_update(lcore_id);\n+\n+\t\t\t\tcontinue;\n+\t\t\t} else {\n+\t\t\t\trte_power_poll_stat_update(lcore_id, nb_rx);\n+\t\t\t}\n+\n+\n+\t\t\t/* Prefetch first packets */\n+\t\t\tfor (j = 0; j < PREFETCH_OFFSET && j < nb_rx; j++) {\n+\t\t\t\trte_prefetch0(rte_pktmbuf_mtod(\n+\t\t\t\t\t\t\tpkts_burst[j], void *));\n+\t\t\t}\n+\n+\t\t\t/* Prefetch and forward already prefetched packets */\n+\t\t\tfor (j = 0; j < (nb_rx - PREFETCH_OFFSET); j++) {\n+\t\t\t\trte_prefetch0(rte_pktmbuf_mtod(pkts_burst[\n+\t\t\t\t\t\t\tj + PREFETCH_OFFSET], void *));\n+\t\t\t\tl3fwd_simple_forward(pkts_burst[j], portid,\n+\t\t\t\t\t\tqconf);\n+\t\t\t}\n+\n+\t\t\t/* Forward remaining prefetched packets */\n+\t\t\tfor (; j < nb_rx; j++) {\n+\t\t\t\tl3fwd_simple_forward(pkts_burst[j], portid,\n+\t\t\t\t\t\tqconf);\n+\t\t\t}\n+\n+\t\t}\n+\n+\t}\n+\n+\treturn 0;\n+}\n \n /* main processing loop */\n static int\n@@ -1128,7 +1248,8 @@ print_usage(const char *prgname)\n \t\t\"  --no-numa: optional, disable numa awareness\\n\"\n \t\t\"  --enable-jumbo: enable jumbo frame\"\n \t\t\" which max packet len is PKTLEN in decimal (64-9600)\\n\"\n-\t\t\"  --parse-ptype: parse packet type by software\\n\",\n+\t\t\"  --parse-ptype: parse packet type by software\\n\"\n+\t\t\"  --empty=poll: enable empty poll detection\\n\",\n \t\tprgname);\n }\n \n@@ -1231,10 +1352,12 @@ parse_args(int argc, char **argv)\n \tint opt, ret;\n \tchar **argvopt;\n \tint option_index;\n+\tuint32_t limit;\n \tchar *prgname = argv[0];\n \tstatic struct option lgopts[] = {\n \t\t{\"config\", 1, 0, 0},\n \t\t{\"no-numa\", 0, 0, 0},\n+\t\t{\"empty-poll\", 0, 0, 0},\n \t\t{\"enable-jumbo\", 0, 0, 0},\n \t\t{CMD_LINE_OPT_PARSE_PTYPE, 0, 0, 0},\n \t\t{NULL, 0, 0, 0}\n@@ -1259,7 +1382,18 @@ parse_args(int argc, char **argv)\n \t\t\tprintf(\"Promiscuous mode selected\\n\");\n \t\t\tpromiscuous_on = 1;\n \t\t\tbreak;\n-\n+\t\tcase 'l':\n+\t\t\tlimit = parse_portmask(optarg);\n+\t\t\trte_power_empty_poll_set_freq(LOW, limit);\n+\t\t\tbreak;\n+\t\tcase 'm':\n+\t\t\tlimit = parse_portmask(optarg);\n+\t\t\trte_power_empty_poll_set_freq(MED, limit);\n+\t\t\tbreak;\n+\t\tcase 'h':\n+\t\t\tlimit = parse_portmask(optarg);\n+\t\t\trte_power_empty_poll_set_freq(HGH, limit);\n+\t\t\tbreak;\n \t\t/* long options */\n \t\tcase 0:\n \t\t\tif (!strncmp(lgopts[option_index].name, \"config\", 6)) {\n@@ -1278,6 +1412,12 @@ parse_args(int argc, char **argv)\n \t\t\t}\n \n \t\t\tif (!strncmp(lgopts[option_index].name,\n+\t\t\t\t\t\t\"empty-poll\", 10)) {\n+\t\t\t\tprintf(\"empty-poll is enabled\\n\");\n+\t\t\t\tempty_poll_on = true;\n+\t\t\t}\n+\n+\t\t\tif (!strncmp(lgopts[option_index].name,\n \t\t\t\t\t\"enable-jumbo\", 12)) {\n \t\t\t\tstruct option lenopts =\n \t\t\t\t\t{\"max-pkt-len\", required_argument, \\\n@@ -1609,6 +1749,41 @@ static int check_ptype(uint16_t portid)\n \n }\n \n+static int\n+launch_timer(unsigned int lcore_id)\n+{\n+\tint64_t prev_tsc = 0, cur_tsc, diff_tsc, cycles_10ms;\n+\n+\tRTE_SET_USED(lcore_id);\n+\n+\n+\tif (rte_get_master_lcore() != lcore_id) {\n+\t\trte_panic(\"timer on lcore:%d which is not master core:%d\\n\",\n+\t\t\t\tlcore_id,\n+\t\t\t\trte_get_master_lcore());\n+\t}\n+\n+\tRTE_LOG(INFO, POWER, \"Bring up the Timer\\n\");\n+\n+\trte_power_empty_poll_setup_timer();\n+\n+\tcycles_10ms = rte_get_timer_hz() / 100;\n+\n+\twhile (!is_done()) {\n+\t\tcur_tsc = rte_rdtsc();\n+\t\tdiff_tsc = cur_tsc - prev_tsc;\n+\t\tif (diff_tsc > cycles_10ms) {\n+\t\t\trte_timer_manage();\n+\t\t\tprev_tsc = cur_tsc;\n+\t\t\tcycles_10ms = rte_get_timer_hz() / 100;\n+\t\t}\n+\t}\n+\n+\tRTE_LOG(INFO, POWER, \"Timer_subsystem is done\\n\");\n+\n+\treturn 0;\n+}\n+\n int\n main(int argc, char **argv)\n {\n@@ -1693,6 +1868,10 @@ main(int argc, char **argv)\n \t\tif (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)\n \t\t\tlocal_port_conf.txmode.offloads |=\n \t\t\t\tDEV_TX_OFFLOAD_MBUF_FAST_FREE;\n+\n+\t\tlocal_port_conf.rx_adv_conf.rss_conf.rss_hf &=\n+\t\t\tdev_info.flow_type_rss_offloads;\n+\n \t\tret = rte_eth_dev_configure(portid, nb_rx_queue,\n \t\t\t\t\t(uint16_t)n_tx_queue, &local_port_conf);\n \t\tif (ret < 0)\n@@ -1780,14 +1959,15 @@ main(int argc, char **argv)\n \t\t\t\t\"Library initialization failed on core %u\\n\", lcore_id);\n \n \t\t/* init timer structures for each enabled lcore */\n-\t\trte_timer_init(&power_timers[lcore_id]);\n-\t\thz = rte_get_timer_hz();\n-\t\trte_timer_reset(&power_timers[lcore_id],\n-\t\t\thz/TIMER_NUMBER_PER_SECOND, SINGLE, lcore_id,\n-\t\t\t\t\t\tpower_timer_cb, NULL);\n-\n+\t\tif (empty_poll_on == false) {\n+\t\t\trte_timer_init(&power_timers[lcore_id]);\n+\t\t\thz = rte_get_timer_hz();\n+\t\t\trte_timer_reset(&power_timers[lcore_id],\n+\t\t\t\t\thz/TIMER_NUMBER_PER_SECOND, SINGLE, lcore_id,\n+\t\t\t\t\tpower_timer_cb, NULL);\n+\t\t}\n \t\tqconf = &lcore_conf[lcore_id];\n-\t\tprintf(\"\\nInitializing rx queues on lcore %u ... \", lcore_id );\n+\t\tprintf(\"\\nInitializing rx queues on lcore %u ...\\n\", lcore_id);\n \t\tfflush(stdout);\n \t\t/* init RX queues */\n \t\tfor(queue = 0; queue < qconf->n_rx_queue; ++queue) {\n@@ -1856,12 +2036,28 @@ main(int argc, char **argv)\n \n \tcheck_all_ports_link_status(enabled_port_mask);\n \n+\tif (empty_poll_on == true)\n+\t\trte_power_empty_poll_stat_init();\n+\n+\n \t/* launch per-lcore init on every lcore */\n-\trte_eal_mp_remote_launch(main_loop, NULL, CALL_MASTER);\n+\tif (empty_poll_on == false) {\n+\t\trte_eal_mp_remote_launch(main_loop, NULL, CALL_MASTER);\n+\t} else {\n+\t\tempty_poll_stop = false;\n+\t\trte_eal_mp_remote_launch(main_empty_poll_loop, NULL, SKIP_MASTER);\n+\t}\n+\n+\tif (empty_poll_on == true)\n+\t\tlaunch_timer(rte_lcore_id());\n+\n \tRTE_LCORE_FOREACH_SLAVE(lcore_id) {\n \t\tif (rte_eal_wait_lcore(lcore_id) < 0)\n \t\t\treturn -1;\n \t}\n \n+\tif (empty_poll_on)\n+\t\trte_power_empty_poll_stat_free();\n+\n \treturn 0;\n }\n",
    "prefixes": [
        "v3",
        "2/2"
    ]
}