Re: [PATCH] vmxnet3: remove redundant initialization of pointer 'rq'

2018-02-01 Thread Shrikrishna Khare


On Thu, 1 Feb 2018, Colin King wrote:

> From: Colin Ian King <colin.k...@canonical.com>
> 
> Pointer rq is being initialized but this value is never read, it
> is being updated inside a for-loop. Remove the initialization and
> move it into the scope of the for-loop.
> 
> Cleans up clang warning:
> drivers/net/vmxnet3/vmxnet3_drv.c:2763:27: warning: Value stored
> to 'rq' during its initialization is never read
> 
> Signed-off-by: Colin Ian King <colin.k...@canonical.com>

Acked-by: Shrikrishna Khare <skh...@vmware.com>


Re: [PATCH] vmxnet3: remove redundant initialization of pointer 'rq'

2018-02-01 Thread Shrikrishna Khare


On Thu, 1 Feb 2018, Colin King wrote:

> From: Colin Ian King 
> 
> Pointer rq is being initialized but this value is never read, it
> is being updated inside a for-loop. Remove the initialization and
> move it into the scope of the for-loop.
> 
> Cleans up clang warning:
> drivers/net/vmxnet3/vmxnet3_drv.c:2763:27: warning: Value stored
> to 'rq' during its initialization is never read
> 
> Signed-off-by: Colin Ian King 

Acked-by: Shrikrishna Khare 


Re: [RFC PATCH] e1000e: Remove Other from EIAC.

2018-01-18 Thread Shrikrishna Khare


On Thu, 18 Jan 2018, Benjamin Poirier wrote:

