diff mbox series

[4/8] IB/mlx5: Only define uplink_rep_profile if CONFIG_MLX5_ESWITCH is enabled

Message ID 20190321172417.77869-5-bvanassche@acm.org (mailing list archive)
State Superseded
Headers show
Series Multiple fixes for issues reported by static checkers | expand

Commit Message

Bart Van Assche March 21, 2019, 5:24 p.m. UTC
This patch avoids that sparse complains about a missing declaration when
building with CONFIG_MLX5_ESWITCH=n.

Cc: Bodong Wang <bodong@mellanox.com>
Cc: Mark Bloch <markb@mellanox.com>
Cc: Saeed Mahameed <saeedm@mellanox.com>
Fixes: f0666f1f22b5 ("IB/mlx5: Use unified register/load function for uplink and VF vports") # v5.1-rc1.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/infiniband/hw/mlx5/main.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Leon Romanovsky March 26, 2019, 10:24 a.m. UTC | #1
On Thu, Mar 21, 2019 at 10:24:13AM -0700, Bart Van Assche wrote:
> This patch avoids that sparse complains about a missing declaration when
> building with CONFIG_MLX5_ESWITCH=n.

Bart,

What error do you see?
I'm building without MLX5_ESWITCH too and not fully understand what
declaration is missing.

Thanks
Bart Van Assche March 26, 2019, 3:21 p.m. UTC | #2
On Tue, 2019-03-26 at 10:24 +0000, Leon Romanovsky wrote:
> On Thu, Mar 21, 2019 at 10:24:13AM -0700, Bart Van Assche wrote:
> > This patch avoids that sparse complains about a missing declaration when
> > building with CONFIG_MLX5_ESWITCH=n.
> 
> What error do you see?
> I'm building without MLX5_ESWITCH too and not fully understand what
> declaration is missing.

Hi Leon,

sparse reports the following warning if I build with MLX5_ESWITCH disabled:

drivers/infiniband/hw/mlx5/main.c:6486:30: warning: symbol 'uplink_rep_profile' was not declared. Should it be static?

I think that is related to the following declaration in ib_rep.h:

#ifdef CONFIG_MLX5_ESWITCH
extern const struct mlx5_ib_profile uplink_rep_profile;
[ ... ]
#else
[ ... ]
#endif

Bart.
Leon Romanovsky March 26, 2019, 3:26 p.m. UTC | #3
On Tue, Mar 26, 2019 at 08:21:10AM -0700, Bart Van Assche wrote:
> On Tue, 2019-03-26 at 10:24 +0000, Leon Romanovsky wrote:
> > On Thu, Mar 21, 2019 at 10:24:13AM -0700, Bart Van Assche wrote:
> > > This patch avoids that sparse complains about a missing declaration when
> > > building with CONFIG_MLX5_ESWITCH=n.
> >
> > What error do you see?
> > I'm building without MLX5_ESWITCH too and not fully understand what
> > declaration is missing.
>
> Hi Leon,
>
> sparse reports the following warning if I build with MLX5_ESWITCH disabled:
>
> drivers/infiniband/hw/mlx5/main.c:6486:30: warning: symbol 'uplink_rep_profile' was not declared. Should it be static?
>
> I think that is related to the following declaration in ib_rep.h:
>
> #ifdef CONFIG_MLX5_ESWITCH
> extern const struct mlx5_ib_profile uplink_rep_profile;
> [ ... ]
> #else
> [ ... ]
> #endif

Thanks,

I think that the best solution will be to move that extern to be outside
of ifdef CONFIG_MLX5_ESWITCH

Thanks

>
> Bart.
Bart Van Assche March 26, 2019, 3:38 p.m. UTC | #4
On Tue, 2019-03-26 at 15:26 +0000, Leon Romanovsky wrote:
> I think that the best solution will be to move that extern to be outside
> of ifdef CONFIG_MLX5_ESWITCH

Hi Leon,

How about moving the uplink_rep_profile definition such that the extern
declaration can be removed?

Thanks,

Bart.

diff --git a/drivers/infiniband/hw/mlx5/ib_rep.c b/drivers/infiniband/hw/mlx5/ib_rep.c
index b8639ac71336..e2c1cb6abd1a 100644
--- a/drivers/infiniband/hw/mlx5/ib_rep.c
+++ b/drivers/infiniband/hw/mlx5/ib_rep.c
@@ -7,6 +7,51 @@
 #include "ib_rep.h"
 #include "srq.h"
 
