144e43d91SMitko Haralanov /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */ 244e43d91SMitko Haralanov /* 344e43d91SMitko Haralanov * Copyright(c) 2018 Intel Corporation. 444e43d91SMitko Haralanov * 544e43d91SMitko Haralanov */ 644e43d91SMitko Haralanov #ifndef _HFI1_OPFN_H 744e43d91SMitko Haralanov #define _HFI1_OPFN_H 844e43d91SMitko Haralanov 944e43d91SMitko Haralanov /** 1044e43d91SMitko Haralanov * DOC: Omni Path Feature Negotion (OPFN) 1144e43d91SMitko Haralanov * 1244e43d91SMitko Haralanov * OPFN is a discovery protocol for Intel Omni-Path fabric that 1344e43d91SMitko Haralanov * allows two RC QPs to negotiate a common feature that both QPs 1444e43d91SMitko Haralanov * can support. Currently, the only OPA feature that OPFN 1544e43d91SMitko Haralanov * supports is TID RDMA. 1644e43d91SMitko Haralanov * 1744e43d91SMitko Haralanov * Architecture 1844e43d91SMitko Haralanov * 1944e43d91SMitko Haralanov * OPFN involves the communication between two QPs on the HFI 2044e43d91SMitko Haralanov * level on an Omni-Path fabric, and ULPs have no knowledge of 2144e43d91SMitko Haralanov * OPFN at all. 2244e43d91SMitko Haralanov * 2344e43d91SMitko Haralanov * Implementation 2444e43d91SMitko Haralanov * 2544e43d91SMitko Haralanov * OPFN extends the existing IB RC protocol with the following 2644e43d91SMitko Haralanov * changes: 2744e43d91SMitko Haralanov * -- Uses Bit 24 (reserved) of DWORD 1 of Base Transport 2844e43d91SMitko Haralanov * Header (BTH1) to indicate that the RC QP supports OPFN; 2944e43d91SMitko Haralanov * -- Uses a combination of RC COMPARE_SWAP opcode (0x13) and 3044e43d91SMitko Haralanov * the address U64_MAX (0xFFFFFFFFFFFFFFFF) as an OPFN 3144e43d91SMitko Haralanov * request; The 64-bit data carried with the request/response 3244e43d91SMitko Haralanov * contains the parameters for negotiation and will be 3344e43d91SMitko Haralanov * defined in tid_rdma.c file; 3444e43d91SMitko Haralanov * -- Defines IB_WR_RESERVED3 as IB_WR_OPFN. 3544e43d91SMitko Haralanov * 3644e43d91SMitko Haralanov * The OPFN communication will be triggered when an RC QP 3744e43d91SMitko Haralanov * receives a request with Bit 24 of BTH1 set. The responder QP 3844e43d91SMitko Haralanov * will then post send an OPFN request with its local 3944e43d91SMitko Haralanov * parameters, which will be sent to the requester QP once all 4044e43d91SMitko Haralanov * existing requests on the responder QP side have been sent. 4144e43d91SMitko Haralanov * Once the requester QP receives the OPFN request, it will 4244e43d91SMitko Haralanov * keep a copy of the responder QP's parameters, and return a 4344e43d91SMitko Haralanov * response packet with its own local parameters. The responder 4444e43d91SMitko Haralanov * QP receives the response packet and keeps a copy of the requester 4544e43d91SMitko Haralanov * QP's parameters. After this exchange, each side has the parameters 4644e43d91SMitko Haralanov * for both sides and therefore can select the right parameters 4744e43d91SMitko Haralanov * for future transactions 4844e43d91SMitko Haralanov */ 4944e43d91SMitko Haralanov 5062644c1dSMike Marciniszyn #include <linux/workqueue.h> 5162644c1dSMike Marciniszyn #include <rdma/ib_verbs.h> 5262644c1dSMike Marciniszyn #include <rdma/rdmavt_qp.h> 5362644c1dSMike Marciniszyn 5444e43d91SMitko Haralanov /* STL Verbs Extended */ 5544e43d91SMitko Haralanov #define IB_BTHE_E_SHIFT 24 56f01b4d5aSKaike Wan #define HFI1_VERBS_E_ATOMIC_VADDR U64_MAX 57f01b4d5aSKaike Wan 58f01b4d5aSKaike Wan enum hfi1_opfn_codes { 59f01b4d5aSKaike Wan STL_VERBS_EXTD_NONE = 0, 60f01b4d5aSKaike Wan STL_VERBS_EXTD_TID_RDMA, 61f01b4d5aSKaike Wan STL_VERBS_EXTD_MAX 62f01b4d5aSKaike Wan }; 6344e43d91SMitko Haralanov 64d22a207dSKaike Wan struct hfi1_opfn_data { 65f01b4d5aSKaike Wan u8 extended; 66f01b4d5aSKaike Wan u16 requested; 67f01b4d5aSKaike Wan u16 completed; 68f01b4d5aSKaike Wan enum hfi1_opfn_codes curr; 69d22a207dSKaike Wan /* serialize opfn function calls */ 70d22a207dSKaike Wan spinlock_t lock; 71f01b4d5aSKaike Wan struct work_struct opfn_work; 72d22a207dSKaike Wan }; 73d22a207dSKaike Wan 74f01b4d5aSKaike Wan /* WR opcode for OPFN */ 75f01b4d5aSKaike Wan #define IB_WR_OPFN IB_WR_RESERVED3 76f01b4d5aSKaike Wan 77f01b4d5aSKaike Wan void opfn_send_conn_request(struct work_struct *work); 78f01b4d5aSKaike Wan void opfn_conn_response(struct rvt_qp *qp, struct rvt_ack_entry *e, 79f01b4d5aSKaike Wan struct ib_atomic_eth *ateth); 80f01b4d5aSKaike Wan void opfn_conn_reply(struct rvt_qp *qp, u64 data); 81f01b4d5aSKaike Wan void opfn_conn_error(struct rvt_qp *qp); 82f01b4d5aSKaike Wan void opfn_qp_init(struct rvt_qp *qp, struct ib_qp_attr *attr, int attr_mask); 83f01b4d5aSKaike Wan void opfn_trigger_conn_request(struct rvt_qp *qp, u32 bth1); 84f01b4d5aSKaike Wan int opfn_init(void); 85f01b4d5aSKaike Wan void opfn_exit(void); 86f01b4d5aSKaike Wan 8744e43d91SMitko Haralanov #endif /* _HFI1_OPFN_H */ 88