aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorHoang-Nam Nguyen <hnguyen@de.ibm.com>2007-07-12 11:49:02 -0400
committerRoland Dreier <rolandd@cisco.com>2007-07-17 21:37:39 -0400
commita1a6ff11006c3a056cda9e8b13e7388fba3e69a1 (patch)
tree7741708bf408ff3fbbf01d75f5ab30b73a1db583 /drivers/infiniband
parent3df78f81e070c0e3330ae1bd40385e2f0d6fea2c (diff)
IB/ehca: Use common error code mapping instead of specific ones
Instead of one error mapping function for each potential error source in ehca_mrmw.c, use a centralized function that handles all cases, saving a three-figure line count. Signed-off-by: Joachim Fenkes <fenkes@de.ibm.com> Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/hw/ehca/ehca_mrmw.c195
-rw-r--r--drivers/infiniband/hw/ehca/ehca_mrmw.h14
-rw-r--r--drivers/infiniband/hw/ehca/ehca_tools.h3
3 files changed, 15 insertions, 197 deletions
diff --git a/drivers/infiniband/hw/ehca/ehca_mrmw.c b/drivers/infiniband/hw/ehca/ehca_mrmw.c
index 98f253147d2c..7c1656a7e1af 100644
--- a/drivers/infiniband/hw/ehca/ehca_mrmw.c
+++ b/drivers/infiniband/hw/ehca/ehca_mrmw.c
@@ -537,7 +537,7 @@ int ehca_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr)
537 "hca_hndl=%lx mr_hndl=%lx lkey=%x", 537 "hca_hndl=%lx mr_hndl=%lx lkey=%x",
538 h_ret, mr, shca->ipz_hca_handle.handle, 538 h_ret, mr, shca->ipz_hca_handle.handle,
539 e_mr->ipz_mr_handle.handle, mr->lkey); 539 e_mr->ipz_mr_handle.handle, mr->lkey);
540 ret = ehca_mrmw_map_hrc_query_mr(h_ret); 540 ret = ehca2ib_return_code(h_ret);
541 goto query_mr_exit1; 541 goto query_mr_exit1;
542 } 542 }
543 mr_attr->pd = mr->pd; 543 mr_attr->pd = mr->pd;
@@ -597,7 +597,7 @@ int ehca_dereg_mr(struct ib_mr *mr)
597 "e_mr=%p hca_hndl=%lx mr_hndl=%lx mr->lkey=%x", 597 "e_mr=%p hca_hndl=%lx mr_hndl=%lx mr->lkey=%x",
598 h_ret, shca, e_mr, shca->ipz_hca_handle.handle, 598 h_ret, shca, e_mr, shca->ipz_hca_handle.handle,
599 e_mr->ipz_mr_handle.handle, mr->lkey); 599 e_mr->ipz_mr_handle.handle, mr->lkey);
600 ret = ehca_mrmw_map_hrc_free_mr(h_ret); 600 ret = ehca2ib_return_code(h_ret);
601 goto dereg_mr_exit0; 601 goto dereg_mr_exit0;
602 } 602 }
603 603
@@ -637,7 +637,7 @@ struct ib_mw *ehca_alloc_mw(struct ib_pd *pd)
637 ehca_err(pd->device, "hipz_mw_allocate failed, h_ret=%lx " 637 ehca_err(pd->device, "hipz_mw_allocate failed, h_ret=%lx "
638 "shca=%p hca_hndl=%lx mw=%p", 638 "shca=%p hca_hndl=%lx mw=%p",
639 h_ret, shca, shca->ipz_hca_handle.handle, e_mw); 639 h_ret, shca, shca->ipz_hca_handle.handle, e_mw);
640 ib_mw = ERR_PTR(ehca_mrmw_map_hrc_alloc(h_ret)); 640 ib_mw = ERR_PTR(ehca2ib_return_code(h_ret));
641 goto alloc_mw_exit1; 641 goto alloc_mw_exit1;
642 } 642 }
643 /* successful MW allocation */ 643 /* successful MW allocation */
@@ -680,7 +680,7 @@ int ehca_dealloc_mw(struct ib_mw *mw)
680 "mw=%p rkey=%x hca_hndl=%lx mw_hndl=%lx", 680 "mw=%p rkey=%x hca_hndl=%lx mw_hndl=%lx",
681 h_ret, shca, mw, mw->rkey, shca->ipz_hca_handle.handle, 681 h_ret, shca, mw, mw->rkey, shca->ipz_hca_handle.handle,
682 e_mw->ipz_mw_handle.handle); 682 e_mw->ipz_mw_handle.handle);
683 return ehca_mrmw_map_hrc_free_mw(h_ret); 683 return ehca2ib_return_code(h_ret);
684 } 684 }
685 /* successful deallocation */ 685 /* successful deallocation */
686 ehca_mw_delete(e_mw); 686 ehca_mw_delete(e_mw);
@@ -923,7 +923,7 @@ int ehca_dealloc_fmr(struct ib_fmr *fmr)
923 "hca_hndl=%lx fmr_hndl=%lx fmr->lkey=%x", 923 "hca_hndl=%lx fmr_hndl=%lx fmr->lkey=%x",
924 h_ret, e_fmr, shca->ipz_hca_handle.handle, 924 h_ret, e_fmr, shca->ipz_hca_handle.handle,
925 e_fmr->ipz_mr_handle.handle, fmr->lkey); 925 e_fmr->ipz_mr_handle.handle, fmr->lkey);
926 ret = ehca_mrmw_map_hrc_free_mr(h_ret); 926 ret = ehca2ib_return_code(h_ret);
927 goto free_fmr_exit0; 927 goto free_fmr_exit0;
928 } 928 }
929 /* successful deregistration */ 929 /* successful deregistration */
@@ -964,7 +964,7 @@ int ehca_reg_mr(struct ehca_shca *shca,
964 if (h_ret != H_SUCCESS) { 964 if (h_ret != H_SUCCESS) {
965 ehca_err(&shca->ib_device, "hipz_alloc_mr failed, h_ret=%lx " 965 ehca_err(&shca->ib_device, "hipz_alloc_mr failed, h_ret=%lx "
966 "hca_hndl=%lx", h_ret, shca->ipz_hca_handle.handle); 966 "hca_hndl=%lx", h_ret, shca->ipz_hca_handle.handle);
967 ret = ehca_mrmw_map_hrc_alloc(h_ret); 967 ret = ehca2ib_return_code(h_ret);
968 goto ehca_reg_mr_exit0; 968 goto ehca_reg_mr_exit0;
969 } 969 }
970 970
@@ -1079,7 +1079,7 @@ int ehca_reg_mr_rpages(struct ehca_shca *shca,
1079 shca->ipz_hca_handle.handle, 1079 shca->ipz_hca_handle.handle,
1080 e_mr->ipz_mr_handle.handle, 1080 e_mr->ipz_mr_handle.handle,
1081 e_mr->ib.ib_mr.lkey); 1081 e_mr->ib.ib_mr.lkey);
1082 ret = ehca_mrmw_map_hrc_rrpg_last(h_ret); 1082 ret = ehca2ib_return_code(h_ret);
1083 break; 1083 break;
1084 } else 1084 } else
1085 ret = 0; 1085 ret = 0;
@@ -1090,7 +1090,7 @@ int ehca_reg_mr_rpages(struct ehca_shca *shca,
1090 e_mr->ib.ib_mr.lkey, 1090 e_mr->ib.ib_mr.lkey,
1091 shca->ipz_hca_handle.handle, 1091 shca->ipz_hca_handle.handle,
1092 e_mr->ipz_mr_handle.handle); 1092 e_mr->ipz_mr_handle.handle);
1093 ret = ehca_mrmw_map_hrc_rrpg_notlast(h_ret); 1093 ret = ehca2ib_return_code(h_ret);
1094 break; 1094 break;
1095 } else 1095 } else
1096 ret = 0; 1096 ret = 0;
@@ -1254,7 +1254,7 @@ int ehca_rereg_mr(struct ehca_shca *shca,
1254 h_ret, e_mr, shca->ipz_hca_handle.handle, 1254 h_ret, e_mr, shca->ipz_hca_handle.handle,
1255 e_mr->ipz_mr_handle.handle, 1255 e_mr->ipz_mr_handle.handle,
1256 e_mr->ib.ib_mr.lkey); 1256 e_mr->ib.ib_mr.lkey);
1257 ret = ehca_mrmw_map_hrc_free_mr(h_ret); 1257 ret = ehca2ib_return_code(h_ret);
1258 goto ehca_rereg_mr_exit0; 1258 goto ehca_rereg_mr_exit0;
1259 } 1259 }
1260 /* clean ehca_mr_t, without changing struct ib_mr and lock */ 1260 /* clean ehca_mr_t, without changing struct ib_mr and lock */
@@ -1351,7 +1351,7 @@ int ehca_unmap_one_fmr(struct ehca_shca *shca,
1351 h_ret, e_fmr, shca->ipz_hca_handle.handle, 1351 h_ret, e_fmr, shca->ipz_hca_handle.handle,
1352 e_fmr->ipz_mr_handle.handle, 1352 e_fmr->ipz_mr_handle.handle,
1353 e_fmr->ib.ib_fmr.lkey); 1353 e_fmr->ib.ib_fmr.lkey);
1354 ret = ehca_mrmw_map_hrc_free_mr(h_ret); 1354 ret = ehca2ib_return_code(h_ret);
1355 goto ehca_unmap_one_fmr_exit0; 1355 goto ehca_unmap_one_fmr_exit0;
1356 } 1356 }
1357 /* clean ehca_mr_t, without changing lock */ 1357 /* clean ehca_mr_t, without changing lock */
@@ -1420,7 +1420,7 @@ int ehca_reg_smr(struct ehca_shca *shca,
1420 shca->ipz_hca_handle.handle, 1420 shca->ipz_hca_handle.handle,
1421 e_origmr->ipz_mr_handle.handle, 1421 e_origmr->ipz_mr_handle.handle,
1422 e_origmr->ib.ib_mr.lkey); 1422 e_origmr->ib.ib_mr.lkey);
1423 ret = ehca_mrmw_map_hrc_reg_smr(h_ret); 1423 ret = ehca2ib_return_code(h_ret);
1424 goto ehca_reg_smr_exit0; 1424 goto ehca_reg_smr_exit0;
1425 } 1425 }
1426 /* successful registration */ 1426 /* successful registration */
@@ -1539,7 +1539,7 @@ int ehca_reg_maxmr(struct ehca_shca *shca,
1539 h_ret, e_origmr, shca->ipz_hca_handle.handle, 1539 h_ret, e_origmr, shca->ipz_hca_handle.handle,
1540 e_origmr->ipz_mr_handle.handle, 1540 e_origmr->ipz_mr_handle.handle,
1541 e_origmr->ib.ib_mr.lkey); 1541 e_origmr->ib.ib_mr.lkey);
1542 return ehca_mrmw_map_hrc_reg_smr(h_ret); 1542 return ehca2ib_return_code(h_ret);
1543 } 1543 }
1544 /* successful registration */ 1544 /* successful registration */
1545 e_newmr->num_pages = e_origmr->num_pages; 1545 e_newmr->num_pages = e_origmr->num_pages;
@@ -2043,177 +2043,6 @@ void ehca_mrmw_reverse_map_acl(const u32 *hipz_acl,
2043/*----------------------------------------------------------------------*/ 2043/*----------------------------------------------------------------------*/
2044 2044
2045/* 2045/*
2046 * map HIPZ rc to IB retcodes for MR/MW allocations
2047 * Used for hipz_mr_reg_alloc and hipz_mw_alloc.
2048 */
2049int ehca_mrmw_map_hrc_alloc(const u64 hipz_rc)
2050{
2051 switch (hipz_rc) {
2052 case H_SUCCESS: /* successful completion */
2053 return 0;
2054 case H_NOT_ENOUGH_RESOURCES: /* insufficient resources */
2055 case H_CONSTRAINED: /* resource constraint */
2056 case H_NO_MEM:
2057 return -ENOMEM;
2058 case H_BUSY: /* long busy */
2059 return -EBUSY;
2060 default:
2061 return -EINVAL;
2062 }
2063} /* end ehca_mrmw_map_hrc_alloc() */
2064
2065/*----------------------------------------------------------------------*/
2066
2067/*
2068 * map HIPZ rc to IB retcodes for MR register rpage
2069 * Used for hipz_h_register_rpage_mr at registering last page
2070 */
2071int ehca_mrmw_map_hrc_rrpg_last(const u64 hipz_rc)
2072{
2073 switch (hipz_rc) {
2074 case H_SUCCESS: /* registration complete */
2075 return 0;
2076 case H_PAGE_REGISTERED: /* page registered */
2077 case H_ADAPTER_PARM: /* invalid adapter handle */
2078 case H_RH_PARM: /* invalid resource handle */
2079/* case H_QT_PARM: invalid queue type */
2080 case H_PARAMETER: /*
2081 * invalid logical address,
2082 * or count zero or greater 512
2083 */
2084 case H_TABLE_FULL: /* page table full */
2085 case H_HARDWARE: /* HCA not operational */
2086 return -EINVAL;
2087 case H_BUSY: /* long busy */
2088 return -EBUSY;
2089 default:
2090 return -EINVAL;
2091 }
2092} /* end ehca_mrmw_map_hrc_rrpg_last() */
2093
2094/*----------------------------------------------------------------------*/
2095
2096/*
2097 * map HIPZ rc to IB retcodes for MR register rpage
2098 * Used for hipz_h_register_rpage_mr at registering one page, but not last page
2099 */
2100int ehca_mrmw_map_hrc_rrpg_notlast(const u64 hipz_rc)
2101{
2102 switch (hipz_rc) {
2103 case H_PAGE_REGISTERED: /* page registered */
2104 return 0;
2105 case H_SUCCESS: /* registration complete */
2106 case H_ADAPTER_PARM: /* invalid adapter handle */
2107 case H_RH_PARM: /* invalid resource handle */
2108/* case H_QT_PARM: invalid queue type */
2109 case H_PARAMETER: /*
2110 * invalid logical address,
2111 * or count zero or greater 512
2112 */
2113 case H_TABLE_FULL: /* page table full */
2114 case H_HARDWARE: /* HCA not operational */
2115 return -EINVAL;
2116 case H_BUSY: /* long busy */
2117 return -EBUSY;
2118 default:
2119 return -EINVAL;
2120 }
2121} /* end ehca_mrmw_map_hrc_rrpg_notlast() */
2122
2123/*----------------------------------------------------------------------*/
2124
2125/* map HIPZ rc to IB retcodes for MR query. Used for hipz_mr_query. */
2126int ehca_mrmw_map_hrc_query_mr(const u64 hipz_rc)
2127{
2128 switch (hipz_rc) {
2129 case H_SUCCESS: /* successful completion */
2130 return 0;
2131 case H_ADAPTER_PARM: /* invalid adapter handle */
2132 case H_RH_PARM: /* invalid resource handle */
2133 return -EINVAL;
2134 case H_BUSY: /* long busy */
2135 return -EBUSY;
2136 default:
2137 return -EINVAL;
2138 }
2139} /* end ehca_mrmw_map_hrc_query_mr() */
2140
2141/*----------------------------------------------------------------------*/
2142/*----------------------------------------------------------------------*/
2143
2144/*
2145 * map HIPZ rc to IB retcodes for freeing MR resource
2146 * Used for hipz_h_free_resource_mr
2147 */
2148int ehca_mrmw_map_hrc_free_mr(const u64 hipz_rc)
2149{
2150 switch (hipz_rc) {
2151 case H_SUCCESS: /* resource freed */
2152 return 0;
2153 case H_ADAPTER_PARM: /* invalid adapter handle */
2154 case H_RH_PARM: /* invalid resource handle */
2155 case H_R_STATE: /* invalid resource state */
2156 case H_HARDWARE: /* HCA not operational */
2157 return -EINVAL;
2158 case H_RESOURCE: /* Resource in use */
2159 case H_BUSY: /* long busy */
2160 return -EBUSY;
2161 default:
2162 return -EINVAL;
2163 }
2164} /* end ehca_mrmw_map_hrc_free_mr() */
2165
2166/*----------------------------------------------------------------------*/
2167
2168/*
2169 * map HIPZ rc to IB retcodes for freeing MW resource
2170 * Used for hipz_h_free_resource_mw
2171 */
2172int ehca_mrmw_map_hrc_free_mw(const u64 hipz_rc)
2173{
2174 switch (hipz_rc) {
2175 case H_SUCCESS: /* resource freed */
2176 return 0;
2177 case H_ADAPTER_PARM: /* invalid adapter handle */
2178 case H_RH_PARM: /* invalid resource handle */
2179 case H_R_STATE: /* invalid resource state */
2180 case H_HARDWARE: /* HCA not operational */
2181 return -EINVAL;
2182 case H_RESOURCE: /* Resource in use */
2183 case H_BUSY: /* long busy */
2184 return -EBUSY;
2185 default:
2186 return -EINVAL;
2187 }
2188} /* end ehca_mrmw_map_hrc_free_mw() */
2189
2190/*----------------------------------------------------------------------*/
2191
2192/*
2193 * map HIPZ rc to IB retcodes for SMR registrations
2194 * Used for hipz_h_register_smr.
2195 */
2196int ehca_mrmw_map_hrc_reg_smr(const u64 hipz_rc)
2197{
2198 switch (hipz_rc) {
2199 case H_SUCCESS: /* successful completion */
2200 return 0;
2201 case H_ADAPTER_PARM: /* invalid adapter handle */
2202 case H_RH_PARM: /* invalid resource handle */
2203 case H_MEM_PARM: /* invalid MR virtual address */
2204 case H_MEM_ACCESS_PARM: /* invalid access controls */
2205 case H_NOT_ENOUGH_RESOURCES: /* insufficient resources */
2206 return -EINVAL;
2207 case H_BUSY: /* long busy */
2208 return -EBUSY;
2209 default:
2210 return -EINVAL;
2211 }
2212} /* end ehca_mrmw_map_hrc_reg_smr() */
2213
2214/*----------------------------------------------------------------------*/
2215
2216/*
2217 * MR destructor and constructor 2046 * MR destructor and constructor
2218 * used in Reregister MR verb, sets all fields in ehca_mr_t to 0, 2047 * used in Reregister MR verb, sets all fields in ehca_mr_t to 0,
2219 * except struct ib_mr and spinlock 2048 * except struct ib_mr and spinlock
diff --git a/drivers/infiniband/hw/ehca/ehca_mrmw.h b/drivers/infiniband/hw/ehca/ehca_mrmw.h
index d936e40a5748..fb69eded3b48 100644
--- a/drivers/infiniband/hw/ehca/ehca_mrmw.h
+++ b/drivers/infiniband/hw/ehca/ehca_mrmw.h
@@ -121,20 +121,6 @@ void ehca_mrmw_set_pgsize_hipz_acl(u32 *hipz_acl);
121void ehca_mrmw_reverse_map_acl(const u32 *hipz_acl, 121void ehca_mrmw_reverse_map_acl(const u32 *hipz_acl,
122 int *ib_acl); 122 int *ib_acl);
123 123
124int ehca_mrmw_map_hrc_alloc(const u64 hipz_rc);
125
126int ehca_mrmw_map_hrc_rrpg_last(const u64 hipz_rc);
127
128int ehca_mrmw_map_hrc_rrpg_notlast(const u64 hipz_rc);
129
130int ehca_mrmw_map_hrc_query_mr(const u64 hipz_rc);
131
132int ehca_mrmw_map_hrc_free_mr(const u64 hipz_rc);
133
134int ehca_mrmw_map_hrc_free_mw(const u64 hipz_rc);
135
136int ehca_mrmw_map_hrc_reg_smr(const u64 hipz_rc);
137
138void ehca_mr_deletenew(struct ehca_mr *mr); 124void ehca_mr_deletenew(struct ehca_mr *mr);
139 125
140#endif /*_EHCA_MRMW_H_*/ 126#endif /*_EHCA_MRMW_H_*/
diff --git a/drivers/infiniband/hw/ehca/ehca_tools.h b/drivers/infiniband/hw/ehca/ehca_tools.h
index 03b185f873da..fd8238b32153 100644
--- a/drivers/infiniband/hw/ehca/ehca_tools.h
+++ b/drivers/infiniband/hw/ehca/ehca_tools.h
@@ -161,8 +161,11 @@ static inline int ehca2ib_return_code(u64 ehca_rc)
161 switch (ehca_rc) { 161 switch (ehca_rc) {
162 case H_SUCCESS: 162 case H_SUCCESS:
163 return 0; 163 return 0;
164 case H_RESOURCE: /* Resource in use */
164 case H_BUSY: 165 case H_BUSY:
165 return -EBUSY; 166 return -EBUSY;
167 case H_NOT_ENOUGH_RESOURCES: /* insufficient resources */
168 case H_CONSTRAINED: /* resource constraint */
166 case H_NO_MEM: 169 case H_NO_MEM:
167 return -ENOMEM; 170 return -ENOMEM;
168 default: 171 default: