DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/2] Windows logging
@ 2020-04-29 23:24 Pallavi Kadam
  2020-04-29 23:24 ` [dpdk-dev] [PATCH 1/2] eal: initialize eal logging on Windows Pallavi Kadam
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Pallavi Kadam @ 2020-04-29 23:24 UTC (permalink / raw)
  To: dev, thomas
  Cc: ranjit.menon, Harini.Ramakrishnan, Narcisa.Vasile,
	dmitry.kozliuk, tbashar, pallavi.kadam

This patchset adds EAL logging support on Windows.
Logs will be sent to console output.

Pallavi Kadam (2):
  eal: initialize eal logging on Windows
  eal: add fnmatch implementation on Windows

 lib/librte_eal/windows/eal.c             |   3 +
 lib/librte_eal/windows/eal_log.c         |  16 +++
 lib/librte_eal/windows/fnmatch.c         | 172 +++++++++++++++++++++++
 lib/librte_eal/windows/include/fnmatch.h |  16 +--
 lib/librte_eal/windows/meson.build       |   2 +
 5 files changed, 201 insertions(+), 8 deletions(-)
 create mode 100644 lib/librte_eal/windows/eal_log.c
 create mode 100644 lib/librte_eal/windows/fnmatch.c

-- 
2.18.0.windows.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [dpdk-dev] [PATCH 1/2] eal: initialize eal logging on Windows
  2020-04-29 23:24 [dpdk-dev] [PATCH 0/2] Windows logging Pallavi Kadam
@ 2020-04-29 23:24 ` Pallavi Kadam
  2020-04-29 23:24 ` [dpdk-dev] [PATCH 2/2] eal: add fnmatch implementation " Pallavi Kadam
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 16+ messages in thread
From: Pallavi Kadam @ 2020-04-29 23:24 UTC (permalink / raw)
  To: dev, thomas
  Cc: ranjit.menon, Harini.Ramakrishnan, Narcisa.Vasile,
	dmitry.kozliuk, tbashar, pallavi.kadam

Add logging function on Windows to send log output to the console.

Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
Reviewed-by: Tasnim Bashar <tbashar@mellanox.com>
Tested-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
---
 lib/librte_eal/windows/eal.c       |  3 +++
 lib/librte_eal/windows/eal_log.c   | 16 ++++++++++++++++
 lib/librte_eal/windows/meson.build |  1 +
 3 files changed, 20 insertions(+)
 create mode 100644 lib/librte_eal/windows/eal_log.c

diff --git a/lib/librte_eal/windows/eal.c b/lib/librte_eal/windows/eal.c
index 2cf7a04ef..123afed8d 100644
--- a/lib/librte_eal/windows/eal.c
+++ b/lib/librte_eal/windows/eal.c
@@ -227,6 +227,9 @@ rte_eal_init(int argc, char **argv)
 {
 	int i, fctret;
 
+	/* initialize all logs */
+	rte_eal_log_init(NULL, 0);
+
 	eal_log_level_parse(argc, argv);
 
 	/* create a map of all processors in the system */
diff --git a/lib/librte_eal/windows/eal_log.c b/lib/librte_eal/windows/eal_log.c
new file mode 100644
index 000000000..875981f13
--- /dev/null
+++ b/lib/librte_eal/windows/eal_log.c
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2017-2018 Intel Corporation
+ */
+
+#include "eal_private.h"
+
+/* set the log to default function, called during eal init process. */
+int
+rte_eal_log_init(__rte_unused const char *id, __rte_unused int facility)
+{
+	rte_openlog_stream(stderr);
+
+	eal_log_set_default(stderr);
+
+	return 0;
+}
diff --git a/lib/librte_eal/windows/meson.build b/lib/librte_eal/windows/meson.build
index 09dd4ab2f..e5d1d8336 100644
--- a/lib/librte_eal/windows/meson.build
+++ b/lib/librte_eal/windows/meson.build
@@ -7,6 +7,7 @@ sources += files(
 	'eal.c',
 	'eal_debug.c',
 	'eal_lcore.c',
+	'eal_log.c',
 	'eal_thread.c',
 	'getopt.c',
 )
-- 
2.18.0.windows.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [dpdk-dev] [PATCH 2/2] eal: add fnmatch implementation on Windows
  2020-04-29 23:24 [dpdk-dev] [PATCH 0/2] Windows logging Pallavi Kadam
  2020-04-29 23:24 ` [dpdk-dev] [PATCH 1/2] eal: initialize eal logging on Windows Pallavi Kadam
