DPDK patches and discussions
 help / color / mirror / Atom feed
From: Wang Xiao W <xiao.w.wang@intel.com>
To: jing.d.chen@intel.com
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2 08/16] fm10k/base: use BIT macro instead of open-coded bit-shifting of 1
Date: Wed, 27 Jan 2016 11:50:39 +0800	[thread overview]
Message-ID: <1453866647-16215-9-git-send-email-xiao.w.wang@intel.com> (raw)
In-Reply-To: <1453866647-16215-1-git-send-email-xiao.w.wang@intel.com>

The upstream Linux kernel community prefers using the BIT macro over
bit-shifting a 1.  Similar to how this is handled in the i40e shared code,
define a macro for OSes that do not already have it and wrap all that in
LINUX_MACROS so that it can be stripped from the Linux driver.

The upstream Linux kernel community prefers avoiding CamelCase in
variables, function names, etc.

Signed-off-by: Wang Xiao W <xiao.w.wang@intel.com>
---
 drivers/net/fm10k/base/fm10k_pf.c   | 12 ++++++------
 drivers/net/fm10k/base/fm10k_tlv.c  | 24 ++++++++++++------------
 drivers/net/fm10k/base/fm10k_type.h | 18 ++++++++++++------
 3 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/drivers/net/fm10k/base/fm10k_pf.c b/drivers/net/fm10k/base/fm10k_pf.c
