6 /************************************************************************************************************
10 * DATE : $Date: 2004/08/05 11:47:10 $ $Revision: 1.7 $
11 * Original: 2004/05/19 07:26:01 Revision: 1.56 Tag: hcf7_t20040602_01
12 * Original: 2004/05/12 08:47:23 Revision: 1.53 Tag: hcf7_t7_20040513_01
13 * Original: 2004/04/15 09:24:42 Revision: 1.46 Tag: hcf7_t7_20040415_01
14 * Original: 2004/04/08 15:18:16 Revision: 1.45 Tag: t7_20040413_01
15 * Original: 2004/04/01 15:32:55 Revision: 1.43 Tag: t7_20040401_01
16 * Original: 2004/03/10 15:39:28 Revision: 1.39 Tag: t20040310_01
17 * Original: 2004/03/04 11:03:38 Revision: 1.37 Tag: t20040304_01
18 * Original: 2004/03/02 14:51:21 Revision: 1.35 Tag: t20040302_03
19 * Original: 2004/02/24 13:00:28 Revision: 1.28 Tag: t20040224_01
20 * Original: 2004/02/09 14:50:14 Revision: 1.26 Tag: t20040219_01
22 * AUTHOR : Nico Valster
24 * SPECIFICATION: ..........
26 * DESC : Definitions and Prototypes for MSF as well as HCF sources
28 * Customizable via HCFCFG.H
31 **************************************************************************************************************
33 **************************************************************************************************************
38 * This software is provided subject to the following terms and conditions,
39 * which you should read carefully before using the software. Using this
40 * software indicates your acceptance of these terms and conditions. If you do
41 * not agree with these terms and conditions, do not use the software.
43 * COPYRIGHT © 1994 - 1995 by AT&T. All Rights Reserved
44 * COPYRIGHT © 1996 - 2000 by Lucent Technologies. All Rights Reserved
45 * COPYRIGHT © 2001 - 2004 by Agere Systems Inc. All Rights Reserved
46 * All rights reserved.
48 * Redistribution and use in source or binary forms, with or without
49 * modifications, are permitted provided that the following conditions are met:
51 * . Redistributions of source code must retain the above copyright notice, this
52 * list of conditions and the following Disclaimer as comments in the code as
53 * well as in the documentation and/or other materials provided with the
56 * . Redistributions in binary form must reproduce the above copyright notice,
57 * this list of conditions and the following Disclaimer in the documentation
58 * and/or other materials provided with the distribution.
60 * . Neither the name of Agere Systems Inc. nor the names of the contributors
61 * may be used to endorse or promote products derived from this software
62 * without specific prior written permission.
66 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
67 * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
68 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
69 * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
70 * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY
71 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
72 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
73 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
74 * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT
75 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
76 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
80 *************************************************************************************************************/
83 #include "hcfcfg.h" // System Constants to be defined by the MSF-programmer to tailor the HCF
84 #include "mdd.h" // Include file common for HCF, MSF
87 /************************************************************************************************/
88 /************************************** MACROS ************************************************/
89 /************************************************************************************************/
91 #define LOF(x) (sizeof(x)/sizeof(hcf_16)-1)
94 * Little Endian (a.k.a. Intel), least significant byte first
95 * Big Endian (a.k.a. Motorola), most significant byte first
97 * The following macros are supplied
98 * o CNV_LITTLE_TO_SHORT(w) interprets the 16-bits input value as Little Endian, returns an hcf_16
99 * o CNV_BIG_TO_SHORT(w) interprets the 16-bits input value as Big Endian, returns an hcf_16
103 /* To increase portability, use unsigned char and unsigned char * when accessing parts of larger
104 * types to convert their Endianess
107 #define CNV_END_SHORT(w) (hcf_16)( ((hcf_16)(w) & 0x00FF) << 8 | ((hcf_16)(w) & 0xFF00) >> 8 )
108 #define CNV_END_LONG(dw) (hcf_32)( (dw >> 24) | ((dw >> 8) & 0xff00) | ((dw << 8) & 0xff0000) | (dw << 24) )
111 //******************************************** B I G E N D I A N *******************************************
112 #define CNV_LITTLE_TO_SHORT(w) CNV_END_SHORT(w) // endianess conversion needed
113 #define CNV_BIG_TO_SHORT(w) (w) // no endianess conversion needed
114 #define CNV_LITTLE_TO_LONG(dw) CNV_END_LONG(dw)
115 #define CNV_LONG_TO_LITTLE(dw) CNV_END_LONG(dw)
117 //****************************************** L I T T L E E N D I A N ****************************************
118 #define CNV_LITTLE_TO_SHORT(w) (w) // no endianess conversion needed
119 #define CNV_BIG_TO_SHORT(w) CNV_END_SHORT(w) // endianess conversion needed
120 #define CNV_LITTLE_TO_LONG(dw) (dw)
121 #define CNV_LONG_TO_LITTLE(dw) (dw)
123 #if defined HCF_ALIGN && HCF_ALIGN > 1
124 #define CNV_SHORTP_TO_LITTLE(pw) ((hcf_16)(*(hcf_8 *)pw)) | ((hcf_16)(*((hcf_8 *)pw+1)) << 8)
125 #define CNV_LONGP_TO_LITTLE(pdw) ((hcf_32)(*(hcf_8 *)pdw)) | ((hcf_32)(*((hcf_8 *)pdw+1)) << 8) | \
126 ((hcf_32)(*((hcf_8 *)pdw+2)) << 16) | ((hcf_32)(*((hcf_8 *)pdw+3)) << 24)
128 #define CNV_LONGP_TO_LITTLE(pdw) (*(hcf_32 *)pdw)
129 #define CNV_SHORTP_TO_LITTLE(pw) (*(hcf_16 *)pw)
132 #endif // HCF_BIG_ENDIAN
134 // conversion macros which can be expressed in other macros
135 #define CNV_SHORT_TO_LITTLE(w) CNV_LITTLE_TO_SHORT(w)
136 #define CNV_SHORT_TO_BIG(w) CNV_BIG_TO_SHORT(w)
138 /************************************************************************************************/
139 /************************************** END OF MACROS *****************************************/
140 /************************************************************************************************/
142 /***********************************************************************************************************/
143 /***************** ****************************************/
144 /***********************************************************************************************************/
146 // offsets Transmit/Receive Frame Structure
147 #define HFS_STAT 0x0000
148 #define HFS_SWSUP 0x0006 //SW Support
149 #define HFS_Q_INFO 0x0006 //Signal/Silence level
150 #define HFS_RATE 0x0008 //RxFlow/Rate
151 #define HFS_STAT_ERR RX_STAT_ERR //link "natural" HCF name to "natural" MSF name
152 #define HFS_TX_CNTL 0x0036
154 #define HFS_DAT_LEN (HFS_ADDR_DEST - 2) // 0x002C 0x0038
155 #define HFS_ADDR_DEST 0x003A // 0x002E 0x003A
156 #define HFS_ADDR_SRC (HFS_ADDR_DEST + 6) // 0x0034 0x0040
157 #define HFS_LEN (HFS_ADDR_SRC + 6) // 0x003A 0x0046
158 #define HFS_DAT (HFS_LEN + 2) // 0x003C 0x0048
159 #define HFS_TYPE (HFS_DAT + 6) // 0x0042 0x004E
162 //============================= D E S C R I P T O R S T R U C T U R E ==============================
166 #define DESC_STRCT_CNT 0
167 #define DESC_STRCT_SIZE 1
169 #define DESC_STRCT_CNT 1
170 #define DESC_STRCT_SIZE 0
171 #endif // HCF_BIG_ENDIAN
173 #define BUF_CNT buf_dim[DESC_STRCT_CNT]
174 #define BUF_SIZE buf_dim[DESC_STRCT_SIZE]
176 typedef struct DESC_STRCT
{
178 hcf_32 buf_phys_addr
;
179 hcf_32 next_desc_phys_addr
; // physical address of next descriptor
180 hcf_32 desc_phys_addr
; // physical address of this descriptor
181 struct DESC_STRCT
*next_desc_addr
;
183 #if (HCF_EXT) & HCF_EXT_DESC_STRCT
184 void FAR
*DESC_MSFSup
; // pointer for arbitrary use by the MSF
185 #endif // HCF_DESC_STRCT_EXT
188 #define HCF_DASA_SIZE 12 //size in bytes for DA/SA
190 #define DESC_CNT_MASK 0x0FFF
192 #define GET_BUF_SIZE(descp) ((descp)->BUF_SIZE)
193 #define GET_BUF_CNT(descp) ((descp)->BUF_CNT)
194 #define SET_BUF_SIZE(descp, size) (descp)->BUF_SIZE = size;
195 #define SET_BUF_CNT(descp, count) (descp)->BUF_CNT = count;
197 //========================================= T A L L I E S ===================================================
199 typedef struct { //Hermes Tallies (IFB substructure)
200 hcf_32 TxUnicastFrames
;
201 hcf_32 TxMulticastFrames
;
203 hcf_32 TxUnicastOctets
;
204 hcf_32 TxMulticastOctets
;
205 hcf_32 TxDeferredTransmissions
;
206 hcf_32 TxSingleRetryFrames
;
207 hcf_32 TxMultipleRetryFrames
;
208 hcf_32 TxRetryLimitExceeded
;
210 hcf_32 RxUnicastFrames
;
211 hcf_32 RxMulticastFrames
;
213 hcf_32 RxUnicastOctets
;
214 hcf_32 RxMulticastOctets
;
216 hcf_32 RxDiscardsNoBuffer
;
217 hcf_32 TxDiscardsWrongSA
;
218 hcf_32 RxWEPUndecryptable
;
219 hcf_32 RxMsgInMsgFragments
;
220 hcf_32 RxMsgInBadMsgFragments
;
221 hcf_32 RxDiscardsWEPICVError
;
222 hcf_32 RxDiscardsWEPExcluded
;
223 #if (HCF_EXT) & HCF_EXT_TALLIES_FW
224 hcf_32 TalliesExtra
[32];
225 #endif // HCF_EXT_TALLIES_FW
226 } CFG_HERMES_TALLIES_STRCT
;
228 typedef struct { //HCF Tallies (IFB substructure)
229 hcf_32 NoBufInfo
; //No buffer available for unsolicited Notify frame
230 hcf_32 NoBufMB
; //No space available in MailBox
231 hcf_32 MiscErr
; /* Command errors
232 * - time out on completion synchronous part Hermes Command
233 * - completed Hermes Command doesn't match original command
234 * - status of completed Hermes Command contains error bits
236 #if (HCF_EXT) & HCF_EXT_TALLIES_FW
238 #endif // HCF_EXT_TALLIES_FW
239 } CFG_HCF_TALLIES_STRCT
;
241 //Note this way to define ..._TAL_CNT implies that all tallies must keep the same (hcf_32) size
242 #if (HCF_TALLIES) & ( HCF_TALLIES_NIC | HCF_TALLIES_HCF )
243 #if (HCF_TALLIES) & HCF_TALLIES_NIC //Hermes tally support
244 #define HCF_NIC_TAL_CNT (sizeof(CFG_HERMES_TALLIES_STRCT)/ sizeof(hcf_32))
246 #define HCF_NIC_TAL_CNT 0
247 #endif // HCF_TALLIES
248 #if (HCF_TALLIES) & HCF_TALLIES_HCF //HCF tally support
249 #define HCF_HCF_TAL_CNT (sizeof(CFG_HCF_TALLIES_STRCT) / sizeof(hcf_32))
251 #define HCF_HCF_TAL_CNT 0
252 #endif // HCF_TALLIES
253 #define HCF_TOT_TAL_CNT ( HCF_NIC_TAL_CNT + HCF_NIC_TAL_CNT )
254 #endif // HCF_TALLIES_NIC / HCF_TALLIES_HCF
257 /***********************************************************************************************************/
258 /********************************** I N T E R F A C E B L O C K ******************************************/
259 /***********************************************************************************************************/
261 #define IFB_VERSION 0x0E // initially 0, to be incremented by every IFB layout change
264 hcf_io IFB_IOBase
; // I/O address of Hermes chip as passed by MSF at hcf_connect call
265 hcf_16 IFB_IORange
; // I/O Range used by Hermes chip
266 hcf_16 IFB_DLMode
; // Download Mode state
267 hcf_16 IFB_Cmd
; // cmd in progress flag, to be ack-ed before next cmd can be issued
268 hcf_16 IFB_RxFID
; // FID of "current" RxFS (non-DMA mode)
269 //;?#if tx_delay option
270 hcf_16 IFB_TxFID
; // fid storage during "delayed" send
271 //;?#endif tx_delay option
273 hcf_16 IFB_DefunctStat
; // BAP initialization or Cmd Completion failed
274 hcf_16 IFB_ErrCmd
; // contents Status reg when error bits and/or mismatch in cmd_wait
275 hcf_16 IFB_ErrQualifier
; // contents Resp0 reg when error bits and/or mismatch in cmd_wait
276 hcf_16 IFB_lal
; // LookAhead Length
277 wci_bufp IFB_lap
; // LookAhead Buffer pointer
278 hcf_16 IFB_LinkStat
; // Link Status
279 hcf_16 IFB_DSLinkStat
; // Link Status, new strategy introduced for DeepSleep
280 hcf_16 IFB_CarryIn
; // carry and carry-flag to move 1 byte from one get_frag to the next
281 hcf_16 IFB_CarryOut
; // carry and carry-flag to move 1 byte from one put_frag to the next
282 hcf_16 IFB_Version
; // IFB_VERSION, incremented by every SIGNIFICANT IFB layout change
283 hcf_16 IFB_CardStat
; // NIC error / F/W incompatibility status
284 hcf_16 IFB_RscInd
; // non-DMA: TxFID available, DMA: always 1
285 hcf_16 IFB_CntlOpt
; // flags: 32 bits I/O, DMA available, DMA enabled
286 hcf_16 IFB_BusType
; // BusType, derived via CFG_NIC_BUS_TYPE
287 CFG_FW_IDENTITY_STRCT IFB_FWIdentity
; /* keep FWIdentity/Sup and PRIIdentity/Sup in sequence
288 * because of the (dumb) copy in init() */
289 #if defined MSF_COMPONENT_ID
290 CFG_SUP_RANGE_STRCT IFB_FWSup
;
291 CFG_PRI_IDENTITY_STRCT IFB_PRIIdentity
;
292 CFG_SUP_RANGE_STRCT IFB_PRISup
;
293 CFG_SUP_RANGE_STRCT IFB_HSISup
;
294 #endif // MSF_COMPONENT_ID
295 #if (HCF_EXT) & HCF_EXT_INFO_LOG
296 RID_LOGP IFB_RIDLogp
; // pointer to RID_LOG structure
297 #endif // HCF_EXT_INFO_LOG
299 hcf_32 IFB_TickIni
; // initialization of S/W counter based protection loop
300 #endif // HCF_PROT_TIME
301 #if (HCF_EXT) & HCF_EXT_INT_TICK
302 int IFB_TickCnt
; // Hermes Timer Tick Counter
303 #endif // HCF_EXT_INT_TICK
304 hcf_16
*IFB_MBp
; // pointer to the MailBox
305 hcf_16 IFB_MBSize
; // size of the MailBox
306 hcf_16 IFB_MBWp
; // zero-based write index into the MailBox
307 hcf_16 IFB_MBRp
; // zero-based read index into the MailBox
308 hcf_16 IFB_MBInfoLen
; // contents of L-field of the oldest available MailBoxInfoBlock
309 #if (HCF_TYPE) & HCF_TYPE_WPA
310 hcf_16 IFB_MICTxCntl
; // MIC bit and Key index in TxControl field of TxFS
311 hcf_32 IFB_MICTxKey
[2]; // calculating key
312 hcf_32 IFB_MICTx
[2]; // Tx MIC calculation Engine state
313 hcf_16 IFB_MICTxCarry
; // temp length, carries over from one Tx fragment to another
314 hcf_16 IFB_MICRxCarry
; // temp length, carries over from one Rx fragment to another
315 hcf_32 IFB_MICRxKey
[4*2]; // 4 checking keys
316 hcf_32 IFB_MICRx
[2]; // Rx MIC calculation Engine state
317 #endif // HCF_TYPE_WPA
319 #if (HCF_ASSERT) & HCF_ASSERT_MB
320 CFG_MB_INFO_RANGE1_STRCT IFB_AssertStrct
; // Add some complication to the HCF as prize for the new MSF I/F
321 #endif // HCF_ASSERT_MB
322 // target of above IFB_AssertStrct
323 hcf_16 IFB_AssertLine
; // - line number ( + encoded module name )
324 hcf_16 IFB_AssertTrace
; // - bit based trace of all hcf_.... invocations
325 hcf_32 IFB_AssertQualifier
; // - qualifier
326 hcf_16 IFB_AssertLvl
; // Assert Filtering, Not yet implemented
327 hcf_16 IFB_AssertWhere
; // Where parameter of the Assert macro
328 #if (HCF_ASSERT) & ( HCF_ASSERT_LNK_MSF_RTN | HCF_ASSERT_RT_MSF_RTN )
329 MSF_ASSERT_RTNP IFB_AssertRtn
; // MSF Assert Call back routine (inspired by GEF, DrDobbs Nov 1998 )
330 #endif // HCF_ASSERT_LNK_MSF_RTN
331 #if (HCF_ASSERT) & HCF_ASSERT_PRINTF // engineering facilty intended as F/W debugging aid
332 hcf_16 IFB_DbgPrintF_Cnt
;
333 CFG_FW_PRINTF_BUFFER_LOCATION_STRCT IFB_FwPfBuff
;
334 #endif // HCF_ASSERT_PRINTF
336 hcf_16
volatile IFB_IntOffCnt
; // 0xFFFF based HCF_ACT_INT_OFF nesting counter, DeepSleep flag
337 #if (HCF_TALLIES) & ( HCF_TALLIES_NIC | HCF_TALLIES_HCF ) //Hermes and/or HCF tally support
338 hcf_32 IFB_Silly_you_should_align
; //;?
339 hcf_16 IFB_TallyLen
; // Tally length (to build an LTV)
340 hcf_16 IFB_TallyTyp
; // Tally Type (to build an LTV)
341 #endif // HCF_TALLIES_NIC / HCF_TALLIES_HCF
342 #if (HCF_TALLIES) & HCF_TALLIES_NIC //Hermes tally support
343 CFG_HERMES_TALLIES_STRCT IFB_NIC_Tallies
;
344 #endif // HCF_TALLIES_NIC
345 #if (HCF_TALLIES) & HCF_TALLIES_HCF //HCF tally support
346 CFG_HCF_TALLIES_STRCT IFB_HCF_Tallies
;
347 #endif // HCF_TALLIES_HCF
349 //used for a pool of destination_address descriptor/buffers, used during tx encapsulation points to the
350 //first/last descriptor in the descriptor chain, so we can easily remove and append a packet.
351 DESC_STRCT
*IFB_FirstDesc
[2];
352 DESC_STRCT
*IFB_LastDesc
[2];
353 DESC_STRCT
*IFB_ConfinedDesc
[2]; // pointers to descriptor used for host reclaim purposes.
354 hcf_16 IFB_DmaPackets
; // HREG_EV_[TX/RX]DMA_DONE flags, reports DMA Frame availability to MSF
356 #if (HCF_EXT) & HCF_EXT_INT_TX_EX
357 hcf_16 IFB_TxFsStat
; // Tx message monitoring
358 hcf_16 IFB_TxFsGap
[2]; //;?make this robust
359 hcf_16 IFB_TxFsSwSup
;
360 #endif // HCF_EXT_INT_TX_EX
361 hcf_16 IFB_Magic
; /* "Magic" signature, to help the debugger interpret a memory dump
362 * also the last field cleared at hcf_connect
364 #if (HCF_EXT) & HCF_EXT_IFB_STRCT // for usage by the MSF
365 void FAR
*IFB_MSFSup
; // pointer for arbitrary use by the MSF
366 #endif // HCF_EXT_IFB_STRCT_EXT
369 typedef IFB_STRCT
* IFBP
;
372 /***********************************************************************************************************/
373 /********************** W C I F U N C T I O N S P R O T O T Y P E S ******************************/
374 /***********************************************************************************************************/
376 EXTERN_C
int hcf_action (IFBP ifbp
, hcf_16 cmd
);
377 EXTERN_C
int hcf_connect (IFBP ifbp
, hcf_io io_base
);
378 EXTERN_C
int hcf_get_info (IFBP ifbp
, LTVP ltvp
);
379 EXTERN_C
int hcf_service_nic (IFBP ifbp
, wci_bufp bufp
, unsigned int len
);
380 EXTERN_C
int hcf_cntl (IFBP ifbp
, hcf_16 cmd
);
381 EXTERN_C
int hcf_put_info (IFBP ifbp
, LTVP ltvp
);
382 EXTERN_C
int hcf_rcv_msg (IFBP ifbp
, DESC_STRCT
*descp
, unsigned int offset
);
383 EXTERN_C
int hcf_send_msg (IFBP ifbp
, DESC_STRCT
*dp
, hcf_16 tx_cntl
);
385 EXTERN_C
void hcf_dma_tx_put (IFBP ifbp
, DESC_STRCT
*d
, hcf_16 tx_cntl
);
386 EXTERN_C DESC_STRCT
* hcf_dma_tx_get (IFBP ifbp
);
387 EXTERN_C DESC_STRCT
* hcf_dma_rx_get (IFBP ifbp
);
388 EXTERN_C
void hcf_dma_rx_put (IFBP ifbp
, DESC_STRCT
*d
);
390 #if (HCF_ASSERT) & HCF_ASSERT_LNK_MSF_RTN
391 EXTERN_C
void msf_assert (unsigned int line_number
, hcf_16 trace
, hcf_32 qual
);
392 #endif // HCF_ASSERT_LNK_MSF_RTN