> On 2018/01/18 15:50, Benjamin Poirier wrote:
> > It was reported that emulated e1000e devices in vmware esxi 6.5 Build
> > 7526125 do not link up after commit 4aea7a5c5e94 ("e1000e: Avoid receiver
> > overrun interrupt bursts", v4.15-rc1). Some tracing shows that after
> > e1000e_trigger_lsc() is called, ICR reads out as 0x0 in e1000_msix_other()
> > on emulated e1000e devices. In comparison, on real e1000e 82574 hardware,
> > icr=0x8004 (_INT_ASSERTED | _OTHER) in the same situation.
> > 
> > Some experimentation showed that this flaw in vmware e1000e emulation can
> > be worked around by not setting Other in EIAC. This is how it was before
> > 16ecba59bc33 ("e1000e: Do not read ICR in Other interrupt", v4.5-rc1).
> 
> vmware folks, please comment.

Thank you for bringing this to our attention.

Using the reported build (ESX 6.5, 7526125) and 4.15.0-rc8+ kernel (which 
has the said patch), I could bring up e1000e interface (version: 3.2.6-k),
get dhcp address and even do large file downloads without difficulty.

Could you give us more pointers on how we may be able to reproduce this 
locally? Was there anything different with the configuration when the 
issue was observed? Is the issue consistently reproducible?

Thanks,
Shri


Re: [RFC PATCH] e1000e: Remove Other from EIAC.

2018-01-18 Thread Shrikrishna Khare


On Thu, 18 Jan 2018, Benjamin Poirier wrote:

> On 2018/01/18 15:50, Benjamin Poirier wrote:
> > It was reported that emulated e1000e devices in vmware esxi 6.5 Build
> > 7526125 do not link up after commit 4aea7a5c5e94 ("e1000e: Avoid receiver
> > overrun interrupt bursts", v4.15-rc1). Some tracing shows that after
> > e1000e_trigger_lsc() is called, ICR reads out as 0x0 in e1000_msix_other()
> > on emulated e1000e devices. In comparison, on real e1000e 82574 hardware,
> > icr=0x8004 (_INT_ASSERTED | _OTHER) in the same situation.
> > 
> > Some experimentation showed that this flaw in vmware e1000e emulation can
> > be worked around by not setting Other in EIAC. This is how it was before
> > 16ecba59bc33 ("e1000e: Do not read ICR in Other interrupt", v4.5-rc1).
> 
> vmware folks, please comment.

Thank you for bringing this to our attention.

Using the reported build (ESX 6.5, 7526125) and 4.15.0-rc8+ kernel (which 
has the said patch), I could bring up e1000e interface (version: 3.2.6-k),
get dhcp address and even do large file downloads without difficulty.

Could you give us more pointers on how we may be able to reproduce this 
locally? Was there anything different with the configuration when the 
issue was observed? Is the issue consistently reproducible?

Thanks,
Shri


[PATCH net-next v2] vmxnet3: increase default rx ring sizes

2017-11-30 Thread Shrikrishna Khare
There are several reasons for increasing the receive ring sizes:

1. The original ring size of 256 was chosen about 10 years ago when
vmxnet3 was first created. At that time, 10Gbps Ethernet was not prevalent
and servers were dominated by 1Gbps Ethernet. Now 10Gbps is common place,
and higher bandwidth links -- 25Gbps, 40Gbps, 50Gbps -- are starting
to appear. 256 Rx ring entries are simply not enough to keep up with
higher link speed when there is a burst of network frames coming from
these high speed links. Even with full MTU size frames, they are gone
in a short time. It is also more common to have a mix of frame sizes,
and more likely bi-modal distribution of frame sizes so the average frame
size is not close to full MTU. If we consider average frame size of 800B,
1024 frames that come in a burst takes ~0.65 ms to arrive at 10Gbps. With
256 entires, it takes ~0.16 ms to arrive at 10Gbps.  At 25Gbps or 40Gbps,
this time is reduced accordingly.

2. On a hypervisor where there are many VMs and CPU is over committed,
i.e. the number of VCPUs is more than the number of VCPUs, each PCPU is
in effect time shared between multiple VMs/VCPUs. The time granularity at
which this multiplexing occurs is typically coarser than between processes
on a guest OS. Trying to time slice more finely is not efficient, for
example, if memory cache is barely warmed up when switching from one VM
to another occurs. This CPU overcommit adds delay to when the driver
in a VM can service incoming packets. Whether CPU is over committed
really depends on customer workloads. For certain situations, it is very
common. For example, workloads of desktop VMs and product testing setups.
Consolidation and sharing is what drives efficiency of a customer setup
for such workloads. In these situations, the raw network bandwidth may
not be very high, but the delays between when a VM is running or not
running can also be relatively long.

Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
Acked-by: Jin Heo <h...@vmware.com>
Acked-by: Guolin Yang <gy...@vmware.com>
Acked-by: Boon Ang <b...@vmware.com>

---
v1->v2: revise commit message to explain the motivation for increasing
the ring size.
---
 drivers/net/vmxnet3/vmxnet3_int.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_int.h 
b/drivers/net/vmxnet3/vmxnet3_int.h
index 9c51b8be0038..5ba222920e80 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.a.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.11.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM  0x01040a00
+#define VMXNET3_DRIVER_VERSION_NUM  0x01040b00
 
 #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
@@ -416,8 +416,8 @@ struct vmxnet3_adapter {
 
 /* must be a multiple of VMXNET3_RING_SIZE_ALIGN */
 #define VMXNET3_DEF_TX_RING_SIZE512
-#define VMXNET3_DEF_RX_RING_SIZE256
-#define VMXNET3_DEF_RX_RING2_SIZE   128
+#define VMXNET3_DEF_RX_RING_SIZE1024
+#define VMXNET3_DEF_RX_RING2_SIZE   256
 
 #define VMXNET3_DEF_RXDATA_DESC_SIZE 128
 
-- 
2.11.0



[PATCH net-next v2] vmxnet3: increase default rx ring sizes

2017-11-30 Thread Shrikrishna Khare
There are several reasons for increasing the receive ring sizes:

1. The original ring size of 256 was chosen about 10 years ago when
vmxnet3 was first created. At that time, 10Gbps Ethernet was not prevalent
and servers were dominated by 1Gbps Ethernet. Now 10Gbps is common place,
and higher bandwidth links -- 25Gbps, 40Gbps, 50Gbps -- are starting
to appear. 256 Rx ring entries are simply not enough to keep up with
higher link speed when there is a burst of network frames coming from
these high speed links. Even with full MTU size frames, they are gone
in a short time. It is also more common to have a mix of frame sizes,
and more likely bi-modal distribution of frame sizes so the average frame
size is not close to full MTU. If we consider average frame size of 800B,
1024 frames that come in a burst takes ~0.65 ms to arrive at 10Gbps. With
256 entires, it takes ~0.16 ms to arrive at 10Gbps.  At 25Gbps or 40Gbps,
this time is reduced accordingly.

2. On a hypervisor where there are many VMs and CPU is over committed,
i.e. the number of VCPUs is more than the number of VCPUs, each PCPU is
in effect time shared between multiple VMs/VCPUs. The time granularity at
which this multiplexing occurs is typically coarser than between processes
on a guest OS. Trying to time slice more finely is not efficient, for
example, if memory cache is barely warmed up when switching from one VM
to another occurs. This CPU overcommit adds delay to when the driver
in a VM can service incoming packets. Whether CPU is over committed
really depends on customer workloads. For certain situations, it is very
common. For example, workloads of desktop VMs and product testing setups.
Consolidation and sharing is what drives efficiency of a customer setup
for such workloads. In these situations, the raw network bandwidth may
not be very high, but the delays between when a VM is running or not
running can also be relatively long.

Signed-off-by: Shrikrishna Khare 
Acked-by: Jin Heo 
Acked-by: Guolin Yang 
Acked-by: Boon Ang 

---
v1->v2: revise commit message to explain the motivation for increasing
the ring size.
---
 drivers/net/vmxnet3/vmxnet3_int.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_int.h 
b/drivers/net/vmxnet3/vmxnet3_int.h
index 9c51b8be0038..5ba222920e80 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.a.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.11.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM  0x01040a00
+#define VMXNET3_DRIVER_VERSION_NUM  0x01040b00
 
 #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
@@ -416,8 +416,8 @@ struct vmxnet3_adapter {
 
 /* must be a multiple of VMXNET3_RING_SIZE_ALIGN */
 #define VMXNET3_DEF_TX_RING_SIZE512
-#define VMXNET3_DEF_RX_RING_SIZE256
-#define VMXNET3_DEF_RX_RING2_SIZE   128
+#define VMXNET3_DEF_RX_RING_SIZE1024
+#define VMXNET3_DEF_RX_RING2_SIZE   256
 
 #define VMXNET3_DEF_RXDATA_DESC_SIZE 128
 
-- 
2.11.0



Re: [PATCH net-next] vmxnet3: increase default rx ring sizes

2017-11-28 Thread Shrikrishna Khare


On Tue, 28 Nov 2017, Andrew Lunn wrote:

> >  /*
> >   * Version numbers
> >   */
> > -#define VMXNET3_DRIVER_VERSION_STRING   "1.4.a.0-k"
> > +#define VMXNET3_DRIVER_VERSION_STRING   "1.4.11.0-k"
> >  
> >  /* a 32-bit int, each byte encode a verion number in 
> > VMXNET3_DRIVER_VERSION */
> > -#define VMXNET3_DRIVER_VERSION_NUM  0x01040a00
> > +#define VMXNET3_DRIVER_VERSION_NUM  0x01040b00
> 
> Version strings in drivers are totally pointless, but should not this
> be 0x01041100?
> 

Version number is hex value written to vmxnet3 emulation, thus 0x1040b00 
is correct (0x0b = 11). The VERSION_STRING should have previously been 
"1.4.10.0-k", this patch rectifies that by setting correct value 
"1.4.11.0-k".

I will let John Savanyo (cc'ed) comment on having the version in the 
driver part.

Thanks,
Shri


Re: [PATCH net-next] vmxnet3: increase default rx ring sizes

2017-11-28 Thread Shrikrishna Khare


On Tue, 28 Nov 2017, Andrew Lunn wrote:

> >  /*
> >   * Version numbers
> >   */
> > -#define VMXNET3_DRIVER_VERSION_STRING   "1.4.a.0-k"
> > +#define VMXNET3_DRIVER_VERSION_STRING   "1.4.11.0-k"
> >  
> >  /* a 32-bit int, each byte encode a verion number in 
> > VMXNET3_DRIVER_VERSION */
> > -#define VMXNET3_DRIVER_VERSION_NUM  0x01040a00
> > +#define VMXNET3_DRIVER_VERSION_NUM  0x01040b00
> 
> Version strings in drivers are totally pointless, but should not this
> be 0x01041100?
> 

Version number is hex value written to vmxnet3 emulation, thus 0x1040b00 
is correct (0x0b = 11). The VERSION_STRING should have previously been 
"1.4.10.0-k", this patch rectifies that by setting correct value 
"1.4.11.0-k".

I will let John Savanyo (cc'ed) comment on having the version in the 
driver part.

Thanks,
Shri


[PATCH net-next] vmxnet3: increase default rx ring sizes

2017-11-28 Thread Shrikrishna Khare
We often notice rx packet drops due to small default rx ring sizes and
solve the problem by increasing the ring sizes. This patch increases the
default rx ring sizes thereby reducing the probability of rx packet
drops out of the box.

Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
Acked-by: Jin Heo <h...@vmware.com>
Acked-by: Guolin Yang <gy...@vmware.com>
Acked-by: Boon Ang <b...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_int.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_int.h 
b/drivers/net/vmxnet3/vmxnet3_int.h
index 9c51b8be0038..5ba222920e80 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.a.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.11.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM  0x01040a00
+#define VMXNET3_DRIVER_VERSION_NUM  0x01040b00
 
 #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
@@ -416,8 +416,8 @@ struct vmxnet3_adapter {
 
 /* must be a multiple of VMXNET3_RING_SIZE_ALIGN */
 #define VMXNET3_DEF_TX_RING_SIZE512
-#define VMXNET3_DEF_RX_RING_SIZE256
-#define VMXNET3_DEF_RX_RING2_SIZE   128
+#define VMXNET3_DEF_RX_RING_SIZE1024
+#define VMXNET3_DEF_RX_RING2_SIZE   256
 
 #define VMXNET3_DEF_RXDATA_DESC_SIZE 128
 
-- 
2.11.0



[PATCH net-next] vmxnet3: increase default rx ring sizes

2017-11-28 Thread Shrikrishna Khare
We often notice rx packet drops due to small default rx ring sizes and
solve the problem by increasing the ring sizes. This patch increases the
default rx ring sizes thereby reducing the probability of rx packet
drops out of the box.

Signed-off-by: Shrikrishna Khare 
Acked-by: Jin Heo 
Acked-by: Guolin Yang 
Acked-by: Boon Ang 
---
 drivers/net/vmxnet3/vmxnet3_int.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_int.h 
b/drivers/net/vmxnet3/vmxnet3_int.h
index 9c51b8be0038..5ba222920e80 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.a.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.11.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM  0x01040a00
+#define VMXNET3_DRIVER_VERSION_NUM  0x01040b00
 
 #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
@@ -416,8 +416,8 @@ struct vmxnet3_adapter {
 
 /* must be a multiple of VMXNET3_RING_SIZE_ALIGN */
 #define VMXNET3_DEF_TX_RING_SIZE512
-#define VMXNET3_DEF_RX_RING_SIZE256
-#define VMXNET3_DEF_RX_RING2_SIZE   128
+#define VMXNET3_DEF_RX_RING_SIZE1024
+#define VMXNET3_DEF_RX_RING2_SIZE   256
 
 #define VMXNET3_DEF_RXDATA_DESC_SIZE 128
 
-- 
2.11.0



Re: [PATCH net-next 5/6] net: use core MTU range checking in virt drivers

2016-10-19 Thread Shrikrishna Khare


On Wed, 19 Oct 2016, Jarod Wilson wrote:

> hyperv_net:
> - set min/max_mtu
> 
> virtio_net:
> - set min/max_mtu
> - remove virtnet_change_mtu
> 
> vmxnet3:
> - set min/max_mtu
> 
> CC: net...@vger.kernel.org
> CC: virtualizat...@lists.linux-foundation.org
> CC: "K. Y. Srinivasan" <k...@microsoft.com>
> CC: Haiyang Zhang <haiya...@microsoft.com>
> CC: "Michael S. Tsirkin" <m...@redhat.com>
> CC: Shrikrishna Khare <skh...@vmware.com>
> CC: "VMware, Inc." <pv-driv...@vmware.com>
> Signed-off-by: Jarod Wilson <ja...@redhat.com>
> ---

The vmxnet3 part of the change looks good to me.

Thanks,
Shri


Re: [PATCH net-next 5/6] net: use core MTU range checking in virt drivers

2016-10-19 Thread Shrikrishna Khare


On Wed, 19 Oct 2016, Jarod Wilson wrote:

> hyperv_net:
> - set min/max_mtu
> 
> virtio_net:
> - set min/max_mtu
> - remove virtnet_change_mtu
> 
> vmxnet3:
> - set min/max_mtu
> 
> CC: net...@vger.kernel.org
> CC: virtualizat...@lists.linux-foundation.org
> CC: "K. Y. Srinivasan" 
> CC: Haiyang Zhang 
> CC: "Michael S. Tsirkin" 
> CC: Shrikrishna Khare 
> CC: "VMware, Inc." 
> Signed-off-by: Jarod Wilson 
> ---

The vmxnet3 part of the change looks good to me.

Thanks,
Shri


[PATCH net] vmxnet3: fix tx data ring copy for variable size

2016-08-19 Thread Shrikrishna Khare
'Commit 3c8b3efc061a ("vmxnet3: allow variable length transmit data ring
buffer")' changed the size of the buffers in the tx data ring from a
fixed size of 128 bytes to a variable size.

However, while copying data to the data ring, vmxnet3_copy_hdr continues
to carry the old code that assumes fixed buffer size of 128. This patch
fixes it by adding correct offset based on the actual data ring buffer
size.

Signed-off-by: Guolin Yang <gy...@vmware.com>
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 4 +++-
 drivers/net/vmxnet3/vmxnet3_int.h | 4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index c68fe49..4244b9d 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -914,7 +914,9 @@ vmxnet3_copy_hdr(struct sk_buff *skb, struct 
vmxnet3_tx_queue *tq,
 {
struct Vmxnet3_TxDataDesc *tdd;
 
-   tdd = tq->data_ring.base + tq->tx_ring.next2fill;
+   tdd = (struct Vmxnet3_TxDataDesc *)((u8 *)tq->data_ring.base +
+   tq->tx_ring.next2fill *
+   tq->txdata_desc_size);
 
memcpy(tdd->data, skb->data, ctx->copy_size);
netdev_dbg(adapter->netdev,
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h 
b/drivers/net/vmxnet3/vmxnet3_int.h
index 74fc030..7dc37a0 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.9.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.a.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM  0x01040900
+#define VMXNET3_DRIVER_VERSION_NUM  0x01040a00
 
 #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
-- 
2.8.2



[PATCH net] vmxnet3: fix tx data ring copy for variable size

2016-08-19 Thread Shrikrishna Khare
'Commit 3c8b3efc061a ("vmxnet3: allow variable length transmit data ring
buffer")' changed the size of the buffers in the tx data ring from a
fixed size of 128 bytes to a variable size.

However, while copying data to the data ring, vmxnet3_copy_hdr continues
to carry the old code that assumes fixed buffer size of 128. This patch
fixes it by adding correct offset based on the actual data ring buffer
size.

Signed-off-by: Guolin Yang 
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 4 +++-
 drivers/net/vmxnet3/vmxnet3_int.h | 4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index c68fe49..4244b9d 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -914,7 +914,9 @@ vmxnet3_copy_hdr(struct sk_buff *skb, struct 
vmxnet3_tx_queue *tq,
 {
struct Vmxnet3_TxDataDesc *tdd;
 
-   tdd = tq->data_ring.base + tq->tx_ring.next2fill;
+   tdd = (struct Vmxnet3_TxDataDesc *)((u8 *)tq->data_ring.base +
+   tq->tx_ring.next2fill *
+   tq->txdata_desc_size);
 
memcpy(tdd->data, skb->data, ctx->copy_size);
netdev_dbg(adapter->netdev,
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h 
b/drivers/net/vmxnet3/vmxnet3_int.h
index 74fc030..7dc37a0 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.9.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.a.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM  0x01040900
+#define VMXNET3_DRIVER_VERSION_NUM  0x01040a00
 
 #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
-- 
2.8.2



[PATCH net-next v5 6/7] vmxnet3: introduce command to register memory region

2016-06-16 Thread Shrikrishna Khare
In vmxnet3 version 3, the emulation added support for the vmxnet3 driver
to communicate information about the memory regions the driver will use
for rx/tx buffers. The driver can also indicate which rx/tx queue the
memory region is applicable for. If this information is communicated
to the emulation, the emulation will always keep these memory regions
mapped, thereby avoiding the mapping/unmapping overhead for every packet.

Currently, Linux vmxnet3 driver does not leverage this capability. The
feasibility of using this approach for the Linux vmxnet3 driver will be
investigated independently and if possible, will be part of a different
patch. This patch only exposes the emulation capability to the driver
(vmxnet3_defs.h is identical between the driver and the emulation).

Signed-off-by: Guolin Yang <gy...@vmware.com>
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_defs.h | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 274e145..c3a3164 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -81,6 +81,7 @@ enum {
VMXNET3_CMD_RESERVED2,
VMXNET3_CMD_RESERVED3,
VMXNET3_CMD_SET_COALESCE,
+   VMXNET3_CMD_REGISTER_MEMREGS,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -668,6 +669,22 @@ struct Vmxnet3_CoalesceScheme {
} coalPara;
 };
 
+struct Vmxnet3_MemoryRegion {
+   __le64  startPA;
+   __le32  length;
+   __le16  txQueueBits;
+   __le16  rxQueueBits;
+};
+
+#define MAX_MEMORY_REGION_PER_QUEUE 16
+#define MAX_MEMORY_REGION_PER_DEVICE 256
+
+struct Vmxnet3_MemRegs {
+   __le16  numRegs;
+   __le16  pad[3];
+   struct Vmxnet3_MemoryRegion memRegs[1];
+};
+
 /* If the command data <= 16 bytes, use the shared memory directly.
  * otherwise, use variable length configuration descriptor.
  */
-- 
2.8.2



[PATCH net-next v5 3/7] vmxnet3: allow variable length transmit data ring buffer

2016-06-16 Thread Shrikrishna Khare
vmxnet3 driver supports transmit data ring viz. a set of fixed size
buffers used by the driver to copy packet headers. Small packets that
fit these buffers are copied into these buffers entirely.

Currently this buffer size of fixed at 128 bytes. This patch extends
transmit data ring implementation to allow variable length transmit
data ring buffers. The length of the buffer is read from the emulation
during initialization.

Signed-off-by: Sriram Rangarajan <rangaraj...@vmware.com>
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_defs.h| 12 +++-
 drivers/net/vmxnet3/vmxnet3_drv.c | 55 ++-
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  9 +++---
 drivers/net/vmxnet3/vmxnet3_int.h |  7 -
 4 files changed, 64 insertions(+), 19 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index a26a69d..701d989 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -92,6 +92,7 @@ enum {
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
VMXNET3_CMD_GET_CONF_INTR,
VMXNET3_CMD_GET_RESERVED1,
+   VMXNET3_CMD_GET_TXDATA_DESC_SIZE
 };
 
 /*
@@ -377,6 +378,10 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_RING_SIZE_ALIGN 32
 #define VMXNET3_RING_SIZE_MASK  (VMXNET3_RING_SIZE_ALIGN - 1)
 
+/* Tx Data Ring buffer size must be a multiple of 64 */
+#define VMXNET3_TXDATA_DESC_SIZE_ALIGN 64
+#define VMXNET3_TXDATA_DESC_SIZE_MASK  (VMXNET3_TXDATA_DESC_SIZE_ALIGN - 1)
+
 /* Max ring size */
 #define VMXNET3_TX_RING_MAX_SIZE   4096
 #define VMXNET3_TC_RING_MAX_SIZE   4096
@@ -384,6 +389,9 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_RX_RING2_MAX_SIZE  4096
 #define VMXNET3_RC_RING_MAX_SIZE   8192
 
+#define VMXNET3_TXDATA_DESC_MIN_SIZE 128
+#define VMXNET3_TXDATA_DESC_MAX_SIZE 2048
+
 /* a list of reasons for queue stop */
 
 enum {
@@ -470,7 +478,9 @@ struct Vmxnet3_TxQueueConf {
__le32  compRingSize; /* # of comp desc */
__le32  ddLen;/* size of driver data */
u8  intrIdx;
-   u8  _pad[7];
+   u8  _pad1[1];
+   __le16  txDataRingDescSize;
+   u8  _pad2[4];
 };
 
 
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 507c53d..4e42eb0 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -435,8 +435,8 @@ vmxnet3_tq_destroy(struct vmxnet3_tx_queue *tq,
tq->tx_ring.base = NULL;
}
if (tq->data_ring.base) {
-   dma_free_coherent(>pdev->dev, tq->data_ring.size *
- sizeof(struct Vmxnet3_TxDataDesc),
+   dma_free_coherent(>pdev->dev,
+ tq->data_ring.size * tq->txdata_desc_size,
  tq->data_ring.base, tq->data_ring.basePA);
tq->data_ring.base = NULL;
}
@@ -478,8 +478,8 @@ vmxnet3_tq_init(struct vmxnet3_tx_queue *tq,
tq->tx_ring.next2fill = tq->tx_ring.next2comp = 0;
tq->tx_ring.gen = VMXNET3_INIT_GEN;
 
-   memset(tq->data_ring.base, 0, tq->data_ring.size *
-  sizeof(struct Vmxnet3_TxDataDesc));
+   memset(tq->data_ring.base, 0,
+  tq->data_ring.size * tq->txdata_desc_size);
 
/* reset the tx comp ring contents to 0 and reset comp ring states */
memset(tq->comp_ring.base, 0, tq->comp_ring.size *
@@ -514,10 +514,10 @@ vmxnet3_tq_create(struct vmxnet3_tx_queue *tq,
}
 
tq->data_ring.base = dma_alloc_coherent(>pdev->dev,
-   tq->data_ring.size * sizeof(struct Vmxnet3_TxDataDesc),
+   tq->data_ring.size * tq->txdata_desc_size,
>data_ring.basePA, GFP_KERNEL);
if (!tq->data_ring.base) {
-   netdev_err(adapter->netdev, "failed to allocate data ring\n");
+   netdev_err(adapter->netdev, "failed to allocate tx data 
ring\n");
goto err;
}
 
@@ -689,7 +689,7 @@ vmxnet3_map_pkt(struct sk_buff *skb, struct vmxnet3_tx_ctx 
*ctx,
if (ctx->copy_size) {
ctx->sop_txd->txd.addr = cpu_to_le64(tq->data_ring.basePA +
tq->tx_ring.next2fill *
-   sizeof(struct Vmxnet3_TxDataDesc));
+   tq->txdata_desc_size);
ctx->sop_txd->dword[2] = cpu_to_le32(dw2 | ctx->copy_size);
ctx->sop_txd->dword[3] = 0;
 
@@ -873,8 +873,9 @@ vmxnet3_parse_hdr(struct sk_buff *skb, struct 
vmxnet3_tx_queue *tq,
ctx->eth_ip_hdr_size = 0;

[PATCH net-next v5 6/7] vmxnet3: introduce command to register memory region

2016-06-16 Thread Shrikrishna Khare
In vmxnet3 version 3, the emulation added support for the vmxnet3 driver
to communicate information about the memory regions the driver will use
for rx/tx buffers. The driver can also indicate which rx/tx queue the
memory region is applicable for. If this information is communicated
to the emulation, the emulation will always keep these memory regions
mapped, thereby avoiding the mapping/unmapping overhead for every packet.

Currently, Linux vmxnet3 driver does not leverage this capability. The
feasibility of using this approach for the Linux vmxnet3 driver will be
investigated independently and if possible, will be part of a different
patch. This patch only exposes the emulation capability to the driver
(vmxnet3_defs.h is identical between the driver and the emulation).

Signed-off-by: Guolin Yang 
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_defs.h | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 274e145..c3a3164 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -81,6 +81,7 @@ enum {
VMXNET3_CMD_RESERVED2,
VMXNET3_CMD_RESERVED3,
VMXNET3_CMD_SET_COALESCE,
+   VMXNET3_CMD_REGISTER_MEMREGS,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -668,6 +669,22 @@ struct Vmxnet3_CoalesceScheme {
} coalPara;
 };
 
+struct Vmxnet3_MemoryRegion {
+   __le64  startPA;
+   __le32  length;
+   __le16  txQueueBits;
+   __le16  rxQueueBits;
+};
+
+#define MAX_MEMORY_REGION_PER_QUEUE 16
+#define MAX_MEMORY_REGION_PER_DEVICE 256
+
+struct Vmxnet3_MemRegs {
+   __le16  numRegs;
+   __le16  pad[3];
+   struct Vmxnet3_MemoryRegion memRegs[1];
+};
+
 /* If the command data <= 16 bytes, use the shared memory directly.
  * otherwise, use variable length configuration descriptor.
  */
-- 
2.8.2



[PATCH net-next v5 3/7] vmxnet3: allow variable length transmit data ring buffer

2016-06-16 Thread Shrikrishna Khare
vmxnet3 driver supports transmit data ring viz. a set of fixed size
buffers used by the driver to copy packet headers. Small packets that
fit these buffers are copied into these buffers entirely.

Currently this buffer size of fixed at 128 bytes. This patch extends
transmit data ring implementation to allow variable length transmit
data ring buffers. The length of the buffer is read from the emulation
during initialization.

Signed-off-by: Sriram Rangarajan 
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_defs.h| 12 +++-
 drivers/net/vmxnet3/vmxnet3_drv.c | 55 ++-
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  9 +++---
 drivers/net/vmxnet3/vmxnet3_int.h |  7 -
 4 files changed, 64 insertions(+), 19 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index a26a69d..701d989 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -92,6 +92,7 @@ enum {
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
VMXNET3_CMD_GET_CONF_INTR,
VMXNET3_CMD_GET_RESERVED1,
+   VMXNET3_CMD_GET_TXDATA_DESC_SIZE
 };
 
 /*
@@ -377,6 +378,10 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_RING_SIZE_ALIGN 32
 #define VMXNET3_RING_SIZE_MASK  (VMXNET3_RING_SIZE_ALIGN - 1)
 
+/* Tx Data Ring buffer size must be a multiple of 64 */
+#define VMXNET3_TXDATA_DESC_SIZE_ALIGN 64
+#define VMXNET3_TXDATA_DESC_SIZE_MASK  (VMXNET3_TXDATA_DESC_SIZE_ALIGN - 1)
+
 /* Max ring size */
 #define VMXNET3_TX_RING_MAX_SIZE   4096
 #define VMXNET3_TC_RING_MAX_SIZE   4096
@@ -384,6 +389,9 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_RX_RING2_MAX_SIZE  4096
 #define VMXNET3_RC_RING_MAX_SIZE   8192
 
+#define VMXNET3_TXDATA_DESC_MIN_SIZE 128
+#define VMXNET3_TXDATA_DESC_MAX_SIZE 2048
+
 /* a list of reasons for queue stop */
 
 enum {
@@ -470,7 +478,9 @@ struct Vmxnet3_TxQueueConf {
__le32  compRingSize; /* # of comp desc */
__le32  ddLen;/* size of driver data */
u8  intrIdx;
-   u8  _pad[7];
+   u8  _pad1[1];
+   __le16  txDataRingDescSize;
+   u8  _pad2[4];
 };
 
 
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 507c53d..4e42eb0 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -435,8 +435,8 @@ vmxnet3_tq_destroy(struct vmxnet3_tx_queue *tq,
tq->tx_ring.base = NULL;
}
if (tq->data_ring.base) {
-   dma_free_coherent(>pdev->dev, tq->data_ring.size *
- sizeof(struct Vmxnet3_TxDataDesc),
+   dma_free_coherent(>pdev->dev,
+ tq->data_ring.size * tq->txdata_desc_size,
  tq->data_ring.base, tq->data_ring.basePA);
tq->data_ring.base = NULL;
}
@@ -478,8 +478,8 @@ vmxnet3_tq_init(struct vmxnet3_tx_queue *tq,
tq->tx_ring.next2fill = tq->tx_ring.next2comp = 0;
tq->tx_ring.gen = VMXNET3_INIT_GEN;
 
-   memset(tq->data_ring.base, 0, tq->data_ring.size *
-  sizeof(struct Vmxnet3_TxDataDesc));
+   memset(tq->data_ring.base, 0,
+  tq->data_ring.size * tq->txdata_desc_size);
 
/* reset the tx comp ring contents to 0 and reset comp ring states */
memset(tq->comp_ring.base, 0, tq->comp_ring.size *
@@ -514,10 +514,10 @@ vmxnet3_tq_create(struct vmxnet3_tx_queue *tq,
}
 
tq->data_ring.base = dma_alloc_coherent(>pdev->dev,
-   tq->data_ring.size * sizeof(struct Vmxnet3_TxDataDesc),
+   tq->data_ring.size * tq->txdata_desc_size,
>data_ring.basePA, GFP_KERNEL);
if (!tq->data_ring.base) {
-   netdev_err(adapter->netdev, "failed to allocate data ring\n");
+   netdev_err(adapter->netdev, "failed to allocate tx data 
ring\n");
goto err;
}
 
@@ -689,7 +689,7 @@ vmxnet3_map_pkt(struct sk_buff *skb, struct vmxnet3_tx_ctx 
*ctx,
if (ctx->copy_size) {
ctx->sop_txd->txd.addr = cpu_to_le64(tq->data_ring.basePA +
tq->tx_ring.next2fill *
-   sizeof(struct Vmxnet3_TxDataDesc));
+   tq->txdata_desc_size);
ctx->sop_txd->dword[2] = cpu_to_le32(dw2 | ctx->copy_size);
ctx->sop_txd->dword[3] = 0;
 
@@ -873,8 +873,9 @@ vmxnet3_parse_hdr(struct sk_buff *skb, struct 
vmxnet3_tx_queue *tq,
ctx->eth_ip_hdr_size = 0;
ctx->l4_hdr_size = 0;
/* copy as much as allowed */
-  

[PATCH net-next v5 0/7] vmxnet3: upgrade to version 3

2016-06-16 Thread Shrikrishna Khare
vmxnet3 emulation has recently added several new features which includes
support for new commands the driver can issue to emulation, change in
descriptor fields etc. This patch series extends the vmxnet3 driver to
leverage these new features.

Compatibility is maintained using existing vmxnet3 versioning mechanism as
follows:
 - new features added to vmxnet3 emulation are associated with new vmxnet3
   version viz. vmxnet3 version 3.
 - emulation advertises all the versions it supports to the driver.
 - during initialization, vmxnet3 driver picks the highest version number
 supported by both the emulation and the driver and configures emulation
 to run at that version.

In particular, following changes are introduced:

Patch 1:
  Some command definitions from previous vmxnet3 versions are
  missing. This patch adds those definitions before moving to vmxnet3
  version 3. It also fixes copyright info and maintained by.

Patch 2:
  This patch introduces generalized command interface which allows
  for easily adding new commands that vmxnet3 driver can issue to the
  emulation. Further patches in this series make use of this facility.

Patch 3:
  Transmit data ring buffer is used to copy packet headers or small
  packets. It is a fixed size buffer. This patch extends the driver to
  allow variable sized transmit data ring buffer.

Patch 4:
  This patch introduces receive data ring buffer - a set of small sized
  buffers that are always mapped by the emulation. This avoids memory
  mapping/unmapping overhead for small packets.

Patch 5:
  The vmxnet3 emulation supports a variety of coalescing modes. This patch
  extends vmxnet3 driver to allow querying and configuring these modes.

Patch 6:
  In vmxnet3 version 3, the emulation added support for the vmxnet3 driver
  to communicate information about the memory regions the driver will use
  for rx/tx buffers. This patch exposes related commands to the driver.

Patch 7:
  With all vmxnet3 version 3 changes incorporated in the vmxnet3 driver,
  with this patch, the driver can configure emulation to run at vmxnet3
  version 3.

Changes in v2:
 - v1 patch used special values of rx-usecs to differentiate between
 coalescing modes. v2 uses relevant fields in struct ethtool_coalesce
 to choose modes. Also, a new command VMXNET3_CMD_GET_COALESCE
 is introduced which allows driver to query the device for default
 coalescing configuration.

Changes in v3:
 - fix subject line to use vmxnet3: instead of Driver:Vmxnet3
 - resubmit when net-next is open

Changes in v4:
 - Address code review comments by Ben Hutchings: remove unnecessary memset
   from vmxnet3_get_coalesce.

Changes in v5:
 - Updated all the patches to add detailed commit messages.

---


Shrikrishna Khare (7):
  vmxnet3: prepare for version 3 changes
  vmxnet3: introduce generalized command interface to configure the
device
  vmxnet3: allow variable length transmit data ring buffer
  vmxnet3: add receive data ring support
  vmxnet3: add support for get_coalesce, set_coalesce ethtool operations
  vmxnet3: introduce command to register memory region
  vmxnet3: update to version 3

 drivers/net/vmxnet3/Makefile  |   4 +-
 drivers/net/vmxnet3/upt1_defs.h   |   4 +-
 drivers/net/vmxnet3/vmxnet3_defs.h| 105 -
 drivers/net/vmxnet3/vmxnet3_drv.c | 285 --
 drivers/net/vmxnet3/vmxnet3_ethtool.c | 215 +++--
 drivers/net/vmxnet3/vmxnet3_int.h |  54 ++-
 6 files changed, 585 insertions(+), 82 deletions(-)

-- 
2.8.2



[PATCH net-next v5 5/7] vmxnet3: add support for get_coalesce, set_coalesce ethtool operations

2016-06-16 Thread Shrikrishna Khare
The emulation supports a variety of coalescing modes viz. disabled
(no coalescing), adaptive, static (number of packets to batch before
raising an interrupt), rate based (number of interrupts per second).

This patch implements get_coalesce and set_coalesce methods to allow
querying and configuring different coalescing modes.

Signed-off-by: Keyong Sun <s...@vmware.com>
Signed-off-by: Manoj Tammali <tamma...@vmware.com>
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_defs.h|  33 ++-
 drivers/net/vmxnet3/vmxnet3_drv.c |  54 
 drivers/net/vmxnet3/vmxnet3_ethtool.c | 158 ++
 drivers/net/vmxnet3/vmxnet3_int.h |   9 ++
 4 files changed, 253 insertions(+), 1 deletion(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index f3b31c2..274e145 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -80,6 +80,7 @@ enum {
VMXNET3_CMD_LOAD_PLUGIN,
VMXNET3_CMD_RESERVED2,
VMXNET3_CMD_RESERVED3,
+   VMXNET3_CMD_SET_COALESCE,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -92,7 +93,8 @@ enum {
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
VMXNET3_CMD_GET_CONF_INTR,
VMXNET3_CMD_GET_RESERVED1,
-   VMXNET3_CMD_GET_TXDATA_DESC_SIZE
+   VMXNET3_CMD_GET_TXDATA_DESC_SIZE,
+   VMXNET3_CMD_GET_COALESCE,
 };
 
 /*
@@ -637,6 +639,35 @@ struct Vmxnet3_SetPolling {
u8  enablePolling;
 };
 
+#define VMXNET3_COAL_STATIC_MAX_DEPTH  128
+#define VMXNET3_COAL_RBC_MIN_RATE  100
+#define VMXNET3_COAL_RBC_MAX_RATE  10
+
+enum Vmxnet3_CoalesceMode {
+   VMXNET3_COALESCE_DISABLED   = 0,
+   VMXNET3_COALESCE_ADAPT  = 1,
+   VMXNET3_COALESCE_STATIC = 2,
+   VMXNET3_COALESCE_RBC= 3
+};
+
+struct Vmxnet3_CoalesceRbc {
+   u32 rbc_rate;
+};
+
+struct Vmxnet3_CoalesceStatic {
+   u32 tx_depth;
+   u32 tx_comp_depth;
+   u32 rx_depth;
+};
+
+struct Vmxnet3_CoalesceScheme {
+   enum Vmxnet3_CoalesceMode   coalMode;
+   union {
+   struct Vmxnet3_CoalesceRbc  coalRbc;
+   struct Vmxnet3_CoalesceStatic   coalStatic;
+   } coalPara;
+};
+
 /* If the command data <= 16 bytes, use the shared memory directly.
  * otherwise, use variable length configuration descriptor.
  */
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 6449d2e..d0bcc1d9 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -2491,6 +2491,32 @@ vmxnet3_setup_driver_shared(struct vmxnet3_adapter 
*adapter)
/* the rest are already zeroed */
 }
 
+static void
+vmxnet3_init_coalesce(struct vmxnet3_adapter *adapter)
+{
+   struct Vmxnet3_DriverShared *shared = adapter->shared;
+   union Vmxnet3_CmdInfo *cmdInfo = >cu.cmdInfo;
+   unsigned long flags;
+
+   if (!VMXNET3_VERSION_GE_3(adapter))
+   return;
+
+   spin_lock_irqsave(>cmd_lock, flags);
+   cmdInfo->varConf.confVer = 1;
+   cmdInfo->varConf.confLen =
+   cpu_to_le32(sizeof(*adapter->coal_conf));
+   cmdInfo->varConf.confPA  = cpu_to_le64(adapter->coal_conf_pa);
+
+   if (adapter->default_coal_mode) {
+   VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
+  VMXNET3_CMD_GET_COALESCE);
+   } else {
+   VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
+  VMXNET3_CMD_SET_COALESCE);
+   }
+
+   spin_unlock_irqrestore(>cmd_lock, flags);
+}
 
 int
 vmxnet3_activate_dev(struct vmxnet3_adapter *adapter)
@@ -2540,6 +2566,8 @@ vmxnet3_activate_dev(struct vmxnet3_adapter *adapter)
goto activate_err;
}
 
+   vmxnet3_init_coalesce(adapter);
+
for (i = 0; i < adapter->num_rx_queues; i++) {
VMXNET3_WRITE_BAR0_REG(adapter,
VMXNET3_REG_RXPROD + i * VMXNET3_REG_ALIGN,
@@ -3345,6 +3373,22 @@ vmxnet3_probe_device(struct pci_dev *pdev,
goto err_ver;
}
 
+   if (VMXNET3_VERSION_GE_3(adapter)) {
+   adapter->coal_conf =
+   dma_alloc_coherent(>pdev->dev,
+  sizeof(struct Vmxnet3_CoalesceScheme)
+  ,
+  >coal_conf_pa,
+  GFP_KERNEL);
+   if (!adapter->coal_conf) {
+   err = -ENOMEM;
+   goto

[PATCH net-next v5 0/7] vmxnet3: upgrade to version 3

2016-06-16 Thread Shrikrishna Khare
vmxnet3 emulation has recently added several new features which includes
support for new commands the driver can issue to emulation, change in
descriptor fields etc. This patch series extends the vmxnet3 driver to
leverage these new features.

Compatibility is maintained using existing vmxnet3 versioning mechanism as
follows:
 - new features added to vmxnet3 emulation are associated with new vmxnet3
   version viz. vmxnet3 version 3.
 - emulation advertises all the versions it supports to the driver.
 - during initialization, vmxnet3 driver picks the highest version number
 supported by both the emulation and the driver and configures emulation
 to run at that version.

In particular, following changes are introduced:

Patch 1:
  Some command definitions from previous vmxnet3 versions are
  missing. This patch adds those definitions before moving to vmxnet3
  version 3. It also fixes copyright info and maintained by.

Patch 2:
  This patch introduces generalized command interface which allows
  for easily adding new commands that vmxnet3 driver can issue to the
  emulation. Further patches in this series make use of this facility.

Patch 3:
  Transmit data ring buffer is used to copy packet headers or small
  packets. It is a fixed size buffer. This patch extends the driver to
  allow variable sized transmit data ring buffer.

Patch 4:
  This patch introduces receive data ring buffer - a set of small sized
  buffers that are always mapped by the emulation. This avoids memory
  mapping/unmapping overhead for small packets.

Patch 5:
  The vmxnet3 emulation supports a variety of coalescing modes. This patch
  extends vmxnet3 driver to allow querying and configuring these modes.

Patch 6:
  In vmxnet3 version 3, the emulation added support for the vmxnet3 driver
  to communicate information about the memory regions the driver will use
  for rx/tx buffers. This patch exposes related commands to the driver.

Patch 7:
  With all vmxnet3 version 3 changes incorporated in the vmxnet3 driver,
  with this patch, the driver can configure emulation to run at vmxnet3
  version 3.

Changes in v2:
 - v1 patch used special values of rx-usecs to differentiate between
 coalescing modes. v2 uses relevant fields in struct ethtool_coalesce
 to choose modes. Also, a new command VMXNET3_CMD_GET_COALESCE
 is introduced which allows driver to query the device for default
 coalescing configuration.

Changes in v3:
 - fix subject line to use vmxnet3: instead of Driver:Vmxnet3
 - resubmit when net-next is open

Changes in v4:
 - Address code review comments by Ben Hutchings: remove unnecessary memset
   from vmxnet3_get_coalesce.

Changes in v5:
 - Updated all the patches to add detailed commit messages.

---


Shrikrishna Khare (7):
  vmxnet3: prepare for version 3 changes
  vmxnet3: introduce generalized command interface to configure the
device
  vmxnet3: allow variable length transmit data ring buffer
  vmxnet3: add receive data ring support
  vmxnet3: add support for get_coalesce, set_coalesce ethtool operations
  vmxnet3: introduce command to register memory region
  vmxnet3: update to version 3

 drivers/net/vmxnet3/Makefile  |   4 +-
 drivers/net/vmxnet3/upt1_defs.h   |   4 +-
 drivers/net/vmxnet3/vmxnet3_defs.h| 105 -
 drivers/net/vmxnet3/vmxnet3_drv.c | 285 --
 drivers/net/vmxnet3/vmxnet3_ethtool.c | 215 +++--
 drivers/net/vmxnet3/vmxnet3_int.h |  54 ++-
 6 files changed, 585 insertions(+), 82 deletions(-)

-- 
2.8.2



[PATCH net-next v5 5/7] vmxnet3: add support for get_coalesce, set_coalesce ethtool operations

2016-06-16 Thread Shrikrishna Khare
The emulation supports a variety of coalescing modes viz. disabled
(no coalescing), adaptive, static (number of packets to batch before
raising an interrupt), rate based (number of interrupts per second).

This patch implements get_coalesce and set_coalesce methods to allow
querying and configuring different coalescing modes.

Signed-off-by: Keyong Sun 
Signed-off-by: Manoj Tammali 
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_defs.h|  33 ++-
 drivers/net/vmxnet3/vmxnet3_drv.c |  54 
 drivers/net/vmxnet3/vmxnet3_ethtool.c | 158 ++
 drivers/net/vmxnet3/vmxnet3_int.h |   9 ++
 4 files changed, 253 insertions(+), 1 deletion(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index f3b31c2..274e145 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -80,6 +80,7 @@ enum {
VMXNET3_CMD_LOAD_PLUGIN,
VMXNET3_CMD_RESERVED2,
VMXNET3_CMD_RESERVED3,
+   VMXNET3_CMD_SET_COALESCE,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -92,7 +93,8 @@ enum {
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
VMXNET3_CMD_GET_CONF_INTR,
VMXNET3_CMD_GET_RESERVED1,
-   VMXNET3_CMD_GET_TXDATA_DESC_SIZE
+   VMXNET3_CMD_GET_TXDATA_DESC_SIZE,
+   VMXNET3_CMD_GET_COALESCE,
 };
 
 /*
@@ -637,6 +639,35 @@ struct Vmxnet3_SetPolling {
u8  enablePolling;
 };
 
+#define VMXNET3_COAL_STATIC_MAX_DEPTH  128
+#define VMXNET3_COAL_RBC_MIN_RATE  100
+#define VMXNET3_COAL_RBC_MAX_RATE  10
+
+enum Vmxnet3_CoalesceMode {
+   VMXNET3_COALESCE_DISABLED   = 0,
+   VMXNET3_COALESCE_ADAPT  = 1,
+   VMXNET3_COALESCE_STATIC = 2,
+   VMXNET3_COALESCE_RBC= 3
+};
+
+struct Vmxnet3_CoalesceRbc {
+   u32 rbc_rate;
+};
+
+struct Vmxnet3_CoalesceStatic {
+   u32 tx_depth;
+   u32 tx_comp_depth;
+   u32 rx_depth;
+};
+
+struct Vmxnet3_CoalesceScheme {
+   enum Vmxnet3_CoalesceMode   coalMode;
+   union {
+   struct Vmxnet3_CoalesceRbc  coalRbc;
+   struct Vmxnet3_CoalesceStatic   coalStatic;
+   } coalPara;
+};
+
 /* If the command data <= 16 bytes, use the shared memory directly.
  * otherwise, use variable length configuration descriptor.
  */
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 6449d2e..d0bcc1d9 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -2491,6 +2491,32 @@ vmxnet3_setup_driver_shared(struct vmxnet3_adapter 
*adapter)
/* the rest are already zeroed */
 }
 
+static void
+vmxnet3_init_coalesce(struct vmxnet3_adapter *adapter)
+{
+   struct Vmxnet3_DriverShared *shared = adapter->shared;
+   union Vmxnet3_CmdInfo *cmdInfo = >cu.cmdInfo;
+   unsigned long flags;
+
+   if (!VMXNET3_VERSION_GE_3(adapter))
+   return;
+
+   spin_lock_irqsave(>cmd_lock, flags);
+   cmdInfo->varConf.confVer = 1;
+   cmdInfo->varConf.confLen =
+   cpu_to_le32(sizeof(*adapter->coal_conf));
+   cmdInfo->varConf.confPA  = cpu_to_le64(adapter->coal_conf_pa);
+
+   if (adapter->default_coal_mode) {
+   VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
+  VMXNET3_CMD_GET_COALESCE);
+   } else {
+   VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
+  VMXNET3_CMD_SET_COALESCE);
+   }
+
+   spin_unlock_irqrestore(>cmd_lock, flags);
+}
 
 int
 vmxnet3_activate_dev(struct vmxnet3_adapter *adapter)
@@ -2540,6 +2566,8 @@ vmxnet3_activate_dev(struct vmxnet3_adapter *adapter)
goto activate_err;
}
 
+   vmxnet3_init_coalesce(adapter);
+
for (i = 0; i < adapter->num_rx_queues; i++) {
VMXNET3_WRITE_BAR0_REG(adapter,
VMXNET3_REG_RXPROD + i * VMXNET3_REG_ALIGN,
@@ -3345,6 +3373,22 @@ vmxnet3_probe_device(struct pci_dev *pdev,
goto err_ver;
}
 
+   if (VMXNET3_VERSION_GE_3(adapter)) {
+   adapter->coal_conf =
+   dma_alloc_coherent(>pdev->dev,
+  sizeof(struct Vmxnet3_CoalesceScheme)
+  ,
+  >coal_conf_pa,
+  GFP_KERNEL);
+   if (!adapter->coal_conf) {
+   err = -ENOMEM;
+   goto err_ver;
+   }
+   memset(adapter->coal_conf,

[PATCH net-next v5 7/7] vmxnet3: update to version 3

2016-06-16 Thread Shrikrishna Khare
With all vmxnet3 version 3 changes incorporated in the vmxnet3 driver,
the driver can configure emulation to run at vmxnet3 version 3, provided
the emulation advertises support for version 3.

Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 7 ++-
 drivers/net/vmxnet3/vmxnet3_int.h | 4 ++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index d0bcc1d9..c68fe49 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -3345,7 +3345,12 @@ vmxnet3_probe_device(struct pci_dev *pdev,
goto err_alloc_pci;
 
ver = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_VRRS);
-   if (ver & (1 << VMXNET3_REV_2)) {
+   if (ver & (1 << VMXNET3_REV_3)) {
+   VMXNET3_WRITE_BAR1_REG(adapter,
+  VMXNET3_REG_VRRS,
+  1 << VMXNET3_REV_3);
+   adapter->version = VMXNET3_REV_3 + 1;
+   } else if (ver & (1 << VMXNET3_REV_2)) {
VMXNET3_WRITE_BAR1_REG(adapter,
   VMXNET3_REG_VRRS,
   1 << VMXNET3_REV_2);
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h 
b/drivers/net/vmxnet3/vmxnet3_int.h
index 63df4f2..74fc030 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.8.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.9.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM  0x01040800
+#define VMXNET3_DRIVER_VERSION_NUM  0x01040900
 
 #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
-- 
2.8.2



[PATCH net-next v5 7/7] vmxnet3: update to version 3

2016-06-16 Thread Shrikrishna Khare
With all vmxnet3 version 3 changes incorporated in the vmxnet3 driver,
the driver can configure emulation to run at vmxnet3 version 3, provided
the emulation advertises support for version 3.

Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 7 ++-
 drivers/net/vmxnet3/vmxnet3_int.h | 4 ++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index d0bcc1d9..c68fe49 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -3345,7 +3345,12 @@ vmxnet3_probe_device(struct pci_dev *pdev,
goto err_alloc_pci;
 
ver = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_VRRS);
-   if (ver & (1 << VMXNET3_REV_2)) {
+   if (ver & (1 << VMXNET3_REV_3)) {
+   VMXNET3_WRITE_BAR1_REG(adapter,
+  VMXNET3_REG_VRRS,
+  1 << VMXNET3_REV_3);
+   adapter->version = VMXNET3_REV_3 + 1;
+   } else if (ver & (1 << VMXNET3_REV_2)) {
VMXNET3_WRITE_BAR1_REG(adapter,
   VMXNET3_REG_VRRS,
   1 << VMXNET3_REV_2);
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h 
b/drivers/net/vmxnet3/vmxnet3_int.h
index 63df4f2..74fc030 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.8.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.9.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM  0x01040800
+#define VMXNET3_DRIVER_VERSION_NUM  0x01040900
 
 #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
-- 
2.8.2



[PATCH net-next v5 2/7] vmxnet3: introduce generalized command interface to configure the device

2016-06-16 Thread Shrikrishna Khare
Shared memory is used to exchange information between the vmxnet3 driver
and the emulation. In order to request emulation to perform a task, the
driver first populates specific fields in this shared memory and then
issues corresponding command by writing to the command register(CMD). The
layout of the shared memory was defined by vmxnet3 version 1 and cannot
be extended for every new command without breaking backward compatibility.

To address this problem, in vmxnet3 version 3, the emulation repurposed
a reserved field in the shared memory to represent command information
instead. For new commands, the driver first populates the command
information field in the shared memory and then issues the command. The
emulation interprets the data written to the command information depending
on the type of the command. This patch exposes this capability to the driver.

Signed-off-by: Guolin Yang <gy...@vmware.com>
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_defs.h | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 8345e0c..a26a69d 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -79,6 +79,7 @@ enum {
VMXNET3_CMD_RESERVED1,
VMXNET3_CMD_LOAD_PLUGIN,
VMXNET3_CMD_RESERVED2,
+   VMXNET3_CMD_RESERVED3,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -612,6 +613,18 @@ struct Vmxnet3_RxQueueDesc {
u8__pad[88]; /* 128 aligned */
 };
 
+struct Vmxnet3_SetPolling {
+   u8  enablePolling;
+};
+
+/* If the command data <= 16 bytes, use the shared memory directly.
+ * otherwise, use variable length configuration descriptor.
+ */
+union Vmxnet3_CmdInfo {
+   struct Vmxnet3_VariableLenConfDesc  varConf;
+   struct Vmxnet3_SetPolling   setPolling;
+   __le64  data[2];
+};
 
 struct Vmxnet3_DSDevRead {
/* read-only region for device, read by dev in response to a SET cmd */
@@ -630,7 +643,14 @@ struct Vmxnet3_DriverShared {
__le32  pad;
struct Vmxnet3_DSDevReaddevRead;
__le32  ecr;
-   __le32  reserved[5];
+   __le32  reserved;
+   union {
+   __le32  reserved1[4];
+   union Vmxnet3_CmdInfo   cmdInfo; /* only valid in the context of
+ * executing the relevant
+ * command
+ */
+   } cu;
 };
 
 
-- 
2.8.2



[PATCH net-next v5 2/7] vmxnet3: introduce generalized command interface to configure the device

2016-06-16 Thread Shrikrishna Khare
Shared memory is used to exchange information between the vmxnet3 driver
and the emulation. In order to request emulation to perform a task, the
driver first populates specific fields in this shared memory and then
issues corresponding command by writing to the command register(CMD). The
layout of the shared memory was defined by vmxnet3 version 1 and cannot
be extended for every new command without breaking backward compatibility.

To address this problem, in vmxnet3 version 3, the emulation repurposed
a reserved field in the shared memory to represent command information
instead. For new commands, the driver first populates the command
information field in the shared memory and then issues the command. The
emulation interprets the data written to the command information depending
on the type of the command. This patch exposes this capability to the driver.

Signed-off-by: Guolin Yang 
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_defs.h | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 8345e0c..a26a69d 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -79,6 +79,7 @@ enum {
VMXNET3_CMD_RESERVED1,
VMXNET3_CMD_LOAD_PLUGIN,
VMXNET3_CMD_RESERVED2,
+   VMXNET3_CMD_RESERVED3,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -612,6 +613,18 @@ struct Vmxnet3_RxQueueDesc {
u8__pad[88]; /* 128 aligned */
 };
 
+struct Vmxnet3_SetPolling {
+   u8  enablePolling;
+};
+
+/* If the command data <= 16 bytes, use the shared memory directly.
+ * otherwise, use variable length configuration descriptor.
+ */
+union Vmxnet3_CmdInfo {
+   struct Vmxnet3_VariableLenConfDesc  varConf;
+   struct Vmxnet3_SetPolling   setPolling;
+   __le64  data[2];
+};
 
 struct Vmxnet3_DSDevRead {
/* read-only region for device, read by dev in response to a SET cmd */
@@ -630,7 +643,14 @@ struct Vmxnet3_DriverShared {
__le32  pad;
struct Vmxnet3_DSDevReaddevRead;
__le32  ecr;
-   __le32  reserved[5];
+   __le32  reserved;
+   union {
+   __le32  reserved1[4];
+   union Vmxnet3_CmdInfo   cmdInfo; /* only valid in the context of
+ * executing the relevant
+ * command
+ */
+   } cu;
 };
 
 
-- 
2.8.2



[PATCH net-next v5 4/7] vmxnet3: add receive data ring support

2016-06-16 Thread Shrikrishna Khare
vmxnet3 driver preallocates buffers for receiving packets and posts the
buffers to the emulation. In order to deliver a received packet to the
guest, the emulation must map buffer(s) and copy the packet into it.

To avoid this memory mapping overhead, this patch introduces the receive
data ring - a set of small sized buffers that are always mapped by
the emulation. If a packet fits into the receive data ring buffer, the
emulation delivers the packet via the receive data ring (which must be
copied by the guest driver), or else the usual receive path is used.

Receive Data Ring buffer length is configurable via ethtool -G ethX rx-mini

Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_defs.h|  14 +++-
 drivers/net/vmxnet3/vmxnet3_drv.c | 153 +++---
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  48 ---
 drivers/net/vmxnet3/vmxnet3_int.h |  23 -
 4 files changed, 193 insertions(+), 45 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 701d989..f3b31c2 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -174,6 +174,8 @@ struct Vmxnet3_TxDataDesc {
u8  data[VMXNET3_HDR_COPY_SIZE];
 };
 
+typedef u8 Vmxnet3_RxDataDesc;
+
 #define VMXNET3_TCD_GEN_SHIFT  31
 #define VMXNET3_TCD_GEN_SIZE   1
 #define VMXNET3_TCD_TXIDX_SHIFT0
@@ -382,6 +384,10 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_TXDATA_DESC_SIZE_ALIGN 64
 #define VMXNET3_TXDATA_DESC_SIZE_MASK  (VMXNET3_TXDATA_DESC_SIZE_ALIGN - 1)
 
+/* Rx Data Ring buffer size must be a multiple of 64 */
+#define VMXNET3_RXDATA_DESC_SIZE_ALIGN 64
+#define VMXNET3_RXDATA_DESC_SIZE_MASK  (VMXNET3_RXDATA_DESC_SIZE_ALIGN - 1)
+
 /* Max ring size */
 #define VMXNET3_TX_RING_MAX_SIZE   4096
 #define VMXNET3_TC_RING_MAX_SIZE   4096
@@ -392,6 +398,8 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_TXDATA_DESC_MIN_SIZE 128
 #define VMXNET3_TXDATA_DESC_MAX_SIZE 2048
 
+#define VMXNET3_RXDATA_DESC_MAX_SIZE 2048
+
 /* a list of reasons for queue stop */
 
 enum {
@@ -488,12 +496,14 @@ struct Vmxnet3_RxQueueConf {
__le64  rxRingBasePA[2];
__le64  compRingBasePA;
__le64  ddPA;/* driver data */
-   __le64  reserved;
+   __le64  rxDataRingBasePA;
__le32  rxRingSize[2];   /* # of rx desc */
__le32  compRingSize;/* # of rx comp desc */
__le32  ddLen;   /* size of driver data */
u8  intrIdx;
-   u8  _pad[7];
+   u8  _pad1[1];
+   __le16  rxDataRingDescSize;  /* size of rx data ring buffer */
+   u8  _pad2[4];
 };
 
 
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 4e42eb0..6449d2e 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1284,9 +1284,10 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
 */
break;
}
-   BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2);
+   BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2 &&
+  rcd->rqID != rq->dataRingQid);
idx = rcd->rxdIdx;
-   ring_idx = rcd->rqID < adapter->num_rx_queues ? 0 : 1;
+   ring_idx = VMXNET3_GET_RING_IDX(adapter, rcd->rqID);
ring = rq->rx_ring + ring_idx;
vmxnet3_getRxDesc(rxd, >rx_ring[ring_idx].base[idx].rxd,
  );
@@ -1301,8 +1302,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
}
 
if (rcd->sop) { /* first buf of the pkt */
+   bool rxDataRingUsed;
+   u16 len;
+
BUG_ON(rxd->btype != VMXNET3_RXD_BTYPE_HEAD ||
-  rcd->rqID != rq->qid);
+  (rcd->rqID != rq->qid &&
+   rcd->rqID != rq->dataRingQid));
 
BUG_ON(rbi->buf_type != VMXNET3_RX_BUF_SKB);
BUG_ON(ctx->skb != NULL || rbi->skb == NULL);
@@ -1318,8 +1323,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
 
skip_page_frags = false;
ctx->skb = rbi->skb;
+
+   rxDataRingUsed =
+   VMXNET3_RX_DATA_RING(adapter, rcd->rqID);
+   len = rxDataRingUsed ? rcd->len : rbi->len;
new_skb = netdev_alloc_skb_ip_align(adapter->netdev,
-   rbi->len);
+  

[PATCH net-next v5 4/7] vmxnet3: add receive data ring support

2016-06-16 Thread Shrikrishna Khare
vmxnet3 driver preallocates buffers for receiving packets and posts the
buffers to the emulation. In order to deliver a received packet to the
guest, the emulation must map buffer(s) and copy the packet into it.

To avoid this memory mapping overhead, this patch introduces the receive
data ring - a set of small sized buffers that are always mapped by
the emulation. If a packet fits into the receive data ring buffer, the
emulation delivers the packet via the receive data ring (which must be
copied by the guest driver), or else the usual receive path is used.

Receive Data Ring buffer length is configurable via ethtool -G ethX rx-mini

Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_defs.h|  14 +++-
 drivers/net/vmxnet3/vmxnet3_drv.c | 153 +++---
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  48 ---
 drivers/net/vmxnet3/vmxnet3_int.h |  23 -
 4 files changed, 193 insertions(+), 45 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 701d989..f3b31c2 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -174,6 +174,8 @@ struct Vmxnet3_TxDataDesc {
u8  data[VMXNET3_HDR_COPY_SIZE];
 };
 
+typedef u8 Vmxnet3_RxDataDesc;
+
 #define VMXNET3_TCD_GEN_SHIFT  31
 #define VMXNET3_TCD_GEN_SIZE   1
 #define VMXNET3_TCD_TXIDX_SHIFT0
@@ -382,6 +384,10 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_TXDATA_DESC_SIZE_ALIGN 64
 #define VMXNET3_TXDATA_DESC_SIZE_MASK  (VMXNET3_TXDATA_DESC_SIZE_ALIGN - 1)
 
+/* Rx Data Ring buffer size must be a multiple of 64 */
+#define VMXNET3_RXDATA_DESC_SIZE_ALIGN 64
+#define VMXNET3_RXDATA_DESC_SIZE_MASK  (VMXNET3_RXDATA_DESC_SIZE_ALIGN - 1)
+
 /* Max ring size */
 #define VMXNET3_TX_RING_MAX_SIZE   4096
 #define VMXNET3_TC_RING_MAX_SIZE   4096
@@ -392,6 +398,8 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_TXDATA_DESC_MIN_SIZE 128
 #define VMXNET3_TXDATA_DESC_MAX_SIZE 2048
 
+#define VMXNET3_RXDATA_DESC_MAX_SIZE 2048
+
 /* a list of reasons for queue stop */
 
 enum {
@@ -488,12 +496,14 @@ struct Vmxnet3_RxQueueConf {
__le64  rxRingBasePA[2];
__le64  compRingBasePA;
__le64  ddPA;/* driver data */
-   __le64  reserved;
+   __le64  rxDataRingBasePA;
__le32  rxRingSize[2];   /* # of rx desc */
__le32  compRingSize;/* # of rx comp desc */
__le32  ddLen;   /* size of driver data */
u8  intrIdx;
-   u8  _pad[7];
+   u8  _pad1[1];
+   __le16  rxDataRingDescSize;  /* size of rx data ring buffer */
+   u8  _pad2[4];
 };
 
 
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 4e42eb0..6449d2e 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1284,9 +1284,10 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
 */
break;
}
-   BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2);
+   BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2 &&
+  rcd->rqID != rq->dataRingQid);
idx = rcd->rxdIdx;
-   ring_idx = rcd->rqID < adapter->num_rx_queues ? 0 : 1;
+   ring_idx = VMXNET3_GET_RING_IDX(adapter, rcd->rqID);
ring = rq->rx_ring + ring_idx;
vmxnet3_getRxDesc(rxd, >rx_ring[ring_idx].base[idx].rxd,
  );
@@ -1301,8 +1302,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
}
 
if (rcd->sop) { /* first buf of the pkt */
+   bool rxDataRingUsed;
+   u16 len;
+
BUG_ON(rxd->btype != VMXNET3_RXD_BTYPE_HEAD ||
-  rcd->rqID != rq->qid);
+  (rcd->rqID != rq->qid &&
+   rcd->rqID != rq->dataRingQid));
 
BUG_ON(rbi->buf_type != VMXNET3_RX_BUF_SKB);
BUG_ON(ctx->skb != NULL || rbi->skb == NULL);
@@ -1318,8 +1323,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
 
skip_page_frags = false;
ctx->skb = rbi->skb;
+
+   rxDataRingUsed =
+   VMXNET3_RX_DATA_RING(adapter, rcd->rqID);
+   len = rxDataRingUsed ? rcd->len : rbi->len;
new_skb = netdev_alloc_skb_ip_align(adapter->netdev,
-   rbi->len);
+

[PATCH net-next v5 1/7] vmxnet3: prepare for version 3 changes

2016-06-16 Thread Shrikrishna Khare
vmxnet3 is currently at version 2, but some command definitions from
previous vmxnet3 versions are missing. Add those definitions before
moving to version 3.

Also, introduce utility macros for vmxnet3 version comparison and update
Copyright information and Maintained by.

Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/Makefile  |  4 ++--
 drivers/net/vmxnet3/upt1_defs.h   |  4 ++--
 drivers/net/vmxnet3/vmxnet3_defs.h|  9 ++---
 drivers/net/vmxnet3/vmxnet3_drv.c | 22 +-
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  4 ++--
 drivers/net/vmxnet3/vmxnet3_int.h | 13 +++--
 6 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/drivers/net/vmxnet3/Makefile b/drivers/net/vmxnet3/Makefile
index 880f509..8cdbb63 100644
--- a/drivers/net/vmxnet3/Makefile
+++ b/drivers/net/vmxnet3/Makefile
@@ -2,7 +2,7 @@
 #
 # Linux driver for VMware's vmxnet3 ethernet NIC.
 #
-# Copyright (C) 2007-2009, VMware, Inc. All Rights Reserved.
+# Copyright (C) 2007-2016, VMware, Inc. All Rights Reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by the
@@ -21,7 +21,7 @@
 # The full GNU General Public License is included in this distribution in
 # the file called "COPYING".
 #
-# Maintained by: Shreyas Bhatewara <pv-driv...@vmware.com>
+# Maintained by: pv-driv...@vmware.com
 #
 #
 

diff --git a/drivers/net/vmxnet3/upt1_defs.h b/drivers/net/vmxnet3/upt1_defs.h
index 969c751..db9f1fd 100644
--- a/drivers/net/vmxnet3/upt1_defs.h
+++ b/drivers/net/vmxnet3/upt1_defs.h
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara <pv-driv...@vmware.com>
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 72ba8ae..8345e0c 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2015, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara <pv-driv...@vmware.com>
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
@@ -76,7 +76,9 @@ enum {
VMXNET3_CMD_UPDATE_IML,
VMXNET3_CMD_UPDATE_PMCFG,
VMXNET3_CMD_UPDATE_FEATURE,
+   VMXNET3_CMD_RESERVED1,
VMXNET3_CMD_LOAD_PLUGIN,
+   VMXNET3_CMD_RESERVED2,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -87,7 +89,8 @@ enum {
VMXNET3_CMD_GET_DID_LO,
VMXNET3_CMD_GET_DID_HI,
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
-   VMXNET3_CMD_GET_CONF_INTR
+   VMXNET3_CMD_GET_CONF_INTR,
+   VMXNET3_CMD_GET_RESERVED1,
 };
 
 /*
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 08885bc..507c53d 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara <pv-driv...@vmware.com>
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
@@ -1363,7 +1363,7 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
rbi->dma_addr = new_dma_addr;
rxd->addr = cpu_to_le64(rbi->dma_addr);
rxd->len = rbi->len;
-   if (adapter->version == 2 &&
+   if (VMXNET3_VERSION_GE_2(adapter) &&
rcd-&g

[PATCH net-next v5 1/7] vmxnet3: prepare for version 3 changes

2016-06-16 Thread Shrikrishna Khare
vmxnet3 is currently at version 2, but some command definitions from
previous vmxnet3 versions are missing. Add those definitions before
moving to version 3.

Also, introduce utility macros for vmxnet3 version comparison and update
Copyright information and Maintained by.

Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/Makefile  |  4 ++--
 drivers/net/vmxnet3/upt1_defs.h   |  4 ++--
 drivers/net/vmxnet3/vmxnet3_defs.h|  9 ++---
 drivers/net/vmxnet3/vmxnet3_drv.c | 22 +-
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  4 ++--
 drivers/net/vmxnet3/vmxnet3_int.h | 13 +++--
 6 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/drivers/net/vmxnet3/Makefile b/drivers/net/vmxnet3/Makefile
index 880f509..8cdbb63 100644
--- a/drivers/net/vmxnet3/Makefile
+++ b/drivers/net/vmxnet3/Makefile
@@ -2,7 +2,7 @@
 #
 # Linux driver for VMware's vmxnet3 ethernet NIC.
 #
-# Copyright (C) 2007-2009, VMware, Inc. All Rights Reserved.
+# Copyright (C) 2007-2016, VMware, Inc. All Rights Reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by the
@@ -21,7 +21,7 @@
 # The full GNU General Public License is included in this distribution in
 # the file called "COPYING".
 #
-# Maintained by: Shreyas Bhatewara 
+# Maintained by: pv-driv...@vmware.com
 #
 #
 

diff --git a/drivers/net/vmxnet3/upt1_defs.h b/drivers/net/vmxnet3/upt1_defs.h
index 969c751..db9f1fd 100644
--- a/drivers/net/vmxnet3/upt1_defs.h
+++ b/drivers/net/vmxnet3/upt1_defs.h
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara 
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 72ba8ae..8345e0c 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2015, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara 
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
@@ -76,7 +76,9 @@ enum {
VMXNET3_CMD_UPDATE_IML,
VMXNET3_CMD_UPDATE_PMCFG,
VMXNET3_CMD_UPDATE_FEATURE,
+   VMXNET3_CMD_RESERVED1,
VMXNET3_CMD_LOAD_PLUGIN,
+   VMXNET3_CMD_RESERVED2,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -87,7 +89,8 @@ enum {
VMXNET3_CMD_GET_DID_LO,
VMXNET3_CMD_GET_DID_HI,
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
-   VMXNET3_CMD_GET_CONF_INTR
+   VMXNET3_CMD_GET_CONF_INTR,
+   VMXNET3_CMD_GET_RESERVED1,
 };
 
 /*
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 08885bc..507c53d 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara 
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
@@ -1363,7 +1363,7 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
rbi->dma_addr = new_dma_addr;
rxd->addr = cpu_to_le64(rbi->dma_addr);
rxd->len = rbi->len;
-   if (adapter->version == 2 &&
+   if (VMXNET3_VERSION_GE_2(adapter) &&
rcd->type == VMXNET3_CDTYPE_RXCOMP_LRO) {
struct Vmxnet3_RxCompDescExt *rcdlro;
rcdlro = (str

[PATCH net-next v4 7/7] vmxnet3: update to version 3

2016-06-14 Thread Shrikrishna Khare
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 7 ++-
 drivers/net/vmxnet3/vmxnet3_int.h | 4 ++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index d0bcc1d9..c68fe49 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -3345,7 +3345,12 @@ vmxnet3_probe_device(struct pci_dev *pdev,
goto err_alloc_pci;
 
ver = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_VRRS);
-   if (ver & (1 << VMXNET3_REV_2)) {
+   if (ver & (1 << VMXNET3_REV_3)) {
+   VMXNET3_WRITE_BAR1_REG(adapter,
+  VMXNET3_REG_VRRS,
+  1 << VMXNET3_REV_3);
+   adapter->version = VMXNET3_REV_3 + 1;
+   } else if (ver & (1 << VMXNET3_REV_2)) {
VMXNET3_WRITE_BAR1_REG(adapter,
   VMXNET3_REG_VRRS,
   1 << VMXNET3_REV_2);
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h 
b/drivers/net/vmxnet3/vmxnet3_int.h
index 63df4f2..74fc030 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.8.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.9.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM  0x01040800
+#define VMXNET3_DRIVER_VERSION_NUM  0x01040900
 
 #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
-- 
2.8.2



[PATCH net-next v4 3/7] vmxnet3: allow variable length transmit data ring buffer

2016-06-14 Thread Shrikrishna Khare
Signed-off-by: Sriram Rangarajan <rangaraj...@vmware.com>
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_defs.h| 12 +++-
 drivers/net/vmxnet3/vmxnet3_drv.c | 55 ++-
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  9 +++---
 drivers/net/vmxnet3/vmxnet3_int.h |  7 -
 4 files changed, 64 insertions(+), 19 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index a26a69d..701d989 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -92,6 +92,7 @@ enum {
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
VMXNET3_CMD_GET_CONF_INTR,
VMXNET3_CMD_GET_RESERVED1,
+   VMXNET3_CMD_GET_TXDATA_DESC_SIZE
 };
 
 /*
@@ -377,6 +378,10 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_RING_SIZE_ALIGN 32
 #define VMXNET3_RING_SIZE_MASK  (VMXNET3_RING_SIZE_ALIGN - 1)
 
+/* Tx Data Ring buffer size must be a multiple of 64 */
+#define VMXNET3_TXDATA_DESC_SIZE_ALIGN 64
+#define VMXNET3_TXDATA_DESC_SIZE_MASK  (VMXNET3_TXDATA_DESC_SIZE_ALIGN - 1)
+
 /* Max ring size */
 #define VMXNET3_TX_RING_MAX_SIZE   4096
 #define VMXNET3_TC_RING_MAX_SIZE   4096
@@ -384,6 +389,9 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_RX_RING2_MAX_SIZE  4096
 #define VMXNET3_RC_RING_MAX_SIZE   8192
 
+#define VMXNET3_TXDATA_DESC_MIN_SIZE 128
+#define VMXNET3_TXDATA_DESC_MAX_SIZE 2048
+
 /* a list of reasons for queue stop */
 
 enum {
@@ -470,7 +478,9 @@ struct Vmxnet3_TxQueueConf {
__le32  compRingSize; /* # of comp desc */
__le32  ddLen;/* size of driver data */
u8  intrIdx;
-   u8  _pad[7];
+   u8  _pad1[1];
+   __le16  txDataRingDescSize;
+   u8  _pad2[4];
 };
 
 
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 507c53d..4e42eb0 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -435,8 +435,8 @@ vmxnet3_tq_destroy(struct vmxnet3_tx_queue *tq,
tq->tx_ring.base = NULL;
}
if (tq->data_ring.base) {
-   dma_free_coherent(>pdev->dev, tq->data_ring.size *
- sizeof(struct Vmxnet3_TxDataDesc),
+   dma_free_coherent(>pdev->dev,
+ tq->data_ring.size * tq->txdata_desc_size,
  tq->data_ring.base, tq->data_ring.basePA);
tq->data_ring.base = NULL;
}
@@ -478,8 +478,8 @@ vmxnet3_tq_init(struct vmxnet3_tx_queue *tq,
tq->tx_ring.next2fill = tq->tx_ring.next2comp = 0;
tq->tx_ring.gen = VMXNET3_INIT_GEN;
 
-   memset(tq->data_ring.base, 0, tq->data_ring.size *
-  sizeof(struct Vmxnet3_TxDataDesc));
+   memset(tq->data_ring.base, 0,
+  tq->data_ring.size * tq->txdata_desc_size);
 
/* reset the tx comp ring contents to 0 and reset comp ring states */
memset(tq->comp_ring.base, 0, tq->comp_ring.size *
@@ -514,10 +514,10 @@ vmxnet3_tq_create(struct vmxnet3_tx_queue *tq,
}
 
tq->data_ring.base = dma_alloc_coherent(>pdev->dev,
-   tq->data_ring.size * sizeof(struct Vmxnet3_TxDataDesc),
+   tq->data_ring.size * tq->txdata_desc_size,
>data_ring.basePA, GFP_KERNEL);
if (!tq->data_ring.base) {
-   netdev_err(adapter->netdev, "failed to allocate data ring\n");
+   netdev_err(adapter->netdev, "failed to allocate tx data 
ring\n");
goto err;
}
 
@@ -689,7 +689,7 @@ vmxnet3_map_pkt(struct sk_buff *skb, struct vmxnet3_tx_ctx 
*ctx,
if (ctx->copy_size) {
ctx->sop_txd->txd.addr = cpu_to_le64(tq->data_ring.basePA +
tq->tx_ring.next2fill *
-   sizeof(struct Vmxnet3_TxDataDesc));
+   tq->txdata_desc_size);
ctx->sop_txd->dword[2] = cpu_to_le32(dw2 | ctx->copy_size);
ctx->sop_txd->dword[3] = 0;
 
@@ -873,8 +873,9 @@ vmxnet3_parse_hdr(struct sk_buff *skb, struct 
vmxnet3_tx_queue *tq,
ctx->eth_ip_hdr_size = 0;
ctx->l4_hdr_size = 0;
/* copy as much as allowed */
-   ctx->copy_size = min((unsigned int)VMXNET3_HDR_COPY_SIZE
-, skb_headlen(skb));
+   ctx->copy_size = min_t(unsigned int,
+  tq->txdata_desc_size,
+  skb_headlen(skb));
}
 

[PATCH net-next v4 7/7] vmxnet3: update to version 3

2016-06-14 Thread Shrikrishna Khare
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 7 ++-
 drivers/net/vmxnet3/vmxnet3_int.h | 4 ++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index d0bcc1d9..c68fe49 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -3345,7 +3345,12 @@ vmxnet3_probe_device(struct pci_dev *pdev,
goto err_alloc_pci;
 
ver = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_VRRS);
-   if (ver & (1 << VMXNET3_REV_2)) {
+   if (ver & (1 << VMXNET3_REV_3)) {
+   VMXNET3_WRITE_BAR1_REG(adapter,
+  VMXNET3_REG_VRRS,
+  1 << VMXNET3_REV_3);
+   adapter->version = VMXNET3_REV_3 + 1;
+   } else if (ver & (1 << VMXNET3_REV_2)) {
VMXNET3_WRITE_BAR1_REG(adapter,
   VMXNET3_REG_VRRS,
   1 << VMXNET3_REV_2);
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h 
b/drivers/net/vmxnet3/vmxnet3_int.h
index 63df4f2..74fc030 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.8.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.9.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM  0x01040800
+#define VMXNET3_DRIVER_VERSION_NUM  0x01040900
 
 #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
-- 
2.8.2



[PATCH net-next v4 3/7] vmxnet3: allow variable length transmit data ring buffer

2016-06-14 Thread Shrikrishna Khare
Signed-off-by: Sriram Rangarajan 
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_defs.h| 12 +++-
 drivers/net/vmxnet3/vmxnet3_drv.c | 55 ++-
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  9 +++---
 drivers/net/vmxnet3/vmxnet3_int.h |  7 -
 4 files changed, 64 insertions(+), 19 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index a26a69d..701d989 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -92,6 +92,7 @@ enum {
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
VMXNET3_CMD_GET_CONF_INTR,
VMXNET3_CMD_GET_RESERVED1,
+   VMXNET3_CMD_GET_TXDATA_DESC_SIZE
 };
 
 /*
@@ -377,6 +378,10 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_RING_SIZE_ALIGN 32
 #define VMXNET3_RING_SIZE_MASK  (VMXNET3_RING_SIZE_ALIGN - 1)
 
+/* Tx Data Ring buffer size must be a multiple of 64 */
+#define VMXNET3_TXDATA_DESC_SIZE_ALIGN 64
+#define VMXNET3_TXDATA_DESC_SIZE_MASK  (VMXNET3_TXDATA_DESC_SIZE_ALIGN - 1)
+
 /* Max ring size */
 #define VMXNET3_TX_RING_MAX_SIZE   4096
 #define VMXNET3_TC_RING_MAX_SIZE   4096
@@ -384,6 +389,9 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_RX_RING2_MAX_SIZE  4096
 #define VMXNET3_RC_RING_MAX_SIZE   8192
 
+#define VMXNET3_TXDATA_DESC_MIN_SIZE 128
+#define VMXNET3_TXDATA_DESC_MAX_SIZE 2048
+
 /* a list of reasons for queue stop */
 
 enum {
@@ -470,7 +478,9 @@ struct Vmxnet3_TxQueueConf {
__le32  compRingSize; /* # of comp desc */
__le32  ddLen;/* size of driver data */
u8  intrIdx;
-   u8  _pad[7];
+   u8  _pad1[1];
+   __le16  txDataRingDescSize;
+   u8  _pad2[4];
 };
 
 
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 507c53d..4e42eb0 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -435,8 +435,8 @@ vmxnet3_tq_destroy(struct vmxnet3_tx_queue *tq,
tq->tx_ring.base = NULL;
}
if (tq->data_ring.base) {
-   dma_free_coherent(>pdev->dev, tq->data_ring.size *
- sizeof(struct Vmxnet3_TxDataDesc),
+   dma_free_coherent(>pdev->dev,
+ tq->data_ring.size * tq->txdata_desc_size,
  tq->data_ring.base, tq->data_ring.basePA);
tq->data_ring.base = NULL;
}
@@ -478,8 +478,8 @@ vmxnet3_tq_init(struct vmxnet3_tx_queue *tq,
tq->tx_ring.next2fill = tq->tx_ring.next2comp = 0;
tq->tx_ring.gen = VMXNET3_INIT_GEN;
 
-   memset(tq->data_ring.base, 0, tq->data_ring.size *
-  sizeof(struct Vmxnet3_TxDataDesc));
+   memset(tq->data_ring.base, 0,
+  tq->data_ring.size * tq->txdata_desc_size);
 
/* reset the tx comp ring contents to 0 and reset comp ring states */
memset(tq->comp_ring.base, 0, tq->comp_ring.size *
@@ -514,10 +514,10 @@ vmxnet3_tq_create(struct vmxnet3_tx_queue *tq,
}
 
tq->data_ring.base = dma_alloc_coherent(>pdev->dev,
-   tq->data_ring.size * sizeof(struct Vmxnet3_TxDataDesc),
+   tq->data_ring.size * tq->txdata_desc_size,
>data_ring.basePA, GFP_KERNEL);
if (!tq->data_ring.base) {
-   netdev_err(adapter->netdev, "failed to allocate data ring\n");
+   netdev_err(adapter->netdev, "failed to allocate tx data 
ring\n");
goto err;
}
 
@@ -689,7 +689,7 @@ vmxnet3_map_pkt(struct sk_buff *skb, struct vmxnet3_tx_ctx 
*ctx,
if (ctx->copy_size) {
ctx->sop_txd->txd.addr = cpu_to_le64(tq->data_ring.basePA +
tq->tx_ring.next2fill *
-   sizeof(struct Vmxnet3_TxDataDesc));
+   tq->txdata_desc_size);
ctx->sop_txd->dword[2] = cpu_to_le32(dw2 | ctx->copy_size);
ctx->sop_txd->dword[3] = 0;
 
@@ -873,8 +873,9 @@ vmxnet3_parse_hdr(struct sk_buff *skb, struct 
vmxnet3_tx_queue *tq,
ctx->eth_ip_hdr_size = 0;
ctx->l4_hdr_size = 0;
/* copy as much as allowed */
-   ctx->copy_size = min((unsigned int)VMXNET3_HDR_COPY_SIZE
-, skb_headlen(skb));
+   ctx->copy_size = min_t(unsigned int,
+  tq->txdata_desc_size,
+  skb_headlen(skb));
}
 
if (skb->len <= VMXNET3_HDR_COPY_SIZE)

[PATCH net-next v4 2/7] vmxnet3: introduce generic command interface to configure the device

2016-06-14 Thread Shrikrishna Khare
Signed-off-by: Guolin Yang <gy...@vmware.com>
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_defs.h | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 8345e0c..a26a69d 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -79,6 +79,7 @@ enum {
VMXNET3_CMD_RESERVED1,
VMXNET3_CMD_LOAD_PLUGIN,
VMXNET3_CMD_RESERVED2,
+   VMXNET3_CMD_RESERVED3,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -612,6 +613,18 @@ struct Vmxnet3_RxQueueDesc {
u8__pad[88]; /* 128 aligned */
 };
 
+struct Vmxnet3_SetPolling {
+   u8  enablePolling;
+};
+
+/* If the command data <= 16 bytes, use the shared memory directly.
+ * otherwise, use variable length configuration descriptor.
+ */
+union Vmxnet3_CmdInfo {
+   struct Vmxnet3_VariableLenConfDesc  varConf;
+   struct Vmxnet3_SetPolling   setPolling;
+   __le64  data[2];
+};
 
 struct Vmxnet3_DSDevRead {
/* read-only region for device, read by dev in response to a SET cmd */
@@ -630,7 +643,14 @@ struct Vmxnet3_DriverShared {
__le32  pad;
struct Vmxnet3_DSDevReaddevRead;
__le32  ecr;
-   __le32  reserved[5];
+   __le32  reserved;
+   union {
+   __le32  reserved1[4];
+   union Vmxnet3_CmdInfo   cmdInfo; /* only valid in the context of
+ * executing the relevant
+ * command
+ */
+   } cu;
 };
 
 
-- 
2.8.2



[PATCH net-next v4 4/7] vmxnet3: add receive data ring support

2016-06-14 Thread Shrikrishna Khare
Receive Data Ring buffer length is configurable via ethtool -G ethX rx-mini

Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_defs.h|  14 +++-
 drivers/net/vmxnet3/vmxnet3_drv.c | 153 +++---
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  48 ---
 drivers/net/vmxnet3/vmxnet3_int.h |  23 -
 4 files changed, 193 insertions(+), 45 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 701d989..f3b31c2 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -174,6 +174,8 @@ struct Vmxnet3_TxDataDesc {
u8  data[VMXNET3_HDR_COPY_SIZE];
 };
 
+typedef u8 Vmxnet3_RxDataDesc;
+
 #define VMXNET3_TCD_GEN_SHIFT  31
 #define VMXNET3_TCD_GEN_SIZE   1
 #define VMXNET3_TCD_TXIDX_SHIFT0
@@ -382,6 +384,10 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_TXDATA_DESC_SIZE_ALIGN 64
 #define VMXNET3_TXDATA_DESC_SIZE_MASK  (VMXNET3_TXDATA_DESC_SIZE_ALIGN - 1)
 
+/* Rx Data Ring buffer size must be a multiple of 64 */
+#define VMXNET3_RXDATA_DESC_SIZE_ALIGN 64
+#define VMXNET3_RXDATA_DESC_SIZE_MASK  (VMXNET3_RXDATA_DESC_SIZE_ALIGN - 1)
+
 /* Max ring size */
 #define VMXNET3_TX_RING_MAX_SIZE   4096
 #define VMXNET3_TC_RING_MAX_SIZE   4096
@@ -392,6 +398,8 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_TXDATA_DESC_MIN_SIZE 128
 #define VMXNET3_TXDATA_DESC_MAX_SIZE 2048
 
+#define VMXNET3_RXDATA_DESC_MAX_SIZE 2048
+
 /* a list of reasons for queue stop */
 
 enum {
@@ -488,12 +496,14 @@ struct Vmxnet3_RxQueueConf {
__le64  rxRingBasePA[2];
__le64  compRingBasePA;
__le64  ddPA;/* driver data */
-   __le64  reserved;
+   __le64  rxDataRingBasePA;
__le32  rxRingSize[2];   /* # of rx desc */
__le32  compRingSize;/* # of rx comp desc */
__le32  ddLen;   /* size of driver data */
u8  intrIdx;
-   u8  _pad[7];
+   u8  _pad1[1];
+   __le16  rxDataRingDescSize;  /* size of rx data ring buffer */
+   u8  _pad2[4];
 };
 
 
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 4e42eb0..6449d2e 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1284,9 +1284,10 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
 */
break;
}
-   BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2);
+   BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2 &&
+  rcd->rqID != rq->dataRingQid);
idx = rcd->rxdIdx;
-   ring_idx = rcd->rqID < adapter->num_rx_queues ? 0 : 1;
+   ring_idx = VMXNET3_GET_RING_IDX(adapter, rcd->rqID);
ring = rq->rx_ring + ring_idx;
vmxnet3_getRxDesc(rxd, >rx_ring[ring_idx].base[idx].rxd,
  );
@@ -1301,8 +1302,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
}
 
if (rcd->sop) { /* first buf of the pkt */
+   bool rxDataRingUsed;
+   u16 len;
+
BUG_ON(rxd->btype != VMXNET3_RXD_BTYPE_HEAD ||
-  rcd->rqID != rq->qid);
+  (rcd->rqID != rq->qid &&
+   rcd->rqID != rq->dataRingQid));
 
BUG_ON(rbi->buf_type != VMXNET3_RX_BUF_SKB);
BUG_ON(ctx->skb != NULL || rbi->skb == NULL);
@@ -1318,8 +1323,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
 
skip_page_frags = false;
ctx->skb = rbi->skb;
+
+   rxDataRingUsed =
+   VMXNET3_RX_DATA_RING(adapter, rcd->rqID);
+   len = rxDataRingUsed ? rcd->len : rbi->len;
new_skb = netdev_alloc_skb_ip_align(adapter->netdev,
-   rbi->len);
+   len);
if (new_skb == NULL) {
/* Skb allocation failed, do not handover this
 * skb to stack. Reuse it. Drop the existing pkt
@@ -1330,25 +1339,48 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
skip_page_frags = true;
goto rcd_done;
}
-   new_dma_addr = dma_map_single(>pdev->dev,
- new_skb

[PATCH net-next v4 2/7] vmxnet3: introduce generic command interface to configure the device

2016-06-14 Thread Shrikrishna Khare
Signed-off-by: Guolin Yang 
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_defs.h | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 8345e0c..a26a69d 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -79,6 +79,7 @@ enum {
VMXNET3_CMD_RESERVED1,
VMXNET3_CMD_LOAD_PLUGIN,
VMXNET3_CMD_RESERVED2,
+   VMXNET3_CMD_RESERVED3,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -612,6 +613,18 @@ struct Vmxnet3_RxQueueDesc {
u8__pad[88]; /* 128 aligned */
 };
 
+struct Vmxnet3_SetPolling {
+   u8  enablePolling;
+};
+
+/* If the command data <= 16 bytes, use the shared memory directly.
+ * otherwise, use variable length configuration descriptor.
+ */
+union Vmxnet3_CmdInfo {
+   struct Vmxnet3_VariableLenConfDesc  varConf;
+   struct Vmxnet3_SetPolling   setPolling;
+   __le64  data[2];
+};
 
 struct Vmxnet3_DSDevRead {
/* read-only region for device, read by dev in response to a SET cmd */
@@ -630,7 +643,14 @@ struct Vmxnet3_DriverShared {
__le32  pad;
struct Vmxnet3_DSDevReaddevRead;
__le32  ecr;
-   __le32  reserved[5];
+   __le32  reserved;
+   union {
+   __le32  reserved1[4];
+   union Vmxnet3_CmdInfo   cmdInfo; /* only valid in the context of
+ * executing the relevant
+ * command
+ */
+   } cu;
 };
 
 
-- 
2.8.2



[PATCH net-next v4 4/7] vmxnet3: add receive data ring support

2016-06-14 Thread Shrikrishna Khare
Receive Data Ring buffer length is configurable via ethtool -G ethX rx-mini

Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_defs.h|  14 +++-
 drivers/net/vmxnet3/vmxnet3_drv.c | 153 +++---
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  48 ---
 drivers/net/vmxnet3/vmxnet3_int.h |  23 -
 4 files changed, 193 insertions(+), 45 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 701d989..f3b31c2 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -174,6 +174,8 @@ struct Vmxnet3_TxDataDesc {
u8  data[VMXNET3_HDR_COPY_SIZE];
 };
 
+typedef u8 Vmxnet3_RxDataDesc;
+
 #define VMXNET3_TCD_GEN_SHIFT  31
 #define VMXNET3_TCD_GEN_SIZE   1
 #define VMXNET3_TCD_TXIDX_SHIFT0
@@ -382,6 +384,10 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_TXDATA_DESC_SIZE_ALIGN 64
 #define VMXNET3_TXDATA_DESC_SIZE_MASK  (VMXNET3_TXDATA_DESC_SIZE_ALIGN - 1)
 
+/* Rx Data Ring buffer size must be a multiple of 64 */
+#define VMXNET3_RXDATA_DESC_SIZE_ALIGN 64
+#define VMXNET3_RXDATA_DESC_SIZE_MASK  (VMXNET3_RXDATA_DESC_SIZE_ALIGN - 1)
+
 /* Max ring size */
 #define VMXNET3_TX_RING_MAX_SIZE   4096
 #define VMXNET3_TC_RING_MAX_SIZE   4096
@@ -392,6 +398,8 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_TXDATA_DESC_MIN_SIZE 128
 #define VMXNET3_TXDATA_DESC_MAX_SIZE 2048
 
+#define VMXNET3_RXDATA_DESC_MAX_SIZE 2048
+
 /* a list of reasons for queue stop */
 
 enum {
@@ -488,12 +496,14 @@ struct Vmxnet3_RxQueueConf {
__le64  rxRingBasePA[2];
__le64  compRingBasePA;
__le64  ddPA;/* driver data */
-   __le64  reserved;
+   __le64  rxDataRingBasePA;
__le32  rxRingSize[2];   /* # of rx desc */
__le32  compRingSize;/* # of rx comp desc */
__le32  ddLen;   /* size of driver data */
u8  intrIdx;
-   u8  _pad[7];
+   u8  _pad1[1];
+   __le16  rxDataRingDescSize;  /* size of rx data ring buffer */
+   u8  _pad2[4];
 };
 
 
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 4e42eb0..6449d2e 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1284,9 +1284,10 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
 */
break;
}
-   BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2);
+   BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2 &&
+  rcd->rqID != rq->dataRingQid);
idx = rcd->rxdIdx;
-   ring_idx = rcd->rqID < adapter->num_rx_queues ? 0 : 1;
+   ring_idx = VMXNET3_GET_RING_IDX(adapter, rcd->rqID);
ring = rq->rx_ring + ring_idx;
vmxnet3_getRxDesc(rxd, >rx_ring[ring_idx].base[idx].rxd,
  );
@@ -1301,8 +1302,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
}
 
if (rcd->sop) { /* first buf of the pkt */
+   bool rxDataRingUsed;
+   u16 len;
+
BUG_ON(rxd->btype != VMXNET3_RXD_BTYPE_HEAD ||
-  rcd->rqID != rq->qid);
+  (rcd->rqID != rq->qid &&
+   rcd->rqID != rq->dataRingQid));
 
BUG_ON(rbi->buf_type != VMXNET3_RX_BUF_SKB);
BUG_ON(ctx->skb != NULL || rbi->skb == NULL);
@@ -1318,8 +1323,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
 
skip_page_frags = false;
ctx->skb = rbi->skb;
+
+   rxDataRingUsed =
+   VMXNET3_RX_DATA_RING(adapter, rcd->rqID);
+   len = rxDataRingUsed ? rcd->len : rbi->len;
new_skb = netdev_alloc_skb_ip_align(adapter->netdev,
-   rbi->len);
+   len);
if (new_skb == NULL) {
/* Skb allocation failed, do not handover this
 * skb to stack. Reuse it. Drop the existing pkt
@@ -1330,25 +1339,48 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
skip_page_frags = true;
goto rcd_done;
}
-   new_dma_addr = dma_map_single(>pdev->dev,
- new_skb->d

[PATCH net-next v4 6/7] vmxnet3: introduce command to register memory region

2016-06-14 Thread Shrikrishna Khare
Signed-off-by: Guolin Yang <gy...@vmware.com>
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_defs.h | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 274e145..c3a3164 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -81,6 +81,7 @@ enum {
VMXNET3_CMD_RESERVED2,
VMXNET3_CMD_RESERVED3,
VMXNET3_CMD_SET_COALESCE,
+   VMXNET3_CMD_REGISTER_MEMREGS,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -668,6 +669,22 @@ struct Vmxnet3_CoalesceScheme {
} coalPara;
 };
 
+struct Vmxnet3_MemoryRegion {
+   __le64  startPA;
+   __le32  length;
+   __le16  txQueueBits;
+   __le16  rxQueueBits;
+};
+
+#define MAX_MEMORY_REGION_PER_QUEUE 16
+#define MAX_MEMORY_REGION_PER_DEVICE 256
+
+struct Vmxnet3_MemRegs {
+   __le16  numRegs;
+   __le16  pad[3];
+   struct Vmxnet3_MemoryRegion memRegs[1];
+};
+
 /* If the command data <= 16 bytes, use the shared memory directly.
  * otherwise, use variable length configuration descriptor.
  */
-- 
2.8.2



[PATCH net-next v4 6/7] vmxnet3: introduce command to register memory region

2016-06-14 Thread Shrikrishna Khare
Signed-off-by: Guolin Yang 
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_defs.h | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 274e145..c3a3164 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -81,6 +81,7 @@ enum {
VMXNET3_CMD_RESERVED2,
VMXNET3_CMD_RESERVED3,
VMXNET3_CMD_SET_COALESCE,
+   VMXNET3_CMD_REGISTER_MEMREGS,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -668,6 +669,22 @@ struct Vmxnet3_CoalesceScheme {
} coalPara;
 };
 
+struct Vmxnet3_MemoryRegion {
+   __le64  startPA;
+   __le32  length;
+   __le16  txQueueBits;
+   __le16  rxQueueBits;
+};
+
+#define MAX_MEMORY_REGION_PER_QUEUE 16
+#define MAX_MEMORY_REGION_PER_DEVICE 256
+
+struct Vmxnet3_MemRegs {
+   __le16  numRegs;
+   __le16  pad[3];
+   struct Vmxnet3_MemoryRegion memRegs[1];
+};
+
 /* If the command data <= 16 bytes, use the shared memory directly.
  * otherwise, use variable length configuration descriptor.
  */
-- 
2.8.2



[PATCH net-next v4 0/7] vmxnet3: upgrade to version 3

2016-06-14 Thread Shrikrishna Khare
This patchset upgrades vmxnet3 to version 3.

Changes in v2:
 - Following patch is updated. See that patch for details:
   vmxnet3: add support for get_coalesce, set_coalesce ethtool

Changes in v3:
 - fix subject line to use vmxnet3: instead of Driver:Vmxnet3
 - resubmit when net-next is open

Changes in v4:
 - Following patch is updated. See that patch for details:
   vmxnet3: add support for get_coalesce, set_coalesce ethtool


Shrikrishna Khare (7):
  vmxnet3: prepare for version 3 changes
  vmxnet3: introduce generic command interface to configure the device
  vmxnet3: allow variable length transmit data ring buffer
  vmxnet3: add receive data ring support
  vmxnet3: add support for get_coalesce, set_coalesce ethtool operations
  vmxnet3: introduce command to register memory region
  vmxnet3: update to version 3

 drivers/net/vmxnet3/Makefile  |   4 +-
 drivers/net/vmxnet3/upt1_defs.h   |   4 +-
 drivers/net/vmxnet3/vmxnet3_defs.h| 105 -
 drivers/net/vmxnet3/vmxnet3_drv.c | 285 --
 drivers/net/vmxnet3/vmxnet3_ethtool.c | 215 +++--
 drivers/net/vmxnet3/vmxnet3_int.h |  54 ++-
 6 files changed, 585 insertions(+), 82 deletions(-)

-- 
2.8.2



[PATCH net-next v4 5/7] vmxnet3: add support for get_coalesce, set_coalesce ethtool operations

2016-06-14 Thread Shrikrishna Khare
Signed-off-by: Keyong Sun <s...@vmware.com>
Signed-off-by: Manoj Tammali <tamma...@vmware.com>
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
v1-v2: v1 patch used special values of rx-usecs to differentiate between
coalescing modes. v2 uses relevant fields in struct ethtool_coalesce
to choose modes. Also, a new command VMXNET3_CMD_GET_COALESCE is
introduced which allows driver to query the device for default coalescing
configuration.

v3-v4: address Ben's review comments: remove unnecessary memset from
vmxnet3_get_coalesce.

---
 drivers/net/vmxnet3/vmxnet3_defs.h|  33 ++-
 drivers/net/vmxnet3/vmxnet3_drv.c |  54 
 drivers/net/vmxnet3/vmxnet3_ethtool.c | 158 ++
 drivers/net/vmxnet3/vmxnet3_int.h |   9 ++
 4 files changed, 253 insertions(+), 1 deletion(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index f3b31c2..274e145 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -80,6 +80,7 @@ enum {
VMXNET3_CMD_LOAD_PLUGIN,
VMXNET3_CMD_RESERVED2,
VMXNET3_CMD_RESERVED3,
+   VMXNET3_CMD_SET_COALESCE,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -92,7 +93,8 @@ enum {
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
VMXNET3_CMD_GET_CONF_INTR,
VMXNET3_CMD_GET_RESERVED1,
-   VMXNET3_CMD_GET_TXDATA_DESC_SIZE
+   VMXNET3_CMD_GET_TXDATA_DESC_SIZE,
+   VMXNET3_CMD_GET_COALESCE,
 };
 
 /*
@@ -637,6 +639,35 @@ struct Vmxnet3_SetPolling {
u8  enablePolling;
 };
 
+#define VMXNET3_COAL_STATIC_MAX_DEPTH  128
+#define VMXNET3_COAL_RBC_MIN_RATE  100
+#define VMXNET3_COAL_RBC_MAX_RATE  10
+
+enum Vmxnet3_CoalesceMode {
+   VMXNET3_COALESCE_DISABLED   = 0,
+   VMXNET3_COALESCE_ADAPT  = 1,
+   VMXNET3_COALESCE_STATIC = 2,
+   VMXNET3_COALESCE_RBC= 3
+};
+
+struct Vmxnet3_CoalesceRbc {
+   u32 rbc_rate;
+};
+
+struct Vmxnet3_CoalesceStatic {
+   u32 tx_depth;
+   u32 tx_comp_depth;
+   u32 rx_depth;
+};
+
+struct Vmxnet3_CoalesceScheme {
+   enum Vmxnet3_CoalesceMode   coalMode;
+   union {
+   struct Vmxnet3_CoalesceRbc  coalRbc;
+   struct Vmxnet3_CoalesceStatic   coalStatic;
+   } coalPara;
+};
+
 /* If the command data <= 16 bytes, use the shared memory directly.
  * otherwise, use variable length configuration descriptor.
  */
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 6449d2e..d0bcc1d9 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -2491,6 +2491,32 @@ vmxnet3_setup_driver_shared(struct vmxnet3_adapter 
*adapter)
/* the rest are already zeroed */
 }
 
+static void
+vmxnet3_init_coalesce(struct vmxnet3_adapter *adapter)
+{
+   struct Vmxnet3_DriverShared *shared = adapter->shared;
+   union Vmxnet3_CmdInfo *cmdInfo = >cu.cmdInfo;
+   unsigned long flags;
+
+   if (!VMXNET3_VERSION_GE_3(adapter))
+   return;
+
+   spin_lock_irqsave(>cmd_lock, flags);
+   cmdInfo->varConf.confVer = 1;
+   cmdInfo->varConf.confLen =
+   cpu_to_le32(sizeof(*adapter->coal_conf));
+   cmdInfo->varConf.confPA  = cpu_to_le64(adapter->coal_conf_pa);
+
+   if (adapter->default_coal_mode) {
+   VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
+  VMXNET3_CMD_GET_COALESCE);
+   } else {
+   VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
+  VMXNET3_CMD_SET_COALESCE);
+   }
+
+   spin_unlock_irqrestore(>cmd_lock, flags);
+}
 
 int
 vmxnet3_activate_dev(struct vmxnet3_adapter *adapter)
@@ -2540,6 +2566,8 @@ vmxnet3_activate_dev(struct vmxnet3_adapter *adapter)
goto activate_err;
}
 
+   vmxnet3_init_coalesce(adapter);
+
for (i = 0; i < adapter->num_rx_queues; i++) {
VMXNET3_WRITE_BAR0_REG(adapter,
VMXNET3_REG_RXPROD + i * VMXNET3_REG_ALIGN,
@@ -3345,6 +3373,22 @@ vmxnet3_probe_device(struct pci_dev *pdev,
goto err_ver;
}
 
+   if (VMXNET3_VERSION_GE_3(adapter)) {
+   adapter->coal_conf =
+   dma_alloc_coherent(>pdev->dev,
+  sizeof(struct Vmxnet3_CoalesceScheme)
+  ,
+  >coal_conf_pa,
+  GFP_KERNEL);
+   if (!adapter->coal_conf) {
+  

[PATCH net-next v4 0/7] vmxnet3: upgrade to version 3

2016-06-14 Thread Shrikrishna Khare
This patchset upgrades vmxnet3 to version 3.

Changes in v2:
 - Following patch is updated. See that patch for details:
   vmxnet3: add support for get_coalesce, set_coalesce ethtool

Changes in v3:
 - fix subject line to use vmxnet3: instead of Driver:Vmxnet3
 - resubmit when net-next is open

Changes in v4:
 - Following patch is updated. See that patch for details:
   vmxnet3: add support for get_coalesce, set_coalesce ethtool


Shrikrishna Khare (7):
  vmxnet3: prepare for version 3 changes
  vmxnet3: introduce generic command interface to configure the device
  vmxnet3: allow variable length transmit data ring buffer
  vmxnet3: add receive data ring support
  vmxnet3: add support for get_coalesce, set_coalesce ethtool operations
  vmxnet3: introduce command to register memory region
  vmxnet3: update to version 3

 drivers/net/vmxnet3/Makefile  |   4 +-
 drivers/net/vmxnet3/upt1_defs.h   |   4 +-
 drivers/net/vmxnet3/vmxnet3_defs.h| 105 -
 drivers/net/vmxnet3/vmxnet3_drv.c | 285 --
 drivers/net/vmxnet3/vmxnet3_ethtool.c | 215 +++--
 drivers/net/vmxnet3/vmxnet3_int.h |  54 ++-
 6 files changed, 585 insertions(+), 82 deletions(-)

-- 
2.8.2



[PATCH net-next v4 5/7] vmxnet3: add support for get_coalesce, set_coalesce ethtool operations

2016-06-14 Thread Shrikrishna Khare
Signed-off-by: Keyong Sun 
Signed-off-by: Manoj Tammali 
Signed-off-by: Shrikrishna Khare 
---
v1-v2: v1 patch used special values of rx-usecs to differentiate between
coalescing modes. v2 uses relevant fields in struct ethtool_coalesce
to choose modes. Also, a new command VMXNET3_CMD_GET_COALESCE is
introduced which allows driver to query the device for default coalescing
configuration.

v3-v4: address Ben's review comments: remove unnecessary memset from
vmxnet3_get_coalesce.

---
 drivers/net/vmxnet3/vmxnet3_defs.h|  33 ++-
 drivers/net/vmxnet3/vmxnet3_drv.c |  54 
 drivers/net/vmxnet3/vmxnet3_ethtool.c | 158 ++
 drivers/net/vmxnet3/vmxnet3_int.h |   9 ++
 4 files changed, 253 insertions(+), 1 deletion(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index f3b31c2..274e145 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -80,6 +80,7 @@ enum {
VMXNET3_CMD_LOAD_PLUGIN,
VMXNET3_CMD_RESERVED2,
VMXNET3_CMD_RESERVED3,
+   VMXNET3_CMD_SET_COALESCE,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -92,7 +93,8 @@ enum {
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
VMXNET3_CMD_GET_CONF_INTR,
VMXNET3_CMD_GET_RESERVED1,
-   VMXNET3_CMD_GET_TXDATA_DESC_SIZE
+   VMXNET3_CMD_GET_TXDATA_DESC_SIZE,
+   VMXNET3_CMD_GET_COALESCE,
 };
 
 /*
@@ -637,6 +639,35 @@ struct Vmxnet3_SetPolling {
u8  enablePolling;
 };
 
+#define VMXNET3_COAL_STATIC_MAX_DEPTH  128
+#define VMXNET3_COAL_RBC_MIN_RATE  100
+#define VMXNET3_COAL_RBC_MAX_RATE  10
+
+enum Vmxnet3_CoalesceMode {
+   VMXNET3_COALESCE_DISABLED   = 0,
+   VMXNET3_COALESCE_ADAPT  = 1,
+   VMXNET3_COALESCE_STATIC = 2,
+   VMXNET3_COALESCE_RBC= 3
+};
+
+struct Vmxnet3_CoalesceRbc {
+   u32 rbc_rate;
+};
+
+struct Vmxnet3_CoalesceStatic {
+   u32 tx_depth;
+   u32 tx_comp_depth;
+   u32 rx_depth;
+};
+
+struct Vmxnet3_CoalesceScheme {
+   enum Vmxnet3_CoalesceMode   coalMode;
+   union {
+   struct Vmxnet3_CoalesceRbc  coalRbc;
+   struct Vmxnet3_CoalesceStatic   coalStatic;
+   } coalPara;
+};
+
 /* If the command data <= 16 bytes, use the shared memory directly.
  * otherwise, use variable length configuration descriptor.
  */
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 6449d2e..d0bcc1d9 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -2491,6 +2491,32 @@ vmxnet3_setup_driver_shared(struct vmxnet3_adapter 
*adapter)
/* the rest are already zeroed */
 }
 
+static void
+vmxnet3_init_coalesce(struct vmxnet3_adapter *adapter)
+{
+   struct Vmxnet3_DriverShared *shared = adapter->shared;
+   union Vmxnet3_CmdInfo *cmdInfo = >cu.cmdInfo;
+   unsigned long flags;
+
+   if (!VMXNET3_VERSION_GE_3(adapter))
+   return;
+
+   spin_lock_irqsave(>cmd_lock, flags);
+   cmdInfo->varConf.confVer = 1;
+   cmdInfo->varConf.confLen =
+   cpu_to_le32(sizeof(*adapter->coal_conf));
+   cmdInfo->varConf.confPA  = cpu_to_le64(adapter->coal_conf_pa);
+
+   if (adapter->default_coal_mode) {
+   VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
+  VMXNET3_CMD_GET_COALESCE);
+   } else {
+   VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
+  VMXNET3_CMD_SET_COALESCE);
+   }
+
+   spin_unlock_irqrestore(>cmd_lock, flags);
+}
 
 int
 vmxnet3_activate_dev(struct vmxnet3_adapter *adapter)
@@ -2540,6 +2566,8 @@ vmxnet3_activate_dev(struct vmxnet3_adapter *adapter)
goto activate_err;
}
 
+   vmxnet3_init_coalesce(adapter);
+
for (i = 0; i < adapter->num_rx_queues; i++) {
VMXNET3_WRITE_BAR0_REG(adapter,
VMXNET3_REG_RXPROD + i * VMXNET3_REG_ALIGN,
@@ -3345,6 +3373,22 @@ vmxnet3_probe_device(struct pci_dev *pdev,
goto err_ver;
}
 
+   if (VMXNET3_VERSION_GE_3(adapter)) {
+   adapter->coal_conf =
+   dma_alloc_coherent(>pdev->dev,
+  sizeof(struct Vmxnet3_CoalesceScheme)
+  ,
+  >coal_conf_pa,
+  GFP_KERNEL);
+   if (!adapter->coal_conf) {
+   err = -ENOMEM;
+   goto err_ver;
+

[PATCH net-next v4 1/7] vmxnet3: prepare for version 3 changes

2016-06-14 Thread Shrikrishna Khare
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/Makefile  |  4 ++--
 drivers/net/vmxnet3/upt1_defs.h   |  4 ++--
 drivers/net/vmxnet3/vmxnet3_defs.h|  9 ++---
 drivers/net/vmxnet3/vmxnet3_drv.c | 22 +-
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  4 ++--
 drivers/net/vmxnet3/vmxnet3_int.h | 13 +++--
 6 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/drivers/net/vmxnet3/Makefile b/drivers/net/vmxnet3/Makefile
index 880f509..8cdbb63 100644
--- a/drivers/net/vmxnet3/Makefile
+++ b/drivers/net/vmxnet3/Makefile
@@ -2,7 +2,7 @@
 #
 # Linux driver for VMware's vmxnet3 ethernet NIC.
 #
-# Copyright (C) 2007-2009, VMware, Inc. All Rights Reserved.
+# Copyright (C) 2007-2016, VMware, Inc. All Rights Reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by the
@@ -21,7 +21,7 @@
 # The full GNU General Public License is included in this distribution in
 # the file called "COPYING".
 #
-# Maintained by: Shreyas Bhatewara <pv-driv...@vmware.com>
+# Maintained by: pv-driv...@vmware.com
 #
 #
 

diff --git a/drivers/net/vmxnet3/upt1_defs.h b/drivers/net/vmxnet3/upt1_defs.h
index 969c751..db9f1fd 100644
--- a/drivers/net/vmxnet3/upt1_defs.h
+++ b/drivers/net/vmxnet3/upt1_defs.h
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara <pv-driv...@vmware.com>
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 72ba8ae..8345e0c 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2015, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara <pv-driv...@vmware.com>
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
@@ -76,7 +76,9 @@ enum {
VMXNET3_CMD_UPDATE_IML,
VMXNET3_CMD_UPDATE_PMCFG,
VMXNET3_CMD_UPDATE_FEATURE,
+   VMXNET3_CMD_RESERVED1,
VMXNET3_CMD_LOAD_PLUGIN,
+   VMXNET3_CMD_RESERVED2,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -87,7 +89,8 @@ enum {
VMXNET3_CMD_GET_DID_LO,
VMXNET3_CMD_GET_DID_HI,
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
-   VMXNET3_CMD_GET_CONF_INTR
+   VMXNET3_CMD_GET_CONF_INTR,
+   VMXNET3_CMD_GET_RESERVED1,
 };
 
 /*
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 08885bc..507c53d 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara <pv-driv...@vmware.com>
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
@@ -1363,7 +1363,7 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
rbi->dma_addr = new_dma_addr;
rxd->addr = cpu_to_le64(rbi->dma_addr);
rxd->len = rbi->len;
-   if (adapter->version == 2 &&
+   if (VMXNET3_VERSION_GE_2(adapter) &&
rcd->type == VMXNET3_CDTYPE_RXCOMP_LRO) {
struct Vmxnet3_RxCompDescExt *rcdlro;
rcdlro = (struct Vmxnet3_RxCompDescExt *)rcd;
@@ -3200,12 +3200,16 @@ vmxnet3_probe_device(struct pci_dev *pdev,
  

[PATCH net-next v4 1/7] vmxnet3: prepare for version 3 changes

2016-06-14 Thread Shrikrishna Khare
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/Makefile  |  4 ++--
 drivers/net/vmxnet3/upt1_defs.h   |  4 ++--
 drivers/net/vmxnet3/vmxnet3_defs.h|  9 ++---
 drivers/net/vmxnet3/vmxnet3_drv.c | 22 +-
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  4 ++--
 drivers/net/vmxnet3/vmxnet3_int.h | 13 +++--
 6 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/drivers/net/vmxnet3/Makefile b/drivers/net/vmxnet3/Makefile
index 880f509..8cdbb63 100644
--- a/drivers/net/vmxnet3/Makefile
+++ b/drivers/net/vmxnet3/Makefile
@@ -2,7 +2,7 @@
 #
 # Linux driver for VMware's vmxnet3 ethernet NIC.
 #
-# Copyright (C) 2007-2009, VMware, Inc. All Rights Reserved.
+# Copyright (C) 2007-2016, VMware, Inc. All Rights Reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by the
@@ -21,7 +21,7 @@
 # The full GNU General Public License is included in this distribution in
 # the file called "COPYING".
 #
-# Maintained by: Shreyas Bhatewara 
+# Maintained by: pv-driv...@vmware.com
 #
 #
 

diff --git a/drivers/net/vmxnet3/upt1_defs.h b/drivers/net/vmxnet3/upt1_defs.h
index 969c751..db9f1fd 100644
--- a/drivers/net/vmxnet3/upt1_defs.h
+++ b/drivers/net/vmxnet3/upt1_defs.h
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara 
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 72ba8ae..8345e0c 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2015, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara 
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
@@ -76,7 +76,9 @@ enum {
VMXNET3_CMD_UPDATE_IML,
VMXNET3_CMD_UPDATE_PMCFG,
VMXNET3_CMD_UPDATE_FEATURE,
+   VMXNET3_CMD_RESERVED1,
VMXNET3_CMD_LOAD_PLUGIN,
+   VMXNET3_CMD_RESERVED2,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -87,7 +89,8 @@ enum {
VMXNET3_CMD_GET_DID_LO,
VMXNET3_CMD_GET_DID_HI,
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
-   VMXNET3_CMD_GET_CONF_INTR
+   VMXNET3_CMD_GET_CONF_INTR,
+   VMXNET3_CMD_GET_RESERVED1,
 };
 
 /*
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 08885bc..507c53d 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara 
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
@@ -1363,7 +1363,7 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
rbi->dma_addr = new_dma_addr;
rxd->addr = cpu_to_le64(rbi->dma_addr);
rxd->len = rbi->len;
-   if (adapter->version == 2 &&
+   if (VMXNET3_VERSION_GE_2(adapter) &&
rcd->type == VMXNET3_CDTYPE_RXCOMP_LRO) {
struct Vmxnet3_RxCompDescExt *rcdlro;
rcdlro = (struct Vmxnet3_RxCompDescExt *)rcd;
@@ -3200,12 +3200,16 @@ vmxnet3_probe_device(struct pci_dev *pdev,
goto err_alloc_pci;
 
ver = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_VRRS);
-   if (ver & 2) {
-   VMXNET3_WRITE_BAR1_REG(adapter, V

[PATCH net-next v3 6/7] vmxnet3: introduce command to register memory region

2016-06-13 Thread Shrikrishna Khare
Signed-off-by: Guolin Yang <gy...@vmware.com>
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_defs.h | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 274e145..c3a3164 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -81,6 +81,7 @@ enum {
VMXNET3_CMD_RESERVED2,
VMXNET3_CMD_RESERVED3,
VMXNET3_CMD_SET_COALESCE,
+   VMXNET3_CMD_REGISTER_MEMREGS,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -668,6 +669,22 @@ struct Vmxnet3_CoalesceScheme {
} coalPara;
 };
 
+struct Vmxnet3_MemoryRegion {
+   __le64  startPA;
+   __le32  length;
+   __le16  txQueueBits;
+   __le16  rxQueueBits;
+};
+
+#define MAX_MEMORY_REGION_PER_QUEUE 16
+#define MAX_MEMORY_REGION_PER_DEVICE 256
+
+struct Vmxnet3_MemRegs {
+   __le16  numRegs;
+   __le16  pad[3];
+   struct Vmxnet3_MemoryRegion memRegs[1];
+};
+
 /* If the command data <= 16 bytes, use the shared memory directly.
  * otherwise, use variable length configuration descriptor.
  */
-- 
2.8.2



[PATCH net-next v3 5/7] vmxnet3: add support for get_coalesce, set_coalesce ethtool operations

2016-06-13 Thread Shrikrishna Khare
Signed-off-by: Keyong Sun <s...@vmware.com>
Signed-off-by: Manoj Tammali <tamma...@vmware.com>
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_defs.h|  33 ++-
 drivers/net/vmxnet3/vmxnet3_drv.c |  54 
 drivers/net/vmxnet3/vmxnet3_ethtool.c | 160 ++
 drivers/net/vmxnet3/vmxnet3_int.h |   9 ++
 4 files changed, 255 insertions(+), 1 deletion(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index f3b31c2..274e145 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -80,6 +80,7 @@ enum {
VMXNET3_CMD_LOAD_PLUGIN,
VMXNET3_CMD_RESERVED2,
VMXNET3_CMD_RESERVED3,
+   VMXNET3_CMD_SET_COALESCE,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -92,7 +93,8 @@ enum {
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
VMXNET3_CMD_GET_CONF_INTR,
VMXNET3_CMD_GET_RESERVED1,
-   VMXNET3_CMD_GET_TXDATA_DESC_SIZE
+   VMXNET3_CMD_GET_TXDATA_DESC_SIZE,
+   VMXNET3_CMD_GET_COALESCE,
 };
 
 /*
@@ -637,6 +639,35 @@ struct Vmxnet3_SetPolling {
u8  enablePolling;
 };
 
+#define VMXNET3_COAL_STATIC_MAX_DEPTH  128
+#define VMXNET3_COAL_RBC_MIN_RATE  100
+#define VMXNET3_COAL_RBC_MAX_RATE  10
+
+enum Vmxnet3_CoalesceMode {
+   VMXNET3_COALESCE_DISABLED   = 0,
+   VMXNET3_COALESCE_ADAPT  = 1,
+   VMXNET3_COALESCE_STATIC = 2,
+   VMXNET3_COALESCE_RBC= 3
+};
+
+struct Vmxnet3_CoalesceRbc {
+   u32 rbc_rate;
+};
+
+struct Vmxnet3_CoalesceStatic {
+   u32 tx_depth;
+   u32 tx_comp_depth;
+   u32 rx_depth;
+};
+
+struct Vmxnet3_CoalesceScheme {
+   enum Vmxnet3_CoalesceMode   coalMode;
+   union {
+   struct Vmxnet3_CoalesceRbc  coalRbc;
+   struct Vmxnet3_CoalesceStatic   coalStatic;
+   } coalPara;
+};
+
 /* If the command data <= 16 bytes, use the shared memory directly.
  * otherwise, use variable length configuration descriptor.
  */
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 6449d2e..d0bcc1d9 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -2491,6 +2491,32 @@ vmxnet3_setup_driver_shared(struct vmxnet3_adapter 
*adapter)
/* the rest are already zeroed */
 }
 
+static void
+vmxnet3_init_coalesce(struct vmxnet3_adapter *adapter)
+{
+   struct Vmxnet3_DriverShared *shared = adapter->shared;
+   union Vmxnet3_CmdInfo *cmdInfo = >cu.cmdInfo;
+   unsigned long flags;
+
+   if (!VMXNET3_VERSION_GE_3(adapter))
+   return;
+
+   spin_lock_irqsave(>cmd_lock, flags);
+   cmdInfo->varConf.confVer = 1;
+   cmdInfo->varConf.confLen =
+   cpu_to_le32(sizeof(*adapter->coal_conf));
+   cmdInfo->varConf.confPA  = cpu_to_le64(adapter->coal_conf_pa);
+
+   if (adapter->default_coal_mode) {
+   VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
+  VMXNET3_CMD_GET_COALESCE);
+   } else {
+   VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
+  VMXNET3_CMD_SET_COALESCE);
+   }
+
+   spin_unlock_irqrestore(>cmd_lock, flags);
+}
 
 int
 vmxnet3_activate_dev(struct vmxnet3_adapter *adapter)
@@ -2540,6 +2566,8 @@ vmxnet3_activate_dev(struct vmxnet3_adapter *adapter)
goto activate_err;
}
 
+   vmxnet3_init_coalesce(adapter);
+
for (i = 0; i < adapter->num_rx_queues; i++) {
VMXNET3_WRITE_BAR0_REG(adapter,
VMXNET3_REG_RXPROD + i * VMXNET3_REG_ALIGN,
@@ -3345,6 +3373,22 @@ vmxnet3_probe_device(struct pci_dev *pdev,
goto err_ver;
}
 
+   if (VMXNET3_VERSION_GE_3(adapter)) {
+   adapter->coal_conf =
+   dma_alloc_coherent(>pdev->dev,
+  sizeof(struct Vmxnet3_CoalesceScheme)
+  ,
+  >coal_conf_pa,
+  GFP_KERNEL);
+   if (!adapter->coal_conf) {
+   err = -ENOMEM;
+   goto err_ver;
+   }
+   memset(adapter->coal_conf, 0, sizeof(*adapter->coal_conf));
+   adapter->coal_conf->coalMode = VMXNET3_COALESCE_DISABLED;
+   adapter->default_coal_mode = true;
+   }
+
SET_NETDEV_DEV(netdev, >dev);
vmxnet3_declare_fe

[PATCH net-next v3 6/7] vmxnet3: introduce command to register memory region

2016-06-13 Thread Shrikrishna Khare
Signed-off-by: Guolin Yang 
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_defs.h | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 274e145..c3a3164 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -81,6 +81,7 @@ enum {
VMXNET3_CMD_RESERVED2,
VMXNET3_CMD_RESERVED3,
VMXNET3_CMD_SET_COALESCE,
+   VMXNET3_CMD_REGISTER_MEMREGS,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -668,6 +669,22 @@ struct Vmxnet3_CoalesceScheme {
} coalPara;
 };
 
+struct Vmxnet3_MemoryRegion {
+   __le64  startPA;
+   __le32  length;
+   __le16  txQueueBits;
+   __le16  rxQueueBits;
+};
+
+#define MAX_MEMORY_REGION_PER_QUEUE 16
+#define MAX_MEMORY_REGION_PER_DEVICE 256
+
+struct Vmxnet3_MemRegs {
+   __le16  numRegs;
+   __le16  pad[3];
+   struct Vmxnet3_MemoryRegion memRegs[1];
+};
+
 /* If the command data <= 16 bytes, use the shared memory directly.
  * otherwise, use variable length configuration descriptor.
  */
-- 
2.8.2



[PATCH net-next v3 5/7] vmxnet3: add support for get_coalesce, set_coalesce ethtool operations

2016-06-13 Thread Shrikrishna Khare
Signed-off-by: Keyong Sun 
Signed-off-by: Manoj Tammali 
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_defs.h|  33 ++-
 drivers/net/vmxnet3/vmxnet3_drv.c |  54 
 drivers/net/vmxnet3/vmxnet3_ethtool.c | 160 ++
 drivers/net/vmxnet3/vmxnet3_int.h |   9 ++
 4 files changed, 255 insertions(+), 1 deletion(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index f3b31c2..274e145 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -80,6 +80,7 @@ enum {
VMXNET3_CMD_LOAD_PLUGIN,
VMXNET3_CMD_RESERVED2,
VMXNET3_CMD_RESERVED3,
+   VMXNET3_CMD_SET_COALESCE,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -92,7 +93,8 @@ enum {
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
VMXNET3_CMD_GET_CONF_INTR,
VMXNET3_CMD_GET_RESERVED1,
-   VMXNET3_CMD_GET_TXDATA_DESC_SIZE
+   VMXNET3_CMD_GET_TXDATA_DESC_SIZE,
+   VMXNET3_CMD_GET_COALESCE,
 };
 
 /*
@@ -637,6 +639,35 @@ struct Vmxnet3_SetPolling {
u8  enablePolling;
 };
 
+#define VMXNET3_COAL_STATIC_MAX_DEPTH  128
+#define VMXNET3_COAL_RBC_MIN_RATE  100
+#define VMXNET3_COAL_RBC_MAX_RATE  10
+
+enum Vmxnet3_CoalesceMode {
+   VMXNET3_COALESCE_DISABLED   = 0,
+   VMXNET3_COALESCE_ADAPT  = 1,
+   VMXNET3_COALESCE_STATIC = 2,
+   VMXNET3_COALESCE_RBC= 3
+};
+
+struct Vmxnet3_CoalesceRbc {
+   u32 rbc_rate;
+};
+
+struct Vmxnet3_CoalesceStatic {
+   u32 tx_depth;
+   u32 tx_comp_depth;
+   u32 rx_depth;
+};
+
+struct Vmxnet3_CoalesceScheme {
+   enum Vmxnet3_CoalesceMode   coalMode;
+   union {
+   struct Vmxnet3_CoalesceRbc  coalRbc;
+   struct Vmxnet3_CoalesceStatic   coalStatic;
+   } coalPara;
+};
+
 /* If the command data <= 16 bytes, use the shared memory directly.
  * otherwise, use variable length configuration descriptor.
  */
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 6449d2e..d0bcc1d9 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -2491,6 +2491,32 @@ vmxnet3_setup_driver_shared(struct vmxnet3_adapter 
*adapter)
/* the rest are already zeroed */
 }
 
+static void
+vmxnet3_init_coalesce(struct vmxnet3_adapter *adapter)
+{
+   struct Vmxnet3_DriverShared *shared = adapter->shared;
+   union Vmxnet3_CmdInfo *cmdInfo = >cu.cmdInfo;
+   unsigned long flags;
+
+   if (!VMXNET3_VERSION_GE_3(adapter))
+   return;
+
+   spin_lock_irqsave(>cmd_lock, flags);
+   cmdInfo->varConf.confVer = 1;
+   cmdInfo->varConf.confLen =
+   cpu_to_le32(sizeof(*adapter->coal_conf));
+   cmdInfo->varConf.confPA  = cpu_to_le64(adapter->coal_conf_pa);
+
+   if (adapter->default_coal_mode) {
+   VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
+  VMXNET3_CMD_GET_COALESCE);
+   } else {
+   VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
+  VMXNET3_CMD_SET_COALESCE);
+   }
+
+   spin_unlock_irqrestore(>cmd_lock, flags);
+}
 
 int
 vmxnet3_activate_dev(struct vmxnet3_adapter *adapter)
@@ -2540,6 +2566,8 @@ vmxnet3_activate_dev(struct vmxnet3_adapter *adapter)
goto activate_err;
}
 
+   vmxnet3_init_coalesce(adapter);
+
for (i = 0; i < adapter->num_rx_queues; i++) {
VMXNET3_WRITE_BAR0_REG(adapter,
VMXNET3_REG_RXPROD + i * VMXNET3_REG_ALIGN,
@@ -3345,6 +3373,22 @@ vmxnet3_probe_device(struct pci_dev *pdev,
goto err_ver;
}
 
+   if (VMXNET3_VERSION_GE_3(adapter)) {
+   adapter->coal_conf =
+   dma_alloc_coherent(>pdev->dev,
+  sizeof(struct Vmxnet3_CoalesceScheme)
+  ,
+  >coal_conf_pa,
+  GFP_KERNEL);
+   if (!adapter->coal_conf) {
+   err = -ENOMEM;
+   goto err_ver;
+   }
+   memset(adapter->coal_conf, 0, sizeof(*adapter->coal_conf));
+   adapter->coal_conf->coalMode = VMXNET3_COALESCE_DISABLED;
+   adapter->default_coal_mode = true;
+   }
+
SET_NETDEV_DEV(netdev, >dev);
vmxnet3_declare_features(adapter, dma64);
 
@@ -3407,6 +3451,11 @@ vmxn

[PATCH net-next v3 7/7] vmxnet3: update to version 3

2016-06-13 Thread Shrikrishna Khare
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 7 ++-
 drivers/net/vmxnet3/vmxnet3_int.h | 4 ++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index d0bcc1d9..c68fe49 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -3345,7 +3345,12 @@ vmxnet3_probe_device(struct pci_dev *pdev,
goto err_alloc_pci;
 
ver = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_VRRS);
-   if (ver & (1 << VMXNET3_REV_2)) {
+   if (ver & (1 << VMXNET3_REV_3)) {
+   VMXNET3_WRITE_BAR1_REG(adapter,
+  VMXNET3_REG_VRRS,
+  1 << VMXNET3_REV_3);
+   adapter->version = VMXNET3_REV_3 + 1;
+   } else if (ver & (1 << VMXNET3_REV_2)) {
VMXNET3_WRITE_BAR1_REG(adapter,
   VMXNET3_REG_VRRS,
   1 << VMXNET3_REV_2);
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h 
b/drivers/net/vmxnet3/vmxnet3_int.h
index 63df4f2..74fc030 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.8.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.9.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM  0x01040800
+#define VMXNET3_DRIVER_VERSION_NUM  0x01040900
 
 #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
-- 
2.8.2



[PATCH net-next v3 7/7] vmxnet3: update to version 3

2016-06-13 Thread Shrikrishna Khare
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 7 ++-
 drivers/net/vmxnet3/vmxnet3_int.h | 4 ++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index d0bcc1d9..c68fe49 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -3345,7 +3345,12 @@ vmxnet3_probe_device(struct pci_dev *pdev,
goto err_alloc_pci;
 
ver = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_VRRS);
-   if (ver & (1 << VMXNET3_REV_2)) {
+   if (ver & (1 << VMXNET3_REV_3)) {
+   VMXNET3_WRITE_BAR1_REG(adapter,
+  VMXNET3_REG_VRRS,
+  1 << VMXNET3_REV_3);
+   adapter->version = VMXNET3_REV_3 + 1;
+   } else if (ver & (1 << VMXNET3_REV_2)) {
VMXNET3_WRITE_BAR1_REG(adapter,
   VMXNET3_REG_VRRS,
   1 << VMXNET3_REV_2);
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h 
b/drivers/net/vmxnet3/vmxnet3_int.h
index 63df4f2..74fc030 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.8.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.9.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM  0x01040800
+#define VMXNET3_DRIVER_VERSION_NUM  0x01040900
 
 #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
-- 
2.8.2



[PATCH net-next v3 4/7] vmxnet3: add receive data ring support

2016-06-13 Thread Shrikrishna Khare
Receive Data Ring buffer length is configurable via ethtool -G ethX rx-mini

Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_defs.h|  14 +++-
 drivers/net/vmxnet3/vmxnet3_drv.c | 153 +++---
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  48 ---
 drivers/net/vmxnet3/vmxnet3_int.h |  23 -
 4 files changed, 193 insertions(+), 45 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 701d989..f3b31c2 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -174,6 +174,8 @@ struct Vmxnet3_TxDataDesc {
u8  data[VMXNET3_HDR_COPY_SIZE];
 };
 
+typedef u8 Vmxnet3_RxDataDesc;
+
 #define VMXNET3_TCD_GEN_SHIFT  31
 #define VMXNET3_TCD_GEN_SIZE   1
 #define VMXNET3_TCD_TXIDX_SHIFT0
@@ -382,6 +384,10 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_TXDATA_DESC_SIZE_ALIGN 64
 #define VMXNET3_TXDATA_DESC_SIZE_MASK  (VMXNET3_TXDATA_DESC_SIZE_ALIGN - 1)
 
+/* Rx Data Ring buffer size must be a multiple of 64 */
+#define VMXNET3_RXDATA_DESC_SIZE_ALIGN 64
+#define VMXNET3_RXDATA_DESC_SIZE_MASK  (VMXNET3_RXDATA_DESC_SIZE_ALIGN - 1)
+
 /* Max ring size */
 #define VMXNET3_TX_RING_MAX_SIZE   4096
 #define VMXNET3_TC_RING_MAX_SIZE   4096
@@ -392,6 +398,8 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_TXDATA_DESC_MIN_SIZE 128
 #define VMXNET3_TXDATA_DESC_MAX_SIZE 2048
 
+#define VMXNET3_RXDATA_DESC_MAX_SIZE 2048
+
 /* a list of reasons for queue stop */
 
 enum {
@@ -488,12 +496,14 @@ struct Vmxnet3_RxQueueConf {
__le64  rxRingBasePA[2];
__le64  compRingBasePA;
__le64  ddPA;/* driver data */
-   __le64  reserved;
+   __le64  rxDataRingBasePA;
__le32  rxRingSize[2];   /* # of rx desc */
__le32  compRingSize;/* # of rx comp desc */
__le32  ddLen;   /* size of driver data */
u8  intrIdx;
-   u8  _pad[7];
+   u8  _pad1[1];
+   __le16  rxDataRingDescSize;  /* size of rx data ring buffer */
+   u8  _pad2[4];
 };
 
 
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 4e42eb0..6449d2e 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1284,9 +1284,10 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
 */
break;
}
-   BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2);
+   BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2 &&
+  rcd->rqID != rq->dataRingQid);
idx = rcd->rxdIdx;
-   ring_idx = rcd->rqID < adapter->num_rx_queues ? 0 : 1;
+   ring_idx = VMXNET3_GET_RING_IDX(adapter, rcd->rqID);
ring = rq->rx_ring + ring_idx;
vmxnet3_getRxDesc(rxd, >rx_ring[ring_idx].base[idx].rxd,
  );
@@ -1301,8 +1302,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
}
 
if (rcd->sop) { /* first buf of the pkt */
+   bool rxDataRingUsed;
+   u16 len;
+
BUG_ON(rxd->btype != VMXNET3_RXD_BTYPE_HEAD ||
-  rcd->rqID != rq->qid);
+  (rcd->rqID != rq->qid &&
+   rcd->rqID != rq->dataRingQid));
 
BUG_ON(rbi->buf_type != VMXNET3_RX_BUF_SKB);
BUG_ON(ctx->skb != NULL || rbi->skb == NULL);
@@ -1318,8 +1323,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
 
skip_page_frags = false;
ctx->skb = rbi->skb;
+
+   rxDataRingUsed =
+   VMXNET3_RX_DATA_RING(adapter, rcd->rqID);
+   len = rxDataRingUsed ? rcd->len : rbi->len;
new_skb = netdev_alloc_skb_ip_align(adapter->netdev,
-   rbi->len);
+   len);
if (new_skb == NULL) {
/* Skb allocation failed, do not handover this
 * skb to stack. Reuse it. Drop the existing pkt
@@ -1330,25 +1339,48 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
skip_page_frags = true;
goto rcd_done;
}
-   new_dma_addr = dma_map_single(>pdev->dev,
- new_skb

[PATCH net-next v3 1/7] vmxnet3: prepare for version 3 changes

2016-06-13 Thread Shrikrishna Khare
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/Makefile  |  4 ++--
 drivers/net/vmxnet3/upt1_defs.h   |  4 ++--
 drivers/net/vmxnet3/vmxnet3_defs.h|  9 ++---
 drivers/net/vmxnet3/vmxnet3_drv.c | 22 +-
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  4 ++--
 drivers/net/vmxnet3/vmxnet3_int.h | 13 +++--
 6 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/drivers/net/vmxnet3/Makefile b/drivers/net/vmxnet3/Makefile
index 880f509..8cdbb63 100644
--- a/drivers/net/vmxnet3/Makefile
+++ b/drivers/net/vmxnet3/Makefile
@@ -2,7 +2,7 @@
 #
 # Linux driver for VMware's vmxnet3 ethernet NIC.
 #
-# Copyright (C) 2007-2009, VMware, Inc. All Rights Reserved.
+# Copyright (C) 2007-2016, VMware, Inc. All Rights Reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by the
@@ -21,7 +21,7 @@
 # The full GNU General Public License is included in this distribution in
 # the file called "COPYING".
 #
-# Maintained by: Shreyas Bhatewara <pv-driv...@vmware.com>
+# Maintained by: pv-driv...@vmware.com
 #
 #
 

diff --git a/drivers/net/vmxnet3/upt1_defs.h b/drivers/net/vmxnet3/upt1_defs.h
index 969c751..db9f1fd 100644
--- a/drivers/net/vmxnet3/upt1_defs.h
+++ b/drivers/net/vmxnet3/upt1_defs.h
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara <pv-driv...@vmware.com>
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 72ba8ae..8345e0c 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2015, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara <pv-driv...@vmware.com>
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
@@ -76,7 +76,9 @@ enum {
VMXNET3_CMD_UPDATE_IML,
VMXNET3_CMD_UPDATE_PMCFG,
VMXNET3_CMD_UPDATE_FEATURE,
+   VMXNET3_CMD_RESERVED1,
VMXNET3_CMD_LOAD_PLUGIN,
+   VMXNET3_CMD_RESERVED2,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -87,7 +89,8 @@ enum {
VMXNET3_CMD_GET_DID_LO,
VMXNET3_CMD_GET_DID_HI,
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
-   VMXNET3_CMD_GET_CONF_INTR
+   VMXNET3_CMD_GET_CONF_INTR,
+   VMXNET3_CMD_GET_RESERVED1,
 };
 
 /*
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 08885bc..507c53d 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara <pv-driv...@vmware.com>
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
@@ -1363,7 +1363,7 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
rbi->dma_addr = new_dma_addr;
rxd->addr = cpu_to_le64(rbi->dma_addr);
rxd->len = rbi->len;
-   if (adapter->version == 2 &&
+   if (VMXNET3_VERSION_GE_2(adapter) &&
rcd->type == VMXNET3_CDTYPE_RXCOMP_LRO) {
struct Vmxnet3_RxCompDescExt *rcdlro;
rcdlro = (struct Vmxnet3_RxCompDescExt *)rcd;
@@ -3200,12 +3200,16 @@ vmxnet3_probe_device(struct pci_dev *pdev,
  

[PATCH net-next v3 4/7] vmxnet3: add receive data ring support

2016-06-13 Thread Shrikrishna Khare
Receive Data Ring buffer length is configurable via ethtool -G ethX rx-mini

Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_defs.h|  14 +++-
 drivers/net/vmxnet3/vmxnet3_drv.c | 153 +++---
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  48 ---
 drivers/net/vmxnet3/vmxnet3_int.h |  23 -
 4 files changed, 193 insertions(+), 45 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 701d989..f3b31c2 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -174,6 +174,8 @@ struct Vmxnet3_TxDataDesc {
u8  data[VMXNET3_HDR_COPY_SIZE];
 };
 
+typedef u8 Vmxnet3_RxDataDesc;
+
 #define VMXNET3_TCD_GEN_SHIFT  31
 #define VMXNET3_TCD_GEN_SIZE   1
 #define VMXNET3_TCD_TXIDX_SHIFT0
@@ -382,6 +384,10 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_TXDATA_DESC_SIZE_ALIGN 64
 #define VMXNET3_TXDATA_DESC_SIZE_MASK  (VMXNET3_TXDATA_DESC_SIZE_ALIGN - 1)
 
+/* Rx Data Ring buffer size must be a multiple of 64 */
+#define VMXNET3_RXDATA_DESC_SIZE_ALIGN 64
+#define VMXNET3_RXDATA_DESC_SIZE_MASK  (VMXNET3_RXDATA_DESC_SIZE_ALIGN - 1)
+
 /* Max ring size */
 #define VMXNET3_TX_RING_MAX_SIZE   4096
 #define VMXNET3_TC_RING_MAX_SIZE   4096
@@ -392,6 +398,8 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_TXDATA_DESC_MIN_SIZE 128
 #define VMXNET3_TXDATA_DESC_MAX_SIZE 2048
 
+#define VMXNET3_RXDATA_DESC_MAX_SIZE 2048
+
 /* a list of reasons for queue stop */
 
 enum {
@@ -488,12 +496,14 @@ struct Vmxnet3_RxQueueConf {
__le64  rxRingBasePA[2];
__le64  compRingBasePA;
__le64  ddPA;/* driver data */
-   __le64  reserved;
+   __le64  rxDataRingBasePA;
__le32  rxRingSize[2];   /* # of rx desc */
__le32  compRingSize;/* # of rx comp desc */
__le32  ddLen;   /* size of driver data */
u8  intrIdx;
-   u8  _pad[7];
+   u8  _pad1[1];
+   __le16  rxDataRingDescSize;  /* size of rx data ring buffer */
+   u8  _pad2[4];
 };
 
 
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 4e42eb0..6449d2e 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1284,9 +1284,10 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
 */
break;
}
-   BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2);
+   BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2 &&
+  rcd->rqID != rq->dataRingQid);
idx = rcd->rxdIdx;
-   ring_idx = rcd->rqID < adapter->num_rx_queues ? 0 : 1;
+   ring_idx = VMXNET3_GET_RING_IDX(adapter, rcd->rqID);
ring = rq->rx_ring + ring_idx;
vmxnet3_getRxDesc(rxd, >rx_ring[ring_idx].base[idx].rxd,
  );
@@ -1301,8 +1302,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
}
 
if (rcd->sop) { /* first buf of the pkt */
+   bool rxDataRingUsed;
+   u16 len;
+
BUG_ON(rxd->btype != VMXNET3_RXD_BTYPE_HEAD ||
-  rcd->rqID != rq->qid);
+  (rcd->rqID != rq->qid &&
+   rcd->rqID != rq->dataRingQid));
 
BUG_ON(rbi->buf_type != VMXNET3_RX_BUF_SKB);
BUG_ON(ctx->skb != NULL || rbi->skb == NULL);
@@ -1318,8 +1323,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
 
skip_page_frags = false;
ctx->skb = rbi->skb;
+
+   rxDataRingUsed =
+   VMXNET3_RX_DATA_RING(adapter, rcd->rqID);
+   len = rxDataRingUsed ? rcd->len : rbi->len;
new_skb = netdev_alloc_skb_ip_align(adapter->netdev,
-   rbi->len);
+   len);
if (new_skb == NULL) {
/* Skb allocation failed, do not handover this
 * skb to stack. Reuse it. Drop the existing pkt
@@ -1330,25 +1339,48 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
skip_page_frags = true;
goto rcd_done;
}
-   new_dma_addr = dma_map_single(>pdev->dev,
- new_skb->d

[PATCH net-next v3 1/7] vmxnet3: prepare for version 3 changes

2016-06-13 Thread Shrikrishna Khare
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/Makefile  |  4 ++--
 drivers/net/vmxnet3/upt1_defs.h   |  4 ++--
 drivers/net/vmxnet3/vmxnet3_defs.h|  9 ++---
 drivers/net/vmxnet3/vmxnet3_drv.c | 22 +-
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  4 ++--
 drivers/net/vmxnet3/vmxnet3_int.h | 13 +++--
 6 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/drivers/net/vmxnet3/Makefile b/drivers/net/vmxnet3/Makefile
index 880f509..8cdbb63 100644
--- a/drivers/net/vmxnet3/Makefile
+++ b/drivers/net/vmxnet3/Makefile
@@ -2,7 +2,7 @@
 #
 # Linux driver for VMware's vmxnet3 ethernet NIC.
 #
-# Copyright (C) 2007-2009, VMware, Inc. All Rights Reserved.
+# Copyright (C) 2007-2016, VMware, Inc. All Rights Reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by the
@@ -21,7 +21,7 @@
 # The full GNU General Public License is included in this distribution in
 # the file called "COPYING".
 #
-# Maintained by: Shreyas Bhatewara 
+# Maintained by: pv-driv...@vmware.com
 #
 #
 

diff --git a/drivers/net/vmxnet3/upt1_defs.h b/drivers/net/vmxnet3/upt1_defs.h
index 969c751..db9f1fd 100644
--- a/drivers/net/vmxnet3/upt1_defs.h
+++ b/drivers/net/vmxnet3/upt1_defs.h
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara 
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 72ba8ae..8345e0c 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2015, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara 
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
@@ -76,7 +76,9 @@ enum {
VMXNET3_CMD_UPDATE_IML,
VMXNET3_CMD_UPDATE_PMCFG,
VMXNET3_CMD_UPDATE_FEATURE,
+   VMXNET3_CMD_RESERVED1,
VMXNET3_CMD_LOAD_PLUGIN,
+   VMXNET3_CMD_RESERVED2,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -87,7 +89,8 @@ enum {
VMXNET3_CMD_GET_DID_LO,
VMXNET3_CMD_GET_DID_HI,
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
-   VMXNET3_CMD_GET_CONF_INTR
+   VMXNET3_CMD_GET_CONF_INTR,
+   VMXNET3_CMD_GET_RESERVED1,
 };
 
 /*
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 08885bc..507c53d 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara 
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
@@ -1363,7 +1363,7 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
rbi->dma_addr = new_dma_addr;
rxd->addr = cpu_to_le64(rbi->dma_addr);
rxd->len = rbi->len;
-   if (adapter->version == 2 &&
+   if (VMXNET3_VERSION_GE_2(adapter) &&
rcd->type == VMXNET3_CDTYPE_RXCOMP_LRO) {
struct Vmxnet3_RxCompDescExt *rcdlro;
rcdlro = (struct Vmxnet3_RxCompDescExt *)rcd;
@@ -3200,12 +3200,16 @@ vmxnet3_probe_device(struct pci_dev *pdev,
goto err_alloc_pci;
 
ver = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_VRRS);
-   if (ver & 2) {
-   VMXNET3_WRITE_BAR1_REG(adapter, V

[PATCH net-next v3 2/7] vmxnet3: introduce generic command interface to configure the device

2016-06-13 Thread Shrikrishna Khare
Signed-off-by: Guolin Yang <gy...@vmware.com>
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_defs.h | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 8345e0c..a26a69d 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -79,6 +79,7 @@ enum {
VMXNET3_CMD_RESERVED1,
VMXNET3_CMD_LOAD_PLUGIN,
VMXNET3_CMD_RESERVED2,
+   VMXNET3_CMD_RESERVED3,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -612,6 +613,18 @@ struct Vmxnet3_RxQueueDesc {
u8__pad[88]; /* 128 aligned */
 };
 
+struct Vmxnet3_SetPolling {
+   u8  enablePolling;
+};
+
+/* If the command data <= 16 bytes, use the shared memory directly.
+ * otherwise, use variable length configuration descriptor.
+ */
+union Vmxnet3_CmdInfo {
+   struct Vmxnet3_VariableLenConfDesc  varConf;
+   struct Vmxnet3_SetPolling   setPolling;
+   __le64  data[2];
+};
 
 struct Vmxnet3_DSDevRead {
/* read-only region for device, read by dev in response to a SET cmd */
@@ -630,7 +643,14 @@ struct Vmxnet3_DriverShared {
__le32  pad;
struct Vmxnet3_DSDevReaddevRead;
__le32  ecr;
-   __le32  reserved[5];
+   __le32  reserved;
+   union {
+   __le32  reserved1[4];
+   union Vmxnet3_CmdInfo   cmdInfo; /* only valid in the context of
+ * executing the relevant
+ * command
+ */
+   } cu;
 };
 
 
-- 
2.8.2



[PATCH net-next v3 2/7] vmxnet3: introduce generic command interface to configure the device

2016-06-13 Thread Shrikrishna Khare
Signed-off-by: Guolin Yang 
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_defs.h | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 8345e0c..a26a69d 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -79,6 +79,7 @@ enum {
VMXNET3_CMD_RESERVED1,
VMXNET3_CMD_LOAD_PLUGIN,
VMXNET3_CMD_RESERVED2,
+   VMXNET3_CMD_RESERVED3,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -612,6 +613,18 @@ struct Vmxnet3_RxQueueDesc {
u8__pad[88]; /* 128 aligned */
 };
 
+struct Vmxnet3_SetPolling {
+   u8  enablePolling;
+};
+
+/* If the command data <= 16 bytes, use the shared memory directly.
+ * otherwise, use variable length configuration descriptor.
+ */
+union Vmxnet3_CmdInfo {
+   struct Vmxnet3_VariableLenConfDesc  varConf;
+   struct Vmxnet3_SetPolling   setPolling;
+   __le64  data[2];
+};
 
 struct Vmxnet3_DSDevRead {
/* read-only region for device, read by dev in response to a SET cmd */
@@ -630,7 +643,14 @@ struct Vmxnet3_DriverShared {
__le32  pad;
struct Vmxnet3_DSDevReaddevRead;
__le32  ecr;
-   __le32  reserved[5];
+   __le32  reserved;
+   union {
+   __le32  reserved1[4];
+   union Vmxnet3_CmdInfo   cmdInfo; /* only valid in the context of
+ * executing the relevant
+ * command
+ */
+   } cu;
 };
 
 
-- 
2.8.2



[PATCH net-next v3 3/7] vmxnet3: allow variable length transmit data ring buffer

2016-06-13 Thread Shrikrishna Khare
Signed-off-by: Sriram Rangarajan <rangaraj...@vmware.com>
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_defs.h| 12 +++-
 drivers/net/vmxnet3/vmxnet3_drv.c | 55 ++-
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  9 +++---
 drivers/net/vmxnet3/vmxnet3_int.h |  7 -
 4 files changed, 64 insertions(+), 19 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index a26a69d..701d989 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -92,6 +92,7 @@ enum {
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
VMXNET3_CMD_GET_CONF_INTR,
VMXNET3_CMD_GET_RESERVED1,
+   VMXNET3_CMD_GET_TXDATA_DESC_SIZE
 };
 
 /*
@@ -377,6 +378,10 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_RING_SIZE_ALIGN 32
 #define VMXNET3_RING_SIZE_MASK  (VMXNET3_RING_SIZE_ALIGN - 1)
 
+/* Tx Data Ring buffer size must be a multiple of 64 */
+#define VMXNET3_TXDATA_DESC_SIZE_ALIGN 64
+#define VMXNET3_TXDATA_DESC_SIZE_MASK  (VMXNET3_TXDATA_DESC_SIZE_ALIGN - 1)
+
 /* Max ring size */
 #define VMXNET3_TX_RING_MAX_SIZE   4096
 #define VMXNET3_TC_RING_MAX_SIZE   4096
@@ -384,6 +389,9 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_RX_RING2_MAX_SIZE  4096
 #define VMXNET3_RC_RING_MAX_SIZE   8192
 
+#define VMXNET3_TXDATA_DESC_MIN_SIZE 128
+#define VMXNET3_TXDATA_DESC_MAX_SIZE 2048
+
 /* a list of reasons for queue stop */
 
 enum {
@@ -470,7 +478,9 @@ struct Vmxnet3_TxQueueConf {
__le32  compRingSize; /* # of comp desc */
__le32  ddLen;/* size of driver data */
u8  intrIdx;
-   u8  _pad[7];
+   u8  _pad1[1];
+   __le16  txDataRingDescSize;
+   u8  _pad2[4];
 };
 
 
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 507c53d..4e42eb0 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -435,8 +435,8 @@ vmxnet3_tq_destroy(struct vmxnet3_tx_queue *tq,
tq->tx_ring.base = NULL;
}
if (tq->data_ring.base) {
-   dma_free_coherent(>pdev->dev, tq->data_ring.size *
- sizeof(struct Vmxnet3_TxDataDesc),
+   dma_free_coherent(>pdev->dev,
+ tq->data_ring.size * tq->txdata_desc_size,
  tq->data_ring.base, tq->data_ring.basePA);
tq->data_ring.base = NULL;
}
@@ -478,8 +478,8 @@ vmxnet3_tq_init(struct vmxnet3_tx_queue *tq,
tq->tx_ring.next2fill = tq->tx_ring.next2comp = 0;
tq->tx_ring.gen = VMXNET3_INIT_GEN;
 
-   memset(tq->data_ring.base, 0, tq->data_ring.size *
-  sizeof(struct Vmxnet3_TxDataDesc));
+   memset(tq->data_ring.base, 0,
+  tq->data_ring.size * tq->txdata_desc_size);
 
/* reset the tx comp ring contents to 0 and reset comp ring states */
memset(tq->comp_ring.base, 0, tq->comp_ring.size *
@@ -514,10 +514,10 @@ vmxnet3_tq_create(struct vmxnet3_tx_queue *tq,
}
 
tq->data_ring.base = dma_alloc_coherent(>pdev->dev,
-   tq->data_ring.size * sizeof(struct Vmxnet3_TxDataDesc),
+   tq->data_ring.size * tq->txdata_desc_size,
>data_ring.basePA, GFP_KERNEL);
if (!tq->data_ring.base) {
-   netdev_err(adapter->netdev, "failed to allocate data ring\n");
+   netdev_err(adapter->netdev, "failed to allocate tx data 
ring\n");
goto err;
}
 
@@ -689,7 +689,7 @@ vmxnet3_map_pkt(struct sk_buff *skb, struct vmxnet3_tx_ctx 
*ctx,
if (ctx->copy_size) {
ctx->sop_txd->txd.addr = cpu_to_le64(tq->data_ring.basePA +
tq->tx_ring.next2fill *
-   sizeof(struct Vmxnet3_TxDataDesc));
+   tq->txdata_desc_size);
ctx->sop_txd->dword[2] = cpu_to_le32(dw2 | ctx->copy_size);
ctx->sop_txd->dword[3] = 0;
 
@@ -873,8 +873,9 @@ vmxnet3_parse_hdr(struct sk_buff *skb, struct 
vmxnet3_tx_queue *tq,
ctx->eth_ip_hdr_size = 0;
ctx->l4_hdr_size = 0;
/* copy as much as allowed */
-   ctx->copy_size = min((unsigned int)VMXNET3_HDR_COPY_SIZE
-, skb_headlen(skb));
+   ctx->copy_size = min_t(unsigned int,
+  tq->txdata_desc_size,
+  skb_headlen(skb));
}
 

[PATCH net-next v3 3/7] vmxnet3: allow variable length transmit data ring buffer

2016-06-13 Thread Shrikrishna Khare
Signed-off-by: Sriram Rangarajan 
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_defs.h| 12 +++-
 drivers/net/vmxnet3/vmxnet3_drv.c | 55 ++-
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  9 +++---
 drivers/net/vmxnet3/vmxnet3_int.h |  7 -
 4 files changed, 64 insertions(+), 19 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index a26a69d..701d989 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -92,6 +92,7 @@ enum {
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
VMXNET3_CMD_GET_CONF_INTR,
VMXNET3_CMD_GET_RESERVED1,
+   VMXNET3_CMD_GET_TXDATA_DESC_SIZE
 };
 
 /*
@@ -377,6 +378,10 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_RING_SIZE_ALIGN 32
 #define VMXNET3_RING_SIZE_MASK  (VMXNET3_RING_SIZE_ALIGN - 1)
 
+/* Tx Data Ring buffer size must be a multiple of 64 */
+#define VMXNET3_TXDATA_DESC_SIZE_ALIGN 64
+#define VMXNET3_TXDATA_DESC_SIZE_MASK  (VMXNET3_TXDATA_DESC_SIZE_ALIGN - 1)
+
 /* Max ring size */
 #define VMXNET3_TX_RING_MAX_SIZE   4096
 #define VMXNET3_TC_RING_MAX_SIZE   4096
@@ -384,6 +389,9 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_RX_RING2_MAX_SIZE  4096
 #define VMXNET3_RC_RING_MAX_SIZE   8192
 
+#define VMXNET3_TXDATA_DESC_MIN_SIZE 128
+#define VMXNET3_TXDATA_DESC_MAX_SIZE 2048
+
 /* a list of reasons for queue stop */
 
 enum {
@@ -470,7 +478,9 @@ struct Vmxnet3_TxQueueConf {
__le32  compRingSize; /* # of comp desc */
__le32  ddLen;/* size of driver data */
u8  intrIdx;
-   u8  _pad[7];
+   u8  _pad1[1];
+   __le16  txDataRingDescSize;
+   u8  _pad2[4];
 };
 
 
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 507c53d..4e42eb0 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -435,8 +435,8 @@ vmxnet3_tq_destroy(struct vmxnet3_tx_queue *tq,
tq->tx_ring.base = NULL;
}
if (tq->data_ring.base) {
-   dma_free_coherent(>pdev->dev, tq->data_ring.size *
- sizeof(struct Vmxnet3_TxDataDesc),
+   dma_free_coherent(>pdev->dev,
+ tq->data_ring.size * tq->txdata_desc_size,
  tq->data_ring.base, tq->data_ring.basePA);
tq->data_ring.base = NULL;
}
@@ -478,8 +478,8 @@ vmxnet3_tq_init(struct vmxnet3_tx_queue *tq,
tq->tx_ring.next2fill = tq->tx_ring.next2comp = 0;
tq->tx_ring.gen = VMXNET3_INIT_GEN;
 
-   memset(tq->data_ring.base, 0, tq->data_ring.size *
-  sizeof(struct Vmxnet3_TxDataDesc));
+   memset(tq->data_ring.base, 0,
+  tq->data_ring.size * tq->txdata_desc_size);
 
/* reset the tx comp ring contents to 0 and reset comp ring states */
memset(tq->comp_ring.base, 0, tq->comp_ring.size *
@@ -514,10 +514,10 @@ vmxnet3_tq_create(struct vmxnet3_tx_queue *tq,
}
 
tq->data_ring.base = dma_alloc_coherent(>pdev->dev,
-   tq->data_ring.size * sizeof(struct Vmxnet3_TxDataDesc),
+   tq->data_ring.size * tq->txdata_desc_size,
>data_ring.basePA, GFP_KERNEL);
if (!tq->data_ring.base) {
-   netdev_err(adapter->netdev, "failed to allocate data ring\n");
+   netdev_err(adapter->netdev, "failed to allocate tx data 
ring\n");
goto err;
}
 
@@ -689,7 +689,7 @@ vmxnet3_map_pkt(struct sk_buff *skb, struct vmxnet3_tx_ctx 
*ctx,
if (ctx->copy_size) {
ctx->sop_txd->txd.addr = cpu_to_le64(tq->data_ring.basePA +
tq->tx_ring.next2fill *
-   sizeof(struct Vmxnet3_TxDataDesc));
+   tq->txdata_desc_size);
ctx->sop_txd->dword[2] = cpu_to_le32(dw2 | ctx->copy_size);
ctx->sop_txd->dword[3] = 0;
 
@@ -873,8 +873,9 @@ vmxnet3_parse_hdr(struct sk_buff *skb, struct 
vmxnet3_tx_queue *tq,
ctx->eth_ip_hdr_size = 0;
ctx->l4_hdr_size = 0;
/* copy as much as allowed */
-   ctx->copy_size = min((unsigned int)VMXNET3_HDR_COPY_SIZE
-, skb_headlen(skb));
+   ctx->copy_size = min_t(unsigned int,
+  tq->txdata_desc_size,
+  skb_headlen(skb));
}
 
if (skb->len <= VMXNET3_HDR_COPY_SIZE)

[PATCH net-next v3 0/7] vmxnet3: upgrade to version 3

2016-06-13 Thread Shrikrishna Khare
This patchset upgrades vmxnet3 to version 3.

Changes in v2:
 - Following patch is updated. See that patch for details:
   Driver: Vmxnet3: Add support for get_coalesce, set_coalesce ethtool

Changes in v3:
 - fix subject line to use vmxnet3: instead of Driver:Vmxnet3
 - resubmit when net-next is open


Shrikrishna Khare (7):
  vmxnet3: prepare for version 3 changes
  vmxnet3: introduce generic command interface to configure the device
  vmxnet3: allow variable length transmit data ring buffer
  vmxnet3: add receive data ring support
  vmxnet3: add support for get_coalesce, set_coalesce ethtool operations
  vmxnet3: introduce command to register memory region
  vmxnet3: update to version 3

 drivers/net/vmxnet3/Makefile  |   4 +-
 drivers/net/vmxnet3/upt1_defs.h   |   4 +-
 drivers/net/vmxnet3/vmxnet3_defs.h| 105 -
 drivers/net/vmxnet3/vmxnet3_drv.c | 285 --
 drivers/net/vmxnet3/vmxnet3_ethtool.c | 217 --
 drivers/net/vmxnet3/vmxnet3_int.h |  54 ++-
 6 files changed, 587 insertions(+), 82 deletions(-)

-- 
2.8.2



[PATCH net-next v3 0/7] vmxnet3: upgrade to version 3

2016-06-13 Thread Shrikrishna Khare
This patchset upgrades vmxnet3 to version 3.

Changes in v2:
 - Following patch is updated. See that patch for details:
   Driver: Vmxnet3: Add support for get_coalesce, set_coalesce ethtool

Changes in v3:
 - fix subject line to use vmxnet3: instead of Driver:Vmxnet3
 - resubmit when net-next is open


Shrikrishna Khare (7):
  vmxnet3: prepare for version 3 changes
  vmxnet3: introduce generic command interface to configure the device
  vmxnet3: allow variable length transmit data ring buffer
  vmxnet3: add receive data ring support
  vmxnet3: add support for get_coalesce, set_coalesce ethtool operations
  vmxnet3: introduce command to register memory region
  vmxnet3: update to version 3

 drivers/net/vmxnet3/Makefile  |   4 +-
 drivers/net/vmxnet3/upt1_defs.h   |   4 +-
 drivers/net/vmxnet3/vmxnet3_defs.h| 105 -
 drivers/net/vmxnet3/vmxnet3_drv.c | 285 --
 drivers/net/vmxnet3/vmxnet3_ethtool.c | 217 --
 drivers/net/vmxnet3/vmxnet3_int.h |  54 ++-
 6 files changed, 587 insertions(+), 82 deletions(-)

-- 
2.8.2



Re: [Pv-drivers] [PATCH net v2] vmxnet3: segCnt can be 1 for LRO packets

2016-06-08 Thread Shrikrishna Khare


On Wed, 8 Jun 2016, Thomas Hellstrom wrote:

> > mss = rcdlro->mss;
> > if (unlikely(segCnt <= 1))
> > segCnt = 0;
> 
> Based on this code, it looks like it can handle the case without taking
> down the kernel completely, so instead of a
> "BUG_ON", would it make sense with a WARN_ON_ONCE() or WARN_ON()?

Thanks for the review Thomas. I fixed the code to use WARN_ON_ONCE. Sent 
out revised patch.


Re: [Pv-drivers] [PATCH net v2] vmxnet3: segCnt can be 1 for LRO packets

2016-06-08 Thread Shrikrishna Khare


On Wed, 8 Jun 2016, Thomas Hellstrom wrote:

> > mss = rcdlro->mss;
> > if (unlikely(segCnt <= 1))
> > segCnt = 0;
> 
> Based on this code, it looks like it can handle the case without taking
> down the kernel completely, so instead of a
> "BUG_ON", would it make sense with a WARN_ON_ONCE() or WARN_ON()?

Thanks for the review Thomas. I fixed the code to use WARN_ON_ONCE. Sent 
out revised patch.


[PATCH net v3] vmxnet3: segCnt can be 1 for LRO packets

2016-06-08 Thread Shrikrishna Khare
The device emulation may send segCnt of 1 for LRO packets.

Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
Signed-off-by: Jin Heo <h...@vmware.com>

---
v2: fix subject line
v3: replace BUG_ON with WARN_ON_ONCE
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 2 +-
 drivers/net/vmxnet3/vmxnet3_int.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index db8022a..08885bc 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1369,7 +1369,7 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
rcdlro = (struct Vmxnet3_RxCompDescExt *)rcd;
 
segCnt = rcdlro->segCnt;
-   BUG_ON(segCnt <= 1);
+   WARN_ON_ONCE(segCnt == 0);
mss = rcdlro->mss;
if (unlikely(segCnt <= 1))
segCnt = 0;
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h 
b/drivers/net/vmxnet3/vmxnet3_int.h
index c482539..3d2b64e 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.7.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.8.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM  0x01040700
+#define VMXNET3_DRIVER_VERSION_NUM  0x01040800
 
 #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
-- 
2.8.2



[PATCH net v3] vmxnet3: segCnt can be 1 for LRO packets

2016-06-08 Thread Shrikrishna Khare
The device emulation may send segCnt of 1 for LRO packets.

Signed-off-by: Shrikrishna Khare 
Signed-off-by: Jin Heo 

---
v2: fix subject line
v3: replace BUG_ON with WARN_ON_ONCE
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 2 +-
 drivers/net/vmxnet3/vmxnet3_int.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index db8022a..08885bc 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1369,7 +1369,7 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
rcdlro = (struct Vmxnet3_RxCompDescExt *)rcd;
 
segCnt = rcdlro->segCnt;
-   BUG_ON(segCnt <= 1);
+   WARN_ON_ONCE(segCnt == 0);
mss = rcdlro->mss;
if (unlikely(segCnt <= 1))
segCnt = 0;
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h 
b/drivers/net/vmxnet3/vmxnet3_int.h
index c482539..3d2b64e 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.7.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.8.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM  0x01040700
+#define VMXNET3_DRIVER_VERSION_NUM  0x01040800
 
 #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
-- 
2.8.2



Re: [PATCH net] Driver: Vmxnet3: segCnt can be 1 for LRO packets

2016-06-08 Thread Shrikrishna Khare


On Tue, 7 Jun 2016, David Miller wrote:

> From: Shrikrishna Khare <skh...@vmware.com>
> Date: Tue,  7 Jun 2016 22:55:17 -0700
> 
> > The device emulation may send segCnt of 1 for LRO packets.
> > 
> > Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
> > Signed-off-by: Jin Heo <h...@vmware.com>
> 
> Please do not capitalize subsystem prefixes in your Subject line,
> and "Driver: " is so generic that it's pointless to use it as a
> part of the subsystem prefix.  Plain "vmxnet3: " is sufficient.
> 

Ok. Sent v2 of the patch with the subject line fixed.


Re: [PATCH net] Driver: Vmxnet3: segCnt can be 1 for LRO packets

2016-06-08 Thread Shrikrishna Khare


On Tue, 7 Jun 2016, David Miller wrote:

> From: Shrikrishna Khare 
> Date: Tue,  7 Jun 2016 22:55:17 -0700
> 
> > The device emulation may send segCnt of 1 for LRO packets.
> > 
> > Signed-off-by: Shrikrishna Khare 
> > Signed-off-by: Jin Heo 
> 
> Please do not capitalize subsystem prefixes in your Subject line,
> and "Driver: " is so generic that it's pointless to use it as a
> part of the subsystem prefix.  Plain "vmxnet3: " is sufficient.
> 

Ok. Sent v2 of the patch with the subject line fixed.


[PATCH net v2] vmxnet3: segCnt can be 1 for LRO packets

2016-06-08 Thread Shrikrishna Khare
The device emulation may send segCnt of 1 for LRO packets.

Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
Signed-off-by: Jin Heo <h...@vmware.com>

---
v2: fix subject line
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 2 +-
 drivers/net/vmxnet3/vmxnet3_int.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index db8022a..6f399b2 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1369,7 +1369,7 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
rcdlro = (struct Vmxnet3_RxCompDescExt *)rcd;
 
segCnt = rcdlro->segCnt;
-   BUG_ON(segCnt <= 1);
+   BUG_ON(segCnt == 0);
mss = rcdlro->mss;
if (unlikely(segCnt <= 1))
segCnt = 0;
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h 
b/drivers/net/vmxnet3/vmxnet3_int.h
index c482539..3d2b64e 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.7.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.8.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM  0x01040700
+#define VMXNET3_DRIVER_VERSION_NUM  0x01040800
 
 #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
-- 
2.8.2



[PATCH net v2] vmxnet3: segCnt can be 1 for LRO packets

2016-06-08 Thread Shrikrishna Khare
The device emulation may send segCnt of 1 for LRO packets.

Signed-off-by: Shrikrishna Khare 
Signed-off-by: Jin Heo 

---
v2: fix subject line
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 2 +-
 drivers/net/vmxnet3/vmxnet3_int.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index db8022a..6f399b2 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1369,7 +1369,7 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
rcdlro = (struct Vmxnet3_RxCompDescExt *)rcd;
 
segCnt = rcdlro->segCnt;
-   BUG_ON(segCnt <= 1);
+   BUG_ON(segCnt == 0);
mss = rcdlro->mss;
if (unlikely(segCnt <= 1))
segCnt = 0;
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h 
b/drivers/net/vmxnet3/vmxnet3_int.h
index c482539..3d2b64e 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.7.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.8.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM  0x01040700
+#define VMXNET3_DRIVER_VERSION_NUM  0x01040800
 
 #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
-- 
2.8.2



[PATCH net] Driver: Vmxnet3: segCnt can be 1 for LRO packets

2016-06-07 Thread Shrikrishna Khare
The device emulation may send segCnt of 1 for LRO packets.

Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
Signed-off-by: Jin Heo <h...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 2 +-
 drivers/net/vmxnet3/vmxnet3_int.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index db8022a..6f399b2 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1369,7 +1369,7 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
rcdlro = (struct Vmxnet3_RxCompDescExt *)rcd;
 
segCnt = rcdlro->segCnt;
-   BUG_ON(segCnt <= 1);
+   BUG_ON(segCnt == 0);
mss = rcdlro->mss;
if (unlikely(segCnt <= 1))
segCnt = 0;
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h 
b/drivers/net/vmxnet3/vmxnet3_int.h
index c482539..3d2b64e 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.7.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.8.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM  0x01040700
+#define VMXNET3_DRIVER_VERSION_NUM  0x01040800
 
 #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
-- 
2.8.2



[PATCH net] Driver: Vmxnet3: segCnt can be 1 for LRO packets

2016-06-07 Thread Shrikrishna Khare
The device emulation may send segCnt of 1 for LRO packets.

Signed-off-by: Shrikrishna Khare 
Signed-off-by: Jin Heo 
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 2 +-
 drivers/net/vmxnet3/vmxnet3_int.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index db8022a..6f399b2 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1369,7 +1369,7 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
rcdlro = (struct Vmxnet3_RxCompDescExt *)rcd;
 
segCnt = rcdlro->segCnt;
-   BUG_ON(segCnt <= 1);
+   BUG_ON(segCnt == 0);
mss = rcdlro->mss;
if (unlikely(segCnt <= 1))
segCnt = 0;
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h 
b/drivers/net/vmxnet3/vmxnet3_int.h
index c482539..3d2b64e 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.7.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.8.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM  0x01040700
+#define VMXNET3_DRIVER_VERSION_NUM  0x01040800
 
 #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
-- 
2.8.2



Re: [PATCH net-next 5/7] Driver: Vmxnet3: Add support for get_coalesce, set_coalesce ethtool operations

2016-05-20 Thread Shrikrishna Khare


On Sun, 8 May 2016, Ben Hutchings wrote:

> > Would a patch that maps 0 to 'no coalescing' be acceptable? That is:
> > 
> > rx-usecs = 0 -> coalescing disabled.
> > rx-usecs = 1 -> default (chosen by the device).
> > rx-usecs = 2 -> adaptive coalescing.
> > rx-usecs = 3 -> static coalescing.
> 
> I still don't like it much.  For the 3 special values (0 isn't really
> special):
> 
> 1 = default: When the driver sets the virtual device to this mode, can it 
> then read back what the actual settings are, or are they hidden?  If it can, 
> then userland can also read the defaults and explicitly return to them later. 
>  But I do see the usefulness of an explicit request to reset to defaults.
> 
> 2 = adaptive coalescing: There are already fields to request adaptive 
> coalescing; you should support them.
> 
> 3 = static coalescing: I don't understand what this means.

static refers to the number of packets to batch before raising an 
interrupt - which maps to existing tx_max_coaleced_frames.

Have sent out v2 of the patch that no longer uses special values of 
rx-usecs to distinguish between the coalescing modes. Existing 
ethtool_coalesce fields are used as appropriate instead.

In v2, driver can no longer issue "revert to defaults" command 
(think such a mechanism might be useful addition but belongs to ethtool 
framework).


Thanks,
Shri

Re: [PATCH net-next 5/7] Driver: Vmxnet3: Add support for get_coalesce, set_coalesce ethtool operations

2016-05-20 Thread Shrikrishna Khare


On Sun, 8 May 2016, Ben Hutchings wrote:

> > Would a patch that maps 0 to 'no coalescing' be acceptable? That is:
> > 
> > rx-usecs = 0 -> coalescing disabled.
> > rx-usecs = 1 -> default (chosen by the device).
> > rx-usecs = 2 -> adaptive coalescing.
> > rx-usecs = 3 -> static coalescing.
> 
> I still don't like it much.  For the 3 special values (0 isn't really
> special):
> 
> 1 = default: When the driver sets the virtual device to this mode, can it 
> then read back what the actual settings are, or are they hidden?  If it can, 
> then userland can also read the defaults and explicitly return to them later. 
>  But I do see the usefulness of an explicit request to reset to defaults.
> 
> 2 = adaptive coalescing: There are already fields to request adaptive 
> coalescing; you should support them.
> 
> 3 = static coalescing: I don't understand what this means.

static refers to the number of packets to batch before raising an 
interrupt - which maps to existing tx_max_coaleced_frames.

Have sent out v2 of the patch that no longer uses special values of 
rx-usecs to distinguish between the coalescing modes. Existing 
ethtool_coalesce fields are used as appropriate instead.

In v2, driver can no longer issue "revert to defaults" command 
(think such a mechanism might be useful addition but belongs to ethtool 
framework).


Thanks,
Shri

[PATCH net-next v2 6/7] Driver: Vmxnet3: Introduce command to register memory region

2016-05-20 Thread Shrikrishna Khare
Signed-off-by: Guolin Yang <gy...@vmware.com>
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_defs.h | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 274e145..c3a3164 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -81,6 +81,7 @@ enum {
VMXNET3_CMD_RESERVED2,
VMXNET3_CMD_RESERVED3,
VMXNET3_CMD_SET_COALESCE,
+   VMXNET3_CMD_REGISTER_MEMREGS,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -668,6 +669,22 @@ struct Vmxnet3_CoalesceScheme {
} coalPara;
 };
 
+struct Vmxnet3_MemoryRegion {
+   __le64  startPA;
+   __le32  length;
+   __le16  txQueueBits;
+   __le16  rxQueueBits;
+};
+
+#define MAX_MEMORY_REGION_PER_QUEUE 16
+#define MAX_MEMORY_REGION_PER_DEVICE 256
+
+struct Vmxnet3_MemRegs {
+   __le16  numRegs;
+   __le16  pad[3];
+   struct Vmxnet3_MemoryRegion memRegs[1];
+};
+
 /* If the command data <= 16 bytes, use the shared memory directly.
  * otherwise, use variable length configuration descriptor.
  */
-- 
2.8.2



[PATCH net-next v2 1/7] Driver: Vmxnet3: Prepare for version 3 changes

2016-05-20 Thread Shrikrishna Khare
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/Makefile  |  4 ++--
 drivers/net/vmxnet3/upt1_defs.h   |  4 ++--
 drivers/net/vmxnet3/vmxnet3_defs.h|  9 ++---
 drivers/net/vmxnet3/vmxnet3_drv.c | 22 +-
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  4 ++--
 drivers/net/vmxnet3/vmxnet3_int.h | 13 +++--
 6 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/drivers/net/vmxnet3/Makefile b/drivers/net/vmxnet3/Makefile
index 880f509..8cdbb63 100644
--- a/drivers/net/vmxnet3/Makefile
+++ b/drivers/net/vmxnet3/Makefile
@@ -2,7 +2,7 @@
 #
 # Linux driver for VMware's vmxnet3 ethernet NIC.
 #
-# Copyright (C) 2007-2009, VMware, Inc. All Rights Reserved.
+# Copyright (C) 2007-2016, VMware, Inc. All Rights Reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by the
@@ -21,7 +21,7 @@
 # The full GNU General Public License is included in this distribution in
 # the file called "COPYING".
 #
-# Maintained by: Shreyas Bhatewara <pv-driv...@vmware.com>
+# Maintained by: pv-driv...@vmware.com
 #
 #
 

diff --git a/drivers/net/vmxnet3/upt1_defs.h b/drivers/net/vmxnet3/upt1_defs.h
index 969c751..db9f1fd 100644
--- a/drivers/net/vmxnet3/upt1_defs.h
+++ b/drivers/net/vmxnet3/upt1_defs.h
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara <pv-driv...@vmware.com>
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 72ba8ae..8345e0c 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2015, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara <pv-driv...@vmware.com>
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
@@ -76,7 +76,9 @@ enum {
VMXNET3_CMD_UPDATE_IML,
VMXNET3_CMD_UPDATE_PMCFG,
VMXNET3_CMD_UPDATE_FEATURE,
+   VMXNET3_CMD_RESERVED1,
VMXNET3_CMD_LOAD_PLUGIN,
+   VMXNET3_CMD_RESERVED2,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -87,7 +89,8 @@ enum {
VMXNET3_CMD_GET_DID_LO,
VMXNET3_CMD_GET_DID_HI,
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
-   VMXNET3_CMD_GET_CONF_INTR
+   VMXNET3_CMD_GET_CONF_INTR,
+   VMXNET3_CMD_GET_RESERVED1,
 };
 
 /*
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index db8022a..53434ed 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara <pv-driv...@vmware.com>
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
@@ -1363,7 +1363,7 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
rbi->dma_addr = new_dma_addr;
rxd->addr = cpu_to_le64(rbi->dma_addr);
rxd->len = rbi->len;
-   if (adapter->version == 2 &&
+   if (VMXNET3_VERSION_GE_2(adapter) &&
rcd->type == VMXNET3_CDTYPE_RXCOMP_LRO) {
struct Vmxnet3_RxCompDescExt *rcdlro;
rcdlro = (struct Vmxnet3_RxCompDescExt *)rcd;
@@ -3200,12 +3200,16 @@ vmxnet3_probe_device(struct pci_dev *pdev,
  

[PATCH net-next v2 2/7] Driver: Vmxnet3: Introduce generic command interface to configure the device

2016-05-20 Thread Shrikrishna Khare
Signed-off-by: Guolin Yang <gy...@vmware.com>
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_defs.h | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 8345e0c..a26a69d 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -79,6 +79,7 @@ enum {
VMXNET3_CMD_RESERVED1,
VMXNET3_CMD_LOAD_PLUGIN,
VMXNET3_CMD_RESERVED2,
+   VMXNET3_CMD_RESERVED3,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -612,6 +613,18 @@ struct Vmxnet3_RxQueueDesc {
u8__pad[88]; /* 128 aligned */
 };
 
+struct Vmxnet3_SetPolling {
+   u8  enablePolling;
+};
+
+/* If the command data <= 16 bytes, use the shared memory directly.
+ * otherwise, use variable length configuration descriptor.
+ */
+union Vmxnet3_CmdInfo {
+   struct Vmxnet3_VariableLenConfDesc  varConf;
+   struct Vmxnet3_SetPolling   setPolling;
+   __le64  data[2];
+};
 
 struct Vmxnet3_DSDevRead {
/* read-only region for device, read by dev in response to a SET cmd */
@@ -630,7 +643,14 @@ struct Vmxnet3_DriverShared {
__le32  pad;
struct Vmxnet3_DSDevReaddevRead;
__le32  ecr;
-   __le32  reserved[5];
+   __le32  reserved;
+   union {
+   __le32  reserved1[4];
+   union Vmxnet3_CmdInfo   cmdInfo; /* only valid in the context of
+ * executing the relevant
+ * command
+ */
+   } cu;
 };
 
 
-- 
2.8.2



[PATCH net-next v2 6/7] Driver: Vmxnet3: Introduce command to register memory region

2016-05-20 Thread Shrikrishna Khare
Signed-off-by: Guolin Yang 
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_defs.h | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 274e145..c3a3164 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -81,6 +81,7 @@ enum {
VMXNET3_CMD_RESERVED2,
VMXNET3_CMD_RESERVED3,
VMXNET3_CMD_SET_COALESCE,
+   VMXNET3_CMD_REGISTER_MEMREGS,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -668,6 +669,22 @@ struct Vmxnet3_CoalesceScheme {
} coalPara;
 };
 
+struct Vmxnet3_MemoryRegion {
+   __le64  startPA;
+   __le32  length;
+   __le16  txQueueBits;
+   __le16  rxQueueBits;
+};
+
+#define MAX_MEMORY_REGION_PER_QUEUE 16
+#define MAX_MEMORY_REGION_PER_DEVICE 256
+
+struct Vmxnet3_MemRegs {
+   __le16  numRegs;
+   __le16  pad[3];
+   struct Vmxnet3_MemoryRegion memRegs[1];
+};
+
 /* If the command data <= 16 bytes, use the shared memory directly.
  * otherwise, use variable length configuration descriptor.
  */
-- 
2.8.2



[PATCH net-next v2 1/7] Driver: Vmxnet3: Prepare for version 3 changes

2016-05-20 Thread Shrikrishna Khare
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/Makefile  |  4 ++--
 drivers/net/vmxnet3/upt1_defs.h   |  4 ++--
 drivers/net/vmxnet3/vmxnet3_defs.h|  9 ++---
 drivers/net/vmxnet3/vmxnet3_drv.c | 22 +-
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  4 ++--
 drivers/net/vmxnet3/vmxnet3_int.h | 13 +++--
 6 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/drivers/net/vmxnet3/Makefile b/drivers/net/vmxnet3/Makefile
index 880f509..8cdbb63 100644
--- a/drivers/net/vmxnet3/Makefile
+++ b/drivers/net/vmxnet3/Makefile
@@ -2,7 +2,7 @@
 #
 # Linux driver for VMware's vmxnet3 ethernet NIC.
 #
-# Copyright (C) 2007-2009, VMware, Inc. All Rights Reserved.
+# Copyright (C) 2007-2016, VMware, Inc. All Rights Reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by the
@@ -21,7 +21,7 @@
 # The full GNU General Public License is included in this distribution in
 # the file called "COPYING".
 #
-# Maintained by: Shreyas Bhatewara 
+# Maintained by: pv-driv...@vmware.com
 #
 #
 

diff --git a/drivers/net/vmxnet3/upt1_defs.h b/drivers/net/vmxnet3/upt1_defs.h
index 969c751..db9f1fd 100644
--- a/drivers/net/vmxnet3/upt1_defs.h
+++ b/drivers/net/vmxnet3/upt1_defs.h
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara 
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 72ba8ae..8345e0c 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2015, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara 
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
@@ -76,7 +76,9 @@ enum {
VMXNET3_CMD_UPDATE_IML,
VMXNET3_CMD_UPDATE_PMCFG,
VMXNET3_CMD_UPDATE_FEATURE,
+   VMXNET3_CMD_RESERVED1,
VMXNET3_CMD_LOAD_PLUGIN,
+   VMXNET3_CMD_RESERVED2,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -87,7 +89,8 @@ enum {
VMXNET3_CMD_GET_DID_LO,
VMXNET3_CMD_GET_DID_HI,
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
-   VMXNET3_CMD_GET_CONF_INTR
+   VMXNET3_CMD_GET_CONF_INTR,
+   VMXNET3_CMD_GET_RESERVED1,
 };
 
 /*
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index db8022a..53434ed 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara 
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
@@ -1363,7 +1363,7 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
rbi->dma_addr = new_dma_addr;
rxd->addr = cpu_to_le64(rbi->dma_addr);
rxd->len = rbi->len;
-   if (adapter->version == 2 &&
+   if (VMXNET3_VERSION_GE_2(adapter) &&
rcd->type == VMXNET3_CDTYPE_RXCOMP_LRO) {
struct Vmxnet3_RxCompDescExt *rcdlro;
rcdlro = (struct Vmxnet3_RxCompDescExt *)rcd;
@@ -3200,12 +3200,16 @@ vmxnet3_probe_device(struct pci_dev *pdev,
goto err_alloc_pci;
 
ver = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_VRRS);
-   if (ver & 2) {
-   VMXNET3_WRITE_BAR1_REG(adapter, V

[PATCH net-next v2 2/7] Driver: Vmxnet3: Introduce generic command interface to configure the device

2016-05-20 Thread Shrikrishna Khare
Signed-off-by: Guolin Yang 
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_defs.h | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 8345e0c..a26a69d 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -79,6 +79,7 @@ enum {
VMXNET3_CMD_RESERVED1,
VMXNET3_CMD_LOAD_PLUGIN,
VMXNET3_CMD_RESERVED2,
+   VMXNET3_CMD_RESERVED3,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -612,6 +613,18 @@ struct Vmxnet3_RxQueueDesc {
u8__pad[88]; /* 128 aligned */
 };
 
+struct Vmxnet3_SetPolling {
+   u8  enablePolling;
+};
+
+/* If the command data <= 16 bytes, use the shared memory directly.
+ * otherwise, use variable length configuration descriptor.
+ */
+union Vmxnet3_CmdInfo {
+   struct Vmxnet3_VariableLenConfDesc  varConf;
+   struct Vmxnet3_SetPolling   setPolling;
+   __le64  data[2];
+};
 
 struct Vmxnet3_DSDevRead {
/* read-only region for device, read by dev in response to a SET cmd */
@@ -630,7 +643,14 @@ struct Vmxnet3_DriverShared {
__le32  pad;
struct Vmxnet3_DSDevReaddevRead;
__le32  ecr;
-   __le32  reserved[5];
+   __le32  reserved;
+   union {
+   __le32  reserved1[4];
+   union Vmxnet3_CmdInfo   cmdInfo; /* only valid in the context of
+ * executing the relevant
+ * command
+ */
+   } cu;
 };
 
 
-- 
2.8.2



[PATCH net-next v2 5/7] Driver: Vmxnet3: Add support for get_coalesce, set_coalesce ethtool operations

2016-05-20 Thread Shrikrishna Khare
Signed-off-by: Keyong Sun <s...@vmware.com>
Signed-off-by: Manoj Tammali <tamma...@vmware.com>
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
v1-v2: v1 patch used special values of rx-usecs to differentiate between
coalescing modes. v2 uses relevant fields in struct ethtool_coalesce
to choose modes. Also, a new command VMXNET3_CMD_GET_COALESCE is
introduced which allows driver to query the device for default coalescing
configuration.

---
 drivers/net/vmxnet3/vmxnet3_defs.h|  33 ++-
 drivers/net/vmxnet3/vmxnet3_drv.c |  55 
 drivers/net/vmxnet3/vmxnet3_ethtool.c | 160 ++
 drivers/net/vmxnet3/vmxnet3_int.h |   9 ++
 4 files changed, 256 insertions(+), 1 deletion(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index f3b31c2..274e145 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -80,6 +80,7 @@ enum {
VMXNET3_CMD_LOAD_PLUGIN,
VMXNET3_CMD_RESERVED2,
VMXNET3_CMD_RESERVED3,
+   VMXNET3_CMD_SET_COALESCE,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -92,7 +93,8 @@ enum {
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
VMXNET3_CMD_GET_CONF_INTR,
VMXNET3_CMD_GET_RESERVED1,
-   VMXNET3_CMD_GET_TXDATA_DESC_SIZE
+   VMXNET3_CMD_GET_TXDATA_DESC_SIZE,
+   VMXNET3_CMD_GET_COALESCE,
 };
 
 /*
@@ -637,6 +639,35 @@ struct Vmxnet3_SetPolling {
u8  enablePolling;
 };
 
+#define VMXNET3_COAL_STATIC_MAX_DEPTH  128
+#define VMXNET3_COAL_RBC_MIN_RATE  100
+#define VMXNET3_COAL_RBC_MAX_RATE  10
+
+enum Vmxnet3_CoalesceMode {
+   VMXNET3_COALESCE_DISABLED   = 0,
+   VMXNET3_COALESCE_ADAPT  = 1,
+   VMXNET3_COALESCE_STATIC = 2,
+   VMXNET3_COALESCE_RBC= 3
+};
+
+struct Vmxnet3_CoalesceRbc {
+   u32 rbc_rate;
+};
+
+struct Vmxnet3_CoalesceStatic {
+   u32 tx_depth;
+   u32 tx_comp_depth;
+   u32 rx_depth;
+};
+
+struct Vmxnet3_CoalesceScheme {
+   enum Vmxnet3_CoalesceMode   coalMode;
+   union {
+   struct Vmxnet3_CoalesceRbc  coalRbc;
+   struct Vmxnet3_CoalesceStatic   coalStatic;
+   } coalPara;
+};
+
 /* If the command data <= 16 bytes, use the shared memory directly.
  * otherwise, use variable length configuration descriptor.
  */
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index a6dc7c7..86965cd 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -2491,6 +2491,33 @@ vmxnet3_setup_driver_shared(struct vmxnet3_adapter 
*adapter)
/* the rest are already zeroed */
 }
 
+static void
+vmxnet3_init_coalesce(struct vmxnet3_adapter *adapter)
+{
+   struct Vmxnet3_DriverShared *shared = adapter->shared;
+   union Vmxnet3_CmdInfo *cmdInfo = >cu.cmdInfo;
+   unsigned long flags;
+
+   if (!VMXNET3_VERSION_GE_3(adapter))
+   return;
+
+   spin_lock_irqsave(>cmd_lock, flags);
+   cmdInfo->varConf.confVer = 1;
+   cmdInfo->varConf.confLen =
+   cpu_to_le32(sizeof(*adapter->coal_conf));
+   cmdInfo->varConf.confPA  = cpu_to_le64(adapter->coal_conf_pa);
+   spin_unlock_irqrestore(>cmd_lock, flags);
+
+   if (adapter->default_coal_mode) {
+   VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
+  VMXNET3_CMD_GET_COALESCE);
+   } else {
+   VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
+  VMXNET3_CMD_SET_COALESCE);
+   }
+
+   spin_unlock_irqrestore(>cmd_lock, flags);
+}
 
 int
 vmxnet3_activate_dev(struct vmxnet3_adapter *adapter)
@@ -2540,6 +2567,8 @@ vmxnet3_activate_dev(struct vmxnet3_adapter *adapter)
goto activate_err;
}
 
+   vmxnet3_init_coalesce(adapter);
+
for (i = 0; i < adapter->num_rx_queues; i++) {
VMXNET3_WRITE_BAR0_REG(adapter,
VMXNET3_REG_RXPROD + i * VMXNET3_REG_ALIGN,
@@ -3345,6 +3374,22 @@ vmxnet3_probe_device(struct pci_dev *pdev,
goto err_ver;
}
 
+   if (VMXNET3_VERSION_GE_3(adapter)) {
+   adapter->coal_conf =
+   dma_alloc_coherent(>pdev->dev,
+  sizeof(struct Vmxnet3_CoalesceScheme)
+  ,
+  >coal_conf_pa,
+  GFP_KERNEL);
+   if (!adapter->coal_conf) {
+   err = -ENOMEM;
+  

[PATCH net-next v2 4/7] Driver: Vmxnet3: Add Receive Data Ring support

2016-05-20 Thread Shrikrishna Khare
Receive Data Ring buffer length is configurable via ethtool -G ethX rx-mini

Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_defs.h|  14 +++-
 drivers/net/vmxnet3/vmxnet3_drv.c | 153 +++---
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  48 ---
 drivers/net/vmxnet3/vmxnet3_int.h |  23 -
 4 files changed, 193 insertions(+), 45 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 701d989..f3b31c2 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -174,6 +174,8 @@ struct Vmxnet3_TxDataDesc {
u8  data[VMXNET3_HDR_COPY_SIZE];
 };
 
+typedef u8 Vmxnet3_RxDataDesc;
+
 #define VMXNET3_TCD_GEN_SHIFT  31
 #define VMXNET3_TCD_GEN_SIZE   1
 #define VMXNET3_TCD_TXIDX_SHIFT0
@@ -382,6 +384,10 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_TXDATA_DESC_SIZE_ALIGN 64
 #define VMXNET3_TXDATA_DESC_SIZE_MASK  (VMXNET3_TXDATA_DESC_SIZE_ALIGN - 1)
 
+/* Rx Data Ring buffer size must be a multiple of 64 */
+#define VMXNET3_RXDATA_DESC_SIZE_ALIGN 64
+#define VMXNET3_RXDATA_DESC_SIZE_MASK  (VMXNET3_RXDATA_DESC_SIZE_ALIGN - 1)
+
 /* Max ring size */
 #define VMXNET3_TX_RING_MAX_SIZE   4096
 #define VMXNET3_TC_RING_MAX_SIZE   4096
@@ -392,6 +398,8 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_TXDATA_DESC_MIN_SIZE 128
 #define VMXNET3_TXDATA_DESC_MAX_SIZE 2048
 
+#define VMXNET3_RXDATA_DESC_MAX_SIZE 2048
+
 /* a list of reasons for queue stop */
 
 enum {
@@ -488,12 +496,14 @@ struct Vmxnet3_RxQueueConf {
__le64  rxRingBasePA[2];
__le64  compRingBasePA;
__le64  ddPA;/* driver data */
-   __le64  reserved;
+   __le64  rxDataRingBasePA;
__le32  rxRingSize[2];   /* # of rx desc */
__le32  compRingSize;/* # of rx comp desc */
__le32  ddLen;   /* size of driver data */
u8  intrIdx;
-   u8  _pad[7];
+   u8  _pad1[1];
+   __le16  rxDataRingDescSize;  /* size of rx data ring buffer */
+   u8  _pad2[4];
 };
 
 
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 58632b1..a6dc7c7 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1284,9 +1284,10 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
 */
break;
}
-   BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2);
+   BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2 &&
+  rcd->rqID != rq->dataRingQid);
idx = rcd->rxdIdx;
-   ring_idx = rcd->rqID < adapter->num_rx_queues ? 0 : 1;
+   ring_idx = VMXNET3_GET_RING_IDX(adapter, rcd->rqID);
ring = rq->rx_ring + ring_idx;
vmxnet3_getRxDesc(rxd, >rx_ring[ring_idx].base[idx].rxd,
  );
@@ -1301,8 +1302,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
}
 
if (rcd->sop) { /* first buf of the pkt */
+   bool rxDataRingUsed;
+   u16 len;
+
BUG_ON(rxd->btype != VMXNET3_RXD_BTYPE_HEAD ||
-  rcd->rqID != rq->qid);
+  (rcd->rqID != rq->qid &&
+   rcd->rqID != rq->dataRingQid));
 
BUG_ON(rbi->buf_type != VMXNET3_RX_BUF_SKB);
BUG_ON(ctx->skb != NULL || rbi->skb == NULL);
@@ -1318,8 +1323,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
 
skip_page_frags = false;
ctx->skb = rbi->skb;
+
+   rxDataRingUsed =
+   VMXNET3_RX_DATA_RING(adapter, rcd->rqID);
+   len = rxDataRingUsed ? rcd->len : rbi->len;
new_skb = netdev_alloc_skb_ip_align(adapter->netdev,
-   rbi->len);
+   len);
if (new_skb == NULL) {
/* Skb allocation failed, do not handover this
 * skb to stack. Reuse it. Drop the existing pkt
@@ -1330,25 +1339,48 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
skip_page_frags = true;
goto rcd_done;
}
-   new_dma_addr = dma_map_single(>pdev->dev,
- new_skb

[PATCH net-next v2 5/7] Driver: Vmxnet3: Add support for get_coalesce, set_coalesce ethtool operations

2016-05-20 Thread Shrikrishna Khare
Signed-off-by: Keyong Sun 
Signed-off-by: Manoj Tammali 
Signed-off-by: Shrikrishna Khare 
---
v1-v2: v1 patch used special values of rx-usecs to differentiate between
coalescing modes. v2 uses relevant fields in struct ethtool_coalesce
to choose modes. Also, a new command VMXNET3_CMD_GET_COALESCE is
introduced which allows driver to query the device for default coalescing
configuration.

---
 drivers/net/vmxnet3/vmxnet3_defs.h|  33 ++-
 drivers/net/vmxnet3/vmxnet3_drv.c |  55 
 drivers/net/vmxnet3/vmxnet3_ethtool.c | 160 ++
 drivers/net/vmxnet3/vmxnet3_int.h |   9 ++
 4 files changed, 256 insertions(+), 1 deletion(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index f3b31c2..274e145 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -80,6 +80,7 @@ enum {
VMXNET3_CMD_LOAD_PLUGIN,
VMXNET3_CMD_RESERVED2,
VMXNET3_CMD_RESERVED3,
+   VMXNET3_CMD_SET_COALESCE,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -92,7 +93,8 @@ enum {
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
VMXNET3_CMD_GET_CONF_INTR,
VMXNET3_CMD_GET_RESERVED1,
-   VMXNET3_CMD_GET_TXDATA_DESC_SIZE
+   VMXNET3_CMD_GET_TXDATA_DESC_SIZE,
+   VMXNET3_CMD_GET_COALESCE,
 };
 
 /*
@@ -637,6 +639,35 @@ struct Vmxnet3_SetPolling {
u8  enablePolling;
 };
 
+#define VMXNET3_COAL_STATIC_MAX_DEPTH  128
+#define VMXNET3_COAL_RBC_MIN_RATE  100
+#define VMXNET3_COAL_RBC_MAX_RATE  10
+
+enum Vmxnet3_CoalesceMode {
+   VMXNET3_COALESCE_DISABLED   = 0,
+   VMXNET3_COALESCE_ADAPT  = 1,
+   VMXNET3_COALESCE_STATIC = 2,
+   VMXNET3_COALESCE_RBC= 3
+};
+
+struct Vmxnet3_CoalesceRbc {
+   u32 rbc_rate;
+};
+
+struct Vmxnet3_CoalesceStatic {
+   u32 tx_depth;
+   u32 tx_comp_depth;
+   u32 rx_depth;
+};
+
+struct Vmxnet3_CoalesceScheme {
+   enum Vmxnet3_CoalesceMode   coalMode;
+   union {
+   struct Vmxnet3_CoalesceRbc  coalRbc;
+   struct Vmxnet3_CoalesceStatic   coalStatic;
+   } coalPara;
+};
+
 /* If the command data <= 16 bytes, use the shared memory directly.
  * otherwise, use variable length configuration descriptor.
  */
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index a6dc7c7..86965cd 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -2491,6 +2491,33 @@ vmxnet3_setup_driver_shared(struct vmxnet3_adapter 
*adapter)
/* the rest are already zeroed */
 }
 
+static void
+vmxnet3_init_coalesce(struct vmxnet3_adapter *adapter)
+{
+   struct Vmxnet3_DriverShared *shared = adapter->shared;
+   union Vmxnet3_CmdInfo *cmdInfo = >cu.cmdInfo;
+   unsigned long flags;
+
+   if (!VMXNET3_VERSION_GE_3(adapter))
+   return;
+
+   spin_lock_irqsave(>cmd_lock, flags);
+   cmdInfo->varConf.confVer = 1;
+   cmdInfo->varConf.confLen =
+   cpu_to_le32(sizeof(*adapter->coal_conf));
+   cmdInfo->varConf.confPA  = cpu_to_le64(adapter->coal_conf_pa);
+   spin_unlock_irqrestore(>cmd_lock, flags);
+
+   if (adapter->default_coal_mode) {
+   VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
+  VMXNET3_CMD_GET_COALESCE);
+   } else {
+   VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
+  VMXNET3_CMD_SET_COALESCE);
+   }
+
+   spin_unlock_irqrestore(>cmd_lock, flags);
+}
 
 int
 vmxnet3_activate_dev(struct vmxnet3_adapter *adapter)
@@ -2540,6 +2567,8 @@ vmxnet3_activate_dev(struct vmxnet3_adapter *adapter)
goto activate_err;
}
 
+   vmxnet3_init_coalesce(adapter);
+
for (i = 0; i < adapter->num_rx_queues; i++) {
VMXNET3_WRITE_BAR0_REG(adapter,
VMXNET3_REG_RXPROD + i * VMXNET3_REG_ALIGN,
@@ -3345,6 +3374,22 @@ vmxnet3_probe_device(struct pci_dev *pdev,
goto err_ver;
}
 
+   if (VMXNET3_VERSION_GE_3(adapter)) {
+   adapter->coal_conf =
+   dma_alloc_coherent(>pdev->dev,
+  sizeof(struct Vmxnet3_CoalesceScheme)
+  ,
+  >coal_conf_pa,
+  GFP_KERNEL);
+   if (!adapter->coal_conf) {
+   err = -ENOMEM;
+   goto err_ver;
+   }
+  

[PATCH net-next v2 4/7] Driver: Vmxnet3: Add Receive Data Ring support

2016-05-20 Thread Shrikrishna Khare
Receive Data Ring buffer length is configurable via ethtool -G ethX rx-mini

Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_defs.h|  14 +++-
 drivers/net/vmxnet3/vmxnet3_drv.c | 153 +++---
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  48 ---
 drivers/net/vmxnet3/vmxnet3_int.h |  23 -
 4 files changed, 193 insertions(+), 45 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 701d989..f3b31c2 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -174,6 +174,8 @@ struct Vmxnet3_TxDataDesc {
u8  data[VMXNET3_HDR_COPY_SIZE];
 };
 
+typedef u8 Vmxnet3_RxDataDesc;
+
 #define VMXNET3_TCD_GEN_SHIFT  31
 #define VMXNET3_TCD_GEN_SIZE   1
 #define VMXNET3_TCD_TXIDX_SHIFT0
@@ -382,6 +384,10 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_TXDATA_DESC_SIZE_ALIGN 64
 #define VMXNET3_TXDATA_DESC_SIZE_MASK  (VMXNET3_TXDATA_DESC_SIZE_ALIGN - 1)
 
+/* Rx Data Ring buffer size must be a multiple of 64 */
+#define VMXNET3_RXDATA_DESC_SIZE_ALIGN 64
+#define VMXNET3_RXDATA_DESC_SIZE_MASK  (VMXNET3_RXDATA_DESC_SIZE_ALIGN - 1)
+
 /* Max ring size */
 #define VMXNET3_TX_RING_MAX_SIZE   4096
 #define VMXNET3_TC_RING_MAX_SIZE   4096
@@ -392,6 +398,8 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_TXDATA_DESC_MIN_SIZE 128
 #define VMXNET3_TXDATA_DESC_MAX_SIZE 2048
 
+#define VMXNET3_RXDATA_DESC_MAX_SIZE 2048
+
 /* a list of reasons for queue stop */
 
 enum {
@@ -488,12 +496,14 @@ struct Vmxnet3_RxQueueConf {
__le64  rxRingBasePA[2];
__le64  compRingBasePA;
__le64  ddPA;/* driver data */
-   __le64  reserved;
+   __le64  rxDataRingBasePA;
__le32  rxRingSize[2];   /* # of rx desc */
__le32  compRingSize;/* # of rx comp desc */
__le32  ddLen;   /* size of driver data */
u8  intrIdx;
-   u8  _pad[7];
+   u8  _pad1[1];
+   __le16  rxDataRingDescSize;  /* size of rx data ring buffer */
+   u8  _pad2[4];
 };
 
 
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 58632b1..a6dc7c7 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1284,9 +1284,10 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
 */
break;
}
-   BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2);
+   BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2 &&
+  rcd->rqID != rq->dataRingQid);
idx = rcd->rxdIdx;
-   ring_idx = rcd->rqID < adapter->num_rx_queues ? 0 : 1;
+   ring_idx = VMXNET3_GET_RING_IDX(adapter, rcd->rqID);
ring = rq->rx_ring + ring_idx;
vmxnet3_getRxDesc(rxd, >rx_ring[ring_idx].base[idx].rxd,
  );
@@ -1301,8 +1302,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
}
 
if (rcd->sop) { /* first buf of the pkt */
+   bool rxDataRingUsed;
+   u16 len;
+
BUG_ON(rxd->btype != VMXNET3_RXD_BTYPE_HEAD ||
-  rcd->rqID != rq->qid);
+  (rcd->rqID != rq->qid &&
+   rcd->rqID != rq->dataRingQid));
 
BUG_ON(rbi->buf_type != VMXNET3_RX_BUF_SKB);
BUG_ON(ctx->skb != NULL || rbi->skb == NULL);
@@ -1318,8 +1323,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
 
skip_page_frags = false;
ctx->skb = rbi->skb;
+
+   rxDataRingUsed =
+   VMXNET3_RX_DATA_RING(adapter, rcd->rqID);
+   len = rxDataRingUsed ? rcd->len : rbi->len;
new_skb = netdev_alloc_skb_ip_align(adapter->netdev,
-   rbi->len);
+   len);
if (new_skb == NULL) {
/* Skb allocation failed, do not handover this
 * skb to stack. Reuse it. Drop the existing pkt
@@ -1330,25 +1339,48 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
skip_page_frags = true;
goto rcd_done;
}
-   new_dma_addr = dma_map_single(>pdev->dev,
- new_skb->d

[PATCH net-next v2 7/7] Driver: Vmxnet3: Update to Version 3

2016-05-20 Thread Shrikrishna Khare
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 7 ++-
 drivers/net/vmxnet3/vmxnet3_int.h | 4 ++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 86965cd..71ce4be 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -3346,7 +3346,12 @@ vmxnet3_probe_device(struct pci_dev *pdev,
goto err_alloc_pci;
 
ver = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_VRRS);
-   if (ver & (1 << VMXNET3_REV_2)) {
+   if (ver & (1 << VMXNET3_REV_3)) {
+   VMXNET3_WRITE_BAR1_REG(adapter,
+  VMXNET3_REG_VRRS,
+  1 << VMXNET3_REV_3);
+   adapter->version = VMXNET3_REV_3 + 1;
+   } else if (ver & (1 << VMXNET3_REV_2)) {
VMXNET3_WRITE_BAR1_REG(adapter,
   VMXNET3_REG_VRRS,
   1 << VMXNET3_REV_2);
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h 
b/drivers/net/vmxnet3/vmxnet3_int.h
index 29f087f..63df4f2 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.7.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.8.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM  0x01040700
+#define VMXNET3_DRIVER_VERSION_NUM  0x01040800
 
 #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
-- 
2.8.2



[PATCH net-next v2 7/7] Driver: Vmxnet3: Update to Version 3

2016-05-20 Thread Shrikrishna Khare
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 7 ++-
 drivers/net/vmxnet3/vmxnet3_int.h | 4 ++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 86965cd..71ce4be 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -3346,7 +3346,12 @@ vmxnet3_probe_device(struct pci_dev *pdev,
goto err_alloc_pci;
 
ver = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_VRRS);
-   if (ver & (1 << VMXNET3_REV_2)) {
+   if (ver & (1 << VMXNET3_REV_3)) {
+   VMXNET3_WRITE_BAR1_REG(adapter,
+  VMXNET3_REG_VRRS,
+  1 << VMXNET3_REV_3);
+   adapter->version = VMXNET3_REV_3 + 1;
+   } else if (ver & (1 << VMXNET3_REV_2)) {
VMXNET3_WRITE_BAR1_REG(adapter,
   VMXNET3_REG_VRRS,
   1 << VMXNET3_REV_2);
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h 
b/drivers/net/vmxnet3/vmxnet3_int.h
index 29f087f..63df4f2 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.7.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.8.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM  0x01040700
+#define VMXNET3_DRIVER_VERSION_NUM  0x01040800
 
 #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
-- 
2.8.2



[PATCH net-next v2 0/7] Driver: Vmxnet3: Version 3

2016-05-20 Thread Shrikrishna Khare
This patchset upgrades Vmxnet3 to Version 3.

Changes in v2:
 - Following patch is updated. See that patch for details:
   Driver: Vmxnet3: Add support for get_coalesce, set_coalesce ethtool

Shrikrishna Khare (7):
  Driver: Vmxnet3: Prepare for version 3 changes
  Driver: Vmxnet3: Introduce generic command interface to configure the
device
  Driver: Vmxnet3: Allow variable length Transmit Data ring buffer
  Driver: Vmxnet3: Add Receive Data Ring support
  Driver: Vmxnet3: Add support for get_coalesce, set_coalesce ethtool
operations
  Driver: Vmxnet3: Introduce command to register memory region
  Driver: Vmxnet3: Update to Version 3

 drivers/net/vmxnet3/Makefile  |   4 +-
 drivers/net/vmxnet3/upt1_defs.h   |   4 +-
 drivers/net/vmxnet3/vmxnet3_defs.h| 105 -
 drivers/net/vmxnet3/vmxnet3_drv.c | 286 --
 drivers/net/vmxnet3/vmxnet3_ethtool.c | 217 --
 drivers/net/vmxnet3/vmxnet3_int.h |  54 ++-
 6 files changed, 588 insertions(+), 82 deletions(-)

-- 
2.8.2



[PATCH net-next v2 3/7] Driver: Vmxnet3: Allow variable length Transmit Data ring buffer

2016-05-20 Thread Shrikrishna Khare
Signed-off-by: Sriram Rangarajan <rangaraj...@vmware.com>
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_defs.h| 12 +++-
 drivers/net/vmxnet3/vmxnet3_drv.c | 55 ++-
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  9 +++---
 drivers/net/vmxnet3/vmxnet3_int.h |  7 -
 4 files changed, 64 insertions(+), 19 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index a26a69d..701d989 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -92,6 +92,7 @@ enum {
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
VMXNET3_CMD_GET_CONF_INTR,
VMXNET3_CMD_GET_RESERVED1,
+   VMXNET3_CMD_GET_TXDATA_DESC_SIZE
 };
 
 /*
@@ -377,6 +378,10 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_RING_SIZE_ALIGN 32
 #define VMXNET3_RING_SIZE_MASK  (VMXNET3_RING_SIZE_ALIGN - 1)
 
+/* Tx Data Ring buffer size must be a multiple of 64 */
+#define VMXNET3_TXDATA_DESC_SIZE_ALIGN 64
+#define VMXNET3_TXDATA_DESC_SIZE_MASK  (VMXNET3_TXDATA_DESC_SIZE_ALIGN - 1)
+
 /* Max ring size */
 #define VMXNET3_TX_RING_MAX_SIZE   4096
 #define VMXNET3_TC_RING_MAX_SIZE   4096
@@ -384,6 +389,9 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_RX_RING2_MAX_SIZE  4096
 #define VMXNET3_RC_RING_MAX_SIZE   8192
 
+#define VMXNET3_TXDATA_DESC_MIN_SIZE 128
+#define VMXNET3_TXDATA_DESC_MAX_SIZE 2048
+
 /* a list of reasons for queue stop */
 
 enum {
@@ -470,7 +478,9 @@ struct Vmxnet3_TxQueueConf {
__le32  compRingSize; /* # of comp desc */
__le32  ddLen;/* size of driver data */
u8  intrIdx;
-   u8  _pad[7];
+   u8  _pad1[1];
+   __le16  txDataRingDescSize;
+   u8  _pad2[4];
 };
 
 
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 53434ed..58632b1 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -435,8 +435,8 @@ vmxnet3_tq_destroy(struct vmxnet3_tx_queue *tq,
tq->tx_ring.base = NULL;
}
if (tq->data_ring.base) {
-   dma_free_coherent(>pdev->dev, tq->data_ring.size *
- sizeof(struct Vmxnet3_TxDataDesc),
+   dma_free_coherent(>pdev->dev,
+ tq->data_ring.size * tq->txdata_desc_size,
  tq->data_ring.base, tq->data_ring.basePA);
tq->data_ring.base = NULL;
}
@@ -478,8 +478,8 @@ vmxnet3_tq_init(struct vmxnet3_tx_queue *tq,
tq->tx_ring.next2fill = tq->tx_ring.next2comp = 0;
tq->tx_ring.gen = VMXNET3_INIT_GEN;
 
-   memset(tq->data_ring.base, 0, tq->data_ring.size *
-  sizeof(struct Vmxnet3_TxDataDesc));
+   memset(tq->data_ring.base, 0,
+  tq->data_ring.size * tq->txdata_desc_size);
 
/* reset the tx comp ring contents to 0 and reset comp ring states */
memset(tq->comp_ring.base, 0, tq->comp_ring.size *
@@ -514,10 +514,10 @@ vmxnet3_tq_create(struct vmxnet3_tx_queue *tq,
}
 
tq->data_ring.base = dma_alloc_coherent(>pdev->dev,
-   tq->data_ring.size * sizeof(struct Vmxnet3_TxDataDesc),
+   tq->data_ring.size * tq->txdata_desc_size,
>data_ring.basePA, GFP_KERNEL);
if (!tq->data_ring.base) {
-   netdev_err(adapter->netdev, "failed to allocate data ring\n");
+   netdev_err(adapter->netdev, "failed to allocate tx data 
ring\n");
goto err;
}
 
@@ -689,7 +689,7 @@ vmxnet3_map_pkt(struct sk_buff *skb, struct vmxnet3_tx_ctx 
*ctx,
if (ctx->copy_size) {
ctx->sop_txd->txd.addr = cpu_to_le64(tq->data_ring.basePA +
tq->tx_ring.next2fill *
-   sizeof(struct Vmxnet3_TxDataDesc));
+   tq->txdata_desc_size);
ctx->sop_txd->dword[2] = cpu_to_le32(dw2 | ctx->copy_size);
ctx->sop_txd->dword[3] = 0;
 
@@ -873,8 +873,9 @@ vmxnet3_parse_hdr(struct sk_buff *skb, struct 
vmxnet3_tx_queue *tq,
ctx->eth_ip_hdr_size = 0;
ctx->l4_hdr_size = 0;
/* copy as much as allowed */
-   ctx->copy_size = min((unsigned int)VMXNET3_HDR_COPY_SIZE
-, skb_headlen(skb));
+   ctx->copy_size = min_t(unsigned int,
+  tq->txdata_desc_size,
+  skb_headlen(skb));
}
 

[PATCH net-next v2 0/7] Driver: Vmxnet3: Version 3

2016-05-20 Thread Shrikrishna Khare
This patchset upgrades Vmxnet3 to Version 3.

Changes in v2:
 - Following patch is updated. See that patch for details:
   Driver: Vmxnet3: Add support for get_coalesce, set_coalesce ethtool

Shrikrishna Khare (7):
  Driver: Vmxnet3: Prepare for version 3 changes
  Driver: Vmxnet3: Introduce generic command interface to configure the
device
  Driver: Vmxnet3: Allow variable length Transmit Data ring buffer
  Driver: Vmxnet3: Add Receive Data Ring support
  Driver: Vmxnet3: Add support for get_coalesce, set_coalesce ethtool
operations
  Driver: Vmxnet3: Introduce command to register memory region
  Driver: Vmxnet3: Update to Version 3

 drivers/net/vmxnet3/Makefile  |   4 +-
 drivers/net/vmxnet3/upt1_defs.h   |   4 +-
 drivers/net/vmxnet3/vmxnet3_defs.h| 105 -
 drivers/net/vmxnet3/vmxnet3_drv.c | 286 --
 drivers/net/vmxnet3/vmxnet3_ethtool.c | 217 --
 drivers/net/vmxnet3/vmxnet3_int.h |  54 ++-
 6 files changed, 588 insertions(+), 82 deletions(-)

-- 
2.8.2



[PATCH net-next v2 3/7] Driver: Vmxnet3: Allow variable length Transmit Data ring buffer

2016-05-20 Thread Shrikrishna Khare
Signed-off-by: Sriram Rangarajan 
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_defs.h| 12 +++-
 drivers/net/vmxnet3/vmxnet3_drv.c | 55 ++-
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  9 +++---
 drivers/net/vmxnet3/vmxnet3_int.h |  7 -
 4 files changed, 64 insertions(+), 19 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index a26a69d..701d989 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -92,6 +92,7 @@ enum {
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
VMXNET3_CMD_GET_CONF_INTR,
VMXNET3_CMD_GET_RESERVED1,
+   VMXNET3_CMD_GET_TXDATA_DESC_SIZE
 };
 
 /*
@@ -377,6 +378,10 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_RING_SIZE_ALIGN 32
 #define VMXNET3_RING_SIZE_MASK  (VMXNET3_RING_SIZE_ALIGN - 1)
 
+/* Tx Data Ring buffer size must be a multiple of 64 */
+#define VMXNET3_TXDATA_DESC_SIZE_ALIGN 64
+#define VMXNET3_TXDATA_DESC_SIZE_MASK  (VMXNET3_TXDATA_DESC_SIZE_ALIGN - 1)
+
 /* Max ring size */
 #define VMXNET3_TX_RING_MAX_SIZE   4096
 #define VMXNET3_TC_RING_MAX_SIZE   4096
@@ -384,6 +389,9 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_RX_RING2_MAX_SIZE  4096
 #define VMXNET3_RC_RING_MAX_SIZE   8192
 
+#define VMXNET3_TXDATA_DESC_MIN_SIZE 128
+#define VMXNET3_TXDATA_DESC_MAX_SIZE 2048
+
 /* a list of reasons for queue stop */
 
 enum {
@@ -470,7 +478,9 @@ struct Vmxnet3_TxQueueConf {
__le32  compRingSize; /* # of comp desc */
__le32  ddLen;/* size of driver data */
u8  intrIdx;
-   u8  _pad[7];
+   u8  _pad1[1];
+   __le16  txDataRingDescSize;
+   u8  _pad2[4];
 };
 
 
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 53434ed..58632b1 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -435,8 +435,8 @@ vmxnet3_tq_destroy(struct vmxnet3_tx_queue *tq,
tq->tx_ring.base = NULL;
}
if (tq->data_ring.base) {
-   dma_free_coherent(>pdev->dev, tq->data_ring.size *
- sizeof(struct Vmxnet3_TxDataDesc),
+   dma_free_coherent(>pdev->dev,
+ tq->data_ring.size * tq->txdata_desc_size,
  tq->data_ring.base, tq->data_ring.basePA);
tq->data_ring.base = NULL;
}
@@ -478,8 +478,8 @@ vmxnet3_tq_init(struct vmxnet3_tx_queue *tq,
tq->tx_ring.next2fill = tq->tx_ring.next2comp = 0;
tq->tx_ring.gen = VMXNET3_INIT_GEN;
 
-   memset(tq->data_ring.base, 0, tq->data_ring.size *
-  sizeof(struct Vmxnet3_TxDataDesc));
+   memset(tq->data_ring.base, 0,
+  tq->data_ring.size * tq->txdata_desc_size);
 
/* reset the tx comp ring contents to 0 and reset comp ring states */
memset(tq->comp_ring.base, 0, tq->comp_ring.size *
@@ -514,10 +514,10 @@ vmxnet3_tq_create(struct vmxnet3_tx_queue *tq,
}
 
tq->data_ring.base = dma_alloc_coherent(>pdev->dev,
-   tq->data_ring.size * sizeof(struct Vmxnet3_TxDataDesc),
+   tq->data_ring.size * tq->txdata_desc_size,
>data_ring.basePA, GFP_KERNEL);
if (!tq->data_ring.base) {
-   netdev_err(adapter->netdev, "failed to allocate data ring\n");
+   netdev_err(adapter->netdev, "failed to allocate tx data 
ring\n");
goto err;
}
 
@@ -689,7 +689,7 @@ vmxnet3_map_pkt(struct sk_buff *skb, struct vmxnet3_tx_ctx 
*ctx,
if (ctx->copy_size) {
ctx->sop_txd->txd.addr = cpu_to_le64(tq->data_ring.basePA +
tq->tx_ring.next2fill *
-   sizeof(struct Vmxnet3_TxDataDesc));
+   tq->txdata_desc_size);
ctx->sop_txd->dword[2] = cpu_to_le32(dw2 | ctx->copy_size);
ctx->sop_txd->dword[3] = 0;
 
@@ -873,8 +873,9 @@ vmxnet3_parse_hdr(struct sk_buff *skb, struct 
vmxnet3_tx_queue *tq,
ctx->eth_ip_hdr_size = 0;
ctx->l4_hdr_size = 0;
/* copy as much as allowed */
-   ctx->copy_size = min((unsigned int)VMXNET3_HDR_COPY_SIZE
-, skb_headlen(skb));
+   ctx->copy_size = min_t(unsigned int,
+  tq->txdata_desc_size,
+  skb_headlen(skb));
}
 
if (skb->len <= VMXNET3_HDR_COPY_SIZE)

Re: [PATCH net-next 5/7] Driver: Vmxnet3: Add support for get_coalesce, set_coalesce ethtool operations

2016-05-08 Thread Shrikrishna Khare


On Sat, 7 May 2016, Ben Hutchings wrote:

> On Fri, 2016-05-06 at 16:12 -0700, Shrikrishna Khare wrote:
> [...]
> > +static int
> > +vmxnet3_set_coalesce(struct net_device *netdev, struct ethtool_coalesce 
> > *ec)
> > +{
> [...]
> > +   switch (ec->rx_coalesce_usecs) {
> > +   case VMXNET3_COALESCE_DEFAULT:
> > +   case VMXNET3_COALESCE_DISABLED:
> > +   case VMXNET3_COALESCE_ADAPT:
> > +   if (ec->tx_max_coalesced_frames ||
> > +   ec->tx_max_coalesced_frames_irq ||
> > +   ec->rx_max_coalesced_frames_irq) {
> > +   return -EINVAL;
> > +   }
> > +   memset(adapter->coal_conf, 0, sizeof(*adapter->coal_conf));
> > +   adapter->coal_conf->coalMode = ec->rx_coalesce_usecs;
> > +   break;
> > +   case VMXNET3_COALESCE_STATIC:
> [...]
> 
> I don't want to see drivers introducing magic values for fields that
> are denominated in microseconds (especially not for 0, which is the
> correct way to specify 'no coalescing').  If the current
> ethtool_coalesce structure is inadequate, propose an extension.

For vmxnet3, we need an ethtool mechanism to indicate coalescing mode to 
the device.

Would a patch that maps 0 to 'no coalescing' be acceptable? That is:

rx-usecs = 0 -> coalescing disabled.
rx-usecs = 1 -> default (chosen by the device).
rx-usecs = 2 -> adaptive coalescing.
rx-usecs = 3 -> static coalescing.
all other rx-usecs values -> rate based coalescing where rx-usecs denotes 
rate.

Alternatively: I don't think new members could be added to struct 
ethtool_coalesce without breaking compatibility. Thus, I could extend 
coalescing as follows:
- new struct ethtool_coalesce_v2 with coalesce_mode (along with all the 
members of struct ethtool_coalesce).
- introduce new ETHTOOL_{G,S}COALESCE_V2 commands.
- extend userspace ethtool to invoke new commands.

Could you please advice?

Thanks,
Shri

Re: [PATCH net-next 5/7] Driver: Vmxnet3: Add support for get_coalesce, set_coalesce ethtool operations

2016-05-08 Thread Shrikrishna Khare


On Sat, 7 May 2016, Ben Hutchings wrote:

> On Fri, 2016-05-06 at 16:12 -0700, Shrikrishna Khare wrote:
> [...]
> > +static int
> > +vmxnet3_set_coalesce(struct net_device *netdev, struct ethtool_coalesce 
> > *ec)
> > +{
> [...]
> > +   switch (ec->rx_coalesce_usecs) {
> > +   case VMXNET3_COALESCE_DEFAULT:
> > +   case VMXNET3_COALESCE_DISABLED:
> > +   case VMXNET3_COALESCE_ADAPT:
> > +   if (ec->tx_max_coalesced_frames ||
> > +   ec->tx_max_coalesced_frames_irq ||
> > +   ec->rx_max_coalesced_frames_irq) {
> > +   return -EINVAL;
> > +   }
> > +   memset(adapter->coal_conf, 0, sizeof(*adapter->coal_conf));
> > +   adapter->coal_conf->coalMode = ec->rx_coalesce_usecs;
> > +   break;
> > +   case VMXNET3_COALESCE_STATIC:
> [...]
> 
> I don't want to see drivers introducing magic values for fields that
> are denominated in microseconds (especially not for 0, which is the
> correct way to specify 'no coalescing').  If the current
> ethtool_coalesce structure is inadequate, propose an extension.

For vmxnet3, we need an ethtool mechanism to indicate coalescing mode to 
the device.

Would a patch that maps 0 to 'no coalescing' be acceptable? That is:

rx-usecs = 0 -> coalescing disabled.
rx-usecs = 1 -> default (chosen by the device).
rx-usecs = 2 -> adaptive coalescing.
rx-usecs = 3 -> static coalescing.
all other rx-usecs values -> rate based coalescing where rx-usecs denotes 
rate.

Alternatively: I don't think new members could be added to struct 
ethtool_coalesce without breaking compatibility. Thus, I could extend 
coalescing as follows:
- new struct ethtool_coalesce_v2 with coalesce_mode (along with all the 
members of struct ethtool_coalesce).
- introduce new ETHTOOL_{G,S}COALESCE_V2 commands.
- extend userspace ethtool to invoke new commands.

Could you please advice?

Thanks,
Shri

[PATCH net-next 3/7] Driver: Vmxnet3: Allow variable length Transmit Data ring buffer

2016-05-06 Thread Shrikrishna Khare
Signed-off-by: Sriram Rangarajan <rangaraj...@vmware.com>
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_defs.h| 12 +++-
 drivers/net/vmxnet3/vmxnet3_drv.c | 55 ++-
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  9 +++---
 drivers/net/vmxnet3/vmxnet3_int.h |  7 -
 4 files changed, 64 insertions(+), 19 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index a26a69d..701d989 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -92,6 +92,7 @@ enum {
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
VMXNET3_CMD_GET_CONF_INTR,
VMXNET3_CMD_GET_RESERVED1,
+   VMXNET3_CMD_GET_TXDATA_DESC_SIZE
 };
 
 /*
@@ -377,6 +378,10 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_RING_SIZE_ALIGN 32
 #define VMXNET3_RING_SIZE_MASK  (VMXNET3_RING_SIZE_ALIGN - 1)
 
+/* Tx Data Ring buffer size must be a multiple of 64 */
+#define VMXNET3_TXDATA_DESC_SIZE_ALIGN 64
+#define VMXNET3_TXDATA_DESC_SIZE_MASK  (VMXNET3_TXDATA_DESC_SIZE_ALIGN - 1)
+
 /* Max ring size */
 #define VMXNET3_TX_RING_MAX_SIZE   4096
 #define VMXNET3_TC_RING_MAX_SIZE   4096
@@ -384,6 +389,9 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_RX_RING2_MAX_SIZE  4096
 #define VMXNET3_RC_RING_MAX_SIZE   8192
 
+#define VMXNET3_TXDATA_DESC_MIN_SIZE 128
+#define VMXNET3_TXDATA_DESC_MAX_SIZE 2048
+
 /* a list of reasons for queue stop */
 
 enum {
@@ -470,7 +478,9 @@ struct Vmxnet3_TxQueueConf {
__le32  compRingSize; /* # of comp desc */
__le32  ddLen;/* size of driver data */
u8  intrIdx;
-   u8  _pad[7];
+   u8  _pad1[1];
+   __le16  txDataRingDescSize;
+   u8  _pad2[4];
 };
 
 
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 53434ed..58632b1 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -435,8 +435,8 @@ vmxnet3_tq_destroy(struct vmxnet3_tx_queue *tq,
tq->tx_ring.base = NULL;
}
if (tq->data_ring.base) {
-   dma_free_coherent(>pdev->dev, tq->data_ring.size *
- sizeof(struct Vmxnet3_TxDataDesc),
+   dma_free_coherent(>pdev->dev,
+ tq->data_ring.size * tq->txdata_desc_size,
  tq->data_ring.base, tq->data_ring.basePA);
tq->data_ring.base = NULL;
}
@@ -478,8 +478,8 @@ vmxnet3_tq_init(struct vmxnet3_tx_queue *tq,
tq->tx_ring.next2fill = tq->tx_ring.next2comp = 0;
tq->tx_ring.gen = VMXNET3_INIT_GEN;
 
-   memset(tq->data_ring.base, 0, tq->data_ring.size *
-  sizeof(struct Vmxnet3_TxDataDesc));
+   memset(tq->data_ring.base, 0,
+  tq->data_ring.size * tq->txdata_desc_size);
 
/* reset the tx comp ring contents to 0 and reset comp ring states */
memset(tq->comp_ring.base, 0, tq->comp_ring.size *
@@ -514,10 +514,10 @@ vmxnet3_tq_create(struct vmxnet3_tx_queue *tq,
}
 
tq->data_ring.base = dma_alloc_coherent(>pdev->dev,
-   tq->data_ring.size * sizeof(struct Vmxnet3_TxDataDesc),
+   tq->data_ring.size * tq->txdata_desc_size,
>data_ring.basePA, GFP_KERNEL);
if (!tq->data_ring.base) {
-   netdev_err(adapter->netdev, "failed to allocate data ring\n");
+   netdev_err(adapter->netdev, "failed to allocate tx data 
ring\n");
goto err;
}
 
@@ -689,7 +689,7 @@ vmxnet3_map_pkt(struct sk_buff *skb, struct vmxnet3_tx_ctx 
*ctx,
if (ctx->copy_size) {
ctx->sop_txd->txd.addr = cpu_to_le64(tq->data_ring.basePA +
tq->tx_ring.next2fill *
-   sizeof(struct Vmxnet3_TxDataDesc));
+   tq->txdata_desc_size);
ctx->sop_txd->dword[2] = cpu_to_le32(dw2 | ctx->copy_size);
ctx->sop_txd->dword[3] = 0;
 
@@ -873,8 +873,9 @@ vmxnet3_parse_hdr(struct sk_buff *skb, struct 
vmxnet3_tx_queue *tq,
ctx->eth_ip_hdr_size = 0;
ctx->l4_hdr_size = 0;
/* copy as much as allowed */
-   ctx->copy_size = min((unsigned int)VMXNET3_HDR_COPY_SIZE
-, skb_headlen(skb));
+   ctx->copy_size = min_t(unsigned int,
+  tq->txdata_desc_size,
+  skb_headlen(skb));
}
 

[PATCH net-next 3/7] Driver: Vmxnet3: Allow variable length Transmit Data ring buffer

2016-05-06 Thread Shrikrishna Khare
Signed-off-by: Sriram Rangarajan 
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_defs.h| 12 +++-
 drivers/net/vmxnet3/vmxnet3_drv.c | 55 ++-
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  9 +++---
 drivers/net/vmxnet3/vmxnet3_int.h |  7 -
 4 files changed, 64 insertions(+), 19 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index a26a69d..701d989 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -92,6 +92,7 @@ enum {
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
VMXNET3_CMD_GET_CONF_INTR,
VMXNET3_CMD_GET_RESERVED1,
+   VMXNET3_CMD_GET_TXDATA_DESC_SIZE
 };
 
 /*
@@ -377,6 +378,10 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_RING_SIZE_ALIGN 32
 #define VMXNET3_RING_SIZE_MASK  (VMXNET3_RING_SIZE_ALIGN - 1)
 
+/* Tx Data Ring buffer size must be a multiple of 64 */
+#define VMXNET3_TXDATA_DESC_SIZE_ALIGN 64
+#define VMXNET3_TXDATA_DESC_SIZE_MASK  (VMXNET3_TXDATA_DESC_SIZE_ALIGN - 1)
+
 /* Max ring size */
 #define VMXNET3_TX_RING_MAX_SIZE   4096
 #define VMXNET3_TC_RING_MAX_SIZE   4096
@@ -384,6 +389,9 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_RX_RING2_MAX_SIZE  4096
 #define VMXNET3_RC_RING_MAX_SIZE   8192
 
+#define VMXNET3_TXDATA_DESC_MIN_SIZE 128
+#define VMXNET3_TXDATA_DESC_MAX_SIZE 2048
+
 /* a list of reasons for queue stop */
 
 enum {
@@ -470,7 +478,9 @@ struct Vmxnet3_TxQueueConf {
__le32  compRingSize; /* # of comp desc */
__le32  ddLen;/* size of driver data */
u8  intrIdx;
-   u8  _pad[7];
+   u8  _pad1[1];
+   __le16  txDataRingDescSize;
+   u8  _pad2[4];
 };
 
 
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 53434ed..58632b1 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -435,8 +435,8 @@ vmxnet3_tq_destroy(struct vmxnet3_tx_queue *tq,
tq->tx_ring.base = NULL;
}
if (tq->data_ring.base) {
-   dma_free_coherent(>pdev->dev, tq->data_ring.size *
- sizeof(struct Vmxnet3_TxDataDesc),
+   dma_free_coherent(>pdev->dev,
+ tq->data_ring.size * tq->txdata_desc_size,
  tq->data_ring.base, tq->data_ring.basePA);
tq->data_ring.base = NULL;
}
@@ -478,8 +478,8 @@ vmxnet3_tq_init(struct vmxnet3_tx_queue *tq,
tq->tx_ring.next2fill = tq->tx_ring.next2comp = 0;
tq->tx_ring.gen = VMXNET3_INIT_GEN;
 
-   memset(tq->data_ring.base, 0, tq->data_ring.size *
-  sizeof(struct Vmxnet3_TxDataDesc));
+   memset(tq->data_ring.base, 0,
+  tq->data_ring.size * tq->txdata_desc_size);
 
/* reset the tx comp ring contents to 0 and reset comp ring states */
memset(tq->comp_ring.base, 0, tq->comp_ring.size *
@@ -514,10 +514,10 @@ vmxnet3_tq_create(struct vmxnet3_tx_queue *tq,
}
 
tq->data_ring.base = dma_alloc_coherent(>pdev->dev,
-   tq->data_ring.size * sizeof(struct Vmxnet3_TxDataDesc),
+   tq->data_ring.size * tq->txdata_desc_size,
>data_ring.basePA, GFP_KERNEL);
if (!tq->data_ring.base) {
-   netdev_err(adapter->netdev, "failed to allocate data ring\n");
+   netdev_err(adapter->netdev, "failed to allocate tx data 
ring\n");
goto err;
}
 
@@ -689,7 +689,7 @@ vmxnet3_map_pkt(struct sk_buff *skb, struct vmxnet3_tx_ctx 
*ctx,
if (ctx->copy_size) {
ctx->sop_txd->txd.addr = cpu_to_le64(tq->data_ring.basePA +
tq->tx_ring.next2fill *
-   sizeof(struct Vmxnet3_TxDataDesc));
+   tq->txdata_desc_size);
ctx->sop_txd->dword[2] = cpu_to_le32(dw2 | ctx->copy_size);
ctx->sop_txd->dword[3] = 0;
 
@@ -873,8 +873,9 @@ vmxnet3_parse_hdr(struct sk_buff *skb, struct 
vmxnet3_tx_queue *tq,
ctx->eth_ip_hdr_size = 0;
ctx->l4_hdr_size = 0;
/* copy as much as allowed */
-   ctx->copy_size = min((unsigned int)VMXNET3_HDR_COPY_SIZE
-, skb_headlen(skb));
+   ctx->copy_size = min_t(unsigned int,
+  tq->txdata_desc_size,
+  skb_headlen(skb));
}
 
if (skb->len <= VMXNET3_HDR_COPY_SIZE)

[PATCH net-next 1/7] Driver: Vmxnet3: Prepare for version 3 changes

2016-05-06 Thread Shrikrishna Khare
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/Makefile  |  4 ++--
 drivers/net/vmxnet3/upt1_defs.h   |  4 ++--
 drivers/net/vmxnet3/vmxnet3_defs.h|  9 ++---
 drivers/net/vmxnet3/vmxnet3_drv.c | 22 +-
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  4 ++--
 drivers/net/vmxnet3/vmxnet3_int.h | 13 +++--
 6 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/drivers/net/vmxnet3/Makefile b/drivers/net/vmxnet3/Makefile
index 880f509..8cdbb63 100644
--- a/drivers/net/vmxnet3/Makefile
+++ b/drivers/net/vmxnet3/Makefile
@@ -2,7 +2,7 @@
 #
 # Linux driver for VMware's vmxnet3 ethernet NIC.
 #
-# Copyright (C) 2007-2009, VMware, Inc. All Rights Reserved.
+# Copyright (C) 2007-2016, VMware, Inc. All Rights Reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by the
@@ -21,7 +21,7 @@
 # The full GNU General Public License is included in this distribution in
 # the file called "COPYING".
 #
-# Maintained by: Shreyas Bhatewara <pv-driv...@vmware.com>
+# Maintained by: pv-driv...@vmware.com
 #
 #
 

diff --git a/drivers/net/vmxnet3/upt1_defs.h b/drivers/net/vmxnet3/upt1_defs.h
index 969c751..db9f1fd 100644
--- a/drivers/net/vmxnet3/upt1_defs.h
+++ b/drivers/net/vmxnet3/upt1_defs.h
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara <pv-driv...@vmware.com>
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 72ba8ae..8345e0c 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2015, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara <pv-driv...@vmware.com>
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
@@ -76,7 +76,9 @@ enum {
VMXNET3_CMD_UPDATE_IML,
VMXNET3_CMD_UPDATE_PMCFG,
VMXNET3_CMD_UPDATE_FEATURE,
+   VMXNET3_CMD_RESERVED1,
VMXNET3_CMD_LOAD_PLUGIN,
+   VMXNET3_CMD_RESERVED2,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -87,7 +89,8 @@ enum {
VMXNET3_CMD_GET_DID_LO,
VMXNET3_CMD_GET_DID_HI,
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
-   VMXNET3_CMD_GET_CONF_INTR
+   VMXNET3_CMD_GET_CONF_INTR,
+   VMXNET3_CMD_GET_RESERVED1,
 };
 
 /*
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index db8022a..53434ed 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara <pv-driv...@vmware.com>
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
@@ -1363,7 +1363,7 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
rbi->dma_addr = new_dma_addr;
rxd->addr = cpu_to_le64(rbi->dma_addr);
rxd->len = rbi->len;
-   if (adapter->version == 2 &&
+   if (VMXNET3_VERSION_GE_2(adapter) &&
rcd->type == VMXNET3_CDTYPE_RXCOMP_LRO) {
struct Vmxnet3_RxCompDescExt *rcdlro;
rcdlro = (struct Vmxnet3_RxCompDescExt *)rcd;
@@ -3200,12 +3200,16 @@ vmxnet3_probe_device(struct pci_dev *pdev,
  

[PATCH net-next 1/7] Driver: Vmxnet3: Prepare for version 3 changes

2016-05-06 Thread Shrikrishna Khare
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/Makefile  |  4 ++--
 drivers/net/vmxnet3/upt1_defs.h   |  4 ++--
 drivers/net/vmxnet3/vmxnet3_defs.h|  9 ++---
 drivers/net/vmxnet3/vmxnet3_drv.c | 22 +-
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  4 ++--
 drivers/net/vmxnet3/vmxnet3_int.h | 13 +++--
 6 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/drivers/net/vmxnet3/Makefile b/drivers/net/vmxnet3/Makefile
index 880f509..8cdbb63 100644
--- a/drivers/net/vmxnet3/Makefile
+++ b/drivers/net/vmxnet3/Makefile
@@ -2,7 +2,7 @@
 #
 # Linux driver for VMware's vmxnet3 ethernet NIC.
 #
-# Copyright (C) 2007-2009, VMware, Inc. All Rights Reserved.
+# Copyright (C) 2007-2016, VMware, Inc. All Rights Reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by the
@@ -21,7 +21,7 @@
 # The full GNU General Public License is included in this distribution in
 # the file called "COPYING".
 #
-# Maintained by: Shreyas Bhatewara 
+# Maintained by: pv-driv...@vmware.com
 #
 #
 

diff --git a/drivers/net/vmxnet3/upt1_defs.h b/drivers/net/vmxnet3/upt1_defs.h
index 969c751..db9f1fd 100644
--- a/drivers/net/vmxnet3/upt1_defs.h
+++ b/drivers/net/vmxnet3/upt1_defs.h
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara 
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 72ba8ae..8345e0c 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2015, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara 
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
@@ -76,7 +76,9 @@ enum {
VMXNET3_CMD_UPDATE_IML,
VMXNET3_CMD_UPDATE_PMCFG,
VMXNET3_CMD_UPDATE_FEATURE,
+   VMXNET3_CMD_RESERVED1,
VMXNET3_CMD_LOAD_PLUGIN,
+   VMXNET3_CMD_RESERVED2,
 
VMXNET3_CMD_FIRST_GET = 0xF00D,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -87,7 +89,8 @@ enum {
VMXNET3_CMD_GET_DID_LO,
VMXNET3_CMD_GET_DID_HI,
VMXNET3_CMD_GET_DEV_EXTRA_INFO,
-   VMXNET3_CMD_GET_CONF_INTR
+   VMXNET3_CMD_GET_CONF_INTR,
+   VMXNET3_CMD_GET_RESERVED1,
 };
 
 /*
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index db8022a..53434ed 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1,7 +1,7 @@
 /*
  * Linux driver for VMware's vmxnet3 ethernet NIC.
  *
- * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Maintained by: Shreyas Bhatewara 
+ * Maintained by: pv-driv...@vmware.com
  *
  */
 
@@ -1363,7 +1363,7 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
rbi->dma_addr = new_dma_addr;
rxd->addr = cpu_to_le64(rbi->dma_addr);
rxd->len = rbi->len;
-   if (adapter->version == 2 &&
+   if (VMXNET3_VERSION_GE_2(adapter) &&
rcd->type == VMXNET3_CDTYPE_RXCOMP_LRO) {
struct Vmxnet3_RxCompDescExt *rcdlro;
rcdlro = (struct Vmxnet3_RxCompDescExt *)rcd;
@@ -3200,12 +3200,16 @@ vmxnet3_probe_device(struct pci_dev *pdev,
goto err_alloc_pci;
 
ver = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_VRRS);
-   if (ver & 2) {
-   VMXNET3_WRITE_BAR1_REG(adapter, V

[PATCH net-next 7/7] Driver: Vmxnet3: Update to Version 3

2016-05-06 Thread Shrikrishna Khare
Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 7 ++-
 drivers/net/vmxnet3/vmxnet3_int.h | 4 ++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index fe1c6ad..5f98fb2 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -3339,7 +3339,12 @@ vmxnet3_probe_device(struct pci_dev *pdev,
goto err_alloc_pci;
 
ver = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_VRRS);
-   if (ver & (1 << VMXNET3_REV_2)) {
+   if (ver & (1 << VMXNET3_REV_3)) {
+   VMXNET3_WRITE_BAR1_REG(adapter,
+  VMXNET3_REG_VRRS,
+  1 << VMXNET3_REV_3);
+   adapter->version = VMXNET3_REV_3 + 1;
+   } else if (ver & (1 << VMXNET3_REV_2)) {
VMXNET3_WRITE_BAR1_REG(adapter,
   VMXNET3_REG_VRRS,
   1 << VMXNET3_REV_2);
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h 
b/drivers/net/vmxnet3/vmxnet3_int.h
index 8cd1851..cc67837 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.7.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.8.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM  0x01040700
+#define VMXNET3_DRIVER_VERSION_NUM  0x01040800
 
 #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
-- 
1.9.1



[PATCH net-next 7/7] Driver: Vmxnet3: Update to Version 3

2016-05-06 Thread Shrikrishna Khare
Signed-off-by: Shrikrishna Khare 
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 7 ++-
 drivers/net/vmxnet3/vmxnet3_int.h | 4 ++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index fe1c6ad..5f98fb2 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -3339,7 +3339,12 @@ vmxnet3_probe_device(struct pci_dev *pdev,
goto err_alloc_pci;
 
ver = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_VRRS);
-   if (ver & (1 << VMXNET3_REV_2)) {
+   if (ver & (1 << VMXNET3_REV_3)) {
+   VMXNET3_WRITE_BAR1_REG(adapter,
+  VMXNET3_REG_VRRS,
+  1 << VMXNET3_REV_3);
+   adapter->version = VMXNET3_REV_3 + 1;
+   } else if (ver & (1 << VMXNET3_REV_2)) {
VMXNET3_WRITE_BAR1_REG(adapter,
   VMXNET3_REG_VRRS,
   1 << VMXNET3_REV_2);
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h 
b/drivers/net/vmxnet3/vmxnet3_int.h
index 8cd1851..cc67837 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.7.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.8.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM  0x01040700
+#define VMXNET3_DRIVER_VERSION_NUM  0x01040800
 
 #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
-- 
1.9.1



[PATCH net-next 4/7] Driver: Vmxnet3: Add Receive Data Ring support

2016-05-06 Thread Shrikrishna Khare
Receive Data Ring buffer length is configurable via ethtool -G ethX rx-mini

Signed-off-by: Shrikrishna Khare <skh...@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_defs.h|  14 +++-
 drivers/net/vmxnet3/vmxnet3_drv.c | 153 +++---
 drivers/net/vmxnet3/vmxnet3_ethtool.c |  48 ---
 drivers/net/vmxnet3/vmxnet3_int.h |  23 -
 4 files changed, 193 insertions(+), 45 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h 
b/drivers/net/vmxnet3/vmxnet3_defs.h
index 701d989..f3b31c2 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -174,6 +174,8 @@ struct Vmxnet3_TxDataDesc {
u8  data[VMXNET3_HDR_COPY_SIZE];
 };
 
+typedef u8 Vmxnet3_RxDataDesc;
+
 #define VMXNET3_TCD_GEN_SHIFT  31
 #define VMXNET3_TCD_GEN_SIZE   1
 #define VMXNET3_TCD_TXIDX_SHIFT0
@@ -382,6 +384,10 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_TXDATA_DESC_SIZE_ALIGN 64
 #define VMXNET3_TXDATA_DESC_SIZE_MASK  (VMXNET3_TXDATA_DESC_SIZE_ALIGN - 1)
 
+/* Rx Data Ring buffer size must be a multiple of 64 */
+#define VMXNET3_RXDATA_DESC_SIZE_ALIGN 64
+#define VMXNET3_RXDATA_DESC_SIZE_MASK  (VMXNET3_RXDATA_DESC_SIZE_ALIGN - 1)
+
 /* Max ring size */
 #define VMXNET3_TX_RING_MAX_SIZE   4096
 #define VMXNET3_TC_RING_MAX_SIZE   4096
@@ -392,6 +398,8 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_TXDATA_DESC_MIN_SIZE 128
 #define VMXNET3_TXDATA_DESC_MAX_SIZE 2048
 
+#define VMXNET3_RXDATA_DESC_MAX_SIZE 2048
+
 /* a list of reasons for queue stop */
 
 enum {
@@ -488,12 +496,14 @@ struct Vmxnet3_RxQueueConf {
__le64  rxRingBasePA[2];
__le64  compRingBasePA;
__le64  ddPA;/* driver data */
-   __le64  reserved;
+   __le64  rxDataRingBasePA;
__le32  rxRingSize[2];   /* # of rx desc */
__le32  compRingSize;/* # of rx comp desc */
__le32  ddLen;   /* size of driver data */
u8  intrIdx;
-   u8  _pad[7];
+   u8  _pad1[1];
+   __le16  rxDataRingDescSize;  /* size of rx data ring buffer */
+   u8  _pad2[4];
 };
 
 
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 58632b1..a6dc7c7 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1284,9 +1284,10 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
 */
break;
}
-   BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2);
+   BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2 &&
+  rcd->rqID != rq->dataRingQid);
idx = rcd->rxdIdx;
-   ring_idx = rcd->rqID < adapter->num_rx_queues ? 0 : 1;
+   ring_idx = VMXNET3_GET_RING_IDX(adapter, rcd->rqID);
ring = rq->rx_ring + ring_idx;
vmxnet3_getRxDesc(rxd, >rx_ring[ring_idx].base[idx].rxd,
  );
@@ -1301,8 +1302,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
}
 
if (rcd->sop) { /* first buf of the pkt */
+   bool rxDataRingUsed;
+   u16 len;
+
BUG_ON(rxd->btype != VMXNET3_RXD_BTYPE_HEAD ||
-  rcd->rqID != rq->qid);
+  (rcd->rqID != rq->qid &&
+   rcd->rqID != rq->dataRingQid));
 
BUG_ON(rbi->buf_type != VMXNET3_RX_BUF_SKB);
BUG_ON(ctx->skb != NULL || rbi->skb == NULL);
@@ -1318,8 +1323,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
 
skip_page_frags = false;
ctx->skb = rbi->skb;
+
+   rxDataRingUsed =
+   VMXNET3_RX_DATA_RING(adapter, rcd->rqID);
+   len = rxDataRingUsed ? rcd->len : rbi->len;
new_skb = netdev_alloc_skb_ip_align(adapter->netdev,
-   rbi->len);
+   len);
if (new_skb == NULL) {
/* Skb allocation failed, do not handover this
 * skb to stack. Reuse it. Drop the existing pkt
@@ -1330,25 +1339,48 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
skip_page_frags = true;
goto rcd_done;
}
-   new_dma_addr = dma_map_single(>pdev->dev,
- new_skb

[PATCH net-next 0/7] Driver: Vmxnet3: Version 3

2016-05-06 Thread Shrikrishna Khare
This patchset upgrades Vmxnet3 to Version 3.


Shrikrishna Khare (7):
  Driver: Vmxnet3: Prepare for version 3 changes
  Driver: Vmxnet3: Introduce generic command interface to configure the
device
  Driver: Vmxnet3: Allow variable length Transmit Data ring buffer
  Driver: Vmxnet3: Add Receive Data Ring support
  Driver: Vmxnet3: Add support for get_coalesce, set_coalesce ethtool
operations
  Driver: Vmxnet3: Introduce command to register memory region
  Driver: Vmxnet3: Update to Version 3

 drivers/net/vmxnet3/Makefile  |   4 +-
 drivers/net/vmxnet3/upt1_defs.h   |   4 +-
 drivers/net/vmxnet3/vmxnet3_defs.h| 106 -
 drivers/net/vmxnet3/vmxnet3_drv.c | 278 +++---
 drivers/net/vmxnet3/vmxnet3_ethtool.c | 192 +--
 drivers/net/vmxnet3/vmxnet3_int.h |  50 +-
 6 files changed, 551 insertions(+), 83 deletions(-)

-- 
1.9.1



  1   2   >