日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > windows >内容正文

windows

DPDK 18 log日志系统使用

發(fā)布時間:2023/12/10 windows 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 DPDK 18 log日志系统使用 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

概述:

DPDK 日志系統(tǒng)分為1-8個等級,在lib/librte_eal/common/include/rte_log.h文件中定義,每個DPDK模塊都可以定義一個預(yù)設(shè)日志輸出等級,只有日志輸出語句的等級小于等于預(yù)設(shè)輸出等級才能被輸出。

以下為dpdk對日志的分級:

/* Can't 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, …); 函數(shù)打印日志,傳入?yún)?shù)為:

  • 此條日志輸出等級,

  • 日志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);}
  • 調(diào)用rte_log_register函數(shù)為ixgbe注冊了名為”pmd.net.ixgbe.init”的日志type
    返回一個int作為此日志的type( ixgbe_logtype_driver是為了方便代碼編寫,”pmd.net.ixgbe.init”是為了方便用戶,他們是一一映射的)。
  • 隨后使用rte_log_set_level設(shè)置了默認日志輸出等級為RTE_LOG_NOTICE
    RTE_LOG_NOTICE<RTE_LOG_DEBUG,因此pmd.net.ixgbe.init日志 的DEBUG信息默認將不會輸出。
  • log的使用

    想要看到上文中ixgbe_logtype_driver 的debug級別日志需要在啟動時傳入–log-level參數(shù),指定ixgbe_logtype_driver的debug開啟。

    以testpmd為例子:

    ./mips-loongson3a-linuxapp-gcc/app/testpmd --log-level=pmd.net.ixgbe.driver:8

    則可以看見很多的debug信息被輸出。這里的pmd.net.ixgbe.driver就是rte_log_register時傳入的名字。
    因此,想要看到對應(yīng)的log,只需要展開二次封裝的宏(如上文的PMD_DRV_LOG)找到此條log對應(yīng)的type名字,在–log-level中傳入設(shè)置即可

    總結(jié)

    以上是生活随笔為你收集整理的DPDK 18 log日志系统使用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。