[dpdk-dev] [Dpdk-ovs] problem in binding interfaces of virtio-pci on the VM

2015-02-26 Thread Srinivasreddy R
hi Bruce ,
Thank you for your response .
I am accessing my VM via  " vncviewer " . so ssh doesn't come into picture .
Is there any way to find the root cause of my problem . does dpdk stores
any logs while binding interfaces to igb_uio.
i have seen my /var/log/messages . but could not find any clue.

the movement i gave the below command my vm got struck and not responding
untill i forcefully kill the qemu and relaunch .
./dpdk_nic_bind.py --bind=igb_uio 00:04.0 00:05.0



thanks,
srinivas.



On Thu, Feb 26, 2015 at 10:30 PM, Bruce Richardson <
bruce.richardson at intel.com> wrote:

> On Thu, Feb 26, 2015 at 10:08:59PM +0530, Srinivasreddy R wrote:
> > hi Mike,
> > Thanks for our detailed explanation of your example . usually i do
> similar
> > to u and i am aware of working with dpdk applications .
> > my problem is :
> > 1. i have written a code for  host to guest communication .[taken form
> > usvhost which is developed in ovdk vswitch] .
> > 2. i launched VM with two  interfaces .
> > 3. i am able to send and receive traffic to and from guest to host on
> these
> > interfaces .
> > 4. when i  try to bind these interfaces to igb_uio  to run dpdk
> application
> > . i am not able to access my instance . it got struck and not responding
> .
> > i need to hard reboot the vm.
>
> Are you sure you are not trying to access the vm via one of the interfaces
> now bount to igb_uio? If you bind the interface you use for ssh to igb_uio,
> you won't be able to ssh to that vm any more.
>
> /Bruce
>
> >
> > My Question is  :
> > surely i might done something wrong in code . as my VM is not able to
> > access any more when i try to bind interfaces to igb_uio  . not able to
> > debug the issue .
> > someone please help me in figuring the issue . i dont find anything in
> > /var/log/messages after relaunching the instance .
> >
> >
> > thanks,
> > srinivas.
> >
> >
> >
> > On Thu, Feb 26, 2015 at 8:42 PM, Polehn, Mike A  >
> > wrote:
> >
> > > In this example, the control network 00:03.0, remains unbound to UIO
> > > driver but remains attached
> > >  to Linux device driver (ssh access with putty) and just the target
> > > interfaces are bound.
> > > Below, it shows all 3 interfaces bound to the uio driver, which are not
> > > usable until a task uses the UIO driver.
> > >
> > > [root at F21vm l3fwd-vf]# lspci -nn
> > > 00:00.0 Host bridge [0600]: Intel Corporation 440FX - 82441FX PMC
> [Natoma]
> > > [8086:1237] (rev 02)
> > > 00:01.0 ISA bridge [0601]: Intel Corporation 82371SB PIIX3 ISA
> > > [Natoma/Triton II] [8086:7000]
> > > 00:01.1 IDE interface [0101]: Intel Corporation 82371SB PIIX3 IDE
> > > [Natoma/Triton II] [8086:7010]
> > > 00:01.3 Bridge [0680]: Intel Corporation 82371AB/EB/MB PIIX4 ACPI
> > > [8086:7113] (rev 03)
> > > 00:02.0 VGA compatible controller [0300]: Cirrus Logic GD 5446
> [1013:00b8]
> > > 00:03.0 Ethernet controller [0200]: Red Hat, Inc Virtio network device
> > > [1af4:1000]
> > > 00:04.0 Ethernet controller [0200]: Intel Corporation XL710/X710
> Virtual
> > > Function [8086:154c] (rev 01)
> > > 00:05.0 Ethernet controller [0200]: Intel Corporation XL710/X710
> Virtual
> > > Function [8086:154c] (rev 01)
> > >
> > > [root at F21vm l3fwd-vf]# /usr/src/dpdk/tools/dpdk_nic_bind.py
> > > --bind=igb_uio 00:04.0
> > > [root at F21vm l3fwd-vf]# /usr/src/dpdk/tools/dpdk_nic_bind.py
> > > --bind=igb_uio 00:05.0
> > > [root at F21vm l3fwd-vf]# /usr/src/dpdk/tools/dpdk_nic_bind.py --status
> > >
> > > Network devices using DPDK-compatible driver
> > > 
> > > :00:04.0 'XL710/X710 Virtual Function' drv=igb_uio unused=i40evf
> > > :00:05.0 'XL710/X710 Virtual Function' drv=igb_uio unused=i40evf
> > >
> > > Network devices using kernel driver
> > > ===
> > > :00:03.0 'Virtio network device' if= drv=virtio-pci
> > > unused=virtio_pci,igb_uio
> > >
> > > Other network devices
> > > =
> > > 
> > >
> > > -Original Message-
> > > From: Dpdk-ovs [mailto:dpdk-ovs-bounces at lists.01.org] On Behalf Of
> > > Srinivasreddy R
> > > Sent: Thursday, February 26, 2015 6:11 AM
> > > To: dev at dpdk.org; dpdk-ovs at lists.01.org
> > > Subject: [Dpdk-ovs] problem in binding interfaces of virtio-pci on the
> VM
> > >
> > > hi ,
> > > I have written sample program for usvhost  supported by ovdk.
> > >
> > > i have initialized VM using the below command .
> > > On the VM :
> > >
> > > I am able to see two interfaces . and working fine with traffic in
> > > rawsocket mode .
> > > my problem is when i bind the interfaces to pmd driver[ ibg_uio ] my
> > > virtual machine is getting hanged . and  i am not able to access it
> further
> > > .
> > > now my question is . what may be the reason for the behavior . and how
> can
> > > in debug the root cause .
> > > please help in finding out the problem .
> > >
> > >
> > >
> > >  ./tools/dpdk_nic_bind.py --status
> > >
> > > Network devices using DPDK-compatible driver

[dpdk-dev] [Dpdk-ovs] problem in binding interfaces of virtio-pci on the VM

2015-02-26 Thread Srinivasreddy R
hi Mike,
Thanks for our detailed explanation of your example . usually i do similar
to u and i am aware of working with dpdk applications .
my problem is :
1. i have written a code for  host to guest communication .[taken form
usvhost which is developed in ovdk vswitch] .
2. i launched VM with two  interfaces .
3. i am able to send and receive traffic to and from guest to host on these
interfaces .
4. when i  try to bind these interfaces to igb_uio  to run dpdk application
. i am not able to access my instance . it got struck and not responding .
i need to hard reboot the vm.

My Question is  :
surely i might done something wrong in code . as my VM is not able to
access any more when i try to bind interfaces to igb_uio  . not able to
debug the issue .
someone please help me in figuring the issue . i dont find anything in
/var/log/messages after relaunching the instance .


thanks,
srinivas.



On Thu, Feb 26, 2015 at 8:42 PM, Polehn, Mike A 
wrote:

> In this example, the control network 00:03.0, remains unbound to UIO
> driver but remains attached
>  to Linux device driver (ssh access with putty) and just the target
> interfaces are bound.
> Below, it shows all 3 interfaces bound to the uio driver, which are not
> usable until a task uses the UIO driver.
>
> [root at F21vm l3fwd-vf]# lspci -nn
> 00:00.0 Host bridge [0600]: Intel Corporation 440FX - 82441FX PMC [Natoma]
> [8086:1237] (rev 02)
> 00:01.0 ISA bridge [0601]: Intel Corporation 82371SB PIIX3 ISA
> [Natoma/Triton II] [8086:7000]
> 00:01.1 IDE interface [0101]: Intel Corporation 82371SB PIIX3 IDE
> [Natoma/Triton II] [8086:7010]
> 00:01.3 Bridge [0680]: Intel Corporation 82371AB/EB/MB PIIX4 ACPI
> [8086:7113] (rev 03)
> 00:02.0 VGA compatible controller [0300]: Cirrus Logic GD 5446 [1013:00b8]
> 00:03.0 Ethernet controller [0200]: Red Hat, Inc Virtio network device
> [1af4:1000]
> 00:04.0 Ethernet controller [0200]: Intel Corporation XL710/X710 Virtual
> Function [8086:154c] (rev 01)
> 00:05.0 Ethernet controller [0200]: Intel Corporation XL710/X710 Virtual
> Function [8086:154c] (rev 01)
>
> [root at F21vm l3fwd-vf]# /usr/src/dpdk/tools/dpdk_nic_bind.py
> --bind=igb_uio 00:04.0
> [root at F21vm l3fwd-vf]# /usr/src/dpdk/tools/dpdk_nic_bind.py
> --bind=igb_uio 00:05.0
> [root at F21vm l3fwd-vf]# /usr/src/dpdk/tools/dpdk_nic_bind.py --status
>
> Network devices using DPDK-compatible driver
> 
> :00:04.0 'XL710/X710 Virtual Function' drv=igb_uio unused=i40evf
> :00:05.0 'XL710/X710 Virtual Function' drv=igb_uio unused=i40evf
>
> Network devices using kernel driver
> ===
> :00:03.0 'Virtio network device' if= drv=virtio-pci
> unused=virtio_pci,igb_uio
>
> Other network devices
> =
> 
>
> -Original Message-
> From: Dpdk-ovs [mailto:dpdk-ovs-bounces at lists.01.org] On Behalf Of
> Srinivasreddy R
> Sent: Thursday, February 26, 2015 6:11 AM
> To: dev at dpdk.org; dpdk-ovs at lists.01.org
> Subject: [Dpdk-ovs] problem in binding interfaces of virtio-pci on the VM
>
> hi ,
> I have written sample program for usvhost  supported by ovdk.
>
> i have initialized VM using the below command .
> On the VM :
>
> I am able to see two interfaces . and working fine with traffic in
> rawsocket mode .
> my problem is when i bind the interfaces to pmd driver[ ibg_uio ] my
> virtual machine is getting hanged . and  i am not able to access it further
> .
> now my question is . what may be the reason for the behavior . and how can
> in debug the root cause .
> please help in finding out the problem .
>
>
>
>  ./tools/dpdk_nic_bind.py --status
>
> Network devices using DPDK-compatible driver
> 
> 
>
> Network devices using kernel driver
> ===
> :00:03.0 '82540EM Gigabit Ethernet Controller' if=ens3 drv=e1000
> unused=igb_uio *Active*
> :00:04.0 'Virtio network device' if= drv=virtio-pci unused=igb_uio
> :00:05.0 'Virtio network device' if= drv=virtio-pci unused=igb_uio
>
> Other network devices
> =
> 
>
>
> ./dpdk_nic_bind.py --bind=igb_uio 00:04.0 00:05.0
>
>
>
> ./x86_64-softmmu/qemu-system-x86_64 -cpu host -boot c  -hda
> /home/utils/images/vm1.img  -m 2048M -smp 3 --enable-kvm -name 'VM1'
> -nographic -vnc :1 -pidfile /tmp/vm1.pid -drive
> file=fat:rw:/tmp/qemu_share,snapshot=off -monitor
> unix:/tmp/vm1monitor,server,nowait  -net none -no-reboot -mem-path
> /dev/hugepages -mem-prealloc -netdev
> type=tap,id=net1,script=no,downscript=no,ifname=usvhost1,vhost=on -device
> virtio-net-pci,netdev=net1,mac=00:16:3e:00:03:03,csum=off,gso=off,guest_tso4=off,guest_tso6=off,guest_ecn=off
> -netdev type=tap,id=net2,script=no,downscript=no,ifname=usvhost2,vhost=on
> -device
>
> virtio-net-pci,netdev=net2,mac=00:16:3e:00:03:04,csum=off,gso=off,guest_tso4=off,guest_tso6=off,guest_ecn=off
>
>
>
>
> --
> thanks
> srinivas.
> 

[dpdk-dev] [PATCH v11 2/2] librte_pmd_null: Support port hotplug function

