1174a1631SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause 2174a1631SBruce Richardson * Copyright(c) 2010-2014 Intel Corporation 3af75078fSIntel */ 4af75078fSIntel 5af75078fSIntel #include <stdarg.h> 6af75078fSIntel #include <string.h> 7af75078fSIntel #include <stdio.h> 8af75078fSIntel #include <errno.h> 9af75078fSIntel #include <stdint.h> 10af75078fSIntel #include <unistd.h> 11af75078fSIntel #include <inttypes.h> 12af75078fSIntel 13af75078fSIntel #include <sys/queue.h> 14af75078fSIntel #include <sys/stat.h> 15af75078fSIntel 16af75078fSIntel #include <rte_common.h> 17af75078fSIntel #include <rte_byteorder.h> 18af75078fSIntel #include <rte_log.h> 19af75078fSIntel #include <rte_debug.h> 20af75078fSIntel #include <rte_cycles.h> 21af75078fSIntel #include <rte_memory.h> 22af75078fSIntel #include <rte_memcpy.h> 23af75078fSIntel #include <rte_launch.h> 24af75078fSIntel #include <rte_eal.h> 25af75078fSIntel #include <rte_per_lcore.h> 26af75078fSIntel #include <rte_lcore.h> 27af75078fSIntel #include <rte_branch_prediction.h> 28af75078fSIntel #include <rte_mempool.h> 29af75078fSIntel #include <rte_mbuf.h> 30af75078fSIntel #include <rte_interrupts.h> 31af75078fSIntel #include <rte_ether.h> 32af75078fSIntel #include <rte_ethdev.h> 33af75078fSIntel #include <rte_ip.h> 34af75078fSIntel #include <rte_string_fns.h> 35938a184aSAdrien Mazarguil #include <rte_flow.h> 36af75078fSIntel 37af75078fSIntel #include "testpmd.h" 38*1d343c19SMike Pattrick #include "macfwd.h" 39af75078fSIntel 40af75078fSIntel /* 41af75078fSIntel * Forwarding of packets in MAC mode. 42af75078fSIntel * Change the source and the destination Ethernet addressed of packets 43af75078fSIntel * before forwarding them. 44af75078fSIntel */ 4506c20561SDavid Marchand static bool pkt_burst_mac_forward(struct fwd_stream * fs)46af75078fSIntelpkt_burst_mac_forward(struct fwd_stream *fs) 47af75078fSIntel { 48af75078fSIntel struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; 49af75078fSIntel uint16_t nb_rx; 50af75078fSIntel 51af75078fSIntel /* 52af75078fSIntel * Receive a burst of packets and forward them. 53af75078fSIntel */ 54d3dae396SDavid Marchand nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); 557569b8c1SHonnappa Nagarahalli if (unlikely(nb_rx == 0)) 5606c20561SDavid Marchand return false; 577569b8c1SHonnappa Nagarahalli 58*1d343c19SMike Pattrick do_macfwd(pkts_burst, nb_rx, fs); 59bf56fce1SZhihong Wang 60655131ccSDavid Marchand common_fwd_stream_transmit(fs, pkts_burst, nb_rx); 61bc700b67SDharmik Thakkar 6206c20561SDavid Marchand return true; 63af75078fSIntel } 64af75078fSIntel 65af75078fSIntel struct fwd_engine mac_fwd_engine = { 66af75078fSIntel .fwd_mode_name = "mac", 67180ba023SDavid Marchand .stream_init = common_fwd_stream_init, 68af75078fSIntel .packet_fwd = pkt_burst_mac_forward, 69af75078fSIntel }; 70