Compile error in b53/b53_common.c multiple definition

I ran into this issue during compilation of Lede for EA9500 4.14.29

this is the error code

make[5]: Entering directory '/home/gunter/lede/build_dir/target-arm_cortex-a9_musl_eabi/linux-bcm53xx/linux-4.14.29'
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  CHK     scripts/mod/devicetable-offsets.h
  CHK     include/generated/compile.h
  GEN     .version
  CHK     include/generated/compile.h
  AR      built-in.o
  LD      vmlinux.o
drivers/net/dsa/b53/b53_common.o: In function `b53_switch_alloc':
b53_common.c:(.text+0x2028): multiple definition of `b53_switch_alloc'
drivers/net/phy/b53/b53_common.o:b53_common.c:(.text+0x68c): first defined here
drivers/net/dsa/b53/b53_common.o: In function `b53_switch_detect':
b53_common.c:(.text+0x20cc): multiple definition of `b53_switch_detect'
drivers/net/phy/b53/b53_common.o:b53_common.c:(.text+0x6e8): first defined here
drivers/net/dsa/b53/b53_common.o: In function `b53_switch_register':
b53_common.c:(.text+0x2350): multiple definition of `b53_switch_register'
drivers/net/phy/b53/b53_common.o:b53_common.c:(.text+0x190c): first defined here
Makefile:1012: recipe for target 'vmlinux' failed
make[5]: *** [vmlinux] Error 1

By checking the 2 files I see that both files

drivers/net/dsa/b53/b53_common.c

struct b53_device *b53_switch_alloc(struct device *base,
				    const struct b53_io_ops *ops,
				    void *priv)
{
	struct dsa_switch *ds;
	struct b53_device *dev;

	ds = dsa_switch_alloc(base, DSA_MAX_PORTS);
	if (!ds)
		return NULL;

	dev = devm_kzalloc(base, sizeof(*dev), GFP_KERNEL);
	if (!dev)
		return NULL;

	ds->priv = dev;
	dev->dev = base;

	dev->ds = ds;
	dev->priv = priv;
	dev->ops = ops;
	ds->ops = &b53_switch_ops;
	mutex_init(&dev->reg_mutex);
	mutex_init(&dev->stats_mutex);

	return dev;
}
EXPORT_SYMBOL(b53_switch_alloc);

int b53_switch_detect(struct b53_device *dev)
{
	u32 id32;
	u16 tmp;
	u8 id8;
	int ret;

	ret = b53_read8(dev, B53_MGMT_PAGE, B53_DEVICE_ID, &id8);
	if (ret)
		return ret;

	switch (id8) {
	case 0:
		/* BCM5325 and BCM5365 do not have this register so reads
		 * return 0. But the read operation did succeed, so assume this
		 * is one of them.
		 *
		 * Next check if we can write to the 5325's VTA register; for
		 * 5365 it is read only.
		 */
		b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_TABLE_ACCESS_25, 0xf);
		b53_read16(dev, B53_VLAN_PAGE, B53_VLAN_TABLE_ACCESS_25, &tmp);

		if (tmp == 0xf)
			dev->chip_id = BCM5325_DEVICE_ID;
		else
			dev->chip_id = BCM5365_DEVICE_ID;
		break;
	case BCM5395_DEVICE_ID:
	case BCM5397_DEVICE_ID:
	case BCM5398_DEVICE_ID:
		dev->chip_id = id8;
		break;
	default:
		ret = b53_read32(dev, B53_MGMT_PAGE, B53_DEVICE_ID, &id32);
		if (ret)
			return ret;

		switch (id32) {
		case BCM53115_DEVICE_ID:
		case BCM53125_DEVICE_ID:
		case BCM53128_DEVICE_ID:
		case BCM53010_DEVICE_ID:
		case BCM53011_DEVICE_ID:
		case BCM53012_DEVICE_ID:
		case BCM53018_DEVICE_ID:
		case BCM53019_DEVICE_ID:
			dev->chip_id = id32;
			break;
		default:
			pr_err("unsupported switch detected (BCM53%02x/BCM%x)\n",
			       id8, id32);
			return -ENODEV;
		}
	}

	if (dev->chip_id == BCM5325_DEVICE_ID)
		return b53_read8(dev, B53_STAT_PAGE, B53_REV_ID_25,
				 &dev->core_rev);
	else
		return b53_read8(dev, B53_MGMT_PAGE, B53_REV_ID,
				 &dev->core_rev);
}
EXPORT_SYMBOL(b53_switch_detect);

