public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: mellanox: add DEVLINK dependencies
@ 2016-03-02  9:40 Arnd Bergmann
  2016-03-02 10:10 ` Jiri Pirko
       [not found] ` <1456911665-1424389-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org>
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2016-03-02  9:40 UTC (permalink / raw)
  To: Jiri Pirko, David S. Miller
  Cc: linux-arm-kernel, Arnd Bergmann, Yishai Hadas, Doug Ledford,
	Sean Hefty, Hal Rosenstock, Ido Schimmel, linux-rdma,
	linux-kernel, netdev

The new NET_DEVLINK infrastructure can be a loadable module, but the drivers
using it might be built-in, which causes link errors like:

drivers/net/built-in.o: In function `mlx4_load_one':
:(.text+0x2fbfda): undefined reference to `devlink_port_register'
:(.text+0x2fc084): undefined reference to `devlink_port_unregister'
drivers/net/built-in.o: In function `mlxsw_sx_port_remove':
:(.text+0x33a03a): undefined reference to `devlink_port_type_clear'
:(.text+0x33a04e): undefined reference to `devlink_port_unregister'

There are multiple ways to avoid this:

a) add 'depends on NET_DEVLINK || !NET_DEVLINK' dependencies
   for each user
b) use 'select NET_DEVLINK' from each driver that uses it
   and hide the symbol in Kconfig.
c) make NET_DEVLINK a 'bool' option so we don't have to
   list it as a dependency, and rely on the APIs to be
   stubbed out when it is disabled
d) use IS_REACHABLE() rather than IS_ENABLED() to check for
   NET_DEVLINK in include/net/devlink.h

This implements a variation of approach a) by adding an
intermediate symbol that drivers can depend on, and changes
the three drivers using it.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 09d4d087cd48 ("mlx4: Implement devlink interface")
Fixes: c4745500e988 ("mlxsw: Implement devlink interface")
---
 drivers/infiniband/hw/mlx4/Kconfig          | 1 +
 drivers/net/ethernet/mellanox/mlx4/Kconfig  | 1 +
 drivers/net/ethernet/mellanox/mlxsw/Kconfig | 1 +
 net/Kconfig                                 | 9 +++++++++
 4 files changed, 12 insertions(+)

diff --git a/drivers/infiniband/hw/mlx4/Kconfig b/drivers/infiniband/hw/mlx4/Kconfig
index fc01deac1d3c..db4aa13ebae0 100644
--- a/drivers/infiniband/hw/mlx4/Kconfig
+++ b/drivers/infiniband/hw/mlx4/Kconfig
@@ -1,6 +1,7 @@
 config MLX4_INFINIBAND
 	tristate "Mellanox ConnectX HCA support"
 	depends on NETDEVICES && ETHERNET && PCI && INET
+	depends on MAY_USE_DEVLINK
 	select NET_VENDOR_MELLANOX
 	select MLX4_CORE
 	---help---
diff --git a/drivers/net/ethernet/mellanox/mlx4/Kconfig b/drivers/net/ethernet/mellanox/mlx4/Kconfig
index 1486ce902a56..9ca3734ebb6b 100644
--- a/drivers/net/ethernet/mellanox/mlx4/Kconfig
+++ b/drivers/net/ethernet/mellanox/mlx4/Kconfig
@@ -4,6 +4,7 @@
 
 config MLX4_EN
 	tristate "Mellanox Technologies 1/10/40Gbit Ethernet support"
+	depends on MAY_USE_DEVLINK
 	depends on PCI
 	select MLX4_CORE
 	select PTP_1588_CLOCK
diff --git a/drivers/net/ethernet/mellanox/mlxsw/Kconfig b/drivers/net/ethernet/mellanox/mlxsw/Kconfig
index ce26adcb4988..2ad7f67854d5 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/Kconfig
+++ b/drivers/net/ethernet/mellanox/mlxsw/Kconfig
@@ -4,6 +4,7 @@
 
 config MLXSW_CORE
 	tristate "Mellanox Technologies Switch ASICs support"
+	depends on MAY_USE_DEVLINK
 	---help---
 	  This driver supports Mellanox Technologies Switch ASICs family.
 
diff --git a/net/Kconfig b/net/Kconfig
index 6c9cfb0d7639..2760825e53fa 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -403,6 +403,15 @@ config NET_DEVLINK
 	  infrastructure to support access to physical chip-wide config and
 	  monitoring.
 
