@@ -252,6 +252,9 @@ typedef struct dwmac1000
252
252
* PHY at startup.
253
253
*/
254
254
uint16_t anar ;
255
+
256
+ /* lwip network interface handle */
257
+ struct netif * netif ;
255
258
} dwmac1000_t ;
256
259
257
260
#ifdef DEBUG_DATA
@@ -289,6 +292,24 @@ static void dwmac1000_pbuf_dump (struct pbuf * p)
289
292
}
290
293
#endif /* DEBUG_DATA */
291
294
295
+ #if MIB2_STATS
296
+ static uint32_t dwmac1000_snmp_link_speed (uint8_t link_state )
297
+ {
298
+ if (link_state & PHY_LINK_10MBIT )
299
+ {
300
+ return 10 * 1000 * 1000 ;
301
+ }
302
+ else if (link_state & PHY_LINK_100MBIT )
303
+ {
304
+ return 100 * 1000 * 1000 ;
305
+ }
306
+ else
307
+ {
308
+ return 0 ;
309
+ }
310
+ }
311
+ #endif /* MIB2_STATS */
312
+
292
313
static uint16_t dwmac1000_read_phy (void * arg , uint8_t address , uint8_t reg )
293
314
{
294
315
dwmac1000_t * dwmac1000 = arg ;
@@ -727,6 +748,11 @@ static dev_state_t dwmac1000_probe (drv_t * drv)
727
748
/* Save link state for IOCTL_NET_GET_STATUS */
728
749
dwmac1000 -> last_link_state = link_state ;
729
750
751
+ /* Set ifSpeed in SNMP MIB-II ifTable */
752
+ #if MIB2_STATS
753
+ dwmac1000 -> netif -> link_speed = dwmac1000_snmp_link_speed (link_state );
754
+ #endif /* MIB2_STATS */
755
+
730
756
return (link_state & PHY_LINK_OK ) ? StateAttached : StateDetached ;
731
757
}
732
758
@@ -815,6 +841,7 @@ drv_t * dwmac1000_init (
815
841
dwmac1000 -> mmc = (eth_mmc_t * )(cfg -> base + 0x100 );
816
842
dwmac1000 -> dma = (eth_dma_t * )(cfg -> base + 0x1000 );
817
843
dwmac1000 -> last_link_state = 0x00 ;
844
+ dwmac1000 -> netif = netif ;
818
845
819
846
/* Create receive task */
820
847
dwmac1000 -> tRcv = task_spawn (
0 commit comments