4545#include <linux/interrupt.h>
4646struct device_attribute ;
4747/*The limit of outstanding scsi command that firmware can handle*/
48- #define ARCMSR_MAX_OUTSTANDING_CMD 256
4948#ifdef CONFIG_XEN
5049 #define ARCMSR_MAX_FREECCB_NUM 160
50+ #define ARCMSR_MAX_OUTSTANDING_CMD 155
5151#else
5252 #define ARCMSR_MAX_FREECCB_NUM 320
53+ #define ARCMSR_MAX_OUTSTANDING_CMD 255
5354#endif
54- #define ARCMSR_DRIVER_VERSION "Driver Version 1.20 .00.15 2010/08/05 "
55+ #define ARCMSR_DRIVER_VERSION "v1.30 .00.04-20140919 "
5556#define ARCMSR_SCSI_INITIATOR_ID 255
5657#define ARCMSR_MAX_XFER_SECTORS 512
5758#define ARCMSR_MAX_XFER_SECTORS_B 4096
@@ -62,11 +63,17 @@ struct device_attribute;
6263#define ARCMSR_MAX_QBUFFER 4096
6364#define ARCMSR_DEFAULT_SG_ENTRIES 38
6465#define ARCMSR_MAX_HBB_POSTQUEUE 264
66+ #define ARCMSR_MAX_ARC1214_POSTQUEUE 256
67+ #define ARCMSR_MAX_ARC1214_DONEQUEUE 257
6568#define ARCMSR_MAX_XFER_LEN 0x26000 /* 152K */
6669#define ARCMSR_CDB_SG_PAGE_LENGTH 256
70+ #define ARCMST_NUM_MSIX_VECTORS 4
6771#ifndef PCI_DEVICE_ID_ARECA_1880
6872#define PCI_DEVICE_ID_ARECA_1880 0x1880
6973 #endif
74+ #ifndef PCI_DEVICE_ID_ARECA_1214
75+ #define PCI_DEVICE_ID_ARECA_1214 0x1214
76+ #endif
7077/*
7178**********************************************************************************
7279**
@@ -100,10 +107,11 @@ struct CMD_MESSAGE
100107** IOP Message Transfer Data for user space
101108*******************************************************************************
102109*/
110+ #define ARCMSR_API_DATA_BUFLEN 1032
103111struct CMD_MESSAGE_FIELD
104112{
105113 struct CMD_MESSAGE cmdmessage ;
106- uint8_t messagedatabuffer [1032 ];
114+ uint8_t messagedatabuffer [ARCMSR_API_DATA_BUFLEN ];
107115};
108116/* IOP message transfer */
109117#define ARCMSR_MESSAGE_FAIL 0x0001
@@ -337,6 +345,56 @@ struct FIRMWARE_INFO
337345#define ARCMSR_HBCMU_MESSAGE_FIRMWARE_OK 0x80000000
338346/*
339347*******************************************************************************
348+ ** SPEC. for Areca Type D adapter
349+ *******************************************************************************
350+ */
351+ #define ARCMSR_ARC1214_CHIP_ID 0x00004
352+ #define ARCMSR_ARC1214_CPU_MEMORY_CONFIGURATION 0x00008
353+ #define ARCMSR_ARC1214_I2_HOST_INTERRUPT_MASK 0x00034
354+ #define ARCMSR_ARC1214_SAMPLE_RESET 0x00100
355+ #define ARCMSR_ARC1214_RESET_REQUEST 0x00108
356+ #define ARCMSR_ARC1214_MAIN_INTERRUPT_STATUS 0x00200
357+ #define ARCMSR_ARC1214_PCIE_F0_INTERRUPT_ENABLE 0x0020C
358+ #define ARCMSR_ARC1214_INBOUND_MESSAGE0 0x00400
359+ #define ARCMSR_ARC1214_INBOUND_MESSAGE1 0x00404
360+ #define ARCMSR_ARC1214_OUTBOUND_MESSAGE0 0x00420
361+ #define ARCMSR_ARC1214_OUTBOUND_MESSAGE1 0x00424
362+ #define ARCMSR_ARC1214_INBOUND_DOORBELL 0x00460
363+ #define ARCMSR_ARC1214_OUTBOUND_DOORBELL 0x00480
364+ #define ARCMSR_ARC1214_OUTBOUND_DOORBELL_ENABLE 0x00484
365+ #define ARCMSR_ARC1214_INBOUND_LIST_BASE_LOW 0x01000
366+ #define ARCMSR_ARC1214_INBOUND_LIST_BASE_HIGH 0x01004
367+ #define ARCMSR_ARC1214_INBOUND_LIST_WRITE_POINTER 0x01018
368+ #define ARCMSR_ARC1214_OUTBOUND_LIST_BASE_LOW 0x01060
369+ #define ARCMSR_ARC1214_OUTBOUND_LIST_BASE_HIGH 0x01064
370+ #define ARCMSR_ARC1214_OUTBOUND_LIST_COPY_POINTER 0x0106C
371+ #define ARCMSR_ARC1214_OUTBOUND_LIST_READ_POINTER 0x01070
372+ #define ARCMSR_ARC1214_OUTBOUND_INTERRUPT_CAUSE 0x01088
373+ #define ARCMSR_ARC1214_OUTBOUND_INTERRUPT_ENABLE 0x0108C
374+ #define ARCMSR_ARC1214_MESSAGE_WBUFFER 0x02000
375+ #define ARCMSR_ARC1214_MESSAGE_RBUFFER 0x02100
376+ #define ARCMSR_ARC1214_MESSAGE_RWBUFFER 0x02200
377+ /* Host Interrupt Mask */
378+ #define ARCMSR_ARC1214_ALL_INT_ENABLE 0x00001010
379+ #define ARCMSR_ARC1214_ALL_INT_DISABLE 0x00000000
380+ /* Host Interrupt Status */
381+ #define ARCMSR_ARC1214_OUTBOUND_DOORBELL_ISR 0x00001000
382+ #define ARCMSR_ARC1214_OUTBOUND_POSTQUEUE_ISR 0x00000010
383+ /* DoorBell*/
384+ #define ARCMSR_ARC1214_DRV2IOP_DATA_IN_READY 0x00000001
385+ #define ARCMSR_ARC1214_DRV2IOP_DATA_OUT_READ 0x00000002
386+ /*inbound message 0 ready*/
387+ #define ARCMSR_ARC1214_IOP2DRV_DATA_WRITE_OK 0x00000001
388+ /*outbound DATA WRITE isr door bell clear*/
389+ #define ARCMSR_ARC1214_IOP2DRV_DATA_READ_OK 0x00000002
390+ /*outbound message 0 ready*/
391+ #define ARCMSR_ARC1214_IOP2DRV_MESSAGE_CMD_DONE 0x02000000
392+ /*outbound message cmd isr door bell clear*/
393+ /*ARCMSR_HBAMU_MESSAGE_FIRMWARE_OK*/
394+ #define ARCMSR_ARC1214_MESSAGE_FIRMWARE_OK 0x80000000
395+ #define ARCMSR_ARC1214_OUTBOUND_LIST_INTERRUPT_CLEAR 0x00000001
396+ /*
397+ *******************************************************************************
340398** ARECA SCSI COMMAND DESCRIPTOR BLOCK size 0x1F8 (504)
341399*******************************************************************************
342400*/
@@ -357,7 +415,7 @@ struct ARCMSR_CDB
357415#define ARCMSR_CDB_FLAG_ORDEREDQ 0x10
358416
359417 uint8_t msgPages ;
360- uint32_t Context ;
418+ uint32_t msgContext ;
361419 uint32_t DataLength ;
362420 uint8_t Cdb [16 ];
363421 uint8_t DeviceStatus ;
@@ -494,6 +552,56 @@ struct MessageUnit_C{
494552 uint32_t msgcode_rwbuffer [256 ]; /*2200 23FF*/
495553};
496554/*
555+ *********************************************************************
556+ ** Messaging Unit (MU) of Type D processor
557+ *********************************************************************
558+ */
559+ struct InBound_SRB {
560+ uint32_t addressLow ; /* pointer to SRB block */
561+ uint32_t addressHigh ;
562+ uint32_t length ; /* in DWORDs */
563+ uint32_t reserved0 ;
564+ };
565+
566+ struct OutBound_SRB {
567+ uint32_t addressLow ; /* pointer to SRB block */
568+ uint32_t addressHigh ;
569+ };
570+
571+ struct MessageUnit_D {
572+ struct InBound_SRB post_qbuffer [ARCMSR_MAX_ARC1214_POSTQUEUE ];
573+ volatile struct OutBound_SRB
574+ done_qbuffer [ARCMSR_MAX_ARC1214_DONEQUEUE ];
575+ u16 postq_index ;
576+ volatile u16 doneq_index ;
577+ u32 __iomem * chip_id ; /* 0x00004 */
578+ u32 __iomem * cpu_mem_config ; /* 0x00008 */
579+ u32 __iomem * i2o_host_interrupt_mask ; /* 0x00034 */
580+ u32 __iomem * sample_at_reset ; /* 0x00100 */
581+ u32 __iomem * reset_request ; /* 0x00108 */
582+ u32 __iomem * host_int_status ; /* 0x00200 */
583+ u32 __iomem * pcief0_int_enable ; /* 0x0020C */
584+ u32 __iomem * inbound_msgaddr0 ; /* 0x00400 */
585+ u32 __iomem * inbound_msgaddr1 ; /* 0x00404 */
586+ u32 __iomem * outbound_msgaddr0 ; /* 0x00420 */
587+ u32 __iomem * outbound_msgaddr1 ; /* 0x00424 */
588+ u32 __iomem * inbound_doorbell ; /* 0x00460 */
589+ u32 __iomem * outbound_doorbell ; /* 0x00480 */
590+ u32 __iomem * outbound_doorbell_enable ; /* 0x00484 */
591+ u32 __iomem * inboundlist_base_low ; /* 0x01000 */
592+ u32 __iomem * inboundlist_base_high ; /* 0x01004 */
593+ u32 __iomem * inboundlist_write_pointer ; /* 0x01018 */
594+ u32 __iomem * outboundlist_base_low ; /* 0x01060 */
595+ u32 __iomem * outboundlist_base_high ; /* 0x01064 */
596+ u32 __iomem * outboundlist_copy_pointer ; /* 0x0106C */
597+ u32 __iomem * outboundlist_read_pointer ; /* 0x01070 0x01072 */
598+ u32 __iomem * outboundlist_interrupt_cause ; /* 0x1088 */
599+ u32 __iomem * outboundlist_interrupt_enable ; /* 0x108C */
600+ u32 __iomem * message_wbuffer ; /* 0x2000 */
601+ u32 __iomem * message_rbuffer ; /* 0x2100 */
602+ u32 __iomem * msgcode_rwbuffer ; /* 0x2200 */
603+ };
604+ /*
497605*******************************************************************************
498606** Adapter Control Block
499607*******************************************************************************
@@ -505,19 +613,26 @@ struct AdapterControlBlock
505613 #define ACB_ADAPTER_TYPE_B 0x00000002 /* hbb M IOP */
506614 #define ACB_ADAPTER_TYPE_C 0x00000004 /* hbc P IOP */
507615 #define ACB_ADAPTER_TYPE_D 0x00000008 /* hbd A IOP */
616+ u32 roundup_ccbsize ;
508617 struct pci_dev * pdev ;
509618 struct Scsi_Host * host ;
510619 unsigned long vir2phy_offset ;
620+ struct msix_entry entries [ARCMST_NUM_MSIX_VECTORS ];
511621 /* Offset is used in making arc cdb physical to virtual calculations */
512622 uint32_t outbound_int_enable ;
513623 uint32_t cdb_phyaddr_hi32 ;
514624 uint32_t reg_mu_acc_handle0 ;
515625 spinlock_t eh_lock ;
516626 spinlock_t ccblist_lock ;
627+ spinlock_t postq_lock ;
628+ spinlock_t doneq_lock ;
629+ spinlock_t rqbuffer_lock ;
630+ spinlock_t wqbuffer_lock ;
517631 union {
518632 struct MessageUnit_A __iomem * pmuA ;
519633 struct MessageUnit_B * pmuB ;
520634 struct MessageUnit_C __iomem * pmuC ;
635+ struct MessageUnit_D * pmuD ;
521636 };
522637 /* message unit ATU inbound base address0 */
523638 void __iomem * mem_base0 ;
@@ -544,6 +659,8 @@ struct AdapterControlBlock
544659 /* iop init */
545660 #define ACB_F_ABORT 0x0200
546661 #define ACB_F_FIRMWARE_TRAP 0x0400
662+ #define ACB_F_MSI_ENABLED 0x1000
663+ #define ACB_F_MSIX_ENABLED 0x2000
547664 struct CommandControlBlock * pccb_pool [ARCMSR_MAX_FREECCB_NUM ];
548665 /* used for memory free */
549666 struct list_head ccb_free_list ;
@@ -557,19 +674,20 @@ struct AdapterControlBlock
557674 /* dma_coherent used for memory free */
558675 dma_addr_t dma_coherent_handle ;
559676 /* dma_coherent_handle used for memory free */
560- dma_addr_t dma_coherent_handle_hbb_mu ;
677+ dma_addr_t dma_coherent_handle2 ;
678+ void * dma_coherent2 ;
561679 unsigned int uncache_size ;
562680 uint8_t rqbuffer [ARCMSR_MAX_QBUFFER ];
563681 /* data collection buffer for read from 80331 */
564- int32_t rqbuf_firstindex ;
682+ int32_t rqbuf_getIndex ;
565683 /* first of read buffer */
566- int32_t rqbuf_lastindex ;
684+ int32_t rqbuf_putIndex ;
567685 /* last of read buffer */
568686 uint8_t wqbuffer [ARCMSR_MAX_QBUFFER ];
569687 /* data collection buffer for write to 80331 */
570- int32_t wqbuf_firstindex ;
688+ int32_t wqbuf_getIndex ;
571689 /* first of write buffer */
572- int32_t wqbuf_lastindex ;
690+ int32_t wqbuf_putIndex ;
573691 /* last of write buffer */
574692 uint8_t devstate [ARCMSR_MAX_TARGETID ][ARCMSR_MAX_TARGETLUN ];
575693 /* id0 ..... id15, lun0...lun7 */
@@ -594,6 +712,8 @@ struct AdapterControlBlock
594712 #define FW_DEADLOCK 0x0010
595713 atomic_t rq_map_token ;
596714 atomic_t ante_token_value ;
715+ uint32_t maxOutstanding ;
716+ int msix_vector_count ;
597717};/* HW_DEVICE_EXTENSION */
598718/*
599719*******************************************************************************
@@ -606,7 +726,7 @@ struct CommandControlBlock{
606726 struct list_head list ; /*x32: 8byte, x64: 16byte*/
607727 struct scsi_cmnd * pcmd ; /*8 bytes pointer of linux scsi command */
608728 struct AdapterControlBlock * acb ; /*x32: 4byte, x64: 8byte*/
609- uint32_t cdb_phyaddr_pattern ; /*x32: 4byte, x64: 4byte*/
729+ uint32_t cdb_phyaddr ; /*x32: 4byte, x64: 4byte*/
610730 uint32_t arc_cdb_size ; /*x32:4byte,x64:4byte*/
611731 uint16_t ccb_flags ; /*x32: 2byte, x64: 2byte*/
612732 #define CCB_FLAG_READ 0x0000
@@ -684,8 +804,10 @@ struct SENSE_DATA
684804#define ARCMSR_MU_OUTBOUND_MESSAGE0_INTMASKENABLE 0x01
685805#define ARCMSR_MU_OUTBOUND_ALL_INTMASKENABLE 0x1F
686806
687- extern void arcmsr_post_ioctldata2iop (struct AdapterControlBlock * );
688- extern void arcmsr_iop_message_read (struct AdapterControlBlock * );
807+ extern void arcmsr_write_ioctldata2iop (struct AdapterControlBlock * );
808+ extern uint32_t arcmsr_Read_iop_rqbuffer_data (struct AdapterControlBlock * ,
809+ struct QBUFFER __iomem * );
810+ extern void arcmsr_clear_iop2drv_rqueue_buffer (struct AdapterControlBlock * );
689811extern struct QBUFFER __iomem * arcmsr_get_iop_rqbuffer (struct AdapterControlBlock * );
690812extern struct device_attribute * arcmsr_host_attrs [];
691813extern int arcmsr_alloc_sysfs_attr (struct AdapterControlBlock * );
0 commit comments