ethdev: increase port id range
[dpdk.git] / examples / link_status_interrupt / main.c
index 04dc3e4..c83a62f 100644 (file)
@@ -37,7 +37,6 @@
 #include <stdint.h>
 #include <inttypes.h>
 #include <sys/types.h>
-#include <string.h>
 #include <sys/queue.h>
 #include <netinet/in.h>
 #include <setjmp.h>
@@ -53,7 +52,6 @@
 #include <rte_memcpy.h>
 #include <rte_memzone.h>
 #include <rte_eal.h>
-#include <rte_per_lcore.h>
 #include <rte_launch.h>
 #include <rte_atomic.h>
 #include <rte_cycles.h>
@@ -67,7 +65,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>
 
@@ -117,7 +114,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    = 0, /**< Jumbo Frame Support disabled */
-               .hw_strip_crc   = 0, /**< CRC stripped by hardware */
+               .hw_strip_crc   = 1, /**< CRC stripped by hardware */
        },
        .txmode = {
                .mq_mode = ETH_MQ_TX_NONE,
@@ -148,7 +145,7 @@ print_stats(void)
 {
        struct rte_eth_link link;
        uint64_t total_packets_dropped, total_packets_tx, total_packets_rx;
-       unsigned portid;
+       uint16_t portid;
 
        total_packets_dropped = 0;
        total_packets_tx = 0;
@@ -168,7 +165,7 @@ print_stats(void)
                        continue;
 
                memset(&link, 0, sizeof(link));
-               rte_eth_link_get_nowait((uint8_t)portid, &link);
+               rte_eth_link_get_nowait(portid, &link);
                printf("\nStatistics for port %u ------------------------------"
                           "\nLink status: %25s"
                           "\nLink speed: %26u"
@@ -452,7 +449,7 @@ lsi_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;
 }
 
@@ -470,14 +467,16 @@ lsi_parse_args(int argc, char **argv)
  *  Pointer to(address of) the parameters.
  *
  * @return
- *  void.
+ *  int.
  */
-static void
-lsi_event_callback(uint8_t port_id, enum rte_eth_event_type type, void *param)
+static int
+lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param,
+                   void *ret_param)
 {
        struct rte_eth_link link;
 
        RTE_SET_USED(param);
+       RTE_SET_USED(ret_param);
 
        printf("\n\nIn registered callback...\n");
        printf("Event type: %s\n", type == RTE_ETH_EVENT_INTR_LSC ? "LSC interrupt" : "unknown event");
@@ -489,6 +488,8 @@ lsi_event_callback(uint8_t port_id, enum rte_eth_event_type type, void *param)
                                ("full-duplex") : ("half-duplex"));
        } else
                printf("Port %d Link Down\n\n", port_id);
+
+       return 0;
 }
 
 /* Check the link status of all ports in up to 9s, and print them finally */
@@ -497,7 +498,8 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 {
 #define CHECK_INTERVAL 100 /* 100ms */
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
-       uint8_t portid, count, all_ports_up, print_flag = 0;
+       uint8_t count, all_ports_up, print_flag = 0;
+       uint16_t portid;
        struct rte_eth_link link;
 
        printf("\nChecking link status");
@@ -647,6 +649,13 @@ main(int argc, char **argv)
                        rte_exit(EXIT_FAILURE, "Cannot configure device: err=%d, port=%u\n",
                                  ret, (unsigned) portid);
 
+               ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd,
+                                                      &nb_txd);
+               if (ret < 0)
+                       rte_exit(EXIT_FAILURE,
+                                "rte_eth_dev_adjust_nb_rx_tx_desc: err=%d, port=%u\n",
+                                ret, (unsigned) portid);
+
                /* register lsi interrupt callback, need to be after
                 * rte_eth_dev_configure(). if (intr_conf.lsc == 0), no
                 * lsc interrupt will be present, and below callback to