18c2ecf20Sopenharmony_ci#ifndef _QP_H 28c2ecf20Sopenharmony_ci#define _QP_H 38c2ecf20Sopenharmony_ci/* 48c2ecf20Sopenharmony_ci * Copyright(c) 2015 - 2018 Intel Corporation. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license. When using or 78c2ecf20Sopenharmony_ci * redistributing this file, you may do so under either license. 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * GPL LICENSE SUMMARY 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify 128c2ecf20Sopenharmony_ci * it under the terms of version 2 of the GNU General Public License as 138c2ecf20Sopenharmony_ci * published by the Free Software Foundation. 148c2ecf20Sopenharmony_ci * 158c2ecf20Sopenharmony_ci * This program is distributed in the hope that it will be useful, but 168c2ecf20Sopenharmony_ci * WITHOUT ANY WARRANTY; without even the implied warranty of 178c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 188c2ecf20Sopenharmony_ci * General Public License for more details. 198c2ecf20Sopenharmony_ci * 208c2ecf20Sopenharmony_ci * BSD LICENSE 218c2ecf20Sopenharmony_ci * 228c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without 238c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions 248c2ecf20Sopenharmony_ci * are met: 258c2ecf20Sopenharmony_ci * 268c2ecf20Sopenharmony_ci * - Redistributions of source code must retain the above copyright 278c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer. 288c2ecf20Sopenharmony_ci * - Redistributions in binary form must reproduce the above copyright 298c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer in 308c2ecf20Sopenharmony_ci * the documentation and/or other materials provided with the 318c2ecf20Sopenharmony_ci * distribution. 328c2ecf20Sopenharmony_ci * - Neither the name of Intel Corporation nor the names of its 338c2ecf20Sopenharmony_ci * contributors may be used to endorse or promote products derived 348c2ecf20Sopenharmony_ci * from this software without specific prior written permission. 358c2ecf20Sopenharmony_ci * 368c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 378c2ecf20Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 388c2ecf20Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 398c2ecf20Sopenharmony_ci * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 408c2ecf20Sopenharmony_ci * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 418c2ecf20Sopenharmony_ci * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 428c2ecf20Sopenharmony_ci * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 438c2ecf20Sopenharmony_ci * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 448c2ecf20Sopenharmony_ci * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 458c2ecf20Sopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 468c2ecf20Sopenharmony_ci * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 478c2ecf20Sopenharmony_ci * 488c2ecf20Sopenharmony_ci */ 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#include <linux/hash.h> 518c2ecf20Sopenharmony_ci#include <rdma/rdmavt_qp.h> 528c2ecf20Sopenharmony_ci#include "verbs.h" 538c2ecf20Sopenharmony_ci#include "sdma.h" 548c2ecf20Sopenharmony_ci#include "verbs_txreq.h" 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ciextern unsigned int hfi1_qp_table_size; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ciextern const struct rvt_operation_params hfi1_post_parms[]; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci/* 618c2ecf20Sopenharmony_ci * Driver specific s_flags starting at bit 31 down to HFI1_S_MIN_BIT_MASK 628c2ecf20Sopenharmony_ci * 638c2ecf20Sopenharmony_ci * HFI1_S_AHG_VALID - ahg header valid on chip 648c2ecf20Sopenharmony_ci * HFI1_S_AHG_CLEAR - have send engine clear ahg state 658c2ecf20Sopenharmony_ci * HFI1_S_WAIT_PIO_DRAIN - qp waiting for PIOs to drain 668c2ecf20Sopenharmony_ci * HFI1_S_WAIT_TID_SPACE - a QP is waiting for TID resource 678c2ecf20Sopenharmony_ci * HFI1_S_WAIT_TID_RESP - waiting for a TID RDMA WRITE response 688c2ecf20Sopenharmony_ci * HFI1_S_WAIT_HALT - halt the first leg send engine 698c2ecf20Sopenharmony_ci * HFI1_S_MIN_BIT_MASK - the lowest bit that can be used by hfi1 708c2ecf20Sopenharmony_ci */ 718c2ecf20Sopenharmony_ci#define HFI1_S_AHG_VALID 0x80000000 728c2ecf20Sopenharmony_ci#define HFI1_S_AHG_CLEAR 0x40000000 738c2ecf20Sopenharmony_ci#define HFI1_S_WAIT_PIO_DRAIN 0x20000000 748c2ecf20Sopenharmony_ci#define HFI1_S_WAIT_TID_SPACE 0x10000000 758c2ecf20Sopenharmony_ci#define HFI1_S_WAIT_TID_RESP 0x08000000 768c2ecf20Sopenharmony_ci#define HFI1_S_WAIT_HALT 0x04000000 778c2ecf20Sopenharmony_ci#define HFI1_S_MIN_BIT_MASK 0x01000000 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* 808c2ecf20Sopenharmony_ci * overload wait defines 818c2ecf20Sopenharmony_ci */ 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci#define HFI1_S_ANY_WAIT_IO (RVT_S_ANY_WAIT_IO | HFI1_S_WAIT_PIO_DRAIN) 848c2ecf20Sopenharmony_ci#define HFI1_S_ANY_WAIT (HFI1_S_ANY_WAIT_IO | RVT_S_ANY_WAIT_SEND) 858c2ecf20Sopenharmony_ci#define HFI1_S_ANY_TID_WAIT_SEND (RVT_S_WAIT_SSN_CREDIT | RVT_S_WAIT_DMA) 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci/* 888c2ecf20Sopenharmony_ci * Send if not busy or waiting for I/O and either 898c2ecf20Sopenharmony_ci * a RC response is pending or we can process send work requests. 908c2ecf20Sopenharmony_ci */ 918c2ecf20Sopenharmony_cistatic inline int hfi1_send_ok(struct rvt_qp *qp) 928c2ecf20Sopenharmony_ci{ 938c2ecf20Sopenharmony_ci struct hfi1_qp_priv *priv = qp->priv; 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci return !(qp->s_flags & (RVT_S_BUSY | HFI1_S_ANY_WAIT_IO)) && 968c2ecf20Sopenharmony_ci (verbs_txreq_queued(iowait_get_ib_work(&priv->s_iowait)) || 978c2ecf20Sopenharmony_ci (qp->s_flags & RVT_S_RESP_PENDING) || 988c2ecf20Sopenharmony_ci !(qp->s_flags & RVT_S_ANY_WAIT_SEND)); 998c2ecf20Sopenharmony_ci} 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci/* 1028c2ecf20Sopenharmony_ci * free_ahg - clear ahg from QP 1038c2ecf20Sopenharmony_ci */ 1048c2ecf20Sopenharmony_cistatic inline void clear_ahg(struct rvt_qp *qp) 1058c2ecf20Sopenharmony_ci{ 1068c2ecf20Sopenharmony_ci struct hfi1_qp_priv *priv = qp->priv; 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci priv->s_ahg->ahgcount = 0; 1098c2ecf20Sopenharmony_ci qp->s_flags &= ~(HFI1_S_AHG_VALID | HFI1_S_AHG_CLEAR); 1108c2ecf20Sopenharmony_ci if (priv->s_sde && qp->s_ahgidx >= 0) 1118c2ecf20Sopenharmony_ci sdma_ahg_free(priv->s_sde, qp->s_ahgidx); 1128c2ecf20Sopenharmony_ci qp->s_ahgidx = -1; 1138c2ecf20Sopenharmony_ci} 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci/** 1168c2ecf20Sopenharmony_ci * hfi1_qp_wakeup - wake up on the indicated event 1178c2ecf20Sopenharmony_ci * @qp: the QP 1188c2ecf20Sopenharmony_ci * @flag: flag the qp on which the qp is stalled 1198c2ecf20Sopenharmony_ci */ 1208c2ecf20Sopenharmony_civoid hfi1_qp_wakeup(struct rvt_qp *qp, u32 flag); 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_cistruct sdma_engine *qp_to_sdma_engine(struct rvt_qp *qp, u8 sc5); 1238c2ecf20Sopenharmony_cistruct send_context *qp_to_send_context(struct rvt_qp *qp, u8 sc5); 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_civoid qp_iter_print(struct seq_file *s, struct rvt_qp_iter *iter); 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_cibool _hfi1_schedule_send(struct rvt_qp *qp); 1288c2ecf20Sopenharmony_cibool hfi1_schedule_send(struct rvt_qp *qp); 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_civoid hfi1_migrate_qp(struct rvt_qp *qp); 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci/* 1338c2ecf20Sopenharmony_ci * Functions provided by hfi1 driver for rdmavt to use 1348c2ecf20Sopenharmony_ci */ 1358c2ecf20Sopenharmony_civoid *qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp); 1368c2ecf20Sopenharmony_civoid qp_priv_free(struct rvt_dev_info *rdi, struct rvt_qp *qp); 1378c2ecf20Sopenharmony_ciunsigned free_all_qps(struct rvt_dev_info *rdi); 1388c2ecf20Sopenharmony_civoid notify_qp_reset(struct rvt_qp *qp); 1398c2ecf20Sopenharmony_ciint get_pmtu_from_attr(struct rvt_dev_info *rdi, struct rvt_qp *qp, 1408c2ecf20Sopenharmony_ci struct ib_qp_attr *attr); 1418c2ecf20Sopenharmony_civoid flush_qp_waiters(struct rvt_qp *qp); 1428c2ecf20Sopenharmony_civoid notify_error_qp(struct rvt_qp *qp); 1438c2ecf20Sopenharmony_civoid stop_send_queue(struct rvt_qp *qp); 1448c2ecf20Sopenharmony_civoid quiesce_qp(struct rvt_qp *qp); 1458c2ecf20Sopenharmony_ciu32 mtu_from_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp, u32 pmtu); 1468c2ecf20Sopenharmony_ciint mtu_to_path_mtu(u32 mtu); 1478c2ecf20Sopenharmony_civoid hfi1_error_port_qps(struct hfi1_ibport *ibp, u8 sl); 1488c2ecf20Sopenharmony_civoid hfi1_qp_unbusy(struct rvt_qp *qp, struct iowait_work *wait); 1498c2ecf20Sopenharmony_ci#endif /* _QP_H */ 150