svn commit: r244921 - in stable/9: share/man/man4 sys/dev/arcmsr

Xin LI delphij at FreeBSD.org
Tue Jan 1 07:02:34 UTC 2013


Author: delphij
Date: Tue Jan  1 07:02:33 2013
New Revision: 244921
URL: http://svnweb.freebsd.org/changeset/base/244921

Log:
  MFC r244406:
  
  Update arcmsr(4) to vendor version 1.20.00.26, this adds
  support for their new RAID adapter ARC-1214.
  
  Many thanks to Areca for continuing to support FreeBSD.
  
  Submitted by: 黃清隆 Ching-Lung Huang <ching2048 areca com tw>

Modified:
  stable/9/share/man/man4/arcmsr.4
  stable/9/sys/dev/arcmsr/arcmsr.c
  stable/9/sys/dev/arcmsr/arcmsr.h
Directory Properties:
  stable/9/share/man/man4/   (props changed)
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/share/man/man4/arcmsr.4
==============================================================================
--- stable/9/share/man/man4/arcmsr.4	Tue Jan  1 07:00:42 2013	(r244920)
+++ stable/9/share/man/man4/arcmsr.4	Tue Jan  1 07:02:33 2013	(r244921)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd September 3, 2012
+.Dd December 18, 2012
 .Dt ARCMSR 4
 .Os
 .Sh NAME
@@ -100,6 +100,8 @@ ARC-1212
 .It
 ARC-1213
 .It
+ARC-1214
+.It
 ARC-1220
 .It
 ARC-1222

Modified: stable/9/sys/dev/arcmsr/arcmsr.c
==============================================================================
--- stable/9/sys/dev/arcmsr/arcmsr.c	Tue Jan  1 07:00:42 2013	(r244920)
+++ stable/9/sys/dev/arcmsr/arcmsr.c	Tue Jan  1 07:02:33 2013	(r244921)
@@ -10,8 +10,7 @@
 ******************************************************************************************
 ************************************************************************
 **
-** Copyright (c) 2004-2010 ARECA Co. Ltd.
-**        Erich Chen, Taipei Taiwan All rights reserved.
+** Copyright (C) 2002 - 2010, Areca Technology Corporation All rights reserved.
 **
 ** Redistribution and use in source and binary forms, with or without
 ** modification, are permitted provided that the following conditions
@@ -74,6 +73,7 @@
 **     1.20.00.23   01/30/2012      Ching Huang          Fixed Request requeued and Retrying command
 **     1.20.00.24   06/11/2012      Ching Huang          Fixed return sense data condition
 **     1.20.00.25   08/17/2012      Ching Huang          Fixed hotplug device no function on type A adapter
+**     1.20.00.26   12/14/2012      Ching Huang          Added support ARC1214
 ******************************************************************************************
 */
 
@@ -129,24 +129,10 @@ __FBSDID("$FreeBSD$");
     #include <sys/endian.h>
     #include <dev/pci/pcivar.h>
     #include <dev/pci/pcireg.h>
-    #define ARCMSR_LOCK_INIT(l, s)	mtx_init(l, s, NULL, MTX_DEF)
-    #define ARCMSR_LOCK_DESTROY(l)	mtx_destroy(l)
-    #define ARCMSR_LOCK_ACQUIRE(l)	mtx_lock(l)
-    #define ARCMSR_LOCK_RELEASE(l)	mtx_unlock(l)
-    #define ARCMSR_LOCK_TRY(l)		mtx_trylock(l)
-    #define arcmsr_htole32(x)		htole32(x)
-    typedef struct mtx				arcmsr_lock_t;
 #else
     #include <sys/select.h>
     #include <pci/pcivar.h>
     #include <pci/pcireg.h>
-    #define ARCMSR_LOCK_INIT(l, s)	simple_lock_init(l)
-    #define ARCMSR_LOCK_DESTROY(l)
-    #define ARCMSR_LOCK_ACQUIRE(l)	simple_lock(l)
-    #define ARCMSR_LOCK_RELEASE(l)	simple_unlock(l)
-    #define ARCMSR_LOCK_TRY(l)		simple_lock_try(l)
-    #define arcmsr_htole32(x)		(x)
-    typedef struct simplelock		arcmsr_lock_t;
 #endif
 
 #if !defined(CAM_NEW_TRAN_CODE) && __FreeBSD_version >= 700025
@@ -159,23 +145,15 @@ __FBSDID("$FreeBSD$");
 #define arcmsr_callout_init(a)	callout_init(a);
 #endif
 
-#define ARCMSR_DRIVER_VERSION			"Driver Version 1.20.00.25 2012-08-17"
+#define ARCMSR_DRIVER_VERSION	"Driver Version 1.20.00.26 2012-12-14"
 #include <dev/arcmsr/arcmsr.h>
-#define	SRB_SIZE						((sizeof(struct CommandControlBlock)+0x1f) & 0xffe0)
-#define ARCMSR_SRBS_POOL_SIZE           (SRB_SIZE * ARCMSR_MAX_FREESRB_NUM)
-/*
-**************************************************************************
-**************************************************************************
-*/
-#define CHIP_REG_READ32(s, b, r)		bus_space_read_4(acb->btag[b], acb->bhandle[b], offsetof(struct s, r))
-#define CHIP_REG_WRITE32(s, b, r, d)	bus_space_write_4(acb->btag[b], acb->bhandle[b], offsetof(struct s, r), d)
 /*
 **************************************************************************
 **************************************************************************
 */
 static void arcmsr_free_srb(struct CommandControlBlock *srb);
-static struct CommandControlBlock * arcmsr_get_freesrb(struct AdapterControlBlock *acb);
-static u_int8_t arcmsr_seek_cmd2abort(union ccb * abortccb);
+static struct CommandControlBlock *arcmsr_get_freesrb(struct AdapterControlBlock *acb);
+static u_int8_t arcmsr_seek_cmd2abort(union ccb *abortccb);
 static int arcmsr_probe(device_t dev);
 static int arcmsr_attach(device_t dev);
 static int arcmsr_detach(device_t dev);
@@ -190,18 +168,20 @@ static void arcmsr_stop_adapter_bgrb(str
 static void arcmsr_start_adapter_bgrb(struct AdapterControlBlock *acb);
 static void arcmsr_iop_init(struct AdapterControlBlock *acb);
 static void arcmsr_flush_adapter_cache(struct AdapterControlBlock *acb);
-static void arcmsr_post_ioctldata2iop(struct AdapterControlBlock *acb);
+static void	arcmsr_Read_iop_rqbuffer_data(struct AdapterControlBlock *acb, struct QBUFFER *prbuffer);
+static void arcmsr_Write_data_2iop_wqbuffer(struct AdapterControlBlock *acb);
 static void arcmsr_abort_allcmd(struct AdapterControlBlock *acb);
 static void arcmsr_srb_complete(struct CommandControlBlock *srb, int stand_flag);
 static void arcmsr_iop_reset(struct AdapterControlBlock *acb);
 static void arcmsr_report_sense_info(struct CommandControlBlock *srb);
-static void arcmsr_build_srb(struct CommandControlBlock *srb, bus_dma_segment_t * dm_segs, u_int32_t nseg);
-static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, union ccb * pccb);
+static void arcmsr_build_srb(struct CommandControlBlock *srb, bus_dma_segment_t *dm_segs, u_int32_t nseg);
+static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, union ccb *pccb);
 static int arcmsr_resume(device_t dev);
 static int arcmsr_suspend(device_t dev);
 static void arcmsr_rescanLun_cb(struct cam_periph *periph, union ccb *ccb);
