Skip to content

Commit d029434

Browse files
kwan-intcjgunthorpe
authored andcommitted
IB/hfi1: Fix the allocation of RSM table
The receive side mapping (RSM) on hfi1 hardware is a special matching mechanism to direct an incoming packet to a given hardware receive context. It has 4 instances of matching capabilities (RSM0 - RSM3) that share the same RSM table (RMT). The RMT has a total of 256 entries, each of which points to a receive context. Currently, three instances of RSM have been used: 1. RSM0 by QOS; 2. RSM1 by PSM FECN; 3. RSM2 by VNIC. Each RSM instance should reserve enough entries in RMT to function properly. Since both PSM and VNIC could allocate any receive context between dd->first_dyn_alloc_ctxt and dd->num_rcv_contexts, PSM FECN must reserve enough RMT entries to cover the entire receive context index range (dd->num_rcv_contexts - dd->first_dyn_alloc_ctxt) instead of only the user receive contexts allocated for PSM (dd->num_user_contexts). Consequently, the sizing of dd->num_user_contexts in set_up_context_variables is incorrect. Fixes: 2280740 ("IB/hfi1: Virtual Network Interface Controller (VNIC) HW support") Reviewed-by: Mike Marciniszyn <[email protected]> Reviewed-by: Michael J. Ruhl <[email protected]> Signed-off-by: Kaike Wan <[email protected]> Signed-off-by: Dennis Dalessandro <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent a8639a7 commit d029434

File tree

1 file changed

+19
-7
lines changed
  • drivers/infiniband/hw/hfi1

1 file changed

+19
-7
lines changed

drivers/infiniband/hw/hfi1/chip.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13232,7 +13232,7 @@ static int set_up_context_variables(struct hfi1_devdata *dd)
1323213232
int total_contexts;
1323313233
int ret;
1323413234
unsigned ngroups;
13235-
int qos_rmt_count;
13235+
int rmt_count;
1323613236
int user_rmt_reduced;
1323713237
u32 n_usr_ctxts;
1323813238
u32 send_contexts = chip_send_contexts(dd);
@@ -13294,10 +13294,20 @@ static int set_up_context_variables(struct hfi1_devdata *dd)
1329413294
n_usr_ctxts = rcv_contexts - total_contexts;
1329513295
}
1329613296

13297-
/* each user context requires an entry in the RMT */
13298-
qos_rmt_count = qos_rmt_entries(dd, NULL, NULL);
13299-
if (qos_rmt_count + n_usr_ctxts > NUM_MAP_ENTRIES) {
13300-
user_rmt_reduced = NUM_MAP_ENTRIES - qos_rmt_count;
13297+
/*
13298+
* The RMT entries are currently allocated as shown below:
13299+
* 1. QOS (0 to 128 entries);
13300+
* 2. FECN for PSM (num_user_contexts + num_vnic_contexts);
13301+
* 3. VNIC (num_vnic_contexts).
13302+
* It should be noted that PSM FECN oversubscribe num_vnic_contexts
13303+
* entries of RMT because both VNIC and PSM could allocate any receive
13304+
* context between dd->first_dyn_alloc_text and dd->num_rcv_contexts,
13305+
* and PSM FECN must reserve an RMT entry for each possible PSM receive
13306+
* context.
13307+
*/
13308+
rmt_count = qos_rmt_entries(dd, NULL, NULL) + (num_vnic_contexts * 2);
13309+
if (rmt_count + n_usr_ctxts > NUM_MAP_ENTRIES) {
13310+
user_rmt_reduced = NUM_MAP_ENTRIES - rmt_count;
1330113311
dd_dev_err(dd,
1330213312
"RMT size is reducing the number of user receive contexts from %u to %d\n",
1330313313
n_usr_ctxts,
@@ -14285,9 +14295,11 @@ static void init_user_fecn_handling(struct hfi1_devdata *dd,
1428514295
u64 reg;
1428614296
int i, idx, regoff, regidx;
1428714297
u8 offset;
14298+
u32 total_cnt;
1428814299

1428914300
/* there needs to be enough room in the map table */
14290-
if (rmt->used + dd->num_user_contexts >= NUM_MAP_ENTRIES) {
14301+
total_cnt = dd->num_rcv_contexts - dd->first_dyn_alloc_ctxt;
14302+
if (rmt->used + total_cnt >= NUM_MAP_ENTRIES) {
1429114303
dd_dev_err(dd, "User FECN handling disabled - too many user contexts allocated\n");
1429214304
return;
1429314305
}
@@ -14341,7 +14353,7 @@ static void init_user_fecn_handling(struct hfi1_devdata *dd,
1434114353
/* add rule 1 */
1434214354
add_rsm_rule(dd, RSM_INS_FECN, &rrd);
1434314355

14344-
rmt->used += dd->num_user_contexts;
14356+
rmt->used += total_cnt;
1434514357
}
1434614358

1434714359
/* Initialize RSM for VNIC */

0 commit comments

Comments
 (0)