rapidio 路由枚举算法

简介: rapidio 路由枚举算法

目录

系统枚举伪代码

主机枚举

邻居节点枚举


系统枚举伪代码


// System enumeration and initialization using the power-on device ID as the hostDeviceID
// —Discover the host first
// —Discover the host’s neighbor recursively
 STATUS rioSystemEnumerate (hostDeviceID)
{
// Discover the host first.
status = rioEnumerateHost (hostDeviceID);
 if (status == ERR_SLAVE) {
 rioClearUp (hostDeviceID);
 return ERR_SLAVE;
 }
// Discover the host neighbor
status = rioEnumerateNeighbor (hostDeviceID, hopCount = 1);
if (status == ERR_SLAVE) {
rioClearUp (hostDeviceID);
return ERR_SLAVE;
}
// If the code advances to this point successfully, the host must acquire the
// HostBaseDeviceIdLock for all devices in the system. When this is done, the Discovered bit
// Master Enable bit, etc. can be set for all devices.
} // end rioSystemEnumerate


主机枚举


STATUS rioEnumerateHost (hostDeviceID)

{
// Try to acquire the lock
rioAcquireDeviceLock (0, hostDeviceID, 0, hostDeviceID);
while (HostBaseDeviceIdLockCSR.HostBaseDeviceID < hostDeviceID) {
// Delay for a while
rioDelay ();
// Retry lock acquisition
rioAcquireDeviceLock (0, hostDeviceID, 0, hostDeviceID, &lockingHost);
}
// Check to see if there is a master with a larger host device ID
if (HostBaseDeviceIdLock.HostBaseDeviceID > hostDeviceID) {
// Release the current lock
rioReleaseDeviceLock (0, hostDeviceID, 0, hostDeviceID);
return ERR_SLAVE;
}
// Lock has been acquired so enumeration can begin
// Assign the default host ID to the host
rioSetBaseDeviceId (0, hostDeviceID, hostDeviceID);
// Increment the available device ID
if (DeviceID == hostDeviceID) {
DeviceID ++;
 }
return RIO_SUCCESS;
} // end rioEnumerateHost


邻居节点枚举


 STATUS rioEnumerateNeighbor (hostDeviceID, hopCount)
{
// The host has already discovered this node if it currently owns the lock
rioGetCurHostLock (0, 0, 0, &owner_device_id);
if (owner_device_id == hostDeviceID) {
return RIO_SUCCESS;
}
// Try to acquire the lock
rioAcquireDeviceLock (0, RIO_GEN_DFLT_DID, hopCount, hostDeviceID, &lockingHost);
while (HostBaseDeviceIdLockCSR.HostBaseDeviceID < hostDeviceID) {
// Delay for a while
rioDelay ();
// Retry lock acquisition
rioAcquireDeviceLock(0, RIO_GEN_DFLT_DID, hopCount, hostDeviceID,&lockingHost);
}
// Check to see if there is a master with a larger host device ID
if (HostBaseDeviceIdLock.HostBaseDeviceID > hostDeviceID) {
return ERR_SLAVE;
}
// Lock has been acquired so enumeration can begin
// Check Source Operation CAR and Destination Operation CAR to see if a Device ID can be
// assigned
rioGetSourceOps (0, RIO_GEN_DFLT_DID, hopCount, &SourceOperationCAR);
rioGetDestOps (0, RIO_GEN_DFLT_DID, hopCount, &DestinationOperationCAR);
if ( (SourceOperationCAR.Read || Write || Atomic) &&
(DestinationOperationCAR.Read || Write || Atomic)) {
// Set the device ID
rioSetBaseDeviceId (0, RIO_GEN_DFLT_DID, DeviceID);
// Increment the available device ID
DeviceID ++;
if (DeviceID == hostDeviceID) {
DeviceID ++;
}
}
// Check to see if the device is a switch
rioGetFeatures (0, RIO_GEN_DFLT_DID, hopCount, &ProcessingElementFeatureCAR);
if (ProcessingElementFeatureCAR.Switch == TRUE) {
// Read the switch information
rioGetSwitchPortInfo (0, RIO_GEN_DFLT_DID, hopCount,&SwitchPortInformationCAR);
// Record the switch device identity
Switches[SwitchID].SwitchIdentity = DeviceIdentityCAR.DeviceIdentity;
// Bookkeeping for the current switch ID
curSwitchID = SwitchID;
// Increment the available switch ID
SwitchID ++;
// Initialize the current switch routing table to add entries for all previously discovered
// devices so that they are routed correctly. Start with the host device ID (0x00) and end with
// DeviceID-1.
for (each deviceID in [0..DeviceID-1]) {
rioRouteAddEntry (0, RIO_GEN_DFLT_DID, hopCount, RIO_GEN_DFLT_DID,
deviceID,
SwitchPortInformationCAR.PortNumber, NULL);
}
// Synchronize the current switch routing table with the global table
for (each deviceID in [0.. DeviceID-1]) {
Switches[curSwitchID].RouteTable.LFT[deviceID] =
SwitchPortInformationCAR.PortNumber;
}
// Update the hopCount to reach the current switch
Switches[curSwitchID].HopCount = hopCount;
for (each portNum in SwitchPortInformationCAR.PortTotal) {
if (SwitchPortInformationCAR.PortNumber == portNum) {
continue;
}、
// Bookkeeping for the current available device ID
curDeviceID = DeviceID;
rioGetPortErrStatus (0, RIO_GEN_DFLT_DID, hopCount, &PortErrorStatusCSR[portNum]);
// Check if it is possible to have a neighbor
if (PortErrorStatusCSR[portNum].PortUninitialized == TRUE) {
continue;
}
else if (PortErrorStatusCSR[portNum].PortOK == TRUE) {
// Check if it is an enumeration boundary port
if (PortControlCSR[portNum].PortEnumerationBoundary == TRUE) {
continue;
}
rioRouteAddEntry(0, RIO_GEN_DFLT_DID, hopCount, RIO_GEN_DFLT_DID, 0, portNumber, NULL);
// Discover the neighbor recursively
if (status = rioEnumerateNeighbor(hopCount + 1) != RIO_SUCCESS) {
return status;
}
// If more than one end point device was found, update the current switch routing table
// entries beginning with the curDeviceID entry and ending with the DeviceID-1
// entry.
if (DeviceID > curDeviceID) {
for (each deviceID in [curDeviceID..DeviceID-1]) {
rioRouteAddEntry(0, RIO_GEN_DFLT_DID, hopCount, deviceID,portNumber);
}
// Synchronize the current switch routing table with the global table
for (each deviceID in [curDeviceID..DeviceID-1]) {
Switches[curSwitchID].RouteTable.LFT[deviceID] = portNumber;
}
// Update the associated Device ID in the path.
Switches[curSwitchID].DeviceID = curDeviceID;
} // end if
} // end else if
} // end for
} // end if (ProcessingElementFeatureCAR.Switch == TRUE)
return RIO_SUCCESS;
} // end rioEnumerateNeighbor


