* [dpdk-dev] [PATCH 0/3] net/mlx: fix link state modification
@ 2016-07-04 8:24 Olivier Matz
2016-07-04 8:24 ` [dpdk-dev] [PATCH 1/3] net/mlx: fix setting of interface flags Olivier Matz
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Olivier Matz @ 2016-07-04 8:24 UTC (permalink / raw)
To: adrien.mazarguil, dev; +Cc: bruce.richardson, fengtian.guo
This series adds a missing device operation in mlx4 to
set the link state. It also fixes the function to set the
flags on the kernel interface in both mlx4 and mlx5.
Guo Fengtian (1):
net/mlx4: add link up/down callback function
Olivier Matz (2):
net/mlx: fix setting of interface flags
net/mlx5: fix api comment of link set function
drivers/net/mlx4/mlx4.c | 88 +++++++++++++++++++++++++++++++++++++++++-
drivers/net/mlx5/mlx5_ethdev.c | 4 +-
2 files changed, 89 insertions(+), 3 deletions(-)
--
2.8.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH 1/3] net/mlx: fix setting of interface flags
2016-07-04 8:24 [dpdk-dev] [PATCH 0/3] net/mlx: fix link state modification Olivier Matz
@ 2016-07-04 8:24 ` Olivier Matz
2016-07-04 8:24 ` [dpdk-dev] [PATCH 2/3] net/mlx5: fix api comment of link set function Olivier Matz
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Olivier Matz @ 2016-07-04 8:24 UTC (permalink / raw)
To: adrien.mazarguil, dev; +Cc: bruce.richardson, fengtian.guo
According to the documentation, the function
priv_set_flags(priv, keep, flags) should not modify the flags
in "keep" mask.
So 'flags' argument should be masked with '~keep' before ORing
it with the previous flags value.
This avoids to mess the kernel interface flags when calling
priv_set_flags(priv, ~IFF_UP, ~IFF_UP) in priv_set_link():
$ ip link
26: eth0: BROADCAST,MULTICAST,NOARP,ALLMULTI,PROMISC,DEBUG,\
DYNAMIC,AUTOMEDIA,PORTSEL,NOTRAILERS
Fixes: 7fae69eeff13 ("mlx4: new poll mode driver")
Fixes: 771fa900b73a ("mlx5: introduce new driver for Mellanox ConnectX-4 adapters")
Reported-by: Fengtian Guo <fengtian.guo@6wind.com>
Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
drivers/net/mlx4/mlx4.c | 2 +-
drivers/net/mlx5/mlx5_ethdev.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index f8ed42b..1dd14f4 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -689,7 +689,7 @@ priv_set_flags(struct priv *priv, unsigned int keep, unsigned int flags)
if (priv_get_sysfs_ulong(priv, "flags", &tmp) == -1)
return -1;
tmp &= keep;
- tmp |= flags;
+ tmp |= (flags & (~keep));
return priv_set_sysfs_ulong(priv, "flags", tmp);
}
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 0e7ed01..6fef902 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -461,7 +461,7 @@ priv_set_flags(struct priv *priv, unsigned int keep, unsigned int flags)
if (priv_get_sysfs_ulong(priv, "flags", &tmp) == -1)
return -1;
tmp &= keep;
- tmp |= flags;
+ tmp |= (flags & (~keep));
return priv_set_sysfs_ulong(priv, "flags", tmp);
}
--
2.8.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH 2/3] net/mlx5: fix api comment of link set function
2016-07-04 8:24 [dpdk-dev] [PATCH 0/3] net/mlx: fix link state modification Olivier Matz
2016-07-04 8:24 ` [dpdk-dev] [PATCH 1/3] net/mlx: fix setting of interface flags Olivier Matz
@ 2016-07-04 8:24 ` Olivier Matz
2016-07-04 8:24 ` [dpdk-dev] [PATCH 3/3] net/mlx4: add link up/down callback function Olivier Matz
2016-07-05 9:25 ` [dpdk-dev] [PATCH 0/3] net/mlx: fix link state modification Adrien Mazarguil
3 siblings, 0 replies; 6+ messages in thread
From: Olivier Matz @ 2016-07-04 8:24 UTC (permalink / raw)
To: adrien.mazarguil, dev; +Cc: bruce.richardson, fengtian.guo
Fixes: 62072098b54e ("mlx5: support setting link up or down")
Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
drivers/net/mlx5/mlx5_ethdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 6fef902..130e15d 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -1150,7 +1150,7 @@ priv_dev_interrupt_handler_install(struct priv *priv, struct rte_eth_dev *dev)
/**
* Change the link state (UP / DOWN).
*
- * @param dev
+ * @param priv
* Pointer to Ethernet device structure.
* @param up
* Nonzero for link up, otherwise link down.
--
2.8.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH 3/3] net/mlx4: add link up/down callback function
2016-07-04 8:24 [dpdk-dev] [PATCH 0/3] net/mlx: fix link state modification Olivier Matz
2016-07-04 8:24 ` [dpdk-dev] [PATCH 1/3] net/mlx: fix setting of interface flags Olivier Matz
2016-07-04 8:24 ` [dpdk-dev] [PATCH 2/3] net/mlx5: fix api comment of link set function Olivier Matz
@ 2016-07-04 8:24 ` Olivier Matz
2016-07-05 9:25 ` [dpdk-dev] [PATCH 0/3] net/mlx: fix link state modification Adrien Mazarguil
3 siblings, 0 replies; 6+ messages in thread
From: Olivier Matz @ 2016-07-04 8:24 UTC (permalink / raw)
To: adrien.mazarguil, dev; +Cc: bruce.richardson, fengtian.guo
From: Guo Fengtian <fengtian.guo@6wind.com>
Implement dev_set_link_up and dev_set_link_down device
operations. Code is inspired from mlx5.
Signed-off-by: Guo Fengtian <fengtian.guo@6wind.com>
---
drivers/net/mlx4/mlx4.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 86 insertions(+)
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index 1dd14f4..5dd77c2 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -4328,6 +4328,90 @@ mlx4_dev_close(struct rte_eth_dev *dev)
}
/**
+ * Change the link state (UP / DOWN).
+ *
+ * @param priv
+ * Pointer to Ethernet device private data.
+ * @param up
+ * Nonzero for link up, otherwise link down.
+ *
+ * @return
+ * 0 on success, errno value on failure.
+ */
+static int
+priv_set_link(struct priv *priv, int up)
+{
+ struct rte_eth_dev *dev = priv->dev;
+ int err;
+ unsigned int i;
+
+ if (up) {
+ err = priv_set_flags(priv, ~IFF_UP, IFF_UP);
+ if (err)
+ return err;
+ for (i = 0; i < priv->rxqs_n; i++)
+ if ((*priv->rxqs)[i]->sp)
+ break;
+ /* Check if an sp queue exists.
+ * Note: Some old frames might be received.
+ */
+ if (i == priv->rxqs_n)
+ dev->rx_pkt_burst = mlx4_rx_burst;
+ else
+ dev->rx_pkt_burst = mlx4_rx_burst_sp;
+ dev->tx_pkt_burst = mlx4_tx_burst;
+ } else {
+ err = priv_set_flags(priv, ~IFF_UP, ~IFF_UP);
+ if (err)
+ return err;
+ dev->rx_pkt_burst = removed_rx_burst;
+ dev->tx_pkt_burst = removed_tx_burst;
+ }
+ return 0;
+}
+
+/**
+ * DPDK callback to bring the link DOWN.
+ *
+ * @param dev
+ * Pointer to Ethernet device structure.
+ *
+ * @return
+ * 0 on success, errno value on failure.
+ */
+static int
+mlx4_set_link_down(struct rte_eth_dev *dev)
+{
+ struct priv *priv = dev->data->dev_private;
+ int err;
+
+ priv_lock(priv);
+ err = priv_set_link(priv, 0);
+ priv_unlock(priv);
+ return err;
+}
+
+/**
+ * DPDK callback to bring the link UP.
+ *
+ * @param dev
+ * Pointer to Ethernet device structure.
+ *
+ * @return
+ * 0 on success, errno value on failure.
+ */
+static int
+mlx4_set_link_up(struct rte_eth_dev *dev)
+{
+ struct priv *priv = dev->data->dev_private;
+ int err;
+
+ priv_lock(priv);
+ err = priv_set_link(priv, 1);
+ priv_unlock(priv);
+ return err;
+}
+/**
* DPDK callback to get information about the device.
*
* @param dev
@@ -5134,6 +5218,8 @@ static const struct eth_dev_ops mlx4_dev_ops = {
.dev_configure = mlx4_dev_configure,
.dev_start = mlx4_dev_start,
.dev_stop = mlx4_dev_stop,
+ .dev_set_link_down = mlx4_set_link_down,
+ .dev_set_link_up = mlx4_set_link_up,
.dev_close = mlx4_dev_close,
.promiscuous_enable = mlx4_promiscuous_enable,
.promiscuous_disable = mlx4_promiscuous_disable,
--
2.8.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH 0/3] net/mlx: fix link state modification
2016-07-04 8:24 [dpdk-dev] [PATCH 0/3] net/mlx: fix link state modification Olivier Matz
` (2 preceding siblings ...)
2016-07-04 8:24 ` [dpdk-dev] [PATCH 3/3] net/mlx4: add link up/down callback function Olivier Matz
@ 2016-07-05 9:25 ` Adrien Mazarguil
2016-07-05 10:56 ` Bruce Richardson
3 siblings, 1 reply; 6+ messages in thread
From: Adrien Mazarguil @ 2016-07-05 9:25 UTC (permalink / raw)
To: Olivier Matz; +Cc: dev, bruce.richardson, fengtian.guo
On Mon, Jul 04, 2016 at 10:24:16AM +0200, Olivier Matz wrote:
> This series adds a missing device operation in mlx4 to
> set the link state. It also fixes the function to set the
> flags on the kernel interface in both mlx4 and mlx5.
Thanks.
Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Guo Fengtian (1):
> net/mlx4: add link up/down callback function
>
> Olivier Matz (2):
> net/mlx: fix setting of interface flags
> net/mlx5: fix api comment of link set function
>
> drivers/net/mlx4/mlx4.c | 88 +++++++++++++++++++++++++++++++++++++++++-
> drivers/net/mlx5/mlx5_ethdev.c | 4 +-
> 2 files changed, 89 insertions(+), 3 deletions(-)
>
> --
> 2.8.1
--
Adrien Mazarguil
6WIND
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH 0/3] net/mlx: fix link state modification
2016-07-05 9:25 ` [dpdk-dev] [PATCH 0/3] net/mlx: fix link state modification Adrien Mazarguil
@ 2016-07-05 10:56 ` Bruce Richardson
0 siblings, 0 replies; 6+ messages in thread
From: Bruce Richardson @ 2016-07-05 10:56 UTC (permalink / raw)
To: Olivier Matz, dev, fengtian.guo
On Tue, Jul 05, 2016 at 11:25:10AM +0200, Adrien Mazarguil wrote:
> On Mon, Jul 04, 2016 at 10:24:16AM +0200, Olivier Matz wrote:
> > This series adds a missing device operation in mlx4 to
> > set the link state. It also fixes the function to set the
> > flags on the kernel interface in both mlx4 and mlx5.
>
> Thanks.
>
> Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
>
Series applied to dpdk-next-net/rel_16_07
/Bruce
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-07-05 10:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-04 8:24 [dpdk-dev] [PATCH 0/3] net/mlx: fix link state modification Olivier Matz
2016-07-04 8:24 ` [dpdk-dev] [PATCH 1/3] net/mlx: fix setting of interface flags Olivier Matz
2016-07-04 8:24 ` [dpdk-dev] [PATCH 2/3] net/mlx5: fix api comment of link set function Olivier Matz
2016-07-04 8:24 ` [dpdk-dev] [PATCH 3/3] net/mlx4: add link up/down callback function Olivier Matz
2016-07-05 9:25 ` [dpdk-dev] [PATCH 0/3] net/mlx: fix link state modification Adrien Mazarguil
2016-07-05 10:56 ` Bruce Richardson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).