DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/2] cmdline: add polling mode for command line
@ 2015-05-12 11:10 Pawel Wodkowski
  2015-05-12 11:10 ` [dpdk-dev] [PATCH 1/2] cmdline: fix missing include files Pawel Wodkowski
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Pawel Wodkowski @ 2015-05-12 11:10 UTC (permalink / raw)
  To: dev

This patchset adds the ability to process console input in the same thread
as packet processing by using poll() function and fixes some minor issues.

Pawel Wodkowski (2):
  cmdline: fix missing include files
  cmdline: add polling mode for command line

 lib/librte_cmdline/cmdline.c               | 35 ++++++++++++++++++++++++++++++
 lib/librte_cmdline/cmdline.h               |  4 ++++
 lib/librte_cmdline/cmdline_rdline.h        |  1 +
 lib/librte_cmdline/cmdline_vt100.h         |  2 ++
 lib/librte_cmdline/rte_cmdline_version.map |  1 +
 5 files changed, 43 insertions(+)

-- 
1.9.1

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

* [dpdk-dev] [PATCH 1/2] cmdline: fix missing include files
  2015-05-12 11:10 [dpdk-dev] [PATCH 0/2] cmdline: add polling mode for command line Pawel Wodkowski
@ 2015-05-12 11:10 ` Pawel Wodkowski
  2015-05-12 11:10 ` [dpdk-dev] [PATCH 2/2] cmdline: add polling mode for command line Pawel Wodkowski
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 13+ messages in thread
From: Pawel Wodkowski @ 2015-05-12 11:10 UTC (permalink / raw)
  To: dev

When including only some of library headers some definitions
are missing and build fails.

Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
---
 lib/librte_cmdline/cmdline.h        | 3 +++
 lib/librte_cmdline/cmdline_rdline.h | 1 +
 lib/librte_cmdline/cmdline_vt100.h  | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/lib/librte_cmdline/cmdline.h b/lib/librte_cmdline/cmdline.h
index 06ae086..9085ff6 100644
--- a/lib/librte_cmdline/cmdline.h
+++ b/lib/librte_cmdline/cmdline.h
@@ -61,6 +61,9 @@
 #ifndef _CMDLINE_H_
 #define _CMDLINE_H_
 
+#include <termios.h>
+#include <cmdline_rdline.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/lib/librte_cmdline/cmdline_rdline.h b/lib/librte_cmdline/cmdline_rdline.h
index ae6e24e..b9aad9b 100644
--- a/lib/librte_cmdline/cmdline_rdline.h
+++ b/lib/librte_cmdline/cmdline_rdline.h
@@ -84,6 +84,7 @@
  *   instance.
  */
 
+#include <stdio.h>
 #include <cmdline_cirbuf.h>
 #include <cmdline_vt100.h>
 
diff --git a/lib/librte_cmdline/cmdline_vt100.h b/lib/librte_cmdline/cmdline_vt100.h
index b9840f6..963add8 100644
--- a/lib/librte_cmdline/cmdline_vt100.h
+++ b/lib/librte_cmdline/cmdline_vt100.h
@@ -61,6 +61,8 @@
 #ifndef _CMDLINE_VT100_H_
 #define _CMDLINE_VT100_H_
 
+#include <stdint.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
-- 
1.9.1

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

* [dpdk-dev] [PATCH 2/2] cmdline: add polling mode for command line
  2015-05-12 11:10 [dpdk-dev] [PATCH 0/2] cmdline: add polling mode for command line Pawel Wodkowski
  2015-05-12 11:10 ` [dpdk-dev] [PATCH 1/2] cmdline: fix missing include files Pawel Wodkowski
