[dpdk-dev] [PATCH v2 5/5] Revert "bonding: use existing enslaved device queues"

2016-11-24 Thread Jan Blunck
From: Ilya Maximets <i.maxim...@samsung.com>

This reverts commit 5b7bb2bda5519b7800f814df64d4e015282140e5.

It is necessary to reconfigure all queues every time because configuration
can be changed.

For example, if we're reconfiguring bonding device with new memory pool,
already configured queues will still use the old one. And if the old
mempool be freed, application likely will panic in attempt to use
freed mempool.

This happens when we use the bonding device with OVS 2.6 while MTU
reconfiguration:

PANIC in rte_mempool_get_ops():
assert "(ops_index >= 0) && (ops_index < RTE_MEMPOOL_MAX_OPS_IDX)" failed

Cc: 
Signed-off-by: Ilya Maximets 
Acked-by: Declan Doherty 
Acked-by: Declan Doherty 
Acked-by: Jan Blunck 
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index e61afc9..b604642 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -1317,8 +1317,6 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
struct bond_rx_queue *bd_rx_q;
struct bond_tx_queue *bd_tx_q;

-   uint16_t old_nb_tx_queues = slave_eth_dev->data->nb_tx_queues;
-   uint16_t old_nb_rx_queues = slave_eth_dev->data->nb_rx_queues;
int errval;
uint16_t q_id;

@@ -1362,9 +1360,7 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
}

/* Setup Rx Queues */
-   /* Use existing queues, if any */
-   for (q_id = old_nb_rx_queues;
-q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
+   for (q_id = 0; q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
bd_rx_q = (struct bond_rx_queue 
*)bonded_eth_dev->data->rx_queues[q_id];

errval = rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, 
q_id,
@@ -1380,9 +1376,7 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
}

/* Setup Tx Queues */
-   /* Use existing queues, if any */
-   for (q_id = old_nb_tx_queues;
-q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
+   for (q_id = 0; q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
bd_tx_q = (struct bond_tx_queue 
*)bonded_eth_dev->data->tx_queues[q_id];

errval = rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, 
q_id,
-- 
2.7.4



[dpdk-dev] [PATCH v2 4/5] net/bonding: Force reconfiguration of removed slave interfaces

2016-11-24 Thread Jan Blunck
After a slave interface is removed from a bond group it still has the
configuration of the bond interface. Lets enforce that the slave interface
is reconfigured after removal by resetting it.

Signed-off-by: Jan Blunck 
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index a80b6fa..e61afc9 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -1454,6 +1454,9 @@ slave_remove(struct bond_dev_private *internals,
(internals->slave_count - i - 1));

internals->slave_count--;
+
+   /* force reconfiguration of slave interfaces */
+   _rte_eth_dev_reset(slave_eth_dev);
 }

 static void
-- 
2.7.4



[dpdk-dev] [PATCH v2 3/5] ethdev: Add DPDK internal _rte_eth_dev_reset()

2016-11-24 Thread Jan Blunck
This is a helper for DPDK internal users to force a reconfiguration of a
device.

Signed-off-by: Jan Blunck 
---
 lib/librte_ether/rte_ethdev.c  | 16 
 lib/librte_ether/rte_ethdev.h  | 13 +
 lib/librte_ether/rte_ether_version.map |  6 ++
 3 files changed, 35 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index a3986ad..9e69ee5 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -858,6 +858,22 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, 
uint16_t nb_tx_q,
return 0;
 }

+void
+_rte_eth_dev_reset(struct rte_eth_dev *dev)
+{
+   if (dev->data->dev_started) {
+   RTE_PMD_DEBUG_TRACE(
+   "port %d must be stopped to allow reset\n",
+   dev->data->port_id);
+   return;
+   }
+
+   rte_eth_dev_rx_queue_config(dev, 0);
+   rte_eth_dev_tx_queue_config(dev, 0);
+
+   memset(>data->dev_conf, 0, sizeof(dev->data->dev_conf));
+}
+
 static void
 rte_eth_dev_config_restore(uint8_t port_id)
 {
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 9678179..e0740db 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1914,6 +1914,19 @@ int rte_eth_dev_configure(uint8_t port_id, uint16_t 
nb_rx_queue,
uint16_t nb_tx_queue, const struct rte_eth_conf *eth_conf);

 /**
+ * @internal Release a devices rx/tx queues and clear its configuration to
+ * force the user application to reconfigure it. It is for DPDK internal user
+ * only.
+ *
+ * @param dev
+ *  Pointer to struct rte_eth_dev.
+ *
+ * @return
+ *  void
+ */
+void _rte_eth_dev_reset(struct rte_eth_dev *dev);
+
+/**
  * Allocate and set up a receive queue for an Ethernet device.
  *
  * The function allocates a contiguous block of memory for *nb_rx_desc*
diff --git a/lib/librte_ether/rte_ether_version.map 
b/lib/librte_ether/rte_ether_version.map
index 72be66d..0c31c5d 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -147,3 +147,9 @@ DPDK_16.11 {
rte_eth_dev_pci_remove;

 } DPDK_16.07;
+
+DPDK_17.02 {
+   global:
+
+   _rte_eth_dev_reset;
+} DPDK_16.11;
-- 
2.7.4



[dpdk-dev] [PATCH v2 2/5] ethdev: Free rx/tx_queues after releasing all queues

2016-11-24 Thread Jan Blunck
If all queues are released lets also free up the dev->data->rx/tx_queues
to be able to properly reinitialize.

Signed-off-by: Jan Blunck 
---
 lib/librte_ether/rte_ethdev.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 8c4b6cd..a3986ad 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -531,6 +531,9 @@ rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, 
uint16_t nb_queues)

for (i = nb_queues; i < old_nb_queues; i++)
(*dev->dev_ops->rx_queue_release)(rxq[i]);
+
+   rte_free(dev->data->rx_queues);
+   dev->data->rx_queues = NULL;
}
dev->data->nb_rx_queues = nb_queues;
return 0;
@@ -682,6 +685,9 @@ rte_eth_dev_tx_queue_config(struct rte_eth_dev *dev, 
uint16_t nb_queues)

for (i = nb_queues; i < old_nb_queues; i++)
(*dev->dev_ops->tx_queue_release)(txq[i]);
+
+   rte_free(dev->data->tx_queues);
+   dev->data->tx_queues = NULL;
}
dev->data->nb_tx_queues = nb_queues;
return 0;
-- 
2.7.4



[dpdk-dev] [PATCH v2 1/5] ethdev: Call rx/tx_queue_release before rx/tx_queue_setup

2016-11-24 Thread Jan Blunck
If a queue has been setup before lets release it before we setup.
Otherwise we might leak resources.

Signed-off-by: Jan Blunck 
---
 lib/librte_ether/rte_ethdev.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index fde8112..8c4b6cd 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1010,6 +1010,7 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t 
rx_queue_id,
uint32_t mbp_buf_size;
struct rte_eth_dev *dev;
struct rte_eth_dev_info dev_info;
+   void **rxq;

RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);

@@ -1068,6 +1069,14 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t 
rx_queue_id,
return -EINVAL;
}

+   rxq = dev->data->rx_queues;
+   if (rxq[rx_queue_id]) {
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release,
+   -ENOTSUP);
+   (*dev->dev_ops->rx_queue_release)(rxq[rx_queue_id]);
+   rxq[rx_queue_id] = NULL;
+   }
+
if (rx_conf == NULL)
rx_conf = _info.default_rxconf;

@@ -1089,6 +1098,7 @@ rte_eth_tx_queue_setup(uint8_t port_id, uint16_t 
tx_queue_id,
 {
struct rte_eth_dev *dev;
struct rte_eth_dev_info dev_info;
+   void **txq;

RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);

@@ -1121,6 +1131,14 @@ rte_eth_tx_queue_setup(uint8_t port_id, uint16_t 
tx_queue_id,
return -EINVAL;
}

+   txq = dev->data->tx_queues;
+   if (txq[tx_queue_id]) {
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_release,
+   -ENOTSUP);
+   (*dev->dev_ops->tx_queue_release)(txq[tx_queue_id]);
+   txq[tx_queue_id] = NULL;
+   }
+
if (tx_conf == NULL)
tx_conf = _info.default_txconf;

-- 
2.7.4



[dpdk-dev] [PATCH v2 0/5] bonding: setup all queues of slave devices

2016-11-24 Thread Jan Blunck
Prior to 16.11 some drivers (e.g. virtio) still had problems if their
queues where setup repeatedly. The bonding driver was working around the
problem by reusing already setup queues. This series of patches changes the
way how queue setup is done to give control to the driver to properly release
already initialized queues before they are setup again. Therefore the driver
call sequence is as if the number of queues is temporarily reduced before the
queues are setup again.

Ilya Maximets (1):
  Revert "bonding: use existing enslaved device queues"

Jan Blunck (4):
  ethdev: Call rx/tx_queue_release before rx/tx_queue_setup
  ethdev: Free rx/tx_queues after releasing all queues
  ethdev: Add DPDK internal _rte_eth_dev_reset()
  net/bonding: Force reconfiguration of removed slave interfaces

 drivers/net/bonding/rte_eth_bond_pmd.c | 13 +--
 lib/librte_ether/rte_ethdev.c  | 40 ++
 lib/librte_ether/rte_ethdev.h  | 13 +++
 lib/librte_ether/rte_ether_version.map |  6 +
 4 files changed, 64 insertions(+), 8 deletions(-)

-- 
2.7.4



[dpdk-dev] [PATCH 4/4] bond: Force reconfiguration of removed slave interfaces

2016-11-23 Thread Jan Blunck
After a slave interface is removed from a bond group it still has the
configuration of the bond interface. Lets enforce that the slave interface
is reconfigured after removal by resetting it.

Signed-off-by: Jan Blunck 
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index a80b6fa..e61afc9 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -1454,6 +1454,9 @@ slave_remove(struct bond_dev_private *internals,
(internals->slave_count - i - 1));

internals->slave_count--;
+
+   /* force reconfiguration of slave interfaces */
+   _rte_eth_dev_reset(slave_eth_dev);
 }

 static void
-- 
2.7.4



[dpdk-dev] [PATCH 3/4] ethdev: Add DPDK internal _rte_eth_dev_reset()

2016-11-23 Thread Jan Blunck
This is a helper for DPDK internal users to force a reconfiguration of a
device.

Signed-off-by: Jan Blunck 
---
 lib/librte_ether/rte_ethdev.c  | 15 +++
 lib/librte_ether/rte_ethdev.h  | 13 +
 lib/librte_ether/rte_ether_version.map |  6 ++
 3 files changed, 34 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index a3986ad..bd5787b 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -858,6 +858,21 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, 
uint16_t nb_tx_q,
return 0;
 }

+void
+_rte_eth_dev_reset(struct rte_eth_dev *dev)
+{
+   if (dev->data->dev_started) {
+   RTE_PMD_DEBUG_TRACE(
+   "port %d must be stopped to allow reset\n", port_id);
+   return;
+   }
+
+   rte_eth_dev_rx_queue_config(dev, 0);
+   rte_eth_dev_tx_queue_config(dev, 0);
+
+   memset(>data->dev_conf, 0, sizeof(dev->data->dev_conf));
+}
+
 static void
 rte_eth_dev_config_restore(uint8_t port_id)
 {
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 9678179..e0740db 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1914,6 +1914,19 @@ int rte_eth_dev_configure(uint8_t port_id, uint16_t 
nb_rx_queue,
uint16_t nb_tx_queue, const struct rte_eth_conf *eth_conf);

 /**
+ * @internal Release a devices rx/tx queues and clear its configuration to
+ * force the user application to reconfigure it. It is for DPDK internal user
+ * only.
+ *
+ * @param dev
+ *  Pointer to struct rte_eth_dev.
+ *
+ * @return
+ *  void
+ */
+void _rte_eth_dev_reset(struct rte_eth_dev *dev);
+
+/**
  * Allocate and set up a receive queue for an Ethernet device.
  *
  * The function allocates a contiguous block of memory for *nb_rx_desc*
diff --git a/lib/librte_ether/rte_ether_version.map 
b/lib/librte_ether/rte_ether_version.map
index 72be66d..0c31c5d 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -147,3 +147,9 @@ DPDK_16.11 {
rte_eth_dev_pci_remove;

 } DPDK_16.07;
+
+DPDK_17.02 {
+   global:
+
+   _rte_eth_dev_reset;
+} DPDK_16.11;
-- 
2.7.4



[dpdk-dev] [PATCH 2/4] ethdev: Free rx/tx_queues after releasing all queues

2016-11-23 Thread Jan Blunck
If all queues are released lets also free up the dev->data->rx/tx_queues
to be able to properly reinitialize.

Signed-off-by: Jan Blunck 
---
 lib/librte_ether/rte_ethdev.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 8c4b6cd..a3986ad 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -531,6 +531,9 @@ rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, 
uint16_t nb_queues)

for (i = nb_queues; i < old_nb_queues; i++)
(*dev->dev_ops->rx_queue_release)(rxq[i]);
+
+   rte_free(dev->data->rx_queues);
+   dev->data->rx_queues = NULL;
}
dev->data->nb_rx_queues = nb_queues;
return 0;
@@ -682,6 +685,9 @@ rte_eth_dev_tx_queue_config(struct rte_eth_dev *dev, 
uint16_t nb_queues)

for (i = nb_queues; i < old_nb_queues; i++)
(*dev->dev_ops->tx_queue_release)(txq[i]);
+
+   rte_free(dev->data->tx_queues);
+   dev->data->tx_queues = NULL;
}
dev->data->nb_tx_queues = nb_queues;
return 0;
-- 
2.7.4



[dpdk-dev] [PATCH 1/4] ethdev: Call rx/tx_queue_release before rx/tx_queue_setup

2016-11-23 Thread Jan Blunck
If a queue has been setup before lets release it before we setup.
Otherwise we might leak resources.

Signed-off-by: Jan Blunck 
---
 lib/librte_ether/rte_ethdev.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index fde8112..8c4b6cd 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1010,6 +1010,7 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t 
rx_queue_id,
uint32_t mbp_buf_size;
struct rte_eth_dev *dev;
struct rte_eth_dev_info dev_info;
+   void **rxq;

RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);

@@ -1068,6 +1069,14 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t 
rx_queue_id,
return -EINVAL;
}

+   rxq = dev->data->rx_queues;
+   if (rxq[rx_queue_id]) {
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release,
+   -ENOTSUP);
+   (*dev->dev_ops->rx_queue_release)(rxq[rx_queue_id]);
+   rxq[rx_queue_id] = NULL;
+   }
+
if (rx_conf == NULL)
rx_conf = _info.default_rxconf;

@@ -1089,6 +1098,7 @@ rte_eth_tx_queue_setup(uint8_t port_id, uint16_t 
tx_queue_id,
 {
struct rte_eth_dev *dev;
struct rte_eth_dev_info dev_info;
+   void **txq;

RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);

@@ -1121,6 +1131,14 @@ rte_eth_tx_queue_setup(uint8_t port_id, uint16_t 
tx_queue_id,
return -EINVAL;
}

+   txq = dev->data->tx_queues;
+   if (txq[tx_queue_id]) {
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_release,
+   -ENOTSUP);
+   (*dev->dev_ops->tx_queue_release)(txq[tx_queue_id]);
+   txq[tx_queue_id] = NULL;
+   }
+
if (tx_conf == NULL)
tx_conf = _info.default_txconf;

-- 
2.7.4



[dpdk-dev] [PATCH 2/7] eal: Helper to convert to struct rte_pci_device

2016-11-21 Thread Jan Blunck
On Sun, Nov 20, 2016 at 4:20 PM, David Marchand
 wrote:
> Hello Jan,
>
> On Sun, Nov 20, 2016 at 11:05 AM, Jan Blunck  wrote:
>> Signed-off-by: Jan Blunck 
>> ---
>>  lib/librte_eal/common/include/rte_pci.h | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/lib/librte_eal/common/include/rte_pci.h 
>> b/lib/librte_eal/common/include/rte_pci.h
>> index 9ce8847..0376160 100644
>> --- a/lib/librte_eal/common/include/rte_pci.h
>> +++ b/lib/librte_eal/common/include/rte_pci.h
>> @@ -160,6 +160,8 @@ struct rte_pci_device {
>> enum rte_kernel_driver kdrv;/**< Kernel driver 
>> passthrough */
>>  };
>>
>> +#define ETH_DEV_PCI_DEV(ptr) ((ptr)->pci_dev)
>> +
>>  /** Any PCI device identifier (vendor, device, ...) */
>>  #define PCI_ANY_ID (0x)
>>  #define RTE_CLASS_ANY_ID (0xff)
>
> This should come from ethdev, not eal.
>

Fixed in v2.

Thanks,
Jan


[dpdk-dev] [PATCH v2 8/8] ethdev: Decouple interrupt handling from PCI device

2016-11-21 Thread Jan Blunck
The struct rte_intr_handle is an abstraction layer for different types of
interrupt mechanisms. It is embedded in the low-level device (e.g. PCI).
On allocation of a struct rte_eth_dev a reference to the intr_handle
should be stored for devices supporting interrupts.

Signed-off-by: Jan Blunck 
---
 lib/librte_ether/rte_ethdev.c | 18 --
 lib/librte_ether/rte_ethdev.h |  1 +
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 4288577..4ecea50 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -258,6 +258,7 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
rte_panic("Cannot allocate memzone for private port 
data\n");
}
eth_dev->pci_dev = pci_dev;
+   eth_dev->intr_handle = _dev->intr_handle;
eth_dev->driver = eth_drv;
eth_dev->data->rx_mbuf_alloc_failed = 0;

@@ -2543,7 +2544,13 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int 
op, void *data)
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);

dev = _eth_devices[port_id];
-   intr_handle = >pci_dev->intr_handle;
+
+   if (!dev->intr_handle) {
+   RTE_PMD_DEBUG_TRACE("RX Intr handle unset\n");
+   return -ENOTSUP;
+   }
+
+   intr_handle = dev->intr_handle;
if (!intr_handle->intr_vec) {
RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n");
return -EPERM;
@@ -2603,7 +2610,12 @@ rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t 
queue_id,
return -EINVAL;
}

-   intr_handle = >pci_dev->intr_handle;
+   if (!dev->intr_handle) {
+   RTE_PMD_DEBUG_TRACE("RX Intr handle unset\n");
+   return -ENOTSUP;
+   }
+
+   intr_handle = dev->intr_handle;
if (!intr_handle->intr_vec) {
RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n");
return -EPERM;
@@ -3205,6 +3217,8 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct 
rte_pci_device *pci_de
return;
}

+   eth_dev->intr_handle = _dev->intr_handle;
+
eth_dev->data->dev_flags = 0;
if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 3adbb2b..f1f656a 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1629,6 +1629,7 @@ struct rte_eth_dev {
const struct eth_driver *driver;/**< Driver for this device */
const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */
struct rte_pci_device *pci_dev; /**< PCI info. supplied by probing */
+   struct rte_intr_handle *intr_handle; /**< Device interrupt handle */
/** User application callbacks for NIC interrupts */
struct rte_eth_dev_cb_list link_intr_cbs;
/**
-- 
2.7.4



[dpdk-dev] [PATCH v2 7/8] ethdev: Move filling of rte_eth_dev_info->pci_dev to dev_infos_get()

2016-11-21 Thread Jan Blunck
Only the device itself can decide its PCI or not.

Signed-off-by: Jan Blunck 
---
 drivers/net/bnx2x/bnx2x_ethdev.c| 1 +
 drivers/net/bnxt/bnxt_ethdev.c  | 2 ++
 drivers/net/cxgbe/cxgbe_ethdev.c| 2 ++
 drivers/net/e1000/em_ethdev.c   | 1 +
 drivers/net/e1000/igb_ethdev.c  | 2 ++
 drivers/net/ena/ena_ethdev.c| 2 ++
 drivers/net/enic/enic_ethdev.c  | 1 +
 drivers/net/fm10k/fm10k_ethdev.c| 1 +
 drivers/net/i40e/i40e_ethdev.c  | 1 +
 drivers/net/i40e/i40e_ethdev_vf.c   | 1 +
 drivers/net/ixgbe/ixgbe_ethdev.c| 2 ++
 drivers/net/mlx4/mlx4.c | 2 ++
 drivers/net/mlx5/mlx5_ethdev.c  | 2 ++
 drivers/net/nfp/nfp_net.c   | 1 +
 drivers/net/qede/qede_ethdev.c  | 1 +
 drivers/net/szedata2/rte_eth_szedata2.c | 1 +
 drivers/net/thunderx/nicvf_ethdev.c | 2 ++
 drivers/net/virtio/virtio_ethdev.c  | 1 +
 drivers/net/vmxnet3/vmxnet3_ethdev.c| 2 ++
 lib/librte_ether/rte_ethdev.c   | 1 -
 20 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index 0eae433..06453fe 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -431,6 +431,7 @@ static void
 bnx2x_dev_infos_get(struct rte_eth_dev *dev, __rte_unused struct 
rte_eth_dev_info *dev_info)
 {
struct bnx2x_softc *sc = dev->data->dev_private;
+   dev_info->pci_dev = ETH_DEV_PCI_DEV(dev);
dev_info->max_rx_queues  = sc->max_rx_queues;
dev_info->max_tx_queues  = sc->max_tx_queues;
dev_info->min_rx_bufsize = BNX2X_MIN_RX_BUF_SIZE;
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index cd50f11..bf39fbe 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -303,6 +303,8 @@ static void bnxt_dev_info_get_op(struct rte_eth_dev 
*eth_dev,
struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
uint16_t max_vnics, i, j, vpool, vrxq;

+   dev_info->pci_dev = ETH_DEV_PCI_DEV(eth_dev);
+
/* MAC Specifics */
dev_info->max_mac_addrs = MAX_NUM_MAC_ADDR;
dev_info->max_hash_mac_addrs = 0;
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 8bfdda8..8938b08 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -147,6 +147,8 @@ static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev,
.nb_align = 1,
};

