net/mlx5e: make VXLAN support conditional
Subsystems (5)
PATCH 1/1 net/mlx5e: make VXLAN support conditional
VXLAN can be disabled at compile-time or it can be a loadable module while mlx5 is built-in, which leads to a link error:
drivers/net/built-in.o: In function `mlx5e_create_netdev':
ntb_netdev.c:(.text+0x106de4): undefined reference to `vxlan_get_rx_port'
This avoids the link error and makes the vxlan code optional, like the other ethernet drivers do as well.
--- drivers/net/ethernet/mellanox/mlx5/core/Kconfig | 7 +++++++ drivers/net/ethernet/mellanox/mlx5/core/Makefile | 4 +++- drivers/net/ethernet/mellanox/mlx5/core/en.h | 2 ++ drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 3 +++ drivers/net/ethernet/mellanox/mlx5/core/vxlan.h | 11 +++++++++-- 5 files changed, 24 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/Kconfig +7 -0
@@ -31,3 +31,10 @@ config MLX5_CORE_EN_DCB This flag is depended on the kernel's DCB support. If unsure, set to Y + +config MLX5_CORE_EN_VXLAN + bool "VXLAN offloads Support" + default y + depends on MLX5_CORE_EN && VXLAN && !(MLX5_CORE=y && VXLAN=m) + ---help--- + Say Y here if you want to use VXLAN offloads in the driver.
drivers/net/ethernet/mellanox/mlx5/core/Makefile +3 -1
@@ -6,6 +6,8 @@ mlx5_core-y := main.o cmd.o debugfs.o fw.o eq.o uar.o pagealloc.o \ mlx5_core-$(CONFIG_MLX5_CORE_EN) += wq.o eswitch.o \ en_main.o en_fs.o en_ethtool.o en_tx.o en_rx.o \ - en_txrx.o en_clock.o vxlan.o + en_txrx.o en_clock.o + +mlx5_core-$(CONFIG_MLX5_CORE_EN_VXLAN) += vxlan.o mlx5_core-$(CONFIG_MLX5_CORE_EN_DCB) += en_dcbnl.o
drivers/net/ethernet/mellanox/mlx5/core/en.h +2 -0
@@ -552,7 +552,9 @@ struct mlx5e_priv {struct mlx5e_flow_tables fts;struct mlx5e_eth_addr_db eth_addr;struct mlx5e_vlan_db vlan; +#ifdef CONFIG_MLX5_CORE_EN_VXLAN struct mlx5e_vxlan_db vxlan; +#endif struct mlx5e_params params;spinlock_t async_events_spinlock;/* sync hw events */
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +3 -0
@@ -2116,6 +2116,9 @@ static netdev_features_t mlx5e_vxlan_features_check(struct mlx5e_priv *priv,u16 proto;u16 port =0 ; +if (!IS_ENABLED (CONFIG_MLX5_CORE_EN_VXLAN )) + goto out; +switch (vlan_get_protocol (skb)) {case htons (ETH_P_IP ): proto =ip_hdr (skb)->protocol;
drivers/net/ethernet/mellanox/mlx5/core/vxlan.h +9 -2
@@ -41,14 +41,21 @@ struct mlx5e_vxlan {static inline bool mlx5e_vxlan_allowed (struct mlx5_core_dev *mdev) { -return (MLX5_CAP_ETH (mdev, tunnel_stateless_vxlan) && +return IS_ENABLED (CONFIG_MLX5_CORE_EN_VXLAN ) && + (MLX5_CAP_ETH (mdev, tunnel_stateless_vxlan) &&mlx5_core_is_pf (mdev)); } +#ifdef CONFIG_MLX5_CORE_EN_VXLAN void mlx5e_vxlan_init (struct mlx5e_priv *priv); +void mlx5e_vxlan_cleanup (struct mlx5e_priv *priv); +#else +static inline void mlx5e_vxlan_init (struct mlx5e_priv *priv) {} +static inline void mlx5e_vxlan_cleanup (struct mlx5e_priv *priv) {} +#endif +int mlx5e_vxlan_add_port (struct mlx5e_priv *priv,u16 port);void mlx5e_vxlan_del_port (struct mlx5e_priv *priv,u16 port);struct mlx5e_vxlan *mlx5e_vxlan_lookup_port (struct mlx5e_priv *priv,u16 port); -void mlx5e_vxlan_cleanup (struct mlx5e_priv *priv);#endif /* __MLX5_VXLAN_H__ */
Signature · 1 line
2.7.0
Quoted 11 lines · Arnd Bergmann
VXLAN can be disabled at compile-time or it can be a loadable module while mlx5 is built-in, which leads to a link error:
drivers/net/built-in.o: In function `mlx5e_create_netdev':
ntb_netdev.c:(.text+0x106de4): undefined reference to `vxlan_get_rx_port'This avoids the link error and makes the vxlan code optional, like the other ethernet drivers do as well.
Signed-off-by Arnd Bergmann <[email protected]>Fixes b3f63c3d5e2c ("net/mlx5e: Add netdev support for VXLAN tunneling")
Hi Arnd,
Thanks for the patch, I will suggest some slight modifications and we will handle it and re-post the patch.
Quoted 8 lines
struct
mlx5e_paramsparams;
spinlock_tasync_events_spinlock; /* sync hw events */drivers/net/ethernet/mellanox/mlx5/core/en_main.c +0
-0
drivers/net/ethernet/mellanox/mlx5/core/en_main.c static netdev_features_t mlx5e_vxlan_features_check(struct mlx5e_priv *priv, · line 2121
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +3
-0@@ -2116,6 +2116,9 @@ static netdev_features_t mlx5e_vxlan_features_check(struct mlx5e_priv *priv,u16 proto;u16 port =0 ; +if (!IS_ENABLED (CONFIG_MLX5_CORE_EN_VXLAN )) + goto out; +
I would rather wrap the whole mlx5e_features_check with the suggested config flag and disable it in case CONFIG_MLX5_CORE_EN_VXLAN is OFF, since this function is only needed for when vxlan is supported.
drivers/net/ethernet/mellanox/mlx5/core/en_main.c static netdev_features_t mlx5e_vxlan_features_check(struct mlx5e_priv *priv,
Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +2
-1static inline bool mlx5e_vxlan_allowed (struct mlx5_core_dev *mdev) { -return (MLX5_CAP_ETH (mdev, tunnel_stateless_vxlan) && +return IS_ENABLED (CONFIG_MLX5_CORE_EN_VXLAN ) && + (MLX5_CAP_ETH (mdev, tunnel_stateless_vxlan) &&mlx5_core_is_pf (mdev)); }
Same here.
Quoted 8 lines · On Sunday 28 February 2016 15:26:53 Saeed Mahameed wrote:
Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +0
-0@@ -2116,6 +2116,9 @@ static netdev_features_t mlx5e_vxlan_features_check(struct mlx5e_priv *priv,u16 proto;u16 port =0 ;
Quoted 7 lines
drivers/net/ethernet/mellanox/mlx5/core/en_main.c static netdev_features_t mlx5e_vxlan_features_check(struct mlx5e_priv *priv, · line 2121
Quoted 3 lines
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +3
-0+if (!IS_ENABLED (CONFIG_MLX5_CORE_EN_VXLAN )) + goto out; +I would rather wrap the whole
mlx5e_features_checkwith the suggested config flag and disable it in caseCONFIG_MLX5_CORE_EN_VXLANis OFF, since this function is only needed for when vxlan is supported.
Sounds good.
I think moving the IS_ENABLED() check into the caller(s) will still result in the same object code, but it makes sense to structure the code for best readability.
Arnd