]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - sys/dev/pms/freebsd/driver/ini/src/agtiproto.h
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / sys / dev / pms / freebsd / driver / ini / src / agtiproto.h
1 /*******************************************************************************
2 **Copyright (c) 2014 PMC-Sierra, Inc.  All rights reserved. 
3  *
4 *Redistribution and use in source and binary forms, with or without modification, are permitted provided 
5 *that the following conditions are met: 
6 *1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
7 *2. Redistributions in binary form must reproduce the above copyright notice, 
8 *this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 
9 *
10 *THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
11 *
12 *INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
13 *ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
14 *SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
15 *OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
16 *WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
17 *THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
18 **
19 * $FreeBSD$
20 **
21 *******************************************************************************/
22
23 //void agtiapi_cam_init(struct agtiapi_softc *sc);
24 //void agtiapi_cam_poll( struct cam_sim *asim );
25 int agtiapi_QueueCmnd_(struct agtiapi_softc *, union ccb * );
26 int agtiapi_alloc_ostimem(struct agtiapi_softc *);
27 int agtiapi_alloc_requests(struct agtiapi_softc *);
28 static int agtiapi_PrepareSGList(struct agtiapi_softc *, ccb_t *);
29 static void agtiapi_PrepareSGListCB( void *arg,
30                                      bus_dma_segment_t *dm_segs,
31                                      int nseg,
32                                      int error );
33 static int agtiapi_PrepareSMPSGList(struct agtiapi_softc *pmcsc, ccb_t *);
34 static void agtiapi_PrepareSMPSGListCB( void *arg,
35                                         bus_dma_segment_t *dm_segs,
36                                         int nsegs,
37                                         int error );
38 int agtiapi_eh_HostReset( struct agtiapi_softc *pmcsc, union ccb *cmnd );
39 STATIC void agtiapi_FreeCCB(struct agtiapi_softc *pmcsc, pccb_t pccb);
40 STATIC void agtiapi_FreeSMPCCB(struct agtiapi_softc *pmcsc, pccb_t pccb);
41 STATIC void agtiapi_FreeTMCCB(struct agtiapi_softc *pmcsc, pccb_t pccb);
42 STATIC pccb_t agtiapi_GetCCB(struct agtiapi_softc *pmcsc);
43 void agtiapi_SetLunField( ccb_t *pccb );
44 STATIC void agtiapi_QueueCCB( struct agtiapi_softc *pmcsc,
45                               pccb_t *phead,
46                               pccb_t *ptail, 
47 #ifdef AGTIAPI_LOCAL_LOCK
48                               struct mtx *mutex,
49 #endif
50                               ccb_t *pccb );
51 static int agtiapi_QueueSMP(struct agtiapi_softc *, union ccb * );
52 STATIC void agtiapi_StartIO(struct agtiapi_softc *pmcsc);
53 STATIC void agtiapi_StartSMP(struct agtiapi_softc *pmcsc);
54 STATIC void agtiapi_DumpCCB(ccb_t *pccb);
55 STATIC void agtiapi_Done(struct agtiapi_softc *pmcsc, ccb_t *pccb);
56 STATIC void agtiapi_SMPDone(struct agtiapi_softc *pmcsc, ccb_t *pccb);
57 // void agtiapi_LogEvent(ag_card_t *, U16, U16, U32 *, U08, S08 *, ...);
58 STATIC U32 agtiapi_CheckError(struct agtiapi_softc *pmcsc, ccb_t *pccb);
59 STATIC U32 agtiapi_CheckSMPError(struct agtiapi_softc *pmcsc, ccb_t *pccb);
60 STATIC void agtiapi_Retry(struct agtiapi_softc *pmcsc, ccb_t *pccb);
61 static void agtiapi_scan(struct agtiapi_softc *pmcsc);
62 STATIC int agtiapi_FindWWNListNext( ag_tgt_map_t  * pWWNList, int lstMax );
63 STATIC U32 agtiapi_GetDevHandle(struct agtiapi_softc *pmcsc, 
64                                 ag_portal_info_t *pPortalInfo, 
65                                 U32 eType, U32 eStatus);
66
67 int agtiapi_StartTM(struct agtiapi_softc *pCard, ccb_t *pccb);
68
69 STATIC void wwnprintk(unsigned char *name, int len);
70 STATIC int wwncpy(ag_device_t      *pDevice);
71
72 STATIC void agtiapi_DiscoverTgt(struct agtiapi_softc *pCard);
73 agBOOLEAN agtiapi_CheckCB( struct agtiapi_softc *pCard,
74                            U32 milisec,
75                            U32 flag,
76                            volatile U32 *pStatus );
77 STATIC agBOOLEAN  agtiapi_DeQueueCCB( struct agtiapi_softc *,
78                                       pccb_t *,
79                                       pccb_t *,
80 #ifdef AGTIAPI_LOCAL_LOCK
81                                       struct mtx *,
82 #endif
83                                       ccb_t * );
84
85 void agtiapi_CheckAllVectors( struct agtiapi_softc *pCard, bit32 context );
86
87 STATIC U32 agtiapi_InitCCBs( struct agtiapi_softc *pCard,
88                              int tgtCount,
89                              int tid );
90 STATIC void agtiapi_PrepCCBs( struct agtiapi_softc *pCard,
91                               ccb_hdr_t *hdr,
92                               U32 size,
93                               U32 max_ccb,
94                               int tid );
95
96
97 #ifdef LINUX_PERBI_SUPPORT
98 void  agtiapi_GetWWNMappings( struct agtiapi_softc *, ag_mapping_t * );
99 //#ifndef HOTPLUG_SUPPORT
100 STATIC void agtiapi_MapWWNList( struct agtiapi_softc *pCard );
101 //#endif
102 #endif
103
104 STATIC void agtiapi_ReleaseCCBs( struct agtiapi_softc *pCard );
105 STATIC void agtiapi_clrRmScan(   struct agtiapi_softc *pCard );
106 STATIC void agtiapi_TITimer(    void *data );
107 STATIC void agtiapi_devRmCheck( void *data );
108
109 int agtiapi_ReleaseHBA( device_t dev );
110
111 void agtiapi_IntrHandler0(  void *arg );
112 void agtiapi_IntrHandler1(  void *arg );
113 void agtiapi_IntrHandler2(  void *arg );
114 void agtiapi_IntrHandler3(  void *arg );
115 void agtiapi_IntrHandler4(  void *arg );
116 void agtiapi_IntrHandler5(  void *arg );
117 void agtiapi_IntrHandler6(  void *arg );
118 void agtiapi_IntrHandler7(  void *arg );
119 void agtiapi_IntrHandler8(  void *arg );
120 void agtiapi_IntrHandler9(  void *arg );
121 void agtiapi_IntrHandler10( void *arg );
122 void agtiapi_IntrHandler11( void *arg );
123 void agtiapi_IntrHandler12( void *arg );
124 void agtiapi_IntrHandler13( void *arg );
125 void agtiapi_IntrHandler14( void *arg );
126 void agtiapi_IntrHandler15( void *arg );
127 void agtiapi_IntrHandlerx_( void *arg, int index );
128 STATIC agBOOLEAN agtiapi_InitCardSW( struct agtiapi_softc *pmsc );
129 STATIC agBOOLEAN agtiapi_InitCardHW( struct agtiapi_softc *pmsc );
130 STATIC void agtiapi_DumpCDB( const char *ptitle, ccb_t *pccb );
131 void agtiapi_hexdump( const char *ptitle, bit8 *pbuf, int len );
132 static void agtiapi_SglMemoryCB( void *arg,
133                                  bus_dma_segment_t *dm_segs,
134                                  int nseg,
135                                  int error );
136 static void agtiapi_MemoryCB( void *arg,
137                               bus_dma_segment_t *dm_segs,
138                               int nseg,
139                               int error );
140 U32 agtiapi_ResetCard( struct agtiapi_softc *pCard, unsigned long *flags );
141 int agtiapi_DoSoftReset( struct agtiapi_softc *pmcsc );
142
143 STATIC void agtiapi_FlushCCBs(   struct agtiapi_softc *pCard, U32 flag );
144