@@ -159,6 +159,41 @@ static void iface_cb(struct net_if *iface, void *user_data)
159159}
160160#endif
161161
162+ #if defined(CONFIG_NET_STATISTICS_ETHERNET )
163+ static void print_eth_stats (struct net_if * iface , struct net_stats_eth * data )
164+ {
165+ printk ("Statistics for Ethernet interface %p [%d]\n" , iface ,
166+ net_if_get_by_iface (iface ));
167+
168+ printk ("Bytes received : %u\n" , data -> bytes .received );
169+ printk ("Bytes sent : %u\n" , data -> bytes .sent );
170+ printk ("Packets received : %u\n" , data -> pkts .rx );
171+ printk ("Packets sent : %u\n" , data -> pkts .tx );
172+ printk ("Bcast received : %u\n" , data -> broadcast .rx );
173+ printk ("Bcast sent : %u\n" , data -> broadcast .tx );
174+ printk ("Mcast received : %u\n" , data -> multicast .rx );
175+ printk ("Mcast sent : %u\n" , data -> multicast .tx );
176+ }
177+
178+ static void eth_iface_cb (struct net_if * iface , void * user_data )
179+ {
180+ struct net_stats_eth eth_data ;
181+ int ret ;
182+
183+ if (net_if_l2 (iface ) != & NET_L2_GET_NAME (ETHERNET )) {
184+ return ;
185+ }
186+
187+ ret = net_mgmt (NET_REQUEST_STATS_GET_ETHERNET , iface , & eth_data ,
188+ sizeof (eth_data ));
189+ if (ret < 0 ) {
190+ return ;
191+ }
192+
193+ print_eth_stats (iface , & eth_data );
194+ }
195+ #endif
196+
162197static void stats (struct k_work * work )
163198{
164199 struct net_stats data ;
@@ -175,6 +210,10 @@ static void stats(struct k_work *work)
175210 net_if_foreach (iface_cb , & data );
176211#endif
177212
213+ #if defined(CONFIG_NET_STATISTICS_ETHERNET )
214+ net_if_foreach (eth_iface_cb , & data );
215+ #endif
216+
178217 k_delayed_work_submit (& stats_timer , K_SECONDS (CONFIG_SAMPLE_PERIOD ));
179218}
180219
0 commit comments