diff options
Diffstat (limited to 'net/tipc/ib_media.c')
| -rw-r--r-- | net/tipc/ib_media.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/net/tipc/ib_media.c b/net/tipc/ib_media.c index 844a77e25828..8522eef9c136 100644 --- a/net/tipc/ib_media.c +++ b/net/tipc/ib_media.c | |||
| @@ -42,7 +42,7 @@ | |||
| 42 | #include "core.h" | 42 | #include "core.h" |
| 43 | #include "bearer.h" | 43 | #include "bearer.h" |
| 44 | 44 | ||
| 45 | /* convert InfiniBand address to string */ | 45 | /* convert InfiniBand address (media address format) media address to string */ |
| 46 | static int tipc_ib_addr2str(struct tipc_media_addr *a, char *str_buf, | 46 | static int tipc_ib_addr2str(struct tipc_media_addr *a, char *str_buf, |
| 47 | int str_size) | 47 | int str_size) |
| 48 | { | 48 | { |
| @@ -54,23 +54,35 @@ static int tipc_ib_addr2str(struct tipc_media_addr *a, char *str_buf, | |||
| 54 | return 0; | 54 | return 0; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | /* convert InfiniBand address format to message header format */ | 57 | /* Convert from media address format to discovery message addr format */ |
| 58 | static int tipc_ib_addr2msg(struct tipc_media_addr *a, char *msg_area) | 58 | static int tipc_ib_addr2msg(char *msg, struct tipc_media_addr *addr) |
| 59 | { | 59 | { |
| 60 | memset(msg_area, 0, TIPC_MEDIA_ADDR_SIZE); | 60 | memset(msg, 0, TIPC_MEDIA_ADDR_SIZE); |
| 61 | msg_area[TIPC_MEDIA_TYPE_OFFSET] = TIPC_MEDIA_TYPE_IB; | 61 | memcpy(msg, addr->value, INFINIBAND_ALEN); |
| 62 | memcpy(msg_area, a->value, INFINIBAND_ALEN); | ||
| 63 | return 0; | 62 | return 0; |
| 64 | } | 63 | } |
| 65 | 64 | ||
| 66 | /* convert message header address format to InfiniBand format */ | 65 | /* Convert raw InfiniBand address format to media addr format */ |
| 67 | static int tipc_ib_msg2addr(const struct tipc_bearer *tb_ptr, | 66 | static int tipc_ib_raw2addr(struct tipc_bearer *b, |
| 68 | struct tipc_media_addr *a, char *msg_area) | 67 | struct tipc_media_addr *addr, |
| 68 | char *msg) | ||
| 69 | { | 69 | { |
| 70 | tipc_l2_media_addr_set(tb_ptr, a, msg_area); | 70 | memset(addr, 0, sizeof(*addr)); |
| 71 | memcpy(addr->value, msg, INFINIBAND_ALEN); | ||
| 72 | addr->media_id = TIPC_MEDIA_TYPE_IB; | ||
| 73 | addr->broadcast = !memcmp(msg, b->bcast_addr.value, | ||
| 74 | INFINIBAND_ALEN); | ||
| 71 | return 0; | 75 | return 0; |
| 72 | } | 76 | } |
| 73 | 77 | ||
| 78 | /* Convert discovery msg addr format to InfiniBand media addr format */ | ||
| 79 | static int tipc_ib_msg2addr(struct tipc_bearer *b, | ||
| 80 | struct tipc_media_addr *addr, | ||
| 81 | char *msg) | ||
| 82 | { | ||
| 83 | return tipc_ib_raw2addr(b, addr, msg); | ||
| 84 | } | ||
| 85 | |||
| 74 | /* InfiniBand media registration info */ | 86 | /* InfiniBand media registration info */ |
| 75 | struct tipc_media ib_media_info = { | 87 | struct tipc_media ib_media_info = { |
| 76 | .send_msg = tipc_l2_send_msg, | 88 | .send_msg = tipc_l2_send_msg, |
| @@ -79,6 +91,7 @@ struct tipc_media ib_media_info = { | |||
| 79 | .addr2str = tipc_ib_addr2str, | 91 | .addr2str = tipc_ib_addr2str, |
| 80 | .addr2msg = tipc_ib_addr2msg, | 92 | .addr2msg = tipc_ib_addr2msg, |
| 81 | .msg2addr = tipc_ib_msg2addr, | 93 | .msg2addr = tipc_ib_msg2addr, |
| 94 | .raw2addr = tipc_ib_raw2addr, | ||
| 82 | .priority = TIPC_DEF_LINK_PRI, | 95 | .priority = TIPC_DEF_LINK_PRI, |
| 83 | .tolerance = TIPC_DEF_LINK_TOL, | 96 | .tolerance = TIPC_DEF_LINK_TOL, |
| 84 | .window = TIPC_DEF_LINK_WIN, | 97 | .window = TIPC_DEF_LINK_WIN, |
| @@ -86,4 +99,3 @@ struct tipc_media ib_media_info = { | |||
| 86 | .hwaddr_len = INFINIBAND_ALEN, | 99 | .hwaddr_len = INFINIBAND_ALEN, |
| 87 | .name = "ib" | 100 | .name = "ib" |
| 88 | }; | 101 | }; |
| 89 | |||
