svn commit: r213447 - projects/ofed/head/sys/ofed/drivers/infiniband/ulp/ipoib

Jeff Roberson jeff at FreeBSD.org
Tue Oct 5 07:21:15 UTC 2010


Author: jeff
Date: Tue Oct  5 07:21:14 2010
New Revision: 213447
URL: http://svn.freebsd.org/changeset/base/213447

Log:
   - Checkpoint initial ipoib porting.  ARP and IP work.  Multicast, RC, and
     vlan support currently disabled.
  
  Sponsored by:	Isilon Systems, iX Systems, and Panasas

Modified:
  projects/ofed/head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h
  projects/ofed/head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c
  projects/ofed/head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
  projects/ofed/head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_fs.c
  projects/ofed/head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ib.c
  projects/ofed/head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
  projects/ofed/head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
  projects/ofed/head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
  projects/ofed/head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_vlan.c

Modified: projects/ofed/head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h
==============================================================================
--- projects/ofed/head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h	Tue Oct  5 07:19:37 2010	(r213446)
+++ projects/ofed/head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h	Tue Oct  5 07:21:14 2010	(r213447)
@@ -35,25 +35,65 @@
 #ifndef _IPOIB_H
 #define _IPOIB_H
 
+#include "opt_inet.h"
+#include "opt_inet6.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/lock.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/random.h>
+#include <sys/rwlock.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+#include <sys/sysctl.h>
+
+#include <net/if.h>
+#include <net/if_arp.h>
+#include <net/netisr.h>
+#include <net/route.h>
+#include <net/if_llc.h>
+#include <net/if_dl.h>
+#include <net/if_types.h>
+#include <net/bpf.h>
+#include <net/if_llatbl.h>
+#include <net/vnet.h>
+
+#if defined(INET) || defined(INET6)
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/if_ether.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_fw.h>
+#include <netinet/ipfw/ip_fw_private.h>
+#endif
+#ifdef INET6
+#include <netinet6/nd6.h>
+#endif
+
+#include <security/mac/mac_framework.h>
+
 #include <linux/list.h>
-#include <linux/skbuff.h>
-#include <linux/netdevice.h>
+
 #include <linux/workqueue.h>
 #include <linux/kref.h>
-#include <linux/if_infiniband.h>
 #include <linux/mutex.h>
 
-#include <net/neighbour.h>
-
 #include <asm/atomic.h>
 
 #include <rdma/ib_verbs.h>
 #include <rdma/ib_pack.h>
 #include <rdma/ib_sa.h>
-#include <linux/inet_lro.h>
 
 /* constants */
 
