hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/infiniband/hw/mthca/mthca_mad.c
....@@ -58,8 +58,9 @@
5858
5959 ret = ib_query_port(&dev->ib_dev, port_num, tprops);
6060 if (ret) {
61
- printk(KERN_WARNING "ib_query_port failed (%d) for %s port %d\n",
62
- ret, dev->ib_dev.name, port_num);
61
+ dev_warn(&dev->ib_dev.dev,
62
+ "ib_query_port failed (%d) forport %d\n", ret,
63
+ port_num);
6364 goto out;
6465 }
6566
....@@ -88,13 +89,13 @@
8889 rdma_ah_set_port_num(&ah_attr, port_num);
8990
9091 new_ah = rdma_create_ah(dev->send_agent[port_num - 1][0]->qp->pd,
91
- &ah_attr);
92
+ &ah_attr, 0);
9293 if (IS_ERR(new_ah))
9394 return;
9495
9596 spin_lock_irqsave(&dev->sm_lock, flags);
9697 if (dev->sm_ah[port_num - 1])
97
- rdma_destroy_ah(dev->sm_ah[port_num - 1]);
98
+ rdma_destroy_ah(dev->sm_ah[port_num - 1], 0);
9899 dev->sm_ah[port_num - 1] = new_ah;
99100 spin_unlock_irqrestore(&dev->sm_lock, flags);
100101 }
....@@ -195,30 +196,19 @@
195196 }
196197 }
197198
198
-int mthca_process_mad(struct ib_device *ibdev,
199
- int mad_flags,
200
- u8 port_num,
201
- const struct ib_wc *in_wc,
202
- const struct ib_grh *in_grh,
203
- const struct ib_mad_hdr *in, size_t in_mad_size,
204
- struct ib_mad_hdr *out, size_t *out_mad_size,
205
- u16 *out_mad_pkey_index)
199
+int mthca_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
200
+ const struct ib_wc *in_wc, const struct ib_grh *in_grh,
201
+ const struct ib_mad *in, struct ib_mad *out,
202
+ size_t *out_mad_size, u16 *out_mad_pkey_index)
206203 {
207204 int err;
208205 u16 slid = in_wc ? ib_lid_cpu16(in_wc->slid) : be16_to_cpu(IB_LID_PERMISSIVE);
209206 u16 prev_lid = 0;
210207 struct ib_port_attr pattr;
211
- const struct ib_mad *in_mad = (const struct ib_mad *)in;
212
- struct ib_mad *out_mad = (struct ib_mad *)out;
213
-
214
- if (WARN_ON_ONCE(in_mad_size != sizeof(*in_mad) ||
215
- *out_mad_size != sizeof(*out_mad)))
216
- return IB_MAD_RESULT_FAILURE;
217208
218209 /* Forward locally generated traps to the SM */
219
- if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP &&
220
- slid == 0) {
221
- forward_trap(to_mdev(ibdev), port_num, in_mad);
210
+ if (in->mad_hdr.method == IB_MGMT_METHOD_TRAP && !slid) {
211
+ forward_trap(to_mdev(ibdev), port_num, in);
222212 return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
223213 }
224214
....@@ -228,40 +218,39 @@
228218 * Only handle PMA and Mellanox vendor-specific class gets and
229219 * sets for other classes.
230220 */
231
- if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
232
- in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {
233
- if (in_mad->mad_hdr.method != IB_MGMT_METHOD_GET &&
234
- in_mad->mad_hdr.method != IB_MGMT_METHOD_SET &&
235
- in_mad->mad_hdr.method != IB_MGMT_METHOD_TRAP_REPRESS)
221
+ if (in->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
222
+ in->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {
223
+ if (in->mad_hdr.method != IB_MGMT_METHOD_GET &&
224
+ in->mad_hdr.method != IB_MGMT_METHOD_SET &&
225
+ in->mad_hdr.method != IB_MGMT_METHOD_TRAP_REPRESS)
236226 return IB_MAD_RESULT_SUCCESS;
237227
238228 /*
239229 * Don't process SMInfo queries or vendor-specific
240230 * MADs -- the SMA can't handle them.
241231 */
242
- if (in_mad->mad_hdr.attr_id == IB_SMP_ATTR_SM_INFO ||
243
- ((in_mad->mad_hdr.attr_id & IB_SMP_ATTR_VENDOR_MASK) ==
232
+ if (in->mad_hdr.attr_id == IB_SMP_ATTR_SM_INFO ||
233
+ ((in->mad_hdr.attr_id & IB_SMP_ATTR_VENDOR_MASK) ==
244234 IB_SMP_ATTR_VENDOR_MASK))
245235 return IB_MAD_RESULT_SUCCESS;
246
- } else if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT ||
247
- in_mad->mad_hdr.mgmt_class == MTHCA_VENDOR_CLASS1 ||
248
- in_mad->mad_hdr.mgmt_class == MTHCA_VENDOR_CLASS2) {
249
- if (in_mad->mad_hdr.method != IB_MGMT_METHOD_GET &&
250
- in_mad->mad_hdr.method != IB_MGMT_METHOD_SET)
236
+ } else if (in->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT ||
237
+ in->mad_hdr.mgmt_class == MTHCA_VENDOR_CLASS1 ||
238
+ in->mad_hdr.mgmt_class == MTHCA_VENDOR_CLASS2) {
239
+ if (in->mad_hdr.method != IB_MGMT_METHOD_GET &&
240
+ in->mad_hdr.method != IB_MGMT_METHOD_SET)
251241 return IB_MAD_RESULT_SUCCESS;
252242 } else
253243 return IB_MAD_RESULT_SUCCESS;
254
- if ((in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
255
- in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) &&
256
- in_mad->mad_hdr.method == IB_MGMT_METHOD_SET &&
257
- in_mad->mad_hdr.attr_id == IB_SMP_ATTR_PORT_INFO &&
244
+ if ((in->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
245
+ in->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) &&
246
+ in->mad_hdr.method == IB_MGMT_METHOD_SET &&
247
+ in->mad_hdr.attr_id == IB_SMP_ATTR_PORT_INFO &&
258248 !ib_query_port(ibdev, port_num, &pattr))
259249 prev_lid = ib_lid_cpu16(pattr.lid);
260250
261
- err = mthca_MAD_IFC(to_mdev(ibdev),
262
- mad_flags & IB_MAD_IGNORE_MKEY,
263
- mad_flags & IB_MAD_IGNORE_BKEY,
264
- port_num, in_wc, in_grh, in_mad, out_mad);
251
+ err = mthca_MAD_IFC(to_mdev(ibdev), mad_flags & IB_MAD_IGNORE_MKEY,
252
+ mad_flags & IB_MAD_IGNORE_BKEY, port_num, in_wc,
253
+ in_grh, in, out);
265254 if (err == -EBADMSG)
266255 return IB_MAD_RESULT_SUCCESS;
267256 else if (err) {
....@@ -269,16 +258,16 @@
269258 return IB_MAD_RESULT_FAILURE;
270259 }
271260
272
- if (!out_mad->mad_hdr.status) {
273
- smp_snoop(ibdev, port_num, in_mad, prev_lid);
274
- node_desc_override(ibdev, out_mad);
261
+ if (!out->mad_hdr.status) {
262
+ smp_snoop(ibdev, port_num, in, prev_lid);
263
+ node_desc_override(ibdev, out);
275264 }
276265
277266 /* set return bit in status of directed route responses */
278
- if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
279
- out_mad->mad_hdr.status |= cpu_to_be16(1 << 15);
267
+ if (in->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
268
+ out->mad_hdr.status |= cpu_to_be16(1 << 15);
280269
281
- if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP_REPRESS)
270
+ if (in->mad_hdr.method == IB_MGMT_METHOD_TRAP_REPRESS)
282271 /* no response for trap repress */
283272 return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
284273
....@@ -346,6 +335,7 @@
346335 }
347336
348337 if (dev->sm_ah[p])
349
- rdma_destroy_ah(dev->sm_ah[p]);
338
+ rdma_destroy_ah(dev->sm_ah[p],
339
+ RDMA_DESTROY_AH_SLEEPABLE);
350340 }
351341 }