index 3ee88b6..7d48210 100644
--- a/drivers/net/fm10k/base/fm10k_pf.c
+++ b/drivers/net/fm10k/base/fm10k_pf.c
@@ -576,8 +576,8 @@ STATIC s32 fm10k_configure_dglort_map_pf(struct fm10k_hw *hw,
 		return FM10K_ERR_PARAM;
 
 	/* determine count of VSIs and queues */
-	queue_count = 1 << (dglort->rss_l + dglort->pc_l);
-	vsi_count = 1 << (dglort->vsi_l + dglort->queue_l);
+	queue_count = BIT(dglort->rss_l + dglort->pc_l);
+	vsi_count = BIT(dglort->vsi_l + dglort->queue_l);
 	glort = dglort->glort;
 	q_idx = dglort->queue_b;
 
@@ -593,8 +593,8 @@ STATIC s32 fm10k_configure_dglort_map_pf(struct fm10k_hw *hw,
 	}
 
 	/* determine count of PCs and queues */
-	queue_count = 1 << (dglort->queue_l + dglort->rss_l + dglort->vsi_l);
-	pc_count = 1 << dglort->pc_l;
+	queue_count = BIT(dglort->queue_l + dglort->rss_l + dglort->vsi_l);
+	pc_count = BIT(dglort->pc_l);
 
 	/* configure PC for Tx queues */
 	for (pc = 0; pc < pc_count; pc++) {
@@ -1001,7 +1001,7 @@ STATIC s32 fm10k_iov_reset_resources_pf(struct fm10k_hw *hw,
 		return FM10K_ERR_PARAM;
 
 	/* clear event notification of VF FLR */
-	FM10K_WRITE_REG(hw, FM10K_PFVFLREC(vf_idx / 32), 1 << (vf_idx % 32));
+	FM10K_WRITE_REG(hw, FM10K_PFVFLREC(vf_idx / 32), BIT(vf_idx % 32));
 
 	/* force timeout and then disconnect the mailbox */
 	vf_info->mbx.timeout = 0;
@@ -1417,7 +1417,7 @@ s32 fm10k_iov_msg_lport_state_pf(struct fm10k_hw *hw, u32 **results,
 		mode = fm10k_iov_supported_xcast_mode_pf(vf_info, mode);
 
 		/* if mode is not currently enabled, enable it */
-		if (!(FM10K_VF_FLAG_ENABLED(vf_info) & (1 << mode)))
+		if (!(FM10K_VF_FLAG_ENABLED(vf_info) & BIT(mode)))
 			fm10k_update_xcast_mode_pf(hw, vf_info->glort, mode);
 
 		/* swap mode back to a bit flag */
diff --git a/drivers/net/fm10k/base/fm10k_tlv.c b/drivers/net/fm10k/base/fm10k_tlv.c
index ade87d1..e6150c1 100644
--- a/drivers/net/fm10k/base/fm10k_tlv.c
+++ b/drivers/net/fm10k/base/fm10k_tlv.c
@@ -249,7 +249,7 @@ s32 fm10k_tlv_attr_put_value(u32 *msg, u16 attr_id, s64 value, u32 len)
 	attr = &msg[FM10K_TLV_DWORD_LEN(*msg)];
 
 	if (len < 4) {
-		attr[1] = (u32)value & ((0x1ul << (8 * len)) - 1);
+		attr[1] = (u32)value & (BIT(8 * len) - 1);
 	} else {
 		attr[1] = (u32)value;
 		if (len > 4)
@@ -699,29 +699,29 @@ STATIC void fm10k_tlv_msg_test_generate_data(u32 *msg, u32 attr_flags)
 {
 	DEBUGFUNC("fm10k_tlv_msg_test_generate_data");
 
-	if (attr_flags & (1 << FM10K_TEST_MSG_STRING))
+	if (attr_flags & BIT(FM10K_TEST_MSG_STRING))
 		fm10k_tlv_attr_put_null_string(msg, FM10K_TEST_MSG_STRING,
 					       test_str);
-	if (attr_flags & (1 << FM10K_TEST_MSG_MAC_ADDR))
+	if (attr_flags & BIT(FM10K_TEST_MSG_MAC_ADDR))
 		fm10k_tlv_attr_put_mac_vlan(msg, FM10K_TEST_MSG_MAC_ADDR,
 					    test_mac, test_vlan);
-	if (attr_flags & (1 << FM10K_TEST_MSG_U8))
+	if (attr_flags & BIT(FM10K_TEST_MSG_U8))
 		fm10k_tlv_attr_put_u8(msg, FM10K_TEST_MSG_U8,  test_u8);
-	if (attr_flags & (1 << FM10K_TEST_MSG_U16))
+	if (attr_flags & BIT(FM10K_TEST_MSG_U16))
 		fm10k_tlv_attr_put_u16(msg, FM10K_TEST_MSG_U16, test_u16);
-	if (attr_flags & (1 << FM10K_TEST_MSG_U32))
+	if (attr_flags & BIT(FM10K_TEST_MSG_U32))
 		fm10k_tlv_attr_put_u32(msg, FM10K_TEST_MSG_U32, test_u32);
-	if (attr_flags & (1 << FM10K_TEST_MSG_U64))
+	if (attr_flags & BIT(FM10K_TEST_MSG_U64))
 		fm10k_tlv_attr_put_u64(msg, FM10K_TEST_MSG_U64, test_u64);
-	if (attr_flags & (1 << FM10K_TEST_MSG_S8))
+	if (attr_flags & BIT(FM10K_TEST_MSG_S8))
 		fm10k_tlv_attr_put_s8(msg, FM10K_TEST_MSG_S8,  test_s8);
-	if (attr_flags & (1 << FM10K_TEST_MSG_S16))
+	if (attr_flags & BIT(FM10K_TEST_MSG_S16))
 		fm10k_tlv_attr_put_s16(msg, FM10K_TEST_MSG_S16, test_s16);
-	if (attr_flags & (1 << FM10K_TEST_MSG_S32))
+	if (attr_flags & BIT(FM10K_TEST_MSG_S32))
 		fm10k_tlv_attr_put_s32(msg, FM10K_TEST_MSG_S32, test_s32);
-	if (attr_flags & (1 << FM10K_TEST_MSG_S64))
+	if (attr_flags & BIT(FM10K_TEST_MSG_S64))
 		fm10k_tlv_attr_put_s64(msg, FM10K_TEST_MSG_S64, test_s64);
-	if (attr_flags & (1 << FM10K_TEST_MSG_LE_STRUCT))
+	if (attr_flags & BIT(FM10K_TEST_MSG_LE_STRUCT))
 		fm10k_tlv_attr_put_le_struct(msg, FM10K_TEST_MSG_LE_STRUCT,
 					     test_le, 8);
 }
diff --git a/drivers/net/fm10k/base/fm10k_type.h b/drivers/net/fm10k/base/fm10k_type.h
index 5db6345..387d25b 100644
--- a/drivers/net/fm10k/base/fm10k_type.h
+++ b/drivers/net/fm10k/base/fm10k_type.h
@@ -50,6 +50,12 @@ struct fm10k_hw;
 #define FM10K_DEV_ID_SDI_FM10420_DA2	0x15D5
 #endif /* ATWOOD_CHANNEL_HW */
 
+#ifndef LINUX_MACROS
+#ifndef BIT
+#define BIT(a) (1UL << (a))
+#endif
+#endif /* LINUX_MACROS */
+
 #define FM10K_MAX_QUEUES		256
 #define FM10K_MAX_QUEUES_PF		128
 #define FM10K_MAX_QUEUES_POOL		16
@@ -465,7 +471,7 @@ struct fm10k_hw;
 #define FM10K_VLAN_TABLE_VID_MAX		4096
 #define FM10K_VLAN_TABLE_VSI_MAX		64
 #define FM10K_VLAN_LENGTH_SHIFT			16
-#define FM10K_VLAN_CLEAR			(1 << 15)
+#define FM10K_VLAN_CLEAR			BIT(15)
 #define FM10K_VLAN_ALL \
 	((FM10K_VLAN_TABLE_VID_MAX - 1) << FM10K_VLAN_LENGTH_SHIFT)
 
@@ -762,10 +768,10 @@ struct fm10k_vf_info {
 						 */
 };
 
-#define FM10K_VF_FLAG_ALLMULTI_CAPABLE	((u8)1 << FM10K_XCAST_MODE_ALLMULTI)
-#define FM10K_VF_FLAG_MULTI_CAPABLE	((u8)1 << FM10K_XCAST_MODE_MULTI)
-#define FM10K_VF_FLAG_PROMISC_CAPABLE	((u8)1 << FM10K_XCAST_MODE_PROMISC)
-#define FM10K_VF_FLAG_NONE_CAPABLE	((u8)1 << FM10K_XCAST_MODE_NONE)
+#define FM10K_VF_FLAG_ALLMULTI_CAPABLE	(u8)(BIT(FM10K_XCAST_MODE_ALLMULTI))
+#define FM10K_VF_FLAG_MULTI_CAPABLE	(u8)(BIT(FM10K_XCAST_MODE_MULTI))
+#define FM10K_VF_FLAG_PROMISC_CAPABLE	(u8)(BIT(FM10K_XCAST_MODE_PROMISC))
+#define FM10K_VF_FLAG_NONE_CAPABLE	(u8)(BIT(FM10K_XCAST_MODE_NONE))
 #define FM10K_VF_FLAG_CAPABLE(vf_info)	((vf_info)->vf_flags & (u8)0xF)
 #define FM10K_VF_FLAG_ENABLED(vf_info)	((vf_info)->vf_flags >> 4)
 #define FM10K_VF_FLAG_SET_MODE(mode)	((u8)0x10 << (mode))
@@ -816,7 +822,7 @@ struct fm10k_hw {
 	u16 subsystem_vendor_id;
 	u8 revision_id;
 	u32 flags;
-#define FM10K_HW_FLAG_CLOCK_OWNER	(u32)(1 << 0)
+#define FM10K_HW_FLAG_CLOCK_OWNER	BIT(0)
 };
 
 /* Number of Transmit and Receive Descriptors must be a multiple of 8 */
-- 
1.9.3

  parent reply	other threads:[~2016-01-27  3:51 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-21 10:35 [dpdk-dev] [PATCH 00/16] fm10k: update shared code from ND team Wang Xiao W
2016-01-21 10:35 ` [dpdk-dev] [PATCH 01/16] fm10k/base: cleanup namespace pollution and correct typecast Wang Xiao W
2016-01-21 10:35 ` [dpdk-dev] [PATCH 02/16] fm10k/base: use bitshift for itr_scale Wang Xiao W
2016-01-21 10:35 ` [dpdk-dev] [PATCH 03/16] fm10k/base: reset max_queues on init_hw_vf failure Wang Xiao W
2016-01-21 10:35 ` [dpdk-dev] [PATCH 04/16] fm10k/base: document ITR scale workaround in VF TDLEN register Wang Xiao W
2016-01-21 10:35 ` [dpdk-dev] [PATCH 05/16] fm10k/base: fix checkpatch warning Wang Xiao W
2016-01-21 10:35 ` [dpdk-dev] [PATCH 06/16] fm10k/base: use BIT macro instead of open-coded bit-shifting of 1 Wang Xiao W
2016-01-21 10:35 ` [dpdk-dev] [PATCH 07/16] fm10k/base: do not use CamelCase Wang Xiao W
2016-01-21 10:35 ` [dpdk-dev] [PATCH 08/16] fm10k/base: use memcpy for mac addr copy Wang Xiao W
2016-01-21 10:35 ` [dpdk-dev] [PATCH 09/16] fm10k/base: allow removal of is_slot_appropriate function Wang Xiao W
2016-01-21 10:35 ` [dpdk-dev] [PATCH 10/16] fm10k/base: consistently use VLAN ID when referencing vid variables Wang Xiao W
2016-01-21 10:35 ` [dpdk-dev] [PATCH 11/16] fm10k/base: fix comment per upstream review changes Wang Xiao W
2016-01-21 10:35 ` [dpdk-dev] [PATCH 12/16] fm10k/base: TLV structures must be 4byte aligned, not 1byte aligned Wang Xiao W
2016-01-21 10:35 ` [dpdk-dev] [PATCH 13/16] fm10k/base: move constants to the right of binary operators Wang Xiao W
2016-01-21 10:35 ` [dpdk-dev] [PATCH 14/16] fm10k/base: minor cleanups Wang Xiao W
2016-01-21 10:36 ` [dpdk-dev] [PATCH 15/16] fm10k: use default mailbox message handler for pf Wang Xiao W
2016-01-22 21:31   ` Bruce Richardson
2016-01-25  2:31     ` Wang, Xiao W
2016-01-26 20:16       ` Bruce Richardson
2016-01-27  1:57         ` Wang, Xiao W
2016-01-27  3:50   ` [dpdk-dev] [PATCH v2 00/16] fm10k: update shared code Wang Xiao W
2016-01-27  3:50     ` [dpdk-dev] [PATCH v2 01/16] fm10k: use default mailbox message handler for pf Wang Xiao W
2016-02-16 10:50       ` Bruce Richardson
2016-02-18 10:25         ` Wang, Xiao W
2016-02-19 11:06       ` [dpdk-dev] [PATCH v3 00/18] fm10k: update shared code Wang Xiao W
2016-02-19 11:06         ` [dpdk-dev] [PATCH v3 01/18] fm10k: use default mailbox message handler for PF Wang Xiao W
2016-02-19 11:06         ` [dpdk-dev] [PATCH v3 02/18] fm10k/base: correct typecast in fm10k_update_xc_addr_pf Wang Xiao W
2016-02-19 11:06         ` [dpdk-dev] [PATCH v3 03/18] fm10k/base: cleanup namespace pollution Wang Xiao W
2016-02-19 11:06         ` [dpdk-dev] [PATCH v3 04/18] fm10k/base: use bitshift for itr_scale Wang Xiao W
2016-02-19 11:06         ` [dpdk-dev] [PATCH v3 05/18] fm10k/base: reset max_queues on init_hw_vf failure Wang Xiao W
2016-02-19 11:06         ` [dpdk-dev] [PATCH v3 06/18] fm10k/base: document ITR scale workaround in VF TDLEN register Wang Xiao W
2016-02-19 11:06         ` [dpdk-dev] [PATCH v3 07/18] fm10k/base: cleanup lines over 80 characters Wang Xiao W
2016-02-19 11:06         ` [dpdk-dev] [PATCH v3 08/18] fm10k/base: cleanup useless else Wang Xiao W
2016-02-19 11:06         ` [dpdk-dev] [PATCH v3 09/18] fm10k/base: use BIT macro instead of open-coded bit-shifting of 1 Wang Xiao W
2016-02-19 11:06         ` [dpdk-dev] [PATCH v3 10/18] fm10k/base: do not use CamelCase Wang Xiao W
2016-02-19 11:06         ` [dpdk-dev] [PATCH v3 11/18] fm10k/base: use memcpy for mac addr copy Wang Xiao W
2016-02-19 11:06         ` [dpdk-dev] [PATCH v3 12/18] fm10k/base: allow removal of is_slot_appropriate function Wang Xiao W
2016-02-19 11:07         ` [dpdk-dev] [PATCH v3 13/18] fm10k/base: consistently use VLAN ID when referencing vid variables Wang Xiao W
2016-02-19 11:07         ` [dpdk-dev] [PATCH v3 14/18] fm10k/base: imporve comment per upstream review changes Wang Xiao W
2016-02-19 11:07         ` [dpdk-dev] [PATCH v3 15/18] fm10k/base: fix TLV structures alignment Wang Xiao W
2016-02-19 11:07         ` [dpdk-dev] [PATCH v3 16/18] fm10k/base: move constants to the right of binary operators Wang Xiao W
2016-02-19 11:07         ` [dpdk-dev] [PATCH v3 17/18] fm10k/base: minor cleanups Wang Xiao W
2016-02-19 11:07         ` [dpdk-dev] [PATCH v3 18/18] fm10k/base: remove unused struct element Wang Xiao W
2016-02-29  2:30         ` [dpdk-dev] [PATCH v3 00/18] fm10k: update shared code Ding, HengX
2016-03-08 16:27           ` Bruce Richardson
2016-03-08 13:24         ` Bruce Richardson
2016-03-08 14:15           ` Wang, Xiao W
2016-03-08 14:25             ` Chen, Jing D
2016-03-08 14:32               ` Wang, Xiao W
2016-03-08 14:53               ` Bruce Richardson
2016-01-27  3:50     ` [dpdk-dev] [PATCH v2 02/16] fm10k/base: add macro definitions that are needed Wang Xiao W
2016-02-16 10:52       ` Bruce Richardson
2016-01-27  3:50     ` [dpdk-dev] [PATCH v2 03/16] fm10k/base: cleanup namespace pollution and correct typecast Wang Xiao W
2016-02-16 10:55       ` Bruce Richardson
2016-01-27  3:50     ` [dpdk-dev] [PATCH v2 04/16] fm10k/base: use bitshift for itr_scale Wang Xiao W
2016-01-27  3:50     ` [dpdk-dev] [PATCH v2 05/16] fm10k/base: reset max_queues on init_hw_vf failure Wang Xiao W
2016-01-27  3:50     ` [dpdk-dev] [PATCH v2 06/16] fm10k/base: document ITR scale workaround in VF TDLEN register Wang Xiao W
2016-01-27  3:50     ` [dpdk-dev] [PATCH v2 07/16] fm10k/base: fix checkpatch warning Wang Xiao W
2016-01-27  3:50     ` Wang Xiao W [this message]
2016-01-27  3:50     ` [dpdk-dev] [PATCH v2 09/16] fm10k/base: do not use CamelCase Wang Xiao W
2016-01-27  3:50     ` [dpdk-dev] [PATCH v2 10/16] fm10k/base: use memcpy for mac addr copy Wang Xiao W
2016-01-27  3:50     ` [dpdk-dev] [PATCH v2 11/16] fm10k/base: allow removal of is_slot_appropriate function Wang Xiao W
2016-01-27  3:50     ` [dpdk-dev] [PATCH v2 12/16] fm10k/base: consistently use VLAN ID when referencing vid variables Wang Xiao W
2016-01-27  3:50     ` [dpdk-dev] [PATCH v2 13/16] fm10k/base: fix comment per upstream review changes Wang Xiao W
2016-01-27  3:50     ` [dpdk-dev] [PATCH v2 14/16] fm10k/base: TLV structures must be 4byte aligned, not 1byte aligned Wang Xiao W
2016-01-27  3:50     ` [dpdk-dev] [PATCH v2 15/16] fm10k/base: move constants to the right of binary operators Wang Xiao W
2016-01-27  3:50     ` [dpdk-dev] [PATCH v2 16/16] fm10k/base: minor cleanups Wang Xiao W
2016-02-16  8:11     ` [dpdk-dev] [PATCH v2 00/16] fm10k: update shared code Chen, Jing D
2016-01-21 10:36 ` [dpdk-dev] [PATCH 16/16] fm10k/base: add macro definitions that are needed Wang Xiao W

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=1453866647-16215-9-git-send-email-xiao.w.wang@intel.com \
    --to=xiao.w.wang@intel.com \
    --cc=dev@dpdk.org \
    --cc=jing.d.chen@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).