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, 832866196fSDoug Ledford IPOIB_MAX_MCAST_QUEUE = 64, 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_FLAG_SUBINTERFACE = 5, 907a343d4cSLeonid Arsh IPOIB_STOP_REAPER = 7, 911b524963SMichael S. Tsirkin IPOIB_FLAG_ADMIN_CM = 9, 921b524963SMichael S. Tsirkin IPOIB_FLAG_UMCAST = 10, 93b63b70d8SShlomo Pongratz IPOIB_STOP_NEIGH_GC = 11, 94b63b70d8SShlomo Pongratz IPOIB_NEIGH_TBL_FLUSH = 12, 951da177e4SLinus Torvalds 961da177e4SLinus Torvalds IPOIB_MAX_BACKOFF_SECONDS = 16, 971da177e4SLinus Torvalds 981da177e4SLinus Torvalds IPOIB_MCAST_FLAG_FOUND = 0, /* used in set_multicast_list */ 991da177e4SLinus Torvalds IPOIB_MCAST_FLAG_SENDONLY = 1, 10069911416SDoug Ledford /* 10169911416SDoug Ledford * For IPOIB_MCAST_FLAG_BUSY 10269911416SDoug Ledford * When set, in flight join and mcast->mc is unreliable 10369911416SDoug Ledford * When clear and mcast->mc IS_ERR_OR_NULL, need to restart or 10469911416SDoug Ledford * haven't started yet 10569911416SDoug Ledford * When clear and mcast->mc is valid pointer, join was successful 10669911416SDoug Ledford */ 10769911416SDoug Ledford IPOIB_MCAST_FLAG_BUSY = 2, 1081da177e4SLinus Torvalds IPOIB_MCAST_FLAG_ATTACHED = 3, 109f56bcd80SEli Cohen 110f56bcd80SEli Cohen MAX_SEND_CQE = 16, 111f89271daSEli Cohen IPOIB_CM_COPYBREAK = 256, 1129baa0b03SOr Gerlitz 1139baa0b03SOr Gerlitz IPOIB_NON_CHILD = 0, 1149baa0b03SOr Gerlitz IPOIB_LEGACY_CHILD = 1, 1159baa0b03SOr Gerlitz IPOIB_RTNL_CHILD = 2, 1161da177e4SLinus Torvalds }; 1171da177e4SLinus Torvalds 118839fcabaSMichael S. Tsirkin #define IPOIB_OP_RECV (1ul << 31) 119839fcabaSMichael S. Tsirkin #ifdef CONFIG_INFINIBAND_IPOIB_CM 1201b524963SMichael S. Tsirkin #define IPOIB_OP_CM (1ul << 30) 121839fcabaSMichael S. Tsirkin #else 1221b524963SMichael S. Tsirkin #define IPOIB_OP_CM (0) 123839fcabaSMichael S. Tsirkin #endif 124839fcabaSMichael S. Tsirkin 1259d1ad66eSShlomo Pongratz #define IPOIB_QPN_MASK ((__force u32) cpu_to_be32(0xFFFFFF)) 1269d1ad66eSShlomo Pongratz 1271da177e4SLinus Torvalds /* structs */ 1281da177e4SLinus Torvalds 1291da177e4SLinus Torvalds struct ipoib_header { 13097f52eb4SSean Hefty __be16 proto; 1311da177e4SLinus Torvalds u16 reserved; 1321da177e4SLinus Torvalds }; 1331da177e4SLinus Torvalds 134936d7de3SRoland Dreier struct ipoib_cb { 135936d7de3SRoland Dreier struct qdisc_skb_cb qdisc_cb; 1361da177e4SLinus Torvalds u8 hwaddr[INFINIBAND_ALEN]; 1371da177e4SLinus Torvalds }; 1381da177e4SLinus Torvalds 139b49fe362SEric Dumazet static inline struct ipoib_cb *ipoib_skb_cb(const struct sk_buff *skb) 140b49fe362SEric Dumazet { 141b49fe362SEric Dumazet BUILD_BUG_ON(sizeof(skb->cb) < sizeof(struct ipoib_cb)); 142b49fe362SEric Dumazet return (struct ipoib_cb *)skb->cb; 143b49fe362SEric Dumazet } 144b49fe362SEric Dumazet 14581668838SSean Hefty /* Used for all multicast joins (broadcast, IPv4 mcast and IPv6 mcast) */ 14681668838SSean Hefty struct ipoib_mcast { 14781668838SSean Hefty struct ib_sa_mcmember_rec mcmember; 14881668838SSean Hefty struct ib_sa_multicast *mc; 14981668838SSean Hefty struct ipoib_ah *ah; 15081668838SSean Hefty 15181668838SSean Hefty struct rb_node rb_node; 15281668838SSean Hefty struct list_head list; 15381668838SSean Hefty 15481668838SSean Hefty unsigned long created; 15581668838SSean Hefty unsigned long backoff; 15669911416SDoug Ledford unsigned long delay_until; 15781668838SSean Hefty 15881668838SSean Hefty unsigned long flags; 15981668838SSean Hefty unsigned char logcount; 16081668838SSean Hefty 16181668838SSean Hefty struct list_head neigh_list; 16281668838SSean Hefty 16381668838SSean Hefty struct sk_buff_head pkt_queue; 16481668838SSean Hefty 16581668838SSean Hefty struct net_device *dev; 166a9c8ba58SErez Shitrit struct completion done; 16781668838SSean Hefty }; 1681da177e4SLinus Torvalds 1691993d683SRoland Dreier struct ipoib_rx_buf { 1701993d683SRoland Dreier struct sk_buff *skb; 171bc7b3a36SShirley Ma u64 mapping[IPOIB_UD_RX_SG]; 1721993d683SRoland Dreier }; 1731993d683SRoland Dreier 1741993d683SRoland Dreier struct ipoib_tx_buf { 1751da177e4SLinus Torvalds struct sk_buff *skb; 1767143740dSEli Cohen u64 mapping[MAX_SKB_FRAGS + 1]; 1771da177e4SLinus Torvalds }; 1781da177e4SLinus Torvalds 179e112373fSEli Cohen struct ipoib_cm_tx_buf { 180e112373fSEli Cohen struct sk_buff *skb; 181e112373fSEli Cohen u64 mapping; 182e112373fSEli Cohen }; 183e112373fSEli Cohen 184839fcabaSMichael S. Tsirkin struct ib_cm_id; 185839fcabaSMichael S. Tsirkin 186839fcabaSMichael S. Tsirkin struct ipoib_cm_data { 187839fcabaSMichael S. Tsirkin __be32 qpn; /* High byte MUST be ignored on receive */ 188839fcabaSMichael S. Tsirkin __be32 mtu; 189839fcabaSMichael S. Tsirkin }; 190839fcabaSMichael S. Tsirkin 191518b1646SMichael S. Tsirkin /* 192518b1646SMichael S. Tsirkin * Quoting 10.3.1 Queue Pair and EE Context States: 193518b1646SMichael S. Tsirkin * 194518b1646SMichael S. Tsirkin * Note, for QPs that are associated with an SRQ, the Consumer should take the 195518b1646SMichael S. Tsirkin * QP through the Error State before invoking a Destroy QP or a Modify QP to the 196518b1646SMichael S. Tsirkin * Reset State. The Consumer may invoke the Destroy QP without first performing 197518b1646SMichael S. Tsirkin * a Modify QP to the Error State and waiting for the Affiliated Asynchronous 198518b1646SMichael S. Tsirkin * Last WQE Reached Event. However, if the Consumer does not wait for the 199518b1646SMichael S. Tsirkin * Affiliated Asynchronous Last WQE Reached Event, then WQE and Data Segment 200518b1646SMichael S. Tsirkin * leakage may occur. Therefore, it is good programming practice to tear down a 201518b1646SMichael S. Tsirkin * QP that is associated with an SRQ by using the following process: 202518b1646SMichael S. Tsirkin * 203518b1646SMichael S. Tsirkin * - Put the QP in the Error State 204518b1646SMichael S. Tsirkin * - Wait for the Affiliated Asynchronous Last WQE Reached Event; 205518b1646SMichael S. Tsirkin * - either: 206518b1646SMichael S. Tsirkin * drain the CQ by invoking the Poll CQ verb and either wait for CQ 207518b1646SMichael S. Tsirkin * to be empty or the number of Poll CQ operations has exceeded 208518b1646SMichael S. Tsirkin * CQ capacity size; 209518b1646SMichael S. Tsirkin * - or 210518b1646SMichael S. Tsirkin * post another WR that completes on the same CQ and wait for this 211518b1646SMichael S. Tsirkin * WR to return as a WC; 212518b1646SMichael S. Tsirkin * - and then invoke a Destroy QP or Reset QP. 213518b1646SMichael S. Tsirkin * 214518b1646SMichael S. Tsirkin * We use the second option and wait for a completion on the 215ec56dc0bSMichael S. Tsirkin * same CQ before destroying QPs attached to our SRQ. 216518b1646SMichael S. Tsirkin */ 217518b1646SMichael S. Tsirkin 218518b1646SMichael S. Tsirkin enum ipoib_cm_state { 219518b1646SMichael S. Tsirkin IPOIB_CM_RX_LIVE, 220518b1646SMichael S. Tsirkin IPOIB_CM_RX_ERROR, /* Ignored by stale task */ 221518b1646SMichael S. Tsirkin IPOIB_CM_RX_FLUSH /* Last WQE Reached event observed */ 222518b1646SMichael S. Tsirkin }; 223518b1646SMichael S. Tsirkin 224839fcabaSMichael S. Tsirkin struct ipoib_cm_rx { 225839fcabaSMichael S. Tsirkin struct ib_cm_id *id; 226839fcabaSMichael S. Tsirkin struct ib_qp *qp; 22768e995a2SPradeep Satyanarayana struct ipoib_cm_rx_buf *rx_ring; 228839fcabaSMichael S. Tsirkin struct list_head list; 229839fcabaSMichael S. Tsirkin struct net_device *dev; 230839fcabaSMichael S. Tsirkin unsigned long jiffies; 231518b1646SMichael S. Tsirkin enum ipoib_cm_state state; 23268e995a2SPradeep Satyanarayana int recv_count; 233839fcabaSMichael S. Tsirkin }; 234839fcabaSMichael S. Tsirkin 235839fcabaSMichael S. Tsirkin struct ipoib_cm_tx { 236839fcabaSMichael S. Tsirkin struct ib_cm_id *id; 237839fcabaSMichael S. Tsirkin struct ib_qp *qp; 238839fcabaSMichael S. Tsirkin struct list_head list; 239839fcabaSMichael S. Tsirkin struct net_device *dev; 240839fcabaSMichael S. Tsirkin struct ipoib_neigh *neigh; 241839fcabaSMichael S. Tsirkin struct ipoib_path *path; 242c4268778SYuval Shaia struct ipoib_tx_buf *tx_ring; 243839fcabaSMichael S. Tsirkin unsigned tx_head; 244839fcabaSMichael S. Tsirkin unsigned tx_tail; 245839fcabaSMichael S. Tsirkin unsigned long flags; 246839fcabaSMichael S. Tsirkin u32 mtu; 247839fcabaSMichael S. Tsirkin }; 248839fcabaSMichael S. Tsirkin 249839fcabaSMichael S. Tsirkin struct ipoib_cm_rx_buf { 250839fcabaSMichael S. Tsirkin struct sk_buff *skb; 251839fcabaSMichael S. Tsirkin u64 mapping[IPOIB_CM_RX_SG]; 252839fcabaSMichael S. Tsirkin }; 253839fcabaSMichael S. Tsirkin 254839fcabaSMichael S. Tsirkin struct ipoib_cm_dev_priv { 255839fcabaSMichael S. Tsirkin struct ib_srq *srq; 256839fcabaSMichael S. Tsirkin struct ipoib_cm_rx_buf *srq_ring; 257839fcabaSMichael S. Tsirkin struct ib_cm_id *id; 258518b1646SMichael S. Tsirkin struct list_head passive_ids; /* state: LIVE */ 259518b1646SMichael S. Tsirkin struct list_head rx_error_list; /* state: ERROR */ 260518b1646SMichael S. Tsirkin struct list_head rx_flush_list; /* state: FLUSH, drain not started */ 261518b1646SMichael S. Tsirkin struct list_head rx_drain_list; /* state: FLUSH, drain started */ 262518b1646SMichael S. Tsirkin struct list_head rx_reap_list; /* state: FLUSH, drain done */ 263839fcabaSMichael S. Tsirkin struct work_struct start_task; 264839fcabaSMichael S. Tsirkin struct work_struct reap_task; 265839fcabaSMichael S. Tsirkin struct work_struct skb_task; 266518b1646SMichael S. Tsirkin struct work_struct rx_reap_task; 267839fcabaSMichael S. Tsirkin struct delayed_work stale_task; 268839fcabaSMichael S. Tsirkin struct sk_buff_head skb_queue; 269839fcabaSMichael S. Tsirkin struct list_head start_list; 270839fcabaSMichael S. Tsirkin struct list_head reap_list; 271839fcabaSMichael S. Tsirkin struct ib_wc ibwc[IPOIB_NUM_WC]; 272839fcabaSMichael S. Tsirkin struct ib_sge rx_sge[IPOIB_CM_RX_SG]; 273839fcabaSMichael S. Tsirkin struct ib_recv_wr rx_wr; 27468e995a2SPradeep Satyanarayana int nonsrq_conn_qp; 275586a6934SPradeep Satyanarayana int max_cm_mtu; 276586a6934SPradeep Satyanarayana int num_frags; 277839fcabaSMichael S. Tsirkin }; 278839fcabaSMichael S. Tsirkin 27928d52b3cSEli Cohen struct ipoib_ethtool_st { 28028d52b3cSEli Cohen u16 coalesce_usecs; 28128d52b3cSEli Cohen u16 max_coalesced_frames; 28228d52b3cSEli Cohen }; 28328d52b3cSEli Cohen 28466172c09SShlomo Pongratz struct ipoib_neigh_table; 28566172c09SShlomo Pongratz 286b63b70d8SShlomo Pongratz struct ipoib_neigh_hash { 28766172c09SShlomo Pongratz struct ipoib_neigh_table *ntbl; 288b63b70d8SShlomo Pongratz struct ipoib_neigh __rcu **buckets; 289b63b70d8SShlomo Pongratz struct rcu_head rcu; 290b63b70d8SShlomo Pongratz u32 mask; 291b63b70d8SShlomo Pongratz u32 size; 292b63b70d8SShlomo Pongratz }; 293b63b70d8SShlomo Pongratz 294b63b70d8SShlomo Pongratz struct ipoib_neigh_table { 295b63b70d8SShlomo Pongratz struct ipoib_neigh_hash __rcu *htbl; 296b63b70d8SShlomo Pongratz atomic_t entries; 297b63b70d8SShlomo Pongratz struct completion flushed; 29866172c09SShlomo Pongratz struct completion deleted; 299b63b70d8SShlomo Pongratz }; 300b63b70d8SShlomo Pongratz 3012c010730SErez Shitrit struct ipoib_qp_state_validate { 3022c010730SErez Shitrit struct work_struct work; 3032c010730SErez Shitrit struct ipoib_dev_priv *priv; 3042c010730SErez Shitrit }; 3052c010730SErez Shitrit 3061da177e4SLinus Torvalds /* 307943c246eSRoland Dreier * Device private locking: network stack tx_lock protects members used 308943c246eSRoland Dreier * in TX fast path, lock protects everything else. lock nests inside 309943c246eSRoland Dreier * of tx_lock (ie tx_lock must be acquired first if needed). 3101da177e4SLinus Torvalds */ 3111da177e4SLinus Torvalds struct ipoib_dev_priv { 3121da177e4SLinus Torvalds spinlock_t lock; 3131da177e4SLinus Torvalds 3141da177e4SLinus Torvalds struct net_device *dev; 3151da177e4SLinus Torvalds 316bea3348eSStephen Hemminger struct napi_struct napi; 317bea3348eSStephen Hemminger 3181da177e4SLinus Torvalds unsigned long flags; 3191da177e4SLinus Torvalds 320f47944ccSErez Shitrit struct rw_semaphore vlan_rwsem; 3211da177e4SLinus Torvalds 3221da177e4SLinus Torvalds struct rb_root path_tree; 3231da177e4SLinus Torvalds struct list_head path_list; 3241da177e4SLinus Torvalds 325b63b70d8SShlomo Pongratz struct ipoib_neigh_table ntbl; 326b63b70d8SShlomo Pongratz 3271da177e4SLinus Torvalds struct ipoib_mcast *broadcast; 3281da177e4SLinus Torvalds struct list_head multicast_list; 3291da177e4SLinus Torvalds struct rb_root multicast_tree; 3301da177e4SLinus Torvalds 3310b39578bSDoug Ledford struct workqueue_struct *wq; 332c4028958SDavid Howells struct delayed_work mcast_task; 333e8224e4bSYossi Etigin struct work_struct carrier_on_task; 334ee1e2c82SMoni Shoua struct work_struct flush_light; 335ee1e2c82SMoni Shoua struct work_struct flush_normal; 336ee1e2c82SMoni Shoua struct work_struct flush_heavy; 3371da177e4SLinus Torvalds struct work_struct restart_task; 338c4028958SDavid Howells struct delayed_work ah_reap_task; 339b63b70d8SShlomo Pongratz struct delayed_work neigh_reap_task; 3401da177e4SLinus Torvalds struct ib_device *ca; 3411da177e4SLinus Torvalds u8 port; 3421da177e4SLinus Torvalds u16 pkey; 34326bbf13cSYosef Etigin u16 pkey_index; 3441da177e4SLinus Torvalds struct ib_pd *pd; 345f56bcd80SEli Cohen struct ib_cq *recv_cq; 346f56bcd80SEli Cohen struct ib_cq *send_cq; 3471da177e4SLinus Torvalds struct ib_qp *qp; 3481da177e4SLinus Torvalds u32 qkey; 3491da177e4SLinus Torvalds 3501da177e4SLinus Torvalds union ib_gid local_gid; 3511da177e4SLinus Torvalds u16 local_lid; 3521da177e4SLinus Torvalds 3531da177e4SLinus Torvalds unsigned int admin_mtu; 3541da177e4SLinus Torvalds unsigned int mcast_mtu; 355bc7b3a36SShirley Ma unsigned int max_ib_mtu; 3561da177e4SLinus Torvalds 3571993d683SRoland Dreier struct ipoib_rx_buf *rx_ring; 3581da177e4SLinus Torvalds 3591993d683SRoland Dreier struct ipoib_tx_buf *tx_ring; 3601da177e4SLinus Torvalds unsigned tx_head; 3611da177e4SLinus Torvalds unsigned tx_tail; 3627143740dSEli Cohen struct ib_sge tx_sge[MAX_SKB_FRAGS + 1]; 363e622f2f4SChristoph Hellwig struct ib_ud_wr tx_wr; 3641b524963SMichael S. Tsirkin unsigned tx_outstanding; 365f56bcd80SEli Cohen struct ib_wc send_wc[MAX_SEND_CQE]; 3661da177e4SLinus Torvalds 367bc7b3a36SShirley Ma struct ib_recv_wr rx_wr; 368bc7b3a36SShirley Ma struct ib_sge rx_sge[IPOIB_UD_RX_SG]; 369bc7b3a36SShirley Ma 3701da177e4SLinus Torvalds struct ib_wc ibwc[IPOIB_NUM_WC]; 3711da177e4SLinus Torvalds 3721da177e4SLinus Torvalds struct list_head dead_ahs; 3731da177e4SLinus Torvalds 3741da177e4SLinus Torvalds struct ib_event_handler event_handler; 3751da177e4SLinus Torvalds 3761da177e4SLinus Torvalds struct net_device *parent; 3771da177e4SLinus Torvalds struct list_head child_intfs; 3781da177e4SLinus Torvalds struct list_head list; 3799baa0b03SOr Gerlitz int child_type; 3801da177e4SLinus Torvalds 381839fcabaSMichael S. Tsirkin #ifdef CONFIG_INFINIBAND_IPOIB_CM 382839fcabaSMichael S. Tsirkin struct ipoib_cm_dev_priv cm; 383839fcabaSMichael S. Tsirkin #endif 384839fcabaSMichael S. Tsirkin 3851da177e4SLinus Torvalds #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG 3861da177e4SLinus Torvalds struct list_head fs_list; 3871da177e4SLinus Torvalds struct dentry *mcg_dentry; 3881732b0efSRoland Dreier struct dentry *path_dentry; 3891da177e4SLinus Torvalds #endif 39040ca1988SEli Cohen int hca_caps; 39128d52b3cSEli Cohen struct ipoib_ethtool_st ethtool; 39257ce41d1SEli Cohen struct timer_list poll_timer; 3931da177e4SLinus Torvalds }; 3941da177e4SLinus Torvalds 3951da177e4SLinus Torvalds struct ipoib_ah { 3961da177e4SLinus Torvalds struct net_device *dev; 3971da177e4SLinus Torvalds struct ib_ah *ah; 3981da177e4SLinus Torvalds struct list_head list; 3991da177e4SLinus Torvalds struct kref ref; 4001da177e4SLinus Torvalds unsigned last_send; 4011da177e4SLinus Torvalds }; 4021da177e4SLinus Torvalds 4031da177e4SLinus Torvalds struct ipoib_path { 4041da177e4SLinus Torvalds struct net_device *dev; 4051da177e4SLinus Torvalds struct ib_sa_path_rec pathrec; 4061da177e4SLinus Torvalds struct ipoib_ah *ah; 4071da177e4SLinus Torvalds struct sk_buff_head queue; 4081da177e4SLinus Torvalds 4091da177e4SLinus Torvalds struct list_head neigh_list; 4101da177e4SLinus Torvalds 4111da177e4SLinus Torvalds int query_id; 4121da177e4SLinus Torvalds struct ib_sa_query *query; 4131da177e4SLinus Torvalds struct completion done; 4141da177e4SLinus Torvalds 4151da177e4SLinus Torvalds struct rb_node rb_node; 4161da177e4SLinus Torvalds struct list_head list; 417ee1e2c82SMoni Shoua int valid; 4181da177e4SLinus Torvalds }; 4191da177e4SLinus Torvalds 4201da177e4SLinus Torvalds struct ipoib_neigh { 4211da177e4SLinus Torvalds struct ipoib_ah *ah; 422839fcabaSMichael S. Tsirkin #ifdef CONFIG_INFINIBAND_IPOIB_CM 423839fcabaSMichael S. Tsirkin struct ipoib_cm_tx *cm; 424839fcabaSMichael S. Tsirkin #endif 425b63b70d8SShlomo Pongratz u8 daddr[INFINIBAND_ALEN]; 4261da177e4SLinus Torvalds struct sk_buff_head queue; 4271da177e4SLinus Torvalds 428732a2170SMoni Shoua struct net_device *dev; 4291da177e4SLinus Torvalds 4301da177e4SLinus Torvalds struct list_head list; 431b63b70d8SShlomo Pongratz struct ipoib_neigh __rcu *hnext; 432b63b70d8SShlomo Pongratz struct rcu_head rcu; 433b63b70d8SShlomo Pongratz atomic_t refcnt; 434b63b70d8SShlomo Pongratz unsigned long alive; 4351da177e4SLinus Torvalds }; 4361da177e4SLinus Torvalds 437bc7b3a36SShirley Ma #define IPOIB_UD_MTU(ib_mtu) (ib_mtu - IPOIB_ENCAP_LEN) 438bc7b3a36SShirley Ma #define IPOIB_UD_BUF_SIZE(ib_mtu) (ib_mtu + IB_GRH_BYTES) 439bc7b3a36SShirley Ma 440b63b70d8SShlomo Pongratz void ipoib_neigh_dtor(struct ipoib_neigh *neigh); 441b63b70d8SShlomo Pongratz static inline void ipoib_neigh_put(struct ipoib_neigh *neigh) 4421da177e4SLinus Torvalds { 443b63b70d8SShlomo Pongratz if (atomic_dec_and_test(&neigh->refcnt)) 444b63b70d8SShlomo Pongratz ipoib_neigh_dtor(neigh); 4451da177e4SLinus Torvalds } 446b63b70d8SShlomo Pongratz struct ipoib_neigh *ipoib_neigh_get(struct net_device *dev, u8 *daddr); 447b63b70d8SShlomo Pongratz struct ipoib_neigh *ipoib_neigh_alloc(u8 *daddr, 448732a2170SMoni Shoua struct net_device *dev); 449b63b70d8SShlomo Pongratz void ipoib_neigh_free(struct ipoib_neigh *neigh); 450b63b70d8SShlomo Pongratz void ipoib_del_neighs_by_gid(struct net_device *dev, u8 *gid); 451d2e0655eSMichael S. Tsirkin 4521da177e4SLinus Torvalds extern struct workqueue_struct *ipoib_workqueue; 4531da177e4SLinus Torvalds 4541da177e4SLinus Torvalds /* functions */ 4551da177e4SLinus Torvalds 456bea3348eSStephen Hemminger int ipoib_poll(struct napi_struct *napi, int budget); 4571da177e4SLinus Torvalds void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr); 45857ce41d1SEli Cohen void ipoib_send_comp_handler(struct ib_cq *cq, void *dev_ptr); 4591da177e4SLinus Torvalds 4601da177e4SLinus Torvalds struct ipoib_ah *ipoib_create_ah(struct net_device *dev, 4611da177e4SLinus Torvalds struct ib_pd *pd, struct ib_ah_attr *attr); 4621da177e4SLinus Torvalds void ipoib_free_ah(struct kref *kref); 4631da177e4SLinus Torvalds static inline void ipoib_put_ah(struct ipoib_ah *ah) 4641da177e4SLinus Torvalds { 4651da177e4SLinus Torvalds kref_put(&ah->ref, ipoib_free_ah); 4661da177e4SLinus Torvalds } 4678ae5a8a2SRoland Dreier int ipoib_open(struct net_device *dev); 4681da177e4SLinus Torvalds int ipoib_add_pkey_attr(struct net_device *dev); 469335a64a5SOr Gerlitz int ipoib_add_umcast_attr(struct net_device *dev); 4701da177e4SLinus Torvalds 4711da177e4SLinus Torvalds void ipoib_send(struct net_device *dev, struct sk_buff *skb, 4721da177e4SLinus Torvalds struct ipoib_ah *address, u32 qpn); 473c4028958SDavid Howells void ipoib_reap_ah(struct work_struct *work); 4741da177e4SLinus Torvalds 475ee1e2c82SMoni Shoua void ipoib_mark_paths_invalid(struct net_device *dev); 4761da177e4SLinus Torvalds void ipoib_flush_paths(struct net_device *dev); 4771da177e4SLinus Torvalds struct ipoib_dev_priv *ipoib_intf_alloc(const char *format); 4781da177e4SLinus Torvalds 4791da177e4SLinus Torvalds int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port); 480ee1e2c82SMoni Shoua void ipoib_ib_dev_flush_light(struct work_struct *work); 481ee1e2c82SMoni Shoua void ipoib_ib_dev_flush_normal(struct work_struct *work); 482ee1e2c82SMoni Shoua void ipoib_ib_dev_flush_heavy(struct work_struct *work); 48326bbf13cSYosef Etigin void ipoib_pkey_event(struct work_struct *work); 4841da177e4SLinus Torvalds void ipoib_ib_dev_cleanup(struct net_device *dev); 4851da177e4SLinus Torvalds 486efc82eeeSDoug Ledford int ipoib_ib_dev_open(struct net_device *dev); 4871da177e4SLinus Torvalds int ipoib_ib_dev_up(struct net_device *dev); 488efc82eeeSDoug Ledford int ipoib_ib_dev_down(struct net_device *dev); 489efc82eeeSDoug Ledford int ipoib_ib_dev_stop(struct net_device *dev); 490db84f880SErez Shitrit void ipoib_pkey_dev_check_presence(struct net_device *dev); 4911da177e4SLinus Torvalds 4921da177e4SLinus Torvalds int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port); 4931da177e4SLinus Torvalds void ipoib_dev_cleanup(struct net_device *dev); 4941da177e4SLinus Torvalds 495c4028958SDavid Howells void ipoib_mcast_join_task(struct work_struct *work); 496e8224e4bSYossi Etigin void ipoib_mcast_carrier_on_task(struct work_struct *work); 497b63b70d8SShlomo Pongratz void ipoib_mcast_send(struct net_device *dev, u8 *daddr, struct sk_buff *skb); 4981da177e4SLinus Torvalds 499c4028958SDavid Howells void ipoib_mcast_restart_task(struct work_struct *work); 5001da177e4SLinus Torvalds int ipoib_mcast_start_thread(struct net_device *dev); 501efc82eeeSDoug Ledford int ipoib_mcast_stop_thread(struct net_device *dev); 5021da177e4SLinus Torvalds 5031da177e4SLinus Torvalds void ipoib_mcast_dev_down(struct net_device *dev); 5041da177e4SLinus Torvalds void ipoib_mcast_dev_flush(struct net_device *dev); 5051da177e4SLinus Torvalds 506c4268778SYuval Shaia int ipoib_dma_map_tx(struct ib_device *ca, struct ipoib_tx_buf *tx_req); 507c4268778SYuval Shaia void ipoib_dma_unmap_tx(struct ipoib_dev_priv *priv, 508c4268778SYuval Shaia struct ipoib_tx_buf *tx_req); 509c4268778SYuval Shaia 510c4268778SYuval Shaia static inline void ipoib_build_sge(struct ipoib_dev_priv *priv, 511c4268778SYuval Shaia struct ipoib_tx_buf *tx_req) 512c4268778SYuval Shaia { 513c4268778SYuval Shaia int i, off; 514c4268778SYuval Shaia struct sk_buff *skb = tx_req->skb; 515c4268778SYuval Shaia skb_frag_t *frags = skb_shinfo(skb)->frags; 516c4268778SYuval Shaia int nr_frags = skb_shinfo(skb)->nr_frags; 517c4268778SYuval Shaia u64 *mapping = tx_req->mapping; 518c4268778SYuval Shaia 519c4268778SYuval Shaia if (skb_headlen(skb)) { 520c4268778SYuval Shaia priv->tx_sge[0].addr = mapping[0]; 521c4268778SYuval Shaia priv->tx_sge[0].length = skb_headlen(skb); 522c4268778SYuval Shaia off = 1; 523c4268778SYuval Shaia } else 524c4268778SYuval Shaia off = 0; 525c4268778SYuval Shaia 526c4268778SYuval Shaia for (i = 0; i < nr_frags; ++i) { 527c4268778SYuval Shaia priv->tx_sge[i + off].addr = mapping[i + off]; 528c4268778SYuval Shaia priv->tx_sge[i + off].length = skb_frag_size(&frags[i]); 529c4268778SYuval Shaia } 530e622f2f4SChristoph Hellwig priv->tx_wr.wr.num_sge = nr_frags + off; 531c4268778SYuval Shaia } 532c4268778SYuval Shaia 5338ae5a8a2SRoland Dreier #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG 5341da177e4SLinus Torvalds struct ipoib_mcast_iter *ipoib_mcast_iter_init(struct net_device *dev); 5351da177e4SLinus Torvalds int ipoib_mcast_iter_next(struct ipoib_mcast_iter *iter); 5361da177e4SLinus Torvalds void ipoib_mcast_iter_read(struct ipoib_mcast_iter *iter, 5371da177e4SLinus Torvalds union ib_gid *gid, 5381da177e4SLinus Torvalds unsigned long *created, 5391da177e4SLinus Torvalds unsigned int *queuelen, 5401da177e4SLinus Torvalds unsigned int *complete, 5411da177e4SLinus Torvalds unsigned int *send_only); 5421732b0efSRoland Dreier 5431732b0efSRoland Dreier struct ipoib_path_iter *ipoib_path_iter_init(struct net_device *dev); 5441732b0efSRoland Dreier int ipoib_path_iter_next(struct ipoib_path_iter *iter); 5451732b0efSRoland Dreier void ipoib_path_iter_read(struct ipoib_path_iter *iter, 5461732b0efSRoland Dreier struct ipoib_path *path); 5478ae5a8a2SRoland Dreier #endif 5481da177e4SLinus Torvalds 5491da177e4SLinus Torvalds int ipoib_mcast_attach(struct net_device *dev, u16 mlid, 550d0de1362SEli Cohen union ib_gid *mgid, int set_qkey); 551*50be28deSErez Shitrit void ipoib_mcast_remove_list(struct list_head *remove_list); 552432c55ffSChristoph Lameter void ipoib_check_and_add_mcast_sendonly(struct ipoib_dev_priv *priv, u8 *mgid, 553432c55ffSChristoph Lameter struct list_head *remove_list); 5541da177e4SLinus Torvalds 5555b6810e0SRoland Dreier int ipoib_init_qp(struct net_device *dev); 5561da177e4SLinus Torvalds int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca); 5571da177e4SLinus Torvalds void ipoib_transport_dev_cleanup(struct net_device *dev); 5581da177e4SLinus Torvalds 5591da177e4SLinus Torvalds void ipoib_event(struct ib_event_handler *handler, 5601da177e4SLinus Torvalds struct ib_event *record); 5611da177e4SLinus Torvalds 5621da177e4SLinus Torvalds int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey); 5631da177e4SLinus Torvalds int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey); 5641da177e4SLinus Torvalds 5659baa0b03SOr Gerlitz int __ipoib_vlan_add(struct ipoib_dev_priv *ppriv, struct ipoib_dev_priv *priv, 5669baa0b03SOr Gerlitz u16 pkey, int child_type); 5679baa0b03SOr Gerlitz 5689baa0b03SOr Gerlitz int __init ipoib_netlink_init(void); 5699baa0b03SOr Gerlitz void __exit ipoib_netlink_fini(void); 5709baa0b03SOr Gerlitz 571862096a8SOr Gerlitz void ipoib_set_umcast(struct net_device *ndev, int umcast_val); 572862096a8SOr Gerlitz int ipoib_set_mode(struct net_device *dev, const char *buf); 573862096a8SOr Gerlitz 5749baa0b03SOr Gerlitz void ipoib_setup(struct net_device *dev); 5759baa0b03SOr Gerlitz 576db84f880SErez Shitrit void ipoib_pkey_open(struct ipoib_dev_priv *priv); 5772dfbfc37SMichael S. Tsirkin void ipoib_drain_cq(struct net_device *dev); 5781da177e4SLinus Torvalds 57982c24c18SEli Cohen void ipoib_set_ethtool_ops(struct net_device *dev); 58083bb63f6SOr Gerlitz int ipoib_set_dev_features(struct ipoib_dev_priv *priv, struct ib_device *hca); 58182c24c18SEli Cohen 582839fcabaSMichael S. Tsirkin #define IPOIB_FLAGS_RC 0x80 583839fcabaSMichael S. Tsirkin #define IPOIB_FLAGS_UC 0x40 584839fcabaSMichael S. Tsirkin 585839fcabaSMichael S. Tsirkin /* We don't support UC connections at the moment */ 586839fcabaSMichael S. Tsirkin #define IPOIB_CM_SUPPORTED(ha) (ha[0] & (IPOIB_FLAGS_RC)) 587839fcabaSMichael S. Tsirkin 58871d9c5f9SRoland Dreier #ifdef CONFIG_INFINIBAND_IPOIB_CM 58971d9c5f9SRoland Dreier 59068e995a2SPradeep Satyanarayana extern int ipoib_max_conn_qp; 59168e995a2SPradeep Satyanarayana 592839fcabaSMichael S. Tsirkin static inline int ipoib_cm_admin_enabled(struct net_device *dev) 593839fcabaSMichael S. Tsirkin { 594839fcabaSMichael S. Tsirkin struct ipoib_dev_priv *priv = netdev_priv(dev); 595839fcabaSMichael S. Tsirkin return IPOIB_CM_SUPPORTED(dev->dev_addr) && 596839fcabaSMichael S. Tsirkin test_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags); 597839fcabaSMichael S. Tsirkin } 598839fcabaSMichael S. Tsirkin 599b63b70d8SShlomo Pongratz static inline int ipoib_cm_enabled(struct net_device *dev, u8 *hwaddr) 600839fcabaSMichael S. Tsirkin { 601839fcabaSMichael S. Tsirkin struct ipoib_dev_priv *priv = netdev_priv(dev); 602b63b70d8SShlomo Pongratz return IPOIB_CM_SUPPORTED(hwaddr) && 603839fcabaSMichael S. Tsirkin test_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags); 604839fcabaSMichael S. Tsirkin } 605839fcabaSMichael S. Tsirkin 606839fcabaSMichael S. Tsirkin static inline int ipoib_cm_up(struct ipoib_neigh *neigh) 607839fcabaSMichael S. Tsirkin 608839fcabaSMichael S. Tsirkin { 609839fcabaSMichael S. Tsirkin return test_bit(IPOIB_FLAG_OPER_UP, &neigh->cm->flags); 610839fcabaSMichael S. Tsirkin } 611839fcabaSMichael S. Tsirkin 612839fcabaSMichael S. Tsirkin static inline struct ipoib_cm_tx *ipoib_cm_get(struct ipoib_neigh *neigh) 613839fcabaSMichael S. Tsirkin { 614839fcabaSMichael S. Tsirkin return neigh->cm; 615839fcabaSMichael S. Tsirkin } 616839fcabaSMichael S. Tsirkin 617839fcabaSMichael S. Tsirkin static inline void ipoib_cm_set(struct ipoib_neigh *neigh, struct ipoib_cm_tx *tx) 618839fcabaSMichael S. Tsirkin { 619839fcabaSMichael S. Tsirkin neigh->cm = tx; 620839fcabaSMichael S. Tsirkin } 621839fcabaSMichael S. Tsirkin 62268e995a2SPradeep Satyanarayana static inline int ipoib_cm_has_srq(struct net_device *dev) 62368e995a2SPradeep Satyanarayana { 62468e995a2SPradeep Satyanarayana struct ipoib_dev_priv *priv = netdev_priv(dev); 62568e995a2SPradeep Satyanarayana return !!priv->cm.srq; 62668e995a2SPradeep Satyanarayana } 62768e995a2SPradeep Satyanarayana 628586a6934SPradeep Satyanarayana static inline unsigned int ipoib_cm_max_mtu(struct net_device *dev) 629586a6934SPradeep Satyanarayana { 630586a6934SPradeep Satyanarayana struct ipoib_dev_priv *priv = netdev_priv(dev); 631586a6934SPradeep Satyanarayana return priv->cm.max_cm_mtu; 632586a6934SPradeep Satyanarayana } 633586a6934SPradeep Satyanarayana 634839fcabaSMichael S. Tsirkin void ipoib_cm_send(struct net_device *dev, struct sk_buff *skb, struct ipoib_cm_tx *tx); 635839fcabaSMichael S. Tsirkin int ipoib_cm_dev_open(struct net_device *dev); 636839fcabaSMichael S. Tsirkin void ipoib_cm_dev_stop(struct net_device *dev); 637839fcabaSMichael S. Tsirkin int ipoib_cm_dev_init(struct net_device *dev); 638839fcabaSMichael S. Tsirkin int ipoib_cm_add_mode_attr(struct net_device *dev); 639839fcabaSMichael S. Tsirkin void ipoib_cm_dev_cleanup(struct net_device *dev); 640839fcabaSMichael S. Tsirkin struct ipoib_cm_tx *ipoib_cm_create_tx(struct net_device *dev, struct ipoib_path *path, 641839fcabaSMichael S. Tsirkin struct ipoib_neigh *neigh); 642839fcabaSMichael S. Tsirkin void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx); 643839fcabaSMichael S. Tsirkin void ipoib_cm_skb_too_long(struct net_device *dev, struct sk_buff *skb, 644839fcabaSMichael S. Tsirkin unsigned int mtu); 645839fcabaSMichael S. Tsirkin void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc); 6461b524963SMichael S. Tsirkin void ipoib_cm_handle_tx_wc(struct net_device *dev, struct ib_wc *wc); 647839fcabaSMichael S. Tsirkin #else 648839fcabaSMichael S. Tsirkin 649839fcabaSMichael S. Tsirkin struct ipoib_cm_tx; 650839fcabaSMichael S. Tsirkin 65168e995a2SPradeep Satyanarayana #define ipoib_max_conn_qp 0 65268e995a2SPradeep Satyanarayana 653839fcabaSMichael S. Tsirkin static inline int ipoib_cm_admin_enabled(struct net_device *dev) 654839fcabaSMichael S. Tsirkin { 655839fcabaSMichael S. Tsirkin return 0; 656839fcabaSMichael S. Tsirkin } 657b63b70d8SShlomo Pongratz static inline int ipoib_cm_enabled(struct net_device *dev, u8 *hwaddr) 658839fcabaSMichael S. Tsirkin 659839fcabaSMichael S. Tsirkin { 660839fcabaSMichael S. Tsirkin return 0; 661839fcabaSMichael S. Tsirkin } 662839fcabaSMichael S. Tsirkin 663839fcabaSMichael S. Tsirkin static inline int ipoib_cm_up(struct ipoib_neigh *neigh) 664839fcabaSMichael S. Tsirkin 665839fcabaSMichael S. Tsirkin { 666839fcabaSMichael S. Tsirkin return 0; 667839fcabaSMichael S. Tsirkin } 668839fcabaSMichael S. Tsirkin 669839fcabaSMichael S. Tsirkin static inline struct ipoib_cm_tx *ipoib_cm_get(struct ipoib_neigh *neigh) 670839fcabaSMichael S. Tsirkin { 671839fcabaSMichael S. Tsirkin return NULL; 672839fcabaSMichael S. Tsirkin } 673839fcabaSMichael S. Tsirkin 674839fcabaSMichael S. Tsirkin static inline void ipoib_cm_set(struct ipoib_neigh *neigh, struct ipoib_cm_tx *tx) 675839fcabaSMichael S. Tsirkin { 676839fcabaSMichael S. Tsirkin } 677839fcabaSMichael S. Tsirkin 67868e995a2SPradeep Satyanarayana static inline int ipoib_cm_has_srq(struct net_device *dev) 67968e995a2SPradeep Satyanarayana { 68068e995a2SPradeep Satyanarayana return 0; 68168e995a2SPradeep Satyanarayana } 68268e995a2SPradeep Satyanarayana 683586a6934SPradeep Satyanarayana static inline unsigned int ipoib_cm_max_mtu(struct net_device *dev) 684586a6934SPradeep Satyanarayana { 685586a6934SPradeep Satyanarayana return 0; 686586a6934SPradeep Satyanarayana } 687586a6934SPradeep Satyanarayana 688839fcabaSMichael S. Tsirkin static inline 689839fcabaSMichael S. Tsirkin void ipoib_cm_send(struct net_device *dev, struct sk_buff *skb, struct ipoib_cm_tx *tx) 690839fcabaSMichael S. Tsirkin { 691839fcabaSMichael S. Tsirkin return; 692839fcabaSMichael S. Tsirkin } 693839fcabaSMichael S. Tsirkin 694839fcabaSMichael S. Tsirkin static inline 695839fcabaSMichael S. Tsirkin int ipoib_cm_dev_open(struct net_device *dev) 696839fcabaSMichael S. Tsirkin { 697839fcabaSMichael S. Tsirkin return 0; 698839fcabaSMichael S. Tsirkin } 699839fcabaSMichael S. Tsirkin 700839fcabaSMichael S. Tsirkin static inline 701839fcabaSMichael S. Tsirkin void ipoib_cm_dev_stop(struct net_device *dev) 702839fcabaSMichael S. Tsirkin { 703839fcabaSMichael S. Tsirkin return; 704839fcabaSMichael S. Tsirkin } 705839fcabaSMichael S. Tsirkin 706839fcabaSMichael S. Tsirkin static inline 707839fcabaSMichael S. Tsirkin int ipoib_cm_dev_init(struct net_device *dev) 708839fcabaSMichael S. Tsirkin { 709839fcabaSMichael S. Tsirkin return -ENOSYS; 710839fcabaSMichael S. Tsirkin } 711839fcabaSMichael S. Tsirkin 712839fcabaSMichael S. Tsirkin static inline 713839fcabaSMichael S. Tsirkin void ipoib_cm_dev_cleanup(struct net_device *dev) 714839fcabaSMichael S. Tsirkin { 715839fcabaSMichael S. Tsirkin return; 716839fcabaSMichael S. Tsirkin } 717839fcabaSMichael S. Tsirkin 718839fcabaSMichael S. Tsirkin static inline 719839fcabaSMichael S. Tsirkin struct ipoib_cm_tx *ipoib_cm_create_tx(struct net_device *dev, struct ipoib_path *path, 720839fcabaSMichael S. Tsirkin struct ipoib_neigh *neigh) 721839fcabaSMichael S. Tsirkin { 722839fcabaSMichael S. Tsirkin return NULL; 723839fcabaSMichael S. Tsirkin } 724839fcabaSMichael S. Tsirkin 725839fcabaSMichael S. Tsirkin static inline 726839fcabaSMichael S. Tsirkin void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx) 727839fcabaSMichael S. Tsirkin { 728839fcabaSMichael S. Tsirkin return; 729839fcabaSMichael S. Tsirkin } 730839fcabaSMichael S. Tsirkin 731839fcabaSMichael S. Tsirkin static inline 732839fcabaSMichael S. Tsirkin int ipoib_cm_add_mode_attr(struct net_device *dev) 733839fcabaSMichael S. Tsirkin { 734839fcabaSMichael S. Tsirkin return 0; 735839fcabaSMichael S. Tsirkin } 736839fcabaSMichael S. Tsirkin 737839fcabaSMichael S. Tsirkin static inline void ipoib_cm_skb_too_long(struct net_device *dev, struct sk_buff *skb, 738839fcabaSMichael S. Tsirkin unsigned int mtu) 739839fcabaSMichael S. Tsirkin { 740839fcabaSMichael S. Tsirkin dev_kfree_skb_any(skb); 741839fcabaSMichael S. Tsirkin } 742839fcabaSMichael S. Tsirkin 743839fcabaSMichael S. Tsirkin static inline void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc) 744839fcabaSMichael S. Tsirkin { 745839fcabaSMichael S. Tsirkin } 746839fcabaSMichael S. Tsirkin 7471b524963SMichael S. Tsirkin static inline void ipoib_cm_handle_tx_wc(struct net_device *dev, struct ib_wc *wc) 7481b524963SMichael S. Tsirkin { 7491b524963SMichael S. Tsirkin } 750839fcabaSMichael S. Tsirkin #endif 751839fcabaSMichael S. Tsirkin 7521da177e4SLinus Torvalds #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG 7531732b0efSRoland Dreier void ipoib_create_debug_files(struct net_device *dev); 7541732b0efSRoland Dreier void ipoib_delete_debug_files(struct net_device *dev); 7551da177e4SLinus Torvalds int ipoib_register_debugfs(void); 7561da177e4SLinus Torvalds void ipoib_unregister_debugfs(void); 7571da177e4SLinus Torvalds #else 7581732b0efSRoland Dreier static inline void ipoib_create_debug_files(struct net_device *dev) { } 7591732b0efSRoland Dreier static inline void ipoib_delete_debug_files(struct net_device *dev) { } 7601da177e4SLinus Torvalds static inline int ipoib_register_debugfs(void) { return 0; } 7611da177e4SLinus Torvalds static inline void ipoib_unregister_debugfs(void) { } 7621da177e4SLinus Torvalds #endif 7631da177e4SLinus Torvalds 7641da177e4SLinus Torvalds #define ipoib_printk(level, priv, format, arg...) \ 7651da177e4SLinus Torvalds printk(level "%s: " format, ((struct ipoib_dev_priv *) priv)->dev->name , ## arg) 7661da177e4SLinus Torvalds #define ipoib_warn(priv, format, arg...) \ 7671da177e4SLinus Torvalds ipoib_printk(KERN_WARNING, priv, format , ## arg) 7681da177e4SLinus Torvalds 7690f485251SShirley Ma extern int ipoib_sendq_size; 7700f485251SShirley Ma extern int ipoib_recvq_size; 7711da177e4SLinus Torvalds 772c1a0b23bSMichael S. Tsirkin extern struct ib_sa_client ipoib_sa_client; 773c1a0b23bSMichael S. Tsirkin 7741da177e4SLinus Torvalds #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG 7751da177e4SLinus Torvalds extern int ipoib_debug_level; 7761da177e4SLinus Torvalds 7771da177e4SLinus Torvalds #define ipoib_dbg(priv, format, arg...) \ 7781da177e4SLinus Torvalds do { \ 7791da177e4SLinus Torvalds if (ipoib_debug_level > 0) \ 7801da177e4SLinus Torvalds ipoib_printk(KERN_DEBUG, priv, format , ## arg); \ 7811da177e4SLinus Torvalds } while (0) 7821da177e4SLinus Torvalds #define ipoib_dbg_mcast(priv, format, arg...) \ 7831da177e4SLinus Torvalds do { \ 7841da177e4SLinus Torvalds if (mcast_debug_level > 0) \ 7851da177e4SLinus Torvalds ipoib_printk(KERN_DEBUG, priv, format , ## arg); \ 7861da177e4SLinus Torvalds } while (0) 7871da177e4SLinus Torvalds #else /* CONFIG_INFINIBAND_IPOIB_DEBUG */ 7881da177e4SLinus Torvalds #define ipoib_dbg(priv, format, arg...) \ 7891da177e4SLinus Torvalds do { (void) (priv); } while (0) 7901da177e4SLinus Torvalds #define ipoib_dbg_mcast(priv, format, arg...) \ 7911da177e4SLinus Torvalds do { (void) (priv); } while (0) 7921da177e4SLinus Torvalds #endif /* CONFIG_INFINIBAND_IPOIB_DEBUG */ 7931da177e4SLinus Torvalds 7941da177e4SLinus Torvalds #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG_DATA 7951da177e4SLinus Torvalds #define ipoib_dbg_data(priv, format, arg...) \ 7961da177e4SLinus Torvalds do { \ 7971da177e4SLinus Torvalds if (data_debug_level > 0) \ 7981da177e4SLinus Torvalds ipoib_printk(KERN_DEBUG, priv, format , ## arg); \ 7991da177e4SLinus Torvalds } while (0) 8001da177e4SLinus Torvalds #else /* CONFIG_INFINIBAND_IPOIB_DEBUG_DATA */ 8011da177e4SLinus Torvalds #define ipoib_dbg_data(priv, format, arg...) \ 8021da177e4SLinus Torvalds do { (void) (priv); } while (0) 8031da177e4SLinus Torvalds #endif /* CONFIG_INFINIBAND_IPOIB_DEBUG_DATA */ 8041da177e4SLinus Torvalds 805839fcabaSMichael S. Tsirkin #define IPOIB_QPN(ha) (be32_to_cpup((__be32 *) ha) & 0xffffff) 806839fcabaSMichael S. Tsirkin 8074b48680bSYan Burman extern const char ipoib_driver_version[]; 8084b48680bSYan Burman 8091da177e4SLinus Torvalds #endif /* _IPOIB_H */ 810