Soft Patch Panel
 help / color / mirror / Atom feed
From: x-fn-spp@sl.ntt-tx.co.jp
To: spp@dpdk.org
Subject: [spp] [PATCH 51/57] spp_vf: refactor for commnets in spp_config.c
Date: Thu, 28 Dec 2017 13:55:58 +0900	[thread overview]
Message-ID: <201712280456.vBS4u8iY011158@imss03.silk.ntt-tx.co.jp> (raw)
In-Reply-To: <4aae78ff-3b6c-cdfe-a8b7-24ec08b73935@lab.ntt.co.jp>

From: Hiroyuki Nakamura <nakamura.hioryuki@po.ntt-tx.co.jp>

* Update remaining Japanese to English.
* Remove meaningless comments, for instance, 'Get client ID' for
  spp_get_client_id() or 'initialize' for init functions.
* Add suplementary comments for more understandable
* Add TODOs for futher revising.
* Remove nouse whitespaces.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/vf/spp_config.c | 197 ++++++++++++++++++++++------------------------------
 1 file changed, 83 insertions(+), 114 deletions(-)

diff --git a/src/vf/spp_config.c b/src/vf/spp_config.c
index bca455c..55129ac 100644
--- a/src/vf/spp_config.c
+++ b/src/vf/spp_config.c
@@ -24,8 +24,12 @@
 #define JSONPATH_TX_PORT    "$.tx_port"
 #define JSONPATH_TX_TABLE   "$.tx_port_table"
 
-/*
+/**
  * Instead of json_path_get
+ *
+ * TODO(yasufum) confirm, add instead of what
+ * TODO(yasufum) confirm, add reason why this function is needed
+ * TODO(yasufum) confirm, add roles of obj, new_obj to make it more understandable
  */
 json_t *
 spp_config_get_path_obj(const json_t *json, const char *path)
@@ -74,69 +78,69 @@ spp_config_get_path_obj(const json_t *json, const char *path)
 	return new_obj;
 }
 
-/*
+/**
  * Get integer data from config
+ *
+ * If target is found, the result is assigned to argument 'value' and
+ * it reutrns 0, or returns -1 if not found.
  */
 static int
 config_get_int_value(const json_t *obj, const char *path, int *value)
 {
-	/* 指定パラメータのJsonオブジェクト取得 */
+	/* Use tmp to get target value of integer */
 	json_t *tmp_obj = spp_config_get_path_obj(obj, path);
 	if (unlikely(tmp_obj == NULL)) {
-		/* 必須でないデータを取得する場合を考慮し、DEBUGログとする。 */
+		/* For debugging, logging a case of null */
 		RTE_LOG(DEBUG, APP, "No parameter. (path = %s)\n", path);
 		return -1;
 	}
 
-	/* Integer type check */
 	if (unlikely(!json_is_integer(tmp_obj))) {
-		/* 必須でないデータを取得する場合を考慮し、DEBUGログとする。 */
+		/* For debugging, logging for other than target type */
 		RTE_LOG(DEBUG, APP, "Not an integer. (path = %s)\n", path);
 		return -1;
 	}
 
-	/* Set to OUT parameter */
 	*value = json_integer_value(tmp_obj);
 	RTE_LOG(DEBUG, APP, "get value = %d\n", *value);
 	return 0;
 }
 
 /*
- * Get String data from config
+ * Get string data from config
+ *
+ * If target is found, the result is assigned to argument 'value' and
+ * it reutrns 0, or returns -1 if not found.
  */
 static int
 config_get_str_value(const json_t *obj, const char *path, char *value)
 {
-	/* 指定パラメータのJsonオブジェクト取得 */
 	json_t *tmp_obj = spp_config_get_path_obj(obj, path);
 	if (unlikely(tmp_obj == NULL)) {
 		RTE_LOG(DEBUG, APP, "No parameter. (path = %s)\n", path);
 		return -1;
 	}
 
-	/* String type check */
 	if (unlikely(!json_is_string(tmp_obj))) {
+		/* For debugging, logging for other than target type */
 		RTE_LOG(DEBUG, APP, "Not a string. (path = %s)\n", path);
 		return -1;
 	}
 
-	/* Set to OUT parameter */
 	strcpy(value, json_string_value(tmp_obj));
 	RTE_LOG(DEBUG, APP, "get value = %s\n", value);
 	return 0;
 }
 
