[dpdk-dev] [PATCH v2] ixgbe: Fix for 82599 Bypass NIC, getting incorrect media type

2014-06-10 Thread Pablo de Lara
From: Pablo de Lara 

Function ixgbe_get_media_type_82599 returns media_type =
ixgbe_media_type_unknown, when using an 82599 Bypass NIC,
so that causes link status interrupt not to work properly.

change in v2: Fixed compilation error when RTE_NIC_BYPASS=n

Signed-off-by: Pablo de Lara 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.c
index db07789..7d9decd 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.c
@@ -436,6 +436,9 @@ enum ixgbe_media_type ixgbe_get_media_type_82599(struct 
ixgbe_hw *hw)
case IXGBE_DEV_ID_82599_SFP_SF2:
case IXGBE_DEV_ID_82599_SFP_SF_QP:
case IXGBE_DEV_ID_82599EN_SFP:
+#ifdef RTE_NIC_BYPASS 
+   case IXGBE_DEV_ID_82599_BYPASS:
+#endif
media_type = ixgbe_media_type_fiber;
break;
case IXGBE_DEV_ID_82599_CX4:
-- 
1.7.0.7



[dpdk-dev] [PATCH 2/2] eal_pci: Fix compilation under FreeBSD

2014-06-10 Thread Bruce Richardson
On Thu, Jun 05, 2014 at 05:12:08PM +0100, Alan Carew wrote:
> I'm not sure why this has not caused an issue before, perhaps
> missing -Werror=unused-parameter or super-set
> and subsequently fixed.
> This patch adds __rte_unused to
> pci_unbind_kernel_driver(struct rte_pci_device *dev)
> 
> Signed-off-by: Alan Carew 

Acked-by: Bruce Richardson 



[dpdk-dev] [PATCH 1/2] rte_tailq.h: Fix compilation under FreeBSD

2014-06-10 Thread Bruce Richardson
On Thu, Jun 05, 2014 at 05:12:07PM +0100, Alan Carew wrote:
> Recent change to rte_dump_tailq, which now uses a FILE parameter
> causes compilation to fail under FreeBSD and sourced to a
> missing include of stdio.h
> 
> This and next patch(both small) allows to compile without error.
> 
> Signed-off-by: Alan Carew 

Acked-by: Bruce Richardson 



[dpdk-dev] [PATCH 00/10] igb_uio patches

2014-06-10 Thread Carew, Alan
-Original Message-
From: Stephen Hemminger [mailto:step...@networkplumber.org] 
Sent: Tuesday, June 10, 2014 6:41 PM
To: Carew, Alan
Cc: dev at dpkd.org
Subject: Re: [PATCH 00/10] igb_uio patches

On Tue, 10 Jun 2014 15:33:31 +
"Carew, Alan"  wrote:

> Good catches and fixes in this set, would it be possible to refactor the 
> "enum igbuio_intr_mode" to a common header files as with 
> http://dpdk.org/ml/archives/dev/2014-June/003127.html

Actually, thought that was ugly. The userspace shouldn't have to see all these
definitions.

Not a big fan of doing this and it would go against goal of making a version
that could be merged upstream.

Stephen,

One alternative for us is then to take Neil Horman's idea of scanning 
/sys/bus/pci/devices//msi_irqs/
This gives us at least (MSI | MSI-X) | INT-X, however the Virtio specification 
mentions MSI-X explicitly for determining the correct offset and might not 
address the underlying problem my patch set was addressing, I have not tried 
Virtio with MSI.

A question then, how does uio_pci_generic handle interrupt modes in terms of 
userspace interface when determining the configured interrupt mode?

In the short term while we still work with igb_uio we may have to rely on 
SYSFS, but there is nothing stopping us from having device specific code paths 
that does not exclude us from ignoring igb_uio. The shared headers also gives 
us the benefit of having an internal interface(rte_pci_device: rte_intr_mode ) 
already in place when  swapping out kernel drivers, Anatoly's VFIO 
implementation already uses such an interface.

Thanks,
Alan


[dpdk-dev] [PATCH v4] mk: allow updates to build config on make install

2014-06-10 Thread Richardson, Bruce


> -Original Message-
> From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> Sent: Tuesday, June 10, 2014 9:38 AM
> To: dev at dpdk.org
> Cc: Richardson, Bruce
> Subject: [PATCH v4] mk: allow updates to build config on make install
> 
> From: Bruce Richardson 
> 
> When running "make config", an additional config.orig file is also
> generated, which is intended to hold the original, clean configuration
> from the template.
> When running make install, we first check if there is no existing
> .config file, and run make config if not. If there is a file, we then
> check if it's unmodified, in which case we regenerate a new .config to
> take account of any possible updates to the template. Finally, in the
> case where there is an existing .config file, and it HAS been modified,
> we then do a check to see if the template has had further updates, and
> throw an error if so. If no updates, we continue with the build using
> the existing, user-modified config.
> 
> Signed-off-by: Bruce Richardson 
> Signed-off-by: Thomas Monjalon 

Tested-by: Bruce Richardson 


[dpdk-dev] [PATCH v4] mk: allow updates to build config on make install

2014-06-10 Thread Thomas Monjalon
From: Bruce Richardson 

When running "make config", an additional config.orig file is also
generated, which is intended to hold the original, clean configuration
from the template.
When running make install, we first check if there is no existing
.config file, and run make config if not. If there is a file, we then
check if it's unmodified, in which case we regenerate a new .config to
take account of any possible updates to the template. Finally, in the
case where there is an existing .config file, and it HAS been modified,
we then do a check to see if the template has had further updates, and
throw an error if so. If no updates, we continue with the build using
the existing, user-modified config.

Signed-off-by: Bruce Richardson 
Signed-off-by: Thomas Monjalon 
---
 mk/rte.sdkconfig.mk  |  1 +
 mk/rte.sdkinstall.mk | 12 
 2 files changed, 13 insertions(+)

changes in v3:
- typos commented by Olivier
- compatibility with old builds without .orig
- prefix and suffix in tmp path
- remove tmp directory if no conflict

changes in v4:
- tmp directory in build directory
- do not remove tmp directory to speed up rebuild

diff --git a/mk/rte.sdkconfig.mk b/mk/rte.sdkconfig.mk
index d0692e7..3124dce 100644
--- a/mk/rte.sdkconfig.mk
+++ b/mk/rte.sdkconfig.mk
@@ -74,6 +74,7 @@ $(RTE_OUTPUT)/.config: $(RTE_CONFIG_TEMPLATE) FORCE
-o $(RTE_OUTPUT)/.config_tmp $(RTE_CONFIG_TEMPLATE) ; \
if ! cmp -s $(RTE_OUTPUT)/.config_tmp $(RTE_OUTPUT)/.config; 
then \
cp $(RTE_OUTPUT)/.config_tmp $(RTE_OUTPUT)/.config ; \
+   cp $(RTE_OUTPUT)/.config_tmp $(RTE_OUTPUT)/.config.orig 
; \
fi ; \
rm -f $(RTE_OUTPUT)/.config_tmp ; \
else \
diff --git a/mk/rte.sdkinstall.mk b/mk/rte.sdkinstall.mk
index 24b60cf..8571196 100644
--- a/mk/rte.sdkinstall.mk
+++ b/mk/rte.sdkinstall.mk
@@ -58,6 +58,18 @@ install: $(INSTALL_TARGETS)
@echo == Installing $*
$(Q)if [ ! -f $(BUILD_DIR)/$*/.config ]; then \
$(MAKE) config T=$* O=$(BUILD_DIR)/$*; \
+   elif cmp -s $(BUILD_DIR)/$*/.config.orig $(BUILD_DIR)/$*/.config; then \
+   $(MAKE) config T=$* O=$(BUILD_DIR)/$*; \
+   else \
+   if [ -f $(BUILD_DIR)/$*/.config.orig ] ; then \
+   tmp_build=$(BUILD_DIR)/$*/.config.tmp; \
+   $(MAKE) config T=$* O=$$tmp_build; \
+   if ! cmp -s $(BUILD_DIR)/$*/.config.orig 
$$tmp_build/.config ; then \
+   echo "Conflict: local config and template 
config have both changed"; \
+   exit 1; \
+   fi; \
+   fi; \
+   echo "Using local configuration"; \
fi
$(Q)$(MAKE) all O=$(BUILD_DIR)/$*

-- 
2.0.0



[dpdk-dev] [PATCH v3] mk: factorize config rules

2014-06-10 Thread Olivier MATZ
On 06/10/2014 04:39 PM, Thomas Monjalon wrote:
> Error message for missing template is factorized in notemplate rule.
>
> RTE_OUTPUT directory is marked as order-only prerequisite.
>
> RTE_OUTPUT is always created after having been cleaned for rte_config.h.
>
> Signed-off-by: Thomas Monjalon 

Acked-by Olivier Matz 



[dpdk-dev] [PATCH v3] mk: allow updates to build config on make install

2014-06-10 Thread Olivier MATZ
Hi Thomas,

On 06/10/2014 03:51 PM, Thomas Monjalon wrote:
> + if [ -f $(BUILD_DIR)/$*/.config.orig ] ; then \
> + tmp_build=/tmp/dpdk-$*-; \
> + $(MAKE) config T=$* O=$$(tmp_build); \
> + if ! cmp -s $(BUILD_DIR)/$*/.config.orig 
> $$(tmp_build)/.config ; then \
> + echo "Conflict: local config and template 
> config have both changed"; \
> + exit 1; \

I missed it the first time, but what do you think about using
$(BUILD_DIR)/$*/.config.tmp instead of /tmp/dpdk-$*-$$ ?
I think using /tmp should be avoided when possible as it is a
shared folder.

Regards,
Olivier



[dpdk-dev] sharing rte_malloc() address between processes.

2014-06-10 Thread Venkat Thummala
Hi,

You can refer section 20.3 [Multi-Process Limitations] in DPDK Programmer's
Guide.

It says,

? The multi-process feature requires that the exact same hugepage memory
mappings be present in all applications. The Linux security feature -
Address-Space
Layout Randomization (ASLR) can interfere with this mapping, so it may be
necessary to disable this feature in order to reliably run multi-process
applications.

Thanks
Venkat


On 10 June 2014 17:59, Venkat Thummala 
wrote:

> Hi,
>
> Yo
>
> ? The multi-process feature requires that the exact same hugepage memory
> mappings be present in all applications. The Linux security feature -
> Address-Space
> Layout Randomization (ASLR) can interfere with this mapping, so it may be
> necessary to disable this feature in order to reliably run multi-process
> applications.
>
>
> On 10 June 2014 17:17, Uri Sidler  wrote:
>
>> How can I share the addresses between processes?
>> Is there a simple way of doing so?
>>
>> thanks,
>> Shirley.
>>
>
>


[dpdk-dev] sharing rte_malloc() address between processes.

2014-06-10 Thread Venkat Thummala
Hi,

Yo

? The multi-process feature requires that the exact same hugepage memory
mappings be present in all applications. The Linux security feature -
Address-Space
Layout Randomization (ASLR) can interfere with this mapping, so it may be
necessary to disable this feature in order to reliably run multi-process
applications.


On 10 June 2014 17:17, Uri Sidler  wrote:

> How can I share the addresses between processes?
> Is there a simple way of doing so?
>
> thanks,
> Shirley.
>


[dpdk-dev] using hash table in a MP environment

2014-06-10 Thread Venkat Thummala
Hi Shirley,

Please refer the section 20.3 [Multi-Process Limitations] in DPDK
Programmers Guide.

The use of function pointers between multiple processes running based of
different
compiled binaries is not supported, since the location of a given function
in one
process may be different to its location in a second. This prevents the
librte_hash library from behaving properly as in a multi-threaded instance,
since it uses a pointer to the hash function internally.
To work around this issue, it is recommended that multi-process applications
perform the hash calculations by directly calling the hashing function from
the code
and then using the rte_hash_add_with_hash()/
rte_hash_lookup_with_hash() functions instead of the functions which do the
hashing internally, such as rte_hash_add()/rte_hash_lookup()

Thanks
Venkat


On 10 June 2014 17:05, Neil Horman  wrote:

> On Tue, Jun 10, 2014 at 11:02:03AM +0300, Uri Sidler wrote:
> > Hi,
> > I am currently using a hash table in a multi-process environment.
> > the master process creates the hash table which is later used by other
> > secondary processes.
> > but the secondary processes fail to use the hash table since the hash
> > function address actually points to a different fucntion. (this makes
> sense
> > since the address of the hash function is in fact different per process).
> > How can I solve this issue?
> >
> > Thanks,
> > Shirley.
> >
>
> Use shared memory.  see shmget
>
> Neil
>
>


[dpdk-dev] [PATCH 3/5] ethdev: add mtu accessors

2014-06-10 Thread Ananyev, Konstantin
Hi David,

>This patch adds two new functions in ethdev api to retrieve current MTU and
>change MTU of a port.
>These operations have been implemented for rte_em_pmd, rte_igb_pmd and
>rte_ixgbe_pmd.

>+
>+void ixgbe_dev_set_rx_scatter_mode(struct rte_eth_dev *dev)
>+{
>+  if (dev->rx_pkt_burst != ixgbe_recv_scattered_pkts) {
>+  dev->rx_pkt_burst = ixgbe_recv_scattered_pkts;
>+  /* we must ensure that this is done when we leave the
>+ function */
>+  rte_wmb();
>+  }
>+}

I don't think it is safe to change RX function on the fly (without calling 
dev_stop first).
If before that ixgbe_recv_pkts_bulk_alloc() was used, then up to 32 mbufs could 
be stored internally in the stage[],
and ixgbe_recv_scattered_pkts() doesn't have a clue about them.
Also with ixgbe_recv_pkts_bulk_alloc(), it could be up to rx_free_thresh RX 
descriptors not armed yet with proper buffer addresses,
while ixgbe_recv_scattered_pkts()  doesn't expect that - it re-arms RXD 
straight after it receives a packet from it.

I wonder is the ability to change mtu on the fly (without dev_stop) is really 
needed?
If so, then we probably can allow ixgbe_dev_set_mtu() to increase MTU only if
new frame size is less than RX buffer size OR that device already using  
ixgbe_recv_scattered_pkts().
Something like:
frame_size <= rx_buf_size || dev->rx_pkt_burst == ixgbe_recv_scattered_pkts