+config MAY_USE_DEVLINK
+	tristate
+	default m if NET_DEVLINK=m
+	default y if NET_DEVLINK=y || NET_DEVLINK=n
+	help
+	  Drivers using the devlink infrastructure should have a dependency
+	  on MAY_USE_DEVLINK to ensure they do not cause link errors when
+	  devlink is a loadable module and the driver using it is built-in.
+
 endif   # if NET
 
 # Used by archs to tell that they support BPF_JIT
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: mellanox: add DEVLINK dependencies
  2016-03-02  9:40 [PATCH] net: mellanox: add DEVLINK dependencies Arnd Bergmann
@ 2016-03-02 10:10 ` Jiri Pirko
       [not found] ` <1456911665-1424389-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org>
  1 sibling, 0 replies; 3+ messages in thread
From: Jiri Pirko @ 2016-03-02 10:10 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Jiri Pirko, David S. Miller, linux-arm-kernel, Yishai Hadas,
	Doug Ledford, Sean Hefty, Hal Rosenstock, Ido Schimmel,
	linux-rdma, linux-kernel, netdev

Wed, Mar 02, 2016 at 10:40:54AM CET, arnd@arndb.de wrote:
>The new NET_DEVLINK infrastructure can be a loadable module, but the drivers
>using it might be built-in, which causes link errors like:
>
>drivers/net/built-in.o: In function `mlx4_load_one':
>:(.text+0x2fbfda): undefined reference to `devlink_port_register'
>:(.text+0x2fc084): undefined reference to `devlink_port_unregister'
>drivers/net/built-in.o: In function `mlxsw_sx_port_remove':
>:(.text+0x33a03a): undefined reference to `devlink_port_type_clear'
>:(.text+0x33a04e): undefined reference to `devlink_port_unregister'
>
>There are multiple ways to avoid this:
>
>a) add 'depends on NET_DEVLINK || !NET_DEVLINK' dependencies
>   for each user
>b) use 'select NET_DEVLINK' from each driver that uses it
>   and hide the symbol in Kconfig.
>c) make NET_DEVLINK a 'bool' option so we don't have to
>   list it as a dependency, and rely on the APIs to be
>   stubbed out when it is disabled
>d) use IS_REACHABLE() rather than IS_ENABLED() to check for
>   NET_DEVLINK in include/net/devlink.h
>
>This implements a variation of approach a) by adding an
>intermediate symbol that drivers can depend on, and changes
>the three drivers using it.

Approach a) looks like the best. Thanks for taking care of this.

>
>Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Jiri Pirko <jiri@mellanox.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: mellanox: add DEVLINK dependencies
       [not found] ` <1456911665-1424389-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org>
@ 2016-03-03 21:48   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2016-03-03 21:48 UTC (permalink / raw)
  To: arnd-r2nGTMty4D4
  Cc: jiri-VPRAkNaXOzVWk0Htik3J/w,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	yishaih-VPRAkNaXOzVWk0Htik3J/w, dledford-H+wXaHxf7aLQT0dZR+AlfA,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	idosch-VPRAkNaXOzVWk0Htik3J/w, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA

From: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
Date: Wed,  2 Mar 2016 10:40:54 +0100

> The new NET_DEVLINK infrastructure can be a loadable module, but the drivers
> using it might be built-in, which causes link errors like:
> 
> drivers/net/built-in.o: In function `mlx4_load_one':
> :(.text+0x2fbfda): undefined reference to `devlink_port_register'
> :(.text+0x2fc084): undefined reference to `devlink_port_unregister'
> drivers/net/built-in.o: In function `mlxsw_sx_port_remove':
> :(.text+0x33a03a): undefined reference to `devlink_port_type_clear'
> :(.text+0x33a04e): undefined reference to `devlink_port_unregister'
> 
> There are multiple ways to avoid this:
> 
> a) add 'depends on NET_DEVLINK || !NET_DEVLINK' dependencies
>    for each user
> b) use 'select NET_DEVLINK' from each driver that uses it
>    and hide the symbol in Kconfig.
> c) make NET_DEVLINK a 'bool' option so we don't have to
>    list it as a dependency, and rely on the APIs to be
>    stubbed out when it is disabled
> d) use IS_REACHABLE() rather than IS_ENABLED() to check for
>    NET_DEVLINK in include/net/devlink.h
> 
> This implements a variation of approach a) by adding an
> intermediate symbol that drivers can depend on, and changes
> the three drivers using it.
> 
> Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
> Fixes: 09d4d087cd48 ("mlx4: Implement devlink interface")
> Fixes: c4745500e988 ("mlxsw: Implement devlink interface")

Applied, thanks Arnd.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-03-03 21:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-02  9:40 [PATCH] net: mellanox: add DEVLINK dependencies Arnd Bergmann
2016-03-02 10:10 ` Jiri Pirko
     [not found] ` <1456911665-1424389-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org>
2016-03-03 21:48   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox