Soft Patch Panel
 help / color / Atom feed
* [spp] [PATCH 0/2] Rename shared lib command_conn
@ 2019-06-24  2:21 yasufum.o
  2019-06-24  2:21 ` [spp] [PATCH 1/2] shared/sec: revise funcs to connect to spp-ctl yasufum.o
  2019-06-24  2:21 ` [spp] [PATCH 2/2] shared/sec: rename command_conn.c yasufum.o
  0 siblings, 2 replies; 3+ messages in thread
From: yasufum.o @ 2019-06-24  2:21 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

From: Yasufumi Ogawa <yasufum.o@gmail.com>

Shared libs of SPP workers for connecting to spp-ctl are defined in
`command_conn.c` and `command_conn.h`. This update is to rename
`command_conn` to `conn_spp_ctl` to be explicitly it is just for
spp-ctl. This update also renames functions in these files.

Yasufumi Ogawa (2):
  shared/sec: revise funcs to connect to spp-ctl
  shared/sec: rename command_conn.c

 src/mirror/Makefile                           |  2 +-
 src/pcap/Makefile                             |  2 +-
 src/pcap/cmd_runner.c                         | 14 ++--
 .../secondary/spp_worker_th/cmd_runner.c      | 12 +--
 .../secondary/spp_worker_th/command_conn.h    | 82 -------------------
 .../{command_conn.c => conn_spp_ctl.c}        | 20 ++---
 .../secondary/spp_worker_th/conn_spp_ctl.h    | 70 ++++++++++++++++
 src/vf/Makefile                               |  2 +-
 8 files changed, 96 insertions(+), 108 deletions(-)
 delete mode 100644 src/shared/secondary/spp_worker_th/command_conn.h
 rename src/shared/secondary/spp_worker_th/{command_conn.c => conn_spp_ctl.c} (88%)
 create mode 100644 src/shared/secondary/spp_worker_th/conn_spp_ctl.h

-- 
2.17.1


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

* [spp] [PATCH 1/2] shared/sec: revise funcs to connect to spp-ctl
  2019-06-24  2:21 [spp] [PATCH 0/2] Rename shared lib command_conn yasufum.o
@ 2019-06-24  2:21 ` yasufum.o
  2019-06-24  2:21 ` [spp] [PATCH 2/2] shared/sec: rename command_conn.c yasufum.o
  1 sibling, 0 replies; 3+ messages in thread
From: yasufum.o @ 2019-06-24  2:21 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

From: Yasufumi Ogawa <yasufum.o@gmail.com>

Functions defined in `command_conn.c` and its header are prefixed as
`spp_`, but there are not application wide and the prefix should be
removed. This update is to simplize the name of functions, and revise
comments.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 src/pcap/cmd_runner.c                         | 12 +--
 .../secondary/spp_worker_th/cmd_runner.c      | 10 +--
 .../secondary/spp_worker_th/command_conn.c    | 18 ++---
 .../secondary/spp_worker_th/command_conn.h    | 74 ++++++++-----------
 4 files changed, 51 insertions(+), 63 deletions(-)

diff --git a/src/pcap/cmd_runner.c b/src/pcap/cmd_runner.c
index d623d8c..9541cbb 100644
--- a/src/pcap/cmd_runner.c
+++ b/src/pcap/cmd_runner.c
@@ -743,7 +743,7 @@ send_parse_error_response(int *sock,
 			"response_str=\n%s\n", msg);
 
 	/* send response to requester */
-	ret = spp_send_message(sock, msg, strlen(msg));
+	ret = send_ctl_msg(sock, msg, strlen(msg));
 	if (unlikely(ret != SPPWK_RET_OK)) {
 		RTE_LOG(ERR, PCAP_RUNNER,
 				"Failed to send parse error response.\n");
@@ -839,7 +839,7 @@ send_command_result_response(int *sock,
 			"response_str=\n%s\n", msg);
 
 	/* send response to requester */
-	ret = spp_send_message(sock, msg, strlen(msg));
+	ret = send_ctl_msg(sock, msg, strlen(msg));
 	if (unlikely(ret != SPPWK_RET_OK)) {
 		RTE_LOG(ERR, PCAP_RUNNER,
 			"Failed to send command result response.\n");
@@ -923,9 +923,9 @@ process_request(int *sock, const char *request_str, size_t request_str_len)
 
 /* initialize command processor. */
 int
-spp_command_proc_init(const char *controller_ip, int controller_port)
+spp_command_proc_init(const char *ctl_ipaddr, int ctl_port)
 {
-	return spp_command_conn_init(controller_ip, controller_port);
+	return conn_spp_ctl_init(ctl_ipaddr, ctl_port);
 }
 
 /* process command from controller. */
@@ -948,11 +948,11 @@ spp_command_proc_do(void)
 		}
 	}
 
