Path: blob/main/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h
39566 views
/*-1* SPDX-License-Identifier: BSD-2-Clause OR GPL-2.02*3* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.4* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.5* Copyright (c) 2004 Voltaire, Inc. All rights reserved.6*7* This software is available to you under a choice of one of two8* licenses. You may choose to be licensed under the terms of the GNU9* General Public License (GPL) Version 2, available from the file10* COPYING in the main directory of this source tree, or the11* OpenIB.org BSD license below:12*13* Redistribution and use in source and binary forms, with or14* without modification, are permitted provided that the following15* conditions are met:16*17* - Redistributions of source code must retain the above18* copyright notice, this list of conditions and the following19* disclaimer.20*21* - Redistributions in binary form must reproduce the above22* copyright notice, this list of conditions and the following23* disclaimer in the documentation and/or other materials24* provided with the distribution.25*26* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,27* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF28* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND29* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS30* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN31* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN32* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE33* SOFTWARE.34*/3536#ifndef _IPOIB_H37#define _IPOIB_H3839#define LINUXKPI_PARAM_PREFIX ipoib_4041#include "opt_inet.h"42#include "opt_inet6.h"43#include "opt_ofed.h"4445#include <sys/param.h>46#include <sys/systm.h>47#include <sys/kernel.h>48#include <sys/lock.h>49#include <sys/malloc.h>50#include <sys/mbuf.h>51#include <sys/random.h>52#include <sys/rwlock.h>53#include <sys/socket.h>54#include <sys/sockio.h>55#include <sys/sysctl.h>5657#include <net/if.h>58#include <net/if_var.h>59#include <net/if_arp.h>60#include <net/netisr.h>61#include <net/route.h>62#include <net/if_llc.h>63#include <net/if_dl.h>64#include <net/if_types.h>65#include <net/bpf.h>66#include <net/if_llatbl.h>67#include <net/vnet.h>6869#if defined(INET) || defined(INET6)70#include <netinet/in.h>71#include <netinet/in_var.h>72#include <netinet/if_ether.h>73#include <netinet/ip_var.h>74#endif75#ifdef INET676#include <netinet6/nd6.h>77#endif7879#include <security/mac/mac_framework.h>8081#include <linux/list.h>8283#include <linux/workqueue.h>84#include <linux/kref.h>85#include <linux/mutex.h>86#include <linux/rbtree.h>8788#include <asm/atomic.h>8990#include <rdma/ib_verbs.h>91#include <rdma/ib_pack.h>92#include <rdma/ib_sa.h>9394/* constants */9596#define INFINIBAND_ALEN 20 /* Octets in IPoIB HW addr */9798#ifdef IPOIB_CM99#define CONFIG_INFINIBAND_IPOIB_CM100#endif101102#ifdef IPOIB_DEBUG103#define CONFIG_INFINIBAND_IPOIB_DEBUG104#define CONFIG_INFINIBAND_IPOIB_DEBUG_DATA105#endif106107enum ipoib_flush_level {108IPOIB_FLUSH_LIGHT,109IPOIB_FLUSH_NORMAL,110IPOIB_FLUSH_HEAVY111};112113enum {114IPOIB_ENCAP_LEN = 4,115IPOIB_HEADER_LEN = IPOIB_ENCAP_LEN + INFINIBAND_ALEN,116IPOIB_UD_MAX_MTU = 4 * 1024,117IPOIB_UD_RX_SG = 2, /* packet header and one cluster */118IPOIB_UD_TX_SG = (IPOIB_UD_MAX_MTU / MCLBYTES) + 2,119IPOIB_CM_MAX_MTU = (64 * 1024),120IPOIB_CM_TX_SG = (IPOIB_CM_MAX_MTU / MCLBYTES) + 2,121IPOIB_CM_RX_SG = (IPOIB_CM_MAX_MTU / MCLBYTES) + 2,122IPOIB_RX_RING_SIZE = 256,123IPOIB_TX_RING_SIZE = 128,124IPOIB_MAX_RX_SG = MAX(IPOIB_CM_RX_SG, IPOIB_UD_RX_SG),125IPOIB_MAX_TX_SG = MAX(IPOIB_CM_TX_SG, IPOIB_UD_TX_SG),126IPOIB_MAX_QUEUE_SIZE = 8192,127IPOIB_MIN_QUEUE_SIZE = 2,128IPOIB_CM_MAX_CONN_QP = 4096,129130IPOIB_NUM_WC = 4,131132IPOIB_MAX_PATH_REC_QUEUE = 16,133IPOIB_MAX_MCAST_QUEUE = 16,134135IPOIB_FLAG_OPER_UP = 0,136IPOIB_FLAG_INITIALIZED = 1,137IPOIB_FLAG_ADMIN_UP = 2,138IPOIB_PKEY_ASSIGNED = 3,139IPOIB_PKEY_STOP = 4,140IPOIB_FLAG_SUBINTERFACE = 5,141IPOIB_MCAST_RUN = 6,142IPOIB_STOP_REAPER = 7,143IPOIB_FLAG_UMCAST = 10,144IPOIB_FLAG_CSUM = 11,145146IPOIB_MAX_BACKOFF_SECONDS = 16,147148IPOIB_MCAST_FLAG_FOUND = 0, /* used in set_multicast_list */149IPOIB_MCAST_FLAG_SENDONLY = 1,150IPOIB_MCAST_FLAG_BUSY = 2, /* joining or already joined */151IPOIB_MCAST_FLAG_ATTACHED = 3,152153IPOIB_MAX_LRO_DESCRIPTORS = 8,154IPOIB_LRO_MAX_AGGR = 64,155156MAX_SEND_CQE = 16,157IPOIB_CM_COPYBREAK = 256,158};159160#define IPOIB_OP_RECV (1ul << 31)161#ifdef CONFIG_INFINIBAND_IPOIB_CM162#define IPOIB_OP_CM (1ul << 30)163#else164#define IPOIB_OP_CM (0)165#endif166167/* structs */168169struct ipoib_header {170u8 hwaddr[INFINIBAND_ALEN];171__be16 proto;172u16 reserved;173};174175struct ipoib_pseudoheader {176u8 hwaddr[INFINIBAND_ALEN];177};178179/* Used for all multicast joins (broadcast, IPv4 mcast and IPv6 mcast) */180struct ipoib_mcast {181struct ib_sa_mcmember_rec mcmember;182struct ib_sa_multicast *mc;183struct ipoib_ah *ah;184185struct rb_node rb_node;186struct list_head list;187188unsigned long created;189unsigned long backoff;190191unsigned long flags;192unsigned char logcount;193194struct ifqueue pkt_queue;195196struct ipoib_dev_priv *priv;197};198199struct ipoib_cm_rx_buf {200struct mbuf *mb;201u64 mapping[IPOIB_CM_RX_SG];202};203204struct ipoib_cm_tx_buf {205struct mbuf *mb;206u64 mapping[IPOIB_CM_TX_SG];207};208209struct ipoib_rx_buf {210struct mbuf *mb;211u64 mapping[IPOIB_UD_RX_SG];212};213214struct ipoib_tx_buf {215struct mbuf *mb;216u64 mapping[IPOIB_UD_TX_SG];217};218219struct ib_cm_id;220221struct ipoib_cm_data {222__be32 qpn; /* High byte MUST be ignored on receive */223__be32 mtu;224};225226/*227* Quoting 10.3.1 Queue Pair and EE Context States:228*229* Note, for QPs that are associated with an SRQ, the Consumer should take the230* QP through the Error State before invoking a Destroy QP or a Modify QP to the231* Reset State. The Consumer may invoke the Destroy QP without first performing232* a Modify QP to the Error State and waiting for the Affiliated Asynchronous233* Last WQE Reached Event. However, if the Consumer does not wait for the234* Affiliated Asynchronous Last WQE Reached Event, then WQE and Data Segment235* leakage may occur. Therefore, it is good programming practice to tear down a236* QP that is associated with an SRQ by using the following process:237*238* - Put the QP in the Error State239* - Wait for the Affiliated Asynchronous Last WQE Reached Event;240* - either:241* drain the CQ by invoking the Poll CQ verb and either wait for CQ242* to be empty or the number of Poll CQ operations has exceeded243* CQ capacity size;244* - or245* post another WR that completes on the same CQ and wait for this246* WR to return as a WC;247* - and then invoke a Destroy QP or Reset QP.248*249* We use the second option and wait for a completion on the250* same CQ before destroying QPs attached to our SRQ.251*/252253enum ipoib_cm_state {254IPOIB_CM_RX_LIVE,255IPOIB_CM_RX_ERROR, /* Ignored by stale task */256IPOIB_CM_RX_FLUSH /* Last WQE Reached event observed */257};258259struct ipoib_cm_rx {260struct ib_cm_id *id;261struct ib_qp *qp;262struct ipoib_cm_rx_buf *rx_ring;263struct list_head list;264struct ipoib_dev_priv *priv;265unsigned long jiffies;266enum ipoib_cm_state state;267int recv_count;268};269270struct ipoib_cm_tx {271struct ib_cm_id *id;272struct ib_qp *qp;273struct list_head list;274struct ipoib_dev_priv *priv;275struct ipoib_path *path;276struct ipoib_cm_tx_buf *tx_ring;277unsigned tx_head;278unsigned tx_tail;279unsigned long flags;280u32 mtu; /* remote specified mtu, with grh. */281};282283struct ipoib_cm_dev_priv {284struct ib_srq *srq;285struct ipoib_cm_rx_buf *srq_ring;286struct ib_cm_id *id;287struct list_head passive_ids; /* state: LIVE */288struct list_head rx_error_list; /* state: ERROR */289struct list_head rx_flush_list; /* state: FLUSH, drain not started */290struct list_head rx_drain_list; /* state: FLUSH, drain started */291struct list_head rx_reap_list; /* state: FLUSH, drain done */292struct work_struct start_task;293struct work_struct reap_task;294struct work_struct mb_task;295struct work_struct rx_reap_task;296struct delayed_work stale_task;297struct ifqueue mb_queue;298struct list_head start_list;299struct list_head reap_list;300struct ib_sge rx_sge[IPOIB_CM_RX_SG];301struct ib_recv_wr rx_wr;302int nonsrq_conn_qp;303int max_cm_mtu; /* Actual buf size. */304int num_frags;305};306307struct ipoib_ethtool_st {308u16 coalesce_usecs;309u16 max_coalesced_frames;310};311312/*313* Device private locking: network stack tx_lock protects members used314* in TX fast path, lock protects everything else. lock nests inside315* of tx_lock (ie tx_lock must be acquired first if needed).316*/317struct ipoib_dev_priv {318spinlock_t lock;319spinlock_t drain_lock;320321if_t dev;322323u8 broadcastaddr[INFINIBAND_ALEN];324325unsigned long flags;326327int gone;328int unit;329330struct mutex vlan_mutex;331332struct rb_root path_tree;333struct list_head path_list;334335struct ipoib_mcast *broadcast;336struct list_head multicast_list;337struct rb_root multicast_tree;338339struct delayed_work pkey_poll_task;340struct delayed_work mcast_task;341struct work_struct carrier_on_task;342struct work_struct flush_light;343struct work_struct flush_normal;344struct work_struct flush_heavy;345struct work_struct restart_task;346struct delayed_work ah_reap_task;347348struct ib_device *ca;349u8 port;350u16 pkey;351u16 pkey_index;352struct ib_pd *pd;353struct ib_cq *recv_cq;354struct ib_cq *send_cq;355struct ib_qp *qp;356u32 qkey;357358union ib_gid local_gid;359u16 local_lid;360361unsigned int admin_mtu; /* User selected MTU, no GRH. */362unsigned int mcast_mtu; /* Minus GRH bytes, from mcast group. */363unsigned int max_ib_mtu; /* Without header, actual buf size. */364365struct ipoib_rx_buf *rx_ring;366367struct ipoib_tx_buf *tx_ring;368unsigned tx_head;369unsigned tx_tail;370struct ib_sge tx_sge[IPOIB_MAX_TX_SG];371struct ib_ud_wr tx_wr;372unsigned tx_outstanding;373struct ib_wc send_wc[MAX_SEND_CQE];374375struct ib_recv_wr rx_wr;376struct ib_sge rx_sge[IPOIB_MAX_RX_SG];377378struct ib_wc ibwc[IPOIB_NUM_WC];379380struct list_head dead_ahs;381382struct ib_event_handler event_handler;383384if_t parent;385struct list_head child_intfs;386struct list_head list;387388#ifdef CONFIG_INFINIBAND_IPOIB_CM389struct ipoib_cm_dev_priv cm;390#endif391392#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG393struct list_head fs_list;394struct dentry *mcg_dentry;395struct dentry *path_dentry;396#endif397int hca_caps;398struct ipoib_ethtool_st ethtool;399struct timer_list poll_timer;400};401402struct ipoib_ah {403struct ipoib_dev_priv *priv;404struct ib_ah *ah;405struct list_head list;406struct kref ref;407unsigned last_send;408};409410struct ipoib_path {411struct ipoib_dev_priv *priv;412struct rb_node rb_node;413struct list_head list;414#ifdef CONFIG_INFINIBAND_IPOIB_CM415uint8_t hwaddr[INFINIBAND_ALEN];416struct ipoib_cm_tx *cm;417#endif418struct ipoib_ah *ah;419struct ib_sa_path_rec pathrec;420struct ifqueue queue;421422int query_id;423struct ib_sa_query *query;424struct completion done;425426int valid;427};428429/* UD Only transmits encap len but we want the two sizes to be symmetrical. */430#define IPOIB_UD_MTU(ib_mtu) (ib_mtu - IPOIB_ENCAP_LEN)431#define IPOIB_CM_MTU(ib_mtu) (ib_mtu - 0x10)432433#define IPOIB_IS_MULTICAST(addr) ((addr)[4] == 0xff)434435extern struct workqueue_struct *ipoib_workqueue;436437/* functions */438void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr);439void ipoib_send_comp_handler(struct ib_cq *cq, void *dev_ptr);440441struct ipoib_ah *ipoib_create_ah(struct ipoib_dev_priv *,442struct ib_pd *pd, struct ib_ah_attr *attr);443void ipoib_free_ah(struct kref *kref);444static inline void ipoib_put_ah(struct ipoib_ah *ah)445{446kref_put(&ah->ref, ipoib_free_ah);447}448449int ipoib_open(struct ipoib_dev_priv *priv);450int ipoib_add_pkey_attr(struct ipoib_dev_priv *priv);451int ipoib_add_umcast_attr(struct ipoib_dev_priv *priv);452453void ipoib_send(struct ipoib_dev_priv *priv, struct mbuf *mb,454struct ipoib_ah *address, u32 qpn);455void ipoib_reap_ah(struct work_struct *work);456457void ipoib_mark_paths_invalid(struct ipoib_dev_priv *priv);458void ipoib_flush_paths(struct ipoib_dev_priv *priv);459struct ipoib_dev_priv *ipoib_intf_alloc(const char *format, struct ib_device *ca);460461int ipoib_ib_dev_init(struct ipoib_dev_priv *priv, struct ib_device *ca,462int port);463void ipoib_ib_dev_flush_light(struct work_struct *work);464void ipoib_ib_dev_flush_normal(struct work_struct *work);465void ipoib_ib_dev_flush_heavy(struct work_struct *work);466void ipoib_pkey_event(struct work_struct *work);467void ipoib_ib_dev_cleanup(struct ipoib_dev_priv *priv);468469int ipoib_ib_dev_open(struct ipoib_dev_priv *priv);470int ipoib_ib_dev_up(struct ipoib_dev_priv *priv);471int ipoib_ib_dev_down(struct ipoib_dev_priv *priv, int flush);472int ipoib_ib_dev_stop(struct ipoib_dev_priv *priv, int flush);473474int ipoib_dev_init(struct ipoib_dev_priv *priv, struct ib_device *ca, int port);475void ipoib_dev_cleanup(struct ipoib_dev_priv *priv);476477void ipoib_mcast_join_task(struct work_struct *work);478void ipoib_mcast_carrier_on_task(struct work_struct *work);479void ipoib_mcast_send(struct ipoib_dev_priv *priv, void *mgid, struct mbuf *mb);480481void ipoib_mcast_restart_task(struct work_struct *work);482void ipoib_mcast_restart(struct ipoib_dev_priv *);483int ipoib_mcast_start_thread(struct ipoib_dev_priv *priv);484int ipoib_mcast_stop_thread(struct ipoib_dev_priv *priv, int flush);485486void ipoib_mcast_dev_down(struct ipoib_dev_priv *priv);487void ipoib_mcast_dev_flush(struct ipoib_dev_priv *priv);488489void ipoib_path_free(struct ipoib_dev_priv *priv, struct ipoib_path *path);490#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG491struct ipoib_mcast_iter *ipoib_mcast_iter_init(struct ipoib_dev_priv *priv);492int ipoib_mcast_iter_next(struct ipoib_mcast_iter *iter);493void ipoib_mcast_iter_read(struct ipoib_mcast_iter *iter,494union ib_gid *gid,495unsigned long *created,496unsigned int *queuelen,497unsigned int *complete,498unsigned int *send_only);499500struct ipoib_path_iter *ipoib_path_iter_init(struct ipoib_dev_priv *priv);501int ipoib_path_iter_next(struct ipoib_path_iter *iter);502void ipoib_path_iter_read(struct ipoib_path_iter *iter,503struct ipoib_path *path);504#endif505506int ipoib_change_mtu(struct ipoib_dev_priv *priv, int new_mtu, bool propagate);507508int ipoib_mcast_attach(struct ipoib_dev_priv *priv, u16 mlid,509union ib_gid *mgid, int set_qkey);510511int ipoib_init_qp(struct ipoib_dev_priv *priv);512int ipoib_transport_dev_init(struct ipoib_dev_priv *priv, struct ib_device *ca);513void ipoib_transport_dev_cleanup(struct ipoib_dev_priv *priv);514515void ipoib_event(struct ib_event_handler *handler,516struct ib_event *record);517518void ipoib_pkey_poll(struct work_struct *work);519int ipoib_pkey_dev_delay_open(struct ipoib_dev_priv *priv);520void ipoib_drain_cq(struct ipoib_dev_priv *priv);521522int ipoib_dma_map_tx(struct ib_device *ca, struct ipoib_tx_buf *tx_req, int max);523void ipoib_dma_unmap_tx(struct ib_device *ca, struct ipoib_tx_buf *tx_req);524int ipoib_poll_tx(struct ipoib_dev_priv *priv, bool do_start);525526void ipoib_dma_unmap_rx(struct ipoib_dev_priv *priv, struct ipoib_rx_buf *rx_req);527void ipoib_dma_mb(struct ipoib_dev_priv *priv, struct mbuf *mb, unsigned int length);528struct mbuf *ipoib_alloc_map_mb(struct ipoib_dev_priv *priv, struct ipoib_rx_buf *rx_req, int align, int size, int max_frags);529530531void ipoib_set_ethtool_ops(if_t dev);532int ipoib_set_dev_features(struct ipoib_dev_priv *priv, struct ib_device *hca);533534#ifdef CONFIG_INFINIBAND_IPOIB_CM535536#define IPOIB_FLAGS_RC 0x80537#define IPOIB_FLAGS_UC 0x40538539/* We don't support UC connections at the moment */540#define IPOIB_CM_SUPPORTED(ha) (ha[0] & (IPOIB_FLAGS_RC))541542extern int ipoib_max_conn_qp;543544static inline int ipoib_cm_admin_enabled(struct ipoib_dev_priv *priv)545{546return IPOIB_CM_SUPPORTED(if_getlladdr(priv->dev));547}548549static inline int ipoib_cm_enabled(struct ipoib_dev_priv *priv, uint8_t *hwaddr)550{551return IPOIB_CM_SUPPORTED(hwaddr);552}553554static inline int ipoib_cm_up(struct ipoib_path *path)555556{557return test_bit(IPOIB_FLAG_OPER_UP, &path->cm->flags);558}559560static inline struct ipoib_cm_tx *ipoib_cm_get(struct ipoib_path *path)561{562return path->cm;563}564565static inline void ipoib_cm_set(struct ipoib_path *path, struct ipoib_cm_tx *tx)566{567path->cm = tx;568}569570static inline int ipoib_cm_has_srq(struct ipoib_dev_priv *priv)571{572return !!priv->cm.srq;573}574575static inline unsigned int ipoib_cm_max_mtu(struct ipoib_dev_priv *priv)576{577return priv->cm.max_cm_mtu;578}579580void ipoib_cm_send(struct ipoib_dev_priv *priv, struct mbuf *mb, struct ipoib_cm_tx *tx);581int ipoib_cm_dev_open(struct ipoib_dev_priv *priv);582void ipoib_cm_dev_stop(struct ipoib_dev_priv *priv);583int ipoib_cm_dev_init(struct ipoib_dev_priv *priv);584int ipoib_cm_add_mode_attr(struct ipoib_dev_priv *priv);585void ipoib_cm_dev_cleanup(struct ipoib_dev_priv *priv);586struct ipoib_cm_tx *ipoib_cm_create_tx(struct ipoib_dev_priv *priv,587struct ipoib_path *path);588void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx);589void ipoib_cm_mb_too_long(struct ipoib_dev_priv *priv, struct mbuf *mb,590unsigned int mtu);591void ipoib_cm_handle_rx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc);592void ipoib_cm_handle_tx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc);593#else594595struct ipoib_cm_tx;596597#define ipoib_max_conn_qp 0598599static inline int ipoib_cm_admin_enabled(struct ipoib_dev_priv *priv)600{601return 0;602}603static inline int ipoib_cm_enabled(struct ipoib_dev_priv *priv, uint8_t *hwaddr)604605{606return 0;607}608609static inline int ipoib_cm_up(struct ipoib_path *path)610611{612return 0;613}614615static inline struct ipoib_cm_tx *ipoib_cm_get(struct ipoib_path *path)616{617return NULL;618}619620static inline void ipoib_cm_set(struct ipoib_path *path, struct ipoib_cm_tx *tx)621{622}623624static inline int ipoib_cm_has_srq(struct ipoib_dev_priv *priv)625{626return 0;627}628629static inline unsigned int ipoib_cm_max_mtu(struct ipoib_dev_priv *priv)630{631return 0;632}633634static inline635void ipoib_cm_send(struct ipoib_dev_priv *priv, struct mbuf *mb, struct ipoib_cm_tx *tx)636{637return;638}639640static inline641int ipoib_cm_dev_open(struct ipoib_dev_priv *priv)642{643return 0;644}645646static inline647void ipoib_cm_dev_stop(struct ipoib_dev_priv *priv)648{649return;650}651652static inline653int ipoib_cm_dev_init(struct ipoib_dev_priv *priv)654{655return -ENOSYS;656}657658static inline659void ipoib_cm_dev_cleanup(struct ipoib_dev_priv *priv)660{661return;662}663664static inline665struct ipoib_cm_tx *ipoib_cm_create_tx(struct ipoib_dev_priv *priv, struct ipoib_path *path)666{667return NULL;668}669670static inline671void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx)672{673return;674}675676static inline677int ipoib_cm_add_mode_attr(struct ipoib_dev_priv *priv)678{679return 0;680}681682static inline void ipoib_cm_mb_too_long(struct ipoib_dev_priv *priv, struct mbuf *mb,683unsigned int mtu)684{685m_freem(mb);686}687688static inline void ipoib_cm_handle_rx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc)689{690}691692static inline void ipoib_cm_handle_tx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc)693{694}695#endif696697#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG698void ipoib_create_debug_files(struct ipoib_dev_priv *priv);699void ipoib_delete_debug_files(struct ipoib_dev_priv *priv);700int ipoib_register_debugfs(void);701void ipoib_unregister_debugfs(void);702#else703static inline void ipoib_create_debug_files(struct ipoib_dev_priv *priv) { }704static inline void ipoib_delete_debug_files(struct ipoib_dev_priv *priv) { }705static inline int ipoib_register_debugfs(void) { return 0; }706static inline void ipoib_unregister_debugfs(void) { }707#endif708709#define ipoib_printk(level, priv, format, arg...) \710printk(level "%s: " format, if_name(((struct ipoib_dev_priv *) priv)->dev), ## arg)711#define ipoib_warn(priv, format, arg...) \712ipoib_printk(KERN_WARNING, priv, format , ## arg)713714extern int ipoib_sendq_size;715extern int ipoib_recvq_size;716717extern struct ib_sa_client ipoib_sa_client;718719#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG720extern int ipoib_debug_level;721722#define ipoib_dbg(priv, format, arg...) \723do { \724if (ipoib_debug_level > 0) \725ipoib_printk(KERN_DEBUG, priv, format , ## arg); \726} while (0)727#define ipoib_dbg_mcast(priv, format, arg...) \728do { \729if (mcast_debug_level > 0) \730ipoib_printk(KERN_DEBUG, priv, format , ## arg); \731} while (0)732#else /* CONFIG_INFINIBAND_IPOIB_DEBUG */733#define ipoib_dbg(priv, format, arg...) \734do { (void) (priv); } while (0)735#define ipoib_dbg_mcast(priv, format, arg...) \736do { (void) (priv); } while (0)737#endif /* CONFIG_INFINIBAND_IPOIB_DEBUG */738739#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG_DATA740#define ipoib_dbg_data(priv, format, arg...) \741do { \742if (data_debug_level > 0) \743ipoib_printk(KERN_DEBUG, priv, format , ## arg); \744} while (0)745#else /* CONFIG_INFINIBAND_IPOIB_DEBUG_DATA */746#define ipoib_dbg_data(priv, format, arg...) \747do { (void) (priv); } while (0)748#endif /* CONFIG_INFINIBAND_IPOIB_DEBUG_DATA */749750#define IPOIB_QPN(ha) (be32_to_cpup((__be32 *) ha) & 0xffffff)751752void ipoib_start_locked(if_t, struct ipoib_dev_priv *);753754#endif /* _IPOIB_H */755756757