1fe267a55SPedro F. Giffuni /*- 2fe267a55SPedro F. Giffuni * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0 3fe267a55SPedro F. Giffuni * 4aa0a1e58SJeff Roberson * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 5aa0a1e58SJeff Roberson * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 6aa0a1e58SJeff Roberson * Copyright (c) 2004 Voltaire, Inc. All rights reserved. 7aa0a1e58SJeff Roberson * 8aa0a1e58SJeff Roberson * This software is available to you under a choice of one of two 9aa0a1e58SJeff Roberson * licenses. You may choose to be licensed under the terms of the GNU 10aa0a1e58SJeff Roberson * General Public License (GPL) Version 2, available from the file 11aa0a1e58SJeff Roberson * COPYING in the main directory of this source tree, or the 12aa0a1e58SJeff Roberson * OpenIB.org BSD license below: 13aa0a1e58SJeff Roberson * 14aa0a1e58SJeff Roberson * Redistribution and use in source and binary forms, with or 15aa0a1e58SJeff Roberson * without modification, are permitted provided that the following 16aa0a1e58SJeff Roberson * conditions are met: 17aa0a1e58SJeff Roberson * 18aa0a1e58SJeff Roberson * - Redistributions of source code must retain the above 19aa0a1e58SJeff Roberson * copyright notice, this list of conditions and the following 20aa0a1e58SJeff Roberson * disclaimer. 21aa0a1e58SJeff Roberson * 22aa0a1e58SJeff Roberson * - Redistributions in binary form must reproduce the above 23aa0a1e58SJeff Roberson * copyright notice, this list of conditions and the following 24aa0a1e58SJeff Roberson * disclaimer in the documentation and/or other materials 25aa0a1e58SJeff Roberson * provided with the distribution. 26aa0a1e58SJeff Roberson * 27aa0a1e58SJeff Roberson * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 28aa0a1e58SJeff Roberson * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 29aa0a1e58SJeff Roberson * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 30aa0a1e58SJeff Roberson * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 31aa0a1e58SJeff Roberson * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 32aa0a1e58SJeff Roberson * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 33aa0a1e58SJeff Roberson * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 34aa0a1e58SJeff Roberson * SOFTWARE. 35cda1e10cSHans Petter Selasky * 36cda1e10cSHans Petter Selasky * $FreeBSD$ 37aa0a1e58SJeff Roberson */ 38aa0a1e58SJeff Roberson 39aa0a1e58SJeff Roberson #ifndef _IPOIB_H 40aa0a1e58SJeff Roberson #define _IPOIB_H 41aa0a1e58SJeff Roberson 42fa201e28SHans Petter Selasky #define LINUXKPI_PARAM_PREFIX ipoib_ 43fa201e28SHans Petter Selasky 44aa0a1e58SJeff Roberson #include "opt_inet.h" 45aa0a1e58SJeff Roberson #include "opt_inet6.h" 46aa0a1e58SJeff Roberson #include "opt_ofed.h" 47aa0a1e58SJeff Roberson 48aa0a1e58SJeff Roberson #include <sys/param.h> 49aa0a1e58SJeff Roberson #include <sys/systm.h> 50aa0a1e58SJeff Roberson #include <sys/kernel.h> 51aa0a1e58SJeff Roberson #include <sys/lock.h> 52aa0a1e58SJeff Roberson #include <sys/malloc.h> 53aa0a1e58SJeff Roberson #include <sys/mbuf.h> 54aa0a1e58SJeff Roberson #include <sys/random.h> 55aa0a1e58SJeff Roberson #include <sys/rwlock.h> 56aa0a1e58SJeff Roberson #include <sys/socket.h> 57aa0a1e58SJeff Roberson #include <sys/sockio.h> 58aa0a1e58SJeff Roberson #include <sys/sysctl.h> 59aa0a1e58SJeff Roberson 60aa0a1e58SJeff Roberson #include <net/if.h> 6176039bc8SGleb Smirnoff #include <net/if_var.h> 62aa0a1e58SJeff Roberson #include <net/if_arp.h> 63aa0a1e58SJeff Roberson #include <net/netisr.h> 64aa0a1e58SJeff Roberson #include <net/route.h> 65aa0a1e58SJeff Roberson #include <net/if_llc.h> 66aa0a1e58SJeff Roberson #include <net/if_dl.h> 67aa0a1e58SJeff Roberson #include <net/if_types.h> 68aa0a1e58SJeff Roberson #include <net/bpf.h> 69aa0a1e58SJeff Roberson #include <net/if_llatbl.h> 70aa0a1e58SJeff Roberson #include <net/vnet.h> 71aa0a1e58SJeff Roberson 72aa0a1e58SJeff Roberson #if defined(INET) || defined(INET6) 73aa0a1e58SJeff Roberson #include <netinet/in.h> 74aa0a1e58SJeff Roberson #include <netinet/in_var.h> 75aa0a1e58SJeff Roberson #include <netinet/if_ether.h> 76aa0a1e58SJeff Roberson #include <netinet/ip_var.h> 77aa0a1e58SJeff Roberson #endif 78aa0a1e58SJeff Roberson #ifdef INET6 79aa0a1e58SJeff Roberson #include <netinet6/nd6.h> 80aa0a1e58SJeff Roberson #endif 81aa0a1e58SJeff Roberson 82aa0a1e58SJeff Roberson #include <security/mac/mac_framework.h> 83aa0a1e58SJeff Roberson 84aa0a1e58SJeff Roberson #include <linux/list.h> 85aa0a1e58SJeff Roberson 86aa0a1e58SJeff Roberson #include <linux/workqueue.h> 87aa0a1e58SJeff Roberson #include <linux/kref.h> 88aa0a1e58SJeff Roberson #include <linux/mutex.h> 89b5c1e0cbSHans Petter Selasky #include <linux/rbtree.h> 90aa0a1e58SJeff Roberson 91aa0a1e58SJeff Roberson #include <asm/atomic.h> 92aa0a1e58SJeff Roberson 93aa0a1e58SJeff Roberson #include <rdma/ib_verbs.h> 94aa0a1e58SJeff Roberson #include <rdma/ib_pack.h> 95aa0a1e58SJeff Roberson #include <rdma/ib_sa.h> 96aa0a1e58SJeff Roberson 97aa0a1e58SJeff Roberson /* constants */ 98aa0a1e58SJeff Roberson 99aa0a1e58SJeff Roberson #define INFINIBAND_ALEN 20 /* Octets in IPoIB HW addr */ 100aa0a1e58SJeff Roberson 101aa0a1e58SJeff Roberson #ifdef IPOIB_CM 102aa0a1e58SJeff Roberson #define CONFIG_INFINIBAND_IPOIB_CM 103aa0a1e58SJeff Roberson #endif 104aa0a1e58SJeff Roberson 105aa0a1e58SJeff Roberson #ifdef IPOIB_DEBUG 106aa0a1e58SJeff Roberson #define CONFIG_INFINIBAND_IPOIB_DEBUG 107aa0a1e58SJeff Roberson #define CONFIG_INFINIBAND_IPOIB_DEBUG_DATA 108aa0a1e58SJeff Roberson #endif 109aa0a1e58SJeff Roberson 110aa0a1e58SJeff Roberson enum ipoib_flush_level { 111aa0a1e58SJeff Roberson IPOIB_FLUSH_LIGHT, 112aa0a1e58SJeff Roberson IPOIB_FLUSH_NORMAL, 113aa0a1e58SJeff Roberson IPOIB_FLUSH_HEAVY 114aa0a1e58SJeff Roberson }; 115aa0a1e58SJeff Roberson 116aa0a1e58SJeff Roberson enum { 117aa0a1e58SJeff Roberson IPOIB_ENCAP_LEN = 4, 118aa0a1e58SJeff Roberson IPOIB_HEADER_LEN = IPOIB_ENCAP_LEN + INFINIBAND_ALEN, 119aa0a1e58SJeff Roberson IPOIB_UD_MAX_MTU = 4 * 1024, 1204e38478cSHans Petter Selasky IPOIB_UD_RX_SG = 2, /* packet header and one cluster */ 121aa0a1e58SJeff Roberson IPOIB_UD_TX_SG = (IPOIB_UD_MAX_MTU / MCLBYTES) + 2, 122aa0a1e58SJeff Roberson IPOIB_CM_MAX_MTU = (64 * 1024), 123aa0a1e58SJeff Roberson IPOIB_CM_TX_SG = (IPOIB_CM_MAX_MTU / MCLBYTES) + 2, 1244e38478cSHans Petter Selasky IPOIB_CM_RX_SG = (IPOIB_CM_MAX_MTU / MCLBYTES) + 2, 125aa0a1e58SJeff Roberson IPOIB_RX_RING_SIZE = 256, 126aa0a1e58SJeff Roberson IPOIB_TX_RING_SIZE = 128, 127aa0a1e58SJeff Roberson IPOIB_MAX_RX_SG = MAX(IPOIB_CM_RX_SG, IPOIB_UD_RX_SG), 128aa0a1e58SJeff Roberson IPOIB_MAX_TX_SG = MAX(IPOIB_CM_TX_SG, IPOIB_UD_TX_SG), 129aa0a1e58SJeff Roberson IPOIB_MAX_QUEUE_SIZE = 8192, 130aa0a1e58SJeff Roberson IPOIB_MIN_QUEUE_SIZE = 2, 131aa0a1e58SJeff Roberson IPOIB_CM_MAX_CONN_QP = 4096, 132aa0a1e58SJeff Roberson 133aa0a1e58SJeff Roberson IPOIB_NUM_WC = 4, 134aa0a1e58SJeff Roberson 135a061f0ebSSlava Shwartsman IPOIB_MAX_PATH_REC_QUEUE = 16, 136a061f0ebSSlava Shwartsman IPOIB_MAX_MCAST_QUEUE = 16, 137aa0a1e58SJeff Roberson 138aa0a1e58SJeff Roberson IPOIB_FLAG_OPER_UP = 0, 139aa0a1e58SJeff Roberson IPOIB_FLAG_INITIALIZED = 1, 140aa0a1e58SJeff Roberson IPOIB_FLAG_ADMIN_UP = 2, 141aa0a1e58SJeff Roberson IPOIB_PKEY_ASSIGNED = 3, 142aa0a1e58SJeff Roberson IPOIB_PKEY_STOP = 4, 143aa0a1e58SJeff Roberson IPOIB_FLAG_SUBINTERFACE = 5, 144aa0a1e58SJeff Roberson IPOIB_MCAST_RUN = 6, 145aa0a1e58SJeff Roberson IPOIB_STOP_REAPER = 7, 146aa0a1e58SJeff Roberson IPOIB_FLAG_UMCAST = 10, 147aa0a1e58SJeff Roberson IPOIB_FLAG_CSUM = 11, 148aa0a1e58SJeff Roberson 149aa0a1e58SJeff Roberson IPOIB_MAX_BACKOFF_SECONDS = 16, 150aa0a1e58SJeff Roberson 151aa0a1e58SJeff Roberson IPOIB_MCAST_FLAG_FOUND = 0, /* used in set_multicast_list */ 152aa0a1e58SJeff Roberson IPOIB_MCAST_FLAG_SENDONLY = 1, 153aa0a1e58SJeff Roberson IPOIB_MCAST_FLAG_BUSY = 2, /* joining or already joined */ 154aa0a1e58SJeff Roberson IPOIB_MCAST_FLAG_ATTACHED = 3, 155aa0a1e58SJeff Roberson 156aa0a1e58SJeff Roberson IPOIB_MAX_LRO_DESCRIPTORS = 8, 157aa0a1e58SJeff Roberson IPOIB_LRO_MAX_AGGR = 64, 158aa0a1e58SJeff Roberson 159aa0a1e58SJeff Roberson MAX_SEND_CQE = 16, 160aa0a1e58SJeff Roberson IPOIB_CM_COPYBREAK = 256, 161aa0a1e58SJeff Roberson }; 162aa0a1e58SJeff Roberson 163aa0a1e58SJeff Roberson #define IPOIB_OP_RECV (1ul << 31) 164aa0a1e58SJeff Roberson #ifdef CONFIG_INFINIBAND_IPOIB_CM 165aa0a1e58SJeff Roberson #define IPOIB_OP_CM (1ul << 30) 166aa0a1e58SJeff Roberson #else 167aa0a1e58SJeff Roberson #define IPOIB_OP_CM (0) 168aa0a1e58SJeff Roberson #endif 169aa0a1e58SJeff Roberson 170aa0a1e58SJeff Roberson /* structs */ 171aa0a1e58SJeff Roberson 172aa0a1e58SJeff Roberson struct ipoib_header { 173aa0a1e58SJeff Roberson u8 hwaddr[INFINIBAND_ALEN]; 174aa0a1e58SJeff Roberson __be16 proto; 175aa0a1e58SJeff Roberson u16 reserved; 176aa0a1e58SJeff Roberson }; 177aa0a1e58SJeff Roberson 178aa0a1e58SJeff Roberson struct ipoib_pseudoheader { 179aa0a1e58SJeff Roberson u8 hwaddr[INFINIBAND_ALEN]; 180aa0a1e58SJeff Roberson }; 181aa0a1e58SJeff Roberson 182aa0a1e58SJeff Roberson /* Used for all multicast joins (broadcast, IPv4 mcast and IPv6 mcast) */ 183aa0a1e58SJeff Roberson struct ipoib_mcast { 184aa0a1e58SJeff Roberson struct ib_sa_mcmember_rec mcmember; 185aa0a1e58SJeff Roberson struct ib_sa_multicast *mc; 186aa0a1e58SJeff Roberson struct ipoib_ah *ah; 187aa0a1e58SJeff Roberson 188aa0a1e58SJeff Roberson struct rb_node rb_node; 189aa0a1e58SJeff Roberson struct list_head list; 190aa0a1e58SJeff Roberson 191aa0a1e58SJeff Roberson unsigned long created; 192aa0a1e58SJeff Roberson unsigned long backoff; 193aa0a1e58SJeff Roberson 194aa0a1e58SJeff Roberson unsigned long flags; 195aa0a1e58SJeff Roberson unsigned char logcount; 196aa0a1e58SJeff Roberson 197aa0a1e58SJeff Roberson struct ifqueue pkt_queue; 198aa0a1e58SJeff Roberson 199aa0a1e58SJeff Roberson struct ipoib_dev_priv *priv; 200aa0a1e58SJeff Roberson }; 201aa0a1e58SJeff Roberson 202aa0a1e58SJeff Roberson struct ipoib_cm_rx_buf { 203aa0a1e58SJeff Roberson struct mbuf *mb; 204aa0a1e58SJeff Roberson u64 mapping[IPOIB_CM_RX_SG]; 205aa0a1e58SJeff Roberson }; 206aa0a1e58SJeff Roberson 207aa0a1e58SJeff Roberson struct ipoib_cm_tx_buf { 208aa0a1e58SJeff Roberson struct mbuf *mb; 209aa0a1e58SJeff Roberson u64 mapping[IPOIB_CM_TX_SG]; 210aa0a1e58SJeff Roberson }; 211aa0a1e58SJeff Roberson 212aa0a1e58SJeff Roberson struct ipoib_rx_buf { 213aa0a1e58SJeff Roberson struct mbuf *mb; 214aa0a1e58SJeff Roberson u64 mapping[IPOIB_UD_RX_SG]; 215aa0a1e58SJeff Roberson }; 216aa0a1e58SJeff Roberson 217aa0a1e58SJeff Roberson struct ipoib_tx_buf { 218aa0a1e58SJeff Roberson struct mbuf *mb; 219aa0a1e58SJeff Roberson u64 mapping[IPOIB_UD_TX_SG]; 220aa0a1e58SJeff Roberson }; 221aa0a1e58SJeff Roberson 222aa0a1e58SJeff Roberson struct ib_cm_id; 223aa0a1e58SJeff Roberson 224aa0a1e58SJeff Roberson struct ipoib_cm_data { 225aa0a1e58SJeff Roberson __be32 qpn; /* High byte MUST be ignored on receive */ 226aa0a1e58SJeff Roberson __be32 mtu; 227aa0a1e58SJeff Roberson }; 228aa0a1e58SJeff Roberson 229aa0a1e58SJeff Roberson /* 230aa0a1e58SJeff Roberson * Quoting 10.3.1 Queue Pair and EE Context States: 231aa0a1e58SJeff Roberson * 232aa0a1e58SJeff Roberson * Note, for QPs that are associated with an SRQ, the Consumer should take the 233aa0a1e58SJeff Roberson * QP through the Error State before invoking a Destroy QP or a Modify QP to the 234aa0a1e58SJeff Roberson * Reset State. The Consumer may invoke the Destroy QP without first performing 235aa0a1e58SJeff Roberson * a Modify QP to the Error State and waiting for the Affiliated Asynchronous 236aa0a1e58SJeff Roberson * Last WQE Reached Event. However, if the Consumer does not wait for the 237aa0a1e58SJeff Roberson * Affiliated Asynchronous Last WQE Reached Event, then WQE and Data Segment 238aa0a1e58SJeff Roberson * leakage may occur. Therefore, it is good programming practice to tear down a 239aa0a1e58SJeff Roberson * QP that is associated with an SRQ by using the following process: 240aa0a1e58SJeff Roberson * 241aa0a1e58SJeff Roberson * - Put the QP in the Error State 242aa0a1e58SJeff Roberson * - Wait for the Affiliated Asynchronous Last WQE Reached Event; 243aa0a1e58SJeff Roberson * - either: 244aa0a1e58SJeff Roberson * drain the CQ by invoking the Poll CQ verb and either wait for CQ 245aa0a1e58SJeff Roberson * to be empty or the number of Poll CQ operations has exceeded 246aa0a1e58SJeff Roberson * CQ capacity size; 247aa0a1e58SJeff Roberson * - or 248aa0a1e58SJeff Roberson * post another WR that completes on the same CQ and wait for this 249aa0a1e58SJeff Roberson * WR to return as a WC; 250aa0a1e58SJeff Roberson * - and then invoke a Destroy QP or Reset QP. 251aa0a1e58SJeff Roberson * 252aa0a1e58SJeff Roberson * We use the second option and wait for a completion on the 253aa0a1e58SJeff Roberson * same CQ before destroying QPs attached to our SRQ. 254aa0a1e58SJeff Roberson */ 255aa0a1e58SJeff Roberson 256aa0a1e58SJeff Roberson enum ipoib_cm_state { 257aa0a1e58SJeff Roberson IPOIB_CM_RX_LIVE, 258aa0a1e58SJeff Roberson IPOIB_CM_RX_ERROR, /* Ignored by stale task */ 259aa0a1e58SJeff Roberson IPOIB_CM_RX_FLUSH /* Last WQE Reached event observed */ 260aa0a1e58SJeff Roberson }; 261aa0a1e58SJeff Roberson 262aa0a1e58SJeff Roberson struct ipoib_cm_rx { 263aa0a1e58SJeff Roberson struct ib_cm_id *id; 264aa0a1e58SJeff Roberson struct ib_qp *qp; 265aa0a1e58SJeff Roberson struct ipoib_cm_rx_buf *rx_ring; 266aa0a1e58SJeff Roberson struct list_head list; 267aa0a1e58SJeff Roberson struct ipoib_dev_priv *priv; 268aa0a1e58SJeff Roberson unsigned long jiffies; 269aa0a1e58SJeff Roberson enum ipoib_cm_state state; 270aa0a1e58SJeff Roberson int recv_count; 271aa0a1e58SJeff Roberson }; 272aa0a1e58SJeff Roberson 273aa0a1e58SJeff Roberson struct ipoib_cm_tx { 274aa0a1e58SJeff Roberson struct ib_cm_id *id; 275aa0a1e58SJeff Roberson struct ib_qp *qp; 276aa0a1e58SJeff Roberson struct list_head list; 277aa0a1e58SJeff Roberson struct ipoib_dev_priv *priv; 278aa0a1e58SJeff Roberson struct ipoib_path *path; 279aa0a1e58SJeff Roberson struct ipoib_cm_tx_buf *tx_ring; 280aa0a1e58SJeff Roberson unsigned tx_head; 281aa0a1e58SJeff Roberson unsigned tx_tail; 282aa0a1e58SJeff Roberson unsigned long flags; 283aa0a1e58SJeff Roberson u32 mtu; /* remote specified mtu, with grh. */ 284aa0a1e58SJeff Roberson }; 285aa0a1e58SJeff Roberson 286aa0a1e58SJeff Roberson struct ipoib_cm_dev_priv { 287aa0a1e58SJeff Roberson struct ib_srq *srq; 288aa0a1e58SJeff Roberson struct ipoib_cm_rx_buf *srq_ring; 289aa0a1e58SJeff Roberson struct ib_cm_id *id; 290aa0a1e58SJeff Roberson struct list_head passive_ids; /* state: LIVE */ 291aa0a1e58SJeff Roberson struct list_head rx_error_list; /* state: ERROR */ 292aa0a1e58SJeff Roberson struct list_head rx_flush_list; /* state: FLUSH, drain not started */ 293aa0a1e58SJeff Roberson struct list_head rx_drain_list; /* state: FLUSH, drain started */ 294aa0a1e58SJeff Roberson struct list_head rx_reap_list; /* state: FLUSH, drain done */ 295aa0a1e58SJeff Roberson struct work_struct start_task; 296aa0a1e58SJeff Roberson struct work_struct reap_task; 297aa0a1e58SJeff Roberson struct work_struct mb_task; 298aa0a1e58SJeff Roberson struct work_struct rx_reap_task; 299aa0a1e58SJeff Roberson struct delayed_work stale_task; 300aa0a1e58SJeff Roberson struct ifqueue mb_queue; 301aa0a1e58SJeff Roberson struct list_head start_list; 302aa0a1e58SJeff Roberson struct list_head reap_list; 303aa0a1e58SJeff Roberson struct ib_sge rx_sge[IPOIB_CM_RX_SG]; 304aa0a1e58SJeff Roberson struct ib_recv_wr rx_wr; 305aa0a1e58SJeff Roberson int nonsrq_conn_qp; 306aa0a1e58SJeff Roberson int max_cm_mtu; /* Actual buf size. */ 307aa0a1e58SJeff Roberson int num_frags; 308aa0a1e58SJeff Roberson }; 309aa0a1e58SJeff Roberson 310aa0a1e58SJeff Roberson struct ipoib_ethtool_st { 311aa0a1e58SJeff Roberson u16 coalesce_usecs; 312aa0a1e58SJeff Roberson u16 max_coalesced_frames; 313aa0a1e58SJeff Roberson }; 314aa0a1e58SJeff Roberson 315aa0a1e58SJeff Roberson /* 316aa0a1e58SJeff Roberson * Device private locking: network stack tx_lock protects members used 317aa0a1e58SJeff Roberson * in TX fast path, lock protects everything else. lock nests inside 318aa0a1e58SJeff Roberson * of tx_lock (ie tx_lock must be acquired first if needed). 319aa0a1e58SJeff Roberson */ 320aa0a1e58SJeff Roberson struct ipoib_dev_priv { 321aa0a1e58SJeff Roberson spinlock_t lock; 322b5c1e0cbSHans Petter Selasky spinlock_t drain_lock; 323aa0a1e58SJeff Roberson 3243e142e07SJustin Hibbits if_t dev; 325aa0a1e58SJeff Roberson 326aa0a1e58SJeff Roberson u8 broadcastaddr[INFINIBAND_ALEN]; 327aa0a1e58SJeff Roberson 328aa0a1e58SJeff Roberson unsigned long flags; 329aa0a1e58SJeff Roberson 3309319562bSHans Petter Selasky int gone; 331478d3005SHans Petter Selasky int unit; 3329319562bSHans Petter Selasky 333aa0a1e58SJeff Roberson struct mutex vlan_mutex; 334aa0a1e58SJeff Roberson 335aa0a1e58SJeff Roberson struct rb_root path_tree; 336aa0a1e58SJeff Roberson struct list_head path_list; 337aa0a1e58SJeff Roberson 338aa0a1e58SJeff Roberson struct ipoib_mcast *broadcast; 339aa0a1e58SJeff Roberson struct list_head multicast_list; 340aa0a1e58SJeff Roberson struct rb_root multicast_tree; 341aa0a1e58SJeff Roberson 342aa0a1e58SJeff Roberson struct delayed_work pkey_poll_task; 343aa0a1e58SJeff Roberson struct delayed_work mcast_task; 344aa0a1e58SJeff Roberson struct work_struct carrier_on_task; 345aa0a1e58SJeff Roberson struct work_struct flush_light; 346aa0a1e58SJeff Roberson struct work_struct flush_normal; 347aa0a1e58SJeff Roberson struct work_struct flush_heavy; 348aa0a1e58SJeff Roberson struct work_struct restart_task; 349aa0a1e58SJeff Roberson struct delayed_work ah_reap_task; 350aa0a1e58SJeff Roberson 351aa0a1e58SJeff Roberson struct ib_device *ca; 352aa0a1e58SJeff Roberson u8 port; 353aa0a1e58SJeff Roberson u16 pkey; 354aa0a1e58SJeff Roberson u16 pkey_index; 355aa0a1e58SJeff Roberson struct ib_pd *pd; 356aa0a1e58SJeff Roberson struct ib_cq *recv_cq; 357aa0a1e58SJeff Roberson struct ib_cq *send_cq; 358aa0a1e58SJeff Roberson struct ib_qp *qp; 359aa0a1e58SJeff Roberson u32 qkey; 360aa0a1e58SJeff Roberson 361aa0a1e58SJeff Roberson union ib_gid local_gid; 362aa0a1e58SJeff Roberson u16 local_lid; 363aa0a1e58SJeff Roberson 364aa0a1e58SJeff Roberson unsigned int admin_mtu; /* User selected MTU, no GRH. */ 365aa0a1e58SJeff Roberson unsigned int mcast_mtu; /* Minus GRH bytes, from mcast group. */ 366aa0a1e58SJeff Roberson unsigned int max_ib_mtu; /* Without header, actual buf size. */ 367aa0a1e58SJeff Roberson 368aa0a1e58SJeff Roberson struct ipoib_rx_buf *rx_ring; 369aa0a1e58SJeff Roberson 370aa0a1e58SJeff Roberson struct ipoib_tx_buf *tx_ring; 371aa0a1e58SJeff Roberson unsigned tx_head; 372aa0a1e58SJeff Roberson unsigned tx_tail; 373aa0a1e58SJeff Roberson struct ib_sge tx_sge[IPOIB_MAX_TX_SG]; 374478d3005SHans Petter Selasky struct ib_ud_wr tx_wr; 375aa0a1e58SJeff Roberson unsigned tx_outstanding; 376aa0a1e58SJeff Roberson struct ib_wc send_wc[MAX_SEND_CQE]; 377aa0a1e58SJeff Roberson 378aa0a1e58SJeff Roberson struct ib_recv_wr rx_wr; 379aa0a1e58SJeff Roberson struct ib_sge rx_sge[IPOIB_MAX_RX_SG]; 380aa0a1e58SJeff Roberson 381aa0a1e58SJeff Roberson struct ib_wc ibwc[IPOIB_NUM_WC]; 382aa0a1e58SJeff Roberson 383aa0a1e58SJeff Roberson struct list_head dead_ahs; 384aa0a1e58SJeff Roberson 385aa0a1e58SJeff Roberson struct ib_event_handler event_handler; 386aa0a1e58SJeff Roberson 3873e142e07SJustin Hibbits if_t parent; 388aa0a1e58SJeff Roberson struct list_head child_intfs; 389aa0a1e58SJeff Roberson struct list_head list; 390aa0a1e58SJeff Roberson 391aa0a1e58SJeff Roberson #ifdef CONFIG_INFINIBAND_IPOIB_CM 392aa0a1e58SJeff Roberson struct ipoib_cm_dev_priv cm; 393aa0a1e58SJeff Roberson #endif 394aa0a1e58SJeff Roberson 395aa0a1e58SJeff Roberson #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG 396aa0a1e58SJeff Roberson struct list_head fs_list; 397aa0a1e58SJeff Roberson struct dentry *mcg_dentry; 398aa0a1e58SJeff Roberson struct dentry *path_dentry; 399aa0a1e58SJeff Roberson #endif 400aa0a1e58SJeff Roberson int hca_caps; 401aa0a1e58SJeff Roberson struct ipoib_ethtool_st ethtool; 402aa0a1e58SJeff Roberson struct timer_list poll_timer; 403aa0a1e58SJeff Roberson }; 404aa0a1e58SJeff Roberson 405aa0a1e58SJeff Roberson struct ipoib_ah { 406aa0a1e58SJeff Roberson struct ipoib_dev_priv *priv; 407aa0a1e58SJeff Roberson struct ib_ah *ah; 408aa0a1e58SJeff Roberson struct list_head list; 409aa0a1e58SJeff Roberson struct kref ref; 410aa0a1e58SJeff Roberson unsigned last_send; 411aa0a1e58SJeff Roberson }; 412aa0a1e58SJeff Roberson 413aa0a1e58SJeff Roberson struct ipoib_path { 414aa0a1e58SJeff Roberson struct ipoib_dev_priv *priv; 415aa0a1e58SJeff Roberson struct rb_node rb_node; 416aa0a1e58SJeff Roberson struct list_head list; 417aa0a1e58SJeff Roberson #ifdef CONFIG_INFINIBAND_IPOIB_CM 418aa0a1e58SJeff Roberson uint8_t hwaddr[INFINIBAND_ALEN]; 419aa0a1e58SJeff Roberson struct ipoib_cm_tx *cm; 420aa0a1e58SJeff Roberson #endif 421aa0a1e58SJeff Roberson struct ipoib_ah *ah; 422aa0a1e58SJeff Roberson struct ib_sa_path_rec pathrec; 423aa0a1e58SJeff Roberson struct ifqueue queue; 424aa0a1e58SJeff Roberson 425aa0a1e58SJeff Roberson int query_id; 426aa0a1e58SJeff Roberson struct ib_sa_query *query; 427aa0a1e58SJeff Roberson struct completion done; 428aa0a1e58SJeff Roberson 429aa0a1e58SJeff Roberson int valid; 430aa0a1e58SJeff Roberson }; 431aa0a1e58SJeff Roberson 432aa0a1e58SJeff Roberson /* UD Only transmits encap len but we want the two sizes to be symmetrical. */ 433aa0a1e58SJeff Roberson #define IPOIB_UD_MTU(ib_mtu) (ib_mtu - IPOIB_ENCAP_LEN) 434aa0a1e58SJeff Roberson #define IPOIB_CM_MTU(ib_mtu) (ib_mtu - 0x10) 435aa0a1e58SJeff Roberson 436aa0a1e58SJeff Roberson #define IPOIB_IS_MULTICAST(addr) ((addr)[4] == 0xff) 437aa0a1e58SJeff Roberson 438aa0a1e58SJeff Roberson extern struct workqueue_struct *ipoib_workqueue; 439aa0a1e58SJeff Roberson 440aa0a1e58SJeff Roberson /* functions */ 441aa0a1e58SJeff Roberson void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr); 442aa0a1e58SJeff Roberson void ipoib_send_comp_handler(struct ib_cq *cq, void *dev_ptr); 443aa0a1e58SJeff Roberson 444aa0a1e58SJeff Roberson struct ipoib_ah *ipoib_create_ah(struct ipoib_dev_priv *, 445aa0a1e58SJeff Roberson struct ib_pd *pd, struct ib_ah_attr *attr); 446aa0a1e58SJeff Roberson void ipoib_free_ah(struct kref *kref); 447aa0a1e58SJeff Roberson static inline void ipoib_put_ah(struct ipoib_ah *ah) 448aa0a1e58SJeff Roberson { 449aa0a1e58SJeff Roberson kref_put(&ah->ref, ipoib_free_ah); 450aa0a1e58SJeff Roberson } 451aa0a1e58SJeff Roberson 452aa0a1e58SJeff Roberson int ipoib_open(struct ipoib_dev_priv *priv); 453aa0a1e58SJeff Roberson int ipoib_add_pkey_attr(struct ipoib_dev_priv *priv); 454aa0a1e58SJeff Roberson int ipoib_add_umcast_attr(struct ipoib_dev_priv *priv); 455aa0a1e58SJeff Roberson 456aa0a1e58SJeff Roberson void ipoib_send(struct ipoib_dev_priv *priv, struct mbuf *mb, 457aa0a1e58SJeff Roberson struct ipoib_ah *address, u32 qpn); 458aa0a1e58SJeff Roberson void ipoib_reap_ah(struct work_struct *work); 459aa0a1e58SJeff Roberson 460aa0a1e58SJeff Roberson void ipoib_mark_paths_invalid(struct ipoib_dev_priv *priv); 461aa0a1e58SJeff Roberson void ipoib_flush_paths(struct ipoib_dev_priv *priv); 462*fc6c93b6SZhenlei Huang struct ipoib_dev_priv *ipoib_intf_alloc(const char *format, struct ib_device *ca); 463aa0a1e58SJeff Roberson 464aa0a1e58SJeff Roberson int ipoib_ib_dev_init(struct ipoib_dev_priv *priv, struct ib_device *ca, 465aa0a1e58SJeff Roberson int port); 466aa0a1e58SJeff Roberson void ipoib_ib_dev_flush_light(struct work_struct *work); 467aa0a1e58SJeff Roberson void ipoib_ib_dev_flush_normal(struct work_struct *work); 468aa0a1e58SJeff Roberson void ipoib_ib_dev_flush_heavy(struct work_struct *work); 469aa0a1e58SJeff Roberson void ipoib_pkey_event(struct work_struct *work); 470aa0a1e58SJeff Roberson void ipoib_ib_dev_cleanup(struct ipoib_dev_priv *priv); 471aa0a1e58SJeff Roberson 472aa0a1e58SJeff Roberson int ipoib_ib_dev_open(struct ipoib_dev_priv *priv); 473aa0a1e58SJeff Roberson int ipoib_ib_dev_up(struct ipoib_dev_priv *priv); 474aa0a1e58SJeff Roberson int ipoib_ib_dev_down(struct ipoib_dev_priv *priv, int flush); 475aa0a1e58SJeff Roberson int ipoib_ib_dev_stop(struct ipoib_dev_priv *priv, int flush); 476aa0a1e58SJeff Roberson 477aa0a1e58SJeff Roberson int ipoib_dev_init(struct ipoib_dev_priv *priv, struct ib_device *ca, int port); 478aa0a1e58SJeff Roberson void ipoib_dev_cleanup(struct ipoib_dev_priv *priv); 479aa0a1e58SJeff Roberson 480aa0a1e58SJeff Roberson void ipoib_mcast_join_task(struct work_struct *work); 481aa0a1e58SJeff Roberson void ipoib_mcast_carrier_on_task(struct work_struct *work); 482aa0a1e58SJeff Roberson void ipoib_mcast_send(struct ipoib_dev_priv *priv, void *mgid, struct mbuf *mb); 483aa0a1e58SJeff Roberson 484aa0a1e58SJeff Roberson void ipoib_mcast_restart_task(struct work_struct *work); 485aa0a1e58SJeff Roberson void ipoib_mcast_restart(struct ipoib_dev_priv *); 486aa0a1e58SJeff Roberson int ipoib_mcast_start_thread(struct ipoib_dev_priv *priv); 487aa0a1e58SJeff Roberson int ipoib_mcast_stop_thread(struct ipoib_dev_priv *priv, int flush); 488aa0a1e58SJeff Roberson 489aa0a1e58SJeff Roberson void ipoib_mcast_dev_down(struct ipoib_dev_priv *priv); 490aa0a1e58SJeff Roberson void ipoib_mcast_dev_flush(struct ipoib_dev_priv *priv); 491aa0a1e58SJeff Roberson 492aa0a1e58SJeff Roberson void ipoib_path_free(struct ipoib_dev_priv *priv, struct ipoib_path *path); 493aa0a1e58SJeff Roberson #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG 494aa0a1e58SJeff Roberson struct ipoib_mcast_iter *ipoib_mcast_iter_init(struct ipoib_dev_priv *priv); 495aa0a1e58SJeff Roberson int ipoib_mcast_iter_next(struct ipoib_mcast_iter *iter); 496aa0a1e58SJeff Roberson void ipoib_mcast_iter_read(struct ipoib_mcast_iter *iter, 497aa0a1e58SJeff Roberson union ib_gid *gid, 498aa0a1e58SJeff Roberson unsigned long *created, 499aa0a1e58SJeff Roberson unsigned int *queuelen, 500aa0a1e58SJeff Roberson unsigned int *complete, 501aa0a1e58SJeff Roberson unsigned int *send_only); 502aa0a1e58SJeff Roberson 503aa0a1e58SJeff Roberson struct ipoib_path_iter *ipoib_path_iter_init(struct ipoib_dev_priv *priv); 504aa0a1e58SJeff Roberson int ipoib_path_iter_next(struct ipoib_path_iter *iter); 505aa0a1e58SJeff Roberson void ipoib_path_iter_read(struct ipoib_path_iter *iter, 506aa0a1e58SJeff Roberson struct ipoib_path *path); 507aa0a1e58SJeff Roberson #endif 508aa0a1e58SJeff Roberson 509099ad46eSSlava Shwartsman int ipoib_change_mtu(struct ipoib_dev_priv *priv, int new_mtu, bool propagate); 510aa0a1e58SJeff Roberson 511aa0a1e58SJeff Roberson int ipoib_mcast_attach(struct ipoib_dev_priv *priv, u16 mlid, 512aa0a1e58SJeff Roberson union ib_gid *mgid, int set_qkey); 513aa0a1e58SJeff Roberson 514aa0a1e58SJeff Roberson int ipoib_init_qp(struct ipoib_dev_priv *priv); 515aa0a1e58SJeff Roberson int ipoib_transport_dev_init(struct ipoib_dev_priv *priv, struct ib_device *ca); 516aa0a1e58SJeff Roberson void ipoib_transport_dev_cleanup(struct ipoib_dev_priv *priv); 517aa0a1e58SJeff Roberson 518aa0a1e58SJeff Roberson void ipoib_event(struct ib_event_handler *handler, 519aa0a1e58SJeff Roberson struct ib_event *record); 520aa0a1e58SJeff Roberson 521aa0a1e58SJeff Roberson void ipoib_pkey_poll(struct work_struct *work); 522aa0a1e58SJeff Roberson int ipoib_pkey_dev_delay_open(struct ipoib_dev_priv *priv); 523aa0a1e58SJeff Roberson void ipoib_drain_cq(struct ipoib_dev_priv *priv); 524aa0a1e58SJeff Roberson 525aa0a1e58SJeff Roberson int ipoib_dma_map_tx(struct ib_device *ca, struct ipoib_tx_buf *tx_req, int max); 526aa0a1e58SJeff Roberson void ipoib_dma_unmap_tx(struct ib_device *ca, struct ipoib_tx_buf *tx_req); 5276fe20cefSHans Petter Selasky int ipoib_poll_tx(struct ipoib_dev_priv *priv, bool do_start); 528aa0a1e58SJeff Roberson 529aa0a1e58SJeff Roberson void ipoib_dma_unmap_rx(struct ipoib_dev_priv *priv, struct ipoib_rx_buf *rx_req); 530aa0a1e58SJeff Roberson void ipoib_dma_mb(struct ipoib_dev_priv *priv, struct mbuf *mb, unsigned int length); 5314e38478cSHans Petter Selasky struct mbuf *ipoib_alloc_map_mb(struct ipoib_dev_priv *priv, struct ipoib_rx_buf *rx_req, int align, int size, int max_frags); 532aa0a1e58SJeff Roberson 533aa0a1e58SJeff Roberson 5343e142e07SJustin Hibbits void ipoib_set_ethtool_ops(if_t dev); 535aa0a1e58SJeff Roberson int ipoib_set_dev_features(struct ipoib_dev_priv *priv, struct ib_device *hca); 536aa0a1e58SJeff Roberson 537aa0a1e58SJeff Roberson #ifdef CONFIG_INFINIBAND_IPOIB_CM 538aa0a1e58SJeff Roberson 539aa0a1e58SJeff Roberson #define IPOIB_FLAGS_RC 0x80 540aa0a1e58SJeff Roberson #define IPOIB_FLAGS_UC 0x40 541aa0a1e58SJeff Roberson 542aa0a1e58SJeff Roberson /* We don't support UC connections at the moment */ 543aa0a1e58SJeff Roberson #define IPOIB_CM_SUPPORTED(ha) (ha[0] & (IPOIB_FLAGS_RC)) 544aa0a1e58SJeff Roberson 545aa0a1e58SJeff Roberson extern int ipoib_max_conn_qp; 546aa0a1e58SJeff Roberson 547aa0a1e58SJeff Roberson static inline int ipoib_cm_admin_enabled(struct ipoib_dev_priv *priv) 548aa0a1e58SJeff Roberson { 5493e142e07SJustin Hibbits return IPOIB_CM_SUPPORTED(if_getlladdr(priv->dev)); 550aa0a1e58SJeff Roberson } 551aa0a1e58SJeff Roberson 552aa0a1e58SJeff Roberson static inline int ipoib_cm_enabled(struct ipoib_dev_priv *priv, uint8_t *hwaddr) 553aa0a1e58SJeff Roberson { 554aa0a1e58SJeff Roberson return IPOIB_CM_SUPPORTED(hwaddr); 555aa0a1e58SJeff Roberson } 556aa0a1e58SJeff Roberson 557aa0a1e58SJeff Roberson static inline int ipoib_cm_up(struct ipoib_path *path) 558aa0a1e58SJeff Roberson 559aa0a1e58SJeff Roberson { 560aa0a1e58SJeff Roberson return test_bit(IPOIB_FLAG_OPER_UP, &path->cm->flags); 561aa0a1e58SJeff Roberson } 562aa0a1e58SJeff Roberson 563aa0a1e58SJeff Roberson static inline struct ipoib_cm_tx *ipoib_cm_get(struct ipoib_path *path) 564aa0a1e58SJeff Roberson { 565aa0a1e58SJeff Roberson return path->cm; 566aa0a1e58SJeff Roberson } 567aa0a1e58SJeff Roberson 568aa0a1e58SJeff Roberson static inline void ipoib_cm_set(struct ipoib_path *path, struct ipoib_cm_tx *tx) 569aa0a1e58SJeff Roberson { 570aa0a1e58SJeff Roberson path->cm = tx; 571aa0a1e58SJeff Roberson } 572aa0a1e58SJeff Roberson 573aa0a1e58SJeff Roberson static inline int ipoib_cm_has_srq(struct ipoib_dev_priv *priv) 574aa0a1e58SJeff Roberson { 575aa0a1e58SJeff Roberson return !!priv->cm.srq; 576aa0a1e58SJeff Roberson } 577aa0a1e58SJeff Roberson 578aa0a1e58SJeff Roberson static inline unsigned int ipoib_cm_max_mtu(struct ipoib_dev_priv *priv) 579aa0a1e58SJeff Roberson { 580aa0a1e58SJeff Roberson return priv->cm.max_cm_mtu; 581aa0a1e58SJeff Roberson } 582aa0a1e58SJeff Roberson 583aa0a1e58SJeff Roberson void ipoib_cm_send(struct ipoib_dev_priv *priv, struct mbuf *mb, struct ipoib_cm_tx *tx); 584aa0a1e58SJeff Roberson int ipoib_cm_dev_open(struct ipoib_dev_priv *priv); 585aa0a1e58SJeff Roberson void ipoib_cm_dev_stop(struct ipoib_dev_priv *priv); 586aa0a1e58SJeff Roberson int ipoib_cm_dev_init(struct ipoib_dev_priv *priv); 587aa0a1e58SJeff Roberson int ipoib_cm_add_mode_attr(struct ipoib_dev_priv *priv); 588aa0a1e58SJeff Roberson void ipoib_cm_dev_cleanup(struct ipoib_dev_priv *priv); 589aa0a1e58SJeff Roberson struct ipoib_cm_tx *ipoib_cm_create_tx(struct ipoib_dev_priv *priv, 590aa0a1e58SJeff Roberson struct ipoib_path *path); 591aa0a1e58SJeff Roberson void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx); 592aa0a1e58SJeff Roberson void ipoib_cm_mb_too_long(struct ipoib_dev_priv *priv, struct mbuf *mb, 593aa0a1e58SJeff Roberson unsigned int mtu); 594aa0a1e58SJeff Roberson void ipoib_cm_handle_rx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc); 595aa0a1e58SJeff Roberson void ipoib_cm_handle_tx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc); 596aa0a1e58SJeff Roberson #else 597aa0a1e58SJeff Roberson 598aa0a1e58SJeff Roberson struct ipoib_cm_tx; 599aa0a1e58SJeff Roberson 600aa0a1e58SJeff Roberson #define ipoib_max_conn_qp 0 601aa0a1e58SJeff Roberson 602aa0a1e58SJeff Roberson static inline int ipoib_cm_admin_enabled(struct ipoib_dev_priv *priv) 603aa0a1e58SJeff Roberson { 604aa0a1e58SJeff Roberson return 0; 605aa0a1e58SJeff Roberson } 606aa0a1e58SJeff Roberson static inline int ipoib_cm_enabled(struct ipoib_dev_priv *priv, uint8_t *hwaddr) 607aa0a1e58SJeff Roberson 608aa0a1e58SJeff Roberson { 609aa0a1e58SJeff Roberson return 0; 610aa0a1e58SJeff Roberson } 611aa0a1e58SJeff Roberson 612aa0a1e58SJeff Roberson static inline int ipoib_cm_up(struct ipoib_path *path) 613aa0a1e58SJeff Roberson 614aa0a1e58SJeff Roberson { 615aa0a1e58SJeff Roberson return 0; 616aa0a1e58SJeff Roberson } 617aa0a1e58SJeff Roberson 618aa0a1e58SJeff Roberson static inline struct ipoib_cm_tx *ipoib_cm_get(struct ipoib_path *path) 619aa0a1e58SJeff Roberson { 620aa0a1e58SJeff Roberson return NULL; 621aa0a1e58SJeff Roberson } 622aa0a1e58SJeff Roberson 623aa0a1e58SJeff Roberson static inline void ipoib_cm_set(struct ipoib_path *path, struct ipoib_cm_tx *tx) 624aa0a1e58SJeff Roberson { 625aa0a1e58SJeff Roberson } 626aa0a1e58SJeff Roberson 627aa0a1e58SJeff Roberson static inline int ipoib_cm_has_srq(struct ipoib_dev_priv *priv) 628aa0a1e58SJeff Roberson { 629aa0a1e58SJeff Roberson return 0; 630aa0a1e58SJeff Roberson } 631aa0a1e58SJeff Roberson 632aa0a1e58SJeff Roberson static inline unsigned int ipoib_cm_max_mtu(struct ipoib_dev_priv *priv) 633aa0a1e58SJeff Roberson { 634aa0a1e58SJeff Roberson return 0; 635aa0a1e58SJeff Roberson } 636aa0a1e58SJeff Roberson 637aa0a1e58SJeff Roberson static inline 638aa0a1e58SJeff Roberson void ipoib_cm_send(struct ipoib_dev_priv *priv, struct mbuf *mb, struct ipoib_cm_tx *tx) 639aa0a1e58SJeff Roberson { 640aa0a1e58SJeff Roberson return; 641aa0a1e58SJeff Roberson } 642aa0a1e58SJeff Roberson 643aa0a1e58SJeff Roberson static inline 644aa0a1e58SJeff Roberson int ipoib_cm_dev_open(struct ipoib_dev_priv *priv) 645aa0a1e58SJeff Roberson { 646aa0a1e58SJeff Roberson return 0; 647aa0a1e58SJeff Roberson } 648aa0a1e58SJeff Roberson 649aa0a1e58SJeff Roberson static inline 650aa0a1e58SJeff Roberson void ipoib_cm_dev_stop(struct ipoib_dev_priv *priv) 651aa0a1e58SJeff Roberson { 652aa0a1e58SJeff Roberson return; 653aa0a1e58SJeff Roberson } 654aa0a1e58SJeff Roberson 655aa0a1e58SJeff Roberson static inline 656aa0a1e58SJeff Roberson int ipoib_cm_dev_init(struct ipoib_dev_priv *priv) 657aa0a1e58SJeff Roberson { 658aa0a1e58SJeff Roberson return -ENOSYS; 659aa0a1e58SJeff Roberson } 660aa0a1e58SJeff Roberson 661aa0a1e58SJeff Roberson static inline 662aa0a1e58SJeff Roberson void ipoib_cm_dev_cleanup(struct ipoib_dev_priv *priv) 663aa0a1e58SJeff Roberson { 664aa0a1e58SJeff Roberson return; 665aa0a1e58SJeff Roberson } 666aa0a1e58SJeff Roberson 667aa0a1e58SJeff Roberson static inline 668aa0a1e58SJeff Roberson struct ipoib_cm_tx *ipoib_cm_create_tx(struct ipoib_dev_priv *priv, struct ipoib_path *path) 669aa0a1e58SJeff Roberson { 670aa0a1e58SJeff Roberson return NULL; 671aa0a1e58SJeff Roberson } 672aa0a1e58SJeff Roberson 673aa0a1e58SJeff Roberson static inline 674aa0a1e58SJeff Roberson void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx) 675aa0a1e58SJeff Roberson { 676aa0a1e58SJeff Roberson return; 677aa0a1e58SJeff Roberson } 678aa0a1e58SJeff Roberson 679aa0a1e58SJeff Roberson static inline 680aa0a1e58SJeff Roberson int ipoib_cm_add_mode_attr(struct ipoib_dev_priv *priv) 681aa0a1e58SJeff Roberson { 682aa0a1e58SJeff Roberson return 0; 683aa0a1e58SJeff Roberson } 684aa0a1e58SJeff Roberson 685aa0a1e58SJeff Roberson static inline void ipoib_cm_mb_too_long(struct ipoib_dev_priv *priv, struct mbuf *mb, 686aa0a1e58SJeff Roberson unsigned int mtu) 687aa0a1e58SJeff Roberson { 688aa0a1e58SJeff Roberson m_freem(mb); 689aa0a1e58SJeff Roberson } 690aa0a1e58SJeff Roberson 691aa0a1e58SJeff Roberson static inline void ipoib_cm_handle_rx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc) 692aa0a1e58SJeff Roberson { 693aa0a1e58SJeff Roberson } 694aa0a1e58SJeff Roberson 695aa0a1e58SJeff Roberson static inline void ipoib_cm_handle_tx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc) 696aa0a1e58SJeff Roberson { 697aa0a1e58SJeff Roberson } 698aa0a1e58SJeff Roberson #endif 699aa0a1e58SJeff Roberson 700aa0a1e58SJeff Roberson #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG 701aa0a1e58SJeff Roberson void ipoib_create_debug_files(struct ipoib_dev_priv *priv); 702aa0a1e58SJeff Roberson void ipoib_delete_debug_files(struct ipoib_dev_priv *priv); 703aa0a1e58SJeff Roberson int ipoib_register_debugfs(void); 704aa0a1e58SJeff Roberson void ipoib_unregister_debugfs(void); 705aa0a1e58SJeff Roberson #else 706aa0a1e58SJeff Roberson static inline void ipoib_create_debug_files(struct ipoib_dev_priv *priv) { } 707aa0a1e58SJeff Roberson static inline void ipoib_delete_debug_files(struct ipoib_dev_priv *priv) { } 708aa0a1e58SJeff Roberson static inline int ipoib_register_debugfs(void) { return 0; } 709aa0a1e58SJeff Roberson static inline void ipoib_unregister_debugfs(void) { } 710aa0a1e58SJeff Roberson #endif 711aa0a1e58SJeff Roberson 712aa0a1e58SJeff Roberson #define ipoib_printk(level, priv, format, arg...) \ 713aa0a1e58SJeff Roberson printk(level "%s: " format, if_name(((struct ipoib_dev_priv *) priv)->dev), ## arg) 714aa0a1e58SJeff Roberson #define ipoib_warn(priv, format, arg...) \ 715aa0a1e58SJeff Roberson ipoib_printk(KERN_WARNING, priv, format , ## arg) 716aa0a1e58SJeff Roberson 717aa0a1e58SJeff Roberson extern int ipoib_sendq_size; 718aa0a1e58SJeff Roberson extern int ipoib_recvq_size; 719aa0a1e58SJeff Roberson 720aa0a1e58SJeff Roberson extern struct ib_sa_client ipoib_sa_client; 721aa0a1e58SJeff Roberson 722aa0a1e58SJeff Roberson #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG 723aa0a1e58SJeff Roberson extern int ipoib_debug_level; 724aa0a1e58SJeff Roberson 725aa0a1e58SJeff Roberson #define ipoib_dbg(priv, format, arg...) \ 726aa0a1e58SJeff Roberson do { \ 727aa0a1e58SJeff Roberson if (ipoib_debug_level > 0) \ 728aa0a1e58SJeff Roberson ipoib_printk(KERN_DEBUG, priv, format , ## arg); \ 729aa0a1e58SJeff Roberson } while (0) 730aa0a1e58SJeff Roberson #define ipoib_dbg_mcast(priv, format, arg...) \ 731aa0a1e58SJeff Roberson do { \ 732aa0a1e58SJeff Roberson if (mcast_debug_level > 0) \ 733aa0a1e58SJeff Roberson ipoib_printk(KERN_DEBUG, priv, format , ## arg); \ 734aa0a1e58SJeff Roberson } while (0) 735aa0a1e58SJeff Roberson #else /* CONFIG_INFINIBAND_IPOIB_DEBUG */ 736aa0a1e58SJeff Roberson #define ipoib_dbg(priv, format, arg...) \ 737aa0a1e58SJeff Roberson do { (void) (priv); } while (0) 738aa0a1e58SJeff Roberson #define ipoib_dbg_mcast(priv, format, arg...) \ 739aa0a1e58SJeff Roberson do { (void) (priv); } while (0) 740aa0a1e58SJeff Roberson #endif /* CONFIG_INFINIBAND_IPOIB_DEBUG */ 741aa0a1e58SJeff Roberson 742aa0a1e58SJeff Roberson #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG_DATA 743aa0a1e58SJeff Roberson #define ipoib_dbg_data(priv, format, arg...) \ 744aa0a1e58SJeff Roberson do { \ 745aa0a1e58SJeff Roberson if (data_debug_level > 0) \ 746aa0a1e58SJeff Roberson ipoib_printk(KERN_DEBUG, priv, format , ## arg); \ 747aa0a1e58SJeff Roberson } while (0) 748aa0a1e58SJeff Roberson #else /* CONFIG_INFINIBAND_IPOIB_DEBUG_DATA */ 749aa0a1e58SJeff Roberson #define ipoib_dbg_data(priv, format, arg...) \ 750aa0a1e58SJeff Roberson do { (void) (priv); } while (0) 751aa0a1e58SJeff Roberson #endif /* CONFIG_INFINIBAND_IPOIB_DEBUG_DATA */ 752aa0a1e58SJeff Roberson 753aa0a1e58SJeff Roberson #define IPOIB_QPN(ha) (be32_to_cpup((__be32 *) ha) & 0xffffff) 754aa0a1e58SJeff Roberson 7553e142e07SJustin Hibbits void ipoib_start_locked(if_t, struct ipoib_dev_priv *); 7566fe20cefSHans Petter Selasky 757aa0a1e58SJeff Roberson #endif /* _IPOIB_H */ 758