diff options
| author | Lu Qiuwen <[email protected]> | 2024-04-12 09:52:11 +0800 |
|---|---|---|
| committer | 陆秋文 <[email protected]> | 2024-04-14 12:38:19 +0000 |
| commit | ffb888acf3149f4ec185978b09ef66abffe81333 (patch) | |
| tree | 50945ba512596df620bdf0fe9add26af022d63e6 | |
| parent | a14d9eab5384eaca1925670486b5e3b54dca390e (diff) | |
bugfix: clean the credit counters when cons created, fix the txdrop counter.
| -rw-r--r-- | infra/include/vnode.h | 3 | ||||
| -rw-r--r-- | infra/src/vnode_common.c | 37 | ||||
| -rw-r--r-- | infra/src/vnode_common.h | 3 | ||||
| -rw-r--r-- | infra/src/vnode_mirror.c | 13 | ||||
| -rw-r--r-- | infra/test/TestVNode.cc | 30 | ||||
| -rw-r--r-- | service/include/sc_devmgr.h | 8 | ||||
| -rw-r--r-- | service/include/sc_vdev.h | 11 | ||||
| -rw-r--r-- | service/src/devmgr.c | 50 | ||||
| -rw-r--r-- | service/src/node_phydev.c | 24 | ||||
| -rw-r--r-- | service/src/vdata.c | 25 | ||||
| -rw-r--r-- | service/src/vdev.c | 23 | ||||
| -rw-r--r-- | support/CMakeLists.txt | 3 |
12 files changed, 93 insertions, 137 deletions
diff --git a/infra/include/vnode.h b/infra/include/vnode.h index 478a995..5b7f861 100644 --- a/infra/include/vnode.h +++ b/infra/include/vnode.h @@ -118,8 +118,7 @@ int vnode_mirror_rt_object_retrieve(struct vnode_prod * prod, unsigned int prodq unsigned int nr_max_objects); struct vnode * vnode_mirror_create(const char * sym, unsigned int sz_exclusive, unsigned int sz_max_inflight, - unsigned int notify_cons_when_rx, unsigned int batch_interval_us, - unsigned int en_q_len_monitor); + unsigned int notify_cons_when_rx, unsigned int batch_interval_us); int vnode_mirror_delete(struct vnode * vnode); diff --git a/infra/src/vnode_common.c b/infra/src/vnode_common.c index 67e019e..b27af85 100644 --- a/infra/src/vnode_common.c +++ b/infra/src/vnode_common.c @@ -314,37 +314,11 @@ struct vnode_cons * __vnode_common_create_cons(struct vnode * vnode, const char goto err; } } - - if (vnode->en_q_len_monitor) - { - struct variable_monitor_ioctl_cmd_args ioctl_cmd_args = {}; - ioctl_cmd_args.task_id = getpid(); - - snprintf(ioctl_cmd_args.name, sizeof(ioctl_cmd_args.name), "%s-%d", symbol, qid); - ioctl_cmd_args.var_ptr = (void *)&cons->stat[qid].q_len_max; - ioctl_cmd_args.var_len = sizeof(cons->stat[qid].q_len_max); - - ioctl_cmd_args.threshold = floor(vnode->sz_tunnel * 0.8); - ioctl_cmd_args.unsigned_flag = 1; - ioctl_cmd_args.greater_flag = 1; - - /* write the cmds by ioctl to the variable monitor modules */ - int variable_monitor_fd = open("/dev/variable_monitor", 0); - if (unlikely(variable_monitor_fd < 0)) - { - MR_ERROR("failed at open /dev/variable_monitor: %s", strerror(errno)); - goto err; - } - - int ioctl_ret = ioctl(variable_monitor_fd, 1, &ioctl_cmd_args); - if (unlikely(ioctl_ret < 0)) - { - MR_ERROR("failed at ioctl /dev/variable_monitor: %s", strerror(errno)); - goto err; - } - } } + vnode->max_credits_per_tunnel = vnode->max_inflight / nr_consq; + vnode->credits_on_loan = 0; + rte_spinlock_lock(&vnode->lock); int ret = do_consumer_join_unsafe(vnode, cons); rte_spinlock_unlock(&vnode->lock); @@ -357,10 +331,7 @@ struct vnode_cons * __vnode_common_create_cons(struct vnode * vnode, const char return cons; err: - if (cons != NULL) - { - rte_free(cons); - } + rte_free(cons); return NULL; } diff --git a/infra/src/vnode_common.h b/infra/src/vnode_common.h index 71873d1..4dc35b9 100644 --- a/infra/src/vnode_common.h +++ b/infra/src/vnode_common.h @@ -37,9 +37,7 @@ struct tunnel_desc /* second cacheline, read/write */ RTE_MARKER cacheline1 __rte_cache_min_aligned; - int32_t inflight_credits; - unsigned int send_credits_watermark; /* Tunnel Enqueue Buffer Size */ unsigned int sz_en_buffer; @@ -140,6 +138,7 @@ struct vnode /* atomic, inflight credit */ int32_t credits_on_loan; int32_t max_inflight; + int32_t max_credits_per_tunnel; /* Guarantees one operator(consumer or producer, create or destroy) a time */ rte_spinlock_t lock __rte_cache_aligned; diff --git a/infra/src/vnode_mirror.c b/infra/src/vnode_mirror.c index 9859dd3..17ff8ee 100644 --- a/infra/src/vnode_mirror.c +++ b/infra/src/vnode_mirror.c @@ -19,7 +19,7 @@ static inline unsigned int dist_tunnel_rt_objects_retrieve(struct tunnel_desc * return nr_rt_objs; } -static bool dist_tunnel_acquire_credits(struct vnode * vnode_desc, struct tunnel_desc * tunnel_desc, int32_t credits) +static inline bool dist_tunnel_acquire_credits(struct vnode * vnode_desc, struct tunnel_desc * tunnel_desc, int32_t credits) { int32_t inflight_credits = tunnel_desc->inflight_credits; int32_t missing_credits = credits - inflight_credits; @@ -56,7 +56,6 @@ static bool dist_tunnel_acquire_credits(struct vnode * vnode_desc, struct tunnel if (unlikely(new_total_on_loan > vnode_desc->max_inflight)) { - /* Some other port took the last credits */ __atomic_fetch_sub(&vnode_desc->credits_on_loan, acquired_credits, __ATOMIC_RELAXED); return false; } @@ -66,14 +65,14 @@ static bool dist_tunnel_acquire_credits(struct vnode * vnode_desc, struct tunnel return true; } -static void dist_tunnel_return_credits(struct vnode * vnode_desc, struct tunnel_desc * tunnel_desc, int32_t credits) +static inline void dist_tunnel_return_credits(struct vnode * vnode_desc, struct tunnel_desc * tunnel_desc, int32_t credits) { tunnel_desc->inflight_credits += credits; #define DIST_TUNNEL_MAX_CREDITS (2 * DIST_TUNNEL_DESC_MIN_CREDITS) - if (unlikely(tunnel_desc->inflight_credits > DIST_TUNNEL_MAX_CREDITS)) + if (unlikely(tunnel_desc->inflight_credits > vnode_desc->max_credits_per_tunnel)) { - int32_t leave_credits = DIST_TUNNEL_MAX_CREDITS; + int32_t leave_credits = vnode_desc->max_credits_per_tunnel; int32_t return_credits = tunnel_desc->inflight_credits - leave_credits; tunnel_desc->inflight_credits = leave_credits; @@ -342,8 +341,7 @@ void vnode_mirror_flush(struct vnode_prod * prod, unsigned int prodq) } struct vnode * vnode_mirror_create(const char * sym, unsigned int sz_exclusive, unsigned int sz_max_inflight, - unsigned int notify_cons_when_rx, unsigned int batch_interval_us, - unsigned int en_q_len_monitor) + unsigned int notify_cons_when_rx, unsigned int batch_interval_us) { struct vnode * vnode_common = __vnode_common_create(sym, sz_exclusive, sz_max_inflight, notify_cons_when_rx); @@ -365,7 +363,6 @@ struct vnode * vnode_mirror_create(const char * sym, unsigned int sz_exclusive, } vnode_common->batch_interval_tsc = batch_interval_us * rte_get_timer_cycles() / US_PER_S; - vnode_common->en_q_len_monitor = en_q_len_monitor; return vnode_common; } diff --git a/infra/test/TestVNode.cc b/infra/test/TestVNode.cc index 77d5bb5..76846be 100644 --- a/infra/test/TestVNode.cc +++ b/infra/test/TestVNode.cc @@ -39,7 +39,7 @@ class TestCaseVNodeQueue : public TestCaseVNode void SetUp() override { - vnode_ = vnode_mirror_create("m-vnode", 1024, 0, 0, 0, 0); + vnode_ = vnode_mirror_create("m-vnode", 1024, 0, 0, 0); ASSERT_NE(vnode_, nullptr); assert(prod_ == nullptr); @@ -82,7 +82,7 @@ struct rte_mempool * TestCaseVNode::pktmbuf_pool_ = nullptr; TEST_F(TestCaseVNode, CreateAndDeleteInEmptyNode) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 1024, 32, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 1024, 32, 0, 0); EXPECT_NE(vnode_ptr, nullptr); int ret = vnode_mirror_delete(vnode_ptr); @@ -91,7 +91,7 @@ TEST_F(TestCaseVNode, CreateAndDeleteInEmptyNode) TEST_F(TestCaseVNode, CreateAndDelete) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 1024, 32, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 1024, 32, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod; @@ -109,7 +109,7 @@ TEST_F(TestCaseVNode, CreateAndDelete) TEST_F(TestCaseVNode, CreateAndDeleteMultiThread) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 1024, 32, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 1024, 32, 0, 0); ASSERT_NE(vnode_ptr, nullptr); /* create multiple thread and run them at same time */ @@ -141,7 +141,7 @@ TEST_F(TestCaseVNode, CreateAndDeleteMultiThread) TEST_F(TestCaseVNode, TestVNodeProdAndConsLookup) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 1024, 32, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 1024, 32, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod; @@ -164,7 +164,7 @@ TEST_F(TestCaseVNode, TestVNodeProdAndConsLookup) TEST_F(TestCaseVNode, TestVNodeEnqueue) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 1024, 0, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 1024, 0, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod; @@ -212,7 +212,7 @@ TEST_F(TestCaseVNode, TestVNodeEnqueue) TEST_F(TestCaseVNode, TestVNodeMultipleThreadEnqueue) { /* create multiple thread */ - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 32, 0, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 32, 0, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod; @@ -318,7 +318,7 @@ TEST_F(TestCaseVNode, TestVNodeMultipleThreadEnqueue) TEST_F(TestCaseVNode, TestVNodeEnqueueAndDequeueUseSharedCredict) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 32, 0, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 32, 0, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod; @@ -416,7 +416,7 @@ TEST_F(TestCaseVNode, TestVNodeEnqueueAndDequeueUseSharedCredict) TEST_F(TestCaseVNode, TestVNodeMultipleQueueUseSharedCredict) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 32, 0, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 32, 0, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod; @@ -494,7 +494,7 @@ TEST_F(TestCaseVNode, TestVNodeMultipleQueueUseSharedCredict) TEST_F(TestCaseVNode, TestVNodeEnqueueMultipleQueue) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 512, 0, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 512, 0, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod; @@ -566,7 +566,7 @@ TEST_F(TestCaseVNode, TestVNodeEnqueueMultipleQueue) TEST_F(TestCaseVNode, TestVNodeEnableMaxInFlight_NoEnoughCredits) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 16384, 32, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 16384, 32, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod = vnode_mirror_create_prod(vnode_ptr, "prod", 8); @@ -610,7 +610,7 @@ TEST_F(TestCaseVNode, TestVNodeEnableMaxInFlight_NoEnoughCredits) TEST_F(TestCaseVNode, TestVNodeEnableMaxInFlight_EnoughCredits) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 16384, 64, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 16384, 64, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod = vnode_mirror_create_prod(vnode_ptr, "prod", 8); @@ -654,7 +654,7 @@ TEST_F(TestCaseVNode, TestVNodeEnableMaxInFlight_EnoughCredits) TEST_F(TestCaseVNode, TestVNodeEnableMaxInFlight_RefillCredits) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 16384, 64, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 16384, 64, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod = vnode_mirror_create_prod(vnode_ptr, "prod", 8); @@ -750,7 +750,7 @@ TEST_F(TestCaseVNode, TestVNodeEnableMaxInFlight_RefillCredits) TEST_F(TestCaseVNode, TestVNodeEnableMaxInFlight_MultipleThreadProducer) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 16384, 64, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 16384, 64, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod = vnode_mirror_create_prod(vnode_ptr, "prod", 4); @@ -812,7 +812,7 @@ TEST_F(TestCaseVNode, TestVNodeEnableMaxInFlight_MultipleThreadProducer) TEST_F(TestCaseVNodeQueue, MultQueueEnqueue) { - struct vnode * vnode_ptr = vnode_mirror_create("vnode", 1024, 0, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("vnode", 1024, 0, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod; diff --git a/service/include/sc_devmgr.h b/service/include/sc_devmgr.h index 0b7513e..3787fe9 100644 --- a/service/include/sc_devmgr.h +++ b/service/include/sc_devmgr.h @@ -98,14 +98,8 @@ struct representor_config struct dpdk_dev_stats { - struct - { - uint64_t user_rx_packets; - uint64_t user_tx_packets; - uint64_t user_rx_drops; - uint64_t user_tx_drops; - } user[MR_SID_MAX] __rte_cache_aligned; struct rte_eth_stats rte; + uint64_t tx_drop_counter[RTE_MAX_LCORE]; }; struct dpdk_dev diff --git a/service/include/sc_vdev.h b/service/include/sc_vdev.h index b6fad5e..e247f20 100644 --- a/service/include/sc_vdev.h +++ b/service/include/sc_vdev.h @@ -39,14 +39,14 @@ struct _vdev /* Stream */ unsigned int nr_rxstream; unsigned int nr_txstream; - unsigned int sz_tunnel; - unsigned int sz_buffer; + unsigned int sz_rx_tunnel; + unsigned int sz_tx_tunnel; + unsigned int sz_max_inflight; /* VNODE */ struct vnode * vnode_rx; struct vnode * vnode_tx; struct vnode * vnode_ftx; - struct vnode * vnode_ltx; /* VNODE CONS/PROD */ struct vnode_prod * vnode_rx_prod; @@ -114,9 +114,8 @@ void vdev_stats_last_save(struct vdev * vdev, struct vdev_stat_info * stat_info_ void vdev_stats_last_get(struct vdev * vdev, struct vdev_stat_info * stat_info_last); int vdev_data_create(struct vdev_main * v_main, const char * symbol, unsigned int nr_rxstream, unsigned int nr_txstream, - unsigned int sz_tunnel_rx_exclusive, unsigned int sz_tunnel_rx_shared, unsigned int sz_tunnel_tx, - unsigned int sz_buffer, unsigned int batch_interval_in_us, unsigned int en_q_len_monitor, - struct rte_mempool * direct_pool); + unsigned int sz_tunnel_rx, unsigned int sz_tunnel_tx, unsigned int sz_max_inflight, + unsigned int batch_interval_in_us, struct rte_mempool * direct_pool); int vdev_data_dispatch(struct _vdev * _vdev, queue_id_t qid, struct rte_mbuf * pkts[], unsigned int nr_pkts, int flags); diff --git a/service/src/devmgr.c b/service/src/devmgr.c index 058569b..634a015 100644 --- a/service/src/devmgr.c +++ b/service/src/devmgr.c @@ -968,13 +968,10 @@ static char ** gcfg_device_syms_get_by_drv(struct sc_main * sc, enum mr_dev_driv struct shmdev_config { - unsigned int sz_tun_rx_exclusive; - unsigned int sz_tun_rx_shared; + unsigned int sz_tun_rx; unsigned int sz_tun_tx; - - unsigned int sz_buffer; + unsigned int sz_max_inflight; unsigned int batch_interval_in_us; - unsigned int en_q_len_monitor; }; void shmdev_config_load(struct devmgr_main * devmgr_main, const char * devsym, struct shmdev_config * cfg_out) @@ -985,31 +982,22 @@ void shmdev_config_load(struct devmgr_main * devmgr_main, const char * devsym, s unsigned int default_sz_tunnel; MESA_load_profile_uint_def(cfgfile, "device", "sz_tunnel", &default_sz_tunnel, 4096); - unsigned int default_sz_tun_rx_exclusive = default_sz_tunnel; + unsigned int default_sz_tun_rx = default_sz_tunnel; unsigned int default_sz_tun_tx = default_sz_tunnel; - unsigned int default_sz_tun_rx_shared = 0; + unsigned int default_sz_max_inflight = 0; - /* override configration */ - MESA_load_profile_uint_def(cfgfile, "device", "sz_rx_tunnel", &default_sz_tun_rx_exclusive, - default_sz_tun_rx_exclusive); + /* override configuration */ + MESA_load_profile_uint_def(cfgfile, "device", "sz_rx_tunnel", &default_sz_tun_rx, default_sz_tun_rx); MESA_load_profile_uint_def(cfgfile, "device", "sz_tx_tunnel", &default_sz_tun_tx, default_sz_tun_tx); - MESA_load_profile_uint_def(cfgfile, "device", "sz_rx_tunnel_shared", &default_sz_tun_rx_shared, - default_sz_tun_rx_shared); + MESA_load_profile_uint_def(cfgfile, "device", "sz_max_inflight", &default_sz_max_inflight, default_sz_max_inflight); - unsigned int default_sz_buffer; unsigned int default_batch_interval_in_us; - unsigned int default_en_q_len_monitor; - - MESA_load_profile_uint_def(cfgfile, "device", "sz_buffer", &default_sz_buffer, 32); MESA_load_profile_uint_def(cfgfile, "device", "batch_interval_tsc", &default_batch_interval_in_us, 50); - MESA_load_profile_uint_def(cfgfile, "device", "en_q_len_monitor", &default_en_q_len_monitor, 0); - cfg_out->sz_tun_rx_exclusive = default_sz_tun_rx_exclusive; + cfg_out->sz_tun_rx = default_sz_tun_rx; cfg_out->sz_tun_tx = default_sz_tun_tx; - cfg_out->sz_tun_rx_shared = default_sz_tun_rx_shared; - cfg_out->sz_buffer = default_sz_buffer; + cfg_out->sz_max_inflight = default_sz_max_inflight; cfg_out->batch_interval_in_us = default_batch_interval_in_us; - cfg_out->en_q_len_monitor = default_en_q_len_monitor; } int shmdev_setup_one_device(struct devmgr_main * devmgr_main, const char * devsym) @@ -1041,9 +1029,9 @@ int shmdev_setup_one_device(struct devmgr_main * devmgr_main, const char * devsy return RT_ERR; } - ret = vdev_data_create(sc->vdev_main, devsym, nr_rxstream, nr_txstream, shmdev_config.sz_tun_rx_exclusive, - shmdev_config.sz_tun_rx_shared, shmdev_config.sz_tun_tx, shmdev_config.sz_buffer, - shmdev_config.batch_interval_in_us, shmdev_config.en_q_len_monitor, direct_pool); + ret = vdev_data_create(sc->vdev_main, devsym, nr_rxstream, nr_txstream, shmdev_config.sz_tun_rx, + shmdev_config.sz_tun_tx, shmdev_config.sz_max_inflight, + shmdev_config.batch_interval_in_us, direct_pool); if (unlikely(ret < 0)) { @@ -1249,6 +1237,7 @@ static int dpdk_dev_queue_setup_rss(struct dpdk_dev * dev, cpu_set_t * rx_cpu_se dev->nr_tx_descs = default_txportconf->ring_size; } + MR_INFO("dpdk device %s: rx_desc=%d, tx_desc=%d", dev->symbol, dev->nr_rx_descs, dev->nr_tx_descs); socket_id_t dev_socket_id = rte_eth_dev_socket_id(dev->port_id); unsigned int nr_rxq_use = CPU_COUNT(rx_cpu_set); unsigned int nr_txq_use = CPU_COUNT(tx_cpu_set); @@ -2339,16 +2328,14 @@ static cJSON * dpdk_dev_monit_stats(struct dpdk_dev * dev) uint64_t user_tx_drop_total = 0; uint64_t user_tx_drop_last = 0; - for (int i = 0; i < RTE_DIM(_dpdk_dev_stat.user); i++) + for (int i = 0; i < RTE_DIM(_dpdk_dev_stat.tx_drop_counter); i++) { - user_rx_drop_total += _dpdk_dev_stat.user[i].user_rx_drops; - user_tx_drop_total += _dpdk_dev_stat.user[i].user_tx_drops; + user_rx_drop_total += _dpdk_dev_stat.tx_drop_counter[i]; } - for (int i = 0; i < RTE_DIM(_dpdk_dev_stat_last.user); i++) + for (int i = 0; i < RTE_DIM(_dpdk_dev_stat_last.tx_drop_counter); i++) { - user_rx_drop_last += _dpdk_dev_stat_last.user[i].user_rx_drops; - user_tx_drop_last += _dpdk_dev_stat_last.user[i].user_tx_drops; + user_rx_drop_last += _dpdk_dev_stat_last.tx_drop_counter[i]; } cJSON_AddNumberToObject(j_device_value, "ipackets", _eth_stat.ipackets); @@ -2604,6 +2591,9 @@ void devmgr_eal_args_generate(struct devmgr_main * devmgr_main, char * eal_argv[ unsigned int mlx5_txq_inline_mpw = 0; MESA_load_profile_uint_def(local_cfgfile, "eal", "mlx5_txq_inline_mpw", &mlx5_txq_inline_mpw, 128); + unsigned int mlx5_tx_pp = 0; + MESA_load_profile_uint_def(local_cfgfile, "eal", "mlx5_tx_pp", &mlx5_tx_pp, 0); + TAILQ_FOREACH(dev_can, &devmgr_main->dpdk_dev_candidate_list, next) { /* for now, all the candidate devices are PCI devices, diff --git a/service/src/node_phydev.c b/service/src/node_phydev.c index 51c80f9..0cb5a9d 100644 --- a/service/src/node_phydev.c +++ b/service/src/node_phydev.c @@ -29,6 +29,9 @@ struct phydev_stat_per_core { volatile uint64_t total_rx_pkts; volatile uint64_t total_tx_pkts; + volatile uint32_t total_rx_drop_pkts; + volatile uint32_t total_tx_drop_pkts; + volatile uint32_t rx_zero_iterations; volatile uint32_t rx_non_zero_iterations; } __rte_cache_aligned; @@ -478,22 +481,26 @@ static __rte_always_inline uint16_t dpdk_dev_tx_node_process(struct rte_graph * { struct dev_node_ctx * ctx = (struct dev_node_ctx *)node->ctx; struct mr_dev_desc * dev_desc = ctx->dev_desc; + struct dpdk_dev_stats * dev_stat = &ctx->dev_desc->dpdk_dev_desc->stat; + struct phydev_stat_per_core * stat_per_core = &phydev_stat[graph->id]; unsigned int tx_nr_mbufs = rte_eth_tx_burst(dev_desc->port_id, graph->id, (struct rte_mbuf **)objs, cnt); if (unlikely(tx_nr_mbufs != cnt)) { /* redirect unsent packets to drop node */ + stat_per_core->total_tx_drop_pkts += cnt - tx_nr_mbufs; + dev_stat->tx_drop_counter[graph->id] += cnt - tx_nr_mbufs; + + /* stat for dpdk dev */ rte_node_enqueue(graph, node, 0, &objs[tx_nr_mbufs], cnt - tx_nr_mbufs); } - /* stat */ - struct phydev_stat_per_core * stat_per_core = &phydev_stat[graph->id]; stat_per_core->total_tx_pkts += tx_nr_mbufs; return cnt; } static __rte_always_inline uint16_t dpdk_dev_tx_periodical_process(struct rte_graph * graph, struct rte_node * node, - void ** objs, uint16_t cnt) + void ** objs, uint16_t cnt) { struct dev_node_ctx * ctx = (struct dev_node_ctx *)node->ctx; struct mr_dev_desc * dev_desc = ctx->dev_desc; @@ -798,12 +805,17 @@ cJSON * phydev_rx_node_monit_loop(struct sc_main * sc) /* total_rx_pkts, total_tx_pkts, rx_zero_iterations, rx_total_iterations */ uint64_t total_rx_pkts[RTE_MAX_LCORE]; uint64_t total_tx_pkts[RTE_MAX_LCORE]; + uint64_t total_rx_drop_pkts[RTE_MAX_LCORE]; + uint64_t total_tx_drop_pkts[RTE_MAX_LCORE]; + double rx_spin_time[RTE_MAX_LCORE]; for (unsigned int i = 0; i < nr_graphs; i++) { total_rx_pkts[i] = phydev_stat[i].total_rx_pkts; total_tx_pkts[i] = phydev_stat[i].total_tx_pkts; + total_rx_drop_pkts[i] = phydev_stat[i].total_rx_drop_pkts; + total_tx_drop_pkts[i] = phydev_stat[i].total_tx_drop_pkts; /* calculate the spin time */ uint32_t rx_zero_iterations = phydev_stat[i].rx_zero_iterations; @@ -828,6 +840,12 @@ cJSON * phydev_rx_node_monit_loop(struct sc_main * sc) cJSON * json_total_tx_pkts = create_uint64_array(total_tx_pkts, nr_graphs); cJSON_AddItemToObject(json_root, "total_tx_pkts", json_total_tx_pkts); + cJSON * json_total_rx_drop_pkts = create_uint64_array(total_rx_drop_pkts, nr_graphs); + cJSON_AddItemToObject(json_root, "total_rx_drop_pkts", json_total_rx_drop_pkts); + + cJSON * json_total_tx_drop_pkts = create_uint64_array(total_tx_drop_pkts, nr_graphs); + cJSON_AddItemToObject(json_root, "total_tx_drop_pkts", json_total_tx_drop_pkts); + cJSON * json_rx_spin_time = cJSON_CreateDoubleArray(rx_spin_time, (int)nr_graphs); cJSON_AddItemToObject(json_root, "rx_spin_time", json_rx_spin_time); return json_root; diff --git a/service/src/vdata.c b/service/src/vdata.c index e87b52c..0010c23 100644 --- a/service/src/vdata.c +++ b/service/src/vdata.c @@ -185,9 +185,8 @@ static int vdev_data_destory(struct _vdev * _vdev) } int vdev_data_create(struct vdev_main * v_main, const char * symbol, unsigned int nr_rxstream, unsigned int nr_txstream, - unsigned int sz_tunnel_rx_exclusive, unsigned int sz_tunnel_rx_shared, unsigned int sz_tunnel_tx, - unsigned int sz_buffer, unsigned int batch_interval_in_us, unsigned int en_q_len_monitor, - struct rte_mempool * direct_pool) + unsigned int sz_tunnel_rx, unsigned int sz_tunnel_tx, unsigned int sz_max_inflight, + unsigned int batch_interval_in_us, struct rte_mempool * direct_pool) { // 检查设备是否已经存在,不允许重复创建 struct vdev * vdev_info = vdev_lookup(v_main, symbol); @@ -208,8 +207,9 @@ int vdev_data_create(struct vdev_main * v_main, const char * symbol, unsigned in snprintf(vdev_info->symbol, sizeof(vdev_info->symbol), "%s", symbol); _vdev->nr_rxstream = nr_rxstream; _vdev->nr_txstream = nr_txstream; - _vdev->sz_buffer = sz_buffer; - _vdev->sz_tunnel = sz_tunnel_rx_exclusive; + _vdev->sz_rx_tunnel = sz_tunnel_rx; + _vdev->sz_tx_tunnel = sz_tunnel_tx; + _vdev->sz_max_inflight = sz_max_inflight; _vdev->direct_pool = direct_pool; char vnode_sym_rx[MR_SYMBOL_MAX * 2]; @@ -225,11 +225,9 @@ int vdev_data_create(struct vdev_main * v_main, const char * symbol, unsigned in snprintf(vnode_sym_ltx, sizeof(vnode_sym_ltx), "%s-ltx", vdev_info->symbol); /* 创建VNODE */ - _vdev->vnode_rx = - vnode_mirror_create(vnode_sym_rx, sz_tunnel_rx_exclusive, sz_buffer, 1, batch_interval_in_us, en_q_len_monitor); - _vdev->vnode_tx = vnode_mirror_create(vnode_sym_tx, sz_tunnel_tx, sz_buffer, 0, 0, 0); - _vdev->vnode_ftx = vnode_mirror_create(vnode_sym_ftx, sz_tunnel_tx, 0, 0, 0, 0); - _vdev->vnode_ltx = vnode_mirror_create(vnode_sym_ltx, sz_tunnel_tx, 0, 0, 0, 0); + _vdev->vnode_rx = vnode_mirror_create(vnode_sym_rx, sz_tunnel_rx, sz_max_inflight, 1, batch_interval_in_us); + _vdev->vnode_tx = vnode_mirror_create(vnode_sym_tx, sz_tunnel_tx, 0, 0, 0); + _vdev->vnode_ftx = vnode_mirror_create(vnode_sym_ftx, sz_tunnel_tx, 0, 0, 0); #define ERR_VERIFY(x, ...) \ do \ @@ -245,7 +243,6 @@ int vdev_data_create(struct vdev_main * v_main, const char * symbol, unsigned in ERR_VERIFY(_vdev->vnode_rx, "Create vdev %s rx vnode failed.", vdev_info->symbol); ERR_VERIFY(_vdev->vnode_tx, "Create vdev %s tx vnode failed.", vdev_info->symbol); ERR_VERIFY(_vdev->vnode_ftx, "Create vdev %s fast tx vnode failed. ", vdev_info->symbol); - ERR_VERIFY(_vdev->vnode_ltx, "Create vdev %s lock tx vnode failed. ", vdev_info->symbol); _vdev->vnode_rx_prod = vnode_mirror_create_prod(_vdev->vnode_rx, "sv", (int)nr_rxstream); _vdev->vnode_tx_cons = vnode_mirror_create_cons(_vdev->vnode_tx, "sv", (int)nr_txstream); @@ -264,11 +261,7 @@ int vdev_data_create(struct vdev_main * v_main, const char * symbol, unsigned in return RT_SUCCESS; errout: - if (_vdev != NULL) - { - vdev_data_destory(_vdev); - } - + vdev_data_destory(_vdev); rte_free(_vdev); return RT_ERR; diff --git a/service/src/vdev.c b/service/src/vdev.c index 7ce3eff..f8ec387 100644 --- a/service/src/vdev.c +++ b/service/src/vdev.c @@ -238,32 +238,27 @@ int vdev_main_init(struct sc_main * sc) int vdev_dump(struct sc_main * sc) { MR_INFO("\n"); + for (int i = 0; i < sc->vdev_main->vdev_max_idx; i++) { struct _vdev * _vdev_iter = sc->vdev_main->_vdev_array[i]; char str_vdev_info[2048]; - int len = snprintf(str_vdev_info, sizeof(str_vdev_info), "virtual device, name=%s", _vdev_iter->vdev.symbol); - len += - snprintf(str_vdev_info + len, sizeof(str_vdev_info) - len, ", rx_thread_count=%d", _vdev_iter->nr_rxstream); - len += - snprintf(str_vdev_info + len, sizeof(str_vdev_info) - len, ", tx_thread_count=%d", _vdev_iter->nr_txstream); - len += snprintf(str_vdev_info + len, sizeof(str_vdev_info) - len, ", ring_size=%d", _vdev_iter->sz_tunnel); - len += snprintf(str_vdev_info + len, sizeof(str_vdev_info) - len, ", buffer_size=%d", _vdev_iter->sz_buffer); + int len = snprintf(str_vdev_info, sizeof(str_vdev_info), + "virtual device, name=%s, rx_thread_count=%d, tx_thread_count=%d, rx_ring_size=%d, tx_ring_size=%d, max_inflight=%d", + _vdev_iter->vdev.symbol, _vdev_iter->nr_rxstream, _vdev_iter->nr_txstream, _vdev_iter->sz_rx_tunnel, + _vdev_iter->sz_tx_tunnel, _vdev_iter->sz_max_inflight); /* IP地址没有配置,忽略IP类信息的输出 */ if (_vdev_iter->vdev.in_addr.s_addr != 0) { - len += snprintf(str_vdev_info + len, sizeof(str_vdev_info) - len, ", ip_addr=%s", - inet_ntoa(_vdev_iter->vdev.in_addr)); - len += snprintf(str_vdev_info + len, sizeof(str_vdev_info) - len, ", subnet_mask=%s", - inet_ntoa(_vdev_iter->vdev.in_addr)); - len += snprintf(str_vdev_info + len, sizeof(str_vdev_info) - len, ", gateway=%s", - inet_ntoa(_vdev_iter->vdev.in_gateway)); + snprintf(str_vdev_info + len, sizeof(str_vdev_info) - len, ", ip_addr=%s, subnet_mask=%s, gateway=%s", + inet_ntoa(_vdev_iter->vdev.in_addr), inet_ntoa(_vdev_iter->vdev.in_addr), + inet_ntoa(_vdev_iter->vdev.in_gateway)); } MR_INFO("%s", str_vdev_info); } return 0; -} +}
\ No newline at end of file diff --git a/support/CMakeLists.txt b/support/CMakeLists.txt index d06256a..b639830 100644 --- a/support/CMakeLists.txt +++ b/support/CMakeLists.txt @@ -104,7 +104,8 @@ set(DPDP_PATCH_FILES ${DPDK_PATCH_DIR}/dpdk-21.11.4-memzone-namesize.patch ${DPDK_PATCH_DIR}/dpdk-21.11.4-dpdk-hugepages-path.patch ${DPDK_PATCH_DIR}/dpdk-21.11.4-dpdk-pcapng-path.patch ${DPDK_PATCH_DIR}/dpdk-21.11.4-extend-max-virtqueue-pairs.patch - ${DPDK_PATCH_DIR}/dpdk-21.11.4-macro-adjust.patch) + ${DPDK_PATCH_DIR}/dpdk-21.11.4-macro-adjust.patch +) execute_process(COMMAND cat ${DPDP_PATCH_FILES} OUTPUT_FILE ${MERGED_PATCH_FILE}) if(CMAKE_BUILD_TYPE STREQUAL "Debug") |
