[dpdk-dev] [PATCH v2] maintainers: update email address for vhost and null PMD

2016-07-28 Thread Tetsuya Mukawa
Signed-off-by: Tetsuya Mukawa 
---
 MAINTAINERS | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index d099131..6536c6b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -373,7 +373,7 @@ F: drivers/net/vmxnet3/
 F: doc/guides/nics/vmxnet3.rst

 Vhost PMD
-M: Tetsuya Mukawa 
+M: Tetsuya Mukawa 
 M: Yuanhan Liu 
 T: git://dpdk.org/next/dpdk-next-virtio
 F: drivers/net/vhost/
@@ -392,7 +392,7 @@ F: app/test/test_pmd_ring.c
 F: app/test/test_pmd_ring_perf.c

 Null Networking PMD
-M: Tetsuya Mukawa 
+M: Tetsuya Mukawa 
 F: drivers/net/null/


-- 
2.7.4



[dpdk-dev] [PATCH] maintainers: claim responsibility for vhost and null PMD

2016-07-28 Thread Tetsuya Mukawa
Hi Yuanhan,

Okay, thanks.
I will submit again.

Thanks,
Tetsuya

On 2016/07/28 14:43, Yuanhan Liu wrote:
> You are already the maintainer of the both :)
> 
> I think a title like "update email address" would be more appropriate.
> 
>   -yliu
> 
> On Thu, Jul 28, 2016 at 02:27:00PM +0900, Tetsuya Mukawa wrote:
>> Signed-off-by: Tetsuya Mukawa 
>> ---
>>  MAINTAINERS | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index d099131..6536c6b 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -373,7 +373,7 @@ F: drivers/net/vmxnet3/
>>  F: doc/guides/nics/vmxnet3.rst
>>  
>>  Vhost PMD
>> -M: Tetsuya Mukawa 
>> +M: Tetsuya Mukawa 
>>  M: Yuanhan Liu 
>>  T: git://dpdk.org/next/dpdk-next-virtio
>>  F: drivers/net/vhost/
>> @@ -392,7 +392,7 @@ F: app/test/test_pmd_ring.c
>>  F: app/test/test_pmd_ring_perf.c
>>  
>>  Null Networking PMD
>> -M: Tetsuya Mukawa 
>> +M: Tetsuya Mukawa 
>>  F: drivers/net/null/
>>  
>>  
>> -- 
>> 2.7.4



[dpdk-dev] [PATCH] maintainers: claim responsibility for vhost and null PMD

2016-07-28 Thread Tetsuya Mukawa
I left my current company soon. Until my next email address is assigned,
here is my email address.

Regards,
Tetsuya

On 2016/07/28 14:27, Tetsuya Mukawa wrote:
> Signed-off-by: Tetsuya Mukawa 
> ---
>  MAINTAINERS | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index d099131..6536c6b 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -373,7 +373,7 @@ F: drivers/net/vmxnet3/
>  F: doc/guides/nics/vmxnet3.rst
>  
>  Vhost PMD
> -M: Tetsuya Mukawa 
> +M: Tetsuya Mukawa 
>  M: Yuanhan Liu 
>  T: git://dpdk.org/next/dpdk-next-virtio
>  F: drivers/net/vhost/
> @@ -392,7 +392,7 @@ F: app/test/test_pmd_ring.c
>  F: app/test/test_pmd_ring_perf.c
>  
>  Null Networking PMD
> -M: Tetsuya Mukawa 
> +M: Tetsuya Mukawa 
>  F: drivers/net/null/
>  
>  
> 



[dpdk-dev] [PATCH] maintainers: claim responsibility for vhost and null PMD

2016-07-28 Thread Tetsuya Mukawa
Signed-off-by: Tetsuya Mukawa 
---
 MAINTAINERS | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index d099131..6536c6b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -373,7 +373,7 @@ F: drivers/net/vmxnet3/
 F: doc/guides/nics/vmxnet3.rst

 Vhost PMD
-M: Tetsuya Mukawa 
+M: Tetsuya Mukawa 
 M: Yuanhan Liu 
 T: git://dpdk.org/next/dpdk-next-virtio
 F: drivers/net/vhost/
@@ -392,7 +392,7 @@ F: app/test/test_pmd_ring.c
 F: app/test/test_pmd_ring_perf.c

 Null Networking PMD
-M: Tetsuya Mukawa 
+M: Tetsuya Mukawa 
 F: drivers/net/null/


-- 
2.7.4



[dpdk-dev] SRIOV hot unplug

2016-07-19 Thread Tetsuya Mukawa
Hi Eli,

On 2016/07/18 17:47, Eli Britstein wrote:
> Hi Bernard,
> 
> Thank you for your answer.
> However, to do this, I have to have some communication protocol to the VM's 
> application in order for it to do this sequence and acknowledge that it is 
> now safe to proceed with detaching the device.
> This implies some kind of integration from the host side, which I would like 
> to avoid.

I guess you should have some kind of communication channel to notice the
hotpluging events from host to VM.

> Do you think might there be any other way for the application to handle such 
> event in a smooth way?

So far, I guess having one more virtio-net device will be easiest way.

Thanks,
Tetsuya

> 
> Thanks,
> Eli
> 
>> -Original Message-
>> From: Iremonger, Bernard [mailto:bernard.iremonger at intel.com]
>> Sent: Sunday, 17 July, 2016 11:53 PM
>> To: Eli Britstein; dev at dpdk.org
>> Cc: Iremonger, Bernard
>> Subject: RE: SRIOV hot unplug
>>
>> Hi Eli,
>>
>> The DPDK application in the VM should remove the slave device from the
>> bond device, stop, close and detach the device in the VM before doing "virsh
>> detach-device" from the host.
>>
>> Regards,
>>
>> Bernard.
>>
>>
>>> -Original Message-
>>> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Eli Britstein
>>> Sent: Sunday, July 17, 2016 9:58 AM
>>> To: dev at dpdk.org
>>> Subject: [dpdk-dev] SRIOV hot unplug
>>>
>>> Hello,
>>>
>>> A DPDK application with a DPDK bond device, with 2 slaves: one vnic,
>>> and another is a SRIOV VF connected as a pathrough.
>>> The bond device is configured as ACTIVE/BACKUP, and the primary is the
>>> VF slave.
>>> Now, I do "virsh detach-device" from the host, and the DPDK process in
>>> the VM gets segmentation fault, as it tries to poll an address that is
>>> not mmaped anymore.
>>> I wonder if this flow is supposed to be supported by DPDK, or not.
>>> Please advise.
>>>
>>> Thanks,
>>> Eli
>>> --
>>> 
>>> ---
>>> This email and any files transmitted and/or attachments with it are
>>> confidential and proprietary information of Toga Networks Ltd., and
>>> intended solely for the use of the individual or entity to whom they
>>> are addressed.
>>> If you have received this email in error please notify the system manager.
>>> This message contains confidential information of Toga Networks Ltd.,
>>> and is intended only for the individual named. If you are not the
>>> named addressee you should not disseminate, distribute or copy this
>>> e-mail. Please notify the sender immediately by e-mail if you have
>>> received this e-mail by mistake and delete this e-mail from your
>>> system. If you are not the intended recipient you are notified that
>>> disclosing, copying, distributing or taking any action in reliance on the
>> contents of this information is strictly prohibited.
>>> --
>>> 
>>> --
> 
> -
> This email and any files transmitted and/or attachments with it are 
> confidential and proprietary information of
> Toga Networks Ltd., and intended solely for the use of the individual or 
> entity to whom they are addressed.
> If you have received this email in error please notify the system manager. 
> This message contains confidential
> information of Toga Networks Ltd., and is intended only for the individual 
> named. If you are not the named
> addressee you should not disseminate, distribute or copy this e-mail. Please 
> notify the sender immediately
> by e-mail if you have received this e-mail by mistake and delete this e-mail 
> from your system. If you are not
> the intended recipient you are notified that disclosing, copying, 
> distributing or taking any action in reliance on
> the contents of this information is strictly prohibited.
> 
> 



[dpdk-dev] [PATCH] vhost: fix Tx error counting of vhost PMD

2016-06-24 Thread Tetsuya Mukawa
On 2016/06/24 11:17, Yuanhan Liu wrote:
> On Fri, Jun 24, 2016 at 11:04:20AM +0900, Tetsuya Mukawa wrote:
>> According to 'rte_eth_stats' structure comments, 'imissed'
>> should represent RX error counting, but currently 'imissed' is
>> used to count TX error.
>> The patch replaces 'imissed' by 'oerrors'.
>>
>> Fixes: ee584e9710b9 ("vhost: add driver on top of the library")
>> Signed-off-by: Tetsuya Mukawa 
> 
> Acked-by: Yuanhan Liu 
> 
> (And sorry for the delay: I planned to look at the report from
> you at the earlier of this week; but somehow I forgot :(
> 
>   --yliu
> 

Hi Yuanhan,

No need to worry. Thanks for your checking!

Thanks,
Tetsuya


[dpdk-dev] [PATCH] vhost: fix Tx error counting of vhost PMD

2016-06-24 Thread Tetsuya Mukawa
According to 'rte_eth_stats' structure comments, 'imissed'
should represent RX error counting, but currently 'imissed' is
used to count TX error.
The patch replaces 'imissed' by 'oerrors'.

Fixes: ee584e9710b9 ("vhost: add driver on top of the library")
Signed-off-by: Tetsuya Mukawa 
---
 drivers/net/vhost/rte_eth_vhost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/vhost/rte_eth_vhost.c 
b/drivers/net/vhost/rte_eth_vhost.c
index c5bbb87..3b50946 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -594,7 +594,7 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats 
*stats)

stats->ipackets = rx_total;
stats->opackets = tx_total;
-   stats->imissed = tx_missed_total;
+   stats->oerrors = tx_missed_total;
stats->ibytes = rx_total_bytes;
stats->obytes = tx_total_bytes;
 }
-- 
2.7.4



[dpdk-dev] [PATCH v2] eal: Fix resource leak while secondary process maps pci devices

2016-06-20 Thread Tetsuya Mukawa
On 2016/06/17 21:28, David Marchand wrote:
> On Thu, Jun 16, 2016 at 4:33 AM, Tetsuya Mukawa  wrote:
>> This patch fixes resource leak of pci_uio_map_secondary().
>> If pci_map_resource() succeeds but mapped address is different from an
>> address primary process mapped, this should be error.
>> Then the addresses secondary process mapped should be freed.
>>
>> Signed-off-by: Tetsuya Mukawa 
> 
> scripts/check-git-log.sh is not happy :
> 
> Wrong headline uppercase:
> eal: Fix resource leak while secondary process maps pci devices
> Wrong headline lowercase:
> eal: Fix resource leak while secondary process maps pci devices
> Headline too long:
> eal: Fix resource leak while secondary process maps pci devices
> Missing 'Fixes' tag:
> eal: Fix resource leak while secondary process maps pci devices
> 
> 
> checkpatch is not happy, but I think we can ignore it.
> 
> WARNING:LONG_LINE: line over 80 characters
> #48: FILE: lib/librte_eal/common/eal_common_pci_uio.c:93:
> +(size_t)uio_res->maps[j].size);
> 
> 
> Anyways, looks good to me, Thomas, can you fix the commit logs of
> those last 3 patches on eal ?
> Thanks.
> 

Hi David,

I appreciate your checking.
Next time I will check check-git-log.sh before submitting.


Hi Thomas,

Could you please let me know if you need the fixed patches.

Best,
Tetsuya




[dpdk-dev] [PATCH v2] eal: Fix resource leak while secondary process maps pci devices

2016-06-16 Thread Tetsuya Mukawa
This patch fixes resource leak of pci_uio_map_secondary().
If pci_map_resource() succeeds but mapped address is different from an
address primary process mapped, this should be error.
Then the addresses secondary process mapped should be freed.

Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_eal/common/eal_common_pci_uio.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_pci_uio.c 
b/lib/librte_eal/common/eal_common_pci_uio.c
index 488b6dd..83314c3 100644
--- a/lib/librte_eal/common/eal_common_pci_uio.c
+++ b/lib/librte_eal/common/eal_common_pci_uio.c
@@ -53,7 +53,7 @@ EAL_REGISTER_TAILQ(rte_uio_tailq)
 static int
 pci_uio_map_secondary(struct rte_pci_device *dev)
 {
-   int fd, i;
+   int fd, i, j;
struct mapped_pci_resource *uio_res;
struct mapped_pci_res_list *uio_res_list =
RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);
@@ -85,6 +85,17 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
"Cannot mmap device resource file %s to 
address: %p\n",
uio_res->maps[i].path,
uio_res->maps[i].addr);
+   if (mapaddr != MAP_FAILED) {
+   /* unmap addrs correctly mapped */
+   for (j = 0; j < i; j++)
+   pci_unmap_resource(
+   uio_res->maps[j].addr,
+   
(size_t)uio_res->maps[j].size);
+
+   /* unmap addr wrongly mapped */
+   pci_unmap_resource(mapaddr,
+   (size_t)uio_res->maps[i].size);
+   }
return -1;
}
}
-- 
2.7.4



[dpdk-dev] [PATCH v2] eal: Fix wrong resource release while unmapping pci devices

2016-06-16 Thread Tetsuya Mukawa
This patch fixes wrong resource release of pci_uio_unmap().
The 'path' member of mapped_pci_resource structure is allocated by
primary process, but currently it will be freed by both primary
and secondary process.
The patch fixes to be freed by only primary process.

Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_eal/common/eal_common_pci_uio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_pci_uio.c 
b/lib/librte_eal/common/eal_common_pci_uio.c
index f062e81..488b6dd 100644
--- a/lib/librte_eal/common/eal_common_pci_uio.c
+++ b/lib/librte_eal/common/eal_common_pci_uio.c
@@ -159,7 +159,9 @@ pci_uio_unmap(struct mapped_pci_resource *uio_res)
for (i = 0; i != uio_res->nb_maps; i++) {
pci_unmap_resource(uio_res->maps[i].addr,
(size_t)uio_res->maps[i].size);
-   rte_free(uio_res->maps[i].path);
+
+   if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+   rte_free(uio_res->maps[i].path);
}
 }

-- 
2.7.4



[dpdk-dev] [PATCH v2] eal: Fix wrong error checking while parsing device arguments

2016-06-16 Thread Tetsuya Mukawa
This patch fixes wrong error checking of rte_eal_parse_devargs_str().
Currently, a return value of strdup() is wrongly checked.

Fixes: 0fe11ec592b2 ("eal: add vdev init and uninit")
Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_eal/common/eal_common_devargs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_devargs.c 
b/lib/librte_eal/common/eal_common_devargs.c
index 2bfe54a..e403717 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -58,7 +58,7 @@ rte_eal_parse_devargs_str(const char *devargs_str,
return -1;

*drvname = strdup(devargs_str);
-   if (drvname == NULL)
+   if (*drvname == NULL)
return -1;

/* set the first ',' to '\0' to split name and arguments */
-- 
2.7.4



[dpdk-dev] [PATCH] eal: Fix wrong error checking of rte_eal_parse_devargs_str()

2016-06-16 Thread Tetsuya Mukawa
On 2016/06/15 23:48, David Marchand wrote:
> On Wed, Jun 15, 2016 at 5:26 AM, Tetsuya Mukawa  wrote:
>> Currently, a return value of strdup() isn't checked correctly.
>> The patch fixes it.
>>
>> Signed-off-by: Tetsuya Mukawa 
> 
> Idem, the title does not need the function name to describe what is going 
> wrong.
> 
> This might deserve a fixline, I traced this to 0fe11ec592b2 ("eal: add
> vdev init and uninit").

Will add it.

Thanks,
Tetsuya


[dpdk-dev] [PATCH] eal: Fix resource leak of pci_uio_map_secondary()

2016-06-16 Thread Tetsuya Mukawa
On 2016/06/15 23:45, David Marchand wrote:
> Hello Tetsuya,
> 
> On Wed, Jun 15, 2016 at 5:26 AM, Tetsuya Mukawa  wrote:
>> If pci_map_resource() succeeds but mapped address is different from an
>> address primary process mapped, this should be error.
>> Then the address secondary process mapped should be freed.
>>
>> Signed-off-by: Tetsuya Mukawa 
> 
> The title should not contain the function name.

Hi David,

Thanks, I will change the title of all patches.

> 
> 
>> ---
>>  lib/librte_eal/common/eal_common_pci_uio.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/lib/librte_eal/common/eal_common_pci_uio.c 
>> b/lib/librte_eal/common/eal_common_pci_uio.c
>> index f062e81..e718643 100644
>> --- a/lib/librte_eal/common/eal_common_pci_uio.c
>> +++ b/lib/librte_eal/common/eal_common_pci_uio.c
>> @@ -85,6 +85,9 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
>> "Cannot mmap device resource file %s 
>> to address: %p\n",
>> uio_res->maps[i].path,
>> uio_res->maps[i].addr);
>> +   if (mapaddr != MAP_FAILED)
>> +   pci_unmap_resource(mapaddr,
>> +   
>> (size_t)uio_res->maps[i].size);
>> return -1;
>> }
>> }
> 
> What of the previous mappings that might have succeeded earlier in this loop ?

I will unmap all addresses mapped before.

Thanks,
Tetsuya


[dpdk-dev] [PATCH] eal: Fix wrong resource release of pci_uio_unmap()

2016-06-15 Thread Tetsuya Mukawa
The 'path' member of mapped_pci_resource structure is allocated by
primary process, but currenctly it will be freed by both primary
and secondary process.
The patch fixes to be freed by only primary process.

Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_eal/common/eal_common_pci_uio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_pci_uio.c 
b/lib/librte_eal/common/eal_common_pci_uio.c
index e718643..b2c68f3 100644
--- a/lib/librte_eal/common/eal_common_pci_uio.c
+++ b/lib/librte_eal/common/eal_common_pci_uio.c
@@ -162,7 +162,9 @@ pci_uio_unmap(struct mapped_pci_resource *uio_res)
for (i = 0; i != uio_res->nb_maps; i++) {
pci_unmap_resource(uio_res->maps[i].addr,
(size_t)uio_res->maps[i].size);
-   rte_free(uio_res->maps[i].path);
+
+   if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+   rte_free(uio_res->maps[i].path);
}
 }

-- 
2.7.4



[dpdk-dev] [PATCH] eal: Fix wrong error checking of rte_eal_parse_devargs_str()

2016-06-15 Thread Tetsuya Mukawa
Currently, a return value of strdup() isn't checked correctly.
The patch fixes it.

Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_eal/common/eal_common_devargs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_devargs.c 
b/lib/librte_eal/common/eal_common_devargs.c
index 2bfe54a..e403717 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -58,7 +58,7 @@ rte_eal_parse_devargs_str(const char *devargs_str,
return -1;

*drvname = strdup(devargs_str);
-   if (drvname == NULL)
+   if (*drvname == NULL)
return -1;

/* set the first ',' to '\0' to split name and arguments */
-- 
2.7.4



[dpdk-dev] [PATCH] eal: Fix resource leak of pci_uio_map_secondary()

2016-06-15 Thread Tetsuya Mukawa
If pci_map_resource() succeeds but mapped address is different from an
address primary process mapped, this should be error.
Then the address secondary process mapped should be freed.

Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_eal/common/eal_common_pci_uio.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_pci_uio.c 
b/lib/librte_eal/common/eal_common_pci_uio.c
index f062e81..e718643 100644
--- a/lib/librte_eal/common/eal_common_pci_uio.c
+++ b/lib/librte_eal/common/eal_common_pci_uio.c
@@ -85,6 +85,9 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
"Cannot mmap device resource file %s to 
address: %p\n",
uio_res->maps[i].path,
uio_res->maps[i].addr);
+   if (mapaddr != MAP_FAILED)
+   pci_unmap_resource(mapaddr,
+   (size_t)uio_res->maps[i].size);
return -1;
}
}
-- 
2.7.4



[dpdk-dev] packet counting of vhost PMD

2016-06-10 Thread Tetsuya Mukawa
Hi Yuanhan,

Can I get your opnion about packet counting of vhost PMD?

So far, we may not be able to send all packets at once, the number of
failed packets are counted, and when stats_get() is called, the number
of the packet is filled like below.

stats->imissed = tx_missed_total;

I wonder whether this should be filled as "stats->oerror"?
It seems all virtual PMD doesn't use 'imissed' except for vhost PMD.
What do you think?

Thanks,
Tetsuya


[dpdk-dev] [PATCH v5 0/6] Virtio-net PMD: QEMU QTest extension for container

2016-06-07 Thread Tetsuya Mukawa
On 2016/06/06 19:50, Tan, Jianfeng wrote:
>> Please let me make sure how we can invoke many DPDK applications in
>> hundreds containers.
>> (Do we have a way to do? Or, will we have it in the future?)
> 
> Just to add some option here, we cannot say no to that kind of use case.
> To have many instances, we can:
> 
> (1) add a restriction of "cpu share" on each instance, relying on kernel
> to schedule.
> (2) enable interrupt mode, so that one instance can go to sleep when it
> has no pkts to receive and awoke by vhost backend when pkts come.
> 
> Option 2 is my choice.

Hi Yuanhan and Jianfeng,

Thanks for your descriptions about how you will invoke many DPDK
applications in containers.
I guess we have almost talked everything we need to consider to choose
one of container implementations.

We may have one conclusion about this choice.
If we can easily maintain virtio device implementation, also if we have
an use-case to invoke hundreds of DPDK applications in containers, I
guess Jianfeng's implementation will be nice.
Anyway, we just follow virtio maintainers choice.

Thanks,
Tetsuya

> 
> Thanks,
> Jianfeng
> 
>>
>> Thanks,
>> Tetsuya
> 
> 



[dpdk-dev] [PATCH v5 0/6] Virtio-net PMD: QEMU QTest extension for container

2016-06-06 Thread Tetsuya Mukawa
On 2016/06/06 17:49, Yuanhan Liu wrote:
> On Mon, Jun 06, 2016 at 05:33:31PM +0900, Tetsuya Mukawa wrote:
>>>> [My solution]
>>>> - Pros
>>>> Basic principle of my implementation is not to reinvent the wheel.
>>>
>>> Yes, that's a good point. However, it's not that hard as we would have
>>> thought in the first time: the tough part that dequeue/enqueue packets
>>> from/to vring is actually offloaded to DPDK vhost-user. That means we
>>> only need re-implement the control path of virtio-net device, plus the
>>> vhost-user frontend. If you have a detailed look of your patchset as
>>> well Jianfeng's, you might find that the two patchset are actually with
>>> same code size. 
>>
>> Yes, I know this.
>> So far, the amount of code is almost same, but in the future we may need
>> to implement more, if virtio-net specification is revised.
> 
> It didn't take too much effort to implement from scratch, I doubt it
> will for future revise. And, virtio-net spec is unlikely revised, or
> to be precisely, unlikely revised quite often. Therefore, I don't see
> big issues here.
> 
>>>> We can use a virtio-net device of QEMU implementation, it means we don't
>>>> need to maintain virtio-net device by ourselves, and we can use all of
>>>> functions supported by QEMU virtio-net device.
>>>> - Cons
>>>> Need to invoke QEMU process.
>>>
>>> Another thing is that it makes the usage a bit harder: look at the
>>> long qemu cli options of your example usage. It also has some traps,
>>> say, "--enable-kvm" is not allowed, which is a default option used
>>> with QEMU.
>>
>> Probably a kind of shell script will help the users.
> 
> Yeah, that would help. But if we have a choice to make it simpler in the
> beginning, why not then? :-)
> 
>>>
>>> And judging that we actually don't take too much effort to implement
>>> a virtio device emulation, I'd prefer it slightly. I guess something
>>> light weight and easier for use is more important here.
>>
>> This is very important point.
>> If so, we don't need much effort when virtio-spec is changed.
> 
> I'd assume so.
> 
>>> Actually, I have foreseen another benefit of adding virtio-user device
>>> emulation: we now might be able to add a rte_vhost_dequeue/enqueue_burst()
>>> unit test case. We simply can't do it before, since we depend on QEMU
>>> for testing, which is not acceptable for a unit test case. Making it
>>> be a unit test case would help us spotting any bad changes that would
>>> introduce bugs easily and automatically.
>>
>> As you mentioned above, QEMU process is not related with
>> dequeuing/enqueuing.
>> So I guess we may have a testing for rte_vhost_dequeue/enqueue_burst()
>> regardless of choice.
> 
> Yes, we don't need the dequeue/enqueue part, but we need the vhost-user
> initialization part from QEMU vhost-user. Now that we have vhost-user
> frontend from virtio-user, we have no dependency on QEMU any more.
> 
>>>> Anyway, we can choose one of belows.
>>>> 1. Take advantage of invoking less processes.
>>>> 2. Take advantage of maintainability of virtio-net device.
>>
>> If container usage that DPDK assumes is to invoke hundreds containers in
>> one host,
> 
> I barely know about container, but I would assume that's not rare.

Hi Yuanhan,

It's great to hear it's not so hard to maintain Jiangfeng's virtio-net
device features.

Please let me make sure how we can invoke many DPDK applications in
hundreds containers.
(Do we have a way to do? Or, will we have it in the future?)

Thanks,
Tetsuya

> 
>> we should take Jiangfeng's solution.
>>
>> Also, if implementing a new feature and maintaining Jiangfeng's
>> virtio-net device are not so hard,
> 
> As stated, I would assume so.




> 
>   --yliu
> 
>> we should take his solution.
>>
>> I guess this is the point we need to consider.
>> What do you think?
>>
>> Thanks,
>> Tetsuya
>>
>>>>
>>>> Honestly, I'm OK if my solution is not merged.
>>>> Thus, it should be decided to let DPDK better.
>>>>
>>>> What do you think?
>>>> Which is better for DPDK?
>>>>
>>>> Thanks,
>>>> Tetsuya
>>>>
>>>>>
>>>>>   --yliu
>>>>>



[dpdk-dev] [PATCH v5 0/6] Virtio-net PMD: QEMU QTest extension for container

2016-06-06 Thread Tetsuya Mukawa
On 2016/06/06 17:03, Tan, Jianfeng wrote:
> Hi,
> 
> 
> On 6/6/2016 1:10 PM, Tetsuya Mukawa wrote:
>> Hi Yuanhan,
>>
>> Sorry for late replying.
>>
>> On 2016/06/03 13:17, Yuanhan Liu wrote:
>>> On Thu, Jun 02, 2016 at 06:30:18PM +0900, Tetsuya Mukawa wrote:
>>>> Hi Yuanhan,
>>>>
>>>> On 2016/06/02 16:31, Yuanhan Liu wrote:
>>>>> But still, I'd ask do we really need 2 virtio for container solutions?
>>>> I appreciate your comments.
>>> No, I appreciate your effort for contributing to DPDK! vhost-pmd stuff
>>> is just brilliant!
>>>
>>>> Let me have time to discuss it with our team.
>>> I'm wondering could we have one solution only. IMO, the drawback of
>>> having two (quite different) solutions might outweighs the benefit
>>> it takes. Say, it might just confuse user.
>> I agree with this.
>> If we have 2 solutions, it would confuse the DPDK users.
>>
>>> OTOH, I'm wondering could you adapt to Jianfeng's solution? If not,
>>> what's the missing parts, and could we fix it? I'm thinking having
>>> one unified solution will keep ours energy/focus on one thing, making
>>> it better and better! Having two just splits the energy; it also
>>> introduces extra burden for maintaining.
>> Of course, I adopt Jiangeng's solution basically.
>> Actually, his solution is almost similar I tried to implement at first.
>>
>> I guess here is pros/cons of 2 solutions.
>>
>> [Jianfeng's solution]
>> - Pros
>> Don't need to invoke QEMU process.
>> - Cons
>> If virtio-net specification is changed, we need to implement it by
>> ourselves.
> 
> It will barely introduce any change when virtio-net specification is
> changed as far as I can see. The only part we care is the how desc,
> avail, used distribute on memory, which is a very small part.

It's a good news, because we don't pay much effort to follow latest
virtio-net specification.

> 
> It's true that my solution now seriously depend on vhost-user protocol,
> which is defined in QEMU. I cannot see a big problem there so far.
> 
>>   Also, LSC interrupt and control queue functions are not
>> supported yet.
>> I agree both functions may not be so important, and if we need it
>> we can implement them, but we need to pay energy to implement them.
> 
> LSC is really less important than rxq interrupt (IMO). We don't know how
> long will rxq interrupt of virtio be available for QEMU, but we can
> accelerate it if we avoid using QEMU.
> 
> Actually, if the vhost backend is vhost-user (the main use case),
> current qemu have limited control queue support, because it needs the
> support from the vhost user backend.
> 
> Add one more con of my solution:
> - Need to write another logic to support other virtio device (say
> virtio-scsi), if it's easier of Tetsuya's solution to do that?
> 

Probably, my solution will be easier to do that.
My solution has enough facility to access to io port and PCI
configuration space of virtio-scsi device of QEMU.
So, if you invoke with QEMU with virtio-scsi, only you need to do is
changing PCI interface of current virtio-scsi PMD.
(I just assume currently we have virtio-scsi PMD.)
If the virtio-scsi PMD works on QEMU, same code should work with only
changing PCI interface.

>>
>> [My solution]
>> - Pros
>> Basic principle of my implementation is not to reinvent the wheel.
>> We can use a virtio-net device of QEMU implementation, it means we don't
>> need to maintain virtio-net device by ourselves, and we can use all of
>> functions supported by QEMU virtio-net device.
>> - Cons
>> Need to invoke QEMU process.
> 
> Two more possible cons:
> a) This solution also needs to maintain qtest utility, right?

But the spec of qtest will be more stable than virtio-net.

> b) There's still address arrange restriction, right? Although we can use
> "--base-virtaddr=0x4" to relieve this question, but how about if
> there are 2 or more devices? (By the way, is there still address arrange
> requirement for 32 bit system)

Our solutions are a virtio-net driver, and a vhost-user backend driver
needs to access to memory allocated by virtio-net driver.
If an application has 2 devices, it means 2 vhost-user backend PMD needs
to access to the same application memory, right?
Also, currently each virtio-net device has an one QEMU process.
So, I am not sure what will be problem if we have 2 devices.

BTW, 44bits limitations comes from current QEMU implementation itself.
(Actually, if modern virtio device is used, we should be able to remove
the restriction.)

> c) Actually, IMO this so

[dpdk-dev] [PATCH v5 0/6] Virtio-net PMD: QEMU QTest extension for container

2016-06-06 Thread Tetsuya Mukawa
On 2016/06/06 16:21, Yuanhan Liu wrote:
> On Mon, Jun 06, 2016 at 02:10:46PM +0900, Tetsuya Mukawa wrote:
>> Hi Yuanhan,
>>
>> Sorry for late replying.
> 
> Never mind.
> 
>>
>> On 2016/06/03 13:17, Yuanhan Liu wrote:
>>> On Thu, Jun 02, 2016 at 06:30:18PM +0900, Tetsuya Mukawa wrote:
>>>> Hi Yuanhan,
>>>>
>>>> On 2016/06/02 16:31, Yuanhan Liu wrote:
>>>>> But still, I'd ask do we really need 2 virtio for container solutions?
>>>>
>>>> I appreciate your comments.
>>>
>>> No, I appreciate your effort for contributing to DPDK! vhost-pmd stuff
>>> is just brilliant!
>>>
>>>> Let me have time to discuss it with our team.
>>>
>>> I'm wondering could we have one solution only. IMO, the drawback of
>>> having two (quite different) solutions might outweighs the benefit
>>> it takes. Say, it might just confuse user.
>>
>> I agree with this.
>> If we have 2 solutions, it would confuse the DPDK users.
>>
>>>
>>> OTOH, I'm wondering could you adapt to Jianfeng's solution? If not,
>>> what's the missing parts, and could we fix it? I'm thinking having
>>> one unified solution will keep ours energy/focus on one thing, making
>>> it better and better! Having two just splits the energy; it also
>>> introduces extra burden for maintaining.
>>
>> Of course, I adopt Jiangeng's solution basically.
>> Actually, his solution is almost similar I tried to implement at first.
>>
>> I guess here is pros/cons of 2 solutions.
>>
>> [Jianfeng's solution]
>> - Pros
>> Don't need to invoke QEMU process.
>> - Cons
>> If virtio-net specification is changed, we need to implement it by
>> ourselves. Also, LSC interrupt and control queue functions are not
>> supported yet.
> 
> Jianfeng have made and sent out the patch to enable ctrl queue and
> multiple queue support.

Sorry, I haven't noticed that ctrl queue has been already enabled.

> 
> For the LSC part, no much idea yet so far. But I'm assuming it will
> not take too much effort, either.
> 
>> I agree both functions may not be so important, and if we need it
>> we can implement them, but we need to pay energy to implement them.
>>
>> [My solution]
>> - Pros
>> Basic principle of my implementation is not to reinvent the wheel.
> 
> Yes, that's a good point. However, it's not that hard as we would have
> thought in the first time: the tough part that dequeue/enqueue packets
> from/to vring is actually offloaded to DPDK vhost-user. That means we
> only need re-implement the control path of virtio-net device, plus the
> vhost-user frontend. If you have a detailed look of your patchset as
> well Jianfeng's, you might find that the two patchset are actually with
> same code size. 

Yes, I know this.
So far, the amount of code is almost same, but in the future we may need
to implement more, if virtio-net specification is revised.

> 
>> We can use a virtio-net device of QEMU implementation, it means we don't
>> need to maintain virtio-net device by ourselves, and we can use all of
>> functions supported by QEMU virtio-net device.
>> - Cons
>> Need to invoke QEMU process.
> 
> Another thing is that it makes the usage a bit harder: look at the
> long qemu cli options of your example usage. It also has some traps,
> say, "--enable-kvm" is not allowed, which is a default option used
> with QEMU.

Probably a kind of shell script will help the users.

> 
> And judging that we actually don't take too much effort to implement
> a virtio device emulation, I'd prefer it slightly. I guess something
> light weight and easier for use is more important here.

This is very important point.
If so, we don't need much effort when virtio-spec is changed.

> 
> Actually, I have foreseen another benefit of adding virtio-user device
> emulation: we now might be able to add a rte_vhost_dequeue/enqueue_burst()
> unit test case. We simply can't do it before, since we depend on QEMU
> for testing, which is not acceptable for a unit test case. Making it
> be a unit test case would help us spotting any bad changes that would
> introduce bugs easily and automatically.

As you mentioned above, QEMU process is not related with
dequeuing/enqueuing.
So I guess we may have a testing for rte_vhost_dequeue/enqueue_burst()
regardless of choice.

>> Anyway, we can choose one of belows.
>> 1. Take advantage of invoking less processes.
>> 2. Take advantage of maintainability of virtio-net device.

If container usage that DPDK assumes is to invoke hundreds containers in
one host, we should take Jiangfeng's solution.

Also, if implementing a new feature and maintaining Jiangfeng's
virtio-net device are not so hard, we should take his solution.

I guess this is the point we need to consider.
What do you think?

Thanks,
Tetsuya

>>
>> Honestly, I'm OK if my solution is not merged.
>> Thus, it should be decided to let DPDK better.
>>
>> What do you think?
>> Which is better for DPDK?
>>
>> Thanks,
>> Tetsuya
>>
>>>
>>> --yliu
>>>



[dpdk-dev] [PATCH v5 0/6] Virtio-net PMD: QEMU QTest extension for container

2016-06-06 Thread Tetsuya Mukawa
Hi Yuanhan,

Sorry for late replying.

On 2016/06/03 13:17, Yuanhan Liu wrote:
> On Thu, Jun 02, 2016 at 06:30:18PM +0900, Tetsuya Mukawa wrote:
>> Hi Yuanhan,
>>
>> On 2016/06/02 16:31, Yuanhan Liu wrote:
>>> But still, I'd ask do we really need 2 virtio for container solutions?
>>
>> I appreciate your comments.
> 
> No, I appreciate your effort for contributing to DPDK! vhost-pmd stuff
> is just brilliant!
> 
>> Let me have time to discuss it with our team.
> 
> I'm wondering could we have one solution only. IMO, the drawback of
> having two (quite different) solutions might outweighs the benefit
> it takes. Say, it might just confuse user.

I agree with this.
If we have 2 solutions, it would confuse the DPDK users.

> 
> OTOH, I'm wondering could you adapt to Jianfeng's solution? If not,
> what's the missing parts, and could we fix it? I'm thinking having
> one unified solution will keep ours energy/focus on one thing, making
> it better and better! Having two just splits the energy; it also
> introduces extra burden for maintaining.

Of course, I adopt Jiangeng's solution basically.
Actually, his solution is almost similar I tried to implement at first.

I guess here is pros/cons of 2 solutions.

[Jianfeng's solution]
- Pros
Don't need to invoke QEMU process.
- Cons
If virtio-net specification is changed, we need to implement it by
ourselves. Also, LSC interrupt and control queue functions are not
supported yet.
I agree both functions may not be so important, and if we need it
we can implement them, but we need to pay energy to implement them.

[My solution]
- Pros
Basic principle of my implementation is not to reinvent the wheel.
We can use a virtio-net device of QEMU implementation, it means we don't
need to maintain virtio-net device by ourselves, and we can use all of
functions supported by QEMU virtio-net device.
- Cons
Need to invoke QEMU process.


Anyway, we can choose one of belows.
1. Take advantage of invoking less processes.
2. Take advantage of maintainability of virtio-net device.

Honestly, I'm OK if my solution is not merged.
Thus, it should be decided to let DPDK better.

What do you think?
Which is better for DPDK?

Thanks,
Tetsuya

> 
>   --yliu
> 



[dpdk-dev] [PATCH v5 0/6] Virtio-net PMD: QEMU QTest extension for container

2016-06-02 Thread Tetsuya Mukawa
Hi Yuanhan,

On 2016/06/02 16:31, Yuanhan Liu wrote:
> But still, I'd ask do we really need 2 virtio for container solutions?

I appreciate your comments.
Let me have time to discuss it with our team.

Thanks,
Tetsuya


[dpdk-dev] [PATCH v1 2/2] virtio, qtest: Add functionality to handle interrupt

2016-06-02 Thread Tetsuya Mukawa
The patch adds functionality to handle interrupt from pci device of
QEMU guest. To handle the interrupts, the patch adds to initialize piix3
pci device.

Signed-off-by: Tetsuya Mukawa 
---
 drivers/net/virtio/virtio_ethdev.c |   7 +-
 drivers/net/virtio/virtio_qtest/qtest.h|   3 +-
 drivers/net/virtio/virtio_qtest/qtest_utils.c  | 225 -
 drivers/net/virtio/virtio_qtest/qtest_utils.h  |  68 ++-
 drivers/net/virtio/virtio_qtest/virtio_qtest_dev.c |  23 ++-
 drivers/net/virtio/virtio_qtest/virtio_qtest_pci.c |  64 --
 6 files changed, 360 insertions(+), 30 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index 8b5fb66..e8737ab 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1043,7 +1043,6 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
struct virtio_net_config *config;
struct virtio_net_config local_config;
struct rte_pci_device *pci_dev;
-   uint32_t dev_flags = RTE_ETH_DEV_DETACHABLE;
int ret;

RTE_BUILD_BUG_ON(RTE_PKTMBUF_HEADROOM < sizeof(struct 
virtio_net_hdr_mrg_rxbuf));
@@ -1067,8 +1066,9 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)

pci_dev = eth_dev->pci_dev;

+   eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE;
if (pci_dev) {
-   ret = vtpci_init(pci_dev, hw, _flags);
+   ret = vtpci_init(pci_dev, hw, _dev->data->dev_flags);
if (ret)
return ret;
}
@@ -1086,10 +1086,9 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)

