34 #include <linux/module.h>
35 #include <linux/string.h>
36 #include <linux/errno.h>
37 #include <linux/kernel.h>
38 #include <linux/slab.h>
72 #define IB_MANDATORY_FUNC(x) { offsetof(struct ib_device, x), #x }
76 } mandatory_table[] = {
100 if (!*(
void **) ((
void *) device + mandatory_table[i].
offset)) {
102 device->
name, mandatory_table[i].name);
110 static struct ib_device *__ib_device_get_by_name(
const char *
name)
122 static
int alloc_name(
char *name)
124 unsigned long *
inuse;
147 if (__ib_device_get_by_name(buf))
154 static int start_port(
struct ib_device *device)
160 static int end_port(
struct ib_device *device)
225 static int read_port_table_lengths(
struct ib_device *device)
235 num_ports = end_port(device) - start_port(device) + 1;
244 for (port_index = 0; port_index < num_ports; ++port_index) {
282 ret = alloc_name(device->
name);
287 if (ib_device_check_mandatory(device)) {
297 ret = read_port_table_lengths(device);
321 if (client->
add && !add_client_context(device, client))
388 if (client->
add && !add_client_context(device, client))
419 if (context->
client == client) {
447 if (context->
client == client) {
474 if (context->
client == client) {
502 &event_handler->
device->event_handler_list);
503 spin_unlock_irqrestore(&event_handler->
device->event_handler_lock, flags);
522 spin_unlock_irqrestore(&event_handler->
device->event_handler_lock, flags);
544 handler->
handler(handler, event);
546 spin_unlock_irqrestore(&event->
device->event_handler_lock, flags);
578 if (port_num < start_port(device) || port_num > end_port(device))
581 return device->
query_port(device, port_num, port_attr);
597 return device->
query_gid(device, port_num, index, gid);
613 return device->
query_pkey(device, port_num, index, pkey);
627 int device_modify_mask,
656 if (port_num < start_port(device) || port_num > end_port(device))
659 return device->
modify_port(device, port_num, port_modify_mask,
679 for (port = start_port(device); port <= end_port(device); ++
port) {
680 for (i = 0; i < device->
gid_tbl_len[port - start_port(device)]; ++
i) {
684 if (!
memcmp(&tmp_gid, gid,
sizeof *gid)) {
712 for (i = 0; i < device->
pkey_tbl_len[port_num - start_port(device)]; ++
i) {
716 if ((pkey & 0x7fff) == (tmp_pkey & 0x7fff)) {
718 if (tmp_pkey & 0x8000) {
728 if (partial_ix >= 0) {
736 static int __init ib_core_init(
void)
775 static void __exit ib_core_cleanup(
void)