0001
0002
0003
0004
0005
0006 #include "exp_rcv.h"
0007 #include "trace.h"
0008
0009
0010
0011
0012
0013 static void hfi1_exp_tid_set_init(struct exp_tid_set *set)
0014 {
0015 INIT_LIST_HEAD(&set->list);
0016 set->count = 0;
0017 }
0018
0019
0020
0021
0022
0023 void hfi1_exp_tid_group_init(struct hfi1_ctxtdata *rcd)
0024 {
0025 hfi1_exp_tid_set_init(&rcd->tid_group_list);
0026 hfi1_exp_tid_set_init(&rcd->tid_used_list);
0027 hfi1_exp_tid_set_init(&rcd->tid_full_list);
0028 }
0029
0030
0031
0032
0033
0034 int hfi1_alloc_ctxt_rcv_groups(struct hfi1_ctxtdata *rcd)
0035 {
0036 struct hfi1_devdata *dd = rcd->dd;
0037 u32 tidbase;
0038 struct tid_group *grp;
0039 int i;
0040 u32 ngroups;
0041
0042 ngroups = rcd->expected_count / dd->rcv_entries.group_size;
0043 rcd->groups =
0044 kcalloc_node(ngroups, sizeof(*rcd->groups),
0045 GFP_KERNEL, rcd->numa_id);
0046 if (!rcd->groups)
0047 return -ENOMEM;
0048 tidbase = rcd->expected_base;
0049 for (i = 0; i < ngroups; i++) {
0050 grp = &rcd->groups[i];
0051 grp->size = dd->rcv_entries.group_size;
0052 grp->base = tidbase;
0053 tid_group_add_tail(grp, &rcd->tid_group_list);
0054 tidbase += dd->rcv_entries.group_size;
0055 }
0056
0057 return 0;
0058 }
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071 void hfi1_free_ctxt_rcv_groups(struct hfi1_ctxtdata *rcd)
0072 {
0073 kfree(rcd->groups);
0074 rcd->groups = NULL;
0075 hfi1_exp_tid_group_init(rcd);
0076
0077 hfi1_clear_tids(rcd);
0078 }