> +static int
>+ixgbe_dev_set_mtu(struct rte_eth_dev *dev, uint16_t *mtu)
>+{
>
>+
>+  /* switch to jumbo mode if needed */
>+  if (frame_size  > ETHER_MAX_LEN) {

Why ETHER_MAX_LEN?
If we have rx_buffer big enough, we don't need to split packets even for jumbo 
frames. 
Shouldn't it be something like inside ixgbe_dev_rx_init():
If (mtu + 2 * IXGBE_VLAN_TAG_SIZE) > rx_buf_size) {...

Same thing for igb.

Konstantin





[dpdk-dev] [PATCH v3] mk: factorize config rules

2014-06-10 Thread Thomas Monjalon
Error message for missing template is factorized in notemplate rule.

RTE_OUTPUT directory is marked as order-only prerequisite.

RTE_OUTPUT is always created after having been cleaned for rte_config.h.

Signed-off-by: Thomas Monjalon 
---
 mk/rte.sdkconfig.mk | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

change in v2:
- keep RTE_OUTPUT creation for rte_config.h
change in v3:
- quiet mkdir

diff --git a/mk/rte.sdkconfig.mk b/mk/rte.sdkconfig.mk
index 3124dce..14d8051 100644
--- a/mk/rte.sdkconfig.mk
+++ b/mk/rte.sdkconfig.mk
@@ -51,23 +51,28 @@ INSTALL_TARGETS := $(addsuffix _install,$(INSTALL_CONFIGS))
 showconfigs:
@$(foreach CONFIG, $(INSTALL_CONFIGS), echo $(CONFIG);)

-.PHONY: config
-ifeq ($(RTE_CONFIG_TEMPLATE),)
-config:
+.PHONY: notemplate
+notemplate:
@printf "No template specified. "
@echo "Use T=template among the following list:"
@$(MAKE) -rR showconfigs | sed 's,^,  ,'
+
+.PHONY: config
+ifeq ($(RTE_CONFIG_TEMPLATE),)
+config: notemplate
 else
 config: $(RTE_OUTPUT)/include/rte_config.h $(RTE_OUTPUT)/Makefile
$(Q)$(MAKE) depdirs
@echo "Configuration done"
 endif

+$(RTE_OUTPUT):
+   $(Q)mkdir -p $@
+
 ifdef NODOTCONF
 $(RTE_OUTPUT)/.config: ;
 else
-$(RTE_OUTPUT)/.config: $(RTE_CONFIG_TEMPLATE) FORCE
-   @[ -d $(RTE_OUTPUT) ] || mkdir -p $(RTE_OUTPUT)
+$(RTE_OUTPUT)/.config: $(RTE_CONFIG_TEMPLATE) FORCE | $(RTE_OUTPUT)
$(Q)if [ "$(RTE_CONFIG_TEMPLATE)" != "" -a -f "$(RTE_CONFIG_TEMPLATE)" 
]; then \
$(CPP) -undef -P -x assembler-with-cpp \
-fdirectives-only -ffreestanding \
@@ -78,11 +83,7 @@ $(RTE_OUTPUT)/.config: $(RTE_CONFIG_TEMPLATE) FORCE
fi ; \
rm -f $(RTE_OUTPUT)/.config_tmp ; \
else \
-   echo -n "No template specified. Use T=template " ; \
-   echo "among the following list:" ; \
-   for t in $(INSTALL_CONFIGS); do \
-   echo "  $$t" ; \
-   done ; \
+   $(MAKE) -rRf $(RTE_SDK)/mk/rte.sdkconfig.mk notemplate; \
fi
 endif

@@ -92,8 +93,7 @@ SDK_RELPATH=$(shell $(RTE_SDK)/scripts/relpath.sh $(abspath 
$(RTE_SRCDIR)) \
$(abspath $(RTE_OUTPUT)))
 OUTPUT_RELPATH=$(shell $(RTE_SDK)/scripts/relpath.sh $(abspath $(RTE_OUTPUT)) \
$(abspath $(RTE_SRCDIR)))
-$(RTE_OUTPUT)/Makefile:
-   @[ -d $(RTE_OUTPUT) ] || mkdir -p $(RTE_OUTPUT)
+$(RTE_OUTPUT)/Makefile: | $(RTE_OUTPUT)
$(Q)$(RTE_SDK)/scripts/gen-build-mk.sh $(SDK_RELPATH) $(OUTPUT_RELPATH) 
\
> $(RTE_OUTPUT)/Makefile

@@ -103,7 +103,7 @@ $(RTE_OUTPUT)/include/rte_config.h: $(RTE_OUTPUT)/.config
$(Q)rm -rf $(RTE_OUTPUT)/include $(RTE_OUTPUT)/app \
$(RTE_OUTPUT)/hostapp $(RTE_OUTPUT)/lib \
$(RTE_OUTPUT)/hostlib $(RTE_OUTPUT)/kmod $(RTE_OUTPUT)/build
-   @[ -d $(RTE_OUTPUT)/include ] || mkdir -p $(RTE_OUTPUT)/include
+   $(Q)mkdir -p $(RTE_OUTPUT)/include
$(Q)$(RTE_SDK)/scripts/gen-config-h.sh $(RTE_OUTPUT)/.config \
> $(RTE_OUTPUT)/include/rte_config.h

-- 
2.0.0



[dpdk-dev] [PATCH v3] mk: allow updates to build config on make install

2014-06-10 Thread Richardson, Bruce
Yes, good point. I'll try and redraft a v3 of the patch (thanks Thomas for 
doing a V2), with that in it. I also think if we keep everything in the build 
dir we should not the rm afterwards. [In my previous tests when doing V1 patch, 
I found that deleting the directory each time seemed to slow things down for 
the next run. I'll test if that is still the case when doing V3]

> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Olivier MATZ
> Sent: Tuesday, June 10, 2014 9:03 AM
> To: Thomas Monjalon; dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v3] mk: allow updates to build config on make
> install
> 
> Hi Thomas,
> 
> On 06/10/2014 03:51 PM, Thomas Monjalon wrote:
> > +   if [ -f $(BUILD_DIR)/$*/.config.orig ] ; then \
> > +   tmp_build=/tmp/dpdk-$*-; \
> > +   $(MAKE) config T=$* O=$$(tmp_build); \
> > +   if ! cmp -s $(BUILD_DIR)/$*/.config.orig
> $$(tmp_build)/.config ; then \
> > +   echo "Conflict: local config and template
> config have both changed"; \
> > +   exit 1; \
> 
> I missed it the first time, but what do you think about using
> $(BUILD_DIR)/$*/.config.tmp instead of /tmp/dpdk-$*-$$ ?
> I think using /tmp should be avoided when possible as it is a
> shared folder.
> 
> Regards,
> Olivier



[dpdk-dev] [PATCH] ixgbe: Fix for 82599 Bypass NIC, getting incorrect media type

2014-06-10 Thread Pablo de Lara
From: Pablo de Lara 

Function ixgbe_get_media_type_82599 returns media_type =
ixgbe_media_type_unknown, when using an 82599 Bypass NIC,
so that causes link status interrupt not to work properly.

Signed-off-by: Pablo de Lara 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.c
index db07789..e230a5b 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.c
@@ -436,6 +436,7 @@ enum ixgbe_media_type ixgbe_get_media_type_82599(struct 
ixgbe_hw *hw)
case IXGBE_DEV_ID_82599_SFP_SF2:
case IXGBE_DEV_ID_82599_SFP_SF_QP:
case IXGBE_DEV_ID_82599EN_SFP:
+   case IXGBE_DEV_ID_82599_BYPASS:
media_type = ixgbe_media_type_fiber;
break;
case IXGBE_DEV_ID_82599_CX4:
-- 
1.7.0.7



[dpdk-dev] [PATCH 00/10] igb_uio patches

2014-06-10 Thread Burakov, Anatoly
> These apply to the current DPDK tree, and are an alternative to the patches
> from Alan. It provides indication of IRQ mode via sysfs attribute. They 
> include
> cleanups and fixes to allow use of MSI and do proper fallback for the case
> where MSI-X vectors are exhausted.
> 
> Hi Stephen,
> 
> Good catches and fixes in this set, would it be possible to refactor the "enum
> igbuio_intr_mode" to a common header files as with
> http://dpdk.org/ml/archives/dev/2014-June/003127.html
> With that infrastructure in place, I could resubmit my set {2,3,4} to work
> cleanly with yours, maintaining the same interface across user/kernel,
> FreeBSD and fixing Virtio also.

...or better yet, with

http://dpdk.org/ml/archives/dev/2014-June/003221.html

:-)

Best regards,
Anatoly Burakov
DPDK SW Engineer





[dpdk-dev] [PATCH v2] mk: factorize config rules

2014-06-10 Thread Thomas Monjalon
Error message for missing template is factorized in notemplate rule.

RTE_OUTPUT directory is marked as order-only prerequisite.

RTE_OUTPUT is always created after having been cleaned for rte_config.h.

Signed-off-by: Thomas Monjalon 
---
 mk/rte.sdkconfig.mk | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

changes in v2:
- keep RTE_OUTPUT creation for rte_config.h

diff --git a/mk/rte.sdkconfig.mk b/mk/rte.sdkconfig.mk
index 3124dce..26bd611 100644
--- a/mk/rte.sdkconfig.mk
+++ b/mk/rte.sdkconfig.mk
@@ -51,23 +51,28 @@ INSTALL_TARGETS := $(addsuffix _install,$(INSTALL_CONFIGS))
 showconfigs:
@$(foreach CONFIG, $(INSTALL_CONFIGS), echo $(CONFIG);)

-.PHONY: config
-ifeq ($(RTE_CONFIG_TEMPLATE),)
-config:
+.PHONY: notemplate
+notemplate:
@printf "No template specified. "
@echo "Use T=template among the following list:"
@$(MAKE) -rR showconfigs | sed 's,^,  ,'
+
+.PHONY: config
+ifeq ($(RTE_CONFIG_TEMPLATE),)
+config: notemplate
 else
 config: $(RTE_OUTPUT)/include/rte_config.h $(RTE_OUTPUT)/Makefile
$(Q)$(MAKE) depdirs
@echo "Configuration done"
 endif

+$(RTE_OUTPUT):
+   mkdir -p $@
+
 ifdef NODOTCONF
 $(RTE_OUTPUT)/.config: ;
 else
-$(RTE_OUTPUT)/.config: $(RTE_CONFIG_TEMPLATE) FORCE
-   @[ -d $(RTE_OUTPUT) ] || mkdir -p $(RTE_OUTPUT)
+$(RTE_OUTPUT)/.config: $(RTE_CONFIG_TEMPLATE) FORCE | $(RTE_OUTPUT)
$(Q)if [ "$(RTE_CONFIG_TEMPLATE)" != "" -a -f "$(RTE_CONFIG_TEMPLATE)" 
]; then \
$(CPP) -undef -P -x assembler-with-cpp \
-fdirectives-only -ffreestanding \
@@ -78,11 +83,7 @@ $(RTE_OUTPUT)/.config: $(RTE_CONFIG_TEMPLATE) FORCE
fi ; \
rm -f $(RTE_OUTPUT)/.config_tmp ; \
else \
-   echo -n "No template specified. Use T=template " ; \
-   echo "among the following list:" ; \
-   for t in $(INSTALL_CONFIGS); do \
-   echo "  $$t" ; \
-   done ; \
+   $(MAKE) -rRf $(RTE_SDK)/mk/rte.sdkconfig.mk notemplate; \
fi
 endif

@@ -92,8 +93,7 @@ SDK_RELPATH=$(shell $(RTE_SDK)/scripts/relpath.sh $(abspath 
$(RTE_SRCDIR)) \
$(abspath $(RTE_OUTPUT)))
 OUTPUT_RELPATH=$(shell $(RTE_SDK)/scripts/relpath.sh $(abspath $(RTE_OUTPUT)) \
$(abspath $(RTE_SRCDIR)))
-$(RTE_OUTPUT)/Makefile:
-   @[ -d $(RTE_OUTPUT) ] || mkdir -p $(RTE_OUTPUT)
+$(RTE_OUTPUT)/Makefile: | $(RTE_OUTPUT)
$(Q)$(RTE_SDK)/scripts/gen-build-mk.sh $(SDK_RELPATH) $(OUTPUT_RELPATH) 
\
> $(RTE_OUTPUT)/Makefile

@@ -103,7 +103,7 @@ $(RTE_OUTPUT)/include/rte_config.h: $(RTE_OUTPUT)/.config
$(Q)rm -rf $(RTE_OUTPUT)/include $(RTE_OUTPUT)/app \
$(RTE_OUTPUT)/hostapp $(RTE_OUTPUT)/lib \
$(RTE_OUTPUT)/hostlib $(RTE_OUTPUT)/kmod $(RTE_OUTPUT)/build
-   @[ -d $(RTE_OUTPUT)/include ] || mkdir -p $(RTE_OUTPUT)/include
+   $(Q)mkdir -p $(RTE_OUTPUT)/include
$(Q)$(RTE_SDK)/scripts/gen-config-h.sh $(RTE_OUTPUT)/.config \
> $(RTE_OUTPUT)/include/rte_config.h

-- 
2.0.0



[dpdk-dev] [PATCH 00/10] igb_uio patches

2014-06-10 Thread Carew, Alan

-Original Message-
From: Stephen Hemminger [mailto:step...@networkplumber.org] 
Sent: Friday, June 06, 2014 10:27 PM
To: Carew, Alan
Cc: dev at dpkd.org
Subject: [PATCH 00/10] igb_uio patches

These apply to the current DPDK tree, and are an alternative to
the patches from Alan. It provides indication of IRQ mode via
sysfs attribute. They include cleanups and fixes to allow use
of MSI and do proper fallback for the case where MSI-X vectors
are exhausted.

Hi Stephen,

Good catches and fixes in this set, would it be possible to refactor the "enum 
igbuio_intr_mode" to a common header files as with 
http://dpdk.org/ml/archives/dev/2014-June/003127.html
With that infrastructure in place, I could resubmit my set {2,3,4} to work 
cleanly with yours, maintaining the same interface across user/kernel, FreeBSD 
and fixing Virtio also.

Regards,
Alan


[dpdk-dev] [PATCH] mk: factorize config rules

2014-06-10 Thread Thomas Monjalon
Error message for missing template is factorized in notemplate rule.

RTE_OUTPUT directory is marked as order-only prerequisite.

Signed-off-by: Thomas Monjalon 
---
 mk/rte.sdkconfig.mk | 25 -
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/mk/rte.sdkconfig.mk b/mk/rte.sdkconfig.mk
index 3124dce..d35b83a 100644
--- a/mk/rte.sdkconfig.mk
+++ b/mk/rte.sdkconfig.mk
@@ -51,23 +51,28 @@ INSTALL_TARGETS := $(addsuffix _install,$(INSTALL_CONFIGS))
 showconfigs:
