net/ixgbe: support committing TM hierarchy
[dpdk.git] / examples / qos_meter / main.c
index b968b00..b0909f6 100644 (file)
@@ -89,7 +89,7 @@ static struct rte_eth_conf port_conf = {
                .hw_ip_checksum = 1,
                .hw_vlan_filter = 0,
                .jumbo_frame    = 0,
-               .hw_strip_crc   = 0,
+               .hw_strip_crc   = 1,
        },
        .rx_adv_conf = {
                .rss_conf = {
@@ -133,14 +133,20 @@ struct rte_meter_trtcm_params app_trtcm_params[] = {
 
 FLOW_METER app_flows[APP_FLOWS_MAX];
 
-static void
+static int
 app_configure_flow_table(void)
 {
        uint32_t i, j;
+       int ret;
 
-       for (i = 0, j = 0; i < APP_FLOWS_MAX; i ++, j = (j + 1) % RTE_DIM(PARAMS)){
-               FUNC_CONFIG(&app_flows[i], &PARAMS[j]);
+       for (i = 0, j = 0; i < APP_FLOWS_MAX;
+                       i ++, j = (j + 1) % RTE_DIM(PARAMS)) {
+               ret = FUNC_CONFIG(&app_flows[i], &PARAMS[j]);
+               if (ret)
+                       return ret;
        }
+
+       return 0;
 }
 
 static inline void
@@ -294,7 +300,7 @@ parse_args(int argc, char **argv)
 
        argv[optind-1] = prgname;
 
-       optind = 0; /* reset getopt lib */
+       optind = 1; /* reset getopt lib */
        return 0;
 }
 
@@ -302,6 +308,8 @@ int
 main(int argc, char **argv)
 {
        uint32_t lcore_id;
+       uint16_t nb_rxd = NIC_RX_QUEUE_DESC;
+       uint16_t nb_txd = NIC_TX_QUEUE_DESC;
        int ret;
 
        /* EAL init */
@@ -331,13 +339,18 @@ main(int argc, char **argv)
        if (ret < 0)
                rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", port_rx, ret);
 
-       ret = rte_eth_rx_queue_setup(port_rx, NIC_RX_QUEUE, NIC_RX_QUEUE_DESC,
+       ret = rte_eth_dev_adjust_nb_rx_tx_desc(port_rx, &nb_rxd, &nb_txd);
+       if (ret < 0)
+               rte_exit(EXIT_FAILURE, "Port %d adjust number of descriptors error (%d)\n",
+                               port_rx, ret);
+
+       ret = rte_eth_rx_queue_setup(port_rx, NIC_RX_QUEUE, nb_rxd,
                                rte_eth_dev_socket_id(port_rx),
                                NULL, pool);
        if (ret < 0)
                rte_exit(EXIT_FAILURE, "Port %d RX queue setup error (%d)\n", port_rx, ret);
 
-       ret = rte_eth_tx_queue_setup(port_rx, NIC_TX_QUEUE, NIC_TX_QUEUE_DESC,
+       ret = rte_eth_tx_queue_setup(port_rx, NIC_TX_QUEUE, nb_txd,
                                rte_eth_dev_socket_id(port_rx),
                                NULL);
        if (ret < 0)
@@ -347,13 +360,20 @@ main(int argc, char **argv)
        if (ret < 0)
                rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", port_tx, ret);
 
-       ret = rte_eth_rx_queue_setup(port_tx, NIC_RX_QUEUE, NIC_RX_QUEUE_DESC,
+       nb_rxd = NIC_RX_QUEUE_DESC;
+       nb_txd = NIC_TX_QUEUE_DESC;
+       ret = rte_eth_dev_adjust_nb_rx_tx_desc(port_tx, &nb_rxd, &nb_txd);
+       if (ret < 0)
+               rte_exit(EXIT_FAILURE, "Port %d adjust number of descriptors error (%d)\n",
+                               port_tx, ret);
+
+       ret = rte_eth_rx_queue_setup(port_tx, NIC_RX_QUEUE, nb_rxd,
                                rte_eth_dev_socket_id(port_tx),
                                NULL, pool);
        if (ret < 0)
                rte_exit(EXIT_FAILURE, "Port %d RX queue setup error (%d)\n", port_tx, ret);
 
-       ret = rte_eth_tx_queue_setup(port_tx, NIC_TX_QUEUE, NIC_TX_QUEUE_DESC,
+       ret = rte_eth_tx_queue_setup(port_tx, NIC_TX_QUEUE, nb_txd,
                                rte_eth_dev_socket_id(port_tx),
                                NULL);
        if (ret < 0)
@@ -381,7 +401,9 @@ main(int argc, char **argv)
        rte_eth_promiscuous_enable(port_tx);
 
        /* App configuration */
-       app_configure_flow_table();
+       ret = app_configure_flow_table();
+       if (ret < 0)
+               rte_exit(EXIT_FAILURE, "Invalid configure flow table\n");
 
        /* Launch per-lcore init on every lcore */
        rte_eal_mp_remote_launch(main_loop, NULL, CALL_MASTER);