Networking Forums

Networking Forums > Computer Networking > Linux Networking > switch chip driver

Reply
Thread Tools Display Modes

switch chip driver

 
 
Mark
Guest
Posts: n/a

 
      06-23-2010, 03:39 AM
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

 
Reply With Quote
 
 
 
 
Pascal Hambourg
Guest
Posts: n/a

 
      06-23-2010, 09:10 AM
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.
 
Reply With Quote
 
Mark
Guest
Posts: n/a

 
      06-24-2010, 01:44 AM
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...ource/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

 
Reply With Quote
 
Mark
Guest
Posts: n/a

 
      06-24-2010, 02:35 AM
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

 
Reply With Quote
 
Mark
Guest
Posts: n/a

 
      06-24-2010, 06:09 AM
David Schwartz wrote:
> I thought you wanted to present them as five separate interfaces. If
> you do that, how can you also have the hardware switch packets between
> them?



As I wrote earlier to Pascal in this thread, I will basically have 2
internal ports connected to external 24-port switch, and I need these two
ports configured as WAN and LAN interfaces. I thought the easiest way would
be have the seperate interfaces.

Hm.. now I'm very confused.

> If you think that just having two operational interfaces with no
> addresses assigned to them implements some kind of switching or
> bridging, you are mistaken.

I don't really understand this point -- if a packet enters the switch,
before it gets any network interface (eth0..eth4) it is supposed to be
already hardware switched, unless the switch is configured to forward all
frames to the CPU port (in this case it will be processed by the network
driver).

> Perhaps I'm misunderstanding you, but it sounds like you don't really
> understand the basics about specifically what a network interface
> driver does.

That's why I'm here, asking the questions.

--
Mark

 
Reply With Quote
 
Mark
Guest
Posts: n/a

 
      06-24-2010, 06:53 AM
David Schwartz wrote:
[skip]
> Perhaps I'm misunderstanding you, but it sounds like you don't really
> understand the basics about specifically what a network interface
> driver does.


Allright, let's reason about this once again. Suupose we have 5 distinct
network interfaces, eth0 is for switch port 0, eth1 - port 1 and so on. Now,
a frame enters the port 0, the driver picks the frame off the switch and
pushes it up the network stack, so in this case all switching/tagging is
done in driver or in higher OS layer.

Am I right, is that what you meant ?

On the other hand -- consider the 5-port switch and the driver representing
single interface to OS (that single interface is the one connecting the
switch to CPU), that's how it's implemented now. Any frame entering the
switch port is hardware switched and if necessary (depending on the switch
configuration) is also forwarded to the CPU port and will be accepted by the
driver and moved, if necessary, up the tcp/ip stack.

--
Mark

 
Reply With Quote
 
David Brown
Guest
Posts: n/a

 
      06-24-2010, 07:17 AM
On 24/06/2010 08:09, Mark wrote:
> David Schwartz wrote:
>> I thought you wanted to present them as five separate interfaces. If
>> you do that, how can you also have the hardware switch packets between
>> them?

>
>
> As I wrote earlier to Pascal in this thread, I will basically have 2
> internal ports connected to external 24-port switch, and I need these
> two ports configured as WAN and LAN interfaces. I thought the easiest
> way would be have the seperate interfaces.
>


This will work fine. I think perhaps David missed the other post where
you mentioned the external 24-port switches.

Most small or medium routers work in this way, using VLAN tags to get
multiple virtual Ethernet devices from the managed switch. The
disadvantage is, as David says, that you can't then pass VLAN tagged
packets through the router. But that's okay - if you have such a large
and advanced network that you are wanting to pass VLAN tagged packets
here then you would probably have faster and more advanced hardware anyway.

I haven't used these Broadcom devices on their own, but I use LinkSys
routers with similar devices and OpenWRT firmware. Using the VLAN
tagging on the built-in switch gives you enormous flexibility - far more
than you get with the original firmware.

If you can't make use of the switch driver code from tomoyo, you could
look at openwrt and see if you can use the code from there (although I
believe the two projects have a common ancestor, so the code there may
be the same).

> Hm.. now I'm very confused.
>
>> If you think that just having two operational interfaces with no
>> addresses assigned to them implements some kind of switching or
>> bridging, you are mistaken.

