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