netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vmxnet3: remove set_flag_le{16,64} functions
@ 2010-10-16  7:33 Harvey Harrison
  2010-10-16 15:57 ` Shreyas Bhatewara
  0 siblings, 1 reply; 3+ messages in thread
From: Harvey Harrison @ 2010-10-16  7:33 UTC (permalink / raw)
  To: sbhatewara; +Cc: netdev, shemminger

Opencode the flag setting in the few places it was being done.

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
 drivers/net/vmxnet3/vmxnet3_drv.c     |   35 +++++++-------------------------
 drivers/net/vmxnet3/vmxnet3_ethtool.c |   10 +++-----
 drivers/net/vmxnet3/vmxnet3_int.h     |    4 ---
 3 files changed, 12 insertions(+), 37 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index 198ce92..c52d259 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1548,23 +1548,6 @@ vmxnet3_free_irqs(struct vmxnet3_adapter *adapter)
 	}
 }
 
-
-inline void set_flag_le16(__le16 *data, u16 flag)
-{
-	*data = cpu_to_le16(le16_to_cpu(*data) | flag);
-}
-
-inline void set_flag_le64(__le64 *data, u64 flag)
-{
-	*data = cpu_to_le64(le64_to_cpu(*data) | flag);
-}
-
-inline void reset_flag_le64(__le64 *data, u64 flag)
-{
-	*data = cpu_to_le64(le64_to_cpu(*data) & ~flag);
-}
-
-
 static void
 vmxnet3_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
 {
@@ -1580,8 +1563,7 @@ vmxnet3_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
 			adapter->vlan_grp = grp;
 
 			/* update FEATURES to device */
-			set_flag_le64(&devRead->misc.uptFeatures,
-				      UPT1_F_RXVLAN);
+			devRead->misc.uptFeatures |= cpu_to_le64(UPT1_F_RXVLAN);
 			VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
 					       VMXNET3_CMD_UPDATE_FEATURE);
 			/*
@@ -1617,8 +1599,7 @@ vmxnet3_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
 					       VMXNET3_CMD_UPDATE_VLAN_FILTERS);
 
 			/* update FEATURES to device */
-			reset_flag_le64(&devRead->misc.uptFeatures,
-					UPT1_F_RXVLAN);
+			devRead->misc.uptFeatures |= cpu_to_le64(UPT1_F_RXVLAN);
 			VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
 					       VMXNET3_CMD_UPDATE_FEATURE);
 		}
@@ -1779,15 +1760,15 @@ vmxnet3_setup_driver_shared(struct vmxnet3_adapter *adapter)
 
 	/* set up feature flags */
 	if (adapter->rxcsum)
-		set_flag_le64(&devRead->misc.uptFeatures, UPT1_F_RXCSUM);
+		devRead->misc.uptFeatures |= cpu_to_le64(UPT1_F_RXCSUM);
 
 	if (adapter->lro) {
-		set_flag_le64(&devRead->misc.uptFeatures, UPT1_F_LRO);
+		devRead->misc.uptFeatures |= cpu_to_le64(UPT1_F_LRO);
 		devRead->misc.maxNumRxSG = cpu_to_le16(1 + MAX_SKB_FRAGS);
 	}
 	if ((adapter->netdev->features & NETIF_F_HW_VLAN_RX) &&
 	    adapter->vlan_grp) {
-		set_flag_le64(&devRead->misc.uptFeatures, UPT1_F_RXVLAN);
+		devRead->misc.uptFeatures |= cpu_to_le64(UPT1_F_RXVLAN);
 	}
 
 	devRead->misc.mtu = cpu_to_le32(adapter->netdev->mtu);
@@ -2594,7 +2575,7 @@ vmxnet3_suspend(struct device *device)
 		memcpy(pmConf->filters[i].pattern, netdev->dev_addr, ETH_ALEN);
 		pmConf->filters[i].mask[0] = 0x3F; /* LSB ETH_ALEN bits */
 
-		set_flag_le16(&pmConf->wakeUpEvents, VMXNET3_PM_WAKEUP_FILTER);
+		pmConf->wakeUpEvents |= cpu_to_le16(VMXNET3_PM_WAKEUP_FILTER);
 		i++;
 	}
 
@@ -2636,13 +2617,13 @@ vmxnet3_suspend(struct device *device)
 		pmConf->filters[i].mask[5] = 0x03; /* IPv4 TIP */
 		in_dev_put(in_dev);
 
-		set_flag_le16(&pmConf->wakeUpEvents, VMXNET3_PM_WAKEUP_FILTER);
+		pmConf->wakeUpEvents |= cpu_to_le16(VMXNET3_PM_WAKEUP_FILTER);
 		i++;
 	}
 
 skip_arp:
 	if (adapter->wol & WAKE_MAGIC)
-		set_flag_le16(&pmConf->wakeUpEvents, VMXNET3_PM_WAKEUP_MAGIC);
+		pmConf->wakeUpEvents |= cpu_to_le16(VMXNET3_PM_WAKEUP_MAGIC);
 
 	pmConf->numFilters = i;
 
diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c b/drivers/net/vmxnet3/vmxnet3_ethtool.c
index 7e4b5a8..79a72e8 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethtool.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c
@@ -50,13 +50,11 @@ vmxnet3_set_rx_csum(struct net_device *netdev, u32 val)
 		adapter->rxcsum = val;
 		if (netif_running(netdev)) {
 			if (val)
-				set_flag_le64(
-				&adapter->shared->devRead.misc.uptFeatures,
-				UPT1_F_RXCSUM);
+				adapter->shared->devRead.misc.uptFeatures |=
+					cpu_to_le64(UPT1_F_RXCSUM);
 			else
-				reset_flag_le64(
-				&adapter->shared->devRead.misc.uptFeatures,
-				UPT1_F_RXCSUM);
+				adapter->shared->devRead.misc.uptFeatures &= 
+					~cpu_to_le64(UPT1_F_RXCSUM);
 
 			VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
 					       VMXNET3_CMD_UPDATE_FEATURE);
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h
index 2121c73..46aee6d 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -353,10 +353,6 @@ struct vmxnet3_adapter {
 #define VMXNET3_MAX_ETH_HDR_SIZE    22
 #define VMXNET3_MAX_SKB_BUF_SIZE    (3*1024)
 
-void set_flag_le16(__le16 *data, u16 flag);
-void set_flag_le64(__le64 *data, u64 flag);
-void reset_flag_le64(__le64 *data, u64 flag);
-
 int
 vmxnet3_quiesce_dev(struct vmxnet3_adapter *adapter);
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] vmxnet3: remove set_flag_le{16,64} functions
  2010-10-16  7:33 [PATCH] vmxnet3: remove set_flag_le{16,64} functions Harvey Harrison
@ 2010-10-16 15:57 ` Shreyas Bhatewara
  2010-10-18 18:44   ` Harvey Harrison
  0 siblings, 1 reply; 3+ messages in thread
From: Shreyas Bhatewara @ 2010-10-16 15:57 UTC (permalink / raw)
  To: Harvey Harrison; +Cc: netdev@vger.kernel.org, shemminger@vyatta.com

________________________________________
From: Harvey Harrison [harvey.harrison@gmail.com]
Sent: Saturday, October 16, 2010 12:33 AM
To: Shreyas Bhatewara
Cc: netdev@vger.kernel.org; shemminger@vyatta.com
Subject: [PATCH] vmxnet3: remove set_flag_le{16,64} functions

Opencode the flag setting in the few places it was being done.

Signed-off-by: Harvey Harrison harvey.harrison@gmail.com
---
@@ -1617,8 +1599,7 @@ vmxnet3_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
                                               VMXNET3_CMD_UPDATE_VLAN_FILTERS);

                        /* update FEATURES to device */
-                       reset_flag_le64(&devRead->misc.uptFeatures,
-                                       UPT1_F_RXVLAN);
+                       devRead->misc.uptFeatures |= cpu_to_le64(UPT1_F_RXVLAN);
                        VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
                                               VMXNET3_CMD_UPDATE_FEATURE);
                }


This hunk is wrong, UPT1_F_RXVLAN should be reset here.

I fail to understand why set/reset functions were not good enough and why this opencoding is required. I agree with your earlier suggestion about replacing two conversions with *data |= cpu_to_le16(flag); though.


Regards.
Shreyas

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] vmxnet3: remove set_flag_le{16,64} functions
  2010-10-16 15:57 ` Shreyas Bhatewara