> I don't really understand this point -- if a packet enters the switch,
> before it gets any network interface (eth0..eth4) it is supposed to be
> already hardware switched, unless the switch is configured to forward
> all frames to the CPU port (in this case it will be processed by the
> network driver).
>


The external switches will handle switching within their local network.
Packets aimed off the network will be passed on to your device
(assuming you have the routing and addresses configured correctly). But
your two virtual ports eth0.1 and eth0.2 on your device need an ip
address so that machines on the network can pass packets to them for
forwarding.

It /is/ possible to set up your device as a bridge between eth0.1 and
eth0.2 rather than a router, with no IP addresses on the ports, but
unless you are doing something really advanced (such as using ebtables
to control the bridge), a patch wire between the two 24-port switches
would be more efficient.

>> Perhaps I'm misunderstanding you, but it sounds like you don't really
>> understand the basics about specifically what a network interface
>> driver does.

> That's why I'm here, asking the questions.
>


 
Reply With Quote
 
Pascal Hambourg
Guest
Posts: n/a

 
      06-24-2010, 11:23 AM
David Schwartz a écrit :
> Let's try it again, from a simpler point of view.
>
> Suppose the switch receives two broadcast packets on port 1, one
> tagged VLAN 10 (call this '1,10') and one tagged VLAN 11 (call this
> '1,11'). Then the switch receives two broadcast packets on port 2, one
> tagged VLAN 10 (call this '2,10') and one tagged VLAN 11 (call this
> '2,11').
>
> I presume your intention would be packets 1,10 and 1,11 would come out
> logical interface 1, tagged with VLANs 10 and 11 respectively. And
> packets 2,10 and 2,11 would come out logical interface 2, tagged with
> VLANs 10 and 11 respectively.
>
> Is that a correct description of the effect you want?


I didn't read any need for external VLAN tagging in Mark's posts.

> Now, how can you get it?
>
> Suppose you configure physical ports to ignore incoming VLAN tags.
> Now, you can't tell packets 1,10 and 1,11 apart. So you have no way to
> tag them correctly when you pass them to the operating system.


What do you mean by "ignore" ? Replace the incoming VLAN ID with the one
associated to the port ?
 
Reply With Quote
 
Pascal Hambourg
Guest
Posts: n/a

 
      06-24-2010, 11:29 AM
Mark a écrit :
>
> What I have is bcm5358u - Broadcom's SoC containing MIPS core, 5-port switch
> core connected to the CPU via internal MII.

[...]
> 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.


Doesn't that current setup meet this need ? You can assign one VLAN
group as WAN and the other one as LAN, using either port of each group
to connect to the switch. You just need is to create and use the VLAN
subinterfaces for the two VLAN IDs in Linux. Ok, they won't be named
eth0 and eth1 but eth0.<vlan_id1> and eth0.<vlan_id2>.
 
Reply With Quote
 
David Brown
Guest
Posts: n/a

 
      06-24-2010, 01:43 PM
On 24/06/2010 03:44, Mark wrote:
> 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...ource/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, could you give us a more precise picture of your setup here?

As I see it, you have an external 24-port switch. Is this a managed
switch (that can assign VLAN tags according to port)? If it is not a
managed switch, then I can't see why you want to connect both ports on
your broadcom device to the switch. If it /is/ a managed switch, then
everything you are trying to do with the broadcom device can be handled
more easily using the managed switch.

I have been under the assumption that you have one port of the broadcom
device switch connected to your WAN network (such as an ADSL modem),
while another port is connected to an unmanaged external switch for a LAN.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Which chip is best? Bin Chen Wireless Internet 0 08-06-2007 05:02 AM
chip tuning chip tuning Broadband Hardware 0 06-10-2004 02:24 PM
chip tuning chip tuning Broadband Hardware 0 06-10-2004 12:11 AM
802.11b (prism 2.0 chip) & mandrake 9.0...?????? Forrest McKerchar Linux Networking 2 07-31-2003 09:33 AM
SMC 7404WBRA chip SD Wireless Internet 0 06-28-2003 11:02 AM



1 2 3 4 5 6 7 8 9 10 11