On a separate note, I'd like to solicit comments about exposing the following (with slight modifications), in ib_verbs.h, ib_mad.h, and/or ib_mad_helper.h.
- Sean >+struct rmpp_msg { >+ struct ib_mad_agent *mad_agent; >+ struct ib_send_wr send_wr; >+ struct ib_sge sge; >+ DECLARE_PCI_UNMAP_ADDR(mapping) >+ struct ib_rmpp_mad mad; >+}; >+ >+static struct ib_ah * create_ah_from_wc(struct ib_pd *pd, struct ib_wc >*wc, >+ u8 port_num) >+{ >+ struct ib_ah_attr *ah_attr; >+ struct ib_ah *ah; >+ >+ ah_attr = kmalloc(sizeof *ah_attr, GFP_KERNEL); >+ if (!ah_attr) >+ return ERR_PTR(-ENOMEM); >+ >+ memset(ah_attr, 0, sizeof *ah_attr); >+ ah_attr->dlid = wc->slid; >+ ah_attr->sl = wc->sl; >+ ah_attr->src_path_bits = wc->dlid_path_bits; >+ ah_attr->port_num = port_num; >+ >+ ah = ib_create_ah(pd, ah_attr); >+ kfree(ah_attr); >+ return ah; >+} >+ >+static struct rmpp_msg * alloc_rmpp_msg(struct ib_mad_agent *mad_agent, >+ u32 remote_qpn, u16 pkey_index, >+ struct ib_ah *ah) >+{ >+ struct rmpp_msg *msg; >+ >+ msg = kmalloc(sizeof *msg, GFP_KERNEL); >+ if (!msg) >+ return NULL; >+ memset(msg, 0, sizeof *msg); >+ >+ msg->sge.addr = dma_map_single(mad_agent->device->dma_device, >+ &msg->mad, sizeof msg->mad, >+ DMA_TO_DEVICE); >+ pci_unmap_addr_set(msg, mapping, msg->sge.addr); >+ msg->sge.length = sizeof msg->mad; >+ msg->sge.lkey = mad_agent->mr->lkey; >+ >+ msg->send_wr.wr_id = (unsigned long) msg; >+ msg->send_wr.sg_list = &msg->sge; >+ msg->send_wr.num_sge = 1; >+ msg->send_wr.opcode = IB_WR_SEND; >+ msg->send_wr.send_flags = IB_SEND_SIGNALED; >+ msg->send_wr.wr.ud.ah = ah; >+ msg->send_wr.wr.ud.mad_hdr = &msg->mad.mad_hdr; >+ msg->send_wr.wr.ud.remote_qpn = remote_qpn; >+ msg->send_wr.wr.ud.remote_qkey = IB_QP_SET_QKEY; >+ msg->send_wr.wr.ud.pkey_index = pkey_index; >+ >+ msg->mad_agent = mad_agent; >+ return msg; >+} >+ >+static void free_rmpp_msg(struct rmpp_msg *msg) >+{ >+ dma_unmap_single(msg->mad_agent->device->dma_device, >+ pci_unmap_addr(msg, mapping), >+ sizeof msg->mad, DMA_TO_DEVICE); >+ kfree(msg); _______________________________________________ openib-general mailing list openib-general@openib.org http://openib.org/mailman/listinfo/openib-general To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general