Skip to content

Commit 2551c40

Browse files
committed
Merge branch 'tipc-ipoib'
Patrick McHardy says: ==================== The following patchset adds support for running TIPC over InfiniBand. The patchset consists of three parts (+ a minor fix for the ethernet media type): - Preparation: removal of an the unused str2addr callback and move of the bcast_addr from struct tipc_media to struct tipc_bearer. This is necessary because InfiniBand doesn't have a fixed broadcast address like ethernet, so it needs to be initialized with the device's broadcast address when the bearer is enabled - Introduction of a TIPC InfiniBand media type. A new media type is needed to deal with the different address sizes - Support for ETH_P_TIPC in IPoIB Since the last posting I've addressed all feedback I received and rebased to the current net-next tree. I consider these patches ready for merging. Since they mainly affect TIPC code, I'd propose to have them either go through the TIPC tree or through Dave directly (not sure how TIPC patches are managed). ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents a6bda45 + dc850b0 commit 2551c40

File tree

10 files changed

+438
-42
lines changed

10 files changed

+438
-42
lines changed

drivers/infiniband/ulp/ipoib/ipoib_main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,8 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
730730
if ((header->proto != htons(ETH_P_IP)) &&
731731
(header->proto != htons(ETH_P_IPV6)) &&
732732
(header->proto != htons(ETH_P_ARP)) &&
733-
(header->proto != htons(ETH_P_RARP))) {
733+
(header->proto != htons(ETH_P_RARP)) &&
734+
(header->proto != htons(ETH_P_TIPC))) {
734735
/* ethertype not supported by IPoIB */
735736
++dev->stats.tx_dropped;
736737
dev_kfree_skb_any(skb);
@@ -751,6 +752,7 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
751752
switch (header->proto) {
752753
case htons(ETH_P_IP):
753754
case htons(ETH_P_IPV6):
755+
case htons(ETH_P_TIPC):
754756
neigh = ipoib_neigh_get(dev, cb->hwaddr);
755757
if (unlikely(!neigh)) {
756758
neigh_add_path(skb, cb->hwaddr, dev);

net/tipc/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,10 @@ config TIPC_PORTS
3131

3232
Setting this to a smaller value saves some memory,
3333
setting it to higher allows for more ports.
34+
35+
config TIPC_MEDIA_IB
36+
bool "InfiniBand media type support"
37+
depends on TIPC && INFINIBAND_IPOIB
38+
help
39+
Saying Y here will enable support for running TIPC on
40+
IP-over-InfiniBand devices.

net/tipc/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ tipc-y += addr.o bcast.o bearer.o config.o \
99
name_distr.o subscr.o name_table.o net.o \
1010
netlink.o node.o node_subscr.o port.o ref.o \
1111
socket.o log.o eth_media.o
12+
13+
tipc-$(CONFIG_TIPC_MEDIA_IB) += ib_media.o

net/tipc/bcast.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,10 +620,10 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
620620
continue; /* bearer pair doesn't add anything */
621621

622622
if (!tipc_bearer_blocked(p))
623-
tipc_bearer_send(p, buf, &p->media->bcast_addr);
623+
tipc_bearer_send(p, buf, &p->bcast_addr);
624624
else if (s && !tipc_bearer_blocked(s))
625625
/* unable to send on primary bearer */
626-
tipc_bearer_send(s, buf, &s->media->bcast_addr);
626+
tipc_bearer_send(s, buf, &s->bcast_addr);
627627
else
628628
/* unable to send on either bearer */
629629
continue;

net/tipc/bearer.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include "bearer.h"
4040
#include "discover.h"
4141

42-
#define MAX_ADDR_STR 32
42+
#define MAX_ADDR_STR 60
4343

4444
static struct tipc_media *media_list[MAX_MEDIA];
4545
static u32 media_count;
@@ -89,9 +89,6 @@ int tipc_register_media(struct tipc_media *m_ptr)
8989

9090
if ((strlen(m_ptr->name) + 1) > TIPC_MAX_MEDIA_NAME)
9191
goto exit;
92-
if ((m_ptr->bcast_addr.media_id != m_ptr->type_id) ||
93-
!m_ptr->bcast_addr.broadcast)
94-
goto exit;
9592
if (m_ptr->priority > TIPC_MAX_LINK_PRI)
9693
goto exit;
9794
if ((m_ptr->tolerance < TIPC_MIN_LINK_TOL) ||
@@ -407,7 +404,7 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
407404
INIT_LIST_HEAD(&b_ptr->links);
408405
spin_lock_init(&b_ptr->lock);
409406

410-
res = tipc_disc_create(b_ptr, &m_ptr->bcast_addr, disc_domain);
407+
res = tipc_disc_create(b_ptr, &b_ptr->bcast_addr, disc_domain);
411408
if (res) {
412409
bearer_disable(b_ptr);
413410
pr_warn("Bearer <%s> rejected, discovery object creation failed\n",

net/tipc/bearer.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
* Identifiers of supported TIPC media types
5757
*/
5858
#define TIPC_MEDIA_TYPE_ETH 1
59+
#define TIPC_MEDIA_TYPE_IB 2
5960

6061
/**
6162
* struct tipc_media_addr - destination address used by TIPC bearers
@@ -77,7 +78,6 @@ struct tipc_bearer;
7778
* @enable_bearer: routine which enables a bearer
7879
* @disable_bearer: routine which disables a bearer
7980
* @addr2str: routine which converts media address to string
80-
* @str2addr: routine which converts media address from string
8181
* @addr2msg: routine which converts media address to protocol message area
8282
* @msg2addr: routine which converts media address from protocol message area
8383
* @bcast_addr: media address used in broadcasting
@@ -94,10 +94,9 @@ struct tipc_media {
9494
int (*enable_bearer)(struct tipc_bearer *b_ptr);
9595
void (*disable_bearer)(struct tipc_bearer *b_ptr);
9696
int (*addr2str)(struct tipc_media_addr *a, char *str_buf, int str_size);
97-
int (*str2addr)(struct tipc_media_addr *a, char *str_buf);
9897
int (*addr2msg)(struct tipc_media_addr *a, char *msg_area);
99-
int (*msg2addr)(struct tipc_media_addr *a, char *msg_area);
100-
struct tipc_media_addr bcast_addr;
98+
int (*msg2addr)(const struct tipc_bearer *b_ptr,
99+
struct tipc_media_addr *a, char *msg_area);
101100
u32 priority;
102101
u32 tolerance;
103102
u32 window;
@@ -136,6 +135,7 @@ struct tipc_bearer {
136135
char name[TIPC_MAX_BEARER_NAME];
137136
spinlock_t lock;
138137
struct tipc_media *media;
138+
struct tipc_media_addr bcast_addr;
139139
u32 priority;
140140
u32 window;
141141
u32 tolerance;
@@ -175,6 +175,14 @@ int tipc_disable_bearer(const char *name);
175175
int tipc_eth_media_start(void);
176176
void tipc_eth_media_stop(void);
177177

178+
#ifdef CONFIG_TIPC_MEDIA_IB
179+
int tipc_ib_media_start(void);
180+
void tipc_ib_media_stop(void);
181+
#else
182+
static inline int tipc_ib_media_start(void) { return 0; }
183+
static inline void tipc_ib_media_stop(void) { return; }
184+
#endif
185+
178186
int tipc_media_set_priority(const char *name, u32 new_value);
179187
int tipc_media_set_window(const char *name, u32 new_value);
180188
void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a);

net/tipc/core.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ static void tipc_core_stop_net(void)
8282
{
8383
tipc_net_stop();
8484
tipc_eth_media_stop();
85+
tipc_ib_media_stop();
8586
}
8687

8788
/**
@@ -93,8 +94,15 @@ int tipc_core_start_net(unsigned long addr)
9394

9495
tipc_net_start(addr);
9596
res = tipc_eth_media_start();
96-
if (res)
97-
tipc_core_stop_net();
97+
if (res < 0)
98+
goto err;
99+
res = tipc_ib_media_start();
100+
if (res < 0)
101+
goto err;
102+
return res;
103+
104+
err:
105+
tipc_core_stop_net();
98106
return res;
99107
}
100108

net/tipc/discover.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr)
129129
int link_fully_up;
130130

131131
media_addr.broadcast = 1;
132-
b_ptr->media->msg2addr(&media_addr, msg_media_addr(msg));
132+
b_ptr->media->msg2addr(b_ptr, &media_addr, msg_media_addr(msg));
133133
kfree_skb(buf);
134134

135135
/* Ensure message from node is valid and communication is permitted */

net/tipc/eth_media.c

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,13 @@ static struct notifier_block notifier = {
7777
* Media-dependent "value" field stores MAC address in first 6 bytes
7878
* and zeroes out the remaining bytes.
7979
*/
80-
static void eth_media_addr_set(struct tipc_media_addr *a, char *mac)
80+
static void eth_media_addr_set(const struct tipc_bearer *tb_ptr,
81+
struct tipc_media_addr *a, char *mac)
8182
{
8283
memcpy(a->value, mac, ETH_ALEN);
8384
memset(a->value + ETH_ALEN, 0, sizeof(a->value) - ETH_ALEN);
8485
a->media_id = TIPC_MEDIA_TYPE_ETH;
85-
a->broadcast = !memcmp(mac, eth_media_info.bcast_addr.value, ETH_ALEN);
86+
a->broadcast = !memcmp(mac, tb_ptr->bcast_addr.value, ETH_ALEN);
8687
}
8788

8889
/**
@@ -110,6 +111,7 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr,
110111

111112
skb_reset_network_header(clone);
112113
clone->dev = dev;
114+
clone->protocol = htons(ETH_P_TIPC);
113115
dev_hard_header(clone, dev, ETH_P_TIPC, dest->value,
114116
dev->dev_addr, clone->len);
115117
dev_queue_xmit(clone);
@@ -201,9 +203,13 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
201203
/* Associate TIPC bearer with Ethernet bearer */
202204
eb_ptr->bearer = tb_ptr;
203205
tb_ptr->usr_handle = (void *)eb_ptr;
206+
memset(tb_ptr->bcast_addr.value, 0, sizeof(tb_ptr->bcast_addr.value));
207+
memcpy(tb_ptr->bcast_addr.value, dev->broadcast, ETH_ALEN);
208+
tb_ptr->bcast_addr.media_id = TIPC_MEDIA_TYPE_ETH;
209+
tb_ptr->bcast_addr.broadcast = 1;
204210
tb_ptr->mtu = dev->mtu;
205211
tb_ptr->blocked = 0;
206-
eth_media_addr_set(&tb_ptr->addr, (char *)dev->dev_addr);
212+
eth_media_addr_set(tb_ptr, &tb_ptr->addr, (char *)dev->dev_addr);
207213
return 0;
208214
}
209215

@@ -301,25 +307,6 @@ static int eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size)
301307
return 0;
302308
}
303309

304-
/**
305-
* eth_str2addr - convert string to Ethernet address
306-
*/
307-
static int eth_str2addr(struct tipc_media_addr *a, char *str_buf)
308-
{
309-
char mac[ETH_ALEN];
310-
int r;
311-
312-
r = sscanf(str_buf, "%02x:%02x:%02x:%02x:%02x:%02x",
313-
(u32 *)&mac[0], (u32 *)&mac[1], (u32 *)&mac[2],
314-
(u32 *)&mac[3], (u32 *)&mac[4], (u32 *)&mac[5]);
315-
316-
if (r != ETH_ALEN)
317-
return 1;
318-
319-
eth_media_addr_set(a, mac);
320-
return 0;
321-
}
322-
323310
/**
324311
* eth_str2addr - convert Ethernet address format to message header format
325312
*/
@@ -334,12 +321,13 @@ static int eth_addr2msg(struct tipc_media_addr *a, char *msg_area)
334321
/**
335322
* eth_str2addr - convert message header address format to Ethernet format
336323
*/
337-
static int eth_msg2addr(struct tipc_media_addr *a, char *msg_area)
324+
static int eth_msg2addr(const struct tipc_bearer *tb_ptr,
325+
struct tipc_media_addr *a, char *msg_area)
338326
{
339327
if (msg_area[TIPC_MEDIA_TYPE_OFFSET] != TIPC_MEDIA_TYPE_ETH)
340328
return 1;
341329

342-
eth_media_addr_set(a, msg_area + ETH_ADDR_OFFSET);
330+
eth_media_addr_set(tb_ptr, a, msg_area + ETH_ADDR_OFFSET);
343331
return 0;
344332
}
345333

@@ -351,11 +339,8 @@ static struct tipc_media eth_media_info = {
351339
.enable_bearer = enable_bearer,
352340
.disable_bearer = disable_bearer,
353341
.addr2str = eth_addr2str,
354-
.str2addr = eth_str2addr,
355342
.addr2msg = eth_addr2msg,
356343
.msg2addr = eth_msg2addr,
357-
.bcast_addr = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
358-
TIPC_MEDIA_TYPE_ETH, 1 },
359344
.priority = TIPC_DEF_LINK_PRI,
360345
.tolerance = TIPC_DEF_LINK_TOL,
361346
.window = TIPC_DEF_LINK_WIN,

0 commit comments

Comments
 (0)