freebsd-skq/sys/dev/etherswitch/etherswitch_if.m

222 lines
3.1 KiB
Mathematica
Raw Normal View History

Commit the first pass of the etherswitch support. This is designed to support the very basic ethernet switch chip behaviour, specifically: * accessing switch register space; * accessing per-PHY registers (for switches that actually expose PHYs); * basic vlan group support, which applies for the rtl8366 driver but not for the atheros switches. This also includes initial support for: * rtl8366rb support - which is a 10/100/1000 switch which supports vlan groups; * Initial Atheros AR8316 switch support - which is a 10/100/1000 switch which supports an alternate vlan configuration (so the vlan group methods are stubbed.) The general idea here is that the switch driver may speak to a variety of backend busses (mdio, i2c, spi, whatever) and expose: * If applicable, one or more MDIO busses which ethernet interfaces can then attach PHYs to via miiproxy/mdioproxy; * exposes miibusses, one for each port at the moment, so .. * .. a PHY can be exposed on each miibus, for each switch port, with all of the existing MII/ifnet framework. However: * The ifnet is manually created for now, and it isn't linked into the interface list, nor can you (currently) send/receive frames on this ifnet. At some point in the future there may be _some_ support for this, for switches with a multi-port, isolated mode. * I'm still in the process of sorting out correct(er) locking. TODO: * ray's switch code in zrouter (zrouter.org) includes a much more developed newbus API that covers the various switch methods, as well as a capability API so drivers, the switch layer and the userland utility can properly control the subset of supported features. The plan is to sort that out later, once the rest of ray's switch drivers are brought over and extended to export MII busses and PHYs. Submitted by: Stefan Bethke <stb@lassitu.de> Reviewed by: ray
2012-05-11 20:53:20 +00:00
# $FreeBSD$
#include <sys/bus.h>
# Needed for ifreq/ifmediareq
#include <sys/socket.h>
#include <net/if.h>
#include <dev/etherswitch/etherswitch.h>
INTERFACE etherswitch;
#
# Default implementation
#
CODE {
static void
null_etherswitch_lock(device_t dev)
{
}
static void
null_etherswitch_unlock(device_t dev)
{
}
static int
null_etherswitch_getconf(device_t dev, etherswitch_conf_t *conf)
{
return (0);
}
static int
null_etherswitch_setconf(device_t dev, etherswitch_conf_t *conf)
{
return (0);
}
static int
null_etherswitch_flush_all(device_t dev)
{
return (ENXIO);
}
static int
null_etherswitch_flush_port(device_t dev, int port)
{
return (ENXIO);
}
static int
null_etherswitch_flush_mac(device_t dev,
etherswitch_atu_flush_macentry_t *e)
{
return (ENXIO);
}
static int
null_etherswitch_fetch_table(device_t dev,
etherswitch_atu_table_t *table)
{
table->es_nitems = 0;
return (ENXIO);
}
static int
null_etherswitch_fetch_entry(device_t dev,
etherswitch_atu_entry_t *e)
{
return (ENXIO);
}
};
Commit the first pass of the etherswitch support. This is designed to support the very basic ethernet switch chip behaviour, specifically: * accessing switch register space; * accessing per-PHY registers (for switches that actually expose PHYs); * basic vlan group support, which applies for the rtl8366 driver but not for the atheros switches. This also includes initial support for: * rtl8366rb support - which is a 10/100/1000 switch which supports vlan groups; * Initial Atheros AR8316 switch support - which is a 10/100/1000 switch which supports an alternate vlan configuration (so the vlan group methods are stubbed.) The general idea here is that the switch driver may speak to a variety of backend busses (mdio, i2c, spi, whatever) and expose: * If applicable, one or more MDIO busses which ethernet interfaces can then attach PHYs to via miiproxy/mdioproxy; * exposes miibusses, one for each port at the moment, so .. * .. a PHY can be exposed on each miibus, for each switch port, with all of the existing MII/ifnet framework. However: * The ifnet is manually created for now, and it isn't linked into the interface list, nor can you (currently) send/receive frames on this ifnet. At some point in the future there may be _some_ support for this, for switches with a multi-port, isolated mode. * I'm still in the process of sorting out correct(er) locking. TODO: * ray's switch code in zrouter (zrouter.org) includes a much more developed newbus API that covers the various switch methods, as well as a capability API so drivers, the switch layer and the userland utility can properly control the subset of supported features. The plan is to sort that out later, once the rest of ray's switch drivers are brought over and extended to export MII busses and PHYs. Submitted by: Stefan Bethke <stb@lassitu.de> Reviewed by: ray
2012-05-11 20:53:20 +00:00
#
# Return device info
#
METHOD etherswitch_info_t* getinfo {
device_t dev;
}
#
# Lock access to switch registers
#
METHOD void lock {
device_t dev;
} DEFAULT null_etherswitch_lock;
#
# Unlock access to switch registers
#
METHOD void unlock {
device_t dev;
} DEFAULT null_etherswitch_unlock;
Commit the first pass of the etherswitch support. This is designed to support the very basic ethernet switch chip behaviour, specifically: * accessing switch register space; * accessing per-PHY registers (for switches that actually expose PHYs); * basic vlan group support, which applies for the rtl8366 driver but not for the atheros switches. This also includes initial support for: * rtl8366rb support - which is a 10/100/1000 switch which supports vlan groups; * Initial Atheros AR8316 switch support - which is a 10/100/1000 switch which supports an alternate vlan configuration (so the vlan group methods are stubbed.) The general idea here is that the switch driver may speak to a variety of backend busses (mdio, i2c, spi, whatever) and expose: * If applicable, one or more MDIO busses which ethernet interfaces can then attach PHYs to via miiproxy/mdioproxy; * exposes miibusses, one for each port at the moment, so .. * .. a PHY can be exposed on each miibus, for each switch port, with all of the existing MII/ifnet framework. However: * The ifnet is manually created for now, and it isn't linked into the interface list, nor can you (currently) send/receive frames on this ifnet. At some point in the future there may be _some_ support for this, for switches with a multi-port, isolated mode. * I'm still in the process of sorting out correct(er) locking. TODO: * ray's switch code in zrouter (zrouter.org) includes a much more developed newbus API that covers the various switch methods, as well as a capability API so drivers, the switch layer and the userland utility can properly control the subset of supported features. The plan is to sort that out later, once the rest of ray's switch drivers are brought over and extended to export MII busses and PHYs. Submitted by: Stefan Bethke <stb@lassitu.de> Reviewed by: ray
2012-05-11 20:53:20 +00:00
#
# Read switch register
#
METHOD int readreg {
device_t dev;
int reg;
};
#
# Write switch register
#
METHOD int writereg {
device_t dev;
int reg;
int value;
};
#
# Read PHY register
#
METHOD int readphyreg {
device_t dev;
int phy;
int reg;
};
#
# Write PHY register
#
METHOD int writephyreg {
device_t dev;
int phy;
int reg;
int value;
};
#
# Get port configuration
#
METHOD int getport {
device_t dev;
etherswitch_port_t *vg;
}
#
# Set port configuration
#
METHOD int setport {
device_t dev;
etherswitch_port_t *vg;
}
#
# Get VLAN group configuration
#
METHOD int getvgroup {
device_t dev;
etherswitch_vlangroup_t *vg;
}
#
# Set VLAN group configuration
#
METHOD int setvgroup {
device_t dev;
etherswitch_vlangroup_t *vg;
}
#
# Get the Switch configuration
#
METHOD int getconf {
device_t dev;
etherswitch_conf_t *conf;
} DEFAULT null_etherswitch_getconf;
#
# Set the Switch configuration
#
METHOD int setconf {
device_t dev;
etherswitch_conf_t *conf;
} DEFAULT null_etherswitch_setconf;
#
# Flush all of the programmed/learnt MAC addresses
#
METHOD int flush_all {
device_t dev;
} DEFAULT null_etherswitch_flush_all;
#
# Flush a single MAC address entry
#
METHOD int flush_mac {
device_t dev;
etherswitch_atu_flush_macentry_t *entry;
} DEFAULT null_etherswitch_flush_mac;
#
# Flush all of the dynamic MAC addresses on a given port
#
METHOD int flush_port {
device_t dev;
int port;
} DEFAULT null_etherswitch_flush_port;
#
# Fetch the address table from the ethernet switch.
#
METHOD int fetch_table {
device_t dev;
etherswitch_atu_table_t *table;
} DEFAULT null_etherswitch_fetch_table;
#
# Fetch a single entry from the ethernet switch table.
#
METHOD int fetch_table_entry {
device_t dev;
etherswitch_atu_entry_t *entry;
} DEFAULT null_etherswitch_fetch_entry;