Fix bug where UVP would return non-NULL handle in case of failure
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Fri, 29 Jul 2005 00:30:12 +0000 (00:30 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Fri, 29 Jul 2005 00:30:12 +0000 (00:30 +0000)
when preparing for PD, CQ, and QP allocation.
Fixed indentation of the affected functions while in there.  Tabs
are your friend.

git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@48 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

hw/mt23108/user/mlnx_ual_cq.c
hw/mt23108/user/mlnx_ual_pd.c
hw/mt23108/user/mlnx_ual_qp.c

index bb1ebf8..4bfd1e2 100644 (file)
@@ -214,100 +214,84 @@ mlnx_post_create_cq (
                OUT                     ib_cq_handle_t                          *ph_uvp_cq,\r
        IN                              ci_umv_buf_t                            *p_umv_buf )\r
 {\r
-    ib_api_status_t status;\r
-    mlnx_ual_hobul_t *p_hobul = (mlnx_ual_hobul_t *)((void*)h_uvp_ca);\r
-    MT_size_t buf_size = 0;\r
-    mlnx_ual_cq_info_t *p_new_cq = NULL;\r
-    \r
+       mlnx_ual_hobul_t *p_hobul = (mlnx_ual_hobul_t *)((void*)h_uvp_ca);\r
+       MT_size_t buf_size = 0;\r
+       mlnx_ual_cq_info_t *p_new_cq = NULL;\r
 \r
-    FUNC_ENTER;\r
 \r
-    CL_ASSERT(p_umv_buf);\r
+       FUNC_ENTER;\r
 \r
-    CL_ASSERT(p_hobul);\r
+       CL_ASSERT(p_umv_buf);\r
 \r
-    status = ioctl_status;\r
+       CL_ASSERT(p_hobul);\r
 \r
-    do\r
-    {\r
-       if (p_hobul->p_hca_ul_info )\r
+       buf_size = p_hobul->p_hca_ul_info->cq_ul_resources_sz + \r
+               sizeof (u_int32_t) + sizeof (mlnx_ual_cq_info_t *);\r
+\r
+       /* Retrieve our cq_info back from priv buffer */\r
+       cl_memcpy (&p_new_cq,\r
+               ((u_int8_t *)p_umv_buf->p_inout_buf + buf_size - \r
+               sizeof (mlnx_ual_cq_info_t *)),\r
+               sizeof (mlnx_ual_cq_info_t *));\r
+       CL_ASSERT(p_new_cq);\r
+\r
+       *ph_uvp_cq = (uvp_cq_handle_t) p_new_cq;\r
+\r
+       if ( ioctl_status == IB_SUCCESS )\r
        {\r
-           buf_size = p_hobul->p_hca_ul_info->cq_ul_resources_sz + \r
-               sizeof (u_int32_t) + sizeof (mlnx_ual_cq_info_t *);\r
-       \r
-\r
-           /*\r
-           * Retrieve our cq_info back from priv buffer\r
-           */\r
-           cl_memcpy (&p_new_cq,\r
-                   ((u_int8_t *)p_umv_buf->p_inout_buf + buf_size - \r
-                    sizeof (mlnx_ual_cq_info_t *)),\r
-                   sizeof (mlnx_ual_cq_info_t *));\r
-           CL_ASSERT(p_new_cq);\r
-           *ph_uvp_cq = (uvp_cq_handle_t) p_new_cq;\r
+               if (IB_SUCCESS != p_umv_buf->status) \r
+               {\r
+                       CL_TRACE (MLNX_TRACE_LVL_1, mlnx_dbg_lvl,\r
+                               ("Bad status %ld\n", p_umv_buf->status));\r
+                       goto err;\r
+               }\r
+               else if ((buf_size - sizeof (mlnx_ual_cq_info_t *)) != \r
+                       p_umv_buf->output_size) \r
+               {\r
+                       CL_TRACE (MLNX_TRACE_LVL_1, mlnx_dbg_lvl,\r
+                               ("Bad user priv buffer size (exp - 4) = %d, res = %ld\n",\r
+                               buf_size, p_umv_buf->output_size));\r
+                       goto err;\r
+               }\r
+\r
+               cl_memcpy (p_new_cq->p_cq_ul_resources,\r
+                       p_umv_buf->p_inout_buf,\r
+                       p_hobul->p_hca_ul_info->cq_ul_resources_sz);\r
+\r
+               cl_memcpy (&p_new_cq->cq_idx,\r
+                       ((u_int8_t *)p_umv_buf->p_inout_buf + \r
+                       p_hobul->p_hca_ul_info->cq_ul_resources_sz),\r
+                       sizeof (u_int32_t));\r
+\r
+               if (HH_OK !=\r
+                       THHUL_cqm_create_cq_done (p_hobul->hhul_hca_hndl,\r
+                       p_new_cq->hhul_cq_hndl,\r
+                       p_new_cq->cq_idx,\r
+                       p_new_cq->p_cq_ul_resources))\r
+               {\r
+                       CL_TRACE (MLNX_TRACE_LVL_1, mlnx_dbg_lvl,\r
+                               ("Call THHUL_cqm_create_cq_done Failed\n"));\r
+                       goto err;\r
+               }\r
+\r
+               CL_TRACE (MLNX_TRACE_LVL_7, mlnx_dbg_lvl,\r
+                       ("Newly created CQ cq_idx 0x%x (CQ size %d)\n",p_new_cq->cq_idx, p_new_cq->cq_size)); \r
        }\r
+       else\r
+       {\r
+err:\r
+               if (p_new_cq->p_cq_ul_resources)\r
+                       cl_free (p_new_cq->p_cq_ul_resources);\r
 \r
-        if (IB_SUCCESS == status)\r
-        {\r
-        \r
-            if (IB_SUCCESS != p_umv_buf->status) \r
-            {\r
-                CL_TRACE (MLNX_TRACE_LVL_1, mlnx_dbg_lvl,\r
-                          ("Bad status %ld\n", p_umv_buf->status));\r
-                status = p_umv_buf->status;\r
-                break;\r
-            }\r
-            else if ((buf_size - sizeof (mlnx_ual_cq_info_t *)) != \r
-                     p_umv_buf->output_size) \r
-            {\r
-                CL_TRACE (MLNX_TRACE_LVL_1, mlnx_dbg_lvl,\r
-                          ("Bad user priv buffer size (exp - 4) = %d, res = %ld\n",\r
-                          buf_size, p_umv_buf->output_size));\r
-                status = IB_ERROR;\r
-                break;\r
-            }\r
-\r
-            cl_memcpy (p_new_cq->p_cq_ul_resources,\r
-                       p_umv_buf->p_inout_buf,\r
-                       p_hobul->p_hca_ul_info->cq_ul_resources_sz);\r
-\r
-            cl_memcpy (&p_new_cq->cq_idx,\r
-                       ((u_int8_t *)p_umv_buf->p_inout_buf + \r
-                        p_hobul->p_hca_ul_info->cq_ul_resources_sz),\r
-                       sizeof (u_int32_t));\r
-\r
-            if (HH_OK !=\r
-                THHUL_cqm_create_cq_done (p_hobul->hhul_hca_hndl,\r
-                                          p_new_cq->hhul_cq_hndl,\r
-                                          p_new_cq->cq_idx,\r
-                                          p_new_cq->p_cq_ul_resources))\r
-            {\r
-                CL_TRACE (MLNX_TRACE_LVL_1, mlnx_dbg_lvl,\r
-                          ("Call THHUL_cqm_create_cq_done Failed\n"));\r
-                status = IB_ERROR;\r
-                break;\r
-            }\r
-        \r
-            CL_TRACE (MLNX_TRACE_LVL_7, mlnx_dbg_lvl,\r
-                ("Newly created CQ cq_idx 0x%x (CQ size %d)\n",p_new_cq->cq_idx, p_new_cq->cq_size)); \r
-        }\r
-        else\r
-        {\r
-            if (p_new_cq->p_cq_ul_resources);\r
-            {\r
-                cl_free (p_new_cq->p_cq_ul_resources);\r
-            }\r
-            cl_free (p_new_cq);\r
-           *ph_uvp_cq = NULL;\r
-        }\r
+               cl_free (p_new_cq);\r
+               *ph_uvp_cq = NULL;\r
+       }\r
 \r
-    } while (0);\r
-    \r
-    cl_free (p_umv_buf->p_inout_buf);\r
-    p_umv_buf->p_inout_buf = NULL;\r
-    \r
-    FUNC_EXIT;\r
-    return;\r
+       cl_free (p_umv_buf->p_inout_buf);\r
+       p_umv_buf->p_inout_buf = NULL;\r
+\r
+       FUNC_EXIT;\r
+       return;\r
 }\r
 \r
 \r
index 46112c8..0c5599e 100644 (file)
@@ -190,87 +190,77 @@ mlnx_post_allocate_pd (
                OUT                     ib_pd_handle_t                          *ph_uvp_pd,\r
        IN                              ci_umv_buf_t                            *p_umv_buf )\r
 {\r
-    ib_api_status_t status;\r
-    mlnx_ual_hobul_t *p_hobul = (mlnx_ual_hobul_t *)((void *)h_uvp_ca);\r
-    mlnx_ual_pd_info_t *p_new_pd;\r
+       mlnx_ual_hobul_t *p_hobul = (mlnx_ual_hobul_t *)((void *)h_uvp_ca);\r
+       mlnx_ual_pd_info_t *p_new_pd;\r
 \r
-    MT_size_t size;\r
+       MT_size_t size;\r
 \r
-    FUNC_ENTER;\r
+       FUNC_ENTER;\r
 \r
-    CL_ASSERT(p_hobul);\r
-    CL_ASSERT(p_umv_buf);\r
+       CL_ASSERT(p_hobul);\r
+       CL_ASSERT(p_umv_buf);\r
 \r
-    status = ioctl_status;\r
-    \r
-    do \r
-    {\r
        size = p_hobul->p_hca_ul_info->pd_ul_resources_sz + \r
-                     sizeof (u_int32_t) + sizeof (mlnx_ual_pd_info_t *);\r
-\r
-        cl_memcpy (&p_new_pd,\r
-                   ((u_int8_t *)p_umv_buf->p_inout_buf + size - \r
-                    sizeof (mlnx_ual_pd_info_t*)),\r
-                   sizeof (mlnx_ual_pd_info_t *));\r
-        CL_ASSERT(p_new_pd);\r
-        *ph_uvp_pd = (uvp_pd_handle_t) p_new_pd;\r
-\r
-        if (IB_SUCCESS == status)\r
-        {\r
-            if (IB_SUCCESS != p_umv_buf->status) \r
-            {\r
-                CL_TRACE (MLNX_TRACE_LVL_1, mlnx_dbg_lvl,\r
-                          ("post_allocate_pd return status %s\n", \r
-                           ib_get_err_str(p_umv_buf->status)));\r
-                status = p_umv_buf->status;\r
-                break;\r
-            }\r
-            else if ((size - sizeof (mlnx_ual_pd_info_t *)) != \r
-                     p_umv_buf->output_size )\r
-            {\r
-                CL_TRACE (MLNX_TRACE_LVL_1, mlnx_dbg_lvl,\r
-                          ("Bad user priv buffer size exp = %d, res = %ld\n",\r
-                          size, p_umv_buf->output_size));\r
-                status = IB_ERROR;\r
-                break;\r
-            }\r
+               sizeof (u_int32_t) + sizeof (mlnx_ual_pd_info_t *);\r
+\r
+       cl_memcpy (&p_new_pd,\r
+               ((u_int8_t *)p_umv_buf->p_inout_buf + size - \r
+               sizeof (mlnx_ual_pd_info_t*)),\r
+               sizeof (mlnx_ual_pd_info_t *));\r
+       CL_ASSERT(p_new_pd);\r
+       *ph_uvp_pd = (uvp_pd_handle_t) p_new_pd;\r
+\r
+       if ( ioctl_status == IB_SUCCESS )\r
+       {\r
+               if (IB_SUCCESS != p_umv_buf->status) \r
+               {\r
+                       CL_TRACE (MLNX_TRACE_LVL_1, mlnx_dbg_lvl,\r
+                               ("post_allocate_pd return status %s\n", \r
+                               ib_get_err_str(p_umv_buf->status)));\r
+                       goto err;\r
+               }\r
+               else if ((size - sizeof (mlnx_ual_pd_info_t *)) != \r
+                       p_umv_buf->output_size )\r
+               {\r
+                       CL_TRACE (MLNX_TRACE_LVL_1, mlnx_dbg_lvl,\r
+                               ("Bad user priv buffer size exp = %d, res = %ld\n",\r
+                               size, p_umv_buf->output_size));\r
+                       goto err;\r
+               }\r
 \r
-            cl_memcpy (p_new_pd->p_pd_ul_resources,\r
-                       p_umv_buf->p_inout_buf,\r
-                      p_hobul->p_hca_ul_info->pd_ul_resources_sz);\r
-            cl_memcpy (&p_new_pd->pd_idx,\r
-                       ((u_int8_t *)p_umv_buf->p_inout_buf + \r
-                        p_hobul->p_hca_ul_info->pd_ul_resources_sz),\r
-                       sizeof (u_int32_t));\r
-\r
-            if (HH_OK !=\r
-                THHUL_pdm_alloc_pd_done (p_hobul->hhul_hca_hndl,\r
-                                         p_new_pd->hhul_pd_hndl,\r
-                                         p_new_pd->pd_idx,\r
-                                         p_new_pd->p_pd_ul_resources))\r
-            {\r
-                CL_TRACE (MLNX_TRACE_LVL_1, mlnx_dbg_lvl,\r
-                          ("Call THHUL_pdm_alloc_pd_done Failed\n"));\r
-                status = IB_ERROR;\r
-                break;\r
-            }\r
-        }\r
-        else\r
-        {\r
-            if (p_new_pd->p_pd_ul_resources);\r
-            {\r
-                cl_free (p_new_pd->p_pd_ul_resources);\r
-            }\r
-            cl_free (p_new_pd);\r
-        }\r
+               cl_memcpy (p_new_pd->p_pd_ul_resources,\r
+                       p_umv_buf->p_inout_buf,\r
+                       p_hobul->p_hca_ul_info->pd_ul_resources_sz);\r
+               cl_memcpy (&p_new_pd->pd_idx,\r
+                       ((u_int8_t *)p_umv_buf->p_inout_buf + \r
+                       p_hobul->p_hca_ul_info->pd_ul_resources_sz),\r
+                       sizeof (u_int32_t));\r
+\r
+               if (HH_OK !=\r
+                       THHUL_pdm_alloc_pd_done (p_hobul->hhul_hca_hndl,\r
+                       p_new_pd->hhul_pd_hndl,\r
+                       p_new_pd->pd_idx,\r
+                       p_new_pd->p_pd_ul_resources))\r
+               {\r
+                       CL_TRACE (MLNX_TRACE_LVL_1, mlnx_dbg_lvl,\r
+                               ("Call THHUL_pdm_alloc_pd_done Failed\n"));\r
+                       goto err;\r
+               }\r
+       }\r
+       else\r
+       {\r
+err:\r
+               if (p_new_pd->p_pd_ul_resources)\r
+                       cl_free (p_new_pd->p_pd_ul_resources);\r
 \r
-    } while (0);\r
-    \r
-    cl_free (p_umv_buf->p_inout_buf);\r
+               cl_free (p_new_pd);\r
+               *ph_uvp_pd = NULL;\r
+       }\r
 \r
-    FUNC_EXIT;\r
-    return;\r
+       cl_free (p_umv_buf->p_inout_buf);\r
 \r
+       FUNC_EXIT;\r
+       return;\r
 }\r
 \r
 \r
index b6d5273..21cb009 100644 (file)
@@ -251,94 +251,83 @@ mlnx_post_create_qp (
                OUT                     ib_qp_handle_t                          *ph_uvp_qp,\r
        IN                              ci_umv_buf_t                            *p_umv_buf )\r
 {\r
-    ib_api_status_t status;\r
-    mlnx_ual_pd_info_t *p_pd_info = (mlnx_ual_pd_info_t *)((void*)h_uvp_pd);\r
-    mlnx_ual_hobul_t *p_hobul;\r
-    mlnx_ual_qp_info_t *p_new_qp;\r
-    MT_size_t buf_size;\r
-\r
-    FUNC_ENTER;\r
-    CL_ASSERT(p_pd_info);\r
-    CL_ASSERT(p_umv_buf);\r
+       mlnx_ual_pd_info_t *p_pd_info = (mlnx_ual_pd_info_t *)((void*)h_uvp_pd);\r
+       mlnx_ual_hobul_t *p_hobul;\r
+       mlnx_ual_qp_info_t *p_new_qp;\r
+       MT_size_t buf_size;\r
 \r
-    p_hobul = p_pd_info->p_hobul;\r
-    CL_ASSERT(p_hobul);\r
+       FUNC_ENTER;\r
+       CL_ASSERT(p_pd_info);\r
+       CL_ASSERT(p_umv_buf);\r
 \r
-       status = ioctl_status;\r
+       p_hobul = p_pd_info->p_hobul;\r
+       CL_ASSERT(p_hobul);\r
 \r
-    do \r
-    {\r
-        buf_size = p_hobul->p_hca_ul_info->qp_ul_resources_sz + \r
-               sizeof (u_int32_t) + sizeof (mlnx_ual_qp_info_t *);\r
+       buf_size = p_hobul->p_hca_ul_info->qp_ul_resources_sz + \r
+               sizeof (u_int32_t) + sizeof (mlnx_ual_qp_info_t *);\r
 \r
-        /*\r
-         * Retrieve our qp_info back from priv buffer\r
-         */\r
-        cl_memcpy (&p_new_qp, ((u_int8_t *)p_umv_buf->p_inout_buf + buf_size -\r
-                   sizeof (mlnx_ual_qp_info_t *)), sizeof (mlnx_ual_qp_info_t *));\r
-        CL_ASSERT(p_new_qp);\r
-        *ph_uvp_qp = (uvp_qp_handle_t) p_new_qp;\r
+       /* Retrieve our qp_info back from priv buffer */\r
+       cl_memcpy (&p_new_qp, ((u_int8_t *)p_umv_buf->p_inout_buf + buf_size -\r
+               sizeof (mlnx_ual_qp_info_t *)), sizeof (mlnx_ual_qp_info_t *));\r
+       CL_ASSERT(p_new_qp);\r
 \r
+       *ph_uvp_qp = (uvp_qp_handle_t) p_new_qp;\r
 \r
-        if (IB_SUCCESS == status)\r
-        {\r
-            if (IB_SUCCESS != p_umv_buf->status) \r
-            {\r
-                CL_TRACE (MLNX_TRACE_LVL_1, mlnx_dbg_lvl,\r
-                          ("Bad status %ld\n", p_umv_buf->status));\r
-                status = p_umv_buf->status;\r
-                break;\r
-            }\r
-            else if ((buf_size - sizeof (mlnx_ual_qp_info_t *)) != \r
-                     p_umv_buf->output_size) \r
-            {\r
-                CL_TRACE (MLNX_TRACE_LVL_1, mlnx_dbg_lvl,\r
-                          ("Bad user priv buffer size exp = %d, res = %ld\n",\r
-                          buf_size, p_umv_buf->output_size));\r
-                status = IB_ERROR;\r
-                break;\r
-            }\r
-\r
-            cl_memcpy (p_new_qp->p_qp_ul_resources,\r
-                       p_umv_buf->p_inout_buf,\r
-                       p_hobul->p_hca_ul_info->qp_ul_resources_sz);\r
-\r
-            cl_memcpy (&p_new_qp->qp_idx,\r
-                       ((u_int8_t *)p_umv_buf->p_inout_buf + \r
-                        p_hobul->p_hca_ul_info->qp_ul_resources_sz),\r
-                       sizeof (u_int32_t));\r
-\r
-            if (HH_OK !=\r
-                THHUL_qpm_create_qp_done (p_hobul->hhul_hca_hndl,\r
-                                          p_new_qp->hhul_qp_hndl,\r
-                                          p_new_qp->qp_idx,\r
-                                          p_new_qp->p_qp_ul_resources))\r
-            {\r
-                CL_TRACE (MLNX_TRACE_LVL_1, mlnx_dbg_lvl,\r
-                          ("Call THHUL_qpm_create_qp_done Failed\n"));\r
-                status = IB_ERROR;\r
-                break;\r
-            }\r
-        \r
-            CL_TRACE (MLNX_TRACE_LVL_7, mlnx_dbg_lvl,\r
-                      ("Newly created QP qp_idx 0x%x\n",p_new_qp->qp_idx)); \r
-        }\r
-        else\r
-        {\r
-            if (p_new_qp->p_qp_ul_resources);\r
-            {\r
-                cl_free (p_new_qp->p_qp_ul_resources);\r
-            }\r
-            cl_free (p_new_qp);\r
-        }\r
+       if ( ioctl_status == IB_SUCCESS )\r
+       {\r
+               if (IB_SUCCESS != p_umv_buf->status) \r
+               {\r
+                       CL_TRACE (MLNX_TRACE_LVL_1, mlnx_dbg_lvl,\r
+                               ("Bad status %ld\n", p_umv_buf->status));\r
+                       goto err;\r
+               }\r
+               else if ((buf_size - sizeof (mlnx_ual_qp_info_t *)) != \r
+                       p_umv_buf->output_size) \r
+               {\r
+                       CL_TRACE (MLNX_TRACE_LVL_1, mlnx_dbg_lvl,\r
+                               ("Bad user priv buffer size exp = %d, res = %ld\n",\r
+                               buf_size, p_umv_buf->output_size));\r
+                       goto err;\r
+               }\r
+\r
+               cl_memcpy (p_new_qp->p_qp_ul_resources,\r
+                       p_umv_buf->p_inout_buf,\r
+                       p_hobul->p_hca_ul_info->qp_ul_resources_sz);\r
+\r
+               cl_memcpy (&p_new_qp->qp_idx,\r
+                       ((u_int8_t *)p_umv_buf->p_inout_buf + \r
+                       p_hobul->p_hca_ul_info->qp_ul_resources_sz),\r
+                       sizeof (u_int32_t));\r
+\r
+               if (HH_OK !=\r
+                       THHUL_qpm_create_qp_done (p_hobul->hhul_hca_hndl,\r
+                       p_new_qp->hhul_qp_hndl,\r
+                       p_new_qp->qp_idx,\r
+                       p_new_qp->p_qp_ul_resources))\r
+               {\r
+                       CL_TRACE (MLNX_TRACE_LVL_1, mlnx_dbg_lvl,\r
+                               ("Call THHUL_qpm_create_qp_done Failed\n"));\r
+                       goto err;\r
+               }\r
+\r
+               CL_TRACE (MLNX_TRACE_LVL_7, mlnx_dbg_lvl,\r
+                       ("Newly created QP qp_idx 0x%x\n",p_new_qp->qp_idx)); \r
+       }\r
+       else\r
+       {\r
+err:\r
+               if (p_new_qp->p_qp_ul_resources)\r
+                       cl_free (p_new_qp->p_qp_ul_resources);\r
 \r
-    } while (0);\r
+               cl_free (p_new_qp);\r
+               *ph_uvp_qp = NULL;\r
+       }\r
 \r
-    cl_free (p_umv_buf->p_inout_buf);\r
-    p_umv_buf->p_inout_buf = NULL;\r
+       cl_free (p_umv_buf->p_inout_buf);\r
+       p_umv_buf->p_inout_buf = NULL;\r
 \r
-    FUNC_EXIT;\r
-    return;\r
+       FUNC_EXIT;\r
+       return;\r
 }\r
 \r
 \r