* Allocate and initialize the TID tables. Returns 0 on success. */
| 480 | * Allocate and initialize the TID tables. Returns 0 on success. |
| 481 | */ |
| 482 | static int tid_init(struct tid_info *t) |
| 483 | { |
| 484 | size_t size; |
| 485 | unsigned int ftid_bmap_size; |
| 486 | unsigned int natids = t->natids; |
| 487 | unsigned int max_ftids = t->nftids; |
| 488 | |
| 489 | ftid_bmap_size = rte_bitmap_get_memory_footprint(t->nftids); |
| 490 | size = t->ntids * sizeof(*t->tid_tab) + |
| 491 | max_ftids * sizeof(*t->ftid_tab) + |
| 492 | natids * sizeof(*t->atid_tab); |
| 493 | |
| 494 | t->tid_tab = t4_os_alloc(size); |
| 495 | if (!t->tid_tab) |
| 496 | return -ENOMEM; |
| 497 | |
| 498 | t->atid_tab = (union aopen_entry *)&t->tid_tab[t->ntids]; |
| 499 | t->ftid_tab = (struct filter_entry *)&t->atid_tab[t->natids]; |
| 500 | t->ftid_bmap_array = t4_os_alloc(ftid_bmap_size); |
| 501 | if (!t->ftid_bmap_array) { |
| 502 | tid_free(t); |
| 503 | return -ENOMEM; |
| 504 | } |
| 505 | |
| 506 | t4_os_lock_init(&t->atid_lock); |
| 507 | t4_os_lock_init(&t->ftid_lock); |
| 508 | |
| 509 | t->afree = NULL; |
| 510 | t->atids_in_use = 0; |
| 511 | t->tids_in_use = 0; |
| 512 | t->conns_in_use = 0; |
| 513 | |
| 514 | /* Setup the free list for atid_tab and clear the stid bitmap. */ |
| 515 | if (natids) { |
| 516 | while (--natids) |
| 517 | t->atid_tab[natids - 1].next = &t->atid_tab[natids]; |
| 518 | t->afree = t->atid_tab; |
| 519 | } |
| 520 | |
| 521 | t->ftid_bmap = rte_bitmap_init(t->nftids, t->ftid_bmap_array, |
| 522 | ftid_bmap_size); |
| 523 | if (!t->ftid_bmap) { |
| 524 | tid_free(t); |
| 525 | return -ENOMEM; |
| 526 | } |
| 527 | |
| 528 | return 0; |
| 529 | } |
| 530 | |
| 531 | static inline void init_rspq(struct adapter *adap, struct sge_rspq *q, |
| 532 | unsigned int us, unsigned int cnt, |
no test coverage detected