Mike Marciniszyn | 7724105 | 2015-07-30 15:17:43 -0400 | [diff] [blame] | 1 | #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 Dalessandro | 1c4b7d9 | 2016-01-19 14:43:06 -0800 | [diff] [blame] | 54 | #include <rdma/rdmavt_qp.h> |
Mike Marciniszyn | 7724105 | 2015-07-30 15:17:43 -0400 | [diff] [blame] | 55 | #include "verbs.h" |
Mike Marciniszyn | 13a69f5 | 2015-10-26 10:28:27 -0400 | [diff] [blame] | 56 | #include "sdma.h" |
Mike Marciniszyn | 7724105 | 2015-07-30 15:17:43 -0400 | [diff] [blame] | 57 | |
Dennis Dalessandro | a2c2d60 | 2016-01-19 14:43:12 -0800 | [diff] [blame] | 58 | extern unsigned int hfi1_qp_table_size; |
| 59 | |
Dennis Dalessandro | 895420d | 2016-01-19 14:42:28 -0800 | [diff] [blame] | 60 | /* |
| 61 | * free_ahg - clear ahg from QP |
Mike Marciniszyn | 13a69f5 | 2015-10-26 10:28:27 -0400 | [diff] [blame] | 62 | */ |
Dennis Dalessandro | 895420d | 2016-01-19 14:42:28 -0800 | [diff] [blame] | 63 | static inline void clear_ahg(struct rvt_qp *qp) |
Mike Marciniszyn | 13a69f5 | 2015-10-26 10:28:27 -0400 | [diff] [blame] | 64 | { |
Dennis Dalessandro | 4c6829c | 2016-01-19 14:42:00 -0800 | [diff] [blame] | 65 | struct hfi1_qp_priv *priv = qp->priv; |
| 66 | |
| 67 | priv->s_hdr->ahgcount = 0; |
Dennis Dalessandro | 54d10c1 | 2016-01-19 14:43:01 -0800 | [diff] [blame] | 68 | qp->s_flags &= ~(RVT_S_AHG_VALID | RVT_S_AHG_CLEAR); |
Dennis Dalessandro | 4c6829c | 2016-01-19 14:42:00 -0800 | [diff] [blame] | 69 | if (priv->s_sde && qp->s_ahgidx >= 0) |
| 70 | sdma_ahg_free(priv->s_sde, qp->s_ahgidx); |
Mike Marciniszyn | 13a69f5 | 2015-10-26 10:28:27 -0400 | [diff] [blame] | 71 | qp->s_ahgidx = -1; |
Mike Marciniszyn | 13a69f5 | 2015-10-26 10:28:27 -0400 | [diff] [blame] | 72 | } |
| 73 | |
Mike Marciniszyn | 7724105 | 2015-07-30 15:17:43 -0400 | [diff] [blame] | 74 | /** |
| 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 Dalessandro | 895420d | 2016-01-19 14:42:28 -0800 | [diff] [blame] | 80 | __be32 hfi1_compute_aeth(struct rvt_qp *qp); |
Mike Marciniszyn | 7724105 | 2015-07-30 15:17:43 -0400 | [diff] [blame] | 81 | |
| 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 | */ |
| 92 | struct ib_qp *hfi1_create_qp(struct ib_pd *ibpd, |
| 93 | struct ib_qp_init_attr *init_attr, |
| 94 | struct ib_udata *udata); |
| 95 | /** |
Mike Marciniszyn | 7724105 | 2015-07-30 15:17:43 -0400 | [diff] [blame] | 96 | * 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 Dalessandro | 895420d | 2016-01-19 14:42:28 -0800 | [diff] [blame] | 102 | void hfi1_get_credit(struct rvt_qp *qp, u32 aeth); |
Mike Marciniszyn | 7724105 | 2015-07-30 15:17:43 -0400 | [diff] [blame] | 103 | |
| 104 | /** |
Kaike Wan | 92d207f | 2015-12-01 15:38:13 -0500 | [diff] [blame] | 105 | * hfi1_qp_wakeup - wake up on the indicated event |
Mike Marciniszyn | 7724105 | 2015-07-30 15:17:43 -0400 | [diff] [blame] | 106 | * @qp: the QP |
| 107 | * @flag: flag the qp on which the qp is stalled |
| 108 | */ |
Dennis Dalessandro | 895420d | 2016-01-19 14:42:28 -0800 | [diff] [blame] | 109 | void hfi1_qp_wakeup(struct rvt_qp *qp, u32 flag); |
Mike Marciniszyn | 7724105 | 2015-07-30 15:17:43 -0400 | [diff] [blame] | 110 | |
Dennis Dalessandro | 895420d | 2016-01-19 14:42:28 -0800 | [diff] [blame] | 111 | struct sdma_engine *qp_to_sdma_engine(struct rvt_qp *qp, u8 sc5); |
Mike Marciniszyn | 7724105 | 2015-07-30 15:17:43 -0400 | [diff] [blame] | 112 | |
| 113 | struct qp_iter; |
| 114 | |
| 115 | /** |
Kaike Wan | 92d207f | 2015-12-01 15:38:13 -0500 | [diff] [blame] | 116 | * qp_iter_init - initialize the iterator for the qp hash list |
Mike Marciniszyn | 7724105 | 2015-07-30 15:17:43 -0400 | [diff] [blame] | 117 | * @dev: the hfi1_ibdev |
| 118 | */ |
| 119 | struct qp_iter *qp_iter_init(struct hfi1_ibdev *dev); |
| 120 | |
| 121 | /** |
Kaike Wan | 92d207f | 2015-12-01 15:38:13 -0500 | [diff] [blame] | 122 | * qp_iter_next - Find the next qp in the hash list |
Mike Marciniszyn | 7724105 | 2015-07-30 15:17:43 -0400 | [diff] [blame] | 123 | * @iter: the iterator for the qp hash list |
| 124 | */ |
| 125 | int qp_iter_next(struct qp_iter *iter); |
| 126 | |
| 127 | /** |
Kaike Wan | 92d207f | 2015-12-01 15:38:13 -0500 | [diff] [blame] | 128 | * qp_iter_print - print the qp information to seq_file |
Mike Marciniszyn | 7724105 | 2015-07-30 15:17:43 -0400 | [diff] [blame] | 129 | * @s: the seq_file to emit the qp information on |
| 130 | * @iter: the iterator for the qp hash list |
| 131 | */ |
| 132 | void 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 Dalessandro | 895420d | 2016-01-19 14:42:28 -0800 | [diff] [blame] | 138 | void qp_comm_est(struct rvt_qp *qp); |
Mike Marciniszyn | 7724105 | 2015-07-30 15:17:43 -0400 | [diff] [blame] | 139 | |
Mike Marciniszyn | 0a226ed | 2015-11-09 19:13:58 -0500 | [diff] [blame] | 140 | /** |
| 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 Dalessandro | 895420d | 2016-01-19 14:42:28 -0800 | [diff] [blame] | 149 | static inline void _hfi1_schedule_send(struct rvt_qp *qp) |
Mike Marciniszyn | 0a226ed | 2015-11-09 19:13:58 -0500 | [diff] [blame] | 150 | { |
Dennis Dalessandro | 4c6829c | 2016-01-19 14:42:00 -0800 | [diff] [blame] | 151 | struct hfi1_qp_priv *priv = qp->priv; |
Mike Marciniszyn | 0a226ed | 2015-11-09 19:13:58 -0500 | [diff] [blame] | 152 | 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 Dalessandro | 4c6829c | 2016-01-19 14:42:00 -0800 | [diff] [blame] | 157 | iowait_schedule(&priv->s_iowait, ppd->hfi1_wq, |
| 158 | priv->s_sde ? |
| 159 | priv->s_sde->cpu : |
Mike Marciniszyn | 0a226ed | 2015-11-09 19:13:58 -0500 | [diff] [blame] | 160 | 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 Dalessandro | 895420d | 2016-01-19 14:42:28 -0800 | [diff] [blame] | 170 | static inline void hfi1_schedule_send(struct rvt_qp *qp) |
Mike Marciniszyn | 0a226ed | 2015-11-09 19:13:58 -0500 | [diff] [blame] | 171 | { |
| 172 | if (hfi1_send_ok(qp)) |
| 173 | _hfi1_schedule_send(qp); |
| 174 | } |
| 175 | |
Dennis Dalessandro | 895420d | 2016-01-19 14:42:28 -0800 | [diff] [blame] | 176 | void hfi1_migrate_qp(struct rvt_qp *qp); |
Mike Marciniszyn | c2f3ffb | 2015-11-09 19:13:57 -0500 | [diff] [blame] | 177 | |
Dennis Dalessandro | a2c2d60 | 2016-01-19 14:43:12 -0800 | [diff] [blame] | 178 | /* |
| 179 | * Functions provided by hfi1 driver for rdmavt to use |
| 180 | */ |
| 181 | void *qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp, |
| 182 | gfp_t gfp); |
| 183 | void qp_priv_free(struct rvt_dev_info *rdi, struct rvt_qp *qp); |
| 184 | unsigned free_all_qps(struct rvt_dev_info *rdi); |
| 185 | void notify_qp_reset(struct rvt_qp *qp); |
Dennis Dalessandro | ec4274f | 2016-01-19 14:43:44 -0800 | [diff] [blame] | 186 | int get_pmtu_from_attr(struct rvt_dev_info *rdi, struct rvt_qp *qp, |
| 187 | struct ib_qp_attr *attr); |
| 188 | void flush_qp_waiters(struct rvt_qp *qp); |
| 189 | void notify_error_qp(struct rvt_qp *qp); |
| 190 | void stop_send_queue(struct rvt_qp *qp); |
| 191 | void quiesce_qp(struct rvt_qp *qp); |
| 192 | u32 mtu_from_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp, u32 pmtu); |
| 193 | int mtu_to_path_mtu(u32 mtu); |
Mike Marciniszyn | 7724105 | 2015-07-30 15:17:43 -0400 | [diff] [blame] | 194 | #endif /* _QP_H */ |