e1000: cleanup unused parameters
[safe/jmp/linux-2.6] / drivers / net / bnx2x_main.c
index d91a269..2bc35c7 100644 (file)
@@ -57,8 +57,8 @@
 #include "bnx2x_init_ops.h"
 #include "bnx2x_dump.h"
 
-#define DRV_MODULE_VERSION     "1.52.1-8"
-#define DRV_MODULE_RELDATE     "2010/04/01"
+#define DRV_MODULE_VERSION     "1.52.53-1"
+#define DRV_MODULE_RELDATE     "2010/18/04"
 #define BNX2X_BC_VER           0x040200
 
 #include <linux/firmware.h>
@@ -1582,7 +1582,7 @@ static int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget)
                struct sw_rx_bd *rx_buf = NULL;
                struct sk_buff *skb;
                union eth_rx_cqe *cqe;
-               u8 cqe_fp_flags;
+               u8 cqe_fp_flags, cqe_fp_status_flags;
                u16 len, pad;
 
                comp_ring_cons = RCQ_BD(sw_comp_cons);
@@ -1598,6 +1598,7 @@ static int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget)
 
                cqe = &fp->rx_comp_ring[comp_ring_cons];
                cqe_fp_flags = cqe->fast_path_cqe.type_error_flags;
+               cqe_fp_status_flags = cqe->fast_path_cqe.status_flags;
 
                DP(NETIF_MSG_RX_STATUS, "CQE type %x  err %x  status %x"
                   "  queue %x  vlan %x  len %u\n", CQE_TYPE(cqe_fp_flags),
@@ -1616,7 +1617,6 @@ static int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget)
                        rx_buf = &fp->rx_buf_ring[bd_cons];
                        skb = rx_buf->skb;
                        prefetch(skb);
-                       prefetch((u8 *)skb + 256);
                        len = le16_to_cpu(cqe->fast_path_cqe.pkt_len);
                        pad = cqe->fast_path_cqe.placement_offset;
 
@@ -1667,7 +1667,6 @@ static int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget)
                                        dma_unmap_addr(rx_buf, mapping),
                                                   pad + RX_COPY_THRESH,
                                                   DMA_FROM_DEVICE);
-                       prefetch(skb);
                        prefetch(((char *)(skb)) + 128);
 
                        /* is this an error packet? */
@@ -1727,6 +1726,12 @@ reuse_rx:
 
                        skb->protocol = eth_type_trans(skb, bp->dev);
 
