hpsa.c (50a0decf75b66480aa5b076d4e1bca11bc202efe) hpsa.c (a505b86fde5903944828fa04f775e79a6636791d)
1/*
2 * Disk Array driver for HP Smart Array SAS controllers
3 * Copyright 2000, 2014 Hewlett-Packard Development Company, L.P.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *

--- 4005 unchanged lines hidden (view full) ---

4014
4015 /* Fill in the request block... */
4016
4017 c->Request.Timeout = 0;
4018 memset(c->Request.CDB, 0, sizeof(c->Request.CDB));
4019 BUG_ON(cmd->cmd_len > sizeof(c->Request.CDB));
4020 c->Request.CDBLen = cmd->cmd_len;
4021 memcpy(c->Request.CDB, cmd->cmnd, cmd->cmd_len);
1/*
2 * Disk Array driver for HP Smart Array SAS controllers
3 * Copyright 2000, 2014 Hewlett-Packard Development Company, L.P.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *

--- 4005 unchanged lines hidden (view full) ---

4014
4015 /* Fill in the request block... */
4016
4017 c->Request.Timeout = 0;
4018 memset(c->Request.CDB, 0, sizeof(c->Request.CDB));
4019 BUG_ON(cmd->cmd_len > sizeof(c->Request.CDB));
4020 c->Request.CDBLen = cmd->cmd_len;
4021 memcpy(c->Request.CDB, cmd->cmnd, cmd->cmd_len);
4022 c->Request.Type.Type = TYPE_CMD;
4023 c->Request.Type.Attribute = ATTR_SIMPLE;
4024 switch (cmd->sc_data_direction) {
4025 case DMA_TO_DEVICE:
4022 switch (cmd->sc_data_direction) {
4023 case DMA_TO_DEVICE:
4026 c->Request.Type.Direction = XFER_WRITE;
4024 c->Request.type_attr_dir =
4025 TYPE_ATTR_DIR(TYPE_CMD, ATTR_SIMPLE, XFER_WRITE);
4027 break;
4028 case DMA_FROM_DEVICE:
4026 break;
4027 case DMA_FROM_DEVICE:
4029 c->Request.Type.Direction = XFER_READ;
4028 c->Request.type_attr_dir =
4029 TYPE_ATTR_DIR(TYPE_CMD, ATTR_SIMPLE, XFER_READ);
4030 break;
4031 case DMA_NONE:
4030 break;
4031 case DMA_NONE:
4032 c->Request.Type.Direction = XFER_NONE;
4032 c->Request.type_attr_dir =
4033 TYPE_ATTR_DIR(TYPE_CMD, ATTR_SIMPLE, XFER_NONE);
4033 break;
4034 case DMA_BIDIRECTIONAL:
4035 /* This can happen if a buggy application does a scsi passthru
4036 * and sets both inlen and outlen to non-zero. ( see
4037 * ../scsi/scsi_ioctl.c:scsi_ioctl_send_command() )
4038 */
4039
4034 break;
4035 case DMA_BIDIRECTIONAL:
4036 /* This can happen if a buggy application does a scsi passthru
4037 * and sets both inlen and outlen to non-zero. ( see
4038 * ../scsi/scsi_ioctl.c:scsi_ioctl_send_command() )
4039 */
4040
4040 c->Request.Type.Direction = XFER_RSVD;
4041 c->Request.type_attr_dir =
4042 TYPE_ATTR_DIR(TYPE_CMD, ATTR_SIMPLE, XFER_RSVD);
4041 /* This is technically wrong, and hpsa controllers should
4042 * reject it with CMD_INVALID, which is the most correct
4043 * response, but non-fibre backends appear to let it
4044 * slide by, and give the same results as if this field
4045 * were set correctly. Either way is acceptable for
4046 * our purposes here.
4047 */
4048

--- 1203 unchanged lines hidden (view full) ---

5252 c->Header.SGTotal = cpu_to_le16(1);
5253 } else {
5254 c->Header.SGList = 0;
5255 c->Header.SGTotal = cpu_to_le16(0);
5256 }
5257 c->Header.tag = c->busaddr;
5258 memcpy(c->Header.LUN.LunAddrBytes, scsi3addr, 8);
5259
4043 /* This is technically wrong, and hpsa controllers should
4044 * reject it with CMD_INVALID, which is the most correct
4045 * response, but non-fibre backends appear to let it
4046 * slide by, and give the same results as if this field
4047 * were set correctly. Either way is acceptable for
4048 * our purposes here.
4049 */
4050

--- 1203 unchanged lines hidden (view full) ---

5254 c->Header.SGTotal = cpu_to_le16(1);
5255 } else {
5256 c->Header.SGList = 0;
5257 c->Header.SGTotal = cpu_to_le16(0);
5258 }
5259 c->Header.tag = c->busaddr;
5260 memcpy(c->Header.LUN.LunAddrBytes, scsi3addr, 8);
5261
5260 c->Request.Type.Type = cmd_type;
5261 if (cmd_type == TYPE_CMD) {
5262 switch (cmd) {
5263 case HPSA_INQUIRY:
5264 /* are we trying to read a vital product page */
5265 if (page_code & VPD_PAGE) {
5266 c->Request.CDB[1] = 0x01;
5267 c->Request.CDB[2] = (page_code & 0xff);
5268 }
5269 c->Request.CDBLen = 6;
5262 if (cmd_type == TYPE_CMD) {
5263 switch (cmd) {
5264 case HPSA_INQUIRY:
5265 /* are we trying to read a vital product page */
5266 if (page_code & VPD_PAGE) {
5267 c->Request.CDB[1] = 0x01;
5268 c->Request.CDB[2] = (page_code & 0xff);
5269 }
5270 c->Request.CDBLen = 6;
5270 c->Request.Type.Attribute = ATTR_SIMPLE;
5271 c->Request.Type.Direction = XFER_READ;
5271 c->Request.type_attr_dir =
5272 TYPE_ATTR_DIR(cmd_type, ATTR_SIMPLE, XFER_READ);
5272 c->Request.Timeout = 0;
5273 c->Request.CDB[0] = HPSA_INQUIRY;
5274 c->Request.CDB[4] = size & 0xFF;
5275 break;
5276 case HPSA_REPORT_LOG:
5277 case HPSA_REPORT_PHYS:
5278 /* Talking to controller so It's a physical command
5279 mode = 00 target = 0. Nothing to write.
5280 */
5281 c->Request.CDBLen = 12;
5273 c->Request.Timeout = 0;
5274 c->Request.CDB[0] = HPSA_INQUIRY;
5275 c->Request.CDB[4] = size & 0xFF;
5276 break;
5277 case HPSA_REPORT_LOG:
5278 case HPSA_REPORT_PHYS:
5279 /* Talking to controller so It's a physical command
5280 mode = 00 target = 0. Nothing to write.
5281 */
5282 c->Request.CDBLen = 12;
5282 c->Request.Type.Attribute = ATTR_SIMPLE;
5283 c->Request.Type.Direction = XFER_READ;
5283 c->Request.type_attr_dir =
5284 TYPE_ATTR_DIR(cmd_type, ATTR_SIMPLE, XFER_READ);
5284 c->Request.Timeout = 0;
5285 c->Request.CDB[0] = cmd;
5286 c->Request.CDB[6] = (size >> 24) & 0xFF; /* MSB */
5287 c->Request.CDB[7] = (size >> 16) & 0xFF;
5288 c->Request.CDB[8] = (size >> 8) & 0xFF;
5289 c->Request.CDB[9] = size & 0xFF;
5290 break;
5291 case HPSA_CACHE_FLUSH:
5292 c->Request.CDBLen = 12;
5285 c->Request.Timeout = 0;
5286 c->Request.CDB[0] = cmd;
5287 c->Request.CDB[6] = (size >> 24) & 0xFF; /* MSB */
5288 c->Request.CDB[7] = (size >> 16) & 0xFF;
5289 c->Request.CDB[8] = (size >> 8) & 0xFF;
5290 c->Request.CDB[9] = size & 0xFF;
5291 break;
5292 case HPSA_CACHE_FLUSH:
5293 c->Request.CDBLen = 12;
5293 c->Request.Type.Attribute = ATTR_SIMPLE;
5294 c->Request.Type.Direction = XFER_WRITE;
5294 c->Request.type_attr_dir =
5295 TYPE_ATTR_DIR(cmd_type,
5296 ATTR_SIMPLE, XFER_WRITE);
5295 c->Request.Timeout = 0;
5296 c->Request.CDB[0] = BMIC_WRITE;
5297 c->Request.CDB[6] = BMIC_CACHE_FLUSH;
5298 c->Request.CDB[7] = (size >> 8) & 0xFF;
5299 c->Request.CDB[8] = size & 0xFF;
5300 break;
5301 case TEST_UNIT_READY:
5302 c->Request.CDBLen = 6;
5297 c->Request.Timeout = 0;
5298 c->Request.CDB[0] = BMIC_WRITE;
5299 c->Request.CDB[6] = BMIC_CACHE_FLUSH;
5300 c->Request.CDB[7] = (size >> 8) & 0xFF;
5301 c->Request.CDB[8] = size & 0xFF;
5302 break;
5303 case TEST_UNIT_READY:
5304 c->Request.CDBLen = 6;
5303 c->Request.Type.Attribute = ATTR_SIMPLE;
5304 c->Request.Type.Direction = XFER_NONE;
5305 c->Request.type_attr_dir =
5306 TYPE_ATTR_DIR(cmd_type, ATTR_SIMPLE, XFER_NONE);
5305 c->Request.Timeout = 0;
5306 break;
5307 case HPSA_GET_RAID_MAP:
5308 c->Request.CDBLen = 12;
5307 c->Request.Timeout = 0;
5308 break;
5309 case HPSA_GET_RAID_MAP:
5310 c->Request.CDBLen = 12;
5309 c->Request.Type.Attribute = ATTR_SIMPLE;
5310 c->Request.Type.Direction = XFER_READ;
5311 c->Request.type_attr_dir =
5312 TYPE_ATTR_DIR(cmd_type, ATTR_SIMPLE, XFER_READ);
5311 c->Request.Timeout = 0;
5312 c->Request.CDB[0] = HPSA_CISS_READ;
5313 c->Request.CDB[1] = cmd;
5314 c->Request.CDB[6] = (size >> 24) & 0xFF; /* MSB */
5315 c->Request.CDB[7] = (size >> 16) & 0xFF;
5316 c->Request.CDB[8] = (size >> 8) & 0xFF;
5317 c->Request.CDB[9] = size & 0xFF;
5318 break;
5319 case BMIC_SENSE_CONTROLLER_PARAMETERS:
5320 c->Request.CDBLen = 10;
5313 c->Request.Timeout = 0;
5314 c->Request.CDB[0] = HPSA_CISS_READ;
5315 c->Request.CDB[1] = cmd;
5316 c->Request.CDB[6] = (size >> 24) & 0xFF; /* MSB */
5317 c->Request.CDB[7] = (size >> 16) & 0xFF;
5318 c->Request.CDB[8] = (size >> 8) & 0xFF;
5319 c->Request.CDB[9] = size & 0xFF;
5320 break;
5321 case BMIC_SENSE_CONTROLLER_PARAMETERS:
5322 c->Request.CDBLen = 10;
5321 c->Request.Type.Attribute = ATTR_SIMPLE;
5322 c->Request.Type.Direction = XFER_READ;
5323 c->Request.type_attr_dir =
5324 TYPE_ATTR_DIR(cmd_type, ATTR_SIMPLE, XFER_READ);
5323 c->Request.Timeout = 0;
5324 c->Request.CDB[0] = BMIC_READ;
5325 c->Request.CDB[6] = BMIC_SENSE_CONTROLLER_PARAMETERS;
5326 c->Request.CDB[7] = (size >> 16) & 0xFF;
5327 c->Request.CDB[8] = (size >> 8) & 0xFF;
5328 break;
5329 default:
5330 dev_warn(&h->pdev->dev, "unknown command 0x%c\n", cmd);
5331 BUG();
5332 return -1;
5333 }
5334 } else if (cmd_type == TYPE_MSG) {
5335 switch (cmd) {
5336
5337 case HPSA_DEVICE_RESET_MSG:
5338 c->Request.CDBLen = 16;
5325 c->Request.Timeout = 0;
5326 c->Request.CDB[0] = BMIC_READ;
5327 c->Request.CDB[6] = BMIC_SENSE_CONTROLLER_PARAMETERS;
5328 c->Request.CDB[7] = (size >> 16) & 0xFF;
5329 c->Request.CDB[8] = (size >> 8) & 0xFF;
5330 break;
5331 default:
5332 dev_warn(&h->pdev->dev, "unknown command 0x%c\n", cmd);
5333 BUG();
5334 return -1;
5335 }
5336 } else if (cmd_type == TYPE_MSG) {
5337 switch (cmd) {
5338
5339 case HPSA_DEVICE_RESET_MSG:
5340 c->Request.CDBLen = 16;
5339 c->Request.Type.Type = 1; /* It is a MSG not a CMD */
5340 c->Request.Type.Attribute = ATTR_SIMPLE;
5341 c->Request.Type.Direction = XFER_NONE;
5341 c->Request.type_attr_dir =
5342 TYPE_ATTR_DIR(cmd_type, ATTR_SIMPLE, XFER_NONE);
5342 c->Request.Timeout = 0; /* Don't time out */
5343 memset(&c->Request.CDB[0], 0, sizeof(c->Request.CDB));
5344 c->Request.CDB[0] = cmd;
5345 c->Request.CDB[1] = HPSA_RESET_TYPE_LUN;
5346 /* If bytes 4-7 are zero, it means reset the */
5347 /* LunID device */
5348 c->Request.CDB[4] = 0x00;
5349 c->Request.CDB[5] = 0x00;
5350 c->Request.CDB[6] = 0x00;
5351 c->Request.CDB[7] = 0x00;
5352 break;
5353 case HPSA_ABORT_MSG:
5354 a = buff; /* point to command to be aborted */
5355 dev_dbg(&h->pdev->dev, "Abort Tag:0x%016llx using request Tag:0x%016llx",
5356 a->Header.tag, c->Header.tag);
5357 tlower = (u32) (a->Header.tag >> 32);
5358 tupper = (u32) (a->Header.tag & 0x0ffffffffULL);
5359 c->Request.CDBLen = 16;
5343 c->Request.Timeout = 0; /* Don't time out */
5344 memset(&c->Request.CDB[0], 0, sizeof(c->Request.CDB));
5345 c->Request.CDB[0] = cmd;
5346 c->Request.CDB[1] = HPSA_RESET_TYPE_LUN;
5347 /* If bytes 4-7 are zero, it means reset the */
5348 /* LunID device */
5349 c->Request.CDB[4] = 0x00;
5350 c->Request.CDB[5] = 0x00;
5351 c->Request.CDB[6] = 0x00;
5352 c->Request.CDB[7] = 0x00;
5353 break;
5354 case HPSA_ABORT_MSG:
5355 a = buff; /* point to command to be aborted */
5356 dev_dbg(&h->pdev->dev, "Abort Tag:0x%016llx using request Tag:0x%016llx",
5357 a->Header.tag, c->Header.tag);
5358 tlower = (u32) (a->Header.tag >> 32);
5359 tupper = (u32) (a->Header.tag & 0x0ffffffffULL);
5360 c->Request.CDBLen = 16;
5360 c->Request.Type.Type = TYPE_MSG;
5361 c->Request.Type.Attribute = ATTR_SIMPLE;
5362 c->Request.Type.Direction = XFER_WRITE;
5361 c->Request.type_attr_dir =
5362 TYPE_ATTR_DIR(cmd_type,
5363 ATTR_SIMPLE, XFER_WRITE);
5363 c->Request.Timeout = 0; /* Don't time out */
5364 c->Request.CDB[0] = HPSA_TASK_MANAGEMENT;
5365 c->Request.CDB[1] = HPSA_TMF_ABORT_TASK;
5366 c->Request.CDB[2] = 0x00; /* reserved */
5367 c->Request.CDB[3] = 0x00; /* reserved */
5368 /* Tag to abort goes in CDB[4]-CDB[11] */
5369 c->Request.CDB[4] = tlower & 0xFF;
5370 c->Request.CDB[5] = (tlower >> 8) & 0xFF;

--- 13 unchanged lines hidden (view full) ---

5384 cmd);
5385 BUG();
5386 }
5387 } else {
5388 dev_warn(&h->pdev->dev, "unknown command type %d\n", cmd_type);
5389 BUG();
5390 }
5391
5364 c->Request.Timeout = 0; /* Don't time out */
5365 c->Request.CDB[0] = HPSA_TASK_MANAGEMENT;
5366 c->Request.CDB[1] = HPSA_TMF_ABORT_TASK;
5367 c->Request.CDB[2] = 0x00; /* reserved */
5368 c->Request.CDB[3] = 0x00; /* reserved */
5369 /* Tag to abort goes in CDB[4]-CDB[11] */
5370 c->Request.CDB[4] = tlower & 0xFF;
5371 c->Request.CDB[5] = (tlower >> 8) & 0xFF;

--- 13 unchanged lines hidden (view full) ---

5385 cmd);
5386 BUG();
5387 }
5388 } else {
5389 dev_warn(&h->pdev->dev, "unknown command type %d\n", cmd_type);
5390 BUG();
5391 }
5392
5392 switch (c->Request.Type.Direction) {
5393 switch (GET_DIR(c->Request.type_attr_dir)) {
5393 case XFER_READ:
5394 pci_dir = PCI_DMA_FROMDEVICE;
5395 break;
5396 case XFER_WRITE:
5397 pci_dir = PCI_DMA_TODEVICE;
5398 break;
5399 case XFER_NONE:
5400 pci_dir = PCI_DMA_NONE;

--- 341 unchanged lines hidden (view full) ---

5742
5743 cmd->CommandHeader.ReplyQueue = 0;
5744 cmd->CommandHeader.SGList = 0;
5745 cmd->CommandHeader.SGTotal = cpu_to_le16(0);
5746 cmd->CommandHeader.tag = paddr32;
5747 memset(&cmd->CommandHeader.LUN.LunAddrBytes, 0, 8);
5748
5749 cmd->Request.CDBLen = 16;
5394 case XFER_READ:
5395 pci_dir = PCI_DMA_FROMDEVICE;
5396 break;
5397 case XFER_WRITE:
5398 pci_dir = PCI_DMA_TODEVICE;
5399 break;
5400 case XFER_NONE:
5401 pci_dir = PCI_DMA_NONE;

--- 341 unchanged lines hidden (view full) ---

5743
5744 cmd->CommandHeader.ReplyQueue = 0;
5745 cmd->CommandHeader.SGList = 0;
5746 cmd->CommandHeader.SGTotal = cpu_to_le16(0);
5747 cmd->CommandHeader.tag = paddr32;
5748 memset(&cmd->CommandHeader.LUN.LunAddrBytes, 0, 8);
5749
5750 cmd->Request.CDBLen = 16;
5750 cmd->Request.Type.Type = TYPE_MSG;
5751 cmd->Request.Type.Attribute = ATTR_HEADOFQUEUE;
5752 cmd->Request.Type.Direction = XFER_NONE;
5751 cmd->Request.type_attr_dir =
5752 TYPE_ATTR_DIR(TYPE_MSG, ATTR_HEADOFQUEUE, XFER_NONE);
5753 cmd->Request.Timeout = 0; /* Don't time out */
5754 cmd->Request.CDB[0] = opcode;
5755 cmd->Request.CDB[1] = type;
5756 memset(&cmd->Request.CDB[2], 0, 14); /* rest of the CDB is reserved */
5757 cmd->ErrorDescriptor.Addr =
5758 cpu_to_le64((paddr32 + sizeof(*cmd)));
5759 cmd->ErrorDescriptor.Len = cpu_to_le32(sizeof(struct ErrorInfo));
5760

--- 1937 unchanged lines hidden ---
5753 cmd->Request.Timeout = 0; /* Don't time out */
5754 cmd->Request.CDB[0] = opcode;
5755 cmd->Request.CDB[1] = type;
5756 memset(&cmd->Request.CDB[2], 0, 14); /* rest of the CDB is reserved */
5757 cmd->ErrorDescriptor.Addr =
5758 cpu_to_le64((paddr32 + sizeof(*cmd)));
5759 cmd->ErrorDescriptor.Len = cpu_to_le32(sizeof(struct ErrorInfo));
5760

--- 1937 unchanged lines hidden ---