[openib-general] [PATCH] IPoIB PKEY in/out event handling fix

Leonid Arsh leonida at voltaire.com
Thu Mar 23 09:52:51 PST 2006


Roland,

    I'm resending you the patch. Hope it will work fine now.

    The patch was tested on an earlier version on the kernel 2.6.15.
    I checked that in can also be applied on the latest revision (rev 5943.)

    This patch requires my previous small patch to be applied ( [openib-general] [PATCH] IPoIB network interface "RUNNING" statuswith the cable disconnected - fix.)
    Although you succeeded to apply the small patch manually, I'm resending it too.
    I generated it against the latest version, so you shouldn't have any problems applying it,
    if you need.

Leonid wrote:
>   the patch causes the network interface to respond to PKEY in/out events correctly.
>  As a result, you'll see a child interface in the "RUNNING" state (netif_carrier_on()) only when the corresponding PKEY is configured by the SM.
>   When SM removes a PKEY, the "RUNNING" state will be disabled for the corresponding network interface (netif_carrir_off().)
>   (To do it,  I added IB_EVENT_PKEY_CHANGE event handling.  
>   To prevent flushing the device before the device is open by the "delay open" mechanism,  I added an additional device flag called IPOIB_FLAG_INITIALIZED.)
>
>  The patch also prevents the child network interface from trying to join to multicast groups until the PKEY is configured.
>  We used to get error messages like:
>       "ib0.f2f2: couldn't attach QP to multicast group ff12:401b:f2f2:0:0:0:ffff:ffff"
>  in this case.
>  (To do it, I just check  IPOIB_FLAG_OPER_UP flag in
ipoib_set_mcast_list() )


This is the main patch:    
    
Signed-off-by: Leonid Arsh <leonida at voltaire.com>

Index: linux-kernel/infiniband/ulp/ipoib/ipoib_verbs.c
===================================================================
--- linux-kernel/infiniband/ulp/ipoib/ipoib_verbs.c	(revision 8503)
+++ linux-kernel/infiniband/ulp/ipoib/ipoib_verbs.c	(working copy)
@@ -252,6 +252,7 @@
 		container_of(handler, struct ipoib_dev_priv, event_handler);
 
 	if (record->event == IB_EVENT_PORT_ERR    ||
+	    record->event == IB_EVENT_PKEY_CHANGE ||
 	    record->event == IB_EVENT_PORT_ACTIVE ||
 	    record->event == IB_EVENT_LID_CHANGE  ||
 	    record->event == IB_EVENT_SM_CHANGE) {
Index: linux-kernel/infiniband/ulp/ipoib/ipoib_main.c
===================================================================
--- linux-kernel/infiniband/ulp/ipoib/ipoib_main.c	(revision 8502)
+++ linux-kernel/infiniband/ulp/ipoib/ipoib_main.c	(working copy)
@@ -737,6 +737,11 @@
 {
 	struct ipoib_dev_priv *priv = netdev_priv(dev);
 
+	if (!test_bit(IPOIB_FLAG_OPER_UP, &priv->flags)) {
+		ipoib_dbg(priv, "IPOIB_FLAG_OPER_UP not set");
+		return;
+	}
+
 	queue_work(ipoib_workqueue, &priv->restart_task);
 }
 
Index: linux-kernel/infiniband/ulp/ipoib/ipoib.h
===================================================================
--- linux-kernel/infiniband/ulp/ipoib/ipoib.h	(revision 8502)
+++ linux-kernel/infiniband/ulp/ipoib/ipoib.h	(working copy)
@@ -79,13 +79,14 @@
 	IPOIB_MAX_MCAST_QUEUE     = 3,
 
 	IPOIB_FLAG_OPER_UP 	  = 0,
-	IPOIB_FLAG_ADMIN_UP 	  = 1,
-	IPOIB_PKEY_ASSIGNED 	  = 2,
-	IPOIB_PKEY_STOP 	  = 3,
-	IPOIB_FLAG_SUBINTERFACE   = 4,
-	IPOIB_MCAST_RUN 	  = 5,
-	IPOIB_STOP_REAPER         = 6,
-	IPOIB_MCAST_STARTED       = 7,
+	IPOIB_FLAG_INITIALIZED    = 1,
+	IPOIB_FLAG_ADMIN_UP 	  = 2,
+	IPOIB_PKEY_ASSIGNED 	  = 3,
+	IPOIB_PKEY_STOP 	  = 4,
+	IPOIB_FLAG_SUBINTERFACE   = 5,
+	IPOIB_MCAST_RUN 	  = 6,
+	IPOIB_STOP_REAPER         = 7,
+	IPOIB_MCAST_STARTED       = 8,
 
 	IPOIB_MAX_BACKOFF_SECONDS = 16,
 
Index: linux-kernel/infiniband/ulp/ipoib/ipoib_ib.c
===================================================================
--- linux-kernel/infiniband/ulp/ipoib/ipoib_ib.c	(revision 8502)
+++ linux-kernel/infiniband/ulp/ipoib/ipoib_ib.c	(working copy)
@@ -422,13 +422,33 @@
 	clear_bit(IPOIB_STOP_REAPER, &priv->flags);
 	queue_delayed_work(ipoib_workqueue, &priv->ah_reap_task, HZ);
 
+	set_bit(IPOIB_FLAG_INITIALIZED, &priv->flags);
 	return 0;
 }
 