/* If host does not support status then disable LSC */
if (!vtpci_with_feature(hw, VIRTIO_NET_F_STATUS))
-   dev_flags &= ~RTE_ETH_DEV_INTR_LSC;
+   eth_dev->data->dev_flags &= ~RTE_ETH_DEV_INTR_LSC;

rte_eth_copy_pci_info(eth_dev, pci_dev);
-   eth_dev->data->dev_flags = dev_flags;

rx_func_get(eth_dev);

diff --git a/drivers/net/virtio/virtio_qtest/qtest.h 
b/drivers/net/virtio/virtio_qtest/qtest.h
index 534c5a0..7e8c093 100644
--- a/drivers/net/virtio/virtio_qtest/qtest.h
+++ b/drivers/net/virtio/virtio_qtest/qtest.h
@@ -35,7 +35,7 @@
 #define _VIRTIO_QTEST_H_

 #define QTEST_DRV_NAME "eth_virtio_qtest"
-#define QTEST_DEVICE_NUM2
+#define QTEST_DEVICE_NUM3

 #include 
 #include 
@@ -43,6 +43,7 @@
 /* Device information */
 #define VIRTIO_NET_DEVICE_ID0x1000
 #define VIRTIO_NET_VENDOR_ID0x1af4
+#define VIRTIO_NET_IRQ_NUM  10
 #define IVSHMEM_DEVICE_ID   0x1110
 #define IVSHMEM_VENDOR_ID   0x1af4
 #define PIIX3_DEVICE_ID 0x7000
diff --git a/drivers/net/virtio/virtio_qtest/qtest_utils.c 
b/drivers/net/virtio/virtio_qtest/qtest_utils.c
index 27118fb..c5a3a7a 100644
--- a/drivers/net/virtio/virtio_qtest/qtest_utils.c
+++ b/drivers/net/virtio/virtio_qtest/qtest_utils.c
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 

@@ -43,6 +44,12 @@
 #include "../virtio_ethdev.h"
 #include "qtest_utils.h"

+/* PIIX3 configuration registers */
+#define PIIX3_REG_ADDR_PIRQA0x60
+#define PIIX3_REG_ADDR_PIRQB0x61
+#define PIIX3_REG_ADDR_PIRQC0x62
+#define PIIX3_REG_ADDR_PIRQD0x63
+
 /* ivshmem configuration */
 #define IVSHMEM_PROTOCOL_VERSION0

@@ -74,6 +81,14 @@ struct qtest_session {
size_t evq_total_len;

union qtest_pipefds msgfds;
+
+   int irqno;
+   pthread_t intr_th;
+   int intr_th_started;
+   int eventfd;
+   rte_atomic16_t enable_intr;
+   rte_intr_callback_fn cb;
+   void *cb_arg;
 };

 static int
@@ -230,6 +245,29 @@ qtest_pci_inb(struct qtest_session *s, uint8_t bus, 
uint8_t device,
return (tmp >> ((offset & 0x3) * 8)) & 0xff;
 }

+static void
+qtest_pci_outb(struct qtest_session *s, uint8_t bus, uint8_t device,
+   uint8_t function, uint8_t offset, uint8_t value)
+{
+   uint32_t addr, tmp, pos;
+
+   addr = PCI_CONFIG_ADDR(bus, device, function, offset);
+   pos = (offset % 4) * 8;
+
+   if (pthread_mutex_lock(>qtest_session_lock) < 0)
+   rte_panic("Cannot lock mutex\n");
+
+   qtest_raw_out(s, 0xcf8, addr, 'l');
+   tmp = qtest_raw_in(s, 0xcfc, 'l');
+   tmp = (tmp & ~(0xff << pos)) | (value << pos);
+
+   qtest_raw_out(s, 0xcf8, addr, 'l');
+   qtest_raw_out(s, 0xcfc, tmp, 'l');
+
+   if (pthread_mutex_unlock(>qtest_session_lock) < 0)
+   rte_panic("Cannot unlock mutex\n");
+}
+
 static uint32_t
 qtest_pci_inl(struct qtest_session *s, uint8_t bus, uint8_t device,
uint8_t function, uint8_t offset)
@@ -466,15 +504,112 @@ qt

[dpdk-dev] [PATCH v1 1/2] virtio: Handle interrupt things under vtpci abstraction

2016-06-02 Thread Tetsuya Mukawa
So far, interrupts from PCI devices are handled in virtio_ethdev
directly. The patch changes it, and try to handle it under vtpci
abstraction. The patch is needed because virtio-qtest needs to handle
interrupts from virtual pci devices.

Signed-off-by: Tetsuya Mukawa 
---
 drivers/net/virtio/virtio_ethdev.c | 10 ++---
 drivers/net/virtio/virtio_pci.c| 86 ++
 drivers/net/virtio/virtio_pci.h|  7 
 3 files changed, 72 insertions(+), 31 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index c35d1c0..8b5fb66 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1011,7 +1011,7 @@ virtio_interrupt_handler(__rte_unused struct 
rte_intr_handle *handle,
isr = vtpci_isr(hw);
PMD_DRV_LOG(INFO, "interrupt status = %#x", isr);

-   if (rte_intr_enable(>pci_dev->intr_handle) < 0)
+   if (hw->vtpci_ops->intr_enable(hw) < 0)
PMD_DRV_LOG(ERR, "interrupt enable failed");

if (isr & VIRTIO_PCI_ISR_CONFIG) {
@@ -1170,7 +1170,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)

/* Setup interrupt callback  */
if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
-   rte_intr_callback_register(_dev->intr_handle,
+   hw->vtpci_ops->intr_cb_register(hw,
   virtio_interrupt_handler, eth_dev);

virtio_dev_cq_start(eth_dev);
@@ -1205,7 +1205,7 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)

/* reset interrupt callback  */
if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
-   rte_intr_callback_unregister(_dev->intr_handle,
+   hw->vtpci_ops->intr_cb_unregister(hw,
virtio_interrupt_handler,
eth_dev);
rte_eal_pci_unmap_device(pci_dev);
@@ -1294,7 +1294,7 @@ virtio_dev_start(struct rte_eth_dev *dev)
return -ENOTSUP;
}

-   if (rte_intr_enable(>pci_dev->intr_handle) < 0) {
+   if (hw->vtpci_ops->intr_enable(hw) < 0) {
PMD_DRV_LOG(ERR, "interrupt enable failed");
return -EIO;
}
@@ -1398,7 +1398,7 @@ virtio_dev_stop(struct rte_eth_dev *dev)
hw->started = 0;

if (dev->data->dev_conf.intr_conf.lsc)
-   rte_intr_disable(>pci_dev->intr_handle);
+   hw->vtpci_ops->intr_disable(hw);

memset(, 0, sizeof(link));
virtio_dev_atomic_write_link_status(dev, );
diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
index 6bd239c..acbc9b1 100644
--- a/drivers/net/virtio/virtio_pci.c
+++ b/drivers/net/virtio/virtio_pci.c
@@ -71,6 +71,32 @@ check_vq_phys_addr_ok(struct virtqueue *vq)
return 1;
 }

+static int
+intr_cb_register(struct virtio_hw *hw,
+   rte_intr_callback_fn cb, void *cb_arg)
+{
+   return rte_intr_callback_register(>dev->intr_handle, cb, cb_arg);
+}
+
+static int
+intr_cb_unregister(struct virtio_hw *hw,
+   rte_intr_callback_fn cb, void *cb_arg)
+{
+   return rte_intr_callback_register(>dev->intr_handle, cb, cb_arg);
+}
+
+static int
+intr_enable(struct virtio_hw *hw)
+{
+   return rte_intr_enable(>dev->intr_handle);
+}
+
+static int
+intr_disable(struct virtio_hw *hw)
+{
+   return rte_intr_disable(>dev->intr_handle);
+}
+
 static void
 legacy_read_dev_config(struct virtio_hw *hw, size_t offset,
   void *dst, int length)
@@ -234,19 +260,23 @@ legacy_virtio_resource_init(struct rte_pci_device 
*pci_dev,
 }

 static const struct virtio_pci_ops legacy_ops = {
-   .read_dev_cfg   = legacy_read_dev_config,
-   .write_dev_cfg  = legacy_write_dev_config,
-   .reset  = legacy_reset,
-   .get_status = legacy_get_status,
-   .set_status = legacy_set_status,
-   .get_features   = legacy_get_features,
-   .set_features   = legacy_set_features,
-   .get_isr= legacy_get_isr,
-   .set_config_irq = legacy_set_config_irq,
-   .get_queue_num  = legacy_get_queue_num,
-   .setup_queue= legacy_setup_queue,
-   .del_queue  = legacy_del_queue,
-   .notify_queue   = legacy_notify_queue,
+   .read_dev_cfg   = legacy_read_dev_config,
+   .write_dev_cfg  = legacy_write_dev_config,
+   .reset  = legacy_reset,
+   .get_status = legacy_get_status,
+   .set_status = legacy_set_status,
+   .get_features   = legacy_get_features,
+   .set_features   = legacy_set_features,
+   .get_isr= legacy_get_isr,
+   .set

[dpdk-dev] [PATCH v1 0/2] Supplement patches for virtio-qtest to support LSC interrupt

2016-06-02 Thread Tetsuya Mukawa
This is patches to support LSC interrupt handling for virtio-qtest.
This patches should be on below patches.
 - [PATCH v5 0/6] Virtio-net PMD: QEMU QTest extension for container

To support LSC interrupts, vtpci abstraction was expanded to handle interrupt 
from
pci devices.
Actually, this PMD is handling a virtual virtio-net device. So handling 
interrupts
are a bit different from actual pci devices. In this case, all interrupts are 
come
from unix domain socket connected to QEMU.


Tetsuya Mukawa (2):
  virtio: Handle interrupt things under vtpci abstraction
  virtio, qtest: Add functionality to handle interrupt

 drivers/net/virtio/virtio_ethdev.c |  17 +-
 drivers/net/virtio/virtio_pci.c|  86 +---
 drivers/net/virtio/virtio_pci.h|   7 +
 drivers/net/virtio/virtio_qtest/qtest.h|   3 +-
 drivers/net/virtio/virtio_qtest/qtest_utils.c  | 225 -
 drivers/net/virtio/virtio_qtest/qtest_utils.h  |  68 ++-
 drivers/net/virtio/virtio_qtest/virtio_qtest_dev.c |  23 ++-
 drivers/net/virtio/virtio_qtest/virtio_qtest_pci.c |  64 --
 8 files changed, 432 insertions(+), 61 deletions(-)

-- 
2.7.4



[dpdk-dev] [PATCH v5 6/6] virtio: Add QTest support for virtio-net PMD

2016-06-02 Thread Tetsuya Mukawa
The patch adds a new virtio-net PMD configuration that allows the PMD to
work on host as if the PMD is in VM.
Here is new configuration for virtio-net PMD.
 - CONFIG_RTE_VIRTIO_QTEST
To use this mode, EAL needs map all hugepages as one file. Also the file
should be mapped between (1 << 31) and (1 << 44). And start address
should be aligned by EAL memory size.

To allocate like above, use below '--base-virtaddr' option with
appropriate value.
If EAL cannot allocate memory like above, the PMD will return error
while initialization. In the case, try other values.
Later supplement patches will help allocating EAL memory like above.

To prepare virtio-net device on host, the users need to invoke QEMU
process in special QTest mode. This mode is mainly used for testing QEMU
devices from outer process. In this mode, no guest runs.
Here is QEMU command line.

 $ qemu-system-x86_64 \
 -machine pc-i440fx-1.4,accel=qtest \
 -display none -qtest-log /dev/null \
 -qtest unix:/tmp/socket,server \
 -netdev type=tap,script=/etc/qemu-ifup,id=net0,queues=1 \
 -device
virtio-net-pci,netdev=net0,mq=on,disable-modern=false,addr=3 \
 -chardev socket,id=chr1,path=/tmp/ivshmem,server \
 -device ivshmem,size=1G,chardev=chr1,vectors=1,addr=4

 * Should use QEMU-2.6, or above.
 * QEMU process is needed per port.
 * virtio-1.0 device are only supported.
 * The vhost backends like vhost-net and vhost-user can be specified.
 * In most cases, just using above command is enough, but you can also
   specify other QEMU virtio-net options like mac address.
 * Only checked "pc-i440fx-1.4" machine, but may work with other
   machines.
 * Should not add "--enable-kvm" to QEMU command line.

After invoking QEMU, the PMD can connect to QEMU process using unix
domain sockets. Over these sockets, virtio-net and ivshmem in QEMU
are probed by the PMD.
Here is example of command line.

 $ testpmd -c f -n 1 -m 1024 --no-pci --base-virtaddr=0x4 \
  --vdev="eth_virtio_qtest0,qtest=/tmp/socket,ivshmem=/tmp/ivshmem"\
  -- --disable-hw-vlan --txqflags=0xf00 -i

Please specify same unix domain sockets and memory size in both QEMU
and DPDK command lines like above.
The share memory size should be power of 2, because ivshmem only
accepts such memory size.

Signed-off-by: Tetsuya Mukawa 
---
 drivers/net/virtio/Makefile|   1 +
 drivers/net/virtio/virtio_ethdev.c |   3 +-
 drivers/net/virtio/virtio_ethdev.h |   1 +
 drivers/net/virtio/virtio_qtest/qtest.h|  95 +
 drivers/net/virtio/virtio_qtest/virtio_qtest_dev.c | 393 +
 drivers/net/virtio/virtio_qtest/virtio_qtest_dev.h |  42 +++
 drivers/net/virtio/virtqueue.h |   6 +-
 7 files changed, 536 insertions(+), 5 deletions(-)
 create mode 100644 drivers/net/virtio/virtio_qtest/qtest.h
 create mode 100644 drivers/net/virtio/virtio_qtest/virtio_qtest_dev.c
 create mode 100644 drivers/net/virtio/virtio_qtest/virtio_qtest_dev.h

diff --git a/drivers/net/virtio/Makefile b/drivers/net/virtio/Makefile
index 1c86d9d..5933205 100644
--- a/drivers/net/virtio/Makefile
+++ b/drivers/net/virtio/Makefile
@@ -66,6 +66,7 @@ endif
 ifeq ($(CONFIG_RTE_VIRTIO_QTEST),y)
 SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_qtest/qtest_utils.c
 SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_qtest/virtio_qtest_pci.c
+SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_qtest/virtio_qtest_dev.c
 endif

 # this lib depends upon:
diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index f8972f2..c35d1c0 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -59,7 +59,6 @@
 #include "virtqueue.h"
 #include "virtio_rxtx.h"

-static int eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev);
 static int  virtio_dev_configure(struct rte_eth_dev *dev);
 static int  virtio_dev_start(struct rte_eth_dev *dev);
 static void virtio_dev_stop(struct rte_eth_dev *dev);
@@ -1179,7 +1178,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
return 0;
 }