-static void	arcmsr_polling_devmap(void* arg);
-static void	arcmsr_srb_timeout(void* arg);
+static void	arcmsr_polling_devmap(void *arg);
+static void	arcmsr_srb_timeout(void *arg);
+static void arcmsr_hbd_postqueue_isr(struct AdapterControlBlock *acb);
 #ifdef ARCMSR_DEBUG1
 static void arcmsr_dump_data(struct AdapterControlBlock *acb);
 #endif
@@ -293,12 +273,12 @@ static struct cdevsw arcmsr_cdevsw = {
 #endif
 {
 	#if __FreeBSD_version < 503000
-		struct AdapterControlBlock *acb=dev->si_drv1;
+		struct AdapterControlBlock *acb = dev->si_drv1;
 	#else
 		int	unit = dev2unit(dev);
 		struct AdapterControlBlock *acb = devclass_get_softc(arcmsr_devclass, unit);
 	#endif
-	if(acb==NULL) {
+	if(acb == NULL) {
 		return ENXIO;
 	}
 	return (0);
@@ -318,12 +298,12 @@ static struct cdevsw arcmsr_cdevsw = {
 #endif
 {
 	#if __FreeBSD_version < 503000
-		struct AdapterControlBlock *acb=dev->si_drv1;
+		struct AdapterControlBlock *acb = dev->si_drv1;
 	#else
 		int	unit = dev2unit(dev);
 		struct AdapterControlBlock *acb = devclass_get_softc(arcmsr_devclass, unit);
 	#endif
-	if(acb==NULL) {
+	if(acb == NULL) {
 		return ENXIO;
 	}
 	return 0;
@@ -343,13 +323,13 @@ static struct cdevsw arcmsr_cdevsw = {
 #endif
 {
 	#if __FreeBSD_version < 503000
-		struct AdapterControlBlock *acb=dev->si_drv1;
+		struct AdapterControlBlock *acb = dev->si_drv1;
 	#else
 		int	unit = dev2unit(dev);
 		struct AdapterControlBlock *acb = devclass_get_softc(arcmsr_devclass, unit);
 	#endif
 	
-	if(acb==NULL) {
+	if(acb == NULL) {
 		return ENXIO;
 	}
 	return (arcmsr_iop_ioctlcmd(acb, ioctl_cmd, arg));
@@ -360,28 +340,34 @@ static struct cdevsw arcmsr_cdevsw = {
 */
 static u_int32_t arcmsr_disable_allintr( struct AdapterControlBlock *acb)
 {
-	u_int32_t intmask_org=0;
+	u_int32_t intmask_org = 0;
 	
 	switch (acb->adapter_type) {
 	case ACB_ADAPTER_TYPE_A: {
 			/* disable all outbound interrupt */
-			intmask_org=CHIP_REG_READ32(HBA_MessageUnit, 0, outbound_intmask); /* disable outbound message0 int */
+			intmask_org = CHIP_REG_READ32(HBA_MessageUnit, 0, outbound_intmask); /* disable outbound message0 int */
 			CHIP_REG_WRITE32(HBA_MessageUnit, 0, outbound_intmask, intmask_org|ARCMSR_MU_OUTBOUND_ALL_INTMASKENABLE);
 		}
 		break;
 	case ACB_ADAPTER_TYPE_B: {
 			/* disable all outbound interrupt */
-			intmask_org=CHIP_REG_READ32(HBB_DOORBELL, 
+			intmask_org = CHIP_REG_READ32(HBB_DOORBELL, 
 						0, iop2drv_doorbell_mask) & (~ARCMSR_IOP2DRV_MESSAGE_CMD_DONE); /* disable outbound message0 int */
 			CHIP_REG_WRITE32(HBB_DOORBELL, 0, iop2drv_doorbell_mask, 0); /* disable all interrupt */
 		}
 		break;
 	case ACB_ADAPTER_TYPE_C: {
 			/* disable all outbound interrupt */
-			intmask_org=CHIP_REG_READ32(HBC_MessageUnit, 0, host_int_mask)	; /* disable outbound message0 int */
+			intmask_org = CHIP_REG_READ32(HBC_MessageUnit, 0, host_int_mask)	; /* disable outbound message0 int */
 			CHIP_REG_WRITE32(HBC_MessageUnit, 0, host_int_mask, intmask_org|ARCMSR_HBCMU_ALL_INTMASKENABLE);
 		}
 		break;
+	case ACB_ADAPTER_TYPE_D: {
+			/* disable all outbound interrupt */
+			intmask_org = CHIP_REG_READ32(HBD_MessageUnit, 0, pcief0_int_enable)	; /* disable outbound message0 int */
+			CHIP_REG_WRITE32(HBD_MessageUnit, 0, pcief0_int_enable, ARCMSR_HBDMU_ALL_INT_DISABLE);
+		}
+		break;
 	}
 	return (intmask_org);
 }
@@ -396,23 +382,31 @@ static void arcmsr_enable_allintr( struc
 	switch (acb->adapter_type) {
 	case ACB_ADAPTER_TYPE_A: {
 			/* enable outbound Post Queue, outbound doorbell Interrupt */
-			mask=~(ARCMSR_MU_OUTBOUND_POSTQUEUE_INTMASKENABLE|ARCMSR_MU_OUTBOUND_DOORBELL_INTMASKENABLE|ARCMSR_MU_OUTBOUND_MESSAGE0_INTMASKENABLE);
+			mask = ~(ARCMSR_MU_OUTBOUND_POSTQUEUE_INTMASKENABLE|ARCMSR_MU_OUTBOUND_DOORBELL_INTMASKENABLE|ARCMSR_MU_OUTBOUND_MESSAGE0_INTMASKENABLE);
 			CHIP_REG_WRITE32(HBA_MessageUnit, 0, outbound_intmask, intmask_org & mask);
 			acb->outbound_int_enable = ~(intmask_org & mask) & 0x000000ff;
 		}
 		break;
 	case ACB_ADAPTER_TYPE_B: {
 			/* enable ARCMSR_IOP2DRV_MESSAGE_CMD_DONE */
-			mask=(ARCMSR_IOP2DRV_DATA_WRITE_OK|ARCMSR_IOP2DRV_DATA_READ_OK|ARCMSR_IOP2DRV_CDB_DONE|ARCMSR_IOP2DRV_MESSAGE_CMD_DONE);
+			mask = (ARCMSR_IOP2DRV_DATA_WRITE_OK|ARCMSR_IOP2DRV_DATA_READ_OK|ARCMSR_IOP2DRV_CDB_DONE|ARCMSR_IOP2DRV_MESSAGE_CMD_DONE);
 			CHIP_REG_WRITE32(HBB_DOORBELL, 0, iop2drv_doorbell_mask, intmask_org | mask); /*1=interrupt enable, 0=interrupt disable*/
 			acb->outbound_int_enable = (intmask_org | mask) & 0x0000000f;
 		}
 		break;
 	case ACB_ADAPTER_TYPE_C: {
 			/* enable outbound Post Queue, outbound doorbell Interrupt */
-			mask=~(ARCMSR_HBCMU_UTILITY_A_ISR_MASK | ARCMSR_HBCMU_OUTBOUND_DOORBELL_ISR_MASK | ARCMSR_HBCMU_OUTBOUND_POSTQUEUE_ISR_MASK);
+			mask = ~(ARCMSR_HBCMU_UTILITY_A_ISR_MASK | ARCMSR_HBCMU_OUTBOUND_DOORBELL_ISR_MASK | ARCMSR_HBCMU_OUTBOUND_POSTQUEUE_ISR_MASK);
 			CHIP_REG_WRITE32(HBC_MessageUnit, 0, host_int_mask, intmask_org & mask);
-			acb->outbound_int_enable= ~(intmask_org & mask) & 0x0000000f;
+			acb->outbound_int_enable = ~(intmask_org & mask) & 0x0000000f;
+		}
+		break;
+	case ACB_ADAPTER_TYPE_D: {
+			/* enable outbound Post Queue, outbound doorbell Interrupt */
+			mask = ARCMSR_HBDMU_ALL_INT_ENABLE;
+			CHIP_REG_WRITE32(HBD_MessageUnit, 0, pcief0_int_enable, intmask_org | mask);
+			CHIP_REG_READ32(HBD_MessageUnit, 0, pcief0_int_enable);
+			acb->outbound_int_enable = mask;
 		}
 		break;
 	}
@@ -424,7 +418,7 @@ static void arcmsr_enable_allintr( struc
 static u_int8_t arcmsr_hba_wait_msgint_ready(struct AdapterControlBlock *acb)
 {
 	u_int32_t Index;
-	u_int8_t Retries=0x00;
+	u_int8_t Retries = 0x00;
 	
 	do {
 		for(Index=0; Index < 100; Index++) {
@@ -444,7 +438,7 @@ static u_int8_t arcmsr_hba_wait_msgint_r
 static u_int8_t arcmsr_hbb_wait_msgint_ready(struct AdapterControlBlock *acb)
 {
 	u_int32_t Index;
-	u_int8_t Retries=0x00;
+	u_int8_t Retries = 0x00;
 	
 	do {
 		for(Index=0; Index < 100; Index++) {
@@ -465,7 +459,7 @@ static u_int8_t arcmsr_hbb_wait_msgint_r
 static u_int8_t arcmsr_hbc_wait_msgint_ready(struct AdapterControlBlock *acb)
 {
 	u_int32_t Index;
-	u_int8_t Retries=0x00;
+	u_int8_t Retries = 0x00;
 	
 	do {
 		for(Index=0; Index < 100; Index++) {
@@ -479,12 +473,32 @@ static u_int8_t arcmsr_hbc_wait_msgint_r
 	return (FALSE);
 }
 /*
+**********************************************************************
+**********************************************************************
+*/
+static u_int8_t arcmsr_hbd_wait_msgint_ready(struct AdapterControlBlock *acb)
+{
+	u_int32_t Index;
+	u_int8_t Retries = 0x00;
+	
+	do {
+		for(Index=0; Index < 100; Index++) {
+			if(CHIP_REG_READ32(HBD_MessageUnit, 0, outbound_doorbell) & ARCMSR_HBDMU_IOP2DRV_MESSAGE_CMD_DONE) {
+				CHIP_REG_WRITE32(HBD_MessageUnit, 0, outbound_doorbell, ARCMSR_HBDMU_IOP2DRV_MESSAGE_CMD_DONE_CLEAR);/*clear interrupt*/
+				return TRUE;
+			}
+			UDELAY(10000);
+		}/*max 1 seconds*/
+	}while(Retries++ < 20);/*max 20 sec*/
+	return (FALSE);
+}
+/*
 ************************************************************************
 ************************************************************************
 */
 static void arcmsr_flush_hba_cache(struct AdapterControlBlock *acb)
 {
-	int retry_count=30;/* enlarge wait flush adapter cache time: 10 minute */
+	int retry_count = 30;/* enlarge wait flush adapter cache time: 10 minute */
 	
 	CHIP_REG_WRITE32(HBA_MessageUnit, 0, inbound_msgaddr0, ARCMSR_INBOUND_MESG0_FLUSH_CACHE);
 	do {
@@ -493,7 +507,7 @@ static void arcmsr_flush_hba_cache(struc
 		} else {
 			retry_count--;
 		}
-	}while(retry_count!=0);
+	}while(retry_count != 0);
 }
 /*
 ************************************************************************
@@ -501,7 +515,7 @@ static void arcmsr_flush_hba_cache(struc
 */
 static void arcmsr_flush_hbb_cache(struct AdapterControlBlock *acb)
 {
-	int retry_count=30;/* enlarge wait flush adapter cache time: 10 minute */
+	int retry_count = 30;/* enlarge wait flush adapter cache time: 10 minute */
 	
 	CHIP_REG_WRITE32(HBB_DOORBELL, 
 	0, drv2iop_doorbell, ARCMSR_MESSAGE_FLUSH_CACHE);
@@ -511,7 +525,7 @@ static void arcmsr_flush_hbb_cache(struc
 		} else {
 			retry_count--;
 		}
-	}while(retry_count!=0);
+	}while(retry_count != 0);
 }
 /*
 ************************************************************************
@@ -519,7 +533,7 @@ static void arcmsr_flush_hbb_cache(struc
 */
 static void arcmsr_flush_hbc_cache(struct AdapterControlBlock *acb)
 {
-	int retry_count=30;/* enlarge wait flush adapter cache time: 10 minute */
+	int retry_count = 30;/* enlarge wait flush adapter cache time: 10 minute */
 	
 	CHIP_REG_WRITE32(HBC_MessageUnit, 0, inbound_msgaddr0, ARCMSR_INBOUND_MESG0_FLUSH_CACHE);
 	CHIP_REG_WRITE32(HBC_MessageUnit, 0, inbound_doorbell, ARCMSR_HBCMU_DRV2IOP_MESSAGE_CMD_DONE);
@@ -529,7 +543,24 @@ static void arcmsr_flush_hbc_cache(struc
 		} else {
 			retry_count--;
 		}
-	}while(retry_count!=0);
+	}while(retry_count != 0);
+}
+/*
+************************************************************************
+************************************************************************
+*/
+static void arcmsr_flush_hbd_cache(struct AdapterControlBlock *acb)
+{
+	int retry_count = 30; /* enlarge wait flush adapter cache time: 10 minute */
+	
+	CHIP_REG_WRITE32(HBD_MessageUnit, 0, inbound_msgaddr0, ARCMSR_INBOUND_MESG0_FLUSH_CACHE);
+	do {
+		if(arcmsr_hbd_wait_msgint_ready(acb)) {
+			break;
+		} else {
+			retry_count--;
+		}
+	}while(retry_count != 0);
 }
 /*
 ************************************************************************
@@ -550,6 +581,10 @@ static void arcmsr_flush_adapter_cache(s
 			arcmsr_flush_hbc_cache(acb);
 		}
 		break;
+	case ACB_ADAPTER_TYPE_D: {
+			arcmsr_flush_hbd_cache(acb);
+		}
+		break;
 	}
 }
 /*
@@ -585,14 +620,14 @@ static void arcmsr_async(void *cb_arg, u
 {
 	struct AdapterControlBlock *acb;
 	u_int8_t target_id, target_lun;
-	struct cam_sim * sim;
+	struct cam_sim *sim;
 	
-	sim=(struct cam_sim *) cb_arg;
+	sim = (struct cam_sim *) cb_arg;
 	acb =(struct AdapterControlBlock *) cam_sim_softc(sim);
 	switch (code) {
 	case AC_LOST_DEVICE:
-		target_id=xpt_path_target_id(path);
-		target_lun=xpt_path_lun_id(path);
+		target_id = xpt_path_target_id(path);
+		target_lun = xpt_path_lun_id(path);
 		if((target_id > ARCMSR_MAX_TARGETID) || (target_lun > ARCMSR_MAX_TARGETLUN)) {
 			break;
 		}
@@ -608,7 +643,7 @@ static void arcmsr_async(void *cb_arg, u
 */
 static void arcmsr_report_sense_info(struct CommandControlBlock *srb)
 {
-	union ccb * pccb=srb->pccb;
+	union ccb *pccb = srb->pccb;
 	
 	pccb->ccb_h.status |= CAM_SCSI_STATUS_ERROR;
 	pccb->csio.scsi_status = SCSI_STATUS_CHECK_COND;
@@ -658,6 +693,17 @@ static void arcmsr_abort_hbc_allcmd(stru
 *********************************************************************
 *********************************************************************
 */
+static void arcmsr_abort_hbd_allcmd(struct AdapterControlBlock *acb)
+{
+	CHIP_REG_WRITE32(HBD_MessageUnit, 0, inbound_msgaddr0, ARCMSR_INBOUND_MESG0_ABORT_CMD);
+	if(!arcmsr_hbd_wait_msgint_ready(acb)) {
+		printf("arcmsr%d: wait 'abort all outstanding command' timeout \n", acb->pci_unit);
+	}
+}
+/*
+*********************************************************************
+*********************************************************************
+*/
 static void arcmsr_abort_allcmd(struct AdapterControlBlock *acb)
 {
 	switch (acb->adapter_type) {
@@ -673,6 +719,10 @@ static void arcmsr_abort_allcmd(struct A
 			arcmsr_abort_hbc_allcmd(acb);
 		}
 		break;
+	case ACB_ADAPTER_TYPE_D: {
+			arcmsr_abort_hbd_allcmd(acb);
+		}
+		break;
 	}
 }
 /*
@@ -681,8 +731,8 @@ static void arcmsr_abort_allcmd(struct A
 */
 static void arcmsr_srb_complete(struct CommandControlBlock *srb, int stand_flag)
 {
-	struct AdapterControlBlock *acb=srb->acb;
-	union ccb * pccb=srb->pccb;
+	struct AdapterControlBlock *acb = srb->acb;
+	union ccb *pccb = srb->pccb;
 	
 	if(srb->srb_flags & SRB_FLAG_TIMER_START)
 		callout_stop(&srb->ccb_callout);
@@ -697,19 +747,17 @@ static void arcmsr_srb_complete(struct C
 		bus_dmamap_sync(acb->dm_segs_dmat, srb->dm_segs_dmamap, op);
 		bus_dmamap_unload(acb->dm_segs_dmat, srb->dm_segs_dmamap);
 	}
-	if(stand_flag==1) {
+	if(stand_flag == 1) {
 		atomic_subtract_int(&acb->srboutstandingcount, 1);
 		if((acb->acb_flags & ACB_F_CAM_DEV_QFRZN) && (
-		acb->srboutstandingcount < ARCMSR_RELEASE_SIMQ_LEVEL)) {
+		acb->srboutstandingcount < (acb->firm_numbers_queue -10))) {
 			acb->acb_flags &= ~ACB_F_CAM_DEV_QFRZN;
 			pccb->ccb_h.status |= CAM_RELEASE_SIMQ;
 		}
 	}
 	if(srb->srb_state != ARCMSR_SRB_TIMEOUT)
 		arcmsr_free_srb(srb);
-#ifdef ARCMSR_DEBUG1
 	acb->pktReturnCount++;
-#endif
 	xpt_done(pccb);
 }
 /*
@@ -720,34 +768,34 @@ static void arcmsr_report_srb_state(stru
 {
 	int target, lun;
 	
-	target=srb->pccb->ccb_h.target_id;
-	lun=srb->pccb->ccb_h.target_lun;
+	target = srb->pccb->ccb_h.target_id;
+	lun = srb->pccb->ccb_h.target_lun;
 	if(error == FALSE) {
-		if(acb->devstate[target][lun]==ARECA_RAID_GONE) {
-			acb->devstate[target][lun]=ARECA_RAID_GOOD;
+		if(acb->devstate[target][lun] == ARECA_RAID_GONE) {
+			acb->devstate[target][lun] = ARECA_RAID_GOOD;
 		}
 		srb->pccb->ccb_h.status |= CAM_REQ_CMP;
 		arcmsr_srb_complete(srb, 1);
 	} else {
 		switch(srb->arcmsr_cdb.DeviceStatus) {
 		case ARCMSR_DEV_SELECT_TIMEOUT: {
-				if(acb->devstate[target][lun]==ARECA_RAID_GOOD) {
+				if(acb->devstate[target][lun] == ARECA_RAID_GOOD) {
 					printf( "arcmsr%d: Target=%x, Lun=%x, selection timeout, raid volume was lost\n", acb->pci_unit, target, lun);
 				}
-				acb->devstate[target][lun]=ARECA_RAID_GONE;
+				acb->devstate[target][lun] = ARECA_RAID_GONE;
 				srb->pccb->ccb_h.status |= CAM_DEV_NOT_THERE;
 				arcmsr_srb_complete(srb, 1);
 			}
 			break;
 		case ARCMSR_DEV_ABORTED:
 		case ARCMSR_DEV_INIT_FAIL: {
-				acb->devstate[target][lun]=ARECA_RAID_GONE;
+				acb->devstate[target][lun] = ARECA_RAID_GONE;
 				srb->pccb->ccb_h.status |= CAM_DEV_NOT_THERE;
 				arcmsr_srb_complete(srb, 1);
 			}
 			break;
 		case SCSISTAT_CHECK_CONDITION: {
-				acb->devstate[target][lun]=ARECA_RAID_GOOD;
+				acb->devstate[target][lun] = ARECA_RAID_GOOD;
 				arcmsr_report_sense_info(srb);
 				arcmsr_srb_complete(srb, 1);
 			}
@@ -755,7 +803,7 @@ static void arcmsr_report_srb_state(stru
 		default:
 			printf("arcmsr%d: scsi id=%d lun=%d isr got command error done,but got unknow DeviceStatus=0x%x \n"
 					, acb->pci_unit, target, lun ,srb->arcmsr_cdb.DeviceStatus);
-			acb->devstate[target][lun]=ARECA_RAID_GONE;
+			acb->devstate[target][lun] = ARECA_RAID_GONE;
 			srb->pccb->ccb_h.status |= CAM_UNCOR_PARITY;
 			/*unknow error or crc error just for retry*/
 			arcmsr_srb_complete(srb, 1);
@@ -774,7 +822,8 @@ static void arcmsr_drain_donequeue(struc
 	/* check if command done with no error*/
 	switch (acb->adapter_type) {
 	case ACB_ADAPTER_TYPE_C:
-		srb = (struct CommandControlBlock *)(acb->vir2phy_offset+(flag_srb & 0xFFFFFFE0));/*frame must be 32 bytes aligned*/
+	case ACB_ADAPTER_TYPE_D:
+		srb = (struct CommandControlBlock *)(acb->vir2phy_offset+(flag_srb & 0xFFFFFFE0)); /*frame must be 32 bytes aligned*/
 		break;
 	case ACB_ADAPTER_TYPE_A:
 	case ACB_ADAPTER_TYPE_B:
@@ -782,7 +831,7 @@ static void arcmsr_drain_donequeue(struc
 		srb = (struct CommandControlBlock *)(acb->vir2phy_offset+(flag_srb << 5));/*frame must be 32 bytes aligned*/
 		break;
 	}
-	if((srb->acb!=acb) || (srb->srb_state!=ARCMSR_SRB_START)) {
+	if((srb->acb != acb) || (srb->srb_state != ARCMSR_SRB_START)) {
 		if(srb->srb_state == ARCMSR_SRB_TIMEOUT) {
 			arcmsr_free_srb(srb);
 			printf("arcmsr%d: srb='%p' return srb has been timeouted\n", acb->pci_unit, srb);
@@ -799,17 +848,17 @@ static void arcmsr_drain_donequeue(struc
 **************************************************************************
 **************************************************************************
 */
-static void	arcmsr_srb_timeout(void* arg)
+static void	arcmsr_srb_timeout(void *arg)
 {
 	struct CommandControlBlock *srb = (struct CommandControlBlock *)arg;
 	struct AdapterControlBlock *acb;
 	int target, lun;
 	u_int8_t cmd;
 	
-	target=srb->pccb->ccb_h.target_id;
-	lun=srb->pccb->ccb_h.target_lun;
+	target = srb->pccb->ccb_h.target_id;
+	lun = srb->pccb->ccb_h.target_lun;
 	acb = srb->acb;
-	ARCMSR_LOCK_ACQUIRE(&acb->qbuffer_lock);
+	ARCMSR_LOCK_ACQUIRE(&acb->isr_lock);
 	if(srb->srb_state == ARCMSR_SRB_START)
 	{
 		cmd = srb->pccb->csio.cdb_io.cdb_bytes[0];
@@ -819,7 +868,7 @@ static void	arcmsr_srb_timeout(void* arg
 		printf("arcmsr%d: scsi id %d lun %d cmd=0x%x srb='%p' ccb command time out!\n",
 				 acb->pci_unit, target, lun, cmd, srb);
 	}
-	ARCMSR_LOCK_RELEASE(&acb->qbuffer_lock);
+	ARCMSR_LOCK_RELEASE(&acb->isr_lock);
 #ifdef ARCMSR_DEBUG1
     	arcmsr_dump_data(acb);
 #endif
@@ -840,10 +889,10 @@ static void arcmsr_done4abort_postqueue(
 			u_int32_t outbound_intstatus;
 	
 			/*clear and abort all outbound posted Q*/
-			outbound_intstatus=CHIP_REG_READ32(HBA_MessageUnit, 0, outbound_intstatus) & acb->outbound_int_enable;
+			outbound_intstatus = CHIP_REG_READ32(HBA_MessageUnit, 0, outbound_intstatus) & acb->outbound_int_enable;
 			CHIP_REG_WRITE32(HBA_MessageUnit, 0, outbound_intstatus, outbound_intstatus);/*clear interrupt*/
 			while(((flag_srb=CHIP_REG_READ32(HBA_MessageUnit, 0, outbound_queueport)) != 0xFFFFFFFF) && (i++ < ARCMSR_MAX_OUTSTANDING_CMD)) {
-                error=(flag_srb & ARCMSR_SRBREPLY_FLAG_ERROR_MODE0)?TRUE:FALSE;
+                error = (flag_srb & ARCMSR_SRBREPLY_FLAG_ERROR_MODE0)?TRUE:FALSE;
 				arcmsr_drain_donequeue(acb, flag_srb, error);
 			}
 		}
@@ -854,26 +903,30 @@ static void arcmsr_done4abort_postqueue(
 			/*clear all outbound posted Q*/
 			CHIP_REG_WRITE32(HBB_DOORBELL, 0, iop2drv_doorbell, ARCMSR_DOORBELL_INT_CLEAR_PATTERN); /* clear doorbell interrupt */
 			for(i=0; i < ARCMSR_MAX_HBB_POSTQUEUE; i++) {
-				if((flag_srb=phbbmu->done_qbuffer[i])!=0) {
-					phbbmu->done_qbuffer[i]=0;
-                	error=(flag_srb & ARCMSR_SRBREPLY_FLAG_ERROR_MODE0)?TRUE:FALSE;
+				if((flag_srb = phbbmu->done_qbuffer[i]) != 0) {
+					phbbmu->done_qbuffer[i] = 0;
+                	error = (flag_srb & ARCMSR_SRBREPLY_FLAG_ERROR_MODE0)?TRUE:FALSE;
 					arcmsr_drain_donequeue(acb, flag_srb, error);
 				}
-				phbbmu->post_qbuffer[i]=0;
+				phbbmu->post_qbuffer[i] = 0;
 			}/*drain reply FIFO*/
-			phbbmu->doneq_index=0;
-			phbbmu->postq_index=0;
+			phbbmu->doneq_index = 0;
+			phbbmu->postq_index = 0;
 		}
 		break;
 	case ACB_ADAPTER_TYPE_C: {
 	
 			while((CHIP_REG_READ32(HBC_MessageUnit, 0, host_int_status) & ARCMSR_HBCMU_OUTBOUND_POSTQUEUE_ISR) && (i++ < ARCMSR_MAX_OUTSTANDING_CMD)) {
-				flag_srb=CHIP_REG_READ32(HBC_MessageUnit, 0, outbound_queueport_low);
-                error=(flag_srb & ARCMSR_SRBREPLY_FLAG_ERROR_MODE1)?TRUE:FALSE;
+				flag_srb = CHIP_REG_READ32(HBC_MessageUnit, 0, outbound_queueport_low);
+                error = (flag_srb & ARCMSR_SRBREPLY_FLAG_ERROR_MODE1) ? TRUE : FALSE;
 				arcmsr_drain_donequeue(acb, flag_srb, error);
 			}
 		}
 		break;
+	case ACB_ADAPTER_TYPE_D: {
+			arcmsr_hbd_postqueue_isr(acb);
+		}
+		break;
 	}
 }
 /*
@@ -888,15 +941,15 @@ static void arcmsr_iop_reset(struct Adap
 	
 	if(acb->srboutstandingcount>0) {
 		/* disable all outbound interrupt */
-		intmask_org=arcmsr_disable_allintr(acb);
+		intmask_org = arcmsr_disable_allintr(acb);
 		/*clear and abort all outbound posted Q*/
 		arcmsr_done4abort_postqueue(acb);
 		/* talk to iop 331 outstanding command aborted*/
 		arcmsr_abort_allcmd(acb);
-		for(i=0;i<ARCMSR_MAX_FREESRB_NUM;i++) {
-			srb=acb->psrb_pool[i];
-			if(srb->srb_state==ARCMSR_SRB_START) {
-				srb->srb_state=ARCMSR_SRB_ABORTED;
+		for(i=0; i < ARCMSR_MAX_FREESRB_NUM; i++) {
+			srb = acb->psrb_pool[i];
+			if(srb->srb_state == ARCMSR_SRB_START) {
+				srb->srb_state = ARCMSR_SRB_ABORTED;
 				srb->pccb->ccb_h.status |= CAM_REQ_ABORTED;
 				arcmsr_srb_complete(srb, 1);
 				printf("arcmsr%d: scsi id=%d lun=%d srb='%p' aborted\n"
@@ -907,13 +960,11 @@ static void arcmsr_iop_reset(struct Adap
 		/* enable all outbound interrupt */
 		arcmsr_enable_allintr(acb, intmask_org);
 	}
-	acb->srboutstandingcount=0;
-	acb->workingsrb_doneindex=0;
-	acb->workingsrb_startindex=0;
-#ifdef ARCMSR_DEBUG1
+	acb->srboutstandingcount = 0;
+	acb->workingsrb_doneindex = 0;
+	acb->workingsrb_startindex = 0;
 	acb->pktRequestCount = 0;
 	acb->pktReturnCount = 0;
-#endif
 }
 /*
 **********************************************************************
@@ -922,67 +973,66 @@ static void arcmsr_iop_reset(struct Adap
 static void arcmsr_build_srb(struct CommandControlBlock *srb, 
 		bus_dma_segment_t *dm_segs, u_int32_t nseg)
 {
-	struct ARCMSR_CDB * arcmsr_cdb= &srb->arcmsr_cdb;
-	u_int8_t * psge=(u_int8_t *)&arcmsr_cdb->u;
+	struct ARCMSR_CDB *arcmsr_cdb = &srb->arcmsr_cdb;
+	u_int8_t *psge = (u_int8_t *)&arcmsr_cdb->u;
 	u_int32_t address_lo, address_hi;
-	union ccb * pccb=srb->pccb;
-	struct ccb_scsiio * pcsio= &pccb->csio;
-	u_int32_t arccdbsize=0x30;
+	union ccb *pccb = srb->pccb;
+	struct ccb_scsiio *pcsio = &pccb->csio;
+	u_int32_t arccdbsize = 0x30;
 	
 	memset(arcmsr_cdb, 0, sizeof(struct ARCMSR_CDB));
-	arcmsr_cdb->Bus=0;
-	arcmsr_cdb->TargetID=pccb->ccb_h.target_id;
-	arcmsr_cdb->LUN=pccb->ccb_h.target_lun;
-	arcmsr_cdb->Function=1;
-	arcmsr_cdb->CdbLength=(u_int8_t)pcsio->cdb_len;
-	arcmsr_cdb->Context=0;
+	arcmsr_cdb->Bus = 0;
+	arcmsr_cdb->TargetID = pccb->ccb_h.target_id;
+	arcmsr_cdb->LUN = pccb->ccb_h.target_lun;
+	arcmsr_cdb->Function = 1;
+	arcmsr_cdb->CdbLength = (u_int8_t)pcsio->cdb_len;
 	bcopy(pcsio->cdb_io.cdb_bytes, arcmsr_cdb->Cdb, pcsio->cdb_len);
 	if(nseg != 0) {
-		struct AdapterControlBlock *acb=srb->acb;
+		struct AdapterControlBlock *acb = srb->acb;
 		bus_dmasync_op_t op;	
-		u_int32_t length, i, cdb_sgcount=0;
+		u_int32_t length, i, cdb_sgcount = 0;
 	
 		if((pccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
-			op=BUS_DMASYNC_PREREAD;
+			op = BUS_DMASYNC_PREREAD;
 		} else {
-			op=BUS_DMASYNC_PREWRITE;
-			arcmsr_cdb->Flags|=ARCMSR_CDB_FLAG_WRITE;
-			srb->srb_flags|=SRB_FLAG_WRITE;
+			op = BUS_DMASYNC_PREWRITE;
+			arcmsr_cdb->Flags |= ARCMSR_CDB_FLAG_WRITE;
+			srb->srb_flags |= SRB_FLAG_WRITE;
 		}
 		bus_dmamap_sync(acb->dm_segs_dmat, srb->dm_segs_dmamap, op);
-		for(i=0;i<nseg;i++) {
+		for(i=0; i < nseg; i++) {
 			/* Get the physical address of the current data pointer */
-			length=arcmsr_htole32(dm_segs[i].ds_len);
-			address_lo=arcmsr_htole32(dma_addr_lo32(dm_segs[i].ds_addr));
-			address_hi=arcmsr_htole32(dma_addr_hi32(dm_segs[i].ds_addr));
-			if(address_hi==0) {
-				struct SG32ENTRY * pdma_sg=(struct SG32ENTRY *)psge;
-				pdma_sg->address=address_lo;
-				pdma_sg->length=length;
+			length = arcmsr_htole32(dm_segs[i].ds_len);
+			address_lo = arcmsr_htole32(dma_addr_lo32(dm_segs[i].ds_addr));
+			address_hi = arcmsr_htole32(dma_addr_hi32(dm_segs[i].ds_addr));
+			if(address_hi == 0) {
+				struct SG32ENTRY *pdma_sg = (struct SG32ENTRY *)psge;
+				pdma_sg->address = address_lo;
+				pdma_sg->length = length;
 				psge += sizeof(struct SG32ENTRY);
 				arccdbsize += sizeof(struct SG32ENTRY);
 			} else {
-				u_int32_t sg64s_size=0, tmplength=length;
+				u_int32_t sg64s_size = 0, tmplength = length;
 	
 				while(1) {
 					u_int64_t span4G, length0;
-					struct SG64ENTRY * pdma_sg=(struct SG64ENTRY *)psge;
+					struct SG64ENTRY *pdma_sg = (struct SG64ENTRY *)psge;
 	
-					span4G=(u_int64_t)address_lo + tmplength;
-					pdma_sg->addresshigh=address_hi;
-					pdma_sg->address=address_lo;
+					span4G = (u_int64_t)address_lo + tmplength;
+					pdma_sg->addresshigh = address_hi;
+					pdma_sg->address = address_lo;
 					if(span4G > 0x100000000) {
 						/*see if cross 4G boundary*/
-						length0=0x100000000-address_lo;
-						pdma_sg->length=(u_int32_t)length0|IS_SG64_ADDR;
-						address_hi=address_hi+1;
-						address_lo=0;
-						tmplength=tmplength-(u_int32_t)length0;
+						length0 = 0x100000000-address_lo;
+						pdma_sg->length = (u_int32_t)length0 | IS_SG64_ADDR;
+						address_hi = address_hi+1;
+						address_lo = 0;
+						tmplength = tmplength - (u_int32_t)length0;
 						sg64s_size += sizeof(struct SG64ENTRY);
 						psge += sizeof(struct SG64ENTRY);
 						cdb_sgcount++;
 					} else {
-						pdma_sg->length=tmplength|IS_SG64_ADDR;
+						pdma_sg->length = tmplength | IS_SG64_ADDR;
 						sg64s_size += sizeof(struct SG64ENTRY);
 						psge += sizeof(struct SG64ENTRY);
 						break;
@@ -992,15 +1042,16 @@ static void arcmsr_build_srb(struct Comm
 			}
 			cdb_sgcount++;
 		}
-		arcmsr_cdb->sgcount=(u_int8_t)cdb_sgcount;
-		arcmsr_cdb->DataLength=pcsio->dxfer_len;
+		arcmsr_cdb->sgcount = (u_int8_t)cdb_sgcount;
+		arcmsr_cdb->DataLength = pcsio->dxfer_len;
 		if( arccdbsize > 256) {
-			arcmsr_cdb->Flags|=ARCMSR_CDB_FLAG_SGL_BSIZE;
+			arcmsr_cdb->Flags |= ARCMSR_CDB_FLAG_SGL_BSIZE;
 		}
 	} else {
 		arcmsr_cdb->DataLength = 0;
 	}
-    srb->arc_cdb_size=arccdbsize;
+    srb->arc_cdb_size = arccdbsize;
+    arcmsr_cdb->msgPages = (arccdbsize/256) + ((arccdbsize % 256) ? 1 : 0);
 }
 /*
 **************************************************************************
@@ -1008,46 +1059,45 @@ static void arcmsr_build_srb(struct Comm
 */ 
 static void arcmsr_post_srb(struct AdapterControlBlock *acb, struct CommandControlBlock *srb)
 {
-	u_int32_t cdb_shifted_phyaddr=(u_int32_t) srb->cdb_shifted_phyaddr;
-	struct ARCMSR_CDB * arcmsr_cdb=(struct ARCMSR_CDB *)&srb->arcmsr_cdb;
+	u_int32_t cdb_phyaddr_low = (u_int32_t) srb->cdb_phyaddr_low;
+	struct ARCMSR_CDB *arcmsr_cdb = (struct ARCMSR_CDB *)&srb->arcmsr_cdb;
 	
 	bus_dmamap_sync(acb->srb_dmat, acb->srb_dmamap, (srb->srb_flags & SRB_FLAG_WRITE) ? BUS_DMASYNC_POSTWRITE:BUS_DMASYNC_POSTREAD);
 	atomic_add_int(&acb->srboutstandingcount, 1);
-	srb->srb_state=ARCMSR_SRB_START;
+	srb->srb_state = ARCMSR_SRB_START;
 
 	switch (acb->adapter_type) {
 	case ACB_ADAPTER_TYPE_A: {
 			if(arcmsr_cdb->Flags & ARCMSR_CDB_FLAG_SGL_BSIZE) {
-				CHIP_REG_WRITE32(HBA_MessageUnit, 0, inbound_queueport, cdb_shifted_phyaddr|ARCMSR_SRBPOST_FLAG_SGL_BSIZE);
+				CHIP_REG_WRITE32(HBA_MessageUnit, 0, inbound_queueport, cdb_phyaddr_low|ARCMSR_SRBPOST_FLAG_SGL_BSIZE);
 			} else {
-				CHIP_REG_WRITE32(HBA_MessageUnit, 0, inbound_queueport, cdb_shifted_phyaddr);
+				CHIP_REG_WRITE32(HBA_MessageUnit, 0, inbound_queueport, cdb_phyaddr_low);
 			}
 		}
 		break;
 	case ACB_ADAPTER_TYPE_B: {
-			struct HBB_MessageUnit *phbbmu=(struct HBB_MessageUnit *)acb->pmu;
+			struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu;
 			int ending_index, index;
 	
-			index=phbbmu->postq_index;
-			ending_index=((index+1)%ARCMSR_MAX_HBB_POSTQUEUE);
-			phbbmu->post_qbuffer[ending_index]=0;
+			index = phbbmu->postq_index;
+			ending_index = ((index+1) % ARCMSR_MAX_HBB_POSTQUEUE);
+			phbbmu->post_qbuffer[ending_index] = 0;
 			if(arcmsr_cdb->Flags & ARCMSR_CDB_FLAG_SGL_BSIZE) {
-				phbbmu->post_qbuffer[index]= cdb_shifted_phyaddr|ARCMSR_SRBPOST_FLAG_SGL_BSIZE;
+				phbbmu->post_qbuffer[index] = cdb_phyaddr_low | ARCMSR_SRBPOST_FLAG_SGL_BSIZE;
 			} else {
-				phbbmu->post_qbuffer[index]= cdb_shifted_phyaddr;
+				phbbmu->post_qbuffer[index] = cdb_phyaddr_low;
 			}
 			index++;
 			index %= ARCMSR_MAX_HBB_POSTQUEUE;     /*if last index number set it to 0 */
-			phbbmu->postq_index=index;
+			phbbmu->postq_index = index;
 			CHIP_REG_WRITE32(HBB_DOORBELL, 0, drv2iop_doorbell, ARCMSR_DRV2IOP_CDB_POSTED);
 		}
 		break;
-    case ACB_ADAPTER_TYPE_C:
-        {
+    case ACB_ADAPTER_TYPE_C: {
             u_int32_t ccb_post_stamp, arc_cdb_size, cdb_phyaddr_hi32;
 
-            arc_cdb_size=(srb->arc_cdb_size>0x300)?0x300:srb->arc_cdb_size;
-            ccb_post_stamp=(cdb_shifted_phyaddr | ((arc_cdb_size-1) >> 6) | 1);
+            arc_cdb_size = (srb->arc_cdb_size > 0x300) ? 0x300 : srb->arc_cdb_size;
+            ccb_post_stamp = (cdb_phyaddr_low | ((arc_cdb_size-1) >> 6) | 1);
 			cdb_phyaddr_hi32 = acb->srb_phyaddr.B.phyadd_high;
             if(cdb_phyaddr_hi32)
             {
@@ -1060,33 +1110,67 @@ static void arcmsr_post_srb(struct Adapt
             }
         }
         break;
+	case ACB_ADAPTER_TYPE_D: {
+			struct HBD_MessageUnit0 *phbdmu = (struct HBD_MessageUnit0 *)acb->pmu;
+			u_int16_t index_stripped;
+			u_int16_t postq_index;
+			struct InBound_SRB *pinbound_srb;
+
+			ARCMSR_LOCK_ACQUIRE(&acb->postDone_lock);
+			postq_index = phbdmu->postq_index;
+			pinbound_srb = (struct InBound_SRB *)&phbdmu->post_qbuffer[postq_index & 0xFF];
+			pinbound_srb->addressHigh = srb->cdb_phyaddr_high;
+			pinbound_srb->addressLow = srb->cdb_phyaddr_low;
+			pinbound_srb->length = srb->arc_cdb_size >> 2;
+			arcmsr_cdb->Context = srb->cdb_phyaddr_low;
+			if (postq_index & 0x4000) {
+				index_stripped = postq_index & 0xFF;
+				index_stripped += 1;
+				index_stripped %= ARCMSR_MAX_HBD_POSTQUEUE;
+				phbdmu->postq_index = index_stripped ? (index_stripped | 0x4000) : index_stripped;
+			} else {
+				index_stripped = postq_index;
+				index_stripped += 1;
+				index_stripped %= ARCMSR_MAX_HBD_POSTQUEUE;
+				phbdmu->postq_index = index_stripped ? index_stripped : (index_stripped | 0x4000);
+			}
+			CHIP_REG_WRITE32(HBD_MessageUnit, 0, inboundlist_write_pointer, postq_index);
+			ARCMSR_LOCK_RELEASE(&acb->postDone_lock);
+		}
+		break;
 	}
 }
 /*
 ************************************************************************
 ************************************************************************
 */
-static struct QBUFFER * arcmsr_get_iop_rqbuffer( struct AdapterControlBlock *acb)
+static struct QBUFFER *arcmsr_get_iop_rqbuffer( struct AdapterControlBlock *acb)
 {
 	struct QBUFFER *qbuffer=NULL;
 	
 	switch (acb->adapter_type) {
 	case ACB_ADAPTER_TYPE_A: {
-			struct HBA_MessageUnit *phbamu=(struct HBA_MessageUnit *)acb->pmu;
+			struct HBA_MessageUnit *phbamu = (struct HBA_MessageUnit *)acb->pmu;
 	
-			qbuffer=(struct QBUFFER *)&phbamu->message_rbuffer;
+			qbuffer = (struct QBUFFER *)&phbamu->message_rbuffer;
 		}
 		break;
 	case ACB_ADAPTER_TYPE_B: {
-			struct HBB_MessageUnit *phbbmu=(struct HBB_MessageUnit *)acb->pmu;
+			struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu;
 	
-			qbuffer=(struct QBUFFER *)&phbbmu->hbb_rwbuffer->message_rbuffer;
+			qbuffer = (struct QBUFFER *)&phbbmu->hbb_rwbuffer->message_rbuffer;
 		}
 		break;
 	case ACB_ADAPTER_TYPE_C: {
-			struct HBC_MessageUnit *phbcmu=(struct HBC_MessageUnit *)acb->pmu;
+			struct HBC_MessageUnit *phbcmu = (struct HBC_MessageUnit *)acb->pmu;
 	
-			qbuffer=(struct QBUFFER *)&phbcmu->message_rbuffer;
+			qbuffer = (struct QBUFFER *)&phbcmu->message_rbuffer;
+		}
+		break;
+	case ACB_ADAPTER_TYPE_D: {
+			struct HBD_MessageUnit0 *phbdmu = (struct HBD_MessageUnit0 *)acb->pmu;
+	
+			qbuffer = (struct QBUFFER *)&phbdmu->phbdmu->message_rbuffer;
 		}
 		break;
 	}
@@ -1096,27 +1180,33 @@ static struct QBUFFER * arcmsr_get_iop_r
 ************************************************************************
 ************************************************************************
 */
-static struct QBUFFER * arcmsr_get_iop_wqbuffer( struct AdapterControlBlock *acb)
+static struct QBUFFER *arcmsr_get_iop_wqbuffer( struct AdapterControlBlock *acb)
 {
-	struct QBUFFER *qbuffer=NULL;
+	struct QBUFFER *qbuffer = NULL;
 	
 	switch (acb->adapter_type) {
 	case ACB_ADAPTER_TYPE_A: {
-			struct HBA_MessageUnit *phbamu=(struct HBA_MessageUnit *)acb->pmu;
+			struct HBA_MessageUnit *phbamu = (struct HBA_MessageUnit *)acb->pmu;
 	
-			qbuffer=(struct QBUFFER *)&phbamu->message_wbuffer;
+			qbuffer = (struct QBUFFER *)&phbamu->message_wbuffer;
 		}
 		break;
 	case ACB_ADAPTER_TYPE_B: {
-			struct HBB_MessageUnit *phbbmu=(struct HBB_MessageUnit *)acb->pmu;
+			struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu;
 	
-			qbuffer=(struct QBUFFER *)&phbbmu->hbb_rwbuffer->message_wbuffer;
+			qbuffer = (struct QBUFFER *)&phbbmu->hbb_rwbuffer->message_wbuffer;
 		}
 		break;
 	case ACB_ADAPTER_TYPE_C: {
-			struct HBC_MessageUnit *phbcmu=(struct HBC_MessageUnit *)acb->pmu;
+			struct HBC_MessageUnit *phbcmu = (struct HBC_MessageUnit *)acb->pmu;
 	
-			qbuffer=(struct QBUFFER *)&phbcmu->message_wbuffer;
+			qbuffer = (struct QBUFFER *)&phbcmu->message_wbuffer;
+		}
+		break;
+	case ACB_ADAPTER_TYPE_D: {
+			struct HBD_MessageUnit0 *phbdmu = (struct HBD_MessageUnit0 *)acb->pmu;
+	
+			qbuffer = (struct QBUFFER *)&phbdmu->phbdmu->message_wbuffer;
 		}
 		break;
 	}
@@ -1143,6 +1233,12 @@ static void arcmsr_iop_message_read(stru
 			/* let IOP know data has been read */
 			CHIP_REG_WRITE32(HBC_MessageUnit, 0, inbound_doorbell, ARCMSR_HBCMU_DRV2IOP_DATA_READ_OK);
 		}
+		break;
+	case ACB_ADAPTER_TYPE_D: {
+			/* let IOP know data has been read */
+			CHIP_REG_WRITE32(HBD_MessageUnit, 0, inbound_doorbell, ARCMSR_HBDMU_DRV2IOP_DATA_OUT_READ);
+		}
+		break;
 	}
 }
 /*
@@ -1176,37 +1272,14 @@ static void arcmsr_iop_message_wrote(str
 			CHIP_REG_WRITE32(HBC_MessageUnit, 0, inbound_doorbell, ARCMSR_HBCMU_DRV2IOP_DATA_WRITE_OK);
 		}
 		break;
-	}
-}
-/*
-**********************************************************************
-**********************************************************************
-*/
-static void arcmsr_post_ioctldata2iop(struct AdapterControlBlock *acb)
-{
-	u_int8_t *pQbuffer;
-	struct QBUFFER *pwbuffer;
-	u_int8_t * iop_data;
-	int32_t allxfer_len=0;
-	
-	pwbuffer=arcmsr_get_iop_wqbuffer(acb);
-	iop_data=(u_int8_t *)pwbuffer->data;
-	if(acb->acb_flags & ACB_F_MESSAGE_WQBUFFER_READ) {
-		acb->acb_flags &= (~ACB_F_MESSAGE_WQBUFFER_READ);
-		while((acb->wqbuf_firstindex!=acb->wqbuf_lastindex) 
-			&& (allxfer_len<124)) {
-			pQbuffer=&acb->wqbuffer[acb->wqbuf_firstindex];
-			memcpy(iop_data, pQbuffer, 1);
-			acb->wqbuf_firstindex++;
-			acb->wqbuf_firstindex %=ARCMSR_MAX_QBUFFER; /*if last index number set it to 0 */
-			iop_data++;
-			allxfer_len++;

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-stable-9 mailing list