@@ -111,6 +111,7 @@ Anna Lukin <annal@silicom.co.il>
Anoob Joseph <anoobj@marvell.com> <anoob.joseph@caviumnetworks.com>
Antara Ganesh Kolar <antara.ganesh.kolar@intel.com>
Anthony Fee <anthonyx.fee@intel.com>
+Anthony Harivel <aharivel@redhat.com>
Antonio Fischetti <antonio.fischetti@intel.com>
Anupam Kapoor <anupam.kapoor@gmail.com>
Apeksha Gupta <apeksha.gupta@nxp.com>
@@ -81,7 +81,7 @@ swap_udp(struct rte_udp_hdr *udp_hdr)
* 2,3,4. Swaps source and destination for MAC, IPv4/IPv6, UDP/TCP.
* Parses each layer and swaps it. When the next layer doesn't match it stops.
*/
-static bool
+static size_t
pkt_burst_5tuple_swap(struct fwd_stream *fs)
{
struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
@@ -107,7 +107,7 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs)
*/
nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);
if (unlikely(nb_rx == 0))
- return false;
+ return 0;
txp = &ports[fs->tx_port];
ol_flags = ol_flags_init(txp->dev_conf.txmode.offloads);
@@ -154,7 +154,7 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs)
}
common_fwd_stream_transmit(fs, pkts_burst, nb_rx);
- return true;
+ return nb_rx;
}
struct fwd_engine five_tuple_swap_fwd_engine = {
@@ -828,7 +828,7 @@ pkts_ip_csum_recalc(struct rte_mbuf **pkts_burst, const uint16_t nb_pkts, uint64
* IP, UDP, TCP and SCTP flags always concern the inner layer. The
* OUTER_IP is only useful for tunnel packets.
*/
-static bool
+static size_t
pkt_burst_checksum_forward(struct fwd_stream *fs)
{
struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
@@ -860,7 +860,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
/* receive a burst of packet */
nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);
if (unlikely(nb_rx == 0))
- return false;
+ return 0;
rx_bad_ip_csum = 0;
rx_bad_l4_csum = 0;
@@ -1174,7 +1174,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
fs->rx_bad_outer_l4_csum += rx_bad_outer_l4_csum;
fs->rx_bad_outer_ip_csum += rx_bad_outer_ip_csum;
- return true;
+ return nb_rx;
}
struct fwd_engine csum_fwd_engine = {
@@ -58,7 +58,7 @@ RTE_DEFINE_PER_LCORE(int, _next_flow);
* terminate receive traffic. Received traffic is simply discarded, but we
* still do so in order to maintain traffic statistics.
*/
-static bool
+static size_t
pkt_burst_flow_gen(struct fwd_stream *fs)
{
unsigned pkt_size = tx_pkt_length - 4; /* Adjust FCS */
@@ -168,7 +168,7 @@ pkt_burst_flow_gen(struct fwd_stream *fs)
RTE_PER_LCORE(_next_flow) = next_flow;
- return true;
+ return nb_pkt;
}
static int
@@ -269,7 +269,7 @@ ipv4_hdr_cksum(struct rte_ipv4_hdr *ip_h)
* Receive a burst of packets, lookup for ICMP echo requests, and, if any,
* send back ICMP echo replies.
*/
-static bool
+static size_t
reply_to_icmp_echo_rqsts(struct fwd_stream *fs)
{
struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
@@ -296,7 +296,7 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs)
*/
nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);
if (unlikely(nb_rx == 0))
- return false;
+ return 0;
nb_replies = 0;
for (i = 0; i < nb_rx; i++) {
@@ -477,7 +477,7 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs)
if (nb_replies > 0)
common_fwd_stream_transmit(fs, pkts_burst, nb_replies);
- return true;
+ return nb_rx;
}
struct fwd_engine icmp_echo_engine = {
@@ -89,7 +89,7 @@ port_ieee1588_tx_timestamp_check(portid_t pi)
(wait_us == 1) ? "" : "s");
}
-static bool
+static size_t
ieee1588_packet_fwd(struct fwd_stream *fs)
{
struct rte_mbuf *mb;
@@ -103,7 +103,7 @@ ieee1588_packet_fwd(struct fwd_stream *fs)
* Receive 1 packet at a time.
*/
if (common_fwd_stream_receive(fs, &mb, 1) == 0)
- return false;
+ return 0;
/*
* Check that the received packet is a PTP packet that was detected
@@ -124,14 +124,14 @@ ieee1588_packet_fwd(struct fwd_stream *fs)
(unsigned) mb->pkt_len);
}
rte_pktmbuf_free(mb);
- return false;
+ return 0;
}
if (eth_type != RTE_ETHER_TYPE_1588) {
printf("Port %u Received NON PTP packet incorrectly"
" detected by hardware\n",
fs->rx_port);
rte_pktmbuf_free(mb);
- return false;
+ return 0;
}
/*
@@ -145,14 +145,14 @@ ieee1588_packet_fwd(struct fwd_stream *fs)
" protocol version 0x%x (should be 0x02)\n",
fs->rx_port, ptp_hdr->version);
rte_pktmbuf_free(mb);
- return false;
+ return 0;
}
if (ptp_hdr->msg_id != PTP_SYNC_MESSAGE) {
printf("Port %u Received PTP V2 Ethernet frame with unexpected"
" message ID 0x%x (expected 0x0 - PTP_SYNC_MESSAGE)\n",
fs->rx_port, ptp_hdr->msg_id);
rte_pktmbuf_free(mb);
- return false;
+ return 0;
}
printf("Port %u IEEE1588 PTP V2 SYNC Message filtered by hardware\n",
fs->rx_port);
@@ -166,7 +166,7 @@ ieee1588_packet_fwd(struct fwd_stream *fs)
" by hardware\n",
fs->rx_port);
rte_pktmbuf_free(mb);
- return false;
+ return 0;
}
/* For i40e we need the timesync register index. It is ignored for the
@@ -184,14 +184,14 @@ ieee1588_packet_fwd(struct fwd_stream *fs)
mb->ol_flags |= RTE_MBUF_F_TX_IEEE1588_TMST;
if (common_fwd_stream_transmit(fs, &mb, 1) == 0) {
printf("Port %u sent PTP packet dropped\n", fs->tx_port);
- return false;
+ return 0;
}
/*
* Check the TX timestamp.
*/
port_ieee1588_tx_timestamp_check(fs->tx_port);
- return true;
+ return 1;
}
static int
@@ -41,7 +41,7 @@
* This is the fastest possible forwarding operation, as it does not access
* to packets data.
*/
-static bool
+static size_t
pkt_burst_io_forward(struct fwd_stream *fs)
{
struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
@@ -52,11 +52,11 @@ pkt_burst_io_forward(struct fwd_stream *fs)
*/
nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);
if (unlikely(nb_rx == 0))
- return false;
+ return 0;
common_fwd_stream_transmit(fs, pkts_burst, nb_rx);
- return true;
+ return nb_rx;
}
struct fwd_engine io_fwd_engine = {
@@ -41,7 +41,7 @@
* Change the source and the destination Ethernet addressed of packets
* before forwarding them.
*/
-static bool
+static size_t
pkt_burst_mac_forward(struct fwd_stream *fs)
{
struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
@@ -58,7 +58,7 @@ pkt_burst_mac_forward(struct fwd_stream *fs)
*/
nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);
if (unlikely(nb_rx == 0))
- return false;
+ return 0;
txp = &ports[fs->tx_port];
tx_offloads = txp->dev_conf.txmode.offloads;
@@ -88,7 +88,7 @@ pkt_burst_mac_forward(struct fwd_stream *fs)
common_fwd_stream_transmit(fs, pkts_burst, nb_rx);
- return true;
+ return nb_rx;
}
struct fwd_engine mac_fwd_engine = {
@@ -47,7 +47,7 @@
* MAC swap forwarding mode: Swap the source and the destination Ethernet
* addresses of packets before forwarding them.
*/
-static bool
+static size_t
pkt_burst_mac_swap(struct fwd_stream *fs)
{
struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
@@ -58,12 +58,12 @@ pkt_burst_mac_swap(struct fwd_stream *fs)
*/
nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);
if (unlikely(nb_rx == 0))
- return false;
+ return 0;
do_macswap(pkts_burst, nb_rx, &ports[fs->tx_port]);
common_fwd_stream_transmit(fs, pkts_burst, nb_rx);
- return true;
+ return nb_rx;
}
struct fwd_engine mac_swap_engine = {
@@ -110,7 +110,7 @@ sim_memory_lookups(struct noisy_config *ncf, uint16_t nb_pkts)
* out of the FIFO
* 4. Cases 2 and 3 combined
*/
-static bool
+static size_t
pkt_burst_noisy_vnf(struct fwd_stream *fs)
{
const uint64_t freq_khz = rte_get_timer_hz() / 1000;
@@ -169,7 +169,7 @@ pkt_burst_noisy_vnf(struct fwd_stream *fs)
ncf->prev_time = rte_get_timer_cycles();
}
end:
- return nb_rx > 0 || nb_tx > 0;
+ return (nb_rx > nb_tx) ? nb_rx : nb_tx;
}
#define NOISY_STRSIZE 256
@@ -41,7 +41,7 @@
/*
* Received a burst of packets.
*/
-static bool
+static size_t
pkt_burst_receive(struct fwd_stream *fs)
{
struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
@@ -52,11 +52,11 @@ pkt_burst_receive(struct fwd_stream *fs)
*/
nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);
if (unlikely(nb_rx == 0))
- return false;
+ return 0;
rte_pktmbuf_free_bulk(pkts_burst, nb_rx);
- return true;
+ return nb_rx;
}
static void
@@ -89,7 +89,7 @@ forward_shared_rxq(struct fwd_stream *fs, uint16_t nb_rx,
&pkts_burst[nb_rx - nb_sub_burst]);
}
-static bool
+static size_t
shared_rxq_fwd(struct fwd_stream *fs)
{
struct rte_mbuf *pkts_burst[nb_pkt_per_burst];
@@ -97,10 +97,10 @@ shared_rxq_fwd(struct fwd_stream *fs)
nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);
if (unlikely(nb_rx == 0))
- return false;
+ return 0;
forward_shared_rxq(fs, nb_rx, pkts_burst);
- return true;
+ return nb_rx;
}
static void
@@ -2274,14 +2274,14 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd)
for (sm_id = 0; sm_id < nb_fs; sm_id++) {
struct fwd_stream *fs = fsm[sm_id];
uint64_t start_fs_tsc = 0;
- bool busy;
+ size_t pkts;
if (fs->disabled)
continue;
if (record_core_cycles)
start_fs_tsc = rte_rdtsc();
- busy = (*pkt_fwd)(fs);
- if (record_core_cycles && busy)
+ pkts = (*pkt_fwd)(fs);
+ if (record_core_cycles && pkts > 0)
fs->busy_cycles += rte_rdtsc() - start_fs_tsc;
}
#ifdef RTE_LIB_BITRATESTATS
@@ -382,7 +382,7 @@ struct fwd_lcore {
typedef int (*port_fwd_begin_t)(portid_t pi);
typedef void (*port_fwd_end_t)(portid_t pi);
typedef void (*stream_init_t)(struct fwd_stream *fs);
-typedef bool (*packet_fwd_t)(struct fwd_stream *fs);
+typedef size_t (*packet_fwd_t)(struct fwd_stream *fs);
struct fwd_engine {
const char *fwd_mode_name; /**< Forwarding mode name. */
@@ -323,7 +323,7 @@ pkt_burst_prepare(struct rte_mbuf *pkt, struct rte_mempool *mbp,
/*
* Transmit a burst of multi-segments packets.
*/
-static bool
+static size_t
pkt_burst_transmit(struct fwd_stream *fs)
{
struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
@@ -388,7 +388,7 @@ pkt_burst_transmit(struct fwd_stream *fs)
}
if (nb_pkt == 0)
- return false;
+ return 0;
nb_tx = common_fwd_stream_transmit(fs, pkts_burst, nb_pkt);
@@ -404,7 +404,7 @@ pkt_burst_transmit(struct fwd_stream *fs)
(unsigned) (nb_pkt - nb_tx));
}
- return true;
+ return nb_tx;
}
static int