Ejemplo n.º 1
0
func (qp *queuePair) PostSendImm(imm uint32, mr *MemoryRegion) error {
	if qp.qp == nil {
		return errQPAlreadyClosed
	}

	var sendWr C.struct_ibv_send_wr
	var bad *C.struct_ibv_send_wr
	if imm > 0 {
		sendWr.opcode = C.IBV_WR_SEND_WITH_IMM
		// always send inline if there is immediate data
		sendWr.send_flags = C.IBV_SEND_INLINE
		sendWr.imm_data = C.uint32_t(imm)
	} else {
		sendWr.opcode = C.IBV_WR_SEND
		sendWr.send_flags = C.IBV_SEND_SIGNALED
	}

	if mr != nil {
		var sge C.struct_ibv_sge
		sendWr.sg_list = &sge
		sendWr.num_sge = 1
		mr.populateSge(qp.iface.pd, &sge)
	} else {
		// send inline if there is no memory region to send
		sendWr.send_flags = C.IBV_SEND_INLINE
	}

	sendWr.wr_id = C.uint64_t(uintptr(unsafe.Pointer(&sendWr)))
	qp.workRequests[sendWr.wr_id] = workRequest{mr, &sendWr, nil, false}

	errno := C.ibv_post_send(qp.qp, &sendWr, &bad)
	return newError("ibv_post_send", errno)
}
Ejemplo n.º 2
0
// Zero-length RDMA write.
func (qp *queuePair) PostKeepalive() error {
	if qp.qp == nil {
		return errQPAlreadyClosed
	}

	var sendWr C.struct_ibv_send_wr
	var bad *C.struct_ibv_send_wr
	sendWr.opcode = C.IBV_WR_RDMA_WRITE
	sendWr.send_flags = C.IBV_SEND_SIGNALED

	sendWr.wr_id = C.uint64_t(uintptr(unsafe.Pointer(&sendWr)))
	qp.workRequests[sendWr.wr_id] = workRequest{nil, &sendWr, nil, true}

	errno := C.ibv_post_send(qp.qp, &sendWr, &bad)
	return newError("ibv_post_send", errno)
}
Ejemplo n.º 3
0
func (qp *queuePair) PostWrite(mr *MemoryRegion, remoteAddr uint64, rkey uint32) error {
	if qp.qp == nil {
		return errQPAlreadyClosed
	}

	var sendWr C.struct_ibv_send_wr
	var sge C.struct_ibv_sge
	var bad *C.struct_ibv_send_wr
	sendWr.opcode = C.IBV_WR_RDMA_WRITE
	sendWr.send_flags = C.IBV_SEND_SIGNALED
	sendWr.sg_list = &sge
	sendWr.num_sge = 1
	mr.populateSge(qp.iface.pd, &sge)
	r := (*rdma)(unsafe.Pointer(&sendWr.wr))
	r.remoteAddr = remoteAddr
	r.rkey = rkey

	sendWr.wr_id = C.uint64_t(uintptr(unsafe.Pointer(&sendWr)))
	qp.workRequests[sendWr.wr_id] = workRequest{mr, &sendWr, nil, false}

	errno := C.ibv_post_send(qp.qp, &sendWr, &bad)
	return newError("ibv_post_send", errno)
}