-static int
+int
 eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
 {
struct rte_pci_device *pci_dev;
diff --git a/drivers/net/virtio/virtio_ethdev.h 
b/drivers/net/virtio/virtio_ethdev.h
index 284afaa..cbb03f5 100644
--- a/drivers/net/virtio/virtio_ethdev.h
+++ b/drivers/net/virtio/virtio_ethdev.h
@@ -114,6 +114,7 @@ uint16_t virtio_xmit_pkts_simple(void *tx_queue, struct 
rte_mbuf **tx_pkts,
uint16_t nb_pkts);

 int eth_virtio_dev_init(struct rte_eth_dev *eth_dev);
+int eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev);

 /*
  * The VIRTIO_NET_F_GUEST_TSO[46] features permit the host to send us
diff --git a/drivers/net/virtio/virtio_qtest/qtest.h 
b/drivers/net/virtio/virtio_qtest/qtest.h
new file mode 100644
index 000..534c5a0
--- /dev/null
+++ b/drivers/net/virtio/virtio_qtest/qtest.h
@@ -0

[dpdk-dev] [PATCH v5 5/6] virtio: Add QTest support to vtpci abstraction

2016-06-02 Thread Tetsuya Mukawa
The patch adds QTest support to vtpci abstraction.
With this patch, only modern virtio device will be supported.
This implementation will be used by later QTest extension patch
of virtio-net PMD.

Signed-off-by: Tetsuya Mukawa 
---
 drivers/net/virtio/Makefile|   1 +
 drivers/net/virtio/virtio_qtest/virtio_qtest_pci.c | 407 +
 drivers/net/virtio/virtio_qtest/virtio_qtest_pci.h |  39 ++
 3 files changed, 447 insertions(+)
 create mode 100644 drivers/net/virtio/virtio_qtest/virtio_qtest_pci.c
 create mode 100644 drivers/net/virtio/virtio_qtest/virtio_qtest_pci.h

diff --git a/drivers/net/virtio/Makefile b/drivers/net/virtio/Makefile
index 0b1ccff..1c86d9d 100644
--- a/drivers/net/virtio/Makefile
+++ b/drivers/net/virtio/Makefile
@@ -65,6 +65,7 @@ endif

 ifeq ($(CONFIG_RTE_VIRTIO_QTEST),y)
 SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_qtest/qtest_utils.c
+SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_qtest/virtio_qtest_pci.c
 endif

 # this lib depends upon:
diff --git a/drivers/net/virtio/virtio_qtest/virtio_qtest_pci.c 
b/drivers/net/virtio/virtio_qtest/virtio_qtest_pci.c
new file mode 100644
index 000..d715b13
--- /dev/null
+++ b/drivers/net/virtio/virtio_qtest/virtio_qtest_pci.c
@@ -0,0 +1,407 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+
+#include "../virtio_logs.h"
+#include "../virtio_pci.h"
+#include "../virtqueue.h"
+
+#include "qtest_utils.h"
+#include "virtio_qtest_pci.h"
+
+static inline int
+check_vq_phys_addr_ok(struct virtqueue *vq)
+{
+   /* Virtio PCI device VIRTIO_PCI_QUEUE_PF register is 32bit,
+* and only accepts 32 bit page frame number.
+* Check if the allocated physical memory exceeds 16TB.
+*/
+   if ((vq->vq_ring_mem + vq->vq_ring_size - 1) >>
+   (VIRTIO_PCI_QUEUE_ADDR_SHIFT + 32)) {
+   PMD_INIT_LOG(ERR, "vring address shouldn't be above 16TB!");
+   return 0;
+   }
+
+   return 1;
+}
+
+static inline uint8_t
+qtest_read8(struct virtio_hw *hw, uint8_t *addr)
+{
+   return qtest_read(hw->virtio_user_dev, (uint64_t)addr, 'b');
+}
+
+static inline void
+qtest_write8(struct virtio_hw *hw, uint8_t val, uint8_t *addr)
+{
+   return qtest_write(hw->virtio_user_dev, (uint64_t)addr, val, 'b');
+}
+
+static inline uint16_t
+qtest_read16(struct virtio_hw *hw, uint16_t *addr)
+{
+   return qtest_read(hw->virtio_user_dev, (uint64_t)addr, 'w');
+}
+
+static inline void
+qtest_write16(struct virtio_hw *hw, uint16_t val, uint16_t *addr)
+{
+   return qtest_write(hw->virtio_user_dev, (uint64_t)addr, val, 'w');
+}
+
+static inline uint32_t
+qtest_read32(struct virtio_hw *hw, uint32_t *addr)
+{
+   return qtest_read(hw->virtio_user_dev, (uint64_t)addr, 'l');
+}
+
+static inline void
+qtest_write32(struct virtio_hw *hw, uint32_t val, uint32_t *addr)
+{
+   return qtest_write(hw->virtio_user_dev, (uint64_t)addr, val, 'l');
+}
+
+static inline void
+qtest_write64_twopart(struct virtio_hw *hw,
+   uint64_t val, uint32_t *lo, uint32_t *hi)
+{
+   qtest_write32(hw, val & ((1ULL << 32) - 1), lo);
+   qtest_write32(h

[dpdk-dev] [PATCH v5 4/6] virtio, qtest: Add misc functions to handle pci information

2016-06-02 Thread Tetsuya Mukawa
The patch adds below functions.
 - qtest_read_pci_cfg
 - qtest_get_bar_addr
 - qtest_get_bar_size
These are used for handling pci device information.
It will be called by later patches.

Signed-off-by: Tetsuya Mukawa 
---
 drivers/net/virtio/virtio_qtest/qtest_utils.c | 77 +++
 drivers/net/virtio/virtio_qtest/qtest_utils.h | 56 +++
 2 files changed, 133 insertions(+)

diff --git a/drivers/net/virtio/virtio_qtest/qtest_utils.c 
b/drivers/net/virtio/virtio_qtest/qtest_utils.c
index 9bc1fca..27118fb 100644
--- a/drivers/net/virtio/virtio_qtest/qtest_utils.c
+++ b/drivers/net/virtio/virtio_qtest/qtest_utils.c
@@ -389,6 +389,83 @@ qtest_find_device(struct qtest_session *s, const char 
*name)
return NULL;
 }

+/*
+ * The function is used for reading pci configuration space of specifed device.
+ */
+int
+qtest_read_pci_cfg(struct qtest_session *s, const char *name,
+   void *buf, size_t len, off_t offset)
+{
+   struct qtest_pci_device *dev;
+   uint32_t i;
+   uint8_t *p = buf;
+
+   dev = qtest_find_device(s, name);
+   if (dev == NULL) {
+   PMD_DRV_LOG(ERR, "Cannot find specified device: %s", name);
+   return -1;
+   }
+
+   for (i = 0; i < len; i++) {
+   *(p + i) = qtest_pci_inb(s,
+   dev->bus_addr, dev->device_addr, 0, offset + i);
+   }
+
+   return 0;
+}
+
+static struct qtest_pci_bar *
+qtest_get_bar(struct qtest_session *s, const char *name, uint8_t bar)
+{
+   struct qtest_pci_device *dev;
+
+   if (bar >= NB_BAR) {
+   PMD_DRV_LOG(ERR, "Invalid bar is specified: %u", bar);
+   return NULL;
+   }
+
+   dev = qtest_find_device(s, name);
+   if (dev == NULL) {
+   PMD_DRV_LOG(ERR, "Cannot find specified device: %s", name);
+   return NULL;
+   }
+
+   if (dev->bar[bar].type == QTEST_PCI_BAR_DISABLE) {
+   PMD_DRV_LOG(ERR, "Cannot find valid BAR(%s): %u", name, bar);
+   return NULL;
+   }
+
+   return >bar[bar];
+}
+
+int
+qtest_get_bar_addr(struct qtest_session *s, const char *name,
+   uint8_t bar, uint64_t **addr)
+{
+   struct qtest_pci_bar *bar_ptr;
+
+   bar_ptr = qtest_get_bar(s, name, bar);
+   if (bar_ptr == NULL)
+   return -1;
+
+   *addr = (uint64_t *)bar_ptr->region_start;
+   return 0;
+}
+
+int
+qtest_get_bar_size(struct qtest_session *s, const char *name,
+   uint8_t bar, uint64_t *size)
+{
+   struct qtest_pci_bar *bar_ptr;
+
+   bar_ptr = qtest_get_bar(s, name, bar);
+   if (bar_ptr == NULL)
+   return -1;
+
+   *size = bar_ptr->region_size;
+   return 0;
+}
+
 static void
 qtest_event_send(struct qtest_session *s, char *buf)
 {
diff --git a/drivers/net/virtio/virtio_qtest/qtest_utils.h 
b/drivers/net/virtio/virtio_qtest/qtest_utils.h
index 6c70552..e41374f 100644
--- a/drivers/net/virtio/virtio_qtest/qtest_utils.h
+++ b/drivers/net/virtio/virtio_qtest/qtest_utils.h
@@ -218,6 +218,62 @@ void qtest_write(struct qtest_session *s, uint64_t addr,

 /**
  * @internal
+ * Read pci configuration space of QEMU guest.
+ *
+ * @param s
+ *   The pointer to qtest session structure.
+ * @param name
+ *   The name of pci device.
+ * @param buf
+ *   The pointer to the buffer.
+ * @param len
+ *   Length to read.
+ * @param offset
+ *   Offset of pci configuration space.
+ * @return
+ *   0 on success, negative on error
+ */
+int qtest_read_pci_cfg(struct qtest_session *s, const char *name,
+   void *buf, size_t len, off_t offset);
+
+/**
+ * @internal
+ * Get BAR address of a specified pci device.
+ *
+ * @param s
+ *   The pointer to qtest session structure.
+ * @param name
+ *   The name of pci device.
+ * @param bar
+ *   The index of BAR. Should be between 0 to 5.
+ * @param addr
+ *   The pointer to store BAR address.
+ * @return
+ *   0 on success, negative on error
+ */
+int qtest_get_bar_addr(struct qtest_session *s, const char *name,
+   uint8_t bar, uint64_t **addr);
+
+/**
+ * @internal
+ * Get BAR size of a specified pci device.
+ *
+ * @param s
+ *   The pointer to qtest session structure.
+ * @param name
+ *   The name of pci device.
+ * @param bar
+ *   The index of BAR. Should be between 0 to 5.
+ * @param size
+ *   The pointer to store BAR size.
+ * @return
+ *   0 on success, negative on error
+ */
+int qtest_get_bar_size(struct qtest_session *s, const char *name,
+   uint8_t bar, uint64_t *size);
+
+/**
+ * @internal
  * Initialization function of general device.
  *
  * @param s
-- 
2.7.4



[dpdk-dev] [PATCH v5 3/6] virtio, qtest: Add functionality to share memory between QTest guest

2016-06-02 Thread Tetsuya Mukawa
The patch adds functionality to share memory between QTest guest and
DPDK application using ivshmem device.
The shared memory will be all EAL memory on hugepages. This memory will
be accessed by QEMU vcpu and DPDK application using same address.

Signed-off-by: Tetsuya Mukawa 
---
 drivers/net/virtio/virtio_qtest/qtest_utils.c | 189 +-
 drivers/net/virtio/virtio_qtest/qtest_utils.h |   4 +-
 2 files changed, 189 insertions(+), 4 deletions(-)

diff --git a/drivers/net/virtio/virtio_qtest/qtest_utils.c 
b/drivers/net/virtio/virtio_qtest/qtest_utils.c
index 2c088f0..9bc1fca 100644
--- a/drivers/net/virtio/virtio_qtest/qtest_utils.c
+++ b/drivers/net/virtio/virtio_qtest/qtest_utils.c
@@ -43,6 +43,9 @@
 #include "../virtio_ethdev.h"
 #include "qtest_utils.h"

+/* ivshmem configuration */
+#define IVSHMEM_PROTOCOL_VERSION0
+
 #define PCI_CONFIG_ADDR(_bus, _device, _function, _offset) ( \
(1 << 31) | ((_bus) & 0xff) << 16 | ((_device) & 0x1f) << 11 | \
((_function) & 0x7) << 8 | ((_offset) & 0xfc))
@@ -59,6 +62,7 @@ union qtest_pipefds {

 struct qtest_session {
int qtest_socket;
+   int ivshmem_socket;
pthread_mutex_t qtest_session_lock;

struct qtest_pci_device_list head;
@@ -411,6 +415,7 @@ qtest_close_sockets(struct qtest_session *s)
qtest_close_one_socket(>qtest_socket);
qtest_close_one_socket(>msgfds.readfd);
qtest_close_one_socket(>msgfds.writefd);
+   qtest_close_one_socket(>ivshmem_socket);
 }

 static void
@@ -716,6 +721,172 @@ qtest_register_target_devices(struct qtest_session *s,
 }

 static int
+qtest_send_message_to_ivshmem(int sock_fd, uint64_t client_id, int shm_fd)
+{
+   struct iovec iov;
+   struct msghdr msgh;
+   size_t fdsize = sizeof(int);
+   char control[CMSG_SPACE(fdsize)];
+   struct cmsghdr *cmsg;
+   int ret;
+
+   memset(, 0, sizeof(msgh));
+   iov.iov_base = _id;
+   iov.iov_len = sizeof(client_id);
+
+   msgh.msg_iov = 
+   msgh.msg_iovlen = 1;
+
+   if (shm_fd >= 0) {
+   msgh.msg_control = 
+   msgh.msg_controllen = sizeof(control);
+   cmsg = CMSG_FIRSTHDR();
+   cmsg->cmsg_len = CMSG_LEN(fdsize);
+   cmsg->cmsg_level = SOL_SOCKET;
+   cmsg->cmsg_type = SCM_RIGHTS;
+   memcpy(CMSG_DATA(cmsg), _fd, fdsize);
+   }
+
+   do {
+   ret = sendmsg(sock_fd, , 0);
+   } while (ret < 0 && errno == EINTR);
+
+   if (ret < 0) {
+   PMD_DRV_LOG(ERR, "sendmsg error");
+   return ret;
+   }
+
+   return ret;
+}
+
+/* This function is came from ../virtio_user/vhost_user.c
+ *
+ * Two possible options:
+ * 1. Match HUGEPAGE_INFO_FMT to find the file storing struct hugepage_file
+ * array. This is simple but cannot be used in secondary process because
+ * secondary process will close and munmap that file.
+ * 2. Match HUGEFILE_FMT to find hugepage files directly.
+ *
+ * We choose option 2.
+ */
+struct hugepage_file_info {
+   uint64_t addr;/**< virtual addr */
+   size_t   size;/**< the file size */
+   char path[PATH_MAX];  /**< path to backing file */
+};
+
+static int
+get_hugepage_file_info(struct hugepage_file_info huges[], int max)
+{
+   int idx;
+   FILE *f;
+   char buf[BUFSIZ], *tmp, *tail;
+   char *str_underline, *str_start;
+   int huge_index;
+   uint64_t v_start, v_end;
+
+   f = fopen("/proc/self/maps", "r");
+   if (!f) {
+   PMD_DRV_LOG(ERR, "cannot open /proc/self/maps");
+   return -1;
+   }
+
+   idx = 0;
+   while (fgets(buf, sizeof(buf), f) != NULL) {
+   sscanf(buf, "%" PRIx64 "-%" PRIx64, _start, _end);
+
+   tmp = strchr(buf, ' ') + 1; /** skip address */
+   tmp = strchr(tmp, ' ') + 1; /** skip perm */
+   tmp = strchr(tmp, ' ') + 1; /** skip offset */
+   tmp = strchr(tmp, ' ') + 1; /** skip dev */
+   tmp = strchr(tmp, ' ') + 1; /** skip inode */
+   while (*tmp == ' ') /** skip spaces */
+   tmp++;
+   tail = strrchr(tmp, '\n');  /** remove newline if exists */
+   if (tail)
+   *tail = '\0';
+
+   /* Match HUGEFILE_FMT, aka "%s/%smap_%d",
+* which is defined in eal_filesystem.h
+*/
+   str_underline = strrchr(tmp, '_');
+   if (!str_underline)
+   continue;
+
+   str_start = str_underline - strlen("map");
+   if (str_start < tmp)
+   continue;
+
+   if (sscanf(str_start, "map

[dpdk-dev] [PATCH v5 2/6] virtio, qtest: Add pci device initialization function to qtest utils

2016-06-02 Thread Tetsuya Mukawa
The patch adds general pci device initialization functionality to
qtest utils. It initializes pci devices using qtest messaging.

Signed-off-by: Tetsuya Mukawa 
---
 drivers/net/virtio/virtio_qtest/qtest_utils.c | 349 +-
 drivers/net/virtio/virtio_qtest/qtest_utils.h | 114 -
 2 files changed, 461 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/virtio_qtest/qtest_utils.c 
b/drivers/net/virtio/virtio_qtest/qtest_utils.c
index 3ad8f9e..2c088f0 100644
--- a/drivers/net/virtio/virtio_qtest/qtest_utils.c
+++ b/drivers/net/virtio/virtio_qtest/qtest_utils.c
@@ -43,6 +43,10 @@
 #include "../virtio_ethdev.h"
 #include "qtest_utils.h"

+#define PCI_CONFIG_ADDR(_bus, _device, _function, _offset) ( \
+   (1 << 31) | ((_bus) & 0xff) << 16 | ((_device) & 0x1f) << 11 | \
+   ((_function) & 0x7) << 8 | ((_offset) & 0xfc))
+
 union qtest_pipefds {
struct {
int pipefd[2];
@@ -57,6 +61,8 @@ struct qtest_session {
int qtest_socket;
pthread_mutex_t qtest_session_lock;

+   struct qtest_pci_device_list head;
+
pthread_t event_th;
int event_th_started;
char *evq;
@@ -195,6 +201,119 @@ qtest_raw_write(struct qtest_session *s, uint64_t addr, 
uint32_t val, char type)
 }

 /*
+ * qtest_pci_inX/outX are used for accessing PCI configuration space.
+ * The functions are implemented based on PCI configuration space
+ * specification.
+ * Accroding to the spec, access size of read()/write() should be 4 bytes.
+ */
+static int
+qtest_pci_inb(struct qtest_session *s, uint8_t bus, uint8_t device,
+   uint8_t function, uint8_t offset)
+{
+   uint32_t tmp;
+
+   tmp = PCI_CONFIG_ADDR(bus, device, function, offset);
+
+   if (pthread_mutex_lock(>qtest_session_lock) < 0)
+   rte_panic("Cannot lock mutex\n");
+
+   qtest_raw_out(s, 0xcf8, tmp, 'l');
+   tmp = qtest_raw_in(s, 0xcfc, 'l');
+
+   if (pthread_mutex_unlock(>qtest_session_lock) < 0)
+   rte_panic("Cannot unlock mutex\n");
+
+   return (tmp >> ((offset & 0x3) * 8)) & 0xff;
+}
+
+static uint32_t
+qtest_pci_inl(struct qtest_session *s, uint8_t bus, uint8_t device,
+   uint8_t function, uint8_t offset)
+{
+   uint32_t tmp;
+
+   tmp = PCI_CONFIG_ADDR(bus, device, function, offset);
+
+   if (pthread_mutex_lock(>qtest_session_lock) < 0)
+   rte_panic("Cannot lock mutex\n");
+
+   qtest_raw_out(s, 0xcf8, tmp, 'l');
+   tmp = qtest_raw_in(s, 0xcfc, 'l');
+
+   if (pthread_mutex_unlock(>qtest_session_lock) < 0)
+   rte_panic("Cannot unlock mutex\n");
+
+   return tmp;
+}
+
+static void
+qtest_pci_outl(struct qtest_session *s, uint8_t bus, uint8_t device,
+   uint8_t function, uint8_t offset, uint32_t value)
+{
+   uint32_t tmp;
+
+   tmp = PCI_CONFIG_ADDR(bus, device, function, offset);
+
+   if (pthread_mutex_lock(>qtest_session_lock) < 0)
+   rte_panic("Cannot lock mutex\n");
+
+   qtest_raw_out(s, 0xcf8, tmp, 'l');
+   qtest_raw_out(s, 0xcfc, value, 'l');
+
+   if (pthread_mutex_unlock(>qtest_session_lock) < 0)
+   rte_panic("Cannot unlock mutex\n");
+}
+
+static uint64_t
+qtest_pci_inq(struct qtest_session *s, uint8_t bus, uint8_t device,
+   uint8_t function, uint8_t offset)
+{
+   uint32_t tmp;
+   uint64_t val;
+
+   tmp = PCI_CONFIG_ADDR(bus, device, function, offset);
+
+   if (pthread_mutex_lock(>qtest_session_lock) < 0)
+   rte_panic("Cannot lock mutex\n");
+
+   qtest_raw_out(s, 0xcf8, tmp, 'l');
+   val = (uint64_t)qtest_raw_in(s, 0xcfc, 'l');
+
+   tmp = PCI_CONFIG_ADDR(bus, device, function, offset + 4);
+
+   qtest_raw_out(s, 0xcf8, tmp, 'l');
+   val |= (uint64_t)qtest_raw_in(s, 0xcfc, 'l') << 32;
+
+   if (pthread_mutex_unlock(>qtest_session_lock) < 0)
+   rte_panic("Cannot unlock mutex\n");
+
+   return val;
+}
+
+static void
+qtest_pci_outq(struct qtest_session *s, uint8_t bus, uint8_t device,
+   uint8_t function, uint8_t offset, uint64_t value)
+{
+   uint32_t tmp;
+
+   tmp = PCI_CONFIG_ADDR(bus, device, function, offset);
+
+   if (pthread_mutex_lock(>qtest_session_lock) < 0)
+   rte_panic("Cannot lock mutex\n");
+
+   qtest_raw_out(s, 0xcf8, tmp, 'l');
+   qtest_raw_out(s, 0xcfc, (uint32_t)(value & 0x), 'l');
+
+   tmp = PCI_CONFIG_ADDR(bus, device, function, offset + 4);
+
+   qtest_raw_out(s, 0xcf8, tmp, 'l');
+   qtest_raw_out(s, 0xcfc, (uint32_t)(value >> 32), 'l');
+
+   if (pthread_mutex_unlock(>qtest_session_lock) < 0)
+   rte_panic("Cannot unlock mutex

[dpdk-dev] [PATCH v5 1/6] virtio, qtest: Add QTest utility basic functions

2016-06-02 Thread Tetsuya Mukawa
The patch adds basic functions for accessing to QEMU quest that runs in
QTest mode. The functions will be used by virtio container extension
that can access to the above guest.

Signed-off-by: Tetsuya Mukawa 
---
 config/common_linuxapp|   2 +
 drivers/net/virtio/Makefile   |   4 +
 drivers/net/virtio/virtio_qtest/qtest_utils.c | 480 ++
 drivers/net/virtio/virtio_qtest/qtest_utils.h | 119 +++
 4 files changed, 605 insertions(+)
 create mode 100644 drivers/net/virtio/virtio_qtest/qtest_utils.c
 create mode 100644 drivers/net/virtio/virtio_qtest/qtest_utils.h

diff --git a/config/common_linuxapp b/config/common_linuxapp
index 946a6d4..3bf6237 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -46,3 +46,5 @@ CONFIG_RTE_LIBRTE_POWER=y

 # Enable virtio-user
 CONFIG_RTE_VIRTIO_VDEV=y
+# Enable virtio-qtest
+CONFIG_RTE_VIRTIO_QTEST=y
diff --git a/drivers/net/virtio/Makefile b/drivers/net/virtio/Makefile
index 13b2b75..0b1ccff 100644
--- a/drivers/net/virtio/Makefile
+++ b/drivers/net/virtio/Makefile
@@ -63,6 +63,10 @@ SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += 
virtio_user/virtio_user_dev.c
 SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_user/virtio_user_pci.c
 endif

+ifeq ($(CONFIG_RTE_VIRTIO_QTEST),y)
+SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_qtest/qtest_utils.c
+endif
+
 # this lib depends upon:
 DEPDIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += lib/librte_eal lib/librte_ether
 DEPDIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += lib/librte_mempool lib/librte_mbuf
diff --git a/drivers/net/virtio/virtio_qtest/qtest_utils.c 
b/drivers/net/virtio/virtio_qtest/qtest_utils.c
new file mode 100644
index 000..3ad8f9e
--- /dev/null
+++ b/drivers/net/virtio/virtio_qtest/qtest_utils.c
@@ -0,0 +1,480 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2016 IGEL Co., Ltd. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of IGEL Co., Ltd. nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "../virtio_logs.h"
+#include "../virtio_ethdev.h"
+#include "qtest_utils.h"
+
+union qtest_pipefds {
+   struct {
+   int pipefd[2];
+   };
+   struct {
+   int readfd;
+   int writefd;
+   };
+};
+
+struct qtest_session {
+   int qtest_socket;
+   pthread_mutex_t qtest_session_lock;
+
+   pthread_t event_th;
+   int event_th_started;
+   char *evq;
+   char *evq_dequeue_ptr;
+   size_t evq_total_len;
+
+   union qtest_pipefds msgfds;
+};
+
+static int
+qtest_raw_send(int fd, char *buf, size_t count)
+{
+   size_t len = count;
+   size_t total_len = 0;
+   int ret = 0;
+
+   while (len > 0) {
+   ret = write(fd, buf, len);
+   if (ret == -1) {
+   if (errno == EINTR)
+   continue;
+   return ret;
+   }
+   if (ret == (int)len)
+   break;
+   total_len += ret;
+   buf += ret;
+   len -= ret;
+   }
+   return total_len + ret;
+}
+
+static int
+qtest_raw_recv(int fd, char *buf, size_t count)
+{
+   size_t len = count;
+   size_t total_len = 0;
+   int ret = 0;
+
+   while (len > 0) {
+   ret = read(fd, buf, len);
+   if (ret <

[dpdk-dev] [PATCH v5 0/6] Virtio-net PMD: QEMU QTest extension for container

2016-06-02 Thread Tetsuya Mukawa
ionality is 
used.
QTest is a test framework of QEMU devices. It allows us to implement a device 
driver outside of QEMU.
With QTest, we can implement DPDK application and virtio-net PMD as standalone 
process on host.
When QEMU is invoked as QTest mode, any guest code will not run.
To know more about QTest, see below.
http://wiki.qemu.org/Features/QTest

 - probing devices
QTest provides a unix domain socket. Through this socket, driver process can 
access to I/O port and memory of QEMU virtual machine.
The PMD will send I/O port accesses to probe pci devices.
If we can find virtio-net and ivshmem device, initialize the devices.
Also, I/O port accesses of virtio-net PMD will be sent through socket, and 
virtio-net PMD can initialize vitio-net device on QEMU correctly.

 - ivshmem device to share memory
To share memory that virtio-net PMD process uses, ivshmem device will be used.
Because ivshmem device can only handle one file descriptor, shared memory 
should be consist of one file.
To allocate such a memory, EAL has new option called "--single-file".
Also, the hugepages should be mapped between "1 << 31" to "1 << 44".
To map like above, use '--base-virtaddr' option.
While initializing ivshmem device, we can set BAR(Base Address Register).
It represents which memory QEMU vcpu can access to this shared memory.
We will specify host virtual address of shared memory as this address.
It is very useful because we don't need to apply patch to QEMU to calculate 
address offset.
(For example, if virtio-net PMD process will allocate memory from shared 
memory, then specify the virtual address of it to virtio-net register, QEMU 
virtio-net device can understand it without calculating address offset.)



Tetsuya Mukawa (6):
  virtio, qtest: Add QTest utility basic functions
  virtio, qtest: Add pci device initialization function to qtest utils
  virtio, qtest: Add functionality to share memory between QTest guest
  virtio, qtest: Add misc functions to handle pci information
  virtio: Add QTest support to vtpci abstraction
  virtio: Add QTest support for virtio-net PMD

 config/common_linuxapp |2 +
 drivers/net/virtio/Makefile|6 +
 drivers/net/virtio/virtio_ethdev.c |3 +-
 drivers/net/virtio/virtio_ethdev.h |1 +
 drivers/net/virtio/virtio_qtest/qtest.h|   95 ++
 drivers/net/virtio/virtio_qtest/qtest_utils.c  | 1087 
 drivers/net/virtio/virtio_qtest/qtest_utils.h  |  289 ++
 drivers/net/virtio/virtio_qtest/virtio_qtest_dev.c |  393 +++
 drivers/net/virtio/virtio_qtest/virtio_qtest_dev.h |   42 +
 drivers/net/virtio/virtio_qtest/virtio_qtest_pci.c |  407 
 drivers/net/virtio/virtio_qtest/virtio_qtest_pci.h |   39 +
 drivers/net/virtio/virtqueue.h |6 +-
 12 files changed, 2365 insertions(+), 5 deletions(-)
 create mode 100644 drivers/net/virtio/virtio_qtest/qtest.h
 create mode 100644 drivers/net/virtio/virtio_qtest/qtest_utils.c
 create mode 100644 drivers/net/virtio/virtio_qtest/qtest_utils.h
 create mode 100644 drivers/net/virtio/virtio_qtest/virtio_qtest_dev.c
 create mode 100644 drivers/net/virtio/virtio_qtest/virtio_qtest_dev.h
 create mode 100644 drivers/net/virtio/virtio_qtest/virtio_qtest_pci.c
 create mode 100644 drivers/net/virtio/virtio_qtest/virtio_qtest_pci.h

-- 
2.7.4



[dpdk-dev] [PATCH v1] null: set port_id in mbufs received from null PMD

2016-05-30 Thread Tetsuya Mukawa
On 2016/05/27 21:28, Mcnamara, John wrote:
>> -Original Message-
>> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Sean Harte
>> Sent: Friday, May 27, 2016 1:27 PM
>> To: mukawa at igel.co.jp
>> Cc: dev at dpdk.org; Harte, Sean 
>> Subject: [dpdk-dev] [PATCH v1] null: set port_id in mbufs received from
>> null PMD
>>
>> Ensure that the port field is set in mbufs received from the null PMD.
>>
>> Signed-off-by: Sean Harte 
> Acked-by: John McNamara 
>
Acked-by: Tetsuya Mukawa 



[dpdk-dev] [PATCH] mk: add build-time library directory to linker path

2016-04-28 Thread Tetsuya Mukawa
On 2016/04/27 20:02, Panu Matilainen wrote:
> This is a pre-requisite for adding DT_NEEDED dependencies
> between internal libraries.
>
> Signed-off-by: Panu Matilainen 
> ---
>  mk/rte.lib.mk | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mk/rte.lib.mk b/mk/rte.lib.mk
> index 8f7e021..b420280 100644
> --- a/mk/rte.lib.mk
> +++ b/mk/rte.lib.mk
> @@ -86,8 +86,8 @@ O_TO_A_DO = @set -e; \
>   $(O_TO_A) && \
>   echo $(O_TO_A_CMD) > $(call exe2cmd,$(@))
>  
> -O_TO_S = $(LD) $(_CPU_LDFLAGS) $(EXTRA_LDFLAGS) -shared $(OBJS-y) $(LDLIBS) \
> -  -Wl,-soname,$(LIB) -o $(LIB)
> +O_TO_S = $(LD) -L$(RTE_OUTPUT)/lib $(_CPU_LDFLAGS) $(EXTRA_LDFLAGS) \
> +   -shared $(OBJS-y) $(LDLIBS) -Wl,-soname,$(LIB) -o $(LIB)
>  O_TO_S_STR = $(subst ','\'',$(O_TO_S)) #'# fix syntax highlight
>  O_TO_S_DISP = $(if $(V),"$(O_TO_S_STR)","  LD $(@)")
>  O_TO_S_DO = @set -e; \
Tested-by: Tetsuya Mukawa 


[dpdk-dev] [PATCH v2] vhost: Fix linkage of vhost PMD

2016-04-27 Thread Tetsuya Mukawa
On 2016/04/26 18:35, Panu Matilainen wrote:
> On 04/26/2016 08:39 AM, Tetsuya Mukawa wrote:
>> Currently, vhost PMD doesn't have linkage for librte_vhost, even though
>> it depends on librte_vhost APIs. This causes a linkage error if below
>> conditions are fulfilled.
>>
>>  - DPDK libraries are compiled as shared libraries.
>>  - DPDK application doesn't link librte_vhost.
>>  - Above application tries to link vhost PMD using '-d' DPDK option.
>>
>> The patch adds linkage for librte_vhost to vhost PMD not to cause an
>> above error.
>>
>> Signed-off-by: Tetsuya Mukawa 
>> Acked-by: Panu Matilainen 
>> ---
>>  drivers/net/vhost/Makefile | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/net/vhost/Makefile b/drivers/net/vhost/Makefile
>> index f49a69b..30b91a0 100644
>> --- a/drivers/net/vhost/Makefile
>> +++ b/drivers/net/vhost/Makefile
>> @@ -38,6 +38,7 @@ LIB = librte_pmd_vhost.a
>>
>>  CFLAGS += -O3
>>  CFLAGS += $(WERROR_FLAGS)
>> +LDLIBS += -lrte_vhost
>>
>>  EXPORT_MAP := rte_pmd_vhost_version.map
>>
>>
>
> Hmm, turns out this isn't quite enough, simply because its the first
> of its kind (first internal dependency between libraries), at least
> I'm getting:
>
> == Build drivers/net/vhost
> gcc -m64
> -Wl,--version-script=/srv/work/dist/dpdk/dpdk-16.04/drivers/net/vhost/rte_pmd_vhost_version.map
>  -shared rte_eth_vhost.o -lrte_vhost -Wl,-soname,librte_pmd_vhost.so.1
> -o librte_pmd_vhost.so.1
> /usr/bin/ld: cannot find -lrte_vhost
> collect2: error: ld returned 1 exit status
> /srv/work/dist/dpdk/dpdk-16.04/mk/rte.lib.mk:127: recipe for target
> 'librte_pmd_vhost.so.1' failed
>
> So it'll need something like this as a pre-requisite to add the
> internal libraries to the linker path:
>
> diff --git a/mk/rte.lib.mk b/mk/rte.lib.mk
> index 8f7e021..f5d7b04 100644
> --- a/mk/rte.lib.mk
> +++ b/mk/rte.lib.mk
> @@ -86,7 +86,7 @@ O_TO_A_DO = @set -e; \
> $(O_TO_A) && \
> echo $(O_TO_A_CMD) > $(call exe2cmd,$(@))
>
> -O_TO_S = $(LD) $(_CPU_LDFLAGS) $(EXTRA_LDFLAGS) -shared $(OBJS-y)
> $(LDLIBS) \
> +O_TO_S = $(LD) -L$(RTE_OUTPUT)/lib $(_CPU_LDFLAGS) $(EXTRA_LDFLAGS)
> -shared $(OBJS-y) $(LDLIBS) \
>  -Wl,-soname,$(LIB) -o $(LIB)
>  O_TO_S_STR = $(subst ','\'',$(O_TO_S)) #'# fix syntax highlight
>  O_TO_S_DISP = $(if $(V),"$(O_TO_S_STR)","  LD $(@)")
>
>
> I can submit an official patch for this later but I'm not exactly
> feeling like the sharpest knife in the drawer today so if somebody
> beats me to it, feel free.
>
> - Panu -

Thanks for catching it.
It seems I've already installed DPDK libraries in /usr/local/lib/. Then
, I could not catch this error.
I've confirmed your solution works fine.

Thanks,
Tetsuya


[dpdk-dev] [RFC] Link ibrte_vhost to librte_pmd_vhost

2016-04-26 Thread Tetsuya Mukawa
On 2016/04/26 14:48, Yuanhan Liu wrote:
> On Tue, Apr 26, 2016 at 02:37:37PM +0900, Tetsuya Mukawa wrote:
>> On 2016/04/26 12:47, Yuanhan Liu wrote:
>>> On Mon, Apr 25, 2016 at 12:28:37PM +0300, Panu Matilainen wrote:
>>>  >
>>>>> Another way is applying a below patch.
>>>>> --- a/drivers/net/vhost/Makefile
>>>>> +++ b/drivers/net/vhost/Makefile
>>>>> @@ -38,6 +38,7 @@ LIB = librte_pmd_vhost.a
>>>>>
>>>>>  CFLAGS += -O3
>>>>>  CFLAGS += $(WERROR_FLAGS)
>>>>> +LDLIBS += -lrte_vhost
>>>>>
>>>>>  EXPORT_MAP := rte_pmd_vhost_version.map
>>>>>
>>>>> This is same way to link libpcap to librte_pmd_pcap.
>>>>> What do you think about adding it to vhost PMD?
>>>> Yes, this is absolutely the right thing to do.
>>>>
>>>> Ultimately this should be done for all dependencies in all libraries, but
>>>> missing dependencies are even more pronounced in plugins so the sooner this
>>>> goes in, the better.
>>>>
>>>> Acked-by: Panu Matilainen 
>>> Panu, thanks for the input.
>>>
>>> Tetsuya, please submit a formal patch so that I can merge.
>>>
>>> --yliu
>> Hi Yuanhan,
>>
>> Oh sorry, I forgot to add "--in-reply-to" while sending the patch, so
>> you may miss it.
>> Also the order of Acked-by and Signed-off-by was wrong in above patch.
>> So I will send v2 soon.
> No worry. I could fix them, and I don't think there is a very strict
> rule for both of them :) BTW, FYI, I just found my linux.intel.com
> seems to be broken (no idea why), thus I made late response.
>
> (well, I found you just send a v2; I will apply that tomorrow).
>
>   --yliu

Thank you so much!

Tetsuya


[dpdk-dev] [PATCH v2] vhost: Fix linkage of vhost PMD

2016-04-26 Thread Tetsuya Mukawa
Currently, vhost PMD doesn't have linkage for librte_vhost, even though
it depends on librte_vhost APIs. This causes a linkage error if below
conditions are fulfilled.

 - DPDK libraries are compiled as shared libraries.
 - DPDK application doesn't link librte_vhost.
 - Above application tries to link vhost PMD using '-d' DPDK option.

The patch adds linkage for librte_vhost to vhost PMD not to cause an
above error.

Signed-off-by: Tetsuya Mukawa 
Acked-by: Panu Matilainen 
---
 drivers/net/vhost/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/vhost/Makefile b/drivers/net/vhost/Makefile
index f49a69b..30b91a0 100644
--- a/drivers/net/vhost/Makefile
+++ b/drivers/net/vhost/Makefile
@@ -38,6 +38,7 @@ LIB = librte_pmd_vhost.a

 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+LDLIBS += -lrte_vhost

 EXPORT_MAP := rte_pmd_vhost_version.map

-- 
2.5.0



[dpdk-dev] [RFC] Link ibrte_vhost to librte_pmd_vhost

2016-04-26 Thread Tetsuya Mukawa
On 2016/04/26 12:47, Yuanhan Liu wrote:
> On Mon, Apr 25, 2016 at 12:28:37PM +0300, Panu Matilainen wrote:
>  >
>>> Another way is applying a below patch.
>>> --- a/drivers/net/vhost/Makefile
>>> +++ b/drivers/net/vhost/Makefile
>>> @@ -38,6 +38,7 @@ LIB = librte_pmd_vhost.a
>>>
>>>  CFLAGS += -O3
>>>  CFLAGS += $(WERROR_FLAGS)
>>> +LDLIBS += -lrte_vhost
>>>
>>>  EXPORT_MAP := rte_pmd_vhost_version.map
>>>
>>> This is same way to link libpcap to librte_pmd_pcap.
>>> What do you think about adding it to vhost PMD?
>> Yes, this is absolutely the right thing to do.
>>
>> Ultimately this should be done for all dependencies in all libraries, but
>> missing dependencies are even more pronounced in plugins so the sooner this
>> goes in, the better.
>>
>> Acked-by: Panu Matilainen 
> Panu, thanks for the input.
>
> Tetsuya, please submit a formal patch so that I can merge.
>
>   --yliu

Hi Yuanhan,

Oh sorry, I forgot to add "--in-reply-to" while sending the patch, so
you may miss it.
Also the order of Acked-by and Signed-off-by was wrong in above patch.
So I will send v2 soon.

Thanks,
Tetsuya


[dpdk-dev] [PATCH] vhost: Fix linkage of vhost PMD

2016-04-26 Thread Tetsuya Mukawa
Currently, vhost PMD doesn't have linkage for librte_vhost, even though
it depends on librte_vhost APIs. This causes a linkage error if below
conditions are fulfilled.

 - DPDK libraries are compiled as shared libraries.
 - DPDK application doesn't link librte_vhost.
 - Above application tries to link vhost PMD using '-d' DPDK option.

The patch adds linkage for librte_vhost to vhost PMD not to cause an
above error.

Acked-by: Panu Matilainen 
Signed-off-by: Tetsuya Mukawa 
---
 drivers/net/vhost/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/vhost/Makefile b/drivers/net/vhost/Makefile
index f49a69b..30b91a0 100644
--- a/drivers/net/vhost/Makefile
+++ b/drivers/net/vhost/Makefile
@@ -38,6 +38,7 @@ LIB = librte_pmd_vhost.a

 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+LDLIBS += -lrte_vhost

 EXPORT_MAP := rte_pmd_vhost_version.map

-- 
2.5.0



[dpdk-dev] Git repository might be down

2016-04-25 Thread Tetsuya Mukawa
Hi,

I've faced below error while connecting to DPDK git repository.

$ git clone git://dpdk.org/dpdk
Cloning into 'dpdk'...
fatal: read error: Connection reset by peer

It might be caused by my environment, but report it just in case.

Thanks,
Tetsuya


[dpdk-dev] [RFC] Link ibrte_vhost to librte_pmd_vhost

2016-04-25 Thread Tetsuya Mukawa
On 2016/04/25 18:28, Panu Matilainen wrote:
> On 04/25/2016 12:05 PM, Tetsuya Mukawa wrote:
>> Hi Yuanhan,
>>
>> I want to apply a patch to vhost PMD.
>> Before submitting, could you please let me know your guess about the
>> patch?
>>
>> Here is my problem.
>> I am using below shared library configuration to build my application.
>> CONFIG_RTE_BUILD_SHARED_LIB=y
>> Normally, My application doesn't need vhost facilities, so librte_vhost
>> isn't linked while compiling.
>>
>> Sometimes, I need to use vhost PMD, so I just want to add '-d
>> librte_pmd_vhost.so' to DPDK command line to load vhost PMD library.
>> But my application doesn't have librte_vhost, then I've got an error
>> about it.
>> Even if specify like "-d librte_vhost -d librte_pmd_vhost", I still have
>> an error.
>> Probably this is because above libraries will be dlopen(ed) with
>> RTLD_LOCAL option.
>>
>> Here, I have 2 choices.
>> One is linking librte_vhost to my application while compiling, even if I
>> don't need it normally.
>> This is the way all DPDK examples did. But I am wondering if I should
>> follow this.
>>
>> Another way is applying a below patch.
>> --- a/drivers/net/vhost/Makefile
>> +++ b/drivers/net/vhost/Makefile
>> @@ -38,6 +38,7 @@ LIB = librte_pmd_vhost.a
>>
>>   CFLAGS += -O3
>>   CFLAGS += $(WERROR_FLAGS)
>> +LDLIBS += -lrte_vhost
>>
>>   EXPORT_MAP := rte_pmd_vhost_version.map
>>
>> This is same way to link libpcap to librte_pmd_pcap.
>> What do you think about adding it to vhost PMD?
>
> Yes, this is absolutely the right thing to do.
>
> Ultimately this should be done for all dependencies in all libraries,
> but missing dependencies are even more pronounced in plugins so the
> sooner this goes in, the better.
>
> Acked-by: Panu Matilainen 
>
> - Panu -

Hi Panu,

I appreciate your comment.
I will send it as a patch tomorrow.
It seems I cannot connect to DPDK git repository so far. So I cannot
test it with latest code.

Thanks,
Tetsuya

>
>
>>
>> Thanks,
>> Tetsuya
>>
>



[dpdk-dev] [RFC] Link ibrte_vhost to librte_pmd_vhost

2016-04-25 Thread Tetsuya Mukawa
Hi Yuanhan,

I want to apply a patch to vhost PMD.
Before submitting, could you please let me know your guess about the patch?

Here is my problem.
I am using below shared library configuration to build my application.
CONFIG_RTE_BUILD_SHARED_LIB=y
Normally, My application doesn't need vhost facilities, so librte_vhost
isn't linked while compiling.

Sometimes, I need to use vhost PMD, so I just want to add '-d
librte_pmd_vhost.so' to DPDK command line to load vhost PMD library.
But my application doesn't have librte_vhost, then I've got an error
about it.
Even if specify like "-d librte_vhost -d librte_pmd_vhost", I still have
an error.
Probably this is because above libraries will be dlopen(ed) with
RTLD_LOCAL option.

Here, I have 2 choices.
One is linking librte_vhost to my application while compiling, even if I
don't need it normally.
This is the way all DPDK examples did. But I am wondering if I should
follow this.

Another way is applying a below patch.
--- a/drivers/net/vhost/Makefile
+++ b/drivers/net/vhost/Makefile
@@ -38,6 +38,7 @@ LIB = librte_pmd_vhost.a

 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+LDLIBS += -lrte_vhost

 EXPORT_MAP := rte_pmd_vhost_version.map

This is same way to link libpcap to librte_pmd_pcap.
What do you think about adding it to vhost PMD?

Thanks,
Tetsuya


[dpdk-dev] [Announce] A new tree for vhost/virtio

2016-04-19 Thread Tetsuya Mukawa
On 2016/04/19 3:55, Yuanhan Liu wrote:
> Hi,
>
> Here I'd like to announce a new tree for vhost/virtio[0], and I'm
> going to be the maintainer.
>
> [0]: http://dpdk.org/browse/next/dpdk-next-virtio/
>
> This is done by a private request to Thomas few days ago (well, I'd
> confess this should have been a public request/discussion, and you
> can find it in the end of this email).
>
> And this is for merging patches a bit faster, especially for those
> fix and cleanup patches. Note that it still takes time to merge
> feature patches, even those from myself. Another note is that this
> tree is meant to be rebaseable.
>
> You are suggested to make virtio/vhost patches based on this tree,
> to reduce patch conflict chance.
>
> @Tetsuya, do you mind if I take over patches for vhost-pmd as well?

Yes, could you please.

Thanks,
Tetsuya

>
> Thanks.
>
>   --yliu
>
> - Forwarded message from Yuanhan Liu  
> -
>
> Date: Wed, 13 Apr 2016 01:53:41 +0800
> From: Yuanhan Liu 
> To: Thomas Monjalon 
> Cc: Bruce Richardson , "Zhu, Heqing" 
> ,
>   Yuanhan Liu 
> Subject: A request to take over vhost/virtio patches (was Re: [dpdk-dev] 
> dpdk: vhost/virtio
>   staging/testing tree)
> User-Agent: Mutt/1.5.23 (2014-03-12)
>
> Hi Thomas,
>
> Due to the nature of vhost/virtio (being open standard), we have more
> external contributors (not from intel) than other components: I just
> wrote a script to count that (the number means the # of contributors
> not from intel, and the date is got from this release only):
>
> vhost|virtio: 10
> doc: 10
> ethdev: 9
> eal: 9
> mlx: 8
> mk: 7
> mlx5: 6
> app/test: 6
> examples: 5
> config: 5
> tools: 4
> mlx4: 4
> eal/linux: 4
> bonding: 4
> vmxnet3: 3
> nfp: 3
> mbuf: 3
> lpm: 3
> ixgbe: 3
> igb: 3
> i40e: 3
>
> As you can see, vhost/virtio is on the top of the list, which is a
> great thing: it means we have a health community. We have done well
> to achieve that, however, I'm thinking we could do better: to be
> more active on patch reviewing/merging, to try to solve some problems
> I found as I stated in my following email.
>
> Therefore, I'd like to request again to take over all vhost/virtio
> patches. In another word, I'd like to maintain another tree, like
> Bruce does for dpdk-next-net tree, and to apply patches in time.
>
> And now, I'd like to introduce myself a bit, and hopefully this
> could convince you that I'm competent to the committer role, though
> you might have already known that from my recent performs :)
>
> I have been working on open source projects since 2009. Till now,
> it would be about 7 years of experience on open source. My first
> project was Syslinux, later on, I have worked on few more projects,
> including Linux Kernel, Mesa and so on. Therefore, I'm sure that
> my rich experience on open source would definitely let me be
> capable of the new role.
>
> Thanks.
>
>   --yliu
>
>
> On Tue, Feb 16, 2016 at 12:02:42PM +0800, Yuanhan Liu wrote:
>> On Fri, Feb 12, 2016 at 01:54:21PM +0200, Victor Kaplansky wrote:
>>> Hi!
>> Hi Victor,
>>
>>> Since I was maintaining an internal tree with patches related to
>>> vhost/virtio, I decided to make this staging tree public. It is
>>> useful to me and I hope it will be useful to others.
>>>
>>> Collecting patches like this allows tracking dependencies between
>>> patches, their improvement etc. I also rebase the tree so
>>> contributors don't have to.
>> I had same thoughts, before, aiming to speed the patch review and
>> merge process.
>>
>> DPDK community, likely, has a culture of very slow patch review and
>> merge process: I often saw patches not get reviewed for weeks, even
>> months! I also saw that a patch has been ACK-ed, but not get merged
>> until few weeks has been passed. While I am inside the team, I
>> understand it's a very reasonable phenomenon: every one of us has
>> lots of tasks to do, and we intend to do the review after all tasks
>> have been finished.
>>
>> Despite the fact, I was thinking that I could maintain a tree, so
>> that I could apply all virtio/vhost patches that has been ACKed in
>> the first time. Later, I will send pull request to Thomas, from
>> time to time. Thomas, on the other hand, only need to have a double
>> check of the patches from my request. If he has any concerns on
>> some specific patch (or patch set), I will drop them, and let the
>> author to send a new version.
>>
>> Put simply, it's a similar style Linux kernel (and QEMU) takes.
>>
>> Another thing worthy noting is that Bruce started to maintain
>> a such tree recently:
>>
>> http://dpdk.org/browse/next/dpdk-next-net/
>>
>> So, as long as Bruce merges patches quickly, it should not matter.
>>
>>> Before publishing, I test the tree so it can serve as a known
>>> good state for people interested in preliminary testing of
>>> patches that aren't yet upstream, improving testing/validation as
>>> multiple 

[dpdk-dev] [PATCH] vhost: call rte_vhost_enable_guest_notification only on enabled queues

2016-04-08 Thread Tetsuya Mukawa
On 2016/04/08 15:14, Yuanhan Liu wrote:
> On Fri, Apr 08, 2016 at 10:45:33AM +0900, Tetsuya Mukawa wrote:
>> On 2016/04/08 2:20, Thomas Monjalon wrote:
>>>>> If the vhost PMD were configured with more queues than the guest, the old
>>>>> code would segfault in rte_vhost_enable_guest_notification due to a NULL
>>>>> virtqueue pointer.
>>>>>
>>>>> Fixes: ee584e9710b9 ("vhost: add driver on top of the library")
>>>>> Signed-off-by: Rich Lane 
>>>> Acked-by: Yuanhan Liu 
>>> Applied, thanks
>> Hi Rich and Yuanhan,
>>
>> I am sorry for late reply. I was out of office yesterday.
> Tetsuya, no worry! Man takes leaves, and isn't the reason we have 2 or
> more maintainers on some blocks? :)
>
>   --yliu

Yeah, thanks!

Tetsuya


[dpdk-dev] [PATCH] vhost: call rte_vhost_enable_guest_notification only on enabled queues

2016-04-08 Thread Tetsuya Mukawa
On 2016/04/08 2:20, Thomas Monjalon wrote:
>>> If the vhost PMD were configured with more queues than the guest, the old
>>> code would segfault in rte_vhost_enable_guest_notification due to a NULL
>>> virtqueue pointer.
>>>
>>> Fixes: ee584e9710b9 ("vhost: add driver on top of the library")
>>> Signed-off-by: Rich Lane 
>> Acked-by: Yuanhan Liu 
> Applied, thanks

Hi Rich and Yuanhan,

I am sorry for late reply. I was out of office yesterday.
I've tested it also today, and seems to be good.

Thanks,
Tetsuya


[dpdk-dev] [PATCH] vhost: Fix retrieval of numa information in PMD

2016-04-06 Thread Tetsuya Mukawa
On 2016/04/06 16:17, Yuanhan Liu wrote:
> On Wed, Apr 06, 2016 at 03:49:25PM +0900, Tetsuya Mukawa wrote:
>> On 2016/04/06 1:09, Ciara Loftus wrote:
>>> After some testing, it was found that retrieving numa information
>>> about a vhost device via a call to get_mempolicy is more
>>> accurate when performed during the new_device callback versus
>>> the vring_state_changed callback, in particular upon initial boot
>>> of the VM.  Performing this check during new_device is also
>>> potentially more efficient as this callback is only triggered once
>>> during device initialisation, compared with vring_state_changed
>>> which may be called multiple times depending on the number of
>>> queues assigned to the device.
>>>
>>> Reorganise the code to perform this check and assign the correct
>>> socket_id to the device during the new_device callback.
>>>
>>> Signed-off-by: Ciara Loftus 
>>> ---
>>>  drivers/net/vhost/rte_eth_vhost.c | 28 ++--
>>>  1 file changed, 14 insertions(+), 14 deletions(-)
>>>
>>> diff --git a/drivers/net/vhost/rte_eth_vhost.c 
>>> b/drivers/net/vhost/rte_eth_vhost.c
>>> index 4cc6bec..b1eb082 100644
>>> --- a/drivers/net/vhost/rte_eth_vhost.c
>>> +++ b/drivers/net/vhost/rte_eth_vhost.c
>>>
>> Hi,
>>
>> I appreciate fixing it.
>> Just one worry is that state changed event may be occurred before new
>> device event.
>> The users should not call rte_eth_dev_socket_id() until new device event
>> comes, even if they catch queue state events.
>> Otherwise, they will get wrong socket id to call
>> rte_eth_rx/tx_queue_setup().
> There is no way to guarantee that the socket id stuff would work
> perfectly in vhost, right? I mean, it's likely that virtio device
> would allocate memory from 2 or more sockets.
>
> So, it doesn't matter too much whether it's set perfectly right
> or not. Instead, we should assign it with a saner value instead
> of a obvious wrong one when new_device() is not invoked yet. So,
> I'd suggest to make an assignment first based on vhost_dev (or
> whatever) struct, and then make it "right" at new_device()
> callback?

Yes, I agree with you idea.

Thanks,
Tetsuya

>> So how about commenting it in 'rte_eth_vhost.h'?
> It asks a different usage than other PMDs, which I don't think
> it's a good idea.
>
>   --yliu



[dpdk-dev] [PATCH] vhost: Fix retrieval of numa information in PMD

2016-04-06 Thread Tetsuya Mukawa
On 2016/04/06 1:09, Ciara Loftus wrote:
> After some testing, it was found that retrieving numa information
> about a vhost device via a call to get_mempolicy is more
> accurate when performed during the new_device callback versus
> the vring_state_changed callback, in particular upon initial boot
> of the VM.  Performing this check during new_device is also
> potentially more efficient as this callback is only triggered once
> during device initialisation, compared with vring_state_changed
> which may be called multiple times depending on the number of
> queues assigned to the device.
>
> Reorganise the code to perform this check and assign the correct
> socket_id to the device during the new_device callback.
>
> Signed-off-by: Ciara Loftus 
> ---
>  drivers/net/vhost/rte_eth_vhost.c | 28 ++--
>  1 file changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/net/vhost/rte_eth_vhost.c 
> b/drivers/net/vhost/rte_eth_vhost.c
> index 4cc6bec..b1eb082 100644
> --- a/drivers/net/vhost/rte_eth_vhost.c
> +++ b/drivers/net/vhost/rte_eth_vhost.c
>

Hi,

I appreciate fixing it.
Just one worry is that state changed event may be occurred before new
device event.
The users should not call rte_eth_dev_socket_id() until new device event
comes, even if they catch queue state events.
Otherwise, they will get wrong socket id to call
rte_eth_rx/tx_queue_setup().

So how about commenting it in 'rte_eth_vhost.h'?

Thanks,
Tetsuya


[dpdk-dev] [PATCH] vhost PMD: Fix wrong handling of maximum value of rx/tx queues

2016-03-23 Thread Tetsuya Mukawa
On 2016/03/23 2:17, Loftus, Ciara wrote:
>> Currently, the maximum value of rx/tx queueus are kept by EAL. But,
>> the value are used like below different meanings in vhost PMD.
>>  - The maximum value of current enabled queues.
>>  - The maximum value of current supported queues.
>>
>> This wrong double meaning will cause an issue like below steps.
>>
>> * Invoke application with below option.
>>   --vdev 'eth_vhost0,iface=,queues=4'
>> * Configure queues like below.
>>   rte_eth_dev_configure(portid, 2, 2, ...);
>> * Configure queues again like below.
>>   rte_eth_dev_configure(portid, 4, 4, ...);
>>
>> The second rte_eth_dev_configure() will be failed because both
>> the maximum value of current enabled queues and supported queues
>> will be '2' after calling first rte_eth_dev_configure().
>>
>> To fix the issue, the patch prepare one more variable to keep the
>> number of maximum supported queues in vhost PMD.
>>
>> Signed-off-by: Tetsuya Mukawa 
>> ---
>>  drivers/net/vhost/rte_eth_vhost.c | 14 --
>>  1 file changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/vhost/rte_eth_vhost.c
>> b/drivers/net/vhost/rte_eth_vhost.c
>> index 6b9d287..5fd8c70 100644
>> --- a/drivers/net/vhost/rte_eth_vhost.c
>> +++ b/drivers/net/vhost/rte_eth_vhost.c
>> @@ -88,6 +88,7 @@ struct vhost_queue {
>>  struct pmd_internal {
>>  char *dev_name;
>>  char *iface_name;
>> +uint16_t max_queues;
>>
>>  volatile uint16_t once;
>>  };
>> @@ -555,11 +556,19 @@ static void
>>  eth_dev_info(struct rte_eth_dev *dev,
>>   struct rte_eth_dev_info *dev_info)
>>  {
>> +struct pmd_internal *internal;
>> +
>> +internal = dev->data->dev_private;
>> +if (internal == NULL) {
>> +RTE_LOG(ERR, PMD, "Invalid device specified\n");
>> +return;
>> +}
>> +
>>  dev_info->driver_name = drivername;
>>  dev_info->max_mac_addrs = 1;
>>  dev_info->max_rx_pktlen = (uint32_t)-1;
>> -dev_info->max_rx_queues = dev->data->nb_rx_queues;
>> -dev_info->max_tx_queues = dev->data->nb_tx_queues;
>> +dev_info->max_rx_queues = internal->max_queues;
>> +dev_info->max_tx_queues = internal->max_queues;
>>  dev_info->min_rx_bufsize = 0;
>>  }
>>
>> @@ -751,6 +760,7 @@ eth_dev_vhost_create(const char *name, char
>> *iface_name, int16_t queues,
>>  memmove(data->name, eth_dev->data->name, sizeof(data-
>>> name));
>>  data->nb_rx_queues = queues;
>>  data->nb_tx_queues = queues;
>> +internal->max_queues = queues;
>>  data->dev_link = pmd_link;
>>  data->mac_addrs = eth_addr;
>>
>> --
>> 2.1.4
> Hi Tetsuya,
>
> Thanks again for the patch.
>
> Acked-by: Ciara Loftus 
>
> Thanks,
> Ciara
>

I appreciate your reviewing and testing.

Thanks,
Tetsuya



[dpdk-dev] [PATCH] vhost PMD: Fix wrong handling of maximum value of rx/tx queues

2016-03-22 Thread Tetsuya Mukawa
Currently, the maximum value of rx/tx queueus are kept by EAL. But,
the value are used like below different meanings in vhost PMD.
 - The maximum value of current enabled queues.
 - The maximum value of current supported queues.

This wrong double meaning will cause an issue like below steps.

* Invoke application with below option.
  --vdev 'eth_vhost0,iface=,queues=4'
* Configure queues like below.
  rte_eth_dev_configure(portid, 2, 2, ...);
* Configure queues again like below.
  rte_eth_dev_configure(portid, 4, 4, ...);

The second rte_eth_dev_configure() will be failed because both
the maximum value of current enabled queues and supported queues
will be '2' after calling first rte_eth_dev_configure().

To fix the issue, the patch prepare one more variable to keep the
number of maximum supported queues in vhost PMD.

Signed-off-by: Tetsuya Mukawa 
---
 drivers/net/vhost/rte_eth_vhost.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/net/vhost/rte_eth_vhost.c 
b/drivers/net/vhost/rte_eth_vhost.c
index 6b9d287..5fd8c70 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -88,6 +88,7 @@ struct vhost_queue {
 struct pmd_internal {
char *dev_name;
char *iface_name;
+   uint16_t max_queues;

volatile uint16_t once;
 };
@@ -555,11 +556,19 @@ static void
 eth_dev_info(struct rte_eth_dev *dev,
 struct rte_eth_dev_info *dev_info)
 {
+   struct pmd_internal *internal;
+
+   internal = dev->data->dev_private;
+   if (internal == NULL) {
+   RTE_LOG(ERR, PMD, "Invalid device specified\n");
+   return;
+   }
+
dev_info->driver_name = drivername;
dev_info->max_mac_addrs = 1;
dev_info->max_rx_pktlen = (uint32_t)-1;
-   dev_info->max_rx_queues = dev->data->nb_rx_queues;
-   dev_info->max_tx_queues = dev->data->nb_tx_queues;
+   dev_info->max_rx_queues = internal->max_queues;
+   dev_info->max_tx_queues = internal->max_queues;
dev_info->min_rx_bufsize = 0;
 }

@@ -751,6 +760,7 @@ eth_dev_vhost_create(const char *name, char *iface_name, 
int16_t queues,
memmove(data->name, eth_dev->data->name, sizeof(data->name));
data->nb_rx_queues = queues;
data->nb_tx_queues = queues;
+   internal->max_queues = queues;
data->dev_link = pmd_link;
data->mac_addrs = eth_addr;

-- 
2.1.4



[dpdk-dev] [PATCH v13 2/2] vhost: Add VHOST PMD

2016-03-22 Thread Tetsuya Mukawa
On 2016/03/22 0:40, Loftus, Ciara wrote:
>> +
>> +static void
>> +eth_dev_info(struct rte_eth_dev *dev,
>> + struct rte_eth_dev_info *dev_info)
>> +{
>> +dev_info->driver_name = drivername;
>> +dev_info->max_mac_addrs = 1;
>> +dev_info->max_rx_pktlen = (uint32_t)-1;
>> +dev_info->max_rx_queues = dev->data->nb_rx_queues;
>> +dev_info->max_tx_queues = dev->data->nb_tx_queues;
> I'm not entirely familiar with eth driver code so please correct me if I am 
> wrong.
>
> I'm wondering if assigning the max queue values to dev->data->nb_*x_queues is 
> correct.
> A user could change the value of nb_*x_queues with a call to 
> rte_eth_dev_configure(n_queues) which in turn calls 
> rte_eth_dev_*x_queue_config(n_queues) which will set dev->data->nb_*x_queues 
> to the value of n_queues which can be arbitrary and decided by the user. If 
> this is the case, dev->data->nb_*x_queues will no longer reflect the max, 
> rather the value the user chose in the call to rte_eth_dev_configure. And the 
> max could potentially change with multiple calls to configure. Is this 
> intended behaviour?

Hi Ciara,

Thanks for reviewing it. Here is a part of rte_eth_dev_configure().

int
rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
  const struct rte_eth_conf *dev_conf)
{

/*
 * Check that the numbers of RX and TX queues are not greater
 * than the maximum number of RX and TX queues supported by the
 * configured device.
 */
(*dev->dev_ops->dev_infos_get)(dev, _info);

if (nb_rx_q == 0 && nb_tx_q == 0) {
   
return -EINVAL;
}

if (nb_rx_q > dev_info.max_rx_queues) {
   
return -EINVAL;
}

if (nb_tx_q > dev_info.max_tx_queues) {
   
return -EINVAL;
}



/*
 * Setup new number of RX/TX queues and reconfigure device.
 */
diag = rte_eth_dev_rx_queue_config(dev, nb_rx_q);

diag = rte_eth_dev_tx_queue_config(dev, nb_tx_q);

}

Anyway, rte_eth_dev_tx/rx_queue_config() will be called only after
checking the current maximum number of queues.
So the user cannot set the number of queues greater than current maximum
number.

Regards,
Tetsuya


[dpdk-dev] [PATCH v13 1/2] ethdev: Add a new event type to notify a queue state changed event

2016-03-21 Thread Tetsuya Mukawa
2016-03-21 20:05 GMT+09:00 Bruce Richardson :
> On Mon, Mar 21, 2016 at 06:24:36PM +0900, Tetsuya Mukawa wrote:
>> 2016-03-21 17:37 GMT+09:00 Thomas Monjalon :
>> > 2016-03-21 14:45, Tetsuya Mukawa:
>> >> This event will be occured when some queues are enabled or disabled.
>> >> So far, only vhost PMD supports the event, and it indicates some queues
>> >> are enabled or disabled by virtio-net device. Such an event is needed
>> >> because virtio-net device may not enable all queues vhost PMD prepare.
>> >>
>> >> Because only vhost PMD uses the event so far, it isn't an actual hardware
>> >> interrupt but a simple software event.
>> > [...]
>> >>
>> >> + RTE_ETH_EVENT_QUEUE_STATE_CHANGE,
>> >> + /**< queue state changed interrupt */
>> >
>> > Is the shorter RTE_ETH_EVENT_QUEUE_STATE descriptive enough?
>> >
>> > What about this comment?
>> > /**< queue state event (enabled/disabled) */
>>
>> Hi Thomas,
>>
>> Yes, it's enough, and above comment is nice.
>> Thanks for suggestion.
>>
>>
>> Hi Bruce,
>>
>> If today is the deadline, could you kindly please replace above
>> changes while merging?
>> I need half a day to re-submit the patch. Sorry for asking it.
>> I will ask my company to let me have vpn access. ;)
>>
>> Regards,
>> Tetsuya
>
> Yes, I can fix on apply to dpdk-next-net.
>
> /Bruce

I appreciate your helping.

Regards,
Tetsuya


[dpdk-dev] [PATCH v13 1/2] ethdev: Add a new event type to notify a queue state changed event

2016-03-21 Thread Tetsuya Mukawa
2016-03-21 17:37 GMT+09:00 Thomas Monjalon :
> 2016-03-21 14:45, Tetsuya Mukawa:
>> This event will be occured when some queues are enabled or disabled.
>> So far, only vhost PMD supports the event, and it indicates some queues
>> are enabled or disabled by virtio-net device. Such an event is needed
>> because virtio-net device may not enable all queues vhost PMD prepare.
>>
>> Because only vhost PMD uses the event so far, it isn't an actual hardware
>> interrupt but a simple software event.
> [...]
>>
>> + RTE_ETH_EVENT_QUEUE_STATE_CHANGE,
>> + /**< queue state changed interrupt */
>
> Is the shorter RTE_ETH_EVENT_QUEUE_STATE descriptive enough?
>
> What about this comment?
> /**< queue state event (enabled/disabled) */

Hi Thomas,

Yes, it's enough, and above comment is nice.
Thanks for suggestion.


Hi Bruce,

If today is the deadline, could you kindly please replace above
changes while merging?
I need half a day to re-submit the patch. Sorry for asking it.
I will ask my company to let me have vpn access. ;)

Regards,
Tetsuya


[dpdk-dev] [PATCH v13 2/2] vhost: Add VHOST PMD

2016-03-21 Thread Tetsuya Mukawa
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.

The PMD has 2 parameters.
 - iface:  The parameter is used to specify a path to connect to a
   virtio-net device.
 - queues: The parameter is used to specify the number of the queues
   virtio-net device has.
   (Default: 1)

Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i

To connect above testpmd, here is qemu command example.

$ qemu-system-x86_64 \

-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on

Signed-off-by: Tetsuya Mukawa 
Acked-by: Ferruh Yigit 
Acked-by: Yuanhan Liu 
Acked-by: Rich Lane 
Tested-by: Rich Lane 
---
 MAINTAINERS |   5 +
 config/common_base  |   6 +
 config/common_linuxapp  |   1 +
 doc/guides/nics/index.rst   |   1 +
 doc/guides/nics/overview.rst|  37 +-
 doc/guides/nics/vhost.rst   | 110 
 doc/guides/rel_notes/release_16_04.rst  |   4 +
 drivers/net/Makefile|   4 +
 drivers/net/vhost/Makefile  |  62 ++
 drivers/net/vhost/rte_eth_vhost.c   | 917 
 drivers/net/vhost/rte_eth_vhost.h   | 109 
 drivers/net/vhost/rte_pmd_vhost_version.map |  10 +
 mk/rte.app.mk   |   6 +
 13 files changed, 1254 insertions(+), 18 deletions(-)
 create mode 100644 doc/guides/nics/vhost.rst
 create mode 100644 drivers/net/vhost/Makefile
 create mode 100644 drivers/net/vhost/rte_eth_vhost.c
 create mode 100644 drivers/net/vhost/rte_eth_vhost.h
 create mode 100644 drivers/net/vhost/rte_pmd_vhost_version.map

diff --git a/MAINTAINERS b/MAINTAINERS
index 8b21979..7a47fc0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -352,6 +352,11 @@ Null PMD
 M: Tetsuya Mukawa 
 F: drivers/net/null/

+Vhost PMD
+M: Tetsuya Mukawa 
+M: Yuanhan Liu 
+F: drivers/net/vhost/
+
 Intel AES-NI GCM PMD
 M: Declan Doherty 
 F: drivers/crypto/aesni_gcm/
diff --git a/config/common_base b/config/common_base
index dbd405b..5efee07 100644
--- a/config/common_base
+++ b/config/common_base
@@ -514,6 +514,12 @@ CONFIG_RTE_LIBRTE_VHOST_NUMA=n
 CONFIG_RTE_LIBRTE_VHOST_DEBUG=n

 #
+# Compile vhost PMD
+# To compile, CONFIG_RTE_LIBRTE_VHOST should be enabled.
+#
+CONFIG_RTE_LIBRTE_PMD_VHOST=n
+
+#
 #Compile Xen domain0 support
 #
 CONFIG_RTE_LIBRTE_XEN_DOM0=n
diff --git a/config/common_linuxapp b/config/common_linuxapp
index ffbe260..7e698e2 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -40,5 +40,6 @@ CONFIG_RTE_EAL_VFIO=y
 CONFIG_RTE_KNI_KMOD=y
 CONFIG_RTE_LIBRTE_KNI=y
 CONFIG_RTE_LIBRTE_VHOST=y
+CONFIG_RTE_LIBRTE_PMD_VHOST=y
 CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y
 CONFIG_RTE_LIBRTE_POWER=y
diff --git a/doc/guides/nics/index.rst b/doc/guides/nics/index.rst
index 0b353a8..d53b0c7 100644
--- a/doc/guides/nics/index.rst
+++ b/doc/guides/nics/index.rst
@@ -49,6 +49,7 @@ Network Interface Controller Drivers
 nfp
 szedata2
 virtio
+vhost
 vmxnet3
 pcap_ring

diff --git a/doc/guides/nics/overview.rst b/doc/guides/nics/overview.rst
index 2d4f014..40ca5ec 100644
--- a/doc/guides/nics/overview.rst
+++ b/doc/guides/nics/overview.rst
@@ -74,20 +74,21 @@ Most of these differences are summarized below.

 .. table:: Features availability in networking drivers

-    = = = = = = = = = = = = = = = = = = = = = = = = = = = 
= = = =
-   Feature  a b b b c e e i i i i i i i i i i f f m m m n n p r s 
v v v x
-f n n o x 1 n 4 4 4 4 g g x x x x m m l l p f u c i z 
i i m e
-p x x n g 0 i 0 0 0 0 b b g g g g 1 1 x x i p l a n e 
r r x n
-a 2 2 d b 0 c e e e e   v b b b b 0 0 4 5 p   l p g d 
t t n v
-c x x i e 0 . v v   f e e e e k k e a 
i i e i
-k   v n . f f   . v v   .   t 
o o t r
-e   f g .   .   . f f   .   a  
 . 3 t
-t   v   v   v   v   v   2  
 v
-e   e   e   e   e  
 e
-c   c   c   c   c  
 c
-    = = = = = = = = = = = = = = = = = = = = = = = = = = = 
= = = =
-   link status  X X X   X
-   link status event  X X
+    = = = = = = = = = = = = = = = = = = = = = = = = = = = 
= = = = =
+   Feature  a b b b c e e i i

[dpdk-dev] [PATCH v13 1/2] ethdev: Add a new event type to notify a queue state changed event

2016-03-21 Thread Tetsuya Mukawa
This patch adds a below event type.
 - RTE_ETH_EVENT_QUEUE_STATE_CHANGE

This event will be occured when some queues are enabled or disabled.
So far, only vhost PMD supports the event, and it indicates some queues
are enabled or disabled by virtio-net device. Such an event is needed
because virtio-net device may not enable all queues vhost PMD prepare.

Because only vhost PMD uses the event so far, it isn't an actual hardware
interrupt but a simple software event.

Signed-off-by: Tetsuya Mukawa 
Acked-by: Ferruh Yigit 
Acked-by: Yuanhan Liu 
Acked-by: Rich Lane 
Tested-by: Rich Lane 
---
 lib/librte_ether/rte_ethdev.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index b5704e1..470d7a5 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2917,6 +2917,8 @@ rte_eth_tx_buffer_count_callback(struct rte_mbuf **pkts, 
uint16_t unsent,
 enum rte_eth_event_type {
RTE_ETH_EVENT_UNKNOWN,  /**< unknown event type */
RTE_ETH_EVENT_INTR_LSC, /**< lsc interrupt event */
+   RTE_ETH_EVENT_QUEUE_STATE_CHANGE,
+   /**< queue state changed interrupt */
RTE_ETH_EVENT_MAX   /**< max value of this enum */
 };

-- 
2.1.4



[dpdk-dev] [PATCH v13 0/2] Add VHOST PMD

2016-03-21 Thread Tetsuya Mukawa
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost.

PATCH v13 changes:
 - Rebase on latest master.
 - Fix commit log of below patch.
   - ethdev: Add a new event type to notify a queue state changed event
 - Fix warnings from checkpatch.pl.
 - Add description to doc/guides/nics/overview.rst.

PATCH v12 changes:
 - Rebase on latest master.
 - Add a missing documentation.

PATCH v11 changes:
 - Rebase on latest master.
 - Fix MAINTAINERS file.
 - Fix Acked-by and Tested-by signatures of commit log.

PATCH v10 changes:
 - Rebase on latest master.
 - Fix DPDK version number(2.3 to 16.04)
 - Set port id to mbuf while receiving packets.

PATCH v9 changes:
 - Fix a null pointer access issue implemented in v8 patch.

PATCH v8 changes:
 - Manage ether devices list instead of internal structures list.
 - Remove needless NULL checking.
 - Replace "pthread_exit" to "return NULL".
 - Replace rte_panic to RTE_LOG, also add error handling.
 - Remove duplicated lines.
 - Remove needless casting.
 - Follow coding style.
 - Remove needless parenthesis.

PATCH v7 changes:
 - Remove needless parenthesis.
 - Add release note.
 - Remove needless line wraps.
 - Add null pointer check in vring_state_changed().
 - Free queue memory in eth_queue_release().
 - Fix wrong variable name.
 - Fix error handling code of eth_dev_vhost_create() and
   rte_pmd_vhost_devuninit().
 - Remove needless null checking from rte_pmd_vhost_devinit/devuninit().
 - Use port id to create mac address.
 - Add doxygen style comments in "rte_eth_vhost.h".
 - Fix wrong comment in "mk/rte.app.mk".

PATCH v6 changes:
 - Remove rte_vhost_driver_pmd_callback_registe().
 - Support link status interrupt.
 - Support queue state changed interrupt.
 - Add rte_eth_vhost_get_queue_event().
 - Support numa node detection when new device is connected.

PATCH v5 changes:
 - Rebase on latest master.
 - Fix RX/TX routine to count RX/TX bytes.
 - Fix RX/TX routine not to count as error packets if enqueue/dequeue
   cannot send all packets.
 - Fix if-condition checking for multiqueues.
 - Add "static" to pthread variable.
 - Fix format.
 - Change default behavior not to receive queueing event from driver.
 - Split the patch to separate rte_eth_vhost_portid2vdev().

PATCH v4 changes:
 - Rebase on latest DPDK tree.
 - Fix cording style.
 - Fix code not to invoke multiple messaging handling threads.
 - Fix code to handle vdev parameters correctly.
 - Remove needless cast.
 - Remove needless if-condition before rt_free().

PATCH v3 changes:
 - Rebase on latest matser
 - Specify correct queue_id in RX/TX function.

PATCH v2 changes:
 - Remove a below patch that fixes vhost library.
   The patch was applied as a separate patch.
   - vhost: fix crash with multiqueue enabled
 - Fix typos.
   (Thanks to Thomas, Monjalon)
 - Rebase on latest tree with above bernard's patches.

PATCH v1 changes:
 - Support vhost multiple queues.
 - Rebase on "remove pci driver from vdevs".
 - Optimize RX/TX functions.
 - Fix resource leaks.
 - Fix compile issue.
 - Add patch to fix vhost library.

RFC PATCH v3 changes:
 - Optimize performance.
   In RX/TX functions, change code to access only per core data.
 - Add below API to allow user to use vhost library APIs for a port managed
   by vhost PMD. There are a few limitations. See "rte_eth_vhost.h".
- rte_eth_vhost_portid2vdev()
   To support this functionality, vhost library is also changed.
   Anyway, if users doesn't use vhost PMD, can fully use vhost library APIs.
 - Add code to support vhost multiple queues.
   Actually, multiple queues functionality is not enabled so far.

RFC PATCH v2 changes:
 - Fix issues reported by checkpatch.pl
   (Thanks to Stephen Hemminger)


Tetsuya Mukawa (2):
  ethdev: Add a new event type to notify a queue state changed event
  vhost: Add VHOST PMD

 MAINTAINERS |   5 +
 config/common_base  |   6 +
 config/common_linuxapp  |   1 +
 doc/guides/nics/index.rst   |   1 +
 doc/guides/nics/overview.rst|  37 +-
 doc/guides/nics/vhost.rst   | 110 
 doc/guides/rel_notes/release_16_04.rst  |   4 +
 drivers/net/Makefile|   4 +
 drivers/net/vhost/Makefile  |  62 ++
 drivers/net/vhost/rte_eth_vhost.c   | 917 
 drivers/net/vhost/rte_eth_vhost.h   | 109 
 drivers/net/vhost/rte_pmd_vhost_version.map |  10 +
 lib/librte_ether/rte_ethdev.h   |   2 +
 mk/rte.app.mk   |   6 +
 14 files changed, 1256 insertions(+), 18 deletions(-)
 create mode 100644 doc/guides/nics/vhost.rst
 create mode 100644 drivers/net/vhost/Makefile
 create mode 100644 drivers/net/vhost/rte_eth_vhost.c
 create mode 100644 drivers/net/vhost/rte_eth_vhost.h
 create mode 100644 drivers/net/vhost/rte_pmd_vhost_version.map

-- 
2.1.4



[dpdk-dev] [PATCH v12 2/2] vhost: Add VHOST PMD

2016-03-21 Thread Tetsuya Mukawa
On 2016/03/18 21:27, Bruce Richardson wrote:
> On Tue, Mar 15, 2016 at 05:31:41PM +0900, Tetsuya Mukawa wrote:
>> The patch introduces a new PMD. This PMD is implemented as thin wrapper
>> of librte_vhost. It means librte_vhost is also needed to compile the PMD.
>> The vhost messages will be handled only when a port is started. So start
>> a port first, then invoke QEMU.
>>
>> The PMD has 2 parameters.
>>  - iface:  The parameter is used to specify a path to connect to a
>>virtio-net device.
>>  - queues: The parameter is used to specify the number of the queues
>>virtio-net device has.
>>(Default: 1)
>>
>> Here is an example.
>> $ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
>>
>> To connect above testpmd, here is qemu command example.
>>
>> $ qemu-system-x86_64 \
>> 
>> -chardev socket,id=chr0,path=/tmp/sock0 \
>> -netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
>> -device virtio-net-pci,netdev=net0,mq=on
>>
>> Signed-off-by: Tetsuya Mukawa 
>> Acked-by: Ferruh Yigit 
>> Acked-by: Yuanhan Liu 
>> Acked-by: Rich Lane 
>> Tested-by: Rich Lane 
> Hi Tetsuya,
>
> I hope to get this set merged for RC2 very soon. Can you provide an update for
> the nic overview.rst doc listing out the features of this new PMD. If you 
> want,
> you can provide it as a separate patch, that I will merge into this one for 
> you
> on apply to next-net.
>
> If you do decide to respin this patchset with the extra doc, please take into
> account the following patchwork issues also - otherwise I'll also fix them on
> apply:
>
> WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be 
> static const char * const
> #364: FILE: drivers/net/vhost/rte_eth_vhost.c:56:
> +static const char *valid_arguments[] = {

It seems this is false positive. So I will leave it.

Regards,
Tetsuya



[dpdk-dev] [PATCH v12 2/2] vhost: Add VHOST PMD

2016-03-19 Thread Tetsuya Mukawa
On 2016/03/18 23:13, Bruce Richardson wrote:
> On Fri, Mar 18, 2016 at 11:03:56PM +0900, Tetsuya Mukawa wrote:
>> On 2016/03/18 22:52, Thomas Monjalon wrote:
>>> 2016-03-18 22:41, Tetsuya Mukawa:
>>>> 2016/03/18 ??9:27 "Bruce Richardson" :
>>>>> I hope to get this set merged for RC2 very soon. Can you provide an
>>>>> update for the nic overview.rst doc listing out the features of
>>>>> this new PMD.
>>> [...]
>>>> I've sent the v12 patch with vhost.rst.
>>>> Could you please check below?
>>> Bruce is talking about the table of features in overview.rst.
>> Hi Bruce and Thomas,
>>
>> Thanks, I've got it.
>> Now I am out of office, so I will send the patch separately by hopefully
>> tomorrow.
>> Could you please apply it separately?
>>
> I'll hold applying the patchset until I have all relevant bits ready to go 
> together.
> If it's in by Monday, it should be ok. 

I appreciate it.

> Please also supply a more detailed comment
> for the new flag addition that Thomas has called out on patch 1. That needs 
> to be
> resolved too before apply.

Sure, I will add more description.

Regards,
Tetsuya



[dpdk-dev] [PATCH v12 2/2] vhost: Add VHOST PMD

2016-03-19 Thread Tetsuya Mukawa
On 2016/03/18 22:52, Thomas Monjalon wrote:
> 2016-03-18 22:41, Tetsuya Mukawa:
>> 2016/03/18 ??9:27 "Bruce Richardson" :
>>> I hope to get this set merged for RC2 very soon. Can you provide an
>>> update for the nic overview.rst doc listing out the features of
>>> this new PMD.
> [...]
>> I've sent the v12 patch with vhost.rst.
>> Could you please check below?
> Bruce is talking about the table of features in overview.rst.

Hi Bruce and Thomas,

Thanks, I've got it.
Now I am out of office, so I will send the patch separately by hopefully
tomorrow.
Could you please apply it separately?

Regards,
Tetsuya


[dpdk-dev] [PATCH v12 2/2] vhost: Add VHOST PMD

2016-03-18 Thread Tetsuya Mukawa
2016/03/18 ??9:27 "Bruce Richardson" :
>
> On Tue, Mar 15, 2016 at 05:31:41PM +0900, Tetsuya Mukawa wrote:
> > The patch introduces a new PMD. This PMD is implemented as thin wrapper
> > of librte_vhost. It means librte_vhost is also needed to compile the
PMD.
> > The vhost messages will be handled only when a port is started. So start
> > a port first, then invoke QEMU.
> >
> > The PMD has 2 parameters.
> >  - iface:  The parameter is used to specify a path to connect to a
> >virtio-net device.
> >  - queues: The parameter is used to specify the number of the queues
> >virtio-net device has.
> >(Default: 1)
> >
> > Here is an example.
> > $ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' --
-i
> >
> > To connect above testpmd, here is qemu command example.
> >
> > $ qemu-system-x86_64 \
> > 
> > -chardev socket,id=chr0,path=/tmp/sock0 \
> > -netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
> > -device virtio-net-pci,netdev=net0,mq=on
> >
> > Signed-off-by: Tetsuya Mukawa 
> > Acked-by: Ferruh Yigit 
> > Acked-by: Yuanhan Liu 
> > Acked-by: Rich Lane 
> > Tested-by: Rich Lane 
>
> Hi Tetsuya,
>
> I hope to get this set merged for RC2 very soon. Can you provide an
update for
> the nic overview.rst doc listing out the features of this new PMD. If you
want,
> you can provide it as a separate patch, that I will merge into this one
for you
> on apply to next-net.
>
> If you do decide to respin this patchset with the extra doc, please take
into
> account the following patchwork issues also - otherwise I'll also fix
them on
> apply:
>
> WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should
probably be static const char * const
> #364: FILE: drivers/net/vhost/rte_eth_vhost.c:56:
> +static const char *valid_arguments[] = {
>
> WARNING:LINE_SPACING: Missing a blank line after declarations
> #399: FILE: drivers/net/vhost/rte_eth_vhost.c:91:
> +   char *iface_name;
> +   volatile uint16_t once;
>
> WARNING:TYPO_SPELLING: 'Unknow' may be misspelled - perhaps 'Unknown'?
> #684: FILE: drivers/net/vhost/rte_eth_vhost.c:376:
> +   RTE_LOG(ERR, PMD, "Unknow numa node\n");
>
> Regards,
> /Bruce
>

Hi Bruce,

I've sent the v12 patch with vhost.rst.
Could you please check below?

http://dpdk.org/dev/patchwork/project/dpdk/list/?submitter=64

Is this the documentation I need to add?

Anyway, it contains above nits. So could you please fix it before merging,
if it's the documentation?

Regards,
Tetsuya


[dpdk-dev] [PATCH v12 2/2] vhost: Add VHOST PMD

2016-03-15 Thread Tetsuya Mukawa
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.

The PMD has 2 parameters.
 - iface:  The parameter is used to specify a path to connect to a
   virtio-net device.
 - queues: The parameter is used to specify the number of the queues
   virtio-net device has.
   (Default: 1)

Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i

To connect above testpmd, here is qemu command example.

$ qemu-system-x86_64 \

-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on

Signed-off-by: Tetsuya Mukawa 
Acked-by: Ferruh Yigit 
Acked-by: Yuanhan Liu 
Acked-by: Rich Lane 
Tested-by: Rich Lane 
---
 MAINTAINERS |   5 +
 config/common_base  |   6 +
 config/common_linuxapp  |   1 +
 doc/guides/nics/index.rst   |   1 +
 doc/guides/nics/vhost.rst   | 110 
 doc/guides/rel_notes/release_16_04.rst  |   5 +
 drivers/net/Makefile|   4 +
 drivers/net/vhost/Makefile  |  62 ++
 drivers/net/vhost/rte_eth_vhost.c   | 916 
 drivers/net/vhost/rte_eth_vhost.h   | 109 
 drivers/net/vhost/rte_pmd_vhost_version.map |  10 +
 mk/rte.app.mk   |   6 +
 12 files changed, 1235 insertions(+)
 create mode 100644 doc/guides/nics/vhost.rst
 create mode 100644 drivers/net/vhost/Makefile
 create mode 100644 drivers/net/vhost/rte_eth_vhost.c
 create mode 100644 drivers/net/vhost/rte_eth_vhost.h
 create mode 100644 drivers/net/vhost/rte_pmd_vhost_version.map

diff --git a/MAINTAINERS b/MAINTAINERS
index f10b26a..8ec1972 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -351,6 +351,11 @@ Null PMD
 M: Tetsuya Mukawa 
 F: drivers/net/null/

+Vhost PMD
+M: Tetsuya Mukawa 
+M: Yuanhan Liu 
+F: drivers/net/vhost/
+
 Intel AES-NI GCM PMD
 M: Declan Doherty 
 F: drivers/crypto/aesni_gcm/
diff --git a/config/common_base b/config/common_base
index 52bd34f..3d753e1 100644
--- a/config/common_base
+++ b/config/common_base
@@ -505,6 +505,12 @@ CONFIG_RTE_LIBRTE_VHOST_NUMA=n
 CONFIG_RTE_LIBRTE_VHOST_DEBUG=n

 #
+# Compile vhost PMD
+# To compile, CONFIG_RTE_LIBRTE_VHOST should be enabled.
+#
+CONFIG_RTE_LIBRTE_PMD_VHOST=n
+
+#
 #Compile Xen domain0 support
 #
 CONFIG_RTE_LIBRTE_XEN_DOM0=n
diff --git a/config/common_linuxapp b/config/common_linuxapp
index ffbe260..7e698e2 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -40,5 +40,6 @@ CONFIG_RTE_EAL_VFIO=y
 CONFIG_RTE_KNI_KMOD=y
 CONFIG_RTE_LIBRTE_KNI=y
 CONFIG_RTE_LIBRTE_VHOST=y
+CONFIG_RTE_LIBRTE_PMD_VHOST=y
 CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y
 CONFIG_RTE_LIBRTE_POWER=y
diff --git a/doc/guides/nics/index.rst b/doc/guides/nics/index.rst
index 0b353a8..d53b0c7 100644
--- a/doc/guides/nics/index.rst
+++ b/doc/guides/nics/index.rst
@@ -49,6 +49,7 @@ Network Interface Controller Drivers
 nfp
 szedata2
 virtio
+vhost
 vmxnet3
 pcap_ring

diff --git a/doc/guides/nics/vhost.rst b/doc/guides/nics/vhost.rst
new file mode 100644
index 000..50e8a3a
--- /dev/null
+++ b/doc/guides/nics/vhost.rst
@@ -0,0 +1,110 @@
+..  BSD LICENSE
+Copyright(c) 2016 IGEL Co., Ltd.. All rights reserved.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+* Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in
+the documentation and/or other materials provided with the
+distribution.
+* Neither the name of IGEL Co., Ltd. nor the names of its
+contributors may be used to endorse or promote products derived
+from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILIT

[dpdk-dev] [PATCH v12 1/2] ethdev: Add a new event type to notify a queue state changed event

2016-03-15 Thread Tetsuya Mukawa
This patch adds a below event type.
 - RTE_ETH_EVENT_QUEUE_STATE_CHANGE
This event is used for notifying a queue state changed event.

Signed-off-by: Tetsuya Mukawa 
Acked-by: Ferruh Yigit 
Acked-by: Yuanhan Liu 
Acked-by: Rich Lane 
Tested-by: Rich Lane 
---
 lib/librte_ether/rte_ethdev.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index d867976..0680a71 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2915,6 +2915,8 @@ rte_eth_tx_buffer_count_callback(struct rte_mbuf **pkts, 
uint16_t unsent,
 enum rte_eth_event_type {
RTE_ETH_EVENT_UNKNOWN,  /**< unknown event type */
RTE_ETH_EVENT_INTR_LSC, /**< lsc interrupt event */
+   RTE_ETH_EVENT_QUEUE_STATE_CHANGE,
+   /**< queue state changed interrupt */
RTE_ETH_EVENT_MAX   /**< max value of this enum */
 };

-- 
2.1.4



[dpdk-dev] [PATCH v12 0/2] Add VHOST PMD

2016-03-15 Thread Tetsuya Mukawa
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost.

PATCH v12 changes:
 - Rebase on latest master.
 - Add a missing documentation.

PATCH v11 changes:
 - Rebase on latest master.
 - Fix MAINTAINERS file.
 - Fix Acked-by and Tested-by signatures of commit log.

PATCH v10 changes:
 - Rebase on latest master.
 - Fix DPDK version number(2.3 to 16.04)
 - Set port id to mbuf while receiving packets.

PATCH v9 changes:
 - Fix a null pointer access issue implemented in v8 patch.

PATCH v8 changes:
 - Manage ether devices list instead of internal structures list.
 - Remove needless NULL checking.
 - Replace "pthread_exit" to "return NULL".
 - Replace rte_panic to RTE_LOG, also add error handling.
 - Remove duplicated lines.
 - Remove needless casting.
 - Follow coding style.
 - Remove needless parenthesis.

PATCH v7 changes:
 - Remove needless parenthesis.
 - Add release note.
 - Remove needless line wraps.
 - Add null pointer check in vring_state_changed().
 - Free queue memory in eth_queue_release().
 - Fix wrong variable name.
 - Fix error handling code of eth_dev_vhost_create() and
   rte_pmd_vhost_devuninit().
 - Remove needless null checking from rte_pmd_vhost_devinit/devuninit().
 - Use port id to create mac address.
 - Add doxygen style comments in "rte_eth_vhost.h".
 - Fix wrong comment in "mk/rte.app.mk".

PATCH v6 changes:
 - Remove rte_vhost_driver_pmd_callback_registe().
 - Support link status interrupt.
 - Support queue state changed interrupt.
 - Add rte_eth_vhost_get_queue_event().
 - Support numa node detection when new device is connected.

PATCH v5 changes:
 - Rebase on latest master.
 - Fix RX/TX routine to count RX/TX bytes.
 - Fix RX/TX routine not to count as error packets if enqueue/dequeue
   cannot send all packets.
 - Fix if-condition checking for multiqueues.
 - Add "static" to pthread variable.
 - Fix format.
 - Change default behavior not to receive queueing event from driver.
 - Split the patch to separate rte_eth_vhost_portid2vdev().

PATCH v4 changes:
 - Rebase on latest DPDK tree.
 - Fix cording style.
 - Fix code not to invoke multiple messaging handling threads.
 - Fix code to handle vdev parameters correctly.
 - Remove needless cast.
 - Remove needless if-condition before rt_free().

PATCH v3 changes:
 - Rebase on latest matser
 - Specify correct queue_id in RX/TX function.

PATCH v2 changes:
 - Remove a below patch that fixes vhost library.
   The patch was applied as a separate patch.
   - vhost: fix crash with multiqueue enabled
 - Fix typos.
   (Thanks to Thomas, Monjalon)
 - Rebase on latest tree with above bernard's patches.

PATCH v1 changes:
 - Support vhost multiple queues.
 - Rebase on "remove pci driver from vdevs".
 - Optimize RX/TX functions.
 - Fix resource leaks.
 - Fix compile issue.
 - Add patch to fix vhost library.

RFC PATCH v3 changes:
 - Optimize performance.
   In RX/TX functions, change code to access only per core data.
 - Add below API to allow user to use vhost library APIs for a port managed
   by vhost PMD. There are a few limitations. See "rte_eth_vhost.h".
- rte_eth_vhost_portid2vdev()
   To support this functionality, vhost library is also changed.
   Anyway, if users doesn't use vhost PMD, can fully use vhost library APIs.
 - Add code to support vhost multiple queues.
   Actually, multiple queues functionality is not enabled so far.

RFC PATCH v2 changes:
 - Fix issues reported by checkpatch.pl
   (Thanks to Stephen Hemminger)


Tetsuya Mukawa (2):
  ethdev: Add a new event type to notify a queue state changed event
  vhost: Add VHOST PMD

 MAINTAINERS |   5 +
 config/common_base  |   6 +
 config/common_linuxapp  |   1 +
 doc/guides/nics/index.rst   |   1 +
 doc/guides/nics/vhost.rst   | 110 
 doc/guides/rel_notes/release_16_04.rst  |   5 +
 drivers/net/Makefile|   4 +
 drivers/net/vhost/Makefile  |  62 ++
 drivers/net/vhost/rte_eth_vhost.c   | 916 
 drivers/net/vhost/rte_eth_vhost.h   | 109 
 drivers/net/vhost/rte_pmd_vhost_version.map |  10 +
 lib/librte_ether/rte_ethdev.h   |   2 +
 mk/rte.app.mk   |   6 +
 13 files changed, 1237 insertions(+)
 create mode 100644 doc/guides/nics/vhost.rst
 create mode 100644 drivers/net/vhost/Makefile
 create mode 100644 drivers/net/vhost/rte_eth_vhost.c
 create mode 100644 drivers/net/vhost/rte_eth_vhost.h
 create mode 100644 drivers/net/vhost/rte_pmd_vhost_version.map

-- 
2.1.4



[dpdk-dev] [PATCH v11 2/2] vhost: Add VHOST PMD

2016-03-15 Thread Tetsuya Mukawa
On 2016/03/14 21:02, Bruce Richardson wrote:
> On Mon, Mar 07, 2016 at 11:07:14AM +0900, Tetsuya Mukawa wrote:
>> The patch introduces a new PMD. This PMD is implemented as thin wrapper
>> of librte_vhost. It means librte_vhost is also needed to compile the PMD.
>> The vhost messages will be handled only when a port is started. So start
>> a port first, then invoke QEMU.
>>
>> The PMD has 2 parameters.
>>  - iface:  The parameter is used to specify a path to connect to a
>>virtio-net device.
>>  - queues: The parameter is used to specify the number of the queues
>>virtio-net device has.
>>(Default: 1)
>>
>> Here is an example.
>> $ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
>>
>> To connect above testpmd, here is qemu command example.
>>
>> $ qemu-system-x86_64 \
>> 
>> -chardev socket,id=chr0,path=/tmp/sock0 \
>> -netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
>> -device virtio-net-pci,netdev=net0,mq=on
>>
>> Signed-off-by: Tetsuya Mukawa 
>> Acked-by: Ferruh Yigit 
>> Acked-by: Yuanhan Liu 
>> Acked-by: Rich Lane 
>> Tested-by: Rich Lane 
>> ---
>>  MAINTAINERS |   5 +
>>  config/common_base  |   6 +
>>  config/common_linuxapp  |   1 +
>>  doc/guides/nics/index.rst   |   1 +
> This adds a new entry for vhost PMD into the index, but there is no vhost.rst
> file present in this patchset. Did you forget to add it?

Yes, it seems so. The file is only on my environment.
I will add it.

Thanks,
Tetsuya

>
>>  doc/guides/rel_notes/release_16_04.rst  |   4 +
>>  drivers/net/Makefile|   4 +
>>  drivers/net/vhost/Makefile  |  62 ++
>>  drivers/net/vhost/rte_eth_vhost.c   | 916 
>> 
>>  drivers/net/vhost/rte_eth_vhost.h   | 109 
>>  drivers/net/vhost/rte_pmd_vhost_version.map |  10 +
>>  mk/rte.app.mk   |   6 +
>>  11 files changed, 1124 insertions(+)
>>  create mode 100644 drivers/net/vhost/Makefile
>>  create mode 100644 drivers/net/vhost/rte_eth_vhost.c
>>  create mode 100644 drivers/net/vhost/rte_eth_vhost.h
>>  create mode 100644 drivers/net/vhost/rte_pmd_vhost_version.map
> 
>
> /Bruce
>



[dpdk-dev] [PATCH v3] vhost: Fix default value of kickfd and callfd

2016-03-14 Thread Tetsuya Mukawa
Currently, default values of kickfd and callfd are -1.
If the values are -1, current code guesses kickfd and callfd haven't
been initialized yet. Then vhost library will guess the virtqueue isn't
ready for processing.
But callfd and kickfd will be set as -1 when "--enable-kvm"
isn't specified in QEMU command line. It means we cannot treat -1 as
uninitialized state.
The patch defines -1 and -2 as VIRTIO_INVALID_EVENTFD and
VIRTIO_UNINITIALIZED_EVENTFD, and uses VIRTIO_UNINITIALIZED_EVENTFD for
the default values of kickfd and callfd.

Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_vhost/rte_virtio_net.h |  2 ++
 lib/librte_vhost/vhost_rxtx.c |  9 ++---
 lib/librte_vhost/vhost_user/virtio-net-user.c | 14 +++---
 lib/librte_vhost/virtio-net.c |  4 ++--
 4 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/lib/librte_vhost/rte_virtio_net.h 
b/lib/librte_vhost/rte_virtio_net.h
index 443245d..600b20b 100644
--- a/lib/librte_vhost/rte_virtio_net.h
+++ b/lib/librte_vhost/rte_virtio_net.h
@@ -89,6 +89,8 @@ struct vhost_virtqueue {
uint16_tvhost_hlen; /**< Vhost header 
length (varies depending on RX merge buffers. */
volatile uint16_t   last_used_idx;  /**< Last index used on 
the available ring */
volatile uint16_t   last_used_idx_res;  /**< Used for multiple 
devices reserving buffers. */
+#define VIRTIO_INVALID_EVENTFD (-1)
+#define VIRTIO_UNINITIALIZED_EVENTFD   (-2)
int callfd; /**< Used to notify the 
guest (trigger interrupt). */
int kickfd; /**< Currently unused 
as polling mode is enabled. */
int enabled;
diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c
index 9d23eb1..29d002d 100644
--- a/lib/librte_vhost/vhost_rxtx.c
+++ b/lib/librte_vhost/vhost_rxtx.c
@@ -333,7 +333,8 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,
rte_mb();

/* Kick the guest if necessary. */
-   if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT))
+   if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)
+   && (vq->callfd >= 0))
eventfd_write(vq->callfd, (eventfd_t)1);
return count;
 }
@@ -654,7 +655,8 @@ merge_rx_exit:
rte_mb();

/* Kick the guest if necessary. */
-   if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT))
+   if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)
+   && (vq->callfd >= 0))
eventfd_write(vq->callfd, (eventfd_t)1);
}

@@ -1048,7 +1050,8 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t 
queue_id,
sizeof(vq->used->idx));

/* Kick guest if required. */
-   if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT))
+   if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)
+   && (vq->callfd >= 0))
eventfd_write(vq->callfd, (eventfd_t)1);

 out:
diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c 
b/lib/librte_vhost/vhost_user/virtio-net-user.c
index 65b5652..f5248bc 100644
--- a/lib/librte_vhost/vhost_user/virtio-net-user.c
+++ b/lib/librte_vhost/vhost_user/virtio-net-user.c
@@ -225,8 +225,8 @@ static int
 vq_is_ready(struct vhost_virtqueue *vq)
 {
return vq && vq->desc   &&
-  vq->kickfd != -1 &&
-  vq->callfd != -1;
+  vq->kickfd != VIRTIO_UNINITIALIZED_EVENTFD &&
+  vq->callfd != VIRTIO_UNINITIALIZED_EVENTFD;
 }

 static int
@@ -258,7 +258,7 @@ user_set_vring_call(struct vhost_device_ctx ctx, struct 
VhostUserMsg *pmsg)

file.index = pmsg->payload.u64 & VHOST_USER_VRING_IDX_MASK;
if (pmsg->payload.u64 & VHOST_USER_VRING_NOFD_MASK)
-   file.fd = -1;
+   file.fd = VIRTIO_INVALID_EVENTFD;
else
file.fd = pmsg->fds[0];
RTE_LOG(INFO, VHOST_CONFIG,
@@ -279,7 +279,7 @@ user_set_vring_kick(struct vhost_device_ctx ctx, struct 
VhostUserMsg *pmsg)

file.index = pmsg->payload.u64 & VHOST_USER_VRING_IDX_MASK;
if (pmsg->payload.u64 & VHOST_USER_VRING_NOFD_MASK)
-   file.fd = -1;
+   file.fd = VIRTIO_INVALID_EVENTFD;
else
file.fd = pmsg->fds[0];
RTE_LOG(INFO, VHOST_CONFIG,
@@ -316,10 +316,10 @@ user_get_vring_base(struct vhost_device_ctx ctx,
 * sent and only sent in vhost_vring_stop.
 * TODO: cleanup the vring, it isn't usable since here.
 */
-   if (dev->virtqueue[state->index]->kickfd >= 0

[dpdk-dev] [PATCH v2] vhost: Fix default value of kickfd and callfd

2016-03-14 Thread Tetsuya Mukawa
On 2016/03/14 17:21, Yuanhan Liu wrote:
> On Mon, Mar 14, 2016 at 04:54:00PM +0900, Tetsuya Mukawa wrote:
>> On 2016/03/14 11:08, Yuanhan Liu wrote:
>>> On Mon, Mar 14, 2016 at 10:54:14AM +0900, Tetsuya Mukawa wrote:
>>>> On 2016/03/11 16:19, Yuanhan Liu wrote:
>>>>> On Thu, Mar 10, 2016 at 04:06:05PM +0900, Tetsuya Mukawa wrote:
>>>>>> Currently, default values of kickfd and callfd are -1.
>>>>>> If the values are -1, current code guesses kickfd and callfd haven't
>>>>>> been initialized yet. And vhost library will guess the virtqueue isn't
>>>>>> ready for processing.
>>>>>> But callfd and kickfd will be set as -1 when "--enable-kvm"
>>>>>> isn't specified in QEMU command line. It means we cannot treat -1 as
>>>>>> uninitialized state. The patch changes default values to -2. And the
>>>>>> patch defines -2 as VIRTIO_UNINITIALIZED_EVENTFD.
>>>>> This looks more like a workaround to me. 
>>>> Hi Yuanhan,
>>>>
>>>> Sorry for late reply.
>>>> I have checked QEMU documentation, and found below.
>>>>
>>>> --
>>>>  * VHOST_USER_SET_VRING_CALL
>>>>
>>>>   Id: 14
>>>>   Equivalent ioctl: VHOST_SET_VRING_CALL
>>>>   Master payload: u64
>>>>
>>>>   Set the event file descriptor to signal when buffers are used. It
>>>>   is passed in the ancillary data.
>>>>   Bits (0-7) of the payload contain the vring index. Bit 8 is the
>>>>   invalid FD flag.
>>>> --
>>>>
>>>> VHOST_USER_SET_VRING_KICK has almost same description.
>>>> I will check this invalid flag, and if it works for our case, then will
>>>> use it.
>>>> How about it?
>>> Yeah, that indeed sounds much better.
>> I've checked current dpdk code.
>> It seems we've already checked invalid flag like below.
>>
>> if (pmsg->payload.u64 & VHOST_USER_VRING_NOFD_MASK)
>> file.fd = -1;
>> else
>> file.fd = pmsg->fds[0];
>>
>> So how about adding below macros or enum?
>>
>> #define VIRTIO_UNINITIALIZED_EVENTFD   (-2)
>> #define VIRTIO_INVALID_EVENTFD  (-1)
>>
>> I am still not sure whether using enum is better or not.
> Both are Okay to me; I have no preference on that.
>
>> But here is one of example patch.
>> What do you think?
> Looks okay to me
>
>> diff --git a/lib/librte_vhost/rte_virtio_net.h
>> b/lib/librte_vhost/rte_virtio_net.h
>> index 7d1fde2..2a7566d 100644
>> --- a/lib/librte_vhost/rte_virtio_net.h
>> +++ b/lib/librte_vhost/rte_virtio_net.h
>> @@ -89,6 +89,8 @@ struct vhost_virtqueue {
>> uint16_tvhost_hlen; /**< Vhost
>> header length (varies depending on RX merge buffers. */
>> volatile uint16_t   last_used_idx;  /**< Last index
>> used on the available ring */
>> volatile uint16_t   last_used_idx_res;  /**< Used for
>> multiple devices reserving buffers. */
>> +#define VIRTIO_UNINITIALIZED_EVENTFD   (-2)
>> +#define VIRTIO_INVALID_EVENTFD (-1)
> One nit: you may keep it in order.

Thanks for  your comments, will change it.

Tetsuya

>   --yliu



[dpdk-dev] [PATCH v2] vhost: Fix default value of kickfd and callfd

2016-03-14 Thread Tetsuya Mukawa
On 2016/03/14 11:08, Yuanhan Liu wrote:
> On Mon, Mar 14, 2016 at 10:54:14AM +0900, Tetsuya Mukawa wrote:
>> On 2016/03/11 16:19, Yuanhan Liu wrote:
>>> On Thu, Mar 10, 2016 at 04:06:05PM +0900, Tetsuya Mukawa wrote:
>>>> Currently, default values of kickfd and callfd are -1.
>>>> If the values are -1, current code guesses kickfd and callfd haven't
>>>> been initialized yet. And vhost library will guess the virtqueue isn't
>>>> ready for processing.
>>>> But callfd and kickfd will be set as -1 when "--enable-kvm"
>>>> isn't specified in QEMU command line. It means we cannot treat -1 as
>>>> uninitialized state. The patch changes default values to -2. And the
>>>> patch defines -2 as VIRTIO_UNINITIALIZED_EVENTFD.
>>> This looks more like a workaround to me. 
>>
>> Hi Yuanhan,
>>
>> Sorry for late reply.
>> I have checked QEMU documentation, and found below.
>>
>> --
>>  * VHOST_USER_SET_VRING_CALL
>>
>>   Id: 14
>>   Equivalent ioctl: VHOST_SET_VRING_CALL
>>   Master payload: u64
>>
>>   Set the event file descriptor to signal when buffers are used. It
>>   is passed in the ancillary data.
>>   Bits (0-7) of the payload contain the vring index. Bit 8 is the
>>   invalid FD flag.
>> --
>>
>> VHOST_USER_SET_VRING_KICK has almost same description.
>> I will check this invalid flag, and if it works for our case, then will
>> use it.
>> How about it?
> Yeah, that indeed sounds much better.

I've checked current dpdk code.
It seems we've already checked invalid flag like below.

if (pmsg->payload.u64 & VHOST_USER_VRING_NOFD_MASK)
file.fd = -1;
else
file.fd = pmsg->fds[0];

So how about adding below macros or enum?

#define VIRTIO_UNINITIALIZED_EVENTFD   (-2)
#define VIRTIO_INVALID_EVENTFD  (-1)

I am still not sure whether using enum is better or not.
But here is one of example patch.
What do you think?

diff --git a/lib/librte_vhost/rte_virtio_net.h
b/lib/librte_vhost/rte_virtio_net.h
index 7d1fde2..2a7566d 100644
--- a/lib/librte_vhost/rte_virtio_net.h
+++ b/lib/librte_vhost/rte_virtio_net.h
@@ -89,6 +89,8 @@ struct vhost_virtqueue {
uint16_tvhost_hlen; /**< Vhost
header length (varies depending on RX merge buffers. */
volatile uint16_t   last_used_idx;  /**< Last index
used on the available ring */
volatile uint16_t   last_used_idx_res;  /**< Used for
multiple devices reserving buffers. */
+#define VIRTIO_UNINITIALIZED_EVENTFD   (-2)
+#define VIRTIO_INVALID_EVENTFD (-1)
int callfd; /**< Used to
notify the guest (trigger interrupt). */
int kickfd; /**< Currently
unused as polling mode is enabled. */
int enabled;
diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c
index 9d23eb1..29d002d 100644
--- a/lib/librte_vhost/vhost_rxtx.c
+++ b/lib/librte_vhost/vhost_rxtx.c
@@ -333,7 +333,8 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,
rte_mb();

/* Kick the guest if necessary. */
-   if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT))
+   if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)
+   && (vq->callfd >= 0))
eventfd_write(vq->callfd, (eventfd_t)1);
return count;
 }
@@ -654,7 +655,8 @@ merge_rx_exit:
rte_mb();

/* Kick the guest if necessary. */
-   if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT))
+   if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)
+   && (vq->callfd >= 0))
eventfd_write(vq->callfd, (eventfd_t)1);
}

