aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-06-06 14:23:42 +0200
committerMarco Varlese <marco.varlese@suse.de>2018-06-07 05:48:49 +0000
commit0e969ac8431c80ff4bca5f6985876b1c584eefcd (patch)
tree3860c4273c016bd23f2fa1e5cd51f854999c1274 /src
parentd018870d1b02109fc8b328446f15312fdd2fcd11 (diff)
Add support for DPDK 18.05
Change-Id: I205932bc727c990011bbbe1dc6c0cf5349d19806 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/dpdk/buffer.c33
-rw-r--r--src/plugins/dpdk/device/cli.c54
-rw-r--r--src/plugins/dpdk/device/format.c20
-rw-r--r--src/plugins/dpdk/device/init.c46
-rw-r--r--src/plugins/dpdk/ipsec/ipsec.c10
5 files changed, 119 insertions, 44 deletions
diff --git a/src/plugins/dpdk/buffer.c b/src/plugins/dpdk/buffer.c
index 31e8eee25a9..6afd20e06fe 100644
--- a/src/plugins/dpdk/buffer.c
+++ b/src/plugins/dpdk/buffer.c
@@ -463,22 +463,26 @@ dpdk_pool_create (vlib_main_t * vm, u8 * pool_name, u32 elt_size,
clib_error_t *error = 0;
u32 size, obj_size;
i32 ret;
+ uword i;
obj_size = rte_mempool_calc_obj_size (elt_size, 0, 0);
+
+#if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0)
size = rte_mempool_xmem_size (num_elts, obj_size, 21, 0);
+#else
+ size = rte_mempool_calc_mem_size_helper (num_elts, obj_size, 21);
+#endif
- error =
- vlib_physmem_region_alloc (vm, (char *) pool_name, size, numa,
- VLIB_PHYSMEM_F_HUGETLB | VLIB_PHYSMEM_F_SHARED,
- pri);
+ error = vlib_physmem_region_alloc (vm, (char *) pool_name, size, numa,
+ VLIB_PHYSMEM_F_HUGETLB |
+ VLIB_PHYSMEM_F_SHARED, pri);
if (error)
return error;
pr = vlib_physmem_get_region (vm, pri[0]);
- mp =
- rte_mempool_create_empty ((char *) pool_name, num_elts, elt_size,
- 512, pool_priv_size, numa, 0);
+ mp = rte_mempool_create_empty ((char *) pool_name, num_elts, elt_size,
+ 512, pool_priv_size, numa, 0);
if (!mp)
return clib_error_return (0, "failed to create %s", pool_name);
@@ -490,13 +494,16 @@ dpdk_pool_create (vlib_main_t * vm, u8 * pool_name, u32 elt_size,
priv.mbp_priv.mbuf_priv_size = VLIB_BUFFER_HDR_SIZE;
rte_pktmbuf_pool_init (mp, &priv);
- ret =
- rte_mempool_populate_iova_tab (mp, pr->mem, pr->page_table, pr->n_pages,
- pr->log2_page_size, NULL, NULL);
- if (ret != (i32) mp->size)
+ for (i = 0; i < pr->n_pages; i++)
{
- rte_mempool_free (mp);
- return clib_error_return (0, "failed to populate %s", pool_name);
+ size_t page_size = 1 << pr->log2_page_size;
+ ret = rte_mempool_populate_iova (mp, ((char *) pr->mem) + i * page_size,
+ pr->page_table[i], page_size, 0, 0);
+ if (ret < 0)
+ {
+ rte_mempool_free (mp);
+ return clib_error_return (0, "failed to populate %s", pool_name);
+ }
}
_mp[0] = mp;
diff --git a/src/plugins/dpdk/device/cli.c b/src/plugins/dpdk/device/cli.c
index 25308588469..2a49771ef26 100644
--- a/src/plugins/dpdk/device/cli.c
+++ b/src/plugins/dpdk/device/cli.c
@@ -46,6 +46,7 @@ get_hqos (u32 hw_if_index, u32 subport_id, dpdk_device_t ** xd,
dpdk_main_t *dm = &dpdk_main;
vnet_hw_interface_t *hw;
struct rte_eth_dev_info dev_info;
+ struct rte_pci_device *pci_dev;
uword *p = 0;
clib_error_t *error = NULL;
@@ -66,14 +67,21 @@ get_hqos (u32 hw_if_index, u32 subport_id, dpdk_device_t ** xd,
*xd = vec_elt_at_index (dm->devices, hw->dev_instance);
rte_eth_dev_info_get ((*xd)->port_id, &dev_info);
- if (dev_info.pci_dev)
+
+#if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0)
+ pci_dev = dev_info.pci_dev;
+#else
+ pci_dev = RTE_DEV_TO_PCI (dev_info.device);
+#endif
+
+ if (pci_dev)
{ /* bonded interface has no pci info */
vlib_pci_addr_t pci_addr;
- pci_addr.domain = dev_info.pci_dev->addr.domain;
- pci_addr.bus = dev_info.pci_dev->addr.bus;
- pci_addr.slot = dev_info.pci_dev->addr.devid;
- pci_addr.function = dev_info.pci_dev->addr.function;
+ pci_addr.domain = pci_dev->addr.domain;
+ pci_addr.bus = pci_dev->addr.bus;
+ pci_addr.slot = pci_dev->addr.devid;
+ pci_addr.function = pci_dev->addr.function;
p =
hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32);
@@ -1218,6 +1226,7 @@ set_dpdk_if_hqos_pktfield (vlib_main_t * vm, unformat_input_t * input,
/* Device specific data */
struct rte_eth_dev_info dev_info;
+ struct rte_pci_device *pci_dev;
dpdk_device_config_t *devconf = 0;
vnet_hw_interface_t *hw;
dpdk_device_t *xd;
@@ -1284,14 +1293,21 @@ set_dpdk_if_hqos_pktfield (vlib_main_t * vm, unformat_input_t * input,
xd = vec_elt_at_index (dm->devices, hw->dev_instance);
rte_eth_dev_info_get (xd->port_id, &dev_info);
- if (dev_info.pci_dev)
+
+#if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0)
+ pci_dev = dev_info.pci_dev;
+#else
+ pci_dev = RTE_DEV_TO_PCI (dev_info.device);
+#endif
+
+ if (pci_dev)
{ /* bonded interface has no pci info */
vlib_pci_addr_t pci_addr;
- pci_addr.domain = dev_info.pci_dev->addr.domain;
- pci_addr.bus = dev_info.pci_dev->addr.bus;
- pci_addr.slot = dev_info.pci_dev->addr.devid;
- pci_addr.function = dev_info.pci_dev->addr.function;
+ pci_addr.domain = pci_dev->addr.domain;
+ pci_addr.bus = pci_dev->addr.bus;
+ pci_addr.slot = pci_dev->addr.devid;
+ pci_addr.function = pci_dev->addr.function;
p =
hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32);
@@ -1443,6 +1459,7 @@ show_dpdk_if_hqos (vlib_main_t * vm, unformat_input_t * input,
u32 hw_if_index = (u32) ~ 0;
u32 profile_id, subport_id, i;
struct rte_eth_dev_info dev_info;
+ struct rte_pci_device *pci_dev;
dpdk_device_config_t *devconf = 0;
vlib_thread_registration_t *tr;
uword *p = 0;
@@ -1475,14 +1492,21 @@ show_dpdk_if_hqos (vlib_main_t * vm, unformat_input_t * input,
xd = vec_elt_at_index (dm->devices, hw->dev_instance);
rte_eth_dev_info_get (xd->port_id, &dev_info);
- if (dev_info.pci_dev)
+
+#if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0)
+ pci_dev = dev_info.pci_dev;
+#else
+ pci_dev = RTE_DEV_TO_PCI (dev_info.device);
+#endif
+
+ if (pci_dev)
{ /* bonded interface has no pci info */
vlib_pci_addr_t pci_addr;
- pci_addr.domain = dev_info.pci_dev->addr.domain;
- pci_addr.bus = dev_info.pci_dev->addr.bus;
- pci_addr.slot = dev_info.pci_dev->addr.devid;
- pci_addr.function = dev_info.pci_dev->addr.function;
+ pci_addr.domain = pci_dev->addr.domain;
+ pci_addr.bus = pci_dev->addr.bus;
+ pci_addr.slot = pci_dev->addr.devid;
+ pci_addr.function = pci_dev->addr.function;
p =
hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32);
diff --git a/src/plugins/dpdk/device/format.c b/src/plugins/dpdk/device/format.c
index f10b00e27a6..4b8e3be5240 100644
--- a/src/plugins/dpdk/device/format.c
+++ b/src/plugins/dpdk/device/format.c
@@ -163,6 +163,7 @@ format_dpdk_device_name (u8 * s, va_list * args)
char *device_name;
u32 i = va_arg (*args, u32);
struct rte_eth_dev_info dev_info;
+ struct rte_pci_device *pci_dev;
u8 *ret;
if (dm->conf->interface_name_format_decimal)
@@ -246,12 +247,15 @@ format_dpdk_device_name (u8 * s, va_list * args)
}
rte_eth_dev_info_get (i, &dev_info);
-
- if (dev_info.pci_dev &&
- dm->devices[i].port_type != VNET_DPDK_PORT_TYPE_FAILSAFE)
- ret = format (s, devname_format, device_name, dev_info.pci_dev->addr.bus,
- dev_info.pci_dev->addr.devid,
- dev_info.pci_dev->addr.function);
+#if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0)
+ pci_dev = dev_info.pci_dev;
+#else
+ pci_dev = RTE_DEV_TO_PCI (dev_info.device);
+#endif
+
+ if (pci_dev && dm->devices[i].port_type != VNET_DPDK_PORT_TYPE_FAILSAFE)
+ ret = format (s, devname_format, device_name, pci_dev->addr.bus,
+ pci_dev->addr.devid, pci_dev->addr.function);
else
ret = format (s, "%s%d", device_name, dm->devices[i].port_id);
@@ -507,7 +511,11 @@ format_dpdk_device (u8 * s, va_list * args)
retval = rte_eth_dev_rss_hash_conf_get (xd->port_id, &rss_conf);
if (retval < 0)
clib_warning ("rte_eth_dev_rss_hash_conf_get returned %d", retval);
+#if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0)
pci = di.pci_dev;
+#else
+ pci = RTE_DEV_TO_PCI (di.device);
+#endif
if (pci)
s =
diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c
index ceaa5bb61e9..2232b89e1b3 100644
--- a/src/plugins/dpdk/device/init.c
+++ b/src/plugins/dpdk/device/init.c
@@ -227,7 +227,12 @@ dpdk_lib_init (dpdk_main_t * dm)
vec_validate_aligned (dm->devices_by_hqos_cpu, tm->n_vlib_mains - 1,
CLIB_CACHE_LINE_BYTES);
+#if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0)
nports = rte_eth_dev_count ();
+#else
+ nports = rte_eth_dev_count_avail ();
+#endif
+
if (nports < 1)
{
dpdk_log_notice ("DPDK drivers found no ports...");
@@ -260,19 +265,36 @@ dpdk_lib_init (dpdk_main_t * dm)
u8 addr[6];
u8 vlan_strip = 0;
struct rte_eth_dev_info dev_info;
+ struct rte_pci_device *pci_dev;
struct rte_eth_link l;
dpdk_device_config_t *devconf = 0;
vlib_pci_addr_t pci_addr;
uword *p = 0;
+ if (!rte_eth_dev_is_valid_port(i))
+ continue;
+
rte_eth_link_get_nowait (i, &l);
rte_eth_dev_info_get (i, &dev_info);
- if (dev_info.pci_dev) /* bonded interface has no pci info */
+
+#if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0)
+ pci_dev = dev_info.pci_dev;
+#else
+ if (dev_info.device == 0)
+ {
+ clib_warning ("DPDK bug: missing device info. Skipping %s device",
+ dev_info.driver_name);
+ continue;
+ }
+ pci_dev = RTE_DEV_TO_PCI (dev_info.device);
+#endif
+
+ if (pci_dev) /* bonded interface has no pci info */
{
- pci_addr.domain = dev_info.pci_dev->addr.domain;
- pci_addr.bus = dev_info.pci_dev->addr.bus;
- pci_addr.slot = dev_info.pci_dev->addr.devid;
- pci_addr.function = dev_info.pci_dev->addr.function;
+ pci_addr.domain = pci_dev->addr.domain;
+ pci_addr.bus = pci_dev->addr.bus;
+ pci_addr.slot = pci_dev->addr.devid;
+ pci_addr.function = pci_dev->addr.function;
p =
hash_get (dm->conf->device_config_index_by_pci_addr,
pci_addr.as_u32);
@@ -290,12 +312,12 @@ dpdk_lib_init (dpdk_main_t * dm)
xd->cpu_socket = (i8) rte_eth_dev_socket_id (i);
/* Handle interface naming for devices with multiple ports sharing same PCI ID */
- if (dev_info.pci_dev)
+ if (pci_dev)
{
struct rte_eth_dev_info di = { 0 };
rte_eth_dev_info_get (i + 1, &di);
- if (di.pci_dev && pci_addr.as_u32 != last_pci_addr.as_u32 &&
- memcmp (&dev_info.pci_dev->addr, &di.pci_dev->addr,
+ if (pci_dev && pci_addr.as_u32 != last_pci_addr.as_u32 &&
+ memcmp (&pci_dev->addr, &pci_dev->addr,
sizeof (struct rte_pci_addr)) == 0)
{
xd->interface_name_suffix = format (0, "0");
@@ -358,8 +380,8 @@ dpdk_lib_init (dpdk_main_t * dm)
xd->flags |= DPDK_DEVICE_FLAG_PMD;
/* workaround for drivers not setting driver_name */
- if ((!dev_info.driver_name) && (dev_info.pci_dev))
- dev_info.driver_name = dev_info.pci_dev->driver->driver.name;
+ if ((!dev_info.driver_name) && (pci_dev))
+ dev_info.driver_name = pci_dev->driver->driver.name;
ASSERT (dev_info.driver_name);
@@ -1533,7 +1555,11 @@ dpdk_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
* 2. Set up info and register slave link state change callback handling.
* 3. Set up info for bond interface related CLI support.
*/
+#if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0)
int nports = rte_eth_dev_count ();
+#else
+ int nports = rte_eth_dev_count_avail ();
+#endif
if (nports > 0)
{
/* *INDENT-OFF* */
diff --git a/src/plugins/dpdk/ipsec/ipsec.c b/src/plugins/dpdk/ipsec/ipsec.c
index 268f27be42f..731613b009c 100644
--- a/src/plugins/dpdk/ipsec/ipsec.c
+++ b/src/plugins/dpdk/ipsec/ipsec.c
@@ -873,7 +873,12 @@ crypto_create_session_h_pool (vlib_main_t * vm, u8 numa)
pool_name = format (0, "session_h_pool_numa%u%c", numa, 0);
+
+#if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0)
elt_size = rte_cryptodev_get_header_session_size ();
+#else
+ elt_size = rte_cryptodev_sym_get_header_session_size ();
+#endif
error =
dpdk_pool_create (vm, pool_name, elt_size, DPDK_CRYPTO_NB_SESS_OBJS,
@@ -912,7 +917,12 @@ crypto_create_session_drv_pool (vlib_main_t * vm, crypto_dev_t * dev)
return NULL;
pool_name = format (0, "session_drv%u_pool_numa%u%c", dev->drv_id, numa, 0);
+
+#if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0)
elt_size = rte_cryptodev_get_private_session_size (dev->id);
+#else
+ elt_size = rte_cryptodev_sym_get_private_session_size (dev->id);
+#endif
error =
dpdk_pool_create (vm, pool_name, elt_size, DPDK_CRYPTO_NB_SESS_OBJS,