lkml.org 
[lkml]   [2000]   [Sep]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: PATCH 2.4.0.9.2: export ethtool interface
Jeff Garzik wrote:
>
> This patch, against 2.4.0-test9-pre2, moves ethtool.h from the private
> domain of the sparc ports into include/linux. This publishes an
> existing interface, and has been discussed before. (search past lkml
> subject headers for "media tool" and "ethtool")
>
> This updated patch should take some of the past threads into account.
> The differences from the current sparc ethtool.h are:
>
> * bitmask for advertising as well as supported media types
> * interrupt mitigation hints max{tx,rx}pkt (Jes suggestion)
> * four reserved u32 slots for future expansion
> * assigned an ioctl: SIOCETHTOOL (0x8944)
>

This is good. It would be useful to have this in place ASAP so driver
authors have something to look at and to work against.

I've made some edits (revised patch attached here).

* With this interface I don't see a way in which one can force some
settings but leave others unforced. Suppose, for example, that I wish
to force 10mbps but to leave the setting of the transceiver type,
duplex, etc alone (ie: up to the driver/hardware to determine the value
of these).

If you do an ETHTOOL_SSET/modify/ETHTOOL_SGET on the interface you'll
end up *forcing* all these settings into whatever state they happened to
be in when you did the read, no?

So I added the `force_mask' which should be tested by the ETHTOOL_SSET
handler to decide which fields are actually being forced.

When the driver receives a ETHTOOL_SGET it should populate `force_mask'
to indicate to the caller which fields are currently forced.

* I added SUPPORTED_MAC_FLOWCTRL/ADVERTISED_MAC_FLOWCTRL for advertising
of 802.3x MAC-layer flow control.