@ 2010-10-18 18:44   ` Harvey Harrison
  0 siblings, 0 replies; 3+ messages in thread
From: Harvey Harrison @ 2010-10-18 18:44 UTC (permalink / raw)
  To: Shreyas Bhatewara; +Cc: netdev@vger.kernel.org, shemminger@vyatta.com

On Sat, Oct 16, 2010 at 8:57 AM, Shreyas Bhatewara
<sbhatewara@vmware.com> wrote:
> This hunk is wrong, UPT1_F_RXVLAN should be reset here.
>
> I fail to understand why set/reset functions were not good enough and why this opencoding is required. I agree with your earlier suggestion about replacing two conversions with *data |= cpu_to_le16(flag); though.
>
>

There's nothing really _wrong_ with them, they are a bit special-case,
and they are incomplete in that there is only 16/64 and
no 32 bit version.  And the naming is usually set/clear rather than set/reset.

That, and they are used so infrequently, why not just define the
constants as little endian and then it's just
use regular bitwise math which is common everywhere in networking?
Then others reading your driver don't have
to go look at a special-case set/reset function...it's just or'ing a flag.

I'll send a patch this evening so you can see what it would look like.

Harvey

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-10-18 18:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-16  7:33 [PATCH] vmxnet3: remove set_flag_le{16,64} functions Harvey Harrison
2010-10-16 15:57 ` Shreyas Bhatewara
2010-10-18 18:44   ` Harvey Harrison

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).