diff mbox

[rdma-next,2/9] IB/ipoib: Set device connection mode only when needed

Message ID 20161227133911.14340-3-leon@kernel.org (mailing list archive)
State Superseded
Headers show

Commit Message

Leon Romanovsky Dec. 27, 2016, 1:39 p.m. UTC
From: Feras Daoud <ferasda@mellanox.com>

When changing the connection mode, the ipoib_set_mode function
did not check if the previous connection mode equals to the
new one. This commit adds the required check and return 0 if the new
mode equals to the previous one.

Fixes: 839fcaba355a ("IPoIB: Connected mode experimental support")
Signed-off-by: Feras Daoud <ferasda@mellanox.com>
Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
Reviewed-by: Alex Vesker <valex@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
---
 drivers/infiniband/ulp/ipoib/ipoib_main.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Yuval Shaia Dec. 27, 2016, 8:15 p.m. UTC | #1
Extremely minor comment inline, feel free to ignore.

Reviewed-By: Yuval Shaia <yuval.shaia@oracle.com>

On Tue, Dec 27, 2016 at 03:39:04PM +0200, Leon Romanovsky wrote:
> From: Feras Daoud <ferasda@mellanox.com>
> 
> When changing the connection mode, the ipoib_set_mode function
> did not check if the previous connection mode equals to the
> new one. This commit adds the required check and return 0 if the new
> mode equals to the previous one.
> 
> Fixes: 839fcaba355a ("IPoIB: Connected mode experimental support")
> Signed-off-by: Feras Daoud <ferasda@mellanox.com>
> Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
> Reviewed-by: Alex Vesker <valex@mellanox.com>
> Signed-off-by: Leon Romanovsky <leon@kernel.org>
> ---
>  drivers/infiniband/ulp/ipoib/ipoib_main.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> index a550cc6..1787f6b 100644
> --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
> +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> @@ -474,6 +474,14 @@ int ipoib_set_mode(struct net_device *dev, const char *buf)
>  {
>  	struct ipoib_dev_priv *priv = netdev_priv(dev);
>  
> +	if ((test_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags) &&
> +	     !strcmp(buf, "connected\n")) ||
> +	     (!test_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags) &&
> +	     !strcmp(buf, "datagram\n"))) {
> +		ipoib_dbg(priv, "already in that mode, goes out.\n");

Why not ipoib_warn/warn_once?

> +		return 0;
> +	}
> +
>  	/* flush paths if we switch modes so that connections are restarted */
>  	if (IPOIB_CM_SUPPORTED(dev->dev_addr) && !strcmp(buf, "connected\n")) {
>  		set_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags);
> -- 
> 2.10.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Leon Romanovsky Dec. 28, 2016, 5:43 a.m. UTC | #2
On Tue, Dec 27, 2016 at 10:15:01PM +0200, Yuval Shaia wrote:
> Extremely minor comment inline, feel free to ignore.
>
> Reviewed-By: Yuval Shaia <yuval.shaia@oracle.com>
>
> On Tue, Dec 27, 2016 at 03:39:04PM +0200, Leon Romanovsky wrote:
> > From: Feras Daoud <ferasda@mellanox.com>
> >
> > When changing the connection mode, the ipoib_set_mode function
> > did not check if the previous connection mode equals to the
> > new one. This commit adds the required check and return 0 if the new
> > mode equals to the previous one.
> >
> > Fixes: 839fcaba355a ("IPoIB: Connected mode experimental support")
> > Signed-off-by: Feras Daoud <ferasda@mellanox.com>
> > Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
> > Reviewed-by: Alex Vesker <valex@mellanox.com>
> > Signed-off-by: Leon Romanovsky <leon@kernel.org>
> > ---
> >  drivers/infiniband/ulp/ipoib/ipoib_main.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> > index a550cc6..1787f6b 100644
> > --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
> > +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> > @@ -474,6 +474,14 @@ int ipoib_set_mode(struct net_device *dev, const char *buf)
> >  {
> >  	struct ipoib_dev_priv *priv = netdev_priv(dev);
> >
> > +	if ((test_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags) &&
> > +	     !strcmp(buf, "connected\n")) ||
> > +	     (!test_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags) &&
> > +	     !strcmp(buf, "datagram\n"))) {
> > +		ipoib_dbg(priv, "already in that mode, goes out.\n");
>
> Why not ipoib_warn/warn_once?

We didn't use warn(), because setting the same mode more than once is a valid flow.
However, it makes no sense to continue and this is why we are returning zero (sucesss)
without doing a thing.

>
> > +		return 0;
> > +	}
> > +
> >  	/* flush paths if we switch modes so that connections are restarted */
> >  	if (IPOIB_CM_SUPPORTED(dev->dev_addr) && !strcmp(buf, "connected\n")) {
> >  		set_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags);
> > --
> > 2.10.2
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index a550cc6..1787f6b 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -474,6 +474,14 @@  int ipoib_set_mode(struct net_device *dev, const char *buf)
 {
 	struct ipoib_dev_priv *priv = netdev_priv(dev);
 
+	if ((test_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags) &&
+	     !strcmp(buf, "connected\n")) ||
+	     (!test_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags) &&
+	     !strcmp(buf, "datagram\n"))) {
+		ipoib_dbg(priv, "already in that mode, goes out.\n");
+		return 0;
+	}
+
 	/* flush paths if we switch modes so that connections are restarted */
 	if (IPOIB_CM_SUPPORTED(dev->dev_addr) && !strcmp(buf, "connected\n")) {
 		set_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags);