DPDK patches and discussions
 help / color / mirror / Atom feed
From: Kalesh A P <kalesh-anakkur.purayil@broadcom.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com, ajit.khaparde@broadcom.com
Subject: [dpdk-dev]  [PATCH 1/3] net/bnxt: rework code to select chip type
Date: Mon,  2 Dec 2019 09:48:07 +0530	[thread overview]
Message-ID: <20191202041809.18370-2-kalesh-anakkur.purayil@broadcom.com> (raw)
In-Reply-To: <20191202041809.18370-1-kalesh-anakkur.purayil@broadcom.com>

From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

Use switch-case statement to replace if-else statement.

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c | 73 ++++++++++++++++++++++++------------------
 1 file changed, 42 insertions(+), 31 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 41848f3..081bb46 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -4028,49 +4028,60 @@ static void bnxt_cancel_fw_health_check(struct bnxt *bp)
 	bp->flags &= ~BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED;
 }
 
-static bool bnxt_vf_pciid(uint16_t id)
+static bool bnxt_vf_pciid(uint16_t device_id)
 {
-	if (id == BROADCOM_DEV_ID_57304_VF ||
-	    id == BROADCOM_DEV_ID_57406_VF ||
-	    id == BROADCOM_DEV_ID_5731X_VF ||
-	    id == BROADCOM_DEV_ID_5741X_VF ||
-	    id == BROADCOM_DEV_ID_57414_VF ||
-	    id == BROADCOM_DEV_ID_STRATUS_NIC_VF1 ||
-	    id == BROADCOM_DEV_ID_STRATUS_NIC_VF2 ||
-	    id == BROADCOM_DEV_ID_58802_VF ||
-	    id == BROADCOM_DEV_ID_57500_VF1 ||
-	    id == BROADCOM_DEV_ID_57500_VF2)
+	switch (device_id) {
+	case BROADCOM_DEV_ID_57304_VF:
+	case BROADCOM_DEV_ID_57406_VF:
+	case BROADCOM_DEV_ID_5731X_VF:
+	case BROADCOM_DEV_ID_5741X_VF:
+	case BROADCOM_DEV_ID_57414_VF:
+	case BROADCOM_DEV_ID_STRATUS_NIC_VF1:
+	case BROADCOM_DEV_ID_STRATUS_NIC_VF2:
+	case BROADCOM_DEV_ID_58802_VF:
+	case BROADCOM_DEV_ID_57500_VF1:
+	case BROADCOM_DEV_ID_57500_VF2:
+		/* FALLTHROUGH */
 		return true;
-	return false;
+	default:
+		return false;
+	}
 }
 
-static bool bnxt_thor_device(uint16_t id)
+static bool bnxt_thor_device(uint16_t device_id)
 {
-	if (id == BROADCOM_DEV_ID_57508 ||
-	    id == BROADCOM_DEV_ID_57504 ||
-	    id == BROADCOM_DEV_ID_57502 ||
-	    id == BROADCOM_DEV_ID_57508_MF1 ||
-	    id == BROADCOM_DEV_ID_57504_MF1 ||
-	    id == BROADCOM_DEV_ID_57502_MF1 ||
-	    id == BROADCOM_DEV_ID_57508_MF2 ||
-	    id == BROADCOM_DEV_ID_57504_MF2 ||
-	    id == BROADCOM_DEV_ID_57502_MF2 ||
-	    id == BROADCOM_DEV_ID_57500_VF1 ||
-	    id == BROADCOM_DEV_ID_57500_VF2)
+	switch (device_id) {
+	case BROADCOM_DEV_ID_57508:
+	case BROADCOM_DEV_ID_57504:
+	case BROADCOM_DEV_ID_57502:
+	case BROADCOM_DEV_ID_57508_MF1:
+	case BROADCOM_DEV_ID_57504_MF1:
+	case BROADCOM_DEV_ID_57502_MF1:
+	case BROADCOM_DEV_ID_57508_MF2:
+	case BROADCOM_DEV_ID_57504_MF2:
+	case BROADCOM_DEV_ID_57502_MF2:
+	case BROADCOM_DEV_ID_57500_VF1:
+	case BROADCOM_DEV_ID_57500_VF2:
+		/* FALLTHROUGH */
 		return true;
-
-	return false;
+	default:
+		return false;
+	}
 }
 
 bool bnxt_stratus_device(struct bnxt *bp)
 {
-	uint16_t id = bp->pdev->id.device_id;
+	uint16_t device_id = bp->pdev->id.device_id;
 
-	if (id == BROADCOM_DEV_ID_STRATUS_NIC ||
-	    id == BROADCOM_DEV_ID_STRATUS_NIC_VF1 ||
-	    id == BROADCOM_DEV_ID_STRATUS_NIC_VF2)
+	switch (device_id) {
+	case BROADCOM_DEV_ID_STRATUS_NIC:
+	case BROADCOM_DEV_ID_STRATUS_NIC_VF1:
+	case BROADCOM_DEV_ID_STRATUS_NIC_VF2:
+		/* FALLTHROUGH */
 		return true;
-	return false;
+	default:
+		return false;
+	}
 }
 
 static int bnxt_init_board(struct rte_eth_dev *eth_dev)
-- 
2.10.1


  reply	other threads:[~2019-12-02  4:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-02  4:18 [dpdk-dev] [PATCH 0/3] updates for bnxt PMD Kalesh A P
2019-12-02  4:18 ` Kalesh A P [this message]
2019-12-02  4:18 ` [dpdk-dev] [PATCH 2/3] net/bnxt: remove an unnecessary log Kalesh A P
2019-12-02  4:18 ` [dpdk-dev] [PATCH 3/3] net/bnxt: use macro for getting default vnic Kalesh A P
2019-12-05 18:10 ` [dpdk-dev] [PATCH 0/3] updates for bnxt PMD Ajit Khaparde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191202041809.18370-2-kalesh-anakkur.purayil@broadcom.com \
    --to=kalesh-anakkur.purayil@broadcom.com \
    --cc=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).