+const struct mlx5_ib_profile uplink_rep_profile = {
+	STAGE_CREATE(MLX5_IB_STAGE_INIT,
+		     mlx5_ib_stage_init_init,
+		     mlx5_ib_stage_init_cleanup),
+	STAGE_CREATE(MLX5_IB_STAGE_FLOW_DB,
+		     mlx5_ib_stage_flow_db_init,
+		     mlx5_ib_stage_flow_db_cleanup),
+	STAGE_CREATE(MLX5_IB_STAGE_CAPS,
+		     mlx5_ib_stage_caps_init,
+		     NULL),
+	STAGE_CREATE(MLX5_IB_STAGE_NON_DEFAULT_CB,
+		     mlx5_ib_stage_rep_non_default_cb,
+		     NULL),
+	STAGE_CREATE(MLX5_IB_STAGE_ROCE,
+		     mlx5_ib_stage_rep_roce_init,
+		     mlx5_ib_stage_rep_roce_cleanup),
+	STAGE_CREATE(MLX5_IB_STAGE_SRQ,
+		     mlx5_init_srq_table,
+		     mlx5_cleanup_srq_table),
+	STAGE_CREATE(MLX5_IB_STAGE_DEVICE_RESOURCES,
+		     mlx5_ib_stage_dev_res_init,
+		     mlx5_ib_stage_dev_res_cleanup),
+	STAGE_CREATE(MLX5_IB_STAGE_DEVICE_NOTIFIER,
+		     mlx5_ib_stage_dev_notifier_init,
+		     mlx5_ib_stage_dev_notifier_cleanup),
+	STAGE_CREATE(MLX5_IB_STAGE_COUNTERS,
+		     mlx5_ib_stage_counters_init,
+		     mlx5_ib_stage_counters_cleanup),
+	STAGE_CREATE(MLX5_IB_STAGE_UAR,
+		     mlx5_ib_stage_uar_init,
+		     mlx5_ib_stage_uar_cleanup),
+	STAGE_CREATE(MLX5_IB_STAGE_BFREG,
+		     mlx5_ib_stage_bfrag_init,
+		     mlx5_ib_stage_bfrag_cleanup),
+	STAGE_CREATE(MLX5_IB_STAGE_PRE_IB_REG_UMR,
+		     NULL,
+		     mlx5_ib_stage_pre_ib_reg_umr_cleanup),
+	STAGE_CREATE(MLX5_IB_STAGE_IB_REG,
+		     mlx5_ib_stage_ib_reg_init,
+		     mlx5_ib_stage_ib_reg_cleanup),
+	STAGE_CREATE(MLX5_IB_STAGE_POST_IB_REG_UMR,
+		     mlx5_ib_stage_post_ib_reg_umr_init,
+		     NULL),
+};
+
 static const struct mlx5_ib_profile vf_rep_profile = {
 	STAGE_CREATE(MLX5_IB_STAGE_INIT,
 		     mlx5_ib_stage_init_init,
diff --git a/drivers/infiniband/hw/mlx5/ib_rep.h b/drivers/infiniband/hw/mlx5/ib_rep.h
index 798d41e61fb4..ef9e789294be 100644
--- a/drivers/infiniband/hw/mlx5/ib_rep.h
+++ b/drivers/infiniband/hw/mlx5/ib_rep.h
@@ -10,8 +10,6 @@
 #include "mlx5_ib.h"
 
 #ifdef CONFIG_MLX5_ESWITCH
-extern const struct mlx5_ib_profile uplink_rep_profile;
-
 u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw);
 struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw,
 					  int vport_index);
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index 531ff20b32ad..3c925a524619 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -6483,51 +6483,6 @@ static const struct mlx5_ib_profile pf_profile = {
 		     mlx5_ib_stage_delay_drop_cleanup),
 };
 
