diff options
| -rw-r--r-- | include/internal/adapter_define.h | 1 | ||||
| -rw-r--r-- | infra/src/port_adapter_mapping.c | 60 |
2 files changed, 24 insertions, 37 deletions
diff --git a/include/internal/adapter_define.h b/include/internal/adapter_define.h index 63db8c6..66d9728 100644 --- a/include/internal/adapter_define.h +++ b/include/internal/adapter_define.h @@ -11,6 +11,7 @@ enum adapter_type ADAPTER_TYPE_NONE }; +const char * str_adapter_type(enum adapter_type type); unsigned int nr_max_vwires_get(); uint16_t ef_nr_adapters_get(); unsigned int nr_max_ef_adapters_get(); diff --git a/infra/src/port_adapter_mapping.c b/infra/src/port_adapter_mapping.c index f8e5da9..a426f9a 100644 --- a/infra/src/port_adapter_mapping.c +++ b/infra/src/port_adapter_mapping.c @@ -57,24 +57,7 @@ int port_adapter_mapping_insert(port_id_t port_id, enum adapter_type adapter_typ g_mapping_mgr->port_adapter_maps[port_id] = adapter_type; g_mapping_mgr->nr_maps++; - char str_adapter_type[MR_STRING_MAX]; - switch (adapter_type) - { - case ADAPTER_TYPE_EF: - snprintf(str_adapter_type, sizeof(str_adapter_type) - 1, "Etherfabric"); - break; - case ADAPTER_TYPE_VWIRE: - snprintf(str_adapter_type, sizeof(str_adapter_type) - 1, "Vwire"); - break; - case ADAPTER_TYPE_TERA: - snprintf(str_adapter_type, sizeof(str_adapter_type) - 1, "Tera"); - break; - default: - snprintf(str_adapter_type, sizeof(str_adapter_type) - 1, "None"); - break; - } - - MR_INFO("Port adapter mapping insert, port_id: %d, adapter_type: %s.", port_id, str_adapter_type); + MR_INFO("Port adapter mapping insert, port_id: %d, adapter_type: %s.", port_id, str_adapter_type(adapter_type)); return RT_SUCCESS; } @@ -142,26 +125,29 @@ void port_adapter_mapping_dump(void) for (int i = 0; i < RTE_DIM(g_mapping_mgr->port_adapter_maps); i++) { - if (g_mapping_mgr->port_adapter_maps[i] != ADAPTER_TYPE_NONE) + enum adapter_type type = g_mapping_mgr->port_adapter_maps[i]; + if (type != ADAPTER_TYPE_NONE) { - char str_adapter_type[MR_STRING_MAX]; - - switch (g_mapping_mgr->port_adapter_maps[i]) - { - case ADAPTER_TYPE_EF: - snprintf(str_adapter_type, sizeof(str_adapter_type) - 1, "Etherfabric"); - break; - case ADAPTER_TYPE_VWIRE: - snprintf(str_adapter_type, sizeof(str_adapter_type) - 1, "Vwire"); - break; - case ADAPTER_TYPE_TERA: - snprintf(str_adapter_type, sizeof(str_adapter_type) - 1, "Tera"); - break; - default: - snprintf(str_adapter_type, sizeof(str_adapter_type) - 1, "None"); - break; - } - MR_INFO("Port adapter mapping, port_id:%d, adapter_type:%s", i, str_adapter_type); + MR_INFO("Port adapter mapping, port_id:%d, adapter_type:%s", i, str_adapter_type(type)); } } } + +const char * str_adapter_type(enum adapter_type type) +{ + switch (type) + { + case ADAPTER_TYPE_EF: + return "Etherfabric"; + case ADAPTER_TYPE_VWIRE: + return "Vwire"; + case ADAPTER_TYPE_TERA: + return "Tera"; + case ADAPTER_TYPE_ALL: + return "All"; + case ADAPTER_TYPE_NONE: + return "None"; + default: + return "Unknow"; + } +} |
