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
8 changes: 7 additions & 1 deletion config/RdkVlanManager.xml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,13 @@
<type>unsignedInt</type>
<syntax>uint32</syntax>
<writable>true</writable>
</parameter>
</parameter>
<parameter>
<name>MACVLAN</name>
<type>unsignedInt</type>
<syntax>uint32</syntax>
<writable>true</writable>
</parameter>
Comment thread
PalakshaOS marked this conversation as resolved.
<parameter>
<name>X_RDK_BaseInterface</name>
<type>string(64)</type>
Expand Down
10 changes: 10 additions & 0 deletions source/TR-181/include/vlan_apis.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#define PSM_VLANMANAGER_LOWERLAYERS "dmsb.vlanmanager.%d.lowerlayers"
#define PSM_VLANMANAGER_VLANID "dmsb.vlanmanager.%d.vlanid"
#define PSM_VLANMANAGER_TPID "dmsb.vlanmanager.%d.tpid"
#define PSM_VLANMANAGER_MACVLAN "dmsb.vlanmanager.%d.macvlan"
#define PSM_VLANMANAGER_BASEINTERFACE "dmsb.vlanmanager.%d.baseinterface"
#define PSM_VLANMANAGER_PATH "dmsb.vlanmanager.%d.path"

Expand All @@ -75,6 +76,13 @@ typedef enum {
VLAN_IF_ERROR
}vlan_link_status_e;

typedef enum macVlan_status
{
MACVLAN_DISABLED = 0,
MACVLAN_PRIVATE = 1,
MACVLAN_PUBLIC = 2
}macVlan_status_t;

typedef struct
_DML_VLAN
{
Expand All @@ -88,6 +96,7 @@ _DML_VLAN
CHAR BaseInterface[64];
INT VLANId;
UINT TPId;
macVlan_status_t MacVlanEnable;
CHAR Path[1024];
Comment thread
PalakshaOS marked this conversation as resolved.
Comment thread
PalakshaOS marked this conversation as resolved.
Comment thread
PalakshaOS marked this conversation as resolved.
Comment thread
PalakshaOS marked this conversation as resolved.
Comment thread
PalakshaOS marked this conversation as resolved.
}
DML_VLAN, *PDML_VLAN;
Expand All @@ -96,6 +105,7 @@ static inline void DML_VLAN_INIT(PDML_VLAN pVlan)
{
pVlan->Enable = FALSE;
pVlan->Status = VLAN_IF_DOWN;
pVlan->MacVlanEnable = MACVLAN_DISABLED;
}

/*************************************
Expand Down
87 changes: 78 additions & 9 deletions source/TR-181/middle_layer_src/vlan_apis.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ void * Vlan_Disable(void *Arg)

pthread_mutex_lock(&vlan_access_mutex);
//Set EthLink to False. it will take care UnTagged Created Vlan Interface
if (Vlan_SetEthLink(pEntry, FALSE, FALSE) == ANSC_STATUS_FAILURE)
if (pEntry->MacVlanEnable != MACVLAN_DISABLED && Vlan_SetEthLink(pEntry, FALSE, FALSE) == ANSC_STATUS_FAILURE)
{
CcspTraceError(("%s-%d: Failed to Enable EthLink\n", __FUNCTION__, __LINE__));
}
Expand Down Expand Up @@ -402,6 +402,22 @@ void * Vlan_Disable(void *Arg)
Vlan_DeleteInterface(pEntry);
#endif
}
#if !defined(VLAN_MANAGER_HAL_ENABLED)
else if(pEntry->VLANId == -1 && pEntry->MacVlanEnable == MACVLAN_DISABLED)
{
/* If the VLANID = -1, delete the OVS bridge and remove the interface */
if (strcmp(pEntry->BaseInterface, pEntry->Name))
{
if (pEntry->BaseInterface[0] != '\0')
{
v_secure_system("brctl delif %s %s", pEntry->Name, pEntry->BaseInterface);
}
v_secure_system("ifconfig %s down", pEntry->Name);
v_secure_system("brctl delbr %s", pEntry->Name);
}

}
#endif
pEntry->Status = VLAN_IF_DOWN;
EthLink_SendVirtualIfaceVlanStatus(pEntry->Path, "Down");
CcspTraceInfo(("%s - %s:Successfully deleted VLAN interface %s\n", __FUNCTION__, VLAN_MARKER_VLAN_IF_CREATE, pEntry->Name));
Expand Down Expand Up @@ -590,6 +606,35 @@ static ANSC_STATUS Vlan_CreateTaggedInterface(PDML_VLAN pEntry)
}
#endif

