Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion source/TR-181/board_sbapi/cosa_ethernet_apis.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ int _getMac(char* ifName, char* mac){

AnscTraceFlow(("%s...\n", __FUNCTION__));

CcspTraceDebug(("cosa_ethernet_apis.c - _getMac: name=%s\n", ifName));
/* CID 281903 Copy into fixed size buffer fix */
strncpy (ifr.ifr_name, ifName , sizeof(ifr.ifr_name)-1);

Expand Down Expand Up @@ -595,24 +596,30 @@ COSA_DML_IF_STATUS getIfStatus(const PUCHAR name, struct ifreq *pIfr)
{
struct ifreq ifr;
int skfd = -1;
AnscTraceFlow(("%s... name %s\n", __FUNCTION__,name));

skfd = socket(AF_INET, SOCK_DGRAM, 0);
/* CID: 56442 Argument cannot be negative*/
if(skfd == -1)
return COSA_DML_IF_STATUS_Error;

CcspTraceDebug(("cosa_ethernet_apis.c - getIfStatus: name=%s\n", (char*)name));

/* CID 281944 Copy into fixed size buffer fix */
strncpy (ifr.ifr_name, (char*)name, sizeof(ifr.ifr_name)-1);
strncpy(ifr.ifr_name, (char*)name, sizeof(ifr.ifr_name)-1);
ifr.ifr_name[sizeof(ifr.ifr_name)-1] = '\0';

if (!isValid((char*)name)) {
/* CID 162574 Resource leak */
close(skfd);
CcspTraceDebug(("cosa_ethernet_apis.c - getIfStatus: [1]\n"));
return COSA_DML_IF_STATUS_Error;
}
AnscTraceFlow(("%s...\n", __FUNCTION__));
if (ioctl(skfd, SIOCGIFFLAGS, &ifr) < 0) {
if (errno == ENODEV) {
close(skfd);
CcspTraceDebug(("cosa_ethernet_apis.c - getIfStatus: [2]\n"));
return COSA_DML_IF_STATUS_Error;
}

Expand All @@ -621,9 +628,11 @@ COSA_DML_IF_STATUS getIfStatus(const PUCHAR name, struct ifreq *pIfr)

if ( FALSE == getIfAvailability( name ) )
{
CcspTraceDebug(("cosa_ethernet_apis.c - getIfStatus: [3]\n"));
return COSA_DML_IF_STATUS_NotPresent;
}

CcspTraceDebug(("cosa_ethernet_apis.c - getIfStatus: [4]\n"));
return COSA_DML_IF_STATUS_Unknown;
}
close(skfd);
Expand All @@ -635,10 +644,12 @@ COSA_DML_IF_STATUS getIfStatus(const PUCHAR name, struct ifreq *pIfr)

if ( ifr.ifr_flags & IFF_UP )
{
CcspTraceDebug(("cosa_ethernet_apis.c - getIfStatus: UP\n"));
return COSA_DML_IF_STATUS_Up;
}
else
{
CcspTraceDebug(("cosa_ethernet_apis.c - getIfStatus: DOWN\n"));
return COSA_DML_IF_STATUS_Down;
}
}
Expand Down Expand Up @@ -2082,6 +2093,7 @@ BOOL CosaDmlEthWanLinkStatus()

port += CCSP_HAL_ETHSW_EthPort1; /* ETH WAN HALs start from 0 but Ethernet Switch HALs start with 1*/

CcspTraceDebug(("cosa_ethernet_apis.c - CosaDmlEthWanLinkStatus calling HAL CcspHalEthSwGetPortStatus\n"));
status = CcspHalEthSwGetPortStatus(port, &LinkRate, &DuplexMode, &LinkStatus);

if ( status == RETURN_OK )
Expand Down
19 changes: 13 additions & 6 deletions source/TR-181/board_sbapi/eth_hal_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,14 +390,15 @@ void* CcspHalExtSw_AssociatedDeviceMonitorThread( void *arg )
static BOOL isDeleteAllDone = FALSE;


// CcspTraceInfo(("<EthMonThrd> Iteration Start\n") );
CcspTraceDebug(("<EthMonThrd> Iteration Start, flags: bProcessFurther=%d, isDeleteAllDone=%d\n", bProcessFurther, isDeleteAllDone));
//Get Associated Device Details from HAL. Do nothing if failure case
if(-1 == CcspHalExtSw_getAssociatedDevice( &ulTotalEthDeviceCount, &pstRecvEthDevice ))
{
CcspTraceInfo(("%s %d - Fail to get AssociatedDevice details\n" ,__FUNCTION__,__LINE__ ) );
bProcessFurther = FALSE;
}

CcspTraceDebug(("<EthMonThrd> Total ethernet count from HAL=%lu, flags: bProcessFurther=%d, isDeleteAllDone=%d\n", ulTotalEthDeviceCount, bProcessFurther, isDeleteAllDone));
if( bProcessFurther )
{
/*
Expand Down Expand Up @@ -439,9 +440,10 @@ void* CcspHalExtSw_AssociatedDeviceMonitorThread( void *arg )
bProcessFurther = FALSE;
}

CcspTraceDebug(("<EthMonThrd> Handle notification start, flags: bProcessFurther=%d, isDeleteAllDone=%d\n", bProcessFurther, isDeleteAllDone));
if( bProcessFurther )
{
// CcspTraceInfo(("<EthMonThrd> - Host(+) Loop Start\n") );
CcspTraceDebug(("<EthMonThrd> - Host(+) Loop Start\n") );

// Reset isDeleteAllDone variable to proceed further from next iteration
isDeleteAllDone = FALSE;
Expand Down Expand Up @@ -469,6 +471,7 @@ void* CcspHalExtSw_AssociatedDeviceMonitorThread( void *arg )
if( 0 == ValidateClient( tmp_mac_id ) )
{
//Delete and send notification
CcspTraceDebug(("<EthMonThrd> - Delete host and send notification, mac:%s\n", tmp_mac_id));
CcspHalExtSw_DeleteHost( &pstRecvEthDevice[ iLoopCount ], eth_device_hashArrayList, TRUE );
continue;
}
Expand All @@ -478,16 +481,18 @@ void* CcspHalExtSw_AssociatedDeviceMonitorThread( void *arg )
if ( NULL == CcspHalExtSw_FindHost( &pstRecvEthDevice[ iLoopCount ], eth_device_hashArrayList, NULL ) )
{
//Add and send notification
CcspTraceDebug(("<EthMonThrd> - Add host and send notification, mac:%s\n", tmp_mac_id));
CcspHalExtSw_AddHost( &pstRecvEthDevice[ iLoopCount ], eth_device_hashArrayList, TRUE );
}

//Add in temp hash list and Don't send notification
CcspTraceDebug(("<EthMonThrd> - Add host tmp list, mac:%s\n", tmp_mac_id));
CcspHalExtSw_AddHost( &pstRecvEthDevice[ iLoopCount ], eth_device_hashArrayTempList, FALSE );
}

// CcspTraceInfo(("<EthMonThrd> - Host(+) Loop End\n") );
CcspTraceDebug(("<EthMonThrd> - Host(+) Loop End\n"));

// CcspTraceInfo(("<EthMonThrd> - Host(-) Loop Start\n") );
CcspTraceDebug(("<EthMonThrd> - Host(-) Loop Start\n"));

//Disconnection Case
for( iLoopCount = 0; iLoopCount< ETH_NODE_HASH_SIZE; iLoopCount++ )
Expand All @@ -499,14 +504,16 @@ void* CcspHalExtSw_AssociatedDeviceMonitorThread( void *arg )
)
{
//Delete and Need to send notification
CcspTraceDebug(("<EthMonThrd> - Delete and send notification disconnect\n"));
CcspHalExtSw_DeleteHost( eth_device_hashArrayList[ iLoopCount ], eth_device_hashArrayList, TRUE );
}
}

//Delete all hosts from temp hash list
CcspTraceDebug(("<EthMonThrd> - Delete all host tmp list\n"));
CcspHalExtSw_DeleteAllHosts( eth_device_hashArrayTempList, FALSE );

// CcspTraceInfo(("<EthMonThrd> - Host(-) Loop End\n") );
CcspTraceDebug(("<EthMonThrd> - Host(-) Loop End\n"));
}
//Free if memory is valid case
if( NULL != pstRecvEthDevice )
Expand All @@ -516,7 +523,7 @@ void* CcspHalExtSw_AssociatedDeviceMonitorThread( void *arg )
}
}

// CcspTraceInfo(("<EthMonThrd> Iteration End\n") );
CcspTraceDebug(("<EthMonThrd> Iteration End\n"));

//Sleep
sleep( ETH_POLLING_PERIOD );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,8 @@ CosaDmlEthPortGetDinfo
return ANSC_STATUS_FAILURE;
}

CcspTraceDebug(("cosa_ethernet_apis_arm.c - CosaDmlEthPortGetDinfo: num=%lu,%lu name=%s,%s\n",
ulInstanceNumber, pEthIf->instanceNumber, pEthIf->sInfo->Name, pEthIf->Alias));
pEthIf->control->getDInfo(pEthIf, pInfo);

pInfo->LastChange = pEthIf->LastChange;
Expand Down Expand Up @@ -942,10 +944,12 @@ static int puma6_getSwitchDInfo(PCosaEthInterfaceInfo eth, PCOSA_DML_ETH_PORT_DI
}
#endif

CcspTraceDebug(("cosa_ethernet_apis_arm.c - puma6_getSwitchDInfo, name=%s\n", (PUCHAR)eth->sInfo->Name));
status = CcspHalEthSwGetPortStatus(port, &LinkRate, &DuplexMode, &LinkStatus);

if ( status == RETURN_OK )
{
CcspTraceDebug(("cosa_ethernet_apis_arm.c - puma6_getSwitchDInfo: HAL status=%d\n", LinkStatus));
switch ( LinkStatus )
{
case CCSP_HAL_ETHSW_LINK_Up:
Expand Down Expand Up @@ -1018,6 +1022,7 @@ static int puma6_getSwitchDInfo(PCosaEthInterfaceInfo eth, PCOSA_DML_ETH_PORT_DI
}
else
{
CcspTraceDebug(("cosa_ethernet_apis_arm.c - puma6_getSwitchDInfo: HAL failure\n"));
return ANSC_STATUS_FAILURE;
}

Expand Down Expand Up @@ -1131,6 +1136,7 @@ static int getIfStats(PCosaEthInterfaceInfo pEthIf, PCOSA_DML_ETH_STATS pStats)

static int getIfDInfo(PCosaEthInterfaceInfo pEthIf, PCOSA_DML_ETH_PORT_DINFO pInfo)
{
CcspTraceDebug(("cosa_ethernet_apis_arm.c - getIfDInfo\n"));
pInfo->Status = getIfStatus((PUCHAR)pEthIf->sInfo->Name, NULL);

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
#define ETH_4_PORTS
#endif

#define SWITCH_PORT_0_NAME "sw_1"
#define SWITCH_PORT_1_NAME "sw_2"
#define SWITCH_PORT_2_NAME "sw_3"
#define SWITCH_PORT_3_NAME "sw_4"
#define SWITCH_PORT_0_NAME "eth0"
#define SWITCH_PORT_1_NAME "eth1"
#define SWITCH_PORT_2_NAME "eth2"
#define SWITCH_PORT_3_NAME "eth3"

#if defined (ETH_5_PORTS) || defined (ETH_6_PORTS) || defined (ETH_8_PORTS) || (defined(INTEL_PUMA7) && !defined(_ARRIS_XB6_PRODUCT_REQ_))
#define SWITCH_PORT_4_NAME "sw_5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ Interface_GetParamUlongValue
/* check the parameter name and return the corresponding value */
if (strcmp(ParamName, "Status") == 0)
{
CcspTraceDebug(("Interface_GetParamUlongValue: Get status case, calling CosaDmlEthPortGetDinfo\n"));
/* collect value */
CosaDmlEthPortGetDinfo(NULL, pEthernetPortFull->Cfg.InstanceNumber, &pEthernetPortFull->DynamicInfo);

Expand Down