-/*
- * コンフィグ情報初期化
- */
+/* TODO(yasufum) change function name to be realized doing init, for instance, init_config_area()  */
 static void
 config_init_data(struct spp_config_area *config)
 {
-	/* 0クリア */
+  /* Clear config area with zero */
 	memset(config, 0x00, sizeof(struct spp_config_area));
 	int core_cnt, port_cnt, table_cnt;
 
-	/* IF種別初期設定 */
+  /* Set all of interface type of ports and mac tables to UNDEF */
 	for (core_cnt = 0; core_cnt < SPP_CONFIG_CORE_MAX; core_cnt++) {
 		for (port_cnt = 0; port_cnt < RTE_MAX_ETHPORTS; port_cnt++) {
 			config->proc.functions[core_cnt].rx_ports[port_cnt].if_type = UNDEF;
@@ -150,9 +154,13 @@ config_init_data(struct spp_config_area *config)
 	return;
 }
 
-/*
- * IFの情報からIF種別とIF番号を取得する
- * ("ring0" -> 種別:"ring"、番号:0)
+/**
+ * Sepeparate port id of combination of iface type and number and
+ * assign to given argment, if_type and if_no.
+ *
+ * For instance, 'ring:0' is separated to 'ring' and '0'.
+ *
+ * TODO(yasufum) change if to iface
  */
 int
 spp_config_get_if_info(const char *port, enum port_type *if_type, int *if_no)
@@ -161,7 +169,7 @@ spp_config_get_if_info(const char *port, enum port_type *if_type, int *if_no)
 	const char *no_str = NULL;
 	char *endptr = NULL;
 
-	/* IF type check */
+	/* Find out which type of interface from port */
 	if (strncmp(port, SPP_CONFIG_IFTYPE_NIC ":", strlen(SPP_CONFIG_IFTYPE_NIC)+1) == 0) {
 		/* NIC */
 		type = PHY;
@@ -180,7 +188,7 @@ spp_config_get_if_info(const char *port, enum port_type *if_type, int *if_no)
 		return -1;
 	}
 
-	/* IF番号を文字列から数値変換 */
+  /* Change type of number of interface */
 	int ret_no = strtol(no_str, &endptr, 0);
 	if (unlikely(no_str == endptr) || unlikely(*endptr != '\0')) { 
 		/* No IF number */
@@ -188,7 +196,6 @@ spp_config_get_if_info(const char *port, enum port_type *if_type, int *if_no)
 		return -1;
 	}
 
-	/* Set OUT parameter */
 	*if_type = type;
 	*if_no = ret_no;
 
@@ -197,8 +204,9 @@ spp_config_get_if_info(const char *port, enum port_type *if_type, int *if_no)
 	return 0;
 }
 
-/*
- * IF種別とIF番号からIF情報文字列を作成する
+/**
+ * Generate a formatted string of conbination from interface type and
+ * number and assign to given 'port'
  */
 int spp_config_format_port_string(char *port, enum port_type if_type, int if_no)
 {
@@ -223,8 +231,8 @@ int spp_config_format_port_string(char *port, enum port_type if_type, int if_no)
 	return 0;
 }
 
-/*
- * MAC addressを文字列から数値へ変換
+/**
+ * Change mac address of 'aa:bb:cc:dd:ee:ff' to int64 and return it
  */
 int64_t
 spp_config_change_mac_str_to_int64(const char *mac)
@@ -253,14 +261,14 @@ spp_config_change_mac_str_to_int64(const char *mac)
 			break;
 		}
 
-		/* 各数値をまとめる */
+		/* Append separated value to the result */
 		token_val = (int64_t)ret_tol;
 		ret_mac |= token_val << (token_cnt * 8);
 		token_cnt++;
 		str = NULL;
 	}
 
-	/* 区切り文字が5個以外 */
+	/* Check for mal-formatted address */
 	if (unlikely(token_cnt != ETHER_ADDR_LEN)) {
 		RTE_LOG(ERR, APP, "MAC address format error. (mac = %s)\n",
 				 mac);
@@ -272,21 +280,17 @@ spp_config_change_mac_str_to_int64(const char *mac)
 	return ret_mac;
 }
 
