wkz / mdio-tools

Low-level debug tools for MDIO devices.
GNU General Public License v2.0
66 stars 29 forks source link

Cannot build mdio-netlink for kernel version 4.19 (I know it claims to be at least 5.2) #34

Closed zera98 closed 11 months ago

zera98 commented 11 months ago

I have board with kernel version 4.19 and it seems like the tool is not compatible with that version. Is it true? I checked here https://elixir.bootlin.com/linux/v4.19/ident and it looks like I am missing couple of functions, and build fails with error:

.../git/kernel/compat.h:14:33: error: 'MII_DEVADDR_C45_SHIFT' undeclared (first use in this function) | 14 | return MII_ADDR_C45 | devad << MII_DEVADDR_C45_SHIFT | regnum; | | ^~~~~ git/kernel/compat.h:14:33: note: each undeclared identifier is reported only once for each function it appears in | ...git/kernel/mdio-netlink.c: At top level: | ...git/kernel/mdio-netlink.c:288:23: error: implicit declaration of function 'NLA_POLICY_MAX' [-Werror=implicit-function-declaration] | 288 | [MDIO_NLA_TIMEOUT] = NLA_POLICY_MAX(NLA_U16, 10 MSEC_PER_SEC), | | ^~~~~~ |...git/kernel/mdio-netlink.c:288:23: error: initializer element is not constant | ...git/kernel/mdio-netlink.c:288:23: note: (near initialization for 'mdio_nl_policy[2].type') |...git/kernel/mdio-netlink.c:289:23: error: implicit declaration of function 'NLA_POLICY_VALIDATE_FN' [-Werror=implicit-function-declaration] | 289 | [MDIO_NLA_PROG] = NLA_POLICY_VALIDATE_FN(NLA_BINARY, | | ^~~~~~ | ...git/kernel/mdio-netlink.c:289:23: error: initializer element is not constant | ...git/kernel/mdio-netlink.c:289:23: note: (near initialization for 'mdio_nl_policy[3].type') | ...git/kernel/mdio-netlink.c:285:67: warning: missing braces around initializer [-Wmissing-braces] | 285 | static const struct nla_policy mdio_nl_policy[MDIO_NLA_MAX + 1] = { | | ^ | ...... | 288 | [MDIO_NLA_TIMEOUT] = NLA_POLICY_MAX(NLA_U16, 10 MSEC_PER_SEC), | | { } | 289 | [MDIO_NLA_PROG] = NLA_POLICY_VALIDATE_FN(NLA_BINARY, | | { | 290 | mdio_nl_validate_prog, | 291 | 0x1000), | | } | ...git/kernel/mdio-netlink.c:285:67: warning: missing braces around initializer [-Wmissing-braces] | 285 | static const struct nla_policy mdio_nl_policy[MDIO_NLA_MAX + 1] = { | | ^ | ...... | 288 | [MDIO_NLA_TIMEOUT] = NLA_POLICY_MAX(NLA_U16, 10 MSEC_PER_SEC), | | { } | 289 | [MDIO_NLA_PROG] = NLA_POLICY_VALIDATE_FN(NLA_BINARY, | | { | 290 | mdio_nl_validate_prog, | 291 | 0x1000), | | } | ...git/kernel/mdio-netlink.c:285:67: warning: missing braces around initializer [-Wmissing-braces] | 285 | static const struct nla_policy mdio_nl_policy[MDIO_NLA_MAX + 1] = { | | ^ | ...... | 288 | [MDIO_NLA_TIMEOUT] = NLA_POLICY_MAX(NLA_U16, 10 MSEC_PER_SEC), | | { } | 289 | [MDIO_NLA_PROG] = NLA_POLICY_VALIDATE_FN(NLA_BINARY, | | { | 290 | mdio_nl_validate_prog, | 291 | 0x1000), | | } | ...git/kernel/mdio-netlink.c:430:3: error: 'struct genl_family' has no member named 'policy' | 430 | .policy = mdio_nl_policy, | | ^~ | ...git/kernel/mdio-netlink.c:430:14: warning: initialization of 'unsigned int' from 'const struct nla_policy *' makes integer from pointer without a cast [-Wint-conversion] | 430 | .policy = mdio_nl_policy, | | ^~~~~~ | ...git/kernel/mdio-netlink.c:430:14: note: (near initialization for 'mdio_nl_family.n_mcgrps') | In file included from ...git/kernel/mdio-netlink.c:11: | ...git/kernel/compat.h: In function 'mdiobus_c45_addr': | ...git/kernel/compat.h:15:1: warning: control reaches end of non-void function [-Wreturn-type] | 15 | } | | ^

I am using Yocto Project to install mdio-tools to system. Does anyone know how to solve this compatibility issue? I tried to patch the kernel but it is disaster :) Maybe I am missing something (I successfully installed it on system using Yocto Project where kernel version is 5.15, but I cannot update from 4.19 on this system...)

zera98 commented 11 months ago

I patched the kernel and managed to build it for v4.19