]> git.proxmox.com Git - mirror_edk2.git/blob - OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h
5382e44c1bea58e82efce43e5571f3a1a1e9c406
[mirror_edk2.git] / OptionRomPkg / Bus / Usb / UsbNetworking / Ax88772b / Ax88772.h
1 /** @file
2 Definitions for ASIX AX88772 Ethernet adapter.
3
4 Copyright (c) 2011, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _AX88772_H_
16 #define _AX88772_H_
17
18 #include <Uefi.h>
19
20 #include <Guid/EventGroup.h>
21 #include <Guid/NicIp4ConfigNvData.h>
22
23 #include <IndustryStandard/Pci.h>
24
25 #include <Library/BaseMemoryLib.h>
26 #include <Library/DebugLib.h>
27 #include <Library/DevicePathLib.h>
28 #include <Library/UefiBootServicesTableLib.h>
29 #include <Library/UefiDriverEntryPoint.h>
30 #include <Library/UefiLib.h>
31 #include <Library/UefiRuntimeLib.h>
32
33 #include <Protocol/DevicePath.h>
34 #include <Protocol/LoadedImage.h>
35 #include <Protocol/NetworkInterfaceIdentifier.h>
36 #include <Protocol/SimpleNetwork.h>
37 #include <Protocol/UsbIo.h>
38
39 #define MAX_QUEUE_SIZE 50
40 #define MAX_BULKIN_SIZE 16384
41 #define HW_HDR_LENGTH 8
42
43
44 #define MAX_LINKIDLE_THRESHOLD 20000
45
46
47
48 //------------------------------------------------------------------------------
49 // Macros
50 //------------------------------------------------------------------------------
51
52 #if defined(_MSC_VER) /* Handle Microsoft VC++ compiler specifics. */
53 #define DBG_ENTER() DEBUG (( 0xffffffff, "Entering " __FUNCTION__ "\n" )) ///< Display routine entry
54 #define DBG_EXIT() DEBUG (( 0xffffffff, "Exiting " __FUNCTION__ "\n" )) ///< Display routine exit
55 #define DBG_EXIT_DEC(Status) DEBUG (( 0xffffffff, "Exiting " __FUNCTION__ ", Status: %d\n", Status )) ///< Display routine exit with decimal value
56 #define DBG_EXIT_HEX(Status) DEBUG (( 0xffffffff, "Exiting " __FUNCTION__ ", Status: 0x%08x\n", Status )) ///< Display routine exit with hex value
57 #define DBG_EXIT_STATUS(Status) DEBUG (( 0xffffffff, "Exiting " __FUNCTION__ ", Status: %r\n", Status )) ///< Display routine exit with status value
58 #define DBG_EXIT_TF(Status) DEBUG (( 0xffffffff, "Exiting " __FUNCTION__ ", returning %s\n", (FALSE == Status) ? L"FALSE" : L"TRUE" )) ///< Display routine with TRUE/FALSE value
59 #else // _MSC_VER
60 #define DBG_ENTER() ///< Display routine entry
61 #define DBG_EXIT() ///< Display routine exit
62 #define DBG_EXIT_DEC(Status) ///< Display routine exit with decimal value
63 #define DBG_EXIT_HEX(Status) ///< Display routine exit with hex value
64 #define DBG_EXIT_STATUS(Status) ///< Display routine exit with status value
65 #define DBG_EXIT_TF(Status) ///< Display routine with TRUE/FALSE value
66 #endif // _MSC_VER
67
68 #define USB_IS_IN_ENDPOINT(EndPointAddr) (((EndPointAddr) & BIT7) != 0) ///< Return TRUE/FALSE for IN direction
69 #define USB_IS_OUT_ENDPOINT(EndPointAddr) (((EndPointAddr) & BIT7) == 0) ///< Return TRUE/FALSE for OUT direction
70 #define USB_IS_BULK_ENDPOINT(Attribute) (((Attribute) & (BIT0 | BIT1)) == USB_ENDPOINT_BULK) ///< Return TRUE/FALSE for BULK type
71 #define USB_IS_INTERRUPT_ENDPOINT(Attribute) (((Attribute) & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT) ///< Return TRUE/FALSE for INTERRUPT type
72
73
74 #define PRINT(_L_STR) (gST->ConOut->OutputString(gST->ConOut,(_L_STR)))
75 //------------------------------------------------------------------------------
76 // Constants
77 //------------------------------------------------------------------------------
78
79 #define DEBUG_RX_BROADCAST 0x40000000 ///< Display RX broadcast messages
80 #define DEBUG_RX_MULTICAST 0x20000000 ///< Display RX multicast messages
81 #define DEBUG_RX_UNICAST 0x10000000 ///< Display RX unicast messages
82 #define DEBUG_MAC_ADDRESS 0x08000000 ///< Display the MAC address
83 #define DEBUG_LINK 0x04000000 ///< Display the link status
84 #define DEBUG_TX 0x02000000 ///< Display the TX messages
85 #define DEBUG_PHY 0x01000000 ///< Display the PHY register values
86 #define DEBUG_SROM 0x00800000 ///< Display the SROM contents
87 #define DEBUG_TIMER 0x00400000 ///< Display the timer routine entry/exit
88 #define DEBUG_TPL 0x00200000 ///< Display the timer routine entry/exit
89
90 #define AX88772_MAX_PKT_SIZE 2048 ///< Maximum packet size
91
92 #define ETHERNET_HEADER_SIZE sizeof ( ETHERNET_HEADER ) ///< Size in bytes of the Ethernet header
93 #define MIN_ETHERNET_PKT_SIZE 60 ///< Minimum packet size including Ethernet header
94 #define MAX_ETHERNET_PKT_SIZE 1500 ///< Ethernet spec 3.1.1: Minimum packet size
95
96 #define USB_NETWORK_CLASS 0x09 ///< USB Network class code
97 #define USB_BUS_TIMEOUT 1000 ///< USB timeout in milliseconds
98
99 #define TIMER_MSEC 20 ///< Polling interval for the NIC
100 //#define TPL_AX88772 TPL_CALLBACK ///< TPL for routine synchronization
101
102 #define HC_DEBUG 0
103 #define BULKIN_TIMEOUT 20
104 #define AUTONEG_DELAY 500000
105 #define AUTONEG_POLLCNT 20
106
107 /**
108 Verify new TPL value
109
110 This macro which is enabled when debug is enabled verifies that
111 the new TPL value is >= the current TPL value.
112 **/
113 #ifdef VERIFY_TPL
114 #undef VERIFY_TPL
115 #endif // VERIFY_TPL
116
117 #if !defined(MDEPKG_NDEBUG)
118
119 #define VERIFY_TPL(tpl) \
120 { \
121 EFI_TPL PreviousTpl; \
122 \
123 PreviousTpl = gBS->RaiseTPL ( TPL_HIGH_LEVEL ); \
124 gBS->RestoreTPL ( PreviousTpl ); \
125 if ( PreviousTpl > tpl ) { \
126 DEBUG (( DEBUG_ERROR, "Current TPL: %d, New TPL: %d\r\n", PreviousTpl, tpl )); \
127 ASSERT ( PreviousTpl <= tpl ); \
128 } \
129 }
130
131 #else // MDEPKG_NDEBUG
132
133 #define VERIFY_TPL(tpl)
134
135 #endif // MDEPKG_NDEBUG
136
137 //------------------------------------------------------------------------------
138 // Hardware Definition
139 //------------------------------------------------------------------------------
140
141 #define FreeQueueSize 10
142
143 #define DEV_SIGNATURE SIGNATURE_32 ('A','X','8','8') ///< Signature of data structures in memory
144
145 #define VENDOR_ID 0x0B95 ///< Vendor ID for Asix
146 #define PRODUCT_ID 0x772B ///< Product ID for the AX88772 USB 10/100 Ethernet controller
147
148 #define RESET_MSEC 1000 ///< Reset duration
149 #define PHY_RESET_MSEC 500 ///< PHY reset duration
150
151 //
152 // RX Control register
153 //
154
155 #define RXC_PRO 0x0001 ///< Receive all packets
156 #define RXC_AMALL 0x0002 ///< Receive all multicast packets
157 #define RXC_SEP 0x0004 ///< Save error packets
158 #define RXC_AB 0x0008 ///< Receive broadcast packets
159 #define RXC_AM 0x0010 ///< Use multicast destination address hash table
160 #define RXC_AP 0x0020 ///< Accept physical address from Multicast Filter
161 #define RXC_SO 0x0080 ///< Start operation
162 #define RXC_MFB 0x0300 ///< Maximum frame burst
163 #define RXC_MFB_2048 0 ///< Maximum frame size: 2048 bytes
164 #define RXC_MFB_4096 0x0100 ///< Maximum frame size: 4096 bytes
165 #define RXC_MFB_8192 0x0200 ///< Maximum frame size: 8192 bytes
166 #define RXC_MFB_16384 0x0300 ///< Maximum frame size: 16384 bytes
167
168 /*Freddy*/
169 #define RXC_RH1M 0x0100 ///< Rx header 1
170 #define RXC_RH2M 0x0200 ///< Rx header 2
171 #define RXC_RH3M 0x0400 ///< Rx header 3
172 /*Freddy*/
173
174 //
175 // Medium Status register
176 //
177
178 #define MS_FD 0x0002 ///< Full duplex
179 #define MS_ONE 0x0004 ///< Must be one
180 #define MS_RFC 0x0010 ///< RX flow control enable
181 #define MS_TFC 0x0020 ///< TX flow control enable
182 #define MS_PF 0x0080 ///< Pause frame enable
183 #define MS_RE 0x0100 ///< Receive enable
184 #define MS_PS 0x0200 ///< Port speed 1=100, 0=10 Mbps
185 #define MS_SBP 0x0800 ///< Stop back pressure
186 #define MS_SM 0x1000 ///< Super MAC support
187
188 //
189 // Software PHY Select register
190 //
191
192 #define SPHY_PSEL (1 << 0) ///< Select internal PHY
193 #define SPHY_SSMII (1 << 2)
194 #define SPHY_SSEN (1 << 4)
195 #define SPHY_ASEL 0x02 ///< 1=Auto select, 0=Manual select
196
197 //
198 // Software Reset register
199 //
200
201 #define SRR_RR 0x01 ///< Clear receive frame length error
202 #define SRR_RT 0x02 ///< Clear transmit frame length error
203 #define SRR_BZTYPE 0x04 ///< External PHY reset pin tri-state enable
204 #define SRR_PRL 0x08 ///< External PHY reset pin level
205 #define SRR_BZ 0x10 ///< Force Bulk to return zero length packet
206 #define SRR_IPRL 0x20 ///< Internal PHY reset control
207 #define SRR_IPPD 0x40 ///< Internal PHY power down
208
209 //
210 // PHY ID values
211 //
212
213 #define PHY_ID_INTERNAL 0x0010 ///< Internal PHY
214
215 //
216 // USB Commands
217 //
218
219 #define CMD_PHY_ACCESS_SOFTWARE 0x06 ///< Software in control of PHY
220 #define CMD_PHY_REG_READ 0x07 ///< Read PHY register, Value: PHY, Index: Register, Data: Register value
221 #define CMD_PHY_REG_WRITE 0x08 ///< Write PHY register, Value: PHY, Index: Register, Data: New 16-bit value
222 #define CMD_PHY_ACCESS_HARDWARE 0x0a ///< Hardware in control of PHY
223 #define CMD_SROM_READ 0x0b ///< Read SROM register: Value: Address, Data: Value
224 #define CMD_RX_CONTROL_WRITE 0x10 ///< Set the RX control register, Value: New value
225 #define CMD_GAPS_WRITE 0x12 ///< Write the gaps register, Value: New value
226 #define CMD_MAC_ADDRESS_READ 0x13 ///< Read the MAC address, Data: 6 byte MAC address
227 #define CMD_MAC_ADDRESS_WRITE 0x14 ///< Set the MAC address, Data: New 6 byte MAC address
228 #define CMD_MULTICAST_HASH_WRITE 0x16 ///< Write the multicast hash table, Data: New 8 byte value
229 #define CMD_MULTICAST_HASH_READ 0x16 ///< Read the multicast hash table
230 #define CMD_MEDIUM_STATUS_READ 0x1a ///< Read medium status register, Data: Register value
231 #define CMD_MEDIUM_STATUS_WRITE 0x1b ///< Write medium status register, Value: New value
232 #define CMD_WRITE_GPIOS 0x1f
233 #define CMD_RESET 0x20 ///< Reset register, Value: New value
234 #define CMD_PHY_SELECT 0x22 ///< PHY select register, Value: New value
235
236 /*Freddy*/
237 #define CMD_RXQTC 0x2a ///< RX Queue Cascade Threshold Control Register
238 /*Freddy*/
239
240 //------------------------------
241 // USB Endpoints
242 //------------------------------
243
244 #define CONTROL_ENDPOINT 0 ///< Control endpoint
245 #define INTERRUPT_ENDPOINT 1 ///< Interrupt endpoint
246 #define BULK_IN_ENDPOINT 2 ///< Receive endpoint
247 #define BULK_OUT_ENDPOINT 3 ///< Transmit endpoint
248
249 //------------------------------
250 // PHY Registers
251 //------------------------------
252
253 #define PHY_BMCR 0 ///< Control register
254 #define PHY_BMSR 1 ///< Status register
255 #define PHY_ANAR 4 ///< Autonegotiation advertisement register
256 #define PHY_ANLPAR 5 ///< Autonegotiation link parter ability register
257 #define PHY_ANER 6 ///< Autonegotiation expansion register
258
259 // BMCR - Register 0
260
261 #define BMCR_RESET 0x8000 ///< 1 = Reset the PHY, bit clears after reset
262 #define BMCR_LOOPBACK 0x4000 ///< 1 = Loopback enabled
263 #define BMCR_100MBPS 0x2000 ///< 100 Mbits/Sec
264 #define BMCR_10MBPS 0 ///< 10 Mbits/Sec
265 #define BMCR_AUTONEGOTIATION_ENABLE 0x1000 ///< 1 = Enable autonegotiation
266 #define BMCR_POWER_DOWN 0x0800 ///< 1 = Power down
267 #define BMCR_ISOLATE 0x0400 ///< 0 = Isolate PHY
268 #define BMCR_RESTART_AUTONEGOTIATION 0x0200 ///< 1 = Restart autonegotiation
269 #define BMCR_FULL_DUPLEX 0x0100 ///< Full duplex operation
270 #define BMCR_HALF_DUPLEX 0 ///< Half duplex operation
271 #define BMCR_COLLISION_TEST 0x0080 ///< 1 = Collision test enabled
272
273 // BSMR - Register 1
274
275 #define BMSR_100BASET4 0x8000 ///< 1 = 100BASE-T4 mode
276 #define BMSR_100BASETX_FDX 0x4000 ///< 1 = 100BASE-TX full duplex
277 #define BMSR_100BASETX_HDX 0x2000 ///< 1 = 100BASE-TX half duplex
278 #define BMSR_10BASET_FDX 0x1000 ///< 1 = 10BASE-T full duplex
279 #define BMSR_10BASET_HDX 0x0800 ///< 1 = 10BASE-T half duplex
280 #define BMSR_MF 0x0040 ///< 1 = PHY accepts frames with preamble suppressed
281 #define BMSR_AUTONEG_CMPLT 0x0020 ///< 1 = Autonegotiation complete
282 #define BMSR_RF 0x0010 ///< 1 = Remote fault
283 #define BMSR_AUTONEG 0x0008 ///< 1 = Able to perform autonegotiation
284 #define BMSR_LINKST 0x0004 ///< 1 = Link up
285 #define BMSR_JABBER_DETECT 0x0002 ///< 1 = jabber condition detected
286 #define BMSR_EXTENDED_CAPABILITY 0x0001 ///< 1 = Extended register capable
287
288 // ANAR and ANLPAR Registers 4, 5
289
290 #define AN_NP 0x8000 ///< 1 = Next page available
291 #define AN_ACK 0x4000 ///< 1 = Link partner acknowledged
292 #define AN_RF 0x2000 ///< 1 = Remote fault indicated by link partner
293 #define AN_FCS 0x0400 ///< 1 = Flow control ability
294 #define AN_T4 0x0200 ///< 1 = 100BASE-T4 support
295 #define AN_TX_FDX 0x0100 ///< 1 = 100BASE-TX Full duplex
296 #define AN_TX_HDX 0x0080 ///< 1 = 100BASE-TX support
297 #define AN_10_FDX 0x0040 ///< 1 = 10BASE-T Full duplex
298 #define AN_10_HDX 0x0020 ///< 1 = 10BASE-T support
299 #define AN_CSMA_CD 0x0001 ///< 1 = IEEE 802.3 CSMA/CD support
300
301
302
303 //------------------------------------------------------------------------------
304 // Data Types
305 //------------------------------------------------------------------------------
306
307 /**
308 Ethernet header layout
309
310 IEEE 802.3-2002 Part 3 specification, section 3.1.1.
311 **/
312 #pragma pack(1)
313 typedef struct {
314 UINT8 dest_addr[PXE_HWADDR_LEN_ETHER]; ///< Destination LAN address
315 UINT8 src_addr[PXE_HWADDR_LEN_ETHER]; ///< Source LAN address
316 UINT16 type; ///< Protocol or length
317 } ETHERNET_HEADER;
318 #pragma pack()
319
320 /**
321 Receive and Transmit packet structure
322 **/
323 #pragma pack(1)
324 typedef struct _RX_TX_PACKET {
325 struct _RX_TX_PACKET * pNext; ///< Next receive packet
326 UINT16 Length; ///< Packet length
327 UINT16 LengthBar; ///< Complement of the length
328 UINT8 Data[ AX88772_MAX_PKT_SIZE ]; ///< Received packet data
329 } RX_TX_PACKET;
330 #pragma pack()
331
332
333 #pragma pack(1)
334 typedef struct _RX_PKT {
335 struct _RX_PKT *pNext;
336 BOOLEAN f_Used;
337 UINT16 Length;
338 UINT8 Data [AX88772_MAX_PKT_SIZE] ;
339 } RX_PKT;
340 #pragma pack()
341
342 /**
343 AX88772 control structure
344
345 The driver uses this structure to manage the Asix AX88772 10/100
346 Ethernet controller.
347 **/
348 typedef struct {
349 UINTN Signature; ///< Structure identification
350
351 //
352 // USB data
353 //
354 EFI_HANDLE Controller; ///< Controller handle
355 EFI_USB_IO_PROTOCOL * pUsbIo; ///< USB driver interface
356
357 //
358 // Simple network protocol data
359 //
360 EFI_SIMPLE_NETWORK_PROTOCOL SimpleNetwork; ///< Driver's network stack interface
361 EFI_SIMPLE_NETWORK_PROTOCOL SimpleNetwork_Backup;
362 EFI_SIMPLE_NETWORK_MODE SimpleNetworkData; ///< Data for simple network
363
364 //
365 // Ethernet controller data
366 //
367 BOOLEAN bInitialized; ///< Controller initialized
368 VOID * pTxBuffer; ///< Last transmit buffer
369 UINT16 PhyId; ///< PHY ID
370
371 //
372 // Link state
373 //
374 BOOLEAN b100Mbps; ///< Current link speed, FALSE = 10 Mbps
375 BOOLEAN bComplete; ///< Current state of auto-negotiation
376 BOOLEAN bFullDuplex; ///< Current duplex
377 BOOLEAN bLinkUp; ///< Current link state
378 UINTN LinkIdleCnt;
379 UINTN PollCount; ///< Number of times the autonegotiation status was polled
380 UINT16 CurRxControl;
381 //
382 // Receive buffer list
383 //
384 RX_TX_PACKET * pRxTest;
385 RX_TX_PACKET * pTxTest;
386
387 INT8 MulticastHash[8];
388 EFI_MAC_ADDRESS MAC;
389 BOOLEAN bHavePkt;
390
391 EFI_DEVICE_PATH_PROTOCOL *MyDevPath;
392
393 EFI_DRIVER_BINDING_PROTOCOL * DrvBind;
394
395 RX_PKT * QueueHead;
396 RX_PKT * pNextFill;
397 RX_PKT * pFirstFill;
398 UINTN PktCntInQueue;
399 UINT8 * pBulkInBuff;
400
401 } NIC_DEVICE;
402
403 #define DEV_FROM_SIMPLE_NETWORK(a) CR (a, NIC_DEVICE, SimpleNetwork, DEV_SIGNATURE) ///< Locate NIC_DEVICE from Simple Network Protocol
404
405 //------------------------------------------------------------------------------
406 // Simple Network Protocol
407 //------------------------------------------------------------------------------
408
409 /**
410 Reset the network adapter.
411
412 Resets a network adapter and reinitializes it with the parameters that
413 were provided in the previous call to Initialize (). The transmit and
414 receive queues are cleared. Receive filters, the station address, the
415 statistics, and the multicast-IP-to-HW MAC addresses are not reset by
416 this call.
417
418 This routine calls ::Ax88772Reset to perform the adapter specific
419 reset operation. This routine also starts the link negotiation
420 by calling ::Ax88772NegotiateLinkStart.
421
422 @param [in] pSimpleNetwork Protocol instance pointer
423 @param [in] bExtendedVerification Indicates that the driver may perform a more
424 exhaustive verification operation of the device
425 during reset.
426
427 @retval EFI_SUCCESS This operation was successful.
428 @retval EFI_NOT_STARTED The network interface was not started.
429 @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid
430 EFI_SIMPLE_NETWORK_PROTOCOL structure.
431 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
432 @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.
433
434 **/
435 EFI_STATUS
436 EFIAPI
437 SN_Reset (
438 IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork,
439 IN BOOLEAN bExtendedVerification
440 );
441
442 /**
443 Initialize the simple network protocol.
444
445 This routine calls ::Ax88772MacAddressGet to obtain the
446 MAC address.
447
448 @param [in] pNicDevice NIC_DEVICE_INSTANCE pointer
449
450 @retval EFI_SUCCESS Setup was successful
451
452 **/
453 EFI_STATUS
454 SN_Setup (
455 IN NIC_DEVICE * pNicDevice
456 );
457
458 /**
459 This routine starts the network interface.
460
461 @param [in] pSimpleNetwork Protocol instance pointer
462
463 @retval EFI_SUCCESS This operation was successful.
464 @retval EFI_ALREADY_STARTED The network interface was already started.
465 @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid
466 EFI_SIMPLE_NETWORK_PROTOCOL structure.
467 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
468 @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.
469
470 **/
471 EFI_STATUS
472 EFIAPI
473 SN_Start (
474 IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork
475 );
476
477 /**
478 Set the MAC address.
479
480 This function modifies or resets the current station address of a
481 network interface. If Reset is TRUE, then the current station address
482 is set ot the network interface's permanent address. If Reset if FALSE
483 then the current station address is changed to the address specified by
484 pNew.
485
486 This routine calls ::Ax88772MacAddressSet to update the MAC address
487 in the network adapter.
488
489 @param [in] pSimpleNetwork Protocol instance pointer
490 @param [in] bReset Flag used to reset the station address to the
491 network interface's permanent address.
492 @param [in] pNew New station address to be used for the network
493 interface.
494
495 @retval EFI_SUCCESS This operation was successful.
496 @retval EFI_NOT_STARTED The network interface was not started.
497 @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid
498 EFI_SIMPLE_NETWORK_PROTOCOL structure.
499 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
500 @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.
501
502 **/
503 EFI_STATUS
504 EFIAPI
505 SN_StationAddress (
506 IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork,
507 IN BOOLEAN bReset,
508 IN EFI_MAC_ADDRESS * pNew
509 );
510
511 /**
512 This function resets or collects the statistics on a network interface.
513 If the size of the statistics table specified by StatisticsSize is not
514 big enough for all of the statistics that are collected by the network
515 interface, then a partial buffer of statistics is returned in
516 StatisticsTable.
517
518 @param [in] pSimpleNetwork Protocol instance pointer
519 @param [in] bReset Set to TRUE to reset the statistics for the network interface.
520 @param [in, out] pStatisticsSize On input the size, in bytes, of StatisticsTable. On output
521 the size, in bytes, of the resulting table of statistics.
522 @param [out] pStatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that
523 conains the statistics.
524
525 @retval EFI_SUCCESS This operation was successful.
526 @retval EFI_NOT_STARTED The network interface was not started.
527 @retval EFI_BUFFER_TOO_SMALL The pStatisticsTable is NULL or the buffer is too small.
528 @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid
529 EFI_SIMPLE_NETWORK_PROTOCOL structure.
530 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
531 @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.
532
533 **/
534 EFI_STATUS
535 EFIAPI
536 SN_Statistics (
537 IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork,
538 IN BOOLEAN bReset,
539 IN OUT UINTN * pStatisticsSize,
540 OUT EFI_NETWORK_STATISTICS * pStatisticsTable
541 );
542
543 /**
544 This function stops a network interface. This call is only valid
545 if the network interface is in the started state.
546
547 @param [in] pSimpleNetwork Protocol instance pointer
548
549 @retval EFI_SUCCESS This operation was successful.
550 @retval EFI_NOT_STARTED The network interface was not started.
551 @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid
552 EFI_SIMPLE_NETWORK_PROTOCOL structure.
553 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
554 @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.
555
556 **/
557 EFI_STATUS
558 EFIAPI
559 SN_Stop (
560 IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork
561 );
562
563 /**
564 This function releases the memory buffers assigned in the Initialize() call.
565 Pending transmits and receives are lost, and interrupts are cleared and disabled.
566 After this call, only Initialize() and Stop() calls may be used.
567
568 @param [in] pSimpleNetwork Protocol instance pointer
569
570 @retval EFI_SUCCESS This operation was successful.
571 @retval EFI_NOT_STARTED The network interface was not started.
572 @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid
573 EFI_SIMPLE_NETWORK_PROTOCOL structure.
574 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
575 @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.
576
577 **/
578 EFI_STATUS
579 EFIAPI
580 SN_Shutdown (
581 IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork
582 );
583
584 /**
585 Send a packet over the network.
586
587 This function places the packet specified by Header and Buffer on
588 the transmit queue. This function performs a non-blocking transmit
589 operation. When the transmit is complete, the buffer is returned
590 via the GetStatus() call.
591
592 This routine calls ::Ax88772Rx to empty the network adapter of
593 receive packets. The routine then passes the transmit packet
594 to the network adapter.
595
596 @param [in] pSimpleNetwork Protocol instance pointer
597 @param [in] HeaderSize The size, in bytes, of the media header to be filled in by
598 the Transmit() function. If HeaderSize is non-zero, then
599 it must be equal to SimpleNetwork->Mode->MediaHeaderSize
600 and DestAddr and Protocol parameters must not be NULL.
601 @param [in] BufferSize The size, in bytes, of the entire packet (media header and
602 data) to be transmitted through the network interface.
603 @param [in] pBuffer A pointer to the packet (media header followed by data) to
604 to be transmitted. This parameter can not be NULL. If
605 HeaderSize is zero, then the media header is Buffer must
606 already be filled in by the caller. If HeaderSize is nonzero,
607 then the media header will be filled in by the Transmit()
608 function.
609 @param [in] pSrcAddr The source HW MAC address. If HeaderSize is zero, then
610 this parameter is ignored. If HeaderSize is nonzero and
611 SrcAddr is NULL, then SimpleNetwork->Mode->CurrentAddress
612 is used for the source HW MAC address.
613 @param [in] pDestAddr The destination HW MAC address. If HeaderSize is zero, then
614 this parameter is ignored.
615 @param [in] pProtocol The type of header to build. If HeaderSize is zero, then
616 this parameter is ignored.
617
618 @retval EFI_SUCCESS This operation was successful.
619 @retval EFI_NOT_STARTED The network interface was not started.
620 @retval EFI_NOT_READY The network interface is too busy to accept this transmit request.
621 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.
622 @retval EFI_INVALID_PARAMETER pSimpleNetwork parameter was NULL or did not point to a valid
623 EFI_SIMPLE_NETWORK_PROTOCOL structure.
624 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
625
626 **/
627 EFI_STATUS
628 EFIAPI
629 SN_Transmit (
630 IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork,
631 IN UINTN HeaderSize,
632 IN UINTN BufferSize,
633 IN VOID * pBuffer,
634 IN EFI_MAC_ADDRESS * pSrcAddr,
635 IN EFI_MAC_ADDRESS * pDestAddr,
636 IN UINT16 * pProtocol
637 );
638
639 //------------------------------------------------------------------------------
640 // Support Routines
641 //------------------------------------------------------------------------------
642
643 /**
644 Get the MAC address
645
646 This routine calls ::Ax88772UsbCommand to request the MAC
647 address from the network adapter.
648
649 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
650 @param [out] pMacAddress Address of a six byte buffer to receive the MAC address.
651
652 @retval EFI_SUCCESS The MAC address is available.
653 @retval other The MAC address is not valid.
654
655 **/
656 EFI_STATUS
657 Ax88772MacAddressGet (
658 IN NIC_DEVICE * pNicDevice,
659 OUT UINT8 * pMacAddress
660 );
661
662 /**
663 Set the MAC address
664
665 This routine calls ::Ax88772UsbCommand to set the MAC address
666 in the network adapter.
667
668 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
669 @param [in] pMacAddress Address of a six byte buffer to containing the new MAC address.
670
671 @retval EFI_SUCCESS The MAC address was set.
672 @retval other The MAC address was not set.
673
674 **/
675 EFI_STATUS
676 Ax88772MacAddressSet (
677 IN NIC_DEVICE * pNicDevice,
678 IN UINT8 * pMacAddress
679 );
680
681 /**
682 Clear the multicast hash table
683
684 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
685
686 **/
687 VOID
688 Ax88772MulticastClear (
689 IN NIC_DEVICE * pNicDevice
690 );
691
692 /**
693 Enable a multicast address in the multicast hash table
694
695 This routine calls ::Ax88772Crc to compute the hash bit for
696 this MAC address.
697
698 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
699 @param [in] pMacAddress Address of a six byte buffer to containing the MAC address.
700
701 **/
702 VOID
703 Ax88772MulticastSet (
704 IN NIC_DEVICE * pNicDevice,
705 IN UINT8 * pMacAddress
706 );
707
708 /**
709 Start the link negotiation
710
711 This routine calls ::Ax88772PhyWrite to start the PHY's link
712 negotiation.
713
714 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
715
716 @retval EFI_SUCCESS The link negotiation was started.
717 @retval other Failed to start the link negotiation.
718
719 **/
720 EFI_STATUS
721 Ax88772NegotiateLinkStart (
722 IN NIC_DEVICE * pNicDevice
723 );
724
725 /**
726 Complete the negotiation of the PHY link
727
728 This routine calls ::Ax88772PhyRead to determine if the
729 link negotiation is complete.
730
731 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
732 @param [in, out] pPollCount Address of number of times this routine was polled
733 @param [out] pbComplete Address of boolean to receive complate status.
734 @param [out] pbLinkUp Address of boolean to receive link status, TRUE=up.
735 @param [out] pbHiSpeed Address of boolean to receive link speed, TRUE=100Mbps.
736 @param [out] pbFullDuplex Address of boolean to receive link duplex, TRUE=full.
737
738 @retval EFI_SUCCESS The MAC address is available.
739 @retval other The MAC address is not valid.
740
741 **/
742 EFI_STATUS
743 Ax88772NegotiateLinkComplete (
744 IN NIC_DEVICE * pNicDevice,
745 IN OUT UINTN * pPollCount,
746 OUT BOOLEAN * pbComplete,
747 OUT BOOLEAN * pbLinkUp,
748 OUT BOOLEAN * pbHiSpeed,
749 OUT BOOLEAN * pbFullDuplex
750 );
751
752 /**
753 Read a register from the PHY
754
755 This routine calls ::Ax88772UsbCommand to read a PHY register.
756
757 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
758 @param [in] RegisterAddress Number of the register to read.
759 @param [in, out] pPhyData Address of a buffer to receive the PHY register value
760
761 @retval EFI_SUCCESS The PHY data is available.
762 @retval other The PHY data is not valid.
763
764 **/
765 EFI_STATUS
766 Ax88772PhyRead (
767 IN NIC_DEVICE * pNicDevice,
768 IN UINT8 RegisterAddress,
769 IN OUT UINT16 * pPhyData
770 );
771
772 /**
773 Write to a PHY register
774
775 This routine calls ::Ax88772UsbCommand to write a PHY register.
776
777 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
778 @param [in] RegisterAddress Number of the register to read.
779 @param [in] PhyData Address of a buffer to receive the PHY register value
780
781 @retval EFI_SUCCESS The PHY data was written.
782 @retval other Failed to wwrite the PHY register.
783
784 **/
785 EFI_STATUS
786 Ax88772PhyWrite (
787 IN NIC_DEVICE * pNicDevice,
788 IN UINT8 RegisterAddress,
789 IN UINT16 PhyData
790 );
791
792 /**
793 Reset the AX88772
794
795 This routine uses ::Ax88772UsbCommand to reset the network
796 adapter. This routine also uses ::Ax88772PhyWrite to reset
797 the PHY.
798
799 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
800
801 @retval EFI_SUCCESS The MAC address is available.
802 @retval other The MAC address is not valid.
803
804 **/
805 EFI_STATUS
806 Ax88772Reset (
807 IN NIC_DEVICE * pNicDevice
808 );
809
810 VOID
811 Ax88772ChkLink (
812 IN NIC_DEVICE * pNicDevice,
813 IN BOOLEAN bUpdateLink
814 );
815
816 /**
817 Receive a frame from the network.
818
819 This routine polls the USB receive interface for a packet. If a packet
820 is available, this routine adds the receive packet to the list of
821 pending receive packets.
822
823 This routine calls ::Ax88772NegotiateLinkComplete to verify
824 that the link is up. This routine also calls ::SN_Reset to
825 reset the network adapter when necessary. Finally this
826 routine attempts to receive one or more packets from the
827 network adapter.
828
829 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
830 @param [in] bUpdateLink TRUE = Update link status
831
832 **/
833 VOID
834 Ax88772Rx (
835 IN NIC_DEVICE * pNicDevice,
836 IN BOOLEAN bUpdateLink
837 );
838
839 /**
840 Enable or disable the receiver
841
842 This routine calls ::Ax88772UsbCommand to update the
843 receiver state. This routine also calls ::Ax88772MacAddressSet
844 to establish the MAC address for the network adapter.
845
846 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
847 @param [in] RxFilter Simple network RX filter mask value
848
849 @retval EFI_SUCCESS The MAC address was set.
850 @retval other The MAC address was not set.
851
852 **/
853 EFI_STATUS
854 Ax88772RxControl (
855 IN NIC_DEVICE * pNicDevice,
856 IN UINT32 RxFilter
857 );
858
859 /**
860 Read an SROM location
861
862 This routine calls ::Ax88772UsbCommand to read data from the
863 SROM.
864
865 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
866 @param [in] Address SROM address
867 @param [out] pData Buffer to receive the data
868
869 @retval EFI_SUCCESS The read was successful
870 @retval other The read failed
871
872 **/
873 EFI_STATUS
874 Ax88772SromRead (
875 IN NIC_DEVICE * pNicDevice,
876 IN UINT32 Address,
877 OUT UINT16 * pData
878 );
879
880 /**
881 Send a command to the USB device.
882
883 @param [in] pNicDevice Pointer to the NIC_DEVICE structure
884 @param [in] pRequest Pointer to the request structure
885 @param [in, out] pBuffer Data buffer address
886
887 @retval EFI_SUCCESS The USB transfer was successful
888 @retval other The USB transfer failed
889
890 **/
891 EFI_STATUS
892 Ax88772UsbCommand (
893 IN NIC_DEVICE * pNicDevice,
894 IN USB_DEVICE_REQUEST * pRequest,
895 IN OUT VOID * pBuffer
896 );
897
898 //------------------------------------------------------------------------------
899 // EFI Component Name Protocol Support
900 //------------------------------------------------------------------------------
901
902 extern EFI_COMPONENT_NAME_PROTOCOL gComponentName; ///< Component name protocol declaration
903 extern EFI_COMPONENT_NAME2_PROTOCOL gComponentName2; ///< Component name 2 protocol declaration
904
905 /**
906 Retrieves a Unicode string that is the user readable name of the driver.
907
908 This function retrieves the user readable name of a driver in the form of a
909 Unicode string. If the driver specified by This has a user readable name in
910 the language specified by Language, then a pointer to the driver name is
911 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
912 by This does not support the language specified by Language,
913 then EFI_UNSUPPORTED is returned.
914
915 @param [in] pThis A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
916 EFI_COMPONENT_NAME_PROTOCOL instance.
917 @param [in] pLanguage A pointer to a Null-terminated ASCII string
918 array indicating the language. This is the
919 language of the driver name that the caller is
920 requesting, and it must match one of the
921 languages specified in SupportedLanguages. The
922 number of languages supported by a driver is up
923 to the driver writer. Language is specified
924 in RFC 3066 or ISO 639-2 language code format.
925 @param [out] ppDriverName A pointer to the Unicode string to return.
926 This Unicode string is the name of the
927 driver specified by This in the language
928 specified by Language.
929
930 @retval EFI_SUCCESS The Unicode string for the Driver specified by
931 This and the language specified by Language was
932 returned in DriverName.
933 @retval EFI_INVALID_PARAMETER Language is NULL.
934 @retval EFI_INVALID_PARAMETER DriverName is NULL.
935 @retval EFI_UNSUPPORTED The driver specified by This does not support
936 the language specified by Language.
937
938 **/
939 EFI_STATUS
940 EFIAPI
941 GetDriverName (
942 IN EFI_COMPONENT_NAME_PROTOCOL * pThis,
943 IN CHAR8 * pLanguage,
944 OUT CHAR16 ** ppDriverName
945 );
946
947
948 /**
949 Retrieves a Unicode string that is the user readable name of the controller
950 that is being managed by a driver.
951
952 This function retrieves the user readable name of the controller specified by
953 ControllerHandle and ChildHandle in the form of a Unicode string. If the
954 driver specified by This has a user readable name in the language specified by
955 Language, then a pointer to the controller name is returned in ControllerName,
956 and EFI_SUCCESS is returned. If the driver specified by This is not currently
957 managing the controller specified by ControllerHandle and ChildHandle,
958 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
959 support the language specified by Language, then EFI_UNSUPPORTED is returned.
960
961 @param [in] pThis A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
962 EFI_COMPONENT_NAME_PROTOCOL instance.
963 @param [in] ControllerHandle The handle of a controller that the driver
964 specified by This is managing. This handle
965 specifies the controller whose name is to be
966 returned.
967 @param [in] ChildHandle The handle of the child controller to retrieve
968 the name of. This is an optional parameter that
969 may be NULL. It will be NULL for device
970 drivers. It will also be NULL for a bus drivers
971 that wish to retrieve the name of the bus
972 controller. It will not be NULL for a bus
973 driver that wishes to retrieve the name of a
974 child controller.
975 @param [in] pLanguage A pointer to a Null-terminated ASCII string
976 array indicating the language. This is the
977 language of the driver name that the caller is
978 requesting, and it must match one of the
979 languages specified in SupportedLanguages. The
980 number of languages supported by a driver is up
981 to the driver writer. Language is specified in
982 RFC 3066 or ISO 639-2 language code format.
983 @param [out] ppControllerName A pointer to the Unicode string to return.
984 This Unicode string is the name of the
985 controller specified by ControllerHandle and
986 ChildHandle in the language specified by
987 Language from the point of view of the driver
988 specified by This.
989
990 @retval EFI_SUCCESS The Unicode string for the user readable name in
991 the language specified by Language for the
992 driver specified by This was returned in
993 DriverName.
994 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
995 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
996 EFI_HANDLE.
997 @retval EFI_INVALID_PARAMETER Language is NULL.
998 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
999 @retval EFI_UNSUPPORTED The driver specified by This is not currently
1000 managing the controller specified by
1001 ControllerHandle and ChildHandle.
1002 @retval EFI_UNSUPPORTED The driver specified by This does not support
1003 the language specified by Language.
1004
1005 **/
1006 EFI_STATUS
1007 EFIAPI
1008 GetControllerName (
1009 IN EFI_COMPONENT_NAME_PROTOCOL * pThis,
1010 IN EFI_HANDLE ControllerHandle,
1011 IN OPTIONAL EFI_HANDLE ChildHandle,
1012 IN CHAR8 * pLanguage,
1013 OUT CHAR16 ** ppControllerName
1014 );
1015
1016 VOID
1017 FillPkt2Queue (
1018 IN EFI_SIMPLE_NETWORK_PROTOCOL * pSimpleNetwork,
1019 IN UINTN BufLength);
1020
1021 //------------------------------------------------------------------------------
1022
1023 #endif // _AX88772_H_