Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1406/?format=api
https://patches.dpdk.org/api/patches/1406/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1416524335-22753-13-git-send-email-olivier.matz@6wind.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": "<1416524335-22753-13-git-send-email-olivier.matz@6wind.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1416524335-22753-13-git-send-email-olivier.matz@6wind.com", "date": "2014-11-20T22:58:54", "name": "[dpdk-dev,v3,12/13] testpmd: support TSO in csum forward engine", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "a8b3f88d27bd2c03ff1d5c183d190f2508a169ca", "submitter": { "id": 8, "url": "https://patches.dpdk.org/api/people/8/?format=api", "name": "Olivier Matz", "email": "olivier.matz@6wind.com" }, "delegate": null, "mbox": "https://patches.dpdk.org/project/dpdk/patch/1416524335-22753-13-git-send-email-olivier.matz@6wind.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/1406/comments/", "check": "pending", "checks": "https://patches.dpdk.org/api/patches/1406/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 224067FF5;\n\tThu, 20 Nov 2014 23:48:55 +0100 (CET)", "from mail-wg0-f44.google.com (mail-wg0-f44.google.com\n\t[74.125.82.44]) by dpdk.org (Postfix) with ESMTP id 681687F40\n\tfor <dev@dpdk.org>; Thu, 20 Nov 2014 23:48:45 +0100 (CET)", "by mail-wg0-f44.google.com with SMTP id b13so5053136wgh.3\n\tfor <dev@dpdk.org>; Thu, 20 Nov 2014 14:59:17 -0800 (PST)", "from glumotte.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\tcz3sm5380581wjb.23.2014.11.20.14.59.16 for <multiple recipients>\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tThu, 20 Nov 2014 14:59:16 -0800 (PST)" ], "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:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=q0thLtkuOtdUKlmLKbmH8iC6j2SoQq1X/tXdm9iK/cE=;\n\tb=LXzoYmY410tmH4+APvpe9uGVJm3Akj3ZSV+RhwTeFQaUgWEbqSTsAwaFkDZtLnXtZ8\n\tPjKTAvf2DHt/lJ983jK/DTQHXJT5BL38pBb6kELinWqRyyfhZqbjhc8TcHDV4SQn9/Wy\n\t6DzqNidsL7iVg2bxN/Y7lPIHdFwsOvqLCIguxlhg/UVmToVW9vicIgk7dMoIL15rAOLp\n\tGb0kKf6p1dEaPz5kFZeCtFoPiI9pw38qqHDWrnSAT5ELkotgW2/u8Afb43DiV8xcC1d7\n\tUgj4ExkIrFy6WMbwd39KhBnxU1amtbDdDy9slgdcgnTbBo2Gdr5IWiXLKOn66B5iB8Sv\n\tXPMQ==", "X-Gm-Message-State": "ALoCoQm4tsjW7oSKVakxrHnzQqDFjNriWOxXdrhkjW7keypAkskQm7w9K11pATMl2EesrhmT1K4F", "X-Received": "by 10.194.237.162 with SMTP id vd2mr1501186wjc.52.1416524357296; \n\tThu, 20 Nov 2014 14:59:17 -0800 (PST)", "From": "Olivier Matz <olivier.matz@6wind.com>", "To": "dev@dpdk.org", "Date": "Thu, 20 Nov 2014 23:58:54 +0100", "Message-Id": "<1416524335-22753-13-git-send-email-olivier.matz@6wind.com>", "X-Mailer": "git-send-email 2.1.0", "In-Reply-To": "<1416524335-22753-1-git-send-email-olivier.matz@6wind.com>", "References": "<1415984609-2484-1-git-send-email-olivier.matz@6wind.com>\n\t<1416524335-22753-1-git-send-email-olivier.matz@6wind.com>", "Cc": "jigsaw@gmail.com", "Subject": "[dpdk-dev] [PATCH v3 12/13] testpmd: support TSO in csum forward\n\tengine", "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": "Add two new commands in testpmd:\n\n- tso set <segsize> <portid>\n- tso show <portid>\n\nThese commands can be used enable TSO when transmitting TCP packets in\nthe csum forward engine. Ex:\n\n set fwd csum\n tx_checksum set ip hw 0\n tso set 800 0\n start\n\nSigned-off-by: Olivier Matz <olivier.matz@6wind.com>\n---\n app/test-pmd/cmdline.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++\n app/test-pmd/csumonly.c | 64 ++++++++++++++++++++++++----------\n app/test-pmd/testpmd.h | 1 +\n 3 files changed, 139 insertions(+), 18 deletions(-)", "diff": "diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c\nindex 61e4340..fe2ee41 100644\n--- a/app/test-pmd/cmdline.c\n+++ b/app/test-pmd/cmdline.c\n@@ -323,6 +323,14 @@ static void cmd_help_long_parsed(void *parsed_result,\n \t\t\t\"tx_checksum show (port_id)\\n\"\n \t\t\t\" Display tx checksum offload configuration\\n\\n\"\n \n+\t\t\t\"tso set (segsize) (portid)\\n\"\n+\t\t\t\" Enable TCP Segmentation Offload in csum forward\"\n+\t\t\t\" engine.\\n\"\n+\t\t\t\" Please check the NIC datasheet for HW limits.\\n\\n\"\n+\n+\t\t\t\"tso show (portid)\"\n+\t\t\t\" Display the status of TCP Segmentation Offload.\\n\\n\"\n+\n \t\t\t\"set fwd (%s)\\n\"\n \t\t\t\" Set packet forwarding mode.\\n\\n\"\n \n@@ -2867,6 +2875,88 @@ cmdline_parse_inst_t cmd_tx_cksum_show = {\n \t},\n };\n \n+/* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */\n+struct cmd_tso_set_result {\n+\tcmdline_fixed_string_t tso;\n+\tcmdline_fixed_string_t mode;\n+\tuint16_t tso_segsz;\n+\tuint8_t port_id;\n+};\n+\n+static void\n+cmd_tso_set_parsed(void *parsed_result,\n+\t\t __attribute__((unused)) struct cmdline *cl,\n+\t\t __attribute__((unused)) void *data)\n+{\n+\tstruct cmd_tso_set_result *res = parsed_result;\n+\tstruct rte_eth_dev_info dev_info;\n+\n+\tif (port_id_is_invalid(res->port_id))\n+\t\treturn;\n+\n+\tif (!strcmp(res->mode, \"set\"))\n+\t\tports[res->port_id].tso_segsz = res->tso_segsz;\n+\n+\tif (ports[res->port_id].tso_segsz == 0)\n+\t\tprintf(\"TSO is disabled\\n\");\n+\telse\n+\t\tprintf(\"TSO segment size is %d\\n\",\n+\t\t\tports[res->port_id].tso_segsz);\n+\n+\t/* display warnings if configuration is not supported by the NIC */\n+\trte_eth_dev_info_get(res->port_id, &dev_info);\n+\tif ((ports[res->port_id].tso_segsz != 0) &&\n+\t\t(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {\n+\t\tprintf(\"Warning: TSO enabled but not \"\n+\t\t\t\"supported by port %d\\n\", res->port_id);\n+\t}\n+}\n+\n+cmdline_parse_token_string_t cmd_tso_set_tso =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,\n+\t\t\t\ttso, \"tso\");\n+cmdline_parse_token_string_t cmd_tso_set_mode =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,\n+\t\t\t\tmode, \"set\");\n+cmdline_parse_token_num_t cmd_tso_set_tso_segsz =\n+\tTOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,\n+\t\t\t\ttso_segsz, UINT16);\n+cmdline_parse_token_num_t cmd_tso_set_portid =\n+\tTOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,\n+\t\t\t\tport_id, UINT8);\n+\n+cmdline_parse_inst_t cmd_tso_set = {\n+\t.f = cmd_tso_set_parsed,\n+\t.data = NULL,\n+\t.help_str = \"Set TSO segment size for csum engine (0 to disable): \"\n+\t\"tso set <tso_segsz> <port>\",\n+\t.tokens = {\n+\t\t(void *)&cmd_tso_set_tso,\n+\t\t(void *)&cmd_tso_set_mode,\n+\t\t(void *)&cmd_tso_set_tso_segsz,\n+\t\t(void *)&cmd_tso_set_portid,\n+\t\tNULL,\n+\t},\n+};\n+\n+cmdline_parse_token_string_t cmd_tso_show_mode =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,\n+\t\t\t\tmode, \"show\");\n+\n+\n+cmdline_parse_inst_t cmd_tso_show = {\n+\t.f = cmd_tso_set_parsed,\n+\t.data = NULL,\n+\t.help_str = \"Show TSO segment size for csum engine: \"\n+\t\"tso show <port>\",\n+\t.tokens = {\n+\t\t(void *)&cmd_tso_set_tso,\n+\t\t(void *)&cmd_tso_show_mode,\n+\t\t(void *)&cmd_tso_set_portid,\n+\t\tNULL,\n+\t},\n+};\n+\n /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */\n struct cmd_set_flush_rx {\n \tcmdline_fixed_string_t set;\n@@ -7880,6 +7970,8 @@ cmdline_parse_ctx_t main_ctx[] = {\n \t(cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,\n \t(cmdline_parse_inst_t *)&cmd_tx_cksum_set,\n \t(cmdline_parse_inst_t *)&cmd_tx_cksum_show,\n+\t(cmdline_parse_inst_t *)&cmd_tso_set,\n+\t(cmdline_parse_inst_t *)&cmd_tso_show,\n \t(cmdline_parse_inst_t *)&cmd_link_flow_control_set,\n \t(cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,\n \t(cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,\ndiff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c\nindex 37d4129..ec9555f 100644\n--- a/app/test-pmd/csumonly.c\n+++ b/app/test-pmd/csumonly.c\n@@ -88,12 +88,12 @@\n #endif\n \n static uint16_t\n-get_psd_sum(void *l3_hdr, uint16_t ethertype)\n+get_psd_sum(void *l3_hdr, uint16_t ethertype, uint64_t ol_flags)\n {\n \tif (ethertype == _htons(ETHER_TYPE_IPv4))\n-\t\treturn rte_ipv4_phdr_cksum(l3_hdr);\n+\t\treturn rte_ipv4_phdr_cksum(l3_hdr, ol_flags);\n \telse /* assume ethertype == ETHER_TYPE_IPv6 */\n-\t\treturn rte_ipv6_phdr_cksum(l3_hdr);\n+\t\treturn rte_ipv6_phdr_cksum(l3_hdr, ol_flags);\n }\n \n static uint16_t\n@@ -108,14 +108,15 @@ get_udptcp_checksum(void *l3_hdr, void *l4_hdr, uint16_t ethertype)\n /*\n * Parse an ethernet header to fill the ethertype, l2_len, l3_len and\n * ipproto. This function is able to recognize IPv4/IPv6 with one optional vlan\n- * header.\n+ * header. The l4_len argument is only set in case of TCP (useful for TSO).\n */\n static void\n parse_ethernet(struct ether_hdr *eth_hdr, uint16_t *ethertype, uint16_t *l2_len,\n-\tuint16_t *l3_len, uint8_t *l4_proto)\n+\tuint16_t *l3_len, uint8_t *l4_proto, uint16_t *l4_len)\n {\n \tstruct ipv4_hdr *ipv4_hdr;\n \tstruct ipv6_hdr *ipv6_hdr;\n+\tstruct tcp_hdr *tcp_hdr;\n \n \t*l2_len = sizeof(struct ether_hdr);\n \t*ethertype = eth_hdr->ether_type;\n@@ -143,6 +144,14 @@ parse_ethernet(struct ether_hdr *eth_hdr, uint16_t *ethertype, uint16_t *l2_len,\n \t\t*l4_proto = 0;\n \t\tbreak;\n \t}\n+\n+\tif (*l4_proto == IPPROTO_TCP) {\n+\t\ttcp_hdr = (struct tcp_hdr *)((char *)eth_hdr +\n+\t\t\t*l2_len + *l3_len);\n+\t\t*l4_len = (tcp_hdr->data_off & 0xf0) >> 2;\n+\t}\n+\telse\n+\t\t*l4_len = 0;\n }\n \n /* modify the IPv4 or IPv4 source address of a packet */\n@@ -165,7 +174,7 @@ change_ip_addresses(void *l3_hdr, uint16_t ethertype)\n * depending on the testpmd command line configuration */\n static uint64_t\n process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len,\n-\tuint8_t l4_proto, uint16_t testpmd_ol_flags)\n+\tuint8_t l4_proto, uint16_t tso_segsz, uint16_t testpmd_ol_flags)\n {\n \tstruct ipv4_hdr *ipv4_hdr = l3_hdr;\n \tstruct udp_hdr *udp_hdr;\n@@ -177,11 +186,16 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len,\n \t\tipv4_hdr = l3_hdr;\n \t\tipv4_hdr->hdr_checksum = 0;\n \n-\t\tif (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM)\n+\t\tif (tso_segsz != 0 && l4_proto == IPPROTO_TCP) {\n \t\t\tol_flags |= PKT_TX_IP_CKSUM;\n-\t\telse\n-\t\t\tipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr);\n-\n+\t\t}\n+\t\telse {\n+\t\t\tif (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM)\n+\t\t\t\tol_flags |= PKT_TX_IP_CKSUM;\n+\t\t\telse\n+\t\t\t\tipv4_hdr->hdr_checksum =\n+\t\t\t\t\trte_ipv4_cksum(ipv4_hdr);\n+\t\t}\n \t}\n \telse if (ethertype != _htons(ETHER_TYPE_IPv6))\n \t\treturn 0; /* packet type not supported nothing to do */\n@@ -194,7 +208,7 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len,\n \t\t\tif (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) {\n \t\t\t\tol_flags |= PKT_TX_UDP_CKSUM;\n \t\t\t\tudp_hdr->dgram_cksum = get_psd_sum(l3_hdr,\n-\t\t\t\t\tethertype);\n+\t\t\t\t\tethertype, ol_flags);\n \t\t\t}\n \t\t\telse {\n \t\t\t\tudp_hdr->dgram_cksum =\n@@ -206,9 +220,13 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len,\n \telse if (l4_proto == IPPROTO_TCP) {\n \t\ttcp_hdr = (struct tcp_hdr *)((char *)l3_hdr + l3_len);\n \t\ttcp_hdr->cksum = 0;\n-\t\tif (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) {\n+\t\tif (tso_segsz != 0) {\n+\t\t\tol_flags |= PKT_TX_TCP_SEG;\n+\t\t\ttcp_hdr->cksum = get_psd_sum(l3_hdr, ethertype, ol_flags);\n+\t\t}\n+\t\telse if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) {\n \t\t\tol_flags |= PKT_TX_TCP_CKSUM;\n-\t\t\ttcp_hdr->cksum = get_psd_sum(l3_hdr, ethertype);\n+\t\t\ttcp_hdr->cksum = get_psd_sum(l3_hdr, ethertype, ol_flags);\n \t\t}\n \t\telse {\n \t\t\ttcp_hdr->cksum =\n@@ -279,6 +297,8 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype,\n * - modify the IPs in inner headers and in outer headers if any\n * - reprocess the checksum of all supported layers. This is done in SW\n * or HW, depending on testpmd command line configuration\n+ * - if TSO is enabled in testpmd command line, also flag the mbuf for TCP\n+ * segmentation offload (this implies HW TCP checksum)\n * Then transmit packets on the output port.\n *\n * (1) Supported packets are:\n@@ -309,7 +329,9 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)\n \tuint16_t testpmd_ol_flags;\n \tuint8_t l4_proto;\n \tuint16_t ethertype = 0, outer_ethertype = 0;\n-\tuint16_t l2_len = 0, l3_len = 0, outer_l2_len = 0, outer_l3_len = 0;\n+\tuint16_t l2_len = 0, l3_len = 0, l4_len = 0;\n+\tuint16_t outer_l2_len = 0, outer_l3_len = 0;\n+\tuint16_t tso_segsz;\n \tint tunnel = 0;\n \tuint32_t rx_bad_ip_csum;\n \tuint32_t rx_bad_l4_csum;\n@@ -339,6 +361,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)\n \n \ttxp = &ports[fs->tx_port];\n \ttestpmd_ol_flags = txp->tx_ol_flags;\n+\ttso_segsz = txp->tso_segsz;\n \n \tfor (i = 0; i < nb_rx; i++) {\n \n@@ -354,7 +377,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)\n \t\t * and inner headers */\n \n \t\teth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);\n-\t\tparse_ethernet(eth_hdr, ðertype, &l2_len, &l3_len, &l4_proto);\n+\t\tparse_ethernet(eth_hdr, ðertype, &l2_len, &l3_len,\n+\t\t\t&l4_proto, &l4_len);\n \t\tl3_hdr = (char *)eth_hdr + l2_len;\n \n \t\t/* check if it's a supported tunnel (only vxlan for now) */\n@@ -382,7 +406,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)\n \t\t\t\t\tsizeof(struct vxlan_hdr));\n \n \t\t\t\tparse_ethernet(eth_hdr, ðertype, &l2_len,\n-\t\t\t\t\t&l3_len, &l4_proto);\n+\t\t\t\t\t&l3_len, &l4_proto, &l4_len);\n \t\t\t\tl3_hdr = (char *)eth_hdr + l2_len;\n \t\t\t}\n \t\t}\n@@ -396,11 +420,12 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)\n \n \t\t/* step 3: depending on user command line configuration,\n \t\t * recompute checksum either in software or flag the\n-\t\t * mbuf to offload the calculation to the NIC */\n+\t\t * mbuf to offload the calculation to the NIC. If TSO\n+\t\t * is configured, prepare the mbuf for TCP segmentation. */\n \n \t\t/* process checksums of inner headers first */\n \t\tol_flags |= process_inner_cksums(l3_hdr, ethertype,\n-\t\t\tl3_len, l4_proto, testpmd_ol_flags);\n+\t\t\tl3_len, l4_proto, tso_segsz, testpmd_ol_flags);\n \n \t\t/* Then process outer headers if any. Note that the software\n \t\t * checksum will be wrong if one of the inner checksums is\n@@ -429,6 +454,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)\n \t\t\t\t\tsizeof(struct udp_hdr) +\n \t\t\t\t\tsizeof(struct vxlan_hdr) + l2_len;\n \t\t\t\tm->l3_len = l3_len;\n+\t\t\t\tm->l4_len = l4_len;\n \t\t\t}\n \t\t} else {\n \t\t\t/* this is only useful if an offload flag is\n@@ -436,7 +462,9 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)\n \t\t\t * case */\n \t\t\tm->l2_len = l2_len;\n \t\t\tm->l3_len = l3_len;\n+\t\t\tm->l4_len = l4_len;\n \t\t}\n+\t\tm->tso_segsz = tso_segsz;\n \t\tm->ol_flags = ol_flags;\n \n \t}\ndiff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h\nindex c753d37..c22863f 100644\n--- a/app/test-pmd/testpmd.h\n+++ b/app/test-pmd/testpmd.h\n@@ -149,6 +149,7 @@ struct rte_port {\n \tstruct fwd_stream *tx_stream; /**< Port TX stream, if unique */\n \tunsigned int socket_id; /**< For NUMA support */\n \tuint16_t tx_ol_flags;/**< TX Offload Flags (TESTPMD_TX_OFFLOAD...). */\n+\tuint16_t tso_segsz; /**< MSS for segmentation offload. */\n \tuint16_t tx_vlan_id; /**< Tag Id. in TX VLAN packets. */\n \tvoid *fwd_ctx; /**< Forwarding mode context */\n \tuint64_t rx_bad_ip_csum; /**< rx pkts with bad ip checksum */\n", "prefixes": [ "dpdk-dev", "v3", "12/13" ] }{ "id": 1406, "url": "