libertas: fix 8686 firmware loading regression
[safe/jmp/linux-2.6] / drivers / net / mlx4 / en_netdev.c
index 16a634f..c48b0f4 100644 (file)
@@ -367,7 +367,7 @@ static void mlx4_en_set_default_moderation(struct mlx4_en_priv *priv)
        int i;
 
        /* If we haven't received a specific coalescing setting
-        * (module param), we set the moderation paramters as follows:
+        * (module param), we set the moderation parameters as follows:
         * - moder_cnt is set to the number of mtu sized packets to
         *   satisfy our coelsing target.
         * - moder_time is set to a fixed value.
@@ -414,6 +414,7 @@ static void mlx4_en_auto_moderation(struct mlx4_en_priv *priv)
        unsigned long avg_pkt_size;
        unsigned long rx_packets;
        unsigned long rx_bytes;
+       unsigned long rx_byte_diff;
        unsigned long tx_packets;
        unsigned long tx_pkt_diff;
        unsigned long rx_pkt_diff;
@@ -437,6 +438,8 @@ static void mlx4_en_auto_moderation(struct mlx4_en_priv *priv)
        rx_pkt_diff = ((unsigned long) (rx_packets -
                                        priv->last_moder_packets));
        packets = max(tx_pkt_diff, rx_pkt_diff);
+       rx_byte_diff = rx_bytes - priv->last_moder_bytes;
+       rx_byte_diff = rx_byte_diff ? rx_byte_diff : 1;
        rate = packets * HZ / period;
        avg_pkt_size = packets ? ((unsigned long) (rx_bytes -
                                 priv->last_moder_bytes)) / packets : 0;
@@ -447,10 +450,13 @@ static void mlx4_en_auto_moderation(struct mlx4_en_priv *priv)
                /* If tx and rx packet rates are not balanced, assume that
                 * traffic is mainly BW bound and apply maximum moderation.
                 * Otherwise, moderate according to packet rate */
