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