333 lines
9.8 KiB
C
333 lines
9.8 KiB
C
/* ipcom_cmd_vlanfwd.c - VLAN stacking NAE shell commands */
|
|
|
|
/*
|
|
* Copyright (c) 2010 Wind River Systems, Inc.
|
|
*
|
|
* The right to copy, distribute or otherwise make use of this software
|
|
* may be licensed only pursuant to the terms of an applicable Wind River
|
|
* license agreement. No license to Wind River intellectual property rights
|
|
* is granted herein. All rights not licensed by Wind River are reserved
|
|
* by Wind River.
|
|
*/
|
|
|
|
/*
|
|
modification history
|
|
--------------------
|
|
01c,25jun10,tlu Added S-VLAN to Nehalem NAE
|
|
01b,08jul10,zhr Added priority queue display
|
|
01a,26mar10,tlu Created.
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 1 DESCRIPTION
|
|
****************************************************************************
|
|
*
|
|
* Shell command related to VLAN stacking forwarder.
|
|
*
|
|
* The file is only valid if IPCOM_USE_FORWARDER_VLAN_STACKING is defined.
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 2 CONFIGURATION
|
|
****************************************************************************
|
|
*/
|
|
|
|
#include "ipcom_config.h"
|
|
|
|
#ifdef IPCOM_USE_FORWARDER_VLAN_STACKING
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 3 INCLUDE FILES
|
|
****************************************************************************
|
|
*/
|
|
|
|
#define IPCOM_USE_CLIB_PROTO
|
|
#include "ipcom_clib.h"
|
|
#include "ipcom_cstyle.h"
|
|
#include "ipcom_os.h"
|
|
#include "ipcom_time.h"
|
|
#include "ipcom_type.h"
|
|
#include "ipcom_err.h"
|
|
#include "ipcom_shell.h"
|
|
|
|
#include "ipcom_forwarder.h"
|
|
|
|
static char buf[50];
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 4 TYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 6 EXTERN PROTOTYPES
|
|
****************************************************************************
|
|
*/
|
|
#ifdef _WRS_CONFIG_COMPONENT_OCTEON_PRIORITY_QUEUE
|
|
extern int ipcom_forwader_show_nae_priority_queue(void);
|
|
#endif
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 9 STATIC FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipcom_vlan_fwd_print_flags
|
|
*===========================================================================
|
|
* Description: Convert the enumerate flags to string
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC char *
|
|
ipcom_vlan_fwd_print_flags(Ip_u8 flags)
|
|
{
|
|
ipcom_strcpy(buf, "");
|
|
|
|
if (flags & IPCOM_FWD_VLAN_ADD_SVLAN)
|
|
ipcom_strcat(buf, "Add_SVLAN ");
|
|
if (flags & IPCOM_FWD_VLAN_DEL_SVLAN)
|
|
ipcom_strcat(buf, "Del_SVLAN ");
|
|
if (flags & IPCOM_FWD_VLAN_ADD_CVLAN)
|
|
ipcom_strcat(buf, "Add_CVLAN ");
|
|
if (flags & IPCOM_FWD_VLAN_PRI_REMAP)
|
|
ipcom_strcat(buf, "PRI_REMAP ");
|
|
if (flags & IPCOM_FWD_VLAN_DROP_NO_VID)
|
|
ipcom_strcat(buf, "DROP_NO_VID ");
|
|
if (flags & IPCOM_FWD_VLAN_DROP_VID)
|
|
ipcom_strcat(buf, "DROP_VID ");
|
|
|
|
return buf;
|
|
}
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipcom_vlan_fwd_has_port_type
|
|
*===========================================================================
|
|
* Description: Check whether has specified port type
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_STATIC Ip_bool
|
|
ipcom_vlan_fwd_has_port_type(Ip_u8 port_type)
|
|
{
|
|
Ip_u8 i;
|
|
|
|
for (i = 0; i < MAX_FW_PORTS; i++)
|
|
if (ipcom_fw->port_type[i] & port_type)
|
|
return IP_TRUE;
|
|
|
|
return IP_FALSE;
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipcom_forwarder_fwctrl
|
|
*===========================================================================
|
|
* Context: shell
|
|
* Description: Forwarder control command
|
|
* Parameters:
|
|
* Returns: 0
|
|
*
|
|
*/
|
|
IP_STATIC int
|
|
ipcom_vlan_forwarder_cmd(int argc, char **argv)
|
|
{
|
|
Ip_u16 port, i, j, num_entries = 0;
|
|
fw_cache_entry_vlan_stacking_t evlan;
|
|
unsigned int cpu = ipcom_forwarder_current_core();
|
|
|
|
if (argc != 2)
|
|
goto usage;
|
|
|
|
if (!ipcom_strcmp(argv[1], "cache"))
|
|
{
|
|
ipcom_printf("VLAN stacking forwarder cache table:\n");
|
|
for (port = 0; port < MAX_FW_PORTS; port++)
|
|
for (i = 0; i < 1024; i++)
|
|
{
|
|
if (ipcom_fw->fw_cache_tbl_vlan[port] == IP_NULL)
|
|
continue;
|
|
|
|
evlan = ipcom_fw->fw_cache_tbl_vlan[port][i];
|
|
if (evlan.tx_ports_num)
|
|
{
|
|
ipcom_printf(" VLAN stacking cache entry: %x\n",
|
|
&(ipcom_fw->fw_cache_tbl_vlan[port][i]));
|
|
ipcom_printf(" index: %d\n", i);
|
|
ipcom_printf(" rx port: %d\n", port);
|
|
if (evlan.s_vlan_id &&
|
|
(ipcom_fw->port_type[port] & IPCOM_FWD_VLAN_PORT_CS))
|
|
{
|
|
ipcom_printf(" incoming customer VID: %d\n", i);
|
|
ipcom_printf(" service VID: %d\n",evlan.s_vlan_id);
|
|
}
|
|
else if (evlan.s_vlan_id &&
|
|
(ipcom_fw->port_type[port]&IPCOM_FWD_VLAN_PORT_SC))
|
|
{
|
|
ipcom_printf(" incoming service VID: %d\n",
|
|
evlan.s_vlan_id);
|
|
ipcom_printf(" customer VID: %d\n",
|
|
evlan.c_vlan_tag & 0xfff);
|
|
}
|
|
else
|
|
ipcom_printf(" incoming service VID: %d\n", i);
|
|
|
|
if (ipcom_fw->port_type[port] & IPCOM_FWD_VLAN_PORT_CS)
|
|
{
|
|
ipcom_printf(" priority mapping: \n\t");
|
|
for (j = 0; j < 8; j++)
|
|
{
|
|
ipcom_printf(" %d --> %d",
|
|
j, evlan.pri_mapping[j]);
|
|
if (j == 3) ipcom_printf("\n\t");
|
|
}
|
|
ipcom_printf("\n");
|
|
}
|
|
ipcom_printf(" number of tx ports: %d\n",
|
|
evlan.tx_ports_num);
|
|
ipcom_printf(" tx ports: ");
|
|
for (j = 0; j < MAX_FW_PORTS; j++)
|
|
{
|
|
if (evlan.tx_ports[j>>5] & (1 << (j & 0x1f)))
|
|
ipcom_printf(" %d,", j);
|
|
}
|
|
ipcom_printf("\n");
|
|
|
|
num_entries ++;
|
|
}
|
|
}
|
|
if (!num_entries) ipcom_printf(" No cache entry exist\n");
|
|
}
|
|
else if (!ipcom_strcmp(argv[1], "data"))
|
|
{
|
|
ipcom_printf("VLAN stacking NAE forwarder shared data:\n");
|
|
ipcom_printf(" NAE/forwarder core number: %d\n", cpu);
|
|
if (ipcom_vlan_fwd_has_port_type(IPCOM_FWD_VLAN_PORT_CS))
|
|
{
|
|
ipcom_printf(" VLAN stacking customer ports on provder edge: ");
|
|
for (j = 0; j < MAX_FW_PORTS; j++)
|
|
{
|
|
if (ipcom_fw->port_type[j] & IPCOM_FWD_VLAN_PORT_CS)
|
|
ipcom_printf(" %d,", j);
|
|
}
|
|
ipcom_printf("\n");
|
|
}
|
|
if (ipcom_vlan_fwd_has_port_type(IPCOM_FWD_VLAN_PORT_SC))
|
|
{
|
|
ipcom_printf(" VLAN stacking provider ports on provder edge: ");
|
|
for (j = 0; j < MAX_FW_PORTS; j++)
|
|
{
|
|
if (ipcom_fw->port_type[j] & IPCOM_FWD_VLAN_PORT_SC)
|
|
ipcom_printf(" %d,", j);
|
|
}
|
|
ipcom_printf("\n");
|
|
}
|
|
if (ipcom_vlan_fwd_has_port_type(IPCOM_FWD_VLAN_PORT_S))
|
|
{
|
|
ipcom_printf(" VLAN stacking provider ports on S-VLAN node: ");
|
|
for (j = 0; j < MAX_FW_PORTS; j++)
|
|
{
|
|
if (ipcom_fw->port_type[j] & IPCOM_FWD_VLAN_PORT_S)
|
|
ipcom_printf(" %d,", j);
|
|
}
|
|
ipcom_printf("\n");
|
|
}
|
|
if (ipcom_vlan_fwd_has_port_type(IPCOM_FWD_VLAN_PORT_SC) ||
|
|
ipcom_vlan_fwd_has_port_type(IPCOM_FWD_VLAN_PORT_CS))
|
|
{
|
|
ipcom_printf(" Port action: port\tAction flags:\n");
|
|
for (j = 0; j < MAX_FW_PORTS; j++)
|
|
{
|
|
if (ipcom_fw->rule_flags[j] & 0x1f)
|
|
ipcom_printf(" %d\t%s\n",
|
|
j, ipcom_vlan_fwd_print_flags(ipcom_fw->rule_flags[j]));
|
|
}
|
|
}
|
|
if (ipcom_vlan_fwd_has_port_type(IPCOM_FWD_VLAN_PORT_STACKING))
|
|
{
|
|
ipcom_printf(" Port VID: port\tPVID\tMAC address\n");
|
|
for (j = 0; j < MAX_FW_PORTS; j++)
|
|
{
|
|
if (ipcom_fw->hw_pvid[j])
|
|
{
|
|
ipcom_printf(" %d\t%d\t",
|
|
j, ipcom_fw->hw_pvid[j]);
|
|
ipcom_printf("%x:%x:%x:%x:%x:%x\n",
|
|
ipcom_fw->hw_mac[j][0], ipcom_fw->hw_mac[j][1],
|
|
ipcom_fw->hw_mac[j][2], ipcom_fw->hw_mac[j][3],
|
|
ipcom_fw->hw_mac[j][4], ipcom_fw->hw_mac[j][5]);
|
|
}
|
|
}
|
|
}
|
|
ipcom_printf(" Server TPID: %x\n",
|
|
ip_ntohs(ipcom_fw->vlan_s_tpid_net));
|
|
}
|
|
#ifdef _WRS_CONFIG_COMPONENT_OCTEON_PRIORITY_QUEUE
|
|
else if (!ipcom_strcmp(argv[1], "queue"))
|
|
{
|
|
if (ipcom_forwader_show_nae_priority_queue() != 0)
|
|
return -1;
|
|
return 0;
|
|
}
|
|
#endif
|
|
else
|
|
goto usage;
|
|
|
|
return 0;
|
|
|
|
usage:
|
|
ipcom_printf("Usage vlanfwdshow cache\n");
|
|
ipcom_printf(" vlanfwdshow data\n");
|
|
#ifdef IPCOM_NAE_PRIORITY_QUEUE
|
|
ipcom_printf(" vlanfwdshow queue\n");
|
|
#endif
|
|
return 0;
|
|
}
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 10 PUBLISHED FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipcom_svlan_forwarder_cmd_add
|
|
*===========================================================================
|
|
* Context: init
|
|
* Description: Register S-VLAN forwarder shell command
|
|
*
|
|
*/
|
|
IP_GLOBAL void ipcom_svlan_forwarder_cmd_add(void)
|
|
{
|
|
(void)ipcom_shell_add_cmd("vlanfwdshow", "vlanfwdshow <cache|data>",
|
|
"Display VLAN stacking fast forwarder",
|
|
ipcom_vlan_forwarder_cmd,
|
|
IPCOM_PRIORITY_DEFAULT, IPCOM_PROC_STACK_SMALL);
|
|
}
|
|
|
|
#else
|
|
int ipcom_cmd_svlanfwd_empty_file;
|
|
#endif /* IPCOM_USE_FORWARDER_VLAN_STACKING */
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* End of file
|
|
*===========================================================================
|
|
*/
|