diff options
author | Stefan Roscher <ossrosch@linux.vnet.ibm.com> | 2008-04-17 00:09:35 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2008-04-17 00:09:35 -0400 |
commit | c83b5b1cb2b050c7a9054f330598df99c31abb98 (patch) | |
tree | 4d6790054a25d4e98d4f772a2b93f4d13262ec6c /drivers | |
parent | 4cd1e5eb3cbe6e0cc934959770b4c60eac6ecf66 (diff) |
IB/ehca: Support all ibv_devinfo values in query_device() and query_port()
Also, introduce a few inline helper functions to make the code more readable.
Signed-off-by: Stefan Roscher <stefan.roscher@de.ibm.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/infiniband/hw/ehca/ehca_hca.c | 127 |
1 files changed, 79 insertions, 48 deletions
diff --git a/drivers/infiniband/hw/ehca/ehca_hca.c b/drivers/infiniband/hw/ehca/ehca_hca.c index 8832123d1d0f..2515cbde7e65 100644 --- a/drivers/infiniband/hw/ehca/ehca_hca.c +++ b/drivers/infiniband/hw/ehca/ehca_hca.c | |||
@@ -43,6 +43,11 @@ | |||
43 | #include "ehca_iverbs.h" | 43 | #include "ehca_iverbs.h" |
44 | #include "hcp_if.h" | 44 | #include "hcp_if.h" |
45 | 45 | ||
46 | static unsigned int limit_uint(unsigned int value) | ||
47 | { | ||
48 | return min_t(unsigned int, value, INT_MAX); | ||
49 | } | ||
50 | |||
46 | int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props) | 51 | int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props) |
47 | { | 52 | { |
48 | int i, ret = 0; | 53 | int i, ret = 0; |
@@ -83,37 +88,40 @@ int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props) | |||
83 | props->vendor_id = rblock->vendor_id >> 8; | 88 | props->vendor_id = rblock->vendor_id >> 8; |
84 | props->vendor_part_id = rblock->vendor_part_id >> 16; | 89 | props->vendor_part_id = rblock->vendor_part_id >> 16; |
85 | props->hw_ver = rblock->hw_ver; | 90 | props->hw_ver = rblock->hw_ver; |
86 | props->max_qp = min_t(unsigned, rblock->max_qp, INT_MAX); | 91 | props->max_qp = limit_uint(rblock->max_qp); |
87 | props->max_qp_wr = min_t(unsigned, rblock->max_wqes_wq, INT_MAX); | 92 | props->max_qp_wr = limit_uint(rblock->max_wqes_wq); |
88 | props->max_sge = min_t(unsigned, rblock->max_sge, INT_MAX); | 93 | props->max_sge = limit_uint(rblock->max_sge); |
89 | props->max_sge_rd = min_t(unsigned, rblock->max_sge_rd, INT_MAX); | 94 | props->max_sge_rd = limit_uint(rblock->max_sge_rd); |
90 | props->max_cq = min_t(unsigned, rblock->max_cq, INT_MAX); | 95 | props->max_cq = limit_uint(rblock->max_cq); |
91 | props->max_cqe = min_t(unsigned, rblock->max_cqe, INT_MAX); | 96 | props->max_cqe = limit_uint(rblock->max_cqe); |
92 | props->max_mr = min_t(unsigned, rblock->max_mr, INT_MAX); | 97 | props->max_mr = limit_uint(rblock->max_mr); |
93 | props->max_mw = min_t(unsigned, rblock->max_mw, INT_MAX); | 98 | props->max_mw = limit_uint(rblock->max_mw); |
94 | props->max_pd = min_t(unsigned, rblock->max_pd, INT_MAX); | 99 | props->max_pd = limit_uint(rblock->max_pd); |
95 | props->max_ah = min_t(unsigned, rblock->max_ah, INT_MAX); | 100 | props->max_ah = limit_uint(rblock->max_ah); |
96 | props->max_fmr = min_t(unsigned, rblock->max_mr, INT_MAX); | 101 | props->max_ee = limit_uint(rblock->max_rd_ee_context); |
102 | props->max_rdd = limit_uint(rblock->max_rd_domain); | ||
103 | props->max_fmr = limit_uint(rblock->max_mr); | ||
104 | props->local_ca_ack_delay = limit_uint(rblock->local_ca_ack_delay); | ||
105 | props->max_qp_rd_atom = limit_uint(rblock->max_rr_qp); | ||
106 | props->max_ee_rd_atom = limit_uint(rblock->max_rr_ee_context); | ||
107 | props->max_res_rd_atom = limit_uint(rblock->max_rr_hca); | ||
108 | props->max_qp_init_rd_atom = limit_uint(rblock->max_act_wqs_qp); | ||
109 | props->max_ee_init_rd_atom = limit_uint(rblock->max_act_wqs_ee_context); | ||
97 | 110 | ||
98 | if (EHCA_BMASK_GET(HCA_CAP_SRQ, shca->hca_cap)) { | 111 | if (EHCA_BMASK_GET(HCA_CAP_SRQ, shca->hca_cap)) { |
99 | props->max_srq = props->max_qp; | 112 | props->max_srq = limit_uint(props->max_qp); |
100 | props->max_srq_wr = props->max_qp_wr; | 113 | props->max_srq_wr = limit_uint(props->max_qp_wr); |
101 | props->max_srq_sge = 3; | 114 | props->max_srq_sge = 3; |
102 | } | 115 | } |
103 | 116 | ||
104 | props->max_pkeys = 16; | 117 | props->max_pkeys = 16; |
105 | props->local_ca_ack_delay | 118 | props->local_ca_ack_delay = limit_uint(rblock->local_ca_ack_delay); |
106 | = rblock->local_ca_ack_delay; | 119 | props->max_raw_ipv6_qp = limit_uint(rblock->max_raw_ipv6_qp); |
107 | props->max_raw_ipv6_qp | 120 | props->max_raw_ethy_qp = limit_uint(rblock->max_raw_ethy_qp); |
108 | = min_t(unsigned, rblock->max_raw_ipv6_qp, INT_MAX); | 121 | props->max_mcast_grp = limit_uint(rblock->max_mcast_grp); |
109 | props->max_raw_ethy_qp | 122 | props->max_mcast_qp_attach = limit_uint(rblock->max_mcast_qp_attach); |
110 | = min_t(unsigned, rblock->max_raw_ethy_qp, INT_MAX); | ||
111 | props->max_mcast_grp | ||
112 | = min_t(unsigned, rblock->max_mcast_grp, INT_MAX); | ||
113 | props->max_mcast_qp_attach | ||
114 | = min_t(unsigned, rblock->max_mcast_qp_attach, INT_MAX); | ||
115 | props->max_total_mcast_qp_attach | 123 | props->max_total_mcast_qp_attach |
116 | = min_t(unsigned, rblock->max_total_mcast_qp_attach, INT_MAX); | 124 | = limit_uint(rblock->max_total_mcast_qp_attach); |
117 | 125 | ||
118 | /* translate device capabilities */ | 126 | /* translate device capabilities */ |
119 | props->device_cap_flags = IB_DEVICE_SYS_IMAGE_GUID | | 127 | props->device_cap_flags = IB_DEVICE_SYS_IMAGE_GUID | |
@@ -128,6 +136,46 @@ query_device1: | |||
128 | return ret; | 136 | return ret; |
129 | } | 137 | } |
130 | 138 | ||
139 | static int map_mtu(struct ehca_shca *shca, u32 fw_mtu) | ||
140 | { | ||
141 | switch (fw_mtu) { | ||
142 | case 0x1: | ||
143 | return IB_MTU_256; | ||
144 | case 0x2: | ||
145 | return IB_MTU_512; | ||
146 | case 0x3: | ||
147 | return IB_MTU_1024; | ||
148 | case 0x4: | ||
149 | return IB_MTU_2048; | ||
150 | case 0x5: | ||
151 | return IB_MTU_4096; | ||
152 | default: | ||
153 | ehca_err(&shca->ib_device, "Unknown MTU size: %x.", | ||
154 | fw_mtu); | ||
155 | return 0; | ||
156 | } | ||
157 | } | ||
158 | |||
159 | static int map_number_of_vls(struct ehca_shca *shca, u32 vl_cap) | ||
160 | { | ||
161 | switch (vl_cap) { | ||
162 | case 0x1: | ||
163 | return 1; | ||
164 | case 0x2: | ||
165 | return 2; | ||
166 | case 0x3: | ||
167 | return 4; | ||
168 | case 0x4: | ||
169 | return 8; | ||
170 | case 0x5: | ||
171 | return 15; | ||
172 | default: | ||
173 | ehca_err(&shca->ib_device, "invalid Vl Capability: %x.", | ||
174 | vl_cap); | ||
175 | return 0; | ||
176 | } | ||
177 | } | ||
178 | |||
131 | int ehca_query_port(struct ib_device *ibdev, | 179 | int ehca_query_port(struct ib_device *ibdev, |
132 | u8 port, struct ib_port_attr *props) | 180 | u8 port, struct ib_port_attr *props) |
133 | { | 181 | { |
@@ -152,31 +200,13 @@ int ehca_query_port(struct ib_device *ibdev, | |||
152 | 200 | ||
153 | memset(props, 0, sizeof(struct ib_port_attr)); | 201 | memset(props, 0, sizeof(struct ib_port_attr)); |
154 | 202 | ||
155 | switch (rblock->max_mtu) { | 203 | props->active_mtu = props->max_mtu = map_mtu(shca, rblock->max_mtu); |
156 | case 0x1: | ||
157 | props->active_mtu = props->max_mtu = IB_MTU_256; | ||
158 | break; | ||
159 | case 0x2: | ||
160 | props->active_mtu = props->max_mtu = IB_MTU_512; | ||
161 | break; | ||
162 | case 0x3: | ||
163 | props->active_mtu = props->max_mtu = IB_MTU_1024; | ||
164 | break; | ||
165 | case 0x4: | ||
166 | props->active_mtu = props->max_mtu = IB_MTU_2048; | ||
167 | break; | ||
168 | case 0x5: | ||
169 | props->active_mtu = props->max_mtu = IB_MTU_4096; | ||
170 | break; | ||
171 | default: | ||
172 | ehca_err(&shca->ib_device, "Unknown MTU size: %x.", | ||
173 | rblock->max_mtu); | ||
174 | break; | ||
175 | } | ||
176 | |||
177 | props->port_cap_flags = rblock->capability_mask; | 204 | props->port_cap_flags = rblock->capability_mask; |
178 | props->gid_tbl_len = rblock->gid_tbl_len; | 205 | props->gid_tbl_len = rblock->gid_tbl_len; |
179 | props->max_msg_sz = rblock->max_msg_sz; | 206 | if (rblock->max_msg_sz) |
207 | props->max_msg_sz = rblock->max_msg_sz; | ||
208 | else | ||
209 | props->max_msg_sz = 0x1 << 31; | ||
180 | props->bad_pkey_cntr = rblock->bad_pkey_cntr; | 210 | props->bad_pkey_cntr = rblock->bad_pkey_cntr; |
181 | props->qkey_viol_cntr = rblock->qkey_viol_cntr; | 211 | props->qkey_viol_cntr = rblock->qkey_viol_cntr; |
182 | props->pkey_tbl_len = rblock->pkey_tbl_len; | 212 | props->pkey_tbl_len = rblock->pkey_tbl_len; |
@@ -186,6 +216,7 @@ int ehca_query_port(struct ib_device *ibdev, | |||
186 | props->sm_sl = rblock->sm_sl; | 216 | props->sm_sl = rblock->sm_sl; |
187 | props->subnet_timeout = rblock->subnet_timeout; | 217 | props->subnet_timeout = rblock->subnet_timeout; |
188 | props->init_type_reply = rblock->init_type_reply; | 218 | props->init_type_reply = rblock->init_type_reply; |
219 | props->max_vl_num = map_number_of_vls(shca, rblock->vl_cap); | ||
189 | 220 | ||
190 | if (rblock->state && rblock->phys_width) { | 221 | if (rblock->state && rblock->phys_width) { |
191 | props->phys_state = rblock->phys_pstate; | 222 | props->phys_state = rblock->phys_pstate; |