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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

[dpdk]rte_mempool_ops_table

發布時間:2024/3/12 编程问答 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [dpdk]rte_mempool_ops_table 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

定義

/* /lib/librte_mempool/rte_mempool_ops.c */ struct rte_mempool_ops_table rte_mempool_ops_table = {.sl = RTE_SPINLOCK_INITIALIZER,.num_ops = 0 }; /* lib/librte_mempool/rte_mempool.h*/ struct rte_mempool_ops_table {rte_spinlock_t sl; /**< Spinlock for add/delete. */uint32_t num_ops; /**< Number of used ops structs in the table. *//*** Storage for all possible ops structs.*/struct rte_mempool_ops ops[RTE_MEMPOOL_MAX_OPS_IDX]; } __rte_cache_aligned;

rte_mempool_ops_table 作為全局變量,內部ops數組存儲已注冊的ops信息,ops包括操作內存池的一系列(alloc、free、dequeue、enqueue)函數指針。每個進程內部都有存儲 ops 數組,這樣mempool 可以在主進程和輔助進程之間共享(自己未這樣使用過)。訪問ops 數組的索引在進程之間是有效的,但是mempool結構里直接存儲的函數指針,在進程間未必是有效的。這就導致我們在mempool結構體內有個"ops_index" 的變量。

ops數組的初始化

/* /drivers/mempool/ring/rte_mempool_ring.c */MEMPOOL_REGISTER_OPS(ops_mp_mc); MEMPOOL_REGISTER_OPS(ops_sp_sc); MEMPOOL_REGISTER_OPS(ops_mp_sc); MEMPOOL_REGISTER_OPS(ops_sp_mc); MEMPOOL_REGISTER_OPS(ops_mt_rts); MEMPOOL_REGISTER_OPS(ops_mt_hts);static const struct rte_mempool_ops ops_mp_mc = {.name = "ring_mp_mc",.alloc = common_ring_alloc,.free = common_ring_free,.enqueue = common_ring_mp_enqueue,.dequeue = common_ring_mc_dequeue,.get_count = common_ring_get_count, };/* /lib/librte_mempool/rte_mempool.h */#define MEMPOOL_REGISTER_OPS(ops) \RTE_INIT(mp_hdlr_init_##ops) \{ \rte_mempool_register_ops(&ops); \}

通過宏定義和 ops_mp_mc 的定義,在程序main函數執行前完成ops數組的初始化。

如何設置mempool結構體內的“ops_index”

rte_mempool_create 的最后一個變量flag,可設置內存池操作方式是否支持多 producer 和 多 consumer。未主動設置情況下,支持多 producer 和 多 consumer 。如此能確定 ops_index 對應 “ring_mp_mc” 的ops數組元素的下標。

int rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,void *pool_config) {struct rte_mempool_ops *ops = NULL;unsigned i;/* too late, the mempool is already populated. */if (mp->flags & MEMPOOL_F_POOL_CREATED)return -EEXIST;for (i = 0; i < rte_mempool_ops_table.num_ops; i++) {if (!strcmp(name,rte_mempool_ops_table.ops[i].name)) {ops = &rte_mempool_ops_table.ops[i];break;}}if (ops == NULL)return -EINVAL;mp->ops_index = i;mp->pool_config = pool_config;rte_mempool_trace_set_ops_byname(mp, name, pool_config);return 0; }

總結

以上是生活随笔為你收集整理的[dpdk]rte_mempool_ops_table的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。