BNX2X: spatch ether->mtu -> ether->maxmtu
[akaros.git] / kern / drivers / net / bnx2x / bnx2x_main.c
index 7be287b..b82b545 100644 (file)
@@ -485,7 +485,7 @@ int bnx2x_issue_dmae_with_comp(struct bnx2x *bp, struct dmae_command *dmae,
         * from ndo_set_rx_mode() flow that may be called from BH.
         */
 
-       spin_lock_bh(&bp->dmae_lock);
+       spin_lock(&bp->dmae_lock);
 
        /* reset completion */
        *comp = 0;
@@ -514,7 +514,7 @@ int bnx2x_issue_dmae_with_comp(struct bnx2x *bp, struct dmae_command *dmae,
 
 unlock:
 
-       spin_unlock_bh(&bp->dmae_lock);
+       spin_unlock(&bp->dmae_lock);
 
        return rc;
 }
@@ -769,7 +769,8 @@ void bnx2x_fw_dump_lvl(struct bnx2x *bp, const char *lvl)
        /* dump buffer after the mark */
        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));
+                       data[word] = cpu_to_be32(REG_RD(bp,
+                                                offset + 4 * word));
                data[8] = 0x0;
                pr_cont("%s", (char *)data);
        }
@@ -777,7 +778,8 @@ void bnx2x_fw_dump_lvl(struct bnx2x *bp, const char *lvl)
        /* dump buffer before the mark */
        for (offset = addr + 4; offset <= mark; offset += 0x8*4) {
                for (word = 0; word < 8; word++)
-                       data[word] = htonl(REG_RD(bp, offset + 4*word));
+                       data[word] = cpu_to_be32(REG_RD(bp,
+                                                offset + 4 * word));
                data[8] = 0x0;
                pr_cont("%s", (char *)data);
        }
@@ -1547,7 +1549,7 @@ static void bnx2x_hc_int_enable(struct bnx2x *bp)
         * Ensure that HC_CONFIG is written before leading/trailing edge config
         */
        bus_wmb();
-       barrier();
+       cmb();
 
        if (!CHIP_IS_E1(bp)) {
                /* init leading/trailing edge */
@@ -1612,7 +1614,7 @@ static void bnx2x_igu_int_enable(struct bnx2x *bp)
        if (val & IGU_PF_CONF_INT_LINE_EN)
                pci_intx(bp->pdev, true);
 
-       barrier();
+       cmb();
 
        /* init leading/trailing edge */
        if (IS_MF(bp)) {
@@ -1656,7 +1658,7 @@ void bnx2x_int_disable_sync(struct bnx2x *bp, int disable_hw)
                for_each_eth_queue(bp, i)
                        synchronize_irq(bp->msix_table[offset++].vector);
        } else
-               synchronize_irq(bp->pdev->irq);
+               synchronize_irq(bp->pdev->irqline);
 
        /* make sure sp_task is not running */
        cancel_delayed_work(&bp->sp_task);
@@ -1749,7 +1751,7 @@ static int bnx2x_schedule_sp_task(struct bnx2x *bp)
         * is set, otherwise we will get out of sync and miss all
         * further interrupts. Hence, the barrier.
         */
-       smp_wmb();
+       wmb();
 
        /* schedule sp_task to workqueue */
        return queue_delayed_work(bnx2x_wq, &bp->sp_task, 0);
@@ -1832,10 +1834,10 @@ void bnx2x_sp_event(struct bnx2x_fastpath *fp, union eth_rx_cqe *rr_cqe)
                return;
 #endif
 
-       smp_mb__before_atomic();
+       cmb();
        atomic_inc(&bp->cq_spq_left);
        /* push the change in bp->spq_left and towards the memory */
-       smp_mb__after_atomic();
+       cmb();
 
        DP(BNX2X_MSG_SP, "bp->cq_spq_left %x\n", atomic_read(&bp->cq_spq_left));
 
@@ -1850,11 +1852,11 @@ void bnx2x_sp_event(struct bnx2x_fastpath *fp, union eth_rx_cqe *rr_cqe)
                 * sp_state is cleared, and this order prevents
                 * races
                 */
-               smp_mb__before_atomic();
+               cmb();
                set_bit(BNX2X_AFEX_PENDING_VIFSET_MCP_ACK, &bp->sp_state);
                wmb();
                clear_bit(BNX2X_AFEX_FCOE_Q_UPDATE_PENDING, &bp->sp_state);
-               smp_mb__after_atomic();
+               cmb();
 
                /* schedule the sp task as mcp ack is required */
                bnx2x_schedule_sp_task(bp);
@@ -2278,7 +2280,7 @@ static void bnx2x_set_requested_fc(struct bnx2x *bp)
         * It is recommended to turn off RX FC for jumbo frames
         *  for better performance
         */
-       if (CHIP_IS_E1x(bp) && (bp->dev->mtu > 5000))
+       if (CHIP_IS_E1x(bp) && (bp->dev->maxmtu > 5000))
                bp->link_params.req_fc_auto_adv = BNX2X_FLOW_CTRL_TX;
        else
                bp->link_params.req_fc_auto_adv = BNX2X_FLOW_CTRL_BOTH;
@@ -2934,7 +2936,7 @@ static void bnx2x_pmf_update(struct bnx2x *bp)
         * We need the mb() to ensure the ordering between the writing to
         * bp->port.pmf here and reading it from the bnx2x_periodic_task().
         */
-       smp_mb();
+       mb();
 
        /* queue a periodic task */
        queue_delayed_work(bnx2x_wq, &bp->period_task, 0);
@@ -3126,7 +3128,7 @@ static void bnx2x_pf_q_prep_general(struct bnx2x *bp,
        if (IS_FCOE_FP(fp))
                gen_init->mtu = BNX2X_FCOE_MINI_JUMBO_MTU;
        else
-               gen_init->mtu = bp->dev->mtu;
+               gen_init->mtu = bp->dev->maxmtu;
 
        gen_init->cos = cos;
 
@@ -3151,11 +3153,11 @@ static void bnx2x_pf_rx_q_prep(struct bnx2x *bp,
                                MAX_RX_SGE_CNT * NUM_RX_SGE_PAGES);
 
                tpa_agg_size = TPA_AGG_SIZE;
-               max_sge = SGE_PAGE_ALIGN(bp->dev->mtu) >>
+               max_sge = SGE_PAGE_ALIGN(bp->dev->maxmtu) >>
                        SGE_PAGE_SHIFT;
                max_sge = ((max_sge + PAGES_PER_SGE - 1) &
                          (~(PAGES_PER_SGE-1))) >> PAGES_PER_SGE_SHIFT;
-               sge_sz = (uint16_t)min_t(uint32_t, SGE_PAGES, 0xffff);
+               sge_sz = (uint16_t)MIN_T(uint32_t, SGE_PAGES, 0xffff);
        }
 
        /* pause - not for e1 */
@@ -3356,10 +3358,10 @@ static void bnx2x_drv_info_ether_stat(struct bnx2x *bp)
                                DRV_INFO_ETH_STAT_NUM_MACS_REQUIRED,
                                ether_stat->mac_local + MAC_PAD, MAC_PAD,
                                Eaddrlen);
