Re: svn commit: r269106 - head/tools/tools/cxgbetool

2014-07-27 Thread Navdeep Parhar
On Sat, Jul 26, 2014 at 09:26:07PM +0300, Konstantin Belousov wrote:
 On Sat, Jul 26, 2014 at 12:51:45AM +, Navdeep Parhar wrote:
  Author: np
  Date: Sat Jul 26 00:51:45 2014
  New Revision: 269106
  URL: http://svnweb.freebsd.org/changeset/base/269106
  
  Log:
Add a 'raw' parameter to the 'modinfo' subcommand.  This is handy when
trying to figure out why a QSFP+/SFP+ connector or cable wasn't
identified correctly by cxgbe(4).  Its output looks like this:

# cxgbetool t5nex0 modinfo 0 raw
00:  03 04 21 00  00 00 00 00  ..!. 
08:  04 00 00 00  67 00 00 00   g...
10:  00 00 05 00  41 6d 70 68   Amph
18:  65 6e 6f 6c  20 20 20 20  enol
20:  20 20 20 20  00 41 50 48   .APH
28:  35 37 31 35  34 30 30 30  5715 4000
30:  33 20 20 20  20 20 20 20  3
38:  4b 20 20 20  01 00 00 fa  K
40:  00 00 00 00  41 50 46 31   APF1
48:  30 30 34 30  30 33 30 30  0040 0300
50:  30 33 20 20  31 30 30 31  03   1001
58:  33 30 20 20  00 00 00 97  30   

MFC after:3 days
  
  Modified:
head/tools/tools/cxgbetool/cxgbetool.c
 
 I do not remember if this question was already asked.
 
 Why cxgbetool lives in tools and not installed into /usr/sbin as
 cxgbecontrol(8) ?

cxgbetool was originally meant to be just a debug tool, not something
that would be of interest to most users (not even those using cxgbe).
But once written, it offered an easy way to interface with the driver
and chip, and so it gradually grew a number of commands for features for
which there is no system CLI (packet filtering/steering, QoS-ish stuff,
packet sniffing, pluggable optics/copper modules, etc.).

In its current state I think it fits in tools/tools or usr/sbin equally
well.  Moving it to usr/sbin will force the issue of a manpage -- I have
one that has been 80% complete for 2 years now :-(

Regards,
Navdeep
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r269106 - head/tools/tools/cxgbetool

2014-07-26 Thread Konstantin Belousov
On Sat, Jul 26, 2014 at 12:51:45AM +, Navdeep Parhar wrote:
 Author: np
 Date: Sat Jul 26 00:51:45 2014
 New Revision: 269106
 URL: http://svnweb.freebsd.org/changeset/base/269106
 
 Log:
   Add a 'raw' parameter to the 'modinfo' subcommand.  This is handy when
   trying to figure out why a QSFP+/SFP+ connector or cable wasn't
   identified correctly by cxgbe(4).  Its output looks like this:
   
   # cxgbetool t5nex0 modinfo 0 raw
   00:  03 04 21 00  00 00 00 00  ..!. 
   08:  04 00 00 00  67 00 00 00   g...
   10:  00 00 05 00  41 6d 70 68   Amph
   18:  65 6e 6f 6c  20 20 20 20  enol
   20:  20 20 20 20  00 41 50 48   .APH
   28:  35 37 31 35  34 30 30 30  5715 4000
   30:  33 20 20 20  20 20 20 20  3
   38:  4b 20 20 20  01 00 00 fa  K
   40:  00 00 00 00  41 50 46 31   APF1
   48:  30 30 34 30  30 33 30 30  0040 0300
   50:  30 33 20 20  31 30 30 31  03   1001
   58:  33 30 20 20  00 00 00 97  30   
   
   MFC after:  3 days
 
 Modified:
   head/tools/tools/cxgbetool/cxgbetool.c

I do not remember if this question was already asked.

Why cxgbetool lives in tools and not installed into /usr/sbin as
cxgbecontrol(8) ?


pgpk7hyFcRkNb.pgp
Description: PGP signature


svn commit: r269106 - head/tools/tools/cxgbetool

2014-07-25 Thread Navdeep Parhar
Author: np
Date: Sat Jul 26 00:51:45 2014
New Revision: 269106
URL: http://svnweb.freebsd.org/changeset/base/269106

Log:
  Add a 'raw' parameter to the 'modinfo' subcommand.  This is handy when
  trying to figure out why a QSFP+/SFP+ connector or cable wasn't
  identified correctly by cxgbe(4).  Its output looks like this:
  
  # cxgbetool t5nex0 modinfo 0 raw
  00:  03 04 21 00  00 00 00 00  ..!. 
  08:  04 00 00 00  67 00 00 00   g...
  10:  00 00 05 00  41 6d 70 68   Amph
  18:  65 6e 6f 6c  20 20 20 20  enol
  20:  20 20 20 20  00 41 50 48   .APH
  28:  35 37 31 35  34 30 30 30  5715 4000
  30:  33 20 20 20  20 20 20 20  3
  38:  4b 20 20 20  01 00 00 fa  K
  40:  00 00 00 00  41 50 46 31   APF1
  48:  30 30 34 30  30 33 30 30  0040 0300
  50:  30 33 20 20  31 30 30 31  03   1001
  58:  33 30 20 20  00 00 00 97  30   
  
  MFC after:3 days

Modified:
  head/tools/tools/cxgbetool/cxgbetool.c

Modified: head/tools/tools/cxgbetool/cxgbetool.c
==
--- head/tools/tools/cxgbetool/cxgbetool.c  Fri Jul 25 23:52:53 2014
(r269105)
+++ head/tools/tools/cxgbetool/cxgbetool.c  Sat Jul 26 00:51:45 2014
(r269106)
@@ -95,7 +95,7 @@ usage(FILE *fp)
\ti2c port devaddr addr [len] read from i2c device\n
\tloadfw fw-image.bin   install firmware\n
\tmemdump addr lendump a memory range\n
-   \tmodinfo port  optics/cable information\n
+   \tmodinfo port [raw]optics/cable information\n
\treg address[=val]   read/write register\n
\treg64 address[=val] read/write 64 bit register\n
\tregdump [module] ...  dump registers\n
@@ -1873,6 +1873,41 @@ tracer_cmd(int argc, const char *argv[])
 }
 
 static int