-               if (2 * tx_pkt_diff > 3 * rx_pkt_diff ||
-                   2 * rx_pkt_diff > 3 * tx_pkt_diff) {
+               if (2 * tx_pkt_diff > 3 * rx_pkt_diff &&
+                   rx_pkt_diff / rx_byte_diff <
+                   MLX4_EN_SMALL_PKT_SIZE)
+                       moder_time = priv->rx_usecs_low;
+               else if (2 * rx_pkt_diff > 3 * tx_pkt_diff)
                        moder_time = priv->rx_usecs_high;
-               else {
+               else {
                        if (rate < priv->pkt_rate_low)
                                moder_time = priv->rx_usecs_low;
                        else if (rate > priv->pkt_rate_high)
@@ -616,8 +622,7 @@ int mlx4_en_start_port(struct net_device *dev)
 
                /* Configure ring */
                tx_ring = &priv->tx_ring[i];
-               err = mlx4_en_activate_tx_ring(priv, tx_ring, cq->mcq.cqn,
-                                              priv->rx_ring[0].srq.srqn);
+               err = mlx4_en_activate_tx_ring(priv, tx_ring, cq->mcq.cqn);
                if (err) {
                        en_err(priv, "Failed allocating Tx ring\n");
                        mlx4_en_deactivate_cq(priv, cq);
@@ -668,7 +673,7 @@ int mlx4_en_start_port(struct net_device *dev)
        queue_work(mdev->workqueue, &priv->mcast_task);
 
        priv->port_up = true;
-       netif_start_queue(dev);
+       netif_tx_start_all_queues(dev);
        return 0;
 
 mac_err:
@@ -700,14 +705,14 @@ void mlx4_en_stop_port(struct net_device *dev)
                en_dbg(DRV, priv, "stop port called while port already down\n");
                return;
        }
-       netif_stop_queue(dev);
 
        /* Synchronize with tx routine */
        netif_tx_lock_bh(dev);
-       priv->port_up = false;
+       netif_tx_stop_all_queues(dev);
        netif_tx_unlock_bh(dev);
 
        /* close port*/
+       priv->port_up = false;
        mlx4_CLOSE_PORT(mdev->dev, priv->port);
 
        /* Unregister Mac address for the port */
@@ -881,7 +886,6 @@ void mlx4_en_destroy_netdev(struct net_device *dev)
                mlx4_free_hwq_res(mdev->dev, &priv->res, MLX4_EN_PAGE_SIZE);
 
        cancel_delayed_work(&priv->stats_task);
-       cancel_delayed_work(&priv->refill_task);
        /* flush any pending task for this netdev */
        flush_workqueue(mdev->workqueue);
 
@@ -934,6 +938,7 @@ static const struct net_device_ops mlx4_netdev_ops = {
        .ndo_open               = mlx4_en_open,
        .ndo_stop               = mlx4_en_close,
        .ndo_start_xmit         = mlx4_en_xmit,
+       .ndo_select_queue       = mlx4_en_select_queue,
        .ndo_get_stats          = mlx4_en_get_stats,
        .ndo_set_multicast_list = mlx4_en_set_multicast,
        .ndo_set_mac_address    = mlx4_en_set_mac,
@@ -956,7 +961,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
        int i;
        int err;
 
-       dev = alloc_etherdev(sizeof(struct mlx4_en_priv));
+       dev = alloc_etherdev_mq(sizeof(struct mlx4_en_priv), prof->tx_ring_num);
        if (dev == NULL) {
                mlx4_err(mdev, "Net device allocation failed\n");
                return -ENOMEM;
@@ -985,7 +990,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
        spin_lock_init(&priv->stats_lock);
        INIT_WORK(&priv->mcast_task, mlx4_en_do_set_multicast);
        INIT_WORK(&priv->mac_task, mlx4_en_do_set_mac);
-       INIT_DELAYED_WORK(&priv->refill_task, mlx4_en_rx_refill);
        INIT_WORK(&priv->watchdog_task, mlx4_en_restart);
        INIT_WORK(&priv->linkstate_task, mlx4_en_linkstate);
        INIT_DELAYED_WORK(&priv->stats_task, mlx4_en_do_get_stats);
@@ -1006,9 +1010,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
        if (err)
                goto out;
 
-       /* Populate Rx default RSS mappings */
-       mlx4_en_set_default_rss_map(priv, &priv->rss_map, priv->rx_ring_num *
-                                               RSS_FACTOR, priv->rx_ring_num);
        /* Allocate page for receive rings */
        err = mlx4_alloc_hwq_res(mdev->dev, &priv->res,
                                MLX4_EN_PAGE_SIZE, MLX4_EN_PAGE_SIZE);
@@ -1018,14 +1019,12 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
        }
        priv->allocated = 1;
 
-       /* Populate Tx priority mappings */
-       mlx4_en_set_prio_map(priv, priv->tx_prio_map, prof->tx_ring_num);
-
        /*
         * Initialize netdev entry points
         */
        dev->netdev_ops = &mlx4_netdev_ops;
        dev->watchdog_timeo = MLX4_EN_WATCHDOG_TIMEOUT;
+       dev->real_num_tx_queues = MLX4_EN_NUM_TX_RINGS;
 
        SET_ETHTOOL_OPS(dev, &mlx4_en_ethtool_ops);
 
@@ -1039,7 +1038,9 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
         * Set driver features
         */
        dev->features |= NETIF_F_SG;
+       dev->vlan_features |= NETIF_F_SG;
        dev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
+       dev->vlan_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
        dev->features |= NETIF_F_HIGHDMA;
        dev->features |= NETIF_F_HW_VLAN_TX |
                         NETIF_F_HW_VLAN_RX |
@@ -1049,6 +1050,8 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
        if (mdev->LSO_support) {
                dev->features |= NETIF_F_TSO;
                dev->features |= NETIF_F_TSO6;
+               dev->vlan_features |= NETIF_F_TSO;
+               dev->vlan_features |= NETIF_F_TSO6;
        }
 
        mdev->pndev[port] = dev;