Vlan-support backporting to 4.14


(Frank W.) #1

Hi, can anyone help me backporting the vlan-driver to 4.14? the official patch needs structures that are available first in 4.15…as i see there has been much changed in dsa-driver backend.

I did as far as i can,but colliding now in modified function get_tag_protocol which has now an additional param and seems to be called via a callback-struct.

https://github.com/frank-w/BPI-R2-4.14/tree/vlan_414?files=1

In build.log you see my error-messages

There is a branch vlan_support,which has 4.15 as base and compiles fine to compare how it should be working.


What´s the best Practice to Build own Kernel
(Frank W.) #2

anyone have more knowledge than me for porting that? dsa-driver (net/dsa/dsa2.c) has massive changes between 4.14 and 4.15, most functions from 4.14 does not exist in 4.15 and vice versa

e.g.

net/dsa/dsa2.c: In function 'dsa_cpu_parse':
net/dsa/dsa2.c:519:2: error: too few arguments to function 'ds->ops->get_tag_protocol'
  tag_protocol = ds->ops->get_tag_protocol(ds);
  ^

does not exist in 4.14

dsa2.zip (15,0 KB)


(dorabmon) #3

try to apply below two patches only to your 4.14 bpi-r2 tree and see what conflict happens. and don’t change other code.

https://patchwork.kernel.org/patch/10113837/

https://patchwork.kernel.org/patch/10113841/


(Frank W.) #4

that have same problem, using dsa_is_user_port, which depend on Flag DSA_PORT_TYPE_USER (can be added, but must also be set somethere in dsa2)

there must be one patch before, that adds the

struct dsa_port {
...
  enum {
		DSA_PORT_TYPE_UNUSED = 0,
		DSA_PORT_TYPE_CPU,
		DSA_PORT_TYPE_DSA,
		DSA_PORT_TYPE_USER,
  } type;
...
}

to https://github.com/torvalds/linux/blob/master/include/net/dsa.h and its depencies


(dorabmon) #5

please reverse to the points dsa_is_user_port is not being used, please check below patches

https://patchwork.kernel.org/patch/10028515/


(Frank W.) #6

i try to fix reject from second patch…then i post the build-log


(Frank W.) #7

https://github.com/frank-w/BPI-R2-4.14/tree/vlan_new

drivers/net/dsa/mt7530.c: In function 'mt7530_port_set_vlan_unaware':
drivers/net/dsa/mt7530.c:825:3: error: implicit declaration of function 'dsa_is_user_port' [-Werror=implicit-function-declaration]
   if (dsa_is_user_port(ds, i) &&
   ^
drivers/net/dsa/mt7530.c:837:9: error: implicit declaration of function 'dsa_user_ports' [-Werror=implicit-function-declaration]
         PCR_MATRIX(dsa_user_ports(priv->ds)));
         ^
drivers/net/dsa/mt7530.c: In function 'mt7530_port_bridge_leave':
drivers/net/dsa/mt7530.c:888:4: error: implicit declaration of function 'dsa_to_port' [-Werror=implicit-function-declaration]
    if (dsa_to_port(ds, i)->bridge_dev != bridge)
    ^
drivers/net/dsa/mt7530.c:888:26: error: invalid type argument of '->' (have 'int')
    if (dsa_to_port(ds, i)->bridge_dev != bridge)
                          ^
drivers/net/dsa/mt7530.c: At top level:
drivers/net/dsa/mt7530.c:1321:2: warning: initialization from incompatible pointer type [enabled by default]
  .port_vlan_prepare = mt7530_port_vlan_prepare,
  ^
drivers/net/dsa/mt7530.c:1321:2: warning: (near initialization for 'mt7530_switch_ops.port_vlan_prepare') [enabled by default]
drivers/net/dsa/mt7530.c:1322:2: warning: initialization from incompatible pointer type [enabled by default]
  .port_vlan_add  = mt7530_port_vlan_add,
  ^
drivers/net/dsa/mt7530.c:1322:2: warning: (near initialization for 'mt7530_switch_ops.port_vlan_add') [enabled by default]

(Frank W.) #8

got my vlan_4.14 branch compiled by fixing the get_tag_protocol-errors…if i not miss anything vlan should be now included in that branch…

maybe someone will test it?


(xbgmsharp) #9
  CC      drivers/net/dsa/mt7530.o
drivers/net/dsa/mt7530.c: In function 'mt7530_port_vlan_add':
drivers/net/dsa/mt7530.c:1142:6: warning: unused variable 'ret' [-Wunused-variable]
  int ret;
      ^~~

(Frank W.) #10

have you used the branch vlan_414 or vlan_414_new?

as you see in my build.log (github) i’ve did not get this error

