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