Lines Matching +full:my +full:- +full:dma +full:- +full:window
12 ** SPDX-License-Identifier: BSD-3-Clause
14 ** Copyright (C) 2002 - 2012, Areca Technology Corporation All rights reserved.
52 ** with scsi pass-through command
78 ** 1.20.00.27 05/06/2013 Ching Huang Fixed out standing cmd full on ARC-12x4
84 ** 1.50.00.00 09/30/2020 Ching Huang Added support ARC-1886, NVMe/SAS/SATA controller
86 ** 1.50.00.02 04/16/2021 Ching Huang Fixed scsi command timeout on ARC-1886 when
87 ** scatter-gather count large than some number
88 ** 1.50.00.03 05/04/2021 Ching Huang Fixed doorbell status arrived late on ARC-1886
89 ** 1.50.00.04 12/08/2021 Ching Huang Fixed boot up hung under ARC-1886 with no volume created
148 #define ARCMSR_DRIVER_VERSION "arcmsr version 1.50.00.06 2023-08-07"
259 struct AdapterControlBlock *acb = dev->si_drv1; in arcmsr_ioctl()
271 switch (acb->adapter_type) { in arcmsr_disable_allintr()
279 struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_disable_allintr()
281 intmask_org = READ_CHIP_REG32(0, phbbmu->iop2drv_doorbell_mask) in arcmsr_disable_allintr()
283 WRITE_CHIP_REG32(0, phbbmu->iop2drv_doorbell_mask, 0); /* disable all interrupt */ in arcmsr_disable_allintr()
316 switch (acb->adapter_type) { in arcmsr_enable_allintr()
321 acb->outbound_int_enable = ~(intmask_org & mask) & 0x000000ff; in arcmsr_enable_allintr()
325 struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_enable_allintr()
328 …WRITE_CHIP_REG32(0, phbbmu->iop2drv_doorbell_mask, intmask_org | mask); /*1=interrupt enable, 0=in… in arcmsr_enable_allintr()
329 acb->outbound_int_enable = (intmask_org | mask) & 0x0000000f; in arcmsr_enable_allintr()
336 acb->outbound_int_enable = ~(intmask_org & mask) & 0x0000000f; in arcmsr_enable_allintr()
344 acb->outbound_int_enable = mask; in arcmsr_enable_allintr()
352 acb->outbound_int_enable = ~(intmask_org & mask) & 0x0000000f; in arcmsr_enable_allintr()
385 struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_hbb_wait_msgint_ready()
389 if(READ_CHIP_REG32(0, phbbmu->iop2drv_doorbell) & ARCMSR_IOP2DRV_MESSAGE_CMD_DONE) { in arcmsr_hbb_wait_msgint_ready()
390 …WRITE_CHIP_REG32(0, phbbmu->iop2drv_doorbell, ARCMSR_MESSAGE_INT_CLEAR_PATTERN);/*clear interrupt*/ in arcmsr_hbb_wait_msgint_ready()
391 WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_DRV2IOP_END_OF_INTERRUPT); in arcmsr_hbb_wait_msgint_ready()
451 if((read_doorbell ^ acb->in_doorbell) & ARCMSR_HBEMU_IOP2DRV_MESSAGE_CMD_DONE) { in arcmsr_hbe_wait_msgint_ready()
453 acb->in_doorbell = read_doorbell; in arcmsr_hbe_wait_msgint_ready()
474 retry_count--; in arcmsr_flush_hba_cache()
485 struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_flush_hbb_cache()
487 WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_MESSAGE_FLUSH_CACHE); in arcmsr_flush_hbb_cache()
492 retry_count--; in arcmsr_flush_hbb_cache()
510 retry_count--; in arcmsr_flush_hbc_cache()
527 retry_count--; in arcmsr_flush_hbd_cache()
540 acb->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_MESSAGE_CMD_DONE; in arcmsr_flush_hbe_cache()
541 CHIP_REG_WRITE32(HBE_MessageUnit, 0, iobound_doorbell, acb->out_doorbell); in arcmsr_flush_hbe_cache()
546 retry_count--; in arcmsr_flush_hbe_cache()
556 switch (acb->adapter_type) { in arcmsr_flush_adapter_cache()
631 union ccb *pccb = srb->pccb; in arcmsr_report_sense_info()
633 pccb->ccb_h.status |= CAM_SCSI_STATUS_ERROR; in arcmsr_report_sense_info()
634 pccb->csio.scsi_status = SCSI_STATUS_CHECK_COND; in arcmsr_report_sense_info()
635 if(pccb->csio.sense_len) { in arcmsr_report_sense_info()
636 memset(&pccb->csio.sense_data, 0, sizeof(pccb->csio.sense_data)); in arcmsr_report_sense_info()
637 memcpy(&pccb->csio.sense_data, srb->arcmsr_cdb.SenseData, in arcmsr_report_sense_info()
638 get_min(sizeof(struct SENSE_DATA), sizeof(pccb->csio.sense_data))); in arcmsr_report_sense_info()
639 ((u_int8_t *)&pccb->csio.sense_data)[0] = (0x1 << 7 | 0x70); /* Valid,ErrorCode */ in arcmsr_report_sense_info()
640 pccb->ccb_h.status |= CAM_AUTOSNS_VALID; in arcmsr_report_sense_info()
651 printf("arcmsr%d: wait 'abort all outstanding command' timeout \n", acb->pci_unit); in arcmsr_abort_hba_allcmd()
660 struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_abort_hbb_allcmd()
661 WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_MESSAGE_ABORT_CMD); in arcmsr_abort_hbb_allcmd()
663 printf("arcmsr%d: wait 'abort all outstanding command' timeout \n", acb->pci_unit); in arcmsr_abort_hbb_allcmd()
675 printf("arcmsr%d: wait 'abort all outstanding command' timeout \n", acb->pci_unit); in arcmsr_abort_hbc_allcmd()
686 printf("arcmsr%d: wait 'abort all outstanding command' timeout \n", acb->pci_unit); in arcmsr_abort_hbd_allcmd()
696 acb->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_MESSAGE_CMD_DONE; in arcmsr_abort_hbe_allcmd()
697 CHIP_REG_WRITE32(HBE_MessageUnit, 0, iobound_doorbell, acb->out_doorbell); in arcmsr_abort_hbe_allcmd()
699 printf("arcmsr%d: wait 'abort all outstanding command' timeout \n", acb->pci_unit); in arcmsr_abort_hbe_allcmd()
708 switch (acb->adapter_type) { in arcmsr_abort_allcmd()
738 struct AdapterControlBlock *acb = srb->acb; in arcmsr_srb_complete()
739 union ccb *pccb = srb->pccb; in arcmsr_srb_complete()
741 if(srb->srb_flags & SRB_FLAG_TIMER_START) in arcmsr_srb_complete()
742 callout_stop(&srb->ccb_callout); in arcmsr_srb_complete()
743 if((pccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) { in arcmsr_srb_complete()
746 if((pccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) { in arcmsr_srb_complete()
751 bus_dmamap_sync(acb->dm_segs_dmat, srb->dm_segs_dmamap, op); in arcmsr_srb_complete()
752 bus_dmamap_unload(acb->dm_segs_dmat, srb->dm_segs_dmamap); in arcmsr_srb_complete()
755 atomic_subtract_int(&acb->srboutstandingcount, 1); in arcmsr_srb_complete()
756 if((acb->acb_flags & ACB_F_CAM_DEV_QFRZN) && ( in arcmsr_srb_complete()
757 acb->srboutstandingcount < (acb->maxOutstanding -10))) { in arcmsr_srb_complete()
758 acb->acb_flags &= ~ACB_F_CAM_DEV_QFRZN; in arcmsr_srb_complete()
759 pccb->ccb_h.status |= CAM_RELEASE_SIMQ; in arcmsr_srb_complete()
762 if(srb->srb_state != ARCMSR_SRB_TIMEOUT) in arcmsr_srb_complete()
764 acb->pktReturnCount++; in arcmsr_srb_complete()
775 target = srb->pccb->ccb_h.target_id; in arcmsr_report_srb_state()
776 lun = srb->pccb->ccb_h.target_lun; in arcmsr_report_srb_state()
778 if(acb->devstate[target][lun] == ARECA_RAID_GONE) { in arcmsr_report_srb_state()
779 acb->devstate[target][lun] = ARECA_RAID_GOOD; in arcmsr_report_srb_state()
781 srb->pccb->ccb_h.status |= CAM_REQ_CMP; in arcmsr_report_srb_state()
784 switch(srb->arcmsr_cdb.DeviceStatus) { in arcmsr_report_srb_state()
786 if(acb->devstate[target][lun] == ARECA_RAID_GOOD) { in arcmsr_report_srb_state()
787 …printf( "arcmsr%d: Target=%x, Lun=%x, selection timeout, raid volume was lost\n", acb->pci_unit, t… in arcmsr_report_srb_state()
789 acb->devstate[target][lun] = ARECA_RAID_GONE; in arcmsr_report_srb_state()
790 srb->pccb->ccb_h.status |= CAM_DEV_NOT_THERE; in arcmsr_report_srb_state()
796 acb->devstate[target][lun] = ARECA_RAID_GONE; in arcmsr_report_srb_state()
797 srb->pccb->ccb_h.status |= CAM_DEV_NOT_THERE; in arcmsr_report_srb_state()
802 acb->devstate[target][lun] = ARECA_RAID_GOOD; in arcmsr_report_srb_state()
809 , acb->pci_unit, target, lun ,srb->arcmsr_cdb.DeviceStatus); in arcmsr_report_srb_state()
810 acb->devstate[target][lun] = ARECA_RAID_GONE; in arcmsr_report_srb_state()
811 srb->pccb->ccb_h.status |= CAM_UNCOR_PARITY; in arcmsr_report_srb_state()
827 switch (acb->adapter_type) { in arcmsr_drain_donequeue()
830 …srb = (struct CommandControlBlock *)(acb->vir2phy_offset+(flag_srb << 5));/*frame must be 32 bytes… in arcmsr_drain_donequeue()
834 …srb = (struct CommandControlBlock *)(acb->vir2phy_offset+(flag_srb & 0xFFFFFFE0)); /*frame must be… in arcmsr_drain_donequeue()
838 srb = acb->psrb_pool[flag_srb]; in arcmsr_drain_donequeue()
841 …srb = (struct CommandControlBlock *)(acb->vir2phy_offset+(flag_srb << 5));/*frame must be 32 bytes… in arcmsr_drain_donequeue()
844 if((srb->acb != acb) || (srb->srb_state != ARCMSR_SRB_START)) { in arcmsr_drain_donequeue()
845 if(srb->srb_state == ARCMSR_SRB_TIMEOUT) { in arcmsr_drain_donequeue()
847 printf("arcmsr%d: srb='%p' return srb has been timeouted\n", acb->pci_unit, srb); in arcmsr_drain_donequeue()
852 acb->pci_unit, srb, srb->srb_state, acb->srboutstandingcount); in arcmsr_drain_donequeue()
868 target = srb->pccb->ccb_h.target_id; in arcmsr_srb_timeout()
869 lun = srb->pccb->ccb_h.target_lun; in arcmsr_srb_timeout()
870 acb = srb->acb; in arcmsr_srb_timeout()
871 ARCMSR_LOCK_ACQUIRE(&acb->isr_lock); in arcmsr_srb_timeout()
872 if(srb->srb_state == ARCMSR_SRB_START) in arcmsr_srb_timeout()
874 cmd = scsiio_cdb_ptr(&srb->pccb->csio)[0]; in arcmsr_srb_timeout()
875 srb->srb_state = ARCMSR_SRB_TIMEOUT; in arcmsr_srb_timeout()
876 srb->pccb->ccb_h.status |= CAM_CMD_TIMEOUT; in arcmsr_srb_timeout()
879 acb->pci_unit, target, lun, cmd, srb); in arcmsr_srb_timeout()
881 ARCMSR_LOCK_RELEASE(&acb->isr_lock); in arcmsr_srb_timeout()
897 switch (acb->adapter_type) { in arcmsr_done4abort_postqueue()
902 …outbound_intstatus = CHIP_REG_READ32(HBA_MessageUnit, 0, outbound_intstatus) & acb->outbound_int_e… in arcmsr_done4abort_postqueue()
911 struct HBB_MessageUnit *phbbmu=(struct HBB_MessageUnit *)acb->pmu; in arcmsr_done4abort_postqueue()
914 …WRITE_CHIP_REG32(0, phbbmu->iop2drv_doorbell, ARCMSR_DOORBELL_INT_CLEAR_PATTERN); /* clear doorbel… in arcmsr_done4abort_postqueue()
916 if((flag_srb = phbbmu->done_qbuffer[i]) != 0) { in arcmsr_done4abort_postqueue()
917 phbbmu->done_qbuffer[i] = 0; in arcmsr_done4abort_postqueue()
921 phbbmu->post_qbuffer[i] = 0; in arcmsr_done4abort_postqueue()
923 phbbmu->doneq_index = 0; in arcmsr_done4abort_postqueue()
924 phbbmu->postq_index = 0; in arcmsr_done4abort_postqueue()
956 if(acb->srboutstandingcount>0) { in arcmsr_iop_reset()
964 srb = acb->psrb_pool[i]; in arcmsr_iop_reset()
965 if(srb->srb_state == ARCMSR_SRB_START) { in arcmsr_iop_reset()
966 srb->srb_state = ARCMSR_SRB_ABORTED; in arcmsr_iop_reset()
967 srb->pccb->ccb_h.status |= CAM_REQ_ABORTED; in arcmsr_iop_reset()
970 , acb->pci_unit, srb->pccb->ccb_h.target_id in arcmsr_iop_reset()
971 , (uintmax_t)srb->pccb->ccb_h.target_lun, srb); in arcmsr_iop_reset()
977 acb->srboutstandingcount = 0; in arcmsr_iop_reset()
978 acb->workingsrb_doneindex = 0; in arcmsr_iop_reset()
979 acb->workingsrb_startindex = 0; in arcmsr_iop_reset()
980 acb->pktRequestCount = 0; in arcmsr_iop_reset()
981 acb->pktReturnCount = 0; in arcmsr_iop_reset()
990 struct ARCMSR_CDB *arcmsr_cdb = &srb->arcmsr_cdb; in arcmsr_build_srb()
991 u_int8_t *psge = (u_int8_t *)&arcmsr_cdb->u; in arcmsr_build_srb()
993 union ccb *pccb = srb->pccb; in arcmsr_build_srb()
994 struct ccb_scsiio *pcsio = &pccb->csio; in arcmsr_build_srb()
998 arcmsr_cdb->Bus = 0; in arcmsr_build_srb()
999 arcmsr_cdb->TargetID = pccb->ccb_h.target_id; in arcmsr_build_srb()
1000 arcmsr_cdb->LUN = pccb->ccb_h.target_lun; in arcmsr_build_srb()
1001 arcmsr_cdb->Function = 1; in arcmsr_build_srb()
1002 arcmsr_cdb->CdbLength = (u_int8_t)pcsio->cdb_len; in arcmsr_build_srb()
1003 bcopy(scsiio_cdb_ptr(pcsio), arcmsr_cdb->Cdb, pcsio->cdb_len); in arcmsr_build_srb()
1005 struct AdapterControlBlock *acb = srb->acb; in arcmsr_build_srb()
1009 if((pccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) { in arcmsr_build_srb()
1013 arcmsr_cdb->Flags |= ARCMSR_CDB_FLAG_WRITE; in arcmsr_build_srb()
1014 srb->srb_flags |= SRB_FLAG_WRITE; in arcmsr_build_srb()
1016 bus_dmamap_sync(acb->dm_segs_dmat, srb->dm_segs_dmamap, op); in arcmsr_build_srb()
1024 pdma_sg->address = address_lo; in arcmsr_build_srb()
1025 pdma_sg->length = length; in arcmsr_build_srb()
1036 pdma_sg->addresshigh = address_hi; in arcmsr_build_srb()
1037 pdma_sg->address = address_lo; in arcmsr_build_srb()
1040 length0 = 0x100000000-address_lo; in arcmsr_build_srb()
1041 pdma_sg->length = (u_int32_t)length0 | IS_SG64_ADDR; in arcmsr_build_srb()
1044 tmplength = tmplength - (u_int32_t)length0; in arcmsr_build_srb()
1049 pdma_sg->length = tmplength | IS_SG64_ADDR; in arcmsr_build_srb()
1059 arcmsr_cdb->sgcount = (u_int8_t)cdb_sgcount; in arcmsr_build_srb()
1060 arcmsr_cdb->DataLength = pcsio->dxfer_len; in arcmsr_build_srb()
1062 arcmsr_cdb->Flags |= ARCMSR_CDB_FLAG_SGL_BSIZE; in arcmsr_build_srb()
1065 arcmsr_cdb->DataLength = 0; in arcmsr_build_srb()
1067 srb->arc_cdb_size = arccdbsize; in arcmsr_build_srb()
1068 arcmsr_cdb->msgPages = (arccdbsize/256) + ((arccdbsize % 256) ? 1 : 0); in arcmsr_build_srb()
1076 u_int32_t cdb_phyaddr_low = (u_int32_t) srb->cdb_phyaddr; in arcmsr_post_srb()
1077 struct ARCMSR_CDB *arcmsr_cdb = (struct ARCMSR_CDB *)&srb->arcmsr_cdb; in arcmsr_post_srb()
1079 …bus_dmamap_sync(acb->srb_dmat, acb->srb_dmamap, (srb->srb_flags & SRB_FLAG_WRITE) ? BUS_DMASYNC_PO… in arcmsr_post_srb()
1080 atomic_add_int(&acb->srboutstandingcount, 1); in arcmsr_post_srb()
1081 srb->srb_state = ARCMSR_SRB_START; in arcmsr_post_srb()
1083 switch (acb->adapter_type) { in arcmsr_post_srb()
1085 if(arcmsr_cdb->Flags & ARCMSR_CDB_FLAG_SGL_BSIZE) { in arcmsr_post_srb()
1093 struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_post_srb()
1096 index = phbbmu->postq_index; in arcmsr_post_srb()
1098 phbbmu->post_qbuffer[ending_index] = 0; in arcmsr_post_srb()
1099 if(arcmsr_cdb->Flags & ARCMSR_CDB_FLAG_SGL_BSIZE) { in arcmsr_post_srb()
1100 phbbmu->post_qbuffer[index] = cdb_phyaddr_low | ARCMSR_SRBPOST_FLAG_SGL_BSIZE; in arcmsr_post_srb()
1102 phbbmu->post_qbuffer[index] = cdb_phyaddr_low; in arcmsr_post_srb()
1106 phbbmu->postq_index = index; in arcmsr_post_srb()
1107 WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_DRV2IOP_CDB_POSTED); in arcmsr_post_srb()
1113 arc_cdb_size = (srb->arc_cdb_size > 0x300) ? 0x300 : srb->arc_cdb_size; in arcmsr_post_srb()
1114 ccb_post_stamp = (cdb_phyaddr_low | ((arc_cdb_size-1) >> 6) | 1); in arcmsr_post_srb()
1115 cdb_phyaddr_hi32 = acb->srb_phyaddr.B.phyadd_high; in arcmsr_post_srb()
1128 struct HBD_MessageUnit0 *phbdmu = (struct HBD_MessageUnit0 *)acb->pmu; in arcmsr_post_srb()
1133 ARCMSR_LOCK_ACQUIRE(&acb->postDone_lock); in arcmsr_post_srb()
1134 postq_index = phbdmu->postq_index; in arcmsr_post_srb()
1135 pinbound_srb = (struct InBound_SRB *)&phbdmu->post_qbuffer[postq_index & 0xFF]; in arcmsr_post_srb()
1136 pinbound_srb->addressHigh = (u_int32_t)((srb->cdb_phyaddr >> 16) >> 16); in arcmsr_post_srb()
1137 pinbound_srb->addressLow = (u_int32_t)srb->cdb_phyaddr; in arcmsr_post_srb()
1138 pinbound_srb->length = srb->arc_cdb_size >> 2; in arcmsr_post_srb()
1139 arcmsr_cdb->Context = (u_int32_t)srb->cdb_phyaddr; in arcmsr_post_srb()
1144 phbdmu->postq_index = index_stripped ? (index_stripped | 0x4000) : index_stripped; in arcmsr_post_srb()
1149 phbdmu->postq_index = index_stripped ? index_stripped : (index_stripped | 0x4000); in arcmsr_post_srb()
1152 ARCMSR_LOCK_RELEASE(&acb->postDone_lock); in arcmsr_post_srb()
1158 arc_cdb_size = (srb->arc_cdb_size > 0x300) ? 0x300 : srb->arc_cdb_size; in arcmsr_post_srb()
1159 ccb_post_stamp = (srb->smid | ((arc_cdb_size-1) >> 6)); in arcmsr_post_srb()
1167 if (srb->arc_cdb_size <= 0x300) in arcmsr_post_srb()
1168 arc_cdb_size = (srb->arc_cdb_size - 1) >> 6 | 1; in arcmsr_post_srb()
1170 arc_cdb_size = ((srb->arc_cdb_size + 0xff) >> 8) + 2; in arcmsr_post_srb()
1175 ccb_post_stamp = (srb->smid | arc_cdb_size); in arcmsr_post_srb()
1190 switch (acb->adapter_type) { in arcmsr_get_iop_rqbuffer()
1192 struct HBA_MessageUnit *phbamu = (struct HBA_MessageUnit *)acb->pmu; in arcmsr_get_iop_rqbuffer()
1194 qbuffer = (struct QBUFFER *)&phbamu->message_rbuffer; in arcmsr_get_iop_rqbuffer()
1198 struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_get_iop_rqbuffer()
1200 qbuffer = (struct QBUFFER *)&phbbmu->hbb_rwbuffer->message_rbuffer; in arcmsr_get_iop_rqbuffer()
1204 struct HBC_MessageUnit *phbcmu = (struct HBC_MessageUnit *)acb->pmu; in arcmsr_get_iop_rqbuffer()
1206 qbuffer = (struct QBUFFER *)&phbcmu->message_rbuffer; in arcmsr_get_iop_rqbuffer()
1210 struct HBD_MessageUnit0 *phbdmu = (struct HBD_MessageUnit0 *)acb->pmu; in arcmsr_get_iop_rqbuffer()
1212 qbuffer = (struct QBUFFER *)&phbdmu->phbdmu->message_rbuffer; in arcmsr_get_iop_rqbuffer()
1216 struct HBE_MessageUnit *phbcmu = (struct HBE_MessageUnit *)acb->pmu; in arcmsr_get_iop_rqbuffer()
1218 qbuffer = (struct QBUFFER *)&phbcmu->message_rbuffer; in arcmsr_get_iop_rqbuffer()
1222 qbuffer = (struct QBUFFER *)acb->message_rbuffer; in arcmsr_get_iop_rqbuffer()
1235 switch (acb->adapter_type) { in arcmsr_get_iop_wqbuffer()
1237 struct HBA_MessageUnit *phbamu = (struct HBA_MessageUnit *)acb->pmu; in arcmsr_get_iop_wqbuffer()
1239 qbuffer = (struct QBUFFER *)&phbamu->message_wbuffer; in arcmsr_get_iop_wqbuffer()
1243 struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_get_iop_wqbuffer()
1245 qbuffer = (struct QBUFFER *)&phbbmu->hbb_rwbuffer->message_wbuffer; in arcmsr_get_iop_wqbuffer()
1249 struct HBC_MessageUnit *phbcmu = (struct HBC_MessageUnit *)acb->pmu; in arcmsr_get_iop_wqbuffer()
1251 qbuffer = (struct QBUFFER *)&phbcmu->message_wbuffer; in arcmsr_get_iop_wqbuffer()
1255 struct HBD_MessageUnit0 *phbdmu = (struct HBD_MessageUnit0 *)acb->pmu; in arcmsr_get_iop_wqbuffer()
1257 qbuffer = (struct QBUFFER *)&phbdmu->phbdmu->message_wbuffer; in arcmsr_get_iop_wqbuffer()
1261 struct HBE_MessageUnit *phbcmu = (struct HBE_MessageUnit *)acb->pmu; in arcmsr_get_iop_wqbuffer()
1263 qbuffer = (struct QBUFFER *)&phbcmu->message_wbuffer; in arcmsr_get_iop_wqbuffer()
1267 qbuffer = (struct QBUFFER *)acb->message_wbuffer; in arcmsr_get_iop_wqbuffer()
1278 switch (acb->adapter_type) { in arcmsr_iop_message_read()
1285 struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_iop_message_read()
1287 WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_DRV2IOP_DATA_READ_OK); in arcmsr_iop_message_read()
1303 acb->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_DATA_READ_OK; in arcmsr_iop_message_read()
1304 CHIP_REG_WRITE32(HBE_MessageUnit, 0, iobound_doorbell, acb->out_doorbell); in arcmsr_iop_message_read()
1315 switch (acb->adapter_type) { in arcmsr_iop_message_wrote()
1325 struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_iop_message_wrote()
1330 WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_DRV2IOP_DATA_WRITE_OK); in arcmsr_iop_message_wrote()
1355 acb->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_DATA_WRITE_OK; in arcmsr_iop_message_wrote()
1356 CHIP_REG_WRITE32(HBE_MessageUnit, 0, iobound_doorbell, acb->out_doorbell); in arcmsr_iop_message_wrote()
1367 acb->acb_flags &= ~ACB_F_MSG_START_BGRB; in arcmsr_stop_hba_bgrb()
1372 , acb->pci_unit); in arcmsr_stop_hba_bgrb()
1381 struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_stop_hbb_bgrb()
1382 acb->acb_flags &= ~ACB_F_MSG_START_BGRB; in arcmsr_stop_hbb_bgrb()
1383 WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_MESSAGE_STOP_BGRB); in arcmsr_stop_hbb_bgrb()
1386 , acb->pci_unit); in arcmsr_stop_hbb_bgrb()
1395 acb->acb_flags &= ~ACB_F_MSG_START_BGRB; in arcmsr_stop_hbc_bgrb()
1399 printf("arcmsr%d: wait 'stop adapter background rebuild' timeout \n", acb->pci_unit); in arcmsr_stop_hbc_bgrb()
1408 acb->acb_flags &= ~ACB_F_MSG_START_BGRB; in arcmsr_stop_hbd_bgrb()
1411 printf("arcmsr%d: wait 'stop adapter background rebuild' timeout \n", acb->pci_unit); in arcmsr_stop_hbd_bgrb()
1420 acb->acb_flags &= ~ACB_F_MSG_START_BGRB; in arcmsr_stop_hbe_bgrb()
1422 acb->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_MESSAGE_CMD_DONE; in arcmsr_stop_hbe_bgrb()
1423 CHIP_REG_WRITE32(HBE_MessageUnit, 0, iobound_doorbell, acb->out_doorbell); in arcmsr_stop_hbe_bgrb()
1425 printf("arcmsr%d: wait 'stop adapter background rebuild' timeout \n", acb->pci_unit); in arcmsr_stop_hbe_bgrb()
1434 switch (acb->adapter_type) { in arcmsr_stop_adapter_bgrb()
1468 mutex = mtx_owned(&acb->isr_lock); in arcmsr_poll()
1470 ARCMSR_LOCK_ACQUIRE(&acb->isr_lock); in arcmsr_poll()
1473 ARCMSR_LOCK_RELEASE(&acb->isr_lock); in arcmsr_poll()
1486 iop_data = (u_int32_t *)prbuffer->data; in arcmsr_Read_iop_rqbuffer_data_D()
1487 iop_len = (u_int32_t)prbuffer->data_len; in arcmsr_Read_iop_rqbuffer_data_D()
1498 data_len -= 4; in arcmsr_Read_iop_rqbuffer_data_D()
1505 pQbuffer = &acb->rqbuffer[acb->rqbuf_lastindex]; in arcmsr_Read_iop_rqbuffer_data_D()
1507 acb->rqbuf_lastindex++; in arcmsr_Read_iop_rqbuffer_data_D()
1509 acb->rqbuf_lastindex %= ARCMSR_MAX_QBUFFER; in arcmsr_Read_iop_rqbuffer_data_D()
1511 iop_len--; in arcmsr_Read_iop_rqbuffer_data_D()
1529 if(acb->adapter_type >= ACB_ADAPTER_TYPE_B) { in arcmsr_Read_iop_rqbuffer_data()
1532 iop_data = (u_int8_t *)prbuffer->data; in arcmsr_Read_iop_rqbuffer_data()
1533 iop_len = (u_int32_t)prbuffer->data_len; in arcmsr_Read_iop_rqbuffer_data()
1535 pQbuffer = &acb->rqbuffer[acb->rqbuf_lastindex]; in arcmsr_Read_iop_rqbuffer_data()
1537 acb->rqbuf_lastindex++; in arcmsr_Read_iop_rqbuffer_data()
1539 acb->rqbuf_lastindex %= ARCMSR_MAX_QBUFFER; in arcmsr_Read_iop_rqbuffer_data()
1541 iop_len--; in arcmsr_Read_iop_rqbuffer_data()
1556 /*check this iop data if overflow my rqbuffer*/ in arcmsr_iop2drv_data_wrote_handle()
1557 ARCMSR_LOCK_ACQUIRE(&acb->qbuffer_lock); in arcmsr_iop2drv_data_wrote_handle()
1559 if (acb->rqbuf_lastindex >= acb->rqbuf_firstindex) in arcmsr_iop2drv_data_wrote_handle()
1560 my_empty_len = (ARCMSR_MAX_QBUFFER - 1) - (acb->rqbuf_lastindex - acb->rqbuf_firstindex); in arcmsr_iop2drv_data_wrote_handle()
1562 my_empty_len = acb->rqbuf_firstindex - acb->rqbuf_lastindex - 1; in arcmsr_iop2drv_data_wrote_handle()
1563 if(my_empty_len >= prbuffer->data_len) { in arcmsr_iop2drv_data_wrote_handle()
1565 acb->acb_flags |= ACB_F_IOPDATA_OVERFLOW; in arcmsr_iop2drv_data_wrote_handle()
1567 acb->acb_flags |= ACB_F_IOPDATA_OVERFLOW; in arcmsr_iop2drv_data_wrote_handle()
1569 ARCMSR_LOCK_RELEASE(&acb->qbuffer_lock); in arcmsr_iop2drv_data_wrote_handle()
1583 if(acb->acb_flags & ACB_F_MESSAGE_WQBUFFER_READ) { in arcmsr_Write_data_2iop_wqbuffer_D()
1589 acb->acb_flags &= (~ACB_F_MESSAGE_WQBUFFER_READ); in arcmsr_Write_data_2iop_wqbuffer_D()
1591 iop_data = (u_int32_t *)pwbuffer->data; in arcmsr_Write_data_2iop_wqbuffer_D()
1592 while((acb->wqbuf_firstindex != acb->wqbuf_lastindex) in arcmsr_Write_data_2iop_wqbuffer_D()
1594 pQbuffer = &acb->wqbuffer[acb->wqbuf_firstindex]; in arcmsr_Write_data_2iop_wqbuffer_D()
1596 acb->wqbuf_firstindex++; in arcmsr_Write_data_2iop_wqbuffer_D()
1597 acb->wqbuf_firstindex %= ARCMSR_MAX_QBUFFER; in arcmsr_Write_data_2iop_wqbuffer_D()
1601 pwbuffer->data_len = allxfer_len; in arcmsr_Write_data_2iop_wqbuffer_D()
1607 data_len -= 4; in arcmsr_Write_data_2iop_wqbuffer_D()
1626 if(acb->adapter_type >= ACB_ADAPTER_TYPE_B) { in arcmsr_Write_data_2iop_wqbuffer()
1630 if(acb->acb_flags & ACB_F_MESSAGE_WQBUFFER_READ) { in arcmsr_Write_data_2iop_wqbuffer()
1631 acb->acb_flags &= (~ACB_F_MESSAGE_WQBUFFER_READ); in arcmsr_Write_data_2iop_wqbuffer()
1633 iop_data = (u_int8_t *)pwbuffer->data; in arcmsr_Write_data_2iop_wqbuffer()
1634 while((acb->wqbuf_firstindex != acb->wqbuf_lastindex) in arcmsr_Write_data_2iop_wqbuffer()
1636 pQbuffer = &acb->wqbuffer[acb->wqbuf_firstindex]; in arcmsr_Write_data_2iop_wqbuffer()
1638 acb->wqbuf_firstindex++; in arcmsr_Write_data_2iop_wqbuffer()
1639 acb->wqbuf_firstindex %= ARCMSR_MAX_QBUFFER; in arcmsr_Write_data_2iop_wqbuffer()
1643 pwbuffer->data_len = allxfer_len; in arcmsr_Write_data_2iop_wqbuffer()
1653 ARCMSR_LOCK_ACQUIRE(&acb->qbuffer_lock); in arcmsr_iop2drv_data_read_handle()
1654 acb->acb_flags |= ACB_F_MESSAGE_WQBUFFER_READ; in arcmsr_iop2drv_data_read_handle()
1658 ** in my post bag, now is the time to send them into Areca's firmware in arcmsr_iop2drv_data_read_handle()
1661 if(acb->wqbuf_firstindex != acb->wqbuf_lastindex) { in arcmsr_iop2drv_data_read_handle()
1664 if(acb->wqbuf_firstindex == acb->wqbuf_lastindex) { in arcmsr_iop2drv_data_read_handle()
1665 acb->acb_flags |= ACB_F_MESSAGE_WQBUFFER_CLEARED; in arcmsr_iop2drv_data_read_handle()
1667 ARCMSR_LOCK_RELEASE(&acb->qbuffer_lock); in arcmsr_iop2drv_data_read_handle()
1676 if (ccb->ccb_h.status != CAM_REQ_CMP) in arcmsr_rescanLun_cb()
1678 "failure status=%x\n", ccb->ccb_h.target_id, in arcmsr_rescanLun_cb()
1679 ccb->ccb_h.target_lun, ccb->ccb_h.status); in arcmsr_rescanLun_cb()
1683 xpt_free_path(ccb->ccb_h.path); in arcmsr_rescanLun_cb()
1694 if (xpt_create_path(&path, NULL, cam_sim_path(acb->psim), target, lun) != CAM_REQ_CMP) in arcmsr_rescan_lun()
1700 xpt_setup_ccb(&ccb->ccb_h, path, 5); in arcmsr_rescan_lun()
1701 ccb->ccb_h.func_code = XPT_SCAN_LUN; in arcmsr_rescan_lun()
1702 ccb->ccb_h.cbfcnp = arcmsr_rescanLun_cb; in arcmsr_rescan_lun()
1703 ccb->crcn.flags = CAM_FLAG_NONE; in arcmsr_rescan_lun()
1717 srb = acb->psrb_pool[i]; in arcmsr_abort_dr_ccbs()
1718 if (srb->srb_state == ARCMSR_SRB_START) in arcmsr_abort_dr_ccbs()
1720 if((target == srb->pccb->ccb_h.target_id) && (lun == srb->pccb->ccb_h.target_lun)) in arcmsr_abort_dr_ccbs()
1722 srb->srb_state = ARCMSR_SRB_ABORTED; in arcmsr_abort_dr_ccbs()
1723 srb->pccb->ccb_h.status |= CAM_REQ_ABORTED; in arcmsr_abort_dr_ccbs()
1725 printf("arcmsr%d: abort scsi id %d lun %d srb=%p \n", acb->pci_unit, target, lun, srb); in arcmsr_abort_dr_ccbs()
1742 switch (acb->adapter_type) { in arcmsr_dr_handle()
1747 deviceMapCurrent[target]=bus_space_read_4(acb->btag[0], acb->bhandle[0], devicemap); in arcmsr_dr_handle()
1756 deviceMapCurrent[target]=bus_space_read_4(acb->btag[1], acb->bhandle[1], devicemap); in arcmsr_dr_handle()
1765 deviceMapCurrent[target]=bus_space_read_4(acb->btag[0], acb->bhandle[0], devicemap); in arcmsr_dr_handle()
1773 deviceMapCurrent[target]=bus_space_read_4(acb->btag[0], acb->bhandle[0], devicemap); in arcmsr_dr_handle()
1781 deviceMapCurrent[target]=bus_space_read_4(acb->btag[0], acb->bhandle[0], devicemap); in arcmsr_dr_handle()
1789 deviceMapCurrent[target] = acb->msgcode_rwbuffer[devicemap]; in arcmsr_dr_handle()
1795 if(acb->acb_flags & ACB_F_BUS_HANG_ON) in arcmsr_dr_handle()
1797 acb->acb_flags &= ~ACB_F_BUS_HANG_ON; in arcmsr_dr_handle()
1804 for (target = 0; target < ARCMSR_MAX_TARGETID - 1; target++) in arcmsr_dr_handle()
1806 if (*pDevMap != acb->device_map[target]) in arcmsr_dr_handle()
1810 difference = *pDevMap ^ acb->device_map[target]; in arcmsr_dr_handle()
1816 if(acb->device_map[target] & bit_check) in arcmsr_dr_handle()
1822 acb->devstate[target][lun] = ARECA_RAID_GONE; in arcmsr_dr_handle()
1826 printf("arcmsr_dr_handle: Target=0x%x, lun=%x, Plug-IN!!!\n",target,lun); in arcmsr_dr_handle()
1828 acb->devstate[target][lun] = ARECA_RAID_GOOD; in arcmsr_dr_handle()
1832 /* printf("arcmsr_dr_handle: acb->device_map[%x]=0x%x, deviceMapCurrent[%x]=%x\n",target,acb->dev… in arcmsr_dr_handle()
1833 acb->device_map[target] = *pDevMap; in arcmsr_dr_handle()
1856 struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_hbb_message_isr()
1859 WRITE_CHIP_REG32(0, phbbmu->iop2drv_doorbell, ARCMSR_MESSAGE_INT_CLEAR_PATTERN); in arcmsr_hbb_message_isr()
1896 if (acb->adapter_type == ACB_ADAPTER_TYPE_E) in arcmsr_hbe_message_isr()
1899 outbound_message = acb->msgcode_rwbuffer[0]; in arcmsr_hbe_message_isr()
2004 doorbell_status = in_doorbell ^ acb->in_doorbell; in arcmsr_hbe_doorbell_isr()
2014 acb->in_doorbell = in_doorbell; in arcmsr_hbe_doorbell_isr()
2037 doorbell_status = in_doorbell ^ acb->in_doorbell; in arcmsr_hbf_doorbell_isr()
2047 acb->in_doorbell = in_doorbell; in arcmsr_hbf_doorbell_isr()
2063 bus_dmamap_sync(acb->srb_dmat, acb->srb_dmamap, in arcmsr_hba_postqueue_isr()
2078 struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_hbb_postqueue_isr()
2088 bus_dmamap_sync(acb->srb_dmat, acb->srb_dmamap, in arcmsr_hbb_postqueue_isr()
2090 index = phbbmu->doneq_index; in arcmsr_hbb_postqueue_isr()
2091 while((flag_srb = phbbmu->done_qbuffer[index]) != 0) { in arcmsr_hbb_postqueue_isr()
2092 phbbmu->done_qbuffer[index] = 0; in arcmsr_hbb_postqueue_isr()
2095 phbbmu->doneq_index = index; in arcmsr_hbb_postqueue_isr()
2115 bus_dmamap_sync(acb->srb_dmat, acb->srb_dmamap, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); in arcmsr_hbc_postqueue_isr()
2139 doneq_index = phbdmu->doneq_index; in arcmsr_get_doneq_index()
2144 phbdmu->doneq_index = index_stripped ? in arcmsr_get_doneq_index()
2150 phbdmu->doneq_index = index_stripped ? in arcmsr_get_doneq_index()
2153 return (phbdmu->doneq_index); in arcmsr_get_doneq_index()
2161 struct HBD_MessageUnit0 *phbdmu = (struct HBD_MessageUnit0 *)acb->pmu; in arcmsr_hbd_postqueue_isr()
2174 bus_dmamap_sync(acb->srb_dmat, acb->srb_dmamap, in arcmsr_hbd_postqueue_isr()
2176 outbound_write_pointer = phbdmu->done_qbuffer[0].addressLow; in arcmsr_hbd_postqueue_isr()
2177 doneq_index = phbdmu->doneq_index; in arcmsr_hbd_postqueue_isr()
2180 addressLow = phbdmu->done_qbuffer[(doneq_index & 0xFF)+1].addressLow; in arcmsr_hbd_postqueue_isr()
2184 outbound_write_pointer = phbdmu->done_qbuffer[0].addressLow; in arcmsr_hbd_postqueue_isr()
2204 bus_dmamap_sync(acb->srb_dmat, acb->srb_dmamap, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); in arcmsr_hbe_postqueue_isr()
2205 doneq_index = acb->doneq_index; in arcmsr_hbe_postqueue_isr()
2207 cmdSMID = acb->pCompletionQ[doneq_index].cmdSMID; in arcmsr_hbe_postqueue_isr()
2208 …error = (acb->pCompletionQ[doneq_index].cmdFlag & ARCMSR_SRBREPLY_FLAG_ERROR_MODE1) ? TRUE : FALSE; in arcmsr_hbe_postqueue_isr()
2211 if (doneq_index >= acb->completionQ_entry) in arcmsr_hbe_postqueue_isr()
2214 acb->doneq_index = doneq_index; in arcmsr_hbe_postqueue_isr()
2229 bus_dmamap_sync(acb->srb_dmat, acb->srb_dmamap, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); in arcmsr_hbf_postqueue_isr()
2230 doneq_index = acb->doneq_index; in arcmsr_hbf_postqueue_isr()
2232 cmdSMID = acb->pCompletionQ[doneq_index].cmdSMID; in arcmsr_hbf_postqueue_isr()
2235 …error = (acb->pCompletionQ[doneq_index].cmdFlag & ARCMSR_SRBREPLY_FLAG_ERROR_MODE1) ? TRUE : FALSE; in arcmsr_hbf_postqueue_isr()
2237 acb->pCompletionQ[doneq_index].cmdSMID = 0xffff; in arcmsr_hbf_postqueue_isr()
2239 if (doneq_index >= acb->completionQ_entry) in arcmsr_hbf_postqueue_isr()
2242 acb->doneq_index = doneq_index; in arcmsr_hbf_postqueue_isr()
2258 …outbound_intStatus = CHIP_REG_READ32(HBA_MessageUnit, 0, outbound_intstatus) & acb->outbound_int_e… in arcmsr_handle_hba_isr()
2283 struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_handle_hbb_isr()
2289 outbound_doorbell = READ_CHIP_REG32(0, phbbmu->iop2drv_doorbell) & acb->outbound_int_enable; in arcmsr_handle_hbb_isr()
2294 WRITE_CHIP_REG32(0, phbbmu->iop2drv_doorbell, ~outbound_doorbell); /* clear doorbell interrupt */ in arcmsr_handle_hbb_isr()
2295 READ_CHIP_REG32(0, phbbmu->iop2drv_doorbell); in arcmsr_handle_hbb_isr()
2296 WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_DRV2IOP_END_OF_INTERRUPT); in arcmsr_handle_hbb_isr()
2356 …host_interrupt_status = CHIP_REG_READ32(HBD_MessageUnit, 0, host_int_status) & acb->outbound_int_e… in arcmsr_handle_hbd_isr()
2441 switch (acb->adapter_type) { in arcmsr_interrupt()
2462 " unknown adapter type =%d\n", acb->pci_unit, acb->adapter_type); in arcmsr_interrupt()
2474 ARCMSR_LOCK_ACQUIRE(&acb->isr_lock); in arcmsr_intr_handler()
2476 ARCMSR_LOCK_RELEASE(&acb->isr_lock); in arcmsr_intr_handler()
2485 switch (acb->adapter_type) { in arcmsr_polling_devmap()
2491 struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_polling_devmap()
2492 WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_MESSAGE_GET_CONFIG); in arcmsr_polling_devmap()
2507 acb->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_MESSAGE_CMD_DONE; in arcmsr_polling_devmap()
2508 CHIP_REG_WRITE32(HBE_MessageUnit, 0, iobound_doorbell, acb->out_doorbell); in arcmsr_polling_devmap()
2517 acb->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_MESSAGE_CMD_DONE; in arcmsr_polling_devmap()
2518 CHIP_REG_WRITE32(HBF_MessageUnit, 0, iobound_doorbell, acb->out_doorbell); in arcmsr_polling_devmap()
2523 if((acb->acb_flags & ACB_F_SCSISTOPADAPTER) == 0) in arcmsr_polling_devmap()
2525 …callout_reset(&acb->devmap_callout, 5 * hz, arcmsr_polling_devmap, acb); /* polling per 5 seconds … in arcmsr_polling_devmap()
2540 if(acb->acb_flags & ACB_F_MSG_START_BGRB) { in arcmsr_iop_parking()
2559 if(memcmp(pcmdmessagefld->cmdmessage.Signature, "ARCMSR", 6)!=0) { in arcmsr_iop_ioctlcmd()
2562 ARCMSR_LOCK_ACQUIRE(&acb->qbuffer_lock); in arcmsr_iop_ioctlcmd()
2566 u_int8_t *ptmpQbuffer = pcmdmessagefld->messagedatabuffer; in arcmsr_iop_ioctlcmd()
2569 while((acb->rqbuf_firstindex != acb->rqbuf_lastindex) in arcmsr_iop_ioctlcmd()
2572 pQbuffer = &acb->rqbuffer[acb->rqbuf_firstindex]; in arcmsr_iop_ioctlcmd()
2574 acb->rqbuf_firstindex++; in arcmsr_iop_ioctlcmd()
2575 acb->rqbuf_firstindex %= ARCMSR_MAX_QBUFFER; in arcmsr_iop_ioctlcmd()
2580 if(acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) { in arcmsr_iop_ioctlcmd()
2583 acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW; in arcmsr_iop_ioctlcmd()
2586 acb->acb_flags |= ACB_F_IOPDATA_OVERFLOW; in arcmsr_iop_ioctlcmd()
2588 pcmdmessagefld->cmdmessage.Length = allxfer_len; in arcmsr_iop_ioctlcmd()
2589 pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_OK; in arcmsr_iop_ioctlcmd()
2596 u_int8_t *ptmpuserbuffer = pcmdmessagefld->messagedatabuffer; in arcmsr_iop_ioctlcmd()
2598 user_len = pcmdmessagefld->cmdmessage.Length; in arcmsr_iop_ioctlcmd()
2599 /*check if data xfer length of this request will overflow my array qbuffer */ in arcmsr_iop_ioctlcmd()
2600 wqbuf_lastindex = acb->wqbuf_lastindex; in arcmsr_iop_ioctlcmd()
2601 wqbuf_firstindex = acb->wqbuf_firstindex; in arcmsr_iop_ioctlcmd()
2604 pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_ERROR; in arcmsr_iop_ioctlcmd()
2606 my_empty_len = (wqbuf_firstindex - wqbuf_lastindex - 1) & in arcmsr_iop_ioctlcmd()
2607 (ARCMSR_MAX_QBUFFER - 1); in arcmsr_iop_ioctlcmd()
2611 pQbuffer = &acb->wqbuffer[acb->wqbuf_lastindex]; in arcmsr_iop_ioctlcmd()
2613 acb->wqbuf_lastindex++; in arcmsr_iop_ioctlcmd()
2614 acb->wqbuf_lastindex %= ARCMSR_MAX_QBUFFER; in arcmsr_iop_ioctlcmd()
2617 user_len--; in arcmsr_iop_ioctlcmd()
2620 if(acb->acb_flags & ACB_F_MESSAGE_WQBUFFER_CLEARED) { in arcmsr_iop_ioctlcmd()
2621 acb->acb_flags &= ~ACB_F_MESSAGE_WQBUFFER_CLEARED; in arcmsr_iop_ioctlcmd()
2624 pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_OK; in arcmsr_iop_ioctlcmd()
2626 pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_ERROR; in arcmsr_iop_ioctlcmd()
2633 u_int8_t *pQbuffer = acb->rqbuffer; in arcmsr_iop_ioctlcmd()
2635 if(acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) { in arcmsr_iop_ioctlcmd()
2636 acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW; in arcmsr_iop_ioctlcmd()
2640 acb->acb_flags |= ACB_F_MESSAGE_RQBUFFER_CLEARED; in arcmsr_iop_ioctlcmd()
2641 acb->rqbuf_firstindex = 0; in arcmsr_iop_ioctlcmd()
2642 acb->rqbuf_lastindex = 0; in arcmsr_iop_ioctlcmd()
2644 pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_OK; in arcmsr_iop_ioctlcmd()
2650 u_int8_t *pQbuffer = acb->wqbuffer; in arcmsr_iop_ioctlcmd()
2652 if(acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) { in arcmsr_iop_ioctlcmd()
2653 acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW; in arcmsr_iop_ioctlcmd()
2657 acb->acb_flags |= (ACB_F_MESSAGE_WQBUFFER_CLEARED|ACB_F_MESSAGE_WQBUFFER_READ); in arcmsr_iop_ioctlcmd()
2658 acb->wqbuf_firstindex = 0; in arcmsr_iop_ioctlcmd()
2659 acb->wqbuf_lastindex = 0; in arcmsr_iop_ioctlcmd()
2661 pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_OK; in arcmsr_iop_ioctlcmd()
2668 if(acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) { in arcmsr_iop_ioctlcmd()
2669 acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW; in arcmsr_iop_ioctlcmd()
2673 acb->acb_flags |= (ACB_F_MESSAGE_WQBUFFER_CLEARED in arcmsr_iop_ioctlcmd()
2676 acb->rqbuf_firstindex = 0; in arcmsr_iop_ioctlcmd()
2677 acb->rqbuf_lastindex = 0; in arcmsr_iop_ioctlcmd()
2678 acb->wqbuf_firstindex = 0; in arcmsr_iop_ioctlcmd()
2679 acb->wqbuf_lastindex = 0; in arcmsr_iop_ioctlcmd()
2680 pQbuffer = acb->rqbuffer; in arcmsr_iop_ioctlcmd()
2682 pQbuffer = acb->wqbuffer; in arcmsr_iop_ioctlcmd()
2684 pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_OK; in arcmsr_iop_ioctlcmd()
2689 pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_3F; in arcmsr_iop_ioctlcmd()
2695 u_int8_t *puserbuffer = (u_int8_t *)pcmdmessagefld->messagedatabuffer; in arcmsr_iop_ioctlcmd()
2698 pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_ERROR; in arcmsr_iop_ioctlcmd()
2699 ARCMSR_LOCK_RELEASE(&acb->qbuffer_lock); in arcmsr_iop_ioctlcmd()
2702 pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_OK; in arcmsr_iop_ioctlcmd()
2717 ARCMSR_LOCK_RELEASE(&acb->qbuffer_lock); in arcmsr_iop_ioctlcmd()
2728 acb = srb->acb; in arcmsr_free_srb()
2729 ARCMSR_LOCK_ACQUIRE(&acb->srb_lock); in arcmsr_free_srb()
2730 srb->srb_state = ARCMSR_SRB_DONE; in arcmsr_free_srb()
2731 srb->srb_flags = 0; in arcmsr_free_srb()
2732 acb->srbworkingQ[acb->workingsrb_doneindex] = srb; in arcmsr_free_srb()
2733 acb->workingsrb_doneindex++; in arcmsr_free_srb()
2734 acb->workingsrb_doneindex %= ARCMSR_MAX_FREESRB_NUM; in arcmsr_free_srb()
2735 ARCMSR_LOCK_RELEASE(&acb->srb_lock); in arcmsr_free_srb()
2746 ARCMSR_LOCK_ACQUIRE(&acb->srb_lock); in arcmsr_get_freesrb()
2747 workingsrb_doneindex = acb->workingsrb_doneindex; in arcmsr_get_freesrb()
2748 workingsrb_startindex = acb->workingsrb_startindex; in arcmsr_get_freesrb()
2749 srb = acb->srbworkingQ[workingsrb_startindex]; in arcmsr_get_freesrb()
2753 acb->workingsrb_startindex = workingsrb_startindex; in arcmsr_get_freesrb()
2757 ARCMSR_LOCK_RELEASE(&acb->srb_lock); in arcmsr_get_freesrb()
2769 uint8_t *ptr = scsiio_cdb_ptr(&pccb->csio); in arcmsr_iop_message_xfer()
2775 if ((pccb->ccb_h.flags & CAM_DATA_MASK) == CAM_DATA_VADDR) { in arcmsr_iop_message_xfer()
2776 buffer = pccb->csio.data_ptr; in arcmsr_iop_message_xfer()
2777 transfer_len = pccb->csio.dxfer_len; in arcmsr_iop_message_xfer()
2790 u_int8_t *ptmpQbuffer = pcmdmessagefld->messagedatabuffer; in arcmsr_iop_message_xfer()
2793 ARCMSR_LOCK_ACQUIRE(&acb->qbuffer_lock); in arcmsr_iop_message_xfer()
2794 while ((acb->rqbuf_firstindex != acb->rqbuf_lastindex) in arcmsr_iop_message_xfer()
2796 pQbuffer = &acb->rqbuffer[acb->rqbuf_firstindex]; in arcmsr_iop_message_xfer()
2798 acb->rqbuf_firstindex++; in arcmsr_iop_message_xfer()
2799 acb->rqbuf_firstindex %= ARCMSR_MAX_QBUFFER; in arcmsr_iop_message_xfer()
2803 if (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) { in arcmsr_iop_message_xfer()
2806 acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW; in arcmsr_iop_message_xfer()
2809 acb->acb_flags |= ACB_F_IOPDATA_OVERFLOW; in arcmsr_iop_message_xfer()
2811 pcmdmessagefld->cmdmessage.Length = allxfer_len; in arcmsr_iop_message_xfer()
2812 pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_OK; in arcmsr_iop_message_xfer()
2814 ARCMSR_LOCK_RELEASE(&acb->qbuffer_lock); in arcmsr_iop_message_xfer()
2820 u_int8_t *ptmpuserbuffer = pcmdmessagefld->messagedatabuffer; in arcmsr_iop_message_xfer()
2822 user_len = pcmdmessagefld->cmdmessage.Length; in arcmsr_iop_message_xfer()
2823 ARCMSR_LOCK_ACQUIRE(&acb->qbuffer_lock); in arcmsr_iop_message_xfer()
2824 wqbuf_lastindex = acb->wqbuf_lastindex; in arcmsr_iop_message_xfer()
2825 wqbuf_firstindex = acb->wqbuf_firstindex; in arcmsr_iop_message_xfer()
2829 if(pccb->csio.sense_len) { in arcmsr_iop_message_xfer()
2830 ((u_int8_t *)&pccb->csio.sense_data)[0] = (0x1 << 7 | 0x70); in arcmsr_iop_message_xfer()
2832 ((u_int8_t *)&pccb->csio.sense_data)[2] = 0x05; in arcmsr_iop_message_xfer()
2834 ((u_int8_t *)&pccb->csio.sense_data)[7] = 0x0A; in arcmsr_iop_message_xfer()
2836 ((u_int8_t *)&pccb->csio.sense_data)[12] = 0x20; in arcmsr_iop_message_xfer()
2841 my_empty_len = (wqbuf_firstindex-wqbuf_lastindex - 1) in arcmsr_iop_message_xfer()
2842 &(ARCMSR_MAX_QBUFFER - 1); in arcmsr_iop_message_xfer()
2845 pQbuffer = &acb->wqbuffer[acb->wqbuf_lastindex]; in arcmsr_iop_message_xfer()
2847 acb->wqbuf_lastindex++; in arcmsr_iop_message_xfer()
2848 acb->wqbuf_lastindex %= ARCMSR_MAX_QBUFFER; in arcmsr_iop_message_xfer()
2850 user_len--; in arcmsr_iop_message_xfer()
2852 if (acb->acb_flags & ACB_F_MESSAGE_WQBUFFER_CLEARED) { in arcmsr_iop_message_xfer()
2853 acb->acb_flags &= in arcmsr_iop_message_xfer()
2859 if(pccb->csio.sense_len) { in arcmsr_iop_message_xfer()
2860 ((u_int8_t *)&pccb->csio.sense_data)[0] = (0x1 << 7 | 0x70); in arcmsr_iop_message_xfer()
2862 ((u_int8_t *)&pccb->csio.sense_data)[2] = 0x05; in arcmsr_iop_message_xfer()
2864 ((u_int8_t *)&pccb->csio.sense_data)[7] = 0x0A; in arcmsr_iop_message_xfer()
2866 ((u_int8_t *)&pccb->csio.sense_data)[12] = 0x20; in arcmsr_iop_message_xfer()
2872 ARCMSR_LOCK_RELEASE(&acb->qbuffer_lock); in arcmsr_iop_message_xfer()
2876 u_int8_t *pQbuffer = acb->rqbuffer; in arcmsr_iop_message_xfer()
2878 ARCMSR_LOCK_ACQUIRE(&acb->qbuffer_lock); in arcmsr_iop_message_xfer()
2879 if (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) { in arcmsr_iop_message_xfer()
2880 acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW; in arcmsr_iop_message_xfer()
2883 acb->acb_flags |= ACB_F_MESSAGE_RQBUFFER_CLEARED; in arcmsr_iop_message_xfer()
2884 acb->rqbuf_firstindex = 0; in arcmsr_iop_message_xfer()
2885 acb->rqbuf_lastindex = 0; in arcmsr_iop_message_xfer()
2887 pcmdmessagefld->cmdmessage.ReturnCode = in arcmsr_iop_message_xfer()
2889 ARCMSR_LOCK_RELEASE(&acb->qbuffer_lock); in arcmsr_iop_message_xfer()
2893 u_int8_t *pQbuffer = acb->wqbuffer; in arcmsr_iop_message_xfer()
2895 ARCMSR_LOCK_ACQUIRE(&acb->qbuffer_lock); in arcmsr_iop_message_xfer()
2896 if (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) { in arcmsr_iop_message_xfer()
2897 acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW; in arcmsr_iop_message_xfer()
2900 acb->acb_flags |= in arcmsr_iop_message_xfer()
2903 acb->wqbuf_firstindex = 0; in arcmsr_iop_message_xfer()
2904 acb->wqbuf_lastindex = 0; in arcmsr_iop_message_xfer()
2906 pcmdmessagefld->cmdmessage.ReturnCode = in arcmsr_iop_message_xfer()
2908 ARCMSR_LOCK_RELEASE(&acb->qbuffer_lock); in arcmsr_iop_message_xfer()
2914 ARCMSR_LOCK_ACQUIRE(&acb->qbuffer_lock); in arcmsr_iop_message_xfer()
2915 if (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) { in arcmsr_iop_message_xfer()
2916 acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW; in arcmsr_iop_message_xfer()
2919 acb->acb_flags |= in arcmsr_iop_message_xfer()
2923 acb->rqbuf_firstindex = 0; in arcmsr_iop_message_xfer()
2924 acb->rqbuf_lastindex = 0; in arcmsr_iop_message_xfer()
2925 acb->wqbuf_firstindex = 0; in arcmsr_iop_message_xfer()
2926 acb->wqbuf_lastindex = 0; in arcmsr_iop_message_xfer()
2927 pQbuffer = acb->rqbuffer; in arcmsr_iop_message_xfer()
2929 pQbuffer = acb->wqbuffer; in arcmsr_iop_message_xfer()
2931 pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_OK; in arcmsr_iop_message_xfer()
2932 ARCMSR_LOCK_RELEASE(&acb->qbuffer_lock); in arcmsr_iop_message_xfer()
2936 pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_3F; in arcmsr_iop_message_xfer()
2942 memcpy(pcmdmessagefld->messagedatabuffer, hello_string in arcmsr_iop_message_xfer()
2944 pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_OK; in arcmsr_iop_message_xfer()
2966 struct AdapterControlBlock *acb = (struct AdapterControlBlock *)srb->acb; in arcmsr_execute_srb()
2970 pccb = srb->pccb; in arcmsr_execute_srb()
2971 target = pccb->ccb_h.target_id; in arcmsr_execute_srb()
2972 lun = pccb->ccb_h.target_lun; in arcmsr_execute_srb()
2973 acb->pktRequestCount++; in arcmsr_execute_srb()
2978 , acb->pci_unit, error); in arcmsr_execute_srb()
2980 if((pccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_INPROG) { in arcmsr_execute_srb()
2981 pccb->ccb_h.status |= CAM_REQ_TOO_BIG; in arcmsr_execute_srb()
2987 pccb->ccb_h.status |= CAM_REQ_TOO_BIG; in arcmsr_execute_srb()
2991 if(acb->acb_flags & ACB_F_BUS_RESET) { in arcmsr_execute_srb()
2992 printf("arcmsr%d: bus reset and return busy \n", acb->pci_unit); in arcmsr_execute_srb()
2993 pccb->ccb_h.status |= CAM_SCSI_BUS_RESET; in arcmsr_execute_srb()
2997 if(acb->devstate[target][lun] == ARECA_RAID_GONE) { in arcmsr_execute_srb()
3000 cmd = scsiio_cdb_ptr(&pccb->csio)[0]; in arcmsr_execute_srb()
3005 , acb->pci_unit, cmd, target, lun); in arcmsr_execute_srb()
3006 pccb->ccb_h.status |= CAM_DEV_NOT_THERE; in arcmsr_execute_srb()
3011 if((pccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_INPROG) { in arcmsr_execute_srb()
3013 bus_dmamap_unload(acb->dm_segs_dmat, srb->dm_segs_dmamap); in arcmsr_execute_srb()
3018 if(acb->srboutstandingcount >= acb->maxOutstanding) { in arcmsr_execute_srb()
3019 if((acb->acb_flags & ACB_F_CAM_DEV_QFRZN) == 0) in arcmsr_execute_srb()
3021 xpt_freeze_simq(acb->psim, 1); in arcmsr_execute_srb()
3022 acb->acb_flags |= ACB_F_CAM_DEV_QFRZN; in arcmsr_execute_srb()
3024 pccb->ccb_h.status &= ~CAM_SIM_QUEUED; in arcmsr_execute_srb()
3025 pccb->ccb_h.status |= CAM_REQUEUE_REQ; in arcmsr_execute_srb()
3029 pccb->ccb_h.status |= CAM_SIM_QUEUED; in arcmsr_execute_srb()
3032 if (pccb->ccb_h.timeout != CAM_TIME_INFINITY) in arcmsr_execute_srb()
3034 arcmsr_callout_init(&srb->ccb_callout); in arcmsr_execute_srb()
3035 callout_reset_sbt(&srb->ccb_callout, SBT_1MS * in arcmsr_execute_srb()
3036 (pccb->ccb_h.timeout + (ARCMSR_TIMEOUT_DELAY * 1000)), 0, in arcmsr_execute_srb()
3038 srb->srb_flags |= SRB_FLAG_TIMER_START; in arcmsr_execute_srb()
3048 struct AdapterControlBlock *acb = (struct AdapterControlBlock *) abortccb->ccb_h.arcmsr_ccbacb_ptr; in arcmsr_seek_cmd2abort()
3052 acb->num_aborts++; in arcmsr_seek_cmd2abort()
3062 if(acb->srboutstandingcount != 0) { in arcmsr_seek_cmd2abort()
3066 srb = acb->psrb_pool[i]; in arcmsr_seek_cmd2abort()
3067 if(srb->srb_state == ARCMSR_SRB_START) { in arcmsr_seek_cmd2abort()
3068 if(srb->pccb == abortccb) { in arcmsr_seek_cmd2abort()
3069 srb->srb_state = ARCMSR_SRB_ABORTED; in arcmsr_seek_cmd2abort()
3072 , acb->pci_unit, abortccb->ccb_h.target_id in arcmsr_seek_cmd2abort()
3073 , (uintmax_t)abortccb->ccb_h.target_lun, srb); in arcmsr_seek_cmd2abort()
3094 acb->num_resets++; in arcmsr_bus_reset()
3095 acb->acb_flags |= ACB_F_BUS_RESET; in arcmsr_bus_reset()
3096 while(acb->srboutstandingcount != 0 && retry < 400) { in arcmsr_bus_reset()
3102 acb->acb_flags &= ~ACB_F_BUS_RESET; in arcmsr_bus_reset()
3111 if (pccb->ccb_h.target_lun) { in arcmsr_handle_virtual_command()
3112 pccb->ccb_h.status |= CAM_DEV_NOT_THERE; in arcmsr_handle_virtual_command()
3116 pccb->ccb_h.status |= CAM_REQ_CMP; in arcmsr_handle_virtual_command()
3117 switch (scsiio_cdb_ptr(&pccb->csio)[0]) { in arcmsr_handle_virtual_command()
3120 char *buffer = pccb->csio.data_ptr; in arcmsr_handle_virtual_command()
3140 pccb->ccb_h.status |= CAM_SCSI_STATUS_ERROR; in arcmsr_handle_virtual_command()
3141 pccb->csio.scsi_status = SCSI_STATUS_CHECK_COND; in arcmsr_handle_virtual_command()
3160 pccb->ccb_h.status |= CAM_REQ_INVALID; in arcmsr_action()
3164 switch (pccb->ccb_h.func_code) { in arcmsr_action()
3167 int target = pccb->ccb_h.target_id; in arcmsr_action()
3170 if (pccb->ccb_h.flags & CAM_CDB_PHYS) { in arcmsr_action()
3171 pccb->ccb_h.status = CAM_REQ_INVALID; in arcmsr_action()
3182 pccb->ccb_h.status |= CAM_RESRC_UNAVAIL; in arcmsr_action()
3186 pccb->ccb_h.arcmsr_ccbsrb_ptr = srb; in arcmsr_action()
3187 pccb->ccb_h.arcmsr_ccbacb_ptr = acb; in arcmsr_action()
3188 srb->pccb = pccb; in arcmsr_action()
3189 error = bus_dmamap_load_ccb(acb->dm_segs_dmat in arcmsr_action()
3190 , srb->dm_segs_dmamap in arcmsr_action()
3194 xpt_freeze_simq(acb->psim, 1); in arcmsr_action()
3195 pccb->ccb_h.status |= CAM_RELEASE_SIMQ; in arcmsr_action()
3200 struct ccb_pathinq *cpi = &pccb->cpi; in arcmsr_action()
3202 cpi->version_num = 1; in arcmsr_action()
3203 cpi->hba_inquiry = PI_SDTR_ABLE | PI_TAG_ABLE; in arcmsr_action()
3204 cpi->target_sprt = 0; in arcmsr_action()
3205 cpi->hba_misc = 0; in arcmsr_action()
3206 cpi->hba_eng_cnt = 0; in arcmsr_action()
3207 cpi->max_target = ARCMSR_MAX_TARGETID; /* 0-16 */ in arcmsr_action()
3208 cpi->max_lun = ARCMSR_MAX_TARGETLUN; /* 0-7 */ in arcmsr_action()
3209 cpi->initiator_id = ARCMSR_SCSI_INITIATOR_ID; /* 255 */ in arcmsr_action()
3210 cpi->bus_id = cam_sim_bus(psim); in arcmsr_action()
3211 strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); in arcmsr_action()
3212 strlcpy(cpi->hba_vid, "ARCMSR", HBA_IDLEN); in arcmsr_action()
3213 strlcpy(cpi->dev_name, cam_sim_name(psim), DEV_IDLEN); in arcmsr_action()
3214 cpi->unit_number = cam_sim_unit(psim); in arcmsr_action()
3215 if(acb->adapter_bus_speed == ACB_BUS_SPEED_12G) in arcmsr_action()
3216 cpi->base_transfer_speed = 1200000; in arcmsr_action()
3217 else if(acb->adapter_bus_speed == ACB_BUS_SPEED_6G) in arcmsr_action()
3218 cpi->base_transfer_speed = 600000; in arcmsr_action()
3220 cpi->base_transfer_speed = 300000; in arcmsr_action()
3221 if((acb->vendor_device_id == PCIDevVenIDARC1880) || in arcmsr_action()
3222 (acb->vendor_device_id == PCIDevVenIDARC1883) || in arcmsr_action()
3223 (acb->vendor_device_id == PCIDevVenIDARC1884) || in arcmsr_action()
3224 (acb->vendor_device_id == PCIDevVenIDARC1886) || in arcmsr_action()
3225 (acb->vendor_device_id == PCIDevVenIDARC1680) || in arcmsr_action()
3226 (acb->vendor_device_id == PCIDevVenIDARC1214)) in arcmsr_action()
3228 cpi->transport = XPORT_SAS; in arcmsr_action()
3229 cpi->transport_version = 0; in arcmsr_action()
3230 cpi->protocol_version = SCSI_REV_SPC2; in arcmsr_action()
3234 cpi->transport = XPORT_SPI; in arcmsr_action()
3235 cpi->transport_version = 2; in arcmsr_action()
3236 cpi->protocol_version = SCSI_REV_2; in arcmsr_action()
3238 cpi->protocol = PROTO_SCSI; in arcmsr_action()
3239 cpi->ccb_h.status |= CAM_REQ_CMP; in arcmsr_action()
3246 pabort_ccb = pccb->cab.abort_ccb; in arcmsr_action()
3247 switch (pabort_ccb->ccb_h.func_code) { in arcmsr_action()
3251 pabort_ccb->ccb_h.status |= CAM_REQ_ABORTED; in arcmsr_action()
3253 pccb->ccb_h.status |= CAM_REQ_CMP; in arcmsr_action()
3255 xpt_print_path(pabort_ccb->ccb_h.path); in arcmsr_action()
3257 pccb->ccb_h.status |= CAM_PATH_INVALID; in arcmsr_action()
3261 pccb->ccb_h.status |= CAM_UA_ABORT; in arcmsr_action()
3264 pccb->ccb_h.status |= CAM_REQ_INVALID; in arcmsr_action()
3278 pccb->ccb_h.status |= CAM_REQ_CMP; in arcmsr_action()
3283 pccb->ccb_h.status |= CAM_REQ_INVALID; in arcmsr_action()
3290 if(pccb->ccb_h.target_id == ARCMSR_VIRTUAL_DEVICE_ID) { in arcmsr_action()
3291 pccb->ccb_h.status |= CAM_FUNC_NOTAVAIL; in arcmsr_action()
3295 cts = &pccb->cts; in arcmsr_action()
3301 scsi = &cts->proto_specific.scsi; in arcmsr_action()
3302 scsi->flags = CTS_SCSI_FLAGS_TAG_ENB; in arcmsr_action()
3303 scsi->valid = CTS_SCSI_VALID_TQ; in arcmsr_action()
3304 cts->protocol = PROTO_SCSI; in arcmsr_action()
3306 if((acb->vendor_device_id == PCIDevVenIDARC1880) || in arcmsr_action()
3307 (acb->vendor_device_id == PCIDevVenIDARC1883) || in arcmsr_action()
3308 (acb->vendor_device_id == PCIDevVenIDARC1884) || in arcmsr_action()
3309 (acb->vendor_device_id == PCIDevVenIDARC1886) || in arcmsr_action()
3310 (acb->vendor_device_id == PCIDevVenIDARC1680) || in arcmsr_action()
3311 (acb->vendor_device_id == PCIDevVenIDARC1214)) in arcmsr_action()
3313 cts->protocol_version = SCSI_REV_SPC2; in arcmsr_action()
3314 cts->transport_version = 0; in arcmsr_action()
3315 cts->transport = XPORT_SAS; in arcmsr_action()
3316 sas = &cts->xport_specific.sas; in arcmsr_action()
3317 sas->valid = CTS_SAS_VALID_SPEED; in arcmsr_action()
3318 if (acb->adapter_bus_speed == ACB_BUS_SPEED_12G) in arcmsr_action()
3319 sas->bitrate = 1200000; in arcmsr_action()
3320 else if(acb->adapter_bus_speed == ACB_BUS_SPEED_6G) in arcmsr_action()
3321 sas->bitrate = 600000; in arcmsr_action()
3322 else if(acb->adapter_bus_speed == ACB_BUS_SPEED_3G) in arcmsr_action()
3323 sas->bitrate = 300000; in arcmsr_action()
3327 cts->protocol_version = SCSI_REV_2; in arcmsr_action()
3328 cts->transport_version = 2; in arcmsr_action()
3329 cts->transport = XPORT_SPI; in arcmsr_action()
3330 spi = &cts->xport_specific.spi; in arcmsr_action()
3331 spi->flags = CTS_SPI_FLAGS_DISC_ENB; in arcmsr_action()
3332 if (acb->adapter_bus_speed == ACB_BUS_SPEED_6G) in arcmsr_action()
3333 spi->sync_period = 1; in arcmsr_action()
3335 spi->sync_period = 2; in arcmsr_action()
3336 spi->sync_offset = 32; in arcmsr_action()
3337 spi->bus_width = MSG_EXT_WDTR_BUS_16_BIT; in arcmsr_action()
3338 spi->valid = CTS_SPI_VALID_DISC in arcmsr_action()
3344 pccb->ccb_h.status |= CAM_REQ_CMP; in arcmsr_action()
3349 pccb->ccb_h.status |= CAM_FUNC_NOTAVAIL; in arcmsr_action()
3354 if(pccb->ccb_h.target_id == ARCMSR_VIRTUAL_DEVICE_ID) { in arcmsr_action()
3355 pccb->ccb_h.status |= CAM_FUNC_NOTAVAIL; in arcmsr_action()
3359 cam_calc_geometry(&pccb->ccg, 1); in arcmsr_action()
3363 pccb->ccb_h.status |= CAM_REQ_INVALID; in arcmsr_action()
3374 acb->acb_flags |= ACB_F_MSG_START_BGRB; in arcmsr_start_hba_bgrb()
3377 printf("arcmsr%d: wait 'start adapter background rebuild' timeout \n", acb->pci_unit); in arcmsr_start_hba_bgrb()
3386 struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_start_hbb_bgrb()
3387 acb->acb_flags |= ACB_F_MSG_START_BGRB; in arcmsr_start_hbb_bgrb()
3388 WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_MESSAGE_START_BGRB); in arcmsr_start_hbb_bgrb()
3390 printf( "arcmsr%d: wait 'start adapter background rebuild' timeout \n", acb->pci_unit); in arcmsr_start_hbb_bgrb()
3399 acb->acb_flags |= ACB_F_MSG_START_BGRB; in arcmsr_start_hbc_bgrb()
3403 printf("arcmsr%d: wait 'start adapter background rebuild' timeout \n", acb->pci_unit); in arcmsr_start_hbc_bgrb()
3412 acb->acb_flags |= ACB_F_MSG_START_BGRB; in arcmsr_start_hbd_bgrb()
3415 printf("arcmsr%d: wait 'start adapter background rebuild' timeout \n", acb->pci_unit); in arcmsr_start_hbd_bgrb()
3424 acb->acb_flags |= ACB_F_MSG_START_BGRB; in arcmsr_start_hbe_bgrb()
3426 acb->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_MESSAGE_CMD_DONE; in arcmsr_start_hbe_bgrb()
3427 CHIP_REG_WRITE32(HBE_MessageUnit, 0, iobound_doorbell, acb->out_doorbell); in arcmsr_start_hbe_bgrb()
3429 printf("arcmsr%d: wait 'start adapter background rebuild' timeout \n", acb->pci_unit); in arcmsr_start_hbe_bgrb()
3438 switch (acb->adapter_type) { in arcmsr_start_adapter_bgrb()
3470 …outbound_intstatus=CHIP_REG_READ32(HBA_MessageUnit, 0, outbound_intstatus) & acb->outbound_int_ena… in arcmsr_polling_hba_srbdone()
3472 bus_dmamap_sync(acb->srb_dmat, acb->srb_dmamap, BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE); in arcmsr_polling_hba_srbdone()
3488 (acb->vir2phy_offset+(flag_srb << 5));/*frame must be 32 bytes aligned*/ in arcmsr_polling_hba_srbdone()
3491 if((srb->acb != acb) || (srb->srb_state != ARCMSR_SRB_START)) { in arcmsr_polling_hba_srbdone()
3492 if(srb->srb_state == ARCMSR_SRB_ABORTED) { in arcmsr_polling_hba_srbdone()
3495 , acb->pci_unit in arcmsr_polling_hba_srbdone()
3496 , srb->pccb->ccb_h.target_id in arcmsr_polling_hba_srbdone()
3497 , (uintmax_t)srb->pccb->ccb_h.target_lun, srb); in arcmsr_polling_hba_srbdone()
3498 srb->pccb->ccb_h.status |= CAM_REQ_ABORTED; in arcmsr_polling_hba_srbdone()
3504 , acb->pci_unit in arcmsr_polling_hba_srbdone()
3505 , srb, acb->srboutstandingcount); in arcmsr_polling_hba_srbdone()
3518 struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_polling_hbb_srbdone()
3526 …WRITE_CHIP_REG32(0, phbbmu->iop2drv_doorbell, ARCMSR_DOORBELL_INT_CLEAR_PATTERN); /* clear doorbel… in arcmsr_polling_hbb_srbdone()
3527 bus_dmamap_sync(acb->srb_dmat, acb->srb_dmamap, BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE); in arcmsr_polling_hbb_srbdone()
3529 index = phbbmu->doneq_index; in arcmsr_polling_hbb_srbdone()
3530 if((flag_srb = phbbmu->done_qbuffer[index]) == 0) { in arcmsr_polling_hbb_srbdone()
3541 phbbmu->done_qbuffer[index] = 0; in arcmsr_polling_hbb_srbdone()
3544 phbbmu->doneq_index = index; in arcmsr_polling_hbb_srbdone()
3547 (acb->vir2phy_offset+(flag_srb << 5));/*frame must be 32 bytes aligned*/ in arcmsr_polling_hbb_srbdone()
3550 if((srb->acb != acb) || (srb->srb_state != ARCMSR_SRB_START)) { in arcmsr_polling_hbb_srbdone()
3551 if(srb->srb_state == ARCMSR_SRB_ABORTED) { in arcmsr_polling_hbb_srbdone()
3554 , acb->pci_unit in arcmsr_polling_hbb_srbdone()
3555 , srb->pccb->ccb_h.target_id in arcmsr_polling_hbb_srbdone()
3556 , (uintmax_t)srb->pccb->ccb_h.target_lun, srb); in arcmsr_polling_hbb_srbdone()
3557 srb->pccb->ccb_h.status |= CAM_REQ_ABORTED; in arcmsr_polling_hbb_srbdone()
3563 , acb->pci_unit in arcmsr_polling_hbb_srbdone()
3564 , srb, acb->srboutstandingcount); in arcmsr_polling_hbb_srbdone()
3583 bus_dmamap_sync(acb->srb_dmat, acb->srb_dmamap, BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE); in arcmsr_polling_hbc_srbdone()
3593 if (acb->srboutstandingcount == 0) { in arcmsr_polling_hbc_srbdone()
3601 …srb = (struct CommandControlBlock *)(acb->vir2phy_offset+(flag_srb & 0xFFFFFFE0));/*frame must be … in arcmsr_polling_hbc_srbdone()
3605 if((srb->acb != acb) || (srb->srb_state != ARCMSR_SRB_START)) { in arcmsr_polling_hbc_srbdone()
3606 if(srb->srb_state == ARCMSR_SRB_ABORTED) { in arcmsr_polling_hbc_srbdone()
3608 , acb->pci_unit, srb->pccb->ccb_h.target_id, (uintmax_t)srb->pccb->ccb_h.target_lun, srb); in arcmsr_polling_hbc_srbdone()
3609 srb->pccb->ccb_h.status |= CAM_REQ_ABORTED; in arcmsr_polling_hbc_srbdone()
3614 , acb->pci_unit, srb, acb->srboutstandingcount); in arcmsr_polling_hbc_srbdone()
3627 struct HBD_MessageUnit0 *phbdmu = (struct HBD_MessageUnit0 *)acb->pmu; in arcmsr_polling_hbd_srbdone()
3635 bus_dmamap_sync(acb->srb_dmat, acb->srb_dmamap, BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE); in arcmsr_polling_hbd_srbdone()
3637 outbound_write_pointer = phbdmu->done_qbuffer[0].addressLow; in arcmsr_polling_hbd_srbdone()
3638 doneq_index = phbdmu->doneq_index; in arcmsr_polling_hbd_srbdone()
3647 if (acb->srboutstandingcount == 0) { in arcmsr_polling_hbd_srbdone()
3654 flag_srb = phbdmu->done_qbuffer[(doneq_index & 0xFF)+1].addressLow; in arcmsr_polling_hbd_srbdone()
3656 …srb = (struct CommandControlBlock *)(acb->vir2phy_offset+(flag_srb & 0xFFFFFFE0));/*frame must be … in arcmsr_polling_hbd_srbdone()
3661 if((srb->acb != acb) || (srb->srb_state != ARCMSR_SRB_START)) { in arcmsr_polling_hbd_srbdone()
3662 if(srb->srb_state == ARCMSR_SRB_ABORTED) { in arcmsr_polling_hbd_srbdone()
3664 , acb->pci_unit, srb->pccb->ccb_h.target_id, (uintmax_t)srb->pccb->ccb_h.target_lun, srb); in arcmsr_polling_hbd_srbdone()
3665 srb->pccb->ccb_h.status |= CAM_REQ_ABORTED; in arcmsr_polling_hbd_srbdone()
3670 , acb->pci_unit, srb, acb->srboutstandingcount); in arcmsr_polling_hbd_srbdone()
3689 bus_dmamap_sync(acb->srb_dmat, acb->srb_dmamap, BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE); in arcmsr_polling_hbe_srbdone()
3691 doneq_index = acb->doneq_index; in arcmsr_polling_hbe_srbdone()
3700 if (acb->srboutstandingcount == 0) { in arcmsr_polling_hbe_srbdone()
3706 cmdSMID = acb->pCompletionQ[doneq_index].cmdSMID; in arcmsr_polling_hbe_srbdone()
3708 if (doneq_index >= acb->completionQ_entry) in arcmsr_polling_hbe_srbdone()
3710 acb->doneq_index = doneq_index; in arcmsr_polling_hbe_srbdone()
3711 srb = acb->psrb_pool[cmdSMID]; in arcmsr_polling_hbe_srbdone()
3712 …error = (acb->pCompletionQ[doneq_index].cmdFlag & ARCMSR_SRBREPLY_FLAG_ERROR_MODE1) ? TRUE : FALSE; in arcmsr_polling_hbe_srbdone()
3715 if((srb->acb != acb) || (srb->srb_state != ARCMSR_SRB_START)) { in arcmsr_polling_hbe_srbdone()
3716 if(srb->srb_state == ARCMSR_SRB_ABORTED) { in arcmsr_polling_hbe_srbdone()
3718 , acb->pci_unit, srb->pccb->ccb_h.target_id, (uintmax_t)srb->pccb->ccb_h.target_lun, srb); in arcmsr_polling_hbe_srbdone()
3719 srb->pccb->ccb_h.status |= CAM_REQ_ABORTED; in arcmsr_polling_hbe_srbdone()
3724 , acb->pci_unit, srb, acb->srboutstandingcount); in arcmsr_polling_hbe_srbdone()
3737 switch (acb->adapter_type) { in arcmsr_polling_srbdone()
3762 char *acb_firm_model = acb->firm_model; in arcmsr_get_hba_config()
3763 char *acb_firm_version = acb->firm_version; in arcmsr_get_hba_config()
3764 char *acb_device_map = acb->device_map; in arcmsr_get_hba_config()
3765 … offsetof(struct HBA_MessageUnit,msgcode_rwbuffer[ARCMSR_FW_MODEL_OFFSET]); /*firm_model,15,60-67*/ in arcmsr_get_hba_config()
3766 …offsetof(struct HBA_MessageUnit,msgcode_rwbuffer[ARCMSR_FW_VERS_OFFSET]); /*firm_version,17,68-83*/ in arcmsr_get_hba_config()
3772 printf("arcmsr%d: wait 'get adapter firmware miscellaneous data' timeout \n", acb->pci_unit); in arcmsr_get_hba_config()
3776 *acb_firm_model = bus_space_read_1(acb->btag[0], acb->bhandle[0], iop_firm_model+i); in arcmsr_get_hba_config()
3777 /* 8 bytes firm_model, 15, 60-67*/ in arcmsr_get_hba_config()
3783 *acb_firm_version = bus_space_read_1(acb->btag[0], acb->bhandle[0], iop_firm_version+i); in arcmsr_get_hba_config()
3784 /* 16 bytes firm_version, 17, 68-83*/ in arcmsr_get_hba_config()
3790 *acb_device_map = bus_space_read_1(acb->btag[0], acb->bhandle[0], iop_device_map+i); in arcmsr_get_hba_config()
3794 …printf("Areca RAID adapter%d: %s F/W version %s \n", acb->pci_unit, acb->firm_model, acb->firm_ver… in arcmsr_get_hba_config()
3795 …acb->firm_request_len = CHIP_REG_READ32(HBA_MessageUnit, 0, msgcode_rwbuffer[1]); /*firm_request… in arcmsr_get_hba_config()
3796 …acb->firm_numbers_queue = CHIP_REG_READ32(HBA_MessageUnit, 0, msgcode_rwbuffer[2]); /*firm_numbers… in arcmsr_get_hba_config()
3797 …acb->firm_sdram_size = CHIP_REG_READ32(HBA_MessageUnit, 0, msgcode_rwbuffer[3]); /*firm_sdram_s… in arcmsr_get_hba_config()
3798 …acb->firm_ide_channels = CHIP_REG_READ32(HBA_MessageUnit, 0, msgcode_rwbuffer[4]); /*firm_ide_cha… in arcmsr_get_hba_config()
3799 …acb->firm_cfg_version = CHIP_REG_READ32(HBA_MessageUnit, 0, msgcode_rwbuffer[ARCMSR_FW_CFGVER_OFFS… in arcmsr_get_hba_config()
3800 if(acb->firm_numbers_queue > ARCMSR_MAX_OUTSTANDING_CMD) in arcmsr_get_hba_config()
3801 acb->maxOutstanding = ARCMSR_MAX_OUTSTANDING_CMD - 1; in arcmsr_get_hba_config()
3803 acb->maxOutstanding = acb->firm_numbers_queue - 1; in arcmsr_get_hba_config()
3811 struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_get_hbb_config()
3812 char *acb_firm_model = acb->firm_model; in arcmsr_get_hbb_config()
3813 char *acb_firm_version = acb->firm_version; in arcmsr_get_hbb_config()
3814 char *acb_device_map = acb->device_map; in arcmsr_get_hbb_config()
3815 … = offsetof(struct HBB_RWBUFFER, msgcode_rwbuffer[ARCMSR_FW_MODEL_OFFSET]); /*firm_model,15,60-67*/ in arcmsr_get_hbb_config()
3816 …= offsetof(struct HBB_RWBUFFER, msgcode_rwbuffer[ARCMSR_FW_VERS_OFFSET]); /*firm_version,17,68-83*/ in arcmsr_get_hbb_config()
3820 WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_MESSAGE_GET_CONFIG); in arcmsr_get_hbb_config()
3822 printf( "arcmsr%d: wait" "'get adapter firmware miscellaneous data' timeout \n", acb->pci_unit); in arcmsr_get_hbb_config()
3826 *acb_firm_model = bus_space_read_1(acb->btag[1], acb->bhandle[1], iop_firm_model+i); in arcmsr_get_hbb_config()
3827 /* 8 bytes firm_model, 15, 60-67*/ in arcmsr_get_hbb_config()
3833 *acb_firm_version = bus_space_read_1(acb->btag[1], acb->bhandle[1], iop_firm_version+i); in arcmsr_get_hbb_config()
3834 /* 16 bytes firm_version, 17, 68-83*/ in arcmsr_get_hbb_config()
3840 *acb_device_map = bus_space_read_1(acb->btag[1], acb->bhandle[1], iop_device_map+i); in arcmsr_get_hbb_config()
3844 …printf("Areca RAID adapter%d: %s F/W version %s \n", acb->pci_unit, acb->firm_model, acb->firm_ver… in arcmsr_get_hbb_config()
3845 …acb->firm_request_len = CHIP_REG_READ32(HBB_RWBUFFER, 1, msgcode_rwbuffer[1]); /*firm_request_le… in arcmsr_get_hbb_config()
3846 …acb->firm_numbers_queue = CHIP_REG_READ32(HBB_RWBUFFER, 1, msgcode_rwbuffer[2]); /*firm_numbers_qu… in arcmsr_get_hbb_config()
3847 …acb->firm_sdram_size = CHIP_REG_READ32(HBB_RWBUFFER, 1, msgcode_rwbuffer[3]); /*firm_sdram_size… in arcmsr_get_hbb_config()
3848 …acb->firm_ide_channels = CHIP_REG_READ32(HBB_RWBUFFER, 1, msgcode_rwbuffer[4]); /*firm_ide_channe… in arcmsr_get_hbb_config()
3849 …acb->firm_cfg_version = CHIP_REG_READ32(HBB_RWBUFFER, 1, msgcode_rwbuffer[ARCMSR_FW_CFGVER_OFFSET]… in arcmsr_get_hbb_config()
3850 if(acb->firm_numbers_queue > ARCMSR_MAX_HBB_POSTQUEUE) in arcmsr_get_hbb_config()
3851 acb->maxOutstanding = ARCMSR_MAX_HBB_POSTQUEUE - 1; in arcmsr_get_hbb_config()
3853 acb->maxOutstanding = acb->firm_numbers_queue - 1; in arcmsr_get_hbb_config()
3861 char *acb_firm_model = acb->firm_model; in arcmsr_get_hbc_config()
3862 char *acb_firm_version = acb->firm_version; in arcmsr_get_hbc_config()
3863 char *acb_device_map = acb->device_map; in arcmsr_get_hbc_config()
3864 …ffsetof(struct HBC_MessageUnit,msgcode_rwbuffer[ARCMSR_FW_MODEL_OFFSET]); /*firm_model,15,60-67*/ in arcmsr_get_hbc_config()
3865 …offsetof(struct HBC_MessageUnit,msgcode_rwbuffer[ARCMSR_FW_VERS_OFFSET]); /*firm_version,17,68-83*/ in arcmsr_get_hbc_config()
3872 printf("arcmsr%d: wait 'get adapter firmware miscellaneous data' timeout \n", acb->pci_unit); in arcmsr_get_hbc_config()
3876 *acb_firm_model = bus_space_read_1(acb->btag[0], acb->bhandle[0], iop_firm_model+i); in arcmsr_get_hbc_config()
3877 /* 8 bytes firm_model, 15, 60-67*/ in arcmsr_get_hbc_config()
3883 *acb_firm_version = bus_space_read_1(acb->btag[0], acb->bhandle[0], iop_firm_version+i); in arcmsr_get_hbc_config()
3884 /* 16 bytes firm_version, 17, 68-83*/ in arcmsr_get_hbc_config()
3890 *acb_device_map = bus_space_read_1(acb->btag[0], acb->bhandle[0], iop_device_map+i); in arcmsr_get_hbc_config()
3894 …printf("Areca RAID adapter%d: %s F/W version %s \n", acb->pci_unit, acb->firm_model, acb->firm_ver… in arcmsr_get_hbc_config()
3895 …acb->firm_request_len = CHIP_REG_READ32(HBC_MessageUnit, 0, msgcode_rwbuffer[1]); /*firm_request_l… in arcmsr_get_hbc_config()
3896 …acb->firm_numbers_queue = CHIP_REG_READ32(HBC_MessageUnit, 0, msgcode_rwbuffer[2]); /*firm_numbers… in arcmsr_get_hbc_config()
3897 …acb->firm_sdram_size = CHIP_REG_READ32(HBC_MessageUnit, 0, msgcode_rwbuffer[3]); /*firm_sdram_size… in arcmsr_get_hbc_config()
3898 …acb->firm_ide_channels = CHIP_REG_READ32(HBC_MessageUnit, 0, msgcode_rwbuffer[4]); /*firm_ide_chan… in arcmsr_get_hbc_config()
3899 …acb->firm_cfg_version = CHIP_REG_READ32(HBC_MessageUnit, 0, msgcode_rwbuffer[ARCMSR_FW_CFGVER_OFFS… in arcmsr_get_hbc_config()
3900 if(acb->firm_numbers_queue > ARCMSR_MAX_OUTSTANDING_CMD) in arcmsr_get_hbc_config()
3901 acb->maxOutstanding = ARCMSR_MAX_OUTSTANDING_CMD - 1; in arcmsr_get_hbc_config()
3903 acb->maxOutstanding = acb->firm_numbers_queue - 1; in arcmsr_get_hbc_config()
3911 char *acb_firm_model = acb->firm_model; in arcmsr_get_hbd_config()
3912 char *acb_firm_version = acb->firm_version; in arcmsr_get_hbd_config()
3913 char *acb_device_map = acb->device_map; in arcmsr_get_hbd_config()
3914 …fsetof(struct HBD_MessageUnit, msgcode_rwbuffer[ARCMSR_FW_MODEL_OFFSET]); /*firm_model,15,60-67*/ in arcmsr_get_hbd_config()
3915 …ffsetof(struct HBD_MessageUnit, msgcode_rwbuffer[ARCMSR_FW_VERS_OFFSET]); /*firm_version,17,68-83*/ in arcmsr_get_hbd_config()
3923 printf("arcmsr%d: wait 'get adapter firmware miscellaneous data' timeout \n", acb->pci_unit); in arcmsr_get_hbd_config()
3927 *acb_firm_model = bus_space_read_1(acb->btag[0], acb->bhandle[0], iop_firm_model+i); in arcmsr_get_hbd_config()
3928 /* 8 bytes firm_model, 15, 60-67*/ in arcmsr_get_hbd_config()
3934 *acb_firm_version = bus_space_read_1(acb->btag[0], acb->bhandle[0], iop_firm_version+i); in arcmsr_get_hbd_config()
3935 /* 16 bytes firm_version, 17, 68-83*/ in arcmsr_get_hbd_config()
3941 *acb_device_map = bus_space_read_1(acb->btag[0], acb->bhandle[0], iop_device_map+i); in arcmsr_get_hbd_config()
3945 …printf("Areca RAID adapter%d: %s F/W version %s \n", acb->pci_unit, acb->firm_model, acb->firm_ver… in arcmsr_get_hbd_config()
3946 …acb->firm_request_len = CHIP_REG_READ32(HBD_MessageUnit, 0, msgcode_rwbuffer[1]); /*firm_request_l… in arcmsr_get_hbd_config()
3947 …acb->firm_numbers_queue = CHIP_REG_READ32(HBD_MessageUnit, 0, msgcode_rwbuffer[2]); /*firm_numbers… in arcmsr_get_hbd_config()
3948 …acb->firm_sdram_size = CHIP_REG_READ32(HBD_MessageUnit, 0, msgcode_rwbuffer[3]); /*firm_sdram_size… in arcmsr_get_hbd_config()
3949 …acb->firm_ide_channels = CHIP_REG_READ32(HBD_MessageUnit, 0, msgcode_rwbuffer[4]); /*firm_ide_chan… in arcmsr_get_hbd_config()
3950 …acb->firm_cfg_version = CHIP_REG_READ32(HBD_MessageUnit, 0, msgcode_rwbuffer[ARCMSR_FW_CFGVER_OFFS… in arcmsr_get_hbd_config()
3951 if(acb->firm_numbers_queue > ARCMSR_MAX_HBD_POSTQUEUE) in arcmsr_get_hbd_config()
3952 acb->maxOutstanding = ARCMSR_MAX_HBD_POSTQUEUE - 1; in arcmsr_get_hbd_config()
3954 acb->maxOutstanding = acb->firm_numbers_queue - 1; in arcmsr_get_hbd_config()
3962 char *acb_firm_model = acb->firm_model; in arcmsr_get_hbe_config()
3963 char *acb_firm_version = acb->firm_version; in arcmsr_get_hbe_config()
3964 char *acb_device_map = acb->device_map; in arcmsr_get_hbe_config()
3965 …ffsetof(struct HBE_MessageUnit,msgcode_rwbuffer[ARCMSR_FW_MODEL_OFFSET]); /*firm_model,15,60-67*/ in arcmsr_get_hbe_config()
3966 …offsetof(struct HBE_MessageUnit,msgcode_rwbuffer[ARCMSR_FW_VERS_OFFSET]); /*firm_version,17,68-83*/ in arcmsr_get_hbe_config()
3971 acb->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_MESSAGE_CMD_DONE; in arcmsr_get_hbe_config()
3972 CHIP_REG_WRITE32(HBE_MessageUnit, 0, iobound_doorbell, acb->out_doorbell); in arcmsr_get_hbe_config()
3974 printf("arcmsr%d: wait 'get adapter firmware miscellaneous data' timeout \n", acb->pci_unit); in arcmsr_get_hbe_config()
3979 *acb_firm_model = bus_space_read_1(acb->btag[0], acb->bhandle[0], iop_firm_model+i); in arcmsr_get_hbe_config()
3980 /* 8 bytes firm_model, 15, 60-67*/ in arcmsr_get_hbe_config()
3986 *acb_firm_version = bus_space_read_1(acb->btag[0], acb->bhandle[0], iop_firm_version+i); in arcmsr_get_hbe_config()
3987 /* 16 bytes firm_version, 17, 68-83*/ in arcmsr_get_hbe_config()
3993 *acb_device_map = bus_space_read_1(acb->btag[0], acb->bhandle[0], iop_device_map+i); in arcmsr_get_hbe_config()
3997 …printf("Areca RAID adapter%d: %s F/W version %s \n", acb->pci_unit, acb->firm_model, acb->firm_ver… in arcmsr_get_hbe_config()
3998 …acb->firm_request_len = CHIP_REG_READ32(HBE_MessageUnit, 0, msgcode_rwbuffer[1]); /*firm_request_l… in arcmsr_get_hbe_config()
3999 …acb->firm_numbers_queue = CHIP_REG_READ32(HBE_MessageUnit, 0, msgcode_rwbuffer[2]); /*firm_numbers… in arcmsr_get_hbe_config()
4000 …acb->firm_sdram_size = CHIP_REG_READ32(HBE_MessageUnit, 0, msgcode_rwbuffer[3]); /*firm_sdram_size… in arcmsr_get_hbe_config()
4001 …acb->firm_ide_channels = CHIP_REG_READ32(HBE_MessageUnit, 0, msgcode_rwbuffer[4]); /*firm_ide_chan… in arcmsr_get_hbe_config()
4002 …acb->firm_cfg_version = CHIP_REG_READ32(HBE_MessageUnit, 0, msgcode_rwbuffer[ARCMSR_FW_CFGVER_OFFS… in arcmsr_get_hbe_config()
4003 if(acb->firm_numbers_queue > ARCMSR_MAX_OUTSTANDING_CMD) in arcmsr_get_hbe_config()
4004 acb->maxOutstanding = ARCMSR_MAX_OUTSTANDING_CMD - 1; in arcmsr_get_hbe_config()
4006 acb->maxOutstanding = acb->firm_numbers_queue - 1; in arcmsr_get_hbe_config()
4014 u_int32_t *acb_firm_model = (u_int32_t *)acb->firm_model; in arcmsr_get_hbf_config()
4015 u_int32_t *acb_firm_version = (u_int32_t *)acb->firm_version; in arcmsr_get_hbf_config()
4016 u_int32_t *acb_device_map = (u_int32_t *)acb->device_map; in arcmsr_get_hbf_config()
4017 size_t iop_firm_model = ARCMSR_FW_MODEL_OFFSET; /*firm_model,15,60-67*/ in arcmsr_get_hbf_config()
4018 size_t iop_firm_version = ARCMSR_FW_VERS_OFFSET; /*firm_version,17,68-83*/ in arcmsr_get_hbf_config()
4023 acb->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_MESSAGE_CMD_DONE; in arcmsr_get_hbf_config()
4024 CHIP_REG_WRITE32(HBE_MessageUnit, 0, iobound_doorbell, acb->out_doorbell); in arcmsr_get_hbf_config()
4026 printf("arcmsr%d: wait 'get adapter firmware miscellaneous data' timeout \n", acb->pci_unit); in arcmsr_get_hbf_config()
4030 *acb_firm_model = acb->msgcode_rwbuffer[iop_firm_model]; in arcmsr_get_hbf_config()
4031 /* 8 bytes firm_model, 15, 60-67*/ in arcmsr_get_hbf_config()
4038 *acb_firm_version = acb->msgcode_rwbuffer[iop_firm_version]; in arcmsr_get_hbf_config()
4039 /* 16 bytes firm_version, 17, 68-83*/ in arcmsr_get_hbf_config()
4046 *acb_device_map = acb->msgcode_rwbuffer[iop_device_map]; in arcmsr_get_hbf_config()
4051 …printf("Areca RAID adapter%d: %s F/W version %s \n", acb->pci_unit, acb->firm_model, acb->firm_ver… in arcmsr_get_hbf_config()
4052 acb->firm_request_len = acb->msgcode_rwbuffer[1]; /*firm_request_len, 1, 04-07*/ in arcmsr_get_hbf_config()
4053 acb->firm_numbers_queue = acb->msgcode_rwbuffer[2]; /*firm_numbers_queue, 2, 08-11*/ in arcmsr_get_hbf_config()
4054 acb->firm_sdram_size = acb->msgcode_rwbuffer[3]; /*firm_sdram_size, 3, 12-15*/ in arcmsr_get_hbf_config()
4055 acb->firm_ide_channels = acb->msgcode_rwbuffer[4]; /*firm_ide_channels, 4, 16-19*/ in arcmsr_get_hbf_config()
4056 acb->firm_cfg_version = acb->msgcode_rwbuffer[ARCMSR_FW_CFGVER_OFFSET]; /*firm_cfg_version, 25*/ in arcmsr_get_hbf_config()
4057 acb->firm_PicStatus = acb->msgcode_rwbuffer[ARCMSR_FW_PICSTATUS]; /* firm_PicStatus, 30 */ in arcmsr_get_hbf_config()
4058 if(acb->firm_numbers_queue > ARCMSR_MAX_OUTSTANDING_CMD) in arcmsr_get_hbf_config()
4059 acb->maxOutstanding = ARCMSR_MAX_OUTSTANDING_CMD - 1; in arcmsr_get_hbf_config()
4061 acb->maxOutstanding = acb->firm_numbers_queue - 1; in arcmsr_get_hbf_config()
4069 switch (acb->adapter_type) { in arcmsr_get_firmware_spec()
4098 switch (acb->adapter_type) { in arcmsr_wait_firmware_ready()
4104 printf( "arcmsr%d:timed out waiting for firmware \n", acb->pci_unit); in arcmsr_wait_firmware_ready()
4107 UDELAY(15000); /* wait 15 milli-seconds */ in arcmsr_wait_firmware_ready()
4112 struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_wait_firmware_ready()
4113 while ((READ_CHIP_REG32(0, phbbmu->iop2drv_doorbell) & ARCMSR_MESSAGE_FIRMWARE_OK) == 0) in arcmsr_wait_firmware_ready()
4117 printf( "arcmsr%d: timed out waiting for firmware \n", acb->pci_unit); in arcmsr_wait_firmware_ready()
4120 UDELAY(15000); /* wait 15 milli-seconds */ in arcmsr_wait_firmware_ready()
4122 WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_DRV2IOP_END_OF_INTERRUPT); in arcmsr_wait_firmware_ready()
4130 printf( "arcmsr%d:timed out waiting for firmware ready\n", acb->pci_unit); in arcmsr_wait_firmware_ready()
4133 UDELAY(15000); /* wait 15 milli-seconds */ in arcmsr_wait_firmware_ready()
4142 printf( "arcmsr%d:timed out waiting for firmware ready\n", acb->pci_unit); in arcmsr_wait_firmware_ready()
4145 UDELAY(15000); /* wait 15 milli-seconds */ in arcmsr_wait_firmware_ready()
4155 printf( "arcmsr%d:timed out waiting for firmware ready\n", acb->pci_unit); in arcmsr_wait_firmware_ready()
4158 UDELAY(15000); /* wait 15 milli-seconds */ in arcmsr_wait_firmware_ready()
4172 switch (acb->adapter_type) { in arcmsr_clear_doorbell_queue_buffer()
4181 struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_clear_doorbell_queue_buffer()
4182 …WRITE_CHIP_REG32(0, phbbmu->iop2drv_doorbell, ARCMSR_DOORBELL_INT_CLEAR_PATTERN);/*clear interrupt… in arcmsr_clear_doorbell_queue_buffer()
4183 WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_DRV2IOP_DATA_READ_OK); in arcmsr_clear_doorbell_queue_buffer()
4206 acb->in_doorbell = CHIP_REG_READ32(HBE_MessageUnit, 0, iobound_doorbell); in arcmsr_clear_doorbell_queue_buffer()
4208 acb->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_DATA_READ_OK; in arcmsr_clear_doorbell_queue_buffer()
4209 CHIP_REG_WRITE32(HBE_MessageUnit, 0, iobound_doorbell, acb->out_doorbell); in arcmsr_clear_doorbell_queue_buffer()
4230 srb_phyaddr = (unsigned long) acb->srb_phyaddr.phyaddr; in arcmsr_iop_confirm()
4231 srb_phyaddr_hi32 = acb->srb_phyaddr.B.phyadd_high; in arcmsr_iop_confirm()
4232 srb_phyaddr_lo32 = acb->srb_phyaddr.B.phyadd_low; in arcmsr_iop_confirm()
4233 switch (acb->adapter_type) { in arcmsr_iop_confirm()
4240 printf( "arcmsr%d: 'set srb high part physical address' timeout \n", acb->pci_unit); in arcmsr_iop_confirm()
4248 ** if adapter type B, set window of "post command Q" in arcmsr_iop_confirm()
4255 phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_iop_confirm()
4256 phbbmu->postq_index = 0; in arcmsr_iop_confirm()
4257 phbbmu->doneq_index = 0; in arcmsr_iop_confirm()
4258 WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_MESSAGE_SET_POST_WINDOW); in arcmsr_iop_confirm()
4260 printf( "arcmsr%d: 'set window of post command Q' timeout\n", acb->pci_unit); in arcmsr_iop_confirm()
4269 …CHIP_REG_WRITE32(HBB_RWBUFFER, 1, msgcode_rwbuffer[4], 1056); /* srb maxQ size must be --> [(256+8… in arcmsr_iop_confirm()
4270 WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_MESSAGE_SET_CONFIG); in arcmsr_iop_confirm()
4272 printf( "arcmsr%d: 'set command Q window' timeout \n", acb->pci_unit); in arcmsr_iop_confirm()
4275 WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_MESSAGE_START_DRIVER_MODE); in arcmsr_iop_confirm()
4277 printf( "arcmsr%d: 'start diver mode' timeout \n", acb->pci_unit); in arcmsr_iop_confirm()
4289 printf( "arcmsr%d: 'set srb high part physical address' timeout \n", acb->pci_unit); in arcmsr_iop_confirm()
4299 phbdmu = (struct HBD_MessageUnit0 *)acb->pmu; in arcmsr_iop_confirm()
4300 phbdmu->postq_index = 0; in arcmsr_iop_confirm()
4301 phbdmu->doneq_index = 0x40FF; in arcmsr_iop_confirm()
4313 printf( "arcmsr%d: 'set srb high part physical address' timeout \n", acb->pci_unit); in arcmsr_iop_confirm()
4331 acb->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_MESSAGE_CMD_DONE; in arcmsr_iop_confirm()
4332 CHIP_REG_WRITE32(HBE_MessageUnit, 0, iobound_doorbell, acb->out_doorbell); in arcmsr_iop_confirm()
4334 printf( "arcmsr%d: 'set srb high part physical address' timeout \n", acb->pci_unit); in arcmsr_iop_confirm()
4342 acb->msgcode_rwbuffer[0] = ARCMSR_SIGNATURE_SET_CONFIG; in arcmsr_iop_confirm()
4343 acb->msgcode_rwbuffer[1] = ARCMSR_SIGNATURE_1886; in arcmsr_iop_confirm()
4344 acb->msgcode_rwbuffer[2] = cdb_phyaddr_lo32; in arcmsr_iop_confirm()
4345 acb->msgcode_rwbuffer[3] = srb_phyaddr_hi32; in arcmsr_iop_confirm()
4346 acb->msgcode_rwbuffer[4] = SRB_SIZE; in arcmsr_iop_confirm()
4348 acb->msgcode_rwbuffer[5] = cdb_phyaddr_lo32; in arcmsr_iop_confirm()
4349 acb->msgcode_rwbuffer[6] = srb_phyaddr_hi32; in arcmsr_iop_confirm()
4350 acb->msgcode_rwbuffer[7] = COMPLETION_Q_POOL_SIZE; in arcmsr_iop_confirm()
4351 if (acb->xor_mega) { in arcmsr_iop_confirm()
4352 acb->msgcode_rwbuffer[8] = 0x555AA; //FreeBSD init 2 in arcmsr_iop_confirm()
4353 acb->msgcode_rwbuffer[9] = 0; in arcmsr_iop_confirm()
4354 acb->msgcode_rwbuffer[10] = (uint32_t)acb->xor_sgtable_phy; in arcmsr_iop_confirm()
4355 acb->msgcode_rwbuffer[11] = (uint32_t)((acb->xor_sgtable_phy >> 16) >> 16); in arcmsr_iop_confirm()
4358 acb->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_MESSAGE_CMD_DONE; in arcmsr_iop_confirm()
4359 CHIP_REG_WRITE32(HBF_MessageUnit, 0, iobound_doorbell, acb->out_doorbell); in arcmsr_iop_confirm()
4361 printf( "arcmsr%d: 'set srb high part physical address' timeout \n", acb->pci_unit); in arcmsr_iop_confirm()
4375 if (acb->adapter_type == ACB_ADAPTER_TYPE_B) in arcmsr_enable_eoi_mode()
4377 struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_enable_eoi_mode()
4378 WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_MESSAGE_ACTIVE_EOI_MODE); in arcmsr_enable_eoi_mode()
4380 printf( "arcmsr%d: 'iop enable eoi mode' timeout \n", acb->pci_unit); in arcmsr_enable_eoi_mode()
4405 acb->acb_flags |= ACB_F_IOP_INITED; in arcmsr_iop_init()
4416 unsigned long srb_phyaddr = (unsigned long)segs->ds_addr; in arcmsr_map_free_srb()
4418 acb->srb_phyaddr.phyaddr = srb_phyaddr; in arcmsr_map_free_srb()
4419 srb_tmp = (struct CommandControlBlock *)acb->uncacheptr; in arcmsr_map_free_srb()
4421 if(bus_dmamap_create(acb->dm_segs_dmat, in arcmsr_map_free_srb()
4422 /*flags*/0, &srb_tmp->dm_segs_dmamap) != 0) { in arcmsr_map_free_srb()
4423 acb->acb_flags |= ACB_F_MAPFREESRB_FAILD; in arcmsr_map_free_srb()
4425 " srb dmamap bus_dmamap_create error\n", acb->pci_unit); in arcmsr_map_free_srb()
4428 if((acb->adapter_type == ACB_ADAPTER_TYPE_C) || (acb->adapter_type == ACB_ADAPTER_TYPE_D) in arcmsr_map_free_srb()
4429 || (acb->adapter_type == ACB_ADAPTER_TYPE_E) || (acb->adapter_type == ACB_ADAPTER_TYPE_F)) in arcmsr_map_free_srb()
4431 srb_tmp->cdb_phyaddr = srb_phyaddr; in arcmsr_map_free_srb()
4434 srb_tmp->cdb_phyaddr = srb_phyaddr >> 5; in arcmsr_map_free_srb()
4435 srb_tmp->acb = acb; in arcmsr_map_free_srb()
4436 srb_tmp->smid = i << 16; in arcmsr_map_free_srb()
4437 acb->srbworkingQ[i] = acb->psrb_pool[i] = srb_tmp; in arcmsr_map_free_srb()
4441 srb_tmp = (struct CommandControlBlock *)(acb->uncacheptr + ARCMSR_SRBS_POOL_SIZE); in arcmsr_map_free_srb()
4442 srb_phyaddr = (unsigned long)segs->ds_addr + ARCMSR_SRBS_POOL_SIZE; in arcmsr_map_free_srb()
4443 switch (acb->adapter_type) { in arcmsr_map_free_srb()
4447 acb->pmu = (struct MessageUnit_UNION *)srb_tmp; in arcmsr_map_free_srb()
4448 phbbmu = (struct HBB_MessageUnit *)acb->pmu; in arcmsr_map_free_srb()
4449 phbbmu->hbb_doorbell = (struct HBB_DOORBELL *)acb->mem_base0; in arcmsr_map_free_srb()
4450 phbbmu->hbb_rwbuffer = (struct HBB_RWBUFFER *)acb->mem_base1; in arcmsr_map_free_srb()
4451 if (acb->vendor_device_id == PCIDevVenIDARC1203) { in arcmsr_map_free_srb()
4452 phbbmu->drv2iop_doorbell = offsetof(struct HBB_DOORBELL_1203, drv2iop_doorbell); in arcmsr_map_free_srb()
4453 phbbmu->drv2iop_doorbell_mask = offsetof(struct HBB_DOORBELL_1203, drv2iop_doorbell_mask); in arcmsr_map_free_srb()
4454 phbbmu->iop2drv_doorbell = offsetof(struct HBB_DOORBELL_1203, iop2drv_doorbell); in arcmsr_map_free_srb()
4455 phbbmu->iop2drv_doorbell_mask = offsetof(struct HBB_DOORBELL_1203, iop2drv_doorbell_mask); in arcmsr_map_free_srb()
4457 phbbmu->drv2iop_doorbell = offsetof(struct HBB_DOORBELL, drv2iop_doorbell); in arcmsr_map_free_srb()
4458 phbbmu->drv2iop_doorbell_mask = offsetof(struct HBB_DOORBELL, drv2iop_doorbell_mask); in arcmsr_map_free_srb()
4459 phbbmu->iop2drv_doorbell = offsetof(struct HBB_DOORBELL, iop2drv_doorbell); in arcmsr_map_free_srb()
4460 phbbmu->iop2drv_doorbell_mask = offsetof(struct HBB_DOORBELL, iop2drv_doorbell_mask); in arcmsr_map_free_srb()
4465 acb->pmu = (struct MessageUnit_UNION *)srb_tmp; in arcmsr_map_free_srb()
4466 acb->pmu->muu.hbdmu.phbdmu = (struct HBD_MessageUnit *)acb->mem_base0; in arcmsr_map_free_srb()
4469 acb->pCompletionQ = (pCompletion_Q)srb_tmp; in arcmsr_map_free_srb()
4473 acb->pCompletionQ = (pCompletion_Q)srb_tmp; in arcmsr_map_free_srb()
4474 acb->completeQ_phys = srb_phyaddr; in arcmsr_map_free_srb()
4475 memset(acb->pCompletionQ, 0xff, COMPLETION_Q_POOL_SIZE); in arcmsr_map_free_srb()
4476 acb->message_wbuffer = (u_int32_t *)((unsigned long)acb->pCompletionQ + COMPLETION_Q_POOL_SIZE); in arcmsr_map_free_srb()
4477 acb->message_rbuffer = (u_int32_t *)((unsigned long)acb->message_wbuffer + 0x100); in arcmsr_map_free_srb()
4478 acb->msgcode_rwbuffer = (u_int32_t *)((unsigned long)acb->message_wbuffer + 0x200); in arcmsr_map_free_srb()
4479 memset((void *)acb->message_wbuffer, 0, MESG_RW_BUFFER_SIZE); in arcmsr_map_free_srb()
4481 host_buffer_dma = acb->completeQ_phys + COMPLETION_Q_POOL_SIZE; in arcmsr_map_free_srb()
4485 …acb->firm_PicStatus = CHIP_REG_READ32(HBF_MessageUnit, 0, outbound_msgaddr1); /* get firmware spec… in arcmsr_map_free_srb()
4489 acb->vir2phy_offset = (unsigned long)srb_tmp - (unsigned long)srb_phyaddr; in arcmsr_map_free_srb()
4496 acb->xor_sgtable_phy = (unsigned long)segs->ds_addr; in arcmsr_map_xor_sgtable()
4497 if ((nseg != 1) || ((u_int32_t)segs->ds_len != acb->init2cfg_size)) { in arcmsr_map_xor_sgtable()
4498 acb->acb_flags |= ACB_F_MAPXOR_FAILD; in arcmsr_map_xor_sgtable()
4499 printf("arcmsr%d: alloc xor table seg num or size not as i wish!\n", acb->pci_unit); in arcmsr_map_xor_sgtable()
4509 struct XorSg *pxortable = (struct XorSg *)(acb->xortable + sizeof(struct HostRamBuf)); in arcmsr_map_xor_sg()
4511 if (nseg != acb->xor_mega) { in arcmsr_map_xor_sg()
4512 acb->acb_flags |= ACB_F_MAPXOR_FAILD; in arcmsr_map_xor_sg()
4513 printf("arcmsr%d: alloc xor seg NUM not as i wish!\n", acb->pci_unit); in arcmsr_map_xor_sg()
4517 if ((u_int32_t)segs->ds_len != ARCMSR_XOR_SEG_SIZE) { in arcmsr_map_xor_sg()
4518 acb->acb_flags |= ACB_F_MAPXOR_FAILD; in arcmsr_map_xor_sg()
4519 printf("arcmsr%d: alloc xor seg SIZE not as i wish!\n", acb->pci_unit); in arcmsr_map_xor_sg()
4522 pxortable->xorPhys = (u_int64_t)segs->ds_addr; in arcmsr_map_xor_sg()
4523 pxortable->xorBufLen = (u_int64_t)segs->ds_len; in arcmsr_map_xor_sg()
4527 pRamBuf = (struct HostRamBuf *)acb->xortable; in arcmsr_map_xor_sg()
4528 pRamBuf->hrbSignature = 0x53425248; //HRBS in arcmsr_map_xor_sg()
4529 pRamBuf->hrbSize = ARCMSR_XOR_SEG_SIZE * nseg; in arcmsr_map_xor_sg()
4530 pRamBuf->hrbRes[0] = 0; in arcmsr_map_xor_sg()
4531 pRamBuf->hrbRes[1] = 0; in arcmsr_map_xor_sg()
4532 bus_dmamap_sync(acb->xortable_dmat, acb->xortable_dmamap, BUS_DMASYNC_PREREAD); in arcmsr_map_xor_sg()
4533 bus_dmamap_sync(acb->xor_dmat, acb->xor_dmamap, BUS_DMASYNC_PREWRITE); in arcmsr_map_xor_sg()
4543 if(acb->ioctl_dev != NULL) { in arcmsr_free_resource()
4544 destroy_dev(acb->ioctl_dev); in arcmsr_free_resource()
4546 if (acb->acb_flags & ACB_F_DMAMAP_SG) in arcmsr_free_resource()
4547 bus_dmamap_unload(acb->xor_dmat, acb->xor_dmamap); in arcmsr_free_resource()
4548 if (acb->xor_dmamap) { in arcmsr_free_resource()
4549 bus_dmamem_free(acb->xor_dmat, acb->xorptr, acb->xor_dmamap); in arcmsr_free_resource()
4551 if (acb->acb_flags & ACB_F_DMAMAP_SGTABLE) in arcmsr_free_resource()
4552 bus_dmamap_unload(acb->xortable_dmat, acb->xortable_dmamap); in arcmsr_free_resource()
4553 if (acb->xortable_dmamap) { in arcmsr_free_resource()
4554 bus_dmamem_free(acb->xortable_dmat, acb->xortable, acb->xortable_dmamap); in arcmsr_free_resource()
4556 if (acb->acb_flags & ACB_F_DMAMAP_SRB) in arcmsr_free_resource()
4557 bus_dmamap_unload(acb->srb_dmat, acb->srb_dmamap); in arcmsr_free_resource()
4558 if (acb->srb_dmamap) { in arcmsr_free_resource()
4559 bus_dmamem_free(acb->srb_dmat, acb->uncacheptr, acb->srb_dmamap); in arcmsr_free_resource()
4561 if (acb->srb_dmat) in arcmsr_free_resource()
4562 bus_dma_tag_destroy(acb->srb_dmat); in arcmsr_free_resource()
4563 if (acb->dm_segs_dmat) in arcmsr_free_resource()
4564 bus_dma_tag_destroy(acb->dm_segs_dmat); in arcmsr_free_resource()
4565 if (acb->parent_dmat) in arcmsr_free_resource()
4566 bus_dma_tag_destroy(acb->parent_dmat); in arcmsr_free_resource()
4567 switch(acb->adapter_type) { in arcmsr_free_resource()
4569 if (acb->sys_res_arcmsr[0]) in arcmsr_free_resource()
4570 bus_release_resource(acb->pci_dev, SYS_RES_MEMORY, PCIR_BAR(0), acb->sys_res_arcmsr[0]); in arcmsr_free_resource()
4573 if (acb->sys_res_arcmsr[0]) in arcmsr_free_resource()
4574 bus_release_resource(acb->pci_dev, SYS_RES_MEMORY, PCIR_BAR(0), acb->sys_res_arcmsr[0]); in arcmsr_free_resource()
4575 if (acb->sys_res_arcmsr[1]) in arcmsr_free_resource()
4576 bus_release_resource(acb->pci_dev, SYS_RES_MEMORY, PCIR_BAR(2), acb->sys_res_arcmsr[1]); in arcmsr_free_resource()
4579 if (acb->sys_res_arcmsr[0]) in arcmsr_free_resource()
4580 bus_release_resource(acb->pci_dev, SYS_RES_MEMORY, PCIR_BAR(1), acb->sys_res_arcmsr[0]); in arcmsr_free_resource()
4583 if (acb->sys_res_arcmsr[0]) in arcmsr_free_resource()
4584 bus_release_resource(acb->pci_dev, SYS_RES_MEMORY, PCIR_BAR(0), acb->sys_res_arcmsr[0]); in arcmsr_free_resource()
4587 if (acb->sys_res_arcmsr[0]) in arcmsr_free_resource()
4588 bus_release_resource(acb->pci_dev, SYS_RES_MEMORY, PCIR_BAR(1), acb->sys_res_arcmsr[0]); in arcmsr_free_resource()
4591 if (acb->sys_res_arcmsr[0]) in arcmsr_free_resource()
4592 bus_release_resource(acb->pci_dev, SYS_RES_MEMORY, PCIR_BAR(0), acb->sys_res_arcmsr[0]); in arcmsr_free_resource()
4602 ARCMSR_LOCK_INIT(&acb->isr_lock, "arcmsr isr lock"); in arcmsr_mutex_init()
4603 ARCMSR_LOCK_INIT(&acb->srb_lock, "arcmsr srb lock"); in arcmsr_mutex_init()
4604 ARCMSR_LOCK_INIT(&acb->postDone_lock, "arcmsr postQ lock"); in arcmsr_mutex_init()
4605 ARCMSR_LOCK_INIT(&acb->qbuffer_lock, "arcmsr RW buffer lock"); in arcmsr_mutex_init()
4613 ARCMSR_LOCK_DESTROY(&acb->qbuffer_lock); in arcmsr_mutex_destroy()
4614 ARCMSR_LOCK_DESTROY(&acb->postDone_lock); in arcmsr_mutex_destroy()
4615 ARCMSR_LOCK_DESTROY(&acb->srb_lock); in arcmsr_mutex_destroy()
4616 ARCMSR_LOCK_DESTROY(&acb->isr_lock); in arcmsr_mutex_destroy()
4626 switch (acb->vendor_device_id) { in arcmsr_define_adapter_type()
4632 acb->adapter_type = ACB_ADAPTER_TYPE_C; in arcmsr_define_adapter_type()
4633 if ((acb->sub_device_id == ARECA_SUB_DEV_ID_1883) || in arcmsr_define_adapter_type()
4634 (acb->sub_device_id == ARECA_SUB_DEV_ID_1216) || in arcmsr_define_adapter_type()
4635 (acb->sub_device_id == ARECA_SUB_DEV_ID_1226)) in arcmsr_define_adapter_type()
4636 acb->adapter_bus_speed = ACB_BUS_SPEED_12G; in arcmsr_define_adapter_type()
4638 acb->adapter_bus_speed = ACB_BUS_SPEED_6G; in arcmsr_define_adapter_type()
4639 acb->max_coherent_size = ARCMSR_SRBS_POOL_SIZE; in arcmsr_define_adapter_type()
4643 acb->adapter_type = ACB_ADAPTER_TYPE_E; in arcmsr_define_adapter_type()
4644 acb->adapter_bus_speed = ACB_BUS_SPEED_12G; in arcmsr_define_adapter_type()
4645 acb->max_coherent_size = ARCMSR_SRBS_POOL_SIZE + COMPLETION_Q_POOL_SIZE; in arcmsr_define_adapter_type()
4646 acb->completionQ_entry = COMPLETION_Q_POOL_SIZE / sizeof(struct deliver_completeQ); in arcmsr_define_adapter_type()
4651 acb->adapter_type = ACB_ADAPTER_TYPE_F; in arcmsr_define_adapter_type()
4652 acb->adapter_bus_speed = ACB_BUS_SPEED_12G; in arcmsr_define_adapter_type()
4653 acb->max_coherent_size = ARCMSR_SRBS_POOL_SIZE + COMPLETION_Q_POOL_SIZE + MESG_RW_BUFFER_SIZE; in arcmsr_define_adapter_type()
4654 acb->completionQ_entry = COMPLETION_Q_POOL_SIZE / sizeof(struct deliver_completeQ); in arcmsr_define_adapter_type()
4658 acb->adapter_type = ACB_ADAPTER_TYPE_D; in arcmsr_define_adapter_type()
4659 acb->adapter_bus_speed = ACB_BUS_SPEED_6G; in arcmsr_define_adapter_type()
4660 acb->max_coherent_size = ARCMSR_SRBS_POOL_SIZE + (sizeof(struct HBD_MessageUnit0)); in arcmsr_define_adapter_type()
4665 acb->adapter_type = ACB_ADAPTER_TYPE_B; in arcmsr_define_adapter_type()
4666 acb->adapter_bus_speed = ACB_BUS_SPEED_3G; in arcmsr_define_adapter_type()
4667 acb->max_coherent_size = ARCMSR_SRBS_POOL_SIZE + (sizeof(struct HBB_MessageUnit)); in arcmsr_define_adapter_type()
4671 acb->adapter_type = ACB_ADAPTER_TYPE_B; in arcmsr_define_adapter_type()
4672 acb->adapter_bus_speed = ACB_BUS_SPEED_6G; in arcmsr_define_adapter_type()
4673 acb->max_coherent_size = ARCMSR_SRBS_POOL_SIZE + (sizeof(struct HBB_MessageUnit)); in arcmsr_define_adapter_type()
4695 acb->adapter_type = ACB_ADAPTER_TYPE_A; in arcmsr_define_adapter_type()
4696 acb->adapter_bus_speed = ACB_BUS_SPEED_3G; in arcmsr_define_adapter_type()
4697 acb->max_coherent_size = ARCMSR_SRBS_POOL_SIZE; in arcmsr_define_adapter_type()
4702 " unknown RAID adapter type \n", acb->pci_unit); in arcmsr_define_adapter_type()
4711 switch(acb->adapter_type) { in arcmsr_map_pcireg()
4716 acb->sys_res_arcmsr[0] = bus_alloc_resource_any(dev,SYS_RES_MEMORY, &rid0, RF_ACTIVE); in arcmsr_map_pcireg()
4717 if(acb->sys_res_arcmsr[0] == NULL) { in arcmsr_map_pcireg()
4719 printf("arcmsr%d: bus_alloc_resource failure!\n", acb->pci_unit); in arcmsr_map_pcireg()
4722 if(rman_get_start(acb->sys_res_arcmsr[0]) <= 0) { in arcmsr_map_pcireg()
4724 printf("arcmsr%d: rman_get_start failure!\n", acb->pci_unit); in arcmsr_map_pcireg()
4727 mem_base0 = (vm_offset_t) rman_get_virtual(acb->sys_res_arcmsr[0]); in arcmsr_map_pcireg()
4730 printf("arcmsr%d: rman_get_virtual failure!\n", acb->pci_unit); in arcmsr_map_pcireg()
4733 acb->btag[0] = rman_get_bustag(acb->sys_res_arcmsr[0]); in arcmsr_map_pcireg()
4734 acb->bhandle[0] = rman_get_bushandle(acb->sys_res_arcmsr[0]); in arcmsr_map_pcireg()
4735 acb->pmu = (struct MessageUnit_UNION *)mem_base0; in arcmsr_map_pcireg()
4736 acb->rid[0] = rid0; in arcmsr_map_pcireg()
4745 acb->sys_res_arcmsr[i] = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid[i], RF_ACTIVE); in arcmsr_map_pcireg()
4746 if(acb->sys_res_arcmsr[i] == NULL) { in arcmsr_map_pcireg()
4748 printf("arcmsr%d: bus_alloc_resource %d failure!\n", acb->pci_unit, i); in arcmsr_map_pcireg()
4751 if(rman_get_start(acb->sys_res_arcmsr[i]) <= 0) { in arcmsr_map_pcireg()
4753 printf("arcmsr%d: rman_get_start %d failure!\n", acb->pci_unit, i); in arcmsr_map_pcireg()
4756 mem_base[i] = (vm_offset_t) rman_get_virtual(acb->sys_res_arcmsr[i]); in arcmsr_map_pcireg()
4759 printf("arcmsr%d: rman_get_virtual %d failure!\n", acb->pci_unit, i); in arcmsr_map_pcireg()
4762 acb->btag[i] = rman_get_bustag(acb->sys_res_arcmsr[i]); in arcmsr_map_pcireg()
4763 acb->bhandle[i] = rman_get_bushandle(acb->sys_res_arcmsr[i]); in arcmsr_map_pcireg()
4765 acb->mem_base0 = mem_base[0]; in arcmsr_map_pcireg()
4766 acb->mem_base1 = mem_base[1]; in arcmsr_map_pcireg()
4767 acb->rid[0] = rid[0]; in arcmsr_map_pcireg()
4768 acb->rid[1] = rid[1]; in arcmsr_map_pcireg()
4775 acb->sys_res_arcmsr[0] = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid0, RF_ACTIVE); in arcmsr_map_pcireg()
4776 if(acb->sys_res_arcmsr[0] == NULL) { in arcmsr_map_pcireg()
4778 printf("arcmsr%d: bus_alloc_resource failure!\n", acb->pci_unit); in arcmsr_map_pcireg()
4781 if(rman_get_start(acb->sys_res_arcmsr[0]) <= 0) { in arcmsr_map_pcireg()
4783 printf("arcmsr%d: rman_get_start failure!\n", acb->pci_unit); in arcmsr_map_pcireg()
4786 mem_base0 = (vm_offset_t) rman_get_virtual(acb->sys_res_arcmsr[0]); in arcmsr_map_pcireg()
4789 printf("arcmsr%d: rman_get_virtual failure!\n", acb->pci_unit); in arcmsr_map_pcireg()
4792 acb->btag[0] = rman_get_bustag(acb->sys_res_arcmsr[0]); in arcmsr_map_pcireg()
4793 acb->bhandle[0] = rman_get_bushandle(acb->sys_res_arcmsr[0]); in arcmsr_map_pcireg()
4794 acb->pmu = (struct MessageUnit_UNION *)mem_base0; in arcmsr_map_pcireg()
4795 acb->rid[0] = rid0; in arcmsr_map_pcireg()
4802 acb->sys_res_arcmsr[0] = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid0, RF_ACTIVE); in arcmsr_map_pcireg()
4803 if(acb->sys_res_arcmsr[0] == NULL) { in arcmsr_map_pcireg()
4805 printf("arcmsr%d: bus_alloc_resource failure!\n", acb->pci_unit); in arcmsr_map_pcireg()
4808 if(rman_get_start(acb->sys_res_arcmsr[0]) <= 0) { in arcmsr_map_pcireg()
4810 printf("arcmsr%d: rman_get_start failure!\n", acb->pci_unit); in arcmsr_map_pcireg()
4813 mem_base0 = (vm_offset_t) rman_get_virtual(acb->sys_res_arcmsr[0]); in arcmsr_map_pcireg()
4816 printf("arcmsr%d: rman_get_virtual failure!\n", acb->pci_unit); in arcmsr_map_pcireg()
4819 acb->btag[0] = rman_get_bustag(acb->sys_res_arcmsr[0]); in arcmsr_map_pcireg()
4820 acb->bhandle[0] = rman_get_bushandle(acb->sys_res_arcmsr[0]); in arcmsr_map_pcireg()
4821 acb->mem_base0 = mem_base0; in arcmsr_map_pcireg()
4822 acb->rid[0] = rid0; in arcmsr_map_pcireg()
4829 acb->sys_res_arcmsr[0] = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid0, RF_ACTIVE); in arcmsr_map_pcireg()
4830 if(acb->sys_res_arcmsr[0] == NULL) { in arcmsr_map_pcireg()
4832 printf("arcmsr%d: bus_alloc_resource failure!\n", acb->pci_unit); in arcmsr_map_pcireg()
4835 if(rman_get_start(acb->sys_res_arcmsr[0]) <= 0) { in arcmsr_map_pcireg()
4837 printf("arcmsr%d: rman_get_start failure!\n", acb->pci_unit); in arcmsr_map_pcireg()
4840 mem_base0 = (vm_offset_t) rman_get_virtual(acb->sys_res_arcmsr[0]); in arcmsr_map_pcireg()
4843 printf("arcmsr%d: rman_get_virtual failure!\n", acb->pci_unit); in arcmsr_map_pcireg()
4846 acb->btag[0] = rman_get_bustag(acb->sys_res_arcmsr[0]); in arcmsr_map_pcireg()
4847 acb->bhandle[0] = rman_get_bushandle(acb->sys_res_arcmsr[0]); in arcmsr_map_pcireg()
4848 acb->pmu = (struct MessageUnit_UNION *)mem_base0; in arcmsr_map_pcireg()
4849 acb->doneq_index = 0; in arcmsr_map_pcireg()
4850 acb->in_doorbell = 0; in arcmsr_map_pcireg()
4851 acb->out_doorbell = 0; in arcmsr_map_pcireg()
4852 acb->rid[0] = rid0; in arcmsr_map_pcireg()
4861 acb->sys_res_arcmsr[0] = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid0, RF_ACTIVE); in arcmsr_map_pcireg()
4862 if(acb->sys_res_arcmsr[0] == NULL) { in arcmsr_map_pcireg()
4864 printf("arcmsr%d: bus_alloc_resource failure!\n", acb->pci_unit); in arcmsr_map_pcireg()
4867 if(rman_get_start(acb->sys_res_arcmsr[0]) <= 0) { in arcmsr_map_pcireg()
4869 printf("arcmsr%d: rman_get_start failure!\n", acb->pci_unit); in arcmsr_map_pcireg()
4872 mem_base0 = (vm_offset_t) rman_get_virtual(acb->sys_res_arcmsr[0]); in arcmsr_map_pcireg()
4875 printf("arcmsr%d: rman_get_virtual failure!\n", acb->pci_unit); in arcmsr_map_pcireg()
4878 acb->btag[0] = rman_get_bustag(acb->sys_res_arcmsr[0]); in arcmsr_map_pcireg()
4879 acb->bhandle[0] = rman_get_bushandle(acb->sys_res_arcmsr[0]); in arcmsr_map_pcireg()
4880 acb->pmu = (struct MessageUnit_UNION *)mem_base0; in arcmsr_map_pcireg()
4881 acb->doneq_index = 0; in arcmsr_map_pcireg()
4882 acb->in_doorbell = 0; in arcmsr_map_pcireg()
4883 acb->out_doorbell = 0; in arcmsr_map_pcireg()
4884 acb->rid[0] = rid0; in arcmsr_map_pcireg()
4910 &acb->parent_dmat) != 0) in arcmsr_alloc_srb()
4912 printf("arcmsr%d: parent_dmat bus_dma_tag_create failure!\n", acb->pci_unit); in arcmsr_alloc_srb()
4917 if(bus_dma_tag_create( /*parent_dmat*/ acb->parent_dmat, in arcmsr_alloc_srb()
4933 /*lockarg*/ &acb->isr_lock, in arcmsr_alloc_srb()
4934 &acb->dm_segs_dmat) != 0) in arcmsr_alloc_srb()
4937 printf("arcmsr%d: dm_segs_dmat bus_dma_tag_create failure!\n", acb->pci_unit); in arcmsr_alloc_srb()
4941 /* DMA tag for our srb structures.... Allocate the freesrb memory */ in arcmsr_alloc_srb()
4942 if(bus_dma_tag_create( /*parent_dmat*/ acb->parent_dmat, in arcmsr_alloc_srb()
4949 /*maxsize*/ acb->max_coherent_size, in arcmsr_alloc_srb()
4955 &acb->srb_dmat) != 0) in arcmsr_alloc_srb()
4958 printf("arcmsr%d: srb_dmat bus_dma_tag_create failure!\n", acb->pci_unit); in arcmsr_alloc_srb()
4962 …if(bus_dmamem_alloc(acb->srb_dmat, (void **)&acb->uncacheptr, ARCMSR_DMA_ALLOC_FLAG, &acb->srb_dma… in arcmsr_alloc_srb()
4964 printf("arcmsr%d: srb_dmat bus_dmamem_alloc failure!\n", acb->pci_unit); in arcmsr_alloc_srb()
4968 …rc = bus_dmamap_load(acb->srb_dmat, acb->srb_dmamap, acb->uncacheptr, acb->max_coherent_size, arcm… in arcmsr_alloc_srb()
4971 printf("arcmsr%d: srb_dmat bus_dmamap_load failure!\n", acb->pci_unit); in arcmsr_alloc_srb()
4974 acb->acb_flags |= ACB_F_DMAMAP_SRB; in arcmsr_alloc_srb()
4982 xor_ram = (acb->firm_PicStatus >> 24) & 0x0f; in arcmsr_alloc_xor_mem()
4983 acb->xor_mega = (xor_ram - 1) * 32 + 128 + 3; in arcmsr_alloc_xor_mem()
4984 acb->init2cfg_size = sizeof(struct HostRamBuf) + (sizeof(struct XorSg) * acb->xor_mega); in arcmsr_alloc_xor_mem()
4985 /* DMA tag for XOR engine of Raid 5,6 */ in arcmsr_alloc_xor_mem()
4986 if(bus_dma_tag_create( /*parent_dmat*/ acb->parent_dmat, in arcmsr_alloc_xor_mem()
4993 /*maxsize*/ acb->init2cfg_size, in arcmsr_alloc_xor_mem()
4995 /*maxsegsz*/ acb->init2cfg_size, in arcmsr_alloc_xor_mem()
4999 &acb->xortable_dmat) != 0) in arcmsr_alloc_xor_mem()
5002 printf("arcmsr%d: xor table bus_dma_tag_create failure!\n", acb->pci_unit); in arcmsr_alloc_xor_mem()
5006 …if(bus_dmamem_alloc(acb->xortable_dmat, (void **)&acb->xortable, ARCMSR_DMA_ALLOC_FLAG, &acb->xort… in arcmsr_alloc_xor_mem()
5008 printf("arcmsr%d: xor table bus_dmamem_alloc failure!\n", acb->pci_unit); in arcmsr_alloc_xor_mem()
5012 …rc = bus_dmamap_load(acb->xortable_dmat, acb->xortable_dmamap, acb->xortable, acb->init2cfg_size, … in arcmsr_alloc_xor_mem()
5015 printf("arcmsr%d: xor table bus_dmamap_load failure!\n", acb->pci_unit); in arcmsr_alloc_xor_mem()
5018 acb->acb_flags |= ACB_F_DMAMAP_SGTABLE; in arcmsr_alloc_xor_mem()
5020 /* DMA tag for XOR engine of Raid 5,6 */ in arcmsr_alloc_xor_mem()
5021 if(bus_dma_tag_create( /*parent_dmat*/ acb->parent_dmat, in arcmsr_alloc_xor_mem()
5028 /*maxsize*/ (ARCMSR_XOR_SEG_SIZE * acb->xor_mega), in arcmsr_alloc_xor_mem()
5029 /*nsegments*/ acb->xor_mega, in arcmsr_alloc_xor_mem()
5034 &acb->xor_dmat) != 0) in arcmsr_alloc_xor_mem()
5037 printf("arcmsr%d: xor bus_dma_tag_create failure!\n", acb->pci_unit); in arcmsr_alloc_xor_mem()
5041 …if(bus_dmamem_alloc(acb->xor_dmat, (void **)&acb->xorptr, ARCMSR_DMA_ALLOC_FLAG, &acb->xor_dmamap)… in arcmsr_alloc_xor_mem()
5043 printf("arcmsr%d: xor bus_dmamem_alloc failure!\n", acb->pci_unit); in arcmsr_alloc_xor_mem()
5047 …rc = bus_dmamap_load(acb->xor_dmat, acb->xor_dmamap, acb->xorptr, (ARCMSR_XOR_SEG_SIZE * acb->xor_… in arcmsr_alloc_xor_mem()
5050 printf("arcmsr%d: xor bus_dmamap_load failure!\n", acb->pci_unit); in arcmsr_alloc_xor_mem()
5053 acb->acb_flags |= ACB_F_DMAMAP_SG; in arcmsr_alloc_xor_mem()
5064 acb->vendor_device_id = vendor_dev_id; in arcmsr_initialize()
5065 acb->sub_device_id = pci_read_config(dev, PCIR_SUBDEV_0, 2); in arcmsr_initialize()
5076 if ((acb->firm_PicStatus >> 24) & 0x0f) { in arcmsr_initialize()
5081 if(acb->acb_flags & (ACB_F_MAPFREESRB_FAILD | ACB_F_MAPXOR_FAILD)) { in arcmsr_initialize()
5083 printf("arcmsr%d: map free srb or xor buffer failure!\n", acb->pci_unit); in arcmsr_initialize()
5086 …acb->acb_flags |= (ACB_F_MESSAGE_WQBUFFER_CLEARED|ACB_F_MESSAGE_RQBUFFER_CLEARED|ACB_F_MESSAGE_WQ… in arcmsr_initialize()
5087 acb->acb_flags &= ~ACB_F_SCSISTOPADAPTER; in arcmsr_initialize()
5095 acb->devstate[i][j] = ARECA_RAID_GONE; in arcmsr_initialize()
5106 for (i = 0; i < acb->msix_vectors; i++) { in arcmsr_setup_msix()
5107 acb->irq_id[i] = 1 + i; in arcmsr_setup_msix()
5108 acb->irqres[i] = bus_alloc_resource_any(acb->pci_dev, in arcmsr_setup_msix()
5109 SYS_RES_IRQ, &acb->irq_id[i], RF_ACTIVE); in arcmsr_setup_msix()
5110 if (acb->irqres[i] == NULL) { in arcmsr_setup_msix()
5111 printf("arcmsr: Can't allocate MSI-X resource\n"); in arcmsr_setup_msix()
5114 if (bus_setup_intr(acb->pci_dev, acb->irqres[i], in arcmsr_setup_msix()
5116 acb, &acb->ih[i])) { in arcmsr_setup_msix()
5117 printf("arcmsr: Cannot set up MSI-X interrupt handler\n"); in arcmsr_setup_msix()
5121 printf("arcmsr: MSI-X INT enabled\n"); in arcmsr_setup_msix()
5122 acb->acb_flags |= ACB_F_MSIX_ENABLED; in arcmsr_setup_msix()
5126 arcmsr_teardown_intr(acb->pci_dev, acb); in arcmsr_setup_msix()
5148 acb->pci_dev = dev; in arcmsr_attach()
5149 acb->pci_unit = unit; in arcmsr_attach()
5155 acb->msix_vectors = ARCMSR_NUM_MSIX_VECTORS; in arcmsr_attach()
5156 if (pci_alloc_msix(dev, &acb->msix_vectors) == 0) { in arcmsr_attach()
5160 acb->irq_id[0] = 0; in arcmsr_attach()
5161 irqres = bus_alloc_resource_any(dev, SYS_RES_IRQ, &acb->irq_id[0], RF_SHAREABLE | RF_ACTIVE); in arcmsr_attach()
5163 …ev, irqres, INTR_TYPE_CAM|INTR_ENTROPY|INTR_MPSAFE, NULL, arcmsr_intr_handler, acb, &acb->ih[0])) { in arcmsr_attach()
5167 acb->irqres[0] = irqres; in arcmsr_attach()
5172 * Create device queue of SIM(s) * (MAX_START_JOB - 1) : in arcmsr_attach()
5175 devq = cam_simq_alloc(acb->maxOutstanding); in arcmsr_attach()
5180 …acb->psim = cam_sim_alloc(arcmsr_action, arcmsr_poll, "arcmsr", acb, unit, &acb->isr_lock, 1, ARCM… in arcmsr_attach()
5181 if(acb->psim == NULL) { in arcmsr_attach()
5185 ARCMSR_LOCK_ACQUIRE(&acb->isr_lock); in arcmsr_attach()
5186 if(xpt_bus_register(acb->psim, dev, 0) != CAM_SUCCESS) { in arcmsr_attach()
5190 …if(xpt_create_path(&acb->ppath, /* periph */ NULL, cam_sim_path(acb->psim), CAM_TARGET_WILDCARD, C… in arcmsr_attach()
5198 xpt_setup_ccb(&csa.ccb_h, acb->ppath, /*priority*/5); in arcmsr_attach()
5202 csa.callback_arg = acb->psim; in arcmsr_attach()
5204 ARCMSR_LOCK_RELEASE(&acb->isr_lock); in arcmsr_attach()
5212 (void)make_dev_s(&args, &acb->ioctl_dev, "arcmsr%d", unit); in arcmsr_attach()
5214 (void)make_dev_alias(acb->ioctl_dev, "arc%d", unit); in arcmsr_attach()
5215 arcmsr_callout_init(&acb->devmap_callout); in arcmsr_attach()
5216 callout_reset(&acb->devmap_callout, 60 * hz, arcmsr_polling_devmap, acb); in arcmsr_attach()
5219 xpt_bus_deregister(cam_sim_path(acb->psim)); in arcmsr_attach()
5221 cam_sim_free(acb->psim, /* free_simq */ TRUE); in arcmsr_attach()
5295 type = "NVME,SAS-12G,SATA-6G"; in arcmsr_probe()
5330 ARCMSR_LOCK_ACQUIRE(&acb->isr_lock); in arcmsr_shutdown()
5336 acb->acb_flags |= ACB_F_SCSISTOPADAPTER; in arcmsr_shutdown()
5337 acb->acb_flags &= ~ACB_F_IOP_INITED; in arcmsr_shutdown()
5338 if(acb->srboutstandingcount != 0) { in arcmsr_shutdown()
5344 srb = acb->psrb_pool[i]; in arcmsr_shutdown()
5345 if(srb->srb_state == ARCMSR_SRB_START) { in arcmsr_shutdown()
5346 srb->srb_state = ARCMSR_SRB_ABORTED; in arcmsr_shutdown()
5347 srb->pccb->ccb_h.status |= CAM_REQ_ABORTED; in arcmsr_shutdown()
5352 acb->srboutstandingcount = 0; in arcmsr_shutdown()
5353 acb->workingsrb_doneindex = 0; in arcmsr_shutdown()
5354 acb->workingsrb_startindex = 0; in arcmsr_shutdown()
5355 acb->pktRequestCount = 0; in arcmsr_shutdown()
5356 acb->pktReturnCount = 0; in arcmsr_shutdown()
5357 ARCMSR_LOCK_RELEASE(&acb->isr_lock); in arcmsr_shutdown()
5368 if (acb->acb_flags & ACB_F_MSIX_ENABLED) { in arcmsr_teardown_intr()
5369 for (i = 0; i < acb->msix_vectors; i++) { in arcmsr_teardown_intr()
5370 if (acb->ih[i]) in arcmsr_teardown_intr()
5371 bus_teardown_intr(dev, acb->irqres[i], acb->ih[i]); in arcmsr_teardown_intr()
5372 if (acb->irqres[i] != NULL) in arcmsr_teardown_intr()
5374 acb->irq_id[i], acb->irqres[i]); in arcmsr_teardown_intr()
5376 acb->ih[i] = NULL; in arcmsr_teardown_intr()
5380 if (acb->ih[0]) in arcmsr_teardown_intr()
5381 bus_teardown_intr(dev, acb->irqres[0], acb->ih[0]); in arcmsr_teardown_intr()
5382 if (acb->irqres[0] != NULL) in arcmsr_teardown_intr()
5384 acb->irq_id[0], acb->irqres[0]); in arcmsr_teardown_intr()
5385 acb->ih[0] = NULL; in arcmsr_teardown_intr()
5397 callout_stop(&acb->devmap_callout); in arcmsr_detach()
5401 ARCMSR_LOCK_ACQUIRE(&acb->isr_lock); in arcmsr_detach()
5402 xpt_async(AC_LOST_DEVICE, acb->ppath, NULL); in arcmsr_detach()
5403 xpt_free_path(acb->ppath); in arcmsr_detach()
5404 xpt_bus_deregister(cam_sim_path(acb->psim)); in arcmsr_detach()
5405 cam_sim_free(acb->psim, TRUE); in arcmsr_detach()
5406 ARCMSR_LOCK_RELEASE(&acb->isr_lock); in arcmsr_detach()
5414 if((acb->pktRequestCount - acb->pktReturnCount) == 0) in arcmsr_dump_data()
5416 printf("Command Request Count =0x%x\n",acb->pktRequestCount); in arcmsr_dump_data()
5417 printf("Command Return Count =0x%x\n",acb->pktReturnCount); in arcmsr_dump_data()
5418 printf("Command (Req-Rtn) Count =0x%x\n",(acb->pktRequestCount - acb->pktReturnCount)); in arcmsr_dump_data()
5419 printf("Queued Command Count =0x%x\n",acb->srboutstandingcount); in arcmsr_dump_data()