+   device_info->pci_dev = ETH_DEV_PCI_DEV(eth_dev);
+
device_info->min_rx_bufsize = CXGBE_MIN_RX_BUFSIZE;
device_info->max_rx_pktlen = CXGBE_MAX_RX_PKTLEN;
device_info->max_rx_queues = max_queues;
diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index 7f2f521..3d34e5b 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -1048,6 +1048,7 @@ eth_em_infos_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
 {
struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);

+   dev_info->pci_dev = ETH_DEV_PCI_DEV(dev);
dev_info->min_rx_bufsize = 256; /* See BSIZE field of RCTL register. */
dev_info->max_rx_pktlen = em_get_max_pktlen(hw);
dev_info->max_mac_addrs = hw->mac.rar_entry_count;
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index b25c66e..7d77561 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -1983,6 +1983,7 @@ eth_igb_infos_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
 {
struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);

+   dev_info->pci_dev = ETH_DEV_PCI_DEV(dev);
dev_info->min_rx_bufsize = 256; /* See BSIZE field of RCTL register. */
dev_info->max_rx_pktlen  = 0x3FFF; /* See RLPML register. */
dev_info->max_mac_addrs = hw->mac.rar_entry_count;
@@ -2111,6 +2112,7 @@ eth_igbvf_infos_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
 {
struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);

+   dev_info->pci_dev = ETH_DEV_PCI_DEV(dev);
dev_info->min_rx_bufsize = 256; /* See BSIZE field of RCTL register. */
dev_info->max_rx_pktlen  = 0x3FFF; /* See RLPML register. */
dev_info->max_mac_addrs = hw->mac.rar_entry_count;
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index c17d969..051275e 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -1436,6 +1436,8 @@ static void ena_infos_get(struct rte_eth_dev *dev,
ena_dev = >ena_dev;
ena_assert_msg(ena_dev != NULL, "Uninitialized device");

+   dev_info->pci_dev = ETH_DEV_PCI_DEV(dev);
+
dev_info->s

[dpdk-dev] [PATCH v2 6/8] virtio: Don't depend on struct rte_eth_dev's pci_dev

2016-11-21 Thread Jan Blunck
We don't need to depend on rte_eth_dev->pci_dev to differentiate between
the virtio_user and the virtio_pci case. Instead we can use the private
virtio_hw struct to get that information.

Signed-off-by: Jan Blunck 
---
 drivers/net/virtio/virtio_ethdev.c | 21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index da9668e..023101d 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -483,11 +483,11 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t 
vtpci_queue_idx)
hw->cvq = cvq;
}

-   /* For virtio_user case (that is when dev->pci_dev is NULL), we use
+   /* For virtio_user case (that is when hw->dev is NULL), we use
 * virtual address. And we need properly set _offset_, please see
 * VIRTIO_MBUF_DATA_DMA_ADDR in virtqueue.h for more information.
 */
-   if (dev->pci_dev)
+   if (hw->dev)
vq->offset = offsetof(struct rte_mbuf, buf_physaddr);
else {
vq->vq_ring_mem = (uintptr_t)mz->addr;
@@ -1190,7 +1190,7 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t 
req_features)
struct virtio_hw *hw = eth_dev->data->dev_private;
struct virtio_net_config *config;
struct virtio_net_config local_config;
-   struct rte_pci_device *pci_dev = eth_dev->pci_dev;
+   struct rte_pci_device *pci_dev = hw->dev;
int ret;

/* Reset the device although not necessary at startup */
@@ -1294,7 +1294,6 @@ int
 eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 {
struct virtio_hw *hw = eth_dev->data->dev_private;
-   struct rte_pci_device *pci_dev;
uint32_t dev_flags = RTE_ETH_DEV_DETACHABLE;
int ret;

@@ -1317,10 +1316,11 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
return -ENOMEM;
}