compile goes through…but that function is “static void” so ret can be simply commented out

more critical is this:

net/dsa/dsa2.c:649:12: warning: 'dsa_port_parse_of' defined but not used [-Wunused-function]
 static int dsa_port_parse_of(struct dsa_port *dp, struct device_node *dn)

because here is the port classified as user/cpu/…that should be called…


(xbgmsharp) #11

I used vlan_414 and it seem to work. i can create a VLAN without error.

# uname -a
Linux bpi-r2 4.14.10-00042-g2fe7d48c1c64-dirty #4 SMP Fri Jan 5 16:34:11 CET 2018 armv7l GNU/Linux

(Frank W.) #12

added the missing function call and some vlan-options, which maybe needed

can you try again and look if vlan is really set (managed switch or another device with vlan-support)


(xbgmsharp) #13

it is my internet connexion will try later.


(Frank W.) #14

@linkerosa, can you take a look, if i had ported all necessary functions (branch vlan_414 vs. vlan_support) the right way?


(xbgmsharp) #15

Good news it is working on 4.14 kernel. I was able to create a vlan and connect using pppoe to ISP.

# uname -a
Linux bpi-r2 4.14.11-00041-g8d9a66bcc677 #6 SMP Fri Jan 5 19:30:01 CET 2018 armv7l GNU/Linux

dmesg

[44764.006518] mt7530 mdio-bus:00 wan: Link is Up - 1Gbps/Full - flow control off
[44770.132756] PPP generic driver version 2.4.2
[44799.722802] NET: Registered protocol family 24

Link in 1G/Full

# ethtool wan
Settings for wan:
	Supported ports: [ TP AUI BNC MII FIBRE ]
	Supported link modes:   10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	Supported pause frame use: Symmetric Receive-only
	Supports auto-negotiation: Yes
	Advertised link modes:  10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	Advertised pause frame use: No
	Advertised auto-negotiation: Yes
	Link partner advertised link modes:  10baseT/Half 10baseT/Full 
	                                     100baseT/Half 100baseT/Full 
	                                     1000baseT/Full 
	Link partner advertised pause frame use: No
	Link partner advertised auto-negotiation: Yes
	Speed: 1000Mb/s
	Duplex: Full
	Port: MII
	PHYAD: 0
	Transceiver: internal
	Auto-negotiation: on
	Supports Wake-on: d
	Wake-on: d
	Link detected: yes

(Frank W.) #16

vlan creation in OS is one function,real tagging the other…

is it also tagged in ethernet-frame?

OS<>HW/dsa-Support


(xbgmsharp) #17

Yes the frame are tag.


(Frank W.) #18

is there anywhere an overview, which dsa-function is renamed to which function

currently i used a simple diff like that: https://fossies.org/diffs/linux/4.14.2_vs_4.15-rc1/net/dsa/dsa2.c-diff.html

but for some functions it does not show simple renamings because there are additional functions or function is moved to another position…it is hard to patch right function if name has changed :stuck_out_tongue:


(Frank W.) #19

seems that porting is not needed…i can define vlans via software with main-branch:

auto lan3
iface lan3 inet static
  pre-up ip link set $IFACE address 02:01:02:03:04:03 up

auto lan3.60
iface lan3.60 inet static
  address 192.168.60.10
  netmask 255.255.255.0

root@bpi-r2:~# ping 192.168.60.1
PING 192.168.60.1 (192.168.60.1) 56(84) bytes of data.
64 bytes from 192.168.60.1: icmp_seq=1 ttl=64 time=0.712 ms
64 bytes from 192.168.60.1: icmp_seq=2 ttl=64 time=0.653 ms
64 bytes from 192.168.60.1: icmp_seq=3 ttl=64 time=0.619 ms
^C
--- 192.168.60.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2104ms
rtt min/avg/max/mdev = 0.619/0.661/0.712/0.043 ms

on lan3 is a rpi directly connected with similar config (vlan60 and ip 192.168.60.1 which i ping from bpi-r2), port on rpi is mixed mode (untagged in subnet 192.168.0.x+tagged on vlan60

pi@raspberrypi:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 
1000
    link/ether b8:27:eb:5f:b8:a2 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.6/24 brd 192.168.0.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 169.254.141.212/16 brd 169.254.255.255 scope global eth0
       valid_lft forever preferred_lft forever
3: eth0.60@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
qlen 1000
    link/ether b8:27:eb:5f:b8:a2 brd ff:ff:ff:ff:ff:ff
    inet 192.168.60.1/24 brd 192.168.60.255 scope global eth0.60
       valid_lft forever preferred_lft forever

seems to work without any additions patches…


Clone MAC in LEDE