Beispiel #1
0
func (iface *Interface) createCompletionQueue(cqe int) *C.struct_ibv_cq {
	compChannel := C.ibv_create_comp_channel(iface.ctx)
	if compChannel == nil {
		panic("ibv_create_comp_channel: failure")
	}
	if err := syscall.SetNonblock(int(compChannel.fd), true); err != nil {
		panic(err)
	}
	cq := C.ibv_create_cq(iface.ctx, C.int(cqe), nil, compChannel, 0)
	if cq != nil {
		return cq
	}
	errno := C.ibv_destroy_comp_channel(compChannel)
	if errno != 0 {
		panic(newError("ibv_destroy_comp_channel", errno))
	}
	return nil
}
Beispiel #2
0
func destroyCompletionQueue(cq *C.struct_ibv_cq) error {
	if cq == nil {
		return nil
	}
	channel := cq.channel
	// CQ must be destroyed before completion channel
	errno := C.ibv_destroy_cq(cq)
	if errno != 0 {
		return newError("ibv_destroy_cq", errno)
	}
	if channel != nil {
		errno := C.ibv_destroy_comp_channel(channel)
		if errno != 0 {
			return newError("ibv_destroy_comp_channel", errno)
		}
	}
	return nil
}