2015-02-26 Thread Tetsuya Mukawa
2015-02-26 19:57 GMT+09:00 Thomas Monjalon :
> 2015-02-26 18:06, Tetsuya Mukawa:
>> 2015-02-26 16:03 GMT+09:00 Thomas Monjalon :
>> > 2015-02-25 16:49, Stephen Hemminger:
>> >> Build fails if HOTPLUG is disabled
>>
>> Hi Stephen,
>>
>> I appreciate for you reporting.
>>
>> >
>> > OK thanks for reporting.
>> > Actually there is no good reason to disable hotplug on Linux.
>> > Though it means that it's impossible to build on FreeBSD.
>> >
>> > Tetsuya, the right fix is to remove this option.
>>
>> Hi Thomas,
>>
>> Yes, I agree with it. I will add some codes to remove the option.
>> Please let me have a few days, I need to prepare BSD machine for compile 
>> test.
>>
>> > You should manage to graceful degrades hotplug in not supported
>> > cases supported: devices cannot be detachable in case of VFIO or nic_uio.
>> > What about uio_pci_generic?
>>
>> We cannot detach a vfio device so far. But we can detach a igb_uio and
>> uio_pci_generic device.
>> About a vfio ddevice, I haven't checked related code yet, but I guess
>> I will submit code to detach a vfio device in post-rc1.
>
> OK thanks.
> I made a quick fix (moving #ifdef) waiting the option removal:
> http://dpdk.org/browse/dpdk/commit/?id=7609e6609350
>

Thank you so much for that.

Tetsuya,


[dpdk-dev] problem in binding interfaces of virtio-pci on the VM

2015-02-26 Thread Srinivasreddy R
hi ,
I have written sample program for usvhost  supported by ovdk.

i have initialized VM using the below command .
On the VM :

I am able to see two interfaces . and working fine with traffic in
rawsocket mode .
my problem is when i bind the interfaces to pmd driver[ ibg_uio ] my
virtual machine is getting hanged . and  i am not able to access it further
. 
now my question is . what may be the reason for the behavior . and how can
in debug the root cause .
please help in finding out the problem .



 ./tools/dpdk_nic_bind.py --status

Network devices using DPDK-compatible driver



Network devices using kernel driver
===
:00:03.0 '82540EM Gigabit Ethernet Controller' if=ens3 drv=e1000
unused=igb_uio *Active*
:00:04.0 'Virtio network device' if= drv=virtio-pci unused=igb_uio
:00:05.0 'Virtio network device' if= drv=virtio-pci unused=igb_uio

Other network devices
=



./dpdk_nic_bind.py --bind=igb_uio 00:04.0 00:05.0



./x86_64-softmmu/qemu-system-x86_64 -cpu host -boot c  -hda
/home/utils/images/vm1.img  -m 2048M -smp 3 --enable-kvm -name 'VM1'
-nographic -vnc :1 -pidfile /tmp/vm1.pid -drive
file=fat:rw:/tmp/qemu_share,snapshot=off -monitor
unix:/tmp/vm1monitor,server,nowait  -net none -no-reboot -mem-path
/dev/hugepages -mem-prealloc -netdev
type=tap,id=net1,script=no,downscript=no,ifname=usvhost1,vhost=on -device
virtio-net-pci,netdev=net1,mac=00:16:3e:00:03:03,csum=off,gso=off,guest_tso4=off,guest_tso6=off,guest_ecn=off
-netdev type=tap,id=net2,script=no,downscript=no,ifname=usvhost2,vhost=on
-device
virtio-net-pci,netdev=net2,mac=00:16:3e:00:03:04,csum=off,gso=off,guest_tso4=off,guest_tso6=off,guest_ecn=off




--
thanks
srinivas.


[dpdk-dev] [PATCH v15] testpmd: Add port hotplug support

2015-02-26 Thread De Lara Guarch, Pablo


> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Tetsuya Mukawa
> Sent: Wednesday, February 25, 2015 7:32 PM
> To: dev at dpdk.org
> Subject: [dpdk-dev] [PATCH v15] testpmd: Add port hotplug support
> 
> The patch introduces following commands.
> - port attach [ident]
> - port detach [port_id]
>  - attach: attaching a port
>  - detach: detaching a port
>  - ident: pci address of physical device.
>   Or device name and parameters of virtual device.
>  (ex. :02:00.0, eth_pcap0,iface=eth0)
>  - port_id: port identifier
> 
> v15:
> - Replace rte_eal_dev_attach() by rte_eth_dev_attach()
> - Replace rte_eal_dev_detach() by rte_eth_dev_detach()
> 
> v7:
> - Fix doc.
>   (Thanks to Iremonger, Bernard)
> - Fix port checking implementation of star_port();
>   (Thanks to Qiu, Michael)
> v5:
> - Add testpmd documentation.
>   (Thanks to Iremonger, Bernard)
> v4:
>  - Fix strings of command help.
> 
> Signed-off-by: Tetsuya Mukawa 
> ---
>  app/test-pmd/cmdline.c  | 137 +++
>  app/test-pmd/config.c   | 102 --
>  app/test-pmd/parameters.c   |  22 ++-
>  app/test-pmd/testpmd.c  | 199 
> +---
>  app/test-pmd/testpmd.h  |  18 ++-
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  57 
>  6 files changed, 409 insertions(+), 126 deletions(-)
> 

[...]

> @@ -1423,12 +1443,8 @@ set_fwd_ports_list(unsigned int *portlist,
> unsigned int nb_pt)
>   again:
>   for (i = 0; i < nb_pt; i++) {
>   port_id = (portid_t) portlist[i];
> - if (port_id >= nb_ports) {
> - printf("Invalid port id %u >= %u\n",
> -(unsigned int) port_id,
> -(unsigned int) nb_ports);
> + if (port_id_is_invalid(port_id, ENABLED_WARN))

Sorry for catching this late, but there is a segmentation fault when this 
function gets called 
when parsing "portmask" at testpmd initialization, since port_id_is_invalid 
function needs to have array "ports" initialized.
I would revert the change, but not sure if this is need for other reasons.

Thanks,
Pablo
>   return;
> - }
>   if (record_now)
>   fwd_ports_ids[i] = port_id;
>   }



[dpdk-dev] [PATCH v11 2/2] librte_pmd_null: Support port hotplug function

2015-02-26 Thread Tetsuya Mukawa
2015-02-26 16:03 GMT+09:00 Thomas Monjalon :
> 2015-02-25 16:49, Stephen Hemminger:
>> Build fails if HOTPLUG is disabled

Hi Stephen,

I appreciate for you reporting.

>
> OK thanks for reporting.
> Actually there is no good reason to disable hotplug on Linux.
> Though it means that it's impossible to build on FreeBSD.
>
> Tetsuya, the right fix is to remove this option.

Hi Thomas,

Yes, I agree with it. I will add some codes to remove the option.
Please let me have a few days, I need to prepare BSD machine for compile test.

> You should manage to graceful degrades hotplug in not supported
> cases supported: devices cannot be detachable in case of VFIO or nic_uio.
> What about uio_pci_generic?

We cannot detach a vfio device so far. But we can detach a igb_uio and
uio_pci_generic device.
About a vfio ddevice, I haven't checked related code yet, but I guess
I will submit code to detach a vfio device in post-rc1.

Thanks,
Tetsuya


[dpdk-dev] [PATCH v3 0/3] Mellanox ConnectX-3 PMD

2015-02-26 Thread Gleb Natapov
On Thu, Feb 26, 2015 at 03:18:34PM +0100, Adrien Mazarguil wrote:
> On Thu, Feb 26, 2015 at 03:49:07PM +0200, Gleb Natapov wrote:
> > On Thu, Feb 26, 2015 at 02:36:27PM +0100, Thomas Monjalon wrote:
> > > 2015-02-26 13:51, Gleb Natapov:
> > > > Did git pull today. After enabling mlnx pmd compilation fails with:
> > > > 
> > > > dpdk/lib/librte_pmd_mlx4/mlx4.c: In function ?mlx4_pci_devinit?:
> > > > dpdk/lib/librte_pmd_mlx4/mlx4.c:4636:14: error: too few arguments to 
> > > > function ?rte_eth_dev_allocate?
> > > > eth_dev = rte_eth_dev_allocate(name);
> > > 
> > > Yes, thanks for reporting.
> > > I didn't test the disabled mlx4 after hotplug integration:
> > >   dpdk.org/browse/dpdk/commit/?id=9f1653e7b7e1746e7c
> > > 
> > > Clearly, I have to improve my sanity checks.
> > > Sorry for the inconvenience.
> > No problem, I fixed that locally, but now I see another issue. I have
> > several PMDs statically compiled in with my application and I expect
> > dpdk to choose correct one depending on available HW, but mlnx pmd does
> > not behave nicely, if its initialization fails it kills entire
> > application:
> > 
> > EAL: PCI device :03:00.0 on NUMA socket 0
> > EAL:   probe driver: 15b3:1003 librte_pmd_mlx4
> > EAL: Error - exiting with code: 1
> >   Cause: Requested device :03:00.0 cannot be used
> 
> About this error, make sure you are using the kernel modules provided by the
> mlnx-ofed-kernel package from MOFED [1] as described in the documentation.
> 
The problem is not in the error, I know how to get rid of it, but in the
error handling. My program has a fallback, so I an error to init a PMD
should not kill it, non other PMDs do.

--
Gleb.


[dpdk-dev] [Dpdk-ovs] problem in binding interfaces of virtio-pci on the VM

2015-02-26 Thread Bruce Richardson
On Thu, Feb 26, 2015 at 10:08:59PM +0530, Srinivasreddy R wrote:
> hi Mike,
> Thanks for our detailed explanation of your example . usually i do similar
> to u and i am aware of working with dpdk applications .
> my problem is :
> 1. i have written a code for  host to guest communication .[taken form
> usvhost which is developed in ovdk vswitch] .
> 2. i launched VM with two  interfaces .
> 3. i am able to send and receive traffic to and from guest to host on these
> interfaces .
> 4. when i  try to bind these interfaces to igb_uio  to run dpdk application
> . i am not able to access my instance . it got struck and not responding .
> i need to hard reboot the vm.

Are you sure you are not trying to access the vm via one of the interfaces
now bount to igb_uio? If you bind the interface you use for ssh to igb_uio, 
you won't be able to ssh to that vm any more.

/Bruce

> 
> My Question is  :
> surely i might done something wrong in code . as my VM is not able to
> access any more when i try to bind interfaces to igb_uio  . not able to
> debug the issue .
> someone please help me in figuring the issue . i dont find anything in
> /var/log/messages after relaunching the instance .
> 
> 
> thanks,
> srinivas.
> 
> 
> 
> On Thu, Feb 26, 2015 at 8:42 PM, Polehn, Mike A 
> wrote:
> 
> > In this example, the control network 00:03.0, remains unbound to UIO
> > driver but remains attached
> >  to Linux device driver (ssh access with putty) and just the target
> > interfaces are bound.
> > Below, it shows all 3 interfaces bound to the uio driver, which are not
> > usable until a task uses the UIO driver.
> >
> > [root at F21vm l3fwd-vf]# lspci -nn
> > 00:00.0 Host bridge [0600]: Intel Corporation 440FX - 82441FX PMC [Natoma]
> > [8086:1237] (rev 02)
> > 00:01.0 ISA bridge [0601]: Intel Corporation 82371SB PIIX3 ISA
> > [Natoma/Triton II] [8086:7000]
> > 00:01.1 IDE interface [0101]: Intel Corporation 82371SB PIIX3 IDE
> > [Natoma/Triton II] [8086:7010]
> > 00:01.3 Bridge [0680]: Intel Corporation 82371AB/EB/MB PIIX4 ACPI
> > [8086:7113] (rev 03)
> > 00:02.0 VGA compatible controller [0300]: Cirrus Logic GD 5446 [1013:00b8]
> > 00:03.0 Ethernet controller [0200]: Red Hat, Inc Virtio network device
> > [1af4:1000]
> > 00:04.0 Ethernet controller [0200]: Intel Corporation XL710/X710 Virtual
> > Function [8086:154c] (rev 01)
> > 00:05.0 Ethernet controller [0200]: Intel Corporation XL710/X710 Virtual
> > Function [8086:154c] (rev 01)
> >
> > [root at F21vm l3fwd-vf]# /usr/src/dpdk/tools/dpdk_nic_bind.py
> > --bind=igb_uio 00:04.0
> > [root at F21vm l3fwd-vf]# /usr/src/dpdk/tools/dpdk_nic_bind.py
> > --bind=igb_uio 00:05.0
> > [root at F21vm l3fwd-vf]# /usr/src/dpdk/tools/dpdk_nic_bind.py --status
> >
> > Network devices using DPDK-compatible driver
> > 
> > :00:04.0 'XL710/X710 Virtual Function' drv=igb_uio unused=i40evf
> > :00:05.0 'XL710/X710 Virtual Function' drv=igb_uio unused=i40evf
> >
> > Network devices using kernel driver
> > ===
> > :00:03.0 'Virtio network device' if= drv=virtio-pci
> > unused=virtio_pci,igb_uio
> >
> > Other network devices
> > =
> > 
> >
> > -Original Message-
> > From: Dpdk-ovs [mailto:dpdk-ovs-bounces at lists.01.org] On Behalf Of
> > Srinivasreddy R
> > Sent: Thursday, February 26, 2015 6:11 AM
> > To: dev at dpdk.org; dpdk-ovs at lists.01.org
> > Subject: [Dpdk-ovs] problem in binding interfaces of virtio-pci on the VM
> >
> > hi ,
> > I have written sample program for usvhost  supported by ovdk.
> >
> > i have initialized VM using the below command .
> > On the VM :
> >
> > I am able to see two interfaces . and working fine with traffic in
> > rawsocket mode .
> > my problem is when i bind the interfaces to pmd driver[ ibg_uio ] my
> > virtual machine is getting hanged . and  i am not able to access it further
> > .
> > now my question is . what may be the reason for the behavior . and how can
> > in debug the root cause .
> > please help in finding out the problem .
> >
> >
> >
> >  ./tools/dpdk_nic_bind.py --status
> >
> > Network devices using DPDK-compatible driver
> > 
> > 
> >
> > Network devices using kernel driver
> > ===
> > :00:03.0 '82540EM Gigabit Ethernet Controller' if=ens3 drv=e1000
> > unused=igb_uio *Active*
> > :00:04.0 'Virtio network device' if= drv=virtio-pci unused=igb_uio
> > :00:05.0 'Virtio network device' if= drv=virtio-pci unused=igb_uio
> >
> > Other network devices
> > =
> > 
> >
> >
> > ./dpdk_nic_bind.py --bind=igb_uio 00:04.0 00:05.0
> >
> >
> >
> > ./x86_64-softmmu/qemu-system-x86_64 -cpu host -boot c  -hda
> > /home/utils/images/vm1.img  -m 2048M -smp 3 --enable-kvm -name 'VM1'
> > -nographic -vnc :1 -pidfile /tmp/vm1.pid -drive
> > file=fat:rw:/tmp/qemu_share,snapshot=off -monitor
> > unix:/tmp/vm1monitor,server,nowait  -net none 

[dpdk-dev] [PATCH] rte_mbuf: scattered pktmbufs freeing optimization

2015-02-26 Thread Stephen Hemminger
On Fri, 27 Feb 2015 01:15:06 +0200
"vadim.suraev at gmail.com"  wrote:

> +static inline void __attribute__((always_inline))
> +rte_pktmbuf_free_bulk(struct rte_mbuf *head)

Quit with the inlining. Inlining all the time isn't faster
it just increase the code bloat and causes i-cache misses.

> +{
> +void *mbufs[MAX_MBUF_FREE_SIZE];
> +unsigned mbufs_count = 0;
> +struct rte_mbuf *next;
> +
> +RTE_MBUF_MEMPOOL_CHECK1(head);
> +
> +while(head) {
> +next = head->next;
> +head->next = NULL;
> +if(__rte_pktmbuf_prefree_seg(head)) {

Missing space after 'if'

> +RTE_MBUF_ASSERT(rte_mbuf_refcnt_read(head) == 0);
> +RTE_MBUF_MEMPOOL_CHECK2(head);
> +mbufs[mbufs_count++] = head;
> +}
> +head = next;
> +if(mbufs_count == MAX_MBUF_FREE_SIZE) {
> +rte_mempool_put_bulk(((struct rte_mbuf 
> *)mbufs[0])->pool,mbufs,mbufs_count);
why not have mbufs[] be type struct rte_mbuf * and avoid casting.
Casting is one of the sources of bugs in C code.


> +mbufs_count = 0;
> +}
> +}
> +if(mbufs_count > 0) {
Don't need {} on one line if clause

> +rte_mempool_put_bulk(((struct rte_mbuf 
> *)mbufs[0])->pool,mbufs,mbufs_count);
> +}
> +}


[dpdk-dev] [BUG] PMD null driver build fails

2015-02-26 Thread Stephen Hemminger
Null driver fails on Debian Wheezy (with backports) which uses
GCC 4.7


== Build lib/librte_pmd_null
  CC rte_eth_null.o
/home/shemminger/src/dpdk/lib/librte_pmd_null/rte_eth_null.c: In function 
?eth_stats_get?:
/home/shemminger/src/dpdk/lib/librte_pmd_null/rte_eth_null.c:302:28: error: 
array subscript is above array bounds [-Werror=array-bounds]
/home/shemminger/src/dpdk/lib/librte_pmd_null/rte_eth_null.c:302:28: error: 
array subscript is above array bounds [-Werror=array-bounds]
/home/shemminger/src/dpdk/lib/librte_pmd_null/rte_eth_null.c:302:28: error: 
array subscript is above array bounds [-Werror=array-bounds]


[dpdk-dev] vhost-user deconnection bug

2015-02-26 Thread BenoƮt Canet

Hi Xie,

I connected a QEMU from git master with the vhost-user from git master
and noticed the following bug.

In the following code:

void
user_destroy_device(struct vhost_device_ctx ctx)
{   
struct virtio_net *dev = get_device(ctx);   

if (dev && (dev->flags & VIRTIO_DEV_RUNNING)) 
notify_ops->destroy_device(dev);

if (dev && dev->mem) {  
free_mem_region(dev);   
free(dev->mem); 
dev->mem = NULL;
}   
}

The if (dev && (dev->flags & VIRTIO_DEV_RUNNING)) is evaluated false
and notify_ops->destroy_device(dev); is not called when QEMU terminate
and provocate the deconnexion.

As a consequence any piece of code busy polling or bursting on
the vhost-user device will segfault since it will not be notified
of the deconnexion.

By the way VIRTIO_DEV_RUNNING does not seem to be set anywhere.

Best regards

Beno?t  


[dpdk-dev] [PATCH] headers: typeof -> __typeof__ to unbreak C++11 code

2015-02-26 Thread Mcnamara, John
> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Thomas Monjalon
> Sent: Thursday, February 26, 2015 11:15 AM
> To: dev at dpdk.org; Simon Kagstrom
> Subject: Re: [dpdk-dev] [PATCH] headers: typeof -> __typeof__ to unbreak
> C++11 code


> I'd like to be sure that it's working with every compilers we support
> (gcc, icc, clang).
> Anyone to check please?

Hi,

The patch works with:

gcc (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8)
icc (ICC) 13.1.1 20130313
clang version 3.3 (tags/RELEASE_33/rc2)

Regards,

John





[dpdk-dev] [PATCH v3 0/3] support TSO on i40e

2015-02-26 Thread Ananyev, Konstantin


> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Jijiang Liu
> Sent: Thursday, February 26, 2015 3:37 AM
> To: dev at dpdk.org
> Subject: [dpdk-dev] [PATCH v3 0/3] support TSO on i40e
> 
> This patch set enables i40e TSO feature for both non-tunneling packet and 
> tunneling packet.
> 
> Change logs:
> v2 change: rework based on Olivier's patch set [PATCH v2 00/20] enhance 
> Tx checksum offload API
>   http://dpdk.org/ml/archives/dev/2015-February/012375.html
> v3 change:
>   1. split 'enable i40e TSO' patch in v2 into two patches.
> One patch is for moving tx offloads parameters of i40e to 
> separate structure.
> And other patch is for enabling i40e TSO feature for both 
> non-tunneling packet and tunneling packet
>   2. patch order change
> 
> Jijiang Liu (3):
>   Move Tx offloads parameters of i40e to separate structure
>   Enable i40e TSO feature for both non-tunneling packet and tunneling packet
>   Advertise the DEV_TX_OFFLOAD_TCP_TSO flag in the PMD features
> 
>  lib/librte_pmd_i40e/i40e_ethdev.c |3 +-
>  lib/librte_pmd_i40e/i40e_rxtx.c   |   99 
> +++--
>  lib/librte_pmd_i40e/i40e_rxtx.h   |   13 +
>  3 files changed, 87 insertions(+), 28 deletions(-)
> 

Acked-by: Konstantin Ananyev 

> --
> 1.7.7.6



[dpdk-dev] [PATCH v3 0/3] Mellanox ConnectX-3 PMD

2015-02-26 Thread Gleb Natapov
On Thu, Feb 26, 2015 at 02:36:27PM +0100, Thomas Monjalon wrote:
> 2015-02-26 13:51, Gleb Natapov:
> > Did git pull today. After enabling mlnx pmd compilation fails with:
> > 
> > dpdk/lib/librte_pmd_mlx4/mlx4.c: In function ?mlx4_pci_devinit?:
> > dpdk/lib/librte_pmd_mlx4/mlx4.c:4636:14: error: too few arguments to 
> > function ?rte_eth_dev_allocate?
> > eth_dev = rte_eth_dev_allocate(name);
> 
> Yes, thanks for reporting.
> I didn't test the disabled mlx4 after hotplug integration:
>   dpdk.org/browse/dpdk/commit/?id=9f1653e7b7e1746e7c
> 
> Clearly, I have to improve my sanity checks.
> Sorry for the inconvenience.
No problem, I fixed that locally, but now I see another issue. I have
several PMDs statically compiled in with my application and I expect
dpdk to choose correct one depending on available HW, but mlnx pmd does
not behave nicely, if its initialization fails it kills entire
application:

EAL: PCI device :03:00.0 on NUMA socket 0
EAL:   probe driver: 15b3:1003 librte_pmd_mlx4
EAL: Error - exiting with code: 1
  Cause: Requested device :03:00.0 cannot be used

This is how other pmds handle situation when init cannot be done:
EAL: PCI device :02:00.0 on NUMA socket 0
EAL:   probe driver: 8086:1528 rte_ixgbe_pmd
EAL:   Not managed by known pt driver, skipped
EAL: PCI device :02:00.1 on NUMA socket 0
EAL:   probe driver: 8086:1528 rte_ixgbe_pmd
EAL:   Not managed by known pt driver, skipped

--
Gleb.


[dpdk-dev] [PATCH v3 0/3] Mellanox ConnectX-3 PMD

2015-02-26 Thread Adrien Mazarguil
On Thu, Feb 26, 2015 at 03:49:07PM +0200, Gleb Natapov wrote:
> On Thu, Feb 26, 2015 at 02:36:27PM +0100, Thomas Monjalon wrote:
> > 2015-02-26 13:51, Gleb Natapov:
> > > Did git pull today. After enabling mlnx pmd compilation fails with:
> > > 
> > > dpdk/lib/librte_pmd_mlx4/mlx4.c: In function ?mlx4_pci_devinit?:
> > > dpdk/lib/librte_pmd_mlx4/mlx4.c:4636:14: error: too few arguments to 
> > > function ?rte_eth_dev_allocate?
> > > eth_dev = rte_eth_dev_allocate(name);
> > 
> > Yes, thanks for reporting.
> > I didn't test the disabled mlx4 after hotplug integration:
> > dpdk.org/browse/dpdk/commit/?id=9f1653e7b7e1746e7c
> > 
> > Clearly, I have to improve my sanity checks.
> > Sorry for the inconvenience.
> No problem, I fixed that locally, but now I see another issue. I have
> several PMDs statically compiled in with my application and I expect
> dpdk to choose correct one depending on available HW, but mlnx pmd does
> not behave nicely, if its initialization fails it kills entire
> application:
> 
> EAL: PCI device :03:00.0 on NUMA socket 0
> EAL:   probe driver: 15b3:1003 librte_pmd_mlx4
> EAL: Error - exiting with code: 1
>   Cause: Requested device :03:00.0 cannot be used

About this error, make sure you are using the kernel modules provided by the
mlnx-ofed-kernel package from MOFED [1] as described in the documentation.

In short, unload mlx4_core, mlx4_en, mlx4_ib and ib_uverbs, install this
package, run depmod and load them again. Since they have similar names, the
updated kernel modules should be found in a "extra" or "updates"
subdirectory of /lib/modules and come first when queried by modinfo.

[1] 
http://www.mellanox.com/page/products_dyn?product_family=26=linux_sw_drivers

-- 
Adrien Mazarguil
6WIND


[dpdk-dev] [Dpdk-ovs] problem in binding interfaces of virtio-pci on the VM

2015-02-26 Thread Polehn, Mike A
In this example, the control network 00:03.0, remains unbound to UIO driver but 
remains attached
 to Linux device driver (ssh access with putty) and just the target interfaces 
are bound.
Below, it shows all 3 interfaces bound to the uio driver, which are not usable 
until a task uses the UIO driver. 

[root at F21vm l3fwd-vf]# lspci -nn
00:00.0 Host bridge [0600]: Intel Corporation 440FX - 82441FX PMC [Natoma] 
[8086:1237] (rev 02)
00:01.0 ISA bridge [0601]: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton 
II] [8086:7000]
00:01.1 IDE interface [0101]: Intel Corporation 82371SB PIIX3 IDE 
[Natoma/Triton II] [8086:7010]
00:01.3 Bridge [0680]: Intel Corporation 82371AB/EB/MB PIIX4 ACPI [8086:7113] 
(rev 03)
00:02.0 VGA compatible controller [0300]: Cirrus Logic GD 5446 [1013:00b8]
00:03.0 Ethernet controller [0200]: Red Hat, Inc Virtio network device 
[1af4:1000]
00:04.0 Ethernet controller [0200]: Intel Corporation XL710/X710 Virtual 
Function [8086:154c] (rev 01)
00:05.0 Ethernet controller [0200]: Intel Corporation XL710/X710 Virtual 
Function [8086:154c] (rev 01)

[root at F21vm l3fwd-vf]# /usr/src/dpdk/tools/dpdk_nic_bind.py --bind=igb_uio 
00:04.0
[root at F21vm l3fwd-vf]# /usr/src/dpdk/tools/dpdk_nic_bind.py --bind=igb_uio 
00:05.0
[root at F21vm l3fwd-vf]# /usr/src/dpdk/tools/dpdk_nic_bind.py --status

Network devices using DPDK-compatible driver

:00:04.0 'XL710/X710 Virtual Function' drv=igb_uio unused=i40evf
:00:05.0 'XL710/X710 Virtual Function' drv=igb_uio unused=i40evf

Network devices using kernel driver
===
:00:03.0 'Virtio network device' if= drv=virtio-pci 
unused=virtio_pci,igb_uio

Other network devices
=


-Original Message-
From: Dpdk-ovs [mailto:dpdk-ovs-boun...@lists.01.org] On Behalf Of 
Srinivasreddy R
Sent: Thursday, February 26, 2015 6:11 AM
To: dev at dpdk.org; dpdk-ovs at lists.01.org
Subject: [Dpdk-ovs] problem in binding interfaces of virtio-pci on the VM

hi ,
I have written sample program for usvhost  supported by ovdk.

i have initialized VM using the below command .
On the VM :

I am able to see two interfaces . and working fine with traffic in rawsocket 
mode .
my problem is when i bind the interfaces to pmd driver[ ibg_uio ] my virtual 
machine is getting hanged . and  i am not able to access it further .
now my question is . what may be the reason for the behavior . and how can in 
debug the root cause .
please help in finding out the problem .



 ./tools/dpdk_nic_bind.py --status

Network devices using DPDK-compatible driver 



Network devices using kernel driver
===
:00:03.0 '82540EM Gigabit Ethernet Controller' if=ens3 drv=e1000 
unused=igb_uio *Active*
:00:04.0 'Virtio network device' if= drv=virtio-pci unused=igb_uio
:00:05.0 'Virtio network device' if= drv=virtio-pci unused=igb_uio

Other network devices
=



./dpdk_nic_bind.py --bind=igb_uio 00:04.0 00:05.0



./x86_64-softmmu/qemu-system-x86_64 -cpu host -boot c  -hda 
/home/utils/images/vm1.img  -m 2048M -smp 3 --enable-kvm -name 'VM1'
-nographic -vnc :1 -pidfile /tmp/vm1.pid -drive 
file=fat:rw:/tmp/qemu_share,snapshot=off -monitor 
unix:/tmp/vm1monitor,server,nowait  -net none -no-reboot -mem-path 
/dev/hugepages -mem-prealloc -netdev 
type=tap,id=net1,script=no,downscript=no,ifname=usvhost1,vhost=on -device 
virtio-net-pci,netdev=net1,mac=00:16:3e:00:03:03,csum=off,gso=off,guest_tso4=off,guest_tso6=off,guest_ecn=off
-netdev type=tap,id=net2,script=no,downscript=no,ifname=usvhost2,vhost=on
-device
virtio-net-pci,netdev=net2,mac=00:16:3e:00:03:04,csum=off,gso=off,guest_tso4=off,guest_tso6=off,guest_ecn=off




--
thanks
srinivas.
___
Dpdk-ovs mailing list
Dpdk-ovs at lists.01.org
https://lists.01.org/mailman/listinfo/dpdk-ovs


[dpdk-dev] [PATCH] af_packet: Fix some klocwork errors

2015-02-26 Thread Ouyang Changchun
Fix possible memory leak issue: free kvlist before return;
Fix possible resource lost issue: close qssockfd before return;

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_af_packet/rte_eth_af_packet.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pmd_af_packet/rte_eth_af_packet.c 
b/lib/librte_pmd_af_packet/rte_eth_af_packet.c
index 80e9bdf..cf8f4fa 100644
--- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c
+++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c
@@ -694,6 +694,8 @@ error:
}
rte_free(*internals);
}
+   if (qsockfd != -1)
+   close(qsockfd);
return -1;
 }

@@ -822,16 +824,21 @@ rte_pmd_af_packet_devinit(const char *name, const char 
*params)

ret = rte_kvargs_process(kvlist, ETH_AF_PACKET_IFACE_ARG,
 _packet_iface, );
-   if (ret < 0)
+   if (ret < 0) {
+   rte_kvargs_free(kvlist);
return -1;
+   }
}

ret = rte_eth_from_packet(name, , numa_node, kvlist);
close(sockfd); /* no longer needed */

-   if (ret < 0)
+   if (ret < 0) {
+   rte_kvargs_free(kvlist);
return -1;
+   }

+   rte_kvargs_free(kvlist);
return 0;
 }

-- 
1.8.4.2



[dpdk-dev] [PATCH v3 0/3] Mellanox ConnectX-3 PMD

2015-02-26 Thread Thomas Monjalon
2015-02-26 13:51, Gleb Natapov:
> Did git pull today. After enabling mlnx pmd compilation fails with:
> 
> dpdk/lib/librte_pmd_mlx4/mlx4.c: In function ?mlx4_pci_devinit?:
> dpdk/lib/librte_pmd_mlx4/mlx4.c:4636:14: error: too few arguments to function 
> ?rte_eth_dev_allocate?
> eth_dev = rte_eth_dev_allocate(name);

Yes, thanks for reporting.
I didn't test the disabled mlx4 after hotplug integration:
dpdk.org/browse/dpdk/commit/?id=9f1653e7b7e1746e7c

