app/testpmd: support outer UDP HW checksum
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 <jerin.jacob@caviumnetworks.com> Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
This commit is contained in:
parent
df694a05bf
commit
bf5618fa6d
@ -394,12 +394,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"
|
||||
|
||||
"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"
|
||||
@ -4159,6 +4160,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");
|
||||
|
||||
/* display warnings if configuration is not supported by the NIC */
|
||||
rte_eth_dev_info_get(port_id, &dev_info);
|
||||
@ -4187,6 +4190,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)
|
||||
== 0) {
|
||||
printf("Warning: hardware outer UDP checksum enabled but not "
|
||||
"supported by port %d\n", port_id);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -4255,6 +4264,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 == 0 || (dev_info.tx_offload_capa &
|
||||
DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
|
||||
csum_offloads |=
|
||||
DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
|
||||
} else {
|
||||
printf("Outer UDP checksum offload is not "
|
||||
"supported by port %u\n", res->port_id);
|
||||
}
|
||||
}
|
||||
|
||||
if (hw) {
|
||||
@ -4278,7 +4296,7 @@ cmdline_parse_token_string_t cmd_csum_mode =
|
||||
mode, "set");
|
||||
cmdline_parse_token_string_t cmd_csum_proto =
|
||||
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 =
|
||||
TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
|
||||
hwsw, "hw#sw");
|
||||
@ -4289,7 +4307,7 @@ cmdline_parse_token_num_t cmd_csum_portid =
|
||||
cmdline_parse_inst_t cmd_csum_set = {
|
||||
.f = cmd_csum_parsed,
|
||||
.data = NULL,
|
||||
.help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
|
||||
.help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
|
||||
"Enable/Disable hardware calculation of L3/L4 checksum when "
|
||||
"using csum forward engine",
|
||||
.tokens = {
|
||||
|
@ -468,10 +468,15 @@ process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info,
|
||||
if (info->outer_l4_proto != IPPROTO_UDP)
|
||||
return ol_flags;
|
||||
|
||||
/* Skip SW outer UDP checksum generation if HW supports it */
|
||||
if (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) {
|
||||
ol_flags |= PKT_TX_OUTER_UDP_CKSUM;
|
||||
return ol_flags;
|
||||
}
|
||||
|
||||
udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + info->outer_l3_len);
|
||||
|
||||
/* 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 = info.outer_l2_len;
|
||||
m->outer_l3_len = info.outer_l3_len;
|
||||
@ -898,6 +905,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
|
||||
if (info.is_tunnel == 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=%d "
|
||||
"m->outer_l3_len=%d\n",
|
||||
|
@ -857,7 +857,7 @@ csum set
|
||||
Select hardware or software calculation of the checksum when
|
||||
transmitting a packet using the ``csum`` forwarding engine::
|
||||
|
||||
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)
|
||||
|
||||
Where:
|
||||
|
||||
@ -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.
|
||||
|
||||
* ``outer-udp`` relates to the outer UDP layer in the case where the packet is recognized
|
||||
as a tunnel packet by the forwarding engine (vxlan, vxlan-gpe are
|
||||
supported). See also the ``csum parse-tunnel`` command.
|
||||
|
||||
.. note::
|
||||
|
||||
Check the NIC Datasheet for hardware limits.
|
||||
@ -940,7 +944,7 @@ Consider a packet in packet like the following::
|
||||
|
||||
* 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``), and the
|
||||
``outer-ip parameter`` relates to the outer headers (here ``ipv4_out``).
|
||||
``outer-ip|outer-udp`` parameter relates to the outer headers (here ``ipv4_out`` and ``udp_out``).
|
||||
|
||||
* If parse-tunnel is disabled, the ``ip|udp|tcp|sctp`` parameters of ``csum set``
|
||||
command relate to the outer headers, here ``ipv4_out`` and ``udp_out``.
|
||||
|
Loading…
Reference in New Issue
Block a user