]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/bnx2x_main.c
bnx2x: Not dropping packets with L3/L4 checksum error
[linux-2.6-omap-h63xx.git] / drivers / net / bnx2x_main.c
index 0263bef9cc6ddfb2cfa428ebe1ad6a104d27b49c..b9d376d972ca4855a1194688f883e4b548ca5b6d 100644 (file)
@@ -76,23 +76,21 @@ MODULE_DESCRIPTION("Broadcom NetXtreme II BCM57710 Driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_MODULE_VERSION);
 
+static int disable_tpa;
 static int use_inta;
 static int poll;
 static int debug;
-static int disable_tpa;
-static int nomcp;
 static int load_count[3]; /* 0-common, 1-port0, 2-port1 */
 static int use_multi;
 
+module_param(disable_tpa, int, 0);
 module_param(use_inta, int, 0);
 module_param(poll, int, 0);
 module_param(debug, int, 0);
-module_param(disable_tpa, int, 0);
-module_param(nomcp, int, 0);
+MODULE_PARM_DESC(disable_tpa, "disable the TPA (LRO) feature");
 MODULE_PARM_DESC(use_inta, "use INT#A instead of MSI-X");
 MODULE_PARM_DESC(poll, "use polling (for debug)");
 MODULE_PARM_DESC(debug, "default debug msglevel");
-MODULE_PARM_DESC(nomcp, "ignore management CPU");
 
 #ifdef BNX2X_MULTI
 module_param(use_multi, int, 0);
@@ -814,7 +812,7 @@ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fastpath *fp,
        }
 
        /* release skb */
-       BUG_TRAP(skb);
+       WARN_ON(!skb);
        dev_kfree_skb(skb);
        tx_buf->first_bd = 0;
        tx_buf->skb = NULL;
@@ -837,9 +835,9 @@ static inline u16 bnx2x_tx_avail(struct bnx2x_fastpath *fp)
        used = SUB_S16(prod, cons) + (s16)NUM_TX_RINGS;
 
 #ifdef BNX2X_STOP_ON_ERROR
-       BUG_TRAP(used >= 0);
-       BUG_TRAP(used <= fp->bp->tx_ring_size);
-       BUG_TRAP((fp->bp->tx_ring_size - used) <= MAX_TX_AVAIL);
+       WARN_ON(used < 0);
+       WARN_ON(used > fp->bp->tx_ring_size);
+       WARN_ON((fp->bp->tx_ring_size - used) > MAX_TX_AVAIL);
 #endif
 
        return (s16)(fp->bp->tx_ring_size) - used;
@@ -1020,7 +1018,7 @@ static inline int bnx2x_alloc_rx_sge(struct bnx2x *bp,
 
        mapping = pci_map_page(bp->pdev, page, 0, BCM_PAGE_SIZE*PAGES_PER_SGE,
                               PCI_DMA_FROMDEVICE);
-       if (unlikely(dma_mapping_error(mapping))) {
+       if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) {
                __free_pages(page, PAGES_PER_SGE_SHIFT);
                return -ENOMEM;
        }
@@ -1048,7 +1046,7 @@ static inline int bnx2x_alloc_rx_skb(struct bnx2x *bp,
 
        mapping = pci_map_single(bp->pdev, skb->data, bp->rx_buf_use_size,
                                 PCI_DMA_FROMDEVICE);
-       if (unlikely(dma_mapping_error(mapping))) {
+       if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) {
                dev_kfree_skb(skb);
                return -ENOMEM;
        }
@@ -1503,7 +1501,6 @@ static int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget)
 
                        /* is this an error packet? */
                        if (unlikely(cqe_fp_flags & ETH_RX_ERROR_FALGS)) {
-                       /* do we sometimes forward error packets anyway? */
                                DP(NETIF_MSG_RX_ERR,
                                   "ERROR  flags %x  rx packet %u\n",
                                   cqe_fp_flags, sw_comp_cons);
@@ -1559,10 +1556,10 @@ reuse_rx:
                        skb->protocol = eth_type_trans(skb, bp->dev);
 
                        skb->ip_summed = CHECKSUM_NONE;
-                       if (bp->rx_csum && BNX2X_RX_SUM_OK(cqe))
-                               skb->ip_summed = CHECKSUM_UNNECESSARY;
+                       if (bp->rx_csum)
+                               if (likely(BNX2X_RX_CSUM_OK(cqe)))
+                                       skb->ip_summed = CHECKSUM_UNNECESSARY;
 
-                       /* TBD do we pass bad csum packets in promisc */
                }
 
 #ifdef BCM_VLAN
@@ -1940,37 +1937,47 @@ static void bnx2x_link_report(struct bnx2x *bp)
 
 static u8 bnx2x_initial_phy_init(struct bnx2x *bp)
 {
-       u8 rc;
+       if (!BP_NOMCP(bp)) {
+               u8 rc;
 
-       /* Initialize link parameters structure variables */
-       bp->link_params.mtu = bp->dev->mtu;
+               /* Initialize link parameters structure variables */
+               bp->link_params.mtu = bp->dev->mtu;
 
-       bnx2x_phy_hw_lock(bp);
-       rc = bnx2x_phy_init(&bp->link_params, &bp->link_vars);
-       bnx2x_phy_hw_unlock(bp);
+               bnx2x_phy_hw_lock(bp);
+               rc = bnx2x_phy_init(&bp->link_params, &bp->link_vars);
+               bnx2x_phy_hw_unlock(bp);
 
-       if (bp->link_vars.link_up)
-               bnx2x_link_report(bp);
+               if (bp->link_vars.link_up)
+                       bnx2x_link_report(bp);
 
-       bnx2x_calc_fc_adv(bp);
+               bnx2x_calc_fc_adv(bp);
 
-       return rc;
+               return rc;
+       }
+       BNX2X_ERR("Bootcode is missing -not initializing link\n");
+       return -EINVAL;
 }
 
 static void bnx2x_link_set(struct bnx2x *bp)
 {
-       bnx2x_phy_hw_lock(bp);
-       bnx2x_phy_init(&bp->link_params, &bp->link_vars);
-       bnx2x_phy_hw_unlock(bp);
+       if (!BP_NOMCP(bp)) {
+               bnx2x_phy_hw_lock(bp);
+               bnx2x_phy_init(&bp->link_params, &bp->link_vars);
+               bnx2x_phy_hw_unlock(bp);
 
-       bnx2x_calc_fc_adv(bp);
+               bnx2x_calc_fc_adv(bp);
+       } else
+               BNX2X_ERR("Bootcode is missing -not setting link\n");
 }
 
 static void bnx2x__link_reset(struct bnx2x *bp)
 {
-       bnx2x_phy_hw_lock(bp);
-       bnx2x_link_reset(&bp->link_params, &bp->link_vars);
-       bnx2x_phy_hw_unlock(bp);
+       if (!BP_NOMCP(bp)) {
+               bnx2x_phy_hw_lock(bp);
+               bnx2x_link_reset(&bp->link_params, &bp->link_vars);
+               bnx2x_phy_hw_unlock(bp);
+       } else
+               BNX2X_ERR("Bootcode is missing -not resetting link\n");
 }
 
 static u8 bnx2x_link_test(struct bnx2x *bp)
@@ -2374,7 +2381,7 @@ static int bnx2x_lock_alr(struct bnx2x *bp)
                msleep(5);
        }
        if (!(val & (1L << 31))) {
-               BNX2X_ERR("Cannot acquire nvram interface\n");
+               BNX2X_ERR("Cannot acquire MCP access lock register\n");
                rc = -EBUSY;
        }
 
