Skip to content

Commit f13bcef

Browse files
selvintxavierrleon
authored andcommitted
RDMA/bnxt_re: Enable congestion control by default
Enable Congesion control by default. Issue FW command enable the CC during driver load and disable it during unload. Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com> Link: https://lore.kernel.org/r/1680169540-10029-8-git-send-email-selvin.xavier@broadcom.com Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent c682c6e commit f13bcef

5 files changed

Lines changed: 222 additions & 13 deletions

File tree

drivers/infiniband/hw/bnxt_re/main.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1332,6 +1332,27 @@ static int bnxt_re_add_device(struct auxiliary_device *adev, u8 wqe_mode)
13321332
return rc;
13331333
}
13341334

1335+
static void bnxt_re_setup_cc(struct bnxt_re_dev *rdev, bool enable)
1336+
{
1337+
struct bnxt_qplib_cc_param cc_param = {};
1338+
1339+
/* Currently enabling only for GenP5 adapters */
1340+
if (!bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx))
1341+
return;
1342+
1343+
if (enable) {
1344+
cc_param.enable = 1;
1345+
cc_param.cc_mode = CMDQ_MODIFY_ROCE_CC_CC_MODE_PROBABILISTIC_CC_MODE;
1346+
}
1347+
1348+
cc_param.mask = (CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_CC_MODE |
1349+
CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_ENABLE_CC |
1350+
CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_TOS_ECN);
1351+
1352+
if (bnxt_qplib_modify_cc(&rdev->qplib_res, &cc_param))
1353+
ibdev_err(&rdev->ibdev, "Failed to setup CC enable = %d\n", enable);
1354+
}
1355+
13351356
/*
13361357
* "Notifier chain callback can be invoked for the same chain from
13371358
* different CPUs at the same time".
@@ -1400,7 +1421,7 @@ static void bnxt_re_remove(struct auxiliary_device *adev)
14001421
*/
14011422
goto skip_remove;
14021423
}
1403-
1424+
bnxt_re_setup_cc(rdev, false);
14041425
ib_unregister_device(&rdev->ibdev);
14051426
ib_dealloc_device(&rdev->ibdev);
14061427
bnxt_re_dev_uninit(rdev);
@@ -1432,6 +1453,7 @@ static int bnxt_re_probe(struct auxiliary_device *adev,
14321453
goto err;
14331454
}
14341455

1456+
bnxt_re_setup_cc(rdev, true);
14351457
mutex_unlock(&bnxt_re_mutex);
14361458
return 0;
14371459

drivers/infiniband/hw/bnxt_re/qplib_rcfw.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static int __send_message(struct bnxt_qplib_rcfw *rcfw,
9696
u32 sw_prod, cmdq_prod;
9797
struct pci_dev *pdev;
9898
unsigned long flags;
99-
u32 size, opcode;
99+
u32 bsize, opcode;
100100
u16 cookie, cbit;
101101
u8 *preq;
102102

@@ -145,15 +145,14 @@ static int __send_message(struct bnxt_qplib_rcfw *rcfw,
145145
return -EBUSY;
146146
}
147147

148-
size = msg->req->cmd_size;
149148
/* change the cmd_size to the number of 16byte cmdq unit.
150149
* req->cmd_size is modified here
151150
*/
152-
bnxt_qplib_set_cmd_slots(msg->req);
151+
bsize = bnxt_qplib_set_cmd_slots(msg->req);
153152

154153
memset(msg->resp, 0, sizeof(*msg->resp));
155154
crsqe->resp = (struct creq_qp_event *)msg->resp;
156-
crsqe->resp->cookie = msg->req->cookie;
155+
crsqe->resp->cookie = cpu_to_le16(cookie);
157156
crsqe->req_size = __get_cmdq_base_cmd_size(msg->req, msg->req_sz);
158157
if (__get_cmdq_base_resp_size(msg->req, msg->req_sz) && msg->sb) {
159158
struct bnxt_qplib_rcfw_sbuf *sbuf = msg->sb;
@@ -174,11 +173,11 @@ static int __send_message(struct bnxt_qplib_rcfw *rcfw,
174173
}
175174
/* Copy a segment of the req cmd to the cmdq */
176175
memset(cmdqe, 0, sizeof(*cmdqe));
177-
memcpy(cmdqe, preq, min_t(u32, size, sizeof(*cmdqe)));
178-
preq += min_t(u32, size, sizeof(*cmdqe));
179-
size -= min_t(u32, size, sizeof(*cmdqe));
176+
memcpy(cmdqe, preq, min_t(u32, bsize, sizeof(*cmdqe)));
177+
preq += min_t(u32, bsize, sizeof(*cmdqe));
178+
bsize -= min_t(u32, bsize, sizeof(*cmdqe));
180179
hwq->prod++;
181-
} while (size > 0);
180+
} while (bsize > 0);
182181
cmdq->seq_num++;
183182

184183
cmdq_prod = hwq->prod;

drivers/infiniband/hw/bnxt_re/qplib_rcfw.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
#ifndef __BNXT_QPLIB_RCFW_H__
4040
#define __BNXT_QPLIB_RCFW_H__
4141

42+
#include "qplib_tlv.h"
43+
4244
#define RCFW_CMDQ_TRIG_VAL 1
4345
#define RCFW_COMM_PCI_BAR_REGION 0
4446
#define RCFW_COMM_CONS_PCI_BAR_REGION 2
@@ -87,11 +89,21 @@ static inline u32 bnxt_qplib_cmdqe_page_size(u32 depth)
8789
return (bnxt_qplib_cmdqe_npages(depth) * PAGE_SIZE);
8890
}
8991

