Skip to contentSkip to conversation

RDMA/bnxt_re: Minor code cleanups

PATCH Applied Selvin Xavier 2 participants 7 messages Dec 11, 2024 – Dec 16, 2024

Subsystems (2)
lore
Share & tools
lore

Selvin Xavier

author maintainer
#0 lore raw

cover RDMA/bnxt_re: Minor code cleanups

Some minor code cleanup for bnxt_re.

Please review and apply.

Thanks,
Selvin Xavier

Kalesh AP (5):
RDMA/bnxt_re: Remove extra new line in bnxt_re_netdev_event RDMA/bnxt_re: Remove unnecessary goto in bnxt_re_netdev_event RDMA/bnxt_re: Optimize error handling in bnxt_re_probe RDMA/bnxt_re: Eliminate need for some forward declarations RDMA/bnxt_re: Remove unnecessary header file inclusion

 drivers/infiniband/hw/bnxt_re/hw_counters.c |  9 ----
 drivers/infiniband/hw/bnxt_re/ib_verbs.c    |  2 -
 drivers/infiniband/hw/bnxt_re/main.c        | 84 +++++++++++++----------------
 3 files changed, 37 insertions(+), 58 deletions(-)
Signature · 1 line
2.5.5
author maintainer
#1 lore raw

PATCH 1/5 RDMA/bnxt_re: Remove extra new line in bnxt_re_netdev_event

From: Kalesh AP <[email protected]>

This is a purely cosmetic change.

---
 drivers/infiniband/hw/bnxt_re/main.c | 1 -
 1 file changed, 1 deletion(-)
