Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/xe/guc: Add Relay Communication ABI definitions

The communication between Virtual Function (VF) drivers and
Physical Function (PF) drivers is based on the GuC firmware
acting as a proxy (relay) agent.

Add related ABI definitions that we will be using in upcoming
patches with our GuC Relay implementation.

Reviewed-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Link: https://lore.kernel.org/r/20240104222031.277-7-michal.wajdeczko@intel.com
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>

+371
+174
drivers/gpu/drm/xe/abi/guc_actions_sriov_abi.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* 3 + * Copyright © 2023 Intel Corporation 4 + */ 5 + 6 + #ifndef _GUC_ACTIONS_PF_ABI_H 7 + #define _GUC_ACTIONS_PF_ABI_H 8 + 9 + #include "guc_communication_ctb_abi.h" 10 + 11 + /** 12 + * DOC: GUC2PF_RELAY_FROM_VF 13 + * 14 + * This message is used by the GuC firmware to forward a VF2PF `Relay Message`_ 15 + * received from the Virtual Function (VF) driver to this Physical Function (PF) 16 + * driver. 17 + * 18 + * This message is always sent as `CTB HXG Message`_. 19 + * 20 + * +---+-------+--------------------------------------------------------------+ 21 + * | | Bits | Description | 22 + * +===+=======+==============================================================+ 23 + * | 0 | 31 | ORIGIN = GUC_HXG_ORIGIN_GUC_ | 24 + * | +-------+--------------------------------------------------------------+ 25 + * | | 30:28 | TYPE = GUC_HXG_TYPE_EVENT_ | 26 + * | +-------+--------------------------------------------------------------+ 27 + * | | 27:16 | MBZ | 28 + * | +-------+--------------------------------------------------------------+ 29 + * | | 15:0 | ACTION = _`XE_GUC_ACTION_GUC2PF_RELAY_FROM_VF` = 0x5100 | 30 + * +---+-------+--------------------------------------------------------------+ 31 + * | 1 | 31:0 | **VFID** - source VF identifier | 32 + * +---+-------+--------------------------------------------------------------+ 33 + * | 2 | 31:0 | **RELAY_ID** - VF/PF message ID | 34 + * +---+-------+-----------------+--------------------------------------------+ 35 + * | 3 | 31:0 | **RELAY_DATA1** | | 36 + * +---+-------+-----------------+ | 37 + * |...| | | [Embedded `Relay Message`_] | 38 + * +---+-------+-----------------+ | 39 + * | n | 31:0 | **RELAY_DATAx** | | 40 + * +---+-------+-----------------+--------------------------------------------+ 41 + */ 42 + #define XE_GUC_ACTION_GUC2PF_RELAY_FROM_VF 0x5100 43 + 44 + #define GUC2PF_RELAY_FROM_VF_EVENT_MSG_MIN_LEN (GUC_HXG_EVENT_MSG_MIN_LEN + 2u) 45 + #define GUC2PF_RELAY_FROM_VF_EVENT_MSG_MAX_LEN \ 46 + (GUC2PF_RELAY_FROM_VF_EVENT_MSG_MIN_LEN + GUC_RELAY_MSG_MAX_LEN) 47 + #define GUC2PF_RELAY_FROM_VF_EVENT_MSG_0_MBZ GUC_HXG_EVENT_MSG_0_DATA0 48 + #define GUC2PF_RELAY_FROM_VF_EVENT_MSG_1_VFID GUC_HXG_EVENT_MSG_n_DATAn 49 + #define GUC2PF_RELAY_FROM_VF_EVENT_MSG_2_RELAY_ID GUC_HXG_EVENT_MSG_n_DATAn 50 + #define GUC2PF_RELAY_FROM_VF_EVENT_MSG_3_RELAY_DATA1 GUC_HXG_EVENT_MSG_n_DATAn 51 + #define GUC2PF_RELAY_FROM_VF_EVENT_MSG_n_RELAY_DATAx GUC_HXG_EVENT_MSG_n_DATAn 52 + #define GUC2PF_RELAY_FROM_VF_EVENT_MSG_NUM_RELAY_DATA GUC_RELAY_MSG_MAX_LEN 53 + 54 + /** 55 + * DOC: PF2GUC_RELAY_TO_VF 56 + * 57 + * This H2G message is used by the Physical Function (PF) driver to send embedded 58 + * VF2PF `Relay Message`_ to the VF. 59 + * 60 + * This action message must be sent over CTB as `CTB HXG Message`_. 61 + * 62 + * +---+-------+--------------------------------------------------------------+ 63 + * | | Bits | Description | 64 + * +===+=======+==============================================================+ 65 + * | 0 | 31 | ORIGIN = GUC_HXG_ORIGIN_HOST_ | 66 + * | +-------+--------------------------------------------------------------+ 67 + * | | 30:28 | TYPE = `GUC_HXG_TYPE_FAST_REQUEST`_ | 68 + * | +-------+--------------------------------------------------------------+ 69 + * | | 27:16 | MBZ | 70 + * | +-------+--------------------------------------------------------------+ 71 + * | | 15:0 | ACTION = _`XE_GUC_ACTION_PF2GUC_RELAY_TO_VF` = 0x5101 | 72 + * +---+-------+--------------------------------------------------------------+ 73 + * | 1 | 31:0 | **VFID** - target VF identifier | 74 + * +---+-------+--------------------------------------------------------------+ 75 + * | 2 | 31:0 | **RELAY_ID** - VF/PF message ID | 76 + * +---+-------+-----------------+--------------------------------------------+ 77 + * | 3 | 31:0 | **RELAY_DATA1** | | 78 + * +---+-------+-----------------+ | 79 + * |...| | | [Embedded `Relay Message`_] | 80 + * +---+-------+-----------------+ | 81 + * | n | 31:0 | **RELAY_DATAx** | | 82 + * +---+-------+-----------------+--------------------------------------------+ 83 + */ 84 + #define XE_GUC_ACTION_PF2GUC_RELAY_TO_VF 0x5101 85 + 86 + #define PF2GUC_RELAY_TO_VF_REQUEST_MSG_MIN_LEN (GUC_HXG_REQUEST_MSG_MIN_LEN + 2u) 87 + #define PF2GUC_RELAY_TO_VF_REQUEST_MSG_MAX_LEN \ 88 + (PF2GUC_RELAY_TO_VF_REQUEST_MSG_MIN_LEN + GUC_RELAY_MSG_MAX_LEN) 89 + #define PF2GUC_RELAY_TO_VF_REQUEST_MSG_0_MBZ GUC_HXG_REQUEST_MSG_0_DATA0 90 + #define PF2GUC_RELAY_TO_VF_REQUEST_MSG_1_VFID GUC_HXG_REQUEST_MSG_n_DATAn 91 + #define PF2GUC_RELAY_TO_VF_REQUEST_MSG_2_RELAY_ID GUC_HXG_REQUEST_MSG_n_DATAn 92 + #define PF2GUC_RELAY_TO_VF_REQUEST_MSG_3_RELAY_DATA1 GUC_HXG_REQUEST_MSG_n_DATAn 93 + #define PF2GUC_RELAY_TO_VF_REQUEST_MSG_n_RELAY_DATAx GUC_HXG_REQUEST_MSG_n_DATAn 94 + #define PF2GUC_RELAY_TO_VF_REQUEST_MSG_NUM_RELAY_DATA GUC_RELAY_MSG_MAX_LEN 95 + 96 + /** 97 + * DOC: GUC2VF_RELAY_FROM_PF 98 + * 99 + * This message is used by the GuC firmware to deliver `Relay Message`_ from the 100 + * Physical Function (PF) driver to this Virtual Function (VF) driver. 101 + * See `GuC Relay Communication`_ for details. 102 + * 103 + * This message is always sent over CTB. 104 + * 105 + * +---+-------+--------------------------------------------------------------+ 106 + * | | Bits | Description | 107 + * +===+=======+==============================================================+ 108 + * | 0 | 31 | ORIGIN = GUC_HXG_ORIGIN_GUC_ | 109 + * | +-------+--------------------------------------------------------------+ 110 + * | | 30:28 | TYPE = GUC_HXG_TYPE_EVENT_ | 111 + * | +-------+--------------------------------------------------------------+ 112 + * | | 27:16 | MBZ | 113 + * | +-------+--------------------------------------------------------------+ 114 + * | | 15:0 | ACTION = _`XE_GUC_ACTION_GUC2VF_RELAY_FROM_PF` = 0x5102 | 115 + * +---+-------+--------------------------------------------------------------+ 116 + * | 1 | 31:0 | **RELAY_ID** - VF/PF message ID | 117 + * +---+-------+-----------------+--------------------------------------------+ 118 + * | 2 | 31:0 | **RELAY_DATA1** | | 119 + * +---+-------+-----------------+ | 120 + * |...| | | [Embedded `Relay Message`_] | 121 + * +---+-------+-----------------+ | 122 + * | n | 31:0 | **RELAY_DATAx** | | 123 + * +---+-------+-----------------+--------------------------------------------+ 124 + */ 125 + #define XE_GUC_ACTION_GUC2VF_RELAY_FROM_PF 0x5102 126 + 127 + #define GUC2VF_RELAY_FROM_PF_EVENT_MSG_MIN_LEN (GUC_HXG_EVENT_MSG_MIN_LEN + 1u) 128 + #define GUC2VF_RELAY_FROM_PF_EVENT_MSG_MAX_LEN \ 129 + (GUC2VF_RELAY_FROM_PF_EVENT_MSG_MIN_LEN + GUC_RELAY_MSG_MAX_LEN) 130 + #define GUC2VF_RELAY_FROM_PF_EVENT_MSG_0_MBZ GUC_HXG_EVENT_MSG_0_DATA0 131 + #define GUC2VF_RELAY_FROM_PF_EVENT_MSG_1_RELAY_ID GUC_HXG_EVENT_MSG_n_DATAn 132 + #define GUC2VF_RELAY_FROM_PF_EVENT_MSG_n_RELAY_DATAx GUC_HXG_EVENT_MSG_n_DATAn 133 + #define GUC2VF_RELAY_FROM_PF_EVENT_MSG_NUM_RELAY_DATA GUC_RELAY_MSG_MAX_LEN 134 + 135 + /** 136 + * DOC: VF2GUC_RELAY_TO_PF 137 + * 138 + * This message is used by the Virtual Function (VF) drivers to communicate with 139 + * the Physical Function (PF) driver and send `Relay Message`_ to the PF driver. 140 + * See `GuC Relay Communication`_ for details. 141 + * 142 + * This message must be sent over CTB. 143 + * 144 + * +---+-------+--------------------------------------------------------------+ 145 + * | | Bits | Description | 146 + * +===+=======+==============================================================+ 147 + * | 0 | 31 | ORIGIN = GUC_HXG_ORIGIN_HOST_ | 148 + * | +-------+--------------------------------------------------------------+ 149 + * | | 30:28 | TYPE = GUC_HXG_TYPE_REQUEST_ or GUC_HXG_TYPE_FAST_REQUEST_ | 150 + * | +-------+--------------------------------------------------------------+ 151 + * | | 27:16 | MBZ | 152 + * | +-------+--------------------------------------------------------------+ 153 + * | | 15:0 | ACTION = _`XE_GUC_ACTION_VF2GUC_RELAY_TO_PF` = 0x5103 | 154 + * +---+-------+--------------------------------------------------------------+ 155 + * | 1 | 31:0 | **RELAY_ID** - VF/PF message ID | 156 + * +---+-------+-----------------+--------------------------------------------+ 157 + * | 2 | 31:0 | **RELAY_DATA1** | | 158 + * +---+-------+-----------------+ | 159 + * |...| | | [Embedded `Relay Message`_] | 160 + * +---+-------+-----------------+ | 161 + * | n | 31:0 | **RELAY_DATAx** | | 162 + * +---+-------+-----------------+--------------------------------------------+ 163 + */ 164 + #define XE_GUC_ACTION_VF2GUC_RELAY_TO_PF 0x5103 165 + 166 + #define VF2GUC_RELAY_TO_PF_REQUEST_MSG_MIN_LEN (GUC_HXG_REQUEST_MSG_MIN_LEN + 1u) 167 + #define VF2GUC_RELAY_TO_PF_REQUEST_MSG_MAX_LEN \ 168 + (VF2GUC_RELAY_TO_PF_REQUEST_MSG_MIN_LEN + GUC_RELAY_MSG_MAX_LEN) 169 + #define VF2GUC_RELAY_TO_PF_REQUEST_MSG_0_MBZ GUC_HXG_REQUEST_MSG_0_DATA0 170 + #define VF2GUC_RELAY_TO_PF_REQUEST_MSG_1_RELAY_ID GUC_HXG_REQUEST_MSG_n_DATAn 171 + #define VF2GUC_RELAY_TO_PF_REQUEST_MSG_n_RELAY_DATAx GUC_HXG_REQUEST_MSG_n_DATAn 172 + #define VF2GUC_RELAY_TO_PF_REQUEST_MSG_NUM_RELAY_DATA GUC_RELAY_MSG_MAX_LEN 173 + 174 + #endif
+79
drivers/gpu/drm/xe/abi/guc_relay_actions_abi.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* 3 + * Copyright © 2023 Intel Corporation 4 + */ 5 + 6 + #ifndef _ABI_GUC_RELAY_ACTIONS_ABI_H_ 7 + #define _ABI_GUC_RELAY_ACTIONS_ABI_H_ 8 + 9 + /** 10 + * DOC: GuC Relay Debug Actions 11 + * 12 + * This range of action codes is reserved for debugging purposes only and should 13 + * be used only on debug builds. These actions may not be supported by the 14 + * production drivers. Their definitions could be changed in the future. 15 + * 16 + * _`GUC_RELAY_ACTION_DEBUG_ONLY_START` = 0xDEB0 17 + * _`GUC_RELAY_ACTION_DEBUG_ONLY_END` = 0xDEFF 18 + */ 19 + 20 + #define GUC_RELAY_ACTION_DEBUG_ONLY_START 0xDEB0 21 + #define GUC_RELAY_ACTION_DEBUG_ONLY_END 0xDEFF 22 + 23 + /** 24 + * DOC: VFXPF_TESTLOOP 25 + * 26 + * This `Relay Message`_ is used to selftest the `GuC Relay Communication`_. 27 + * 28 + * The following opcodes are defined: 29 + * VFXPF_TESTLOOP_OPCODE_NOP_ will return no data. 30 + * VFXPF_TESTLOOP_OPCODE_BUSY_ will reply with BUSY response first. 31 + * VFXPF_TESTLOOP_OPCODE_RETRY_ will reply with RETRY response instead. 32 + * VFXPF_TESTLOOP_OPCODE_ECHO_ will return same data as received. 33 + * VFXPF_TESTLOOP_OPCODE_FAIL_ will always fail with error. 34 + * 35 + * +---+-------+--------------------------------------------------------------+ 36 + * | | Bits | Description | 37 + * +===+=======+==============================================================+ 38 + * | 0 | 31 | ORIGIN = GUC_HXG_ORIGIN_HOST_ | 39 + * | +-------+--------------------------------------------------------------+ 40 + * | | 30:28 | TYPE = GUC_HXG_TYPE_REQUEST_ or GUC_HXG_TYPE_FAST_REQUEST_ | 41 + * | | | or GUC_HXG_TYPE_EVENT_ | 42 + * | +-------+--------------------------------------------------------------+ 43 + * | | 27:16 | **OPCODE** | 44 + * | | | - _`VFXPF_TESTLOOP_OPCODE_NOP` = 0x0 | 45 + * | | | - _`VFXPF_TESTLOOP_OPCODE_BUSY` = 0xB | 46 + * | | | - _`VFXPF_TESTLOOP_OPCODE_RETRY` = 0xD | 47 + * | | | - _`VFXPF_TESTLOOP_OPCODE_ECHO` = 0xE | 48 + * | | | - _`VFXPF_TESTLOOP_OPCODE_FAIL` = 0xF | 49 + * | +-------+--------------------------------------------------------------+ 50 + * | | 15:0 | ACTION = _`IOV_ACTION_SELFTEST_RELAY` | 51 + * +---+-------+--------------------------------------------------------------+ 52 + * | 1 | 31:0 | **DATA1** = optional, depends on **OPCODE**: | 53 + * | | | for VFXPF_TESTLOOP_OPCODE_BUSY_: time in ms for reply | 54 + * | | | for VFXPF_TESTLOOP_OPCODE_FAIL_: expected error | 55 + * | | | for VFXPF_TESTLOOP_OPCODE_ECHO_: payload | 56 + * +---+-------+--------------------------------------------------------------+ 57 + * |...| 31:0 | **DATAn** = only for **OPCODE** VFXPF_TESTLOOP_OPCODE_ECHO_ | 58 + * +---+-------+--------------------------------------------------------------+ 59 + * 60 + * +---+-------+--------------------------------------------------------------+ 61 + * | | Bits | Description | 62 + * +===+=======+==============================================================+ 63 + * | 0 | 31 | ORIGIN = GUC_HXG_ORIGIN_HOST_ | 64 + * | +-------+--------------------------------------------------------------+ 65 + * | | 30:28 | TYPE = GUC_HXG_TYPE_RESPONSE_SUCCESS_ | 66 + * | +-------+--------------------------------------------------------------+ 67 + * | | 27:0 | DATA0 = MBZ | 68 + * +---+-------+--------------------------------------------------------------+ 69 + * |...| 31:0 | DATAn = only for **OPCODE** VFXPF_TESTLOOP_OPCODE_ECHO_ | 70 + * +---+-------+--------------------------------------------------------------+ 71 + */ 72 + #define GUC_RELAY_ACTION_VFXPF_TESTLOOP (GUC_RELAY_ACTION_DEBUG_ONLY_START + 1) 73 + #define VFXPF_TESTLOOP_OPCODE_NOP 0x0 74 + #define VFXPF_TESTLOOP_OPCODE_BUSY 0xB 75 + #define VFXPF_TESTLOOP_OPCODE_RETRY 0xD 76 + #define VFXPF_TESTLOOP_OPCODE_ECHO 0xE 77 + #define VFXPF_TESTLOOP_OPCODE_FAIL 0xF 78 + 79 + #endif
+118
drivers/gpu/drm/xe/abi/guc_relay_communication_abi.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* 3 + * Copyright © 2023 Intel Corporation 4 + */ 5 + 6 + #ifndef _ABI_GUC_RELAY_COMMUNICATION_ABI_H 7 + #define _ABI_GUC_RELAY_COMMUNICATION_ABI_H 8 + 9 + #include <linux/build_bug.h> 10 + 11 + #include "guc_actions_sriov_abi.h" 12 + #include "guc_communication_ctb_abi.h" 13 + #include "guc_messages_abi.h" 14 + 15 + /** 16 + * DOC: GuC Relay Communication 17 + * 18 + * The communication between Virtual Function (VF) drivers and Physical Function 19 + * (PF) drivers is based on the GuC firmware acting as a proxy (relay) agent. 20 + * 21 + * To communicate with the PF driver, VF's drivers use `VF2GUC_RELAY_TO_PF`_ 22 + * action that takes the `Relay Message`_ as opaque payload and requires the 23 + * relay message identifier (RID) as additional parameter. 24 + * 25 + * This identifier is used by the drivers to match related messages. 26 + * 27 + * The GuC forwards this `Relay Message`_ and its identifier to the PF driver 28 + * in `GUC2PF_RELAY_FROM_VF`_ action. This event message additionally contains 29 + * the identifier of the origin VF (VFID). 30 + * 31 + * Likewise, to communicate with the VF drivers, PF driver use 32 + * `VF2GUC_RELAY_TO_PF`_ action that in addition to the `Relay Message`_ 33 + * and the relay message identifier (RID) also takes the target VF identifier. 34 + * 35 + * The GuC uses this target VFID from the message to select where to send the 36 + * `GUC2VF_RELAY_FROM_PF`_ with the embedded `Relay Message`_ with response:: 37 + * 38 + * VF GuC PF 39 + * | | | 40 + * [ ] VF2GUC_RELAY_TO_PF | | 41 + * [ ]---------------------------> [ ] | 42 + * [ ] { rid, msg } [ ] | 43 + * [ ] [ ] GUC2PF_RELAY_FROM_VF | 44 + * [ ] [ ]---------------------------> [ ] 45 + * [ ] | { VFID, rid, msg } [ ] 46 + * [ ] | [ ] 47 + * [ ] | PF2GUC_RELAY_TO_VF [ ] 48 + * [ ] [ ] <---------------------------[ ] 49 + * [ ] [ ] { VFID, rid, reply } | 50 + * [ ] GUC2VF_RELAY_FROM_PF [ ] | 51 + * [ ] <---------------------------[ ] | 52 + * | { rid, reply } | | 53 + * | | | 54 + * 55 + * It is also possible that PF driver will initiate communication with the 56 + * selected VF driver. The same GuC action messages will be used:: 57 + * 58 + * VF GuC PF 59 + * | | | 60 + * | | PF2GUC_RELAY_TO_VF [ ] 61 + * | [ ] <---------------------------[ ] 62 + * | [ ] { VFID, rid, msg } [ ] 63 + * | GUC2VF_RELAY_FROM_PF [ ] [ ] 64 + * [ ] <---------------------------[ ] [ ] 65 + * [ ] { rid, msg } | [ ] 66 + * [ ] | [ ] 67 + * [ ] VF2GUC_RELAY_TO_PF | [ ] 68 + * [ ]---------------------------> [ ] [ ] 69 + * | { rid, reply } [ ] [ ] 70 + * | [ ] GUC2PF_RELAY_FROM_VF [ ] 71 + * | [ ]---------------------------> [ ] 72 + * | | { VFID, rid, reply } | 73 + * | | | 74 + */ 75 + 76 + /** 77 + * DOC: Relay Message 78 + * 79 + * The `Relay Message`_ is used by Physical Function (PF) driver and Virtual 80 + * Function (VF) drivers to communicate using `GuC Relay Communication`_. 81 + * 82 + * Format of the `Relay Message`_ follows format of the generic `HXG Message`_. 83 + * 84 + * +--------------------------------------------------------------------------+ 85 + * | `Relay Message`_ | 86 + * +==========================================================================+ 87 + * | `HXG Message`_ | 88 + * +--------------------------------------------------------------------------+ 89 + * 90 + * Maximum length of the `Relay Message`_ is limited by the maximum length of 91 + * the `CTB HXG Message`_ and format of the `GUC2PF_RELAY_FROM_VF`_ message. 92 + */ 93 + 94 + #define GUC_RELAY_MSG_MIN_LEN GUC_HXG_MSG_MIN_LEN 95 + #define GUC_RELAY_MSG_MAX_LEN \ 96 + (GUC_CTB_MAX_DWORDS - GUC2PF_RELAY_FROM_VF_EVENT_MSG_MIN_LEN) 97 + 98 + static_assert(PF2GUC_RELAY_TO_VF_REQUEST_MSG_MIN_LEN > 99 + VF2GUC_RELAY_TO_PF_REQUEST_MSG_MIN_LEN); 100 + 101 + /** 102 + * DOC: Relay Error Codes 103 + * 104 + * The `GuC Relay Communication`_ can be used to pass `Relay Message`_ between 105 + * drivers that run on different Operating Systems. To help in troubleshooting, 106 + * `GuC Relay Communication`_ uses error codes that mostly match errno values. 107 + */ 108 + 109 + #define GUC_RELAY_ERROR_UNDISCLOSED 0 110 + #define GUC_RELAY_ERROR_OPERATION_NOT_PERMITTED 1 /* EPERM */ 111 + #define GUC_RELAY_ERROR_PERMISSION_DENIED 13 /* EACCES */ 112 + #define GUC_RELAY_ERROR_INVALID_ARGUMENT 22 /* EINVAL */ 113 + #define GUC_RELAY_ERROR_INVALID_REQUEST_CODE 56 /* EBADRQC */ 114 + #define GUC_RELAY_ERROR_NO_DATA_AVAILABLE 61 /* ENODATA */ 115 + #define GUC_RELAY_ERROR_PROTOCOL_ERROR 71 /* EPROTO */ 116 + #define GUC_RELAY_ERROR_MESSAGE_SIZE 90 /* EMSGSIZE */ 117 + 118 + #endif