162306a36Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright(c) 2018 Intel Corporation. 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci#ifndef _HFI1_OPFN_H 762306a36Sopenharmony_ci#define _HFI1_OPFN_H 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci/** 1062306a36Sopenharmony_ci * DOC: Omni Path Feature Negotion (OPFN) 1162306a36Sopenharmony_ci * 1262306a36Sopenharmony_ci * OPFN is a discovery protocol for Intel Omni-Path fabric that 1362306a36Sopenharmony_ci * allows two RC QPs to negotiate a common feature that both QPs 1462306a36Sopenharmony_ci * can support. Currently, the only OPA feature that OPFN 1562306a36Sopenharmony_ci * supports is TID RDMA. 1662306a36Sopenharmony_ci * 1762306a36Sopenharmony_ci * Architecture 1862306a36Sopenharmony_ci * 1962306a36Sopenharmony_ci * OPFN involves the communication between two QPs on the HFI 2062306a36Sopenharmony_ci * level on an Omni-Path fabric, and ULPs have no knowledge of 2162306a36Sopenharmony_ci * OPFN at all. 2262306a36Sopenharmony_ci * 2362306a36Sopenharmony_ci * Implementation 2462306a36Sopenharmony_ci * 2562306a36Sopenharmony_ci * OPFN extends the existing IB RC protocol with the following 2662306a36Sopenharmony_ci * changes: 2762306a36Sopenharmony_ci * -- Uses Bit 24 (reserved) of DWORD 1 of Base Transport 2862306a36Sopenharmony_ci * Header (BTH1) to indicate that the RC QP supports OPFN; 2962306a36Sopenharmony_ci * -- Uses a combination of RC COMPARE_SWAP opcode (0x13) and 3062306a36Sopenharmony_ci * the address U64_MAX (0xFFFFFFFFFFFFFFFF) as an OPFN 3162306a36Sopenharmony_ci * request; The 64-bit data carried with the request/response 3262306a36Sopenharmony_ci * contains the parameters for negotiation and will be 3362306a36Sopenharmony_ci * defined in tid_rdma.c file; 3462306a36Sopenharmony_ci * -- Defines IB_WR_RESERVED3 as IB_WR_OPFN. 3562306a36Sopenharmony_ci * 3662306a36Sopenharmony_ci * The OPFN communication will be triggered when an RC QP 3762306a36Sopenharmony_ci * receives a request with Bit 24 of BTH1 set. The responder QP 3862306a36Sopenharmony_ci * will then post send an OPFN request with its local 3962306a36Sopenharmony_ci * parameters, which will be sent to the requester QP once all 4062306a36Sopenharmony_ci * existing requests on the responder QP side have been sent. 4162306a36Sopenharmony_ci * Once the requester QP receives the OPFN request, it will 4262306a36Sopenharmony_ci * keep a copy of the responder QP's parameters, and return a 4362306a36Sopenharmony_ci * response packet with its own local parameters. The responder 4462306a36Sopenharmony_ci * QP receives the response packet and keeps a copy of the requester 4562306a36Sopenharmony_ci * QP's parameters. After this exchange, each side has the parameters 4662306a36Sopenharmony_ci * for both sides and therefore can select the right parameters 4762306a36Sopenharmony_ci * for future transactions 4862306a36Sopenharmony_ci */ 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ci#include <linux/workqueue.h> 5162306a36Sopenharmony_ci#include <rdma/ib_verbs.h> 5262306a36Sopenharmony_ci#include <rdma/rdmavt_qp.h> 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci/* STL Verbs Extended */ 5562306a36Sopenharmony_ci#define IB_BTHE_E_SHIFT 24 5662306a36Sopenharmony_ci#define HFI1_VERBS_E_ATOMIC_VADDR U64_MAX 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_cienum hfi1_opfn_codes { 5962306a36Sopenharmony_ci STL_VERBS_EXTD_NONE = 0, 6062306a36Sopenharmony_ci STL_VERBS_EXTD_TID_RDMA, 6162306a36Sopenharmony_ci STL_VERBS_EXTD_MAX 6262306a36Sopenharmony_ci}; 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_cistruct hfi1_opfn_data { 6562306a36Sopenharmony_ci u8 extended; 6662306a36Sopenharmony_ci u16 requested; 6762306a36Sopenharmony_ci u16 completed; 6862306a36Sopenharmony_ci enum hfi1_opfn_codes curr; 6962306a36Sopenharmony_ci /* serialize opfn function calls */ 7062306a36Sopenharmony_ci spinlock_t lock; 7162306a36Sopenharmony_ci struct work_struct opfn_work; 7262306a36Sopenharmony_ci}; 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci/* WR opcode for OPFN */ 7562306a36Sopenharmony_ci#define IB_WR_OPFN IB_WR_RESERVED3 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_civoid opfn_send_conn_request(struct work_struct *work); 7862306a36Sopenharmony_civoid opfn_conn_response(struct rvt_qp *qp, struct rvt_ack_entry *e, 7962306a36Sopenharmony_ci struct ib_atomic_eth *ateth); 8062306a36Sopenharmony_civoid opfn_conn_reply(struct rvt_qp *qp, u64 data); 8162306a36Sopenharmony_civoid opfn_conn_error(struct rvt_qp *qp); 8262306a36Sopenharmony_civoid opfn_qp_init(struct rvt_qp *qp, struct ib_qp_attr *attr, int attr_mask); 8362306a36Sopenharmony_civoid opfn_trigger_conn_request(struct rvt_qp *qp, u32 bth1); 8462306a36Sopenharmony_ciint opfn_init(void); 8562306a36Sopenharmony_civoid opfn_exit(void); 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci#endif /* _HFI1_OPFN_H */ 88