blob: 36be54771205491c07d5e527165404bfcdcad899 [file] [log] [blame]
Mike Marciniszyn77241052015-07-30 15:17:43 -04001#ifndef _QP_H
2#define _QP_H
3/*
4 *
5 * This file is provided under a dual BSD/GPLv2 license. When using or
6 * redistributing this file, you may do so under either license.
7 *
8 * GPL LICENSE SUMMARY
9 *
10 * Copyright(c) 2015 Intel Corporation.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of version 2 of the GNU General Public License as
14 * published by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * BSD LICENSE
22 *
23 * Copyright(c) 2015 Intel Corporation.
24 *
25 * Redistribution and use in source and binary forms, with or without
26 * modification, are permitted provided that the following conditions
27 * are met:
28 *
29 * - Redistributions of source code must retain the above copyright
30 * notice, this list of conditions and the following disclaimer.
31 * - Redistributions in binary form must reproduce the above copyright
32 * notice, this list of conditions and the following disclaimer in
33 * the documentation and/or other materials provided with the
34 * distribution.
35 * - Neither the name of Intel Corporation nor the names of its
36 * contributors may be used to endorse or promote products derived
37 * from this software without specific prior written permission.
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
40 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
41 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
42 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
43 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
45 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
46 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
47 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
48 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
49 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50 *
51 */
52
53#include <linux/hash.h>
Dennis Dalessandro1c4b7d92016-01-19 14:43:06 -080054#include <rdma/rdmavt_qp.h>
Mike Marciniszyn77241052015-07-30 15:17:43 -040055#include "verbs.h"
Mike Marciniszyn13a69f52015-10-26 10:28:27 -040056#include "sdma.h"
Mike Marciniszyn77241052015-07-30 15:17:43 -040057
Dennis Dalessandroa2c2d602016-01-19 14:43:12 -080058extern unsigned int hfi1_qp_table_size;
59
Dennis Dalessandro895420d2016-01-19 14:42:28 -080060/*
61 * free_ahg - clear ahg from QP
Mike Marciniszyn13a69f52015-10-26 10:28:27 -040062 */
Dennis Dalessandro895420d2016-01-19 14:42:28 -080063static inline void clear_ahg(struct rvt_qp *qp)
Mike Marciniszyn13a69f52015-10-26 10:28:27 -040064{
Dennis Dalessandro4c6829c2016-01-19 14:42:00 -080065 struct hfi1_qp_priv *priv = qp->priv;
66
67 priv->s_hdr->ahgcount = 0;
Dennis Dalessandro54d10c12016-01-19 14:43:01 -080068 qp->s_flags &= ~(RVT_S_AHG_VALID | RVT_S_AHG_CLEAR);
Dennis Dalessandro4c6829c2016-01-19 14:42:00 -080069 if (priv->s_sde && qp->s_ahgidx >= 0)
70 sdma_ahg_free(priv->s_sde, qp->s_ahgidx);
Mike Marciniszyn13a69f52015-10-26 10:28:27 -040071 qp->s_ahgidx = -1;
Mike Marciniszyn13a69f52015-10-26 10:28:27 -040072}
73
Mike Marciniszyn77241052015-07-30 15:17:43 -040074/**
75 * hfi1_compute_aeth - compute the AETH (syndrome + MSN)
76 * @qp: the queue pair to compute the AETH for
77 *
78 * Returns the AETH.
79 */
Dennis Dalessandro895420d2016-01-19 14:42:28 -080080__be32 hfi1_compute_aeth(struct rvt_qp *qp);
Mike Marciniszyn77241052015-07-30 15:17:43 -040081
82/**
83 * hfi1_create_qp - create a queue pair for a device
84 * @ibpd: the protection domain who's device we create the queue pair for
85 * @init_attr: the attributes of the queue pair
86 * @udata: user data for libibverbs.so
87 *
88 * Returns the queue pair on success, otherwise returns an errno.
89 *
90 * Called by the ib_create_qp() core verbs function.
91 */
92struct ib_qp *hfi1_create_qp(struct ib_pd *ibpd,
93 struct ib_qp_init_attr *init_attr,
94 struct ib_udata *udata);
95/**
Mike Marciniszyn77241052015-07-30 15:17:43 -040096 * hfi1_get_credit - flush the send work queue of a QP
97 * @qp: the qp who's send work queue to flush
98 * @aeth: the Acknowledge Extended Transport Header
99 *
100 * The QP s_lock should be held.
101 */
Dennis Dalessandro895420d2016-01-19 14:42:28 -0800102void hfi1_get_credit(struct rvt_qp *qp, u32 aeth);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400103
104/**
Kaike Wan92d207f2015-12-01 15:38:13 -0500105 * hfi1_qp_wakeup - wake up on the indicated event
Mike Marciniszyn77241052015-07-30 15:17:43 -0400106 * @qp: the QP
107 * @flag: flag the qp on which the qp is stalled
108 */
Dennis Dalessandro895420d2016-01-19 14:42:28 -0800109void hfi1_qp_wakeup(struct rvt_qp *qp, u32 flag);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400110
Dennis Dalessandro895420d2016-01-19 14:42:28 -0800111struct sdma_engine *qp_to_sdma_engine(struct rvt_qp *qp, u8 sc5);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400112
113struct qp_iter;
114
115/**
Kaike Wan92d207f2015-12-01 15:38:13 -0500116 * qp_iter_init - initialize the iterator for the qp hash list
Mike Marciniszyn77241052015-07-30 15:17:43 -0400117 * @dev: the hfi1_ibdev
118 */
119struct qp_iter *qp_iter_init(struct hfi1_ibdev *dev);
120
121/**
Kaike Wan92d207f2015-12-01 15:38:13 -0500122 * qp_iter_next - Find the next qp in the hash list
Mike Marciniszyn77241052015-07-30 15:17:43 -0400123 * @iter: the iterator for the qp hash list
124 */
125int qp_iter_next(struct qp_iter *iter);
126
127/**
Kaike Wan92d207f2015-12-01 15:38:13 -0500128 * qp_iter_print - print the qp information to seq_file
Mike Marciniszyn77241052015-07-30 15:17:43 -0400129 * @s: the seq_file to emit the qp information on
130 * @iter: the iterator for the qp hash list
131 */
132void qp_iter_print(struct seq_file *s, struct qp_iter *iter);
133
134/**
135 * qp_comm_est - handle trap with QP established
136 * @qp: the QP
137 */
Dennis Dalessandro895420d2016-01-19 14:42:28 -0800138void qp_comm_est(struct rvt_qp *qp);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400139
Mike Marciniszyn0a226ed2015-11-09 19:13:58 -0500140/**
141 * _hfi1_schedule_send - schedule progress
142 * @qp: the QP
143 *
144 * This schedules qp progress w/o regard to the s_flags.
145 *
146 * It is only used in the post send, which doesn't hold
147 * the s_lock.
148 */
Dennis Dalessandro895420d2016-01-19 14:42:28 -0800149static inline void _hfi1_schedule_send(struct rvt_qp *qp)
Mike Marciniszyn0a226ed2015-11-09 19:13:58 -0500150{
Dennis Dalessandro4c6829c2016-01-19 14:42:00 -0800151 struct hfi1_qp_priv *priv = qp->priv;
Mike Marciniszyn0a226ed2015-11-09 19:13:58 -0500152 struct hfi1_ibport *ibp =
153 to_iport(qp->ibqp.device, qp->port_num);
154 struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
155 struct hfi1_devdata *dd = dd_from_ibdev(qp->ibqp.device);
156
Dennis Dalessandro4c6829c2016-01-19 14:42:00 -0800157 iowait_schedule(&priv->s_iowait, ppd->hfi1_wq,
158 priv->s_sde ?
159 priv->s_sde->cpu :
Mike Marciniszyn0a226ed2015-11-09 19:13:58 -0500160 cpumask_first(cpumask_of_node(dd->assigned_node_id)));
161}
162
163/**
164 * hfi1_schedule_send - schedule progress
165 * @qp: the QP
166 *
167 * This schedules qp progress and caller should hold
168 * the s_lock.
169 */
Dennis Dalessandro895420d2016-01-19 14:42:28 -0800170static inline void hfi1_schedule_send(struct rvt_qp *qp)
Mike Marciniszyn0a226ed2015-11-09 19:13:58 -0500171{
172 if (hfi1_send_ok(qp))
173 _hfi1_schedule_send(qp);
174}
175
Dennis Dalessandro895420d2016-01-19 14:42:28 -0800176void hfi1_migrate_qp(struct rvt_qp *qp);
Mike Marciniszync2f3ffb2015-11-09 19:13:57 -0500177
Dennis Dalessandroa2c2d602016-01-19 14:43:12 -0800178/*
179 * Functions provided by hfi1 driver for rdmavt to use
180 */
181void *qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp,
182 gfp_t gfp);
183void qp_priv_free(struct rvt_dev_info *rdi, struct rvt_qp *qp);
184unsigned free_all_qps(struct rvt_dev_info *rdi);
185void notify_qp_reset(struct rvt_qp *qp);
Dennis Dalessandroec4274f2016-01-19 14:43:44 -0800186int get_pmtu_from_attr(struct rvt_dev_info *rdi, struct rvt_qp *qp,
187 struct ib_qp_attr *attr);
188void flush_qp_waiters(struct rvt_qp *qp);
189void notify_error_qp(struct rvt_qp *qp);
190void stop_send_queue(struct rvt_qp *qp);
191void quiesce_qp(struct rvt_qp *qp);
192u32 mtu_from_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp, u32 pmtu);
193int mtu_to_path_mtu(u32 mtu);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400194#endif /* _QP_H */