drivers/infiniband/hw/bnxt_re/main.c +0 -1
index b7af0d5..735bd78 100644
@@ -2247,7 +2247,6 @@ static int bnxt_re_netdev_event(struct notifier_block *notifier,
 	if (!rdev)
 		return NOTIFY_DONE;
 
-
 	switch (event) {
 	case NETDEV_UP:
 	case NETDEV_DOWN:
Signature · 1 line
2.5.5
author maintainer
#2 lore raw

PATCH 2/5 RDMA/bnxt_re: Remove unnecessary goto in bnxt_re_netdev_event

In reply to Selvin Xavier

From: Kalesh AP <[email protected]>

Return directly in case of error without a goto label as there is no cleanup actions performed.

---
 drivers/infiniband/hw/bnxt_re/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/bnxt_re/main.c +2 -2
index 735bd78..ae5025b 100644
@@ -2241,7 +2241,7 @@ static int bnxt_re_netdev_event(struct notifier_block *notifier,
 		real_dev = netdev;
 
 	if (real_dev != netdev)
-		goto exit;
+		return NOTIFY_DONE;
 
 	rdev = bnxt_re_from_netdev(real_dev);
 	if (!rdev)
@@ -2260,7 +2260,7 @@ static int bnxt_re_netdev_event(struct notifier_block *notifier,
 		break;
 	}
 	ib_device_put(&rdev->ibdev);
-exit:
+
 	return NOTIFY_DONE;
 }
 
Signature · 1 line
2.5.5
author maintainer
#3 lore raw

PATCH 3/5 RDMA/bnxt_re: Optimize error handling in bnxt_re_probe

In reply to Selvin Xavier

From: Kalesh AP <[email protected]>

Optimize error handling path in bnxt_re_probe by removing some duplicate code.

---
 drivers/infiniband/hw/bnxt_re/main.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/infiniband/hw/bnxt_re/main.c +1 -5
index ae5025b..75e1611 100644
@@ -2321,13 +2321,9 @@ static int bnxt_re_probe(struct auxiliary_device *adev,
 
 	rc = bnxt_re_add_device(adev, BNXT_RE_COMPLETE_INIT);
 	if (rc)
-		goto err;
-	mutex_unlock(&bnxt_re_mutex);
-	return 0;
+		kfree(en_info);
 
-err:
 	mutex_unlock(&bnxt_re_mutex);
-	kfree(en_info);
 
 	return rc;
 }
Signature · 1 line
2.5.5
author maintainer
#4 lore raw

PATCH 4/5 RDMA/bnxt_re: Eliminate need for some forward declarations

In reply to Selvin Xavier

From: Kalesh AP <[email protected]>

Move the function definition of bnxt_re_shutdown() to avoid forward declarartion of bnxt_re_dev_uninit().

Move the function definition of bnxt_re_setup_cc() before bnxt_re_add_device() to avoid it's forward declarations.

Also, forward declarartions of bnxt_re_stop_irq() and bnxt_re_dev_stop() are unnecessary.

---
 drivers/infiniband/hw/bnxt_re/main.c | 73 +++++++++++++++++-------------------
 1 file changed, 34 insertions(+), 39 deletions(-)
drivers/infiniband/hw/bnxt_re/main.c +34 -39
index 75e1611..5e10b54 100644
@@ -79,17 +79,12 @@ MODULE_LICENSE("Dual BSD/GPL");
 /* globals */
 static DEFINE_MUTEX(bnxt_re_mutex);
 
-static void bnxt_re_stop_irq(void *handle);
-static void bnxt_re_dev_stop(struct bnxt_re_dev *rdev);
 static int bnxt_re_netdev_event(struct notifier_block *notifier,
 				unsigned long event, void *ptr);
-static struct bnxt_re_dev *bnxt_re_from_netdev(struct net_device *netdev);
-static void bnxt_re_dev_uninit(struct bnxt_re_dev *rdev, u8 op_type);
 static int bnxt_re_hwrm_qcaps(struct bnxt_re_dev *rdev);
 
 static int bnxt_re_hwrm_qcfg(struct bnxt_re_dev *rdev, u32 *db_len,
 			     u32 *offset);
-static void bnxt_re_setup_cc(struct bnxt_re_dev *rdev, bool enable);
 static void bnxt_re_set_db_offset(struct bnxt_re_dev *rdev)
 {
 	struct bnxt_qplib_chip_ctx *cctx;
@@ -302,16 +297,6 @@ static void bnxt_re_vf_res_config(struct bnxt_re_dev *rdev)
 				      &rdev->qplib_ctx);
 }
 
-static void bnxt_re_shutdown(struct auxiliary_device *adev)
-{
-	struct bnxt_re_en_dev_info *en_info = auxiliary_get_drvdata(adev);
-	struct bnxt_re_dev *rdev;
-
-	rdev = en_info->rdev;
-	ib_unregister_device(&rdev->ibdev);
-	bnxt_re_dev_uninit(rdev, BNXT_RE_COMPLETE_REMOVE);
-}
-
 static void bnxt_re_stop_irq(void *handle)
 {
 	struct bnxt_re_en_dev_info *en_info = auxiliary_get_drvdata(handle);
@@ -2123,6 +2108,30 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 op_type)
 	return rc;
 }
 
+static void bnxt_re_setup_cc(struct bnxt_re_dev *rdev, bool enable)
+{
+	struct bnxt_qplib_cc_param cc_param = {};
+
+	/* Do not enable congestion control on VFs */
+	if (rdev->is_virtfn)
+		return;
+
+	/* Currently enabling only for GenP5 adapters */
+	if (!bnxt_qplib_is_chip_gen_p5_p7(rdev->chip_ctx))
+		return;
+
+	if (enable) {
+		cc_param.enable  = 1;
+		cc_param.tos_ecn = 1;
+	}
+
+	cc_param.mask = (CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_ENABLE_CC |
+			 CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_TOS_ECN);
+
+	if (bnxt_qplib_modify_cc(&rdev->qplib_res, &cc_param))
+		ibdev_err(&rdev->ibdev, "Failed to setup CC enable = %d\n", enable);
+}
+
 static void bnxt_re_update_en_info_rdev(struct bnxt_re_dev *rdev,
 					struct bnxt_re_en_dev_info *en_info,
 					struct auxiliary_device *adev)
@@ -2192,30 +2201,6 @@ static int bnxt_re_add_device(struct auxiliary_device *adev, u8 op_type)
 	return rc;
 }
 