* I added the `flow_ctrl' field to say whether we want to enable/disable
this.

Other comments:

* There don't seem to be enough port types and transceiver types.
10base2? BNC? 100baseTx/100baseFX?

* Regarding the ADVERTISED bits. Are these designed to read back what
we're currently advertising, or are they designed to allow us to force
what is to be advertised? Both, I guess.

* maxtxpkt and maxrxpkt seem highly specific to particular hardware and
particular drivers. Plus there are a large range of other
driver-specific performance tunables which are typically controlled by
module parms. Why pick these two?

It may be better to bury this sort of thing into a device-specific
anonymous field. Shrug - don't bother: I wouldn't expect anyone to
really use these things because it's such a PITA to tear down all the
driver data structures and rebuild them.

* Are you really, really sure about the alignment issues with struct
ethtool_cmd? It strikes me that burying a short and five chars in among
a bunch of longs is asking for trouble. Suppose the caller is using a
different compiler? If you're not sure, make 'em all u32 :)



On a related topic, it offends me that when you unplug the RJ45 from a
win2k machine it pops up a little box telling you your network has
disappeared. We can't do that.

At present, SIOCGIFFLAGS returns an amalgam of __LINK_STATE_START and
__LINK_STATE_NOCARRIER in IFF_RUNNING. We need to separate these out so
applications can query __LINK_STATE_NOCARRIER independently. We also
need a select()able interface so changes in carrier can be monitored.

The users of a select()able carrier detect would be desktop UIs and the
high-availability guys. The latter is a guess - I don't really know if
people who are concerned about failover would find a carrier-lost
indication useful. TBD.--- linux-2.4.0-test9-pre4/include/linux/ethtool.h Thu Jan 1 10:00:00 1970
+++ linux-akpm/include/linux/ethtool.h Tue Sep 19 23:09:38 2000
@@ -0,0 +1,114 @@
+/* $Id: ethtool.h,v 1.1.186.1 2000/09/16 20:13:14 jgarzik Exp $
+ * ethtool.h: Defines for Linux ethtool.
+ *
+ * Copyright (C) 1998 David S. Miller (davem@redhat.com)
+ */
+
+#ifndef _LINUX_ETHTOOL_H
+#define _LINUX_ETHTOOL_H
+
+/* This should work for both 32 and 64 bit userland. */
+struct ethtool_cmd {
+ u32 cmd;
+ u32 force_mask; /* Which fieldswe wish to force */
+ u32 supported; /* Features this interface supports */
+ u32 advertising; /* Features this interface advertises */
+ u16 speed; /* The forced speed, 10Mb, 100Mb, gigabit */
+ u8 duplex; /* Duplex, half or full */
+ u8 flow_ctrl; /* 802.3x flow control */
+ u8 port; /* Which connector port */
+ u8 phy_address;
+ u8 transceiver; /* Which tranceiver to use */
+ u8 autoneg; /* Enable or disable autonegotiation */
+ u32 maxtxpkt; /* Tx pkts before generating tx int */
+ u32 maxrxpkt; /* Rx pkts before generating rx int */
+ u32 reserved[4];
+};
+
+
+/* CMDs currently supported */
+#define ETHTOOL_GSET 0x00000001 /* Get settings, non-privileged. */
+#define ETHTOOL_SSET 0x00000002 /* Set settings, privileged. */
+
+/* compatibility with older code */
+#define SPARC_ETH_GSET ETHTOOL_GSET
+#define SPARC_ETH_SSET ETHTOOL_SSET
+
+/* Bits in ethtool_cmd.force_mask */
+#define ETHTOOL_FORCE_ADVERTISED (1 << 0)
+#define ETHTOOL_FORCE_SPEED (1 << 1)
+#define ETHTOOL_FORCE_DUPLEX (1 << 2)
+#define ETHTOOL_FORCE_FLOWCTRL (1 << 3)
+#define ETHTOOL_FORCE_PORT (1 << 4)
+#define ETHTOOL_FORCE_XCVR (1 << 5)
+#define ETHTOOL_FORCE_AUTONEG (1 << 6)
+#define ETHTOOL_FORCE_MAXTXPKT (1 << 7)
+#define ETHTOOL_FORCE_MAXRXPKT (1 << 8)
+
+/* Indicates what features are supported by the interface. */
+#define SUPPORTED_10baseT_Half (1 << 0)
+#define SUPPORTED_10baseT_Full (1 << 1)
+#define SUPPORTED_100baseT_Half (1 << 2)
+#define SUPPORTED_100baseT_Full (1 << 3)
+#define SUPPORTED_1000baseT_Half (1 << 4)
+#define SUPPORTED_1000baseT_Full (1 << 5)
+#define SUPPORTED_Autoneg (1 << 6)
+#define SUPPORTED_TP (1 << 7)
+#define SUPPORTED_AUI (1 << 8)
+#define SUPPORTED_MII (1 << 9)
+#define SUPPORTED_FIBRE (1 << 10)
+#define SUPPORTED_MAC_FLOWCTRL (1 << 11)
+
+/* Indicates what features are advertised by the interface. */
+#define ADVERTISED_10baseT_Half (1 << 0)
+#define ADVERTISED_10baseT_Full (1 << 1)
+#define ADVERTISED_100baseT_Half (1 << 2)
+#define ADVERTISED_100baseT_Full (1 << 3)
+#define ADVERTISED_1000baseT_Half (1 << 4)
+#define ADVERTISED_1000baseT_Full (1 << 5)
+#define ADVERTISED_Autoneg (1 << 6)
+#define ADVERTISED_TP (1 << 7)
+#define ADVERTISED_AUI (1 << 8)
+#define ADVERTISED_MII (1 << 9)
+#define ADVERTISED_FIBRE (1 << 10)
+#define ADVERTISED_MAC_FLOWCTRL (1 << 11)
+
+/* The following are all involved in forcing a particular link
+ * mode for the device for setting things. When getting the
+ * devices settings, these indicate the current mode and whether
+ * it was foced up into this mode or autonegotiated.
+ */
+
+/* The forced speed, 10Mb, 100Mb, gigabit. */
+#define SPEED_10 10
+#define SPEED_100 100
+#define SPEED_1000 1000
+
+/* Duplex, half or full. */
+#define DUPLEX_HALF 0x00
+#define DUPLEX_FULL 0x01
+
+/* 802.3x flow control: on or off */
+#define FLOWCTRL_OFF 0x00
+#define FLOWCTRL_ON 0x01
+
+/* Which connector port. */
+#define PORT_TP 0x00
+#define PORT_AUI 0x01
+#define PORT_MII 0x02
+#define PORT_FIBRE 0x03
+
+/* Which tranceiver to use. */
+#define XCVR_INTERNAL 0x00
+#define XCVR_EXTERNAL 0x01
+#define XCVR_DUMMY1 0x02
+#define XCVR_DUMMY2 0x03
+#define XCVR_DUMMY3 0x04
+
+/* Enable or disable autonegotiation. If this is set to enable,
+ * the forced link modes above are completely ignored.
+ */
+#define AUTONEG_DISABLE 0x00
+#define AUTONEG_ENABLE 0x01
+
+#endif /* _LINUX_ETHTOOL_H */
--- linux-2.4.0-test9-pre4/drivers/net/sunhme.c Sat Sep 9 16:19:26 2000
+++ linux-akpm/drivers/net/sunhme.c Tue Sep 19 22:23:56 2000
@@ -24,6 +24,7 @@
#include <linux/string.h>
#include <linux/delay.h>
#include <linux/init.h>
+#include <linux/ethtool.h>
#include <asm/system.h>
#include <asm/bitops.h>
#include <asm/io.h>
@@ -41,7 +42,6 @@
#ifndef __sparc_v9__
#include <asm/io-unit.h>
#endif
-#include <asm/ethtool.h>
#include <asm/uaccess.h>

#include <linux/netdevice.h>
--- linux-2.4.0-test9-pre4/include/asm-sparc/ethtool.h Tue Feb 1 18:37:19 2000
+++ linux-akpm/include/asm-sparc/ethtool.h Thu Jan 1 10:00:00 1970
@@ -1,79 +0,0 @@
-/* $Id: ethtool.h,v 1.2 2000/01/31 04:59:17 davem Exp $
- * ethtool.h: Defines for SparcLinux ethtool.
- *
- * Copyright (C) 1998 David S. Miller (davem@redhat.com)
- */
-
-#ifndef _SPARC_ETHTOOL_H
-#define _SPARC_ETHTOOL_H
-
-/* We do things like this so it does not matter what kernel
- * headers you have on your system etc.
- */
-#undef SIOCETHTOOL
-#define SIOCETHTOOL (SIOCDEVPRIVATE + 0x0f)
-
-/* This should work for both 32 and 64 bit userland. */
-struct ethtool_cmd {
- u32 cmd;
- u32 supported;
- u16 speed;
- u8 duplex;
- u8 port;
- u8 phy_address;
- u8 transceiver;
- u8 autoneg;
-};
-
-/* CMDs currently supported */
-#define SPARC_ETH_GSET 0x00000001 /* Get settings, non-privileged. */
-#define SPARC_ETH_SSET 0x00000002 /* Set settings, privileged. */
-
-/* Indicates what features are supported by the interface. */
-#define SUPPORTED_10baseT_Half 0x00000001
-#define SUPPORTED_10baseT_Full 0x00000002
-#define SUPPORTED_100baseT_Half 0x00000004
-#define SUPPORTED_100baseT_Full 0x00000008
-#define SUPPORTED_1000baseT_Half 0x00000010
-#define SUPPORTED_1000baseT_Full 0x00000020
-#define SUPPORTED_Autoneg 0x00000040
-#define SUPPORTED_TP 0x00000080
-#define SUPPORTED_AUI 0x00000100
-#define SUPPORTED_MII 0x00000200
-#define SUPPORTED_FIBRE 0x00000400
-
-/* The following are all involved in forcing a particular link
- * mode for the device for setting things. When getting the
- * devices settings, these indicate the current mode and whether
- * it was foced up into this mode or autonegotiated.
- */
-
-/* The forced speec, 10Mb, 100Mb, gigabit. */
-#define SPEED_10 10
-#define SPEED_100 100
-#define SPEED_1000 1000
-
-/* Duplex, half or full. */
-#define DUPLEX_HALF 0x00
-#define DUPLEX_FULL 0x01
-
-/* Which connector port. */
-#define PORT_TP 0x00
-#define PORT_AUI 0x01
-#define PORT_MII 0x02
-#define PORT_FIBRE 0x03
-
-/* Which tranceiver to use. */
-#define XCVR_INTERNAL 0x00
-#define XCVR_EXTERNAL 0x01
-#define XCVR_DUMMY1 0x02
-#define XCVR_DUMMY2 0x03
-#define XCVR_DUMMY3 0x04
-
-/* Enable or disable autonegotiation. If this is set to enable,
- * the forced link modes above are completely ignored.
- */
-#define AUTONEG_DISABLE 0x00
-#define AUTONEG_ENABLE 0x01
-
-#endif /* _SPARC_ETHTOOL_H */
--- linux-2.4.0-test9-pre4/include/asm-sparc64/ethtool.h Tue Feb 1 18:37:19 2000
+++ linux-akpm/include/asm-sparc64/ethtool.h Thu Jan 1 10:00:00 1970
@@ -1,79 +0,0 @@
-/* $Id: ethtool.h,v 1.2 2000/01/31 04:59:19 davem Exp $
- * ethtool.h: Defines for SparcLinux ethtool.
- *
- * Copyright (C) 1998 David S. Miller (davem@redhat.com)
- */
-
-#ifndef _SPARC64_ETHTOOL_H
-#define _SPARC64_ETHTOOL_H
-
-/* We do things like this so it does not matter what kernel
- * headers you have on your system etc.
- */
-#undef SIOCETHTOOL
-#define SIOCETHTOOL (SIOCDEVPRIVATE + 0x0f)
-
-/* This should work for both 32 and 64 bit userland. */
-struct ethtool_cmd {
- u32 cmd;
- u32 supported;
- u16 speed;
- u8 duplex;
- u8 port;
- u8 phy_address;
- u8 transceiver;
- u8 autoneg;
-};
-
-/* CMDs currently supported */
-#define SPARC_ETH_GSET 0x00000001 /* Get settings, non-privileged. */
-#define SPARC_ETH_SSET 0x00000002 /* Set settings, privileged. */
-
-/* Indicates what features are supported by the interface. */
-#define SUPPORTED_10baseT_Half 0x00000001
-#define SUPPORTED_10baseT_Full 0x00000002
-#define SUPPORTED_100baseT_Half 0x00000004
-#define SUPPORTED_100baseT_Full 0x00000008
-#define SUPPORTED_1000baseT_Half 0x00000010
-#define SUPPORTED_1000baseT_Full 0x00000020
-#define SUPPORTED_Autoneg 0x00000040
-#define SUPPORTED_TP 0x00000080
-#define SUPPORTED_AUI 0x00000100
-#define SUPPORTED_MII 0x00000200
-#define SUPPORTED_FIBRE 0x00000400
-
-/* The following are all involved in forcing a particular link
- * mode for the device for setting things. When getting the
- * devices settings, these indicate the current mode and whether
- * it was foced up into this mode or autonegotiated.
- */
-
-/* The forced speec, 10Mb, 100Mb, gigabit. */
-#define SPEED_10 10
-#define SPEED_100 100
-#define SPEED_1000 1000
-
-/* Duplex, half or full. */
-#define DUPLEX_HALF 0x00
-#define DUPLEX_FULL 0x01
-
-/* Which connector port. */
-#define PORT_TP 0x00
-#define PORT_AUI 0x01
-#define PORT_MII 0x02
-#define PORT_FIBRE 0x03
-
-/* Which tranceiver to use. */
-#define XCVR_INTERNAL 0x00
-#define XCVR_EXTERNAL 0x01
-#define XCVR_DUMMY1 0x02
-#define XCVR_DUMMY2 0x03
-#define XCVR_DUMMY3 0x04
-
-/* Enable or disable autonegotiation. If this is set to enable,
- * the forced link modes above are completely ignored.
- */
-#define AUTONEG_DISABLE 0x00
-#define AUTONEG_ENABLE 0x01
-
-#endif /* _SPARC64_ETHTOOL_H */
--- linux-2.4.0-test9-pre4/include/linux/sockios.h Sun Jan 23 06:54:57 2000
+++ linux-akpm/include/linux/sockios.h Tue Sep 19 22:23:56 2000
@@ -71,7 +71,7 @@

#define SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */
#define SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */
-
+#define SIOCETHTOOL 0x8944 /* Ethtool interface */

/* ARP cache control calls. */
/* 0x8950 - 0x8952 * obsolete calls, don't re-use */
\
 
 \ /
  Last update: 2005-03-22 12:39    [W:0.054 / U:3.284 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site