summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLu Qiuwen <[email protected]>2022-09-01 03:23:23 -0400
committerLu Qiuwen <[email protected]>2022-09-01 03:23:23 -0400
commit864c9e7952a065270c99dd41b0444f536c20849a (patch)
tree06dda35fc0c8b6a54168453ac8c9e1872cbc69b1
parent2360ec50ffce8a32e1f330bb9cb4397059a79db3 (diff)
增加控制通道的统计功能。feature-gtp-offload
-rw-r--r--app/src/mrb.c1
-rw-r--r--service/src/monit.c34
-rw-r--r--service/src/offload.c48
-rw-r--r--service/src/vdata.c23
4 files changed, 57 insertions, 49 deletions
diff --git a/app/src/mrb.c b/app/src/mrb.c
index 336c39d..7ac0496 100644
--- a/app/src/mrb.c
+++ b/app/src/mrb.c
@@ -699,6 +699,7 @@ marsio_buff_t * marsio_buff_malloc_smartoffload(struct mr_vdev * vdev, const cha
struct rte_mbuf * __mbuf = (struct rte_mbuf *)bufs[0];
assert(__mbuf != NULL);
+ __mbuf->hash.usr = rte_lcore_id();
char * cur_ptr = rte_pktmbuf_append(__mbuf, pkt_len);
if (unlikely(cur_ptr == NULL))
{
diff --git a/service/src/monit.c b/service/src/monit.c
index ce90fa6..edf81d6 100644
--- a/service/src/monit.c
+++ b/service/src/monit.c
@@ -69,15 +69,15 @@ static cJSON * __create_vdev_stats(struct vdev * vdev, unsigned int nr_serv_thre
__JOIN_VDEV_VALUE_STATS_ITEM(tx_missed);
__JOIN_VDEV_VALUE_STATS_ITEM(tx_total_len);
- __JOIN_VDEV_VALUE_STATS_ITEM(ftx_on_line);
- __JOIN_VDEV_VALUE_STATS_ITEM(ftx_deliver);
- __JOIN_VDEV_VALUE_STATS_ITEM(ftx_missed);
- __JOIN_VDEV_VALUE_STATS_ITEM(ftx_total_len);
-
- __JOIN_VDEV_VALUE_STATS_ITEM(ltx_on_line);
- __JOIN_VDEV_VALUE_STATS_ITEM(ltx_deliver);
- __JOIN_VDEV_VALUE_STATS_ITEM(ltx_missed);
- __JOIN_VDEV_VALUE_STATS_ITEM(ltx_total_len);
+ __JOIN_VDEV_VALUE_STATS_ITEM(crx_on_line);
+ __JOIN_VDEV_VALUE_STATS_ITEM(crx_deliver);
+ __JOIN_VDEV_VALUE_STATS_ITEM(crx_missed);
+ __JOIN_VDEV_VALUE_STATS_ITEM(crx_total_len);
+
+ __JOIN_VDEV_VALUE_STATS_ITEM(ctx_on_line);
+ __JOIN_VDEV_VALUE_STATS_ITEM(ctx_deliver);
+ __JOIN_VDEV_VALUE_STATS_ITEM(ctx_missed);
+ __JOIN_VDEV_VALUE_STATS_ITEM(ctx_total_len);
#define __JOIN_VDEV_SPEED_STATS_ITEM(item) do { \
cJSON_AddItemToObject(j_vdev_speed, #item, \
@@ -95,15 +95,15 @@ static cJSON * __create_vdev_stats(struct vdev * vdev, unsigned int nr_serv_thre
__JOIN_VDEV_SPEED_STATS_ITEM(tx_missed);
__JOIN_VDEV_SPEED_STATS_ITEM(tx_total_len);
- __JOIN_VDEV_SPEED_STATS_ITEM(ftx_on_line);
- __JOIN_VDEV_SPEED_STATS_ITEM(ftx_deliver);
- __JOIN_VDEV_SPEED_STATS_ITEM(ftx_missed);
- __JOIN_VDEV_SPEED_STATS_ITEM(ftx_total_len);
+ __JOIN_VDEV_SPEED_STATS_ITEM(crx_on_line);
+ __JOIN_VDEV_SPEED_STATS_ITEM(crx_deliver);
+ __JOIN_VDEV_SPEED_STATS_ITEM(crx_missed);
+ __JOIN_VDEV_SPEED_STATS_ITEM(crx_total_len);
- __JOIN_VDEV_SPEED_STATS_ITEM(ltx_on_line);
- __JOIN_VDEV_SPEED_STATS_ITEM(ltx_deliver);
- __JOIN_VDEV_SPEED_STATS_ITEM(ltx_missed);
- __JOIN_VDEV_SPEED_STATS_ITEM(ltx_total_len);
+ __JOIN_VDEV_SPEED_STATS_ITEM(ctx_on_line);
+ __JOIN_VDEV_SPEED_STATS_ITEM(ctx_deliver);
+ __JOIN_VDEV_SPEED_STATS_ITEM(ctx_missed);
+ __JOIN_VDEV_SPEED_STATS_ITEM(ctx_total_len);
cJSON_AddItemToObject(j_vdev_stats, "accumulative", j_vdev_value);
cJSON_AddItemToObject(j_vdev_stats, "speed", j_vdev_speed);
diff --git a/service/src/offload.c b/service/src/offload.c
index ac5f942..c38fd86 100644
--- a/service/src/offload.c
+++ b/service/src/offload.c
@@ -20,6 +20,7 @@
#include <sc_vdev.h>
#include <cJSON.h>
#include <mrb_define.h>
+#include <MESA_prof_load.h>
#define SMARTOFFLOAD_DEV_MAX 512
#define SMARTOFFLOAD_REPORT_METADATA_CTRL_ZONE_ID 0
@@ -71,6 +72,7 @@ struct smartoffload_main
/* stats */
struct smartoffload_stat_per_lcore stat_per_lcore[RTE_MAX_LCORE];
+ unsigned int flow_age_in_sec;
};
int smartoffload_config(struct sc_main * sc)
@@ -84,12 +86,8 @@ int smartoffload_init(struct sc_main * sc)
MR_VERIFY_MALLOC(sc->smartoffload_main);
struct smartoffload_main * smartoffload_main = sc->smartoffload_main;
- struct phydev_main * phydev_main = sc->phydev_main;
- struct vdev_main * vdev_main = sc->vdev_main;
-
- assert(phydev_main != NULL);
- assert(vdev_main != NULL);
+ MESA_load_profile_uint_def(sc->local_cfgfile, "offload", "flow_age_in_sec", &smartoffload_main->flow_age_in_sec, 30);
struct phydev * phydev_iter = NULL;
/* Checkout all physical devices which smartoffload is enabled. */
@@ -810,14 +808,13 @@ void smartoffload_flow_destroy(struct smartoffload_flow * flow)
}
}
-int smartoffload_flow_init_ctrl_mbuf(struct smartoffload_flow * offload_flow, struct phydev * phydev, struct rte_mbuf * mbuf)
+int smartoffload_flow_init_ctrl_mbuf(struct smartoffload_flow * offload_flow, struct phydev * phydev, struct rte_mbuf * mbuf, unsigned int age)
{
unsigned int cur_offset = 0;
- struct tlv_header_define * tlv_header;
/* move to offload_flow->mbuf */
offload_flow->mbuf = mbuf;
- offload_flow->age = 30;
+ offload_flow->age = age;
/* pkt hdr and len */
const char * pkt_header = rte_pktmbuf_mtod(offload_flow->mbuf, const char *);
@@ -879,7 +876,7 @@ void smartoffload_rxtx_loop_per_dev(struct sc_main * sc, struct smartoffload_dev
struct vdev * vdev = dev_instance->vdev;
struct phydev * phydev = dev_instance->phydev;
struct rte_flow_error flow_error = {};
- struct smartoffload_main * main = sc->smartoffload_main;
+ struct smartoffload_main * so_main = sc->smartoffload_main;
uint32_t lcore_id = rte_lcore_id();
unsigned int local_rxq_id = dev_instance->map_lcore_to_rxq[lcore_id];
@@ -893,16 +890,16 @@ void smartoffload_rxtx_loop_per_dev(struct sc_main * sc, struct smartoffload_dev
return;
}
- SMARTOFFLOAD_STAT_ADD(main, offload_request_recv, rx_nr_mbufs);
+ SMARTOFFLOAD_STAT_ADD(so_main, offload_request_recv, rx_nr_mbufs);
for (unsigned int i = 0; i < rx_nr_mbufs; i++)
{
struct smartoffload_flow __flow_in_stack = {};
struct smartoffload_flow * smart_offload_flow = &__flow_in_stack;
- int ret = smartoffload_flow_init_ctrl_mbuf(smart_offload_flow, phydev, mbufs[i]);
+ int ret = smartoffload_flow_init_ctrl_mbuf(smart_offload_flow, phydev, mbufs[i], so_main->flow_age_in_sec);
if (unlikely(ret < 0))
{
- SMARTOFFLOAD_STAT_ADD(main, offload_request_accept_err_flow_construct, 1);
+ SMARTOFFLOAD_STAT_ADD(so_main, offload_request_accept_err_flow_construct, 1);
goto _errout;
}
@@ -919,7 +916,7 @@ void smartoffload_rxtx_loop_per_dev(struct sc_main * sc, struct smartoffload_dev
if (unlikely(ret < 0))
{
MR_ERROR("Failed at flow validate: ret = %d, %s.", ret, flow_error.message);
- SMARTOFFLOAD_STAT_ADD(main, offload_request_accept_err_flow_create, 1);
+ SMARTOFFLOAD_STAT_ADD(so_main, offload_request_accept_err_flow_create, 1);
goto _errout;
}
@@ -945,19 +942,19 @@ void smartoffload_rxtx_loop_per_dev(struct sc_main * sc, struct smartoffload_dev
{
if(rte_errno == EEXIST)
{
- SMARTOFFLOAD_STAT_ADD(main, offload_request_accept_duplicated, 1);
+ SMARTOFFLOAD_STAT_ADD(so_main, offload_request_accept_duplicated, 1);
}
else
{
- SMARTOFFLOAD_STAT_ADD(main, offload_request_accept_err_flow_create, 1);
+ SMARTOFFLOAD_STAT_ADD(so_main, offload_request_accept_err_flow_create, 1);
}
goto _errout;
}
- SMARTOFFLOAD_STAT_ADD(main, offload_request_accept_success, 1);
- SMARTOFFLOAD_STAT_ADD(main, flow_create, 1);
+ SMARTOFFLOAD_STAT_ADD(so_main, offload_request_accept_success, 1);
+ SMARTOFFLOAD_STAT_ADD(so_main, flow_create, 1);
continue;
_errout:
@@ -999,7 +996,7 @@ static void create_report_mbuf_from_aged_ctxs(struct rte_mempool * pool,
out_mbufs[i] = out_mbuf;
}
- return RT_SUCCESS;
+ return;
}
void smartoffload_timeout_flows_per_dev(struct sc_main * sc, struct smartoffload_dev_instance * dev_instance)
@@ -1087,19 +1084,16 @@ out:
void smartoffload_rxtx_loop(struct sc_main * sc, unsigned int lcore_id)
{
struct smartoffload_main * smartoffload_main = sc->smartoffload_main;
- const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) / US_PER_S * TIMEOUT_CHECK_US;
- static uint64_t prev_tsc[RTE_MAX_LCORE] = {};
- uint64_t cur_tsc = rte_rdtsc();
for (unsigned int i = 0; i < smartoffload_main->nr_dev_instances; i++)
{
smartoffload_rxtx_loop_per_dev(sc, smartoffload_main->dev_instances[i]);
}
- for (unsigned int i = 0; i < smartoffload_main->nr_dev_instances; i++)
- {
- smartoffload_timeout_flows_per_dev(sc, smartoffload_main->dev_instances[i]);
- }
+ for (unsigned int i = 0; i < smartoffload_main->nr_dev_instances; i++)
+ {
+ smartoffload_timeout_flows_per_dev(sc, smartoffload_main->dev_instances[i]);
+ }
return;
}
@@ -1115,7 +1109,7 @@ int32_t smartoffload_service_entry(void * args)
cJSON * smartoffload_monit_loop(struct sc_main * sc)
{
- struct smartoffload_main * main = sc->smartoffload_main;
+ struct smartoffload_main * so_main = sc->smartoffload_main;
cJSON * json_root = cJSON_CreateObject();
@@ -1128,7 +1122,7 @@ cJSON * smartoffload_monit_loop(struct sc_main * sc)
if (!CPU_ISSET(i, &sc->cpu_set_offload)) \
continue; \
\
- uint64_t value = main->stat_per_lcore[i]._counter; \
+ uint64_t value = so_main->stat_per_lcore[i]._counter; \
cJSON_AddItemToArray(json_array, cJSON_CreateNumber(value)); \
} \
cJSON_AddItemToObject(json_root, _str_counter, json_array); \
diff --git a/service/src/vdata.c b/service/src/vdata.c
index 0b15a66..756e3f8 100644
--- a/service/src/vdata.c
+++ b/service/src/vdata.c
@@ -105,8 +105,10 @@ static int vdev_data_idle_poll(struct _vdev * _vdev, queue_id_t qid)
static int vdev_data_stats_get(struct _vdev * _vdev, struct vdev_stat_info * stat_info)
{
struct vnode_prod_stat * st_prod_rx = vnode_mirror_prod_stat_get(_vdev->vnode_rx_prod);
+ struct vnode_prod_stat * st_prod_ctrl_rx = vnode_mirror_prod_stat_get(_vdev->vnode_rx_ctrl_prod);
+
struct vnode_cons_stat * st_cons_tx = vnode_mirror_cons_stat_get(_vdev->vnode_tx_cons);
- struct vnode_cons_stat * st_cons_ltx = vnode_mirror_cons_stat_get(_vdev->vnode_tx_ctrl_cons);
+ struct vnode_cons_stat * st_cons_ctrl_tx = vnode_mirror_cons_stat_get(_vdev->vnode_tx_ctrl_cons);
//TODO: What about nr_rxstream, nr_txstream is different?
for (int i = 0; i < _vdev->nr_rxstream; i++)
@@ -117,17 +119,28 @@ static int vdev_data_stats_get(struct _vdev * _vdev, struct vdev_stat_info * sta
stat_info->rx_total_len[i] = VNODE_STAT_READ(&st_prod_rx[i].on_line);
}
+ for (int i = 0; i < _vdev->nr_ctrl_rxstream; i++)
+ {
+ stat_info->crx_on_line[i] = VNODE_STAT_READ(&st_prod_ctrl_rx[i].on_line);
+ stat_info->crx_deliver[i] = VNODE_STAT_READ(&st_prod_ctrl_rx[i].deliver);
+ stat_info->crx_missed[i] = VNODE_STAT_READ(&st_prod_ctrl_rx[i].missed);
+ stat_info->crx_total_len[i] = VNODE_STAT_READ(&st_prod_ctrl_rx[i].on_line);
+ }
+
for (int i = 0; i < _vdev->nr_txstream; i++)
{
stat_info->tx_on_line[i] = VNODE_STAT_READ(&st_cons_tx[i].on_line);
stat_info->tx_deliver[i] = VNODE_STAT_READ(&st_cons_tx[i].deliver);
stat_info->tx_missed[i] = VNODE_STAT_READ(&st_cons_tx[i].missed);
stat_info->tx_total_len[i] = VNODE_STAT_READ(&st_cons_tx[i].total_len);
+ }
- stat_info->ltx_on_line[i] = VNODE_STAT_READ(&st_cons_ltx[i].on_line);
- stat_info->ltx_deliver[i] = VNODE_STAT_READ(&st_cons_ltx[i].deliver);
- stat_info->ltx_missed[i] = VNODE_STAT_READ(&st_cons_ltx[i].missed);
- stat_info->ltx_total_len[i] = VNODE_STAT_READ(&st_cons_ltx[i].total_len);
+ for(int i = 0; i < _vdev->nr_ctrl_txstream; i++)
+ {
+ stat_info->ctx_on_line[i] = VNODE_STAT_READ(&st_cons_ctrl_tx[i].on_line);
+ stat_info->ctx_deliver[i] = VNODE_STAT_READ(&st_cons_ctrl_tx[i].deliver);
+ stat_info->ctx_missed[i] = VNODE_STAT_READ(&st_cons_ctrl_tx[i].missed);
+ stat_info->ctx_total_len[i] = VNODE_STAT_READ(&st_cons_ctrl_tx[i].total_len);
}
return 0;