Clearly, I have to improve my sanity checks.
Sorry for the inconvenience.


[dpdk-dev] [PATCH] kni:optimization of rte_kni_rx_burst

2015-02-26 Thread Marc Sune

On 26/02/15 08:00, Hemant at freescale.com wrote:
>
>> -Original Message-
>> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Jay Rolette
>> Sent: 25/Feb/2015 7:00 PM
>> To: Marc Sune
>> Cc: DPDK
>> Subject: Re: [dpdk-dev] [PATCH] kni:optimization of rte_kni_rx_burst
>>
>> On Wed, Feb 25, 2015 at 6:38 AM, Marc Sune  wrote:
>>
>>> On 25/02/15 13:24, Hemant at freescale.com wrote:
>>>
 Hi OIivier
   Comments inline.
 Regards,
 Hemant

   -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Olivier Deme
> Sent: 25/Feb/2015 5:44 PM
> To: dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] kni:optimization of rte_kni_rx_burst
>
> Thank you Hemant, I think there might be one issue left with the
> patch though.
> The alloc_q must initially be filled with mbufs before getting mbuf
> back on the tx_q.
>
> So the patch should allow rte_kni_rx_burst to check if alloc_q is empty.
> If so, it should invoke kni_allocate_mbufs(kni, 0) (to fill the
> alloc_q with MAX_MBUF_BURST_NUM mbufs)
>
> The patch for rte_kni_rx_burst would then look like:
>
> @@ -575,7 +575,7 @@ rte_kni_rx_burst(struct rte_kni *kni, struct
> rte_mbuf **mbufs, unsigned num)
>
> /* If buffers removed, allocate mbufs and then put them into
> alloc_q */
> if (ret)
> -kni_allocate_mbufs(kni);
> +  kni_allocate_mbufs(kni, ret);  else if
> + (unlikely(kni->alloc_q->write == kni->alloc_q->read))
> +  kni_allocate_mbufs(kni, 0);
>
>   [hemant]  This will introduce a run-time check.
 I missed to include the other change in the patch.
I am doing it in kni_alloc i.e. initiate the alloc_q with default
 burst size.
  kni_allocate_mbufs(ctx, 0);

 In a way, we are now suggesting to reduce the size of alloc_q to only
 default burst size.

>>> As an aside comment here, I think that we should allow to tweak the
>>> userspace <-> kernel queue sizes (rx_q, tx_q, free_q and alloc_q) .
>>> Whether this should be a build configuration option or a parameter to
>>> rte_kni_init(), it is not completely clear to me, but I guess
>>> rte_kni_init() is a better option.
>>>
>> rte_kni_init() is definitely a better option. It allows things to be tuned 
>> based on
>> individual system config rather than requiring different builds.
>>
>>
>>> Having said that, the original mail from Hemant was describing that
>>> KNI was giving an out-of-memory. This to me indicates that the pool is
>>> incorrectly dimensioned. Even if KNI will not pre-allocate in the
>>> alloc_q, or not completely, in the event of high load, you will get
>>> this same "out of memory".
>>>
>>> We can reduce the usage of buffers by the KNI subsystem in kernel
>>> space and in userspace, but the kernel will always need a small cache
>>> of pre-allocated buffers (coming from user-space), since the KNI
>>> kernel module does not know where to grab the packets from (which
>>> pool). So my guess is that the dimensioning problem experienced by
>>> Hemant would be the same, even with the proposed changes.
>>>
>>>
 Can we reach is situation, when the kernel is adding packets faster
 in tx_q than the application is able to dequeue?

>>> I think so. We cannot control much how the kernel will schedule the
>>> KNI thread(s), specially if the # of threads in relation to the cores
>>> is incorrect (not enough), hence we need at least a reasonable amount
>>> of buffering to prevent early dropping to those "internal" burst side 
>>> effects.
>>>
>>> Marc
>>
>> Strongly agree with Marc here. We *really* don't want just a single burst 
>> worth
>> of mbufs available to the kernel in alloc_q. That's just asking for 
>> congestion
>> when there's no need for it.
>>
>> The original problem reported by Olivier is more of a resource tuning problem
>> than anything else. The number of mbufs you need in the system has to take
>> into account internal queue depths.
> [hemant]  Following are my suggestions for the time being.
> 1.  The existing code allocates X buffers and try to add them to alloc_q. If 
> alloc_q is not having space, it frees them. This is not optimized at all.  In 
> the rx_burst, we shall only add the numbers of packets, as removed from tx_q.

Agree

> 2. During the kni_alloc, we can set kni_allocate_mbufs X*Y buffers initially 
> for alloc_q.  We can further improve it to make it configurable in future 
> enhancements.  Currently we can have the value of Y as 2.

Provided that the dimensioning (X*Y), if defined in runtime it is set 
during rte_kni_init(), in principle I agree.

However it is not clear to me if you wantg to call 
kni_allocate_mbufs(X*Y) for every kni_alloc or just in the first one (in 
other words, if X*Y == size of alloc_q). Since alloc_q is shared and 
assuming X*Y == size of alloc_q, I think doing it that in the first 
kni_alloc() 

[dpdk-dev] [PATCH v3 0/3] Mellanox ConnectX-3 PMD

2015-02-26 Thread Gleb Natapov
Did git pull today. After enabling mlnx pmd compilation fails with:

dpdk/lib/librte_pmd_mlx4/mlx4.c: In function ?mlx4_pci_devinit?:
dpdk/lib/librte_pmd_mlx4/mlx4.c:4636:14: error: too few arguments to function 
?rte_eth_dev_allocate?
eth_dev = rte_eth_dev_allocate(name);


On Wed, Feb 25, 2015 at 02:52:03PM +0100, Adrien Mazarguil wrote:
> This PMD adds support for Mellanox ConnectX-3-based adapters through the
> verbs framework. It relies on external libraries (libibverbs and user space
> driver libmlx4) and kernel support to do so.
> 
> While these libraries and kernel modules are available on OpenFabrics
> Alliance's website [1] and provided by package managers on most
> distributions, this PMD requires Ethernet extensions that may not be
> supported at the moment (this is a work in progress).
> 
> Mellanox OFED [2] includes the necessary support and should be used in the
> meantime. For DPDK, only libibverbs, libmlx4 and mlnx-ofed-kernel packages
> are required from that distribution.
> 
> The following kernel modules must be loaded before using this PMD:
> 
> - mlx4_core (hardware driver, does global initialization)
> - mlx4_en (Ethernet device driver)
> - mlx4_ib (InfiniBand device driver)
> - ib_uverbs (user space driver for verbs)
> 
> [1] https://www.openfabrics.org/
> [2] 
> http://www.mellanox.com/page/products_dyn?product_family=26=linux_sw_drivers
> 
> v2:
>  - Include minor bugfix for VLAN filtering.
>  - Add maintainers entry.
>  - Add documentation.
> 
> v3:
>  - Add script and documentation to MAINTAINERS.
>  - Make cosmetic changes to copyright notices.
>  - Remove unwanted executable bits.
>  - Fix coding style and typos found by checkpatch.
>  - Add shared library compilation support.
> 
> Adrien Mazarguil (3):
>   scripts: check features to generate configuration header
>   mlx4: new poll mode driver
>   doc: add librte_pmd_mlx4 documentation
> 
>  MAINTAINERS  |6 +
>  config/common_bsdapp |   11 +
>  config/common_linuxapp   |   11 +
>  doc/guides/prog_guide/index.rst  |1 +
>  doc/guides/prog_guide/mlx4_poll_mode_drv.rst |  326 ++
>  doc/guides/prog_guide/source_org.rst |1 +
>  lib/Makefile |1 +
>  lib/librte_pmd_mlx4/Makefile |  121 +
>  lib/librte_pmd_mlx4/mlx4.c   | 4749 
> ++
>  lib/librte_pmd_mlx4/mlx4.h   |  165 +
>  lib/librte_pmd_mlx4/rte_pmd_mlx4_version.map |4 +
>  mk/rte.app.mk|8 +
>  scripts/auto-config-h.sh |  136 +
>  13 files changed, 5540 insertions(+)
>  create mode 100644 doc/guides/prog_guide/mlx4_poll_mode_drv.rst
>  create mode 100644 lib/librte_pmd_mlx4/Makefile
>  create mode 100644 lib/librte_pmd_mlx4/mlx4.c
>  create mode 100644 lib/librte_pmd_mlx4/mlx4.h
>  create mode 100644 lib/librte_pmd_mlx4/rte_pmd_mlx4_version.map
>  create mode 100755 scripts/auto-config-h.sh
> 
> -- 
> 2.1.0
> 

--
Gleb.


[dpdk-dev] [PATCH v6 0/6] enicpmd: Cisco Systems Inc. VIC Ethernet PMD

2015-02-26 Thread Wiles, Keith
On 2/26/15, 5:49 AM, "Thomas Monjalon"  wrote:

>Hi Sujith,
>
>Do you have news about doc for enic?
>
>In case you didn't find the doc for pktgen-dpdk, it's available here:
>   http://pktgen.readthedocs.org

Hi Sujith,

If you can not find the answer your questions in the doc please me an
email.


Regards,

++Keith
>
>2015-01-21 05:03, Sujith Sankar:
>> Hi David,
>> 
>> Apologies for the delay.  I was not able to find quality time to finish
>>it
>> as a few other things have been keeping me busy.  But I shall work on it
>> and provide the doc and the perf details soon.
>> In the mean time, it would be great if you could point me to some
>>resources
>> on running pktgen-dpdk as I was stuck on it.
>> 
>> Thanks,
>> -Sujith
>> 
>> From: David Marchand
>>mailto:david.marchand at 6wind.com>>
>> Date: Tuesday, 20 January 2015 4:55 pm
>> > Hello Sujith,
>> > 
>> > Any news on the documentation and the performance numbers you said you
>> > would send ?
>> > 
>> > Thanks.
>> > 
>> > --
>> > David Marchand
>> > 
>> > On Thu, Nov 27, 2014 at 4:31 PM, Thomas Monjalon
>> > mailto:thomas.monjalon at 6wind.com>> wrote:
>> > > 2014-11-27 04:27, Sujith Sankar:
>> > > > Thanks Thomas, David and Neil !
>> > > > 
>> > > > I shall work on finishing the documentation.
>> > > > About that, you had mentioned that you wanted it in doc/drivers/
>>path.
>> > > > Could I send a patch with documentation in the path
>> > > > doc/drivers/enicpmd/
>> > > > ?
>> > > 
>> > > Yes.
>> > > I'd prefer doc/drivers/enic/ but it's a detail ;)
>> > > The format must be sphinx rst to allow web publishing.
>> > > 
>> > > It would be great to have some design documentation of every drivers
>> > > in doc/drivers.
>> > > 
>> > > Thanks
>> > > --
>> > > Thomas



[dpdk-dev] [PATCH v6 0/6] enicpmd: Cisco Systems Inc. VIC Ethernet PMD

2015-02-26 Thread Thomas Monjalon
Hi Sujith,

Do you have news about doc for enic?

In case you didn't find the doc for pktgen-dpdk, it's available here:
http://pktgen.readthedocs.org

2015-01-21 05:03, Sujith Sankar:
> Hi David,
> 
> Apologies for the delay.  I was not able to find quality time to finish it
> as a few other things have been keeping me busy.  But I shall work on it
> and provide the doc and the perf details soon.
> In the mean time, it would be great if you could point me to some resources
> on running pktgen-dpdk as I was stuck on it.
> 
> Thanks,
> -Sujith
> 
> From: David Marchand mailto:david.marchand at 
> 6wind.com>>
> Date: Tuesday, 20 January 2015 4:55 pm
> > Hello Sujith,
> > 
> > Any news on the documentation and the performance numbers you said you
> > would send ?
> > 
> > Thanks.
> > 
> > --
> > David Marchand
> > 
> > On Thu, Nov 27, 2014 at 4:31 PM, Thomas Monjalon
> > mailto:thomas.monjalon at 6wind.com>> wrote:
> > > 2014-11-27 04:27, Sujith Sankar:
> > > > Thanks Thomas, David and Neil !
> > > > 
> > > > I shall work on finishing the documentation.
> > > > About that, you had mentioned that you wanted it in doc/drivers/ path.
> > > > Could I send a patch with documentation in the path
> > > > doc/drivers/enicpmd/
> > > > ?
> > > 
> > > Yes.
> > > I'd prefer doc/drivers/enic/ but it's a detail ;)
> > > The format must be sphinx rst to allow web publishing.
> > > 
> > > It would be great to have some design documentation of every drivers
> > > in doc/drivers.
> > > 
> > > Thanks
> > > --
> > > Thomas


[dpdk-dev] [PATCH 1/7] vmxnet3: enable VLAN filtering

2015-02-26 Thread Thomas Monjalon
2015-02-25 18:31, Stephen Hemminger:
> Support the VLAN filter functionality of the VMXNET3 interface.
> 
> Signed-off-by: Stephen Hemminger 
> ---
> v2 -- incorporate comments from Yong Wang

You forgot v2 in the title.
Please prefer a cover letter threading when sending a series of patches;
it's easier to manage.
Thanks


[dpdk-dev] [PATCH v11 2/2] librte_pmd_null: Support port hotplug function

2015-02-26 Thread Mcnamara, John
Hi,

The HEAD doesn't compile with gcc 4.7.2:

$ git clone http://dpdk.org/git/dpdk
$ cd dpdk
$ make T=x86_64-native-linuxapp-gcc -j install 

...
== Build lib/librte_pipeline
  SYMLINK-FILE include/rte_pipeline.h
  CC rte_pipeline.o
/tmp/dpdk/lib/librte_pmd_null/rte_eth_null.c: In function 'eth_stats_get':

/tmp/dpdk/lib/librte_pmd_null/rte_eth_null.c:302:28:
error: array subscript is above array bounds [-Werror=array-bounds]
/tmp/dpdk/lib/librte_pmd_null/rte_eth_null.c:302:28: 
error: array subscript is above array bounds [-Werror=array-bounds]
/tmp/dpdk/lib/librte_pmd_null/rte_eth_null.c:302:28: 
error: array subscript is above array bounds [-Werror=array-bounds]
...

cc1: all warnings being treated as errors
make[5]: *** [rte_eth_null.o] Error 1
make[4]: *** [librte_pmd_null] Error 2


The following commit introduced this issue:

$ git bisect good  
c743e50c475f73edf78e5ba26445d7c6ea217f40 is the first bad commit
commit c743e50c475f73edf78e5ba26445d7c6ea217f40
Author: Tetsuya Mukawa 
Date:   Mon Feb 23 14:12:34 2015 +0900

null: new poll mode driver


I don't see the issue with gcc 4.9.

Regards,

John


[dpdk-dev] [PATCH] headers: typeof -> __typeof__ to unbreak C++11 code

2015-02-26 Thread Thomas Monjalon
Hi Simon,

2015-02-25 14:28, Simon Kagstrom:
> When compiling C++11-code or above (--std=c++11), the build fails with
> lots of
> 
>   rte_eth_ctrl.h:517:3: note: in expansion of macro RTE_ALIGN
> (RTE_ALIGN(RTE_ETH_FLOW_MAX, UINT32_BIT)/UINT32_BIT)
> ^
> 
> When reading the GCC info pages, I get the feeling that __typeof__ is
> a better choice, and that indeed works when including the headers in
> C++ files (--std=c++11).

I'd like to be sure that it's working with every compilers we support
(gcc, icc, clang).
Anyone to check please?


[dpdk-dev] [PATCH v11 2/2] librte_pmd_null: Support port hotplug function

2015-02-26 Thread Thomas Monjalon
2015-02-26 18:06, Tetsuya Mukawa:
> 2015-02-26 16:03 GMT+09:00 Thomas Monjalon :
> > 2015-02-25 16:49, Stephen Hemminger:
> >> Build fails if HOTPLUG is disabled
> 
> Hi Stephen,
> 
> I appreciate for you reporting.
> 
> >
> > OK thanks for reporting.
> > Actually there is no good reason to disable hotplug on Linux.
> > Though it means that it's impossible to build on FreeBSD.
> >
> > Tetsuya, the right fix is to remove this option.
> 
> Hi Thomas,
> 
> Yes, I agree with it. I will add some codes to remove the option.
> Please let me have a few days, I need to prepare BSD machine for compile test.
> 
> > You should manage to graceful degrades hotplug in not supported
> > cases supported: devices cannot be detachable in case of VFIO or nic_uio.
> > What about uio_pci_generic?
> 
> We cannot detach a vfio device so far. But we can detach a igb_uio and
> uio_pci_generic device.
> About a vfio ddevice, I haven't checked related code yet, but I guess
> I will submit code to detach a vfio device in post-rc1.

