netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] vmxnet3: make bit twiddle routines inline
@ 2010-10-15 21:06 Stephen Hemminger
  2010-10-15 21:14 ` Shreyas Bhatewara
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Stephen Hemminger @ 2010-10-15 21:06 UTC (permalink / raw)
  To: Shreyas Bhatewara, David S. Miller; +Cc: VMware, Inc., netdev

Gcc doesn't usually handle inline across compilation units, and the
functions don't have to be global in scope. Move the set/reset flag
functions int the existing vmxnet3 header.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

---
 drivers/net/vmxnet3/vmxnet3_drv.c |   17 -----------------
 drivers/net/vmxnet3/vmxnet3_int.h |   17 ++++++++++++++---
 2 files changed, 14 insertions(+), 20 deletions(-)

--- a/drivers/net/vmxnet3/vmxnet3_drv.c	2010-10-15 13:58:23.378722695 -0700
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c	2010-10-15 13:59:32.724873755 -0700
@@ -1548,23 +1548,6 @@ vmxnet3_free_irqs(struct vmxnet3_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)
 {
--- a/drivers/net/vmxnet3/vmxnet3_int.h	2010-10-15 13:58:23.390723065 -0700
+++ b/drivers/net/vmxnet3/vmxnet3_int.h	2010-10-15 13:59:46.329296549 -0700
@@ -353,9 +353,20 @@ 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);
+static inline void set_flag_le16(__le16 *data, u16 flag)
+{
+	*data = cpu_to_le16(le16_to_cpu(*data) | flag);
+}
+
+static inline void set_flag_le64(__le64 *data, u64 flag)
+{
+	*data = cpu_to_le64(le64_to_cpu(*data) | flag);
+}
+
+static inline void reset_flag_le64(__le64 *data, u64 flag)
+{
+	*data = cpu_to_le64(le64_to_cpu(*data) & ~flag);
+}
 
 int
 vmxnet3_quiesce_dev(struct vmxnet3_adapter *adapter);

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

* RE: [PATCH net-next] vmxnet3: make bit twiddle routines inline
  2010-10-15 21:06 [PATCH net-next] vmxnet3: make bit twiddle routines inline Stephen Hemminger
@ 2010-10-15 21:14 ` Shreyas Bhatewara
  2010-10-15 21:22 ` Harvey Harrison
  2010-10-21 10:14 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Shreyas Bhatewara @ 2010-10-15 21:14 UTC (permalink / raw)
  To: Stephen Hemminger, David S. Miller; +Cc: VMware, Inc., netdev@vger.kernel.org

Thanks for the change Stephen. Looks good.


Acked-by: Shreyas Bhatewara <sbhatewara@vmware.com>



> -----Original Message-----
> From: Stephen Hemminger [mailto:shemminger@vyatta.com]
> Sent: Friday, October 15, 2010 2:06 PM
> To: Shreyas Bhatewara; David S. Miller
> Cc: VMware, Inc.; netdev@vger.kernel.org
> Subject: [PATCH net-next] vmxnet3: make bit twiddle routines inline
> 
> Gcc doesn't usually handle inline across compilation units, and the
> functions don't have to be global in scope. Move the set/reset flag
> functions int the existing vmxnet3 header.
> 
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
> 
> ---
>  drivers/net/vmxnet3/vmxnet3_drv.c |   17 -----------------
>  drivers/net/vmxnet3/vmxnet3_int.h |   17 ++++++++++++++---
>  2 files changed, 14 insertions(+), 20 deletions(-)
> 
> --- a/drivers/net/vmxnet3/vmxnet3_drv.c	2010-10-15 13:58:23.378722695
> -0700
> +++ b/drivers/net/vmxnet3/vmxnet3_drv.c	2010-10-15 13:59:32.724873755
> -0700
> @@ -1548,23 +1548,6 @@ vmxnet3_free_irqs(struct vmxnet3_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)
>  {
> --- a/drivers/net/vmxnet3/vmxnet3_int.h	2010-10-15 13:58:23.390723065
> -0700
> +++ b/drivers/net/vmxnet3/vmxnet3_int.h	2010-10-15 13:59:46.329296549
> -0700
> @@ -353,9 +353,20 @@ 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);
> +static inline void set_flag_le16(__le16 *data, u16 flag)
> +{
> +	*data = cpu_to_le16(le16_to_cpu(*data) | flag);
> +}
> +
> +static inline void set_flag_le64(__le64 *data, u64 flag)
> +{
> +	*data = cpu_to_le64(le64_to_cpu(*data) | flag);
> +}
> +
> +static inline void reset_flag_le64(__le64 *data, u64 flag)
> +{
> +	*data = cpu_to_le64(le64_to_cpu(*data) & ~flag);
> +}
> 
>  int
>  vmxnet3_quiesce_dev(struct vmxnet3_adapter *adapter);

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

* Re: [PATCH net-next] vmxnet3: make bit twiddle routines inline
  2010-10-15 21:06 [PATCH net-next] vmxnet3: make bit twiddle routines inline Stephen Hemminger
  2010-10-15 21:14 ` Shreyas Bhatewara
@ 2010-10-15 21:22 ` Harvey Harrison
  2010-10-21 10:14 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Harvey Harrison @ 2010-10-15 21:22 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: Shreyas Bhatewara, David S. Miller, VMware, Inc., netdev

On Fri, Oct 15, 2010 at 2:06 PM, Stephen Hemminger
<shemminger@vyatta.com> wrote:
> +static inline void set_flag_le16(__le16 *data, u16 flag)
> +{
> +       *data = cpu_to_le16(le16_to_cpu(*data) | flag);
> +}
> +

Instead of swapping twice on BE machines, why not:

*data |= cpu_to_le16(flag);

Which may even get done away with at compile time if flag is a constant.

Similarly for the others.

Cheers,

Harvey

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

* Re: [PATCH net-next] vmxnet3: make bit twiddle routines inline
  2010-10-15 21:06 [PATCH net-next] vmxnet3: make bit twiddle routines inline Stephen Hemminger
  2010-10-15 21:14 ` Shreyas Bhatewara
  2010-10-15 21:22 ` Harvey Harrison
@ 2010-10-21 10:14 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2010-10-21 10:14 UTC (permalink / raw)
  To: shemminger; +Cc: sbhatewara, pv-drivers, netdev

From: Stephen Hemminger <shemminger@vyatta.com>
Date: Fri, 15 Oct 2010 14:06:20 -0700

> Gcc doesn't usually handle inline across compilation units, and the
> functions don't have to be global in scope. Move the set/reset flag
> functions int the existing vmxnet3 header.
> 
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

Applied.

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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-15 21:06 [PATCH net-next] vmxnet3: make bit twiddle routines inline Stephen Hemminger
2010-10-15 21:14 ` Shreyas Bhatewara
2010-10-15 21:22 ` Harvey Harrison
2010-10-21 10:14 ` David Miller

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