-       ether_stat->mtu_size = bp->dev->mtu;
-       if (bp->dev->features & NETIF_F_RXCSUM)
+       ether_stat->mtu_size = bp->dev->maxmtu;
+       if (bp->dev->feat & NETIF_F_RXCSUM)
                ether_stat->feature_flags |= FEATURE_ETH_CHKSUM_OFFLOAD_MASK;
-       if (bp->dev->features & NETIF_F_TSO)
+       if (bp->dev->feat & NETIF_F_TSO)
                ether_stat->feature_flags |= FEATURE_ETH_LSO_MASK;
        ether_stat->feature_flags |= bp->common.boot_mode;
 
@@ -3810,18 +3812,18 @@ int bnx2x_sp_post(struct bnx2x *bp, int command, int cid,
        }
 #endif
 
-       spin_lock_bh(&bp->spq_lock);
+       spin_lock(&bp->spq_lock);
 
        if (common) {
                if (!atomic_read(&bp->eq_spq_left)) {
                        BNX2X_ERR("BUG! EQ ring full!\n");
-                       spin_unlock_bh(&bp->spq_lock);
+                       spin_unlock(&bp->spq_lock);
                        bnx2x_panic();
                        return -EBUSY;
                }
        } else if (!atomic_read(&bp->cq_spq_left)) {
                        BNX2X_ERR("BUG! SPQ ring full!\n");
-                       spin_unlock_bh(&bp->spq_lock);
+                       spin_unlock(&bp->spq_lock);
                        bnx2x_panic();
                        return -EBUSY;
        }
@@ -3870,7 +3872,7 @@ int bnx2x_sp_post(struct bnx2x *bp, int command, int cid,
           atomic_read(&bp->cq_spq_left), atomic_read(&bp->eq_spq_left));
 
        bnx2x_sp_prod_update(bp);
-       spin_unlock_bh(&bp->spq_lock);
+       spin_unlock(&bp->spq_lock);
        return 0;
 }
 
@@ -3911,7 +3913,7 @@ static uint16_t bnx2x_update_dsb_idx(struct bnx2x *bp)
        struct host_sp_status_block *def_sb = bp->def_status_blk;
        uint16_t rc = 0;
 
-       barrier(); /* status block is written to by the chip */
+       cmb(); /* status block is written to by the chip */
        if (bp->def_att_idx != def_sb->atten_status_block.attn_bits_index) {
                bp->def_att_idx = def_sb->atten_status_block.attn_bits_index;
                rc |= BNX2X_DEF_SB_ATT_IDX;
@@ -3923,7 +3925,7 @@ static uint16_t bnx2x_update_dsb_idx(struct bnx2x *bp)
        }
 
        /* Do not reorder: indices reading should complete before handling */
-       barrier();
+       cmb();
        return rc;
 }
 
@@ -4046,7 +4048,7 @@ static void bnx2x_attn_int_asserted(struct bnx2x *bp, uint32_t asserted)
                        if (!igu_acked)
                                DP(NETIF_MSG_HW,
                                   "Failed to verify IGU ack on time\n");
