Lines Matching refs:packet
180 struct ib_umad_packet *packet) in queue_packet() argument
186 for (packet->mad.hdr.id = 0; in queue_packet()
187 packet->mad.hdr.id < IB_UMAD_MAX_AGENTS; in queue_packet()
188 packet->mad.hdr.id++) in queue_packet()
189 if (agent == __get_agent(file, packet->mad.hdr.id)) { in queue_packet()
190 list_add_tail(&packet->list, &file->recv_list); in queue_packet()
202 struct ib_umad_packet *packet) in dequeue_send() argument
205 list_del(&packet->list); in dequeue_send()
213 struct ib_umad_packet *packet = send_wc->send_buf->context[0]; in send_handler() local
215 dequeue_send(file, packet); in send_handler()
216 rdma_destroy_ah(packet->msg->ah, RDMA_DESTROY_AH_SLEEPABLE); in send_handler()
217 ib_free_send_mad(packet->msg); in send_handler()
220 packet->length = IB_MGMT_MAD_HDR; in send_handler()
221 packet->mad.hdr.status = ETIMEDOUT; in send_handler()
222 if (!queue_packet(file, agent, packet)) in send_handler()
225 kfree(packet); in send_handler()
233 struct ib_umad_packet *packet; in recv_handler() local
238 packet = kzalloc(sizeof *packet, GFP_KERNEL); in recv_handler()
239 if (!packet) in recv_handler()
242 packet->length = mad_recv_wc->mad_len; in recv_handler()
243 packet->recv_wc = mad_recv_wc; in recv_handler()
245 packet->mad.hdr.status = 0; in recv_handler()
246 packet->mad.hdr.length = hdr_size(file) + mad_recv_wc->mad_len; in recv_handler()
247 packet->mad.hdr.qpn = cpu_to_be32(mad_recv_wc->wc->src_qp); in recv_handler()
253 packet->mad.hdr.lid = ib_lid_be16(0xFFFF & in recv_handler()
256 packet->mad.hdr.lid = ib_lid_be16(mad_recv_wc->wc->slid); in recv_handler()
257 packet->mad.hdr.sl = mad_recv_wc->wc->sl; in recv_handler()
258 packet->mad.hdr.path_bits = mad_recv_wc->wc->dlid_path_bits; in recv_handler()
259 packet->mad.hdr.pkey_index = mad_recv_wc->wc->pkey_index; in recv_handler()
260 packet->mad.hdr.grh_present = !!(mad_recv_wc->wc->wc_flags & IB_WC_GRH); in recv_handler()
261 if (packet->mad.hdr.grh_present) { in recv_handler()
274 packet->mad.hdr.gid_index = grh->sgid_index; in recv_handler()
275 packet->mad.hdr.hop_limit = grh->hop_limit; in recv_handler()
276 packet->mad.hdr.traffic_class = grh->traffic_class; in recv_handler()
277 memcpy(packet->mad.hdr.gid, &grh->dgid, 16); in recv_handler()
278 packet->mad.hdr.flow_label = cpu_to_be32(grh->flow_label); in recv_handler()
282 if (queue_packet(file, agent, packet)) in recv_handler()
287 kfree(packet); in recv_handler()
293 struct ib_umad_packet *packet, size_t count) in copy_recv_mad() argument
299 recv_buf = &packet->recv_wc->recv_buf; in copy_recv_mad()
300 seg_size = packet->recv_wc->mad_seg_size; in copy_recv_mad()
303 if ((packet->length <= seg_size && in copy_recv_mad()
304 count < hdr_size(file) + packet->length) || in copy_recv_mad()
305 (packet->length > seg_size && in copy_recv_mad()
309 if (copy_to_user(buf, &packet->mad, hdr_size(file))) in copy_recv_mad()
313 seg_payload = min_t(int, packet->length, seg_size); in copy_recv_mad()
317 if (seg_payload < packet->length) { in copy_recv_mad()
322 if (count < hdr_size(file) + packet->length) { in copy_recv_mad()
332 for (left = packet->length - seg_payload, buf += seg_payload; in copy_recv_mad()
343 trace_ib_umad_read_recv(file, &packet->mad.hdr, &recv_buf->mad->mad_hdr); in copy_recv_mad()
345 return hdr_size(file) + packet->length; in copy_recv_mad()
349 struct ib_umad_packet *packet, size_t count) in copy_send_mad() argument
351 ssize_t size = hdr_size(file) + packet->length; in copy_send_mad()
356 if (copy_to_user(buf, &packet->mad, hdr_size(file))) in copy_send_mad()
361 if (copy_to_user(buf, packet->mad.data, packet->length)) in copy_send_mad()
364 trace_ib_umad_read_send(file, &packet->mad.hdr, in copy_send_mad()
365 (struct ib_mad_hdr *)&packet->mad.data); in copy_send_mad()
374 struct ib_umad_packet *packet; in ib_umad_read() local
405 packet = list_entry(file->recv_list.next, struct ib_umad_packet, list); in ib_umad_read()
406 list_del(&packet->list); in ib_umad_read()
410 if (packet->recv_wc) in ib_umad_read()
411 ret = copy_recv_mad(file, buf, packet, count); in ib_umad_read()
413 ret = copy_send_mad(file, buf, packet, count); in ib_umad_read()
418 list_add(&packet->list, &file->recv_list); in ib_umad_read()
421 if (packet->recv_wc) in ib_umad_read()
422 ib_free_recv_mad(packet->recv_wc); in ib_umad_read()
423 kfree(packet); in ib_umad_read()
461 struct ib_umad_packet *packet) in is_duplicate() argument
466 hdr = (struct ib_mad_hdr *) packet->mad.data; in is_duplicate()
486 if (same_destination(&packet->mad.hdr, &sent_packet->mad.hdr)) in is_duplicate()
497 struct ib_umad_packet *packet; in ib_umad_write() local
509 packet = kzalloc(sizeof *packet + IB_MGMT_RMPP_HDR, GFP_KERNEL); in ib_umad_write()
510 if (!packet) in ib_umad_write()
513 if (copy_from_user(&packet->mad, buf, hdr_size(file))) { in ib_umad_write()
518 if (packet->mad.hdr.id >= IB_UMAD_MAX_AGENTS) { in ib_umad_write()
525 if (copy_from_user(packet->mad.data, buf, IB_MGMT_RMPP_HDR)) { in ib_umad_write()
532 trace_ib_umad_write(file, &packet->mad.hdr, in ib_umad_write()
533 (struct ib_mad_hdr *)&packet->mad.data); in ib_umad_write()
535 agent = __get_agent(file, packet->mad.hdr.id); in ib_umad_write()
544 rdma_ah_set_dlid(&ah_attr, be16_to_cpu(packet->mad.hdr.lid)); in ib_umad_write()
545 rdma_ah_set_sl(&ah_attr, packet->mad.hdr.sl); in ib_umad_write()
546 rdma_ah_set_path_bits(&ah_attr, packet->mad.hdr.path_bits); in ib_umad_write()
548 if (packet->mad.hdr.grh_present) { in ib_umad_write()
550 be32_to_cpu(packet->mad.hdr.flow_label), in ib_umad_write()
551 packet->mad.hdr.gid_index, in ib_umad_write()
552 packet->mad.hdr.hop_limit, in ib_umad_write()
553 packet->mad.hdr.traffic_class); in ib_umad_write()
554 rdma_ah_set_dgid_raw(&ah_attr, packet->mad.hdr.gid); in ib_umad_write()
563 rmpp_mad = (struct ib_rmpp_mad *) packet->mad.data; in ib_umad_write()
576 base_version = ((struct ib_mad_hdr *)&packet->mad.data)->base_version; in ib_umad_write()
578 packet->msg = ib_create_send_mad(agent, in ib_umad_write()
579 be32_to_cpu(packet->mad.hdr.qpn), in ib_umad_write()
580 packet->mad.hdr.pkey_index, rmpp_active, in ib_umad_write()
583 if (IS_ERR(packet->msg)) { in ib_umad_write()
584 ret = PTR_ERR(packet->msg); in ib_umad_write()
588 packet->msg->ah = ah; in ib_umad_write()
589 packet->msg->timeout_ms = packet->mad.hdr.timeout_ms; in ib_umad_write()
590 packet->msg->retries = packet->mad.hdr.retries; in ib_umad_write()
591 packet->msg->context[0] = packet; in ib_umad_write()
594 memcpy(packet->msg->mad, packet->mad.data, IB_MGMT_MAD_HDR); in ib_umad_write()
597 if (copy_from_user(packet->msg->mad + copy_offset, in ib_umad_write()
604 ret = copy_rmpp_mad(packet->msg, buf); in ib_umad_write()
614 if (!ib_response_mad(packet->msg->mad)) { in ib_umad_write()
615 tid = &((struct ib_mad_hdr *) packet->msg->mad)->tid; in ib_umad_write()
625 list_add_tail(&packet->list, &file->send_list); in ib_umad_write()
629 ret = is_duplicate(file, packet); in ib_umad_write()
631 list_add_tail(&packet->list, &file->send_list); in ib_umad_write()
639 ret = ib_post_send_mad(packet->msg, NULL); in ib_umad_write()
647 dequeue_send(file, packet); in ib_umad_write()
649 ib_free_send_mad(packet->msg); in ib_umad_write()
655 kfree(packet); in ib_umad_write()
1029 struct ib_umad_packet *packet, *tmp; in ib_umad_close() local
1039 list_for_each_entry_safe(packet, tmp, &file->recv_list, list) { in ib_umad_close()
1040 if (packet->recv_wc) in ib_umad_close()
1041 ib_free_recv_mad(packet->recv_wc); in ib_umad_close()
1042 kfree(packet); in ib_umad_close()