@ 2020-04-29 23:24 ` Pallavi Kadam
  2020-04-30  6:52   ` Thomas Monjalon
  2020-04-30  6:48 ` [dpdk-dev] [PATCH 0/2] Windows logging Thomas Monjalon
  2020-05-06  1:30 ` [dpdk-dev] [PATCH v2 " Pallavi Kadam
  3 siblings, 1 reply; 16+ messages in thread
From: Pallavi Kadam @ 2020-04-29 23:24 UTC (permalink / raw)
  To: dev, thomas
  Cc: ranjit.menon, Harini.Ramakrishnan, Narcisa.Vasile,
	dmitry.kozliuk, tbashar, pallavi.kadam

Added fnmatch implementation on Windows to support
log level arguments.
The source file is with BSD-3-Clause license.
https://github.com/lattera/freebsd/blob/master/usr.bin/csup/fnmatch.c

Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
Reviewed-by: Tasnim Bashar <tbashar@mellanox.com>
Tested-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
---
 lib/librte_eal/windows/fnmatch.c         | 172 +++++++++++++++++++++++
 lib/librte_eal/windows/include/fnmatch.h |  16 +--
 lib/librte_eal/windows/meson.build       |   1 +
 3 files changed, 181 insertions(+), 8 deletions(-)
 create mode 100644 lib/librte_eal/windows/fnmatch.c

diff --git a/lib/librte_eal/windows/fnmatch.c b/lib/librte_eal/windows/fnmatch.c
new file mode 100644
index 000000000..f622bf54c
--- /dev/null
+++ b/lib/librte_eal/windows/fnmatch.c
@@ -0,0 +1,172 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 1989, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Guido van Rossum.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static const char sccsid[] = "@(#)fnmatch.c	8.2 (Berkeley) 4/16/94";
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6.
+ * Compares a filename or pathname to a pattern.
+ */
+
+#include <ctype.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "fnmatch.h"
+
+#define EOS	'\0'
+
+static const char *rangematch(const char *, char, int);
+
+int
+fnmatch(const char *pattern, const char *string, int flags)
+{
+	const char *stringstart;
+	char c, test;
+
+	for (stringstart = string;;)
+		switch (c = *pattern++) {
+		case EOS:
+			if ((flags & FNM_LEADING_DIR) && *string == '/')
+				return (0);
+			return (*string == EOS ? 0 : FNM_NOMATCH);
+		case '?':
+			if (*string == EOS)
+				return (FNM_NOMATCH);
+			if (*string == '/' && (flags & FNM_PATHNAME))
+				return (FNM_NOMATCH);
+			if (*string == '.' && (flags & FNM_PERIOD) &&
+			    (string == stringstart ||
+			    ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
+				return (FNM_NOMATCH);
+			++string;
+			break;
+		case '*':
+			c = *pattern;
+			/* Collapse multiple stars. */
+			while (c == '*')
+				c = *++pattern;
+
+			if (*string == '.' && (flags & FNM_PERIOD) &&
+			    (string == stringstart ||
+			    ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
+				return (FNM_NOMATCH);
+
+			/* Optimize for pattern with * at end or before /. */
+			if (c == EOS)
+				if (flags & FNM_PATHNAME)
+					return ((flags & FNM_LEADING_DIR) ||
+					    strchr(string, '/') == NULL ?
+					    0 : FNM_NOMATCH);
+				else
+					return (0);
+			else if (c == '/' && flags & FNM_PATHNAME) {
+				string = strchr(string, '/');
+				if (string == NULL)
+					return (FNM_NOMATCH);
+				break;
+			}
+
+			/* General case, use recursion. */
+			while ((test = *string) != EOS) {
+				if (!fnmatch(pattern, string,
+					flags & ~FNM_PERIOD))
+					return (0);
+				if (test == '/' && flags & FNM_PATHNAME)
+					break;
+				++string;
+			}
+			return (FNM_NOMATCH);
+		case '[':
+			if (*string == EOS)
+				return (FNM_NOMATCH);
+			if (*string == '/' && flags & FNM_PATHNAME)
+				return (FNM_NOMATCH);
+			pattern = rangematch(pattern, *string, flags);
+			if (pattern == NULL)
+				return (FNM_NOMATCH);
+			++string;
+			break;
+		case '\\':
+			if (!(flags & FNM_NOESCAPE)) {
+				c = *pattern++;
+				if (c == EOS) {
+					c = '\\';
+					--pattern;
+				}
+			}
+			/* FALLTHROUGH */
+		default:
+			if (c == *string)
+				;
+			else if ((flags & FNM_CASEFOLD) &&
+				 (tolower((unsigned char)c) ==
+				  tolower((unsigned char)*string)))
+				;
+			else if ((flags & FNM_PREFIX_DIRS) && *string == EOS &&
+			     ((c == '/' && string != stringstart) ||
+			     (string == stringstart+1 && *stringstart == '/')))
+				return (0);
+			else
+				return (FNM_NOMATCH);
+			string++;
+			break;
+		}
+	/* NOTREACHED */
+}
+
+static const char *
+rangematch(const char *pattern, char test, int flags)
+{
+	int negate, ok;
+	char c, c2;
+
+	/*
+	 * A bracket expression starting with an unquoted circumflex
+	 * character produces unspecified results (IEEE 1003.2-1992,
+	 * 3.13.2).  This implementation treats it like '!', for
+	 * consistency with the regular expression syntax.
+	 * J.T. Conklin (conklin@ngai.kaleida.com)
+	 */
+	negate = (*pattern == '!' || *pattern == '^');
+	if (negate)
+		++pattern;
+
+	if (flags & FNM_CASEFOLD)
+		test = tolower((unsigned char)test);
+
+	for (ok = 0; (c = *pattern++) != ']';) {
+		if (c == '\\' && !(flags & FNM_NOESCAPE))
+			c = *pattern++;
+		if (c == EOS)
+			return (NULL);
+
+		if (flags & FNM_CASEFOLD)
+			c = tolower((unsigned char)c);
+
+		c2 = *(pattern + 1);
+		if (*pattern == '-' && c2 != EOS && c2 != ']') {
+			pattern += 2;
+			if (c2 == '\\' && !(flags & FNM_NOESCAPE))
+				c2 = *pattern++;
+			if (c2 == EOS)
+				return (NULL);
+
+			if (flags & FNM_CASEFOLD)
+				c2 = tolower((unsigned char)c2);
+
+			if ((unsigned char)c <= (unsigned char)test &&
+			    (unsigned char)test <= (unsigned char)c2)
+				ok = 1;
+		} else if (c == test)
+			ok = 1;
+	}
+	return (ok == negate ? NULL : pattern);
+}
diff --git a/lib/librte_eal/windows/include/fnmatch.h b/lib/librte_eal/windows/include/fnmatch.h
index d0159f07a..142753c35 100644
--- a/lib/librte_eal/windows/include/fnmatch.h
+++ b/lib/librte_eal/windows/include/fnmatch.h
@@ -18,6 +18,13 @@ extern "C" {
 
 #define FNM_NOMATCH 1
 
+#define FNM_NOESCAPE 0x01
+#define FNM_PATHNAME 0x02
+#define FNM_PERIOD 0x04
+#define FNM_LEADING_DIR 0x08
+#define FNM_CASEFOLD 0x10
+#define FNM_PREFIX_DIRS 0x20
+
 /**
  * This function is used for searhing a given string source
  * with the given regular expression pattern.
@@ -34,14 +41,7 @@ extern "C" {
  * @return
  *	if the pattern is found then return 0 or else FNM_NOMATCH
  */
-static inline int fnmatch(__rte_unused const char *pattern,
-		__rte_unused const char *string,
-		__rte_unused int flags)
-{
-	/* TODO */
-	/* This is a stub, not the expected result */
-	return FNM_NOMATCH;
-}
+int fnmatch(const char *pattern, const char *string, int flags);
 
 #ifdef __cplusplus
 }
diff --git a/lib/librte_eal/windows/meson.build b/lib/librte_eal/windows/meson.build
index e5d1d8336..adfc8b9b7 100644
--- a/lib/librte_eal/windows/meson.build
+++ b/lib/librte_eal/windows/meson.build
@@ -9,5 +9,6 @@ sources += files(
 	'eal_lcore.c',
 	'eal_log.c',
 	'eal_thread.c',
+	'fnmatch.c',
 	'getopt.c',
 )
-- 
2.18.0.windows.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [dpdk-dev] [PATCH 0/2] Windows logging
  2020-04-29 23:24 [dpdk-dev] [PATCH 0/2] Windows logging Pallavi Kadam
  2020-04-29 23:24 ` [dpdk-dev] [PATCH 1/2] eal: initialize eal logging on Windows Pallavi Kadam
  2020-04-29 23:24 ` [dpdk-dev] [PATCH 2/2] eal: add fnmatch implementation " Pallavi Kadam
@ 2020-04-30  6:48 ` Thomas Monjalon
  2020-04-30 22:18   ` Kadam, Pallavi
  2020-05-06  1:30 ` [dpdk-dev] [PATCH v2 " Pallavi Kadam
  3 siblings, 1 reply; 16+ messages in thread
From: Thomas Monjalon @ 2020-04-30  6:48 UTC (permalink / raw)
  To: Pallavi Kadam
  Cc: dev, ranjit.menon, Harini.Ramakrishnan, Narcisa.Vasile,
	dmitry.kozliuk, tbashar

30/04/2020 01:24, Pallavi Kadam:
> This patchset adds EAL logging support on Windows.
> Logs will be sent to console output.
> 
> Pallavi Kadam (2):
>   eal: initialize eal logging on Windows
>   eal: add fnmatch implementation on Windows

fnmatch is required to change the log level of logs
specified with a globbing pattern.

I think it would be nicer to introduce fnmatch first,
and state in the other patch that logging is supported on Windows.

Titles would be:
eal/windows: add fnmatch implementation
log: support on Windows



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] eal: add fnmatch implementation on Windows
  2020-04-29 23:24 ` [dpdk-dev] [PATCH 2/2] eal: add fnmatch implementation " Pallavi Kadam
@ 2020-04-30  6:52   ` Thomas Monjalon
  2020-04-30  7:30     ` Dmitry Kozlyuk
  0 siblings, 1 reply; 16+ messages in thread
From: Thomas Monjalon @ 2020-04-30  6:52 UTC (permalink / raw)
  To: Pallavi Kadam
  Cc: dev, ranjit.menon, Harini.Ramakrishnan, Narcisa.Vasile,
	dmitry.kozliuk, tbashar

30/04/2020 01:24, Pallavi Kadam:
> Added fnmatch implementation on Windows to support
> log level arguments.
> The source file is with BSD-3-Clause license.
> https://github.com/lattera/freebsd/blob/master/usr.bin/csup/fnmatch.c

Sorry for the naive question, I don't know Windows programming.

Do we really need this external code?
Why RtlIsNameInExpression from Windows cannot be used?
https://docs.microsoft.com/en-us/windows/win32/devnotes/rtlisnameinexpression




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] eal: add fnmatch implementation on Windows
  2020-04-30  6:52   ` Thomas Monjalon
@ 2020-04-30  7:30     ` Dmitry Kozlyuk
  2020-05-01  1:08       ` Ranjit Menon
  0 siblings, 1 reply; 16+ messages in thread
From: Dmitry Kozlyuk @ 2020-04-30  7:30 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: Pallavi Kadam, dev, ranjit.menon, Harini.Ramakrishnan,
	Narcisa.Vasile, tbashar

On 2020-04-30 08:52 GMT+0200 Thomas Monjalon wrote:
> 30/04/2020 01:24, Pallavi Kadam:
> > Added fnmatch implementation on Windows to support
> > log level arguments.
> > The source file is with BSD-3-Clause license.
> > https://github.com/lattera/freebsd/blob/master/usr.bin/csup/fnmatch.c  
> 
> Sorry for the naive question, I don't know Windows programming.
> 
> Do we really need this external code?
> Why RtlIsNameInExpression from Windows cannot be used?
> https://docs.microsoft.com/en-us/windows/win32/devnotes/rtlisnameinexpression

The general reason not to use Win32 API for globbing is poorly documented
contract: what are the exact matching rules? They're definitely incompatible
with fnmatch(3). IMO small external code is better than unknown behavior.

RtlIsNameInExpression is an internal call for drivers and services with a
cumbersome API. PathMatchSpecA is the user-mode interface, but see above.

https://docs.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-pathmatchspeca

-- 
Dmitry Kozlyuk

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [dpdk-dev] [PATCH 0/2] Windows logging
  2020-04-30  6:48 ` [dpdk-dev] [PATCH 0/2] Windows logging Thomas Monjalon
@ 2020-04-30 22:18   ` Kadam, Pallavi
  0 siblings, 0 replies; 16+ messages in thread
From: Kadam, Pallavi @ 2020-04-30 22:18 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, ranjit.menon, Harini.Ramakrishnan, Narcisa.Vasile,
	dmitry.kozliuk, tbashar



On 4/29/2020 11:48 PM, Thomas Monjalon wrote:
> 30/04/2020 01:24, Pallavi Kadam:
>> This patchset adds EAL logging support on Windows.
>> Logs will be sent to console output.
>>
>> Pallavi Kadam (2):
>>    eal: initialize eal logging on Windows
>>    eal: add fnmatch implementation on Windows
> 
> fnmatch is required to change the log level of logs
> specified with a globbing pattern.
> 
> I think it would be nicer to introduce fnmatch first,
> and state in the other patch that logging is supported on Windows.
> 
> Titles would be:
> eal/windows: add fnmatch implementation
> log: support on Windows
> 
> 
Ok, will interchange the sequence of the patches in v2.
Thanks,

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] eal: add fnmatch implementation on Windows
  2020-04-30  7:30     ` Dmitry Kozlyuk
@ 2020-05-01  1:08       ` Ranjit Menon
  2020-05-04 16:51         ` Thomas Monjalon
  0 siblings, 1 reply; 16+ messages in thread
From: Ranjit Menon @ 2020-05-01  1:08 UTC (permalink / raw)
  To: Dmitry Kozlyuk, Thomas Monjalon
  Cc: Pallavi Kadam, dev, Harini.Ramakrishnan, Narcisa.Vasile, tbashar

On 4/30/2020 12:30 AM, Dmitry Kozlyuk wrote:
> On 2020-04-30 08:52 GMT+0200 Thomas Monjalon wrote:
>> 30/04/2020 01:24, Pallavi Kadam:
>>> Added fnmatch implementation on Windows to support
>>> log level arguments.
>>> The source file is with BSD-3-Clause license.
>>> https://github.com/lattera/freebsd/blob/master/usr.bin/csup/fnmatch.c
>>
>> Sorry for the naive question, I don't know Windows programming.
>>
>> Do we really need this external code?
>> Why RtlIsNameInExpression from Windows cannot be used?
>> https://docs.microsoft.com/en-us/windows/win32/devnotes/rtlisnameinexpression
> 
> The general reason not to use Win32 API for globbing is poorly documented
> contract: what are the exact matching rules? They're definitely incompatible
> with fnmatch(3). IMO small external code is better than unknown behavior.
> 
> RtlIsNameInExpression is an internal call for drivers and services with a
> cumbersome API. PathMatchSpecA is the user-mode interface, but see above.
> 
> https://docs.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-pathmatchspeca
> 

I will agree with Dmitry here. The fnmatch external code is shipping, 
production quality code. So it's better to use it than writing something 
new.

ranjit m.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] eal: add fnmatch implementation on Windows
  2020-05-01  1:08       ` Ranjit Menon
@ 2020-05-04 16:51         ` Thomas Monjalon
  0 siblings, 0 replies; 16+ messages in thread
From: Thomas Monjalon @ 2020-05-04 16:51 UTC (permalink / raw)
  To: Dmitry Kozlyuk, Ranjit Menon
  Cc: Pallavi Kadam, dev, Harini.Ramakrishnan, Narcisa.Vasile, tbashar

01/05/2020 03:08, Ranjit Menon:
> On 4/30/2020 12:30 AM, Dmitry Kozlyuk wrote:
> > On 2020-04-30 08:52 GMT+0200 Thomas Monjalon wrote:
> >> 30/04/2020 01:24, Pallavi Kadam:
> >>> Added fnmatch implementation on Windows to support
> >>> log level arguments.
> >>> The source file is with BSD-3-Clause license.
> >>> https://github.com/lattera/freebsd/blob/master/usr.bin/csup/fnmatch.c
> >>
> >> Sorry for the naive question, I don't know Windows programming.
> >>
> >> Do we really need this external code?
> >> Why RtlIsNameInExpression from Windows cannot be used?
> >> https://docs.microsoft.com/en-us/windows/win32/devnotes/rtlisnameinexpression
> > 
> > The general reason not to use Win32 API for globbing is poorly documented
> > contract: what are the exact matching rules? They're definitely incompatible
> > with fnmatch(3). IMO small external code is better than unknown behavior.
> > 
> > RtlIsNameInExpression is an internal call for drivers and services with a
> > cumbersome API. PathMatchSpecA is the user-mode interface, but see above.
> > 
> > https://docs.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-pathmatchspeca
> > 
> 
> I will agree with Dmitry here. The fnmatch external code is shipping, 
> production quality code. So it's better to use it than writing something 
> new.

OK thank you for the explanations and opinions.




^ permalink raw reply	[flat|nested] 16+ messages in thread

* [dpdk-dev] [PATCH v2 0/2] Windows logging
  2020-04-29 23:24 [dpdk-dev] [PATCH 0/2] Windows logging Pallavi Kadam
                   ` (2 preceding siblings ...)
  2020-04-30  6:48 ` [dpdk-dev] [PATCH 0/2] Windows logging Thomas Monjalon
@ 2020-05-06  1:30 ` Pallavi Kadam
  2020-05-06  1:30   ` [dpdk-dev] [PATCH v2 1/2] eal: add fnmatch implementation Pallavi Kadam
                     ` (2 more replies)
  3 siblings, 3 replies; 16+ messages in thread
From: Pallavi Kadam @ 2020-05-06  1:30 UTC (permalink / raw)
  To: dev, thomas
  Cc: ranjit.menon, dmitry.kozliuk, Narcisa.Vasile, tbashar,
	Harini.Ramakrishnan, pallavi.kadam

This patchset adds EAL logging support on Windows.
Logs will be sent to console output.

v2 Changes:
	Introduced Fnmatch implementation first
	Added logging support in the second patch

Pallavi Kadam (2):
  eal: add fnmatch implementation
  eal: add log support on Windows

 lib/librte_eal/windows/eal.c             |   3 +
 lib/librte_eal/windows/eal_log.c         |  16 +++
 lib/librte_eal/windows/fnmatch.c         | 172 +++++++++++++++++++++++
 lib/librte_eal/windows/include/fnmatch.h |  16 +--
 lib/librte_eal/windows/meson.build       |   2 +
 5 files changed, 201 insertions(+), 8 deletions(-)
 create mode 100644 lib/librte_eal/windows/eal_log.c
 create mode 100644 lib/librte_eal/windows/fnmatch.c

-- 
2.18.0.windows.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [dpdk-dev] [PATCH v2 1/2] eal: add fnmatch implementation
  2020-05-06  1:30 ` [dpdk-dev] [PATCH v2 " Pallavi Kadam
@ 2020-05-06  1:30   ` Pallavi Kadam
  2020-05-06  2:24     ` Narcisa Ana Maria Vasile
  2020-05-06  1:30   ` [dpdk-dev] [PATCH v2 2/2] eal: add log support on Windows Pallavi Kadam
  2020-05-07 10:19   ` [dpdk-dev] [PATCH v2 0/2] Windows logging Thomas Monjalon
  2 siblings, 1 reply; 16+ messages in thread
From: Pallavi Kadam @ 2020-05-06  1:30 UTC (permalink / raw)
  To: dev, thomas
  Cc: ranjit.menon, dmitry.kozliuk, Narcisa.Vasile, tbashar,
	Harini.Ramakrishnan, pallavi.kadam

Fnmatch implementation is required on Windows to support
log level arguments specified with a globbing pattern.
The source file is with BSD-3-Clause license.
https://github.com/lattera/freebsd/blob/master/usr.bin/csup/fnmatch.c

Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
Reviewed-by: Tasnim Bashar <tbashar@mellanox.com>
Tested-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
---
 lib/librte_eal/windows/fnmatch.c         | 172 +++++++++++++++++++++++
 lib/librte_eal/windows/include/fnmatch.h |  16 +--
 lib/librte_eal/windows/meson.build       |   1 +
 3 files changed, 181 insertions(+), 8 deletions(-)
 create mode 100644 lib/librte_eal/windows/fnmatch.c

diff --git a/lib/librte_eal/windows/fnmatch.c b/lib/librte_eal/windows/fnmatch.c
new file mode 100644
index 000000000..f622bf54c
--- /dev/null
+++ b/lib/librte_eal/windows/fnmatch.c
@@ -0,0 +1,172 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 1989, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Guido van Rossum.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static const char sccsid[] = "@(#)fnmatch.c	8.2 (Berkeley) 4/16/94";
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6.
+ * Compares a filename or pathname to a pattern.
+ */
+
+#include <ctype.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "fnmatch.h"
+
+#define EOS	'\0'
+
+static const char *rangematch(const char *, char, int);
+
+int
+fnmatch(const char *pattern, const char *string, int flags)
+{
+	const char *stringstart;
+	char c, test;
+
+	for (stringstart = string;;)
+		switch (c = *pattern++) {
+		case EOS:
+			if ((flags & FNM_LEADING_DIR) && *string == '/')
+				return (0);
+			return (*string == EOS ? 0 : FNM_NOMATCH);
+		case '?':
+			if (*string == EOS)
+				return (FNM_NOMATCH);
+			if (*string == '/' && (flags & FNM_PATHNAME))
+				return (FNM_NOMATCH);
+			if (*string == '.' && (flags & FNM_PERIOD) &&
+			    (string == stringstart ||
+			    ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
+				return (FNM_NOMATCH);
+			++string;
+			break;
+		case '*':
+			c = *pattern;
+			/* Collapse multiple stars. */
+			while (c == '*')
+				c = *++pattern;
+
+			if (*string == '.' && (flags & FNM_PERIOD) &&
+			    (string == stringstart ||
+			    ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
+				return (FNM_NOMATCH);
+
+			/* Optimize for pattern with * at end or before /. */
+			if (c == EOS)
+				if (flags & FNM_PATHNAME)
+					return ((flags & FNM_LEADING_DIR) ||
+					    strchr(string, '/') == NULL ?
+					    0 : FNM_NOMATCH);
+				else
+					return (0);
+			else if (c == '/' && flags & FNM_PATHNAME) {
+				string = strchr(string, '/');
+				if (string == NULL)
+					return (FNM_NOMATCH);
+				break;
+			}
+
+			/* General case, use recursion. */
+			while ((test = *string) != EOS) {
+				if (!fnmatch(pattern, string,
+					flags & ~FNM_PERIOD))
+					return (0);
+				if (test == '/' && flags & FNM_PATHNAME)
+					break;
+				++string;
+			}
+			return (FNM_NOMATCH);
+		case '[':
+			if (*string == EOS)
+				return (FNM_NOMATCH);
+			if (*string == '/' && flags & FNM_PATHNAME)
+				return (FNM_NOMATCH);
+			pattern = rangematch(pattern, *string, flags);
+			if (pattern == NULL)
+				return (FNM_NOMATCH);
+			++string;
+			break;
+		case '\\':
+			if (!(flags & FNM_NOESCAPE)) {
+				c = *pattern++;
+				if (c == EOS) {
+					c = '\\';
+					--pattern;
+				}
+			}
+			/* FALLTHROUGH */
+		default:
+			if (c == *string)
+				;
+			else if ((flags & FNM_CASEFOLD) &&
+				 (tolower((unsigned char)c) ==
+				  tolower((unsigned char)*string)))
+				;
+			else if ((flags & FNM_PREFIX_DIRS) && *string == EOS &&
+			     ((c == '/' && string != stringstart) ||
+			     (string == stringstart+1 && *stringstart == '/')))
+				return (0);
+			else
+				return (FNM_NOMATCH);
+			string++;
+			break;
+		}
+	/* NOTREACHED */
+}
+
+static const char *
+rangematch(const char *pattern, char test, int flags)
+{
+	int negate, ok;
+	char c, c2;
+
+	/*
+	 * A bracket expression starting with an unquoted circumflex
+	 * character produces unspecified results (IEEE 1003.2-1992,
+	 * 3.13.2).  This implementation treats it like '!', for
+	 * consistency with the regular expression syntax.
+	 * J.T. Conklin (conklin@ngai.kaleida.com)
+	 */
+	negate = (*pattern == '!' || *pattern == '^');
+	if (negate)
+		++pattern;
+
+	if (flags & FNM_CASEFOLD)
+		test = tolower((unsigned char)test);
+
+	for (ok = 0; (c = *pattern++) != ']';) {
+		if (c == '\\' && !(flags & FNM_NOESCAPE))
+			c = *pattern++;
+		if (c == EOS)
+			return (NULL);
+
+		if (flags & FNM_CASEFOLD)
+			c = tolower((unsigned char)c);
+
+		c2 = *(pattern + 1);
+		if (*pattern == '-' && c2 != EOS && c2 != ']') {
+			pattern += 2;
+			if (c2 == '\\' && !(flags & FNM_NOESCAPE))
+				c2 = *pattern++;
+			if (c2 == EOS)
+				return (NULL);
+
+			if (flags & FNM_CASEFOLD)
+				c2 = tolower((unsigned char)c2);
+
+			if ((unsigned char)c <= (unsigned char)test &&
+			    (unsigned char)test <= (unsigned char)c2)
+				ok = 1;
+		} else if (c == test)
+			ok = 1;
+	}
+	return (ok == negate ? NULL : pattern);
+}
diff --git a/lib/librte_eal/windows/include/fnmatch.h b/lib/librte_eal/windows/include/fnmatch.h
index d0159f07a..142753c35 100644
--- a/lib/librte_eal/windows/include/fnmatch.h
+++ b/lib/librte_eal/windows/include/fnmatch.h
@@ -18,6 +18,13 @@ extern "C" {
 
 #define FNM_NOMATCH 1
 
+#define FNM_NOESCAPE 0x01
+#define FNM_PATHNAME 0x02
+#define FNM_PERIOD 0x04
+#define FNM_LEADING_DIR 0x08
+#define FNM_CASEFOLD 0x10
+#define FNM_PREFIX_DIRS 0x20
+
 /**
  * This function is used for searhing a given string source
  * with the given regular expression pattern.
@@ -34,14 +41,7 @@ extern "C" {
  * @return
  *	if the pattern is found then return 0 or else FNM_NOMATCH
  */
-static inline int fnmatch(__rte_unused const char *pattern,
-		__rte_unused const char *string,
-		__rte_unused int flags)
-{
-	/* TODO */
-	/* This is a stub, not the expected result */
-	return FNM_NOMATCH;
-}
+int fnmatch(const char *pattern, const char *string, int flags);
 
 #ifdef __cplusplus
 }
diff --git a/lib/librte_eal/windows/meson.build b/lib/librte_eal/windows/meson.build
index 09dd4ab2f..8829407c4 100644
--- a/lib/librte_eal/windows/meson.build
+++ b/lib/librte_eal/windows/meson.build
@@ -8,5 +8,6 @@ sources += files(
 	'eal_debug.c',
 	'eal_lcore.c',
 	'eal_thread.c',
+	'fnmatch.c',
 	'getopt.c',
 )
-- 
2.18.0.windows.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [dpdk-dev] [PATCH v2 2/2] eal: add log support on Windows
  2020-05-06  1:30 ` [dpdk-dev] [PATCH v2 " Pallavi Kadam
  2020-05-06  1:30   ` [dpdk-dev] [PATCH v2 1/2] eal: add fnmatch implementation Pallavi Kadam
@ 2020-05-06  1:30   ` Pallavi Kadam
  2020-05-06  2:20     ` Narcisa Ana Maria Vasile
  2020-05-07 10:17     ` Thomas Monjalon
  2020-05-07 10:19   ` [dpdk-dev] [PATCH v2 0/2] Windows logging Thomas Monjalon
  2 siblings, 2 replies; 16+ messages in thread
From: Pallavi Kadam @ 2020-05-06  1:30 UTC (permalink / raw)
  To: dev, thomas
  Cc: ranjit.menon, dmitry.kozliuk, Narcisa.Vasile, tbashar,
	Harini.Ramakrishnan, pallavi.kadam

Initialize logging on Windows to send log output
to the console.

Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
Reviewed-by: Tasnim Bashar <tbashar@mellanox.com>
Tested-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
---
 lib/librte_eal/windows/eal.c       |  3 +++
 lib/librte_eal/windows/eal_log.c   | 16 ++++++++++++++++
 lib/librte_eal/windows/meson.build |  1 +
 3 files changed, 20 insertions(+)
 create mode 100644 lib/librte_eal/windows/eal_log.c

diff --git a/lib/librte_eal/windows/eal.c b/lib/librte_eal/windows/eal.c
index 2cf7a04ef..123afed8d 100644
--- a/lib/librte_eal/windows/eal.c
+++ b/lib/librte_eal/windows/eal.c
@@ -227,6 +227,9 @@ rte_eal_init(int argc, char **argv)
 {
 	int i, fctret;
 
+	/* initialize all logs */
+	rte_eal_log_init(NULL, 0);
+
 	eal_log_level_parse(argc, argv);
 
 	/* create a map of all processors in the system */
diff --git a/lib/librte_eal/windows/eal_log.c b/lib/librte_eal/windows/eal_log.c
new file mode 100644
index 000000000..875981f13
--- /dev/null
+++ b/lib/librte_eal/windows/eal_log.c
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2017-2018 Intel Corporation
+ */
+
+#include "eal_private.h"
+
+/* set the log to default function, called during eal init process. */
+int
+rte_eal_log_init(__rte_unused const char *id, __rte_unused int facility)
+{
+	rte_openlog_stream(stderr);
+
+	eal_log_set_default(stderr);
+
+	return 0;
+}
diff --git a/lib/librte_eal/windows/meson.build b/lib/librte_eal/windows/meson.build
index 8829407c4..adfc8b9b7 100644
--- a/lib/librte_eal/windows/meson.build
+++ b/lib/librte_eal/windows/meson.build
@@ -7,6 +7,7 @@ sources += files(
 	'eal.c',
 	'eal_debug.c',
 	'eal_lcore.c',
+	'eal_log.c',
 	'eal_thread.c',
 	'fnmatch.c',
 	'getopt.c',
-- 
2.18.0.windows.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [dpdk-dev] [PATCH v2 2/2] eal: add log support on Windows
  2020-05-06  1:30   ` [dpdk-dev] [PATCH v2 2/2] eal: add log support on Windows Pallavi Kadam
@ 2020-05-06  2:20     ` Narcisa Ana Maria Vasile
  2020-05-07 10:17     ` Thomas Monjalon
  1 sibling, 0 replies; 16+ messages in thread
From: Narcisa Ana Maria Vasile @ 2020-05-06  2:20 UTC (permalink / raw)
  To: Pallavi Kadam
  Cc: dev, thomas, ranjit.menon, dmitry.kozliuk, Narcisa.Vasile,
	tbashar, Harini.Ramakrishnan

On Tue, May 05, 2020 at 06:30:32PM -0700, Pallavi Kadam wrote:
> Initialize logging on Windows to send log output
> to the console.
> 
> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
> Reviewed-by: Tasnim Bashar <tbashar@mellanox.com>
> Tested-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> ---
Tested-by: Narcisa Vasile <navasile@linux.microsoft.com>
Acked-by: Narcisa Vasile <navasile@linux.microsoft.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [dpdk-dev] [PATCH v2 1/2] eal: add fnmatch implementation
  2020-05-06  1:30   ` [dpdk-dev] [PATCH v2 1/2] eal: add fnmatch implementation Pallavi Kadam
@ 2020-05-06  2:24     ` Narcisa Ana Maria Vasile
  0 siblings, 0 replies; 16+ messages in thread
From: Narcisa Ana Maria Vasile @ 2020-05-06  2:24 UTC (permalink / raw)
  To: Pallavi Kadam
  Cc: dev, thomas, ranjit.menon, dmitry.kozliuk, Narcisa.Vasile,
	tbashar, Harini.Ramakrishnan, ocardona

On Tue, May 05, 2020 at 06:30:31PM -0700, Pallavi Kadam wrote:
> Fnmatch implementation is required on Windows to support
> log level arguments specified with a globbing pattern.
> The source file is with BSD-3-Clause license.
> https://github.com/lattera/freebsd/blob/master/usr.bin/csup/fnmatch.c
> 
> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
> Reviewed-by: Tasnim Bashar <tbashar@mellanox.com>
> Tested-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> ---
Acked-by: Narcisa Vasile <navasile@linux.microsoft.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [dpdk-dev] [PATCH v2 2/2] eal: add log support on Windows
  2020-05-06  1:30   ` [dpdk-dev] [PATCH v2 2/2] eal: add log support on Windows Pallavi Kadam
  2020-05-06  2:20     ` Narcisa Ana Maria Vasile
@ 2020-05-07 10:17     ` Thomas Monjalon
  1 sibling, 0 replies; 16+ messages in thread
From: Thomas Monjalon @ 2020-05-07 10:17 UTC (permalink / raw)
  To: Pallavi Kadam
  Cc: dev, ranjit.menon, dmitry.kozliuk, Narcisa.Vasile, tbashar,
	Harini.Ramakrishnan

06/05/2020 03:30, Pallavi Kadam:
> Initialize logging on Windows to send log output
> to the console.
> 
> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
> Reviewed-by: Tasnim Bashar <tbashar@mellanox.com>
> Tested-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> ---

The comment below is useless. I take freedom of dropping it on apply :-)

> +	/* initialize all logs */
> +	rte_eal_log_init(NULL, 0);




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [dpdk-dev] [PATCH v2 0/2] Windows logging
  2020-05-06  1:30 ` [dpdk-dev] [PATCH v2 " Pallavi Kadam
  2020-05-06  1:30   ` [dpdk-dev] [PATCH v2 1/2] eal: add fnmatch implementation Pallavi Kadam
  2020-05-06  1:30   ` [dpdk-dev] [PATCH v2 2/2] eal: add log support on Windows Pallavi Kadam
@ 2020-05-07 10:19   ` Thomas Monjalon
  2 siblings, 0 replies; 16+ messages in thread
From: Thomas Monjalon @ 2020-05-07 10:19 UTC (permalink / raw)
  To: Pallavi Kadam
  Cc: dev, ranjit.menon, dmitry.kozliuk, Narcisa.Vasile, tbashar,
	Harini.Ramakrishnan

06/05/2020 03:30, Pallavi Kadam:
> This patchset adds EAL logging support on Windows.
> Logs will be sent to console output.
> 
> v2 Changes:
> 	Introduced Fnmatch implementation first
> 	Added logging support in the second patch
> 
> Pallavi Kadam (2):
>   eal: add fnmatch implementation
>   eal: add log support on Windows

Applied, thanks



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2020-05-07 10:19 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-29 23:24 [dpdk-dev] [PATCH 0/2] Windows logging Pallavi Kadam
2020-04-29 23:24 ` [dpdk-dev] [PATCH 1/2] eal: initialize eal logging on Windows Pallavi Kadam
2020-04-29 23:24 ` [dpdk-dev] [PATCH 2/2] eal: add fnmatch implementation " Pallavi Kadam
2020-04-30  6:52   ` Thomas Monjalon
2020-04-30  7:30     ` Dmitry Kozlyuk
2020-05-01  1:08       ` Ranjit Menon
2020-05-04 16:51         ` Thomas Monjalon
2020-04-30  6:48 ` [dpdk-dev] [PATCH 0/2] Windows logging Thomas Monjalon
2020-04-30 22:18   ` Kadam, Pallavi
2020-05-06  1:30 ` [dpdk-dev] [PATCH v2 " Pallavi Kadam
2020-05-06  1:30   ` [dpdk-dev] [PATCH v2 1/2] eal: add fnmatch implementation Pallavi Kadam
2020-05-06  2:24     ` Narcisa Ana Maria Vasile
2020-05-06  1:30   ` [dpdk-dev] [PATCH v2 2/2] eal: add log support on Windows Pallavi Kadam
2020-05-06  2:20     ` Narcisa Ana Maria Vasile
2020-05-07 10:17     ` Thomas Monjalon
2020-05-07 10:19   ` [dpdk-dev] [PATCH v2 0/2] Windows logging Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).