git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
examples/l3fwd: support config file for LPM/FIB
[dpdk.git]
/
examples
/
ip_pipeline
/
kni.c
diff --git
a/examples/ip_pipeline/kni.c
b/examples/ip_pipeline/kni.c
index
ebc8c79
..
a2d3331
100644
(file)
--- a/
examples/ip_pipeline/kni.c
+++ b/
examples/ip_pipeline/kni.c
@@
-7,6
+7,7
@@
#include <rte_ethdev.h>
#include <rte_bus_pci.h>
#include <rte_ethdev.h>
#include <rte_bus_pci.h>
+#include <rte_string_fns.h>
#include "kni.h"
#include "mempool.h"
#include "kni.h"
#include "mempool.h"
@@
-23,7
+24,7
@@
kni_init(void)
{
TAILQ_INIT(&kni_list);
{
TAILQ_INIT(&kni_list);
-#ifdef RTE_LIB
RTE
_KNI
+#ifdef RTE_LIB_KNI
rte_kni_init(KNI_MAX);
#endif
rte_kni_init(KNI_MAX);
#endif
@@
-45,7
+46,7
@@
kni_find(const char *name)
return NULL;
}
return NULL;
}
-#ifndef RTE_LIB
RTE
_KNI
+#ifndef RTE_LIB_KNI
struct kni *
kni_create(const char *name __rte_unused,
struct kni *
kni_create(const char *name __rte_unused,
@@
-67,7
+68,7
@@
kni_config_network_interface(uint16_t port_id, uint8_t if_up)
{
int ret = 0;
{
int ret = 0;
- if (
port_id >= rte_eth_dev_count(
))
+ if (
!rte_eth_dev_is_valid_port(port_id
))
return -EINVAL;
ret = (if_up) ?
return -EINVAL;
ret = (if_up) ?
@@
-82,10
+83,10
@@
kni_change_mtu(uint16_t port_id, unsigned int new_mtu)
{
int ret;
{
int ret;
- if (
port_id >= rte_eth_dev_count(
))
+ if (
!rte_eth_dev_is_valid_port(port_id
))
return -EINVAL;
return -EINVAL;
- if (new_mtu > ETHER_MAX_LEN)
+ if (new_mtu >
RTE_
ETHER_MAX_LEN)
return -EINVAL;
/* Set new MTU */
return -EINVAL;
/* Set new MTU */
@@
-106,6
+107,9
@@
kni_create(const char *name, struct kni_params *params)
struct mempool *mempool;
struct link *link;
struct rte_kni *k;
struct mempool *mempool;
struct link *link;
struct rte_kni *k;
+ const struct rte_pci_device *pci_dev;
+ const struct rte_bus *bus = NULL;
+ int ret;
/* Check input params */
if ((name == NULL) ||
/* Check input params */
if ((name == NULL) ||
@@
-120,16
+124,23
@@
kni_create(const char *name, struct kni_params *params)
return NULL;
/* Resource create */
return NULL;
/* Resource create */
- rte_eth_dev_info_get(link->port_id, &dev_info);
+ ret = rte_eth_dev_info_get(link->port_id, &dev_info);
+ if (ret != 0)
+ return NULL;
memset(&kni_conf, 0, sizeof(kni_conf));
memset(&kni_conf, 0, sizeof(kni_conf));
- s
nprintf(kni_conf.name, RTE_KNI_NAMESIZE, "%s", name
);
+ s
trlcpy(kni_conf.name, name, RTE_KNI_NAMESIZE
);
kni_conf.force_bind = params->force_bind;
kni_conf.core_id = params->thread_id;
kni_conf.group_id = link->port_id;
kni_conf.mbuf_size = mempool->buffer_size;
kni_conf.force_bind = params->force_bind;
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;
memset(&kni_ops, 0, sizeof(kni_ops));
kni_ops.port_id = link->port_id;
@@
-146,7
+157,7
@@
kni_create(const char *name, struct kni_params *params)
return NULL;
/* Node fill in */
return NULL;
/* Node fill in */
- str
n
cpy(kni->name, name, sizeof(kni->name));
+ str
l
cpy(kni->name, name, sizeof(kni->name));
kni->k = k;
/* Node add to list */
kni->k = k;
/* Node add to list */