+modinfo_raw(int port_id)
+{
+   uint8_t offset;
+   struct t4_i2c_data i2cd;
+   int rc;
+
+   for (offset = 0; offset  96; offset += sizeof(i2cd.data)) {
+   bzero(i2cd, sizeof(i2cd));
+   i2cd.port_id = port_id;
+   i2cd.dev_addr = 0xa0;
+   i2cd.offset = offset;
+   i2cd.len = sizeof(i2cd.data);
+   rc = doit(CHELSIO_T4_GET_I2C, i2cd);
+   if (rc != 0)
+   return (rc);
+   printf(%02x:  %02x %02x %02x %02x  %02x %02x %02x %02x,
+   offset, i2cd.data[0], i2cd.data[1], i2cd.data[2],
+   i2cd.data[3], i2cd.data[4], i2cd.data[5], i2cd.data[6],
+   i2cd.data[7]);
+
+   printf(  %c%c%c%c %c%c%c%c\n,
+   isprint(i2cd.data[0]) ? i2cd.data[0] : '.',
+   isprint(i2cd.data[1]) ? i2cd.data[1] : '.',
+   isprint(i2cd.data[2]) ? i2cd.data[2] : '.',
+   isprint(i2cd.data[3]) ? i2cd.data[3] : '.',
+   isprint(i2cd.data[4]) ? i2cd.data[4] : '.',
+   isprint(i2cd.data[5]) ? i2cd.data[5] : '.',
+   isprint(i2cd.data[6]) ? i2cd.data[6] : '.',
+   isprint(i2cd.data[7]) ? i2cd.data[7] : '.');
+   }
+
+   return (0);
+}
+
+static int
 modinfo(int argc, const char *argv[])
 {
long port;
@@ -1881,17 +1916,31 @@ modinfo(int argc, const char *argv[])
int rc, i;
uint16_t temp, vcc, tx_bias, tx_power, rx_power;
 
-   if (argc != 1) {
+   if (argc  1) {
warnx(must supply a port);
return (EINVAL);
}
 
+   if (argc  2) {
+   warnx(too many arguments);
+   return (EINVAL);
+   }
+
p = str_to_number(argv[0], port, NULL);
if (*p || port  UCHAR_MAX) {
warnx(invalid port id \%s\, argv[0]);
return (EINVAL);
}
 
+   if (argc == 2) {
+   if (!strcmp(argv[1], raw))
+   return (modinfo_raw(port));
+   else {
+   warnx(second argument can only be \raw\);
+   return (EINVAL);
+   }
+   }
+
bzero(i2cd, sizeof(i2cd));
i2cd.len = 1;
i2cd.port_id = port;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org