-	ret = spp_connect_to_controller(&sock);
+	ret = conn_spp_ctl(&sock);
 	if (unlikely(ret != SPPWK_RET_OK))
 		return SPPWK_RET_OK;
 
-	msg_ret = spp_receive_message(&sock, &msgbuf);
+	msg_ret = recv_ctl_msg(&sock, &msgbuf);
 	if (unlikely(msg_ret <= 0)) {
 		if (likely(msg_ret == 0))
 			return SPPWK_RET_OK;
diff --git a/src/shared/secondary/spp_worker_th/cmd_runner.c b/src/shared/secondary/spp_worker_th/cmd_runner.c
index ef3b2d9..92d727b 100644
--- a/src/shared/secondary/spp_worker_th/cmd_runner.c
+++ b/src/shared/secondary/spp_worker_th/cmd_runner.c
@@ -1525,7 +1525,7 @@ send_decode_error_response(int *sock,
 			"response_str=\n%s\n", msg);
 
 	/* send response to requester */
-	ret = spp_send_message(sock, msg, strlen(msg));
+	ret = send_ctl_msg(sock, msg, strlen(msg));
 	if (unlikely(ret != SPP_RET_OK)) {
 		RTE_LOG(ERR, WK_CMD_RUNNER,
 				"Failed to send decode error response.\n");
@@ -1608,7 +1608,7 @@ send_command_result_response(int *sock,
 			"response_str=\n%s\n", msg);
 
 	/* send response to requester */
-	ret = spp_send_message(sock, msg, strlen(msg));
+	ret = send_ctl_msg(sock, msg, strlen(msg));
 	if (unlikely(ret != SPP_RET_OK)) {
 		RTE_LOG(ERR, WK_CMD_RUNNER,
 			"Failed to send command result response.\n");
@@ -1687,7 +1687,7 @@ exec_cmds(int *sock, const char *req_str, size_t req_str_len)
 int
 sppwk_cmd_runner_conn(const char *ctl_ipaddr, int ctl_port)
 {
-	return spp_command_conn_init(ctl_ipaddr, ctl_port);
+	return conn_spp_ctl_init(ctl_ipaddr, ctl_port);
 }
 
 /* Run command sent from spp-ctl. */
@@ -1710,12 +1710,12 @@ sppwk_run_cmd(void)
 		}
 	}
 
-	ret = spp_connect_to_controller(&sock);
+	ret = conn_spp_ctl(&sock);
 
 	if (unlikely(ret != SPP_RET_OK))
 		return SPP_RET_OK;
 
-	msg_ret = spp_receive_message(&sock, &msgbuf);
+	msg_ret = recv_ctl_msg(&sock, &msgbuf);
 	if (unlikely(msg_ret <= 0)) {
 		if (likely(msg_ret == 0))
 			return SPP_RET_OK;
diff --git a/src/shared/secondary/spp_worker_th/command_conn.c b/src/shared/secondary/spp_worker_th/command_conn.c
index 915ad20..b80c54b 100644
--- a/src/shared/secondary/spp_worker_th/command_conn.c
+++ b/src/shared/secondary/spp_worker_th/command_conn.c
@@ -27,19 +27,19 @@ static char g_controller_ip[128] = "";
 /* controller's port number */
 static int g_controller_port;
 
-/* initialize command connection */
+/* Initialize connection to spp-ctl. */
 int
-spp_command_conn_init(const char *controller_ip, int controller_port)
+conn_spp_ctl_init(const char *ctl_ipaddr, int ctl_port)
 {
-	strcpy(g_controller_ip, controller_ip);
-	g_controller_port = controller_port;
+	strcpy(g_controller_ip, ctl_ipaddr);
+	g_controller_port = ctl_port;
 
 	return SPP_RET_OK;
 }
 
 /* connect to controller */
 int
-spp_connect_to_controller(int *sock)
+conn_spp_ctl(int *sock)
 {
 	static struct sockaddr_in controller_addr;
 	int ret = SPP_RET_NG;
@@ -90,7 +90,7 @@ spp_connect_to_controller(int *sock)
 
 /* receive message */
 int
-spp_receive_message(int *sock, char **strbuf)
+recv_ctl_msg(int *sock, char **strbuf)
 {
 	int ret = SPP_RET_NG;
 	int n_rx = 0;
@@ -134,13 +134,13 @@ spp_receive_message(int *sock, char **strbuf)
 	return n_rx;
 }
 
-/* send message */
+/* Send message to spp-ctl. */
 int
-spp_send_message(int *sock, const char *message, size_t message_len)
+send_ctl_msg(int *sock, const char *msg, size_t msg_len)
 {
 	int ret = SPP_RET_NG;
 
-	ret = send(*sock, message, message_len, 0);
+	ret = send(*sock, msg, msg_len, 0);
 	if (unlikely(ret == -1)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC, "Send failure. ret=%d\n", ret);
 		close(*sock);
diff --git a/src/shared/secondary/spp_worker_th/command_conn.h b/src/shared/secondary/spp_worker_th/command_conn.h
index 9112847..0d06131 100644
--- a/src/shared/secondary/spp_worker_th/command_conn.h
+++ b/src/shared/secondary/spp_worker_th/command_conn.h
@@ -6,8 +6,7 @@
 #define _COMMAND_CONN_H_
 
 /**
- * @file
- * SPP Connection
+ * @file SPP Connection
  *
  * Command connection management.
  */
@@ -20,63 +19,52 @@
 #define SPP_CONNERR_FATAL     -2
 
 /**
- * initialize command connection.
+ * Initialize connection to spp-ctl.
  *
- * @param controller_ip
- *  The controller's ip address.
- * @param controller_port
- *  The controller's port number.
- *
- * @retval SPP_RET_OK  succeeded.
- * @retval SPP_RET_NG failed.
+ * @param[in] ctl_ipaddr IP address of spp-ctl.
+ * @param[in] ctl_port Port num of spp-ctl.
+ * @retval SPP_RET_OK If succeeded.
+ * @retval SPP_RET_NG If failed.
  */
-int spp_command_conn_init(const char *controller_ip, int controller_port);
+int conn_spp_ctl_init(const char *ctl_ipaddr, int ctl_port);
 
 /**
- * connect to controller.
+ * Connect to spp-ctl.
  *
  * @note bocking.
- *
- * @param sock
- *  Socket number for connecting to controller.
- *
- * @retval SPP_RET_OK		 succeeded.
- * @retval SPP_CONNERR_TEMPORARY temporary error. please retry.
+ * @param sock Socket number for connecting to controller.
+ * @retval SPP_RET_OK If succeeded.
+ * @retval SPP_CONNERR_TEMPORARY Temporary error for retry.
  */
-int spp_connect_to_controller(int *sock);
+int conn_spp_ctl(int *sock);
 
 /**
- * receive message.
- *
- * @note non-blocking.
+ * Receive message from spp-ctl.
  *
- * @param sock
- *  The socket number for the connection.
- * @param msgbuf
- *  The pointer to command message buffer.
+ * This function returns the num of received  msg in bytes, or SPP_RET_OK
+ * if empty message. Given socket is closed if spp-ctl has terminated the
+ * session.
  *
- * @retval 0 <			 succeeded. number of bytes received.
- * @retval SPP_RET_OK		 no receive message.
- * @retval SPP_CONNERR_TEMPORARY temporary error. please reconnect.
- * @retval SPP_CONNERR_FATAL	fatal error occurred. should terminate process.
+ * @note non-blocking.
+ * @param[in,out] sock Socket.
+ * @param[in,out] msgbuf The pointer to command message buffer.
+ * @retval NOB_BYTES Num of bytes of received msg if succeeded.
+ * @retval SPP_RET_OK No receive message.
+ * @retval SPP_CONNERR_TEMPORARY Temporary error for retry.
+ * @retval SPP_CONNERR_FATAL Fatal error for terminating the process.
  */
-int spp_receive_message(int *sock, char **msgbuf);
+int recv_ctl_msg(int *sock, char **msgbuf);
 
 /**
- * send message.
+ * Send message to spp-ctl.
  *
  * @note non-blocking.
- *
- * @param sock
- *  The socket number to be sent.
- * @param message
- *  The pointer to the message to be sent.
- * @param message_len
- *  The length of message.
- *
- * @retval SPP_RET_OK		 succeeded.
- * @retval SPP_CONNERR_TEMPORARY temporary error. please reconnect.
+ * @param[in,out] sock Socket.
+ * @param[in] msg Message sent to spp-ctl.
+ * @param[in] msg_len Length of given message.
+ * @retval SPP_RET_OK If succeeded.
+ * @retval SPP_CONNERR_TEMPORARY Temporary error for retry.
  */
-int spp_send_message(int *sock, const char *message, size_t message_len);
+int send_ctl_msg(int *sock, const char *msg, size_t msg_len);
 
 #endif /* _COMMAND_CONN_H_ */
-- 
2.17.1


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

* [spp] [PATCH 2/2] shared/sec: rename command_conn.c
  2019-06-24  2:21 [spp] [PATCH 0/2] Rename shared lib command_conn yasufum.o
  2019-06-24  2:21 ` [spp] [PATCH 1/2] shared/sec: revise funcs to connect to spp-ctl yasufum.o
@ 2019-06-24  2:21 ` yasufum.o
  1 sibling, 0 replies; 3+ messages in thread
From: yasufum.o @ 2019-06-24  2:21 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

From: Yasufumi Ogawa <yasufum.o@gmail.com>

This patch is to rename `command_conn.c` and `command_conn.h`, and
update Makefiles.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 src/mirror/Makefile                                             | 2 +-
 src/pcap/Makefile                                               | 2 +-
 src/pcap/cmd_runner.c                                           | 2 +-
 src/shared/secondary/spp_worker_th/cmd_runner.c                 | 2 +-
 .../secondary/spp_worker_th/{command_conn.c => conn_spp_ctl.c}  | 2 +-
 .../secondary/spp_worker_th/{command_conn.h => conn_spp_ctl.h}  | 0
 src/vf/Makefile                                                 | 2 +-
 7 files changed, 6 insertions(+), 6 deletions(-)
 rename src/shared/secondary/spp_worker_th/{command_conn.c => conn_spp_ctl.c} (99%)
 rename src/shared/secondary/spp_worker_th/{command_conn.h => conn_spp_ctl.h} (100%)

diff --git a/src/mirror/Makefile b/src/mirror/Makefile
index d1ae9ce..3e31cfa 100644
--- a/src/mirror/Makefile
+++ b/src/mirror/Makefile
@@ -19,7 +19,7 @@ SRCS-y += ../shared/common.c
 SRCS-y += ../shared/secondary/utils.c ../shared/secondary/add_port.c
 SRCS-y += $(SPP_WKT_DIR)/cmd_utils.c
 SRCS-y += $(SPP_WKT_DIR)/spp_port.c
-SRCS-y += $(SPP_WKT_DIR)/command_conn.c
+SRCS-y += $(SPP_WKT_DIR)/conn_spp_ctl.c
 SRCS-y += $(SPP_WKT_DIR)/cmd_parser.c
 SRCS-y += $(SPP_WKT_DIR)/cmd_runner.c
 SRCS-y += $(SPP_WKT_DIR)/string_buffer.c
diff --git a/src/pcap/Makefile b/src/pcap/Makefile
index 61f6f81..c3d5ae4 100644
--- a/src/pcap/Makefile
+++ b/src/pcap/Makefile
@@ -18,7 +18,7 @@ SRCS-y := spp_pcap.c
 SRCS-y += cmd_utils.c
 SRCS-y += cmd_runner.c cmd_parser.c
 SRCS-y += ../shared/common.c
-SRCS-y += $(SPP_WKT_DIR)/command_conn.c
+SRCS-y += $(SPP_WKT_DIR)/conn_spp_ctl.c
 SRCS-y += $(SPP_WKT_DIR)/spp_port.c
 SRCS-y += $(SPP_WKT_DIR)/ringlatencystats.c
 SRCS-y += $(SPP_WKT_DIR)/string_buffer.c
diff --git a/src/pcap/cmd_runner.c b/src/pcap/cmd_runner.c
index 9541cbb..8a1fb87 100644
--- a/src/pcap/cmd_runner.c
+++ b/src/pcap/cmd_runner.c
@@ -9,7 +9,7 @@
 
 #include "shared/secondary/spp_worker_th/string_buffer.h"
 #include "spp_pcap.h"
-#include "shared/secondary/spp_worker_th/command_conn.h"
+#include "shared/secondary/spp_worker_th/conn_spp_ctl.h"
 #include "cmd_parser.h"
 #include "cmd_runner.h"
 
diff --git a/src/shared/secondary/spp_worker_th/cmd_runner.c b/src/shared/secondary/spp_worker_th/cmd_runner.c
index 92d727b..1d1ec49 100644
--- a/src/shared/secondary/spp_worker_th/cmd_runner.c
+++ b/src/shared/secondary/spp_worker_th/cmd_runner.c
@@ -13,7 +13,7 @@
 #include "spp_port.h"
 #include "string_buffer.h"
 
-#include "command_conn.h"
+#include "conn_spp_ctl.h"
 #include "cmd_parser.h"
 #include "cmd_runner.h"
 
diff --git a/src/shared/secondary/spp_worker_th/command_conn.c b/src/shared/secondary/spp_worker_th/conn_spp_ctl.c
similarity index 99%
rename from src/shared/secondary/spp_worker_th/command_conn.c
rename to src/shared/secondary/spp_worker_th/conn_spp_ctl.c
index b80c54b..030da92 100644
--- a/src/shared/secondary/spp_worker_th/command_conn.c
+++ b/src/shared/secondary/spp_worker_th/conn_spp_ctl.c
@@ -14,7 +14,7 @@
 
 #include "shared/common.h"
 #include "string_buffer.h"
-#include "command_conn.h"
+#include "conn_spp_ctl.h"
 
 #define RTE_LOGTYPE_SPP_COMMAND_PROC RTE_LOGTYPE_USER1
 
diff --git a/src/shared/secondary/spp_worker_th/command_conn.h b/src/shared/secondary/spp_worker_th/conn_spp_ctl.h
similarity index 100%
rename from src/shared/secondary/spp_worker_th/command_conn.h
rename to src/shared/secondary/spp_worker_th/conn_spp_ctl.h
diff --git a/src/vf/Makefile b/src/vf/Makefile
index bdeff98..faf72ee 100644
--- a/src/vf/Makefile
+++ b/src/vf/Makefile
@@ -18,7 +18,7 @@ SRCS-y := spp_vf.c classifier_mac.c spp_forward.c
 SRCS-y += $(SPP_WKT_DIR)/string_buffer.c
 SRCS-y += $(SPP_WKT_DIR)/ringlatencystats.c
 SRCS-y += $(SPP_WKT_DIR)/spp_port.c
-SRCS-y += $(SPP_WKT_DIR)/command_conn.c
+SRCS-y += $(SPP_WKT_DIR)/conn_spp_ctl.c
 SRCS-y += $(SPP_WKT_DIR)/cmd_parser.c
 SRCS-y += $(SPP_WKT_DIR)/cmd_runner.c
 SRCS-y += $(SPP_WKT_DIR)/cmd_utils.c
-- 
2.17.1


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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-24  2:21 [spp] [PATCH 0/2] Rename shared lib command_conn yasufum.o
2019-06-24  2:21 ` [spp] [PATCH 1/2] shared/sec: revise funcs to connect to spp-ctl yasufum.o
2019-06-24  2:21 ` [spp] [PATCH 2/2] shared/sec: rename command_conn.c yasufum.o

Soft Patch Panel

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/spp/0 spp/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 spp spp/ http://inbox.dpdk.org/spp \
		spp@dpdk.org
	public-inbox-index spp


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.spp


AGPL code for this site: git clone https://public-inbox.org/ public-inbox