[brcm63xx] remove 2.6.33 support
[openwrt.git] / target / linux / s3c24xx / files-2.6.30 / drivers / ar6000 / htc / htc_internal.h
1 /*
2 *
3 * Copyright (c) 2007 Atheros Communications Inc.
4 * All rights reserved.
5 *
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation;
10 *
11 * Software distributed under the License is distributed on an "AS
12 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
13 * implied. See the License for the specific language governing
14 * rights and limitations under the License.
15 *
16 *
17 *
18 */
19
20 #ifndef _HTC_INTERNAL_H_
21 #define _HTC_INTERNAL_H_
22
23 /* for debugging, uncomment this to capture the last frame header, on frame header
24 * processing errors, the last frame header is dump for comparison */
25 //#define HTC_CAPTURE_LAST_FRAME
26
27 //#define HTC_EP_STAT_PROFILING
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif /* __cplusplus */
32
33 /* Header files */
34 #include "a_config.h"
35 #include "athdefs.h"
36 #include "a_types.h"
37 #include "a_osapi.h"
38 #include "a_debug.h"
39 #include "htc.h"
40 #include "htc_api.h"
41 #include "bmi_msg.h"
42 #include "hif.h"
43 #include "ar6k.h"
44
45 /* HTC operational parameters */
46 #define HTC_TARGET_RESPONSE_TIMEOUT 2000 /* in ms */
47 #define HTC_TARGET_DEBUG_INTR_MASK 0x01
48 #define HTC_TARGET_CREDIT_INTR_MASK 0xF0
49
50 typedef struct _HTC_ENDPOINT {
51 HTC_SERVICE_ID ServiceID; /* service ID this endpoint is bound to
52 non-zero value means this endpoint is in use */
53 HTC_PACKET_QUEUE TxQueue; /* HTC frame buffer TX queue */
54 HTC_PACKET_QUEUE RxBuffers; /* HTC frame buffer RX list */
55 HTC_ENDPOINT_CREDIT_DIST CreditDist; /* credit distribution structure (exposed to driver layer) */
56 HTC_EP_CALLBACKS EpCallBacks; /* callbacks associated with this endpoint */
57 int MaxTxQueueDepth; /* max depth of the TX queue before we need to
58 call driver's full handler */
59 int CurrentTxQueueDepth; /* current TX queue depth */
60 int MaxMsgLength; /* max length of endpoint message */
61 #ifdef HTC_EP_STAT_PROFILING
62 HTC_ENDPOINT_STATS EndPointStats; /* endpoint statistics */
63 #endif
64 } HTC_ENDPOINT;
65
66 #ifdef HTC_EP_STAT_PROFILING
67 #define INC_HTC_EP_STAT(p,stat,count) (p)->EndPointStats.stat += (count);
68 #else
69 #define INC_HTC_EP_STAT(p,stat,count)
70 #endif
71
72 #define HTC_SERVICE_TX_PACKET_TAG HTC_TX_PACKET_TAG_INTERNAL
73
74 #define NUM_CONTROL_BUFFERS 8
75 #define NUM_CONTROL_TX_BUFFERS 2
76 #define NUM_CONTROL_RX_BUFFERS (NUM_CONTROL_BUFFERS - NUM_CONTROL_TX_BUFFERS)
77
78 #define HTC_CONTROL_BUFFER_SIZE (HTC_MAX_CONTROL_MESSAGE_LENGTH + HTC_HDR_LENGTH)
79
80 typedef struct HTC_CONTROL_BUFFER {
81 HTC_PACKET HtcPacket;
82 A_UINT8 Buffer[HTC_CONTROL_BUFFER_SIZE];
83 } HTC_CONTROL_BUFFER;
84
85 /* our HTC target state */
86 typedef struct _HTC_TARGET {
87 HTC_ENDPOINT EndPoint[ENDPOINT_MAX];
88 HTC_CONTROL_BUFFER HTCControlBuffers[NUM_CONTROL_BUFFERS];
89 HTC_ENDPOINT_CREDIT_DIST *EpCreditDistributionListHead;
90 HTC_PACKET_QUEUE ControlBufferTXFreeList;
91 HTC_PACKET_QUEUE ControlBufferRXFreeList;
92 HTC_CREDIT_DIST_CALLBACK DistributeCredits;
93 HTC_CREDIT_INIT_CALLBACK InitCredits;
94 void *pCredDistContext;
95 int TargetCredits;
96 int TargetCreditSize;
97 A_MUTEX_T HTCLock;
98 A_MUTEX_T HTCRxLock;
99 A_MUTEX_T HTCTxLock;
100 AR6K_DEVICE Device; /* AR6K - specific state */
101 A_UINT32 HTCStateFlags;
102 HTC_ENDPOINT_ID EpWaitingForBuffers;
103 A_BOOL TargetFailure;
104 void *pInstanceContext;
105 #define HTC_STATE_WAIT_BUFFERS (1 << 0)
106 #define HTC_STATE_STOPPING (1 << 1)
107 #ifdef HTC_CAPTURE_LAST_FRAME
108 HTC_FRAME_HDR LastFrameHdr; /* useful for debugging */
109 A_UINT8 LastTrailer[256];
110 A_UINT8 LastTrailerLength;
111 #endif
112 } HTC_TARGET;
113
114 #define HTC_STOPPING(t) ((t)->HTCStateFlags & HTC_STATE_STOPPING)
115 #define LOCK_HTC(t) A_MUTEX_LOCK(&(t)->HTCLock);
116 #define UNLOCK_HTC(t) A_MUTEX_UNLOCK(&(t)->HTCLock);
117 #define LOCK_HTC_RX(t) A_MUTEX_LOCK(&(t)->HTCRxLock);
118 #define UNLOCK_HTC_RX(t) A_MUTEX_UNLOCK(&(t)->HTCRxLock);
119 #define LOCK_HTC_TX(t) A_MUTEX_LOCK(&(t)->HTCTxLock);
120 #define UNLOCK_HTC_TX(t) A_MUTEX_UNLOCK(&(t)->HTCTxLock);
121
122 #define GET_HTC_TARGET_FROM_HANDLE(hnd) ((HTC_TARGET *)(hnd))
123 #define HTC_RECYCLE_RX_PKT(target,p) \
124 { \
125 HTC_PACKET_RESET_RX(pPacket); \
126 HTCAddReceivePkt((HTC_HANDLE)(target),(p)); \
127 }
128
129 /* internal HTC functions */
130 void HTCControlTxComplete(void *Context, HTC_PACKET *pPacket);
131 void HTCControlRecv(void *Context, HTC_PACKET *pPacket);
132 A_STATUS HTCWaitforControlMessage(HTC_TARGET *target, HTC_PACKET **ppControlPacket);
133 HTC_PACKET *HTCAllocControlBuffer(HTC_TARGET *target, HTC_PACKET_QUEUE *pList);
134 void HTCFreeControlBuffer(HTC_TARGET *target, HTC_PACKET *pPacket, HTC_PACKET_QUEUE *pList);
135 A_STATUS HTCIssueSend(HTC_TARGET *target, HTC_PACKET *pPacket, A_UINT8 Flags);
136 A_STATUS HTCIssueRecv(HTC_TARGET *target, HTC_PACKET *pPacket);
137 void HTCRecvCompleteHandler(void *Context, HTC_PACKET *pPacket);
138 A_STATUS HTCRecvMessagePendingHandler(void *Context, A_UINT32 LookAhead, A_BOOL *pAsyncProc);
139 void HTCProcessCreditRpt(HTC_TARGET *target, HTC_CREDIT_REPORT *pRpt, int NumEntries, HTC_ENDPOINT_ID FromEndpoint);
140 A_STATUS HTCSendSetupComplete(HTC_TARGET *target);
141 void HTCFlushRecvBuffers(HTC_TARGET *target);
142 void HTCFlushSendPkts(HTC_TARGET *target);
143 void DumpCreditDist(HTC_ENDPOINT_CREDIT_DIST *pEPDist);
144 void DumpCreditDistStates(HTC_TARGET *target);
145 void DebugDumpBytes(A_UCHAR *buffer, A_UINT16 length, char *pDescription);
146
147 static INLINE HTC_PACKET *HTC_ALLOC_CONTROL_TX(HTC_TARGET *target) {
148 HTC_PACKET *pPacket = HTCAllocControlBuffer(target,&target->ControlBufferTXFreeList);
149 if (pPacket != NULL) {
150 /* set payload pointer area with some headroom */
151 pPacket->pBuffer = pPacket->pBufferStart + HTC_HDR_LENGTH;
152 }
153 return pPacket;
154 }
155
156 #define HTC_FREE_CONTROL_TX(t,p) HTCFreeControlBuffer((t),(p),&(t)->ControlBufferTXFreeList)
157 #define HTC_ALLOC_CONTROL_RX(t) HTCAllocControlBuffer((t),&(t)->ControlBufferRXFreeList)
158 #define HTC_FREE_CONTROL_RX(t,p) \
159 { \
160 HTC_PACKET_RESET_RX(p); \
161 HTCFreeControlBuffer((t),(p),&(t)->ControlBufferRXFreeList); \
162 }
163
164 #ifdef __cplusplus
165 }
166 #endif
167
168 #endif /* _HTC_INTERNAL_H_ */
This page took 0.051215 seconds and 5 git commands to generate.