examples/performance-thread: remove non-SSE4 fallbacks
[dpdk.git] / examples / performance-thread / l3fwd-thread / main.c
index f6154ac..535c347 100644 (file)
@@ -73,6 +73,7 @@
 #include <rte_tcp.h>
 #include <rte_udp.h>
 #include <rte_string_fns.h>
+#include <rte_pause.h>
 
 #include <cmdline_parse.h>
 #include <cmdline_parse_etheraddr.h>
 #define APP_LOOKUP_METHOD             APP_LOOKUP_LPM
 #endif
 
+#ifndef __GLIBC__ /* sched_getcpu() is glibc specific */
+#define sched_getcpu() rte_lcore_id()
+#endif
+
 static int
 check_ptype(int portid)
 {
@@ -153,11 +158,7 @@ cb_parse_ptype(__rte_unused uint8_t port, __rte_unused uint16_t queue,
  *  When set to one, optimized forwarding path is enabled.
  *  Note that LPM optimisation path uses SSE4.1 instructions.
  */
-#if ((APP_LOOKUP_METHOD == APP_LOOKUP_LPM) && !defined(__SSE4_1__))
-#define ENABLE_MULTI_BUFFER_OPTIMIZE   0
-#else
 #define ENABLE_MULTI_BUFFER_OPTIMIZE   1
-#endif
 
 #if (APP_LOOKUP_METHOD == APP_LOOKUP_EXACT_MATCH)
 #include <rte_hash.h>
@@ -358,13 +359,8 @@ static struct rte_mempool *pktmbuf_pool[NB_SOCKETS];
 
 #if (APP_LOOKUP_METHOD == APP_LOOKUP_EXACT_MATCH)
 
-#ifdef RTE_MACHINE_CPUFLAG_SSE4_2
 #include <rte_hash_crc.h>
 #define DEFAULT_HASH_FUNC       rte_hash_crc
-#else
-#include <rte_jhash.h>
-#define DEFAULT_HASH_FUNC       rte_jhash
-#endif
 
 struct ipv4_5tuple {
        uint32_t ip_dst;
@@ -481,17 +477,10 @@ ipv4_hash_crc(const void *data, __rte_unused uint32_t data_len,
        t = k->proto;
        p = (const uint32_t *)&k->port_src;
 
-#ifdef RTE_MACHINE_CPUFLAG_SSE4_2
        init_val = rte_hash_crc_4byte(t, init_val);
        init_val = rte_hash_crc_4byte(k->ip_src, init_val);
        init_val = rte_hash_crc_4byte(k->ip_dst, init_val);
        init_val = rte_hash_crc_4byte(*p, init_val);
-#else /* RTE_MACHINE_CPUFLAG_SSE4_2 */
-       init_val = rte_jhash_1word(t, init_val);
-       init_val = rte_jhash_1word(k->ip_src, init_val);
-       init_val = rte_jhash_1word(k->ip_dst, init_val);
-       init_val = rte_jhash_1word(*p, init_val);
-#endif /* RTE_MACHINE_CPUFLAG_SSE4_2 */
        return init_val;
 }
 
@@ -502,16 +491,13 @@ ipv6_hash_crc(const void *data, __rte_unused uint32_t data_len,
        const union ipv6_5tuple_host *k;
        uint32_t t;
        const uint32_t *p;
-#ifdef RTE_MACHINE_CPUFLAG_SSE4_2
        const uint32_t *ip_src0, *ip_src1, *ip_src2, *ip_src3;
        const uint32_t *ip_dst0, *ip_dst1, *ip_dst2, *ip_dst3;
-#endif /* RTE_MACHINE_CPUFLAG_SSE4_2 */
 
        k = data;
        t = k->proto;
        p = (const uint32_t *)&k->port_src;
 
-#ifdef RTE_MACHINE_CPUFLAG_SSE4_2
        ip_src0 = (const uint32_t *) k->ip_src;
        ip_src1 = (const uint32_t *)(k->ip_src + 4);
        ip_src2 = (const uint32_t *)(k->ip_src + 8);
@@ -530,12 +516,6 @@ ipv6_hash_crc(const void *data, __rte_unused uint32_t data_len,
        init_val = rte_hash_crc_4byte(*ip_dst2, init_val);
        init_val = rte_hash_crc_4byte(*ip_dst3, init_val);
        init_val = rte_hash_crc_4byte(*p, init_val);
-#else /* RTE_MACHINE_CPUFLAG_SSE4_2 */
-       init_val = rte_jhash_1word(t, init_val);
-       init_val = rte_jhash(k->ip_src, sizeof(uint8_t) * IPV6_ADDR_LEN, init_val);
-       init_val = rte_jhash(k->ip_dst, sizeof(uint8_t) * IPV6_ADDR_LEN, init_val);
-       init_val = rte_jhash_1word(*p, init_val);
-#endif /* RTE_MACHINE_CPUFLAG_SSE4_2 */
        return init_val;
 }
 
@@ -716,7 +696,7 @@ send_single_packet(struct rte_mbuf *m, uint8_t port)
 
 #if ((APP_LOOKUP_METHOD == APP_LOOKUP_LPM) && \
        (ENABLE_MULTI_BUFFER_OPTIMIZE == 1))
-static inline __attribute__((always_inline)) void
+static __rte_always_inline void
 send_packetsx4(uint8_t port,
        struct rte_mbuf *m[], uint32_t num)
 {
@@ -757,12 +737,15 @@ send_packetsx4(uint8_t port,
        case 0:
                qconf->tx_mbufs[port].m_table[len + j] = m[j];
                j++;
+               /* fall-through */
        case 3:
                qconf->tx_mbufs[port].m_table[len + j] = m[j];
                j++;
+               /* fall-through */
        case 2:
                qconf->tx_mbufs[port].m_table[len + j] = m[j];
                j++;
+               /* fall-through */
        case 1:
                qconf->tx_mbufs[port].m_table[len + j] = m[j];
                j++;
@@ -784,12 +767,15 @@ send_packetsx4(uint8_t port,
                case 0:
                        qconf->tx_mbufs[port].m_table[j] = m[n + j];
                        j++;
+                       /* fall-through */
                case 3:
                        qconf->tx_mbufs[port].m_table[j] = m[n + j];
                        j++;
+                       /* fall-through */
                case 2:
                        qconf->tx_mbufs[port].m_table[j] = m[n + j];
                        j++;
+                       /* fall-through */
                case 1:
                        qconf->tx_mbufs[port].m_table[j] = m[n + j];
                        j++;
@@ -1277,7 +1263,7 @@ simple_ipv6_fwd_8pkts(struct rte_mbuf *m[8], uint8_t portid)
 }
 #endif /* APP_LOOKUP_METHOD */
 
-static inline __attribute__((always_inline)) void
+static __rte_always_inline void
 l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid)
 {
        struct ether_hdr *eth_hdr;
@@ -1365,7 +1351,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid)
  * If we encounter invalid IPV4 packet, then set destination port for it
  * to BAD_PORT value.
  */
-static inline __attribute__((always_inline)) void
+static __rte_always_inline void
 rfc1812_process(struct ipv4_hdr *ipv4_hdr, uint16_t *dp, uint32_t ptype)
 {
        uint8_t ihl;
@@ -1393,7 +1379,7 @@ rfc1812_process(struct ipv4_hdr *ipv4_hdr, uint16_t *dp, uint32_t ptype)
 #if ((APP_LOOKUP_METHOD == APP_LOOKUP_LPM) && \
        (ENABLE_MULTI_BUFFER_OPTIMIZE == 1))
 
-static inline __attribute__((always_inline)) uint16_t
+static __rte_always_inline uint16_t
 get_dst_port(struct rte_mbuf *pkt, uint32_t dst_ipv4, uint8_t portid)
 {
        uint32_t next_hop;
@@ -1594,7 +1580,7 @@ processx4_step3(struct rte_mbuf *pkt[FWDSTEP], uint16_t dst_port[FWDSTEP])
  * Suppose we have array of destionation ports:
  * dst_port[] = {a, b, c, d,, e, ... }
  * dp1 should contain: <a, b, c, d>, dp2: <b, c, d, e>.
- * We doing 4 comparisions at once and the result is 4 bit mask.
+ * We doing 4 comparisons at once and the result is 4 bit mask.
  * This mask is used as an index into prebuild array of pnum values.
  */
 static inline uint16_t *
@@ -1856,10 +1842,12 @@ process_burst(struct rte_mbuf *pkts_burst[MAX_PKT_BURST], int nb_rx,
                process_packet(pkts_burst[j], dst_port + j, portid);
                GROUP_PORT_STEP(dlp, dst_port, lp, pnum, j);
                j++;
+               /* fall-through */
        case 2:
                process_packet(pkts_burst[j], dst_port + j, portid);
                GROUP_PORT_STEP(dlp, dst_port, lp, pnum, j);
                j++;
+               /* fall-through */
        case 1:
                process_packet(pkts_burst[j], dst_port + j, portid);
                GROUP_PORT_STEP(dlp, dst_port, lp, pnum, j);