[SRP] Fix REP processing to reject the connection in case of errors.
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Fri, 4 Aug 2006 07:19:55 +0000 (07:19 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Fri, 4 Aug 2006 07:19:55 +0000 (07:19 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@438 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/srp/kernel/srp_connection.c

index f8f2c11..8f86b36 100644 (file)
@@ -409,13 +409,18 @@ void
 __srp_cm_reply_cb(\r
        IN  ib_cm_rep_rec_t     *p_cm_reply)\r
 {\r
-       srp_session_t       *p_srp_session = (srp_session_t* __ptr64)p_cm_reply->qp_context;\r
-       srp_connection_t    *p_connection;\r
-       srp_login_rsp_t     *p_srp_login_rsp = (srp_login_rsp_t* __ptr64)p_cm_reply->p_rep_pdata;\r
-       ib_api_status_t     status;\r
-       ib_cm_mra_t         cm_mra;\r
-       ib_cm_rtu_t         cm_rtu;\r
-       cl_status_t         cl_status;\r
+       srp_session_t           *p_srp_session = (srp_session_t* __ptr64)p_cm_reply->qp_context;\r
+       srp_connection_t        *p_connection;\r
+       srp_login_rsp_t         *p_srp_login_rsp = (srp_login_rsp_t* __ptr64)p_cm_reply->p_rep_pdata;\r
+       ib_api_status_t         status;\r
+       union\r
+       {\r
+               ib_cm_mra_t             cm_mra;\r
+               ib_cm_rtu_t             cm_rtu;\r
+               ib_cm_rej_t             cm_rej;\r
+\r
+       }       u;\r
+       cl_status_t                     cl_status;\r
        ib_al_ifc_t                     *p_ifc;\r
 \r
        SRP_ENTER( SRP_DBG_PNP );\r
@@ -448,8 +453,7 @@ __srp_cm_reply_cb(
        else /* not reported any descriptor format */\r
        {\r
                SRP_TRACE( SRP_DBG_DEBUG,(" Target does not support valid descriptor formats\n") );\r
-               p_connection->state = SRP_CONNECT_FAILURE;\r
-               goto exit;\r
+               goto rej;\r
        }\r
        SRP_TRACE( SRP_DBG_DEBUG,\r
                        ("Request Limit = %d, SendQ Depth = %d, RecvQDepth = %d, ItoT size = %d, TtoI size = %d, Max S/G = %d\n",\r
@@ -460,17 +464,16 @@ __srp_cm_reply_cb(
                        p_connection->targ_to_init_iu_sz,\r
                        p_connection->max_scatter_gather_entries) );\r
 \r
-       cm_mra.svc_timeout = 0x08;\r
-       cm_mra.p_mra_pdata = NULL;\r
-       cm_mra.mra_length = 0;\r
+       u.cm_mra.svc_timeout = 0x08;\r
+       u.cm_mra.p_mra_pdata = NULL;\r
+       u.cm_mra.mra_length = 0;\r
 \r
-       status = p_ifc->cm_mra( p_cm_reply->h_cm_rep, &cm_mra );\r
+       status = p_ifc->cm_mra( p_cm_reply->h_cm_rep, &u.cm_mra );\r
        if ( status != IB_SUCCESS )\r
        {\r
                SRP_TRACE( SRP_DBG_ERROR,\r
                        ("Cannot Send MRA. Status = %d\n", status) );\r
-               p_connection->state = SRP_CONNECT_FAILURE;\r
-               goto exit;\r
+               goto rej;\r
        }\r
 \r
        status = p_ifc->modify_cq( p_connection->h_send_cq, &p_connection->send_queue_depth );\r
@@ -490,8 +493,7 @@ __srp_cm_reply_cb(
        cl_status = __srp_create_wc_free_list( p_connection, (p_connection->request_limit * 2) );/* Send/Recv */\r
        if ( cl_status != CL_SUCCESS )\r
        {\r
-               p_connection->state = SRP_CONNECT_FAILURE;\r
-               goto exit;\r
+               goto rej;\r
        }\r
 \r
        status = srp_init_descriptors( &p_srp_session->descriptors,\r
@@ -505,22 +507,26 @@ __srp_cm_reply_cb(
                cl_free( p_connection->p_wc_array );\r
                p_connection->p_wc_array = NULL;\r
                p_connection->p_wc_free_list = NULL;\r
+rej:\r
                p_connection->state = SRP_CONNECT_FAILURE;\r
+               cl_memclr( &u.cm_rej, sizeof(u.cm_rej) );\r
+               u.cm_rej.rej_status = IB_REJ_INSUF_RESOURCES;\r
+               p_ifc->cm_rej( p_cm_reply->h_cm_rep, &u.cm_rej );\r
                goto exit;\r
        }\r
 \r
-       cm_rtu.access_ctrl = IB_AC_LOCAL_WRITE | IB_AC_RDMA_READ | IB_AC_RDMA_WRITE;\r
+       u.cm_rtu.access_ctrl = IB_AC_LOCAL_WRITE | IB_AC_RDMA_READ | IB_AC_RDMA_WRITE;\r
 \r
        /* Have to set to 0 to indicate not to modify because Tavor doesn't support this */\r
-       cm_rtu.sq_depth = 0 /*p_connection->request_limit*/;\r
-       cm_rtu.rq_depth = 0 /*p_connection->request_limit*/;\r
+       u.cm_rtu.sq_depth = 0 /*p_connection->request_limit*/;\r
+       u.cm_rtu.rq_depth = 0 /*p_connection->request_limit*/;\r
 \r
-       cm_rtu.p_rtu_pdata = NULL;\r
-       cm_rtu.rtu_length = 0;\r
-       cm_rtu.pfn_cm_apr_cb = __srp_cm_apr_cb;\r
-       cm_rtu.pfn_cm_dreq_cb = __srp_cm_dreq_cb;\r
+       u.cm_rtu.p_rtu_pdata = NULL;\r
+       u.cm_rtu.rtu_length = 0;\r
+       u.cm_rtu.pfn_cm_apr_cb = __srp_cm_apr_cb;\r
+       u.cm_rtu.pfn_cm_dreq_cb = __srp_cm_dreq_cb;\r
 \r
-       status = p_ifc->cm_rtu( p_cm_reply->h_cm_rep, &cm_rtu );\r
+       status = p_ifc->cm_rtu( p_cm_reply->h_cm_rep, &u.cm_rtu );\r
        if ( status != IB_SUCCESS )\r
        {\r
                SRP_TRACE( SRP_DBG_ERROR,\r