Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright 2014-2020 Mellanox Technologies, Ltd 3 : : */ 4 : : 5 : : #include <stdarg.h> 6 : : #include <stdio.h> 7 : : #include <stdint.h> 8 : : #include <unistd.h> 9 : : #include <inttypes.h> 10 : : 11 : : #include <sys/queue.h> 12 : : #include <sys/stat.h> 13 : : 14 : : #include <rte_common.h> 15 : : #include <rte_ether.h> 16 : : #include <rte_ethdev.h> 17 : : #include <rte_ip.h> 18 : : #include <rte_flow.h> 19 : : 20 : : #include "testpmd.h" 21 : : #include "5tswap.h" 22 : : 23 : : /* 24 : : * 5 tuple swap forwarding mode: Swap the source and the destination of layers 25 : : * 2,3,4. Swaps source and destination for MAC, IPv4/IPv6, UDP/TCP. 26 : : * Parses each layer and swaps it. When the next layer doesn't match it stops. 27 : : */ 28 : : static bool 29 : 0 : pkt_burst_5tuple_swap(struct fwd_stream *fs) 30 : : { 31 : : struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; 32 : : uint16_t nb_rx; 33 : : 34 : : /* 35 : : * Receive a burst of packets and forward them. 36 : : */ 37 : 0 : nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); 38 : 0 : if (unlikely(nb_rx == 0)) 39 : : return false; 40 : : 41 : 0 : do_5tswap(pkts_burst, nb_rx, fs); 42 : : 43 : 0 : common_fwd_stream_transmit(fs, pkts_burst, nb_rx); 44 : : 45 : 0 : return true; 46 : : } 47 : : 48 : : struct fwd_engine five_tuple_swap_fwd_engine = { 49 : : .fwd_mode_name = "5tswap", 50 : : .stream_init = common_fwd_stream_init, 51 : : .packet_fwd = pkt_burst_5tuple_swap, 52 : : };