[IPoIB] More SM reregister handling
[mirror/winof/.git] / ulp / ipoib / kernel / ipoib_adapter.c
index cd14196..af976df 100644 (file)
@@ -480,6 +480,7 @@ __ipoib_pnp_cb(
        ipoib_adapter_t         *p_adapter;\r
        ipoib_port_t            *p_port;\r
        ib_pnp_event_t          old_state;\r
+       ib_pnp_port_rec_t       *p_port_rec;\r
 \r
        IPOIB_ENTER( IPOIB_DBG_PNP );\r
 \r
@@ -507,6 +508,8 @@ __ipoib_pnp_cb(
        IPOIB_TRACE( IPOIB_DBG_INFO,\r
                ("p_pnp_rec->pnp_event = 0x%x\n",p_pnp_rec->pnp_event));\r
 \r
+       p_port_rec = (ib_pnp_port_rec_t*)p_pnp_rec;\r
+\r
        switch( p_pnp_rec->pnp_event )\r
        {\r
        case IB_PNP_PORT_ADD:\r
@@ -530,8 +533,7 @@ __ipoib_pnp_cb(
                cl_obj_lock( &p_adapter->obj );\r
                p_adapter->state = IB_PNP_PORT_ADD;\r
                cl_obj_unlock( &p_adapter->obj );\r
-               status = ipoib_create_port( p_adapter,\r
-                       (ib_pnp_port_rec_t*)p_pnp_rec, &p_port );\r
+               status = ipoib_create_port( p_adapter, p_port_rec, &p_port );\r
                cl_obj_lock( &p_adapter->obj );\r
                if( status != IB_SUCCESS )\r
                {\r
@@ -568,7 +570,7 @@ __ipoib_pnp_cb(
                cl_obj_lock( &p_adapter->obj );\r
                p_adapter->state = IB_PNP_PORT_INIT;\r
                cl_obj_unlock( &p_adapter->obj );\r
-               ipoib_port_up( p_adapter->p_port, (ib_pnp_port_rec_t*)p_pnp_rec );\r
+               ipoib_port_up( p_adapter->p_port, p_port_rec );\r
 \r
                status = IB_SUCCESS;\r
                break;\r
@@ -639,6 +641,12 @@ __ipoib_pnp_cb(
        case IB_PNP_SM_CHANGE:\r
        case IB_PNP_GID_CHANGE:\r
        case IB_PNP_LID_CHANGE:\r
+               status = IB_SUCCESS;\r
+\r
+               /* We ignore this event if the link is not active. */\r
+               if( p_port_rec->p_port_attr->link_state != IB_LINK_ACTIVE )\r
+                       break;\r
+\r
                cl_obj_lock( &p_adapter->obj );\r
                old_state = p_adapter->state;\r
                switch( old_state )\r
@@ -652,7 +660,6 @@ __ipoib_pnp_cb(
                }\r
                cl_obj_unlock( &p_adapter->obj );\r
                \r
-               status = IB_SUCCESS;\r
                if( p_adapter->registering )\r
                        break;\r
 \r
@@ -670,6 +677,9 @@ __ipoib_pnp_cb(
                        /* Fall through. */\r
 \r
                case IB_PNP_PORT_DOWN:\r
+                       cl_obj_lock( &p_adapter->obj );\r
+                       p_adapter->state = IB_PNP_PORT_INIT;\r
+                       cl_obj_unlock( &p_adapter->obj );\r
                        ipoib_port_up( p_adapter->p_port, (ib_pnp_port_rec_t*)p_pnp_rec );\r
                }\r
                break;\r