OK thanks.
I made a quick fix (moving #ifdef) waiting the option removal:
http://dpdk.org/browse/dpdk/commit/?id=7609e6609350



[dpdk-dev] [PATCH v3 3/3] i40e:advertise TSO capability

2015-02-26 Thread Jijiang Liu
Advertise the DEV_TX_OFFLOAD_TCP_TSO flag in the PMD features. It means that 
the i40e PMD supports the offload of TSO.

Signed-off-by: Jijiang Liu 
Signed-off-by: Miroslaw Walukiewicz 

---
 lib/librte_pmd_i40e/i40e_ethdev.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 85e8315..5e502b6 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -1531,7 +1531,8 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
DEV_TX_OFFLOAD_UDP_CKSUM |
DEV_TX_OFFLOAD_TCP_CKSUM |
DEV_TX_OFFLOAD_SCTP_CKSUM |
-   DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
+   DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM |
+   DEV_TX_OFFLOAD_TCP_TSO;
dev_info->reta_size = pf->hash_lut_size;
dev_info->flow_type_rss_offloads = I40E_RSS_OFFLOAD_ALL;

-- 
1.7.7.6



[dpdk-dev] [PATCH v3 2/3] i40e:enable TSO support

2015-02-26 Thread Jijiang Liu
This patch enables i40e TSO feature for both non-tunneling packet and tunneling 
packet

Signed-off-by: Jijiang Liu 
Signed-off-by: Miroslaw Walukiewicz 
Signed-off-by: Grzegorz Galkowski 

---
 lib/librte_pmd_i40e/i40e_rxtx.c |   60 +++---
 lib/librte_pmd_i40e/i40e_rxtx.h |2 +
 2 files changed, 57 insertions(+), 5 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index d0f84c8..9c7be6f 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -506,6 +506,13 @@ i40e_txd_enable_checksum(uint64_t ol_flags,
<< I40E_TX_DESC_LENGTH_IPLEN_SHIFT;
}

+   if (ol_flags & PKT_TX_TCP_SEG) {
+   *td_cmd |= I40E_TX_DESC_CMD_L4T_EOFT_TCP;
+   *td_offset |= (tx_offload.l4_len >> 2)
+   << I40E_TX_DESC_LENGTH_L4_FC_LEN_SHIFT;
+   return;
+   }
+
/* Enable L4 checksum offloads */
switch (ol_flags & PKT_TX_L4_MASK) {
case PKT_TX_TCP_CKSUM:
@@ -1154,7 +1161,7 @@ i40e_calc_context_desc(uint64_t flags)
 {
uint64_t mask = 0ULL;

-   mask |= PKT_TX_OUTER_IP_CKSUM;
+   mask |= (PKT_TX_OUTER_IP_CKSUM | PKT_TX_TCP_SEG);

 #ifdef RTE_LIBRTE_IEEE1588
mask |= PKT_TX_IEEE1588_TMST;
@@ -1165,6 +1172,39 @@ i40e_calc_context_desc(uint64_t flags)
return 0;
 }

+/* set i40e TSO context descriptor */
+static inline uint64_t
+i40e_set_tso_ctx(struct rte_mbuf *mbuf, union i40e_tx_offload tx_offload)
+{
+   uint64_t ctx_desc = 0;
+   uint32_t cd_cmd, hdr_len, cd_tso_len;
+
+   if (!tx_offload.l4_len) {
+   PMD_DRV_LOG(DEBUG, "L4 length set to 0");
+   return ctx_desc;
+   }
+
+   /**
+* in case of tunneling packet, the outer_l2_len and
+* outer_l3_len must be 0.
+*/
+   hdr_len = tx_offload.outer_l2_len +
+   tx_offload.outer_l3_len +
+   tx_offload.l2_len +
+   tx_offload.l3_len +
+   tx_offload.l4_len;
+
+   cd_cmd = I40E_TX_CTX_DESC_TSO;
+   cd_tso_len = mbuf->pkt_len - hdr_len;
+   ctx_desc |= ((uint64_t)cd_cmd << I40E_TXD_CTX_QW1_CMD_SHIFT) |
+   ((uint64_t)cd_tso_len <<
+I40E_TXD_CTX_QW1_TSO_LEN_SHIFT) |
+   ((uint64_t)mbuf->tso_segsz <<
+I40E_TXD_CTX_QW1_MSS_SHIFT);
+
+   return ctx_desc;
+}
+
 uint16_t
 i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
@@ -1214,6 +1254,8 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 
uint16_t nb_pkts)
tx_offload.l3_len = tx_pkt->l3_len;
tx_offload.outer_l2_len = tx_pkt->outer_l2_len;
tx_offload.outer_l3_len = tx_pkt->outer_l3_len;
+   tx_offload.l4_len = tx_pkt->l4_len;
+   tx_offload.tso_segsz = tx_pkt->tso_segsz;

/* Calculate the number of context descriptors needed. */
nb_ctx = i40e_calc_context_desc(ol_flags);
@@ -1282,12 +1324,20 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts, uint16_t nb_pkts)
rte_pktmbuf_free_seg(txe->mbuf);
txe->mbuf = NULL;
}
-#ifdef RTE_LIBRTE_IEEE1588
-   if (ol_flags & PKT_TX_IEEE1588_TMST)
+
+   /* TSO enabled means no timestamp */
+   if (ol_flags & PKT_TX_TCP_SEG)
cd_type_cmd_tso_mss |=
-   ((uint64_t)I40E_TX_CTX_DESC_TSYN <<
-   I40E_TXD_CTX_QW1_CMD_SHIFT);
+   i40e_set_tso_ctx(tx_pkt, tx_offload);
+   else {
+#ifdef RTE_LIBRTE_IEEE1588
+   if (ol_flags & PKT_TX_IEEE1588_TMST)
+   cd_type_cmd_tso_mss |=
+   
((uint64_t)I40E_TX_CTX_DESC_TSYN <<
+I40E_TXD_CTX_QW1_CMD_SHIFT);
 #endif
+   }
+
ctx_txd->tunneling_params =
rte_cpu_to_le_32(cd_tunneling_params);
ctx_txd->l2tag2 = rte_cpu_to_le_16(cd_l2tag2);
diff --git a/lib/librte_pmd_i40e/i40e_rxtx.h b/lib/librte_pmd_i40e/i40e_rxtx.h
index abd8fa2..5b2984a 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.h
+++ b/lib/librte_pmd_i40e/i40e_rxtx.h
@@ -160,6 +160,8 @@ union i40e_tx_offload {
struct {
uint64_t l2_len:7; /**< L2 (MAC) Header Length. */
uint64_t l3_len:9; /**< L3 (IP) Header Length. */
+   uint64_t l4_len:8; /**< L4 Header Length. */
+   uint64_t tso_segsz:16; /**< TCP TSO segment size */
uint64_t outer_l2_len:8; /**< outer L2 Header Length */
uint64_t 

[dpdk-dev] [PATCH v3 1/3] i40e:move Tx offloads parameters of i40e to separate structure

2015-02-26 Thread Jijiang Liu
The structure size is u64 so it could be used with single cpu operation.

Signed-off-by: Jijiang Liu 
Signed-off-by: Miroslaw Walukiewicz 
Signed-off-by: Grzegorz Galkowski 

---
 lib/librte_pmd_i40e/i40e_rxtx.c |   39 +--
 lib/librte_pmd_i40e/i40e_rxtx.h |   11 +++
 2 files changed, 28 insertions(+), 22 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index 12c0831..d0f84c8 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -465,16 +465,13 @@ static inline void
 i40e_txd_enable_checksum(uint64_t ol_flags,
uint32_t *td_cmd,
uint32_t *td_offset,
-   uint8_t l2_len,
-   uint16_t l3_len,
-   uint8_t outer_l2_len,
-   uint16_t outer_l3_len,
+   union i40e_tx_offload tx_offload,
uint32_t *cd_tunneling)
 {
/* UDP tunneling packet TX checksum offload */
if (ol_flags & PKT_TX_OUTER_IP_CKSUM) {

-   *td_offset |= (outer_l2_len >> 1)
+   *td_offset |= (tx_offload.outer_l2_len >> 1)
<< I40E_TX_DESC_LENGTH_MACLEN_SHIFT;

if (ol_flags & PKT_TX_OUTER_IP_CKSUM)
@@ -485,25 +482,28 @@ i40e_txd_enable_checksum(uint64_t ol_flags,
*cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV6;

/* Now set the ctx descriptor fields */
-   *cd_tunneling |= (outer_l3_len >> 2) <<
+   *cd_tunneling |= (tx_offload.outer_l3_len >> 2) <<
I40E_TXD_CTX_QW0_EXT_IPLEN_SHIFT |
-   (l2_len >> 1) <<
+   (tx_offload.l2_len >> 1) <<
I40E_TXD_CTX_QW0_NATLEN_SHIFT;

} else
-   *td_offset |= (l2_len >> 1)
+   *td_offset |= (tx_offload.l2_len >> 1)
<< I40E_TX_DESC_LENGTH_MACLEN_SHIFT;

/* Enable L3 checksum offloads */
if (ol_flags & PKT_TX_IP_CKSUM) {
*td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV4_CSUM;
-   *td_offset |= (l3_len >> 2) << I40E_TX_DESC_LENGTH_IPLEN_SHIFT;
+   *td_offset |= (tx_offload.l3_len >> 2)
+   << I40E_TX_DESC_LENGTH_IPLEN_SHIFT;
} else if (ol_flags & PKT_TX_IPV4) {
*td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV4;
-   *td_offset |= (l3_len >> 2) << I40E_TX_DESC_LENGTH_IPLEN_SHIFT;
+   *td_offset |= (tx_offload.l3_len >> 2)
+   << I40E_TX_DESC_LENGTH_IPLEN_SHIFT;
} else if (ol_flags & PKT_TX_IPV6) {
*td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV6;
-   *td_offset |= (l3_len >> 2) << I40E_TX_DESC_LENGTH_IPLEN_SHIFT;
+   *td_offset |= (tx_offload.l3_len >> 2)
+   << I40E_TX_DESC_LENGTH_IPLEN_SHIFT;
}

/* Enable L4 checksum offloads */
@@ -1183,15 +1183,12 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts, uint16_t nb_pkts)
uint32_t tx_flags;
uint32_t td_tag;
uint64_t ol_flags;
-   uint8_t l2_len;
-   uint16_t l3_len;
-   uint8_t outer_l2_len;
-   uint16_t outer_l3_len;
uint16_t nb_used;
uint16_t nb_ctx;
uint16_t tx_last;
uint16_t slen;
uint64_t buf_dma_addr;
+   union i40e_tx_offload tx_offload = { .data = 0 };

txq = tx_queue;
sw_ring = txq->sw_ring;
@@ -1213,10 +1210,10 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts, uint16_t nb_pkts)
RTE_MBUF_PREFETCH_TO_FREE(txe->mbuf);

ol_flags = tx_pkt->ol_flags;
-   l2_len = tx_pkt->l2_len;
-   l3_len = tx_pkt->l3_len;
-   outer_l2_len = tx_pkt->outer_l2_len;
-   outer_l3_len = tx_pkt->outer_l3_len;
+   tx_offload.l2_len = tx_pkt->l2_len;
+   tx_offload.l3_len = tx_pkt->l3_len;
+   tx_offload.outer_l2_len = tx_pkt->outer_l2_len;
+   tx_offload.outer_l3_len = tx_pkt->outer_l3_len;

/* Calculate the number of context descriptors needed. */
nb_ctx = i40e_calc_context_desc(ol_flags);
@@ -1267,9 +1264,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 
uint16_t nb_pkts)
cd_tunneling_params = 0;
if (unlikely(ol_flags & I40E_TX_CKSUM_OFFLOAD_MASK)) {
i40e_txd_enable_checksum(ol_flags, _cmd, _offset,
-   l2_len, l3_len, outer_l2_len,
-   outer_l3_len,
-   _tunneling_params);
+   tx_offload, _tunneling_params);
}

if (unlikely(nb_ctx)) {
diff --git a/lib/librte_pmd_i40e/i40e_rxtx.h 

[dpdk-dev] [PATCH v3 0/3] support TSO on i40e

2015-02-26 Thread Jijiang Liu
This patch set enables i40e TSO feature for both non-tunneling packet and 
tunneling packet.

Change logs:
v2 change: rework based on Olivier's patch set [PATCH v2 00/20] enhance Tx 
checksum offload API
http://dpdk.org/ml/archives/dev/2015-February/012375.html
v3 change: 
1. split 'enable i40e TSO' patch in v2 into two patches.
  One patch is for moving tx offloads parameters of i40e to 
separate structure.
  And other patch is for enabling i40e TSO feature for both 
non-tunneling packet and tunneling packet   
2. patch order change

Jijiang Liu (3):
  Move Tx offloads parameters of i40e to separate structure
  Enable i40e TSO feature for both non-tunneling packet and tunneling packet 
  Advertise the DEV_TX_OFFLOAD_TCP_TSO flag in the PMD features  

 lib/librte_pmd_i40e/i40e_ethdev.c |3 +-
 lib/librte_pmd_i40e/i40e_rxtx.c   |   99 +++--
 lib/librte_pmd_i40e/i40e_rxtx.h   |   13 +
 3 files changed, 87 insertions(+), 28 deletions(-)

-- 
1.7.7.6



[dpdk-dev] [PATCH 35/36] ixgbe base codes: Update readme

2015-02-26 Thread Ouyang Changchun
Update the share code version into cid-10g-shared-code.2015.02.03.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/README | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/README 
b/lib/librte_pmd_ixgbe/ixgbe/README
index e0e5f0d..ba1249b 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/README
+++ b/lib/librte_pmd_ixgbe/ixgbe/README
@@ -34,7 +34,7 @@ Intel? IXGBE driver
 ===

 This directory contains source code of FreeBSD ixgbe driver of version
-cid-10g-shared-code.2014.09.04 released by LAD. The sub-directory of lad/
+cid-10g-shared-code.2015.02.03 released by LAD. The sub-directory of lad/
 contains the original source package.
 This driver is valid for the product(s) listed below

-- 
1.8.4.2



[dpdk-dev] [PATCH] af_packet: Fix some klocwork errors

2015-02-26 Thread Pawel Wodkowski
On 2015-02-26 07:42, Ouyang Changchun wrote:
> Fix possible memory leak issue: free kvlist before return;
> Fix possible resource lost issue: close qssockfd before return;
>
> Signed-off-by: Changchun Ouyang 
> ---
>   lib/librte_pmd_af_packet/rte_eth_af_packet.c | 11 +--
>   1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/lib/librte_pmd_af_packet/rte_eth_af_packet.c 
> b/lib/librte_pmd_af_packet/rte_eth_af_packet.c
> index 80e9bdf..cf8f4fa 100644
> --- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c
> +++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c
> @@ -694,6 +694,8 @@ error:
>   }
>   rte_free(*internals);
>   }
> + if (qsockfd != -1)
> + close(qsockfd);
>   return -1;
>   }
>
> @@ -822,16 +824,21 @@ rte_pmd_af_packet_devinit(const char *name, const char 
> *params)
>
>   ret = rte_kvargs_process(kvlist, ETH_AF_PACKET_IFACE_ARG,
>_packet_iface, );
> - if (ret < 0)
> + if (ret < 0) {
> + rte_kvargs_free(kvlist);
>   return -1;
> + }
>   }
>
>   ret = rte_eth_from_packet(name, , numa_node, kvlist);
>   close(sockfd); /* no longer needed */
>
> - if (ret < 0)
> + if (ret < 0) {
> + rte_kvargs_free(kvlist);
>   return -1;
> + }
>
> + rte_kvargs_free(kvlist);
>   return 0;
>   }
>
>

This patch is correct but it would be good to rework it to have common 
error exit point like in rte_pmd_init_internals() function you changed.

-- 
Pawel


[dpdk-dev] [PATCH 3/5] xen: add phys-addr command line argument

2015-02-26 Thread Stephen Hemminger
On Thu, 26 Feb 2015 07:55:13 +
"Liu, Jijiang"  wrote:

> If the application is built with DOM0 support , the application will run in 
> non Dom0 environment when using the new argument, correct?

Yes.

Our startup script has

if [ -d /proc/xen ] ; then
log_progress_msg "xen_uio"
modprobe xen_uio
if [ "$(cat /proc/xen/domain)" == "pv" ]; then
log_progress_msg "rte_dom0_mm"
modprobe rte_dom0_mm xen_phys_addr=y
set_domU_memsize
XEN_ARGS="--xen-dom0 --xen-phys-addr"
fi
fi


[dpdk-dev] [PATCH v11 2/2] librte_pmd_null: Support port hotplug function

2015-02-26 Thread Thomas Monjalon
2015-02-25 16:49, Stephen Hemminger:
> Build fails if HOTPLUG is disabled

OK thanks for reporting.
Actually there is no good reason to disable hotplug on Linux.
Though it means that it's impossible to build on FreeBSD.

Tetsuya, the right fix is to remove this option.
You should manage to graceful degrades hotplug in not supported
cases supported: devices cannot be detachable in case of VFIO or nic_uio.
What about uio_pci_generic?


[dpdk-dev] [PATCH] Missing use of macro rte_eth_dev_is_valid_port()

