[dpdk-dev] [PATCHv3 1/2] config/armv8a: disable igb_uio

2016-05-13 Thread Santosh Shukla
On Fri, May 13, 2016 at 02:50:48PM +0200, Thomas Monjalon wrote:
> 2016-05-11 19:17, Hemant Agrawal:
> > IGB_UIO not supported for arm64 arch in kernel so disable.
> 
> If I understand well, a patch is needed in the kernel to make
> igb_uio works? Please confirm.
>

Yes. User need this [1] out-of-tree patch for igb_uio.

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-July/359435.html

> In that case, yes, the default configuration should be to disable
> igb_uio.
> Please note it's just a default to make it work in most common cases.
> And yes, the default should focus on recent kernels and future directions.
> 
> > +CONFIG_RTE_EAL_IGB_UIO=n
> 


[dpdk-dev] [PATCH 5/7] eal/linux: mmap ioports on ppc64

2016-05-13 Thread Olivier Matz


On 05/13/2016 04:33 PM, David Marchand wrote:
>> --- a/lib/librte_eal/common/include/rte_pci.h
>> +++ b/lib/librte_eal/common/include/rte_pci.h
>> @@ -105,7 +105,8 @@ extern struct pci_device_list pci_device_list; /**< 
>> Global list of PCI devices.
>>  /** Nb. of values in PCI resource format. */
>>  #define PCI_RESOURCE_FMT_NVAL 3
>>
>> -/** IO resource type: memory address space */
>> +/** IO resource type: */
>> +#define IORESOURCE_IO 0x0100
>>  #define IORESOURCE_MEM0x0200
>>
>>  /**
> 
> This could go in a linux-specific header.

Yep, I'll do a separate patch for that in v2.

> 
>> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
>> b/lib/librte_eal/linuxapp/eal/eal_pci.c
>> index 1a93725..f1ea52b 100644
>> --- a/lib/librte_eal/linuxapp/eal/eal_pci.c
>> +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
>> @@ -191,9 +191,9 @@ pci_find_max_end_va(void)
>>  }
>>
>>  /* parse one line of the "resource" sysfs file (note that the 'line'
>> - * string is modified)
>> + * string is modified
>>   */
> 
> Garbage ?

Indeed :)


Thanks for reviewing!



[dpdk-dev] [PATCH 6/7] virtio: fix pci accesses for ppc64 in legacy mode

2016-05-13 Thread Olivier Matz
Hi David,

On 05/13/2016 04:28 PM, David Marchand wrote:
>> +#ifdef RTE_ARCH_PPC_64
>> +   switch (length) {
>> +   case 4:
>> +   *(uint32_t *)dst = rte_be_to_cpu_32(*(uint32_t *)dst);
>> +   break;
>> +   case 2:
>> +   *(uint16_t *)dst = rte_be_to_cpu_16(*(uint16_t *)dst);
>> +   break;
>> +   default:
>> +   break;
>> +   }
>> +#endif
>>  }
> 
> I think that, in the original patch, I was handling lengths different
> than 1, 2 and 4 ;-)
> Idem for write.

Oh oh, spotted :)
I'll fix that in the v2.


[dpdk-dev] [PATCH] librte_ether: use RTE_ETH_VALID_PORTID_OR_ERR_RET to check port_id

2016-05-13 Thread Thomas Monjalon
2016-04-29 17:23, Mauricio Vasquez B:
> The RTE_ETH_VALID_PORTID_OR_ERR_RET macro is used in some places
> to check if a port id is valid or not. This commit makes use of it in
> some new parts of the code.

There are other occurences:
rte_eth_dev_socket_id
rte_eth_add_rx_callback
rte_eth_add_tx_callback
rte_eth_remove_rx_callback
rte_eth_remove_tx_callback
I think it could be done also in examples/ethtool/lib.



[dpdk-dev] [PATCHv3 1/2] config/armv8a: disable igb_uio

2016-05-13 Thread Jianbo Liu
On 13 May 2016 at 15:47, Jerin Jacob  wrote:
> On Fri, May 13, 2016 at 03:37:01AM +, Hemant Agrawal wrote:
>>
>>
>> > -Original Message-
>> > From: Jianbo Liu [mailto:jianbo.liu at linaro.org]
>> > Sent: Friday, May 13, 2016 7:13 AM
>> > To: Santosh Shukla 
>> > Cc: Stephen Hemminger ; Jerin Jacob
>> > ; Hemant Agrawal
>> > ; dev at dpdk.org; Thomas Monjalon
>> > 
>> > Subject: Re: [dpdk-dev] [PATCHv3 1/2] config/armv8a: disable igb_uio
>> >
>> > On 12 May 2016 at 18:31, Santosh Shukla
>> >  wrote:
>> > > On Thu, May 12, 2016 at 05:52:54PM +0800, Jianbo Liu wrote:
>> > >> On 12 May 2016 at 16:57, Santosh Shukla
>> > >>  wrote:
>> > >> > On Thu, May 12, 2016 at 01:54:13PM +0800, Jianbo Liu wrote:
>> > >> >> On 12 May 2016 at 13:06, Santosh Shukla
>> > >> >>  wrote:
>> > >> >> > On Thu, May 12, 2016 at 11:42:26AM +0800, Jianbo Liu wrote:
>> > >> >> >> On 12 May 2016 at 11:17, Santosh Shukla
>> > >> >> >>  wrote:
>> > >> >> >> > On Thu, May 12, 2016 at 10:01:05AM +0800, Jianbo Liu wrote:
>> > >> >> >> >> On 12 May 2016 at 02:25, Stephen Hemminger
>> >  wrote:
>> > >> >> >> >> > On Wed, 11 May 2016 22:32:16 +0530 Jerin Jacob
>> > >> >> >> >> >  wrote:
>> > >> >> >> >> >
>> > >> >> >> >> >> On Wed, May 11, 2016 at 08:22:59AM -0700, Stephen
>> > Hemminger wrote:
>> > >> >> >> >> >> > On Wed, 11 May 2016 19:17:58 +0530 Hemant Agrawal
>> > >> >> >> >> >> >  wrote:
>> > >> >> >> >> >> >
>> > >> >> >> >> >> > > IGB_UIO not supported for arm64 arch in kernel so 
>> > >> >> >> >> >> > > disable.
>> > >> >> >> >> >> > >
>> > >> >> >> >> >> > > Signed-off-by: Hemant Agrawal
>> > >> >> >> >> >> > > 
>> > >> >> >> >> >> > > Reviewed-by: Santosh Shukla
>> > >> >> >> >> >> > > 
>> > >> >> >> >> >> >
>> > >> >> >> >> >> > Really, I have use IGB_UIO on ARM64
>> > >> >> >> >> >>
>> > >> >> >> >> >> May I know what is the technical use case for igb_uio on
>> > >> >> >> >> >> arm64 which cannot be addressed through vfio or vfioionommu.
>> > >> >> >> >> >
>> > >> >> >> >> > I was running on older kernel which did not support 
>> > >> >> >> >> > vfioionommu
>> > mode.
>> > >> >> >> >>
>> > >> >> >> >> As I said, most of DPDK developers are not kernel
>> > >> >> >> >> developers. They may have their own kernel tree, and
>> > >> >> >> >> couldn't like to upgrade to latest kernel.
>> > >> >> >> >> They can choose to use or not use igb_uio when binding the
>> > >> >> >> >> driver. But blindly disabling it in the base config seems 
>> > >> >> >> >> unreasonable.
>> > >> >> >> >
>> > >> >> >> > if user keeping his own kernel so they could also keep
>> > >> >> >> > IGB_UIO=y in their local
>> > >> >> >> Most likely they don't have local dpdk tree. They write their
>> > >> >> >> own applications, complie and link to dpdk lib, then done.
>> > >> >> >>
>> > >> >> >> > dpdk tree. Why are you imposing user-x custome depedancy on
>> > >> >> >> > upstream dpdk base
>> > >> >> >> Customer requiremnts is important. I want they can choose the way
>> > they like.
>> > >> >> >>
>> > >> >> >
>> > >> >> > so you choose to keep igb_uio option, provided arch doesn't 
>> > >> >> > support?
>> > >> >> > new user did reported issues with igb_uio for arm64, refer this
>> > >> >> > thread [1], as well hemanth too faced issues. we want to avoid 
>> > >> >> > that.
>> > >> >> >
>> > >> >> > If customer maintaing out-of-tree kernel then he can also switch 
>> > >> >> > to vfio-
>> > way.
>> > >> >> > isn;t it?
>> > >> >> >
>> > >> >> >> > config. Is it not enough for explanation that - Base config
>> > >> >> >> > ie.. armv8 doesn;t support pci mmap, so igb_uio is n/a. New
>> > >> >> >> > user wont able to build/run dpdk/arm64 in igb_uio-way, He'll
>> > >> >> >> > prefer to use upstream stuff. I think, you are not making
>> > >> >> >> You are wrong, he can build dpdk. If he like to use upstream
>> > >> >> >> without patching, he can use vfio.
>> > >> >> >
>> > >> >> > I disagree, we want to avoid [1] for new user.
>> > >> >> >
>> > >> >> >> But you can't ignore the need from old user which is more
>> > >> >> >> comfortable with older kernel.
>> > >> >> >>
>> > >> >> > arm/arm64 dpdk support recently added and I am guessing, most
>> > >> >> > likely customer using near latest kernel, switching to vfio won't 
>> > >> >> > be so
>> > difficult.
>> > >> >> >
>> > >> >> > Or can you take up responsibility of upstreaming pci mmap patch,
>> > >> >> > then we don't need this patch.
>> > >> >> >
>> > >> >> > [1] http://dpdk.org/ml/archives/dev/2016-January/031313.html
>> > >> >>
>> > >> >> Can you read carefully about the guide at
>> > >> >> http://dpdk.org/doc/guides/linux_gsg/build_dpdk.html? It says to
>> > >> >> use uio_pci_generic, igb_uio or vfio-pci.
>> > >> >
>> > >> > *** applicable and works for x86 only, not for arm64: because pci
>> > >> > mmap support not present for arm64, in that case we should update the
>> > doc.
>> > >> >
>> > >> >> Could it be possible that the user in that thread has already read
>> > >> >> and tried them all and found 

[dpdk-dev] [PATCH] arm64: change rte_memcpy to inline function

2016-05-13 Thread Thomas Monjalon
2016-05-10 14:01, Jianbo Liu:
> Other APP may call rte_memcpy by function pointer,
> so change it to an inline function.

Any example in mind?

> --- a/lib/librte_eal/common/include/arch/arm/rte_memcpy_64.h
> +++ b/lib/librte_eal/common/include/arch/arm/rte_memcpy_64.h
> -#define rte_memcpy(d, s, n)  memcpy((d), (s), (n))
> +static inline void *
> +rte_memcpy(void *dst, const void *src, size_t n)
> +{
> + return memcpy(dst, src, n);
> +}

It has no sense if other archs (arm32, ppc64, tile) are not updated.



[dpdk-dev] [PATCH] qede: fix build with gcc >= 6.0

2016-05-13 Thread Thomas Monjalon
2016-05-10 13:01, Panu Matilainen:
> With gcc >= 6.0, qede base driver fails to build with:
> drivers/net/qede/base/ecore_cxt.c: In function 'ecore_cdu_init_common':
> cc1: error: left shift of negative value [-Werror=shift-negative-value]
> 
> Since the base drivers are untouchable, work around by disabling
> the warning.

Are the qede base driver files untouchable?

> Signed-off-by: Panu Matilainen 
[...]
> +ifeq ($(shell test $(GCC_VERSION) -ge 60 && echo 1), 1)
> +CFLAGS_BASE_DRIVER += -Wno-shift-negative-value
> +endif

Fixes: ec94dbc57362 ("qede: add base driver")

Applied, thanks

Rasesh, would you mind to fix the base driver and remove this workaround?


[dpdk-dev] [PATCH v2 08/11] app/test: convert current pci_test into a single test case

2016-05-13 Thread Thomas Monjalon
2016-05-13 17:19, Jan Viktorin:
> On Thu, 12 May 2016 17:34:13 +0200
> Thomas Monjalon  wrote:
> 
> > 2016-05-10 20:13, Jan Viktorin:
> > > The current test_pci is just a single test case that tests the 
> > > blacklisting
> > > of devices. Rename it to test_pci_blacklist and call it from the 
> > > test_pci.  
> > 
> > The functions are also moved. It is confusing.
> > Maybe this patch can be squashed with the previous one.
> > 
> 
> Well, I wanted to separate the functional changes from cosmetic ones.
> The goal here is to extract the setup and cleanup phases from the orignal
> test. Would be better to just change the description?
> 
> ---
> 
> app/test: extract setup and cleanup phase from pci_test
> 
> The original test_pci contains the setup and cleanup phase in its body.
> By extracting this code out, we can take advantage of this code for other
> (future) tests as well.
> 
> The test_pci is renamed to test_pci_blacklist - it's only a single test
> case (others will follow) now.
> 
> ---
> 
> Probably, it can be splitted (instead of squashed with a previous one) to
> "extract setup and cleanup" and "rename to test_pci_blacklist".

Not a big deal, I will check in v3.
Thanks


[dpdk-dev] [PATCH 11/15] vfio: move global vfio_cfg to eal_vfio.c

2016-05-13 Thread Jan Viktorin
Self review:

* missing #ifdef VFIO_PRESENT ... #endif in eal_vfio.c leads to fail
  when VFIO build is disabled

Jan

On Fri, 29 Apr 2016 15:44:12 +0200
Jan Viktorin  wrote:

> The vfio_cfg is a module-global variable and so together with this
> variable, it is necessary to move functions:
> 
> * pci_vfio_get_group_fd
>   - renamed to vfio_get_group_fd
>   - pci_* version removed (no other call in EAL)
> 
> * pci_vfio_setup_device
>   - renamed as vfio_setup_device
> 
> * pci_vfio_enable
>   - renamed as vfio_enable
>   - generalized to check for a specific vfio driver presence
>   - pci_* specialization preserved as a wrapper
> 
> * pci_vfio_is_enabled
>   - renamed as vfio_is_enabled
>   - generalized to check for a specific vfio driver presence
> to preserve the semantics of VFIO + PCI
>   - pci_* specialization preserved as a wrapper
> 
> * clear_current_group
>   - private function, just moved
> 
> To stop GCC complaining about "defined but not used", the private
> function pci_vfio_get_group_no has been removed entirely.
> 
> Signed-off-by: Jan Viktorin 
> ---
>  lib/librte_eal/linuxapp/eal/eal_pci_init.h |   1 -
>  lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 282 
> +
>  lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c |   2 +-
>  lib/librte_eal/linuxapp/eal/eal_vfio.c | 272 
>  lib/librte_eal/linuxapp/eal/eal_vfio.h |  17 ++
>  5 files changed, 294 insertions(+), 280 deletions(-)

[...]


[dpdk-dev] [PATCH] qede: fix icc build error

2016-05-13 Thread Thomas Monjalon
> >fix errors:
> >icc: command line warning #10006: ignoring unknown option
> >'-Wno-unused-value'
> >icc: command line warning #10006: ignoring unknown option
> >'-Wno-format-nonliteral'
> >icc: command line warning #10006: ignoring unknown option
> >'-Wno-shift-negative-value'
> >qede/base/ecore_dev.c(1643): error #188: enumerated type mixed with
> >another type
> >return 0;
> >   ^
> >
> >Signed-off-by: Ferruh Yigit 
> 
> Looks good. 
> I hope its retested against gcc/clang also to make sure the change doesn?t
> cause build errors.
> 
> Acked-by: Harish Patil 

Fixes: ec94dbc57362 ("qede: add base driver")

Applied, thanks


[dpdk-dev] [PATCH v2 09/11] eal/pci: replace SYSFS_PCI_DEVICES with pci_get_sysfs_path()

2016-05-13 Thread Jan Viktorin
On Thu, 12 May 2016 18:10:07 +0200
Thomas Monjalon  wrote:

> 2016-05-12 17:46, Jan Viktorin:
> > On Thu, 12 May 2016 17:41:22 +0200
> > Thomas Monjalon  wrote:  
> > > 2016-05-10 20:13, Jan Viktorin:  
> > > > +   orig = pci_get_sysfs_path();
> > > > +   ret = setenv("SYSFS_PCI_DEVICES", "My Documents", 1);
> > > 
> > > Oh no!  
> > 
> > Not sure about your reaction...  
> 
> MS reference... ;)
> 
> > >   
> > > > +   TEST_ASSERT_SUCCESS(ret, "Failed setenv to My Documents");
> > > > +
> > > > +   path = pci_get_sysfs_path();
> > > > +   TEST_ASSERT(strcmp(orig, path),
> > > > +   "orig must be different from path: "
> > > 
> > > I missed something here. Why different?  
> > 
> > Because I've set it to "My Documents" and want to be sure that the
> > pci_get_sysfs_path() returns the new path instead of the default
> > one.
> > 
> > Perhaps, !strcmp(path, "My Documents") would be better here...  
> 
> No, just rethink the variable names maybe.

Fixed for v3 as a combination of both.



-- 
   Jan Viktorin  E-mail: Viktorin at RehiveTech.com
   System Architect  Web:www.RehiveTech.com
   RehiveTech
   Brno, Czech Republic


[dpdk-dev] [PATCH v2 08/11] app/test: convert current pci_test into a single test case

2016-05-13 Thread Jan Viktorin
On Thu, 12 May 2016 17:34:13 +0200
Thomas Monjalon  wrote:

> 2016-05-10 20:13, Jan Viktorin:
> > The current test_pci is just a single test case that tests the blacklisting
> > of devices. Rename it to test_pci_blacklist and call it from the test_pci.  
> 
> The functions are also moved. It is confusing.
> Maybe this patch can be squashed with the previous one.
> 

Well, I wanted to separate the functional changes from cosmetic ones.
The goal here is to extract the setup and cleanup phases from the orignal
test. Would be better to just change the description?

---

app/test: extract setup and cleanup phase from pci_test

The original test_pci contains the setup and cleanup phase in its body.
By extracting this code out, we can take advantage of this code for other
(future) tests as well.

The test_pci is renamed to test_pci_blacklist - it's only a single test
case (others will follow) now.

---

Probably, it can be splitted (instead of squashed with a previous one) to
"extract setup and cleanup" and "rename to test_pci_blacklist".

Jan

-- 
   Jan Viktorin  E-mail: Viktorin at RehiveTech.com
   System Architect  Web:www.RehiveTech.com
   RehiveTech
   Brno, Czech Republic


[dpdk-dev] [PATCH 1/5] bonding: replace spinlock with read/write lock

2016-05-13 Thread Ananyev, Konstantin


> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Ananyev, Konstantin
> Sent: Friday, May 13, 2016 6:11 PM
> To: Stephen Hemminger; Doherty, Declan
> Cc: Iremonger, Bernard; dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 1/5] bonding: replace spinlock with read/write 
> lock
> 
> 
> 
> > -Original Message-
> > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Stephen Hemminger
> > Sent: Friday, May 06, 2016 4:56 PM
> > To: Doherty, Declan
> > Cc: Iremonger, Bernard; dev at dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH 1/5] bonding: replace spinlock with 
> > read/write lock
> >
> > On Fri, 6 May 2016 11:32:19 +0100
> > Declan Doherty  wrote:
> >
> > > On 05/05/16 18:12, Stephen Hemminger wrote:
> > > > On Thu,  5 May 2016 16:14:56 +0100
> > > > Bernard Iremonger  wrote:
> > > >
> > > >> Fixes: a45b288ef21a ("bond: support link status polling")
> > > >> Signed-off-by: Bernard Iremonger 
> > > >
> > > > You know an uncontested reader/writer lock is significantly slower
> > > > than a spinlock.
> > > >
> > >
> > > As we can have multiple readers of the active slave list / primary
> > > slave, basically any tx/rx burst call needs to protect against a device
> > > being removed/closed during it's operation now that we support
> > > hotplugging, in the worst case this could mean we have 2(rx+tx) * queues
> > > possibly using the active slave list simultaneously, in that case I
> > > would have thought that a spinlock would have a much more significant
> > > affect on performance?
> >
> > Right, but the window where the shared variable is accessed is very small,
> > and it is actually faster to use spinlock for that.
> 
> I don't think that window we hold the lock is that small, let say if we have
> a burst of 32 packets * (let say) 50 cycles/pkt = ~1500 cycles - each IO 
> thread would stall.
> For me that's long enough to justify rwlock usage here, especially that
> DPDK rwlock price is not much bigger (as I remember) then spinlock -
> it is basically 1 CAS operation.

As another alternative we can have a spinlock per queue, then different IO 
threads
doing RX/XTX over different queues will be uncontended at all.
Though control thread would need to grab locks for all configured queues :)

Konstantin

> 
> Konstantin
> 


[dpdk-dev] [PATCH 1/5] bonding: replace spinlock with read/write lock

2016-05-13 Thread Ananyev, Konstantin


> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Stephen Hemminger
> Sent: Friday, May 06, 2016 4:56 PM
> To: Doherty, Declan
> Cc: Iremonger, Bernard; dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 1/5] bonding: replace spinlock with read/write 
> lock
> 
> On Fri, 6 May 2016 11:32:19 +0100
> Declan Doherty  wrote:
> 
> > On 05/05/16 18:12, Stephen Hemminger wrote:
> > > On Thu,  5 May 2016 16:14:56 +0100
> > > Bernard Iremonger  wrote:
> > >
> > >> Fixes: a45b288ef21a ("bond: support link status polling")
> > >> Signed-off-by: Bernard Iremonger 
> > >
> > > You know an uncontested reader/writer lock is significantly slower
> > > than a spinlock.
> > >
> >
> > As we can have multiple readers of the active slave list / primary
> > slave, basically any tx/rx burst call needs to protect against a device
> > being removed/closed during it's operation now that we support
> > hotplugging, in the worst case this could mean we have 2(rx+tx) * queues
> > possibly using the active slave list simultaneously, in that case I
> > would have thought that a spinlock would have a much more significant
> > affect on performance?
> 
> Right, but the window where the shared variable is accessed is very small,
> and it is actually faster to use spinlock for that.

I don't think that window we hold the lock is that small, let say if we have
a burst of 32 packets * (let say) 50 cycles/pkt = ~1500 cycles - each IO thread 
would stall.
For me that's long enough to justify rwlock usage here, especially that 
DPDK rwlock price is not much bigger (as I remember) then spinlock -
it is basically 1 CAS operation.

Konstantin



[dpdk-dev] [PATCH] armv7a: disable qede pmd

2016-05-13 Thread Thomas Monjalon
2016-05-09 23:34, Jan Viktorin:
> The qede PMD driver is failing when building for ARMv7:
> 
> drivers/net/qede/base/ecore_dev.c: In function ?ecore_hw_init_pf?:
> drivers/net/qede/base/ecore_dev.c:1150:6:
>   error: variable ?prs_reg? set but not used 
> [-Werror=unused-but-set-variable]
>   u32 prs_reg;
>   ^
> [...]
> 
> drivers/net/qede/base/ecore_dev.c:2492:13:
>   error: variable ?p_phys? set but not used 
> [-Werror=unused-but-set-variable]
>   dma_addr_t p_phys = p_chain->p_phys_addr, p_phys_next = 0;
>  ^
> drivers/net/qede/base/ecore_dev.c: In function ?ecore_chain_free_pbl?:
> drivers/net/qede/base/ecore_dev.c:2532:39:
>   error: variable ?pbl_size? set but not used 
> [-Werror=unused-but-set-variable]
>   u32 page_cnt = p_chain->page_cnt, i, pbl_size;
> 
> Fixes: 3eae93a9bfd5 ("qede: enable PMD build")
> 
> Signed-off-by: Jan Viktorin 

Applied, not because of the build issue, but because ARMv7 is
not really interested in PCI devices.


[dpdk-dev] [PATCH 5/7] eal/linux: mmap ioports on ppc64

2016-05-13 Thread David Marchand
On Fri, May 13, 2016 at 2:50 PM, Olivier Matz  wrote:
> On PPC64, the ioports are mapped in memory. Implement the missing part
> of ioport API for PPC64 when using uio. This may also work on other
> architectures but it has not been tested.
>
> Signed-off-by: David Marchand 
> Signed-off-by: Olivier Matz 
> ---
>  lib/librte_eal/common/include/rte_pci.h|   4 +-
>  lib/librte_eal/linuxapp/eal/eal_pci.c  |   4 +-
>  lib/librte_eal/linuxapp/eal/eal_pci_init.h |   6 ++
>  lib/librte_eal/linuxapp/eal/eal_pci_uio.c  | 119 
> +++--
>  4 files changed, 107 insertions(+), 26 deletions(-)
>
> diff --git a/lib/librte_eal/common/include/rte_pci.h 
> b/lib/librte_eal/common/include/rte_pci.h
> index fd049d1..4657396 100644
> --- a/lib/librte_eal/common/include/rte_pci.h
> +++ b/lib/librte_eal/common/include/rte_pci.h
> @@ -105,7 +105,8 @@ extern struct pci_device_list pci_device_list; /**< 
> Global list of PCI devices.
>  /** Nb. of values in PCI resource format. */
>  #define PCI_RESOURCE_FMT_NVAL 3
>
> -/** IO resource type: memory address space */
> +/** IO resource type: */
> +#define IORESOURCE_IO 0x0100
>  #define IORESOURCE_MEM0x0200
>
>  /**

This could go in a linux-specific header.

> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
> b/lib/librte_eal/linuxapp/eal/eal_pci.c
> index 1a93725..f1ea52b 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_pci.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
> @@ -191,9 +191,9 @@ pci_find_max_end_va(void)
>  }
>
>  /* parse one line of the "resource" sysfs file (note that the 'line'
> - * string is modified)
> + * string is modified
>   */

Garbage ?

-- 
David Marchand


[dpdk-dev] [PATCH 6/7] virtio: fix pci accesses for ppc64 in legacy mode

2016-05-13 Thread David Marchand
Hello Olivier,

On Fri, May 13, 2016 at 2:50 PM, Olivier Matz  wrote:
> From: David Marchand 
>
> Although ppc supports both endianesses, qemu supposes that the cpu is
> big endian and enforces this for the virtio-net stuff.
>
> Fix PCI accesses in legacy mode. Only ppc64le is supported at the moment.
>
> Signed-off-by: David Marchand 
> Signed-off-by: Olivier Matz 
> ---
>  drivers/net/virtio/virtio_pci.c | 44 
> +
>  1 file changed, 44 insertions(+)
>
> diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
> index 9cdca06..bdb89fd 100644
> --- a/drivers/net/virtio/virtio_pci.c
> +++ b/drivers/net/virtio/virtio_pci.c
> @@ -55,18 +55,62 @@
>   */
>  #define VIRTIO_PCI_CONFIG(hw) (((hw)->use_msix) ? 24 : 20)
>
> +/*
> + * Since we are in legacy mode:
> + * http://ozlabs.org/~rusty/virtio-spec/virtio-0.9.5.pdf
> + *
> + * "Note that this is possible because while the virtio header is PCI (i.e.
> + * little) endian, the device-specific region is encoded in the native 
> endian of
> + * the guest (where such distinction is applicable)."
> + *
> + * For powerpc which supports both, qemu supposes that cpu is big endian and
> + * enforces this for the virtio-net stuff.
> + */
> +
>  static void
>  legacy_read_dev_config(struct virtio_hw *hw, size_t offset,
>void *dst, int length)
>  {
> rte_eal_pci_ioport_read(>io, dst, length,
> VIRTIO_PCI_CONFIG(hw) + offset);
> +#ifdef RTE_ARCH_PPC_64
> +   switch (length) {
> +   case 4:
> +   *(uint32_t *)dst = rte_be_to_cpu_32(*(uint32_t *)dst);
> +   break;
> +   case 2:
> +   *(uint16_t *)dst = rte_be_to_cpu_16(*(uint16_t *)dst);
> +   break;
> +   default:
> +   break;
> +   }
> +#endif
>  }

I think that, in the original patch, I was handling lengths different
than 1, 2 and 4 ;-)
Idem for write.


-- 
David Marchand


[dpdk-dev] [PATCH v3] i40e: configure MTU

2016-05-13 Thread Beilei Xing
This patch enables configuring MTU for i40e.
Since changing MTU needs to reconfigure queue, stop port first
before configuring MTU.

Signed-off-by: Beilei Xing 
---
v3 changes:
 Add frame size with extra I40E_VLAN_TAG_SIZE.
 Delete i40e_dev_rx_init(pf) cause it will be called when port starts.

v2 changes:
 If mtu is not within the allowed range, return -EINVAL instead of -EBUSY.
 Delete rxq reconfigure cause rxq reconfigure will be finished in
 i40e_dev_rx_init.

 drivers/net/i40e/i40e_ethdev.c | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index d8b6bd7..96d10c2 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -447,6 +447,8 @@ static int i40e_get_eeprom(struct rte_eth_dev *dev,
 static void i40e_set_default_mac_addr(struct rte_eth_dev *dev,
  struct ether_addr *mac_addr);

+static int i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
+
 static const struct rte_pci_id pci_id_i40e_map[] = {
 #define RTE_PCI_DEV_ID_DECL_I40E(vend, dev) {RTE_PCI_DEVICE(vend, dev)},
 #include "rte_pci_dev_ids.h"
@@ -520,6 +522,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
.get_eeprom_length= i40e_get_eeprom_length,
.get_eeprom   = i40e_get_eeprom,
.mac_addr_set = i40e_set_default_mac_addr,
+   .mtu_set  = i40e_dev_mtu_set,
 };

 /* store statistics names and its offset in stats structure */
@@ -9103,3 +9106,34 @@ static void i40e_set_default_mac_addr(struct rte_eth_dev 
*dev,
/* Flags: 0x3 updates port address */
i40e_aq_mac_address_write(hw, 0x3, mac_addr->addr_bytes, NULL);
 }
+
+static int
+i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+   struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+   struct rte_eth_dev_data *dev_data = pf->dev_data;
+   uint32_t frame_size = mtu + ETHER_HDR_LEN
+ + ETHER_CRC_LEN + I40E_VLAN_TAG_SIZE;
+   int ret = 0;
+
+   /* check if mtu is within the allowed range */
+   if ((mtu < ETHER_MIN_MTU) || (frame_size > I40E_FRAME_SIZE_MAX))
+   return -EINVAL;
+
+   /* mtu setting is forbidden if port is start */
+   if (dev_data->dev_started) {
+   PMD_DRV_LOG(ERR,
+   "port %d must be stopped before configuration\n",
+   dev_data->port_id);
+   return -ENOTSUP;
+   }
+
+   if (frame_size > ETHER_MAX_LEN)
+   dev_data->dev_conf.rxmode.jumbo_frame = 1;
+   else
+   dev_data->dev_conf.rxmode.jumbo_frame = 0;
+
+   dev_data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
+
+   return ret;
+}
-- 
2.5.0



[dpdk-dev] [dpdk-dev, 2/3] eth_dev: add support for device dma mask

2016-05-13 Thread Thomas Monjalon
2016-05-13 09:38, Alejandro Lucero:
> On Thu, May 12, 2016 at 4:41 PM, Jan Viktorin 
> > Alejandro Lucero  wrote:
> > > On Thu, May 12, 2016 at 3:52 PM, Jan Viktorin 
> > > > "Alejandro.Lucero"  wrote:
> > > > > - New dma_mask field in rte_eth_dev_data.
> > > > >  - If PMD sets device dma_mask, call to check hugepages within
> > > >
> > > > I think that one of the purposes of DPDK is to support DMA transfers
> > > > in userspace. In other words, I can see no reason to support dma_mask
> > > > at the ethdev level only.
> > > >
> > > > The limitation is a device limitation so I can not see a better place
> > for
> > > adding the device dma mask.
> >
> > That's what I've meant. It is a _device_ limitation. The ethdev is a
> > wrapper
> > around the rte_pci_device. The ethdev just extends semantics of the
> > generic device.
> > However, all DPDK devices are expected to be DMA-capable.
> >
> > If you get a pointer to the ethdev, you get a pointer to the
> > rte_pci_device as well
> > (1 more level of dereference but we are not on the fast path here, so it's
> > unimportant).
> >
> > Consider the cryptodev. If cryptodev has some DMA mask requirements we can
> > support it
> > in the generic place, i.e. rte_pci_device and not rte_ethdev because the
> > cryptodev
> > is not an ethdev.
> >
> Ok. I was wrongly assuming we had just ethdevs, with the ethdev being the
> generic and rte_pci_device being a type of ethdev.
> 
> I can add the dma mask to the rte_pci_dev. The extra level of dereference
> is not a problem as long as we do not use that dma mask for a more complex
> allocation API (more about this later).
> 
> If I understand it right, work is in progress for adding a rte_device. I
> can not see a problem with adding dma mask to the rte_device struct either.
> 
> > > > We should consider adding this to the generic struct rte_device
> > > > (currently rte_pci_device). Thomas?

Yes
This patchset could be split in 2 discussions:
- ability to restrict the physical address range of requested memory,
see the memory allocation rework discussion:
http://dpdk.org/ml/archives/dev/2016-April/037444.html
- DMA range capability in a device, to be done on top of the EAL/device
rework in progress.

This feature is a good candidate for the roadmap of 16.11.



[dpdk-dev] [RFC PATCH] tools:new tool for system info CPU, memory and huge pages

2016-05-13 Thread Wiles, Keith
Sorry this one should have been an RFC instead of a patch.

I create this new tool to combine some information and use /sys/devices 
instead. What I was hoping was some of you could try this script and see if it 
works correctly. Also I was hope to find out if this script is useful and what 
other features you would like in this type of tool.

I am not a Python coder, so if you have suggestions on the code please let me 
know.

Thanks

>The new tool uses /sys/devices instead of /proc directory, which
>does not exist on all systems. If the procfs is not available
>then memory and huge page information is skipped.
>
>The tool also can emit a json format in short or long form to
>allow for machine readable information.
>
>Here is the usage information:
>
>Usage: sys_info.py [options]
>
>Show the lcores layout with core id and socket(s).
>
>Options:
>--help or -h:
>Display the usage information and quit
>
>--long or -l:
>Display the information in a machine readable long format.
>
>--short or -s:
>Display the information in a machine readable short format.
>
>--pci or -p:
>Display all of the Ethernet devices in the system using 'lspci'.
>
>--version or -v:
>Display the current version number of this script.
>
>--debug or -d:
>Output some debug information.
>
>default:
>Display the information in a human readable format.
>
>Signed-off-by: Keith Wiles 
>---
> tools/sys_info.py | 551 ++
> 1 file changed, 551 insertions(+)
> create mode 100755 tools/sys_info.py
>
>diff --git a/tools/sys_info.py b/tools/sys_info.py
>new file mode 100755
>index 000..5e09d12
>--- /dev/null
>+++ b/tools/sys_info.py
>@@ -0,0 +1,551 @@
>+#! /usr/bin/python
>+#
>+#   BSD LICENSE
>+#
>+#   Copyright(c) 2016 Intel Corporation. All rights reserved.
>+#   All rights reserved.
>+#
>+#   Redistribution and use in source and binary forms, with or without
>+#   modification, are permitted provided that the following conditions
>+#   are met:
>+#
>+# * Redistributions of source code must retain the above copyright
>+#   notice, this list of conditions and the following disclaimer.
>+# * Redistributions in binary form must reproduce the above copyright
>+#   notice, this list of conditions and the following disclaimer in
>+#   the documentation and/or other materials provided with the
>+#   distribution.
>+# * Neither the name of Intel Corporation nor the names of its
>+#   contributors may be used to endorse or promote products derived
>+#   from this software without specific prior written permission.
>+#
>+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
>+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
>+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
>+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
>+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
>+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
>+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
>+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
>+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>+#
>+
>+import os, sys
>+import getopt
>+import json
>+from os.path import exists, abspath, dirname, basename
>+
>+version = "0.1.3"
>+
>+# Global lists and flags
>+machine_readable = 0
>+show_pci = False
>+debug_flag = False
>+coremaps_flag = False
>+
>+sys_info = {}
>+coremaps = {}
>+
>+def proc_cpuinfo_path():
>+'''Return the cpu information from /proc'''
>+return "/proc/cpuinfo"
>+
>+def proc_sysinfo_path():
>+'''Return the system path string from /proc'''
>+return "/proc/sysinfo"
>+
>+def proc_meminfo_path():
>+'''Return the memory information path from /proc'''
>+return "/proc/meminfo"
>+
>+def sys_system_path():
>+'''Return the system path string from /sys'''
>+return "/sys/devices/system"
>+
>+def read_file(path, whole_file=False):
>+'''Read the first line of a file'''
>+
>+if os.access(path, os.F_OK) == False:
>+print "Path (%s) Not found" % path
>+return ""
>+
>+fd = open(path)
>+if whole_file == True:
>+lines = fd.readlines()
>+else:
>+line = fd.readline()
>+fd.close()
>+
>+if whole_file == True:
>+return lines
>+
>+return line
>+
>+def get_range(line):
>+'''Split a line and convert to low/high values'''
>+
>+line = line.strip()
>+
>+if '-' in line:
>+low, high = line.split("-")
>+elif ',' in line:
>+low, high = line.split(",")
>+else:
>+return [int(line)]
>+
>+return [int(low), int(high)]
>+
>+def 

[dpdk-dev] [PATCH v2 40/40] bnxt: cleanup null pointer checks

2016-05-13 Thread Stephen Hurd
Prefer !ptr to ptr == NULL

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_ethdev.c | 10 +-
 drivers/net/bnxt/bnxt_filter.c |  2 +-
 drivers/net/bnxt/bnxt_hwrm.c   |  6 +++---
 drivers/net/bnxt/bnxt_ring.c   |  2 +-
 drivers/net/bnxt/bnxt_vnic.c   |  2 +-
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 93dac7a..2f1a85a 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -535,7 +535,7 @@ static void bnxt_promiscuous_enable_op(struct rte_eth_dev 
*eth_dev)
struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
struct bnxt_vnic_info *vnic;

-   if (bp->vnic_info == NULL)
+   if (!bp->vnic_info)
return;

vnic = >vnic_info[0];
@@ -549,7 +549,7 @@ static void bnxt_promiscuous_disable_op(struct rte_eth_dev 
*eth_dev)
struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
struct bnxt_vnic_info *vnic;

-   if (bp->vnic_info == NULL)
+   if (!bp->vnic_info)
return;

vnic = >vnic_info[0];
@@ -563,7 +563,7 @@ static void bnxt_allmulticast_enable_op(struct rte_eth_dev 
*eth_dev)
struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
struct bnxt_vnic_info *vnic;

-   if (bp->vnic_info == NULL)
+   if (!bp->vnic_info)
return;

vnic = >vnic_info[0];
@@ -577,7 +577,7 @@ static void bnxt_allmulticast_disable_op(struct rte_eth_dev 
*eth_dev)
struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
struct bnxt_vnic_info *vnic;

-   if (bp->vnic_info == NULL)
+   if (!bp->vnic_info)
return;

vnic = >vnic_info[0];
@@ -955,7 +955,7 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
}
eth_dev->data->mac_addrs = rte_zmalloc("bnxt_mac_addr_tbl",
ETHER_ADDR_LEN * MAX_NUM_MAC_ADDR, 0);
-   if (eth_dev->data->mac_addrs == NULL) {
+   if (!eth_dev->data->mac_addrs) {
RTE_LOG(ERR, PMD,
"Failed to alloc %u bytes needed to store MAC addr tbl",
ETHER_ADDR_LEN * MAX_NUM_MAC_ADDR);
diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c
index f03a1dc..d2576f7 100644
--- a/drivers/net/bnxt/bnxt_filter.c
+++ b/drivers/net/bnxt/bnxt_filter.c
@@ -165,7 +165,7 @@ int bnxt_alloc_filter_mem(struct bnxt *bp)
filter_mem = rte_zmalloc("bnxt_filter_info",
 max_filters * sizeof(struct bnxt_filter_info),
 0);
-   if (filter_mem == NULL) {
+   if (!filter_mem) {
RTE_LOG(ERR, PMD, "Failed to alloc memory for %d filters",
max_filters);
return -ENOMEM;
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 1a1f108..8994c47 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -431,7 +431,7 @@ int bnxt_hwrm_ver_get(struct bnxt *bp)
rte_free(bp->hwrm_cmd_resp_addr);

bp->hwrm_cmd_resp_addr = rte_malloc(type, max_resp_len, 0);
-   if (bp->hwrm_cmd_resp_addr == NULL) {
+   if (!bp->hwrm_cmd_resp_addr) {
rc = -ENOMEM;
goto error;
}
@@ -1171,7 +1171,7 @@ int bnxt_alloc_hwrm_resources(struct bnxt *bp)
bp->max_req_len = HWRM_MAX_REQ_LEN;
bp->max_resp_len = HWRM_MAX_RESP_LEN;
bp->hwrm_cmd_resp_addr = rte_malloc(type, bp->max_resp_len, 0);
-   if (bp->hwrm_cmd_resp_addr == NULL)
+   if (!bp->hwrm_cmd_resp_addr)
return -ENOMEM;
bp->hwrm_cmd_resp_dma_addr =
rte_malloc_virt2phy(bp->hwrm_cmd_resp_addr);
@@ -1211,7 +1211,7 @@ void bnxt_free_all_hwrm_resources(struct bnxt *bp)
struct bnxt_vnic_info *vnic;
unsigned i;

-   if (bp->vnic_info == NULL)
+   if (!bp->vnic_info)
return;

vnic = >vnic_info[0];
diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c
index 8852e28..91f6371 100644
--- a/drivers/net/bnxt/bnxt_ring.c
+++ b/drivers/net/bnxt/bnxt_ring.c
@@ -143,7 +143,7 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
 SOCKET_ID_ANY,
 RTE_MEMZONE_2MB |
 RTE_MEMZONE_SIZE_HINT_ONLY);
-   if (mz == NULL)
+   if (!mz)
return -ENOMEM;
}
memset(mz->addr, 0, mz->len);
diff --git a/drivers/net/bnxt/bnxt_vnic.c b/drivers/net/bnxt/bnxt_vnic.c
index c04c4c7..e957c0d 100644
--- a/drivers/net/bnxt/bnxt_vnic.c
+++ b/drivers/net/bnxt/bnxt_vnic.c
@@ -267,7 +267,7 @@ int bnxt_alloc_vnic_mem(struct bnxt *bp)
/* Allocate memory for VNIC pool 

[dpdk-dev] [PATCH v2 39/40] bnxt: add flow control operations

2016-05-13 Thread Stephen Hurd
Add flow_ctrl_get and flow_ctrl_set device operations.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_ethdev.c | 83 ++
 1 file changed, 83 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index d14fcae..93dac7a 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -747,6 +747,87 @@ static int bnxt_rss_hash_conf_get_op(struct rte_eth_dev 
*eth_dev,
return 0;
 }

+static int bnxt_flow_ctrl_get_op(struct rte_eth_dev *dev,
+  struct rte_eth_fc_conf *fc_conf __rte_unused)
+{
+   struct bnxt *bp = (struct bnxt *)dev->data->dev_private;
+   struct rte_eth_link link_info;
+   int rc;
+
+   rc = bnxt_get_hwrm_link_config(bp, _info);
+   if (rc)
+   return rc;
+
+   memset(fc_conf, 0, sizeof(*fc_conf));
+   if (bp->link_info.auto_pause)
+   fc_conf->autoneg = 1;
+   switch (bp->link_info.pause) {
+   case 0:
+   fc_conf->mode = RTE_FC_NONE;
+   break;
+   case HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_TX:
+   fc_conf->mode = RTE_FC_TX_PAUSE;
+   break;
+   case HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_RX:
+   fc_conf->mode = RTE_FC_RX_PAUSE;
+   break;
+   case (HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_TX |
+   HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_RX):
+   fc_conf->mode = RTE_FC_FULL;
+   break;
+   }
+   return 0;
+}
+
+static int bnxt_flow_ctrl_set_op(struct rte_eth_dev *dev,
+  struct rte_eth_fc_conf *fc_conf)
+{
+   struct bnxt *bp = (struct bnxt *)dev->data->dev_private;
+
+   switch (fc_conf->mode) {
+   case RTE_FC_NONE:
+   bp->link_info.auto_pause = 0;
+   bp->link_info.force_pause = 0;
+   break;
+   case RTE_FC_RX_PAUSE:
+   if (fc_conf->autoneg) {
+   bp->link_info.auto_pause =
+   HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_RX;
+   bp->link_info.force_pause = 0;
+   } else {
+   bp->link_info.auto_pause = 0;
+   bp->link_info.force_pause =
+   HWRM_PORT_PHY_CFG_INPUT_FORCE_PAUSE_RX;
+   }
+   break;
+   case RTE_FC_TX_PAUSE:
+   if (fc_conf->autoneg) {
+   bp->link_info.auto_pause =
+   HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_TX;
+   bp->link_info.force_pause = 0;
+   } else {
+   bp->link_info.auto_pause = 0;
+   bp->link_info.force_pause =
+   HWRM_PORT_PHY_CFG_INPUT_FORCE_PAUSE_TX;
+   }
+   break;
+   case RTE_FC_FULL:
+   if (fc_conf->autoneg) {
+   bp->link_info.auto_pause =
+   HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_TX |
+   HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_RX;
+   bp->link_info.force_pause = 0;
+   } else {
+   bp->link_info.auto_pause = 0;
+   bp->link_info.force_pause =
+   HWRM_PORT_PHY_CFG_INPUT_FORCE_PAUSE_TX |
+   HWRM_PORT_PHY_CFG_INPUT_FORCE_PAUSE_RX;
+   }
+   break;
+   }
+   return bnxt_set_hwrm_link_config(bp, true);
+}
+
 /*
  * Initialization
  */
@@ -776,6 +857,8 @@ static struct eth_dev_ops bnxt_dev_ops = {
.allmulticast_disable = bnxt_allmulticast_disable_op,
.mac_addr_add = bnxt_mac_addr_add_op,
.mac_addr_remove = bnxt_mac_addr_remove_op,
+   .flow_ctrl_get = bnxt_flow_ctrl_get_op,
+   .flow_ctrl_set = bnxt_flow_ctrl_set_op,
 };

 static bool bnxt_vf_pciid(uint16_t id)
-- 
1.9.1



[dpdk-dev] [PATCH v2 38/40] bnxt: add RSS device operations

2016-05-13 Thread Stephen Hurd
Add rss_hash_update and rss_hash_conf_get

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_ethdev.c | 117 +
 1 file changed, 117 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 2503112..d14fcae 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -62,6 +62,14 @@ static struct rte_pci_id bnxt_pci_id_map[] = {
{.device_id = 0},
 };

+#define BNXT_ETH_RSS_SUPPORT ( \
+   ETH_RSS_IPV4 |  \
+   ETH_RSS_NONFRAG_IPV4_TCP |  \
+   ETH_RSS_NONFRAG_IPV4_UDP |  \
+   ETH_RSS_IPV6 |  \
+   ETH_RSS_NONFRAG_IPV6_TCP |  \
+   ETH_RSS_NONFRAG_IPV6_UDP)
+
 /***/

 /*
@@ -632,6 +640,113 @@ static int bnxt_reta_query_op(struct rte_eth_dev *eth_dev,
return 0;
 }

+static int bnxt_rss_hash_update_op(struct rte_eth_dev *eth_dev,
+  struct rte_eth_rss_conf *rss_conf)
+{
+   struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
+   struct rte_eth_conf *dev_conf = >eth_dev->data->dev_conf;
+   struct bnxt_vnic_info *vnic;
+   uint16_t hash_type = 0;
+   int i;
+
+   /* If RSS enablement were different than dev_configure,
+  then return -EINVAL */
+   if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG) {
+   if (!rss_conf->rss_hf)
+   return -EINVAL;
+   } else {
+   if (rss_conf->rss_hf & BNXT_ETH_RSS_SUPPORT)
+   return -EINVAL;
+   }
+   if (rss_conf->rss_hf & ETH_RSS_IPV4)
+   hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4;
+   if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV4_TCP)
+   hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV4;
+   if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV4_UDP)
+   hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV4;
+   if (rss_conf->rss_hf & ETH_RSS_IPV6)
+   hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV6;
+   if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV6_TCP)
+   hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV6;
+   if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV6_UDP)
+   hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV6;
+
+   /* Update the RSS VNIC(s) */
+   for (i = 0; i < MAX_FF_POOLS; i++) {
+   STAILQ_FOREACH(vnic, >ff_pool[i], next) {
+   vnic->hash_type = hash_type;
+
+   /* Use the supplied key if the key length is
+  acceptable and the rss_key is not NULL */
+   if (rss_conf->rss_key &&
+   rss_conf->rss_key_len <= HW_HASH_KEY_SIZE)
+   memcpy(vnic->rss_hash_key, rss_conf->rss_key,
+  rss_conf->rss_key_len);
+
+   bnxt_hwrm_vnic_rss_cfg(bp, vnic);
+   }
+   }
+   return 0;
+}
+
+static int bnxt_rss_hash_conf_get_op(struct rte_eth_dev *eth_dev,
+struct rte_eth_rss_conf *rss_conf)
+{
+   struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
+   struct bnxt_vnic_info *vnic = >vnic_info[0];
+   int len;
+   uint32_t hash_types;
+
+   /* RSS configuration is the same for all VNICs */
+   if (vnic && vnic->rss_hash_key) {
+   if (rss_conf->rss_key) {
+   len = rss_conf->rss_key_len <= HW_HASH_KEY_SIZE ?
+ rss_conf->rss_key_len : HW_HASH_KEY_SIZE;
+   memcpy(rss_conf->rss_key, vnic->rss_hash_key, len);
+   }
+
+   hash_types = vnic->hash_type;
+   rss_conf->rss_hf = 0;
+   if (hash_types & HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4) {
+   rss_conf->rss_hf |= ETH_RSS_IPV4;
+   hash_types &= ~HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4;
+   }
+   if (hash_types & HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV4) {
+   rss_conf->rss_hf |= ETH_RSS_NONFRAG_IPV4_TCP;
+   hash_types &=
+   ~HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV4;
+   }
+   if (hash_types & HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV4) {
+   rss_conf->rss_hf |= ETH_RSS_NONFRAG_IPV4_UDP;
+   hash_types &=
+   ~HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV4;
+   }
+   if (hash_types & HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV6) {
+   rss_conf->rss_hf |= ETH_RSS_IPV6;
+   hash_types &= ~HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV6;
+   }
+   if (hash_types & HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV6) {
+   

[dpdk-dev] [PATCH v2 37/40] bnxt: add reta update/query operations

2016-05-13 Thread Stephen Hurd
Update/query reta operations

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_ethdev.c | 56 ++
 1 file changed, 56 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 3396079..2503112 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -578,6 +578,60 @@ static void bnxt_allmulticast_disable_op(struct 
rte_eth_dev *eth_dev)
bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic);
 }

+static int bnxt_reta_update_op(struct rte_eth_dev *eth_dev,
+   struct rte_eth_rss_reta_entry64 *reta_conf,
+   uint16_t reta_size)
+{
+   struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
+   struct rte_eth_conf *dev_conf = >eth_dev->data->dev_conf;
+   struct bnxt_vnic_info *vnic;
+   int i;
+
+   if (!(dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG))
+   return -EINVAL;
+
+   if (reta_size != HW_HASH_INDEX_SIZE) {
+   RTE_LOG(ERR, PMD, "The configured hash table lookup size "
+   "(%d) must equal the size supported by the hardware "
+   "(%d)\n", reta_size, HW_HASH_INDEX_SIZE);
+   return -EINVAL;
+   }
+   /* Update the RSS VNIC(s) */
+   for (i = 0; i < MAX_FF_POOLS; i++) {
+   STAILQ_FOREACH(vnic, >ff_pool[i], next) {
+   memcpy(vnic->rss_table, reta_conf, reta_size);
+
+   bnxt_hwrm_vnic_rss_cfg(bp, vnic);
+   }
+   }
+   return 0;
+}
+
+static int bnxt_reta_query_op(struct rte_eth_dev *eth_dev,
+ struct rte_eth_rss_reta_entry64 *reta_conf,
+ uint16_t reta_size)
+{
+   struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
+   struct bnxt_vnic_info *vnic = >vnic_info[0];
+
+   /* Retrieve from the default VNIC */
+   if (!vnic)
+   return -EINVAL;
+   if (!vnic->rss_table)
+   return -EINVAL;
+
+   if (reta_size != HW_HASH_INDEX_SIZE) {
+   RTE_LOG(ERR, PMD, "The configured hash table lookup size "
+   "(%d) must equal the size supported by the hardware "
+   "(%d)\n", reta_size, HW_HASH_INDEX_SIZE);
+   return -EINVAL;
+   }
+   /* EW - need to revisit here copying from u64 to u16 */
+   memcpy(reta_conf, vnic->rss_table, reta_size);
+
+   return 0;
+}
+
 /*
  * Initialization
  */
@@ -596,6 +650,8 @@ static struct eth_dev_ops bnxt_dev_ops = {
.rx_queue_release = bnxt_rx_queue_release_op,
.tx_queue_setup = bnxt_tx_queue_setup_op,
.tx_queue_release = bnxt_tx_queue_release_op,
+   .reta_update = bnxt_reta_update_op,
+   .reta_query = bnxt_reta_query_op,
.link_update = bnxt_link_update_op,
.promiscuous_enable = bnxt_promiscuous_enable_op,
.promiscuous_disable = bnxt_promiscuous_disable_op,
-- 
1.9.1



[dpdk-dev] [PATCH v2 36/40] bnxt: add dev set link up/down operations

2016-05-13 Thread Stephen Hurd
Sets link to up or down as appropriate.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_ethdev.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 7056f98..3396079 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -390,6 +390,24 @@ static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
bnxt_shutdown_nic(bp);
 }

+static int bnxt_dev_set_link_up_op(struct rte_eth_dev *eth_dev)
+{
+   struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
+
+   eth_dev->data->dev_link.link_status = 1;
+   bnxt_set_hwrm_link_config(bp, true);
+   return 0;
+}
+
+static int bnxt_dev_set_link_down_op(struct rte_eth_dev *eth_dev)
+{
+   struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
+
+   eth_dev->data->dev_link.link_status = 0;
+   bnxt_set_hwrm_link_config(bp, false);
+   return 0;
+}
+
 static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev)
 {
struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
@@ -569,6 +587,8 @@ static struct eth_dev_ops bnxt_dev_ops = {
.dev_configure = bnxt_dev_configure_op,
.dev_start = bnxt_dev_start_op,
.dev_stop = bnxt_dev_stop_op,
+   .dev_set_link_up = bnxt_dev_set_link_up_op,
+   .dev_set_link_down = bnxt_dev_set_link_down_op,
.dev_close = bnxt_dev_close_op,
.stats_get = bnxt_stats_get_op,
.stats_reset = bnxt_stats_reset_op,
-- 
1.9.1



[dpdk-dev] [PATCH v2 35/40] bnxt: add MAC address add/remove operations

2016-05-13 Thread Stephen Hurd
Add/remove MAC addresses

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_ethdev.c | 69 ++
 1 file changed, 69 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index edb7427..7056f98 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -400,6 +400,73 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev)
rte_free(eth_dev->data->mac_addrs);
 }

+static void bnxt_mac_addr_remove_op(struct rte_eth_dev *eth_dev,
+   uint32_t index)
+{
+   struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
+   uint64_t pool_mask = eth_dev->data->mac_pool_sel[index];
+   struct bnxt_vnic_info *vnic;
+   struct bnxt_filter_info *filter, *temp_filter;
+   int i;
+
+   /* Loop through all VNICs from the specified filter flow pools to
+  remove the corresponding MAC addr filter */
+   for (i = 0; i < MAX_FF_POOLS; i++) {
+   if (!(pool_mask & (1 << i)))
+   continue;
+
+   STAILQ_FOREACH(vnic, >ff_pool[i], next) {
+   filter = STAILQ_FIRST(>filter);
+   while (filter) {
+   temp_filter = STAILQ_NEXT(filter, next);
+   if (filter->mac_index == index) {
+   STAILQ_REMOVE(>filter, filter,
+ bnxt_filter_info, next);
+   bnxt_hwrm_clear_filter(bp, filter);
+   filter->mac_index = INVALID_MAC_INDEX;
+   memset(>l2_addr, 0,
+  ETHER_ADDR_LEN);
+   STAILQ_INSERT_TAIL(
+   >free_filter_list,
+   filter, next);
+   }
+   filter = temp_filter;
+   }
+   }
+   }
+}
+
+static void bnxt_mac_addr_add_op(struct rte_eth_dev *eth_dev,
+struct ether_addr *mac_addr,
+uint32_t index, uint32_t pool)
+{
+   struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
+   struct bnxt_vnic_info *vnic = STAILQ_FIRST(>ff_pool[pool]);
+   struct bnxt_filter_info *filter;
+
+   if (!vnic) {
+   RTE_LOG(ERR, PMD, "VNIC not found for pool %d!\n", pool);
+   return;
+   }
+   /* Attach requested MAC address to the new l2_filter */
+   STAILQ_FOREACH(filter, >filter, next) {
+   if (filter->mac_index == index) {
+   RTE_LOG(ERR, PMD,
+   "MAC addr already existed for pool %d\n", pool);
+   return;
+   }
+   }
+   filter = bnxt_alloc_filter(bp);
+   if (!filter) {
+   RTE_LOG(ERR, PMD, "L2 filter alloc failed\n");
+   return;
+   }
+   STAILQ_INSERT_TAIL(>filter, filter, next);
+   filter->mac_index = index;
+   memcpy(filter->l2_addr, mac_addr, ETHER_ADDR_LEN);
+   bnxt_hwrm_set_filter(bp, vnic, filter);
+}
+
 static int bnxt_link_update_op(struct rte_eth_dev *eth_dev,
   int wait_to_complete)
 {
@@ -514,6 +581,8 @@ static struct eth_dev_ops bnxt_dev_ops = {
.promiscuous_disable = bnxt_promiscuous_disable_op,
.allmulticast_enable = bnxt_allmulticast_enable_op,
.allmulticast_disable = bnxt_allmulticast_disable_op,
+   .mac_addr_add = bnxt_mac_addr_add_op,
+   .mac_addr_remove = bnxt_mac_addr_remove_op,
 };

 static bool bnxt_vf_pciid(uint16_t id)
-- 
1.9.1



[dpdk-dev] [PATCH v2 34/40] bnxt: add device close operation

2016-05-13 Thread Stephen Hurd
Frees all resources except the hwrm ones, which are required to notify
the HWRM that the driver is unloaded (these are freed in uninit()).

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_ethdev.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 97ef0b4..edb7427 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -390,6 +390,16 @@ static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
bnxt_shutdown_nic(bp);
 }

+static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev)
+{
+   struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
+
+   bnxt_free_tx_mbufs(bp);
+   bnxt_free_rx_mbufs(bp);
+   bnxt_free_mem(bp);
+   rte_free(eth_dev->data->mac_addrs);
+}
+
 static int bnxt_link_update_op(struct rte_eth_dev *eth_dev,
   int wait_to_complete)
 {
@@ -492,6 +502,7 @@ static struct eth_dev_ops bnxt_dev_ops = {
.dev_configure = bnxt_dev_configure_op,
.dev_start = bnxt_dev_start_op,
.dev_stop = bnxt_dev_stop_op,
+   .dev_close = bnxt_dev_close_op,
.stats_get = bnxt_stats_get_op,
.stats_reset = bnxt_stats_reset_op,
.rx_queue_setup = bnxt_rx_queue_setup_op,
-- 
1.9.1



[dpdk-dev] [PATCH v2 33/40] bnxt: add all multicast enable/disable operations

2016-05-13 Thread Stephen Hurd
Enables/disables all multicast traffic.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_ethdev.c | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index f5de4c4..97ef0b4 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -455,6 +455,34 @@ static void bnxt_promiscuous_disable_op(struct rte_eth_dev 
*eth_dev)
bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic);
 }

+static void bnxt_allmulticast_enable_op(struct rte_eth_dev *eth_dev)
+{
+   struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
+   struct bnxt_vnic_info *vnic;
+
+   if (bp->vnic_info == NULL)
+   return;
+
+   vnic = >vnic_info[0];
+
+   vnic->flags |= BNXT_VNIC_INFO_ALLMULTI;
+   bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic);
+}
+
+static void bnxt_allmulticast_disable_op(struct rte_eth_dev *eth_dev)
+{
+   struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
+   struct bnxt_vnic_info *vnic;
+
+   if (bp->vnic_info == NULL)
+   return;
+
+   vnic = >vnic_info[0];
+
+   vnic->flags &= ~BNXT_VNIC_INFO_ALLMULTI;
+   bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic);
+}
+
 /*
  * Initialization
  */
@@ -473,6 +501,8 @@ static struct eth_dev_ops bnxt_dev_ops = {
.link_update = bnxt_link_update_op,
.promiscuous_enable = bnxt_promiscuous_enable_op,
.promiscuous_disable = bnxt_promiscuous_disable_op,
+   .allmulticast_enable = bnxt_allmulticast_enable_op,
+   .allmulticast_disable = bnxt_allmulticast_disable_op,
 };

 static bool bnxt_vf_pciid(uint16_t id)
-- 
1.9.1



[dpdk-dev] [PATCH v2 32/40] bnxt: add promiscuous enable/disable operations

2016-05-13 Thread Stephen Hurd
Enables and diables promiscuous mode.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_ethdev.c | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index a91e1c2..f5de4c4 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -427,6 +427,34 @@ out:
return rc;
 }

+static void bnxt_promiscuous_enable_op(struct rte_eth_dev *eth_dev)
+{
+   struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
+   struct bnxt_vnic_info *vnic;
+
+   if (bp->vnic_info == NULL)
+   return;
+
+   vnic = >vnic_info[0];
+
+   vnic->flags |= BNXT_VNIC_INFO_PROMISC;
+   bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic);
+}
+
+static void bnxt_promiscuous_disable_op(struct rte_eth_dev *eth_dev)
+{
+   struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
+   struct bnxt_vnic_info *vnic;
+
+   if (bp->vnic_info == NULL)
+   return;
+
+   vnic = >vnic_info[0];
+
+   vnic->flags &= ~BNXT_VNIC_INFO_PROMISC;
+   bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic);
+}
+
 /*
  * Initialization
  */
@@ -443,6 +471,8 @@ static struct eth_dev_ops bnxt_dev_ops = {
.tx_queue_setup = bnxt_tx_queue_setup_op,
.tx_queue_release = bnxt_tx_queue_release_op,
.link_update = bnxt_link_update_op,
+   .promiscuous_enable = bnxt_promiscuous_enable_op,
+   .promiscuous_disable = bnxt_promiscuous_disable_op,
 };

 static bool bnxt_vf_pciid(uint16_t id)
-- 
1.9.1



[dpdk-dev] [PATCH v2 31/40] bnxt: add start/stop/link update operations

2016-05-13 Thread Stephen Hurd
BNXT driver will now minimally pass traffic with testpmd.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_ethdev.c | 267 +
 1 file changed, 267 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index e1b3e3a..a91e1c2 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -40,12 +40,17 @@
 #include 

 #include "bnxt.h"
+#include "bnxt_cpr.h"
+#include "bnxt_filter.h"
 #include "bnxt_hwrm.h"
+#include "bnxt_ring.h"
 #include "bnxt_rxq.h"
 #include "bnxt_rxr.h"
 #include "bnxt_stats.h"
 #include "bnxt_txq.h"
 #include "bnxt_txr.h"
+#include "bnxt_vnic.h"
+#include "hsi_struct_def_dpdk.h"

 #define DRV_MODULE_NAME"bnxt"
 static const char bnxt_version[] =
@@ -57,6 +62,175 @@ static struct rte_pci_id bnxt_pci_id_map[] = {
{.device_id = 0},
 };

+/***/
+
+/*
+ * High level utility functions
+ */
+
+static void bnxt_free_mem(struct bnxt *bp)
+{
+   bnxt_free_filter_mem(bp);
+   bnxt_free_vnic_attributes(bp);
+   bnxt_free_vnic_mem(bp);
+
+   bnxt_free_stats(bp);
+   bnxt_free_tx_rings(bp);
+   bnxt_free_rx_rings(bp);
+   bnxt_free_def_cp_ring(bp);
+}
+
+static int bnxt_alloc_mem(struct bnxt *bp)
+{
+   int rc;
+
+   /* Default completion ring */
+   rc = bnxt_init_def_ring_struct(bp, SOCKET_ID_ANY);
+   if (rc)
+   goto alloc_mem_err;
+
+   rc = bnxt_alloc_rings(bp, 0, NULL, NULL,
+ bp->def_cp_ring, "def_cp_ring");
+   if (rc)
+   goto alloc_mem_err;
+
+   rc = bnxt_alloc_vnic_mem(bp);
+   if (rc)
+   goto alloc_mem_err;
+
+   rc = bnxt_alloc_vnic_attributes(bp);
+   if (rc)
+   goto alloc_mem_err;
+
+   rc = bnxt_alloc_filter_mem(bp);
+   if (rc)
+   goto alloc_mem_err;
+
+   return 0;
+
+alloc_mem_err:
+   bnxt_free_mem(bp);
+   return rc;
+}
+
+static int bnxt_init_chip(struct bnxt *bp)
+{
+   unsigned i, rss_idx, fw_idx;
+   int rc;
+
+   rc = bnxt_alloc_all_hwrm_stat_ctxs(bp);
+   if (rc) {
+   RTE_LOG(ERR, PMD, "HWRM stat ctx alloc failure rc: %x\n", rc);
+   goto err_out;
+   }
+
+   rc = bnxt_alloc_hwrm_rings(bp);
+   if (rc) {
+   RTE_LOG(ERR, PMD, "HWRM ring alloc failure rc: %x\n", rc);
+   goto err_out;
+   }
+
+   rc = bnxt_alloc_all_hwrm_ring_grps(bp);
+   if (rc) {
+   RTE_LOG(ERR, PMD, "HWRM ring grp alloc failure: %x\n", rc);
+   goto err_out;
+   }
+
+   rc = bnxt_mq_rx_configure(bp);
+   if (rc) {
+   RTE_LOG(ERR, PMD, "MQ mode configure failure rc: %x\n", rc);
+   goto err_out;
+   }
+
+   /* VNIC configuration */
+   for (i = 0; i < bp->nr_vnics; i++) {
+   struct bnxt_vnic_info *vnic = >vnic_info[i];
+
+   rc = bnxt_hwrm_vnic_alloc(bp, vnic);
+   if (rc) {
+   RTE_LOG(ERR, PMD, "HWRM vnic alloc failure rc: %x\n",
+   rc);
+   goto err_out;
+   }
+
+   rc = bnxt_hwrm_vnic_ctx_alloc(bp, vnic);
+   if (rc) {
+   RTE_LOG(ERR, PMD,
+   "HWRM vnic ctx alloc failure rc: %x\n", rc);
+   goto err_out;
+   }
+
+   rc = bnxt_hwrm_vnic_cfg(bp, vnic);
+   if (rc) {
+   RTE_LOG(ERR, PMD, "HWRM vnic cfg failure rc: %x\n", rc);
+   goto err_out;
+   }
+
+   rc = bnxt_set_hwrm_vnic_filters(bp, vnic);
+   if (rc) {
+   RTE_LOG(ERR, PMD, "HWRM vnic filter failure rc: %x\n",
+   rc);
+   goto err_out;
+   }
+   if (vnic->rss_table && vnic->hash_type) {
+   /* Fill the RSS hash & redirection table with
+  ring group ids for all VNICs */
+   for (rss_idx = 0, fw_idx = 0;
+rss_idx < HW_HASH_INDEX_SIZE;
+rss_idx++, fw_idx++) {
+   if (vnic->fw_grp_ids[fw_idx] ==
+   INVALID_HW_RING_ID)
+   fw_idx = 0;
+   vnic->rss_table[rss_idx] =
+   vnic->fw_grp_ids[fw_idx];
+   }
+   rc = bnxt_hwrm_vnic_rss_cfg(bp, vnic);
+   if (rc) {
+   RTE_LOG(ERR, PMD,
+   "HWRM vnic set RSS failure rc: %x\n",
+   rc);
+   goto err_out;
+   

[dpdk-dev] [PATCH v2 30/40] bnxt: add HWRM port phy qcfg call and wrapper

2016-05-13 Thread Stephen Hurd
Add HWRM port pgy qcfg HWRM command and bnxt_get_hwrm_link_config()
wrapper which parses the link state.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_hwrm.c   | 120 +
 drivers/net/bnxt/bnxt_hwrm.h   |   1 +
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 790 +
 3 files changed, 911 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 897e766..1a1f108 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -521,6 +521,43 @@ static int bnxt_hwrm_port_phy_cfg(struct bnxt *bp, struct 
bnxt_link_info *conf)
return rc;
 }

+static int bnxt_hwrm_port_phy_qcfg(struct bnxt *bp,
+  struct bnxt_link_info *link_info)
+{
+   int rc = 0;
+   struct hwrm_port_phy_qcfg_input req = {.req_type = 0};
+   struct hwrm_port_phy_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
+
+   HWRM_PREP(req, PORT_PHY_QCFG, -1, resp);
+
+   rc = bnxt_hwrm_send_message(bp, , sizeof(req));
+
+   HWRM_CHECK_RESULT;
+
+   link_info->phy_link_status = resp->link;
+   if (link_info->phy_link_status == HWRM_PORT_PHY_QCFG_OUTPUT_LINK_LINK) {
+   link_info->link_up = 1;
+   link_info->link_speed = rte_le_to_cpu_16(resp->link_speed);
+   } else {
+   link_info->link_up = 0;
+   link_info->link_speed = 0;
+   }
+   link_info->duplex = resp->duplex;
+   link_info->pause = resp->pause;
+   link_info->auto_pause = resp->auto_pause;
+   link_info->force_pause = resp->force_pause;
+   link_info->auto_mode = resp->auto_mode;
+
+   link_info->support_speeds = rte_le_to_cpu_16(resp->support_speeds);
+   link_info->auto_link_speed = rte_le_to_cpu_16(resp->auto_link_speed);
+   link_info->preemphasis = rte_le_to_cpu_32(resp->preemphasis);
+   link_info->phy_ver[0] = resp->phy_maj;
+   link_info->phy_ver[1] = resp->phy_min;
+   link_info->phy_ver[2] = resp->phy_bld;
+
+   return rc;
+}
+
 int bnxt_hwrm_queue_qportcfg(struct bnxt *bp)
 {
int rc = 0;
@@ -1326,6 +1363,89 @@ static uint16_t bnxt_parse_eth_link_speed_mask(uint32_t 
link_speed)
return ret;
 }

+static uint32_t bnxt_parse_hw_link_speed(uint16_t hw_link_speed)
+{
+   uint32_t eth_link_speed = ETH_SPEED_NUM_NONE;
+
+   switch (hw_link_speed) {
+   case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100MB:
+   eth_link_speed = ETH_SPEED_NUM_100M;
+   break;
+   case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_1GB:
+   eth_link_speed = ETH_SPEED_NUM_1G;
+   break;
+   case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2_5GB:
+   eth_link_speed = ETH_SPEED_NUM_2_5G;
+   break;
+   case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_10GB:
+   eth_link_speed = ETH_SPEED_NUM_10G;
+   break;
+   case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_20GB:
+   eth_link_speed = ETH_SPEED_NUM_20G;
+   break;
+   case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_25GB:
+   eth_link_speed = ETH_SPEED_NUM_25G;
+   break;
+   case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_40GB:
+   eth_link_speed = ETH_SPEED_NUM_40G;
+   break;
+   case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_50GB:
+   eth_link_speed = ETH_SPEED_NUM_50G;
+   break;
+   case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2GB:
+   default:
+   RTE_LOG(ERR, PMD, "HWRM link speed %d not defined\n",
+   hw_link_speed);
+   break;
+   }
+   return eth_link_speed;
+}
+
+static uint16_t bnxt_parse_hw_link_duplex(uint16_t hw_link_duplex)
+{
+   uint16_t eth_link_duplex = ETH_LINK_FULL_DUPLEX;
+
+   switch (hw_link_duplex) {
+   case HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_BOTH:
+   case HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_FULL:
+   eth_link_duplex = ETH_LINK_FULL_DUPLEX;
+   break;
+   case HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_HALF:
+   eth_link_duplex = ETH_LINK_HALF_DUPLEX;
+   break;
+   default:
+   RTE_LOG(ERR, PMD, "HWRM link duplex %d not defined\n",
+   hw_link_duplex);
+   break;
+   }
+   return eth_link_duplex;
+}
+
+int bnxt_get_hwrm_link_config(struct bnxt *bp, struct rte_eth_link *link)
+{
+   int rc = 0;
+   struct bnxt_link_info *link_info = >link_info;
+
+   rc = bnxt_hwrm_port_phy_qcfg(bp, link_info);
+   if (rc) {
+   RTE_LOG(ERR, PMD,
+   "Get link config failed with rc %d\n", rc);
+   goto exit;
+   }
+   if (link_info->link_up)
+   link->link_speed =
+   bnxt_parse_hw_link_speed(link_info->link_speed);
+   else
+   link->link_speed = ETH_LINK_SPEED_10M;
+

[dpdk-dev] [PATCH v2 29/40] bnxt: work around HWRM error when creating rings

2016-05-13 Thread Stephen Hurd
Some HWRM versions will stop responding if we request poll mode interrupt.
As a workaround, request an MSI interrupt even though we never enable it.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_hwrm.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index b5bc473..897e766 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -581,7 +581,11 @@ int bnxt_hwrm_ring_alloc(struct bnxt *bp,
break;
case HWRM_RING_ALLOC_INPUT_RING_TYPE_CMPL:
req.ring_type = ring_type;
-   req.int_mode = HWRM_RING_ALLOC_INPUT_INT_MODE_POLL;
+   /*
+* TODO: Some HWRM versions crash with
+* HWRM_RING_ALLOC_INPUT_INT_MODE_POLL
+*/
+   req.int_mode = HWRM_RING_ALLOC_INPUT_INT_MODE_MSIX;
req.length = rte_cpu_to_le_32(ring->ring_size);
break;
default:
-- 
1.9.1



[dpdk-dev] [PATCH v2 28/40] bnxt: add ring allocation and group init

2016-05-13 Thread Stephen Hurd
Add a function to initialize ring groups, and a function to
allocate the rings via HWRM.

This should be the last functionality needed to add start/stop
device operations.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_ring.c | 119 +++
 drivers/net/bnxt/bnxt_ring.h |   2 +
 2 files changed, 121 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c
index 69837bf..8852e28 100644
--- a/drivers/net/bnxt/bnxt_ring.c
+++ b/drivers/net/bnxt/bnxt_ring.c
@@ -35,8 +35,11 @@

 #include "bnxt.h"
 #include "bnxt_cpr.h"
+#include "bnxt_hwrm.h"
 #include "bnxt_ring.h"
+#include "bnxt_rxq.h"
 #include "bnxt_rxr.h"
+#include "bnxt_txq.h"
 #include "bnxt_txr.h"

 #include "hsi_struct_def_dpdk.h"
@@ -58,6 +61,19 @@ void bnxt_free_ring(struct bnxt_ring_struct *ring)
 }

 /*
+ * Ring groups
+ */
+
+void bnxt_init_ring_grps(struct bnxt *bp)
+{
+   unsigned i;
+
+   for (i = 0; i < bp->max_ring_grps; i++)
+   memset(>grp_info[i], (uint8_t)HWRM_NA_SIGNATURE,
+  sizeof(struct bnxt_ring_grp_info));
+}
+
+/*
  * Allocates a completion ring with vmem and stats optionally also allocating
  * a TX and/or RX ring.  Passing NULL as tx_ring_info and/or rx_ring_info
  * to not allocate them.
@@ -185,3 +201,106 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
cp_ring_info->hw_stats_ctx_id = HWRM_NA_SIGNATURE;
return 0;
 }
+
+/* ring_grp usage:
+ * [0] = default completion ring
+ * [1 -> +rx_cp_nr_rings] = rx_cp, rx rings
+ * [1+rx_cp_nr_rings + 1 -> +tx_cp_nr_rings] = tx_cp, tx rings
+ */
+int bnxt_alloc_hwrm_rings(struct bnxt *bp)
+{
+   unsigned i;
+   int rc = 0;
+
+   /* Default completion ring */
+   {
+   struct bnxt_cp_ring_info *cpr = bp->def_cp_ring;
+   struct bnxt_ring_struct *cp_ring = cpr->cp_ring_struct;
+
+   rc = bnxt_hwrm_ring_alloc(bp, cp_ring,
+ HWRM_RING_ALLOC_INPUT_RING_TYPE_CMPL,
+ 0, HWRM_NA_SIGNATURE);
+   if (rc)
+   goto err_out;
+   cpr->cp_doorbell =
+   (char *)bp->eth_dev->pci_dev->mem_resource[2].addr;
+   B_CP_DIS_DB(cpr, cpr->cp_raw_cons);
+   bp->grp_info[0].cp_fw_ring_id = cp_ring->fw_ring_id;
+   }
+
+   for (i = 0; i < bp->rx_cp_nr_rings; i++) {
+   struct bnxt_rx_queue *rxq = bp->rx_queues[i];
+   struct bnxt_cp_ring_info *cpr = rxq->cp_ring;
+   struct bnxt_ring_struct *cp_ring = cpr->cp_ring_struct;
+   struct bnxt_rx_ring_info *rxr = rxq->rx_ring;
+   struct bnxt_ring_struct *ring = rxr->rx_ring_struct;
+   unsigned idx = i + 1;
+
+   /* Rx cmpl */
+   rc = bnxt_hwrm_ring_alloc(bp, cp_ring,
+   HWRM_RING_ALLOC_INPUT_RING_TYPE_CMPL,
+   idx, HWRM_NA_SIGNATURE);
+   if (rc)
+   goto err_out;
+   cpr->cp_doorbell =
+   (char *)bp->eth_dev->pci_dev->mem_resource[2].addr +
+   idx * 0x80;
+   bp->grp_info[idx].cp_fw_ring_id = cp_ring->fw_ring_id;
+   B_CP_DIS_DB(cpr, cpr->cp_raw_cons);
+
+   /* Rx ring */
+   rc = bnxt_hwrm_ring_alloc(bp, ring,
+   HWRM_RING_ALLOC_INPUT_RING_TYPE_RX,
+   idx, cpr->hw_stats_ctx_id);
+   if (rc)
+   goto err_out;
+   rxr->rx_prod = 0;
+   rxr->rx_doorbell =
+   (char *)bp->eth_dev->pci_dev->mem_resource[2].addr +
+   idx * 0x80;
+   bp->grp_info[idx].rx_fw_ring_id = ring->fw_ring_id;
+   B_RX_DB(rxr->rx_doorbell, rxr->rx_prod);
+   if (bnxt_init_one_rx_ring(rxq)) {
+   RTE_LOG(ERR, PMD, "bnxt_init_one_rx_ring failed!");
+   bnxt_rx_queue_release_op(rxq);
+   return -ENOMEM;
+   }
+   B_RX_DB(rxr->rx_doorbell, rxr->rx_prod);
+   }
+
+   for (i = 0; i < bp->tx_cp_nr_rings; i++) {
+   struct bnxt_tx_queue *txq = bp->tx_queues[i];
+   struct bnxt_cp_ring_info *cpr = txq->cp_ring;
+   struct bnxt_ring_struct *cp_ring = cpr->cp_ring_struct;
+   struct bnxt_tx_ring_info *txr = txq->tx_ring;
+   struct bnxt_ring_struct *ring = txr->tx_ring_struct;
+   unsigned idx = 1 + bp->rx_cp_nr_rings + i;
+
+   /* Tx cmpl */
+   rc = bnxt_hwrm_ring_alloc(bp, cp_ring,
+   HWRM_RING_ALLOC_INPUT_RING_TYPE_CMPL,
+   idx, HWRM_NA_SIGNATURE);
+   if (rc)
+ 

[dpdk-dev] [PATCH v2 27/40] bnxt: add struct forward decl

2016-05-13 Thread Stephen Hurd
Add missing forward declaration of struct bnxt_ring_struct to avoid
requiring additional headers for the function declaation.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_hwrm.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
index b7a3f24..8ad91d3 100644
--- a/drivers/net/bnxt/bnxt_hwrm.h
+++ b/drivers/net/bnxt/bnxt_hwrm.h
@@ -42,6 +42,7 @@
 struct bnxt;
 struct bnxt_filter_info;
 struct bnxt_cp_ring_info;
+struct bnxt_ring_struct;
 int bnxt_hwrm_cfa_l2_clear_rx_mask(struct bnxt *bp,
   struct bnxt_vnic_info *vnic);
 int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp, struct bnxt_vnic_info *vnic);
-- 
1.9.1



[dpdk-dev] [PATCH v2 26/40] bnxt: add HWRM stat context free function

2016-05-13 Thread Stephen Hurd
Add function and associated structures and definitions as well as
some convenienct functions for manipulating the state of the entire
function.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_hwrm.c   | 219 +
 drivers/net/bnxt/bnxt_hwrm.h   |  10 ++
 drivers/net/bnxt/hsi_struct_def_dpdk.h |  81 
 3 files changed, 310 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 027a2e8..b5bc473 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -43,8 +43,10 @@
 #include "bnxt_filter.h"
 #include "bnxt_hwrm.h"
 #include "bnxt_rxq.h"
+#include "bnxt_rxr.h"
 #include "bnxt_ring.h"
 #include "bnxt_txq.h"
+#include "bnxt_txr.h"
 #include "bnxt_vnic.h"
 #include "hsi_struct_def_dpdk.h"

@@ -206,6 +208,49 @@ int bnxt_hwrm_clear_filter(struct bnxt *bp,
return 0;
 }

+int bnxt_hwrm_set_filter(struct bnxt *bp,
+struct bnxt_vnic_info *vnic,
+struct bnxt_filter_info *filter)
+{
+   int rc = 0;
+   struct hwrm_cfa_l2_filter_alloc_input req = {.req_type = 0 };
+   struct hwrm_cfa_l2_filter_alloc_output *resp = bp->hwrm_cmd_resp_addr;
+   uint32_t enables = 0;
+
+   HWRM_PREP(req, CFA_L2_FILTER_ALLOC, -1, resp);
+
+   req.flags = rte_cpu_to_le_32(filter->flags);
+
+   enables = filter->enables |
+ HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_DST_ID;
+   req.dst_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
+
+   if (enables &
+   HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR)
+   memcpy(req.l2_addr, filter->l2_addr,
+  ETHER_ADDR_LEN);
+   if (enables &
+   HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR_MASK)
+   memcpy(req.l2_addr_mask, filter->l2_addr_mask,
+  ETHER_ADDR_LEN);
+   if (enables &
+   HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_OVLAN)
+   req.l2_ovlan = filter->l2_ovlan;
+   if (enables &
+   HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_OVLAN_MASK)
+   req.l2_ovlan_mask = filter->l2_ovlan_mask;
+
+   req.enables = rte_cpu_to_le_32(enables);
+
+   rc = bnxt_hwrm_send_message(bp, , sizeof(req));
+
+   HWRM_CHECK_RESULT;
+
+   filter->fw_l2_filter_id = rte_le_to_cpu_64(resp->l2_filter_id);
+
+   return rc;
+}
+
 int bnxt_hwrm_exec_fwd_resp(struct bnxt *bp, void *fwd_cmd)
 {
int rc;
@@ -699,6 +744,28 @@ int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp,
return rc;
 }

+int bnxt_hwrm_stat_ctx_free(struct bnxt *bp,
+   struct bnxt_cp_ring_info *cpr, unsigned idx)
+{
+   int rc;
+   struct hwrm_stat_ctx_free_input req = {.req_type = 0 };
+   struct hwrm_stat_ctx_free_output *resp = bp->hwrm_cmd_resp_addr;
+
+   HWRM_PREP(req, STAT_CTX_FREE, -1, resp);
+
+   req.stat_ctx_id = rte_cpu_to_le_16(cpr->hw_stats_ctx_id);
+   req.seq_id = rte_cpu_to_le_16(bp->hwrm_cmd_seq++);
+
+   rc = bnxt_hwrm_send_message(bp, , sizeof(req));
+
+   HWRM_CHECK_RESULT;
+
+   cpr->hw_stats_ctx_id = HWRM_NA_SIGNATURE;
+   bp->grp_info[idx].fw_stats_ctx = cpr->hw_stats_ctx_id;
+
+   return rc;
+}
+
 int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic)
 {
int rc = 0, i, j;
@@ -875,6 +942,28 @@ int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp)
return 0;
 }

+int bnxt_free_all_hwrm_stat_ctxs(struct bnxt *bp)
+{
+   int rc;
+   unsigned i;
+   struct bnxt_cp_ring_info *cpr;
+
+   for (i = 0; i < bp->rx_cp_nr_rings + bp->tx_cp_nr_rings; i++) {
+   unsigned idx = i + 1;
+
+   if (i >= bp->rx_cp_nr_rings)
+   cpr = bp->tx_queues[i - bp->rx_cp_nr_rings]->cp_ring;
+   else
+   cpr = bp->rx_queues[i]->cp_ring;
+   if (cpr->hw_stats_ctx_id != HWRM_NA_SIGNATURE) {
+   rc = bnxt_hwrm_stat_ctx_free(bp, cpr, idx);
+   if (rc)
+   return rc;
+   }
+   }
+   return 0;
+}
+
 int bnxt_alloc_all_hwrm_stat_ctxs(struct bnxt *bp)
 {
unsigned i;
@@ -925,6 +1014,84 @@ int bnxt_free_all_hwrm_ring_grps(struct bnxt *bp)
return rc;
 }

+static void bnxt_free_cp_ring(struct bnxt *bp,
+ struct bnxt_cp_ring_info *cpr, unsigned idx)
+{
+   struct bnxt_ring_struct *cp_ring = cpr->cp_ring_struct;
+
+   bnxt_hwrm_ring_free(bp, cp_ring,
+   HWRM_RING_FREE_INPUT_RING_TYPE_CMPL);
+   cp_ring->fw_ring_id = INVALID_HW_RING_ID;
+   bp->grp_info[idx].cp_fw_ring_id = INVALID_HW_RING_ID;
+   memset(cpr->cp_desc_ring, 0, cpr->cp_ring_struct->ring_size *
+   sizeof(*cpr->cp_desc_ring));
+   cpr->cp_raw_cons = 0;
+}
+
+int bnxt_free_all_hwrm_rings(struct bnxt *bp)
+{
+   

[dpdk-dev] [PATCH v2 25/40] bnxt: add ring group alloc/free functions

2016-05-13 Thread Stephen Hurd
Add HWRM ring group add/free functions and associated structs and
definitions.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_hwrm.c   |  84 +++
 drivers/net/bnxt/bnxt_hwrm.h   |   4 +
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 185 +
 3 files changed, 273 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 6a92089..027a2e8 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -612,6 +612,47 @@ int bnxt_hwrm_ring_free(struct bnxt *bp,
return 0;
 }

+int bnxt_hwrm_ring_grp_alloc(struct bnxt *bp, unsigned idx)
+{
+   int rc = 0;
+   struct hwrm_ring_grp_alloc_input req = {.req_type = 0 };
+   struct hwrm_ring_grp_alloc_output *resp = bp->hwrm_cmd_resp_addr;
+
+   HWRM_PREP(req, RING_GRP_ALLOC, -1, resp);
+
+   req.cr = rte_cpu_to_le_16(bp->grp_info[idx].cp_fw_ring_id);
+   req.rr = rte_cpu_to_le_16(bp->grp_info[idx].rx_fw_ring_id);
+   req.ar = rte_cpu_to_le_16(bp->grp_info[idx].ag_fw_ring_id);
+   req.sc = rte_cpu_to_le_16(bp->grp_info[idx].fw_stats_ctx);
+
+   rc = bnxt_hwrm_send_message(bp, , sizeof(req));
+
+   HWRM_CHECK_RESULT;
+
+   bp->grp_info[idx].fw_grp_id =
+   rte_le_to_cpu_16(resp->ring_group_id);
+
+   return rc;
+}
+
+int bnxt_hwrm_ring_grp_free(struct bnxt *bp, unsigned idx)
+{
+   int rc;
+   struct hwrm_ring_grp_free_input req = {.req_type = 0 };
+   struct hwrm_ring_grp_free_output *resp = bp->hwrm_cmd_resp_addr;
+
+   HWRM_PREP(req, RING_GRP_FREE, -1, resp);
+
+   req.ring_group_id = rte_cpu_to_le_16(bp->grp_info[idx].fw_grp_id);
+
+   rc = bnxt_hwrm_send_message(bp, , sizeof(req));
+
+   HWRM_CHECK_RESULT;
+
+   bp->grp_info[idx].fw_grp_id = INVALID_HW_RING_ID;
+   return rc;
+}
+
 int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
 {
int rc = 0;
@@ -861,6 +902,49 @@ int bnxt_alloc_all_hwrm_stat_ctxs(struct bnxt *bp)
return rc;
 }

+int bnxt_free_all_hwrm_ring_grps(struct bnxt *bp)
+{
+   uint16_t i;
+   uint32_t rc = 0;
+
+   for (i = 0; i < bp->rx_cp_nr_rings; i++) {
+   unsigned idx = i + 1;
+
+   if (bp->grp_info[idx].fw_grp_id == INVALID_HW_RING_ID) {
+   RTE_LOG(ERR, PMD,
+   "Attempt to free invalid ring group %d\n",
+   idx);
+   continue;
+   }
+
+   rc = bnxt_hwrm_ring_grp_free(bp, idx);
+
+   if (rc)
+   return rc;
+   }
+   return rc;
+}
+
+int bnxt_alloc_all_hwrm_ring_grps(struct bnxt *bp)
+{
+   uint16_t i;
+   uint32_t rc = 0;
+
+   for (i = 0; i < bp->rx_cp_nr_rings; i++) {
+   unsigned idx = i + 1;
+
+   if (bp->grp_info[idx].cp_fw_ring_id == INVALID_HW_RING_ID ||
+   bp->grp_info[idx].rx_fw_ring_id == INVALID_HW_RING_ID)
+   continue;
+
+   rc = bnxt_hwrm_ring_grp_alloc(bp, idx);
+
+   if (rc)
+   return rc;
+   }
+   return rc;
+}
+
 void bnxt_free_hwrm_resources(struct bnxt *bp)
 {
/* Release memzone */
diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
index 40accbc..b65d692 100644
--- a/drivers/net/bnxt/bnxt_hwrm.h
+++ b/drivers/net/bnxt/bnxt_hwrm.h
@@ -64,6 +64,8 @@ int bnxt_hwrm_ring_alloc(struct bnxt *bp,
 uint32_t stats_ctx_id);
 int bnxt_hwrm_ring_free(struct bnxt *bp,
struct bnxt_ring_struct *ring, uint32_t ring_type);
+int bnxt_hwrm_ring_grp_alloc(struct bnxt *bp, unsigned idx);
+int bnxt_hwrm_ring_grp_free(struct bnxt *bp, unsigned idx);

 int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr);
 int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp,
@@ -81,6 +83,8 @@ int bnxt_hwrm_vnic_rss_cfg(struct bnxt *bp,

 int bnxt_alloc_all_hwrm_stat_ctxs(struct bnxt *bp);
 int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp);
+int bnxt_free_all_hwrm_ring_grps(struct bnxt *bp);
+int bnxt_alloc_all_hwrm_ring_grps(struct bnxt *bp);
 void bnxt_free_hwrm_resources(struct bnxt *bp);
 int bnxt_alloc_hwrm_resources(struct bnxt *bp);
 int bnxt_set_hwrm_link_config(struct bnxt *bp, bool link_up);
diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h 
b/drivers/net/bnxt/hsi_struct_def_dpdk.h
index 16ac528..12a28ba 100644
--- a/drivers/net/bnxt/hsi_struct_def_dpdk.h
+++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h
@@ -95,6 +95,8 @@ typedef struct ctx_hw_stats64 {
 #define HWRM_VNIC_RSS_CFG  (UINT32_C(0x46))
 #define HWRM_RING_ALLOC(UINT32_C(0x50))
 #define HWRM_RING_FREE (UINT32_C(0x51))
+#define HWRM_RING_GRP_ALLOC(UINT32_C(0x60))
+#define HWRM_RING_GRP_FREE (UINT32_C(0x61))
 #define 

[dpdk-dev] [PATCH v2 24/40] bnxt: add HWRM ring alloc/free functions

2016-05-13 Thread Stephen Hurd
Add HWRM calls to allocate and free TX/RX/CMPL rings along with
the associated structs and definitions.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_hwrm.c   | 108 
 drivers/net/bnxt/bnxt_hwrm.h   |   7 +
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 305 +
 3 files changed, 420 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 2993aef..6a92089 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -504,6 +504,114 @@ int bnxt_hwrm_queue_qportcfg(struct bnxt *bp)
return rc;
 }

+int bnxt_hwrm_ring_alloc(struct bnxt *bp,
+struct bnxt_ring_struct *ring,
+uint32_t ring_type, uint32_t map_index,
+uint32_t stats_ctx_id)
+{
+   int rc = 0;
+   struct hwrm_ring_alloc_input req = {.req_type = 0 };
+   struct hwrm_ring_alloc_output *resp = bp->hwrm_cmd_resp_addr;
+
+   HWRM_PREP(req, RING_ALLOC, -1, resp);
+
+   req.enables = rte_cpu_to_le_32(0);
+
+   req.page_tbl_addr = rte_cpu_to_le_64(ring->bd_dma);
+   req.fbo = rte_cpu_to_le_32(0);
+   /* Association of ring index with doorbell index */
+   req.logical_id = rte_cpu_to_le_16(map_index);
+
+   switch (ring_type) {
+   case HWRM_RING_ALLOC_INPUT_RING_TYPE_TX:
+   req.queue_id = bp->cos_queue[0].id;
+   case HWRM_RING_ALLOC_INPUT_RING_TYPE_RX:
+   req.ring_type = ring_type;
+   req.cmpl_ring_id =
+   rte_cpu_to_le_16(bp->grp_info[map_index].cp_fw_ring_id);
+   req.length = rte_cpu_to_le_32(ring->ring_size);
+   req.stat_ctx_id = rte_cpu_to_le_16(stats_ctx_id);
+   req.enables = rte_cpu_to_le_32(rte_le_to_cpu_32(req.enables) |
+   HWRM_RING_ALLOC_INPUT_ENABLES_STAT_CTX_ID_VALID);
+   break;
+   case HWRM_RING_ALLOC_INPUT_RING_TYPE_CMPL:
+   req.ring_type = ring_type;
+   req.int_mode = HWRM_RING_ALLOC_INPUT_INT_MODE_POLL;
+   req.length = rte_cpu_to_le_32(ring->ring_size);
+   break;
+   default:
+   RTE_LOG(ERR, PMD, "hwrm alloc invalid ring type %d\n",
+   ring_type);
+   return -1;
+   }
+
+   rc = bnxt_hwrm_send_message(bp, , sizeof(req));
+
+   if (rc || resp->error_code) {
+   if (rc == 0 && resp->error_code)
+   rc = rte_le_to_cpu_16(resp->error_code);
+   switch (ring_type) {
+   case HWRM_RING_FREE_INPUT_RING_TYPE_CMPL:
+   RTE_LOG(ERR, PMD,
+   "hwrm_ring_alloc cp failed. rc:%d\n", rc);
+   return rc;
+   case HWRM_RING_FREE_INPUT_RING_TYPE_RX:
+   RTE_LOG(ERR, PMD,
+   "hwrm_ring_alloc rx failed. rc:%d\n", rc);
+   return rc;
+   case HWRM_RING_FREE_INPUT_RING_TYPE_TX:
+   RTE_LOG(ERR, PMD,
+   "hwrm_ring_alloc tx failed. rc:%d\n", rc);
+   return rc;
+   default:
+   RTE_LOG(ERR, PMD, "Invalid ring. rc:%d\n", rc);
+   return rc;
+   }
+   }
+
+   ring->fw_ring_id = rte_le_to_cpu_16(resp->ring_id);
+   return rc;
+}
+
+int bnxt_hwrm_ring_free(struct bnxt *bp,
+   struct bnxt_ring_struct *ring, uint32_t ring_type)
+{
+   int rc;
+   struct hwrm_ring_free_input req = {.req_type = 0 };
+   struct hwrm_ring_free_output *resp = bp->hwrm_cmd_resp_addr;
+
+   HWRM_PREP(req, RING_FREE, -1, resp);
+
+   req.ring_type = ring_type;
+   req.ring_id = rte_cpu_to_le_16(ring->fw_ring_id);
+
+   rc = bnxt_hwrm_send_message(bp, , sizeof(req));
+
+   if (rc || resp->error_code) {
+   if (rc == 0 && resp->error_code)
+   rc = rte_le_to_cpu_16(resp->error_code);
+
+   switch (ring_type) {
+   case HWRM_RING_FREE_INPUT_RING_TYPE_CMPL:
+   RTE_LOG(ERR, PMD, "hwrm_ring_free cp failed. rc:%d\n",
+   rc);
+   return rc;
+   case HWRM_RING_FREE_INPUT_RING_TYPE_RX:
+   RTE_LOG(ERR, PMD, "hwrm_ring_free rx failed. rc:%d\n",
+   rc);
+   return rc;
+   case HWRM_RING_FREE_INPUT_RING_TYPE_TX:
+   RTE_LOG(ERR, PMD, "hwrm_ring_free tx failed. rc:%d\n",
+   rc);
+   return rc;
+   default:
+   RTE_LOG(ERR, PMD, "Invalid ring, rc:%d\n", rc);
+   return rc;
+   }
+   }
+   return 0;
+}
+
 int 

[dpdk-dev] [PATCH v2 23/40] bnxt: add HWRM stats context allocation

2016-05-13 Thread Stephen Hurd
Add HWRM code to allocate a statistics context and a helper function
to allocate one for evert completion ring.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_hwrm.c   | 52 
 drivers/net/bnxt/bnxt_hwrm.h   |  3 ++
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 89 ++
 3 files changed, 144 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 44c6e80..2993aef 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -525,6 +525,31 @@ int bnxt_hwrm_stat_clear(struct bnxt *bp, struct 
bnxt_cp_ring_info *cpr)
return rc;
 }

+int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp,
+struct bnxt_cp_ring_info *cpr, unsigned idx)
+{
+   int rc;
+   struct hwrm_stat_ctx_alloc_input req = {.req_type = 0 };
+   struct hwrm_stat_ctx_alloc_output *resp = bp->hwrm_cmd_resp_addr;
+
+   HWRM_PREP(req, STAT_CTX_ALLOC, -1, resp);
+
+   req.update_period_ms = rte_cpu_to_le_32(1000);
+
+   req.seq_id = rte_cpu_to_le_16(bp->hwrm_cmd_seq++);
+   req.stats_dma_addr =
+   rte_cpu_to_le_64(cpr->hw_stats_map);
+
+   rc = bnxt_hwrm_send_message(bp, , sizeof(req));
+
+   HWRM_CHECK_RESULT;
+
+   cpr->hw_stats_ctx_id = rte_le_to_cpu_16(resp->stat_ctx_id);
+   bp->grp_info[idx].fw_stats_ctx = cpr->hw_stats_ctx_id;
+
+   return rc;
+}
+
 int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic)
 {
int rc = 0, i, j;
@@ -701,6 +726,33 @@ int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp)
return 0;
 }

+int bnxt_alloc_all_hwrm_stat_ctxs(struct bnxt *bp)
+{
+   unsigned i;
+   int rc = 0;
+
+   for (i = 0; i < bp->rx_cp_nr_rings + bp->tx_cp_nr_rings; i++) {
+   struct bnxt_tx_queue *txq;
+   struct bnxt_rx_queue *rxq;
+   struct bnxt_cp_ring_info *cpr;
+   unsigned idx = i + 1;
+
+   if (i >= bp->rx_cp_nr_rings) {
+   txq = bp->tx_queues[i - bp->rx_cp_nr_rings];
+   cpr = txq->cp_ring;
+   } else {
+   rxq = bp->rx_queues[i];
+   cpr = rxq->cp_ring;
+   }
+
+   rc = bnxt_hwrm_stat_ctx_alloc(bp, cpr, idx);
+
+   if (rc)
+   return rc;
+   }
+   return rc;
+}
+
 void bnxt_free_hwrm_resources(struct bnxt *bp)
 {
/* Release memzone */
diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
index 915cf2a..b4cc3b6 100644
--- a/drivers/net/bnxt/bnxt_hwrm.h
+++ b/drivers/net/bnxt/bnxt_hwrm.h
@@ -59,6 +59,8 @@ int bnxt_hwrm_func_driver_unregister(struct bnxt *bp, 
uint32_t flags);
 int bnxt_hwrm_queue_qportcfg(struct bnxt *bp);

 int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr);
+int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp,
+struct bnxt_cp_ring_info *cpr, unsigned idx);

 int bnxt_hwrm_ver_get(struct bnxt *bp);

@@ -70,6 +72,7 @@ int bnxt_hwrm_vnic_free(struct bnxt *bp, struct 
bnxt_vnic_info *vnic);
 int bnxt_hwrm_vnic_rss_cfg(struct bnxt *bp,
   struct bnxt_vnic_info *vnic);

+int bnxt_alloc_all_hwrm_stat_ctxs(struct bnxt *bp);
 int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp);
 void bnxt_free_hwrm_resources(struct bnxt *bp);
 int bnxt_alloc_hwrm_resources(struct bnxt *bp);
diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h 
b/drivers/net/bnxt/hsi_struct_def_dpdk.h
index 89a1d6f..de3eb0e 100644
--- a/drivers/net/bnxt/hsi_struct_def_dpdk.h
+++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h
@@ -99,6 +99,7 @@ typedef struct ctx_hw_stats64 {
 #define HWRM_CFA_L2_FILTER_FREE(UINT32_C(0x91))
 #define HWRM_CFA_L2_FILTER_CFG (UINT32_C(0x92))
 #define HWRM_CFA_L2_SET_RX_MASK(UINT32_C(0x93))
+#define HWRM_STAT_CTX_ALLOC(UINT32_C(0xb0))
 #define HWRM_STAT_CTX_CLR_STATS(UINT32_C(0xb3))
 #define HWRM_EXEC_FWD_RESP (UINT32_C(0xd0))

@@ -3232,6 +3233,94 @@ struct hwrm_queue_qportcfg_input {
uint16_t unused_0;
 } __attribute__((packed));

+/* hwrm_stat_ctx_alloc */
+/*
+ * Description: This command allocates and does basic preparation for a stat
+ * context.
+ */
+
+/* Input (32 bytes) */
+struct hwrm_stat_ctx_alloc_input {
+   /*
+* This value indicates what type of request this is. The format for the
+* rest of the command is determined by this field.
+*/
+   uint16_t req_type;
+
+   /*
+* This value indicates the what completion ring the request will be
+* optionally completed on. If the value is -1, then no CR completion
+* will be generated. Any other value must be a valid CR ring_id value
+* for this function.
+*/
+   uint16_t cmpl_ring;
+
+   /* This value indicates the command sequence 

[dpdk-dev] [PATCH v2 22/40] bnxt: add L2 Rx mask set/clear functions

2016-05-13 Thread Stephen Hurd
Allows setting and clearing L2 context RX masks per vnic

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_hwrm.c   |  45 +++
 drivers/net/bnxt/bnxt_hwrm.h   |   3 +
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 135 +
 3 files changed, 183 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 6e37315..44c6e80 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -141,6 +141,51 @@ static int bnxt_hwrm_send_message(struct bnxt *bp, void 
*msg, uint32_t msg_len)
} \
}

+int bnxt_hwrm_cfa_l2_clear_rx_mask(struct bnxt *bp, struct bnxt_vnic_info 
*vnic)
+{
+   int rc = 0;
+   struct hwrm_cfa_l2_set_rx_mask_input req = {.req_type = 0 };
+   struct hwrm_cfa_l2_set_rx_mask_output *resp = bp->hwrm_cmd_resp_addr;
+
+   HWRM_PREP(req, CFA_L2_SET_RX_MASK, -1, resp);
+   req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
+   req.mask = 0;
+
+   rc = bnxt_hwrm_send_message(bp, , sizeof(req));
+
+   HWRM_CHECK_RESULT;
+
+   return rc;
+}
+
+int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp, struct bnxt_vnic_info *vnic)
+{
+   int rc = 0;
+   struct hwrm_cfa_l2_set_rx_mask_input req = {.req_type = 0 };
+   struct hwrm_cfa_l2_set_rx_mask_output *resp = bp->hwrm_cmd_resp_addr;
+   uint32_t mask = 0;
+
+   HWRM_PREP(req, CFA_L2_SET_RX_MASK, -1, resp);
+   req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
+
+   /* FIXME add multicast flag, when multicast adding options is supported
+* by ethtool.
+*/
+   if (vnic->flags & BNXT_VNIC_INFO_PROMISC)
+   mask = HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_PROMISCUOUS;
+   if (vnic->flags & BNXT_VNIC_INFO_ALLMULTI)
+   mask = HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST;
+   req.mask = rte_cpu_to_le_32(HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_MCAST |
+   HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_BCAST |
+   mask);
+
+   rc = bnxt_hwrm_send_message(bp, , sizeof(req));
+
+   HWRM_CHECK_RESULT;
+
+   return rc;
+}
+
 int bnxt_hwrm_clear_filter(struct bnxt *bp,
   struct bnxt_filter_info *filter)
 {
diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
index 7c12c6d..915cf2a 100644
--- a/drivers/net/bnxt/bnxt_hwrm.h
+++ b/drivers/net/bnxt/bnxt_hwrm.h
@@ -42,6 +42,9 @@
 struct bnxt;
 struct bnxt_filter_info;
 struct bnxt_cp_ring_info;
+int bnxt_hwrm_cfa_l2_clear_rx_mask(struct bnxt *bp,
+  struct bnxt_vnic_info *vnic);
+int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp, struct bnxt_vnic_info *vnic);
 int bnxt_hwrm_clear_filter(struct bnxt *bp,
   struct bnxt_filter_info *filter);

diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h 
b/drivers/net/bnxt/hsi_struct_def_dpdk.h
index 5b8895c..89a1d6f 100644
--- a/drivers/net/bnxt/hsi_struct_def_dpdk.h
+++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h
@@ -1781,6 +1781,141 @@ struct hwrm_cfa_l2_filter_free_output {
uint8_t valid;
 } __attribute__((packed));

+/* hwrm_cfa_l2_set_rx_mask */
+/* Description: This command will set rx mask of the function. */
+
+/* Input (40 bytes) */
+struct hwrm_cfa_l2_set_rx_mask_input {
+   /*
+* This value indicates what type of request this is. The format for the
+* rest of the command is determined by this field.
+*/
+   uint16_t req_type;
+
+   /*
+* This value indicates the what completion ring the request will be
+* optionally completed on. If the value is -1, then no CR completion
+* will be generated. Any other value must be a valid CR ring_id value
+* for this function.
+*/
+   uint16_t cmpl_ring;
+
+   /* This value indicates the command sequence number. */
+   uint16_t seq_id;
+
+   /*
+* Target ID of this command. 0x0 - 0xFFF8 - Used for function ids
+* 0xFFF8 - 0xFFFE - Reserved for internal processors 0x - HWRM
+*/
+   uint16_t target_id;
+
+   /*
+* This is the host address where the response will be written when the
+* request is complete. This area must be 16B aligned and must be
+* cleared to zero before the request is made.
+*/
+   uint64_t resp_addr;
+
+   /* VNIC ID */
+   uint32_t vnic_id;
+
+   /* Reserved for future use. */
+   #define HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_RESERVED UINT32_C(0x1)
+   /*
+* When this bit is '1', the function is requested to accept multi-cast
+* packets specified by the multicast addr table.
+*/
+   #define HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_MCASTUINT32_C(0x2)
+   /*
+* When this bit is '1', the function is requested to accept all multi-
+* cast packets.
+*/
+   

[dpdk-dev] [PATCH v2 21/40] bnxt: add HWRM vnic RSS config function

2016-05-13 Thread Stephen Hurd
Used to enable RSS configuration

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_hwrm.c   | 24 
 drivers/net/bnxt/bnxt_hwrm.h   |  2 ++
 drivers/net/bnxt/hsi_struct_def_dpdk.h |  1 +
 3 files changed, 27 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 4609862..6e37315 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -603,6 +603,30 @@ int bnxt_hwrm_vnic_free(struct bnxt *bp, struct 
bnxt_vnic_info *vnic)
return rc;
 }

+int bnxt_hwrm_vnic_rss_cfg(struct bnxt *bp,
+  struct bnxt_vnic_info *vnic)
+{
+   int rc = 0;
+   struct hwrm_vnic_rss_cfg_input req = {.req_type = 0 };
+   struct hwrm_vnic_rss_cfg_output *resp = bp->hwrm_cmd_resp_addr;
+
+   HWRM_PREP(req, VNIC_RSS_CFG, -1, resp);
+
+   req.hash_type = rte_cpu_to_le_32(vnic->hash_type);
+
+   req.ring_grp_tbl_addr =
+   rte_cpu_to_le_64(vnic->rss_table_dma_addr);
+   req.hash_key_tbl_addr =
+   rte_cpu_to_le_64(vnic->rss_hash_key_dma_addr);
+   req.rss_ctx_idx = rte_cpu_to_le_16(vnic->fw_rss_cos_lb_ctx);
+
+   rc = bnxt_hwrm_send_message(bp, , sizeof(req));
+
+   HWRM_CHECK_RESULT;
+
+   return rc;
+}
+
 /*
  * HWRM utility functions
  */
diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
index b7f6b20..7c12c6d 100644
--- a/drivers/net/bnxt/bnxt_hwrm.h
+++ b/drivers/net/bnxt/bnxt_hwrm.h
@@ -64,6 +64,8 @@ int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info 
*vnic);
 int bnxt_hwrm_vnic_ctx_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic);
 int bnxt_hwrm_vnic_ctx_free(struct bnxt *bp, struct bnxt_vnic_info *vnic);
 int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic);
+int bnxt_hwrm_vnic_rss_cfg(struct bnxt *bp,
+  struct bnxt_vnic_info *vnic);

 int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp);
 void bnxt_free_hwrm_resources(struct bnxt *bp);
diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h 
b/drivers/net/bnxt/hsi_struct_def_dpdk.h
index 34f66c5..5b8895c 100644
--- a/drivers/net/bnxt/hsi_struct_def_dpdk.h
+++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h
@@ -92,6 +92,7 @@ typedef struct ctx_hw_stats64 {
 #define HWRM_VNIC_ALLOC(UINT32_C(0x40))
 #define HWRM_VNIC_FREE (UINT32_C(0x41))
 #define HWRM_VNIC_CFG  (UINT32_C(0x42))
+#define HWRM_VNIC_RSS_CFG  (UINT32_C(0x46))
 #define HWRM_VNIC_RSS_COS_LB_CTX_ALLOC (UINT32_C(0x70))
 #define HWRM_VNIC_RSS_COS_LB_CTX_FREE  (UINT32_C(0x71))
 #define HWRM_CFA_L2_FILTER_ALLOC   (UINT32_C(0x90))
-- 
1.9.1



[dpdk-dev] [PATCH v2 20/40] bnxt: add vnic RSS cos lb cTx alloc/free functions

2016-05-13 Thread Stephen Hurd
More HWRM calls.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_hwrm.c   |  38 
 drivers/net/bnxt/bnxt_hwrm.h   |   2 +
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 153 +
 3 files changed, 193 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 2a18cf3..4609862 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -544,6 +544,44 @@ int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct 
bnxt_vnic_info *vnic)
return rc;
 }

+int bnxt_hwrm_vnic_ctx_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic)
+{
+   int rc = 0;
+   struct hwrm_vnic_rss_cos_lb_ctx_alloc_input req = {.req_type = 0 };
+   struct hwrm_vnic_rss_cos_lb_ctx_alloc_output *resp =
+   bp->hwrm_cmd_resp_addr;
+
+   HWRM_PREP(req, VNIC_RSS_COS_LB_CTX_ALLOC, -1, resp);
+
+   rc = bnxt_hwrm_send_message(bp, , sizeof(req));
+
+   HWRM_CHECK_RESULT;
+
+   vnic->fw_rss_cos_lb_ctx = rte_le_to_cpu_16(resp->rss_cos_lb_ctx_id);
+
+   return rc;
+}
+
+int bnxt_hwrm_vnic_ctx_free(struct bnxt *bp, struct bnxt_vnic_info *vnic)
+{
+   int rc = 0;
+   struct hwrm_vnic_rss_cos_lb_ctx_free_input req = {.req_type = 0 };
+   struct hwrm_vnic_rss_cos_lb_ctx_free_output *resp =
+   bp->hwrm_cmd_resp_addr;
+
+   HWRM_PREP(req, VNIC_RSS_COS_LB_CTX_FREE, -1, resp);
+
+   req.rss_cos_lb_ctx_id = rte_cpu_to_le_16(vnic->fw_rss_cos_lb_ctx);
+
+   rc = bnxt_hwrm_send_message(bp, , sizeof(req));
+
+   HWRM_CHECK_RESULT;
+
+   vnic->fw_rss_cos_lb_ctx = INVALID_HW_RING_ID;
+
+   return rc;
+}
+
 int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic)
 {
int rc = 0;
diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
index b5cf090..b7f6b20 100644
--- a/drivers/net/bnxt/bnxt_hwrm.h
+++ b/drivers/net/bnxt/bnxt_hwrm.h
@@ -61,6 +61,8 @@ int bnxt_hwrm_ver_get(struct bnxt *bp);

 int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic);
 int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic);
+int bnxt_hwrm_vnic_ctx_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic);
+int bnxt_hwrm_vnic_ctx_free(struct bnxt *bp, struct bnxt_vnic_info *vnic);
 int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic);

 int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp);
diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h 
b/drivers/net/bnxt/hsi_struct_def_dpdk.h
index b74f9f9..34f66c5 100644
--- a/drivers/net/bnxt/hsi_struct_def_dpdk.h
+++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h
@@ -92,6 +92,8 @@ typedef struct ctx_hw_stats64 {
 #define HWRM_VNIC_ALLOC(UINT32_C(0x40))
 #define HWRM_VNIC_FREE (UINT32_C(0x41))
 #define HWRM_VNIC_CFG  (UINT32_C(0x42))
+#define HWRM_VNIC_RSS_COS_LB_CTX_ALLOC (UINT32_C(0x70))
+#define HWRM_VNIC_RSS_COS_LB_CTX_FREE  (UINT32_C(0x71))
 #define HWRM_CFA_L2_FILTER_ALLOC   (UINT32_C(0x90))
 #define HWRM_CFA_L2_FILTER_FREE(UINT32_C(0x91))
 #define HWRM_CFA_L2_FILTER_CFG (UINT32_C(0x92))
@@ -3625,6 +3627,157 @@ struct hwrm_vnic_rss_cfg_output {
uint8_t valid;
 } __attribute__((packed));

+/* Input (16 bytes) */
+struct hwrm_vnic_rss_cos_lb_ctx_alloc_input {
+   /*
+* This value indicates what type of request this is. The format for the
+* rest of the command is determined by this field.
+*/
+   uint16_t req_type;
+
+   /*
+* This value indicates the what completion ring the request will be
+* optionally completed on. If the value is -1, then no CR completion
+* will be generated. Any other value must be a valid CR ring_id value
+* for this function.
+*/
+   uint16_t cmpl_ring;
+
+   /* This value indicates the command sequence number. */
+   uint16_t seq_id;
+
+   /*
+* Target ID of this command. 0x0 - 0xFFF8 - Used for function ids
+* 0xFFF8 - 0xFFFE - Reserved for internal processors 0x - HWRM
+*/
+   uint16_t target_id;
+
+   /*
+* This is the host address where the response will be written when the
+* request is complete. This area must be 16B aligned and must be
+* cleared to zero before the request is made.
+*/
+   uint64_t resp_addr;
+} __attribute__((packed));
+
+/* Output (16 bytes) */
+
+struct hwrm_vnic_rss_cos_lb_ctx_alloc_output {
+   /*
+* Pass/Fail or error type Note: receiver to verify the in parameters,
+* and fail the call with an error when appropriate
+*/
+   uint16_t error_code;
+
+   /* This field returns the type of original request. */
+   uint16_t req_type;
+
+   /* This field provides original sequence number of the command. */
+   uint16_t seq_id;
+
+   

[dpdk-dev] [PATCH v2 19/40] bnxt: add HWRM vnic cfg function

2016-05-13 Thread Stephen Hurd
Configurs a vnic allocaed by vnic_alloc function.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_hwrm.c   |  34 
 drivers/net/bnxt/bnxt_hwrm.h   |   3 +-
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 155 +
 3 files changed, 191 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index d716b67..2a18cf3 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -510,6 +510,40 @@ int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct 
bnxt_vnic_info *vnic)
return rc;
 }

+int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic)
+{
+   int rc = 0;
+   struct hwrm_vnic_cfg_input req = {.req_type = 0 };
+   struct hwrm_vnic_cfg_output *resp = bp->hwrm_cmd_resp_addr;
+
+   HWRM_PREP(req, VNIC_CFG, -1, resp);
+
+   /* Only RSS support for now TBD: COS & LB */
+   req.enables =
+   rte_cpu_to_le_32(HWRM_VNIC_CFG_INPUT_ENABLES_DFLT_RING_GRP |
+HWRM_VNIC_CFG_INPUT_ENABLES_RSS_RULE |
+HWRM_VNIC_CFG_INPUT_ENABLES_MRU);
+   req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
+   req.dflt_ring_grp =
+   rte_cpu_to_le_16(bp->grp_info[vnic->start_grp_id].fw_grp_id);
+   req.rss_rule = rte_cpu_to_le_16(vnic->fw_rss_cos_lb_ctx);
+   req.cos_rule = rte_cpu_to_le_16(0x);
+   req.lb_rule = rte_cpu_to_le_16(0x);
+   req.mru = rte_cpu_to_le_16(bp->eth_dev->data->mtu + ETHER_HDR_LEN +
+  ETHER_CRC_LEN + VLAN_TAG_SIZE);
+   if (vnic->func_default)
+   req.flags = 1;
+   if (vnic->vlan_strip)
+   req.flags |=
+   rte_cpu_to_le_32(HWRM_VNIC_CFG_INPUT_FLAGS_VLAN_STRIP_MODE);
+
+   rc = bnxt_hwrm_send_message(bp, , sizeof(req));
+
+   HWRM_CHECK_RESULT;
+
+   return rc;
+}
+
 int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic)
 {
int rc = 0;
diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
index 887ad2d..b5cf090 100644
--- a/drivers/net/bnxt/bnxt_hwrm.h
+++ b/drivers/net/bnxt/bnxt_hwrm.h
@@ -59,8 +59,9 @@ int bnxt_hwrm_stat_clear(struct bnxt *bp, struct 
bnxt_cp_ring_info *cpr);

 int bnxt_hwrm_ver_get(struct bnxt *bp);

-int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic);
 int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic);
+int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic);
+int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic);

 int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp);
 void bnxt_free_hwrm_resources(struct bnxt *bp);
diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h 
b/drivers/net/bnxt/hsi_struct_def_dpdk.h
index 93d50fb..b74f9f9 100644
--- a/drivers/net/bnxt/hsi_struct_def_dpdk.h
+++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h
@@ -91,6 +91,7 @@ typedef struct ctx_hw_stats64 {
 #define HWRM_QUEUE_QPORTCFG(UINT32_C(0x30))
 #define HWRM_VNIC_ALLOC(UINT32_C(0x40))
 #define HWRM_VNIC_FREE (UINT32_C(0x41))
+#define HWRM_VNIC_CFG  (UINT32_C(0x42))
 #define HWRM_CFA_L2_FILTER_ALLOC   (UINT32_C(0x90))
 #define HWRM_CFA_L2_FILTER_FREE(UINT32_C(0x91))
 #define HWRM_CFA_L2_FILTER_CFG (UINT32_C(0x92))
@@ -3268,6 +3269,160 @@ struct hwrm_vnic_alloc_output {
uint8_t valid;
 } __attribute__((packed));

+/* hwrm_vnic_cfg */
+/* Description: Configure the RX VNIC structure. */
+
+/* Input (40 bytes) */
+struct hwrm_vnic_cfg_input {
+   /*
+* This value indicates what type of request this is. The format for the
+* rest of the command is determined by this field.
+*/
+   uint16_t req_type;
+
+   /*
+* This value indicates the what completion ring the request will be
+* optionally completed on. If the value is -1, then no CR completion
+* will be generated. Any other value must be a valid CR ring_id value
+* for this function.
+*/
+   uint16_t cmpl_ring;
+
+   /* This value indicates the command sequence number. */
+   uint16_t seq_id;
+
+   /*
+* Target ID of this command. 0x0 - 0xFFF8 - Used for function ids
+* 0xFFF8 - 0xFFFE - Reserved for internal processors 0x - HWRM
+*/
+   uint16_t target_id;
+
+   /*
+* This is the host address where the response will be written when the
+* request is complete. This area must be 16B aligned and must be
+* cleared to zero before the request is made.
+*/
+   uint64_t resp_addr;
+
+   /*
+* When this bit is '1', the VNIC is requested to be the default VNIC
+* for the function.
+*/
+   #define HWRM_VNIC_CFG_INPUT_FLAGS_DEFAULT   UINT32_C(0x1)
+   /*
+* When this bit 

[dpdk-dev] [PATCH v2 18/40] bnxt: add HWRM vnic free function

2016-05-13 Thread Stephen Hurd
Frees a vnic allocated by vnic_alloc.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_hwrm.c   | 21 +
 drivers/net/bnxt/bnxt_hwrm.h   |  1 +
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 82 ++
 3 files changed, 104 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index ecd4718..d716b67 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -510,6 +510,27 @@ int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct 
bnxt_vnic_info *vnic)
return rc;
 }

+int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic)
+{
+   int rc = 0;
+   struct hwrm_vnic_free_input req = {.req_type = 0 };
+   struct hwrm_vnic_free_output *resp = bp->hwrm_cmd_resp_addr;
+
+   if (vnic->fw_vnic_id == INVALID_HW_RING_ID)
+   return rc;
+
+   HWRM_PREP(req, VNIC_FREE, -1, resp);
+
+   req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
+
+   rc = bnxt_hwrm_send_message(bp, , sizeof(req));
+
+   HWRM_CHECK_RESULT;
+
+   vnic->fw_vnic_id = INVALID_HW_RING_ID;
+   return rc;
+}
+
 /*
  * HWRM utility functions
  */
diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
index 62dc801..887ad2d 100644
--- a/drivers/net/bnxt/bnxt_hwrm.h
+++ b/drivers/net/bnxt/bnxt_hwrm.h
@@ -59,6 +59,7 @@ int bnxt_hwrm_stat_clear(struct bnxt *bp, struct 
bnxt_cp_ring_info *cpr);

 int bnxt_hwrm_ver_get(struct bnxt *bp);

+int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic);
 int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic);

 int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp);
diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h 
b/drivers/net/bnxt/hsi_struct_def_dpdk.h
index ba0e054..93d50fb 100644
--- a/drivers/net/bnxt/hsi_struct_def_dpdk.h
+++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h
@@ -90,6 +90,7 @@ typedef struct ctx_hw_stats64 {
 #define HWRM_PORT_PHY_CFG  (UINT32_C(0x20))
 #define HWRM_QUEUE_QPORTCFG(UINT32_C(0x30))
 #define HWRM_VNIC_ALLOC(UINT32_C(0x40))
+#define HWRM_VNIC_FREE (UINT32_C(0x41))
 #define HWRM_CFA_L2_FILTER_ALLOC   (UINT32_C(0x90))
 #define HWRM_CFA_L2_FILTER_FREE(UINT32_C(0x91))
 #define HWRM_CFA_L2_FILTER_CFG (UINT32_C(0x92))
@@ -3267,6 +3268,87 @@ struct hwrm_vnic_alloc_output {
uint8_t valid;
 } __attribute__((packed));

+/* hwrm_vnic_free */
+/*
+ * Description: Free a VNIC resource. Idle any resources associated with the
+ * VNIC as well as the VNIC. Reset and release all resources associated with 
the
+ * VNIC.
+ */
+
+/* Input (24 bytes) */
+struct hwrm_vnic_free_input {
+   /*
+* This value indicates what type of request this is. The format for the
+* rest of the command is determined by this field.
+*/
+   uint16_t req_type;
+
+   /*
+* This value indicates the what completion ring the request will be
+* optionally completed on. If the value is -1, then no CR completion
+* will be generated. Any other value must be a valid CR ring_id value
+* for this function.
+*/
+   uint16_t cmpl_ring;
+
+   /* This value indicates the command sequence number. */
+   uint16_t seq_id;
+
+   /*
+* Target ID of this command. 0x0 - 0xFFF8 - Used for function ids
+* 0xFFF8 - 0xFFFE - Reserved for internal processors 0x - HWRM
+*/
+   uint16_t target_id;
+
+   /*
+* This is the host address where the response will be written when the
+* request is complete. This area must be 16B aligned and must be
+* cleared to zero before the request is made.
+*/
+   uint64_t resp_addr;
+
+   /* Logical vnic ID */
+   uint32_t vnic_id;
+
+   uint32_t unused_0;
+} __attribute__((packed));
+
+/* Output (16 bytes) */
+struct hwrm_vnic_free_output {
+   /*
+* Pass/Fail or error type Note: receiver to verify the in parameters,
+* and fail the call with an error when appropriate
+*/
+   uint16_t error_code;
+
+   /* This field returns the type of original request. */
+   uint16_t req_type;
+
+   /* This field provides original sequence number of the command. */
+   uint16_t seq_id;
+
+   /*
+* This field is the length of the response in bytes. The last byte of
+* the response is a valid flag that will read as '1' when the command
+* has been completely written to memory.
+*/
+   uint16_t resp_len;
+
+   uint32_t unused_0;
+   uint8_t unused_1;
+   uint8_t unused_2;
+   uint8_t unused_3;
+
+   /*
+* This field is used in Output records to indicate that the output is
+* completely written to RAM. This field should be read as '1' to
+* indicate that the output has been completely written. 

[dpdk-dev] [PATCH v2 17/40] bnxt: add HWRM vnic alloc function

2016-05-13 Thread Stephen Hurd
This requires a group info array in struct bnxt, so add that, save
the max size from the func_qcap response, and alloc/free in init/uninit

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt.h|  2 +
 drivers/net/bnxt/bnxt_hwrm.c   | 33 
 drivers/net/bnxt/bnxt_hwrm.h   |  2 +
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 99 ++
 4 files changed, 136 insertions(+)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 96f162e..d258e2b 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -140,6 +140,8 @@ struct bnxt {
/* Default completion ring */
struct bnxt_cp_ring_info*def_cp_ring;

+   uint32_tmax_ring_grps;
+   struct bnxt_ring_grp_info   *grp_info;
unsignednr_vnics;

struct bnxt_vnic_info   *vnic_info;
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 922c92a..ecd4718 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -43,7 +43,9 @@
 #include "bnxt_filter.h"
 #include "bnxt_hwrm.h"
 #include "bnxt_rxq.h"
+#include "bnxt_ring.h"
 #include "bnxt_txq.h"
+#include "bnxt_vnic.h"
 #include "hsi_struct_def_dpdk.h"

 #define HWRM_CMD_TIMEOUT   2000
@@ -191,6 +193,7 @@ int bnxt_hwrm_func_qcaps(struct bnxt *bp)

HWRM_CHECK_RESULT;

+   bp->max_ring_grps = rte_le_to_cpu_32(resp->max_hw_ring_grps);
if (BNXT_PF(bp)) {
struct bnxt_pf_info *pf = >pf;

@@ -477,6 +480,36 @@ int bnxt_hwrm_stat_clear(struct bnxt *bp, struct 
bnxt_cp_ring_info *cpr)
return rc;
 }

+int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic)
+{
+   int rc = 0, i, j;
+   struct hwrm_vnic_alloc_input req = {.req_type = 0 };
+   struct hwrm_vnic_alloc_output *resp = bp->hwrm_cmd_resp_addr;
+
+   /* map ring groups to this vnic */
+   for (i = vnic->start_grp_id, j = 0; i <= vnic->end_grp_id; i++, j++) {
+   if (bp->grp_info[i].fw_grp_id == (uint16_t)HWRM_NA_SIGNATURE) {
+   RTE_LOG(ERR, PMD,
+   "Not enough ring groups avail:%x req:%x\n", j,
+   (vnic->end_grp_id - vnic->start_grp_id) + 1);
+   break;
+   }
+   vnic->fw_grp_ids[j] = bp->grp_info[i].fw_grp_id;
+   }
+
+   vnic->fw_rss_cos_lb_ctx = (uint16_t)HWRM_NA_SIGNATURE;
+   vnic->ctx_is_rss_cos_lb = HW_CONTEXT_NONE;
+
+   HWRM_PREP(req, VNIC_ALLOC, -1, resp);
+
+   rc = bnxt_hwrm_send_message(bp, , sizeof(req));
+
+   HWRM_CHECK_RESULT;
+
+   vnic->fw_vnic_id = rte_le_to_cpu_16(resp->vnic_id);
+   return rc;
+}
+
 /*
  * HWRM utility functions
  */
diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
index 4fa94aa..62dc801 100644
--- a/drivers/net/bnxt/bnxt_hwrm.h
+++ b/drivers/net/bnxt/bnxt_hwrm.h
@@ -59,6 +59,8 @@ int bnxt_hwrm_stat_clear(struct bnxt *bp, struct 
bnxt_cp_ring_info *cpr);

 int bnxt_hwrm_ver_get(struct bnxt *bp);

+int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic);
+
 int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp);
 void bnxt_free_hwrm_resources(struct bnxt *bp);
 int bnxt_alloc_hwrm_resources(struct bnxt *bp);
diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h 
b/drivers/net/bnxt/hsi_struct_def_dpdk.h
index 9c82d13..ba0e054 100644
--- a/drivers/net/bnxt/hsi_struct_def_dpdk.h
+++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h
@@ -89,6 +89,7 @@ typedef struct ctx_hw_stats64 {
 #define HWRM_FUNC_DRV_RGTR (UINT32_C(0x1d))
 #define HWRM_PORT_PHY_CFG  (UINT32_C(0x20))
 #define HWRM_QUEUE_QPORTCFG(UINT32_C(0x30))
+#define HWRM_VNIC_ALLOC(UINT32_C(0x40))
 #define HWRM_CFA_L2_FILTER_ALLOC   (UINT32_C(0x90))
 #define HWRM_CFA_L2_FILTER_FREE(UINT32_C(0x91))
 #define HWRM_CFA_L2_FILTER_CFG (UINT32_C(0x92))
@@ -3168,6 +3169,104 @@ struct hwrm_stat_ctx_clr_stats_output {
uint8_t valid;
 } __attribute__((packed));

+/* hwrm_vnic_alloc */
+/*
+ * Description: This VNIC is a resource in the RX side of the chip that is used
+ * to represent a virtual host "interface". # At the time of VNIC allocation or
+ * configuration, the function can specify whether it wants the requested VNIC
+ * to be the default VNIC for the function or not. # If a function requests
+ * allocation of a VNIC for the first time and a VNIC is successfully allocated
+ * by the HWRM, then the HWRM shall make the allocated VNIC as the default VNIC
+ * for that function. # The default VNIC shall be used for the default action
+ * for a partition or function. # For each VNIC allocated on a function, a
+ * mapping on the RX side to map the allocated VNIC to source virtual interface
+ * shall be performed by the HWRM. This should be hidden to the function driver
+ 

[dpdk-dev] [PATCH v2 16/40] bnxt: add HWRM function reset command

2016-05-13 Thread Stephen Hurd
Add bnxt_hwrm_func_reset() function and supporting structs and macros.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_hwrm.c   |  17 +
 drivers/net/bnxt/bnxt_hwrm.h   |   1 +
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 129 +
 3 files changed, 147 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 50d8b89..922c92a 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -221,6 +221,23 @@ int bnxt_hwrm_func_qcaps(struct bnxt *bp)
return rc;
 }

+int bnxt_hwrm_func_reset(struct bnxt *bp)
+{
+   int rc = 0;
+   struct hwrm_func_reset_input req = {.req_type = 0 };
+   struct hwrm_func_reset_output *resp = bp->hwrm_cmd_resp_addr;
+
+   HWRM_PREP(req, FUNC_RESET, -1, resp);
+
+   req.enables = rte_cpu_to_le_32(0);
+
+   rc = bnxt_hwrm_send_message(bp, , sizeof(req));
+
+   HWRM_CHECK_RESULT;
+
+   return rc;
+}
+
 int bnxt_hwrm_func_driver_register(struct bnxt *bp, uint32_t flags,
   uint32_t *vf_req_fwd)
 {
diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
index 0861417..4fa94aa 100644
--- a/drivers/net/bnxt/bnxt_hwrm.h
+++ b/drivers/net/bnxt/bnxt_hwrm.h
@@ -50,6 +50,7 @@ int bnxt_hwrm_exec_fwd_resp(struct bnxt *bp, void *fwd_cmd);
 int bnxt_hwrm_func_driver_register(struct bnxt *bp, uint32_t flags,
   uint32_t *vf_req_fwd);
 int bnxt_hwrm_func_qcaps(struct bnxt *bp);
+int bnxt_hwrm_func_reset(struct bnxt *bp);
 int bnxt_hwrm_func_driver_unregister(struct bnxt *bp, uint32_t flags);

 int bnxt_hwrm_queue_qportcfg(struct bnxt *bp);
diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h 
b/drivers/net/bnxt/hsi_struct_def_dpdk.h
index fd9eb62..9c82d13 100644
--- a/drivers/net/bnxt/hsi_struct_def_dpdk.h
+++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h
@@ -83,6 +83,7 @@ typedef struct ctx_hw_stats64 {
  * Request types
  */
 #define HWRM_VER_GET   (UINT32_C(0x0))
+#define HWRM_FUNC_RESET(UINT32_C(0x11))
 #define HWRM_FUNC_QCAPS(UINT32_C(0x15))
 #define HWRM_FUNC_DRV_UNRGTR   (UINT32_C(0x1a))
 #define HWRM_FUNC_DRV_RGTR (UINT32_C(0x1d))
@@ -2097,6 +2098,134 @@ struct hwrm_func_qcaps_output {
uint8_t valid;
 } __attribute__((packed));

+/* hwrm_func_reset */
+/*
+ * Description: This command resets a hardware function (PCIe function) and
+ * frees any resources used by the function. This command shall be initiated by
+ * the driver after an FLR has occurred to prepare the function for re-use. 
This
+ * command may also be initiated by a driver prior to doing it's own
+ * configuration. This command puts the function into the reset state. In the
+ * reset state, global and port related features of the chip are not available.
+ */
+/*
+ * Note: This command will reset a function that has already been disabled or
+ * idled. The command returns all the resources owned by the function so a new
+ * driver may allocate and configure resources normally.
+ */
+
+/* Input (24 bytes) */
+struct hwrm_func_reset_input {
+   /*
+* This value indicates what type of request this is. The format for the
+* rest of the command is determined by this field.
+*/
+   uint16_t req_type;
+
+   /*
+* This value indicates the what completion ring the request will be
+* optionally completed on. If the value is -1, then no CR completion
+* will be generated. Any other value must be a valid CR ring_id value
+* for this function.
+*/
+   uint16_t cmpl_ring;
+
+   /* This value indicates the command sequence number. */
+   uint16_t seq_id;
+
+   /*
+* Target ID of this command. 0x0 - 0xFFF8 - Used for function ids
+* 0xFFF8 - 0xFFFE - Reserved for internal processors 0x - HWRM
+*/
+   uint16_t target_id;
+
+   /*
+* This is the host address where the response will be written when the
+* request is complete. This area must be 16B aligned and must be
+* cleared to zero before the request is made.
+*/
+   uint64_t resp_addr;
+
+   /* This bit must be '1' for the vf_id_valid field to be configured. */
+   #define HWRM_FUNC_RESET_INPUT_ENABLES_VF_ID_VALID \
+   UINT32_C(0x1)
+   uint32_t enables;
+
+   /*
+* The ID of the VF that this PF is trying to reset. Only the parent PF
+* shall be allowed to reset a child VF. A parent PF driver shall use
+* this field only when a specific child VF is requested to be reset.
+*/
+   uint16_t vf_id;
+
+   /* This value indicates the level of a function reset. */
+   /*
+* Reset the caller function and its children VFs (if any). If
+* no 

[dpdk-dev] [PATCH v2 15/40] bnxt: alloc/free ring information

2016-05-13 Thread Stephen Hurd
Perform allocation and free()ing of ring information structures for
TX, RX, and completion rings.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt_cpr.c | 28 +++-
 drivers/net/bnxt/bnxt_cpr.h |  2 +-
 drivers/net/bnxt/bnxt_rxq.c | 17 -
 drivers/net/bnxt/bnxt_rxr.c | 42 ++
 drivers/net/bnxt/bnxt_rxr.h |  2 +-
 drivers/net/bnxt/bnxt_txq.c | 23 ---
 drivers/net/bnxt/bnxt_txr.c | 43 ++-
 drivers/net/bnxt/bnxt_txr.h |  2 +-
 8 files changed, 122 insertions(+), 37 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c
index 34e45ef..27c557f 100644
--- a/drivers/net/bnxt/bnxt_cpr.c
+++ b/drivers/net/bnxt/bnxt_cpr.c
@@ -31,6 +31,8 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */

+#include 
+
 #include "bnxt.h"
 #include "bnxt_cpr.h"
 #include "bnxt_hwrm.h"
@@ -120,21 +122,37 @@ reject:
 void bnxt_free_def_cp_ring(struct bnxt *bp)
 {
struct bnxt_cp_ring_info *cpr = bp->def_cp_ring;
-   struct bnxt_ring_struct *ring = cpr->cp_ring_struct;

-   bnxt_free_ring(ring);
+   bnxt_free_ring(cpr->cp_ring_struct);
+   rte_free(cpr->cp_ring_struct);
+   rte_free(cpr);
 }

 /* For the default completion ring only */
-void bnxt_init_def_ring_struct(struct bnxt *bp)
+int bnxt_init_def_ring_struct(struct bnxt *bp, unsigned int socket_id)
 {
-   struct bnxt_cp_ring_info *cpr = bp->def_cp_ring;
-   struct bnxt_ring_struct *ring = cpr->cp_ring_struct;
+   struct bnxt_cp_ring_info *cpr;
+   struct bnxt_ring_struct *ring;

+   cpr = rte_zmalloc_socket("bnxt_cp_ring",
+sizeof(struct bnxt_cp_ring_info),
+RTE_CACHE_LINE_SIZE, socket_id);
+   if (!cpr)
+   return -ENOMEM;
+   bp->def_cp_ring = cpr;
+
+   ring = rte_zmalloc_socket("bnxt_cp_ring_struct",
+ sizeof(struct bnxt_ring_struct),
+ RTE_CACHE_LINE_SIZE, socket_id);
+   if (!ring)
+   return -ENOMEM;
+   cpr->cp_ring_struct = ring;
ring->bd = (void *)cpr->cp_desc_ring;
ring->bd_dma = cpr->cp_desc_mapping;
ring->ring_size = rte_align32pow2(DEFAULT_CP_RING_SIZE);
ring->ring_mask = ring->ring_size - 1;
ring->vmem_size = 0;
ring->vmem = NULL;
+
+   return 0;
 }
diff --git a/drivers/net/bnxt/bnxt_cpr.h b/drivers/net/bnxt/bnxt_cpr.h
index f104281..3e25a75 100644
--- a/drivers/net/bnxt/bnxt_cpr.h
+++ b/drivers/net/bnxt/bnxt_cpr.h
@@ -79,7 +79,7 @@ struct bnxt_cp_ring_info {

 struct bnxt;
 void bnxt_free_def_cp_ring(struct bnxt *bp);
-void bnxt_init_def_ring_struct(struct bnxt *bp);
+int bnxt_init_def_ring_struct(struct bnxt *bp, unsigned int socket_id);
 void bnxt_handle_async_event(struct bnxt *bp, struct cmpl_base *cmp);
 void bnxt_handle_fwd_req(struct bnxt *bp, struct cmpl_base *cmp);

diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c
index 90a116b..2fe4de8 100644
--- a/drivers/net/bnxt/bnxt_rxq.c
+++ b/drivers/net/bnxt/bnxt_rxq.c
@@ -271,10 +271,12 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
 {
struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
struct bnxt_rx_queue *rxq;
+   int rc = 0;

if (!nb_desc || nb_desc > MAX_RX_DESC_CNT) {
RTE_LOG(ERR, PMD, "nb_desc %d is invalid", nb_desc);
-   return -EINVAL;
+   rc = -EINVAL;
+   goto out;
}

if (eth_dev->data->rx_queues) {
@@ -286,14 +288,17 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
 RTE_CACHE_LINE_SIZE, socket_id);
if (!rxq) {
RTE_LOG(ERR, PMD, "bnxt_rx_queue allocation failed!");
-   return -ENOMEM;
+   rc = -ENOMEM;
+   goto out;
}
rxq->bp = bp;
rxq->mb_pool = mp;
rxq->nb_rx_desc = nb_desc;
rxq->rx_free_thresh = rx_conf->rx_free_thresh;

-   bnxt_init_rx_ring_struct(rxq);
+   rc = bnxt_init_rx_ring_struct(rxq, socket_id);
+   if (rc)
+   goto out;

rxq->queue_id = queue_idx;
rxq->port_id = eth_dev->data->port_id;
@@ -306,8 +311,10 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
"bnxt_rx_ring")) {
RTE_LOG(ERR, PMD, "ring_dma_zone_reserve for rx_ring failed!");
bnxt_rx_queue_release_op(rxq);
-   return -ENOMEM;
+   rc = -ENOMEM;
+   goto out;
}

-   return 0;
+out:
+   return rc;
 }
diff --git a/drivers/net/bnxt/bnxt_rxr.c b/drivers/net/bnxt/bnxt_rxr.c
index eed88c6..5a6f2fe 100644
--- a/drivers/net/bnxt/bnxt_rxr.c
+++ b/drivers/net/bnxt/bnxt_rxr.c
@@ -252,17 +252,20 @@ void 

[dpdk-dev] [PATCH v2 14/40] bnxt: initial Rx ring code

2016-05-13 Thread Stephen Hurd
Initial implementation of rx_pkt_burst
Add code to allocate rings to bnxt_ring.c

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/Makefile  |   1 +
 drivers/net/bnxt/bnxt_ethdev.c |   3 +-
 drivers/net/bnxt/bnxt_ring.c   |  20 +-
 drivers/net/bnxt/bnxt_rxq.c|  34 ++-
 drivers/net/bnxt/bnxt_rxr.c| 338 +++
 drivers/net/bnxt/bnxt_rxr.h|  62 +
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 474 +
 7 files changed, 915 insertions(+), 17 deletions(-)
 create mode 100644 drivers/net/bnxt/bnxt_rxr.c
 create mode 100644 drivers/net/bnxt/bnxt_rxr.h

diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile
index 0785681..4d35412 100644
--- a/drivers/net/bnxt/Makefile
+++ b/drivers/net/bnxt/Makefile
@@ -54,6 +54,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_filter.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_rxq.c
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_rxr.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_stats.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txq.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txr.c
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 61e856a..e1b3e3a 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -42,6 +42,7 @@
 #include "bnxt.h"
 #include "bnxt_hwrm.h"
 #include "bnxt_rxq.h"
+#include "bnxt_rxr.h"
 #include "bnxt_stats.h"
 #include "bnxt_txq.h"
 #include "bnxt_txr.h"
@@ -260,7 +261,7 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
goto error;
}
eth_dev->dev_ops = _dev_ops;
-   /* eth_dev->rx_pkt_burst = _recv_pkts; */
+   eth_dev->rx_pkt_burst = _recv_pkts;
eth_dev->tx_pkt_burst = _xmit_pkts;

rc = bnxt_alloc_hwrm_resources(bp);
diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c
index bb20806..69837bf 100644
--- a/drivers/net/bnxt/bnxt_ring.c
+++ b/drivers/net/bnxt/bnxt_ring.c
@@ -36,6 +36,7 @@
 #include "bnxt.h"
 #include "bnxt_cpr.h"
 #include "bnxt_ring.h"
+#include "bnxt_rxr.h"
 #include "bnxt_txr.h"

 #include "hsi_struct_def_dpdk.h"
@@ -77,9 +78,8 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
const char *suffix)
 {
struct bnxt_ring_struct *cp_ring = cp_ring_info->cp_ring_struct;
+   struct bnxt_ring_struct *rx_ring;
struct bnxt_ring_struct *tx_ring;
-   /* TODO: RX ring */
-   /* struct bnxt_ring_struct *rx_ring; */
struct rte_pci_device *pdev = bp->pdev;
const struct rte_memzone *mz = NULL;
char mz_name[RTE_MEMZONE_NAMESIZE];
@@ -96,10 +96,9 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
tx_ring_struct->vmem_size) : 0;

int rx_vmem_start = tx_vmem_start + tx_vmem_len;
-   /* TODO: RX ring */
-   int rx_vmem_len = /*
-   rx_ring_info ? RTE_CACHE_LINE_ROUNDUP(rx_ring_info->
-   rx_ring_struct->vmem_size) : */ 0;
+   int rx_vmem_len =
+   rx_ring_info ? RTE_CACHE_LINE_ROUNDUP(rx_ring_info->
+   rx_ring_struct->vmem_size) : 0;

int cp_ring_start = rx_vmem_start + rx_vmem_len;
int cp_ring_len = RTE_CACHE_LINE_ROUNDUP(cp_ring->ring_size *
@@ -111,10 +110,9 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
   sizeof(struct tx_bd_long)) : 0;

int rx_ring_start = tx_ring_start + tx_ring_len;
-   /* TODO: RX ring */
-   int rx_ring_len = /* rx_ring_info ?
+   int rx_ring_len = rx_ring_info ?
RTE_CACHE_LINE_ROUNDUP(rx_ring_info->rx_ring_struct->ring_size *
-  sizeof(struct rx_prod_pkt_bd)) : */ 0;
+  sizeof(struct rx_prod_pkt_bd)) : 0;

int total_alloc_len = rx_ring_start + rx_ring_len;

@@ -152,9 +150,8 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
}
}

-/*
if (rx_ring_info) {
-   rx_ring = _ring_info->rx_ring_struct;
+   rx_ring = rx_ring_info->rx_ring_struct;

rx_ring->bd = ((char *)mz->addr + rx_ring_start);
rx_ring_info->rx_desc_ring =
@@ -171,7 +168,6 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
(struct bnxt_sw_rx_bd *)rx_ring->vmem;
}
}
-*/

cp_ring->bd = ((char *)mz->addr + cp_ring_start);
cp_ring->bd_dma = mz->phys_addr + cp_ring_start;
diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c
index b284e20..90a116b 100644
--- a/drivers/net/bnxt/bnxt_rxq.c
+++ b/drivers/net/bnxt/bnxt_rxq.c
@@ -41,6 +41,7 @@
 #include "bnxt_hwrm.h"
 #include "bnxt_ring.h"
 #include "bnxt_rxq.h"

[dpdk-dev] [PATCH v2 13/40] bnxt: initial Tx ring code

2016-05-13 Thread Stephen Hurd
Initial implementation of rx_pkt_burst
Add code to allocate rings to bnxt_ring.c

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/Makefile  |   1 +
 drivers/net/bnxt/bnxt_cpr.h|   4 +-
 drivers/net/bnxt/bnxt_ethdev.c |   5 +-
 drivers/net/bnxt/bnxt_ring.c   | 140 +
 drivers/net/bnxt/bnxt_ring.h   |   8 +
 drivers/net/bnxt/bnxt_txq.c|  42 ++-
 drivers/net/bnxt/bnxt_txr.c| 314 
 drivers/net/bnxt/bnxt_txr.h|  71 +
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 512 +
 9 files changed, 1086 insertions(+), 11 deletions(-)
 create mode 100644 drivers/net/bnxt/bnxt_txr.c
 create mode 100644 drivers/net/bnxt/bnxt_txr.h

diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile
index f6a04f8..0785681 100644
--- a/drivers/net/bnxt/Makefile
+++ b/drivers/net/bnxt/Makefile
@@ -56,6 +56,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_rxq.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_stats.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txq.c
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txr.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c

 #
diff --git a/drivers/net/bnxt/bnxt_cpr.h b/drivers/net/bnxt/bnxt_cpr.h
index e6333fc..f104281 100644
--- a/drivers/net/bnxt/bnxt_cpr.h
+++ b/drivers/net/bnxt/bnxt_cpr.h
@@ -51,11 +51,11 @@

 #define B_CP_DB_REARM(cpr, raw_cons)   \
(*(uint32_t *)((cpr)->cp_doorbell) = (DB_CP_REARM_FLAGS | \
-   RING_CMP(>cp_ring_struct, raw_cons)))
+   RING_CMP(cpr->cp_ring_struct, raw_cons)))

 #define B_CP_DIS_DB(cpr, raw_cons) \
(*(uint32_t *)((cpr)->cp_doorbell) = (DB_CP_FLAGS | \
-   RING_CMP(>cp_ring_struct, raw_cons)))
+   RING_CMP(cpr->cp_ring_struct, raw_cons)))

 struct bnxt_ring_struct;
 struct bnxt_cp_ring_info {
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 786318c..61e856a 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -44,6 +44,7 @@
 #include "bnxt_rxq.h"
 #include "bnxt_stats.h"
 #include "bnxt_txq.h"
+#include "bnxt_txr.h"

 #define DRV_MODULE_NAME"bnxt"
 static const char bnxt_version[] =
@@ -259,10 +260,8 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
goto error;
}
eth_dev->dev_ops = _dev_ops;
-   /*
-   eth_dev->rx_pkt_burst = _recv_pkts;
+   /* eth_dev->rx_pkt_burst = _recv_pkts; */
eth_dev->tx_pkt_burst = _xmit_pkts;
-*/

rc = bnxt_alloc_hwrm_resources(bp);
if (rc) {
diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c
index 0434b07..bb20806 100644
--- a/drivers/net/bnxt/bnxt_ring.c
+++ b/drivers/net/bnxt/bnxt_ring.c
@@ -31,8 +31,14 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */

+#include 
+
 #include "bnxt.h"
+#include "bnxt_cpr.h"
 #include "bnxt_ring.h"
+#include "bnxt_txr.h"
+
+#include "hsi_struct_def_dpdk.h"

 /*
  * Generic ring handling
@@ -49,3 +55,137 @@ void bnxt_free_ring(struct bnxt_ring_struct *ring)
*ring->vmem = NULL;
}
 }
+
+/*
+ * Allocates a completion ring with vmem and stats optionally also allocating
+ * a TX and/or RX ring.  Passing NULL as tx_ring_info and/or rx_ring_info
+ * to not allocate them.
+ *
+ * Order in the allocation is:
+ * stats - Always non-zero length
+ * cp vmem - Always zero-length, supported for the bnxt_ring_struct abstraction
+ * tx vmem - Only non-zero length if tx_ring_info is not NULL
+ * rx vmem - Only non-zero length if rx_ring_info is not NULL
+ * cp bd ring - Always non-zero length
+ * tx bd ring - Only non-zero length if tx_ring_info is not NULL
+ * rx bd ring - Only non-zero length if rx_ring_info is not NULL
+ */
+int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
+   struct bnxt_tx_ring_info *tx_ring_info,
+   struct bnxt_rx_ring_info *rx_ring_info,
+   struct bnxt_cp_ring_info *cp_ring_info,
+   const char *suffix)
+{
+   struct bnxt_ring_struct *cp_ring = cp_ring_info->cp_ring_struct;
+   struct bnxt_ring_struct *tx_ring;
+   /* TODO: RX ring */
+   /* struct bnxt_ring_struct *rx_ring; */
+   struct rte_pci_device *pdev = bp->pdev;
+   const struct rte_memzone *mz = NULL;
+   char mz_name[RTE_MEMZONE_NAMESIZE];
+
+   int stats_len = (tx_ring_info || rx_ring_info) ?
+   RTE_CACHE_LINE_ROUNDUP(sizeof(struct ctx_hw_stats64)) : 0;
+
+   int cp_vmem_start = stats_len;
+   int cp_vmem_len = RTE_CACHE_LINE_ROUNDUP(cp_ring->vmem_size);
+
+   int tx_vmem_start = cp_vmem_start + cp_vmem_len;
+ 

[dpdk-dev] [PATCH v2 12/40] bnxt: statistics operations

2016-05-13 Thread Stephen Hurd
Add get and clear staitstics operations and the asociated HWRM calls.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/Makefile  |   1 +
 drivers/net/bnxt/bnxt.h|   5 +-
 drivers/net/bnxt/bnxt_cpr.c|   5 +-
 drivers/net/bnxt/bnxt_cpr.h|   2 -
 drivers/net/bnxt/bnxt_ethdev.c |   3 +
 drivers/net/bnxt/bnxt_hwrm.c   |  49 
 drivers/net/bnxt/bnxt_hwrm.h   |   8 +-
 drivers/net/bnxt/bnxt_rxq.c|   1 +
 drivers/net/bnxt/bnxt_stats.c  | 142 +
 drivers/net/bnxt/bnxt_stats.h  |  44 ++
 drivers/net/bnxt/bnxt_txq.c|   1 +
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 107 +
 12 files changed, 358 insertions(+), 10 deletions(-)
 create mode 100644 drivers/net/bnxt/bnxt_stats.c
 create mode 100644 drivers/net/bnxt/bnxt_stats.h

diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile
index 21ed71c..f6a04f8 100644
--- a/drivers/net/bnxt/Makefile
+++ b/drivers/net/bnxt/Makefile
@@ -54,6 +54,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_filter.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_rxq.c
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_stats.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txq.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 38b590b..96f162e 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -42,9 +42,6 @@
 #include 
 #include 

-/* TODO make bnxt.def_cp_ring a pointer to avoid this... */
-#include "bnxt_cpr.h"
-
 #define BNXT_MAX_MTU   9000
 #define VLAN_TAG_SIZE  4

@@ -141,7 +138,7 @@ struct bnxt {
struct bnxt_tx_queue **tx_queues;

/* Default completion ring */
-   struct bnxt_cp_ring_infodef_cp_ring;
+   struct bnxt_cp_ring_info*def_cp_ring;

unsignednr_vnics;

diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c
index ff82335..34e45ef 100644
--- a/drivers/net/bnxt/bnxt_cpr.c
+++ b/drivers/net/bnxt/bnxt_cpr.c
@@ -35,6 +35,7 @@
 #include "bnxt_cpr.h"
 #include "bnxt_hwrm.h"
 #include "bnxt_ring.h"
+#include "hsi_struct_def_dpdk.h"

 /*
  * Async event handling
@@ -118,7 +119,7 @@ reject:
 /* For the default completion ring only */
 void bnxt_free_def_cp_ring(struct bnxt *bp)
 {
-   struct bnxt_cp_ring_info *cpr = >def_cp_ring;
+   struct bnxt_cp_ring_info *cpr = bp->def_cp_ring;
struct bnxt_ring_struct *ring = cpr->cp_ring_struct;

bnxt_free_ring(ring);
@@ -127,7 +128,7 @@ void bnxt_free_def_cp_ring(struct bnxt *bp)
 /* For the default completion ring only */
 void bnxt_init_def_ring_struct(struct bnxt *bp)
 {
-   struct bnxt_cp_ring_info *cpr = >def_cp_ring;
+   struct bnxt_cp_ring_info *cpr = bp->def_cp_ring;
struct bnxt_ring_struct *ring = cpr->cp_ring_struct;

ring->bd = (void *)cpr->cp_desc_ring;
diff --git a/drivers/net/bnxt/bnxt_cpr.h b/drivers/net/bnxt/bnxt_cpr.h
index 878c7c9..e6333fc 100644
--- a/drivers/net/bnxt/bnxt_cpr.h
+++ b/drivers/net/bnxt/bnxt_cpr.h
@@ -34,8 +34,6 @@
 #ifndef _BNXT_CPR_H_
 #define _BNXT_CPR_H_

-#include "hsi_struct_def_dpdk.h"
-
 #define CMP_VALID(cmp, raw_cons, ring) \
(!!(((struct cmpl_base *)(cmp))->info3_v & CMPL_BASE_V) ==  \
 !((raw_cons) & ((ring)->ring_size)))
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index df39fae..786318c 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -42,6 +42,7 @@
 #include "bnxt.h"
 #include "bnxt_hwrm.h"
 #include "bnxt_rxq.h"
+#include "bnxt_stats.h"
 #include "bnxt_txq.h"

 #define DRV_MODULE_NAME"bnxt"
@@ -178,6 +179,8 @@ static int bnxt_dev_configure_op(struct rte_eth_dev 
*eth_dev)
 static struct eth_dev_ops bnxt_dev_ops = {
.dev_infos_get = bnxt_dev_info_get_op,
.dev_configure = bnxt_dev_configure_op,
+   .stats_get = bnxt_stats_get_op,
+   .stats_reset = bnxt_stats_reset_op,
.rx_queue_setup = bnxt_rx_queue_setup_op,
.rx_queue_release = bnxt_rx_queue_release_op,
.tx_queue_setup = bnxt_tx_queue_setup_op,
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 82139ca..50d8b89 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -39,8 +39,11 @@
 #include 

 #include "bnxt.h"
+#include "bnxt_cpr.h"
 #include "bnxt_filter.h"
 #include "bnxt_hwrm.h"
+#include "bnxt_rxq.h"
+#include "bnxt_txq.h"
 #include "hsi_struct_def_dpdk.h"

 #define HWRM_CMD_TIMEOUT   2000
@@ -436,10 +439,56 @@ int bnxt_hwrm_queue_qportcfg(struct bnxt *bp)
return rc;
 }

+int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)

[dpdk-dev] [PATCH v2 11/40] bnxt: add Rx queue create/destroy operations

2016-05-13 Thread Stephen Hurd
Initial create/destroy queue code.  Requires RX ring support to be
functional.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/Makefile  |   1 +
 drivers/net/bnxt/bnxt.h|   2 +
 drivers/net/bnxt/bnxt_ethdev.c |   3 +
 drivers/net/bnxt/bnxt_rxq.c| 286 +
 drivers/net/bnxt/bnxt_rxq.h|  74 +
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 121 ++
 6 files changed, 487 insertions(+)
 create mode 100644 drivers/net/bnxt/bnxt_rxq.c
 create mode 100644 drivers/net/bnxt/bnxt_rxq.h

diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile
index 13a90b9..21ed71c 100644
--- a/drivers/net/bnxt/Makefile
+++ b/drivers/net/bnxt/Makefile
@@ -53,6 +53,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_filter.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_rxq.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txq.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 54ddd24..38b590b 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -143,6 +143,8 @@ struct bnxt {
/* Default completion ring */
struct bnxt_cp_ring_infodef_cp_ring;

+   unsignednr_vnics;
+
struct bnxt_vnic_info   *vnic_info;
STAILQ_HEAD(, bnxt_vnic_info)   free_vnic_list;

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index d8dbc10..df39fae 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -41,6 +41,7 @@

 #include "bnxt.h"
 #include "bnxt_hwrm.h"
+#include "bnxt_rxq.h"
 #include "bnxt_txq.h"

 #define DRV_MODULE_NAME"bnxt"
@@ -177,6 +178,8 @@ static int bnxt_dev_configure_op(struct rte_eth_dev 
*eth_dev)
 static struct eth_dev_ops bnxt_dev_ops = {
.dev_infos_get = bnxt_dev_info_get_op,
.dev_configure = bnxt_dev_configure_op,
+   .rx_queue_setup = bnxt_rx_queue_setup_op,
+   .rx_queue_release = bnxt_rx_queue_release_op,
.tx_queue_setup = bnxt_tx_queue_setup_op,
.tx_queue_release = bnxt_tx_queue_release_op,
 };
diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c
new file mode 100644
index 000..4ba5d75
--- /dev/null
+++ b/drivers/net/bnxt/bnxt_rxq.c
@@ -0,0 +1,286 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) Broadcom Limited.
+ *   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 Broadcom Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+
+#include 
+
+#include "bnxt.h"
+#include "bnxt_filter.h"
+#include "bnxt_hwrm.h"
+#include "bnxt_ring.h"
+#include "bnxt_rxq.h"
+#include "bnxt_vnic.h"
+#include "hsi_struct_def_dpdk.h"
+
+/*
+ * RX Queues
+ */
+
+void bnxt_free_rxq_stats(struct bnxt_rx_queue *rxq)
+{
+   struct bnxt_cp_ring_info *cpr = rxq->cp_ring;
+
+   /* 'Unreserve' rte_memzone */
+   /* N/A */
+
+   if (cpr->hw_stats)
+   cpr->hw_stats = NULL;
+}
+
+int bnxt_mq_rx_configure(struct bnxt *bp)
+{
+   struct rte_eth_conf *dev_conf = >eth_dev->data->dev_conf;
+   unsigned i, j, nb_q_per_grp, ring_idx;
+   int start_grp_id, end_grp_id, rc = 0;
+   struct bnxt_vnic_info *vnic;
+   struct bnxt_filter_info *filter;
+   struct 

[dpdk-dev] [PATCH v2 10/40] bnxt: add Tx queue operations (nonfunctional)

2016-05-13 Thread Stephen Hurd
Add code to create/destroy TX queues.  This still requires TX ring support
to be completed in a future commit.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/Makefile  |   1 +
 drivers/net/bnxt/bnxt_ethdev.c |   3 +
 drivers/net/bnxt/bnxt_txq.c| 125 +
 drivers/net/bnxt/bnxt_txq.h|  75 +
 4 files changed, 204 insertions(+)
 create mode 100644 drivers/net/bnxt/bnxt_txq.c
 create mode 100644 drivers/net/bnxt/bnxt_txq.h

diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile
index b7834b1..13a90b9 100644
--- a/drivers/net/bnxt/Makefile
+++ b/drivers/net/bnxt/Makefile
@@ -53,6 +53,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_filter.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txq.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c

 #
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 1852035..d8dbc10 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -41,6 +41,7 @@

 #include "bnxt.h"
 #include "bnxt_hwrm.h"
+#include "bnxt_txq.h"

 #define DRV_MODULE_NAME"bnxt"
 static const char bnxt_version[] =
@@ -176,6 +177,8 @@ static int bnxt_dev_configure_op(struct rte_eth_dev 
*eth_dev)
 static struct eth_dev_ops bnxt_dev_ops = {
.dev_infos_get = bnxt_dev_info_get_op,
.dev_configure = bnxt_dev_configure_op,
+   .tx_queue_setup = bnxt_tx_queue_setup_op,
+   .tx_queue_release = bnxt_tx_queue_release_op,
 };

 static bool bnxt_vf_pciid(uint16_t id)
diff --git a/drivers/net/bnxt/bnxt_txq.c b/drivers/net/bnxt/bnxt_txq.c
new file mode 100644
index 000..cb3dd8e
--- /dev/null
+++ b/drivers/net/bnxt/bnxt_txq.c
@@ -0,0 +1,125 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) Broadcom Limited.
+ *   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 Broadcom Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+
+#include 
+
+#include "bnxt.h"
+#include "bnxt_ring.h"
+#include "bnxt_txq.h"
+
+/*
+ * TX Queues
+ */
+
+void bnxt_free_txq_stats(struct bnxt_tx_queue *txq)
+{
+   struct bnxt_cp_ring_info *cpr = txq->cp_ring;
+
+   /* 'Unreserve' rte_memzone */
+   /* N/A */
+
+   if (cpr->hw_stats)
+   cpr->hw_stats = NULL;
+}
+
+static void bnxt_tx_queue_release_mbufs(struct bnxt_tx_queue *txq __rte_unused)
+{
+   /* TODO: Requires interaction with TX ring */
+}
+
+void bnxt_free_tx_mbufs(struct bnxt *bp)
+{
+   struct bnxt_tx_queue *txq;
+   int i;
+
+   for (i = 0; i < (int)bp->tx_nr_rings; i++) {
+   txq = bp->tx_queues[i];
+   bnxt_tx_queue_release_mbufs(txq);
+   }
+}
+
+void bnxt_tx_queue_release_op(void *tx_queue)
+{
+   struct bnxt_tx_queue *txq = (struct bnxt_tx_queue *)tx_queue;
+
+   if (txq) {
+   /* TODO: Free ring and stats here */
+   rte_free(txq);
+   }
+}
+
+int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
+  uint16_t queue_idx,
+  uint16_t nb_desc,
+  unsigned int socket_id,
+  const struct rte_eth_txconf *tx_conf)
+{
+   struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
+   struct 

[dpdk-dev] [PATCH v2 09/40] bnxt: add L2 filter alloc/init/free

2016-05-13 Thread Stephen Hurd
Add the L2 filter structure and the alloc/init/free functions for
dealing with them.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/Makefile  |   1 +
 drivers/net/bnxt/bnxt.h|   3 +
 drivers/net/bnxt/bnxt_filter.c | 175 
 drivers/net/bnxt/bnxt_filter.h |  74 +
 drivers/net/bnxt/bnxt_hwrm.c   |  21 ++
 drivers/net/bnxt/bnxt_hwrm.h   |   3 +
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 505 +
 7 files changed, 782 insertions(+)
 create mode 100644 drivers/net/bnxt/bnxt_filter.c
 create mode 100644 drivers/net/bnxt/bnxt_filter.h

diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile
index afd1690..b7834b1 100644
--- a/drivers/net/bnxt/Makefile
+++ b/drivers/net/bnxt/Makefile
@@ -50,6 +50,7 @@ EXPORT_MAP := rte_pmd_bnxt_version.map
 #
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_cpr.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ethdev.c
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_filter.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c
diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 4e0b514..54ddd24 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -146,6 +146,9 @@ struct bnxt {
struct bnxt_vnic_info   *vnic_info;
STAILQ_HEAD(, bnxt_vnic_info)   free_vnic_list;

+   struct bnxt_filter_info *filter_info;
+   STAILQ_HEAD(, bnxt_filter_info) free_filter_list;
+
/* VNIC pointer for flow filter (VMDq) pools */
 #define MAX_FF_POOLS   ETH_64_POOLS
STAILQ_HEAD(, bnxt_vnic_info)   ff_pool[MAX_FF_POOLS];
diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c
new file mode 100644
index 000..f03a1dc
--- /dev/null
+++ b/drivers/net/bnxt/bnxt_filter.c
@@ -0,0 +1,175 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) Broadcom Limited.
+ *   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 Broadcom Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+
+#include 
+#include 
+
+#include "bnxt.h"
+#include "bnxt_filter.h"
+#include "bnxt_hwrm.h"
+#include "bnxt_vnic.h"
+#include "hsi_struct_def_dpdk.h"
+
+/*
+ * Filter Functions
+ */
+
+struct bnxt_filter_info *bnxt_alloc_filter(struct bnxt *bp)
+{
+   struct bnxt_filter_info *filter;
+
+   /* Find the 1st unused filter from the free_filter_list pool*/
+   filter = STAILQ_FIRST(>free_filter_list);
+   if (!filter) {
+   RTE_LOG(ERR, PMD, "No more free filter resources\n");
+   return NULL;
+   }
+   STAILQ_REMOVE_HEAD(>free_filter_list, next);
+
+   /* Default to L2 MAC Addr filter */
+   filter->flags = HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX;
+   filter->enables = HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR |
+   HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR_MASK;
+   memcpy(filter->l2_addr, bp->eth_dev->data->mac_addrs->addr_bytes,
+  ETHER_ADDR_LEN);
+   memset(filter->l2_addr_mask, 0xff, ETHER_ADDR_LEN);
+   return filter;
+}
+
+void bnxt_init_filters(struct bnxt *bp)
+{
+   struct bnxt_filter_info *filter;
+   int i, max_filters;
+
+   if (BNXT_PF(bp)) {
+   struct bnxt_pf_info *pf = >pf;
+
+   max_filters = pf->max_l2_ctx;
+   } else {
+   struct 

[dpdk-dev] [PATCH v2 08/40] bnxt: add completion ring support

2016-05-13 Thread Stephen Hurd
Structures, macros, and functions for working with completion rings
in the driver.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/Makefile  |   1 +
 drivers/net/bnxt/bnxt.h|   6 +
 drivers/net/bnxt/bnxt_cpr.c| 139 +++
 drivers/net/bnxt/bnxt_cpr.h|  88 
 drivers/net/bnxt/bnxt_hwrm.c   |  18 +++
 drivers/net/bnxt/bnxt_hwrm.h   |   2 +
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 239 -
 7 files changed, 487 insertions(+), 6 deletions(-)
 create mode 100644 drivers/net/bnxt/bnxt_cpr.c
 create mode 100644 drivers/net/bnxt/bnxt_cpr.h

diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile
index 757ea62..afd1690 100644
--- a/drivers/net/bnxt/Makefile
+++ b/drivers/net/bnxt/Makefile
@@ -48,6 +48,7 @@ EXPORT_MAP := rte_pmd_bnxt_version.map
 #
 # all source are stored in SRCS-y
 #
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_cpr.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c
diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 846972e..4e0b514 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -42,6 +42,9 @@
 #include 
 #include 

+/* TODO make bnxt.def_cp_ring a pointer to avoid this... */
+#include "bnxt_cpr.h"
+
 #define BNXT_MAX_MTU   9000
 #define VLAN_TAG_SIZE  4

@@ -137,6 +140,9 @@ struct bnxt {
unsignedtx_cp_nr_rings;
struct bnxt_tx_queue **tx_queues;

+   /* Default completion ring */
+   struct bnxt_cp_ring_infodef_cp_ring;
+
struct bnxt_vnic_info   *vnic_info;
STAILQ_HEAD(, bnxt_vnic_info)   free_vnic_list;

diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c
new file mode 100644
index 000..ff82335
--- /dev/null
+++ b/drivers/net/bnxt/bnxt_cpr.c
@@ -0,0 +1,139 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) Broadcom Limited.
+ *   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 Broadcom Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "bnxt.h"
+#include "bnxt_cpr.h"
+#include "bnxt_hwrm.h"
+#include "bnxt_ring.h"
+
+/*
+ * Async event handling
+ */
+void bnxt_handle_async_event(struct bnxt *bp __rte_unused,
+struct cmpl_base *cmp)
+{
+   struct hwrm_async_event_cmpl *async_cmp =
+   (struct hwrm_async_event_cmpl *)cmp;
+
+   /* TODO: HWRM async events are not defined yet */
+   /* Needs to handle: link events, error events, etc. */
+   switch (async_cmp->event_id) {
+   case 0:
+   /* Assume LINK_CHANGE == 0 */
+   RTE_LOG(INFO, PMD, "Link change event\n");
+
+   /* Can just prompt the update_op routine to do a qcfg
+  instead of doing the actual qcfg */
+   break;
+   case 1:
+   break;
+   default:
+   RTE_LOG(ERR, PMD, "handle_async_event id = 0x%x\n",
+   async_cmp->event_id);
+   break;
+   }
+}
+
+void bnxt_handle_fwd_req(struct bnxt *bp, struct cmpl_base *cmpl)
+{
+   struct hwrm_fwd_req_cmpl *fwd_cmpl = (struct hwrm_fwd_req_cmpl *)cmpl;
+   struct input *fwd_cmd;
+   uint16_t logical_vf_id, error_code;
+
+   /* Qualify the fwd request */
+   if 

[dpdk-dev] [PATCH v2 07/40] bnxt: declare ring structs and free() func

2016-05-13 Thread Stephen Hurd
Declare ring structures and a ring free() function.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/Makefile|  1 +
 drivers/net/bnxt/bnxt_ring.c | 51 
 drivers/net/bnxt/bnxt_ring.h | 92 
 3 files changed, 144 insertions(+)
 create mode 100644 drivers/net/bnxt/bnxt_ring.c
 create mode 100644 drivers/net/bnxt/bnxt_ring.h

diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile
index c57afaa..757ea62 100644
--- a/drivers/net/bnxt/Makefile
+++ b/drivers/net/bnxt/Makefile
@@ -50,6 +50,7 @@ EXPORT_MAP := rte_pmd_bnxt_version.map
 #
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c

 #
diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c
new file mode 100644
index 000..0434b07
--- /dev/null
+++ b/drivers/net/bnxt/bnxt_ring.c
@@ -0,0 +1,51 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) Broadcom Limited.
+ *   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 Broadcom Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "bnxt.h"
+#include "bnxt_ring.h"
+
+/*
+ * Generic ring handling
+ */
+
+void bnxt_free_ring(struct bnxt_ring_struct *ring)
+{
+   /* The actual ring is reserved via rte_memzone_reserve API.
+  The current document/code indicates that:
+  "Note: A reserved zone cannot be freed."
+*/
+   if (ring->vmem_size && *ring->vmem) {
+   memset((char *)*ring->vmem, 0, ring->vmem_size);
+   *ring->vmem = NULL;
+   }
+}
diff --git a/drivers/net/bnxt/bnxt_ring.h b/drivers/net/bnxt/bnxt_ring.h
new file mode 100644
index 000..f44025c
--- /dev/null
+++ b/drivers/net/bnxt/bnxt_ring.h
@@ -0,0 +1,92 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) Broadcom Limited.
+ *   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 Broadcom Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 

[dpdk-dev] [PATCH v2 06/40] bnxt: add vnic functions and structs

2016-05-13 Thread Stephen Hurd
Add functions to allocate, initialize, and free vnics.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/Makefile  |   1 +
 drivers/net/bnxt/bnxt.h|  14 ++
 drivers/net/bnxt/bnxt_vnic.c   | 277 +
 drivers/net/bnxt/bnxt_vnic.h   |  80 ++
 drivers/net/bnxt/hsi_struct_def_dpdk.h |   5 +-
 5 files changed, 376 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/bnxt/bnxt_vnic.c
 create mode 100644 drivers/net/bnxt/bnxt_vnic.h

diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile
index 9965597..c57afaa 100644
--- a/drivers/net/bnxt/Makefile
+++ b/drivers/net/bnxt/Makefile
@@ -50,6 +50,7 @@ EXPORT_MAP := rte_pmd_bnxt_version.map
 #
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c

 #
 # Export include files
diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index f1a620f..846972e 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -45,6 +45,13 @@
 #define BNXT_MAX_MTU   9000
 #define VLAN_TAG_SIZE  4

+enum bnxt_hw_context {
+   HW_CONTEXT_NONE = 0,
+   HW_CONTEXT_IS_RSS   = 1,
+   HW_CONTEXT_IS_COS   = 2,
+   HW_CONTEXT_IS_LB= 3,
+};
+
 struct bnxt_vf_info {
uint16_tfw_fid;
uint8_t mac_addr[ETHER_ADDR_LEN];
@@ -130,6 +137,13 @@ struct bnxt {
unsignedtx_cp_nr_rings;
struct bnxt_tx_queue **tx_queues;

+   struct bnxt_vnic_info   *vnic_info;
+   STAILQ_HEAD(, bnxt_vnic_info)   free_vnic_list;
+
+   /* VNIC pointer for flow filter (VMDq) pools */
+#define MAX_FF_POOLS   ETH_64_POOLS
+   STAILQ_HEAD(, bnxt_vnic_info)   ff_pool[MAX_FF_POOLS];
+
 #define MAX_NUM_MAC_ADDR   32
uint8_t mac_addr[ETHER_ADDR_LEN];

diff --git a/drivers/net/bnxt/bnxt_vnic.c b/drivers/net/bnxt/bnxt_vnic.c
new file mode 100644
index 000..c04c4c7
--- /dev/null
+++ b/drivers/net/bnxt/bnxt_vnic.c
@@ -0,0 +1,277 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2014-2015 Broadcom Corporation.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of Broadcom Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+
+#include 
+#include 
+
+#include "bnxt.h"
+#include "bnxt_vnic.h"
+#include "hsi_struct_def_dpdk.h"
+
+/*
+ * VNIC Functions
+ */
+
+static void prandom_bytes(void *dest_ptr, size_t len)
+{
+   char *dest = (char *)dest_ptr;
+   uint64_t rb;
+
+   while (len) {
+   rb = rte_rand();
+   if (len >= 8) {
+   memcpy(dest, , 8);
+   len -= 8;
+   dest += 8;
+   } else {
+   memcpy(dest, , len);
+   dest += len;
+   len = 0;
+   }
+   }
+}
+
+void bnxt_init_vnics(struct bnxt *bp)
+{
+   struct bnxt_vnic_info *vnic;
+   uint16_t max_vnics;
+   int i, j;
+
+   if (BNXT_PF(bp)) {
+   struct bnxt_pf_info *pf = >pf;
+
+   max_vnics = pf->max_vnics;
+   } else {
+   struct bnxt_vf_info *vf = >vf;
+
+   max_vnics = vf->max_vnics;
+   }
+   STAILQ_INIT(>free_vnic_list);
+   for (i = 0; i < max_vnics; i++) {
+   vnic = >vnic_info[i];
+  

[dpdk-dev] [PATCH v2 05/40] bnxt: add dev configure operation

2016-05-13 Thread Stephen Hurd
This adds the bnxt_hwrm_port_phy_cfg() HWRM call, and copies required
information into the new struct bnxt_link_info.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt.h|  32 +++
 drivers/net/bnxt/bnxt_ethdev.c |  24 ++
 drivers/net/bnxt/bnxt_hwrm.c   | 232 +++-
 drivers/net/bnxt/bnxt_hwrm.h   |   1 +
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 470 +
 5 files changed, 758 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 9ba2433..f1a620f 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -81,6 +81,29 @@ struct bnxt_pf_info {
struct bnxt_vf_info *vf;
 };

+/* Max wait time is 10 * 100ms = 1s */
+#define BNXT_LINK_WAIT_CNT 10
+#define BNXT_LINK_WAIT_INTERVAL100
+struct bnxt_link_info {
+   uint8_t phy_flags;
+   uint8_t mac_type;
+   uint8_t phy_link_status;
+   uint8_t loop_back;
+   uint8_t link_up;
+   uint8_t duplex;
+   uint8_t pause;
+   uint8_t force_pause;
+   uint8_t auto_pause;
+   uint8_t auto_mode;
+#define PHY_VER_LEN3
+   uint8_t phy_ver[PHY_VER_LEN];
+   uint16_tlink_speed;
+   uint16_tsupport_speeds;
+   uint16_tauto_link_speed;
+   uint16_tauto_link_speed_mask;
+   uint32_tpreemphasis;
+};
+
 #define BNXT_COS_QUEUE_COUNT   8
 struct bnxt_cos_queue_info {
uint8_t id;
@@ -99,6 +122,14 @@ struct bnxt {
 #define BNXT_PF(bp)(!((bp)->flags & BNXT_FLAG_VF))
 #define BNXT_VF(bp)((bp)->flags & BNXT_FLAG_VF)

+   unsignedrx_nr_rings;
+   unsignedrx_cp_nr_rings;
+   struct bnxt_rx_queue **rx_queues;
+
+   unsignedtx_nr_rings;
+   unsignedtx_cp_nr_rings;
+   struct bnxt_tx_queue **tx_queues;
+
 #define MAX_NUM_MAC_ADDR   32
uint8_t mac_addr[ETHER_ADDR_LEN];

@@ -109,6 +140,7 @@ struct bnxt {
uint16_tmax_req_len;
uint16_tmax_resp_len;

+   struct bnxt_link_info   link_info;
struct bnxt_cos_queue_info  cos_queue[BNXT_COS_QUEUE_COUNT];

struct bnxt_pf_info pf;
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index d55b9e9..1852035 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -146,12 +146,36 @@ found:
dev_info->vmdq_queue_base = 0;
 }

+/* Configure the device based on the configuration provided */
+static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
+{
+   struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
+   int rc;
+
+   bp->rx_queues = (void *)eth_dev->data->rx_queues;
+   bp->tx_queues = (void *)eth_dev->data->tx_queues;
+
+   /* Inherit new configurations */
+   bp->rx_nr_rings = eth_dev->data->nb_rx_queues;
+   bp->tx_nr_rings = eth_dev->data->nb_tx_queues;
+   bp->rx_cp_nr_rings = bp->rx_nr_rings;
+   bp->tx_cp_nr_rings = bp->tx_nr_rings;
+
+   if (eth_dev->data->dev_conf.rxmode.jumbo_frame)
+   eth_dev->data->mtu =
+   eth_dev->data->dev_conf.rxmode.max_rx_pkt_len -
+   ETHER_HDR_LEN - ETHER_CRC_LEN - VLAN_TAG_SIZE;
+   rc = bnxt_set_hwrm_link_config(bp, true);
+   return rc;
+}
+
 /*
  * Initialization
  */

 static struct eth_dev_ops bnxt_dev_ops = {
.dev_infos_get = bnxt_dev_info_get_op,
+   .dev_configure = bnxt_dev_configure_op,
 };

 static bool bnxt_vf_pciid(uint16_t id)
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 398f0f5..73d92c5 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -83,7 +83,7 @@ static int bnxt_hwrm_send_message_locked(struct bnxt *bp, 
void *msg,
/* Sanity check on the resp->resp_len */
rte_rmb();
if (resp->resp_len && resp->resp_len <=
-   bp->max_resp_len) {
+   bp->max_resp_len) {
/* Last byte of resp contains the valid key */
valid = (uint8_t *)resp + resp->resp_len - 1;
if (*valid == HWRM_RESP_VALID_KEY)
@@ -314,6 +314,61 @@ int bnxt_hwrm_func_driver_unregister(struct bnxt *bp, 
uint32_t flags)
return rc;
 }

+static int bnxt_hwrm_port_phy_cfg(struct bnxt *bp, struct bnxt_link_info *conf)
+{
+   int rc = 0;
+   struct hwrm_port_phy_cfg_input req = {.req_type = 0};
+   struct hwrm_port_phy_cfg_output *resp = 

[dpdk-dev] [PATCH v2 04/40] bnxt: add dev infos get operation

2016-05-13 Thread Stephen Hurd
Gets device info from the bp structure filled in the init() function.

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt.h|  3 ++
 drivers/net/bnxt/bnxt_ethdev.c | 96 +-
 2 files changed, 98 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index ebddeab..9ba2433 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -42,6 +42,9 @@
 #include 
 #include 

+#define BNXT_MAX_MTU   9000
+#define VLAN_TAG_SIZE  4
+
 struct bnxt_vf_info {
uint16_tfw_fid;
uint8_t mac_addr[ETHER_ADDR_LEN];
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 07519df..d55b9e9 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -53,11 +53,105 @@ static struct rte_pci_id bnxt_pci_id_map[] = {
 };

 /*
+ * Device configuration and status function
+ */
+
+static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
+ struct rte_eth_dev_info *dev_info)
+{
+   struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
+   uint16_t max_vnics, i, j, vpool, vrxq;
+
+   /* MAC Specifics */
+   dev_info->max_mac_addrs = MAX_NUM_MAC_ADDR;
+   dev_info->max_hash_mac_addrs = 0;
+
+   /* PF/VF specifics */
+   if (BNXT_PF(bp)) {
+   dev_info->max_rx_queues = bp->pf.max_rx_rings;
+   dev_info->max_tx_queues = bp->pf.max_tx_rings;
+   dev_info->max_vfs = bp->pf.active_vfs;
+   dev_info->reta_size = bp->pf.max_rsscos_ctx;
+   max_vnics = bp->pf.max_vnics;
+   } else {
+   dev_info->max_rx_queues = bp->vf.max_rx_rings;
+   dev_info->max_tx_queues = bp->vf.max_tx_rings;
+   dev_info->reta_size = bp->vf.max_rsscos_ctx;
+   max_vnics = bp->vf.max_vnics;
+   }
+
+   /* Fast path specifics */
+   dev_info->min_rx_bufsize = 1;
+   dev_info->max_rx_pktlen = BNXT_MAX_MTU + ETHER_HDR_LEN + ETHER_CRC_LEN
+ + VLAN_TAG_SIZE;
+   dev_info->rx_offload_capa = 0;
+   dev_info->tx_offload_capa = DEV_TX_OFFLOAD_IPV4_CKSUM |
+   DEV_TX_OFFLOAD_TCP_CKSUM |
+   DEV_TX_OFFLOAD_UDP_CKSUM |
+   DEV_TX_OFFLOAD_TCP_TSO;
+
+   /* *INDENT-OFF* */
+   dev_info->default_rxconf = (struct rte_eth_rxconf) {
+   .rx_thresh = {
+   .pthresh = 8,
+   .hthresh = 8,
+   .wthresh = 0,
+   },
+   .rx_free_thresh = 32,
+   .rx_drop_en = 0,
+   };
+
+   dev_info->default_txconf = (struct rte_eth_txconf) {
+   .tx_thresh = {
+   .pthresh = 32,
+   .hthresh = 0,
+   .wthresh = 0,
+   },
+   .tx_free_thresh = 32,
+   .tx_rs_thresh = 32,
+   .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
+ETH_TXQ_FLAGS_NOOFFLOADS,
+   };
+   /* *INDENT-ON* */
+
+   /*
+* TODO: default_rxconf, default_txconf, rx_desc_lim, and tx_desc_lim
+*   need further investigation.
+*/
+
+   /* VMDq resources */
+   vpool = 64; /* ETH_64_POOLS */
+   vrxq = 128; /* ETH_VMDQ_DCB_NUM_QUEUES */
+   for (i = 0; i < 4; vpool >>= 1, i++) {
+   if (max_vnics > vpool) {
+   for (j = 0; j < 5; vrxq >>= 1, j++) {
+   if (dev_info->max_rx_queues > vrxq) {
+   if (vpool > vrxq)
+   vpool = vrxq;
+   goto found;
+   }
+   }
+   /* Not enough resources to support VMDq */
+   break;
+   }
+   }
+   /* Not enough resources to support VMDq */
+   vpool = 0;
+   vrxq = 0;
+found:
+   dev_info->max_vmdq_pools = vpool;
+   dev_info->vmdq_queue_num = vrxq;
+
+   dev_info->vmdq_pool_base = 0;
+   dev_info->vmdq_queue_base = 0;
+}
+
+/*
  * Initialization
  */

 static struct eth_dev_ops bnxt_dev_ops = {
-0
+   .dev_infos_get = bnxt_dev_info_get_op,
 };

 static bool bnxt_vf_pciid(uint16_t id)
-- 
1.9.1



[dpdk-dev] [PATCH v2 03/40] bnxt: add driver register/unregister support

2016-05-13 Thread Stephen Hurd
Move init() cleanup into uninit() function
Fix .dev_private_size
Add require hwrm calls:
bnxt_hwrm_func_driver_register()
bnxt_hwrm_func_driver_unregister()

Signed-off-by: Stephen Hurd 
Reviewed-by: Ajit Kumar Khaparde 
---
 drivers/net/bnxt/bnxt.h|   1 +
 drivers/net/bnxt/bnxt_ethdev.c |  48 --
 drivers/net/bnxt/bnxt_hwrm.c   |  50 ++
 drivers/net/bnxt/bnxt_hwrm.h   |   3 +
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 277 -
 5 files changed, 359 insertions(+), 20 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 0f816ed..ebddeab 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -91,6 +91,7 @@ struct bnxt {
struct rte_pci_device   *pdev;

uint32_tflags;
+#define BNXT_FLAG_REGISTERED   (1<<0)
 #define BNXT_FLAG_VF   (1<<1)
 #define BNXT_PF(bp)(!((bp)->flags & BNXT_FLAG_VF))
 #define BNXT_VF(bp)((bp)->flags & BNXT_FLAG_VF)
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index a74cc6c..07519df 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -52,20 +52,12 @@ static struct rte_pci_id bnxt_pci_id_map[] = {
{.device_id = 0},
 };

-static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev)
-{
-   struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
-
-   rte_free(eth_dev->data->mac_addrs);
-   bnxt_free_hwrm_resources(bp);
-}
-
 /*
  * Initialization
  */

 static struct eth_dev_ops bnxt_dev_ops = {
-   .dev_close = bnxt_dev_close_op,
+0
 };

 static bool bnxt_vf_pciid(uint16_t id)
@@ -123,7 +115,8 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
eth_dev->pci_dev->addr.function < 4) {
RTE_LOG(ERR, PMD, "Function not enabled %x:\n",
eth_dev->pci_dev->addr.function);
-   return -ENOMEM;
+   rc = -ENOMEM;
+   goto error;
}

rte_eth_copy_pci_info(eth_dev, eth_dev->pci_dev);
@@ -148,11 +141,11 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
if (rc) {
RTE_LOG(ERR, PMD,
"hwrm resource allocation failure rc: %x\n", rc);
-   goto error;
+   goto error_free;
}
rc = bnxt_hwrm_ver_get(bp);
if (rc)
-   goto error;
+   goto error_free;
bnxt_hwrm_queue_qportcfg(bp);

/* Get the MAX capabilities for this function */
@@ -177,17 +170,38 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
memcpy(bp->mac_addr, bp->vf.mac_addr, sizeof(bp->mac_addr));
memcpy(_dev->data->mac_addrs[0], bp->mac_addr, ETHER_ADDR_LEN);

-   return -EPERM;
+   rc = bnxt_hwrm_func_driver_register(bp, 0,
+   bp->pf.vf_req_fwd);
+   if (rc) {
+   RTE_LOG(ERR, PMD,
+   "Failed to register driver");
+   rc = -EBUSY;
+   goto error_free;
+   }
+
+   RTE_LOG(INFO, PMD,
+   DRV_MODULE_NAME " found at mem %" PRIx64 ", node addr %pM\n",
+   eth_dev->pci_dev->mem_resource[0].phys_addr,
+   eth_dev->pci_dev->mem_resource[0].addr);
+
+   return 0;

 error_free:
-   bnxt_dev_close_op(eth_dev);
+   eth_dev->driver->eth_dev_uninit(eth_dev);
 error:
return rc;
 }

 static int
-bnxt_dev_uninit(struct rte_eth_dev *eth_dev __rte_unused) {
-   return 0;
+bnxt_dev_uninit(struct rte_eth_dev *eth_dev) {
+   struct bnxt *bp = eth_dev->data->dev_private;
+   int rc;
+
+   if (eth_dev->data->mac_addrs)
+   rte_free(eth_dev->data->mac_addrs);
+   rc = bnxt_hwrm_func_driver_unregister(bp, 0);
+   bnxt_free_hwrm_resources(bp);
+   return rc;
 }

 static struct eth_driver bnxt_rte_pmd = {
@@ -198,7 +212,7 @@ static struct eth_driver bnxt_rte_pmd = {
},
.eth_dev_init = bnxt_dev_init,
.eth_dev_uninit = bnxt_dev_uninit,
-   .dev_private_size = 32 /* this must be non-zero apparently */,
+   .dev_private_size = sizeof(struct bnxt),
 };

 static int bnxt_rte_pmd_init(const char *name, const char *params __rte_unused)
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 5b66721..398f0f5 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "bnxt.h"
 #include "bnxt_hwrm.h"
@@ -178,6 +179,34 @@ int bnxt_hwrm_func_qcaps(struct bnxt *bp)
return rc;
 }

+int bnxt_hwrm_func_driver_register(struct bnxt *bp, uint32_t flags,
+  uint32_t *vf_req_fwd)
+{
+   int rc;
+   struct hwrm_func_drv_rgtr_input req = {.req_type = 0 };
+   struct hwrm_func_drv_rgtr_output *resp = bp->hwrm_cmd_resp_addr;
+
+   if 

[dpdk-dev] [PATCH v2 02/40] bnxt: add HWRM init code

2016-05-13 Thread Stephen Hurd
Start adding HWRM support.
Initial commit just performs necessary HWRM queries for init, then
fails as before.

Thee used HWRM calls so far:
bnxt_hwrm_func_qcaps:
Queries device capabilities.

bnxt_hwrm_ver_get:
Gets the firmware version and interface specifications.
Returns an error if the firmware on the device is not
supported by the driver and ensures the response space
is large enough for the largest possible response.

bnxt_hwrm_queue_qportcfg:
Required to get the default queue ID.

Signed-off-by: Stephen Hurd 
Reviewed-by: David Christensen 
---
 drivers/net/bnxt/Makefile  |   1 +
 drivers/net/bnxt/bnxt.h| 114 
 drivers/net/bnxt/bnxt_ethdev.c | 113 
 drivers/net/bnxt/bnxt_hwrm.c   | 324 +++
 drivers/net/bnxt/bnxt_hwrm.h   |  53 ++
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 954 +
 6 files changed, 1559 insertions(+)
 create mode 100644 drivers/net/bnxt/bnxt.h
 create mode 100644 drivers/net/bnxt/bnxt_hwrm.c
 create mode 100644 drivers/net/bnxt/bnxt_hwrm.h
 create mode 100644 drivers/net/bnxt/hsi_struct_def_dpdk.h

diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile
index f6333fd..9965597 100644
--- a/drivers/net/bnxt/Makefile
+++ b/drivers/net/bnxt/Makefile
@@ -49,6 +49,7 @@ EXPORT_MAP := rte_pmd_bnxt_version.map
 # all source are stored in SRCS-y
 #
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ethdev.c
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c

 #
 # Export include files
diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
new file mode 100644
index 000..0f816ed
--- /dev/null
+++ b/drivers/net/bnxt/bnxt.h
@@ -0,0 +1,114 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) Broadcom Limited.
+ *   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 Broadcom Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _BNXT_H_
+#define _BNXT_H_
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+struct bnxt_vf_info {
+   uint16_tfw_fid;
+   uint8_t mac_addr[ETHER_ADDR_LEN];
+   uint16_tmax_rsscos_ctx;
+   uint16_tmax_cp_rings;
+   uint16_tmax_tx_rings;
+   uint16_tmax_rx_rings;
+   uint16_tmax_l2_ctx;
+   uint16_tmax_vnics;
+   struct bnxt_pf_info *pf;
+};
+
+struct bnxt_pf_info {
+#define BNXT_FIRST_PF_FID  1
+#define BNXT_MAX_VFS(bp)   (bp->pf.max_vfs)
+#define BNXT_FIRST_VF_FID  128
+#define BNXT_PF_RINGS_USED(bp) bnxt_get_num_queues(bp)
+#define BNXT_PF_RINGS_AVAIL(bp)(bp->pf.max_cp_rings - 
BNXT_PF_RINGS_USED(bp))
+   uint32_tfw_fid;
+   uint8_t port_id;
+   uint8_t mac_addr[ETHER_ADDR_LEN];
+   uint16_tmax_rsscos_ctx;
+   uint16_tmax_cp_rings;
+   uint16_tmax_tx_rings;
+   uint16_tmax_rx_rings;
+   uint16_tmax_l2_ctx;
+   uint16_tmax_vnics;
+   uint16_tfirst_vf_id;
+   uint16_tactive_vfs;
+   uint16_tmax_vfs;
+   void*vf_req_buf;
+   phys_addr_t vf_req_buf_dma_addr;
+   uint32_tvf_req_fwd[8];
+   struct bnxt_vf_info *vf;
+};
+

[dpdk-dev] [PATCH v2 01/40] bnxt: new driver for Broadcom NetXtreme-C devices

2016-05-13 Thread Stephen Hurd
Initial skeleton simply fails init.
Add nic guide and tie into build system.

Signed-off-by: Stephen Hurd 
---
 MAINTAINERS |   5 ++
 config/common_base  |   5 ++
 doc/guides/nics/bnxt.rst|  49 +++
 drivers/net/Makefile|   1 +
 drivers/net/bnxt/Makefile   |  63 ++
 drivers/net/bnxt/bnxt_ethdev.c  | 104 
 drivers/net/bnxt/rte_pmd_bnxt_version.map   |   4 +
 lib/librte_eal/common/include/rte_pci_dev_ids.h |  40 +++--
 mk/rte.app.mk   |   1 +
 9 files changed, 267 insertions(+), 5 deletions(-)
 create mode 100644 doc/guides/nics/bnxt.rst
 create mode 100644 drivers/net/bnxt/Makefile
 create mode 100644 drivers/net/bnxt/bnxt_ethdev.c
 create mode 100644 drivers/net/bnxt/rte_pmd_bnxt_version.map

diff --git a/MAINTAINERS b/MAINTAINERS
index ba4053a..c69b529 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -403,6 +403,11 @@ M: Declan Doherty 
 F: drivers/crypto/null/
 F: doc/guides/cryptodevs/null.rst

+Broadcom BNXT PMD
+M: Stephen Hurd 
+F: drivers/net/bnxt/
+F: doc/guides/nics/bnxt.rst
+

 Packet processing
 -
diff --git a/config/common_base b/config/common_base
index 3535c6e..08a19e1 100644
--- a/config/common_base
+++ b/config/common_base
@@ -245,6 +245,11 @@ CONFIG_RTE_LIBRTE_NFP_PMD=n
 CONFIG_RTE_LIBRTE_NFP_DEBUG=n

 #
+# Compile burst-oriented Broadcom BNXT PMD driver
+#
+CONFIG_RTE_LIBRTE_BNXT_PMD=y
+
+#
 # Compile software PMD backed by SZEDATA2 device
 #
 CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n
diff --git a/doc/guides/nics/bnxt.rst b/doc/guides/nics/bnxt.rst
new file mode 100644
index 000..2669e98
--- /dev/null
+++ b/doc/guides/nics/bnxt.rst
@@ -0,0 +1,49 @@
+..  BSD LICENSE
+Copyright 2016 Broadcom Limited
+
+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 Broadcom Limited 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.
+
+bnxt poll mode driver library
+=
+
+The bnxt poll mode library (**librte_pmd_bnxt**) implements support for
+**Broadcom NetXtreme? C-Series**.  These adapters support Standards-
+compliant 10/25/50Gbps 30MPPS full-duplex throughput.
+
+Information about this family of adapters can be found in the
+`NetXtreme? Brand section 
`_
+of the `Broadcom web site `_.
+
+Limitations
+---
+
+With the current driver, allocated mbufs must be large enough to hold
+the entire received frame.  If the mbufs are not large enough, the
+packets will be dropped.  This is most limiting when jumbo frames are
+used.
+
+SR-IOV is not supported.
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 6ba7658..3832706 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -45,6 +45,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4
 DIRS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5
 DIRS-$(CONFIG_RTE_LIBRTE_MPIPE_PMD) += mpipe
 DIRS-$(CONFIG_RTE_LIBRTE_NFP_PMD) += nfp
+DIRS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_NULL) += null
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_PCAP) += pcap
 DIRS-$(CONFIG_RTE_LIBRTE_QEDE_PMD) += qede
diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile
new file mode 100644
index 000..f6333fd
--- /dev/null
+++ b/drivers/net/bnxt/Makefile
@@ -0,0 +1,63 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+#   

[dpdk-dev] [PATCH] doc: move rel_notes instructions as comments

2016-05-13 Thread Olivier Matz
We don't want to have this instructions in the generated docs, so use
comments. It's also less confusing for people adding entries in the
documentation.

Signed-off-by: Olivier Matz 
---
 doc/guides/rel_notes/release_16_07.rst | 86 +-
 1 file changed, 43 insertions(+), 43 deletions(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index f6d543c..71d3540 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -1,50 +1,50 @@
 DPDK Release 16.07
 ==

-**Read this first.**
+.. **Read this first.**

-The text below explains how to update the release notes.
+   The text below explains how to update the release notes.

-Use proper spelling, capitalization and punctuation in all sections.
+   Use proper spelling, capitalization and punctuation in all sections.

-Variable and config names should be quoted as fixed width text: ``LIKE_THIS``.
+   Variable and config names should be quoted as fixed width text: 
``LIKE_THIS``.

-Build the docs and view the output file to ensure the changes are correct::
+   Build the docs and view the output file to ensure the changes are correct::

-   make doc-guides-html
+  make doc-guides-html

-   firefox build/doc/html/guides/rel_notes/release_16_07.html
+  firefox build/doc/html/guides/rel_notes/release_16_07.html


 New Features
 

-This section should contain new features added in this release. Sample format:
+.. This section should contain new features added in this release. Sample 
format:

-* **Add a title in the past tense with a full stop.**
+   * **Add a title in the past tense with a full stop.**

-  Add a short 1-2 sentence description in the past tense. The description
-  should be enough to allow someone scanning the release notes to understand
-  the new feature.
+ Add a short 1-2 sentence description in the past tense. The description
+ should be enough to allow someone scanning the release notes to understand
+ the new feature.

-  If the feature adds a lot of sub-features you can use a bullet list like 
this.
+ If the feature adds a lot of sub-features you can use a bullet list like 
this.

-  * Added feature foo to do something.
-  * Enhanced feature bar to do something else.
+ * Added feature foo to do something.
+ * Enhanced feature bar to do something else.

-  Refer to the previous release notes for examples.
+ Refer to the previous release notes for examples.


 Resolved Issues
 ---

-This section should contain bug fixes added to the relevant sections. Sample 
format:
+.. This section should contain bug fixes added to the relevant sections. 
Sample format:

-* **code/section Fixed issue in the past tense with a full stop.**
+   * **code/section Fixed issue in the past tense with a full stop.**

-  Add a short 1-2 sentence description of the resolved issue in the past tense.
-  The title should contain the code/lib section like a commit message.
-  Add the entries in alphabetic order in the relevant sections below.
+ Add a short 1-2 sentence description of the resolved issue in the past 
tense.
+ The title should contain the code/lib section like a commit message.
+ Add the entries in alphabetic order in the relevant sections below.


 EAL
@@ -77,21 +77,21 @@ Other
 Known Issues
 

-This section should contain new known issues in this release. Sample format:
+.. This section should contain new known issues in this release. Sample format:

-* **Add title in present tense with full stop.**
+   * **Add title in present tense with full stop.**

-  Add a short 1-2 sentence description of the known issue in the present
-  tense. Add information on any known workarounds.
+ Add a short 1-2 sentence description of the known issue in the present
+ tense. Add information on any known workarounds.


 API Changes
 ---

-This section should contain API changes. Sample format:
+.. This section should contain API changes. Sample format:

-* Add a short 1-2 sentence description of the API change. Use fixed width
-  quotes for ``rte_function_names`` or ``rte_struct_names``. Use the past 
tense.
+   * Add a short 1-2 sentence description of the API change. Use fixed width
+ quotes for ``rte_function_names`` or ``rte_struct_names``. Use the past 
tense.

 * The following counters are removed from ``rte_eth_stats`` structure:
   ibadcrc, ibadlen, imcasts, fdirmatch, fdirmiss,
@@ -101,9 +101,9 @@ This section should contain API changes. Sample format:
 ABI Changes
 ---

-* Add a short 1-2 sentence description of the ABI change that was announced in
-  the previous releases and made in this release. Use fixed width quotes for
-  ``rte_function_names`` or ``rte_struct_names``. Use the past tense.
+.. * Add a short 1-2 sentence description of the ABI change that was announced 
in
+ the previous releases and made in this release. 

[dpdk-dev] [PATCH 7/7] config: enable virtio-net pmd for ppc64

2016-05-13 Thread Olivier Matz
Now that virtio pmd is supported on ppc, enable it.

Signed-off-by: Olivier Matz 
---
 config/defconfig_ppc_64-power8-linuxapp-gcc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/config/defconfig_ppc_64-power8-linuxapp-gcc 
b/config/defconfig_ppc_64-power8-linuxapp-gcc
index 9eb0cc4..bef8f49 100644
--- a/config/defconfig_ppc_64-power8-linuxapp-gcc
+++ b/config/defconfig_ppc_64-power8-linuxapp-gcc
@@ -50,7 +50,7 @@ CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT=n
 # Will turn on them only after the successful testing on Power
 CONFIG_RTE_LIBRTE_IXGBE_PMD=n
 CONFIG_RTE_LIBRTE_I40E_PMD=n
-CONFIG_RTE_LIBRTE_VIRTIO_PMD=n
+CONFIG_RTE_LIBRTE_VIRTIO_PMD=y
 CONFIG_RTE_LIBRTE_VMXNET3_PMD=n
 CONFIG_RTE_LIBRTE_PMD_BOND=n
 CONFIG_RTE_LIBRTE_ENIC_PMD=n
-- 
2.8.0.rc3



[dpdk-dev] [PATCH 6/7] virtio: fix pci accesses for ppc64 in legacy mode

2016-05-13 Thread Olivier Matz
From: David Marchand 

Although ppc supports both endianesses, qemu supposes that the cpu is
big endian and enforces this for the virtio-net stuff.

Fix PCI accesses in legacy mode. Only ppc64le is supported at the moment.

Signed-off-by: David Marchand 
Signed-off-by: Olivier Matz 
---
 drivers/net/virtio/virtio_pci.c | 44 +
 1 file changed, 44 insertions(+)

diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
index 9cdca06..bdb89fd 100644
--- a/drivers/net/virtio/virtio_pci.c
+++ b/drivers/net/virtio/virtio_pci.c
@@ -55,18 +55,62 @@
  */
 #define VIRTIO_PCI_CONFIG(hw) (((hw)->use_msix) ? 24 : 20)

+/*
+ * Since we are in legacy mode:
+ * http://ozlabs.org/~rusty/virtio-spec/virtio-0.9.5.pdf
+ *
+ * "Note that this is possible because while the virtio header is PCI (i.e.
+ * little) endian, the device-specific region is encoded in the native endian 
of
+ * the guest (where such distinction is applicable)."
+ *
+ * For powerpc which supports both, qemu supposes that cpu is big endian and
+ * enforces this for the virtio-net stuff.
+ */
+
 static void
 legacy_read_dev_config(struct virtio_hw *hw, size_t offset,
   void *dst, int length)
 {
rte_eal_pci_ioport_read(>io, dst, length,
VIRTIO_PCI_CONFIG(hw) + offset);
+#ifdef RTE_ARCH_PPC_64
+   switch (length) {
+   case 4:
+   *(uint32_t *)dst = rte_be_to_cpu_32(*(uint32_t *)dst);
+   break;
+   case 2:
+   *(uint16_t *)dst = rte_be_to_cpu_16(*(uint16_t *)dst);
+   break;
+   default:
+   break;
+   }
+#endif
 }

 static void
 legacy_write_dev_config(struct virtio_hw *hw, size_t offset,
const void *src, int length)
 {
+#ifdef RTE_ARCH_PPC_64
+   union {
+   uint32_t u32;
+   uint16_t u16;
+   } tmp;
+   switch (length) {
+   case 4:
+   tmp.u32 = *(const uint32_t *)src;
+   tmp.u32 = rte_cpu_to_be_32(tmp.u32);
+   src = 
+   break;
+   case 2:
+   tmp.u16 = *(const uint16_t *)src;
+   tmp.u16 = rte_cpu_to_be_16(tmp.u16);
+   src = 
+   break;
+   default:
+   break;
+   }
+#endif
rte_eal_pci_ioport_write(>io, src, length,
 VIRTIO_PCI_CONFIG(hw) + offset);
 }
-- 
2.8.0.rc3



[dpdk-dev] [PATCH 5/7] eal/linux: mmap ioports on ppc64

2016-05-13 Thread Olivier Matz
On PPC64, the ioports are mapped in memory. Implement the missing part
of ioport API for PPC64 when using uio. This may also work on other
architectures but it has not been tested.

Signed-off-by: David Marchand 
Signed-off-by: Olivier Matz 
---
 lib/librte_eal/common/include/rte_pci.h|   4 +-
 lib/librte_eal/linuxapp/eal/eal_pci.c  |   4 +-
 lib/librte_eal/linuxapp/eal/eal_pci_init.h |   6 ++
 lib/librte_eal/linuxapp/eal/eal_pci_uio.c  | 119 +++--
 4 files changed, 107 insertions(+), 26 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_pci.h 
b/lib/librte_eal/common/include/rte_pci.h
index fd049d1..4657396 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -105,7 +105,8 @@ extern struct pci_device_list pci_device_list; /**< Global 
list of PCI devices.
 /** Nb. of values in PCI resource format. */
 #define PCI_RESOURCE_FMT_NVAL 3

-/** IO resource type: memory address space */
+/** IO resource type: */
+#define IORESOURCE_IO 0x0100
 #define IORESOURCE_MEM0x0200

 /**
@@ -518,6 +519,7 @@ int rte_eal_pci_write_config(const struct rte_pci_device 
*device,
 struct rte_pci_ioport {
struct rte_pci_device *dev;
uint64_t base;
+   uint64_t len; /* only filled for memory mapped ports */
 };

 /**
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index 1a93725..f1ea52b 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -191,9 +191,9 @@ pci_find_max_end_va(void)
 }

 /* parse one line of the "resource" sysfs file (note that the 'line'
- * string is modified)
+ * string is modified
  */
-static int
+int
 pci_parse_one_sysfs_resource(char *line, size_t len, uint64_t *phys_addr,
uint64_t *end_addr, uint64_t *flags)
 {
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_init.h 
b/lib/librte_eal/linuxapp/eal/eal_pci_init.h
index 7011753..fbe34c6 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_init.h
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_init.h
@@ -42,6 +42,12 @@
 extern void *pci_map_addr;
 void *pci_find_max_end_va(void);

+/* parse one line of the "resource" sysfs file (note that the 'line'
+ * string is modified)
+ */
+int pci_parse_one_sysfs_resource(char *line, size_t len, uint64_t *phys_addr,
+   uint64_t *end_addr, uint64_t *flags);
+
 int pci_uio_alloc_resource(struct rte_pci_device *dev,
struct mapped_pci_resource **uio_res);
 void pci_uio_free_resource(struct rte_pci_device *dev,
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c 
b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
index ac449c5..077ad96 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -368,11 +369,11 @@ error:
return -1;
 }

+#if defined(RTE_ARCH_X86)
 int
 pci_uio_ioport_map(struct rte_pci_device *dev, int bar,
   struct rte_pci_ioport *p)
 {
-#if defined(RTE_ARCH_X86)
char dirname[PATH_MAX];
char filename[PATH_MAX];
int uio_num;
@@ -411,81 +412,153 @@ pci_uio_ioport_map(struct rte_pci_device *dev, int bar,
RTE_LOG(DEBUG, EAL, "PCI Port IO found start=0x%lx\n", start);

p->base = start;
+   p->len = 0;
return 0;
+}
 #else
-   RTE_SET_USED(dev);
-   RTE_SET_USED(bar);
-   RTE_SET_USED(p);
+int
+pci_uio_ioport_map(struct rte_pci_device *dev, int bar,
+  struct rte_pci_ioport *p)
+{
+   FILE *f;
+   char buf[BUFSIZ];
+   char filename[PATH_MAX];
+   uint64_t phys_addr, end_addr, flags;
+   int fd, i;
+   void *addr;
+
+   /* open and read addresses of the corresponding resource in sysfs */
+   snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT "/resource",
+   SYSFS_PCI_DEVICES, dev->addr.domain, dev->addr.bus,
+dev->addr.devid, dev->addr.function);
+   f = fopen(filename, "r");
+   if (f == NULL) {
+   RTE_LOG(ERR, EAL, "Cannot open sysfs resource: %s\n",
+   strerror(errno));
+   return -1;
+   }
+   for (i = 0; i < bar + 1; i++) {
+   if (fgets(buf, sizeof(buf), f) == NULL) {
+   RTE_LOG(ERR, EAL, "Cannot read sysfs resource\n");
+   goto error;
+   }
+   }
+   if (pci_parse_one_sysfs_resource(buf, sizeof(buf), _addr,
+   _addr, ) < 0)
+   goto error;
+   if ((flags & IORESOURCE_IO) == 0) {
+   RTE_LOG(ERR, EAL, "BAR %d is not an IO resource\n", bar);
+   goto error;
+   }
+   snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT "/resource%d",
+   SYSFS_PCI_DEVICES, dev->addr.domain, dev->addr.bus,
+dev->addr.devid, dev->addr.function, bar);
+
+   /* 

[dpdk-dev] [PATCH 4/7] eal/linux: split function parsing pci resources in sysfs

2016-05-13 Thread Olivier Matz
Split pci_parse_sysfs_resource() and introduce
pci_parse_one_sysfs_resource() that parses one line of sysfs resource
file.

This new function will be exported and used in next commits when
mapping the ioports resources.

No functional change.

Signed-off-by: Olivier Matz 
---
 lib/librte_eal/linuxapp/eal/eal_pci.c | 50 ++-
 1 file changed, 32 insertions(+), 18 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index bdc08a0..1a93725 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -190,12 +190,13 @@ pci_find_max_end_va(void)
return RTE_PTR_ADD(last->addr, last->len);
 }

-/* parse the "resource" sysfs file */
+/* parse one line of the "resource" sysfs file (note that the 'line'
+ * string is modified)
+ */
 static int
-pci_parse_sysfs_resource(const char *filename, struct rte_pci_device *dev)
+pci_parse_one_sysfs_resource(char *line, size_t len, uint64_t *phys_addr,
+   uint64_t *end_addr, uint64_t *flags)
 {
-   FILE *f;
-   char buf[BUFSIZ];
union pci_resource_info {
struct {
char *phys_addr;
@@ -204,6 +205,31 @@ pci_parse_sysfs_resource(const char *filename, struct 
rte_pci_device *dev)
};
char *ptrs[PCI_RESOURCE_FMT_NVAL];
} res_info;
+
+   if (rte_strsplit(line, len, res_info.ptrs, 3, ' ') != 3) {
+   RTE_LOG(ERR, EAL,
+   "%s(): bad resource format\n", __func__);
+   return -1;
+   }
+   errno = 0;
+   *phys_addr = strtoull(res_info.phys_addr, NULL, 16);
+   *end_addr = strtoull(res_info.end_addr, NULL, 16);
+   *flags = strtoull(res_info.flags, NULL, 16);
+   if (errno != 0) {
+   RTE_LOG(ERR, EAL,
+   "%s(): bad resource format\n", __func__);
+   return -1;
+   }
+
+   return 0;
+}
+
+/* parse the "resource" sysfs file */
+static int
+pci_parse_sysfs_resource(const char *filename, struct rte_pci_device *dev)
+{
+   FILE *f;
+   char buf[BUFSIZ];
int i;
uint64_t phys_addr, end_addr, flags;

@@ -220,21 +246,9 @@ pci_parse_sysfs_resource(const char *filename, struct 
rte_pci_device *dev)
"%s(): cannot read resource\n", __func__);
goto error;
}
-
-   if (rte_strsplit(buf, sizeof(buf), res_info.ptrs, 3, ' ') != 3) 
{
-   RTE_LOG(ERR, EAL,
-   "%s(): bad resource format\n", __func__);
+   if (pci_parse_one_sysfs_resource(buf, sizeof(buf), _addr,
+   _addr, ) < 0)
goto error;
-   }
-   errno = 0;
-   phys_addr = strtoull(res_info.phys_addr, NULL, 16);
-   end_addr = strtoull(res_info.end_addr, NULL, 16);
-   flags = strtoull(res_info.flags, NULL, 16);
-   if (errno != 0) {
-   RTE_LOG(ERR, EAL,
-   "%s(): bad resource format\n", __func__);
-   goto error;
-   }

if (flags & IORESOURCE_MEM) {
dev->mem_resource[i].phys_addr = phys_addr;
-- 
2.8.0.rc3



[dpdk-dev] [PATCH 3/7] eal/linux: remove invalid comment

2016-05-13 Thread Olivier Matz
In a previous commit, the file used to map the PCI resources changed
from "/dev/uio" to "/sys/bus/pci/devices//resource", making
the comment wrong. Remove it.

Fixes: 9e67561acd1a ("eal/linux: mmap uio resources using resourceX files")
Signed-off-by: Olivier Matz 
---
 lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c 
b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
index 068694d..ac449c5 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
@@ -309,7 +309,7 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, 
int res_idx,
struct mapped_pci_resource *uio_res, int map_idx)
 {
int fd;
-   char devname[PATH_MAX]; /* contains the /dev/uioX */
+   char devname[PATH_MAX];
void *mapaddr;
struct rte_pci_addr *loc;
struct pci_map *maps;
-- 
2.8.0.rc3



[dpdk-dev] [PATCH 2/7] eal/linux: only call iopl on x86

2016-05-13 Thread Olivier Matz
>From iopl(2) man page: "This call is mostly for the x86 architecture. On
many other architectures it does not exist or will always return an
error".

This patch removes the call to iopl() in rte_eal_iopl_init() for
architectures other than x86, and always return 0 (success). This was
already done for ARM in
commit 0291476ae364 ("eal/linux: never check iopl for arm")

Next patches will introduce the support of memory mapped IO resources
for architectures != x86.

On BSD, there is nothing to do as open("/dev/io") already does the
proper thing. See man IO(4).

Signed-off-by: Olivier Matz 
---
 lib/librte_eal/linuxapp/eal/eal.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
b/lib/librte_eal/linuxapp/eal/eal.c
index 8aafd51..bba8fea 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -715,12 +715,8 @@ rte_eal_iopl_init(void)
 #if defined(RTE_ARCH_X86)
if (iopl(3) != 0)
return -1;
-   return 0;
-#elif defined(RTE_ARCH_ARM) || defined(RTE_ARCH_ARM64)
-   return 0; /* iopl syscall not supported for ARM/ARM64 */
-#else
-   return -1;
 #endif
+   return 0;
 }

 /* Launch threads, called at application init(). */
-- 
2.8.0.rc3



[dpdk-dev] [PATCH 1/7] eal: fix typos in ioport API doxygen comments

2016-05-13 Thread Olivier Matz
Fix some typos and add missing comments related to ioports API in
rte_pci.h.

Fixes: 756ce64b1 ("eal: introduce PCI ioport API")
Signed-off-by: Olivier Matz 
---
 lib/librte_eal/common/include/rte_pci.h | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_pci.h 
b/lib/librte_eal/common/include/rte_pci.h
index 8fa2712..fd049d1 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -521,12 +521,13 @@ struct rte_pci_ioport {
 };

 /**
- * Initialises a rte_pci_ioport object for a pci device io resource.
+ * Initialize a rte_pci_ioport object for a pci device io resource.
+ *
  * This object is then used to gain access to those io resources (see below).
  *
  * @param dev
- *   A pointer to a rte_pci_device structure describing the device.
- *   to use
+ *   A pointer to a rte_pci_device structure describing the device
+ *   to use.
  * @param bar
  *   Index of the io pci resource we want to access.
  * @param p
@@ -542,6 +543,8 @@ int rte_eal_pci_ioport_map(struct rte_pci_device *dev, int 
bar,
  *
  * @param p
  *   The rte_pci_ioport object to be uninitialized.
+ * @return
+ *  0 on success, negative on error.
  */
 int rte_eal_pci_ioport_unmap(struct rte_pci_ioport *p);

-- 
2.8.0.rc3



[dpdk-dev] [PATCH 0/7] virtio-net support on ppc64

2016-05-13 Thread Olivier Matz
This patchset allows virtio-net pmd to run on ppc64 processors.
The main thing that as missing was the support of ioports in EAL.
It also fixes some endianess issues in PCI config accesses in
legacy mode.

This is validated with test-pmd:

=== HOST

mkdir -p /mnt/huge
mount -t hugetlbfs nodev /mnt/huge
echo 128 > 
/sys/devices/system/node/node0/hugepages/hugepages-16384kB/nr_hugepages 
qemu-system-ppc64le --enable-kvm -m 1G -mem-path "/mnt/huge" -cpu host -smp 3 \
  -serial telnet::58028,server,nowait -serial null \
  -device ne2k_pci,mac=de:ad:de:01:02:03,netdev=user.0,addr=03 \
  -netdev user,id=user.0,hostfwd=tcp::49680-:22 \
  -netdev type=tap,id=vhostnet0,script=no,vhost=on,queues=8 \
  -device virtio-net-pci,netdev=vhostnet0,ioeventfd=on,mq=on,vectors=17 \
  -hda /path/to/ubuntu-14.04-ppc64el.qcow2 \
  -vga none -display none
ip l set tap0 up
ip a a 1.1.1.1/24 dev tap0
# start guest, then:
ping 1.1.1.2

=== GUEST

cd dpdk.org/
make config T=ppc_64-power8-linuxapp-gcc
make
mkdir -p /mnt/huge
mount -t hugetlbfs nodev /mnt/huge
echo 64 > 
/sys/devices/system/node/node0/hugepages/hugepages-16384kB/nr_hugepages 
modprobe uio_pci_generic
python tools/dpdk_nic_bind.py -b uio_pci_generic :00:00.0
./build/app/testpmd -l 0,1 --log-level 8 -- --total-num-mbufs=16384 -i 
--port-topology=chained
EAL: Detected 3 lcore(s)
EAL: Probing VFIO support...
EAL: PCI device :00:00.0 on NUMA socket -1
EAL:   probe driver: 1af4:1000 rte_virtio_pmd
Interactive-mode selected
Configuring Port 0 (socket 0)
Port 0: 12:00:54:52:56:34
Checking link statuses...
Port 0 Link Up - speed 1 Mbps - full-duplex
Done
testpmd> set fwd icmpecho
Set icmpecho packet forwarding mode
testpmd> set verbose 1
Change verbose level from 0 to 1
testpmd> start
icmp_echo_config_setup fwd_cores=1 fwd_ports=1 fwd_streams=1
  core=0:
  stream=0 port=0 rxq=0 txq=0
  icmpecho packet forwarding - CRC stripping disabled - packets/burst=32
  nb forwarding cores=1 - nb forwarding ports=1
  RX queues=1 - RX desc=128 - RX free threshold=0
  RX threshold registers: pthresh=0 hthresh=0 wthresh=0
  TX queues=1 - TX desc=512 - TX free threshold=0
  TX threshold registers: pthresh=0 hthresh=0 wthresh=0
  TX RS bit threshold=0 - TXQ flags=0xf00
testpmd>
Port 0 pkt-len=98 nb-segs=1
  ETH:  src=46:A9:44:17:62:F1 dst=12:00:54:52:56:34 type=0x0800
  IPV4: src=1.1.1.1 dst=1.1.1.2 proto=1 (ICMP)
  ICMP: echo request seq id=1

Port 0 pkt-len=98 nb-segs=1
  ETH:  src=46:A9:44:17:62:F1 dst=12:00:54:52:56:34 type=0x0800
  IPV4: src=1.1.1.1 dst=1.1.1.2 proto=1 (ICMP)
  ICMP: echo request seq id=2




David Marchand (1):
  virtio: fix pci accesses for ppc64 in legacy mode

Olivier Matz (6):
  eal: fix typos in ioport API doxygen comments
  eal/linux: only call iopl on x86
  eal/linux: remove invalid comment
  eal/linux: split function parsing pci resources in sysfs
  eal/linux: mmap ioports on ppc64
  config: enable virtio-net pmd for ppc64

 config/defconfig_ppc_64-power8-linuxapp-gcc |   2 +-
 drivers/net/virtio/virtio_pci.c |  44 ++
 lib/librte_eal/common/include/rte_pci.h |  13 ++-
 lib/librte_eal/linuxapp/eal/eal.c   |   6 +-
 lib/librte_eal/linuxapp/eal/eal_pci.c   |  52 +++-
 lib/librte_eal/linuxapp/eal/eal_pci_init.h  |   6 ++
 lib/librte_eal/linuxapp/eal/eal_pci_uio.c   | 121 ++--
 7 files changed, 191 insertions(+), 53 deletions(-)

-- 
2.8.0.rc3



[dpdk-dev] [PATCHv3 1/2] config/armv8a: disable igb_uio

2016-05-13 Thread Thomas Monjalon
2016-05-11 19:17, Hemant Agrawal:
> IGB_UIO not supported for arm64 arch in kernel so disable.

If I understand well, a patch is needed in the kernel to make
igb_uio works? Please confirm.

In that case, yes, the default configuration should be to disable
igb_uio.
Please note it's just a default to make it work in most common cases.
And yes, the default should focus on recent kernels and future directions.

> +CONFIG_RTE_EAL_IGB_UIO=n



[dpdk-dev] [PATCH] arm64: change rte_memcpy to inline function

2016-05-13 Thread Jerin Jacob
On Tue, May 10, 2016 at 02:01:04PM +0530, Jianbo Liu wrote:
> Other APP may call rte_memcpy by function pointer,

Instead of "Other APP" may be better to use DPDK application

> so change it to an inline function.
> 
> Signed-off-by: Jianbo Liu 

Acked-by: Jerin Jacob 

> ---
>  lib/librte_eal/common/include/arch/arm/rte_memcpy_64.h | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_eal/common/include/arch/arm/rte_memcpy_64.h 
> b/lib/librte_eal/common/include/arch/arm/rte_memcpy_64.h
> index 917cdc1..3abe7cd 100644
> --- a/lib/librte_eal/common/include/arch/arm/rte_memcpy_64.h
> +++ b/lib/librte_eal/common/include/arch/arm/rte_memcpy_64.h
> @@ -78,7 +78,11 @@ rte_mov256(uint8_t *dst, const uint8_t *src)
>   memcpy(dst, src, 256);
>  }
>  
> -#define rte_memcpy(d, s, n)  memcpy((d), (s), (n))
> +static inline void *
> +rte_memcpy(void *dst, const void *src, size_t n)
> +{
> + return memcpy(dst, src, n);
> +}
>  
>  static inline void *
>  rte_memcpy_func(void *dst, const void *src, size_t n)
> -- 
> 2.4.11
> 


[dpdk-dev] [PATCH 06/20] thunderx/nicvf: add dev_infos_get support

2016-05-13 Thread Pattan, Reshma


> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Jerin Jacob
> Sent: Saturday, May 7, 2016 4:16 PM
> To: dev at dpdk.org
> Cc: thomas.monjalon at 6wind.com; Richardson, Bruce
> ; Jerin Jacob
> ; Maciej Czekaj
> ; Kamil Rytarowski
> ; Zyta Szpak
> ; Slawomir Rosek ;
> Radoslaw Biernacki 
> Subject: [dpdk-dev] [PATCH 06/20] thunderx/nicvf: add dev_infos_get support
> 
> diff --git a/drivers/net/thunderx/nicvf_ethdev.h
> b/drivers/net/thunderx/nicvf_ethdev.h
> index cc19da5..da6fdcf 100644
> --- a/drivers/net/thunderx/nicvf_ethdev.h
> +++ b/drivers/net/thunderx/nicvf_ethdev.h
> @@ -42,6 +42,23 @@
>  #define NICVF_FULL_DUPLEX0x01
>  #define NICVF_UNKNOWN_DUPLEX 0xff
> 
> +#define NICVF_RSS_OFFLOAD_PASS1 ( \
> + ETH_RSS_PORT | \
> + ETH_RSS_IPV4 | \
> + ETH_RSS_NONFRAG_IPV4_TCP | \
> + ETH_RSS_NONFRAG_IPV4_UDP | \
> + ETH_RSS_IPV6 | \
> + ETH_RSS_NONFRAG_IPV6_TCP | \
> + ETH_RSS_NONFRAG_IPV6_UDP)
> +
> +#define NICVF_RSS_OFFLOAD_TUNNEL ( \
> + ETH_RSS_VXLAN | \
> + ETH_RSS_GENEVE | \
> + ETH_RSS_NVGRE)
> +
> +#define DEFAULT_RX_FREE_THRESH  224
> +#define DEFAULT_TX_FREE_THRESH  224
> +#define DEFAULT_TX_FREE_MPOOL_THRESH16
> 
How about prefixing these 3 macronames with NICVF? Like the previous ones.

Thanks,
Reshma



[dpdk-dev] [PATCH 04/20] thunderx/nicvf: add get_reg and get_reg_length support

2016-05-13 Thread Jerin Jacob
On Thu, May 12, 2016 at 03:39:56PM +, Pattan, Reshma wrote:
> 
> 
> > -Original Message-
> > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Jerin Jacob
> > Sent: Saturday, May 7, 2016 4:16 PM
> > To: dev at dpdk.org
> > Cc: thomas.monjalon at 6wind.com; Richardson, Bruce
> > ; Jerin Jacob
> > ; Maciej Czekaj
> > ; Kamil Rytarowski
> > ; Zyta Szpak
> > ; Slawomir Rosek  > semihalf.com>;
> > Radoslaw Biernacki 
> > Subject: [dpdk-dev] [PATCH 04/20] thunderx/nicvf: add get_reg and
> > get_reg_length support
> > 
> > +
> > +static int
> > +nicvf_dev_get_regs(struct rte_eth_dev *dev, struct rte_dev_reg_info
> > +*regs) {
> > +   uint64_t *data = regs->data;
> > +   struct nicvf *nic = nicvf_pmd_priv(dev);
> > +
> > +   if (data == NULL)
> > +   return -EINVAL;
> 
> nicvf_reg_dump prints to stdout if data in NULL, so do we still want to 
> return here?

Yes as base is code common for other data plane libraries and I think in
DPDK get_regs callback perspective it makes sense to add this check as
PMD driver expected to get the data in the buffer.

Thanks for the review.
I agree with your all other review comments in another thread. Will fix it V2.
> 
> Thanks,
> Reshma
> 
> 
> 


[dpdk-dev] [PATCHv3 1/2] config/armv8a: disable igb_uio

2016-05-13 Thread Jerin Jacob
On Fri, May 13, 2016 at 03:37:01AM +, Hemant Agrawal wrote:
> 
> 
> > -Original Message-
> > From: Jianbo Liu [mailto:jianbo.liu at linaro.org]
> > Sent: Friday, May 13, 2016 7:13 AM
> > To: Santosh Shukla 
> > Cc: Stephen Hemminger ; Jerin Jacob
> > ; Hemant Agrawal
> > ; dev at dpdk.org; Thomas Monjalon
> > 
> > Subject: Re: [dpdk-dev] [PATCHv3 1/2] config/armv8a: disable igb_uio
> > 
> > On 12 May 2016 at 18:31, Santosh Shukla
> >  wrote:
> > > On Thu, May 12, 2016 at 05:52:54PM +0800, Jianbo Liu wrote:
> > >> On 12 May 2016 at 16:57, Santosh Shukla
> > >>  wrote:
> > >> > On Thu, May 12, 2016 at 01:54:13PM +0800, Jianbo Liu wrote:
> > >> >> On 12 May 2016 at 13:06, Santosh Shukla
> > >> >>  wrote:
> > >> >> > On Thu, May 12, 2016 at 11:42:26AM +0800, Jianbo Liu wrote:
> > >> >> >> On 12 May 2016 at 11:17, Santosh Shukla
> > >> >> >>  wrote:
> > >> >> >> > On Thu, May 12, 2016 at 10:01:05AM +0800, Jianbo Liu wrote:
> > >> >> >> >> On 12 May 2016 at 02:25, Stephen Hemminger
> >  wrote:
> > >> >> >> >> > On Wed, 11 May 2016 22:32:16 +0530 Jerin Jacob
> > >> >> >> >> >  wrote:
> > >> >> >> >> >
> > >> >> >> >> >> On Wed, May 11, 2016 at 08:22:59AM -0700, Stephen
> > Hemminger wrote:
> > >> >> >> >> >> > On Wed, 11 May 2016 19:17:58 +0530 Hemant Agrawal
> > >> >> >> >> >> >  wrote:
> > >> >> >> >> >> >
> > >> >> >> >> >> > > IGB_UIO not supported for arm64 arch in kernel so 
> > >> >> >> >> >> > > disable.
> > >> >> >> >> >> > >
> > >> >> >> >> >> > > Signed-off-by: Hemant Agrawal
> > >> >> >> >> >> > > 
> > >> >> >> >> >> > > Reviewed-by: Santosh Shukla
> > >> >> >> >> >> > > 
> > >> >> >> >> >> >
> > >> >> >> >> >> > Really, I have use IGB_UIO on ARM64
> > >> >> >> >> >>
> > >> >> >> >> >> May I know what is the technical use case for igb_uio on
> > >> >> >> >> >> arm64 which cannot be addressed through vfio or vfioionommu.
> > >> >> >> >> >
> > >> >> >> >> > I was running on older kernel which did not support 
> > >> >> >> >> > vfioionommu
> > mode.
> > >> >> >> >>
> > >> >> >> >> As I said, most of DPDK developers are not kernel
> > >> >> >> >> developers. They may have their own kernel tree, and
> > >> >> >> >> couldn't like to upgrade to latest kernel.
> > >> >> >> >> They can choose to use or not use igb_uio when binding the
> > >> >> >> >> driver. But blindly disabling it in the base config seems 
> > >> >> >> >> unreasonable.
> > >> >> >> >
> > >> >> >> > if user keeping his own kernel so they could also keep
> > >> >> >> > IGB_UIO=y in their local
> > >> >> >> Most likely they don't have local dpdk tree. They write their
> > >> >> >> own applications, complie and link to dpdk lib, then done.
> > >> >> >>
> > >> >> >> > dpdk tree. Why are you imposing user-x custome depedancy on
> > >> >> >> > upstream dpdk base
> > >> >> >> Customer requiremnts is important. I want they can choose the way
> > they like.
> > >> >> >>
> > >> >> >
> > >> >> > so you choose to keep igb_uio option, provided arch doesn't support?
> > >> >> > new user did reported issues with igb_uio for arm64, refer this
> > >> >> > thread [1], as well hemanth too faced issues. we want to avoid that.
> > >> >> >
> > >> >> > If customer maintaing out-of-tree kernel then he can also switch to 
> > >> >> > vfio-
> > way.
> > >> >> > isn;t it?
> > >> >> >
> > >> >> >> > config. Is it not enough for explanation that - Base config
> > >> >> >> > ie.. armv8 doesn;t support pci mmap, so igb_uio is n/a. New
> > >> >> >> > user wont able to build/run dpdk/arm64 in igb_uio-way, He'll
> > >> >> >> > prefer to use upstream stuff. I think, you are not making
> > >> >> >> You are wrong, he can build dpdk. If he like to use upstream
> > >> >> >> without patching, he can use vfio.
> > >> >> >
> > >> >> > I disagree, we want to avoid [1] for new user.
> > >> >> >
> > >> >> >> But you can't ignore the need from old user which is more
> > >> >> >> comfortable with older kernel.
> > >> >> >>
> > >> >> > arm/arm64 dpdk support recently added and I am guessing, most
> > >> >> > likely customer using near latest kernel, switching to vfio won't 
> > >> >> > be so
> > difficult.
> > >> >> >
> > >> >> > Or can you take up responsibility of upstreaming pci mmap patch,
> > >> >> > then we don't need this patch.
> > >> >> >
> > >> >> > [1] http://dpdk.org/ml/archives/dev/2016-January/031313.html
> > >> >>
> > >> >> Can you read carefully about the guide at
> > >> >> http://dpdk.org/doc/guides/linux_gsg/build_dpdk.html? It says to
> > >> >> use uio_pci_generic, igb_uio or vfio-pci.
> > >> >
> > >> > *** applicable and works for x86 only, not for arm64: because pci
> > >> > mmap support not present for arm64, in that case we should update the
> > doc.
> > >> >
> > >> >> Could it be possible that the user in that thread has already read
> > >> >> and tried them all and found that he can't enable vifo with his
> > >> >> kernel, and igb_uio is the easy way for him and asked for help from
> > community?
> > >> >> If so, we have no choice but keeping igb_uio 

[dpdk-dev] [PATCH] doc: known issue on EAL argv

2016-05-13 Thread Jingjing Wu
This patch docs the issue on EAL argument that the last EAL
argument is replaced by program name in argv[].

Reported-by: Ziye Yang 
Signed-off-by: Jingjing Wu 
---
 doc/guides/rel_notes/known_issues.rst | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/doc/guides/rel_notes/known_issues.rst 
b/doc/guides/rel_notes/known_issues.rst
index 923a202..9f03733 100644
--- a/doc/guides/rel_notes/known_issues.rst
+++ b/doc/guides/rel_notes/known_issues.rst
@@ -618,3 +618,22 @@ DPDK may not build on some Intel CPUs using clang < 3.7.0

 **Driver/Module**:
Environment Abstraction Layer (EAL).
+
+
+The last EAL argument is replaced by program name in argv[]
+---
+
+**Description**:
+   The last EAL argument will be replaced by program name in argv[] after 
eal_parse_args, and it causes the pointer to the last EAL argument lost.
+
+**Implication**:
+  If the last EAL argument in argv is generated by malloc function, changing 
it will cause memory issues when free the argument.
+
+**Resolution/Workaround**:
+   Application should not consider the value in argv[] as unchanged.
+
+**Affected Environment/Platform**:
+   ALL.
+
+**Driver/Module**:
+   Environment Abstraction Layer (EAL).
-- 
2.4.0



[dpdk-dev] [PATCH] eal/linuxapp: fix resource leak

2016-05-13 Thread Thomas Monjalon
2016-05-12 08:55, Sergio Gonzalez Monroy:
> On 11/05/2016 17:01, Daniel Mrzyglod wrote:
> > Fix issue reported by Coverity.
> > Coverity ID 97920
> >
> > munmap structure of hugepage
> >
> > leaked_storage: Variable hugepage going out of scope leaks the storage
> > it points to.
> >
> > The system resource will not be reclaimed and reused, reducing the future
> > availability of the resource.
> 
> I'm not really fond of this commit messages, but if no one minds them, 
> so be it.

Me too. It looks like a Machine2Machine message.
I'd prefer an explanation of what is wrong first, then an explanation of
the fix, and at the end, the Coverity ID (can be a tag like
Fixes-Coverity-ID: 97920).

> > In rte_eal_hugepage_init: Leak of memory or pointers to system resources
> >
> > Fixes: b6a468ad41d5 ("memory: add --socket-mem option")
> >
> > Signed-off-by: Daniel Mrzyglod 



[dpdk-dev] [PATCH] sched: fix useless call

2016-05-13 Thread Thomas Monjalon
2016-05-11 10:46, Ferruh Yigit:
> On 5/10/2016 6:18 PM, Dumitrescu, Cristian wrote:
> > As previously discussed on this email list, the rte_bitmap_free() is an API 
> > function that works as a placeholder for any resource freeing that needs to 
> > be done for the bitmap. The API function should not be removed and also the 
> > call to this function from the rte_sched_port_free() should not be removed 
> > either.
> > 
> 
> Right now it isn't required and doesn't do anything.
> Why not add this function when it is required?

I don't understand why we keep a function which does nothing.


[dpdk-dev] [PATCH v1 09/28] eal: introduce --no-soc option

2016-05-13 Thread Jianbo Liu
On 6 May 2016 at 21:47, Jan Viktorin  wrote:
> This option has the same meaning for the SoC infra as the --no-pci
> for the PCI infra.
>
> Signed-off-by: Jan Viktorin 
> ---
>  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 ++
>  3 files changed, 8 insertions(+)
>
> diff --git a/lib/librte_eal/common/eal_common_options.c 
> b/lib/librte_eal/common/eal_common_options.c
> index 3efc90f..09d64f7 100644
> --- a/lib/librte_eal/common/eal_common_options.c
> +++ b/lib/librte_eal/common/eal_common_options.c
> @@ -85,6 +85,7 @@ eal_long_options[] = {
> {OPT_NO_HPET,   0, NULL, OPT_NO_HPET_NUM  },
> {OPT_NO_HUGE,   0, NULL, OPT_NO_HUGE_NUM  },
> {OPT_NO_PCI,0, NULL, OPT_NO_PCI_NUM   },
> +   {OPT_NO_SOC,0, NULL, OPT_NO_SOC_NUM   },
> {OPT_NO_SHCONF, 0, NULL, OPT_NO_SHCONF_NUM},
> {OPT_PCI_BLACKLIST, 1, NULL, OPT_PCI_BLACKLIST_NUM},
> {OPT_PCI_WHITELIST, 1, NULL, OPT_PCI_WHITELIST_NUM},
> @@ -841,6 +842,10 @@ eal_parse_common_option(int opt, const char *optarg,
> conf->no_pci = 1;
> break;
>
> +   case OPT_NO_SOC_NUM:
> +   conf->no_soc = 1;

Could it be better to rename to enable_soc, and disable soc by default?

> +   break;
> +
> case OPT_NO_HPET_NUM:
> conf->no_hpet = 1;
> break;
> diff --git a/lib/librte_eal/common/eal_internal_cfg.h 
> b/lib/librte_eal/common/eal_internal_cfg.h
> index 5f1367e..3a98e94 100644
> --- a/lib/librte_eal/common/eal_internal_cfg.h
> +++ b/lib/librte_eal/common/eal_internal_cfg.h
> @@ -67,6 +67,7 @@ struct internal_config {
> unsigned hugepage_unlink; /**< true to unlink backing files */
> volatile unsigned xen_dom0_support; /**< support app running on Xen 
> Dom0*/
> volatile unsigned no_pci; /**< true to disable PCI */
> +   volatile unsigned no_soc; /**< true to disable SoC */
> volatile unsigned no_hpet;/**< true to disable HPET */
> volatile unsigned vmware_tsc_map; /**< true to use VMware TSC mapping
>   
>   * instead of native TSC */
> diff --git a/lib/librte_eal/common/eal_options.h 
> b/lib/librte_eal/common/eal_options.h
> index a881c62..ba1e704 100644
> --- a/lib/librte_eal/common/eal_options.h
> +++ b/lib/librte_eal/common/eal_options.h
> @@ -69,6 +69,8 @@ enum {
> OPT_NO_HUGE_NUM,
>  #define OPT_NO_PCI"no-pci"
> OPT_NO_PCI_NUM,
> +#define OPT_NO_SOC"no-soc"
> +   OPT_NO_SOC_NUM,
>  #define OPT_NO_SHCONF "no-shconf"
> OPT_NO_SHCONF_NUM,
>  #define OPT_SOCKET_MEM"socket-mem"
> --
> 2.8.0
>


[dpdk-dev] [PATCH] sched: fix useless call

2016-05-13 Thread Dumitrescu, Cristian


> -Original Message-
> From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> Sent: Friday, May 13, 2016 11:12 AM
> To: Dumitrescu, Cristian 
> Cc: dev at dpdk.org; Yigit, Ferruh ; Mrzyglod, 
> DanielX
> T 
> Subject: Re: [dpdk-dev] [PATCH] sched: fix useless call
> 
> 2016-05-11 10:46, Ferruh Yigit:
> > On 5/10/2016 6:18 PM, Dumitrescu, Cristian wrote:
> > > As previously discussed on this email list, the rte_bitmap_free() is an 
> > > API
> function that works as a placeholder for any resource freeing that needs to
> be done for the bitmap. The API function should not be removed and also
> the call to this function from the rte_sched_port_free() should not be
> removed either.
> > >
> >
> > Right now it isn't required and doesn't do anything.
> > Why not add this function when it is required?
> 
> I don't understand why we keep a function which does nothing.

Every data type/class/object should have a constructor/create and 
destructor/free function. This is standard programming practice, right?

This API function is the free function for the bitmap object. Right now there 
are no internally allocated resources to be freed, but as code evolves, some 
other internal memory could be allocated by the bitmap, which needs to be freed 
in the bitmap free function.

This function should be kept in order to have a stable API. We should not go 
back and forth with adding / removing API functions as code evolves. It does 
not make any sense to go through the ABI change process to remove this API 
function now just to come back later on and go again through ABI change to add 
back this API function later.

I think each DPDK object should have its create and free functions clearly 
identified in the API.



[dpdk-dev] [PATCH] tools:new tool for system info CPU, memory and huge pages

2016-05-13 Thread Keith Wiles
The new tool uses /sys/devices instead of /proc directory, which
does not exist on all systems. If the procfs is not available
then memory and huge page information is skipped.

The tool also can emit a json format in short or long form to
allow for machine readable information.

Here is the usage information:

Usage: sys_info.py [options]

Show the lcores layout with core id and socket(s).

Options:
--help or -h:
Display the usage information and quit

--long or -l:
Display the information in a machine readable long format.

--short or -s:
Display the information in a machine readable short format.

--pci or -p:
Display all of the Ethernet devices in the system using 'lspci'.

--version or -v:
Display the current version number of this script.

--debug or -d:
Output some debug information.

default:
Display the information in a human readable format.

Signed-off-by: Keith Wiles 
---
 tools/sys_info.py | 551 ++
 1 file changed, 551 insertions(+)
 create mode 100755 tools/sys_info.py

diff --git a/tools/sys_info.py b/tools/sys_info.py
new file mode 100755
index 000..5e09d12
--- /dev/null
+++ b/tools/sys_info.py
@@ -0,0 +1,551 @@
+#! /usr/bin/python
+#
+#   BSD LICENSE
+#
+#   Copyright(c) 2016 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution.
+# * Neither the name of Intel Corporation nor the names of its
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+import os, sys
+import getopt
+import json
+from os.path import exists, abspath, dirname, basename
+
+version = "0.1.3"
+
+# Global lists and flags
+machine_readable = 0
+show_pci = False
+debug_flag = False
+coremaps_flag = False
+
+sys_info = {}
+coremaps = {}
+
+def proc_cpuinfo_path():
+'''Return the cpu information from /proc'''
+return "/proc/cpuinfo"
+
+def proc_sysinfo_path():
+'''Return the system path string from /proc'''
+return "/proc/sysinfo"
+
+def proc_meminfo_path():
+'''Return the memory information path from /proc'''
+return "/proc/meminfo"
+
+def sys_system_path():
+'''Return the system path string from /sys'''
+return "/sys/devices/system"
+
+def read_file(path, whole_file=False):
+'''Read the first line of a file'''
+
+if os.access(path, os.F_OK) == False:
+print "Path (%s) Not found" % path
+return ""
+
+fd = open(path)
+if whole_file == True:
+lines = fd.readlines()
+else:
+line = fd.readline()
+fd.close()
+
+if whole_file == True:
+return lines
+
+return line
+
+def get_range(line):
+'''Split a line and convert to low/high values'''
+
+line = line.strip()
+
+if '-' in line:
+low, high = line.split("-")
+elif ',' in line:
+low, high = line.split(",")
+else:
+return [int(line)]
+
+return [int(low), int(high)]
+
+def get_ranges(line):
+'''Split a set of ranges into first low/high, second low/high value'''
+
+line = line.strip()
+
+first, second = line.split(',')
+
+f = get_range(first)
+s = get_range(second)
+
+return [f, s]
+
+def get_low(line):
+'''Return the low value in a range'''
+range = get_range(line)
+return int(range[0])
+
+def get_high(line):
+'''Return the high value in a range'''
+range = get_range(line)
+
+if len(range) > 1:
+return range[1]
+
+return range[0]
+
+def get_value(line):
+'''Convert a number into a integer 

[dpdk-dev] [PATCH v4] examples/qos_meter: fix unchecked return value

2016-05-13 Thread Slawomir Mrozowicz
Fix issue reported by Coverity.

Coverity ID 30693: Unchecked return value
check_return: Calling rte_meter_srtcm_config without checking return value.

Fixes: e6541fdec8b2 ("meter: initial import")

Signed-off-by: Slawomir Mrozowicz 
---
 examples/qos_meter/main.c | 16 
 examples/qos_meter/main.h |  2 +-
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/examples/qos_meter/main.c b/examples/qos_meter/main.c
index b968b00..1565615 100644
--- a/examples/qos_meter/main.c
+++ b/examples/qos_meter/main.c
@@ -133,14 +133,20 @@ struct rte_meter_trtcm_params app_trtcm_params[] = {

 FLOW_METER app_flows[APP_FLOWS_MAX];

-static void
+static int
 app_configure_flow_table(void)
 {
uint32_t i, j;
+   int ret;

-   for (i = 0, j = 0; i < APP_FLOWS_MAX; i ++, j = (j + 1) % 
RTE_DIM(PARAMS)){
-   FUNC_CONFIG(_flows[i], [j]);
+   for (i = 0, j = 0; i < APP_FLOWS_MAX;
+   i ++, j = (j + 1) % RTE_DIM(PARAMS)) {
+   ret = FUNC_CONFIG(_flows[i], [j]);
+   if (ret)
+   return ret;
}
+
+   return 0;
 }

 static inline void
@@ -381,7 +387,9 @@ main(int argc, char **argv)
rte_eth_promiscuous_enable(port_tx);

/* App configuration */
-   app_configure_flow_table();
+   ret = app_configure_flow_table();
+   if (ret < 0)
+   rte_exit(EXIT_FAILURE, "Invalid configure flow table\n");

/* Launch per-lcore init on every lcore */
rte_eal_mp_remote_launch(main_loop, NULL, CALL_MASTER);
diff --git a/examples/qos_meter/main.h b/examples/qos_meter/main.h
index 530bf69..54867dc 100644
--- a/examples/qos_meter/main.h
+++ b/examples/qos_meter/main.h
@@ -51,7 +51,7 @@ enum policer_action 
policer_table[e_RTE_METER_COLORS][e_RTE_METER_COLORS] =
 #if APP_MODE == APP_MODE_FWD

 #define FUNC_METER(a,b,c,d) color, flow_id=flow_id, pkt_len=pkt_len, time=time
-#define FUNC_CONFIG(a,b)
+#define FUNC_CONFIG(a, b) 0
 #define PARAMS app_srtcm_params
 #define FLOW_METER int

-- 
1.9.1



[dpdk-dev] virtio pmd failed in pci probing

2016-05-13 Thread Vincent Li
sorry for the noise, it turned out I need to add the virtio pmd in the
mTCP app Makefile as below

LIBS += -m64 -g -O3 -pthread -lrt -march=native -Wl,-export-dynamic
${MTCP_FLD}/lib/libmtcp.a -L../../dpdk/lib -Wl,-lnuma -Wl,-lmtcp
-Wl,-lpthread -Wl,-lrt -Wl,-ldl -Wl,--whole-archive
-Wl,-lrte_distributor -Wl,-lrte_kni -Wl,-lrte_pipeline -Wl,-lrte_table
-Wl,-lrte_port -Wl,-lrte_timer -Wl,-lrte_hash -Wl,-lrte_lpm
-Wl,-lrte_power -Wl,-lrte_acl -Wl,-lrte_meter -Wl,-lrte_sched -Wl,-lm
-Wl,-lrt -Wl,--start-group -Wl,-lrte_kvargs -Wl,-lrte_mbuf
-Wl,-lrte_ip_frag -Wl,-lethdev -Wl,-lrte_mempool -Wl,-lrte_ring
-Wl,-lrte_eal -Wl,-lrte_cmdline -Wl,-lrte_cfgfile -Wl,-lrte_pmd_bond
-Wl,-lrte_pmd_vmxnet3_uio -Wl,-lrte_pmd_i40e -Wl,-lrte_pmd_ixgbe
-Wl,-lrte_pmd_e1000 -Wl,-lrte_pmd_virtio -Wl,-lrte_pmd_ring -Wl,-lrt
-Wl,-lm -Wl,-ldl -Wl,--end-group -Wl,--no-whole-archive

On Thu, May 12, 2016 at 1:10 PM, Vincent Li  wrote:
> I add a debug log line in dpdk-16.04/lib/librte_ether/rte_ethdev.c
> rte_eth_driver_register
>
> void
> rte_eth_driver_register(struct eth_driver *eth_drv)
> {
> eth_drv->pci_drv.devinit = rte_eth_dev_init;
> eth_drv->pci_drv.devuninit = rte_eth_dev_uninit;
> rte_eal_pci_register(_drv->pci_drv);
> RTE_LOG(DEBUG, EAL, "  register pmd driver %s\n",
> eth_drv->pci_drv.name);
> }
>
> then run the mTCP app, rte_virtio_pmd is missing:
>
> EAL: WARNING: cpu flags constant_tsc=yes nonstop_tsc=no -> using
> unreliable clock cycles !
> EAL: Master lcore 0 is ready (tid=6ec31900;cpuset=[0])
> EAL:   register pmd driver rte_vmxnet3_pmd
> EAL:   register pmd driver rte_i40e_pmd
> EAL:   register pmd driver rte_i40evf_pmd
> EAL:   register pmd driver rte_ixgbe_pmd
> EAL:   register pmd driver rte_ixgbevf_pmd
> EAL:   register pmd driver rte_igb_pmd
> EAL:   register pmd driver rte_igbvf_pmd
> EAL:   register pmd driver rte_em_pmd
> EAL:   dev->id.vendor_id:dev->id.device_id dr->name 1af4:1000 rte_vmxnet3_pmd
> EAL:   dev->id.vendor_id:dev->id.device_id dr->name 1af4:1000 rte_i40e_pmd
> EAL:   dev->id.vendor_id:dev->id.device_id dr->name 1af4:1000 rte_i40evf_pmd
> EAL:   dev->id.vendor_id:dev->id.device_id dr->name 1af4:1000 rte_ixgbe_pmd
> EAL:   dev->id.vendor_id:dev->id.device_id dr->name 1af4:1000 rte_ixgbevf_pmd
> EAL:   dev->id.vendor_id:dev->id.device_id dr->name 1af4:1000 rte_igb_pmd
> EAL:   dev->id.vendor_id:dev->id.device_id dr->name 1af4:1000 rte_igbvf_pmd
> EAL:   dev->id.vendor_id:dev->id.device_id dr->name 1af4:1000 rte_em_pmd
> pci_probe_all_drivers ret: 1 devargs not NULL and whitelisted
> EAL: Error - exiting with code: 1
>   Cause: No Ethernet port!
>
> any clue?
>
>
> On Thu, May 12, 2016 at 9:34 AM, Vincent Li  
> wrote:
>> Hi
>>
>> I am testing mTCP https://github.com/eunyoung14/mtcp  with dpdk-16.04
>> on KVM guest and it appears the virtio pmd fail to load, detail info
>> below:
>>
>>
>> # ./tools/dpdk_nic_bind.py --status
>>
>> Network devices using DPDK-compatible driver
>> 
>> :00:07.0 'Virtio network device' drv=igb_uio unused=
>>
>> Network devices using kernel driver
>> ===
>> :00:03.0 'Virtio network device' if= drv=virtio-pci unused=igb_uio
>> :00:08.0 'Virtio network device' if= drv=virtio-pci unused=igb_uio
>>
>> in mtcp/src/io_module.c, I have (I hard code the whiltelist to make it
>> easy to test for me):
>>
>>
>>
>>sprintf(whitelist, "%s", ":00:07.0");
>>/* initialize the rte env first, what a waste of
>> implementation effort!  */
>> char *argv[] = {"",
>> "-c",
>> cpumaskbuf,
>> "-w",
>> whitelist,
>> "-n",
>> mem_channels,
>> "--proc-type=auto",
>> ""
>> };
>> const int argc = 8;
>>
>> /*
>>  * re-set getopt extern variable optind.
>>  * this issue was a bitch to debug
>>  * rte_eal_init() internally uses getopt() syscall
>>  * mtcp applications that also use an `external' getopt
>>  * will cause a violent crash if optind is not reset to zero
>>  * prior to calling the func below...
>>  * see man getopt(3) for more details
>>  */
>> optind = 0;
>>
>> /* initialize the dpdk eal env */
>> ret = rte_eal_init(argc, argv);
>> if (ret < 0)
>> rte_exit(EXIT_FAILURE, "Invalid EAL args!\n");
>> /* give me the count of 'detected' ethernet ports */
>> num_devices = rte_eth_dev_count();
>> if (num_devices == 0) {
>> rte_exit(EXIT_FAILURE, 

[dpdk-dev] [PATCH] qat: change optimization flag for Intel QuickAssist Technology

2016-05-13 Thread Thomas Monjalon
2016-05-10 10:24, Arek Kusztal:
> From: Arkadiusz Kusztal 
> 
> Changed to -O3 optimization flag in Intel QuickAssist Technology Makefile

There is another change below. Should it be a separate patch?

> --- a/drivers/crypto/qat/qat_adf/qat_algs_build_desc.c
> +++ b/drivers/crypto/qat/qat_adf/qat_algs_build_desc.c
> @@ -616,10 +616,12 @@ int 
> qat_alg_aead_session_create_content_desc_auth(struct qat_session *cdesc,
>* Write (the length of AAD) into bytes 16-19 of state2
>* in big-endian format. This field is 8 bytes
>*/
> - *(uint32_t *)&(hash->sha.state1[
> + uint32_t *aad_len = (uint32_t *)>sha.state1[
>   ICP_QAT_HW_GALOIS_128_STATE1_SZ +
> - ICP_QAT_HW_GALOIS_H_SZ]) =
> - rte_bswap32(add_auth_data_length);
> + ICP_QAT_HW_GALOIS_H_SZ];
> +
> + *aad_len = rte_bswap32(add_auth_data_length);
> +
>   proto = ICP_QAT_FW_LA_GCM_PROTO;
>   } else if (cdesc->qat_hash_alg == ICP_QAT_HW_AUTH_ALGO_SNOW_3G_UIA2)  {
>   proto = ICP_QAT_FW_LA_SNOW_3G_PROTO;
> 




[dpdk-dev] [PATCH v4 6/8] virtio-user: add new virtual pci driver for virtio

2016-05-13 Thread Tan, Jianfeng

Hi Michael,

On 5/13/2016 1:02 AM, Michael S. Tsirkin wrote:
> On Thu, May 12, 2016 at 03:08:05PM +0800, Tan, Jianfeng wrote:
>> (2) It's more aligned to previous logic to hide the detail to differentiate
>> modern/legacy device.
> Why is there a need to support legacy interfaces at all?  It's a container
> so if it's in use one can be reasonably sure you have a new kernel.
>

No, there's no need. The added device, virtio-user, is parallel to 
legacy and modern device. But there's a feature bit inside vhost user 
protocol for vhost user to decide the length of header, current 
implementation by default set this feature bit.

Thanks,
Jianfeng


[dpdk-dev] [PATCH v4 6/8] virtio-user: add new virtual pci driver for virtio

2016-05-13 Thread Tan, Jianfeng


On 5/13/2016 12:40 AM, Yuanhan Liu wrote:
> On Thu, May 12, 2016 at 03:08:05PM +0800, Tan, Jianfeng wrote:
 +static int
 +vdev_setup_queue(struct virtio_hw *hw __rte_unused, struct virtqueue *vq)
 +{
 +  /* Changed to use virtual addr */
 +  vq->vq_ring_mem = (phys_addr_t)vq->mz->addr;
 +  if (vq->virtio_net_hdr_mz) {
 +  vq->virtio_net_hdr_mem =
 +  (phys_addr_t)vq->virtio_net_hdr_mz->addr;
 +  /* Do it one more time after we reset virtio_net_hdr_mem */
 +  vring_hdr_desc_init(vq);
 +  }
 +  vq->offset = offsetof(struct rte_mbuf, buf_addr);
 +  return 0;
>>> Here as last email said, you should not mix vq stuff. What's more,
>>> why do you invoke vring_hdr_desc_init() here?
>> vring_hdr_desc_init() is to init header desc according to
>> vq->virtio_net_hdr_mem, and here we change to use virtual address, so we
>> need to invoke this after vq->virtio_net_hdr_mem is decided.
>>
>> But for this case, you remind me that we can achieve that by: inside
>> virtio_dev_queue_setup(), move vring_hdr_desc_init() after setup_queue().
>>
>>> If it needs a special
>>> handling, do it in driver.
>> As discussed in previous mail with David, we should hide special handling
>> inside pci ops,
> Generally speaking, yes.
>
>> such as real virtio device needs to check address (patch 1).
> And that's a good one: I've already acked. But here, I doubt it introduces
> any benefits to do that. Firstly, it's a Tx queue specific setting, moving
> it to common code path means you have to add a check like the way you did
> in this patch.

I agree about this point. But is it really big deal? Please go on with 
remaining comments before make decision.

> BTW, it's an implicit check, which hurts readability a bit.

At the point of readability, I think driver does not need to care about 
devices use physical addresses or virtual addresses, and this is why we 
do that inside pci ops to hide those details.

Another side, pci ops is introduced to cover the details of talking to a 
device as I understand, do you think it offends such semantics? (this 
one could be your argument :-))

>
> Secondly, you have to do this kind of check/settings in 3 different places:
>
> - legacy queue_setup() method
> - modern queue_setup() method
> - your vdev queue_setup() method

Each kind of device does such check/settings on its own requirement. So 
only indispensable check/settings are added into these three different 
devices.

>
> And another remind is that Huawei planned to split Rx/Tx queue settings,
> here you mixed them again, and I don't think Huawei would like it. Don't
> even to say that after the split, the Tx specific stuff will be no longer
> in the common vq structure.

Yes, this is a blocker issue of my current implementation. Let's see you 
suggestion firstly.

>
> So, I'd suggest something like following:
>
>   if (is_vdev(..)) {

The blocker issue of your suggestion is that we have no such condition.

Previously, I use dev_type, but as David's comment said:

"The reason of those comments is that dev_type in ethdev is going to
disappear, see [1] and [2].
Drivers are called through their own specific ethdev/crypto ops and
so, those drivers know implicitely that their are either pci or vdev
(or whatever in the future) drivers."

Another consideration is comparing vtpci_ops pointer, I don't think it's 
elegant.

>   /* comment here that we use VA for vdev */
>   vq->vq_ring_mem = (phys_addr_t)vq->mz->addr;
>   vq->virtio_net_hdr_mem = ...;
>   vq->offset = ...;
>   } else {
>   vq->vq_ring_mem = ...;
>   ...
>   }
>   vring_hdr_desc_init(vq);
>
>> See below comments for more detail.
>>
>>> The "setup_queue" method is actually for telling the device where desc,
>>> avail and used vring are located. Hence, the implementation could be simple:
>>> just log them.
 +
 +const struct virtio_pci_ops vdev_ops = {
>>> Note that this is the interface for the driver to talk to the device,
>>> we should put this file into upper layer then, in the driver.
>>>
>>> And let me make a summary, trying to make it clear:
>>>
>>> - We should not use any structures/functions from the virtio driver
>>>here, unless it's really a must.
>> Firstly I agree this point (although I see a difference in how we take "a
>> must"). My original principle is to maximize the use of existing structures
>> instead of maintain any new ones.
> If that could save you a lot of efforts and make the design clean, I
> might would say, yes, go for it. But it's obviously NO in this case.
>
>> And I already give up that principle when
>> I accept your previous suggestion to use struct virtio_user_device to store
>> virtio-user specific fields. So I agree to add the new struct virtqueue to
>> avoid use of driver-layer virtqueues.
>>
>>> - It's allowed for driver to make *few* special 

[dpdk-dev] [PATCHv3 1/2] config/armv8a: disable igb_uio

2016-05-13 Thread Jianbo Liu
On 12 May 2016 at 18:31, Santosh Shukla
 wrote:
> On Thu, May 12, 2016 at 05:52:54PM +0800, Jianbo Liu wrote:
>> On 12 May 2016 at 16:57, Santosh Shukla
>>  wrote:
>> > On Thu, May 12, 2016 at 01:54:13PM +0800, Jianbo Liu wrote:
>> >> On 12 May 2016 at 13:06, Santosh Shukla
>> >>  wrote:
>> >> > On Thu, May 12, 2016 at 11:42:26AM +0800, Jianbo Liu wrote:
>> >> >> On 12 May 2016 at 11:17, Santosh Shukla
>> >> >>  wrote:
>> >> >> > On Thu, May 12, 2016 at 10:01:05AM +0800, Jianbo Liu wrote:
>> >> >> >> On 12 May 2016 at 02:25, Stephen Hemminger > >> >> >> networkplumber.org> wrote:
>> >> >> >> > On Wed, 11 May 2016 22:32:16 +0530
>> >> >> >> > Jerin Jacob  wrote:
>> >> >> >> >
>> >> >> >> >> On Wed, May 11, 2016 at 08:22:59AM -0700, Stephen Hemminger 
>> >> >> >> >> wrote:
>> >> >> >> >> > On Wed, 11 May 2016 19:17:58 +0530
>> >> >> >> >> > Hemant Agrawal  wrote:
>> >> >> >> >> >
>> >> >> >> >> > > IGB_UIO not supported for arm64 arch in kernel so disable.
>> >> >> >> >> > >
>> >> >> >> >> > > Signed-off-by: Hemant Agrawal 
>> >> >> >> >> > > Reviewed-by: Santosh Shukla > >> >> >> >> > > caviumnetworks.com>
>> >> >> >> >> >
>> >> >> >> >> > Really, I have use IGB_UIO on ARM64
>> >> >> >> >>
>> >> >> >> >> May I know what is the technical use case for igb_uio on arm64
>> >> >> >> >> which cannot be addressed through vfio or vfioionommu.
>> >> >> >> >
>> >> >> >> > I was running on older kernel which did not support vfioionommu 
>> >> >> >> > mode.
>> >> >> >>
>> >> >> >> As I said, most of DPDK developers are not kernel developers. They 
>> >> >> >> may
>> >> >> >> have their own kernel tree, and couldn't like to upgrade to latest
>> >> >> >> kernel.
>> >> >> >> They can choose to use or not use igb_uio when binding the driver. 
>> >> >> >> But
>> >> >> >> blindly disabling it in the base config seems unreasonable.
>> >> >> >
>> >> >> > if user keeping his own kernel so they could also keep IGB_UIO=y in 
>> >> >> > their local
>> >> >> Most likely they don't have local dpdk tree. They write their own
>> >> >> applications, complie and link to dpdk lib, then done.
>> >> >>
>> >> >> > dpdk tree. Why are you imposing user-x custome depedancy on upstream 
>> >> >> > dpdk base
>> >> >> Customer requiremnts is important. I want they can choose the way they 
>> >> >> like.
>> >> >>
>> >> >
>> >> > so you choose to keep igb_uio option, provided arch doesn't support?
>> >> > new user did reported issues with igb_uio for arm64, refer this thread 
>> >> > [1], as
>> >> > well hemanth too faced issues. we want to avoid that.
>> >> >
>> >> > If customer maintaing out-of-tree kernel then he can also switch to 
>> >> > vfio-way.
>> >> > isn;t it?
>> >> >
>> >> >> > config. Is it not enough for explanation that - Base config ie.. 
>> >> >> > armv8 doesn;t
>> >> >> > support pci mmap, so igb_uio is n/a. New user wont able to build/run 
>> >> >> > dpdk/arm64
>> >> >> > in igb_uio-way, He'll prefer to use upstream stuff. I think, you are 
>> >> >> > not making
>> >> >> You are wrong, he can build dpdk. If he like to use upstream without
>> >> >> patching, he can use vfio.
>> >> >
>> >> > I disagree, we want to avoid [1] for new user.
>> >> >
>> >> >> But you can't ignore the need from old user which is more comfortable
>> >> >> with older kernel.
>> >> >>
>> >> > arm/arm64 dpdk support recently added and I am guessing, most likely 
>> >> > customer
>> >> > using near latest kernel, switching to vfio won't be so difficult.
>> >> >
>> >> > Or can you take up responsibility of upstreaming pci mmap patch, then 
>> >> > we don't
>> >> > need this patch.
>> >> >
>> >> > [1] http://dpdk.org/ml/archives/dev/2016-January/031313.html
>> >>
>> >> Can you read carefully about the guide at
>> >> http://dpdk.org/doc/guides/linux_gsg/build_dpdk.html? It says to use
>> >> uio_pci_generic, igb_uio or vfio-pci.
>> >
>> > *** applicable and works for x86 only, not for arm64: because pci mmap 
>> > support
>> > not present for arm64, in that case we should update the doc.
>> >
>> >> Could it be possible that the user in that thread has already read and
>> >> tried them all and found that he can't enable vifo with his kernel,
>> >> and igb_uio is the easy way for him and asked for help from community?
>> >> If so, we have no choice but keeping igb_uio enabled.
>> >
>> > By then vfionoiommu support was wip progress in dpdk/linux. but now it 
>> > merged
>> > and it works. So no need to retain igb_uio in base config for which to 
>> > work -
>> > user need to use mmap patch at linux side.
>>
>> We can't decide which kernel user will use.
>>
>
> yes, we can't decide kernel for user but we should be explicit to user on - 
> what
> works for dpdk/linux out-of-box vs what could work with use of out-of-tree
> patch/RFC's.. example igb_uio.
>

OK, please persuade Stephen Hemminger and the other guy to use
upstream kernel first!

>> >
>> > Or can you maintain out-of-tree pci mmap patch/ kerne source and make it
>> > explicit somewhere in dpdk build doc 

[dpdk-dev] [dpdk-dev, 2/3] eth_dev: add support for device dma mask

2016-05-13 Thread Alejandro Lucero
On Thu, May 12, 2016 at 4:41 PM, Jan Viktorin 
wrote:

> Hi,
>
> Just a note, please, when replying inline, do not prepend ">" before your
> new text. I could not find your replies.
>
>
My gmail interface does not show that prepend character... It seems I have
to leave a white line before my replies.



> See below...
>
> On Thu, 12 May 2016 16:03:14 +0100
> Alejandro Lucero  wrote:
>
> > Hi Jan
> >
> > On Thu, May 12, 2016 at 3:52 PM, Jan Viktorin 
> > wrote:
> >
> > > Hello Alejandro,
> > >
> > > On Thu, 12 May 2016 15:33:59 +0100
> > > "Alejandro.Lucero"  wrote:
> > >
> > > > - New dma_mask field in rte_eth_dev_data.
> > > >  - If PMD sets device dma_mask, call to check hugepages within
> > >
> > > I think that one of the purposes of DPDK is to support DMA transfers
> > > in userspace. In other words, I can see no reason to support dma_mask
> > > at the ethdev level only.
> > >
> > > The limitation is a device limitation so I can not see a better place
> for
> > adding the device dma mask.
>
> That's what I've meant. It is a _device_ limitation. The ethdev is a
> wrapper
> around the rte_pci_device. The ethdev just extends semantics of the
> generic device.
> However, all DPDK devices are expected to be DMA-capable.
>
> If you get a pointer to the ethdev, you get a pointer to the
> rte_pci_device as well
> (1 more level of dereference but we are not on the fast path here, so it's
> unimportant).
>
> Consider the cryptodev. If cryptodev has some DMA mask requirements we can
> support it
> in the generic place, i.e. rte_pci_device and not rte_ethdev because the
> cryptodev
> is not an ethdev.
>
>
Ok. I was wrongly assuming we had just ethdevs, with the ethdev being the
generic and rte_pci_device being a type of ethdev.

I can add the dma mask to the rte_pci_dev. The extra level of dereference
is not a problem as long as we do not use that dma mask for a more complex
allocation API (more about this later).

If I understand it right, work is in progress for adding a rte_device. I
can not see a problem with adding dma mask to the rte_device struct either.



> >
> >
> > > We should consider adding this to the generic struct rte_device
> > > (currently rte_pci_device). Thomas?
> > >
> > > I guess it could be a non-pci device with such a limitation. I though
> > rte_ethdev is more generic.
>
> When it is added to the rte_pci_device (or rte_device after the planned
> changes)
> the non-PCI devices get this for free... Otherwise I don't understand the
> point
> here.
>
> >
> >
> > > >supported range.
> > >
> > > I think, the '-' is unnecessary at the beginning of line. As for me
> > > I prefer a fluent text describing the purpose. The '-' is useful for
> > > a real list of notes.
> > >
> > > >
> > > > Signed-off-by: Alejandro Lucero 
> > > >
> > > > ---
> > > > lib/librte_ether/rte_ethdev.c | 7 +++
> > > >  lib/librte_ether/rte_ethdev.h | 1 +
> > > >  2 files changed, 8 insertions(+)
> > > >
> > > > diff --git a/lib/librte_ether/rte_ethdev.c
> > > b/lib/librte_ether/rte_ethdev.c
> > > > index a31018e..c0de88a 100644
> > > > --- a/lib/librte_ether/rte_ethdev.c
> > > > +++ b/lib/librte_ether/rte_ethdev.c
> > > > @@ -280,9 +280,16 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,
> > > >
> > > >   /* Invoke PMD device initialization function */
> > > >   diag = (*eth_drv->eth_dev_init)(eth_dev);
> > > > + if (diag)
> > > > + goto err;
> > > > +
> > > > + if (eth_dev->data->dma_mask)
> > > > + diag =
> > > rte_eal_hugepage_check_address_mask(eth_dev->data->dma_mask);
> > > > +
> > >
> > > I don't understand what happens if the memory is out of the DMA mask.
> What
> > > can the driver
> > > do? Does it just fail?
> > >
> > > I think that this should be considered during a malloc instead. (Well,
> > > there is probably
> > > no suitable API for this at the moment.)
> > >
> > > hugepage memory allocation is done before device initialization. I see
> > easier to leave the normal hugepage code as it is now and add a later
> call
> > if a device requires it.
>
> True. I didn't meant to change hugepages allocation but to change
> allocation
> of memory for a device. If we reserve a set of hugepages, a subset of them
> can
> match the DMA mask for a particular device. When allocating memory for a
> device,
> we can consider the DMA mask and choose only the hugepages we can handle.
>
> Quite frankly, I am not very aware of the memory allocation internals of
> DPDK so
> I can be wrong...
>
>
Of course, we could use a device dma mask smartly, and for ethdevs, to
allocate device TX and RX rings and mbufs just from mempools with hugepages
in the supported range. Any memory allocation by the app not related to
packet handling could use another mempool with no dma mask restriction at
all. This implies awareness by the app in some way, what I guess it would
preferable to avoid.

In our case, NFP PMD support, the restriction is 40bits which implies
potential problems with machines 

[dpdk-dev] [PATCH] examples/ip_pipline: fix memory initialization in firewall bulk functions

2016-05-13 Thread Dumitrescu, Cristian


> -Original Message-
> From: Mrzyglod, DanielX T
> Sent: Friday, May 6, 2016 6:55 PM
> To: Kerlin, MarcinX ; Dumitrescu, Cristian
> ; Singh, Jasvinder
> 
> Cc: dev at dpdk.org; Mrzyglod, DanielX T 
> Subject: [PATCH] examples/ip_pipline: fix memory initialization in firewall
> bulk functions
> 
> bulk functions expect that all memory is set with zeros
> 
> Fixes: 67ebdbef0c31 ("examples/ip_pipeline: add bulk update of firewall
> rules")
> 
> Signed-off-by: Daniel Mrzyglod 
> ---
>  examples/ip_pipeline/pipeline/pipeline_firewall_be.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/examples/ip_pipeline/pipeline/pipeline_firewall_be.c
> b/examples/ip_pipeline/pipeline/pipeline_firewall_be.c
> index e7a8a4c..4edca66 100644
> --- a/examples/ip_pipeline/pipeline/pipeline_firewall_be.c
> +++ b/examples/ip_pipeline/pipeline/pipeline_firewall_be.c
> @@ -732,7 +732,7 @@ pipeline_firewall_msg_req_add_bulk_handler(struct
> pipeline *p, void *msg)
>   n_keys = req->n_keys;
> 
>   for (i = 0; i < n_keys; i++) {
> - entries[i] = rte_malloc(NULL,
> + entries[i] = rte_zmalloc(NULL,
>   sizeof(struct firewall_table_entry),
>   RTE_CACHE_LINE_SIZE);
>   if (entries[i] == NULL) {
> @@ -740,7 +740,7 @@ pipeline_firewall_msg_req_add_bulk_handler(struct
> pipeline *p, void *msg)
>   return rsp;
>   }
> 
> - params[i] = rte_malloc(NULL,
> + params[i] = rte_zmalloc(NULL,
>   sizeof(struct
> rte_table_acl_rule_add_params),
>   RTE_CACHE_LINE_SIZE);
>   if (params[i] == NULL) {
> @@ -814,7 +814,7 @@ pipeline_firewall_msg_req_del_bulk_handler(struct
> pipeline *p, void *msg)
>   n_keys = req->n_keys;
> 
>   for (i = 0; i < n_keys; i++) {
> - params[i] = rte_malloc(NULL,
> + params[i] = rte_zmalloc(NULL,
>   sizeof(struct
> rte_table_acl_rule_delete_params),
>   RTE_CACHE_LINE_SIZE);
>   if (params[i] == NULL) {
> --
> 2.5.5


Acked-by: Cristian Dumitrescu 



[dpdk-dev] [PATCH v1 03/28] eal/linux: extract function rte_eal_unbind_kernel_driver

2016-05-13 Thread Jianbo Liu
On 6 May 2016 at 21:47, Jan Viktorin  wrote:
> Generalize the PCI-specific pci_unbind_kernel_driver. It is now divided into
> two parts. First, determination of the path and string identification of the
> device to be unbound. Second, the actual unbind operation which is generic.
>
> Signed-off-by: Jan Viktorin 
> ---
>  lib/librte_eal/common/eal_private.h   | 13 +
>  lib/librte_eal/linuxapp/eal/eal.c | 26 ++
>  lib/librte_eal/linuxapp/eal/eal_pci.c | 33 +
>  3 files changed, 48 insertions(+), 24 deletions(-)
>
> diff --git a/lib/librte_eal/common/eal_private.h 
> b/lib/librte_eal/common/eal_private.h
> index 81816a6..3fb8353 100644
> --- a/lib/librte_eal/common/eal_private.h
> +++ b/lib/librte_eal/common/eal_private.h
> @@ -289,6 +289,19 @@ int rte_eal_alarm_init(void);
>  int rte_eal_check_module(const char *module_name);
>
>  /**
> + * Unbind kernel driver bound to the device specified by the given devpath,
> + * and its string identification.
> + *
> + * @param devpath  path to the device directory ("/sys/.../devices/")
> + * @param devididentification of the device ()
> + *
> + * @return
> + *  -1  unbind has failed
> + *   0  module has been unbound
> + */
> +int rte_eal_unbind_kernel_driver(const char *devpath, const char *devid);
> +
> +/**
>   * Get cpu core_id.
>   *
>   * This function is private to the EAL.
> diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
> b/lib/librte_eal/linuxapp/eal/eal.c
> index e8fce6b..844f958 100644
> --- a/lib/librte_eal/linuxapp/eal/eal.c
> +++ b/lib/librte_eal/linuxapp/eal/eal.c
> @@ -949,3 +949,29 @@ rte_eal_check_module(const char *module_name)
> /* Module has been found */
> return 1;
>  }
> +
> +int
> +rte_eal_unbind_kernel_driver(const char *devpath, const char *devid)
> +{
> +   char filename[PATH_MAX];
> +   FILE *f;
> +
> +   snprintf(filename, sizeof(filename),
> +"%s/driver/unbind", devpath);
> +
> +   f = fopen(filename, "w");
> +   if (f == NULL) /* device was not bound */
> +   return 0;
> +
> +   if (fwrite(devid, strlen(devid), 1, f) == 0) {
> +   RTE_LOG(ERR, EAL, "%s(): could not write to %s\n", __func__,
> +   filename);
> +   goto error;
> +   }
> +
> +   fclose(f);
> +   return 0;
> +error:
> +   fclose(f);
> +   return -1;
> +}
> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
> b/lib/librte_eal/linuxapp/eal/eal_pci.c
> index fd7e34f..312cb14 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_pci.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
> @@ -59,38 +59,23 @@ int
>  pci_unbind_kernel_driver(struct rte_pci_device *dev)
>  {
> int n;
> -   FILE *f;
> -   char filename[PATH_MAX];
> -   char buf[BUFSIZ];
> +   char devpath[PATH_MAX];
> +   char devid[BUFSIZ];
> struct rte_pci_addr *loc = >addr;
>
> -   /* open /sys/bus/pci/devices/:BB:CC.D/driver */
> -   snprintf(filename, sizeof(filename),
> -SYSFS_PCI_DEVICES "/" PCI_PRI_FMT "/driver/unbind",
> +   /* devpath /sys/bus/pci/devices/:BB:CC.D */
> +   snprintf(devpath, sizeof(devpath),
> +SYSFS_PCI_DEVICES "/" PCI_PRI_FMT,
>  loc->domain, loc->bus, loc->devid, loc->function);
>
> -   f = fopen(filename, "w");
> -   if (f == NULL) /* device was not bound */
> -   return 0;
> -
> -   n = snprintf(buf, sizeof(buf), PCI_PRI_FMT "\n",
> +   n = snprintf(devid, sizeof(devid), PCI_PRI_FMT "\n",
>  loc->domain, loc->bus, loc->devid, loc->function);
> -   if ((n < 0) || (n >= (int)sizeof(buf))) {
> +   if ((n < 0) || (n >= (int)sizeof(devid))) {

Is it better to move "(n >= (int)sizeof(devid))" before snprintf and
it has different reason from "n < 0"?

> RTE_LOG(ERR, EAL, "%s(): snprintf failed\n", __func__);
> -   goto error;
> -   }
> -   if (fwrite(buf, n, 1, f) == 0) {
> -   RTE_LOG(ERR, EAL, "%s(): could not write to %s\n", __func__,
> -   filename);
> -   goto error;
> +   return -1;
> }
>
> -   fclose(f);
> -   return 0;
> -
> -error:
> -   fclose(f);
> -   return -1;
> +   return rte_eal_unbind_kernel_driver(devpath, devid);
>  }
>
>  static int
> --
> 2.8.0
>


[dpdk-dev] [PATCH v4] examples/qos_meter: fix unchecked return value

2016-05-13 Thread Dumitrescu, Cristian


> -Original Message-
> From: Mrozowicz, SlawomirX
> Sent: Friday, May 13, 2016 9:35 AM
> To: Dumitrescu, Cristian 
> Cc: dev at dpdk.org; Singh, Jasvinder ;
> Mrozowicz, SlawomirX 
> Subject: [PATCH v4] examples/qos_meter: fix unchecked return value
> 
> Fix issue reported by Coverity.
> 
> Coverity ID 30693: Unchecked return value
> check_return: Calling rte_meter_srtcm_config without checking return
> value.
> 
> Fixes: e6541fdec8b2 ("meter: initial import")
> 
> Signed-off-by: Slawomir Mrozowicz 
> ---
>  examples/qos_meter/main.c | 16 
>  examples/qos_meter/main.h |  2 +-
>  2 files changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/examples/qos_meter/main.c b/examples/qos_meter/main.c
> index b968b00..1565615 100644
> --- a/examples/qos_meter/main.c
> +++ b/examples/qos_meter/main.c
> @@ -133,14 +133,20 @@ struct rte_meter_trtcm_params
> app_trtcm_params[] = {
> 
>  FLOW_METER app_flows[APP_FLOWS_MAX];
> 
> -static void
> +static int
>  app_configure_flow_table(void)
>  {
>   uint32_t i, j;
> + int ret;
> 
> - for (i = 0, j = 0; i < APP_FLOWS_MAX; i ++, j = (j + 1) %
> RTE_DIM(PARAMS)){
> - FUNC_CONFIG(_flows[i], [j]);
> + for (i = 0, j = 0; i < APP_FLOWS_MAX;
> + i ++, j = (j + 1) % RTE_DIM(PARAMS)) {
> + ret = FUNC_CONFIG(_flows[i], [j]);
> + if (ret)
> + return ret;
>   }
> +
> + return 0;
>  }
> 
>  static inline void
> @@ -381,7 +387,9 @@ main(int argc, char **argv)
>   rte_eth_promiscuous_enable(port_tx);
> 
>   /* App configuration */
> - app_configure_flow_table();
> + ret = app_configure_flow_table();
> + if (ret < 0)
> + rte_exit(EXIT_FAILURE, "Invalid configure flow table\n");
> 
>   /* Launch per-lcore init on every lcore */
>   rte_eal_mp_remote_launch(main_loop, NULL, CALL_MASTER);
> diff --git a/examples/qos_meter/main.h b/examples/qos_meter/main.h
> index 530bf69..54867dc 100644
> --- a/examples/qos_meter/main.h
> +++ b/examples/qos_meter/main.h
> @@ -51,7 +51,7 @@ enum policer_action
> policer_table[e_RTE_METER_COLORS][e_RTE_METER_COLORS] =
>  #if APP_MODE == APP_MODE_FWD
> 
>  #define FUNC_METER(a,b,c,d) color, flow_id=flow_id, pkt_len=pkt_len,
> time=time
> -#define FUNC_CONFIG(a,b)
> +#define FUNC_CONFIG(a, b) 0
>  #define PARAMS   app_srtcm_params
>  #define FLOW_METER int
> 
> --
> 1.9.1

Acked-by: Cristian Dumitrescu 




[dpdk-dev] [PATCH] qat: change optimization flag for Intel QuickAssist Technology

2016-05-13 Thread Jain, Deepak K
Hi Thomas,

This change was made to fix the compilation issues arising when optimization 
flag was changed. Hence its related to same optimization flag patch.
Do you want us to separate the Makefile and .c file change?

Regards,
Deepak

-Original Message-
From: Thomas Monjalon [mailto:thomas.monja...@6wind.com] 
Sent: Friday, May 13, 2016 9:18 AM
To: Kusztal, ArkadiuszX 
Cc: dev at dpdk.org; Trahe, Fiona ; Griffin, John 
; Jain, Deepak K 
Subject: Re: [dpdk-dev] [PATCH] qat: change optimization flag for Intel 
QuickAssist Technology

2016-05-10 10:24, Arek Kusztal:
> From: Arkadiusz Kusztal 
> 
> Changed to -O3 optimization flag in Intel QuickAssist Technology Makefile

There is another change below. Should it be a separate patch?

> --- a/drivers/crypto/qat/qat_adf/qat_algs_build_desc.c
> +++ b/drivers/crypto/qat/qat_adf/qat_algs_build_desc.c
> @@ -616,10 +616,12 @@ int 
> qat_alg_aead_session_create_content_desc_auth(struct qat_session *cdesc,
>* Write (the length of AAD) into bytes 16-19 of state2
>* in big-endian format. This field is 8 bytes
>*/
> - *(uint32_t *)&(hash->sha.state1[
> + uint32_t *aad_len = (uint32_t *)>sha.state1[
>   ICP_QAT_HW_GALOIS_128_STATE1_SZ +
> - ICP_QAT_HW_GALOIS_H_SZ]) =
> - rte_bswap32(add_auth_data_length);
> + ICP_QAT_HW_GALOIS_H_SZ];
> +
> + *aad_len = rte_bswap32(add_auth_data_length);
> +
>   proto = ICP_QAT_FW_LA_GCM_PROTO;
>   } else if (cdesc->qat_hash_alg == ICP_QAT_HW_AUTH_ALGO_SNOW_3G_UIA2)  {
>   proto = ICP_QAT_FW_LA_SNOW_3G_PROTO;
> 




[dpdk-dev] [ovs-dev] Traffic scheduling by qos_sched library in DPDK

2016-05-13 Thread gayathri.manepa...@wipro.com
Hi Team,

I started working on implementing the QoS Shaping in OVS+DPDK by making use of 
rte_sched library provided in DPDK.  Meanwhile to compare the performance, 
started performance test with DPDK sample scheduling application. Below are the 
configuration details of system which I am using,

Server Type : Intel ATOM

Huge page configuration: (Each page of 2M size)

[root at ATOM qos_sched]# grep -i huge /proc/meminfo
AnonHugePages: 90112 kB
HugePages_Total:7168
HugePages_Free: 7168
HugePages_Rsvd:0
HugePages_Surp:0
Hugepagesize:   2048 kB

Port Capacity : 1G (All four ports)
I am able to successfully run the qos_sched with three pfc's as below,

./build/qos_sched -c 0x3e -n 1 --socket-mem 14336 -- --pfc "0,1,2,3" --pfc 
"1,0,3,2" --pfc "2,3,4,5" --cfg ./profile.cfg

Issue :

When I am trying to add one more profile configuration flow(4th one) , I am 
getting below error

Command : ./build/qos_sched -c 0x3e -n 1 --socket-mem 14336 -- --pfc "0,1,2,3" 
--pfc "1,0,3,2" --pfc "2,3,4,5" --pfc "3,2,5,4"  --cfg ./profile.cfg

Error:

done:  Link Up - speed 1000 Mbps - full-duplex
SCHED: Low level config for pipe profile 0:
Token bucket: period = 1, credits per period = 1, size = 10
Traffic classes: period = 500, credits per period = [500, 
500, 500, 500]
   Traffic class 3 oversubscription: weight = 0
WRR cost: [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]
SCHED: Low level config for subport 0:
Token bucket: period = 1, credits per period = 1, size = 10
Traffic classes: period = 125, credits per period = [125, 
125, 125, 125]
Traffic class 3 oversubscription: wm min = 0, wm max = 0
EAL: Error - exiting with code: 1
  Cause: Cannot init mbuf pool for socket 3

Analysis:

I have analyzed DPDK source code to find the root cause. I could see that in 
qos_sched, memory allocation while creating each mbug pool (rte_mempool_create) 
for corresponding RX port is as below,


MBUF_SIZE = (1528 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM)

mp_size  =  2*1024*1024



>From above I understood that, for each pfc/ rx port around 4G of huge pages 
>are consumed. Whereas ATOM is capable of maximum 7168 huge pages of 2M which 
>is 14336M in total. So I am not able to configure beyond three pfc's. But I 
>would like to measure the performance with 4 port & 6 port scenario which 
>requires 4-6 pfc's configured.



Is there any other alternative through which I can configure more number of 
pfc's with my system configuration provided above.



Thanks & Regards,

Gayathri

The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments. WARNING: Computer viruses can be transmitted via email. The 
recipient should check this email and any attachments for the presence of 
viruses. The company accepts no liability for any damage caused by any virus 
transmitted by this email. www.wipro.com


[dpdk-dev] [PATCHv3 1/2] config/armv8a: disable igb_uio

2016-05-13 Thread Hemant Agrawal


> -Original Message-
> From: Jianbo Liu [mailto:jianbo.liu at linaro.org]
> Sent: Friday, May 13, 2016 7:13 AM
> To: Santosh Shukla 
> Cc: Stephen Hemminger ; Jerin Jacob
> ; Hemant Agrawal
> ; dev at dpdk.org; Thomas Monjalon
> 
> Subject: Re: [dpdk-dev] [PATCHv3 1/2] config/armv8a: disable igb_uio
> 
> On 12 May 2016 at 18:31, Santosh Shukla
>  wrote:
> > On Thu, May 12, 2016 at 05:52:54PM +0800, Jianbo Liu wrote:
> >> On 12 May 2016 at 16:57, Santosh Shukla
> >>  wrote:
> >> > On Thu, May 12, 2016 at 01:54:13PM +0800, Jianbo Liu wrote:
> >> >> On 12 May 2016 at 13:06, Santosh Shukla
> >> >>  wrote:
> >> >> > On Thu, May 12, 2016 at 11:42:26AM +0800, Jianbo Liu wrote:
> >> >> >> On 12 May 2016 at 11:17, Santosh Shukla
> >> >> >>  wrote:
> >> >> >> > On Thu, May 12, 2016 at 10:01:05AM +0800, Jianbo Liu wrote:
> >> >> >> >> On 12 May 2016 at 02:25, Stephen Hemminger
>  wrote:
> >> >> >> >> > On Wed, 11 May 2016 22:32:16 +0530 Jerin Jacob
> >> >> >> >> >  wrote:
> >> >> >> >> >
> >> >> >> >> >> On Wed, May 11, 2016 at 08:22:59AM -0700, Stephen
> Hemminger wrote:
> >> >> >> >> >> > On Wed, 11 May 2016 19:17:58 +0530 Hemant Agrawal
> >> >> >> >> >> >  wrote:
> >> >> >> >> >> >
> >> >> >> >> >> > > IGB_UIO not supported for arm64 arch in kernel so disable.
> >> >> >> >> >> > >
> >> >> >> >> >> > > Signed-off-by: Hemant Agrawal
> >> >> >> >> >> > > 
> >> >> >> >> >> > > Reviewed-by: Santosh Shukla
> >> >> >> >> >> > > 
> >> >> >> >> >> >
> >> >> >> >> >> > Really, I have use IGB_UIO on ARM64
> >> >> >> >> >>
> >> >> >> >> >> May I know what is the technical use case for igb_uio on
> >> >> >> >> >> arm64 which cannot be addressed through vfio or vfioionommu.
> >> >> >> >> >
> >> >> >> >> > I was running on older kernel which did not support vfioionommu
> mode.
> >> >> >> >>
> >> >> >> >> As I said, most of DPDK developers are not kernel
> >> >> >> >> developers. They may have their own kernel tree, and
> >> >> >> >> couldn't like to upgrade to latest kernel.
> >> >> >> >> They can choose to use or not use igb_uio when binding the
> >> >> >> >> driver. But blindly disabling it in the base config seems 
> >> >> >> >> unreasonable.
> >> >> >> >
> >> >> >> > if user keeping his own kernel so they could also keep
> >> >> >> > IGB_UIO=y in their local
> >> >> >> Most likely they don't have local dpdk tree. They write their
> >> >> >> own applications, complie and link to dpdk lib, then done.
> >> >> >>
> >> >> >> > dpdk tree. Why are you imposing user-x custome depedancy on
> >> >> >> > upstream dpdk base
> >> >> >> Customer requiremnts is important. I want they can choose the way
> they like.
> >> >> >>
> >> >> >
> >> >> > so you choose to keep igb_uio option, provided arch doesn't support?
> >> >> > new user did reported issues with igb_uio for arm64, refer this
> >> >> > thread [1], as well hemanth too faced issues. we want to avoid that.
> >> >> >
> >> >> > If customer maintaing out-of-tree kernel then he can also switch to 
> >> >> > vfio-
> way.
> >> >> > isn;t it?
> >> >> >
> >> >> >> > config. Is it not enough for explanation that - Base config
> >> >> >> > ie.. armv8 doesn;t support pci mmap, so igb_uio is n/a. New
> >> >> >> > user wont able to build/run dpdk/arm64 in igb_uio-way, He'll
> >> >> >> > prefer to use upstream stuff. I think, you are not making
> >> >> >> You are wrong, he can build dpdk. If he like to use upstream
> >> >> >> without patching, he can use vfio.
> >> >> >
> >> >> > I disagree, we want to avoid [1] for new user.
> >> >> >
> >> >> >> But you can't ignore the need from old user which is more
> >> >> >> comfortable with older kernel.
> >> >> >>
> >> >> > arm/arm64 dpdk support recently added and I am guessing, most
> >> >> > likely customer using near latest kernel, switching to vfio won't be 
> >> >> > so
> difficult.
> >> >> >
> >> >> > Or can you take up responsibility of upstreaming pci mmap patch,
> >> >> > then we don't need this patch.
> >> >> >
> >> >> > [1] http://dpdk.org/ml/archives/dev/2016-January/031313.html
> >> >>
> >> >> Can you read carefully about the guide at
> >> >> http://dpdk.org/doc/guides/linux_gsg/build_dpdk.html? It says to
> >> >> use uio_pci_generic, igb_uio or vfio-pci.
> >> >
> >> > *** applicable and works for x86 only, not for arm64: because pci
> >> > mmap support not present for arm64, in that case we should update the
> doc.
> >> >
> >> >> Could it be possible that the user in that thread has already read
> >> >> and tried them all and found that he can't enable vifo with his
> >> >> kernel, and igb_uio is the easy way for him and asked for help from
> community?
> >> >> If so, we have no choice but keeping igb_uio enabled.
> >> >
> >> > By then vfionoiommu support was wip progress in dpdk/linux. but now
> >> > it merged and it works. So no need to retain igb_uio in base config
> >> > for which to work - user need to use mmap patch at linux side.
> >>
> >> We can't decide which kernel user will use.
> >>
> >
> > yes, we can't decide kernel 

[dpdk-dev] [PATCH v1] net: i40e: add VLAN tag size to RXMAX

2016-05-13 Thread Wu, Jingjing
Hi, Nikita

dev_conf.rxmode.max_rx_pkt_len is different with MTU concept.
The max_rx_pkt_len indicates the maximum packet length it can receive, it 
should be larger than MTU.

There is another patch which is enabling set_mtu ops.
http://dpdk.org/dev/patchwork/patch/12218/
You can definitely help to review and comment it.

Thanks
Jingjing

> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Nikita Kozlov
> Sent: Friday, May 06, 2016 11:51 PM
> To: Zhang, Helin
> Cc: dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v1] net: i40e: add VLAN tag size to RXMAX
> 
> Hello,
> 
> On 09/ 1/15 07:34 AM, Zhang, Helin wrote:
> >> -Original Message-
> >> From: Vlad Zolotarov [mailto:vladz at cloudius-systems.com]
> >> Sent: Monday, August 31, 2015 2:42 PM
> >> To: dev at dpdk.org
> >> Cc: Zhang, Helin; Ananyev, Konstantin; avi at cloudius-systems.com; Vlad
> >> Zolotarov
> >> Subject: [dpdk-dev] [PATCH v1] net: i40e: add VLAN tag size to RXMAX
> >>
> >> HW requires it regardless the presence of the VLAN tag in the received
> frame.
> >> Otherwise Rx frames are being filtered out on the MTU-4 boundary.
> > Maximum packet length could have different meanings from MTU. I agree
> > with you to have it be regardless of vlan tag length.
> >
> >> Signed-off-by: Vlad Zolotarov 
> >> ---
> >>  drivers/net/i40e/i40e_rxtx.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/net/i40e/i40e_rxtx.c
> >> b/drivers/net/i40e/i40e_rxtx.c index
> >> eae4ab0..22aaeb1 100644
> >> --- a/drivers/net/i40e/i40e_rxtx.c
> >> +++ b/drivers/net/i40e/i40e_rxtx.c
> >> @@ -3156,7 +3156,7 @@ i40e_rx_queue_init(struct i40e_rx_queue *rxq)
> >>rx_ctx.hsplit_0 = I40E_HEADER_SPLIT_ALL;
> >>else
> >>rx_ctx.hsplit_0 = I40E_HEADER_SPLIT_NONE;
> >> -  rx_ctx.rxmax = rxq->max_pkt_len;
> >> +  rx_ctx.rxmax = rxq->max_pkt_len + I40E_VLAN_TAG_SIZE;
> > It needs to take into account the double vlan case, and also VF case.
> > It seems it needs more code changes. Thank you for the contribution!
> I was wondering if this "bug" haven't been forgotten ? Even if it his not
> patched yet maybe it is worth an entry in the documentation ?
> >
> > Regards,
> > Helin
> >
> >>rx_ctx.tphrdesc_ena = 1;
> >>rx_ctx.tphwdesc_ena = 1;
> >>rx_ctx.tphdata_ena = 1;
> >> --
> >> 2.1.0



[dpdk-dev] [PATCH v2 06/11] app/test: use linked list to store PCI drivers

2016-05-13 Thread Thomas Monjalon
2016-05-12 23:00, Jan Viktorin:
> On Thu, 12 May 2016 18:08:16 +0200
> Thomas Monjalon  wrote:
> 
> > 2016-05-12 17:53, Jan Viktorin:
> > > On Thu, 12 May 2016 17:31:28 +0200
> > > Thomas Monjalon  wrote:
> > >   
> > > > 2016-05-10 20:13, Jan Viktorin:  
> > > > > The test unregisters all real drivers before starting into an array. 
> > > > > This
> > > > > inflexiable as we can use a linked list for this purpose.
> > > > 
> > > > I don't understand this. Maybe some words are missing.  
> > > 
> > > Better?
> > > 
> > > The test unregisters all real drivers before starting (stored into an 
> > > array).
> > > This is inflexiable (due to its fixed size) and we can use a linked list 
> > > for
> > > this purpose.
> > 
> > Better with a past tense? "The test was unregistering..."
> 
> No. This patch does not change the semantics (well, it does, because
> the list of drivers become global but that's all). The test still
> unregisters the drivers. That is the important fact to consider.
> 
> Perhaps:
> 
> The test unregisters all drivers before start. The drivers were stored
> into a fixed-sized array. This is inflexible. This patch change this to
> utilize a linked list for the same purpose.

Yes better. Thanks


[dpdk-dev] [PATCH v2 6/6] vhost: add pmd client and reconnect option

2016-05-13 Thread Yuanhan Liu
Add client and reconnect option to vhost pmd. reconnect only works when
client is given.

Signed-off-by: Yuanhan Liu 
---
 drivers/net/vhost/rte_eth_vhost.c | 54 ++-
 1 file changed, 42 insertions(+), 12 deletions(-)

diff --git a/drivers/net/vhost/rte_eth_vhost.c 
b/drivers/net/vhost/rte_eth_vhost.c
index 91b5d95..c7e03d0 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -50,12 +50,16 @@

 #define ETH_VHOST_IFACE_ARG"iface"
 #define ETH_VHOST_QUEUES_ARG   "queues"
+#define ETH_VHOST_CLIENT_ARG   "client"
+#define ETH_VHOST_RECONNECT_ARG"reconnect"

 static const char *drivername = "VHOST PMD";

 static const char *valid_arguments[] = {
ETH_VHOST_IFACE_ARG,
ETH_VHOST_QUEUES_ARG,
+   ETH_VHOST_CLIENT_ARG,
+   ETH_VHOST_RECONNECT_ARG,
NULL
 };

@@ -89,6 +93,7 @@ struct pmd_internal {
char *dev_name;
char *iface_name;
uint16_t max_queues;
+   uint64_t flags;

volatile uint16_t once;
 };
@@ -467,7 +472,8 @@ eth_dev_start(struct rte_eth_dev *dev)
int ret = 0;

if (rte_atomic16_cmpset(>once, 0, 1)) {
-   ret = rte_vhost_driver_register(internal->iface_name, 0);
+   ret = rte_vhost_driver_register(internal->iface_name,
+   internal->flags);
if (ret)
return ret;
}
@@ -672,7 +678,7 @@ static const struct eth_dev_ops ops = {

 static int
 eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues,
-const unsigned numa_node)
+const unsigned numa_node, uint64_t flags)
 {
struct rte_eth_dev_data *data = NULL;
struct pmd_internal *internal = NULL;
@@ -729,6 +735,7 @@ eth_dev_vhost_create(const char *name, char *iface_name, 
int16_t queues,
internal->iface_name = strdup(iface_name);
if (internal->iface_name == NULL)
goto error;
+   internal->flags = flags;

list->eth_dev = eth_dev;
pthread_mutex_lock(_list_lock);
@@ -793,18 +800,15 @@ open_iface(const char *key __rte_unused, const char 
*value, void *extra_args)
 }

 static inline int
-open_queues(const char *key __rte_unused, const char *value, void *extra_args)
+open_int(const char *key __rte_unused, const char *value, void *extra_args)
 {
-   uint16_t *q = extra_args;
+   uint16_t *n = extra_args;

if (value == NULL || extra_args == NULL)
return -EINVAL;

-   *q = (uint16_t)strtoul(value, NULL, 0);
-   if (*q == USHRT_MAX && errno == ERANGE)
-   return -1;
-
-   if (*q > RTE_MAX_QUEUES_PER_PORT)
+   *n = (uint16_t)strtoul(value, NULL, 0);
+   if (*n == USHRT_MAX && errno == ERANGE)
return -1;

return 0;
@@ -817,6 +821,9 @@ rte_pmd_vhost_devinit(const char *name, const char *params)
int ret = 0;
char *iface_name;
uint16_t queues;
+   uint64_t flags = 0;
+   int client_mode;
+   int reconnect;

RTE_LOG(INFO, PMD, "Initializing pmd_vhost for %s\n", name);

@@ -836,14 +843,37 @@ rte_pmd_vhost_devinit(const char *name, const char 
*params)

if (rte_kvargs_count(kvlist, ETH_VHOST_QUEUES_ARG) == 1) {
ret = rte_kvargs_process(kvlist, ETH_VHOST_QUEUES_ARG,
-_queues, );
-   if (ret < 0)
+_int, );
+   if (ret < 0 || queues > RTE_MAX_QUEUES_PER_PORT)
goto out_free;

} else
queues = 1;

-   eth_dev_vhost_create(name, iface_name, queues, rte_socket_id());
+   if (rte_kvargs_count(kvlist, ETH_VHOST_CLIENT_ARG) == 1) {
+   ret = rte_kvargs_process(kvlist, ETH_VHOST_CLIENT_ARG,
+_int, _mode);
+   if (ret < 0)
+   goto out_free;
+   }
+   if (rte_kvargs_count(kvlist, ETH_VHOST_RECONNECT_ARG) == 1) {
+   ret = rte_kvargs_process(kvlist, ETH_VHOST_RECONNECT_ARG,
+_int, );
+   if (ret < 0)
+   goto out_free;
+   }
+   if (client_mode)
+   flags |= RTE_VHOST_USER_CLIENT;
+   if (reconnect)
+   flags |= RTE_VHOST_USER_RECONNECT;
+   if (reconnect && !client_mode) {
+   RTE_LOG(ERR, PMD,
+   "reconnect works only when client is specified\n");
+   ret = -1;
+   goto out_free;
+   }
+
+   eth_dev_vhost_create(name, iface_name, queues, rte_socket_id(), flags);

 out_free:
rte_kvargs_free(kvlist);
-- 
1.9.0



[dpdk-dev] [PATCH v2 5/6] examples/vhost: add client and reconnect option

2016-05-13 Thread Yuanhan Liu
Add --client and --reconnect option to enable the client mode and
reconnect mode, respectively. --rconnect works only when --client
is given as well.

Signed-off-by: Yuanhan Liu 
---
 examples/vhost/main.c | 23 +--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 1391cd6..5048d23 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -132,6 +132,9 @@ static uint32_t enable_tx_csum;
 /* Disable TSO offload */
 static uint32_t enable_tso;

+static int client_mode;
+static int reconnect;
+
 /* Specify timeout (in useconds) between retries on RX. */
 static uint32_t burst_rx_delay_time = BURST_RX_WAIT_US;
 /* Specify the number of retries on RX. */
@@ -458,7 +461,9 @@ us_vhost_usage(const char *prgname)
"   --stats [0-N]: 0: Disable stats, N: Time in seconds to 
print stats\n"
"   --dev-basename: The basename to be used for the 
character device.\n"
"   --tx-csum [0|1] disable/enable TX checksum offload.\n"
-   "   --tso [0|1] disable/enable TCP segment offload.\n",
+   "   --tso [0|1] disable/enable TCP segment offload.\n"
+   "   --client register a vhost-user socket as client mode.\n"
+   "   --reconnect reconnect to vhost-user server when 
disconnects.\n",
   prgname);
 }

@@ -483,6 +488,8 @@ us_vhost_parse_args(int argc, char **argv)
{"dev-basename", required_argument, NULL, 0},
{"tx-csum", required_argument, NULL, 0},
{"tso", required_argument, NULL, 0},
+   {"client", no_argument, _mode, 1},
+   {"reconnect", no_argument, , 1},
{NULL, 0, 0, 0},
};

@@ -646,6 +653,12 @@ us_vhost_parse_args(int argc, char **argv)
}
}

+   if (reconnect && !client_mode) {
+   RTE_LOG(INFO, VHOST_CONFIG,
+   "--reconnect works only when --client is specified\n");
+   return -1;
+   }
+
for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
if (enabled_port_mask & (1 << i))
ports[num_ports++] = (uint8_t)i;
@@ -1403,6 +1416,7 @@ main(int argc, char *argv[])
uint8_t portid;
static pthread_t tid;
char thread_name[RTE_MAX_THREAD_NAME_LEN];
+   uint64_t flags = 0;

signal(SIGINT, sigint_handler);

@@ -1495,8 +1509,13 @@ main(int argc, char *argv[])
if (mergeable == 0)
rte_vhost_feature_disable(1ULL << VIRTIO_NET_F_MRG_RXBUF);

+   if (client_mode)
+   flags |= RTE_VHOST_USER_CLIENT;
+   if (reconnect)
+   flags |= RTE_VHOST_USER_RECONNECT;
+
/* Register vhost(cuse or user) driver to handle vhost messages. */
-   ret = rte_vhost_driver_register(dev_basename, 0);
+   ret = rte_vhost_driver_register(dev_basename, flags);
if (ret != 0)
rte_exit(EXIT_FAILURE, "vhost driver register failure.\n");

-- 
1.9.0



[dpdk-dev] [PATCH v2 4/6] vhost: workaround stale vring base

2016-05-13 Thread Yuanhan Liu
When DPDK app crashes (or quits, or gets killed), a restart of DPDK
app would get stale vring base from QEMU. That would break the kernel
virtio net completely, making it non-work any more, unless a driver
reset is done.

So, instead of getting the stale vring base from QEMU, Huawei suggested
we could get a much saner (and may not the most accurate) vring base
from used->idx. That would work because:

- there is a memory barrier between updating used ring entries and
  used->idx. So, even though we crashed at updating the used ring
  entries, it will not cause any issue, as the guest driver will not
  process those stale used entries, for used-idx is not updated yet.

- DPDK process vring in order, that means a crash may just lead some
  packet retransmission for Tx and drop for Rx.

Cc: "Michael S. Tsirkin" 
Suggested-by: Huawei Xie 
Signed-off-by: Yuanhan Liu 
Acked-by: "Michael S. Tsirkin" 
Acked-by: Huawei Xie 
---

v2: log on packets resent for Tx and drop for Rx
---
 lib/librte_vhost/virtio-net.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c
index 835ab3a..bd7e55e 100644
--- a/lib/librte_vhost/virtio-net.c
+++ b/lib/librte_vhost/virtio-net.c
@@ -561,6 +561,15 @@ vhost_set_vring_addr(int vid, struct vhost_vring_addr 
*addr)
return -1;
}

+   if (vq->last_used_idx != vq->used->idx) {
+   RTE_LOG(WARNING, VHOST_CONFIG,
+   "last_used_idx (%u) and vq->used->idx (%u) mismatches; "
+   "some packets maybe resent for Tx and dropped for Rx\n",
+   vq->last_used_idx, vq->used->idx);
+   vq->last_used_idx = vq->used->idx;
+   vq->last_used_idx_res = vq->used->idx;
+   }
+
vq->log_guest_addr = addr->log_guest_addr;

LOG_DEBUG(VHOST_CONFIG, "(%d) mapped address desc: %p\n",
-- 
1.9.0



[dpdk-dev] [PATCH v2 3/6] vhost: add reconnect ability

2016-05-13 Thread Yuanhan Liu
Allow reconnecting on failure when both RTE_VHOST_USER_RECONNECT and
RTE_VHOST_USER_CLIENT flags are set.

Reconnecting means two things here:

- when DPDK app starts first and QEMU (as the server) is not started,
  without reconnecting, DPDK app would simply fail on vhost-user
  registration.

- when QEMU reboots, without reconnecting, you can't re-establish the
  connection without restarting DPDK app.

This patch make it work well for both above cases. It simply creates
a new thread, and keep trying calling "connect()", until it succeeds.

Signed-off-by: Yuanhan Liu 
---

v2: - create one thread only to handle all reconnects
- update release note on reconnect
---
 doc/guides/rel_notes/release_16_07.rst   |   9 +++
 lib/librte_vhost/rte_virtio_net.h|   1 +
 lib/librte_vhost/vhost_user/vhost-net-user.c | 103 +--
 3 files changed, 109 insertions(+), 4 deletions(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index da2c6cf..c711b48 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -48,6 +48,15 @@ This section should contain new features added in this 
release. Sample format:
   the time of writing this, patches for QEMU are not merged yet, but it's
   likely to get merged in v2.7.

+* **Added vhost-user reconnect ability.**
+
+  Reconnect will only work in the client mode and when RTE_VHOST_USER_RECONNECT
+  flag is set. It allows DPDK to keep trying to connect to the server
+  (QEMU) until it succeeds when
+
+  * the first connect fails (when QEMU is not started yet)
+  * connection is broken (when QEMU restarts)
+

 Resolved Issues
 ---
diff --git a/lib/librte_vhost/rte_virtio_net.h 
b/lib/librte_vhost/rte_virtio_net.h
index 5f69e78..57eb03d 100644
--- a/lib/librte_vhost/rte_virtio_net.h
+++ b/lib/librte_vhost/rte_virtio_net.h
@@ -52,6 +52,7 @@
 #include 

 #define RTE_VHOST_USER_CLIENT  (1ULL << 0)
+#define RTE_VHOST_USER_RECONNECT   (1ULL << 1)

 /* Enum for virtqueue management. */
 enum {VIRTIO_RXQ, VIRTIO_TXQ, VIRTIO_QNUM};
diff --git a/lib/librte_vhost/vhost_user/vhost-net-user.c 
b/lib/librte_vhost/vhost_user/vhost-net-user.c
index a480f9f..6ede8a6 100644
--- a/lib/librte_vhost/vhost_user/vhost-net-user.c
+++ b/lib/librte_vhost/vhost_user/vhost-net-user.c
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 

@@ -60,6 +61,7 @@ struct vhost_user_socket {
char *path;
int listenfd;
bool is_server;
+   bool reconnect;
 };

 struct vhost_user_connection {
@@ -79,6 +81,7 @@ struct vhost_user {

 static void vhost_user_server_new_connection(int fd, void *data, int *remove);
 static void vhost_user_msg_handler(int fd, void *dat, int *remove);
+static int vhost_user_create_client(struct vhost_user_socket *vsocket);

 static struct vhost_user vhost_user = {
.fdset = {
@@ -305,6 +308,8 @@ vhost_user_msg_handler(int connfd, void *dat, int *remove)
vid = conn->vid;
ret = read_vhost_message(connfd, );
if (ret <= 0 || msg.request >= VHOST_USER_MAX) {
+   struct vhost_user_socket *vsocket = conn->vsocket;
+
if (ret < 0)
RTE_LOG(ERR, VHOST_CONFIG,
"vhost read message failed\n");
@@ -320,6 +325,9 @@ vhost_user_msg_handler(int connfd, void *dat, int *remove)
free(conn);
vhost_destroy_device(vid);

+   if (vsocket->reconnect)
+   vhost_user_create_client(vsocket);
+
return;
}

@@ -471,6 +479,73 @@ err:
return -1;
 }

+struct vhost_user_reconnect {
+   struct sockaddr_un un;
+   int fd;
+   struct vhost_user_socket *vsocket;
+
+   TAILQ_ENTRY(vhost_user_reconnect) next;
+};
+
+TAILQ_HEAD(vhost_user_reconnect_tailq_list, vhost_user_reconnect);
+struct vhost_user_reconnect_list {
+   struct vhost_user_reconnect_tailq_list head;
+   pthread_mutex_t mutex;
+};
+
+static struct vhost_user_reconnect_list reconn_list;
+static pthread_t reconn_tid;
+
+static void *
+vhost_user_client_reconnect(void *arg __rte_unused)
+{
+   struct vhost_user_reconnect *reconn, *next;
+
+   while (1) {
+   pthread_mutex_lock(_list.mutex);
+
+   /*
+* An equal implementation of TAILQ_FOREACH_SAFE,
+* which does not exist on all platforms.
+*/
+   for (reconn = TAILQ_FIRST(_list.head);
+reconn != NULL; reconn = next) {
+   next = TAILQ_NEXT(reconn, next);
+
+   if (connect(reconn->fd, (struct sockaddr *)>un,
+   sizeof(reconn->un)) < 0)
+   continue;
+
+   RTE_LOG(INFO, VHOST_CONFIG,
+   "%s: connected\n", reconn->vsocket->path);
+   

[dpdk-dev] [PATCH v2 2/6] vhost: add vhost-user client mode

2016-05-13 Thread Yuanhan Liu
Add a new paramter (flags) to rte_vhost_driver_register(). DPDK
vhost-user acts as client mode when RTE_VHOST_USER_CLIENT flag
is set.  The flags would also allow future extensions without
breaking the API (again).

The rest is straingfoward then: allocate a unix socket, and
bind/listen for server, connect for client.

This extension is for vhost-user only, therefore we simply quit
and report error when any flags are given for vhost-cuse.

Signed-off-by: Yuanhan Liu 
---
v2: - add relase doc
- do not remove socket file for client mode
---
 doc/guides/rel_notes/release_16_07.rst   |  14 ++
 drivers/net/vhost/rte_eth_vhost.c|   2 +-
 examples/vhost/main.c|   2 +-
 lib/librte_vhost/rte_virtio_net.h|  11 +-
 lib/librte_vhost/vhost_cuse/vhost-net-cdev.c |   8 +-
 lib/librte_vhost/vhost_user/vhost-net-user.c | 227 ---
 6 files changed, 170 insertions(+), 94 deletions(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index ebc507b..da2c6cf 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -34,6 +34,20 @@ This section should contain new features added in this 
release. Sample format:

   Refer to the previous release notes for examples.

+* **Added vhost-user client mode.**
+
+  DPDK vhost-user could be the server as well as the client. It supports
+  server mode only before, now it also supports client mode. Client mode
+  is enabled when RTE_VHOST_USER_CLIENT flag is set while calling
+  ``rte_vhost_driver_register``.
+
+  When DPDK vhost-user restarts from normal or abnormal quit (say crash),
+  the client mode would allow DPDK to establish the connect again.  Note
+  that a brand new QEMU version is needed to make it work: current QEMU
+  simply can not accept the connection from DPDK vhost-user restart. At
+  the time of writing this, patches for QEMU are not merged yet, but it's
+  likely to get merged in v2.7.
+

 Resolved Issues
 ---
diff --git a/drivers/net/vhost/rte_eth_vhost.c 
b/drivers/net/vhost/rte_eth_vhost.c
index 56c1c36..91b5d95 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -467,7 +467,7 @@ eth_dev_start(struct rte_eth_dev *dev)
int ret = 0;

if (rte_atomic16_cmpset(>once, 0, 1)) {
-   ret = rte_vhost_driver_register(internal->iface_name);
+   ret = rte_vhost_driver_register(internal->iface_name, 0);
if (ret)
return ret;
}
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index f3a6277..1391cd6 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -1496,7 +1496,7 @@ main(int argc, char *argv[])
rte_vhost_feature_disable(1ULL << VIRTIO_NET_F_MRG_RXBUF);

/* Register vhost(cuse or user) driver to handle vhost messages. */
-   ret = rte_vhost_driver_register((char *)_basename);
+   ret = rte_vhost_driver_register(dev_basename, 0);
if (ret != 0)
rte_exit(EXIT_FAILURE, "vhost driver register failure.\n");

diff --git a/lib/librte_vhost/rte_virtio_net.h 
b/lib/librte_vhost/rte_virtio_net.h
index bc2b74b..5f69e78 100644
--- a/lib/librte_vhost/rte_virtio_net.h
+++ b/lib/librte_vhost/rte_virtio_net.h
@@ -51,6 +51,8 @@
 #include 
 #include 

+#define RTE_VHOST_USER_CLIENT  (1ULL << 0)
+
 /* Enum for virtqueue management. */
 enum {VIRTIO_RXQ, VIRTIO_TXQ, VIRTIO_QNUM};

@@ -85,11 +87,14 @@ uint64_t rte_vhost_feature_get(void);

 int rte_vhost_enable_guest_notification(int vid, uint16_t queue_id, int 
enable);

-/* Register vhost driver. dev_name could be different for multiple instance 
support. */
-int rte_vhost_driver_register(const char *dev_name);
+/**
+ * Register vhost driver. path could be different for multiple
+ * instance support.
+ */
+int rte_vhost_driver_register(const char *path, uint64_t flags);

 /* Unregister vhost driver. This is only meaningful to vhost user. */
-int rte_vhost_driver_unregister(const char *dev_name);
+int rte_vhost_driver_unregister(const char *path);

 /* Register callbacks. */
 int rte_vhost_driver_callback_register(struct virtio_net_device_ops const * 
const);
diff --git a/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c 
b/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c
index cf6d191..5d15011 100644
--- a/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c
+++ b/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c
@@ -352,7 +352,7 @@ static const struct cuse_lowlevel_ops vhost_net_ops = {
  * vhost_net_device_ops are also passed when the device is registered in app.
  */
 int
-rte_vhost_driver_register(const char *dev_name)
+rte_vhost_driver_register(const char *dev_name, uint64_t flags)
 {
struct cuse_info cuse_info;
char device_name[PATH_MAX] = "";
@@ -364,6 +364,12 @@ rte_vhost_driver_register(const char *dev_name)
char fuse_opt_nomulti[] = FUSE_OPT_NOMULTI;
 

  1   2   >