aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/fusion/mptscsih.c
diff options
context:
space:
mode:
authorEric Moore <eric.moore@lsi.com>2007-01-29 11:42:20 -0500
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2007-02-02 21:48:49 -0500
commit793955f549c710a1b0c18f823d5d710840747b15 (patch)
treeef85a09c1d90404a83f95b35d6fd717c421a4e5b /drivers/message/fusion/mptscsih.c
parent502c62f17aa7daa78d5da963305251b872885ff9 (diff)
[SCSI] fusion - Greater than 255 target and lun support
Add support for greater than 255 target and luns. Kill the hd->Target[] field, and change all references of bus_id/target_id, to channel/id. Signed-off-by: Eric Moore <Eric.Moore@lsi.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/message/fusion/mptscsih.c')
-rw-r--r--drivers/message/fusion/mptscsih.c301
1 files changed, 82 insertions, 219 deletions
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index f0cca3ea93b2..ce58431bee8e 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -79,43 +79,6 @@ MODULE_LICENSE("GPL");
79MODULE_VERSION(my_VERSION); 79MODULE_VERSION(my_VERSION);
80 80
81/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 81/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
82
83typedef struct _BIG_SENSE_BUF {
84 u8 data[MPT_SENSE_BUFFER_ALLOC];
85} BIG_SENSE_BUF;
86
87#define MPT_SCANDV_GOOD (0x00000000) /* must be 0 */
88#define MPT_SCANDV_DID_RESET (0x00000001)
89#define MPT_SCANDV_SENSE (0x00000002)
90#define MPT_SCANDV_SOME_ERROR (0x00000004)
91#define MPT_SCANDV_SELECTION_TIMEOUT (0x00000008)
92#define MPT_SCANDV_ISSUE_SENSE (0x00000010)
93#define MPT_SCANDV_FALLBACK (0x00000020)
94
95#define MPT_SCANDV_MAX_RETRIES (10)
96
97#define MPT_ICFLAG_BUF_CAP 0x01 /* ReadBuffer Read Capacity format */
98#define MPT_ICFLAG_ECHO 0x02 /* ReadBuffer Echo buffer format */
99#define MPT_ICFLAG_EBOS 0x04 /* ReadBuffer Echo buffer has EBOS */
100#define MPT_ICFLAG_PHYS_DISK 0x08 /* Any SCSI IO but do Phys Disk Format */
101#define MPT_ICFLAG_TAGGED_CMD 0x10 /* Do tagged IO */
102#define MPT_ICFLAG_DID_RESET 0x20 /* Bus Reset occurred with this command */
103#define MPT_ICFLAG_RESERVED 0x40 /* Reserved has been issued */
104
105typedef struct _internal_cmd {
106 char *data; /* data pointer */
107 dma_addr_t data_dma; /* data dma address */
108 int size; /* transfer size */
109 u8 cmd; /* SCSI Op Code */
110 u8 bus; /* bus number */
111 u8 id; /* SCSI ID (virtual) */
112 u8 lun;
113 u8 flags; /* Bit Field - See above */
114 u8 physDiskNum; /* Phys disk number, -1 else */
115 u8 rsvd2;
116 u8 rsvd;
117} INTERNAL_CMD;
118
119/* 82/*
120 * Other private/forward protos... 83 * Other private/forward protos...
121 */ 84 */
@@ -131,14 +94,14 @@ static int mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd);
131static int mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout ); 94static int mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout );
132static int SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc); 95static int SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc);
133 96
134static int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout); 97static int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int ctx2abort, ulong timeout);
135 98
136int mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset); 99int mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset);
137int mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply); 100int mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply);
138 101
139static void mptscsih_initTarget(MPT_SCSI_HOST *hd, VirtTarget *vtarget, struct scsi_device *sdev); 102static void mptscsih_initTarget(MPT_SCSI_HOST *hd, VirtTarget *vtarget, struct scsi_device *sdev);
140static void mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *vtarget, struct scsi_device *sdev); 103static void mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *vtarget, struct scsi_device *sdev);
141static int mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus); 104static int mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int channel, int id);
142int mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); 105int mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
143static int mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *iocmd); 106static int mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *iocmd);
144static void mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, VirtDevice *vdevice); 107static void mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, VirtDevice *vdevice);
@@ -517,13 +480,13 @@ mptscsih_issue_sep_command(MPT_ADAPTER *ioc, VirtTarget *vtarget,
517 480
518 SEPMsg = (SEPRequest_t *)mf; 481 SEPMsg = (SEPRequest_t *)mf;
519 SEPMsg->Function = MPI_FUNCTION_SCSI_ENCLOSURE_PROCESSOR; 482 SEPMsg->Function = MPI_FUNCTION_SCSI_ENCLOSURE_PROCESSOR;
520 SEPMsg->Bus = vtarget->bus_id; 483 SEPMsg->Bus = vtarget->channel;
521 SEPMsg->TargetID = vtarget->target_id; 484 SEPMsg->TargetID = vtarget->id;
522 SEPMsg->Action = MPI_SEP_REQ_ACTION_WRITE_STATUS; 485 SEPMsg->Action = MPI_SEP_REQ_ACTION_WRITE_STATUS;
523 SEPMsg->SlotStatus = SlotStatus; 486 SEPMsg->SlotStatus = SlotStatus;
524 devtverboseprintk((MYIOC_s_WARN_FMT 487 devtverboseprintk((MYIOC_s_WARN_FMT
525 "Sending SEP cmd=%x id=%d bus=%d\n", 488 "Sending SEP cmd=%x channel=%d id=%d\n",
526 ioc->name, SlotStatus, SEPMsg->TargetID, SEPMsg->Bus)); 489 ioc->name, SlotStatus, SEPMsg->Bus, SEPMsg->TargetID));
527 mpt_put_msg_frame(ioc->DoneCtx, ioc, mf); 490 mpt_put_msg_frame(ioc->DoneCtx, ioc, mf);
528} 491}
529 492
@@ -955,9 +918,10 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
955 int ii; 918 int ii;
956 int max = hd->ioc->req_depth; 919 int max = hd->ioc->req_depth;
957 struct scsi_cmnd *sc; 920 struct scsi_cmnd *sc;
921 struct scsi_lun lun;
958 922
959 dsprintk((KERN_INFO MYNAM ": search_running target %d lun %d max %d\n", 923 dsprintk((KERN_INFO MYNAM ": search_running channel %d id %d lun %d max %d\n",
960 vdevice->vtarget->target_id, vdevice->lun, max)); 924 vdevice->vtarget->channel, vdevice->vtarget->id, vdevice->lun, max));
961 925
962 for (ii=0; ii < max; ii++) { 926 for (ii=0; ii < max; ii++) {
963 if ((sc = hd->ScsiLookup[ii]) != NULL) { 927 if ((sc = hd->ScsiLookup[ii]) != NULL) {
@@ -965,10 +929,14 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
965 mf = (SCSIIORequest_t *)MPT_INDEX_2_MFPTR(hd->ioc, ii); 929 mf = (SCSIIORequest_t *)MPT_INDEX_2_MFPTR(hd->ioc, ii);
966 if (mf == NULL) 930 if (mf == NULL)
967 continue; 931 continue;
968 dsprintk(( "search_running: found (sc=%p, mf = %p) target %d, lun %d \n", 932 int_to_scsilun(vdevice->lun, &lun);
969 hd->ScsiLookup[ii], mf, mf->TargetID, mf->LUN[1])); 933 if ((mf->Bus != vdevice->vtarget->channel) ||
970 if ((mf->TargetID != ((u8)vdevice->vtarget->target_id)) || (mf->LUN[1] != ((u8) vdevice->lun))) 934 (mf->TargetID != vdevice->vtarget->id) ||
935 memcmp(lun.scsi_lun, mf->LUN, 8))
971 continue; 936 continue;
937 dsprintk(( "search_running: found (sc=%p, mf = %p) "
938 "channel %d id %d, lun %d \n", hd->ScsiLookup[ii],
939 mf, mf->Bus, mf->TargetID, vdevice->lun));
972 940
973 /* Cleanup 941 /* Cleanup
974 */ 942 */
@@ -1065,12 +1033,6 @@ mptscsih_remove(struct pci_dev *pdev)
1065 hd->ScsiLookup = NULL; 1033 hd->ScsiLookup = NULL;
1066 } 1034 }
1067 1035
1068 /*
1069 * Free pointer array.
1070 */
1071 kfree(hd->Targets);
1072 hd->Targets = NULL;
1073
1074 dprintk((MYIOC_s_INFO_FMT 1036 dprintk((MYIOC_s_INFO_FMT
1075 "Free'd ScsiLookup (%d) memory\n", 1037 "Free'd ScsiLookup (%d) memory\n",
1076 hd->ioc->name, sz1)); 1038 hd->ioc->name, sz1));
@@ -1317,14 +1279,6 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1317 return SCSI_MLQUEUE_HOST_BUSY; 1279 return SCSI_MLQUEUE_HOST_BUSY;
1318 } 1280 }
1319 1281
1320 if ((hd->ioc->bus_type == SPI) &&
1321 vdev->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT &&
1322 mptscsih_raid_id_to_num(hd, SCpnt->device->id) < 0) {
1323 SCpnt->result = DID_NO_CONNECT << 16;
1324 done(SCpnt);
1325 return 0;
1326 }
1327
1328 /* 1282 /*
1329 * Put together a MPT SCSI request... 1283 * Put together a MPT SCSI request...
1330 */ 1284 */
@@ -1368,8 +1322,8 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1368 1322
1369 /* Use the above information to set up the message frame 1323 /* Use the above information to set up the message frame
1370 */ 1324 */
1371 pScsiReq->TargetID = (u8) vdev->vtarget->target_id; 1325 pScsiReq->TargetID = (u8) vdev->vtarget->id;
1372 pScsiReq->Bus = vdev->vtarget->bus_id; 1326 pScsiReq->Bus = vdev->vtarget->channel;
1373 pScsiReq->ChainOffset = 0; 1327 pScsiReq->ChainOffset = 0;
1374 if (vdev->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) 1328 if (vdev->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT)
1375 pScsiReq->Function = MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH; 1329 pScsiReq->Function = MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH;
@@ -1379,14 +1333,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1379 pScsiReq->SenseBufferLength = MPT_SENSE_BUFFER_SIZE; 1333 pScsiReq->SenseBufferLength = MPT_SENSE_BUFFER_SIZE;
1380 pScsiReq->Reserved = 0; 1334 pScsiReq->Reserved = 0;
1381 pScsiReq->MsgFlags = mpt_msg_flags(); 1335 pScsiReq->MsgFlags = mpt_msg_flags();
1382 pScsiReq->LUN[0] = 0; 1336 int_to_scsilun(SCpnt->device->lun, (struct scsi_lun *)pScsiReq->LUN);
1383 pScsiReq->LUN[1] = lun;
1384 pScsiReq->LUN[2] = 0;
1385 pScsiReq->LUN[3] = 0;
1386 pScsiReq->LUN[4] = 0;
1387 pScsiReq->LUN[5] = 0;
1388 pScsiReq->LUN[6] = 0;
1389 pScsiReq->LUN[7] = 0;
1390 pScsiReq->Control = cpu_to_le32(scsictl); 1337 pScsiReq->Control = cpu_to_le32(scsictl);
1391 1338
1392 /* 1339 /*
@@ -1498,7 +1445,7 @@ mptscsih_freeChainBuffers(MPT_ADAPTER *ioc, int req_idx)
1498 * 1445 *
1499 * @ioc: Pointer to MPT_ADAPTER structure 1446 * @ioc: Pointer to MPT_ADAPTER structure
1500 * @type: Task Management type 1447 * @type: Task Management type
1501 * @target: Logical Target ID for reset (if appropriate) 1448 * @id: Logical Target ID for reset (if appropriate)
1502 * @lun: Logical Unit for reset (if appropriate) 1449 * @lun: Logical Unit for reset (if appropriate)
1503 * @ctx2abort: Context for the task to be aborted (if appropriate) 1450 * @ctx2abort: Context for the task to be aborted (if appropriate)
1504 * 1451 *
@@ -1510,7 +1457,7 @@ mptscsih_freeChainBuffers(MPT_ADAPTER *ioc, int req_idx)
1510 * Returns 0 for SUCCESS or -1 if FAILED. 1457 * Returns 0 for SUCCESS or -1 if FAILED.
1511 */ 1458 */
1512int 1459int
1513mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout) 1460mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int ctx2abort, ulong timeout)
1514{ 1461{
1515 MPT_ADAPTER *ioc; 1462 MPT_ADAPTER *ioc;
1516 int rc = -1; 1463 int rc = -1;
@@ -1590,7 +1537,7 @@ mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, in
1590 */ 1537 */
1591 if (hd->hard_resets < -1) 1538 if (hd->hard_resets < -1)
1592 hd->hard_resets++; 1539 hd->hard_resets++;
1593 rc = mptscsih_IssueTaskMgmt(hd, type, channel, target, lun, ctx2abort, timeout); 1540 rc = mptscsih_IssueTaskMgmt(hd, type, channel, id, lun, ctx2abort, timeout);
1594 if (rc) { 1541 if (rc) {
1595 printk(MYIOC_s_INFO_FMT "Issue of TaskMgmt failed!\n", hd->ioc->name); 1542 printk(MYIOC_s_INFO_FMT "Issue of TaskMgmt failed!\n", hd->ioc->name);
1596 } else { 1543 } else {
@@ -1624,7 +1571,7 @@ mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, in
1624 * mptscsih_IssueTaskMgmt - Generic send Task Management function. 1571 * mptscsih_IssueTaskMgmt - Generic send Task Management function.
1625 * @hd: Pointer to MPT_SCSI_HOST structure 1572 * @hd: Pointer to MPT_SCSI_HOST structure
1626 * @type: Task Management type 1573 * @type: Task Management type
1627 * @target: Logical Target ID for reset (if appropriate) 1574 * @id: Logical Target ID for reset (if appropriate)
1628 * @lun: Logical Unit for reset (if appropriate) 1575 * @lun: Logical Unit for reset (if appropriate)
1629 * @ctx2abort: Context for the task to be aborted (if appropriate) 1576 * @ctx2abort: Context for the task to be aborted (if appropriate)
1630 * 1577 *
@@ -1637,7 +1584,7 @@ mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, in
1637 * else other non-zero value returned. 1584 * else other non-zero value returned.
1638 */ 1585 */
1639static int 1586static int
1640mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout) 1587mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int ctx2abort, ulong timeout)
1641{ 1588{
1642 MPT_FRAME_HDR *mf; 1589 MPT_FRAME_HDR *mf;
1643 SCSITaskMgmt_t *pScsiTm; 1590 SCSITaskMgmt_t *pScsiTm;
@@ -1657,7 +1604,7 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun
1657 /* Format the Request 1604 /* Format the Request
1658 */ 1605 */
1659 pScsiTm = (SCSITaskMgmt_t *) mf; 1606 pScsiTm = (SCSITaskMgmt_t *) mf;
1660 pScsiTm->TargetID = target; 1607 pScsiTm->TargetID = id;
1661 pScsiTm->Bus = channel; 1608 pScsiTm->Bus = channel;
1662 pScsiTm->ChainOffset = 0; 1609 pScsiTm->ChainOffset = 0;
1663 pScsiTm->Function = MPI_FUNCTION_SCSI_TASK_MGMT; 1610 pScsiTm->Function = MPI_FUNCTION_SCSI_TASK_MGMT;
@@ -1668,10 +1615,7 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun
1668 pScsiTm->MsgFlags = (type == MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS) 1615 pScsiTm->MsgFlags = (type == MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS)
1669 ? MPI_SCSITASKMGMT_MSGFLAGS_LIPRESET_RESET_OPTION : 0; 1616 ? MPI_SCSITASKMGMT_MSGFLAGS_LIPRESET_RESET_OPTION : 0;
1670 1617
1671 for (ii= 0; ii < 8; ii++) { 1618 int_to_scsilun(lun, (struct scsi_lun *)pScsiTm->LUN);
1672 pScsiTm->LUN[ii] = 0;
1673 }
1674 pScsiTm->LUN[1] = lun;
1675 1619
1676 for (ii=0; ii < 7; ii++) 1620 for (ii=0; ii < 7; ii++)
1677 pScsiTm->Reserved2[ii] = 0; 1621 pScsiTm->Reserved2[ii] = 0;
@@ -1789,7 +1733,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1789 1733
1790 vdev = SCpnt->device->hostdata; 1734 vdev = SCpnt->device->hostdata;
1791 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK, 1735 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK,
1792 vdev->vtarget->bus_id, vdev->vtarget->target_id, vdev->lun, 1736 vdev->vtarget->channel, vdev->vtarget->id, vdev->lun,
1793 ctx2abort, mptscsih_get_tm_timeout(hd->ioc)); 1737 ctx2abort, mptscsih_get_tm_timeout(hd->ioc));
1794 1738
1795 if (SCPNT_TO_LOOKUP_IDX(SCpnt) == scpnt_idx && 1739 if (SCPNT_TO_LOOKUP_IDX(SCpnt) == scpnt_idx &&
@@ -1845,7 +1789,7 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
1845 1789
1846 vdev = SCpnt->device->hostdata; 1790 vdev = SCpnt->device->hostdata;
1847 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 1791 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET,
1848 vdev->vtarget->bus_id, vdev->vtarget->target_id, 1792 vdev->vtarget->channel, vdev->vtarget->id,
1849 0, 0, mptscsih_get_tm_timeout(hd->ioc)); 1793 0, 0, mptscsih_get_tm_timeout(hd->ioc));
1850 1794
1851 printk (KERN_WARNING MYNAM ": %s: target reset: %s (sc=%p)\n", 1795 printk (KERN_WARNING MYNAM ": %s: target reset: %s (sc=%p)\n",
@@ -1896,7 +1840,7 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
1896 1840
1897 vdev = SCpnt->device->hostdata; 1841 vdev = SCpnt->device->hostdata;
1898 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS, 1842 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS,
1899 vdev->vtarget->bus_id, 0, 0, 0, mptscsih_get_tm_timeout(hd->ioc)); 1843 vdev->vtarget->channel, 0, 0, 0, mptscsih_get_tm_timeout(hd->ioc));
1900 1844
1901 printk (KERN_WARNING MYNAM ": %s: bus reset: %s (sc=%p)\n", 1845 printk (KERN_WARNING MYNAM ": %s: bus reset: %s (sc=%p)\n",
1902 hd->ioc->name, 1846 hd->ioc->name,
@@ -2191,7 +2135,7 @@ mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev,
2191 2135
2192 dprintk((KERN_NOTICE 2136 dprintk((KERN_NOTICE
2193 ": bios_param: Id=%i Lun=%i Channel=%i CHS=%i/%i/%i\n", 2137 ": bios_param: Id=%i Lun=%i Channel=%i CHS=%i/%i/%i\n",
2194 sdev->id, sdev->lun,sdev->channel,(int)cylinders,heads,sectors)); 2138 sdev->id, sdev->lun, sdev->channel, (int)cylinders, heads, sectors));
2195 2139
2196 return 0; 2140 return 0;
2197} 2141}
@@ -2200,115 +2144,46 @@ mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev,
2200 * 2144 *
2201 */ 2145 */
2202int 2146int
2203mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id) 2147mptscsih_is_phys_disk(MPT_ADAPTER *ioc, u8 channel, u8 id)
2204{ 2148{
2205 int i; 2149 int i;
2150 int rc = 0;
2206 2151
2207 if (!ioc->raid_data.isRaid || !ioc->raid_data.pIocPg3) 2152 if (!ioc->raid_data.pIocPg3)
2208 return 0; 2153 goto out;
2209 for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) { 2154 for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) {
2210 if (id == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskID) 2155 if ((id == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskID) &&
2211 return 1; 2156 (channel == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskBus)) {
2212 } 2157 rc = 1;
2213 return 0; 2158 goto out;
2214} 2159 }
2215EXPORT_SYMBOL(mptscsih_is_phys_disk);
2216
2217int
2218mptscsih_raid_id_to_num(MPT_SCSI_HOST *hd, uint physdiskid)
2219{
2220 int i;
2221
2222 if (!hd->ioc->raid_data.isRaid || !hd->ioc->raid_data.pIocPg3)
2223 return -ENXIO;
2224
2225 for (i = 0; i < hd->ioc->raid_data.pIocPg3->NumPhysDisks; i++) {
2226 if (physdiskid ==
2227 hd->ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskID)
2228 return hd->ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskNum;
2229 } 2160 }
2230 2161
2231 return -ENXIO; 2162 out:
2232} 2163 return rc;
2233EXPORT_SYMBOL(mptscsih_raid_id_to_num);
2234
2235/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2236/*
2237 * OS entry point to allow host driver to alloc memory
2238 * for each scsi target. Called once per device the bus scan.
2239 * Return non-zero if allocation fails.
2240 */
2241int
2242mptscsih_target_alloc(struct scsi_target *starget)
2243{
2244 VirtTarget *vtarget;
2245
2246 vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL);
2247 if (!vtarget)
2248 return -ENOMEM;
2249 starget->hostdata = vtarget;
2250 vtarget->starget = starget;
2251 return 0;
2252} 2164}
2165EXPORT_SYMBOL(mptscsih_is_phys_disk);
2253 2166
2254/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2167u8
2255/* 2168mptscsih_raid_id_to_num(MPT_ADAPTER *ioc, u8 channel, u8 id)
2256 * OS entry point to allow host driver to alloc memory
2257 * for each scsi device. Called once per device the bus scan.
2258 * Return non-zero if allocation fails.
2259 */
2260int
2261mptscsih_slave_alloc(struct scsi_device *sdev)
2262{ 2169{
2263 struct Scsi_Host *host = sdev->host; 2170 int i;
2264 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 2171 int rc = -ENXIO;
2265 VirtTarget *vtarget;
2266 VirtDevice *vdev;
2267 struct scsi_target *starget;
2268
2269 vdev = kzalloc(sizeof(VirtDevice), GFP_KERNEL);
2270 if (!vdev) {
2271 printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n",
2272 hd->ioc->name, sizeof(VirtDevice));
2273 return -ENOMEM;
2274 }
2275
2276 vdev->lun = sdev->lun;
2277 sdev->hostdata = vdev;
2278
2279 starget = scsi_target(sdev);
2280 vtarget = starget->hostdata;
2281 2172
2282 vdev->vtarget = vtarget; 2173 if (!ioc->raid_data.pIocPg3)
2283 2174 goto out;
2284 if (vtarget->num_luns == 0) { 2175 for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) {
2285 hd->Targets[sdev->id] = vtarget; 2176 if ((id == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskID) &&
2286 vtarget->ioc_id = hd->ioc->id; 2177 (channel == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskBus)) {
2287 vtarget->tflags = MPT_TARGET_FLAGS_Q_YES; 2178 rc = ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskNum;
2288 vtarget->target_id = sdev->id; 2179 goto out;
2289 vtarget->bus_id = sdev->channel;
2290 if (hd->ioc->bus_type == SPI && sdev->channel == 0 &&
2291 hd->ioc->raid_data.isRaid & (1 << sdev->id)) {
2292 vtarget->raidVolume = 1;
2293 ddvtprintk((KERN_INFO
2294 "RAID Volume @ id %d\n", sdev->id));
2295 } 2180 }
2296 } 2181 }
2297 vtarget->num_luns++;
2298 return 0;
2299}
2300 2182
2301/* 2183 out:
2302 * OS entry point to allow for host driver to free allocated memory 2184 return rc;
2303 * Called if no device present or device being unloaded
2304 */
2305void
2306mptscsih_target_destroy(struct scsi_target *starget)
2307{
2308 if (starget->hostdata)
2309 kfree(starget->hostdata);
2310 starget->hostdata = NULL;
2311} 2185}
2186EXPORT_SYMBOL(mptscsih_raid_id_to_num);
2312 2187
2313/* 2188/*
2314 * OS entry point to allow for host driver to free allocated memory 2189 * OS entry point to allow for host driver to free allocated memory
@@ -2328,11 +2203,7 @@ mptscsih_slave_destroy(struct scsi_device *sdev)
2328 vdevice = sdev->hostdata; 2203 vdevice = sdev->hostdata;
2329 2204
2330 mptscsih_search_running_cmds(hd, vdevice); 2205 mptscsih_search_running_cmds(hd, vdevice);
2331 vtarget->luns[0] &= ~(1 << vdevice->lun);
2332 vtarget->num_luns--; 2206 vtarget->num_luns--;
2333 if (vtarget->num_luns == 0) {
2334 hd->Targets[sdev->id] = NULL;
2335 }
2336 mptscsih_synchronize_cache(hd, vdevice); 2207 mptscsih_synchronize_cache(hd, vdevice);
2337 kfree(vdevice); 2208 kfree(vdevice);
2338 sdev->hostdata = NULL; 2209 sdev->hostdata = NULL;
@@ -2394,15 +2265,14 @@ mptscsih_slave_configure(struct scsi_device *sdev)
2394 VirtDevice *vdevice; 2265 VirtDevice *vdevice;
2395 struct scsi_target *starget; 2266 struct scsi_target *starget;
2396 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sh->hostdata; 2267 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sh->hostdata;
2397 int indexed_lun, lun_index;
2398 2268
2399 starget = scsi_target(sdev); 2269 starget = scsi_target(sdev);
2400 vtarget = starget->hostdata; 2270 vtarget = starget->hostdata;
2401 vdevice = sdev->hostdata; 2271 vdevice = sdev->hostdata;
2402 2272
2403 dsprintk((MYIOC_s_INFO_FMT 2273 dsprintk((MYIOC_s_INFO_FMT
2404 "device @ %p, id=%d, LUN=%d, channel=%d\n", 2274 "device @ %p, channel=%d, id=%d, lun=%d\n",
2405 hd->ioc->name, sdev, sdev->id, sdev->lun, sdev->channel)); 2275 hd->ioc->name, sdev, sdev->channel, sdev->id, sdev->lun));
2406 if (hd->ioc->bus_type == SPI) 2276 if (hd->ioc->bus_type == SPI)
2407 dsprintk((MYIOC_s_INFO_FMT 2277 dsprintk((MYIOC_s_INFO_FMT
2408 "sdtr %d wdtr %d ppr %d inq length=%d\n", 2278 "sdtr %d wdtr %d ppr %d inq length=%d\n",
@@ -2415,10 +2285,7 @@ mptscsih_slave_configure(struct scsi_device *sdev)
2415 goto slave_configure_exit; 2285 goto slave_configure_exit;
2416 } 2286 }
2417 2287
2418 vdevice->configured_lun=1; 2288 vdevice->configured_lun = 1;
2419 lun_index = (vdevice->lun >> 5); /* 32 luns per lun_index */
2420 indexed_lun = (vdevice->lun % 32);
2421 vtarget->luns[lun_index] |= (1 << indexed_lun);
2422 mptscsih_initTarget(hd, vtarget, sdev); 2289 mptscsih_initTarget(hd, vtarget, sdev);
2423 mptscsih_change_queue_depth(sdev, MPT_SCSI_CMD_PER_DEV_HIGH); 2290 mptscsih_change_queue_depth(sdev, MPT_SCSI_CMD_PER_DEV_HIGH);
2424 2291
@@ -2699,8 +2566,8 @@ static void
2699mptscsih_initTarget(MPT_SCSI_HOST *hd, VirtTarget *vtarget, 2566mptscsih_initTarget(MPT_SCSI_HOST *hd, VirtTarget *vtarget,
2700 struct scsi_device *sdev) 2567 struct scsi_device *sdev)
2701{ 2568{
2702 dinitprintk((MYIOC_s_INFO_FMT "initTarget bus=%d id=%d lun=%d hd=%p\n", 2569 dinitprintk((MYIOC_s_INFO_FMT "initTarget channel=%d id=%d lun=%d hd=%p\n",
2703 hd->ioc->name, vtarget->bus_id, vtarget->target_id, 2570 hd->ioc->name, vtarget->channel, vtarget->id,
2704 sdev->lun, hd)); 2571 sdev->lun, hd));
2705 2572
2706 /* Is LUN supported? If so, upper 2 bits will be 0 2573 /* Is LUN supported? If so, upper 2 bits will be 0
@@ -2721,7 +2588,7 @@ mptscsih_initTarget(MPT_SCSI_HOST *hd, VirtTarget *vtarget,
2721 /* Treat all Processors as SAF-TE if 2588 /* Treat all Processors as SAF-TE if
2722 * command line option is set */ 2589 * command line option is set */
2723 vtarget->tflags |= MPT_TARGET_FLAGS_SAF_TE_ISSUED; 2590 vtarget->tflags |= MPT_TARGET_FLAGS_SAF_TE_ISSUED;
2724 mptscsih_writeIOCPage4(hd, vtarget->target_id, vtarget->bus_id); 2591 mptscsih_writeIOCPage4(hd, vtarget->channel, vtarget->id);
2725 }else if ((sdev->type == TYPE_PROCESSOR) && 2592 }else if ((sdev->type == TYPE_PROCESSOR) &&
2726 !(vtarget->tflags & MPT_TARGET_FLAGS_SAF_TE_ISSUED )) { 2593 !(vtarget->tflags & MPT_TARGET_FLAGS_SAF_TE_ISSUED )) {
2727 if (sdev->inquiry_len > 49 ) { 2594 if (sdev->inquiry_len > 49 ) {
@@ -2732,7 +2599,7 @@ mptscsih_initTarget(MPT_SCSI_HOST *hd, VirtTarget *vtarget,
2732 sdev->inquiry[48] == 'T' && 2599 sdev->inquiry[48] == 'T' &&
2733 sdev->inquiry[49] == 'E' ) { 2600 sdev->inquiry[49] == 'E' ) {
2734 vtarget->tflags |= MPT_TARGET_FLAGS_SAF_TE_ISSUED; 2601 vtarget->tflags |= MPT_TARGET_FLAGS_SAF_TE_ISSUED;
2735 mptscsih_writeIOCPage4(hd, vtarget->target_id, vtarget->bus_id); 2602 mptscsih_writeIOCPage4(hd, vtarget->channel, vtarget->id);
2736 } 2603 }
2737 } 2604 }
2738 } 2605 }
@@ -2750,7 +2617,7 @@ mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target,
2750 struct scsi_device *sdev) 2617 struct scsi_device *sdev)
2751{ 2618{
2752 SpiCfgData *pspi_data = &hd->ioc->spi_data; 2619 SpiCfgData *pspi_data = &hd->ioc->spi_data;
2753 int id = (int) target->target_id; 2620 int id = (int) target->id;
2754 int nvram; 2621 int nvram;
2755 u8 width = MPT_NARROW; 2622 u8 width = MPT_NARROW;
2756 u8 factor = MPT_ASYNC; 2623 u8 factor = MPT_ASYNC;
@@ -2887,7 +2754,8 @@ mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target,
2887/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2754/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2888/* mptscsih_writeIOCPage4 - write IOC Page 4 2755/* mptscsih_writeIOCPage4 - write IOC Page 4
2889 * @hd: Pointer to a SCSI Host Structure 2756 * @hd: Pointer to a SCSI Host Structure
2890 * @target_id: write IOC Page4 for this ID & Bus 2757 * @channel: write IOC Page4 for this Bus
2758 * @id: write IOC Page4 for this ID
2891 * 2759 *
2892 * Return: -EAGAIN if unable to obtain a Message Frame 2760 * Return: -EAGAIN if unable to obtain a Message Frame
2893 * or 0 if success. 2761 * or 0 if success.
@@ -2895,7 +2763,7 @@ mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target,
2895 * Remark: We do not wait for a return, write pages sequentially. 2763 * Remark: We do not wait for a return, write pages sequentially.
2896 */ 2764 */
2897static int 2765static int
2898mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus) 2766mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int channel, int id)
2899{ 2767{
2900 MPT_ADAPTER *ioc = hd->ioc; 2768 MPT_ADAPTER *ioc = hd->ioc;
2901 Config_t *pReq; 2769 Config_t *pReq;
@@ -2936,13 +2804,13 @@ mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus)
2936 pReq->Reserved2[ii] = 0; 2804 pReq->Reserved2[ii] = 0;
2937 } 2805 }
2938 2806
2939 IOCPage4Ptr = ioc->spi_data.pIocPg4; 2807 IOCPage4Ptr = ioc->spi_data.pIocPg4;
2940 dataDma = ioc->spi_data.IocPg4_dma; 2808 dataDma = ioc->spi_data.IocPg4_dma;
2941 ii = IOCPage4Ptr->ActiveSEP++; 2809 ii = IOCPage4Ptr->ActiveSEP++;
2942 IOCPage4Ptr->SEP[ii].SEPTargetID = target_id; 2810 IOCPage4Ptr->SEP[ii].SEPTargetID = id;
2943 IOCPage4Ptr->SEP[ii].SEPBus = bus; 2811 IOCPage4Ptr->SEP[ii].SEPBus = channel;
2944 pReq->Header = IOCPage4Ptr->Header; 2812 pReq->Header = IOCPage4Ptr->Header;
2945 pReq->PageAddress = cpu_to_le32(target_id | (bus << 8 )); 2813 pReq->PageAddress = cpu_to_le32(id | (channel << 8 ));
2946 2814
2947 /* Add a SGE to the config request. 2815 /* Add a SGE to the config request.
2948 */ 2816 */
@@ -2952,8 +2820,8 @@ mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus)
2952 mpt_add_sge((char *)&pReq->PageBufferSGE, flagsLength, dataDma); 2820 mpt_add_sge((char *)&pReq->PageBufferSGE, flagsLength, dataDma);
2953 2821
2954 dinitprintk((MYIOC_s_INFO_FMT 2822 dinitprintk((MYIOC_s_INFO_FMT
2955 "writeIOCPage4: MaxSEP=%d ActiveSEP=%d id=%d bus=%d\n", 2823 "writeIOCPage4: MaxSEP=%d ActiveSEP=%d channel=%d id=%d \n",
2956 ioc->name, IOCPage4Ptr->MaxSEP, IOCPage4Ptr->ActiveSEP, target_id, bus)); 2824 ioc->name, IOCPage4Ptr->MaxSEP, IOCPage4Ptr->ActiveSEP, channel, id));
2957 2825
2958 mpt_put_msg_frame(ioc->DoneCtx, ioc, mf); 2826 mpt_put_msg_frame(ioc->DoneCtx, ioc, mf);
2959 2827
@@ -3343,7 +3211,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
3343 pScsiReq->Function = MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH; 3211 pScsiReq->Function = MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH;
3344 } else { 3212 } else {
3345 pScsiReq->TargetID = io->id; 3213 pScsiReq->TargetID = io->id;
3346 pScsiReq->Bus = io->bus; 3214 pScsiReq->Bus = io->channel;
3347 pScsiReq->ChainOffset = 0; 3215 pScsiReq->ChainOffset = 0;
3348 pScsiReq->Function = MPI_FUNCTION_SCSI_IO_REQUEST; 3216 pScsiReq->Function = MPI_FUNCTION_SCSI_IO_REQUEST;
3349 } 3217 }
@@ -3356,9 +3224,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
3356 pScsiReq->MsgFlags = mpt_msg_flags(); 3224 pScsiReq->MsgFlags = mpt_msg_flags();
3357 /* MsgContext set in mpt_get_msg_fram call */ 3225 /* MsgContext set in mpt_get_msg_fram call */
3358 3226
3359 for (ii=0; ii < 8; ii++) 3227 int_to_scsilun(io->lun, (struct scsi_lun *)pScsiReq->LUN);
3360 pScsiReq->LUN[ii] = 0;
3361 pScsiReq->LUN[1] = io->lun;
3362 3228
3363 if (io->flags & MPT_ICFLAG_TAGGED_CMD) 3229 if (io->flags & MPT_ICFLAG_TAGGED_CMD)
3364 pScsiReq->Control = cpu_to_le32(dir | MPI_SCSIIO_CONTROL_SIMPLEQ); 3230 pScsiReq->Control = cpu_to_le32(dir | MPI_SCSIIO_CONTROL_SIMPLEQ);
@@ -3379,7 +3245,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
3379 + (my_idx * MPT_SENSE_BUFFER_ALLOC)); 3245 + (my_idx * MPT_SENSE_BUFFER_ALLOC));
3380 3246
3381 ddvprintk((MYIOC_s_INFO_FMT "Sending Command 0x%x for (%d:%d:%d)\n", 3247 ddvprintk((MYIOC_s_INFO_FMT "Sending Command 0x%x for (%d:%d:%d)\n",
3382 hd->ioc->name, cmd, io->bus, io->id, io->lun)); 3248 hd->ioc->name, cmd, io->channel, io->id, io->lun));
3383 3249
3384 if (dir == MPI_SCSIIO_CONTROL_READ) { 3250 if (dir == MPI_SCSIIO_CONTROL_READ) {
3385 mpt_add_sge((char *) &pScsiReq->SGL, 3251 mpt_add_sge((char *) &pScsiReq->SGL,
@@ -3462,9 +3328,9 @@ mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
3462 iocmd.data_dma = -1; 3328 iocmd.data_dma = -1;
3463 iocmd.size = 0; 3329 iocmd.size = 0;
3464 iocmd.rsvd = iocmd.rsvd2 = 0; 3330 iocmd.rsvd = iocmd.rsvd2 = 0;
3465 iocmd.bus = vdevice->vtarget->bus_id; 3331 iocmd.channel = vdevice->vtarget->channel;
3466 iocmd.id = vdevice->vtarget->target_id; 3332 iocmd.id = vdevice->vtarget->id;
3467 iocmd.lun = (u8)vdevice->lun; 3333 iocmd.lun = vdevice->lun;
3468 3334
3469 if ((vdevice->vtarget->type == TYPE_DISK) && 3335 if ((vdevice->vtarget->type == TYPE_DISK) &&
3470 (vdevice->configured_lun)) 3336 (vdevice->configured_lun))
@@ -3480,9 +3346,6 @@ EXPORT_SYMBOL(mptscsih_resume);
3480EXPORT_SYMBOL(mptscsih_proc_info); 3346EXPORT_SYMBOL(mptscsih_proc_info);
3481EXPORT_SYMBOL(mptscsih_info); 3347EXPORT_SYMBOL(mptscsih_info);
3482EXPORT_SYMBOL(mptscsih_qcmd); 3348EXPORT_SYMBOL(mptscsih_qcmd);
3483EXPORT_SYMBOL(mptscsih_target_alloc);
3484EXPORT_SYMBOL(mptscsih_slave_alloc);
3485EXPORT_SYMBOL(mptscsih_target_destroy);
3486EXPORT_SYMBOL(mptscsih_slave_destroy); 3349EXPORT_SYMBOL(mptscsih_slave_destroy);
3487EXPORT_SYMBOL(mptscsih_slave_configure); 3350EXPORT_SYMBOL(mptscsih_slave_configure);
3488EXPORT_SYMBOL(mptscsih_abort); 3351EXPORT_SYMBOL(mptscsih_abort);