2015-02-26 Thread Keith Wiles
Signed-off-by: Keith Wiles 
---
 lib/librte_ether/rte_ethdev.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index bb94ccb..6fd89d7 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3541,7 +3541,7 @@ rte_eth_add_rx_callback(uint8_t port_id, uint16_t 
queue_id,
return NULL;
 #endif
/* check input parameters */
-   if (port_id >= nb_ports || fn == NULL ||
+   if (!rte_eth_dev_is_valid_port(port_id) || fn == NULL ||
queue_id >= rte_eth_devices[port_id].data->nb_rx_queues) {
rte_errno = EINVAL;
return NULL;
@@ -3570,7 +3570,7 @@ rte_eth_add_tx_callback(uint8_t port_id, uint16_t 
queue_id,
return NULL;
 #endif
/* check input parameters */
-   if (port_id >= nb_ports || fn == NULL ||
+   if (!rte_eth_dev_is_valid_port(port_id) || fn == NULL ||
queue_id >= rte_eth_devices[port_id].data->nb_tx_queues) {
rte_errno = EINVAL;
return NULL;
@@ -3598,7 +3598,7 @@ rte_eth_remove_rx_callback(uint8_t port_id, uint16_t 
queue_id,
return (-ENOTSUP);
 #endif
/* Check input parameters. */
-   if (port_id >= nb_ports || user_cb == NULL ||
+   if (!rte_eth_dev_is_valid_port(port_id) || user_cb == NULL ||
queue_id >= rte_eth_devices[port_id].data->nb_rx_queues) {
return (-EINVAL);
}
@@ -3637,7 +3637,7 @@ rte_eth_remove_tx_callback(uint8_t port_id, uint16_t 
queue_id,
return (-ENOTSUP);
 #endif
/* Check input parameters. */
-   if (port_id >= nb_ports || user_cb == NULL ||
+   if (!rte_eth_dev_is_valid_port(port_id) || user_cb == NULL ||
queue_id >= rte_eth_devices[port_id].data->nb_tx_queues) {
return (-EINVAL);
}
-- 
2.3.0



[dpdk-dev] [PATCH 3/5] xen: add phys-addr command line argument

2015-02-26 Thread Liu, Jijiang


> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Stephen Hemminger
> Sent: Sunday, February 15, 2015 11:25 PM
> To: dev at dpdk.org
> Cc: Stephen Hemminger
> Subject: [dpdk-dev] [PATCH 3/5] xen: add phys-addr command line argument
> 
> Allow overriding default Xen DOM0 behavior to use physical addresses insted of
> mfn

If the application is built with DOM0 support , the application will run in non 
Dom0 environment when using the new argument, correct?

> Signed-off-by: Stephen Hemminger 
> ---
> v2 -- no changes
> 
>  lib/librte_eal/common/eal_common_options.c |  5 +
>  lib/librte_eal/common/eal_internal_cfg.h   |  1 +
>  lib/librte_eal/common/eal_options.h|  2 ++
>  lib/librte_eal/common/include/rte_memory.h |  3 +++
>  lib/librte_eal/linuxapp/eal/eal_memory.c   |  5 +
>  lib/librte_mempool/rte_dom0_mempool.c  | 10 --
>  6 files changed, 24 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/librte_eal/common/eal_common_options.c
> b/lib/librte_eal/common/eal_common_options.c
> index 67e02dc..1742364 100644
> --- a/lib/librte_eal/common/eal_common_options.c
> +++ b/lib/librte_eal/common/eal_common_options.c
> @@ -83,6 +83,7 @@ eal_long_options[] = {
>   {OPT_LOG_LEVEL, 1, NULL, OPT_LOG_LEVEL_NUM},
>   {OPT_BASE_VIRTADDR, 1, 0, OPT_BASE_VIRTADDR_NUM},
>   {OPT_XEN_DOM0, 0, 0, OPT_XEN_DOM0_NUM},
> + {OPT_XEN_PHYS_ADDR, 0, 0, OPT_XEN_PHYS_ADDR_NUM},
>   {OPT_CREATE_UIO_DEV, 1, NULL, OPT_CREATE_UIO_DEV_NUM},
>   {OPT_VFIO_INTR, 1, NULL, OPT_VFIO_INTR_NUM},
>   {0, 0, 0, 0}
> @@ -491,6 +492,10 @@ eal_parse_common_option(int opt, const char
> *optarg,
>   }
>   conf->log_level = log;
>   break;
> +
> + case OPT_XEN_PHYS_ADDR_NUM:
> + conf->xen_phys_addr_support = 1;
> + break;
>   }
> 
>   /* don't know what to do, leave this to caller */ diff --git
> a/lib/librte_eal/common/eal_internal_cfg.h
> b/lib/librte_eal/common/eal_internal_cfg.h
> index e2ecb0d..41b4169 100644
> --- a/lib/librte_eal/common/eal_internal_cfg.h
> +++ b/lib/librte_eal/common/eal_internal_cfg.h
> @@ -65,6 +65,7 @@ struct internal_config {
>   volatile unsigned force_nrank;/**< force number of ranks */
>   volatile unsigned no_hugetlbfs;   /**< true to disable hugetlbfs */
>   volatile unsigned xen_dom0_support; /**< support app running on Xen
> Dom0*/
> + volatile unsigned xen_phys_addr_support; /**< support phys addr */
>   volatile unsigned no_pci; /**< true to disable PCI */
>   volatile unsigned no_hpet;/**< true to disable HPET */
>   volatile unsigned vmware_tsc_map; /**< true to use VMware TSC
> mapping diff --git a/lib/librte_eal/common/eal_options.h
> b/lib/librte_eal/common/eal_options.h
> index e476f8d..8aee959 100644
> --- a/lib/librte_eal/common/eal_options.h
> +++ b/lib/librte_eal/common/eal_options.h
> @@ -73,6 +73,8 @@ enum {
>   OPT_BASE_VIRTADDR_NUM,
>  #define OPT_XEN_DOM0"xen-dom0"
>   OPT_XEN_DOM0_NUM,
> +#define OPT_XEN_PHYS_ADDR "xen-phys-addr"
> + OPT_XEN_PHYS_ADDR_NUM,
>  #define OPT_CREATE_UIO_DEV "create-uio-dev"
>   OPT_CREATE_UIO_DEV_NUM,
>  #define OPT_VFIO_INTR"vfio-intr"
> diff --git a/lib/librte_eal/common/include/rte_memory.h
> b/lib/librte_eal/common/include/rte_memory.h
> index ab6c1ff..c3b8a98 100644
> --- a/lib/librte_eal/common/include/rte_memory.h
> +++ b/lib/librte_eal/common/include/rte_memory.h
> @@ -180,6 +180,9 @@ unsigned rte_memory_get_nrank(void);  /**< Internal
> use only - should DOM0 memory mapping be used */  extern int
> is_xen_dom0_supported(void);
> 
> +/**< Internal use only - should DOM0 use physical addresses insted of
> +mfn */ extern int is_xen_phys_addr_supported(void);
> +
>  /**
>   * Return the physical address of elt, which is an element of the pool mp.
>   *
> diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c
> b/lib/librte_eal/linuxapp/eal/eal_memory.c
> index 4afda2a..a759ac9 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_memory.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
> @@ -103,6 +103,11 @@ int is_xen_dom0_supported(void)  {
>   return internal_config.xen_dom0_support;  }
> +
> +int is_xen_phys_addr_supported(void)
> +{
> + return internal_config.xen_phys_addr_support;
> +}
>  #endif
> 
>  /**
> diff --git a/lib/librte_mempool/rte_dom0_mempool.c
> b/lib/librte_mempool/rte_dom0_mempool.c
> index 9ec68fb..ab35826 100644
> --- a/lib/librte_mempool/rte_dom0_mempool.c
> +++ b/lib/librte_mempool/rte_dom0_mempool.c
> @@ -74,8 +74,14 @@ get_phys_map(void *va, phys_addr_t pa[], uint32_t
> pg_num,
>  virt_addr =(uintptr_t) mcfg->memseg[memseg_id].addr;
> 
>  for (i = 0; i != pg_num; i++) {
> -mfn_id = ((uintptr_t)va + i * pg_sz - virt_addr) / RTE_PGSIZE_2M;
> -pa[i] = mcfg->memseg[memseg_id].mfn[mfn_id] * page_size;
> + if (!is_xen_phys_addr_supported()) {
> + mfn_id = ((uintptr_t)va 

[dpdk-dev] [PATCH v2] eal: Clean up export of per_lcore__socket_id

2015-02-26 Thread Neil Horman
Theres no need to export this variable.  Its set and queried from an API call
that doesn't exist in the hot path.  Instead just export the rte_socket_id
symbol and make the variable private to protect it from type changes.  We should
do this with the other exported variables too, but I think its too late in the
release cycle to do that.

tested using distributor_autotest (which uses rte_socket_id), successfully.
Only tested on linux, as I don't currently have a bsd system spun up, but the
changes are symmetric, and should be fine

Signed-off-by: Neil Horman 

---
Change Notes:

v2) Moved rte_socket_id to be a common function
---
 lib/librte_eal/bsdapp/eal/eal_thread.c  | 1 -
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   | 2 +-
 lib/librte_eal/common/eal_common_thread.c   | 7 +++
 lib/librte_eal/common/include/rte_lcore.h   | 7 +--
 lib/librte_eal/linuxapp/eal/eal_thread.c| 1 -
 lib/librte_eal/linuxapp/eal/rte_eal_version.map | 2 +-
 6 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal_thread.c 
b/lib/librte_eal/bsdapp/eal/eal_thread.c
index ca95c72..3672cdb 100644
--- a/lib/librte_eal/bsdapp/eal/eal_thread.c
+++ b/lib/librte_eal/bsdapp/eal/eal_thread.c
@@ -59,7 +59,6 @@
 RTE_DEFINE_PER_LCORE(unsigned, _lcore_id) = LCORE_ID_ANY;
 RTE_DEFINE_PER_LCORE(unsigned, _socket_id) = (unsigned)SOCKET_ID_ANY;
 RTE_DEFINE_PER_LCORE(rte_cpuset_t, _cpuset);
-
 /*
  * Send a message to a slave lcore identified by slave_id to call a
  * function f with argument arg. Once the execution is done, the
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map 
b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 17515a9..d83524d 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -10,7 +10,6 @@ DPDK_2.0 {
pci_driver_list;
per_lcore__lcore_id;
per_lcore__rte_errno;
-   per_lcore__socket_id;
rte_cpu_check_supported;
rte_cpu_get_flag_enabled;
rte_cycles_vmware_tsc_map;
@@ -82,6 +81,7 @@ DPDK_2.0 {
rte_set_log_level;
rte_set_log_type;
rte_snprintf;
+   rte_socket_id;
rte_strerror;
rte_strsplit;
rte_sys_gettid;
diff --git a/lib/librte_eal/common/eal_common_thread.c 
b/lib/librte_eal/common/eal_common_thread.c
index f4d9892..2405e93 100644
--- a/lib/librte_eal/common/eal_common_thread.c
+++ b/lib/librte_eal/common/eal_common_thread.c
@@ -46,6 +46,13 @@

 #include "eal_thread.h"

+RTE_DECLARE_PER_LCORE(unsigned , _socket_id);
+
+unsigned rte_socket_id(void)
+{
+   return RTE_PER_LCORE(_socket_id);
+}
+
 int eal_cpuset_socket_id(rte_cpuset_t *cpusetp)
 {
unsigned cpu = 0;
diff --git a/lib/librte_eal/common/include/rte_lcore.h 
b/lib/librte_eal/common/include/rte_lcore.h
index 20a58eb..e03264e 100644
--- a/lib/librte_eal/common/include/rte_lcore.h
+++ b/lib/librte_eal/common/include/rte_lcore.h
@@ -81,7 +81,6 @@ struct lcore_config {
 extern struct lcore_config lcore_config[RTE_MAX_LCORE];

 RTE_DECLARE_PER_LCORE(unsigned, _lcore_id);  /**< Per thread "lcore id". */
-RTE_DECLARE_PER_LCORE(unsigned, _socket_id); /**< Per thread "socket id". */
 RTE_DECLARE_PER_LCORE(rte_cpuset_t, _cpuset); /**< Per thread "cpuset". */

 /**
@@ -145,11 +144,7 @@ rte_lcore_index(int lcore_id)
  * @return
  *   the ID of current lcoreid's physical socket
  */
-static inline unsigned
-rte_socket_id(void)
-{
-   return RTE_PER_LCORE(_socket_id);
-}
+unsigned rte_socket_id(void);

 /**
  * Get the ID of the physical socket of the specified lcore
diff --git a/lib/librte_eal/linuxapp/eal/eal_thread.c 
b/lib/librte_eal/linuxapp/eal/eal_thread.c
index 5635c7d..65bcbe3 100644
--- a/lib/librte_eal/linuxapp/eal/eal_thread.c
+++ b/lib/librte_eal/linuxapp/eal/eal_thread.c
@@ -59,7 +59,6 @@
 RTE_DEFINE_PER_LCORE(unsigned, _lcore_id) = LCORE_ID_ANY;
 RTE_DEFINE_PER_LCORE(unsigned, _socket_id) = (unsigned)SOCKET_ID_ANY;
 RTE_DEFINE_PER_LCORE(rte_cpuset_t, _cpuset);
-
 /*
  * Send a message to a slave lcore identified by slave_id to call a
  * function f with argument arg. Once the execution is done, the
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map 
b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index 17515a9..d83524d 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -10,7 +10,6 @@ DPDK_2.0 {
pci_driver_list;
per_lcore__lcore_id;
per_lcore__rte_errno;
-   per_lcore__socket_id;
rte_cpu_check_supported;
rte_cpu_get_flag_enabled;
rte_cycles_vmware_tsc_map;
@@ -82,6 +81,7 @@ DPDK_2.0 {
rte_set_log_level;
rte_set_log_type;
rte_snprintf;
+   rte_socket_id;
rte_strerror;
rte_strsplit;
rte_sys_gettid;
-- 
2.1.0



[dpdk-dev] [PATCH] kni:optimization of rte_kni_rx_burst

2015-02-26 Thread hem...@freescale.com


> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Jay Rolette
> Sent: 25/Feb/2015 7:00 PM
> To: Marc Sune
> Cc: DPDK
> Subject: Re: [dpdk-dev] [PATCH] kni:optimization of rte_kni_rx_burst
> 
> On Wed, Feb 25, 2015 at 6:38 AM, Marc Sune  wrote:
> 
> >
> > On 25/02/15 13:24, Hemant at freescale.com wrote:
> >
> >> Hi OIivier
> >>  Comments inline.
> >> Regards,
> >> Hemant
> >>
> >>  -Original Message-
> >>> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Olivier Deme
> >>> Sent: 25/Feb/2015 5:44 PM
> >>> To: dev at dpdk.org
> >>> Subject: Re: [dpdk-dev] [PATCH] kni:optimization of rte_kni_rx_burst
> >>>
> >>> Thank you Hemant, I think there might be one issue left with the
> >>> patch though.
> >>> The alloc_q must initially be filled with mbufs before getting mbuf
> >>> back on the tx_q.
> >>>
> >>> So the patch should allow rte_kni_rx_burst to check if alloc_q is empty.
> >>> If so, it should invoke kni_allocate_mbufs(kni, 0) (to fill the
> >>> alloc_q with MAX_MBUF_BURST_NUM mbufs)
> >>>
> >>> The patch for rte_kni_rx_burst would then look like:
> >>>
> >>> @@ -575,7 +575,7 @@ rte_kni_rx_burst(struct rte_kni *kni, struct
> >>> rte_mbuf **mbufs, unsigned num)
> >>>
> >>>/* If buffers removed, allocate mbufs and then put them into
> >>> alloc_q */
> >>>if (ret)
> >>> -kni_allocate_mbufs(kni);
> >>> +  kni_allocate_mbufs(kni, ret);  else if
> >>> + (unlikely(kni->alloc_q->write == kni->alloc_q->read))
> >>> +  kni_allocate_mbufs(kni, 0);
> >>>
> >>>  [hemant]  This will introduce a run-time check.
> >>
> >> I missed to include the other change in the patch.
> >>   I am doing it in kni_alloc i.e. initiate the alloc_q with default
> >> burst size.
> >> kni_allocate_mbufs(ctx, 0);
> >>
> >> In a way, we are now suggesting to reduce the size of alloc_q to only
> >> default burst size.
> >>
> >
> > As an aside comment here, I think that we should allow to tweak the
> > userspace <-> kernel queue sizes (rx_q, tx_q, free_q and alloc_q) .
> > Whether this should be a build configuration option or a parameter to
> > rte_kni_init(), it is not completely clear to me, but I guess
> > rte_kni_init() is a better option.
> >
> 
> rte_kni_init() is definitely a better option. It allows things to be tuned 
> based on
> individual system config rather than requiring different builds.
> 
> 
> > Having said that, the original mail from Hemant was describing that
> > KNI was giving an out-of-memory. This to me indicates that the pool is
> > incorrectly dimensioned. Even if KNI will not pre-allocate in the
> > alloc_q, or not completely, in the event of high load, you will get
> > this same "out of memory".
> >
> > We can reduce the usage of buffers by the KNI subsystem in kernel
> > space and in userspace, but the kernel will always need a small cache
> > of pre-allocated buffers (coming from user-space), since the KNI
> > kernel module does not know where to grab the packets from (which
> > pool). So my guess is that the dimensioning problem experienced by
> > Hemant would be the same, even with the proposed changes.
> >
> >
> >> Can we reach is situation, when the kernel is adding packets faster
> >> in tx_q than the application is able to dequeue?
> >>
> >
> > I think so. We cannot control much how the kernel will schedule the
> > KNI thread(s), specially if the # of threads in relation to the cores
> > is incorrect (not enough), hence we need at least a reasonable amount
> > of buffering to prevent early dropping to those "internal" burst side 
> > effects.
> >
> > Marc
> 
> 
> Strongly agree with Marc here. We *really* don't want just a single burst 
> worth
> of mbufs available to the kernel in alloc_q. That's just asking for congestion
> when there's no need for it.
> 
> The original problem reported by Olivier is more of a resource tuning problem
> than anything else. The number of mbufs you need in the system has to take
> into account internal queue depths.

[hemant]  Following are my suggestions for the time being.
1.  The existing code allocates X buffers and try to add them to alloc_q. If 
alloc_q is not having space, it frees them. This is not optimized at all.  In 
the rx_burst, we shall only add the numbers of packets, as removed from tx_q. 
2. During the kni_alloc, we can set kni_allocate_mbufs X*Y buffers initially 
for alloc_q.  We can further improve it to make it configurable in future 
enhancements.  Currently we can have the value of Y as 2. 
3. kni_allocate_mbufs will allocate as many buffer are requested in function 
parameter.

> 
> Jay


[dpdk-dev] [PATCH 1/4] xen: allow choosing dom0 support at runtime

2015-02-26 Thread Liu, Jijiang


> -Original Message-
> From: Stephen Hemminger [mailto:stephen at networkplumber.org]
> Sent: Sunday, February 15, 2015 10:28 PM
> To: Liu, Jijiang
> Cc: Stephen Hemminger; dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 1/4] xen: allow choosing dom0 support at
> runtime
> 
> On Sun, 15 Feb 2015 04:07:21 +
> "Liu, Jijiang"  wrote:
> 
> > Hi Stephen,
> >
> > What do you mean ' allow choosing dom0 support at runtime'?
> > If you mean user can choose DPDK  to run Xen Dom0 or not on DOM0 by a
> runtime flag, I don't think your change can achieve this goal.
> >
> > Thanks
> > Jijiang Liu
> 
> With the existing DPDK model if application is built with DOM0 support it will
> not work (it crashes) if the application is run in a non DOM0 environment 
> (with
> real huge pages). And vice-versa if application is built without DOM0 support
> and it will crash if run in Xen Paravirt mode.
> 
> This patch allows the library to be built in such a way that only one version
> needs to be shipped which is important for distro's like RHEL who want to 
> ship a
> shared library. And also important for users like Brocade/Vyatta who build one
> binary that needs to work on bare Linux and in Xen PV mode.
> 
Ok, thanks for the explanation.

Could you  replace 'internal_config.xen_dom0_support' with  
'is_xen_dom0_supported()' in the function  rte_eal_hugepage_init()?

/* check if app runs on Xen Dom0 */
if (internal_config.xen_dom0_support) {
#ifdef RTE_LIBRTE_XEN_DOM0
/* use dom0_mm kernel driver to init memory */
if (rte_xen_dom0_memory_init() < 0)
return -1;
else
return 0;
#endif




[dpdk-dev] [PATCH] pci: save list of detached devices, and re-probe during driver unload

2015-02-26 Thread Raz Amir
Added code that saves the pointers to the detached devices, during
driver loading, and during driver unloading, go over the list,
and re-attach them by calling device_probe_and_attach
on each device.

Signed-off-by: Raz Amir 
---
 lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c 
b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c
index 5ae8560..7d702a5 100644
--- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c
+++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c
@@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$");

 #define MAX_BARS (PCIR_MAX_BAR_0 + 1)

+#define MAX_DETACHED_DEVICES   128
+static device_t detached_devices[MAX_DETACHED_DEVICES] = {};
+static int last_detached = 0;

 struct nic_uio_softc {
device_tdev_t;
@@ -291,14 +294,35 @@ nic_uio_load(void)
if (dev != NULL)
for (i = 0; i < NUM_DEVICES; i++)
if (pci_get_vendor(dev) == devices[i].vend &&
-   pci_get_device(dev) == 
devices[i].dev)
+   pci_get_device(dev) == 
devices[i].dev) {
+   if (last_detached+1 < 
MAX_DETACHED_DEVICES) {
+   
printf("nic_uio_load: detaching and storing dev=%p\n", dev);
+   
detached_devices[last_detached++] = dev;
+   }
+   else {
+   
printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. dev=%p won't be 
reattached\n",
+   
MAX_DETACHED_DEVICES, dev);
+   }
+   
device_detach(dev);
+   }
}
 }

 static void
 nic_uio_unload(void)
 {
+   int i;
+   printf("nic_uio_unload: entered ... \n");
+
+   for (i = 0; i < last_detached; i++) {
+   printf("nic_uio_unload: calling to device_probe_and_attach for 
dev=%p...\n",
+   detached_devices[i]);
+   device_probe_and_attach(detached_devices[i]);
+   printf("nic_uio_unload: done.\n");
+   }
+
+   printf("nic_uio_unload: leaving ... \n");
 }

 static int
-- 
2.1.2



[dpdk-dev] [PATCH] tools/dpdk_nic_bind: Fix can't bind virtio-pci issue

2015-02-26 Thread Xu, Qian Q
Tested-by: Qian Xu 

- Tested Commit: b67578ccdf45df9fd0f0204578b71acd854ca834
- OS: Fedora20 3.11
- GCC: gcc version 4.8.3 20140624
- CPU: Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz
- NIC: Intel 82599 Ethernet 10G SFI/SFP+ Network Connection
- Default x86_64-native-linuxapp-gcc configuration
- Total 1 case, 1 passed, 0 failed

- Case: bind virtio-pci driver when igb_uio is removed
Steps:   
1. Bind virtio port to igb_uio driver;
2. Remove igb_uio module;
3. Bind virtio port to virtio-pci driver, it can be binded to virtio-pci driver 
and also have a warning that no supported modules(DPDK Driver) are loaded.

Signed-off-by: Qian Xu 

-Original Message-
From: Ouyang, Changchun 
Sent: Thursday, February 26, 2015 12:58 PM
To: dev at dpdk.org
Cc: Richardson, Bruce; Cao, Waterman; Ouyang, Changchun
Subject: [PATCH] tools/dpdk_nic_bind: Fix can't bind virtio-pci issue

In virtio test, on guest
1. Bind virtio port to igb_uio driver;
2. Remove igb_uio module;
3. Bind virtio port to virtio-pci driver, it fails and reports:
   "Error - no supported modules are loaded"

The tool should check the to-be-bound driver flag, if it is dpdk 
driver(igb_uio, vfio etc), and the corresponding module is not loaded, then 
exit, otherwise, just report a warning, and continue to bind the non-dpdk 
driver(like virtio-pci) to dev.

Signed-off-by: Changchun Ouyang 
---
 tools/dpdk_nic_bind.py | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/dpdk_nic_bind.py b/tools/dpdk_nic_bind.py index 
2483056..8523f82 100755
--- a/tools/dpdk_nic_bind.py
+++ b/tools/dpdk_nic_bind.py
@@ -175,8 +175,11 @@ def check_modules():

 # check if we have at least one loaded module
 if True not in [mod["Found"] for mod in mods] and b_flag is not None:
-print "Error - no supported modules are loaded"
-sys.exit(1)
+if b_flag in dpdk_drivers:
+print "Error - no supported modules(DPDK driver) are loaded"
+sys.exit(1)
+else:
+print "Warning - no supported modules(DPDK driver) are loaded"

 # change DPDK driver list to only contain drivers that are loaded
 dpdk_drivers = [mod["Name"] for mod in mods if mod["Found"]]
--
1.8.4.2



[dpdk-dev] [PATCH v15] testpmd: Add port hotplug support

2015-02-26 Thread Tetsuya Mukawa
The patch introduces following commands.
- port attach [ident]
- port detach [port_id]
 - attach: attaching a port
 - detach: detaching a port
 - ident: pci address of physical device.
  Or device name and parameters of virtual device.
 (ex. :02:00.0, eth_pcap0,iface=eth0)
 - port_id: port identifier

v15:
- Replace rte_eal_dev_attach() by rte_eth_dev_attach()
- Replace rte_eal_dev_detach() by rte_eth_dev_detach()

v7:
- Fix doc.
  (Thanks to Iremonger, Bernard)
- Fix port checking implementation of star_port();
  (Thanks to Qiu, Michael)
v5:
- Add testpmd documentation.
  (Thanks to Iremonger, Bernard)
v4:
 - Fix strings of command help.

Signed-off-by: Tetsuya Mukawa 
---
 app/test-pmd/cmdline.c  | 137 +++
 app/test-pmd/config.c   | 102 --
 app/test-pmd/parameters.c   |  22 ++-
 app/test-pmd/testpmd.c  | 199 +---
 app/test-pmd/testpmd.h  |  18 ++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  57 
 6 files changed, 409 insertions(+), 126 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 4c9f423..c8312be 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -513,6 +513,12 @@ static void cmd_help_long_parsed(void *parsed_result,
"port close (port_id|all)\n"
"Close all ports or port_id.\n\n"

+   "port attach (ident)\n"
+   "Attach physical or virtual dev by pci address or 
virtual device name\n\n"
+
+   "port detach (port_id)\n"
+   "Detach physical or virtual dev by port_id\n\n"
+
"port config (port_id|all)"
" speed (10|100|1000|1|4|auto)"
" duplex (half|full|auto)\n"
@@ -793,6 +799,89 @@ cmdline_parse_inst_t cmd_operate_specific_port = {
},
 };

+/* *** attach a specified port *** */
+struct cmd_operate_attach_port_result {
+   cmdline_fixed_string_t port;
+   cmdline_fixed_string_t keyword;
+   cmdline_fixed_string_t identifier;
+};
+
+static void cmd_operate_attach_port_parsed(void *parsed_result,
+   __attribute__((unused)) struct cmdline *cl,
+   __attribute__((unused)) void *data)
+{
+   struct cmd_operate_attach_port_result *res = parsed_result;
+
+   if (!strcmp(res->keyword, "attach"))
+   attach_port(res->identifier);
+   else
+   printf("Unknown parameter\n");
+}
+
+cmdline_parse_token_string_t cmd_operate_attach_port_port =
+   TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
+   port, "port");
+cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
+   TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
+   keyword, "attach");
+cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
+   TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
+   identifier, NULL);
+
+cmdline_parse_inst_t cmd_operate_attach_port = {
+   .f = cmd_operate_attach_port_parsed,
+   .data = NULL,
+   .help_str = "port attach identifier, "
+   "identifier: pci address or virtual dev name",
+   .tokens = {
+   (void *)_operate_attach_port_port,
+   (void *)_operate_attach_port_keyword,
+   (void *)_operate_attach_port_identifier,
+   NULL,
+   },
+};
+
+/* *** detach a specified port *** */
+struct cmd_operate_detach_port_result {
+   cmdline_fixed_string_t port;
+   cmdline_fixed_string_t keyword;
+   uint8_t port_id;
+};
+
+static void cmd_operate_detach_port_parsed(void *parsed_result,
+   __attribute__((unused)) struct cmdline *cl,
+   __attribute__((unused)) void *data)
+{
+   struct cmd_operate_detach_port_result *res = parsed_result;
+
+   if (!strcmp(res->keyword, "detach"))
+   detach_port(res->port_id);
+   else
+   printf("Unknown parameter\n");
+}
+
+cmdline_parse_token_string_t cmd_operate_detach_port_port =
+   TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
+   port, "port");
+cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
+   TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
+   keyword, "detach");
+cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
+   TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
+   port_id, UINT8);
+
+cmdline_parse_inst_t cmd_operate_detach_port = {
+   .f = cmd_operate_detach_port_parsed,
+   .data = NULL,
+   .help_str = "port detach port_id",
+   .tokens = {
+   

[dpdk-dev] [PATCH v15] librte_pmd_pcap: Add port hotplug support

2015-02-26 Thread Tetsuya Mukawa
This patch adds finalization code to free resources allocated by the
PMD.

v6:
 - Fix a paramter of rte_eth_dev_free().
v4:
 - Change function name.

Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_pmd_pcap/rte_eth_pcap.c | 40 ++
 1 file changed, 40 insertions(+)

diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.c 
b/lib/librte_pmd_pcap/rte_eth_pcap.c
index af7fae8..5e94930 100644
--- a/lib/librte_pmd_pcap/rte_eth_pcap.c
+++ b/lib/librte_pmd_pcap/rte_eth_pcap.c
@@ -498,6 +498,13 @@ static struct eth_dev_ops ops = {
.stats_reset = eth_stats_reset,
 };

+static struct eth_driver rte_pcap_pmd = {
+   .pci_drv = {
+   .name = "rte_pcap_pmd",
+   .drv_flags = RTE_PCI_DRV_DETACHABLE,
+   },
+};
+
 /*
  * Function handler that opens the pcap file for reading a stores a
  * reference of it for use it later on.
@@ -713,6 +720,10 @@ rte_pmd_init_internals(const char *name, const unsigned 
nb_rx_queues,
if (*eth_dev == NULL)
goto error;

+   /* check length of device name */
+   if ((strlen((*eth_dev)->data->name) + 1) > sizeof(data->name))
+   goto error;
+
/* now put it all together
 * - store queue data in internals,
 * - store numa_node info in pci_driver
@@ -739,10 +750,13 @@ rte_pmd_init_internals(const char *name, const unsigned 
nb_rx_queues,
data->nb_tx_queues = (uint16_t)nb_tx_queues;
data->dev_link = pmd_link;
data->mac_addrs = _addr;
+   strncpy(data->name,
+   (*eth_dev)->data->name, strlen((*eth_dev)->data->name));

(*eth_dev)->data = data;
(*eth_dev)->dev_ops = 
(*eth_dev)->pci_dev = pci_dev;
+   (*eth_dev)->driver = _pcap_pmd;

return 0;

@@ -927,10 +941,36 @@ rte_pmd_pcap_devinit(const char *name, const char *params)

 }

+static int
+rte_pmd_pcap_devuninit(const char *name)
+{
+   struct rte_eth_dev *eth_dev = NULL;
+
+   RTE_LOG(INFO, PMD, "Closing pcap ethdev on numa socket %u\n",
+   rte_socket_id());
+
+   if (name == NULL)
+   return -1;
+
+   /* reserve an ethdev entry */
+   eth_dev = rte_eth_dev_allocated(name);
+   if (eth_dev == NULL)
+   return -1;
+
+   rte_free(eth_dev->data->dev_private);
+   rte_free(eth_dev->data);
+   rte_free(eth_dev->pci_dev);
+
+   rte_eth_dev_release_port(eth_dev);
+
+   return 0;
+}
+
 static struct rte_driver pmd_pcap_drv = {
.name = "eth_pcap",
.type = PMD_VDEV,
.init = rte_pmd_pcap_devinit,
+   .uninit = rte_pmd_pcap_devuninit,
 };

 PMD_REGISTER_DRIVER(pmd_pcap_drv);
-- 
1.9.1



[dpdk-dev] [PATCH v15 13/13] doc: Add port hotplug framework section to programmers guide

2015-02-26 Thread Tetsuya Mukawa
This patch adds a new section for describing port hotplug framework.

v15:
- Fix function names like below.
 - rte_eal_dev_attach() to rte_eth_dev_attach().
 - rte_eal_dev_detach() to rte_eth_dev_detach().

Signed-off-by: Tetsuya Mukawa 
---
 doc/guides/prog_guide/index.rst  |   1 +
 doc/guides/prog_guide/port_hotplug_framework.rst | 110 +++
 2 files changed, 111 insertions(+)
 create mode 100644 doc/guides/prog_guide/port_hotplug_framework.rst

diff --git a/doc/guides/prog_guide/index.rst b/doc/guides/prog_guide/index.rst
index de69682..60a6ac5 100644
--- a/doc/guides/prog_guide/index.rst
+++ b/doc/guides/prog_guide/index.rst
@@ -71,6 +71,7 @@ Programmer's Guide
 packet_classif_access_ctrl
 packet_framework
 vhost_lib
+port_hotplug_framework
 source_org
 dev_kit_build_system
 dev_kit_root_make_help
diff --git a/doc/guides/prog_guide/port_hotplug_framework.rst 
b/doc/guides/prog_guide/port_hotplug_framework.rst
new file mode 100644
index 000..fe6d72a
--- /dev/null
+++ b/doc/guides/prog_guide/port_hotplug_framework.rst
@@ -0,0 +1,110 @@
+..  BSD LICENSE
+Copyright(c) 2015 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.
+
+Port Hotplug Framework
+==
+
+The Port Hotplug Framework provides DPDK applications with the ability to
+attach and detach ports at runtime. Because the framework depends on PMD
+implementation, the ports that PMDs cannot handle are out of scope of this
+framework. Furthermore, after detaching a port from a DPDK application, the
+framework doesn't provide a way for removing the devices from the system.
+For the ports backed by a physical NIC, the kernel will need to support PCI
+Hotplug feature.
+
+Overview
+
+
+The basic requirements of the Port Hotplug Framework are:
+
+*   DPDK applications that use the Port Hotplug Framework must manage their
+own ports.
+
+The Port Hotplug Framework is implemented to allow DPDK applications to
+manage ports. For example, when DPDK applications call the port attach
+function, the attached port number is returned. DPDK applications can
+also detach the port by port number.
+
+*   Kernel support is needed for attaching or detaching physical device
+ports.
+
+To attach new physical device ports, the device will be recognized by
+userspace driver I/O framework in kernel at first. Then DPDK
+applications can call the Port Hotplug functions to attach the ports.
+For detaching, steps are vice versa.
+
+*   Before detaching, they must be stopped and closed.
+
+DPDK applications must call "rte_eth_dev_stop()" and
+"rte_eth_dev_close()" APIs before detaching ports. These functions will
+start finalization sequence of the PMDs.
+
+*   The framework doesn't affect legacy DPDK applications behavior.
+
+If the Port Hotplug functions aren't called, all legacy DPDK apps can
+still work without modifications.
+
+Port Hotplug API overview
+-
+
+*   Attaching a port
+
+"rte_eth_dev_attach()" API attaches a port to DPDK application, and
+returns the attached port number. Before calling the API, the device
+should be recognized by an userspace driver I/O framework. The API
+receives a pci address like ":01:00.0" or a virtual device name
+like 

[dpdk-dev] [PATCH v15 12/13] ethdev: Add rte_eth_dev_attach/detach() functions

2015-02-26 Thread Tetsuya Mukawa
These functions are used for attaching or detaching a port.
When rte_eth_dev_attach() is called, the function tries to realize the
device name as pci address. If this is done successfully,
rte_eth_dev_attach() will attach physical device port. If not, attaches
virtual devive port.
When rte_eth_dev_detach() is called, the function gets the device type
of this port to know whether the port is come from physical or virtual.
And then specific detaching function will be called.

v15:
- Fix issue that eal calls ethedv library APIs.
 - Remove rte_eal_dev_attach(), and add rte_eth_dev_attach().
 - Remove rte_eal_dev_detach(), and add rte_eth_dev_detach().
 - Call rte_eal_vdev_init/uninit from ethdev library.
  (Thanks to Thomas Monjalon)
- Fix version.map
- Squash below patch to compile.
 - ethdev: Add functions that will be used by port hotplug functions

v14:
- Remove needless if statement.
  (Thanks to Maxime Leroy)
v13:
- Change log level when error occurs in rte_eal_vdev_init() and
  rte_eal_dev_init().
- Return value of driver init and uninit functions.
- Replace rte_panic by RTE_LOG in rte_eal_dev_init()
- Fix return value of rte_eal_vdev_uninit().
- Fix rte_eal_dev_attach_vdev to set port_id correctly.
  (Thanks to Maxime Leroy)
v11:
- Remove needless devargs handling codes.
- Replace get_vdev_name() by rte_eal_parse_devargs_str().
- Replace rte_eal_vdev_find_and_init by rte_eal_vdev_init()
- Replace rte_eal_vdev_find_and_uninit by rte_eal_vdev_uninit()
- Fix rte_eal_dev_init() to use rte_eal_vdev_init().
  (Thanks to Maxime Leroy)
v10:
- Add comments.
- Change order of version.map.
  (Thanks to Thomas Monjalon)
v9:
- Fix comments.
- Use strcmp() instead of strncmp().
- Remove RTE_EAL_INVOKE_TYPE_PROBE/CLOSE.
- Change definition of rte_dev_uninit_t.
  (Thanks to Thomas Monjalon and Maxime Leroy)
v8:
- Add missing symbol in version map.
  (Thanks to Qiu, Michael and Iremonger, Bernard)
v7:
- Fix typo of warning messages.
  (Thanks to Qiu, Michael)
v5:
- Change function names like below.
  rte_eal_dev_find_and_invoke() to rte_eal_vdev_find_and_invoke().
  rte_eal_dev_invoke() to rte_eal_vdev_invoke().
- Add code to handle a return value of rte_eal_devargs_remove().
- Fix pci address format in rte_eal_dev_detach().
v4:
- Fix comment.
- Add error checking.
- Fix indent of 'if' statement.
- Change function name.

Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_eal/common/include/rte_pci.h |   9 +
 lib/librte_eal/linuxapp/eal/eal_pci.c   |   6 +-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   1 +
 lib/librte_ether/rte_ethdev.c   | 303 +++-
 lib/librte_ether/rte_ethdev.h   |  38 +++
 lib/librte_ether/rte_ether_version.map  |   3 +
 6 files changed, 355 insertions(+), 5 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_pci.h 
b/lib/librte_eal/common/include/rte_pci.h
index ac30925..b9cdf8b 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -313,6 +313,15 @@ rte_eal_compare_pci_addr(struct rte_pci_addr *addr, struct 
rte_pci_addr *addr2)
 }

 /**
+ * Scan the content of the PCI bus, and the devices in the devices
+ * list
+ *
+ * @return
+ *  0 on success, negative on error
+ */
+int rte_eal_pci_scan(void);
+
+/**
  * Probe the PCI bus for registered drivers.
  *
  * Scan the content of the PCI bus, and call the probe() function for
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index f880f90..6d4932d 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -440,8 +440,8 @@ error:
  * Scan the content of the PCI bus, and the devices in the devices
  * list
  */
-static int
-pci_scan(void)
+int
+rte_eal_pci_scan(void)
 {
struct dirent *e;
DIR *dir;
@@ -773,7 +773,7 @@ rte_eal_pci_init(void)
if (internal_config.no_pci)
return 0;

-   if (pci_scan() < 0) {
+   if (rte_eal_pci_scan() < 0) {
RTE_LOG(ERR, EAL, "%s(): Cannot scan PCI bus\n", __func__);
return -1;
}
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map 
b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index 214643d..7c2aac3 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -45,6 +45,7 @@ DPDK_2.0 {
rte_eal_pci_probe_one;
rte_eal_pci_register;
rte_eal_pci_unregister;
+   rte_eal_pci_scan;
rte_eal_process_type;
rte_eal_remote_launch;
rte_eal_tailq_lookup;
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index b07f2df..868289c 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -201,7 +201,7 @@ rte_eth_dev_data_alloc(void)
RTE_MAX_ETHPORTS * sizeof(*rte_eth_dev_data));
 }

-static struct rte_eth_dev *
+struct rte_eth_dev *
 

[dpdk-dev] [PATCH v15 11/13] eal/pci: Add vdev driver initialization and uninitialization functions

2015-02-26 Thread Tetsuya Mukawa
The patch adds following functions.
- rte_eal_vdev_init();
- rte_eal_vdev_uninit();
- rte_eal_parse_devargs_str().
These functions are used for driver initialization and finalization.

v15:
- Add this patch to hotplug series.

Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_eal/common/eal_common_dev.c  | 77 -
 lib/librte_eal/common/eal_common_devargs.c  | 54 +++--
 lib/librte_eal/common/include/rte_dev.h | 28 +
 lib/librte_eal/common/include/rte_devargs.h | 28 +
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  3 +
 5 files changed, 155 insertions(+), 35 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_dev.c 
b/lib/librte_eal/common/eal_common_dev.c
index eae5656..92a5a94 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -32,6 +32,7 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */

+#include 
 #include 
 #include 
 #include 
@@ -40,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "eal_private.h"

@@ -62,6 +64,32 @@ rte_eal_driver_unregister(struct rte_driver *driver)
 }

 int
+rte_eal_vdev_init(const char *name, const char *args)
+{
+   struct rte_driver *driver;
+
+   if (name == NULL)
+   return -EINVAL;
+
+   TAILQ_FOREACH(driver, _driver_list, next) {
+   if (driver->type != PMD_VDEV)
+   continue;
+
+   /*
+* search a driver prefix in virtual device name.
+* For example, if the driver is pcap PMD, driver->name
+* will be "eth_pcap", but "name" will be "eth_pcapN".
+* So use strncmp to compare.
+*/
+   if (!strncmp(driver->name, name, strlen(driver->name)))
+   return driver->init(name, args);
+   }
+
+   RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
+   return -EINVAL;
+}
+
+int
 rte_eal_dev_init(void)
 {
struct rte_devargs *devargs;
@@ -79,22 +107,11 @@ rte_eal_dev_init(void)
if (devargs->type != RTE_DEVTYPE_VIRTUAL)
continue;

-   TAILQ_FOREACH(driver, _driver_list, next) {
-   if (driver->type != PMD_VDEV)
-   continue;
-
-   /* search a driver prefix in virtual device name */
-   if (!strncmp(driver->name, devargs->virtual.drv_name,
-   strlen(driver->name))) {
-   driver->init(devargs->virtual.drv_name,
-   devargs->args);
-   break;
-   }
-   }
-
-   if (driver == NULL) {
-   rte_panic("no driver found for %s\n",
- devargs->virtual.drv_name);
+   if (rte_eal_vdev_init(devargs->virtual.drv_name,
+   devargs->args)) {
+   RTE_LOG(ERR, EAL, "failed to initialize %s device\n",
+   devargs->virtual.drv_name);
+   return -1;
}
}

@@ -107,3 +124,31 @@ rte_eal_dev_init(void)
}
return 0;
 }
+
+#ifdef RTE_LIBRTE_EAL_HOTPLUG
+int
+rte_eal_vdev_uninit(const char *name)
+{
+   struct rte_driver *driver;
+
+   if (name == NULL)
+   return -EINVAL;
+
+   TAILQ_FOREACH(driver, _driver_list, next) {
+   if (driver->type != PMD_VDEV)
+   continue;
+
+   /*
+* search a driver prefix in virtual device name.
+* For example, if the driver is pcap PMD, driver->name
+* will be "eth_pcap", but "name" will be "eth_pcapN".
+* So use strncmp to compare.
+*/
+   if (!strncmp(driver->name, name, strlen(driver->name)))
+   return driver->uninit(name);
+   }
+
+   RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
+   return -EINVAL;
+}
+#endif /* RTE_LIBRTE_EAL_HOTPLUG */
diff --git a/lib/librte_eal/common/eal_common_devargs.c 
b/lib/librte_eal/common/eal_common_devargs.c
index eadd719..9b110f7 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -44,13 +44,46 @@
 struct rte_devargs_list devargs_list =
TAILQ_HEAD_INITIALIZER(devargs_list);

+int
+rte_eal_parse_devargs_str(const char *devargs_str,
+   char **drvname, char **drvargs)
+{
+   char *sep;
+
+   if ((devargs_str) == NULL || (drvname) == NULL || (drvargs == NULL))
+   return -1;
+
+   *drvname = strdup(devargs_str);
+   if (drvname == NULL) {
+   RTE_LOG(ERR, EAL,
+   "cannot allocate temp memory for driver name\n");
+

[dpdk-dev] [PATCH v15 10/13] ethdev: Add one dev_type parameter to rte_eth_dev_allocate

2015-02-26 Thread Tetsuya Mukawa
This new parameter is needed to keep device type like PCI or virtual.
Port detaching processes are different between PCI device and virtual
device.
RTE_ETH_DEV_PCI indicates device type is PCI. RTE_ETH_DEV_VIRTUAL
indicates device is virtual.

v15:
- Remove needless symbols in version.map
- Move rte_eth_dev_get_device_type() to later patch to compile
  correctly.

v12:
- Add missing symbol in version map.
  (Thanks to Iremonger, Bernard)
v10:
- Change order of version.map.
  (Thanks to Thomas Monjalon)
- Fix comment of "rte_ethdev.h".
  (Thanks to Thomas Monjalon)
v9:
- Fix commit log.
- RTE_ETH_DEV_PHYSICAL is replaced by RTE_ETH_DEV_PCI.
  (Thanks to Thomas Monjalon)
v8:
- NONE_TRACE is replaced by NO_TRACE.
- Add missing symbol in version map.
  (Thanks to Qiu, Michael and Iremonger, Bernard)
v4:
- Fix comments of rte_eth_dev_type.

Signed-off-by: Tetsuya Mukawa 
---
 app/test/virtual_pmd.c   |  2 +-
 lib/librte_ether/rte_ethdev.c|  5 +++--
 lib/librte_ether/rte_ethdev.h| 16 +++-
 lib/librte_pmd_af_packet/rte_eth_af_packet.c |  2 +-
 lib/librte_pmd_bond/rte_eth_bond_api.c   |  2 +-
 lib/librte_pmd_pcap/rte_eth_pcap.c   |  2 +-
 lib/librte_pmd_ring/rte_eth_ring.c   |  2 +-
 lib/librte_pmd_xenvirt/rte_eth_xenvirt.c |  2 +-
 8 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index 785bccc..9b07ab1 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -580,7 +580,7 @@ virtual_ethdev_create(const char *name, struct ether_addr 
*mac_addr,
goto err;

/* reserve an ethdev entry */
-   eth_dev = rte_eth_dev_allocate(name);
+   eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
if (eth_dev == NULL)
goto err;

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 0ca7147..b07f2df 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -227,7 +227,7 @@ rte_eth_dev_find_free_port(void)
 }

 struct rte_eth_dev *
-rte_eth_dev_allocate(const char *name)
+rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)
 {
uint8_t port_id;
struct rte_eth_dev *eth_dev;
@@ -251,6 +251,7 @@ rte_eth_dev_allocate(const char *name)
snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
eth_dev->data->port_id = port_id;
eth_dev->attached = DEV_ATTACHED;
+   eth_dev->dev_type = type;
nb_ports++;
return eth_dev;
 }
@@ -300,7 +301,7 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,
rte_eth_dev_create_unique_device_name(ethdev_name,
sizeof(ethdev_name), pci_dev);

-   eth_dev = rte_eth_dev_allocate(ethdev_name);
+   eth_dev = rte_eth_dev_allocate(ethdev_name, RTE_ETH_DEV_PCI);
if (eth_dev == NULL)
return -ENOMEM;

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 37c3765..50c2dce 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1422,6 +1422,17 @@ struct rte_eth_rxtx_callback {
void *param;
 };

+/*
+ * The eth device type
+ */
+enum rte_eth_dev_type {
+   RTE_ETH_DEV_UNKNOWN,/**< unknown device type */
+   RTE_ETH_DEV_PCI,
+   /**< Physical function and Virtual function of PCI devices */
+   RTE_ETH_DEV_VIRTUAL,/**< non hardware device */
+   RTE_ETH_DEV_MAX /**< max value of this enum */
+};
+
 /**
  * @internal
  * The generic data structure associated with each ethernet device.
@@ -1452,6 +1463,7 @@ struct rte_eth_dev {
 */
struct rte_eth_rxtx_callback **pre_tx_burst_cbs;
uint8_t attached; /**< Flag indicating the port is attached */
+   enum rte_eth_dev_type dev_type; /**< Flag indicating the device type */
 };

 struct rte_eth_dev_sriov {
@@ -1534,10 +1546,12 @@ extern uint8_t rte_eth_dev_count(void);
  * to that slot for the driver to use.
  *
  * @param  nameUnique identifier name for each Ethernet device
+ * @param  typeDevice type of this Ethernet device
  * @return
  *   - Slot in the rte_dev_devices array for a new device;
  */
-struct rte_eth_dev *rte_eth_dev_allocate(const char *name);
+struct rte_eth_dev *rte_eth_dev_allocate(const char *name,
+   enum rte_eth_dev_type type);

 /**
  * Function for internal use by dummy drivers primarily, e.g. ring-based
diff --git a/lib/librte_pmd_af_packet/rte_eth_af_packet.c 
b/lib/librte_pmd_af_packet/rte_eth_af_packet.c
index 1ffe1cd..80e9bdf 100644
--- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c
+++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c
@@ -649,7 +649,7 @@ rte_pmd_init_internals(const char *name,
}

/* reserve an ethdev entry */
-   *eth_dev = rte_eth_dev_allocate(name);
+   *eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
if (*eth_dev == 

[dpdk-dev] [PATCH v15 09/13] eal/pci: Add probe and close functions of pci driver

2015-02-26 Thread Tetsuya Mukawa
- Add pci_close_all_drivers()
  The function tries to find a driver for the specified device, and
  then close the driver.
- Add rte_eal_pci_probe_one() and rte_eal_pci_close_one()
  The functions are used for probe and close a device.
  First the function tries to find a device that has the specified
  PCI address. Then, probe or close the device.

v15:
- Fix version.map.
v9:
- Fix commit title.
- Remove RTE_EAL_INVOKE_TYPE_PROBE/CLOSE.
  (Thanks to Thomas Monjalon)
- Implement pci_unmap_device() in this patch.
v5:
- Remove RTE_EAL_INVOKE_TYPE_UNKNOWN, because it's unused.
v4:
- Fix parameter checking.
- Fix indent of 'if' statement.

Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_eal/common/eal_common_pci.c  | 98 -
 lib/librte_eal/common/eal_private.h | 15 
 lib/librte_eal/common/include/rte_pci.h | 32 
 lib/librte_eal/linuxapp/eal/eal_pci.c   | 94 
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  2 +
 lib/librte_ether/rte_ethdev.c   |  6 +-
 6 files changed, 243 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_pci.c 
b/lib/librte_eal/common/eal_common_pci.c
index bf2793f..5b6b55d 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -108,7 +108,10 @@ static int
 pci_probe_all_drivers(struct rte_pci_device *dev)
 {
struct rte_pci_driver *dr = NULL;
-   int rc;
+   int rc = 0;
+
+   if (dev == NULL)
+   return -1;

TAILQ_FOREACH(dr, _driver_list, next) {
rc = rte_eal_pci_probe_one_driver(dr, dev);
@@ -123,6 +126,99 @@ pci_probe_all_drivers(struct rte_pci_device *dev)
return 1;
 }

+#ifdef RTE_LIBRTE_EAL_HOTPLUG
+/*
+ * If vendor/device ID match, call the devuninit() function of all
+ * registered driver for the given device. Return -1 if initialization
+ * failed, return 1 if no driver is found for this device.
+ */
+static int
+pci_close_all_drivers(struct rte_pci_device *dev)
+{
+   struct rte_pci_driver *dr = NULL;
+   int rc = 0;
+
+   if (dev == NULL)
+   return -1;
+
+   TAILQ_FOREACH(dr, _driver_list, next) {
+   rc = rte_eal_pci_close_one_driver(dr, dev);
+   if (rc < 0)
+   /* negative value is an error */
+   return -1;
+   if (rc > 0)
+   /* positive value means driver not found */
+   continue;
+   return 0;
+   }
+   return 1;
+}
+
+/*
+ * Find the pci device specified by pci address, then invoke probe function of
+ * the driver of the devive.
+ */
+int
+rte_eal_pci_probe_one(struct rte_pci_addr *addr)
+{
+   struct rte_pci_device *dev = NULL;
+   int ret = 0;
+
+   if (addr == NULL)
+   return -1;
+
+   TAILQ_FOREACH(dev, _device_list, next) {
+   if (rte_eal_compare_pci_addr(>addr, addr))
+   continue;
+
+   ret = pci_probe_all_drivers(dev);
+   if (ret < 0)
+   goto err_return;
+   return 0;
+   }
+   return -1;
+
+err_return:
+   RTE_LOG(WARNING, EAL, "Requested device " PCI_PRI_FMT
+   " cannot be used\n", dev->addr.domain, dev->addr.bus,
+   dev->addr.devid, dev->addr.function);
+   return -1;
+}
+
+/*
+ * Find the pci device specified by pci address, then invoke close function of
+ * the driver of the devive.
+ */
+int
+rte_eal_pci_close_one(struct rte_pci_addr *addr)
+{
+   struct rte_pci_device *dev = NULL;
+   int ret = 0;
+
+   if (addr == NULL)
+   return -1;
+
+   TAILQ_FOREACH(dev, _device_list, next) {
+   if (rte_eal_compare_pci_addr(>addr, addr))
+   continue;
+
+   ret = pci_close_all_drivers(dev);
+   if (ret < 0)
+   goto err_return;
+
+   TAILQ_REMOVE(_device_list, dev, next);
+   return 0;
+   }
+   return -1;
+
+err_return:
+   RTE_LOG(WARNING, EAL, "Requested device " PCI_PRI_FMT
+   " cannot be used\n", dev->addr.domain, dev->addr.bus,
+   dev->addr.devid, dev->addr.function);
+   return -1;
+}
+#endif /* RTE_LIBRTE_EAL_HOTPLUG */
+
 /*
  * Scan the content of the PCI bus, and call the devinit() function for
  * all registered drivers that have a matching entry in its id_table
diff --git a/lib/librte_eal/common/eal_private.h 
b/lib/librte_eal/common/eal_private.h
index 159cd66..4acf5a0 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -165,6 +165,21 @@ int rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr,
struct rte_pci_device *dev);

 /**
+ * Munmap memory for single PCI device
+ *
+ * This function is private to EAL.
+ *
+ * @param  dr
+ 

[dpdk-dev] [PATCH v15 08/13] eal/linux/pci: Add functions for unmapping igb_uio resources

2015-02-26 Thread Tetsuya Mukawa
The patch adds functions for unmapping igb_uio resources. The patch is only
for Linux and igb_uio environment. VFIO and BSD are not supported.

v9:
- Remove "rte_dev_hotplug.h".
- Remove needless "#ifdef".
  (Thanks to Thomas Monjalon and Neil Horman)
- Remove pci_unmap_device(). It will be implemented in later patch.
v8:
- Fix typo.
  (Thanks to Iremonger, Bernard)
v5:
- Fix pci_unmap_device() to check pt_driver.
v4:
- Add parameter checking.
- Add header file to determine if hotplug can be enabled.

Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_eal/linuxapp/eal/eal_pci.c  | 17 
 lib/librte_eal/linuxapp/eal/eal_pci_init.h |  7 
 lib/librte_eal/linuxapp/eal/eal_pci_uio.c  | 65 ++
 3 files changed, 89 insertions(+)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index 06bfc1a..d03429c 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -168,6 +168,23 @@ pci_map_resource(void *requested_addr, int fd, off_t 
offset, size_t size,
return mapaddr;
 }

+/* unmap a particular resource */
+void
+pci_unmap_resource(void *requested_addr, size_t size)
+{
+   if (requested_addr == NULL)
+   return;
+
+   /* Unmap the PCI memory resource of device */
+   if (munmap(requested_addr, size)) {
+   RTE_LOG(ERR, EAL, "%s(): cannot munmap(%p, 0x%lx): %s\n",
+   __func__, requested_addr, (unsigned long)size,
+   strerror(errno));
+   } else
+   RTE_LOG(DEBUG, EAL, "  PCI memory unmapped at %p\n",
+   requested_addr);
+}
+
 /* parse the "resource" sysfs file */
 static int
 pci_parse_sysfs_resource(const char *filename, struct rte_pci_device *dev)
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_init.h 
b/lib/librte_eal/linuxapp/eal/eal_pci_init.h
index 03d2b52..6af84d1 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_init.h
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_init.h
@@ -72,6 +72,13 @@ void *pci_map_resource(void *requested_addr, int fd, off_t 
offset,
 /* map IGB_UIO resource prototype */
 int pci_uio_map_resource(struct rte_pci_device *dev);

+void pci_unmap_resource(void *requested_addr, size_t size);
+
+#ifdef RTE_LIBRTE_EAL_HOTPLUG
+/* unmap IGB_UIO resource prototype */
+void pci_uio_unmap_resource(struct rte_pci_device *dev);
+#endif /* RTE_LIBRTE_EAL_HOTPLUG */
+
 #ifdef VFIO_PRESENT

 #define VFIO_MAX_GROUPS 64
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c 
b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
index c5e0cf3..35d31c5 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
@@ -386,3 +386,68 @@ pci_uio_map_resource(struct rte_pci_device *dev)

return 0;
 }
+
+#ifdef RTE_LIBRTE_EAL_HOTPLUG
+static void
+pci_uio_unmap(struct mapped_pci_resource *uio_res)
+{
+   int i;
+
+   if (uio_res == NULL)
+   return;
+
+   for (i = 0; i != uio_res->nb_maps; i++)
+   pci_unmap_resource(uio_res->maps[i].addr,
+   (size_t)uio_res->maps[i].size);
+}
+
+static struct mapped_pci_resource *
+pci_uio_find_resource(struct rte_pci_device *dev)
+{
+   struct mapped_pci_resource *uio_res;
+
+   if (dev == NULL)
+   return NULL;
+
+   TAILQ_FOREACH(uio_res, pci_res_list, next) {
+
+   /* skip this element if it doesn't match our PCI address */
+   if (!rte_eal_compare_pci_addr(_res->pci_addr, >addr))
+   return uio_res;
+   }
+   return NULL;
+}
+
+/* unmap the PCI resource of a PCI device in virtual memory */
+void
+pci_uio_unmap_resource(struct rte_pci_device *dev)
+{
+   struct mapped_pci_resource *uio_res;
+
+   if (dev == NULL)
+   return;
+
+   /* find an entry for the device */
+   uio_res = pci_uio_find_resource(dev);
+   if (uio_res == NULL)
+   return;
+
+   /* secondary processes - just free maps */
+   if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+   return pci_uio_unmap(uio_res);
+
+   TAILQ_REMOVE(pci_res_list, uio_res, next);
+
+   /* unmap all resources */
+   pci_uio_unmap(uio_res);
+
+   /* free uio resource */
+   rte_free(uio_res);
+
+   /* close fd if in primary process */
+   close(dev->intr_handle.fd);
+
+   dev->intr_handle.fd = -1;
+   dev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;
+}
+#endif /* RTE_LIBRTE_EAL_HOTPLUG */
-- 
1.9.1



[dpdk-dev] [PATCH v15 05/13] eal/pci: Consolidate pci address comparison APIs

2015-02-26 Thread Tetsuya Mukawa
This patch replaces pci_addr_comparison() and memcmp() of pci addresses by
rte_eal_compare_pci_addr().

To compare PCI addresses, rte_eal_compare_pci_addr() doesn't use memcmp().
This is because sizeof(struct rte_pci_addr) returns 6, but actually
this structure is like below.

struct rte_pci_addr {
uint16_t domain;/**< Device domain */
uint8_t bus;/**< Device bus */
uint8_t devid;  /**< Device ID */
uint8_t function;   /**< Device function. */
};

If the structure is dynamically allocated in a function without bzero,
last 1 byte may have value. As a result, memcmp may not work.
To avoid such a case, rte_eal_compare_pci_addr() compare following values.

dev_addr = (addr->domain << 24) | (addr->bus << 16) |
(addr->devid << 8) | addr->function;

v9:
- eal_compare_pci_addr() is replaced by rte_eal_compare_pci_addr().
- Fix commit log.
  (Thanks to Thomas Monjalon)
v8:
- Fix pci_scan_one() to update sysfs values.
  (Thanks to Qiu, Michael and Iremonger, Bernard)
v5:
- Fix pci_scan_one to handle pt_driver correctly.
v4:
- Fix calculation method of eal_compare_pci_addr().
- Add parameter checking.

Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_eal/bsdapp/eal/eal_pci.c   | 29 --
 lib/librte_eal/common/eal_common_pci.c|  2 +-
 lib/librte_eal/common/include/rte_pci.h   | 34 +++
 lib/librte_eal/linuxapp/eal/eal_pci.c | 30 +--
 lib/librte_eal/linuxapp/eal/eal_pci_uio.c |  2 +-
 5 files changed, 63 insertions(+), 34 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c 
b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 74ecce7..9193f80 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -270,20 +270,6 @@ pci_uio_map_resource(struct rte_pci_device *dev)
return (0);
 }

-/* Compare two PCI device addresses. */
-static int
-pci_addr_comparison(struct rte_pci_addr *addr, struct rte_pci_addr *addr2)
-{
-   uint64_t dev_addr = (addr->domain << 24) + (addr->bus << 16) + 
(addr->devid << 8) + addr->function;
-   uint64_t dev_addr2 = (addr2->domain << 24) + (addr2->bus << 16) + 
(addr2->devid << 8) + addr2->function;
-
-   if (dev_addr > dev_addr2)
-   return 1;
-   else
-   return 0;
-}
-
-
 /* Scan one pci sysfs entry, and fill the devices list from it. */
 static int
 pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
@@ -356,13 +342,24 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
}
else {
struct rte_pci_device *dev2 = NULL;
+   int ret;

TAILQ_FOREACH(dev2, _device_list, next) {
-   if (pci_addr_comparison(>addr, >addr))
+   ret = rte_eal_compare_pci_addr(>addr, >addr);
+   if (ret > 0)
continue;
-   else {
+   else if (ret < 0) {
TAILQ_INSERT_BEFORE(dev2, dev, next);
return 0;
+   } else { /* already registered */
+   /* update pt_driver */
+   dev2->pt_driver = dev->pt_driver;
+   dev2->max_vfs = dev->max_vfs;
+   memmove(dev2->mem_resource,
+   dev->mem_resource,
+   sizeof(dev->mem_resource));
+   free(dev);
+   return 0;
}
}
TAILQ_INSERT_TAIL(_device_list, dev, next);
diff --git a/lib/librte_eal/common/eal_common_pci.c 
b/lib/librte_eal/common/eal_common_pci.c
index f3c7f71..bf2793f 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -93,7 +93,7 @@ static struct rte_devargs *pci_devargs_lookup(struct 
rte_pci_device *dev)
if (devargs->type != RTE_DEVTYPE_BLACKLISTED_PCI &&
devargs->type != RTE_DEVTYPE_WHITELISTED_PCI)
continue;
-   if (!memcmp(>addr, >pci.addr, sizeof(dev->addr)))
+   if (!rte_eal_compare_pci_addr(>addr, >pci.addr))
return devargs;
}
return NULL;
diff --git a/lib/librte_eal/common/include/rte_pci.h 
b/lib/librte_eal/common/include/rte_pci.h
index 255a77b..dcf9c81 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -272,6 +272,40 @@ eal_parse_pci_DomBDF(const char *input, struct 
rte_pci_addr *dev_addr)
 }
 #undef GET_PCIADDR_FIELD

+/* Compare two PCI device addresses. */
+/**
+ * Utility function to compare two PCI device addresses.
+ *
+ * @param addr
+ * The PCI Bus-Device-Function address 

[dpdk-dev] [PATCH v15 04/13] eal/pci, ethdev: Remove assumption that port will not be detached

2015-02-26 Thread Tetsuya Mukawa
To remove assumption, do like followings.

This patch adds "RTE_PCI_DRV_DETACHABLE" to drv_flags of rte_pci_driver
structure. The flags indicate the driver can detach devices at runtime.
Also, remove assumption that port will not be detached.

To remove the assumption.
- Add 'attached' member to rte_eth_dev structure.
  This member is used for indicating the port is attached, or not.
  DEV_ATTACHED indicates a port is attached.
  DEV_DETACHED indicates a port is detached.
- Add rte_eth_dev_allocate_new_port().
  This function is used for allocating new port.

v9:
- DEV_INVALID/VALID are removed.
- DEV_DISCONNECTED is replaced by DEV_DETACHED.
- DEV_CONNECTED is replaced by DEV_ATTACHED.
- rte_eth_dev_allocate_new_port() is renamed to
  rte_eth_dev_find_free_port().
- rte_eth_dev_validate_port() is renamed to rte_eth_dev_is_valid_port().
- rte_eth_dev_is_valid_port() is changed not to handle log toggle.
- Fix commit log to describe DEV_ATACHED and DEV_DETACHED.
  (Thanks to Thomas Monjalon)
v8:
- NONE_TRACE is changed to NO_TRACE.
  (Thanks to Iremonger, Bernard)
v5:
- Change parameters of rte_eth_dev_validate_port() to cleanup code.
v4:
- Use braces with 'for' loop.
- Fix indent of 'if' statement.

Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_eal/common/include/rte_pci.h |   2 +
 lib/librte_ether/rte_ethdev.c   | 248 
 lib/librte_ether/rte_ethdev.h   |   5 +
 3 files changed, 164 insertions(+), 91 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_pci.h 
b/lib/librte_eal/common/include/rte_pci.h
index a87b4b3..255a77b 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -210,6 +210,8 @@ struct rte_pci_driver {
 #define RTE_PCI_DRV_FORCE_UNBIND 0x0004
 /** Device driver supports link state interrupt */
 #define RTE_PCI_DRV_INTR_LSC   0x0008
+/** Device driver supports detaching capability */
+#define RTE_PCI_DRV_DETACHABLE 0x0010

 /**< Internal use only - Macro used by pci addr parsing functions **/
 #define GET_PCIADDR_FIELD(in, fd, lim, dlm)   \
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index ecbe93c..b702039 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -175,6 +175,11 @@ enum {
STAT_QMAP_RX
 };

+enum {
+   DEV_DETACHED = 0,
+   DEV_ATTACHED
+};
+
 static inline void
 rte_eth_dev_data_alloc(void)
 {
@@ -201,19 +206,34 @@ rte_eth_dev_allocated(const char *name)
 {
unsigned i;

-   for (i = 0; i < nb_ports; i++) {
-   if (strcmp(rte_eth_devices[i].data->name, name) == 0)
+   for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
+   if ((rte_eth_devices[i].attached == DEV_ATTACHED) &&
+   strcmp(rte_eth_devices[i].data->name, name) == 0)
return _eth_devices[i];
}
return NULL;
 }

+static uint8_t
+rte_eth_dev_find_free_port(void)
+{
+   unsigned i;
+
+   for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
+   if (rte_eth_devices[i].attached == DEV_DETACHED)
+   return i;
+   }
+   return RTE_MAX_ETHPORTS;
+}
+
 struct rte_eth_dev *
 rte_eth_dev_allocate(const char *name)
 {
+   uint8_t port_id;
struct rte_eth_dev *eth_dev;

-   if (nb_ports == RTE_MAX_ETHPORTS) {
+   port_id = rte_eth_dev_find_free_port();
+   if (port_id == RTE_MAX_ETHPORTS) {
PMD_DEBUG_TRACE("Reached maximum number of Ethernet ports\n");
return NULL;
}
@@ -226,10 +246,12 @@ rte_eth_dev_allocate(const char *name)
return NULL;
}

-   eth_dev = _eth_devices[nb_ports];
-   eth_dev->data = _eth_dev_data[nb_ports];
+   eth_dev = _eth_devices[port_id];
+   eth_dev->data = _eth_dev_data[port_id];
snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
-   eth_dev->data->port_id = nb_ports++;
+   eth_dev->data->port_id = port_id;
+   eth_dev->attached = DEV_ATTACHED;
+   nb_ports++;
return eth_dev;
 }

@@ -283,6 +305,7 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,
(unsigned) pci_dev->id.device_id);
if (rte_eal_process_type() == RTE_PROC_PRIMARY)
rte_free(eth_dev->data->dev_private);
+   eth_dev->attached = DEV_DETACHED;
nb_ports--;
return diag;
 }
