diff options
author | Ying Xue <ying.xue@windriver.com> | 2013-12-10 23:45:43 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-12-11 00:17:43 -0500 |
commit | e4d050cbf7720d8bcc781f4ef557d37ed148a5c4 (patch) | |
tree | 57e491fae1ead5a0c587c1085266dbdbb9d30f45 /net/tipc/bearer.h | |
parent | 6e967adf798ae5066488fd0c2b2466d06c642f23 (diff) |
tipc: eliminate code duplication in media layer
Currently TIPC supports two L2 media types, Ethernet and Infiniband.
Because both these media are accessed through the common net_device API,
several functions in the two media adaptation files turn out to be
fully or almost identical, leading to unnecessary code duplication.
In this commit we extract this common code from the two media files
and move them to the generic bearer.c. Additionally, we change
the function names to reflect their real role: to access L2 media,
irrespective of type.
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Cc: Patrick McHardy <kaber@trash.net>
Reviewed-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/bearer.h')
-rw-r--r-- | net/tipc/bearer.h | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h index 0974c2f2bbe5..fa95c34ca926 100644 --- a/net/tipc/bearer.h +++ b/net/tipc/bearer.h | |||
@@ -84,6 +84,7 @@ struct tipc_bearer; | |||
84 | * @tolerance: default time (in ms) before declaring link failure | 84 | * @tolerance: default time (in ms) before declaring link failure |
85 | * @window: default window (in packets) before declaring link congestion | 85 | * @window: default window (in packets) before declaring link congestion |
86 | * @type_id: TIPC media identifier | 86 | * @type_id: TIPC media identifier |
87 | * @hwaddr_len: TIPC media address len | ||
87 | * @name: media name | 88 | * @name: media name |
88 | */ | 89 | */ |
89 | struct tipc_media { | 90 | struct tipc_media { |
@@ -100,6 +101,7 @@ struct tipc_media { | |||
100 | u32 tolerance; | 101 | u32 tolerance; |
101 | u32 window; | 102 | u32 window; |
102 | u32 type_id; | 103 | u32 type_id; |
104 | u32 hwaddr_len; | ||
103 | char name[TIPC_MAX_MEDIA_NAME]; | 105 | char name[TIPC_MAX_MEDIA_NAME]; |
104 | }; | 106 | }; |
105 | 107 | ||
@@ -128,8 +130,7 @@ struct tipc_media { | |||
128 | * care of initializing all other fields. | 130 | * care of initializing all other fields. |
129 | */ | 131 | */ |
130 | struct tipc_bearer { | 132 | struct tipc_bearer { |
131 | struct net_device *dev; | 133 | void *media_ptr; /* initalized by media */ |
132 | void *usr_handle; /* initalized by media */ | ||
133 | u32 mtu; /* initalized by media */ | 134 | u32 mtu; /* initalized by media */ |
134 | struct tipc_media_addr addr; /* initalized by media */ | 135 | struct tipc_media_addr addr; /* initalized by media */ |
135 | char name[TIPC_MAX_BEARER_NAME]; | 136 | char name[TIPC_MAX_BEARER_NAME]; |
@@ -178,6 +179,12 @@ int tipc_media_set_priority(const char *name, u32 new_value); | |||
178 | int tipc_media_set_window(const char *name, u32 new_value); | 179 | int tipc_media_set_window(const char *name, u32 new_value); |
179 | void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a); | 180 | void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a); |
180 | struct sk_buff *tipc_media_get_names(void); | 181 | struct sk_buff *tipc_media_get_names(void); |
182 | void tipc_l2_media_addr_set(const struct tipc_bearer *b, | ||
183 | struct tipc_media_addr *a, char *mac); | ||
184 | int tipc_enable_l2_media(struct tipc_bearer *b); | ||
185 | void tipc_disable_l2_media(struct tipc_bearer *b); | ||
186 | int tipc_l2_send_msg(struct sk_buff *buf, struct tipc_bearer *b, | ||
187 | struct tipc_media_addr *dest); | ||
181 | 188 | ||
182 | struct sk_buff *tipc_bearer_get_names(void); | 189 | struct sk_buff *tipc_bearer_get_names(void); |
183 | void tipc_bearer_add_dest(struct tipc_bearer *b_ptr, u32 dest); | 190 | void tipc_bearer_add_dest(struct tipc_bearer *b_ptr, u32 dest); |
@@ -188,18 +195,7 @@ struct tipc_media *tipc_media_find(const char *name); | |||
188 | int tipc_bearer_setup(void); | 195 | int tipc_bearer_setup(void); |
189 | void tipc_bearer_cleanup(void); | 196 | void tipc_bearer_cleanup(void); |
190 | void tipc_bearer_stop(void); | 197 | void tipc_bearer_stop(void); |
191 | 198 | void tipc_bearer_send(struct tipc_bearer *b, struct sk_buff *buf, | |
192 | /** | 199 | struct tipc_media_addr *dest); |
193 | * tipc_bearer_send- sends buffer to destination over bearer | ||
194 | * | ||
195 | * IMPORTANT: | ||
196 | * The media send routine must not alter the buffer being passed in | ||
197 | * as it may be needed for later retransmission! | ||
198 | */ | ||
199 | static inline void tipc_bearer_send(struct tipc_bearer *b, struct sk_buff *buf, | ||
200 | struct tipc_media_addr *dest) | ||
201 | { | ||
202 | b->media->send_msg(buf, b, dest); | ||
203 | } | ||
204 | 200 | ||
205 | #endif /* _TIPC_BEARER_H */ | 201 | #endif /* _TIPC_BEARER_H */ |