Replace use of RTE_LOGTYPE_USER1 in libraries.
A message that is not in the archive (sent off-list or not yet received): [200~https://inbox.dpdk.org/dev/[email protected]
v2 cover Replace use of RTE_LOGTYPE_USER1 in libraries.
This is split out of other rte_log patchset.
The DPDK libraries and drivers should not be using the USER1 logtype.
v2 - fix some compile warnings
Stephen Hemminger (5):
ip_frag: use a dynamic logtype
reorder: use a dynamic logtype
latencystats: use dynamic logtype
vhost: use logtype instead of RTE_LOGTYPE_USER1
ipsec: fix usage of RTE_LOGTYPE_USER1
drivers/crypto/ipsec_mb/ipsec_mb_ops.c | 3 +- lib/ip_frag/ip_frag_common.h | 16 ++- lib/ip_frag/ip_frag_internal.c | 174 ++++++++++++------------- lib/ip_frag/rte_ip_frag_common.c | 13 +- lib/ip_frag/rte_ipv4_reassembly.c | 14 +- lib/ip_frag/rte_ipv6_reassembly.c | 59 ++++----- lib/latencystats/rte_latencystats.c | 55 ++++---- lib/reorder/rte_reorder.c | 35 ++--- lib/vhost/fd_man.c | 16 ++- lib/vhost/vhost_crypto.c | 25 ++-- 10 files changed, 207 insertions(+), 203 deletions(-)
Signature · 1 line
2.39.1
PATCH v2 1/5 ip_frag: use a dynamic logtype
DPDK libraries should not be reusing RTE_LOGTYPE_USER1 in lieu of doing proper logtype registration.
--- lib/ip_frag/ip_frag_common.h | 16 ++- lib/ip_frag/ip_frag_internal.c | 174 +++++++++++++++--------------- lib/ip_frag/rte_ip_frag_common.c | 13 +-- lib/ip_frag/rte_ipv4_reassembly.c | 14 ++- lib/ip_frag/rte_ipv6_reassembly.c | 59 +++++----- 5 files changed, 138 insertions(+), 138 deletions(-)
lib/ip_frag/ip_frag_common.h +12 -4
@@ -9,8 +9,16 @@#include "ip_reassembly.h" /* logging macros. */ +extern int ipfrag_logtype; + +#define IP_FRAG_ERR(fmt, args...) \ + rte_log(RTE_LOG_ERR, ipfrag_logtype, \ + "%s: " fmt "\n", __func__, ## args) +#ifdef RTE_LIBRTE_IP_FRAG_DEBUG -#define IP_FRAG_LOG(lvl, fmt, args...) RTE_LOG(lvl, USER1, fmt, ##args) +#define IP_FRAG_LOG(lvl, fmt, args...) \ + rte_log(RTE_LOG ## lvl, ipfrag_logtype, \ + "%s: " fmt "\n", __func__, ## args)#else #define IP_FRAG_LOG(lvl, fmt, args...) do {} while(0)#endif /* IP_FRAG_DEBUG */
@@ -111,9 +119,9 @@ ip_frag_free_immediate(struct ip_frag_pkt *fp)for (i =0 ; i < fp->last_idx; i++) {if (fp->frags[i].mb !=NULL ) { -IP_FRAG_LOG (DEBUG ,"%s:%d\n" -"mbuf: %p, tms: %" PRIu64", key: <%" PRIx64", %#x>\n" , - __func__, __LINE__, fp->frags[i].mb, fp->start, +IP_FRAG_LOG (DEBUG , +"mbuf: %p, tms: %" PRIu64", key: <%" PRIx64", %#x>" , + fp->frags[i].mb, fp->start, fp->key.src_dst[0 ], fp->key.id);rte_pktmbuf_free (fp->frags[i].mb); fp->frags[i].mb =NULL ;
lib/ip_frag/ip_frag_internal.c +85 -89
232 lines not on this page · raw message
lib/ip_frag/rte_ip_frag_common.c +7 -6
@@ -52,21 +52,20 @@ rte_ip_frag_table_create(uint32_t bucket_num, uint32_t bucket_entries,if (rte_is_power_of_2 (bucket_entries) ==0 || nb_entries >UINT32_MAX || nb_entries ==0 || nb_entries < max_entries) { -RTE_LOG (ERR ,USER1 ,"%s: invalid input parameter\n" , __func__); +IP_FRAG_ERR ("invalid input parameter" );return NULL ; } sz =sizeof (*tbl) + nb_entries *sizeof (tbl->pkt[0 ]);if ((tbl =rte_zmalloc_socket (__func__, sz,RTE_CACHE_LINE_SIZE , socket_id)) ==NULL ) { -RTE_LOG (ERR ,USER1 , -"%s: allocation of %zu bytes at socket %d failed do\n" , - __func__, sz, socket_id); +IP_FRAG_ERR ("allocation of %zu bytes at socket %d failed do" , + sz, socket_id);return NULL ; } -RTE_LOG (INFO ,USER1 ,"%s: allocated of %zu bytes at socket %d\n" , - __func__, sz, socket_id); +IP_FRAG_LOG (INFO ,"allocated of %zu bytes at socket %d" , + sz, socket_id); tbl->max_cycles = max_cycles; tbl->max_entries = max_entries;
@@ -142,3 +141,5 @@ rte_ip_frag_table_del_expired_entries(struct rte_ip_frag_tbl *tbl, }else return ; } + +RTE_LOG_REGISTER_DEFAULT (ipfrag_logtype,INFO );
lib/ip_frag/rte_ipv4_reassembly.c +6 -8
@@ -120,12 +120,11 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, ip_len =rte_be_to_cpu_16 (ip_hdr->total_length) - mb->l3_len; trim = mb->pkt_len - (ip_len + mb->l3_len + mb->l2_len); -IP_FRAG_LOG (DEBUG ,"%s:%d:\n" +IP_FRAG_LOG (DEBUG ,"mbuf: %p, tms: %" PRIu64", key: <%" PRIx64", %#x>" "ofs: %u, len: %d, padding: %d, flags: %#x\n" "tbl: %p, max_cycles: %" PRIu64", entry_mask: %#x, " -"max_entries: %u, use_entries: %u\n\n" , - __func__, __LINE__, +"max_entries: %u, use_entries: %u\n" , mb, tms, key.src_dst[0 ], key.id, ip_ofs, ip_len, trim, ip_flag, tbl, tbl->max_cycles, tbl->entry_mask, tbl->max_entries, tbl->use_entries);
@@ -145,11 +144,10 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,return NULL ; } -IP_FRAG_LOG (DEBUG ,"%s:%d:\n" +IP_FRAG_LOG (DEBUG ,"tbl: %p, max_entries: %u, use_entries: %u\n" "ipv4_frag_pkt: %p, key: <%" PRIx64", %#x>, start: %" PRIu64 -", total_size: %u, frag_size: %u, last_idx: %u\n\n" , - __func__, __LINE__, +", total_size: %u, frag_size: %u, last_idx: %u\n" , tbl, tbl->max_entries, tbl->use_entries, fp, fp->key.src_dst[0 ], fp->key.id, fp->start, fp->total_size, fp->frag_size, fp->last_idx);
@@ -159,11 +157,11 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, mb =ip_frag_process (fp, dr, mb, ip_ofs, ip_len, ip_flag);ip_frag_inuse (tbl, fp); - IP_FRAG_LOG(DEBUG, "%s:%d:\n" + IP_FRAG_LOG(DEBUG, "mbuf: %p\n" "tbl: %p, max_entries: %u, use_entries: %u\n" "ipv4_frag_pkt: %p, key: <%" PRIx64 ", %#x>, start: %" PRIu64 - ", total_size: %u, frag_size: %u, last_idx: %u\n\n", + ", total_size: %u, frag_size: %u, last_idx: %u\n", __func__, __LINE__, mb, tbl, tbl->max_entries, tbl->use_entries, fp, fp->key.src_dst[0], fp->key.id, fp->start,
lib/ip_frag/rte_ipv6_reassembly.c +28 -31
83 lines not on this page · raw message
Signature · 1 line
2.39.1
PATCH v2 2/5 reorder: use a dynamic logtype
In reply to Stephen HemmingerLibraries should not be reusing RTE_LOGTYPE_USER1 instead of doing proper logtype registration.
--- lib/reorder/rte_reorder.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-)
lib/reorder/rte_reorder.c +19 -16
@@ -27,7 +27,11 @@ EAL_REGISTER_TAILQ(rte_reorder_tailq)#define RTE_REORDER_NAMESIZE 32/* Macros for printing using RTE_LOG */ -#define RTE_LOGTYPE_REORDER RTE_LOGTYPE_USER1 +RTE_LOG_REGISTER_DEFAULT (reorder_logtype,INFO ); + +#define REORDER_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, reorder_logtype, \ + "%s(): " fmt "\n", __func__, ##args)#define RTE_REORDER_SEQN_DYNFIELD_NAME "rte_reorder_seqn_dynfield"int rte_reorder_seqn_dynfield_offset =-1 ;
@@ -62,26 +66,25 @@ rte_reorder_init(struct rte_reorder_buffer *b, unsigned int bufsize, (2 * size *sizeof (struct rte_mbuf *));if (b ==NULL ) { -RTE_LOG (ERR ,REORDER ,"Invalid reorder buffer parameter:" -" NULL\n" ); +REORDER_LOG (ERR ,"Invalid reorder buffer parameter: NULL" ); rte_errno =EINVAL ;return NULL ; }if (!rte_is_power_of_2 (size)) { -RTE_LOG (ERR ,REORDER ,"Invalid reorder buffer size" -" - Not a power of 2\n" ); +REORDER_LOG (ERR , +"Invalid reorder buffer size - Not a power of 2" ); rte_errno =EINVAL ;return NULL ; }if (name ==NULL ) { -RTE_LOG (ERR ,REORDER ,"Invalid reorder buffer name ptr:" -" NULL\n" ); +REORDER_LOG (ERR ,"Invalid reorder buffer name ptr: NULL" ); rte_errno =EINVAL ;return NULL ; }if (bufsize < min_bufsize) { -RTE_LOG (ERR ,REORDER ,"Invalid reorder buffer memory size: %u, " -"minimum required: %u\n" , bufsize, min_bufsize); +REORDER_LOG (ERR , +"Invalid reorder buffer memory size: %u, minimum required: %u" , + bufsize, min_bufsize); rte_errno =EINVAL ;return NULL ; }
@@ -116,14 +119,13 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size)/* Check user arguments. */ if (!rte_is_power_of_2 (size)) { -RTE_LOG (ERR ,REORDER ,"Invalid reorder buffer size" -" - Not a power of 2\n" ); +REORDER_LOG (ERR , +"Invalid reorder buffer size - Not a power of 2" ); rte_errno =EINVAL ;return NULL ; }if (name ==NULL ) { -RTE_LOG (ERR ,REORDER ,"Invalid reorder buffer name ptr:" -" NULL\n" ); +REORDER_LOG (ERR ,"Invalid reorder buffer name ptr: NULL" ); rte_errno =EINVAL ;return NULL ; }
@@ -131,7 +133,8 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size) rte_reorder_seqn_dynfield_offset =rte_mbuf_dynfield_register (&reorder_seqn_dynfield_desc);if (rte_reorder_seqn_dynfield_offset <0 ) { -RTE_LOG (ERR ,REORDER ,"Failed to register mbuf field for reorder sequence number\n" ); +REORDER_LOG (ERR , +"Failed to register mbuf field for reorder sequence number" ); rte_errno =ENOMEM ;return NULL ; }
@@ -150,7 +153,7 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size)/* allocate tailq entry */ te =rte_zmalloc ("REORDER_TAILQ_ENTRY" ,sizeof (*te),0 );if (te ==NULL ) { -RTE_LOG (ERR ,REORDER ,"Failed to allocate tailq entry\n" ); +REORDER_LOG (ERR ,"Failed to allocate tailq entry" ); rte_errno =ENOMEM ; b =NULL ; goto exit;
@@ -159,7 +162,7 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size)/* Allocate memory to store the reorder buffer structure. */ b =rte_zmalloc_socket ("REORDER_BUFFER" , bufsize,0 , socket_id);if (b ==NULL ) { -RTE_LOG (ERR ,REORDER ,"Memzone allocation failed\n" ); +REORDER_LOG (ERR ,"Memzone allocation failed" ); rte_errno =ENOMEM ;rte_free (te); }else {
Signature · 1 line
2.39.1
PATCH v2 3/5 latencystats: use dynamic logtype
In reply to Stephen HemmingerLibraries should not reuse RTE_LOGTYPE_USER1 for their logging. Instead they should register their own type.
--- lib/latencystats/rte_latencystats.c | 55 +++++++++++++++-------------- 1 file changed, 28 insertions(+), 27 deletions(-)
lib/latencystats/rte_latencystats.c +28 -27
@@ -26,7 +26,10 @@ latencystat_cycles_per_ns(void) }/* Macros for printing using RTE_LOG */ -#define RTE_LOGTYPE_LATENCY_STATS RTE_LOGTYPE_USER1 +RTE_LOG_REGISTER_DEFAULT (latencystat_logtype,INFO ); +#define LATENCYSTATS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, latencystat_logtype, \ + "%s(): " fmt "\n", __func__, ## args)static uint64_t timestamp_dynflag;static int timestamp_dynfield_offset =-1 ;
@@ -95,7 +98,7 @@ rte_latencystats_update(void) latency_stats_index, values, NUM_LATENCY_STATS);if (ret <0 ) -RTE_LOG (INFO ,LATENCY_STATS ,"Failed to push the stats\n" ); +LATENCYSTATS_LOG (INFO ,"Failed to push the stats" );return ret; }
@@ -227,8 +230,7 @@ rte_latencystats_init(uint64_t app_samp_intvl, mz =rte_memzone_reserve (MZ_RTE_LATENCY_STATS ,sizeof (*glob_stats),rte_socket_id (), flags);if (mz ==NULL ) { -RTE_LOG (ERR ,LATENCY_STATS ,"Cannot reserve memory: %s:%d\n" , - __func__, __LINE__); +LATENCYSTATS_LOG (ERR ,"Cannot reserve memory" );return -ENOMEM ; }
@@ -243,8 +245,7 @@ rte_latencystats_init(uint64_t app_samp_intvl, latency_stats_index =rte_metrics_reg_names (ptr_strings,NUM_LATENCY_STATS );if (latency_stats_index <0 ) { -RTE_LOG (DEBUG ,LATENCY_STATS , -"Failed to register latency stats names\n" ); +LATENCYSTATS_LOG (ERR ,"Failed to register latency stats names" );return -1 ; }
@@ -252,8 +253,8 @@ rte_latencystats_init(uint64_t app_samp_intvl, ret =rte_mbuf_dyn_rx_timestamp_register (×tamp_dynfield_offset, ×tamp_dynflag);if (ret !=0 ) { -RTE_LOG (ERR ,LATENCY_STATS , -"Cannot register mbuf field/flag for timestamp\n" ); +LATENCYSTATS_LOG (ERR , +"Cannot register mbuf field/flag for timestamp" );return -rte_errno; }
@@ -263,9 +264,9 @@ rte_latencystats_init(uint64_t app_samp_intvl, ret =rte_eth_dev_info_get (pid, &dev_info);if (ret !=0 ) { -RTE_LOG (INFO ,LATENCY_STATS , -"Error during getting device (port %u) info: %s\n" , - pid,strerror (-ret)); +LATENCYSTATS_LOG (INFO , +"Error during getting device (port %u) info: %s" , + pid,strerror (-ret));continue ; }
@@ -275,18 +276,18 @@ rte_latencystats_init(uint64_t app_samp_intvl, cbs->cb =rte_eth_add_first_rx_callback (pid, qid, add_time_stamps, user_cb);if (!cbs->cb) -RTE_LOG (INFO ,LATENCY_STATS ,"Failed to " -"register Rx callback for pid=%d, " -"qid=%d\n" , pid, qid); +LATENCYSTATS_LOG (INFO , +"Failed to register Rx callback for pid=%d, qid=%d" , + pid, qid); }for (qid =0 ; qid < dev_info.nb_tx_queues; qid++) { cbs = &tx_cbs[pid][qid]; cbs->cb =rte_eth_add_tx_callback (pid, qid, calc_latency, user_cb);if (!cbs->cb) -RTE_LOG (INFO ,LATENCY_STATS ,"Failed to " -"register Tx callback for pid=%d, " -"qid=%d\n" , pid, qid); +LATENCYSTATS_LOG (INFO , +"Failed to register Tx callback for pid=%d, qid=%d" , + pid, qid); } }return 0 ;
@@ -307,8 +308,8 @@ rte_latencystats_uninit(void) ret =rte_eth_dev_info_get (pid, &dev_info);if (ret !=0 ) { -RTE_LOG (INFO ,LATENCY_STATS , -"Error during getting device (port %u) info: %s\n" , +LATENCYSTATS_LOG (INFO , +"Error during getting device (port %u) info: %s" , pid,strerror (-ret));continue ;
@@ -318,17 +319,17 @@ rte_latencystats_uninit(void) cbs = &rx_cbs[pid][qid]; ret =rte_eth_remove_rx_callback (pid, qid, cbs->cb);if (ret) -RTE_LOG (INFO ,LATENCY_STATS ,"failed to " -"remove Rx callback for pid=%d, " -"qid=%d\n" , pid, qid); +LATENCYSTATS_LOG (INFO , +"failed to remove Rx callback for pid=%d, qid=%d" , + pid, qid); }for (qid =0 ; qid < dev_info.nb_tx_queues; qid++) { cbs = &tx_cbs[pid][qid]; ret =rte_eth_remove_tx_callback (pid, qid, cbs->cb);if (ret) -RTE_LOG (INFO ,LATENCY_STATS ,"failed to " -"remove Tx callback for pid=%d, " -"qid=%d\n" , pid, qid); +LATENCYSTATS_LOG (INFO , +"failed to remove Tx callback for pid=%d, qid=%d" , + pid, qid); } }
@@ -365,8 +366,8 @@ rte_latencystats_get(struct rte_metric_value *values, uint16_t size)const struct rte_memzone *mz; mz =rte_memzone_lookup (MZ_RTE_LATENCY_STATS );if (mz ==NULL ) { -RTE_LOG (ERR ,LATENCY_STATS , -"Latency stats memzone not found\n" ); +LATENCYSTATS_LOG (ERR , +"Latency stats memzone not found" );return -ENOMEM ; } glob_stats = mz->addr;
Signature · 1 line
2.39.1
PATCH v2 4/5 vhost: use logtype instead of RTE_LOGTYPE_USER1
In reply to Stephen HemmingerFix instances of USER1 logtype in fdset and crypto sections.
--- lib/vhost/fd_man.c | 16 +++++++++------- lib/vhost/vhost_crypto.c | 25 +++++++++++-------------- 2 files changed, 20 insertions(+), 21 deletions(-)
lib/vhost/fd_man.c +9 -7
@@ -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 ;
lib/vhost/vhost_crypto.c +11 -14
@@ -4,6 +4,7 @@#include <rte_malloc.h> #include <rte_hash.h> #include <rte_jhash.h> +#include <rte_log.h> #include <rte_mbuf.h> #include <rte_cryptodev.h>
@@ -16,22 +17,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__, __LINE__, ## 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
Signature · 1 line
2.39.1
PATCH v2 5/5 ipsec: fix usage of RTE_LOGTYPE_USER1
In reply to Stephen HemmingerThere already is a logtype in this driver, use it!
--- drivers/crypto/ipsec_mb/ipsec_mb_ops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/ipsec_mb/ipsec_mb_ops.c +2 -1
@@ -7,6 +7,7 @@#include <rte_common.h> #include <rte_malloc.h> +#include <rte_log.h> #include "ipsec_mb_private.h"
@@ -125,7 +126,7 @@ ipsec_mb_secondary_qp_op(int dev_id, int qp_id, qp_req_msg.num_fds =0 ; ret =rte_mp_request_sync (&qp_req_msg, &qp_resp, &ts);if (ret) { -RTE_LOG (ERR ,USER1 ,"Create MR request to primary process failed." ); +IPSEC_MB_LOG (ERR ,"Create MR request to primary process failed." );return -1 ; } qp_resp_msg = &qp_resp.msgs[0 ];
Signature · 1 line
2.39.1