diff options
-rw-r--r-- | drivers/net/ethernet/broadcom/bnxt/bnxt.c | 93 |
1 files changed, 84 insertions, 9 deletions
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index de79c9049181..b1317eaa3cbf 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c | |||
@@ -4737,28 +4737,99 @@ static bool bnxt_need_reserve_rings(struct bnxt *bp) | |||
4737 | return false; | 4737 | return false; |
4738 | } | 4738 | } |
4739 | 4739 | ||
4740 | static int bnxt_hwrm_check_tx_rings(struct bnxt *bp, int tx_rings) | 4740 | static int bnxt_hwrm_check_vf_rings(struct bnxt *bp, int tx_rings, int rx_rings, |
4741 | int ring_grps, int cp_rings) | ||
4741 | { | 4742 | { |
4742 | struct hwrm_func_cfg_input req = {0}; | 4743 | struct hwrm_func_vf_cfg_input req = {0}; |
4744 | u32 flags, enables; | ||
4743 | int rc; | 4745 | int rc; |
4744 | 4746 | ||
4745 | if (bp->hwrm_spec_code < 0x10801) | 4747 | if (!(bp->flags & BNXT_FLAG_NEW_RM)) |
4746 | return 0; | 4748 | return 0; |
4747 | 4749 | ||
4748 | if (BNXT_VF(bp)) | 4750 | bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_VF_CFG, -1, -1); |
4749 | return 0; | 4751 | flags = FUNC_VF_CFG_REQ_FLAGS_TX_ASSETS_TEST | |
4752 | FUNC_VF_CFG_REQ_FLAGS_RX_ASSETS_TEST | | ||
4753 | FUNC_VF_CFG_REQ_FLAGS_CMPL_ASSETS_TEST | | ||
4754 | FUNC_VF_CFG_REQ_FLAGS_RING_GRP_ASSETS_TEST | | ||
4755 | FUNC_VF_CFG_REQ_FLAGS_STAT_CTX_ASSETS_TEST | | ||
4756 | FUNC_VF_CFG_REQ_FLAGS_VNIC_ASSETS_TEST; | ||
4757 | enables = FUNC_VF_CFG_REQ_ENABLES_NUM_TX_RINGS | | ||
4758 | FUNC_VF_CFG_REQ_ENABLES_NUM_RX_RINGS | | ||
4759 | FUNC_VF_CFG_REQ_ENABLES_NUM_CMPL_RINGS | | ||
4760 | FUNC_VF_CFG_REQ_ENABLES_NUM_HW_RING_GRPS | | ||
4761 | FUNC_VF_CFG_REQ_ENABLES_NUM_STAT_CTXS | | ||
4762 | FUNC_VF_CFG_REQ_ENABLES_NUM_VNICS; | ||
4763 | |||
4764 | req.flags = cpu_to_le32(flags); | ||
4765 | req.enables = cpu_to_le32(enables); | ||
4766 | req.num_tx_rings = cpu_to_le16(tx_rings); | ||
4767 | req.num_rx_rings = cpu_to_le16(rx_rings); | ||
4768 | req.num_cmpl_rings = cpu_to_le16(cp_rings); | ||
4769 | req.num_hw_ring_grps = cpu_to_le16(ring_grps); | ||
4770 | req.num_stat_ctxs = cpu_to_le16(cp_rings); | ||
4771 | req.num_vnics = cpu_to_le16(1); | ||
4772 | if (bp->flags & BNXT_FLAG_RFS) | ||
4773 | req.num_vnics = cpu_to_le16(rx_rings + 1); | ||
4774 | rc = hwrm_send_message_silent(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); | ||
4775 | if (rc) | ||
4776 | return -ENOMEM; | ||
4777 | return 0; | ||
4778 | } | ||
4779 | |||
4780 | static int bnxt_hwrm_check_pf_rings(struct bnxt *bp, int tx_rings, int rx_rings, | ||
4781 | int ring_grps, int cp_rings) | ||
4782 | { | ||
4783 | struct hwrm_func_cfg_input req = {0}; | ||
4784 | u32 flags, enables; | ||
4785 | int rc; | ||
4750 | 4786 | ||
4751 | bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_CFG, -1, -1); | 4787 | bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_CFG, -1, -1); |
4752 | req.fid = cpu_to_le16(0xffff); | 4788 | req.fid = cpu_to_le16(0xffff); |
4753 | req.flags = cpu_to_le32(FUNC_CFG_REQ_FLAGS_TX_ASSETS_TEST); | 4789 | flags = FUNC_CFG_REQ_FLAGS_TX_ASSETS_TEST; |
4754 | req.enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_NUM_TX_RINGS); | 4790 | enables = FUNC_CFG_REQ_ENABLES_NUM_TX_RINGS; |
4755 | req.num_tx_rings = cpu_to_le16(tx_rings); | 4791 | req.num_tx_rings = cpu_to_le16(tx_rings); |
4792 | if (bp->flags & BNXT_FLAG_NEW_RM) { | ||
4793 | flags |= FUNC_CFG_REQ_FLAGS_RX_ASSETS_TEST | | ||
4794 | FUNC_CFG_REQ_FLAGS_CMPL_ASSETS_TEST | | ||
4795 | FUNC_CFG_REQ_FLAGS_RING_GRP_ASSETS_TEST | | ||
4796 | FUNC_CFG_REQ_FLAGS_STAT_CTX_ASSETS_TEST | | ||
4797 | FUNC_CFG_REQ_FLAGS_VNIC_ASSETS_TEST; | ||
4798 | enables |= FUNC_CFG_REQ_ENABLES_NUM_RX_RINGS | | ||
4799 | FUNC_CFG_REQ_ENABLES_NUM_CMPL_RINGS | | ||
4800 | FUNC_CFG_REQ_ENABLES_NUM_HW_RING_GRPS | | ||
4801 | FUNC_CFG_REQ_ENABLES_NUM_STAT_CTXS | | ||
4802 | FUNC_CFG_REQ_ENABLES_NUM_VNICS; | ||
4803 | req.num_rx_rings = cpu_to_le16(rx_rings); | ||
4804 | req.num_cmpl_rings = cpu_to_le16(cp_rings); | ||
4805 | req.num_hw_ring_grps = cpu_to_le16(ring_grps); | ||
4806 | req.num_stat_ctxs = cpu_to_le16(cp_rings); | ||
4807 | req.num_vnics = cpu_to_le16(1); | ||
4808 | if (bp->flags & BNXT_FLAG_RFS) | ||
4809 | req.num_vnics = cpu_to_le16(rx_rings + 1); | ||
4810 | } | ||
4811 | req.flags = cpu_to_le32(flags); | ||
4812 | req.enables = cpu_to_le32(enables); | ||
4756 | rc = hwrm_send_message_silent(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); | 4813 | rc = hwrm_send_message_silent(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); |
4757 | if (rc) | 4814 | if (rc) |
4758 | return -ENOMEM; | 4815 | return -ENOMEM; |
4759 | return 0; | 4816 | return 0; |
4760 | } | 4817 | } |
4761 | 4818 | ||
4819 | static int bnxt_hwrm_check_rings(struct bnxt *bp, int tx_rings, int rx_rings, | ||
4820 | int ring_grps, int cp_rings) | ||
4821 | { | ||
4822 | if (bp->hwrm_spec_code < 0x10801) | ||
4823 | return 0; | ||
4824 | |||
4825 | if (BNXT_PF(bp)) | ||
4826 | return bnxt_hwrm_check_pf_rings(bp, tx_rings, rx_rings, | ||
4827 | ring_grps, cp_rings); | ||
4828 | |||
4829 | return bnxt_hwrm_check_vf_rings(bp, tx_rings, rx_rings, ring_grps, | ||
4830 | cp_rings); | ||
4831 | } | ||
4832 | |||
4762 | static void bnxt_hwrm_set_coal_params(struct bnxt_coal *hw_coal, | 4833 | static void bnxt_hwrm_set_coal_params(struct bnxt_coal *hw_coal, |
4763 | struct hwrm_ring_cmpl_ring_cfg_aggint_params_input *req) | 4834 | struct hwrm_ring_cmpl_ring_cfg_aggint_params_input *req) |
4764 | { | 4835 | { |
@@ -7426,7 +7497,8 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs, | |||
7426 | { | 7497 | { |
7427 | int max_rx, max_tx, tx_sets = 1; | 7498 | int max_rx, max_tx, tx_sets = 1; |
7428 | int tx_rings_needed; | 7499 | int tx_rings_needed; |
7429 | int rc; | 7500 | int rx_rings = rx; |
7501 | int cp, rc; | ||
7430 | 7502 | ||
7431 | if (tcs) | 7503 | if (tcs) |
7432 | tx_sets = tcs; | 7504 | tx_sets = tcs; |
@@ -7442,7 +7514,10 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs, | |||
7442 | if (max_tx < tx_rings_needed) | 7514 | if (max_tx < tx_rings_needed) |
7443 | return -ENOMEM; | 7515 | return -ENOMEM; |
7444 | 7516 | ||
7445 | return bnxt_hwrm_check_tx_rings(bp, tx_rings_needed); | 7517 | if (bp->flags & BNXT_FLAG_AGG_RINGS) |
7518 | rx_rings <<= 1; | ||
7519 | cp = sh ? max_t(int, tx_rings_needed, rx) : tx_rings_needed + rx; | ||
7520 | return bnxt_hwrm_check_rings(bp, tx_rings_needed, rx_rings, rx, cp); | ||
7446 | } | 7521 | } |
7447 | 7522 | ||
7448 | static void bnxt_unmap_bars(struct bnxt *bp, struct pci_dev *pdev) | 7523 | static void bnxt_unmap_bars(struct bnxt *bp, struct pci_dev *pdev) |