[4/5] vhost: use logtype instead of RTE_LOGTYPE_USER1

Message ID 20230208044825.1682620-5-stephen@networkplumber.org (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Fix use of RTE_LOGTYPE_USER1 in libraries. |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger Feb. 8, 2023, 4:48 a.m. UTC
  Fix instances of USER1 logtype in fdset and crypto
sections.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/vhost/fd_man.c       | 16 +++++++++-------
 lib/vhost/vhost_crypto.c | 24 ++++++++++--------------
 2 files changed, 19 insertions(+), 21 deletions(-)
  

Comments

Chenbo Xia Feb. 9, 2023, 7:19 a.m. UTC | #1
> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Wednesday, February 8, 2023 12:48 PM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Maxime Coquelin
> <maxime.coquelin@redhat.com>; Xia, Chenbo <chenbo.xia@intel.com>
> Subject: [PATCH 4/5] vhost: use logtype instead of RTE_LOGTYPE_USER1
> 
> Fix instances of USER1 logtype in fdset and crypto
> sections.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  lib/vhost/fd_man.c       | 16 +++++++++-------
>  lib/vhost/vhost_crypto.c | 24 ++++++++++--------------
>  2 files changed, 19 insertions(+), 21 deletions(-)
> 
> diff --git a/lib/vhost/fd_man.c b/lib/vhost/fd_man.c
> index 1876fada3354..172f7dc03ab2 100644
> --- a/lib/vhost/fd_man.c
> +++ b/lib/vhost/fd_man.c
> @@ -10,8 +10,10 @@
> 
>  #include "fd_man.h"
> 
> -
> -#define RTE_LOGTYPE_VHOST_FDMAN RTE_LOGTYPE_USER1
> +RTE_LOG_REGISTER_SUFFIX(vhost_fdset_logtype, fdset, INFO);
> +#define FDSET_LOG(level, fmt, args...)		\
> +	rte_log(RTE_LOG_ ## level, vhost_fdset_logtype,	\
> +		"%s(): " fmt "\n", __func__, ## args)
> 
>  #define FDPOLLERR (POLLERR | POLLHUP | POLLNVAL)
> 
> @@ -334,8 +336,8 @@ fdset_pipe_init(struct fdset *fdset)
>  	int ret;
> 
>  	if (pipe(fdset->u.pipefd) < 0) {
> -		RTE_LOG(ERR, VHOST_FDMAN,
> -			"failed to create pipe for vhost fdset\n");
> +		FDSET_LOG(ERR,
> +			"failed to create pipe for vhost fdset");
>  		return -1;
>  	}
> 
> @@ -343,9 +345,9 @@ fdset_pipe_init(struct fdset *fdset)
>  			fdset_pipe_read_cb, NULL, NULL);
> 
>  	if (ret < 0) {
> -		RTE_LOG(ERR, VHOST_FDMAN,
> -			"failed to add pipe readfd %d into vhost server fdset\n",
> -			fdset->u.readfd);
> +		FDSET_LOG(ERR,
> +			  "failed to add pipe readfd %d into vhost server fdset",
> +			  fdset->u.readfd);
> 
>  		fdset_pipe_uninit(fdset);
>  		return -1;
> diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c
> index b448b6685dd2..923c7c0e10d2 100644
> --- a/lib/vhost/vhost_crypto.c
> +++ b/lib/vhost/vhost_crypto.c
> @@ -16,22 +16,18 @@
>  #define IV_OFFSET		(sizeof(struct rte_crypto_op) + \
>  				sizeof(struct rte_crypto_sym_op))
> 
> +RTE_LOG_REGISTER_SUFFIX(vhost_crypto_logtype, crypto, INFO);
> +
> +#define VC_LOG(level, fmt, args...)				\
> +	rte_log(RTE_LOG_ ## level, vhost_crypto_logtype,	\
> +		"%s():%u: " fmt "\n", __func__, ## args)
> +
> +#define VC_LOG_ERR(fmt, args...)	VC_LOG(ERR, fmt, ## args)
> +#define VC_LOG_INFO(fmt, args...)	VC_LOG(INFO, fmt, ## args)
> +
>  #ifdef RTE_LIBRTE_VHOST_DEBUG
> -#define VC_LOG_ERR(fmt, args...)				\
> -	RTE_LOG(ERR, USER1, "[%s] %s() line %u: " fmt "\n",	\
> -		"Vhost-Crypto",	__func__, __LINE__, ## args)
> -#define VC_LOG_INFO(fmt, args...)				\
> -	RTE_LOG(INFO, USER1, "[%s] %s() line %u: " fmt "\n",	\
> -		"Vhost-Crypto",	__func__, __LINE__, ## args)
> -
> -#define VC_LOG_DBG(fmt, args...)				\
> -	RTE_LOG(DEBUG, USER1, "[%s] %s() line %u: " fmt "\n",	\
> -		"Vhost-Crypto",	__func__, __LINE__, ## args)
> +#define VC_LOG_DBG(fmt, args...)	VC_LOG(DEBUG, fmt, ## args)
>  #else
> -#define VC_LOG_ERR(fmt, args...)				\
> -	RTE_LOG(ERR, USER1, "[VHOST-Crypto]: " fmt "\n", ## args)
> -#define VC_LOG_INFO(fmt, args...)				\
> -	RTE_LOG(INFO, USER1, "[VHOST-Crypto]: " fmt "\n", ## args)
>  #define VC_LOG_DBG(fmt, args...)
>  #endif
> 
> --
> 2.39.1

Acked-by: Chenbo Xia <chenbo.xia@intel.com>
  

Patch

diff --git a/lib/vhost/fd_man.c b/lib/vhost/fd_man.c
index 1876fada3354..172f7dc03ab2 100644
--- a/lib/vhost/fd_man.c
+++ b/lib/vhost/fd_man.c
@@ -10,8 +10,10 @@ 
 
 #include "fd_man.h"
 
-
-#define RTE_LOGTYPE_VHOST_FDMAN RTE_LOGTYPE_USER1
+RTE_LOG_REGISTER_SUFFIX(vhost_fdset_logtype, fdset, INFO);
+#define FDSET_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, vhost_fdset_logtype,	\
+		"%s(): " fmt "\n", __func__, ## args)
 
 #define FDPOLLERR (POLLERR | POLLHUP | POLLNVAL)
 
@@ -334,8 +336,8 @@  fdset_pipe_init(struct fdset *fdset)
 	int ret;
 
 	if (pipe(fdset->u.pipefd) < 0) {
-		RTE_LOG(ERR, VHOST_FDMAN,
-			"failed to create pipe for vhost fdset\n");
+		FDSET_LOG(ERR,
+			"failed to create pipe for vhost fdset");
 		return -1;
 	}
 
@@ -343,9 +345,9 @@  fdset_pipe_init(struct fdset *fdset)
 			fdset_pipe_read_cb, NULL, NULL);
 
 	if (ret < 0) {
-		RTE_LOG(ERR, VHOST_FDMAN,
-			"failed to add pipe readfd %d into vhost server fdset\n",
-			fdset->u.readfd);
+		FDSET_LOG(ERR,
+			  "failed to add pipe readfd %d into vhost server fdset",
+			  fdset->u.readfd);
 
 		fdset_pipe_uninit(fdset);
 		return -1;
diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c
index b448b6685dd2..923c7c0e10d2 100644
--- a/lib/vhost/vhost_crypto.c
+++ b/lib/vhost/vhost_crypto.c
@@ -16,22 +16,18 @@ 
 #define IV_OFFSET		(sizeof(struct rte_crypto_op) + \
 				sizeof(struct rte_crypto_sym_op))
 
+RTE_LOG_REGISTER_SUFFIX(vhost_crypto_logtype, crypto, INFO);
+
+#define VC_LOG(level, fmt, args...)				\
+	rte_log(RTE_LOG_ ## level, vhost_crypto_logtype,	\
+		"%s():%u: " fmt "\n", __func__, ## args)
+
+#define VC_LOG_ERR(fmt, args...)	VC_LOG(ERR, fmt, ## args)
+#define VC_LOG_INFO(fmt, args...)	VC_LOG(INFO, fmt, ## args)
+
 #ifdef RTE_LIBRTE_VHOST_DEBUG
-#define VC_LOG_ERR(fmt, args...)				\
-	RTE_LOG(ERR, USER1, "[%s] %s() line %u: " fmt "\n",	\
-		"Vhost-Crypto",	__func__, __LINE__, ## args)
-#define VC_LOG_INFO(fmt, args...)				\
-	RTE_LOG(INFO, USER1, "[%s] %s() line %u: " fmt "\n",	\
-		"Vhost-Crypto",	__func__, __LINE__, ## args)
-
-#define VC_LOG_DBG(fmt, args...)				\
-	RTE_LOG(DEBUG, USER1, "[%s] %s() line %u: " fmt "\n",	\
-		"Vhost-Crypto",	__func__, __LINE__, ## args)
+#define VC_LOG_DBG(fmt, args...)	VC_LOG(DEBUG, fmt, ## args)
 #else
-#define VC_LOG_ERR(fmt, args...)				\
-	RTE_LOG(ERR, USER1, "[VHOST-Crypto]: " fmt "\n", ## args)
-#define VC_LOG_INFO(fmt, args...)				\
-	RTE_LOG(INFO, USER1, "[VHOST-Crypto]: " fmt "\n", ## args)
 #define VC_LOG_DBG(fmt, args...)
 #endif