* [RFC 05/23] eal: failure to parse args returns error
From: Aaron Conole @ 2016-12-30 15:26 UTC (permalink / raw)
To: dev
In-Reply-To: <1483111580-5397-1-git-send-email-aconole@redhat.com>
It's possible that the application could take a corrective action here,
and either prompt the user for different arguments, or at least perform
a better logging. Exiting this early prevents any useful information
gathering from the application layer.
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lib/librte_eal/linuxapp/eal/eal.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index ff70107..1c371f6 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -773,8 +773,11 @@ rte_eal_init(int argc, char **argv)
}
fctret = eal_parse_args(argc, argv);
- if (fctret < 0)
- exit(1);
+ if (fctret < 0) {
+ RTE_LOG (ERR, EAL, "Invalid 'command line' arguments\n");
+ errno = EINVAL;
+ return -1;
+ }
if (internal_config.no_hugetlbfs == 0 &&
internal_config.process_type != RTE_PROC_SECONDARY &&
--
2.7.4
^ permalink raw reply related
* [RFC 06/23] eal-common: introduce a way to query cpu support
From: Aaron Conole @ 2016-12-30 15:26 UTC (permalink / raw)
To: dev
In-Reply-To: <1483111580-5397-1-git-send-email-aconole@redhat.com>
This adds a new API to check for the eal cpu versions.
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lib/librte_eal/common/eal_common_cpuflags.c | 13 +++++++++++--
lib/librte_eal/common/include/generic/rte_cpuflags.h | 9 +++++++++
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_cpuflags.c b/lib/librte_eal/common/eal_common_cpuflags.c
index b5f76f7..2c2127b 100644
--- a/lib/librte_eal/common/eal_common_cpuflags.c
+++ b/lib/librte_eal/common/eal_common_cpuflags.c
@@ -43,6 +43,13 @@
void
rte_cpu_check_supported(void)
{
+ if (!rte_cpu_is_supported())
+ exit(1);
+}
+
+bool
+rte_cpu_is_supported(void)
+{
/* This is generated at compile-time by the build system */
static const enum rte_cpu_flag_t compile_time_flags[] = {
RTE_COMPILE_TIME_CPUFLAGS
@@ -57,14 +64,16 @@ rte_cpu_check_supported(void)
fprintf(stderr,
"ERROR: CPU feature flag lookup failed with error %d\n",
ret);
- exit(1);
+ return false;
}
if (!ret) {
fprintf(stderr,
"ERROR: This system does not support \"%s\".\n"
"Please check that RTE_MACHINE is set correctly.\n",
rte_cpu_get_flag_name(compile_time_flags[i]));
- exit(1);
+ return false;
}
}
+
+ return true;
}
diff --git a/lib/librte_eal/common/include/generic/rte_cpuflags.h b/lib/librte_eal/common/include/generic/rte_cpuflags.h
index 71321f3..e4342ad 100644
--- a/lib/librte_eal/common/include/generic/rte_cpuflags.h
+++ b/lib/librte_eal/common/include/generic/rte_cpuflags.h
@@ -40,6 +40,7 @@
*/
#include <errno.h>
+#include <stdbool.h>
/**
* Enumeration of all CPU features supported
@@ -82,4 +83,12 @@ rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature);
void
rte_cpu_check_supported(void);
+/**
+ * This function checks that the currently used CPU supports the CPU features
+ * that were specified at compile time. It is called automatically within the
+ * EAL, so does not need to be used by applications. This version returns a
+ * result so that decisions may be made (for instance, graceful shutdowns).
+ */
+bool
+rte_cpu_is_supported(void);
#endif /* _RTE_CPUFLAGS_H_ */
--
2.7.4
^ permalink raw reply related
* [RFC 07/23] eal: Signal error when CPU isn't supported
From: Aaron Conole @ 2016-12-30 15:26 UTC (permalink / raw)
To: dev
In-Reply-To: <1483111580-5397-1-git-send-email-aconole@redhat.com>
It's now possible to gracefully exit the application, or for
applications which support non-dpdk datapaths working in concert with
DPDK datapaths, there no longer is the possibility of exiting for
unsupported CPUs.
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lib/librte_eal/linuxapp/eal/eal.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 1c371f6..909f6b7 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -751,7 +751,10 @@ rte_eal_init(int argc, char **argv)
char thread_name[RTE_MAX_THREAD_NAME_LEN];
/* checks if the machine is adequate */
- rte_cpu_check_supported();
+ if (!rte_cpu_is_supported()) {
+ errno = ENOTSUP;
+ return -1;
+ }
if (!rte_atomic32_test_and_set(&run_once))
return -1;
--
2.7.4
^ permalink raw reply related
* [RFC 08/23] eal: do not panic on memzone initialization fails
From: Aaron Conole @ 2016-12-30 15:26 UTC (permalink / raw)
To: dev
In-Reply-To: <1483111580-5397-1-git-send-email-aconole@redhat.com>
When memzone initialization fails, report the error to the calling
application rather than panic().
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lib/librte_eal/linuxapp/eal/eal.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 909f6b7..31d3bba 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -828,8 +828,11 @@ rte_eal_init(int argc, char **argv)
/* the directories are locked during eal_hugepage_info_init */
eal_hugedirs_unlock();
- if (rte_eal_memzone_init() < 0)
- rte_panic("Cannot init memzone\n");
+ if (rte_eal_memzone_init() < 0) {
+ RTE_LOG (ERR, EAL, "Cannot init memzone\n");
+ errno = ENODEV;
+ return -1;
+ }
if (rte_eal_tailqs_init() < 0)
rte_panic("Cannot init tail queues for objects\n");
--
2.7.4
^ permalink raw reply related
* [RFC 09/23] eal: set errno when exiting for already called
From: Aaron Conole @ 2016-12-30 15:26 UTC (permalink / raw)
To: dev
In-Reply-To: <1483111580-5397-1-git-send-email-aconole@redhat.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lib/librte_eal/linuxapp/eal/eal.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 31d3bba..f996047 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -756,8 +756,10 @@ rte_eal_init(int argc, char **argv)
return -1;
}
- if (!rte_atomic32_test_and_set(&run_once))
+ if (!rte_atomic32_test_and_set(&run_once)) {
+ errno = EALREADY;
return -1;
+ }
logid = strrchr(argv[0], '/');
logid = strdup(logid ? logid + 1: argv[0]);
--
2.7.4
^ permalink raw reply related
* [RFC 10/23] eal: Do not panic on log failures
From: Aaron Conole @ 2016-12-30 15:26 UTC (permalink / raw)
To: dev
In-Reply-To: <1483111580-5397-1-git-send-email-aconole@redhat.com>
When log initialization fails, it's generally because the fopencookie
failed. While this is rare in practice, it could happen. Return
'Operation Not Supported' in errno, and let the caller know this error
occured.
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lib/librte_eal/linuxapp/eal/eal.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index f996047..a23ba17 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -813,8 +813,11 @@ rte_eal_init(int argc, char **argv)
rte_config_init();
- if (rte_eal_log_init(logid, internal_config.syslog_facility) < 0)
- rte_panic("Cannot init logs\n");
+ if (rte_eal_log_init(logid, internal_config.syslog_facility) < 0) {
+ RTE_LOG (ERR, EAL, "Cannot init logs\n");
+ errno = ENOTSUP;
+ return -1;
+ }
if (rte_eal_pci_init() < 0)
rte_panic("Cannot init PCI\n");
--
2.7.4
^ permalink raw reply related
* [RFC 11/23] eal: Do not panic on pci-probe
From: Aaron Conole @ 2016-12-30 15:26 UTC (permalink / raw)
To: dev
In-Reply-To: <1483111580-5397-1-git-send-email-aconole@redhat.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lib/librte_eal/linuxapp/eal/eal.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index a23ba17..018d359 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -819,8 +819,11 @@ rte_eal_init(int argc, char **argv)
return -1;
}
- if (rte_eal_pci_init() < 0)
- rte_panic("Cannot init PCI\n");
+ if (rte_eal_pci_init() < 0) {
+ RTE_LOG (ERR, EAL, "Cannot init PCI\n");
+ errno = EPERM;
+ return -1;
+ }
#ifdef VFIO_PRESENT
if (rte_eal_vfio_setup() < 0)
--
2.7.4
^ permalink raw reply related
* [RFC 12/23] eal: do not panic on vfio failure
From: Aaron Conole @ 2016-12-30 15:26 UTC (permalink / raw)
To: dev
In-Reply-To: <1483111580-5397-1-git-send-email-aconole@redhat.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lib/librte_eal/linuxapp/eal/eal.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 018d359..878ba7a 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -826,8 +826,11 @@ rte_eal_init(int argc, char **argv)
}
#ifdef VFIO_PRESENT
- if (rte_eal_vfio_setup() < 0)
- rte_panic("Cannot init VFIO\n");
+ if (rte_eal_vfio_setup() < 0) {
+ RTE_LOG (ERR, EAL, "Cannot init VFIO\n");
+ errno = ENOTSUP;
+ return -1;
+ }
#endif
if (rte_eal_memory_init() < 0)
--
2.7.4
^ permalink raw reply related
* [RFC 13/23] eal: do not panic on memory init
From: Aaron Conole @ 2016-12-30 15:26 UTC (permalink / raw)
To: dev
In-Reply-To: <1483111580-5397-1-git-send-email-aconole@redhat.com>
This can only happen when access to hugepages (either as primary or
secondary process) fails (and that is usually permissions).
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lib/librte_eal/linuxapp/eal/eal.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 878ba7a..050543c 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -833,8 +833,11 @@ rte_eal_init(int argc, char **argv)
}
#endif
- if (rte_eal_memory_init() < 0)
- rte_panic("Cannot init memory\n");
+ if (rte_eal_memory_init() < 0) {
+ RTE_LOG (ERR, EAL, "Cannot init memory\n");
+ errno = EACCES;
+ return -1;
+ }
/* the directories are locked during eal_hugepage_info_init */
eal_hugedirs_unlock();
--
2.7.4
^ permalink raw reply related
* [RFC 14/23] eal: do not panic on tailq init
From: Aaron Conole @ 2016-12-30 15:26 UTC (permalink / raw)
To: dev
In-Reply-To: <1483111580-5397-1-git-send-email-aconole@redhat.com>
There are some theoretical racy conditions in the system that _could_
cause early tailq init to fail; however, no need to panic the
application. While it can't continue using DPDK, it could make better
alerts to the user.
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lib/librte_eal/common/eal_common_tailqs.c | 4 ++--
lib/librte_eal/linuxapp/eal/eal.c | 7 +++++--
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_tailqs.c b/lib/librte_eal/common/eal_common_tailqs.c
index bb08ec8..b856ec9 100644
--- a/lib/librte_eal/common/eal_common_tailqs.c
+++ b/lib/librte_eal/common/eal_common_tailqs.c
@@ -188,8 +188,8 @@ rte_eal_tailqs_init(void)
if (t->head == NULL) {
RTE_LOG(ERR, EAL,
"Cannot initialize tailq: %s\n", t->name);
- /* no need to TAILQ_REMOVE, we are going to panic in
- * rte_eal_init() */
+ /* no need to TAILQ_REMOVE, we are going to disallow re-attemtps
+ * for rte_eal_init(). */
goto fail;
}
}
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 050543c..3616515 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -848,8 +848,11 @@ rte_eal_init(int argc, char **argv)
return -1;
}
- if (rte_eal_tailqs_init() < 0)
- rte_panic("Cannot init tail queues for objects\n");
+ if (rte_eal_tailqs_init() < 0) {
+ RTE_LOG (ERR, EAL, "Cannot init tail queues for objects\n");
+ errno = ENOTSUP;
+ return -1;
+ }
if (rte_eal_alarm_init() < 0)
rte_panic("Cannot init interrupt-handling thread\n");
--
2.7.4
^ permalink raw reply related
* [RFC 15/23] eal: do not panic on alarm init
From: Aaron Conole @ 2016-12-30 15:26 UTC (permalink / raw)
To: dev
In-Reply-To: <1483111580-5397-1-git-send-email-aconole@redhat.com>
rte_eal_alarm_init() call uses the linux timerfd framework to create a
poll()-able timer using standard posix file operations. This could fail
for a few reasons given in the man-pages, but many could be
corrected by the user application. No need to panic.
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lib/librte_eal/linuxapp/eal/eal.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 3616515..ea3d50b 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -61,6 +61,7 @@
#include <rte_launch.h>
#include <rte_eal.h>
#include <rte_eal_memconfig.h>
+#include <rte_errno.h>
#include <rte_per_lcore.h>
#include <rte_lcore.h>
#include <rte_log.h>
@@ -854,8 +855,12 @@ rte_eal_init(int argc, char **argv)
return -1;
}
- if (rte_eal_alarm_init() < 0)
- rte_panic("Cannot init interrupt-handling thread\n");
+ if (rte_eal_alarm_init() < 0) {
+ RTE_LOG (ERR, EAL, "Cannot init interrupt-handling thread\n");
+ /* rte_eal_alarm_init sets rte_errno on failure. */
+ errno = rte_errno;
+ return -1;
+ }
if (rte_eal_timer_init() < 0)
rte_panic("Cannot init HPET or TSC timers\n");
--
2.7.4
^ permalink raw reply related
* [RFC 16/23] eal: convert timer_init not to call panic
From: Aaron Conole @ 2016-12-30 15:26 UTC (permalink / raw)
To: dev
In-Reply-To: <1483111580-5397-1-git-send-email-aconole@redhat.com>
After code inspection, there is no way for eal_timer_init() to fail. It
simply returns 0 in all cases. As such, this test could either go-away
or stay here as 'future-proofing'.
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lib/librte_eal/linuxapp/eal/eal.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index ea3d50b..4206bca 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -862,8 +862,11 @@ rte_eal_init(int argc, char **argv)
return -1;
}
- if (rte_eal_timer_init() < 0)
- rte_panic("Cannot init HPET or TSC timers\n");
+ if (rte_eal_timer_init() < 0) {
+ RTE_LOG (ERR, EAL, "Cannot init HPET or TSC timers\n");
+ errno = ENOTSUP;
+ return -1;
+ }
eal_check_mem_on_local_socket();
--
2.7.4
^ permalink raw reply related
* [RFC 17/23] eal: change the private pipe call to reflect errno
From: Aaron Conole @ 2016-12-30 15:26 UTC (permalink / raw)
To: dev
In-Reply-To: <1483111580-5397-1-git-send-email-aconole@redhat.com>
There could be some confusion as to why the call failed - this change
will always reflect the value of the error in rte_error.
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lib/librte_eal/linuxapp/eal/eal_interrupts.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
index 47a3b20..52cb649 100644
--- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c
+++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
@@ -872,13 +872,16 @@ rte_eal_intr_init(void)
* create a pipe which will be waited by epoll and notified to
* rebuild the wait list of epoll.
*/
- if (pipe(intr_pipe.pipefd) < 0)
+ if (pipe(intr_pipe.pipefd) < 0) {
+ rte_errno = errno;
return -1;
+ }
/* create the host thread to wait/handle the interrupt */
ret = pthread_create(&intr_thread, NULL,
eal_intr_thread_main, NULL);
if (ret != 0) {
+ rte_errno = ret;
RTE_LOG(ERR, EAL,
"Failed to create thread for interrupt handling\n");
} else {
--
2.7.4
^ permalink raw reply related
* [RFC 18/23] eal: Do not panic on interrupt thread init
From: Aaron Conole @ 2016-12-30 15:26 UTC (permalink / raw)
To: dev
In-Reply-To: <1483111580-5397-1-git-send-email-aconole@redhat.com>
When initializing the interrupt thread, there are a number of possible
reasons for failure - some of which are correctable by the application.
Do not panic() needlessly, and give the application a change to reflect
this information to the user.
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lib/librte_eal/linuxapp/eal/eal.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 4206bca..244dc29 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -881,8 +881,11 @@ rte_eal_init(int argc, char **argv)
rte_config.master_lcore, (int)thread_id, cpuset,
ret == 0 ? "" : "...");
- if (rte_eal_intr_init() < 0)
- rte_panic("Cannot init interrupt-handling thread\n");
+ if (rte_eal_intr_init() < 0) {
+ RTE_LOG (ERR, EAL, "Cannot init interrupt-handling thread\n");
+ errno = rte_errno;
+ return -1;
+ }
RTE_LCORE_FOREACH_SLAVE(i) {
--
2.7.4
^ permalink raw reply related
* [RFC 19/23] eal: do not error if plugins fail to init
From: Aaron Conole @ 2016-12-30 15:26 UTC (permalink / raw)
To: dev
In-Reply-To: <1483111580-5397-1-git-send-email-aconole@redhat.com>
Plugins are useful and important. However, it seems crazy to abort
everything just because they don't initialize properly.
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lib/librte_eal/linuxapp/eal/eal.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 244dc29..68596e9 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -870,8 +870,9 @@ rte_eal_init(int argc, char **argv)
eal_check_mem_on_local_socket();
- if (eal_plugins_init() < 0)
- rte_panic("Cannot init plugins\n");
+ if (eal_plugins_init() < 0) {
+ RTE_LOG (ERR, EAL, "Cannot init plugins\n");
+ }
eal_thread_init_master(rte_config.master_lcore);
--
2.7.4
^ permalink raw reply related
* [RFC 20/23] eal_pci: Continue probing even on failures
From: Aaron Conole @ 2016-12-30 15:26 UTC (permalink / raw)
To: dev
In-Reply-To: <1483111580-5397-1-git-send-email-aconole@redhat.com>
Some devices may be inaccessible for a variety of reasons, or the
PCI-bus may be unavailable causing the whole thing to fail. Still,
better to continue attempts at probes.
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lib/librte_eal/common/eal_common_pci.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 33485bc..ca5c63e 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -69,6 +69,7 @@
#include <sys/queue.h>
#include <sys/mman.h>
+#include <rte_errno.h>
#include <rte_interrupts.h>
#include <rte_log.h>
#include <rte_pci.h>
@@ -413,6 +414,7 @@ rte_eal_pci_probe(void)
struct rte_pci_device *dev = NULL;
struct rte_devargs *devargs;
int probe_all = 0;
+ int ret_1 = 0;
int ret = 0;
if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) == 0)
@@ -427,17 +429,20 @@ rte_eal_pci_probe(void)
/* probe all or only whitelisted devices */
if (probe_all)
- ret = pci_probe_all_drivers(dev);
+ ret_1 = pci_probe_all_drivers(dev);
else if (devargs != NULL &&
devargs->type == RTE_DEVTYPE_WHITELISTED_PCI)
- ret = pci_probe_all_drivers(dev);
- if (ret < 0)
- rte_exit(EXIT_FAILURE, "Requested device " PCI_PRI_FMT
+ ret_1 = pci_probe_all_drivers(dev);
+ if (ret_1 < 0) {
+ RTE_LOG (ERR, EAL, "Requested device " PCI_PRI_FMT
" cannot be used\n", dev->addr.domain, dev->addr.bus,
dev->addr.devid, dev->addr.function);
+ rte_errno = errno;
+ ret = 1;
+ }
}
- return 0;
+ return -ret;
}
/* dump one device */
--
2.7.4
^ permalink raw reply related
* [RFC 21/23] eal: do not panic on failed PCI probe
From: Aaron Conole @ 2016-12-30 15:26 UTC (permalink / raw)
To: dev
In-Reply-To: <1483111580-5397-1-git-send-email-aconole@redhat.com>
It may even be possible to simply log the error and continue on letting
the user check the logs and restart the application when things are failed.
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lib/librte_eal/linuxapp/eal/eal.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 68596e9..503e742 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -925,8 +925,11 @@ rte_eal_init(int argc, char **argv)
rte_eal_mp_wait_lcore();
/* Probe & Initialize PCI devices */
- if (rte_eal_pci_probe())
- rte_panic("Cannot probe PCI\n");
+ if (rte_eal_pci_probe()) {
+ RTE_LOG (ERR, EAL, "Cannot probe PCI\n");
+ errno = ENOTSUP;
+ return -1;
+ }
if (rte_eal_dev_init() < 0)
rte_panic("Cannot init pmd devices\n");
--
2.7.4
^ permalink raw reply related
* [RFC 22/23] eal_common_dev: continue initializing vdevs
From: Aaron Conole @ 2016-12-30 15:26 UTC (permalink / raw)
To: dev
In-Reply-To: <1483111580-5397-1-git-send-email-aconole@redhat.com>
Even if one vdev should fail, there's no need to prevent further
processing. Log the error, and reflect it to the higher levels to
decide.
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lib/librte_eal/common/eal_common_dev.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
index 4f3b493..9889997 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -80,6 +80,7 @@ int
rte_eal_dev_init(void)
{
struct rte_devargs *devargs;
+ int ret = 0;
/*
* Note that the dev_driver_list is populated here
@@ -97,11 +98,11 @@ rte_eal_dev_init(void)
devargs->args)) {
RTE_LOG(ERR, EAL, "failed to initialize %s device\n",
devargs->virt.drv_name);
- return -1;
+ ret = -1;
}
}
- return 0;
+ return ret;
}
int rte_eal_dev_attach(const char *name, const char *devargs)
--
2.7.4
^ permalink raw reply related
* [RFC 23/23] eal: do not panic (or abort) if vdev init fails
From: Aaron Conole @ 2016-12-30 15:26 UTC (permalink / raw)
To: dev
In-Reply-To: <1483111580-5397-1-git-send-email-aconole@redhat.com>
Seems like it's possible to continue. At least, the error is reflected
properly in the logs. A user could then go and correct or investigate
the situation.
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lib/librte_eal/linuxapp/eal/eal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 503e742..cb87f15 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -932,7 +932,7 @@ rte_eal_init(int argc, char **argv)
}
if (rte_eal_dev_init() < 0)
- rte_panic("Cannot init pmd devices\n");
+ RTE_LOG (ERR, EAL, "Cannot init pmd devices\n");
rte_eal_mcfg_complete();
--
2.7.4
^ permalink raw reply related
* Re: [PATCH 2/2] vhost: start vhost servers once
From: Charles (Chas) Williams @ 2016-12-30 21:26 UTC (permalink / raw)
To: Yuanhan Liu; +Cc: dev, mtetsuyah
In-Reply-To: <20161230031501.GE21789@yliu-dev.sh.intel.com>
On 12/29/2016 10:15 PM, Yuanhan Liu wrote:
> On Thu, Dec 29, 2016 at 10:58:11AM -0500, Charles (Chas) Williams wrote:
>> On 12/29/2016 03:52 AM, Yuanhan Liu wrote:
>>> On Wed, Dec 28, 2016 at 04:10:52PM -0500, Charles (Chas) Williams wrote:
>>>> Start a vhost server once during devinit instead of during device start
>>>> and stop. Some vhost clients, QEMU, don't re-attaching to sockets when
>>>> the vhost server is stopped and later started. Preserve existing behavior
>>>> for vhost clients.
>>>
>>> I didn't quite get the idea what you are going to fix.
>>
>> The issue I am trying to fix is QEMU interaction when DPDK's vhost is
>> acting as a server to QEMU vhost clients. If you create a vhost server
>> device, it doesn't create the actual datagram socket until you call
>> .dev_start(). If you call .dev_stop() is also deletes those sockets.
>> For QEMU, this is a problem since QEMU doesn't know how to re-attach to
>> datagram sockets that have gone away.
>
> Thanks! And I'd appreciate it if you could have written the commit log
> this way firstly.
>
>> .dev_start()/.dev_stop() seems to roughly means link up and link down
>> so I understand why you might want to add/remove the datagram sockets.
>> However, in practice, this doesn't seem to make much sense for a DPDK
>> vhost server.
>
> Agree.
>
>> This doesn't seem like the right way to indicate link
>> status to vhost clients.
>>
>> It seems like it would just be easier to do this for both clients and
>> servers, but I don't know why it was done this way originally so I
>> choose to keep the client behavior.
>
> I don't think there are any differences between DPDK acting as client or
> server. To me, the right logic seems to be (for both DPDK as server and
> client).
>
> For register,
> - register the vhost socket at probe stage (either at rte_pmd_vhost_probe
> or at eth_dev_vhost_create).
> - start the vhost session right after the register when we haven't started
> it before.
>
> For unregister,
> - invoke rte_vhost_driver_unregister() at rte_pmd_vhost_remove().
OK. This will be much easier than what I submitted.
> For dev_start/stop,
> - set allow_queuing to 1/0 for start/stop, respectively.
Unfortunately, I don't think this will work. new_device() doesn't happen
until a client connects. allow_queueing seems to be following the status
of the "wire" as it where. .dev_start()/.dev_stop() is the link of local
port connected to the wire (administratively up or down as it where).
.dev_start() can happen before new_device() and attempting to RX for a
client that doesn't exist doesn't seem like a good idea. Perhaps another
flag that follows dev_started, but for the queues?
^ permalink raw reply
* Re: [PATCH 22/25] net/qede/base: add support for new firmware
From: Mody, Rasesh @ 2016-12-31 7:40 UTC (permalink / raw)
To: Ferruh Yigit, dev@dpdk.org; +Cc: Dept-Eng DPDK Dev
In-Reply-To: <0442ab3b-307d-de69-2c8b-ce1258a03ab9@intel.com>
Hi Ferruh,
> From: Ferruh Yigit [mailto:ferruh.yigit@intel.com]
> Sent: Friday, December 23, 2016 7:40 AM
>
> On 12/3/2016 9:11 AM, Rasesh Mody wrote:
> > Add support for 8.14.x.x firmware.
>
> Is it possible to list what has been changed with new FW here?
The new firmware adds support for external PHY BCM8485x; configures fixed link speed with transceiver/cable not supporting negotiation; supports engine swap; supports overriding PCIe preset equalization value; checks pause too long for ports and reads die temperature every second for shutdown threshold.
It includes change in FLR flow when there is a SW initiated FLR.
Thanks!
-Rasesh
>
> >
> > Signed-off-by: Rasesh Mody <Rasesh.Mody@cavium.com>
> > ---
> <...>
^ permalink raw reply
* Re: [PATCH 23/25] net/qede/base: semantic/formatting changes
From: Mody, Rasesh @ 2016-12-31 7:41 UTC (permalink / raw)
To: Ferruh Yigit, dev@dpdk.org; +Cc: Dept-Eng DPDK Dev
In-Reply-To: <fff02fac-93b7-068e-ba49-93a360be6b99@intel.com>
> From: Ferruh Yigit [mailto:ferruh.yigit@intel.com]
> Sent: Friday, December 23, 2016 7:42 AM
>
> On 12/3/2016 9:11 AM, Rasesh Mody wrote:
> > This patch consists of semantic/formatting changes. It also includes
> > comment additions.
>
> As far as I can see majority of the changes are formatting, but not all.
>
> Functional changes are hard to detect in this patch, what do you think
> separating formatting/comments patches into another patch, so functional
> changes can become more visible?
There are few of places(ecore_hw_bar_size(), ecore_get_hw_info() and ecore_init_cmd_*), where there is a bit of code refactoring. However, they are not a major change. We have tried to isolate most of the functional changes and made them part of the separate patches as fit. I think, we can include a bit of description in commit message to cover it in this patch. Please let me know if you think otherwise.
> >
> > Signed-off-by: Rasesh Mody <Rasesh.Mody@cavium.com>
> > ---
> <...>
^ permalink raw reply
* [PATCH 5/5] net/qede: convert few DP_NOTICE and DP_INFO to DP_ERR
From: Rasesh Mody @ 2016-12-31 8:09 UTC (permalink / raw)
To: patil.harish, dev; +Cc: Rasesh Mody, stable, Dept-EngDPDKDev
From: Rasesh Mody <Rasesh.Mody@cavium.com>
Signed-off-by: Rasesh Mody <Rasesh.Mody@cavium.com>
---
drivers/net/qede/base/ecore_mcp.c | 2 +-
drivers/net/qede/qede_ethdev.c | 11 +++++------
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/net/qede/base/ecore_mcp.c b/drivers/net/qede/base/ecore_mcp.c
index bb13828..f634d98 100644
--- a/drivers/net/qede/base/ecore_mcp.c
+++ b/drivers/net/qede/base/ecore_mcp.c
@@ -931,7 +931,7 @@ static void ecore_mcp_send_protocol_stats(struct ecore_hwfn *p_hwfn,
hsi_param = DRV_MSG_CODE_STATS_TYPE_LAN;
break;
default:
- DP_NOTICE(p_hwfn, false, "Invalid protocol type %d\n", type);
+ DP_INFO(p_hwfn, "Invalid protocol type %d\n", type);
return;
}
diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index de8286c..ea5b22e 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -650,7 +650,7 @@ static void qede_vlan_offload_set(struct rte_eth_dev *eth_dev, int mask)
qede_vlan_filter_set(eth_dev, 0, 1);
} else {
if (qdev->configured_vlans > 1) { /* Excluding VLAN0 */
- DP_NOTICE(edev, false,
+ DP_ERR(edev,
" Please remove existing VLAN filters"
" before disabling VLAN filtering\n");
/* Signal app that VLAN filtering is still
@@ -684,7 +684,7 @@ static int qede_vlan_filter_set(struct rte_eth_dev *eth_dev,
if (on) {
if (qdev->configured_vlans == dev_info->num_vlan_filters) {
- DP_INFO(edev, "Reached max VLAN filter limit"
+ DP_ERR(edev, "Reached max VLAN filter limit"
" enabling accept_any_vlan\n");
qede_config_accept_any_vlan(qdev, true);
return 0;
@@ -849,14 +849,13 @@ static int qede_dev_configure(struct rte_eth_dev *eth_dev)
if (edev->num_hwfns > 1) {
if (eth_dev->data->nb_rx_queues < 2 ||
eth_dev->data->nb_tx_queues < 2) {
- DP_NOTICE(edev, false,
- "100G mode needs min. 2 RX/TX queues\n");
+ DP_ERR(edev, "100G mode needs min. 2 RX/TX queues\n");
return -EINVAL;
}
if ((eth_dev->data->nb_rx_queues % 2 != 0) ||
(eth_dev->data->nb_tx_queues % 2 != 0)) {
- DP_NOTICE(edev, false,
+ DP_ERR(edev,
"100G mode needs even no. of RX/TX queues\n");
return -EINVAL;
}
@@ -867,7 +866,7 @@ static int qede_dev_configure(struct rte_eth_dev *eth_dev)
eth_dev->data->scattered_rx = 1;
if (rxmode->enable_lro == 1) {
- DP_INFO(edev, "LRO is not supported\n");
+ DP_ERR(edev, "LRO is not supported\n");
return -EINVAL;
}
--
1.7.10.3
^ permalink raw reply related
* [PATCH 1/5] net/qede: fix scatter-gather issue
From: Rasesh Mody @ 2016-12-31 8:16 UTC (permalink / raw)
To: dev; +Cc: Harish Patil, stable, Dept-EngDPDKDev
From: Harish Patil <harish.patil@qlogic.com>
- Make qede_process_sg_pkts() inline and add unlikely check
- Fix mbuf segment chaining logic in qede_process_sg_pkts()
- Change qede_encode_sg_bd() to return total segments required
- Fix first TX buffer descriptor's length
- Replace repeatitive code using a macro
Fixes: bec0228816c0 ("net/qede: support scatter gather")
Signed-off-by: Harish Patil <harish.patil@qlogic.com>
---
drivers/net/qede/qede_rxtx.c | 139 ++++++++++++++++++++----------------------
drivers/net/qede/qede_rxtx.h | 4 --
2 files changed, 65 insertions(+), 78 deletions(-)
diff --git a/drivers/net/qede/qede_rxtx.c b/drivers/net/qede/qede_rxtx.c
index 814d384..ecff5bc 100644
--- a/drivers/net/qede/qede_rxtx.c
+++ b/drivers/net/qede/qede_rxtx.c
@@ -810,39 +810,28 @@ static inline uint32_t qede_rx_cqe_to_tunn_pkt_type(uint16_t flags)
return RTE_PTYPE_UNKNOWN;
}
-
-int qede_process_sg_pkts(void *p_rxq, struct rte_mbuf *rx_mb,
- int num_segs, uint16_t pkt_len)
+static inline int
+qede_process_sg_pkts(void *p_rxq, struct rte_mbuf *rx_mb,
+ uint8_t num_segs, uint16_t pkt_len)
{
struct qede_rx_queue *rxq = p_rxq;
struct qede_dev *qdev = rxq->qdev;
struct ecore_dev *edev = &qdev->edev;
- uint16_t sw_rx_index, cur_size;
-
register struct rte_mbuf *seg1 = NULL;
register struct rte_mbuf *seg2 = NULL;
+ uint16_t sw_rx_index;
+ uint16_t cur_size;
seg1 = rx_mb;
while (num_segs) {
- cur_size = pkt_len > rxq->rx_buf_size ?
- rxq->rx_buf_size : pkt_len;
- if (!cur_size) {
- PMD_RX_LOG(DEBUG, rxq,
- "SG packet, len and num BD mismatch\n");
+ cur_size = pkt_len > rxq->rx_buf_size ? rxq->rx_buf_size :
+ pkt_len;
+ if (unlikely(!cur_size)) {
+ PMD_RX_LOG(ERR, rxq, "Length is 0 while %u BDs"
+ " left for mapping jumbo\n", num_segs);
qede_recycle_rx_bd_ring(rxq, qdev, num_segs);
return -EINVAL;
}
-
- if (qede_alloc_rx_buffer(rxq)) {
- uint8_t index;
-
- PMD_RX_LOG(DEBUG, rxq, "Buffer allocation failed\n");
- index = rxq->port_id;
- rte_eth_devices[index].data->rx_mbuf_alloc_failed++;
- rxq->rx_alloc_errors++;
- return -ENOMEM;
- }
-
sw_rx_index = rxq->sw_rx_cons & NUM_RX_BDS(rxq);
seg2 = rxq->sw_rx_ring[sw_rx_index].mbuf;
qede_rx_bd_ring_consume(rxq);
@@ -852,16 +841,9 @@ int qede_process_sg_pkts(void *p_rxq, struct rte_mbuf *rx_mb,
seg1 = seg1->next;
num_segs--;
rxq->rx_segs++;
- continue;
}
- seg1 = NULL;
-
- if (pkt_len)
- PMD_RX_LOG(DEBUG, rxq,
- "Mapped all BDs of jumbo, but still have %d bytes\n",
- pkt_len);
- return ECORE_SUCCESS;
+ return 0;
}
uint16_t
@@ -878,11 +860,16 @@ qede_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
register struct rte_mbuf *rx_mb = NULL;
register struct rte_mbuf *seg1 = NULL;
enum eth_rx_cqe_type cqe_type;
- uint16_t len, pad, preload_idx, pkt_len, parse_flag;
- uint8_t csum_flag, num_segs;
+ uint16_t pkt_len; /* Sum of all BD segments */
+ uint16_t len; /* Length of first BD */
+ uint8_t num_segs = 1;
+ uint16_t pad;
+ uint16_t preload_idx;
+ uint8_t csum_flag;
+ uint16_t parse_flag;
enum rss_hash_type htype;
uint8_t tunn_parse_flag;
- int ret;
+ uint8_t j;
hw_comp_cons = rte_le_to_cpu_16(*rxq->hw_cons_ptr);
sw_comp_cons = ecore_chain_get_cons_idx(&rxq->rx_comp_ring);
@@ -915,6 +902,7 @@ qede_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
fp_cqe = &cqe->fast_path_regular;
len = rte_le_to_cpu_16(fp_cqe->len_on_first_bd);
+ pkt_len = rte_le_to_cpu_16(fp_cqe->pkt_len);
pad = fp_cqe->placement_offset;
assert((len + pad) <= rx_mb->buf_len);
@@ -979,25 +967,29 @@ qede_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
rxq->rx_alloc_errors++;
break;
}
-
qede_rx_bd_ring_consume(rxq);
-
if (fp_cqe->bd_num > 1) {
- pkt_len = rte_le_to_cpu_16(fp_cqe->pkt_len);
+ PMD_RX_LOG(DEBUG, rxq, "Jumbo-over-BD packet: %02x BDs"
+ " len on first: %04x Total Len: %04x\n",
+ fp_cqe->bd_num, len, pkt_len);
num_segs = fp_cqe->bd_num - 1;
-
- rxq->rx_segs++;
-
- pkt_len -= len;
seg1 = rx_mb;
- ret = qede_process_sg_pkts(p_rxq, seg1, num_segs,
- pkt_len);
- if (ret != ECORE_SUCCESS) {
- qede_recycle_rx_bd_ring(rxq, qdev,
- fp_cqe->bd_num);
+ if (qede_process_sg_pkts(p_rxq, seg1, num_segs,
+ pkt_len - len))
goto next_cqe;
+ for (j = 0; j < num_segs; j++) {
+ if (qede_alloc_rx_buffer(rxq)) {
+ PMD_RX_LOG(ERR, rxq,
+ "Buffer allocation failed\n");
+ rte_eth_devices[rxq->port_id].
+ data->rx_mbuf_alloc_failed++;
+ rxq->rx_alloc_errors++;
+ break;
+ }
+ rxq->rx_segs++;
}
}
+ rxq->rx_segs++; /* for the first segment */
/* Prefetch next mbuf while processing current one. */
preload_idx = rxq->sw_rx_cons & NUM_RX_BDS(rxq);
@@ -1007,7 +999,7 @@ qede_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
rx_mb->data_off = pad + RTE_PKTMBUF_HEADROOM;
rx_mb->nb_segs = fp_cqe->bd_num;
rx_mb->data_len = len;
- rx_mb->pkt_len = fp_cqe->pkt_len;
+ rx_mb->pkt_len = pkt_len;
rx_mb->port = rxq->port_id;
htype = (uint8_t)GET_FIELD(fp_cqe->bitfields,
@@ -1114,17 +1106,16 @@ qede_process_tx_compl(struct ecore_dev *edev, struct qede_tx_queue *txq)
}
/* Populate scatter gather buffer descriptor fields */
-static inline uint16_t qede_encode_sg_bd(struct qede_tx_queue *p_txq,
- struct rte_mbuf *m_seg,
- uint16_t count,
- struct eth_tx_1st_bd *bd1)
+static inline uint8_t
+qede_encode_sg_bd(struct qede_tx_queue *p_txq, struct rte_mbuf *m_seg,
+ struct eth_tx_1st_bd *bd1)
{
struct qede_tx_queue *txq = p_txq;
struct eth_tx_2nd_bd *bd2 = NULL;
struct eth_tx_3rd_bd *bd3 = NULL;
struct eth_tx_bd *tx_bd = NULL;
- uint16_t nb_segs = count;
dma_addr_t mapping;
+ uint8_t nb_segs = 1; /* min one segment per packet */
/* Check for scattered buffers */
while (m_seg) {
@@ -1133,28 +1124,27 @@ static inline uint16_t qede_encode_sg_bd(struct qede_tx_queue *p_txq,
ecore_chain_produce(&txq->tx_pbl);
memset(bd2, 0, sizeof(*bd2));
mapping = rte_mbuf_data_dma_addr(m_seg);
- bd2->addr.hi = rte_cpu_to_le_32(U64_HI(mapping));
- bd2->addr.lo = rte_cpu_to_le_32(U64_LO(mapping));
- bd2->nbytes = rte_cpu_to_le_16(m_seg->data_len);
+ QEDE_BD_SET_ADDR_LEN(bd2, mapping, m_seg->data_len);
+ PMD_TX_LOG(DEBUG, txq, "BD2 len %04x\n",
+ m_seg->data_len);
} else if (nb_segs == 2) {
bd3 = (struct eth_tx_3rd_bd *)
ecore_chain_produce(&txq->tx_pbl);
memset(bd3, 0, sizeof(*bd3));
mapping = rte_mbuf_data_dma_addr(m_seg);
- bd3->addr.hi = rte_cpu_to_le_32(U64_HI(mapping));
- bd3->addr.lo = rte_cpu_to_le_32(U64_LO(mapping));
- bd3->nbytes = rte_cpu_to_le_16(m_seg->data_len);
+ QEDE_BD_SET_ADDR_LEN(bd3, mapping, m_seg->data_len);
+ PMD_TX_LOG(DEBUG, txq, "BD3 len %04x\n",
+ m_seg->data_len);
} else {
tx_bd = (struct eth_tx_bd *)
ecore_chain_produce(&txq->tx_pbl);
memset(tx_bd, 0, sizeof(*tx_bd));
mapping = rte_mbuf_data_dma_addr(m_seg);
- tx_bd->addr.hi = rte_cpu_to_le_32(U64_HI(mapping));
- tx_bd->addr.lo = rte_cpu_to_le_32(U64_LO(mapping));
- tx_bd->nbytes = rte_cpu_to_le_16(m_seg->data_len);
+ QEDE_BD_SET_ADDR_LEN(tx_bd, mapping, m_seg->data_len);
+ PMD_TX_LOG(DEBUG, txq, "BD len %04x\n",
+ m_seg->data_len);
}
nb_segs++;
- bd1->data.nbds = nb_segs;
m_seg = m_seg->next;
}
@@ -1170,13 +1160,14 @@ qede_xmit_pkts(void *p_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
struct ecore_dev *edev = &qdev->edev;
struct qede_fastpath *fp;
struct eth_tx_1st_bd *bd1;
+ struct rte_mbuf *mbuf;
struct rte_mbuf *m_seg = NULL;
uint16_t nb_tx_pkts;
- uint16_t nb_pkt_sent = 0;
uint16_t bd_prod;
uint16_t idx;
uint16_t tx_count;
- uint16_t nb_segs = 0;
+ uint16_t nb_frags;
+ uint16_t nb_pkt_sent = 0;
fp = &qdev->fp_array[QEDE_RSS_COUNT(qdev) + txq->queue_id];
@@ -1198,19 +1189,19 @@ qede_xmit_pkts(void *p_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
while (nb_tx_pkts--) {
/* Fill the entry in the SW ring and the BDs in the FW ring */
idx = TX_PROD(txq);
- struct rte_mbuf *mbuf = *tx_pkts++;
-
+ mbuf = *tx_pkts++;
txq->sw_tx_ring[idx].mbuf = mbuf;
bd1 = (struct eth_tx_1st_bd *)ecore_chain_produce(&txq->tx_pbl);
- /* Zero init struct fields */
- bd1->data.bd_flags.bitfields = 0;
- bd1->data.bitfields = 0;
-
bd1->data.bd_flags.bitfields =
1 << ETH_TX_1ST_BD_FLAGS_START_BD_SHIFT;
+ /* FW 8.10.x specific change */
+ bd1->data.bitfields =
+ (mbuf->pkt_len & ETH_TX_DATA_1ST_BD_PKT_LEN_MASK)
+ << ETH_TX_DATA_1ST_BD_PKT_LEN_SHIFT;
/* Map MBUF linear data for DMA and set in the first BD */
QEDE_BD_SET_ADDR_LEN(bd1, rte_mbuf_data_dma_addr(mbuf),
- mbuf->pkt_len);
+ mbuf->data_len);
+ PMD_TX_LOG(INFO, txq, "BD1 len %04x\n", mbuf->data_len);
if (RTE_ETH_IS_TUNNEL_PKT(mbuf->packet_type)) {
PMD_TX_LOG(INFO, txq, "Tx tunnel packet\n");
@@ -1267,18 +1258,18 @@ qede_xmit_pkts(void *p_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
/* Handle fragmented MBUF */
m_seg = mbuf->next;
- nb_segs++;
- bd1->data.nbds = nb_segs;
/* Encode scatter gather buffer descriptors if required */
- nb_segs = qede_encode_sg_bd(txq, m_seg, nb_segs, bd1);
- txq->nb_tx_avail = txq->nb_tx_avail - nb_segs;
- nb_segs = 0;
+ nb_frags = qede_encode_sg_bd(txq, m_seg, bd1);
+ bd1->data.nbds = nb_frags;
+ txq->nb_tx_avail -= nb_frags;
txq->sw_tx_prod++;
rte_prefetch0(txq->sw_tx_ring[TX_PROD(txq)].mbuf);
bd_prod =
rte_cpu_to_le_16(ecore_chain_get_prod_idx(&txq->tx_pbl));
nb_pkt_sent++;
txq->xmit_pkts++;
+ PMD_TX_LOG(INFO, txq, "nbds = %d pkt_len = %04x\n",
+ bd1->data.nbds, mbuf->pkt_len);
}
/* Write value of prod idx into bd_prod */
diff --git a/drivers/net/qede/qede_rxtx.h b/drivers/net/qede/qede_rxtx.h
index 2a8645a..a95b4ab 100644
--- a/drivers/net/qede/qede_rxtx.h
+++ b/drivers/net/qede/qede_rxtx.h
@@ -41,10 +41,6 @@
(bd)->addr.hi = rte_cpu_to_le_32(U64_HI(maddr)); \
(bd)->addr.lo = rte_cpu_to_le_32(U64_LO(maddr)); \
(bd)->nbytes = rte_cpu_to_le_16(len); \
- /* FW 8.10.x specific change */ \
- (bd)->data.bitfields = ((len) & \
- ETH_TX_DATA_1ST_BD_PKT_LEN_MASK) \
- << ETH_TX_DATA_1ST_BD_PKT_LEN_SHIFT; \
} while (0)
#define CQE_HAS_VLAN(flags) \
--
1.7.10.3
^ permalink raw reply related
* [PATCH 2/5] net/qede: fix minimum buffer size and scatter Rx check
From: Rasesh Mody @ 2016-12-31 8:16 UTC (permalink / raw)
To: dev; +Cc: Harish Patil, stable, Dept-EngDPDKDev
In-Reply-To: <1483172217-30186-1-git-send-email-rasesh.mody@cavium.com>
From: Harish Patil <harish.patil@qlogic.com>
- Fix minimum RX buffer size to 1024B
- Force enable scatter/gather mode if given RX buf size is lesser than MTU
- Adjust RX buffer size to cache-line size with overhead included
Fixes: bec0228816c0 ("net/qede: support scatter gather")
Fixes: 2ea6f76aff40 ("qede: add core driver")
Signed-off-by: Harish Patil <harish.patil@qlogic.com>
---
drivers/net/qede/qede_ethdev.c | 3 +--
drivers/net/qede/qede_rxtx.c | 47 +++++++++++++++++-----------------------
drivers/net/qede/qede_rxtx.h | 11 ++++++++--
3 files changed, 30 insertions(+), 31 deletions(-)
diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index c8581d8..b7606c8 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -968,8 +968,7 @@ qede_dev_info_get(struct rte_eth_dev *eth_dev,
PMD_INIT_FUNC_TRACE(edev);
- dev_info->min_rx_bufsize = (uint32_t)(ETHER_MIN_MTU +
- QEDE_ETH_OVERHEAD);
+ dev_info->min_rx_bufsize = (uint32_t)QEDE_MIN_RX_BUFF_SIZE;
dev_info->max_rx_pktlen = (uint32_t)ETH_TX_MAX_NON_LSO_PKT_LEN;
dev_info->rx_desc_lim = qede_rx_desc_lim;
dev_info->tx_desc_lim = qede_tx_desc_lim;
diff --git a/drivers/net/qede/qede_rxtx.c b/drivers/net/qede/qede_rxtx.c
index ecff5bc..aebe8cb 100644
--- a/drivers/net/qede/qede_rxtx.c
+++ b/drivers/net/qede/qede_rxtx.c
@@ -89,11 +89,11 @@ qede_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
{
struct qede_dev *qdev = dev->data->dev_private;
struct ecore_dev *edev = &qdev->edev;
- struct rte_eth_dev_data *eth_data = dev->data;
+ struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
struct qede_rx_queue *rxq;
- uint16_t pkt_len = (uint16_t)dev->data->dev_conf.rxmode.max_rx_pkt_len;
+ uint16_t max_rx_pkt_len;
+ uint16_t bufsz;
size_t size;
- uint16_t data_size;
int rc;
int i;
@@ -127,34 +127,27 @@ qede_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
rxq->nb_rx_desc = nb_desc;
rxq->queue_id = queue_idx;
rxq->port_id = dev->data->port_id;
-
- /* Sanity check */
- data_size = (uint16_t)rte_pktmbuf_data_room_size(mp) -
- RTE_PKTMBUF_HEADROOM;
-
- if (pkt_len > data_size && !dev->data->scattered_rx) {
- DP_ERR(edev, "MTU %u should not exceed dataroom %u\n",
- pkt_len, data_size);
- rte_free(rxq);
- return -EINVAL;
+ max_rx_pkt_len = (uint16_t)rxmode->max_rx_pkt_len;
+ qdev->mtu = max_rx_pkt_len;
+
+ /* Fix up RX buffer size */
+ bufsz = (uint16_t)rte_pktmbuf_data_room_size(mp) - RTE_PKTMBUF_HEADROOM;
+ if ((rxmode->enable_scatter) ||
+ (max_rx_pkt_len + QEDE_ETH_OVERHEAD) > bufsz) {
+ if (!dev->data->scattered_rx) {
+ DP_INFO(edev, "Forcing scatter-gather mode\n");
+ dev->data->scattered_rx = 1;
+ }
}
-
if (dev->data->scattered_rx)
- rxq->rx_buf_size = data_size;
+ rxq->rx_buf_size = bufsz + QEDE_ETH_OVERHEAD;
else
- rxq->rx_buf_size = pkt_len + QEDE_ETH_OVERHEAD;
-
- qdev->mtu = pkt_len;
+ rxq->rx_buf_size = qdev->mtu + QEDE_ETH_OVERHEAD;
+ /* Align to cache-line size if needed */
+ rxq->rx_buf_size = QEDE_CEIL_TO_CACHE_LINE_SIZE(rxq->rx_buf_size);
- DP_INFO(edev, "MTU = %u ; RX buffer = %u\n",
- qdev->mtu, rxq->rx_buf_size);
-
- if (pkt_len > ETHER_MAX_LEN) {
- dev->data->dev_conf.rxmode.jumbo_frame = 1;
- DP_NOTICE(edev, false, "jumbo frame enabled\n");
- } else {
- dev->data->dev_conf.rxmode.jumbo_frame = 0;
- }
+ DP_INFO(edev, "mtu %u mbufsz %u bd_max_bytes %u scatter_mode %d\n",
+ qdev->mtu, bufsz, rxq->rx_buf_size, dev->data->scattered_rx);
/* Allocate the parallel driver ring for Rx buffers */
size = sizeof(*rxq->sw_rx_ring) * rxq->nb_rx_desc;
diff --git a/drivers/net/qede/qede_rxtx.h b/drivers/net/qede/qede_rxtx.h
index a95b4ab..9a393e9 100644
--- a/drivers/net/qede/qede_rxtx.h
+++ b/drivers/net/qede/qede_rxtx.h
@@ -51,14 +51,21 @@
((flags) & (PARSING_AND_ERR_FLAGS_TUNNEL8021QTAGEXIST_MASK \
<< PARSING_AND_ERR_FLAGS_TUNNEL8021QTAGEXIST_SHIFT))
+#define QEDE_MIN_RX_BUFF_SIZE (1024)
+#define QEDE_VLAN_TAG_SIZE (4)
+#define QEDE_LLC_SNAP_HDR_LEN (8)
+
/* Max supported alignment is 256 (8 shift)
* minimal alignment shift 6 is optimal for 57xxx HW performance
*/
#define QEDE_L1_CACHE_SHIFT 6
#define QEDE_RX_ALIGN_SHIFT (RTE_MAX(6, RTE_MIN(8, QEDE_L1_CACHE_SHIFT)))
#define QEDE_FW_RX_ALIGN_END (1UL << QEDE_RX_ALIGN_SHIFT)
-
-#define QEDE_ETH_OVERHEAD (ETHER_HDR_LEN + 8 + 8 + QEDE_FW_RX_ALIGN_END)
+#define QEDE_CEIL_TO_CACHE_LINE_SIZE(n) (((n) + (QEDE_FW_RX_ALIGN_END - 1)) & \
+ ~(QEDE_FW_RX_ALIGN_END - 1))
+/* Note: QEDE_LLC_SNAP_HDR_LEN is optional */
+#define QEDE_ETH_OVERHEAD ((ETHER_HDR_LEN) + ((2 * QEDE_VLAN_TAG_SIZE)) \
+ + (QEDE_LLC_SNAP_HDR_LEN))
#define QEDE_RSS_OFFLOAD_ALL (ETH_RSS_IPV4 |\
ETH_RSS_NONFRAG_IPV4_TCP |\
--
1.7.10.3
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox