fix typos using codespell utility
[dpdk.git] / examples / performance-thread / l3fwd-thread / main.c
index 6845e28..8237ac6 100644 (file)
 #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)
 {
@@ -341,7 +345,7 @@ static struct rte_eth_conf port_conf = {
                .hw_ip_checksum = 1, /**< IP checksum offload enabled */
                .hw_vlan_filter = 0, /**< VLAN filtering disabled */
                .jumbo_frame    = 0, /**< Jumbo Frame Support disabled */
-               .hw_strip_crc   = 0, /**< CRC stripped by hardware */
+               .hw_strip_crc   = 1, /**< CRC stripped by hardware */
        },
        .rx_adv_conf = {
                .rss_conf = {
@@ -716,7 +720,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 +761,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 +791,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++;
@@ -909,7 +919,7 @@ static inline uint8_t
 get_ipv6_dst_port(void *ipv6_hdr,  uint8_t portid,
                lookup6_struct_t *ipv6_l3fwd_lookup_struct)
 {
-       uint8_t next_hop;
+       uint32_t next_hop;
 
        return (uint8_t) ((rte_lpm6_lookup(ipv6_l3fwd_lookup_struct,
                        ((struct ipv6_hdr *)ipv6_hdr)->dst_addr, &next_hop) == 0) ?
@@ -1277,7 +1287,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 +1375,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,18 +1403,17 @@ 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_ipv4;
-       uint8_t next_hop_ipv6;
+       uint32_t next_hop;
        struct ipv6_hdr *ipv6_hdr;
        struct ether_hdr *eth_hdr;
 
        if (RTE_ETH_IS_IPV4_HDR(pkt->packet_type)) {
                return (uint16_t) ((rte_lpm_lookup(
                                RTE_PER_LCORE(lcore_conf)->ipv4_lookup_struct, dst_ipv4,
-                               &next_hop_ipv4) == 0) ? next_hop_ipv4 : portid);
+                               &next_hop) == 0) ? next_hop : portid);
 
        } else if (RTE_ETH_IS_IPV6_HDR(pkt->packet_type)) {
 
@@ -1413,8 +1422,8 @@ get_dst_port(struct rte_mbuf *pkt, uint32_t dst_ipv4, uint8_t portid)
 
                return (uint16_t) ((rte_lpm6_lookup(
                                RTE_PER_LCORE(lcore_conf)->ipv6_lookup_struct,
-                               ipv6_hdr->dst_addr, &next_hop_ipv6) == 0) ? next_hop_ipv6 :
-                                               portid);
+                               ipv6_hdr->dst_addr, &next_hop) == 0) ?
+                               next_hop : portid);
 
        }
 
@@ -1595,7 +1604,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 *
@@ -1857,10 +1866,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);
@@ -2078,7 +2089,7 @@ lthread_tx_per_ring(void *dummy)
                 */
                SET_CPU_BUSY(tx_conf, CPU_POLL);
                nb_rx = rte_ring_sc_dequeue_burst(ring, (void **)pkts_burst,
-                               MAX_PKT_BURST);
+                               MAX_PKT_BURST, NULL);
                SET_CPU_IDLE(tx_conf, CPU_POLL);
 
                if (nb_rx > 0) {
@@ -2214,7 +2225,7 @@ lthread_rx(void *dummy)
                                ret = rte_ring_sp_enqueue_burst(
                                                rx_conf->ring[worker_id],
                                                (void **) pkts_burst,
-                                               nb_rx);
+                                               nb_rx, NULL);
 
                                new_len = old_len + ret;
 
@@ -2382,7 +2393,7 @@ pthread_tx(void *dummy)
                 */
                SET_CPU_BUSY(tx_conf, CPU_POLL);
                nb_rx = rte_ring_sc_dequeue_burst(tx_conf->ring,
-                               (void **)pkts_burst, MAX_PKT_BURST);
+                               (void **)pkts_burst, MAX_PKT_BURST, NULL);
                SET_CPU_IDLE(tx_conf, CPU_POLL);
 
                if (unlikely(nb_rx == 0)) {
@@ -2454,7 +2465,7 @@ pthread_rx(void *dummy)
                        SET_CPU_BUSY(rx_conf, CPU_PROCESS);
                        worker_id = (worker_id + 1) % rx_conf->n_ring;
                        n = rte_ring_sp_enqueue_burst(rx_conf->ring[worker_id],
-                                       (void **)pkts_burst, nb_rx);
+                                       (void **)pkts_burst, nb_rx, NULL);
 
                        if (unlikely(n != nb_rx)) {
                                uint32_t k;