Skip to contentSkip to conversation

upgrade with 6WIND's enhancements

PATCH In review Thomas Monjalon 2 participants 25 messages Mar 20, 2013 – Mar 21, 2013 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

cover upgrade with 6WIND's enhancements

Here are some patches which were not integrated by Intel in their 1.2.3 version.

---

Adrien Mazarguil (3):
lib: fix non-C99 macros definitions in exported headers
pci: reference driver structure for each device
pci: allow drivers to be bound several times to the same PCI device

Damien Millescamps (3):
app: fix config crash in testpmd
timer: option --vmware-tsc-map for VMware guest
igb_uio: fix driver dependency

Didier Pallard (2):
mk: fix verbose display of install command
mk: add a makefile for shared libraries

Ivan Boule (3):
app: fix volatile read for GCC >= 4.6
app: fix testpmd compliance with __rte_mbuf_sanity_check()
timer: check TSC reliability

Nicolas Dichtel (1):
igb_uio: fix build with kernel >= 3.8

Olivier Matz (1):
app: use (void)variable when unused

Samuel Gauthier (1):
mk: use $CC to detect toolchain version

Thierry Herbelot (1):
mk: fix typo in LDFLAGS for 32-bit

Thomas Monjalon (3):
app: fix autotest summary in error cases
mem: fix access to huge page with high address
timer: get TSC frequency from /proc/cpuinfo

Zijie Pan (4):
mk: allow corei7-avx flag with gcc 4.7
app: fix unused values
lib: fix unused values
lib: fix uninitialized variables

 app/test-pmd/config.c                              |   21 ++--
 app/test-pmd/testpmd.c                             |    1 +
 app/test-pmd/txonly.c                              |    1 +
 app/test/autotest.py                               |    7 +-
 app/test/test.c                                    |    1 -
 app/test/test_hash.c                               |    6 +-
 app/test/test_lpm.c                                |    4 +-
 app/test/test_memory.c                             |    4 +-
 app/test/test_ring.c                               |    4 +-
 config/defconfig_i686-default-linuxapp-gcc         |    5 +
 config/defconfig_i686-default-linuxapp-icc         |    5 +
 config/defconfig_x86_64-default-linuxapp-gcc       |    5 +
 config/defconfig_x86_64-default-linuxapp-icc       |    5 +
 lib/librte_cmdline/cmdline_cirbuf.h                |    5 +-
 lib/librte_cmdline/cmdline_parse_ipaddr.c          |    1 -
 lib/librte_eal/common/eal_common_pci.c             |   17 ++-
 lib/librte_eal/common/include/rte_cycles.h         |   19 +++
 lib/librte_eal/common/include/rte_debug.h          |    3 +-
 lib/librte_eal/common/include/rte_log.h            |   15 +-
 lib/librte_eal/common/include/rte_pci.h            |    5 +
 lib/librte_eal/linuxapp/eal/eal.c                  |   23 +++
 lib/librte_eal/linuxapp/eal/eal_hpet.c             |   84 +++++++++++-
 lib/librte_eal/linuxapp/eal/eal_memory.c           |    3 +-
 lib/librte_eal/linuxapp/eal/eal_pci.c              |   23 +++-
 lib/librte_eal/linuxapp/eal/eal_thread.c           |    2 -
 .../linuxapp/eal/include/eal_internal_cfg.h        |    1 +
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c          |    4 +
 lib/librte_lpm/rte_lpm.c                           |    2 +-
 lib/librte_pmd_igb/e1000_rxtx.c                    |    6 +-
 lib/librte_pmd_igb/igb/e1000_vf.c                  |    3 +-
 lib/librte_pmd_ixgbe/ixgbe_ethdev.c                |    4 +
 lib/librte_pmd_ixgbe/ixgbe_rxtx.c                  |    2 +-
 mk/arch/i686/rte.vars.mk                           |    2 +-
 mk/internal/rte.install-post.mk                    |    2 +-
 mk/{arch/i686/rte.vars.mk => rte.extshared.mk}     |   93 ++++++-------
 mk/rte.shared.mk                                   |  141 ++++++++++++++++++++
 mk/toolchain/gcc/rte.toolchain-compat.mk           |    6 +-
 37 files changed, 417 insertions(+), 118 deletions(-)
 copy mk/{arch/i686/rte.vars.mk => rte.extshared.mk} (55%)
 create mode 100644 mk/rte.shared.mk
Signature · 1 line
1.7.2.5

A message that is not in the archive (sent off-list or not yet received): cover.1363795499.git.thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH 1/22 mk: use $CC to detect toolchain version

From: Samuel Gauthier <[email protected]>

Using gcc is wrong, we should use the cross gcc to detect the version of gcc.

---
 mk/toolchain/gcc/rte.toolchain-compat.mk |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
mk/toolchain/gcc/rte.toolchain-compat.mk +2 -2
index 4e65122..2e05ecb 100644
@@ -40,7 +40,7 @@
 
 #find out GCC version
 
-GCC_MAJOR_VERSION = $(shell gcc -dumpversion | cut -f1 -d.)
+GCC_MAJOR_VERSION = $(shell $(CC) -dumpversion | cut -f1 -d.)
 
 # if GCC is not 4.x
 ifneq ($(GCC_MAJOR_VERSION),4)
@@ -49,7 +49,7 @@ $(warning You are not using GCC 4.x. This is neither supported, nor tested.)
 
 
 else
-	GCC_MINOR_VERSION = $(shell gcc -dumpversion | cut -f2 -d.)
+	GCC_MINOR_VERSION = $(shell $(CC) -dumpversion | cut -f2 -d.)
 
 # GCC graceful degradation
 # GCC 4.2.x - added support for generic target
Signature · 1 line
1.7.2.5
#3 lore raw

PATCH 2/22 mk: fix typo in LDFLAGS for 32-bit

In reply to a message not in the archive

From: Thierry Herbelot <[email protected]>

Enable compilation for 32-bit architecture.

---
 mk/arch/i686/rte.vars.mk |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
mk/arch/i686/rte.vars.mk +1 -1
index 6f8e474..d6a3fe4 100644
@@ -53,7 +53,7 @@ ARCH  ?= i386
 CROSS ?=
 
 CPU_CFLAGS  ?= -m32
-CPU_LDFLAGS ?= -m elf_i386
+CPU_LDFLAGS ?= -melf_i386
 CPU_ASFLAGS ?= -felf
 
 export ARCH CROSS CPU_CFLAGS CPU_LDFLAGS CPU_ASFLAGS
Signature · 1 line
1.7.2.5
#4 lore raw

PATCH 3/22 mk: fix verbose display of install command

In reply to a message not in the archive

From: Didier Pallard <[email protected]>

Correctly display executed install command in
rte.install-post.mk install rules

---
 mk/internal/rte.install-post.mk |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
mk/internal/rte.install-post.mk +1 -1
index 1e84a10..29a8606 100644
@@ -43,7 +43,7 @@ define install_rule
 $(addprefix $(RTE_OUTPUT)/$(1)/,$(notdir $(2))): $(2)
 	@echo "  INSTALL-FILE $(addprefix $(1)/,$(notdir $(2)))"
 	@[ -d $(RTE_OUTPUT)/$(1) ] || mkdir -p $(RTE_OUTPUT)/$(1)