-                       barrier();
+                       cmb();
                }
                REG_WR(bp, nig_int_mask_addr, nig_mask);
                bnx2x_release_phy_lock(bp);
@@ -5195,7 +5197,7 @@ static void bnx2x_handle_mcast_eqe(struct bnx2x *bp)
 
        rparam.mcast_obj = &bp->mcast_obj;
 
-       netif_addr_lock_bh(bp->dev);
+       qlock(&bp->dev->qlock);
 
        /* Clear pending state for the last command */
        bp->mcast_obj.raw.clear_pending(&bp->mcast_obj.raw);
@@ -5208,7 +5210,7 @@ static void bnx2x_handle_mcast_eqe(struct bnx2x *bp)
                                  rc);
        }
 
-       netif_addr_unlock_bh(bp->dev);
+       qunlock(&bp->dev->qlock);
 }
 
 static void bnx2x_handle_classification_eqe(struct bnx2x *bp,
@@ -5257,7 +5259,7 @@ static void bnx2x_set_iscsi_eth_rx_mode(struct bnx2x *bp, bool start);
 
 static void bnx2x_handle_rx_mode_eqe(struct bnx2x *bp)
 {
-       netif_addr_lock_bh(bp->dev);
+       qlock(&bp->dev->qlock);
 
        clear_bit(BNX2X_FILTER_RX_MODE_PENDING, &bp->sp_state);
 
@@ -5271,7 +5273,7 @@ static void bnx2x_handle_rx_mode_eqe(struct bnx2x *bp)
                                    &bp->sp_state))
                bnx2x_set_iscsi_eth_rx_mode(bp, false);
 
-       netif_addr_unlock_bh(bp->dev);
+       qunlock(&bp->dev->qlock);
 }
 
 static void bnx2x_after_afex_vif_lists(struct bnx2x *bp,
@@ -5339,9 +5341,9 @@ static void bnx2x_after_function_update(struct bnx2x *bp)
                __clear_bit(RAMROD_COMP_WAIT, &queue_params.ramrod_flags);
 
                /* mark latest Q bit */
-               smp_mb__before_atomic();
+               cmb();
                set_bit(BNX2X_AFEX_FCOE_Q_UPDATE_PENDING, &bp->sp_state);
-               smp_mb__after_atomic();
+               cmb();
 
                /* send Q update ramrod for FCoE Q */
                rc = bnx2x_queue_state_change(bp, &queue_params);
@@ -5575,13 +5577,13 @@ next_spqe:
                spqe_cnt++;
        } /* for */
 
-       smp_mb__before_atomic();
+       cmb();
        atomic_add(spqe_cnt, &bp->eq_spq_left);
 
        bp->eq_cons = sw_cons;
        bp->eq_prod = sw_prod;
        /* Make sure that above mem writes were issued towards the memory */
-       smp_wmb();
+       wmb();
 
        /* update producer */
        bnx2x_update_eq_prod(bp, bp->eq_prod);
@@ -5594,7 +5596,7 @@ static void bnx2x_sp_task(struct work_struct *work)
        DP(BNX2X_MSG_SP, "sp task invoked\n");
 
        /* make sure the atomic interrupt_occurred has been written */
-       smp_rmb();
+       rmb();
        if (atomic_read(&bp->interrupt_occurred)) {
 
                /* what work needs to be performed? */
@@ -6035,7 +6037,7 @@ void bnx2x_update_coalesce(struct bnx2x *bp)
 
 static void bnx2x_init_sp_ring(struct bnx2x *bp)
 {
-       spin_lock_init(&bp->spq_lock);
+       spinlock_init_irqsave(&bp->spq_lock);
        atomic_set(&bp->cq_spq_left, MAX_SPQ_PENDING);
 
        bp->spq_prod_idx = 0;
@@ -6063,7 +6065,7 @@ static void bnx2x_init_eq_ring(struct bnx2x *bp)
        bp->eq_cons_sb = BNX2X_EQ_INDEX;
        /* we want a warning message before it gets wrought... */
        atomic_set(&bp->eq_spq_left,
-               min_t(int, MAX_SP_DESC_CNT - MAX_SPQ_PENDING, NUM_EQ_DESC) - 1);
+               MIN_T(int, MAX_SP_DESC_CNT - MAX_SPQ_PENDING, NUM_EQ_DESC) - 1);
 }
 
 /* called with netif_addr_lock_bh() */
@@ -6474,11 +6476,11 @@ void bnx2x_post_irq_nic_init(struct bnx2x *bp, uint32_t load_code)
 static int bnx2x_gunzip_init(struct bnx2x *bp)
 {
        bp->gunzip_buf = dma_alloc_coherent(&bp->pdev->dev, FW_BUF_SIZE,
-                                           &bp->gunzip_mapping, GFP_KERNEL);
+                                           &bp->gunzip_mapping, KMALLOC_WAIT);
        if (bp->gunzip_buf  == NULL)
                goto gunzip_nomem1;
 
-       bp->strm = kmalloc(sizeof(*bp->strm), GFP_KERNEL);
+       bp->strm = kmalloc(sizeof(*bp->strm), KMALLOC_WAIT);
        if (bp->strm  == NULL)
                goto gunzip_nomem2;
 
