境外建设网站贴吧,注册推广赚钱一个40元,运营网站需要多少钱,p2p网站制作价格概述#xff1a;
DPDK 日志系统分为1-8个等级#xff0c;在lib/librte_eal/common/include/rte_log.h文件中定义#xff0c;每个DPDK模块都可以定义一个预设日志输出等级#xff0c;只有日志输出语句的等级小于等于预设输出等级才能被输出。
以下为dpdk对日志的分级…概述
DPDK 日志系统分为1-8个等级在lib/librte_eal/common/include/rte_log.h文件中定义每个DPDK模块都可以定义一个预设日志输出等级只有日志输出语句的等级小于等于预设输出等级才能被输出。
以下为dpdk对日志的分级
/* Cant use 0, as it gives compiler warnings */
#define RTE_LOG_EMERG 1U /** System is unusable. */
#define RTE_LOG_ALERT 2U /** Action must be taken immediately. */
#define RTE_LOG_CRIT 3U /** Critical conditions. */
#define RTE_LOG_ERR 4U /** Error conditions. */
#define RTE_LOG_WARNING 5U /** Warning conditions. */
#define RTE_LOG_NOTICE 6U /** Normal but significant condition. */
#define RTE_LOG_INFO 7U /** Informational. */
#define RTE_LOG_DEBUG 8U /** Debug-level messages. */Dpdk 使用int rte_log(uint32_t level, uint32_t logtype, const char *format, …); 函数打印日志传入参数为 此条日志输出等级 日志type 输出log信息 但在dpdk中并不会直接使用rte_log而是不同模块对它进行二次封装后使用
日志输出分析
例如在drivers/net/ixgbe/ixgbe_ethdev.c 1038 此条log默认不会被输出分析见后文
PMD_DRV_LOG(DEBUG, SWFW phy%d lock released, hw-bus.func);PMD_DRV_LOG的宏定义在ixgbe_log.h 通过ixgbe_ethdev.c对头文件的include可以看出每个使用了LOG的地方都会include一个xxx_log.h的文件)它的定义为
extern int ixgbe_logtype_driver;
#define PMD_DRV_LOG_RAW(level, fmt, args...) \rte_log(RTE_LOG_ ## level, ixgbe_logtype_driver, %s(): fmt, \__func__, ## args)传入的DEBUG被拼接为了RTE_LOG_DEBUG
对于宏中的ixgbe_logtype_driver 变量的定义和初始化
//drivers/net/ixgbe/ixgbe_ethdev.c 8916 RTE_INIT(ixgbe_init_log){ixgbe_logtype_init rte_log_register(pmd.net.ixgbe.init);if (ixgbe_logtype_init 0)rte_log_set_level(ixgbe_logtype_init, RTE_LOG_NOTICE);ixgbe_logtype_driver rte_log_register(pmd.net.ixgbe.driver);if (ixgbe_logtype_driver 0)rte_log_set_level(ixgbe_logtype_driver, RTE_LOG_NOTICE);}调用rte_log_register函数为ixgbe注册了名为”pmd.net.ixgbe.init”的日志type 返回一个int作为此日志的type ixgbe_logtype_driver是为了方便代码编写”pmd.net.ixgbe.init”是为了方便用户他们是一一映射的。随后使用rte_log_set_level设置了默认日志输出等级为RTE_LOG_NOTICE RTE_LOG_NOTICERTE_LOG_DEBUG因此pmd.net.ixgbe.init日志 的DEBUG信息默认将不会输出。
log的使用
想要看到上文中ixgbe_logtype_driver 的debug级别日志需要在启动时传入–log-level参数指定ixgbe_logtype_driver的debug开启。
以testpmd为例子
./mips-loongson3a-linuxapp-gcc/app/testpmd --log-levelpmd.net.ixgbe.driver:8则可以看见很多的debug信息被输出。这里的pmd.net.ixgbe.driver就是rte_log_register时传入的名字。 因此想要看到对应的log只需要展开二次封装的宏如上文的PMD_DRV_LOG找到此条log对应的type名字在–log-level中传入设置即可