get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 94783,
    "url": "https://patches.dpdk.org/api/patches/94783/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1624487698-31136-8-git-send-email-jizh@linux.microsoft.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": "<1624487698-31136-8-git-send-email-jizh@linux.microsoft.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1624487698-31136-8-git-send-email-jizh@linux.microsoft.com",
    "date": "2021-06-23T22:34:56",
    "name": "[v14,7/9] app/testpmd: replace POSIX specific code",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "5c5aa6f4c09d47341ee15fc619f9be8ef7a80f2a",
    "submitter": {
        "id": 1934,
        "url": "https://patches.dpdk.org/api/people/1934/?format=api",
        "name": "Jie Zhou",
        "email": "jizh@linux.microsoft.com"
    },
    "delegate": {
        "id": 3961,
        "url": "https://patches.dpdk.org/api/users/3961/?format=api",
        "username": "arybchenko",
        "first_name": "Andrew",
        "last_name": "Rybchenko",
        "email": "andrew.rybchenko@oktetlabs.ru"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1624487698-31136-8-git-send-email-jizh@linux.microsoft.com/mbox/",
    "series": [
        {
            "id": 17465,
            "url": "https://patches.dpdk.org/api/series/17465/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=17465",
            "date": "2021-06-23T22:34:50",
            "name": "app/testpmd: enable testpmd on Windows",
            "version": 14,
            "mbox": "https://patches.dpdk.org/series/17465/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/94783/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/94783/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id EEC7FA0C41;\n\tThu, 24 Jun 2021 00:35:46 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 7B8FF41178;\n\tThu, 24 Jun 2021 00:35:14 +0200 (CEST)",
            "from linux.microsoft.com (linux.microsoft.com [13.77.154.182])\n by mails.dpdk.org (Postfix) with ESMTP id C381940DDE;\n Thu, 24 Jun 2021 00:35:05 +0200 (CEST)",
            "from\n linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net\n (linux.microsoft.com [13.77.154.182])\n by linux.microsoft.com (Postfix) with ESMTPSA id DACF120B83F6;\n Wed, 23 Jun 2021 15:35:04 -0700 (PDT)"
        ],
        "DKIM-Filter": "OpenDKIM Filter v2.11.0 linux.microsoft.com DACF120B83F6",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com;\n s=default; t=1624487704;\n bh=qBEvHsWMGUAGcZ4qbfpe0S8uy/Gw1yvBEqa8wppPAjk=;\n h=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n b=JSKqj+L4GYZQE8tTrSEfczIKTNAM7ju9HdF8DkhWWfeJ4xrTabRWognuiGK1i7/gL\n vm/AbE2GGTH71+zQxKrohDqeuo7+aeVsCCSGOrUvDkyg/nPn0x5tB1ZhLuDqlE4x8d\n qw1B5zXA7Y/qZ6/qsLIzKi7b8RXHTU8QDcHK10ZQ=",
        "From": "Jie Zhou <jizh@linux.microsoft.com>",
        "To": "dev@dpdk.org",
        "Cc": "dmitry.kozliuk@gmail.com, xiaoyun.li@intel.com, roretzla@microsoft.com,\n talshn@nvidia.com, pallavi.kadam@intel.com, andrew.rybchenko@oktetlabs.ru,\n thomas@monjalon.net, bruce.richardson@intel.com, ferruh.yigit@intel.com,\n konstantin.ananyev@intel.com, stable@dpdk.org",
        "Date": "Wed, 23 Jun 2021 15:34:56 -0700",
        "Message-Id": "<1624487698-31136-8-git-send-email-jizh@linux.microsoft.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1624487698-31136-1-git-send-email-jizh@linux.microsoft.com>",
        "References": "<1620241931-28435-1-git-send-email-jizh@linux.microsoft.com>\n <1624487698-31136-1-git-send-email-jizh@linux.microsoft.com>",
        "Subject": "[dpdk-dev] [PATCH v14 7/9] app/testpmd: replace POSIX specific code",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <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 <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "- Make printf format OS independent\n - Replace htons with RTE_BE16\n - Replace POSIX specific inet_aton with OS independent inet_pton\n - Replace sleep with rte_delay_us_sleep\n - Repalce random with rte_rand\n - #ifndef mman related code for now\n - Include rte_os_shim.h in testpmd.h\n - Remove redundant headers\n\nSigned-off-by: Jie Zhou <jizh@microsoft.com>\nSigned-off-by: Jie Zhou <jizh@linux.microsoft.com>\nAcked-by: Tal Shnaiderman <talshn@nvidia.com>\n\n---\n app/test-pmd/cmdline.c      |  6 +-----\n app/test-pmd/cmdline_flow.c |  2 --\n app/test-pmd/csumonly.c     |  2 +-\n app/test-pmd/icmpecho.c     |  4 ++--\n app/test-pmd/ieee1588fwd.c  |  8 ++++----\n app/test-pmd/parameters.c   | 11 +++++++----\n app/test-pmd/testpmd.c      | 21 ++++++++++++++++++++-\n app/test-pmd/testpmd.h      |  3 ++-\n 8 files changed, 37 insertions(+), 20 deletions(-)",
    "diff": "diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c\nindex dff5a75ec5..bfd2fb9240 100644\n--- a/app/test-pmd/cmdline.c\n+++ b/app/test-pmd/cmdline.c\n@@ -8,12 +8,8 @@\n #include <stdio.h>\n #include <stdint.h>\n #include <string.h>\n-#include <termios.h>\n #include <unistd.h>\n #include <inttypes.h>\n-#include <sys/socket.h>\n-#include <netinet/in.h>\n-\n #include <sys/queue.h>\n \n #include <rte_common.h>\n@@ -3614,7 +3610,7 @@ cmdline_parse_inst_t cmd_stop = {\n /* *** SET CORELIST and PORTLIST CONFIGURATION *** */\n \n unsigned int\n-parse_item_list(char* str, const char* item_name, unsigned int max_items,\n+parse_item_list(const char *str, const char *item_name, unsigned int max_items,\n \t\tunsigned int *parsed_items, int check_unique_values)\n {\n \tunsigned int nb_item;\ndiff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c\nindex 61882d5cbc..0168ff7dac 100644\n--- a/app/test-pmd/cmdline_flow.c\n+++ b/app/test-pmd/cmdline_flow.c\n@@ -10,8 +10,6 @@\n #include <errno.h>\n #include <ctype.h>\n #include <string.h>\n-#include <arpa/inet.h>\n-#include <sys/socket.h>\n \n #include <rte_string_fns.h>\n #include <rte_common.h>\ndiff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c\nindex 6b4df335fe..089936587b 100644\n--- a/app/test-pmd/csumonly.c\n+++ b/app/test-pmd/csumonly.c\n@@ -696,7 +696,7 @@ pkt_copy_split(const struct rte_mbuf *pkt)\n \tmp = current_fwd_lcore()->mbp;\n \n \tif (tx_pkt_split == TX_PKT_SPLIT_RND)\n-\t\tnb_seg = random() % tx_pkt_nb_segs + 1;\n+\t\tnb_seg = rte_rand() % tx_pkt_nb_segs + 1;\n \telse\n \t\tnb_seg = tx_pkt_nb_segs;\n \ndiff --git a/app/test-pmd/icmpecho.c b/app/test-pmd/icmpecho.c\nindex af6f7e7902..8948f28eb5 100644\n--- a/app/test-pmd/icmpecho.c\n+++ b/app/test-pmd/icmpecho.c\n@@ -474,8 +474,8 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs)\n \t\t}\n \t\ticmp_h->icmp_type = RTE_IP_ICMP_ECHO_REPLY;\n \t\tcksum = ~icmp_h->icmp_cksum & 0xffff;\n-\t\tcksum += ~htons(RTE_IP_ICMP_ECHO_REQUEST << 8) & 0xffff;\n-\t\tcksum += htons(RTE_IP_ICMP_ECHO_REPLY << 8);\n+\t\tcksum += ~RTE_BE16(RTE_IP_ICMP_ECHO_REQUEST << 8) & 0xffff;\n+\t\tcksum += RTE_BE16(RTE_IP_ICMP_ECHO_REPLY << 8);\n \t\tcksum = (cksum & 0xffff) + (cksum >> 16);\n \t\tcksum = (cksum & 0xffff) + (cksum >> 16);\n \t\ticmp_h->icmp_cksum = ~cksum;\ndiff --git a/app/test-pmd/ieee1588fwd.c b/app/test-pmd/ieee1588fwd.c\nindex e3b98e3e0c..034f238c34 100644\n--- a/app/test-pmd/ieee1588fwd.c\n+++ b/app/test-pmd/ieee1588fwd.c\n@@ -60,8 +60,8 @@ port_ieee1588_rx_timestamp_check(portid_t pi, uint32_t index)\n \t\tprintf(\"Port %u RX timestamp registers not valid\\n\", pi);\n \t\treturn;\n \t}\n-\tprintf(\"Port %u RX timestamp value %lu s %lu ns\\n\",\n-\t\tpi, timestamp.tv_sec, timestamp.tv_nsec);\n+\tprintf(\"Port %u RX timestamp value %ju s %lu ns\\n\",\n+\t\tpi, (uintmax_t)timestamp.tv_sec, timestamp.tv_nsec);\n }\n \n #define MAX_TX_TMST_WAIT_MICROSECS 1000 /**< 1 milli-second */\n@@ -83,9 +83,9 @@ port_ieee1588_tx_timestamp_check(portid_t pi)\n \t\t       pi, MAX_TX_TMST_WAIT_MICROSECS);\n \t\treturn;\n \t}\n-\tprintf(\"Port %u TX timestamp value %lu s %lu ns validated after \"\n+\tprintf(\"Port %u TX timestamp value %ju s %lu ns validated after \"\n \t       \"%u micro-second%s\\n\",\n-\t       pi, timestamp.tv_sec, timestamp.tv_nsec, wait_us,\n+\t       pi, (uintmax_t)timestamp.tv_sec, timestamp.tv_nsec, wait_us,\n \t       (wait_us == 1) ? \"\" : \"s\");\n }\n \ndiff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c\nindex f3954c1c63..5e69d2aa8c 100644\n--- a/app/test-pmd/parameters.c\n+++ b/app/test-pmd/parameters.c\n@@ -19,7 +19,6 @@\n #include <stdint.h>\n #include <unistd.h>\n #include <inttypes.h>\n-#include <arpa/inet.h>\n \n #include <rte_common.h>\n #include <rte_byteorder.h>\n@@ -185,8 +184,10 @@ usage(char* progname)\n \tprintf(\"  --hot-plug: enable hot plug for device.\\n\");\n \tprintf(\"  --vxlan-gpe-port=N: UPD port of tunnel VXLAN-GPE\\n\");\n \tprintf(\"  --geneve-parsed-port=N: UPD port to parse GENEVE tunnel protocol\\n\");\n+#ifndef RTE_EXEC_ENV_WINDOWS\n \tprintf(\"  --mlockall: lock all memory\\n\");\n \tprintf(\"  --no-mlockall: do not lock all memory\\n\");\n+#endif\n \tprintf(\"  --mp-alloc <native|anon|xmem|xmemhuge>: mempool allocation method.\\n\"\n \t       \"    native: use regular DPDK memory to create and populate mempool\\n\"\n \t       \"    anon: use regular DPDK memory to create and anonymous memory to populate mempool\\n\"\n@@ -211,7 +212,7 @@ usage(char* progname)\n \n #ifdef RTE_LIB_CMDLINE\n static int\n-init_peer_eth_addrs(char *config_filename)\n+init_peer_eth_addrs(const char *config_filename)\n {\n \tFILE *config_file;\n \tportid_t i;\n@@ -610,8 +611,10 @@ launch_args_parse(int argc, char** argv)\n \t\t{ \"hot-plug\",\t\t\t0, 0, 0 },\n \t\t{ \"vxlan-gpe-port\",\t\t1, 0, 0 },\n \t\t{ \"geneve-parsed-port\",\t\t1, 0, 0 },\n+#ifndef RTE_EXEC_ENV_WINDOWS\n \t\t{ \"mlockall\",\t\t\t0, 0, 0 },\n \t\t{ \"no-mlockall\",\t\t0, 0, 0 },\n+#endif\n \t\t{ \"mp-alloc\",\t\t\t1, 0, 0 },\n \t\t{ \"tx-ip\",\t\t\t1, 0, 0 },\n \t\t{ \"tx-udp\",\t\t\t1, 0, 0 },\n@@ -723,13 +726,13 @@ launch_args_parse(int argc, char** argv)\n \t\t\t\t\t\t \"Invalid tx-ip: %s\", optarg);\n \n \t\t\t\t*end++ = 0;\n-\t\t\t\tif (inet_aton(optarg, &in) == 0)\n+\t\t\t\tif (inet_pton(AF_INET, optarg, &in) == 0)\n \t\t\t\t\trte_exit(EXIT_FAILURE,\n \t\t\t\t\t\t \"Invalid source IP address: %s\\n\",\n \t\t\t\t\t\t optarg);\n \t\t\t\ttx_ip_src_addr = rte_be_to_cpu_32(in.s_addr);\n \n-\t\t\t\tif (inet_aton(end, &in) == 0)\n+\t\t\t\tif (inet_pton(AF_INET, end, &in) == 0)\n \t\t\t\t\trte_exit(EXIT_FAILURE,\n \t\t\t\t\t\t \"Invalid destination IP address: %s\\n\",\n \t\t\t\t\t\t optarg);\ndiff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c\nindex 8ed1b97dec..1cdd3cdd12 100644\n--- a/app/test-pmd/testpmd.c\n+++ b/app/test-pmd/testpmd.c\n@@ -9,7 +9,9 @@\n #include <string.h>\n #include <time.h>\n #include <fcntl.h>\n+#ifndef RTE_EXEC_ENV_WINDOWS\n #include <sys/mman.h>\n+#endif\n #include <sys/types.h>\n #include <errno.h>\n #include <stdbool.h>\n@@ -60,6 +62,9 @@\n #ifdef RTE_LIB_LATENCYSTATS\n #include <rte_latencystats.h>\n #endif\n+#ifdef RTE_EXEC_ENV_WINDOWS\n+#include <process.h>\n+#endif\n \n #include \"testpmd.h\"\n \n@@ -629,6 +634,7 @@ set_def_fwd_config(void)\n \tset_default_fwd_ports_config();\n }\n \n+#ifndef RTE_EXEC_ENV_WINDOWS\n /* extremely pessimistic estimation of memory required to create a mempool */\n static int\n calc_mem_size(uint32_t nb_mbufs, uint32_t mbuf_sz, size_t pgsz, size_t *out)\n@@ -899,6 +905,7 @@ dma_map_cb(struct rte_mempool *mp __rte_unused, void *opaque __rte_unused,\n \t\t}\n \t}\n }\n+#endif\n \n static unsigned int\n setup_extbuf(uint32_t nb_mbufs, uint16_t mbuf_sz, unsigned int socket_id,\n@@ -969,9 +976,11 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf,\n {\n \tchar pool_name[RTE_MEMPOOL_NAMESIZE];\n \tstruct rte_mempool *rte_mp = NULL;\n+#ifndef RTE_EXEC_ENV_WINDOWS\n \tuint32_t mb_size;\n \n \tmb_size = sizeof(struct rte_mbuf) + mbuf_seg_size;\n+#endif\n \tmbuf_poolname_build(socket_id, pool_name, sizeof(pool_name), size_idx);\n \n \tTESTPMD_LOG(INFO,\n@@ -988,6 +997,7 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf,\n \t\t\t\tmb_mempool_cache, 0, mbuf_seg_size, socket_id);\n \t\t\tbreak;\n \t\t}\n+#ifndef RTE_EXEC_ENV_WINDOWS\n \tcase MP_ALLOC_ANON:\n \t\t{\n \t\t\trte_mp = rte_mempool_create_empty(pool_name, nb_mbuf,\n@@ -1028,6 +1038,7 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf,\n \t\t\t\t\theap_socket);\n \t\t\tbreak;\n \t\t}\n+#endif\n \tcase MP_ALLOC_XBUF:\n \t\t{\n \t\t\tstruct rte_pktmbuf_extmem *ext_mem;\n@@ -1054,7 +1065,9 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf,\n \t\t}\n \t}\n \n+#ifndef RTE_EXEC_ENV_WINDOWS\n err:\n+#endif\n \tif (rte_mp == NULL) {\n \t\trte_exit(EXIT_FAILURE,\n \t\t\t\"Creation of mbuf pool for socket %u failed: %s\\n\",\n@@ -3021,6 +3034,7 @@ pmd_test_exit(void)\n \tif (test_done == 0)\n \t\tstop_packet_forwarding();\n \n+#ifndef RTE_EXEC_ENV_WINDOWS\n \tfor (i = 0 ; i < RTE_DIM(mempools) ; i++) {\n \t\tif (mempools[i]) {\n \t\t\tif (mp_alloc_type == MP_ALLOC_ANON)\n@@ -3028,6 +3042,7 @@ pmd_test_exit(void)\n \t\t\t\t\t\t     NULL);\n \t\t}\n \t}\n+#endif\n \tif (ports != NULL) {\n \t\tno_link_check = 1;\n \t\tRTE_ETH_FOREACH_DEV(pt_id) {\n@@ -3728,8 +3743,10 @@ signal_handler(int signum)\n \t\t/* Set flag to indicate the force termination. */\n \t\tf_quit = 1;\n \t\t/* exit with the expected status */\n+#ifndef RTE_EXEC_ENV_WINDOWS\n \t\tsignal(signum, SIG_DFL);\n \t\tkill(getpid(), signum);\n+#endif\n \t}\n }\n \n@@ -3804,10 +3821,12 @@ main(int argc, char** argv)\n \tif (argc > 1)\n \t\tlaunch_args_parse(argc, argv);\n \n+#ifndef RTE_EXEC_ENV_WINDOWS\n \tif (do_mlockall && mlockall(MCL_CURRENT | MCL_FUTURE)) {\n \t\tTESTPMD_LOG(NOTICE, \"mlockall() failed with error \\\"%s\\\"\\n\",\n \t\t\tstrerror(errno));\n \t}\n+#endif\n \n \tif (tx_first && interactive)\n \t\trte_exit(EXIT_FAILURE, \"--tx-first cannot be used on \"\n@@ -3928,7 +3947,7 @@ main(int argc, char** argv)\n \t\t\t\t}\n \t\t\t\t/* Sleep to avoid unnecessary checks */\n \t\t\t\tprev_time = cur_time;\n-\t\t\t\tsleep(1);\n+\t\t\t\trte_delay_us_sleep(US_PER_S);\n \t\t\t}\n \t\t}\n \ndiff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h\nindex 9ae4d90dd1..d61a055bdd 100644\n--- a/app/test-pmd/testpmd.h\n+++ b/app/test-pmd/testpmd.h\n@@ -11,6 +11,7 @@\n #include <rte_bus_pci.h>\n #include <rte_gro.h>\n #include <rte_gso.h>\n+#include <rte_os_shim.h>\n #include <cmdline.h>\n #include <sys/queue.h>\n \n@@ -762,7 +763,7 @@ inc_tx_burst_stats(struct fwd_stream *fs, uint16_t nb_tx)\n }\n \n /* Prototypes */\n-unsigned int parse_item_list(char* str, const char* item_name,\n+unsigned int parse_item_list(const char *str, const char *item_name,\n \t\t\tunsigned int max_items,\n \t\t\tunsigned int *parsed_items, int check_unique_values);\n void launch_args_parse(int argc, char** argv);\n",
    "prefixes": [
        "v14",
        "7/9"
    ]
}