-	@cp -rf $$(<) $(RTE_OUTPUT)/$(1)
+	$(Q)cp -rf $$(<) $(RTE_OUTPUT)/$(1)
 endef
 
 $(foreach dir,$(INSTALL-DIRS-y),\
Signature · 1 line
1.7.2.5
#5 lore raw

PATCH 4/22 mk: add a makefile for shared libraries

In reply to a message not in the archive

From: Didier Pallard <[email protected]>

Add mk/rte.shared.mk and mk/rte.extshared.mk in framework to
allow shared libraries compilation through framework

---
 mk/rte.extshared.mk |   54 +++++++++++++++++++
 mk/rte.shared.mk    |  141 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 195 insertions(+), 0 deletions(-)
 create mode 100644 mk/rte.extshared.mk
 create mode 100644 mk/rte.shared.mk
mk/rte.extshared.mk new file +54 -0
new file mode 100644
index 0000000..f240fd8
@@ -0,0 +1,54 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2012-2013 6WIND.
+#
+#   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 6WIND S.A. 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.
+#
+
+MAKEFLAGS += --no-print-directory
+
+# we must create the output dir first and recall the same Makefile
+# from this directory
+ifeq ($(NOT_FIRST_CALL),)
+
+NOT_FIRST_CALL = 1
+export NOT_FIRST_CALL
+
+all:
+	$(Q)mkdir -p $(RTE_OUTPUT)
+	$(Q)$(MAKE) -C $(RTE_OUTPUT) -f $(RTE_EXTMK) \
+		S=$(RTE_SRCDIR) O=$(RTE_OUTPUT) SRCDIR=$(RTE_SRCDIR)
+	@echo $(RTE_OUTPUT)/lib must be added to /etc/ld.so.conf or \
+		LD_LIBRARY_PATH variable to allow binary to link with dynamic library
+
+%::
+	$(Q)mkdir -p $(RTE_OUTPUT)
+	$(Q)$(MAKE) -C $(RTE_OUTPUT) -f $(RTE_EXTMK) $@ \
+		S=$(RTE_SRCDIR) O=$(RTE_OUTPUT) SRCDIR=$(RTE_SRCDIR)
+else
+include $(RTE_SDK)/mk/rte.shared.mk
+endif
mk/rte.shared.mk new file +141 -0

141 lines not on this page · raw message

Signature · 1 line
1.7.2.5
#6 lore raw

PATCH 5/22 mk: allow corei7-avx flag with gcc 4.7

In reply to a message not in the archive

From: Zijie Pan <[email protected]>

In rte.toolchain-compat.mk, ensure MACHINE_CFLAGS is initialized when using GCC 4.7. Update the GCC 4.6 test to also include GCC 4.7.

---
 mk/toolchain/gcc/rte.toolchain-compat.mk |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
mk/toolchain/gcc/rte.toolchain-compat.mk +1 -1
index 2e05ecb..137659d 100644
@@ -59,7 +59,7 @@ else
 # GCC 4.6.x - added support for corei7, corei7-avx
 # GCC 4.7.x - added support for fsgsbase, rdrnd, f16c, core-avx-i, core-avx2
 
-	ifeq ($(shell test $(GCC_MINOR_VERSION) -lt 7 && echo 1), 1)
+	ifeq ($(shell test $(GCC_MINOR_VERSION) -le 7 && echo 1), 1)
 		MACHINE_CFLAGS := $(patsubst -march=core-avx-i,-march=corei7-avx,$(MACHINE_CFLAGS))
 		MACHINE_CFLAGS := $(patsubst -march=core-avx2,-march=corei7-avx,$(MACHINE_CFLAGS))
 	endif
Signature · 1 line
1.7.2.5
#7 lore raw

PATCH 6/22 app: fix volatile read for GCC >= 4.6

In reply to a message not in the archive

From: Ivan Boule <[email protected]>

When a memory address must be read, for instance a [mapped] PCI register, the read value is assigned to a local variable that is not used after, as for instance:

    x = *((uint8_t *) mem_addr);

Such instructions do not compile with gcc 4.6.
The fix consists in adding the "volatile" attribute to the accessed data type and to not assign the read value:

    *((volatile uint8_t *) mem_addr);
---
 app/test/test_memory.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
app/test/test_memory.c +1 -3
index 8a25eca..96d35d9 100644
@@ -61,7 +61,6 @@ test_memory(void)
 	uint64_t s;
 	unsigned i, j;
 	const struct rte_memseg *mem;
-	volatile uint8_t x;
 
 	/*
 	 * dump the mapped memory: the python-expect script checks
@@ -83,8 +82,7 @@ test_memory(void)
 
 		/* check memory */
 		for (j = 0; j<mem[i].len; j++) {
-			x = *((uint8_t *) mem[i].addr + j);
-			RTE_SET_USED(x);
+			*((volatile uint8_t *) mem[i].addr + j);
 		}
 	}
 
Signature · 1 line
1.7.2.5
#8 lore raw

PATCH 7/22 app: fix unused values

In reply to a message not in the archive

From: Zijie Pan <[email protected]>

Fix warnings of type "Value stored to 'xxx' is never read".

---
 app/test-pmd/config.c |    1 -
 app/test/test.c       |    1 -
 app/test/test_lpm.c   |    4 +---
 app/test/test_ring.c  |    4 +---
 4 files changed, 2 insertions(+), 8 deletions(-)
app/test-pmd/config.c +0 -1
index fd62235..10cf699 100644
@@ -520,7 +520,6 @@ setup_fwd_config_of_each_lcore(struct fwd_config *cfg)
 		nb_fs_per_lcore = (streamid_t) (nb_fs / nb_fc);
 		nb_extra = (lcoreid_t) (nb_fs % nb_fc);
 	}
-	nb_extra = (lcoreid_t) (nb_fs % nb_fc);
 
 	nb_lc = (lcoreid_t) (nb_fc - nb_extra);
 	sm_id = 0;
app/test/test.c +0 -1
index f98656c..ef978cf 100644
@@ -132,7 +132,6 @@ main(int argc, char **argv)
 
 	rte_timer_subsystem_init();
 
-	argc -= ret;
 	argv += ret;
 
 	prgname = argv[0];
app/test/test_lpm.c +1 -3
index 3a9400f..5b8118a 100644
@@ -752,7 +752,6 @@ test10(void)
 
 	ip = IPv4(128, 0, 0, 0);
 	depth = 24;
-	next_hop_add = 100;
 
 	status = rte_lpm_delete(lpm, ip, depth);
 	TEST_LPM_ASSERT(status < 0);
@@ -766,7 +765,6 @@ test10(void)
 
 	ip = IPv4(128, 0, 0, 0);
 	depth = 32;
-	next_hop_add = 100;
 
 	status = rte_lpm_delete(lpm, ip, depth);
 	TEST_LPM_ASSERT(status < 0);
@@ -976,7 +974,7 @@ test14(void)
 	next_hop_add = 100;
 
 	/* Add 256 rules that require a tbl8 extension */
