From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail04.ics.ntt-tx.co.jp (mail05.ics.ntt-tx.co.jp [210.232.35.69]) by dpdk.org (Postfix) with ESMTP id 1B45B1B011 for ; Thu, 28 Dec 2017 05:56:12 +0100 (CET) Received: from gwchk03.silk.ntt-tx.co.jp (gwchk03.silk.ntt-tx.co.jp [10.107.0.111]) by mail04.ics.ntt-tx.co.jp (unknown) with ESMTP id vBS4uBB4025230 for unknown; Thu, 28 Dec 2017 13:56:11 +0900 Received: (from root@localhost) by gwchk03.silk.ntt-tx.co.jp (unknown) id vBS4u8eS027452 for unknown; Thu, 28 Dec 2017 13:56:09 +0900 Received: from gwchk.silk.ntt-tx.co.jp [10.107.0.110] by gwchk03.silk.ntt-tx.co.jp with ESMTP id PAA27445; Thu, 28 Dec 2017 13:56:08 +0900 Received: from imss03.silk.ntt-tx.co.jp (localhost [127.0.0.1]) by imss03.silk.ntt-tx.co.jp (unknown) with ESMTP id vBS4u8cQ011174 for unknown; Thu, 28 Dec 2017 13:56:08 +0900 Received: from mgate01.silk.ntt-tx.co.jp (smtp02.silk.ntt-tx.co.jp [10.107.0.37]) by imss03.silk.ntt-tx.co.jp (unknown) with ESMTP id vBS4u8jS011162 for unknown; Thu, 28 Dec 2017 13:56:08 +0900 Message-Id: <201712280456.vBS4u8jS011162@imss03.silk.ntt-tx.co.jp> Received: from localhost by mgate01.silk.ntt-tx.co.jp (unknown) id vBS4u4bT025622 ; Thu, 28 Dec 2017 13:56:07 +0900 From: x-fn-spp@sl.ntt-tx.co.jp To: spp@dpdk.org Date: Thu, 28 Dec 2017 13:56:02 +0900 X-Mailer: git-send-email 1.9.1 In-Reply-To: <4aae78ff-3b6c-cdfe-a8b7-24ec08b73935@lab.ntt.co.jp> References: <4aae78ff-3b6c-cdfe-a8b7-24ec08b73935@lab.ntt.co.jp> X-TM-AS-MML: No Subject: [spp] [PATCH 55/57] spp_vf: add display of status command X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Dec 2017 04:56:14 -0000 From: Hiroyuki Nakamura * Display client ID. * Display information for each port. * Display information for each core. Signed-off-by: Kentaro Watanabe Signed-off-by: Yasufum Ogawa --- src/spp_vf.py | 25 ++++-- src/vf/classifier_mac.c | 86 +++++++++++++++--- src/vf/classifier_mac.h | 10 +++ src/vf/command_dec.c | 2 +- src/vf/command_proc.c | 232 ++++++++++++++++++++++++++++++++++++++++++++++-- src/vf/spp_forward.c | 73 ++++++++++++--- src/vf/spp_forward.h | 8 +- src/vf/spp_vf.c | 51 +++++++++++ src/vf/spp_vf.h | 30 +++++++ 9 files changed, 479 insertions(+), 38 deletions(-) diff --git a/src/spp_vf.py b/src/spp_vf.py index 505a142..a96b987 100755 --- a/src/spp_vf.py +++ b/src/spp_vf.py @@ -40,6 +40,7 @@ def connectionthread(name, client_id, conn, m2s, s2m): """Manage secondary process connections""" cmd_str = 'hello' + recv_str = 'recv' #infinite loop so that function do not terminate and thread do not end. while True: @@ -60,12 +61,24 @@ def connectionthread(name, client_id, conn, m2s, s2m): #Receiving from secondary try: - data = conn.recv(2048) # 2048 stands for bytes of data to be received - if data: - s2m.put("recv:" + str(conn.fileno()) + ":" + "{" + data + "}") - else: - s2m.put("closing:" + str(conn)) + recv_str = "" + while True: + data = conn.recv(1024) # 1024 stands for bytes of data to be received + if data: + recv_str = recv_str + data + if len(data) < 1024: + break + else: + break + if len(recv_str) > 0: + recv_str = "recv:" + str(conn.fileno()) + ":len:" + str(len(recv_str)) + ":\n{" + recv_str + "}\n" + + if not data: + s2m.put(recv_str + "closing:" + str(conn)) break + + #s2m.put("recv:" + str(conn.fileno()) + ":{" + recv_str + "}") + s2m.put(recv_str) except Exception, excep: print (str(excep)) break @@ -212,7 +225,7 @@ def primarythread(sock, main2primary, primary2main): #Receiving from primary try: - data = conn.recv(2048) # 2048 stands for bytes of data to be received + data = conn.recv(1024) # 1024 stands for bytes of data to be received if data: primary2main.put("recv:" + str(addr) + ":" + "{" + data + "}") else: diff --git a/src/vf/classifier_mac.c b/src/vf/classifier_mac.c index 937a8c0..2dc6071 100644 --- a/src/vf/classifier_mac.c +++ b/src/vf/classifier_mac.c @@ -67,21 +67,23 @@ static const size_t ETHER_ADDR_STR_BUF_SZ = struct classified_data { enum port_type if_type; /* interface type (see "enum port_type") */ int if_no; /* index of ports handled by classifier */ - int if_no_global; /* interface number */ - uint8_t port; /* port number used by dpdk */ + int if_no_global; /* id for interface generated by spp_vf */ + uint8_t port; /* id for port generated by DPDK */ uint16_t num_pkt; /* the number of packets in pkts[] */ struct rte_mbuf *pkts[MAX_PKT_BURST]; /* packet array to be classified */ }; /* classifier information */ struct classifier_mac_info { - struct rte_hash *classifier_table; - int num_active_classified; - int active_classifieds[RTE_MAX_ETHPORTS]; - int default_classified; - int n_classified_data_tx; - struct classified_data classified_data_rx; + char name[SPP_NAME_STR_LEN]; /* component name */ + struct rte_hash *classifier_table; /* hash table keeps classifier_table */ + int num_active_classified; /* number of valid classification */ + int active_classifieds[RTE_MAX_ETHPORTS]; /* index of valid classification */ + int default_classified; /* index of default classification */ + int n_classified_data_tx; /* number of transmission ports */ + struct classified_data classified_data_rx; /* recive port handled by classifier */ struct classified_data classified_data_tx[RTE_MAX_ETHPORTS]; + /* transmission ports handled by classifier */ }; /* classifier management information */ @@ -126,7 +128,13 @@ init_classifier_info(struct classifier_mac_info *classifier_info, classifier_info->num_active_classified = 0; classifier_info->default_classified = -1; classifier_info->n_classified_data_tx = component_info->num_tx_port; - if (component_info->num_rx_port != 0) { + if (component_info->num_rx_port == 0) { + classified_data_rx->if_type = UNDEF; + classified_data_rx->if_no = 0; + classified_data_rx->if_no_global = 0; + classified_data_rx->port = 0; + classified_data_rx->num_pkt = 0; + } else { classified_data_rx->if_type = component_info->rx_ports[0]->if_type; classified_data_rx->if_no = 0; classified_data_rx->if_no_global = component_info->rx_ports[0]->if_no; @@ -273,6 +281,8 @@ uninit_classifier(struct classifier_mac_mng_info *classifier_mng_info) if (classifier_mng_info->info[i].classifier_table != NULL){ rte_hash_free(classifier_mng_info->info[i].classifier_table); classifier_mng_info->info[i].classifier_table = NULL; + classifier_mng_info->ref_index = 0; + classifier_mng_info->upd_index = 0; } } } @@ -478,6 +488,7 @@ spp_classifier_mac_update(struct spp_component_info *component_info) "Cannot update classifer mac. ret=%d\n", ret); return ret; } + memcpy(classifier_info->name, component_info->name, SPP_NAME_STR_LEN); /* change index of reference side */ classifier_mng_info->upd_index = classifier_mng_info->ref_index; @@ -548,6 +559,9 @@ spp_classifier_mac_do(int id) prev_tsc = cur_tsc; } + if (classified_data_rx->if_type == UNDEF) + continue; + /* retrieve packets */ n_rx = rte_eth_rx_burst(classified_data_rx->port, 0, rx_pkts, MAX_PKT_BURST); @@ -573,8 +587,60 @@ spp_classifier_mac_do(int id) return 0; } +/* classifier iterate component information */ +int +spp_classifier_component_info_iterate(unsigned int lcore_id, int id, + struct spp_iterate_core_params *params) +{ + int ret = -1; + int i, num_tx, num_rx = 0; + struct classifier_mac_mng_info *classifier_mng_info; + struct classifier_mac_info *classifier_info; + struct classified_data *classified_data; + struct spp_port_index rx_ports[RTE_MAX_ETHPORTS]; + struct spp_port_index tx_ports[RTE_MAX_ETHPORTS]; + + classifier_mng_info = g_classifier_mng_info + id; + if (! is_used_mng_info(classifier_mng_info)) { + RTE_LOG(ERR, SPP_CLASSIFIER_MAC, + "Component[%d] Not used. (status)(core = %d, type = %d)\n", + id, lcore_id, SPP_COMPONENT_CLASSIFIER_MAC); + return -1; + } + + classifier_info = classifier_mng_info->info + + classifier_mng_info->ref_index; + + classified_data = classifier_info->classified_data_tx; + + memset(rx_ports, 0x00, sizeof(rx_ports)); + if (classifier_info->classified_data_rx.if_type != UNDEF) { + num_rx = 1; + rx_ports[0].if_type = classifier_info->classified_data_rx.if_type; + rx_ports[0].if_no = classifier_info->classified_data_rx.if_no_global; + } + + memset(tx_ports, 0x00, sizeof(tx_ports)); + num_tx = classifier_info->n_classified_data_tx; + for (i = 0; i < num_tx; i++) { + tx_ports[i].if_type = classified_data[i].if_type; + tx_ports[i].if_no = classified_data[i].if_no_global; + } + + /* Set the information with the function specified by the command. */ + ret = (*params->element_proc)( + params->opaque, lcore_id, + classifier_info->name, SPP_TYPE_CLASSIFIER_MAC_STR, + num_rx, rx_ports, num_tx, tx_ports); + if (unlikely(ret != 0)) + return -1; + + return 0; +} + /* classifier(mac address) iterate classifier table. */ -int spp_classifier_mac_iterate_table( +int +spp_classifier_mac_iterate_table( struct spp_iterate_classifier_table_params *params) { int ret, i; diff --git a/src/vf/classifier_mac.h b/src/vf/classifier_mac.h index f182668..b38ce70 100644 --- a/src/vf/classifier_mac.h +++ b/src/vf/classifier_mac.h @@ -29,6 +29,16 @@ int spp_classifier_mac_update(struct spp_component_info *component_info); */ int spp_classifier_mac_do(int id); +/* + * classifier iterate component information + * + * @ret_val 0 succeeded. + * @ret_val -1 failed. + */ +int +spp_classifier_component_info_iterate(unsigned int lcore_id, int id, + struct spp_iterate_core_params *params); + /** * classifier(mac address) iterate classifier table. */ diff --git a/src/vf/command_dec.c b/src/vf/command_dec.c index 166901c..56360e9 100644 --- a/src/vf/command_dec.c +++ b/src/vf/command_dec.c @@ -566,7 +566,7 @@ static struct decode_command_list command_list[] = { { "_get_client_id", 1, 1, NULL }, /* _get_client_id */ { "status", 1, 1, NULL }, /* status */ { "exit", 1, 1, NULL }, /* exit */ - { "component", 3, 5, decode_comand_parameter_in_list }, /* port */ + { "component", 3, 5, decode_comand_parameter_in_list }, /* component */ { "port", 5, 5, decode_comand_parameter_in_list }, /* port */ { "", 0, 0, NULL } /* termination */ }; diff --git a/src/vf/command_proc.c b/src/vf/command_proc.c index 0a45874..6159e87 100644 --- a/src/vf/command_proc.c +++ b/src/vf/command_proc.c @@ -243,9 +243,191 @@ append_response_client_id_value(json_t *parent_obj) return 0; } +/* append client-id value */ +static int +append_client_id_value(json_t *parent_obj) +{ + int ret = -1; + ret = json_object_set_new(parent_obj, "client-id", + json_integer(spp_get_client_id())); + if (unlikely(ret != 0)) + return -1; + + return 0; +} + +/* append interface array */ +static int +append_interface_array(json_t *parent_obj, const char *name, + const enum port_type type) +{ + int ret = -1; + int i = 0; + json_t *array_obj; + array_obj = json_array(); + if (unlikely(array_obj == NULL)) + return -1; + + for (i = 0; i < RTE_MAX_ETHPORTS; i++) { + if (!spp_check_flush_port(type, i)) + continue; + + ret = json_array_append_new(array_obj, json_integer(i)); + if (unlikely(ret != 0)) { + json_decref(array_obj); + return -1; + } + } + + ret = json_object_set_new(parent_obj, name, array_obj); + if (unlikely(ret != 0)) { + json_decref(array_obj); + return -1; + } + + return 0; +} + +/* append interface value */ +static int +append_interface_value(json_t *parent_obj) +{ + int ret = -1; + ret = append_interface_array(parent_obj, "phy", PHY); + if (unlikely(ret != 0)) + return -1; + + ret = append_interface_array(parent_obj, "vhost", VHOST); + if (unlikely(ret != 0)) + return -1; + + ret = append_interface_array(parent_obj, "ring", RING); + if (unlikely(ret != 0)) + return -1; + + return 0; +} + +/* append port array */ +static int +apeend_port_array(json_t *parent_obj, const char *name, + const int num, const struct spp_port_index *ports) +{ + int ret = -1; + int i = 0; + char port_str[64]; + json_t *array_obj; + array_obj = json_array(); + if (unlikely(array_obj == NULL)) + return -1; + + for (i = 0; i < num; i++) { + spp_format_port_string(port_str, ports[i].if_type, + ports[i].if_no); + ret = json_array_append_new(array_obj, json_string(port_str)); + if (unlikely(ret != 0)) { + json_decref(array_obj); + return -1; + } + } + + ret = json_object_set_new(parent_obj, name, array_obj); + if (unlikely(ret != 0)) { + json_decref(array_obj); + return -1; + } + + return 0; +} + +/* append core element value */ +static int +append_core_element_value( + void *opaque, const unsigned int lcore_id, + const char *name, const char *type, + const int num_rx, const struct spp_port_index *rx_ports, + const int num_tx, const struct spp_port_index *tx_ports) +{ + int ret = -1; + json_t *parent_obj = (json_t *)opaque; + json_t *tab_obj; + + tab_obj = json_object(); + if (unlikely(tab_obj == NULL)) + return -1; + + ret = json_object_set_new(tab_obj, "core", json_integer(lcore_id)); + if (unlikely(ret != 0)) { + json_decref(tab_obj); + return -1; + } + + ret = json_object_set_new(tab_obj, "name", json_string(name)); + if (unlikely(ret != 0)) { + json_decref(tab_obj); + return -1; + } + + ret = json_object_set_new(tab_obj, "type", json_string(type)); + if (unlikely(ret != 0)) { + json_decref(tab_obj); + return -1; + } + + ret = apeend_port_array(tab_obj, "rx_port", num_rx, rx_ports); + if (unlikely(ret != 0)) { + json_decref(tab_obj); + return -1; + } + + ret = apeend_port_array(tab_obj, "tx_port", num_tx, tx_ports); + if (unlikely(ret != 0)) { + json_decref(tab_obj); + return -1; + } + + ret = json_array_append_new(parent_obj, tab_obj); + if (unlikely(ret != 0)) { + json_decref(tab_obj); + return -1; + } + + return 0; +} + +/* append core value */ +static int +append_response_core_value(json_t *parent_obj) +{ + int ret = -1; + json_t *tab_obj; + struct spp_iterate_core_params itr_params; + + tab_obj = json_array(); + if (unlikely(tab_obj == NULL)) + return -1; + + itr_params.opaque = tab_obj; + itr_params.element_proc = append_core_element_value; + + ret = spp_iterate_core_info(&itr_params); + if (unlikely(ret != 0)) { + json_decref(tab_obj); + return -1; + } + + ret = json_object_set_new(parent_obj, "core", tab_obj); + if (unlikely(ret != 0)) { + json_decref(tab_obj); + return -1; + } + + return 0; +} + /* append classifier element value */ -static -int append_classifier_element_value( +static int +append_classifier_element_value( void *opaque, __rte_unused enum spp_classifier_type type, const char *data, @@ -265,12 +447,12 @@ int append_classifier_element_value( return 0; } -/* append info value(status response) to specified json object */ +/* append classifier_table value */ static int -append_response_info_value(json_t *parent_obj) +append_response_classifier_value(json_t *parent_obj) { int ret = -1; - json_t *info_obj, *tab_obj; + json_t *tab_obj; struct spp_iterate_classifier_table_params itr_params; /* create classifier_table array */ @@ -287,16 +469,48 @@ append_response_info_value(json_t *parent_obj) return -1; } + ret = json_object_set_new(parent_obj, "classifier_table", tab_obj); + if (unlikely(ret != 0)) { + json_decref(tab_obj); + return -1; + } + + return 0; +} + +/* append info value(status response) to specified json object */ +static int +append_response_info_value(json_t *parent_obj) +{ + int ret = -1; + json_t *info_obj; + /* set classifier_table object in info object */ info_obj = json_object(); - if (unlikely(info_obj == NULL)) { - json_decref(tab_obj); + if (unlikely(info_obj == NULL)) + return -1; + + ret = append_client_id_value(info_obj); + if (unlikely(ret != 0)) { + json_decref(info_obj); return -1; } - ret = json_object_set_new(info_obj, "classifier_table", tab_obj); + ret = append_interface_value(info_obj); if (unlikely(ret != 0)) { - json_decref(tab_obj); + json_decref(info_obj); + return -1; + } + + ret = append_response_core_value(info_obj); + if (unlikely(ret != 0)) { + json_decref(info_obj); + return -1; + } + + ret = append_response_classifier_value(info_obj); + if (unlikely(ret != 0)) { + json_decref(info_obj); return -1; } diff --git a/src/vf/spp_forward.c b/src/vf/spp_forward.c index 8a0980a..dbe96dc 100644 --- a/src/vf/spp_forward.c +++ b/src/vf/spp_forward.c @@ -12,15 +12,19 @@ struct forward_rxtx { struct spp_port_info tx; }; +/* Information on the path used for forward. */ struct forward_path { - int num; + char name[SPP_NAME_STR_LEN]; /* component name */ + volatile enum spp_component_type type; /* component type */ + int num; /* number of receive ports */ struct forward_rxtx ports[RTE_MAX_ETHPORTS]; + /* port used for transfer */ }; +/* Information for forward. */ struct forward_info { - enum spp_component_type type; - volatile int ref_index; - volatile int upd_index; + volatile int ref_index; /* index to reference area */ + volatile int upd_index; /* index to update area */ struct forward_path path[SPP_INFO_AREA_MAX]; }; @@ -42,8 +46,6 @@ spp_forward_init(void) static void clear_forward_info(int id) { - struct forward_info *info = &g_forward_info[id]; - info->type = SPP_COMPONENT_UNUSE; memset(&g_forward_info[id].path, 0x00, sizeof(struct forward_path)); } @@ -75,10 +77,11 @@ spp_forward_update(struct spp_component_info *component) clear_forward_info(component->component_id); RTE_LOG(INFO, FORWARD, - "Component[%d] Start update component. (type = %d)\n", - component->component_id, component->type); + "Component[%d] Start update component. (name = %s, type = %d)\n", + component->component_id, component->name, component->type); - info->type = component->type; + memcpy(&path->name, component->name, SPP_NAME_STR_LEN); + path->type = component->type; path->num = component->num_rx_port; for (cnt = 0; cnt < num_rx; cnt++) memcpy(&path->ports[cnt].rx, component->rx_ports[cnt], @@ -93,8 +96,9 @@ spp_forward_update(struct spp_component_info *component) while(likely(info->ref_index == info->upd_index)) rte_delay_us_block(SPP_CHANGE_UPDATE_INTERVAL); - RTE_LOG(INFO, FORWARD, "Component[%d] Complete update component. (type = %d)\n", - component->component_id, component->type); + RTE_LOG(INFO, FORWARD, + "Component[%d] Complete update component. (name = %s, type = %d)\n", + component->component_id, component->name, component->type); return 0; } @@ -160,3 +164,50 @@ spp_forward(int id) } return 0; } + +/* Merge/Forward iterate component information */ +int +spp_forward_core_info_iterate(unsigned int lcore_id, int id, + struct spp_iterate_core_params *params) +{ + int ret = -1; + int cnt, num_tx; + const char *component_type = NULL; + struct forward_info *info = &g_forward_info[id]; + struct forward_path *path = &info->path[info->ref_index]; + struct spp_port_index rx_ports[RTE_MAX_ETHPORTS]; + struct spp_port_index tx_ports[RTE_MAX_ETHPORTS]; + + if (unlikely(path->type == SPP_COMPONENT_UNUSE)) { + RTE_LOG(ERR, FORWARD, + "Component[%d] Not used. (status)(core = %d, type = %d)\n", + id, lcore_id, path->type); + return -1; + } + + if (path->type == SPP_COMPONENT_MERGE) + component_type = SPP_TYPE_MERGE_STR; + else + component_type = SPP_TYPE_FORWARD_STR; + + memset(rx_ports, 0x00, sizeof(rx_ports)); + for (cnt = 0; cnt < path->num; cnt++) { + rx_ports[cnt].if_type = path->ports[cnt].rx.if_type; + rx_ports[cnt].if_no = path->ports[cnt].rx.if_no; + } + + memset(tx_ports, 0x00, sizeof(tx_ports)); + num_tx = (path->num > 0)?1:0; + tx_ports[0].if_type = path->ports[0].tx.if_type; + tx_ports[0].if_no = path->ports[0].tx.if_no; + + /* Set the information with the function specified by the command. */ + ret = (*params->element_proc)( + params->opaque, lcore_id, + path->name, component_type, + path->num, rx_ports, num_tx, tx_ports); + if (unlikely(ret != 0)) + return -1; + + return 0; +} diff --git a/src/vf/spp_forward.h b/src/vf/spp_forward.h index 729dbe8..ed0744d 100644 --- a/src/vf/spp_forward.h +++ b/src/vf/spp_forward.h @@ -1,11 +1,13 @@ #ifndef __SPP_FORWARD_H__ #define __SPP_FORWARD_H__ - +/* Clear info */ void spp_forward_init(void); +/* Clear info for one element. */ void spp_forward_init_info(int id); +/* Update forward info */ int spp_forward_update(struct spp_component_info *component); /* @@ -13,4 +15,8 @@ int spp_forward_update(struct spp_component_info *component); */ int spp_forward(int id); +/* Merge/Forward iterate component information */ +int spp_forward_core_info_iterate(unsigned int lcore_id, int id, + struct spp_iterate_core_params *params); + #endif /* __SPP_FORWARD_H__ */ diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c index d6eb7b2..f97c348 100644 --- a/src/vf/spp_vf.c +++ b/src/vf/spp_vf.c @@ -488,6 +488,7 @@ set_nic_interface(void) } for (nic_cnt = 0; nic_cnt < g_if_info.num_nic; nic_cnt++) { + g_if_info.nic[nic_cnt].if_type = PHY; g_if_info.nic[nic_cnt].dpdk_port = nic_cnt; } @@ -842,6 +843,16 @@ spp_check_added_port(enum port_type if_type, int if_no) } /* + * Check if port has been flushed. + */ +int +spp_check_flush_port(enum port_type if_type, int if_no) +{ + struct spp_port_info *port = get_if_area(if_type, if_no); + return port->dpdk_port >= 0; +} + +/* * Check if component is using port. */ int @@ -1068,6 +1079,7 @@ spp_update_component( core->num++; ret = SPP_RET_OK; tmp_lcore_id = lcore_id; + g_change_component[component_id] = 1; break; case SPP_CMD_ACTION_STOP: @@ -1091,6 +1103,7 @@ spp_update_component( core->type = SPP_COMPONENT_UNUSE; ret = SPP_RET_OK; + g_change_component[component_id] = 0; break; default: @@ -1320,6 +1333,44 @@ spp_flush(void) return SPP_RET_OK; } +/* Iterate core infomartion */ +int +spp_iterate_core_info(struct spp_iterate_core_params *params) +{ + int ret; + int core_cnt, cnt; + struct core_info *core = NULL; + + for (core_cnt = 0; core_cnt < RTE_MAX_LCORE; core_cnt++) { + if (spp_get_core_status(core_cnt) == SPP_CORE_UNUSE) + continue; + + core = get_core_info(core_cnt); + for (cnt = 0; cnt < core->num; cnt++) { + if (core->type == SPP_COMPONENT_CLASSIFIER_MAC) { + ret = spp_classifier_component_info_iterate( + core_cnt, + core->id[cnt], + params); + } else { + ret = spp_forward_core_info_iterate( + core_cnt, + core->id[cnt], + params); + } + if (unlikely(ret != 0)) { + RTE_LOG(ERR, APP, "Cannot iterate core information. " + "(core = %d, type = %d)\n", + core_cnt, core->type); + return SPP_RET_NG; + } + } + } + + return SPP_RET_OK; +} + +/* Iterate Classifier_table */ int spp_iterate_classifier_table( struct spp_iterate_classifier_table_params *params) diff --git a/src/vf/spp_vf.h b/src/vf/spp_vf.h index 90a2886..9e846ef 100644 --- a/src/vf/spp_vf.h +++ b/src/vf/spp_vf.h @@ -3,6 +3,10 @@ #include "common.h" +#define SPP_TYPE_CLASSIFIER_MAC_STR "classifier_mac" +#define SPP_TYPE_MERGE_STR "merge" +#define SPP_TYPE_FORWARD_STR "forward" + #define SPP_IFTYPE_NIC_STR "phy" #define SPP_IFTYPE_VHOST_STR "vhost" #define SPP_IFTYPE_RING_STR "ring" @@ -162,6 +166,26 @@ int spp_update_port( */ int spp_flush(void); +/* definition of iterated core element procedure function */ +typedef int (*spp_iterate_core_element_proc)( + void *opaque, + const unsigned int lcore_id, + const char *name, + const char *type, + const int num_rx, + const struct spp_port_index *rx_ports, + const int num_tx, + const struct spp_port_index *tx_ports); + +/* iterate core information parameters */ +struct spp_iterate_core_params { + void *opaque; + spp_iterate_core_element_proc element_proc; +}; + +/* Iterate core infomartion */ +int spp_iterate_core_info(struct spp_iterate_core_params *params); + /* definition of iterated classifier element procedure function */ typedef int (*spp_iterate_classifier_element_proc)( void *opaque, @@ -221,6 +245,12 @@ int spp_check_mac_used_port(uint64_t mac_addr, enum port_type if_type, int if_no int spp_check_added_port(enum port_type if_type, int if_no); /* + * Check if port has been flushed. + * RETURN : True if port has been flushed. + */ +int spp_check_flush_port(enum port_type if_type, int if_no); + +/* * Check if component is using port. * OK : match component ID * NG : SPP_RET_NG -- 1.9.1