IPoIB: Add LSO support
[linux-2.6-block.git] / drivers / infiniband / ulp / ipoib / ipoib.h
index 1b3327ad6bc477332c622b069e55f9d8f7b7f542..19a41ff90d15d4d50c9045eb420ab292429dc4a9 100644 (file)
 /* constants */
 
 enum {
-       IPOIB_PACKET_SIZE         = 2048,
-       IPOIB_BUF_SIZE            = IPOIB_PACKET_SIZE + IB_GRH_BYTES,
+       IPOIB_PACKET_SIZE         = 2048,
+       IPOIB_BUF_SIZE            = IPOIB_PACKET_SIZE + IB_GRH_BYTES,
 
-       IPOIB_ENCAP_LEN           = 4,
+       IPOIB_ENCAP_LEN           = 4,
 
-       IPOIB_CM_MTU              = 0x10000 - 0x10, /* padding to align header to 16 */
-       IPOIB_CM_BUF_SIZE         = IPOIB_CM_MTU  + IPOIB_ENCAP_LEN,
-       IPOIB_CM_HEAD_SIZE        = IPOIB_CM_BUF_SIZE % PAGE_SIZE,
-       IPOIB_CM_RX_SG            = ALIGN(IPOIB_CM_BUF_SIZE, PAGE_SIZE) / PAGE_SIZE,
-       IPOIB_RX_RING_SIZE        = 128,
-       IPOIB_TX_RING_SIZE        = 64,
+       IPOIB_CM_MTU              = 0x10000 - 0x10, /* padding to align header to 16 */
+       IPOIB_CM_BUF_SIZE         = IPOIB_CM_MTU  + IPOIB_ENCAP_LEN,
+       IPOIB_CM_HEAD_SIZE        = IPOIB_CM_BUF_SIZE % PAGE_SIZE,
+       IPOIB_CM_RX_SG            = ALIGN(IPOIB_CM_BUF_SIZE, PAGE_SIZE) / PAGE_SIZE,
+       IPOIB_RX_RING_SIZE        = 128,
+       IPOIB_TX_RING_SIZE        = 64,
        IPOIB_MAX_QUEUE_SIZE      = 8192,
        IPOIB_MIN_QUEUE_SIZE      = 2,
+       IPOIB_CM_MAX_CONN_QP      = 4096,
 
-       IPOIB_NUM_WC              = 4,
+       IPOIB_NUM_WC              = 4,
 
        IPOIB_MAX_PATH_REC_QUEUE  = 3,
-       IPOIB_MAX_MCAST_QUEUE     = 3,
-
-       IPOIB_FLAG_OPER_UP        = 0,
-       IPOIB_FLAG_INITIALIZED    = 1,
-       IPOIB_FLAG_ADMIN_UP       = 2,
-       IPOIB_PKEY_ASSIGNED       = 3,
-       IPOIB_PKEY_STOP           = 4,
-       IPOIB_FLAG_SUBINTERFACE   = 5,
-       IPOIB_MCAST_RUN           = 6,
-       IPOIB_STOP_REAPER         = 7,
-       IPOIB_MCAST_STARTED       = 8,
-       IPOIB_FLAG_NETIF_STOPPED  = 9,
-       IPOIB_FLAG_ADMIN_CM       = 10,
-       IPOIB_FLAG_UMCAST         = 11,
+       IPOIB_MAX_MCAST_QUEUE     = 3,
+
+       IPOIB_FLAG_OPER_UP        = 0,
+       IPOIB_FLAG_INITIALIZED    = 1,
+       IPOIB_FLAG_ADMIN_UP       = 2,
+       IPOIB_PKEY_ASSIGNED       = 3,
+       IPOIB_PKEY_STOP           = 4,
+       IPOIB_FLAG_SUBINTERFACE   = 5,
+       IPOIB_MCAST_RUN           = 6,
+       IPOIB_STOP_REAPER         = 7,
+       IPOIB_MCAST_STARTED       = 8,
+       IPOIB_FLAG_ADMIN_CM       = 9,
+       IPOIB_FLAG_UMCAST         = 10,
+       IPOIB_FLAG_CSUM           = 11,
 
        IPOIB_MAX_BACKOFF_SECONDS = 16,
 
-       IPOIB_MCAST_FLAG_FOUND    = 0,  /* used in set_multicast_list */
+       IPOIB_MCAST_FLAG_FOUND    = 0,  /* used in set_multicast_list */
        IPOIB_MCAST_FLAG_SENDONLY = 1,
-       IPOIB_MCAST_FLAG_BUSY     = 2,  /* joining or already joined */
+       IPOIB_MCAST_FLAG_BUSY     = 2,  /* joining or already joined */
        IPOIB_MCAST_FLAG_ATTACHED = 3,
 };
 
 #define        IPOIB_OP_RECV   (1ul << 31)
 #ifdef CONFIG_INFINIBAND_IPOIB_CM
