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