Skip to content

Commit fcdb0a9

Browse files
bwallanJeff Kirsher
authored andcommitted
fm10k: cleanup remaining right-bit-shifted 1
Use BIT() macro instead. Signed-off-by: Bruce Allan <[email protected]> Tested-by: Krishneil Singh <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 1aab144 commit fcdb0a9

File tree

8 files changed

+52
-54
lines changed

8 files changed

+52
-54
lines changed

drivers/net/ethernet/intel/fm10k/fm10k.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,12 @@ struct fm10k_intfc {
262262
unsigned long state;
263263

264264
u32 flags;
265-
#define FM10K_FLAG_RESET_REQUESTED (u32)(1 << 0)
266-
#define FM10K_FLAG_RSS_FIELD_IPV4_UDP (u32)(1 << 1)
267-
#define FM10K_FLAG_RSS_FIELD_IPV6_UDP (u32)(1 << 2)
268-
#define FM10K_FLAG_RX_TS_ENABLED (u32)(1 << 3)
269-
#define FM10K_FLAG_SWPRI_CONFIG (u32)(1 << 4)
270-
#define FM10K_FLAG_DEBUG_STATS (u32)(1 << 5)
265+
#define FM10K_FLAG_RESET_REQUESTED (u32)(BIT(0))
266+
#define FM10K_FLAG_RSS_FIELD_IPV4_UDP (u32)(BIT(1))
267+
#define FM10K_FLAG_RSS_FIELD_IPV6_UDP (u32)(BIT(2))
268+
#define FM10K_FLAG_RX_TS_ENABLED (u32)(BIT(3))
269+
#define FM10K_FLAG_SWPRI_CONFIG (u32)(BIT(4))
270+
#define FM10K_FLAG_DEBUG_STATS (u32)(BIT(5))
271271
int xcast_mode;
272272

273273
/* Tx fast path data */

drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ static void fm10k_get_regs(struct net_device *netdev,
425425
u32 *buff = p;
426426
u16 i;
427427

428-
regs->version = (1 << 24) | (hw->revision_id << 16) | hw->device_id;
428+
regs->version = BIT(24) | (hw->revision_id << 16) | hw->device_id;
429429

430430
switch (hw->mac.type) {
431431
case fm10k_mac_pf:
@@ -942,8 +942,8 @@ static int fm10k_mbx_test(struct fm10k_intfc *interface, u64 *data)
942942
return 0;
943943

944944
/* loop through both nested and unnested attribute types */
945-
for (attr_flag = (1 << FM10K_TEST_MSG_UNSET);
946-
attr_flag < (1 << (2 * FM10K_TEST_MSG_NESTED));
945+
for (attr_flag = BIT(FM10K_TEST_MSG_UNSET);
946+
attr_flag < BIT(2 * FM10K_TEST_MSG_NESTED);
947947
attr_flag += attr_flag) {
948948
/* generate message to be tested */
949949
fm10k_tlv_msg_test_create(test_msg, attr_flag);
@@ -1005,7 +1005,7 @@ static u32 fm10k_get_priv_flags(struct net_device *netdev)
10051005
u32 priv_flags = 0;
10061006

10071007
if (interface->flags & FM10K_FLAG_DEBUG_STATS)
1008-
priv_flags |= 1 << FM10K_PRV_FLAG_DEBUG_STATS;
1008+
priv_flags |= BIT(FM10K_PRV_FLAG_DEBUG_STATS);
10091009

10101010
return priv_flags;
10111011
}
@@ -1014,10 +1014,10 @@ static int fm10k_set_priv_flags(struct net_device *netdev, u32 priv_flags)
10141014
{
10151015
struct fm10k_intfc *interface = netdev_priv(netdev);
10161016

1017-
if (priv_flags >= (1 << FM10K_PRV_FLAG_LEN))
1017+
if (priv_flags >= BIT(FM10K_PRV_FLAG_LEN))
10181018
return -EINVAL;
10191019

1020-
if (priv_flags & (1 << FM10K_PRV_FLAG_DEBUG_STATS))
1020+
if (priv_flags & BIT(FM10K_PRV_FLAG_DEBUG_STATS))
10211021
interface->flags |= FM10K_FLAG_DEBUG_STATS;
10221022
else
10231023
interface->flags &= ~FM10K_FLAG_DEBUG_STATS;
@@ -1145,7 +1145,7 @@ static unsigned int fm10k_max_channels(struct net_device *dev)
11451145

11461146
/* For QoS report channels per traffic class */
11471147
if (tcs > 1)
1148-
max_combined = 1 << (fls(max_combined / tcs) - 1);
1148+
max_combined = BIT((fls(max_combined / tcs) - 1));
11491149

11501150
return max_combined;
11511151
}
@@ -1210,11 +1210,9 @@ static int fm10k_get_ts_info(struct net_device *dev,
12101210
else
12111211
info->phc_index = -1;
12121212

1213-
info->tx_types = (1 << HWTSTAMP_TX_OFF) |
1214-
(1 << HWTSTAMP_TX_ON);
1213+
info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON);
12151214

1216-
info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
1217-
(1 << HWTSTAMP_FILTER_ALL);
1215+
info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) | BIT(HWTSTAMP_FILTER_ALL);
12181216

12191217
return 0;
12201218
}

drivers/net/ethernet/intel/fm10k/fm10k_main.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,10 @@ static inline void fm10k_rx_checksum(struct fm10k_ring *ring,
401401
}
402402

403403
#define FM10K_RSS_L4_TYPES_MASK \
404-
((1ul << FM10K_RSSTYPE_IPV4_TCP) | \
405-
(1ul << FM10K_RSSTYPE_IPV4_UDP) | \
406-
(1ul << FM10K_RSSTYPE_IPV6_TCP) | \
407-
(1ul << FM10K_RSSTYPE_IPV6_UDP))
404+
(BIT(FM10K_RSSTYPE_IPV4_TCP) | \
405+
BIT(FM10K_RSSTYPE_IPV4_UDP) | \
406+
BIT(FM10K_RSSTYPE_IPV6_TCP) | \
407+
BIT(FM10K_RSSTYPE_IPV6_UDP))
408408

409409
static inline void fm10k_rx_hash(struct fm10k_ring *ring,
410410
union fm10k_rx_desc *rx_desc,
@@ -420,7 +420,7 @@ static inline void fm10k_rx_hash(struct fm10k_ring *ring,
420420
return;
421421

422422
skb_set_hash(skb, le32_to_cpu(rx_desc->d.rss),
423-
((1ul << rss_type) & FM10K_RSS_L4_TYPES_MASK) ?
423+
(BIT(rss_type) & FM10K_RSS_L4_TYPES_MASK) ?
424424
PKT_HASH_TYPE_L4 : PKT_HASH_TYPE_L3);
425425
}
426426

@@ -1409,7 +1409,7 @@ static void fm10k_update_itr(struct fm10k_ring_container *ring_container)
14091409
* accounts for changes in the ITR due to PCIe link speed.
14101410
*/
14111411
itr_round = ACCESS_ONCE(ring_container->itr_scale) + 8;
1412-
avg_wire_size += (1 << itr_round) - 1;
1412+
avg_wire_size += BIT(itr_round) - 1;
14131413
avg_wire_size >>= itr_round;
14141414

14151415
/* write back value and retain adaptive flag */
@@ -1511,17 +1511,17 @@ static bool fm10k_set_qos_queues(struct fm10k_intfc *interface)
15111511
/* set QoS mask and indices */
15121512
f = &interface->ring_feature[RING_F_QOS];
15131513
f->indices = pcs;
1514-
f->mask = (1 << fls(pcs - 1)) - 1;
1514+
f->mask = BIT(fls(pcs - 1)) - 1;
15151515

15161516
/* determine the upper limit for our current DCB mode */
15171517
rss_i = interface->hw.mac.max_queues / pcs;
1518-
rss_i = 1 << (fls(rss_i) - 1);
1518+
rss_i = BIT(fls(rss_i) - 1);
15191519

15201520
/* set RSS mask and indices */
15211521
f = &interface->ring_feature[RING_F_RSS];
15221522
rss_i = min_t(u16, rss_i, f->limit);
15231523
f->indices = rss_i;
1524-
f->mask = (1 << fls(rss_i - 1)) - 1;
1524+
f->mask = BIT(fls(rss_i - 1)) - 1;
15251525

15261526
/* configure pause class to queue mapping */
15271527
for (i = 0; i < pcs; i++)
@@ -1551,7 +1551,7 @@ static bool fm10k_set_rss_queues(struct fm10k_intfc *interface)
15511551

15521552
/* record indices and power of 2 mask for RSS */
15531553
f->indices = rss_i;
1554-
f->mask = (1 << fls(rss_i - 1)) - 1;
1554+
f->mask = BIT(fls(rss_i - 1)) - 1;
15551555

15561556
interface->num_rx_queues = rss_i;
15571557
interface->num_tx_queues = rss_i;

drivers/net/ethernet/intel/fm10k/fm10k_netdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ struct net_device *fm10k_alloc_netdev(const struct fm10k_info *info)
14291429

14301430
/* configure default debug level */
14311431
interface = netdev_priv(dev);
1432-
interface->msg_enable = (1 << DEFAULT_DEBUG_LEVEL_SHIFT) - 1;
1432+
interface->msg_enable = BIT(DEFAULT_DEBUG_LEVEL_SHIFT) - 1;
14331433

14341434
/* configure default features */
14351435
dev->features |= NETIF_F_IP_CSUM |

drivers/net/ethernet/intel/fm10k/fm10k_pci.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ static void fm10k_configure_tx_ring(struct fm10k_intfc *interface,
579579
u64 tdba = ring->dma;
580580
u32 size = ring->count * sizeof(struct fm10k_tx_desc);
581581
u32 txint = FM10K_INT_MAP_DISABLE;
582-
u32 txdctl = (1 << FM10K_TXDCTL_MAX_TIME_SHIFT) | FM10K_TXDCTL_ENABLE;
582+
u32 txdctl = BIT(FM10K_TXDCTL_MAX_TIME_SHIFT) | FM10K_TXDCTL_ENABLE;
583583
u8 reg_idx = ring->reg_idx;
584584

585585
/* disable queue to avoid issues while updating state */
@@ -730,7 +730,7 @@ static void fm10k_configure_rx_ring(struct fm10k_intfc *interface,
730730
if (interface->pfc_en)
731731
rx_pause = interface->pfc_en;
732732
#endif
733-
if (!(rx_pause & (1 << ring->qos_pc)))
733+
if (!(rx_pause & BIT(ring->qos_pc)))
734734
rxdctl |= FM10K_RXDCTL_DROP_ON_EMPTY;
735735

736736
fm10k_write_reg(hw, FM10K_RXDCTL(reg_idx), rxdctl);
@@ -779,7 +779,7 @@ void fm10k_update_rx_drop_en(struct fm10k_intfc *interface)
779779
u32 rxdctl = FM10K_RXDCTL_WRITE_BACK_MIN_DELAY;
780780
u8 reg_idx = ring->reg_idx;
781781

782-
if (!(rx_pause & (1 << ring->qos_pc)))
782+
if (!(rx_pause & BIT(ring->qos_pc)))
783783
rxdctl |= FM10K_RXDCTL_DROP_ON_EMPTY;
784784

785785
fm10k_write_reg(hw, FM10K_RXDCTL(reg_idx), rxdctl);
@@ -1065,7 +1065,7 @@ static void fm10k_reset_drop_on_empty(struct fm10k_intfc *interface, u32 eicr)
10651065
if (maxholdq)
10661066
fm10k_write_reg(hw, FM10K_MAXHOLDQ(7), maxholdq);
10671067
for (q = 255;;) {
1068-
if (maxholdq & (1 << 31)) {
1068+
if (maxholdq & BIT(31)) {
10691069
if (q < FM10K_MAX_QUEUES_PF) {
10701070
interface->rx_overrun_pf++;
10711071
fm10k_write_reg(hw, FM10K_RXDCTL(q), rxdctl);

drivers/net/ethernet/intel/fm10k/fm10k_pf.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,8 @@ static s32 fm10k_configure_dglort_map_pf(struct fm10k_hw *hw,
527527
return FM10K_ERR_PARAM;
528528

529529
/* determine count of VSIs and queues */
530-
queue_count = 1 << (dglort->rss_l + dglort->pc_l);
531-
vsi_count = 1 << (dglort->vsi_l + dglort->queue_l);
530+
queue_count = BIT(dglort->rss_l + dglort->pc_l);
531+
vsi_count = BIT(dglort->vsi_l + dglort->queue_l);
532532
glort = dglort->glort;
533533
q_idx = dglort->queue_b;
534534

@@ -544,8 +544,8 @@ static s32 fm10k_configure_dglort_map_pf(struct fm10k_hw *hw,
544544
}
545545

546546
/* determine count of PCs and queues */
547-
queue_count = 1 << (dglort->queue_l + dglort->rss_l + dglort->vsi_l);
548-
pc_count = 1 << dglort->pc_l;
547+
queue_count = BIT(dglort->queue_l + dglort->rss_l + dglort->vsi_l);
548+
pc_count = BIT(dglort->pc_l);
549549

550550
/* configure PC for Tx queues */
551551
for (pc = 0; pc < pc_count; pc++) {
@@ -952,7 +952,7 @@ static s32 fm10k_iov_reset_resources_pf(struct fm10k_hw *hw,
952952
return FM10K_ERR_PARAM;
953953

954954
/* clear event notification of VF FLR */
955-
fm10k_write_reg(hw, FM10K_PFVFLREC(vf_idx / 32), 1 << (vf_idx % 32));
955+
fm10k_write_reg(hw, FM10K_PFVFLREC(vf_idx / 32), BIT(vf_idx % 32));
956956

957957
/* force timeout and then disconnect the mailbox */
958958
vf_info->mbx.timeout = 0;
@@ -1370,7 +1370,7 @@ s32 fm10k_iov_msg_lport_state_pf(struct fm10k_hw *hw, u32 **results,
13701370
mode = fm10k_iov_supported_xcast_mode_pf(vf_info, mode);
13711371

13721372
/* if mode is not currently enabled, enable it */
1373-
if (!(FM10K_VF_FLAG_ENABLED(vf_info) & (1 << mode)))
1373+
if (!(FM10K_VF_FLAG_ENABLED(vf_info) & BIT(mode)))
13741374
fm10k_update_xcast_mode_pf(hw, vf_info->glort, mode);
13751375

13761376
/* swap mode back to a bit flag */

drivers/net/ethernet/intel/fm10k/fm10k_tlv.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ s32 fm10k_tlv_attr_put_value(u32 *msg, u16 attr_id, s64 value, u32 len)
222222
attr = &msg[FM10K_TLV_DWORD_LEN(*msg)];
223223

224224
if (len < 4) {
225-
attr[1] = (u32)value & ((0x1ul << (8 * len)) - 1);
225+
attr[1] = (u32)value & (BIT(8 * len) - 1);
226226
} else {
227227
attr[1] = (u32)value;
228228
if (len > 4)
@@ -652,29 +652,29 @@ const struct fm10k_tlv_attr fm10k_tlv_msg_test_attr[] = {
652652
**/
653653
static void fm10k_tlv_msg_test_generate_data(u32 *msg, u32 attr_flags)
654654
{
655-
if (attr_flags & (1 << FM10K_TEST_MSG_STRING))
655+
if (attr_flags & BIT(FM10K_TEST_MSG_STRING))
656656
fm10k_tlv_attr_put_null_string(msg, FM10K_TEST_MSG_STRING,
657657
test_str);
658-
if (attr_flags & (1 << FM10K_TEST_MSG_MAC_ADDR))
658+
if (attr_flags & BIT(FM10K_TEST_MSG_MAC_ADDR))
659659
fm10k_tlv_attr_put_mac_vlan(msg, FM10K_TEST_MSG_MAC_ADDR,
660660
test_mac, test_vlan);
661-
if (attr_flags & (1 << FM10K_TEST_MSG_U8))
661+
if (attr_flags & BIT(FM10K_TEST_MSG_U8))
662662
fm10k_tlv_attr_put_u8(msg, FM10K_TEST_MSG_U8, test_u8);
663-
if (attr_flags & (1 << FM10K_TEST_MSG_U16))
663+
if (attr_flags & BIT(FM10K_TEST_MSG_U16))
664664
fm10k_tlv_attr_put_u16(msg, FM10K_TEST_MSG_U16, test_u16);
665-
if (attr_flags & (1 << FM10K_TEST_MSG_U32))
665+
if (attr_flags & BIT(FM10K_TEST_MSG_U32))
666666
fm10k_tlv_attr_put_u32(msg, FM10K_TEST_MSG_U32, test_u32);
667-
if (attr_flags & (1 << FM10K_TEST_MSG_U64))
667+
if (attr_flags & BIT(FM10K_TEST_MSG_U64))
668668
fm10k_tlv_attr_put_u64(msg, FM10K_TEST_MSG_U64, test_u64);
669-
if (attr_flags & (1 << FM10K_TEST_MSG_S8))
669+
if (attr_flags & BIT(FM10K_TEST_MSG_S8))
670670
fm10k_tlv_attr_put_s8(msg, FM10K_TEST_MSG_S8, test_s8);
671-
if (attr_flags & (1 << FM10K_TEST_MSG_S16))
671+
if (attr_flags & BIT(FM10K_TEST_MSG_S16))
672672
fm10k_tlv_attr_put_s16(msg, FM10K_TEST_MSG_S16, test_s16);
673-
if (attr_flags & (1 << FM10K_TEST_MSG_S32))
673+
if (attr_flags & BIT(FM10K_TEST_MSG_S32))
674674
fm10k_tlv_attr_put_s32(msg, FM10K_TEST_MSG_S32, test_s32);
675-
if (attr_flags & (1 << FM10K_TEST_MSG_S64))
675+
if (attr_flags & BIT(FM10K_TEST_MSG_S64))
676676
fm10k_tlv_attr_put_s64(msg, FM10K_TEST_MSG_S64, test_s64);
677-
if (attr_flags & (1 << FM10K_TEST_MSG_LE_STRUCT))
677+
if (attr_flags & BIT(FM10K_TEST_MSG_LE_STRUCT))
678678
fm10k_tlv_attr_put_le_struct(msg, FM10K_TEST_MSG_LE_STRUCT,
679679
test_le, 8);
680680
}

drivers/net/ethernet/intel/fm10k/fm10k_type.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,10 +617,10 @@ struct fm10k_vf_info {
617617
*/
618618
};
619619

620-
#define FM10K_VF_FLAG_ALLMULTI_CAPABLE ((u8)1 << FM10K_XCAST_MODE_ALLMULTI)
621-
#define FM10K_VF_FLAG_MULTI_CAPABLE ((u8)1 << FM10K_XCAST_MODE_MULTI)
622-
#define FM10K_VF_FLAG_PROMISC_CAPABLE ((u8)1 << FM10K_XCAST_MODE_PROMISC)
623-
#define FM10K_VF_FLAG_NONE_CAPABLE ((u8)1 << FM10K_XCAST_MODE_NONE)
620+
#define FM10K_VF_FLAG_ALLMULTI_CAPABLE (u8)(BIT(FM10K_XCAST_MODE_ALLMULTI))
621+
#define FM10K_VF_FLAG_MULTI_CAPABLE (u8)(BIT(FM10K_XCAST_MODE_MULTI))
622+
#define FM10K_VF_FLAG_PROMISC_CAPABLE (u8)(BIT(FM10K_XCAST_MODE_PROMISC))
623+
#define FM10K_VF_FLAG_NONE_CAPABLE (u8)(BIT(FM10K_XCAST_MODE_NONE))
624624
#define FM10K_VF_FLAG_CAPABLE(vf_info) ((vf_info)->vf_flags & (u8)0xF)
625625
#define FM10K_VF_FLAG_ENABLED(vf_info) ((vf_info)->vf_flags >> 4)
626626
#define FM10K_VF_FLAG_SET_MODE(mode) ((u8)0x10 << (mode))

0 commit comments

Comments
 (0)