11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 32a1d9b7fSRoland Dreier * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 42a1d9b7fSRoland Dreier * Copyright (c) 2004 Voltaire, Inc. All rights reserved. 51da177e4SLinus Torvalds * 61da177e4SLinus Torvalds * This software is available to you under a choice of one of two 71da177e4SLinus Torvalds * licenses. You may choose to be licensed under the terms of the GNU 81da177e4SLinus Torvalds * General Public License (GPL) Version 2, available from the file 91da177e4SLinus Torvalds * COPYING in the main directory of this source tree, or the 101da177e4SLinus Torvalds * OpenIB.org BSD license below: 111da177e4SLinus Torvalds * 121da177e4SLinus Torvalds * Redistribution and use in source and binary forms, with or 131da177e4SLinus Torvalds * without modification, are permitted provided that the following 141da177e4SLinus Torvalds * conditions are met: 151da177e4SLinus Torvalds * 161da177e4SLinus Torvalds * - Redistributions of source code must retain the above 171da177e4SLinus Torvalds * copyright notice, this list of conditions and the following 181da177e4SLinus Torvalds * disclaimer. 191da177e4SLinus Torvalds * 201da177e4SLinus Torvalds * - Redistributions in binary form must reproduce the above 211da177e4SLinus Torvalds * copyright notice, this list of conditions and the following 221da177e4SLinus Torvalds * disclaimer in the documentation and/or other materials 231da177e4SLinus Torvalds * provided with the distribution. 241da177e4SLinus Torvalds * 251da177e4SLinus Torvalds * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 261da177e4SLinus Torvalds * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 271da177e4SLinus Torvalds * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 281da177e4SLinus Torvalds * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 291da177e4SLinus Torvalds * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 301da177e4SLinus Torvalds * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 311da177e4SLinus Torvalds * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 321da177e4SLinus Torvalds * SOFTWARE. 331da177e4SLinus Torvalds */ 341da177e4SLinus Torvalds 351da177e4SLinus Torvalds #ifndef _IPOIB_H 361da177e4SLinus Torvalds #define _IPOIB_H 371da177e4SLinus Torvalds 381da177e4SLinus Torvalds #include <linux/list.h> 391da177e4SLinus Torvalds #include <linux/skbuff.h> 401da177e4SLinus Torvalds #include <linux/netdevice.h> 411da177e4SLinus Torvalds #include <linux/workqueue.h> 421da177e4SLinus Torvalds #include <linux/kref.h> 431da177e4SLinus Torvalds #include <linux/if_infiniband.h> 4495ed644fSIngo Molnar #include <linux/mutex.h> 451da177e4SLinus Torvalds 461da177e4SLinus Torvalds #include <net/neighbour.h> 47936d7de3SRoland Dreier #include <net/sch_generic.h> 481da177e4SLinus Torvalds 4960063497SArun Sharma #include <linux/atomic.h> 501da177e4SLinus Torvalds 51a4d61e84SRoland Dreier #include <rdma/ib_verbs.h> 52a4d61e84SRoland Dreier #include <rdma/ib_pack.h> 53a4d61e84SRoland Dreier #include <rdma/ib_sa.h> 5419e364f6SOr Gerlitz #include <linux/sched.h> 551da177e4SLinus Torvalds 561da177e4SLinus Torvalds /* constants */ 571da177e4SLinus Torvalds 58ee1e2c82SMoni Shoua enum ipoib_flush_level { 59ee1e2c82SMoni Shoua IPOIB_FLUSH_LIGHT, 60ee1e2c82SMoni Shoua IPOIB_FLUSH_NORMAL, 61ee1e2c82SMoni Shoua IPOIB_FLUSH_HEAVY 62ee1e2c82SMoni Shoua }; 63ee1e2c82SMoni Shoua 641da177e4SLinus Torvalds enum { 651da177e4SLinus Torvalds IPOIB_ENCAP_LEN = 4, 661da177e4SLinus Torvalds 67bc7b3a36SShirley Ma IPOIB_UD_HEAD_SIZE = IB_GRH_BYTES + IPOIB_ENCAP_LEN, 68bc7b3a36SShirley Ma IPOIB_UD_RX_SG = 2, /* max buffer needed for 4K mtu */ 69bc7b3a36SShirley Ma 70839fcabaSMichael S. Tsirkin IPOIB_CM_MTU = 0x10000 - 0x10, /* padding to align header to 16 */ 71839fcabaSMichael S. Tsirkin IPOIB_CM_BUF_SIZE = IPOIB_CM_MTU + IPOIB_ENCAP_LEN, 72839fcabaSMichael S. Tsirkin IPOIB_CM_HEAD_SIZE = IPOIB_CM_BUF_SIZE % PAGE_SIZE, 73839fcabaSMichael S. Tsirkin IPOIB_CM_RX_SG = ALIGN(IPOIB_CM_BUF_SIZE, PAGE_SIZE) / PAGE_SIZE, 74bc3a290bSEli Cohen IPOIB_RX_RING_SIZE = 256, 75bc3a290bSEli Cohen IPOIB_TX_RING_SIZE = 128, 760f485251SShirley Ma IPOIB_MAX_QUEUE_SIZE = 8192, 770f485251SShirley Ma IPOIB_MIN_QUEUE_SIZE = 2, 7868e995a2SPradeep Satyanarayana IPOIB_CM_MAX_CONN_QP = 4096, 791da177e4SLinus Torvalds 801da177e4SLinus Torvalds IPOIB_NUM_WC = 4, 811da177e4SLinus Torvalds 821da177e4SLinus Torvalds IPOIB_MAX_PATH_REC_QUEUE = 3, 831da177e4SLinus Torvalds IPOIB_MAX_MCAST_QUEUE = 3, 841da177e4SLinus Torvalds 851da177e4SLinus Torvalds IPOIB_FLAG_OPER_UP = 0, 867a343d4cSLeonid Arsh IPOIB_FLAG_INITIALIZED = 1, 877a343d4cSLeonid Arsh IPOIB_FLAG_ADMIN_UP = 2, 887a343d4cSLeonid Arsh IPOIB_PKEY_ASSIGNED = 3, 897a343d4cSLeonid Arsh IPOIB_PKEY_STOP = 4, 907a343d4cSLeonid Arsh IPOIB_FLAG_SUBINTERFACE = 5, 917a343d4cSLeonid Arsh IPOIB_MCAST_RUN = 6, 927a343d4cSLeonid Arsh IPOIB_STOP_REAPER = 7, 931b524963SMichael S. Tsirkin IPOIB_FLAG_ADMIN_CM = 9, 941b524963SMichael S. Tsirkin IPOIB_FLAG_UMCAST = 10, 95b63b70d8SShlomo Pongratz IPOIB_STOP_NEIGH_GC = 11, 96b63b70d8SShlomo Pongratz IPOIB_NEIGH_TBL_FLUSH = 12, 971da177e4SLinus Torvalds 981da177e4SLinus Torvalds IPOIB_MAX_BACKOFF_SECONDS = 16, 991da177e4SLinus Torvalds 1001da177e4SLinus Torvalds IPOIB_MCAST_FLAG_FOUND = 0, /* used in set_multicast_list */ 1011da177e4SLinus Torvalds IPOIB_MCAST_FLAG_SENDONLY = 1, 1021da177e4SLinus Torvalds IPOIB_MCAST_FLAG_BUSY = 2, /* joining or already joined */ 1031da177e4SLinus Torvalds IPOIB_MCAST_FLAG_ATTACHED = 3, 104f56bcd80SEli Cohen 105f56bcd80SEli Cohen MAX_SEND_CQE = 16, 106f89271daSEli Cohen IPOIB_CM_COPYBREAK = 256, 1079baa0b03SOr Gerlitz 1089baa0b03SOr Gerlitz IPOIB_NON_CHILD = 0, 1099baa0b03SOr Gerlitz IPOIB_LEGACY_CHILD = 1, 1109baa0b03SOr Gerlitz IPOIB_RTNL_CHILD = 2, 1111da177e4SLinus Torvalds }; 1121da177e4SLinus Torvalds 113839fcabaSMichael S. Tsirkin #define IPOIB_OP_RECV (1ul << 31) 114839fcabaSMichael S. Tsirkin #ifdef CONFIG_INFINIBAND_IPOIB_CM 1151b524963SMichael S. Tsirkin #define IPOIB_OP_CM (1ul << 30) 116839fcabaSMichael S. Tsirkin #else 1171b524963SMichael S. Tsirkin #define IPOIB_OP_CM (0) 118839fcabaSMichael S. Tsirkin #endif 119839fcabaSMichael S. Tsirkin 120*9d1ad66eSShlomo Pongratz #define IPOIB_QPN_MASK ((__force u32) cpu_to_be32(0xFFFFFF)) 121*9d1ad66eSShlomo Pongratz 1221da177e4SLinus Torvalds /* structs */ 1231da177e4SLinus Torvalds 1241da177e4SLinus Torvalds struct ipoib_header { 12597f52eb4SSean Hefty __be16 proto; 1261da177e4SLinus Torvalds u16 reserved; 1271da177e4SLinus Torvalds }; 1281da177e4SLinus Torvalds 129936d7de3SRoland Dreier struct ipoib_cb { 130936d7de3SRoland Dreier struct qdisc_skb_cb qdisc_cb; 1311da177e4SLinus Torvalds u8 hwaddr[INFINIBAND_ALEN]; 1321da177e4SLinus Torvalds }; 1331da177e4SLinus Torvalds 13481668838SSean Hefty /* Used for all multicast joins (broadcast, IPv4 mcast and IPv6 mcast) */ 13581668838SSean Hefty struct ipoib_mcast { 13681668838SSean Hefty struct ib_sa_mcmember_rec mcmember; 13781668838SSean Hefty struct ib_sa_multicast *mc; 13881668838SSean Hefty struct ipoib_ah *ah; 13981668838SSean Hefty 14081668838SSean Hefty struct rb_node rb_node; 14181668838SSean Hefty struct list_head list; 14281668838SSean Hefty 14381668838SSean Hefty unsigned long created; 14481668838SSean Hefty unsigned long backoff; 14581668838SSean Hefty 14681668838SSean Hefty unsigned long flags; 14781668838SSean Hefty unsigned char logcount; 14881668838SSean Hefty 14981668838SSean Hefty struct list_head neigh_list; 15081668838SSean Hefty 15181668838SSean Hefty struct sk_buff_head pkt_queue; 15281668838SSean Hefty 15381668838SSean Hefty struct net_device *dev; 15481668838SSean Hefty }; 1551da177e4SLinus Torvalds 1561993d683SRoland Dreier struct ipoib_rx_buf { 1571993d683SRoland Dreier struct sk_buff *skb; 158bc7b3a36SShirley Ma u64 mapping[IPOIB_UD_RX_SG]; 1591993d683SRoland Dreier }; 1601993d683SRoland Dreier 1611993d683SRoland Dreier struct ipoib_tx_buf { 1621da177e4SLinus Torvalds struct sk_buff *skb; 1637143740dSEli Cohen u64 mapping[MAX_SKB_FRAGS + 1]; 1641da177e4SLinus Torvalds }; 1651da177e4SLinus Torvalds 166e112373fSEli Cohen struct ipoib_cm_tx_buf { 167e112373fSEli Cohen struct sk_buff *skb; 168e112373fSEli Cohen u64 mapping; 169e112373fSEli Cohen }; 170e112373fSEli Cohen 171839fcabaSMichael S. Tsirkin struct ib_cm_id; 172839fcabaSMichael S. Tsirkin 173839fcabaSMichael S. Tsirkin struct ipoib_cm_data { 174839fcabaSMichael S. Tsirkin __be32 qpn; /* High byte MUST be ignored on receive */ 175839fcabaSMichael S. Tsirkin __be32 mtu; 176839fcabaSMichael S. Tsirkin }; 177839fcabaSMichael S. Tsirkin 178518b1646SMichael S. Tsirkin /* 179518b1646SMichael S. Tsirkin * Quoting 10.3.1 Queue Pair and EE Context States: 180518b1646SMichael S. Tsirkin * 181518b1646SMichael S. Tsirkin * Note, for QPs that are associated with an SRQ, the Consumer should take the 182518b1646SMichael S. Tsirkin * QP through the Error State before invoking a Destroy QP or a Modify QP to the 183518b1646SMichael S. Tsirkin * Reset State. The Consumer may invoke the Destroy QP without first performing 184518b1646SMichael S. Tsirkin * a Modify QP to the Error State and waiting for the Affiliated Asynchronous 185518b1646SMichael S. Tsirkin * Last WQE Reached Event. However, if the Consumer does not wait for the 186518b1646SMichael S. Tsirkin * Affiliated Asynchronous Last WQE Reached Event, then WQE and Data Segment 187518b1646SMichael S. Tsirkin * leakage may occur. Therefore, it is good programming practice to tear down a 188518b1646SMichael S. Tsirkin * QP that is associated with an SRQ by using the following process: 189518b1646SMichael S. Tsirkin * 190518b1646SMichael S. Tsirkin * - Put the QP in the Error State 191518b1646SMichael S. Tsirkin * - Wait for the Affiliated Asynchronous Last WQE Reached Event; 192518b1646SMichael S. Tsirkin * - either: 193518b1646SMichael S. Tsirkin * drain the CQ by invoking the Poll CQ verb and either wait for CQ 194518b1646SMichael S. Tsirkin * to be empty or the number of Poll CQ operations has exceeded 195518b1646SMichael S. Tsirkin * CQ capacity size; 196518b1646SMichael S. Tsirkin * - or 197518b1646SMichael S. Tsirkin * post another WR that completes on the same CQ and wait for this 198518b1646SMichael S. Tsirkin * WR to return as a WC; 199518b1646SMichael S. Tsirkin * - and then invoke a Destroy QP or Reset QP. 200518b1646SMichael S. Tsirkin * 201518b1646SMichael S. Tsirkin * We use the second option and wait for a completion on the 202ec56dc0bSMichael S. Tsirkin * same CQ before destroying QPs attached to our SRQ. 203518b1646SMichael S. Tsirkin */ 204518b1646SMichael S. Tsirkin 205518b1646SMichael S. Tsirkin enum ipoib_cm_state { 206518b1646SMichael S. Tsirkin IPOIB_CM_RX_LIVE, 207518b1646SMichael S. Tsirkin IPOIB_CM_RX_ERROR, /* Ignored by stale task */ 208518b1646SMichael S. Tsirkin IPOIB_CM_RX_FLUSH /* Last WQE Reached event observed */ 209518b1646SMichael S. Tsirkin }; 210518b1646SMichael S. Tsirkin 211839fcabaSMichael S. Tsirkin struct ipoib_cm_rx { 212839fcabaSMichael S. Tsirkin struct ib_cm_id *id; 213839fcabaSMichael S. Tsirkin struct ib_qp *qp; 21468e995a2SPradeep Satyanarayana struct ipoib_cm_rx_buf *rx_ring; 215839fcabaSMichael S. Tsirkin struct list_head list; 216839fcabaSMichael S. Tsirkin struct net_device *dev; 217839fcabaSMichael S. Tsirkin unsigned long jiffies; 218518b1646SMichael S. Tsirkin enum ipoib_cm_state state; 21968e995a2SPradeep Satyanarayana int recv_count; 220839fcabaSMichael S. Tsirkin }; 221839fcabaSMichael S. Tsirkin 222839fcabaSMichael S. Tsirkin struct ipoib_cm_tx { 223839fcabaSMichael S. Tsirkin struct ib_cm_id *id; 224839fcabaSMichael S. Tsirkin struct ib_qp *qp; 225839fcabaSMichael S. Tsirkin struct list_head list; 226839fcabaSMichael S. Tsirkin struct net_device *dev; 227839fcabaSMichael S. Tsirkin struct ipoib_neigh *neigh; 228839fcabaSMichael S. Tsirkin struct ipoib_path *path; 229e112373fSEli Cohen struct ipoib_cm_tx_buf *tx_ring; 230839fcabaSMichael S. Tsirkin unsigned tx_head; 231839fcabaSMichael S. Tsirkin unsigned tx_tail; 232839fcabaSMichael S. Tsirkin unsigned long flags; 233839fcabaSMichael S. Tsirkin u32 mtu; 234839fcabaSMichael S. Tsirkin }; 235839fcabaSMichael S. Tsirkin 236839fcabaSMichael S. Tsirkin struct ipoib_cm_rx_buf { 237839fcabaSMichael S. Tsirkin struct sk_buff *skb; 238839fcabaSMichael S. Tsirkin u64 mapping[IPOIB_CM_RX_SG]; 239839fcabaSMichael S. Tsirkin }; 240839fcabaSMichael S. Tsirkin 241839fcabaSMichael S. Tsirkin struct ipoib_cm_dev_priv { 242839fcabaSMichael S. Tsirkin struct ib_srq *srq; 243839fcabaSMichael S. Tsirkin struct ipoib_cm_rx_buf *srq_ring; 244839fcabaSMichael S. Tsirkin struct ib_cm_id *id; 245518b1646SMichael S. Tsirkin struct list_head passive_ids; /* state: LIVE */ 246518b1646SMichael S. Tsirkin struct list_head rx_error_list; /* state: ERROR */ 247518b1646SMichael S. Tsirkin struct list_head rx_flush_list; /* state: FLUSH, drain not started */ 248518b1646SMichael S. Tsirkin struct list_head rx_drain_list; /* state: FLUSH, drain started */ 249518b1646SMichael S. Tsirkin struct list_head rx_reap_list; /* state: FLUSH, drain done */ 250839fcabaSMichael S. Tsirkin struct work_struct start_task; 251839fcabaSMichael S. Tsirkin struct work_struct reap_task; 252839fcabaSMichael S. Tsirkin struct work_struct skb_task; 253518b1646SMichael S. Tsirkin struct work_struct rx_reap_task; 254839fcabaSMichael S. Tsirkin struct delayed_work stale_task; 255839fcabaSMichael S. Tsirkin struct sk_buff_head skb_queue; 256839fcabaSMichael S. Tsirkin struct list_head start_list; 257839fcabaSMichael S. Tsirkin struct list_head reap_list; 258839fcabaSMichael S. Tsirkin struct ib_wc ibwc[IPOIB_NUM_WC]; 259839fcabaSMichael S. Tsirkin struct ib_sge rx_sge[IPOIB_CM_RX_SG]; 260839fcabaSMichael S. Tsirkin struct ib_recv_wr rx_wr; 26168e995a2SPradeep Satyanarayana int nonsrq_conn_qp; 262586a6934SPradeep Satyanarayana int max_cm_mtu; 263586a6934SPradeep Satyanarayana int num_frags; 264839fcabaSMichael S. Tsirkin }; 265839fcabaSMichael S. Tsirkin 26628d52b3cSEli Cohen struct ipoib_ethtool_st { 26728d52b3cSEli Cohen u16 coalesce_usecs; 26828d52b3cSEli Cohen u16 max_coalesced_frames; 26928d52b3cSEli Cohen }; 27028d52b3cSEli Cohen 27166172c09SShlomo Pongratz struct ipoib_neigh_table; 27266172c09SShlomo Pongratz 273b63b70d8SShlomo Pongratz struct ipoib_neigh_hash { 27466172c09SShlomo Pongratz struct ipoib_neigh_table *ntbl; 275b63b70d8SShlomo Pongratz struct ipoib_neigh __rcu **buckets; 276b63b70d8SShlomo Pongratz struct rcu_head rcu; 277b63b70d8SShlomo Pongratz u32 mask; 278b63b70d8SShlomo Pongratz u32 size; 279b63b70d8SShlomo Pongratz }; 280b63b70d8SShlomo Pongratz 281b63b70d8SShlomo Pongratz struct ipoib_neigh_table { 282b63b70d8SShlomo Pongratz struct ipoib_neigh_hash __rcu *htbl; 283b63b70d8SShlomo Pongratz atomic_t entries; 284b63b70d8SShlomo Pongratz struct completion flushed; 28566172c09SShlomo Pongratz struct completion deleted; 286b63b70d8SShlomo Pongratz }; 287b63b70d8SShlomo Pongratz 2881da177e4SLinus Torvalds /* 289943c246eSRoland Dreier * Device private locking: network stack tx_lock protects members used 290943c246eSRoland Dreier * in TX fast path, lock protects everything else. lock nests inside 291943c246eSRoland Dreier * of tx_lock (ie tx_lock must be acquired first if needed). 2921da177e4SLinus Torvalds */ 2931da177e4SLinus Torvalds struct ipoib_dev_priv { 2941da177e4SLinus Torvalds spinlock_t lock; 2951da177e4SLinus Torvalds 2961da177e4SLinus Torvalds struct net_device *dev; 2971da177e4SLinus Torvalds 298bea3348eSStephen Hemminger struct napi_struct napi; 299bea3348eSStephen Hemminger 3001da177e4SLinus Torvalds unsigned long flags; 3011da177e4SLinus Torvalds 30295ed644fSIngo Molnar struct mutex vlan_mutex; 3031da177e4SLinus Torvalds 3041da177e4SLinus Torvalds struct rb_root path_tree; 3051da177e4SLinus Torvalds struct list_head path_list; 3061da177e4SLinus Torvalds 307b63b70d8SShlomo Pongratz struct ipoib_neigh_table ntbl; 308b63b70d8SShlomo Pongratz 3091da177e4SLinus Torvalds struct ipoib_mcast *broadcast; 3101da177e4SLinus Torvalds struct list_head multicast_list; 3111da177e4SLinus Torvalds struct rb_root multicast_tree; 3121da177e4SLinus Torvalds 31326bbf13cSYosef Etigin struct delayed_work pkey_poll_task; 314c4028958SDavid Howells struct delayed_work mcast_task; 315e8224e4bSYossi Etigin struct work_struct carrier_on_task; 316ee1e2c82SMoni Shoua struct work_struct flush_light; 317ee1e2c82SMoni Shoua struct work_struct flush_normal; 318ee1e2c82SMoni Shoua struct work_struct flush_heavy; 3191da177e4SLinus Torvalds struct work_struct restart_task; 320c4028958SDavid Howells struct delayed_work ah_reap_task; 321b63b70d8SShlomo Pongratz struct delayed_work neigh_reap_task; 3221da177e4SLinus Torvalds struct ib_device *ca; 3231da177e4SLinus Torvalds u8 port; 3241da177e4SLinus Torvalds u16 pkey; 32526bbf13cSYosef Etigin u16 pkey_index; 3261da177e4SLinus Torvalds struct ib_pd *pd; 3271da177e4SLinus Torvalds struct ib_mr *mr; 328f56bcd80SEli Cohen struct ib_cq *recv_cq; 329f56bcd80SEli Cohen struct ib_cq *send_cq; 3301da177e4SLinus Torvalds struct ib_qp *qp; 3311da177e4SLinus Torvalds u32 qkey; 3321da177e4SLinus Torvalds 3331da177e4SLinus Torvalds union ib_gid local_gid; 3341da177e4SLinus Torvalds u16 local_lid; 3351da177e4SLinus Torvalds 3361da177e4SLinus Torvalds unsigned int admin_mtu; 3371da177e4SLinus Torvalds unsigned int mcast_mtu; 338bc7b3a36SShirley Ma unsigned int max_ib_mtu; 3391da177e4SLinus Torvalds 3401993d683SRoland Dreier struct ipoib_rx_buf *rx_ring; 3411da177e4SLinus Torvalds 3421993d683SRoland Dreier struct ipoib_tx_buf *tx_ring; 3431da177e4SLinus Torvalds unsigned tx_head; 3441da177e4SLinus Torvalds unsigned tx_tail; 3457143740dSEli Cohen struct ib_sge tx_sge[MAX_SKB_FRAGS + 1]; 3461da177e4SLinus Torvalds struct ib_send_wr tx_wr; 3471b524963SMichael S. Tsirkin unsigned tx_outstanding; 348f56bcd80SEli Cohen struct ib_wc send_wc[MAX_SEND_CQE]; 3491da177e4SLinus Torvalds 350bc7b3a36SShirley Ma struct ib_recv_wr rx_wr; 351bc7b3a36SShirley Ma struct ib_sge rx_sge[IPOIB_UD_RX_SG]; 352bc7b3a36SShirley Ma 3531da177e4SLinus Torvalds struct ib_wc ibwc[IPOIB_NUM_WC]; 3541da177e4SLinus Torvalds 3551da177e4SLinus Torvalds struct list_head dead_ahs; 3561da177e4SLinus Torvalds 3571da177e4SLinus Torvalds struct ib_event_handler event_handler; 3581da177e4SLinus Torvalds 3591da177e4SLinus Torvalds struct net_device *parent; 3601da177e4SLinus Torvalds struct list_head child_intfs; 3611da177e4SLinus Torvalds struct list_head list; 3629baa0b03SOr Gerlitz int child_type; 3631da177e4SLinus Torvalds 364839fcabaSMichael S. Tsirkin #ifdef CONFIG_INFINIBAND_IPOIB_CM 365839fcabaSMichael S. Tsirkin struct ipoib_cm_dev_priv cm; 366839fcabaSMichael S. Tsirkin #endif 367839fcabaSMichael S. Tsirkin 3681da177e4SLinus Torvalds #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG 3691da177e4SLinus Torvalds struct list_head fs_list; 3701da177e4SLinus Torvalds struct dentry *mcg_dentry; 3711732b0efSRoland Dreier struct dentry *path_dentry; 3721da177e4SLinus Torvalds #endif 37340ca1988SEli Cohen int hca_caps; 37428d52b3cSEli Cohen struct ipoib_ethtool_st ethtool; 37557ce41d1SEli Cohen struct timer_list poll_timer; 3761da177e4SLinus Torvalds }; 3771da177e4SLinus Torvalds 3781da177e4SLinus Torvalds struct ipoib_ah { 3791da177e4SLinus Torvalds struct net_device *dev; 3801da177e4SLinus Torvalds struct ib_ah *ah; 3811da177e4SLinus Torvalds struct list_head list; 3821da177e4SLinus Torvalds struct kref ref; 3831da177e4SLinus Torvalds unsigned last_send; 3841da177e4SLinus Torvalds }; 3851da177e4SLinus Torvalds 3861da177e4SLinus Torvalds struct ipoib_path { 3871da177e4SLinus Torvalds struct net_device *dev; 3881da177e4SLinus Torvalds struct ib_sa_path_rec pathrec; 3891da177e4SLinus Torvalds struct ipoib_ah *ah; 3901da177e4SLinus Torvalds struct sk_buff_head queue; 3911da177e4SLinus Torvalds 3921da177e4SLinus Torvalds struct list_head neigh_list; 3931da177e4SLinus Torvalds 3941da177e4SLinus Torvalds int query_id; 3951da177e4SLinus Torvalds struct ib_sa_query *query; 3961da177e4SLinus Torvalds struct completion done; 3971da177e4SLinus Torvalds 3981da177e4SLinus Torvalds struct rb_node rb_node; 3991da177e4SLinus Torvalds struct list_head list; 400ee1e2c82SMoni Shoua int valid; 4011da177e4SLinus Torvalds }; 4021da177e4SLinus Torvalds 4031da177e4SLinus Torvalds struct ipoib_neigh { 4041da177e4SLinus Torvalds struct ipoib_ah *ah; 405839fcabaSMichael S. Tsirkin #ifdef CONFIG_INFINIBAND_IPOIB_CM 406839fcabaSMichael S. Tsirkin struct ipoib_cm_tx *cm; 407839fcabaSMichael S. Tsirkin #endif 408b63b70d8SShlomo Pongratz u8 daddr[INFINIBAND_ALEN]; 4091da177e4SLinus Torvalds struct sk_buff_head queue; 4101da177e4SLinus Torvalds 411732a2170SMoni Shoua struct net_device *dev; 4121da177e4SLinus Torvalds 4131da177e4SLinus Torvalds struct list_head list; 414b63b70d8SShlomo Pongratz struct ipoib_neigh __rcu *hnext; 415b63b70d8SShlomo Pongratz struct rcu_head rcu; 416b63b70d8SShlomo Pongratz atomic_t refcnt; 417b63b70d8SShlomo Pongratz unsigned long alive; 4181da177e4SLinus Torvalds }; 4191da177e4SLinus Torvalds 420bc7b3a36SShirley Ma #define IPOIB_UD_MTU(ib_mtu) (ib_mtu - IPOIB_ENCAP_LEN) 421bc7b3a36SShirley Ma #define IPOIB_UD_BUF_SIZE(ib_mtu) (ib_mtu + IB_GRH_BYTES) 422bc7b3a36SShirley Ma 423bc7b3a36SShirley Ma static inline int ipoib_ud_need_sg(unsigned int ib_mtu) 424bc7b3a36SShirley Ma { 425bc7b3a36SShirley Ma return IPOIB_UD_BUF_SIZE(ib_mtu) > PAGE_SIZE; 426bc7b3a36SShirley Ma } 427bc7b3a36SShirley Ma 428b63b70d8SShlomo Pongratz void ipoib_neigh_dtor(struct ipoib_neigh *neigh); 429b63b70d8SShlomo Pongratz static inline void ipoib_neigh_put(struct ipoib_neigh *neigh) 4301da177e4SLinus Torvalds { 431b63b70d8SShlomo Pongratz if (atomic_dec_and_test(&neigh->refcnt)) 432b63b70d8SShlomo Pongratz ipoib_neigh_dtor(neigh); 4331da177e4SLinus Torvalds } 434b63b70d8SShlomo Pongratz struct ipoib_neigh *ipoib_neigh_get(struct net_device *dev, u8 *daddr); 435b63b70d8SShlomo Pongratz struct ipoib_neigh *ipoib_neigh_alloc(u8 *daddr, 436732a2170SMoni Shoua struct net_device *dev); 437b63b70d8SShlomo Pongratz void ipoib_neigh_free(struct ipoib_neigh *neigh); 438b63b70d8SShlomo Pongratz void ipoib_del_neighs_by_gid(struct net_device *dev, u8 *gid); 439d2e0655eSMichael S. Tsirkin 4401da177e4SLinus Torvalds extern struct workqueue_struct *ipoib_workqueue; 4411da177e4SLinus Torvalds 4421da177e4SLinus Torvalds /* functions */ 4431da177e4SLinus Torvalds 444bea3348eSStephen Hemminger int ipoib_poll(struct napi_struct *napi, int budget); 4451da177e4SLinus Torvalds void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr); 44657ce41d1SEli Cohen void ipoib_send_comp_handler(struct ib_cq *cq, void *dev_ptr); 4471da177e4SLinus Torvalds 4481da177e4SLinus Torvalds struct ipoib_ah *ipoib_create_ah(struct net_device *dev, 4491da177e4SLinus Torvalds struct ib_pd *pd, struct ib_ah_attr *attr); 4501da177e4SLinus Torvalds void ipoib_free_ah(struct kref *kref); 4511da177e4SLinus Torvalds static inline void ipoib_put_ah(struct ipoib_ah *ah) 4521da177e4SLinus Torvalds { 4531da177e4SLinus Torvalds kref_put(&ah->ref, ipoib_free_ah); 4541da177e4SLinus Torvalds } 4558ae5a8a2SRoland Dreier int ipoib_open(struct net_device *dev); 4561da177e4SLinus Torvalds int ipoib_add_pkey_attr(struct net_device *dev); 457335a64a5SOr Gerlitz int ipoib_add_umcast_attr(struct net_device *dev); 4581da177e4SLinus Torvalds 4591da177e4SLinus Torvalds void ipoib_send(struct net_device *dev, struct sk_buff *skb, 4601da177e4SLinus Torvalds struct ipoib_ah *address, u32 qpn); 461c4028958SDavid Howells void ipoib_reap_ah(struct work_struct *work); 4621da177e4SLinus Torvalds 463ee1e2c82SMoni Shoua void ipoib_mark_paths_invalid(struct net_device *dev); 4641da177e4SLinus Torvalds void ipoib_flush_paths(struct net_device *dev); 4651da177e4SLinus Torvalds struct ipoib_dev_priv *ipoib_intf_alloc(const char *format); 4661da177e4SLinus Torvalds 4671da177e4SLinus Torvalds int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port); 468ee1e2c82SMoni Shoua void ipoib_ib_dev_flush_light(struct work_struct *work); 469ee1e2c82SMoni Shoua void ipoib_ib_dev_flush_normal(struct work_struct *work); 470ee1e2c82SMoni Shoua void ipoib_ib_dev_flush_heavy(struct work_struct *work); 47126bbf13cSYosef Etigin void ipoib_pkey_event(struct work_struct *work); 4721da177e4SLinus Torvalds void ipoib_ib_dev_cleanup(struct net_device *dev); 4731da177e4SLinus Torvalds 4741da177e4SLinus Torvalds int ipoib_ib_dev_open(struct net_device *dev); 4751da177e4SLinus Torvalds int ipoib_ib_dev_up(struct net_device *dev); 4760b3ea082SJack Morgenstein int ipoib_ib_dev_down(struct net_device *dev, int flush); 47726bbf13cSYosef Etigin int ipoib_ib_dev_stop(struct net_device *dev, int flush); 4781da177e4SLinus Torvalds 4791da177e4SLinus Torvalds int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port); 4801da177e4SLinus Torvalds void ipoib_dev_cleanup(struct net_device *dev); 4811da177e4SLinus Torvalds 482c4028958SDavid Howells void ipoib_mcast_join_task(struct work_struct *work); 483e8224e4bSYossi Etigin void ipoib_mcast_carrier_on_task(struct work_struct *work); 484b63b70d8SShlomo Pongratz void ipoib_mcast_send(struct net_device *dev, u8 *daddr, struct sk_buff *skb); 4851da177e4SLinus Torvalds 486c4028958SDavid Howells void ipoib_mcast_restart_task(struct work_struct *work); 4871da177e4SLinus Torvalds int ipoib_mcast_start_thread(struct net_device *dev); 4888d2cae06SRoland Dreier int ipoib_mcast_stop_thread(struct net_device *dev, int flush); 4891da177e4SLinus Torvalds 4901da177e4SLinus Torvalds void ipoib_mcast_dev_down(struct net_device *dev); 4911da177e4SLinus Torvalds void ipoib_mcast_dev_flush(struct net_device *dev); 4921da177e4SLinus Torvalds 4938ae5a8a2SRoland Dreier #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG 4941da177e4SLinus Torvalds struct ipoib_mcast_iter *ipoib_mcast_iter_init(struct net_device *dev); 4951da177e4SLinus Torvalds int ipoib_mcast_iter_next(struct ipoib_mcast_iter *iter); 4961da177e4SLinus Torvalds void ipoib_mcast_iter_read(struct ipoib_mcast_iter *iter, 4971da177e4SLinus Torvalds union ib_gid *gid, 4981da177e4SLinus Torvalds unsigned long *created, 4991da177e4SLinus Torvalds unsigned int *queuelen, 5001da177e4SLinus Torvalds unsigned int *complete, 5011da177e4SLinus Torvalds unsigned int *send_only); 5021732b0efSRoland Dreier 5031732b0efSRoland Dreier struct ipoib_path_iter *ipoib_path_iter_init(struct net_device *dev); 5041732b0efSRoland Dreier int ipoib_path_iter_next(struct ipoib_path_iter *iter); 5051732b0efSRoland Dreier void ipoib_path_iter_read(struct ipoib_path_iter *iter, 5061732b0efSRoland Dreier struct ipoib_path *path); 5078ae5a8a2SRoland Dreier #endif 5081da177e4SLinus Torvalds 5091da177e4SLinus Torvalds int ipoib_mcast_attach(struct net_device *dev, u16 mlid, 510d0de1362SEli Cohen union ib_gid *mgid, int set_qkey); 5111da177e4SLinus Torvalds 5125b6810e0SRoland Dreier int ipoib_init_qp(struct net_device *dev); 5131da177e4SLinus Torvalds int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca); 5141da177e4SLinus Torvalds void ipoib_transport_dev_cleanup(struct net_device *dev); 5151da177e4SLinus Torvalds 5161da177e4SLinus Torvalds void ipoib_event(struct ib_event_handler *handler, 5171da177e4SLinus Torvalds struct ib_event *record); 5181da177e4SLinus Torvalds 5191da177e4SLinus Torvalds int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey); 5201da177e4SLinus Torvalds int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey); 5211da177e4SLinus Torvalds 5229baa0b03SOr Gerlitz int __ipoib_vlan_add(struct ipoib_dev_priv *ppriv, struct ipoib_dev_priv *priv, 5239baa0b03SOr Gerlitz u16 pkey, int child_type); 5249baa0b03SOr Gerlitz 5259baa0b03SOr Gerlitz int __init ipoib_netlink_init(void); 5269baa0b03SOr Gerlitz void __exit ipoib_netlink_fini(void); 5279baa0b03SOr Gerlitz 528862096a8SOr Gerlitz void ipoib_set_umcast(struct net_device *ndev, int umcast_val); 529862096a8SOr Gerlitz int ipoib_set_mode(struct net_device *dev, const char *buf); 530862096a8SOr Gerlitz 5319baa0b03SOr Gerlitz void ipoib_setup(struct net_device *dev); 5329baa0b03SOr Gerlitz 533c4028958SDavid Howells void ipoib_pkey_poll(struct work_struct *work); 5341da177e4SLinus Torvalds int ipoib_pkey_dev_delay_open(struct net_device *dev); 5352dfbfc37SMichael S. Tsirkin void ipoib_drain_cq(struct net_device *dev); 5361da177e4SLinus Torvalds 53782c24c18SEli Cohen void ipoib_set_ethtool_ops(struct net_device *dev); 53883bb63f6SOr Gerlitz int ipoib_set_dev_features(struct ipoib_dev_priv *priv, struct ib_device *hca); 53982c24c18SEli Cohen 540839fcabaSMichael S. Tsirkin #define IPOIB_FLAGS_RC 0x80 541839fcabaSMichael S. Tsirkin #define IPOIB_FLAGS_UC 0x40 542839fcabaSMichael S. Tsirkin 543839fcabaSMichael S. Tsirkin /* We don't support UC connections at the moment */ 544839fcabaSMichael S. Tsirkin #define IPOIB_CM_SUPPORTED(ha) (ha[0] & (IPOIB_FLAGS_RC)) 545839fcabaSMichael S. Tsirkin 54671d9c5f9SRoland Dreier #ifdef CONFIG_INFINIBAND_IPOIB_CM 54771d9c5f9SRoland Dreier 54868e995a2SPradeep Satyanarayana extern int ipoib_max_conn_qp; 54968e995a2SPradeep Satyanarayana 550839fcabaSMichael S. Tsirkin static inline int ipoib_cm_admin_enabled(struct net_device *dev) 551839fcabaSMichael S. Tsirkin { 552839fcabaSMichael S. Tsirkin struct ipoib_dev_priv *priv = netdev_priv(dev); 553839fcabaSMichael S. Tsirkin return IPOIB_CM_SUPPORTED(dev->dev_addr) && 554839fcabaSMichael S. Tsirkin test_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags); 555839fcabaSMichael S. Tsirkin } 556839fcabaSMichael S. Tsirkin 557b63b70d8SShlomo Pongratz static inline int ipoib_cm_enabled(struct net_device *dev, u8 *hwaddr) 558839fcabaSMichael S. Tsirkin { 559839fcabaSMichael S. Tsirkin struct ipoib_dev_priv *priv = netdev_priv(dev); 560b63b70d8SShlomo Pongratz return IPOIB_CM_SUPPORTED(hwaddr) && 561839fcabaSMichael S. Tsirkin test_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags); 562839fcabaSMichael S. Tsirkin } 563839fcabaSMichael S. Tsirkin 564839fcabaSMichael S. Tsirkin static inline int ipoib_cm_up(struct ipoib_neigh *neigh) 565839fcabaSMichael S. Tsirkin 566839fcabaSMichael S. Tsirkin { 567839fcabaSMichael S. Tsirkin return test_bit(IPOIB_FLAG_OPER_UP, &neigh->cm->flags); 568839fcabaSMichael S. Tsirkin } 569839fcabaSMichael S. Tsirkin 570839fcabaSMichael S. Tsirkin static inline struct ipoib_cm_tx *ipoib_cm_get(struct ipoib_neigh *neigh) 571839fcabaSMichael S. Tsirkin { 572839fcabaSMichael S. Tsirkin return neigh->cm; 573839fcabaSMichael S. Tsirkin } 574839fcabaSMichael S. Tsirkin 575839fcabaSMichael S. Tsirkin static inline void ipoib_cm_set(struct ipoib_neigh *neigh, struct ipoib_cm_tx *tx) 576839fcabaSMichael S. Tsirkin { 577839fcabaSMichael S. Tsirkin neigh->cm = tx; 578839fcabaSMichael S. Tsirkin } 579839fcabaSMichael S. Tsirkin 58068e995a2SPradeep Satyanarayana static inline int ipoib_cm_has_srq(struct net_device *dev) 58168e995a2SPradeep Satyanarayana { 58268e995a2SPradeep Satyanarayana struct ipoib_dev_priv *priv = netdev_priv(dev); 58368e995a2SPradeep Satyanarayana return !!priv->cm.srq; 58468e995a2SPradeep Satyanarayana } 58568e995a2SPradeep Satyanarayana 586586a6934SPradeep Satyanarayana static inline unsigned int ipoib_cm_max_mtu(struct net_device *dev) 587586a6934SPradeep Satyanarayana { 588586a6934SPradeep Satyanarayana struct ipoib_dev_priv *priv = netdev_priv(dev); 589586a6934SPradeep Satyanarayana return priv->cm.max_cm_mtu; 590586a6934SPradeep Satyanarayana } 591586a6934SPradeep Satyanarayana 592839fcabaSMichael S. Tsirkin void ipoib_cm_send(struct net_device *dev, struct sk_buff *skb, struct ipoib_cm_tx *tx); 593839fcabaSMichael S. Tsirkin int ipoib_cm_dev_open(struct net_device *dev); 594839fcabaSMichael S. Tsirkin void ipoib_cm_dev_stop(struct net_device *dev); 595839fcabaSMichael S. Tsirkin int ipoib_cm_dev_init(struct net_device *dev); 596839fcabaSMichael S. Tsirkin int ipoib_cm_add_mode_attr(struct net_device *dev); 597839fcabaSMichael S. Tsirkin void ipoib_cm_dev_cleanup(struct net_device *dev); 598839fcabaSMichael S. Tsirkin struct ipoib_cm_tx *ipoib_cm_create_tx(struct net_device *dev, struct ipoib_path *path, 599839fcabaSMichael S. Tsirkin struct ipoib_neigh *neigh); 600839fcabaSMichael S. Tsirkin void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx); 601839fcabaSMichael S. Tsirkin void ipoib_cm_skb_too_long(struct net_device *dev, struct sk_buff *skb, 602839fcabaSMichael S. Tsirkin unsigned int mtu); 603839fcabaSMichael S. Tsirkin void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc); 6041b524963SMichael S. Tsirkin void ipoib_cm_handle_tx_wc(struct net_device *dev, struct ib_wc *wc); 605839fcabaSMichael S. Tsirkin #else 606839fcabaSMichael S. Tsirkin 607839fcabaSMichael S. Tsirkin struct ipoib_cm_tx; 608839fcabaSMichael S. Tsirkin 60968e995a2SPradeep Satyanarayana #define ipoib_max_conn_qp 0 61068e995a2SPradeep Satyanarayana 611839fcabaSMichael S. Tsirkin static inline int ipoib_cm_admin_enabled(struct net_device *dev) 612839fcabaSMichael S. Tsirkin { 613839fcabaSMichael S. Tsirkin return 0; 614839fcabaSMichael S. Tsirkin } 615b63b70d8SShlomo Pongratz static inline int ipoib_cm_enabled(struct net_device *dev, u8 *hwaddr) 616839fcabaSMichael S. Tsirkin 617839fcabaSMichael S. Tsirkin { 618839fcabaSMichael S. Tsirkin return 0; 619839fcabaSMichael S. Tsirkin } 620839fcabaSMichael S. Tsirkin 621839fcabaSMichael S. Tsirkin static inline int ipoib_cm_up(struct ipoib_neigh *neigh) 622839fcabaSMichael S. Tsirkin 623839fcabaSMichael S. Tsirkin { 624839fcabaSMichael S. Tsirkin return 0; 625839fcabaSMichael S. Tsirkin } 626839fcabaSMichael S. Tsirkin 627839fcabaSMichael S. Tsirkin static inline struct ipoib_cm_tx *ipoib_cm_get(struct ipoib_neigh *neigh) 628839fcabaSMichael S. Tsirkin { 629839fcabaSMichael S. Tsirkin return NULL; 630839fcabaSMichael S. Tsirkin } 631839fcabaSMichael S. Tsirkin 632839fcabaSMichael S. Tsirkin static inline void ipoib_cm_set(struct ipoib_neigh *neigh, struct ipoib_cm_tx *tx) 633839fcabaSMichael S. Tsirkin { 634839fcabaSMichael S. Tsirkin } 635839fcabaSMichael S. Tsirkin 63668e995a2SPradeep Satyanarayana static inline int ipoib_cm_has_srq(struct net_device *dev) 63768e995a2SPradeep Satyanarayana { 63868e995a2SPradeep Satyanarayana return 0; 63968e995a2SPradeep Satyanarayana } 64068e995a2SPradeep Satyanarayana 641586a6934SPradeep Satyanarayana static inline unsigned int ipoib_cm_max_mtu(struct net_device *dev) 642586a6934SPradeep Satyanarayana { 643586a6934SPradeep Satyanarayana return 0; 644586a6934SPradeep Satyanarayana } 645586a6934SPradeep Satyanarayana 646839fcabaSMichael S. Tsirkin static inline 647839fcabaSMichael S. Tsirkin void ipoib_cm_send(struct net_device *dev, struct sk_buff *skb, struct ipoib_cm_tx *tx) 648839fcabaSMichael S. Tsirkin { 649839fcabaSMichael S. Tsirkin return; 650839fcabaSMichael S. Tsirkin } 651839fcabaSMichael S. Tsirkin 652839fcabaSMichael S. Tsirkin static inline 653839fcabaSMichael S. Tsirkin int ipoib_cm_dev_open(struct net_device *dev) 654839fcabaSMichael S. Tsirkin { 655839fcabaSMichael S. Tsirkin return 0; 656839fcabaSMichael S. Tsirkin } 657839fcabaSMichael S. Tsirkin 658839fcabaSMichael S. Tsirkin static inline 659839fcabaSMichael S. Tsirkin void ipoib_cm_dev_stop(struct net_device *dev) 660839fcabaSMichael S. Tsirkin { 661839fcabaSMichael S. Tsirkin return; 662839fcabaSMichael S. Tsirkin } 663839fcabaSMichael S. Tsirkin 664839fcabaSMichael S. Tsirkin static inline 665839fcabaSMichael S. Tsirkin int ipoib_cm_dev_init(struct net_device *dev) 666839fcabaSMichael S. Tsirkin { 667839fcabaSMichael S. Tsirkin return -ENOSYS; 668839fcabaSMichael S. Tsirkin } 669839fcabaSMichael S. Tsirkin 670839fcabaSMichael S. Tsirkin static inline 671839fcabaSMichael S. Tsirkin void ipoib_cm_dev_cleanup(struct net_device *dev) 672839fcabaSMichael S. Tsirkin { 673839fcabaSMichael S. Tsirkin return; 674839fcabaSMichael S. Tsirkin } 675839fcabaSMichael S. Tsirkin 676839fcabaSMichael S. Tsirkin static inline 677839fcabaSMichael S. Tsirkin struct ipoib_cm_tx *ipoib_cm_create_tx(struct net_device *dev, struct ipoib_path *path, 678839fcabaSMichael S. Tsirkin struct ipoib_neigh *neigh) 679839fcabaSMichael S. Tsirkin { 680839fcabaSMichael S. Tsirkin return NULL; 681839fcabaSMichael S. Tsirkin } 682839fcabaSMichael S. Tsirkin 683839fcabaSMichael S. Tsirkin static inline 684839fcabaSMichael S. Tsirkin void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx) 685839fcabaSMichael S. Tsirkin { 686839fcabaSMichael S. Tsirkin return; 687839fcabaSMichael S. Tsirkin } 688839fcabaSMichael S. Tsirkin 689839fcabaSMichael S. Tsirkin static inline 690839fcabaSMichael S. Tsirkin int ipoib_cm_add_mode_attr(struct net_device *dev) 691839fcabaSMichael S. Tsirkin { 692839fcabaSMichael S. Tsirkin return 0; 693839fcabaSMichael S. Tsirkin } 694839fcabaSMichael S. Tsirkin 695839fcabaSMichael S. Tsirkin static inline void ipoib_cm_skb_too_long(struct net_device *dev, struct sk_buff *skb, 696839fcabaSMichael S. Tsirkin unsigned int mtu) 697839fcabaSMichael S. Tsirkin { 698839fcabaSMichael S. Tsirkin dev_kfree_skb_any(skb); 699839fcabaSMichael S. Tsirkin } 700839fcabaSMichael S. Tsirkin 701839fcabaSMichael S. Tsirkin static inline void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc) 702839fcabaSMichael S. Tsirkin { 703839fcabaSMichael S. Tsirkin } 704839fcabaSMichael S. Tsirkin 7051b524963SMichael S. Tsirkin static inline void ipoib_cm_handle_tx_wc(struct net_device *dev, struct ib_wc *wc) 7061b524963SMichael S. Tsirkin { 7071b524963SMichael S. Tsirkin } 708839fcabaSMichael S. Tsirkin #endif 709839fcabaSMichael S. Tsirkin 7101da177e4SLinus Torvalds #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG 7111732b0efSRoland Dreier void ipoib_create_debug_files(struct net_device *dev); 7121732b0efSRoland Dreier void ipoib_delete_debug_files(struct net_device *dev); 7131da177e4SLinus Torvalds int ipoib_register_debugfs(void); 7141da177e4SLinus Torvalds void ipoib_unregister_debugfs(void); 7151da177e4SLinus Torvalds #else 7161732b0efSRoland Dreier static inline void ipoib_create_debug_files(struct net_device *dev) { } 7171732b0efSRoland Dreier static inline void ipoib_delete_debug_files(struct net_device *dev) { } 7181da177e4SLinus Torvalds static inline int ipoib_register_debugfs(void) { return 0; } 7191da177e4SLinus Torvalds static inline void ipoib_unregister_debugfs(void) { } 7201da177e4SLinus Torvalds #endif 7211da177e4SLinus Torvalds 7221da177e4SLinus Torvalds #define ipoib_printk(level, priv, format, arg...) \ 7231da177e4SLinus Torvalds printk(level "%s: " format, ((struct ipoib_dev_priv *) priv)->dev->name , ## arg) 7241da177e4SLinus Torvalds #define ipoib_warn(priv, format, arg...) \ 7251da177e4SLinus Torvalds ipoib_printk(KERN_WARNING, priv, format , ## arg) 7261da177e4SLinus Torvalds 7270f485251SShirley Ma extern int ipoib_sendq_size; 7280f485251SShirley Ma extern int ipoib_recvq_size; 7291da177e4SLinus Torvalds 730c1a0b23bSMichael S. Tsirkin extern struct ib_sa_client ipoib_sa_client; 731c1a0b23bSMichael S. Tsirkin 7321da177e4SLinus Torvalds #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG 7331da177e4SLinus Torvalds extern int ipoib_debug_level; 7341da177e4SLinus Torvalds 7351da177e4SLinus Torvalds #define ipoib_dbg(priv, format, arg...) \ 7361da177e4SLinus Torvalds do { \ 7371da177e4SLinus Torvalds if (ipoib_debug_level > 0) \ 7381da177e4SLinus Torvalds ipoib_printk(KERN_DEBUG, priv, format , ## arg); \ 7391da177e4SLinus Torvalds } while (0) 7401da177e4SLinus Torvalds #define ipoib_dbg_mcast(priv, format, arg...) \ 7411da177e4SLinus Torvalds do { \ 7421da177e4SLinus Torvalds if (mcast_debug_level > 0) \ 7431da177e4SLinus Torvalds ipoib_printk(KERN_DEBUG, priv, format , ## arg); \ 7441da177e4SLinus Torvalds } while (0) 7451da177e4SLinus Torvalds #else /* CONFIG_INFINIBAND_IPOIB_DEBUG */ 7461da177e4SLinus Torvalds #define ipoib_dbg(priv, format, arg...) \ 7471da177e4SLinus Torvalds do { (void) (priv); } while (0) 7481da177e4SLinus Torvalds #define ipoib_dbg_mcast(priv, format, arg...) \ 7491da177e4SLinus Torvalds do { (void) (priv); } while (0) 7501da177e4SLinus Torvalds #endif /* CONFIG_INFINIBAND_IPOIB_DEBUG */ 7511da177e4SLinus Torvalds 7521da177e4SLinus Torvalds #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG_DATA 7531da177e4SLinus Torvalds #define ipoib_dbg_data(priv, format, arg...) \ 7541da177e4SLinus Torvalds do { \ 7551da177e4SLinus Torvalds if (data_debug_level > 0) \ 7561da177e4SLinus Torvalds ipoib_printk(KERN_DEBUG, priv, format , ## arg); \ 7571da177e4SLinus Torvalds } while (0) 7581da177e4SLinus Torvalds #else /* CONFIG_INFINIBAND_IPOIB_DEBUG_DATA */ 7591da177e4SLinus Torvalds #define ipoib_dbg_data(priv, format, arg...) \ 7601da177e4SLinus Torvalds do { (void) (priv); } while (0) 7611da177e4SLinus Torvalds #endif /* CONFIG_INFINIBAND_IPOIB_DEBUG_DATA */ 7621da177e4SLinus Torvalds 763839fcabaSMichael S. Tsirkin #define IPOIB_QPN(ha) (be32_to_cpup((__be32 *) ha) & 0xffffff) 764839fcabaSMichael S. Tsirkin 7651da177e4SLinus Torvalds #endif /* _IPOIB_H */ 766