-	for (ip = 0; ip <= IPv4(0, 0, 255, 0); ip += 256) {
+	for (; ip <= IPv4(0, 0, 255, 0); ip += 256) {
 		status = rte_lpm_add(lpm, ip, depth, next_hop_add);
 		TEST_LPM_ASSERT(status == 0);
 
app/test/test_ring.c +1 -3
index d6bb44b..39f69b0 100644
@@ -518,7 +518,7 @@ test_set_watermark( void ){
 	}
 
 	count = 0;
-	setwm = rte_ring_set_water_mark(r, count);
+	rte_ring_set_water_mark(r, count);
 	if (r->prod.watermark != r->prod.size) {
 		printf("Test failed to detect invalid watermark count value\n");
 		goto error;
@@ -759,8 +759,6 @@ test_ring_basic(void)
 		printf("data after dequeue is not the same\n");
 		goto fail;
 	}
-	cur_src = src;
-	cur_dst = dst;
 
 	if (src)
 		free(src);
Signature · 1 line
1.7.2.5
#9 lore raw

PATCH 8/22 app: use (void)variable when unused

In reply to a message not in the archive

From: Olivier Matz <[email protected]>

When compiling with llvm-clang, the notation "variable = variable" produces a warning. We shall use "(void)variable" instead.

---
 app/test/test_hash.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
app/test/test_hash.c +3 -3
index 5992fa3..528baba 100644
@@ -1604,7 +1604,7 @@ test_hash_jhash_1word(const void *key, uint32_t length, uint32_t initval)
 {
 	const uint32_t *k = key;
 
-	length =length;
+	(void)length;
 
 	return rte_jhash_1word(k[0], initval);
 }
@@ -1614,7 +1614,7 @@ test_hash_jhash_2word(const void *key, uint32_t length, uint32_t initval)
 {
 	const uint32_t *k = key;
 
-	length =length;
+	(void)length;
 
 	return rte_jhash_2words(k[0], k[1], initval);
 }
@@ -1624,7 +1624,7 @@ test_hash_jhash_3word(const void *key, uint32_t length, uint32_t initval)
 {
 	const uint32_t *k = key;
 
-	length =length;
+	(void)length;
 
 	return rte_jhash_3words(k[0], k[1], k[2], initval);
 }
Signature · 1 line
1.7.2.5
#10 lore raw

PATCH 9/22 app: fix testpmd compliance with __rte_mbuf_sanity_check()

In reply to a message not in the archive

From: Ivan Boule <[email protected]>

Build mbuf and lists of mbufs in a way compliant with the checks performed by the function __rte_mbuf_sanity_check() when CONFIG_RTE_LIBRTE_MBUF_DEBUG=y

---
 app/test-pmd/testpmd.c |    1 +
 app/test-pmd/txonly.c  |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)
app/test-pmd/testpmd.c +1 -0
index 6813b66..d67b662 100644
@@ -323,6 +323,7 @@ testpmd_mbuf_ctor(struct rte_mempool *mp,
 	mb_ctor_arg = (struct mbuf_ctor_arg *) opaque_arg;
 	mb = (struct rte_mbuf *) raw_mbuf;
 
+	mb->type         = RTE_MBUF_PKT;
 	mb->pool         = mp;
 	mb->buf_addr     = (void *) ((char *)mb + mb_ctor_arg->seg_buf_offset);
 	mb->buf_physaddr = (uint64_t) (rte_mempool_virt2phy(mp, mb) +
app/test-pmd/txonly.c +1 -0
index bf0a3e2..d7c8c31 100644
@@ -235,6 +235,7 @@ pkt_burst_transmit(struct fwd_stream *fs)
 		for (i = 1; i < tx_pkt_nb_segs; i++) {
 			pkt_seg->pkt.next = tx_mbuf_alloc(mbp);
 			if (pkt_seg->pkt.next == NULL) {
+				pkt->pkt.nb_segs = i;
 				rte_pktmbuf_free(pkt);
 				goto nomore_mbuf;
 			}
Signature · 1 line
1.7.2.5
#11 lore raw

PATCH 10/22 app: fix config crash in testpmd

In reply to a message not in the archive

From: Damien Millescamps <[email protected]>

A chained topology must always have an increment of 1. Here, it was 2 if ports number is even.

---
 app/test-pmd/config.c |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)
app/test-pmd/config.c +9 -11
index 10cf699..708ebad 100644
@@ -2,6 +2,7 @@
  *   BSD LICENSE
  * 
  *   Copyright(c) 2010-2012 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2012-2013 6WIND.
  *   All rights reserved.
  * 
  *   Redistribution and use in source and binary forms, with or without 
@@ -547,17 +548,14 @@ simple_fwd_config_setup(void)
 	portid_t j;
 	portid_t inc = 2;
 
-	if (nb_fwd_ports % 2) {
-		if (port_topology == PORT_TOPOLOGY_CHAINED) {
-			inc = 1;
-		}
-		else {
-			printf("\nWarning! Cannot handle an odd number of ports "
-			       "with the current port topology. Configuration "
-			       "must be changed to have an even number of ports, "
-			       "or relaunch application with "
-			       "--port-topology=chained\n\n");
-		}
+	if (port_topology == PORT_TOPOLOGY_CHAINED) {
+		inc = 1;
+	} else if (nb_fwd_ports % 2) {
+		printf("\nWarning! Cannot handle an odd number of ports "
+		       "with the current port topology. Configuration "
+		       "must be changed to have an even number of ports, "
+		       "or relaunch application with "
+		       "--port-topology=chained\n\n");
 	}
 
 	cur_fwd_config.nb_fwd_ports = (portid_t) nb_fwd_ports;
Signature · 1 line
1.7.2.5
#12 lore raw

PATCH 11/22 app: fix autotest summary in error cases

In reply to a message not in the archive

It was reporting "All test OK" even if previous tests (except the last one) were failed.

---
 app/test/autotest.py |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
app/test/autotest.py +5 -2
index 2609142..6613897 100755
@@ -143,6 +143,7 @@ class AutoTest:
             self.report_list.append(report)
 
     def gen_report(self):
+        fails = 0
         for report in self.report_list:
             # main report header and stats
             self.literal = 0
@@ -186,15 +187,17 @@ class AutoTest:
                     reportlog.write(s)
 
             reportlog.close()
+            if report["fails"] > 0:
+                fails += 1
 
         # displayed on console
         print
         print "-------------------------"
         print
-        if report["fails"] == 0:
+        if fails == 0:
             print "All test OK"
         else:
-            print "%s test(s) failed"%(report["fails"])
+            print "%s test(s) failed" % fails
 
     # file API, to store logs from pexpect
     def write(self, buf):
Signature · 1 line
1.7.2.5
#13 lore raw

PATCH 12/22 lib: fix unused values

In reply to a message not in the archive

From: Zijie Pan <[email protected]>

Fix warnings of type "Value stored to 'xxx' is never read".

---
 lib/librte_cmdline/cmdline_parse_ipaddr.c |    1 -
 lib/librte_eal/linuxapp/eal/eal_thread.c  |    2 --
 lib/librte_lpm/rte_lpm.c                  |    2 +-
 lib/librte_pmd_igb/e1000_rxtx.c           |    2 --
 lib/librte_pmd_ixgbe/ixgbe_ethdev.c       |    4 ++++
 5 files changed, 5 insertions(+), 6 deletions(-)
lib/librte_cmdline/cmdline_parse_ipaddr.c +0 -1
index 66a1493..a7dcd2b 100644
@@ -262,7 +262,6 @@ inet_pton6(const char *src, unsigned char *dst)
 		    inet_pton4(curtok, tp) > 0) {
 			tp += INADDRSZ;
 			saw_xdigit = 0;
-			count_xdigit = 0;
 			break;  /* '\0' was seen by inet_pton4(). */
 		}
 		return (0);
lib/librte_eal/linuxapp/eal/eal_thread.c +0 -2
index 7409d28..d36030e 100644
@@ -86,7 +86,6 @@ rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id)
 		rte_panic("cannot write on configuration pipe\n");
 
 	/* wait ack */
-	n = 0;
 	do {
 		n = read(s2m, &c, 1);
 	} while (n < 0 && errno == EINTR);
@@ -203,7 +202,6 @@ eal_thread_loop(__attribute__((unused)) void *arg)
 		void *fct_arg;
 
 		/* wait command */
-		n = 0;
 		do {
 			n = read(m2s, &c, 1);
 		} while (n < 0 && errno == EINTR);
lib/librte_lpm/rte_lpm.c +1 -1
index 4269b3c..bb1ec48 100644
@@ -276,7 +276,7 @@ rule_add(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth,
 	last_rule = rule_gindex + lpm->used_rules_at_depth[depth - 1];
 
 	/* Scan through rule group to see if rule already exists. */
-	for (rule_index = rule_gindex; rule_index < last_rule; rule_index++) {
+	for (; rule_index < last_rule; rule_index++) {
 
 		/* If rule already exists update its next_hop and return. */
 		if (lpm->rules_tbl[rule_index].ip == ip_masked) {
lib/librte_pmd_igb/e1000_rxtx.c +0 -2
index a891d12..96b0682 100644
@@ -1247,8 +1247,6 @@ eth_igb_tx_queue_setup(struct rte_eth_dev *dev,
 	txq->tx_ring_phys_addr = (uint64_t) tz->phys_addr;
 	txq->tx_ring = (union e1000_adv_tx_desc *) tz->addr;
 
-	size = sizeof(union e1000_adv_tx_desc) * nb_desc;
-
 	/* Allocate software ring */
 	txq->sw_ring = rte_zmalloc("txq->sw_ring",
 				   sizeof(struct igb_tx_entry) * nb_desc,
lib/librte_pmd_ixgbe/ixgbe_ethdev.c +4 -0
index f3b3cda..6f41fbe 100644
@@ -507,6 +507,10 @@ eth_ixgbevf_dev_init(__attribute__((unused)) struct eth_driver *eth_drv,
 
 	hw->mac.num_rar_entries = hw->mac.max_rx_queues;
 	diag = hw->mac.ops.reset_hw(hw);
+	if (diag != IXGBE_SUCCESS) {
+		PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", diag);
+		return (diag);
+	}
 
 	/* Allocate memory for storing MAC addresses */
 	eth_dev->data->mac_addrs = rte_zmalloc("ixgbevf", ETHER_ADDR_LEN *
Signature · 1 line
1.7.2.5
#14 lore raw

PATCH 13/22 lib: fix uninitialized variables

In reply to a message not in the archive

From: Zijie Pan <[email protected]>

Fix compilation errors caused by uninitialized variables.

---
 lib/librte_pmd_igb/e1000_rxtx.c   |    4 ++--
 lib/librte_pmd_igb/igb/e1000_vf.c |    3 ++-
 lib/librte_pmd_ixgbe/ixgbe_rxtx.c |    2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)
lib/librte_pmd_igb/e1000_rxtx.c +2 -2
index 96b0682..ef2b88b 100644
@@ -330,8 +330,8 @@ eth_igb_xmit_pkts(struct igb_tx_queue *txq, struct rte_mbuf **tx_pkts,
 	uint16_t tx_last;
 	uint16_t nb_tx;
 	uint16_t tx_ol_req;
-	uint32_t new_ctx;
-	uint32_t ctx;
+	uint32_t new_ctx = 0;
+	uint32_t ctx = 0;
 	uint32_t vlan_macip_lens;
 
 	sw_ring = txq->sw_ring;
lib/librte_pmd_igb/igb/e1000_vf.c +2 -1
index 8b81e4b..5d71210 100644
@@ -405,12 +405,13 @@ void e1000_update_mc_addr_list_vf(struct e1000_hw *hw,
 
 	DEBUGOUT1("MC Addr Count = %d\n", mc_addr_count);
 
+	msgbuf[0] = E1000_VF_SET_MULTICAST;
+
 	if (mc_addr_count > 30) {
 		msgbuf[0] |= E1000_VF_SET_MULTICAST_OVERFLOW;
 		mc_addr_count = 30;
 	}
 
-	msgbuf[0] = E1000_VF_SET_MULTICAST;
 	msgbuf[0] |= mc_addr_count << E1000_VT_MSGINFO_SHIFT;
 
 	for (i = 0; i < mc_addr_count; i++) {
lib/librte_pmd_ixgbe/ixgbe_rxtx.c +1 -1
index aa698a3..47922c9 100644
@@ -399,7 +399,7 @@ ixgbe_xmit_pkts(struct igb_tx_queue *txq, struct rte_mbuf **tx_pkts,
 	uint16_t nb_used;
 	uint16_t tx_ol_req;
 	uint32_t vlan_macip_lens;
-	uint32_t ctx;
+	uint32_t ctx = 0;
 	uint32_t new_ctx;
 
 	sw_ring = txq->sw_ring;
Signature · 1 line
1.7.2.5
#15 lore raw

PATCH 14/22 lib: fix non-C99 macros definitions in exported headers

In reply to a message not in the archive

From: Adrien Mazarguil <[email protected]>

The original definitions prevent external programs/libraries from compiling without warnings when using these headers and -std=gnu99 (relaxed C99 mode).

---
 lib/librte_cmdline/cmdline_cirbuf.h       |    5 +++--
 lib/librte_eal/common/include/rte_debug.h |    3 ++-
 lib/librte_eal/common/include/rte_log.h   |   15 +++++++--------
 3 files changed, 12 insertions(+), 11 deletions(-)
lib/librte_cmdline/cmdline_cirbuf.h +3 -2
index f934292..36b04ec 100644
@@ -81,9 +81,10 @@ struct cirbuf {
 /* #define CIRBUF_DEBUG */
 
 #ifdef CIRBUF_DEBUG
-#define dprintf(fmt, ...) printf("line %3.3d - " fmt, __LINE__, ##__VA_ARGS__)
+#define dprintf_(fmt, ...) printf("line %3.3d - " fmt "%.0s", __LINE__, __VA_ARGS__)
+#define dprintf(...) dprintf_(__VA_ARGS__, "dummy")
 #else
-#define dprintf(args...) do {} while(0)
+#define dprintf(...) (void)0
 #endif
 
 
lib/librte_eal/common/include/rte_debug.h +2 -1
index 451220e..1936dde 100644
@@ -77,7 +77,8 @@ void rte_dump_registers(void);
  * @param args
  *   The variable list of arguments.
  */
-#define rte_panic(format, args...) __rte_panic(__func__, format, ## args)
+#define rte_panic_(func, format, ...) __rte_panic(func, format "%.0s", __VA_ARGS__)
+#define rte_panic(...) rte_panic_(__func__, __VA_ARGS__, "dummy")
 
 /*
  * Provide notification of a critical non-recoverable error and stop.
lib/librte_eal/common/include/rte_log.h +7 -8
index d361130..9a17730 100644
@@ -274,14 +274,13 @@ int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap);
  *   - 0: Success.
  *   - Negative on error.
  */
-#define RTE_LOG(l, t, fmt, args...) ({					\
-	if ((RTE_LOG_##l <= RTE_LOG_LEVEL) &&				\
-	    (RTE_LOG_##l <= rte_logs.level) &&				\
-	    (RTE_LOGTYPE_##t & rte_logs.type)) {			\
-		rte_log(RTE_LOG_##l, RTE_LOGTYPE_##t,			\
-			  #t ": " fmt, ## args);			\
-	}								\
-})
+#define RTE_LOG(l, t, ...)					\
+	(((RTE_LOG_ ## l <= RTE_LOG_LEVEL) &&			\
+	  (RTE_LOG_ ## l <= rte_logs.level) &&			\
+	  (RTE_LOGTYPE_ ## t & rte_logs.type)) ?		\
+	 rte_log(RTE_LOG_ ## l,					\
+		 RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) :	\
+	 0)
 
 #ifdef __cplusplus
 }
Signature · 1 line
1.7.2.5
#16 lore raw

PATCH 15/22 mem: fix access to huge page with high address

In reply to a message not in the archive

The returned value of lseek is a virtual address which can be different from the offset.
Indeed, if the return address has a 64-bit canonical form, the 16 higher bits are all 1 if bit 47 is 1.

So the check was wrong. It is better to test against an error value.

---
 lib/librte_eal/linuxapp/eal/eal_memory.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
lib/librte_eal/linuxapp/eal/eal_memory.c +2 -1
index a47dab4..30a955f 100644
@@ -2,6 +2,7 @@
  *   BSD LICENSE
  * 
  *   Copyright(c) 2010-2012 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2012-2013 6WIND.
  *   All rights reserved.
  * 
  *   Redistribution and use in source and binary forms, with or without 
@@ -292,7 +293,7 @@ find_physaddr(struct hugepage *hugepg_tbl, struct hugepage_info *hpi)
 		virt_pfn = (unsigned long)hugepg_tbl[i].orig_va /
 			page_size;
 		offset = sizeof(uint64_t) * virt_pfn;
-		if (lseek(fd, offset, SEEK_SET) != offset){
+		if (lseek(fd, offset, SEEK_SET) == (off_t) -1) {
 			RTE_LOG(ERR, EAL, "%s(): seek error in /proc/self/pagemap: %s",
 					__func__, strerror(errno));
 			close(fd);
Signature · 1 line
1.7.2.5
#17 lore raw

PATCH 16/22 timer: check TSC reliability

In reply to a message not in the archive

From: Ivan Boule <[email protected]>

Read flags from /proc/cpuinfo and warn if constant_tsc or nonstop_tsc is not found.

---
 lib/librte_eal/linuxapp/eal/eal_hpet.c |   37 ++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)
lib/librte_eal/linuxapp/eal/eal_hpet.c +37 -0
index aa686b1..de05151 100644
@@ -2,6 +2,7 @@
  *   BSD LICENSE
  * 
  *   Copyright(c) 2010-2012 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2012-2013 6WIND.
  *   All rights reserved.
  * 
  *   Redistribution and use in source and binary forms, with or without 
@@ -140,6 +141,41 @@ set_rdtsc_freq(void)
 			((1.0 / eal_hpet_resolution_hz) / 1e-15);
 }
 
+static void
+check_tsc_flags(void)
+{
+	char line[512];
+	FILE *stream;
+
+	stream = fopen("/proc/cpuinfo", "r");
+	if (!stream) {
+		RTE_LOG(WARNING, EAL, "WARNING: Unable to open /proc/cpuinfo\n");
+		return;
+	}
+
+	while (fgets(line, sizeof line, stream)) {
+		char *constant_tsc;
+		char *nonstop_tsc;
+
+		if (strncmp(line, "flags", 5) != 0)
+			continue;
+
+		constant_tsc = strstr(line, "constant_tsc");
+		nonstop_tsc = strstr(line, "nonstop_tsc");
+		if (!constant_tsc || !nonstop_tsc)
+			RTE_LOG(WARNING, EAL,
+				"WARNING: cpu flags "
+				"constant_tsc=%s "
+				"nonstop_tsc=%s "
+				"-> using unreliable clock cycles !\n",
+				constant_tsc ? "yes":"no",
+				nonstop_tsc ? "yes":"no");
+		break;
+	}
+
+	fclose(stream);
+}
+
 /*
  * Open and mmap /dev/hpet (high precision event timer) that will
  * provide our time reference.
@@ -192,6 +228,7 @@ rte_eal_hpet_init(void)
 use_rdtsc:
 	internal_config.no_hpet = 1;
 	set_rdtsc_freq();
+	check_tsc_flags();
 	return 0;
 }
 
Signature · 1 line
1.7.2.5
#18 lore raw

PATCH 17/22 timer: get TSC frequency from /proc/cpuinfo

In reply to a message not in the archive

Frequency was guessed by sleeping 1 sec.
Now, read frequency from cpuinfo first.
Keep sleep method as fallback.

---
 lib/librte_eal/linuxapp/eal/eal_hpet.c |   47 ++++++++++++++++++++++++++++---
 1 files changed, 42 insertions(+), 5 deletions(-)
lib/librte_eal/linuxapp/eal/eal_hpet.c +42 -5
index de05151..d41e857 100644
@@ -129,14 +129,51 @@ hpet_msb_inc(__attribute__((unused)) void *arg)
 	}
 }
 
-static inline void
-set_rdtsc_freq(void)
+static uint64_t
+get_tsc_freq_from_cpuinfo(void)
 {
-	uint64_t start;
+	char line[256];
+	FILE *stream;
+	double dmhz;
+	uint64_t freq = 0;
+
+	stream = fopen("/proc/cpuinfo", "r");
+	if (!stream) {
+		RTE_LOG(WARNING, EAL, "WARNING: Unable to open /proc/cpuinfo\n");
+		return 0;
+	}
+
+	while (fgets(line, sizeof line, stream)) {
+		if (sscanf(line, "cpu MHz\t: %lf", &dmhz) == 1) {
+			freq = (uint64_t)(dmhz * 1000000UL);
+			break;
+		}
+	}
+
+	fclose(stream);
+	return freq;
+}
 
-	start = rte_rdtsc();
+static uint64_t
+get_tsc_freq_from_sleep(void)
+{
+	uint64_t start = rte_rdtsc();
 	sleep(1);
-	eal_hpet_resolution_hz = rte_rdtsc() - start;
+	return rte_rdtsc() - start;
+}
+
+static inline void
+set_rdtsc_freq(void)
+{
+	uint64_t freq;
+	freq = get_tsc_freq_from_cpuinfo();
+	if (!freq) {
+		RTE_LOG(WARNING, EAL, "WARNING: Cannot read CPU clock\n");
+		freq = get_tsc_freq_from_sleep();
+	}
+	RTE_LOG(INFO, EAL, "TSC clock @ %lu MHz\n",
+		(unsigned long) (freq / (1000000UL)));
+	eal_hpet_resolution_hz = freq;
 	eal_hpet_resolution_fs = (uint32_t)
 			((1.0 / eal_hpet_resolution_hz) / 1e-15);
 }
Signature · 1 line
1.7.2.5
#19 lore raw

PATCH 18/22 timer: option --vmware-tsc-map for VMware guest

In reply to a message not in the archive

From: Damien Millescamps <[email protected]>

The VMware TSC mapping uses a hook to RDPMC to read the physical TSC in the case of VMware ESXi.

Introduce new option --vmware-tsc-map, ignored if CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT is not set.

Default is CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT=y.

if CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT is set:
rte_rdtsc() selects at runtime between Vmware mapping of TSC or native TSC
else
rte_rdtsc() always uses native rdtsc.

When running DPDK on VMware guest, enable --vmware-tsc-map to read the physical TSC.
Caution: ESXi should pass monitor_control.pseudo_perfctr = TRUE otherwise it results in general protection fault.

---
 config/defconfig_i686-default-linuxapp-gcc         |    5 ++++
 config/defconfig_i686-default-linuxapp-icc         |    5 ++++
 config/defconfig_x86_64-default-linuxapp-gcc       |    5 ++++
 config/defconfig_x86_64-default-linuxapp-icc       |    5 ++++
 lib/librte_eal/common/include/rte_cycles.h         |   19 ++++++++++++++++
 lib/librte_eal/linuxapp/eal/eal.c                  |   23 ++++++++++++++++++++
 .../linuxapp/eal/include/eal_internal_cfg.h        |    1 +
 7 files changed, 63 insertions(+), 0 deletions(-)
config/defconfig_i686-default-linuxapp-gcc +5 -0
index ed54434..e64bb86 100644
@@ -121,6 +121,11 @@ CONFIG_RTE_LIBRTE_EAL_LINUXAPP=y
 CONFIG_RTE_LIBRTE_EAL_BAREMETAL=n
 
 #
+# Compile Environment Abstraction Layer to support VMware TSC map
+#
+CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT=y
+
+#
 # Compile generic ethernet library
 #
 CONFIG_RTE_LIBRTE_ETHER=y
config/defconfig_i686-default-linuxapp-icc +5 -0
index cb0d017..3f15a53 100644
@@ -121,6 +121,11 @@ CONFIG_RTE_LIBRTE_EAL_LINUXAPP=y
 CONFIG_RTE_LIBRTE_EAL_BAREMETAL=n
 
 #
+# Compile Environment Abstraction Layer to support VMware TSC map
+#
+CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT=y
+
+#
 # Compile generic ethernet library
 #
 CONFIG_RTE_LIBRTE_ETHER=y
config/defconfig_x86_64-default-linuxapp-gcc +5 -0
index 3555187..f5213d5 100644
@@ -121,6 +121,11 @@ CONFIG_RTE_LIBRTE_EAL_LINUXAPP=y
 CONFIG_RTE_LIBRTE_EAL_BAREMETAL=n
 
 #
+# Compile Environment Abstraction Layer to support VMware TSC map
+#
+CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT=y
+
+#
 # Compile generic ethernet library
 #
 CONFIG_RTE_LIBRTE_ETHER=y
config/defconfig_x86_64-default-linuxapp-icc +5 -0
index f527f53..f28943a 100644
@@ -121,6 +121,11 @@ CONFIG_RTE_LIBRTE_EAL_LINUXAPP=y
 CONFIG_RTE_LIBRTE_EAL_BAREMETAL=n
 
 #
+# Compile Environment Abstraction Layer to support VMware TSC map
+#
+CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT=y
+
+#
 # Compile generic ethernet library
 #
 CONFIG_RTE_LIBRTE_ETHER=y
lib/librte_eal/common/include/rte_cycles.h +19 -0
index a1eca6c..fa0b408 100644
@@ -2,6 +2,7 @@
  *   BSD LICENSE
  * 
  *   Copyright(c) 2010-2012 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2012-2013 6WIND.
  *   All rights reserved.
  * 
  *   Redistribution and use in source and binary forms, with or without 
@@ -48,6 +49,13 @@ extern "C" {
 
 #include <stdint.h>
 
+#ifdef RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT
+/** Global switch to use VMware mapping of TSC instead of RDTSC */
+extern int rte_cycles_vmware_tsc_map;
+#include <rte_branch_prediction.h>
+#endif
+
+
 /**
  * Read the TSC register.
  *
@@ -65,9 +73,20 @@ rte_rdtsc(void)
 		};
 	} tsc;
 
+#ifdef RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT
+	if (unlikely(rte_cycles_vmware_tsc_map)) {
+		/* ecx = 0x10000 corresponds to the Physical TSC for VMware */
+		asm volatile("rdpmc" :
+		             "=a" (tsc.lo_32),
+		             "=d" (tsc.hi_32) :
+		             "c"(0x10000));
+		return tsc.tsc_64;
+	}
+#endif
 	asm volatile("rdtsc" :
 		     "=a" (tsc.lo_32),
 		     "=d" (tsc.hi_32));
+
 	return tsc.tsc_64;
 }
 
lib/librte_eal/linuxapp/eal/eal.c +23 -0
index 8d82cc3..a63881c 100644
@@ -78,6 +78,7 @@
 #define OPT_PROC_TYPE   "proc-type"
 #define OPT_NO_SHCONF   "no-shconf"
 #define OPT_NO_HPET     "no-hpet"
+#define OPT_VMWARE_TSC_MAP   "vmware-tsc-map"
 #define OPT_NO_PCI      "no-pci"
 #define OPT_NO_HUGE     "no-huge"
 #define OPT_FILE_PREFIX "file-prefix"
@@ -125,6 +126,9 @@ struct lcore_config lcore_config[RTE_MAX_LCORE];
 /* internal configuration */
 struct internal_config internal_config;
 
+/* used by rte_rdtsc() */
+int rte_cycles_vmware_tsc_map;
+
 /* Return a pointer to the configuration structure */
 struct rte_config *
 rte_eal_get_configuration(void)
@@ -264,6 +268,7 @@ eal_usage(const char *prgname)
 	       "  --"OPT_HUGE_DIR" : directory where hugetlbfs is mounted\n"
 	       "  --"OPT_PROC_TYPE": type of this process\n"
 	       "  --"OPT_FILE_PREFIX": prefix for hugepage filenames\n"
+	       "  --"OPT_VMWARE_TSC_MAP"  : use VMware TSC map instead of native RDTSC\n\n"
 	       "\nEAL options for DEBUG use only:\n"
 	       "  --"OPT_NO_HUGE"  : use malloc instead of hugetlbfs\n"
 	       "  --"OPT_NO_PCI"   : disable pci\n"
@@ -379,6 +384,7 @@ eal_parse_args(int argc, char **argv)
 		{OPT_NO_HUGE, 0, 0, 0},
 		{OPT_NO_PCI, 0, 0, 0},
 		{OPT_NO_HPET, 0, 0, 0},
+		{OPT_VMWARE_TSC_MAP, 0, 0, 0},
 		{OPT_HUGE_DIR, 1, 0, 0},
 		{OPT_NO_SHCONF, 0, 0, 0},
 		{OPT_PROC_TYPE, 1, 0, 0},
@@ -399,6 +405,8 @@ eal_parse_args(int argc, char **argv)
 	internal_config.no_hpet = 1;
 #endif
 
+	internal_config.vmware_tsc_map = 0;
+
 	while ((opt = getopt_long(argc, argvopt, "b:c:m:n:r:v",
 				  lgopts, &option_index)) != EOF) {
 
@@ -464,6 +472,9 @@ eal_parse_args(int argc, char **argv)
 			else if (!strcmp(lgopts[option_index].name, OPT_NO_HPET)) {
 				internal_config.no_hpet = 1;
 			}
+			else if (!strcmp(lgopts[option_index].name, OPT_VMWARE_TSC_MAP)) {
+				internal_config.vmware_tsc_map = 1;
+			}
 			else if (!strcmp(lgopts[option_index].name, OPT_NO_SHCONF)) {
 				internal_config.no_shconf = 1;
 			}
@@ -547,6 +558,18 @@ rte_eal_init(int argc, char **argv)
 			internal_config.memory = eal_get_hugepage_mem_size();
 	}
 
+	if (internal_config.vmware_tsc_map == 1) {
+#ifdef RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT
+		rte_cycles_vmware_tsc_map = 1;
+		RTE_LOG (DEBUG, EAL, "Using VMware TSC map, "
+				"you must have monitor_control.pseudo_perfctr = TRUE\n");
+#else
+		RTE_LOG (WARNING, EAL, "Ignoring --vmware-tsc-map because "
+				"RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT is not set\n");
+#endif
+	} else {
+		RTE_LOG (DEBUG, EAL, "Using native RDTSC\n");
+	}
 	rte_srand(rte_rdtsc());
 	rte_config_init();
 
lib/librte_eal/linuxapp/eal/include/eal_internal_cfg.h +1 -0
index 70d5afb..470b746 100644
@@ -63,6 +63,7 @@ struct internal_config {
 	volatile unsigned no_hugetlbfs;   /* true to disable hugetlbfs */
 	volatile unsigned no_pci;         /* true to disable PCI */
 	volatile unsigned no_hpet;        /* true to disable HPET */
+	volatile unsigned vmware_tsc_map; /* true to use VMware TSC mapping instead of native TSC */
 	volatile unsigned no_shconf;      /* true if there is no shared config */
 	volatile enum rte_proc_type_t process_type; /* multi-process proc type */
 	const char *hugefile_prefix;      /* the base filename of hugetlbfs files */
Signature · 1 line
1.7.2.5
#20 lore raw

PATCH 19/22 pci: reference driver structure for each device

In reply to a message not in the archive

From: Adrien Mazarguil <[email protected]>

Add a driver reference (if available) to every PCI devices, even when blacklisted. This information is made available in the global device_list variable so users know which network devices are managed or ignored.

---
 lib/librte_eal/common/eal_common_pci.c  |    3 +--
 lib/librte_eal/common/include/rte_pci.h |    2 ++
 lib/librte_eal/linuxapp/eal/eal_pci.c   |   11 ++++++++++-
 3 files changed, 13 insertions(+), 3 deletions(-)
lib/librte_eal/common/eal_common_pci.c +1 -2
index fe24265..73d8fb3 100644
@@ -81,9 +81,8 @@ pci_probe_all_drivers(struct rte_pci_device *dev)
 {
 	struct rte_pci_driver *dr = NULL;
 
+	dev->blacklisted = !!is_blacklisted(dev);
 	TAILQ_FOREACH(dr, &driver_list, next) {
-		if (is_blacklisted(dev))
-			return -1;
 		if (rte_eal_pci_probe_one_driver(dr, dev) == 0)
 			return 0;
 	}
lib/librte_eal/common/include/rte_pci.h +2 -0
index f2128b5..b465995 100644
@@ -111,6 +111,8 @@ struct rte_pci_device {
 	struct rte_pci_id id;                   /**< PCI ID. */
 	struct rte_pci_resource mem_resource;   /**< PCI Memory Resource */
 	struct rte_intr_handle intr_handle;     /**< Interrupt handle */
+	const struct rte_pci_driver *driver;    /**< Associated driver */
+	unsigned int blacklisted:1;             /**< Device is blacklisted */
 };
 
 /** Any PCI device identifier (vendor, device, ...) */
lib/librte_eal/linuxapp/eal/eal_pci.c +10 -1
index 78687d6..86002bd 100644
@@ -731,7 +731,8 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d
 		dev->id.vendor_id, dev->id.device_id, dr->name);
 
 		/* Unbind PCI devices if needed */
-		if (module_name != NULL) {
+		if ((!dev->blacklisted) &&
+		    (module_name != NULL)) {
 			if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 			/* unbind current driver, bind ours */
 				if (pci_unbind_kernel_driver(dev) < 0)
@@ -743,6 +744,14 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d
 			if (pci_uio_map_resource(dev) < 0)
 				return -1;
 		}
+
+		/* reference driver structure */
+		dev->driver = dr;
+
+		/* no initialization when blacklisted */
+		if (dev->blacklisted)
+			return -1;
+
 		/* call the driver devinit() function */
 		return dr->devinit(dr, dev);
 
Signature · 1 line
1.7.2.5
#21 lore raw

PATCH 20/22 pci: allow drivers to be bound several times to the same PCI device

In reply to a message not in the archive

From: Adrien Mazarguil <[email protected]>

Drivers with the flag RTE_PCI_DRV_MULTIPLE enabled will be bound several times to the same device until they return an error.

These drivers must internally keep track of each device state in order for this to work reliably.

This flag is currently required for Ethernet adapters with several physical ports but a single address on the PCI bus.

It is currently used by librte_pmd_mlx4 that we are developping.

---
 lib/librte_eal/common/eal_common_pci.c  |   14 ++++++++++++--
 lib/librte_eal/common/include/rte_pci.h |    3 +++
 2 files changed, 15 insertions(+), 2 deletions(-)
lib/librte_eal/common/eal_common_pci.c +12 -2
index 73d8fb3..3a6ab70 100644
@@ -2,6 +2,7 @@
  *   BSD LICENSE
  * 
  *   Copyright(c) 2010-2012 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2013 6WIND.
  *   All rights reserved.
  * 
  *   Redistribution and use in source and binary forms, with or without 
@@ -75,6 +76,10 @@ static int is_blacklisted(struct rte_pci_device *dev)
  * If vendor/device ID match, call the devinit() function of all
  * registered driver for the given device. Return -1 if no driver is
  * found for this device.
+ * For drivers with the RTE_PCI_DRV_MULTIPLE flag enabled, register
+ * the same device multiple times until failure to do so.
+ * It is required for non-Intel NIC drivers provided by third-parties such
+ * as 6WIND.
  */
 static int
 pci_probe_all_drivers(struct rte_pci_device *dev)
@@ -83,8 +88,13 @@ pci_probe_all_drivers(struct rte_pci_device *dev)
 
 	dev->blacklisted = !!is_blacklisted(dev);
 	TAILQ_FOREACH(dr, &driver_list, next) {
-		if (rte_eal_pci_probe_one_driver(dr, dev) == 0)
-			return 0;
+		if (rte_eal_pci_probe_one_driver(dr, dev))
+			continue;
+		/* initialize subsequent driver instances for this device */
+		if (dr->drv_flags & RTE_PCI_DRV_MULTIPLE)
+			while (rte_eal_pci_probe_one_driver(dr, dev) == 0)
+				;
+		return 0;
 	}
 	return -1;
 }
lib/librte_eal/common/include/rte_pci.h +3 -0
index b465995..1007f51 100644
@@ -2,6 +2,7 @@
  *   BSD LICENSE
  * 
  *   Copyright(c) 2010-2012 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2013 6WIND.
  *   All rights reserved.
  * 
  *   Redistribution and use in source and binary forms, with or without 
@@ -154,6 +155,8 @@ struct rte_pci_driver {
 
 /**< Device needs igb_uio kernel module */
 #define RTE_PCI_DRV_NEED_IGB_UIO 0x0001
+/**< Device driver must be registered several times until failure */
+#define RTE_PCI_DRV_MULTIPLE 0x0002
 
 /**
  * Probe the PCI bus for registered drivers.
Signature · 1 line
1.7.2.5
#22 lore raw

PATCH 21/22 igb_uio: fix driver dependency

In reply to a message not in the archive

From: Damien Millescamps <[email protected]>

Allow to run without igb_uio if probed devices don't require it.

The condition for exiting with an error is:
- Tested driver is needed by a probed device
AND
- Tested driver needs igb_uio

---
 lib/librte_eal/linuxapp/eal/eal_pci.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
lib/librte_eal/linuxapp/eal/eal_pci.c +7 -5
index 86002bd..882fd6f 100644
@@ -701,15 +701,12 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d
 {
 	struct rte_pci_id *id_table;
 	const char *module_name = NULL;
-	int ret;
+	int uio_status = -1;
 
 	if (dr->drv_flags & RTE_PCI_DRV_NEED_IGB_UIO)
 		module_name = IGB_UIO_NAME;
 
-	ret = pci_uio_check_module(module_name);
-	if (ret != 0)
-		rte_exit(1, "The %s module is required by the %s driver\n",
-				module_name, dr->name);
+	uio_status = pci_uio_check_module(module_name);
 
 	for (id_table = dr->id_table ; id_table->vendor_id != 0; id_table++) {
 
@@ -730,6 +727,11 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d
 		RTE_LOG(DEBUG, EAL, "probe driver: %x:%x %s\n",
 		dev->id.vendor_id, dev->id.device_id, dr->name);
 
+		if ((!dev->blacklisted) && (uio_status != 0)) {
+			rte_exit(1, "The %s module is required by the %s driver\n",
+					module_name, dr->name);
+		}
+
 		/* Unbind PCI devices if needed */
 		if ((!dev->blacklisted) &&
 		    (module_name != NULL)) {
Signature · 1 line
1.7.2.5
#23 lore raw

PATCH 22/22 igb_uio: fix build with kernel >= 3.8

In reply to a message not in the archive

From: Nicolas Dichtel <[email protected]>

__devinit has been removed in linux commit 54b956b903 ("Remove __dev* markings from init.h", 3.8-rc4).

---
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
lib/librte_eal/linuxapp/igb_uio/igb_uio.c +4 -0
index 51733f6..4e54c46 100644
@@ -255,7 +255,11 @@ igbuio_pci_release_iomem(struct uio_info *info)
 	}
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
 static int __devinit
+#else
+static int
+#endif
 igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
 	struct rte_uio_pci_dev *udev;
Signature · 1 line
1.7.2.5
#24 lore raw
In reply to a message not in the archive

All can be applied.

Quoted 87 lines · Thomas Monjalon

Here are some patches which were not integrated by Intel in their 1.2.3 version.

---

Adrien Mazarguil (3):
lib: fix non-C99 macros definitions in exported headers
pci: reference driver structure for each device
pci: allow drivers to be bound several times to the same PCI device

Damien Millescamps (3):
app: fix config crash in testpmd
timer: option --vmware-tsc-map for VMware guest
igb_uio: fix driver dependency

Didier Pallard (2):
mk: fix verbose display of install command
mk: add a makefile for shared libraries

Ivan Boule (3):
app: fix volatile read for GCC >= 4.6
app: fix testpmd compliance with __rte_mbuf_sanity_check()
timer: check TSC reliability

Nicolas Dichtel (1):
igb_uio: fix build with kernel >= 3.8

Olivier Matz (1):
app: use (void)variable when unused

Samuel Gauthier (1):
mk: use $CC to detect toolchain version

Thierry Herbelot (1):
mk: fix typo in LDFLAGS for 32-bit

Thomas Monjalon (3):
app: fix autotest summary in error cases
mem: fix access to huge page with high address
timer: get TSC frequency from /proc/cpuinfo

Zijie Pan (4):
mk: allow corei7-avx flag with gcc 4.7
app: fix unused values
lib: fix unused values
lib: fix uninitialized variables

  app/test-pmd/config.c                              |   21 ++--
  app/test-pmd/testpmd.c                             |    1 +
  app/test-pmd/txonly.c                              |    1 +
  app/test/autotest.py                               |    7 +-
  app/test/test.c                                    |    1 -
  app/test/test_hash.c                               |    6 +-
  app/test/test_lpm.c                                |    4 +-
  app/test/test_memory.c                             |    4 +-
  app/test/test_ring.c                               |    4 +-
  config/defconfig_i686-default-linuxapp-gcc         |    5 +
  config/defconfig_i686-default-linuxapp-icc         |    5 +
  config/defconfig_x86_64-default-linuxapp-gcc       |    5 +
  config/defconfig_x86_64-default-linuxapp-icc       |    5 +
  lib/librte_cmdline/cmdline_cirbuf.h                |    5 +-
  lib/librte_cmdline/cmdline_parse_ipaddr.c          |    1 -
  lib/librte_eal/common/eal_common_pci.c             |   17 ++-
  lib/librte_eal/common/include/rte_cycles.h         |   19 +++
  lib/librte_eal/common/include/rte_debug.h          |    3 +-
  lib/librte_eal/common/include/rte_log.h            |   15 +-
  lib/librte_eal/common/include/rte_pci.h            |    5 +
  lib/librte_eal/linuxapp/eal/eal.c                  |   23 +++
  lib/librte_eal/linuxapp/eal/eal_hpet.c             |   84 +++++++++++-
  lib/librte_eal/linuxapp/eal/eal_memory.c           |    3 +-
  lib/librte_eal/linuxapp/eal/eal_pci.c              |   23 +++-
  lib/librte_eal/linuxapp/eal/eal_thread.c           |    2 -
  .../linuxapp/eal/include/eal_internal_cfg.h        |    1 +
  lib/librte_eal/linuxapp/igb_uio/igb_uio.c          |    4 +
  lib/librte_lpm/rte_lpm.c                           |    2 +-
  lib/librte_pmd_igb/e1000_rxtx.c                    |    6 +-
  lib/librte_pmd_igb/igb/e1000_vf.c                  |    3 +-
  lib/librte_pmd_ixgbe/ixgbe_ethdev.c                |    4 +
  lib/librte_pmd_ixgbe/ixgbe_rxtx.c                  |    2 +-
  mk/arch/i686/rte.vars.mk                           |    2 +-
  mk/internal/rte.install-post.mk                    |    2 +-
  mk/{arch/i686/rte.vars.mk => rte.extshared.mk}     |   93 ++++++-------
  mk/rte.shared.mk                                   |  141 ++++++++++++++++++++
  mk/toolchain/gcc/rte.toolchain-compat.mk           |    6 +-
  37 files changed, 417 insertions(+), 118 deletions(-)

copy mk/{arch/i686/rte.vars.mk => rte.extshared.mk} (55%) create mode 100644 mk/rte.shared.mk

Signature · 4 lines
-------
This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and contains information that is confidential and proprietary to 6WIND. All unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

Ce courriel ainsi que toutes les pièces jointes, est uniquement destiné à son ou ses destinataires. Il contient des informations confidentielles qui sont la propriété de 6WIND. Toute révélation, distribution ou copie des informations qu'il contient est strictement interdite. Si vous avez reçu ce message par erreur, veuillez immédiatement le signaler à l'émetteur et détruire toutes les données reçues.

A message that is not in the archive (sent off-list or not yet received): [email protected]