examples/performance-thread: fix destination port
[dpdk.git] / examples / performance-thread / l3fwd-thread / main.c
index 7bcca37..4d36093 100644 (file)
@@ -655,7 +655,8 @@ send_single_packet(struct rte_mbuf *m, uint8_t port)
        return 0;
 }
 
-#if (APP_LOOKUP_METHOD == APP_LOOKUP_LPM)
+#if ((APP_LOOKUP_METHOD == APP_LOOKUP_LPM) && \
+       (ENABLE_MULTI_BUFFER_OPTIMIZE == 1))
 static inline __attribute__((always_inline)) void
 send_packetsx4(uint8_t port,
        struct rte_mbuf *m[], uint32_t num)
@@ -995,7 +996,7 @@ simple_ipv4_fwd_8pkts(struct rte_mbuf *m[8], uint8_t portid)
        const void *key_array[8] = {&key[0], &key[1], &key[2], &key[3],
                        &key[4], &key[5], &key[6], &key[7]};
 
-       rte_hash_lookup_multi(RTE_PER_LCORE(lcore_conf)->ipv4_lookup_struct,
+       rte_hash_lookup_bulk(RTE_PER_LCORE(lcore_conf)->ipv4_lookup_struct,
                        &key_array[0], 8, ret);
        dst_port[0] = (uint8_t) ((ret[0] < 0) ? portid : ipv4_l3fwd_out_if[ret[0]]);
        dst_port[1] = (uint8_t) ((ret[1] < 0) ? portid : ipv4_l3fwd_out_if[ret[1]]);
@@ -1149,7 +1150,7 @@ simple_ipv6_fwd_8pkts(struct rte_mbuf *m[8], uint8_t portid)
        const void *key_array[8] = {&key[0], &key[1], &key[2], &key[3],
                        &key[4], &key[5], &key[6], &key[7]};
 
-       rte_hash_lookup_multi(RTE_PER_LCORE(lcore_conf)->ipv6_lookup_struct,
+       rte_hash_lookup_bulk(RTE_PER_LCORE(lcore_conf)->ipv6_lookup_struct,
                        &key_array[0], 4, ret);
        dst_port[0] = (uint8_t) ((ret[0] < 0) ? portid : ipv6_l3fwd_out_if[ret[0]]);
        dst_port[1] = (uint8_t) ((ret[1] < 0) ? portid : ipv6_l3fwd_out_if[ret[1]]);
@@ -1342,24 +1343,23 @@ get_dst_port(struct rte_mbuf *pkt, uint32_t dst_ipv4, uint8_t portid)
        struct ether_hdr *eth_hdr;
 
        if (RTE_ETH_IS_IPV4_HDR(pkt->packet_type)) {
-               if (rte_lpm_lookup(RTE_PER_LCORE(lcore_conf)->ipv4_lookup_struct,
-                               dst_ipv4, &next_hop_ipv4) != 0) {
-                       next_hop_ipv4 = portid;
-                       return next_hop_ipv4;
-               }
+               return (uint16_t) ((rte_lpm_lookup(
+                               RTE_PER_LCORE(lcore_conf)->ipv4_lookup_struct, dst_ipv4,
+                               &next_hop_ipv4) == 0) ? next_hop_ipv4 : portid);
+
        } else if (RTE_ETH_IS_IPV6_HDR(pkt->packet_type)) {
+
                eth_hdr = rte_pktmbuf_mtod(pkt, struct ether_hdr *);
                ipv6_hdr = (struct ipv6_hdr *)(eth_hdr + 1);
-               if (rte_lpm6_lookup(RTE_PER_LCORE(lcore_conf)->ipv6_lookup_struct,
-                               ipv6_hdr->dst_addr, &next_hop_ipv6) != 0) {
-                       next_hop_ipv6 = portid;
-                       return next_hop_ipv6;
-               }
-       } else {
-               next_hop_ipv4 = portid;
-               return next_hop_ipv4;
+
+               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);
+
        }
 
+       return portid;
 }
 
 static inline void
@@ -1657,9 +1657,9 @@ port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, __m128i dp1, __m128i dp2)
 
        /* if dest port value has changed. */
        if (v != GRPMSK) {
-               lp = pnum->u16 + gptbl[v].idx;
-               lp[0] = 1;
                pnum->u64 = gptbl[v].pnum;
+               pnum->u16[FWDSTEP] = 1;
+               lp = pnum->u16 + gptbl[v].idx;
        }
 
        return lp;
@@ -1838,12 +1838,12 @@ process_burst(struct rte_mbuf *pkts_burst[MAX_PKT_BURST], int nb_rx,
        for (j = 0; j < (nb_rx - PREFETCH_OFFSET); j++) {
                rte_prefetch0(rte_pktmbuf_mtod(pkts_burst[
                                j + PREFETCH_OFFSET], void *));
-               l3fwd_simple_forward(pkts_burst[j], portid, qconf);
+               l3fwd_simple_forward(pkts_burst[j], portid);
        }
 
        /* Forward remaining prefetched packets */
        for (; j < nb_rx; j++)
-               l3fwd_simple_forward(pkts_burst[j], portid, qconf);
+               l3fwd_simple_forward(pkts_burst[j], portid);
 
 #endif /* ENABLE_MULTI_BUFFER_OPTIMIZE */
 
@@ -3407,7 +3407,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
                                continue;
                        }
                        /* clear all_ports_up flag if any link down */
-                       if (link.link_status == 0) {
+                       if (link.link_status == ETH_LINK_DOWN) {
                                all_ports_up = 0;
                                break;
                        }
@@ -3481,8 +3481,6 @@ main(int argc, char **argv)
                rte_exit(EXIT_FAILURE, "init_rx_rings failed\n");
 
        nb_ports = rte_eth_dev_count();
-       if (nb_ports > RTE_MAX_ETHPORTS)
-               nb_ports = RTE_MAX_ETHPORTS;
 
        if (check_port_config(nb_ports) < 0)
                rte_exit(EXIT_FAILURE, "check_port_config failed\n");