get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 59428,
    "url": "https://patches.dpdk.org/api/patches/59428/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20190919093850.460-3-marcinx.baran@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": "<20190919093850.460-3-marcinx.baran@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20190919093850.460-3-marcinx.baran@intel.com",
    "date": "2019-09-19T09:38:46",
    "name": "[v4,2/6] examples/ioat: add software copy support",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "0827df28397873fe570067d1cf94002bf12ca150",
    "submitter": {
        "id": 1430,
        "url": "https://patches.dpdk.org/api/people/1430/?format=api",
        "name": "Marcin Baran",
        "email": "marcinx.baran@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20190919093850.460-3-marcinx.baran@intel.com/mbox/",
    "series": [
        {
            "id": 6447,
            "url": "https://patches.dpdk.org/api/series/6447/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=6447",
            "date": "2019-09-19T09:38:44",
            "name": "examples/ioat: sample app on ioat driver usage",
            "version": 4,
            "mbox": "https://patches.dpdk.org/series/6447/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/59428/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/59428/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 360B91ED94;\n\tThu, 19 Sep 2019 11:39:21 +0200 (CEST)",
            "from mga07.intel.com (mga07.intel.com [134.134.136.100])\n\tby dpdk.org (Postfix) with ESMTP id A4D621ED8E\n\tfor <dev@dpdk.org>; Thu, 19 Sep 2019 11:39:17 +0200 (CEST)",
            "from orsmga002.jf.intel.com ([10.7.209.21])\n\tby orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t19 Sep 2019 02:39:17 -0700",
            "from baranmx-mobl.ger.corp.intel.com ([10.103.104.83])\n\tby orsmga002.jf.intel.com with ESMTP; 19 Sep 2019 02:39:15 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.64,523,1559545200\"; d=\"scan'208\";a=\"199341462\"",
        "From": "Marcin Baran <marcinx.baran@intel.com>",
        "To": "dev@dpdk.org,\n\tbruce.richardson@intel.com",
        "Cc": "Marcin Baran <marcinx.baran@intel.com>,\n\tPawel Modrak <pawelx.modrak@intel.com>",
        "Date": "Thu, 19 Sep 2019 11:38:46 +0200",
        "Message-Id": "<20190919093850.460-3-marcinx.baran@intel.com>",
        "X-Mailer": "git-send-email 2.22.0.windows.1",
        "In-Reply-To": "<20190919093850.460-1-marcinx.baran@intel.com>",
        "References": "<20190918091139.1430-1-marcinx.baran@intel.com>\n\t<20190919093850.460-1-marcinx.baran@intel.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v4 2/6] examples/ioat: add software copy support",
        "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": "Added support for copying packets\nusing software copy mode and MAC address\nchanging. The copies are processed using\none lcore.\n\nSigned-off-by: Marcin Baran <marcinx.baran@intel.com>\nSigned-off-by: Pawel Modrak <pawelx.modrak@intel.com>\n---\n examples/ioat/ioatfwd.c | 211 +++++++++++++++++++++++++++++++++++-----\n 1 file changed, 188 insertions(+), 23 deletions(-)",
    "diff": "diff --git a/examples/ioat/ioatfwd.c b/examples/ioat/ioatfwd.c\nindex 977ea6a61..3a092c6cf 100644\n--- a/examples/ioat/ioatfwd.c\n+++ b/examples/ioat/ioatfwd.c\n@@ -13,7 +13,7 @@\n #include <rte_rawdev.h>\n #include <rte_ioat_rawdev.h>\n \n-/* size of ring used for software copying between rx and tx. */\n+ /* size of ring used for software copying between rx and tx. */\n #define RTE_LOGTYPE_IOAT RTE_LOGTYPE_USER1\n #define MAX_PKT_BURST 32\n #define MEMPOOL_CACHE_SIZE 512\n@@ -89,6 +89,142 @@ static struct rte_ether_addr ioat_ports_eth_addr[RTE_MAX_ETHPORTS];\n static struct rte_eth_dev_tx_buffer *tx_buffer[RTE_MAX_ETHPORTS];\n struct rte_mempool *ioat_pktmbuf_pool;\n \n+static void\n+update_mac_addrs(struct rte_mbuf *m, uint32_t dest_portid)\n+{\n+\tstruct rte_ether_hdr *eth;\n+\tvoid *tmp;\n+\n+\teth = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);\n+\n+\t/* 02:00:00:00:00:xx - overwriting 2 bytes of source address but\n+\t * it's acceptable cause it gets overwritten by rte_ether_addr_copy\n+\t */\n+\ttmp = &eth->d_addr.addr_bytes[0];\n+\t*((uint64_t *)tmp) = 0x000000000002 + ((uint64_t)dest_portid << 40);\n+\n+\t/* src addr */\n+\trte_ether_addr_copy(&ioat_ports_eth_addr[dest_portid], &eth->s_addr);\n+}\n+\n+static inline void\n+pktmbuf_sw_copy(struct rte_mbuf *src, struct rte_mbuf *dst)\n+{\n+\t/* Copy packet metadata */\n+\trte_memcpy(&dst->rearm_data,\n+\t\t&src->rearm_data,\n+\t\toffsetof(struct rte_mbuf, cacheline1)\n+\t\t- offsetof(struct rte_mbuf, rearm_data));\n+\n+\t/* Copy packet data */\n+\trte_memcpy(rte_pktmbuf_mtod(dst, char *),\n+\t\trte_pktmbuf_mtod(src, char *), src->data_len);\n+}\n+\n+/* Receive packets on one port and enqueue to IOAT rawdev or rte_ring. */\n+static void\n+ioat_rx_port(struct rxtx_port_config *rx_config)\n+{\n+\tuint32_t nb_rx, nb_enq, i, j;\n+\tstruct rte_mbuf *pkts_burst[MAX_PKT_BURST];\n+\n+\tfor (i = 0; i < rx_config->nb_queues; i++) {\n+\n+\t\tnb_rx = rte_eth_rx_burst(rx_config->rxtx_port, i,\n+\t\t\tpkts_burst, MAX_PKT_BURST);\n+\n+\t\tif (nb_rx == 0)\n+\t\t\tcontinue;\n+\n+\t\t/* Perform packet software copy, free source packets */\n+\t\tint ret;\n+\t\tstruct rte_mbuf *pkts_burst_copy[MAX_PKT_BURST];\n+\n+\t\tret = rte_mempool_get_bulk(ioat_pktmbuf_pool,\n+\t\t\t(void *)pkts_burst_copy, nb_rx);\n+\n+\t\tif (unlikely(ret < 0))\n+\t\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\t\"Unable to allocate memory.\\n\");\n+\n+\t\tfor (j = 0; j < nb_rx; j++)\n+\t\t\tpktmbuf_sw_copy(pkts_burst[j],\n+\t\t\t\tpkts_burst_copy[j]);\n+\n+\t\trte_mempool_put_bulk(ioat_pktmbuf_pool,\n+\t\t\t(void *)pkts_burst, nb_rx);\n+\n+\t\tnb_enq = rte_ring_enqueue_burst(\n+\t\t\trx_config->rx_to_tx_ring,\n+\t\t\t(void *)pkts_burst_copy, nb_rx, NULL);\n+\n+\t\t/* Free any not enqueued packets. */\n+\t\trte_mempool_put_bulk(ioat_pktmbuf_pool,\n+\t\t\t(void *)&pkts_burst_copy[nb_enq],\n+\t\t\tnb_rx - nb_enq);\n+\t}\n+}\n+\n+/* Transmit packets from IOAT rawdev/rte_ring for one port. */\n+static void\n+ioat_tx_port(struct rxtx_port_config *tx_config)\n+{\n+\tuint32_t i, nb_dq = 0;\n+\tstruct rte_mbuf *mbufs_dst[MAX_PKT_BURST];\n+\n+\t/* Deque the mbufs from rx_to_tx_ring. */\n+\tnb_dq = rte_ring_dequeue_burst(tx_config->rx_to_tx_ring,\n+\t\t(void *)mbufs_dst, MAX_PKT_BURST, NULL);\n+\n+\tif (nb_dq == 0)\n+\t\treturn;\n+\n+\t/* Update macs if enabled */\n+\tif (mac_updating) {\n+\t\tfor (i = 0; i < nb_dq; i++)\n+\t\t\tupdate_mac_addrs(mbufs_dst[i],\n+\t\t\t\ttx_config->rxtx_port);\n+\t}\n+\n+\tconst uint16_t nb_tx = rte_eth_tx_burst(tx_config->rxtx_port,\n+\t\t0, (void *)mbufs_dst, nb_dq);\n+\n+\t/* Free any unsent packets. */\n+\tif (unlikely(nb_tx < nb_dq))\n+\t\trte_mempool_put_bulk(ioat_pktmbuf_pool,\n+\t\t(void *)&mbufs_dst[nb_tx],\n+\t\t\tnb_dq - nb_tx);\n+}\n+\n+/* Main rx and tx loop if only one slave lcore available */\n+static void\n+rxtx_main_loop(void)\n+{\n+\tuint16_t i;\n+\tuint16_t nb_ports = cfg.nb_ports;\n+\n+\tRTE_LOG(INFO, IOAT, \"Entering main rx and tx loop for copy on\"\n+\t\t\" lcore %u\\n\", rte_lcore_id());\n+\n+\twhile (!force_quit)\n+\t\tfor (i = 0; i < nb_ports; i++) {\n+\t\t\tioat_rx_port(&cfg.ports[i]);\n+\t\t\tioat_tx_port(&cfg.ports[i]);\n+\t\t}\n+}\n+\n+static void start_forwarding_cores(void)\n+{\n+\tuint32_t lcore_id = rte_lcore_id();\n+\n+\tRTE_LOG(INFO, IOAT, \"Entering %s on lcore %u\\n\",\n+\t\t__func__, rte_lcore_id());\n+\n+\tlcore_id = rte_get_next_lcore(lcore_id, true, true);\n+\trte_eal_remote_launch((lcore_function_t *)rxtx_main_loop,\n+\t\tNULL, lcore_id);\n+}\n+\n /* Display usage */\n static void\n ioat_usage(const char *prgname)\n@@ -102,7 +238,7 @@ ioat_usage(const char *prgname)\n \t\t\"       - The destination MAC address is replaced by 02:00:00:00:00:TX_PORT_ID\\n\"\n \t\t\"  -c --copy-type CT: type of copy: sw|rawdev\\n\"\n \t\t\"  -s --ring-size RS: size of IOAT rawdev ring for hardware copy mode or rte_ring for software copy mode\\n\",\n-\t       prgname);\n+\t\tprgname);\n }\n \n static int\n@@ -161,16 +297,16 @@ ioat_parse_args(int argc, char **argv, unsigned int nb_ports)\n \targvopt = argv;\n \n \twhile ((opt = getopt_long(argc, argvopt, short_options,\n-\t\t\t\t  lgopts, &option_index)) != EOF) {\n+\t\tlgopts, &option_index)) != EOF) {\n \n \t\tswitch (opt) {\n-\t\t/* portmask */\n+\t\t\t/* portmask */\n \t\tcase 'p':\n \t\t\tioat_enabled_port_mask = ioat_parse_portmask(optarg);\n \t\t\tif (ioat_enabled_port_mask & ~default_port_mask ||\n-\t\t\t\t\tioat_enabled_port_mask <= 0) {\n+\t\t\t\tioat_enabled_port_mask <= 0) {\n \t\t\t\tprintf(\"Invalid portmask, %s, suggest 0x%x\\n\",\n-\t\t\t\t\t\toptarg, default_port_mask);\n+\t\t\t\t\toptarg, default_port_mask);\n \t\t\t\tioat_usage(prgname);\n \t\t\t\treturn -1;\n \t\t\t}\n@@ -204,7 +340,7 @@ ioat_parse_args(int argc, char **argv, unsigned int nb_ports)\n \t\t\t}\n \t\t\tbreak;\n \n-\t\t/* long options */\n+\t\t\t/* long options */\n \t\tcase 0:\n \t\t\tbreak;\n \n@@ -216,9 +352,9 @@ ioat_parse_args(int argc, char **argv, unsigned int nb_ports)\n \n \tprintf(\"MAC updating %s\\n\", mac_updating ? \"enabled\" : \"disabled\");\n \tif (optind >= 0)\n-\t\targv[optind-1] = prgname;\n+\t\targv[optind - 1] = prgname;\n \n-\tret = optind-1;\n+\tret = optind - 1;\n \toptind = 1; /* reset getopt lib */\n \treturn ret;\n }\n@@ -253,6 +389,26 @@ check_link_status(uint32_t port_mask)\n \treturn retval;\n }\n \n+static void\n+assign_rings(void)\n+{\n+\tuint32_t i;\n+\n+\tfor (i = 0; i < cfg.nb_ports; i++) {\n+\t\tchar ring_name[RTE_RING_NAMESIZE];\n+\n+\t\tsnprintf(ring_name, sizeof(ring_name), \"rx_to_tx_ring_%u\", i);\n+\t\t/* Create ring for inter core communication */\n+\t\tcfg.ports[i].rx_to_tx_ring = rte_ring_create(\n+\t\t\tring_name, ring_size,\n+\t\t\trte_socket_id(), RING_F_SP_ENQ | RING_F_SC_DEQ);\n+\n+\t\tif (cfg.ports[i].rx_to_tx_ring == NULL)\n+\t\t\trte_exit(EXIT_FAILURE, \"Ring create failed: %s\\n\",\n+\t\t\t\trte_strerror(rte_errno));\n+\t}\n+}\n+\n /*\n  * Initializes a given port using global settings and with the RX buffers\n  * coming from the mbuf_pool passed as a parameter.\n@@ -263,7 +419,7 @@ port_init(uint16_t portid, struct rte_mempool *mbuf_pool, uint16_t nb_queues)\n \t/* configuring port to use RSS for multiple RX queues */\n \tstatic const struct rte_eth_conf port_conf = {\n \t\t.rxmode = {\n-\t\t\t.mq_mode        = ETH_MQ_RX_RSS,\n+\t\t\t.mq_mode = ETH_MQ_RX_RSS,\n \t\t\t.max_rx_pkt_len = RTE_ETHER_MAX_LEN\n \t\t},\n \t\t.rx_adv_conf = {\n@@ -294,14 +450,14 @@ port_init(uint16_t portid, struct rte_mempool *mbuf_pool, uint16_t nb_queues)\n \t\tdev_info.flow_type_rss_offloads;\n \tif (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)\n \t\tlocal_port_conf.txmode.offloads |=\n-\t\t\tDEV_TX_OFFLOAD_MBUF_FAST_FREE;\n+\t\tDEV_TX_OFFLOAD_MBUF_FAST_FREE;\n \tret = rte_eth_dev_configure(portid, nb_queues, 1, &local_port_conf);\n \tif (ret < 0)\n \t\trte_exit(EXIT_FAILURE, \"Cannot configure device:\"\n \t\t\t\" err=%d, port=%u\\n\", ret, portid);\n \n \tret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd,\n-\t\t\t\t\t\t&nb_txd);\n+\t\t&nb_txd);\n \tif (ret < 0)\n \t\trte_exit(EXIT_FAILURE,\n \t\t\t\"Cannot adjust number of descriptors: err=%d, port=%u\\n\",\n@@ -326,8 +482,8 @@ port_init(uint16_t portid, struct rte_mempool *mbuf_pool, uint16_t nb_queues)\n \ttxq_conf = dev_info.default_txconf;\n \ttxq_conf.offloads = local_port_conf.txmode.offloads;\n \tret = rte_eth_tx_queue_setup(portid, 0, nb_txd,\n-\t\t\trte_eth_dev_socket_id(portid),\n-\t\t\t&txq_conf);\n+\t\trte_eth_dev_socket_id(portid),\n+\t\t&txq_conf);\n \tif (ret < 0)\n \t\trte_exit(EXIT_FAILURE,\n \t\t\t\"rte_eth_tx_queue_setup:err=%d,port=%u\\n\",\n@@ -335,8 +491,8 @@ port_init(uint16_t portid, struct rte_mempool *mbuf_pool, uint16_t nb_queues)\n \n \t/* Initialize TX buffers */\n \ttx_buffer[portid] = rte_zmalloc_socket(\"tx_buffer\",\n-\t\t\tRTE_ETH_TX_BUFFER_SIZE(MAX_PKT_BURST), 0,\n-\t\t\trte_eth_dev_socket_id(portid));\n+\t\tRTE_ETH_TX_BUFFER_SIZE(MAX_PKT_BURST), 0,\n+\t\trte_eth_dev_socket_id(portid));\n \tif (tx_buffer[portid] == NULL)\n \t\trte_exit(EXIT_FAILURE,\n \t\t\t\"Cannot allocate buffer for tx on port %u\\n\",\n@@ -354,13 +510,13 @@ port_init(uint16_t portid, struct rte_mempool *mbuf_pool, uint16_t nb_queues)\n \trte_eth_promiscuous_enable(portid);\n \n \tprintf(\"Port %u, MAC address: %02X:%02X:%02X:%02X:%02X:%02X\\n\\n\",\n-\t\t\tportid,\n-\t\t\tioat_ports_eth_addr[portid].addr_bytes[0],\n-\t\t\tioat_ports_eth_addr[portid].addr_bytes[1],\n-\t\t\tioat_ports_eth_addr[portid].addr_bytes[2],\n-\t\t\tioat_ports_eth_addr[portid].addr_bytes[3],\n-\t\t\tioat_ports_eth_addr[portid].addr_bytes[4],\n-\t\t\tioat_ports_eth_addr[portid].addr_bytes[5]);\n+\t\tportid,\n+\t\tioat_ports_eth_addr[portid].addr_bytes[0],\n+\t\tioat_ports_eth_addr[portid].addr_bytes[1],\n+\t\tioat_ports_eth_addr[portid].addr_bytes[2],\n+\t\tioat_ports_eth_addr[portid].addr_bytes[3],\n+\t\tioat_ports_eth_addr[portid].addr_bytes[4],\n+\t\tioat_ports_eth_addr[portid].addr_bytes[5]);\n \n \tcfg.ports[cfg.nb_ports].rxtx_port = portid;\n \tcfg.ports[cfg.nb_ports++].nb_queues = nb_queues;\n@@ -428,10 +584,19 @@ main(int argc, char **argv)\n \tif (cfg.nb_lcores < 1)\n \t\trte_exit(EXIT_FAILURE,\n \t\t\t\"There should be at least one slave lcore.\\n\");\n+\n+\tassign_rings();\n+\n+\tstart_forwarding_cores();\n+\n+\t/* force_quit is true when we get here */\n+\trte_eal_mp_wait_lcore();\n+\n \tfor (i = 0; i < cfg.nb_ports; i++) {\n \t\tprintf(\"Closing port %d\\n\", cfg.ports[i].rxtx_port);\n \t\trte_eth_dev_stop(cfg.ports[i].rxtx_port);\n \t\trte_eth_dev_close(cfg.ports[i].rxtx_port);\n+\t\trte_ring_free(cfg.ports[i].rx_to_tx_ring);\n \t}\n \n \tprintf(\"Bye...\\n\");\n",
    "prefixes": [
        "v4",
        "2/6"
    ]
}