#include <rte_prefetch.h>
#include <rte_string_fns.h>
#include <rte_flow.h>
+#ifdef RTE_LIB_GRO
#include <rte_gro.h>
+#endif
+#ifdef RTE_LIB_GSO
#include <rte_gso.h>
+#endif
#include <rte_geneve.h>
#include "testpmd.h"
/* structure that caches offload info for the current packet */
struct testpmd_offload_info {
uint16_t ethertype;
+#ifdef RTE_LIB_GSO
uint8_t gso_enable;
+#endif
uint16_t l2_len;
uint16_t l3_len;
uint16_t l4_len;
info->ethertype);
}
}
+#ifdef RTE_LIB_GSO
if (info->gso_enable)
ol_flags |= RTE_MBUF_F_TX_UDP_SEG;
+#endif
} else if (info->l4_proto == IPPROTO_TCP) {
tcp_hdr = (struct rte_tcp_hdr *)((char *)l3_hdr + info->l3_len);
if (tso_segsz)
get_udptcp_checksum(l3_hdr, tcp_hdr,
info->ethertype);
}
+#ifdef RTE_LIB_GSO
if (info->gso_enable)
ol_flags |= RTE_MBUF_F_TX_TCP_SEG;
+#endif
} else if (info->l4_proto == IPPROTO_SCTP) {
sctp_hdr = (struct rte_sctp_hdr *)
((char *)l3_hdr + info->l3_len);
*
* The testpmd command line for this forward engine sets the flags
* TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control
- * wether a checksum must be calculated in software or in hardware. The
+ * whether a checksum must be calculated in software or in hardware. The
* IP, UDP, TCP and SCTP flags always concern the inner layer. The
* OUTER_IP is only useful for tunnel packets.
*/
pkt_burst_checksum_forward(struct fwd_stream *fs)
{
struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
+#ifdef RTE_LIB_GSO
struct rte_mbuf *gso_segments[GSO_MAX_PKT_BURST];
struct rte_gso_ctx *gso_ctx;
+#endif
struct rte_mbuf **tx_pkts_burst;
struct rte_port *txp;
struct rte_mbuf *m, *p;
struct rte_ether_hdr *eth_hdr;
void *l3_hdr = NULL, *outer_l3_hdr = NULL; /* can be IPv4 or IPv6 */
+#ifdef RTE_LIB_GRO
void **gro_ctx;
uint16_t gro_pkts_num;
uint8_t gro_enable;
+#endif
uint16_t nb_rx;
uint16_t nb_tx;
uint16_t nb_prep;
uint32_t rx_bad_outer_l4_csum;
uint32_t rx_bad_outer_ip_csum;
struct testpmd_offload_info info;
- uint16_t nb_segments = 0;
- int ret;
uint64_t start_tsc = 0;
rx_bad_l4_csum = 0;
rx_bad_outer_l4_csum = 0;
rx_bad_outer_ip_csum = 0;
+#ifdef RTE_LIB_GRO
gro_enable = gro_ports[fs->rx_port].enable;
+#endif
txp = &ports[fs->tx_port];
tx_offloads = txp->dev_conf.txmode.offloads;
memset(&info, 0, sizeof(info));
info.tso_segsz = txp->tso_segsz;
info.tunnel_tso_segsz = txp->tunnel_tso_segsz;
+#ifdef RTE_LIB_GSO
if (gso_ports[fs->tx_port].enable)
info.gso_enable = 1;
+#endif
for (i = 0; i < nb_rx; i++) {
if (likely(i < nb_rx - 1))
}
}
+#ifdef RTE_LIB_GRO
if (unlikely(gro_enable)) {
if (gro_flush_cycles == GRO_DEFAULT_FLUSH_CYCLES) {
nb_rx = rte_gro_reassemble_burst(pkts_burst, nb_rx,
}
}
}
+#endif
+
+#ifdef RTE_LIB_GSO
+ if (gso_ports[fs->tx_port].enable != 0) {
+ uint16_t nb_segments = 0;
- if (gso_ports[fs->tx_port].enable == 0)
- tx_pkts_burst = pkts_burst;
- else {
gso_ctx = &(current_fwd_lcore()->gso_ctx);
gso_ctx->gso_size = gso_max_segment_size;
for (i = 0; i < nb_rx; i++) {
+ int ret;
+
ret = rte_gso_segment(pkts_burst[i], gso_ctx,
&gso_segments[nb_segments],
GSO_MAX_PKT_BURST - nb_segments);
tx_pkts_burst = gso_segments;
nb_rx = nb_segments;
- }
+ } else
+#endif
+ tx_pkts_burst = pkts_burst;
nb_prep = rte_eth_tx_prepare(fs->tx_port, fs->tx_queue,
tx_pkts_burst, nb_rx);