Lines Matching refs:table
49 u16 table[0]; member
172 struct ib_gid_table *table, int ix, in write_gid() argument
177 __releases(&table->rwlock) __acquires(&table->rwlock) in write_gid()
188 table->data_vec[ix].props |= GID_TABLE_ENTRY_INVALID; in write_gid()
189 write_unlock_irq(&table->rwlock); in write_gid()
195 &table->data_vec[ix].context); in write_gid()
198 &table->data_vec[ix].context); in write_gid()
199 write_lock_irq(&table->rwlock); in write_gid()
202 old_net_dev = table->data_vec[ix].attr.ndev; in write_gid()
203 old_gid_type = table->data_vec[ix].attr.gid_type; in write_gid()
210 table->data_vec[ix].context = NULL; in write_gid()
213 memcpy(&table->data_vec[ix].gid, gid, sizeof(*gid)); in write_gid()
214 memcpy(&table->data_vec[ix].attr, attr, sizeof(*attr)); in write_gid()
216 table->data_vec[ix].props |= GID_TABLE_ENTRY_DEFAULT; in write_gid()
218 table->data_vec[ix].attr.gid_type = old_gid_type; in write_gid()
220 if (table->data_vec[ix].attr.ndev && in write_gid()
221 table->data_vec[ix].attr.ndev != old_net_dev) in write_gid()
222 dev_hold(table->data_vec[ix].attr.ndev); in write_gid()
224 table->data_vec[ix].props &= ~GID_TABLE_ENTRY_INVALID; in write_gid()
230 struct ib_gid_table *table, int ix, in add_gid() argument
234 return write_gid(ib_dev, port, table, ix, gid, attr, in add_gid()
239 struct ib_gid_table *table, int ix, in modify_gid() argument
243 return write_gid(ib_dev, port, table, ix, gid, attr, in modify_gid()
248 struct ib_gid_table *table, int ix, in del_gid() argument
250 return write_gid(ib_dev, port, table, ix, &zgid, &zattr, in del_gid()
255 static int find_gid(struct ib_gid_table *table, const union ib_gid *gid, in find_gid() argument
263 while (i < table->sz && (found < 0 || empty < 0)) { in find_gid()
264 struct ib_gid_table_entry *data = &table->data_vec[i]; in find_gid()
318 struct ib_gid_table *table; in ib_cache_gid_add() local
324 table = ports_table[port - rdma_start_port(ib_dev)]; in ib_cache_gid_add()
345 mutex_lock(&table->lock); in ib_cache_gid_add()
346 write_lock_irq(&table->rwlock); in ib_cache_gid_add()
348 ix = find_gid(table, gid, attr, false, GID_ATTR_FIND_MASK_GID | in ib_cache_gid_add()
359 ret = add_gid(ib_dev, port, table, empty, gid, attr, false); in ib_cache_gid_add()
364 write_unlock_irq(&table->rwlock); in ib_cache_gid_add()
365 mutex_unlock(&table->lock); in ib_cache_gid_add()
373 struct ib_gid_table *table; in ib_cache_gid_del() local
376 table = ports_table[port - rdma_start_port(ib_dev)]; in ib_cache_gid_del()
378 mutex_lock(&table->lock); in ib_cache_gid_del()
379 write_lock_irq(&table->rwlock); in ib_cache_gid_del()
381 ix = find_gid(table, gid, attr, false, in ib_cache_gid_del()
390 if (!del_gid(ib_dev, port, table, ix, false)) in ib_cache_gid_del()
394 write_unlock_irq(&table->rwlock); in ib_cache_gid_del()
395 mutex_unlock(&table->lock); in ib_cache_gid_del()
403 struct ib_gid_table *table; in ib_cache_gid_del_all_netdev_gids() local
407 table = ports_table[port - rdma_start_port(ib_dev)]; in ib_cache_gid_del_all_netdev_gids()
409 mutex_lock(&table->lock); in ib_cache_gid_del_all_netdev_gids()
410 write_lock_irq(&table->rwlock); in ib_cache_gid_del_all_netdev_gids()
412 for (ix = 0; ix < table->sz; ix++) in ib_cache_gid_del_all_netdev_gids()
413 if (table->data_vec[ix].attr.ndev == ndev) in ib_cache_gid_del_all_netdev_gids()
414 if (!del_gid(ib_dev, port, table, ix, in ib_cache_gid_del_all_netdev_gids()
415 !!(table->data_vec[ix].props & in ib_cache_gid_del_all_netdev_gids()
419 write_unlock_irq(&table->rwlock); in ib_cache_gid_del_all_netdev_gids()
420 mutex_unlock(&table->lock); in ib_cache_gid_del_all_netdev_gids()
432 struct ib_gid_table *table; in __ib_cache_gid_get() local
434 table = ports_table[port - rdma_start_port(ib_dev)]; in __ib_cache_gid_get()
436 if (index < 0 || index >= table->sz) in __ib_cache_gid_get()
439 if (table->data_vec[index].props & GID_TABLE_ENTRY_INVALID) in __ib_cache_gid_get()
442 memcpy(gid, &table->data_vec[index].gid, sizeof(*gid)); in __ib_cache_gid_get()
444 memcpy(attr, &table->data_vec[index].attr, sizeof(*attr)); in __ib_cache_gid_get()
459 struct ib_gid_table *table; in _ib_cache_gid_table_find() local
465 table = ports_table[p]; in _ib_cache_gid_table_find()
466 read_lock_irqsave(&table->rwlock, flags); in _ib_cache_gid_table_find()
467 local_index = find_gid(table, gid, val, false, mask, NULL); in _ib_cache_gid_table_find()
473 read_unlock_irqrestore(&table->rwlock, flags); in _ib_cache_gid_table_find()
476 read_unlock_irqrestore(&table->rwlock, flags); in _ib_cache_gid_table_find()
507 struct ib_gid_table *table; in ib_find_cached_gid_by_port() local
517 table = ports_table[port - rdma_start_port(ib_dev)]; in ib_find_cached_gid_by_port()
522 read_lock_irqsave(&table->rwlock, flags); in ib_find_cached_gid_by_port()
523 local_index = find_gid(table, gid, &val, false, mask, NULL); in ib_find_cached_gid_by_port()
527 read_unlock_irqrestore(&table->rwlock, flags); in ib_find_cached_gid_by_port()
531 read_unlock_irqrestore(&table->rwlock, flags); in ib_find_cached_gid_by_port()
566 struct ib_gid_table *table; in ib_cache_gid_find_by_filter() local
579 table = ports_table[port - rdma_start_port(ib_dev)]; in ib_cache_gid_find_by_filter()
581 read_lock_irqsave(&table->rwlock, flags); in ib_cache_gid_find_by_filter()
582 for (i = 0; i < table->sz; i++) { in ib_cache_gid_find_by_filter()
585 if (table->data_vec[i].props & GID_TABLE_ENTRY_INVALID) in ib_cache_gid_find_by_filter()
588 if (memcmp(gid, &table->data_vec[i].gid, sizeof(*gid))) in ib_cache_gid_find_by_filter()
591 memcpy(&attr, &table->data_vec[i].attr, sizeof(attr)); in ib_cache_gid_find_by_filter()
600 read_unlock_irqrestore(&table->rwlock, flags); in ib_cache_gid_find_by_filter()
612 struct ib_gid_table *table = in alloc_gid_table() local
615 if (!table) in alloc_gid_table()
618 table->data_vec = kcalloc(sz, sizeof(*table->data_vec), GFP_KERNEL); in alloc_gid_table()
619 if (!table->data_vec) in alloc_gid_table()
622 mutex_init(&table->lock); in alloc_gid_table()
624 table->sz = sz; in alloc_gid_table()
625 rwlock_init(&table->rwlock); in alloc_gid_table()
627 return table; in alloc_gid_table()
630 kfree(table); in alloc_gid_table()
634 static void release_gid_table(struct ib_gid_table *table) in release_gid_table() argument
636 if (table) { in release_gid_table()
637 kfree(table->data_vec); in release_gid_table()
638 kfree(table); in release_gid_table()
643 struct ib_gid_table *table) in cleanup_gid_table_port() argument
648 if (!table) in cleanup_gid_table_port()
651 write_lock_irq(&table->rwlock); in cleanup_gid_table_port()
652 for (i = 0; i < table->sz; ++i) { in cleanup_gid_table_port()
653 if (memcmp(&table->data_vec[i].gid, &zgid, in cleanup_gid_table_port()
654 sizeof(table->data_vec[i].gid))) in cleanup_gid_table_port()
655 if (!del_gid(ib_dev, port, table, i, in cleanup_gid_table_port()
656 table->data_vec[i].props & in cleanup_gid_table_port()
660 write_unlock_irq(&table->rwlock); in cleanup_gid_table_port()
675 struct ib_gid_table *table; in ib_cache_gid_set_default_gid() local
678 table = ports_table[port - rdma_start_port(ib_dev)]; in ib_cache_gid_set_default_gid()
694 mutex_lock(&table->lock); in ib_cache_gid_set_default_gid()
695 write_lock_irq(&table->rwlock); in ib_cache_gid_set_default_gid()
696 ix = find_gid(table, NULL, &gid_attr, true, in ib_cache_gid_set_default_gid()
717 if (del_gid(ib_dev, port, table, ix, true)) { in ib_cache_gid_set_default_gid()
727 if (add_gid(ib_dev, port, table, ix, &gid, &gid_attr, true)) in ib_cache_gid_set_default_gid()
737 write_unlock_irq(&table->rwlock); in ib_cache_gid_set_default_gid()
738 mutex_unlock(&table->lock); in ib_cache_gid_set_default_gid()
743 struct ib_gid_table *table) in gid_table_reserve_default() argument
752 for (i = 0; i < num_default_gids && i < table->sz; i++) { in gid_table_reserve_default()
754 &table->data_vec[i]; in gid_table_reserve_default()
769 struct ib_gid_table **table; in _gid_table_setup_one() local
772 table = kcalloc(ib_dev->phys_port_cnt, sizeof(*table), GFP_KERNEL); in _gid_table_setup_one()
773 if (!table) in _gid_table_setup_one()
779 table[port] = in _gid_table_setup_one()
782 if (!table[port]) { in _gid_table_setup_one()
789 table[port]); in _gid_table_setup_one()
794 ib_dev->cache.gid_cache = table; in _gid_table_setup_one()
800 table[port]); in _gid_table_setup_one()
801 release_gid_table(table[port]); in _gid_table_setup_one()
804 kfree(table); in _gid_table_setup_one()
810 struct ib_gid_table **table = ib_dev->cache.gid_cache; in gid_table_release_one() local
813 if (!table) in gid_table_release_one()
817 release_gid_table(table[port]); in gid_table_release_one()
819 kfree(table); in gid_table_release_one()
825 struct ib_gid_table **table = ib_dev->cache.gid_cache; in gid_table_cleanup_one() local
828 if (!table) in gid_table_cleanup_one()
833 table[port]); in gid_table_cleanup_one()
864 struct ib_gid_table *table = ports_table[port_num - rdma_start_port(device)]; in ib_get_cached_gid() local
869 read_lock_irqsave(&table->rwlock, flags); in ib_get_cached_gid()
871 read_unlock_irqrestore(&table->rwlock, flags); in ib_get_cached_gid()
925 *pkey = cache->table[index]; in ib_get_cached_pkey()
954 if ((cache->table[i] & 0x7fff) == (pkey & 0x7fff)) { in ib_find_cached_pkey()
955 if (cache->table[i] & 0x8000) { in ib_find_cached_pkey()
994 if (cache->table[i] == pkey) { in ib_find_exact_cached_pkey()
1031 union ib_gid table[0]; in ib_cache_update() member
1035 struct ib_gid_table *table; in ib_cache_update() local
1043 table = ports_table[port - rdma_start_port(device)]; in ib_cache_update()
1057 sizeof *pkey_cache->table, GFP_KERNEL); in ib_cache_update()
1065 sizeof(*gid_cache->table), GFP_KERNEL); in ib_cache_update()
1073 ret = ib_query_pkey(device, port, i, pkey_cache->table + i); in ib_cache_update()
1084 gid_cache->table + i, NULL); in ib_cache_update()
1099 write_lock(&table->rwlock); in ib_cache_update()
1101 modify_gid(device, port, table, i, gid_cache->table + i, in ib_cache_update()
1104 write_unlock(&table->rwlock); in ib_cache_update()