bnx2x: removed unused variables
[pandora-kernel.git] / drivers / net / bnx2x / bnx2x_main.c
index a97d9be..d7cab0d 100644 (file)
@@ -99,6 +99,8 @@ static int disable_tpa;
 module_param(disable_tpa, int, 0);
 MODULE_PARM_DESC(disable_tpa, " Disable the TPA (LRO) feature");
 
+#define INT_MODE_INTx                  1
+#define INT_MODE_MSI                   2
 static int int_mode;
 module_param(int_mode, int, 0);
 MODULE_PARM_DESC(int_mode, " Force interrupt mode other then MSI-X "
@@ -833,9 +835,9 @@ static int bnx2x_mc_assert(struct bnx2x *bp)
        return rc;
 }
 
-static void bnx2x_fw_dump(struct bnx2x *bp)
+void bnx2x_fw_dump_lvl(struct bnx2x *bp, const char *lvl)
 {
-       u32 addr;
+       u32 addr, val;
        u32 mark, offset;
        __be32 data[9];
        int word;
@@ -844,6 +846,14 @@ static void bnx2x_fw_dump(struct bnx2x *bp)
                BNX2X_ERR("NO MCP - can not dump\n");
                return;
        }
+       netdev_printk(lvl, bp->dev, "bc %d.%d.%d\n",
+               (bp->common.bc_ver & 0xff0000) >> 16,
+               (bp->common.bc_ver & 0xff00) >> 8,
+               (bp->common.bc_ver & 0xff));
+
+       val = REG_RD(bp, MCP_REG_MCPR_CPU_PROGRAM_COUNTER);
+       if (val == REG_RD(bp, MCP_REG_MCPR_CPU_PROGRAM_COUNTER))
+               printk("%s" "MCP PC at 0x%x\n", lvl, val);
 
        if (BP_PATH(bp) == 0)
                trace_shmem_base = bp->common.shmem_base;
@@ -853,9 +863,9 @@ static void bnx2x_fw_dump(struct bnx2x *bp)
        mark = REG_RD(bp, addr);
        mark = (CHIP_IS_E1x(bp) ? MCP_REG_MCPR_SCRATCH : MCP_A_REG_MCPR_SCRATCH)
                        + ((mark + 0x3) & ~0x3) - 0x08000000;
-       pr_err("begin fw dump (mark 0x%x)\n", mark);
+       printk("%s" "begin fw dump (mark 0x%x)\n", lvl, mark);
 
-       pr_err("");
+       printk("%s", lvl);
        for (offset = mark; offset <= trace_shmem_base; offset += 0x8*4) {
                for (word = 0; word < 8; word++)
                        data[word] = htonl(REG_RD(bp, offset + 4*word));
@@ -868,7 +878,12 @@ static void bnx2x_fw_dump(struct bnx2x *bp)
                data[8] = 0x0;
                pr_cont("%s", (char *)data);
        }
-       pr_err("end of fw dump\n");
+       printk("%s" "end of fw dump\n", lvl);
+}
+
+static inline void bnx2x_fw_dump(struct bnx2x *bp)
+{
+       bnx2x_fw_dump_lvl(bp, KERN_ERR);
 }
 
 void bnx2x_panic_dump(struct bnx2x *bp)
@@ -1285,10 +1300,6 @@ void bnx2x_int_disable_sync(struct bnx2x *bp, int disable_hw)
        int msix = (bp->flags & USING_MSIX_FLAG) ? 1 : 0;
        int i, offset;
 
-       /* disable interrupt handling */
-       atomic_inc(&bp->intr_sem);
-       smp_wmb(); /* Ensure that bp->intr_sem update is SMP-safe */
-
        if (disable_hw)
                /* prevent the HW from sending interrupts */
                bnx2x_int_disable(bp);
@@ -1411,12 +1422,6 @@ irqreturn_t bnx2x_interrupt(int irq, void *dev_instance)
        }
        DP(NETIF_MSG_INTR, "got an interrupt  status 0x%x\n", 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");
-               return IRQ_HANDLED;
-       }
-
 #ifdef BNX2X_STOP_ON_ERROR
        if (unlikely(bp->panic))
                return IRQ_HANDLED;
@@ -1732,45 +1737,6 @@ static int bnx2x_set_spio(struct bnx2x *bp, int spio_num, u32 mode)
        return 0;
 }
 
