26#define MAJOR_REVISION 1
27#define MINOR_REVISION 3
28#define BUILD_REVISION 10800
31#include <sys/ioccom.h>
32#include <sys/module.h>
35#include <sys/kernel.h>
39#include <sys/malloc.h>
41#include <machine/bus.h>
43#include <machine/resource.h>
46#include <dev/pci/pcivar.h>
47#include <dev/pci/pcireg.h>
48#include <sys/endian.h>
53#include <sys/taskqueue.h>
54#include <machine/atomic.h>
55#include <sys/libkern.h>
57#include <cam/cam_ccb.h>
58#include <cam/cam_debug.h>
59#include <cam/cam_periph.h>
60#include <cam/cam_sim.h>
61#include <cam/cam_xpt_sim.h>
62#include <cam/scsi/scsi_all.h>
63#include <cam/scsi/scsi_message.h>
76 "allocated in agtiapi_attach as memory for lock use" );
78 "allocated in agtiapi_attach as mem for ag_device_t pDevList" );
80 "allocated in agtiapi_attach as mem for *pPortalData" );
82 "allocated in agtiapi_GetDevHandle as local mem for **agDev" );
84 "allocated in agtiapi_GetDevHandle as local mem for * flags" );
85#ifdef LINUX_PERBI_SUPPORT
87 "mem allocated in agtiapi_attach for pSLRList" );
89 "mem allocated in agtiapi_attach for pWWNList" );
105#define cache_line_size() CACHE_LINE_SIZE
107#define PMCoffsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
109#define CPU_TO_LE32(dst, src) \
110 dst.lower = htole32(LOW_32_BITS(src)); \
111 dst.upper = htole32(HIGH_32_BITS(src))
113#define CMND_TO_CHANNEL( ccb ) ( ccb->ccb_h.path_id )
114#define CMND_TO_TARGET( ccb ) ( ccb->ccb_h.target_id )
115#define CMND_TO_LUN( ccb ) ( ccb->ccb_h.target_lun )
120#ifdef LINUX_PERBI_SUPPORT
122static ag_mapping_t *agMappingList =
NULL;
127#define AGTIAPI_WWN(name, len) wwnprintk(name, len)
129#define AGTIAPI_WWN(name, len)
133#define AGTIAPI_WWNPRINTK(name, len, format, a...) \
134 AGTIAPI_PRINTK(format "name ", a); \
135 AGTIAPI_WWN((unsigned char*)name, len);
137#define AGTIAPI_ERR_WWNPRINTK(name, len, format, a...) \
138 printk(KERN_DEBUG format "name ", ## a); \
139 wwnprintk((unsigned char*)name, len);
140#define AGTIAPI_CPY_DEV_INFO(root, dev, pDev) \
141 tiINIGetDeviceInfo(root, dev, &pDev->devInfo); \
144#ifdef AGTIAPI_LOCAL_LOCK
146#define AG_CARD_LOCAL_LOCK(lock) ,(lock)
147#define AG_SPIN_LOCK_IRQ(lock, flags)
148#define AG_SPIN_UNLOCK_IRQ(lock, flags)
149#define AG_SPIN_LOCK(lock)
150#define AG_SPIN_UNLOCK(lock)
151#define AG_GLOBAL_ARG(arg)
152#define AG_PERF_SPINLOCK(lock)
153#define AG_PERF_SPINLOCK_IRQ(lock, flags)
156#define AG_LOCAL_LOCK(lock) if (lock) \
158#define AG_LOCAL_UNLOCK(lock) if (lock) \
160#define AG_LOCAL_FLAGS(_flags) unsigned long _flags = 0
164#define AG_GET_DONE_PCCB(pccb, pmcsc) \
166 AG_LOCAL_LOCK(&pmcsc->doneLock); \
167 pccb = pmcsc->ccbDoneHead; \
170 pmcsc->ccbDoneHead = NULL; \
171 pmcsc->ccbDoneTail = NULL; \
172 AG_LOCAL_UNLOCK(&pmcsc->doneLock); \
173 agtiapi_Done(pmcsc, pccb); \
176 AG_LOCAL_UNLOCK(&pmcsc->doneLock); \
179#define AG_GET_DONE_SMP_PCCB(pccb, pmcsc) \
181 AG_LOCAL_LOCK(&pmcsc->doneSMPLock); \
182 pccb = pmcsc->smpDoneHead; \
185 pmcsc->smpDoneHead = NULL; \
186 pmcsc->smpDoneTail = NULL; \
187 AG_LOCAL_UNLOCK(&pmcsc->doneSMPLock); \
188 agtiapi_SMPDone(pmcsc, pccb); \
191 AG_LOCAL_UNLOCK(&pmcsc->doneSMPLock); \
194#ifdef AGTIAPI_DUMP_IO_DEBUG
195#define AG_IO_DUMPCCB(pccb) agtiapi_DumpCCB(pccb)
197#define AG_IO_DUMPCCB(pccb)
200#define SCHED_DELAY_JIFFIES 4
202#ifdef HOTPLUG_SUPPORT
203#define AG_HOTPLUG_LOCK_INIT(lock) mxt_init(lock)
204#define AG_LIST_LOCK(lock) mtx_lock(lock)
205#define AG_LIST_UNLOCK(lock) mtx_unlock(lock)
207#define AG_HOTPLUG_LOCK_INIT(lock)
208#define AG_LIST_LOCK(lock)
209#define AG_LIST_UNLOCK(lock)
227 struct cam_path *path,
void *arg);
232 .d_version = D_VERSION,
248int agtiapi_open(
struct cdev *dev,
int oflags,
int devtype,
struct thread *td )
258int agtiapi_close(
struct cdev *dev,
int fflag,
int devtype,
struct thread *td )
275 uio->uio_resid, sc->
my_dev );
286 uio->uio_resid, sc->
my_dev );
296 bit8 *pDeviceInfoOrg;
303 bit32 MaxDeviceCount;
309 pDeviceInfoOrg = pIoctlPayload -> pDeviceInfo;
313 AGTIAPI_PRINTK(
"agtiapi_getdevlist: MaxDeviceCount: %d > Requested device length: %d\n", MaxDeviceCount, pIoctlPayload->
deviceLength );
317 AGTIAPI_PRINTK(
"agtiapi_getdevlist: MaxDeviceCount: %d > Requested device length: %d\n", MaxDeviceCount, pIoctlPayload->
deviceLength );
321 devList = malloc(memNeeded1, TEMP2, M_WAITOK);
324 AGTIAPI_PRINTK(
"agtiapi_getdevlist: failed to allocate memory\n");
331 pDeviceHandleList = (
bit8*)devList;
341 free(devList, TEMP2);
348 MaxDeviceCount-= count;
357 devHandleArray = devList;
363 pDeviceData = devList [x]->tdData;
369 pDeviceData->agDeviceInfo.sasAddressHi,
372 pDeviceData->agDeviceInfo.sasAddressLo,
375 pDeviceInfo->sasAddressHi =
376 DMA_BEBIT32_TO_BIT32( pDeviceInfo->sasAddressHi );
377 pDeviceInfo->sasAddressLo =
378 DMA_BEBIT32_TO_BIT32( pDeviceInfo->sasAddressLo );
381 pDeviceInfo->deviceType =
382 ( pDeviceData->agDeviceInfo.devType_S_Rate & 0x30 ) >> 4;
383 pDeviceInfo->linkRate =
384 pDeviceData->agDeviceInfo.devType_S_Rate & 0x0F;
385 pDeviceInfo->phyId = pDeviceData->phyID;
386 pDeviceInfo->ishost = pDeviceData->target_ssp_stp_smp;
387 pDeviceInfo->DeviceHandle= (
unsigned long)pDeviceHandle;
388 if(pDeviceInfo->deviceType == 0x02)
393 pDeviceInfo->sasAddressHi = DMA_BEBIT32_TO_BIT32(*(
bit32*)sasAddressHi);
394 pDeviceInfo->sasAddressLo = DMA_BEBIT32_TO_BIT32(*(
bit32*)sasAddressLo) + pDeviceData->phyID + 16;
398 pDeviceInfo->sasAddressHi =
399 DMA_BEBIT32_TO_BIT32( pDeviceInfo->sasAddressHi );
400 pDeviceInfo->sasAddressLo =
401 DMA_BEBIT32_TO_BIT32( pDeviceInfo->sasAddressLo );
405 pDeviceInfo->deviceType );
407 pDeviceInfo->linkRate );
409 pDeviceInfo->phyId );
411 pDeviceInfo->sasAddressHi );
413 pDeviceInfo->sasAddressHi );
417 AGTIAPI_PRINTK(
"agtiapi_getdevlist: pDeviceData %p or pDeviceInfo "
418 "%p is NULL %d\n", pDeviceData, pDeviceInfo, x );
424 AGTIAPI_PRINTK(
"agtiapi_getdevlist: Exit RealDeviceCount = %d\n", count );
427 free(devList, TEMP2);
461 ((
sizeof(
U32_64))*PCI_NUMBER_BARS) );
472 struct ccb_relsim crs;
473 memset(&crs, 0,
sizeof(crs));
474 xpt_setup_ccb(&crs.ccb_h, path, 5);
475 crs.ccb_h.func_code = XPT_REL_SIMQ;
476 crs.ccb_h.flags = CAM_DEV_QFREEZE;
477 crs.release_flags = RELSIM_ADJUST_OPENINGS;
478 crs.openings = QueueDepth;
479 xpt_action((
union ccb *)&crs);
480 if(crs.ccb_h.status != CAM_REQ_CMP) {
481 printf(
"XPT_REL_SIMQ failed\n");
486 struct cam_path *path,
void *arg)
493 case AC_FOUND_DEVICE:
495 struct ccb_getdev *cgd;
496 cgd = (
struct ccb_getdev *)arg;
500 TID = cgd->ccb_h.target_id;
503 TID =
INDEX(pmsc, TID);
547 load=(datatosend*)data;
548 pIoctlPayload = malloc(load->datasize,TEMP,M_WAITOK);
549 AGTIAPI_PRINTK(
"agtiapi_CharIoctl: old load->datasize = %d\n", load->datasize );
551 err = copyin(load->data,pIoctlPayload,load->datasize);
557 sema_init(&mx,0,
"sem");
576 AGTIAPI_PRINTK(
"agtiapi_CharIoctl: new load->datasize = %d\n", load->datasize );
614 printf(
"agtiapi_CharIoctl: Port Panic Status For Card %d is True\n",
pCard->
cardNo);
662 err=copyout(pIoctlPayload,load->data,load->datasize);
668 free(pIoctlPayload,TEMP);
697 thisCard = device_get_unit( dev );
700 device_printf( dev,
"Too many PMC-Sierra cards detected ERROR!\n" );
707 return( BUS_PROBE_DEFAULT );
727 int thisCard = device_get_unit( devx );
733 char buffer [256], *pLastUsedChar;
736 struct ccb_setasync csa;
738 AGTIAPI_PRINTK(
"agtiapi_attach: start dev %p thisCard %d\n", devx, thisCard);
741 AGTIAPI_PRINTK(
"agtiapi_attach: deviceID: 0x%x\n", pci_get_devid( devx ) );
754 pmsc = device_get_softc( devx );
797 pmsc->
VidDid = ( pci_get_vendor(devx) << 16 ) | pci_get_device( devx );
823 AGTIAPI_PRINTK(
"agtiapi_attach: maxTargets = osti_strtoul 0 \n" );
828 AGTIAPI_PRINTK(
"agtiapi_attach: maxTargets = osti_strtoul 10\n" );
845 AGTIAPI_PRINTK(
"agtiapi_attach: change maxTargets = AGTIAPI_HW_LIMIT_DEVICE\n" );
850 #ifdef HIALEAH_ENCRYPTION
857 printf(
"agtiapi_attach: Encryption Enabled\n" );
868 0600,
"spcv%u", thisCard );
871 mtx_init( &thisCardInst->
pmIOLock,
"pmc SAS I/O lock",
872 NULL, MTX_DEF|MTX_RECURSE );
874 struct cam_devq *devq;
884 struct cam_sim *lsim;
894 if ( lsim ==
NULL ) {
895 cam_simq_free( devq );
902 mtx_lock( &thisCardInst->
pmIOLock );
903 if ( xpt_bus_register( lsim, devx, 0 ) != CAM_SUCCESS )
905 cam_sim_free( lsim,
TRUE );
906 mtx_unlock( &thisCardInst->
pmIOLock );
912 bus = cam_sim_path(pmsc->
sim);
913 tid = CAM_TARGET_WILDCARD;
914 lun = CAM_LUN_WILDCARD;
915 ccb = xpt_alloc_ccb_nowait();
918 mtx_unlock( &thisCardInst->
pmIOLock );
919 cam_sim_free( lsim,
TRUE );
920 cam_simq_free( devq );
923 if (xpt_create_path(&ccb->ccb_h.path,
agNULL, bus, tid,
924 CAM_LUN_WILDCARD) != CAM_REQ_CMP)
926 mtx_unlock( &thisCardInst->
pmIOLock );
927 cam_sim_free( lsim,
TRUE );
928 cam_simq_free( devq );
932 pmsc->
path = ccb->ccb_h.path;
933 memset(&csa, 0,
sizeof(csa));
934 xpt_setup_ccb(&csa.ccb_h, pmsc->
path, 5);
935 csa.ccb_h.func_code = XPT_SASYNC_CB;
936 csa.event_enable = AC_FOUND_DEVICE;
938 csa.callback_arg = pmsc;
939 xpt_action((
union ccb *)&csa);
940 if (csa.ccb_h.status != CAM_REQ_CMP) {
941 AGTIAPI_PRINTK(
"agtiapi_attach: Unable to register AC_FOUND_DEVICE\n" );
944 mtx_unlock( &thisCardInst->
pmIOLock );
957 AGTIAPI_PRINTK(
"agtiapi_attach: size from the call agtiapi_ScopeDMARes"
958 " 0x%x \n", pmsc->
typhn );
962 AGTIAPI_PRINTK(
"agtiapi_attach: Card %d initialize resource ERROR\n",
976 M_PMC_MPRT, M_ZERO | M_WAITOK );
979 AGTIAPI_PRINTK(
"agtiapi_attach: Portal memory allocation ERROR\n" );
984 for( idx = 0; idx < pmsc->
portCount; idx++ ) {
985 pPortalData->
pCard = pmsc;
1021 cnt = pci_msix_count(devx);
1023 mesgs =
MIN(mesgs, cnt);
1024 error = pci_alloc_msix(devx, &mesgs);
1026 printf(
"pci_alloc_msix error %d\n", error );
1031 for(i=0; i < mesgs; i++) {
1032 pmsc->
rscID[i] = i + 1;
1033 pmsc->
irq[i] = bus_alloc_resource_any( devx,
1038 printf(
"RES_IRQ went terribly bad at %d\n", i );
1042 if ( (error = bus_setup_intr( devx, pmsc->
irq[i],
1043 INTR_TYPE_CAM | INTR_MPSAFE,
1049 device_printf( devx,
"Failed to register handler" );
1061 AGTIAPI_PRINTK(
"agtiapi_attach: agtiapi_InitCardSW failure %d\n",
1074 AGTIAPI_PRINTK(
"agtiapi_attach: agtiapi_alloc_requests failure %d\n",
1082 AGTIAPI_PRINTK(
"agtiapi_attach: agtiapi_alloc_ostimem failure %d\n",
1090 AGTIAPI_PRINTK(
"agtiapi_attach: agtiapi_InitCardHW failure %d\n",
1095#ifdef HIALEAH_ENCRYPTION
1103 pmsc->
flags &= ~AGTIAPI_INIT_TIME;
1128 mtx_init( &pmsc->sendLock,
"local q send lock",
NULL, MTX_DEF );
1129 mtx_init( &pmsc->doneLock,
"local q done lock",
NULL, MTX_DEF );
1130 mtx_init( &pmsc->sendSMPLock,
"local q send lock",
NULL, MTX_DEF );
1131 mtx_init( &pmsc->doneSMPLock,
"local q done lock",
NULL, MTX_DEF );
1132 mtx_init( &pmsc->ccbLock,
"ccb list lock",
NULL, MTX_DEF );
1134 mtx_init( &pmsc->memLock,
"dynamic memory lock",
NULL, MTX_DEF );
1135 mtx_init( &pmsc->freezeLock,
"sim freeze lock",
NULL, MTX_DEF | MTX_RECURSE);
1139#ifdef HIALEAH_ENCRYPTION
1154 AGTIAPI_PRINTK(
"agtiapi_InitCardSW: maxInterruptVectors set to %d",
1160 AGTIAPI_PRINTK(
"agtiapi_InitCardSW: tiCOMInit root %p, dev %p, pmsc %p\n",
1172 pmsc->STLock = malloc( ( maxLocks *
sizeof(
struct mtx) ), M_PMC_MSTL,
1173 M_ZERO | M_WAITOK );
1175 for( initSWIdx = 0; initSWIdx < maxLocks; initSWIdx++ )
1178 mtx_init( &pmsc->STLock[initSWIdx],
"LL & TD lock",
NULL, MTX_DEF );
1182 printf(
"agtiapi_InitCardSW: tiCOMPortInit ERROR -- AGTIAPI_FAIL\n" );
1186 " root %p, dev %p, pmsc %p\n",
1192#ifdef HIALEAH_ENCRYPTION
1232 (
ag_device_t *)malloc( numVal, M_PMC_MDVT, M_ZERO | M_WAITOK );
1234 AGTIAPI_PRINTK(
"agtiapi_InitCardHW: kmalloc %d DevList ERROR\n", numVal );
1235 panic(
"agtiapi_InitCardHW\n" );
1239#ifdef LINUX_PERBI_SUPPORT
1242 (
ag_slr_map_t *)malloc( numVal, M_PMC_MSLR, M_ZERO | M_WAITOK );
1244 AGTIAPI_PRINTK(
"agtiapi_InitCardHW: kmalloc %d SLRList ERROR\n", numVal );
1245 panic(
"agtiapi_InitCardHW SLRL\n" );
1251 (
ag_tgt_map_t *)malloc( numVal, M_PMC_MTGT, M_ZERO | M_WAITOK );
1253 AGTIAPI_PRINTK(
"agtiapi_InitCardHW: kmalloc %d WWNList ERROR\n", numVal );
1254 panic(
"agtiapi_InitCardHW WWNL\n" );
1262 agtiapi_GetWWNMappings( pmsc, agMappingList );
1264 agtiapi_GetWWNMappings( pmsc, 0 );
1266 printf(
"agtiapi_InitCardHW: WWN PERBI disabled WARN\n" );
1275 pmsc->
flags &= ~AGTIAPI_CB_DONE;
1280 for (count = 0; count < pmsc->
portCount; count++)
1282 AG_SPIN_LOCK_IRQ( agtiapi_host_lock,
flags );
1302 AG_SPIN_UNLOCK_IRQ( agtiapi_host_lock,
flags );
1304 AG_SPIN_LOCK_IRQ(agtiapi_host_lock,
flags);
1305 AGTIAPI_PRINTK(
"tiCOMPortStart failed -- no loop, portalData %p\n",
1309 AGTIAPI_PRINTK(
"tiCOMPortStart success no loop, portalData %p\n",
1315 AG_SPIN_UNLOCK_IRQ( agtiapi_host_lock,
flags );
1327#ifndef HOTPLUG_SUPPORT
1366 AG_PERF_SPINLOCK(agtiapi_host_lock);
1374 AG_SPIN_UNLOCK(agtiapi_host_lock);
1381 tasklet_hi_schedule(&
pCard->tasklet_dpc[idx]);
1390 AG_SPIN_UNLOCK(agtiapi_host_lock);
1573 bus_dma_segment_t *dm_segs,
1582 panic(
"agtiapi_SglMemoryCB: error %d\n", error);
1586 *addr = dm_segs[0].ds_addr;
1591 bus_dma_segment_t *dm_segs,
1600 panic(
"agtiapi_MemoryCB: error %d\n", error);
1604 *addr = dm_segs[0].ds_addr;
1628 AGTIAPI_PRINTK(
"agtiapi_alloc_requests: maxphys 0x%lx PAGE_SIZE 0x%x \n",
1629 maxphys, PAGE_SIZE );
1633 if( bus_dma_tag_create(
agNULL,
1640 BUS_SPACE_MAXSIZE_32BIT,
1642 BUS_SPACE_MAXSIZE_32BIT,
1647 AGTIAPI_PRINTK(
"agtiapi_alloc_requests: Cannot alloc request DMA tag\n" );
1656 if( bus_dma_tag_create(
agNULL,
1659 BUS_SPACE_MAXADDR_32BIT,
1670 AGTIAPI_PRINTK(
"agtiapi_alloc_requests: Cannot alloc request DMA tag\n" );
1678 AGTIAPI_PRINTK(
"agtiapi_alloc_requests: Cannot allocate SGL memory\n" );
1702 "next_tick 0x%x\n", next_tick );
1727 if( bus_dma_tag_create(
agNULL,
1741 AGTIAPI_PRINTK(
"agtiapi_alloc_ostimem: Can't create no-cache mem tag\n" );
1748 BUS_DMA_WAITOK | BUS_DMA_ZERO | BUS_DMA_NOCACHE,
1750 AGTIAPI_PRINTK(
"agtiapi_alloc_ostimem: Cannot allocate cache mem %d\n",
1799 int pathID, targetID, lunID;
1804 pmcsc = cam_sim_softc(
sim );
1805 AGTIAPI_IO(
"agtiapi_cam_action: start pmcs %p\n", pmcsc );
1814 AGTIAPI_IO(
"agtiapi_cam_action: cardNO %d func_code 0x%x\n", pmcsc->
cardNo, ccb->ccb_h.func_code );
1816 pathID = xpt_path_path_id( ccb->ccb_h.path );
1817 targetID = xpt_path_target_id( ccb->ccb_h.path );
1818 lunID = xpt_path_lun_id( ccb->ccb_h.path );
1820 AGTIAPI_IO(
"agtiapi_cam_action: P 0x%x T 0x%x L 0x%x\n",
1821 pathID, targetID, lunID );
1823 switch (ccb->ccb_h.func_code)
1827 struct ccb_pathinq *cpi;
1831 cpi->version_num = 1;
1832 cpi->hba_inquiry = PI_SDTR_ABLE | PI_TAG_ABLE | PI_WIDE_16;
1833 cpi->target_sprt = 0;
1834 cpi->hba_misc = PIM_NOBUSRESET | PIM_SEQSCAN;
1835 cpi->hba_eng_cnt = 0;
1840 cpi->initiator_id = 255;
1841 strlcpy(cpi->sim_vid,
"FreeBSD", SIM_IDLEN);
1842 strlcpy(cpi->hba_vid,
"PMC", HBA_IDLEN);
1843 strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
1844 cpi->unit_number = cam_sim_unit(sim);
1845 cpi->bus_id = cam_sim_bus(sim);
1847 cpi->base_transfer_speed = 150000;
1848 cpi->transport = XPORT_SAS;
1849 cpi->transport_version = 0;
1850 cpi->protocol = PROTO_SCSI;
1851 cpi->protocol_version = SCSI_REV_SPC3;
1852 cpi->ccb_h.status = CAM_REQ_CMP;
1855 case XPT_GET_TRAN_SETTINGS:
1857 struct ccb_trans_settings *cts;
1858 struct ccb_trans_settings_sas *sas;
1859 struct ccb_trans_settings_scsi *scsi;
1867 sas = &ccb->cts.xport_specific.sas;
1868 scsi = &cts->proto_specific.scsi;
1870 cts->protocol = PROTO_SCSI;
1871 cts->protocol_version = SCSI_REV_SPC3;
1872 cts->transport = XPORT_SAS;
1873 cts->transport_version = 0;
1875 sas->valid = CTS_SAS_VALID_SPEED;
1882 TID =
INDEX(pmcsc, targetID);
1894 case 0x8: speed = 150000;
1896 case 0x9: speed = 300000;
1898 case 0xA: speed = 600000;
1900 case 0xB: speed = 1200000;
1902 default: speed = 150000;
1906 sas->bitrate = speed;
1907 scsi->valid = CTS_SCSI_VALID_TQ;
1908 scsi->flags = CTS_SCSI_FLAGS_TAG_ENB;
1909 ccb->ccb_h.status = CAM_REQ_CMP;
1923 ccb->ccb_h.status = CAM_REQ_CMP;
1928 ccb->ccb_h.status = CAM_REQ_CMP;
1933 ccb->ccb_h.status = CAM_REQ_CMP;
1936#if __FreeBSD_version >= 900026
1947 ccb->ccb_h.status = CAM_SEL_TIMEOUT;
1952 AGTIAPI_PRINTK(
"agtiapi_cam_action: shutdown, XPT_SCSI_IO 0x%x\n",
1954 ccb->ccb_h.status = CAM_FUNC_NOTAVAIL;
1959 AGTIAPI_IO(
"agtiapi_cam_action: Zero XPT_SCSI_IO 0x%x, doing IOs\n",
1966 case XPT_CALC_GEOMETRY:
1968 cam_calc_geometry(&ccb->ccg, 1);
1969 ccb->ccb_h.status = CAM_REQ_CMP;
1977 AGTIAPI_IO(
"agtiapi_cam_action: default function code 0x%x\n",
1978 ccb->ccb_h.func_code );
1979 ccb->ccb_h.status = CAM_FUNC_NOTAVAIL;
2004 AG_LOCAL_LOCK( &pmcsc->ccbLock );
2014 AGTIAPI_IO(
"agtiapi_GetCCB: re-allocated ccb %p\n", pccb );
2018 AGTIAPI_PRINTK(
"agtiapi_GetCCB: kmalloc ERROR - no ccb allocated\n" );
2021 AG_LOCAL_UNLOCK( &pmcsc->ccbLock );
2040 struct ccb_scsiio *csio = &ccb->csio;
2050 if (csio->cdb_len > 16)
2052 AGTIAPI_PRINTK(
"agtiapi_QueueCmnd_: unsupported CDB length %d\n",
2054 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
2055 ccb->ccb_h.status &= ~CAM_STATUS_MASK;
2056 ccb->ccb_h.status |= CAM_REQ_INVALID;
2063 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
2064 ccb->ccb_h.status &= ~CAM_STATUS_MASK;
2065 ccb->ccb_h.status |= CAM_DEV_NOT_THERE;
2076 TID =
INDEX(pmcsc, TID);
2080 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
2081 ccb->ccb_h.status &= ~CAM_STATUS_MASK;
2082 ccb->ccb_h.status |= CAM_REQUEUE_REQ;
2086 pccb->
pmcsc = pmcsc;
2094 pccb->
pSenseData = (caddr_t) &csio->sense_data;
2103 AGTIAPI_PRINTK(
"agtiapi_QueueCmnd_: agtiapi_PrepareSGList failure\n");
2107 ccb->ccb_h.status = CAM_REQ_INVALID;
2111 ccb->ccb_h.status = CAM_REQ_CMP;
2133 struct ccb_scsiio *csio;
2139 printf(
"agtiapi_DumpCDB: no pccb here \n" );
2140 panic(
"agtiapi_DumpCDB: pccb is NULL. called from %s\n", ptitle);
2146 printf(
"agtiapi_DumpCDB: no ccb here \n" );
2147 panic(
"agtiapi_DumpCDB: pccb %p ccb %p flags %d ccb NULL! "
2149 pccb, pccb->
ccb, pccb->
flags, ptitle );
2155 printf(
"agtiapi_DumpCDB: no csio here \n" );
2156 panic(
"agtiapi_DumpCDB: pccb%p ccb%p flags%d csio NULL! called from %s\n",
2157 pccb, pccb->
ccb, pccb->
flags, ptitle );
2160 len =
MIN(64, csio->cdb_len);
2161 if (csio->ccb_h.flags & CAM_CDB_POINTER)
2163 bcopy(csio->cdb_io.cdb_ptr, &cdb[0], len);
2167 bcopy(csio->cdb_io.cdb_bytes, &cdb[0], len);
2170 AGTIAPI_IO(
"agtiapi_DumpCDB: pccb%p CDB0x%x csio->cdb_len %d"
2171 " len %d from %s\n",
2192 unsigned long flags;
2195 AG_SPIN_LOCK_IRQ( agtiapi_host_lock,
flags );
2197 AG_SPIN_UNLOCK_IRQ( agtiapi_host_lock,
flags );
2237 AG_SPIN_LOCK_IRQ(agtiapi_host_lock,
flags);
2245 while (pccb_curr !=
NULL)
2257 AGTIAPI_PRINTK(
"agtiapi_CheckIOTimeout: pccb %p timed out, call TM "
2258 "function -- flags=%x startTime=%ld tdData = %p\n",
2271#ifdef AGTIAPI_LOCAL_RESET
2273 AGTIAPI_PRINTK(
"agtiapi_CheckIOTimeout: Abort request failed\n");
2275 AGTIAPI_PRINTK(
"agtiapi_CheckIOTimeout:in agtiapi_CheckIOTimeout() "
2276 "abort request did not go thru ==> soft reset#7, then "
2277 "restart timer\n" );
2283 pccb_curr = pccb_next;
2289 AG_SPIN_UNLOCK_IRQ(agtiapi_host_lock,
flags);
2314 pccb, pccb->
flags );
2324 AGTIAPI_PRINTK(
"agtiapi_StartTM: ccb %p flag 0x%x tid %d no tdData "
2337 AGTIAPI_PRINTK(
"agtiapi_StartTM: LocalAbort Request for Abort_TASK "
2341 "tiINIIOAbort() failed ==> soft reset#8\n" );
2385 AGTIAPI_PRINTK(
"agtiapi_StartTM: pTMccb %p flag %x tid %d via TM "
2398 AGTIAPI_PRINTK(
"agtiapi_StartTM: TM_ABORT_TASK request success ccb "
2406 AGTIAPI_PRINTK(
"agtiapi_StartTM: TM_ABORT_TASK request tiIONoDevice ccb "
2413 AGTIAPI_PRINTK(
"agtiapi_StartTM: TM_ABORT_TASK request failed ccb %p, "
2425 (pccb) ? pccb->
flags : -1);
2429#if __FreeBSD_version > 901000
2446 union ccb *ccb = pccb->
ccb;
2447 struct ccb_scsiio *csio = &ccb->csio;
2448 struct ccb_hdr *ccbh = &ccb->ccb_h;
2449 AGTIAPI_IO(
"agtiapi_PrepareSGList: start\n" );
2452 AGTIAPI_IO(
"agtiapi_PrepareSGList: dxfer_len %d\n", csio->dxfer_len );
2454 if ((ccbh->flags & CAM_DIR_MASK) != CAM_DIR_NONE)
2456 switch((ccbh->flags & CAM_DATA_MASK))
2459 struct bus_dma_segment seg;
2460 case CAM_DATA_VADDR:
2464 AGTIAPI_IO(
"agtiapi_PrepareSGList: virtual address\n" );
2474 if (error == EINPROGRESS)
2478 xpt_freeze_simq(pmcsc->
sim, 1);
2480 ccbh->status |= CAM_RELEASE_SIMQ;
2483 case CAM_DATA_PADDR:
2489 (bus_addr_t)(vm_offset_t)csio->data_ptr;
2490 seg.ds_len = csio->dxfer_len;
2522 union ccb *ccb = pccb->
ccb;
2523 struct ccb_scsiio *csio = &ccb->csio;
2524 struct ccb_hdr *ccbh = &ccb->ccb_h;
2525 AGTIAPI_IO(
"agtiapi_PrepareSGList: start\n" );
2527 AGTIAPI_IO(
"agtiapi_PrepareSGList: dxfer_len %d\n", csio->dxfer_len );
2529 if ((ccbh->flags & CAM_DIR_MASK) != CAM_DIR_NONE)
2531 if ((ccbh->flags & CAM_SCATTER_VALID) == 0)
2534 if ((ccbh->flags & CAM_DATA_PHYS) == 0)
2539 AGTIAPI_IO(
"agtiapi_PrepareSGList: virtual address\n" );
2549 if (error == EINPROGRESS)
2553 xpt_freeze_simq(pmcsc->
sim, 1);
2555 ccbh->status |= CAM_RELEASE_SIMQ;
2562 struct bus_dma_segment seg;
2565 (bus_addr_t)(vm_offset_t)csio->data_ptr;
2566 seg.ds_len = csio->dxfer_len;
2601 bus_dma_segment_t *segs,
2606 union ccb *ccb = pccb->
ccb;
2607 struct ccb_scsiio *csio = &ccb->csio;
2612 bus_dmasync_op_t op;
2615 int io_is_encryptable = 0;
2616 unsigned long long start_lba = 0;
2620 AGTIAPI_IO(
"agtiapi_PrepareSGListCB: start, nsegs %d error 0x%x\n",
2622 pmcsc = pccb->
pmcsc;
2626 if (error == 0xAABBCCDD || error == 0xAAAAAAAA)
2632 AGTIAPI_PRINTK(
"agtiapi_PrepareSGListCB: error status 0x%x\n", error);
2636 ccb->ccb_h.status = CAM_REQ_TOO_BIG;
2638 ccb->ccb_h.status = CAM_REQ_CMP_ERR;
2646 AGTIAPI_PRINTK(
"agtiapi_PrepareSGListCB: over the limit. nsegs %d"
2647 " AGTIAPI_MAX_DMA_SEGS %d\n",
2651 ccb->ccb_h.status = CAM_REQ_TOO_BIG;
2658 pccb->
dataLen = csio->dxfer_len;
2661 if (nsegs == 1 && error == 0xAABBCCDD)
2672 else if (nsegs == 0 && error == 0xAAAAAAAA)
2675 AGTIAPI_IO(
"agtiapi_PrepareSGListCB: no data transfer\n" );
2685 pccb->
dataLen = segs[0].ds_len;
2698 for (i = 0; i < nsegs; i++)
2700 pccb->
sgList[i].
len = htole32(segs[i].ds_len);
2703 pccb->
dataLen += segs[i].ds_len;
2717 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT)
2719 op = BUS_DMASYNC_PREWRITE;
2724 op = BUS_DMASYNC_PREREAD;
2732 if (csio->ccb_h.flags & CAM_CDB_POINTER)
2734 bcopy(csio->cdb_io.cdb_ptr, &pScsiCmnd->
cdb[0], csio->cdb_len);
2738 bcopy(csio->cdb_io.cdb_bytes, &pScsiCmnd->
cdb[0],csio->cdb_len);
2741 CDB = &pScsiCmnd->
cdb[0];
2749 AGTIAPI_PRINTK(
"agtiapi_PrepareSGListCB: QueueCmnd - REQUEST SENSE new\n");
2751 phys_addr = vtophys(&csio->sense_data);
2761 case TEST_UNIT_READY:
2771 start_lba = ((CDB[1] & 0x1f) << 16) |
2774#ifdef HIALEAH_ENCRYPTION
2775 io_is_encryptable = 1;
2783 start_lba = (CDB[2] << 24) |
2787#ifdef HIALEAH_ENCRYPTION
2788 io_is_encryptable = 1;
2794 start_lba = (CDB[2] << 24) |
2799 start_lba |= ((CDB[6] << 24) |
2803#ifdef HIALEAH_ENCRYPTION
2804 io_is_encryptable = 1;
2819 ccb->ccb_h.status = CAM_DEV_NOT_THERE;
2829 ccb->ccb_h.status = CAM_DEV_NOT_THERE;
2858#ifdef AGTIAPI_TEST_DIF
2863#ifdef TEST_VERIFY_AND_FORWARD
2872#ifdef AGTIAPI_TEST_DIF
2877#ifdef AGTIAPI_TEST_DIF
2900#ifdef AGTIAPI_TEST_DPL
2901 if(agtiapi_SetupDifPerLA(
pCard, pccb, start_lba) < 0) {
2902 printk(KERN_ERR
"SetupDifPerLA Failed.\n");
2903 cmnd->result = SCSI_HOST(DID_ERROR);
2908#ifdef AGTIAPI_TEST_DIF
2914 if(CDB[0] == READ_6) {
2919 }
else if(CDB[0] == READ_10 || CDB[0] == READ_12) {
2924 }
else if(CDB[0] == READ_16) {
2940#ifdef AGTIAPI_TEST_DIF
2962#ifdef AGTIAPI_TEST_DPL
2963 if(agtiapi_SetupDifPerLA(
pCard, pccb, start_lba) < 0) {
2964 printk(KERN_ERR
"SetupDifPerLA Failed.\n");
2965 cmnd->result = SCSI_HOST(DID_ERROR);
2970#ifdef AGTIAPI_TEST_DIF
2976 if(CDB[0] == WRITE_6) {
2980 }
else if(CDB[0] == WRITE_10 || CDB[0] == WRITE_12) {
2985 }
else if(CDB[0] == WRITE_16) {
2998 if ((ccb->ccb_h.flags & CAM_TAG_ACTION_VALID) != 0)
3000 switch(csio->tag_action)
3002 case MSG_HEAD_OF_Q_TAG:
3008 case MSG_ORDERED_Q_TAG:
3011 case MSG_SIMPLE_Q_TAG:
3033 ccb->ccb_h.status = CAM_DEV_NOT_THERE;
3051 ccb->ccb_h.status = CAM_DEV_NOT_THERE;
3056 AGTIAPI_IO(
"agtiapi_PrepareSGListCB: send ccb pccb->devHandle %p, "
3057 "pccb->targetId %d TID %d pmcsc->devDiscover %d card %p\n",
3060#ifdef HIALEAH_ENCRYPTION
3061 if(pmcsc->
encrypt && io_is_encryptable) {
3064 io_is_encryptable = 0;
3070 AG_CARD_LOCAL_LOCK(&pmcsc->sendLock), pccb );
3093 AG_LOCAL_LOCK( &pmcsc->sendLock );
3099 AG_LOCAL_UNLOCK( &pmcsc->sendLock );
3115 AG_LOCAL_UNLOCK( &pmcsc->sendLock );
3147 AGTIAPI_PRINTK(
"agtiapi_StartIO: device %p not active! ERROR\n",
3155 " -- active flag:%d\n",
3169 status = agtiapi_FastIOTest( pmcsc, pccb );
3194 AGTIAPI_PRINTK(
"agtiapi_StartIO: tiINIIOStart status tiDeviceBusy %p\n",
3197 agtiapi_LogEvent( pmcsc,
3202 "tiINIIOStart tiDeviceBusy " );
3210 AGTIAPI_PRINTK(
"agtiapi_StartIO: tiINIIOStart status tiBusy %p\n",
3213 agtiapi_LogEvent( pmcsc,
3218 "tiINIIOStart tiBusy " );
3227 AGTIAPI_PRINTK(
"agtiapi_StartIO: tiINIIOStart status tiNoDevice %p "
3228 "ERROR\n", pccb->
ccb );
3230 agtiapi_LogEvent( pmcsc,
3235 "tiINIIOStart invalid device handle " );
3246 AG_CARD_LOCAL_LOCK(&pmcsc->sendLock), pccb);
3250 AGTIAPI_PRINTK(
"agtiapi_StartIO: tiINIIOStart status tiError %p\n",
3253 agtiapi_LogEvent(pmcsc,
3258 "tiINIIOStart tiError ");
3265 AGTIAPI_PRINTK(
"agtiapi_StartIO: tiINIIOStart status default %x %p\n",
3268 agtiapi_LogEvent(pmcsc,
3273 "tiINIIOStart unexpected status ");
3304 AG_LOCAL_LOCK(&pmcsc->sendSMPLock);
3310 AG_LOCAL_UNLOCK(&pmcsc->sendSMPLock);
3318 AG_LOCAL_UNLOCK(&pmcsc->sendSMPLock);
3357 AGTIAPI_PRINTK(
"agtiapi_StartSMP: tiINISMPStart status tiBusy %p\n",
3361 AG_CARD_LOCAL_LOCK(&pmcsc->sendSMPLock), pccb);
3364 AGTIAPI_PRINTK(
"agtiapi_StartIO: tiINIIOStart status tiError %p\n",
3370 AGTIAPI_PRINTK(
"agtiapi_StartIO: tiINIIOStart status default %x %p\n",
3385#if __FreeBSD_version > 901000
3403 union ccb *ccb = pccb->
ccb;
3404 struct ccb_smpio *csmpio = &ccb->smpio;
3405 struct ccb_hdr *ccbh = &ccb->ccb_h;
3408 switch((ccbh->flags & CAM_DATA_MASK))
3410 case CAM_DATA_PADDR:
3411 case CAM_DATA_SG_PADDR:
3412 AGTIAPI_PRINTK(
"agtiapi_PrepareSMPSGList: Physical Address not supported\n");
3413 ccb->ccb_h.status = CAM_REQ_INVALID;
3422 if ( (csmpio->smp_request_sglist_cnt > 1)
3423 || (csmpio->smp_response_sglist_cnt > 1) )
3425 AGTIAPI_PRINTK(
"agtiapi_PrepareSMPSGList: Multiple SG list not supported\n");
3426 ccb->ccb_h.status = CAM_REQ_INVALID;
3431 if ( csmpio->smp_request_sglist_cnt != 0 )
3442 csmpio->smp_request,
3443 csmpio->smp_request_len,
3450 if (error == EINPROGRESS)
3459 xpt_freeze_simq( pmcsc->
sim, 1 );
3461 ccbh->status |= CAM_RELEASE_SIMQ;
3464 if( csmpio->smp_response_sglist_cnt != 0 )
3475 csmpio->smp_response,
3476 csmpio->smp_response_len,
3483 if ( error == EINPROGRESS )
3492 xpt_freeze_simq( pmcsc->
sim, 1 );
3494 ccbh->status |= CAM_RELEASE_SIMQ;
3500 if ( (csmpio->smp_request_sglist_cnt == 0) &&
3501 (csmpio->smp_response_sglist_cnt == 0) )
3503 AGTIAPI_PRINTK(
"agtiapi_PrepareSMPSGList: physical address\n" );
3535 union ccb *ccb = pccb->
ccb;
3536 struct ccb_smpio *csmpio = &ccb->smpio;
3537 struct ccb_hdr *ccbh = &ccb->ccb_h;
3541 if (ccbh->flags & (CAM_DATA_PHYS|CAM_SG_LIST_PHYS))
3544 "not supported\n" );
3545 ccb->ccb_h.status = CAM_REQ_INVALID;
3550 if (ccbh->flags & CAM_SCATTER_VALID)
3556 if ( (csmpio->smp_request_sglist_cnt > 1)
3557 || (csmpio->smp_response_sglist_cnt > 1) )
3560 "not supported\n" );
3561 ccb->ccb_h.status = CAM_REQ_INVALID;
3565 if ( csmpio->smp_request_sglist_cnt != 0 )
3576 csmpio->smp_request,
3577 csmpio->smp_request_len,
3584 if (error == EINPROGRESS)
3593 xpt_freeze_simq( pmcsc->
sim, 1 );
3595 ccbh->status |= CAM_RELEASE_SIMQ;
3598 if( csmpio->smp_response_sglist_cnt != 0 )
3609 csmpio->smp_response,
3610 csmpio->smp_response_len,
3617 if ( error == EINPROGRESS )
3626 xpt_freeze_simq( pmcsc->
sim, 1 );
3628 ccbh->status |= CAM_RELEASE_SIMQ;
3634 if ( (csmpio->smp_request_sglist_cnt == 0) &&
3635 (csmpio->smp_response_sglist_cnt == 0) )
3637 AGTIAPI_PRINTK(
"agtiapi_PrepareSMPSGList: physical address\n" );
3667 bus_dma_segment_t *segs,
3672 union ccb *ccb = pccb->
ccb;
3680 AGTIAPI_PRINTK(
"agtiapi_PrepareSMPSGListCB: start, nsegs %d error 0x%x\n",
3682 pmcsc = pccb->
pmcsc;
3686 if (error == 0xAABBCCDD)
3692 AGTIAPI_PRINTK(
"agtiapi_PrepareSMPSGListCB: error status 0x%x\n",
3697 ccb->ccb_h.status = CAM_REQ_TOO_BIG;
3699 ccb->ccb_h.status = CAM_REQ_CMP_ERR;
3707 AGTIAPI_PRINTK(
"agtiapi_PrepareSMPSGListCB: over the limit. nsegs %d "
3708 "AGTIAPI_MAX_DMA_SEGS %d\n",
3712 ccb->ccb_h.status = CAM_REQ_TOO_BIG;
3725 ccb->ccb_h.status = CAM_FUNC_NOTAVAIL;
3734 AGTIAPI_PRINTK(
"agtiapi_PrepareSMPSGListCB: not sending ccb devH %p, "
3735 "target %d tid %d/%d "
3736 "card %p ERROR pccb %p\n",
3744 ccb->ccb_h.status = CAM_FUNC_NOTAVAIL;
3752 AGTIAPI_PRINTK(
"agtiapi_PrepareSMPSGListCB: send ccb pccb->devHandle %p, "
3753 "pccb->targetId %d TID %d pmcsc->devDiscover %d card %p\n",
3769 AGTIAPI_PRINTK(
"agtiapi_PrepareSMPSGListCB: Error getting Expander "
3772 ccb->ccb_h.status = CAM_FUNC_NOTAVAIL;
3782 AG_CARD_LOCAL_LOCK(&pmcsc->sendSMPLock), pccb );
3820 if (cmnd->
cdb[0] == RECEIVE_DIAGNOSTIC)
3822 AGTIAPI_PRINTK(
"agtiapi_Done: RECEIVE_DIAG pg %d id %d cmnd %p pccb "
3830 ccb = pccb_curr->
ccb;
3834 pccb_curr = pccb_next;
3870 ccb = pccb_curr->
ccb;
3875 pccb_curr = pccb_next;
3903 for (i = 0; i < len; )
3907 AGTIAPI_PRINTK(
" 0x%02x, 0x%02x, 0x%02x, 0x%02x,\n", pbuf[i], pbuf[i+1],
3908 pbuf[i+2], pbuf[i+3] );
3951 AGTIAPI_PRINTK(
"agtiapi_CheckError: CCB orphan = %p ERROR\n", pccb);
3966 if (pDevice !=
NULL)
3984 atomic_subtract_int(&pDevice->
CCBCount,1);
3986 AG_LOCAL_LOCK(&pmcsc->freezeLock);
3990 xpt_release_simq(pmcsc->
sim, 1);
3992 AG_LOCAL_UNLOCK(&pmcsc->freezeLock);
3997 AGTIAPI_IO(
"agtiapi_CheckError: tiIOSuccess pccb %p\n", pccb);
4001 ccb->ccb_h.status = CAM_REQ_CMP;
4006 ccb->ccb_h.status = CAM_REQ_ABORTED;
4010 ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR;
4014 ccb->ccb_h.status |= CAM_AUTOSNS_VALID;
4020 AGTIAPI_PRINTK(
"agtiapi_CheckError: tiIOOverRun pccb %p\n", pccb);
4022 ccb->csio.resid = 0;
4023 ccb->ccb_h.status = CAM_DATA_RUN_ERR;
4026 AGTIAPI_PRINTK(
"agtiapi_CheckError: tiIOUnderRun pccb %p\n", pccb);
4028 ccb->ccb_h.status = CAM_REQ_CMP;
4029 ccb->csio.scsi_status = SCSI_STATUS_OK;
4033 AGTIAPI_PRINTK(
"agtiapi_CheckError: pccb %p tiIOFailed %d id %d ERROR\n",
4037 AGTIAPI_IO(
"agtiapi_CheckError: pccb %p tiIOFailed - tiDetailBusy\n",
4039 ccb->ccb_h.status &= ~CAM_STATUS_MASK;
4040 ccb->ccb_h.status |= CAM_REQUEUE_REQ;
4041 if ((ccb->ccb_h.status & CAM_DEV_QFRZN) == 0)
4043 ccb->ccb_h.status |= CAM_DEV_QFRZN;
4044 xpt_freeze_devq(ccb->ccb_h.path, 1);
4049 AG_LOCAL_LOCK(&pmcsc->freezeLock);
4053 xpt_freeze_simq(pmcsc->
sim, 1);
4055 AG_LOCAL_UNLOCK(&pmcsc->freezeLock);
4056 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
4057 ccb->ccb_h.status |= CAM_REQUEUE_REQ;
4062 "tiDetailNoLogin ERROR\n", pccb );
4063 ccb->ccb_h.status = CAM_DEV_NOT_THERE;
4068 "tiDetailNotValid ERROR\n", pccb );
4069 ccb->ccb_h.status = CAM_REQ_INVALID;
4074 "tiDetailAbortLogin ERROR\n", pccb );
4075 ccb->ccb_h.status = CAM_REQ_ABORTED;
4080 "tiDetailAbortReset ERROR\n", pccb );
4081 ccb->ccb_h.status = CAM_REQ_ABORTED;
4086 "tiDetailAborted ERROR\n", pccb );
4087 ccb->ccb_h.status = CAM_REQ_ABORTED;
4092 "tiDetailOtherError ERROR\n", pccb );
4093 ccb->ccb_h.status = CAM_REQ_ABORTED;
4097 AGTIAPI_PRINTK(
"agtiapi_CheckError: pccb %p tiIOFailed %d id %d ERROR\n",
4101 AGTIAPI_IO(
"agtiapi_CheckError: pccb %p tiIOFailed - "
4102 "tiDetailDifAppTagMismatch\n", pccb );
4103 ccb->ccb_h.status = CAM_REQ_CMP_ERR;
4108 "tiDetailDifRefTagMismatch\n", pccb );
4109 ccb->ccb_h.status = CAM_REQ_CMP_ERR;
4114 "tiDetailDifCrcMismatch\n", pccb );
4115 ccb->ccb_h.status = CAM_REQ_CMP_ERR;
4118#ifdef HIALEAH_ENCRYPTION
4120 AGTIAPI_PRINTK(
"agtiapi_CheckError: pccb %p tiIOFailed %d id %d ERROR\n",
4125 "tiDetailDekKeyCacheMiss ERROR\n",
4126 __FUNCTION__, pccb );
4127 ccb->ccb_h.status = CAM_REQ_ABORTED;
4133 "tiDetailDekIVMismatch ERROR\n", __FUNCTION__, pccb );
4134 ccb->ccb_h.status = CAM_REQ_ABORTED;
4140 AGTIAPI_PRINTK(
"agtiapi_CheckError: pccb %p tiIOdefault %d id %d ERROR\n",
4142 ccb->ccb_h.status = CAM_REQ_CMP_ERR;
4167 union ccb * ccb = pccb->
ccb;
4174 AGTIAPI_PRINTK(
"agtiapi_CheckSMPError: CCB orphan = %p ERROR\n",
4186 ccb->ccb_h.status = CAM_REQ_CMP;
4192 ccb->ccb_h.status = CAM_REQ_CMP_ERR;
4195 AGTIAPI_PRINTK(
"agtiapi_CheckSMPError: pccb %p tiSMPdefault %d "
4200 ccb->ccb_h.status = CAM_REQ_CMP_ERR;
4246 AGTIAPI_PRINTK(
"agtiapi_Retry: ccb %p retry %d flgs x%x\n", pccb,
4250 AG_CARD_LOCAL_LOCK(&pmcsc->sendLock), pccb);
4267 AGTIAPI_PRINTK(
"agtiapi_DumpCCB: pccb %p, devHandle %p, tid %d, lun %d\n",
4272 AGTIAPI_PRINTK(
"flag 0x%x, add_mode 0x%x, ccbStatus 0x%x, scsiStatus 0x%x\n",
4284 AGTIAPI_PRINTK(
"scsiCmnd: expDataLength 0x%x, taskAttribute 0x%x\n",
4287 AGTIAPI_PRINTK(
"cdb[0] = 0x%x, cdb[1] = 0x%x, cdb[2] = 0x%x, cdb[3] = 0x%x\n",
4292 AGTIAPI_PRINTK(
"cdb[4] = 0x%x, cdb[5] = 0x%x, cdb[6] = 0x%x, cdb[7] = 0x%x\n",
4303 AGTIAPI_PRINTK(
"agSgl1: upper 0x%x, lower 0x%x, len 0x%x, type %d\n",
4329 printf(
"agtiapi_eh_HostReset: null command, skipping reset.\n" );
4334 agtiapi_LogEvent( pmcsc,
4339 "agtiapi_eh_HostReset! " );
4369 AGTIAPI_IO(
"agtiapi_QueueCCB: %p to %p\n", pccb, phead );
4370 if (phead ==
NULL || ptail ==
NULL)
4372 panic(
"agtiapi_QueueCCB: phead %p ptail %p", phead, ptail );
4374 pccb->pccbNext =
NULL;
4375 AG_LOCAL_LOCK( mutex );
4388 AG_LOCAL_UNLOCK( mutex );
4409 int targetID = xpt_path_target_id(ccb->ccb_h.path);
4417 ccb->ccb_h.status = CAM_REQ_CMP_ERR;
4421 pccb->
pmcsc = pmcsc;
4431 AGTIAPI_PRINTK(
"agtiapi_QueueSMP: agtiapi_PrepareSMPSGList failure\n");
4435 ccb->ccb_h.status = CAM_REQ_INVALID;
4439 ccb->ccb_h.status = CAM_REQ_CMP;
4474 (
U08)((pccb->
lun >> 8) & 0x3F);
4502 union ccb *ccb = pccb->
ccb;
4503 bus_dmasync_op_t op;
4505 AG_LOCAL_LOCK(&pmcsc->ccbLock);
4506 AGTIAPI_IO(
"agtiapi_FreeCCB: start %p\n", pccb );
4508#ifdef AGTIAPI_TEST_EPL
4516 AGTIAPI_IO(
"agtiapi_FreeCCB: pccb->sgList is NOT null\n" );
4524 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT)
4526 op = BUS_DMASYNC_POSTWRITE;
4530 op = BUS_DMASYNC_POSTREAD;
4536 AGTIAPI_IO(
"agtiapi_FreeCCB: numSgElements zero\n" );
4540 AGTIAPI_IO(
"agtiapi_FreeCCB: numSgElements is one\n" );
4547 AGTIAPI_PRINTK(
"agtiapi_FreeCCB: numSgElements 2 or higher \n" );
4553#ifdef AGTIAPI_TEST_DPL
4556 memset( (
char *) pccb->dplPtr,
4558 MAX_DPL_REGIONS *
sizeof(dplaRegion_t) );
4565#ifdef AGTIAPI_TEST_EPL
4574#ifdef ENABLE_SATA_DIF
4575 if (pccb->holePtr && pccb->dmaHandleHole)
4579 pccb->dmaHandleHole );
4581 pccb->dmaHandleHole = 0;
4594#ifdef HIALEAH_ENCRYPTION
4607 AG_LOCAL_UNLOCK(&pmcsc->ccbLock);
4632 if( pccb->
flags == 0 )
4658 ccb->ccb_h.status = CAM_SCSI_BUS_RESET;
4680 union ccb *ccb = pccb->
ccb;
4681 bus_dmasync_op_t op;
4683 AG_LOCAL_LOCK(&pmcsc->ccbLock);
4687 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT)
4689 op = BUS_DMASYNC_POSTWRITE;
4693 op = BUS_DMASYNC_POSTREAD;
4710 AGTIAPI_PRINTK(
"agtiapi_FreeSMPCCB: numSgElements 2 or higher \n");
4733 AG_LOCAL_UNLOCK(&pmcsc->ccbLock);
4752 AG_LOCAL_LOCK(&pmcsc->ccbLock);
4769 AG_LOCAL_UNLOCK(&pmcsc->ccbLock);
4822 volatile U32 *pStatus )
4825 initiatorOption.usecsPerTick / 1000;
4826 S32 i = milisec/msecsPerTick;
4827 AG_GLOBAL_ARG( _flags );
4840 if( flag == 0 || *pStatus & flag )
4848 if( flag == 0 || *pStatus & flag )
4856 AG_SPIN_LOCK_IRQ( agtiapi_host_lock, _flags );
4860 AG_SPIN_UNLOCK_IRQ( agtiapi_host_lock, _flags );
4893 for (count = 0; count <
pCard->
portCount; count++, pPortalData++)
4903 AGTIAPI_PRINTK(
"agtiapi_DiscoverTgt: Port %p / %d not ready for "
4905 pPortalData, count );
4917 AGTIAPI_FLOW(
"agtiapi_DiscoverTgt: Portal %p DiscoverTargets starts\n",
4926 AGTIAPI_PRINTK(
"agtiapi_DiscoverTgt: tiINIDiscoverTargets ERROR\n");
4936 for (count = 0; count <
pCard->
portCount; count++, pPortalData++)
4944 AGTIAPI_PRINTK(
"agtiapi_DiscoverTgt: Portal %p discover complete, "
4949 AGTIAPI_PRINTK(
"agtiapi_DiscoverTgt: Portal %p discover is not "
4950 "completed, status 0x%x\n",
4954 AGTIAPI_PRINTK(
"agtiapi_DiscoverTgt: Portal %d discover target "
4968 for (count = 0; count <
pCard->
portCount; count++, pPortalData++)
5029 sgl_sz =
sizeof(
tiSgl_t) * nsegs;
5030 AGTIAPI_PRINTK(
"agtiapi_PrepCCBs: tid %d offset %d nsegs %d sizeof(tiSgl_t) "
5031 "%lu, max_ccb %d\n",
5043 memset((
void *)
hdr, 0, size);
5049 pccb = (
ccb_t*) ((
char*)
hdr + hdr_sz);
5051 for (i = 0; i < max_ccb; i++, pccb = (
ccb_t*)((
char*)pccb + ccb_sz))
5068#ifdef AGTIAPI_ALIGN_CHECK
5073 if (&pccb->
lun & 0x63)
5089 if (&pccb->
flags & 0x63)
5093 if (&pccb->
sgList[0] & 0x63)
5099 if (&pccb->
cmd & 0x63)
5125#ifdef AGTIAPI_ALIGN_CHECK
5146 U32 max_ccb, size, ccb_sz, hdr_sz;
5147 int no_allocs = 0, i;
5151 AGTIAPI_PRINTK(
"agtiapi_InitCCBs: tgtCount %d tid %d\n", tgtCount, tid);
5152 AGTIAPI_FLOW(
"agtiapi_InitCCBs: tgtCount %d tid %d\n", tgtCount, tid);
5154#ifndef HOTPLUG_SUPPORT
5165 size = ccb_sz * max_ccb + hdr_sz;
5167 for (i = 0; i < (1 << no_allocs); i++)
5169 hdr = (
ccb_hdr_t*)malloc( size, M_PMC_MCCB, M_NOWAIT );
5172 panic(
"agtiapi_InitCCBs: bug!!!\n" );
5185#ifdef LINUX_PERBI_SUPPORT
5202 ag_mapping_t *pMapList )
5211 panic(
"agtiapi_GetWWNMappings: no pCard \n" );
5231 for ( lIdx = 0; lIdx < devDisc - 1; lIdx++) {
5232 pWWNList[lIdx].
flags = 0;
5261 for ( lLstIdx = 0; lLstIdx < lstMax; lLstIdx++ )
5263 if ( pWWNList[lLstIdx].devListIndex == lstMax &&
5264 pWWNList[lLstIdx].targetLen == 0 )
5268 pWWNList[lLstIdx].devListIndex,
5269 pWWNList[lLstIdx].targetLen,
5270 pWWNList[lLstIdx].portId,
5304 int devIdx, szdv, devTotal, cmpsetRtn;
5305 int lDevIndex = 0, lRunScanFlag =
FALSE;
5316 AGTIAPI_PRINTK(
"agtiapi_GetDevHandle: pCard->devDiscover %d / tgtCt %d\n",
5318 AGTIAPI_FLOW(
"agtiapi_GetDevHandle: portalInfo %p\n", pPortalInfo );
5322 M_PMC_MDEV, M_ZERO | M_NOWAIT);
5325 AGTIAPI_PRINTK(
"agtiapi_GetDevHandle: failed to alloc agDev[]\n" );
5330 M_PMC_MFLG, M_ZERO | M_NOWAIT );
5331 if (lDevFlags ==
NULL)
5333 free((caddr_t)agDev, M_PMC_MDEV);
5334 AGTIAPI_PRINTK(
"agtiapi_GetDevHandle: failed to alloc lDevFlags[]\n" );
5350 AGTIAPI_PRINTK(
"agtiapi_GetDevHandle: portalInfo %p port id %d event %u "
5351 "status %u card %p pCard->devDiscover %d devTotal %d "
5352 "pPortalInfo->devTotal %d pPortalInfo->devPrev %d "
5353 "AGTIAPI_INIT_TIME %x\n",
5354 pPortalInfo, pPortalInfo->
portID, eType, eStatus,
pCard,
5360 pPortalInfo->
devPrev = devTotal;
5370 AGTIAPI_PRINTK(
"agtiapi_GetDevHandle: tiCOMGetPortInfo did not succeed. \n" );
5374 szdv =
sizeof( pPortalInfo->pDevList ) /
sizeof( pPortalInfo->pDevList[0] );
5384 if ( agDev[devIdx] !=
NULL )
5390 pDevice = &lTmpDevice;
5412 for ( lDevIndex = 0; lDevIndex < szdv; lDevIndex++ )
5424 memcmp( pWWNList[lDevIndex].targetName, pDevice->
targetName,
5426 memcmp( pSLRList[pWWNList[lDevIndex].sasLrIdx].localeName,
5429 memcmp( pSLRList[pWWNList[lDevIndex].sasLrIdx].remoteName,
5434 lDevIndex, devIdx, pPortalInfo->
portID );
5437 ( pPortalInfo->pDevList[lDevIndex] ==
5441 AGTIAPI_PRINTK(
"agtiapi_GetDevHandle: dev in use %d of %d/%d\n",
5442 lDevIndex, devTotal, pPortalInfo->
portID );
5445 lReadRm = atomic_readandclear_32( &pWWNList[lDevIndex].devRemoved );
5450 lDevIndex, pPortalInfo->
portID );
5461 AGTIAPI_PRINTK(
"agtiapi_GetDevHandle: goin fresh on %d of %d/%d\n",
5463 devTotal, pPortalInfo->
portID );
5466 lRunScanFlag =
TRUE;
5472 memcpy ( &
pCard->
pDevList[lDevIndex], pDevice,
sizeof(lTmpDevice) );
5479 free((caddr_t)lDevFlags, M_PMC_MFLG);
5480 free((caddr_t)agDev, M_PMC_MDEV);
5483 pPortalInfo->pDevList[lDevIndex] = &
pCard->
pDevList[lDevIndex];
5484 if ( 0 == lDevFlags[devIdx] )
5493 "status inspect %d %d %d\n",
5494 lDevFlags[devIdx], devIdx, lDevIndex );
5531 lRunScanFlag =
TRUE;
5534 if ( pSLRList[lNextDyad].localeNameLen < 0 &&
5535 pSLRList[lNextDyad].remoteNameLen < 0 )
5541 printf(
"agtiapi_GetDevHandle: failed to find available SAS LR\n" );
5543 free( (caddr_t)lDevFlags, M_PMC_MFLG );
5544 free( (caddr_t)agDev, M_PMC_MDEV );
5549 AGTIAPI_PRINTK(
"agtiapi_GetDevHandle: listIdx new target %d of %d/%d\n",
5550 lDevIndex, devTotal, pPortalInfo->
portID );
5551 if ( 0 > lDevIndex )
5553 printf(
"agtiapi_GetDevHandle: WARNING -- WWNList exhausted.\n" );
5573 pWWNList[lDevIndex].
sasLrIdx = lNextDyad;
5586 agDev[devIdx]->
osData = (
void*)pDevice;
5590 pPortalInfo->pDevList[lDevIndex] = (
void*)pDevice;
5600 pPortalInfo->pDevList[devIdx] !=
NULL ) )
5604 if (
FALSE == lRunScanFlag)
5607 AGTIAPI_PRINTK(
"agtiapi_GetDevHandle: targ dropped out %d of %d/%d\n",
5608 devIdx, devTotal, pPortalInfo->
portID );
5610 cmpsetRtn = atomic_cmpset_32( &pWWNList[devIdx].devRemoved, 0, 5 );
5611 if ( 0 == cmpsetRtn )
5613 AGTIAPI_PRINTK(
"agtiapi_GetDevHandle: target %d timer already set\n",
5628 free((caddr_t)lDevFlags, M_PMC_MFLG);
5629 free((caddr_t)agDev, M_PMC_MDEV);
5631 if (
TRUE == lRunScanFlag )
5654 bus = cam_sim_path(pmcsc->
sim);
5656 tid = CAM_TARGET_WILDCARD;
5657 lun = CAM_LUN_WILDCARD;
5660 ccb = xpt_alloc_ccb_nowait();
5666 if (xpt_create_path(&ccb->ccb_h.path,
agNULL, bus, tid,
5667 CAM_LUN_WILDCARD) != CAM_REQ_CMP)
5706 if (pccb ==
NULL || *phead ==
NULL)
5712 AG_LOCAL_LOCK(lock);
5722 pccb->pccbNext =
NULL;
5746 AG_LOCAL_UNLOCK(lock);
5756 for (i = 0; i < len; i++, name++)
5812#if ( defined AGTIAPI_TEST_DPL || defined AGTIAPI_TEST_EPL )
5816#ifdef AGTIAPI_TEST_DPL
5820 if(pccb->dplPtr && pccb->dplDma)
5821 pci_pool_free(
pCard->dpl_ctx_pool, pccb->dplPtr, pccb->dplDma);
5825#ifdef AGTIAPI_TEST_EPL
5829 if(pccb->epl_ptr && pccb->epl_dma_ptr)
5831 pCard->epl_ctx_pool,
5842 pccb = (
ccb_t*) ((
char*)
hdr + hdr_sz);
5847 free(
hdr, M_PMC_MCCB);
5874 AG_GLOBAL_ARG(
flags );
5879 if( next_tick == 0 )
5881 AG_SPIN_LOCK_IRQ( agtiapi_host_lock,
flags );
5893 AG_SPIN_UNLOCK_IRQ( agtiapi_host_lock,
flags );
5928 lReadRm = atomic_readandclear_32( &
pWWNList[lIdx].devRemoved );
5936 pPortalInfo->pDevList[lIdx] =
NULL;
5937 AGTIAPI_PRINTK(
"agtiapi_clrRmScan: cleared dev %d at port %d\n",
5961 int lIdx, cmpsetRtn, lRunScanFlag =
FALSE;
6007 lReadRm = atomic_load_acq_32( &
pWWNList[lIdx].devRemoved );
6012 lRunScanFlag =
TRUE;
6017 AGTIAPI_PRINTK(
"agtiapi_devRmCheck: counting down dev %d @ %d; %d\n",
6018 lIdx, lReadRm, lReadCt );
6019 cmpsetRtn = atomic_cmpset_32( &
pWWNList[lIdx].devRemoved,
6022 if ( 0 == cmpsetRtn )
6024 printf(
"agtiapi_devRmCheck: %d decrement already handled\n",
6032 if (
TRUE == lRunScanFlag )
6075 AGTIAPI_PRINTK(
"agtiapi_ResetCard: reset card already in progress!\n" );
6082 agtiapi_LogEvent(
pCard,
6087 "Reset initiator time = %d!",
6098 for ( lIdx = 1; 3 >= lIdx; lIdx++ )
6111 AG_SPIN_UNLOCK_IRQ( agtiapi_host_lock, *
flags );
6113 AG_SPIN_LOCK_IRQ( agtiapi_host_lock, *
flags );
6117 AGTIAPI_PRINTK(
"agtiapi_ResetCard: CheckCB indicates failed reset call, "
6129 AGTIAPI_PRINTK(
"agtiapi_ResetCard: soft reset failed after try %d\n",
6134 AGTIAPI_PRINTK(
"agtiapi_ResetCard: soft reset success at try %d\n",
6140 printf(
"agtiapi_ResetCard: reset ERROR\n" );
6149 for( lIdx = 0; lIdx <
maxTargets; lIdx++, pDevice++ )
6155 pDevice->
flags &= ~ACTIVE;
6158 AG_SPIN_UNLOCK_IRQ( agtiapi_host_lock, *
flags );
6160 printf(
"agtiapi_ResetCard: tiCOMPortInit FAILED \n" );
6170 AGTIAPI_PRINTK(
"agtiapi_ResetCard: pre target-count %d port-count %d\n",
6181 AG_SPIN_LOCK_IRQ( agtiapi_host_lock,
flags );
6190 sizeof( pPortalInfo->pDevList ) /
sizeof( pPortalInfo->pDevList[0] );
6196 for( lIdx = 0, loop = 0;
6197 lIdx < szdv && loop < pPortalInfo->
devTotal;
6200 pDevice = (
ag_device_t*)pPortalInfo->pDevList[lIdx];
6207 AGTIAPI_PRINTK(
"agtiapi_ResetCard: reset pDev %p pDevList %p idx %d\n",
6208 pDevice, pPortalInfo->pDevList, lIdx );
6214 pPortalInfo->pDevList[lIdx] =
NULL;
6231 printf(
"agtiapi_ResetCard: tiCOMPortStart %d FAILED\n",
6236 AGTIAPI_PRINTK(
"agtiapi_ResetCard: tiCOMPortStart %d success\n",
6241 AG_SPIN_UNLOCK_IRQ( agtiapi_host_lock,
flags );
6250 AG_SPIN_LOCK_IRQ(agtiapi_host_lock, *
flags);
6254 printf(
"agtiapi_ResetCard: error, driver not intstalled? "
6255 "!AGTIAPI_INSTALLED \n" );
6262 agtiapi_LogEvent(
pCard,
6267 "Reset initiator total device = %d!",
6272 AGTIAPI_PRINTK(
"agtiapi_ResetCard: clear send and done queues\n" );
6274 AG_LOCAL_LOCK( &
pCard->sendLock );
6277 AG_LOCAL_UNLOCK( &
pCard->sendLock );
6279 AG_LOCAL_LOCK( &
pCard->doneLock );
6282 AG_LOCAL_UNLOCK( &
pCard->doneLock );
6285 AG_LOCAL_LOCK( &
pCard->sendSMPLock );
6288 AG_LOCAL_UNLOCK( &
pCard->sendSMPLock );
6290 AG_LOCAL_LOCK( &
pCard->doneSMPLock );
6293 AG_LOCAL_UNLOCK( &
pCard->doneSMPLock );
6322 int thisCard = device_get_unit( dev );
6325 struct ccb_setasync csa;
6327 pCard = device_get_softc( dev );
6331 AG_GLOBAL_ARG(
flags);
6337 AGTIAPI_PRINTK(
"agtiapi_ReleaseHBA: Wrong ag_card_info_t thisCardInst %p "
6341 panic(
"agtiapi_ReleaseHBA: Wrong ag_card_info_t thisCardInst %p pCardInfo "
6356 AG_SPIN_LOCK_IRQ( agtiapi_host_lock,
flags );
6360 AG_SPIN_UNLOCK_IRQ( agtiapi_host_lock,
flags );
6364#ifdef HIALEAH_ENCRYPTION
6400 bus_release_resource( dev,
6406 pci_release_msi(dev);
6414 tasklet_kill(&
pCard->tasklet_dpc[i]);
6442#ifdef HIALEAH_ENCRYPTION
6462#ifdef LINUX_PERBI_SUPPORT
6472 AGTIAPI_PRINTK(
"agtiapi_ReleaseHBA: SAS Local Remote list released\n");
6484 AGTIAPI_PRINTK(
"agtiapi_ReleaseHBA: low level resource released\n");
6486#ifdef HOTPLUG_SUPPORT
6490 AGTIAPI_PRINTK(
"agtiapi_ReleaseHBA: (HP dev) work resources released\n");
6503#ifdef AGTIAPI_LOCAL_LOCK
6510 for( i = 0; i < maxLocks; i++ )
6512 mtx_destroy(&
pCard->STLock[i]);
6514 free(
pCard->STLock, M_PMC_MSTL);
6550 memset(&csa, 0,
sizeof(csa));
6551 xpt_setup_ccb(&csa.ccb_h,
pCard->
path, 5);
6552 csa.ccb_h.func_code = XPT_SASYNC_CB;
6553 csa.event_enable = 0;
6555 csa.callback_arg =
pCard;
6556 xpt_action((
union ccb *)&csa);
6567 xpt_bus_deregister(cam_sim_path(
pCard->
sim));
6569 mtx_unlock(&thisCardInst->
pmIOLock);
6577 mtx_destroy( &thisCardInst->
pmIOLock );
6578 mtx_destroy( &
pCard->sendLock );
6579 mtx_destroy( &
pCard->doneLock );
6580 mtx_destroy( &
pCard->sendSMPLock );
6581 mtx_destroy( &
pCard->doneSMPLock );
6582 mtx_destroy( &
pCard->ccbLock );
6586 mtx_destroy( &
pCard->memLock );
6587 mtx_destroy( &
pCard->freezeLock );
#define AGTIAPI_MAX_DEVICE
#define AGTIAPI_HW_LIMIT_DEVICE
#define AGTIAPI_GET_DEV_MAX
#define AGTIAPI_MAX_CHANNEL_NUM
#define AGTIAPI_MAX_DEVICE_8H
#define AGTIAPI_VOLUME_SET
#define AGTIAPI_CCB_PER_DEVICE
#define AGTIAPI_MAX_DMA_SEGS
#define AGTIAPI_PERIPHERAL
#define SCSI_TASK_ABORTED
#define SCSI_CHECK_CONDITION
#define AGTIAPI_MAX_DEVICE_7H
#define AGTIAPI_ADDRMODE_SHIFT
#define AGTIAPI_MAX_CAM_Q_DEPTH
#define AGTIAPI_EXTRA_DELAY
#define AG_IO_DUMPCCB(pccb)
STATIC U32 agtiapi_polling_mode
void agtiapi_IntrHandler2(void *arg)
STATIC void agtiapi_DumpCCB(ccb_t *pccb)
static void agtiapi_scan(struct agtiapi_softc *pmcsc)
STATIC void wwnprintk(unsigned char *name, int len)
void agtiapi_IntrHandler5(void *arg)
static driver_t pmspcv_driver
static d_write_t agtiapi_write
static int agtiapi_attach(device_t devx)
void agtiapi_IntrHandler8(void *arg)
STATIC void agtiapi_devRmCheck(void *data)
STATIC agBOOLEAN agtiapi_DeQueueCCB(struct agtiapi_softc *pCard, pccb_t *phead, pccb_t *ptail, ccb_t *pccb)
STATIC agBOOLEAN agtiapi_InitCardHW(struct agtiapi_softc *pmsc)
STATIC void agtiapi_ReleaseCCBs(struct agtiapi_softc *pCard)
int agtiapi_QueueCmnd_(struct agtiapi_softc *pmcsc, union ccb *ccb)
static int agtiapi_shutdown(device_t dev)
STATIC void agtiapi_FlushCCBs(struct agtiapi_softc *pCard, U32 flag)
int agtiapi_StartTM(struct agtiapi_softc *pCard, ccb_t *pccb)
static void agtiapi_PrepareSMPSGListCB(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
agBOOLEAN agtiapi_CheckCB(struct agtiapi_softc *pCard, U32 milisec, U32 flag, volatile U32 *pStatus)
#define AG_LIST_UNLOCK(lock)
void agtiapi_IntrHandler3(void *arg)
void agtiapi_IntrHandler15(void *arg)
static int agtiapi_resume(device_t dev)
static void agtiapi_cam_action(struct cam_sim *, union ccb *)
STATIC U32 agtiapi_CheckError(struct agtiapi_softc *pmcsc, ccb_t *pccb)
void agtiapi_IntrHandler1(void *arg)
void agtiapi_adjust_queue_depth(struct cam_path *path, bit32 QueueDepth)
int agtiapi_eh_HostReset(struct agtiapi_softc *pmcsc, union ccb *cmnd)
#define cache_line_size()
void agtiapi_IntrHandler7(void *arg)
MODULE_DEPEND(pmspcv, cam, 1, 1, 1)
STATIC U32 agtiapi_1st_time
void agtiapi_IntrHandler12(void *arg)
int agtiapi_DoSoftReset(struct agtiapi_softc *pmcsc)
void agtiapi_IntrHandlerx_(void *arg, int index)
STATIC void agtiapi_FreeTMCCB(struct agtiapi_softc *pmcsc, pccb_t pccb)
void agtiapi_IntrHandler11(void *arg)
#define CMND_TO_CHANNEL(ccb)
STATIC void agtiapi_TITimer(void *data)
STATIC void agtiapi_StartIO(struct agtiapi_softc *pmcsc)
STATIC void agtiapi_FreeCCB(struct agtiapi_softc *pmcsc, pccb_t pccb)
static d_ioctl_t agtiapi_CharIoctl
STATIC U32 agtiapi_CheckSMPError(struct agtiapi_softc *pmcsc, ccb_t *pccb)
void agtiapi_SetLunField(ccb_t *pccb)
#define AG_GET_DONE_PCCB(pccb, pmcsc)
static int agtiapi_PrepareSMPSGList(struct agtiapi_softc *pmcsc, ccb_t *pccb)
STATIC U32 ag_option_flag
STATIC void agtiapi_FreeSMPCCB(struct agtiapi_softc *pmcsc, pccb_t pccb)
STATIC U32 agtiapi_GetDevHandle(struct agtiapi_softc *pCard, ag_portal_info_t *pPortalInfo, U32 eType, U32 eStatus)
static int agtiapi_probe(device_t dev)
static int agtiapi_QueueSMP(struct agtiapi_softc *pmcsc, union ccb *ccb)
STATIC void agtiapi_QueueCCB(struct agtiapi_softc *pmcsc, pccb_t *phead, pccb_t *ptail, ccb_t *pccb)
static void agtiapi_MemoryCB(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
static void agtiapi_async(void *callback_arg, u_int32_t code, struct cam_path *path, void *arg)
U32 agtiapi_ResetCard(struct agtiapi_softc *pCard, unsigned long *flags)
STATIC pccb_t agtiapi_GetCCB(struct agtiapi_softc *pmcsc)
STATIC U32 agtiapi_intx_mode
int agtiapi_alloc_requests(struct agtiapi_softc *pmcsc)
STATIC U32 ag_timeout_secs
STATIC U08 agtiapi_AddrModes[AGTIAPI_MAX_CHANNEL_NUM+1]
STATIC void agtiapi_PrepCCBs(struct agtiapi_softc *pCard, ccb_hdr_t *hdr, U32 size, U32 max_ccb, int tid)
STATIC void agtiapi_Retry(struct agtiapi_softc *pmcsc, ccb_t *pccb)
STATIC void agtiapi_CheckIOTimeout(void *data)
STATIC int agtiapi_FindWWNListNext(ag_tgt_map_t *pWWNList, int lstMax)
static void agtiapi_SglMemoryCB(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
#define CPU_TO_LE32(dst, src)
static device_method_t agtiapi_methods[]
static d_open_t agtiapi_open
static int agtiapi_suspend(device_t dev)
void agtiapi_HandleEncryptedIOFailure(ag_device_t *pDev, ccb_t *pccb)
static d_read_t agtiapi_read
#define AG_LIST_LOCK(lock)
static int agtiapi_PrepareSGList(struct agtiapi_softc *pmcsc, ccb_t *pccb)
void agtiapi_IntrHandler4(void *arg)
static void agtiapi_cam_poll(struct cam_sim *)
STATIC void agtiapi_DumpCDB(const char *ptitle, ccb_t *pccb)
STATIC void agtiapi_DiscoverTgt(struct agtiapi_softc *pCard)
int agtiapi_alloc_ostimem(struct agtiapi_softc *pmcsc)
STATIC int wwncpy(ag_device_t *pDevice)
DRIVER_MODULE(pmspcv, pci, pmspcv_driver, pmspcv_devclass, 0, 0)
#define CMND_TO_TARGET( ccb)
void agtiapi_IntrHandler14(void *arg)
static void agtiapi_PrepareSGListCB(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
#define CMND_TO_LUN( ccb)
STATIC void agtiapi_SMPDone(struct agtiapi_softc *pmcsc, ccb_t *pccb)
void agtiapi_IntrHandler10(void *arg)
static devclass_t pmspcv_devclass
void agtiapi_IntrHandler13(void *arg)
STATIC void agtiapi_Done(struct agtiapi_softc *pmcsc, ccb_t *pccb)
STATIC void agtiapi_StartSMP(struct agtiapi_softc *pmcsc)
static struct cdevsw agtiapi_cdevsw
static ag_card_info_t agCardInfoList[AGTIAPI_MAX_CARDS]
static d_close_t agtiapi_close
int agtiapi_getCardInfo(struct agtiapi_softc *pCard, U32_64 size, void *buffer)
STATIC void agtiapi_clrRmScan(struct agtiapi_softc *pCard)
void agtiapi_CheckAllVectors(struct agtiapi_softc *pCard, bit32 context)
int agtiapi_ReleaseHBA(device_t dev)
void agtiapi_hexdump(const char *ptitle, bit8 *pbuf, int len)
atomic_t outstanding_encrypted_io_count
MALLOC_DEFINE(M_PMC_MCCB, "CCB List", "CCB List for PMCS driver")
void agtiapi_IntrHandler6(void *arg)
STATIC agBOOLEAN agtiapi_InitCardSW(struct agtiapi_softc *pmsc)
STATIC U32 agtiapi_InitCCBs(struct agtiapi_softc *pCard, int tgtCount, int tid)
void agtiapi_IntrHandler0(void *arg)
int agtiapi_getdevlist(struct agtiapi_softc *pCard, tiIOCTLPayload_t *agIOCTLPayload)
#define AG_GET_DONE_SMP_PCCB(pccb, pmcsc)
void agtiapi_IntrHandler9(void *arg)
struct _ag_device ag_device_t
struct _ag_slr_map ag_slr_map_t
#define AGSMP_INIT_XCHG_LEN
#define INDEX(_pCard, _T)
#define CMND_DMA_UNMAP(pCard, cmnd)
#define DPMC_LEANFLAG_NOAGDEVYT
#define DPMC_LEANFLAG_AGDEVUSED
struct _ag_tgt_map ag_tgt_map_t
#define DPMC_LEANFLAG_NOWWNLIST
#define AGSCSI_INIT_XCHG_LEN
#define DPMC_LEANFLAG_PDEVSUSED
#define AGTIAPI_LOCAL_LOCK
#define MIN(a, b)
MIN macro.
tiIOCTLPayloadHeader_t hdr
#define AGTIAPI_DISC_DONE
#define AGTIAPI_FLOW(format, a...)
#define IOCTL_MN_GET_CARD_INFO
#define AGTIAPI_SYS_INTR_ON
#define AGTIAPI_RESET_SUCCESS
#define AGTIAPI_INITIATOR
#define PORTAL_STATUS(pPortalData)
#define AGTIAPI_DISC_COMPLETE
#define AGTIAPI_IO(format, a...)
#define AGTIAPI_PORT_DISC_READY
#define AGTIAPI_PORT_PANIC
#define AGTIAPI_HAD_RESET
#define AGTIAPI_PORT_INITIALIZED
#define AGTIAPI_MAX_PORTALS
#define PCI_DEVICE_ID_HIALEAH_HBA_SPCVE
#define AGTIAPI_SCSI_REGISTERED
#define AGTIAPI_INIT_DELAY(delay_time)
#define AGTIAPI_INIT_TIME
#define AGTIAPI_INSTALLED
#define AGTIAPI_PRINTK(format, a...)
#define AGTIAPI_INIT(format, a...)
#define AGTIAPI_PORT_START
#define AGTIAPI_SHUT_DOWN
#define AGTIAPI_SOFT_RESET
#define AGTIAPI_IRQ_REQUESTED
#define AGTIAPI_DYNAMIC_MAX
#define MAX_MSIX_NUM_VECTOR
#define AGTIAPI_MAX_CARDS
#define AGTIAPI_PORT_LINK_UP
void agtiapi_CleanupEncryptedIO(struct agtiapi_softc *pCard, ccb_t *pccb)
struct agtiapi_softc * pCard
int agtiapi_SetupEncryptedIO(struct agtiapi_softc *pCard, ccb_t *pccb, unsigned long long block)
int agtiapi_SetupEncryption(struct agtiapi_softc *pCard)
osGLOBAL void ostiIOCTLWaitForSignal(tiRoot_t *ptiRoot, void *agParam1, void *agParam2, void *agParam3)
U32 ostiGetTransportParam(tiRoot_t *ptiRoot, S08 *key, S08 *subkey1, S08 *subkey2, S08 *subkey3, S08 *subkey4, S08 *subkey5, S08 *valueName, S08 *buffer, U32 bufferLen, U32 *lenReceived)
void agtiapi_ReleasePCIMem(ag_card_info_t *)
int agtiapi_ProbeCard(device_t, ag_card_info_t *, int)
void agtiapi_DelayMSec(U32)
int agtiapi_ScopeDMARes(ag_card_info_t *)
void agtiapi_MemFree(ag_card_info_t *)
agBOOLEAN agtiapi_InitResource(ag_card_info_t *)
#define osti_strncmp(s1, s2, n)
#define osti_strtoul(nptr, endptr, base)
#define osti_memset(s, c, n)
#define osti_memcpy(des, src, n)
#define AGSA_MAX_INBOUND_Q
#define DIF_VERIFY_FORWARD
#define DIF_VERIFY_DELETE
struct agtiapi_softc * pmcsc
tiSuperScsiInitiatorRequest_t tiSuperScsiRequest
tiDeviceHandle_t * devHandle
struct _CCB * pccbChainNext
tdIORequestBody_t tdIOReqBody
tiIORequest_t tiIORequest
ag_dma_addr_t * freeDynamicMem[AGTIAPI_DYNAMIC_MAX]
ag_resource_info_t tiRscInfo
ag_dma_addr_t dynamicMem[AGTIAPI_DYNAMIC_MAX]
ag_portal_info_t * pPortalInfo
tiDeviceHandle_t * pDevHandle
U08 targetName[AGTIAPI_MAX_NAME]
bus_addr_t nocache_busaddr
ag_portal_info_t portalInfo
tiPortalContext_t tiPortalContext
tiTdSharedMem_t tiSharedMem
tiInitiatorResource_t tiInitiatorResource
tiLoLevelResource_t tiLoLevelResource
ag_portal_data_t * pPortalData
struct callout devRmTimer
void * intrcookie[MAX_MSIX_NUM_VECTOR]
ag_card_info_t * pCardInfo
struct mtx devRmTimerLock
bus_dma_tag_t buffer_dmat
struct resource * irq[MAX_MSIX_NUM_VECTOR]
int rscID[MAX_MSIX_NUM_VECTOR]
data structure for SAS device list This structure maintains the device as a list and information abou...
tiDetailedDeviceInfo_t info
bit8 udtArray[DIF_UDT_SIZE]
bit32 EncryptionPerLAAddrLo
agBOOLEAN enableEncryptionPerLA
bit32 EncryptionPerLAAddrHi
bit8 FunctionSpecificArea[1]
bit32 max_MSI_InterruptVectors
tiLoLevelOption_t loLevelOption
tiDataDirection_t dataDirection
#define AG_ALIGNSIZE(count, alignment)
#define IOCTL_MJ_FATAL_ERROR_DUMP_COMPLETE
#define IOCTL_MJ_CHECK_FATAL_ERROR
#define IOCTL_MJ_CHECK_DPMC_EVENT
#define IOCTL_MJ_GET_DEVICE_LIST
osGLOBAL void tiCOMShutDown(tiRoot_t *tiRoot)
osGLOBAL bit32 tiINITaskManagement(tiRoot_t *tiRoot, tiDeviceHandle_t *tiDeviceHandle, bit32 task, tiLUN_t *lun, tiIORequest_t *taskTag, tiIORequest_t *currentTaskTag)
osGLOBAL bit32 tiCOMPortInit(tiRoot_t *tiRoot, bit32 sysIntsActive)
osGLOBAL bit32 tiCOMInit(tiRoot_t *tiRoot, tiLoLevelResource_t *loResource, tiInitiatorResource_t *initiatorResource, tiTargetResource_t *targetResource, tiTdSharedMem_t *tdSharedMem)
osGLOBAL FORCEINLINE bit32 tiCOMDelayedInterruptHandler(tiRoot_t *tiRoot, bit32 channelNum, bit32 count, bit32 context)
osGLOBAL void tiCOMTimerTick(tiRoot_t *tiRoot)
osGLOBAL void tiCOMReset(tiRoot_t *tiRoot, bit32 option)
osGLOBAL bit32 tiCOMPortStart(tiRoot_t *tiRoot, bit32 portID, tiPortalContext_t *portalContext, bit32 option)
osGLOBAL bit32 tiINIGetDeviceHandlesForWinIOCTL(tiRoot_t *tiRoot, tiPortalContext_t *portalContext, tiDeviceHandle_t *agDev[], bit32 maxDevs)
osGLOBAL bit32 tiINIIOAbort(tiRoot_t *tiRoot, tiIORequest_t *taskTag)
osGLOBAL bit32 tiINIGetExpander(tiRoot_t *tiRoot, tiPortalContext_t *tiPortalContext, tiDeviceHandle_t *tiDev, tiDeviceHandle_t **tiExp)
osGLOBAL void tiCOMGetResource(tiRoot_t *tiRoot, tiLoLevelResource_t *loResource, tiInitiatorResource_t *initiatorResource, tiTargetResource_t *targetResource, tiTdSharedMem_t *tdSharedMem)
osGLOBAL bit32 tiINIDiscoverTargets(tiRoot_t *tiRoot, tiPortalContext_t *portalContext, bit32 option)
osGLOBAL bit32 tiINISuperIOStart(tiRoot_t *tiRoot, tiIORequest_t *tiIORequest, tiDeviceHandle_t *tiDeviceHandle, tiSuperScsiInitiatorRequest_t *tiScsiRequest, void *tiRequestBody, bit32 interruptContext)
osGLOBAL bit32 tiCOMGetPortInfo(tiRoot_t *tiRoot, tiPortalContext_t *portalContext, tiPortInfo_t *tiPortInfo)
osGLOBAL bit32 tiCOMMgntIOCTL(tiRoot_t *tiRoot, tiIOCTLPayload_t *agIOCTLPayload, void *agParam1, void *agParam2, void *agParam3)
osGLOBAL bit32 tiINIGetDeviceHandles(tiRoot_t *tiRoot, tiPortalContext_t *portalContext, tiDeviceHandle_t *agDev[], bit32 maxDevs)
osGLOBAL bit32 tiINIGetDeviceInfo(tiRoot_t *tiRoot, tiDeviceHandle_t *tiDeviceHandle, tiDeviceInfo_t *tiDeviceInfo)
osGLOBAL bit32 tiINISMPStart(tiRoot_t *tiRoot, tiIORequest_t *tiIORequest, tiDeviceHandle_t *tiDeviceHandle, tiSMPFrame_t *tiScsiRequest, void *tiSMPBody, bit32 interruptContext)
osGLOBAL void tiIniGetDirectSataSasAddr(tiRoot_t *tiRoot, bit32 phyId, bit8 **sasAddressHi, bit8 **sasAddressLo)
osGLOBAL FORCEINLINE bit32 tiCOMInterruptHandler(tiRoot_t *tiRoot, bit32 channelNum)
osGLOBAL void tiCOMSystemInterruptsActive(tiRoot_t *tiRoot, bit32 sysIntsActive)
#define IOCTL_MJ_FATAL_ERR_CHK_SEND_FALSE
@ tiDetailDifAppTagMismatch
@ tiDetailDekKeyCacheMiss
@ tiDetailDifRefTagMismatch
#define IOCTL_CALL_PENDING
#define FORCE_PERSISTENT_ASSIGN_MASK
#define DISCOVERY_IN_PROGRESS
#define IOCTL_CALL_INVALID_CODE
#define TI_SCSI_INITIATOR_DIF
#define TASK_HEAD_OF_QUEUE
#define IOCTL_ERR_STATUS_OK
#define IOCTL_MJ_FATAL_ERROR_SOFT_RESET_TRIG
#define IOCTL_ERR_STATUS_INTERNAL_ERROR
#define IOCTL_CALL_SUCCESS
#define IOCTL_EVT_SEV_INFORMATIONAL
#define IOCTL_MJ_FATAL_ERR_CHK_SEND_TRUE
#define IOCTL_EVT_SEV_ERROR
#define DIF_BLOCK_SIZE_520
#define DIF_UDT_REF_BLOCK_COUNT
#define DIF_CRC_VERIFICATION
#define DIF_BLOCK_SIZE_4096
#define DIF_BLOCK_SIZE_4160