From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by mx.groups.io with SMTP id smtpd.web12.69780.1584370834562562137 for ; Mon, 16 Mar 2020 08:00:34 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=H4DuWgat; spf=pass (domain: oracle.com, ip: 156.151.31.85, mailfrom: liran.alon@oracle.com) Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02GErif3156927; Mon, 16 Mar 2020 15:00:34 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=2Cv02oToPe/fAMvnxTGcIIC6UBc/a/H+trgs6nLAKSM=; b=H4DuWgatHd7qkxUO7EJ0Dak8d9/oqneKP0bxcTuRb03syjjKonPoyuzcEvNAmHTg1N65 Qf34/+Hl0p5QN8WAsn61sHmyCScShGU0IOQzExjjwVrIiDn0KdSk3hZq06sRGAKsm/vd ApYGMRhP7dTy8VkGGV7YzN4M41sQOl3hY3kaQ/sZ300p8DQ2q/rN8UbMtLQGaPS1gkJk xrZd9FNAQ2kDG/sXN1wCyIh0uAdigNa2kIok5Iqhy5GTohROuZS4EuWDL3jTxqPjIiwh uSOCds42OG5KZ0WAa8mani2YXwh+dtBSdzFnGbZq5IzXBX0LPFP3hEXpND/Xk+i2xkxr Fw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2yrqwmyacc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Mar 2020 15:00:33 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02GEqRT9048654; Mon, 16 Mar 2020 15:00:32 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2ys8rcmr6c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Mar 2020 15:00:32 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02GF0VbD011650; Mon, 16 Mar 2020 15:00:31 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 16 Mar 2020 08:00:30 -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 11/17] OvmfPkg/PvScsiDxe: Define device interface structures and constants Date: Mon, 16 Mar 2020 17:01:07 +0200 Message-Id: <20200316150113.104630-12-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316150113.104630-1-liran.alon@oracle.com> References: <20200316150113.104630-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9561 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 phishscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003160072 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9561 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 adultscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003160072 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 Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon --- OvmfPkg/Include/IndustryStandard/PvScsi.h | 162 ++++++++++++++++++++++ 1 file changed, 162 insertions(+) diff --git a/OvmfPkg/Include/IndustryStandard/PvScsi.h b/OvmfPkg/Include/IndustryStandard/PvScsi.h index 004c0af84989..7bb6e664dfcd 100644 --- a/OvmfPkg/Include/IndustryStandard/PvScsi.h +++ b/OvmfPkg/Include/IndustryStandard/PvScsi.h @@ -18,4 +18,166 @@ #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) + +enum PVSCSI_BAR0_OFFSETS { + PVSCSI_REG_OFFSET_COMMAND = 0x0, + PVSCSI_REG_OFFSET_COMMAND_DATA = 0x4, + PVSCSI_REG_OFFSET_COMMAND_STATUS = 0x8, + PVSCSI_REG_OFFSET_LAST_STS_0 = 0x100, + PVSCSI_REG_OFFSET_LAST_STS_1 = 0x104, + PVSCSI_REG_OFFSET_LAST_STS_2 = 0x108, + PVSCSI_REG_OFFSET_LAST_STS_3 = 0x10c, + PVSCSI_REG_OFFSET_INTR_STATUS = 0x100c, + PVSCSI_REG_OFFSET_INTR_MASK = 0x2010, + PVSCSI_REG_OFFSET_KICK_NON_RW_IO = 0x3014, + PVSCSI_REG_OFFSET_DEBUG = 0x3018, + PVSCSI_REG_OFFSET_KICK_RW_IO = 0x4018, +}; + +// +// Define Interrupt-Status register flags +// +#define PVSCSI_INTR_CMPL_0 (1 << 0) +#define PVSCSI_INTR_CMPL_1 (1 << 1) +#define PVSCSI_INTR_CMPL_MASK (PVSCSI_INTR_CMPL_0 | PVSCSI_INTR_CMPL_1) + +enum PVSCSI_COMMANDS { + PVSCSI_CMD_FIRST = 0, + PVSCSI_CMD_ADAPTER_RESET = 1, + PVSCSI_CMD_ISSUE_SCSI = 2, + PVSCSI_CMD_SETUP_RINGS = 3, + PVSCSI_CMD_RESET_BUS = 4, + PVSCSI_CMD_RESET_DEVICE = 5, + PVSCSI_CMD_ABORT_CMD = 6, + PVSCSI_CMD_CONFIG = 7, + PVSCSI_CMD_SETUP_MSG_RING = 8, + PVSCSI_CMD_DEVICE_UNPLUG = 9, + PVSCSI_CMD_LAST = 10 +}; + +#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 (1 << 0) +#define PVSCSI_FLAG_CMD_OUT_OF_BAND_CDB (1 << 1) +#define PVSCSI_FLAG_CMD_DIR_NONE (1 << 2) +#define PVSCSI_FLAG_CMD_DIR_TOHOST (1 << 3) +#define PVSCSI_FLAG_CMD_DIR_TODEVICE (1 << 4) + +#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 +// +enum PVSCSI_HOST_BUS_ADAPTER_STATUS { + BTSTAT_SUCCESS = 0x00, // CCB complete normally with no errors + BTSTAT_LINKED_COMMAND_COMPLETED = 0x0a, + BTSTAT_LINKED_COMMAND_COMPLETED_WITH_FLAG = 0x0b, + BTSTAT_DATA_UNDERRUN = 0x0c, + BTSTAT_SELTIMEO = 0x11, // SCSI selection timeout + BTSTAT_DATARUN = 0x12, // Data overrun/underrun + BTSTAT_BUSFREE = 0x13, // Unexpected bus free + BTSTAT_INVPHASE = 0x14, // + // Invalid bus phase or sequence requested by + // target + // + BTSTAT_LUNMISMATCH = 0x17, // Linked CCB has different LUN from first CCB + BTSTAT_SENSFAILED = 0x1b, // Auto request sense failed + BTSTAT_TAGREJECT = 0x1c, // + // SCSI II tagged queueing message rejected by + // target + // + BTSTAT_BADMSG = 0x1d, // + // Unsupported message received by the host + // adapter + // + BTSTAT_HAHARDWARE = 0x20, // Host adapter hardware failed + BTSTAT_NORESPONSE = 0x21, // + // Target did not respond to SCSI ATN sent a + // SCSI RST + // + BTSTAT_SENTRST = 0x22, // Host adapter asserted a SCSI RST + BTSTAT_RECVRST = 0x23, // Other SCSI devices asserted a SCSI RST + BTSTAT_DISCONNECT = 0x24, // + // Target device reconnected improperly + // (w/o tag) + // + BTSTAT_BUSRESET = 0x25, // Host adapter issued BUS device reset + BTSTAT_ABORTQUEUE = 0x26, // Abort queue generated + BTSTAT_HASOFTWARE = 0x27, // Host adapter software error + BTSTAT_HATIMEOUT = 0x30, // Host adapter hardware timeout error + BTSTAT_SCSIPARITY = 0x34, // SCSI parity error detected +}; + +#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