-int bnx2x_get_link_cfg_idx(struct bnx2x *bp)
-{
-       u32 sel_phy_idx = 0;
-       if (bp->link_vars.link_up) {
-               sel_phy_idx = EXT_PHY1;
-               /* In case link is SERDES, check if the EXT_PHY2 is the one */
-               if ((bp->link_vars.link_status & LINK_STATUS_SERDES_LINK) &&
-                   (bp->link_params.phy[EXT_PHY2].supported & SUPPORTED_FIBRE))
-                       sel_phy_idx = EXT_PHY2;
-       } else {
-
-               switch (bnx2x_phy_selection(&bp->link_params)) {
-               case PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT:
-               case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY:
-               case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY:
-                      sel_phy_idx = EXT_PHY1;
-                      break;
-               case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY:
-               case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY:
-                      sel_phy_idx = EXT_PHY2;
-                      break;
-               }
-       }
-       /*
-       * The selected actived PHY is always after swapping (in case PHY
-       * swapping is enabled). So when swapping is enabled, we need to reverse
-       * the configuration
-       */
-
-       if (bp->link_params.multi_phy_config &
-           PORT_HW_CFG_PHY_SWAPPED_ENABLED) {
-               if (sel_phy_idx == EXT_PHY1)
-                       sel_phy_idx = EXT_PHY2;
-               else if (sel_phy_idx == EXT_PHY2)
-                       sel_phy_idx = EXT_PHY1;
-       }
-       return LINK_CONFIG_IDX(sel_phy_idx);
-}
-
 void bnx2x_calc_fc_adv(struct bnx2x *bp)
 {
        u8 cfg_idx = bnx2x_get_link_cfg_idx(bp);
@@ -1941,8 +1907,12 @@ static void bnx2x_calc_vn_weight_sum(struct bnx2x *bp)
                bp->vn_weight_sum += vn_min_rate;
        }
 
