18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright(c) 2018 Intel Corporation. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci#ifndef _HFI1_OPFN_H 78c2ecf20Sopenharmony_ci#define _HFI1_OPFN_H 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci/** 108c2ecf20Sopenharmony_ci * DOC: Omni Path Feature Negotion (OPFN) 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * OPFN is a discovery protocol for Intel Omni-Path fabric that 138c2ecf20Sopenharmony_ci * allows two RC QPs to negotiate a common feature that both QPs 148c2ecf20Sopenharmony_ci * can support. Currently, the only OPA feature that OPFN 158c2ecf20Sopenharmony_ci * supports is TID RDMA. 168c2ecf20Sopenharmony_ci * 178c2ecf20Sopenharmony_ci * Architecture 188c2ecf20Sopenharmony_ci * 198c2ecf20Sopenharmony_ci * OPFN involves the communication between two QPs on the HFI 208c2ecf20Sopenharmony_ci * level on an Omni-Path fabric, and ULPs have no knowledge of 218c2ecf20Sopenharmony_ci * OPFN at all. 228c2ecf20Sopenharmony_ci * 238c2ecf20Sopenharmony_ci * Implementation 248c2ecf20Sopenharmony_ci * 258c2ecf20Sopenharmony_ci * OPFN extends the existing IB RC protocol with the following 268c2ecf20Sopenharmony_ci * changes: 278c2ecf20Sopenharmony_ci * -- Uses Bit 24 (reserved) of DWORD 1 of Base Transport 288c2ecf20Sopenharmony_ci * Header (BTH1) to indicate that the RC QP supports OPFN; 298c2ecf20Sopenharmony_ci * -- Uses a combination of RC COMPARE_SWAP opcode (0x13) and 308c2ecf20Sopenharmony_ci * the address U64_MAX (0xFFFFFFFFFFFFFFFF) as an OPFN 318c2ecf20Sopenharmony_ci * request; The 64-bit data carried with the request/response 328c2ecf20Sopenharmony_ci * contains the parameters for negotiation and will be 338c2ecf20Sopenharmony_ci * defined in tid_rdma.c file; 348c2ecf20Sopenharmony_ci * -- Defines IB_WR_RESERVED3 as IB_WR_OPFN. 358c2ecf20Sopenharmony_ci * 368c2ecf20Sopenharmony_ci * The OPFN communication will be triggered when an RC QP 378c2ecf20Sopenharmony_ci * receives a request with Bit 24 of BTH1 set. The responder QP 388c2ecf20Sopenharmony_ci * will then post send an OPFN request with its local 398c2ecf20Sopenharmony_ci * parameters, which will be sent to the requester QP once all 408c2ecf20Sopenharmony_ci * existing requests on the responder QP side have been sent. 418c2ecf20Sopenharmony_ci * Once the requester QP receives the OPFN request, it will 428c2ecf20Sopenharmony_ci * keep a copy of the responder QP's parameters, and return a 438c2ecf20Sopenharmony_ci * response packet with its own local parameters. The responder 448c2ecf20Sopenharmony_ci * QP receives the response packet and keeps a copy of the requester 458c2ecf20Sopenharmony_ci * QP's parameters. After this exchange, each side has the parameters 468c2ecf20Sopenharmony_ci * for both sides and therefore can select the right parameters 478c2ecf20Sopenharmony_ci * for future transactions 488c2ecf20Sopenharmony_ci */ 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#include <linux/workqueue.h> 518c2ecf20Sopenharmony_ci#include <rdma/ib_verbs.h> 528c2ecf20Sopenharmony_ci#include <rdma/rdmavt_qp.h> 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci/* STL Verbs Extended */ 558c2ecf20Sopenharmony_ci#define IB_BTHE_E_SHIFT 24 568c2ecf20Sopenharmony_ci#define HFI1_VERBS_E_ATOMIC_VADDR U64_MAX 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_cienum hfi1_opfn_codes { 598c2ecf20Sopenharmony_ci STL_VERBS_EXTD_NONE = 0, 608c2ecf20Sopenharmony_ci STL_VERBS_EXTD_TID_RDMA, 618c2ecf20Sopenharmony_ci STL_VERBS_EXTD_MAX 628c2ecf20Sopenharmony_ci}; 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_cistruct hfi1_opfn_data { 658c2ecf20Sopenharmony_ci u8 extended; 668c2ecf20Sopenharmony_ci u16 requested; 678c2ecf20Sopenharmony_ci u16 completed; 688c2ecf20Sopenharmony_ci enum hfi1_opfn_codes curr; 698c2ecf20Sopenharmony_ci /* serialize opfn function calls */ 708c2ecf20Sopenharmony_ci spinlock_t lock; 718c2ecf20Sopenharmony_ci struct work_struct opfn_work; 728c2ecf20Sopenharmony_ci}; 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci/* WR opcode for OPFN */ 758c2ecf20Sopenharmony_ci#define IB_WR_OPFN IB_WR_RESERVED3 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_civoid opfn_send_conn_request(struct work_struct *work); 788c2ecf20Sopenharmony_civoid opfn_conn_response(struct rvt_qp *qp, struct rvt_ack_entry *e, 798c2ecf20Sopenharmony_ci struct ib_atomic_eth *ateth); 808c2ecf20Sopenharmony_civoid opfn_conn_reply(struct rvt_qp *qp, u64 data); 818c2ecf20Sopenharmony_civoid opfn_conn_error(struct rvt_qp *qp); 828c2ecf20Sopenharmony_civoid opfn_qp_init(struct rvt_qp *qp, struct ib_qp_attr *attr, int attr_mask); 838c2ecf20Sopenharmony_civoid opfn_trigger_conn_request(struct rvt_qp *qp, u32 bth1); 848c2ecf20Sopenharmony_ciint opfn_init(void); 858c2ecf20Sopenharmony_civoid opfn_exit(void); 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci#endif /* _HFI1_OPFN_H */ 88