Lines Matching refs:qpt
44 #define mk_qpn(qpt, map, off) (((map) - (qpt)->map) * BITS_PER_PAGE + \ argument
87 static void get_map_page(struct ipath_qp_table *qpt, struct qpn_map *map) in get_map_page() argument
96 spin_lock_irqsave(&qpt->lock, flags); in get_map_page()
101 spin_unlock_irqrestore(&qpt->lock, flags); in get_map_page()
105 static int alloc_qpn(struct ipath_qp_table *qpt, enum ib_qp_type type) in alloc_qpn() argument
117 map = &qpt->map[0]; in alloc_qpn()
119 get_map_page(qpt, map); in alloc_qpn()
132 qpn = qpt->last + 1; in alloc_qpn()
136 map = &qpt->map[qpn / BITS_PER_PAGE]; in alloc_qpn()
137 max_scan = qpt->nmaps - !offset; in alloc_qpn()
140 get_map_page(qpt, map); in alloc_qpn()
148 qpt->last = qpn; in alloc_qpn()
153 qpn = mk_qpn(qpt, map, offset); in alloc_qpn()
170 if (qpt->nmaps == QPNMAP_ENTRIES) in alloc_qpn()
172 map = &qpt->map[qpt->nmaps++]; in alloc_qpn()
174 } else if (map < &qpt->map[qpt->nmaps]) { in alloc_qpn()
178 map = &qpt->map[0]; in alloc_qpn()
181 qpn = mk_qpn(qpt, map, offset); in alloc_qpn()
190 static void free_qpn(struct ipath_qp_table *qpt, u32 qpn) in free_qpn() argument
194 map = qpt->map + qpn / BITS_PER_PAGE; in free_qpn()
209 static int ipath_alloc_qpn(struct ipath_qp_table *qpt, struct ipath_qp *qp, in ipath_alloc_qpn() argument
215 ret = alloc_qpn(qpt, type); in ipath_alloc_qpn()
221 spin_lock_irqsave(&qpt->lock, flags); in ipath_alloc_qpn()
223 ret %= qpt->max; in ipath_alloc_qpn()
224 qp->next = qpt->table[ret]; in ipath_alloc_qpn()
225 qpt->table[ret] = qp; in ipath_alloc_qpn()
228 spin_unlock_irqrestore(&qpt->lock, flags); in ipath_alloc_qpn()
243 static void ipath_free_qp(struct ipath_qp_table *qpt, struct ipath_qp *qp) in ipath_free_qp() argument
248 spin_lock_irqsave(&qpt->lock, flags); in ipath_free_qp()
251 qpp = &qpt->table[qp->ibqp.qp_num % qpt->max]; in ipath_free_qp()
261 spin_unlock_irqrestore(&qpt->lock, flags); in ipath_free_qp()
271 unsigned ipath_free_all_qps(struct ipath_qp_table *qpt) in ipath_free_all_qps() argument
277 spin_lock_irqsave(&qpt->lock, flags); in ipath_free_all_qps()
278 for (n = 0; n < qpt->max; n++) { in ipath_free_all_qps()
279 qp = qpt->table[n]; in ipath_free_all_qps()
280 qpt->table[n] = NULL; in ipath_free_all_qps()
285 spin_unlock_irqrestore(&qpt->lock, flags); in ipath_free_all_qps()
287 for (n = 0; n < ARRAY_SIZE(qpt->map); n++) in ipath_free_all_qps()
288 if (qpt->map[n].page) in ipath_free_all_qps()
289 free_page((unsigned long) qpt->map[n].page); in ipath_free_all_qps()
301 struct ipath_qp *ipath_lookup_qpn(struct ipath_qp_table *qpt, u32 qpn) in ipath_lookup_qpn() argument
306 spin_lock_irqsave(&qpt->lock, flags); in ipath_lookup_qpn()
308 for (qp = qpt->table[qpn % qpt->max]; qp; qp = qp->next) { in ipath_lookup_qpn()
315 spin_unlock_irqrestore(&qpt->lock, flags); in ipath_lookup_qpn()