-#define        IPOIB_CM_OP_SRQ (1ul << 30)
+#define        IPOIB_OP_CM     (1ul << 30)
 #else
-#define        IPOIB_CM_OP_SRQ (0)
+#define        IPOIB_OP_CM     (0)
 #endif
 
 /* structs */
@@ -118,7 +119,7 @@ struct ipoib_pseudoheader {
 struct ipoib_mcast {
        struct ib_sa_mcmember_rec mcmember;
        struct ib_sa_multicast   *mc;
-       struct ipoib_ah          *ah;
+       struct ipoib_ah          *ah;
 
        struct rb_node    rb_node;
        struct list_head  list;
@@ -143,7 +144,7 @@ struct ipoib_rx_buf {
 
 struct ipoib_tx_buf {
        struct sk_buff *skb;
-       u64             mapping;
+       u64             mapping[MAX_SKB_FRAGS + 1];
 };
 
 struct ib_cm_id;
@@ -187,28 +188,28 @@ enum ipoib_cm_state {
 };
 
 struct ipoib_cm_rx {
-       struct ib_cm_id     *id;
-       struct ib_qp        *qp;
-       struct list_head     list;
-       struct net_device   *dev;
-       unsigned long        jiffies;
-       enum ipoib_cm_state  state;
+       struct ib_cm_id        *id;
+       struct ib_qp           *qp;
+       struct ipoib_cm_rx_buf *rx_ring;
+       struct list_head        list;
+       struct net_device      *dev;
+       unsigned long           jiffies;
+       enum ipoib_cm_state     state;
+       int                     recv_count;
 };
 
 struct ipoib_cm_tx {
-       struct ib_cm_id     *id;
-       struct ib_cq        *cq;
-       struct ib_qp        *qp;
+       struct ib_cm_id     *id;
+       struct ib_qp        *qp;
        struct list_head     list;
        struct net_device   *dev;
        struct ipoib_neigh  *neigh;
        struct ipoib_path   *path;
        struct ipoib_tx_buf *tx_ring;
-       unsigned             tx_head;
-       unsigned             tx_tail;
-       unsigned long        flags;
-       u32                  mtu;
-       struct ib_wc         ibwc[IPOIB_NUM_WC];
+       unsigned             tx_head;
+       unsigned             tx_tail;
+       unsigned long        flags;
+       u32                  mtu;
 };
 
 struct ipoib_cm_rx_buf {
@@ -217,25 +218,28 @@ struct ipoib_cm_rx_buf {
 };
 
 struct ipoib_cm_dev_priv {
-       struct ib_srq          *srq;
+       struct ib_srq          *srq;
        struct ipoib_cm_rx_buf *srq_ring;
-       struct ib_cm_id        *id;
-       struct list_head        passive_ids;   /* state: LIVE */
-       struct list_head        rx_error_list; /* state: ERROR */
-       struct list_head        rx_flush_list; /* state: FLUSH, drain not started */
-       struct list_head        rx_drain_list; /* state: FLUSH, drain started */
-       struct list_head        rx_reap_list;  /* state: FLUSH, drain done */
+       struct ib_cm_id        *id;
+       struct list_head        passive_ids;   /* state: LIVE */
+       struct list_head        rx_error_list; /* state: ERROR */
+       struct list_head        rx_flush_list; /* state: FLUSH, drain not started */
+       struct list_head        rx_drain_list; /* state: FLUSH, drain started */
+       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      rx_reap_task;
        struct delayed_work     stale_task;
        struct sk_buff_head     skb_queue;
-       struct list_head        start_list;
-       struct list_head        reap_list;
-       struct ib_wc            ibwc[IPOIB_NUM_WC];
-       struct ib_sge           rx_sge[IPOIB_CM_RX_SG];
+       struct list_head        start_list;
+       struct list_head        reap_list;
+       struct ib_wc            ibwc[IPOIB_NUM_WC];
+       struct ib_sge           rx_sge[IPOIB_CM_RX_SG];
        struct ib_recv_wr       rx_wr;
+       int                     nonsrq_conn_qp;
+       int                     max_cm_mtu;
+       int                     num_frags;
 };
 
 /*
@@ -271,29 +275,30 @@ struct ipoib_dev_priv {
        struct work_struct pkey_event_task;
 
        struct ib_device *ca;
-       u8                port;
-       u16               pkey;
-       u16               pkey_index;
-       struct ib_pd     *pd;
-       struct ib_mr     *mr;
-       struct ib_cq     *cq;
-       struct ib_qp     *qp;
-       u32               qkey;
+       u8                port;
+       u16               pkey;
+       u16               pkey_index;
+       struct ib_pd     *pd;
+       struct ib_mr     *mr;
+       struct ib_cq     *cq;
+       struct ib_qp     *qp;
+       u32               qkey;
 
        union ib_gid local_gid;
-       u16          local_lid;
+       u16          local_lid;
 
        unsigned int admin_mtu;
        unsigned int mcast_mtu;
 
        struct ipoib_rx_buf *rx_ring;
 
-       spinlock_t           tx_lock;
+       spinlock_t           tx_lock;
        struct ipoib_tx_buf *tx_ring;
-       unsigned             tx_head;
-       unsigned             tx_tail;
-       struct ib_sge        tx_sge;
+       unsigned             tx_head;
+       unsigned             tx_tail;
+       struct ib_sge        tx_sge[MAX_SKB_FRAGS + 1];
        struct ib_send_wr    tx_wr;
+       unsigned             tx_outstanding;
 
        struct ib_wc ibwc[IPOIB_NUM_WC];
 
@@ -314,14 +319,15 @@ struct ipoib_dev_priv {
        struct dentry *mcg_dentry;
        struct dentry *path_dentry;
 #endif
+       int     hca_caps;
 };
 
 struct ipoib_ah {
        struct net_device *dev;
-       struct ib_ah      *ah;
+       struct ib_ah      *ah;
        struct list_head   list;
-       struct kref        ref;
-       unsigned           last_send;
+       struct kref        ref;
+       unsigned           last_send;
 };
 
 struct ipoib_path {
@@ -332,11 +338,11 @@ struct ipoib_path {
 
        struct list_head      neigh_list;
 
-       int                   query_id;
+       int                   query_id;
        struct ib_sa_query   *query;
        struct completion     done;
 
-       struct rb_node        rb_node;
+       struct rb_node        rb_node;
        struct list_head      list;
 };
 
@@ -345,7 +351,7 @@ struct ipoib_neigh {
 #ifdef CONFIG_INFINIBAND_IPOIB_CM
        struct ipoib_cm_tx *cm;
 #endif
-       union ib_gid        dgid;
+       union ib_gid        dgid;
        struct sk_buff_head queue;
 
        struct neighbour   *neighbour;
@@ -456,12 +462,14 @@ void ipoib_drain_cq(struct net_device *dev);
 
 #ifdef CONFIG_INFINIBAND_IPOIB_CM
 
-#define IPOIB_FLAGS_RC          0x80
-#define IPOIB_FLAGS_UC          0x40
+#define IPOIB_FLAGS_RC         0x80
+#define IPOIB_FLAGS_UC         0x40
 
 /* We don't support UC connections at the moment */
 #define IPOIB_CM_SUPPORTED(ha)   (ha[0] & (IPOIB_FLAGS_RC))
 
+extern int ipoib_max_conn_qp;
+
 static inline int ipoib_cm_admin_enabled(struct net_device *dev)
 {
        struct ipoib_dev_priv *priv = netdev_priv(dev);
@@ -492,6 +500,18 @@ static inline void ipoib_cm_set(struct ipoib_neigh *neigh, struct ipoib_cm_tx *t
        neigh->cm = tx;
 }
 
+static inline int ipoib_cm_has_srq(struct net_device *dev)
+{
+       struct ipoib_dev_priv *priv = netdev_priv(dev);
+       return !!priv->cm.srq;
+}
+
+static inline unsigned int ipoib_cm_max_mtu(struct net_device *dev)
+{
+       struct ipoib_dev_priv *priv = netdev_priv(dev);
+       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);
@@ -501,13 +521,16 @@ 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_destroy_tx(struct ipoib_cm_tx *tx);
-void ipoib_cm_skb_too_long(struct net_devicedev, struct sk_buff *skb,
+void ipoib_cm_skb_too_long(struct net_device *dev, struct sk_buff *skb,
                           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);
 #else
 
 struct ipoib_cm_tx;
 
+#define ipoib_max_conn_qp 0
+
 static inline int ipoib_cm_admin_enabled(struct net_device *dev)
 {
        return 0;
@@ -533,6 +556,16 @@ static inline void ipoib_cm_set(struct ipoib_neigh *neigh, struct ipoib_cm_tx *t
 {
 }
 
+static inline int ipoib_cm_has_srq(struct net_device *dev)
+{
+       return 0;
+}
+
+static inline unsigned int ipoib_cm_max_mtu(struct net_device *dev)
+{
+       return 0;
+}
+
 static inline
 void ipoib_cm_send(struct net_device *dev, struct sk_buff *skb, struct ipoib_cm_tx *tx)
 {
@@ -582,7 +615,7 @@ int ipoib_cm_add_mode_attr(struct net_device *dev)
        return 0;
 }
 
-static inline void ipoib_cm_skb_too_long(struct net_devicedev, struct sk_buff *skb,
+static inline void ipoib_cm_skb_too_long(struct net_device *dev, struct sk_buff *skb,
                                         unsigned int mtu)
 {
        dev_kfree_skb_any(skb);
@@ -592,6 +625,9 @@ static inline void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *w
 {
 }
 
+static inline void ipoib_cm_handle_tx_wc(struct net_device *dev, struct ib_wc *wc)
+{
+}
 #endif
 
 #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
@@ -621,12 +657,12 @@ extern struct ib_sa_client ipoib_sa_client;
 extern int ipoib_debug_level;
 
 #define ipoib_dbg(priv, format, arg...)                        \
-       do {                                            \
+       do {                                            \
                if (ipoib_debug_level > 0)                      \
                        ipoib_printk(KERN_DEBUG, priv, format , ## arg); \
        } while (0)
 #define ipoib_dbg_mcast(priv, format, arg...)          \
-       do {                                            \
+       do {                                            \
                if (mcast_debug_level > 0)              \
                        ipoib_printk(KERN_DEBUG, priv, format , ## arg); \
        } while (0)
@@ -639,7 +675,7 @@ extern int ipoib_debug_level;
 
 #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG_DATA
 #define ipoib_dbg_data(priv, format, arg...)           \
-       do {                                            \
+       do {                                            \
                if (data_debug_level > 0)               \
                        ipoib_printk(KERN_DEBUG, priv, format , ## arg); \
        } while (0)