@@ -6815,7 +6817,7 @@ static void bnx2x_reset_common(struct bnx2x *bp)
 static void bnx2x_setup_dmae(struct bnx2x *bp)
 {
        bp->dmae_ready = 0;
-       spin_lock_init(&bp->dmae_lock);
+       spinlock_init_irqsave(&bp->dmae_lock);
 }
 
 static void bnx2x_init_pxp(struct bnx2x *bp)
@@ -7460,11 +7462,11 @@ static int bnx2x_init_hw_port(struct bnx2x *bp)
 
                if (IS_MF(bp))
                        low = ((bp->flags & ONE_PORT_FLAG) ? 160 : 246);
-               else if (bp->dev->mtu > 4096) {
+               else if (bp->dev->maxmtu > 4096) {
                        if (bp->flags & ONE_PORT_FLAG)
                                low = 160;
                        else {
-                               val = bp->dev->mtu;
+                               val = bp->dev->maxmtu;
                                /* (24*1024 + val*4)/256 */
                                low = 96 + (val/64) +
                                                ((val % 64) ? 1 : 0);
@@ -7678,12 +7680,12 @@ void bnx2x_igu_clear_sb_gen(struct bnx2x *bp, uint8_t func,
                         data, igu_addr_data);
        REG_WR(bp, igu_addr_data, data);
        bus_wmb();
-       barrier();
+       cmb();
        DP(NETIF_MSG_HW, "write 0x%08x to IGU(via GRC) addr 0x%x\n",
                          ctl, igu_addr_ctl);
        REG_WR(bp, igu_addr_ctl, ctl);
        bus_wmb();
-       barrier();
+       cmb();
 
        /* wait for clean up to finish */
        while (!(REG_RD(bp, igu_addr_ack) & sb_bit) && --cnt)
@@ -8273,7 +8275,7 @@ int bnx2x_alloc_mem(struct bnx2x *bp)
        context_size = sizeof(union cdu_context) * BNX2X_L2_CID_COUNT(bp);
 
        for (i = 0, allocated = 0; allocated < context_size; i++) {
-               bp->context[i].size = min(CDU_ILT_PAGE_SZ,
+               bp->context[i].size = MIN(CDU_ILT_PAGE_SZ,
                                          (context_size - allocated));
                bp->context[i].vcxt = BNX2X_PCI_ALLOC(&bp->context[i].cxt_mapping,
                                                      bp->context[i].size);
@@ -8281,8 +8283,8 @@ int bnx2x_alloc_mem(struct bnx2x *bp)
                        goto alloc_mem_err;
                allocated += bp->context[i].size;
        }
-       bp->ilt->lines = kcalloc(ILT_MAX_LINES, sizeof(struct ilt_line),
-                                GFP_KERNEL);
+       bp->ilt->lines = kzmalloc((ILT_MAX_LINES) * (sizeof(struct ilt_line)),
+                                 KMALLOC_WAIT);
        if (!bp->ilt->lines)
                goto alloc_mem_err;
 
@@ -8483,7 +8485,7 @@ void bnx2x_ilt_set_info(struct bnx2x *bp)
           ilt_client->end,
           ilt_client->page_size,
           ilt_client->flags,
-          ilog2(ilt_client->page_size >> 12));
+          LOG2_UP(ilt_client->page_size >> 12));
 
        /* QM */
        if (QM_INIT(bp->qm_cid_count)) {
@@ -8505,7 +8507,7 @@ void bnx2x_ilt_set_info(struct bnx2x *bp)
                   ilt_client->end,
                   ilt_client->page_size,
                   ilt_client->flags,
-                  ilog2(ilt_client->page_size >> 12));
+                  LOG2_UP(ilt_client->page_size >> 12));
        }
 
        if (CNIC_SUPPORT(bp)) {
@@ -8524,7 +8526,7 @@ void bnx2x_ilt_set_info(struct bnx2x *bp)
                   ilt_client->end,
                   ilt_client->page_size,
                   ilt_client->flags,
-                  ilog2(ilt_client->page_size >> 12));
+                  LOG2_UP(ilt_client->page_size >> 12));
 
                /* TM */
                ilt_client = &ilt->clients[ILT_CLIENT_TM];
@@ -8541,7 +8543,7 @@ void bnx2x_ilt_set_info(struct bnx2x *bp)
                   ilt_client->end,
                   ilt_client->page_size,
                   ilt_client->flags,
-                  ilog2(ilt_client->page_size >> 12));
+                  LOG2_UP(ilt_client->page_size >> 12));
        }
 
        BUG_ON(line > ILT_MAX_LINES);
@@ -9072,7 +9074,7 @@ static int bnx2x_func_wait_started(struct bnx2x *bp)
        if (msix)
                synchronize_irq(bp->msix_table[0].vector);
        else
-               synchronize_irq(bp->pdev->irq);
+               synchronize_irq(bp->pdev->irqline);
 
        flush_workqueue(bnx2x_wq);
        flush_workqueue(bnx2x_iov_wq);