-const struct mlx5_ib_profile uplink_rep_profile = {
-	STAGE_CREATE(MLX5_IB_STAGE_INIT,
-		     mlx5_ib_stage_init_init,
-		     mlx5_ib_stage_init_cleanup),
-	STAGE_CREATE(MLX5_IB_STAGE_FLOW_DB,
-		     mlx5_ib_stage_flow_db_init,
-		     mlx5_ib_stage_flow_db_cleanup),
-	STAGE_CREATE(MLX5_IB_STAGE_CAPS,
-		     mlx5_ib_stage_caps_init,
-		     NULL),
-	STAGE_CREATE(MLX5_IB_STAGE_NON_DEFAULT_CB,
-		     mlx5_ib_stage_rep_non_default_cb,
-		     NULL),
-	STAGE_CREATE(MLX5_IB_STAGE_ROCE,
-		     mlx5_ib_stage_rep_roce_init,
-		     mlx5_ib_stage_rep_roce_cleanup),
-	STAGE_CREATE(MLX5_IB_STAGE_SRQ,
-		     mlx5_init_srq_table,
-		     mlx5_cleanup_srq_table),
-	STAGE_CREATE(MLX5_IB_STAGE_DEVICE_RESOURCES,
-		     mlx5_ib_stage_dev_res_init,
-		     mlx5_ib_stage_dev_res_cleanup),
-	STAGE_CREATE(MLX5_IB_STAGE_DEVICE_NOTIFIER,
-		     mlx5_ib_stage_dev_notifier_init,
-		     mlx5_ib_stage_dev_notifier_cleanup),
-	STAGE_CREATE(MLX5_IB_STAGE_COUNTERS,
-		     mlx5_ib_stage_counters_init,
-		     mlx5_ib_stage_counters_cleanup),
-	STAGE_CREATE(MLX5_IB_STAGE_UAR,
-		     mlx5_ib_stage_uar_init,
-		     mlx5_ib_stage_uar_cleanup),
-	STAGE_CREATE(MLX5_IB_STAGE_BFREG,
-		     mlx5_ib_stage_bfrag_init,
-		     mlx5_ib_stage_bfrag_cleanup),
-	STAGE_CREATE(MLX5_IB_STAGE_PRE_IB_REG_UMR,
-		     NULL,
-		     mlx5_ib_stage_pre_ib_reg_umr_cleanup),
-	STAGE_CREATE(MLX5_IB_STAGE_IB_REG,
-		     mlx5_ib_stage_ib_reg_init,
-		     mlx5_ib_stage_ib_reg_cleanup),
-	STAGE_CREATE(MLX5_IB_STAGE_POST_IB_REG_UMR,
-		     mlx5_ib_stage_post_ib_reg_umr_init,
-		     NULL),
-};
-
 static void *mlx5_ib_add_slave_port(struct mlx5_core_dev *mdev)
 {
 	struct mlx5_ib_multiport_info *mpi;
Leon Romanovsky March 26, 2019, 4:31 p.m. UTC | #5
On Tue, Mar 26, 2019 at 08:38:12AM -0700, Bart Van Assche wrote:
> On Tue, 2019-03-26 at 15:26 +0000, Leon Romanovsky wrote:
> > I think that the best solution will be to move that extern to be outside
> > of ifdef CONFIG_MLX5_ESWITCH
>
> Hi Leon,
>
> How about moving the uplink_rep_profile definition such that the extern
> declaration can be removed?

Bart,

We are going to rewrite this uplink_rep_profile initialization and I double
checked it now that it will solve this warning too.

The series are ready and I'll start sending them tomorrow.

Thanks
Bart Van Assche March 26, 2019, 4:38 p.m. UTC | #6
On Tue, 2019-03-26 at 16:31 +0000, Leon Romanovsky wrote:
> We are going to rewrite this uplink_rep_profile initialization and I double
> checked it now that it will solve this warning too.
> 
> The series are ready and I'll start sending them tomorrow.

Hi Leon,

That's good to know. I will drop patch 4/8.

Thanks,

Bart.
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index 994c19d01211..bfecb75059ae 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -6476,6 +6476,7 @@  static const struct mlx5_ib_profile pf_profile = {
 		     mlx5_ib_stage_delay_drop_cleanup),
 };
 
+#ifdef CONFIG_MLX5_ESWITCH
 const struct mlx5_ib_profile uplink_rep_profile = {
 	STAGE_CREATE(MLX5_IB_STAGE_INIT,
 		     mlx5_ib_stage_init_init,
@@ -6520,6 +6521,7 @@  const struct mlx5_ib_profile uplink_rep_profile = {
 		     mlx5_ib_stage_post_ib_reg_umr_init,
 		     NULL),
 };
+#endif
 
 static void *mlx5_ib_add_slave_port(struct mlx5_core_dev *mdev)
 {