Commit 2551c405 authored by David S. Miller's avatar David S. Miller

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: default avatarDavid S. Miller <davem@davemloft.net>
parents a6bda459 dc850b0e
...@@ -730,7 +730,8 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -730,7 +730,8 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
if ((header->proto != htons(ETH_P_IP)) && if ((header->proto != htons(ETH_P_IP)) &&
(header->proto != htons(ETH_P_IPV6)) && (header->proto != htons(ETH_P_IPV6)) &&
(header->proto != htons(ETH_P_ARP)) && (header->proto != htons(ETH_P_ARP)) &&
(header->proto != htons(ETH_P_RARP))) { (header->proto != htons(ETH_P_RARP)) &&
(header->proto != htons(ETH_P_TIPC))) {
/* ethertype not supported by IPoIB */ /* ethertype not supported by IPoIB */
++dev->stats.tx_dropped; ++dev->stats.tx_dropped;
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
...@@ -751,6 +752,7 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -751,6 +752,7 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
switch (header->proto) { switch (header->proto) {
case htons(ETH_P_IP): case htons(ETH_P_IP):
case htons(ETH_P_IPV6): case htons(ETH_P_IPV6):
case htons(ETH_P_TIPC):
neigh = ipoib_neigh_get(dev, cb->hwaddr); neigh = ipoib_neigh_get(dev, cb->hwaddr);
if (unlikely(!neigh)) { if (unlikely(!neigh)) {
neigh_add_path(skb, cb->hwaddr, dev); neigh_add_path(skb, cb->hwaddr, dev);
......
...@@ -31,3 +31,10 @@ config TIPC_PORTS ...@@ -31,3 +31,10 @@ config TIPC_PORTS
Setting this to a smaller value saves some memory, Setting this to a smaller value saves some memory,
setting it to higher allows for more ports. setting it to higher allows for more ports.
config TIPC_MEDIA_IB
bool "InfiniBand media type support"
depends on TIPC && INFINIBAND_IPOIB
help
Saying Y here will enable support for running TIPC on
IP-over-InfiniBand devices.
...@@ -9,3 +9,5 @@ tipc-y += addr.o bcast.o bearer.o config.o \ ...@@ -9,3 +9,5 @@ tipc-y += addr.o bcast.o bearer.o config.o \
name_distr.o subscr.o name_table.o net.o \ name_distr.o subscr.o name_table.o net.o \
netlink.o node.o node_subscr.o port.o ref.o \ netlink.o node.o node_subscr.o port.o ref.o \
socket.o log.o eth_media.o socket.o log.o eth_media.o
tipc-$(CONFIG_TIPC_MEDIA_IB) += ib_media.o
...@@ -620,10 +620,10 @@ static int tipc_bcbearer_send(struct sk_buff *buf, ...@@ -620,10 +620,10 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
continue; /* bearer pair doesn't add anything */ continue; /* bearer pair doesn't add anything */
if (!tipc_bearer_blocked(p)) if (!tipc_bearer_blocked(p))
tipc_bearer_send(p, buf, &p->media->bcast_addr); tipc_bearer_send(p, buf, &p->bcast_addr);
else if (s && !tipc_bearer_blocked(s)) else if (s && !tipc_bearer_blocked(s))
/* unable to send on primary bearer */ /* unable to send on primary bearer */
tipc_bearer_send(s, buf, &s->media->bcast_addr); tipc_bearer_send(s, buf, &s->bcast_addr);
else else
/* unable to send on either bearer */ /* unable to send on either bearer */
continue; continue;
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include "bearer.h" #include "bearer.h"
#include "discover.h" #include "discover.h"
#define MAX_ADDR_STR 32 #define MAX_ADDR_STR 60
static struct tipc_media *media_list[MAX_MEDIA]; static struct tipc_media *media_list[MAX_MEDIA];
static u32 media_count; static u32 media_count;
...@@ -89,9 +89,6 @@ int tipc_register_media(struct tipc_media *m_ptr) ...@@ -89,9 +89,6 @@ int tipc_register_media(struct tipc_media *m_ptr)
if ((strlen(m_ptr->name) + 1) > TIPC_MAX_MEDIA_NAME) if ((strlen(m_ptr->name) + 1) > TIPC_MAX_MEDIA_NAME)
goto exit; goto exit;
if ((m_ptr->bcast_addr.media_id != m_ptr->type_id) ||
!m_ptr->bcast_addr.broadcast)
goto exit;
if (m_ptr->priority > TIPC_MAX_LINK_PRI) if (m_ptr->priority > TIPC_MAX_LINK_PRI)
goto exit; goto exit;
if ((m_ptr->tolerance < TIPC_MIN_LINK_TOL) || if ((m_ptr->tolerance < TIPC_MIN_LINK_TOL) ||
...@@ -407,7 +404,7 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority) ...@@ -407,7 +404,7 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
INIT_LIST_HEAD(&b_ptr->links); INIT_LIST_HEAD(&b_ptr->links);
spin_lock_init(&b_ptr->lock); spin_lock_init(&b_ptr->lock);
res = tipc_disc_create(b_ptr, &m_ptr->bcast_addr, disc_domain); res = tipc_disc_create(b_ptr, &b_ptr->bcast_addr, disc_domain);
if (res) { if (res) {
bearer_disable(b_ptr); bearer_disable(b_ptr);
pr_warn("Bearer <%s> rejected, discovery object creation failed\n", pr_warn("Bearer <%s> rejected, discovery object creation failed\n",
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
* Identifiers of supported TIPC media types * Identifiers of supported TIPC media types
*/ */
#define TIPC_MEDIA_TYPE_ETH 1 #define TIPC_MEDIA_TYPE_ETH 1
#define TIPC_MEDIA_TYPE_IB 2
/** /**
* struct tipc_media_addr - destination address used by TIPC bearers * struct tipc_media_addr - destination address used by TIPC bearers
...@@ -77,7 +78,6 @@ struct tipc_bearer; ...@@ -77,7 +78,6 @@ struct tipc_bearer;
* @enable_bearer: routine which enables a bearer * @enable_bearer: routine which enables a bearer
* @disable_bearer: routine which disables a bearer * @disable_bearer: routine which disables a bearer
* @addr2str: routine which converts media address to string * @addr2str: routine which converts media address to string
* @str2addr: routine which converts media address from string
* @addr2msg: routine which converts media address to protocol message area * @addr2msg: routine which converts media address to protocol message area
* @msg2addr: routine which converts media address from protocol message area * @msg2addr: routine which converts media address from protocol message area
* @bcast_addr: media address used in broadcasting * @bcast_addr: media address used in broadcasting
...@@ -94,10 +94,9 @@ struct tipc_media { ...@@ -94,10 +94,9 @@ struct tipc_media {
int (*enable_bearer)(struct tipc_bearer *b_ptr); int (*enable_bearer)(struct tipc_bearer *b_ptr);
void (*disable_bearer)(struct tipc_bearer *b_ptr); void (*disable_bearer)(struct tipc_bearer *b_ptr);
int (*addr2str)(struct tipc_media_addr *a, char *str_buf, int str_size); int (*addr2str)(struct tipc_media_addr *a, char *str_buf, int str_size);
int (*str2addr)(struct tipc_media_addr *a, char *str_buf);
int (*addr2msg)(struct tipc_media_addr *a, char *msg_area); int (*addr2msg)(struct tipc_media_addr *a, char *msg_area);
int (*msg2addr)(struct tipc_media_addr *a, char *msg_area); int (*msg2addr)(const struct tipc_bearer *b_ptr,
struct tipc_media_addr bcast_addr; struct tipc_media_addr *a, char *msg_area);
u32 priority; u32 priority;
u32 tolerance; u32 tolerance;
u32 window; u32 window;
...@@ -136,6 +135,7 @@ struct tipc_bearer { ...@@ -136,6 +135,7 @@ struct tipc_bearer {
char name[TIPC_MAX_BEARER_NAME]; char name[TIPC_MAX_BEARER_NAME];
spinlock_t lock; spinlock_t lock;
struct tipc_media *media; struct tipc_media *media;
struct tipc_media_addr bcast_addr;
u32 priority; u32 priority;
u32 window; u32 window;
u32 tolerance; u32 tolerance;
...@@ -175,6 +175,14 @@ int tipc_disable_bearer(const char *name); ...@@ -175,6 +175,14 @@ int tipc_disable_bearer(const char *name);
int tipc_eth_media_start(void); int tipc_eth_media_start(void);
void tipc_eth_media_stop(void); void tipc_eth_media_stop(void);
#ifdef CONFIG_TIPC_MEDIA_IB
int tipc_ib_media_start(void);
void tipc_ib_media_stop(void);
#else
static inline int tipc_ib_media_start(void) { return 0; }
static inline void tipc_ib_media_stop(void) { return; }
#endif
int tipc_media_set_priority(const char *name, u32 new_value); int tipc_media_set_priority(const char *name, u32 new_value);
int tipc_media_set_window(const char *name, u32 new_value); int tipc_media_set_window(const char *name, u32 new_value);
void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a); void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a);
......
...@@ -82,6 +82,7 @@ static void tipc_core_stop_net(void) ...@@ -82,6 +82,7 @@ static void tipc_core_stop_net(void)
{ {
tipc_net_stop(); tipc_net_stop();
tipc_eth_media_stop(); tipc_eth_media_stop();
tipc_ib_media_stop();
} }
/** /**
...@@ -93,8 +94,15 @@ int tipc_core_start_net(unsigned long addr) ...@@ -93,8 +94,15 @@ int tipc_core_start_net(unsigned long addr)
tipc_net_start(addr); tipc_net_start(addr);
res = tipc_eth_media_start(); res = tipc_eth_media_start();
if (res) if (res < 0)
tipc_core_stop_net(); goto err;
res = tipc_ib_media_start();
if (res < 0)
goto err;
return res;
err:
tipc_core_stop_net();
return res; return res;
} }
......
...@@ -129,7 +129,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr) ...@@ -129,7 +129,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr)
int link_fully_up; int link_fully_up;
media_addr.broadcast = 1; media_addr.broadcast = 1;
b_ptr->media->msg2addr(&media_addr, msg_media_addr(msg)); b_ptr->media->msg2addr(b_ptr, &media_addr, msg_media_addr(msg));
kfree_skb(buf); kfree_skb(buf);
/* Ensure message from node is valid and communication is permitted */ /* Ensure message from node is valid and communication is permitted */
......
...@@ -77,12 +77,13 @@ static struct notifier_block notifier = { ...@@ -77,12 +77,13 @@ static struct notifier_block notifier = {
* Media-dependent "value" field stores MAC address in first 6 bytes * Media-dependent "value" field stores MAC address in first 6 bytes
* and zeroes out the remaining bytes. * and zeroes out the remaining bytes.
*/ */
static void eth_media_addr_set(struct tipc_media_addr *a, char *mac) static void eth_media_addr_set(const struct tipc_bearer *tb_ptr,
struct tipc_media_addr *a, char *mac)
{ {
memcpy(a->value, mac, ETH_ALEN); memcpy(a->value, mac, ETH_ALEN);
memset(a->value + ETH_ALEN, 0, sizeof(a->value) - ETH_ALEN); memset(a->value + ETH_ALEN, 0, sizeof(a->value) - ETH_ALEN);
a->media_id = TIPC_MEDIA_TYPE_ETH; a->media_id = TIPC_MEDIA_TYPE_ETH;
a->broadcast = !memcmp(mac, eth_media_info.bcast_addr.value, ETH_ALEN); a->broadcast = !memcmp(mac, tb_ptr->bcast_addr.value, ETH_ALEN);
} }
/** /**
...@@ -110,6 +111,7 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, ...@@ -110,6 +111,7 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr,
skb_reset_network_header(clone); skb_reset_network_header(clone);
clone->dev = dev; clone->dev = dev;
clone->protocol = htons(ETH_P_TIPC);
dev_hard_header(clone, dev, ETH_P_TIPC, dest->value, dev_hard_header(clone, dev, ETH_P_TIPC, dest->value,
dev->dev_addr, clone->len); dev->dev_addr, clone->len);
dev_queue_xmit(clone); dev_queue_xmit(clone);
...@@ -201,9 +203,13 @@ static int enable_bearer(struct tipc_bearer *tb_ptr) ...@@ -201,9 +203,13 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
/* Associate TIPC bearer with Ethernet bearer */ /* Associate TIPC bearer with Ethernet bearer */
eb_ptr->bearer = tb_ptr; eb_ptr->bearer = tb_ptr;
tb_ptr->usr_handle = (void *)eb_ptr; tb_ptr->usr_handle = (void *)eb_ptr;
memset(tb_ptr->bcast_addr.value, 0, sizeof(tb_ptr->bcast_addr.value));
memcpy(tb_ptr->bcast_addr.value, dev->broadcast, ETH_ALEN);
tb_ptr->bcast_addr.media_id = TIPC_MEDIA_TYPE_ETH;
tb_ptr->bcast_addr.broadcast = 1;
tb_ptr->mtu = dev->mtu; tb_ptr->mtu = dev->mtu;
tb_ptr->blocked = 0; tb_ptr->blocked = 0;
eth_media_addr_set(&tb_ptr->addr, (char *)dev->dev_addr); eth_media_addr_set(tb_ptr, &tb_ptr->addr, (char *)dev->dev_addr);
return 0; return 0;
} }
...@@ -301,25 +307,6 @@ static int eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size) ...@@ -301,25 +307,6 @@ static int eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size)
return 0; return 0;
} }
/**
* eth_str2addr - convert string to Ethernet address
*/
static int eth_str2addr(struct tipc_media_addr *a, char *str_buf)
{
char mac[ETH_ALEN];
int r;
r = sscanf(str_buf, "%02x:%02x:%02x:%02x:%02x:%02x",
(u32 *)&mac[0], (u32 *)&mac[1], (u32 *)&mac[2],
(u32 *)&mac[3], (u32 *)&mac[4], (u32 *)&mac[5]);
if (r != ETH_ALEN)
return 1;
eth_media_addr_set(a, mac);
return 0;
}
/** /**
* eth_str2addr - convert Ethernet address format to message header format * eth_str2addr - convert Ethernet address format to message header format
*/ */
...@@ -334,12 +321,13 @@ static int eth_addr2msg(struct tipc_media_addr *a, char *msg_area) ...@@ -334,12 +321,13 @@ static int eth_addr2msg(struct tipc_media_addr *a, char *msg_area)
/** /**
* eth_str2addr - convert message header address format to Ethernet format * eth_str2addr - convert message header address format to Ethernet format
*/ */
static int eth_msg2addr(struct tipc_media_addr *a, char *msg_area) static int eth_msg2addr(const struct tipc_bearer *tb_ptr,
struct tipc_media_addr *a, char *msg_area)
{ {
if (msg_area[TIPC_MEDIA_TYPE_OFFSET] != TIPC_MEDIA_TYPE_ETH) if (msg_area[TIPC_MEDIA_TYPE_OFFSET] != TIPC_MEDIA_TYPE_ETH)
return 1; return 1;
eth_media_addr_set(a, msg_area + ETH_ADDR_OFFSET); eth_media_addr_set(tb_ptr, a, msg_area + ETH_ADDR_OFFSET);
return 0; return 0;
} }
...@@ -351,11 +339,8 @@ static struct tipc_media eth_media_info = { ...@@ -351,11 +339,8 @@ static struct tipc_media eth_media_info = {
.enable_bearer = enable_bearer, .enable_bearer = enable_bearer,
.disable_bearer = disable_bearer, .disable_bearer = disable_bearer,
.addr2str = eth_addr2str, .addr2str = eth_addr2str,
.str2addr = eth_str2addr,
.addr2msg = eth_addr2msg, .addr2msg = eth_addr2msg,
.msg2addr = eth_msg2addr, .msg2addr = eth_msg2addr,
.bcast_addr = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
TIPC_MEDIA_TYPE_ETH, 1 },
.priority = TIPC_DEF_LINK_PRI, .priority = TIPC_DEF_LINK_PRI,
.tolerance = TIPC_DEF_LINK_TOL, .tolerance = TIPC_DEF_LINK_TOL,
.window = TIPC_DEF_LINK_WIN, .window = TIPC_DEF_LINK_WIN,
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment