diff options
Diffstat (limited to 'net/tipc/ib_media.c')
-rw-r--r-- | net/tipc/ib_media.c | 192 |
1 files changed, 3 insertions, 189 deletions
diff --git a/net/tipc/ib_media.c b/net/tipc/ib_media.c index 9fdf03cd672b..62d91aeda058 100644 --- a/net/tipc/ib_media.c +++ b/net/tipc/ib_media.c @@ -42,34 +42,6 @@ #include "core.h" #include "bearer.h" -#define MAX_IB_MEDIA MAX_BEARERS - -/** - * struct ib_media - Infiniband media data structure - * @bearer: ptr to associated "generic" bearer structure - * @dev: ptr to associated Infiniband network device - * @tipc_packet_type: used in binding TIPC to Infiniband driver - * @cleanup: work item used when disabling bearer - */ - -struct ib_media { - struct tipc_bearer *bearer; - struct net_device *dev; - struct packet_type tipc_packet_type; - struct work_struct setup; - struct work_struct cleanup; -}; - -static struct ib_media ib_media_array[MAX_IB_MEDIA]; -static int ib_started; -static int recv_msg(struct sk_buff *buf, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev); - -static struct packet_type tipc_packet_type __read_mostly = { - .type = __constant_htons(ETH_P_TIPC), - .func = recv_msg, -}; - /** * ib_media_addr_set - initialize Infiniband media address structure * @@ -92,16 +64,14 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, struct tipc_media_addr *dest) { struct sk_buff *clone; - struct net_device *dev; int delta; + struct net_device *dev = tb_ptr->dev; clone = skb_clone(buf, GFP_ATOMIC); if (!clone) return 0; - dev = ((struct ib_media *)(tb_ptr->usr_handle))->dev; delta = dev->hard_header_len - skb_headroom(buf); - if ((delta > 0) && pskb_expand_head(clone, SKB_DATA_ALIGN(delta), 0, GFP_ATOMIC)) { kfree_skb(clone); @@ -118,79 +88,21 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, } /** - * recv_msg - handle incoming TIPC message from an InfiniBand interface - * - * Accept only packets explicitly sent to this node, or broadcast packets; - * ignores packets sent using InfiniBand multicast, and traffic sent to other - * nodes (which can happen if interface is running in promiscuous mode). - */ -static int recv_msg(struct sk_buff *buf, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) -{ - struct tipc_bearer *b_ptr; - - if (!net_eq(dev_net(dev), &init_net)) { - kfree_skb(buf); - return NET_RX_DROP; - } - - rcu_read_lock(); - b_ptr = rcu_dereference(dev->tipc_ptr); - if (likely(b_ptr)) { - if (likely(buf->pkt_type <= PACKET_BROADCAST)) { - buf->next = NULL; - tipc_recv_msg(buf, b_ptr); - rcu_read_unlock(); - return NET_RX_SUCCESS; - } - } - rcu_read_unlock(); - - kfree_skb(buf); - return NET_RX_DROP; -} - -/** - * setup_bearer - setup association between InfiniBand bearer and interface - */ -static void setup_media(struct work_struct *work) -{ - dev_add_pack(&tipc_packet_type); -} - -/** * enable_media - attach TIPC bearer to an InfiniBand interface */ static int enable_media(struct tipc_bearer *tb_ptr) { struct net_device *dev; - struct ib_media *ib_ptr = &ib_media_array[0]; - struct ib_media *stop = &ib_media_array[MAX_IB_MEDIA]; char *driver_name = strchr((const char *)tb_ptr->name, ':') + 1; - int pending_dev = 0; - - /* Find unused InfiniBand bearer structure */ - while (ib_ptr->dev) { - if (!ib_ptr->bearer) - pending_dev++; - if (++ib_ptr == stop) - return pending_dev ? -EAGAIN : -EDQUOT; - } /* Find device with specified name */ dev = dev_get_by_name(&init_net, driver_name); if (!dev) return -ENODEV; - /* Create InfiniBand bearer for device */ - ib_ptr->dev = dev; - INIT_WORK(&ib_ptr->setup, setup_media); - schedule_work(&ib_ptr->setup); - /* Associate TIPC bearer with InfiniBand bearer */ tb_ptr->dev = dev; - ib_ptr->bearer = tb_ptr; - tb_ptr->usr_handle = (void *)ib_ptr; + tb_ptr->usr_handle = NULL; memset(tb_ptr->bcast_addr.value, 0, sizeof(tb_ptr->bcast_addr.value)); memcpy(tb_ptr->bcast_addr.value, dev->broadcast, INFINIBAND_ALEN); tb_ptr->bcast_addr.media_id = TIPC_MEDIA_TYPE_IB; @@ -202,21 +114,6 @@ static int enable_media(struct tipc_bearer *tb_ptr) } /** - * cleanup_bearer - break association between InfiniBand bearer and interface - * - * This routine must be invoked from a work queue because it can sleep. - */ -static void cleanup_bearer(struct work_struct *work) -{ - struct ib_media *ib_ptr = - container_of(work, struct ib_media, cleanup); - - dev_remove_pack(&tipc_packet_type); - dev_put(ib_ptr->dev); - ib_ptr->dev = NULL; -} - -/** * disable_media - detach TIPC bearer from an InfiniBand interface * * Mark InfiniBand bearer as inactive so that incoming buffers are thrown away, @@ -225,63 +122,11 @@ static void cleanup_bearer(struct work_struct *work) */ static void disable_media(struct tipc_bearer *tb_ptr) { - struct ib_media *ib_ptr = (struct ib_media *)tb_ptr->usr_handle; - - ib_ptr->bearer = NULL; - INIT_WORK(&ib_ptr->cleanup, cleanup_bearer); - schedule_work(&ib_ptr->cleanup); RCU_INIT_POINTER(tb_ptr->dev->tipc_ptr, NULL); + dev_put(tb_ptr->dev); } /** - * recv_notification - handle device updates from OS - * - * Change the state of the InfiniBand bearer (if any) associated with the - * specified device. - */ -static int recv_notification(struct notifier_block *nb, unsigned long evt, - void *ptr) -{ - struct tipc_bearer *b_ptr; - struct net_device *dev = netdev_notifier_info_to_dev(ptr); - - if (!net_eq(dev_net(dev), &init_net)) - return NOTIFY_DONE; - - rcu_read_lock(); - b_ptr = rcu_dereference(dev->tipc_ptr); - if (!b_ptr) { - rcu_read_unlock(); - return NOTIFY_DONE; /* bearer had been disabled */ - } - - b_ptr->mtu = dev->mtu; - - switch (evt) { - case NETDEV_CHANGE: - if (netif_carrier_ok(dev)) - break; - case NETDEV_DOWN: - case NETDEV_CHANGEMTU: - case NETDEV_CHANGEADDR: - tipc_reset_bearer(b_ptr); - break; - case NETDEV_UNREGISTER: - case NETDEV_CHANGENAME: - tipc_disable_bearer(b_ptr->name); - break; - } - rcu_read_unlock(); - - return NOTIFY_OK; -} - -static struct notifier_block notifier = { - .notifier_call = recv_notification, - .priority = 0, -}; - -/** * ib_addr2str - convert InfiniBand address to string */ static int ib_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size) @@ -332,34 +177,3 @@ struct tipc_media ib_media_info = { .name = "ib" }; -/** - * tipc_ib_media_start - activate InfiniBand bearer support - * - * Register InfiniBand media type with TIPC bearer code. Also register - * with OS for notifications about device state changes. - */ -int tipc_ib_media_start(void) -{ - int res; - - if (ib_started) - return -EINVAL; - - res = register_netdevice_notifier(¬ifier); - if (!res) - ib_started = 1; - return res; -} - -/** - * tipc_ib_media_stop - deactivate InfiniBand bearer support - */ -void tipc_ib_media_stop(void) -{ - if (!ib_started) - return; - - flush_scheduled_work(); - unregister_netdevice_notifier(¬ifier); - ib_started = 0; -} |