#if !defined(VLAN_MANAGER_HAL_ENABLED)
static ANSC_STATUS Vlan_CreateUnTaggedInterface(PDML_VLAN pEntry)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need separate API? Instead can we make the logic based on valid VLANID?

{
ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS;

if (pEntry == NULL)
{
CcspTraceError(("%s-%d: Failed to Create UnTagged Vlan Interface\n", __FUNCTION__, __LINE__));
return ANSC_STATUS_FAILURE;
}

/* If the VLANID = -1, create an OVS bridge and add the interface */
if(strcmp(pEntry->BaseInterface, pEntry->Name))
{
v_secure_system("ip link show %s > /dev/null 2>&1 || brctl addbr %s", pEntry->Name, pEntry->Name);
v_secure_system("brctl addif %s %s 2>/dev/null", pEntry->Name, pEntry->BaseInterface);
v_secure_system("ifconfig %s up", pEntry->Name);

if (Vlan_SetMacAddr(pEntry) == ANSC_STATUS_FAILURE)
{
CcspTraceError(("%s Failed to Set MacAddress \n", __FUNCTION__));
return ANSC_STATUS_FAILURE;
}
}
return returnStatus;
Comment thread
PalakshaOS marked this conversation as resolved.
}
#endif


void * Vlan_Enable(void *Arg)
{
ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS;
Expand All @@ -607,7 +652,7 @@ void * Vlan_Enable(void *Arg)

pthread_mutex_lock(&vlan_access_mutex);
//Create Vlan Tagged Interface
if(pEntry->VLANId > 0) {
if(pEntry->VLANId > 0 || (pEntry->VLANId == -1 && pEntry->MacVlanEnable == MACVLAN_DISABLED)) {
if (Vlan_SetEthLink(pEntry, TRUE, TRUE) == ANSC_STATUS_FAILURE)
{
CcspTraceError(("%s-%d: Failed to Enable EthLink\n", __FUNCTION__, __LINE__));
Expand All @@ -617,25 +662,49 @@ void * Vlan_Enable(void *Arg)
{
CcspTraceError(("[%s][%d]Failed to get vlan interface status \n", __FUNCTION__, __LINE__));
}
#if defined(VLAN_MANAGER_HAL_ENABLED)
if ( ( status != VLAN_IF_NOTPRESENT ) && ( status != VLAN_IF_ERROR ) )
{
CcspTraceInfo(("%s %s:VLAN interface(%s) already exists, delete it first\n", __FUNCTION__, VLAN_MARKER_VLAN_IF_CREATE, pEntry->Name));
#if defined(VLAN_MANAGER_HAL_ENABLED)
returnStatus = vlan_eth_hal_deleteInterface(pEntry->Name, pEntry->InstanceNumber);
if (ANSC_STATUS_SUCCESS != returnStatus)
{
CcspTraceError(("%s - Failed to delete the existing VLAN interface %s\n", __FUNCTION__, pEntry->Name));
}
CcspTraceInfo(("%s - %s:Successfully deleted VLAN interface %s\n", __FUNCTION__, VLAN_MARKER_VLAN_IF_DELETE, pEntry->Name));
else
#else
{
v_secure_system("ip link set %s down", pEntry->Name);
v_secure_system("ip link delete %s",pEntry->Name);
}
#endif
{
CcspTraceInfo(("%s - %s:Successfully deleted VLAN interface %s\n", __FUNCTION__, VLAN_MARKER_VLAN_IF_DELETE, pEntry->Name));
}
}

#if !defined(VLAN_MANAGER_HAL_ENABLED)
if(pEntry->VLANId > 0)
{
#endif
returnStatus = Vlan_CreateTaggedInterface(pEntry);
if (ANSC_STATUS_SUCCESS != returnStatus)
returnStatus = Vlan_CreateTaggedInterface(pEntry);
if (ANSC_STATUS_SUCCESS != returnStatus)
{
pEntry->Status = VLAN_IF_ERROR;
CcspTraceError(("[%s][%d]Failed to create VLAN Tagged interface \n", __FUNCTION__, __LINE__));
}
#if !defined(VLAN_MANAGER_HAL_ENABLED)
}
else
{
pEntry->Status = VLAN_IF_ERROR;
CcspTraceError(("[%s][%d]Failed to create VLAN Tagged interface \n", __FUNCTION__, __LINE__));
returnStatus = Vlan_CreateUnTaggedInterface(pEntry);
if (ANSC_STATUS_SUCCESS != returnStatus)
{
pEntry->Status = VLAN_IF_ERROR;
CcspTraceError(("[%s][%d]Failed to create VLAN UnTagged interface \n", __FUNCTION__, __LINE__));
}
}

#endif
//Get status of VLAN link
while(iIterator < 10)
{
Expand Down
11 changes: 11 additions & 0 deletions source/TR-181/middle_layer_src/vlan_dml.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,11 @@ Vlan_GetParamUlongValue
*puLong = p_Vlan->TPId;
return TRUE;
}
if (strcmp(ParamName, "MACVLAN") == 0)
{
*puLong = p_Vlan->MacVlanEnable;
return TRUE;
}
/* CcspTraceWarning(("Unsupported parameter '%s'\n", ParamName)); */
return FALSE;
}
Expand Down Expand Up @@ -627,6 +632,12 @@ Vlan_SetParamUlongValue
p_Vlan->TPId = uValue;
return TRUE;
}
if (strcmp(ParamName, "MACVLAN") == 0)
{
p_Vlan->MacVlanEnable = uValue;
return TRUE;
}


/* CcspTraceWarning(("Unsupported parameter '%s'\n", ParamName)); */
return FALSE;
Expand Down
17 changes: 17 additions & 0 deletions source/TR-181/middle_layer_src/vlan_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#define PSM_VLANMANAGER_CFG_REGION "dmsb.vlanmanager.cfg.%d.region"
#define PSM_VLANMANAGER_CFG_VLANID "dmsb.vlanmanager.cfg.%d.vlanid"
#define PSM_VLANMANAGER_CFG_TPID "dmsb.vlanmanager.cfg.%d.tpid"
#define PSM_VLANMANAGER_CFG_MACVLAN "dmsb.vlanmanager.cfg.%d.macvlan"

extern char g_Subsystem[32];
extern ANSC_HANDLE bus_handle;
Expand Down Expand Up @@ -278,6 +279,15 @@ static ANSC_STATUS VlanTerminationInitialize( ANSC_HANDLE hThisObject)
pVlan[nIndex].TPId = atoi(acPSMValue) ;
}

/* get macvlan from psm */
memset(acPSMQuery, 0, sizeof(acPSMQuery));
memset(acPSMValue, 0, sizeof(acPSMValue));
snprintf( acPSMQuery, sizeof( acPSMQuery ), PSM_VLANMANAGER_CFG_MACVLAN, (vlanCfgIndexes[nIndex] + 1) );
if ( CCSP_SUCCESS == DmlVlanGetPSMRecordValue( acPSMQuery, acPSMValue ) )
{
pVlan[nIndex].MacVlanEnable = (UINT)strtoul(acPSMValue, NULL, 10);
}

/*TODO:
*Need to be Removed Path From PSM Once RBUS Support Available in VlanManager and WanManager.
*/
Expand Down Expand Up @@ -377,6 +387,13 @@ static ANSC_STATUS VlanTerminationInitialize( ANSC_HANDLE hThisObject)
pVlan[nIndex].TPId = atoi(acPSMValue) ;
}

/* get macvlan from psm */
snprintf( acPSMQuery, sizeof( acPSMQuery ), PSM_VLANMANAGER_MACVLAN, nIndex + 1 );
if ( CCSP_SUCCESS == DmlVlanGetPSMRecordValue( acPSMQuery, acPSMValue ) )
{
pVlan[nIndex].MacVlanEnable = (UINT)strtoul(acPSMValue, NULL, 10) ;
}

/* get base interface from psm */
snprintf( acPSMQuery, sizeof( acPSMQuery ), PSM_VLANMANAGER_BASEINTERFACE, nIndex + 1 );
if ( CCSP_SUCCESS == DmlVlanGetPSMRecordValue( acPSMQuery, acPSMValue ) )
Expand Down