Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright(c) 2016 - 2019 Intel Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #ifndef DEF_RDMA_VT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #define DEF_RDMA_VT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * Structure that low level drivers will populate in order to register with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * rdmavt layer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/hash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <rdma/ib_verbs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <rdma/ib_mad.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <rdma/rdmavt_mr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #define RVT_MAX_PKEY_VALUES 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #define RVT_MAX_TRAP_LEN 100 /* Limit pending trap list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #define RVT_MAX_TRAP_LISTS 5 /*((IB_NOTICE_TYPE_INFO & 0x0F) + 1)*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define RVT_TRAP_TIMEOUT 4096 /* 4.096 usec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) struct trap_list {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	u32 list_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) struct rvt_qp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) struct rvt_qpn_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) struct rvt_ibport {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	struct rvt_qp __rcu *qp[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	struct ib_mad_agent *send_agent;	/* agent for SMI (traps) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	struct rb_root mcast_tree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	spinlock_t lock;		/* protect changes in this struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	/* non-zero when timer is set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	unsigned long mkey_lease_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	unsigned long trap_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	__be64 gid_prefix;      /* in network order */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	__be64 mkey;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	u64 tid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	u32 port_cap_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	u16 port_cap3_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	u32 pma_sample_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	u32 pma_sample_interval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	__be16 pma_counter_select[5];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	u16 pma_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	u16 mkey_lease_period;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	u32 sm_lid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	u8 sm_sl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	u8 mkeyprot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	u8 subnet_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	u8 vl_high_limit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	 * Driver is expected to keep these up to date. These
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	 * counters are informational only and not required to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	 * completely accurate.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	u64 n_rc_resends;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	u64 n_seq_naks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	u64 n_rdma_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	u64 n_rnr_naks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	u64 n_other_naks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	u64 n_loop_pkts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	u64 n_pkt_drops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	u64 n_vl15_dropped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	u64 n_rc_timeouts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	u64 n_dmawait;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	u64 n_unaligned;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	u64 n_rc_dupreq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	u64 n_rc_seqnak;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	u64 n_rc_crwaits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	u16 pkey_violations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	u16 qkey_violations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	u16 mkey_violations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	/* Hot-path per CPU counters to avoid cacheline trading to update */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	u64 z_rc_acks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	u64 z_rc_qacks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	u64 z_rc_delayed_comp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	u64 __percpu *rc_acks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	u64 __percpu *rc_qacks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	u64 __percpu *rc_delayed_comp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	void *priv; /* driver private data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	 * The pkey table is allocated and maintained by the driver. Drivers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	 * need to have access to this before registering with rdmav. However
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	 * rdmavt will need access to it so drivers need to proviee this during
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	 * the attach port API call.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	u16 *pkey_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	struct rvt_ah *sm_ah;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	 * Keep a list of traps that have not been repressed.  They will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	 * resent based on trap_timer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	struct trap_list trap_lists[RVT_MAX_TRAP_LISTS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	struct timer_list trap_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) #define RVT_CQN_MAX 16 /* maximum length of cq name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) #define RVT_SGE_COPY_MEMCPY	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) #define RVT_SGE_COPY_CACHELESS	1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #define RVT_SGE_COPY_ADAPTIVE	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  * Things that are driver specific, module parameters in hfi1 and qib
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) struct rvt_driver_params {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	struct ib_device_attr props;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	 * Anything driver specific that is not covered by props
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	 * For instance special module parameters. Goes here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	unsigned int lkey_table_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	unsigned int qp_table_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	unsigned int sge_copy_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	unsigned int wss_threshold;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	unsigned int wss_clean_period;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	int qpn_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	int qpn_inc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	int qpn_res_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	int qpn_res_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	int nports;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	int npkeys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	int node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	int psn_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	int psn_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	int psn_modify_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	u32 core_cap_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	u32 max_mad_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	u8 qos_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	u8 max_rdma_atomic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	u8 extra_rdma_atomic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	u8 reserved_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) /* User context */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) struct rvt_ucontext {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	struct ib_ucontext ibucontext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) /* Protection domain */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) struct rvt_pd {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	struct ib_pd ibpd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	bool user;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) /* Address handle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) struct rvt_ah {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	struct ib_ah ibah;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	struct rdma_ah_attr attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	u8 vl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	u8 log_pmtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)  * This structure is used by rvt_mmap() to validate an offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)  * when an mmap() request is made.  The vm_area_struct then uses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)  * this as its vm_private_data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) struct rvt_mmap_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	struct list_head pending_mmaps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	struct ib_ucontext *context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	void *obj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	__u64 offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	struct kref ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	u32 size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) /* memory working set size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) struct rvt_wss {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	unsigned long *entries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	atomic_t total_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	atomic_t clean_counter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	atomic_t clean_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	int threshold;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	int num_entries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	long pages_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	unsigned int clean_period;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) struct rvt_dev_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) struct rvt_swqe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) struct rvt_driver_provided {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	 * Which functions are required depends on which verbs rdmavt is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	 * providing and which verbs the driver is overriding. See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	 * check_support() for details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	/* hot path calldowns in a single cacheline */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	 * Give the driver a notice that there is send work to do. It is up to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	 * the driver to generally push the packets out, this just queues the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	 * work with the driver. There are two variants here. The no_lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	 * version requires the s_lock not to be held. The other assumes the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	 * s_lock is held.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	bool (*schedule_send)(struct rvt_qp *qp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	bool (*schedule_send_no_lock)(struct rvt_qp *qp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	 * Driver specific work request setup and checking.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	 * This function is allowed to perform any setup, checks, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	 * adjustments required to the SWQE in order to be usable by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	 * underlying protocols. This includes private data structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	 * allocations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	int (*setup_wqe)(struct rvt_qp *qp, struct rvt_swqe *wqe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 			 bool *call_send);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	 * Sometimes rdmavt needs to kick the driver's send progress. That is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	 * done by this call back.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	void (*do_send)(struct rvt_qp *qp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	 * Returns a pointer to the undelying hardware's PCI device. This is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	 * used to display information as to what hardware is being referenced
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	 * in an output message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	struct pci_dev * (*get_pci_dev)(struct rvt_dev_info *rdi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	 * Allocate a private queue pair data structure for driver specific
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	 * information which is opaque to rdmavt.  Errors are returned via
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	 * ERR_PTR(err).  The driver is free to return NULL or a valid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	 * pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	void * (*qp_priv_alloc)(struct rvt_dev_info *rdi, struct rvt_qp *qp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	 * Init a struture allocated with qp_priv_alloc(). This should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	 * called after all qp fields have been initialized in rdmavt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	int (*qp_priv_init)(struct rvt_dev_info *rdi, struct rvt_qp *qp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 			    struct ib_qp_init_attr *init_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	 * Free the driver's private qp structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	void (*qp_priv_free)(struct rvt_dev_info *rdi, struct rvt_qp *qp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	 * Inform the driver the particular qp in quesiton has been reset so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	 * that it can clean up anything it needs to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	void (*notify_qp_reset)(struct rvt_qp *qp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	 * Get a path mtu from the driver based on qp attributes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	int (*get_pmtu_from_attr)(struct rvt_dev_info *rdi, struct rvt_qp *qp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 				  struct ib_qp_attr *attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	 * Notify driver that it needs to flush any outstanding IO requests that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	 * are waiting on a qp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	void (*flush_qp_waiters)(struct rvt_qp *qp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	 * Notify driver to stop its queue of sending packets. Nothing else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	 * should be posted to the queue pair after this has been called.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	void (*stop_send_queue)(struct rvt_qp *qp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	 * Have the drivr drain any in progress operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	void (*quiesce_qp)(struct rvt_qp *qp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	 * Inform the driver a qp has went to error state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	void (*notify_error_qp)(struct rvt_qp *qp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	 * Get an MTU for a qp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	u32 (*mtu_from_qp)(struct rvt_dev_info *rdi, struct rvt_qp *qp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 			   u32 pmtu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	 * Convert an mtu to a path mtu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	int (*mtu_to_path_mtu)(u32 mtu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	 * Get the guid of a port in big endian byte order
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	int (*get_guid_be)(struct rvt_dev_info *rdi, struct rvt_ibport *rvp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 			   int guid_index, __be64 *guid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	 * Query driver for the state of the port.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	int (*query_port_state)(struct rvt_dev_info *rdi, u8 port_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 				struct ib_port_attr *props);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	 * Tell driver to shutdown a port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	int (*shut_down_port)(struct rvt_dev_info *rdi, u8 port_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	/* Tell driver to send a trap for changed  port capabilities */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	void (*cap_mask_chg)(struct rvt_dev_info *rdi, u8 port_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	 * The following functions can be safely ignored completely. Any use of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	 * these is checked for NULL before blindly calling. Rdmavt should also
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	 * be functional if drivers omit these.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	/* Called to inform the driver that all qps should now be freed. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	unsigned (*free_all_qps)(struct rvt_dev_info *rdi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	/* Driver specific AH validation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	int (*check_ah)(struct ib_device *, struct rdma_ah_attr *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	/* Inform the driver a new AH has been created */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	void (*notify_new_ah)(struct ib_device *, struct rdma_ah_attr *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 			      struct rvt_ah *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	/* Let the driver pick the next queue pair number*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	int (*alloc_qpn)(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 			 enum ib_qp_type type, u8 port_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	/* Determine if its safe or allowed to modify the qp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	int (*check_modify_qp)(struct rvt_qp *qp, struct ib_qp_attr *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 			       int attr_mask, struct ib_udata *udata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	/* Driver specific QP modification/notification-of */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	void (*modify_qp)(struct rvt_qp *qp, struct ib_qp_attr *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 			  int attr_mask, struct ib_udata *udata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	/* Notify driver a mad agent has been created */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	void (*notify_create_mad_agent)(struct rvt_dev_info *rdi, int port_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	/* Notify driver a mad agent has been removed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	void (*notify_free_mad_agent)(struct rvt_dev_info *rdi, int port_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	/* Notify driver to restart rc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	void (*notify_restart_rc)(struct rvt_qp *qp, u32 psn, int wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	/* Get and return CPU to pin CQ processing thread */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	int (*comp_vect_cpu_lookup)(struct rvt_dev_info *rdi, int comp_vect);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) struct rvt_dev_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	struct ib_device ibdev; /* Keep this first. Nothing above here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	 * Prior to calling for registration the driver will be responsible for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	 * allocating space for this structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	 * The driver will also be responsible for filling in certain members of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	 * dparms.props. The driver needs to fill in dparms exactly as it would
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	 * want values reported to a ULP. This will be returned to the caller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	 * in rdmavt's device. The driver should also therefore refrain from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	 * modifying this directly after registration with rdmavt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	/* Driver specific properties */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	struct rvt_driver_params dparms;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	/* post send table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	const struct rvt_operation_params *post_parms;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	/* opcode translation table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	const enum ib_wc_opcode *wc_opcode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	/* Driver specific helper functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	struct rvt_driver_provided driver_f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	struct rvt_mregion __rcu *dma_mr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	struct rvt_lkey_table lkey_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	/* Internal use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	int n_pds_allocated;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	spinlock_t n_pds_lock; /* Protect pd allocated count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	int n_ahs_allocated;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	spinlock_t n_ahs_lock; /* Protect ah allocated count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	u32 n_srqs_allocated;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	spinlock_t n_srqs_lock; /* Protect srqs allocated count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	int flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	struct rvt_ibport **ports;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	/* QP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	struct rvt_qp_ibdev *qp_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	u32 n_qps_allocated;    /* number of QPs allocated for device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	u32 n_rc_qps;		/* number of RC QPs allocated for device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	u32 busy_jiffies;	/* timeout scaling based on RC QP count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	spinlock_t n_qps_lock;	/* protect qps, rc qps and busy jiffy counts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	/* memory maps */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	struct list_head pending_mmaps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	spinlock_t mmap_offset_lock; /* protect mmap_offset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	u32 mmap_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	spinlock_t pending_lock; /* protect pending mmap list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	/* CQ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	u32 n_cqs_allocated;    /* number of CQs allocated for device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	spinlock_t n_cqs_lock; /* protect count of in use cqs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	/* Multicast */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	u32 n_mcast_grps_allocated; /* number of mcast groups allocated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	spinlock_t n_mcast_grps_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	/* Memory Working Set Size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	struct rvt_wss *wss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)  * rvt_set_ibdev_name - Craft an IB device name from client info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433)  * @rdi: pointer to the client rvt_dev_info structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434)  * @name: client specific name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)  * @unit: client specific unit number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) static inline void rvt_set_ibdev_name(struct rvt_dev_info *rdi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 				      const char *fmt, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 				      const int unit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	 * FIXME: rvt and its users want to touch the ibdev before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	 * registration and have things like the name work. We don't have the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	 * infrastructure in the core to support this directly today, hack it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	 * to work by setting the name manually here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	dev_set_name(&rdi->ibdev.dev, fmt, name, unit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	strlcpy(rdi->ibdev.name, dev_name(&rdi->ibdev.dev), IB_DEVICE_NAME_MAX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)  * rvt_get_ibdev_name - return the IB name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)  * @rdi: rdmavt device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)  * Return the registered name of the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) static inline const char *rvt_get_ibdev_name(const struct rvt_dev_info *rdi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	return dev_name(&rdi->ibdev.dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) static inline struct rvt_pd *ibpd_to_rvtpd(struct ib_pd *ibpd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	return container_of(ibpd, struct rvt_pd, ibpd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) static inline struct rvt_ah *ibah_to_rvtah(struct ib_ah *ibah)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	return container_of(ibah, struct rvt_ah, ibah);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) static inline struct rvt_dev_info *ib_to_rvt(struct ib_device *ibdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 	return  container_of(ibdev, struct rvt_dev_info, ibdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) static inline unsigned rvt_get_npkeys(struct rvt_dev_info *rdi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 	 * All ports have same number of pkeys.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 	return rdi->dparms.npkeys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486)  * Return the max atomic suitable for determining
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487)  * the size of the ack ring buffer in a QP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) static inline unsigned int rvt_max_atomic(struct rvt_dev_info *rdi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	return rdi->dparms.max_rdma_atomic +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 		rdi->dparms.extra_rdma_atomic + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) static inline unsigned int rvt_size_atomic(struct rvt_dev_info *rdi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	return rdi->dparms.max_rdma_atomic +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 		rdi->dparms.extra_rdma_atomic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502)  * Return the indexed PKEY from the port PKEY table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) static inline u16 rvt_get_pkey(struct rvt_dev_info *rdi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 			       int port_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 			       unsigned index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 	if (index >= rvt_get_npkeys(rdi))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 		return rdi->ports[port_index]->pkey_table[index];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) struct rvt_dev_info *rvt_alloc_device(size_t size, int nports);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) void rvt_dealloc_device(struct rvt_dev_info *rdi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) int rvt_register_device(struct rvt_dev_info *rvd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) void rvt_unregister_device(struct rvt_dev_info *rvd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) int rvt_check_ah(struct ib_device *ibdev, struct rdma_ah_attr *ah_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) int rvt_init_port(struct rvt_dev_info *rdi, struct rvt_ibport *port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 		  int port_index, u16 *pkey_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) int rvt_fast_reg_mr(struct rvt_qp *qp, struct ib_mr *ibmr, u32 key,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 		    int access);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) int rvt_invalidate_rkey(struct rvt_qp *qp, u32 rkey);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) int rvt_rkey_ok(struct rvt_qp *qp, struct rvt_sge *sge,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 		u32 len, u64 vaddr, u32 rkey, int acc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) int rvt_lkey_ok(struct rvt_lkey_table *rkt, struct rvt_pd *pd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 		struct rvt_sge *isge, struct rvt_sge *last_sge,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 		struct ib_sge *sge, int acc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) struct rvt_mcast *rvt_mcast_find(struct rvt_ibport *ibp, union ib_gid *mgid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 				 u16 lid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) #endif          /* DEF_RDMA_VT_H */