Skip to content

Commit

Permalink
[nes]: ETHERNET + BRIDGE changes ...
Browse files Browse the repository at this point in the history
  • Loading branch information
nes-repo committed Nov 28, 2014
1 parent 545c1c1 commit 0d2acd8
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 21 deletions.
99 changes: 80 additions & 19 deletions bridge/ieee8021PbbMib.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@ bool
ieee8021PbbVipTable_createHier (
ieee8021PbbVipEntry_t *poEntry)
{
register bool bRetCode = false;
register bool bPhyLocked = false;
ifData_t *poVipIfData = NULL;
register ieee8021BridgeBaseEntry_t *poIeee8021BridgeBaseEntry = NULL;

if ((poIeee8021BridgeBaseEntry = ieee8021BridgeBaseTable_getByIndex (poEntry->u32BridgeBasePortComponentId)) == NULL ||
Expand All @@ -502,30 +502,34 @@ ieee8021PbbVipTable_createHier (
poIeee8021BridgeBasePortEntry->i32Type = ieee8021BridgeBasePortType_virtualInstancePort_c;


ifData_t *poVipIfData = NULL;

if (!ifData_createReference (ifIndex_zero_c, ifType_bridge_c, xAdminStatus_up_c, true, false, false, &poVipIfData))
{
goto ieee8021PbbVipTable_createHier_cleanup;
}

poIeee8021BridgeBasePortEntry->u32IfIndex = poVipIfData->u32Index;
ifData_unLock (poVipIfData);

ieee8021BridgePhyData_wrLock ();
bPhyLocked = true;

if (ieee8021BridgePhyData_createExt (poVipIfData->u32Index, 0) == NULL)
register ieee8021BridgePhyData_t *poVipPhyData = NULL;

if ((poVipPhyData = ieee8021BridgePhyData_createExt (poIeee8021BridgeBasePortEntry->u32IfIndex, 0)) == NULL)
{
goto ieee8021PbbVipTable_createHier_cleanup;
}
xBitmap_setBitRev (poVipPhyData->au8TypeCapabilities, ieee8021BridgeBasePortTypeCapabilities_virtualInstancePort_c, 1);

poIeee8021BridgeBasePortEntry->u32IfIndex = poVipIfData->u32Index;

return true;

bRetCode = true;

ieee8021PbbVipTable_createHier_cleanup:

poVipIfData != NULL ? ifData_unLock (poVipIfData): false;
bPhyLocked ? ieee8021BridgePhyData_unLock (): false;
ieee8021PbbVipTable_removeHier (poEntry);
return false;
!bRetCode ? ieee8021PbbVipTable_removeHier (poEntry): false;
return bRetCode;
}

bool
Expand Down Expand Up @@ -559,12 +563,12 @@ ieee8021PbbVipTable_removeHier (
if ((poVipPhyData = ieee8021BridgePhyData_getByIndex (poIeee8021BridgeBasePortEntry->u32IfIndex, 0)) == NULL ||
!ieee8021BridgePhyData_removeExt (poVipPhyData))
{
goto ieee8021PbbVipTable_removeHier_phyCleanup;
goto ieee8021PbbVipTable_removeHier_phyUnlock;
}

bRetCode = true;

ieee8021PbbVipTable_removeHier_phyCleanup:
ieee8021PbbVipTable_removeHier_phyUnlock:

ieee8021BridgePhyData_unLock ();
if (!bRetCode)
Expand Down Expand Up @@ -1538,7 +1542,7 @@ ieee8021PbbPipTable_createExt (
{
ifData_t *poPipIfData = NULL;

if (!ifData_createReference (u32IfIndex, ifType_pip_c, 0, true, true, false, &poPipIfData))
if (!ifData_createReference (u32IfIndex, ifType_pip_c, ifAdminStatus_up_c, true, true, false, &poPipIfData))
{
goto ieee8021PbbPipTable_createExt_cleanup;
}
Expand All @@ -1556,7 +1560,7 @@ ieee8021PbbPipTable_createExt (
goto ieee8021PbbPipTable_createExt_cleanup;
}

if (!bIfReserved && !ieee8021PbbPipTable_createHier (poEntry))
if (!ieee8021PbbPipTable_createHier (poEntry, bIfReserved))
{
ieee8021PbbPipTable_removeEntry (poEntry);
poEntry = NULL;
Expand All @@ -1582,27 +1586,84 @@ ieee8021PbbPipTable_removeExt (ieee8021PbbPipEntry_t *poEntry)

bool
ieee8021PbbPipTable_createHier (
ieee8021PbbPipEntry_t *poEntry)
ieee8021PbbPipEntry_t *poEntry, bool bIfReserved)
{
if (!ifData_createReference (poEntry->u32IfIndex, 0, 0, false, true, false, NULL))
register bool bRetCode = false;
register bool bPhyLocked = false;

if (!bIfReserved && !ifData_createReference (poEntry->u32IfIndex, 0, ifAdminStatus_up_c, true, true, false, NULL))
{
goto ieee8021PbbPipTable_createHier_cleanup;
}

return true;
ieee8021BridgePhyData_wrLock ();
bPhyLocked = true;

register ieee8021BridgePhyData_t *poPipPhyData = NULL;

if ((poPipPhyData = ieee8021BridgePhyData_getByIndex (poEntry->u32IfIndex, 0)) == NULL ||
(poPipPhyData = ieee8021BridgePhyData_createExt (poEntry->u32IfIndex, 0)) == NULL)
{
goto ieee8021PbbPipTable_createHier_cleanup;
}

poEntry->bExternal = poPipPhyData->u32PhyPort != 0;
xBitmap_setBitRev (poPipPhyData->au8TypeCapabilities, ieee8021BridgeBasePortTypeCapabilities_providerInstancePort_c, 1);

bRetCode = true;

ieee8021PbbPipTable_createHier_cleanup:

ieee8021PbbPipTable_removeHier (poEntry);
return false;
bPhyLocked ? ieee8021BridgePhyData_unLock (): false;
!bRetCode ? ieee8021PbbPipTable_removeHier (poEntry): false;
return bRetCode;
}

bool
ieee8021PbbPipTable_removeHier (
ieee8021PbbPipEntry_t *poEntry)
{
return ifData_removeReference (poEntry->u32IfIndex, true, true, true);
register bool bRetCode = false;

if (!poEntry->bExternal)
{
goto ieee8021PbbPipTable_removeHier_removeIf;
}

ieee8021BridgePhyData_wrLock ();

register ieee8021BridgePhyData_t *poPipPhyData = NULL;

if ((poPipPhyData = ieee8021BridgePhyData_getByIndex (poEntry->u32IfIndex, 0)) != NULL &&
!ieee8021BridgePhyData_removeExt (poPipPhyData))
{
goto ieee8021PbbPipTable_removeHier_phyUnlock;
}

bRetCode = true;

ieee8021PbbPipTable_removeHier_phyUnlock:

ieee8021BridgePhyData_unLock ();
if (!bRetCode)
{
goto ieee8021PbbPipTable_removeHier_cleanup;
}
bRetCode = false;


ieee8021PbbPipTable_removeHier_removeIf:

if (!ifData_removeReference (poEntry->u32IfIndex, true, true, true))
{
goto ieee8021PbbPipTable_removeHier_cleanup;
}

bRetCode = true;

ieee8021PbbPipTable_removeHier_cleanup:

return bRetCode;
}

bool
Expand Down
6 changes: 4 additions & 2 deletions bridge/ieee8021PbbMib.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,10 @@ typedef struct ieee8021PbbPipEntry_t
size_t u16VipMap4_len; /* # of uint8_t elements */
uint8_t u8RowStatus;

xBTree_Node_t oComp_BTreeNode;
bool bExternal;

xBTree_Node_t oBTreeNode;
xBTree_Node_t oComp_BTreeNode;
} ieee8021PbbPipEntry_t;

extern xBTree_t oIeee8021PbbPipTable_BTree;
Expand All @@ -275,7 +277,7 @@ void ieee8021PbbPipTable_removeEntry (ieee8021PbbPipEntry_t *poEntry);
ieee8021PbbPipEntry_t * ieee8021PbbPipTable_createExt (
uint32_t u32IfIndex);
bool ieee8021PbbPipTable_removeExt (ieee8021PbbPipEntry_t *poEntry);
bool ieee8021PbbPipTable_createHier (ieee8021PbbPipEntry_t *poEntry);
bool ieee8021PbbPipTable_createHier (ieee8021PbbPipEntry_t *poEntry, bool bIfReserved);
bool ieee8021PbbPipTable_removeHier (ieee8021PbbPipEntry_t *poEntry);
bool ieee8021PbbPipRowStatus_handler (
ieee8021PbbPipEntry_t *poEntry, uint8_t u8RowStatus);
Expand Down
2 changes: 2 additions & 0 deletions ethernet/ieee8021BridgeMib.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ enum
ieee8021BridgeBasePortTypeCapabilities_stationFacingBridgePort_c = 8,
ieee8021BridgeBasePortTypeCapabilities_uplinkAccessPort_c = 9,
ieee8021BridgeBasePortTypeCapabilities_uplinkRelayPort_c = 10,
ieee8021BridgeBasePortTypeCapabilities_providerInstancePort_c = 12,

/* enums for column ieee8021BridgeBasePortType */
ieee8021BridgeBasePortType_none_c = 1,
Expand All @@ -228,6 +229,7 @@ enum
ieee8021BridgeBasePortType_uplinkAccessPort_c = 11,
ieee8021BridgeBasePortType_uplinkRelayPort_c = 12,
ieee8021BridgeBasePortType_providerEdgePort_c = 101,
ieee8021BridgeBasePortType_providerInstancePort_c = 14,

/* enums for column ieee8021BridgeBasePortExternal */
ieee8021BridgeBasePortExternal_true_c = 1,
Expand Down

0 comments on commit 0d2acd8

Please sign in to comment.