bus/fslmc: reduce the debug log messages
[dpdk.git] / examples / ipv4_multicast / main.c
index 575e989..96a4ab6 100644 (file)
@@ -63,7 +63,6 @@
 #include <rte_debug.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
-#include <rte_ring.h>
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
@@ -77,7 +76,7 @@
 #define        MCAST_CLONE_PORTS       2
 #define        MCAST_CLONE_SEGS        2
 
-#define        PKT_MBUF_DATA_SIZE      (2048 + RTE_PKTMBUF_HEADROOM)
+#define        PKT_MBUF_DATA_SIZE      RTE_MBUF_DEFAULT_BUF_SIZE
 #define        NB_PKT_MBUF     8192
 
 #define        HDR_MBUF_DATA_SIZE      (2 * RTE_PKTMBUF_HEADROOM)
@@ -138,7 +137,7 @@ struct lcore_queue_conf {
 } __rte_cache_aligned;
 static struct lcore_queue_conf lcore_queue_conf[RTE_MAX_LCORE];
 
-static const struct rte_eth_conf port_conf = {
+static struct rte_eth_conf port_conf = {
        .rxmode = {
                .max_rx_pkt_len = JUMBO_FRAME_MAX_SIZE,
                .split_hdr_size = 0,
@@ -146,7 +145,7 @@ static const struct rte_eth_conf port_conf = {
                .hw_ip_checksum = 0, /**< IP checksum offload disabled */
                .hw_vlan_filter = 0, /**< VLAN filtering disabled */
                .jumbo_frame    = 1, /**< Jumbo Frame Support enabled */
-               .hw_strip_crc   = 0, /**< CRC stripped by hardware */
+               .hw_strip_crc   = 1, /**< CRC stripped by hardware */
        },
        .txmode = {
                .mq_mode = ETH_MQ_TX_NONE,
@@ -225,7 +224,7 @@ bitcnt(uint32_t v)
        for (n = 0; v != 0; v &= v - 1, n++)
                ;
 
-       return (n);
+       return n;
 }
 
 /**
@@ -278,13 +277,13 @@ mcast_out_pkt(struct rte_mbuf *pkt, int use_clone)
 
        /* Create new mbuf for the header. */
        if (unlikely ((hdr = rte_pktmbuf_alloc(header_pool)) == NULL))
-               return (NULL);
+               return NULL;
 
        /* If requested, then make a new clone packet. */
        if (use_clone != 0 &&
            unlikely ((pkt = rte_pktmbuf_clone(pkt, clone_pool)) == NULL)) {
                rte_pktmbuf_free(hdr);
-               return (NULL);
+               return NULL;
        }
 
        /* prepend new header */
@@ -298,13 +297,14 @@ mcast_out_pkt(struct rte_mbuf *pkt, int use_clone)
        /* copy metadata from source packet*/
        hdr->port = pkt->port;
        hdr->vlan_tci = pkt->vlan_tci;
+       hdr->vlan_tci_outer = pkt->vlan_tci_outer;
        hdr->tx_offload = pkt->tx_offload;
        hdr->hash = pkt->hash;
 
        hdr->ol_flags = pkt->ol_flags;
 
        __rte_mbuf_sanity_check(hdr, 1);
-       return (hdr);
+       return hdr;
 }
 
 /*
@@ -320,7 +320,7 @@ mcast_send_pkt(struct rte_mbuf *pkt, struct ether_addr *dest_addr,
 
        /* Construct Ethernet header. */
        ethdr = (struct ether_hdr *)rte_pktmbuf_prepend(pkt, (uint16_t)sizeof(*ethdr));
-       RTE_MBUF_ASSERT(ethdr != NULL);
+       RTE_ASSERT(ethdr != NULL);
 
        ether_addr_copy(dest_addr, &ethdr->d_addr);
        ether_addr_copy(&ports_eth_addr[port], &ethdr->s_addr);
@@ -352,7 +352,7 @@ mcast_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf)
 
        /* Remove the Ethernet header from the input packet */
        iphdr = (struct ipv4_hdr *)rte_pktmbuf_adj(m, (uint16_t)sizeof(struct ether_hdr));
-       RTE_MBUF_ASSERT(iphdr != NULL);
+       RTE_ASSERT(iphdr != NULL);
 
        dest_addr = rte_be_to_cpu_32(iphdr->dst_addr);
 
@@ -508,7 +508,7 @@ parse_portmask(const char *portmask)
        if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0'))
                return 0;
 
-       return ((uint32_t)pm);
+       return (uint32_t)pm;
 }
 
 static int
@@ -522,9 +522,9 @@ parse_nqueue(const char *q_arg)
        n = strtoul(q_arg, &end, 0);
        if (errno != 0 || end == NULL || *end != '\0' ||
                        n == 0 || n >= MAX_RX_QUEUE_PER_LCORE)
-               return (-1);
+               return -1;
 
-       return (n);
+       return n;
 }
 
 /* Parse the argument given in the command line of the application */
@@ -575,7 +575,7 @@ parse_args(int argc, char **argv)
                argv[optind-1] = prgname;
 
        ret = optind-1;
-       optind = 0; /* reset getopt lib */
+       optind = 1; /* reset getopt lib */
        return ret;
 }
 
@@ -641,7 +641,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;
                        }
@@ -725,6 +725,11 @@ main(int argc, char **argv)
 
                qconf = &lcore_queue_conf[rx_lcore_id];
 
+               /* limit the frame size to the maximum supported by NIC */
+               rte_eth_dev_info_get(portid, &dev_info);
+               port_conf.rxmode.max_rx_pkt_len = RTE_MIN(
+                   dev_info.max_rx_pktlen, port_conf.rxmode.max_rx_pkt_len);
+
                /* get the lcore_id for this port */
                while (rte_lcore_is_enabled(rx_lcore_id) == 0 ||
                       qconf->n_rx_queue == (unsigned)rx_queue_per_lcore) {
@@ -777,7 +782,6 @@ main(int argc, char **argv)
                        printf("txq=%u,%hu ", lcore_id, queueid);
                        fflush(stdout);
 
-                       rte_eth_dev_info_get(portid, &dev_info);
                        txconf = &dev_info.default_txconf;
                        txconf->txq_flags = 0;
                        ret = rte_eth_tx_queue_setup(portid, queueid, nb_txd,