X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=inline;f=examples%2Fip_pipeline%2Fkni.c;h=7e5ff0543a35339bccdb4b85545ba744b8c23c81;hb=e1e4dafbc7b83c695eb745fe033f5c1e9e344454;hp=ebc8c7904ef610ae17c63810bfbfdebfe8359885;hpb=9a408cc8acc8808e237dceae4bedb7d1b66d3e94;p=dpdk.git diff --git a/examples/ip_pipeline/kni.c b/examples/ip_pipeline/kni.c index ebc8c7904e..7e5ff0543a 100644 --- a/examples/ip_pipeline/kni.c +++ b/examples/ip_pipeline/kni.c @@ -7,6 +7,7 @@ #include #include +#include #include "kni.h" #include "mempool.h" @@ -67,7 +68,7 @@ kni_config_network_interface(uint16_t port_id, uint8_t if_up) { int ret = 0; - if (port_id >= rte_eth_dev_count()) + if (!rte_eth_dev_is_valid_port(port_id)) return -EINVAL; ret = (if_up) ? @@ -82,7 +83,7 @@ kni_change_mtu(uint16_t port_id, unsigned int new_mtu) { int ret; - if (port_id >= rte_eth_dev_count()) + if (!rte_eth_dev_is_valid_port(port_id)) return -EINVAL; if (new_mtu > ETHER_MAX_LEN) @@ -106,6 +107,8 @@ kni_create(const char *name, struct kni_params *params) struct mempool *mempool; struct link *link; struct rte_kni *k; + const struct rte_pci_device *pci_dev; + const struct rte_bus *bus = NULL; /* Check input params */ if ((name == NULL) || @@ -128,8 +131,13 @@ kni_create(const char *name, struct kni_params *params) kni_conf.core_id = params->thread_id; kni_conf.group_id = link->port_id; kni_conf.mbuf_size = mempool->buffer_size; - kni_conf.addr = dev_info.pci_dev->addr; - kni_conf.id = dev_info.pci_dev->id; + if (dev_info.device) + bus = rte_bus_find_by_device(dev_info.device); + if (bus && !strcmp(bus->name, "pci")) { + pci_dev = RTE_DEV_TO_PCI(dev_info.device); + kni_conf.addr = pci_dev->addr; + kni_conf.id = pci_dev->id; + } memset(&kni_ops, 0, sizeof(kni_ops)); kni_ops.port_id = link->port_id; @@ -146,7 +154,7 @@ kni_create(const char *name, struct kni_params *params) return NULL; /* Node fill in */ - strncpy(kni->name, name, sizeof(kni->name)); + strlcpy(kni->name, name, sizeof(kni->name)); kni->k = k; /* Node add to list */