-       /* ... only if all min rates are zeros - disable fairness */
-       if (all_zero) {
+       /* if ETS or all min rates are zeros - disable fairness */
+       if (BNX2X_IS_ETS_ENABLED(bp)) {
+               bp->cmng.flags.cmng_enables &=
+                                       ~CMNG_FLAGS_PER_PORT_FAIRNESS_VN;
+               DP(NETIF_MSG_IFUP, "Fairness will be disabled due to ETS\n");
+       } else if (all_zero) {
                bp->cmng.flags.cmng_enables &=
                                        ~CMNG_FLAGS_PER_PORT_FAIRNESS_VN;
                DP(NETIF_MSG_IFUP, "All MIN values are zeroes"
@@ -2222,12 +2192,13 @@ static void bnx2x_pmf_update(struct bnx2x *bp)
 u32 bnx2x_fw_command(struct bnx2x *bp, u32 command, u32 param)
 {
        int mb_idx = BP_FW_MB_IDX(bp);
-       u32 seq = ++bp->fw_seq;
+       u32 seq;
        u32 rc = 0;
        u32 cnt = 1;
        u8 delay = CHIP_REV_IS_SLOW(bp) ? 100 : 10;
 
        mutex_lock(&bp->fw_mb_mutex);
+       seq = ++bp->fw_seq;
        SHMEM_WR(bp, func_mb[mb_idx].drv_mb_param, param);
        SHMEM_WR(bp, func_mb[mb_idx].drv_mb_header, (command | seq));
 
@@ -2891,9 +2862,15 @@ static void bnx2x_attn_int_asserted(struct bnx2x *bp, u32 asserted)
 
                        /* save nig interrupt mask */
                        nig_mask = REG_RD(bp, nig_int_mask_addr);
-                       REG_WR(bp, nig_int_mask_addr, 0);
 
-                       bnx2x_link_attn(bp);
+                       /* If nig_mask is not set, no need to call the update
+                        * function.
+                        */
+                       if (nig_mask) {
+                               REG_WR(bp, nig_int_mask_addr, 0);
+
+                               bnx2x_link_attn(bp);
+                       }
 
                        /* handle unicore attn? */
                }
@@ -3809,12 +3786,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");
-               return;
-       }
-
        status = bnx2x_update_dsb_idx(bp);
 /*     if (status == 0)                                     */
 /*             BNX2X_ERR("spurious slowpath interrupt!\n"); */
@@ -3858,12 +3829,6 @@ irqreturn_t bnx2x_msix_sp_int(int irq, void *dev_instance)
        struct net_device *dev = dev_instance;
        struct bnx2x *bp = netdev_priv(dev);
 
-       /* 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");
-               return IRQ_HANDLED;
-       }
-
        bnx2x_ack_sb(bp, bp->igu_dsb_id, USTORM_ID, 0,
                     IGU_INT_DISABLE, 0);
 
@@ -3897,9 +3862,6 @@ static void bnx2x_timer(unsigned long data)
        if (!netif_running(bp->dev))
                return;
 
-       if (atomic_read(&bp->intr_sem) != 0)
-               goto timer_restart;
-
        if (poll) {
                struct bnx2x_fastpath *fp = &bp->fp[0];
 
@@ -3934,7 +3896,6 @@ static void bnx2x_timer(unsigned long data)
        if (bp->state == BNX2X_STATE_OPEN)
                bnx2x_stats_handle(bp, STATS_EVENT_UPDATE);
 
-timer_restart:
        mod_timer(&bp->timer, jiffies + bp->current_interval);
 }
 
@@ -4490,6 +4451,10 @@ void bnx2x_nic_init(struct bnx2x *bp, u32 load_code)
 
 #endif
 
+       /* Initialize MOD_ABS interrupts */
+       bnx2x_init_mod_abs_int(bp, &bp->link_vars, bp->common.chip_id,
+                              bp->common.shmem_base, bp->common.shmem2_base,
+                              BP_PORT(bp));
        /* ensure status block indices were read */
        rmb();
 
@@ -4504,9 +4469,6 @@ void bnx2x_nic_init(struct bnx2x *bp, u32 load_code)
        bnx2x_init_ind_table(bp);
        bnx2x_stats_init(bp);
 
-       /* At this point, we are ready for interrupts */
-       atomic_set(&bp->intr_sem, 0);
-
        /* flush all before enabling interrupts */
        mb();
        mmiowb();
@@ -6646,11 +6608,10 @@ static int bnx2x_setup_fw_client(struct bnx2x *bp,
  *
  * In case of MSI-X it will also try to enable MSI-X.
  */
-static int __devinit bnx2x_set_int_mode(struct bnx2x *bp)
+static void __devinit bnx2x_set_int_mode(struct bnx2x *bp)
 {
-       int rc = 0;
 
-       switch (bp->int_mode) {
+       switch (int_mode) {
        case INT_MODE_MSI:
                bnx2x_enable_msi(bp);
                /* falling through... */
@@ -6669,8 +6630,7 @@ static int __devinit bnx2x_set_int_mode(struct bnx2x *bp)
                 * so try to enable MSI-X with the requested number of fp's
                 * and fallback to MSI or legacy INTx with one fp
                 */
-               rc = bnx2x_enable_msix(bp);
-               if (rc) {
+               if (bnx2x_enable_msix(bp)) {
                        /* failed to enable MSI-X */
                        if (bp->multi_mode)
                                DP(NETIF_MSG_IFUP,
@@ -6681,14 +6641,12 @@ static int __devinit bnx2x_set_int_mode(struct bnx2x *bp)
                                   1 + NONE_ETH_CONTEXT_USE);
                        bp->num_queues = 1 + NONE_ETH_CONTEXT_USE;
 
+                       /* Try to enable MSI */
                        if (!(bp->flags & DISABLE_MSI_FLAG))
                                bnx2x_enable_msi(bp);
                }
-
                break;
        }
-
-       return rc;
 }
 
 /* must be called prioir to any HW initializations */
@@ -8682,10 +8640,6 @@ static int __devinit bnx2x_init_bp(struct bnx2x *bp)
        int timer_interval;
        int rc;
 
-       /* Disable interrupt handling until HW is initialized */
-       atomic_set(&bp->intr_sem, 1);
-       smp_wmb(); /* Ensure that bp->intr_sem update is SMP-safe */
-
        mutex_init(&bp->port.phy_mutex);
        mutex_init(&bp->fw_mb_mutex);
        spin_lock_init(&bp->stats_lock);
@@ -8717,7 +8671,6 @@ static int __devinit bnx2x_init_bp(struct bnx2x *bp)
                                        "must load devices in order!\n");
 
        bp->multi_mode = multi_mode;
-       bp->int_mode = int_mode;
 
        /* Set TPA flags */
        if (disable_tpa) {
@@ -10203,9 +10156,6 @@ static int bnx2x_register_cnic(struct net_device *dev, struct cnic_ops *ops,
        if (ops == NULL)
                return -EINVAL;
 
-       if (atomic_read(&bp->intr_sem) != 0)
-               return -EBUSY;
-
        bp->cnic_kwq = kzalloc(PAGE_SIZE, GFP_KERNEL);
        if (!bp->cnic_kwq)
                return -ENOMEM;