[ofw] [RFC] winverbs implementation approach

Sean Hefty sean.hefty at intel.com
Wed Mar 12 16:56:06 PDT 2008


If you ignore the poorly spaced tabs from outlook, the following is the first
attempt at implementing the WinVerbs IWVCompletionQueue::Create() routine.

A goal is to limit changes to the existing userspace or kernel stacks,
especially changes that may impact existing stack stability.  The winverbs
library communicates directly with the userspace verbs provider library.
It issues buffered IOCTLs directly to a kernel winverbs filter driver that
communicates directly with the kernel HCA driver for verb related functionality.
(I.e. CQ, QP, MR, MW, PD, SRQ, etc. type operations.)

The intent is that that winverbs kernel driver will implement the asynchronous
operations until the HCA driver is optimized for this at some undetermined
future point in time.

What's not shown is that default pre/post calls are provided if the provider
does not define one.  This simplifies the code.  The ci_umv_buf_t structure is
not passed directly to the kernel winverb driver.  The provider data
is copied to the end of the IOCTL data itelf.  The winverb driver
reconstructs the ci_umv_buf_t before calling the HCA driver.  

- Sean
---

STDMETHODIMP CWVCompletionQueue::
Create(SIZE_T *pEntries)
{
	WV_IO_CQ_ATTRIBUTES	*pattr;
	DWORD				bytes;
	ib_api_status_t		stat;
	HRESULT			hr;
	ci_umv_buf_t		verbsdata;

	stat = m_pVerbs->pre_create_cq(m_pDevice->m_hVerbsDevice, (UINT32 *) pEntries,
					   &verbsdata, &m_hVerbsCq);
	if (stat)
		return WvConvertIbStatus(stat);

	bytes = sizeof WV_IO_CQ_ATTRIBUTES + max(verbsdata.input_size,
								verbsdata.output_size);
	pattr = (WV_IO_CQ_ATTRIBUTES *) HeapAlloc(GetProcessHeap(), 0, bytes);
	if (!pattr)
		return WV_NO_MEMORY;

	pattr->Id.Id = m_pDevice->m_Id;
	pattr->Id.VerbInfo = verbsdata.command;
	pattr->Id.Reserved = 0;
	pattr->Entries = *pEntries;
	RtlCopyMemory(pattr + 1, verbsdata.p_inout_buf, verbsdata.input_size);

	if (DeviceIoControl(m_hFile, WV_IOCTL_CQ_CREATE,
				pattr, sizeof WV_IO_CQ_ATTRIBUTES + verbsdata.input_size,
				pattr, sizeof WV_IO_CQ_ATTRIBUTES + verbsdata.output_size,
				&bytes, NULL)) {
		hr = WV_SUCCESS;
		m_Id = pattr->Id.Id;
		*pEntries = pattr->Entries;
	} else
		hr = HRESULT_FROM_WIN32(GetLastError());

	verbsdata.status = pattr->Id.VerbInfo;
	RtlCopyMemory(verbsdata.p_inout_buf, pattr + 1, verbsdata.output_size);
	HeapFree(GetProcessHeap(), 0, pattr);

	m_pVerbs->post_create_cq(m_pDevice->m_hVerbsDevice, (ib_api_status_t) hr,
					 (UINT32) *pEntries, &m_hVerbsCq, &verbsdata);
	return hr;
}




More information about the ofw mailing list