From patchwork Fri Jan 30 13:16:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Matz X-Patchwork-Id: 2826 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 495FB5ABD; Fri, 30 Jan 2015 14:17:00 +0100 (CET) Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com [74.125.82.46]) by dpdk.org (Postfix) with ESMTP id 86E6C234 for ; Fri, 30 Jan 2015 14:16:37 +0100 (CET) Received: by mail-wg0-f46.google.com with SMTP id l2so26840401wgh.5 for ; Fri, 30 Jan 2015 05:16:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=V90MqKStsNK04DpsK9RuS5L0vMrPw4SX2ANDnMbdi9M=; b=Xb+wA6un0lb7cxQGUxj8yj/51zXcruDzHONn7+b2fJlFNrXmOWzePDYuHvC8pEdHsv ChTHkIfES5Fr6BvJYj/FUB8cSyNhHlwv8Aae1YfXwzS9MAUSxa63D9HBju4fxH0/Mwgy N/QMeOYhTyQl4xwiGOExLA3K/arLrJ3L3MiTqpVVnkzh3iOUDP/MzjANzedRNp1mU/N4 vkkM9W+d4JRltFfaEfwRhx+1+ZfMYchX8c4CumCvzwexKILV04aAOY+9YfG0ppLlH4KK AQd9xj7RGjoNT86oGUnnOGJ23+7BtOtsjeIBGJPa3BiasdF9HrnP55azAj9GokSUjW1K GPog== X-Gm-Message-State: ALoCoQk2p8Veu4XUqXt7KFESWkTTNs5+SNXZnzb1WiPgetfmDpkcwa5bVriCkvfkLdDQkA9r/Y76 X-Received: by 10.194.84.176 with SMTP id a16mr2737643wjz.113.1422623797414; Fri, 30 Jan 2015 05:16:37 -0800 (PST) Received: from glumotte.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id li7sm6911300wic.4.2015.01.30.05.16.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 30 Jan 2015 05:16:36 -0800 (PST) From: Olivier Matz To: dev@dpdk.org Date: Fri, 30 Jan 2015 14:16:03 +0100 Message-Id: <1422623775-8050-9-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1422623775-8050-1-git-send-email-olivier.matz@6wind.com> References: <1421883395-27235-1-git-send-email-olivier.matz@6wind.com> <1422623775-8050-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH 08/20] testpmd: add csum parse_tunnel command X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add a new command related to csum forward engine: csum parse-tunnel (on|off) (tx_port_id) If enabled, the tunnel packets received by the csum forward engine are parsed and seen as "outer-headers/inner-headers/data". If disabled, the parsing of the csum forward engine stops at the first l4 layer. A tunnel packet is seens as "headers/data" (inner headers are included in payload). Note: the port argument is the tx_port. It's more coherent compared to all other testpmd csum flags. Signed-off-by: Olivier Matz --- app/test-pmd/cmdline.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ app/test-pmd/csumonly.c | 3 ++- app/test-pmd/testpmd.h | 5 +++- 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 260a273..62def61 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -326,6 +326,12 @@ static void cmd_help_long_parsed(void *parsed_result, " the forward engine)\n" " Please check the NIC datasheet for HW limits.\n\n" + "csum parse-tunnel (on|off) (tx_port_id)\n" + " If disabled, treat tunnel packets as non-tunneled" + " packets (treat inner headers as payload). The port\n" + " argument is the port used for TX in csum forward" + " engine.\n\n" + "csum show (port_id)\n" " Display tx checksum offload configuration\n\n" @@ -2873,6 +2879,8 @@ csum_show(int port_id) uint16_t ol_flags; ol_flags = ports[port_id].tx_ol_flags; + printf("Parse tunnel is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off"); printf("IP checksum offload is %s\n", (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw"); printf("UDP checksum offload is %s\n", @@ -2995,6 +3003,63 @@ cmdline_parse_inst_t cmd_csum_show = { }, }; +/* Enable/disable tunnel parsing */ +struct cmd_csum_tunnel_result { + cmdline_fixed_string_t csum; + cmdline_fixed_string_t parse; + cmdline_fixed_string_t onoff; + uint8_t port_id; +}; + +static void +cmd_csum_tunnel_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_csum_tunnel_result *res = parsed_result; + + if (port_id_is_invalid(res->port_id)) { + printf("invalid port %d\n", res->port_id); + return; + } + + if (!strcmp(res->onoff, "on")) + ports[res->port_id].tx_ol_flags |= + TESTPMD_TX_OFFLOAD_PARSE_TUNNEL; + else + ports[res->port_id].tx_ol_flags &= + (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL); + + csum_show(res->port_id); +} + +cmdline_parse_token_string_t cmd_csum_tunnel_csum = + TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, + csum, "csum"); +cmdline_parse_token_string_t cmd_csum_tunnel_parse = + TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, + parse, "parse_tunnel"); +cmdline_parse_token_string_t cmd_csum_tunnel_onoff = + TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, + onoff, "on#off"); +cmdline_parse_token_num_t cmd_csum_tunnel_portid = + TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, + port_id, UINT8); + +cmdline_parse_inst_t cmd_csum_tunnel = { + .f = cmd_csum_tunnel_parsed, + .data = NULL, + .help_str = "enable/disable parsing of tunnels for csum engine: " + "csum parse_tunnel on|off ", + .tokens = { + (void *)&cmd_csum_tunnel_csum, + (void *)&cmd_csum_tunnel_parse, + (void *)&cmd_csum_tunnel_onoff, + (void *)&cmd_csum_tunnel_portid, + NULL, + }, +}; + /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */ struct cmd_tso_set_result { cmdline_fixed_string_t tso; @@ -8731,6 +8796,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, (cmdline_parse_inst_t *)&cmd_csum_set, (cmdline_parse_inst_t *)&cmd_csum_show, + (cmdline_parse_inst_t *)&cmd_csum_tunnel, (cmdline_parse_inst_t *)&cmd_tso_set, (cmdline_parse_inst_t *)&cmd_tso_show, (cmdline_parse_inst_t *)&cmd_link_flow_control_set, diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index ca5ca39..858eb47 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -373,7 +373,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) l3_hdr = (char *)eth_hdr + l2_len; /* check if it's a supported tunnel (only vxlan for now) */ - if (l4_proto == IPPROTO_UDP) { + if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) && + l4_proto == IPPROTO_UDP) { udp_hdr = (struct udp_hdr *)((char *)l3_hdr + l3_len); /* check udp destination port, 4789 is the default diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 8f5e6c7..36277de 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -127,8 +127,11 @@ struct fwd_stream { #define TESTPMD_TX_OFFLOAD_SCTP_CKSUM 0x0008 /** Offload VxLAN checksum in csum forward engine */ #define TESTPMD_TX_OFFLOAD_VXLAN_CKSUM 0x0010 +/** Parse tunnel in csum forward engine. If set, dissect tunnel headers + * of rx packets. If not set, treat inner headers as payload. */ +#define TESTPMD_TX_OFFLOAD_PARSE_TUNNEL 0x0020 /** Insert VLAN header in forward engine */ -#define TESTPMD_TX_OFFLOAD_INSERT_VLAN 0x0020 +#define TESTPMD_TX_OFFLOAD_INSERT_VLAN 0x0040 /** * The data structure associated with each port.