-static void bnxt_re_setup_cc(struct bnxt_re_dev *rdev, bool enable)
-{
-	struct bnxt_qplib_cc_param cc_param = {};
-
-	/* Do not enable congestion control on VFs */
-	if (rdev->is_virtfn)
-		return;
-
-	/* Currently enabling only for GenP5 adapters */
-	if (!bnxt_qplib_is_chip_gen_p5_p7(rdev->chip_ctx))
-		return;
-
-	if (enable) {
-		cc_param.enable  = 1;
-		cc_param.tos_ecn = 1;
-	}
-
-	cc_param.mask = (CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_ENABLE_CC |
-			 CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_TOS_ECN);
-
-	if (bnxt_qplib_modify_cc(&rdev->qplib_res, &cc_param))
-		ibdev_err(&rdev->ibdev, "Failed to setup CC enable = %d\n", enable);
-}
-
 /*
  * "Notifier chain callback can be invoked for the same chain from
  * different CPUs at the same time".
@@ -2376,6 +2361,16 @@ static int bnxt_re_resume(struct auxiliary_device *adev)
 	return 0;
 }
 
+static void bnxt_re_shutdown(struct auxiliary_device *adev)
+{
+	struct bnxt_re_en_dev_info *en_info = auxiliary_get_drvdata(adev);
+	struct bnxt_re_dev *rdev;
+
+	rdev = en_info->rdev;
+	ib_unregister_device(&rdev->ibdev);
+	bnxt_re_dev_uninit(rdev, BNXT_RE_COMPLETE_REMOVE);
+}
+
 static const struct auxiliary_device_id bnxt_re_id_table[] = {
 	{ .name = BNXT_ADEV_NAME ".rdma", },
 	{},
Signature · 1 line
2.5.5
author maintainer
#5 lore raw

PATCH 5/5 RDMA/bnxt_re: Remove unnecessary header file inclusion

In reply to Selvin Xavier

From: Kalesh AP <[email protected]>

There is no need to include bnxt_ulp.h in ib_verbs.c. Remove it. Also, fixed hw_counters.c to remove unwanted header file inclusions.

---
 drivers/infiniband/hw/bnxt_re/hw_counters.c | 9 ---------
 drivers/infiniband/hw/bnxt_re/ib_verbs.c    | 2 --
 2 files changed, 11 deletions(-)
drivers/infiniband/hw/bnxt_re/hw_counters.c +0 -9
index 1e63f80..77ec2ed 100644
@@ -37,18 +37,9 @@
  *
  */
 
-#include <linux/interrupt.h>
 #include <linux/types.h>
-#include <linux/spinlock.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/pci.h>
-#include <linux/prefetch.h>
-#include <linux/delay.h>
 
-#include <rdma/ib_addr.h>
-
-#include "bnxt_ulp.h"
 #include "roce_hsi.h"
 #include "qplib_res.h"
 #include "qplib_sp.h"
drivers/infiniband/hw/bnxt_re/ib_verbs.c +0 -2
index 8202339..129178b 100644
@@ -52,8 +52,6 @@
 #include <rdma/uverbs_ioctl.h>
 #include <linux/hashtable.h>
 
-#include "bnxt_ulp.h"
-
 #include "roce_hsi.h"
 #include "qplib_res.h"
 #include "qplib_sp.h"
Signature · 1 line
2.5.5
#6 lore raw
In reply to Selvin Xavier
Quoted 8 lines · Selvin Xavier

Some minor code cleanup for bnxt_re.

Please review and apply.

Thanks,
Selvin Xavier

[...]

Applied, thanks!

[1/5] RDMA/bnxt_re: Remove extra new line in bnxt_re_netdev_event

      https://git.kernel.org/rdma/rdma/c/c7f2cfe81e059a
[2/5] RDMA/bnxt_re: Remove unnecessary goto in bnxt_re_netdev_event
      https://git.kernel.org/rdma/rdma/c/ae51cb98213268
[3/5] RDMA/bnxt_re: Optimize error handling in bnxt_re_probe
      https://git.kernel.org/rdma/rdma/c/55992c386263f3
[4/5] RDMA/bnxt_re: Eliminate need for some forward declarations
      https://git.kernel.org/rdma/rdma/c/8aa3dd3e765912
[5/5] RDMA/bnxt_re: Remove unnecessary header file inclusion
      https://git.kernel.org/rdma/rdma/c/1950af31dc6648

Best regards,

Signature · 1 line
Leon Romanovsky <[email protected]>