@$(foreach CONFIG, $(INSTALL_CONFIGS), echo $(CONFIG);)

-.PHONY: config
-ifeq ($(RTE_CONFIG_TEMPLATE),)
-config:
+.PHONY: notemplate
+notemplate:
@printf "No template specified. "
@echo "Use T=template among the following list:"
@$(MAKE) -rR showconfigs | sed 's,^,  ,'
+
+.PHONY: config
+ifeq ($(RTE_CONFIG_TEMPLATE),)
+config: notemplate
 else
 config: $(RTE_OUTPUT)/include/rte_config.h $(RTE_OUTPUT)/Makefile
$(Q)$(MAKE) depdirs
@echo "Configuration done"
 endif

+$(RTE_OUTPUT):
+   mkdir -p $@
+
 ifdef NODOTCONF
 $(RTE_OUTPUT)/.config: ;
 else
-$(RTE_OUTPUT)/.config: $(RTE_CONFIG_TEMPLATE) FORCE
-   @[ -d $(RTE_OUTPUT) ] || mkdir -p $(RTE_OUTPUT)
+$(RTE_OUTPUT)/.config: $(RTE_CONFIG_TEMPLATE) FORCE | $(RTE_OUTPUT)
$(Q)if [ "$(RTE_CONFIG_TEMPLATE)" != "" -a -f "$(RTE_CONFIG_TEMPLATE)" 
]; then \
$(CPP) -undef -P -x assembler-with-cpp \
-fdirectives-only -ffreestanding \
@@ -78,11 +83,7 @@ $(RTE_OUTPUT)/.config: $(RTE_CONFIG_TEMPLATE) FORCE
fi ; \
rm -f $(RTE_OUTPUT)/.config_tmp ; \
else \
-   echo -n "No template specified. Use T=template " ; \
-   echo "among the following list:" ; \
-   for t in $(INSTALL_CONFIGS); do \
-   echo "  $$t" ; \
-   done ; \
+   $(MAKE) -rRf $(RTE_SDK)/mk/rte.sdkconfig.mk notemplate; \
fi
 endif

@@ -92,8 +93,7 @@ SDK_RELPATH=$(shell $(RTE_SDK)/scripts/relpath.sh $(abspath 
$(RTE_SRCDIR)) \
$(abspath $(RTE_OUTPUT)))
 OUTPUT_RELPATH=$(shell $(RTE_SDK)/scripts/relpath.sh $(abspath $(RTE_OUTPUT)) \
$(abspath $(RTE_SRCDIR)))
-$(RTE_OUTPUT)/Makefile:
-   @[ -d $(RTE_OUTPUT) ] || mkdir -p $(RTE_OUTPUT)
+$(RTE_OUTPUT)/Makefile: | $(RTE_OUTPUT)
$(Q)$(RTE_SDK)/scripts/gen-build-mk.sh $(SDK_RELPATH) $(OUTPUT_RELPATH) 
\
> $(RTE_OUTPUT)/Makefile

@@ -103,7 +103,6 @@ $(RTE_OUTPUT)/include/rte_config.h: $(RTE_OUTPUT)/.config
$(Q)rm -rf $(RTE_OUTPUT)/include $(RTE_OUTPUT)/app \
$(RTE_OUTPUT)/hostapp $(RTE_OUTPUT)/lib \
$(RTE_OUTPUT)/hostlib $(RTE_OUTPUT)/kmod $(RTE_OUTPUT)/build
-   @[ -d $(RTE_OUTPUT)/include ] || mkdir -p $(RTE_OUTPUT)/include
$(Q)$(RTE_SDK)/scripts/gen-config-h.sh $(RTE_OUTPUT)/.config \
> $(RTE_OUTPUT)/include/rte_config.h

-- 
2.0.0



[dpdk-dev] [PATCH v3] mk: allow updates to build config on make install

2014-06-10 Thread Thomas Monjalon
From: Bruce Richardson 

When running "make config", an additional config.orig file is also
generated, which is intended to hold the original, clean configuration
from the template.
When running make install, we first check if there is no existing
.config file, and run make config if not. If there is a file, we then
check if it's unmodified, in which case we regenerate a new .config to
take account of any possible updates to the template. Finally, in the
case where there is an existing .config file, and it HAS been modified,
we then do a check to see if the template has had further updates, and
throw an error if so. If no updates, we continue with the build using
the existing, user-modified config.

Signed-off-by: Bruce Richardson 
Signed-off-by: Thomas Monjalon 
---
 mk/rte.sdkconfig.mk  |  1 +
 mk/rte.sdkinstall.mk | 13 +
 2 files changed, 14 insertions(+)

changes in v3:
- typos commented by Olivier
- compatibility with old builds without .orig
- prefix and suffix in tmp path
- remove tmp directory if no conflict

diff --git a/mk/rte.sdkconfig.mk b/mk/rte.sdkconfig.mk
index d0692e7..3124dce 100644
--- a/mk/rte.sdkconfig.mk
+++ b/mk/rte.sdkconfig.mk
@@ -74,6 +74,7 @@ $(RTE_OUTPUT)/.config: $(RTE_CONFIG_TEMPLATE) FORCE
-o $(RTE_OUTPUT)/.config_tmp $(RTE_CONFIG_TEMPLATE) ; \
if ! cmp -s $(RTE_OUTPUT)/.config_tmp $(RTE_OUTPUT)/.config; 
then \
cp $(RTE_OUTPUT)/.config_tmp $(RTE_OUTPUT)/.config ; \
+   cp $(RTE_OUTPUT)/.config_tmp $(RTE_OUTPUT)/.config.orig 
; \
fi ; \
rm -f $(RTE_OUTPUT)/.config_tmp ; \
else \
diff --git a/mk/rte.sdkinstall.mk b/mk/rte.sdkinstall.mk
index 24b60cf..28eb662 100644
--- a/mk/rte.sdkinstall.mk
+++ b/mk/rte.sdkinstall.mk
@@ -58,6 +58,19 @@ install: $(INSTALL_TARGETS)
@echo == Installing $*
$(Q)if [ ! -f $(BUILD_DIR)/$*/.config ]; then \
$(MAKE) config T=$* O=$(BUILD_DIR)/$*; \
+   elif cmp -s $(BUILD_DIR)/$*/.config.orig $(BUILD_DIR)/$*/.config; then \
+   $(MAKE) config T=$* O=$(BUILD_DIR)/$*; \
+   else \
+   if [ -f $(BUILD_DIR)/$*/.config.orig ] ; then \
+   tmp_build=/tmp/dpdk-$*-; \
+   $(MAKE) config T=$* O=$$(tmp_build); \
+   if ! cmp -s $(BUILD_DIR)/$*/.config.orig 
$$(tmp_build)/.config ; then \
+   echo "Conflict: local config and template 
config have both changed"; \
+   exit 1; \
+   fi; \
+   rm -rf $$(tmp_build); \
+   fi; \
+   echo "Using local configuration"; \
fi
$(Q)$(MAKE) all O=$(BUILD_DIR)/$*

-- 
2.0.0



[dpdk-dev] using rte_malloc() in a secondary process.

2014-06-10 Thread Uri Sidler
Hi,
I have 2 processes without fork().
can the secondary process use rte_malloc()?
is there a limitation for using rte_malloc on a secondary process?
do I have to allocate a memzone in order to use the rte_malloc()?

Thanks.


[dpdk-dev] [PATCH] kni: fix compile errors on Oracle Linux6.4 and RHEL6.5

2014-06-10 Thread Zhang, Helin
Hi Thomas

Were you talking about the "#ifndef ether_addr_equal "?
The compile errors I copied in that patch shows that the function has already 
been defined in include/linux/etherdevice.h on Oracle Linux6.4. In this case, 
it seems not always true as you said.
The method came from the standard Linux driver, so I think it should be useful 
and has been reviewed by Linux kernel community.

Oops, it seems that there are useless code which I need to remove. I will 
update it later! Thank you very much for the pointing!

Regards,
Helin

-Original Message-
From: Thomas Monjalon [mailto:thomas.monja...@6wind.com] 
Sent: Tuesday, June 10, 2014 6:03 PM
To: Zhang, Helin
Cc: dev at dpdk.org
Subject: Re: [dpdk-dev] [PATCH] kni: fix compile errors on Oracle Linux6.4 and 
RHEL6.5

Hi Helin,

2014-06-09 16:38, Helin Zhang:
>  #if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0) )  #define 
> skb_tx_timestamp(skb) do {} while (0) -#if !(RHEL_RELEASE_CODE && 
> RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,4)) -static inline bool 
> ether_addr_equal(const u8 *addr1, const u8 *addr2)
> +#ifndef ether_addr_equal

It should be always true as it is a function (not known by the preprocessor).

> +static inline bool __kc_ether_addr_equal(const u8 *addr1, const u8 
> +*addr2)
>  {
>   return !compare_ether_addr(addr1, addr2);  } -#endif
> +#define ether_addr_equal(_addr1, _addr2) 
> +__kc_ether_addr_equal((_addr1),(_addr2))
> +#endif /* __kc_ether_addr_equal*/

So it is always replacing ether_addr_equal() by a kcompat equivalent for old 
kernels, even if ether_addr_equal() is already defined as a C function.
Just to confirm: is it really what we want?

[...]
> -#endif
> +#define ethtool_adv_to_mmd_eee_adv_t(adv) \
> +__kc_ethtool_adv_to_mmd_eee_adv_t(adv)

An indentation is missing here.

> +#endif /* ethtool_adv_to_mmd_eee_adv_t */ #endif /* */

Why an empty comment?

Thanks
--
Thomas


[dpdk-dev] sharing rte_malloc() address between processes.

2014-06-10 Thread Uri Sidler
How can I share the addresses between processes?
Is there a simple way of doing so?

thanks,
Shirley.


[dpdk-dev] [PATCH] add link state control driver flag

2014-06-10 Thread Stephen Hemminger
Only some devices support the link state interrupt configuration option.
Link state control does not work in virtual drivers
(virtio, vmxnet3, igbvf, and ixgbevf). Instead of having the application
try and guess whether it will work or not provide a driver flag that
can be checked instead.

Note: if device driver doesn't support link state control, what
would happen previously is that the code would never detect link
transitions. This prevents that.

Signed-off-by: Stephen Hemminger 

---
 lib/librte_eal/common/include/rte_pci.h |2 ++
 lib/librte_ether/rte_ethdev.c   |   14 ++
 lib/librte_pmd_e1000/em_ethdev.c|2 +-
 lib/librte_pmd_e1000/igb_ethdev.c   |2 +-
 lib/librte_pmd_ixgbe/ixgbe_ethdev.c |2 +-
 5 files changed, 19 insertions(+), 3 deletions(-)

