Lines Matching full:table
49 u16 table[] __counted_by(table_len);
75 * GID entry is detached from the table.
101 /* In RoCE, adding a GID to the table requires:
165 * @table: GID table pointer
166 * @index: Index to check in GID table
170 static bool is_gid_index_default(const struct ib_gid_table *table, in is_gid_index_default() argument
173 return index < 32 && (BIT(index) & table->default_gid_indices); in is_gid_index_default()
241 struct ib_gid_table *table = rdma_gid_table(device, port_num); in free_gid_entry_locked() local
246 write_lock_irq(&table->rwlock); in free_gid_entry_locked()
249 * The only way to avoid overwriting NULL in table is in free_gid_entry_locked()
250 * by comparing if it is same entry in table or not! in free_gid_entry_locked()
251 * If new entry in table is added by the time we free here, in free_gid_entry_locked()
252 * don't overwrite the table entry. in free_gid_entry_locked()
254 if (entry == table->data_vec[entry->attr.index]) in free_gid_entry_locked()
255 table->data_vec[entry->attr.index] = NULL; in free_gid_entry_locked()
257 write_unlock_irq(&table->rwlock); in free_gid_entry_locked()
277 * free_gid_work() frees the entry from the HCA's hardware table
286 struct ib_gid_table *table = rdma_gid_table(device, port_num); in free_gid_work() local
288 mutex_lock(&table->lock); in free_gid_work()
290 mutex_unlock(&table->lock); in free_gid_work()
320 static void store_gid_entry(struct ib_gid_table *table, in store_gid_entry() argument
329 lockdep_assert_held(&table->lock); in store_gid_entry()
330 write_lock_irq(&table->rwlock); in store_gid_entry()
331 table->data_vec[entry->attr.index] = entry; in store_gid_entry()
332 write_unlock_irq(&table->rwlock); in store_gid_entry()
373 * del_gid - Delete GID table entry
377 * @table: GID table of the IB device for a port
382 struct ib_gid_table *table, int ix) in del_gid() argument
387 lockdep_assert_held(&table->lock); in del_gid()
390 ix, table->data_vec[ix]->attr.gid.raw); in del_gid()
392 write_lock_irq(&table->rwlock); in del_gid()
393 entry = table->data_vec[ix]; in del_gid()
399 table->data_vec[ix] = NULL; in del_gid()
400 write_unlock_irq(&table->rwlock); in del_gid()
416 * add_modify_gid - Add or modify GID table entry
418 * @table: GID table in which GID to be added or modified
425 static int add_modify_gid(struct ib_gid_table *table, in add_modify_gid() argument
432 * Invalidate any old entry in the table to make it safe to write to in add_modify_gid()
435 if (is_gid_entry_valid(table->data_vec[attr->index])) in add_modify_gid()
436 del_gid(attr->device, attr->port_num, table, attr->index); in add_modify_gid()
441 * empty table entries instead of storing them. in add_modify_gid()
456 store_gid_entry(table, entry); in add_modify_gid()
465 static int find_gid(struct ib_gid_table *table, const union ib_gid *gid, in find_gid() argument
473 while (i < table->sz && (found < 0 || empty < 0)) { in find_gid()
474 struct ib_gid_table_entry *data = table->data_vec[i]; in find_gid()
488 is_gid_index_default(table, curr_index)) { in find_gid()
527 is_gid_index_default(table, curr_index) != default_gid) in find_gid()
549 struct ib_gid_table *table; in __ib_cache_gid_add() local
561 table = rdma_gid_table(ib_dev, port); in __ib_cache_gid_add()
563 mutex_lock(&table->lock); in __ib_cache_gid_add()
565 ix = find_gid(table, gid, attr, default_gid, mask, &empty); in __ib_cache_gid_add()
577 ret = add_modify_gid(table, attr); in __ib_cache_gid_add()
582 mutex_unlock(&table->lock); in __ib_cache_gid_add()
604 struct ib_gid_table *table; in _ib_cache_gid_del() local
608 table = rdma_gid_table(ib_dev, port); in _ib_cache_gid_del()
610 mutex_lock(&table->lock); in _ib_cache_gid_del()
612 ix = find_gid(table, gid, attr, default_gid, mask, NULL); in _ib_cache_gid_del()
618 del_gid(ib_dev, port, table, ix); in _ib_cache_gid_del()
622 mutex_unlock(&table->lock); in _ib_cache_gid_del()
643 struct ib_gid_table *table; in ib_cache_gid_del_all_netdev_gids() local
647 table = rdma_gid_table(ib_dev, port); in ib_cache_gid_del_all_netdev_gids()
649 mutex_lock(&table->lock); in ib_cache_gid_del_all_netdev_gids()
651 for (ix = 0; ix < table->sz; ix++) { in ib_cache_gid_del_all_netdev_gids()
652 if (is_gid_entry_valid(table->data_vec[ix]) && in ib_cache_gid_del_all_netdev_gids()
653 table->data_vec[ix]->attr.ndev == ndev) { in ib_cache_gid_del_all_netdev_gids()
654 del_gid(ib_dev, port, table, ix); in ib_cache_gid_del_all_netdev_gids()
659 mutex_unlock(&table->lock); in ib_cache_gid_del_all_netdev_gids()
688 struct ib_gid_table *table; in rdma_find_gid_by_port() local
698 table = rdma_gid_table(ib_dev, port); in rdma_find_gid_by_port()
703 read_lock_irqsave(&table->rwlock, flags); in rdma_find_gid_by_port()
704 local_index = find_gid(table, gid, &val, false, mask, NULL); in rdma_find_gid_by_port()
706 get_gid_entry(table->data_vec[local_index]); in rdma_find_gid_by_port()
707 attr = &table->data_vec[local_index]->attr; in rdma_find_gid_by_port()
708 read_unlock_irqrestore(&table->rwlock, flags); in rdma_find_gid_by_port()
712 read_unlock_irqrestore(&table->rwlock, flags); in rdma_find_gid_by_port()
718 * rdma_find_gid_by_filter - Returns the GID table attribute where a
724 * @filter: The filter function is executed on any matching GID in the table.
726 * otherwise, we continue searching the GID table. It's guaranteed that
732 * of which the filter function returns true in the port's GID table.
742 struct ib_gid_table *table; in rdma_find_gid_by_filter() local
749 table = rdma_gid_table(ib_dev, port); in rdma_find_gid_by_filter()
751 read_lock_irqsave(&table->rwlock, flags); in rdma_find_gid_by_filter()
752 for (i = 0; i < table->sz; i++) { in rdma_find_gid_by_filter()
753 struct ib_gid_table_entry *entry = table->data_vec[i]; in rdma_find_gid_by_filter()
767 read_unlock_irqrestore(&table->rwlock, flags); in rdma_find_gid_by_filter()
773 struct ib_gid_table *table = kzalloc_obj(*table); in alloc_gid_table() local
775 if (!table) in alloc_gid_table()
778 table->data_vec = kzalloc_objs(*table->data_vec, sz); in alloc_gid_table()
779 if (!table->data_vec) in alloc_gid_table()
782 mutex_init(&table->lock); in alloc_gid_table()
784 table->sz = sz; in alloc_gid_table()
785 rwlock_init(&table->rwlock); in alloc_gid_table()
786 return table; in alloc_gid_table()
789 kfree(table); in alloc_gid_table()
794 struct ib_gid_table *table) in release_gid_table() argument
798 if (!table) in release_gid_table()
801 for (i = 0; i < table->sz; i++) { in release_gid_table()
802 if (is_gid_entry_free(table->data_vec[i])) in release_gid_table()
808 kref_read(&table->data_vec[i]->kref)); in release_gid_table()
811 mutex_destroy(&table->lock); in release_gid_table()
812 kfree(table->data_vec); in release_gid_table()
813 kfree(table); in release_gid_table()
817 struct ib_gid_table *table) in cleanup_gid_table_port() argument
821 if (!table) in cleanup_gid_table_port()
824 mutex_lock(&table->lock); in cleanup_gid_table_port()
825 for (i = 0; i < table->sz; ++i) { in cleanup_gid_table_port()
826 if (is_gid_entry_valid(table->data_vec[i])) in cleanup_gid_table_port()
827 del_gid(ib_dev, port, table, i); in cleanup_gid_table_port()
829 mutex_unlock(&table->lock); in cleanup_gid_table_port()
866 struct ib_gid_table *table) in gid_table_reserve_default() argument
875 for (i = 0; i < num_default_gids && i < table->sz; i++) in gid_table_reserve_default()
876 table->default_gid_indices |= BIT(i); in gid_table_reserve_default()
892 struct ib_gid_table *table; in _gid_table_setup_one() local
896 table = alloc_gid_table( in _gid_table_setup_one()
898 if (!table) in _gid_table_setup_one()
901 gid_table_reserve_default(ib_dev, rdma_port, table); in _gid_table_setup_one()
902 ib_dev->port_data[rdma_port].cache.gid = table; in _gid_table_setup_one()
945 * @index: Index of the GID table entry to read
950 * hold any reference to the GID table entry in the HCA or software cache.
958 struct ib_gid_table *table; in rdma_query_gid() local
965 table = rdma_gid_table(device, port_num); in rdma_query_gid()
966 read_lock_irqsave(&table->rwlock, flags); in rdma_query_gid()
968 if (index < 0 || index >= table->sz) { in rdma_query_gid()
973 if (!is_gid_entry_valid(table->data_vec[index])) { in rdma_query_gid()
978 memcpy(gid, &table->data_vec[index]->attr.gid, sizeof(*gid)); in rdma_query_gid()
982 read_unlock_irqrestore(&table->rwlock, flags); in rdma_query_gid()
1031 struct ib_gid_table *table; in rdma_find_gid() local
1035 table = device->port_data[p].cache.gid; in rdma_find_gid()
1036 read_lock_irqsave(&table->rwlock, flags); in rdma_find_gid()
1037 index = find_gid(table, gid, &gid_attr_val, false, mask, NULL); in rdma_find_gid()
1041 get_gid_entry(table->data_vec[index]); in rdma_find_gid()
1042 attr = &table->data_vec[index]->attr; in rdma_find_gid()
1043 read_unlock_irqrestore(&table->rwlock, flags); in rdma_find_gid()
1046 read_unlock_irqrestore(&table->rwlock, flags); in rdma_find_gid()
1072 *pkey = cache->table[index]; in ib_get_cached_pkey()
1114 if ((cache->table[i] & 0x7fff) == (pkey & 0x7fff)) { in ib_find_cached_pkey()
1115 if (cache->table[i] & 0x8000) { in ib_find_cached_pkey()
1175 * @index: Index of the GID table entry whose attributes are to
1179 * cached GID table. Caller must invoke rdma_put_gid_attr() to release
1189 struct ib_gid_table *table; in rdma_get_gid_attr() local
1195 table = rdma_gid_table(device, port_num); in rdma_get_gid_attr()
1196 if (index < 0 || index >= table->sz) in rdma_get_gid_attr()
1199 read_lock_irqsave(&table->rwlock, flags); in rdma_get_gid_attr()
1200 if (!is_gid_entry_valid(table->data_vec[index])) in rdma_get_gid_attr()
1203 get_gid_entry(table->data_vec[index]); in rdma_get_gid_attr()
1204 attr = &table->data_vec[index]->attr; in rdma_get_gid_attr()
1206 read_unlock_irqrestore(&table->rwlock, flags); in rdma_get_gid_attr()
1212 * rdma_query_gid_table - Reads GID table entries of all the ports of a device up to max_entries.
1226 struct ib_gid_table *table; in rdma_query_gid_table() local
1232 table = rdma_gid_table(device, port_num); in rdma_query_gid_table()
1233 read_lock_irqsave(&table->rwlock, flags); in rdma_query_gid_table()
1234 for (i = 0; i < table->sz; i++) { in rdma_query_gid_table()
1235 if (!is_gid_entry_valid(table->data_vec[i])) in rdma_query_gid_table()
1242 gid_attr = &table->data_vec[i]->attr; in rdma_query_gid_table()
1251 lockdep_is_held(&table->rwlock)); in rdma_query_gid_table()
1258 read_unlock_irqrestore(&table->rwlock, flags); in rdma_query_gid_table()
1263 read_unlock_irqrestore(&table->rwlock, flags); in rdma_query_gid_table()
1326 struct ib_gid_table *table; in rdma_read_gid_attr_ndev_rcu() local
1330 table = rdma_gid_table(device, port_num); in rdma_read_gid_attr_ndev_rcu()
1332 read_lock_irqsave(&table->rwlock, flags); in rdma_read_gid_attr_ndev_rcu()
1333 valid = is_gid_entry_valid(table->data_vec[attr->index]); in rdma_read_gid_attr_ndev_rcu()
1339 read_unlock_irqrestore(&table->rwlock, flags); in rdma_read_gid_attr_ndev_rcu()
1408 struct ib_gid_table *table; in config_non_roce_gid_cache() local
1414 table = rdma_gid_table(device, port); in config_non_roce_gid_cache()
1416 mutex_lock(&table->lock); in config_non_roce_gid_cache()
1441 add_modify_gid(table, &gid_attr); in config_non_roce_gid_cache()
1444 mutex_unlock(&table->lock); in config_non_roce_gid_cache()
1481 pkey_cache = kmalloc_flex(*pkey_cache, table, in ib_cache_update()
1492 pkey_cache->table + i); in ib_cache_update()