summaryrefslogtreecommitdiff
path: root/infra
diff options
context:
space:
mode:
authortongzongzhen <[email protected]>2024-09-27 15:10:22 +0800
committertongzongzhen <[email protected]>2024-09-27 15:10:22 +0800
commit78d4bc884c5c395f785b949633a2b1dcea79ff79 (patch)
tree95cbe4e3e606706b8beae9595e7cc7151c183b6a /infra
parent34732cc360c7e3f70c3bb58b5f2414cead6cea05 (diff)
minor changes
Diffstat (limited to 'infra')
-rw-r--r--infra/src/port_adapter_mapping.c60
1 files changed, 23 insertions, 37 deletions
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";
+ }
+}