Skip to content

Commit

Permalink
net/mlx4: fix build with -fno-common
Browse files Browse the repository at this point in the history
[ upstream commit a5e5af7 ]

The variable storages of the same name are merged together
if compiled with -fcommon. This is the default.
This default behaviour allows to declare a variable in a header file and
share the variable in every .o binaries thanks to merge at link-time.

In the case of dlopen linking of the glue library, the pointer mlx4_glue
is referencing the glue functions struct and is set after calling
dlopen.

If compiling with -fno-common (default in GCC 10), the variables must be
declared as extern to avoid multiple re-definitions.
In case the glue layer is split in glue library, the variable mlx4_glue
needs to have its own storage for the rest of the PMD.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Matan Azrad <matan@mellanox.com>
  • Loading branch information
tmonjalo authored and kevintraynor committed May 27, 2020
1 parent 15b8c1b commit f808ec0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions drivers/net/mlx4/mlx4.c
Expand Up @@ -48,6 +48,10 @@
#include "mlx4_rxtx.h"
#include "mlx4_utils.h"

#ifdef MLX4_GLUE
const struct mlx4_glue *mlx4_glue;
#endif

struct mlx4_dev_list mlx4_mem_event_cb_list =
LIST_HEAD_INITIALIZER(mlx4_mem_event_cb_list);

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/mlx4/mlx4_glue.h
Expand Up @@ -84,6 +84,6 @@ struct mlx4_glue {
void *attr);
};

const struct mlx4_glue *mlx4_glue;
extern const struct mlx4_glue *mlx4_glue;

#endif /* MLX4_GLUE_H_ */
2 changes: 1 addition & 1 deletion drivers/net/mlx4/mlx4_rxtx.h
Expand Up @@ -120,7 +120,7 @@ struct txq {

/* mlx4_rxq.c */

uint8_t mlx4_rss_hash_key_default[MLX4_RSS_HASH_KEY_SIZE];
extern uint8_t mlx4_rss_hash_key_default[MLX4_RSS_HASH_KEY_SIZE];
int mlx4_rss_init(struct mlx4_priv *priv);
void mlx4_rss_deinit(struct mlx4_priv *priv);
struct mlx4_rss *mlx4_rss_get(struct mlx4_priv *priv, uint64_t fields,
Expand Down

0 comments on commit f808ec0

Please sign in to comment.