|
48 | 48 | #include "qplib_res.h" |
49 | 49 | #include "qplib_rcfw.h" |
50 | 50 | #include "qplib_sp.h" |
| 51 | +#include "qplib_tlv.h" |
51 | 52 |
|
52 | 53 | const struct bnxt_qplib_gid bnxt_qplib_gid_zero = {{ 0, 0, 0, 0, 0, 0, 0, 0, |
53 | 54 | 0, 0, 0, 0, 0, 0, 0, 0 } }; |
@@ -849,3 +850,111 @@ int bnxt_qplib_qext_stat(struct bnxt_qplib_rcfw *rcfw, u32 fid, |
849 | 850 | bnxt_qplib_rcfw_free_sbuf(rcfw, sbuf); |
850 | 851 | return rc; |
851 | 852 | } |
| 853 | + |
| 854 | +static void bnxt_qplib_fill_cc_gen1(struct cmdq_modify_roce_cc_gen1_tlv *ext_req, |
| 855 | + struct bnxt_qplib_cc_param_ext *cc_ext) |
| 856 | +{ |
| 857 | + ext_req->modify_mask = cpu_to_le64(cc_ext->ext_mask); |
| 858 | + cc_ext->ext_mask = 0; |
| 859 | + ext_req->inactivity_th_hi = cpu_to_le16(cc_ext->inact_th_hi); |
| 860 | + ext_req->min_time_between_cnps = cpu_to_le16(cc_ext->min_delta_cnp); |
| 861 | + ext_req->init_cp = cpu_to_le16(cc_ext->init_cp); |
| 862 | + ext_req->tr_update_mode = cc_ext->tr_update_mode; |
| 863 | + ext_req->tr_update_cycles = cc_ext->tr_update_cyls; |
| 864 | + ext_req->fr_num_rtts = cc_ext->fr_rtt; |
| 865 | + ext_req->ai_rate_increase = cc_ext->ai_rate_incr; |
| 866 | + ext_req->reduction_relax_rtts_th = cpu_to_le16(cc_ext->rr_rtt_th); |
| 867 | + ext_req->additional_relax_cr_th = cpu_to_le16(cc_ext->ar_cr_th); |
| 868 | + ext_req->cr_min_th = cpu_to_le16(cc_ext->cr_min_th); |
| 869 | + ext_req->bw_avg_weight = cc_ext->bw_avg_weight; |
| 870 | + ext_req->actual_cr_factor = cc_ext->cr_factor; |
| 871 | + ext_req->max_cp_cr_th = cpu_to_le16(cc_ext->cr_th_max_cp); |
| 872 | + ext_req->cp_bias_en = cc_ext->cp_bias_en; |
| 873 | + ext_req->cp_bias = cc_ext->cp_bias; |
| 874 | + ext_req->cnp_ecn = cc_ext->cnp_ecn; |
| 875 | + ext_req->rtt_jitter_en = cc_ext->rtt_jitter_en; |
| 876 | + ext_req->link_bytes_per_usec = cpu_to_le16(cc_ext->bytes_per_usec); |
| 877 | + ext_req->reset_cc_cr_th = cpu_to_le16(cc_ext->cc_cr_reset_th); |
| 878 | + ext_req->cr_width = cc_ext->cr_width; |
| 879 | + ext_req->quota_period_min = cc_ext->min_quota; |
| 880 | + ext_req->quota_period_max = cc_ext->max_quota; |
| 881 | + ext_req->quota_period_abs_max = cc_ext->abs_max_quota; |
| 882 | + ext_req->tr_lower_bound = cpu_to_le16(cc_ext->tr_lb); |
| 883 | + ext_req->cr_prob_factor = cc_ext->cr_prob_fac; |
| 884 | + ext_req->tr_prob_factor = cc_ext->tr_prob_fac; |
| 885 | + ext_req->fairness_cr_th = cpu_to_le16(cc_ext->fair_cr_th); |
| 886 | + ext_req->red_div = cc_ext->red_div; |
| 887 | + ext_req->cnp_ratio_th = cc_ext->cnp_ratio_th; |
| 888 | + ext_req->exp_ai_rtts = cpu_to_le16(cc_ext->ai_ext_rtt); |
| 889 | + ext_req->exp_ai_cr_cp_ratio = cc_ext->exp_crcp_ratio; |
| 890 | + ext_req->use_rate_table = cc_ext->low_rate_en; |
| 891 | + ext_req->cp_exp_update_th = cpu_to_le16(cc_ext->cpcr_update_th); |
| 892 | + ext_req->high_exp_ai_rtts_th1 = cpu_to_le16(cc_ext->ai_rtt_th1); |
| 893 | + ext_req->high_exp_ai_rtts_th2 = cpu_to_le16(cc_ext->ai_rtt_th2); |
| 894 | + ext_req->actual_cr_cong_free_rtts_th = cpu_to_le16(cc_ext->cf_rtt_th); |
| 895 | + ext_req->severe_cong_cr_th1 = cpu_to_le16(cc_ext->sc_cr_th1); |
| 896 | + ext_req->severe_cong_cr_th2 = cpu_to_le16(cc_ext->sc_cr_th2); |
| 897 | + ext_req->link64B_per_rtt = cpu_to_le32(cc_ext->l64B_per_rtt); |
| 898 | + ext_req->cc_ack_bytes = cc_ext->cc_ack_bytes; |
| 899 | +} |
| 900 | + |
| 901 | +int bnxt_qplib_modify_cc(struct bnxt_qplib_res *res, |
| 902 | + struct bnxt_qplib_cc_param *cc_param) |
| 903 | +{ |
| 904 | + struct bnxt_qplib_tlv_modify_cc_req tlv_req = {}; |
| 905 | + struct creq_modify_roce_cc_resp resp = {}; |
| 906 | + struct bnxt_qplib_cmdqmsg msg = {}; |
| 907 | + struct cmdq_modify_roce_cc *req; |
| 908 | + int req_size; |
| 909 | + void *cmd; |
| 910 | + int rc; |
| 911 | + |
| 912 | + /* Prepare the older base command */ |
| 913 | + req = &tlv_req.base_req; |
| 914 | + cmd = req; |
| 915 | + req_size = sizeof(*req); |
| 916 | + bnxt_qplib_rcfw_cmd_prep((struct cmdq_base *)req, CMDQ_BASE_OPCODE_MODIFY_ROCE_CC, |
| 917 | + sizeof(*req)); |
| 918 | + req->modify_mask = cpu_to_le32(cc_param->mask); |
| 919 | + req->enable_cc = cc_param->enable; |
| 920 | + req->g = cc_param->g; |
| 921 | + req->num_phases_per_state = cc_param->nph_per_state; |
| 922 | + req->time_per_phase = cc_param->time_pph; |
| 923 | + req->pkts_per_phase = cc_param->pkts_pph; |
| 924 | + req->init_cr = cpu_to_le16(cc_param->init_cr); |
| 925 | + req->init_tr = cpu_to_le16(cc_param->init_tr); |
| 926 | + req->tos_dscp_tos_ecn = (cc_param->tos_dscp << CMDQ_MODIFY_ROCE_CC_TOS_DSCP_SFT) | |
| 927 | + (cc_param->tos_ecn & CMDQ_MODIFY_ROCE_CC_TOS_ECN_MASK); |
| 928 | + req->alt_vlan_pcp = cc_param->alt_vlan_pcp; |
| 929 | + req->alt_tos_dscp = cpu_to_le16(cc_param->alt_tos_dscp); |
| 930 | + req->rtt = cpu_to_le16(cc_param->rtt); |
| 931 | + req->tcp_cp = cpu_to_le16(cc_param->tcp_cp); |
| 932 | + req->cc_mode = cc_param->cc_mode; |
| 933 | + req->inactivity_th = cpu_to_le16(cc_param->inact_th); |
| 934 | + |
| 935 | + /* For chip gen P5 onwards fill extended cmd and header */ |
| 936 | + if (bnxt_qplib_is_chip_gen_p5(res->cctx)) { |
| 937 | + struct roce_tlv *hdr; |
| 938 | + u32 payload; |
| 939 | + u32 chunks; |
| 940 | + |
| 941 | + cmd = &tlv_req; |
| 942 | + req_size = sizeof(tlv_req); |
| 943 | + /* Prepare primary tlv header */ |
| 944 | + hdr = &tlv_req.tlv_hdr; |
| 945 | + chunks = CHUNKS(sizeof(struct bnxt_qplib_tlv_modify_cc_req)); |
| 946 | + payload = sizeof(struct cmdq_modify_roce_cc); |
| 947 | + __roce_1st_tlv_prep(hdr, chunks, payload, true); |
| 948 | + /* Prepare secondary tlv header */ |
| 949 | + hdr = (struct roce_tlv *)&tlv_req.ext_req; |
| 950 | + payload = sizeof(struct cmdq_modify_roce_cc_gen1_tlv) - |
| 951 | + sizeof(struct roce_tlv); |
| 952 | + __roce_ext_tlv_prep(hdr, TLV_TYPE_MODIFY_ROCE_CC_GEN1, payload, false, true); |
| 953 | + bnxt_qplib_fill_cc_gen1(&tlv_req.ext_req, &cc_param->cc_ext); |
| 954 | + } |
| 955 | + |
| 956 | + bnxt_qplib_fill_cmdqmsg(&msg, cmd, &resp, NULL, req_size, |
| 957 | + sizeof(resp), 0); |
| 958 | + rc = bnxt_qplib_rcfw_send_message(res->rcfw, &msg); |
| 959 | + return rc; |
| 960 | +} |
0 commit comments