1 /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */ 2 /* 3 * Copyright(c) 2018 Intel Corporation. 4 * 5 */ 6 #ifndef _HFI1_OPFN_H 7 #define _HFI1_OPFN_H 8 9 /** 10 * DOC: Omni Path Feature Negotion (OPFN) 11 * 12 * OPFN is a discovery protocol for Intel Omni-Path fabric that 13 * allows two RC QPs to negotiate a common feature that both QPs 14 * can support. Currently, the only OPA feature that OPFN 15 * supports is TID RDMA. 16 * 17 * Architecture 18 * 19 * OPFN involves the communication between two QPs on the HFI 20 * level on an Omni-Path fabric, and ULPs have no knowledge of 21 * OPFN at all. 22 * 23 * Implementation 24 * 25 * OPFN extends the existing IB RC protocol with the following 26 * changes: 27 * -- Uses Bit 24 (reserved) of DWORD 1 of Base Transport 28 * Header (BTH1) to indicate that the RC QP supports OPFN; 29 * -- Uses a combination of RC COMPARE_SWAP opcode (0x13) and 30 * the address U64_MAX (0xFFFFFFFFFFFFFFFF) as an OPFN 31 * request; The 64-bit data carried with the request/response 32 * contains the parameters for negotiation and will be 33 * defined in tid_rdma.c file; 34 * -- Defines IB_WR_RESERVED3 as IB_WR_OPFN. 35 * 36 * The OPFN communication will be triggered when an RC QP 37 * receives a request with Bit 24 of BTH1 set. The responder QP 38 * will then post send an OPFN request with its local 39 * parameters, which will be sent to the requester QP once all 40 * existing requests on the responder QP side have been sent. 41 * Once the requester QP receives the OPFN request, it will 42 * keep a copy of the responder QP's parameters, and return a 43 * response packet with its own local parameters. The responder 44 * QP receives the response packet and keeps a copy of the requester 45 * QP's parameters. After this exchange, each side has the parameters 46 * for both sides and therefore can select the right parameters 47 * for future transactions 48 */ 49 50 /* STL Verbs Extended */ 51 #define IB_BTHE_E_SHIFT 24 52 #define HFI1_VERBS_E_ATOMIC_VADDR U64_MAX 53 54 struct ib_atomic_eth; 55 56 enum hfi1_opfn_codes { 57 STL_VERBS_EXTD_NONE = 0, 58 STL_VERBS_EXTD_TID_RDMA, 59 STL_VERBS_EXTD_MAX 60 }; 61 62 struct hfi1_opfn_data { 63 u8 extended; 64 u16 requested; 65 u16 completed; 66 enum hfi1_opfn_codes curr; 67 /* serialize opfn function calls */ 68 spinlock_t lock; 69 struct work_struct opfn_work; 70 }; 71 72 /* WR opcode for OPFN */ 73 #define IB_WR_OPFN IB_WR_RESERVED3 74 75 void opfn_send_conn_request(struct work_struct *work); 76 void opfn_conn_response(struct rvt_qp *qp, struct rvt_ack_entry *e, 77 struct ib_atomic_eth *ateth); 78 void opfn_conn_reply(struct rvt_qp *qp, u64 data); 79 void opfn_conn_error(struct rvt_qp *qp); 80 void opfn_qp_init(struct rvt_qp *qp, struct ib_qp_attr *attr, int attr_mask); 81 void opfn_trigger_conn_request(struct rvt_qp *qp, u32 bth1); 82 int opfn_init(void); 83 void opfn_exit(void); 84 85 #endif /* _HFI1_OPFN_H */ 86