New upstream version 16.11.9
[deb_dpdk.git] / drivers / net / fm10k / fm10k_ethdev.c
index 923690c..f8f6d37 100644 (file)
@@ -53,7 +53,7 @@
 /* Wait interval to get switch status */
 #define WAIT_SWITCH_MSG_US    100000
 /* A period of quiescence for switch */
-#define FM10K_SWITCH_QUIESCE_US 10000
+#define FM10K_SWITCH_QUIESCE_US 100000
 /* Number of chars per uint32 type */
 #define CHARS_PER_UINT32 (sizeof(uint32_t))
 #define BIT_MASK_PER_UINT32 ((1 << CHARS_PER_UINT32) - 1)
@@ -83,6 +83,7 @@ static void fm10k_rx_queue_release(void *queue);
 static void fm10k_set_rx_function(struct rte_eth_dev *dev);
 static void fm10k_set_tx_function(struct rte_eth_dev *dev);
 static int fm10k_check_ftag(struct rte_devargs *devargs);
+static int fm10k_link_update(struct rte_eth_dev *dev, int wait_to_complete);
 
 struct fm10k_xstats_name_off {
        char name[RTE_ETH_XSTATS_NAME_SIZE];
@@ -481,11 +482,6 @@ fm10k_dev_configure(struct rte_eth_dev *dev)
        return 0;
 }
 
-/* fls = find last set bit = 32 minus the number of leading zeros */
-#ifndef fls
-#define fls(x) (((x) == 0) ? 0 : (32 - __builtin_clz((x))))
-#endif
-
 static void
 fm10k_dev_vmdq_rx_configure(struct rte_eth_dev *dev)
 {
@@ -1058,8 +1054,8 @@ fm10k_dev_dglort_map_configure(struct rte_eth_dev *dev)
 
        macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private);
        nb_queue_pools = macvlan->nb_queue_pools;
-       pool_len = nb_queue_pools ? fls(nb_queue_pools - 1) : 0;
-       rss_len = fls(dev->data->nb_rx_queues - 1) - pool_len;
+       pool_len = nb_queue_pools ? rte_fls_u32(nb_queue_pools - 1) : 0;
+       rss_len = rte_fls_u32(dev->data->nb_rx_queues - 1) - pool_len;
 
        /* GLORT 0x0-0x3F are used by PF and VMDQ,  0x40-0x7F used by FD */
        dglortdec = (rss_len << FM10K_DGLORTDEC_RSSLENGTH_SHIFT) | pool_len;
@@ -1070,7 +1066,7 @@ fm10k_dev_dglort_map_configure(struct rte_eth_dev *dev)
        FM10K_WRITE_REG(hw, FM10K_DGLORTDEC(0), dglortdec);
 
        /* Flow Director configurations, only queue number is valid. */
-       dglortdec = fls(dev->data->nb_rx_queues - 1);
+       dglortdec = rte_fls_u32(dev->data->nb_rx_queues - 1);
        dglortmask = (GLORT_FD_MASK << FM10K_DGLORTMAP_MASK_SHIFT) |
                        (hw->mac.dglort_map + GLORT_FD_Q_BASE);
        FM10K_WRITE_REG(hw, FM10K_DGLORTMAP(1), dglortmask);
@@ -1164,6 +1160,8 @@ fm10k_dev_start(struct rte_eth_dev *dev)
        if (!(dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_VMDQ_FLAG))
                fm10k_vlan_filter_set(dev, hw->mac.default_vid, true);
 
+       fm10k_link_update(dev, 0);
+
        return 0;
 }
 
@@ -1236,7 +1234,7 @@ fm10k_dev_close(struct rte_eth_dev *dev)
                MAX_LPORT_NUM, false);
        fm10k_mbx_unlock(hw);
 
-       /* allow 10ms for device to quiesce */
+       /* allow 100ms for device to quiesce */
        rte_delay_us(FM10K_SWITCH_QUIESCE_US);
 
        /* Stop mailbox service first */
@@ -1315,6 +1313,7 @@ fm10k_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
        for (i = 0; i < FM10K_NB_HW_XSTATS; i++) {
                xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
                        fm10k_hw_stats_strings[count].offset);
+               xstats[count].id = count;
                count++;
        }
 
@@ -1324,12 +1323,14 @@ fm10k_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
                        xstats[count].value =
                                *(uint64_t *)(((char *)&hw_stats->q[q]) +
                                fm10k_hw_stats_rx_q_strings[i].offset);
+                       xstats[count].id = count;
                        count++;
                }
                for (i = 0; i < FM10K_NB_TX_Q_XSTATS; i++) {
                        xstats[count].value =
                                *(uint64_t *)(((char *)&hw_stats->q[q]) +
                                fm10k_hw_stats_tx_q_strings[i].offset);
+                       xstats[count].id = count;
                        count++;
                }
        }
@@ -1794,7 +1795,8 @@ fm10k_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_id,
        const struct rte_eth_rxconf *conf, struct rte_mempool *mp)
 {
        struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-       struct fm10k_dev_info *dev_info = FM10K_DEV_PRIVATE_TO_INFO(dev);
+       struct fm10k_dev_info *dev_info =
+               FM10K_DEV_PRIVATE_TO_INFO(dev->data->dev_private);
        struct fm10k_rx_queue *q;
        const struct rte_memzone *mz;
 
@@ -2764,7 +2766,8 @@ fm10k_set_tx_function(struct rte_eth_dev *dev)
 static void __attribute__((cold))
 fm10k_set_rx_function(struct rte_eth_dev *dev)
 {
-       struct fm10k_dev_info *dev_info = FM10K_DEV_PRIVATE_TO_INFO(dev);
+       struct fm10k_dev_info *dev_info =
+               FM10K_DEV_PRIVATE_TO_INFO(dev->data->dev_private);
        uint16_t i, rx_using_sse;
        uint16_t rx_ftag_en = 0;
 
@@ -2806,7 +2809,8 @@ static void
 fm10k_params_init(struct rte_eth_dev *dev)
 {
        struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-       struct fm10k_dev_info *info = FM10K_DEV_PRIVATE_TO_INFO(dev);
+       struct fm10k_dev_info *info =
+               FM10K_DEV_PRIVATE_TO_INFO(dev->data->dev_private);
 
        /* Inialize bus info. Normally we would call fm10k_get_bus_info(), but
         * there is no way to get link status without reading BAR4.  Until this