90-
/* Set the cmd_size to a factor of CMDQE unit */
91-
static inline void bnxt_qplib_set_cmd_slots(struct cmdq_base *req)
92+
static inline u32 bnxt_qplib_set_cmd_slots(struct cmdq_base *req)
9293
{
93-
req->cmd_size = (req->cmd_size + BNXT_QPLIB_CMDQE_UNITS - 1) /
94-
BNXT_QPLIB_CMDQE_UNITS;
94+
u32 cmd_byte = 0;
95+
96+
if (HAS_TLV_HEADER(req)) {
97+
struct roce_tlv *tlv_req = (struct roce_tlv *)req;
98+
99+
cmd_byte = tlv_req->total_size * BNXT_QPLIB_CMDQE_UNITS;
100+
} else {
101+
cmd_byte = req->cmd_size;
102+
req->cmd_size = (req->cmd_size + BNXT_QPLIB_CMDQE_UNITS - 1) /
103+
BNXT_QPLIB_CMDQE_UNITS;
104+
}
105+
106+
return cmd_byte;
95107
}
96108

97109
#define RCFW_MAX_COOKIE_VALUE 0x7FFF

drivers/infiniband/hw/bnxt_re/qplib_sp.c

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "qplib_res.h"
4949
#include "qplib_rcfw.h"
5050
#include "qplib_sp.h"
51+
#include "qplib_tlv.h"
5152

5253
const struct bnxt_qplib_gid bnxt_qplib_gid_zero = {{ 0, 0, 0, 0, 0, 0, 0, 0,
5354
0, 0, 0, 0, 0, 0, 0, 0 } };
@@ -849,3 +850,111 @@ int bnxt_qplib_qext_stat(struct bnxt_qplib_rcfw *rcfw, u32 fid,
849850
bnxt_qplib_rcfw_free_sbuf(rcfw, sbuf);
850851
return rc;
851852
}
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+
}

drivers/infiniband/hw/bnxt_re/qplib_sp.h

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,71 @@ struct bnxt_qplib_ext_stat {
244244
u64 rx_ecn_marked;
245245
};
246246

247+
struct bnxt_qplib_cc_param_ext {
248+
u64 ext_mask;
249+
u16 inact_th_hi;
250+
u16 min_delta_cnp;
251+
u16 init_cp;
252+
u8 tr_update_mode;
253+
u8 tr_update_cyls;
254+
u8 fr_rtt;
255+
u8 ai_rate_incr;
256+
u16 rr_rtt_th;
257+
u16 ar_cr_th;
258+
u16 cr_min_th;
259+
u8 bw_avg_weight;
260+
u8 cr_factor;
261+
u16 cr_th_max_cp;
262+
u8 cp_bias_en;
263+
u8 cp_bias;
264+
u8 cnp_ecn;
265+
u8 rtt_jitter_en;
266+
u16 bytes_per_usec;
267+
u16 cc_cr_reset_th;
268+
u8 cr_width;
269+
u8 min_quota;
270+
u8 max_quota;
271+
u8 abs_max_quota;
272+
u16 tr_lb;
273+
u8 cr_prob_fac;
274+
u8 tr_prob_fac;
275+
u16 fair_cr_th;
276+
u8 red_div;
277+
u8 cnp_ratio_th;
278+
u16 ai_ext_rtt;
279+
u8 exp_crcp_ratio;
280+
u8 low_rate_en;
281+
u16 cpcr_update_th;
282+
u16 ai_rtt_th1;
283+
u16 ai_rtt_th2;
284+
u16 cf_rtt_th;
285+
u16 sc_cr_th1; /* severe congestion cr threshold 1 */
286+
u16 sc_cr_th2; /* severe congestion cr threshold 2 */
287+
u32 l64B_per_rtt;
288+
u8 cc_ack_bytes;
289+
u16 reduce_cf_rtt_th;
290+
};
291+
292+
struct bnxt_qplib_cc_param {
293+
u8 alt_vlan_pcp;
294+
u16 alt_tos_dscp;
295+
u8 cc_mode;
296+
u8 enable;
297+
u16 inact_th;
298+
u16 init_cr;
299+
u16 init_tr;
300+
u16 rtt;
301+
u8 g;
302+
u8 nph_per_state;
303+
u8 time_pph;
304+
u8 pkts_pph;
305+
u8 tos_ecn;
306+
u8 tos_dscp;
307+
u16 tcp_cp;
308+
struct bnxt_qplib_cc_param_ext cc_ext;
309+
u32 mask;
310+
};
311+
247312
int bnxt_qplib_get_sgid(struct bnxt_qplib_res *res,
248313
struct bnxt_qplib_sgid_tbl *sgid_tbl, int index,
249314
struct bnxt_qplib_gid *gid);
@@ -281,5 +346,7 @@ int bnxt_qplib_get_roce_stats(struct bnxt_qplib_rcfw *rcfw,
281346
struct bnxt_qplib_roce_stats *stats);
282347
int bnxt_qplib_qext_stat(struct bnxt_qplib_rcfw *rcfw, u32 fid,
283348
struct bnxt_qplib_ext_stat *estat);
349+
int bnxt_qplib_modify_cc(struct bnxt_qplib_res *res,
350+
struct bnxt_qplib_cc_param *cc_param);
284351

285352
#endif /* __BNXT_QPLIB_SP_H__*/

0 commit comments

Comments
 (0)