-/*
- * Classifier table読み込み
- */
 static int
 config_load_classifier_table(const json_t *obj,
 		struct spp_config_classifier_table *classifier_table)
 {
-	/* classifier_table用オブジェクト取得 */
 	json_t *classifier_obj = spp_config_get_path_obj(obj, JSONPATH_CLASSIFIER_TABLE);
 	if (unlikely(classifier_obj == NULL)) {
 		RTE_LOG(INFO, APP, "No classifier table.\n");
 		return 0;
 	}
 
-	/* name取得 */
+	/* Name of classifier table */
 	int ret_name = config_get_str_value(classifier_obj, JSONPATH_NAME,
 			classifier_table->name);
 	if (unlikely(ret_name != 0)) {
@@ -294,22 +298,20 @@ config_load_classifier_table(const json_t *obj,
 		return -1;
 	}
 
-	/* table用オブジェクト取得 */
+	/* Setup classifier as an array */
 	json_t *array_obj = spp_config_get_path_obj(classifier_obj, JSONPATH_TABLE);
 	if (unlikely(!array_obj)) {
 		RTE_LOG(ERR, APP, "Json object get failed. (path = %s)\n",
 				JSONPATH_TABLE);
 		return -1;
 	}
-
-	/* table用オブジェクトが配列かチェック */
 	if (unlikely(!json_is_array(array_obj))) {
 		RTE_LOG(ERR, APP, "Not an array. (path = %s)\n",
 				JSONPATH_TABLE);
 		return -1;
 	}
 
-	/* table用オブジェクトの要素数取得 */
+	/* Get the number of tables to set an attribute of classifier_table */
 	int array_num = json_array_size(array_obj);
 	if (unlikely(array_num <= 0) ||
 			unlikely(array_num > SPP_CONFIG_MAC_TABLE_MAX)) {
@@ -319,14 +321,14 @@ config_load_classifier_table(const json_t *obj,
 	}
 	classifier_table->num_table = array_num;
 
-	/* テーブルの各要素毎にデータ取得 */
+  /* Setup for each of mac tables */
 	struct spp_config_mac_table_element *tmp_table = NULL;
 	char if_str[SPP_CONFIG_STR_LEN];
 	int table_cnt = 0;
 	for (table_cnt = 0; table_cnt < array_num; table_cnt++) {
 		tmp_table = &classifier_table->mac_tables[table_cnt];
 
-		/* 要素取得 */
+		/* Get contents from the table */
 		json_t *elements_obj = json_array_get(array_obj, table_cnt);
 		if (unlikely(elements_obj == NULL)) {
 			RTE_LOG(ERR, APP,
@@ -335,7 +337,6 @@ config_load_classifier_table(const json_t *obj,
 			return -1;
 		}
 
-		/* MACアドレス(文字列)取得 */
 		int ret_mac = config_get_str_value(elements_obj, JSONPATH_MAC,
 				tmp_table->mac_addr_str);
 		if (unlikely(ret_mac != 0)) {
@@ -345,13 +346,16 @@ config_load_classifier_table(const json_t *obj,
 			return -1;
 		}
 
-		/* デフォルト転送先指定であれば内部流通用ダミーアドレスに変換 */
+    /**
+     * If mac address is set to 'default', replace it to reserved
+     * dummy address for validation.
+     */
 		if (unlikely(strcmp(tmp_table->mac_addr_str,
 				SPP_CONFIG_DEFAULT_CLASSIFIED_SPEC_STR) == 0))
 			strcpy(tmp_table->mac_addr_str,
 					SPP_CONFIG_DEFAULT_CLASSIFIED_DMY_ADDR_STR);
 
-		/* MACアドレス数値変換 */
+		/* Convert mac address to integer */
 		int64_t ret_mac64 = spp_config_change_mac_str_to_int64(
 				tmp_table->mac_addr_str);
 		if (unlikely(ret_mac64 == -1)) {
@@ -362,7 +366,7 @@ config_load_classifier_table(const json_t *obj,
 		}
 		tmp_table->mac_addr = ret_mac64;
 
-		/* IF情報取得 */
+		/* Extract a set of port type and number of interface */
 		int ret_if_str = config_get_str_value(elements_obj,
 				JSONPATH_PORT, if_str);
 		if (unlikely(ret_if_str != 0)) {
@@ -371,8 +375,7 @@ config_load_classifier_table(const json_t *obj,
 				table_cnt, JSONPATH_PORT);
 			return -1;
 		}
-
-		/* IF種別とIF番号に分割 */
+    /* And separate it to type and number */
 		int ret_if = spp_config_get_if_info(if_str, &tmp_table->port.if_type,
 				&tmp_table->port.if_no);
 		if (unlikely(ret_if != 0)) {
@@ -386,8 +389,8 @@ config_load_classifier_table(const json_t *obj,
 	return 0;
 }
 
-/*
- * 処理種別を文字列から数値変換
+/**
+ * Return the type of forwarder as a member of enum of spp_core_type
  */
 static enum spp_core_type
 config_change_core_type(const char *core_type)
@@ -398,19 +401,17 @@ config_change_core_type(const char *core_type)
 		return SPP_CONFIG_CLASSIFIER_MAC;
 	} else if (strncmp(core_type, CONFIG_CORE_TYPE_MERGE,
 			 strlen(CONFIG_CORE_TYPE_MERGE)+1) == 0) {
-		/* Merge */
+		/* Merger */
 		return SPP_CONFIG_MERGE;
 	} else if (strncmp(core_type, CONFIG_CORE_TYPE_FORWARD,
 			 strlen(CONFIG_CORE_TYPE_FORWARD)+1) == 0) {
-		/* Forward */
+		/* Forwarder */
 		return SPP_CONFIG_FORWARD;
 	}
 	return SPP_CONFIG_UNUSE;
 }
 
-/*
- * 受信ポート取得
- */
+/* Set behavior of rx port for forwarder, merger or classifier */
 static int
 config_set_rx_port(enum spp_core_type type, json_t *obj,
 		struct spp_config_functions *functions)
@@ -418,8 +419,7 @@ config_set_rx_port(enum spp_core_type type, json_t *obj,
 	struct spp_config_port_info *tmp_rx_port = NULL;
 	char if_str[SPP_CONFIG_STR_LEN];
 	if (type == SPP_CONFIG_MERGE) {
-		/* Merge */
-		/* 受信ポート用オブジェクト取得 */
+		/* Merger */
 		json_t *array_obj = spp_config_get_path_obj(obj, JSONPATH_RX_PORT);
 		if (unlikely(!array_obj)) {
 			RTE_LOG(ERR, APP, "Json object get failed. (path = %s, route = merge)\n",
@@ -427,14 +427,13 @@ config_set_rx_port(enum spp_core_type type, json_t *obj,
 			return -1;
 		}
 
-		/* 受信ポート用オブジェクトが配列かチェック */
 		if (unlikely(!json_is_array(array_obj))) {
 			RTE_LOG(ERR, APP, "Not an array. (path = %s, route = merge)\n",
 				JSONPATH_TABLE);
 			return -1;
 		}
 
-		/* 受信ポート用オブジェクトの要素数取得 */
+	  /* Check if the size of array is not over RTE_MAX_ETHPORTS */
 		int port_num = json_array_size(array_obj);
 		if (unlikely(port_num <= 0) ||
 				unlikely(port_num > RTE_MAX_ETHPORTS)) {
@@ -444,12 +443,11 @@ config_set_rx_port(enum spp_core_type type, json_t *obj,
 		}
 		functions->num_rx_port = port_num;
 
-		/* 要素毎にデータ取得 */
+		/* Get interface type and number of each of entries for merging */
 		int array_cnt = 0;
 		for (array_cnt = 0; array_cnt < port_num; array_cnt++) {
 			tmp_rx_port = &functions->rx_ports[array_cnt];
 
-			/* 要素取得 */
 			json_t *elements_obj = json_array_get(array_obj, array_cnt);
 			if (unlikely(elements_obj == NULL)) {
 				RTE_LOG(ERR, APP,
@@ -458,7 +456,6 @@ config_set_rx_port(enum spp_core_type type, json_t *obj,
 				return -1;
 			}
 
-			/* String type check */
 			if (unlikely(!json_is_string(elements_obj))) {
 				RTE_LOG(ERR, APP, "Not a string. (path = %s, No = %d, route = merge)\n",
 						JSONPATH_RX_PORT, array_cnt);
@@ -466,7 +463,7 @@ config_set_rx_port(enum spp_core_type type, json_t *obj,
 			}
 			strcpy(if_str, json_string_value(elements_obj));
 
-			/* IF種別とIF番号に分割 */
+			/* Separate combination of interface type and number to each */
 			int ret_if = spp_config_get_if_info(if_str, &tmp_rx_port->if_type,
 					&tmp_rx_port->if_no);
 			if (unlikely(ret_if != 0)) {
@@ -477,18 +474,18 @@ config_set_rx_port(enum spp_core_type type, json_t *obj,
 			}
 		}
 	} else {
-		/* Classifier/Forward */
+		/* Classifier or forwarder */
 		tmp_rx_port = &functions->rx_ports[0];
 		functions->num_rx_port = 1;
 
-		/* 受信ポート取得 */
+		/* Get receiving port */
 		int ret_rx_port = config_get_str_value(obj, JSONPATH_RX_PORT, if_str);
 		if (unlikely(ret_rx_port != 0)) {
 			RTE_LOG(ERR, APP, "RX port get failed.\n");
 			return -1;
 		}
 
-		/* IF種別とIF番号に分割 */
+		/* Separate it to interface type and number */
 		int ret_if = spp_config_get_if_info(if_str, &tmp_rx_port->if_type,
 				&tmp_rx_port->if_no);
 		if (unlikely(ret_if != 0)) {
@@ -501,9 +498,7 @@ config_set_rx_port(enum spp_core_type type, json_t *obj,
 	return 0;
 }
 
-/*
- * 送信先ポート情報取得
- */
+/* Set behavior of tx port for forwarder, merger or classifier */
 static int
 config_set_tx_port(enum spp_core_type type, json_t *obj,
 		struct spp_config_functions *functions,
@@ -513,11 +508,11 @@ config_set_tx_port(enum spp_core_type type, json_t *obj,
 	struct spp_config_port_info *tmp_tx_port = NULL;
 	char if_str[SPP_CONFIG_STR_LEN];
 	if ((type == SPP_CONFIG_MERGE) || (type == SPP_CONFIG_FORWARD)) {
-		/* Merge or Forward */
+		/* Merger or forwarder */
 		tmp_tx_port = &functions->tx_ports[0];
 		functions->num_tx_port = 1;
 
-		/* 送信ポート取得 */
+		/* Get receiving port */
 		int ret_tx_port = config_get_str_value(obj,
 				JSONPATH_TX_PORT, if_str);
 		if (unlikely(ret_tx_port != 0)) {
@@ -525,7 +520,7 @@ config_set_tx_port(enum spp_core_type type, json_t *obj,
 			return -1;
 		}
 
-		/* IF種別とIF番号に分割 */
+		/* Separate it to interface type and number */
 		int ret_if = spp_config_get_if_info(if_str, &tmp_tx_port->if_type,
 				&tmp_tx_port->if_no);
 		if (unlikely(ret_if != 0)) {
@@ -538,23 +533,17 @@ config_set_tx_port(enum spp_core_type type, json_t *obj,
 		/* Classifier */
 		json_t *table_obj = spp_config_get_path_obj(obj, JSONPATH_TX_TABLE);
 		if (unlikely(table_obj != NULL)) {
-			/* Classifier Tableから取得 */
 			functions->num_tx_port = classifier_table->num_table;
 			struct spp_config_mac_table_element *tmp_mac_table = NULL;
 			for (cnt = 0; cnt < classifier_table->num_table; cnt++) {
 				tmp_tx_port = &functions->tx_ports[cnt];
 				tmp_mac_table = &classifier_table->mac_tables[cnt];
 
-				/* MAC振り分けテーブルより設定 */
 				tmp_tx_port->if_type = tmp_mac_table->port.if_type;
 				tmp_tx_port->if_no   = tmp_mac_table->port.if_no;
 			}
-			
-		}
-		else
-		{
-			/* tx_portパラメータより取得 */
-			/* 送信ポート用オブジェクト取得 */
+		} else {
+			/* Get sending ports if table_obj is NULL */
 			json_t *array_obj = spp_config_get_path_obj(obj, JSONPATH_TX_PORT);
 			if (unlikely(array_obj == NULL)) {
 				RTE_LOG(ERR, APP, "Json object get failed. (path = %s, route = classifier)\n",
@@ -562,14 +551,13 @@ config_set_tx_port(enum spp_core_type type, json_t *obj,
 				return -1;
 			}
 
-			/* 送信ポート用オブジェクトが配列かチェック */
 			if (unlikely(!json_is_array(array_obj))) {
 				RTE_LOG(ERR, APP, "Not an array. (path = %s, route = classifier)\n",
 					JSONPATH_TX_PORT);
 				return -1;
 			}
 
-			/* 受信ポート用オブジェクトの要素数取得 */
+	    /* Check if the size of array is not over RTE_MAX_ETHPORTS */
 			int port_num = json_array_size(array_obj);
 			if (unlikely(port_num <= 0) ||
 					unlikely(port_num > RTE_MAX_ETHPORTS)) {
@@ -579,12 +567,10 @@ config_set_tx_port(enum spp_core_type type, json_t *obj,
 			}
 			functions->num_tx_port = port_num;
 
-			/* 要素毎にデータ取得 */
 			int array_cnt = 0;
 			for (array_cnt = 0; array_cnt < port_num; array_cnt++) {
 				tmp_tx_port = &functions->tx_ports[array_cnt];
 
-				/* 要素取得 */
 				json_t *elements_obj = json_array_get(array_obj, array_cnt);
 				if (unlikely(elements_obj == NULL)) {
 					RTE_LOG(ERR, APP,
@@ -593,7 +579,7 @@ config_set_tx_port(enum spp_core_type type, json_t *obj,
 					return -1;
 				}
 
-				/* String type check */
+        /* Get sending port */
 				if (unlikely(!json_is_string(elements_obj))) {
 					RTE_LOG(ERR, APP, "Not a string. (path = %s, No = %d, route = classifier)\n",
 							JSONPATH_TX_PORT, array_cnt);
@@ -601,7 +587,7 @@ config_set_tx_port(enum spp_core_type type, json_t *obj,
 				}
 				strcpy(if_str, json_string_value(elements_obj));
 
-				/* IF種別とIF番号に分割 */
+		    /* Separate it to interface type and number */
 				int ret_if = spp_config_get_if_info(if_str, &tmp_tx_port->if_type,
 						&tmp_tx_port->if_no);
 				if (unlikely(ret_if != 0)) {
@@ -617,16 +603,13 @@ config_set_tx_port(enum spp_core_type type, json_t *obj,
 	return 0;
 }
 
-/*
- * プロセス情報取得
- */
 static int
 config_load_proc_info(const json_t *obj, int node_id, struct spp_config_area *config)
 {
 	struct spp_config_proc_info *proc = &config->proc;
 	struct spp_config_classifier_table *classifier_table = &config->classifier_table;
 
-	/* proc_table用オブジェクト取得 */
+	/* TODO(yasufum) add comment after updating definition of the function in spp_config.c */
 	json_t *proc_table_obj = spp_config_get_path_obj(obj, JSONPATH_PROC_TABLE);
 	if (unlikely(proc_table_obj == NULL)) {
 		RTE_LOG(ERR, APP, "Json object get failed. (path = %s)\n",
@@ -634,14 +617,14 @@ config_load_proc_info(const json_t *obj, int node_id, struct spp_config_area *co
 		return -1;
 	}
 
-	/* table用オブジェクトが配列かチェック */
+	/* Return error code if it is not an array_obj */
 	if (unlikely(!json_is_array(proc_table_obj))) {
 		RTE_LOG(ERR, APP, "Not an array. (path = %s)\n",
 				JSONPATH_TABLE);
 		return -1;
 	}
 
-	/* table用オブジェクトの要素数取得 */
+	/* Check if the size of array is not over node_id */
 	int proc_table_num = json_array_size(proc_table_obj);
 	if (unlikely(proc_table_num < node_id)) {
 		RTE_LOG(ERR, APP, "No process data. (Size = %d, Node = %d)\n",
@@ -649,7 +632,7 @@ config_load_proc_info(const json_t *obj, int node_id, struct spp_config_area *co
 		return -1;
 	}
 
-	/* 要素取得 */
+	/* Get proc_obj for attributes */
 	json_t *proc_obj = json_array_get(proc_table_obj, node_id);
 	if (unlikely(proc_obj == NULL)) {
 		RTE_LOG(ERR, APP, "Process data get failed. (Node = %d)\n",
@@ -657,14 +640,14 @@ config_load_proc_info(const json_t *obj, int node_id, struct spp_config_area *co
 		return -1;
 	}
 
-	/* name取得 */
+	/* Name of proc */
 	int ret_name = config_get_str_value(proc_obj, JSONPATH_NAME, proc->name);
 	if (unlikely(ret_name != 0)) {
 		RTE_LOG(ERR, APP, "Process name get failed.\n");
 		return -1;
 	}
 
-	/* VHOST数取得 */
+	/* Number of vhost interfaces of proc */
 	int ret_vhost = config_get_int_value(proc_obj, JSONPATH_NUM_VHOST,
 			&proc->num_vhost);
 	if (unlikely(ret_vhost != 0)) {
@@ -672,7 +655,7 @@ config_load_proc_info(const json_t *obj, int node_id, struct spp_config_area *co
 		return -1;
 	}
 
-	/* RING数取得 */
+	/* Number of ring interfaces of proc */
 	int ret_ring = config_get_int_value(proc_obj, JSONPATH_NUM_RING,
 			&proc->num_ring);
 	if (unlikely(ret_ring != 0)) {
@@ -680,7 +663,7 @@ config_load_proc_info(const json_t *obj, int node_id, struct spp_config_area *co
 		return -1;
 	}
 
-	/* functions用オブジェクト取得 */
+	/* Get the number of operator functions */
 	json_t *array_obj = spp_config_get_path_obj(proc_obj, JSONPATH_FUNCTIONS);
 	if (unlikely(!array_obj)) {
 		RTE_LOG(ERR, APP, "Json object get failed. (path = %s)\n",
@@ -688,14 +671,12 @@ config_load_proc_info(const json_t *obj, int node_id, struct spp_config_area *co
 		return -1;
 	}
 
-	/* functions用オブジェクトが配列かチェック */
 	if (unlikely(!json_is_array(array_obj))) {
 		RTE_LOG(ERR, APP, "Not an array. (path = %s)\n",
 				JSONPATH_FUNCTIONS);
 		return -1;
 	}
 
-	/* functions用オブジェクトの要素数取得 */
 	int array_num = json_array_size(array_obj);
 	if (unlikely(array_num <= 0) ||
 			unlikely(array_num > SPP_CONFIG_CORE_MAX)) {
@@ -705,14 +686,13 @@ config_load_proc_info(const json_t *obj, int node_id, struct spp_config_area *co
 	}
 	proc->num_func = array_num;
 
-	/* 要素毎にデータ取得 */
+	/* Get each of operator functions */
 	struct spp_config_functions *tmp_functions = NULL;
 	char core_type_str[SPP_CONFIG_STR_LEN];
 	int array_cnt = 0;
 	for (array_cnt = 0; array_cnt < array_num; array_cnt++) {
 		tmp_functions = &proc->functions[array_cnt];
 
-		/* 要素取得 */
 		json_t *elements_obj = json_array_get(array_obj, array_cnt);
 		if (unlikely(elements_obj == NULL)) {
 			RTE_LOG(ERR, APP,
@@ -721,7 +701,7 @@ config_load_proc_info(const json_t *obj, int node_id, struct spp_config_area *co
 			return -1;
 		}
 
-		/* CORE番号取得 */
+		/* Get number and type of the core */
 		int ret_core = config_get_int_value(elements_obj, JSONPATH_CORE_NO,
 				&tmp_functions->core_no);
 		if (unlikely(ret_core != 0)) {
@@ -730,7 +710,6 @@ config_load_proc_info(const json_t *obj, int node_id, struct spp_config_area *co
 			return -1;
 		}
 
-		/* 処理種別取得 */
 		int ret_core_type = config_get_str_value(elements_obj,
 				 JSONPATH_CORE_TYPE, core_type_str);
 		if (unlikely(ret_core_type != 0)) {
@@ -739,7 +718,7 @@ config_load_proc_info(const json_t *obj, int node_id, struct spp_config_area *co
 			return -1;
 		}
 
-		/* 処理種別を数値に変換 */
+		/* Convert the type of core to a member of enum spp_core_type */
 		enum spp_core_type core_type = config_change_core_type(core_type_str);
 		if (unlikely(core_type == SPP_CONFIG_UNUSE)) {
 			RTE_LOG(ERR, APP,
@@ -749,7 +728,7 @@ config_load_proc_info(const json_t *obj, int node_id, struct spp_config_area *co
 		}
 		tmp_functions->type = core_type;
 
-		/* 受信ポート取得 */
+		/* Get rx and tx ports */
 		int ret_rx_port = config_set_rx_port(core_type, elements_obj,
 				tmp_functions);
 		if (unlikely(ret_rx_port != 0)) {
@@ -758,7 +737,6 @@ config_load_proc_info(const json_t *obj, int node_id, struct spp_config_area *co
 			return -1;
 		}
 
-		/* 送信ポート取得 */
 		int ret_tx_port = config_set_tx_port(core_type, elements_obj,
 				tmp_functions, classifier_table);
 		if (unlikely(ret_tx_port != 0)) {
@@ -771,18 +749,11 @@ config_load_proc_info(const json_t *obj, int node_id, struct spp_config_area *co
 	return 0;
 }
 
-/*
- * Load config file
- * OK : 0
- * NG : -1
- */
 int
 spp_config_load_file(const char* config_file_path, int node_id, struct spp_config_area *config)
 {
-	/* Config initialize */
 	config_init_data(config);
-	
-	/* Config load */
+
 	json_error_t json_error;
 	json_t *conf_obj = json_load_file(config_file_path, 0, &json_error);
 	if (unlikely(conf_obj == NULL)) {
@@ -792,7 +763,6 @@ spp_config_load_file(const char* config_file_path, int node_id, struct spp_confi
 		return -1;
 	}
 
-	/* classifier table */
 	int ret_classifier = config_load_classifier_table(conf_obj,
 			&config->classifier_table);
 	if (unlikely(ret_classifier != 0)) {
@@ -801,7 +771,6 @@ spp_config_load_file(const char* config_file_path, int node_id, struct spp_confi
 		return -1;
 	}
 
-	/* proc info */
 	int ret_proc = config_load_proc_info(conf_obj, node_id, config);
 	if (unlikely(ret_proc != 0)) {
 		RTE_LOG(ERR, APP, "Process table load failed.\n");
@@ -809,7 +778,7 @@ spp_config_load_file(const char* config_file_path, int node_id, struct spp_confi
 		return -1;
 	}
 
-	/* Config object release */
+	/* Finally, release config object */
 	json_decref(conf_obj);
 
 	return 0;
-- 
1.9.1

  parent reply	other threads:[~2017-12-28  4:56 UTC|newest]

Thread overview: 97+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-25  4:41 [spp] Proposal - spp_vf(SR-IOV like feature) addition to SPP Nakamura Hioryuki
2017-12-26  1:54 ` Yasufumi Ogawa
2017-12-28  4:55   ` [spp] [PATCH 01/57] spp_vf: add vf functions x-fn-spp
2017-12-28  8:49     ` Yasufumi Ogawa
2017-12-28  4:55   ` [spp] [PATCH 02/57] spp_vf: support multi process x-fn-spp
2018-02-07 16:50     ` Ferruh Yigit
2018-02-08  1:21       ` Yasufumi Ogawa
2018-02-08  6:44       ` [spp] [spp 02168] " Nakamura Hioryuki
2017-12-28  4:55   ` [spp] [PATCH 03/57] spp_vf: comment out check of using cores x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 04/57] spp_vf: modify classifier for upd command x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 05/57] spp_vf: add procedure that mac address is null x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 06/57] spp_vf: change config format for upd command x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 07/57] spp_vf: fix compiler warning in classifier_mac.c x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 08/57] spp_vf: modify data struct for upd command x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 09/57] spp_vf: add functions of command acceptance x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 10/57] spp_vf: add command acceptance calling x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 11/57] spp_vf: fix compiler warning in command_proc.c x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 12/57] " x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 13/57] spp_vf: refactor command acceptance/decode x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 14/57] spp_vf: fix return value overwrite problem x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 15/57] spp_vf: initialize message buffer x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 16/57] spp_vf: add const keyword to parameter x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 17/57] spp_vf: fix wrong comparison operator x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 18/57] spp_vf: fix wrong variable to be assigned x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 19/57] spp_vf: refactor parsing server ip address x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 20/57] spp_vf: fix error in command decode x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 21/57] spp_vf: fix comparison operator in spp_vf.c x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 22/57] spp_vf: check upper limit to the number of process x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 23/57] spp_vf: display usage message x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 24/57] spp_vf: split command processing source file x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 25/57] spp_vf: add new log and line break x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 26/57] spp_vf: support get-process-id command x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 27/57] spp_vf: update socket creation procedure x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 28/57] spp_vf: change log level and add line break x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 29/57] spp_vf: replace unsupported jansson api x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 30/57] spp_vf: change order of command result in json object x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 31/57] spp_vf: use prediction keywords x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 32/57] spp_vf: fix wrong comparison x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 33/57] spp_vf: update sending error status x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 34/57] spp_vf: modify conditional statement x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 35/57] spp_vf: add proc on receiving l2 multicast x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 36/57] spp_vf: extend limit on number of usable cores x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 37/57] spp_vf: add restart procedure for vhost client x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 38/57] spp_vf: fix classifier mbuf handling x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 39/57] spp_vf: add status command x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 40/57] spp_vf: add output source information in error log x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 41/57] spp_vf: change function names x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 42/57] spp_vf: change how to request commands x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 43/57] spp_vf: update command decode procedure x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 44/57] spp_vf: remove debug log output procedures x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 45/57] spp_vf: improve command_decoder program code x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 46/57] spp_vf: fix a bug in status command x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 47/57] spp_vf: add spp_vf.py instead of spp.py x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 48/57] spp_vf: refactor for commnets in spp_vf.c x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 49/57] spp_vf: refactor comments in classifier_mac.c x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 50/57] spp_vf: refactor comments in spp_forward.c x-fn-spp
2017-12-28  4:55   ` x-fn-spp [this message]
2017-12-28  4:55   ` [spp] [PATCH 52/57] spp_vf: refactor no self-explanatory comments x-fn-spp
2017-12-28  4:56   ` [spp] [PATCH 53/57] spp_vf: correct typo of function name x-fn-spp
2017-12-28  4:56   ` [spp] [PATCH 54/57] spp_vf: support new command x-fn-spp
2017-12-28  4:56   ` [spp] [PATCH 55/57] spp_vf: add display of status command x-fn-spp
2017-12-28  4:56   ` [spp] [PATCH 56/57] spp_vf: fix " x-fn-spp
2017-12-28  4:56   ` [spp] [PATCH 57/57] spp_vf: fix l2 multicast packet forwarding x-fn-spp
2018-01-15 11:04 ` [spp] Proposal - spp_vf(SR-IOV like feature) addition to SPP Ferruh Yigit
2018-01-16  5:16   ` [spp] [PATCH 01/30] doc: add setup guide x-fn-spp
2018-01-19  0:52     ` Yasufumi Ogawa
2018-01-22 14:37       ` Ferruh Yigit
2018-01-23  0:25         ` Yasufumi Ogawa
2018-01-16  5:16   ` [spp] [PATCH 02/30] doc: add how_to_use.md x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 03/30] doc: add config_manual.md x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 04/30] doc: add spp_vf.md x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 05/30] doc: revise spp_vf.md x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 06/30] doc: add config section x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 07/30] doc: update jp setup manual x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 08/30] doc: modify figure in spp_vf_overview x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 09/30] doc: fix " x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 10/30] doc: fix figure in overview x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 11/30] doc: add sample usage x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 12/30] doc: revice path descs x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 13/30] doc: add network configuration diagram x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 14/30] doc: update user account x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 15/30] doc: update descriptions for todo x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 16/30] doc: add description for explanation section x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 17/30] doc: add spp_sample_usage_svg in docs/spp_vf/ x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 18/30] doc: add explanation for terminating spp app x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 19/30] doc: add explanations on options of spp x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 20/30] doc: update description for the latest spp version x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 21/30] doc: update description on dpdk version x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 22/30] doc: fix vm setup procedure for network config x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 23/30] doc: update jansson installation procedure x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 24/30] doc: fix required network configuration x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 25/30] doc: add how to use vhost-user support x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 26/30] doc: add references to hugepages and isolcpus x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 27/30] doc: remove description on classifier_table x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 28/30] doc: fix typos and erros in texts x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 29/30] doc: update sample config section x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 30/30] doc: align figure title position x-fn-spp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201712280456.vBS4u8iY011158@imss03.silk.ntt-tx.co.jp \
    --to=x-fn-spp@sl.ntt-tx.co.jp \
    --cc=spp@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).