Ax88772.c 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318
  1. /** @file
  2. Implement the interface to the AX88772 Ethernet controller.
  3. This module implements the interface to the ASIX AX88772
  4. USB to Ethernet MAC with integrated 10/100 PHY. Note that this implementation
  5. only supports the integrated PHY since no other test cases were available.
  6. Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
  7. SPDX-License-Identifier: BSD-2-Clause-Patent
  8. **/
  9. #include "Ax88772.h"
  10. /**
  11. Compute the CRC
  12. @param [in] pMacAddress Address of a six byte buffer to containing the MAC address.
  13. @returns The CRC-32 value associated with this MAC address
  14. **/
  15. UINT32
  16. Ax88772Crc (
  17. IN UINT8 * pMacAddress
  18. )
  19. {
  20. UINT32 BitNumber;
  21. INT32 Carry;
  22. INT32 Crc;
  23. UINT32 Data;
  24. UINT8 * pEnd;
  25. DBG_ENTER ( );
  26. //
  27. // Walk the MAC address
  28. //
  29. Crc = -1;
  30. pEnd = &pMacAddress[ PXE_HWADDR_LEN_ETHER ];
  31. while ( pEnd > pMacAddress ) {
  32. Data = *pMacAddress++;
  33. //
  34. // CRC32: x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1
  35. //
  36. // 1 0000 0100 1100 0001 0001 1101 1011 0111
  37. //
  38. for ( BitNumber = 0; 8 > BitNumber; BitNumber++ ) {
  39. Carry = (( Crc >> 31 ) & 1 ) ^ ( Data & 1 );
  40. Crc <<= 1;
  41. if ( 0 != Carry ) {
  42. Crc ^= 0x04c11db7;
  43. }
  44. Data >>= 1;
  45. }
  46. }
  47. //
  48. // Return the CRC value
  49. //
  50. DBG_EXIT_HEX ( Crc );
  51. return (UINT32) Crc;
  52. }
  53. /**
  54. Get the MAC address
  55. This routine calls ::Ax88772UsbCommand to request the MAC
  56. address from the network adapter.
  57. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  58. @param [out] pMacAddress Address of a six byte buffer to receive the MAC address.
  59. @retval EFI_SUCCESS The MAC address is available.
  60. @retval other The MAC address is not valid.
  61. **/
  62. EFI_STATUS
  63. Ax88772MacAddressGet (
  64. IN NIC_DEVICE * pNicDevice,
  65. OUT UINT8 * pMacAddress
  66. )
  67. {
  68. USB_DEVICE_REQUEST SetupMsg;
  69. EFI_STATUS Status;
  70. DBG_ENTER ( );
  71. //
  72. // Set the register address.
  73. //
  74. SetupMsg.RequestType = USB_ENDPOINT_DIR_IN
  75. | USB_REQ_TYPE_VENDOR
  76. | USB_TARGET_DEVICE;
  77. SetupMsg.Request = CMD_MAC_ADDRESS_READ;
  78. SetupMsg.Value = 0;
  79. SetupMsg.Index = 0;
  80. SetupMsg.Length = PXE_HWADDR_LEN_ETHER;
  81. //
  82. // Read the PHY register
  83. //
  84. Status = Ax88772UsbCommand ( pNicDevice,
  85. &SetupMsg,
  86. pMacAddress );
  87. //
  88. // Return the operation status
  89. //
  90. DBG_EXIT_STATUS ( Status );
  91. return Status;
  92. }
  93. /**
  94. Set the MAC address
  95. This routine calls ::Ax88772UsbCommand to set the MAC address
  96. in the network adapter.
  97. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  98. @param [in] pMacAddress Address of a six byte buffer to containing the new MAC address.
  99. @retval EFI_SUCCESS The MAC address was set.
  100. @retval other The MAC address was not set.
  101. **/
  102. EFI_STATUS
  103. Ax88772MacAddressSet (
  104. IN NIC_DEVICE * pNicDevice,
  105. IN UINT8 * pMacAddress
  106. )
  107. {
  108. USB_DEVICE_REQUEST SetupMsg;
  109. EFI_STATUS Status;
  110. DBG_ENTER ( );
  111. //
  112. // Set the register address.
  113. //
  114. SetupMsg.RequestType = USB_REQ_TYPE_VENDOR
  115. | USB_TARGET_DEVICE;
  116. SetupMsg.Request = CMD_MAC_ADDRESS_WRITE;
  117. SetupMsg.Value = 0;
  118. SetupMsg.Index = 0;
  119. SetupMsg.Length = PXE_HWADDR_LEN_ETHER;
  120. //
  121. // Read the PHY register
  122. //
  123. Status = Ax88772UsbCommand ( pNicDevice,
  124. &SetupMsg,
  125. pMacAddress );
  126. //
  127. // Return the operation status
  128. //
  129. DBG_EXIT_STATUS ( Status );
  130. return Status;
  131. }
  132. /**
  133. Clear the multicast hash table
  134. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  135. **/
  136. VOID
  137. Ax88772MulticastClear (
  138. IN NIC_DEVICE * pNicDevice
  139. )
  140. {
  141. DBG_ENTER ( );
  142. //
  143. // Clear the multicast hash table
  144. //
  145. pNicDevice->MulticastHash[0] = 0;
  146. pNicDevice->MulticastHash[1] = 0;
  147. DBG_EXIT ( );
  148. }
  149. /**
  150. Enable a multicast address in the multicast hash table
  151. This routine calls ::Ax88772Crc to compute the hash bit for
  152. this MAC address.
  153. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  154. @param [in] pMacAddress Address of a six byte buffer to containing the MAC address.
  155. **/
  156. VOID
  157. Ax88772MulticastSet (
  158. IN NIC_DEVICE * pNicDevice,
  159. IN UINT8 * pMacAddress
  160. )
  161. {
  162. UINT32 BitNumber;
  163. UINT32 Crc;
  164. UINT32 Mask;
  165. DBG_ENTER ( );
  166. //
  167. // Compute the CRC on the destination address
  168. //
  169. Crc = Ax88772Crc ( pMacAddress );
  170. //
  171. // Set the bit corresponding to the destination address
  172. //
  173. BitNumber = Crc >> 26;
  174. if ( 32 > BitNumber ) {
  175. Mask = 1 << BitNumber;
  176. pNicDevice->MulticastHash[0] |= Mask;
  177. }
  178. else {
  179. Mask = 1 << ( BitNumber - 32 );
  180. pNicDevice->MulticastHash[1] |= Mask;
  181. }
  182. //
  183. // Display the multicast address
  184. //
  185. DEBUG (( DEBUG_RX_MULTICAST | DEBUG_INFO,
  186. "Enable multicast: 0x%02x-%02x-%02x-%02x-%02x-%02x, CRC: 0x%08x, Bit number: 0x%02x\r\n",
  187. pMacAddress[0],
  188. pMacAddress[1],
  189. pMacAddress[2],
  190. pMacAddress[3],
  191. pMacAddress[4],
  192. pMacAddress[5],
  193. Crc,
  194. BitNumber ));
  195. DBG_EXIT ( );
  196. }
  197. /**
  198. Start the link negotiation
  199. This routine calls ::Ax88772PhyWrite to start the PHY's link
  200. negotiation.
  201. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  202. @retval EFI_SUCCESS The link negotiation was started.
  203. @retval other Failed to start the link negotiation.
  204. **/
  205. EFI_STATUS
  206. Ax88772NegotiateLinkStart (
  207. IN NIC_DEVICE * pNicDevice
  208. )
  209. {
  210. UINT16 Control;
  211. EFI_STATUS Status;
  212. DBG_ENTER ( );
  213. //
  214. // Set the supported capabilities.
  215. //
  216. Status = Ax88772PhyWrite ( pNicDevice,
  217. PHY_ANAR,
  218. AN_CSMA_CD
  219. | AN_TX_FDX | AN_TX_HDX
  220. | AN_10_FDX | AN_10_HDX );
  221. if ( !EFI_ERROR ( Status )) {
  222. //
  223. // Set the link speed and duplex
  224. //
  225. Control = BMCR_AUTONEGOTIATION_ENABLE
  226. | BMCR_RESTART_AUTONEGOTIATION;
  227. if ( pNicDevice->b100Mbps ) {
  228. Control |= BMCR_100MBPS;
  229. }
  230. if ( pNicDevice->bFullDuplex ) {
  231. Control |= BMCR_FULL_DUPLEX;
  232. }
  233. Status = Ax88772PhyWrite ( pNicDevice, PHY_BMCR, Control );
  234. }
  235. //
  236. // Return the operation status
  237. //
  238. DBG_EXIT_STATUS ( Status );
  239. return Status;
  240. }
  241. /**
  242. Complete the negotiation of the PHY link
  243. This routine calls ::Ax88772PhyRead to determine if the
  244. link negotiation is complete.
  245. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  246. @param [in, out] pPollCount Address of number of times this routine was polled
  247. @param [out] pbComplete Address of boolean to receive complate status.
  248. @param [out] pbLinkUp Address of boolean to receive link status, TRUE=up.
  249. @param [out] pbHiSpeed Address of boolean to receive link speed, TRUE=100Mbps.
  250. @param [out] pbFullDuplex Address of boolean to receive link duplex, TRUE=full.
  251. @retval EFI_SUCCESS The MAC address is available.
  252. @retval other The MAC address is not valid.
  253. **/
  254. EFI_STATUS
  255. Ax88772NegotiateLinkComplete (
  256. IN NIC_DEVICE * pNicDevice,
  257. IN OUT UINTN * pPollCount,
  258. OUT BOOLEAN * pbComplete,
  259. OUT BOOLEAN * pbLinkUp,
  260. OUT BOOLEAN * pbHiSpeed,
  261. OUT BOOLEAN * pbFullDuplex
  262. )
  263. {
  264. UINT16 Mask;
  265. UINT16 PhyData;
  266. EFI_STATUS Status;
  267. DBG_ENTER ( );
  268. //
  269. // Determine if the link is up.
  270. //
  271. *pbComplete = FALSE;
  272. //
  273. // Get the link status
  274. //
  275. Status = Ax88772PhyRead ( pNicDevice,
  276. PHY_BMSR,
  277. &PhyData );
  278. if ( !EFI_ERROR ( Status )) {
  279. //
  280. // Determine if the autonegotiation is complete.
  281. //
  282. *pbLinkUp = (BOOLEAN)( 0 != ( PhyData & BMSR_LINKST ));
  283. *pbComplete = *pbLinkUp;
  284. if ( 0 != *pbComplete ) {
  285. //
  286. // Get the partners capabilities.
  287. //
  288. Status = Ax88772PhyRead ( pNicDevice,
  289. PHY_ANLPAR,
  290. &PhyData );
  291. if ( !EFI_ERROR ( Status )) {
  292. //
  293. // Autonegotiation is complete
  294. // Determine the link speed.
  295. //
  296. *pbHiSpeed = (BOOLEAN)( 0 != ( PhyData & ( AN_TX_FDX | AN_TX_HDX )));
  297. //
  298. // Determine the link duplex.
  299. //
  300. Mask = ( *pbHiSpeed ) ? AN_TX_FDX : AN_10_FDX;
  301. *pbFullDuplex = (BOOLEAN)( 0 != ( PhyData & Mask ));
  302. }
  303. }
  304. }
  305. //
  306. // Return the operation status
  307. //
  308. DBG_EXIT_STATUS ( Status );
  309. return Status;
  310. }
  311. /**
  312. Read a register from the PHY
  313. This routine calls ::Ax88772UsbCommand to read a PHY register.
  314. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  315. @param [in] RegisterAddress Number of the register to read.
  316. @param [in, out] pPhyData Address of a buffer to receive the PHY register value
  317. @retval EFI_SUCCESS The PHY data is available.
  318. @retval other The PHY data is not valid.
  319. **/
  320. EFI_STATUS
  321. Ax88772PhyRead (
  322. IN NIC_DEVICE * pNicDevice,
  323. IN UINT8 RegisterAddress,
  324. IN OUT UINT16 * pPhyData
  325. )
  326. {
  327. USB_DEVICE_REQUEST SetupMsg;
  328. EFI_STATUS Status;
  329. DBG_ENTER ( );
  330. //
  331. // Request access to the PHY
  332. //
  333. SetupMsg.RequestType = USB_REQ_TYPE_VENDOR
  334. | USB_TARGET_DEVICE;
  335. SetupMsg.Request = CMD_PHY_ACCESS_SOFTWARE;
  336. SetupMsg.Value = 0;
  337. SetupMsg.Index = 0;
  338. SetupMsg.Length = 0;
  339. Status = Ax88772UsbCommand ( pNicDevice,
  340. &SetupMsg,
  341. NULL );
  342. if ( !EFI_ERROR ( Status )) {
  343. //
  344. // Read the PHY register address.
  345. //
  346. SetupMsg.RequestType = USB_ENDPOINT_DIR_IN
  347. | USB_REQ_TYPE_VENDOR
  348. | USB_TARGET_DEVICE;
  349. SetupMsg.Request = CMD_PHY_REG_READ;
  350. SetupMsg.Value = pNicDevice->PhyId;
  351. SetupMsg.Index = RegisterAddress;
  352. SetupMsg.Length = sizeof ( *pPhyData );
  353. Status = Ax88772UsbCommand ( pNicDevice,
  354. &SetupMsg,
  355. pPhyData );
  356. if ( !EFI_ERROR ( Status )) {
  357. DEBUG (( DEBUG_PHY | DEBUG_INFO,
  358. "PHY %d: 0x%02x --> 0x%04x\r\n",
  359. pNicDevice->PhyId,
  360. RegisterAddress,
  361. *pPhyData ));
  362. //
  363. // Release the PHY to the hardware
  364. //
  365. SetupMsg.RequestType = USB_REQ_TYPE_VENDOR
  366. | USB_TARGET_DEVICE;
  367. SetupMsg.Request = CMD_PHY_ACCESS_HARDWARE;
  368. SetupMsg.Value = 0;
  369. SetupMsg.Index = 0;
  370. SetupMsg.Length = 0;
  371. Status = Ax88772UsbCommand ( pNicDevice,
  372. &SetupMsg,
  373. NULL );
  374. }
  375. }
  376. //
  377. // Return the operation status.
  378. //
  379. DBG_EXIT_STATUS ( Status );
  380. return Status;
  381. }
  382. /**
  383. Write to a PHY register
  384. This routine calls ::Ax88772UsbCommand to write a PHY register.
  385. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  386. @param [in] RegisterAddress Number of the register to read.
  387. @param [in] PhyData Address of a buffer to receive the PHY register value
  388. @retval EFI_SUCCESS The PHY data was written.
  389. @retval other Failed to wwrite the PHY register.
  390. **/
  391. EFI_STATUS
  392. Ax88772PhyWrite (
  393. IN NIC_DEVICE * pNicDevice,
  394. IN UINT8 RegisterAddress,
  395. IN UINT16 PhyData
  396. )
  397. {
  398. USB_DEVICE_REQUEST SetupMsg;
  399. EFI_STATUS Status;
  400. DBG_ENTER ( );
  401. //
  402. // Request access to the PHY
  403. //
  404. SetupMsg.RequestType = USB_REQ_TYPE_VENDOR
  405. | USB_TARGET_DEVICE;
  406. SetupMsg.Request = CMD_PHY_ACCESS_SOFTWARE;
  407. SetupMsg.Value = 0;
  408. SetupMsg.Index = 0;
  409. SetupMsg.Length = 0;
  410. Status = Ax88772UsbCommand ( pNicDevice,
  411. &SetupMsg,
  412. NULL );
  413. if ( !EFI_ERROR ( Status )) {
  414. //
  415. // Write the PHY register
  416. //
  417. SetupMsg.RequestType = USB_REQ_TYPE_VENDOR
  418. | USB_TARGET_DEVICE;
  419. SetupMsg.Request = CMD_PHY_REG_WRITE;
  420. SetupMsg.Value = pNicDevice->PhyId;
  421. SetupMsg.Index = RegisterAddress;
  422. SetupMsg.Length = sizeof ( PhyData );
  423. Status = Ax88772UsbCommand ( pNicDevice,
  424. &SetupMsg,
  425. &PhyData );
  426. if ( !EFI_ERROR ( Status )) {
  427. DEBUG (( DEBUG_PHY | DEBUG_INFO,
  428. "PHY %d: 0x%02x <-- 0x%04x\r\n",
  429. pNicDevice->PhyId,
  430. RegisterAddress,
  431. PhyData ));
  432. //
  433. // Release the PHY to the hardware
  434. //
  435. SetupMsg.RequestType = USB_REQ_TYPE_VENDOR
  436. | USB_TARGET_DEVICE;
  437. SetupMsg.Request = CMD_PHY_ACCESS_HARDWARE;
  438. SetupMsg.Value = 0;
  439. SetupMsg.Index = 0;
  440. SetupMsg.Length = 0;
  441. Status = Ax88772UsbCommand ( pNicDevice,
  442. &SetupMsg,
  443. NULL );
  444. }
  445. }
  446. //
  447. // Return the operation status.
  448. //
  449. DBG_EXIT_STATUS ( Status );
  450. return Status;
  451. }
  452. /**
  453. Reset the AX88772
  454. This routine uses ::Ax88772UsbCommand to reset the network
  455. adapter. This routine also uses ::Ax88772PhyWrite to reset
  456. the PHY.
  457. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  458. @retval EFI_SUCCESS The MAC address is available.
  459. @retval other The MAC address is not valid.
  460. **/
  461. EFI_STATUS
  462. Ax88772Reset (
  463. IN NIC_DEVICE * pNicDevice
  464. )
  465. {
  466. USB_DEVICE_REQUEST SetupMsg;
  467. EFI_STATUS Status;
  468. DBG_ENTER ( );
  469. //
  470. // Turn off the MAC
  471. //
  472. SetupMsg.RequestType = USB_REQ_TYPE_VENDOR
  473. | USB_TARGET_DEVICE;
  474. SetupMsg.Request = CMD_RX_CONTROL_WRITE;
  475. SetupMsg.Value = 0;
  476. SetupMsg.Index = 0;
  477. SetupMsg.Length = 0;
  478. Status = Ax88772UsbCommand ( pNicDevice,
  479. &SetupMsg,
  480. NULL );
  481. if ( !EFI_ERROR ( Status )) {
  482. DEBUG (( DEBUG_PHY | DEBUG_RX_BROADCAST | DEBUG_RX_MULTICAST
  483. | DEBUG_RX_UNICAST | DEBUG_TX | DEBUG_INFO,
  484. "MAC reset\r\n" ));
  485. //
  486. // The link is now idle
  487. //
  488. pNicDevice->bLinkIdle = TRUE;
  489. //
  490. // Delay for a bit
  491. //
  492. gBS->Stall ( RESET_MSEC );
  493. //
  494. // Select the internal PHY
  495. //
  496. SetupMsg.RequestType = USB_REQ_TYPE_VENDOR
  497. | USB_TARGET_DEVICE;
  498. SetupMsg.Request = CMD_PHY_SELECT;
  499. SetupMsg.Value = SPHY_PSEL;
  500. SetupMsg.Index = 0;
  501. SetupMsg.Length = 0;
  502. Status = Ax88772UsbCommand ( pNicDevice,
  503. &SetupMsg,
  504. NULL );
  505. if ( !EFI_ERROR ( Status )) {
  506. //
  507. // Delay for a bit
  508. //
  509. gBS->Stall ( PHY_RESET_MSEC );
  510. //
  511. // Clear the internal PHY reset
  512. //
  513. SetupMsg.Request = CMD_RESET;
  514. SetupMsg.Value = SRR_IPRL | SRR_PRL;
  515. Status = Ax88772UsbCommand ( pNicDevice,
  516. &SetupMsg,
  517. NULL );
  518. if ( !EFI_ERROR ( Status )) {
  519. //
  520. // Reset the PHY
  521. //
  522. Status = Ax88772PhyWrite ( pNicDevice,
  523. PHY_BMCR,
  524. BMCR_RESET );
  525. if ( !EFI_ERROR ( Status )) {
  526. //
  527. // Set the gaps
  528. //
  529. SetupMsg.RequestType = USB_REQ_TYPE_VENDOR
  530. | USB_TARGET_DEVICE;
  531. SetupMsg.Request = CMD_GAPS_WRITE;
  532. SetupMsg.Value = 0x0c15;
  533. SetupMsg.Index = 0x0e;
  534. SetupMsg.Length = 0;
  535. Status = Ax88772UsbCommand ( pNicDevice,
  536. &SetupMsg,
  537. NULL );
  538. }
  539. }
  540. }
  541. }
  542. //
  543. // Return the operation status.
  544. //
  545. DBG_EXIT_STATUS ( Status );
  546. return Status;
  547. }
  548. VOID
  549. FillPkt2Queue (
  550. IN NIC_DEVICE * pNicDevice,
  551. IN UINTN BufLength)
  552. {
  553. UINT16 * pLength;
  554. UINT16 * pLengthBar;
  555. UINT8* pData;
  556. UINT32 offset;
  557. RX_TX_PACKET * pRxPacket;
  558. EFI_STATUS Status;
  559. for ( offset = 0; offset < BufLength; ){
  560. pLength = (UINT16*) (pNicDevice->pBulkInBuff + offset);
  561. pLengthBar = (UINT16*) (pNicDevice->pBulkInBuff + offset +2);
  562. *pLength &= 0x7ff;
  563. *pLengthBar &= 0x7ff;
  564. *pLengthBar |= 0xf800;
  565. if ((*pLength ^ *pLengthBar ) != 0xFFFF) {
  566. DEBUG (( EFI_D_ERROR , "Pkt length error. BufLength = %d\n", BufLength));
  567. return;
  568. }
  569. pRxPacket = pNicDevice->pRxFree;
  570. if ( NULL == pRxPacket ) {
  571. Status = gBS->AllocatePool ( EfiRuntimeServicesData,
  572. sizeof( RX_TX_PACKET ),
  573. (VOID **) &pRxPacket );
  574. if ( !EFI_ERROR ( Status )) {
  575. //
  576. // Add this packet to the free packet list
  577. //
  578. pNicDevice->pRxFree = pRxPacket;
  579. pRxPacket->pNext = NULL;
  580. }
  581. else {
  582. //
  583. // Use the discard packet buffer
  584. //
  585. //pRxPacket = &Packet;
  586. }
  587. }
  588. pData = pNicDevice->pBulkInBuff + offset + 4;
  589. pRxPacket->Length = *pLength;
  590. pRxPacket->LengthBar = *(UINT16*) (pNicDevice->pBulkInBuff + offset +2);
  591. CopyMem (&pRxPacket->Data[0], pData, *pLength);
  592. //DEBUG((DEBUG_INFO, "Packet [%d]\n", *pLength));
  593. pNicDevice->pRxFree = pRxPacket->pNext;
  594. pRxPacket->pNext = NULL;
  595. if ( NULL == pNicDevice->pRxTail ) {
  596. pNicDevice->pRxHead = pRxPacket;
  597. }
  598. else {
  599. pNicDevice->pRxTail->pNext = pRxPacket;
  600. }
  601. pNicDevice->pRxTail = pRxPacket;
  602. offset += (*pLength + 4);
  603. }
  604. }
  605. /**
  606. Receive a frame from the network.
  607. This routine polls the USB receive interface for a packet. If a packet
  608. is available, this routine adds the receive packet to the list of
  609. pending receive packets.
  610. This routine calls ::Ax88772NegotiateLinkComplete to verify
  611. that the link is up. This routine also calls ::SN_Reset to
  612. reset the network adapter when necessary. Finally this
  613. routine attempts to receive one or more packets from the
  614. network adapter.
  615. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  616. @param [in] bUpdateLink TRUE = Update link status
  617. **/
  618. VOID
  619. Ax88772Rx (
  620. IN NIC_DEVICE * pNicDevice,
  621. IN BOOLEAN bUpdateLink
  622. )
  623. {
  624. BOOLEAN bFullDuplex;
  625. BOOLEAN bLinkUp;
  626. BOOLEAN bRxPacket;
  627. BOOLEAN bSpeed100;
  628. UINTN LengthInBytes;
  629. RX_TX_PACKET Packet;
  630. RX_TX_PACKET * pRxPacket;
  631. EFI_USB_IO_PROTOCOL *pUsbIo;
  632. EFI_STATUS Status;
  633. EFI_TPL TplPrevious;
  634. UINT32 TransferStatus;
  635. //
  636. // Synchronize with Ax88772Timer
  637. //
  638. VERIFY_TPL ( TPL_AX88772 );
  639. TplPrevious = gBS->RaiseTPL ( TPL_AX88772 );
  640. DEBUG (( DEBUG_TPL | DEBUG_INFO,
  641. "%d: TPL\r\n",
  642. TPL_AX88772 ));
  643. //
  644. // Get the link status
  645. //
  646. if ( bUpdateLink ) {
  647. bLinkUp = pNicDevice->bLinkUp;
  648. bSpeed100 = pNicDevice->b100Mbps;
  649. bFullDuplex = pNicDevice->bFullDuplex;
  650. Status = Ax88772NegotiateLinkComplete ( pNicDevice,
  651. &pNicDevice->PollCount,
  652. &pNicDevice->bComplete,
  653. &pNicDevice->bLinkUp,
  654. &pNicDevice->b100Mbps,
  655. &pNicDevice->bFullDuplex );
  656. //
  657. // Determine if the autonegotiation is complete
  658. //
  659. if ( pNicDevice->bComplete ) {
  660. if ( pNicDevice->bLinkUp ) {
  661. if (( bSpeed100 && ( !pNicDevice->b100Mbps ))
  662. || (( !bSpeed100 ) && pNicDevice->b100Mbps )
  663. || ( bFullDuplex && ( !pNicDevice->bFullDuplex ))
  664. || (( !bFullDuplex ) && pNicDevice->bFullDuplex )) {
  665. pNicDevice->PollCount = 0;
  666. DEBUG (( DEBUG_LINK | DEBUG_INFO,
  667. "Reset to establish proper link setup: %d Mbps, %s duplex\r\n",
  668. pNicDevice->b100Mbps ? 100 : 10,
  669. pNicDevice->bFullDuplex ? L"Full" : L"Half" ));
  670. Status = SN_Reset ( &pNicDevice->SimpleNetwork, FALSE );
  671. }
  672. if (( !bLinkUp ) && pNicDevice->bLinkUp ) {
  673. //
  674. // Display the autonegotiation status
  675. //
  676. DEBUG (( DEBUG_LINK | DEBUG_INFO,
  677. "Link: Up, %d Mbps, %s duplex\r\n",
  678. pNicDevice->b100Mbps ? 100 : 10,
  679. pNicDevice->bFullDuplex ? L"Full" : L"Half" ));
  680. }
  681. }
  682. }
  683. //
  684. // Update the link status
  685. //
  686. if ( bLinkUp && ( !pNicDevice->bLinkUp )) {
  687. DEBUG (( DEBUG_LINK | DEBUG_INFO, "Link: Down\r\n" ));
  688. }
  689. }
  690. //
  691. // Loop until all the packets are emptied from the receiver
  692. //
  693. do {
  694. bRxPacket = FALSE;
  695. //
  696. // Locate a packet for use
  697. //
  698. pRxPacket = pNicDevice->pRxFree;
  699. LengthInBytes = MAX_BULKIN_SIZE;
  700. if ( NULL == pRxPacket ) {
  701. Status = gBS->AllocatePool ( EfiRuntimeServicesData,
  702. sizeof ( *pRxPacket ),
  703. (VOID **) &pRxPacket );
  704. if ( !EFI_ERROR ( Status )) {
  705. //
  706. // Add this packet to the free packet list
  707. //
  708. pNicDevice->pRxFree = pRxPacket;
  709. pRxPacket->pNext = NULL;
  710. }
  711. else {
  712. //
  713. // Use the discard packet buffer
  714. //
  715. pRxPacket = &Packet;
  716. }
  717. }
  718. //
  719. // Attempt to receive a packet
  720. //
  721. SetMem (&pNicDevice->pBulkInBuff[0], MAX_BULKIN_SIZE, 0);
  722. pUsbIo = pNicDevice->pUsbIo;
  723. Status = pUsbIo->UsbBulkTransfer ( pUsbIo,
  724. USB_ENDPOINT_DIR_IN | BULK_IN_ENDPOINT,
  725. &pNicDevice->pBulkInBuff[0],
  726. &LengthInBytes,
  727. 2,
  728. &TransferStatus );
  729. if ( LengthInBytes > 0 ) {
  730. FillPkt2Queue(pNicDevice, LengthInBytes);
  731. }
  732. pRxPacket = pNicDevice->pRxHead;
  733. if (( !EFI_ERROR ( Status ))
  734. && ( 0 < pRxPacket->Length )
  735. && ( pRxPacket->Length <= sizeof ( pRxPacket->Data ))
  736. && ( LengthInBytes > 0)) {
  737. //
  738. // Determine if the packet should be received
  739. //
  740. bRxPacket = TRUE;
  741. LengthInBytes = pRxPacket->Length;
  742. pNicDevice->bLinkIdle = FALSE;
  743. if ( pNicDevice->pRxFree == pRxPacket ) {
  744. //
  745. // Display the received packet
  746. //
  747. if ( 0 != ( pRxPacket->Data[0] & 1 )) {
  748. if (( 0xff == pRxPacket->Data[0])
  749. && ( 0xff == pRxPacket->Data[1])
  750. && ( 0xff == pRxPacket->Data[2])
  751. && ( 0xff == pRxPacket->Data[3])
  752. && ( 0xff == pRxPacket->Data[4])
  753. && ( 0xff == pRxPacket->Data[5])) {
  754. DEBUG (( DEBUG_RX_BROADCAST | DEBUG_INFO,
  755. "RX: %02x-%02x-%02x-%02x-%02x-%02x %02x-%02x-%02x-%02x-%02x-%02x %02x-%02x %d bytes\r\n",
  756. pRxPacket->Data[0],
  757. pRxPacket->Data[1],
  758. pRxPacket->Data[2],
  759. pRxPacket->Data[3],
  760. pRxPacket->Data[4],
  761. pRxPacket->Data[5],
  762. pRxPacket->Data[6],
  763. pRxPacket->Data[7],
  764. pRxPacket->Data[8],
  765. pRxPacket->Data[9],
  766. pRxPacket->Data[10],
  767. pRxPacket->Data[11],
  768. pRxPacket->Data[12],
  769. pRxPacket->Data[13],
  770. LengthInBytes ));
  771. }
  772. else {
  773. DEBUG (( DEBUG_RX_MULTICAST | DEBUG_INFO,
  774. "RX: %02x-%02x-%02x-%02x-%02x-%02x %02x-%02x-%02x-%02x-%02x-%02x %02x-%02x %d bytes\r\n",
  775. pRxPacket->Data[0],
  776. pRxPacket->Data[1],
  777. pRxPacket->Data[2],
  778. pRxPacket->Data[3],
  779. pRxPacket->Data[4],
  780. pRxPacket->Data[5],
  781. pRxPacket->Data[6],
  782. pRxPacket->Data[7],
  783. pRxPacket->Data[8],
  784. pRxPacket->Data[9],
  785. pRxPacket->Data[10],
  786. pRxPacket->Data[11],
  787. pRxPacket->Data[12],
  788. pRxPacket->Data[13],
  789. LengthInBytes ));
  790. }
  791. }
  792. else {
  793. DEBUG (( DEBUG_RX_UNICAST | DEBUG_INFO,
  794. "RX: %02x-%02x-%02x-%02x-%02x-%02x %02x-%02x-%02x-%02x-%02x-%02x %02x-%02x %d bytes\r\n",
  795. pRxPacket->Data[0],
  796. pRxPacket->Data[1],
  797. pRxPacket->Data[2],
  798. pRxPacket->Data[3],
  799. pRxPacket->Data[4],
  800. pRxPacket->Data[5],
  801. pRxPacket->Data[6],
  802. pRxPacket->Data[7],
  803. pRxPacket->Data[8],
  804. pRxPacket->Data[9],
  805. pRxPacket->Data[10],
  806. pRxPacket->Data[11],
  807. pRxPacket->Data[12],
  808. pRxPacket->Data[13],
  809. LengthInBytes ));
  810. }
  811. }
  812. else {
  813. //
  814. // Error, not enough buffers for this packet, discard packet
  815. //
  816. DEBUG (( DEBUG_WARN | DEBUG_INFO,
  817. "WARNING - No buffer, discarding RX packet: %02x-%02x-%02x-%02x-%02x-%02x %02x-%02x-%02x-%02x-%02x-%02x %02x-%02x %d bytes\r\n",
  818. pRxPacket->Data[0],
  819. pRxPacket->Data[1],
  820. pRxPacket->Data[2],
  821. pRxPacket->Data[3],
  822. pRxPacket->Data[4],
  823. pRxPacket->Data[5],
  824. pRxPacket->Data[6],
  825. pRxPacket->Data[7],
  826. pRxPacket->Data[8],
  827. pRxPacket->Data[9],
  828. pRxPacket->Data[10],
  829. pRxPacket->Data[11],
  830. pRxPacket->Data[12],
  831. pRxPacket->Data[13],
  832. LengthInBytes ));
  833. }
  834. }
  835. }while ( bRxPacket );
  836. //
  837. // Release the synchronization withhe Ax88772Timer
  838. //
  839. gBS->RestoreTPL ( TplPrevious );
  840. DEBUG (( DEBUG_TPL | DEBUG_INFO,
  841. "%d: TPL\r\n",
  842. TplPrevious ));
  843. }
  844. /**
  845. Enable or disable the receiver
  846. This routine calls ::Ax88772UsbCommand to update the
  847. receiver state. This routine also calls ::Ax88772MacAddressSet
  848. to establish the MAC address for the network adapter.
  849. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  850. @param [in] RxFilter Simple network RX filter mask value
  851. @retval EFI_SUCCESS The MAC address was set.
  852. @retval other The MAC address was not set.
  853. **/
  854. EFI_STATUS
  855. Ax88772RxControl (
  856. IN NIC_DEVICE * pNicDevice,
  857. IN UINT32 RxFilter
  858. )
  859. {
  860. UINT16 MediumStatus;
  861. INT32 MulticastHash[2];
  862. UINT16 RxControl;
  863. USB_DEVICE_REQUEST SetupMsg;
  864. EFI_STATUS Status;
  865. DBG_ENTER ( );
  866. //
  867. // Disable all multicast
  868. //
  869. MulticastHash[0] = 0;
  870. MulticastHash[1] = 0;
  871. //
  872. // Enable the receiver if something is to be received
  873. //
  874. Status = EFI_SUCCESS;
  875. RxControl = RXC_SO | RXC_MFB_16384;
  876. if ( 0 != RxFilter ) {
  877. //
  878. // Enable the receiver
  879. //
  880. SetupMsg.RequestType = USB_ENDPOINT_DIR_IN
  881. | USB_REQ_TYPE_VENDOR
  882. | USB_TARGET_DEVICE;
  883. SetupMsg.Request = CMD_MEDIUM_STATUS_READ;
  884. SetupMsg.Value = 0;
  885. SetupMsg.Index = 0;
  886. SetupMsg.Length = sizeof ( MediumStatus );
  887. Status = Ax88772UsbCommand ( pNicDevice,
  888. &SetupMsg,
  889. &MediumStatus );
  890. if ( !EFI_ERROR ( Status )) {
  891. if ( 0 == ( MediumStatus & MS_RE )) {
  892. MediumStatus |= MS_RE | MS_ONE;
  893. if ( pNicDevice->bFullDuplex ) {
  894. MediumStatus |= MS_TFC | MS_RFC;
  895. }
  896. SetupMsg.RequestType = USB_REQ_TYPE_VENDOR
  897. | USB_TARGET_DEVICE;
  898. SetupMsg.Request = CMD_MEDIUM_STATUS_WRITE;
  899. SetupMsg.Value = MediumStatus;
  900. SetupMsg.Index = 0;
  901. SetupMsg.Length = 0;
  902. Status = Ax88772UsbCommand ( pNicDevice,
  903. &SetupMsg,
  904. NULL );
  905. if ( EFI_ERROR ( Status )) {
  906. DEBUG (( DEBUG_ERROR | DEBUG_INFO,
  907. "ERROR - Failed to enable receiver, Status: %r\r\n",
  908. Status ));
  909. }
  910. }
  911. }
  912. else {
  913. DEBUG (( DEBUG_ERROR | DEBUG_INFO,
  914. "ERROR - Failed to read receiver status, Status: %r\r\n",
  915. Status ));
  916. }
  917. //
  918. // Enable multicast if requested
  919. //
  920. if ( 0 != ( RxFilter & EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST )) {
  921. RxControl |= RXC_AM;
  922. MulticastHash[0] = pNicDevice->MulticastHash[0];
  923. MulticastHash[1] = pNicDevice->MulticastHash[1];
  924. }
  925. //
  926. // Enable all multicast if requested
  927. //
  928. if ( 0 != ( RxFilter & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST )) {
  929. RxControl |= RXC_AMALL;
  930. MulticastHash[0] = -1;
  931. MulticastHash[1] = -1;
  932. }
  933. //
  934. // Enable broadcast if requested
  935. //
  936. if ( 0 != ( RxFilter & EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST )) {
  937. RxControl |= RXC_AB;
  938. }
  939. //
  940. // Enable promiscuous mode if requested
  941. //
  942. if ( 0 != ( RxFilter & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS )) {
  943. RxControl |= RXC_PRO;
  944. MulticastHash[0] = -1;
  945. MulticastHash[1] = -1;
  946. }
  947. }
  948. //
  949. // Update the MAC address
  950. //
  951. if ( !EFI_ERROR ( Status )) {
  952. Status = Ax88772MacAddressSet ( pNicDevice, &pNicDevice->SimpleNetworkData.CurrentAddress.Addr[0]);
  953. }
  954. //
  955. // Update the receiver control
  956. //
  957. if ( !EFI_ERROR ( Status )) {
  958. SetupMsg.RequestType = USB_REQ_TYPE_VENDOR
  959. | USB_TARGET_DEVICE;
  960. SetupMsg.Request = CMD_RX_CONTROL_WRITE;
  961. SetupMsg.Value = RxControl;
  962. SetupMsg.Index = 0;
  963. SetupMsg.Length = 0;
  964. Status = Ax88772UsbCommand ( pNicDevice,
  965. &SetupMsg,
  966. NULL );
  967. if ( !EFI_ERROR ( Status )) {
  968. DEBUG (( DEBUG_RX_BROADCAST | DEBUG_RX_MULTICAST | DEBUG_RX_UNICAST | DEBUG_INFO,
  969. "RxControl: 0x%04x\r\n",
  970. RxControl ));
  971. //
  972. // Update the multicast hash table
  973. //
  974. SetupMsg.RequestType = USB_REQ_TYPE_VENDOR
  975. | USB_TARGET_DEVICE;
  976. SetupMsg.Request = CMD_MULTICAST_HASH_WRITE;
  977. SetupMsg.Value = 0;
  978. SetupMsg.Index = 0;
  979. SetupMsg.Length = sizeof ( pNicDevice ->MulticastHash );
  980. Status = Ax88772UsbCommand ( pNicDevice,
  981. &SetupMsg,
  982. &pNicDevice->MulticastHash );
  983. if ( !EFI_ERROR ( Status )) {
  984. DEBUG (( DEBUG_RX_MULTICAST | DEBUG_INFO,
  985. "Multicast Hash: 0x%02x %02x %02x %02x %02x %02x %02x %02x\r\n",
  986. (UINT8) MulticastHash[0],
  987. (UINT8)( MulticastHash[0] >> 8 ),
  988. (UINT8)( MulticastHash[0] >> 16 ),
  989. (UINT8)( MulticastHash[0] >> 24 ),
  990. (UINT8) MulticastHash[1],
  991. (UINT8)( MulticastHash[1] >> 8 ),
  992. (UINT8)( MulticastHash[1] >> 16 ),
  993. (UINT8)( MulticastHash[1] >> 24 )));
  994. }
  995. else {
  996. DEBUG (( DEBUG_ERROR | DEBUG_INFO,
  997. "ERROR - Failed to update multicast hash table, Status: %r\r\n",
  998. Status ));
  999. }
  1000. }
  1001. else {
  1002. DEBUG (( DEBUG_ERROR | DEBUG_INFO,
  1003. "ERROR - Failed to set receiver control, Status: %r\r\n",
  1004. Status ));
  1005. }
  1006. }
  1007. //
  1008. // Return the operation status
  1009. //
  1010. DBG_EXIT_STATUS ( Status );
  1011. return Status;
  1012. }
  1013. /**
  1014. Read an SROM location
  1015. This routine calls ::Ax88772UsbCommand to read data from the
  1016. SROM.
  1017. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  1018. @param [in] Address SROM address
  1019. @param [out] pData Buffer to receive the data
  1020. @retval EFI_SUCCESS The read was successful
  1021. @retval other The read failed
  1022. **/
  1023. EFI_STATUS
  1024. Ax88772SromRead (
  1025. IN NIC_DEVICE * pNicDevice,
  1026. IN UINT32 Address,
  1027. OUT UINT16 * pData
  1028. )
  1029. {
  1030. USB_DEVICE_REQUEST SetupMsg;
  1031. EFI_STATUS Status;
  1032. DBG_ENTER ( );
  1033. //
  1034. // Read a value from the SROM
  1035. //
  1036. SetupMsg.RequestType = USB_ENDPOINT_DIR_IN
  1037. | USB_REQ_TYPE_VENDOR
  1038. | USB_TARGET_DEVICE;
  1039. SetupMsg.Request = CMD_SROM_READ;
  1040. SetupMsg.Value = (UINT16) Address;
  1041. SetupMsg.Index = 0;
  1042. SetupMsg.Length = sizeof ( *pData );
  1043. Status = Ax88772UsbCommand ( pNicDevice,
  1044. &SetupMsg,
  1045. pData );
  1046. //
  1047. // Return the operation status
  1048. //
  1049. DBG_EXIT_STATUS ( Status );
  1050. return Status;
  1051. }
  1052. /**
  1053. This routine is called at a regular interval to poll for
  1054. receive packets.
  1055. This routine polls the link state and gets any receive packets
  1056. by calling ::Ax88772Rx.
  1057. @param [in] Event Timer event
  1058. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  1059. **/
  1060. VOID
  1061. Ax88772Timer (
  1062. IN EFI_EVENT Event,
  1063. IN NIC_DEVICE * pNicDevice
  1064. )
  1065. {
  1066. //
  1067. // Use explicit DEBUG messages since the output frequency is too
  1068. // high for DEBUG_INFO to keep up and have spare cycles for the
  1069. // shell
  1070. //
  1071. DEBUG (( DEBUG_TIMER, "Entering Ax88772Timer\r\n" ));
  1072. //
  1073. // Poll the link state and get any receive packets
  1074. //
  1075. Ax88772Rx ( pNicDevice, FALSE );
  1076. DEBUG (( DEBUG_TIMER, "Exiting Ax88772Timer\r\n" ));
  1077. }
  1078. /**
  1079. Send a command to the USB device.
  1080. @param [in] pNicDevice Pointer to the NIC_DEVICE structure
  1081. @param [in] pRequest Pointer to the request structure
  1082. @param [in, out] pBuffer Data buffer address
  1083. @retval EFI_SUCCESS The USB transfer was successful
  1084. @retval other The USB transfer failed
  1085. **/
  1086. EFI_STATUS
  1087. Ax88772UsbCommand (
  1088. IN NIC_DEVICE * pNicDevice,
  1089. IN USB_DEVICE_REQUEST * pRequest,
  1090. IN OUT VOID * pBuffer
  1091. )
  1092. {
  1093. UINT32 CmdStatus;
  1094. EFI_USB_DATA_DIRECTION Direction;
  1095. EFI_USB_IO_PROTOCOL * pUsbIo;
  1096. EFI_STATUS Status;
  1097. DBG_ENTER ( );
  1098. //
  1099. // Determine the transfer direction
  1100. //
  1101. Direction = EfiUsbNoData;
  1102. if ( 0 != pRequest->Length ) {
  1103. Direction = ( 0 != ( pRequest->RequestType & USB_ENDPOINT_DIR_IN ))
  1104. ? EfiUsbDataIn : EfiUsbDataOut;
  1105. }
  1106. //
  1107. // Issue the command
  1108. //
  1109. pUsbIo = pNicDevice->pUsbIo;
  1110. Status = pUsbIo->UsbControlTransfer ( pUsbIo,
  1111. pRequest,
  1112. Direction,
  1113. USB_BUS_TIMEOUT,
  1114. pBuffer,
  1115. pRequest->Length,
  1116. &CmdStatus );
  1117. //
  1118. // Determine the operation status
  1119. //
  1120. if ( !EFI_ERROR ( Status )) {
  1121. Status = CmdStatus;
  1122. }
  1123. else {
  1124. //
  1125. // Display any errors
  1126. //
  1127. DEBUG (( DEBUG_INFO,
  1128. "Ax88772UsbCommand - Status: %r\n",
  1129. Status ));
  1130. //
  1131. // Only use status values associated with the Simple Network protocol
  1132. //
  1133. if ( EFI_TIMEOUT == Status ) {
  1134. Status = EFI_DEVICE_ERROR;
  1135. }
  1136. }
  1137. //
  1138. // Return the operation status
  1139. //
  1140. DBG_EXIT_STATUS ( Status );
  1141. return Status;
  1142. }