From e2bb312dd85c12c8534aab2f759a77f2beded3ed Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Fri, 22 Mar 2013 14:30:48 -0700 Subject: [PATCH] Fixed redundant output in SHOW ETHERNET when ethernet devices are open and added device send/receive stats --- sim_ether.c | 38 +++++++++++++++++--------------------- sim_ether.h | 2 ++ 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/sim_ether.c b/sim_ether.c index 082393e9..58bec404 100644 --- a/sim_ether.c +++ b/sim_ether.c @@ -718,19 +718,7 @@ t_stat eth_show (FILE* st, UNIT* uptr, int32 val, void* desc) fprintf(st, " %-7s%s (%s)\n", eth_open_devices[i]->dptr->name, eth_open_devices[i]->dptr->units[0].filename, d); else fprintf(st, " %-7s%s\n", eth_open_devices[i]->dptr->name, eth_open_devices[i]->dptr->units[0].filename); - } - } - if (eth_open_device_count) { - int i; - char desc[ETH_DEV_DESC_MAX], *d; - - fprintf(st,"Open ETH Devices:\n"); - for (i=0; iname, desc); - if (d) - fprintf(st, " %-7s%s (%s)\n", eth_open_devices[i]->dptr->name, eth_open_devices[i]->name, d); - else - fprintf(st, " %-7s%s\n", eth_open_devices[i]->dptr->name, eth_open_devices[i]->name); + eth_show_dev (st, eth_open_devices[i]); } } return SCPE_OK; @@ -2181,6 +2169,7 @@ if ((packet->len >= ETH_MIN_PACKET) && (packet->len <= ETH_MAX_PACKET)) { break; #endif } + ++dev->packets_sent; /* basic bookkeeping */ /* On error, correct loopback bookkeeping */ if ((status != 0) && loopback_self_frame) { #ifdef USE_READER_THREAD @@ -2804,6 +2793,7 @@ if (bpf_used ? to_me : (to_me && !from_me)) { pthread_mutex_lock (&dev->lock); ethq_insert_data(&dev->read_queue, 2, data, 0, len, crc_len, crc_data, 0); + ++dev->packets_received; pthread_mutex_unlock (&dev->lock); free(moved_data); } @@ -2830,6 +2820,8 @@ if (bpf_used ? to_me : (to_me && !from_me)) { eth_packet_trace (dev, dev->read_packet->msg, dev->read_packet->len, "reading"); + ++dev->packets_received; + /* call optional read callback function */ if (dev->read_callback) (dev->read_callback)(0); @@ -3274,22 +3266,26 @@ if (!dev) { fprintf(st, "-- Not Attached\n"); return; } -fprintf(st, " Name: %s\n", dev->name); -fprintf(st, " Reflections: %d\n", dev->reflections); -fprintf(st, " Self Loopbacks Sent: %d\n", dev->loopback_self_sent_total); -fprintf(st, " Self Loopbacks Rcvd: %d\n", dev->loopback_self_rcvd_total); +fprintf(st, " Name: %s\n", dev->name); +fprintf(st, " Reflections: %d\n", dev->reflections); +fprintf(st, " Self Loopbacks Sent: %d\n", dev->loopback_self_sent_total); +fprintf(st, " Self Loopbacks Rcvd: %d\n", dev->loopback_self_rcvd_total); if (dev->have_host_nic_phy_addr) { char hw_mac[20]; eth_mac_fmt(&dev->host_nic_phy_hw_addr, hw_mac); - fprintf(st, " Host NIC Address: %s\n", hw_mac); + fprintf(st, " Host NIC Address: %s\n", hw_mac); } if (dev->jumbo_dropped) - fprintf(st, " Jumbo Dropped: %d\n", dev->jumbo_dropped); + fprintf(st, " Jumbo Dropped: %d\n", dev->jumbo_dropped); if (dev->jumbo_fragmented) - fprintf(st, " Jumbo Fragmented: %d\n", dev->jumbo_fragmented); + fprintf(st, " Jumbo Fragmented: %d\n", dev->jumbo_fragmented); if (dev->jumbo_truncated) - fprintf(st, " Jumbo Truncated: %d\n", dev->jumbo_truncated); + fprintf(st, " Jumbo Truncated: %d\n", dev->jumbo_truncated); +if (dev->packets_sent) + fprintf(st, " Packets Sent: %d\n", dev->packets_sent); +if (dev->packets_received) + fprintf(st, " Packets Received: %d\n", dev->packets_received); #if defined(USE_READER_THREAD) fprintf(st, " Asynch Interrupts: %s\n", dev->asynch_io?"Enabled":"Disabled"); if (dev->asynch_io) diff --git a/sim_ether.h b/sim_ether.h index 78fb2957..c35821e3 100644 --- a/sim_ether.h +++ b/sim_ether.h @@ -235,6 +235,8 @@ struct eth_device { uint32 jumbo_fragmented; /* Giant IPv4 Frames Fragmented */ uint32 jumbo_dropped; /* Giant Frames Dropped */ uint32 jumbo_truncated; /* Giant Frames too big for capture buffer - Dropped */ + uint32 packets_sent; /* Total Packets Sent */ + uint32 packets_received; /* Total Packets Received */ DEVICE* dptr; /* device ethernet is attached to */ uint32 dbit; /* debugging bit */ int reflections; /* packet reflections on interface */