agtiproto.h revision 285809
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 );
25int agtiapi_QueueCmnd_(struct agtiapi_softc *, union ccb * );
26int agtiapi_alloc_ostimem(struct agtiapi_softc *);
27int agtiapi_alloc_requests(struct agtiapi_softc *);
28static int agtiapi_PrepareSGList(struct agtiapi_softc *, ccb_t *);
29static void agtiapi_PrepareSGListCB( void *arg,
30                                     bus_dma_segment_t *dm_segs,
31                                     int nseg,
32                                     int error );
33static int agtiapi_PrepareSMPSGList(struct agtiapi_softc *pmcsc, ccb_t *);
34static void agtiapi_PrepareSMPSGListCB( void *arg,
35                                        bus_dma_segment_t *dm_segs,
36                                        int nsegs,
37                                        int error );
38int agtiapi_eh_HostReset( struct agtiapi_softc *pmcsc, union ccb *cmnd );
39STATIC void agtiapi_FreeCCB(struct agtiapi_softc *pmcsc, pccb_t pccb);
40STATIC void agtiapi_FreeSMPCCB(struct agtiapi_softc *pmcsc, pccb_t pccb);
41STATIC void agtiapi_FreeTMCCB(struct agtiapi_softc *pmcsc, pccb_t pccb);
42STATIC pccb_t agtiapi_GetCCB(struct agtiapi_softc *pmcsc);
43void agtiapi_SetLunField( ccb_t *pccb );
44STATIC 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 );
51static int agtiapi_QueueSMP(struct agtiapi_softc *, union ccb * );
52STATIC void agtiapi_StartIO(struct agtiapi_softc *pmcsc);
53STATIC void agtiapi_StartSMP(struct agtiapi_softc *pmcsc);
54STATIC void agtiapi_DumpCCB(ccb_t *pccb);
55STATIC void agtiapi_Done(struct agtiapi_softc *pmcsc, ccb_t *pccb);
56STATIC void agtiapi_SMPDone(struct agtiapi_softc *pmcsc, ccb_t *pccb);
57// void agtiapi_LogEvent(ag_card_t *, U16, U16, U32 *, U08, S08 *, ...);
58STATIC U32 agtiapi_CheckError(struct agtiapi_softc *pmcsc, ccb_t *pccb);
59STATIC U32 agtiapi_CheckSMPError(struct agtiapi_softc *pmcsc, ccb_t *pccb);
60STATIC void agtiapi_Retry(struct agtiapi_softc *pmcsc, ccb_t *pccb);
61static void agtiapi_scan(struct agtiapi_softc *pmcsc);
62STATIC int agtiapi_FindWWNListNext( ag_tgt_map_t  * pWWNList, int lstMax );
63STATIC U32 agtiapi_GetDevHandle(struct agtiapi_softc *pmcsc,
64				ag_portal_info_t *pPortalInfo,
65				U32 eType, U32 eStatus);
66
67int agtiapi_StartTM(struct agtiapi_softc *pCard, ccb_t *pccb);
68
69STATIC void wwnprintk(unsigned char *name, int len);
70STATIC int wwncpy(ag_device_t      *pDevice);
71
72STATIC void agtiapi_DiscoverTgt(struct agtiapi_softc *pCard);
73agBOOLEAN agtiapi_CheckCB( struct agtiapi_softc *pCard,
74                           U32 milisec,
75                           U32 flag,
76                           volatile U32 *pStatus );
77STATIC 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
85void agtiapi_CheckAllVectors( struct agtiapi_softc *pCard, bit32 context );
86
87STATIC U32 agtiapi_InitCCBs( struct agtiapi_softc *pCard,
88                             int tgtCount,
89                             int tid );
90STATIC 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
98void  agtiapi_GetWWNMappings( struct agtiapi_softc *, ag_mapping_t * );
99//#ifndef HOTPLUG_SUPPORT
100STATIC void agtiapi_MapWWNList( struct agtiapi_softc *pCard );
101//#endif
102#endif
103
104STATIC void agtiapi_ReleaseCCBs( struct agtiapi_softc *pCard );
105STATIC void agtiapi_clrRmScan(   struct agtiapi_softc *pCard );
106STATIC void agtiapi_TITimer(    void *data );
107STATIC void agtiapi_devRmCheck( void *data );
108
109int agtiapi_ReleaseHBA( device_t dev );
110
111void agtiapi_IntrHandler0(  void *arg );
112void agtiapi_IntrHandler1(  void *arg );
113void agtiapi_IntrHandler2(  void *arg );
114void agtiapi_IntrHandler3(  void *arg );
115void agtiapi_IntrHandler4(  void *arg );
116void agtiapi_IntrHandler5(  void *arg );
117void agtiapi_IntrHandler6(  void *arg );
118void agtiapi_IntrHandler7(  void *arg );
119void agtiapi_IntrHandler8(  void *arg );
120void agtiapi_IntrHandler9(  void *arg );
121void agtiapi_IntrHandler10( void *arg );
122void agtiapi_IntrHandler11( void *arg );
123void agtiapi_IntrHandler12( void *arg );
124void agtiapi_IntrHandler13( void *arg );
125void agtiapi_IntrHandler14( void *arg );
126void agtiapi_IntrHandler15( void *arg );
127void agtiapi_IntrHandlerx_( void *arg, int index );
128STATIC agBOOLEAN agtiapi_InitCardSW( struct agtiapi_softc *pmsc );
129STATIC agBOOLEAN agtiapi_InitCardHW( struct agtiapi_softc *pmsc );
130STATIC void agtiapi_DumpCDB( const char *ptitle, ccb_t *pccb );
131void agtiapi_hexdump( const char *ptitle, bit8 *pbuf, int len );
132static void agtiapi_SglMemoryCB( void *arg,
133                                 bus_dma_segment_t *dm_segs,
134                                 int nseg,
135                                 int error );
136static void agtiapi_MemoryCB( void *arg,
137                              bus_dma_segment_t *dm_segs,
138                              int nseg,
139                              int error );
140U32 agtiapi_ResetCard( struct agtiapi_softc *pCard, unsigned long *flags );
141int agtiapi_DoSoftReset( struct agtiapi_softc *pmcsc );
142
143STATIC void agtiapi_FlushCCBs(   struct agtiapi_softc *pCard, U32 flag );
144
145