@@ -9199,7 +9201,7 @@ void bnx2x_chip_cleanup(struct bnx2x *bp, int unload_mode, bool keep_link)
         * We need to take a netif_addr_lock() here in order to prevent
         * a race between the completion code and this code.
         */
-       netif_addr_lock_bh(bp->dev);
+       qlock(&bp->dev->qlock);
        /* Schedule the rx_mode command */
        if (test_bit(BNX2X_FILTER_RX_MODE_PENDING, &bp->sp_state))
                set_bit(BNX2X_FILTER_RX_MODE_SCHED, &bp->sp_state);
@@ -9212,7 +9214,7 @@ void bnx2x_chip_cleanup(struct bnx2x *bp, int unload_mode, bool keep_link)
        if (rc < 0)
                BNX2X_ERR("Failed to send DEL multicast command: %d\n", rc);
 
-       netif_addr_unlock_bh(bp->dev);
+       qunlock(&bp->dev->qlock);
 
        bnx2x_iov_chip_cleanup(bp);
 
@@ -9572,13 +9574,13 @@ static void bnx2x_process_kill_chip_reset(struct bnx2x *bp, bool global)
        REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_CLEAR,
               reset_mask1 & (~not_reset_mask1));
 
-       barrier();
+       cmb();
        bus_wmb();
 
        REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET,
               reset_mask2 & (~stay_reset2));
 
-       barrier();
+       cmb();
        bus_wmb();
 
        REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET, reset_mask1);
@@ -9651,7 +9653,7 @@ static int bnx2x_process_kill(struct bnx2x *bp, bool global)
                return -EAGAIN;
        }
 
-       barrier();
+       cmb();
 
        /* Close gates #2, #3 and #4 */
        bnx2x_set_234_gates(bp, true);
@@ -9664,7 +9666,7 @@ static int bnx2x_process_kill(struct bnx2x *bp, bool global)
 
        /* Clear "unprepared" bit */
        REG_WR(bp, MISC_REG_UNPREPARED, 0);
-       barrier();
+       cmb();
 
        /* Make sure all is written to the chip before the reset */
        bus_wmb();
@@ -9681,11 +9683,11 @@ static int bnx2x_process_kill(struct bnx2x *bp, bool global)
 
        /* PXP */
        bnx2x_pxp_prep(bp);
-       barrier();
+       cmb();
 
        /* reset the chip */
        bnx2x_process_kill_chip_reset(bp, global);
-       barrier();
+       cmb();
 
        /* clear errors in PGB */
        if (!CHIP_IS_E1x(bp))
@@ -9763,7 +9765,7 @@ exit_leader_reset2:
 exit_leader_reset:
        bp->is_leader = 0;
        bnx2x_release_leader_lock(bp);
-       smp_mb();
+       mb();
        return rc;
 }
 
@@ -9785,7 +9787,7 @@ static void bnx2x_recovery_failed(struct bnx2x *bp)
 
        bp->recovery_state = BNX2X_RECOVERY_FAILED;
 
-       smp_mb();
+       mb();
 }
 
 /*
@@ -9833,7 +9835,7 @@ static void bnx2x_parity_recover(struct bnx2x *bp)
                         * "recovery_state" update values are seen on other
                         * CPUs.
                         */
-                       smp_mb();
+                       mb();
                        break;
 
                case BNX2X_RECOVERY_WAIT:
@@ -9927,12 +9929,12 @@ static void bnx2x_parity_recover(struct bnx2x *bp)
                                                /* Shut down the power */
                                                bnx2x_set_power_state(
                                                        bp, PCI_D3hot);
-                                               smp_mb();
+                                               mb();
                                        } else {
                                                bp->recovery_state =
                                                        BNX2X_RECOVERY_DONE;
                                                error_recovered++;
-                                               smp_mb();
+                                               mb();
                                        }
                                        bp->eth_stats.recoverable_error =
                                                error_recovered;
@@ -9975,7 +9977,7 @@ static void bnx2x_sp_rtnl_task(struct work_struct *work)
                 * function anyway.
                 */
                bp->sp_rtnl_state = 0;
-               smp_mb();
+               mb();
 
                bnx2x_parity_recover(bp);
 
@@ -9995,7 +9997,7 @@ static void bnx2x_sp_rtnl_task(struct work_struct *work)
                 * function anyway.
                 */
                bp->sp_rtnl_state = 0;
-               smp_mb();
+               mb();
 
                bnx2x_nic_unload(bp, UNLOAD_NORMAL, true);
                bnx2x_nic_load(bp, LOAD_NORMAL);
@@ -10085,7 +10087,7 @@ static void bnx2x_period_task(struct work_struct *work)
         * the bp->port.pmf in the bnx2x_nic_load() or bnx2x_pmf_update() and
         * the reading here.
         */
