From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: From: David Presotto To: 9fans@cse.psu.edu MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-aznynxalldwwgkklrgjfsuhwtx" Subject: [9fans] (no subject) Date: Sun, 19 Oct 2003 10:22:57 -0400 Topicbox-Message-UUID: 72c5f37c-eacc-11e9-9e20-41e7f4b1d025 This is a multi-part message in MIME format. --upas-aznynxalldwwgkklrgjfsuhwtx Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit I added Micah's changes with the following difference: stats and ifstats now appears both in the higher level directory (/net/ether0) and the old places (/net/ether0/0/). The library and the commands changed now look first in the new place and then in the old place. In a month or so, I'll take stats and ifstats out of the old places and change the command and library to look only in the new places. If you don't keep up, you may experience some difficulties. --upas-aznynxalldwwgkklrgjfsuhwtx Content-Type: message/rfc822 Content-Disposition: inline Received: from plan9.cs.bell-labs.com ([135.104.9.2]) by plan9; Fri Oct 17 23:54:46 EDT 2003 Received: from epaphras.cnm-vra.com ([66.122.178.130]) by plan9; Fri Oct 17 23:54:45 EDT 2003 Received: by epaphras.cnm-vra.com (Postfix, from userid 1000) id 5A044CECC; Fri, 17 Oct 2003 20:55:50 -0700 (PDT) Date: Fri, 17 Oct 2003 20:55:50 -0700 From: Micah Stetson To: David Presotto Subject: Re: [9fans] Ethernet link status Message-ID: <20031018035550.GA21414@epaphras.cnm-vra.com> References: <20031009043303.GB3466@epaphras.cnm-vra.com> <04f174df79eebe235bcf41eed834c385@plan9.bell-labs.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="9jxsPFA5p3P2qPhR" Content-Disposition: inline In-Reply-To: <04f174df79eebe235bcf41eed834c385@plan9.bell-labs.com> User-Agent: Mutt/1.4.1i --9jxsPFA5p3P2qPhR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline > The stats files in connection directories was stupid, because I > originally had a simple structure and that was the easy place to > put the stats files. I really should move it up but never get > around to it... > > In general, stats is meant for generic info common to all types of > interfaces and ifstats for interface specific stuff. I would say > that link is generic; even the 802.11's have something you might > construe as link (i.e. a base station to talk to). OK, tonight I got bored with the other project I was working on and made the requisite changes to move the 'link:' line to stats and move stats and ifstats up out of the connection directories. I haven't tested this very rigorously, but the changes are generally so inconsequential that I can't foresee any major problems. I also changed the ether(3) man page to bring it in line with the current state of affairs. I'm not convinced that the wording I've used is the best, but I can't think of how to say things better without being long winded. Diffs below: term% diff /sys/src/9/port/netif.h port/netif.h 77a78 > int link; /* link status */ term% diff /sys/src/9/port/netif.c port/netif.c 81a82,89 > case 2: > q.path = Nstatqid; > devdir(c, q, "stats", 0, eve, 0444, dp); > break; > case 3: > q.path = Nifstatqid; > devdir(c, q, "ifstats", 0, eve, 0444, dp); > break; 83c91 < i -= 2; --- > i -= 4; 124,127d131 < q.path = NETQID(NETID(c->qid.path), Nstatqid); < devdir(c, q, "stats", 0, eve, 0444, dp); < break; < case 3: 131,134d134 < case 4: < q.path = NETQID(NETID(c->qid.path), Nifstatqid); < devdir(c, q, "ifstats", 0, eve, 0444, dp); < break; 215a216 > j += snprint(p+j, READSTR-j, "link: %d\n", nif->link); term% diff /sys/src/9/ip/ethermedium.c ip/ethermedium.c 166c166 < snprint(addr, sizeof(addr), "%s/stats", dir); --- > snprint(addr, sizeof(addr), "%s/stats", argv[2]); term% diff /sys/src/9/pc/ether82557.c pc/ether82557.c 38a39 > Gstatus = 0x1D, /* General status register */ 426a428,429 > > ether->link = csr8r(ctlr, Gstatus) & 0x1; term% diff /sys/src/libip/myetheraddr.c myetheraddr.c 21c21 < sprint(buf, "%s/0/stats", dev); --- > sprint(buf, "%s/stats", dev); 23c23 < sprint(buf, "/net/%s/0/stats", dev); --- > sprint(buf, "/net/%s/stats", dev); term% diff /sys/src/cmd/stats.c stats.c 46c46 < /* /net/ether0/0/stats */ --- > /* /net/ether0/stats */ 628c628 < snprint(buf, sizeof buf, "%s/net/ether0/0/stats", mpt); --- > snprint(buf, sizeof buf, "%s/net/ether0/stats", mpt); 633c633 < snprint(buf, sizeof buf, "%s/net/ether0/0/ifstats", mpt); --- > snprint(buf, sizeof buf, "%s/net/ether0/ifstats", mpt); The changes to ether(3) are more than just a couple of lines, so I'm just attaching the whole file. It looks to me like the only binaries that need to be recompiled as a result of the libip change are ip/ipconfig, ip/rarpd and ndb/cs. One thing I didn't attempt was to modify the other ethernet controllers to put link info in the stats. Maybe what could be done temporarily is to have them set link to -1 to mean 'unknown'. Then as people have time/interest, they can update the individual drivers. Thanks for all your work, and thanks in advance for incorporating this stuff. I know you guys are busy; I will understand if it doesn't make the distro for a while. Micah --9jxsPFA5p3P2qPhR Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=ether .TH ETHER 3 .SH NAME ether \- Ethernet device .SH SYNOPSIS .nf .B bind -a #l /net .BI /net/ether n /addr .BI /net/ether n /clone .BI /net/ether n /ifstats .BI /net/ether n /stats .BI /net/ether n /[0-7] .BI /net/ether n /[0-7]/data .BI /net/ether n /[0-7]/ctl .BI /net/ether n /[0-7]/type .fi .SH DESCRIPTION The Ethernet interface, .BI /net/ether n\f1, is a directory containing subdirectories, one for each distinct Ethernet packet type, in addition to the files .BR addr , .BR clone , .BR ifstats , and .BR stats . The number .I n is the device number of the card, permitting multiple cards to be used on a single machine. .PP A read of the .B addr file yields the Ethernet address of the card. Reading .B stats returns status information such as the speed and integrity of the physical link along with general statistics, independent of the interface; .B ifstats contains device-specific data and statistics about the card. Opening the .B clone file is equivalent to opening the .B ctl file in an unused, perhaps newly created, connection directory. .PP Each numbered directory contains files to control the associated connection as well as receive and send data. Incoming Ethernet packets are demultiplexed by packet type and passed up the corresponding open connection. Reading from the .B data file reads packets of that type arriving from the network. A read will terminate at packet boundaries. Each write to the .B data file causes a packet to be sent. The Ethernet address of the interface is inserted into the packet header as the source address. .PP A connection is assigned to a packet type by opening its .B ctl file and writing .B connect .I n where .I n is a decimal integer constant identifying the Ethernet packet type. A type of \-1 enables the connection to receive copies of packets of all types. A type of \-2 enables the connection to receive copies of the first 64 bytes of packets of all types. If multiple connections are assigned to a given packet type a copy of each packet is passed up each connection. .PP Some interfaces also accept unique options when written to the .I ctl (or .IR clone ) file; see the description of .I wavelan in .IR plan9.ini (8). .PP Reading the .B ctl file returns the decimal index of the associated connection, 0 through 7. Reading the .B type file returns the decimal value of the assigned Ethernet packet type. .PP An interface normally receives only those packets whose destination address is that of the interface or is the broadcast address, .BR ff:ff:ff:ff:ff:ff . The interface can be made to receive all packets on the network by writing the string .B promiscuous to the .B ctl file. The interface remains promiscuous until the control file is closed. The extra packets are passed up connections only of types \-1 and \-2. .SH SOURCE .B /sys/src/9/*/devether.c --9jxsPFA5p3P2qPhR-- --upas-aznynxalldwwgkklrgjfsuhwtx--