-   pci_dev = eth_dev->pci_dev;
-
-   if (pci_dev) {
-   ret = vtpci_init(pci_dev, hw, _flags);
+   /* For virtio_user case the hw->virtio_user_dev is populated by
+* virtio_user_eth_dev_alloc() before eth_virtio_dev_init() is called.
+*/
+   if (!hw->virtio_user_dev) {
+   ret = vtpci_init(ETH_DEV_PCI_DEV(eth_dev), hw, _flags);
if (ret)
return ret;
}
@@ -1343,7 +1343,6 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 static int
 eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
 {
-   struct rte_pci_device *pci_dev;
struct virtio_hw *hw = eth_dev->data->dev_private;

PMD_INIT_FUNC_TRACE();
@@ -1353,7 +1352,6 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)

virtio_dev_stop(eth_dev);
virtio_dev_close(eth_dev);
-   pci_dev = eth_dev->pci_dev;

eth_dev->dev_ops = NULL;
eth_dev->tx_pkt_burst = NULL;
@@ -1367,7 +1365,8 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
rte_intr_callback_unregister(vtpci_intr_handle(hw),
virtio_interrupt_handler,
eth_dev);
-   rte_eal_pci_unmap_device(pci_dev);
+   if (hw->dev)
+   rte_eal_pci_unmap_device(hw->dev);

PMD_INIT_LOG(DEBUG, "dev_uninit completed");

-- 
2.7.4



[dpdk-dev] [PATCH v2 5/8] virtio: Add vtpci_intr_handle() helper to get rte_intr_handle

2016-11-21 Thread Jan Blunck
This adds a helper to get the rte_intr_handle from the virtio_hw. This is
safe to do since the usage of the helper is guarded by RTE_ETH_DEV_INTR_LSC
which is only set if we found a PCI device during initialization.

Signed-off-by: Jan Blunck 
---
 drivers/net/virtio/virtio_ethdev.c | 12 +++-
 drivers/net/virtio/virtio_pci.h|  6 ++
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index 741688e..da9668e 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1162,7 +1162,7 @@ virtio_interrupt_handler(__rte_unused struct 
rte_intr_handle *handle,
isr = vtpci_isr(hw);
PMD_DRV_LOG(INFO, "interrupt status = %#x", isr);

-   if (rte_intr_enable(>pci_dev->intr_handle) < 0)
+   if (rte_intr_enable(vtpci_intr_handle(hw)) < 0)
PMD_DRV_LOG(ERR, "interrupt enable failed");

if (isr & VIRTIO_PCI_ISR_CONFIG) {
@@ -1334,7 +1334,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)

/* Setup interrupt callback  */
if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
-   rte_intr_callback_register(_dev->intr_handle,
+   rte_intr_callback_register(vtpci_intr_handle(hw),
virtio_interrupt_handler, eth_dev);

return 0;
@@ -1344,6 +1344,7 @@ static int
 eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
 {
struct rte_pci_device *pci_dev;
+   struct virtio_hw *hw = eth_dev->data->dev_private;

PMD_INIT_FUNC_TRACE();

@@ -1363,7 +1364,7 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)

/* reset interrupt callback  */
if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
-   rte_intr_callback_unregister(_dev->intr_handle,
+   rte_intr_callback_unregister(vtpci_intr_handle(hw),
virtio_interrupt_handler,
eth_dev);
rte_eal_pci_unmap_device(pci_dev);
@@ -1481,7 +1482,7 @@ virtio_dev_start(struct rte_eth_dev *dev)
return -ENOTSUP;
}

-   if (rte_intr_enable(>pci_dev->intr_handle) < 0) {
+   if (rte_intr_enable(vtpci_intr_handle(hw)) < 0) {
PMD_DRV_LOG(ERR, "interrupt enable failed");
return -EIO;
}
@@ -1573,12 +1574,13 @@ static void virtio_dev_free_mbufs(struct rte_eth_dev 
*dev)
 static void
 virtio_dev_stop(struct rte_eth_dev *dev)
 {
+   struct virtio_hw *hw = dev->data->dev_private;
struct rte_eth_link link;

PMD_INIT_LOG(DEBUG, "stop");

if (dev->data->dev_conf.intr_conf.lsc)
-   rte_intr_disable(>pci_dev->intr_handle);
+   rte_intr_disable(vtpci_intr_handle(hw));

memset(, 0, sizeof(link));
virtio_dev_atomic_write_link_status(dev, );
diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h
index de271bf..5373e39 100644
--- a/drivers/net/virtio/virtio_pci.h
+++ b/drivers/net/virtio/virtio_pci.h
@@ -317,4 +317,10 @@ uint8_t vtpci_isr(struct virtio_hw *);

 uint16_t vtpci_irq_config(struct virtio_hw *, uint16_t);

+static inline struct rte_intr_handle *
+vtpci_intr_handle(struct virtio_hw *hw)
+{
+   return hw->dev ? >dev->intr_handle : NULL;
+}
+
 #endif /* _VIRTIO_PCI_H_ */
-- 
2.7.4



[dpdk-dev] [PATCH v2 3/8] drivers: Use ETH_DEV_PCI_DEV() helper

2016-11-21 Thread Jan Blunck
The drivers should not directly access the rte_eth_dev->pci_dev but use
a macro instead. This is a preparation for replacing the pci_dev with
a struct rte_device member in the future.

Signed-off-by: Jan Blunck 
---
 drivers/net/bnxt/bnxt_ethdev.c   | 19 ++-
 drivers/net/bnxt/bnxt_ring.c | 11 +++---
 drivers/net/cxgbe/cxgbe_ethdev.c |  2 +-
 drivers/net/e1000/em_ethdev.c| 20 ++-
 drivers/net/e1000/igb_ethdev.c   | 50 +++
 drivers/net/e1000/igb_pf.c   |  3 +-
 drivers/net/ena/ena_ethdev.c |  2 +-
 drivers/net/enic/enic_ethdev.c   |  2 +-
 drivers/net/fm10k/fm10k_ethdev.c | 49 ++-
 drivers/net/i40e/i40e_ethdev.c   | 44 
 drivers/net/i40e/i40e_ethdev.h   |  4 +++
 drivers/net/i40e/i40e_ethdev_vf.c| 38 ++---
 drivers/net/ixgbe/ixgbe_ethdev.c | 65 +---
 drivers/net/ixgbe/ixgbe_pf.c |  2 +-
 drivers/net/qede/qede_ethdev.c   | 17 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c |  4 +--
 16 files changed, 185 insertions(+), 147 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 035fe07..cd50f11 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -743,6 +743,7 @@ static int bnxt_reta_query_op(struct rte_eth_dev *eth_dev,
 {
struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
struct bnxt_vnic_info *vnic = >vnic_info[0];
+   struct rte_pci_device *pci_dev = ETH_DEV_PCI_DEV(eth_dev);

/* Retrieve from the default VNIC */
if (!vnic)
@@ -759,7 +760,7 @@ static int bnxt_reta_query_op(struct rte_eth_dev *eth_dev,
/* EW - need to revisit here copying from u64 to u16 */
memcpy(reta_conf, vnic->rss_table, reta_size);

-   if (rte_intr_allow_others(_dev->pci_dev->intr_handle)) {
+   if (rte_intr_allow_others(_dev->intr_handle)) {
if (eth_dev->data->dev_conf.intr_conf.lsc != 0)
bnxt_dev_lsc_intr_setup(eth_dev);
}
@@ -1011,9 +1012,10 @@ static int bnxt_init_board(struct rte_eth_dev *eth_dev)
 {
int rc;
struct bnxt *bp = eth_dev->data->dev_private;
+   struct rte_pci_device *pci_dev = ETH_DEV_PCI_DEV(eth_dev);

/* enable device (incl. PCI PM wakeup), and bus-mastering */
-   if (!eth_dev->pci_dev->mem_resource[0].addr) {
+   if (!pci_dev->mem_resource[0].addr) {
RTE_LOG(ERR, PMD,
"Cannot find PCI device base address, aborting\n");
rc = -ENODEV;
@@ -1021,9 +1023,9 @@ static int bnxt_init_board(struct rte_eth_dev *eth_dev)
}

bp->eth_dev = eth_dev;
-   bp->pdev = eth_dev->pci_dev;
+   bp->pdev = pci_dev;

-   bp->bar0 = (void *)eth_dev->pci_dev->mem_resource[0].addr;
+   bp->bar0 = (void *)pci_dev->mem_resource[0].addr;
if (!bp->bar0) {
RTE_LOG(ERR, PMD, "Cannot map device registers, aborting\n");
rc = -ENOMEM;
@@ -1043,6 +1045,7 @@ static int bnxt_init_board(struct rte_eth_dev *eth_dev)
 static int
 bnxt_dev_init(struct rte_eth_dev *eth_dev)
 {
+   struct rte_pci_device *pci_dev = ETH_DEV_PCI_DEV(eth_dev);
static int version_printed;
struct bnxt *bp;
int rc;
@@ -1050,10 +1053,10 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
if (version_printed++ == 0)
RTE_LOG(INFO, PMD, "%s", bnxt_version);

-   rte_eth_copy_pci_info(eth_dev, eth_dev->pci_dev);
+   rte_eth_copy_pci_info(eth_dev, pci_dev);
bp = eth_dev->data->dev_private;

-   if (bnxt_vf_pciid(eth_dev->pci_dev->id.device_id))
+   if (bnxt_vf_pciid(pci_dev->id.device_id))
bp->flags |= BNXT_FLAG_VF;

rc = bnxt_init_board(eth_dev);
@@ -1121,8 +1124,8 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)

RTE_LOG(INFO, PMD,
DRV_MODULE_NAME " found at mem %" PRIx64 ", node addr %pM\n",
-   eth_dev->pci_dev->mem_resource[0].phys_addr,
-   eth_dev->pci_dev->mem_resource[0].addr);
+   pci_dev->mem_resource[0].phys_addr,
+   pci_dev->mem_resource[0].addr);

bp->dev_stopped = 0;

diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c
index 3f81ffc..6793d75 100644
--- a/drivers/net/bnxt/bnxt_ring.c
+++ b/drivers/net/bnxt/bnxt_ring.c
@@ -209,6 +209,7 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
  */
 int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 {
+   struct rte_pci_device *pci_dev = ETH_DEV_PCI_DEV(bp->eth_dev);
unsigned int i;
int rc = 0;

@@ -223,7 +224,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
if (rc)
  

[dpdk-dev] [PATCH v2 2/8] ethdev: Helper to convert to struct rte_pci_device

2016-11-21 Thread Jan Blunck
Signed-off-by: Jan Blunck 
---
 lib/librte_ether/rte_ethdev.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 9678179..3adbb2b 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1644,6 +1644,12 @@ struct rte_eth_dev {
uint8_t attached; /**< Flag indicating the port is attached */
 } __rte_cache_aligned;

+/**
+ * @internal
+ * Helper for drivers that need to convert from rte_eth_dev to rte_pci_device.
+ */
+#define ETH_DEV_PCI_DEV(ptr) ((ptr)->pci_dev)
+
 struct rte_eth_dev_sriov {
uint8_t active;   /**< SRIOV is active with 16, 32 or 64 
pools */
uint8_t nb_q_per_pool;/**< rx queue number per pool */
-- 
2.7.4



[dpdk-dev] [PATCH v2 1/8] eal: define container_of macro

2016-11-21 Thread Jan Blunck
This macro is based on Jan Viktorin's original patch but also checks the
type of the passed pointer against the type of the member.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
[jblunck at infradead.org: add type checking and __extension__]
Signed-off-by: Jan Blunck 
---
 lib/librte_eal/common/include/rte_common.h | 20 
 1 file changed, 20 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_common.h 
b/lib/librte_eal/common/include/rte_common.h
index db5ac91..8dda3e2 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -331,6 +331,26 @@ rte_bsf32(uint32_t v)
 #define offsetof(TYPE, MEMBER)  __builtin_offsetof (TYPE, MEMBER)
 #endif

+/**
+ * Return pointer to the wrapping struct instance.
+ *
+ * Example:
+ *
+ *  struct wrapper {
+ *  ...
+ *  struct child c;
+ *  ...
+ *  };
+ *
+ *  struct child *x = obtain(...);
+ *  struct wrapper *w = container_of(x, struct wrapper, c);
+ */
+#ifndef container_of
+#define container_of(ptr, type, member)__extension__ ({
\
+   typeof(((type *)0)->member) *_ptr = (ptr);  \
+   (type *)(((char *)_ptr) - offsetof(type, member)); })
+#endif
+
 #define _RTE_STR(x) #x
 /** Take a macro value and get a string version of it */
 #define RTE_STR(x) _RTE_STR(x)
-- 
2.7.4



[dpdk-dev] [RFC PATCH 0/6] Restructure EAL device model for bus support

2016-11-21 Thread Jan Blunck
On Mon, Nov 21, 2016 at 10:08 AM, Thomas Monjalon
 wrote:
> 2016-11-20 16:30, David Marchand:
>> For a first patchset, I would see:
>> - introduce the rte_bus object. In rte_eal_init, for each bus, we call
>> the scan method. Then, for each bus, we find the appropriate
>> rte_driver using the bus match method then call the probe method. If
>> the probe succeeds, the rte_device points to the associated
>> rte_driver,
>> - migrate the pci scan code to a pci bus (scan looks at sysfs for
>> linux / ioctl for bsd + devargs for blacklist / whitelist ?), match is
>> the same at what is done in rte_eal_pci_probe_one_driver() at the
>> moment,
>> - migrate the vdev init code to a vdev bus (scan looks at devargs):
>> this is new, we must create rte_device objects for vdev drivers to use
>> later
>
> I think it can be 3 patchsets.
> Who can work on the vdev part please?

I'll take a look.


[dpdk-dev] [PATCH 7/7] ethdev: Move filling of rte_eth_dev_info->pci_dev to dev_infos_get()

2016-11-20 Thread Jan Blunck
Only the device itself can decide its PCI or not.

Signed-off-by: Jan Blunck 
---
 drivers/net/bnx2x/bnx2x_ethdev.c| 1 +
 drivers/net/bnxt/bnxt_ethdev.c  | 2 ++
 drivers/net/cxgbe/cxgbe_ethdev.c| 2 ++
 drivers/net/e1000/em_ethdev.c   | 1 +
 drivers/net/e1000/igb_ethdev.c  | 2 ++
 drivers/net/ena/ena_ethdev.c| 2 ++
 drivers/net/enic/enic_ethdev.c  | 1 +
 drivers/net/fm10k/fm10k_ethdev.c| 1 +
 drivers/net/i40e/i40e_ethdev.c  | 1 +
 drivers/net/i40e/i40e_ethdev_vf.c   | 1 +
 drivers/net/ixgbe/ixgbe_ethdev.c| 2 ++
 drivers/net/mlx4/mlx4.c | 2 ++
 drivers/net/mlx5/mlx5_ethdev.c  | 2 ++
 drivers/net/nfp/nfp_net.c   | 1 +
 drivers/net/qede/qede_ethdev.c  | 1 +
 drivers/net/szedata2/rte_eth_szedata2.c | 1 +
 drivers/net/thunderx/nicvf_ethdev.c | 2 ++
 drivers/net/virtio/virtio_ethdev.c  | 1 +
 drivers/net/vmxnet3/vmxnet3_ethdev.c| 2 ++
 lib/librte_ether/rte_ethdev.c   | 1 -
 20 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index 0eae433..06453fe 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -431,6 +431,7 @@ static void
 bnx2x_dev_infos_get(struct rte_eth_dev *dev, __rte_unused struct 
rte_eth_dev_info *dev_info)
 {
struct bnx2x_softc *sc = dev->data->dev_private;
+   dev_info->pci_dev = ETH_DEV_PCI_DEV(dev);
dev_info->max_rx_queues  = sc->max_rx_queues;
dev_info->max_tx_queues  = sc->max_tx_queues;
dev_info->min_rx_bufsize = BNX2X_MIN_RX_BUF_SIZE;
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index cd50f11..bf39fbe 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -303,6 +303,8 @@ static void bnxt_dev_info_get_op(struct rte_eth_dev 
*eth_dev,
struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
uint16_t max_vnics, i, j, vpool, vrxq;

+   dev_info->pci_dev = ETH_DEV_PCI_DEV(eth_dev);
+
/* MAC Specifics */
dev_info->max_mac_addrs = MAX_NUM_MAC_ADDR;
dev_info->max_hash_mac_addrs = 0;
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 8bfdda8..8938b08 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -147,6 +147,8 @@ static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev,
.nb_align = 1,
};

+   device_info->pci_dev = ETH_DEV_PCI_DEV(eth_dev);
+
device_info->min_rx_bufsize = CXGBE_MIN_RX_BUFSIZE;
device_info->max_rx_pktlen = CXGBE_MAX_RX_PKTLEN;
device_info->max_rx_queues = max_queues;
diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index 7f2f521..3d34e5b 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -1048,6 +1048,7 @@ eth_em_infos_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
 {
struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);

+   dev_info->pci_dev = ETH_DEV_PCI_DEV(dev);
dev_info->min_rx_bufsize = 256; /* See BSIZE field of RCTL register. */
dev_info->max_rx_pktlen = em_get_max_pktlen(hw);
dev_info->max_mac_addrs = hw->mac.rar_entry_count;
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index b25c66e..7d77561 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -1983,6 +1983,7 @@ eth_igb_infos_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
 {
struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);

+   dev_info->pci_dev = ETH_DEV_PCI_DEV(dev);
dev_info->min_rx_bufsize = 256; /* See BSIZE field of RCTL register. */
dev_info->max_rx_pktlen  = 0x3FFF; /* See RLPML register. */
dev_info->max_mac_addrs = hw->mac.rar_entry_count;
@@ -2111,6 +2112,7 @@ eth_igbvf_infos_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
 {
struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);

+   dev_info->pci_dev = ETH_DEV_PCI_DEV(dev);
dev_info->min_rx_bufsize = 256; /* See BSIZE field of RCTL register. */
dev_info->max_rx_pktlen  = 0x3FFF; /* See RLPML register. */
dev_info->max_mac_addrs = hw->mac.rar_entry_count;
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index c17d969..051275e 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -1436,6 +1436,8 @@ static void ena_infos_get(struct rte_eth_dev *dev,
ena_dev = >ena_dev;
ena_assert_msg(ena_dev != NULL, "Uninitialized device");

+   dev_info->pci_dev = ETH_DEV_PCI_DEV(dev);
+
dev_info->s

[dpdk-dev] [PATCH 5/7] virtio: Add vtpci_intr_handle() helper to get rte_intr_handle

2016-11-20 Thread Jan Blunck
This adds a helper to get the rte_intr_handle from the virtio_hw. This is
safe to do since the usage of the helper is guarded by RTE_ETH_DEV_INTR_LSC
which is only set if we found a PCI device during initialization.

Signed-off-by: Jan Blunck 
---
 drivers/net/virtio/virtio_ethdev.c | 12 +++-
 drivers/net/virtio/virtio_pci.h|  6 ++
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index 741688e..da9668e 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1162,7 +1162,7 @@ virtio_interrupt_handler(__rte_unused struct 
rte_intr_handle *handle,
isr = vtpci_isr(hw);
PMD_DRV_LOG(INFO, "interrupt status = %#x", isr);

-   if (rte_intr_enable(>pci_dev->intr_handle) < 0)
+   if (rte_intr_enable(vtpci_intr_handle(hw)) < 0)
PMD_DRV_LOG(ERR, "interrupt enable failed");

if (isr & VIRTIO_PCI_ISR_CONFIG) {
@@ -1334,7 +1334,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)

/* Setup interrupt callback  */
if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
-   rte_intr_callback_register(_dev->intr_handle,
+   rte_intr_callback_register(vtpci_intr_handle(hw),
virtio_interrupt_handler, eth_dev);

return 0;
@@ -1344,6 +1344,7 @@ static int
 eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
 {
struct rte_pci_device *pci_dev;
+   struct virtio_hw *hw = eth_dev->data->dev_private;

PMD_INIT_FUNC_TRACE();

@@ -1363,7 +1364,7 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)

/* reset interrupt callback  */
if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
-   rte_intr_callback_unregister(_dev->intr_handle,
+   rte_intr_callback_unregister(vtpci_intr_handle(hw),
virtio_interrupt_handler,
eth_dev);
rte_eal_pci_unmap_device(pci_dev);
@@ -1481,7 +1482,7 @@ virtio_dev_start(struct rte_eth_dev *dev)
return -ENOTSUP;
}

-   if (rte_intr_enable(>pci_dev->intr_handle) < 0) {
+   if (rte_intr_enable(vtpci_intr_handle(hw)) < 0) {
PMD_DRV_LOG(ERR, "interrupt enable failed");
return -EIO;
}
@@ -1573,12 +1574,13 @@ static void virtio_dev_free_mbufs(struct rte_eth_dev 
*dev)
 static void
 virtio_dev_stop(struct rte_eth_dev *dev)
 {
+   struct virtio_hw *hw = dev->data->dev_private;
struct rte_eth_link link;

PMD_INIT_LOG(DEBUG, "stop");

if (dev->data->dev_conf.intr_conf.lsc)
-   rte_intr_disable(>pci_dev->intr_handle);
+   rte_intr_disable(vtpci_intr_handle(hw));

memset(, 0, sizeof(link));
virtio_dev_atomic_write_link_status(dev, );
diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h
index de271bf..5373e39 100644
--- a/drivers/net/virtio/virtio_pci.h
+++ b/drivers/net/virtio/virtio_pci.h
@@ -317,4 +317,10 @@ uint8_t vtpci_isr(struct virtio_hw *);

 uint16_t vtpci_irq_config(struct virtio_hw *, uint16_t);

+static inline struct rte_intr_handle *
+vtpci_intr_handle(struct virtio_hw *hw)
+{
+   return hw->dev ? >dev->intr_handle : NULL;
+}
+
 #endif /* _VIRTIO_PCI_H_ */
-- 
2.7.4



[dpdk-dev] [PATCH 4/7] virtio: Don't fill dev_info->driver_name

2016-11-20 Thread Jan Blunck
This is overwritten in rte_eth_dev_info_get().

Signed-off-by: Jan Blunck 
---
 drivers/net/virtio/virtio_ethdev.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index 079fd6c..741688e 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1624,10 +1624,6 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
uint64_t tso_mask;
struct virtio_hw *hw = dev->data->dev_private;

-   if (dev->pci_dev)
-   dev_info->driver_name = dev->driver->pci_drv.driver.name;
-   else
-   dev_info->driver_name = "virtio_user PMD";
dev_info->max_rx_queues =
RTE_MIN(hw->max_queue_pairs, VIRTIO_MAX_RX_QUEUES);
dev_info->max_tx_queues =
-- 
2.7.4



[dpdk-dev] [PATCH 3/7] drivers: Use ETH_DEV_PCI_DEV() helper

2016-11-20 Thread Jan Blunck
The drivers should not directly access the rte_eth_dev->pci_dev but use
a macro instead. This is a preparation for replacing the pci_dev with
a struct rte_device member in the future.

Signed-off-by: Jan Blunck 
---
 drivers/net/bnxt/bnxt_ethdev.c   | 19 ++-
 drivers/net/bnxt/bnxt_ring.c | 11 +++---
 drivers/net/cxgbe/cxgbe_ethdev.c |  2 +-
 drivers/net/e1000/em_ethdev.c| 20 ++-
 drivers/net/e1000/igb_ethdev.c   | 50 +++
 drivers/net/e1000/igb_pf.c   |  3 +-
 drivers/net/ena/ena_ethdev.c |  2 +-
 drivers/net/enic/enic_ethdev.c   |  2 +-
 drivers/net/fm10k/fm10k_ethdev.c | 49 ++-
 drivers/net/i40e/i40e_ethdev.c   | 44 
 drivers/net/i40e/i40e_ethdev.h   |  4 +++
 drivers/net/i40e/i40e_ethdev_vf.c| 38 ++---
 drivers/net/ixgbe/ixgbe_ethdev.c | 65 +---
 drivers/net/ixgbe/ixgbe_pf.c |  2 +-
 drivers/net/qede/qede_ethdev.c   | 17 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c |  4 +--
 16 files changed, 185 insertions(+), 147 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 035fe07..cd50f11 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -743,6 +743,7 @@ static int bnxt_reta_query_op(struct rte_eth_dev *eth_dev,
 {
struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
struct bnxt_vnic_info *vnic = >vnic_info[0];
+   struct rte_pci_device *pci_dev = ETH_DEV_PCI_DEV(eth_dev);

/* Retrieve from the default VNIC */
if (!vnic)
@@ -759,7 +760,7 @@ static int bnxt_reta_query_op(struct rte_eth_dev *eth_dev,
/* EW - need to revisit here copying from u64 to u16 */
memcpy(reta_conf, vnic->rss_table, reta_size);

-   if (rte_intr_allow_others(_dev->pci_dev->intr_handle)) {
+   if (rte_intr_allow_others(_dev->intr_handle)) {
if (eth_dev->data->dev_conf.intr_conf.lsc != 0)
bnxt_dev_lsc_intr_setup(eth_dev);
}
@@ -1011,9 +1012,10 @@ static int bnxt_init_board(struct rte_eth_dev *eth_dev)
 {
int rc;
struct bnxt *bp = eth_dev->data->dev_private;
+   struct rte_pci_device *pci_dev = ETH_DEV_PCI_DEV(eth_dev);

/* enable device (incl. PCI PM wakeup), and bus-mastering */
-   if (!eth_dev->pci_dev->mem_resource[0].addr) {
+   if (!pci_dev->mem_resource[0].addr) {
RTE_LOG(ERR, PMD,
"Cannot find PCI device base address, aborting\n");
rc = -ENODEV;
@@ -1021,9 +1023,9 @@ static int bnxt_init_board(struct rte_eth_dev *eth_dev)
}

bp->eth_dev = eth_dev;
-   bp->pdev = eth_dev->pci_dev;
+   bp->pdev = pci_dev;

-   bp->bar0 = (void *)eth_dev->pci_dev->mem_resource[0].addr;
+   bp->bar0 = (void *)pci_dev->mem_resource[0].addr;
if (!bp->bar0) {
RTE_LOG(ERR, PMD, "Cannot map device registers, aborting\n");
rc = -ENOMEM;
@@ -1043,6 +1045,7 @@ static int bnxt_init_board(struct rte_eth_dev *eth_dev)
 static int
 bnxt_dev_init(struct rte_eth_dev *eth_dev)
 {
+   struct rte_pci_device *pci_dev = ETH_DEV_PCI_DEV(eth_dev);
static int version_printed;
struct bnxt *bp;
int rc;
@@ -1050,10 +1053,10 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
if (version_printed++ == 0)
RTE_LOG(INFO, PMD, "%s", bnxt_version);

-   rte_eth_copy_pci_info(eth_dev, eth_dev->pci_dev);
+   rte_eth_copy_pci_info(eth_dev, pci_dev);
bp = eth_dev->data->dev_private;

-   if (bnxt_vf_pciid(eth_dev->pci_dev->id.device_id))
+   if (bnxt_vf_pciid(pci_dev->id.device_id))
bp->flags |= BNXT_FLAG_VF;

rc = bnxt_init_board(eth_dev);
@@ -1121,8 +1124,8 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)

RTE_LOG(INFO, PMD,
DRV_MODULE_NAME " found at mem %" PRIx64 ", node addr %pM\n",
-   eth_dev->pci_dev->mem_resource[0].phys_addr,
-   eth_dev->pci_dev->mem_resource[0].addr);
+   pci_dev->mem_resource[0].phys_addr,
+   pci_dev->mem_resource[0].addr);

bp->dev_stopped = 0;

diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c
index 3f81ffc..6793d75 100644
--- a/drivers/net/bnxt/bnxt_ring.c
+++ b/drivers/net/bnxt/bnxt_ring.c
@@ -209,6 +209,7 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
  */
 int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 {
+   struct rte_pci_device *pci_dev = ETH_DEV_PCI_DEV(bp->eth_dev);
unsigned int i;
int rc = 0;

@@ -223,7 +224,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
if (rc)
  

[dpdk-dev] [PATCH 2/7] eal: Helper to convert to struct rte_pci_device

2016-11-20 Thread Jan Blunck
Signed-off-by: Jan Blunck 
---
 lib/librte_eal/common/include/rte_pci.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_pci.h 
b/lib/librte_eal/common/include/rte_pci.h
index 9ce8847..0376160 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -160,6 +160,8 @@ struct rte_pci_device {
enum rte_kernel_driver kdrv;/**< Kernel driver passthrough 
*/
 };

+#define ETH_DEV_PCI_DEV(ptr) ((ptr)->pci_dev)
+
 /** Any PCI device identifier (vendor, device, ...) */
 #define PCI_ANY_ID (0x)
 #define RTE_CLASS_ANY_ID (0xff)
-- 
2.7.4



[dpdk-dev] [PATCH v2 2/2] Move non-PCI related eth_dev initialization to rte_eth_dev_allocate()

2016-11-17 Thread Jan Blunck
This moves the non-PCI related initialization of the link state interrupt
callback list and the setting of the default MTU to rte_eth_dev_allocate()
so that drivers only need to set non-default values.

Signed-off-by: Jan Blunck 
---
 app/test/virtual_pmd.c |  2 --
 drivers/net/bonding/rte_eth_bond_api.c |  2 --
 drivers/net/cxgbe/cxgbe_main.c |  2 --
 drivers/net/mlx4/mlx4.c|  2 --
 drivers/net/mlx5/mlx5.c|  3 ---
 drivers/net/null/rte_eth_null.c|  2 --
 drivers/net/ring/rte_eth_ring.c|  2 --
 drivers/net/vhost/rte_eth_vhost.c  |  2 --
 lib/librte_ether/rte_ethdev.c  | 11 +++
 9 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index 65b44c6..bd969f9 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -601,8 +601,6 @@ virtual_ethdev_create(const char *name, struct ether_addr 
*mac_addr,
eth_dev->data->nb_rx_queues = (uint16_t)1;
eth_dev->data->nb_tx_queues = (uint16_t)1;

-   TAILQ_INIT(&(eth_dev->link_intr_cbs));
-
eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
eth_dev->data->dev_link.link_speed = ETH_SPEED_NUM_10G;
eth_dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
diff --git a/drivers/net/bonding/rte_eth_bond_api.c 
b/drivers/net/bonding/rte_eth_bond_api.c
index ed75c28..19347d8 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -200,8 +200,6 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t 
socket_id)
eth_dev->data->nb_rx_queues = (uint16_t)1;
eth_dev->data->nb_tx_queues = (uint16_t)1;

-   TAILQ_INIT(&(eth_dev->link_intr_cbs));
-
eth_dev->data->mac_addrs = rte_zmalloc_socket(name, ETHER_ADDR_LEN, 0,
socket_id);
if (eth_dev->data->mac_addrs == NULL) {
diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c
index 922155b..9e8402b 100644
--- a/drivers/net/cxgbe/cxgbe_main.c
+++ b/drivers/net/cxgbe/cxgbe_main.c
@@ -1172,8 +1172,6 @@ int cxgbe_probe(struct adapter *adapter)

rte_eth_copy_pci_info(pi->eth_dev, pi->eth_dev->pci_dev);

-   TAILQ_INIT(>eth_dev->link_intr_cbs);
-
pi->eth_dev->data->mac_addrs = rte_zmalloc(name,
   ETHER_ADDR_LEN, 0);
if (!pi->eth_dev->data->mac_addrs) {
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index 9264242..d815a52 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -5834,7 +5834,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct 
rte_pci_device *pci_dev)
eth_dev->rx_pkt_burst = mlx4_rx_burst_secondary_setup;
} else {
eth_dev->data->dev_private = priv;
-   eth_dev->data->mtu = ETHER_MTU;
eth_dev->data->mac_addrs = priv->mac;
}
eth_dev->pci_dev = pci_dev;
@@ -5845,7 +5844,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct 
rte_pci_device *pci_dev)

priv->dev = eth_dev;
eth_dev->dev_ops = _dev_ops;
-   TAILQ_INIT(_dev->link_intr_cbs);

/* Bring Ethernet device up. */
DEBUG("forcing Ethernet interface up");
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index b57cad1..0e91f02 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -652,7 +652,6 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct 
rte_pci_device *pci_dev)
eth_dev->rx_pkt_burst = mlx5_rx_burst_secondary_setup;
} else {
eth_dev->data->dev_private = priv;
-   eth_dev->data->mtu = ETHER_MTU;
eth_dev->data->mac_addrs = priv->mac;
}

@@ -662,8 +661,6 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct 
rte_pci_device *pci_dev)
priv->dev = eth_dev;
eth_dev->dev_ops = _dev_ops;

-   TAILQ_INIT(_dev->link_intr_cbs);
-
/* Bring Ethernet device up. */
DEBUG("forcing Ethernet interface up");
priv_set_flags(priv, ~IFF_UP, IFF_UP);
diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 836d982..f09caf1 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -550,8 +550,6 @@ eth_dev_null_create(const char *name,
eth_dev->data = data;
eth_dev->dev_ops = 

-   TAILQ_INIT(_dev->link_intr_cbs);
-
eth_dev->driver = NULL;
data->dev_flags = R

[dpdk-dev] [PATCH v2 1/2] Clear eth_dev->data in rte_eth_dev_allocate()

2016-11-17 Thread Jan Blunck
Lets clear the eth_dev->data when allocating a new rte_eth_dev so that
drivers only need to set non-zero values.

Signed-off-by: Jan Blunck 
---
 drivers/net/bonding/rte_eth_bond_api.c | 7 ---
 drivers/net/mlx4/mlx4.c| 1 -
 drivers/net/mlx5/mlx5.c| 1 -
 drivers/net/mpipe/mpipe_tilegx.c   | 1 -
 lib/librte_ether/rte_ethdev.c  | 2 +-
 5 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_api.c 
b/drivers/net/bonding/rte_eth_bond_api.c
index 2a3893a..ed75c28 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -202,8 +202,6 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t 
socket_id)

TAILQ_INIT(&(eth_dev->link_intr_cbs));

-   eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
-
eth_dev->data->mac_addrs = rte_zmalloc_socket(name, ETHER_ADDR_LEN, 0,
socket_id);
if (eth_dev->data->mac_addrs == NULL) {
@@ -211,11 +209,6 @@ rte_eth_bond_create(const char *name, uint8_t mode, 
uint8_t socket_id)
goto err;
}

-   eth_dev->data->dev_started = 0;
-   eth_dev->data->promiscuous = 0;
-   eth_dev->data->scattered_rx = 0;
-   eth_dev->data->all_multicast = 0;
-
eth_dev->dev_ops = _dev_ops;
eth_dev->data->dev_flags = RTE_ETH_DEV_INTR_LSC |
RTE_ETH_DEV_DETACHABLE;
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index da61a85..9264242 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -5834,7 +5834,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct 
rte_pci_device *pci_dev)
eth_dev->rx_pkt_burst = mlx4_rx_burst_secondary_setup;
} else {
eth_dev->data->dev_private = priv;
-   eth_dev->data->rx_mbuf_alloc_failed = 0;
eth_dev->data->mtu = ETHER_MTU;
eth_dev->data->mac_addrs = priv->mac;
}
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 90cc35e..b57cad1 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -652,7 +652,6 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct 
rte_pci_device *pci_dev)
eth_dev->rx_pkt_burst = mlx5_rx_burst_secondary_setup;
} else {
eth_dev->data->dev_private = priv;
-   eth_dev->data->rx_mbuf_alloc_failed = 0;
eth_dev->data->mtu = ETHER_MTU;
eth_dev->data->mac_addrs = priv->mac;
}
diff --git a/drivers/net/mpipe/mpipe_tilegx.c b/drivers/net/mpipe/mpipe_tilegx.c
index f00..792ab56 100644
--- a/drivers/net/mpipe/mpipe_tilegx.c
+++ b/drivers/net/mpipe/mpipe_tilegx.c
@@ -1603,7 +1603,6 @@ rte_pmd_mpipe_probe(const char *ifname,
eth_dev->data->dev_private = priv;
eth_dev->data->mac_addrs = >mac_addr;

-   eth_dev->data->dev_flags = 0;
eth_dev->data->kdrv = RTE_KDRV_NONE;
eth_dev->driver = NULL;
eth_dev->data->drv_name = drivername;
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index fde8112..12af4b1 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -212,6 +212,7 @@ rte_eth_dev_allocate(const char *name)

eth_dev = _eth_devices[port_id];
eth_dev->data = _eth_dev_data[port_id];
+   memset(eth_dev->data, 0, sizeof(*eth_dev->data));
snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
eth_dev->data->port_id = port_id;
eth_dev->attached = DEV_ATTACHED;
@@ -259,7 +260,6 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
}
eth_dev->pci_dev = pci_dev;
eth_dev->driver = eth_drv;
-   eth_dev->data->rx_mbuf_alloc_failed = 0;

/* init user callbacks */
TAILQ_INIT(&(eth_dev->link_intr_cbs));
-- 
2.7.4



[dpdk-dev] [RFC PATCH 0/6] Restructure EAL device model for bus support

2016-11-17 Thread Jan Blunck
On Thu, Nov 17, 2016 at 2:08 PM, Shreyansh Jain  
wrote:
> On Thursday 17 November 2016 05:25 PM, Jan Blunck wrote:
>>
>> On Thu, Nov 17, 2016 at 6:29 AM, Shreyansh Jain 
>> wrote:
>>>
>>> DPDK has been inherently a PCI inclined framework. Because of this, the
>>> design of device tree (or list) within DPDK is also PCI inclined. A
>>> non-PCI
>>> device doesn't have a way of being expressed without using hooks started
>>> from
>>> EAL to PMD.
>>>
>>> With this cover letter, some patches are presented which try to break
>>> this
>>> strict linkage of EAL with PCI devices. Aim is to generalize the device
>>> hierarchy on the lines of how Linux handles it:
>>>
>>> device A1
>>>   |
>>>   +==.'==.+ Bus A.
>>>  |`--> driver A11 \
>>>   device A2`-> driver A12  \__
>>> |CPU |
>>> /`
>>> device A1  /
>>>   |   /
>>>   +==.'==.+ Bus A`
>>>  |`--> driver B11
>>>   device A2`-> driver B12
>>>
>>> Simply put:
>>>  - a bus is connect to CPU (or core)
>>>  - devices are conneted to Bus
>>>  - drivers are running instances which manage one or more devices
>>>  - bus is responsible for identifying devices (and interrupt propogation)
>>>  - driver is responsible for initializing the device
>>>
>>> (*Reusing text from email [1])
>>> In context of DPDK EAL:
>>>  - a generic bus (not a driver, not a device). I don't know how to
>>> categorize
>>>a bus. It is certainly not a device, and then handler for a bus
>>> (physical)
>>>can be considered a 'bus driver'. So, just 'rte_bus'.
>>>  - there is a bus for each physical implementation (or virtual). So, a
>>> rte_bus
>>>Object for PCI, VDEV, ABC, DEF and so on.
>>>  - Buses are registered just like a PMD - RTE_PMD_BUS_REGISTER()
>>>  - Each registered bus is part of a doubly list.
>>>-- Each device inherits rte_bus
>>>-- Each driver inherits rte_bus
>>>-- Device and Drivers lists are part of rte_bus
>>>  - eth_driver is no more required - it was just a holder for PMDs to
>>> register
>>>themselves. It can be replaced with rte_xxx_driver and corresponding
>>> init/
>>>uninit moved to rte_driver
>>>  - rte_eth_dev modified to disassociate itself from rte_pci_device and
>>> connect
>>>to generic rte_device
>>>
>>> Once again, improvising from [1]:
>>>
>>>   __ rte_bus_list
>>>  /
>>>  +--'---+
>>>  |rte_bus   |
>>>  | driver_list--> List of rte_bus specific
>>>  | device_listdevices
>>>  | scan | `-> List of rte_bus associated
>>>  | match| drivers
>>>  | dump |
>>>  | ..some refcnt| (#)
>>>  +--|--|+
>>>   _/\_
>>> +/+ +-\---+
>>> |rte_device   | |rte_driver   |
>>> | rte_bus | | rte_bus |
>>> | rte_driver  |(#)  | init|
>>> | | | uninit  |
>>> |  devargs| | dev_private_size|
>>> +---||+ | drv_flags   |(#)
>>> ||  | intr_handle(2*) |(#)
>>> | \ +--\\\+
>>> |  \_   \\\
>>> |\  |||
>>>  +--|-+ +|--+   |||
>>>  |rte_pci_device  | |rte_xxx_device | (4*)  |||
>>>  | PCI specific   | | xxx device|   |||
>>>  | info (mem,)| | specific fns  |  / | \
>>>  ++ 

[dpdk-dev] [PATCH 2/2] Move non-PCI related eth_dev initialization to rte_eth_dev_allocate()

2016-11-17 Thread Jan Blunck
On Thu, Nov 17, 2016 at 4:46 PM, Ferruh Yigit  wrote:
> On 11/17/2016 2:24 PM, Jan Blunck wrote:
>> This moves the non-PCI related initialization of the link state interrupt
>> callback list and the setting of the default MTU to rte_eth_dev_allocate()
>> so that drivers only need to set non-default values.
>>
>> Signed-off-by: Jan Blunck 
>> ---
>>  drivers/net/bonding/rte_eth_bond_api.c |  2 --
>>  drivers/net/cxgbe/cxgbe_main.c |  2 --
>>  drivers/net/mlx4/mlx4.c|  2 --
>>  drivers/net/mlx5/mlx5.c|  3 ---
>>  drivers/net/null/rte_eth_null.c|  2 --
>>  drivers/net/ring/rte_eth_ring.c|  2 --
>>  drivers/net/vhost/rte_eth_vhost.c  |  2 --
>>  lib/librte_ether/rte_ethdev.c  | 12 
>>  8 files changed, 4 insertions(+), 23 deletions(-)
>
> I think following also redundant and can be removed:
> app/test/virtual_pmd.c:
> 604:TAILQ_INIT(&(eth_dev->link_intr_cbs));
>
> <...>
>
>> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
>> index 12af4b1..f58a995 100644
>> --- a/lib/librte_ether/rte_ethdev.c
>> +++ b/lib/librte_ether/rte_ethdev.c
>
> What do you think doing same thing for rte_cryptodev.c J
>

Thanks for the review Ferruh. I'll fixup the patches and resend. I'm
currently looking in the rte_bus and rte_eth_dev stuff. If nobody
volunteers to do the changes for cryptodev I can take a look at some
later point.

Thanks,
Jan

>> @@ -215,6 +215,10 @@ rte_eth_dev_allocate(const char *name)
>>   memset(eth_dev->data, 0, sizeof(*eth_dev->data));
>>   snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
>>   eth_dev->data->port_id = port_id;
>> + eth_dev->data->rx_mbuf_alloc_failed = 0;
>
> This is no more required, because of memset
>
>> + eth_dev->data->mtu = ETHER_MTU;
>> + TAILQ_INIT(&(eth_dev->link_intr_cbs));
>> +
>>   eth_dev->attached = DEV_ATTACHED;
>>   eth_dev_last_created_port = port_id;
>>   nb_ports++;
>> @@ -261,14 +265,6 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
>>   eth_dev->pci_dev = pci_dev;
>>   eth_dev->driver = eth_drv;
>>
>> - /* init user callbacks */
>> - TAILQ_INIT(&(eth_dev->link_intr_cbs));
>> -
>> - /*
>> -  * Set the default MTU.
>> -  */
>> - eth_dev->data->mtu = ETHER_MTU;
>> -
>>   /* Invoke PMD device initialization function */
>>   diag = (*eth_drv->eth_dev_init)(eth_dev);
>>   if (diag == 0)
>>
>


[dpdk-dev] [RFC PATCH 2/6] eal: introduce bus-device-driver structure

2016-11-17 Thread Jan Blunck
On Thu, Nov 17, 2016 at 2:00 PM, Shreyansh Jain  
wrote:
>
> On Thursday 17 November 2016 04:49 PM, Jan Blunck wrote:
>>
>> On Thu, Nov 17, 2016 at 6:30 AM, Shreyansh Jain 
>> wrote:
>>>
>>> A device is connected to a bus and services by a driver associated with
>>> the bus. It is responsibility of the bus to identify the devices (scan)
>>> and then assign each device to a matching driver.
>>>
>>> A PMD would allocate a rte_xxx_driver and rte_xxx_device.
>>> rte_xxx_driver has rte_driver and rte_bus embedded. Similarly,
>>> rte_xxx_device
>>> has rte_device and rte_bus embedded.
>>
>>
>> I don't think so: the rte_xxx_device embeds the generic rte_device and
>> references a the rte_bus
>> that it is attached to.
>
>
> You mean?
>
>  struct rte_pci_device {
>struct rte_device device;
>struct rte_bus *bus;
>...
> }
>
> If yes then I have a different view.
> 'device' is connected to a bus. pci_device is just a type of device. Only
> way it should know about the bus is through the parent rte_device.
> rte_device can reference the bus.
>

No. Actually my English was bad. I meant that the rte_device
references the rte_bus but shouldn't embed it.

>
>>
>>> When a ethernet or crypto device (rte_eth_dev, rte_cryptodev) is
>>> allocated,
>>> it contains a reference of rte_device and rte_driver.
>>> Each ethernet device implementation would use container_of for finding
>>> the
>>> enclosing structure of rte_xxx_*.
>>>
>>> +---+
>>>  +--+   |rte_pci_device |
>>>  |rte_eth_dev   |   |+-+|
>>>  |++|   .>rte_device   ||
>>>  ||rte_device*-'|+-+|
>>>  |++|   ||rte_bus  ||
>>>  |  |   |+-+|
>>>  /  /   +---+
>>>
>>> Signed-off-by: Shreyansh Jain 
>>> ---
>>>  lib/librte_eal/common/include/rte_bus.h | 243
>>> 
>>>  lib/librte_eal/common/include/rte_dev.h |  36 ++---
>>>  2 files changed, 261 insertions(+), 18 deletions(-)
>>>  create mode 100644 lib/librte_eal/common/include/rte_bus.h
>>>
>>> diff --git a/lib/librte_eal/common/include/rte_bus.h
>>> b/lib/librte_eal/common/include/rte_bus.h
>>> new file mode 100644
>>> index 000..dc3aeb8
>>> --- /dev/null
>>> +++ b/lib/librte_eal/common/include/rte_bus.h
>>> @@ -0,0 +1,243 @@
>>> +/*-
>>> + *   BSD LICENSE
>>> + *
>>> + *   Copyright(c) 2016 NXP
>>> + *   All rights reserved.
>>> + *
>>> + *   Redistribution and use in source and binary forms, with or without
>>> + *   modification, are permitted provided that the following conditions
>>> + *   are met:
>>> + *
>>> + * * Redistributions of source code must retain the above copyright
>>> + *   notice, this list of conditions and the following disclaimer.
>>> + * * Redistributions in binary form must reproduce the above
>>> copyright
>>> + *   notice, this list of conditions and the following disclaimer in
>>> + *   the documentation and/or other materials provided with the
>>> + *   distribution.
>>> + * * Neither the name of NXP nor the names of its
>>> + *   contributors may be used to endorse or promote products derived
>>> + *   from this software without specific prior written permission.
>>> + *
>>> + *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
>>> + *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
>>> + *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
>>> FOR
>>> + *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
>>> COPYRIGHT
>>> + *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
>>> INCIDENTAL,
>>> + *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>>> + *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>>> USE,
>>> + *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
>>> ANY
>>> + *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
>>> + *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
>>> USE
>>&g

[dpdk-dev] [PATCH 2/2] Move non-PCI related eth_dev initialization to rte_eth_dev_allocate()

2016-11-17 Thread Jan Blunck
This moves the non-PCI related initialization of the link state interrupt
callback list and the setting of the default MTU to rte_eth_dev_allocate()
so that drivers only need to set non-default values.

Signed-off-by: Jan Blunck 
---
 drivers/net/bonding/rte_eth_bond_api.c |  2 --
 drivers/net/cxgbe/cxgbe_main.c |  2 --
 drivers/net/mlx4/mlx4.c|  2 --
 drivers/net/mlx5/mlx5.c|  3 ---
 drivers/net/null/rte_eth_null.c|  2 --
 drivers/net/ring/rte_eth_ring.c|  2 --
 drivers/net/vhost/rte_eth_vhost.c  |  2 --
 lib/librte_ether/rte_ethdev.c  | 12 
 8 files changed, 4 insertions(+), 23 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_api.c 
b/drivers/net/bonding/rte_eth_bond_api.c
index 2a3893a..18237a3 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -200,8 +200,6 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t 
socket_id)
eth_dev->data->nb_rx_queues = (uint16_t)1;
eth_dev->data->nb_tx_queues = (uint16_t)1;

-   TAILQ_INIT(&(eth_dev->link_intr_cbs));
-
eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;

eth_dev->data->mac_addrs = rte_zmalloc_socket(name, ETHER_ADDR_LEN, 0,
diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c
index 922155b..9e8402b 100644
--- a/drivers/net/cxgbe/cxgbe_main.c
+++ b/drivers/net/cxgbe/cxgbe_main.c
@@ -1172,8 +1172,6 @@ int cxgbe_probe(struct adapter *adapter)

rte_eth_copy_pci_info(pi->eth_dev, pi->eth_dev->pci_dev);

-   TAILQ_INIT(>eth_dev->link_intr_cbs);
-
pi->eth_dev->data->mac_addrs = rte_zmalloc(name,
   ETHER_ADDR_LEN, 0);
if (!pi->eth_dev->data->mac_addrs) {
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index 9264242..d815a52 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -5834,7 +5834,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct 
rte_pci_device *pci_dev)
eth_dev->rx_pkt_burst = mlx4_rx_burst_secondary_setup;
} else {
eth_dev->data->dev_private = priv;
-   eth_dev->data->mtu = ETHER_MTU;
eth_dev->data->mac_addrs = priv->mac;
}
eth_dev->pci_dev = pci_dev;
@@ -5845,7 +5844,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct 
rte_pci_device *pci_dev)

priv->dev = eth_dev;
eth_dev->dev_ops = _dev_ops;
-   TAILQ_INIT(_dev->link_intr_cbs);

/* Bring Ethernet device up. */
DEBUG("forcing Ethernet interface up");
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index b57cad1..0e91f02 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -652,7 +652,6 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct 
rte_pci_device *pci_dev)
eth_dev->rx_pkt_burst = mlx5_rx_burst_secondary_setup;
} else {
eth_dev->data->dev_private = priv;
-   eth_dev->data->mtu = ETHER_MTU;
eth_dev->data->mac_addrs = priv->mac;
}

@@ -662,8 +661,6 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct 
rte_pci_device *pci_dev)
priv->dev = eth_dev;
eth_dev->dev_ops = _dev_ops;

-   TAILQ_INIT(_dev->link_intr_cbs);
-
/* Bring Ethernet device up. */
DEBUG("forcing Ethernet interface up");
priv_set_flags(priv, ~IFF_UP, IFF_UP);
diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 836d982..f09caf1 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -550,8 +550,6 @@ eth_dev_null_create(const char *name,
eth_dev->data = data;
eth_dev->dev_ops = 

-   TAILQ_INIT(_dev->link_intr_cbs);
-
eth_dev->driver = NULL;
data->dev_flags = RTE_ETH_DEV_DETACHABLE;
data->kdrv = RTE_KDRV_NONE;
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index c1767c4..c7726f4 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -346,8 +346,6 @@ do_eth_dev_ring_create(const char *name,
data->drv_name = drivername;
data->numa_node = numa_node;

-   TAILQ_INIT(&(eth_dev->link_intr_cbs));
-
/* finally assign rx and tx ops */
eth_dev->rx_pkt_burst = eth_ring_rx;
eth_dev->tx_pkt_burst = eth_ring_tx;
diff --git a/drivers/net/vhost/rte_eth_vhost.c 
b/drivers/net/vhost/rte_eth_vhost.c
index 766d4ef.

[dpdk-dev] [PATCH 1/2] Clear eth_dev->data in rte_eth_dev_allocate()

2016-11-17 Thread Jan Blunck
Lets clear the eth_dev->data when allocating a new rte_eth_dev so that
drivers only need to set non-zero values.

Signed-off-by: Jan Blunck 
---
 drivers/net/mlx4/mlx4.c   | 1 -
 drivers/net/mlx5/mlx5.c   | 1 -
 lib/librte_ether/rte_ethdev.c | 2 +-
 3 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index da61a85..9264242 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -5834,7 +5834,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct 
rte_pci_device *pci_dev)
eth_dev->rx_pkt_burst = mlx4_rx_burst_secondary_setup;
} else {
eth_dev->data->dev_private = priv;
-   eth_dev->data->rx_mbuf_alloc_failed = 0;
eth_dev->data->mtu = ETHER_MTU;
eth_dev->data->mac_addrs = priv->mac;
}
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 90cc35e..b57cad1 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -652,7 +652,6 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct 
rte_pci_device *pci_dev)
eth_dev->rx_pkt_burst = mlx5_rx_burst_secondary_setup;
} else {
eth_dev->data->dev_private = priv;
-   eth_dev->data->rx_mbuf_alloc_failed = 0;
eth_dev->data->mtu = ETHER_MTU;
eth_dev->data->mac_addrs = priv->mac;
}
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index fde8112..12af4b1 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -212,6 +212,7 @@ rte_eth_dev_allocate(const char *name)

eth_dev = _eth_devices[port_id];
eth_dev->data = _eth_dev_data[port_id];
+   memset(eth_dev->data, 0, sizeof(*eth_dev->data));
snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
eth_dev->data->port_id = port_id;
eth_dev->attached = DEV_ATTACHED;
@@ -259,7 +260,6 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
}
eth_dev->pci_dev = pci_dev;
eth_dev->driver = eth_drv;
-   eth_dev->data->rx_mbuf_alloc_failed = 0;

/* init user callbacks */
TAILQ_INIT(&(eth_dev->link_intr_cbs));
-- 
2.7.4



[dpdk-dev] [RFC PATCH 6/6] eal: removing eth_driver

2016-11-17 Thread Jan Blunck
On Thu, Nov 17, 2016 at 6:30 AM, Shreyansh Jain  
wrote:
> This patch demonstrates how eth_driver can be replaced with appropriate
> changes for rte_xxx_driver from the PMD itself. It uses ixgbe_ethernet as
> an example.
>
> A large set of changes exists in the rte_ethdev.c - primarily because too
> much PCI centric code (names, assumption of rte_pci_device) still exists
> in it. Most, except symbol naming, has been changed in this patch.
>
> This proposes that:
>  - PMD would declare the rte_xxx_driver. In case of ixgbe, it would be
>rte_pci_driver.
>  - Probe and remove continue to exists in rte_pci_driver. But, the
>rte_driver has new hooks for init and uninit. The rationale is that
>once a ethernet or cryto device is created, the rte_driver->init would
>be responsible for initializing the device.
>-- Eth_dev -> rte_driver -> rte_pci_driver
>   |`-> probe/remove
>   `--> init/uninit

Hmm, from my perspective this moves struct rte_driver a step closer to
struct rte_eth_dev instead of decoupling them. It is up to the
rte_driver->probe if it wants to allocate a struct rte_eth_dev,
rte_crypto_dev or the famous rte_foo_dev.

Instead of explicitly modelling rte_eth_dev specifics like init, unit
or dev_private_size I think we should delegate this to the
rte_driver->probe instead. Most of what is in rte_eth_dev_pci_probe()
today is anyway a rte_eth_dev_allocate_priv() anyway. I already have
some patches in this area in my patch stack.


>  - necessary changes in the rte_eth_dev have also been done so that it
>refers to the rte_device and rte_driver rather than rte_xxx_*. This
>would imply, ethernet device is 'linked' to a rte_device/rte_driver
>which in turn is a rte_xxx_device/rte_xxx_driver type.
>- for all operations related to extraction relvant xxx type,
>  container_of would have to be used.
>
> Signed-off-by: Shreyansh Jain 
> ---
>  drivers/net/ixgbe/ixgbe_ethdev.c | 49 
> +---
>  lib/librte_ether/rte_ethdev.c| 36 +
>  lib/librte_ether/rte_ethdev.h|  6 ++---
>  3 files changed, 51 insertions(+), 40 deletions(-)
>
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c 
> b/drivers/net/ixgbe/ixgbe_ethdev.c
> index edc9b22..acead31 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> @@ -1419,7 +1419,7 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
> return 0;
> }
>
> -   pci_dev = eth_dev->pci_dev;
> +   pci_dev = container_of(eth_dev->device, struct rte_pci_device, 
> device);
>
> rte_eth_copy_pci_info(eth_dev, pci_dev);
>
> @@ -1532,7 +1532,9 @@ static int
>  eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
>  {
> struct ixgbe_hw *hw;
> -   struct rte_pci_device *pci_dev = eth_dev->pci_dev;
> +   struct rte_pci_device *pci_dev;
> +
> +   pci_dev = container_of(eth_dev->device, struct rte_pci_device, 
> device);
>
> PMD_INIT_FUNC_TRACE();
>
> @@ -1562,32 +1564,33 @@ eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
> return 0;
>  }
>
> -static struct eth_driver rte_ixgbe_pmd = {
> -   .pci_drv = {
> -   .id_table = pci_id_ixgbe_map,
> -   .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
> -   RTE_PCI_DRV_DETACHABLE,
> -   .probe = rte_eth_dev_pci_probe,
> -   .remove = rte_eth_dev_pci_remove,
> +static struct rte_pci_driver rte_ixgbe_pci_driver = {
> +   .id_table = pci_id_ixgbe_map,
> +   .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
> +RTE_PCI_DRV_DETACHABLE,
> +   .probe = rte_eth_dev_pci_probe,
> +   .remove = rte_eth_dev_pci_remove,
> +   .driver = {
> +   .driver_init_t= eth_ixgbe_dev_init,
> +   .driver_uninit_t= eth_ixgbe_dev_uninit,
> +   .dev_private_size = sizeof(struct ixgbe_adapter),
> },
> -   .eth_dev_init = eth_ixgbe_dev_init,
> -   .eth_dev_uninit = eth_ixgbe_dev_uninit,
> -   .dev_private_size = sizeof(struct ixgbe_adapter),
>  };
>
>  /*
>   * virtual function driver struct
>   */
> -static struct eth_driver rte_ixgbevf_pmd = {
> -   .pci_drv = {
> -   .id_table = pci_id_ixgbevf_map,
> -   .drv_flags = RTE_PCI_DRV_NEED_MAPPING | 
> RTE_PCI_DRV_DETACHABLE,
> -   .probe = rte_eth_dev_pci_probe,
> -   .remove = rte_eth_dev_pci_remove,
> +static struct rte_pci_driver rte_ixgbevf_pci_driver = {
> +   .id_table = pci_id_ixgbevf_map,
> +   .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
> +   .probe = rte_eth_dev_pci_probe,
> +   .remove = rte_eth_dev_pci_remove,
> +   .driver = {
> +   /* rte_driver hooks */
> +   .init = eth_ixgbevf_dev_init,
> +   .uninit = eth_ixgbevf_dev_uninit,
> +

[dpdk-dev] [RFC PATCH 1/6] eal: define container macro

2016-11-17 Thread Jan Blunck
On Thu, Nov 17, 2016 at 6:30 AM, Shreyansh Jain  
wrote:
> From: Jan Viktorin 
>
> Signed-off-by: Jan Viktorin 
> Signed-off-by: Shreyansh Jain 
> ---
>  lib/librte_eal/common/include/rte_common.h | 18 ++
>  1 file changed, 18 insertions(+)
>
> diff --git a/lib/librte_eal/common/include/rte_common.h 
> b/lib/librte_eal/common/include/rte_common.h
> index db5ac91..8152bd9 100644
> --- a/lib/librte_eal/common/include/rte_common.h
> +++ b/lib/librte_eal/common/include/rte_common.h
> @@ -331,6 +331,24 @@ rte_bsf32(uint32_t v)
>  #define offsetof(TYPE, MEMBER)  __builtin_offsetof (TYPE, MEMBER)
>  #endif
>
> +/**
> + * Return pointer to the wrapping struct instance.
> + * Example:
> + *
> + *  struct wrapper {
> + *  ...
> + *  struct child c;
> + *  ...
> + *  };
> + *
> + *  struct child *x = obtain(...);
> + *  struct wrapper *w = container_of(x, struct wrapper, c);
> + */
> +#ifndef container_of
> +#define container_of(p, type, member) \
> +   ((type *) (((char *) (p)) - offsetof(type, member)))

Are there any reasons why you choose to implement this in a non-type
safe way? Catching obvious bugs at compile time is in the interest of
us and our users from my point of view.


> +#endif
> +
>  #define _RTE_STR(x) #x
>  /** Take a macro value and get a string version of it */
>  #define RTE_STR(x) _RTE_STR(x)
> --
> 2.7.4
>


[dpdk-dev] [RFC PATCH 0/6] Restructure EAL device model for bus support

2016-11-17 Thread Jan Blunck
On Thu, Nov 17, 2016 at 6:29 AM, Shreyansh Jain  
wrote:
> DPDK has been inherently a PCI inclined framework. Because of this, the
> design of device tree (or list) within DPDK is also PCI inclined. A non-PCI
> device doesn't have a way of being expressed without using hooks started from
> EAL to PMD.
>
> With this cover letter, some patches are presented which try to break this
> strict linkage of EAL with PCI devices. Aim is to generalize the device
> hierarchy on the lines of how Linux handles it:
>
> device A1
>   |
>   +==.'==.+ Bus A.
>  |`--> driver A11 \
>   device A2`-> driver A12  \__
> |CPU |
> /`
> device A1  /
>   |   /
>   +==.'==.+ Bus A`
>  |`--> driver B11
>   device A2`-> driver B12
>
> Simply put:
>  - a bus is connect to CPU (or core)
>  - devices are conneted to Bus
>  - drivers are running instances which manage one or more devices
>  - bus is responsible for identifying devices (and interrupt propogation)
>  - driver is responsible for initializing the device
>
> (*Reusing text from email [1])
> In context of DPDK EAL:
>  - a generic bus (not a driver, not a device). I don't know how to categorize
>a bus. It is certainly not a device, and then handler for a bus (physical)
>can be considered a 'bus driver'. So, just 'rte_bus'.
>  - there is a bus for each physical implementation (or virtual). So, a rte_bus
>Object for PCI, VDEV, ABC, DEF and so on.
>  - Buses are registered just like a PMD - RTE_PMD_BUS_REGISTER()
>  - Each registered bus is part of a doubly list.
>-- Each device inherits rte_bus
>-- Each driver inherits rte_bus
>-- Device and Drivers lists are part of rte_bus
>  - eth_driver is no more required - it was just a holder for PMDs to register
>themselves. It can be replaced with rte_xxx_driver and corresponding init/
>uninit moved to rte_driver
>  - rte_eth_dev modified to disassociate itself from rte_pci_device and connect
>to generic rte_device
>
> Once again, improvising from [1]:
>
>   __ rte_bus_list
>  /
>  +--'---+
>  |rte_bus   |
>  | driver_list--> List of rte_bus specific
>  | device_listdevices
>  | scan | `-> List of rte_bus associated
>  | match| drivers
>  | dump |
>  | ..some refcnt| (#)
>  +--|--|+
>   _/\_
> +/+ +-\---+
> |rte_device   | |rte_driver   |
> | rte_bus | | rte_bus |
> | rte_driver  |(#)  | init|
> | | | uninit  |
> |  devargs| | dev_private_size|
> +---||+ | drv_flags   |(#)
> ||  | intr_handle(2*) |(#)
> | \ +--\\\+
> |  \_   \\\
> |\  |||
>  +--|-+ +|--+   |||
>  |rte_pci_device  | |rte_xxx_device | (4*)  |||
>  | PCI specific   | | xxx device|   |||
>  | info (mem,)| | specific fns  |  / | \
>  ++ +---+ /  |  \
> _/  /\
>/___/  \
> +-'--++'---++--'+
> |rte_pci_driver  ||rte_vdev_driver ||rte_xxx_driver |
> | PCI id table,  ||  | other driver   ||  nothing>  |+---+
> | data   |++
> ++
>
> (1*) Problem is that probe functions have different arguments. So,
>  generalizing them might be some rework in the respective device
>  layers
> (2*) Interrupt handling for each driver type might be different. I am not
>  sure how to generalize that either. This is grey area for me.
> (3*) Probably exposing a bitmask for device capabilities. Nothing similar
>  exists now to relate it. Don't know if that is useful. Allowing
>  applications to question a device about what it supports and what it
>  doesn't - making it more 

[dpdk-dev] [RFC PATCH 2/6] eal: introduce bus-device-driver structure

2016-11-17 Thread Jan Blunck
On Thu, Nov 17, 2016 at 6:30 AM, Shreyansh Jain  
wrote:
> A device is connected to a bus and services by a driver associated with
> the bus. It is responsibility of the bus to identify the devices (scan)
> and then assign each device to a matching driver.
>
> A PMD would allocate a rte_xxx_driver and rte_xxx_device.
> rte_xxx_driver has rte_driver and rte_bus embedded. Similarly, rte_xxx_device
> has rte_device and rte_bus embedded.

I don't think so: the rte_xxx_device embeds the generic rte_device and
references a the rte_bus
that it is attached to.

> When a ethernet or crypto device (rte_eth_dev, rte_cryptodev) is allocated,
> it contains a reference of rte_device and rte_driver.
> Each ethernet device implementation would use container_of for finding the
> enclosing structure of rte_xxx_*.
>
> +---+
>  +--+   |rte_pci_device |
>  |rte_eth_dev   |   |+-+|
>  |++|   .>rte_device   ||
>  ||rte_device*-'|+-+|
>  |++|   ||rte_bus  ||
>  |  |   |+-+|
>  /  /   +---+
>
> Signed-off-by: Shreyansh Jain 
> ---
>  lib/librte_eal/common/include/rte_bus.h | 243 
> 
>  lib/librte_eal/common/include/rte_dev.h |  36 ++---
>  2 files changed, 261 insertions(+), 18 deletions(-)
>  create mode 100644 lib/librte_eal/common/include/rte_bus.h
>
> diff --git a/lib/librte_eal/common/include/rte_bus.h 
> b/lib/librte_eal/common/include/rte_bus.h
> new file mode 100644
> index 000..dc3aeb8
> --- /dev/null
> +++ b/lib/librte_eal/common/include/rte_bus.h
> @@ -0,0 +1,243 @@
> +/*-
> + *   BSD LICENSE
> + *
> + *   Copyright(c) 2016 NXP
> + *   All rights reserved.
> + *
> + *   Redistribution and use in source and binary forms, with or without
> + *   modification, are permitted provided that the following conditions
> + *   are met:
> + *
> + * * Redistributions of source code must retain the above copyright
> + *   notice, this list of conditions and the following disclaimer.
> + * * Redistributions in binary form must reproduce the above copyright
> + *   notice, this list of conditions and the following disclaimer in
> + *   the documentation and/or other materials provided with the
> + *   distribution.
> + * * Neither the name of NXP nor the names of its
> + *   contributors may be used to endorse or promote products derived
> + *   from this software without specific prior written permission.
> + *
> + *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> + *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> + *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
> + *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
> + *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> + *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> + *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
> + *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
> + *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> + *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
> + *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + */
> +
> +#ifndef _RTE_BUS_H_
> +#define _RTE_BUS_H_
> +
> +/**
> + * @file
> + *
> + * RTE PMD Bus Abstraction interfaces
> + *
> + * This file exposes APIs and Interfaces for Bus Abstraction over the devices
> + * drivers in EAL.
> + */
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +
> +
> +/** Double linked list of buses */
> +TAILQ_HEAD(rte_bus_list, rte_bus);
> +
> +/**
> + * Bus specific scan for devices attached on the bus.
> + * For each bus object, the scan would be reponsible for finding devices and
> + * adding them to its private device list.
> + *
> + * Successful detection of a device results in rte_device object which is
> + * embedded within the respective device type (rte_pci_device, for example).
> + * Thereafter, PCI specific bus would need to perform
> + * container_of(rte_pci_device) to obtain PCI device object.
> + *
> + * Scan failure of a bus is not treated as exit criteria for application. 
> Scan
> + * for all other buses would still continue.
> + *
> + * @param void
> + * @return
> + * 0 for successful scan
> + * !0 (<0) for unsuccessful scan with error value
> + */
> +typedef int (* bus_scan_t)(void);
> +
> +/**
> + * Bus specific match for devices and drivers which can service them.
> + * For each scanned device, during probe the match would link the devices 
> with
> + * drivers which can service the device.
> + *
> + * It is the work of each bus handler to obtain the specific 

[dpdk-dev] [PATCH v2 3/3] drivers: register aliases for renamed cryptodev drivers

2016-10-24 Thread Jan Blunck
This registers the legacy names of the driver being renamed in
commit 2f45703c17ac ("drivers: make driver names consistent").

Signed-off-by: Jan Blunck 
Tested-by: Pablo de Lara 
---
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c   | 1 +
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 1 +
 drivers/crypto/kasumi/rte_kasumi_pmd.c | 1 +
 drivers/crypto/null/null_crypto_pmd.c  | 1 +
 drivers/crypto/snow3g/rte_snow3g_pmd.c | 1 +
 5 files changed, 5 insertions(+)

diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c 
b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
index 0b3fd09..dba5e15 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
@@ -529,6 +529,7 @@ static struct rte_vdev_driver aesni_gcm_pmd_drv = {
 };

 RTE_PMD_REGISTER_VDEV(CRYPTODEV_NAME_AESNI_GCM_PMD, aesni_gcm_pmd_drv);
+RTE_PMD_REGISTER_ALIAS(CRYPTODEV_NAME_AESNI_GCM_PMD, cryptodev_aesni_gcm_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_AESNI_GCM_PMD,
"max_nb_queue_pairs= "
"max_nb_sessions= "
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c 
b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index b936735..f07cd07 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -720,6 +720,7 @@ static struct rte_vdev_driver cryptodev_aesni_mb_pmd_drv = {
 };

 RTE_PMD_REGISTER_VDEV(CRYPTODEV_NAME_AESNI_MB_PMD, cryptodev_aesni_mb_pmd_drv);
+RTE_PMD_REGISTER_ALIAS(CRYPTODEV_NAME_AESNI_MB_PMD, cryptodev_aesni_mb_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_AESNI_MB_PMD,
"max_nb_queue_pairs= "
"max_nb_sessions= "
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c 
b/drivers/crypto/kasumi/rte_kasumi_pmd.c
index 11bbf80..b119da2 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c
@@ -656,6 +656,7 @@ static struct rte_vdev_driver cryptodev_kasumi_pmd_drv = {
 };

 RTE_PMD_REGISTER_VDEV(CRYPTODEV_NAME_KASUMI_PMD, cryptodev_kasumi_pmd_drv);
+RTE_PMD_REGISTER_ALIAS(CRYPTODEV_NAME_KASUMI_PMD, cryptodev_kasumi_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_KASUMI_PMD,
"max_nb_queue_pairs= "
"max_nb_sessions= "
diff --git a/drivers/crypto/null/null_crypto_pmd.c 
b/drivers/crypto/null/null_crypto_pmd.c
index a7d3600..c69606b 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -274,6 +274,7 @@ static struct rte_vdev_driver cryptodev_null_pmd_drv = {
 };

 RTE_PMD_REGISTER_VDEV(CRYPTODEV_NAME_NULL_PMD, cryptodev_null_pmd_drv);
+RTE_PMD_REGISTER_ALIAS(CRYPTODEV_NAME_NULL_PMD, cryptodev_null_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_NULL_PMD,
"max_nb_queue_pairs= "
"max_nb_sessions= "
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c 
b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index a794251..3b4292a 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -644,6 +644,7 @@ static struct rte_vdev_driver cryptodev_snow3g_pmd_drv = {
 };

 RTE_PMD_REGISTER_VDEV(CRYPTODEV_NAME_SNOW3G_PMD, cryptodev_snow3g_pmd_drv);
+RTE_PMD_REGISTER_ALIAS(CRYPTODEV_NAME_SNOW3G_PMD, cryptodev_snow3g_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_SNOW3G_PMD,
"max_nb_queue_pairs= "
"max_nb_sessions= "
-- 
2.6.6



[dpdk-dev] [PATCH v2 2/3] drivers: register aliases for renamed VDEV drivers

2016-10-24 Thread Jan Blunck
This registers the legacy names of the driver being renamed in
commit 2f45703c17ac ("drivers: make driver names consistent").

Signed-off-by: Jan Blunck 
---
 drivers/net/af_packet/rte_eth_af_packet.c | 1 +
 drivers/net/bonding/rte_eth_bond_pmd.c| 1 +
 drivers/net/mpipe/mpipe_tilegx.c  | 2 ++
 drivers/net/null/rte_eth_null.c   | 1 +
 drivers/net/pcap/rte_eth_pcap.c   | 1 +
 drivers/net/ring/rte_eth_ring.c   | 1 +
 drivers/net/vhost/rte_eth_vhost.c | 1 +
 drivers/net/virtio/virtio_user_ethdev.c   | 1 +
 drivers/net/xenvirt/rte_eth_xenvirt.c | 1 +
 9 files changed, 10 insertions(+)

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c 
b/drivers/net/af_packet/rte_eth_af_packet.c
index 201c1be..ff45068 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -895,6 +895,7 @@ static struct rte_vdev_driver pmd_af_packet_drv = {
 };

 RTE_PMD_REGISTER_VDEV(net_af_packet, pmd_af_packet_drv);
+RTE_PMD_REGISTER_ALIAS(net_af_packet, eth_af_packet);
 RTE_PMD_REGISTER_PARAM_STRING(net_af_packet,
"iface= "
"qpairs= "
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index 9e38ec9..9df245e 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2560,6 +2560,7 @@ static struct rte_vdev_driver bond_drv = {
 };

 RTE_PMD_REGISTER_VDEV(net_bonding, bond_drv);
+RTE_PMD_REGISTER_ALIAS(net_bonding, eth_bond);

 RTE_PMD_REGISTER_PARAM_STRING(net_bonding,
"slave= "
diff --git a/drivers/net/mpipe/mpipe_tilegx.c b/drivers/net/mpipe/mpipe_tilegx.c
index adf299b..f00 100644
--- a/drivers/net/mpipe/mpipe_tilegx.c
+++ b/drivers/net/mpipe/mpipe_tilegx.c
@@ -1632,7 +1632,9 @@ static struct rte_vdev_driver pmd_mpipe_gbe_drv = {
 };

 RTE_PMD_REGISTER_VDEV(net_mpipe_xgbe, pmd_mpipe_xgbe_drv);
+RTE_PMD_REGISTER_ALIAS(net_mpipe_xgbe, xgbe);
 RTE_PMD_REGISTER_VDEV(net_mpipe_gbe, pmd_mpipe_gbe_drv);
+RTE_PMD_REGISTER_ALIAS(net_mpipe_gbe, gbe);

 static void __attribute__((constructor, used))
 mpipe_init_contexts(void)
diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 0b7cc37..836d982 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -692,6 +692,7 @@ static struct rte_vdev_driver pmd_null_drv = {
 };

 RTE_PMD_REGISTER_VDEV(net_null, pmd_null_drv);
+RTE_PMD_REGISTER_ALIAS(net_null, eth_null);
 RTE_PMD_REGISTER_PARAM_STRING(net_null,
"size= "
"copy=");
diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 0c4711d..0162f44 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -1065,6 +1065,7 @@ static struct rte_vdev_driver pmd_pcap_drv = {
 };

 RTE_PMD_REGISTER_VDEV(net_pcap, pmd_pcap_drv);
+RTE_PMD_REGISTER_ALIAS(net_pcap, eth_pcap);
 RTE_PMD_REGISTER_PARAM_STRING(net_pcap,
ETH_PCAP_RX_PCAP_ARG "= "
ETH_PCAP_TX_PCAP_ARG "= "
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index ee1fb76..6d2a8c1 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -629,5 +629,6 @@ static struct rte_vdev_driver pmd_ring_drv = {
 };

 RTE_PMD_REGISTER_VDEV(net_ring, pmd_ring_drv);
+RTE_PMD_REGISTER_ALIAS(net_ring, eth_ring);
 RTE_PMD_REGISTER_PARAM_STRING(net_ring,
ETH_RING_NUMA_NODE_ACTION_ARG "=name:node:action(ATTACH|CREATE)");
diff --git a/drivers/net/vhost/rte_eth_vhost.c 
b/drivers/net/vhost/rte_eth_vhost.c
index 6f58476..766d4ef 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -1244,6 +1244,7 @@ static struct rte_vdev_driver pmd_vhost_drv = {
 };

 RTE_PMD_REGISTER_VDEV(net_vhost, pmd_vhost_drv);
+RTE_PMD_REGISTER_ALIAS(net_vhost, eth_vhost);
 RTE_PMD_REGISTER_PARAM_STRING(net_vhost,
"iface= "
"queues=");
diff --git a/drivers/net/virtio/virtio_user_ethdev.c 
b/drivers/net/virtio/virtio_user_ethdev.c
index bfdc3d0..406beea 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -479,6 +479,7 @@ static struct rte_vdev_driver virtio_user_driver = {
 };

 RTE_PMD_REGISTER_VDEV(net_virtio_user, virtio_user_driver);
+RTE_PMD_REGISTER_ALIAS(net_virtio_user, virtio_user);
 RTE_PMD_REGISTER_PARAM_STRING(net_virtio_user,
"path= "
"mac= "
diff --git a/drivers/net/xenvirt/rte_eth_xenvirt.c 
b/drivers/net/xenvirt/rte_eth_xenvirt.c
index 5a897b9..c08a056 100644
--- a/drivers/net/xenvirt/rte_eth_xenvirt.c
+++ b/drivers/net/xenvirt/rte_eth_xenvirt.c
@@ -765,5 +765,6 @@ static struct rte_vdev_driver pmd_xenvirt_drv = {
 };

 RTE_PMD_REGISTER_VDEV(net_xenvirt, pmd_xenvirt_drv);
+RTE_PMD_REGISTER_ALIAS(net_xenvirt, eth_xenvirt);
 RTE_PMD_REGISTER_PARAM_STRING(net_xenvirt,
"mac=");
-- 
2.6.6



[dpdk-dev] [PATCH v2 1/3] drivers: add name alias registration for rte_driver

2016-10-24 Thread Jan Blunck
This adds infrastructure for drivers to allow being requested by an alias
so that a renamed driver can still get loaded by its legacy name.

Signed-off-by: Jan Blunck 
Reviewed-by: Maxime Coquelin 
Tested-by: Pablo de Lara 
---
 lib/librte_eal/common/eal_common_vdev.c  | 8 
 lib/librte_eal/common/include/rte_dev.h  | 1 +
 lib/librte_eal/common/include/rte_vdev.h | 5 +
 3 files changed, 14 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_vdev.c 
b/lib/librte_eal/common/eal_common_vdev.c
index 8b05f50..0ff2377 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -79,6 +79,14 @@ rte_eal_vdev_init(const char *name, const char *args)
return driver->probe(name, args);
}

+   /* Give new names precedence over aliases. */
+   TAILQ_FOREACH(driver, _driver_list, next) {
+   if (driver->driver.alias &&
+   !strncmp(driver->driver.alias, name,
+   strlen(driver->driver.alias)))
+   return driver->probe(name, args);
+   }
+
RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
return -EINVAL;
 }
diff --git a/lib/librte_eal/common/include/rte_dev.h 
b/lib/librte_eal/common/include/rte_dev.h
index b3873bd..8840380 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -149,6 +149,7 @@ void rte_eal_device_remove(struct rte_device *dev);
 struct rte_driver {
TAILQ_ENTRY(rte_driver) next;  /**< Next in list. */
const char *name;   /**< Driver name. */
+   const char *alias;  /**< Driver alias. */
 };

 /**
diff --git a/lib/librte_eal/common/include/rte_vdev.h 
b/lib/librte_eal/common/include/rte_vdev.h
index 97260b2..784e837 100644
--- a/lib/librte_eal/common/include/rte_vdev.h
+++ b/lib/librte_eal/common/include/rte_vdev.h
@@ -83,13 +83,18 @@ void rte_eal_vdrv_unregister(struct rte_vdev_driver 
*driver);

 #define RTE_PMD_REGISTER_VDEV(nm, vdrv)\
 RTE_INIT(vdrvinitfn_ ##vdrv);\
+static const char *vdrvinit_ ## nm ## _alias;\
 static void vdrvinitfn_ ##vdrv(void)\
 {\
(vdrv).driver.name = RTE_STR(nm);\
+   (vdrv).driver.alias = vdrvinit_ ## nm ## _alias;\
rte_eal_vdrv_register();\
 } \
 RTE_PMD_EXPORT_NAME(nm, __COUNTER__)

+#define RTE_PMD_REGISTER_ALIAS(nm, alias)\
+static const char *vdrvinit_ ## nm ## _alias = RTE_STR(alias)
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.6.6



[dpdk-dev] [PATCH] Revert "bonding: use existing enslaved device queues"

2016-10-24 Thread Jan Blunck
On Wed, Oct 19, 2016 at 5:47 AM, Ilya Maximets  
wrote:
> On 18.10.2016 18:19, Jan Blunck wrote:
>> On Tue, Oct 18, 2016 at 2:49 PM, Ilya Maximets  
>> wrote:
>>> On 18.10.2016 15:28, Jan Blunck wrote:
>>>> If the application already configured queues the PMD should not
>>>> silently claim ownership and reset them.
>>>>
>>>> What exactly is the problem when changing MTU? This works fine from
>>>> what I can tell.
>>>
>>> Following scenario leads to APP PANIC:
>>>
>>> 1. mempool_1 = rte_mempool_create()
>>> 2. rte_eth_rx_queue_setup(bond0, ..., mempool_1);
>>> 3. rte_eth_dev_start(bond0);
>>> 4. mempool_2 = rte_mempool_create();
>>> 5. rte_eth_dev_stop(bond0);
>>> 6. rte_eth_rx_queue_setup(bond0, ..., mempool_2);
>>> 7. rte_eth_dev_start(bond0);
>>> * RX queues still use 'mempool_1' because reconfiguration doesn't 
>>> affect them. *
>>> 8. rte_mempool_free(mempool_1);
>>> 9. On any rx operation we'll get PANIC because of using freed 
>>> 'mempool_1':
>>>  PANIC in rte_mempool_get_ops():
>>>  assert "(ops_index >= 0) && (ops_index < RTE_MEMPOOL_MAX_OPS_IDX)" 
>>> failed
>>>
>>> You may just start OVS 2.6 with DPDK bonding device and attempt to change 
>>> MTU via 'mtu_request'.
>>> Bug is easily reproducible.
>>>
>>
>> I see. I'm not 100% that this is expected to work without leaking the
>> driver's queues though. The driver is allowed to do allocations in
>> its rx_queue_setup() function that are being freed via
>> rx_queue_release() later. But rx_queue_release() is only called if you
>> reconfigure the
>> device with 0 queues. From what I understand there is no other way to
>> reconfigure a device to use another mempool.
>>
>> But ... even that wouldn't work with the bonding driver right now: the
>> bonding master only configures the slaves during startup. I can put
>> that on my todo list.
>>
>> Coming back to your original problem: changing the MTU for the bond
>> does work through rte_eth_dev_set_mtu() for slaves supporting that. In
>> any other case you could (re-)configure rxmode.max_rx_pkt_len (and
>> jumbo_frame / enable_scatter accordingly). This does work without a
>> call to rte_eth_rx_queue_setup().
>
> Thanks for suggestion, but using of rte_eth_dev_set_mtu() without
> reconfiguration will require to have mempools with huge mbufs (9KB)
> for all ports from the start. This is unacceptable because leads to
> significant performance regressions because of fast cache exhausting.
> Also this will require big work to rewrite OVS reconfiguration code
> this way.
> Anyway, it isn't the MTU only problem. Number of rx/tx descriptors
> also can't be changed in runtime.
>
>
> I'm not fully understand what is the use case for this 'reusing' code.
> Could you, please, describe situation where this behaviour is necessary?

The device that is added to the bond was used before and therefore
already has allocated queues. Therefore we reuse the existing queues
of the devices instead of borrowing the queues of the bond device. If
the slave is removed from the bond again there is no need to allocate
the queues again.

Hope that clarifies the usecase,
Jan


>
> Best regards, Ilya Maximets.
>
>>>
>>>>
>>>> On Wed, Sep 7, 2016 at 2:28 PM, Ilya Maximets  
>>>> wrote:
>>>>> This reverts commit 5b7bb2bda5519b7800f814df64d4e015282140e5.
>>>>>
>>>>> It is necessary to reconfigure all queues every time because configuration
>>>>> can be changed.
>>>>>
>>>>> For example, if we're reconfiguring bonding device with new memory pool,
>>>>> already configured queues will still use the old one. And if the old
>>>>> mempool be freed, application likely will panic in attempt to use
>>>>> freed mempool.
>>>>>
>>>>> This happens when we use the bonding device with OVS 2.6 while MTU
>>>>> reconfiguration:
>>>>>
>>>>> PANIC in rte_mempool_get_ops():
>>>>> assert "(ops_index >= 0) && (ops_index < RTE_MEMPOOL_MAX_OPS_IDX)" failed
>>>>>
>>>>> Cc: 
>>>>> Signed-off-by: Ilya Maximets 
>>>>> ---
>>>>>  drivers/net/bonding/rte_eth_bond_pmd.c | 10 ++
>>>>>  1 file changed, 2 insertions(+), 8 deletion

[dpdk-dev] [PATCH] Revert "bonding: use existing enslaved device queues"

2016-10-24 Thread Jan Blunck
On Mon, Oct 24, 2016 at 7:02 AM, Declan Doherty
 wrote:
> On 14/10/16 00:37, Eric Kinzie wrote:
>>
>> On Wed Oct 12 16:24:21 +0100 2016, Bruce Richardson wrote:
>>>
>>> On Wed, Oct 12, 2016 at 04:24:54PM +0300, Ilya Maximets wrote:

 On 07.10.2016 05:02, Eric Kinzie wrote:
>
> On Wed Sep 07 15:28:10 +0300 2016, Ilya Maximets wrote:
>>
>> This reverts commit 5b7bb2bda5519b7800f814df64d4e015282140e5.
>>
>> It is necessary to reconfigure all queues every time because
>> configuration
>> can be changed.
>>
>> For example, if we're reconfiguring bonding device with new memory
>> pool,
>> already configured queues will still use the old one. And if the old
>> mempool be freed, application likely will panic in attempt to use
>> freed mempool.
>>
>> This happens when we use the bonding device with OVS 2.6 while MTU
>> reconfiguration:
>>
>> PANIC in rte_mempool_get_ops():
>> assert "(ops_index >= 0) && (ops_index < RTE_MEMPOOL_MAX_OPS_IDX)"
>> failed
>>
>> Cc: 
>> Signed-off-by: Ilya Maximets 
>> ---
>>  drivers/net/bonding/rte_eth_bond_pmd.c | 10 ++
>>  1 file changed, 2 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c
>> b/drivers/net/bonding/rte_eth_bond_pmd.c
>> index b20a272..eb5b6d1 100644
>> --- a/drivers/net/bonding/rte_eth_bond_pmd.c
>> +++ b/drivers/net/bonding/rte_eth_bond_pmd.c
>> @@ -1305,8 +1305,6 @@ slave_configure(struct rte_eth_dev
>> *bonded_eth_dev,
>> struct bond_rx_queue *bd_rx_q;
>> struct bond_tx_queue *bd_tx_q;
>>
>> -   uint16_t old_nb_tx_queues = slave_eth_dev->data->nb_tx_queues;
>> -   uint16_t old_nb_rx_queues = slave_eth_dev->data->nb_rx_queues;
>> int errval;
>> uint16_t q_id;
>>
>> @@ -1347,9 +1345,7 @@ slave_configure(struct rte_eth_dev
>> *bonded_eth_dev,
>> }
>>
>> /* Setup Rx Queues */
>> -   /* Use existing queues, if any */
>> -   for (q_id = old_nb_rx_queues;
>> -q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
>> +   for (q_id = 0; q_id < bonded_eth_dev->data->nb_rx_queues;
>> q_id++) {
>> bd_rx_q = (struct bond_rx_queue
>> *)bonded_eth_dev->data->rx_queues[q_id];
>>
>> errval =
>> rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, q_id,
>> @@ -1365,9 +1361,7 @@ slave_configure(struct rte_eth_dev
>> *bonded_eth_dev,
>> }
>>
>> /* Setup Tx Queues */
>> -   /* Use existing queues, if any */
>> -   for (q_id = old_nb_tx_queues;
>> -q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
>> +   for (q_id = 0; q_id < bonded_eth_dev->data->nb_tx_queues;
>> q_id++) {
>> bd_tx_q = (struct bond_tx_queue
>> *)bonded_eth_dev->data->tx_queues[q_id];
>>
>> errval =
>> rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, q_id,
>> --
>> 2.7.4
>>
>
> NAK
>
> There are still some users of this code.  Let's give them a chance to
> comment before removing it.


 Hi Eric,

 Are these users in CC-list? If not, could you, please, add them?
 This patch awaits in mail-list already more than a month. I think, it's
 enough
 time period for all who wants to say something. Patch fixes a real bug
 that
 prevent using of DPDK bonding in all applications that reconfigures
 devices
 in runtime including OVS.

>>> Agreed.
>>>
>>> Eric, does reverting this patch cause you problems directly, or is your
>>> concern
>>> just with regards to potential impact to others?
>>>
>>> Thanks,
>>> /Bruce
>>
>>
>> This won't impact me directly.  The users are CCed (different thread)
>> and I haven't seen any comment, so I no longer have any objection to
>> reverting this change.
>>
>> Eric
>>
>
> As there has been no further objections and this reinstates the original
> expected behavior of the bonding driver. I'm re-ack'ing for inclusion in
> release.
>
> Acked-by: Declan Doherty 

Ok, I can revert the revert for us.

Do I read this correctly that you are not interested in fixing this properly?!

Thanks,
Jan


[dpdk-dev] [PATCH] drivers: register aliases for renamed cryptodev drivers

2016-10-21 Thread Jan Blunck
This registers the legacy names of the driver being renamed in commit
2f45703c17acb943aaded9f79676fd56a72542b2.

Signed-off-by: Jan Blunck 
---
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c   | 1 +
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 1 +
 drivers/crypto/kasumi/rte_kasumi_pmd.c | 1 +
 drivers/crypto/null/null_crypto_pmd.c  | 1 +
 drivers/crypto/snow3g/rte_snow3g_pmd.c | 1 +
 5 files changed, 5 insertions(+)

diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c 
b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
index 0b3fd09..dba5e15 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
@@ -529,6 +529,7 @@ static struct rte_vdev_driver aesni_gcm_pmd_drv = {
 };

 RTE_PMD_REGISTER_VDEV(CRYPTODEV_NAME_AESNI_GCM_PMD, aesni_gcm_pmd_drv);
+RTE_PMD_REGISTER_ALIAS(CRYPTODEV_NAME_AESNI_GCM_PMD, cryptodev_aesni_gcm_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_AESNI_GCM_PMD,
"max_nb_queue_pairs= "
"max_nb_sessions= "
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c 
b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index b936735..f07cd07 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -720,6 +720,7 @@ static struct rte_vdev_driver cryptodev_aesni_mb_pmd_drv = {
 };

 RTE_PMD_REGISTER_VDEV(CRYPTODEV_NAME_AESNI_MB_PMD, cryptodev_aesni_mb_pmd_drv);
+RTE_PMD_REGISTER_ALIAS(CRYPTODEV_NAME_AESNI_MB_PMD, cryptodev_aesni_mb_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_AESNI_MB_PMD,
"max_nb_queue_pairs= "
"max_nb_sessions= "
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c 
b/drivers/crypto/kasumi/rte_kasumi_pmd.c
index 11bbf80..b119da2 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c
@@ -656,6 +656,7 @@ static struct rte_vdev_driver cryptodev_kasumi_pmd_drv = {
 };

 RTE_PMD_REGISTER_VDEV(CRYPTODEV_NAME_KASUMI_PMD, cryptodev_kasumi_pmd_drv);
+RTE_PMD_REGISTER_ALIAS(CRYPTODEV_NAME_KASUMI_PMD, cryptodev_kasumi_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_KASUMI_PMD,
"max_nb_queue_pairs= "
"max_nb_sessions= "
diff --git a/drivers/crypto/null/null_crypto_pmd.c 
b/drivers/crypto/null/null_crypto_pmd.c
index a7d3600..c69606b 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -274,6 +274,7 @@ static struct rte_vdev_driver cryptodev_null_pmd_drv = {
 };

 RTE_PMD_REGISTER_VDEV(CRYPTODEV_NAME_NULL_PMD, cryptodev_null_pmd_drv);
+RTE_PMD_REGISTER_ALIAS(CRYPTODEV_NAME_NULL_PMD, cryptodev_null_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_NULL_PMD,
"max_nb_queue_pairs= "
"max_nb_sessions= "
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c 
b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index a794251..3b4292a 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -644,6 +644,7 @@ static struct rte_vdev_driver cryptodev_snow3g_pmd_drv = {
 };

 RTE_PMD_REGISTER_VDEV(CRYPTODEV_NAME_SNOW3G_PMD, cryptodev_snow3g_pmd_drv);
+RTE_PMD_REGISTER_ALIAS(CRYPTODEV_NAME_SNOW3G_PMD, cryptodev_snow3g_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_SNOW3G_PMD,
"max_nb_queue_pairs= "
"max_nb_sessions= "
-- 
2.6.6



[dpdk-dev] [PATCH 1/3] mbuf: embedding timestamp into the packet

2016-10-20 Thread Jan Blunck
On Thu, Oct 20, 2016 at 4:03 AM, Oleg Kuporosov  wrote:
> Hello Konstantin,
>
>>
>> My vote also would be to have timestamp in the second cache line.
>> About moving seqn to the 2-nd cache line too - that's probably a fair point.
>
> It may impact throughput till ~6% for applications required such embedded
> Timestamps.
>
>> About the rest of the patch:
>> Do you really need to put that code into the PMDs itself?
>> Can't the same result be achieved by using RX callbacks?
>> Again that approach would work with any PMD and there would be no need
>> to modify PMD code itself.
>
> Correct, the approach with using callbacs 
> (rte_eth_timesync_read_[r|t]x_timestamp())
> Has also some Cons for this use case:
> - FSI needs the most accurate stamping as possible by reasons were described 
> in
> Cover letter

>From my experience this is only true if there is near-zero performance
impact. From my perspective this is only relevant if the used hardware
supports offloading of writing the timestamps. Everything else is a
huge impact if its unconditionally enabled.

The regulatory requirements are already covered by the exchange
protocols which means that timestamps are already present in the
network packet payload (generated by the exchange trading system
and/or the trading application itself). In the end it is the exchange
itself and its members that are regulated. I can see that this might
be interesting for exchange members allowing sponsored naked access
(for non-exchange members) to generate data that they are not
front-running their clients.

I doubt that this non-functional requirement is important enough to
sacrifice the functional requirement of supporting QinQ.

> - callback will be called from user app and so you have to take into account
> Difference between time when packet was released by NIC and callback call

Have you looked at using dedicated preallocated trace buffers that are
filled with timestamps values? This should work fine for getting some
inside into the latency between application readiness and the actual
time the burst happened.

Thanks,
Jan

> - such difference is not easy to estimate correctly due to dependency on CPU 
> type,
> Its frequency and current load conditions
> - even estimated it would be hard without additional performance penalty to 
> align
> Packet with timestamp, taking account that call may actually placed from
> Different thread or even process.
>
> It looks the least impacting and correct way is to have timestamp in rte_mbuf 
> and fill
> It in Rx burst procedure.
>
>> Another thing, that I am in doubt why to use system time?
>> Wouldn't raw HW TSC value (rte_rdtsc()) do here?
>
> System time is being used for periodic clock synchronization between wall
> clock and NIC to estimate NIC clock deviation. It is in assumption the system 
> itself is
> synchronized by PTP from master clock. It is run on context of control thread.
>
> Thanks,
> Oleg.


[dpdk-dev] [PATCH 2/2] drivers: register aliases for renamed VDEV drivers

2016-10-20 Thread Jan Blunck
This registers the legacy names of the driver being renamed in commit
2f45703c17acb943aaded9f79676fd56a72542b2.

Signed-off-by: Jan Blunck 
---
 drivers/net/af_packet/rte_eth_af_packet.c | 1 +
 drivers/net/bonding/rte_eth_bond_pmd.c| 1 +
 drivers/net/mpipe/mpipe_tilegx.c  | 2 ++
 drivers/net/null/rte_eth_null.c   | 1 +
 drivers/net/pcap/rte_eth_pcap.c   | 1 +
 drivers/net/ring/rte_eth_ring.c   | 1 +
 drivers/net/vhost/rte_eth_vhost.c | 1 +
 drivers/net/virtio/virtio_user_ethdev.c   | 1 +
 drivers/net/xenvirt/rte_eth_xenvirt.c | 1 +
 9 files changed, 10 insertions(+)

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c 
b/drivers/net/af_packet/rte_eth_af_packet.c
index 201c1be..ff45068 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -895,6 +895,7 @@ static struct rte_vdev_driver pmd_af_packet_drv = {
 };

 RTE_PMD_REGISTER_VDEV(net_af_packet, pmd_af_packet_drv);
+RTE_PMD_REGISTER_ALIAS(net_af_packet, eth_af_packet);
 RTE_PMD_REGISTER_PARAM_STRING(net_af_packet,
"iface= "
"qpairs= "
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index 9e38ec9..9df245e 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2560,6 +2560,7 @@ static struct rte_vdev_driver bond_drv = {
 };

 RTE_PMD_REGISTER_VDEV(net_bonding, bond_drv);
+RTE_PMD_REGISTER_ALIAS(net_bonding, eth_bond);

 RTE_PMD_REGISTER_PARAM_STRING(net_bonding,
"slave= "
diff --git a/drivers/net/mpipe/mpipe_tilegx.c b/drivers/net/mpipe/mpipe_tilegx.c
index adf299b..f00 100644
--- a/drivers/net/mpipe/mpipe_tilegx.c
+++ b/drivers/net/mpipe/mpipe_tilegx.c
@@ -1632,7 +1632,9 @@ static struct rte_vdev_driver pmd_mpipe_gbe_drv = {
 };

 RTE_PMD_REGISTER_VDEV(net_mpipe_xgbe, pmd_mpipe_xgbe_drv);
+RTE_PMD_REGISTER_ALIAS(net_mpipe_xgbe, xgbe);
 RTE_PMD_REGISTER_VDEV(net_mpipe_gbe, pmd_mpipe_gbe_drv);
+RTE_PMD_REGISTER_ALIAS(net_mpipe_gbe, gbe);

 static void __attribute__((constructor, used))
 mpipe_init_contexts(void)
diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 0b7cc37..836d982 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -692,6 +692,7 @@ static struct rte_vdev_driver pmd_null_drv = {
 };

 RTE_PMD_REGISTER_VDEV(net_null, pmd_null_drv);
+RTE_PMD_REGISTER_ALIAS(net_null, eth_null);
 RTE_PMD_REGISTER_PARAM_STRING(net_null,
"size= "
"copy=");
diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 0c4711d..0162f44 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -1065,6 +1065,7 @@ static struct rte_vdev_driver pmd_pcap_drv = {
 };

 RTE_PMD_REGISTER_VDEV(net_pcap, pmd_pcap_drv);
+RTE_PMD_REGISTER_ALIAS(net_pcap, eth_pcap);
 RTE_PMD_REGISTER_PARAM_STRING(net_pcap,
ETH_PCAP_RX_PCAP_ARG "= "
ETH_PCAP_TX_PCAP_ARG "= "
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index ee1fb76..6d2a8c1 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -629,5 +629,6 @@ static struct rte_vdev_driver pmd_ring_drv = {
 };

 RTE_PMD_REGISTER_VDEV(net_ring, pmd_ring_drv);
+RTE_PMD_REGISTER_ALIAS(net_ring, eth_ring);
 RTE_PMD_REGISTER_PARAM_STRING(net_ring,
ETH_RING_NUMA_NODE_ACTION_ARG "=name:node:action(ATTACH|CREATE)");
diff --git a/drivers/net/vhost/rte_eth_vhost.c 
b/drivers/net/vhost/rte_eth_vhost.c
index 6f58476..766d4ef 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -1244,6 +1244,7 @@ static struct rte_vdev_driver pmd_vhost_drv = {
 };

 RTE_PMD_REGISTER_VDEV(net_vhost, pmd_vhost_drv);
+RTE_PMD_REGISTER_ALIAS(net_vhost, eth_vhost);
 RTE_PMD_REGISTER_PARAM_STRING(net_vhost,
"iface= "
"queues=");
diff --git a/drivers/net/virtio/virtio_user_ethdev.c 
b/drivers/net/virtio/virtio_user_ethdev.c
index bfdc3d0..406beea 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -479,6 +479,7 @@ static struct rte_vdev_driver virtio_user_driver = {
 };

 RTE_PMD_REGISTER_VDEV(net_virtio_user, virtio_user_driver);
+RTE_PMD_REGISTER_ALIAS(net_virtio_user, virtio_user);
 RTE_PMD_REGISTER_PARAM_STRING(net_virtio_user,
"path= "
"mac= "
diff --git a/drivers/net/xenvirt/rte_eth_xenvirt.c 
b/drivers/net/xenvirt/rte_eth_xenvirt.c
index 5a897b9..c08a056 100644
--- a/drivers/net/xenvirt/rte_eth_xenvirt.c
+++ b/drivers/net/xenvirt/rte_eth_xenvirt.c
@@ -765,5 +765,6 @@ static struct rte_vdev_driver pmd_xenvirt_drv = {
 };

 RTE_PMD_REGISTER_VDEV(net_xenvirt, pmd_xenvirt_drv);
+RTE_PMD_REGISTER_ALIAS(net_xenvirt, eth_xenvirt);
 RTE_PMD_REGISTER_PARAM_STRING(net_xenvirt,
"mac=");
-- 
2.6.6



[dpdk-dev] [PATCH 1/2] drivers: add name alias registration for rte_driver

2016-10-20 Thread Jan Blunck
This adds infrastructure for drivers to allow being requested by an alias
so that a renamed driver can still get loaded by its legacy name.

Signed-off-by: Jan Blunck 
---
 lib/librte_eal/common/eal_common_vdev.c  | 8 
 lib/librte_eal/common/include/rte_dev.h  | 1 +
 lib/librte_eal/common/include/rte_vdev.h | 5 +
 3 files changed, 14 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_vdev.c 
b/lib/librte_eal/common/eal_common_vdev.c
index 8b05f50..0ff2377 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -79,6 +79,14 @@ rte_eal_vdev_init(const char *name, const char *args)
return driver->probe(name, args);
}

+   /* Give new names precedence over aliases. */
+   TAILQ_FOREACH(driver, _driver_list, next) {
+   if (driver->driver.alias &&
+   !strncmp(driver->driver.alias, name,
+   strlen(driver->driver.alias)))
+   return driver->probe(name, args);
+   }
+
RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
return -EINVAL;
 }
diff --git a/lib/librte_eal/common/include/rte_dev.h 
b/lib/librte_eal/common/include/rte_dev.h
index b3873bd..8840380 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -149,6 +149,7 @@ void rte_eal_device_remove(struct rte_device *dev);
 struct rte_driver {
TAILQ_ENTRY(rte_driver) next;  /**< Next in list. */
const char *name;   /**< Driver name. */
+   const char *alias;  /**< Driver alias. */
 };

 /**
diff --git a/lib/librte_eal/common/include/rte_vdev.h 
b/lib/librte_eal/common/include/rte_vdev.h
index 97260b2..ee5060e 100644
--- a/lib/librte_eal/common/include/rte_vdev.h
+++ b/lib/librte_eal/common/include/rte_vdev.h
@@ -83,13 +83,18 @@ void rte_eal_vdrv_unregister(struct rte_vdev_driver 
*driver);

 #define RTE_PMD_REGISTER_VDEV(nm, vdrv)\
 RTE_INIT(vdrvinitfn_ ##vdrv);\
+static const char * vdrvinit_ ## nm ## _alias;\
 static void vdrvinitfn_ ##vdrv(void)\
 {\
(vdrv).driver.name = RTE_STR(nm);\
+   (vdrv).driver.alias = vdrvinit_ ## nm ## _alias;\
rte_eal_vdrv_register();\
 } \
 RTE_PMD_EXPORT_NAME(nm, __COUNTER__)

+#define RTE_PMD_REGISTER_ALIAS(nm, alias)\
+static const char * vdrvinit_ ## nm ## _alias = RTE_STR(alias)
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.6.6



[dpdk-dev] [PATCH] drivers: make driver names consistent

2016-10-18 Thread Jan Blunck
On Tue, Oct 18, 2016 at 3:42 PM, Thomas Monjalon
 wrote:
> 2016-10-18 21:06, Yuanhan Liu:
>> On Tue, Oct 18, 2016 at 02:50:16PM +0200, Jan Blunck wrote:
>> > >From my understanding this is a massive API breakage. This forces all
>> > existing users of the virtual PMDs to change with zero benefit. Even
>> > if that isn't enough it also makes it impossible to switch between
>> > releases by recompiling.
>> >
>> > Can we please revert these changes and work on some aliasing support
>> > for the PMDs to fix it long term?
>>
>> +1. Aliasing is also something I would suggest before making such renames.
>
> It is a brutal change, yes.
> It was announced in 16.07 release notes though.
>

"But the plans were on display ..." (HHGTTG)

> We can try to make this change more progressive by keeping old names
> as aliases for some time.
> Is there a volunteer to work on vdev names aliases,
> with the target of integrating them in RC2 or RC3?
>

I'll give it a try ...


[dpdk-dev] [PATCH] Revert "bonding: use existing enslaved device queues"

2016-10-18 Thread Jan Blunck
On Tue, Oct 18, 2016 at 2:49 PM, Ilya Maximets  
wrote:
> On 18.10.2016 15:28, Jan Blunck wrote:
>> If the application already configured queues the PMD should not
>> silently claim ownership and reset them.
>>
>> What exactly is the problem when changing MTU? This works fine from
>> what I can tell.
>
> Following scenario leads to APP PANIC:
>
> 1. mempool_1 = rte_mempool_create()
> 2. rte_eth_rx_queue_setup(bond0, ..., mempool_1);
> 3. rte_eth_dev_start(bond0);
> 4. mempool_2 = rte_mempool_create();
> 5. rte_eth_dev_stop(bond0);
> 6. rte_eth_rx_queue_setup(bond0, ..., mempool_2);
> 7. rte_eth_dev_start(bond0);
> * RX queues still use 'mempool_1' because reconfiguration doesn't 
> affect them. *
> 8. rte_mempool_free(mempool_1);
> 9. On any rx operation we'll get PANIC because of using freed 
> 'mempool_1':
>  PANIC in rte_mempool_get_ops():
>  assert "(ops_index >= 0) && (ops_index < RTE_MEMPOOL_MAX_OPS_IDX)" 
> failed
>
> You may just start OVS 2.6 with DPDK bonding device and attempt to change MTU 
> via 'mtu_request'.
> Bug is easily reproducible.
>

I see. I'm not 100% that this is expected to work without leaking the
driver's queues though. The driver is allowed to do allocations in
its rx_queue_setup() function that are being freed via
rx_queue_release() later. But rx_queue_release() is only called if you
reconfigure the
device with 0 queues. From what I understand there is no other way to
reconfigure a device to use another mempool.

But ... even that wouldn't work with the bonding driver right now: the
bonding master only configures the slaves during startup. I can put
that on my todo list.

Coming back to your original problem: changing the MTU for the bond
does work through rte_eth_dev_set_mtu() for slaves supporting that. In
any other case you could (re-)configure rxmode.max_rx_pkt_len (and
jumbo_frame / enable_scatter accordingly). This does work without a
call to rte_eth_rx_queue_setup().

Hope this helps,
Jan

> Best regards, Ilya Maximets.
>
>>
>> On Wed, Sep 7, 2016 at 2:28 PM, Ilya Maximets  
>> wrote:
>>> This reverts commit 5b7bb2bda5519b7800f814df64d4e015282140e5.
>>>
>>> It is necessary to reconfigure all queues every time because configuration
>>> can be changed.
>>>
>>> For example, if we're reconfiguring bonding device with new memory pool,
>>> already configured queues will still use the old one. And if the old
>>> mempool be freed, application likely will panic in attempt to use
>>> freed mempool.
>>>
>>> This happens when we use the bonding device with OVS 2.6 while MTU
>>> reconfiguration:
>>>
>>> PANIC in rte_mempool_get_ops():
>>> assert "(ops_index >= 0) && (ops_index < RTE_MEMPOOL_MAX_OPS_IDX)" failed
>>>
>>> Cc: 
>>> Signed-off-by: Ilya Maximets 
>>> ---
>>>  drivers/net/bonding/rte_eth_bond_pmd.c | 10 ++
>>>  1 file changed, 2 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
>>> b/drivers/net/bonding/rte_eth_bond_pmd.c
>>> index b20a272..eb5b6d1 100644
>>> --- a/drivers/net/bonding/rte_eth_bond_pmd.c
>>> +++ b/drivers/net/bonding/rte_eth_bond_pmd.c
>>> @@ -1305,8 +1305,6 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
>>> struct bond_rx_queue *bd_rx_q;
>>> struct bond_tx_queue *bd_tx_q;
>>>
>>> -   uint16_t old_nb_tx_queues = slave_eth_dev->data->nb_tx_queues;
>>> -   uint16_t old_nb_rx_queues = slave_eth_dev->data->nb_rx_queues;
>>> int errval;
>>> uint16_t q_id;
>>>
>>> @@ -1347,9 +1345,7 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
>>> }
>>>
>>> /* Setup Rx Queues */
>>> -   /* Use existing queues, if any */
>>> -   for (q_id = old_nb_rx_queues;
>>> -q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
>>> +   for (q_id = 0; q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
>>> bd_rx_q = (struct bond_rx_queue 
>>> *)bonded_eth_dev->data->rx_queues[q_id];
>>>
>>> errval = 
>>> rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, q_id,
>>> @@ -1365,9 +1361,7 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
>>> }
>>>
>>> /* Setup Tx Queues */
>>> -   /* Use existing queues, if any */
>>> -   for (q_id = old_nb_tx_queues;
>>> -q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
>>> +   for (q_id = 0; q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
>>> bd_tx_q = (struct bond_tx_queue 
>>> *)bonded_eth_dev->data->tx_queues[q_id];
>>>
>>> errval = 
>>> rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, q_id,
>>> --
>>> 2.7.4
>>>
>>
>>
>>


[dpdk-dev] [PATCH] drivers: make driver names consistent

2016-10-18 Thread Jan Blunck
>From my understanding this is a massive API breakage. This forces all
existing users of the virtual PMDs to change with zero benefit. Even
if that isn't enough it also makes it impossible to switch between
releases by recompiling.

Can we please revert these changes and work on some aliasing support
for the PMDs to fix it long term?

Thanks,
Jan


On Fri, Sep 16, 2016 at 11:58 AM, Thomas Monjalon
 wrote:
> 2016-08-24 22:37, Mcnamara, John:
>> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Pablo de Lara
>> >
>> > ...
>> >
>> > -$RTE_TARGET/app/testpmd -c '0xf' -n 4 --vdev 
>> > 'eth_pcap0,rx_pcap=/path/to/ file_rx.pcap,tx_pcap=/path/to/file_tx.pcap' 
>> > -- --port-topology=chained
>> > +$RTE_TARGET/app/testpmd -c '0xf' -n 4 --vdev 
>> > 'net_pcap0,rx_pcap=/path/to/ file_rx.pcap,tx_pcap=/path/to/file_tx.pcap' 
>> > -- --port-topology=chained
>>
>>
>> I know that this is an existing issue but there shouldn't be a space in
>> "/path/to/ file". Perhaps you could fix that (in a number of places) as part
>> of this patch. You could probably leave out the "/path/to/" part altogether 
>> as
>> it may be clearer, see below.
>>
>> Also, could you wrap the long code lines in the sections that you change at
>> 80 chars using "\" to keep them on the page in the PDF docs, like:
>>
>> $RTE_TARGET/app/testpmd -c '0xf' -n 4 \
>> --vdev 
>> 'net_pcap0,rx_pcap=/path/to/file_rx.pcap,tx_pcap=/path/to/file_tx.pcap' \
>> -- --port-topology=chained
>>
>> Or without the path part:
>>
>> $RTE_TARGET/app/testpmd -c '0xf' -n 4 \
>> --vdev 'net_pcap0,rx_pcap=file_rx.pcap,tx_pcap=file_tx.pcap' \
>> -- --port-topology=chained
>
> Applied with above comments fixed and release notes updated, thanks.


[dpdk-dev] [PATCH] Revert "bonding: use existing enslaved device queues"

2016-10-18 Thread Jan Blunck
If the application already configured queues the PMD should not
silently claim ownership and reset them.

What exactly is the problem when changing MTU? This works fine from
what I can tell.

Cheers,
Jan

On Wed, Sep 7, 2016 at 2:28 PM, Ilya Maximets  wrote:
> This reverts commit 5b7bb2bda5519b7800f814df64d4e015282140e5.
>
> It is necessary to reconfigure all queues every time because configuration
> can be changed.
>
> For example, if we're reconfiguring bonding device with new memory pool,
> already configured queues will still use the old one. And if the old
> mempool be freed, application likely will panic in attempt to use
> freed mempool.
>
> This happens when we use the bonding device with OVS 2.6 while MTU
> reconfiguration:
>
> PANIC in rte_mempool_get_ops():
> assert "(ops_index >= 0) && (ops_index < RTE_MEMPOOL_MAX_OPS_IDX)" failed
>
> Cc: 
> Signed-off-by: Ilya Maximets 
> ---
>  drivers/net/bonding/rte_eth_bond_pmd.c | 10 ++
>  1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
> b/drivers/net/bonding/rte_eth_bond_pmd.c
> index b20a272..eb5b6d1 100644
> --- a/drivers/net/bonding/rte_eth_bond_pmd.c
> +++ b/drivers/net/bonding/rte_eth_bond_pmd.c
> @@ -1305,8 +1305,6 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
> struct bond_rx_queue *bd_rx_q;
> struct bond_tx_queue *bd_tx_q;
>
> -   uint16_t old_nb_tx_queues = slave_eth_dev->data->nb_tx_queues;
> -   uint16_t old_nb_rx_queues = slave_eth_dev->data->nb_rx_queues;
> int errval;
> uint16_t q_id;
>
> @@ -1347,9 +1345,7 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
> }
>
> /* Setup Rx Queues */
> -   /* Use existing queues, if any */
> -   for (q_id = old_nb_rx_queues;
> -q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
> +   for (q_id = 0; q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
> bd_rx_q = (struct bond_rx_queue 
> *)bonded_eth_dev->data->rx_queues[q_id];
>
> errval = rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, 
> q_id,
> @@ -1365,9 +1361,7 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
> }
>
> /* Setup Tx Queues */
> -   /* Use existing queues, if any */
> -   for (q_id = old_nb_tx_queues;
> -q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
> +   for (q_id = 0; q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
> bd_tx_q = (struct bond_tx_queue 
> *)bonded_eth_dev->data->tx_queues[q_id];
>
> errval = rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, 
> q_id,
> --
> 2.7.4
>


[dpdk-dev] DPDK on Xen maintenance

2016-07-13 Thread Jan Blunck
On Di, 2016-07-12 at 11:34 +0200, Thomas Monjalon wrote:
> Hi all,
> 
> We are facing some issues with Xen dom0.
> Some were fixed in RC2:
>   https://urldefense.proofpoint.com/v2/url?u=http-3A__dpdk.org_ml
> _archives_dev_2016-
> 2DJuly_043760.html=CwICAg=IL_XqQWOjubgfqINi2jTzg=eGq7Pg5OSP440n
> QUcjb02I48YXd7Ce6OiSj9BMaGZiE=98n7rM-Tjze4nm2MUpU8Etvo5lAB-
> oe0KXsst27ujkw=AHzBPDmKhqbsIc8pb2x_s7ShJvDhf93AsXRAm43EXlM=?
> and there still have some other issues.
> 
> It seems Xen is becoming less attractive:
>   - we do not have a lot of test reports or feedbacks
>   - there is no maintainer for DPDK on Xen
>   - we are still waiting for the Xen netfront PMD
> 

Although progress is slow I'm still working on upstreaming the Xen
netfront PMD. I will continue to maintain it afterwards of course.


> I wonder wether it still makes sense to maintain this code or not?
> In case of positive reply, it would be nice to have the name of
> someone responsible for this code, i.e. a maintainer.
> 
> Thanks


[dpdk-dev] [PATCH v3 1/3] xen: Add UIO kernel driver

2016-03-22 Thread Jan Blunck
On Tue, Mar 22, 2016 at 12:27 PM, Thomas Monjalon
 wrote:
> 2016-03-22 12:04, Jan Blunck:
>> On Tue, Mar 22, 2016 at 11:42 AM, Thomas Monjalon
>>  wrote:
>> > 2016-03-22 10:55, Jan Blunck:
>> >> New UIO helper kernel driver for Xen netfront UIO poll mode driver.
>> >>
>> >> Signed-off-by: Stephen Hemminger 
>> >> Signed-off-by: Jan Blunck 
>> >
>> > Is it contributed upstream?
>>
>> No. Haven't planed that yet.
>
> Integrating new kernel modules in DPDK, without upstream work,
> is not planned.
>

I'll look into the existing Linux kernel netfront driver and check if
upstream is actually willing to integrate the UIO part.

>> > Is there something common with igb_uio?
>>
>> AFAIK igb_uio is mapping the bars via UIO. The Xen netfront driver
>> isn't simulating a PCI interface. Instead it directly maps the TX/RX
>> ring.
>>
>> Overlap is limited to reading sysfs files. Don't know if that is worth
>> being extracted into a standalone header.
>
> No it is not worth extracting. I'm just trying to understand what this
> module is, because the log doesn't say much.
>

I can address that for the upstream submission and drop it from this series.


[dpdk-dev] [PATCH v3 1/3] xen: Add UIO kernel driver

2016-03-22 Thread Jan Blunck
On Tue, Mar 22, 2016 at 11:42 AM, Thomas Monjalon
 wrote:
> 2016-03-22 10:55, Jan Blunck:
>> New UIO helper kernel driver for Xen netfront UIO poll mode driver.
>>
>> Signed-off-by: Stephen Hemminger 
>> Signed-off-by: Jan Blunck 
>
> Is it contributed upstream?

No. Haven't planed that yet.

> Is there something common with igb_uio?

AFAIK igb_uio is mapping the bars via UIO. The Xen netfront driver
isn't simulating a PCI interface. Instead it directly maps the TX/RX
ring.

Overlap is limited to reading sysfs files. Don't know if that is worth
being extracted into a standalone header.


[dpdk-dev] [PATCH v3 2/3] xen: Add netfront poll mode driver

2016-03-22 Thread Jan Blunck
On Tue, Mar 22, 2016 at 11:07 AM, David Marchand
 wrote:
> Hello,
>
> On Tue, Mar 22, 2016 at 10:55 AM, Jan Blunck  wrote:
>> +static struct eth_dev_ops xen_eth_dev_ops = {
>> +   /*dev*/
>> +   .dev_configure= xen_dev_configure,
>> +   .dev_close= xen_dev_close,
>> +   .dev_start= xen_dev_start,
>> +   .dev_stop = xen_dev_stop,
>> +   .dev_infos_get= xen_dev_info_get,
>> +   .link_update  = xen_dev_link_update,
>> +   /*rxtx*/
>> +   .stats_get= xen_dev_stats_get,
>> +   .stats_reset  = xen_dev_stats_reset,
>> +   .rx_queue_setup   = xen_dev_rx_queue_setup,
>> +   .rx_queue_release = xen_dev_rx_queue_release,
>> +   .tx_queue_setup   = xen_dev_tx_queue_setup,
>> +   .tx_queue_release = xen_dev_tx_queue_release,
>> +};
>
> Is there anything preventing it from being const ?
>

I don't think so. Will constify it for the next round.

Thanks,
Jan

>
> --
> David Marchand


[dpdk-dev] [PATCH v3 3/3] xen: Add documentation

2016-03-22 Thread Jan Blunck
Add basic documentation for Xen Netfront PMD compilation and testpmd
invocation.

Signed-off-by: Jan Blunck 
---
 doc/guides/nics/overview.rst |  28 ++--
 doc/guides/nics/xen.rst  | 101 +++
 2 files changed, 115 insertions(+), 14 deletions(-)
 create mode 100644 doc/guides/nics/xen.rst

diff --git a/doc/guides/nics/overview.rst b/doc/guides/nics/overview.rst
index 2d4f014..de07390 100644
--- a/doc/guides/nics/overview.rst
+++ b/doc/guides/nics/overview.rst
@@ -74,18 +74,18 @@ Most of these differences are summarized below.

 .. table:: Features availability in networking drivers

-    = = = = = = = = = = = = = = = = = = = = = = = = = = = 
= = = =
-   Feature  a b b b c e e i i i i i i i i i i f f m m m n n p r s 
v v v x
-f n n o x 1 n 4 4 4 4 g g x x x x m m l l p f u c i z 
i i m e
-p x x n g 0 i 0 0 0 0 b b g g g g 1 1 x x i p l a n e 
r r x n
-a 2 2 d b 0 c e e e e   v b b b b 0 0 4 5 p   l p g d 
t t n v
-c x x i e 0 . v v   f e e e e k k e a 
i i e i
-k   v n . f f   . v v   .   t 
o o t r
-e   f g .   .   . f f   .   a  
 . 3 t
+    = = = = = = = = = = = = = = = = = = = = = = = = = = = 
= = = = =
+   Feature  a b b b c e e i i i i i i i i i i f f m m m n n p r s 
v v v x x
+f n n o x 1 n 4 4 4 4 g g x x x x m m l l p f u c i z 
i i m e e
+p x x n g 0 i 0 0 0 0 b b g g g g 1 1 x x i p l a n e 
r r x n n
+a 2 2 d b 0 c e e e e   v b b b b 0 0 4 5 p   l p g d 
t t n   v
+c x x i e 0 . v v   f e e e e k k e a 
i i e   i
+k   v n . f f   . v v   .   t 
o o t   r
+e   f g .   .   . f f   .   a  
 . 3   t
 t   v   v   v   v   v   2  
 v
 e   e   e   e   e  
 e
 c   c   c   c   c  
 c
-    = = = = = = = = = = = = = = = = = = = = = = = = = = = 
= = = =
+    = = = = = = = = = = = = = = = = = = = = = = = = = = = 
= = = = =
link status  X X X   X
link status event  X X
Rx interrupt   X X X X
@@ -125,23 +125,23 @@ Most of these differences are summarized below.
inner L4 checksum  X   X
packet type parsing  X X   X
timesync   X X
-   basic stats  X X X X X   X
+   basic stats  X X X X X   X  
 X
extended stats X X X X
stats per queue  X   X
EEPROM dump
registers dump
multiprocess aware X X X X
BSD nic_uio  X X X X X
-   Linux UIOX X X X X
+   Linux UIOX X X X X  
 X
Linux VFIO   X X X X X
other kdrv   X
ARMv7
ARMv8
Power8
TILE-Gx
-   x86-32   X X X X X
-   x86-64   X X X X X   X
+   x86-32   X X X X X  
 X
+   x86-64   X X X X X   X  
 X
usage docX   X
design doc
perf doc
-    = = = = = = = = = = = = = = = = = = = = = = = = = = = 
= = = =
+    = = = = = = = = = = = = = = = = = = = = = = = = = = = 
= = = = =
diff --git a/doc/guides/nics/xen.rst b/doc/guides/nics/xen.rst
new file mode 100644
index 000..4e4531e
--- /dev/null
+++ b/doc/guides/nics/xen.rst
@@ -0,0 +1,101 @@
+..  BSD LICENSE
+Copyright(c) 2016 Brocade Communications Systems, Inc.
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+* Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in
+the documentation and/or other materials provided with the
+distribution.
+* Neither

[dpdk-dev] [PATCH v3 2/3] xen: Add netfront poll mode driver

2016-03-22 Thread Jan Blunck
This implements a poll mode driver that has the same functionality as
the Xen netfront driver in the Linux kernel.

Signed-off-by: Stephen Hemminger 
Signed-off-by: Jan Blunck 
---
 config/common_base |   6 +
 drivers/net/Makefile   |   1 +
 drivers/net/xen/Makefile   |  30 ++
 drivers/net/xen/uio.c  | 245 
 drivers/net/xen/uio.h  |  54 +++
 drivers/net/xen/xen_adapter_info.h |  64 
 drivers/net/xen/xen_dev.c  | 489 
 drivers/net/xen/xen_dev.h  |  30 ++
 drivers/net/xen/xen_logs.h |  19 +
 drivers/net/xen/xen_rxtx.c | 757 +
 drivers/net/xen/xen_rxtx.h | 131 +++
 11 files changed, 1826 insertions(+)
 create mode 100644 drivers/net/xen/Makefile
 create mode 100644 drivers/net/xen/uio.c
 create mode 100644 drivers/net/xen/uio.h
 create mode 100644 drivers/net/xen/xen_adapter_info.h
 create mode 100644 drivers/net/xen/xen_dev.c
 create mode 100644 drivers/net/xen/xen_dev.h
 create mode 100644 drivers/net/xen/xen_logs.h
 create mode 100644 drivers/net/xen/xen_rxtx.c
 create mode 100644 drivers/net/xen/xen_rxtx.h

diff --git a/config/common_base b/config/common_base
index dbd405b..36e4b59 100644
--- a/config/common_base
+++ b/config/common_base
@@ -306,6 +306,12 @@ CONFIG_RTE_LIBRTE_PMD_AF_PACKET=n
 CONFIG_RTE_LIBRTE_PMD_XENVIRT=n

 #
+# Compile XEN UIO net-front PMD driver
+#
+CONFIG_RTE_LIBRTE_PMD_XEN=n
+CONFIG_RTE_LIBRTE_PMD_XEN_DEBUG_INIT=n
+
+#
 # Compile null PMD
 #
 CONFIG_RTE_LIBRTE_PMD_NULL=y
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 0c3393f..003e51b 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -51,5 +51,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2) += szedata2
 DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio
 DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += vmxnet3
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += xenvirt
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_XEN) += xen

 include $(RTE_SDK)/mk/rte.subdir.mk
diff --git a/drivers/net/xen/Makefile b/drivers/net/xen/Makefile
new file mode 100644
index 000..9e75157
--- /dev/null
+++ b/drivers/net/xen/Makefile
@@ -0,0 +1,30 @@
+#
+#   Copyright (c) 2013-2016 Brocade Communications Systems, Inc.
+#   All rights reserved.
+#
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_pmd_xen.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+VPATH += $(RTE_SDK)/drivers/net/xen
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_XEN) += uio.c
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_XEN) += xen_dev.c
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_XEN) += xen_rxtx.c
+
+# this lib depends upon:
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_XEN) += lib/librte_eal lib/librte_ether
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_XEN) += lib/librte_mempool lib/librte_mbuf
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_XEN) += lib/librte_net lib/librte_malloc
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/drivers/net/xen/uio.c b/drivers/net/xen/uio.c
new file mode 100644
index 000..54e10b9
--- /dev/null
+++ b/drivers/net/xen/uio.c
@@ -0,0 +1,245 @@
+/*
+ * Copyright (c) 2013-2016 Brocade Communications Systems, Inc.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include "uio.h"
+
+#define SYSFS_DEVICES_PATH "/sys/devices"
+#define SYSFS_CLASS_UIO_PATH "/sys/class/uio"
+
+int
+sysfs_device_get_uio_num(const char *device)
+{
+   DIR *dir;
+   struct dirent *e;
+   char path[PATH_MAX];
+   unsigned long uio_num;
+
+   snprintf(path, sizeof(path), "%s/%s/uio", SYSFS_DEVICES_PATH, device);
+   dir = opendir(path);
+   if (!dir)
+   return -errno;
+
+   while ((e = readdir(dir)) != NULL) {
+   char *endptr;
+
+   if (strncmp(e->d_name, "uio", 3) != 0)
+   continue;
+
+   uio_num = strtoul(e->d_name + 3, , 10);
+   if (endptr == e->d_name || *endptr != '\0' ||
+   uio_num == ULONG_MAX)
+   continue;
+
+   RTE_LOG(DEBUG, PMD, "%s uio_num = %lu\n", device, uio_num);
+   break;
+   }
+
+   closedir(dir);
+
+   if (!e)
+   return -ENODEV;
+
+   if (uio_num > 255)
+   return -EINVAL;
+
+   return (int)uio_num;
+}
+
+static int
+sysfs_get_buffer(const char *filename, char *buf, size_t bufsize)
+{
+   FILE *f;
+   char *ptr;
+
+   f = fopen(filename, "r");
+   if (!f) {
+   RTE_LOG(ERR, EAL, "cannot open sysfs file %s\n", filename);
+   return -1;
+   }
+
+   ptr = fgets(buf, bufsize, f);
+   fclose(f);
+   if (!ptr) {
+   RTE_LOG(ERR, EAL, "cannot read sysfs file %s\n", filename);
+   return -1;
+   }
+
+   

[dpdk-dev] [PATCH v3 1/3] xen: Add UIO kernel driver

2016-03-22 Thread Jan Blunck
New UIO helper kernel driver for Xen netfront UIO poll mode driver.

Signed-off-by: Stephen Hemminger 
Signed-off-by: Jan Blunck 
---
 lib/librte_eal/linuxapp/Makefile  |   1 +
 lib/librte_eal/linuxapp/xen_uio/Makefile  |  56 ++
 lib/librte_eal/linuxapp/xen_uio/compat.h  |  47 ++
 lib/librte_eal/linuxapp/xen_uio/xen_uio.c | 954 ++
 4 files changed, 1058 insertions(+)
 create mode 100644 lib/librte_eal/linuxapp/xen_uio/Makefile
 create mode 100644 lib/librte_eal/linuxapp/xen_uio/compat.h
 create mode 100644 lib/librte_eal/linuxapp/xen_uio/xen_uio.c

diff --git a/lib/librte_eal/linuxapp/Makefile b/lib/librte_eal/linuxapp/Makefile
index 20d2a91..6b33e87 100644
--- a/lib/librte_eal/linuxapp/Makefile
+++ b/lib/librte_eal/linuxapp/Makefile
@@ -35,5 +35,6 @@ DIRS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal
 DIRS-$(CONFIG_RTE_EAL_IGB_UIO) += igb_uio
 DIRS-$(CONFIG_RTE_KNI_KMOD) += kni
 DIRS-$(CONFIG_RTE_LIBRTE_XEN_DOM0) += xen_dom0
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_XEN) += xen_uio

 include $(RTE_SDK)/mk/rte.subdir.mk
diff --git a/lib/librte_eal/linuxapp/xen_uio/Makefile 
b/lib/librte_eal/linuxapp/xen_uio/Makefile
new file mode 100644
index 000..936e8bf
--- /dev/null
+++ b/lib/librte_eal/linuxapp/xen_uio/Makefile
@@ -0,0 +1,56 @@
+#   BSD LICENSE
+#
+#   Copyright (c) 2013-2016 Brocade Communications Systems, Inc.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution.
+# * Neither the name of Intel Corporation nor the names of its
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# module name and path
+#
+MODULE = xen_uio
+MODULE_PATH = drivers/net//xen_uio
+
+#
+# CFLAGS
+#
+MODULE_CFLAGS += -I$(SRCDIR) --param max-inline-insns-single=100
+MODULE_CFLAGS += -I$(RTE_OUTPUT)/include
+MODULE_CFLAGS += -Winline -Wall -Werror
+MODULE_CFLAGS += -include $(RTE_OUTPUT)/include/rte_config.h
+MODULE_CFLAGS += -I$(RTE_SDK)
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-y := xen_uio.c
+
+
+include $(RTE_SDK)/mk/rte.module.mk
diff --git a/lib/librte_eal/linuxapp/xen_uio/compat.h 
b/lib/librte_eal/linuxapp/xen_uio/compat.h
new file mode 100644
index 000..b4f30d9
--- /dev/null
+++ b/lib/librte_eal/linuxapp/xen_uio/compat.h
@@ -0,0 +1,47 @@
+/*
+ * Minimal wrappers to allow compiling xen_uio on older kernels.
+ *
+ * Copyright (c) 2016 Brocade Communications Systems, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _XEN_UIO_COMPAT_H_
+#define _XEN_UIO_COMPAT_H_
+
+#include 
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
+#define INVALID_GRANT_HANDLE   (~0U)
+
+static inline int compat_xenbus_grant_ring(struct xenbus_device *dev,
+  void *vaddr,
+  unsigned int nr_pages,
+  grant_ref_t *grefs)
+{
+   int ret;
+
+   ret = xenbus_grant_ring(dev, virt_to_mfn(vaddr));
+
+   if (ret >= 0)
+   *grefs = ret

[dpdk-dev] [PATCH v3 0/3] xen: netfront poll mode driver

2016-03-22 Thread Jan Blunck
v3 changes:
- removed fake PCI interface
- removed struct virt_eth_driver
- check for UIO name and version
- added basic documentation

Jan Blunck (3):
  xen: Add UIO kernel driver
  xen: Add netfront poll mode driver
  xen: Add documentation

 config/common_base|   6 +
 doc/guides/nics/overview.rst  |  28 +-
 doc/guides/nics/xen.rst   | 101 
 drivers/net/Makefile  |   1 +
 drivers/net/xen/Makefile  |  30 +
 drivers/net/xen/uio.c | 245 
 drivers/net/xen/uio.h |  54 ++
 drivers/net/xen/xen_adapter_info.h|  64 ++
 drivers/net/xen/xen_dev.c | 489 +++
 drivers/net/xen/xen_dev.h |  30 +
 drivers/net/xen/xen_logs.h|  19 +
 drivers/net/xen/xen_rxtx.c| 757 
 drivers/net/xen/xen_rxtx.h| 131 
 lib/librte_eal/linuxapp/Makefile  |   1 +
 lib/librte_eal/linuxapp/xen_uio/Makefile  |  56 ++
 lib/librte_eal/linuxapp/xen_uio/compat.h  |  47 ++
 lib/librte_eal/linuxapp/xen_uio/xen_uio.c | 954 ++
 17 files changed, 2999 insertions(+), 14 deletions(-)
 create mode 100644 doc/guides/nics/xen.rst
 create mode 100644 drivers/net/xen/Makefile
 create mode 100644 drivers/net/xen/uio.c
 create mode 100644 drivers/net/xen/uio.h
 create mode 100644 drivers/net/xen/xen_adapter_info.h
 create mode 100644 drivers/net/xen/xen_dev.c
 create mode 100644 drivers/net/xen/xen_dev.h
 create mode 100644 drivers/net/xen/xen_logs.h
 create mode 100644 drivers/net/xen/xen_rxtx.c
 create mode 100644 drivers/net/xen/xen_rxtx.h
 create mode 100644 lib/librte_eal/linuxapp/xen_uio/Makefile
 create mode 100644 lib/librte_eal/linuxapp/xen_uio/compat.h
 create mode 100644 lib/librte_eal/linuxapp/xen_uio/xen_uio.c

-- 
2.5.5



[dpdk-dev] [PATCH v3 8/8] mk: Add rule for installing runtime files

2015-10-12 Thread Jan Blunck
On Fri, Oct 2, 2015 at 12:15 PM, Panu Matilainen  wrote:
> On 10/01/2015 03:11 AM, Mario Carrillo wrote:
>>
>> Add hierarchy-file support to the DPDK libraries, modules,
>> binary files, nic bind files and documentation,
>> when invoking "make install-fhs" (filesystem hierarchy standard)
>> runtime files will be by default installed in:
>> $(DESTDIR)/$(BIN_DIR) where BIN_DIR=/usr/bin (binary files)
>> $(DESTDIR)/$(SBIN_DIR) where SBIN_DIR=/usr/sbin/dpdk_nic_bind (nic bind
>> files)
>> $(DESTDIR)/$(DOC_DIR) where DOC_DIR=/usr/share/doc/dpdk (documentation)
>> $(DESTDIR)/$(LIB_DIR)  (libraries)
>> if the architecture is 64 bits then LIB_DIR=/usr/lib64
>> else LIB_DIR=/usr/lib
>> $(DESTDIR)/$(KERNEL_DIR) (modules)
>> if RTE_EXEC_ENV=linuxapp then
>> KERNEL_DIR=/lib/modules/$(uname -r)/build
>> else KERNEL_DIR=/boot/modules
>> All directory variables mentioned above can be overridden.
>> This hierarchy is based on:
>> http://www.freedesktop.org/software/systemd/man/file-hierarchy.html
>>
>
> Hmm, I think there's a slight misunderstanding here.
>
> What I meant earlier by install-sdk and install-fhs is to preserve the
> current behavior of "make install" as "make install-sdk" and have "make
> install-fhs" behave like normal OSS app on "make install", which installs
> everything (both devel and runtime parts)

>From my point of view it would make sense let 'make install' do the
right thing from
a user perspective (application, library, distribution). The standard
workflow of 'make install'
is well known and supported by many build environments.

One way that could work is to detect the fact that the SDK files are
already installed (e.g.
via $RTE_SDK != $(pwd) ) and in that case skipping the install of them.

Thanks,
Jan

> This patch series eliminates the current behavior of "make install"
> entirely. I personally would not miss it at all, but there likely are people
> relying on it since its quite visibly documented and all. So I think the
> idea was to introduce a separate FHS-installation target and then deal with
> the notion of default behaviors etc separately.
>
> I guess it was already this way in v2 of the series, apologies for missing
> it there.
>
> - Panu -


[dpdk-dev] [PATCH] Make bond_ethdev_stop iterate only over active slaves

2015-06-24 Thread Jan Blunck
When stopping the bond device we don't need to try and free up the LACPDU's
from deactivated devices since this is covered by
bond_mode_8023ad_deactivate_slave().

This fixes the following:
[0.100569] PANIC in bond_ethdev_stop():
[0.100589] line 1172assert "port->rx_ring != NULL" failed

Signed-off-by: Jan Blunck 
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index 5a2fbef..1fd1321 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -1520,8 +1520,8 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev)
bond_mode_8023ad_stop(eth_dev);

/* Discard all messages to/from mode 4 state machines */
-   for (i = 0; i < internals->slave_count; i++) {
-   port = _8023ad_ports[internals->slaves[i].port_id];
+   for (i = 0; i < internals->active_slave_count; i++) {
+   port = _8023ad_ports[internals->active_slaves[i]];

RTE_VERIFY(port->rx_ring != NULL);
while (rte_ring_dequeue(port->rx_ring, ) != -ENOENT)
-- 
2.1.4



[dpdk-dev] [PATCH] log: Properly reset log_history_size in rte_log_dump_history()

2015-06-01 Thread Jan Blunck
On Mon, Jun 1, 2015 at 10:31 AM, Olivier MATZ 
wrote:

> Hi Jan,
>
> On 05/29/2015 12:34 PM, Jan Blunck wrote:
> > In rte_log_dump_history() the log_history list is reinitialized without
> > resetting the log_history_size. In the next call to
> rte_log_add_in_history()
> > the log_history_size > RTE_LOG_HISTORY and the code unconditionally tries
> > to remove the first entry:
> >
> > Program received signal SIGSEGV, Segmentation fault.
> > rte_log_add_in_history (
> > buf=buf at entry=0x7f02035cd000 "DATAPLANE: 9:dp0s7 link RTM_NEWLINK
> [dp0s7] <UP,BROADCAST,RUNNING,MULTICAST,LOWER_UP>\nCAST,LOWER_UP>\n",
> size=size at entry=86)
> > at /usr/src/packages/BUILD/lib/librte_eal/common/eal_common_log.c:122
> >
> > Signed-off-by: Jan Blunck 
> > ---
> >  lib/librte_eal/common/eal_common_log.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/librte_eal/common/eal_common_log.c
> b/lib/librte_eal/common/eal_common_log.c
> > index fe3d7d5..cb4311c 100644
> > --- a/lib/librte_eal/common/eal_common_log.c
> > +++ b/lib/librte_eal/common/eal_common_log.c
> > @@ -119,7 +119,8 @@ rte_log_add_in_history(const char *buf, size_t size)
> >   /* get a buffer for adding in history */
> >   if (log_history_size > RTE_LOG_HISTORY) {
> >   hist_buf = STAILQ_FIRST(_history);
> > - STAILQ_REMOVE_HEAD(_history, next);
> > + if (hist_buf)
> > + STAILQ_REMOVE_HEAD(_history, next);
>
> Shouldn't we decrease log_history_size here?
>
>
Thanks for catching that one.


>
>
> Also, it's probably a bit off-topic, but I think the function that
> adds in history could be optimized a bit to avoid doing the copy with
> the lock held. Maybe something like this is feasible:
>
> rte_mempool_mc_get() into hist_buf
> memcpy(hist_buf->buf, buf, size);
> rte_spinlock_lock(_list_lock
> if (log_history_size > RTE_LOG_HISTORY) {
> STAILQ_REMOVE_HEAD
> log_history_size --
> }
> STAILQ_INSERT_TAIL
> log_history_size ++
> rte_spinlock_unlock(_list_lock)
>
> Feel free to implement it if you feel it's better. It would also
> require to increase the number of objects in the pool to
> RTE_LOG_HISTORY*2 + RTE_MAX_LCORE
>
>
Makes sense. I'll take a look into that one later.

Thanks,
Jan


> Regards,
> Olivier
>
>
>
> >   }
> >   else {
> >   if (rte_mempool_mc_get(log_history_mp, ) < 0)
> > @@ -234,6 +235,7 @@ rte_log_dump_history(FILE *out)
> >   rte_spinlock_lock(_list_lock);
> >   tmp_log_history = log_history;
> >   STAILQ_INIT(_history);
> > + log_history_size = 0;
> >   rte_spinlock_unlock(_list_lock);
> >
> >   for (i=0; i<RTE_LOG_HISTORY; i++) {
> >
>


[dpdk-dev] [PATCH v2] log: Properly reset log_history_size in rte_log_dump_history()

2015-06-01 Thread Jan Blunck
In rte_log_dump_history() the log_history list is reinitialized without
resetting the log_history_size. In the next call to rte_log_add_in_history()
the log_history_size > RTE_LOG_HISTORY and the code unconditionally tries
to remove the first entry:

Program received signal SIGSEGV, Segmentation fault.
rte_log_add_in_history (
buf=buf at entry=0x7f02035cd000 "DATAPLANE: 9:dp0s7 link RTM_NEWLINK 
[dp0s7] <UP,BROADCAST,RUNNING,MULTICAST,LOWER_UP>\nCAST,LOWER_UP>\n", size=size 
at entry=86)
at /usr/src/packages/BUILD/lib/librte_eal/common/eal_common_log.c:122

Signed-off-by: Jan Blunck 
---
 lib/librte_eal/common/eal_common_log.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_log.c 
b/lib/librte_eal/common/eal_common_log.c
index fe3d7d5..39d6e3f 100644
--- a/lib/librte_eal/common/eal_common_log.c
+++ b/lib/librte_eal/common/eal_common_log.c
@@ -119,7 +119,10 @@ rte_log_add_in_history(const char *buf, size_t size)
/* get a buffer for adding in history */
if (log_history_size > RTE_LOG_HISTORY) {
hist_buf = STAILQ_FIRST(_history);
-   STAILQ_REMOVE_HEAD(_history, next);
+   if (hist_buf) {
+   STAILQ_REMOVE_HEAD(_history, next);
+   log_history_size--;
+   }
}
else {
if (rte_mempool_mc_get(log_history_mp, ) < 0)
@@ -234,6 +237,7 @@ rte_log_dump_history(FILE *out)
rte_spinlock_lock(_list_lock);
tmp_log_history = log_history;
STAILQ_INIT(_history);
+   log_history_size = 0;
rte_spinlock_unlock(_list_lock);

for (i=0; i<RTE_LOG_HISTORY; i++) {
-- 
2.1.4



[dpdk-dev] [PATCH] log: Properly reset log_history_size in rte_log_dump_history()

2015-05-29 Thread Jan Blunck
In rte_log_dump_history() the log_history list is reinitialized without
resetting the log_history_size. In the next call to rte_log_add_in_history()
the log_history_size > RTE_LOG_HISTORY and the code unconditionally tries
to remove the first entry:

Program received signal SIGSEGV, Segmentation fault.
rte_log_add_in_history (
buf=buf at entry=0x7f02035cd000 "DATAPLANE: 9:dp0s7 link RTM_NEWLINK 
[dp0s7] <UP,BROADCAST,RUNNING,MULTICAST,LOWER_UP>\nCAST,LOWER_UP>\n", size=size 
at entry=86)
at /usr/src/packages/BUILD/lib/librte_eal/common/eal_common_log.c:122

Signed-off-by: Jan Blunck 
---
 lib/librte_eal/common/eal_common_log.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_log.c 
b/lib/librte_eal/common/eal_common_log.c
index fe3d7d5..cb4311c 100644
--- a/lib/librte_eal/common/eal_common_log.c
+++ b/lib/librte_eal/common/eal_common_log.c
@@ -119,7 +119,8 @@ rte_log_add_in_history(const char *buf, size_t size)
/* get a buffer for adding in history */
if (log_history_size > RTE_LOG_HISTORY) {
hist_buf = STAILQ_FIRST(_history);
-   STAILQ_REMOVE_HEAD(_history, next);
+   if (hist_buf)
+   STAILQ_REMOVE_HEAD(_history, next);
}
else {
if (rte_mempool_mc_get(log_history_mp, ) < 0)
@@ -234,6 +235,7 @@ rte_log_dump_history(FILE *out)
rte_spinlock_lock(_list_lock);
tmp_log_history = log_history;
STAILQ_INIT(_history);
+   log_history_size = 0;
rte_spinlock_unlock(_list_lock);

for (i=0; i<RTE_LOG_HISTORY; i++) {
-- 
2.1.4