162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * VMware PVSCSI header file 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Copyright (C) 2008-2014, VMware, Inc. All Rights Reserved. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * This program is free software; you can redistribute it and/or modify it 762306a36Sopenharmony_ci * under the terms of the GNU General Public License as published by the 862306a36Sopenharmony_ci * Free Software Foundation; version 2 of the License and no later version. 962306a36Sopenharmony_ci * 1062306a36Sopenharmony_ci * This program is distributed in the hope that it will be useful, but 1162306a36Sopenharmony_ci * WITHOUT ANY WARRANTY; without even the implied warranty of 1262306a36Sopenharmony_ci * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 1362306a36Sopenharmony_ci * NON INFRINGEMENT. See the GNU General Public License for more 1462306a36Sopenharmony_ci * details. 1562306a36Sopenharmony_ci * 1662306a36Sopenharmony_ci * You should have received a copy of the GNU General Public License 1762306a36Sopenharmony_ci * along with this program; if not, write to the Free Software 1862306a36Sopenharmony_ci * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1962306a36Sopenharmony_ci * 2062306a36Sopenharmony_ci */ 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci#ifndef _VMW_PVSCSI_H_ 2362306a36Sopenharmony_ci#define _VMW_PVSCSI_H_ 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci#include <linux/types.h> 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci#define PVSCSI_DRIVER_VERSION_STRING "1.0.7.0-k" 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci#define PVSCSI_MAX_NUM_SG_ENTRIES_PER_SEGMENT 128 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci#define MASK(n) ((1 << (n)) - 1) /* make an n-bit mask */ 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci#define PCI_DEVICE_ID_VMWARE_PVSCSI 0x07C0 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci/* 3662306a36Sopenharmony_ci * host adapter status/error codes 3762306a36Sopenharmony_ci */ 3862306a36Sopenharmony_cienum HostBusAdapterStatus { 3962306a36Sopenharmony_ci BTSTAT_SUCCESS = 0x00, /* CCB complete normally with no errors */ 4062306a36Sopenharmony_ci BTSTAT_LINKED_COMMAND_COMPLETED = 0x0a, 4162306a36Sopenharmony_ci BTSTAT_LINKED_COMMAND_COMPLETED_WITH_FLAG = 0x0b, 4262306a36Sopenharmony_ci BTSTAT_DATA_UNDERRUN = 0x0c, 4362306a36Sopenharmony_ci BTSTAT_SELTIMEO = 0x11, /* SCSI selection timeout */ 4462306a36Sopenharmony_ci BTSTAT_DATARUN = 0x12, /* data overrun/underrun */ 4562306a36Sopenharmony_ci BTSTAT_BUSFREE = 0x13, /* unexpected bus free */ 4662306a36Sopenharmony_ci BTSTAT_INVPHASE = 0x14, /* invalid bus phase or sequence 4762306a36Sopenharmony_ci * requested by target */ 4862306a36Sopenharmony_ci BTSTAT_LUNMISMATCH = 0x17, /* linked CCB has different LUN from 4962306a36Sopenharmony_ci * first CCB */ 5062306a36Sopenharmony_ci BTSTAT_INVPARAM = 0x1a, /* invalid parameter in CCB or segment 5162306a36Sopenharmony_ci * list */ 5262306a36Sopenharmony_ci BTSTAT_SENSFAILED = 0x1b, /* auto request sense failed */ 5362306a36Sopenharmony_ci BTSTAT_TAGREJECT = 0x1c, /* SCSI II tagged queueing message 5462306a36Sopenharmony_ci * rejected by target */ 5562306a36Sopenharmony_ci BTSTAT_BADMSG = 0x1d, /* unsupported message received by the 5662306a36Sopenharmony_ci * host adapter */ 5762306a36Sopenharmony_ci BTSTAT_HAHARDWARE = 0x20, /* host adapter hardware failed */ 5862306a36Sopenharmony_ci BTSTAT_NORESPONSE = 0x21, /* target did not respond to SCSI ATN, 5962306a36Sopenharmony_ci * sent a SCSI RST */ 6062306a36Sopenharmony_ci BTSTAT_SENTRST = 0x22, /* host adapter asserted a SCSI RST */ 6162306a36Sopenharmony_ci BTSTAT_RECVRST = 0x23, /* other SCSI devices asserted a SCSI 6262306a36Sopenharmony_ci * RST */ 6362306a36Sopenharmony_ci BTSTAT_DISCONNECT = 0x24, /* target device reconnected improperly 6462306a36Sopenharmony_ci * (w/o tag) */ 6562306a36Sopenharmony_ci BTSTAT_BUSRESET = 0x25, /* host adapter issued BUS device reset */ 6662306a36Sopenharmony_ci BTSTAT_ABORTQUEUE = 0x26, /* abort queue generated */ 6762306a36Sopenharmony_ci BTSTAT_HASOFTWARE = 0x27, /* host adapter software error */ 6862306a36Sopenharmony_ci BTSTAT_HATIMEOUT = 0x30, /* host adapter hardware timeout error */ 6962306a36Sopenharmony_ci BTSTAT_SCSIPARITY = 0x34, /* SCSI parity error detected */ 7062306a36Sopenharmony_ci}; 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci/* 7362306a36Sopenharmony_ci * SCSI device status values. 7462306a36Sopenharmony_ci */ 7562306a36Sopenharmony_cienum ScsiDeviceStatus { 7662306a36Sopenharmony_ci SDSTAT_GOOD = 0x00, /* No errors. */ 7762306a36Sopenharmony_ci SDSTAT_CHECK = 0x02, /* Check condition. */ 7862306a36Sopenharmony_ci}; 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ci/* 8162306a36Sopenharmony_ci * Register offsets. 8262306a36Sopenharmony_ci * 8362306a36Sopenharmony_ci * These registers are accessible both via i/o space and mm i/o. 8462306a36Sopenharmony_ci */ 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_cienum PVSCSIRegOffset { 8762306a36Sopenharmony_ci PVSCSI_REG_OFFSET_COMMAND = 0x0, 8862306a36Sopenharmony_ci PVSCSI_REG_OFFSET_COMMAND_DATA = 0x4, 8962306a36Sopenharmony_ci PVSCSI_REG_OFFSET_COMMAND_STATUS = 0x8, 9062306a36Sopenharmony_ci PVSCSI_REG_OFFSET_LAST_STS_0 = 0x100, 9162306a36Sopenharmony_ci PVSCSI_REG_OFFSET_LAST_STS_1 = 0x104, 9262306a36Sopenharmony_ci PVSCSI_REG_OFFSET_LAST_STS_2 = 0x108, 9362306a36Sopenharmony_ci PVSCSI_REG_OFFSET_LAST_STS_3 = 0x10c, 9462306a36Sopenharmony_ci PVSCSI_REG_OFFSET_INTR_STATUS = 0x100c, 9562306a36Sopenharmony_ci PVSCSI_REG_OFFSET_INTR_MASK = 0x2010, 9662306a36Sopenharmony_ci PVSCSI_REG_OFFSET_KICK_NON_RW_IO = 0x3014, 9762306a36Sopenharmony_ci PVSCSI_REG_OFFSET_DEBUG = 0x3018, 9862306a36Sopenharmony_ci PVSCSI_REG_OFFSET_KICK_RW_IO = 0x4018, 9962306a36Sopenharmony_ci}; 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ci/* 10262306a36Sopenharmony_ci * Virtual h/w commands. 10362306a36Sopenharmony_ci */ 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_cienum PVSCSICommands { 10662306a36Sopenharmony_ci PVSCSI_CMD_FIRST = 0, /* has to be first */ 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_ci PVSCSI_CMD_ADAPTER_RESET = 1, 10962306a36Sopenharmony_ci PVSCSI_CMD_ISSUE_SCSI = 2, 11062306a36Sopenharmony_ci PVSCSI_CMD_SETUP_RINGS = 3, 11162306a36Sopenharmony_ci PVSCSI_CMD_RESET_BUS = 4, 11262306a36Sopenharmony_ci PVSCSI_CMD_RESET_DEVICE = 5, 11362306a36Sopenharmony_ci PVSCSI_CMD_ABORT_CMD = 6, 11462306a36Sopenharmony_ci PVSCSI_CMD_CONFIG = 7, 11562306a36Sopenharmony_ci PVSCSI_CMD_SETUP_MSG_RING = 8, 11662306a36Sopenharmony_ci PVSCSI_CMD_DEVICE_UNPLUG = 9, 11762306a36Sopenharmony_ci PVSCSI_CMD_SETUP_REQCALLTHRESHOLD = 10, 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ci PVSCSI_CMD_LAST = 11 /* has to be last */ 12062306a36Sopenharmony_ci}; 12162306a36Sopenharmony_ci 12262306a36Sopenharmony_ci/* 12362306a36Sopenharmony_ci * Command descriptor for PVSCSI_CMD_RESET_DEVICE -- 12462306a36Sopenharmony_ci */ 12562306a36Sopenharmony_ci 12662306a36Sopenharmony_cistruct PVSCSICmdDescResetDevice { 12762306a36Sopenharmony_ci u32 target; 12862306a36Sopenharmony_ci u8 lun[8]; 12962306a36Sopenharmony_ci} __packed; 13062306a36Sopenharmony_ci 13162306a36Sopenharmony_ci/* 13262306a36Sopenharmony_ci * Command descriptor for PVSCSI_CMD_CONFIG -- 13362306a36Sopenharmony_ci */ 13462306a36Sopenharmony_ci 13562306a36Sopenharmony_cistruct PVSCSICmdDescConfigCmd { 13662306a36Sopenharmony_ci u64 cmpAddr; 13762306a36Sopenharmony_ci u64 configPageAddress; 13862306a36Sopenharmony_ci u32 configPageNum; 13962306a36Sopenharmony_ci u32 _pad; 14062306a36Sopenharmony_ci} __packed; 14162306a36Sopenharmony_ci 14262306a36Sopenharmony_ci/* 14362306a36Sopenharmony_ci * Command descriptor for PVSCSI_CMD_SETUP_REQCALLTHRESHOLD -- 14462306a36Sopenharmony_ci */ 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_cistruct PVSCSICmdDescSetupReqCall { 14762306a36Sopenharmony_ci u32 enable; 14862306a36Sopenharmony_ci} __packed; 14962306a36Sopenharmony_ci 15062306a36Sopenharmony_cienum PVSCSIConfigPageType { 15162306a36Sopenharmony_ci PVSCSI_CONFIG_PAGE_CONTROLLER = 0x1958, 15262306a36Sopenharmony_ci PVSCSI_CONFIG_PAGE_PHY = 0x1959, 15362306a36Sopenharmony_ci PVSCSI_CONFIG_PAGE_DEVICE = 0x195a, 15462306a36Sopenharmony_ci}; 15562306a36Sopenharmony_ci 15662306a36Sopenharmony_cienum PVSCSIConfigPageAddressType { 15762306a36Sopenharmony_ci PVSCSI_CONFIG_CONTROLLER_ADDRESS = 0x2120, 15862306a36Sopenharmony_ci PVSCSI_CONFIG_BUSTARGET_ADDRESS = 0x2121, 15962306a36Sopenharmony_ci PVSCSI_CONFIG_PHY_ADDRESS = 0x2122, 16062306a36Sopenharmony_ci}; 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_ci/* 16362306a36Sopenharmony_ci * Command descriptor for PVSCSI_CMD_ABORT_CMD -- 16462306a36Sopenharmony_ci * 16562306a36Sopenharmony_ci * - currently does not support specifying the LUN. 16662306a36Sopenharmony_ci * - _pad should be 0. 16762306a36Sopenharmony_ci */ 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_cistruct PVSCSICmdDescAbortCmd { 17062306a36Sopenharmony_ci u64 context; 17162306a36Sopenharmony_ci u32 target; 17262306a36Sopenharmony_ci u32 _pad; 17362306a36Sopenharmony_ci} __packed; 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ci/* 17662306a36Sopenharmony_ci * Command descriptor for PVSCSI_CMD_SETUP_RINGS -- 17762306a36Sopenharmony_ci * 17862306a36Sopenharmony_ci * Notes: 17962306a36Sopenharmony_ci * - reqRingNumPages and cmpRingNumPages need to be power of two. 18062306a36Sopenharmony_ci * - reqRingNumPages and cmpRingNumPages need to be different from 0, 18162306a36Sopenharmony_ci * - reqRingNumPages and cmpRingNumPages need to be inferior to 18262306a36Sopenharmony_ci * PVSCSI_SETUP_RINGS_MAX_NUM_PAGES. 18362306a36Sopenharmony_ci */ 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_ci#define PVSCSI_SETUP_RINGS_MAX_NUM_PAGES 32 18662306a36Sopenharmony_cistruct PVSCSICmdDescSetupRings { 18762306a36Sopenharmony_ci u32 reqRingNumPages; 18862306a36Sopenharmony_ci u32 cmpRingNumPages; 18962306a36Sopenharmony_ci u64 ringsStatePPN; 19062306a36Sopenharmony_ci u64 reqRingPPNs[PVSCSI_SETUP_RINGS_MAX_NUM_PAGES]; 19162306a36Sopenharmony_ci u64 cmpRingPPNs[PVSCSI_SETUP_RINGS_MAX_NUM_PAGES]; 19262306a36Sopenharmony_ci} __packed; 19362306a36Sopenharmony_ci 19462306a36Sopenharmony_ci/* 19562306a36Sopenharmony_ci * Command descriptor for PVSCSI_CMD_SETUP_MSG_RING -- 19662306a36Sopenharmony_ci * 19762306a36Sopenharmony_ci * Notes: 19862306a36Sopenharmony_ci * - this command was not supported in the initial revision of the h/w 19962306a36Sopenharmony_ci * interface. Before using it, you need to check that it is supported by 20062306a36Sopenharmony_ci * writing PVSCSI_CMD_SETUP_MSG_RING to the 'command' register, then 20162306a36Sopenharmony_ci * immediately after read the 'command status' register: 20262306a36Sopenharmony_ci * * a value of -1 means that the cmd is NOT supported, 20362306a36Sopenharmony_ci * * a value != -1 means that the cmd IS supported. 20462306a36Sopenharmony_ci * If it's supported the 'command status' register should return: 20562306a36Sopenharmony_ci * sizeof(PVSCSICmdDescSetupMsgRing) / sizeof(u32). 20662306a36Sopenharmony_ci * - this command should be issued _after_ the usual SETUP_RINGS so that the 20762306a36Sopenharmony_ci * RingsState page is already setup. If not, the command is a nop. 20862306a36Sopenharmony_ci * - numPages needs to be a power of two, 20962306a36Sopenharmony_ci * - numPages needs to be different from 0, 21062306a36Sopenharmony_ci * - _pad should be zero. 21162306a36Sopenharmony_ci */ 21262306a36Sopenharmony_ci 21362306a36Sopenharmony_ci#define PVSCSI_SETUP_MSG_RING_MAX_NUM_PAGES 16 21462306a36Sopenharmony_ci 21562306a36Sopenharmony_cistruct PVSCSICmdDescSetupMsgRing { 21662306a36Sopenharmony_ci u32 numPages; 21762306a36Sopenharmony_ci u32 _pad; 21862306a36Sopenharmony_ci u64 ringPPNs[PVSCSI_SETUP_MSG_RING_MAX_NUM_PAGES]; 21962306a36Sopenharmony_ci} __packed; 22062306a36Sopenharmony_ci 22162306a36Sopenharmony_cienum PVSCSIMsgType { 22262306a36Sopenharmony_ci PVSCSI_MSG_DEV_ADDED = 0, 22362306a36Sopenharmony_ci PVSCSI_MSG_DEV_REMOVED = 1, 22462306a36Sopenharmony_ci PVSCSI_MSG_LAST = 2, 22562306a36Sopenharmony_ci}; 22662306a36Sopenharmony_ci 22762306a36Sopenharmony_ci/* 22862306a36Sopenharmony_ci * Msg descriptor. 22962306a36Sopenharmony_ci * 23062306a36Sopenharmony_ci * sizeof(struct PVSCSIRingMsgDesc) == 128. 23162306a36Sopenharmony_ci * 23262306a36Sopenharmony_ci * - type is of type enum PVSCSIMsgType. 23362306a36Sopenharmony_ci * - the content of args depend on the type of event being delivered. 23462306a36Sopenharmony_ci */ 23562306a36Sopenharmony_ci 23662306a36Sopenharmony_cistruct PVSCSIRingMsgDesc { 23762306a36Sopenharmony_ci u32 type; 23862306a36Sopenharmony_ci u32 args[31]; 23962306a36Sopenharmony_ci} __packed; 24062306a36Sopenharmony_ci 24162306a36Sopenharmony_cistruct PVSCSIMsgDescDevStatusChanged { 24262306a36Sopenharmony_ci u32 type; /* PVSCSI_MSG_DEV _ADDED / _REMOVED */ 24362306a36Sopenharmony_ci u32 bus; 24462306a36Sopenharmony_ci u32 target; 24562306a36Sopenharmony_ci u8 lun[8]; 24662306a36Sopenharmony_ci u32 pad[27]; 24762306a36Sopenharmony_ci} __packed; 24862306a36Sopenharmony_ci 24962306a36Sopenharmony_ci/* 25062306a36Sopenharmony_ci * Rings state. 25162306a36Sopenharmony_ci * 25262306a36Sopenharmony_ci * - the fields: 25362306a36Sopenharmony_ci * . msgProdIdx, 25462306a36Sopenharmony_ci * . msgConsIdx, 25562306a36Sopenharmony_ci * . msgNumEntriesLog2, 25662306a36Sopenharmony_ci * .. are only used once the SETUP_MSG_RING cmd has been issued. 25762306a36Sopenharmony_ci * - '_pad' helps to ensure that the msg related fields are on their own 25862306a36Sopenharmony_ci * cache-line. 25962306a36Sopenharmony_ci */ 26062306a36Sopenharmony_ci 26162306a36Sopenharmony_cistruct PVSCSIRingsState { 26262306a36Sopenharmony_ci u32 reqProdIdx; 26362306a36Sopenharmony_ci u32 reqConsIdx; 26462306a36Sopenharmony_ci u32 reqNumEntriesLog2; 26562306a36Sopenharmony_ci 26662306a36Sopenharmony_ci u32 cmpProdIdx; 26762306a36Sopenharmony_ci u32 cmpConsIdx; 26862306a36Sopenharmony_ci u32 cmpNumEntriesLog2; 26962306a36Sopenharmony_ci 27062306a36Sopenharmony_ci u32 reqCallThreshold; 27162306a36Sopenharmony_ci 27262306a36Sopenharmony_ci u8 _pad[100]; 27362306a36Sopenharmony_ci 27462306a36Sopenharmony_ci u32 msgProdIdx; 27562306a36Sopenharmony_ci u32 msgConsIdx; 27662306a36Sopenharmony_ci u32 msgNumEntriesLog2; 27762306a36Sopenharmony_ci} __packed; 27862306a36Sopenharmony_ci 27962306a36Sopenharmony_ci/* 28062306a36Sopenharmony_ci * Request descriptor. 28162306a36Sopenharmony_ci * 28262306a36Sopenharmony_ci * sizeof(RingReqDesc) = 128 28362306a36Sopenharmony_ci * 28462306a36Sopenharmony_ci * - context: is a unique identifier of a command. It could normally be any 28562306a36Sopenharmony_ci * 64bit value, however we currently store it in the serialNumber variable 28662306a36Sopenharmony_ci * of struct SCSI_Command, so we have the following restrictions due to the 28762306a36Sopenharmony_ci * way this field is handled in the vmkernel storage stack: 28862306a36Sopenharmony_ci * * this value can't be 0, 28962306a36Sopenharmony_ci * * the upper 32bit need to be 0 since serialNumber is as a u32. 29062306a36Sopenharmony_ci * Currently tracked as PR 292060. 29162306a36Sopenharmony_ci * - dataLen: contains the total number of bytes that need to be transferred. 29262306a36Sopenharmony_ci * - dataAddr: 29362306a36Sopenharmony_ci * * if PVSCSI_FLAG_CMD_WITH_SG_LIST is set: dataAddr is the PA of the first 29462306a36Sopenharmony_ci * s/g table segment, each s/g segment is entirely contained on a single 29562306a36Sopenharmony_ci * page of physical memory, 29662306a36Sopenharmony_ci * * if PVSCSI_FLAG_CMD_WITH_SG_LIST is NOT set, then dataAddr is the PA of 29762306a36Sopenharmony_ci * the buffer used for the DMA transfer, 29862306a36Sopenharmony_ci * - flags: 29962306a36Sopenharmony_ci * * PVSCSI_FLAG_CMD_WITH_SG_LIST: see dataAddr above, 30062306a36Sopenharmony_ci * * PVSCSI_FLAG_CMD_DIR_NONE: no DMA involved, 30162306a36Sopenharmony_ci * * PVSCSI_FLAG_CMD_DIR_TOHOST: transfer from device to main memory, 30262306a36Sopenharmony_ci * * PVSCSI_FLAG_CMD_DIR_TODEVICE: transfer from main memory to device, 30362306a36Sopenharmony_ci * * PVSCSI_FLAG_CMD_OUT_OF_BAND_CDB: reserved to handle CDBs larger than 30462306a36Sopenharmony_ci * 16bytes. To be specified. 30562306a36Sopenharmony_ci * - vcpuHint: vcpuId of the processor that will be most likely waiting for the 30662306a36Sopenharmony_ci * completion of the i/o. For guest OSes that use lowest priority message 30762306a36Sopenharmony_ci * delivery mode (such as windows), we use this "hint" to deliver the 30862306a36Sopenharmony_ci * completion action to the proper vcpu. For now, we can use the vcpuId of 30962306a36Sopenharmony_ci * the processor that initiated the i/o as a likely candidate for the vcpu 31062306a36Sopenharmony_ci * that will be waiting for the completion.. 31162306a36Sopenharmony_ci * - bus should be 0: we currently only support bus 0 for now. 31262306a36Sopenharmony_ci * - unused should be zero'd. 31362306a36Sopenharmony_ci */ 31462306a36Sopenharmony_ci 31562306a36Sopenharmony_ci#define PVSCSI_FLAG_CMD_WITH_SG_LIST (1 << 0) 31662306a36Sopenharmony_ci#define PVSCSI_FLAG_CMD_OUT_OF_BAND_CDB (1 << 1) 31762306a36Sopenharmony_ci#define PVSCSI_FLAG_CMD_DIR_NONE (1 << 2) 31862306a36Sopenharmony_ci#define PVSCSI_FLAG_CMD_DIR_TOHOST (1 << 3) 31962306a36Sopenharmony_ci#define PVSCSI_FLAG_CMD_DIR_TODEVICE (1 << 4) 32062306a36Sopenharmony_ci 32162306a36Sopenharmony_cistruct PVSCSIRingReqDesc { 32262306a36Sopenharmony_ci u64 context; 32362306a36Sopenharmony_ci u64 dataAddr; 32462306a36Sopenharmony_ci u64 dataLen; 32562306a36Sopenharmony_ci u64 senseAddr; 32662306a36Sopenharmony_ci u32 senseLen; 32762306a36Sopenharmony_ci u32 flags; 32862306a36Sopenharmony_ci u8 cdb[16]; 32962306a36Sopenharmony_ci u8 cdbLen; 33062306a36Sopenharmony_ci u8 lun[8]; 33162306a36Sopenharmony_ci u8 tag; 33262306a36Sopenharmony_ci u8 bus; 33362306a36Sopenharmony_ci u8 target; 33462306a36Sopenharmony_ci u16 vcpuHint; 33562306a36Sopenharmony_ci u8 unused[58]; 33662306a36Sopenharmony_ci} __packed; 33762306a36Sopenharmony_ci 33862306a36Sopenharmony_ci/* 33962306a36Sopenharmony_ci * Scatter-gather list management. 34062306a36Sopenharmony_ci * 34162306a36Sopenharmony_ci * As described above, when PVSCSI_FLAG_CMD_WITH_SG_LIST is set in the 34262306a36Sopenharmony_ci * RingReqDesc.flags, then RingReqDesc.dataAddr is the PA of the first s/g 34362306a36Sopenharmony_ci * table segment. 34462306a36Sopenharmony_ci * 34562306a36Sopenharmony_ci * - each segment of the s/g table contain a succession of struct 34662306a36Sopenharmony_ci * PVSCSISGElement. 34762306a36Sopenharmony_ci * - each segment is entirely contained on a single physical page of memory. 34862306a36Sopenharmony_ci * - a "chain" s/g element has the flag PVSCSI_SGE_FLAG_CHAIN_ELEMENT set in 34962306a36Sopenharmony_ci * PVSCSISGElement.flags and in this case: 35062306a36Sopenharmony_ci * * addr is the PA of the next s/g segment, 35162306a36Sopenharmony_ci * * length is undefined, assumed to be 0. 35262306a36Sopenharmony_ci */ 35362306a36Sopenharmony_ci 35462306a36Sopenharmony_cistruct PVSCSISGElement { 35562306a36Sopenharmony_ci u64 addr; 35662306a36Sopenharmony_ci u32 length; 35762306a36Sopenharmony_ci u32 flags; 35862306a36Sopenharmony_ci} __packed; 35962306a36Sopenharmony_ci 36062306a36Sopenharmony_ci/* 36162306a36Sopenharmony_ci * Completion descriptor. 36262306a36Sopenharmony_ci * 36362306a36Sopenharmony_ci * sizeof(RingCmpDesc) = 32 36462306a36Sopenharmony_ci * 36562306a36Sopenharmony_ci * - context: identifier of the command. The same thing that was specified 36662306a36Sopenharmony_ci * under "context" as part of struct RingReqDesc at initiation time, 36762306a36Sopenharmony_ci * - dataLen: number of bytes transferred for the actual i/o operation, 36862306a36Sopenharmony_ci * - senseLen: number of bytes written into the sense buffer, 36962306a36Sopenharmony_ci * - hostStatus: adapter status, 37062306a36Sopenharmony_ci * - scsiStatus: device status, 37162306a36Sopenharmony_ci * - _pad should be zero. 37262306a36Sopenharmony_ci */ 37362306a36Sopenharmony_ci 37462306a36Sopenharmony_cistruct PVSCSIRingCmpDesc { 37562306a36Sopenharmony_ci u64 context; 37662306a36Sopenharmony_ci u64 dataLen; 37762306a36Sopenharmony_ci u32 senseLen; 37862306a36Sopenharmony_ci u16 hostStatus; 37962306a36Sopenharmony_ci u16 scsiStatus; 38062306a36Sopenharmony_ci u32 _pad[2]; 38162306a36Sopenharmony_ci} __packed; 38262306a36Sopenharmony_ci 38362306a36Sopenharmony_cistruct PVSCSIConfigPageHeader { 38462306a36Sopenharmony_ci u32 pageNum; 38562306a36Sopenharmony_ci u16 numDwords; 38662306a36Sopenharmony_ci u16 hostStatus; 38762306a36Sopenharmony_ci u16 scsiStatus; 38862306a36Sopenharmony_ci u16 reserved[3]; 38962306a36Sopenharmony_ci} __packed; 39062306a36Sopenharmony_ci 39162306a36Sopenharmony_cistruct PVSCSIConfigPageController { 39262306a36Sopenharmony_ci struct PVSCSIConfigPageHeader header; 39362306a36Sopenharmony_ci u64 nodeWWN; /* Device name as defined in the SAS spec. */ 39462306a36Sopenharmony_ci u16 manufacturer[64]; 39562306a36Sopenharmony_ci u16 serialNumber[64]; 39662306a36Sopenharmony_ci u16 opromVersion[32]; 39762306a36Sopenharmony_ci u16 hwVersion[32]; 39862306a36Sopenharmony_ci u16 firmwareVersion[32]; 39962306a36Sopenharmony_ci u32 numPhys; 40062306a36Sopenharmony_ci u8 useConsecutivePhyWWNs; 40162306a36Sopenharmony_ci u8 reserved[3]; 40262306a36Sopenharmony_ci} __packed; 40362306a36Sopenharmony_ci 40462306a36Sopenharmony_ci/* 40562306a36Sopenharmony_ci * Interrupt status / IRQ bits. 40662306a36Sopenharmony_ci */ 40762306a36Sopenharmony_ci 40862306a36Sopenharmony_ci#define PVSCSI_INTR_CMPL_0 (1 << 0) 40962306a36Sopenharmony_ci#define PVSCSI_INTR_CMPL_1 (1 << 1) 41062306a36Sopenharmony_ci#define PVSCSI_INTR_CMPL_MASK MASK(2) 41162306a36Sopenharmony_ci 41262306a36Sopenharmony_ci#define PVSCSI_INTR_MSG_0 (1 << 2) 41362306a36Sopenharmony_ci#define PVSCSI_INTR_MSG_1 (1 << 3) 41462306a36Sopenharmony_ci#define PVSCSI_INTR_MSG_MASK (MASK(2) << 2) 41562306a36Sopenharmony_ci 41662306a36Sopenharmony_ci#define PVSCSI_INTR_ALL_SUPPORTED MASK(4) 41762306a36Sopenharmony_ci 41862306a36Sopenharmony_ci/* 41962306a36Sopenharmony_ci * Number of MSI-X vectors supported. 42062306a36Sopenharmony_ci */ 42162306a36Sopenharmony_ci#define PVSCSI_MAX_INTRS 24 42262306a36Sopenharmony_ci 42362306a36Sopenharmony_ci/* 42462306a36Sopenharmony_ci * Misc constants for the rings. 42562306a36Sopenharmony_ci */ 42662306a36Sopenharmony_ci 42762306a36Sopenharmony_ci#define PVSCSI_MAX_NUM_PAGES_REQ_RING PVSCSI_SETUP_RINGS_MAX_NUM_PAGES 42862306a36Sopenharmony_ci#define PVSCSI_MAX_NUM_PAGES_CMP_RING PVSCSI_SETUP_RINGS_MAX_NUM_PAGES 42962306a36Sopenharmony_ci#define PVSCSI_MAX_NUM_PAGES_MSG_RING PVSCSI_SETUP_MSG_RING_MAX_NUM_PAGES 43062306a36Sopenharmony_ci 43162306a36Sopenharmony_ci#define PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE \ 43262306a36Sopenharmony_ci (PAGE_SIZE / sizeof(struct PVSCSIRingReqDesc)) 43362306a36Sopenharmony_ci 43462306a36Sopenharmony_ci#define PVSCSI_MAX_REQ_QUEUE_DEPTH \ 43562306a36Sopenharmony_ci (PVSCSI_MAX_NUM_PAGES_REQ_RING * PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE) 43662306a36Sopenharmony_ci 43762306a36Sopenharmony_ci#define PVSCSI_MEM_SPACE_COMMAND_NUM_PAGES 1 43862306a36Sopenharmony_ci#define PVSCSI_MEM_SPACE_INTR_STATUS_NUM_PAGES 1 43962306a36Sopenharmony_ci#define PVSCSI_MEM_SPACE_MISC_NUM_PAGES 2 44062306a36Sopenharmony_ci#define PVSCSI_MEM_SPACE_KICK_IO_NUM_PAGES 2 44162306a36Sopenharmony_ci#define PVSCSI_MEM_SPACE_MSIX_NUM_PAGES 2 44262306a36Sopenharmony_ci 44362306a36Sopenharmony_cienum PVSCSIMemSpace { 44462306a36Sopenharmony_ci PVSCSI_MEM_SPACE_COMMAND_PAGE = 0, 44562306a36Sopenharmony_ci PVSCSI_MEM_SPACE_INTR_STATUS_PAGE = 1, 44662306a36Sopenharmony_ci PVSCSI_MEM_SPACE_MISC_PAGE = 2, 44762306a36Sopenharmony_ci PVSCSI_MEM_SPACE_KICK_IO_PAGE = 4, 44862306a36Sopenharmony_ci PVSCSI_MEM_SPACE_MSIX_TABLE_PAGE = 6, 44962306a36Sopenharmony_ci PVSCSI_MEM_SPACE_MSIX_PBA_PAGE = 7, 45062306a36Sopenharmony_ci}; 45162306a36Sopenharmony_ci 45262306a36Sopenharmony_ci#define PVSCSI_MEM_SPACE_NUM_PAGES \ 45362306a36Sopenharmony_ci (PVSCSI_MEM_SPACE_COMMAND_NUM_PAGES + \ 45462306a36Sopenharmony_ci PVSCSI_MEM_SPACE_INTR_STATUS_NUM_PAGES + \ 45562306a36Sopenharmony_ci PVSCSI_MEM_SPACE_MISC_NUM_PAGES + \ 45662306a36Sopenharmony_ci PVSCSI_MEM_SPACE_KICK_IO_NUM_PAGES + \ 45762306a36Sopenharmony_ci PVSCSI_MEM_SPACE_MSIX_NUM_PAGES) 45862306a36Sopenharmony_ci 45962306a36Sopenharmony_ci#define PVSCSI_MEM_SPACE_SIZE (PVSCSI_MEM_SPACE_NUM_PAGES * PAGE_SIZE) 46062306a36Sopenharmony_ci 46162306a36Sopenharmony_ci#endif /* _VMW_PVSCSI_H_ */ 462