aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2016-03-01 15:37:02 -0500
committerDavid S. Miller <davem@davemloft.net>2016-03-01 15:37:02 -0500
commit46d5efa9a6abe2345472bff93a02480b308d3141 (patch)
treedd4f899011b8727f67c9cfb1bf0d65161c7d9a5c
parent0c92c9490be49acbdb9accedc411b8c07a2cf937 (diff)
parent90e209213096110bce06ef580e1c73702fe4a288 (diff)
Merge branch 'bnxt_en-next'
Michael Chan says: ==================== bnxt_en: updates for net-next. Miscellaneous updates covering SRIOV, IRQ coalescing, firmware logging and package version for net-next. Thanks. v2: Updated description and added more comments for patch 1. Fixed function parameters formatting for patch 4. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt.c166
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt.h35
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c126
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt_nvm_defs.h14
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c63
5 files changed, 313 insertions, 91 deletions
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index ff1507f3e226..aa6a3189caca 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -1239,13 +1239,17 @@ static int bnxt_async_event_process(struct bnxt *bp,
1239 switch (event_id) { 1239 switch (event_id) {
1240 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE: 1240 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE:
1241 set_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event); 1241 set_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event);
1242 schedule_work(&bp->sp_task); 1242 break;
1243 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD:
1244 set_bit(BNXT_HWRM_PF_UNLOAD_SP_EVENT, &bp->sp_event);
1243 break; 1245 break;
1244 default: 1246 default:
1245 netdev_err(bp->dev, "unhandled ASYNC event (id 0x%x)\n", 1247 netdev_err(bp->dev, "unhandled ASYNC event (id 0x%x)\n",
1246 event_id); 1248 event_id);
1247 break; 1249 goto async_event_process_exit;
1248 } 1250 }
1251 schedule_work(&bp->sp_task);
1252async_event_process_exit:
1249 return 0; 1253 return 0;
1250} 1254}
1251 1255
@@ -2596,28 +2600,27 @@ alloc_mem_err:
2596void bnxt_hwrm_cmd_hdr_init(struct bnxt *bp, void *request, u16 req_type, 2600void bnxt_hwrm_cmd_hdr_init(struct bnxt *bp, void *request, u16 req_type,
2597 u16 cmpl_ring, u16 target_id) 2601 u16 cmpl_ring, u16 target_id)
2598{ 2602{
2599 struct hwrm_cmd_req_hdr *req = request; 2603 struct input *req = request;
2600 2604
2601 req->cmpl_ring_req_type = 2605 req->req_type = cpu_to_le16(req_type);
2602 cpu_to_le32(req_type | (cmpl_ring << HWRM_CMPL_RING_SFT)); 2606 req->cmpl_ring = cpu_to_le16(cmpl_ring);
2603 req->target_id_seq_id = cpu_to_le32(target_id << HWRM_TARGET_FID_SFT); 2607 req->target_id = cpu_to_le16(target_id);
2604 req->resp_addr = cpu_to_le64(bp->hwrm_cmd_resp_dma_addr); 2608 req->resp_addr = cpu_to_le64(bp->hwrm_cmd_resp_dma_addr);
2605} 2609}
2606 2610
2607int _hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout) 2611static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len,
2612 int timeout, bool silent)
2608{ 2613{
2609 int i, intr_process, rc; 2614 int i, intr_process, rc;
2610 struct hwrm_cmd_req_hdr *req = msg; 2615 struct input *req = msg;
2611 u32 *data = msg; 2616 u32 *data = msg;
2612 __le32 *resp_len, *valid; 2617 __le32 *resp_len, *valid;
2613 u16 cp_ring_id, len = 0; 2618 u16 cp_ring_id, len = 0;
2614 struct hwrm_err_output *resp = bp->hwrm_cmd_resp_addr; 2619 struct hwrm_err_output *resp = bp->hwrm_cmd_resp_addr;
2615 2620
2616 req->target_id_seq_id |= cpu_to_le32(bp->hwrm_cmd_seq++); 2621 req->seq_id = cpu_to_le16(bp->hwrm_cmd_seq++);
2617 memset(resp, 0, PAGE_SIZE); 2622 memset(resp, 0, PAGE_SIZE);
2618 cp_ring_id = (le32_to_cpu(req->cmpl_ring_req_type) & 2623 cp_ring_id = le16_to_cpu(req->cmpl_ring);
2619 HWRM_CMPL_RING_MASK) >>
2620 HWRM_CMPL_RING_SFT;
2621 intr_process = (cp_ring_id == INVALID_HW_RING_ID) ? 0 : 1; 2624 intr_process = (cp_ring_id == INVALID_HW_RING_ID) ? 0 : 1;
2622 2625
2623 /* Write request msg to hwrm channel */ 2626 /* Write request msg to hwrm channel */
@@ -2628,12 +2631,14 @@ int _hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout)
2628 2631
2629 /* currently supports only one outstanding message */ 2632 /* currently supports only one outstanding message */
2630 if (intr_process) 2633 if (intr_process)
2631 bp->hwrm_intr_seq_id = le32_to_cpu(req->target_id_seq_id) & 2634 bp->hwrm_intr_seq_id = le16_to_cpu(req->seq_id);
2632 HWRM_SEQ_ID_MASK;
2633 2635
2634 /* Ring channel doorbell */ 2636 /* Ring channel doorbell */
2635 writel(1, bp->bar0 + 0x100); 2637 writel(1, bp->bar0 + 0x100);
2636 2638
2639 if (!timeout)
2640 timeout = DFLT_HWRM_CMD_TIMEOUT;
2641
2637 i = 0; 2642 i = 0;
2638 if (intr_process) { 2643 if (intr_process) {
2639 /* Wait until hwrm response cmpl interrupt is processed */ 2644 /* Wait until hwrm response cmpl interrupt is processed */
@@ -2644,7 +2649,7 @@ int _hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout)
2644 2649
2645 if (bp->hwrm_intr_seq_id != HWRM_SEQ_ID_INVALID) { 2650 if (bp->hwrm_intr_seq_id != HWRM_SEQ_ID_INVALID) {
2646 netdev_err(bp->dev, "Resp cmpl intr err msg: 0x%x\n", 2651 netdev_err(bp->dev, "Resp cmpl intr err msg: 0x%x\n",
2647 req->cmpl_ring_req_type); 2652 le16_to_cpu(req->req_type));
2648 return -1; 2653 return -1;
2649 } 2654 }
2650 } else { 2655 } else {
@@ -2660,8 +2665,8 @@ int _hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout)
2660 2665
2661 if (i >= timeout) { 2666 if (i >= timeout) {
2662 netdev_err(bp->dev, "Error (timeout: %d) msg {0x%x 0x%x} len:%d\n", 2667 netdev_err(bp->dev, "Error (timeout: %d) msg {0x%x 0x%x} len:%d\n",
2663 timeout, req->cmpl_ring_req_type, 2668 timeout, le16_to_cpu(req->req_type),
2664 req->target_id_seq_id, *resp_len); 2669 le16_to_cpu(req->seq_id), *resp_len);
2665 return -1; 2670 return -1;
2666 } 2671 }
2667 2672
@@ -2675,20 +2680,23 @@ int _hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout)
2675 2680
2676 if (i >= timeout) { 2681 if (i >= timeout) {
2677 netdev_err(bp->dev, "Error (timeout: %d) msg {0x%x 0x%x} len:%d v:%d\n", 2682 netdev_err(bp->dev, "Error (timeout: %d) msg {0x%x 0x%x} len:%d v:%d\n",
2678 timeout, req->cmpl_ring_req_type, 2683 timeout, le16_to_cpu(req->req_type),
2679 req->target_id_seq_id, len, *valid); 2684 le16_to_cpu(req->seq_id), len, *valid);
2680 return -1; 2685 return -1;
2681 } 2686 }
2682 } 2687 }
2683 2688
2684 rc = le16_to_cpu(resp->error_code); 2689 rc = le16_to_cpu(resp->error_code);
2685 if (rc) { 2690 if (rc && !silent)
2686 netdev_err(bp->dev, "hwrm req_type 0x%x seq id 0x%x error 0x%x\n", 2691 netdev_err(bp->dev, "hwrm req_type 0x%x seq id 0x%x error 0x%x\n",
2687 le16_to_cpu(resp->req_type), 2692 le16_to_cpu(resp->req_type),
2688 le16_to_cpu(resp->seq_id), rc); 2693 le16_to_cpu(resp->seq_id), rc);
2689 return rc; 2694 return rc;
2690 } 2695}
2691 return 0; 2696
2697int _hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout)
2698{
2699 return bnxt_hwrm_do_send_msg(bp, msg, msg_len, timeout, false);
2692} 2700}
2693 2701
2694int hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout) 2702int hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout)
@@ -2701,6 +2709,17 @@ int hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout)
2701 return rc; 2709 return rc;
2702} 2710}
2703 2711
2712int hwrm_send_message_silent(struct bnxt *bp, void *msg, u32 msg_len,
2713 int timeout)
2714{
2715 int rc;
2716
2717 mutex_lock(&bp->hwrm_cmd_lock);
2718 rc = bnxt_hwrm_do_send_msg(bp, msg, msg_len, timeout, true);
2719 mutex_unlock(&bp->hwrm_cmd_lock);
2720 return rc;
2721}
2722
2704static int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp) 2723static int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp)
2705{ 2724{
2706 struct hwrm_func_drv_rgtr_input req = {0}; 2725 struct hwrm_func_drv_rgtr_input req = {0};
@@ -3517,47 +3536,82 @@ static void bnxt_hwrm_ring_free(struct bnxt *bp, bool close_path)
3517 } 3536 }
3518} 3537}
3519 3538
3539static void bnxt_hwrm_set_coal_params(struct bnxt *bp, u32 max_bufs,
3540 u32 buf_tmrs, u16 flags,
3541 struct hwrm_ring_cmpl_ring_cfg_aggint_params_input *req)
3542{
3543 req->flags = cpu_to_le16(flags);
3544 req->num_cmpl_dma_aggr = cpu_to_le16((u16)max_bufs);
3545 req->num_cmpl_dma_aggr_during_int = cpu_to_le16(max_bufs >> 16);
3546 req->cmpl_aggr_dma_tmr = cpu_to_le16((u16)buf_tmrs);
3547 req->cmpl_aggr_dma_tmr_during_int = cpu_to_le16(buf_tmrs >> 16);
3548 /* Minimum time between 2 interrupts set to buf_tmr x 2 */
3549 req->int_lat_tmr_min = cpu_to_le16((u16)buf_tmrs * 2);
3550 req->int_lat_tmr_max = cpu_to_le16((u16)buf_tmrs * 4);
3551 req->num_cmpl_aggr_int = cpu_to_le16((u16)max_bufs * 4);
3552}
3553
3520int bnxt_hwrm_set_coal(struct bnxt *bp) 3554int bnxt_hwrm_set_coal(struct bnxt *bp)
3521{ 3555{
3522 int i, rc = 0; 3556 int i, rc = 0;
3523 struct hwrm_ring_cmpl_ring_cfg_aggint_params_input req = {0}; 3557 struct hwrm_ring_cmpl_ring_cfg_aggint_params_input req_rx = {0},
3558 req_tx = {0}, *req;
3524 u16 max_buf, max_buf_irq; 3559 u16 max_buf, max_buf_irq;
3525 u16 buf_tmr, buf_tmr_irq; 3560 u16 buf_tmr, buf_tmr_irq;
3526 u32 flags; 3561 u32 flags;
3527 3562
3528 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS, 3563 bnxt_hwrm_cmd_hdr_init(bp, &req_rx,
3529 -1, -1); 3564 HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS, -1, -1);
3565 bnxt_hwrm_cmd_hdr_init(bp, &req_tx,
3566 HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS, -1, -1);
3530 3567
3531 /* Each rx completion (2 records) should be DMAed immediately */ 3568 /* Each rx completion (2 records) should be DMAed immediately.
3532 max_buf = min_t(u16, bp->coal_bufs / 4, 2); 3569 * DMA 1/4 of the completion buffers at a time.
3570 */
3571 max_buf = min_t(u16, bp->rx_coal_bufs / 4, 2);
3533 /* max_buf must not be zero */ 3572 /* max_buf must not be zero */
3534 max_buf = clamp_t(u16, max_buf, 1, 63); 3573 max_buf = clamp_t(u16, max_buf, 1, 63);
3535 max_buf_irq = clamp_t(u16, bp->coal_bufs_irq, 1, 63); 3574 max_buf_irq = clamp_t(u16, bp->rx_coal_bufs_irq, 1, 63);
3536 buf_tmr = max_t(u16, bp->coal_ticks / 4, 1); 3575 buf_tmr = BNXT_USEC_TO_COAL_TIMER(bp->rx_coal_ticks);
3537 buf_tmr_irq = max_t(u16, bp->coal_ticks_irq, 1); 3576 /* buf timer set to 1/4 of interrupt timer */
3577 buf_tmr = max_t(u16, buf_tmr / 4, 1);
3578 buf_tmr_irq = BNXT_USEC_TO_COAL_TIMER(bp->rx_coal_ticks_irq);
3579 buf_tmr_irq = max_t(u16, buf_tmr_irq, 1);
3538 3580
3539 flags = RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_FLAGS_TIMER_RESET; 3581 flags = RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_FLAGS_TIMER_RESET;
3540 3582
3541 /* RING_IDLE generates more IRQs for lower latency. Enable it only 3583 /* RING_IDLE generates more IRQs for lower latency. Enable it only
3542 * if coal_ticks is less than 25 us. 3584 * if coal_ticks is less than 25 us.
3543 */ 3585 */
3544 if (BNXT_COAL_TIMER_TO_USEC(bp->coal_ticks) < 25) 3586 if (bp->rx_coal_ticks < 25)
3545 flags |= RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_FLAGS_RING_IDLE; 3587 flags |= RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_FLAGS_RING_IDLE;
3546 3588
3547 req.flags = cpu_to_le16(flags); 3589 bnxt_hwrm_set_coal_params(bp, max_buf_irq << 16 | max_buf,
3548 req.num_cmpl_dma_aggr = cpu_to_le16(max_buf); 3590 buf_tmr_irq << 16 | buf_tmr, flags, &req_rx);
3549 req.num_cmpl_dma_aggr_during_int = cpu_to_le16(max_buf_irq); 3591
3550 req.cmpl_aggr_dma_tmr = cpu_to_le16(buf_tmr); 3592 /* max_buf must not be zero */
3551 req.cmpl_aggr_dma_tmr_during_int = cpu_to_le16(buf_tmr_irq); 3593 max_buf = clamp_t(u16, bp->tx_coal_bufs, 1, 63);
3552 req.int_lat_tmr_min = cpu_to_le16(buf_tmr); 3594 max_buf_irq = clamp_t(u16, bp->tx_coal_bufs_irq, 1, 63);
3553 req.int_lat_tmr_max = cpu_to_le16(bp->coal_ticks); 3595 buf_tmr = BNXT_USEC_TO_COAL_TIMER(bp->tx_coal_ticks);
3554 req.num_cmpl_aggr_int = cpu_to_le16(bp->coal_bufs); 3596 /* buf timer set to 1/4 of interrupt timer */
3597 buf_tmr = max_t(u16, buf_tmr / 4, 1);
3598 buf_tmr_irq = BNXT_USEC_TO_COAL_TIMER(bp->tx_coal_ticks_irq);
3599 buf_tmr_irq = max_t(u16, buf_tmr_irq, 1);
3600
3601 flags = RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_FLAGS_TIMER_RESET;
3602 bnxt_hwrm_set_coal_params(bp, max_buf_irq << 16 | max_buf,
3603 buf_tmr_irq << 16 | buf_tmr, flags, &req_tx);
3555 3604
3556 mutex_lock(&bp->hwrm_cmd_lock); 3605 mutex_lock(&bp->hwrm_cmd_lock);
3557 for (i = 0; i < bp->cp_nr_rings; i++) { 3606 for (i = 0; i < bp->cp_nr_rings; i++) {
3558 req.ring_id = cpu_to_le16(bp->grp_info[i].cp_fw_ring_id); 3607 struct bnxt_napi *bnapi = bp->bnapi[i];
3559 3608
3560 rc = _hwrm_send_message(bp, &req, sizeof(req), 3609 req = &req_rx;
3610 if (!bnapi->rx_ring)
3611 req = &req_tx;
3612 req->ring_id = cpu_to_le16(bp->grp_info[i].cp_fw_ring_id);
3613
3614 rc = _hwrm_send_message(bp, req, sizeof(*req),
3561 HWRM_CMD_TIMEOUT); 3615 HWRM_CMD_TIMEOUT);
3562 if (rc) 3616 if (rc)
3563 break; 3617 break;
@@ -3766,10 +3820,14 @@ static int bnxt_hwrm_ver_get(struct bnxt *bp)
3766 resp->hwrm_intf_upd); 3820 resp->hwrm_intf_upd);
3767 netdev_warn(bp->dev, "Please update firmware with HWRM interface 1.0.0 or newer.\n"); 3821 netdev_warn(bp->dev, "Please update firmware with HWRM interface 1.0.0 or newer.\n");
3768 } 3822 }
3769 snprintf(bp->fw_ver_str, BC_HWRM_STR_LEN, "bc %d.%d.%d rm %d.%d.%d", 3823 snprintf(bp->fw_ver_str, BC_HWRM_STR_LEN, "%d.%d.%d/%d.%d.%d",
3770 resp->hwrm_fw_maj, resp->hwrm_fw_min, resp->hwrm_fw_bld, 3824 resp->hwrm_fw_maj, resp->hwrm_fw_min, resp->hwrm_fw_bld,
3771 resp->hwrm_intf_maj, resp->hwrm_intf_min, resp->hwrm_intf_upd); 3825 resp->hwrm_intf_maj, resp->hwrm_intf_min, resp->hwrm_intf_upd);
3772 3826
3827 bp->hwrm_cmd_timeout = le16_to_cpu(resp->def_req_timeout);
3828 if (!bp->hwrm_cmd_timeout)
3829 bp->hwrm_cmd_timeout = DFLT_HWRM_CMD_TIMEOUT;
3830
3773hwrm_ver_get_exit: 3831hwrm_ver_get_exit:
3774 mutex_unlock(&bp->hwrm_cmd_lock); 3832 mutex_unlock(&bp->hwrm_cmd_lock);
3775 return rc; 3833 return rc;
@@ -5291,10 +5349,16 @@ static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev)
5291 bp->rx_ring_size = BNXT_DEFAULT_RX_RING_SIZE; 5349 bp->rx_ring_size = BNXT_DEFAULT_RX_RING_SIZE;
5292 bp->tx_ring_size = BNXT_DEFAULT_TX_RING_SIZE; 5350 bp->tx_ring_size = BNXT_DEFAULT_TX_RING_SIZE;
5293 5351
5294 bp->coal_ticks = BNXT_USEC_TO_COAL_TIMER(4); 5352 /* tick values in micro seconds */
5295 bp->coal_bufs = 20; 5353 bp->rx_coal_ticks = 12;
5296 bp->coal_ticks_irq = BNXT_USEC_TO_COAL_TIMER(1); 5354 bp->rx_coal_bufs = 30;
5297 bp->coal_bufs_irq = 2; 5355 bp->rx_coal_ticks_irq = 1;
5356 bp->rx_coal_bufs_irq = 2;
5357
5358 bp->tx_coal_ticks = 25;
5359 bp->tx_coal_bufs = 30;
5360 bp->tx_coal_ticks_irq = 2;
5361 bp->tx_coal_bufs_irq = 2;
5298 5362
5299 init_timer(&bp->timer); 5363 init_timer(&bp->timer);
5300 bp->timer.data = (unsigned long)bp; 5364 bp->timer.data = (unsigned long)bp;
@@ -5559,6 +5623,8 @@ static void bnxt_cfg_ntp_filters(struct bnxt *bp)
5559 } 5623 }
5560 } 5624 }
5561 } 5625 }
5626 if (test_and_clear_bit(BNXT_HWRM_PF_UNLOAD_SP_EVENT, &bp->sp_event))
5627 netdev_info(bp->dev, "Receive PF driver unload event!");
5562} 5628}
5563 5629
5564#else 5630#else
@@ -5674,7 +5740,6 @@ static int bnxt_probe_phy(struct bnxt *bp)
5674{ 5740{
5675 int rc = 0; 5741 int rc = 0;
5676 struct bnxt_link_info *link_info = &bp->link_info; 5742 struct bnxt_link_info *link_info = &bp->link_info;
5677 char phy_ver[PHY_VER_STR_LEN];
5678 5743
5679 rc = bnxt_update_link(bp, false); 5744 rc = bnxt_update_link(bp, false);
5680 if (rc) { 5745 if (rc) {
@@ -5694,11 +5759,6 @@ static int bnxt_probe_phy(struct bnxt *bp)
5694 link_info->req_duplex = link_info->duplex_setting; 5759 link_info->req_duplex = link_info->duplex_setting;
5695 link_info->req_flow_ctrl = link_info->force_pause_setting; 5760 link_info->req_flow_ctrl = link_info->force_pause_setting;
5696 } 5761 }
5697 snprintf(phy_ver, PHY_VER_STR_LEN, " ph %d.%d.%d",
5698 link_info->phy_ver[0],
5699 link_info->phy_ver[1],
5700 link_info->phy_ver[2]);
5701 strcat(bp->fw_ver_str, phy_ver);
5702 return rc; 5762 return rc;
5703} 5763}
5704 5764
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 2be51b332652..9aa38f57601b 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -477,12 +477,15 @@ struct rx_tpa_end_cmp_ext {
477#define RING_CMP(idx) ((idx) & bp->cp_ring_mask) 477#define RING_CMP(idx) ((idx) & bp->cp_ring_mask)
478#define NEXT_CMP(idx) RING_CMP(ADV_RAW_CMP(idx, 1)) 478#define NEXT_CMP(idx) RING_CMP(ADV_RAW_CMP(idx, 1))
479 479
480#define HWRM_CMD_TIMEOUT 500 480#define DFLT_HWRM_CMD_TIMEOUT 500
481#define HWRM_CMD_TIMEOUT (bp->hwrm_cmd_timeout)
481#define HWRM_RESET_TIMEOUT ((HWRM_CMD_TIMEOUT) * 4) 482#define HWRM_RESET_TIMEOUT ((HWRM_CMD_TIMEOUT) * 4)
482#define HWRM_RESP_ERR_CODE_MASK 0xffff 483#define HWRM_RESP_ERR_CODE_MASK 0xffff
484#define HWRM_RESP_LEN_OFFSET 4
483#define HWRM_RESP_LEN_MASK 0xffff0000 485#define HWRM_RESP_LEN_MASK 0xffff0000
484#define HWRM_RESP_LEN_SFT 16 486#define HWRM_RESP_LEN_SFT 16
485#define HWRM_RESP_VALID_MASK 0xff000000 487#define HWRM_RESP_VALID_MASK 0xff000000
488#define HWRM_SEQ_ID_INVALID -1
486#define BNXT_HWRM_REQ_MAX_SIZE 128 489#define BNXT_HWRM_REQ_MAX_SIZE 128
487#define BNXT_HWRM_REQS_PER_PAGE (BNXT_PAGE_SIZE / \ 490#define BNXT_HWRM_REQS_PER_PAGE (BNXT_PAGE_SIZE / \
488 BNXT_HWRM_REQ_MAX_SIZE) 491 BNXT_HWRM_REQ_MAX_SIZE)
@@ -644,19 +647,6 @@ struct bnxt_irq {
644 647
645#define INVALID_STATS_CTX_ID -1 648#define INVALID_STATS_CTX_ID -1
646 649
647struct hwrm_cmd_req_hdr {
648#define HWRM_CMPL_RING_MASK 0xffff0000
649#define HWRM_CMPL_RING_SFT 16
650 __le32 cmpl_ring_req_type;
651#define HWRM_SEQ_ID_MASK 0xffff
652#define HWRM_SEQ_ID_INVALID -1
653#define HWRM_RESP_LEN_OFFSET 4
654#define HWRM_TARGET_FID_MASK 0xffff0000
655#define HWRM_TARGET_FID_SFT 16
656 __le32 target_id_seq_id;
657 __le64 resp_addr;
658};
659
660struct bnxt_ring_grp_info { 650struct bnxt_ring_grp_info {
661 u16 fw_stats_ctx; 651 u16 fw_stats_ctx;
662 u16 fw_grp_id; 652 u16 fw_grp_id;
@@ -957,6 +947,7 @@ struct bnxt {
957 void *hwrm_dbg_resp_addr; 947 void *hwrm_dbg_resp_addr;
958 dma_addr_t hwrm_dbg_resp_dma_addr; 948 dma_addr_t hwrm_dbg_resp_dma_addr;
959#define HWRM_DBG_REG_BUF_SIZE 128 949#define HWRM_DBG_REG_BUF_SIZE 128
950 int hwrm_cmd_timeout;
960 struct mutex hwrm_cmd_lock; /* serialize hwrm messages */ 951 struct mutex hwrm_cmd_lock; /* serialize hwrm messages */
961 struct hwrm_ver_get_output ver_resp; 952 struct hwrm_ver_get_output ver_resp;
962#define FW_VER_STR_LEN 32 953#define FW_VER_STR_LEN 32
@@ -968,13 +959,17 @@ struct bnxt {
968 __le16 vxlan_fw_dst_port_id; 959 __le16 vxlan_fw_dst_port_id;
969 u8 nge_port_cnt; 960 u8 nge_port_cnt;
970 __le16 nge_fw_dst_port_id; 961 __le16 nge_fw_dst_port_id;
971 u16 coal_ticks; 962
972 u16 coal_ticks_irq; 963 u16 rx_coal_ticks;
973 u16 coal_bufs; 964 u16 rx_coal_ticks_irq;
974 u16 coal_bufs_irq; 965 u16 rx_coal_bufs;
966 u16 rx_coal_bufs_irq;
967 u16 tx_coal_ticks;
968 u16 tx_coal_ticks_irq;
969 u16 tx_coal_bufs;
970 u16 tx_coal_bufs_irq;
975 971
976#define BNXT_USEC_TO_COAL_TIMER(x) ((x) * 25 / 2) 972#define BNXT_USEC_TO_COAL_TIMER(x) ((x) * 25 / 2)
977#define BNXT_COAL_TIMER_TO_USEC(x) ((x) * 2 / 25)
978 973
979 struct work_struct sp_task; 974 struct work_struct sp_task;
980 unsigned long sp_event; 975 unsigned long sp_event;
@@ -986,6 +981,7 @@ struct bnxt {
986#define BNXT_VXLAN_DEL_PORT_SP_EVENT 5 981#define BNXT_VXLAN_DEL_PORT_SP_EVENT 5
987#define BNXT_RESET_TASK_SP_EVENT 6 982#define BNXT_RESET_TASK_SP_EVENT 6
988#define BNXT_RST_RING_SP_EVENT 7 983#define BNXT_RST_RING_SP_EVENT 7
984#define BNXT_HWRM_PF_UNLOAD_SP_EVENT 8
989 985
990 struct bnxt_pf_info pf; 986 struct bnxt_pf_info pf;
991#ifdef CONFIG_BNXT_SRIOV 987#ifdef CONFIG_BNXT_SRIOV
@@ -1099,6 +1095,7 @@ void bnxt_set_ring_params(struct bnxt *);
1099void bnxt_hwrm_cmd_hdr_init(struct bnxt *, void *, u16, u16, u16); 1095void bnxt_hwrm_cmd_hdr_init(struct bnxt *, void *, u16, u16, u16);
1100int _hwrm_send_message(struct bnxt *, void *, u32, int); 1096int _hwrm_send_message(struct bnxt *, void *, u32, int);
1101int hwrm_send_message(struct bnxt *, void *, u32, int); 1097int hwrm_send_message(struct bnxt *, void *, u32, int);
1098int hwrm_send_message_silent(struct bnxt *, void *, u32, int);
1102int bnxt_hwrm_set_coal(struct bnxt *); 1099int bnxt_hwrm_set_coal(struct bnxt *);
1103int bnxt_hwrm_func_qcaps(struct bnxt *); 1100int bnxt_hwrm_func_qcaps(struct bnxt *);
1104int bnxt_hwrm_set_pause(struct bnxt *); 1101int bnxt_hwrm_set_pause(struct bnxt *);
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
index 3238817dfd5f..84ea26d6f3ff 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
@@ -7,6 +7,7 @@
7 * the Free Software Foundation. 7 * the Free Software Foundation.
8 */ 8 */
9 9
10#include <linux/ctype.h>
10#include <linux/ethtool.h> 11#include <linux/ethtool.h>
11#include <linux/interrupt.h> 12#include <linux/interrupt.h>
12#include <linux/pci.h> 13#include <linux/pci.h>
@@ -20,6 +21,8 @@
20#include "bnxt_fw_hdr.h" /* Firmware hdr constant and structure defs */ 21#include "bnxt_fw_hdr.h" /* Firmware hdr constant and structure defs */
21#define FLASH_NVRAM_TIMEOUT ((HWRM_CMD_TIMEOUT) * 100) 22#define FLASH_NVRAM_TIMEOUT ((HWRM_CMD_TIMEOUT) * 100)
22 23
24static char *bnxt_get_pkgver(struct net_device *dev, char *buf, size_t buflen);
25
23static u32 bnxt_get_msglevel(struct net_device *dev) 26static u32 bnxt_get_msglevel(struct net_device *dev)
24{ 27{
25 struct bnxt *bp = netdev_priv(dev); 28 struct bnxt *bp = netdev_priv(dev);
@@ -41,12 +44,16 @@ static int bnxt_get_coalesce(struct net_device *dev,
41 44
42 memset(coal, 0, sizeof(*coal)); 45 memset(coal, 0, sizeof(*coal));
43 46
44 coal->rx_coalesce_usecs = 47 coal->rx_coalesce_usecs = bp->rx_coal_ticks;
45 max_t(u16, BNXT_COAL_TIMER_TO_USEC(bp->coal_ticks), 1); 48 /* 2 completion records per rx packet */
46 coal->rx_max_coalesced_frames = bp->coal_bufs / 2; 49 coal->rx_max_coalesced_frames = bp->rx_coal_bufs / 2;
47 coal->rx_coalesce_usecs_irq = 50 coal->rx_coalesce_usecs_irq = bp->rx_coal_ticks_irq;
48 max_t(u16, BNXT_COAL_TIMER_TO_USEC(bp->coal_ticks_irq), 1); 51 coal->rx_max_coalesced_frames_irq = bp->rx_coal_bufs_irq / 2;
49 coal->rx_max_coalesced_frames_irq = bp->coal_bufs_irq / 2; 52
53 coal->tx_coalesce_usecs = bp->tx_coal_ticks;
54 coal->tx_max_coalesced_frames = bp->tx_coal_bufs;
55 coal->tx_coalesce_usecs_irq = bp->tx_coal_ticks_irq;
56 coal->tx_max_coalesced_frames_irq = bp->tx_coal_bufs_irq;
50 57
51 return 0; 58 return 0;
52} 59}
@@ -57,11 +64,16 @@ static int bnxt_set_coalesce(struct net_device *dev,
57 struct bnxt *bp = netdev_priv(dev); 64 struct bnxt *bp = netdev_priv(dev);
58 int rc = 0; 65 int rc = 0;
59 66
60 bp->coal_ticks = BNXT_USEC_TO_COAL_TIMER(coal->rx_coalesce_usecs); 67 bp->rx_coal_ticks = coal->rx_coalesce_usecs;
61 bp->coal_bufs = coal->rx_max_coalesced_frames * 2; 68 /* 2 completion records per rx packet */
62 bp->coal_ticks_irq = 69 bp->rx_coal_bufs = coal->rx_max_coalesced_frames * 2;
63 BNXT_USEC_TO_COAL_TIMER(coal->rx_coalesce_usecs_irq); 70 bp->rx_coal_ticks_irq = coal->rx_coalesce_usecs_irq;
64 bp->coal_bufs_irq = coal->rx_max_coalesced_frames_irq * 2; 71 bp->rx_coal_bufs_irq = coal->rx_max_coalesced_frames_irq * 2;
72
73 bp->tx_coal_ticks = coal->tx_coalesce_usecs;
74 bp->tx_coal_bufs = coal->tx_max_coalesced_frames;
75 bp->tx_coal_ticks_irq = coal->tx_coalesce_usecs_irq;
76 bp->tx_coal_bufs_irq = coal->tx_max_coalesced_frames_irq;
65 77
66 if (netif_running(dev)) 78 if (netif_running(dev))
67 rc = bnxt_hwrm_set_coal(bp); 79 rc = bnxt_hwrm_set_coal(bp);
@@ -460,10 +472,20 @@ static void bnxt_get_drvinfo(struct net_device *dev,
460 struct ethtool_drvinfo *info) 472 struct ethtool_drvinfo *info)
461{ 473{
462 struct bnxt *bp = netdev_priv(dev); 474 struct bnxt *bp = netdev_priv(dev);
475 char *pkglog;
476 char *pkgver = NULL;
463 477
478 pkglog = kmalloc(BNX_PKG_LOG_MAX_LENGTH, GFP_KERNEL);
479 if (pkglog)
480 pkgver = bnxt_get_pkgver(dev, pkglog, BNX_PKG_LOG_MAX_LENGTH);
464 strlcpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver)); 481 strlcpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver));
465 strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version)); 482 strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version));
466 strlcpy(info->fw_version, bp->fw_ver_str, sizeof(info->fw_version)); 483 if (pkgver && *pkgver != 0 && isdigit(*pkgver))
484 snprintf(info->fw_version, sizeof(info->fw_version) - 1,
485 "%s pkg %s", bp->fw_ver_str, pkgver);
486 else
487 strlcpy(info->fw_version, bp->fw_ver_str,
488 sizeof(info->fw_version));
467 strlcpy(info->bus_info, pci_name(bp->pdev), sizeof(info->bus_info)); 489 strlcpy(info->bus_info, pci_name(bp->pdev), sizeof(info->bus_info));
468 info->n_stats = BNXT_NUM_STATS * bp->cp_nr_rings; 490 info->n_stats = BNXT_NUM_STATS * bp->cp_nr_rings;
469 info->testinfo_len = BNXT_NUM_TESTS(bp); 491 info->testinfo_len = BNXT_NUM_TESTS(bp);
@@ -471,6 +493,7 @@ static void bnxt_get_drvinfo(struct net_device *dev,
471 info->eedump_len = 0; 493 info->eedump_len = 0;
472 /* TODO CHIMP FW: reg dump details */ 494 /* TODO CHIMP FW: reg dump details */
473 info->regdump_len = 0; 495 info->regdump_len = 0;
496 kfree(pkglog);
474} 497}
475 498
476static u32 bnxt_fw_to_ethtool_support_spds(struct bnxt_link_info *link_info) 499static u32 bnxt_fw_to_ethtool_support_spds(struct bnxt_link_info *link_info)
@@ -1102,6 +1125,85 @@ static int bnxt_get_nvram_item(struct net_device *dev, u32 index, u32 offset,
1102 return rc; 1125 return rc;
1103} 1126}
1104 1127
1128static int bnxt_find_nvram_item(struct net_device *dev, u16 type, u16 ordinal,
1129 u16 ext, u16 *index, u32 *item_length,
1130 u32 *data_length)
1131{
1132 struct bnxt *bp = netdev_priv(dev);
1133 int rc;
1134 struct hwrm_nvm_find_dir_entry_input req = {0};
1135 struct hwrm_nvm_find_dir_entry_output *output = bp->hwrm_cmd_resp_addr;
1136
1137 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_NVM_FIND_DIR_ENTRY, -1, -1);
1138 req.enables = 0;
1139 req.dir_idx = 0;
1140 req.dir_type = cpu_to_le16(type);
1141 req.dir_ordinal = cpu_to_le16(ordinal);
1142 req.dir_ext = cpu_to_le16(ext);
1143 req.opt_ordinal = NVM_FIND_DIR_ENTRY_REQ_OPT_ORDINAL_EQ;
1144 rc = hwrm_send_message_silent(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
1145 if (rc == 0) {
1146 if (index)
1147 *index = le16_to_cpu(output->dir_idx);
1148 if (item_length)
1149 *item_length = le32_to_cpu(output->dir_item_length);
1150 if (data_length)
1151 *data_length = le32_to_cpu(output->dir_data_length);
1152 }
1153 return rc;
1154}
1155
1156static char *bnxt_parse_pkglog(int desired_field, u8 *data, size_t datalen)
1157{
1158 char *retval = NULL;
1159 char *p;
1160 char *value;
1161 int field = 0;
1162
1163 if (datalen < 1)
1164 return NULL;
1165 /* null-terminate the log data (removing last '\n'): */
1166 data[datalen - 1] = 0;
1167 for (p = data; *p != 0; p++) {
1168 field = 0;
1169 retval = NULL;
1170 while (*p != 0 && *p != '\n') {
1171 value = p;
1172 while (*p != 0 && *p != '\t' && *p != '\n')
1173 p++;
1174 if (field == desired_field)
1175 retval = value;
1176 if (*p != '\t')
1177 break;
1178 *p = 0;
1179 field++;
1180 p++;
1181 }
1182 if (*p == 0)
1183 break;
1184 *p = 0;
1185 }
1186 return retval;
1187}
1188
1189static char *bnxt_get_pkgver(struct net_device *dev, char *buf, size_t buflen)
1190{
1191 u16 index = 0;
1192 u32 datalen;
1193
1194 if (bnxt_find_nvram_item(dev, BNX_DIR_TYPE_PKG_LOG,
1195 BNX_DIR_ORDINAL_FIRST, BNX_DIR_EXT_NONE,
1196 &index, NULL, &datalen) != 0)
1197 return NULL;
1198
1199 memset(buf, 0, buflen);
1200 if (bnxt_get_nvram_item(dev, index, 0, datalen, buf) != 0)
1201 return NULL;
1202
1203 return bnxt_parse_pkglog(BNX_PKG_LOG_FIELD_IDX_PKG_VERSION, buf,
1204 datalen);
1205}
1206
1105static int bnxt_get_eeprom(struct net_device *dev, 1207static int bnxt_get_eeprom(struct net_device *dev,
1106 struct ethtool_eeprom *eeprom, 1208 struct ethtool_eeprom *eeprom,
1107 u8 *data) 1209 u8 *data)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_nvm_defs.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_nvm_defs.h
index 3cf3e1b70b64..43ef392c8588 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_nvm_defs.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_nvm_defs.h
@@ -50,10 +50,24 @@ enum bnxt_nvm_directory_type {
50 50
51#define BNX_DIR_ORDINAL_FIRST 0 51#define BNX_DIR_ORDINAL_FIRST 0
52 52
53#define BNX_DIR_EXT_NONE 0
53#define BNX_DIR_EXT_INACTIVE (1 << 0) 54#define BNX_DIR_EXT_INACTIVE (1 << 0)
54#define BNX_DIR_EXT_UPDATE (1 << 1) 55#define BNX_DIR_EXT_UPDATE (1 << 1)
55 56
57#define BNX_DIR_ATTR_NONE 0
56#define BNX_DIR_ATTR_NO_CHKSUM (1 << 0) 58#define BNX_DIR_ATTR_NO_CHKSUM (1 << 0)
57#define BNX_DIR_ATTR_PROP_STREAM (1 << 1) 59#define BNX_DIR_ATTR_PROP_STREAM (1 << 1)
58 60
61#define BNX_PKG_LOG_MAX_LENGTH 4096
62
63enum bnxnvm_pkglog_field_index {
64 BNX_PKG_LOG_FIELD_IDX_INSTALLED_TIMESTAMP = 0,
65 BNX_PKG_LOG_FIELD_IDX_PKG_DESCRIPTION = 1,
66 BNX_PKG_LOG_FIELD_IDX_PKG_VERSION = 2,
67 BNX_PKG_LOG_FIELD_IDX_PKG_TIMESTAMP = 3,
68 BNX_PKG_LOG_FIELD_IDX_PKG_CHECKSUM = 4,
69 BNX_PKG_LOG_FIELD_IDX_INSTALLED_ITEMS = 5,
70 BNX_PKG_LOG_FIELD_IDX_INSTALLED_MASK = 6
71};
72
59#endif /* Don't add anything after this line */ 73#endif /* Don't add anything after this line */
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
index c1cc83d7e38c..0c5f510492f1 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
@@ -522,6 +522,46 @@ err_out1:
522 return rc; 522 return rc;
523} 523}
524 524
525static int bnxt_hwrm_fwd_async_event_cmpl(struct bnxt *bp,
526 struct bnxt_vf_info *vf,
527 u16 event_id)
528{
529 int rc = 0;
530 struct hwrm_fwd_async_event_cmpl_input req = {0};
531 struct hwrm_fwd_async_event_cmpl_output *resp = bp->hwrm_cmd_resp_addr;
532 struct hwrm_async_event_cmpl *async_cmpl;
533
534 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FWD_ASYNC_EVENT_CMPL, -1, -1);
535 if (vf)
536 req.encap_async_event_target_id = cpu_to_le16(vf->fw_fid);
537 else
538 /* broadcast this async event to all VFs */
539 req.encap_async_event_target_id = cpu_to_le16(0xffff);
540 async_cmpl = (struct hwrm_async_event_cmpl *)req.encap_async_event_cmpl;
541 async_cmpl->type =
542 cpu_to_le16(HWRM_ASYNC_EVENT_CMPL_TYPE_HWRM_ASYNC_EVENT);
543 async_cmpl->event_id = cpu_to_le16(event_id);
544
545 mutex_lock(&bp->hwrm_cmd_lock);
546 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
547
548 if (rc) {
549 netdev_err(bp->dev, "hwrm_fwd_async_event_cmpl failed. rc:%d\n",
550 rc);
551 goto fwd_async_event_cmpl_exit;
552 }
553
554 if (resp->error_code) {
555 netdev_err(bp->dev, "hwrm_fwd_async_event_cmpl error %d\n",
556 resp->error_code);
557 rc = -1;
558 }
559
560fwd_async_event_cmpl_exit:
561 mutex_unlock(&bp->hwrm_cmd_lock);
562 return rc;
563}
564
525void bnxt_sriov_disable(struct bnxt *bp) 565void bnxt_sriov_disable(struct bnxt *bp)
526{ 566{
527 u16 num_vfs = pci_num_vf(bp->pdev); 567 u16 num_vfs = pci_num_vf(bp->pdev);
@@ -530,6 +570,9 @@ void bnxt_sriov_disable(struct bnxt *bp)
530 return; 570 return;
531 571
532 if (pci_vfs_assigned(bp->pdev)) { 572 if (pci_vfs_assigned(bp->pdev)) {
573 bnxt_hwrm_fwd_async_event_cmpl(
574 bp, NULL,
575 HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD);
533 netdev_warn(bp->dev, "Unable to free %d VFs because some are assigned to VMs.\n", 576 netdev_warn(bp->dev, "Unable to free %d VFs because some are assigned to VMs.\n",
534 num_vfs); 577 num_vfs);
535 } else { 578 } else {
@@ -758,8 +801,8 @@ static int bnxt_vf_set_link(struct bnxt *bp, struct bnxt_vf_info *vf)
758static int bnxt_vf_req_validate_snd(struct bnxt *bp, struct bnxt_vf_info *vf) 801static int bnxt_vf_req_validate_snd(struct bnxt *bp, struct bnxt_vf_info *vf)
759{ 802{
760 int rc = 0; 803 int rc = 0;
761 struct hwrm_cmd_req_hdr *encap_req = vf->hwrm_cmd_req_addr; 804 struct input *encap_req = vf->hwrm_cmd_req_addr;
762 u32 req_type = le32_to_cpu(encap_req->cmpl_ring_req_type) & 0xffff; 805 u32 req_type = le16_to_cpu(encap_req->req_type);
763 806
764 switch (req_type) { 807 switch (req_type) {
765 case HWRM_CFA_L2_FILTER_ALLOC: 808 case HWRM_CFA_L2_FILTER_ALLOC:
@@ -809,13 +852,19 @@ void bnxt_update_vf_mac(struct bnxt *bp)
809 if (_hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT)) 852 if (_hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT))
810 goto update_vf_mac_exit; 853 goto update_vf_mac_exit;
811 854
812 if (!is_valid_ether_addr(resp->perm_mac_address)) 855 /* Store MAC address from the firmware. There are 2 cases:
813 goto update_vf_mac_exit; 856 * 1. MAC address is valid. It is assigned from the PF and we
814 857 * need to override the current VF MAC address with it.
858 * 2. MAC address is zero. The VF will use a random MAC address by
859 * default but the stored zero MAC will allow the VF user to change
860 * the random MAC address using ndo_set_mac_address() if he wants.
861 */
815 if (!ether_addr_equal(resp->perm_mac_address, bp->vf.mac_addr)) 862 if (!ether_addr_equal(resp->perm_mac_address, bp->vf.mac_addr))
816 memcpy(bp->vf.mac_addr, resp->perm_mac_address, ETH_ALEN); 863 memcpy(bp->vf.mac_addr, resp->perm_mac_address, ETH_ALEN);
817 /* overwrite netdev dev_adr with admin VF MAC */ 864
818 memcpy(bp->dev->dev_addr, bp->vf.mac_addr, ETH_ALEN); 865 /* overwrite netdev dev_addr with admin VF MAC */
866 if (is_valid_ether_addr(bp->vf.mac_addr))
867 memcpy(bp->dev->dev_addr, bp->vf.mac_addr, ETH_ALEN);
819update_vf_mac_exit: 868update_vf_mac_exit:
820 mutex_unlock(&bp->hwrm_cmd_lock); 869 mutex_unlock(&bp->hwrm_cmd_lock);
821} 870}