From: Mark on
Hello,

I have a driver for 5-port switch, representing the switch as one eth0
device from the OS perspective. I would like to make it have eth0..eth4
ports respectively, so that I could treat each port individually.

As far as I understand, the kernel network machinery for Ethernet works like
this:

struct net_device *dev;
alloc_netdev(sizeof(private_structure), "eth%d", ether_setup);
....
register_netdev(dev);
....

Am I right that I have to implement this sequence for each interface I
register in the system's data structures? So for the 5-port switch it'd be
something like:

int switch_init(int unit)
{
struct net_device *dev;
alloc_netdev(sizeof(private_structure), "eth", ether_setup);
sprintf(dev->name, "eth", unit);
...
register_netdev(dev);
}

... or the whole thing is a way more complicated than I think?

Thanks.

--
Mark

From: Pascal Hambourg on
Hello,

Mark a �crit :
>
> I have a driver for 5-port switch, representing the switch as one eth0
> device from the OS perspective. I would like to make it have eth0..eth4
> ports respectively, so that I could treat each port individually.

What kind of switch chip is it ?

If it is a "software" switch (i.e. 4 independent physical ethernet
interfaces and one internal virtual interface being eth0, frame
switching being done by the software driver like a software bridge),
then it may be possible to rewrite the driver in order to use the
physical devices as separate devices.

However if it is a hardware switch (the device eth0 being the internal
connection to the switch) just like an external switch then this is not
possible unless it supports VLANs : then you could create one VLAN per
physical port and create VLAN tagged subinterfaces on the internal
interface eth0. This way each physical port would be associated to a
VLAN subinterface.
From: David Schwartz on
On Jun 22, 8:39 pm, "Mark" <mark_cruzNOTFORS...(a)hotmail.com> wrote:

> I have a driver for 5-port switch, representing the switch as one eth0
> device from the OS perspective. I would like to make it have eth0..eth4
> ports respectively, so that I could treat each port individually.

That may be a huge mistake. Typical 5-port switches can only separate
the ports by using VLAN tagging. If your driver forces this mechanism
to be used to create separate interfaces, those interfaces will be
unable to support VLAN tagging. You will also force any switching to
be done between those ports to be done in software, negating the point
of having a 5-port switch.

DS
From: Mark on
Hello,

Pascal Hambourg wrote:
> What kind of switch chip is it ?

What I have is bcm5358u - Broadcom's SoC containing MIPS core, 5-port switch
core connected to the CPU via internal MII.

> However if it is a hardware switch (the device eth0 being the internal
> connection to the switch) just like an external switch then this is
> not possible unless it supports VLANs : then you could create one
> VLAN per physical port and create VLAN tagged subinterfaces on the
> internal interface eth0. This way each physical port would be
> associated to a VLAN subinterface.

I think I should've given more details in my original message.

bcm5358's ethernet driver supports VLANs and currently it seperates these 5
ports in two VLAN groups. Now I'm going to
use two ports of bcm5358 to connect to external 24-port switch, thus these
two ports will serve as WAN and LAN ports respectively and should be able to
have IP addresses on them. I see no other reason rather then make them look
distinct interfaces form the point of view of OS.

PS. I've skimmed through
http://tomoyo.sourceforge.jp/cgi-bin/lxr/source/net/dsa/ and it seems that
it's possible to do what I need, although the kernel ported for my platform
is older and doesn't have some features used by DSA.

--
Mark

From: Mark on
David Schwartz wrote:
> That may be a huge mistake. Typical 5-port switches can only separate
> the ports by using VLAN tagging. If your driver forces this mechanism
> to be used to create separate interfaces, those interfaces will be
> unable to support VLAN tagging. You will also force any switching to
> be done between those ports to be done in software, negating the point
> of having a 5-port switch.
>


I can't see how it would happen: I'm not disabling switching function,
neither do I disable VLAN grouping, i.e. any frame entering a switch port
would be switched in hardware according to the forwarding table. So as I
understand, as long as I don't assign IP address on those interfaces,
everything should work as before; assigning IP addresses will imply NAT on
those interfaces.

Please also see my other reply to Pascal.

--
Mark