aboutsummaryrefslogtreecommitdiffstats
path: root/stacks/lwip_stack/lwip_src
diff options
context:
space:
mode:
authoryalei wang <wylandrea@gmail.com>2018-10-30 07:40:15 +0000
committerGerrit Code Review <gerrit@fd.io>2018-10-30 07:40:15 +0000
commitdbc4c0c8284eddb91e5294ba00e0b43c8faab930 (patch)
tree615beff297ee2e0681169fb5929017d35be7fc5a /stacks/lwip_stack/lwip_src
parent3dd2a5fdd89db1d532229d2ec29078e8e4b23689 (diff)
parent4ed7096d4a4aff47a812a79252edd0834277ee30 (diff)
Merge "Feat: support vhost-user in lwip stack"
Diffstat (limited to 'stacks/lwip_stack/lwip_src')
-rw-r--r--stacks/lwip_stack/lwip_src/api/spl_tcpip.c2
-rw-r--r--stacks/lwip_stack/lwip_src/include/ip_module/ip_module_api.h1
-rw-r--r--stacks/lwip_stack/lwip_src/include/netif/sharedmemory.h1
-rw-r--r--stacks/lwip_stack/lwip_src/ip_module/network.c43
-rw-r--r--stacks/lwip_stack/lwip_src/netif/spl_hal.c21
5 files changed, 64 insertions, 4 deletions
diff --git a/stacks/lwip_stack/lwip_src/api/spl_tcpip.c b/stacks/lwip_stack/lwip_src/api/spl_tcpip.c
index b627bcf..d8c7533 100644
--- a/stacks/lwip_stack/lwip_src/api/spl_tcpip.c
+++ b/stacks/lwip_stack/lwip_src/api/spl_tcpip.c
@@ -61,7 +61,7 @@
#include "sys.h"
-#define NSTACK_MAIN_MAX_PARA 19
+#define NSTACK_MAIN_MAX_PARA 32
#define NSTACK_MAIN_MIN_PARA 1
#define DPDK_DEFAULT_EAL_MEM_SIZE (1024)
diff --git a/stacks/lwip_stack/lwip_src/include/ip_module/ip_module_api.h b/stacks/lwip_stack/lwip_src/include/ip_module/ip_module_api.h
index 488e13e..acf5057 100644
--- a/stacks/lwip_stack/lwip_src/include/ip_module/ip_module_api.h
+++ b/stacks/lwip_stack/lwip_src/include/ip_module/ip_module_api.h
@@ -149,6 +149,7 @@ struct network_configuration
struct ip_subnet *ip_subnet;
char network_name[IP_MODULE_MAX_NAME_LEN];
char type_name[IP_MODULE_MAX_NAME_LEN];
+ char nic_type_name[IP_MODULE_MAX_NAME_LEN];
network_buffer *buffer;
};
diff --git a/stacks/lwip_stack/lwip_src/include/netif/sharedmemory.h b/stacks/lwip_stack/lwip_src/include/netif/sharedmemory.h
index 0a92ea0..6230ed8 100644
--- a/stacks/lwip_stack/lwip_src/include/netif/sharedmemory.h
+++ b/stacks/lwip_stack/lwip_src/include/netif/sharedmemory.h
@@ -101,6 +101,7 @@ enum proc_run_type
struct linux_port_info
{
char if_name[HAL_MAX_NIC_NAME_LEN];
+ char if_type[HAL_MAX_NIC_NAME_LEN];
char ip_addr_linux[18]; //uint32_t ip_addr_linux;
char mask_linux[18]; //uint32_t mask_linux;
char bcast_linux[18]; //uint32_t bcast_linux;
diff --git a/stacks/lwip_stack/lwip_src/ip_module/network.c b/stacks/lwip_stack/lwip_src/ip_module/network.c
index ef0d9a7..d7c9630 100644
--- a/stacks/lwip_stack/lwip_src/ip_module/network.c
+++ b/stacks/lwip_stack/lwip_src/ip_module/network.c
@@ -510,7 +510,8 @@ add_network_configuration (struct network_configuration
while (pheader)
{
if (!spl_hal_is_nic_exist (pheader->nic_name)
- && !nic_already_init (pheader->nic_name))
+ && !nic_already_init (pheader->nic_name)
+ && strncmp (tmp->nic_type_name, "vhost", strlen ("vhost")))
{
NSOPR_LOGERR ("Invalid configuration %s not exist Error! ",
pheader->nic_name);
@@ -584,7 +585,7 @@ parse_network_obj (struct json_object *network_obj)
NULL, *type_name_obj = NULL;
struct json_object *ref_nic_list_obj = NULL, *bond_mode_obj =
NULL, *bond_name_obj = NULL, *ipam_obj = NULL;
- struct json_object *subnet_obj = NULL;
+ struct json_object *subnet_obj = NULL, *nic_type_obj = NULL;
if (!network_obj)
{
@@ -687,6 +688,44 @@ parse_network_obj (struct json_object *network_obj)
goto RETURN_ERROR;
}
+ json_object_object_get_ex (phy_obj, "nic_type", &nic_type_obj); /*lint !e534 no need to check return value */
+ if (nic_type_obj)
+ {
+ const char *nic_type_name =
+ json_object_get_string (nic_type_obj);
+ if (strcmp (nic_type_name, "pci") != 0
+ && strcmp (nic_type_name, "vhost") != 0)
+ {
+ NSOPR_LOGERR ("unsupported nic_type]nic_type=%s",
+ nic_type_name);
+ goto RETURN_ERROR;
+ }
+
+ retVal =
+ STRCPY_S (pst_network_configuration->nic_type_name,
+ sizeof (pst_network_configuration->nic_type_name),
+ nic_type_name);
+ if (EOK != retVal)
+ {
+ NSOPR_LOGERR ("strcpy_s failed]ret=%d", retVal);
+ goto RETURN_ERROR;
+ }
+ }
+ else
+ {
+ NSOPR_LOGINF
+ ("nic_type not specified, use default type]defaul nic_type=pci");
+ retVal =
+ STRCPY_S (pst_network_configuration->nic_type_name,
+ sizeof (pst_network_configuration->nic_type_name),
+ "pci");
+ if (EOK != retVal)
+ {
+ NSOPR_LOGERR ("strcpy_s failed]ret=%d", retVal);
+ goto RETURN_ERROR;
+ }
+ }
+
json_object_object_get_ex (phy_obj, "ref_nic", &ref_nic_list_obj);
if (ref_nic_list_obj)
{
diff --git a/stacks/lwip_stack/lwip_src/netif/spl_hal.c b/stacks/lwip_stack/lwip_src/netif/spl_hal.c
index 596962e..db843d4 100644
--- a/stacks/lwip_stack/lwip_src/netif/spl_hal.c
+++ b/stacks/lwip_stack/lwip_src/netif/spl_hal.c
@@ -962,6 +962,23 @@ spl_hal_port_config (unsigned int *port_num)
NSPOL_LOGINF (SC_DPDK_INFO, "if_name %s",
p_stackx_port_zone->
stackx_one_port[port_index].linux_ip.if_name);
+
+ retVal =
+ STRCPY_S (p_stackx_port_zone->
+ stackx_one_port[port_index].linux_ip.if_type,
+ sizeof (p_stackx_port_zone->
+ stackx_one_port[port_index].linux_ip.if_type),
+ network->nic_type_name);
+ if (EOK != retVal)
+ {
+ NSPOL_LOGERR ("strcpy_s failed]ret=%d.", retVal);
+ return -1;
+ }
+
+ NSPOL_LOGINF (SC_DPDK_INFO, "if_type %s",
+ p_stackx_port_zone->
+ stackx_one_port[port_index].linux_ip.if_type);
+
retVal =
STRCPY_S (p_stackx_port_zone->
stackx_one_port[port_index].linux_ip.ip_addr_linux,
@@ -1286,7 +1303,9 @@ spl_hal_port_start (uint16_t nic_id, struct stackx_port_info *p_port_info,
conf.tx.ring_size[q] = HAL_TX_RING_SIZE;
}
- hdl = hal_create (p_port_info->linux_ip.if_name, &conf);
+ hdl =
+ hal_create (p_port_info->linux_ip.if_name, p_port_info->linux_ip.if_type,
+ &conf);
if (!hal_is_valid (hdl))
{