Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: chromeos/drivers/ath6kl/htc2/htc_internal.h

Issue 646055: Atheros AR600x driver + build glue (Closed)
Patch Set: Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/drivers/ath6kl/htc2/htc_debug.h ('k') | chromeos/drivers/ath6kl/htc2/htc_recv.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 //------------------------------------------------------------------------------
2 // <copyright file="htc_internal.h" company="Atheros">
3 // Copyright (c) 2007-2008 Atheros Corporation. All rights reserved.
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License version 2 as
7 // published by the Free Software Foundation;
8 //
9 // Software distributed under the License is distributed on an "AS
10 // IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
11 // implied. See the License for the specific language governing
12 // rights and limitations under the License.
13 //
14 //
15 //------------------------------------------------------------------------------
16 //==============================================================================
17 // Author(s): ="Atheros"
18 //==============================================================================
19 #ifndef _HTC_INTERNAL_H_
20 #define _HTC_INTERNAL_H_
21
22 /* for debugging, uncomment this to capture the last frame header, on frame head er
23 * processing errors, the last frame header is dump for comparison */
24 //#define HTC_CAPTURE_LAST_FRAME
25
26 //#define HTC_EP_STAT_PROFILING
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif /* __cplusplus */
31
32 /* Header files */
33 #include "a_config.h"
34 #include "athdefs.h"
35 #include "a_types.h"
36 #include "a_osapi.h"
37 #include "htc_debug.h"
38 #include "htc.h"
39 #include "htc_api.h"
40 #include "bmi_msg.h"
41 #include "hif.h"
42 #include "AR6000/ar6k.h"
43
44 /* HTC operational parameters */
45 #define HTC_TARGET_RESPONSE_TIMEOUT 2000 /* in ms */
46 #define HTC_TARGET_DEBUG_INTR_MASK 0x01
47 #define HTC_TARGET_CREDIT_INTR_MASK 0xF0
48
49 #define HTC_HOST_MAX_MSG_PER_BUNDLE 8
50 #define HTC_MIN_HTC_MSGS_TO_BUNDLE 2
51
52 /* packet flags */
53
54 #define HTC_RX_PKT_IGNORE_LOOKAHEAD (1 << 0)
55 #define HTC_RX_PKT_REFRESH_HDR (1 << 1)
56 #define HTC_RX_PKT_PART_OF_BUNDLE (1 << 2)
57 #define HTC_RX_PKT_NO_RECYCLE (1 << 3)
58
59 /* scatter request flags */
60
61 #define HTC_SCATTER_REQ_FLAGS_PARTIAL_BUNDLE (1 << 0)
62
63 typedef struct _HTC_ENDPOINT {
64 HTC_ENDPOINT_ID Id;
65 HTC_SERVICE_ID ServiceID; /* service ID this endpoint is b ound to
66 non-zero value means this end point is in use */
67 HTC_PACKET_QUEUE TxQueue; /* HTC frame buffer TX queue */
68 HTC_PACKET_QUEUE RxBuffers; /* HTC frame buffer RX list */
69 HTC_ENDPOINT_CREDIT_DIST CreditDist; /* credit distribution structure (exposed to driver layer) */
70 HTC_EP_CALLBACKS EpCallBacks; /* callbacks associated with thi s endpoint */
71 int MaxTxQueueDepth; /* max depth of the TX queue before we need to
72 call driver's full handler */
73 int MaxMsgLength; /* max length of endpoint m essage */
74 int TxProcessCount; /* reference count to continue tx processing */
75 HTC_PACKET_QUEUE RecvIndicationQueue; /* recv packets ready to be indicated */
76 int RxProcessCount; /* reference count to al low single processing context */
77 struct _HTC_TARGET *target; /* back pointer to targe t */
78 A_UINT8 SeqNo; /* TX seq no (helpful) f or debugging */
79 A_UINT32 LocalConnectionFlags; /* local connection flag s */
80 #ifdef HTC_EP_STAT_PROFILING
81 HTC_ENDPOINT_STATS EndPointStats; /* endpoint statistics * /
82 #endif
83 } HTC_ENDPOINT;
84
85 #ifdef HTC_EP_STAT_PROFILING
86 #define INC_HTC_EP_STAT(p,stat,count) (p)->EndPointStats.stat += (count);
87 #else
88 #define INC_HTC_EP_STAT(p,stat,count)
89 #endif
90
91 #define HTC_SERVICE_TX_PACKET_TAG HTC_TX_PACKET_TAG_INTERNAL
92
93 #define NUM_CONTROL_BUFFERS 8
94 #define NUM_CONTROL_TX_BUFFERS 2
95 #define NUM_CONTROL_RX_BUFFERS (NUM_CONTROL_BUFFERS - NUM_CONTROL_TX_BUFFERS)
96
97 typedef struct HTC_CONTROL_BUFFER {
98 HTC_PACKET HtcPacket;
99 A_UINT8 *Buffer;
100 } HTC_CONTROL_BUFFER;
101
102 #define HTC_RECV_WAIT_BUFFERS (1 << 0)
103 #define HTC_OP_STATE_STOPPING (1 << 0)
104
105 /* our HTC target state */
106 typedef struct _HTC_TARGET {
107 HTC_ENDPOINT EndPoint[ENDPOINT_MAX];
108 HTC_CONTROL_BUFFER HTCControlBuffers[NUM_CONTROL_BUFFERS];
109 HTC_ENDPOINT_CREDIT_DIST *EpCreditDistributionListHead;
110 HTC_PACKET_QUEUE ControlBufferTXFreeList;
111 HTC_PACKET_QUEUE ControlBufferRXFreeList;
112 HTC_CREDIT_DIST_CALLBACK DistributeCredits;
113 HTC_CREDIT_INIT_CALLBACK InitCredits;
114 void *pCredDistContext;
115 int TargetCredits;
116 int TargetCreditSize;
117 A_MUTEX_T HTCLock;
118 A_MUTEX_T HTCRxLock;
119 A_MUTEX_T HTCTxLock;
120 AR6K_DEVICE Device; /* AR6K - specific state */
121 A_UINT32 OpStateFlags;
122 A_UINT32 RecvStateFlags;
123 HTC_ENDPOINT_ID EpWaitingForBuffers;
124 A_BOOL TargetFailure;
125 #ifdef HTC_CAPTURE_LAST_FRAME
126 HTC_FRAME_HDR LastFrameHdr; /* useful for debugging */
127 A_UINT8 LastTrailer[256];
128 A_UINT8 LastTrailerLength;
129 #endif
130 HTC_INIT_INFO HTCInitInfo;
131 A_UINT8 HTCTargetVersion;
132 int MaxMsgPerBundle; /* max messages per bundl e for HTC */
133 A_BOOL SendBundlingEnabled; /* run time enable for se nd bundling (dynamic) */
134 int RecvBundlingEnabled; /* run time enable for re cv bundling (dynamic) */
135 } HTC_TARGET;
136
137 #define HTC_STOPPING(t) ((t)->OpStateFlags & HTC_OP_STATE_STOPPING)
138 #define LOCK_HTC(t) A_MUTEX_LOCK(&(t)->HTCLock);
139 #define UNLOCK_HTC(t) A_MUTEX_UNLOCK(&(t)->HTCLock);
140 #define LOCK_HTC_RX(t) A_MUTEX_LOCK(&(t)->HTCRxLock);
141 #define UNLOCK_HTC_RX(t) A_MUTEX_UNLOCK(&(t)->HTCRxLock);
142 #define LOCK_HTC_TX(t) A_MUTEX_LOCK(&(t)->HTCTxLock);
143 #define UNLOCK_HTC_TX(t) A_MUTEX_UNLOCK(&(t)->HTCTxLock);
144
145 #define GET_HTC_TARGET_FROM_HANDLE(hnd) ((HTC_TARGET *)(hnd))
146 #define HTC_RECYCLE_RX_PKT(target,p,e) \
147 { \
148 if ((p)->PktInfo.AsRx.HTCRxFlags & HTC_RX_PKT_NO_RECYCLE) { \
149 HTC_PACKET_RESET_RX(pPacket); \
150 pPacket->Status = A_ECANCELED; \
151 (e)->EpCallBacks.EpRecv((e)->EpCallBacks.pContext, \
152 (p)); \
153 } else { \
154 HTC_PACKET_RESET_RX(pPacket); \
155 HTCAddReceivePkt((HTC_HANDLE)(target),(p)); \
156 } \
157 }
158
159 /* internal HTC functions */
160 void HTCControlTxComplete(void *Context, HTC_PACKET *pPacket);
161 void HTCControlRecv(void *Context, HTC_PACKET *pPacket);
162 A_STATUS HTCWaitforControlMessage(HTC_TARGET *target, HTC_PACKET **ppControlP acket);
163 HTC_PACKET *HTCAllocControlBuffer(HTC_TARGET *target, HTC_PACKET_QUEUE *pList);
164 void HTCFreeControlBuffer(HTC_TARGET *target, HTC_PACKET *pPacket, HTC_PA CKET_QUEUE *pList);
165 A_STATUS HTCIssueSend(HTC_TARGET *target, HTC_PACKET *pPacket);
166 void HTCRecvCompleteHandler(void *Context, HTC_PACKET *pPacket);
167 A_STATUS HTCRecvMessagePendingHandler(void *Context, A_UINT32 MsgLookAheads[] , int NumLookAheads, A_BOOL *pAsyncProc, int *pNumPktsFetched);
168 void HTCProcessCreditRpt(HTC_TARGET *target, HTC_CREDIT_REPORT *pRpt, int NumEntries, HTC_ENDPOINT_ID FromEndpoint);
169 A_STATUS HTCSendSetupComplete(HTC_TARGET *target);
170 void HTCFlushRecvBuffers(HTC_TARGET *target);
171 void HTCFlushSendPkts(HTC_TARGET *target);
172 void DumpCreditDist(HTC_ENDPOINT_CREDIT_DIST *pEPDist);
173 void DumpCreditDistStates(HTC_TARGET *target);
174 void DebugDumpBytes(A_UCHAR *buffer, A_UINT16 length, char *pDescript ion);
175
176 static INLINE HTC_PACKET *HTC_ALLOC_CONTROL_TX(HTC_TARGET *target) {
177 HTC_PACKET *pPacket = HTCAllocControlBuffer(target,&target->ControlBufferTXF reeList);
178 if (pPacket != NULL) {
179 /* set payload pointer area with some headroom */
180 pPacket->pBuffer = pPacket->pBufferStart + HTC_HDR_LENGTH;
181 }
182 return pPacket;
183 }
184
185 #define HTC_FREE_CONTROL_TX(t,p) HTCFreeControlBuffer((t),(p),&(t)->ControlBuffe rTXFreeList)
186 #define HTC_ALLOC_CONTROL_RX(t) HTCAllocControlBuffer((t),&(t)->ControlBufferRX FreeList)
187 #define HTC_FREE_CONTROL_RX(t,p) \
188 { \
189 HTC_PACKET_RESET_RX(p); \
190 HTCFreeControlBuffer((t),(p),&(t)->ControlBufferRXFreeList); \
191 }
192
193 #define HTC_PREPARE_SEND_PKT(pP,sendflags,ctrl0,ctrl1) \
194 { \
195 A_UINT8 *pHdrBuf; \
196 (pP)->pBuffer -= HTC_HDR_LENGTH; \
197 pHdrBuf = (pP)->pBuffer; \
198 A_SET_UINT16_FIELD(pHdrBuf,HTC_FRAME_HDR,PayloadLen,(A_UINT16)(pP)->ActualLe ngth); \
199 A_SET_UINT8_FIELD(pHdrBuf,HTC_FRAME_HDR,Flags,(sendflags)); \
200 A_SET_UINT8_FIELD(pHdrBuf,HTC_FRAME_HDR,EndpointID, (A_UINT8)(pP)->Endpoint) ; \
201 A_SET_UINT8_FIELD(pHdrBuf,HTC_FRAME_HDR,ControlBytes[0], (A_UINT8)(ctrl0)); \
202 A_SET_UINT8_FIELD(pHdrBuf,HTC_FRAME_HDR,ControlBytes[1], (A_UINT8)(ctrl1)); \
203 }
204
205 #define HTC_UNPREPARE_SEND_PKT(pP) \
206 (pP)->pBuffer += HTC_HDR_LENGTH; \
207
208 #ifdef __cplusplus
209 }
210 #endif
211
212 #endif /* _HTC_INTERNAL_H_ */
OLDNEW
« no previous file with comments | « chromeos/drivers/ath6kl/htc2/htc_debug.h ('k') | chromeos/drivers/ath6kl/htc2/htc_recv.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698