int b53_switch_register(struct b53_device *dev)
{
	int ret;

	if (dev->pdata) {
		dev->chip_id = dev->pdata->chip_id;
		dev->enabled_ports = dev->pdata->enabled_ports;
	}

	if (!dev->chip_id && b53_switch_detect(dev))
		return -EINVAL;

	ret = b53_switch_init(dev);
	if (ret)
		return ret;

	pr_info("found switch: %s, rev %i\n", dev->name, dev->core_rev);

	return dsa_register_switch(dev->ds);
}
EXPORT_SYMBOL(b53_switch_register);

drivers/net/phy/b53/b53_common.c

struct b53_device *b53_switch_allocP(struct device *base, struct b53_io_ops *ops,
				    void *priv)
{
	struct b53_device *dev;

	dev = devm_kzalloc(base, sizeof(*dev), GFP_KERNEL);
	if (!dev)
		return NULL;

	dev->dev = base;
	dev->ops = ops;
	dev->priv = priv;
	mutex_init(&dev->reg_mutex);

	return dev;
}
EXPORT_SYMBOL(b53_switch_allocP);

int b53_switch_detect(struct b53_device *dev)
{
	u32 id32;
	u16 tmp;
	u8 id8;
	int ret;

	ret = b53_read8(dev, B53_MGMT_PAGE, B53_DEVICE_ID, &id8);
	if (ret)
		return ret;

	switch (id8) {
	case 0:
		/*
		 * BCM5325 and BCM5365 do not have this register so reads
		 * return 0. But the read operation did succeed, so assume
		 * this is one of them.
		 *
		 * Next check if we can write to the 5325's VTA register; for
		 * 5365 it is read only.
		 */

		b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_TABLE_ACCESS_25, 0xf);
		b53_read16(dev, B53_VLAN_PAGE, B53_VLAN_TABLE_ACCESS_25, &tmp);

		if (tmp == 0xf)
			dev->chip_id = BCM5325_DEVICE_ID;
		else
			dev->chip_id = BCM5365_DEVICE_ID;
		break;
	case BCM5395_DEVICE_ID:
	case BCM5397_DEVICE_ID:
	case BCM5398_DEVICE_ID:
		dev->chip_id = id8;
		break;
	default:
		ret = b53_read32(dev, B53_MGMT_PAGE, B53_DEVICE_ID, &id32);
		if (ret)
			return ret;

		switch (id32) {
		case BCM53115_DEVICE_ID:
		case BCM53125_DEVICE_ID:
		case BCM53128_DEVICE_ID:
		case BCM53010_DEVICE_ID:
		case BCM53011_DEVICE_ID:
		case BCM53012_DEVICE_ID:
		case BCM53018_DEVICE_ID:
		case BCM53019_DEVICE_ID:
			dev->chip_id = id32;
			break;
		default:
			pr_err("unsupported switch detected (BCM53%02x/BCM%x)\n",
			       id8, id32);
			return -ENODEV;
		}
	}

	if (dev->chip_id == BCM5325_DEVICE_ID)
		return b53_read8(dev, B53_STAT_PAGE, B53_REV_ID_25,
				 &dev->core_rev);
	else
		return b53_read8(dev, B53_MGMT_PAGE, B53_REV_ID,
				 &dev->core_rev);
}
EXPORT_SYMBOL(b53_switch_detect);

int b53_switch_register(struct b53_device *dev)
{
	int ret;

	if (dev->pdata) {
		dev->chip_id = dev->pdata->chip_id;
		dev->enabled_ports = dev->pdata->enabled_ports;
		dev->sw_dev.alias = dev->pdata->alias;
	}

	if (!dev->chip_id && b53_switch_detect(dev))
		return -EINVAL;

	ret = b53_switch_init(dev);
	if (ret)
		return ret;

	pr_info("found switch: %s, rev %i\n", dev->sw_dev.name, dev->core_rev);

	return register_switch(&dev->sw_dev, NULL);
}
EXPORT_SYMBOL(b53_switch_register);

declare the same definition name

b53_switch_alloc
b53_switch_detect
b53_switch_register

I assume just renaming them will not solve my issue. Should I file a bug report with this, or is this somehow something that's unique to my setup?

