Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 298271
b: refs/heads/master
c: a931073
h: refs/heads/master
i:
  298269: 750e8f3
  298267: f342705
  298263: 3c0927a
  298255: 6430fca
  298239: 4182f2a
v: v3
  • Loading branch information
Arvind Kumar authored and James Bottomley committed Mar 27, 2012
1 parent 27187ef commit 3e8db68
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 26 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3f0bc3b331a371392bb64c5b211b60ec84d5a444
refs/heads/master: a93107355d2d4557e7e19ea1724bdb710268cd34
65 changes: 64 additions & 1 deletion trunk/drivers/scsi/vmw_pvscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Maintained by: Alok N Kataria <akataria@vmware.com>
* Maintained by: Arvind Kumar <arvindkumar@vmware.com>
*
*/

Expand Down Expand Up @@ -1178,11 +1178,67 @@ static int __devinit pvscsi_allocate_sg(struct pvscsi_adapter *adapter)
return 0;
}

/*
* Query the device, fetch the config info and return the
* maximum number of targets on the adapter. In case of
* failure due to any reason return default i.e. 16.
*/
static u32 pvscsi_get_max_targets(struct pvscsi_adapter *adapter)
{
struct PVSCSICmdDescConfigCmd cmd;
struct PVSCSIConfigPageHeader *header;
struct device *dev;
dma_addr_t configPagePA;
void *config_page;
u32 numPhys = 16;

dev = pvscsi_dev(adapter);
config_page = pci_alloc_consistent(adapter->dev, PAGE_SIZE,
&configPagePA);
if (!config_page) {
dev_warn(dev, "vmw_pvscsi: failed to allocate memory for config page\n");
goto exit;
}
BUG_ON(configPagePA & ~PAGE_MASK);

/* Fetch config info from the device. */
cmd.configPageAddress = ((u64)PVSCSI_CONFIG_CONTROLLER_ADDRESS) << 32;
cmd.configPageNum = PVSCSI_CONFIG_PAGE_CONTROLLER;
cmd.cmpAddr = configPagePA;
cmd._pad = 0;

/*
* Mark the completion page header with error values. If the device
* completes the command successfully, it sets the status values to
* indicate success.
*/
header = config_page;
memset(header, 0, sizeof *header);
header->hostStatus = BTSTAT_INVPARAM;
header->scsiStatus = SDSTAT_CHECK;

pvscsi_write_cmd_desc(adapter, PVSCSI_CMD_CONFIG, &cmd, sizeof cmd);

if (header->hostStatus == BTSTAT_SUCCESS &&
header->scsiStatus == SDSTAT_GOOD) {
struct PVSCSIConfigPageController *config;

config = config_page;
numPhys = config->numPhys;
} else
dev_warn(dev, "vmw_pvscsi: PVSCSI_CMD_CONFIG failed. hostStatus = 0x%x, scsiStatus = 0x%x\n",
header->hostStatus, header->scsiStatus);
pci_free_consistent(adapter->dev, PAGE_SIZE, config_page, configPagePA);
exit:
return numPhys;
}

static int __devinit pvscsi_probe(struct pci_dev *pdev,
const struct pci_device_id *id)
{
struct pvscsi_adapter *adapter;
struct Scsi_Host *host;
struct device *dev;
unsigned int i;
unsigned long flags = 0;
int error;
Expand Down Expand Up @@ -1271,6 +1327,13 @@ static int __devinit pvscsi_probe(struct pci_dev *pdev,
goto out_release_resources;
}

/*
* Ask the device for max number of targets.
*/
host->max_id = pvscsi_get_max_targets(adapter);
dev = pvscsi_dev(adapter);
dev_info(dev, "vmw_pvscsi: host->max_id: %u\n", host->max_id);

/*
* From this point on we should reset the adapter if anything goes
* wrong.
Expand Down
109 changes: 85 additions & 24 deletions trunk/drivers/scsi/vmw_pvscsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Maintained by: Alok N Kataria <akataria@vmware.com>
* Maintained by: Arvind Kumar <arvindkumar@vmware.com>
*
*/

Expand All @@ -26,7 +26,7 @@

#include <linux/types.h>

#define PVSCSI_DRIVER_VERSION_STRING "1.0.1.0-k"
#define PVSCSI_DRIVER_VERSION_STRING "1.0.2.0-k"

#define PVSCSI_MAX_NUM_SG_ENTRIES_PER_SEGMENT 128

Expand All @@ -39,28 +39,45 @@
* host adapter status/error codes
*/
enum HostBusAdapterStatus {
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 */
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_INVPARAM = 0x1a, /* invalid parameter in CCB or segment
* list */
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 */
};

/*
* SCSI device status values.
*/
enum ScsiDeviceStatus {
SDSTAT_GOOD = 0x00, /* No errors. */
SDSTAT_CHECK = 0x02, /* Check condition. */
};

/*
Expand Down Expand Up @@ -113,6 +130,29 @@ struct PVSCSICmdDescResetDevice {
u8 lun[8];
} __packed;

/*
* Command descriptor for PVSCSI_CMD_CONFIG --
*/

struct PVSCSICmdDescConfigCmd {
u64 cmpAddr;
u64 configPageAddress;
u32 configPageNum;
u32 _pad;
} __packed;

enum PVSCSIConfigPageType {
PVSCSI_CONFIG_PAGE_CONTROLLER = 0x1958,
PVSCSI_CONFIG_PAGE_PHY = 0x1959,
PVSCSI_CONFIG_PAGE_DEVICE = 0x195a,
};

enum PVSCSIConfigPageAddressType {
PVSCSI_CONFIG_CONTROLLER_ADDRESS = 0x2120,
PVSCSI_CONFIG_BUSTARGET_ADDRESS = 0x2121,
PVSCSI_CONFIG_PHY_ADDRESS = 0x2122,
};

/*
* Command descriptor for PVSCSI_CMD_ABORT_CMD --
*
Expand Down Expand Up @@ -332,6 +372,27 @@ struct PVSCSIRingCmpDesc {
u32 _pad[2];
} __packed;

struct PVSCSIConfigPageHeader {
u32 pageNum;
u16 numDwords;
u16 hostStatus;
u16 scsiStatus;
u16 reserved[3];
} __packed;

struct PVSCSIConfigPageController {
struct PVSCSIConfigPageHeader header;
u64 nodeWWN; /* Device name as defined in the SAS spec. */
u16 manufacturer[64];
u16 serialNumber[64];
u16 opromVersion[32];
u16 hwVersion[32];
u16 firmwareVersion[32];
u32 numPhys;
u8 useConsecutivePhyWWNs;
u8 reserved[3];
} __packed;

/*
* Interrupt status / IRQ bits.
*/
Expand Down

0 comments on commit 3e8db68

Please sign in to comment.