+#define	INFINIBAND_ALEN		20	/* Octets in IPoIB HW addr */
+#define	MAX_MB_FRAGS		(8192 / MCLBYTES)
+
+#define	CONFIG_INFINIBAND_IPOIB_DEBUG
+
 enum ipoib_flush_level {
 	IPOIB_FLUSH_LIGHT,
 	IPOIB_FLUSH_NORMAL,
@@ -62,7 +102,7 @@ enum ipoib_flush_level {
 
 enum {
 	IPOIB_ENCAP_LEN		  = 4,
-
+	IPOIB_HEADER_LEN	  = IPOIB_ENCAP_LEN + INFINIBAND_ALEN,
 	IPOIB_UD_HEAD_SIZE	  = IB_GRH_BYTES + IPOIB_ENCAP_LEN,
 	IPOIB_UD_RX_SG		  = 2, /* max buffer needed for 4K mtu */
 
@@ -117,6 +157,7 @@ enum {
 /* structs */
 
 struct ipoib_header {
+	u8  hwaddr[INFINIBAND_ALEN];
 	__be16	proto;
 	u16	reserved;
 };
@@ -140,25 +181,23 @@ struct ipoib_mcast {
 	unsigned long flags;
 	unsigned char logcount;
 
-	struct list_head  neigh_list;
-
-	struct sk_buff_head pkt_queue;
+	struct ifqueue pkt_queue;
 
-	struct net_device *dev;
+	struct ifnet *dev;
 };
 
 struct ipoib_rx_buf {
-	struct sk_buff *skb;
+	struct mbuf *mb;
 	u64		mapping[IPOIB_UD_RX_SG];
 };
 
 struct ipoib_tx_buf {
-	struct sk_buff *skb;
-	u64		mapping[MAX_SKB_FRAGS + 1];
+	struct mbuf *mb;
+	u64		mapping[MAX_MB_FRAGS];
 };
 
 struct ipoib_cm_tx_buf {
-	struct sk_buff *skb;
+	struct mbuf *mb;
 	u64		mapping;
 };
 
@@ -207,7 +246,7 @@ struct ipoib_cm_rx {
 	struct ib_qp	       *qp;
 	struct ipoib_cm_rx_buf *rx_ring;
 	struct list_head	list;
-	struct net_device      *dev;
+	struct ifnet      *dev;
 	unsigned long		jiffies;
 	enum ipoib_cm_state	state;
 	int			recv_count;
@@ -217,8 +256,7 @@ struct ipoib_cm_tx {
 	struct ib_cm_id	    *id;
 	struct ib_qp	    *qp;
 	struct list_head     list;
-	struct net_device   *dev;
-	struct ipoib_neigh  *neigh;
+	struct ifnet   *dev;
 	struct ipoib_path   *path;
 	struct ipoib_cm_tx_buf *tx_ring;
 	unsigned	     tx_head;
@@ -228,7 +266,7 @@ struct ipoib_cm_tx {
 };
 
 struct ipoib_cm_rx_buf {
-	struct sk_buff *skb;
+	struct mbuf *mb;
 	u64 mapping[IPOIB_CM_RX_SG];
 };
 
@@ -243,10 +281,10 @@ struct ipoib_cm_dev_priv {
 	struct list_head	rx_reap_list;  /* state: FLUSH, drain done */
 	struct work_struct      start_task;
 	struct work_struct      reap_task;
-	struct work_struct      skb_task;
+	struct work_struct      mb_task;
 	struct work_struct      rx_reap_task;
 	struct delayed_work     stale_task;
-	struct sk_buff_head     skb_queue;
+	struct ifqueue     	mb_queue;
 	struct list_head	start_list;
 	struct list_head	reap_list;
 	struct ib_wc		ibwc[IPOIB_NUM_WC];
@@ -262,11 +300,6 @@ struct ipoib_ethtool_st {
 	u16     max_coalesced_frames;
 };
 
-struct ipoib_lro {
-	struct net_lro_mgr lro_mgr;
-	struct net_lro_desc lro_desc[IPOIB_MAX_LRO_DESCRIPTORS];
-};
-
 /*
  * Device private locking: network stack tx_lock protects members used
  * in TX fast path, lock protects everything else.  lock nests inside
@@ -275,9 +308,9 @@ struct ipoib_lro {
 struct ipoib_dev_priv {
 	spinlock_t lock;
 
-	struct net_device *dev;
+	struct ifnet *dev;
 
-	struct napi_struct napi;
+	u8 broadcastaddr[INFINIBAND_ALEN];
 
 	unsigned long flags;
 
@@ -322,7 +355,7 @@ struct ipoib_dev_priv {
 	struct ipoib_tx_buf *tx_ring;
 	unsigned	     tx_head;
 	unsigned	     tx_tail;
-	struct ib_sge	     tx_sge[MAX_SKB_FRAGS + 1];
+	struct ib_sge	     tx_sge[MAX_MB_FRAGS];
 	struct ib_send_wr    tx_wr;
 	unsigned	     tx_outstanding;
 	struct ib_wc	     send_wc[MAX_SEND_CQE];
@@ -336,7 +369,7 @@ struct ipoib_dev_priv {
 
 	struct ib_event_handler event_handler;
 
-	struct net_device *parent;
+	struct ifnet *parent;
 	struct list_head child_intfs;
 	struct list_head list;
 
@@ -352,12 +385,10 @@ struct ipoib_dev_priv {
 	int	hca_caps;
 	struct ipoib_ethtool_st ethtool;
 	struct timer_list poll_timer;
-
-	struct ipoib_lro lro;
 };
 
 struct ipoib_ah {
-	struct net_device *dev;
+	struct ifnet *dev;
 	struct ib_ah	  *ah;
 	struct list_head   list;
 	struct kref	   ref;
@@ -365,69 +396,36 @@ struct ipoib_ah {
 };
 
 struct ipoib_path {
-	struct net_device    *dev;
-	struct ib_sa_path_rec pathrec;
+	struct ifnet         *dev;
+	struct rb_node	      rb_node;
+	struct list_head      list;
+#ifdef CONFIG_INFINIBAND_IPOIB_CM
+	struct ipoib_cm_tx   *cm;
+#endif
 	struct ipoib_ah      *ah;
-	struct sk_buff_head   queue;
-
-	struct list_head      neigh_list;
+	struct ib_sa_path_rec pathrec;
+	struct ifqueue	      queue;
 
 	int		      query_id;
 	struct ib_sa_query   *query;
 	struct completion     done;
 
-	struct rb_node	      rb_node;
-	struct list_head      list;
 	int  		      valid;
 };
 
-struct ipoib_neigh {
-	struct ipoib_ah    *ah;
-#ifdef CONFIG_INFINIBAND_IPOIB_CM
-	struct ipoib_cm_tx *cm;
-#endif
-	union ib_gid	    dgid;
-	struct sk_buff_head queue;
-
-	struct neighbour   *neighbour;
-	struct net_device *dev;
-
-	struct list_head    list;
-};
-
 #define IPOIB_UD_MTU(ib_mtu)		(ib_mtu - IPOIB_ENCAP_LEN)
 #define IPOIB_UD_BUF_SIZE(ib_mtu)	(ib_mtu + IB_GRH_BYTES)
 
-static inline int ipoib_ud_need_sg(unsigned int ib_mtu)
-{
-	return IPOIB_UD_BUF_SIZE(ib_mtu) > PAGE_SIZE;
-}
-
-/*
- * We stash a pointer to our private neighbour information after our
- * hardware address in neigh->ha.  The ALIGN() expression here makes
- * sure that this pointer is stored aligned so that an unaligned
- * load is not needed to dereference it.
- */
-static inline struct ipoib_neigh **to_ipoib_neigh(struct neighbour *neigh)
-{
-	return (void*) neigh + ALIGN(offsetof(struct neighbour, ha) +
-				     INFINIBAND_ALEN, sizeof(void *));
-}
-
-struct ipoib_neigh *ipoib_neigh_alloc(struct neighbour *neigh,
-				      struct net_device *dev);
-void ipoib_neigh_free(struct net_device *dev, struct ipoib_neigh *neigh);
+#define	IPOIB_IS_MULTICAST(addr)	((addr)[4] == 0xff)
 
 extern struct workqueue_struct *ipoib_workqueue;
 
 /* functions */
 
-int ipoib_poll(struct napi_struct *napi, int budget);
 void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr);
 void ipoib_send_comp_handler(struct ib_cq *cq, void *dev_ptr);
 
-struct ipoib_ah *ipoib_create_ah(struct net_device *dev,
+struct ipoib_ah *ipoib_create_ah(struct ifnet *dev,
 				 struct ib_pd *pd, struct ib_ah_attr *attr);
 void ipoib_free_ah(struct kref *kref);
 static inline void ipoib_put_ah(struct ipoib_ah *ah)
@@ -435,46 +433,46 @@ static inline void ipoib_put_ah(struct i
 	kref_put(&ah->ref, ipoib_free_ah);
 }
 
-int ipoib_open(struct net_device *dev);
-int ipoib_add_pkey_attr(struct net_device *dev);
-int ipoib_add_umcast_attr(struct net_device *dev);
+int ipoib_open(struct ifnet *dev);
+int ipoib_add_pkey_attr(struct ifnet *dev);
+int ipoib_add_umcast_attr(struct ifnet *dev);
 
-void ipoib_send(struct net_device *dev, struct sk_buff *skb,
+void ipoib_send(struct ifnet *dev, struct mbuf *mb,
 		struct ipoib_ah *address, u32 qpn);
 void ipoib_reap_ah(struct work_struct *work);
 
-void ipoib_mark_paths_invalid(struct net_device *dev);
-void ipoib_flush_paths(struct net_device *dev);
+void ipoib_mark_paths_invalid(struct ifnet *dev);
+void ipoib_flush_paths(struct ifnet *dev);
 struct ipoib_dev_priv *ipoib_intf_alloc(const char *format);
 
-int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port);
+int ipoib_ib_dev_init(struct ifnet *dev, struct ib_device *ca, int port);
 void ipoib_ib_dev_flush_light(struct work_struct *work);
 void ipoib_ib_dev_flush_normal(struct work_struct *work);
 void ipoib_ib_dev_flush_heavy(struct work_struct *work);
 void ipoib_pkey_event(struct work_struct *work);
-void ipoib_ib_dev_cleanup(struct net_device *dev);
+void ipoib_ib_dev_cleanup(struct ifnet *dev);
 
-int ipoib_ib_dev_open(struct net_device *dev);
-int ipoib_ib_dev_up(struct net_device *dev);
-int ipoib_ib_dev_down(struct net_device *dev, int flush);
-int ipoib_ib_dev_stop(struct net_device *dev, int flush);
+int ipoib_ib_dev_open(struct ifnet *dev);
+int ipoib_ib_dev_up(struct ifnet *dev);
+int ipoib_ib_dev_down(struct ifnet *dev, int flush);
+int ipoib_ib_dev_stop(struct ifnet *dev, int flush);
 
-int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port);
-void ipoib_dev_cleanup(struct net_device *dev);
+int ipoib_dev_init(struct ifnet *dev, struct ib_device *ca, int port);
+void ipoib_dev_cleanup(struct ifnet *dev);
 
 void ipoib_mcast_join_task(struct work_struct *work);
 void ipoib_mcast_carrier_on_task(struct work_struct *work);
-void ipoib_mcast_send(struct net_device *dev, void *mgid, struct sk_buff *skb);
+void ipoib_mcast_send(struct ifnet *dev, void *mgid, struct mbuf *mb);
 
 void ipoib_mcast_restart_task(struct work_struct *work);
-int ipoib_mcast_start_thread(struct net_device *dev);
-int ipoib_mcast_stop_thread(struct net_device *dev, int flush);
+int ipoib_mcast_start_thread(struct ifnet *dev);
+int ipoib_mcast_stop_thread(struct ifnet *dev, int flush);
 
-void ipoib_mcast_dev_down(struct net_device *dev);
-void ipoib_mcast_dev_flush(struct net_device *dev);
+void ipoib_mcast_dev_down(struct ifnet *dev);
+void ipoib_mcast_dev_flush(struct ifnet *dev);
 
 #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
-struct ipoib_mcast_iter *ipoib_mcast_iter_init(struct net_device *dev);
+struct ipoib_mcast_iter *ipoib_mcast_iter_init(struct ifnet *dev);
 int ipoib_mcast_iter_next(struct ipoib_mcast_iter *iter);
 void ipoib_mcast_iter_read(struct ipoib_mcast_iter *iter,
 				  union ib_gid *gid,
@@ -483,30 +481,30 @@ void ipoib_mcast_iter_read(struct ipoib_
 				  unsigned int *complete,
 				  unsigned int *send_only);
 
-struct ipoib_path_iter *ipoib_path_iter_init(struct net_device *dev);
+struct ipoib_path_iter *ipoib_path_iter_init(struct ifnet *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
 
-int ipoib_mcast_attach(struct net_device *dev, u16 mlid,
+int ipoib_mcast_attach(struct ifnet *dev, u16 mlid,
 		       union ib_gid *mgid, int set_qkey);
 
-int ipoib_init_qp(struct net_device *dev);
-int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca);
-void ipoib_transport_dev_cleanup(struct net_device *dev);
+int ipoib_init_qp(struct ifnet *dev);
+int ipoib_transport_dev_init(struct ifnet *dev, struct ib_device *ca);
+void ipoib_transport_dev_cleanup(struct ifnet *dev);
 
 void ipoib_event(struct ib_event_handler *handler,
 		 struct ib_event *record);
 
-int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey);
-int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey);
+int ipoib_vlan_add(struct ifnet *pdev, unsigned short pkey);
+int ipoib_vlan_delete(struct ifnet *pdev, unsigned short pkey);
 
 void ipoib_pkey_poll(struct work_struct *work);
-int ipoib_pkey_dev_delay_open(struct net_device *dev);
-void ipoib_drain_cq(struct net_device *dev);
+int ipoib_pkey_dev_delay_open(struct ifnet *dev);
+void ipoib_drain_cq(struct ifnet *dev);
 
-void ipoib_set_ethtool_ops(struct net_device *dev);
+void ipoib_set_ethtool_ops(struct ifnet *dev);
 int ipoib_set_dev_features(struct ipoib_dev_priv *priv, struct ib_device *hca);
 
 #ifdef CONFIG_INFINIBAND_IPOIB_CM
@@ -519,135 +517,133 @@ int ipoib_set_dev_features(struct ipoib_
 
 extern int ipoib_max_conn_qp;
 
-static inline int ipoib_cm_admin_enabled(struct net_device *dev)
+static inline int ipoib_cm_admin_enabled(struct ifnet *dev)
 {
-	struct ipoib_dev_priv *priv = netdev_priv(dev);
-	return IPOIB_CM_SUPPORTED(dev->dev_addr) &&
+	struct ipoib_dev_priv *priv = dev->if_softc;
+	return IPOIB_CM_SUPPORTED(IF_LLADDR(dev)) &&
 		test_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags);
 }
 
-static inline int ipoib_cm_enabled(struct net_device *dev, struct neighbour *n)
+static inline int ipoib_cm_enabled(struct ifnet *dev, struct llentry *n)
 {
-	struct ipoib_dev_priv *priv = netdev_priv(dev);
-	return IPOIB_CM_SUPPORTED(n->ha) &&
+	struct ipoib_dev_priv *priv = dev->if_softc;
+	return IPOIB_CM_SUPPORTED(rt_key(n)->sa_data) &&
 		test_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags);
 }
 
-static inline int ipoib_cm_up(struct ipoib_neigh *neigh)
+static inline int ipoib_cm_up(struct ipoib_path *path)
 
 {
-	return test_bit(IPOIB_FLAG_OPER_UP, &neigh->cm->flags);
+	return test_bit(IPOIB_FLAG_OPER_UP, &path->cm->flags);
 }
 
-static inline struct ipoib_cm_tx *ipoib_cm_get(struct ipoib_neigh *neigh)
+static inline struct ipoib_cm_tx *ipoib_cm_get(struct ipoib_path *path)
 {
-	return neigh->cm;
+	return path->cm;
 }
 
-static inline void ipoib_cm_set(struct ipoib_neigh *neigh, struct ipoib_cm_tx *tx)
+static inline void ipoib_cm_set(struct ipoib_path *path, struct ipoib_cm_tx *tx)
 {
-	neigh->cm = tx;
+	path->cm = tx;
 }
 
-static inline int ipoib_cm_has_srq(struct net_device *dev)
+static inline int ipoib_cm_has_srq(struct ifnet *dev)
 {
-	struct ipoib_dev_priv *priv = netdev_priv(dev);
+	struct ipoib_dev_priv *priv = dev->if_softc;
 	return !!priv->cm.srq;
 }
 
-static inline unsigned int ipoib_cm_max_mtu(struct net_device *dev)
+static inline unsigned int ipoib_cm_max_mtu(struct ifnet *dev)
 {
-	struct ipoib_dev_priv *priv = netdev_priv(dev);
+	struct ipoib_dev_priv *priv = dev->if_softc;
 	return priv->cm.max_cm_mtu;
 }
 
-void ipoib_cm_send(struct net_device *dev, struct sk_buff *skb, struct ipoib_cm_tx *tx);
-int ipoib_cm_dev_open(struct net_device *dev);
-void ipoib_cm_dev_stop(struct net_device *dev);
-int ipoib_cm_dev_init(struct net_device *dev);
-int ipoib_cm_add_mode_attr(struct net_device *dev);
-void ipoib_cm_dev_cleanup(struct net_device *dev);
-struct ipoib_cm_tx *ipoib_cm_create_tx(struct net_device *dev, struct ipoib_path *path,
-				    struct ipoib_neigh *neigh);
+void ipoib_cm_send(struct ifnet *dev, struct mbuf *mb, struct ipoib_cm_tx *tx);
+int ipoib_cm_dev_open(struct ifnet *dev);
+void ipoib_cm_dev_stop(struct ifnet *dev);
+int ipoib_cm_dev_init(struct ifnet *dev);
+int ipoib_cm_add_mode_attr(struct ifnet *dev);
+void ipoib_cm_dev_cleanup(struct ifnet *dev);
+struct ipoib_cm_tx *ipoib_cm_create_tx(struct ifnet *dev, struct ipoib_path *path);
 void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx);
-void ipoib_cm_skb_too_long(struct net_device *dev, struct sk_buff *skb,
+void ipoib_cm_mb_too_long(struct ifnet *dev, struct mbuf *mb,
 			   unsigned int mtu);
-void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc);
-void ipoib_cm_handle_tx_wc(struct net_device *dev, struct ib_wc *wc);
+void ipoib_cm_handle_rx_wc(struct ifnet *dev, struct ib_wc *wc);
+void ipoib_cm_handle_tx_wc(struct ifnet *dev, struct ib_wc *wc);
 #else
 
 struct ipoib_cm_tx;
 
 #define ipoib_max_conn_qp 0
 
-static inline int ipoib_cm_admin_enabled(struct net_device *dev)
+static inline int ipoib_cm_admin_enabled(struct ifnet *dev)
 {
 	return 0;
 }
-static inline int ipoib_cm_enabled(struct net_device *dev, struct neighbour *n)
+static inline int ipoib_cm_enabled(struct ifnet *dev, struct llentry *n)
 
 {
 	return 0;
 }
 
-static inline int ipoib_cm_up(struct ipoib_neigh *neigh)
+static inline int ipoib_cm_up(struct ipoib_path *path)
 
 {
 	return 0;
 }
 
-static inline struct ipoib_cm_tx *ipoib_cm_get(struct ipoib_neigh *neigh)
+static inline struct ipoib_cm_tx *ipoib_cm_get(struct ipoib_path *path)
 {
 	return NULL;
 }
 
-static inline void ipoib_cm_set(struct ipoib_neigh *neigh, struct ipoib_cm_tx *tx)
+static inline void ipoib_cm_set(struct ipoib_path *path, struct ipoib_cm_tx *tx)
 {
 }
 
-static inline int ipoib_cm_has_srq(struct net_device *dev)
+static inline int ipoib_cm_has_srq(struct ifnet *dev)
 {
 	return 0;
 }
 
-static inline unsigned int ipoib_cm_max_mtu(struct net_device *dev)
+static inline unsigned int ipoib_cm_max_mtu(struct ifnet *dev)
 {
 	return 0;
 }
 
 static inline
-void ipoib_cm_send(struct net_device *dev, struct sk_buff *skb, struct ipoib_cm_tx *tx)
+void ipoib_cm_send(struct ifnet *dev, struct mbuf *mb, struct ipoib_cm_tx *tx)
 {
 	return;
 }
 
 static inline
-int ipoib_cm_dev_open(struct net_device *dev)
+int ipoib_cm_dev_open(struct ifnet *dev)
 {
 	return 0;
 }
 
 static inline
-void ipoib_cm_dev_stop(struct net_device *dev)
+void ipoib_cm_dev_stop(struct ifnet *dev)
 {
 	return;
 }
 
 static inline
-int ipoib_cm_dev_init(struct net_device *dev)
+int ipoib_cm_dev_init(struct ifnet *dev)
 {
 	return -ENOSYS;
 }
 
 static inline
-void ipoib_cm_dev_cleanup(struct net_device *dev)
+void ipoib_cm_dev_cleanup(struct ifnet *dev)
 {
 	return;
 }
 
 static inline
-struct ipoib_cm_tx *ipoib_cm_create_tx(struct net_device *dev, struct ipoib_path *path,
-				    struct ipoib_neigh *neigh)
+struct ipoib_cm_tx *ipoib_cm_create_tx(struct ifnet *dev, struct ipoib_path *path)
 {
 	return NULL;
 }
@@ -659,40 +655,40 @@ void ipoib_cm_destroy_tx(struct ipoib_cm
 }
 
 static inline
-int ipoib_cm_add_mode_attr(struct net_device *dev)
+int ipoib_cm_add_mode_attr(struct ifnet *dev)
 {
 	return 0;
 }
 
-static inline void ipoib_cm_skb_too_long(struct net_device *dev, struct sk_buff *skb,
+static inline void ipoib_cm_mb_too_long(struct ifnet *dev, struct mbuf *mb,
 					 unsigned int mtu)
 {
-	dev_kfree_skb_any(skb);
+	m_free(mb);
 }
 
-static inline void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
+static inline void ipoib_cm_handle_rx_wc(struct ifnet *dev, struct ib_wc *wc)
 {
 }
 
-static inline void ipoib_cm_handle_tx_wc(struct net_device *dev, struct ib_wc *wc)
+static inline void ipoib_cm_handle_tx_wc(struct ifnet *dev, struct ib_wc *wc)
 {
 }
 #endif
 
 #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
-void ipoib_create_debug_files(struct net_device *dev);
-void ipoib_delete_debug_files(struct net_device *dev);
+void ipoib_create_debug_files(struct ifnet *dev);
+void ipoib_delete_debug_files(struct ifnet *dev);
 int ipoib_register_debugfs(void);
 void ipoib_unregister_debugfs(void);
 #else
-static inline void ipoib_create_debug_files(struct net_device *dev) { }
-static inline void ipoib_delete_debug_files(struct net_device *dev) { }
+static inline void ipoib_create_debug_files(struct ifnet *dev) { }
+static inline void ipoib_delete_debug_files(struct ifnet *dev) { }
 static inline int ipoib_register_debugfs(void) { return 0; }
 static inline void ipoib_unregister_debugfs(void) { }
 #endif
 
 #define ipoib_printk(level, priv, format, arg...)	\
-	printk(level "%s: " format, ((struct ipoib_dev_priv *) priv)->dev->name , ## arg)
+	printk(level "%s: " format, if_name(((struct ipoib_dev_priv *) priv)->dev), ## arg)
 #define ipoib_warn(priv, format, arg...)		\
 	ipoib_printk(KERN_WARNING, priv, format , ## arg)
 
@@ -734,4 +730,30 @@ extern int ipoib_debug_level;
 
 #define IPOIB_QPN(ha) (be32_to_cpup((__be32 *) ha) & 0xffffff)
 
+static inline long
+test_and_clear_bit(long bit, long *var)
+{
+	long val;
+
+	bit = 1 << bit;
+	do {
+		val = *(volatile long *)var;
+	} while (atomic_cmpset_long(var, val, val & ~bit) == 0);
+
+	return !!(val & bit);
+}
+
+static inline long
+test_and_set_bit(long bit, long *var)
+{
+	long val;
+
+	bit = 1 << bit;
+	do {
+		val = *(volatile long *)var;
+	} while (atomic_cmpset_long(var, val, val | bit) == 0);
+
+	return !!(val & bit);
+}
+
 #endif /* _IPOIB_H */

Modified: projects/ofed/head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c
==============================================================================
--- projects/ofed/head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c	Tue Oct  5 07:19:37 2010	(r213446)
+++ projects/ofed/head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c	Tue Oct  5 07:21:14 2010	(r213447)
@@ -30,16 +30,13 @@
  * SOFTWARE.
  */
 
+#include "ipoib.h"
+
 #include <rdma/ib_cm.h>
 #include <rdma/ib_cache.h>
-#include <net/dst.h>
-#include <net/icmp.h>
-#include <linux/icmpv6.h>
 #include <linux/delay.h>
 #include <linux/vmalloc.h>
 
-#include "ipoib.h"
-
 int ipoib_max_conn_qp = 128;
 
 module_param_named(max_nonsrq_conn_qp, ipoib_max_conn_qp, int, 0444);
@@ -87,9 +84,9 @@ static void ipoib_cm_dma_unmap_rx(struct
 		ib_dma_unmap_single(priv->ca, mapping[i + 1], PAGE_SIZE, DMA_FROM_DEVICE);
 }
 
-static int ipoib_cm_post_receive_srq(struct net_device *dev, int id)
+static int ipoib_cm_post_receive_srq(struct ifnet *dev, int id)
 {
-	struct ipoib_dev_priv *priv = netdev_priv(dev);
+	struct ipoib_dev_priv *priv = dev->if_softc;
 	struct ib_recv_wr *bad_wr;
 	int i, ret;
 
@@ -103,19 +100,19 @@ static int ipoib_cm_post_receive_srq(str
 		ipoib_warn(priv, "post srq failed for buf %d (%d)\n", id, ret);
 		ipoib_cm_dma_unmap_rx(priv, priv->cm.num_frags - 1,
 				      priv->cm.srq_ring[id].mapping);
-		dev_kfree_skb_any(priv->cm.srq_ring[id].skb);
-		priv->cm.srq_ring[id].skb = NULL;
+		m_free(priv->cm.srq_ring[id].mb);
+		priv->cm.srq_ring[id].mb = NULL;
 	}
 
 	return ret;
 }
 
-static int ipoib_cm_post_receive_nonsrq(struct net_device *dev,
+static int ipoib_cm_post_receive_nonsrq(struct ifnet *dev,
 					struct ipoib_cm_rx *rx,
 					struct ib_recv_wr *wr,
 					struct ib_sge *sge, int id)
 {
-	struct ipoib_dev_priv *priv = netdev_priv(dev);
+	struct ipoib_dev_priv *priv = dev->if_softc;
 	struct ib_recv_wr *bad_wr;
 	int i, ret;
 
@@ -129,36 +126,36 @@ static int ipoib_cm_post_receive_nonsrq(
 		ipoib_warn(priv, "post recv failed for buf %d (%d)\n", id, ret);
 		ipoib_cm_dma_unmap_rx(priv, IPOIB_CM_RX_SG - 1,
 				      rx->rx_ring[id].mapping);
-		dev_kfree_skb_any(rx->rx_ring[id].skb);
-		rx->rx_ring[id].skb = NULL;
+		m_free(rx->rx_ring[id].mb);
+		rx->rx_ring[id].mb = NULL;
 	}
 
 	return ret;
 }
 
-static struct sk_buff *ipoib_cm_alloc_rx_skb(struct net_device *dev,
+static struct mbuf *ipoib_cm_alloc_rx_mb(struct ifnet *dev,
 					     struct ipoib_cm_rx_buf *rx_ring,
 					     int id, int frags,
 					     u64 mapping[IPOIB_CM_RX_SG])
 {
-	struct ipoib_dev_priv *priv = netdev_priv(dev);
-	struct sk_buff *skb;
+	struct ipoib_dev_priv *priv = dev->if_softc;
+	struct mbuf *mb;
 	int i;
 
-	skb = dev_alloc_skb(IPOIB_CM_HEAD_SIZE + 12);
-	if (unlikely(!skb))
+	mb = dev_alloc_mb(IPOIB_CM_HEAD_SIZE + 12);
+	if (unlikely(!mb))
 		return NULL;
 
 	/*
 	 * IPoIB adds a 4 byte header. So we need 12 more bytes to align the
 	 * IP header to a multiple of 16.
 	 */
-	skb_reserve(skb, 12);
+	mb_reserve(mb, 12);
 
-	mapping[0] = ib_dma_map_single(priv->ca, skb->data, IPOIB_CM_HEAD_SIZE,
-				       DMA_FROM_DEVICE);
+	mapping[0] = ib_dma_map_single(priv->ca, mtod(mb, void *),
+				       IPOIB_CM_HEAD_SIZE, DMA_FROM_DEVICE);
 	if (unlikely(ib_dma_mapping_error(priv->ca, mapping[0]))) {
-		dev_kfree_skb_any(skb);
+		m_free(mb);
 		return NULL;
 	}
 
@@ -167,16 +164,16 @@ static struct sk_buff *ipoib_cm_alloc_rx
 
 		if (!page)
 			goto partial_error;
-		skb_fill_page_desc(skb, i, page, 0, PAGE_SIZE);
+		mb_fill_page_desc(mb, i, page, 0, PAGE_SIZE);
 
-		mapping[i + 1] = ib_dma_map_page(priv->ca, skb_shinfo(skb)->frags[i].page,
+		mapping[i + 1] = ib_dma_map_page(priv->ca, mb_shinfo(mb)->frags[i].page,
 						 0, PAGE_SIZE, DMA_FROM_DEVICE);
 		if (unlikely(ib_dma_mapping_error(priv->ca, mapping[i + 1])))
 			goto partial_error;
 	}
 
-	rx_ring[id].skb = skb;
-	return skb;
+	rx_ring[id].mb = mb;
+	return mb;
 
 partial_error:
 
@@ -185,21 +182,21 @@ partial_error:
 	for (; i > 0; --i)
 		ib_dma_unmap_single(priv->ca, mapping[i], PAGE_SIZE, DMA_FROM_DEVICE);
 
-	dev_kfree_skb_any(skb);
+	m_free(mb);
 	return NULL;
 }
 
-static void ipoib_cm_free_rx_ring(struct net_device *dev,
+static void ipoib_cm_free_rx_ring(struct ifnet *dev,
 				  struct ipoib_cm_rx_buf *rx_ring)
 {
-	struct ipoib_dev_priv *priv = netdev_priv(dev);
+	struct ipoib_dev_priv *priv = dev->if_softc;
 	int i;
 
 	for (i = 0; i < ipoib_recvq_size; ++i)
-		if (rx_ring[i].skb) {
+		if (rx_ring[i].mb) {
 			ipoib_cm_dma_unmap_rx(priv, IPOIB_CM_RX_SG - 1,
 					      rx_ring[i].mapping);
-			dev_kfree_skb_any(rx_ring[i].skb);
+			m_free(rx_ring[i].mb);
 		}
 
 	vfree(rx_ring);
@@ -230,7 +227,7 @@ static void ipoib_cm_start_rx_drain(stru
 static void ipoib_cm_rx_event_handler(struct ib_event *event, void *ctx)
 {
 	struct ipoib_cm_rx *p = ctx;
-	struct ipoib_dev_priv *priv = netdev_priv(p->dev);
+	struct ipoib_dev_priv *priv = p->dev->if_softc;
 	unsigned long flags;
 
 	if (event->event != IB_EVENT_QP_LAST_WQE_REACHED)
@@ -243,10 +240,10 @@ static void ipoib_cm_rx_event_handler(st
 	spin_unlock_irqrestore(&priv->lock, flags);
 }
 
-static struct ib_qp *ipoib_cm_create_rx_qp(struct net_device *dev,
+static struct ib_qp *ipoib_cm_create_rx_qp(struct ifnet *dev,
 					   struct ipoib_cm_rx *p)
 {
-	struct ipoib_dev_priv *priv = netdev_priv(dev);
+	struct ipoib_dev_priv *priv = dev->if_softc;
 	struct ib_qp_init_attr attr = {
 		.event_handler = ipoib_cm_rx_event_handler,
 		.send_cq = priv->recv_cq, /* For drain WR */
@@ -267,11 +264,11 @@ static struct ib_qp *ipoib_cm_create_rx_
 	return ib_create_qp(priv->pd, &attr);
 }
 
-static int ipoib_cm_modify_rx_qp(struct net_device *dev,
+static int ipoib_cm_modify_rx_qp(struct ifnet *dev,
 				 struct ib_cm_id *cm_id, struct ib_qp *qp,
 				 unsigned psn)
 {
-	struct ipoib_dev_priv *priv = netdev_priv(dev);
+	struct ipoib_dev_priv *priv = dev->if_softc;
 	struct ib_qp_attr qp_attr;
 	int qp_attr_mask, ret;
 
@@ -322,11 +319,11 @@ static int ipoib_cm_modify_rx_qp(struct 
 	return 0;
 }
 
-static void ipoib_cm_init_rx_wr(struct net_device *dev,
+static void ipoib_cm_init_rx_wr(struct ifnet *dev,
 				struct ib_recv_wr *wr,
 				struct ib_sge *sge)
 {
-	struct ipoib_dev_priv *priv = netdev_priv(dev);
+	struct ipoib_dev_priv *priv = dev->if_softc;
 	int i;
 
 	for (i = 0; i < priv->cm.num_frags; ++i)
@@ -341,10 +338,10 @@ static void ipoib_cm_init_rx_wr(struct n
 	wr->num_sge = priv->cm.num_frags;
 }
 
-static int ipoib_cm_nonsrq_init_rx(struct net_device *dev, struct ib_cm_id *cm_id,
+static int ipoib_cm_nonsrq_init_rx(struct ifnet *dev, struct ib_cm_id *cm_id,
 				   struct ipoib_cm_rx *rx)
 {
-	struct ipoib_dev_priv *priv = netdev_priv(dev);
+	struct ipoib_dev_priv *priv = dev->if_softc;
 	struct {
 		struct ib_recv_wr wr;
 		struct ib_sge sge[IPOIB_CM_RX_SG];
@@ -382,7 +379,7 @@ static int ipoib_cm_nonsrq_init_rx(struc
 	spin_unlock_irq(&priv->lock);
 
 	for (i = 0; i < ipoib_recvq_size; ++i) {
-		if (!ipoib_cm_alloc_rx_skb(dev, rx->rx_ring, i, IPOIB_CM_RX_SG - 1,
+		if (!ipoib_cm_alloc_rx_mb(dev, rx->rx_ring, i, IPOIB_CM_RX_SG - 1,
 					   rx->rx_ring[i].mapping)) {
 			ipoib_warn(priv, "failed to allocate receive buffer %d\n", i);
 				ret = -ENOMEM;
@@ -415,11 +412,11 @@ err_free:
 	return ret;
 }
 
-static int ipoib_cm_send_rep(struct net_device *dev, struct ib_cm_id *cm_id,
+static int ipoib_cm_send_rep(struct ifnet *dev, struct ib_cm_id *cm_id,
 			     struct ib_qp *qp, struct ib_cm_req_event_param *req,
 			     unsigned psn)
 {
-	struct ipoib_dev_priv *priv = netdev_priv(dev);
+	struct ipoib_dev_priv *priv = dev->if_softc;
 	struct ipoib_cm_data data = {};
 	struct ib_cm_rep_param rep = {};
 
@@ -438,8 +435,8 @@ static int ipoib_cm_send_rep(struct net_
 
 static int ipoib_cm_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event)
 {
-	struct net_device *dev = cm_id->context;
-	struct ipoib_dev_priv *priv = netdev_priv(dev);
+	struct ifnet *dev = cm_id->context;
+	struct ipoib_dev_priv *priv = dev->if_softc;
 	struct ipoib_cm_rx *p;
 	unsigned psn;
 	int ret;
@@ -512,7 +509,7 @@ static int ipoib_cm_rx_handler(struct ib
 		/* Fall through */
 	case IB_CM_REJ_RECEIVED:
 		p = cm_id->context;
-		priv = netdev_priv(p->dev);
+		priv = p->dev->if_softc;
 		if (ib_modify_qp(p->qp, &ipoib_cm_err_attr, IB_QP_STATE))
 			ipoib_warn(priv, "unable to move qp to error state\n");
 		/* Fall through */
@@ -520,51 +517,51 @@ static int ipoib_cm_rx_handler(struct ib
 		return 0;
 	}
 }
-/* Adjust length of skb with fragments to match received data */
-static void skb_put_frags(struct sk_buff *skb, unsigned int hdr_space,
-			  unsigned int length, struct sk_buff *toskb)
+/* Adjust length of mb with fragments to match received data */
+static void mb_put_frags(struct mbuf *mb, unsigned int hdr_space,
+			  unsigned int length, struct mbuf *tomb)
 {
 	int i, num_frags;
 	unsigned int size;
 
-	/* put header into skb */
+	/* put header into mb */
 	size = min(length, hdr_space);
-	skb->tail += size;
-	skb->len += size;
+	mb->tail += size;
+	mb->len += size;
 	length -= size;
 
-	num_frags = skb_shinfo(skb)->nr_frags;
+	num_frags = mb_shinfo(mb)->nr_frags;
 	for (i = 0; i < num_frags; i++) {
-		skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
+		mb_frag_t *frag = &mb_shinfo(mb)->frags[i];
 
 		if (length == 0) {
 			/* don't need this page */
-			skb_fill_page_desc(toskb, i, frag->page, 0, PAGE_SIZE);
-			--skb_shinfo(skb)->nr_frags;
+			mb_fill_page_desc(tomb, i, frag->page, 0, PAGE_SIZE);
+			--mb_shinfo(mb)->nr_frags;
 		} else {
 			size = min(length, (unsigned) PAGE_SIZE);
 
 			frag->size = size;
-			skb->data_len += size;
-			skb->truesize += size;
-			skb->len += size;
+			mb->data_len += size;
+			mb->truesize += size;
+			mb->len += size;
 			length -= size;
 		}
 	}
 }
 
-void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
+void ipoib_cm_handle_rx_wc(struct ifnet *dev, struct ib_wc *wc)
 {
-	struct ipoib_dev_priv *priv = netdev_priv(dev);
+	struct ipoib_dev_priv *priv = dev->if_softc;
 	struct ipoib_cm_rx_buf *rx_ring;
 	unsigned int wr_id = wc->wr_id & ~(IPOIB_OP_CM | IPOIB_OP_RECV);
-	struct sk_buff *skb, *newskb;
+	struct mbuf *mb, *newmb;
 	struct ipoib_cm_rx *p;
 	unsigned long flags;
 	u64 mapping[IPOIB_CM_RX_SG];
 	int frags;
 	int has_srq;
-	struct sk_buff *small_skb;
+	struct mbuf *small_mb;
 
 	ipoib_dbg_data(priv, "cm recv completion: id %d, status: %d\n",
 		       wr_id, wc->status);
@@ -587,13 +584,13 @@ void ipoib_cm_handle_rx_wc(struct net_de
 	has_srq = ipoib_cm_has_srq(dev);
 	rx_ring = has_srq ? priv->cm.srq_ring : p->rx_ring;
 
-	skb = rx_ring[wr_id].skb;
+	mb = rx_ring[wr_id].mb;
 

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-projects mailing list