diff options
author | rainbow_0206 <jiangwenjiang@huawei.com> | 2018-10-19 17:04:02 +0800 |
---|---|---|
committer | rainbow_0206 <jiangwenjiang@huawei.com> | 2018-10-29 17:03:49 +0800 |
commit | 4ed7096d4a4aff47a812a79252edd0834277ee30 (patch) | |
tree | b009b4341f123a69869b507504973a4ab42b7e7a /stacks/lwip_stack/src/io_adpt | |
parent | 0e8e4b657d5d388a6ac988b9da97f1f81740a0b0 (diff) |
Feat: support vhost-user in lwip stack
Change-Id: I6685fae6dafb4a4ac4f03bd868aa5ca636ce7054
Signed-off-by: rainbow_0206 <jiangwenjiang@huawei.com>
Diffstat (limited to 'stacks/lwip_stack/src/io_adpt')
-rw-r--r-- | stacks/lwip_stack/src/io_adpt/dpdk.c | 69 |
1 files changed, 68 insertions, 1 deletions
diff --git a/stacks/lwip_stack/src/io_adpt/dpdk.c b/stacks/lwip_stack/src/io_adpt/dpdk.c index d199513..8518112 100644 --- a/stacks/lwip_stack/src/io_adpt/dpdk.c +++ b/stacks/lwip_stack/src/io_adpt/dpdk.c @@ -190,6 +190,13 @@ NSTACK_STATIC struct rte_eth_conf port_conf_default_bond = { }, }; +NSTACK_STATIC struct rte_eth_conf port_conf_default_vhost = { + .rxmode = { + .hw_ip_checksum = 0, /* vhost nic doesn't support hw_ip_checksum and hw_vlan_filter */ + .hw_vlan_filter = 0, + } +}; + /***************************************************************************** * Prototype : dpdk_mbuf_to_file * Description : write the packet data into a file @@ -700,6 +707,39 @@ dpdk_set_port (netif_inst_t * inst, uint8_t port) } /***************************************************************************** + Prototype : dpdk_set_nic_type + Description : check and save nic type + Input : netif_inst_t* inst + const char* type + Output : None + Return Value : NSTACK_STATIC + Calls : + Called By : + +*****************************************************************************/ +NSTACK_STATIC int +dpdk_set_nic_type (netif_inst_t * inst, const char *type) +{ + int ret; + + ret = + STRCPY_S (inst->data.dpdk_if.nic_type, + sizeof (inst->data.dpdk_if.nic_type), type); + if (EOK != ret) + { + NSHAL_LOGERR ("strcpy_s set nic_type failed]ret=%d", ret); + return -1; + } + + /* + * *nic_type is first checked at read_ipmoduleoperateadd_configuration, + * *thus here we dont boring validating it once more and just return. + * */ + + return 0; +} + +/***************************************************************************** Prototype : dpdk_set_nic_name Description : check and save nic name Input : netif_inst_t* inst @@ -1433,10 +1473,25 @@ dpdk_probe_pci (netif_inst_t * inst) *****************************************************************************/ NSTACK_STATIC int -dpdk_open (netif_inst_t * inst, const char *name) +dpdk_open (netif_inst_t * inst, const char *name, const char *type) { int ret; + if ((inst == NULL) || (name == NULL) || (type == NULL)) + { + NSHAL_LOGERR + ("invaliad arguments]inst==NULL, nic_type==NULL or type==NULL"); + return -1; + } + + ret = dpdk_set_nic_type (inst, type); + + if (0 != ret) + { + NSHAL_LOGERR ("dpdk_set_nic_type fail]nic_type=%s, ret=%d", type, ret); + return -1; + } + ret = dpdk_set_nic_name (inst, name); if (0 != ret) @@ -1445,6 +1500,13 @@ dpdk_open (netif_inst_t * inst, const char *name) return -1; } + if (!strncmp (type, "vhost", strlen ("vhost"))) + { + /*for vhost-user device, the remaining steps is unnecessary, y0413485 */ + NSHAL_LOGERR ("initting vhost device]nic_name=%s type=%s", name, type); + return 0; + } + ret = dpdk_get_driver_name (inst); if (0 != ret) @@ -1588,6 +1650,11 @@ dpdk_get_port_conf (netif_inst_t * inst, struct rte_eth_conf **port_conf) { *port_conf = &port_conf_default_bond; } + else if (strncmp ("vhost", inst->data.dpdk_if.nic_type, (size_t) 5) == 0) + { + *port_conf = &port_conf_default_vhost; + return; + } else { *port_conf = &port_conf_default_normal; |