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