linux/drivers/infiniband/ulp/ipoib/ipoib_main.c

/*
 * Copyright (c) 2004 Topspin Communications.  All rights reserved.
 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
 * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
 *
 * This software is available to you under a choice of one of two
 * licenses.  You may choose to be licensed under the terms of the GNU
 * General Public License (GPL) Version 2, available from the file
 * COPYING in the main directory of this source tree, or the
 * OpenIB.org BSD license below:
 *
 *     Redistribution and use in source and binary forms, with or
 *     without modification, are permitted provided that the following
 *     conditions are met:
 *
 *      - Redistributions of source code must retain the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer.
 *
 *      - Redistributions in binary form must reproduce the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer in the documentation and/or other materials
 *        provided with the distribution.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#include "ipoib.h"

#include <linux/module.h>

#include <linux/init.h>
#include <linux/slab.h>
#include <linux/kernel.h>
#include <linux/vmalloc.h>

#include <linux/if_arp.h>	/* For ARPHRD_xxx */

#include <linux/ip.h>
#include <linux/in.h>

#include <linux/jhash.h>
#include <net/arp.h>
#include <net/addrconf.h>
#include <linux/inetdevice.h>
#include <rdma/ib_cache.h>

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();

int ipoib_sendq_size __read_mostly =;
int ipoib_recvq_size __read_mostly =;

module_param_named(send_queue_size, ipoib_sendq_size, int, 0444);
MODULE_PARM_DESC();
module_param_named(recv_queue_size, ipoib_recvq_size, int, 0444);
MODULE_PARM_DESC();

#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
int ipoib_debug_level;

module_param_named(debug_level, ipoib_debug_level, int, 0644);
MODULE_PARM_DESC();
#endif

struct ipoib_path_iter {};

static const u8 ipv4_bcast_addr[] =;

struct workqueue_struct *ipoib_workqueue;

struct ib_sa_client ipoib_sa_client;

static int ipoib_add_one(struct ib_device *device);
static void ipoib_remove_one(struct ib_device *device, void *client_data);
static void ipoib_neigh_reclaim(struct rcu_head *rp);
static struct net_device *ipoib_get_net_dev_by_params(
		struct ib_device *dev, u32 port, u16 pkey,
		const union ib_gid *gid, const struct sockaddr *addr,
		void *client_data);
static int ipoib_set_mac(struct net_device *dev, void *addr);
static int ipoib_ioctl(struct net_device *dev, struct ifreq *ifr,
		       int cmd);

static struct ib_client ipoib_client =;

#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
static int ipoib_netdev_event(struct notifier_block *this,
			      unsigned long event, void *ptr)
{}
#endif

int ipoib_open(struct net_device *dev)
{}

static int ipoib_stop(struct net_device *dev)
{}

static netdev_features_t ipoib_fix_features(struct net_device *dev, netdev_features_t features)
{}

static int ipoib_change_mtu(struct net_device *dev, int new_mtu)
{}

static void ipoib_get_stats(struct net_device *dev,
			    struct rtnl_link_stats64 *stats)
{}

/* Called with an RCU read lock taken */
static bool ipoib_is_dev_match_addr_rcu(const struct sockaddr *addr,
					struct net_device *dev)
{}

/*
 * Find the master net_device on top of the given net_device.
 * @dev: base IPoIB net_device
 *
 * Returns the master net_device with a reference held, or the same net_device
 * if no master exists.
 */
static struct net_device *ipoib_get_master_net_dev(struct net_device *dev)
{}

struct ipoib_walk_data {};

static int ipoib_upper_walk(struct net_device *upper,
			    struct netdev_nested_priv *priv)
{}

/**
 * ipoib_get_net_dev_match_addr - Find a net_device matching
 * the given address, which is an upper device of the given net_device.
 *
 * @addr: IP address to look for.
 * @dev: base IPoIB net_device
 *
 * If found, returns the net_device with a reference held. Otherwise return
 * NULL.
 */
static struct net_device *ipoib_get_net_dev_match_addr(
		const struct sockaddr *addr, struct net_device *dev)
{}

/* returns the number of IPoIB netdevs on top a given ipoib device matching a
 * pkey_index and address, if one exists.
 *
 * @found_net_dev: contains a matching net_device if the return value >= 1,
 * with a reference held. */
static int ipoib_match_gid_pkey_addr(struct ipoib_dev_priv *priv,
				     const union ib_gid *gid,
				     u16 pkey_index,
				     const struct sockaddr *addr,
				     int nesting,
				     struct net_device **found_net_dev)
{}

