1285809Sscottl/*******************************************************************************
2285809Sscottl**Copyright (c) 2014 PMC-Sierra, Inc.  All rights reserved.
3285809Sscottl *
4285809Sscottl*Redistribution and use in source and binary forms, with or without modification, are permitted provided
5285809Sscottl*that the following conditions are met:
6285809Sscottl*1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7285809Sscottl*2. Redistributions in binary form must reproduce the above copyright notice,
8285809Sscottl*this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9285809Sscottl*
10285809Sscottl*THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
11285809Sscottl*
12285809Sscottl*INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
13285809Sscottl*ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
14285809Sscottl*SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
15285809Sscottl*OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
16285809Sscottl*WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
17285809Sscottl*THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
18285809Sscottl**
19285809Sscottl* $FreeBSD$
20285809Sscottl**
21285809Sscottl*******************************************************************************/
22285809Sscottl
23285809Sscottl//void agtiapi_cam_init(struct agtiapi_softc *sc);
24285809Sscottl//void agtiapi_cam_poll( struct cam_sim *asim );
25285809Sscottlint agtiapi_QueueCmnd_(struct agtiapi_softc *, union ccb * );
26285809Sscottlint agtiapi_alloc_ostimem(struct agtiapi_softc *);
27285809Sscottlint agtiapi_alloc_requests(struct agtiapi_softc *);
28285809Sscottlstatic int agtiapi_PrepareSGList(struct agtiapi_softc *, ccb_t *);
29285809Sscottlstatic void agtiapi_PrepareSGListCB( void *arg,
30285809Sscottl                                     bus_dma_segment_t *dm_segs,
31285809Sscottl                                     int nseg,
32285809Sscottl                                     int error );
33285809Sscottlstatic int agtiapi_PrepareSMPSGList(struct agtiapi_softc *pmcsc, ccb_t *);
34285809Sscottlstatic void agtiapi_PrepareSMPSGListCB( void *arg,
35285809Sscottl                                        bus_dma_segment_t *dm_segs,
36285809Sscottl                                        int nsegs,
37285809Sscottl                                        int error );
38285809Sscottlint agtiapi_eh_HostReset( struct agtiapi_softc *pmcsc, union ccb *cmnd );
39285809SscottlSTATIC void agtiapi_FreeCCB(struct agtiapi_softc *pmcsc, pccb_t pccb);
40285809SscottlSTATIC void agtiapi_FreeSMPCCB(struct agtiapi_softc *pmcsc, pccb_t pccb);
41285809SscottlSTATIC void agtiapi_FreeTMCCB(struct agtiapi_softc *pmcsc, pccb_t pccb);
42285809SscottlSTATIC pccb_t agtiapi_GetCCB(struct agtiapi_softc *pmcsc);
43285809Sscottlvoid agtiapi_SetLunField( ccb_t *pccb );
44285809SscottlSTATIC void agtiapi_QueueCCB( struct agtiapi_softc *pmcsc,
45285809Sscottl                              pccb_t *phead,
46285809Sscottl                              pccb_t *ptail,
47285809Sscottl#ifdef AGTIAPI_LOCAL_LOCK
48285809Sscottl                              struct mtx *mutex,
49285809Sscottl#endif
50285809Sscottl                              ccb_t *pccb );
51285809Sscottlstatic int agtiapi_QueueSMP(struct agtiapi_softc *, union ccb * );
52285809SscottlSTATIC void agtiapi_StartIO(struct agtiapi_softc *pmcsc);
53285809SscottlSTATIC void agtiapi_StartSMP(struct agtiapi_softc *pmcsc);
54285809SscottlSTATIC void agtiapi_DumpCCB(ccb_t *pccb);
55285809SscottlSTATIC void agtiapi_Done(struct agtiapi_softc *pmcsc, ccb_t *pccb);
56285809SscottlSTATIC void agtiapi_SMPDone(struct agtiapi_softc *pmcsc, ccb_t *pccb);
57285809Sscottl// void agtiapi_LogEvent(ag_card_t *, U16, U16, U32 *, U08, S08 *, ...);
58285809SscottlSTATIC U32 agtiapi_CheckError(struct agtiapi_softc *pmcsc, ccb_t *pccb);
59285809SscottlSTATIC U32 agtiapi_CheckSMPError(struct agtiapi_softc *pmcsc, ccb_t *pccb);
60285809SscottlSTATIC void agtiapi_Retry(struct agtiapi_softc *pmcsc, ccb_t *pccb);
61285809Sscottlstatic void agtiapi_scan(struct agtiapi_softc *pmcsc);
62285809SscottlSTATIC int agtiapi_FindWWNListNext( ag_tgt_map_t  * pWWNList, int lstMax );
63285809SscottlSTATIC U32 agtiapi_GetDevHandle(struct agtiapi_softc *pmcsc,
64285809Sscottl				ag_portal_info_t *pPortalInfo,
65285809Sscottl				U32 eType, U32 eStatus);
66285809Sscottl
67285809Sscottlint agtiapi_StartTM(struct agtiapi_softc *pCard, ccb_t *pccb);
68285809Sscottl
69285809SscottlSTATIC void wwnprintk(unsigned char *name, int len);
70285809SscottlSTATIC int wwncpy(ag_device_t      *pDevice);
71285809Sscottl
72285809SscottlSTATIC void agtiapi_DiscoverTgt(struct agtiapi_softc *pCard);
73285809SscottlagBOOLEAN agtiapi_CheckCB( struct agtiapi_softc *pCard,
74285809Sscottl                           U32 milisec,
75285809Sscottl                           U32 flag,
76285809Sscottl                           volatile U32 *pStatus );
77285809SscottlSTATIC agBOOLEAN  agtiapi_DeQueueCCB( struct agtiapi_softc *,
78285809Sscottl                                      pccb_t *,
79285809Sscottl                                      pccb_t *,
80285809Sscottl#ifdef AGTIAPI_LOCAL_LOCK
81285809Sscottl                                      struct mtx *,
82285809Sscottl#endif
83285809Sscottl                                      ccb_t * );
84285809Sscottl
85285809Sscottlvoid agtiapi_CheckAllVectors( struct agtiapi_softc *pCard, bit32 context );
86285809Sscottl
87285809SscottlSTATIC U32 agtiapi_InitCCBs( struct agtiapi_softc *pCard,
88285809Sscottl                             int tgtCount,
89285809Sscottl                             int tid );
90285809SscottlSTATIC void agtiapi_PrepCCBs( struct agtiapi_softc *pCard,
91285809Sscottl                              ccb_hdr_t *hdr,
92285809Sscottl                              U32 size,
93285809Sscottl                              U32 max_ccb,
94285809Sscottl                              int tid );
95285809Sscottl
96285809Sscottl
97285809Sscottl#ifdef LINUX_PERBI_SUPPORT
98285809Sscottlvoid  agtiapi_GetWWNMappings( struct agtiapi_softc *, ag_mapping_t * );
99285809Sscottl//#ifndef HOTPLUG_SUPPORT
100285809SscottlSTATIC void agtiapi_MapWWNList( struct agtiapi_softc *pCard );
101285809Sscottl//#endif
102285809Sscottl#endif
103285809Sscottl
104285809SscottlSTATIC void agtiapi_ReleaseCCBs( struct agtiapi_softc *pCard );
105285809SscottlSTATIC void agtiapi_clrRmScan(   struct agtiapi_softc *pCard );
106285809SscottlSTATIC void agtiapi_TITimer(    void *data );
107285809SscottlSTATIC void agtiapi_devRmCheck( void *data );
108285809Sscottl
109285809Sscottlint agtiapi_ReleaseHBA( device_t dev );
110285809Sscottl
111285809Sscottlvoid agtiapi_IntrHandler0(  void *arg );
112285809Sscottlvoid agtiapi_IntrHandler1(  void *arg );
113285809Sscottlvoid agtiapi_IntrHandler2(  void *arg );
114285809Sscottlvoid agtiapi_IntrHandler3(  void *arg );
115285809Sscottlvoid agtiapi_IntrHandler4(  void *arg );
116285809Sscottlvoid agtiapi_IntrHandler5(  void *arg );
117285809Sscottlvoid agtiapi_IntrHandler6(  void *arg );
118285809Sscottlvoid agtiapi_IntrHandler7(  void *arg );
119285809Sscottlvoid agtiapi_IntrHandler8(  void *arg );
120285809Sscottlvoid agtiapi_IntrHandler9(  void *arg );
121285809Sscottlvoid agtiapi_IntrHandler10( void *arg );
122285809Sscottlvoid agtiapi_IntrHandler11( void *arg );
123285809Sscottlvoid agtiapi_IntrHandler12( void *arg );
124285809Sscottlvoid agtiapi_IntrHandler13( void *arg );
125285809Sscottlvoid agtiapi_IntrHandler14( void *arg );
126285809Sscottlvoid agtiapi_IntrHandler15( void *arg );
127285809Sscottlvoid agtiapi_IntrHandlerx_( void *arg, int index );
128285809SscottlSTATIC agBOOLEAN agtiapi_InitCardSW( struct agtiapi_softc *pmsc );
129285809SscottlSTATIC agBOOLEAN agtiapi_InitCardHW( struct agtiapi_softc *pmsc );
130285809SscottlSTATIC void agtiapi_DumpCDB( const char *ptitle, ccb_t *pccb );
131285809Sscottlvoid agtiapi_hexdump( const char *ptitle, bit8 *pbuf, int len );
132285809Sscottlstatic void agtiapi_SglMemoryCB( void *arg,
133285809Sscottl                                 bus_dma_segment_t *dm_segs,
134285809Sscottl                                 int nseg,
135285809Sscottl                                 int error );
136285809Sscottlstatic void agtiapi_MemoryCB( void *arg,
137285809Sscottl                              bus_dma_segment_t *dm_segs,
138285809Sscottl                              int nseg,
139285809Sscottl                              int error );
140285809SscottlU32 agtiapi_ResetCard( struct agtiapi_softc *pCard, unsigned long *flags );
141285809Sscottlint agtiapi_DoSoftReset( struct agtiapi_softc *pmcsc );
142285809Sscottl
143285809SscottlSTATIC void agtiapi_FlushCCBs(   struct agtiapi_softc *pCard, U32 flag );
144285809Sscottl
145