+static void ipoib_pkey_dev_check_presence(struct net_device *dev)
+{
+	struct ipoib_dev_priv *priv = netdev_priv(dev);
+	u16 pkey_index = 0;
+
+	if (ib_find_cached_pkey(priv->ca, priv->port, priv->pkey, &pkey_index))
+		clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
+	else
+		set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
+}
+
 int ipoib_ib_dev_up(struct net_device *dev)
 {
 	struct ipoib_dev_priv *priv = netdev_priv(dev);
 
+	ipoib_pkey_dev_check_presence(dev);
+
+	if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) {
+		ipoib_dbg(priv, "PKEY is not assigned.\n");
+		return 0;
+	}
+
+
 	set_bit(IPOIB_FLAG_OPER_UP, &priv->flags);
 
 	return ipoib_mcast_start_thread(dev);
@@ -481,6 +501,8 @@
 	struct ipoib_tx_buf *tx_req;
 	int i;
 
+
+	clear_bit(IPOIB_FLAG_INITIALIZED, &priv->flags);
 	/*
 	 * Move our QP to the error state and then reinitialize in
 	 * when all work requests have completed or have been flushed.
@@ -585,9 +607,16 @@
 	struct net_device *dev = (struct net_device *)_dev;
 	struct ipoib_dev_priv *priv = netdev_priv(dev), *cpriv;
 
-	if (!test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags))
+	if (!test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags) ) {
+		ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_INITIALIZED not set.\n");
 		return;
+	}
 
+	if (!test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) {
+		ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_ADMIN_UP not set.\n");
+		return;
+	}
+
 	ipoib_dbg(priv, "flushing\n");
 
 	ipoib_ib_dev_down(dev);
@@ -630,17 +659,6 @@
  * change async notification is available.
  */
 
-static void ipoib_pkey_dev_check_presence(struct net_device *dev)
-{
-	struct ipoib_dev_priv *priv = netdev_priv(dev);
-	u16 pkey_index = 0;
-
-	if (ib_find_cached_pkey(priv->ca, priv->port, priv->pkey, &pkey_index))
-		clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
-	else
-		set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
-}
-
 void ipoib_pkey_poll(void *dev_ptr)
 {
 	struct net_device *dev = dev_ptr;





____________________________________________________________________________________
This is the previous small patch: 
([openib-general] [PATCH] IPoIB network interface "RUNNING" statuswith the cable disconnected - fix.)


Signed-off-by: Leonid Arsh <leonida at voltaire.com>

Index: linux-kernel/infiniband/ulp/ipoib/ipoib_verbs.c
===================================================================
--- linux-kernel/infiniband/ulp/ipoib/ipoib_verbs.c	(revision 5983)
+++ linux-kernel/infiniband/ulp/ipoib/ipoib_verbs.c	(working copy)
@@ -251,10 +251,11 @@
 	struct ipoib_dev_priv *priv =
 		container_of(handler, struct ipoib_dev_priv, event_handler);
 
-	if (record->event == IB_EVENT_PORT_ACTIVE ||
+	if (record->event == IB_EVENT_PORT_ERR    ||
+	    record->event == IB_EVENT_PORT_ACTIVE ||
 	    record->event == IB_EVENT_LID_CHANGE  ||
 	    record->event == IB_EVENT_SM_CHANGE) {
-		ipoib_dbg(priv, "Port active event\n");
+ 		ipoib_dbg(priv, "Port state change event\n");
 		queue_work(ipoib_workqueue, &priv->flush_task);
 	}
 }



More information about the general mailing list