目录
相关文章
|
2天前
|
算法 网络协议 数据建模
【计算机网络】—— IP协议及动态路由算法(下)
【计算机网络】—— IP协议及动态路由算法(下)
12 0
|
2天前
|
算法 网络协议 数据建模
【计算机网络】—— IP协议及动态路由算法(上)
【计算机网络】—— IP协议及动态路由算法(上)
11 0
|
2天前
|
网络协议 算法 数据库
【专栏】OSPF是广泛应用的链路状态路由协议,通过分层网络结构和SPF算法实现高效路由。强烈建议收藏!
【4月更文挑战第28天】OSPF是广泛应用的链路状态路由协议,通过分层网络结构和SPF算法实现高效路由。其关键特性包括区域划分、链路状态数据库、邻居关系和路由更新。工作过程涉及邻居发现、信息交换、数据库构建、路由计算及收敛。理解OSPF对于网络管理和规划具有重要意义。
|
2天前
|
网络协议 算法 数据库
【专栏】IS-IS协议是内部网关协议,常用于大型网络路由器间的路由信息交换,基于OSI的CLNP标准和Dijkstra算法
【4月更文挑战第28天】IS-IS协议是内部网关协议,常用于大型网络路由器间的路由信息交换,基于OSI的CLNP标准和Dijkstra算法。其特点是分层设计、快速收敛、高效资源利用和强故障恢复能力。在现代网络中,IS-IS广泛应用于服务提供商、企业网络及与其他协议的融合,是构建稳定、高效网络的关键。了解和应用IS-IS能提升网络系统的可靠性和效率。
|
2天前
|
算法
枚举算法的介绍
枚举算法的介绍
22 0
|
2天前
|
算法
枚举算法:解决问题的穷举之道(二)
枚举算法:解决问题的穷举之道(二)
|
2天前
|
算法
枚举算法:解决问题的穷举之道(一)
枚举算法:解决问题的穷举之道(一)
|
2天前
|
机器学习/深度学习 人工智能 算法
算法02-入门算法枚举与模拟算法
算法02-入门算法枚举与模拟算法
|
2天前
|
算法 数据安全/隐私保护 计算机视觉
基于二维CS-SCHT变换和LABS方法的水印嵌入和提取算法matlab仿真
该内容包括一个算法的运行展示和详细步骤,使用了MATLAB2022a。算法涉及水印嵌入和提取,利用LAB色彩空间可能用于隐藏水印。水印通过二维CS-SCHT变换、低频系数处理和特定解码策略来提取。代码段展示了水印置乱、图像处理(如噪声、旋转、剪切等攻击)以及水印的逆置乱和提取过程。最后,计算并保存了比特率,用于评估水印的稳健性。