From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jerin Jacob Subject: [PATCH v5 3/4] app/testpmd: add outer UDP HW checksum support Date: Tue, 9 Oct 2018 14:18:14 +0000 Message-ID: <20181009141741.5162-3-jerin.jacob@caviumnetworks.com> References: <20181008160953.32510-1-jerin.jacob@caviumnetworks.com> <20181009141741.5162-1-jerin.jacob@caviumnetworks.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: "dev@dpdk.org" , "thomas@monjalon.net" , "ferruh.yigit@intel.com" , "arybchenko@solarflare.com" , "olivier.matz@6wind.com" , "Jacob, Jerin" To: Wenzhuo Lu , Jingjing Wu , Bernard Iremonger , John McNamara , Marko Kovacevic Return-path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0071.outbound.protection.outlook.com [104.47.38.71]) by dpdk.org (Postfix) with ESMTP id B35221B580 for ; Tue, 9 Oct 2018 16:18:17 +0200 (CEST) In-Reply-To: <20181009141741.5162-1-jerin.jacob@caviumnetworks.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Added outer-udp Tx HW checksum support for csum forward engine if device supports DEV_TX_OFFLOAD_OUTER_UDP_CKSUM. Signed-off-by: Jerin Jacob Acked-by: Bernard Iremonger --- app/test-pmd/cmdline.c | 24 ++++++++++++++++++--- app/test-pmd/csumonly.c | 13 +++++++++-- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 8 +++++-- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 0c5399dc4..2fd007423 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -397,12 +397,13 @@ static void cmd_help_long_parsed(void *parsed_result, " Disable hardware insertion of a VLAN header in" " packets sent on a port.\n\n" =20 - "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n" + "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n" " Select hardware or software calculation of the" " checksum when transmitting a packet using the" " csum forward engine.\n" " ip|udp|tcp|sctp always concern the inner layer.\n" " outer-ip concerns the outer IP layer in" + " outer-udp concerns the outer UDP layer in" " case the packet is recognized as a tunnel packet by" " the forward engine (vxlan, gre and ipip are supported)\n" " Please check the NIC datasheet for HW limits.\n\n" @@ -4177,6 +4178,8 @@ csum_show(int port_id) (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); printf("Outer-Ip checksum offload is %s\n", (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw"); + printf("Outer-Udp checksum offload is %s\n", + (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw"); =20 /* display warnings if configuration is not supported by the NIC */ rte_eth_dev_info_get(port_id, &dev_info); @@ -4205,6 +4208,12 @@ csum_show(int port_id) printf("Warning: hardware outer IP checksum enabled but not " "supported by port %d\n", port_id); } + if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) + =3D=3D 0) { + printf("Warning: hardware outer UDP checksum enabled but not " + "supported by port %d\n", port_id); + } } =20 static void @@ -4273,6 +4282,15 @@ cmd_csum_parsed(void *parsed_result, printf("Outer IP checksum offload is not " "supported by port %u\n", res->port_id); } + } else if (!strcmp(res->proto, "outer-udp")) { + if (hw =3D=3D 0 || (dev_info.tx_offload_capa & + DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) { + csum_offloads |=3D + DEV_TX_OFFLOAD_OUTER_UDP_CKSUM; + } else { + printf("Outer UDP checksum offload is not " + "supported by port %u\n", res->port_id); + } } =20 if (hw) { @@ -4296,7 +4314,7 @@ cmdline_parse_token_string_t cmd_csum_mode =3D mode, "set"); cmdline_parse_token_string_t cmd_csum_proto =3D TOKEN_STRING_INITIALIZER(struct cmd_csum_result, - proto, "ip#tcp#udp#sctp#outer-ip"); + proto, "ip#tcp#udp#sctp#outer-ip#outer-udp"); cmdline_parse_token_string_t cmd_csum_hwsw =3D TOKEN_STRING_INITIALIZER(struct cmd_csum_result, hwsw, "hw#sw"); @@ -4307,7 +4325,7 @@ cmdline_parse_token_num_t cmd_csum_portid =3D cmdline_parse_inst_t cmd_csum_set =3D { .f =3D cmd_csum_parsed, .data =3D NULL, - .help_str =3D "csum set ip|tcp|udp|sctp|outer-ip hw|sw : " + .help_str =3D "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw : " "Enable/Disable hardware calculation of L3/L4 checksum when " "using csum forward engine", .tokens =3D { diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 494829266..ea5b112d6 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -468,10 +468,15 @@ process_outer_cksums(void *outer_l3_hdr, struct testp= md_offload_info *info, if (info->outer_l4_proto !=3D IPPROTO_UDP) return ol_flags; =20 + /* Skip SW outer UDP checksum generation if HW supports it */ + if (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) { + ol_flags |=3D PKT_TX_OUTER_UDP_CKSUM; + return ol_flags; + } + udp_hdr =3D (struct udp_hdr *)((char *)outer_l3_hdr + info->outer_l3_len)= ; =20 - /* outer UDP checksum is done in software as we have no hardware - * supporting it today, and no API for it. In the other side, for + /* outer UDP checksum is done in software. In the other side, for * UDP tunneling, like VXLAN or Geneve, outer UDP checksum can be * set to zero. * @@ -826,6 +831,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) if (info.tunnel_tso_segsz || (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) || + (tx_offloads & + DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) || (tx_ol_flags & PKT_TX_OUTER_IPV6)) { m->outer_l2_len =3D info.outer_l2_len; m->outer_l3_len =3D info.outer_l3_len; @@ -898,6 +905,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) if (info.is_tunnel =3D=3D 1) { if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) || + (tx_offloads & + DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) || (tx_ol_flags & PKT_TX_OUTER_IPV6)) printf("tx: m->outer_l2_len=3D%d " "m->outer_l3_len=3D%d\n", diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testp= md_app_ug/testpmd_funcs.rst index 3a73000a6..cfcabf6f0 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -857,7 +857,7 @@ csum set Select hardware or software calculation of the checksum when transmitting a packet using the ``csum`` forwarding engine:: =20 - testpmd> csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id) + testpmd> csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id= ) =20 Where: =20 @@ -867,6 +867,10 @@ Where: as a tunnel packet by the forwarding engine (vxlan, gre and ipip are supported). See also the ``csum parse-tunnel`` command. =20 +* ``outer-udp`` relates to the outer UDP layer in the case where the packe= t is recognized + as a tunnel packet by the forwarding engine (vxlan, vxlan-gpe are + supported). See also the ``csum parse-tunnel`` command. + .. note:: =20 Check the NIC Datasheet for hardware limits. @@ -940,7 +944,7 @@ Consider a packet in packet like the following:: =20 * If parse-tunnel is enabled, the ``ip|udp|tcp|sctp`` parameters of ``csum= set`` command relate to the inner headers (here ``ipv4_in`` and ``tcp_in``), a= nd the - ``outer-ip parameter`` relates to the outer headers (here ``ipv4_out``). + ``outer-ip|outer-udp`` parameter relates to the outer headers (here ``ip= v4_out`` and ``udp_out``). =20 * If parse-tunnel is disabled, the ``ip|udp|tcp|sctp`` parameters of ``csu= m set`` command relate to the outer headers, here ``ipv4_out`` and ``udp_out``. --=20 2.19.1