@@ -4374,7 +4381,7 @@ static void bnx2x_init_rx_rings(struct bnx2x *bp)
                        }
                        ring_prod = NEXT_RX_IDX(ring_prod);
                        cqe_ring_prod = NEXT_RCQ_IDX(cqe_ring_prod);
-                       BUG_TRAP(ring_prod > i);
+                       WARN_ON(ring_prod <= i);
                }
 
                fp->rx_bd_prod = ring_prod;
@@ -5638,18 +5645,23 @@ static u32 bnx2x_fw_command(struct bnx2x *bp, u32 command)
        int func = BP_FUNC(bp);
        u32 seq = ++bp->fw_seq;
        u32 rc = 0;
+       u32 cnt = 1;
+       u8 delay = CHIP_REV_IS_SLOW(bp) ? 100 : 10;
 
        SHMEM_WR(bp, func_mb[func].drv_mb_header, (command | seq));
        DP(BNX2X_MSG_MCP, "wrote command (%x) to FW MB\n", (command | seq));
 
-       /* let the FW do it's magic ... */
-       msleep(100); /* TBD */
+       do {
+               /* let the FW do it's magic ... */
+               msleep(delay);
+
+               rc = SHMEM_RD(bp, func_mb[func].fw_mb_header);
 
-       if (CHIP_REV_IS_SLOW(bp))
-               msleep(900);
+               /* Give the FW up to 2 second (200*10ms) */
+       } while ((seq != (rc & FW_MSG_SEQ_NUMBER_MASK)) && (cnt++ < 200));
 
-       rc = SHMEM_RD(bp, func_mb[func].fw_mb_header);
-       DP(BNX2X_MSG_MCP, "read (%x) seq is (%x) from FW MB\n", rc, seq);
+       DP(BNX2X_MSG_MCP, "[after %d ms] read (%x) seq is (%x) from FW MB\n",
+          cnt*delay, rc, seq);
 
        /* is this a reply to our command? */
        if (seq == (rc & FW_MSG_SEQ_NUMBER_MASK)) {
@@ -7202,7 +7214,7 @@ static void __devinit bnx2x_link_settings_requested(struct bnx2x *bp)
        bp->link_params.req_flow_ctrl = (bp->port.link_config &
                                         PORT_FEATURE_FLOW_CONTROL_MASK);
        if ((bp->link_params.req_flow_ctrl == FLOW_CTRL_AUTO) &&
-           (!bp->port.supported & SUPPORTED_Autoneg))
+           !(bp->port.supported & SUPPORTED_Autoneg))
                bp->link_params.req_flow_ctrl = FLOW_CTRL_NONE;
 
        BNX2X_DEV_INFO("req_line_speed %d  req_duplex %d  req_flow_ctrl 0x%x"
@@ -7337,9 +7349,6 @@ static int __devinit bnx2x_init_bp(struct bnx2x *bp)
        int func = BP_FUNC(bp);
        int rc;
 
-       if (nomcp)
-               bp->flags |= NO_MCP_FLAG;
-
        mutex_init(&bp->port.phy_mutex);
 
        INIT_WORK(&bp->sp_task, bnx2x_sp_task);