|
6 | 6 | #include <linux/mm.h> |
7 | 7 | #include <linux/pci.h> |
8 | 8 | #include <linux/bnxt/hsi.h> |
| 9 | +#include <linux/if_vlan.h> |
| 10 | +#include <net/netdev_queues.h> |
9 | 11 |
|
10 | 12 | #include "bnge.h" |
11 | 13 | #include "bnge_hwrm.h" |
@@ -702,6 +704,211 @@ int bnge_hwrm_queue_qportcfg(struct bnge_dev *bd) |
702 | 704 | return rc; |
703 | 705 | } |
704 | 706 |
|
| 707 | +int bnge_hwrm_vnic_set_hds(struct bnge_net *bn, struct bnge_vnic_info *vnic) |
| 708 | +{ |
| 709 | + u16 hds_thresh = (u16)bn->netdev->cfg_pending->hds_thresh; |
| 710 | + struct hwrm_vnic_plcmodes_cfg_input *req; |
| 711 | + struct bnge_dev *bd = bn->bd; |
| 712 | + int rc; |
| 713 | + |
| 714 | + rc = bnge_hwrm_req_init(bd, req, HWRM_VNIC_PLCMODES_CFG); |
| 715 | + if (rc) |
| 716 | + return rc; |
| 717 | + |
| 718 | + req->flags = cpu_to_le32(VNIC_PLCMODES_CFG_REQ_FLAGS_JUMBO_PLACEMENT); |
| 719 | + req->enables = cpu_to_le32(BNGE_PLC_EN_JUMBO_THRES_VALID); |
| 720 | + req->jumbo_thresh = cpu_to_le16(bn->rx_buf_use_size); |
| 721 | + |
| 722 | + if (bnge_is_agg_reqd(bd)) { |
| 723 | + req->flags |= cpu_to_le32(VNIC_PLCMODES_CFG_REQ_FLAGS_HDS_IPV4 | |
| 724 | + VNIC_PLCMODES_CFG_REQ_FLAGS_HDS_IPV6); |
| 725 | + req->enables |= |
| 726 | + cpu_to_le32(BNGE_PLC_EN_HDS_THRES_VALID); |
| 727 | + req->hds_threshold = cpu_to_le16(hds_thresh); |
| 728 | + } |
| 729 | + req->vnic_id = cpu_to_le32(vnic->fw_vnic_id); |
| 730 | + return bnge_hwrm_req_send(bd, req); |
| 731 | +} |
| 732 | + |
| 733 | +int bnge_hwrm_vnic_ctx_alloc(struct bnge_dev *bd, |
| 734 | + struct bnge_vnic_info *vnic, u16 ctx_idx) |
| 735 | +{ |
| 736 | + struct hwrm_vnic_rss_cos_lb_ctx_alloc_output *resp; |
| 737 | + struct hwrm_vnic_rss_cos_lb_ctx_alloc_input *req; |
| 738 | + int rc; |
| 739 | + |
| 740 | + rc = bnge_hwrm_req_init(bd, req, HWRM_VNIC_RSS_COS_LB_CTX_ALLOC); |
| 741 | + if (rc) |
| 742 | + return rc; |
| 743 | + |
| 744 | + resp = bnge_hwrm_req_hold(bd, req); |
| 745 | + rc = bnge_hwrm_req_send(bd, req); |
| 746 | + if (!rc) |
| 747 | + vnic->fw_rss_cos_lb_ctx[ctx_idx] = |
| 748 | + le16_to_cpu(resp->rss_cos_lb_ctx_id); |
| 749 | + bnge_hwrm_req_drop(bd, req); |
| 750 | + |
| 751 | + return rc; |
| 752 | +} |
| 753 | + |
| 754 | +static void |
| 755 | +__bnge_hwrm_vnic_set_rss(struct bnge_net *bn, |
| 756 | + struct hwrm_vnic_rss_cfg_input *req, |
| 757 | + struct bnge_vnic_info *vnic) |
| 758 | +{ |
| 759 | + struct bnge_dev *bd = bn->bd; |
| 760 | + |
| 761 | + bnge_fill_hw_rss_tbl(bn, vnic); |
| 762 | + req->flags |= VNIC_RSS_CFG_REQ_FLAGS_IPSEC_HASH_TYPE_CFG_SUPPORT; |
| 763 | + |
| 764 | + req->hash_type = cpu_to_le32(bd->rss_hash_cfg); |
| 765 | + req->hash_mode_flags = VNIC_RSS_CFG_REQ_HASH_MODE_FLAGS_DEFAULT; |
| 766 | + req->ring_grp_tbl_addr = cpu_to_le64(vnic->rss_table_dma_addr); |
| 767 | + req->hash_key_tbl_addr = cpu_to_le64(vnic->rss_hash_key_dma_addr); |
| 768 | +} |
| 769 | + |
| 770 | +int bnge_hwrm_vnic_set_rss(struct bnge_net *bn, |
| 771 | + struct bnge_vnic_info *vnic, bool set_rss) |
| 772 | +{ |
| 773 | + struct hwrm_vnic_rss_cfg_input *req; |
| 774 | + struct bnge_dev *bd = bn->bd; |
| 775 | + dma_addr_t ring_tbl_map; |
| 776 | + u32 i, nr_ctxs; |
| 777 | + int rc; |
| 778 | + |
| 779 | + rc = bnge_hwrm_req_init(bd, req, HWRM_VNIC_RSS_CFG); |
| 780 | + if (rc) |
| 781 | + return rc; |
| 782 | + |
| 783 | + req->vnic_id = cpu_to_le16(vnic->fw_vnic_id); |
| 784 | + if (!set_rss) |
| 785 | + return bnge_hwrm_req_send(bd, req); |
| 786 | + |
| 787 | + __bnge_hwrm_vnic_set_rss(bn, req, vnic); |
| 788 | + ring_tbl_map = vnic->rss_table_dma_addr; |
| 789 | + nr_ctxs = bnge_cal_nr_rss_ctxs(bd->rx_nr_rings); |
| 790 | + |
| 791 | + bnge_hwrm_req_hold(bd, req); |
| 792 | + for (i = 0; i < nr_ctxs; ring_tbl_map += BNGE_RSS_TABLE_SIZE, i++) { |
| 793 | + req->ring_grp_tbl_addr = cpu_to_le64(ring_tbl_map); |
| 794 | + req->ring_table_pair_index = i; |
| 795 | + req->rss_ctx_idx = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[i]); |
| 796 | + rc = bnge_hwrm_req_send(bd, req); |
| 797 | + if (rc) |
| 798 | + goto exit; |
| 799 | + } |
| 800 | + |
| 801 | +exit: |
| 802 | + bnge_hwrm_req_drop(bd, req); |
| 803 | + return rc; |
| 804 | +} |
| 805 | + |
| 806 | +int bnge_hwrm_vnic_cfg(struct bnge_net *bn, struct bnge_vnic_info *vnic) |
| 807 | +{ |
| 808 | + struct bnge_rx_ring_info *rxr = &bn->rx_ring[0]; |
| 809 | + struct hwrm_vnic_cfg_input *req; |
| 810 | + struct bnge_dev *bd = bn->bd; |
| 811 | + int rc; |
| 812 | + |
| 813 | + rc = bnge_hwrm_req_init(bd, req, HWRM_VNIC_CFG); |
| 814 | + if (rc) |
| 815 | + return rc; |
| 816 | + |
| 817 | + req->default_rx_ring_id = |
| 818 | + cpu_to_le16(rxr->rx_ring_struct.fw_ring_id); |
| 819 | + req->default_cmpl_ring_id = |
| 820 | + cpu_to_le16(bnge_cp_ring_for_rx(rxr)); |
| 821 | + req->enables = |
| 822 | + cpu_to_le32(VNIC_CFG_REQ_ENABLES_DEFAULT_RX_RING_ID | |
| 823 | + VNIC_CFG_REQ_ENABLES_DEFAULT_CMPL_RING_ID); |
| 824 | + vnic->mru = bd->netdev->mtu + ETH_HLEN + VLAN_HLEN; |
| 825 | + req->mru = cpu_to_le16(vnic->mru); |
| 826 | + |
| 827 | + req->vnic_id = cpu_to_le16(vnic->fw_vnic_id); |
| 828 | + |
| 829 | + if (bd->flags & BNGE_EN_STRIP_VLAN) |
| 830 | + req->flags |= cpu_to_le32(VNIC_CFG_REQ_FLAGS_VLAN_STRIP_MODE); |
| 831 | + if (vnic->vnic_id == BNGE_VNIC_DEFAULT && bnge_aux_registered(bd)) |
| 832 | + req->flags |= cpu_to_le32(BNGE_VNIC_CFG_ROCE_DUAL_MODE); |
| 833 | + |
| 834 | + return bnge_hwrm_req_send(bd, req); |
| 835 | +} |
| 836 | + |
| 837 | +void bnge_hwrm_update_rss_hash_cfg(struct bnge_net *bn) |
| 838 | +{ |
| 839 | + struct bnge_vnic_info *vnic = &bn->vnic_info[BNGE_VNIC_DEFAULT]; |
| 840 | + struct hwrm_vnic_rss_qcfg_output *resp; |
| 841 | + struct hwrm_vnic_rss_qcfg_input *req; |
| 842 | + struct bnge_dev *bd = bn->bd; |
| 843 | + |
| 844 | + if (bnge_hwrm_req_init(bd, req, HWRM_VNIC_RSS_QCFG)) |
| 845 | + return; |
| 846 | + |
| 847 | + req->vnic_id = cpu_to_le16(vnic->fw_vnic_id); |
| 848 | + /* all contexts configured to same hash_type, zero always exists */ |
| 849 | + req->rss_ctx_idx = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[0]); |
| 850 | + resp = bnge_hwrm_req_hold(bd, req); |
| 851 | + if (!bnge_hwrm_req_send(bd, req)) |
| 852 | + bd->rss_hash_cfg = |
| 853 | + le32_to_cpu(resp->hash_type) ?: bd->rss_hash_cfg; |
| 854 | + bnge_hwrm_req_drop(bd, req); |
| 855 | +} |
| 856 | + |
| 857 | +int bnge_hwrm_vnic_alloc(struct bnge_dev *bd, struct bnge_vnic_info *vnic, |
| 858 | + unsigned int nr_rings) |
| 859 | +{ |
| 860 | + struct hwrm_vnic_alloc_output *resp; |
| 861 | + struct hwrm_vnic_alloc_input *req; |
| 862 | + unsigned int i; |
| 863 | + int rc; |
| 864 | + |
| 865 | + rc = bnge_hwrm_req_init(bd, req, HWRM_VNIC_ALLOC); |
| 866 | + if (rc) |
| 867 | + return rc; |
| 868 | + |
| 869 | + for (i = 0; i < BNGE_MAX_CTX_PER_VNIC; i++) |
| 870 | + vnic->fw_rss_cos_lb_ctx[i] = INVALID_HW_RING_ID; |
| 871 | + if (vnic->vnic_id == BNGE_VNIC_DEFAULT) |
| 872 | + req->flags = cpu_to_le32(VNIC_ALLOC_REQ_FLAGS_DEFAULT); |
| 873 | + |
| 874 | + resp = bnge_hwrm_req_hold(bd, req); |
| 875 | + rc = bnge_hwrm_req_send(bd, req); |
| 876 | + if (!rc) |
| 877 | + vnic->fw_vnic_id = le32_to_cpu(resp->vnic_id); |
| 878 | + bnge_hwrm_req_drop(bd, req); |
| 879 | + return rc; |
| 880 | +} |
| 881 | + |
| 882 | +void bnge_hwrm_vnic_free_one(struct bnge_dev *bd, struct bnge_vnic_info *vnic) |
| 883 | +{ |
| 884 | + if (vnic->fw_vnic_id != INVALID_HW_RING_ID) { |
| 885 | + struct hwrm_vnic_free_input *req; |
| 886 | + |
| 887 | + if (bnge_hwrm_req_init(bd, req, HWRM_VNIC_FREE)) |
| 888 | + return; |
| 889 | + |
| 890 | + req->vnic_id = cpu_to_le32(vnic->fw_vnic_id); |
| 891 | + |
| 892 | + bnge_hwrm_req_send(bd, req); |
| 893 | + vnic->fw_vnic_id = INVALID_HW_RING_ID; |
| 894 | + } |
| 895 | +} |
| 896 | + |
| 897 | +void bnge_hwrm_vnic_ctx_free_one(struct bnge_dev *bd, |
| 898 | + struct bnge_vnic_info *vnic, u16 ctx_idx) |
| 899 | +{ |
| 900 | + struct hwrm_vnic_rss_cos_lb_ctx_free_input *req; |
| 901 | + |
| 902 | + if (bnge_hwrm_req_init(bd, req, HWRM_VNIC_RSS_COS_LB_CTX_FREE)) |
| 903 | + return; |
| 904 | + |
| 905 | + req->rss_cos_lb_ctx_id = |
| 906 | + cpu_to_le16(vnic->fw_rss_cos_lb_ctx[ctx_idx]); |
| 907 | + |
| 908 | + bnge_hwrm_req_send(bd, req); |
| 909 | + vnic->fw_rss_cos_lb_ctx[ctx_idx] = INVALID_HW_RING_ID; |
| 910 | +} |
| 911 | + |
705 | 912 | void bnge_hwrm_stat_ctx_free(struct bnge_net *bn) |
706 | 913 | { |
707 | 914 | struct hwrm_stat_ctx_free_input *req; |
|
0 commit comments