From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web11.14079.1585425541501068302 for ; Sat, 28 Mar 2020 12:59:01 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=0LaUY17T; spf=pass (domain: oracle.com, ip: 141.146.126.78, mailfrom: liran.alon@oracle.com) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02SJlFLw028015; Sat, 28 Mar 2020 19:59:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=99kr6U2RcfDYO+1REernvg6uUjlAddFxoN15BAt0oIA=; b=0LaUY17TPrToYy0pZX6BRQu4hmOyaIUD1bhqZsDUN9x4i4oPeBKCPQDryYdMN8LVRBnj 7A0JnWcxBAQMsW7enFCaX1v6F6LUZg/tD+byjVVwySwgvzoJKKagQtMuSAbQ7WNXHs0a UGAF2LdxOGnZdCqRPZO+QhHhIC41k7hJvd0Iosy2TJQi7K5CqReTM4c3+g/lCJky5zuE Q5hTor9iriI94htJC7oNDp2M1QL9t22B4tmfry4fskJRxUG7h9Cc/XeIr5g9aFJ/l5Qb TpzpvJOgNhBavq405i3aczibz4GXH3j5x9ao9D2CmHV/y8KF3vsUhfWzILhKYYvjwdkH vg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 301xhkhh02-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:59:00 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02SJoKGJ031927; Sat, 28 Mar 2020 19:59:00 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 301vm90q6b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:59:00 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02SJwxWZ007274; Sat, 28 Mar 2020 19:58:59 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Mar 2020 12:58:58 -0700 From: "Liran Alon" To: devel@edk2.groups.io, lersek@redhat.com Cc: nikita.leshchenko@oracle.com, aaron.young@oracle.com, jordan.l.justen@intel.com, ard.biesheuvel@linaro.org, Liran Alon Subject: [PATCH v3 11/17] OvmfPkg/PvScsiDxe: Define device interface structures and constants Date: Sat, 28 Mar 2020 23:00:54 +0300 Message-Id: <20200328200100.60786-12-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200328200100.60786-1-liran.alon@oracle.com> References: <20200328200100.60786-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9574 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003280189 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9574 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 clxscore=1015 phishscore=0 adultscore=0 priorityscore=1501 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003280189 Content-Transfer-Encoding: 8bit These definitions will be used by the following commits to complete the implementation of PVSCSI device driver. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2567 Acked-by: Laszlo Ersek Signed-off-by: Liran Alon --- OvmfPkg/Include/IndustryStandard/PvScsi.h | 165 ++++++++++++++++++++++ 1 file changed, 165 insertions(+) diff --git a/OvmfPkg/Include/IndustryStandard/PvScsi.h b/OvmfPkg/Include/IndustryStandard/PvScsi.h index 004c0af84989..a4d6634f3ba0 100644 --- a/OvmfPkg/Include/IndustryStandard/PvScsi.h +++ b/OvmfPkg/Include/IndustryStandard/PvScsi.h @@ -18,4 +18,169 @@ #define PCI_VENDOR_ID_VMWARE (0x15ad) #define PCI_DEVICE_ID_VMWARE_PVSCSI (0x07c0) +// +// CDB (Command Descriptor Block) with size above this constant +// should be considered out-of-band +// +#define PVSCSI_CDB_MAX_SIZE (16) + +typedef enum { + PvScsiRegOffsetCommand = 0x0, + PvScsiRegOffsetCommandData = 0x4, + PvScsiRegOffsetCommandStatus = 0x8, + PvScsiRegOffsetLastSts0 = 0x100, + PvScsiRegOffsetLastSts1 = 0x104, + PvScsiRegOffsetLastSts2 = 0x108, + PvScsiRegOffsetLastSts3 = 0x10c, + PvScsiRegOffsetIntrStatus = 0x100c, + PvScsiRegOffsetIntrMask = 0x2010, + PvScsiRegOffsetKickNonRwIo = 0x3014, + PvScsiRegOffsetDebug = 0x3018, + PvScsiRegOffsetKickRwIo = 0x4018, +} PVSCSI_BAR0_OFFSETS; + +// +// Define Interrupt-Status register flags +// +#define PVSCSI_INTR_CMPL_0 BIT0 +#define PVSCSI_INTR_CMPL_1 BIT1 +#define PVSCSI_INTR_CMPL_MASK (PVSCSI_INTR_CMPL_0 | PVSCSI_INTR_CMPL_1) + +typedef enum { + PvScsiCmdFirst = 0, + PvScsiCmdAdapterReset = 1, + PvScsiCmdIssueScsi = 2, + PvScsiCmdSetupRings = 3, + PvScsiCmdResetBus = 4, + PvScsiCmdResetDevice = 5, + PvScsiCmdAbortCmd = 6, + PvScsiCmdConfig = 7, + PvScsiCmdSetupMsgRing = 8, + PvScsiCmdDeviceUnplug = 9, + PvScsiCmdLast = 10 +} PVSCSI_COMMANDS; + +#define PVSCSI_SETUP_RINGS_MAX_NUM_PAGES (32) + +#pragma pack (1) +typedef struct { + UINT32 ReqRingNumPages; + UINT32 CmpRingNumPages; + UINT64 RingsStatePPN; + UINT64 ReqRingPPNs[PVSCSI_SETUP_RINGS_MAX_NUM_PAGES]; + UINT64 CmpRingPPNs[PVSCSI_SETUP_RINGS_MAX_NUM_PAGES]; +} PVSCSI_CMD_DESC_SETUP_RINGS; +#pragma pack () + +#define PVSCSI_MAX_CMD_DATA_WORDS \ + (sizeof (PVSCSI_CMD_DESC_SETUP_RINGS) / sizeof (UINT32)) + +#pragma pack (1) +typedef struct { + UINT32 ReqProdIdx; + UINT32 ReqConsIdx; + UINT32 ReqNumEntriesLog2; + + UINT32 CmpProdIdx; + UINT32 CmpConsIdx; + UINT32 CmpNumEntriesLog2; + + UINT8 Pad[104]; + + UINT32 MsgProdIdx; + UINT32 MsgConsIdx; + UINT32 MsgNumEntriesLog2; +} PVSCSI_RINGS_STATE; +#pragma pack () + +// +// Define PVSCSI request descriptor tags +// +#define PVSCSI_SIMPLE_QUEUE_TAG (0x20) + +// +// Define PVSCSI request descriptor flags +// +#define PVSCSI_FLAG_CMD_WITH_SG_LIST BIT0 +#define PVSCSI_FLAG_CMD_OUT_OF_BAND_CDB BIT1 +#define PVSCSI_FLAG_CMD_DIR_NONE BIT2 +#define PVSCSI_FLAG_CMD_DIR_TOHOST BIT3 +#define PVSCSI_FLAG_CMD_DIR_TODEVICE BIT4 + +#pragma pack (1) +typedef struct { + UINT64 Context; + UINT64 DataAddr; + UINT64 DataLen; + UINT64 SenseAddr; + UINT32 SenseLen; + UINT32 Flags; + UINT8 Cdb[16]; + UINT8 CdbLen; + UINT8 Lun[8]; + UINT8 Tag; + UINT8 Bus; + UINT8 Target; + UINT8 VcpuHint; + UINT8 Unused[59]; +} PVSCSI_RING_REQ_DESC; +#pragma pack () + +// +// Host adapter status/error codes +// +typedef enum { + PvScsiBtStatSuccess = 0x00, // CCB complete normally with no errors + PvScsiBtStatLinkedCommandCompleted = 0x0a, + PvScsiBtStatLinkedCommandCompletedWithFlag = 0x0b, + PvScsiBtStatDataUnderrun = 0x0c, + PvScsiBtStatSelTimeout = 0x11, // SCSI selection timeout + PvScsiBtStatDatarun = 0x12, // Data overrun/underrun + PvScsiBtStatBusFree = 0x13, // Unexpected bus free + PvScsiBtStatInvPhase = 0x14, // + // Invalid bus phase or sequence requested + // by target + // + PvScsiBtStatLunMismatch = 0x17, // + // Linked CCB has different LUN from first + // CCB + // + PvScsiBtStatSensFailed = 0x1b, // Auto request sense failed + PvScsiBtStatTagReject = 0x1c, // + // SCSI II tagged queueing message rejected + // by target + // + PvScsiBtStatBadMsg = 0x1d, // + // Unsupported message received by the host + // adapter + // + PvScsiBtStatHaHardware = 0x20, // Host adapter hardware failed + PvScsiBtStatNoResponse = 0x21, // + // Target did not respond to SCSI ATN sent + // a SCSI RST + // + PvScsiBtStatSentRst = 0x22, // Host adapter asserted a SCSI RST + PvScsiBtStatRecvRst = 0x23, // Other SCSI devices asserted a SCSI RST + PvScsiBtStatDisconnect = 0x24, // + // Target device reconnected improperly + // (w/o tag) + // + PvScsiBtStatBusReset = 0x25, // Host adapter issued BUS device reset + PvScsiBtStatAbortQueue = 0x26, // Abort queue generated + PvScsiBtStatHaSoftware = 0x27, // Host adapter software error + PvScsiBtStatHaTimeout = 0x30, // Host adapter hardware timeout error + PvScsiBtStatScsiParity = 0x34, // SCSI parity error detected +} PVSCSI_HOST_BUS_ADAPTER_STATUS; + +#pragma pack (1) +typedef struct { + UINT64 Context; + UINT64 DataLen; + UINT32 SenseLen; + UINT16 HostStatus; + UINT16 ScsiStatus; + UINT32 Pad[2]; +} PVSCSI_RING_CMP_DESC; +#pragma pack () + #endif // __PVSCSI_H_ -- 2.20.1