+                       if ((bp->dev->features & NETIF_F_RXHASH) &&
+                           (cqe_fp_status_flags &
+                            ETH_FAST_PATH_RX_CQE_RSS_HASH_FLG))
+                               skb->rxhash = le32_to_cpu(
+                                   cqe->fast_path_cqe.rss_hash_result);
+
                        skb->ip_summed = CHECKSUM_NONE;
                        if (bp->rx_csum) {
                                if (likely(BNX2X_RX_CSUM_OK(cqe)))
@@ -2458,6 +2463,7 @@ static void bnx2x_init_vn_minmax(struct bnx2x *bp, int func)
 /* This function is called upon link interrupt */
 static void bnx2x_link_attn(struct bnx2x *bp)
 {
+       u32 prev_link_status = bp->link_vars.link_status;
        /* Make sure that we are synced with the current statistics */
        bnx2x_stats_handle(bp, STATS_EVENT_STOP);
 
@@ -2490,8 +2496,9 @@ static void bnx2x_link_attn(struct bnx2x *bp)
                        bnx2x_stats_handle(bp, STATS_EVENT_LINK_UP);
        }
 
-       /* indicate link status */
-       bnx2x_link_report(bp);
+       /* indicate link status only if link status actually changed */
+       if (prev_link_status != bp->link_vars.link_status)
+               bnx2x_link_report(bp);
 
        if (IS_E1HMF(bp)) {
                int port = BP_PORT(bp);
@@ -3568,7 +3575,6 @@ static void bnx2x_sp_task(struct work_struct *work)
        struct bnx2x *bp = container_of(work, struct bnx2x, sp_task.work);
        u16 status;
 
-
        /* Return here if interrupt is disabled */
        if (unlikely(atomic_read(&bp->intr_sem) != 0)) {
                DP(NETIF_MSG_INTR, "called but intr_sem not 0, returning\n");
@@ -4425,6 +4431,21 @@ static int bnx2x_storm_stats_update(struct bnx2x *bp)
                       qstats->total_bytes_received_lo,
                       le32_to_cpu(tclient->rcv_unicast_bytes.lo));
 
+               SUB_64(qstats->total_bytes_received_hi,
+                      le32_to_cpu(uclient->bcast_no_buff_bytes.hi),
+                      qstats->total_bytes_received_lo,
+                      le32_to_cpu(uclient->bcast_no_buff_bytes.lo));
+
+               SUB_64(qstats->total_bytes_received_hi,
+                      le32_to_cpu(uclient->mcast_no_buff_bytes.hi),
+                      qstats->total_bytes_received_lo,
+                      le32_to_cpu(uclient->mcast_no_buff_bytes.lo));
+
+               SUB_64(qstats->total_bytes_received_hi,
+                      le32_to_cpu(uclient->ucast_no_buff_bytes.hi),
+                      qstats->total_bytes_received_lo,
+                      le32_to_cpu(uclient->ucast_no_buff_bytes.lo));
+
                qstats->valid_bytes_received_hi =
                                        qstats->total_bytes_received_hi;
                qstats->valid_bytes_received_lo =
@@ -4673,47 +4694,43 @@ static void bnx2x_stats_update(struct bnx2x *bp)
        bnx2x_drv_stats_update(bp);
 
        if (netif_msg_timer(bp)) {
-               struct bnx2x_fastpath *fp0_rx = bp->fp;
-               struct bnx2x_fastpath *fp0_tx = bp->fp;
-               struct tstorm_per_client_stats *old_tclient =
-                                                       &bp->fp->old_tclient;
-               struct bnx2x_eth_q_stats *qstats = &bp->fp->eth_q_stats;
                struct bnx2x_eth_stats *estats = &bp->eth_stats;
-               struct net_device_stats *nstats = &bp->dev->stats;
                int i;
 
-               netdev_printk(KERN_DEBUG, bp->dev, "\n");
-               printk(KERN_DEBUG "  tx avail (%4x)  tx hc idx (%x)"
-                                 "  tx pkt (%lx)\n",
-                      bnx2x_tx_avail(fp0_tx),
-                      le16_to_cpu(*fp0_tx->tx_cons_sb), nstats->tx_packets);
-               printk(KERN_DEBUG "  rx usage (%4x)  rx hc idx (%x)"
-                                 "  rx pkt (%lx)\n",
-                      (u16)(le16_to_cpu(*fp0_rx->rx_cons_sb) -
-                            fp0_rx->rx_comp_cons),
-                      le16_to_cpu(*fp0_rx->rx_cons_sb), nstats->rx_packets);
-               printk(KERN_DEBUG "  %s (Xoff events %u)  brb drops %u  "
-                                 "brb truncate %u\n",
-                      (netif_queue_stopped(bp->dev) ? "Xoff" : "Xon"),
-                      qstats->driver_xoff,
+               printk(KERN_DEBUG "%s: brb drops %u  brb truncate %u\n",
+                      bp->dev->name,
                       estats->brb_drop_lo, estats->brb_truncate_lo);
-               printk(KERN_DEBUG "tstats: checksum_discard %u  "
-                       "packets_too_big_discard %lu  no_buff_discard %lu  "
-                       "mac_discard %u  mac_filter_discard %u  "
-                       "xxovrflow_discard %u  brb_truncate_discard %u  "
-                       "ttl0_discard %u\n",
-                      le32_to_cpu(old_tclient->checksum_discard),
-                      bnx2x_hilo(&qstats->etherstatsoverrsizepkts_hi),
-                      bnx2x_hilo(&qstats->no_buff_discard_hi),
-                      estats->mac_discard, estats->mac_filter_discard,
-                      estats->xxoverflow_discard, estats->brb_truncate_discard,
-                      le32_to_cpu(old_tclient->ttl0_discard));
 
                for_each_queue(bp, i) {
-                       printk(KERN_DEBUG "[%d]: %lu\t%lu\t%lu\n", i,
-                              bnx2x_fp(bp, i, tx_pkt),
-                              bnx2x_fp(bp, i, rx_pkt),
-                              bnx2x_fp(bp, i, rx_calls));
+                       struct bnx2x_fastpath *fp = &bp->fp[i];
+                       struct bnx2x_eth_q_stats *qstats = &fp->eth_q_stats;
+
+                       printk(KERN_DEBUG "%s: rx usage(%4u)  *rx_cons_sb(%u)"
+                                         "  rx pkt(%lu)  rx calls(%lu %lu)\n",
+                              fp->name, (le16_to_cpu(*fp->rx_cons_sb) -
+                              fp->rx_comp_cons),
+                              le16_to_cpu(*fp->rx_cons_sb),
+                              bnx2x_hilo(&qstats->
+                                         total_unicast_packets_received_hi),
+                              fp->rx_calls, fp->rx_pkt);
+               }
+
+               for_each_queue(bp, i) {
+                       struct bnx2x_fastpath *fp = &bp->fp[i];
+                       struct bnx2x_eth_q_stats *qstats = &fp->eth_q_stats;
+                       struct netdev_queue *txq =
+                               netdev_get_tx_queue(bp->dev, i);
+
+                       printk(KERN_DEBUG "%s: tx avail(%4u)  *tx_cons_sb(%u)"
+                                         "  tx pkt(%lu) tx calls (%lu)"
+                                         "  %s (Xoff events %u)\n",
+                              fp->name, bnx2x_tx_avail(fp),
+                              le16_to_cpu(*fp->tx_cons_sb),
+                              bnx2x_hilo(&qstats->
+                                         total_unicast_packets_transmitted_hi),
+                              fp->tx_pkt,
+                              (netif_tx_queue_stopped(txq) ? "Xoff" : "Xon"),
+                              qstats->driver_xoff);
                }
        }
 
@@ -5738,10 +5755,10 @@ static void bnx2x_init_internal_func(struct bnx2x *bp)
        u32 offset;
        u16 max_agg_size;
 
-       if (is_multi(bp)) {
-               tstorm_config.config_flags = MULTI_FLAGS(bp);
+       tstorm_config.config_flags = RSS_FLAGS(bp);
+
+       if (is_multi(bp))
                tstorm_config.rss_result_mask = MULTI_MASK;
-       }
 
        /* Enable TPA if needed */
        if (bp->flags & TPA_ENABLE_FLAG)
@@ -6617,10 +6634,8 @@ static int bnx2x_init_common(struct bnx2x *bp)
        bnx2x_init_block(bp, PBF_BLOCK, COMMON_STAGE);
 
        REG_WR(bp, SRC_REG_SOFT_RST, 1);
-       for (i = SRC_REG_KEYRSS0_0; i <= SRC_REG_KEYRSS1_9; i += 4) {
-               REG_WR(bp, i, 0xc0cac01a);
-               /* TODO: replace with something meaningful */
-       }
+       for (i = SRC_REG_KEYRSS0_0; i <= SRC_REG_KEYRSS1_9; i += 4)
+               REG_WR(bp, i, random32());
        bnx2x_init_block(bp, SRCH_BLOCK, COMMON_STAGE);
 #ifdef BCM_CNIC
        REG_WR(bp, SRC_REG_KEYSEARCH_0, 0x63285672);
@@ -7408,7 +7423,31 @@ static int bnx2x_enable_msix(struct bnx2x *bp)
 
        rc = pci_enable_msix(bp->pdev, &bp->msix_table[0],
                             BNX2X_NUM_QUEUES(bp) + offset);
-       if (rc) {
+
+       /*
+        * reconfigure number of tx/rx queues according to available
+        * MSI-X vectors
+        */
+       if (rc >= BNX2X_MIN_MSIX_VEC_CNT) {
+               /* vectors available for FP */
+               int fp_vec = rc - BNX2X_MSIX_VEC_FP_START;
+
+               DP(NETIF_MSG_IFUP,
+                  "Trying to use less MSI-X vectors: %d\n", rc);
+
+               rc = pci_enable_msix(bp->pdev, &bp->msix_table[0], rc);
+
+               if (rc) {
+                       DP(NETIF_MSG_IFUP,
+                          "MSI-X is not attainable  rc %d\n", rc);
+                       return rc;
+               }
+
+               bp->num_queues = min(bp->num_queues, fp_vec);
+
+               DP(NETIF_MSG_IFUP, "New queue configuration set: %d\n",
+                                 bp->num_queues);
+       } else if (rc) {
                DP(NETIF_MSG_IFUP, "MSI-X is not attainable  rc %d\n", rc);
                return rc;
        }
@@ -7831,8 +7870,6 @@ static int bnx2x_set_num_queues(struct bnx2x *bp)
                bp->num_queues = 1;
                DP(NETIF_MSG_IFUP, "set number of queues to 1\n");
                break;
-
-       case INT_MODE_MSIX:
        default:
                /* Set number of queues according to bp->multi_mode value */
                bnx2x_set_num_queues_msix(bp);
@@ -10967,6 +11004,11 @@ static int bnx2x_set_flags(struct net_device *dev, u32 data)
                changed = 1;
        }
 
+       if (data & ETH_FLAG_RXHASH)
+               dev->features |= NETIF_F_RXHASH;
+       else
+               dev->features &= ~NETIF_F_RXHASH;
+
        if (changed && netif_running(dev)) {
                bnx2x_nic_unload(bp, UNLOAD_NORMAL);
                rc = bnx2x_nic_load(bp, LOAD_NORMAL);
@@ -11105,7 +11147,7 @@ static int bnx2x_test_registers(struct bnx2x *bp)
 
                        save_val = REG_RD(bp, offset);
 
-                       REG_WR(bp, offset, wr_val);
+                       REG_WR(bp, offset, (wr_val & mask));
                        val = REG_RD(bp, offset);
 
                        /* Restore the original register's value */
@@ -11558,7 +11600,11 @@ static const struct {
 
 /* 10 */{ Q_STATS_OFFSET32(total_bytes_transmitted_hi),        8, "[%d]: tx_bytes" },
        { Q_STATS_OFFSET32(total_unicast_packets_transmitted_hi),
-                                                       8, "[%d]: tx_packets" }
+                                               8, "[%d]: tx_ucast_packets" },
+       { Q_STATS_OFFSET32(total_multicast_packets_transmitted_hi),
+                                               8, "[%d]: tx_mcast_packets" },
+       { Q_STATS_OFFSET32(total_broadcast_packets_transmitted_hi),
+                                               8, "[%d]: tx_bcast_packets" }
 };
 
 static const struct {
@@ -11620,16 +11666,20 @@ static const struct {
        { STATS_OFFSET32(tx_stat_ifhcoutbadoctets_hi),
                                8, STATS_FLAGS_PORT, "tx_error_bytes" },
        { STATS_OFFSET32(total_unicast_packets_transmitted_hi),
-                               8, STATS_FLAGS_BOTH, "tx_packets" },
+                               8, STATS_FLAGS_BOTH, "tx_ucast_packets" },
+       { STATS_OFFSET32(total_multicast_packets_transmitted_hi),
+                               8, STATS_FLAGS_BOTH, "tx_mcast_packets" },
+       { STATS_OFFSET32(total_broadcast_packets_transmitted_hi),
+                               8, STATS_FLAGS_BOTH, "tx_bcast_packets" },
        { STATS_OFFSET32(tx_stat_dot3statsinternalmactransmiterrors_hi),
                                8, STATS_FLAGS_PORT, "tx_mac_errors" },
        { STATS_OFFSET32(rx_stat_dot3statscarriersenseerrors_hi),
                                8, STATS_FLAGS_PORT, "tx_carrier_errors" },
-       { STATS_OFFSET32(tx_stat_dot3statssinglecollisionframes_hi),
+/* 30 */{ STATS_OFFSET32(tx_stat_dot3statssinglecollisionframes_hi),
                                8, STATS_FLAGS_PORT, "tx_single_collisions" },
        { STATS_OFFSET32(tx_stat_dot3statsmultiplecollisionframes_hi),
                                8, STATS_FLAGS_PORT, "tx_multi_collisions" },
-/* 30 */{ STATS_OFFSET32(tx_stat_dot3statsdeferredtransmissions_hi),
+       { STATS_OFFSET32(tx_stat_dot3statsdeferredtransmissions_hi),
                                8, STATS_FLAGS_PORT, "tx_deferred" },
        { STATS_OFFSET32(tx_stat_dot3statsexcessivecollisions_hi),
                                8, STATS_FLAGS_PORT, "tx_excess_collisions" },
@@ -11645,11 +11695,11 @@ static const struct {
                        8, STATS_FLAGS_PORT, "tx_128_to_255_byte_packets" },
        { STATS_OFFSET32(tx_stat_etherstatspkts256octetsto511octets_hi),
                        8, STATS_FLAGS_PORT, "tx_256_to_511_byte_packets" },
-       { STATS_OFFSET32(tx_stat_etherstatspkts512octetsto1023octets_hi),
+/* 40 */{ STATS_OFFSET32(tx_stat_etherstatspkts512octetsto1023octets_hi),
                        8, STATS_FLAGS_PORT, "tx_512_to_1023_byte_packets" },
        { STATS_OFFSET32(etherstatspkts1024octetsto1522octets_hi),
                        8, STATS_FLAGS_PORT, "tx_1024_to_1522_byte_packets" },
-/* 40 */{ STATS_OFFSET32(etherstatspktsover1522octets_hi),
+       { STATS_OFFSET32(etherstatspktsover1522octets_hi),
                        8, STATS_FLAGS_PORT, "tx_1523_to_9022_byte_packets" },
        { STATS_OFFSET32(pause_frames_sent_hi),
                                8, STATS_FLAGS_PORT, "tx_pause_frames" }
@@ -11895,6 +11945,14 @@ static int bnx2x_set_power_state(struct bnx2x *bp, pci_power_t state)
                break;
 
        case PCI_D3hot:
+               /* If there are other clients above don't
+                  shut down the power */
+               if (atomic_read(&bp->pdev->enable_cnt) != 1)
+                       return 0;
+               /* Don't shut down the power for emulation and FPGA */
+               if (CHIP_REV_IS_SLOW(bp))
+                       return 0;
+
                pmcsr &= ~PCI_PM_CTRL_STATE_MASK;
                pmcsr |= 3;
 
@@ -12184,6 +12242,8 @@ static netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
        int i;
        u8 hlen = 0;
        __le16 pkt_size = 0;
+       struct ethhdr *eth;
+       u8 mac_type = UNICAST_ADDRESS;
 
 #ifdef BNX2X_STOP_ON_ERROR
        if (unlikely(bp->panic))
@@ -12207,6 +12267,16 @@ static netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
           skb->ip_summed, skb->protocol, ipv6_hdr(skb)->nexthdr,
           ip_hdr(skb)->protocol, skb_shinfo(skb)->gso_type, xmit_type);
 
+       eth = (struct ethhdr *)skb->data;
+
+       /* set flag according to packet type (UNICAST_ADDRESS is default)*/
+       if (unlikely(is_multicast_ether_addr(eth->h_dest))) {
+               if (is_broadcast_ether_addr(eth->h_dest))
+                       mac_type = BROADCAST_ADDRESS;
+               else
+                       mac_type = MULTICAST_ADDRESS;
+       }
+
 #if (MAX_SKB_FRAGS >= MAX_FETCH_BD - 3)
        /* First, check if we need to linearize the skb (due to FW
           restrictions). No need to check fragmentation if page size > 8K
@@ -12240,8 +12310,8 @@ static netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
        tx_start_bd = &fp->tx_desc_ring[bd_prod].start_bd;
 
        tx_start_bd->bd_flags.as_bitfield = ETH_TX_BD_FLAGS_START_BD;
-       tx_start_bd->general_data = (UNICAST_ADDRESS <<
-                                    ETH_TX_START_BD_ETH_ADDR_TYPE_SHIFT);
+       tx_start_bd->general_data =  (mac_type <<
+                                       ETH_TX_START_BD_ETH_ADDR_TYPE_SHIFT);
        /* header nbd */
        tx_start_bd->general_data |= (1 << ETH_TX_START_BD_HDR_NBDS_SHIFT);
 
@@ -12499,9 +12569,7 @@ static int bnx2x_close(struct net_device *dev)
 
        /* Unload the driver, release IRQs */
        bnx2x_nic_unload(bp, UNLOAD_CLOSE);
-       if (atomic_read(&bp->pdev->enable_cnt) == 1)
-               if (!CHIP_REV_IS_SLOW(bp))
-                       bnx2x_set_power_state(bp, PCI_D3hot);
+       bnx2x_set_power_state(bp, PCI_D3hot);
 
        return 0;
 }