@@ -308,10 +331,20 @@ rte_eth_driver_register(struct eth_driver *eth_drv)
rte_eal_pci_register(_drv->pci_drv);
 }

+static int
+rte_eth_dev_is_valid_port(uint8_t port_id)
+{
+   if (port_id >= RTE_MAX_ETHPORTS ||
+   rte_eth_devices[port_id].attached != DEV_ATTACHED)
+   return 0;
+   else
+   return 1;
+}
+
 int
 rte_eth_dev_socket_id(uint8_t port_id)
 {
-   if (port_id >= nb_ports)
+   if (!rte_eth_dev_is_valid_port(port_id))
return -1;
return 

[dpdk-dev] [PATCH v15 03/13] eal_pci: pci memory map work with driver type

2015-02-26 Thread Tetsuya Mukawa
From: Michael Qiu 

With the driver type flag in struct rte_pci_dev, we do not need
to always  map uio devices with vfio related function when
vfio enabled.

Signed-off-by: Michael Qiu 
Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_eal/linuxapp/eal/eal_pci.c | 30 +-
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index 4615756..3291c68 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -555,25 +555,29 @@ pci_config_space_set(struct rte_pci_device *dev)
 static int
 pci_map_device(struct rte_pci_device *dev)
 {
-   int ret, mapped = 0;
+   int ret = -1;

/* try mapping the NIC resources using VFIO if it exists */
+   switch (dev->pt_driver) {
+   case RTE_PT_VFIO:
 #ifdef VFIO_PRESENT
-   if (pci_vfio_is_enabled()) {
-   ret = pci_vfio_map_resource(dev);
-   if (ret == 0)
-   mapped = 1;
-   else if (ret < 0)
-   return ret;
-   }
+   if (pci_vfio_is_enabled())
+   ret = pci_vfio_map_resource(dev);
 #endif
-   /* map resources for devices that use uio_pci_generic or igb_uio */
-   if (!mapped) {
+   break;
+   case RTE_PT_IGB_UIO:
+   case RTE_PT_UIO_GENERIC:
+   /* map resources for devices that use uio */
ret = pci_uio_map_resource(dev);
-   if (ret != 0)
-   return ret;
+   break;
+   default:
+   RTE_LOG(DEBUG, EAL, "  Not managed by known pt driver,"
+   " skipped\n");
+   ret = 1;
+   break;
}
-   return 0;
+
+   return ret;
 }

 /*
-- 
1.9.1



[dpdk-dev] [PATCH v15 02/13] eal_pci: Add flag to hold kernel driver type

2015-02-26 Thread Tetsuya Mukawa
From: Michael Qiu 

Currently, dpdk has no ability to know which type of driver(
vfio-pci/igb_uio/uio_pci_generic) the device used. It only can
check whether vfio is enabled or not staticly.

It really useful to have the flag, becasue different type need to
handle differently in runtime. For example, pci memory map,
pot hotplug, and so on.

This patch add a flag field for pci device to solve above issue.

Signed-off-by: Michael Qiu 
Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_eal/common/include/rte_pci.h |  8 +
 lib/librte_eal/linuxapp/eal/eal_pci.c   | 53 +++--
 2 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_pci.h 
b/lib/librte_eal/common/include/rte_pci.h
index 3df07e8..a87b4b3 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -142,6 +142,13 @@ struct rte_pci_addr {

 struct rte_devargs;

+enum rte_pt_driver {
+   RTE_PT_UNKNOWN  = 0,
+   RTE_PT_IGB_UIO  = 1,
+   RTE_PT_VFIO = 2,
+   RTE_PT_UIO_GENERIC  = 3,
+};
+
 /**
  * A structure describing a PCI device.
  */
@@ -155,6 +162,7 @@ struct rte_pci_device {
uint16_t max_vfs;   /**< sriov enable if not zero */
int numa_node;  /**< NUMA node connection */
struct rte_devargs *devargs;/**< Device user arguments */
+   enum rte_pt_driver pt_driver;   /**< Driver of passthrough */
 };

 /** Any PCI device identifier (vendor, device, ...) */
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index a4fd5f5..4615756 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -97,6 +97,35 @@ error:
return -1;
 }

+static int
+pci_get_kernel_driver_by_path(const char *filename, char *dri_name)
+{
+   int count;
+   char path[PATH_MAX];
+   char *name;
+
+   if (!filename || !dri_name)
+   return -1;
+
+   count = readlink(filename, path, PATH_MAX);
+   if (count >= PATH_MAX)
+   return -1;
+
+   /* For device does not have a driver */
+   if (count < 0)
+   return 1;
+
+   path[count] = '\0';
+
+   name = strrchr(path, '/');
+   if (name) {
+   strncpy(dri_name, name + 1, strlen(name + 1) + 1);
+   return 0;
+   }
+
+   return -1;
+}
+
 void *
 pci_find_max_end_va(void)
 {
@@ -221,11 +250,12 @@ pci_scan_one(const char *dirname, uint16_t domain, 
uint8_t bus,
char filename[PATH_MAX];
unsigned long tmp;
struct rte_pci_device *dev;
+   char driver[PATH_MAX];
+   int ret;

dev = malloc(sizeof(*dev));
-   if (dev == NULL) {
+   if (dev == NULL)
return -1;
-   }

memset(dev, 0, sizeof(*dev));
dev->addr.domain = domain;
@@ -304,6 +334,25 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t 
bus,
return -1;
}

+   /* parse driver */
+   snprintf(filename, sizeof(filename), "%s/driver", dirname);
+   ret = pci_get_kernel_driver_by_path(filename, driver);
+   if (!ret) {
+   if (!strcmp(driver, "vfio-pci"))
+   dev->pt_driver = RTE_PT_VFIO;
+   else if (!strcmp(driver, "igb_uio"))
+   dev->pt_driver = RTE_PT_IGB_UIO;
+   else if (!strcmp(driver, "uio_pci_generic"))
+   dev->pt_driver = RTE_PT_UIO_GENERIC;
+   else
+   dev->pt_driver = RTE_PT_UNKNOWN;
+   } else if (ret < 0) {
+   RTE_LOG(ERR, EAL, "Fail to get kernel driver\n");
+   free(dev);
+   return -1;
+   } else
+   dev->pt_driver = RTE_PT_UNKNOWN;
+
/* device is valid, add in list (sorted) */
if (TAILQ_EMPTY(_device_list)) {
TAILQ_INSERT_TAIL(_device_list, dev, next);
-- 
1.9.1



[dpdk-dev] [PATCH v15 00/13] Port Hotplug Framework

2015-02-26 Thread Tetsuya Mukawa
This patch series adds a dynamic port hotplug framework to DPDK.
With the patches, DPDK apps can attach or detach ports at runtime.

The basic concept of the port hotplug is like followings.
- DPDK apps must have responsibility to manage ports.
  DPDK apps only know which ports are attached or detached at the moment.
  The port hotplug framework is implemented to allow DPDK apps to manage ports.
  For example, when DPDK apps call port attach function, attached port number
  will be returned. Also, DPDK apps can detach port by port number.
- Kernel support is needed for attaching or detaching physical device ports.
  To attach a new physical device port, the device will be recognized by
  userspace directly I/O framework in kernel at first. Then DPDK apps can
  call the port hotplug functions to attach ports.
  For detaching, steps are vice versa.
- Before detach ports, ports must be stopped and closed.
  DPDK application must call rte_eth_dev_stop() and rte_eth_dev_close() before
  detaching ports. These function will call finalization codes of PMDs.
  But so far, no PMD frees all resources allocated by initialization.
  It means PMDs are needed to be fixed to support the port hotplug.
  'RTE_PCI_DRV_DETACHABLE' is a new flag indicating a PMD supports detaching.
  Without this flag, detaching will be failed.
- Mustn't affect legacy DPDK apps.
  No DPDK EAL behavior is changed, if the port hotplug functions are't called.
  So all legacy DPDK apps can still work without modifications.

And a few limitations.
- The port hotplug functions are not thread safe.
  DPDK apps should handle it.
- Only support Linux and igb_uio so far.
  BSD and VFIO is not supported. I will send VFIO patches at least, but I don't
  have a plan to submit BSD patch so far.


Here is port hotplug APIs.
---
/**
 * Attach a new device.
 *
 * @param devargs
 *   A pointer to a strings array describing the new device
 *   to be attached. The strings should be a pci address like
 *   ':01:00.0' or virtual device name like 'eth_pcap0'.
 * @param port_id
 *  A pointer to a port identifier actually attached.
 * @return
 *  0 on success and port_id is filled, negative on error
 */
int rte_eth_dev_attach(const char *devargs, uint8_t *port_id);

/**
 * Detach a device.
 *
 * @param port_id
 *   The port identifier of the device to detach.
 * @param addr
 *  A pointer to a device name actually detached.
 * @return
 *  0 on success and devname is filled, negative on error
 */
int rte_eth_dev_detach(uint8_t port_id, char *devname);
---

This patch series are for DPDK EAL. To use port hotplug function by DPDK apps,
each PMD should be fixed to support 'RTE_PCI_DRV_DETACHABLE' flag. Please check
a patch for pcap PMD.

Also, please check testpmd patch. It will show you how to fix your legacy
applications to support port hotplug feature.

PATCH v15 changes
 - Fix issue that eal calls ethedv library APIs.
  - Remove rte_eal_dev_attach(), and add rte_eth_dev_attach().
  - Remove rte_eal_dev_detach(), and add rte_eth_dev_detach().
  - Call rte_eal_vdev_init/uninit from ethdev library.
   (Thanks to Thomas Monjalon)
 - Fix version.map
 - Reorder and squash patches to compile correctly.
 - Remove needless symbols in version.map
 - Fix version.map.

PATCH v14 changes
 - Remove needless if statement.
   (Thanks to Maxime Leroy)

PATCH v13 changes
 - Change log level when error occurs in rte_eal_vdev_init() and
   rte_eal_dev_init().
 - Return value of driver init and uninit functions.
 - Replace rte_panic by RTE_LOG in rte_eal_dev_init()
 - Fix return value of rte_eal_vdev_uninit().
 - Fix rte_eal_dev_attach_vdev to set port_id correctly.
   (Thanks to Maxime Leroy)

PATCH v12 changes
 - Add missing symbol in version map.
   (Thanks to Iremonger, Bernard)

PATCH v11 changes
 - Remove needless devargs handling codes.
 - Replace get_vdev_name() by rte_eal_parse_devargs_str().
 - Replace rte_eal_vdev_find_and_init by rte_eal_vdev_init()
 - Replace rte_eal_vdev_find_and_uninit by rte_eal_vdev_uninit()
 - Fix rte_eal_dev_init() to use rte_eal_vdev_init().
 - Remove needless patch.
   (Thanks to Maxime Leroy)

PATCH v10 changes
 - Add comments.
 - Chagne order of version.map.
 - Fix comment of "rte_ethdev.h".
   (Thanks to Thomas Monjalon)
 - Add size parameter to rte_eth_dev_create_unique_device_name().
   (Thanks to Iremonger, Bernard)

PATCH v9 changes
 - Fix commit title.
 - Fix commit log.
 - Fix comments.
 - Define CONFIG_RTE_LIBRTE_EAL_HOTPLUG at the top of this patch series.
 - DEV_INVALID/VALID are removed.
 - DEV_DISCONNECTED is replaced by DEV_DETACHED.
 - DEV_CONNECTED is replaced by DEV_ATTACHED.
 - rte_eth_dev_allocate_new_port() is renamed to
   rte_eth_dev_find_free_port().
 - rte_eth_dev_validate_port() is renamed to rte_eth_dev_is_valid_port().
 - rte_eth_dev_is_valid_port() is changed not to 

[dpdk-dev] [PATCH] testpmd: HW vlan command

2015-02-26 Thread Xu, Qian Q
Tested-by: Qian Xu 

- Tested Commit: b67578ccdf45df9fd0f0204578b71acd854ca834
- OS: Fedora20 3.11
- GCC: gcc version 4.8.3 20140624
- CPU: Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz
- NIC: Intel 82599 Ethernet 10G SFI/SFP+ Network Connection
- Default x86_64-native-linuxapp-gcc configuration
- Total 1 case, 1 passed, 0 failed

- Case: test_perf_virtio_one_vm_dpdk_fwd_vhost-user
Description: in one-copy mode, vhost sample is in vhost user mode, launch one 
VM with 2 virtio devices and run testpmd in the VM. 
Steps:   
On host:
1. Start vhost-switch. vm2vm 0 means only one vm without vm to vm 
communication::
taskset -c 1-3 /examples/vhost/build/vhost-switch -c 0xf -n 4 
--huge-dir /mnt/huge --socket-mem 1024,1024 -- -p 1 --mergeable 0 --zero-copy 0 
--vm2vm 0

2. Start VM with vhost user as backend::

/x86_64-softmmu/qemu-system-x86_64 -name us-vhost-vm1 
-cpu host -enable-kvm -m 2048 -object 
memory-backend-file,id=mem,size=2048M,mem-path=/mnt/huge,share=on -numa 
node,memdev=mem -mem-prealloc -smp 2 -drive file=/home/img/dpdk1-vm1.img 
-chardev socket,id=char0,path=/tools/dpdk_nic_bind.py --bind igb_uio 00:03.0 00:04.0

.//x86_64-native-linuxapp-gcc/app/test-pmd/testpmd -c f -n 4 
-- -i --txqflags 0x0f00 --disable-hw-vlan-filter
$ >set fwd mac

$ >start tx_first

4. After typing start tx_first in testpmd, user can see there would be 2 virtio 
device with MAC and vlan id registered in vhost-user server, the log would be 
shown in host's vhost-sample output.

5. Send traffic(30second) to virtio1 and virtio2, and set the packet size from 
64 to 1518 as well as the jumbo frame 3000. Check the performance in Mpps. The 
traffic sent to virtio1 should have the DEST MAC of Virtio1's MAC, Vlan id of 
Virtio1. The traffic sent to virtio2 should have the DEST MAC of Virtio2's MAC, 
Vlan id of Virtio2. As to the functionality criteria, The received rate should 
not be zero. As to the performance criteria, need check it with developer or 
design doc/PRD.
-Original Message-
From: Ouyang, Changchun 
Sent: Friday, February 13, 2015 8:04 PM
To: dev at dpdk.org
Cc: Cao, Waterman; Ouyang, Changchun
Subject: [PATCH] testpmd: HW vlan command

This patch enables testpmd user can config port hw_vlan with more fine 
granularity:
hw vlan filter, hw vlan strip, and hw vlan extend.

Don't remove the original command(hw-vlan) considering that some user still 
want to use only one command to switch on/off all 3 options.

Signed-off-by: Changchun Ouyang 
---
 app/test-pmd/cmdline.c| 36 +---
 app/test-pmd/parameters.c | 18 ++
 2 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 
590e427..99cc307 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -584,7 +584,8 @@ static void cmd_help_long_parsed(void *parsed_result,
"port config all max-pkt-len (value)\n"
"Set the max packet length.\n\n"

-   "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
+   "port config all 
(crc-strip|rx-cksum|hw-vlan|hw-vlan-filter|"
+   "hw-vlan-strip|hw-vlan-extend|drop-en)"
" (on|off)\n"
"Set crc-strip/rx-checksum/hardware-vlan/drop_en"
" for ports.\n\n"
@@ -1327,6 +1328,33 @@ cmd_config_rx_mode_flag_parsed(void *parsed_result,
printf("Unknown parameter\n");
return;
}
+   } else if (!strcmp(res->name, "hw-vlan-filter")) {
+   if (!strcmp(res->value, "on"))
+   rx_mode.hw_vlan_filter = 1;
+   else if (!strcmp(res->value, "off"))
+   rx_mode.hw_vlan_filter = 0;
+   else {
+   printf("Unknown parameter\n");
+   return;
+   }
+   } else if (!strcmp(res->name, "hw-vlan-strip")) {
+   if (!strcmp(res->value, "on"))
+   rx_mode.hw_vlan_strip  = 1;
+   else if (!strcmp(res->value, "off"))
+   rx_mode.hw_vlan_strip  = 0;
+   else {
+   printf("Unknown parameter\n");
+   return;
+   }
+   } else if (!strcmp(res->name, "hw-vlan-extend")) {
+   if (!strcmp(res->value, "on"))
+   rx_mode.hw_vlan_extend = 1;
+   else if (!strcmp(res->value, "off"))
+   rx_mode.hw_vlan_extend = 0;
+   else {
+   printf("Unknown parameter\n");
+   return;
+   }
} else if (!strcmp(res->name, "drop-en")) {
if (!strcmp(res->value, "on"))
rx_drop_en = 1;
@@ -1355,7 +1383,8 @@ cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =

[dpdk-dev] [PATCH 35/36] ixgbe base codes: Update readme

2015-02-26 Thread Ouyang, Changchun
Resend this single patch only as it seems be blocked and not present in the 
mailing list.
Thanks
Changchun


> -Original Message-
> From: Ouyang, Changchun
> Sent: Thursday, February 26, 2015 10:09 AM
> To: dev at dpdk.org
> Cc: Richardson, Bruce; Cao, Waterman; Ouyang, Changchun
> Subject: [PATCH 35/36] ixgbe base codes: Update readme
> 
> Update the share code version into cid-10g-shared-code.2015.02.03.
> 
> Signed-off-by: Changchun Ouyang 
> ---
>  lib/librte_pmd_ixgbe/ixgbe/README | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/librte_pmd_ixgbe/ixgbe/README
> b/lib/librte_pmd_ixgbe/ixgbe/README
> index e0e5f0d..ba1249b 100644
> --- a/lib/librte_pmd_ixgbe/ixgbe/README
> +++ b/lib/librte_pmd_ixgbe/ixgbe/README
> @@ -34,7 +34,7 @@ Intel? IXGBE driver
>  ===
> 
>  This directory contains source code of FreeBSD ixgbe driver of version
> -cid-10g-shared-code.2014.09.04 released by LAD. The sub-directory of lad/
> +cid-10g-shared-code.2015.02.03 released by LAD. The sub-directory of lad/
>  contains the original source package.
>  This driver is valid for the product(s) listed below
> 
> --
> 1.8.4.2



[dpdk-dev] [dpdk-announce] release candidate 2.0.0-rc1

2015-02-26 Thread Thomas Monjalon
A new DPDK release candidate is ready for testing:
http://dpdk.org/browse/dpdk/tag/?id=v2.0.0-rc1

This is the first release candidate for DPDK 2.0.
It means we are entering in the RC testing phase.
Only fixes and cleanups will be accepted.

Changelog (main changes since 1.8.0)
- enhancements:
* ABI versioning
* x32 ABI
* non-eal thread supports
* multi-pthread per core
* port hotplug
* jobstats library
* reorder library
* memcpy optimization
* acl for AVX2
* crc hash arch-independent
* uio_pci_generic support
* kni optimizations
* vhost-user support
* virtio (link, vlan, mac, port IO, perf)
* ixgbevf RSS
* i40e hash filtering
* i40e nvgre offloading
* i40e switch
* fm10k driver
* mlx4 driver
* bonding mode 4 tests
* bonding mode 6
* Rx/Tx callbacks
* unified flow types
* remove old filtering API (flow director, flex, ethertype, 
syn, ntuple)
* remove device arguments limit
* add indirect attached mbuf flag
* use default port configuration in testpmd
* tunnel offloading in testpmd
- fixes for:
* build
* big endian
* cmdline
* timer
* lpm
* pipeline
* bonding
* pcap
* ixgbe vector
* i40e

We are making good progress in organization and reviewing.
Please let's continue to sustain the reviewing effort.
You are welcome to check pending patches from other developers
in http://dpdk.org/dev/patchwork and make some comments:
http://dpdk.org/dev#review

Thank you everyone for making it possible.



[dpdk-dev] [PATCH v11 2/2] librte_pmd_null: Support port hotplug function

2015-02-26 Thread Thomas Monjalon
> This patch adds port hotplug support to Null PMD.
> 
> v9:
>  - Use rte_eth_dev_release_port() instead of rte_eth_dev_free().
> v7:
>  - Add parameter checkings.
>(Thanks to Iremonger, Bernard)
> v6:
>  - Fix a parameter of rte_eth_dev_free().
> v4:
>  - Fix commit title.
> 
> Signed-off-by: Tetsuya Mukawa 

Applied, thanks

I assumed you are OK to be the maintainer of Null PMD.



[dpdk-dev] [PATCH v15] testpmd: Add port hotplug support

2015-02-26 Thread Thomas Monjalon
> The patch introduces following commands.
> - port attach [ident]
> - port detach [port_id]
>  - attach: attaching a port
>  - detach: detaching a port
>  - ident: pci address of physical device.
>   Or device name and parameters of virtual device.
>  (ex. :02:00.0, eth_pcap0,iface=eth0)
>  - port_id: port identifier
> 
> v15:
> - Replace rte_eal_dev_attach() by rte_eth_dev_attach()
> - Replace rte_eal_dev_detach() by rte_eth_dev_detach()
> 
> v7:
> - Fix doc.
>   (Thanks to Iremonger, Bernard)
> - Fix port checking implementation of star_port();
>   (Thanks to Qiu, Michael)
> v5:
> - Add testpmd documentation.
>   (Thanks to Iremonger, Bernard)
> v4:
>  - Fix strings of command help.
> 
> Signed-off-by: Tetsuya Mukawa 

Applied, thanks


[dpdk-dev] [PATCH v15] librte_pmd_pcap: Add port hotplug support

2015-02-26 Thread Thomas Monjalon
> This patch adds finalization code to free resources allocated by the
> PMD.
> 
> v6:
>  - Fix a paramter of rte_eth_dev_free().
> v4:
>  - Change function name.
> 
> Signed-off-by: Tetsuya Mukawa 

Applied, thanks


[dpdk-dev] [PATCH v15 00/13] Port Hotplug Framework

2015-02-26 Thread Thomas Monjalon
2015-02-26 04:32, Tetsuya Mukawa:
> This patch series adds a dynamic port hotplug framework to DPDK.
> With the patches, DPDK apps can attach or detach ports at runtime.
> 
> The basic concept of the port hotplug is like followings.
> - DPDK apps must have responsibility to manage ports.
>   DPDK apps only know which ports are attached or detached at the moment.
>   The port hotplug framework is implemented to allow DPDK apps to manage 
> ports.
>   For example, when DPDK apps call port attach function, attached port number
>   will be returned. Also, DPDK apps can detach port by port number.
> - Kernel support is needed for attaching or detaching physical device ports.
>   To attach a new physical device port, the device will be recognized by
>   userspace directly I/O framework in kernel at first. Then DPDK apps can
>   call the port hotplug functions to attach ports.
>   For detaching, steps are vice versa.
> - Before detach ports, ports must be stopped and closed.
>   DPDK application must call rte_eth_dev_stop() and rte_eth_dev_close() before
>   detaching ports. These function will call finalization codes of PMDs.
>   But so far, no PMD frees all resources allocated by initialization.
>   It means PMDs are needed to be fixed to support the port hotplug.
>   'RTE_PCI_DRV_DETACHABLE' is a new flag indicating a PMD supports detaching.
>   Without this flag, detaching will be failed.
> - Mustn't affect legacy DPDK apps.
>   No DPDK EAL behavior is changed, if the port hotplug functions are't called.
>   So all legacy DPDK apps can still work without modifications.
> 
> And a few limitations.
> - The port hotplug functions are not thread safe.
>   DPDK apps should handle it.
> - Only support Linux and igb_uio so far.
>   BSD and VFIO is not supported. I will send VFIO patches at least, but I 
> don't
>   have a plan to submit BSD patch so far.
> 
> 
> Here is port hotplug APIs.
> ---
> /**
>  * Attach a new device.
>  *
>  * @param devargs
>  *   A pointer to a strings array describing the new device
>  *   to be attached. The strings should be a pci address like
>  *   ':01:00.0' or virtual device name like 'eth_pcap0'.
>  * @param port_id
>  *  A pointer to a port identifier actually attached.
>  * @return
>  *  0 on success and port_id is filled, negative on error
>  */
> int rte_eth_dev_attach(const char *devargs, uint8_t *port_id);
> 
> /**
>  * Detach a device.
>  *
>  * @param port_id
>  *   The port identifier of the device to detach.
>  * @param addr
>  *  A pointer to a device name actually detached.
>  * @return
>  *  0 on success and devname is filled, negative on error
>  */
> int rte_eth_dev_detach(uint8_t port_id, char *devname);
> ---
> 
> This patch series are for DPDK EAL. To use port hotplug function by DPDK apps,
> each PMD should be fixed to support 'RTE_PCI_DRV_DETACHABLE' flag. Please 
> check
> a patch for pcap PMD.
> 
> Also, please check testpmd patch. It will show you how to fix your legacy
> applications to support port hotplug feature.
> 
> PATCH v15 changes
>  - Fix issue that eal calls ethedv library APIs.
>   - Remove rte_eal_dev_attach(), and add rte_eth_dev_attach().
>   - Remove rte_eal_dev_detach(), and add rte_eth_dev_detach().
>   - Call rte_eal_vdev_init/uninit from ethdev library.
>(Thanks to Thomas Monjalon)
>  - Fix version.map
>  - Reorder and squash patches to compile correctly.
>  - Remove needless symbols in version.map
>  - Fix version.map.
> 
> PATCH v14 changes
>  - Remove needless if statement.
>(Thanks to Maxime Leroy)
> 
> PATCH v13 changes
>  - Change log level when error occurs in rte_eal_vdev_init() and
>rte_eal_dev_init().
>  - Return value of driver init and uninit functions.
>  - Replace rte_panic by RTE_LOG in rte_eal_dev_init()
>  - Fix return value of rte_eal_vdev_uninit().
>  - Fix rte_eal_dev_attach_vdev to set port_id correctly.
>(Thanks to Maxime Leroy)
> 
> PATCH v12 changes
>  - Add missing symbol in version map.
>(Thanks to Iremonger, Bernard)
> 
> PATCH v11 changes
>  - Remove needless devargs handling codes.
>  - Replace get_vdev_name() by rte_eal_parse_devargs_str().
>  - Replace rte_eal_vdev_find_and_init by rte_eal_vdev_init()
>  - Replace rte_eal_vdev_find_and_uninit by rte_eal_vdev_uninit()
>  - Fix rte_eal_dev_init() to use rte_eal_vdev_init().
>  - Remove needless patch.
>(Thanks to Maxime Leroy)
> 
> PATCH v10 changes
>  - Add comments.
>  - Chagne order of version.map.
>  - Fix comment of "rte_ethdev.h".
>(Thanks to Thomas Monjalon)
>  - Add size parameter to rte_eth_dev_create_unique_device_name().
>(Thanks to Iremonger, Bernard)
> 
> PATCH v9 changes
>  - Fix commit title.
>  - Fix commit log.
>  - Fix comments.
>  - Define CONFIG_RTE_LIBRTE_EAL_HOTPLUG at the top of this patch series.
>  - DEV_INVALID/VALID are removed.
>  -