/* Returns the number of matching net_devs found (between 0 and 2). Also
 * return the matching net_device in the @net_dev parameter, holding a
 * reference to the net_device, if the number of matches >= 1 */
static int __ipoib_get_net_dev_by_params(struct list_head *dev_list, u32 port,
					 u16 pkey_index,
					 const union ib_gid *gid,
					 const struct sockaddr *addr,
					 struct net_device **net_dev)
{}

static struct net_device *ipoib_get_net_dev_by_params(
		struct ib_device *dev, u32 port, u16 pkey,
		const union ib_gid *gid, const struct sockaddr *addr,
		void *client_data)
{}

int ipoib_set_mode(struct net_device *dev, const char *buf)
{}

struct ipoib_path *__path_find(struct net_device *dev, void *gid)
{}

static int __path_add(struct net_device *dev, struct ipoib_path *path)
{}

static void path_free(struct net_device *dev, struct ipoib_path *path)
{}

#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG

struct ipoib_path_iter *ipoib_path_iter_init(struct net_device *dev)
{}

int ipoib_path_iter_next(struct ipoib_path_iter *iter)
{}

void ipoib_path_iter_read(struct ipoib_path_iter *iter,
			  struct ipoib_path *path)
{}

#endif /* CONFIG_INFINIBAND_IPOIB_DEBUG */

void ipoib_mark_paths_invalid(struct net_device *dev)
{}

static void push_pseudo_header(struct sk_buff *skb, const char *daddr)
{}

void ipoib_flush_paths(struct net_device *dev)
{}

static void path_rec_completion(int status,
				struct sa_path_rec *pathrec,
				unsigned int num_prs, void *path_ptr)
{}

static void init_path_rec(struct ipoib_dev_priv *priv, struct ipoib_path *path,
			  void *gid)
{}

static struct ipoib_path *path_rec_create(struct net_device *dev, void *gid)
{}

static int path_rec_start(struct net_device *dev,
			  struct ipoib_path *path)
{}

static void neigh_refresh_path(struct ipoib_neigh *neigh, u8 *daddr,
			       struct net_device *dev)
{}

static struct ipoib_neigh *neigh_add_path(struct sk_buff *skb, u8 *daddr,
					  struct net_device *dev)
{}

static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
			     struct ipoib_pseudo_header *phdr)
{}

static netdev_tx_t ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
{}

static void ipoib_timeout(struct net_device *dev, unsigned int txqueue)
{}

void ipoib_ib_tx_timeout_work(struct work_struct *work)
{}

static int ipoib_hard_header(struct sk_buff *skb,
			     struct net_device *dev,
			     unsigned short type,
			     const void *daddr,
			     const void *saddr,
			     unsigned int len)
{}

static void ipoib_set_mcast_list(struct net_device *dev)
{}

static int ipoib_get_iflink(const struct net_device *dev)
{}

static u32 ipoib_addr_hash(struct ipoib_neigh_hash *htbl, u8 *daddr)
{}

struct ipoib_neigh *ipoib_neigh_get(struct net_device *dev, u8 *daddr)
{}

static void __ipoib_reap_neigh(struct ipoib_dev_priv *priv)
{}

static void ipoib_reap_neigh(struct work_struct *work)
{}


static struct ipoib_neigh *ipoib_neigh_ctor(u8 *daddr,
				      struct net_device *dev)
{}

struct ipoib_neigh *ipoib_neigh_alloc(u8 *daddr,
				      struct net_device *dev)
{}

void ipoib_neigh_dtor(struct ipoib_neigh *neigh)
{}

static void ipoib_neigh_reclaim(struct rcu_head *rp)
{}

void ipoib_neigh_free(struct ipoib_neigh *neigh)
{}

static int ipoib_neigh_hash_init(struct ipoib_dev_priv *priv)
{}

static void neigh_hash_free_rcu(struct rcu_head *head)
{}

void ipoib_del_neighs_by_gid(struct net_device *dev, u8 *gid)
{}

static void ipoib_flush_neighs(struct ipoib_dev_priv *priv)
{}

static void ipoib_neigh_hash_uninit(struct net_device *dev)
{}

static void ipoib_napi_add(struct net_device *dev)
{}

static void ipoib_napi_del(struct net_device *dev)
{}

static void ipoib_dev_uninit_default(struct net_device *dev)
{}

