diff options
author | Jon Paul Maloy <jon.maloy@ericsson.com> | 2014-05-14 05:39:13 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-05-14 15:19:48 -0400 |
commit | 38504c28a201a80d12a6a0f821fecb331cb1f223 (patch) | |
tree | 001139319f80f9d00cfa510638f61a1ec1725459 /net/tipc/bearer.h | |
parent | 37e22164a8a3c39bdad45aa463b1e69a1fdf4110 (diff) |
tipc: improve and extend media address conversion functions
TIPC currently handles two media specific addresses: Ethernet MAC
addresses and InfiniBand addresses. Those are kept in three different
formats:
1) A "raw" format as obtained from the device. This format is known
only by the media specific adapter code in eth_media.c and
ib_media.c.
2) A "generic" internal format, in the form of struct tipc_media_addr,
which can be referenced and passed around by the generic media-
unaware code.
3) A serialized version of the latter, to be conveyed in neighbor
discovery messages.
Conversion between the three formats can only be done by the media
specific code, so we have function pointers for this purpose in
struct tipc_media. Here, the media adapters can install their own
conversion functions at startup.
We now introduce a new such function, 'raw2addr()', whose purpose
is to convert from format 1 to format 2 above. We also try to as far
as possible uniform commenting, variable names and usage of these
functions, with the purpose of making them more comprehensible.
We can now also remove the function tipc_l2_media_addr_set(), whose
job is done better by the new function.
Finally, we expand the field for serialized addresses (format 3)
in discovery messages from 20 to 32 bytes. This is permitted
according to the spec, and reduces the risk of problems when we
add new media in the future.
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/bearer.h')
-rw-r--r-- | net/tipc/bearer.h | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h index a983b3005e71..78fccc49de23 100644 --- a/net/tipc/bearer.h +++ b/net/tipc/bearer.h | |||
@@ -42,14 +42,12 @@ | |||
42 | #define MAX_BEARERS 2 | 42 | #define MAX_BEARERS 2 |
43 | #define MAX_MEDIA 2 | 43 | #define MAX_MEDIA 2 |
44 | 44 | ||
45 | /* | 45 | /* Identifiers associated with TIPC message header media address info |
46 | * Identifiers associated with TIPC message header media address info | 46 | * - address info field is 32 bytes long |
47 | * | 47 | * - the field's actual content and length is defined per media |
48 | * - address info field is 20 bytes long | 48 | * - remaining unused bytes in the field are set to zero |
49 | * - media type identifier located at offset 3 | ||
50 | * - remaining bytes vary according to media type | ||
51 | */ | 49 | */ |
52 | #define TIPC_MEDIA_ADDR_SIZE 20 | 50 | #define TIPC_MEDIA_ADDR_SIZE 32 |
53 | #define TIPC_MEDIA_TYPE_OFFSET 3 | 51 | #define TIPC_MEDIA_TYPE_OFFSET 3 |
54 | 52 | ||
55 | /* | 53 | /* |
@@ -77,9 +75,10 @@ struct tipc_bearer; | |||
77 | * @send_msg: routine which handles buffer transmission | 75 | * @send_msg: routine which handles buffer transmission |
78 | * @enable_media: routine which enables a media | 76 | * @enable_media: routine which enables a media |
79 | * @disable_media: routine which disables a media | 77 | * @disable_media: routine which disables a media |
80 | * @addr2str: routine which converts media address to string | 78 | * @addr2str: convert media address format to string |
81 | * @addr2msg: routine which converts media address to protocol message area | 79 | * @addr2msg: convert from media addr format to discovery msg addr format |
82 | * @msg2addr: routine which converts media address from protocol message area | 80 | * @msg2addr: convert from discovery msg addr format to media addr format |
81 | * @raw2addr: convert from raw addr format to media addr format | ||
83 | * @priority: default link (and bearer) priority | 82 | * @priority: default link (and bearer) priority |
84 | * @tolerance: default time (in ms) before declaring link failure | 83 | * @tolerance: default time (in ms) before declaring link failure |
85 | * @window: default window (in packets) before declaring link congestion | 84 | * @window: default window (in packets) before declaring link congestion |
@@ -93,10 +92,16 @@ struct tipc_media { | |||
93 | struct tipc_media_addr *dest); | 92 | struct tipc_media_addr *dest); |
94 | int (*enable_media)(struct tipc_bearer *b_ptr); | 93 | int (*enable_media)(struct tipc_bearer *b_ptr); |
95 | void (*disable_media)(struct tipc_bearer *b_ptr); | 94 | void (*disable_media)(struct tipc_bearer *b_ptr); |
96 | int (*addr2str)(struct tipc_media_addr *a, char *str_buf, int str_size); | 95 | int (*addr2str)(struct tipc_media_addr *addr, |
97 | int (*addr2msg)(struct tipc_media_addr *a, char *msg_area); | 96 | char *strbuf, |
98 | int (*msg2addr)(const struct tipc_bearer *b_ptr, | 97 | int bufsz); |
99 | struct tipc_media_addr *a, char *msg_area); | 98 | int (*addr2msg)(char *msg, struct tipc_media_addr *addr); |
99 | int (*msg2addr)(struct tipc_bearer *b, | ||
100 | struct tipc_media_addr *addr, | ||
101 | char *msg); | ||
102 | int (*raw2addr)(struct tipc_bearer *b, | ||
103 | struct tipc_media_addr *addr, | ||
104 | char *raw); | ||
100 | u32 priority; | 105 | u32 priority; |
101 | u32 tolerance; | 106 | u32 tolerance; |
102 | u32 window; | 107 | u32 window; |
@@ -175,8 +180,6 @@ int tipc_media_set_priority(const char *name, u32 new_value); | |||
175 | int tipc_media_set_window(const char *name, u32 new_value); | 180 | int tipc_media_set_window(const char *name, u32 new_value); |
176 | void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a); | 181 | void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a); |
177 | struct sk_buff *tipc_media_get_names(void); | 182 | struct sk_buff *tipc_media_get_names(void); |
178 | void tipc_l2_media_addr_set(const struct tipc_bearer *b, | ||
179 | struct tipc_media_addr *a, char *mac); | ||
180 | int tipc_enable_l2_media(struct tipc_bearer *b); | 183 | int tipc_enable_l2_media(struct tipc_bearer *b); |
181 | void tipc_disable_l2_media(struct tipc_bearer *b); | 184 | void tipc_disable_l2_media(struct tipc_bearer *b); |
182 | int tipc_l2_send_msg(struct sk_buff *buf, struct tipc_bearer *b, | 185 | int tipc_l2_send_msg(struct sk_buff *buf, struct tipc_bearer *b, |