From 6e67f90b45c1006b0e4b3c0afaeb13e41220b195 Mon Sep 17 00:00:00 2001 From: shefty Date: Fri, 18 Jul 2008 08:49:04 +0000 Subject: [PATCH] winverbs: pass in SGID index to uvp pre_create_av The SGID index can change dynamically, so look up the correct index when creating an address vector. The index is passed into the UVP in the resv2 field of the grh. Signed-off-by: Sean Hefty git-svn-id: svn://openib.tc.cornell.edu/gen1@1416 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- .../winverbs/core/winverbs/user/wv_device.cpp | 22 ++++++++ .../winverbs/core/winverbs/user/wv_device.h | 1 + .../winverbs/core/winverbs/user/wv_pd.cpp | 55 ++++++++++++------- branches/winverbs/core/winverbs/user/wv_pd.h | 3 +- 4 files changed, 59 insertions(+), 22 deletions(-) diff --git a/branches/winverbs/core/winverbs/user/wv_device.cpp b/branches/winverbs/core/winverbs/user/wv_device.cpp index be6f9ba8..86c4661f 100644 --- a/branches/winverbs/core/winverbs/user/wv_device.cpp +++ b/branches/winverbs/core/winverbs/user/wv_device.cpp @@ -293,6 +293,28 @@ out: return hr; } +STDMETHODIMP CWVDevice:: +FindGidIndex(UINT8 PortNumber, WV_GID *pGid, UINT8 *pIndex) +{ + WV_GID gid; + DWORD index; + HRESULT hr; + + for (index = 0; true; index++) { + hr = QueryGid(PortNumber, index, &gid); + if (FAILED(hr)) { + break; + } + + if (RtlCompareMemory(pGid, &gid, sizeof(gid)) == sizeof(gid)) { + *pIndex = (UINT8) index; + break; + } + } + + return hr; +} + // TODO: cache PKey table and update with QueryPort() STDMETHODIMP CWVDevice:: QueryPkey(UINT8 PortNumber, DWORD Index, NET16* pPkey) diff --git a/branches/winverbs/core/winverbs/user/wv_device.h b/branches/winverbs/core/winverbs/user/wv_device.h index 43a3a5c3..72314c35 100644 --- a/branches/winverbs/core/winverbs/user/wv_device.h +++ b/branches/winverbs/core/winverbs/user/wv_device.h @@ -94,6 +94,7 @@ public: *ppDevice = NULL; return hr; } + STDMETHODIMP FindGidIndex(UINT8 PortNumber, WV_GID *pGid, UINT8 *pIndex); CWVProvider *m_pProvider; uvp_interface_t m_Verbs; diff --git a/branches/winverbs/core/winverbs/user/wv_pd.cpp b/branches/winverbs/core/winverbs/user/wv_pd.cpp index e34702d0..258205d7 100644 --- a/branches/winverbs/core/winverbs/user/wv_pd.cpp +++ b/branches/winverbs/core/winverbs/user/wv_pd.cpp @@ -311,25 +311,6 @@ Release(void) // Address Handle routines //------------------------ -void WvVerbsConvertAv(ib_av_attr_t *pVerbsAv, WV_ADDRESS_VECTOR *pAv) -{ - pVerbsAv->grh_valid = pAv->Route.Valid; - if (pVerbsAv->grh_valid) { - pVerbsAv->grh.ver_class_flow = - _byteswap_ulong(_byteswap_ulong(pAv->Route.FlowLabel) | - (pAv->Route.TrafficClass << 20)); - pVerbsAv->grh.hop_limit = pAv->Route.HopLimit; - RtlCopyMemory(&pVerbsAv->grh.src_gid, &pAv->Route.SGid, sizeof(pAv->Route.SGid)); - RtlCopyMemory(&pVerbsAv->grh.dest_gid, &pAv->Route.DGid, sizeof(pAv->Route.DGid)); - } - - pVerbsAv->port_num = pAv->PortNumber; - pVerbsAv->sl = pAv->ServiceLevel; - pVerbsAv->dlid = pAv->DLid; - pVerbsAv->static_rate = pAv->StaticRate; - pVerbsAv->path_bits = pAv->SourcePathBits; -} - CWVAddressHandle::CWVAddressHandle(CWVProtectionDomain *pPd) { pPd->AddRef(); @@ -350,7 +331,11 @@ Create(WV_ADDRESS_VECTOR* pAddress) ib_av_attr_t av; CWVBuffer buf; - WvVerbsConvertAv(&av, pAddress); + hr = ConvertAv(&av, pAddress); + if (FAILED(hr)) { + return hr; + } + stat = m_pVerbs->pre_create_av(m_pPd->m_hVerbsPd, &av, &verbsData, &m_hVerbsAh); if (stat != IB_SUCCESS) { if (stat == IB_VERBS_PROCESSING_DONE) { @@ -435,3 +420,33 @@ Release(void) { return CWVBase::Release(); } + +STDMETHODIMP CWVAddressHandle:: +ConvertAv(ib_av_attr_t *pVerbsAv, WV_ADDRESS_VECTOR *pAv) +{ + HRESULT hr; + + pVerbsAv->grh_valid = pAv->Route.Valid; + if (pVerbsAv->grh_valid) { + hr = m_pPd->m_pDevice->FindGidIndex(pAv->PortNumber, &pAv->Route.SGid, + &pVerbsAv->grh.resv2); + if (FAILED(hr)) { + return hr; + } + + pVerbsAv->grh.ver_class_flow = + _byteswap_ulong(_byteswap_ulong(pAv->Route.FlowLabel) | + (pAv->Route.TrafficClass << 20)); + pVerbsAv->grh.hop_limit = pAv->Route.HopLimit; + RtlCopyMemory(&pVerbsAv->grh.src_gid, &pAv->Route.SGid, sizeof(pAv->Route.SGid)); + RtlCopyMemory(&pVerbsAv->grh.dest_gid, &pAv->Route.DGid, sizeof(pAv->Route.DGid)); + } + + pVerbsAv->port_num = pAv->PortNumber; + pVerbsAv->sl = pAv->ServiceLevel; + pVerbsAv->dlid = pAv->DLid; + pVerbsAv->static_rate = pAv->StaticRate; + pVerbsAv->path_bits = pAv->SourcePathBits; + + return WV_SUCCESS; +} \ No newline at end of file diff --git a/branches/winverbs/core/winverbs/user/wv_pd.h b/branches/winverbs/core/winverbs/user/wv_pd.h index 39c912c6..00f46b8d 100644 --- a/branches/winverbs/core/winverbs/user/wv_pd.h +++ b/branches/winverbs/core/winverbs/user/wv_pd.h @@ -207,8 +207,7 @@ public: protected: STDMETHODIMP Create(WV_ADDRESS_VECTOR* pAddress); + STDMETHODIMP ConvertAv(ib_av_attr_t *pVerbsAv, WV_ADDRESS_VECTOR *pAv); }; -void WvVerbsConvertAv(ib_av_attr_t *pVerbsAv, WV_ADDRESS_VECTOR *pAv); - #endif // _WV_PD_H_ \ No newline at end of file -- 2.41.0