-       smp_mb();
+       mb();
        if (bp->port.pmf) {
                bnx2x_period_func(&bp->link_params, &bp->link_vars);
 
@@ -10351,7 +10353,7 @@ static int bnx2x_prev_mark_path(struct bnx2x *bp, bool after_undi)
        up(&bnx2x_prev_sem);
 
        /* Create an entry for this path and add it */
-       tmp_list = kmalloc(sizeof(struct bnx2x_prev_path_list), GFP_KERNEL);
+       tmp_list = kmalloc(sizeof(struct bnx2x_prev_path_list), KMALLOC_WAIT);
        if (!tmp_list) {
                BNX2X_ERR("Failed to allocate 'bnx2x_prev_path_list'\n");
                return -ENOMEM;
@@ -10879,7 +10881,7 @@ static int bnx2x_get_igu_cam_info(struct bnx2x *bp)
         * Driver should use the minimal value of both as the actual status
         * block count
         */
-       bp->igu_sb_cnt = min_t(int, bp->igu_sb_cnt, igu_sb_cnt);
+       bp->igu_sb_cnt = MIN_T(int, bp->igu_sb_cnt, igu_sb_cnt);
 #endif
 
        if (igu_sb_cnt == 0) {
@@ -11851,7 +11853,7 @@ static int bnx2x_get_hwinfo(struct bnx2x *bp)
 
        /* adjust igu_sb_cnt to MF for E1H */
        if (CHIP_IS_E1H(bp) && IS_MF(bp))
-               bp->igu_sb_cnt = min_t(uint8_t, bp->igu_sb_cnt,
+               bp->igu_sb_cnt = MIN_T(uint8_t, bp->igu_sb_cnt,
                                       E1H_MAX_MF_SB_COUNT);
 
        /* port info */
@@ -11895,7 +11897,7 @@ static void bnx2x_read_fwinfo(struct bnx2x *bp)
        i += PCI_VPD_LRDT_TAG_SIZE;
 
        if (block_end > BNX2X_VPD_LEN) {
-               vpd_extended_data = kmalloc(block_end, GFP_KERNEL);
+               vpd_extended_data = kmalloc(block_end, KMALLOC_WAIT);
                if (vpd_extended_data  == NULL)
                        goto out_not_found;
 
@@ -12009,7 +12011,7 @@ static int bnx2x_init_bp(struct bnx2x *bp)
        mutex_init(&bp->fw_mb_mutex);
        mutex_init(&bp->drv_info_mutex);
        bp->drv_info_mng_owner = false;
-       spin_lock_init(&bp->stats_lock);
+       spinlock_init_irqsave(&bp->stats_lock);
        sema_init(&bp->stats_sema, 1);
 
        INIT_DELAYED_WORK(&bp->sp_task, bnx2x_sp_task);
@@ -12063,10 +12065,10 @@ static int bnx2x_init_bp(struct bnx2x *bp)
        /* Set TPA flags */
        if (bp->disable_tpa) {
                bp->flags &= ~(TPA_ENABLE_FLAG | GRO_ENABLE_FLAG);
-               bp->dev->features &= ~NETIF_F_LRO;
+               bp->dev->feat &= ~NETIF_F_LRO;
        } else {
                bp->flags |= (TPA_ENABLE_FLAG | GRO_ENABLE_FLAG);
-               bp->dev->features |= NETIF_F_LRO;
+               bp->dev->feat |= NETIF_F_LRO;
        }
 
        if (CHIP_IS_E1(bp))
@@ -12233,7 +12235,7 @@ static int bnx2x_init_mcast_macs_list(struct bnx2x *bp,
 {
        int mc_count = netdev_mc_count(bp->dev);
        struct bnx2x_mcast_list_elem *mc_mac =
-               kcalloc(mc_count, sizeof(*mc_mac), GFP_ATOMIC);
+               kzmalloc((mc_count) * (sizeof(*mc_mac)), 0);
        struct netdev_hw_addr *ha;
 
        if (!mc_mac)
@@ -12366,7 +12368,7 @@ void bnx2x_set_rx_mode_inner(struct bnx2x *bp)
 
        DP(NETIF_MSG_IFUP, "dev->flags = %x\n", bp->dev->flags);
 
-       netif_addr_lock_bh(bp->dev);
+       qlock(&bp->dev->qlock);
 
        if (bp->dev->flags & IFF_PROMISC) {
                rx_mode = BNX2X_RX_MODE_PROMISC;
@@ -12381,10 +12383,10 @@ void bnx2x_set_rx_mode_inner(struct bnx2x *bp)
                                rx_mode = BNX2X_RX_MODE_ALLMULTI;
 
                        /* release bh lock, as bnx2x_set_uc_list might sleep */
-                       netif_addr_unlock_bh(bp->dev);
+                       qunlock(&bp->dev->qlock);
                        if (bnx2x_set_uc_list(bp) < 0)
                                rx_mode = BNX2X_RX_MODE_PROMISC;
-                       netif_addr_lock_bh(bp->dev);
+                       qlock(&bp->dev->qlock);
                } else {
                        /* configuring mcast to a vf involves sleeping (when we
                         * wait for the pf's response).
@@ -12402,19 +12404,19 @@ void bnx2x_set_rx_mode_inner(struct bnx2x *bp)
        /* Schedule the rx_mode command */
        if (test_bit(BNX2X_FILTER_RX_MODE_PENDING, &bp->sp_state)) {
                set_bit(BNX2X_FILTER_RX_MODE_SCHED, &bp->sp_state);
-               netif_addr_unlock_bh(bp->dev);
+               qunlock(&bp->dev->qlock);
                return;
        }
 
        if (IS_PF(bp)) {
                bnx2x_set_storm_rx_mode(bp);
-               netif_addr_unlock_bh(bp->dev);
+               qunlock(&bp->dev->qlock);
        } else {
                /* VF will need to request the PF to make this change, and so
                 * the VF needs to release the bottom-half lock prior to the
                 * request (as it will likely require sleep on the VF side)
                 */
-               netif_addr_unlock_bh(bp->dev);
+               qunlock(&bp->dev->qlock);
                bnx2x_vfpf_storm_rx_mode(bp);
        }
 }
@@ -12663,7 +12665,7 @@ static int bnx2x_init_dev(struct bnx2x *bp, struct pci_device *pdev,
        dev->base_addr = dev->mem_start;
        dev->mem_end = pci_resource_end(pdev, 0);
 
-       dev->irq = pdev->irq;
+       dev->irq = pdev->irqline;
 
        bp->regview = pci_ioremap_bar(pdev, 0);
        if (!bp->regview) {
@@ -12740,19 +12742,10 @@ static int bnx2x_init_dev(struct bnx2x *bp, struct pci_device *pdev,
        if (!CHIP_IS_E1x(bp)) {
                dev->hw_features |= NETIF_F_GSO_GRE | NETIF_F_GSO_UDP_TUNNEL |
                                    NETIF_F_GSO_IPIP | NETIF_F_GSO_SIT;
-               dev->hw_enc_features =
-                       NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_SG |
-                       NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6 |
-                       NETIF_F_GSO_IPIP |
-                       NETIF_F_GSO_SIT |
-                       NETIF_F_GSO_GRE | NETIF_F_GSO_UDP_TUNNEL;
        }
 
-       dev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
-               NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6 | NETIF_F_HIGHDMA;
-
-       dev->features |= dev->hw_features | NETIF_F_HW_VLAN_CTAG_RX;
-       dev->features |= NETIF_F_HIGHDMA;
+       dev->feat |= dev->hw_features | NETIF_F_HW_VLAN_CTAG_RX;
+       dev->feat |= NETIF_F_HIGHDMA;
 
        /* Add Loopback capability to the device */
        dev->hw_features |= NETIF_F_LOOPBACK;
@@ -12910,7 +12903,7 @@ static void be16_to_cpu_n(const uint8_t *_source, uint8_t *_target,
 #define BNX2X_ALLOC_AND_SET(arr, lbl, func)                            \
 do {                                                                   \
        uint32_t len = be32_to_cpu(fw_hdr->arr.len);                            \
-       bp->arr = kmalloc(len, GFP_KERNEL);                             \
+       bp->arr = kmalloc(len, KMALLOC_WAIT);                           \
        if (!bp->arr)                                                   \
                goto lbl;                                               \
        func(bp->firmware->data + be32_to_cpu(fw_hdr->arr.offset),      \
@@ -13171,7 +13164,7 @@ static int bnx2x_send_update_drift_ramrod(struct bnx2x *bp, int drift_dir,
        return bnx2x_func_state_change(bp, &func_params);
 }
 
-static int bnx2x_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
+static int bnx2x_ptp_adjfreq(struct ptp_clock_info *ptp, int32_t ppb)
 {
        struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info);
        int rc;
@@ -13239,7 +13232,7 @@ static int bnx2x_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
        return 0;
 }
 
-static int bnx2x_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
+static int bnx2x_ptp_adjtime(struct ptp_clock_info *ptp, int64_t delta)
 {
        struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info);
        uint64_t now;
@@ -13489,7 +13482,7 @@ static int bnx2x_init_one(struct pci_device *pdev,
                       pcie_speed == PCIE_SPEED_5_0GT ? "5.0GHz" :
                       pcie_speed == PCIE_SPEED_8_0GT ? "8.0GHz" :
                       "Unknown",
-                      dev->base_addr, bp->pdev->irq, dev->dev_addr);
+                      dev->base_addr, bp->pdev->irqline, dev->dev_addr);
 
        bnx2x_register_phc(bp);
 
@@ -13644,9 +13637,9 @@ static int bnx2x_eeh_nic_unload(struct bnx2x *bp)
        cancel_delayed_work_sync(&bp->sp_task);
        cancel_delayed_work_sync(&bp->period_task);
 
-       spin_lock_bh(&bp->stats_lock);
+       spin_lock(&bp->stats_lock);
        bp->stats_state = STATS_STATE_DISABLED;
-       spin_unlock_bh(&bp->stats_lock);
+       spin_unlock(&bp->stats_lock);
 
        bnx2x_save_statistics(bp);
 
@@ -13932,7 +13925,7 @@ static void bnx2x_cnic_sp_post(struct bnx2x *bp, int count)
                return;
 #endif
 
-       spin_lock_bh(&bp->spq_lock);
+       spin_lock(&bp->spq_lock);
        BUG_ON(bp->cnic_spq_pending < count);
        bp->cnic_spq_pending -= count;
 
@@ -14000,7 +13993,7 @@ static void bnx2x_cnic_sp_post(struct bnx2x *bp, int count)
                        bp->cnic_kwq_cons++;
        }
        bnx2x_sp_prod_update(bp);
-       spin_unlock_bh(&bp->spq_lock);
+       spin_unlock(&bp->spq_lock);
 }
 
 static int bnx2x_cnic_sp_queue(struct ether *dev,
@@ -14022,7 +14015,7 @@ static int bnx2x_cnic_sp_queue(struct ether *dev,
                return -EAGAIN;
        }
 
-       spin_lock_bh(&bp->spq_lock);
+       spin_lock(&bp->spq_lock);
 
        for (i = 0; i < count; i++) {
                struct eth_spe *spe = (struct eth_spe *)kwqes[i];
@@ -14046,7 +14039,7 @@ static int bnx2x_cnic_sp_queue(struct ether *dev,
                        bp->cnic_kwq_prod++;
        }
 
-       spin_unlock_bh(&bp->spq_lock);
+       spin_unlock(&bp->spq_lock);
 
        if (bp->cnic_spq_pending < bp->cnic_eth_dev.max_kwqe_pending)
                bnx2x_cnic_sp_post(bp, 0);
@@ -14190,13 +14183,13 @@ static int bnx2x_drv_ctl(struct ether *dev, struct drv_ctl_info *ctl)
                        break;
 
                bus_wmb();
-               barrier();
+               cmb();
 
                /* Start accepting on iSCSI L2 ring */
 
-               netif_addr_lock_bh(dev);
+               qlock(&dev->qlock);
                bnx2x_set_iscsi_eth_rx_mode(bp, true);
-               netif_addr_unlock_bh(dev);
+               qunlock(&dev->qlock);
 
                /* bits to wait on */
                __set_bit(BNX2X_FILTER_RX_MODE_PENDING, &sp_bits);
@@ -14213,9 +14206,9 @@ static int bnx2x_drv_ctl(struct ether *dev, struct drv_ctl_info *ctl)
                unsigned long sp_bits = 0;
 
                /* Stop accepting on iSCSI L2 ring */
-               netif_addr_lock_bh(dev);
+               qlock(&dev->qlock);
                bnx2x_set_iscsi_eth_rx_mode(bp, false);
-               netif_addr_unlock_bh(dev);
+               qunlock(&dev->qlock);
 
                /* bits to wait on */
                __set_bit(BNX2X_FILTER_RX_MODE_PENDING, &sp_bits);
@@ -14225,7 +14218,7 @@ static int bnx2x_drv_ctl(struct ether *dev, struct drv_ctl_info *ctl)
                        BNX2X_ERR("rx_mode completion timed out!\n");
 
                bus_wmb();
-               barrier();
+               cmb();
 
                /* Unset iSCSI L2 MAC */
                rc = bnx2x_del_all_macs(bp, &bp->iscsi_l2_mac_obj,
@@ -14235,9 +14228,9 @@ static int bnx2x_drv_ctl(struct ether *dev, struct drv_ctl_info *ctl)
        case DRV_CTL_RET_L2_SPQ_CREDIT_CMD: {
                int count = ctl->data.credit.credit_count;
 
-               smp_mb__before_atomic();
+               cmb();
                atomic_add(count, &bp->cq_spq_left);
-               smp_mb__after_atomic();
+               cmb();
                break;
        }
        case DRV_CTL_ULP_REGISTER_CMD: {
@@ -14380,7 +14373,7 @@ static int bnx2x_register_cnic(struct ether *dev, struct cnic_ops *ops,
 
        bp->cnic_enabled = true;
 
-       bp->cnic_kwq = kzalloc(PAGE_SIZE, GFP_KERNEL);
+       bp->cnic_kwq = kzmalloc(PAGE_SIZE, KMALLOC_WAIT);
        if (!bp->cnic_kwq)
                return -ENOMEM;
 
@@ -14738,7 +14731,7 @@ static int bnx2x_hwtstamp_ioctl(struct bnx2x *bp, struct ifreq *ifr)
 
        DP(BNX2X_MSG_PTP, "HWTSTAMP IOCTL called\n");
 
-       if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
+       if (memcpy_from_user(current, &config, ifr->ifr_data, sizeof(config)))
                return -EFAULT;
 
        DP(BNX2X_MSG_PTP, "Requested tx_type: %d, requested rx_filters = %d\n",
@@ -14759,7 +14752,7 @@ static int bnx2x_hwtstamp_ioctl(struct bnx2x *bp, struct ifreq *ifr)
 
        config.rx_filter = bp->rx_filter;
 
-       return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
+       return memcpy_to_user(current, ifr->ifr_data, &config, sizeof(config)) ?
                -EFAULT : 0;
 }
 
@@ -14830,7 +14823,7 @@ void bnx2x_init_ptp(struct bnx2x *bp)
        if (!bp->timecounter_init_done) {
                bnx2x_init_cyclecounter(bp);
                timecounter_init(&bp->timecounter, &bp->cyclecounter,
-                                ktime_to_ns(ktime_get_real()));
+                                epoch_nsec());
                bp->timecounter_init_done = 1;
        }