@@ -1048,7 +1050,8 @@ rte_vhost_dequeue_burst(struct virtio_net *dev,
uint16_t queue_id,
sizeof(vq->used->idx));

/* Kick guest if required. */
-   if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT))
+   if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)
+   && (vq->callfd >= 0))
eventfd_write(vq->callfd, (eventfd_t)1);

 out:
diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c
b/lib/librte_vhost/vhost_user/virtio-net-user.c
index 65b5652..f5248bc 100644
--- a/lib/librte_vhost/vhost_user/virtio-net-user.c
+++ b/lib/librte_vhost/vhost_user/virtio-net-user.c
@@ -225,8 +225,8 @@ static int
 vq_is_ready(struct vhost_virtqueue *vq)
 {
return vq && vq->desc   &am

[dpdk-dev] [PATCH v2] vhost: Fix default value of kickfd and callfd

2016-03-14 Thread Tetsuya Mukawa
On 2016/03/11 16:19, Yuanhan Liu wrote:
> On Thu, Mar 10, 2016 at 04:06:05PM +0900, Tetsuya Mukawa wrote:
>> Currently, default values of kickfd and callfd are -1.
>> If the values are -1, current code guesses kickfd and callfd haven't
>> been initialized yet. And vhost library will guess the virtqueue isn't
>> ready for processing.
>> But callfd and kickfd will be set as -1 when "--enable-kvm"
>> isn't specified in QEMU command line. It means we cannot treat -1 as
>> uninitialized state. The patch changes default values to -2. And the
>> patch defines -2 as VIRTIO_UNINITIALIZED_EVENTFD.
> This looks more like a workaround to me. 


Hi Yuanhan,

Sorry for late reply.
I have checked QEMU documentation, and found below.

--
 * VHOST_USER_SET_VRING_CALL

  Id: 14
  Equivalent ioctl: VHOST_SET_VRING_CALL
  Master payload: u64

  Set the event file descriptor to signal when buffers are used. It
  is passed in the ancillary data.
  Bits (0-7) of the payload contain the vring index. Bit 8 is the
  invalid FD flag.
--

VHOST_USER_SET_VRING_KICK has almost same description.
I will check this invalid flag, and if it works for our case, then will
use it.
How about it?

> Besides, this patch would make
> following fail:
>
> eventfd_write(vq->callfd, (eventfd_t)1);

It's my fault.
I thought above case should be blocked by virtio spec itself. So just
leave it.
But eventfd is came from vhost spec, so VRING_AVAIL_F_NO_INTERRUPT might
be set even when kickfd and callfd are -1.
Thanks for checking it.

Tetsuya

>   --yliu



[dpdk-dev] [PATCH v2] vhost: Fix default value of kickfd and callfd

2016-03-10 Thread Tetsuya Mukawa
Currently, default values of kickfd and callfd are -1.
If the values are -1, current code guesses kickfd and callfd haven't
been initialized yet. And vhost library will guess the virtqueue isn't
ready for processing.
But callfd and kickfd will be set as -1 when "--enable-kvm"
isn't specified in QEMU command line. It means we cannot treat -1 as
uninitialized state. The patch changes default values to -2. And the
patch defines -2 as VIRTIO_UNINITIALIZED_EVENTFD.

Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_vhost/rte_virtio_net.h |  1 +
 lib/librte_vhost/vhost_user/virtio-net-user.c | 10 +-
 lib/librte_vhost/virtio-net.c |  4 ++--
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/lib/librte_vhost/rte_virtio_net.h 
b/lib/librte_vhost/rte_virtio_net.h
index 7d1fde2..d745707 100644
--- a/lib/librte_vhost/rte_virtio_net.h
+++ b/lib/librte_vhost/rte_virtio_net.h
@@ -89,6 +89,7 @@ struct vhost_virtqueue {
uint16_tvhost_hlen; /**< Vhost header 
length (varies depending on RX merge buffers. */
volatile uint16_t   last_used_idx;  /**< Last index used on 
the available ring */
volatile uint16_t   last_used_idx_res;  /**< Used for multiple 
devices reserving buffers. */
+#define VIRTIO_UNINITIALIZED_EVENTFD   (-2)
int callfd; /**< Used to notify the 
guest (trigger interrupt). */
int kickfd; /**< Currently unused 
as polling mode is enabled. */
int enabled;
diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c 
b/lib/librte_vhost/vhost_user/virtio-net-user.c
index 65b5652..4c156a6 100644
--- a/lib/librte_vhost/vhost_user/virtio-net-user.c
+++ b/lib/librte_vhost/vhost_user/virtio-net-user.c
@@ -225,8 +225,8 @@ static int
 vq_is_ready(struct vhost_virtqueue *vq)
 {
return vq && vq->desc   &&
-  vq->kickfd != -1 &&
-  vq->callfd != -1;
+  vq->kickfd != VIRTIO_UNINITIALIZED_EVENTFD &&
+  vq->callfd != VIRTIO_UNINITIALIZED_EVENTFD;
 }

 static int
@@ -316,10 +316,10 @@ user_get_vring_base(struct vhost_device_ctx ctx,
 * sent and only sent in vhost_vring_stop.
 * TODO: cleanup the vring, it isn't usable since here.
 */
-   if (dev->virtqueue[state->index]->kickfd >= 0) {
+   if (dev->virtqueue[state->index]->kickfd >= 0)
close(dev->virtqueue[state->index]->kickfd);
-   dev->virtqueue[state->index]->kickfd = -1;
-   }
+
+   dev->virtqueue[state->index]->kickfd = VIRTIO_UNINITIALIZED_EVENTFD;

return 0;
 }
diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c
index fe1a77e..3498e9d 100644
--- a/lib/librte_vhost/virtio-net.c
+++ b/lib/librte_vhost/virtio-net.c
@@ -263,8 +263,8 @@ init_vring_queue(struct vhost_virtqueue *vq, int qp_idx)
 {
memset(vq, 0, sizeof(struct vhost_virtqueue));

-   vq->kickfd = -1;
-   vq->callfd = -1;
+   vq->kickfd = VIRTIO_UNINITIALIZED_EVENTFD;
+   vq->callfd = VIRTIO_UNINITIALIZED_EVENTFD;

/* Backends are set to -1 indicating an inactive device. */
vq->backend = -1;
-- 
2.1.4



[dpdk-dev] [PATCH] vhost: Fix default value of kickfd and callfd

2016-03-10 Thread Tetsuya Mukawa
On 2016/03/10 15:39, Tan, Jianfeng wrote:
>
> On 3/10/2016 2:34 PM, Tetsuya Mukawa wrote:
>> On 2016/03/10 15:25, Tan, Jianfeng wrote:
>>>
>>> On 3/10/2016 2:14 PM, Tetsuya Mukawa wrote:
>>>> Currently, default value of kickfd and callfd is -1.
>>>> If the value is -1, current code guess kickfd and callfd hasn't been
>>>> initialized yet. And vhost library will guess the virtqueue isn't
>>>> ready
>>>> for processing.
>>>> But callfd and kickfd will be set as -1 when "--enable-kvm"
>>>> isn't specified in QEMU command line. It means we cannot treat -1 as
>>>> uninitialized state. The patch changes default value to -2. And the
>>>> patch defines -2 as VIRTIO_UNINITIALIZED_EVENTFD.
>>>>
>>>> Signed-off-by: Tetsuya Mukawa 
>>>> ---
>>>>lib/librte_vhost/rte_virtio_net.h | 1 +
>>>>lib/librte_vhost/vhost_user/virtio-net-user.c | 7 ---
>>>>lib/librte_vhost/virtio-net.c | 4 ++--
>>>>3 files changed, 7 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/lib/librte_vhost/rte_virtio_net.h
>>>> b/lib/librte_vhost/rte_virtio_net.h
>>>> index 7d1fde2..d745707 100644
>>>> --- a/lib/librte_vhost/rte_virtio_net.h
>>>> +++ b/lib/librte_vhost/rte_virtio_net.h
>>>> @@ -89,6 +89,7 @@ struct vhost_virtqueue {
>>>>uint16_tvhost_hlen;/**< Vhost header length
>>>> (varies depending on RX merge buffers. */
>>>>volatile uint16_tlast_used_idx;/**< Last index used
>>>> on the available ring */
>>>>volatile uint16_tlast_used_idx_res;/**< Used for
>>>> multiple devices reserving buffers. */
>>>> +#define VIRTIO_UNINITIALIZED_EVENTFD(-2)
>>>>intcallfd;/**< Used to notify the guest
>>>> (trigger interrupt). */
>>>>intkickfd;/**< Currently unused as
>>>> polling mode is enabled. */
>>>>intenabled;
>>>> diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c
>>>> b/lib/librte_vhost/vhost_user/virtio-net-user.c
>>>> index 65b5652..591f9bf 100644
>>>> --- a/lib/librte_vhost/vhost_user/virtio-net-user.c
>>>> +++ b/lib/librte_vhost/vhost_user/virtio-net-user.c
>>>> @@ -225,8 +225,8 @@ static int
>>>>vq_is_ready(struct vhost_virtqueue *vq)
>>>>{
>>>>return vq && vq->desc   &&
>>>> -   vq->kickfd != -1 &&
>>>> -   vq->callfd != -1;
>>>> +   vq->kickfd != VIRTIO_UNINITIALIZED_EVENTFD &&
>>>> +   vq->callfd != VIRTIO_UNINITIALIZED_EVENTFD;
>>>>}
>>>>  static int
>>>> @@ -318,7 +318,8 @@ user_get_vring_base(struct vhost_device_ctx ctx,
>>>> */
>>>>if (dev->virtqueue[state->index]->kickfd >= 0) {
>>>>close(dev->virtqueue[state->index]->kickfd);
>>> Then -1 will be a valid value, need to check if it's not -1 to
>>> close()? Nevertheless, close(-1) brings no big problem.
>>>
>> We did it in above 'if' condition checking, then close(-1) will not be
>> called.
>
> Sorry, missed that. So when kickfd == -1, need to be set to
> VIRTIO_UNINITIALIZED_EVENTFD?
>

Aha, I've got it. Will change it.

Thanks,
Tetsuya

> Thanks,
> Jianfeng
>
>>
>> Thanks,
>> Tetsuya
>>
>>> Thanks,
>>> Jianfeng
>>>
>>>> -dev->virtqueue[state->index]->kickfd = -1;
>>>> +dev->virtqueue[state->index]->kickfd =
>>>> +VIRTIO_UNINITIALIZED_EVENTFD;
>>>>}
>>>>  return 0;
>>>> diff --git a/lib/librte_vhost/virtio-net.c
>>>> b/lib/librte_vhost/virtio-net.c
>>>> index fe1a77e..3498e9d 100644
>>>> --- a/lib/librte_vhost/virtio-net.c
>>>> +++ b/lib/librte_vhost/virtio-net.c
>>>> @@ -263,8 +263,8 @@ init_vring_queue(struct vhost_virtqueue *vq, int
>>>> qp_idx)
>>>>{
>>>>memset(vq, 0, sizeof(struct vhost_virtqueue));
>>>>-vq->kickfd = -1;
>>>> -vq->callfd = -1;
>>>> +vq->kickfd = VIRTIO_UNINITIALIZED_EVENTFD;
>>>> +vq->callfd = VIRTIO_UNINITIALIZED_EVENTFD;
>>>>  /* Backends are set to -1 indicating an inactive device. */
>>>>vq->backend = -1;
>



[dpdk-dev] [PATCH] vhost: Fix default value of kickfd and callfd

2016-03-10 Thread Tetsuya Mukawa
On 2016/03/10 15:25, Tan, Jianfeng wrote:
>
>
> On 3/10/2016 2:14 PM, Tetsuya Mukawa wrote:
>> Currently, default value of kickfd and callfd is -1.
>> If the value is -1, current code guess kickfd and callfd hasn't been
>> initialized yet. And vhost library will guess the virtqueue isn't ready
>> for processing.
>> But callfd and kickfd will be set as -1 when "--enable-kvm"
>> isn't specified in QEMU command line. It means we cannot treat -1 as
>> uninitialized state. The patch changes default value to -2. And the
>> patch defines -2 as VIRTIO_UNINITIALIZED_EVENTFD.
>>
>> Signed-off-by: Tetsuya Mukawa 
>> ---
>>   lib/librte_vhost/rte_virtio_net.h | 1 +
>>   lib/librte_vhost/vhost_user/virtio-net-user.c | 7 ---
>>   lib/librte_vhost/virtio-net.c | 4 ++--
>>   3 files changed, 7 insertions(+), 5 deletions(-)
>>
>> diff --git a/lib/librte_vhost/rte_virtio_net.h
>> b/lib/librte_vhost/rte_virtio_net.h
>> index 7d1fde2..d745707 100644
>> --- a/lib/librte_vhost/rte_virtio_net.h
>> +++ b/lib/librte_vhost/rte_virtio_net.h
>> @@ -89,6 +89,7 @@ struct vhost_virtqueue {
>>   uint16_tvhost_hlen;/**< Vhost header length
>> (varies depending on RX merge buffers. */
>>   volatile uint16_tlast_used_idx;/**< Last index used
>> on the available ring */
>>   volatile uint16_tlast_used_idx_res;/**< Used for
>> multiple devices reserving buffers. */
>> +#define VIRTIO_UNINITIALIZED_EVENTFD(-2)
>>   intcallfd;/**< Used to notify the guest
>> (trigger interrupt). */
>>   intkickfd;/**< Currently unused as
>> polling mode is enabled. */
>>   intenabled;
>> diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c
>> b/lib/librte_vhost/vhost_user/virtio-net-user.c
>> index 65b5652..591f9bf 100644
>> --- a/lib/librte_vhost/vhost_user/virtio-net-user.c
>> +++ b/lib/librte_vhost/vhost_user/virtio-net-user.c
>> @@ -225,8 +225,8 @@ static int
>>   vq_is_ready(struct vhost_virtqueue *vq)
>>   {
>>   return vq && vq->desc   &&
>> -   vq->kickfd != -1 &&
>> -   vq->callfd != -1;
>> +   vq->kickfd != VIRTIO_UNINITIALIZED_EVENTFD &&
>> +   vq->callfd != VIRTIO_UNINITIALIZED_EVENTFD;
>>   }
>> static int
>> @@ -318,7 +318,8 @@ user_get_vring_base(struct vhost_device_ctx ctx,
>>*/
>>   if (dev->virtqueue[state->index]->kickfd >= 0) {
>>   close(dev->virtqueue[state->index]->kickfd);
>
> Then -1 will be a valid value, need to check if it's not -1 to
> close()? Nevertheless, close(-1) brings no big problem.
>

We did it in above 'if' condition checking, then close(-1) will not be
called.

Thanks,
Tetsuya

> Thanks,
> Jianfeng
>
>> -dev->virtqueue[state->index]->kickfd = -1;
>> +dev->virtqueue[state->index]->kickfd =
>> +VIRTIO_UNINITIALIZED_EVENTFD;
>>   }
>> return 0;
>> diff --git a/lib/librte_vhost/virtio-net.c
>> b/lib/librte_vhost/virtio-net.c
>> index fe1a77e..3498e9d 100644
>> --- a/lib/librte_vhost/virtio-net.c
>> +++ b/lib/librte_vhost/virtio-net.c
>> @@ -263,8 +263,8 @@ init_vring_queue(struct vhost_virtqueue *vq, int
>> qp_idx)
>>   {
>>   memset(vq, 0, sizeof(struct vhost_virtqueue));
>>   -vq->kickfd = -1;
>> -vq->callfd = -1;
>> +vq->kickfd = VIRTIO_UNINITIALIZED_EVENTFD;
>> +vq->callfd = VIRTIO_UNINITIALIZED_EVENTFD;
>> /* Backends are set to -1 indicating an inactive device. */
>>   vq->backend = -1;
>



[dpdk-dev] [PATCH v4 12/12] docs: add release note for qtest virtio container support

2016-03-09 Thread Tetsuya Mukawa
Signed-off-by: Tetsuya Mukawa 
---
 doc/guides/rel_notes/release_16_04.rst | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/doc/guides/rel_notes/release_16_04.rst 
b/doc/guides/rel_notes/release_16_04.rst
index e3142f2..1c8c6b2 100644
--- a/doc/guides/rel_notes/release_16_04.rst
+++ b/doc/guides/rel_notes/release_16_04.rst
@@ -61,6 +61,9 @@ This section should contain new features added in this 
release. Sample format:

   Add a new virtual device, named eth_cvio, to support virtio for containers.

+* **Virtio support for containers using QEMU qtest mode.**
+  Add a new virtual device, named eth_qtest_virtio, to support virtio for 
containers
+  using QEMU qtest mode.

 Resolved Issues
 ---
-- 
2.1.4



[dpdk-dev] [PATCH v4 11/12] virtio: Add QTest support for virtio-net PMD

2016-03-09 Thread Tetsuya Mukawa
The patch adds a new virtio-net PMD configuration that allows the PMD to
work on host as if the PMD is in VM.
Here is new configuration for virtio-net PMD.
 - CONFIG_RTE_VIRTIO_VDEV_QTEST
To use this mode, EAL needs map all hugepages as one file. Also the file
should be mapped between (1 << 31) and (1 << 44). And start address
should be aligned by EAL memory size.

To allocate like above, use below options.
 --single-file
 --range-virtaddr=0x8000-0x1000
 --align-memsize
If a free region cannot be found, EAL will return error.

To prepare virtio-net device on host, the users need to invoke QEMU
process in special QTest mode. This mode is mainly used for testing QEMU
devices from outer process. In this mode, no guest runs.
Here is QEMU command line.

 $ qemu-system-x86_64 \
 -machine pc-i440fx-1.4,accel=qtest \
 -display none -qtest-log /dev/null \
 -qtest unix:/tmp/socket,server \
 -netdev type=tap,script=/etc/qemu-ifup,id=net0,queues=1 \
 -device
virtio-net-pci,netdev=net0,mq=on,disable-modern=false,addr=3 \
 -chardev socket,id=chr1,path=/tmp/ivshmem,server \
 -device ivshmem,size=1G,chardev=chr1,vectors=1,addr=4

 * Should use QEMU-2.5.1, or above.
 * QEMU process is needed per port.
 * virtio-1.0 device are only supported.
 * The vhost backends like vhost-net and vhost-user can be specified.
 * In most cases, just using above command is enough, but you can also
   specify other QEMU virtio-net options like mac address.
 * Only checked "pc-i440fx-1.4" machine, but may work with other
   machines.
 * Should not add "--enable-kvm" to QEMU command line.

After invoking QEMU, the PMD can connect to QEMU process using unix
domain sockets. Over these sockets, virtio-net, ivshmem and piix3
device in QEMU are probed by the PMD.
Here is example of command line.

 $ testpmd -c f -n 1 -m 1024 --no-pci --single-file \
  --range-virtaddr=0x8000-0x1000 --align-memsize \
  --vdev="eth_qtest_virtio0,qtest=/tmp/socket,ivshmem=/tmp/ivshmem"\
  -- --disable-hw-vlan --txqflags=0xf00 -i

Please specify same unix domain sockets and memory size in both QEMU
and DPDK command lines like above.
The share memory size should be power of 2, because ivshmem only
accepts such memory size.

Signed-off-by: Tetsuya Mukawa 
---
 drivers/net/virtio/qtest.h |  55 +
 drivers/net/virtio/virtio_ethdev.c | 457 -
 2 files changed, 501 insertions(+), 11 deletions(-)

diff --git a/drivers/net/virtio/qtest.h b/drivers/net/virtio/qtest.h
index 46b9ee6..421e62c 100644
--- a/drivers/net/virtio/qtest.h
+++ b/drivers/net/virtio/qtest.h
@@ -35,5 +35,60 @@
 #define _VIRTIO_QTEST_H_

 #define QTEST_DRV_NAME "eth_qtest_virtio"
+#define QTEST_DEVICE_NUM3
+
+#include 
+
+/* Device information */
+#define VIRTIO_NET_DEVICE_ID0x1000
+#define VIRTIO_NET_VENDOR_ID0x1af4
+#define VIRTIO_NET_IRQ_NUM  10
+#define IVSHMEM_DEVICE_ID   0x1110
+#define IVSHMEM_VENDOR_ID   0x1af4
+#define PIIX3_DEVICE_ID 0x7000
+#define PIIX3_VENDOR_ID 0x8086
+
+/* 
+ * IO port mapping of qtest guest
+ * 
+ * 0x - 0xbfff : not used
+ * 0xc000 - 0xc03f : virtio-net(BAR0)
+ * 0xc040 - 0x : not used
+ *
+ * 
+ * Memory mapping of qtest quest
+ * 
+ * 0x_ - 0x_3fff : not used
+ * 0x_4000 - 0x_4fff : virtio-net(BAR1)
+ * 0x_40001000 - 0x_40ff : not used
+ * 0x_4100 - 0x_417f : virtio-net(BAR4)
+ * 0x_4180 - 0x_41ff : not used
+ * 0x_4200 - 0x_42ff : ivshmem(BAR0)
+ * 0x_42000100 - 0x_42ff : not used
+ * 0x_8000 - 0x_ : ivshmem(BAR2)
+ *
+ * We can only specify start address of a region. The region size
+ * will be defined by the device implementation in QEMU.
+ * The size will be pow of 2 according to the PCI specification.
+ * Also, the region start address should be aligned by region size.
+ *
+ * BAR2 of ivshmem will be used to mmap DPDK application memory.
+ * So this address will be dynamically changed, but not to overlap
+ * others, it should be mmaped between above addresses. Such allocation
+ * is done by EAL. Check rte_eal_get_free_region() also.
+ */
+#define VIRTIO_NET_IO_START 0xc000
+#define VIRTIO_NET_MEMORY1_START   0x4000
+#define VIRTIO_NET_MEMORY2_START   0x4100
+#define IVSHMEM_MEMORY_START0x4200
+
+static inline struct rte_pci_id
+qtest_get_pci_id_of_virtio_net(void)
+{
+   struct rte_pci_id id =  {VIRTIO

[dpdk-dev] [PATCH v4 10/12] virtio: Add QTest support to vtpci abstraction

2016-03-09 Thread Tetsuya Mukawa
The patch adds QTest support to vtpci abstraction.
With this patch, only modern virtio device will be supported.
This QTest support will be used by later QTest extension patch of
virtio-net PMD.

Signed-off-by: Tetsuya Mukawa 
---
 drivers/net/virtio/qtest.h |  39 
 drivers/net/virtio/virtio_ethdev.c |   2 +-
 drivers/net/virtio/virtio_pci.c| 368 ++---
 drivers/net/virtio/virtio_pci.h|   9 +-
 4 files changed, 387 insertions(+), 31 deletions(-)
 create mode 100644 drivers/net/virtio/qtest.h

diff --git a/drivers/net/virtio/qtest.h b/drivers/net/virtio/qtest.h
new file mode 100644
index 000..46b9ee6
--- /dev/null
+++ b/drivers/net/virtio/qtest.h
@@ -0,0 +1,39 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2016 IGEL Co., Ltd. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of IGEL Co., Ltd. nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _VIRTIO_QTEST_H_
+#define _VIRTIO_QTEST_H_
+
+#define QTEST_DRV_NAME "eth_qtest_virtio"
+
+#endif /* _VIRTIO_QTEST_H_ */
diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index bc631c7..747596d 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1055,7 +1055,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
pci_dev = eth_dev->pci_dev;

if (virtio_dev_check(eth_dev, RTE_ETH_DEV_PCI, NULL, 0)) {
-   if (vtpci_init(pci_dev, hw) < 0)
+   if (vtpci_init(eth_dev, hw) < 0)
return -1;
}

diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
index 85fbe88..e88531e 100644
--- a/drivers/net/virtio/virtio_pci.c
+++ b/drivers/net/virtio/virtio_pci.c
@@ -37,10 +37,16 @@
  #include 
 #endif

+#include "virtio_ethdev.h"
 #include "virtio_pci.h"
 #include "virtio_logs.h"
 #include "virtqueue.h"

+#ifdef RTE_VIRTIO_VDEV_QTEST
+#include "qtest.h"
+#include "qtest_utils.h"
+#endif
+
 /*
  * Following macros are derived from linux/pci_regs.h, however,
  * we can't simply include that header here, as there is no such
@@ -440,6 +446,220 @@ static const struct virtio_pci_ops modern_ops = {
 };


+#ifdef RTE_VIRTIO_VDEV_QTEST
+static inline uint8_t
+qtest_read8(struct virtio_hw *hw, uint8_t *addr)
+{
+   return qtest_read(hw->qsession, (uint64_t)addr, 'b');
+}
+
+static inline void
+qtest_write8(struct virtio_hw *hw, uint8_t val, uint8_t *addr)
+{
+   return qtest_write(hw->qsession, (uint64_t)addr, val, 'b');
+}
+
+static inline uint16_t
+qtest_read16(struct virtio_hw *hw, uint16_t *addr)
+{
+   return qtest_read(hw->qsession, (uint64_t)addr, 'w');
+}
+
+static inline void
+qtest_write16(struct virtio_hw *hw, uint16_t val, uint16_t *addr)
+{
+   return qtest_write(hw->qsession, (uint64_t)addr, val, 'w');
+}
+
+static inline uint32_t
+qtest_read32(struct virtio_hw *hw, uint32_t *addr)
+{
+   return qtest_read(hw->qsession, (uint64_t)addr, 'l');
+}
+
+static inline void
+qtest_write32(struct virtio_hw *hw, uint32_t val, uint32_t *addr)
+{
+   return qtest_write(hw->qsession, (uint64_t)addr, val, 'l');
+}
+
+static inline void
+qtest_write64_twopart(struct virtio_hw *hw,
+   uint64_t val, uint32_t *lo, uint32_t *hi)
+{
+   qtest_write32(hw, val & ((1ULL << 32) - 1), lo);
+   q

[dpdk-dev] [PATCH v4 09/12] virtio, qtest: Add misc functions to handle pci information

2016-03-09 Thread Tetsuya Mukawa
The patch adds below functions.
 - qtest_read_pci_cfg
 - qtest_get_bar
 - qtest_get_bar_addr
 - qtest_get_bar_size
These are used for handling pci device information.
It will be called by later patches.

Signed-off-by: Tetsuya Mukawa 
---
 drivers/net/virtio/qtest_utils.c | 77 
 drivers/net/virtio/qtest_utils.h | 56 +
 2 files changed, 133 insertions(+)

diff --git a/drivers/net/virtio/qtest_utils.c b/drivers/net/virtio/qtest_utils.c
index 337546a..55ed504 100644
--- a/drivers/net/virtio/qtest_utils.c
+++ b/drivers/net/virtio/qtest_utils.c
@@ -427,6 +427,83 @@ qtest_find_device(struct qtest_session *s, const char 
*name)
return NULL;
 }

+/*
+ * The function is used for reading pci configuration space of specifed device.
+ */
+int
+qtest_read_pci_cfg(struct qtest_session *s, const char *name,
+   void *buf, size_t len, off_t offset)
+{
+   struct qtest_pci_device *dev;
+   uint32_t i;
+   uint8_t *p = buf;
+
+   dev = qtest_find_device(s, name);
+   if (dev == NULL) {
+   PMD_DRV_LOG(ERR, "Cannot find specified device: %s\n", name);
+   return -1;
+   }
+
+   for (i = 0; i < len; i++) {
+   *(p + i) = qtest_pci_inb(s,
+   dev->bus_addr, dev->device_addr, 0, offset + i);
+   }
+
+   return 0;
+}
+
+static struct qtest_pci_bar *
+qtest_get_bar(struct qtest_session *s, const char *name, uint8_t bar)
+{
+   struct qtest_pci_device *dev;
+
+   if (bar >= NB_BAR) {
+   PMD_DRV_LOG(ERR, "Invalid bar is specified: %u\n", bar);
+   return NULL;
+   }
+
+   dev = qtest_find_device(s, name);
+   if (dev == NULL) {
+   PMD_DRV_LOG(ERR, "Cannot find specified device: %s\n", name);
+   return NULL;
+   }
+
+   if (dev->bar[bar].type == QTEST_PCI_BAR_DISABLE) {
+   PMD_DRV_LOG(ERR, "Cannot find valid BAR(%s): %u\n", name, bar);
+   return NULL;
+   }
+
+   return >bar[bar];
+}
+
+int
+qtest_get_bar_addr(struct qtest_session *s, const char *name,
+   uint8_t bar, uint64_t **addr)
+{
+   struct qtest_pci_bar *bar_ptr;
+
+   bar_ptr = qtest_get_bar(s, name, bar);
+   if (bar_ptr == NULL)
+   return -1;
+
+   *addr = (uint64_t *)bar_ptr->region_start;
+   return 0;
+}
+
+int
+qtest_get_bar_size(struct qtest_session *s, const char *name,
+   uint8_t bar, uint64_t *size)
+{
+   struct qtest_pci_bar *bar_ptr;
+
+   bar_ptr = qtest_get_bar(s, name, bar);
+   if (bar_ptr == NULL)
+   return -1;
+
+   *size = bar_ptr->region_size;
+   return 0;
+}
+
 int
 qtest_intr_enable(struct qtest_session *s)
 {
diff --git a/drivers/net/virtio/qtest_utils.h b/drivers/net/virtio/qtest_utils.h
index 0717ee9..dfd2b03 100644
--- a/drivers/net/virtio/qtest_utils.h
+++ b/drivers/net/virtio/qtest_utils.h
@@ -270,6 +270,62 @@ void qtest_write(struct qtest_session *s, uint64_t addr,

 /**
  * @internal
+ * Read pci configuration space of QEMU guest.
+ *
+ * @param s
+ *   The pointer to qtest session structure.
+ * @param name
+ *   The name of pci device.
+ * @param buf
+ *   The pointer to the buffer.
+ * @param len
+ *   Length to read.
+ * @param offset
+ *   Offset of pci configuration space.
+ * @return
+ *   0 on success, negative on error
+ */
+int qtest_read_pci_cfg(struct qtest_session *s, const char *name,
+   void *buf, size_t len, off_t offset);
+
+/**
+ * @internal
+ * Get BAR address of a specified pci device.
+ *
+ * @param s
+ *   The pointer to qtest session structure.
+ * @param name
+ *   The name of pci device.
+ * @param bar
+ *   The index of BAR. Should be between 0 to 5.
+ * @param addr
+ *   The pointer to store BAR address.
+ * @return
+ *   0 on success, negative on error
+ */
+int qtest_get_bar_addr(struct qtest_session *s, const char *name,
+   uint8_t bar, uint64_t **addr);
+
+/**
+ * @internal
+ * Get BAR size of a specified pci device.
+ *
+ * @param s
+ *   The pointer to qtest session structure.
+ * @param name
+ *   The name of pci device.
+ * @param bar
+ *   The index of BAR. Should be between 0 to 5.
+ * @param size
+ *   The pointer to store BAR size.
+ * @return
+ *   0 on success, negative on error
+ */
+int qtest_get_bar_size(struct qtest_session *s, const char *name,
+   uint8_t bar, uint64_t *size);
+
+/**
+ * @internal
  * Initialization function of piix3 device.
  *
  * @param s
-- 
2.1.4



[dpdk-dev] [PATCH v4 08/12] virtio, qtest: Add functionality to handle interrupt

2016-03-09 Thread Tetsuya Mukawa
The patch adds functionality to handle interrupt from pci device of
QEMU guest. To handle the interrupts, the patch adds to initialize piix3
pci device.

Signed-off-by: Tetsuya Mukawa 
---
 drivers/net/virtio/qtest_utils.c | 225 ++-
 drivers/net/virtio/qtest_utils.h |  68 +++-
 2 files changed, 287 insertions(+), 6 deletions(-)

diff --git a/drivers/net/virtio/qtest_utils.c b/drivers/net/virtio/qtest_utils.c
index 338224a..337546a 100644
--- a/drivers/net/virtio/qtest_utils.c
+++ b/drivers/net/virtio/qtest_utils.c
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 

@@ -43,6 +44,12 @@
 #include "virtio_ethdev.h"
 #include "qtest_utils.h"

+/* PIIX3 configuration registers */
+#define PIIX3_REG_ADDR_PIRQA0x60
+#define PIIX3_REG_ADDR_PIRQB0x61
+#define PIIX3_REG_ADDR_PIRQC0x62
+#define PIIX3_REG_ADDR_PIRQD0x63
+
 /* ivshmem configuration */
 #define IVSHMEM_PROTOCOL_VERSION0

@@ -74,6 +81,14 @@ struct qtest_session {
size_t evq_total_len;

union qtest_pipefds msgfds;
+
+   int irqno;
+   pthread_t intr_th;
+   int intr_th_started;
+   int eventfd;
+   rte_atomic16_t enable_intr;
+   rte_intr_callback_fn cb;
+   void *cb_arg;
 };

 static int
@@ -230,6 +245,29 @@ qtest_pci_inb(struct qtest_session *s, uint8_t bus, 
uint8_t device,
return (tmp >> ((offset & 0x3) * 8)) & 0xff;
 }

+static void
+qtest_pci_outb(struct qtest_session *s, uint8_t bus, uint8_t device,
+   uint8_t function, uint8_t offset, uint8_t value)
+{
+   uint32_t addr, tmp, pos;
+
+   addr = PCI_CONFIG_ADDR(bus, device, function, offset);
+   pos = (offset % 4) * 8;
+
+   if (pthread_mutex_lock(>qtest_session_lock) < 0)
+   rte_panic("Cannot lock mutex\n");
+
+   qtest_raw_out(s, 0xcf8, addr, 'l');
+   tmp = qtest_raw_in(s, 0xcfc, 'l');
+   tmp = (tmp & ~(0xff << pos)) | (value << pos);
+
+   qtest_raw_out(s, 0xcf8, addr, 'l');
+   qtest_raw_out(s, 0xcfc, tmp, 'l');
+
+   if (pthread_mutex_unlock(>qtest_session_lock) < 0)
+   rte_panic("Cannot unlock mutex\n");
+}
+
 static uint32_t
 qtest_pci_inl(struct qtest_session *s, uint8_t bus, uint8_t device,
uint8_t function, uint8_t offset)
@@ -389,15 +427,112 @@ qtest_find_device(struct qtest_session *s, const char 
*name)
return NULL;
 }

+int
+qtest_intr_enable(struct qtest_session *s)
+{
+   rte_atomic16_set(>enable_intr, 1);
+
+   return 0;
+}
+
+int
+qtest_intr_disable(struct qtest_session *s)
+{
+   rte_atomic16_set(>enable_intr, 0);
+
+   return 0;
+}
+
+void
+qtest_intr_callback_register(struct qtest_session *s,
+   rte_intr_callback_fn cb, void *cb_arg)
+{
+   s->cb = cb;
+   s->cb_arg = cb_arg;
+   rte_atomic16_set(>enable_intr, 1);
+}
+
+void
+qtest_intr_callback_unregister(struct qtest_session *s,
+   rte_intr_callback_fn cb __rte_unused,
+   void *cb_arg __rte_unused)
+{
+   rte_atomic16_set(>enable_intr, 0);
+   s->cb = NULL;
+   s->cb_arg = NULL;
+}
+
+static void *
+qtest_intr_handler(void *data) {
+   struct qtest_session *s = (struct qtest_session *)data;
+   eventfd_t value;
+   int ret;
+
+   for (;;) {
+   ret = eventfd_read(s->eventfd, );
+   if (ret < 0)
+   return NULL;
+   s->cb(NULL, s->cb_arg);
+   }
+   return NULL;
+}
+
+static int
+qtest_intr_initialize(struct qtest_session *s)
+{
+   char buf[64];
+   int ret;
+
+   snprintf(buf, sizeof(buf), "irq_intercept_in ioapic\n");
+
+   if (pthread_mutex_lock(>qtest_session_lock) < 0)
+   rte_panic("Cannot lock mutex\n");
+
+   /* To enable interrupt, send "irq_intercept_in" message to QEMU */
+   ret = qtest_raw_send(s->qtest_socket, buf, strlen(buf));
+   if (ret < 0) {
+   pthread_mutex_unlock(>qtest_session_lock);
+   return -1;
+   }
+
+   /* just ignore QEMU response */
+   ret = qtest_raw_recv(s->msgfds.readfd, buf, sizeof(buf));
+   if (ret < 0) {
+   pthread_mutex_unlock(>qtest_session_lock);
+   return -1;
+   }
+
+   if (pthread_mutex_unlock(>qtest_session_lock) < 0)
+   rte_panic("Cannot lock mutex\n");
+
+   return 0;
+}
+
 static void
 qtest_event_send(struct qtest_session *s, char *buf)
 {
+   char interrupt_message[32];
int ret;

-   /* relay normal message to pipe */
-   ret = qtest_raw_send(s->msgfds.writefd, buf, strlen(buf));
-   if (ret < 0)
-   rte_panic("cannot relay normal message\n");
+   /* Th

[dpdk-dev] [PATCH v4 07/12] virtio, qtest: Add functionality to share memory between QTest guest

2016-03-09 Thread Tetsuya Mukawa
The patch adds functionality to share memory between QTest guest and
DPDK application using ivshmem device.
The shared memory will be all EAL memory on hugepages. This memory will
be accessed by QEMU vcpu and DPDK application using same address.

Signed-off-by: Tetsuya Mukawa 
---
 drivers/net/virtio/qtest_utils.c | 106 ++-
 drivers/net/virtio/qtest_utils.h |   4 +-
 2 files changed, 108 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/qtest_utils.c b/drivers/net/virtio/qtest_utils.c
index 000c7e8..338224a 100644
--- a/drivers/net/virtio/qtest_utils.c
+++ b/drivers/net/virtio/qtest_utils.c
@@ -43,6 +43,9 @@
 #include "virtio_ethdev.h"
 #include "qtest_utils.h"

+/* ivshmem configuration */
+#define IVSHMEM_PROTOCOL_VERSION0
+
 #define PCI_CONFIG_ADDR(_bus, _device, _function, _offset) ( \
(1 << 31) | ((_bus) & 0xff) << 16 | ((_device) & 0x1f) << 11 | \
((_function) & 0x7) << 8 | ((_offset) & 0xfc))
@@ -59,6 +62,7 @@ union qtest_pipefds {

 struct qtest_session {
int qtest_socket;
+   int ivshmem_socket;
pthread_mutex_t qtest_session_lock;

struct qtest_pci_device_list head;
@@ -411,6 +415,7 @@ qtest_close_sockets(struct qtest_session *s)
qtest_close_one_socket(>qtest_socket);
qtest_close_one_socket(>msgfds.readfd);
qtest_close_one_socket(>msgfds.writefd);
+   qtest_close_one_socket(>ivshmem_socket);
 }

 static void
@@ -716,6 +721,93 @@ qtest_register_target_devices(struct qtest_session *s,
 }

 static int
+qtest_send_message_to_ivshmem(int sock_fd, uint64_t client_id, int shm_fd)
+{
+   struct iovec iov;
+   struct msghdr msgh;
+   size_t fdsize = sizeof(int);
+   char control[CMSG_SPACE(fdsize)];
+   struct cmsghdr *cmsg;
+   int ret;
+
+   memset(, 0, sizeof(msgh));
+   iov.iov_base = _id;
+   iov.iov_len = sizeof(client_id);
+
+   msgh.msg_iov = 
+   msgh.msg_iovlen = 1;
+
+   if (shm_fd >= 0) {
+   msgh.msg_control = 
+   msgh.msg_controllen = sizeof(control);
+   cmsg = CMSG_FIRSTHDR();
+   cmsg->cmsg_len = CMSG_LEN(fdsize);
+   cmsg->cmsg_level = SOL_SOCKET;
+   cmsg->cmsg_type = SCM_RIGHTS;
+   memcpy(CMSG_DATA(cmsg), _fd, fdsize);
+   }
+
+   do {
+   ret = sendmsg(sock_fd, , 0);
+   } while (ret < 0 && errno == EINTR);
+
+   if (ret < 0) {
+   PMD_DRV_LOG(ERR, "sendmsg error\n");
+   return ret;
+   }
+
+   return ret;
+}
+
+static int
+qtest_setup_shared_memory(struct qtest_session *s)
+{
+   int shm_fd, num, ret;
+   struct back_file *huges;
+
+   num = rte_eal_get_backfile_info();
+   if (num != 1) {
+   PMD_DRV_LOG(ERR,
+   "Not supported memory configuration\n");
+   return -1;
+   }
+
+   shm_fd = open(huges[0].filepath, O_RDWR);
+   if (shm_fd < 0) {
+   PMD_DRV_LOG(ERR,
+   "Cannot open file: %s\n", huges[0].filepath);
+   return -1;
+   }
+
+   /* send our protocol version first */
+   ret = qtest_send_message_to_ivshmem(s->ivshmem_socket,
+   IVSHMEM_PROTOCOL_VERSION, -1);
+   if (ret < 0) {
+   PMD_DRV_LOG(ERR,
+   "Failed to send protocol version to ivshmem\n");
+   return -1;
+   }
+
+   /* send client id */
+   ret = qtest_send_message_to_ivshmem(s->ivshmem_socket, 0, -1);
+   if (ret < 0) {
+   PMD_DRV_LOG(ERR, "Failed to send VMID to ivshmem\n");
+   return -1;
+   }
+
+   /* send message to ivshmem */
+   ret = qtest_send_message_to_ivshmem(s->ivshmem_socket, -1, shm_fd);
+   if (ret < 0) {
+   PMD_DRV_LOG(ERR, "Failed to file descriptor to ivshmem\n");
+   return -1;
+   }
+
+   close(shm_fd);
+
+   return 0;
+}
+
+static int
 qtest_open_socket(char *path)
 {
struct sockaddr_un sa = {0};
@@ -769,7 +861,7 @@ qtest_vdev_uninit(struct qtest_session *s)
 }

 struct qtest_session *
-qtest_vdev_init(char *qtest_path,
+qtest_vdev_init(char *qtest_path, char *ivshmem_path,
struct qtest_pci_device *devices, int devnum)
 {
struct qtest_session *s;
@@ -800,6 +892,12 @@ qtest_vdev_init(char *qtest_path,
goto error;
}

+   s->ivshmem_socket = qtest_open_socket(ivshmem_path);
+   if (s->ivshmem_socket < 0) {
+   PMD_DRV_LOG(ERR, "Failed to open %s\n", ivshmem_path);
+   goto error;
+   }
+
s->qtest_socket = qtest_open_socket(qtest_path);
if (s->qtest_socket < 0) {
PMD_

[dpdk-dev] [PATCH v4 06/12] virtio, qtest: Add pci device initialization function to qtest utils

2016-03-09 Thread Tetsuya Mukawa
The patch adds general pci device initialization functionality to
qtest utils. It initializes pci devices using qtest messaging.

Signed-off-by: Tetsuya Mukawa 
---
 drivers/net/virtio/qtest_utils.c | 349 ++-
 drivers/net/virtio/qtest_utils.h | 114 -
 2 files changed, 461 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/qtest_utils.c b/drivers/net/virtio/qtest_utils.c
index f4cd6af..000c7e8 100644
--- a/drivers/net/virtio/qtest_utils.c
+++ b/drivers/net/virtio/qtest_utils.c
@@ -43,6 +43,10 @@
 #include "virtio_ethdev.h"
 #include "qtest_utils.h"

+#define PCI_CONFIG_ADDR(_bus, _device, _function, _offset) ( \
+   (1 << 31) | ((_bus) & 0xff) << 16 | ((_device) & 0x1f) << 11 | \
+   ((_function) & 0x7) << 8 | ((_offset) & 0xfc))
+
 union qtest_pipefds {
struct {
int pipefd[2];
@@ -57,6 +61,8 @@ struct qtest_session {
int qtest_socket;
pthread_mutex_t qtest_session_lock;

+   struct qtest_pci_device_list head;
+
pthread_t event_th;
int event_th_started;
char *evq;
@@ -195,6 +201,119 @@ qtest_raw_write(struct qtest_session *s, uint64_t addr, 
uint32_t val, char type)
 }

 /*
+ * qtest_pci_inX/outX are used for accessing PCI configuration space.
+ * The functions are implemented based on PCI configuration space
+ * specification.
+ * Accroding to the spec, access size of read()/write() should be 4 bytes.
+ */
+static int
+qtest_pci_inb(struct qtest_session *s, uint8_t bus, uint8_t device,
+   uint8_t function, uint8_t offset)
+{
+   uint32_t tmp;
+
+   tmp = PCI_CONFIG_ADDR(bus, device, function, offset);
+
+   if (pthread_mutex_lock(>qtest_session_lock) < 0)
+   rte_panic("Cannot lock mutex\n");
+
+   qtest_raw_out(s, 0xcf8, tmp, 'l');
+   tmp = qtest_raw_in(s, 0xcfc, 'l');
+
+   if (pthread_mutex_unlock(>qtest_session_lock) < 0)
+   rte_panic("Cannot unlock mutex\n");
+
+   return (tmp >> ((offset & 0x3) * 8)) & 0xff;
+}
+
+static uint32_t
+qtest_pci_inl(struct qtest_session *s, uint8_t bus, uint8_t device,
+   uint8_t function, uint8_t offset)
+{
+   uint32_t tmp;
+
+   tmp = PCI_CONFIG_ADDR(bus, device, function, offset);
+
+   if (pthread_mutex_lock(>qtest_session_lock) < 0)
+   rte_panic("Cannot lock mutex\n");
+
+   qtest_raw_out(s, 0xcf8, tmp, 'l');
+   tmp = qtest_raw_in(s, 0xcfc, 'l');
+
+   if (pthread_mutex_unlock(>qtest_session_lock) < 0)
+   rte_panic("Cannot unlock mutex\n");
+
+   return tmp;
+}
+
+static void
+qtest_pci_outl(struct qtest_session *s, uint8_t bus, uint8_t device,
+   uint8_t function, uint8_t offset, uint32_t value)
+{
+   uint32_t tmp;
+
+   tmp = PCI_CONFIG_ADDR(bus, device, function, offset);
+
+   if (pthread_mutex_lock(>qtest_session_lock) < 0)
+   rte_panic("Cannot lock mutex\n");
+
+   qtest_raw_out(s, 0xcf8, tmp, 'l');
+   qtest_raw_out(s, 0xcfc, value, 'l');
+
+   if (pthread_mutex_unlock(>qtest_session_lock) < 0)
+   rte_panic("Cannot unlock mutex\n");
+}
+
+static uint64_t
+qtest_pci_inq(struct qtest_session *s, uint8_t bus, uint8_t device,
+   uint8_t function, uint8_t offset)
+{
+   uint32_t tmp;
+   uint64_t val;
+
+   tmp = PCI_CONFIG_ADDR(bus, device, function, offset);
+
+   if (pthread_mutex_lock(>qtest_session_lock) < 0)
+   rte_panic("Cannot lock mutex\n");
+
+   qtest_raw_out(s, 0xcf8, tmp, 'l');
+   val = (uint64_t)qtest_raw_in(s, 0xcfc, 'l');
+
+   tmp = PCI_CONFIG_ADDR(bus, device, function, offset + 4);
+
+   qtest_raw_out(s, 0xcf8, tmp, 'l');
+   val |= (uint64_t)qtest_raw_in(s, 0xcfc, 'l') << 32;
+
+   if (pthread_mutex_unlock(>qtest_session_lock) < 0)
+   rte_panic("Cannot unlock mutex\n");
+
+   return val;
+}
+
+static void
+qtest_pci_outq(struct qtest_session *s, uint8_t bus, uint8_t device,
+   uint8_t function, uint8_t offset, uint64_t value)
+{
+   uint32_t tmp;
+
+   tmp = PCI_CONFIG_ADDR(bus, device, function, offset);
+
+   if (pthread_mutex_lock(>qtest_session_lock) < 0)
+   rte_panic("Cannot lock mutex\n");
+
+   qtest_raw_out(s, 0xcf8, tmp, 'l');
+   qtest_raw_out(s, 0xcfc, (uint32_t)(value & 0x), 'l');
+
+   tmp = PCI_CONFIG_ADDR(bus, device, function, offset + 4);
+
+   qtest_raw_out(s, 0xcf8, tmp, 'l');
+   qtest_raw_out(s, 0xcfc, (uint32_t)(value >> 32), 'l');
+
+   if (pthread_mutex_unlock(>qtest_session_lock) < 0)
+   rte_panic("Cannot unlock mutex\n");
+}
+
+/*
  * qtest_in/out are used for accessing ioport of 

[dpdk-dev] [PATCH v4 05/12] virtio, qtest: Add QTest utility basic functions

2016-03-09 Thread Tetsuya Mukawa
The patch adds basic functions for accessing to QEMU quest that runs in
QTest mode. The functions will be used by virtio container extension
that can access to the above guest.

Signed-off-by: Tetsuya Mukawa 
---
 config/common_base   |   1 +
 drivers/net/virtio/Makefile  |   4 +
 drivers/net/virtio/qtest_utils.c | 480 +++
 drivers/net/virtio/qtest_utils.h | 119 ++
 4 files changed, 604 insertions(+)
 create mode 100644 drivers/net/virtio/qtest_utils.c
 create mode 100644 drivers/net/virtio/qtest_utils.h

diff --git a/config/common_base b/config/common_base
index 340feaf..b19cb59 100644
--- a/config/common_base
+++ b/config/common_base
@@ -260,6 +260,7 @@ CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_DUMP=n
 # Enable virtio support for container
 #
 CONFIG_RTE_VIRTIO_VDEV=n
+CONFIG_RTE_VIRTIO_VDEV_QTEST=n

 #
 # Compile burst-oriented VMXNET3 PMD driver
diff --git a/drivers/net/virtio/Makefile b/drivers/net/virtio/Makefile
index 9e83852..e6d5a04 100644
--- a/drivers/net/virtio/Makefile
+++ b/drivers/net/virtio/Makefile
@@ -59,6 +59,10 @@ ifeq ($(CONFIG_RTE_VIRTIO_VDEV),y)
SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += vhost_embedded.c
 endif

+ifeq ($(CONFIG_RTE_VIRTIO_VDEV_QTEST),y)
+   SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += qtest_utils.c
+endif
+
 # this lib depends upon:
 DEPDIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += lib/librte_eal lib/librte_ether
 DEPDIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += lib/librte_mempool lib/librte_mbuf
diff --git a/drivers/net/virtio/qtest_utils.c b/drivers/net/virtio/qtest_utils.c
new file mode 100644
index 000..f4cd6af
--- /dev/null
+++ b/drivers/net/virtio/qtest_utils.c
@@ -0,0 +1,480 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2016 IGEL Co., Ltd. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of IGEL Co., Ltd. nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "virtio_logs.h"
+#include "virtio_ethdev.h"
+#include "qtest_utils.h"
+
+union qtest_pipefds {
+   struct {
+   int pipefd[2];
+   };
+   struct {
+   int readfd;
+   int writefd;
+   };
+};
+
+struct qtest_session {
+   int qtest_socket;
+   pthread_mutex_t qtest_session_lock;
+
+   pthread_t event_th;
+   int event_th_started;
+   char *evq;
+   char *evq_dequeue_ptr;
+   size_t evq_total_len;
+
+   union qtest_pipefds msgfds;
+};
+
+static int
+qtest_raw_send(int fd, char *buf, size_t count)
+{
+   size_t len = count;
+   size_t total_len = 0;
+   int ret = 0;
+
+   while (len > 0) {
+   ret = write(fd, buf, len);
+   if (ret == -1) {
+   if (errno == EINTR)
+   continue;
+   return ret;
+   }
+   if (ret == (int)len)
+   break;
+   total_len += ret;
+   buf += ret;
+   len -= ret;
+   }
+   return total_len + ret;
+}
+
+static int
+qtest_raw_recv(int fd, char *buf, size_t count)
+{
+   size_t len = count;
+   size_t total_len = 0;
+   int ret = 0;
+
+   while (len > 0) {
+   ret = read(fd, buf, len);
+   if (ret <= 0) {
+   if (errno == EINTR) {
+   continue;
+  

[dpdk-dev] [PATCH v4 04/12] EAL: Add a new "--align-memsize" option

2016-03-09 Thread Tetsuya Mukawa
The option will work with "--range-virtaddr", and if the option is
specified, mapped address will be align by EAL memory size.
Such an alignment is required for using virtio-net PMD extension
on container that uses QEMU QTest framework.

Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_eal/common/eal_common_options.c | 8 
 lib/librte_eal/common/eal_internal_cfg.h   | 1 +
 lib/librte_eal/common/eal_options.h| 2 ++
 lib/librte_eal/linuxapp/eal/eal.c  | 4 
 lib/librte_eal/linuxapp/eal/eal_memory.c   | 9 +
 5 files changed, 24 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_options.c 
b/lib/librte_eal/common/eal_common_options.c
index 3b4f789..853420a 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -75,6 +75,7 @@ const struct option
 eal_long_options[] = {
{OPT_BASE_VIRTADDR, 1, NULL, OPT_BASE_VIRTADDR_NUM},
{OPT_RANGE_VIRTADDR,1, NULL, OPT_RANGE_VIRTADDR_NUM   },
+   {OPT_ALIGN_MEMSIZE, 0, NULL, OPT_ALIGN_MEMSIZE_NUM},
{OPT_CREATE_UIO_DEV,0, NULL, OPT_CREATE_UIO_DEV_NUM   },
{OPT_FILE_PREFIX,   1, NULL, OPT_FILE_PREFIX_NUM  },
{OPT_HELP,  0, NULL, OPT_HELP_NUM },
@@ -140,6 +141,7 @@ eal_reset_internal_config(struct internal_config 
*internal_cfg)
internal_cfg->base_virtaddr = 0;
internal_cfg->range_virtaddr_start = 0;
internal_cfg->range_virtaddr_end = 0;
+   internal_cfg->align_memsize = 0;

internal_cfg->syslog_facility = LOG_DAEMON;
/* default value from build option */
@@ -994,6 +996,12 @@ eal_check_common_options(struct internal_config 
*internal_cfg)
return -1;
}

+   if (internal_cfg->range_virtaddr_end == 0 && 
internal_cfg->align_memsize) {
+   RTE_LOG(ERR, EAL, "Option --"OPT_RANGE_VIRTADDR" should be "
+   "specified together with --"OPT_ALIGN_MEMSIZE"\n");
+   return -1;
+   }
+
return 0;
 }

diff --git a/lib/librte_eal/common/eal_internal_cfg.h 
b/lib/librte_eal/common/eal_internal_cfg.h
index 0734630..df33a9f 100644
--- a/lib/librte_eal/common/eal_internal_cfg.h
+++ b/lib/librte_eal/common/eal_internal_cfg.h
@@ -80,6 +80,7 @@ struct internal_config {
uintptr_t base_virtaddr;  /**< base address to try and reserve 
memory from */
uintptr_t range_virtaddr_start;   /**< start address of mappable region 
*/
uintptr_t range_virtaddr_end; /**< end address of mappable region */
+   volatile unsigned align_memsize;  /**< true to align virtaddr by memory 
size */
volatile int syslog_facility; /**< facility passed to openlog() */
volatile uint32_t log_level;  /**< default log level */
/** default interrupt mode for VFIO */
diff --git a/lib/librte_eal/common/eal_options.h 
b/lib/librte_eal/common/eal_options.h
index 8e4cf1d..9e36f68 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -49,6 +49,8 @@ enum {
OPT_BASE_VIRTADDR_NUM,
 #define OPT_RANGE_VIRTADDR"range-virtaddr"
OPT_RANGE_VIRTADDR_NUM,
+#define OPT_ALIGN_MEMSIZE "align-memsize"
+   OPT_ALIGN_MEMSIZE_NUM,
 #define OPT_CREATE_UIO_DEV"create-uio-dev"
OPT_CREATE_UIO_DEV_NUM,
 #define OPT_FILE_PREFIX   "file-prefix"
diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
b/lib/librte_eal/linuxapp/eal/eal.c
index 62b7a57..e2a0096 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -643,6 +643,10 @@ eal_parse_args(int argc, char **argv)
}
break;

+   case OPT_ALIGN_MEMSIZE_NUM:
+   internal_config.align_memsize = 1;
+   break;
+
case OPT_VFIO_INTR_NUM:
if (eal_parse_vfio_intr(optarg) < 0) {
RTE_LOG(ERR, EAL, "invalid parameters for --"
diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c 
b/lib/librte_eal/linuxapp/eal/eal_memory.c
index e15bf4c..1c9eb3c 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -272,6 +272,15 @@ rte_eal_get_free_region(uint64_t pagesz)
return 0;
}

+   if (internal_config.align_memsize) {
+   /*
+* Typically, BAR register of PCI device requiers such
+* an alignment.
+*/
+   low_limit = RTE_ALIGN_CEIL(low_limit, alloc_size);
+   high_limit = RTE_ALIGN_FLOOR(high_limit, alloc_size);
+   }
+
fp = fopen("/proc/self/maps", "r");
if (fp == NULL) {
rte_panic("Cannot open /proc/self/maps\n");
-- 
2.1.4



[dpdk-dev] [PATCH v4 03/12] EAL: Add a new "--range-virtaddr" option

2016-03-09 Thread Tetsuya Mukawa
The option specifies how to mmap EAL memory.
If the option is specified like '--range-virtaddr=-',
EAL will check /proc/maps, then tries to find free region between addr1
and addr2. If a region is found, EAL will treat it as if 'base-virtaddr'
is specified. Because of this, the option will not work with
'--base-virtaddr'.

Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_eal/common/eal_common_options.c |  9 
 lib/librte_eal/common/eal_internal_cfg.h   |  2 +
 lib/librte_eal/common/eal_options.h|  2 +
 lib/librte_eal/linuxapp/eal/eal.c  | 39 ++
 lib/librte_eal/linuxapp/eal/eal_memory.c   | 82 +-
 5 files changed, 133 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_options.c 
b/lib/librte_eal/common/eal_common_options.c
index 65bccbd..3b4f789 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -74,6 +74,7 @@ eal_short_options[] =
 const struct option
 eal_long_options[] = {
{OPT_BASE_VIRTADDR, 1, NULL, OPT_BASE_VIRTADDR_NUM},
+   {OPT_RANGE_VIRTADDR,1, NULL, OPT_RANGE_VIRTADDR_NUM   },
{OPT_CREATE_UIO_DEV,0, NULL, OPT_CREATE_UIO_DEV_NUM   },
{OPT_FILE_PREFIX,   1, NULL, OPT_FILE_PREFIX_NUM  },
{OPT_HELP,  0, NULL, OPT_HELP_NUM },
@@ -137,6 +138,8 @@ eal_reset_internal_config(struct internal_config 
*internal_cfg)
for (i = 0; i < MAX_HUGEPAGE_SIZES; i++)
internal_cfg->hugepage_info[i].lock_descriptor = -1;
internal_cfg->base_virtaddr = 0;
+   internal_cfg->range_virtaddr_start = 0;
+   internal_cfg->range_virtaddr_end = 0;

internal_cfg->syslog_facility = LOG_DAEMON;
/* default value from build option */
@@ -985,6 +988,12 @@ eal_check_common_options(struct internal_config 
*internal_cfg)
return -1;
}

+   if (internal_cfg->base_virtaddr && internal_cfg->range_virtaddr_end) {
+   RTE_LOG(ERR, EAL, "Option --"OPT_RANGE_VIRTADDR" cannot "
+   "be specified together with --"OPT_BASE_VIRTADDR"\n");
+   return -1;
+   }
+
return 0;
 }

diff --git a/lib/librte_eal/common/eal_internal_cfg.h 
b/lib/librte_eal/common/eal_internal_cfg.h
index 9117ed9..0734630 100644
--- a/lib/librte_eal/common/eal_internal_cfg.h
+++ b/lib/librte_eal/common/eal_internal_cfg.h
@@ -78,6 +78,8 @@ struct internal_config {
volatile unsigned force_sockets;
volatile uint64_t socket_mem[RTE_MAX_NUMA_NODES]; /**< amount of memory 
per socket */
uintptr_t base_virtaddr;  /**< base address to try and reserve 
memory from */
+   uintptr_t range_virtaddr_start;   /**< start address of mappable region 
*/
+   uintptr_t range_virtaddr_end; /**< end address of mappable region */
volatile int syslog_facility; /**< facility passed to openlog() */
volatile uint32_t log_level;  /**< default log level */
/** default interrupt mode for VFIO */
diff --git a/lib/librte_eal/common/eal_options.h 
b/lib/librte_eal/common/eal_options.h
index e5da14a..8e4cf1d 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -47,6 +47,8 @@ enum {
OPT_LONG_MIN_NUM = 256,
 #define OPT_BASE_VIRTADDR "base-virtaddr"
OPT_BASE_VIRTADDR_NUM,
+#define OPT_RANGE_VIRTADDR"range-virtaddr"
+   OPT_RANGE_VIRTADDR_NUM,
 #define OPT_CREATE_UIO_DEV"create-uio-dev"
OPT_CREATE_UIO_DEV_NUM,
 #define OPT_FILE_PREFIX   "file-prefix"
diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
b/lib/librte_eal/linuxapp/eal/eal.c
index 6bae02c..62b7a57 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -444,6 +444,35 @@ eal_parse_base_virtaddr(const char *arg)
 }

 static int
+eal_parse_range_virtaddr(const char *range)
+{
+   char *p, *endptr;
+   uint64_t tmp_start, tmp_end;
+
+   p = strchr(range, '-');
+   if (p == NULL)
+   return -1;
+   *p++ = '\0';
+
+   errno = 0;
+   tmp_start = strtoul(range, , 0);
+   if ((errno != 0) || endptr == NULL || (*endptr != '\0'))
+   return -1;
+
+   tmp_end = strtoul(p, , 0);
+   if ((errno != 0) || endptr == NULL || (*endptr != '\0'))
+   return -1;
+
+   if (tmp_start >= tmp_end)
+   return -1;
+
+   internal_config.range_virtaddr_start = tmp_start;
+   internal_config.range_virtaddr_end = tmp_end;
+
+   return 0;
+}
+
+static int
 eal_parse_vfio_intr(const char *mode)
 {
unsigned i;
@@ -604,6 +633,16 @@ eal_parse_args(int argc, char **argv)
}
break;

+   case OPT_RANGE_VIRTADDR_NUM:
+  

[dpdk-dev] [PATCH v4 02/12] vhost: Add a function to check virtio device type

2016-03-09 Thread Tetsuya Mukawa
The patch adds below function to cleanup virtio code.
 - virtio_dev_check()

Signed-off-by: Tetsuya Mukawa 
---
 drivers/net/virtio/virtio_ethdev.c | 52 ++
 drivers/net/virtio/virtio_ethdev.h | 32 +++
 2 files changed, 57 insertions(+), 27 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index 429377b..bc631c7 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -371,7 +371,7 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
vq->mz = mz;
vq->vq_ring_virt_mem = mz->addr;

-   if (dev->dev_type == RTE_ETH_DEV_PCI) {
+   if (virtio_dev_check(dev, RTE_ETH_DEV_PCI, NULL, 0)) {
vq->vq_ring_mem = mz->phys_addr;

/* Virtio PCI device VIRTIO_PCI_QUEUE_PF register is 32bit,
@@ -429,7 +429,7 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
vq->virtio_net_hdr_vaddr = mz->addr;
memset(vq->virtio_net_hdr_vaddr, 0, hdr_size);

-   if (dev->dev_type == RTE_ETH_DEV_PCI)
+   if (virtio_dev_check(dev, RTE_ETH_DEV_PCI, NULL, 0))
vq->virtio_net_hdr_mem = mz->phys_addr;
 #ifdef RTE_VIRTIO_VDEV
else
@@ -439,7 +439,7 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,

hw->vtpci_ops->setup_queue(hw, vq);

-   if (dev->dev_type == RTE_ETH_DEV_PCI)
+   if (virtio_dev_check(dev, RTE_ETH_DEV_PCI, NULL, 0))
vq->offset = offsetof(struct rte_mbuf, buf_physaddr);
 #ifdef RTE_VIRTIO_VDEV
else
@@ -490,15 +490,13 @@ static void
 virtio_dev_close(struct rte_eth_dev *dev)
 {
struct virtio_hw *hw = dev->data->dev_private;
-   struct rte_pci_device *pci_dev = dev->pci_dev;

PMD_INIT_LOG(DEBUG, "virtio_dev_close");

/* reset the NIC */
-   if (dev->dev_type == RTE_ETH_DEV_PCI) {
-   if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
-   vtpci_irq_config(hw, VIRTIO_MSI_NO_VECTOR);
-   }
+   if (virtio_dev_check(dev, RTE_ETH_DEV_PCI, NULL, RTE_PCI_DRV_INTR_LSC))
+   vtpci_irq_config(hw, VIRTIO_MSI_NO_VECTOR);
+
vtpci_reset(hw);
hw->started = 0;
virtio_dev_free_mbufs(dev);
@@ -1001,7 +999,7 @@ virtio_interrupt_handler(__rte_unused struct 
rte_intr_handle *handle,
isr = vtpci_isr(hw);
PMD_DRV_LOG(INFO, "interrupt status = %#x", isr);

-   if (dev->dev_type == RTE_ETH_DEV_PCI)
+   if (virtio_dev_check(dev, RTE_ETH_DEV_PCI, NULL, 0))
if (rte_intr_enable(>pci_dev->intr_handle) < 0)
PMD_DRV_LOG(ERR, "interrupt enable failed");

@@ -1056,9 +1054,10 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)

pci_dev = eth_dev->pci_dev;

-   if (eth_dev->dev_type == RTE_ETH_DEV_PCI)
+   if (virtio_dev_check(eth_dev, RTE_ETH_DEV_PCI, NULL, 0)) {
if (vtpci_init(pci_dev, hw) < 0)
return -1;
+   }

/* Reset the device although not necessary at startup */
vtpci_reset(hw);
@@ -1072,7 +1071,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
return -1;

/* If host does not support status then disable LSC */
-   if (eth_dev->dev_type == RTE_ETH_DEV_PCI) {
+   if (virtio_dev_check(eth_dev, RTE_ETH_DEV_PCI, NULL, 0)) {
if (!vtpci_with_feature(hw, VIRTIO_NET_F_STATUS))
pci_dev->driver->drv_flags &= ~RTE_PCI_DRV_INTR_LSC;

@@ -1154,13 +1153,14 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)

PMD_INIT_LOG(DEBUG, "hw->max_rx_queues=%d   hw->max_tx_queues=%d",
hw->max_rx_queues, hw->max_tx_queues);
-   if (eth_dev->dev_type == RTE_ETH_DEV_PCI) {
+   if (virtio_dev_check(eth_dev, RTE_ETH_DEV_PCI, NULL, 0)) {
PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x",
 eth_dev->data->port_id, pci_dev->id.vendor_id,
 pci_dev->id.device_id);

/* Setup interrupt callback  */
-   if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
+   if (virtio_dev_check(eth_dev, RTE_ETH_DEV_PCI,
+   NULL, RTE_PCI_DRV_INTR_LSC))
rte_intr_callback_register(_dev->intr_handle,
   virtio_interrupt_handler,
   eth_dev);
@@ -1197,11 +1197,11 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
eth_dev->data->mac_addrs = NULL;

/* reset interrupt c

[dpdk-dev] [PATCH v4 01/12] virtio: Retrieve driver name from eth_dev

2016-03-09 Thread Tetsuya Mukawa
Currently, virtio_dev_info_get() retrieves driver name from pci_drv.
If the driver is virtual PMD, pci_drv will be invalid.
So retrieves the name from eth_dev.

Signed-off-by: Tetsuya Mukawa 
---
 drivers/net/virtio/virtio_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index bff1926..429377b 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1438,7 +1438,7 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
 {
struct virtio_hw *hw = dev->data->dev_private;

-   dev_info->driver_name = dev->driver->pci_drv.name;
+   dev_info->driver_name = dev->data->drv_name;
dev_info->max_rx_queues = (uint16_t)hw->max_rx_queues;
dev_info->max_tx_queues = (uint16_t)hw->max_tx_queues;
dev_info->min_rx_bufsize = VIRTIO_MIN_RX_BUFSIZE;
-- 
2.1.4



[dpdk-dev] [PATCH v4 00/12] Virtio-net PMD: QEMU QTest extension for container

2016-03-09 Thread Tetsuya Mukawa
ed memory 
should be consist of one file.
To allocate such a memory, EAL has new option called "--single-file".
Also, the hugepages should be mapped between "1 << 31" to "1 << 44".
To map like above, EAL has one more new option called "-qtest-virtio".
While initializing ivshmem device, we can set BAR(Base Address Register).
It represents which memory QEMU vcpu can access to this shared memory.
We will specify host virtual address of shared memory as this address.
It is very useful because we don't need to apply patch to QEMU to calculate 
address offset.
(For example, if virtio-net PMD process will allocate memory from shared 
memory, then specify the virtual address of it to virtio-net register, QEMU 
virtio-net device can understand it without calculating address offset.)


Tetsuya Mukawa (12):
  virtio: Retrieve driver name from eth_dev
  vhost: Add a function to check virtio device type
  EAL: Add a new "--range-virtaddr" option
  EAL: Add a new "--align-memsize" option
  virtio,qtest: Add QTest utility basic functions
  virtio,qtest: Add pci device initialization function to qtest utils
  virtio,qtest: Add functionality to share memory between QTest guest
  virtio,qtest: Add functionality to handle interrupt
  virtio,qtest: Add misc functions to handle pci information
  virtio: Add QTest support to vtpci abstraction
  virtio: Add QTest support for virtio-net PMD
  docs: add release note for qtest virtio container support

 config/common_base |1 +
 doc/guides/rel_notes/release_16_04.rst |3 +
 drivers/net/virtio/Makefile|4 +
 drivers/net/virtio/qtest.h |   94 +++
 drivers/net/virtio/qtest_utils.c   | 1223 
 drivers/net/virtio/qtest_utils.h   |  355 
 drivers/net/virtio/virtio_ethdev.c |  509 +++-
 drivers/net/virtio/virtio_ethdev.h |   32 +
 drivers/net/virtio/virtio_pci.c|  368 -
 drivers/net/virtio/virtio_pci.h|9 +-
 lib/librte_eal/common/eal_common_options.c |   17 +
 lib/librte_eal/common/eal_internal_cfg.h   |3 +
 lib/librte_eal/common/eal_options.h|4 +
 lib/librte_eal/linuxapp/eal/eal.c  |   43 +
 lib/librte_eal/linuxapp/eal/eal_memory.c   |   91 ++-
 15 files changed, 2687 insertions(+), 69 deletions(-)
 create mode 100644 drivers/net/virtio/qtest.h
 create mode 100644 drivers/net/virtio/qtest_utils.c
 create mode 100644 drivers/net/virtio/qtest_utils.h

-- 
2.1.4



[dpdk-dev] [PATCH v11 2/2] vhost: Add VHOST PMD

2016-03-07 Thread Tetsuya Mukawa
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.

The PMD has 2 parameters.
 - iface:  The parameter is used to specify a path to connect to a
   virtio-net device.
 - queues: The parameter is used to specify the number of the queues
   virtio-net device has.
   (Default: 1)

Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i

To connect above testpmd, here is qemu command example.

$ qemu-system-x86_64 \

-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on

Signed-off-by: Tetsuya Mukawa 
Acked-by: Ferruh Yigit 
Acked-by: Yuanhan Liu 
Acked-by: Rich Lane 
Tested-by: Rich Lane 
---
 MAINTAINERS |   5 +
 config/common_base  |   6 +
 config/common_linuxapp  |   1 +
 doc/guides/nics/index.rst   |   1 +
 doc/guides/rel_notes/release_16_04.rst  |   4 +
 drivers/net/Makefile|   4 +
 drivers/net/vhost/Makefile  |  62 ++
 drivers/net/vhost/rte_eth_vhost.c   | 916 
 drivers/net/vhost/rte_eth_vhost.h   | 109 
 drivers/net/vhost/rte_pmd_vhost_version.map |  10 +
 mk/rte.app.mk   |   6 +
 11 files changed, 1124 insertions(+)
 create mode 100644 drivers/net/vhost/Makefile
 create mode 100644 drivers/net/vhost/rte_eth_vhost.c
 create mode 100644 drivers/net/vhost/rte_eth_vhost.h
 create mode 100644 drivers/net/vhost/rte_pmd_vhost_version.map

diff --git a/MAINTAINERS b/MAINTAINERS
index 628bc05..b5b11b0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -352,6 +352,11 @@ Null PMD
 M: Tetsuya Mukawa 
 F: drivers/net/null/

+Vhost PMD
+M: Tetsuya Mukawa 
+M: Yuanhan Liu 
+F: drivers/net/vhost/
+
 Intel AES-NI Multi-Buffer
 M: Declan Doherty 
 F: drivers/crypto/aesni_mb/
diff --git a/config/common_base b/config/common_base
index 1af28c8..b054c00 100644
--- a/config/common_base
+++ b/config/common_base
@@ -495,6 +495,12 @@ CONFIG_RTE_LIBRTE_VHOST_NUMA=n
 CONFIG_RTE_LIBRTE_VHOST_DEBUG=n

 #
+# Compile vhost PMD
+# To compile, CONFIG_RTE_LIBRTE_VHOST should be enabled.
+#
+CONFIG_RTE_LIBRTE_PMD_VHOST=n
+
+#
 #Compile Xen domain0 support
 #
 CONFIG_RTE_LIBRTE_XEN_DOM0=n
diff --git a/config/common_linuxapp b/config/common_linuxapp
index ffbe260..7e698e2 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -40,5 +40,6 @@ CONFIG_RTE_EAL_VFIO=y
 CONFIG_RTE_KNI_KMOD=y
 CONFIG_RTE_LIBRTE_KNI=y
 CONFIG_RTE_LIBRTE_VHOST=y
+CONFIG_RTE_LIBRTE_PMD_VHOST=y
 CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y
 CONFIG_RTE_LIBRTE_POWER=y
diff --git a/doc/guides/nics/index.rst b/doc/guides/nics/index.rst
index 8618114..6bb79b0 100644
--- a/doc/guides/nics/index.rst
+++ b/doc/guides/nics/index.rst
@@ -48,6 +48,7 @@ Network Interface Controller Drivers
 nfp
 szedata2
 virtio
+vhost
 vmxnet3
 pcap_ring

diff --git a/doc/guides/rel_notes/release_16_04.rst 
b/doc/guides/rel_notes/release_16_04.rst
index 24f15bf..f8c069f 100644
--- a/doc/guides/rel_notes/release_16_04.rst
+++ b/doc/guides/rel_notes/release_16_04.rst
@@ -57,6 +57,10 @@ This section should contain new features added in this 
release. Sample format:

 * **Added vhost-user live migration support.**

+* **Added vhost PMD.**
+
+  Added virtual PMD that wraps librte_vhost.
+

 Resolved Issues
 ---
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 0c3393f..8ba37fb 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -52,4 +52,8 @@ DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio
 DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += vmxnet3
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += xenvirt

+ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y)
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost
+endif # $(CONFIG_RTE_LIBRTE_VHOST)
+
 include $(RTE_SDK)/mk/rte.subdir.mk
diff --git a/drivers/net/vhost/Makefile b/drivers/net/vhost/Makefile
new file mode 100644
index 000..f49a69b
--- /dev/null
+++ b/drivers/net/vhost/Makefile
@@ -0,0 +1,62 @@
+#   BSD LICENSE
+#
+#   Copyright (c) 2010-2016 Intel Corporation.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution

[dpdk-dev] [PATCH v11 1/2] ethdev: Add a new event type to notify a queue state changed event

2016-03-07 Thread Tetsuya Mukawa
This patch adds a below event type.
 - RTE_ETH_EVENT_QUEUE_STATE_CHANGE
This event is used for notifying a queue state changed event.

Signed-off-by: Tetsuya Mukawa 
Acked-by: Ferruh Yigit 
Acked-by: Yuanhan Liu 
Acked-by: Rich Lane 
Tested-by: Rich Lane 
---
 lib/librte_ether/rte_ethdev.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index d53e362..7817d4a 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2661,6 +2661,8 @@ rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
 enum rte_eth_event_type {
RTE_ETH_EVENT_UNKNOWN,  /**< unknown event type */
RTE_ETH_EVENT_INTR_LSC, /**< lsc interrupt event */
+   RTE_ETH_EVENT_QUEUE_STATE_CHANGE,
+   /**< queue state changed interrupt */
RTE_ETH_EVENT_MAX   /**< max value of this enum */
 };

-- 
2.1.4



[dpdk-dev] [PATCH v11 0/2] Add VHOST PMD

2016-03-07 Thread Tetsuya Mukawa
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost.


PATCH v11 changes:
 - Rebase on latest master.
 - Fix MAINTAINERS file.
 - Fix Acked-by and Tested-by signatures of commit log.

PATCH v10 changes:
 - Rebase on latest master.
 - Fix DPDK version number(2.3 to 16.04)
 - Set port id to mbuf while receiving packets.

PATCH v9 changes:
 - Fix a null pointer access issue implemented in v8 patch.

PATCH v8 changes:
 - Manage ether devices list instead of internal structures list.
 - Remove needless NULL checking.
 - Replace "pthread_exit" to "return NULL".
 - Replace rte_panic to RTE_LOG, also add error handling.
 - Remove duplicated lines.
 - Remove needless casting.
 - Follow coding style.
 - Remove needless parenthesis.

PATCH v7 changes:
 - Remove needless parenthesis.
 - Add release note.
 - Remove needless line wraps.
 - Add null pointer check in vring_state_changed().
 - Free queue memory in eth_queue_release().
 - Fix wrong variable name.
 - Fix error handling code of eth_dev_vhost_create() and
   rte_pmd_vhost_devuninit().
 - Remove needless null checking from rte_pmd_vhost_devinit/devuninit().
 - Use port id to create mac address.
 - Add doxygen style comments in "rte_eth_vhost.h".
 - Fix wrong comment in "mk/rte.app.mk".

PATCH v6 changes:
 - Remove rte_vhost_driver_pmd_callback_registe().
 - Support link status interrupt.
 - Support queue state changed interrupt.
 - Add rte_eth_vhost_get_queue_event().
 - Support numa node detection when new device is connected.

PATCH v5 changes:
 - Rebase on latest master.
 - Fix RX/TX routine to count RX/TX bytes.
 - Fix RX/TX routine not to count as error packets if enqueue/dequeue
   cannot send all packets.
 - Fix if-condition checking for multiqueues.
 - Add "static" to pthread variable.
 - Fix format.
 - Change default behavior not to receive queueing event from driver.
 - Split the patch to separate rte_eth_vhost_portid2vdev().

PATCH v4 changes:
 - Rebase on latest DPDK tree.
 - Fix cording style.
 - Fix code not to invoke multiple messaging handling threads.
 - Fix code to handle vdev parameters correctly.
 - Remove needless cast.
 - Remove needless if-condition before rt_free().

PATCH v3 changes:
 - Rebase on latest matser
 - Specify correct queue_id in RX/TX function.

PATCH v2 changes:
 - Remove a below patch that fixes vhost library.
   The patch was applied as a separate patch.
   - vhost: fix crash with multiqueue enabled
 - Fix typos.
   (Thanks to Thomas, Monjalon)
 - Rebase on latest tree with above bernard's patches.

PATCH v1 changes:
 - Support vhost multiple queues.
 - Rebase on "remove pci driver from vdevs".
 - Optimize RX/TX functions.
 - Fix resource leaks.
 - Fix compile issue.
 - Add patch to fix vhost library.

RFC PATCH v3 changes:
 - Optimize performance.
   In RX/TX functions, change code to access only per core data.
 - Add below API to allow user to use vhost library APIs for a port managed
   by vhost PMD. There are a few limitations. See "rte_eth_vhost.h".
- rte_eth_vhost_portid2vdev()
   To support this functionality, vhost library is also changed.
   Anyway, if users doesn't use vhost PMD, can fully use vhost library APIs.
 - Add code to support vhost multiple queues.
   Actually, multiple queues functionality is not enabled so far.

RFC PATCH v2 changes:
 - Fix issues reported by checkpatch.pl
   (Thanks to Stephen Hemminger)


Tetsuya Mukawa (2):
  ethdev: Add a new event type to notify a queue state changed event
  vhost: Add VHOST PMD

 MAINTAINERS |   5 +
 config/common_base  |   6 +
 config/common_linuxapp  |   1 +
 doc/guides/nics/index.rst   |   1 +
 doc/guides/rel_notes/release_16_04.rst  |   4 +
 drivers/net/Makefile|   4 +
 drivers/net/vhost/Makefile  |  62 ++
 drivers/net/vhost/rte_eth_vhost.c   | 916 
 drivers/net/vhost/rte_eth_vhost.h   | 109 
 drivers/net/vhost/rte_pmd_vhost_version.map |  10 +
 lib/librte_ether/rte_ethdev.h   |   2 +
 mk/rte.app.mk   |   6 +
 12 files changed, 1126 insertions(+)
 create mode 100644 drivers/net/vhost/Makefile
 create mode 100644 drivers/net/vhost/rte_eth_vhost.c
 create mode 100644 drivers/net/vhost/rte_eth_vhost.h
 create mode 100644 drivers/net/vhost/rte_pmd_vhost_version.map

-- 
2.1.4



[dpdk-dev] [PATCH v10 2/2] vhost: Add VHOST PMD

2016-03-04 Thread Tetsuya Mukawa
On 2016/03/04 17:39, Yuanhan Liu wrote:
> On Fri, Mar 04, 2016 at 01:17:42PM +0900, Tetsuya Mukawa wrote:
>> The patch introduces a new PMD. This PMD is implemented as thin wrapper
>> of librte_vhost. It means librte_vhost is also needed to compile the PMD.
>> The vhost messages will be handled only when a port is started. So start
>> a port first, then invoke QEMU.
>>
>> The PMD has 2 parameters.
>>  - iface:  The parameter is used to specify a path to connect to a
>>virtio-net device.
>>  - queues: The parameter is used to specify the number of the queues
>>virtio-net device has.
>>(Default: 1)
>>
>> Here is an example.
>> $ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
>>
>> To connect above testpmd, here is qemu command example.
>>
>> $ qemu-system-x86_64 \
>> 
>> -chardev socket,id=chr0,path=/tmp/sock0 \
>> -netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
>> -device virtio-net-pci,netdev=net0,mq=on
>>
>> Signed-off-by: Tetsuya Mukawa 
>> Acked-by: Ferruh Yigit 
> You should carry my Acked-by that I gave few versions before, as well
> as the Reviewed-by and Tested-by from Rich, if my memory serves me
> right. It's also a way to show respects to the reivew/test efforts
> from them.

Sure, I will submit one more patch, and will add them.

>> ---
>>  MAINTAINERS |   4 +
> Mind to add me to the MAINTAINER list as well if you send another
> version? :) If so, don't put my email address wrongly, which you
> have done many times ;-)

Thank you so much for it. And sorry I get wrong your email address.
I will add you in MAINTAINERS in next patch.

Thanks,
Tetsuya

>   --yliu



[dpdk-dev] [PATCH v3 5/6] virtio: Add support for qtest virtio-net PMD

2016-03-04 Thread Tetsuya Mukawa
On 2016/03/04 15:10, Tan, Jianfeng wrote:
> Hi Tetsuya,
>
> On 3/4/2016 1:05 PM, Tetsuya Mukawa wrote:
>> On 2016/03/04 11:18, Tan, Jianfeng wrote:
>>> Hi Tetsuya,
>>>
>>> Seems that this patch is too long. Is it possible to split into
>>> multiple commits?
>> Hi Jianfeng,
>>
>> Sure, will do.
>>
>>> On 2/22/2016 4:17 PM, Tetsuya Mukawa wrote:
>>>> The patch adds a new virtio-net PMD configuration that allows the
>>>> PMD to
>>>> work on host as if the PMD is in VM.
>>>> Here is new configuration for virtio-net PMD.
>>>>- CONFIG_RTE_VIRTIO_VDEV_QTEST
>>>> To use this mode, EAL needs map all hugepages as one file. Also the
>>>> file
>>>> should be mapped between (1 << 31) and (1 << 44). And start address
>>>> should be aligned by EAL memory size.
>>>>
>>>> To allocate like above, use below options.
>>>>--single-file
>>>>--range-virtaddr=0x8000-0x1000
>>>>--align-memsize
>>>> If a free regions isn't found, EAL will return error.
>>>>
>>>> To prepare virtio-net device on host, the users need to invoke QEMU
>>>> process in special qtest mode. This mode is mainly used for testing
>>>> QEMU
>>>> devices from outer process. In this mode, no guest runs.
>>>> Here is QEMU command line.
>>>>
>>>>$ qemu-system-x86_64 \
>>>>-machine pc-i440fx-1.4,accel=qtest \
>>>>-display none -qtest-log /dev/null \
>>>>-qtest unix:/tmp/socket,server \
>>>>-netdev type=tap,script=/etc/qemu-ifup,id=net0,queues=1 \
>>>>-device
>>>> virtio-net-pci,netdev=net0,mq=on,disable-modern=false,addr=3 \
>>>>-chardev socket,id=chr1,path=/tmp/ivshmem,server \
>>>>-device ivshmem,size=1G,chardev=chr1,vectors=1,addr=4
>>>>
>>>>* Should use qemu-2.5.1, or above.
>>>>* QEMU process is needed per port.
>>>>* virtio-1.0 device are only supported.
>>>>* The vhost backends like vhost-net and vhost-user can be
>>>> specified.
>>>>* In most cases, just using above command is enough, but you can
>>>> also
>>>>  specify other QEMU virtio-net options.
>>>>* Only checked "pc-i440fx-1.4" machine, but may work with other
>>>>  machines.
>>>>* Should not add "--enable-kvm" to QEMU command line.
>>> Correct me if wrong: all control msgs go through qemu process, e.g.,
>>> tx notifications and rx interrupts need follow frontend-qemu-backend
>>> path. Question: qemu is started without --enable-kvm, as I understand,
>>> ioeventfd, the basis of kickfd/callfd, will not be available. So how
>>> does qemu kick backend or be kicked by backend?
>> Actually, vhost-backend process will receive kickfd and callfd as -1.
>> (Currently, we have a bug in librte_vhost, because the library treats -1
>> as "not initialized state". But actually without "--enable-kvm", -1 will
>> be set by qemu to initialize kickfd and callfd. I will send a patch for
>> the issue with next patch series.)
>
> Yes, we noticed the problem too: librte_vhost judges virtio_is_ready
> by whether both fds are set. But except that, what's kernel's way to
> do the judgement? In addition, it would be better to be a independent
> fix patch.
>

Even if fd is -1, "VHOST_SET_VRING_KICK/CALL" will be issued.
So we can know correct timing.

I have tested current QEMU, and reviewed kernel code to know how kernel
treats it.
And I've fount below.

 - vhost-user backend case.
 "-1" will be set as kickfd and callfd.
 - kernel vhost-net backend case.
 Actually eventfd will be set as kickfd and callfd.

So if backend is vhost-net, vhost-net will use eventfd.

>>
>> In our case, virtio-net driver and vhost-backend driver are PMD. So we
>> don't use kickfd and callfd, right?
>>
>> If you worried about vhost-net case, vhost-net kernel thread will work
>> without ioeventfd and irqfd.
>> In this case, virtio-net PMD can kick the vhost-net by accessing
>> VIRTIO_PCI_QUEUE_NOTIFY register.
>> (vhost-net doesn't need to kick virtio-net driver, because the driver is
>> PMD.)
>
> I ask this question because I think interrupt mode will help the
> scalability. Return to your solution, by accessing
> VIRTIO_PCI_QUEUE_NOTIFY register, virtio-net PMD can only wake up
> qemu, but ho

[dpdk-dev] [PATCH v3 5/6] virtio: Add support for qtest virtio-net PMD

2016-03-04 Thread Tetsuya Mukawa
On 2016/03/04 11:18, Tan, Jianfeng wrote:
> Hi Tetsuya,
>
> Seems that this patch is too long. Is it possible to split into
> multiple commits?

Hi Jianfeng,

Sure, will do.

>
> On 2/22/2016 4:17 PM, Tetsuya Mukawa wrote:
>> The patch adds a new virtio-net PMD configuration that allows the PMD to
>> work on host as if the PMD is in VM.
>> Here is new configuration for virtio-net PMD.
>>   - CONFIG_RTE_VIRTIO_VDEV_QTEST
>> To use this mode, EAL needs map all hugepages as one file. Also the file
>> should be mapped between (1 << 31) and (1 << 44). And start address
>> should be aligned by EAL memory size.
>>
>> To allocate like above, use below options.
>>   --single-file
>>   --range-virtaddr=0x8000-0x1000
>>   --align-memsize
>> If a free regions isn't found, EAL will return error.
>>
>> To prepare virtio-net device on host, the users need to invoke QEMU
>> process in special qtest mode. This mode is mainly used for testing QEMU
>> devices from outer process. In this mode, no guest runs.
>> Here is QEMU command line.
>>
>>   $ qemu-system-x86_64 \
>>   -machine pc-i440fx-1.4,accel=qtest \
>>   -display none -qtest-log /dev/null \
>>   -qtest unix:/tmp/socket,server \
>>   -netdev type=tap,script=/etc/qemu-ifup,id=net0,queues=1 \
>>   -device
>> virtio-net-pci,netdev=net0,mq=on,disable-modern=false,addr=3 \
>>   -chardev socket,id=chr1,path=/tmp/ivshmem,server \
>>   -device ivshmem,size=1G,chardev=chr1,vectors=1,addr=4
>>
>>   * Should use qemu-2.5.1, or above.
>>   * QEMU process is needed per port.
>>   * virtio-1.0 device are only supported.
>>   * The vhost backends like vhost-net and vhost-user can be specified.
>>   * In most cases, just using above command is enough, but you can also
>> specify other QEMU virtio-net options.
>>   * Only checked "pc-i440fx-1.4" machine, but may work with other
>> machines.
>>   * Should not add "--enable-kvm" to QEMU command line.
>
> Correct me if wrong: all control msgs go through qemu process, e.g.,
> tx notifications and rx interrupts need follow frontend-qemu-backend
> path. Question: qemu is started without --enable-kvm, as I understand,
> ioeventfd, the basis of kickfd/callfd, will not be available. So how
> does qemu kick backend or be kicked by backend?

Actually, vhost-backend process will receive kickfd and callfd as -1.
(Currently, we have a bug in librte_vhost, because the library treats -1
as "not initialized state". But actually without "--enable-kvm", -1 will
be set by qemu to initialize kickfd and callfd. I will send a patch for
the issue with next patch series.)

In our case, virtio-net driver and vhost-backend driver are PMD. So we
don't use kickfd and callfd, right?

If you worried about vhost-net case, vhost-net kernel thread will work
without ioeventfd and irqfd.
In this case, virtio-net PMD can kick the vhost-net by accessing
VIRTIO_PCI_QUEUE_NOTIFY register.
(vhost-net doesn't need to kick virtio-net driver, because the driver is
PMD.)

>
>>
>> After invoking QEMU, the PMD can connect to QEMU process using unix
>> domain sockets. Over these sockets, virtio-net, ivshmem and piix3
>> device in QEMU are probed by the PMD.
>> Here is example of command line.
>>
>>   $ testpmd -c f -n 1 -m 1024 --no-pci --single-file \
>>--range-virtaddr=0x8000-0x1000 --align-memsize \
>>   
>> --vdev="eth_qtest_virtio0,qtest=/tmp/socket,ivshmem=/tmp/ivshmem"\
>>-- --disable-hw-vlan --txqflags=0xf00 -i
>>
>> Please specify same unix domain sockets and memory size in both QEMU
>> and DPDK command lines like above.
>> The share memory size should be power of 2, because ivshmem only
>> accepts such memory size.
>>
>> Signed-off-by: Tetsuya Mukawa 
>> ---
>>   config/common_linuxapp |1 +
>>   drivers/net/virtio/Makefile|4 +
>>   drivers/net/virtio/qtest.c | 1342
>> 
>>   drivers/net/virtio/qtest.h |   65 ++
>>   drivers/net/virtio/virtio_ethdev.c |  383 +-
>>   drivers/net/virtio/virtio_pci.c|  364 +-
>>   drivers/net/virtio/virtio_pci.h|5 +-
>>   7 files changed, 2122 insertions(+), 42 deletions(-)
>>   create mode 100644 drivers/net/virtio/qtest.c
>>   create mode 100644 drivers/net/virtio/qtest.h
>>
>> diff --git a/config/common_linuxapp b/config/common_linuxapp
>> index 452f39c..f6e53bc 100644
>> --- a/config/common_linuxapp
>

[dpdk-dev] [PATCH v10 2/2] vhost: Add VHOST PMD

2016-03-04 Thread Tetsuya Mukawa
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.

The PMD has 2 parameters.
 - iface:  The parameter is used to specify a path to connect to a
   virtio-net device.
 - queues: The parameter is used to specify the number of the queues
   virtio-net device has.
   (Default: 1)

Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i

To connect above testpmd, here is qemu command example.

$ qemu-system-x86_64 \

-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on

Signed-off-by: Tetsuya Mukawa 
Acked-by: Ferruh Yigit 
---
 MAINTAINERS |   4 +
 config/common_linuxapp  |   6 +
 doc/guides/nics/index.rst   |   1 +
 doc/guides/rel_notes/release_16_04.rst  |   4 +
 drivers/net/Makefile|   1 +
 drivers/net/vhost/Makefile  |  62 ++
 drivers/net/vhost/rte_eth_vhost.c   | 916 
 drivers/net/vhost/rte_eth_vhost.h   | 109 
 drivers/net/vhost/rte_pmd_vhost_version.map |  10 +
 mk/rte.app.mk   |   6 +
 10 files changed, 1119 insertions(+)
 create mode 100644 drivers/net/vhost/Makefile
 create mode 100644 drivers/net/vhost/rte_eth_vhost.c
 create mode 100644 drivers/net/vhost/rte_eth_vhost.h
 create mode 100644 drivers/net/vhost/rte_pmd_vhost_version.map

diff --git a/MAINTAINERS b/MAINTAINERS
index 628bc05..2ec7cd4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -352,6 +352,10 @@ Null PMD
 M: Tetsuya Mukawa 
 F: drivers/net/null/

+Vhost PMD
+M: Tetsuya Mukawa 
+F: drivers/net/vhost/
+
 Intel AES-NI Multi-Buffer
 M: Declan Doherty 
 F: drivers/crypto/aesni_mb/
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 26df137..4915709 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -503,6 +503,12 @@ CONFIG_RTE_LIBRTE_VHOST_NUMA=n
 CONFIG_RTE_LIBRTE_VHOST_DEBUG=n

 #
+# Compile vhost PMD
+# To compile, CONFIG_RTE_LIBRTE_VHOST should be enabled.
+#
+CONFIG_RTE_LIBRTE_PMD_VHOST=y
+
+#
 #Compile Xen domain0 support
 #
 CONFIG_RTE_LIBRTE_XEN_DOM0=n
diff --git a/doc/guides/nics/index.rst b/doc/guides/nics/index.rst
index 8618114..6bb79b0 100644
--- a/doc/guides/nics/index.rst
+++ b/doc/guides/nics/index.rst
@@ -48,6 +48,7 @@ Network Interface Controller Drivers
 nfp
 szedata2
 virtio
+vhost
 vmxnet3
 pcap_ring

diff --git a/doc/guides/rel_notes/release_16_04.rst 
b/doc/guides/rel_notes/release_16_04.rst
index 9442018..feae36a 100644
--- a/doc/guides/rel_notes/release_16_04.rst
+++ b/doc/guides/rel_notes/release_16_04.rst
@@ -57,6 +57,10 @@ This section should contain new features added in this 
release. Sample format:

 * **Added vhost-user live migration support.**

+* **Added vhost PMD.**
+
+  Added virtual PMD that wraps librte_vhost.
+

 Resolved Issues
 ---
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 0c3393f..ceb2010 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -51,5 +51,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2) += szedata2
 DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio
 DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += vmxnet3
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += xenvirt
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost

 include $(RTE_SDK)/mk/rte.subdir.mk
diff --git a/drivers/net/vhost/Makefile b/drivers/net/vhost/Makefile
new file mode 100644
index 000..f49a69b
--- /dev/null
+++ b/drivers/net/vhost/Makefile
@@ -0,0 +1,62 @@
+#   BSD LICENSE
+#
+#   Copyright (c) 2010-2016 Intel Corporation.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution.
+# * Neither the name of Intel corporation nor the names of its
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE

[dpdk-dev] [PATCH v10 1/2] ethdev: Add a new event type to notify a queue state changed event

2016-03-04 Thread Tetsuya Mukawa
This patch adds a below event type.
 - RTE_ETH_EVENT_QUEUE_STATE_CHANGE
This event is used for notifying a queue state changed event.

Signed-off-by: Tetsuya Mukawa 
Acked-by: Ferruh Yigit 
---
 lib/librte_ether/rte_ethdev.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index d53e362..7817d4a 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2661,6 +2661,8 @@ rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
 enum rte_eth_event_type {
RTE_ETH_EVENT_UNKNOWN,  /**< unknown event type */
RTE_ETH_EVENT_INTR_LSC, /**< lsc interrupt event */
+   RTE_ETH_EVENT_QUEUE_STATE_CHANGE,
+   /**< queue state changed interrupt */
RTE_ETH_EVENT_MAX   /**< max value of this enum */
 };

-- 
2.1.4



[dpdk-dev] [PATCH v10 0/2] Add VHOST PMD

2016-03-04 Thread Tetsuya Mukawa
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost.


PATCH v10 changes:
 - Rebase on latest master.
 - Fix DPDK version number(2.3 to 16.04)
 - Set port id to mbuf while receiving packets.

PATCH v9 changes:
 - Fix a null pointer access issue implemented in v8 patch.

PATCH v8 changes:
 - Manage ether devices list instead of internal structures list.
 - Remove needless NULL checking.
 - Replace "pthread_exit" to "return NULL".
 - Replace rte_panic to RTE_LOG, also add error handling.
 - Remove duplicated lines.
 - Remove needless casting.
 - Follow coding style.
 - Remove needless parenthesis.

PATCH v7 changes:
 - Remove needless parenthesis.
 - Add release note.
 - Remove needless line wraps.
 - Add null pointer check in vring_state_changed().
 - Free queue memory in eth_queue_release().
 - Fix wrong variable name.
 - Fix error handling code of eth_dev_vhost_create() and
   rte_pmd_vhost_devuninit().
 - Remove needless null checking from rte_pmd_vhost_devinit/devuninit().
 - Use port id to create mac address.
 - Add doxygen style comments in "rte_eth_vhost.h".
 - Fix wrong comment in "mk/rte.app.mk".

PATCH v6 changes:
 - Remove rte_vhost_driver_pmd_callback_registe().
 - Support link status interrupt.
 - Support queue state changed interrupt.
 - Add rte_eth_vhost_get_queue_event().
 - Support numa node detection when new device is connected.

PATCH v5 changes:
 - Rebase on latest master.
 - Fix RX/TX routine to count RX/TX bytes.
 - Fix RX/TX routine not to count as error packets if enqueue/dequeue
   cannot send all packets.
 - Fix if-condition checking for multiqueues.
 - Add "static" to pthread variable.
 - Fix format.
 - Change default behavior not to receive queueing event from driver.
 - Split the patch to separate rte_eth_vhost_portid2vdev().

PATCH v4 changes:
 - Rebase on latest DPDK tree.
 - Fix cording style.
 - Fix code not to invoke multiple messaging handling threads.
 - Fix code to handle vdev parameters correctly.
 - Remove needless cast.
 - Remove needless if-condition before rt_free().

PATCH v3 changes:
 - Rebase on latest matser
 - Specify correct queue_id in RX/TX function.

PATCH v2 changes:
 - Remove a below patch that fixes vhost library.
   The patch was applied as a separate patch.
   - vhost: fix crash with multiqueue enabled
 - Fix typos.
   (Thanks to Thomas, Monjalon)
 - Rebase on latest tree with above bernard's patches.

PATCH v1 changes:
 - Support vhost multiple queues.
 - Rebase on "remove pci driver from vdevs".
 - Optimize RX/TX functions.
 - Fix resource leaks.
 - Fix compile issue.
 - Add patch to fix vhost library.

RFC PATCH v3 changes:
 - Optimize performance.
   In RX/TX functions, change code to access only per core data.
 - Add below API to allow user to use vhost library APIs for a port managed
   by vhost PMD. There are a few limitations. See "rte_eth_vhost.h".
- rte_eth_vhost_portid2vdev()
   To support this functionality, vhost library is also changed.
   Anyway, if users doesn't use vhost PMD, can fully use vhost library APIs.
 - Add code to support vhost multiple queues.
   Actually, multiple queues functionality is not enabled so far.

RFC PATCH v2 changes:
 - Fix issues reported by checkpatch.pl
   (Thanks to Stephen Hemminger)



Tetsuya Mukawa (2):
  ethdev: Add a new event type to notify a queue state changed event
  vhost: Add VHOST PMD

 MAINTAINERS |   4 +
 config/common_linuxapp  |   6 +
 doc/guides/nics/index.rst   |   1 +
 doc/guides/rel_notes/release_16_04.rst  |   4 +
 drivers/net/Makefile|   1 +
 drivers/net/vhost/Makefile  |  62 ++
 drivers/net/vhost/rte_eth_vhost.c   | 916 
 drivers/net/vhost/rte_eth_vhost.h   | 109 
 drivers/net/vhost/rte_pmd_vhost_version.map |  10 +
 lib/librte_ether/rte_ethdev.h   |   2 +
 mk/rte.app.mk   |   6 +
 11 files changed, 1121 insertions(+)
 create mode 100644 drivers/net/vhost/Makefile
 create mode 100644 drivers/net/vhost/rte_eth_vhost.c
 create mode 100644 drivers/net/vhost/rte_eth_vhost.h
 create mode 100644 drivers/net/vhost/rte_pmd_vhost_version.map

-- 
2.1.4



[dpdk-dev] [PATCH v9 0/2] Add VHOST PMD

2016-03-04 Thread Tetsuya Mukawa
On 2016/03/02 11:24, Qiu, Michael wrote:
> On 3/1/2016 10:19 AM, Tetsuya Mukawa wrote:
>> On 2016/03/01 11:00, Qiu, Michael wrote:
>>> On 2/26/2016 4:36 PM, Tetsuya Mukawa wrote:
>>>> On 2016/02/26 13:29, Tetsuya Mukawa wrote:
> [...]
>
>>>>> BTW, I have set the frontend mergeable off.
>>>>> I have checked below cases.
>>>>>  - Case1: Disable mergeable feature in virtio-net PMD.
>>>>>  - Case2: Disable mergeable feature in virtio-net PMD and use
>>>>> '--txqflags=0xf01' option to use simple ring deploying.
>>>>> Both cases,  I still cannot see the drop.
>>>>>
>>>>> Anyway, I will send a few patch-series to determine the cause of drop.
>>>>> So, could you please apply them and check the performance to determine
>>>>> which cause the drop?
>>>> Hi Michael,
>>>>
>>>> I may find what causes the drop.
>>>> Could you please restart testpmd on guest when you see the drop, then
>>>> check performance again?
>>>>
>>>> I guess the drop will occur only first time when testpmd on guest and
>>>> host is connected.
>>>> Here are rough steps.
>>>>
>>>> 1. Start testpmd on host
>>>> 2. Start QEMU
>>>> 3. Start testpmd on guest
>>>>
>>>> Then you will see the drop.
>>>> Probably, if testpmd on guest is restarted, then you don't see the drop
>>>> again.
>>>>
>>>> 4. Type 'quit' on guest.
>>>> 5. Start testpmd on guest again.
>> Hi Michael,
>>
>> I am sorry that above was caused by my miss configuration.
>> So please ignore it.
>> If you can have time today, could you please check v7 and v8 performance?
> Hi, Tetsuya
>
> I have tried the qemu case but seems it does not have any difference,
> maybe my configuration is wrong.
>
> What I used to test is container case from Jianfeng.  And I make a
> mistake that V6 compiled by GCC 5.3, but V9 with GCC 4.8, after using
> the same compiler, the performance almost the same.


Hi Michael,

Sorry for late replying. And thanks for your checking.

Thanks,
Tetsuya

> Thanks,
> Michael
>
>
>> Thanks,
>> Tetsuya
>>
>>> OK, I will help to tested today.
>>>
>>> Thanks,
>>> Michael



[dpdk-dev] [PATCH v9 0/2] Add VHOST PMD

2016-03-01 Thread Tetsuya Mukawa
On 2016/03/01 11:00, Qiu, Michael wrote:
> On 2/26/2016 4:36 PM, Tetsuya Mukawa wrote:
>> On 2016/02/26 13:29, Tetsuya Mukawa wrote:
>>> On 2016/02/25 16:51, Qiu, Michael wrote:
>>>> On 2/24/2016 1:10 PM, Tetsuya Mukawa wrote:
>>>>> On 2016/02/24 11:45, Qiu, Michael wrote:
>>>>>> Hi,  Tetsuya
>>>>>>
>>>>>> When I applied your v6 patch, I could reach 9.5Mpps with 64B packet.
>>>>>>
>>>>>> But when apply v9 only 8.4 Mpps, could you figure out why has
>>>>>> performance drop?
>>>>> Hi Michael,
>>>>>
>>>>> Thanks for checking it.
>>>>> I tried to re-produce it, but I don't see the drop on my environment.
>>>>> (My cpu is Xeon E5-2697-v2, and the performances of v6 and v9 patch are
>>>>> almost 5.9Mpps)
>>>>> Did you use totally same code except for vhost PMD?
>>>> Yes, totally same code and same platform, only difference is versions of
>>>> vhost PMD.
>>>>
>>>> BTW, I have set the frontend mergeable off.
>>> I have checked below cases.
>>>  - Case1: Disable mergeable feature in virtio-net PMD.
>>>  - Case2: Disable mergeable feature in virtio-net PMD and use
>>> '--txqflags=0xf01' option to use simple ring deploying.
>>> Both cases,  I still cannot see the drop.
>>>
>>> Anyway, I will send a few patch-series to determine the cause of drop.
>>> So, could you please apply them and check the performance to determine
>>> which cause the drop?
>> Hi Michael,
>>
>> I may find what causes the drop.
>> Could you please restart testpmd on guest when you see the drop, then
>> check performance again?
>>
>> I guess the drop will occur only first time when testpmd on guest and
>> host is connected.
>> Here are rough steps.
>>
>> 1. Start testpmd on host
>> 2. Start QEMU
>> 3. Start testpmd on guest
>>
>> Then you will see the drop.
>> Probably, if testpmd on guest is restarted, then you don't see the drop
>> again.
>>
>> 4. Type 'quit' on guest.
>> 5. Start testpmd on guest again.

Hi Michael,

I am sorry that above was caused by my miss configuration.
So please ignore it.
If you can have time today, could you please check v7 and v8 performance?

Thanks,
Tetsuya

> OK, I will help to tested today.
>
> Thanks,
> Michael
>> If so, I guess the drop is caused by queue notifying.
>> Could you please let me know whether your issue is above case?
>>
>> Thanks,
>> Tetsuya
>>
>>> Thanks,
>>> Tetsuya
>>>
>>>> Thanks,
>>>> Michael
>>>>> Thanks,
>>>>> Tetsuya
>>>>>
>>>>>> Thanks,
>>>>>> Michael
>>>>>> On 2/9/2016 5:38 PM, Tetsuya Mukawa wrote:
>>>>>>> The patch introduces a new PMD. This PMD is implemented as thin wrapper
>>>>>>> of librte_vhost.
>>>>>>>
>>>>>>>
>>>>>>> PATCH v9 changes:
>>>>>>>  - Fix a null pointer access issue implemented in v8 patch.
>>>>>>>
>>>>>>> PATCH v8 changes:
>>>>>>>  - Manage ether devices list instead of internal structures list.
>>>>>>>  - Remove needless NULL checking.
>>>>>>>  - Replace "pthread_exit" to "return NULL".
>>>>>>>  - Replace rte_panic to RTE_LOG, also add error handling.
>>>>>>>  - Remove duplicated lines.
>>>>>>>  - Remove needless casting.
>>>>>>>  - Follow coding style.
>>>>>>>  - Remove needless parenthesis.
>>>>>>>
>>>>>>> PATCH v7 changes:
>>>>>>>  - Remove needless parenthesis.
>>>>>>>  - Add release note.
>>>>>>>  - Remove needless line wraps.
>>>>>>>  - Add null pointer check in vring_state_changed().
>>>>>>>  - Free queue memory in eth_queue_release().
>>>>>>>  - Fix wrong variable name.
>>>>>>>  - Fix error handling code of eth_dev_vhost_create() and
>>>>>>>rte_pmd_vhost_devuninit().
>>>>>>>  - Remove needless null checking from rte_pmd_vhost_devinit/devuninit().
>>>>>>>  - Use port id to create mac address.
>>>>>>>  - Add doxygen style comments in "rte

[dpdk-dev] [PATCH v9 0/2] Add VHOST PMD

2016-02-26 Thread Tetsuya Mukawa
On 2016/02/26 13:29, Tetsuya Mukawa wrote:
> On 2016/02/25 16:51, Qiu, Michael wrote:
>> On 2/24/2016 1:10 PM, Tetsuya Mukawa wrote:
>>> On 2016/02/24 11:45, Qiu, Michael wrote:
>>>> Hi,  Tetsuya
>>>>
>>>> When I applied your v6 patch, I could reach 9.5Mpps with 64B packet.
>>>>
>>>> But when apply v9 only 8.4 Mpps, could you figure out why has
>>>> performance drop?
>>> Hi Michael,
>>>
>>> Thanks for checking it.
>>> I tried to re-produce it, but I don't see the drop on my environment.
>>> (My cpu is Xeon E5-2697-v2, and the performances of v6 and v9 patch are
>>> almost 5.9Mpps)
>>> Did you use totally same code except for vhost PMD?
>> Yes, totally same code and same platform, only difference is versions of
>> vhost PMD.
>>
>> BTW, I have set the frontend mergeable off.
> I have checked below cases.
>  - Case1: Disable mergeable feature in virtio-net PMD.
>  - Case2: Disable mergeable feature in virtio-net PMD and use
> '--txqflags=0xf01' option to use simple ring deploying.
> Both cases,  I still cannot see the drop.
>
> Anyway, I will send a few patch-series to determine the cause of drop.
> So, could you please apply them and check the performance to determine
> which cause the drop?

Hi Michael,

I may find what causes the drop.
Could you please restart testpmd on guest when you see the drop, then
check performance again?

I guess the drop will occur only first time when testpmd on guest and
host is connected.
Here are rough steps.

1. Start testpmd on host
2. Start QEMU
3. Start testpmd on guest

Then you will see the drop.
Probably, if testpmd on guest is restarted, then you don't see the drop
again.

4. Type 'quit' on guest.
5. Start testpmd on guest again.

If so, I guess the drop is caused by queue notifying.
Could you please let me know whether your issue is above case?

Thanks,
Tetsuya

> Thanks,
> Tetsuya
>
>> Thanks,
>> Michael
>>> Thanks,
>>> Tetsuya
>>>
>>>> Thanks,
>>>> Michael
>>>> On 2/9/2016 5:38 PM, Tetsuya Mukawa wrote:
>>>>> The patch introduces a new PMD. This PMD is implemented as thin wrapper
>>>>> of librte_vhost.
>>>>>
>>>>>
>>>>> PATCH v9 changes:
>>>>>  - Fix a null pointer access issue implemented in v8 patch.
>>>>>
>>>>> PATCH v8 changes:
>>>>>  - Manage ether devices list instead of internal structures list.
>>>>>  - Remove needless NULL checking.
>>>>>  - Replace "pthread_exit" to "return NULL".
>>>>>  - Replace rte_panic to RTE_LOG, also add error handling.
>>>>>  - Remove duplicated lines.
>>>>>  - Remove needless casting.
>>>>>  - Follow coding style.
>>>>>  - Remove needless parenthesis.
>>>>>
>>>>> PATCH v7 changes:
>>>>>  - Remove needless parenthesis.
>>>>>  - Add release note.
>>>>>  - Remove needless line wraps.
>>>>>  - Add null pointer check in vring_state_changed().
>>>>>  - Free queue memory in eth_queue_release().
>>>>>  - Fix wrong variable name.
>>>>>  - Fix error handling code of eth_dev_vhost_create() and
>>>>>rte_pmd_vhost_devuninit().
>>>>>  - Remove needless null checking from rte_pmd_vhost_devinit/devuninit().
>>>>>  - Use port id to create mac address.
>>>>>  - Add doxygen style comments in "rte_eth_vhost.h".
>>>>>  - Fix wrong comment in "mk/rte.app.mk".
>>>>>
>>>>> PATCH v6 changes:
>>>>>  - Remove rte_vhost_driver_pmd_callback_registe().
>>>>>  - Support link status interrupt.
>>>>>  - Support queue state changed interrupt.
>>>>>  - Add rte_eth_vhost_get_queue_event().
>>>>>  - Support numa node detection when new device is connected.
>>>>>
>>>>> PATCH v5 changes:
>>>>>  - Rebase on latest master.
>>>>>  - Fix RX/TX routine to count RX/TX bytes.
>>>>>  - Fix RX/TX routine not to count as error packets if enqueue/dequeue
>>>>>cannot send all packets.
>>>>>  - Fix if-condition checking for multiqueues.
>>>>>  - Add "static" to pthread variable.
>>>>>  - Fix format.
>>>>>  - Change default behavior not to receive queueing event from driver.
>>>>>  - Split the patch to separate rte_eth_vhost_porti

[dpdk-dev] [PATCH v9 0/2] Add VHOST PMD

2016-02-26 Thread Tetsuya Mukawa
On 2016/02/25 16:51, Qiu, Michael wrote:
> On 2/24/2016 1:10 PM, Tetsuya Mukawa wrote:
>> On 2016/02/24 11:45, Qiu, Michael wrote:
>>> Hi,  Tetsuya
>>>
>>> When I applied your v6 patch, I could reach 9.5Mpps with 64B packet.
>>>
>>> But when apply v9 only 8.4 Mpps, could you figure out why has
>>> performance drop?
>> Hi Michael,
>>
>> Thanks for checking it.
>> I tried to re-produce it, but I don't see the drop on my environment.
>> (My cpu is Xeon E5-2697-v2, and the performances of v6 and v9 patch are
>> almost 5.9Mpps)
>> Did you use totally same code except for vhost PMD?
> Yes, totally same code and same platform, only difference is versions of
> vhost PMD.
>
> BTW, I have set the frontend mergeable off.

I have checked below cases.
 - Case1: Disable mergeable feature in virtio-net PMD.
 - Case2: Disable mergeable feature in virtio-net PMD and use
'--txqflags=0xf01' option to use simple ring deploying.
Both cases,  I still cannot see the drop.

Anyway, I will send a few patch-series to determine the cause of drop.
So, could you please apply them and check the performance to determine
which cause the drop?

Thanks,
Tetsuya

> Thanks,
> Michael
>> Thanks,
>> Tetsuya
>>
>>> Thanks,
>>> Michael
>>> On 2/9/2016 5:38 PM, Tetsuya Mukawa wrote:
>>>> The patch introduces a new PMD. This PMD is implemented as thin wrapper
>>>> of librte_vhost.
>>>>
>>>>
>>>> PATCH v9 changes:
>>>>  - Fix a null pointer access issue implemented in v8 patch.
>>>>
>>>> PATCH v8 changes:
>>>>  - Manage ether devices list instead of internal structures list.
>>>>  - Remove needless NULL checking.
>>>>  - Replace "pthread_exit" to "return NULL".
>>>>  - Replace rte_panic to RTE_LOG, also add error handling.
>>>>  - Remove duplicated lines.
>>>>  - Remove needless casting.
>>>>  - Follow coding style.
>>>>  - Remove needless parenthesis.
>>>>
>>>> PATCH v7 changes:
>>>>  - Remove needless parenthesis.
>>>>  - Add release note.
>>>>  - Remove needless line wraps.
>>>>  - Add null pointer check in vring_state_changed().
>>>>  - Free queue memory in eth_queue_release().
>>>>  - Fix wrong variable name.
>>>>  - Fix error handling code of eth_dev_vhost_create() and
>>>>rte_pmd_vhost_devuninit().
>>>>  - Remove needless null checking from rte_pmd_vhost_devinit/devuninit().
>>>>  - Use port id to create mac address.
>>>>  - Add doxygen style comments in "rte_eth_vhost.h".
>>>>  - Fix wrong comment in "mk/rte.app.mk".
>>>>
>>>> PATCH v6 changes:
>>>>  - Remove rte_vhost_driver_pmd_callback_registe().
>>>>  - Support link status interrupt.
>>>>  - Support queue state changed interrupt.
>>>>  - Add rte_eth_vhost_get_queue_event().
>>>>  - Support numa node detection when new device is connected.
>>>>
>>>> PATCH v5 changes:
>>>>  - Rebase on latest master.
>>>>  - Fix RX/TX routine to count RX/TX bytes.
>>>>  - Fix RX/TX routine not to count as error packets if enqueue/dequeue
>>>>cannot send all packets.
>>>>  - Fix if-condition checking for multiqueues.
>>>>  - Add "static" to pthread variable.
>>>>  - Fix format.
>>>>  - Change default behavior not to receive queueing event from driver.
>>>>  - Split the patch to separate rte_eth_vhost_portid2vdev().
>>>>
>>>> PATCH v4 changes:
>>>>  - Rebase on latest DPDK tree.
>>>>  - Fix cording style.
>>>>  - Fix code not to invoke multiple messaging handling threads.
>>>>  - Fix code to handle vdev parameters correctly.
>>>>  - Remove needless cast.
>>>>  - Remove needless if-condition before rt_free().
>>>>
>>>> PATCH v3 changes:
>>>>  - Rebase on latest matser
>>>>  - Specify correct queue_id in RX/TX function.
>>>>
>>>> PATCH v2 changes:
>>>>  - Remove a below patch that fixes vhost library.
>>>>The patch was applied as a separate patch.
>>>>- vhost: fix crash with multiqueue enabled
>>>>  - Fix typos.
>>>>(Thanks to Thomas, Monjalon)
>>>>  - Rebase on latest tree with above bernard's patches.
>>>>
>>>> PATCH v1 changes:
>>>> 

[dpdk-dev] [PATCH v9 0/2] Add VHOST PMD

2016-02-24 Thread Tetsuya Mukawa
On 2016/02/24 11:45, Qiu, Michael wrote:
> Hi,  Tetsuya
>
> When I applied your v6 patch, I could reach 9.5Mpps with 64B packet.
>
> But when apply v9 only 8.4 Mpps, could you figure out why has
> performance drop?

Hi Michael,

Thanks for checking it.
I tried to re-produce it, but I don't see the drop on my environment.
(My cpu is Xeon E5-2697-v2, and the performances of v6 and v9 patch are
almost 5.9Mpps)
Did you use totally same code except for vhost PMD?

Thanks,
Tetsuya

> Thanks,
> Michael
> On 2/9/2016 5:38 PM, Tetsuya Mukawa wrote:
>> The patch introduces a new PMD. This PMD is implemented as thin wrapper
>> of librte_vhost.
>>
>>
>> PATCH v9 changes:
>>  - Fix a null pointer access issue implemented in v8 patch.
>>
>> PATCH v8 changes:
>>  - Manage ether devices list instead of internal structures list.
>>  - Remove needless NULL checking.
>>  - Replace "pthread_exit" to "return NULL".
>>  - Replace rte_panic to RTE_LOG, also add error handling.
>>  - Remove duplicated lines.
>>  - Remove needless casting.
>>  - Follow coding style.
>>  - Remove needless parenthesis.
>>
>> PATCH v7 changes:
>>  - Remove needless parenthesis.
>>  - Add release note.
>>  - Remove needless line wraps.
>>  - Add null pointer check in vring_state_changed().
>>  - Free queue memory in eth_queue_release().
>>  - Fix wrong variable name.
>>  - Fix error handling code of eth_dev_vhost_create() and
>>rte_pmd_vhost_devuninit().
>>  - Remove needless null checking from rte_pmd_vhost_devinit/devuninit().
>>  - Use port id to create mac address.
>>  - Add doxygen style comments in "rte_eth_vhost.h".
>>  - Fix wrong comment in "mk/rte.app.mk".
>>
>> PATCH v6 changes:
>>  - Remove rte_vhost_driver_pmd_callback_registe().
>>  - Support link status interrupt.
>>  - Support queue state changed interrupt.
>>  - Add rte_eth_vhost_get_queue_event().
>>  - Support numa node detection when new device is connected.
>>
>> PATCH v5 changes:
>>  - Rebase on latest master.
>>  - Fix RX/TX routine to count RX/TX bytes.
>>  - Fix RX/TX routine not to count as error packets if enqueue/dequeue
>>cannot send all packets.
>>  - Fix if-condition checking for multiqueues.
>>  - Add "static" to pthread variable.
>>  - Fix format.
>>  - Change default behavior not to receive queueing event from driver.
>>  - Split the patch to separate rte_eth_vhost_portid2vdev().
>>
>> PATCH v4 changes:
>>  - Rebase on latest DPDK tree.
>>  - Fix cording style.
>>  - Fix code not to invoke multiple messaging handling threads.
>>  - Fix code to handle vdev parameters correctly.
>>  - Remove needless cast.
>>  - Remove needless if-condition before rt_free().
>>
>> PATCH v3 changes:
>>  - Rebase on latest matser
>>  - Specify correct queue_id in RX/TX function.
>>
>> PATCH v2 changes:
>>  - Remove a below patch that fixes vhost library.
>>The patch was applied as a separate patch.
>>- vhost: fix crash with multiqueue enabled
>>  - Fix typos.
>>(Thanks to Thomas, Monjalon)
>>  - Rebase on latest tree with above bernard's patches.
>>
>> PATCH v1 changes:
>>  - Support vhost multiple queues.
>>  - Rebase on "remove pci driver from vdevs".
>>  - Optimize RX/TX functions.
>>  - Fix resource leaks.
>>  - Fix compile issue.
>>  - Add patch to fix vhost library.
>>
>> RFC PATCH v3 changes:
>>  - Optimize performance.
>>In RX/TX functions, change code to access only per core data.
>>  - Add below API to allow user to use vhost library APIs for a port managed
>>by vhost PMD. There are a few limitations. See "rte_eth_vhost.h".
>> - rte_eth_vhost_portid2vdev()
>>To support this functionality, vhost library is also changed.
>>Anyway, if users doesn't use vhost PMD, can fully use vhost library APIs.
>>  - Add code to support vhost multiple queues.
>>Actually, multiple queues functionality is not enabled so far.
>>
>> RFC PATCH v2 changes:
>>  - Fix issues reported by checkpatch.pl
>>(Thanks to Stephen Hemminger)
>>
>>
>> Tetsuya Mukawa (2):
>>   ethdev: Add a new event type to notify a queue state changed event
>>   vhost: Add VHOST PMD
>>
>>  MAINTAINERS |   4 +
>>  config/common_linuxapp  |   6 +
>>  doc/guides/nics/index.rst   |   1 +
>>  doc/guides/rel_notes/

[dpdk-dev] [PATCH v3 6/6] docs: add release note for qtest virtio container support

2016-02-24 Thread Tetsuya Mukawa
On 2016/02/23 19:28, Mcnamara, John wrote:
>> -Original Message-
>> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Mcnamara, John
>> Sent: Monday, February 22, 2016 3:41 PM
>> To: Tetsuya Mukawa ; dev at dpdk.org
>> Subject: Re: [dpdk-dev] [PATCH v3 6/6] docs: add release note for qtest
>> virtio container support
>>
> Also, could you move the v2 patchset to "Superseded".
>

Thanks for your reviewing.
I will change v2 patches status to "Superseded".

Thanks,
Tetsuya



[dpdk-dev] [PATCH v3 6/6] docs: add release note for qtest virtio container support

2016-02-22 Thread Tetsuya Mukawa
Signed-off-by: Tetsuya Mukawa 
---
 doc/guides/rel_notes/release_16_04.rst | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/doc/guides/rel_notes/release_16_04.rst 
b/doc/guides/rel_notes/release_16_04.rst
index 197d4e1..4c6d528 100644
--- a/doc/guides/rel_notes/release_16_04.rst
+++ b/doc/guides/rel_notes/release_16_04.rst
@@ -50,6 +50,9 @@ This section should contain new features added in this 
release. Sample format:

   Add a new virtual device, named eth_cvio, to support virtio for containers.

+* **Virtio support for containers using QEMU qtest mode.**
+  Add a new virtual device, named eth_qtest_virtio, to support virtio for 
containers
+  using QEMU qtest mode.

 Resolved Issues
 ---
-- 
2.1.4



  1   2   3   4   5   6   7   8   9   10   >