36 #include <linux/module.h>
37 #include <linux/errno.h>
38 #include <linux/slab.h>
81 if (port_num < start_port(device) || port_num > end_port(device))
86 cache = device->
cache.gid_cache[port_num - start_port(device)];
88 if (index < 0 || index >= cache->
table_len)
115 for (p = 0; p <= end_port(device) - start_port(device); ++
p) {
116 cache = device->
cache.gid_cache[
p];
119 *port_num = p + start_port(device);
143 if (port_num < start_port(device) || port_num > end_port(device))
148 cache = device->
cache.pkey_cache[port_num - start_port(device)];
150 if (index < 0 || index >= cache->
table_len)
172 if (port_num < start_port(device) || port_num > end_port(device))
177 cache = device->
cache.pkey_cache[port_num - start_port(device)];
182 if ((cache->
table[i] & 0x7fff) == (pkey & 0x7fff)) {
183 if (cache->
table[i] & 0x8000) {
191 if (ret && partial_ix >= 0) {
212 if (port_num < start_port(device) || port_num > end_port(device))
217 cache = device->
cache.pkey_cache[port_num - start_port(device)];
222 if (cache->
table[i] == pkey) {
241 if (port_num < start_port(device) || port_num > end_port(device))
245 *lmc = device->
cache.lmc_cache[port_num - start_port(device)];
252 static void ib_cache_update(
struct ib_device *device,
290 ret, device->
name, i);
299 ret, device->
name, i);
306 old_pkey_cache = device->
cache.pkey_cache[port - start_port(device)];
307 old_gid_cache = device->
cache.gid_cache [port - start_port(device)];
309 device->
cache.pkey_cache[port - start_port(device)] = pkey_cache;
310 device->
cache.gid_cache [port - start_port(device)] = gid_cache;
312 device->
cache.lmc_cache[port - start_port(device)] = tprops->
lmc;
316 kfree(old_pkey_cache);
317 kfree(old_gid_cache);
327 static void ib_cache_task(
struct work_struct *_work)
351 work->
device =
event->device;
352 work->
port_num =
event->element.port_num;
358 static void ib_cache_setup_one(
struct ib_device *device)
364 device->
cache.pkey_cache =
366 (end_port(device) - start_port(device) + 1),
GFP_KERNEL);
367 device->
cache.gid_cache =
369 (end_port(device) - start_port(device) + 1),
GFP_KERNEL);
373 start_port(device) + 1),
376 if (!device->
cache.pkey_cache || !device->
cache.gid_cache ||
377 !device->
cache.lmc_cache) {
379 "for %s\n", device->
name);
383 for (p = 0; p <= end_port(device) - start_port(device); ++
p) {
386 ib_cache_update(device, p + start_port(device));
390 device, ib_cache_event);
397 for (p = 0; p <= end_port(device) - start_port(device); ++
p) {
408 static void ib_cache_cleanup_one(
struct ib_device *device)
415 for (p = 0; p <= end_port(device) - start_port(device); ++
p) {
427 .add = ib_cache_setup_one,
428 .remove = ib_cache_cleanup_one