You seem to have both DSA and switch driver for b53 switches enabled. Both these drivers have similar set of files under different directories. Disable the switch driver, then you should be fine.

thanks now if compiled, but I don't have access to the internet.
I can connect to the router per wifi but not ethernet. luckily the wifi was still on from the old config

from serial this is ifconfig

BusyBox v1.27.2 () built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt SNAPSHOT, r6587-ac593d895a
 -----------------------------------------------------
root@EA9500:/# 
root@EA9500:/# ifconfig

br-lan    Link encap:Ethernet  HWaddr 48:F8:B3:F4:37:E1  
          inet addr:192.168.2.11  Bcast:192.168.2.255  Mask:255.255.255.0
          inet6 addr: fe80::4af8:b3ff:fef4:37e1/64 Scope:Link
          inet6 addr: fded:d2ff:1d40::1/60 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:405 errors:0 dropped:0 overruns:0 frame:0
          TX packets:495 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:63417 (61.9 KiB)  TX bytes:28643 (27.9 KiB)

br-wan    Link encap:Ethernet  HWaddr 48:F8:B3:F4:37:E1  
          inet6 addr: fe80::4af8:b3ff:fef4:37e1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:310 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:100569 (98.2 KiB)

eth0      Link encap:Ethernet  HWaddr 48:F8:B3:F4:37:E1  
          inet6 addr: fe80::4af8:b3ff:fef4:37e1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5815 errors:0 dropped:87 overruns:0 frame:0
          TX packets:1065 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1980747 (1.8 MiB)  TX bytes:185668 (181.3 KiB)
          Interrupt:23 

eth0.101  Link encap:Ethernet  HWaddr 48:F8:B3:F4:37:E1  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:748 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:80041 (78.1 KiB)

eth0.102  Link encap:Ethernet  HWaddr 48:F8:B3:F4:37:E1  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:310 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:100569 (98.2 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:1102 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1102 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:90264 (88.1 KiB)  TX bytes:90264 (88.1 KiB)

wlan0     Link encap:Ethernet  HWaddr 48:F8:B3:F4:37:E3  
          inet6 addr: fe80::4af8:b3ff:fef4:37e3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:405 errors:0 dropped:0 overruns:0 frame:0
          TX packets:881 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:63417 (61.9 KiB)  TX bytes:97364 (95.0 KiB)

wlan1     Link encap:Ethernet  HWaddr 48:F8:B3:F4:37:E2  
          inet6 addr: fe80::4af8:b3ff:fef4:37e2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:749 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:80271 (78.3 KiB)

wlan2     Link encap:Ethernet  HWaddr 48:F8:B3:F4:37:E4  
          inet6 addr: fe80::4af8:b3ff:fef4:37e4/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:747 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:80111 (78.2 KiB)

root@EA9500:/# 
root@EA9500:/# uname -a

Linux EA9500 4.14.29 #0 SMP Sat Mar 31 17:31:42 2018 armv7l GNU/Linux

all i did unselected
< > kmod-swconfig................................... switch configuration API

Was the the wrong option?

In your target/linux/bcm53xx/config-4.14 you need these:

CONFIG_B53=y
CONFIG_B53_MDIO_DRIVER=y
CONFIG_B53_SRAB_DRIVER=y
CONFIG_SWCONFIG=y
CONFIG_NET_DSA=y
CONFIG_NET_SWITCHDEV=y

Get rid of these:

CONFIG_SWCONFIG_B53=y
CONFIG_SWCONFIG_B53_PHY_DRIVER=y
CONFIG_SWCONFIG_B53_PHY_FIXUP=y
CONFIG_SWCONFIG_B53_SRAB_DRIVER=y

Thanks
I did this and compiled again

Still have issues with the network I can still only connect with wifi.
is there any bridging that needs to setup?

run make kernel_menuconfig. Then close the kernel config and save. I'd also try to make clean && make

took me awhile to get back to it.
I tried it and now success. I guess I will stay with 4.14.23 for a while and play with it.

Don't seem to get the network going with 4.14.29

Did you try ti build against 4.14.29 or even the newer ones yet?

Thanks for all the help

Good news
I got it working. I went over your patch and manually changed all the files that you had in the patch manually and I got it to compile. Now I got 4.14.29 working.

Thanks for all the help so far.

:grinning: