diff -r -u -F *.[ch]\> -x *.[oas] -x Makefile -x .??* -x *onf* -x local.h -x *.ver -x *~ -x version.h linux.2.0.37/drivers/char/serial.c linux.2.0.37.pf/drivers/char/serial.c --- linux.2.0.37/drivers/char/serial.c Sun Jun 20 21:38:52 1999 +++ linux.2.0.37.pf/drivers/char/serial.c Sun Jun 20 21:47:13 1999 @@ -482,6 +482,7 @@ } if (tty->flip.count >= TTY_FLIPBUF_SIZE) break; + info->rx_char_count++; tty->flip.count++; if (*status & (UART_LSR_BI)) { #ifdef SERIAL_DEBUG_INTR @@ -514,6 +515,7 @@ if (info->x_char) { serial_outp(info, UART_TX, info->x_char); + info->tx_char_count++; info->x_char = 0; if (intr_done) *intr_done = 0; @@ -529,6 +531,7 @@ count = info->xmit_fifo_size; do { serial_out(info, UART_TX, info->xmit_buf[info->xmit_tail++]); + info->tx_char_count++; info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1); if (--info->xmit_cnt <= 0) break; @@ -1714,6 +1717,21 @@ } +static int get_serial_stats(struct async_struct * info, struct serial_stats_struct *retinfo) +{ + struct serial_stats_struct k_stats; + + cli(); + do_gettimeofday(&k_stats.ts); + k_stats.count = info->count; + k_stats.rx = info->rx_char_count; + k_stats.tx = info->tx_char_count; + sti(); + memcpy_tofs(retinfo,&k_stats,sizeof(*retinfo)); + + return 0; +} + static int get_modem_info(struct async_struct * info, unsigned int *value) { unsigned char control, status; @@ -2011,6 +2029,7 @@ if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGWILD) && (cmd != TIOCSERSWILD) && (cmd != TIOCSERGSTRUCT) && + (cmd != TIOCMGET) && (cmd != TIOCSERGSTATS) && (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) { if (tty->flags & (1 << TTY_IO_ERROR)) return -EIO; @@ -2125,6 +2144,13 @@ info, sizeof(struct async_struct)); return 0; + case TIOCSERGSTATS: + error = verify_area(VERIFY_WRITE, (void *) arg, + sizeof(struct serial_stats_struct)); + if (error) + return error; + return get_serial_stats(info, + (struct serial_stats_struct *)arg); case TIOCSERGETMULTI: error = verify_area(VERIFY_WRITE, (void *) arg, sizeof(struct serial_multiport_struct)); @@ -2875,6 +2901,8 @@ info->icount.rng = info->icount.dcd = 0; info->next_port = 0; info->prev_port = 0; + info->rx_char_count = info->tx_char_count = 0; + if (info->irq == 2) info->irq = 9; diff -r -u -F *.[ch]\> -x *.[oas] -x Makefile -x .??* -x *onf* -x local.h -x *.ver -x *~ -x version.h linux.2.0.37/include/linux/serial.h linux.2.0.37.pf/include/linux/serial.h --- linux.2.0.37/include/linux/serial.h Sun Jun 20 21:39:01 1999 +++ linux.2.0.37.pf/include/linux/serial.h Sun Jun 20 21:43:49 1999 @@ -109,6 +109,16 @@ int reserved[16]; }; +#include +/* + * Serial statistics structure returned by TIOCSERGSTATS ioctl + */ +struct serial_stats_struct { + int count; + int rx; + int tx; + struct timeval ts; +}; #ifdef __KERNEL__ /* @@ -172,6 +182,8 @@ struct async_icount icount; /* kernel counters for the 4 input interrupts */ struct async_struct *next_port; /* For the linked list */ struct async_struct *prev_port; + unsigned long rx_char_count; /* Total no of chars received */ + unsigned long tx_char_count; /* Total no of chars transmitted */ }; #define SERIAL_MAGIC 0x5301 diff -r -u -F *.[ch]\> -x *.[oas] -x Makefile -x .??* -x *onf* -x *floppy* -x local.h -x *.ver -x *~ -x version.h linux.2.0.36/include/asm/ioctls.h linux.2.0.36.pf/include/asm/ioctls.h --- linux.2.0.36/include/asm-i386/ioctls.h Tue Apr 9 07:29:28 1996 +++ linux.2.0.36.pf/include/asm-i386/ioctls.h Fri Mar 6 22:00:24 1998 @@ -59,6 +59,7 @@ #define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ #define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ +#define TIOCSERGSTATS 0x54f3 /* Get interrupt statistics */ /* Used for packet mode */ #define TIOCPKT_DATA 0