@ 2015-05-12 11:10 ` Pawel Wodkowski
  2015-05-12 14:36   ` Olivier MATZ
  2015-05-12 11:36 ` [dpdk-dev] [PATCH 0/2] " Dumitrescu, Cristian
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 13+ messages in thread
From: Pawel Wodkowski @ 2015-05-12 11:10 UTC (permalink / raw)
  To: dev

This patch adds the ability to process console input in the same thread
as packet processing by using poll() function.

Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
---
 lib/librte_cmdline/cmdline.c               | 35 ++++++++++++++++++++++++++++++
 lib/librte_cmdline/cmdline.h               |  1 +
 lib/librte_cmdline/rte_cmdline_version.map |  1 +
 3 files changed, 37 insertions(+)

diff --git a/lib/librte_cmdline/cmdline.c b/lib/librte_cmdline/cmdline.c
index e61c4f2..6a55f1f 100644
--- a/lib/librte_cmdline/cmdline.c
+++ b/lib/librte_cmdline/cmdline.c
@@ -65,6 +65,7 @@
 #include <stdarg.h>
 #include <inttypes.h>
 #include <fcntl.h>
+#include <poll.h>
 #include <errno.h>
 #include <termios.h>
 #include <netinet/in.h>
@@ -246,6 +247,40 @@ cmdline_quit(struct cmdline *cl)
 	rdline_quit(&cl->rdl);
 }
 
+int
+cmdline_poll(struct cmdline *cl)
+{
+	struct pollfd pfd;
+	int status;
+	ssize_t read_status;
+	char c;
+
+	if (!cl)
+		return -EINVAL;
+	else if (cl->rdl.status == RDLINE_EXITED)
+		return RDLINE_EXITED;
+
+	pfd.fd = cl->s_in;
+	pfd.events = POLLIN;
+	pfd.revents = 0;
+
+	status = poll(&pfd, 1, 0);
+	if (status < 0)
+		return status;
+	else if (status > 0) {
+		c = -1;
+		read_status = read(cl->s_in, &c, 1);
+		if (read_status < 0)
+			return read_status;
+
+		status = cmdline_in(cl, &c, 1);
+		if (status < 0 && cl->rdl.status != RDLINE_EXITED)
+			return status;
+	}
+
+	return cl->rdl.status;
+}
+
 void
 cmdline_interact(struct cmdline *cl)
 {
diff --git a/lib/librte_cmdline/cmdline.h b/lib/librte_cmdline/cmdline.h
index 9085ff6..39e8e6b 100644
--- a/lib/librte_cmdline/cmdline.h
+++ b/lib/librte_cmdline/cmdline.h
@@ -84,6 +84,7 @@ void cmdline_printf(const struct cmdline *cl, const char *fmt, ...)
 	__attribute__((format(printf,2,3)));
 int cmdline_in(struct cmdline *cl, const char *buf, int size);
 int cmdline_write_char(struct rdline *rdl, char c);
+int cmdline_poll(struct cmdline *cl);
 void cmdline_interact(struct cmdline *cl);
 void cmdline_quit(struct cmdline *cl);
 
diff --git a/lib/librte_cmdline/rte_cmdline_version.map b/lib/librte_cmdline/rte_cmdline_version.map
index 6193462..df55def 100644
--- a/lib/librte_cmdline/rte_cmdline_version.map
+++ b/lib/librte_cmdline/rte_cmdline_version.map
@@ -40,6 +40,7 @@ DPDK_2.0 {
 	cmdline_parse_num;
 	cmdline_parse_portlist;
 	cmdline_parse_string;
+	cmdline_poll;
 	cmdline_printf;
 	cmdline_quit;
 	cmdline_set_prompt;
-- 
1.9.1

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

* Re: [dpdk-dev] [PATCH 0/2] cmdline: add polling mode for command line
  2015-05-12 11:10 [dpdk-dev] [PATCH 0/2] cmdline: add polling mode for command line Pawel Wodkowski
  2015-05-12 11:10 ` [dpdk-dev] [PATCH 1/2] cmdline: fix missing include files Pawel Wodkowski
  2015-05-12 11:10 ` [dpdk-dev] [PATCH 2/2] cmdline: add polling mode for command line Pawel Wodkowski
@ 2015-05-12 11:36 ` Dumitrescu, Cristian
  2015-05-12 15:32 ` Wodkowski, PawelX
  2015-05-13 11:59 ` [dpdk-dev] [PATCH v2 " Pawel Wodkowski
  4 siblings, 0 replies; 13+ messages in thread
From: Dumitrescu, Cristian @ 2015-05-12 11:36 UTC (permalink / raw)
  To: Pawel Wodkowski, dev



> -----Original Message-----
> From: Pawel Wodkowski [mailto:pwodkowx@stargo]
> Sent: Tuesday, May 12, 2015 12:10 PM
> To: dev@dpdk.org
> Cc: Dumitrescu, Cristian; Jastrzebski, MichalX K
> Subject: [PATCH 0/2] cmdline: add polling mode for command line
> 
> This patchset adds the ability to process console input in the same thread
> as packet processing by using poll() function and fixes some minor issues.
> 
> Pawel Wodkowski (2):
>   cmdline: fix missing include files
>   cmdline: add polling mode for command line
> 
>  lib/librte_cmdline/cmdline.c               | 35
> ++++++++++++++++++++++++++++++
>  lib/librte_cmdline/cmdline.h               |  4 ++++
>  lib/librte_cmdline/cmdline_rdline.h        |  1 +
>  lib/librte_cmdline/cmdline_vt100.h         |  2 ++
>  lib/librte_cmdline/rte_cmdline_version.map |  1 +
>  5 files changed, 43 insertions(+)
> 
> --
> 1.9.1

Acked by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

The existing cmdline API requires a thread to be completely consumed for running the CLI, so it is not possible to push any other tasks (typically slow tasks, control plane related) on the same thread. This is because the cmdline_interact() function implements an infinite loop internally, so once called after initialization, it only returns when the application is terminated (e.g. as result of quit CLI command).

This patch removes this limitation by providing an alternative function called cmdline_poll(), which allows the application to own the thread dispatch loop and work with the CLI in polling mode, hence making it possible for the application to push additional work on the same thread. The thread dispatch loop should be owned by the application, and not by the cmdline library.

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

* Re: [dpdk-dev] [PATCH 2/2] cmdline: add polling mode for command line
  2015-05-12 11:10 ` [dpdk-dev] [PATCH 2/2] cmdline: add polling mode for command line Pawel Wodkowski
@ 2015-05-12 14:36   ` Olivier MATZ
  2015-05-12 16:14     ` Pawel Wodkowski
  0 siblings, 1 reply; 13+ messages in thread
From: Olivier MATZ @ 2015-05-12 14:36 UTC (permalink / raw)
  To: Pawel Wodkowski, dev

Hi Pawel,

On 05/12/2015 01:10 PM, Pawel Wodkowski wrote:
> This patch adds the ability to process console input in the same thread
> as packet processing by using poll() function.
>
> Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
> [...]
> --- a/lib/librte_cmdline/cmdline.h
> +++ b/lib/librte_cmdline/cmdline.h
> @@ -84,6 +84,7 @@ void cmdline_printf(const struct cmdline *cl, const char *fmt, ...)
>  	__attribute__((format(printf,2,3)));
>  int cmdline_in(struct cmdline *cl, const char *buf, int size);
>  int cmdline_write_char(struct rdline *rdl, char c);
> +int cmdline_poll(struct cmdline *cl);
>  void cmdline_interact(struct cmdline *cl);
>  void cmdline_quit(struct cmdline *cl);
>
> diff --git a/lib/librte_cmdline/rte_cmdline_version.map b/lib/librte_cmdline/rte_cmdline_version.map
> index 6193462..df55def 100644

I know the rest of the file does not document the functions
prototypes, but I think it could be helpful to add doxygen-style
comments for new functions.

> diff --git a/lib/librte_cmdline/rte_cmdline_version.map b/lib/librte_cmdline/rte_cmdline_version.map
> index 6193462..df55def 100644
> --- a/lib/librte_cmdline/rte_cmdline_version.map
> +++ b/lib/librte_cmdline/rte_cmdline_version.map
> @@ -40,6 +40,7 @@ DPDK_2.0 {
>   	cmdline_parse_num;
>   	cmdline_parse_portlist;
>   	cmdline_parse_string;
> +	cmdline_poll;
>   	cmdline_printf;
>   	cmdline_quit;
>   	cmdline_set_prompt;
>

I'm not sure the .map should be modified like this, instead I
would have added a new DPDK_2.1 section, like I did for this
commit (reviewed by Neil):
http://dpdk.org/browse/dpdk/commit/?id=bbd778248985e542175e9b4ce560f2d379e78c4e

By the way, the following link is a good documentation about the
.map files:
http://people.freebsd.org/~deischen/symver/freebsd_versioning.txt

Regards,
Olivier

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

* Re: [dpdk-dev] [PATCH 0/2] cmdline: add polling mode for command line
  2015-05-12 11:10 [dpdk-dev] [PATCH 0/2] cmdline: add polling mode for command line Pawel Wodkowski
                   ` (2 preceding siblings ...)
  2015-05-12 11:36 ` [dpdk-dev] [PATCH 0/2] " Dumitrescu, Cristian
@ 2015-05-12 15:32 ` Wodkowski, PawelX
  2015-05-13 11:59 ` [dpdk-dev] [PATCH v2 " Pawel Wodkowski
  4 siblings, 0 replies; 13+ messages in thread
From: Wodkowski, PawelX @ 2015-05-12 15:32 UTC (permalink / raw)
  To: dev

Self NACK - misconfigured git - wrong email address :(

I will resend this.

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Pawel Wodkowski
> Sent: Tuesday, May 12, 2015 1:10 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH 0/2] cmdline: add polling mode for command line
> 
> This patchset adds the ability to process console input in the same thread
> as packet processing by using poll() function and fixes some minor issues.
> 
> Pawel Wodkowski (2):
>   cmdline: fix missing include files
>   cmdline: add polling mode for command line
> 
>  lib/librte_cmdline/cmdline.c               | 35 ++++++++++++++++++++++++++++++
>  lib/librte_cmdline/cmdline.h               |  4 ++++
>  lib/librte_cmdline/cmdline_rdline.h        |  1 +
>  lib/librte_cmdline/cmdline_vt100.h         |  2 ++
>  lib/librte_cmdline/rte_cmdline_version.map |  1 +
>  5 files changed, 43 insertions(+)
> 
> --
> 1.9.1

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

* Re: [dpdk-dev] [PATCH 2/2] cmdline: add polling mode for command line
  2015-05-12 14:36   ` Olivier MATZ
@ 2015-05-12 16:14     ` Pawel Wodkowski
  0 siblings, 0 replies; 13+ messages in thread
From: Pawel Wodkowski @ 2015-05-12 16:14 UTC (permalink / raw)
  To: Olivier MATZ, Pawel Wodkowski, dev

On 2015-05-12 16:36, Olivier MATZ wrote:
> Hi Pawel,
>
> On 05/12/2015 01:10 PM, Pawel Wodkowski wrote:
>> This patch adds the ability to process console input in the same thread
>> as packet processing by using poll() function.
>>
>> Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
>> [...]
>> --- a/lib/librte_cmdline/cmdline.h
>> +++ b/lib/librte_cmdline/cmdline.h
>> @@ -84,6 +84,7 @@ void cmdline_printf(const struct cmdline *cl, const 
>> char *fmt, ...)
>>      __attribute__((format(printf,2,3)));
>>  int cmdline_in(struct cmdline *cl, const char *buf, int size);
>>  int cmdline_write_char(struct rdline *rdl, char c);
>> +int cmdline_poll(struct cmdline *cl);
>>  void cmdline_interact(struct cmdline *cl);
>>  void cmdline_quit(struct cmdline *cl);
>>
>> diff --git a/lib/librte_cmdline/rte_cmdline_version.map 
>> b/lib/librte_cmdline/rte_cmdline_version.map
>> index 6193462..df55def 100644
>
> I know the rest of the file does not document the functions
> prototypes, but I think it could be helpful to add doxygen-style
> comments for new functions.

Yes, no problem.

>
>> diff --git a/lib/librte_cmdline/rte_cmdline_version.map 
>> b/lib/librte_cmdline/rte_cmdline_version.map
>> index 6193462..df55def 100644
>> --- a/lib/librte_cmdline/rte_cmdline_version.map
>> +++ b/lib/librte_cmdline/rte_cmdline_version.map
>> @@ -40,6 +40,7 @@ DPDK_2.0 {
>>       cmdline_parse_num;
>>       cmdline_parse_portlist;
>>       cmdline_parse_string;
>> +    cmdline_poll;
>>       cmdline_printf;
>>       cmdline_quit;
>>       cmdline_set_prompt;
>>
>
> I'm not sure the .map should be modified like this, instead I
> would have added a new DPDK_2.1 section, like I did for this
> commit (reviewed by Neil):
> http://dpdk.org/browse/dpdk/commit/?id=bbd778248985e542175e9b4ce560f2d379e78c4e 
>
>
> By the way, the following link is a good documentation about the
> .map files:
> http://people.freebsd.org/~deischen/symver/freebsd_versioning.txt

Thank you, I will follow those instructions :)

Please check v2 I will send shortly.
-- 
Pawel

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

* [dpdk-dev] [PATCH v2 0/2] cmdline: add polling mode for command line
  2015-05-12 11:10 [dpdk-dev] [PATCH 0/2] cmdline: add polling mode for command line Pawel Wodkowski
                   ` (3 preceding siblings ...)
  2015-05-12 15:32 ` Wodkowski, PawelX
@ 2015-05-13 11:59 ` Pawel Wodkowski
  2015-05-13 12:00   ` [dpdk-dev] [PATCH v2 1/2] cmdline: fix missing include files Pawel Wodkowski
                     ` (3 more replies)
  4 siblings, 4 replies; 13+ messages in thread
From: Pawel Wodkowski @ 2015-05-13 11:59 UTC (permalink / raw)
  To: dev

This patchset adds the ability to process console input in the same thread
as packet processing by using poll() function and fixes some minor issues.

v2 changes:
 - add doxygen documentation for cmdline_poll()
 - map file issue fixed
 - use proper email address.
 - add addtional missing include in cmdline_parse_ipaddr.h

Pawel Wodkowski (2):
  cmdline: fix missing include files
  cmdline: add polling mode for command line

 doc/api/doxy-api.conf                      |  1 +
 lib/librte_cmdline/cmdline.c               | 35 ++++++++++++++++++++++++++++++
 lib/librte_cmdline/cmdline.h               | 24 ++++++++++++++++++++
 lib/librte_cmdline/cmdline_parse_ipaddr.h  |  2 ++
 lib/librte_cmdline/cmdline_rdline.h        |  1 +
 lib/librte_cmdline/cmdline_vt100.h         |  2 ++
 lib/librte_cmdline/rte_cmdline_version.map |  8 +++++++
 7 files changed, 73 insertions(+)

-- 
1.9.1

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

* [dpdk-dev] [PATCH v2 1/2] cmdline: fix missing include files
  2015-05-13 11:59 ` [dpdk-dev] [PATCH v2 " Pawel Wodkowski
@ 2015-05-13 12:00   ` Pawel Wodkowski
  2015-05-13 12:00   ` [dpdk-dev] [PATCH v2 2/2] cmdline: add polling mode for command line Pawel Wodkowski
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 13+ messages in thread
From: Pawel Wodkowski @ 2015-05-13 12:00 UTC (permalink / raw)
  To: dev

When including only some of library headers some definitions
are missing and build fails.

Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
---
 lib/librte_cmdline/cmdline.h              | 3 +++
 lib/librte_cmdline/cmdline_parse_ipaddr.h | 2 ++
 lib/librte_cmdline/cmdline_rdline.h       | 1 +
 lib/librte_cmdline/cmdline_vt100.h        | 2 ++
 4 files changed, 8 insertions(+)

diff --git a/lib/librte_cmdline/cmdline.h b/lib/librte_cmdline/cmdline.h
index 06ae086..9085ff6 100644
--- a/lib/librte_cmdline/cmdline.h
+++ b/lib/librte_cmdline/cmdline.h
@@ -61,6 +61,9 @@
 #ifndef _CMDLINE_H_
 #define _CMDLINE_H_
 
+#include <termios.h>
+#include <cmdline_rdline.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/lib/librte_cmdline/cmdline_parse_ipaddr.h b/lib/librte_cmdline/cmdline_parse_ipaddr.h
index 296c374..46c6e1b 100644
--- a/lib/librte_cmdline/cmdline_parse_ipaddr.h
+++ b/lib/librte_cmdline/cmdline_parse_ipaddr.h
@@ -61,6 +61,8 @@
 #ifndef _PARSE_IPADDR_H_
 #define _PARSE_IPADDR_H_
 
+#include <netinet/in.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/lib/librte_cmdline/cmdline_rdline.h b/lib/librte_cmdline/cmdline_rdline.h
index ae6e24e..b9aad9b 100644
--- a/lib/librte_cmdline/cmdline_rdline.h
+++ b/lib/librte_cmdline/cmdline_rdline.h
@@ -84,6 +84,7 @@
  *   instance.
  */
 
+#include <stdio.h>
 #include <cmdline_cirbuf.h>
 #include <cmdline_vt100.h>
 
diff --git a/lib/librte_cmdline/cmdline_vt100.h b/lib/librte_cmdline/cmdline_vt100.h
index b9840f6..963add8 100644
--- a/lib/librte_cmdline/cmdline_vt100.h
+++ b/lib/librte_cmdline/cmdline_vt100.h
@@ -61,6 +61,8 @@
 #ifndef _CMDLINE_VT100_H_
 #define _CMDLINE_VT100_H_
 
+#include <stdint.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
-- 
1.9.1

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

* [dpdk-dev] [PATCH v2 2/2] cmdline: add polling mode for command line
  2015-05-13 11:59 ` [dpdk-dev] [PATCH v2 " Pawel Wodkowski
  2015-05-13 12:00   ` [dpdk-dev] [PATCH v2 1/2] cmdline: fix missing include files Pawel Wodkowski
@ 2015-05-13 12:00   ` Pawel Wodkowski
  2015-05-13 12:44   ` [dpdk-dev] [PATCH v2 0/2] " Dumitrescu, Cristian
  2015-05-13 13:20   ` Olivier MATZ
  3 siblings, 0 replies; 13+ messages in thread
From: Pawel Wodkowski @ 2015-05-13 12:00 UTC (permalink / raw)
  To: dev

This patch adds the ability to process console input in the same thread
as packet processing by using poll() function.

Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
---
 doc/api/doxy-api.conf                      |  1 +
 lib/librte_cmdline/cmdline.c               | 35 ++++++++++++++++++++++++++++++
 lib/librte_cmdline/cmdline.h               | 21 ++++++++++++++++++
 lib/librte_cmdline/rte_cmdline_version.map |  8 +++++++
 4 files changed, 65 insertions(+)

diff --git a/doc/api/doxy-api.conf b/doc/api/doxy-api.conf
index 50b0105..51b11c7 100644
--- a/doc/api/doxy-api.conf
+++ b/doc/api/doxy-api.conf
@@ -33,6 +33,7 @@ INPUT                   = doc/api/doxy-api-index.md \
                           lib/librte_eal/common/include \
                           lib/librte_eal/common/include/generic \
                           lib/librte_acl \
+                          lib/librte_cmdline \
                           lib/librte_distributor \
                           lib/librte_ether \
                           lib/librte_hash \
diff --git a/lib/librte_cmdline/cmdline.c b/lib/librte_cmdline/cmdline.c
index e61c4f2..6a55f1f 100644
--- a/lib/librte_cmdline/cmdline.c
+++ b/lib/librte_cmdline/cmdline.c
@@ -65,6 +65,7 @@
 #include <stdarg.h>
 #include <inttypes.h>
 #include <fcntl.h>
+#include <poll.h>
 #include <errno.h>
 #include <termios.h>
 #include <netinet/in.h>
@@ -246,6 +247,40 @@ cmdline_quit(struct cmdline *cl)
 	rdline_quit(&cl->rdl);
 }
 
+int
+cmdline_poll(struct cmdline *cl)
+{
+	struct pollfd pfd;
+	int status;
+	ssize_t read_status;
+	char c;
+
+	if (!cl)
+		return -EINVAL;
+	else if (cl->rdl.status == RDLINE_EXITED)
+		return RDLINE_EXITED;
+
+	pfd.fd = cl->s_in;
+	pfd.events = POLLIN;
+	pfd.revents = 0;
+
+	status = poll(&pfd, 1, 0);
+	if (status < 0)
+		return status;
+	else if (status > 0) {
+		c = -1;
+		read_status = read(cl->s_in, &c, 1);
+		if (read_status < 0)
+			return read_status;
+
+		status = cmdline_in(cl, &c, 1);
+		if (status < 0 && cl->rdl.status != RDLINE_EXITED)
+			return status;
+	}
+
+	return cl->rdl.status;
+}
+
 void
 cmdline_interact(struct cmdline *cl)
 {
diff --git a/lib/librte_cmdline/cmdline.h b/lib/librte_cmdline/cmdline.h
index 9085ff6..2578ca8 100644
--- a/lib/librte_cmdline/cmdline.h
+++ b/lib/librte_cmdline/cmdline.h
@@ -64,6 +64,12 @@
 #include <termios.h>
 #include <cmdline_rdline.h>
 
+/**
+ * @file
+ *
+ * Command line API
+ */
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -84,6 +90,21 @@ void cmdline_printf(const struct cmdline *cl, const char *fmt, ...)
 	__attribute__((format(printf,2,3)));
 int cmdline_in(struct cmdline *cl, const char *buf, int size);
 int cmdline_write_char(struct rdline *rdl, char c);
+
+/**
+ * This function is nonblocking equivalent of ``cmdline_interact()``. It polls
+ * *cl* for one character and interpret it. If return value is *RDLINE_EXITED*
+ * it mean that ``cmdline_quit()`` was invoked.
+ *
+ * @param cl
+ *   The command line object.
+ *
+ * @return
+ *   On success return object status - one of *enum rdline_status*.
+ *   On error return negative value.
+ */
+int cmdline_poll(struct cmdline *cl);
+
 void cmdline_interact(struct cmdline *cl);
 void cmdline_quit(struct cmdline *cl);
 
diff --git a/lib/librte_cmdline/rte_cmdline_version.map b/lib/librte_cmdline/rte_cmdline_version.map
index 6193462..1b0c863 100644
--- a/lib/librte_cmdline/rte_cmdline_version.map
+++ b/lib/librte_cmdline/rte_cmdline_version.map
@@ -69,3 +69,11 @@ DPDK_2.0 {
 
 	local: *;
 };
+
+DPDK_2.1 {
+	global:
+
+	cmdline_poll;
+
+	local: *;
+} DPDK_2.0;
-- 
1.9.1

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

* Re: [dpdk-dev] [PATCH v2 0/2] cmdline: add polling mode for command line
  2015-05-13 11:59 ` [dpdk-dev] [PATCH v2 " Pawel Wodkowski
  2015-05-13 12:00   ` [dpdk-dev] [PATCH v2 1/2] cmdline: fix missing include files Pawel Wodkowski
  2015-05-13 12:00   ` [dpdk-dev] [PATCH v2 2/2] cmdline: add polling mode for command line Pawel Wodkowski
@ 2015-05-13 12:44   ` Dumitrescu, Cristian
  2015-05-13 13:20   ` Olivier MATZ
  3 siblings, 0 replies; 13+ messages in thread
From: Dumitrescu, Cristian @ 2015-05-13 12:44 UTC (permalink / raw)
  To: Wodkowski, PawelX, dev



> -----Original Message-----
> From: Wodkowski, PawelX
> Sent: Wednesday, May 13, 2015 1:00 PM
> To: dev@dpdk.org
> Cc: Dumitrescu, Cristian
> Subject: [PATCH v2 0/2] cmdline: add polling mode for command line
> 
> This patchset adds the ability to process console input in the same thread
> as packet processing by using poll() function and fixes some minor issues.
> 
> v2 changes:
>  - add doxygen documentation for cmdline_poll()
>  - map file issue fixed
>  - use proper email address.
>  - add addtional missing include in cmdline_parse_ipaddr.h
> 
> Pawel Wodkowski (2):
>   cmdline: fix missing include files
>   cmdline: add polling mode for command line
> 
>  doc/api/doxy-api.conf                      |  1 +
>  lib/librte_cmdline/cmdline.c               | 35
> ++++++++++++++++++++++++++++++
>  lib/librte_cmdline/cmdline.h               | 24 ++++++++++++++++++++
>  lib/librte_cmdline/cmdline_parse_ipaddr.h  |  2 ++
>  lib/librte_cmdline/cmdline_rdline.h        |  1 +
>  lib/librte_cmdline/cmdline_vt100.h         |  2 ++
>  lib/librte_cmdline/rte_cmdline_version.map |  8 +++++++
>  7 files changed, 73 insertions(+)
> 
> --
> 1.9.1

Acked by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

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

* Re: [dpdk-dev] [PATCH v2 0/2] cmdline: add polling mode for command line
  2015-05-13 11:59 ` [dpdk-dev] [PATCH v2 " Pawel Wodkowski
                     ` (2 preceding siblings ...)
  2015-05-13 12:44   ` [dpdk-dev] [PATCH v2 0/2] " Dumitrescu, Cristian
@ 2015-05-13 13:20   ` Olivier MATZ
  2015-05-18 13:18     ` Thomas Monjalon
  3 siblings, 1 reply; 13+ messages in thread
From: Olivier MATZ @ 2015-05-13 13:20 UTC (permalink / raw)
  To: Pawel Wodkowski, dev

Hi Pawel,

On 05/13/2015 01:59 PM, Pawel Wodkowski wrote:
> This patchset adds the ability to process console input in the same thread
> as packet processing by using poll() function and fixes some minor issues.
>
> v2 changes:
>   - add doxygen documentation for cmdline_poll()
>   - map file issue fixed
>   - use proper email address.
>   - add addtional missing include in cmdline_parse_ipaddr.h
>
> Pawel Wodkowski (2):
>    cmdline: fix missing include files
>    cmdline: add polling mode for command line
>
>   doc/api/doxy-api.conf                      |  1 +
>   lib/librte_cmdline/cmdline.c               | 35 ++++++++++++++++++++++++++++++
>   lib/librte_cmdline/cmdline.h               | 24 ++++++++++++++++++++
>   lib/librte_cmdline/cmdline_parse_ipaddr.h  |  2 ++
>   lib/librte_cmdline/cmdline_rdline.h        |  1 +
>   lib/librte_cmdline/cmdline_vt100.h         |  2 ++
>   lib/librte_cmdline/rte_cmdline_version.map |  8 +++++++
>   7 files changed, 73 insertions(+)
>


Acked-by: Olivier Matz <olivier.matz@6wind.com>


Thanks,
Olivier

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

* Re: [dpdk-dev] [PATCH v2 0/2] cmdline: add polling mode for command line
  2015-05-13 13:20   ` Olivier MATZ
@ 2015-05-18 13:18     ` Thomas Monjalon
  0 siblings, 0 replies; 13+ messages in thread
From: Thomas Monjalon @ 2015-05-18 13:18 UTC (permalink / raw)
  To: Pawel Wodkowski; +Cc: dev

2015-05-13 15:20, Olivier MATZ:
> On 05/13/2015 01:59 PM, Pawel Wodkowski wrote:
> > This patchset adds the ability to process console input in the same thread
> > as packet processing by using poll() function and fixes some minor issues.
> >
> > v2 changes:
> >   - add doxygen documentation for cmdline_poll()
> >   - map file issue fixed
> >   - use proper email address.
> >   - add addtional missing include in cmdline_parse_ipaddr.h
> >
> > Pawel Wodkowski (2):
> >    cmdline: fix missing include files
> >    cmdline: add polling mode for command line
> 
> Acked-by: Olivier Matz <olivier.matz@6wind.com>

Applied, thanks

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

end of thread, other threads:[~2015-05-18 13:19 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-12 11:10 [dpdk-dev] [PATCH 0/2] cmdline: add polling mode for command line Pawel Wodkowski
2015-05-12 11:10 ` [dpdk-dev] [PATCH 1/2] cmdline: fix missing include files Pawel Wodkowski
2015-05-12 11:10 ` [dpdk-dev] [PATCH 2/2] cmdline: add polling mode for command line Pawel Wodkowski
2015-05-12 14:36   ` Olivier MATZ
2015-05-12 16:14     ` Pawel Wodkowski
2015-05-12 11:36 ` [dpdk-dev] [PATCH 0/2] " Dumitrescu, Cristian
2015-05-12 15:32 ` Wodkowski, PawelX
2015-05-13 11:59 ` [dpdk-dev] [PATCH v2 " Pawel Wodkowski
2015-05-13 12:00   ` [dpdk-dev] [PATCH v2 1/2] cmdline: fix missing include files Pawel Wodkowski
2015-05-13 12:00   ` [dpdk-dev] [PATCH v2 2/2] cmdline: add polling mode for command line Pawel Wodkowski
2015-05-13 12:44   ` [dpdk-dev] [PATCH v2 0/2] " Dumitrescu, Cristian
2015-05-13 13:20   ` Olivier MATZ
2015-05-18 13:18     ` 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).