static int ipoib_dev_init_default(struct net_device *dev)
{}

static int ipoib_ioctl(struct net_device *dev, struct ifreq *ifr,
		       int cmd)
{}

static int ipoib_dev_init(struct net_device *dev)
{}

/*
 * This must be called before doing an unregister_netdev on a parent device to
 * shutdown the IB event handler.
 */
static void ipoib_parent_unregister_pre(struct net_device *ndev)
{}

static void ipoib_set_dev_features(struct ipoib_dev_priv *priv)
{}

static int ipoib_parent_init(struct net_device *ndev)
{}

static void ipoib_child_init(struct net_device *ndev)
{}

static int ipoib_ndo_init(struct net_device *ndev)
{}

static void ipoib_ndo_uninit(struct net_device *dev)
{}

static int ipoib_set_vf_link_state(struct net_device *dev, int vf, int link_state)
{}

static int ipoib_get_vf_config(struct net_device *dev, int vf,
			       struct ifla_vf_info *ivf)
{}

static int ipoib_set_vf_guid(struct net_device *dev, int vf, u64 guid, int type)
{}

static int ipoib_get_vf_guid(struct net_device *dev, int vf,
			     struct ifla_vf_guid *node_guid,
			     struct ifla_vf_guid *port_guid)
{}

static int ipoib_get_vf_stats(struct net_device *dev, int vf,
			      struct ifla_vf_stats *vf_stats)
{}

static const struct header_ops ipoib_header_ops =;

static const struct net_device_ops ipoib_netdev_ops_pf =;

static const struct net_device_ops ipoib_netdev_ops_vf =;

static const struct net_device_ops ipoib_netdev_default_pf =;

void ipoib_setup_common(struct net_device *dev)
{}

static void ipoib_build_priv(struct net_device *dev)
{}

static struct net_device *ipoib_alloc_netdev(struct ib_device *hca, u32 port,
					     const char *name)
{}

int ipoib_intf_init(struct ib_device *hca, u32 port, const char *name,
		    struct net_device *dev)
{}

struct net_device *ipoib_intf_alloc(struct ib_device *hca, u32 port,
				    const char *name)
{}

void ipoib_intf_free(struct net_device *dev)
{}

static ssize_t pkey_show(struct device *dev, struct device_attribute *attr,
			 char *buf)
{}
static DEVICE_ATTR_RO(pkey);

static ssize_t umcast_show(struct device *dev, struct device_attribute *attr,
			   char *buf)
{}

void ipoib_set_umcast(struct net_device *ndev, int umcast_val)
{}

static ssize_t umcast_store(struct device *dev, struct device_attribute *attr,
			    const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(umcast);

int ipoib_add_umcast_attr(struct net_device *dev)
{}

static void set_base_guid(struct ipoib_dev_priv *priv, union ib_gid *gid)
{}

static int ipoib_check_lladdr(struct net_device *dev,
			      struct sockaddr_storage *ss)
{}

static int ipoib_set_mac(struct net_device *dev, void *addr)
{}

static ssize_t create_child_store(struct device *dev,
				  struct device_attribute *attr,
				  const char *buf, size_t count)
{}
static DEVICE_ATTR_WO(create_child);

static ssize_t delete_child_store(struct device *dev,
				  struct device_attribute *attr,
				  const char *buf, size_t count)
{}
static DEVICE_ATTR_WO(delete_child);

int ipoib_add_pkey_attr(struct net_device *dev)
{}

/*
 * We erroneously exposed the iface's port number in the dev_id
 * sysfs field long after dev_port was introduced for that purpose[1],
 * and we need to stop everyone from relying on that.
 * Let's overload the shower routine for the dev_id file here
 * to gently bring the issue up.
 *
 * [1] https://www.spinics.net/lists/netdev/msg272123.html
 */
static ssize_t dev_id_show(struct device *dev,
			   struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(dev_id);

static int ipoib_intercept_dev_id_attr(struct net_device *dev)
{}

static struct net_device *ipoib_add_port(const char *format,
					 struct ib_device *hca, u32 port)
{}

static int ipoib_add_one(struct ib_device *device)
{}

static void ipoib_remove_one(struct ib_device *device, void *client_data)
{}

#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
static struct notifier_block ipoib_netdev_notifier =;
#endif

static int __init ipoib_init_module(void)
{}

static void __exit ipoib_cleanup_module(void)
{}

module_init();
module_exit(ipoib_cleanup_module);