--- a/lib/librte_eal/common/include/rte_pci.h   2014-06-10 13:52:10.446532658 
-0700
+++ b/lib/librte_eal/common/include/rte_pci.h   2014-06-10 13:54:18.667854409 
-0700
@@ -196,6 +196,8 @@ struct rte_pci_driver {
 #define RTE_PCI_DRV_MULTIPLE 0x0002
 /** Device needs to be unbound even if no module is provided */
 #define RTE_PCI_DRV_FORCE_UNBIND 0x0004
+/** Device driver supports link state interrupt */
+#define RTE_PCI_DRV_LSC0x0008

 /**< Internal use only - Macro used by pci addr parsing functions **/
 #define GET_PCIADDR_FIELD(in, fd, lim, dlm)   \
--- a/lib/librte_pmd_e1000/em_ethdev.c  2014-06-10 13:52:10.446532658 -0700
+++ b/lib/librte_pmd_e1000/em_ethdev.c  2014-06-10 13:53:19.963254573 -0700
@@ -280,7 +280,7 @@ static struct eth_driver rte_em_pmd = {
{
.name = "rte_em_pmd",
.id_table = pci_id_em_map,
-   .drv_flags = RTE_PCI_DRV_NEED_IGB_UIO,
+   .drv_flags = RTE_PCI_DRV_NEED_IGB_UIO | RTE_PCI_DRV_LSC,
},
.eth_dev_init = eth_em_dev_init,
.dev_private_size = sizeof(struct e1000_adapter),
--- a/lib/librte_pmd_e1000/igb_ethdev.c 2014-06-10 13:52:10.446532658 -0700
+++ b/lib/librte_pmd_e1000/igb_ethdev.c 2014-06-10 13:52:57.023017751 -0700
@@ -603,7 +603,7 @@ static struct eth_driver rte_igb_pmd = {
{
.name = "rte_igb_pmd",
.id_table = pci_id_igb_map,
-   .drv_flags = RTE_PCI_DRV_NEED_IGB_UIO,
+   .drv_flags = RTE_PCI_DRV_NEED_IGB_UIO | RTE_PCI_DRV_LSC,
},
.eth_dev_init = eth_igb_dev_init,
.dev_private_size = sizeof(struct e1000_adapter),
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c   2014-06-10 13:52:10.446532658 
-0700
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c   2014-06-10 13:53:52.307586153 
-0700
@@ -999,7 +999,7 @@ static struct eth_driver rte_ixgbe_pmd =
{
.name = "rte_ixgbe_pmd",
.id_table = pci_id_ixgbe_map,
-   .drv_flags = RTE_PCI_DRV_NEED_IGB_UIO,
+   .drv_flags = RTE_PCI_DRV_NEED_IGB_UIO | RTE_PCI_DRV_LSC,
},
.eth_dev_init = eth_ixgbe_dev_init,
.dev_private_size = sizeof(struct ixgbe_adapter),
--- a/lib/librte_ether/rte_ethdev.c 2014-06-10 13:52:10.446532658 -0700
+++ b/lib/librte_ether/rte_ethdev.c 2014-06-10 13:52:10.426532446 -0700
@@ -636,6 +636,20 @@ rte_eth_dev_configure(uint8_t port_id, u
memcpy(>data->dev_conf, dev_conf, sizeof(dev->data->dev_conf));

/*
+* If link state interrupt is enabled, check that the
+* device supports it.
+*/
+   if (dev_conf->intr_conf.lsc == 1) {
+   const struct rte_pci_driver *pci_drv = >driver->pci_drv;
+
+   if (!(pci_drv->drv_flags & RTE_PCI_DRV_LSC)) {
+   PMD_DEBUG_TRACE("driver %s does not support lsc\n",
+   pci_drv->name);
+   return (-EINVAL);
+   }
+   }
+
+   /*
 * If jumbo frames are enabled, check that the maximum RX packet
 * length is supported by the configured device.
 */


[dpdk-dev] [PATCH 00/10] igb_uio patches

2014-06-10 Thread Stephen Hemminger
On Tue, 10 Jun 2014 19:26:08 +
"Carew, Alan"  wrote:

> A question then, how does uio_pci_generic handle interrupt modes in terms of 
> userspace interface when determining the configured interrupt mode?

uio_pci_generic only handles INTX disable, and nothing else. It doesn't do MSI
or allow IRQ control.

Also, it doesn't do iomap of resources, so theoretically if IOMMU is enabled
userspace would still not be able to access the resources.



[dpdk-dev] [PATCH] mk: fix link with gcc

2014-06-10 Thread Thomas Monjalon
2014-06-02 09:40, Olivier MATZ:
> Hi Thomas,
> 
> On 05/29/2014 08:48 AM, Thomas Monjalon wrote:
> > You're right, title should be:
> > mk: fix 32-bit link with gcc
> >
> > And I should add some details in the commit log:
> >
> > I didn't see any error with -z muldefs but it isn't documented in gcc 
> > manual.
> > So it's safer to explicitly pass it to the linker.
> >
> > The variable CPU_LDFLAGS contains "-melf_i386" in 32-bit configurations. So
> > building 32-bit shared library raises this error:
> > gcc: error: unrecognized command line option ?-melf_i386?
> >
> > Olivier, I'll make these changes if you (or Neil) ack the patch.
> 
> Acked-by: Olivier Matz 

Applied for version 1.7.0.

-- 
Thomas


[dpdk-dev] [PATCH] fix for eth_pcap_tx() can cause mbuf corruption

2014-06-10 Thread Thomas Monjalon
> If pcap_sendpacket() fails, then eth_pcap_tx shouldn't silently free that
> mbuf and continue.
> 
> Signed-off-by: Konstantin Ananyev 

Acked-by: Pablo de Lara Guarch 
Tested-by: Waterman Cao 

Applied for version 1.7.0.

Thanks
-- 
Thomas


[dpdk-dev] [PATCH v5 19/20] binding script: Renamed igb_uio_bind to dpdk_nic_bind

2014-06-10 Thread Anatoly Burakov
Renaming the igb_uio_bind script to dpdk_nic_bind to have a generic name
since we're now supporting two drivers.

Signed-off-by: Anatoly Burakov 
---
 tools/{igb_uio_bind.py => dpdk_nic_bind.py} | 47 -
 tools/setup.sh  | 16 +-
 2 files changed, 40 insertions(+), 23 deletions(-)
 rename tools/{igb_uio_bind.py => dpdk_nic_bind.py} (92%)

diff --git a/tools/igb_uio_bind.py b/tools/dpdk_nic_bind.py
similarity index 92%
rename from tools/igb_uio_bind.py
rename to tools/dpdk_nic_bind.py
index 33adcf4..1e517e7 100755
--- a/tools/igb_uio_bind.py
+++ b/tools/dpdk_nic_bind.py
@@ -42,6 +42,8 @@ ETHERNET_CLASS = "0200"
 # global dict ethernet devices present. Dictionary indexed by PCI address.
 # Each device within this is itself a dictionary of device properties
 devices = {}
+# list of supported DPDK drivers
+dpdk_drivers = [ "igb_uio", "vfio-pci" ]

 def usage():
 '''Print usage information for the program'''
@@ -146,22 +148,33 @@ def find_module(mod):

 def check_modules():
 '''Checks that igb_uio is loaded'''
+global dpdk_drivers

 fd = file("/proc/modules")
 loaded_mods = fd.readlines()
 fd.close()
-mod = "igb_uio"
+
+# list of supported modules
+mods =  [{"Name" : driver, "Found" : False} for driver in dpdk_drivers]

 # first check if module is loaded
-found = False
 for line in loaded_mods:
-if line.startswith(mod):
-found = True
-break
-if not found:
-print "Error - module %s not loaded" %mod
+for mod in mods:
+if line.startswith(mod["Name"]):
+mod["Found"] = True
+# special case for vfio_pci (module is named vfio-pci,
+# but its .ko is named vfio_pci)
+elif line.replace("_", "-").startswith(mod["Name"]):
+mod["Found"] = True
+
+# check if we have at least one loaded module
+if True not in [mod["Found"] for mod in mods]:
+print "Error - no supported modules are loaded"
 sys.exit(1)

+# change DPDK driver list to only contain drivers that are loaded
+dpdk_drivers = [mod["Name"] for mod in mods if mod["Found"]]
+
 def has_driver(dev_id):
 '''return true if a device is assigned to a driver. False otherwise'''
 return "Driver_str" in devices[dev_id]
@@ -196,6 +209,7 @@ def get_nic_details():
 the pci addresses (domain:bus:slot.func). The values are themselves
 dictionaries - one for each NIC.'''
 global devices
+global dpdk_drivers

 # clear any old data
 devices = {} 
@@ -240,10 +254,11 @@ def get_nic_details():

 # add igb_uio to list of supporting modules if needed
 if "Module_str" in devices[d]:
-if "igb_uio" not in devices[d]["Module_str"]:
-devices[d]["Module_str"] = devices[d]["Module_str"] + 
",igb_uio"
+for driver in dpdk_drivers:
+if driver not in devices[d]["Module_str"]:
+devices[d]["Module_str"] = devices[d]["Module_str"] + 
",%s" % driver
 else:
-devices[d]["Module_str"] = "igb_uio"
+devices[d]["Module_str"] = ",".join(dpdk_drivers)

 # make sure the driver and module strings do not have any duplicates
 if has_driver(d):
@@ -320,7 +335,7 @@ def bind_one(dev_id, driver, force):
 dev["Driver_str"] = "" # clear driver string

 # if we are binding to one of DPDK drivers, add PCI id's to that driver
-if driver == "igb_uio":
+if driver in dpdk_drivers:
 filename = "/sys/bus/pci/drivers/%s/new_id" % driver
 try:
 f = open(filename, "w")
@@ -397,21 +412,23 @@ def show_status():
 '''Function called when the script is passed the "--status" option. 
Displays
 to the user what devices are bound to the igb_uio driver, the kernel driver
 or to no driver'''
+global dpdk_drivers
 kernel_drv = []
-uio_drv = []
+dpdk_drv = []
 no_drv = []
+
 # split our list of devices into the three categories above
 for d in devices.keys():
 if not has_driver(d):
 no_drv.append(devices[d])
 continue
-if devices[d]["Driver_str"] == "igb_uio":
-uio_drv.append(devices[d])
+if devices[d]["Driver_str"] in dpdk_drivers:
+dpdk_drv.append(devices[d])
 else:
 kernel_drv.append(devices[d])

 # print each category separately, so we can clearly see what's used by DPDK
-display_devices("Network devices using IGB_UIO driver", uio_drv, \
+display_devices("Network devices using DPDK-compatible driver", dpdk_drv, \
 "drv=%(Driver_str)s unused=%(Module_str)s")
 display_devices("Network devices using kernel driver", kernel_drv,
 "if=%(Interface)s drv=%(Driver_str)s unused=%(Module_str)s 
%(Active)s")
diff --git a/tools/setup.sh b/tools/setup.sh
index 39be8fc..e0671b8 100755

[dpdk-dev] [PATCH v5 18/20] igb_uio: Removed PCI ID table from igb_uio

2014-06-10 Thread Anatoly Burakov
Removing PCI ID list to make igb_uio more similar to a generic driver
like vfio-pci or pci_uio_generic. This is done to make it easier for
the binding script to support multiple drivers.

Note that since igb_uio no longer has a PCI ID list, it can now be
bound to any device, not just those explicitly supported by DPDK. In
other words, it now behaves similar to PCI stub, VFIO and other generic
PCI drivers.

Therefore to bind a new device to igb_uio, the user will now have to
first write its PCI ID to "new_id" file inside the igb_uio driver
directory, and only then write the PCI ID to "bind". This is reflected
in changes to PCI binding script as well.

There's a weird behaviour of sysfs when a new device ID is added to
new_id. Subsequent writing to "bind" will result in IOError on
closing the file. This error is harmless but it triggers the
exception anyway, so in order to work around that, we check if the
device was actually bound to the driver before raising an error.

Signed-off-by: Anatoly Burakov 
---
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c |  21 +-
 tools/igb_uio_bind.py | 118 +++---
 2 files changed, 59 insertions(+), 80 deletions(-)

diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c 
b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
index 7d5e6b4..6362b1c 100644
--- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
+++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
@@ -65,25 +65,6 @@ struct rte_uio_pci_dev {
 static char *intr_mode = NULL;
 static enum rte_intr_mode igbuio_intr_mode_preferred = RTE_INTR_MODE_MSIX;

-/* PCI device id table */
-static struct pci_device_id igbuio_pci_ids[] = {
-#define RTE_PCI_DEV_ID_DECL_EM(vend, dev) {PCI_DEVICE(vend, dev)},
-#define RTE_PCI_DEV_ID_DECL_IGB(vend, dev) {PCI_DEVICE(vend, dev)},
-#define RTE_PCI_DEV_ID_DECL_IGBVF(vend, dev) {PCI_DEVICE(vend, dev)},
-#define RTE_PCI_DEV_ID_DECL_IXGBE(vend, dev) {PCI_DEVICE(vend, dev)},
-#define RTE_PCI_DEV_ID_DECL_IXGBEVF(vend, dev) {PCI_DEVICE(vend, dev)},
-#ifdef RTE_LIBRTE_VIRTIO_PMD
-#define RTE_PCI_DEV_ID_DECL_VIRTIO(vend, dev) {PCI_DEVICE(vend, dev)},
-#endif
-#ifdef RTE_LIBRTE_VMXNET3_PMD
-#define RTE_PCI_DEV_ID_DECL_VMXNET3(vend, dev) {PCI_DEVICE(vend, dev)},
-#endif
-#include 
-{ 0, },
-};
-
-MODULE_DEVICE_TABLE(pci, igbuio_pci_ids);
-
 static inline struct rte_uio_pci_dev *
 igbuio_get_uio_pci_dev(struct uio_info *info)
 {
@@ -619,7 +600,7 @@ igbuio_config_intr_mode(char *intr_str)

 static struct pci_driver igbuio_pci_driver = {
.name = "igb_uio",
-   .id_table = igbuio_pci_ids,
+   .id_table = NULL,
.probe = igbuio_pci_probe,
.remove = igbuio_pci_remove,
 };
diff --git a/tools/igb_uio_bind.py b/tools/igb_uio_bind.py
index 824aa2b..33adcf4 100755
--- a/tools/igb_uio_bind.py
+++ b/tools/igb_uio_bind.py
@@ -42,8 +42,6 @@ ETHERNET_CLASS = "0200"
 # global dict ethernet devices present. Dictionary indexed by PCI address.
 # Each device within this is itself a dictionary of device properties
 devices = {}
-# list of vendor:device pairs (again stored as dictionary) supported by igb_uio
-module_dev_ids = []

 def usage():
 '''Print usage information for the program'''
@@ -147,9 +145,7 @@ def find_module(mod):
 return path

 def check_modules():
-'''Checks that the needed modules (igb_uio) is loaded, and then
-determine from the .ko file, what its supported device ids are'''
-global module_dev_ids
+'''Checks that igb_uio is loaded'''

 fd = file("/proc/modules")
 loaded_mods = fd.readlines()
@@ -165,41 +161,36 @@ def check_modules():
 if not found:
 print "Error - module %s not loaded" %mod
 sys.exit(1)
-
-# now find the .ko and get list of supported vendor/dev-ids
-modpath = find_module(mod)
-if modpath is None:
-print "Cannot find module file %s" % (mod + ".ko")
-sys.exit(1)
-depmod_output = check_output(["depmod", "-n", modpath]).splitlines()
-for line in depmod_output:
-if not line.startswith("alias"):
-continue
-if not line.endswith(mod):
-continue
-lineparts = line.split()
-if not(lineparts[1].startswith("pci:")):
-continue;
-else:
-lineparts[1] = lineparts[1][4:]
-vendor = lineparts[1][:9]
-device = lineparts[1][9:18]
-if vendor.startswith("v") and device.startswith("d"):
-module_dev_ids.append({"Vendor": int(vendor[1:],16), 
-   "Device": int(device[1:],16)})
-
-def is_supported_device(dev_id):
-'''return true if device is supported by igb_uio, false otherwise'''
-for dev in module_dev_ids:
-if (dev["Vendor"] == devices[dev_id]["Vendor"] and 
-dev["Device"] == devices[dev_id]["Device"]):
-return True
-return False

 def has_driver(dev_id):
 '''return true if a device is assigned to a driver. False otherwise'''
 return "Driver_str" 

[dpdk-dev] [PATCH v5 17/20] test app: adding unit tests for VFIO EAL command-line parameter

2014-06-10 Thread Anatoly Burakov
Adding unit tests for VFIO interrupt type command-line parameter. We
don't know if VFIO is compiled (eal_vfio.h header is internal to
Linuxapp EAL), so we check this flag regardless.

Signed-off-by: Anatoly Burakov 
---
 app/test/test_eal_flags.c | 36 
 1 file changed, 36 insertions(+)

diff --git a/app/test/test_eal_flags.c b/app/test/test_eal_flags.c
index 195a1f5..a0ee4e6 100644
--- a/app/test/test_eal_flags.c
+++ b/app/test/test_eal_flags.c
@@ -768,6 +768,22 @@ test_misc_flags(void)
const char *argv11[] = {prgname, "--file-prefix=virtaddr",
"-c", "1", "-n", "2", "--base-virtaddr=0x12345678"};

+   /* try running with --vfio-intr INTx flag */
+   const char *argv12[] = {prgname, "--file-prefix=intr",
+   "-c", "1", "-n", "2", "--vfio-intr=legacy"};
+
+   /* try running with --vfio-intr MSI flag */
+   const char *argv13[] = {prgname, "--file-prefix=intr",
+   "-c", "1", "-n", "2", "--vfio-intr=msi"};
+
+   /* try running with --vfio-intr MSI-X flag */
+   const char *argv14[] = {prgname, "--file-prefix=intr",
+   "-c", "1", "-n", "2", "--vfio-intr=msix"};
+
+   /* try running with --vfio-intr invalid flag */
+   const char *argv15[] = {prgname, "--file-prefix=intr",
+   "-c", "1", "-n", "2", "--vfio-intr=invalid"};
+

if (launch_proc(argv0) == 0) {
printf("Error - process ran ok with invalid flag\n");
@@ -820,6 +836,26 @@ test_misc_flags(void)
printf("Error - process did not run ok with --base-virtaddr 
parameter\n");
return -1;
}
+   if (launch_proc(argv12) != 0) {
+   printf("Error - process did not run ok with "
+   "--vfio-intr INTx parameter\n");
+   return -1;
+   }
+   if (launch_proc(argv13) != 0) {
+   printf("Error - process did not run ok with "
+   "--vfio-intr MSI parameter\n");
+   return -1;
+   }
+   if (launch_proc(argv14) != 0) {
+   printf("Error - process did not run ok with "
+   "--vfio-intr MSI-X parameter\n");
+   return -1;
+   }
+   if (launch_proc(argv15) == 0) {
+   printf("Error - process run ok with "
+   "--vfio-intr invalid parameter\n");
+   return -1;
+   }
return 0;
 }
 #endif
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 16/20] eal: make --no-huge use mmap instead of malloc

2014-06-10 Thread Anatoly Burakov
This makes it possible to run DPDK without hugepage memory when VFIO
is used, as VFIO uses virtual addresses to set up DMA mappings.

Technically, malloc is just fine, but we want to guarantee that
memory will be page-aligned, so using mmap to be safe.

Signed-off-by: Anatoly Burakov 
---
 lib/librte_eal/linuxapp/eal/eal_memory.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c 
b/lib/librte_eal/linuxapp/eal/eal_memory.c
index 8d1edd9..315214b 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -1031,7 +1031,13 @@ rte_eal_hugepage_init(void)

/* hugetlbfs can be disabled */
if (internal_config.no_hugetlbfs) {
-   addr = malloc(internal_config.memory);
+   addr = mmap(NULL, internal_config.memory, PROT_READ | 
PROT_WRITE,
+   MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
+   if (addr == MAP_FAILED) {
+   RTE_LOG(ERR, EAL, "%s: mmap() failed: %s\n", __func__,
+   strerror(errno));
+   return -1;
+   }
mcfg->memseg[0].phys_addr = (phys_addr_t)(uintptr_t)addr;
mcfg->memseg[0].addr = addr;
mcfg->memseg[0].len = internal_config.memory;
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 15/20] eal: added support for selecting VFIO interrupt type from EAL command-line

2014-06-10 Thread Anatoly Burakov
Unlike igb_uio, VFIO interrupt type is not set by kernel module
parameters but is set up via ioctl() calls at runtime. This warrants
a new EAL command-line parameter. It will have no effect if VFIO is
not compiled, but will set VFIO interrupt type to either "legacy", "msi"
or "msix" if VFIO support is compiled. Note that VFIO initialization
will fail if the interrupt type selected is not supported by the system.

If the interrupt type parameter wasn't specified, VFIO will try all
interrupt types (starting with MSI-X).

Signed-off-by: Anatoly Burakov 
---
 lib/librte_eal/linuxapp/eal/eal.c | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
b/lib/librte_eal/linuxapp/eal/eal.c
index aeb5903..10c40fa 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -99,6 +99,7 @@
 #define OPT_BASE_VIRTADDR   "base-virtaddr"
 #define OPT_XEN_DOM0"xen-dom0"
 #define OPT_CREATE_UIO_DEV "create-uio-dev"
+#define OPT_VFIO_INTR"vfio-intr"

 #define RTE_EAL_BLACKLIST_SIZE 0x100

@@ -361,6 +362,8 @@ eal_usage(const char *prgname)
   "  --"OPT_VMWARE_TSC_MAP": use VMware TSC map instead of "
   "native RDTSC\n"
   "  --"OPT_BASE_VIRTADDR": specify base virtual address\n"
+  "  --"OPT_VFIO_INTR": specify desired interrupt mode for VFIO "
+  "(legacy|msi|msix)\n"
   "  --"OPT_CREATE_UIO_DEV": create /dev/uioX (usually done by 
hotplug)\n"
   "\nEAL options for DEBUG use only:\n"
   "  --"OPT_NO_HUGE"  : use malloc instead of hugetlbfs\n"
@@ -579,6 +582,28 @@ eal_parse_base_virtaddr(const char *arg)
return 0;
 }

+static int
+eal_parse_vfio_intr(const char *mode)
+{
+   unsigned i;
+   static struct {
+   const char *name;
+   enum rte_intr_mode value;
+   } map[] = {
+   { "legacy", RTE_INTR_MODE_LEGACY },
+   { "msi", RTE_INTR_MODE_MSI },
+   { "msix", RTE_INTR_MODE_MSIX },
+   };
+
+   for (i = 0; i < RTE_DIM(map); i++) {
+   if (!strcmp(mode, map[i].name)) {
+   internal_config.vfio_intr_mode = map[i].value;
+   return 0;
+   }
+   }
+   return -1;
+}
+
 static inline size_t
 eal_get_hugepage_mem_size(void)
 {
@@ -633,6 +658,7 @@ eal_parse_args(int argc, char **argv)
{OPT_PCI_BLACKLIST, 1, 0, 0},
{OPT_VDEV, 1, 0, 0},
{OPT_SYSLOG, 1, NULL, 0},
+   {OPT_VFIO_INTR, 1, NULL, 0},
{OPT_BASE_VIRTADDR, 1, 0, 0},
{OPT_XEN_DOM0, 0, 0, 0},
{OPT_CREATE_UIO_DEV, 1, NULL, 0},
@@ -829,6 +855,14 @@ eal_parse_args(int argc, char **argv)
return -1;
}
}
+   else if (!strcmp(lgopts[option_index].name, 
OPT_VFIO_INTR)) {
+   if (eal_parse_vfio_intr(optarg) < 0) {
+   RTE_LOG(ERR, EAL, "invalid parameters 
for --"
+   OPT_VFIO_INTR "\n");
+   eal_usage(prgname);
+   return -1;
+   }
+   }
else if (!strcmp(lgopts[option_index].name, 
OPT_CREATE_UIO_DEV)) {
internal_config.create_uio_dev = 1;
}
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 14/20] pci: enable VFIO device binding

2014-06-10 Thread Anatoly Burakov
Add support for binding VFIO devices if RTE_PCI_DRV_NEED_MAPPING is set
for this driver. Try VFIO first, if not mapped then try IGB_UIO too.

Signed-off-by: Anatoly Burakov 
---
 lib/librte_eal/linuxapp/eal/eal_pci.c | 42 ---
 1 file changed, 39 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index a0abec8..8a9cbf9 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -393,6 +393,27 @@ error:
return -1;
 }

+static int
+pci_map_device(struct rte_pci_device *dev)
+{
+   int ret, mapped = 0;
+
+   /* try mapping the NIC resources using VFIO if it exists */
+#ifdef VFIO_PRESENT
+   if (pci_vfio_is_enabled()) {
+   if ((ret = pci_vfio_map_resource(dev)) == 0)
+   mapped = 1;
+   else if (ret < 0)
+   return ret;
+   }
+#endif
+   /* map resources for devices that use igb_uio */
+   if (!mapped && (ret = pci_uio_map_resource(dev)) != 0)
+   return ret;
+
+   return 0;
+}
+
 /*
  * If vendor/device ID match, call the devinit() function of the
  * driver.
@@ -400,8 +421,8 @@ error:
 int
 rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device 
*dev)
 {
+   int ret;
struct rte_pci_id *id_table;
-   int ret = 0;

for (id_table = dr->id_table ; id_table->vendor_id != 0; id_table++) {

@@ -436,8 +457,7 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, 
struct rte_pci_device *d
}

if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {
-   /* map resources for devices that use igb_uio */
-   if ((ret = pci_uio_map_resource(dev)) != 0)
+   if ((ret = pci_map_device(dev)) != 0)
return ret;
} else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND &&
   rte_eal_process_type() == RTE_PROC_PRIMARY) {
@@ -473,5 +493,21 @@ rte_eal_pci_init(void)
RTE_LOG(ERR, EAL, "%s(): Cannot scan PCI bus\n", __func__);
return -1;
}
+#ifdef VFIO_PRESENT
+   pci_vfio_enable();
+
+   if (pci_vfio_is_enabled()) {
+
+   /* if we are primary process, create a thread to communicate 
with
+* secondary processes. the thread will use a socket to wait for
+* requests from secondary process to send open file 
descriptors,
+* because VFIO does not allow multiple open descriptors on a 
group or
+* VFIO container.
+*/
+   if (internal_config.process_type == RTE_PROC_PRIMARY &&
+   pci_vfio_mp_sync_setup() < 0)
+   return -1;
+   }
+#endif
return 0;
 }
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 13/20] vfio: add multiprocess support.

2014-06-10 Thread Anatoly Burakov
Since VFIO cannot be used to map the same device twice, secondary
processes receive the device/group fd's by means of communicating over a
local socket. Only group and container fd's should be sent, as device
fd's can be obtained via ioctl() calls' on the group fd.

For multiprocess, VFIO distinguishes between existing but unused groups
(e.g. grups that aren't bound to VFIO driver) and non-existing groups in
order to know if the secondary process requests a valid group, or if
secondary process requests something that doesn't exist.

VFIO multiprocess sync communicates over a simple protocol. It defines
two requests - request for group fd, and request for container fd.
Possible replies are: SOCKET_OK (an OK signal), SOCKET_ERR (error
signal) and SOCKET_NO_FD (a signal that indicates that the requested
VFIO group is valid, but no fd is present for that group - indicating
that the respective group is simply not bound to VFIO driver).

Here is the logic in a nutshell:

1. secondary process sends SOCKET_REQ_CONTAINER or SOCKET_REQ_GROUP
1a. in case of SOCKET_REQ_GROUP, client also then sends group number
2. primary process receives message
2a. in case of invalid group, SOCKET_ERR is sent back to secondary
2b. in case of unbound group, SOCKET_NO_FD is sent back to secondary
2c. in case of valid group, SOCKET_OK is sent and followed by fd
3. socket is closed

in case of any error, socket is closed and SOCKET_ERR is sent.

Signed-off-by: Anatoly Burakov 
---
 lib/librte_eal/linuxapp/eal/Makefile   |   1 +
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c |  79 -
 lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c | 395 +
 lib/librte_eal/linuxapp/eal/include/eal_pci_init.h |  19 +
 4 files changed, 492 insertions(+), 2 deletions(-)
 create mode 100644 lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c

diff --git a/lib/librte_eal/linuxapp/eal/Makefile 
b/lib/librte_eal/linuxapp/eal/Makefile
index cf9f026..3c05edf 100644
--- a/lib/librte_eal/linuxapp/eal/Makefile
+++ b/lib/librte_eal/linuxapp/eal/Makefile
@@ -59,6 +59,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_log.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_pci.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_pci_uio.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_pci_vfio.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_pci_vfio_mp_sync.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_debug.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_lcore.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_timer.c
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c 
b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
index e1d6973..f0d4f55 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
@@ -303,7 +303,7 @@ pci_vfio_setup_interrupts(struct rte_pci_device *dev, int 
vfio_dev_fd)
 }

 /* open container fd or get an existing one */
-static int
+int
 pci_vfio_get_container_fd(void)
 {
int ret, vfio_container_fd;
@@ -333,13 +333,36 @@ pci_vfio_get_container_fd(void)
}

return vfio_container_fd;
+   } else {
+   /*
+* if we're in a secondary process, request container fd from 
the
+* primary process via our socket
+*/
+   int socket_fd;
+   if ((socket_fd = vfio_mp_sync_connect_to_primary()) < 0) {
+   RTE_LOG(ERR, EAL, "  cannot connect to primary 
process!\n");
+   return -1;
+   }
+   if (vfio_mp_sync_send_request(socket_fd, SOCKET_REQ_CONTAINER) 
< 0) {
+   RTE_LOG(ERR, EAL, "  cannot request container fd!\n");
+   close(socket_fd);
+   return -1;
+   }
+   vfio_container_fd = vfio_mp_sync_receive_fd(socket_fd);
+   if (vfio_container_fd < 0) {
+   RTE_LOG(ERR, EAL, "  cannot get container fd!\n");
+   close(socket_fd);
+   return -1;
+   }
+   close(socket_fd);
+   return vfio_container_fd;
}

return -1;
 }

 /* open group fd or get an existing one */
-static int
+int
 pci_vfio_get_group_fd(int iommu_group_no)
 {
int i;
@@ -375,6 +398,44 @@ pci_vfio_get_group_fd(int iommu_group_no)
vfio_cfg.vfio_groups[vfio_cfg.vfio_group_idx].fd = 
vfio_group_fd;
return vfio_group_fd;
}
+   /* if we're in a secondary process, request group fd from the primary
+* process via our socket
+*/
+   else {
+   int socket_fd, ret;
+   if ((socket_fd = vfio_mp_sync_connect_to_primary()) < 0) {
+   RTE_LOG(ERR, EAL, "  cannot connect to primary 
process!\n");
+   return -1;
+   }
+   if (vfio_mp_sync_send_request(socket_fd, SOCKET_REQ_GROUP) < 0) 
{
+  

[dpdk-dev] [PATCH v5 12/20] vfio: create mapping code for VFIO

2014-06-10 Thread Anatoly Burakov
Adding code to support VFIO mapping (primary processes only). Most of
the things are done via ioctl() calls on either /dev/vfio/vfio (the
container) or a /dev/vfio/$GROUP_NR (IOMMU group).

In a nutshell, the code does the following:
1. creates a VFIO container (an entity that allows sharing IOMMU DMA
   mappings between devices)
2. checks if a given PCI device is a member of an IOMMU group (if it's
   not, this indicates that the device isn't bound to VFIO)
3. calls open() the group file to obtain a group fd
4. checks if the group is viable (that is, if all the devices in the
   same IOMMU group are either bound to VFIO or not bound to anything)
5. adds the group to a container
6. sets up DMA mappings (only done once, mapping whole DPDK hugepage
   memory for DMA, with a 1:1 correspondence of IOVA to PA)
7. gets the actual PCI device fd from the group fd (can fail, which
   simply means that this particular device is not bound to VFIO)
8. maps BARs (MSI-X BAR cannot be mmaped, so skipping it)
9. sets up interrupt structures (but not enables them!)
10. enables PCI bus mastering

Signed-off-by: Anatoly Burakov 
---
 lib/librte_eal/linuxapp/eal/Makefile   |   2 +
 lib/librte_eal/linuxapp/eal/eal.c  |   2 +
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 706 +
 .../linuxapp/eal/include/eal_internal_cfg.h|   3 +
 lib/librte_eal/linuxapp/eal/include/eal_pci_init.h |  31 +
 lib/librte_eal/linuxapp/eal/include/eal_vfio.h |   6 +
 6 files changed, 750 insertions(+)
 create mode 100644 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c

diff --git a/lib/librte_eal/linuxapp/eal/Makefile 
b/lib/librte_eal/linuxapp/eal/Makefile
index 5f3be5f..cf9f026 100644
--- a/lib/librte_eal/linuxapp/eal/Makefile
+++ b/lib/librte_eal/linuxapp/eal/Makefile
@@ -58,6 +58,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_thread.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_log.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_pci.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_pci_uio.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_pci_vfio.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_debug.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_lcore.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_timer.c
@@ -87,6 +88,7 @@ CFLAGS_eal_log.o := -D_GNU_SOURCE
 CFLAGS_eal_common_log.o := -D_GNU_SOURCE
 CFLAGS_eal_hugepage_info.o := -D_GNU_SOURCE
 CFLAGS_eal_pci.o := -D_GNU_SOURCE
+CFLAGS_eal_pci_vfio.o := -D_GNU_SOURCE
 CFLAGS_eal_common_whitelist.o := -D_GNU_SOURCE

 # workaround for a gcc bug with noreturn attribute
diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
b/lib/librte_eal/linuxapp/eal/eal.c
index 9d2675b..aeb5903 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -650,6 +650,8 @@ eal_parse_args(int argc, char **argv)
internal_config.force_sockets = 0;
internal_config.syslog_facility = LOG_DAEMON;
internal_config.xen_dom0_support = 0;
+   /* if set to NONE, interrupt mode is determined automatically */
+   internal_config.vfio_intr_mode = RTE_INTR_MODE_NONE;
 #ifdef RTE_LIBEAL_USE_HPET
internal_config.no_hpet = 0;
 #else
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c 
b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
new file mode 100644
index 000..e1d6973
--- /dev/null
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
@@ -0,0 +1,706 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2014 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
+ *   

[dpdk-dev] [PATCH v5 11/20] eal: remove -Wno-return-type for non-existent eal_hpet.c

2014-06-10 Thread Anatoly Burakov
eal_hpet.c was renamed to eal_timer.c and, thanks to code changes, does
not need the -Wno-return-type any more.

Signed-off-by: Anatoly Burakov 
---
 lib/librte_eal/linuxapp/eal/Makefile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/eal/Makefile 
b/lib/librte_eal/linuxapp/eal/Makefile
index d958014..5f3be5f 100644
--- a/lib/librte_eal/linuxapp/eal/Makefile
+++ b/lib/librte_eal/linuxapp/eal/Makefile
@@ -93,7 +93,6 @@ CFLAGS_eal_common_whitelist.o := -D_GNU_SOURCE
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
 ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
 CFLAGS_eal_thread.o += -Wno-return-type
-CFLAGS_eal_hpet.o += -Wno-return-type
 endif

 INC := rte_per_lcore.h rte_lcore.h rte_interrupts.h rte_kni_common.h 
rte_dom0_common.h
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 10/20] interrupts: Add support for VFIO interrupts

2014-06-10 Thread Anatoly Burakov
Creating code to handle VFIO interrupts in EAL interrupts (supports all
types of interrupts).

Signed-off-by: Anatoly Burakov 
---
 lib/librte_eal/linuxapp/eal/eal_interrupts.c   | 287 -
 .../linuxapp/eal/include/exec-env/rte_interrupts.h |   4 +
 2 files changed, 286 insertions(+), 5 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c 
b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
index 58e1ddf..664e522 100644
--- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c
+++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
@@ -36,7 +36,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -44,6 +43,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -66,6 +66,7 @@
 #include 

 #include "eal_private.h"
+#include "eal_vfio.h"

 #define EAL_INTR_EPOLL_WAIT_FOREVER (-1)

@@ -87,6 +88,9 @@ union intr_pipefds{
  */
 union rte_intr_read_buffer {
int uio_intr_count;  /* for uio device */
+#ifdef VFIO_PRESENT
+   uint64_t vfio_intr_count;/* for vfio device */
+#endif
uint64_t timerfd_num;/* for timerfd */
char charbuf[16];/* for others */
 };
@@ -119,6 +123,244 @@ static struct rte_intr_source_list intr_sources;
 /* interrupt handling thread */
 static pthread_t intr_thread;

+/* VFIO interrupts */
+#ifdef VFIO_PRESENT
+
+#define IRQ_SET_BUF_LEN  (sizeof(struct vfio_irq_set) + sizeof(int))
+
+/* enable legacy (INTx) interrupts */
+static int
+vfio_enable_intx(struct rte_intr_handle *intr_handle) {
+   struct vfio_irq_set *irq_set;
+   char irq_set_buf[IRQ_SET_BUF_LEN];
+   int len, ret;
+   int *fd_ptr;
+
+   len = sizeof(irq_set_buf);
+
+   /* enable INTx */
+   irq_set = (struct vfio_irq_set *) irq_set_buf;
+   irq_set->argsz = len;
+   irq_set->count = 1;
+   irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | 
VFIO_IRQ_SET_ACTION_TRIGGER;
+   irq_set->index = VFIO_PCI_INTX_IRQ_INDEX;
+   irq_set->start = 0;
+   fd_ptr = (int *) _set->data;
+   *fd_ptr = intr_handle->fd;
+
+   ret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
+
+   if (ret) {
+   RTE_LOG(ERR, EAL, "Error enabling INTx interrupts for fd %d\n",
+   intr_handle->fd);
+   return -1;
+   }
+
+   /* unmask INTx after enabling */
+   memset(irq_set, 0, len);
+   len = sizeof(struct vfio_irq_set);
+   irq_set->argsz = len;
+   irq_set->count = 1;
+   irq_set->flags = VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_ACTION_UNMASK;
+   irq_set->index = VFIO_PCI_INTX_IRQ_INDEX;
+   irq_set->start = 0;
+
+   ret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
+
+   if (ret) {
+   RTE_LOG(ERR, EAL, "Error unmasking INTx interrupts for fd %d\n",
+   intr_handle->fd);
+   return -1;
+   }
+   return 0;
+}
+
+/* disable legacy (INTx) interrupts */
+static int
+vfio_disable_intx(struct rte_intr_handle *intr_handle) {
+   struct vfio_irq_set *irq_set;
+   char irq_set_buf[IRQ_SET_BUF_LEN];
+   int len, ret;
+
+   len = sizeof(struct vfio_irq_set);
+
+   /* mask interrupts before disabling */
+   irq_set = (struct vfio_irq_set *) irq_set_buf;
+   irq_set->argsz = len;
+   irq_set->count = 1;
+   irq_set->flags = VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_ACTION_UNMASK;
+   irq_set->index = VFIO_PCI_INTX_IRQ_INDEX;
+   irq_set->start = 0;
+
+   ret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
+
+   if (ret) {
+   RTE_LOG(ERR, EAL, "Error unmasking INTx interrupts for fd %d\n",
+   intr_handle->fd);
+   return -1;
+   }
+
+   /* disable INTx*/
+   memset(irq_set, 0, len);
+   irq_set->argsz = len;
+   irq_set->count = 0;
+   irq_set->flags = VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_ACTION_TRIGGER;
+   irq_set->index = VFIO_PCI_INTX_IRQ_INDEX;
+   irq_set->start = 0;
+
+   ret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
+
+   if (ret) {
+   RTE_LOG(ERR, EAL,
+   "Error disabling INTx interrupts for fd %d\n", 
intr_handle->fd);
+   return -1;
+   }
+   return 0;
+}
+
+/* enable MSI-X interrupts */
+static int
+vfio_enable_msi(struct rte_intr_handle *intr_handle) {
+   int len, ret;
+   char irq_set_buf[IRQ_SET_BUF_LEN];
+   struct vfio_irq_set *irq_set;
+   int *fd_ptr;
+
+   len = sizeof(irq_set_buf);
+
+   irq_set = (struct vfio_irq_set *) irq_set_buf;
+   irq_set->argsz = len;
+   irq_set->count = 1;
+   irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | 
VFIO_IRQ_SET_ACTION_TRIGGER;
+   irq_set->index = VFIO_PCI_MSI_IRQ_INDEX;
+   irq_set->start = 0;
+  

[dpdk-dev] [PATCH v5 09/20] vfio: add VFIO header

2014-06-10 Thread Anatoly Burakov
Adding a header that will determine if VFIO support should be compiled
in. If VFIO is enabled in config (and it's enabled by default), then the
header will also check for kernel version. If VFIO is enabled in config
and if the kernel version is 3.6+, then VFIO_PRESENT will be defined.
This is the macro that should be used to determine if VFIO support is
being compiled in.

Signed-off-by: Anatoly Burakov 
---
 lib/librte_eal/linuxapp/eal/include/eal_vfio.h | 49 ++
 1 file changed, 49 insertions(+)
 create mode 100644 lib/librte_eal/linuxapp/eal/include/eal_vfio.h

diff --git a/lib/librte_eal/linuxapp/eal/include/eal_vfio.h 
b/lib/librte_eal/linuxapp/eal/include/eal_vfio.h
new file mode 100644
index 000..354e9ca
--- /dev/null
+++ b/lib/librte_eal/linuxapp/eal/include/eal_vfio.h
@@ -0,0 +1,49 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2014 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.
+ */
+
+#ifndef EAL_VFIO_H_
+#define EAL_VFIO_H_
+
+/*
+ * determine if VFIO is present on the system
+ */
+#ifdef RTE_EAL_VFIO
+#include 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
+#include 
+
+#define VFIO_PRESENT
+#endif /* kernel version */
+#endif /* RTE_EAL_VFIO */
+
+#endif /* EAL_VFIO_H_ */
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 08/20] vfio: add support for VFIO in Linuxapp targets

2014-06-10 Thread Anatoly Burakov
Add VFIO compilation option to common Linuxapp config.

Signed-off-by: Anatoly Burakov 
---
 config/common_linuxapp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/config/common_linuxapp b/config/common_linuxapp
index b17e37e..2ed4b7e 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -124,6 +124,7 @@ CONFIG_RTE_LIBEAL_USE_HPET=n
 CONFIG_RTE_EAL_ALLOW_INV_SOCKET_ID=n
 CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n
 CONFIG_RTE_EAL_IGB_UIO=y
+CONFIG_RTE_EAL_VFIO=y

 #
 # Compile Environment Abstraction Layer for linux
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 07/20] igb_uio: Moved interrupt type out of igb_uio

2014-06-10 Thread Anatoly Burakov
Moving interrupt type enum out of igb_uio and renaming it to be more
generic. Such a strange header naming and separation is done mostly to
make coming virtio patches easier to port to dpdk.org tree.

Signed-off-by: Anatoly Burakov 
---
 lib/librte_eal/common/Makefile |  1 +
 lib/librte_eal/common/include/rte_pci.h|  1 +
 .../common/include/rte_pci_dev_feature_defs.h  | 46 +
 .../common/include/rte_pci_dev_features.h  | 44 
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c  | 48 +-
 5 files changed, 112 insertions(+), 28 deletions(-)
 create mode 100644 lib/librte_eal/common/include/rte_pci_dev_feature_defs.h
 create mode 100644 lib/librte_eal/common/include/rte_pci_dev_features.h

diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile
index 0016fc5..e2a3f3a 100644
--- a/lib/librte_eal/common/Makefile
+++ b/lib/librte_eal/common/Makefile
@@ -39,6 +39,7 @@ INC += rte_rwlock.h rte_spinlock.h rte_tailq.h 
rte_interrupts.h rte_alarm.h
 INC += rte_string_fns.h rte_cpuflags.h rte_version.h rte_tailq_elem.h
 INC += rte_eal_memconfig.h rte_malloc_heap.h
 INC += rte_hexdump.h rte_devargs.h rte_dev.h
+INC += rte_pci_dev_feature_defs.h rte_pci_dev_features.h

 ifeq ($(CONFIG_RTE_INSECURE_FUNCTION_WARNING),y)
 INC += rte_warnings.h
diff --git a/lib/librte_eal/common/include/rte_pci.h 
b/lib/librte_eal/common/include/rte_pci.h
index 11b8c13..e653027 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -80,6 +80,7 @@ extern "C" {
 #include 
 #include 
 #include 
+
 #include 

 TAILQ_HEAD(pci_device_list, rte_pci_device); /**< PCI devices in D-linked Q. */
diff --git a/lib/librte_eal/common/include/rte_pci_dev_feature_defs.h 
b/lib/librte_eal/common/include/rte_pci_dev_feature_defs.h
new file mode 100644
index 000..82f2c00
--- /dev/null
+++ b/lib/librte_eal/common/include/rte_pci_dev_feature_defs.h
@@ -0,0 +1,46 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2014 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.
+ */
+
+#ifndef _RTE_PCI_DEV_DEFS_H_
+#define _RTE_PCI_DEV_DEFS_H_
+
+/* interrupt mode */
+enum rte_intr_mode {
+   RTE_INTR_MODE_NONE = 0,
+   RTE_INTR_MODE_LEGACY,
+   RTE_INTR_MODE_MSI,
+   RTE_INTR_MODE_MSIX,
+   RTE_INTR_MODE_MAX
+};
+
+#endif /* _RTE_PCI_DEV_DEFS_H_ */
diff --git a/lib/librte_eal/common/include/rte_pci_dev_features.h 
b/lib/librte_eal/common/include/rte_pci_dev_features.h
new file mode 100644
index 000..01200de
--- /dev/null
+++ b/lib/librte_eal/common/include/rte_pci_dev_features.h
@@ -0,0 +1,44 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2014 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 

[dpdk-dev] [PATCH v5 06/20] igb_uio: make igb_uio compilation optional

2014-06-10 Thread Anatoly Burakov
Currently, igb_uio is always compiled. Some Linux distributions may not
want to include igb_uio with DPDK, so we need to make sure that igb_uio
compilation for Linuxapp targets can be optional.

Signed-off-by: Anatoly Burakov 
---
 config/common_linuxapp   | 1 +
 lib/librte_eal/linuxapp/Makefile | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/config/common_linuxapp b/config/common_linuxapp
index 62619c6..b17e37e 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -123,6 +123,7 @@ CONFIG_RTE_LOG_HISTORY=256
 CONFIG_RTE_LIBEAL_USE_HPET=n
 CONFIG_RTE_EAL_ALLOW_INV_SOCKET_ID=n
 CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n
+CONFIG_RTE_EAL_IGB_UIO=y

 #
 # Compile Environment Abstraction Layer for linux
diff --git a/lib/librte_eal/linuxapp/Makefile b/lib/librte_eal/linuxapp/Makefile
index b00e89f..acbf500 100644
--- a/lib/librte_eal/linuxapp/Makefile
+++ b/lib/librte_eal/linuxapp/Makefile
@@ -31,7 +31,9 @@

 include $(RTE_SDK)/mk/rte.vars.mk

+ifeq ($(CONFIG_RTE_EAL_IGB_UIO),y)
 DIRS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += igb_uio
+endif
 DIRS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal
 ifeq ($(CONFIG_RTE_LIBRTE_KNI),y)
 DIRS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += kni
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 05/20] pci: Rename RTE_PCI_DRV_NEED_IGB_UIO to RTE_PCI_DRV_NEED_MAPPING

2014-06-10 Thread Anatoly Burakov
Rename the RTE_PCI_DRV_NEED_IGB_UIO to be more generic.

Signed-off-by: Anatoly Burakov 
---
 app/test/test_pci.c | 4 ++--
 lib/librte_eal/bsdapp/eal/eal_pci.c | 2 +-
 lib/librte_eal/common/include/rte_pci.h | 4 ++--
 lib/librte_eal/linuxapp/eal/eal_pci.c   | 2 +-
 lib/librte_pmd_e1000/em_ethdev.c| 2 +-
 lib/librte_pmd_e1000/igb_ethdev.c   | 4 ++--
 lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 4 ++--
 lib/librte_pmd_virtio/virtio_ethdev.c   | 2 +-
 lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c | 2 +-
 9 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/app/test/test_pci.c b/app/test/test_pci.c
index 6908d04..fad118e 100644
--- a/app/test/test_pci.c
+++ b/app/test/test_pci.c
@@ -63,7 +63,7 @@ static int my_driver_init(struct rte_pci_driver *dr,
  struct rte_pci_device *dev);

 /*
- * To test cases where RTE_PCI_DRV_NEED_IGB_UIO is set, and isn't set, two
+ * To test cases where RTE_PCI_DRV_NEED_MAPPING is set, and isn't set, two
  * drivers are created (one with IGB devices, the other with IXGBE devices).
  */

@@ -91,7 +91,7 @@ struct rte_pci_driver my_driver = {
.name = "test_driver",
.devinit = my_driver_init,
.id_table = my_driver_id,
-   .drv_flags = RTE_PCI_DRV_NEED_IGB_UIO,
+   .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
 };

 struct rte_pci_driver my_driver2 = {
diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c 
b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 94ae461..eddbd2f 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -474,7 +474,7 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, 
struct rte_pci_device *d
return 0;
}

-   if (dr->drv_flags & RTE_PCI_DRV_NEED_IGB_UIO) {
+   if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {
/* map resources for devices that use igb_uio */
if (pci_uio_map_resource(dev) < 0)
return -1;
diff --git a/lib/librte_eal/common/include/rte_pci.h 
b/lib/librte_eal/common/include/rte_pci.h
index c793773..11b8c13 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -190,8 +190,8 @@ struct rte_pci_driver {
uint32_t drv_flags; /**< Flags contolling handling 
of device. */
 };

-/** Device needs igb_uio kernel module */
-#define RTE_PCI_DRV_NEED_IGB_UIO 0x0001
+/** Device needs PCI BAR mapping (done with either IGB_UIO or VFIO) */
+#define RTE_PCI_DRV_NEED_MAPPING 0x0001
 /** Device driver must be registered several times until failure */
 #define RTE_PCI_DRV_MULTIPLE 0x0002
 /** Device needs to be unbound even if no module is provided */
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index 0b779ec..a0abec8 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -435,7 +435,7 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, 
struct rte_pci_device *d
return 1;
}

-   if (dr->drv_flags & RTE_PCI_DRV_NEED_IGB_UIO) {
+   if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {
/* map resources for devices that use igb_uio */
if ((ret = pci_uio_map_resource(dev)) != 0)
return ret;
diff --git a/lib/librte_pmd_e1000/em_ethdev.c b/lib/librte_pmd_e1000/em_ethdev.c
index 493806c..c8355bc 100644
--- a/lib/librte_pmd_e1000/em_ethdev.c
+++ b/lib/librte_pmd_e1000/em_ethdev.c
@@ -280,7 +280,7 @@ static struct eth_driver rte_em_pmd = {
{
.name = "rte_em_pmd",
.id_table = pci_id_em_map,
-   .drv_flags = RTE_PCI_DRV_NEED_IGB_UIO,
+   .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
},
.eth_dev_init = eth_em_dev_init,
.dev_private_size = sizeof(struct e1000_adapter),
diff --git a/lib/librte_pmd_e1000/igb_ethdev.c 
b/lib/librte_pmd_e1000/igb_ethdev.c
index 5f93bcf..d60f923 100644
--- a/lib/librte_pmd_e1000/igb_ethdev.c
+++ b/lib/librte_pmd_e1000/igb_ethdev.c
@@ -603,7 +603,7 @@ static struct eth_driver rte_igb_pmd = {
{
.name = "rte_igb_pmd",
.id_table = pci_id_igb_map,
-   .drv_flags = RTE_PCI_DRV_NEED_IGB_UIO,
+   .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
},
.eth_dev_init = eth_igb_dev_init,
.dev_private_size = sizeof(struct e1000_adapter),
@@ -616,7 +616,7 @@ static struct eth_driver rte_igbvf_pmd = {
{
.name = "rte_igbvf_pmd",
.id_table = pci_id_igbvf_map,
-   .drv_flags = RTE_PCI_DRV_NEED_IGB_UIO,
+   .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
},
.eth_dev_init = eth_igbvf_dev_init,
.dev_private_size = sizeof(struct e1000_adapter),
diff --git 

[dpdk-dev] [PATCH v5 02/20] pci: move uio mapping code to a separate file

2014-06-10 Thread Anatoly Burakov

Signed-off-by: Anatoly Burakov 
---
 lib/librte_eal/linuxapp/eal/Makefile   |   1 +
 lib/librte_eal/linuxapp/eal/eal_pci.c  | 403 +
 lib/librte_eal/linuxapp/eal/eal_pci_uio.c  | 403 +
 lib/librte_eal/linuxapp/eal/include/eal_pci_init.h |  66 
 4 files changed, 474 insertions(+), 399 deletions(-)
 create mode 100644 lib/librte_eal/linuxapp/eal/eal_pci_uio.c
 create mode 100644 lib/librte_eal/linuxapp/eal/include/eal_pci_init.h

diff --git a/lib/librte_eal/linuxapp/eal/Makefile 
b/lib/librte_eal/linuxapp/eal/Makefile
index b052820..d958014 100644
--- a/lib/librte_eal/linuxapp/eal/Makefile
+++ b/lib/librte_eal/linuxapp/eal/Makefile
@@ -57,6 +57,7 @@ endif
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_thread.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_log.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_pci.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_pci_uio.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_debug.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_lcore.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_timer.c
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index fd88bd0..628813b 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -32,8 +32,6 @@
  */

 #include 
-#include 
-#include 
 #include 
 #include 

@@ -47,6 +45,7 @@
 #include "rte_pci_dev_ids.h"
 #include "eal_filesystem.h"
 #include "eal_private.h"
+#include "eal_pci_init.h"

 /**
  * @file
@@ -57,30 +56,7 @@
  * IGB_UIO driver (or doesn't initialize, if the device wasn't bound to it).
  */

-struct pci_map {
-   void *addr;
-   uint64_t offset;
-   uint64_t size;
-   uint64_t phaddr;
-};
-
-/*
- * For multi-process we need to reproduce all PCI mappings in secondary
- * processes, so save them in a tailq.
- */
-struct mapped_pci_resource {
-   TAILQ_ENTRY(mapped_pci_resource) next;
-
-   struct rte_pci_addr pci_addr;
-   char path[PATH_MAX];
-   int nb_maps;
-   struct pci_map maps[PCI_MAX_RESOURCE];
-};
-
-TAILQ_HEAD(mapped_pci_res_list, mapped_pci_resource);
-static struct mapped_pci_res_list *pci_res_list;
-
-static int pci_parse_sysfs_value(const char *filename, uint64_t *val);
+struct mapped_pci_res_list *pci_res_list = NULL;

 /* unbind kernel driver for this device */
 static int
@@ -122,8 +98,8 @@ error:
 }

 /* map a particular resource from a file */
-static void *
-pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size)
+void *
+pci_map_resource(void * requested_addr, int fd, off_t offset, size_t size)
 {
void *mapaddr;

@@ -147,342 +123,6 @@ fail:
return NULL;
 }

-#define OFF_MAX  ((uint64_t)(off_t)-1)
-static int
-pci_uio_get_mappings(const char *devname, struct pci_map maps[], int nb_maps)
-{
-   int i;
-   char dirname[PATH_MAX];
-   char filename[PATH_MAX];
-   uint64_t offset, size;
-
-   for (i = 0; i != nb_maps; i++) {
- 
-   /* check if map directory exists */
-   rte_snprintf(dirname, sizeof(dirname), 
-   "%s/maps/map%u", devname, i);
- 
-   if (access(dirname, F_OK) != 0)
-   break;
- 
-   /* get mapping offset */
-   rte_snprintf(filename, sizeof(filename),
-   "%s/offset", dirname);
-   if (pci_parse_sysfs_value(filename, ) < 0) {
-   RTE_LOG(ERR, EAL,
-   "%s(): cannot parse offset of %s\n",
-   __func__, dirname);
-   return (-1);
-   }
- 
-   /* get mapping size */
-   rte_snprintf(filename, sizeof(filename),
-   "%s/size", dirname);
-   if (pci_parse_sysfs_value(filename, ) < 0) {
-   RTE_LOG(ERR, EAL,
-   "%s(): cannot parse size of %s\n",
-   __func__, dirname);
-   return (-1);
-   }
- 
-   /* get mapping physical address */
-   rte_snprintf(filename, sizeof(filename),
-   "%s/addr", dirname);
-   if (pci_parse_sysfs_value(filename, [i].phaddr) < 0) {
-   RTE_LOG(ERR, EAL,
-   "%s(): cannot parse addr of %s\n",
-   __func__, dirname);
-   return (-1);
-   }
-
-   if ((offset > OFF_MAX) || (size > SIZE_MAX)) {
-   RTE_LOG(ERR, EAL,
-   "%s(): offset/size exceed system max value\n",
-   __func__); 
-   return (-1);
-   }
-
-   maps[i].offset = offset;
-   maps[i].size = size;
-}
-   return (i);
-}
-
-static int

[dpdk-dev] [PATCH v5 01/20] pci: move open() out of pci_map_resource, rename structs

2014-06-10 Thread Anatoly Burakov
Separating mapping code and calls to open. This is a preparatory work
for VFIO patch since it'll need to map BARs too but it doesn't use path
in mapped_pci_resource. Also, renaming structs to be more generic.

Signed-off-by: Anatoly Burakov 
---
 lib/librte_eal/linuxapp/eal/eal_pci.c | 125 --
 1 file changed, 58 insertions(+), 67 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index ac2c1fe..fd88bd0 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -31,39 +31,17 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */

-#include 
-#include 
-#include 
 #include 
-#include 
-#include 
-#include 
-#include 
 #include 
 #include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include 
-#include 

-#include 
 #include 
 #include 
-#include 
-#include 
-#include 
-#include 
 #include 
-#include 
 #include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include 

 #include "rte_pci_dev_ids.h"
@@ -74,15 +52,12 @@
  * @file
  * PCI probing under linux
  *
- * This code is used to simulate a PCI probe by parsing information in
- * sysfs. Moreover, when a registered driver matches a device, the
- * kernel driver currently using it is unloaded and replaced by
- * igb_uio module, which is a very minimal userland driver for Intel
- * network card, only providing access to PCI BAR to applications, and
- * enabling bus master.
+ * This code is used to simulate a PCI probe by parsing information in sysfs.
+ * When a registered device matches a driver, it is then initialized with
+ * IGB_UIO driver (or doesn't initialize, if the device wasn't bound to it).
  */

-struct uio_map {
+struct pci_map {
void *addr;
uint64_t offset;
uint64_t size;
@@ -93,18 +68,18 @@ struct uio_map {
  * For multi-process we need to reproduce all PCI mappings in secondary
  * processes, so save them in a tailq.
  */
-struct uio_resource {
-   TAILQ_ENTRY(uio_resource) next;
+struct mapped_pci_resource {
+   TAILQ_ENTRY(mapped_pci_resource) next;

struct rte_pci_addr pci_addr;
char path[PATH_MAX];
-   size_t nb_maps;
-   struct uio_map maps[PCI_MAX_RESOURCE];
+   int nb_maps;
+   struct pci_map maps[PCI_MAX_RESOURCE];
 };

-TAILQ_HEAD(uio_res_list, uio_resource);
+TAILQ_HEAD(mapped_pci_res_list, mapped_pci_resource);
+static struct mapped_pci_res_list *pci_res_list;

-static struct uio_res_list *uio_res_list = NULL;
 static int pci_parse_sysfs_value(const char *filename, uint64_t *val);

 /* unbind kernel driver for this device */
@@ -148,30 +123,17 @@ error:

 /* map a particular resource from a file */
 static void *
-pci_map_resource(void *requested_addr, const char *devname, off_t offset,
-size_t size)
+pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size)
 {
-   int fd;
void *mapaddr;

-   /*
-* open devname, to mmap it
-*/
-   fd = open(devname, O_RDWR);
-   if (fd < 0) {
-   RTE_LOG(ERR, EAL, "Cannot open %s: %s\n",
-   devname, strerror(errno));
-   goto fail;
-   }
-
/* Map the PCI memory resource of device */
mapaddr = mmap(requested_addr, size, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, offset);
-   close(fd);
if (mapaddr == MAP_FAILED ||
(requested_addr != NULL && mapaddr != requested_addr)) {
-   RTE_LOG(ERR, EAL, "%s(): cannot mmap(%s(%d), %p, 0x%lx, 0x%lx):"
-   " %s (%p)\n", __func__, devname, fd, requested_addr,
+   RTE_LOG(ERR, EAL, "%s(): cannot mmap(%d, %p, 0x%lx, 0x%lx): %s 
(%p)\n",
+   __func__, fd, requested_addr,
(unsigned long)size, (unsigned long)offset,
strerror(errno), mapaddr);
goto fail;
@@ -186,10 +148,10 @@ fail:
 }

 #define OFF_MAX  ((uint64_t)(off_t)-1)
-static ssize_t
-pci_uio_get_mappings(const char *devname, struct uio_map maps[], size_t 
nb_maps)
+static int
+pci_uio_get_mappings(const char *devname, struct pci_map maps[], int nb_maps)
 {
-   size_t i;
+   int i;
char dirname[PATH_MAX];
char filename[PATH_MAX];
uint64_t offset, size;
@@ -249,25 +211,37 @@ pci_uio_get_mappings(const char *devname, struct uio_map 
maps[], size_t nb_maps)
 static int
 pci_uio_map_secondary(struct rte_pci_device *dev)
 {
-size_t i;
-struct uio_resource *uio_res;
+   int fd, i;
+   struct mapped_pci_resource *uio_res;

-   TAILQ_FOREACH(uio_res, uio_res_list, next) {
+   TAILQ_FOREACH(uio_res, pci_res_list, next) {

/* skip this element if it doesn't match our PCI address */
if (memcmp(_res->pci_addr, >addr, sizeof(dev->addr)))
continue;

[dpdk-dev] [PATCH v5 00/20] Add VFIO support to DPDK

2014-06-10 Thread Anatoly Burakov
This patchset adds support for using VFIO instead of IGB_UIO to
map the device BARs.

VFIO is a kernel 3.6+ driver allowing secure DMA from userspace
by means of using IOMMU instead of working directly with physical
memory like igb_uio does.

Short summary:
* Adding support for VFIO in EAL PCI code
* Adding new command-line parameter for VFIO interrupt type
* Adding support for VFIO in setup.sh
* Renaming igb_uio_bind to dpdk_nic_bind and adding support for
  VFIO there
* Removing PCI ID list from igb_uio, effectively making it another
  generic PCI driver similar to pci_stub, vfio-pci et al
* Adding autotest for VFIO interrupt types
* Making igb_uio and VFIO compilation optional

v2 fixes:
* Fixed a couple of resource leaks

v3 fixes:
* Fixed various checkpatch.pl issues
* Added MSI interrupt support
* Added an option to automatically determine interrupt type
* Fixed various issues of commit atomicity

v4 fixes:
* Rebased on top of 5ebbb17281645b23359fbd49133bb639b63ba88c
* Fixed a typo in EAL command-line help text

v5 fixes:
* Fixed missing virtio change to RTE_PCI_DRV_NEED_MAPPING
* Fixed compile issue when VFIO was disabled (introduced in v3)

Tested-by: Waterman Cao  

This patch has been tested by intel.
We tested this patch with the following functions:
* Layer-2 Forwarding support
* Sample commands test
* Packet forwarding checking
* Bind and unbind VFIO driver
* Compile igb_uio driver ( Linux kernel < 3.6)
* Interrupt model test under Legacy|msi|msix
All cases passed.

Please see test environment information :
Fedora 20 x86_64, Linux Kernel 3.13.6-200,
GCC 4.8.2 Intel Xeon CPU E5-2680 v2 @ 2.80GHz NIC: Intel Niantic 82599


Anatoly Burakov (20):
  pci: move open() out of pci_map_resource, rename structs
  pci: move uio mapping code to a separate file
  pci: fixing errors in a previous commit found by checkpatch
  pci: distinguish between legitimate failures and non-fatal errors
  pci: Rename RTE_PCI_DRV_NEED_IGB_UIO to RTE_PCI_DRV_NEED_MAPPING
  igb_uio: make igb_uio compilation optional
  igb_uio: Moved interrupt type out of igb_uio
  vfio: add support for VFIO in Linuxapp targets
  vfio: add VFIO header
  interrupts: Add support for VFIO interrupts
  eal: remove -Wno-return-type for non-existent eal_hpet.c
  vfio: create mapping code for VFIO
  vfio: add multiprocess support.
  pci: enable VFIO device binding
  eal: added support for selecting VFIO interrupt type from EAL
command-line
  eal: make --no-huge use mmap instead of malloc
  test app: adding unit tests for VFIO EAL command-line parameter
  igb_uio: Removed PCI ID table from igb_uio
  binding script: Renamed igb_uio_bind to dpdk_nic_bind
  setup script: adding support for VFIO to setup.sh

 app/test/test_eal_flags.c  |  36 +
 app/test/test_pci.c|   4 +-
 config/common_linuxapp |   2 +
 lib/librte_eal/bsdapp/eal/eal_pci.c|   2 +-
 lib/librte_eal/common/Makefile |   1 +
 lib/librte_eal/common/eal_common_pci.c |  16 +-
 lib/librte_eal/common/include/rte_pci.h|   5 +-
 .../common/include/rte_pci_dev_feature_defs.h  |  46 ++
 .../common/include/rte_pci_dev_features.h  |  44 ++
 lib/librte_eal/linuxapp/Makefile   |   2 +
 lib/librte_eal/linuxapp/eal/Makefile   |   5 +-
 lib/librte_eal/linuxapp/eal/eal.c  |  36 +
 lib/librte_eal/linuxapp/eal/eal_interrupts.c   | 287 +++-
 lib/librte_eal/linuxapp/eal/eal_memory.c   |   8 +-
 lib/librte_eal/linuxapp/eal/eal_pci.c  | 473 ++---
 lib/librte_eal/linuxapp/eal/eal_pci_uio.c  | 403 +++
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 781 +
 lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c | 395 +++
 .../linuxapp/eal/include/eal_internal_cfg.h|   3 +
 lib/librte_eal/linuxapp/eal/include/eal_pci_init.h | 116 +++
 lib/librte_eal/linuxapp/eal/include/eal_vfio.h |  55 ++
 .../linuxapp/eal/include/exec-env/rte_interrupts.h |   4 +
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c  |  69 +-
 lib/librte_pmd_e1000/em_ethdev.c   |   2 +-
 lib/librte_pmd_e1000/igb_ethdev.c  |   4 +-
 lib/librte_pmd_ixgbe/ixgbe_ethdev.c|   4 +-
 lib/librte_pmd_virtio/virtio_ethdev.c  |   2 +-
 lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c|   2 +-
 tools/{igb_uio_bind.py => dpdk_nic_bind.py}| 157 +++--
 tools/setup.sh | 172 -
 30 files changed, 2548 insertions(+), 588 deletions(-)
 create mode 100644 lib/librte_eal/common/include/rte_pci_dev_feature_defs.h
 create mode 100644 lib/librte_eal/common/include/rte_pci_dev_features.h
 create mode 100644 lib/librte_eal/linuxapp/eal/eal_pci_uio.c
 create mode 100644 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
 create mode 100644 

[dpdk-dev] [PATCH] kni: fix compile errors on Oracle Linux6.4 and RHEL6.5

2014-06-10 Thread Thomas Monjalon
Hi Helin,

2014-06-09 16:38, Helin Zhang:
>  #if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0) )
>  #define skb_tx_timestamp(skb) do {} while (0)
> -#if !(RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,4))
> -static inline bool ether_addr_equal(const u8 *addr1, const u8 *addr2)
> +#ifndef ether_addr_equal

It should be always true as it is a function (not known by the preprocessor).

> +static inline bool __kc_ether_addr_equal(const u8 *addr1, const u8 *addr2)
>  {
>   return !compare_ether_addr(addr1, addr2);
>  }
> -#endif
> +#define ether_addr_equal(_addr1, _addr2) 
> __kc_ether_addr_equal((_addr1),(_addr2))
> +#endif /* __kc_ether_addr_equal*/

So it is always replacing ether_addr_equal() by a kcompat equivalent for old 
kernels,
even if ether_addr_equal() is already defined as a C function.
Just to confirm: is it really what we want?

[...]
> -#endif
> +#define ethtool_adv_to_mmd_eee_adv_t(adv) \
> +__kc_ethtool_adv_to_mmd_eee_adv_t(adv)

An indentation is missing here.

> +#endif /* ethtool_adv_to_mmd_eee_adv_t */
> +#endif /* */

Why an empty comment?

Thanks
-- 
Thomas


[dpdk-dev] using hash table in a MP environment

2014-06-10 Thread Neil Horman
On Tue, Jun 10, 2014 at 11:02:03AM +0300, Uri Sidler wrote:
> Hi,
> I am currently using a hash table in a multi-process environment.
> the master process creates the hash table which is later used by other
> secondary processes.
> but the secondary processes fail to use the hash table since the hash
> function address actually points to a different fucntion. (this makes sense
> since the address of the hash function is in fact different per process).
> How can I solve this issue?
> 
> Thanks,
> Shirley.
> 

Use shared memory.  see shmget

Neil



[dpdk-dev] [PATCH] kni: fix compile errors on Oracle Linux6.4 and RHEL6.5

2014-06-10 Thread Neil Horman
On Mon, Jun 09, 2014 at 04:38:55PM +0800, Helin Zhang wrote:
> From: HELIN ZHANG 
> 
> The compile errors are as follows. The fixes came from standard
> Linux drivers of ixgbe-3.21.2 and igb-5.1.2.
> 
> * Oracle Linux6.4
> lib/librte_eal/linuxapp/kni/ethtool/ixgbe/kcompat.h:3111:
> error: redefinition of 'ether_addr_equal'
> include/linux/etherdevice.h:180: note: previous definition
> of 'ether_addr_equal' was here
> * RHEL6.5
> lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h:3597:
> error: redefinition of 'mmd_eee_cap_to_ethtool_sup_t'
> include/linux/mdio.h:387: note: previous definition of
> 'mmd_eee_cap_to_ethtool_sup_t' was here
> lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h:3625:
> error: redefinition of 'mmd_eee_adv_to_ethtool_adv_t'
> include/linux/mdio.h:415: note: previous definition of
> 'mmd_eee_adv_to_ethtool_adv_t' was here
> lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h:3653:
> error: redefinition of 'ethtool_adv_to_mmd_eee_adv_t'
> include/linux/mdio.h:443: note: previous definition of
> 'ethtool_adv_to_mmd_eee_adv_t' was here
> 
> Signed-off-by: Helin Zhang 
> Acked-by: Cunming Liang 
> Tested-by: Waterman Cao 
> ---
>  lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h  | 29 
> --
>  .../linuxapp/kni/ethtool/ixgbe/kcompat.h   |  5 ++--
>  2 files changed, 24 insertions(+), 10 deletions(-)
> 
> diff --git a/lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h 
> b/lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h
> index 4c27d5d..26bf0b2 100644
> --- a/lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h
> +++ b/lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h
> @@ -3534,12 +3534,13 @@ extern void _kc_skb_add_rx_frag(struct sk_buff *, 
> int, struct page *,
>  
> /*/
>  #if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0) )
>  #define skb_tx_timestamp(skb) do {} while (0)
> -#if !(RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,4))
> -static inline bool ether_addr_equal(const u8 *addr1, const u8 *addr2)
> +#ifndef ether_addr_equal
> +static inline bool __kc_ether_addr_equal(const u8 *addr1, const u8 *addr2)
>  {
>   return !compare_ether_addr(addr1, addr2);
>  }
> -#endif
> +#define ether_addr_equal(_addr1, _addr2) 
> __kc_ether_addr_equal((_addr1),(_addr2))
> +#endif /* __kc_ether_addr_equal*/
I don't see why you're wrapping this in a macro twice, just #defining
ether_addr_equal to !compare_ether_addr should be sufficient here.

>  #else
>  #define HAVE_FDB_OPS
>  #define HAVE_ETHTOOL_GET_TS_INFO
> @@ -3586,7 +3587,8 @@ static inline bool ether_addr_equal(const u8 *addr1, 
> const u8 *addr2)
>  #define ADVERTISED_4baseLR4_Full (1 << 26)
>  #endif
>  
> -#if defined(ETHTOOL_GEEE) || (RHEL_RELEASE_CODE && RHEL_RELEASE_CODE <= 
> RHEL_RELEASE_VERSION(6,4))
> +#if defined(ETHTOOL_GEEE)
> +#ifndef mmd_eee_cap_to_ethtool_sup_t
Why are we even bothering with gating this on ETHTOOL_GEEE?  Or building it in
at all for that matter?  ETHTOOL_GEEE doesn't having any dependence on any 
hardware
feature availability, we can just enable it unilaterally (if its not already
defined, though doing an ifndef on a function thats defined as such is a bit
wierd).  

Theres also an argument for not doing this compat code at all, as nothing
currently uses it.  the KNI is the only code that could reach this path, and
nothing in the KNI does so at the moment.  We could just remove this code and
turn off support in the igb pmd instead, it would save some useless code space.

>  /**
>   * mmd_eee_cap_to_ethtool_sup_t
>   * @eee_cap: value of the MMD EEE Capability register
> @@ -3594,7 +3596,7 @@ static inline bool ether_addr_equal(const u8 *addr1, 
> const u8 *addr2)
>   * A small helper function that translates MMD EEE Capability (3.20) bits
>   * to ethtool supported settings.
>   */
> -static inline u32 mmd_eee_cap_to_ethtool_sup_t(u16 eee_cap)
> +static inline u32 __kc_mmd_eee_cap_to_ethtool_sup_t(u16 eee_cap)
>  {
>   u32 supported = 0;
>  
> @@ -3613,7 +3615,11 @@ static inline u32 mmd_eee_cap_to_ethtool_sup_t(u16 
> eee_cap)
>  
>   return supported;
>  }
> +#define mmd_eee_cap_to_ethtool_sup_t(eee_cap) \
> + __kc_mmd_eee_cap_to_ethtool_sup_t(eee_cap)
> +#endif /* __kc_mmd_eee_cap_to_ethtool_sup_t */
>  
> +#ifndef mmd_eee_adv_to_ethtool_adv_t
>  /**
>   * mmd_eee_adv_to_ethtool_adv_t
>   * @eee_adv: value of the MMD EEE Advertisement/Link Partner Ability 
> registers
> @@ -3622,7 +3628,7 @@ static inline u32 mmd_eee_cap_to_ethtool_sup_t(u16 
> eee_cap)
>   * and MMD EEE Link Partner Ability (7.61) bits to ethtool advertisement
>   * settings.
>   */
> -static inline u32 mmd_eee_adv_to_ethtool_adv_t(u16 eee_adv)
> +static inline u32 __kc_mmd_eee_adv_to_ethtool_adv_t(u16 eee_adv)
>  {
>   u32 adv = 0;
>  
> @@ -3641,7 +3647,11 @@ static inline u32 mmd_eee_adv_to_ethtool_adv_t(u16 
> eee_adv)
>  
>   return adv;
>  }
> +#define 

[dpdk-dev] [PATCH 1/2] rte_tailq.h: Fix compilation under FreeBSD

2014-06-10 Thread Cao, Waterman
Tested-by: Waterman Cao 

This patch is to fix compilation error in the FreeBSD 10.0 like the followings:
.. /include/rte_tailq.h:177:21: error: unknown type name 'FILE' void 
rte_dump_tailq(FILE *f);
../include/rte_memory.h:146:30: error: unknown type name 'FILE' void 
rte_dump_physmem_layout(FILE *f);

After merged this patch with last dpdk.org, compilation can pass without error 
in FreeBSD 10.0