return hr;\r
}\r
\r
+STDMETHODIMP CWVDevice::\r
+FindGidIndex(UINT8 PortNumber, WV_GID *pGid, UINT8 *pIndex)\r
+{\r
+ WV_GID gid;\r
+ DWORD index;\r
+ HRESULT hr;\r
+\r
+ for (index = 0; true; index++) {\r
+ hr = QueryGid(PortNumber, index, &gid);\r
+ if (FAILED(hr)) {\r
+ break;\r
+ }\r
+\r
+ if (RtlCompareMemory(pGid, &gid, sizeof(gid)) == sizeof(gid)) {\r
+ *pIndex = (UINT8) index;\r
+ break;\r
+ }\r
+ }\r
+\r
+ return hr;\r
+}\r
+\r
// TODO: cache PKey table and update with QueryPort()\r
STDMETHODIMP CWVDevice::\r
QueryPkey(UINT8 PortNumber, DWORD Index, NET16* pPkey)\r
// Address Handle routines\r
//------------------------\r
\r
-void WvVerbsConvertAv(ib_av_attr_t *pVerbsAv, WV_ADDRESS_VECTOR *pAv)\r
-{\r
- pVerbsAv->grh_valid = pAv->Route.Valid;\r
- if (pVerbsAv->grh_valid) {\r
- pVerbsAv->grh.ver_class_flow =\r
- _byteswap_ulong(_byteswap_ulong(pAv->Route.FlowLabel) |\r
- (pAv->Route.TrafficClass << 20));\r
- pVerbsAv->grh.hop_limit = pAv->Route.HopLimit;\r
- RtlCopyMemory(&pVerbsAv->grh.src_gid, &pAv->Route.SGid, sizeof(pAv->Route.SGid));\r
- RtlCopyMemory(&pVerbsAv->grh.dest_gid, &pAv->Route.DGid, sizeof(pAv->Route.DGid));\r
- }\r
-\r
- pVerbsAv->port_num = pAv->PortNumber;\r
- pVerbsAv->sl = pAv->ServiceLevel;\r
- pVerbsAv->dlid = pAv->DLid;\r
- pVerbsAv->static_rate = pAv->StaticRate;\r
- pVerbsAv->path_bits = pAv->SourcePathBits;\r
-}\r
-\r
CWVAddressHandle::CWVAddressHandle(CWVProtectionDomain *pPd)\r
{\r
pPd->AddRef();\r
ib_av_attr_t av;\r
CWVBuffer buf;\r
\r
- WvVerbsConvertAv(&av, pAddress);\r
+ hr = ConvertAv(&av, pAddress);\r
+ if (FAILED(hr)) {\r
+ return hr;\r
+ }\r
+\r
stat = m_pVerbs->pre_create_av(m_pPd->m_hVerbsPd, &av, &verbsData, &m_hVerbsAh);\r
if (stat != IB_SUCCESS) {\r
if (stat == IB_VERBS_PROCESSING_DONE) {\r
{\r
return CWVBase::Release();\r
}\r
+\r
+STDMETHODIMP CWVAddressHandle::\r
+ConvertAv(ib_av_attr_t *pVerbsAv, WV_ADDRESS_VECTOR *pAv)\r
+{\r
+ HRESULT hr;\r
+\r
+ pVerbsAv->grh_valid = pAv->Route.Valid;\r
+ if (pVerbsAv->grh_valid) {\r
+ hr = m_pPd->m_pDevice->FindGidIndex(pAv->PortNumber, &pAv->Route.SGid,\r
+ &pVerbsAv->grh.resv2);\r
+ if (FAILED(hr)) {\r
+ return hr;\r
+ }\r
+\r
+ pVerbsAv->grh.ver_class_flow =\r
+ _byteswap_ulong(_byteswap_ulong(pAv->Route.FlowLabel) |\r
+ (pAv->Route.TrafficClass << 20));\r
+ pVerbsAv->grh.hop_limit = pAv->Route.HopLimit;\r
+ RtlCopyMemory(&pVerbsAv->grh.src_gid, &pAv->Route.SGid, sizeof(pAv->Route.SGid));\r
+ RtlCopyMemory(&pVerbsAv->grh.dest_gid, &pAv->Route.DGid, sizeof(pAv->Route.DGid));\r
+ }\r
+\r
+ pVerbsAv->port_num = pAv->PortNumber;\r
+ pVerbsAv->sl = pAv->ServiceLevel;\r
+ pVerbsAv->dlid = pAv->DLid;\r
+ pVerbsAv->static_rate = pAv->StaticRate;\r
+ pVerbsAv->path_bits = pAv->SourcePathBits;\r
+\r
+ return WV_SUCCESS;\r
+}
\ No newline at end of file