[][openwrt][switch][ARHT][update switch app to v1.0.7]
[Description]
Add below modification:
1). align switch app version to v1.0.7 with ARHT
2). fixed check_patch errors as much as possible in switch app
3). get_chip_name() directly return AN8855 to prevent 0x1f register
from being overwritten by reg_read
4). correct some files from Windos(CRLF) to UNIX(LF)
[Release-log]
N/A
Change-Id: I4913c8124ded81cffe0493748c0347fdb1fbb22f
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/9453546
diff --git a/feed/app/switch/src/an8855_sdk/api/inc/air.h b/feed/app/switch/src/an8855_sdk/api/inc/air.h
index c62174f..bedfaf9 100644
--- a/feed/app/switch/src/an8855_sdk/api/inc/air.h
+++ b/feed/app/switch/src/an8855_sdk/api/inc/air.h
@@ -1,216 +1,216 @@
-/* FILE NAME: air.h
- * PURPOSE:
- * Define the initialization in AIR SDK.
- * NOTES:
- */
-
-#ifndef AIR_H
-#define AIR_H
-
-/* INCLUDE FILE DECLARATIONS
- */
-#include <stdio.h>
-#include <string.h>
-#include "air_types.h"
-#include "air_error.h"
-#include "air_reg.h"
-#include "air_aml.h"
-#include "air_port.h"
-#include "air_vlan.h"
-#include "air_lag.h"
-#include "air_l2.h"
-#include "air_stp.h"
-#include "air_mirror.h"
-#include "air_mib.h"
-#include "air_diag.h"
-#include "air_led.h"
-#include "air_cmd.h"
-#include "air_qos.h"
-#include "air_switch.h"
-#include "air_ver.h"
-#include "air_sec.h"
-#include "air_acl.h"
-#include "air_sptag.h"
-
-/* NAMING CONSTANT DECLARATIONS
- */
-
-/* MACRO FUNCTION DECLARATIONS
- */
-#define AIR_CHECK_PTR(__ptr__) do \
-{ \
- if (NULL == (__ptr__)) \
- { \
- return AIR_E_BAD_PARAMETER; \
- } \
-} while (0)
-
-#define AIR_PARAM_CHK(expr, errCode) do \
-{ \
- if ((I32_T)(expr)) \
- { \
- return errCode; \
- } \
-} while (0)
-
-#define AIR_PRINT(fmt,...) do \
-{ \
- if (_ext_printf) \
- { \
- _ext_printf(fmt, ##__VA_ARGS__); \
- } \
-}while (0)
-
-#define AIR_UDELAY(us) do \
-{ \
- if (_ext_udelay) \
- { \
- _ext_udelay(us); \
- } \
-}while (0)
-
-#define AIR_MALLOC(size) (_ext_malloc ? _ext_malloc(size) : NULL)
-
-#define AIR_FREE(ptr) do \
- { \
- if (ptr && _ext_free) \
- { \
- _ext_free(ptr); \
- } \
- }while (0)
-
-#ifndef BIT
-#define BIT(nr) (1UL << (nr))
-#endif /* End of BIT */
-
-/* bits range: for example BITS(16,23) = 0xFF0000*/
-#ifndef BITS
-#define BITS(m, n) (~(BIT(m) - 1) & ((BIT(n) - 1) | BIT(n)))
-#endif /* End of BITS */
-
-/* bits range: for example BITS_RANGE(16,4) = 0x0F0000*/
-#ifndef BITS_RANGE
-#define BITS_RANGE(offset, range) BITS(offset, ((offset)+(range)-1))
-#endif /* End of BITS_RANGE */
-
-/* bits offset right: for example BITS_OFF_R(0x1234, 8, 4) = 0x2 */
-#ifndef BITS_OFF_R
-#define BITS_OFF_R(val, offset, range) ((val >> offset) & (BIT(range) - 1))
-#endif /* End of BITS_OFF_R */
-
-/* bits offset left: for example BITS_OFF_L(0x1234, 8, 4) = 0x400 */
-#ifndef BITS_OFF_L
-#define BITS_OFF_L(val, offset, range) ((val & (BIT(range) - 1)) << offset)
-#endif /* End of BITS_OFF_L */
-
-#ifndef MAX
-#define MAX(a, b) (((a)>(b))?(a):(b))
-#endif /* End of MAX */
-
-#ifndef MIN
-#define MIN(a, b) (((a)<(b))?(a):(b))
-#endif /* End of MIN */
-
-/* DATA TYPE DECLARATIONS
- */
-typedef AIR_ERROR_NO_T
-(*AIR_PRINTF)(
- C8_T* fmt,
- ...);
-
-typedef void
-(*AIR_UDELAY)(
- UI32_T us);
-
-typedef void*
-(*AIR_MALLOC)(
- UI32_T size);
-
-typedef void
-(*AIR_FREE)(
- void *ptr);
-
-typedef struct
-{
- AML_DEV_ACCESS_T dev_access;
- AIR_PRINTF printf;
- AIR_UDELAY udelay;
- AIR_MALLOC malloc;
- AIR_FREE free;
-}AIR_INIT_PARAM_T;
-
-/* EXPORTED SUBPROGRAM SPECIFICATIONS
- */
-extern AIR_PRINTF _ext_printf;
-extern AIR_UDELAY _ext_udelay;
-extern AIR_MALLOC _ext_malloc;
-extern AIR_FREE _ext_free;
-
-
-/* FUNCTION NAME: air_init
- * PURPOSE:
- * This API is used to initialize the SDK.
- *
- * INPUT:
- * unit -- The device unit
- * ptr_init_param -- The sdk callback functions.
- *
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_OTHERS
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_init(
- const UI32_T unit,
- AIR_INIT_PARAM_T *ptr_init_param);
-
-/* FUNCTION NAME: air_hw_reset
- * PURPOSE:
- * This API is used to reset hardware.
- *
- * INPUT:
- * unit -- The device unit
- *
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_OTHERS
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_hw_reset(
- const UI32_T unit);
-
-/* FUNCTION NAME: air_set_gpio_pin_mux
- * PURPOSE:
- * This API is used to set gpio pin mux.
- *
- * INPUT:
- * unit -- The device unit
- *
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_OTHERS
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_set_gpio_pin_mux(
- const UI32_T unit);
-
-#endif /* AIR_H */
-
+/* FILE NAME: air.h
+ * PURPOSE:
+ * Define the initialization in AIR SDK.
+ * NOTES:
+ */
+
+#ifndef AIR_H
+#define AIR_H
+
+/* INCLUDE FILE DECLARATIONS
+ */
+#include <stdio.h>
+#include <string.h>
+#include "air_types.h"
+#include "air_error.h"
+#include "air_reg.h"
+#include "air_aml.h"
+#include "air_port.h"
+#include "air_vlan.h"
+#include "air_lag.h"
+#include "air_l2.h"
+#include "air_stp.h"
+#include "air_mirror.h"
+#include "air_mib.h"
+#include "air_diag.h"
+#include "air_led.h"
+#include "air_cmd.h"
+#include "air_qos.h"
+#include "air_switch.h"
+#include "air_ver.h"
+#include "air_sec.h"
+#include "air_acl.h"
+#include "air_sptag.h"
+
+/* NAMING CONSTANT DECLARATIONS
+ */
+
+/* MACRO FUNCTION DECLARATIONS
+ */
+#define AIR_CHECK_PTR(__ptr__) do \
+{ \
+ if (NULL == (__ptr__)) \
+ { \
+ return AIR_E_BAD_PARAMETER; \
+ } \
+} while (0)
+
+#define AIR_PARAM_CHK(expr, errCode) do \
+{ \
+ if ((I32_T)(expr)) \
+ { \
+ return errCode; \
+ } \
+} while (0)
+
+#define AIR_PRINT(fmt,...) do \
+{ \
+ if (_ext_printf) \
+ { \
+ _ext_printf(fmt, ##__VA_ARGS__); \
+ } \
+}while (0)
+
+#define AIR_UDELAY(us) do \
+{ \
+ if (_ext_udelay) \
+ { \
+ _ext_udelay(us); \
+ } \
+}while (0)
+
+#define AIR_MALLOC(size) (_ext_malloc ? _ext_malloc(size) : NULL)
+
+#define AIR_FREE(ptr) do \
+ { \
+ if (ptr && _ext_free) \
+ { \
+ _ext_free(ptr); \
+ } \
+ }while (0)
+
+#ifndef BIT
+#define BIT(nr) (1UL << (nr))
+#endif /* End of BIT */
+
+/* bits range: for example BITS(16,23) = 0xFF0000*/
+#ifndef BITS
+#define BITS(m, n) (~(BIT(m) - 1) & ((BIT(n) - 1) | BIT(n)))
+#endif /* End of BITS */
+
+/* bits range: for example BITS_RANGE(16,4) = 0x0F0000*/
+#ifndef BITS_RANGE
+#define BITS_RANGE(offset, range) BITS(offset, ((offset)+(range)-1))
+#endif /* End of BITS_RANGE */
+
+/* bits offset right: for example BITS_OFF_R(0x1234, 8, 4) = 0x2 */
+#ifndef BITS_OFF_R
+#define BITS_OFF_R(val, offset, range) ((val >> offset) & (BIT(range) - 1))
+#endif /* End of BITS_OFF_R */
+
+/* bits offset left: for example BITS_OFF_L(0x1234, 8, 4) = 0x400 */
+#ifndef BITS_OFF_L
+#define BITS_OFF_L(val, offset, range) ((val & (BIT(range) - 1)) << offset)
+#endif /* End of BITS_OFF_L */
+
+#ifndef MAX
+#define MAX(a, b) (((a)>(b))?(a):(b))
+#endif /* End of MAX */
+
+#ifndef MIN
+#define MIN(a, b) (((a)<(b))?(a):(b))
+#endif /* End of MIN */
+
+/* DATA TYPE DECLARATIONS
+ */
+typedef int
+(*AIR_PRINTF)(
+ const C8_T* fmt,
+ ...);
+
+typedef int
+(*AIR_UDELAY)(
+ UI32_T us);
+
+typedef void*
+(*AIR_MALLOC)(
+ long unsigned int size);
+
+typedef void
+(*AIR_FREE)(
+ void *ptr);
+
+typedef struct
+{
+ AML_DEV_ACCESS_T dev_access;
+ AIR_PRINTF printf;
+ AIR_UDELAY udelay;
+ AIR_MALLOC malloc;
+ AIR_FREE free;
+}AIR_INIT_PARAM_T;
+
+/* EXPORTED SUBPROGRAM SPECIFICATIONS
+ */
+extern AIR_PRINTF _ext_printf;
+extern AIR_UDELAY _ext_udelay;
+extern AIR_MALLOC _ext_malloc;
+extern AIR_FREE _ext_free;
+
+
+/* FUNCTION NAME: air_init
+ * PURPOSE:
+ * This API is used to initialize the SDK.
+ *
+ * INPUT:
+ * unit -- The device unit
+ * ptr_init_param -- The sdk callback functions.
+ *
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_OTHERS
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_init(
+ const UI32_T unit,
+ AIR_INIT_PARAM_T *ptr_init_param);
+
+/* FUNCTION NAME: air_hw_reset
+ * PURPOSE:
+ * This API is used to reset hardware.
+ *
+ * INPUT:
+ * unit -- The device unit
+ *
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_OTHERS
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_hw_reset(
+ const UI32_T unit);
+
+/* FUNCTION NAME: air_set_gpio_pin_mux
+ * PURPOSE:
+ * This API is used to set gpio pin mux.
+ *
+ * INPUT:
+ * unit -- The device unit
+ *
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_OTHERS
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_set_gpio_pin_mux(
+ const UI32_T unit);
+
+#endif /* AIR_H */
+
diff --git a/feed/app/switch/src/an8855_sdk/api/inc/air_aml.h b/feed/app/switch/src/an8855_sdk/api/inc/air_aml.h
index 49a38b6..8d40bee 100644
--- a/feed/app/switch/src/an8855_sdk/api/inc/air_aml.h
+++ b/feed/app/switch/src/an8855_sdk/api/inc/air_aml.h
@@ -1,214 +1,214 @@
-/* FILE NAME: air_aml.h
- * PURPOSE:
- * Define the access management layer function in AIR SDK.
- * NOTES:
- */
-
-#ifndef AIR_AML_H
-#define AIR_AML_H
-
-/* INCLUDE FILE DECLARATIONS
- */
-
-/* NAMING CONSTANT DECLARATIONS
- */
-
-/* MACRO FUNCTION DECLARATIONS
- */
-
-/* DATA TYPE DECLARATIONS
- */
-typedef AIR_ERROR_NO_T
-(*AML_DEV_READ_FUNC_T)(
- const UI32_T unit,
- const UI32_T addr_offset,
- UI32_T *ptr_data);
-
-typedef AIR_ERROR_NO_T
-(*AML_DEV_WRITE_FUNC_T)(
- const UI32_T unit,
- const UI32_T addr_offset,
- const UI32_T data);
-
-typedef AIR_ERROR_NO_T
-(*AML_DEV_PHY_READ_FUNC_T)(
- const UI32_T unit,
- const UI32_T port_id,
- const UI32_T addr_offset,
- UI32_T *ptr_data);
-
-typedef AIR_ERROR_NO_T
-(*AML_DEV_PHY_WRITE_FUNC_T)(
- const UI32_T unit,
- const UI32_T port_id,
- const UI32_T addr_offset,
- const UI32_T data);
-
-typedef AIR_ERROR_NO_T
-(*AML_DEV_PHY_READ_CL45_FUNC_T)(
- const UI32_T unit,
- const UI32_T port_id,
- const UI32_T dev_type,
- const UI32_T addr_offset,
- UI32_T *ptr_data);
-
-typedef AIR_ERROR_NO_T
-(*AML_DEV_PHY_WRITE_CL45_FUNC_T)(
- const UI32_T unit,
- const UI32_T port_id,
- const UI32_T dev_type,
- const UI32_T addr_offset,
- const UI32_T data);
-
-/* To read or write the HW-intf registers. */
-typedef struct
-{
- AML_DEV_READ_FUNC_T read_callback;
- AML_DEV_WRITE_FUNC_T write_callback;
- AML_DEV_PHY_READ_FUNC_T phy_read_callback;
- AML_DEV_PHY_WRITE_FUNC_T phy_write_callback;
- AML_DEV_PHY_READ_CL45_FUNC_T phy_cl45_read_callback;
- AML_DEV_PHY_WRITE_CL45_FUNC_T phy_cl45_write_callback;
-}AML_DEV_ACCESS_T;
-
-/* EXPORTED SUBPROGRAM SPECIFICATIONS
- */
-extern AML_DEV_ACCESS_T _ext_dev_access;
-
-/* FUNCTION NAME: aml_readReg
- * PURPOSE:
- * To read data from the register of the specified chip unit.
- * INPUT:
- * unit -- the device unit
- * addr_offset -- the address of register
- * OUTPUT:
- * ptr_data -- pointer for the register data
- * RETURN:
- * NPS_E_OK -- Successfully read the data.
- * NPS_E_OTHERS -- Failed to read the data.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-aml_readReg(
- const UI32_T unit,
- const UI32_T addr_offset,
- UI32_T *ptr_data);
-
-/* FUNCTION NAME: aml_writeReg
- * PURPOSE:
- * To write data to the register of the specified chip unit.
- * INPUT:
- * unit -- the device unit
- * addr_offset -- the address of register
- * data -- written data
- * OUTPUT:
- * none
- * RETURN:
- * NPS_E_OK -- Successfully write the data.
- * NPS_E_OTHERS -- Failed to write the data.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-aml_writeReg(
- const UI32_T unit,
- const UI32_T addr_offset,
- const UI32_T data);
-
-/* FUNCTION NAME: aml_readPhyReg
- * PURPOSE:
- * To read data from the phy register of the specified chip unit in Clause22.
- * INPUT:
- * unit -- the device unit
- * port_id -- physical port number
- * addr_offset -- the address of phy register
- * OUTPUT:
- * ptr_data -- pointer for the register data
- * RETURN:
- * NPS_E_OK -- Successfully read the data.
- * NPS_E_OTHERS -- Failed to read the data.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-aml_readPhyReg(
- const UI32_T unit,
- const UI32_T port_id,
- const UI32_T addr_offset,
- UI32_T *ptr_data);
-
-/* FUNCTION NAME: aml_writePhyReg
- * PURPOSE:
- * To write data to the phy register of the specified chip unit in Clause22.
- * INPUT:
- * unit -- the device unit
- * port_id -- physical port number
- * addr_offset -- the address of phy register
- * data -- written data
- * OUTPUT:
- * none
- * RETURN:
- * NPS_E_OK -- Successfully write the data.
- * NPS_E_OTHERS -- Failed to write the data.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-aml_writePhyReg(
- const UI32_T unit,
- const UI32_T port_id,
- const UI32_T addr_offset,
- const UI32_T ptr_data);
-
-/* FUNCTION NAME: aml_readPhyRegCL45
- * PURPOSE:
- * To read data from the phy register of the specified chip unit in Clause45.
- * INPUT:
- * unit -- the device unit
- * port_id -- physical port number
- * dev_type -- phy register type
- * addr_offset -- the address of phy register
- * OUTPUT:
- * ptr_data -- pointer for the register data
- * RETURN:
- * NPS_E_OK -- Successfully read the data.
- * NPS_E_OTHERS -- Failed to read the data.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-aml_readPhyRegCL45(
- const UI32_T unit,
- const UI32_T port_id,
- const UI32_T dev_type,
- const UI32_T addr_offset,
- UI32_T *ptr_data);
-
-/* FUNCTION NAME: aml_writePhyRegCL45
- * PURPOSE:
- * To write data to the phy register of the specified chip unit in Clause45.
- * INPUT:
- * unit -- the device unit
- * port_id -- physical port number
- * dev_type -- phy register offset
- * addr_offset -- the address of phy register
- * data -- written data
- * OUTPUT:
- * none
- * RETURN:
- * NPS_E_OK -- Successfully write the data.
- * NPS_E_OTHERS -- Failed to write the data.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-aml_writePhyRegCL45(
- const UI32_T unit,
- const UI32_T port_id,
- const UI32_T dev_type,
- const UI32_T addr_offset,
- const UI32_T data);
-
-#endif /* AIR_AML_H */
-
+/* FILE NAME: air_aml.h
+ * PURPOSE:
+ * Define the access management layer function in AIR SDK.
+ * NOTES:
+ */
+
+#ifndef AIR_AML_H
+#define AIR_AML_H
+
+/* INCLUDE FILE DECLARATIONS
+ */
+
+/* NAMING CONSTANT DECLARATIONS
+ */
+
+/* MACRO FUNCTION DECLARATIONS
+ */
+
+/* DATA TYPE DECLARATIONS
+ */
+typedef AIR_ERROR_NO_T
+(*AML_DEV_READ_FUNC_T)(
+ const UI32_T unit,
+ const UI32_T addr_offset,
+ UI32_T *ptr_data);
+
+typedef AIR_ERROR_NO_T
+(*AML_DEV_WRITE_FUNC_T)(
+ const UI32_T unit,
+ const UI32_T addr_offset,
+ const UI32_T data);
+
+typedef AIR_ERROR_NO_T
+(*AML_DEV_PHY_READ_FUNC_T)(
+ const UI32_T unit,
+ const UI32_T port_id,
+ const UI32_T addr_offset,
+ UI32_T *ptr_data);
+
+typedef AIR_ERROR_NO_T
+(*AML_DEV_PHY_WRITE_FUNC_T)(
+ const UI32_T unit,
+ const UI32_T port_id,
+ const UI32_T addr_offset,
+ const UI32_T data);
+
+typedef AIR_ERROR_NO_T
+(*AML_DEV_PHY_READ_CL45_FUNC_T)(
+ const UI32_T unit,
+ const UI32_T port_id,
+ const UI32_T dev_type,
+ const UI32_T addr_offset,
+ UI32_T *ptr_data);
+
+typedef AIR_ERROR_NO_T
+(*AML_DEV_PHY_WRITE_CL45_FUNC_T)(
+ const UI32_T unit,
+ const UI32_T port_id,
+ const UI32_T dev_type,
+ const UI32_T addr_offset,
+ const UI32_T data);
+
+/* To read or write the HW-intf registers. */
+typedef struct
+{
+ AML_DEV_READ_FUNC_T read_callback;
+ AML_DEV_WRITE_FUNC_T write_callback;
+ AML_DEV_PHY_READ_FUNC_T phy_read_callback;
+ AML_DEV_PHY_WRITE_FUNC_T phy_write_callback;
+ AML_DEV_PHY_READ_CL45_FUNC_T phy_cl45_read_callback;
+ AML_DEV_PHY_WRITE_CL45_FUNC_T phy_cl45_write_callback;
+}AML_DEV_ACCESS_T;
+
+/* EXPORTED SUBPROGRAM SPECIFICATIONS
+ */
+extern AML_DEV_ACCESS_T _ext_dev_access;
+
+/* FUNCTION NAME: aml_readReg
+ * PURPOSE:
+ * To read data from the register of the specified chip unit.
+ * INPUT:
+ * unit -- the device unit
+ * addr_offset -- the address of register
+ * OUTPUT:
+ * ptr_data -- pointer for the register data
+ * RETURN:
+ * NPS_E_OK -- Successfully read the data.
+ * NPS_E_OTHERS -- Failed to read the data.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+aml_readReg(
+ const UI32_T unit,
+ const UI32_T addr_offset,
+ UI32_T *ptr_data);
+
+/* FUNCTION NAME: aml_writeReg
+ * PURPOSE:
+ * To write data to the register of the specified chip unit.
+ * INPUT:
+ * unit -- the device unit
+ * addr_offset -- the address of register
+ * data -- written data
+ * OUTPUT:
+ * none
+ * RETURN:
+ * NPS_E_OK -- Successfully write the data.
+ * NPS_E_OTHERS -- Failed to write the data.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+aml_writeReg(
+ const UI32_T unit,
+ const UI32_T addr_offset,
+ const UI32_T data);
+
+/* FUNCTION NAME: aml_readPhyReg
+ * PURPOSE:
+ * To read data from the phy register of the specified chip unit in Clause22.
+ * INPUT:
+ * unit -- the device unit
+ * port_id -- physical port number
+ * addr_offset -- the address of phy register
+ * OUTPUT:
+ * ptr_data -- pointer for the register data
+ * RETURN:
+ * NPS_E_OK -- Successfully read the data.
+ * NPS_E_OTHERS -- Failed to read the data.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+aml_readPhyReg(
+ const UI32_T unit,
+ const UI32_T port_id,
+ const UI32_T addr_offset,
+ UI32_T *ptr_data);
+
+/* FUNCTION NAME: aml_writePhyReg
+ * PURPOSE:
+ * To write data to the phy register of the specified chip unit in Clause22.
+ * INPUT:
+ * unit -- the device unit
+ * port_id -- physical port number
+ * addr_offset -- the address of phy register
+ * data -- written data
+ * OUTPUT:
+ * none
+ * RETURN:
+ * NPS_E_OK -- Successfully write the data.
+ * NPS_E_OTHERS -- Failed to write the data.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+aml_writePhyReg(
+ const UI32_T unit,
+ const UI32_T port_id,
+ const UI32_T addr_offset,
+ const UI32_T ptr_data);
+
+/* FUNCTION NAME: aml_readPhyRegCL45
+ * PURPOSE:
+ * To read data from the phy register of the specified chip unit in Clause45.
+ * INPUT:
+ * unit -- the device unit
+ * port_id -- physical port number
+ * dev_type -- phy register type
+ * addr_offset -- the address of phy register
+ * OUTPUT:
+ * ptr_data -- pointer for the register data
+ * RETURN:
+ * NPS_E_OK -- Successfully read the data.
+ * NPS_E_OTHERS -- Failed to read the data.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+aml_readPhyRegCL45(
+ const UI32_T unit,
+ const UI32_T port_id,
+ const UI32_T dev_type,
+ const UI32_T addr_offset,
+ UI32_T *ptr_data);
+
+/* FUNCTION NAME: aml_writePhyRegCL45
+ * PURPOSE:
+ * To write data to the phy register of the specified chip unit in Clause45.
+ * INPUT:
+ * unit -- the device unit
+ * port_id -- physical port number
+ * dev_type -- phy register offset
+ * addr_offset -- the address of phy register
+ * data -- written data
+ * OUTPUT:
+ * none
+ * RETURN:
+ * NPS_E_OK -- Successfully write the data.
+ * NPS_E_OTHERS -- Failed to write the data.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+aml_writePhyRegCL45(
+ const UI32_T unit,
+ const UI32_T port_id,
+ const UI32_T dev_type,
+ const UI32_T addr_offset,
+ const UI32_T data);
+
+#endif /* AIR_AML_H */
+
diff --git a/feed/app/switch/src/an8855_sdk/api/inc/air_cmd.h b/feed/app/switch/src/an8855_sdk/api/inc/air_cmd.h
index 071d063..766a9a3 100644
--- a/feed/app/switch/src/an8855_sdk/api/inc/air_cmd.h
+++ b/feed/app/switch/src/an8855_sdk/api/inc/air_cmd.h
@@ -1,50 +1,50 @@
-/* FILE NAME: air_cmd.h
- * PURPOSE:
- * Define the command line function in AIR SDK.
- * NOTES:
- */
-
-#ifndef AIR_CMD_H
-#define AIR_CMD_H
-
-/* INCLUDE FILE DECLARATIONS
- */
-
-/* NAMING CONSTANT DECLARATIONS
- */
-
-/* MACRO FUNCTION DECLARATIONS
- */
-
-/* DATA TYPE DECLARATIONS
- */
-
-/* EXPORTED SUBPROGRAM SPECIFICATIONS
- */
-/* FUNCTION NAME: air_parse_cmd
- * PURPOSE:
- * This function is used process diagnostic cmd
- * INPUT:
- * argc -- parameter number
- * argv -- parameter strings
- * OUTPUT:
- * None
- * RETURN:
- * NPS_E_OK -- Successfully read the data.
- * NPS_E_OTHERS -- Failed to read the data.
- * NOTES:
- *
- */
-AIR_ERROR_NO_T
-air_parse_cmd(
- const UI32_T argc,
- const C8_T **argv);
-
-UI32_T
-_strtoul(
- const C8_T *cp,
- C8_T **endp,
- UI32_T base);
-
-#endif /* AIR_CMD_H */
-
+/* FILE NAME: air_cmd.h
+ * PURPOSE:
+ * Define the command line function in AIR SDK.
+ * NOTES:
+ */
+
+#ifndef AIR_CMD_H
+#define AIR_CMD_H
+
+/* INCLUDE FILE DECLARATIONS
+ */
+
+/* NAMING CONSTANT DECLARATIONS
+ */
+
+/* MACRO FUNCTION DECLARATIONS
+ */
+
+/* DATA TYPE DECLARATIONS
+ */
+
+/* EXPORTED SUBPROGRAM SPECIFICATIONS
+ */
+/* FUNCTION NAME: air_parse_cmd
+ * PURPOSE:
+ * This function is used process diagnostic cmd
+ * INPUT:
+ * argc -- parameter number
+ * argv -- parameter strings
+ * OUTPUT:
+ * None
+ * RETURN:
+ * NPS_E_OK -- Successfully read the data.
+ * NPS_E_OTHERS -- Failed to read the data.
+ * NOTES:
+ *
+ */
+AIR_ERROR_NO_T
+air_parse_cmd(
+ const UI32_T argc,
+ const C8_T **argv);
+
+UI32_T
+_strtoul(
+ const C8_T *cp,
+ C8_T **endp,
+ UI32_T base);
+
+#endif /* AIR_CMD_H */
+
diff --git a/feed/app/switch/src/an8855_sdk/api/inc/air_error.h b/feed/app/switch/src/an8855_sdk/api/inc/air_error.h
index 836d400..a8852ca 100644
--- a/feed/app/switch/src/an8855_sdk/api/inc/air_error.h
+++ b/feed/app/switch/src/an8855_sdk/api/inc/air_error.h
@@ -1,56 +1,56 @@
-/* FILE NAME: air_error.h
- * PURPOSE:
- * Define the error code in AIR SDK.
- * NOTES:
- */
-
-#ifndef AIR_ERROR_H
-#define AIR_ERROR_H
-
-/* INCLUDE FILE DECLARATIONS
- */
-
-/* NAMING CONSTANT DECLARATIONS
- */
-
-/* MACRO FUNCTION DECLARATIONS
- */
-
-/* DATA TYPE DECLARATIONS
- */
-typedef enum
-{
- AIR_E_OK = 0, /* Ok and no error */
- AIR_E_OTHERS, /* Operation is unsuccessful */
- AIR_E_BAD_PARAMETER, /* Parameter is wrong */
- AIR_E_TABLE_FULL, /* Table is full */
- AIR_E_ENTRY_NOT_FOUND, /* Entry is not found */
- AIR_E_ENTRY_EXISTS, /* Entry already exists */
- AIR_E_NOT_SUPPORT, /* Feature is not supported */
- AIR_E_TIMEOUT, /* Time out error */
- AIR_E_LAST
-} AIR_ERROR_NO_T;
-
-/* EXPORTED SUBPROGRAM SPECIFICATIONS
- */
-/* FUNCTION NAME: air_error_getString
- * PURPOSE:
- * To obtain the error string of the specified error code
- *
- * INPUT:
- * cause -- The specified error code
- * OUTPUT:
- * None
- * RETURN:
- * Pointer to the target error string
- *
- * NOTES:
- *
- *
- */
-C8_T *
-air_error_getString(
- const AIR_ERROR_NO_T cause );
-
-#endif /* AIR_ERROR_H */
-
+/* FILE NAME: air_error.h
+ * PURPOSE:
+ * Define the error code in AIR SDK.
+ * NOTES:
+ */
+
+#ifndef AIR_ERROR_H
+#define AIR_ERROR_H
+
+/* INCLUDE FILE DECLARATIONS
+ */
+
+/* NAMING CONSTANT DECLARATIONS
+ */
+
+/* MACRO FUNCTION DECLARATIONS
+ */
+
+/* DATA TYPE DECLARATIONS
+ */
+typedef enum
+{
+ AIR_E_OK = 0, /* Ok and no error */
+ AIR_E_OTHERS, /* Operation is unsuccessful */
+ AIR_E_BAD_PARAMETER, /* Parameter is wrong */
+ AIR_E_TABLE_FULL, /* Table is full */
+ AIR_E_ENTRY_NOT_FOUND, /* Entry is not found */
+ AIR_E_ENTRY_EXISTS, /* Entry already exists */
+ AIR_E_NOT_SUPPORT, /* Feature is not supported */
+ AIR_E_TIMEOUT, /* Time out error */
+ AIR_E_LAST
+} AIR_ERROR_NO_T;
+
+/* EXPORTED SUBPROGRAM SPECIFICATIONS
+ */
+/* FUNCTION NAME: air_error_getString
+ * PURPOSE:
+ * To obtain the error string of the specified error code
+ *
+ * INPUT:
+ * cause -- The specified error code
+ * OUTPUT:
+ * None
+ * RETURN:
+ * Pointer to the target error string
+ *
+ * NOTES:
+ *
+ *
+ */
+C8_T *
+air_error_getString(
+ const AIR_ERROR_NO_T cause );
+
+#endif /* AIR_ERROR_H */
+
diff --git a/feed/app/switch/src/an8855_sdk/api/inc/air_port.h b/feed/app/switch/src/an8855_sdk/api/inc/air_port.h
index a8745eb..3a39d9b 100644
--- a/feed/app/switch/src/an8855_sdk/api/inc/air_port.h
+++ b/feed/app/switch/src/an8855_sdk/api/inc/air_port.h
@@ -1,963 +1,963 @@
-/* FILE NAME: air_port.h
- * PURPOSE:
- * Define port function in AIR SDK.
- *
- * NOTES:
- * None
- */
-
-#ifndef AIR_PORT_H
-#define AIR_PORT_H
-
-/* INCLUDE FILE DECLARATIONS
- */
-
-/* NAMING CONSTANT DECLARATIONS
- */
-#define AIR_MAX_NUM_OF_UNIT (1)
-#define AIR_DST_DEFAULT_PORT (31)
-#define AIR_PORT_TX (0x00)
-#define AIR_PORT_RX (0x01)
-#define AIR_MAX_NUM_OF_PORTS (7)
-#define AIR_MAX_NUM_OF_GIGA_PORTS (5)
-#define AIR_SGMII_PORT_OFFSET_BEGIN (5)
-#define AIR_SGMII_PORT_OFFSET_END (6)
-#define AIR_ALL_PORT_BITMAP (0x7F)
-
-/* Definition of Power Saving mode */
-#define AIR_PORT_PS_LINKSTATUS (0x1 << 0)
-#define AIR_PORT_PS_EEE (0x1 << 1)
-#define AIR_PORT_PS_MASK (0x3)
-
-/* MACRO FUNCTION DECLARATIONS
- */
-
-/* DATA TYPE DECLARATIONS
- */
-/* AIR_PORT_BITMAP_T is the data type for physical port bitmap. */
-#define AIR_BITMAP_SIZE(bit_num) ((((bit_num) - 1) / AIR_MAX_NUM_OF_PORTS) + 1)
-#define AIR_PORT_BITMAP_SIZE AIR_BITMAP_SIZE(AIR_MAX_NUM_OF_PORTS)
-typedef UI32_T AIR_PORT_BITMAP_T[AIR_PORT_BITMAP_SIZE];
-
-#define AIR_INVALID_ID (0xFFFFFFFF)
-#define AIR_PORT_INVALID (AIR_INVALID_ID)
-
-/* Definition of SGMII mode */
-typedef enum
-{
- AIR_PORT_SGMII_MODE_AN,
- AIR_PORT_SGMII_MODE_FORCE,
- AIR_PORT_SGMII_MODE_LAST
-}AIR_PORT_SGMII_MODE_T;
-
-/* Definition of port speed */
-typedef enum
-{
- AIR_PORT_SPEED_10M,
- AIR_PORT_SPEED_100M,
- AIR_PORT_SPEED_1000M,
- AIR_PORT_SPEED_2500M,
- AIR_PORT_SPEED_LAST
-}AIR_PORT_SPEED_T;
-
-typedef enum
-{
- AIR_PORT_DUPLEX_HALF,
- AIR_PORT_DUPLEX_FULL,
- AIR_PORT_DUPLEX_LAST
-}AIR_PORT_DUPLEX_T;
-
-typedef enum
-{
- AIR_PORT_LINK_DOWN,
- AIR_PORT_LINK_UP,
- AIR_PORT_LINK_LAST
-}AIR_PORT_LINK_T;
-
-/* Definition of Smart speed down will occur after AN failed how many times */
-typedef enum
-{
- AIR_PORT_SSD_2T,
- AIR_PORT_SSD_3T,
- AIR_PORT_SSD_4T,
- AIR_PORT_SSD_5T,
- AIR_PORT_SSD_LAST
-}AIR_PORT_SSD_T;
-
-typedef enum
-{
- AIR_PORT_VLAN_MODE_PORT_MATRIX = 0, /* Port matrix mode */
- AIR_PORT_VLAN_MODE_FALLBACK, /* Fallback mode */
- AIR_PORT_VLAN_MODE_CHECK, /* Check mode */
- AIR_PORT_VLAN_MODE_SECURITY, /* Security mode */
- AIR_PORT_VLAN_MODE_LAST
-} AIR_PORT_VLAN_MODE_T;
-
-/* Definition of AN Advertisement Register */
-typedef struct AIR_AN_ADV_S
-{
- BOOL_T advCap10HDX; /* Advertises 10 BASE-T HDX */
- BOOL_T advCap10FDX; /* Advertises 10 BASE-T FDX */
- BOOL_T advCap100HDX; /* Advertises 100 BASE-T HDX */
- BOOL_T advCap100FDX; /* Advertises 100 BASE-T FDX */
- BOOL_T advCap1000FDX; /* Advertises 1000 BASE-T FDX */
- BOOL_T advPause; /* Advertieses Asynchronous Pause */
-}AIR_AN_ADV_T;
-
-/* Definition of Link Status of a specific port */
-typedef struct AIR_PORT_STATUS_S
-{
- BOOL_T link;
- BOOL_T duplex;
- UI32_T speed;
-}AIR_PORT_STATUS_T;
-
-/* EXPORTED SUBPROGRAM SPECIFICATIONS
- */
-/* FUNCTION NAME: air_port_setPortMatrix
- * PURPOSE:
- * Set port matrix from the specified device.
- *
- * INPUT:
- * unit -- Unit id
- * port -- Port id
- * port_bitmap -- Matrix port bitmap
- *
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_OTHERS
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_port_setPortMatrix(
- const UI32_T unit,
- const UI32_T port,
- const UI32_T port_bitmap);
-
-/* FUNCTION NAME: air_port_getPortMatrix
- * PURPOSE:
- * Get port matrix from the specified device.
- *
- * INPUT:
- * unit -- Unit id
- * port -- Port id
- *
- * OUTPUT:
- * p_port_bitmap -- Matrix port bitmap
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_OTHERS
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_port_getPortMatrix(
- const UI32_T unit,
- const UI32_T port,
- UI32_T *p_port_bitmap);
-
-/* FUNCTION NAME: air_port_setVlanMode
- * PURPOSE:
- * Set port-based vlan mechanism from the specified device.
- *
- * INPUT:
- * unit -- Unit id
- * port -- Port id
- * mode -- Port vlan mode
- *
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_OTHERS
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_port_setVlanMode(
- const UI32_T unit,
- const UI32_T port,
- const AIR_PORT_VLAN_MODE_T mode);
-
-/* FUNCTION NAME: air_port_getVlanMode
- * PURPOSE:
- * Get port-based vlan mechanism from the specified device.
- *
- * INPUT:
- * unit -- Unit id
- * port -- Port id
- *
- * OUTPUT:
- * p_mode -- Port vlan mode
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_OTHERS
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_port_getVlanMode(
- const UI32_T unit,
- const UI32_T port,
- AIR_PORT_VLAN_MODE_T *p_mode);
-
-/* FUNCTION NAME: air_port_setAnMode
- * PURPOSE:
- * Set the auto-negotiation mode for a specific port.(Auto or Forced)
- *
- * INPUT:
- * unit -- Device ID
- * port -- Index of port number
- * state -- FALSE:Disable
- * TRUE: Enable
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_setAnMode(
- const UI32_T unit,
- const UI32_T port,
- const BOOL_T state);
-
-/* FUNCTION NAME: air_port_getAnMode
- * PURPOSE:
- * Get the auto-negotiation mode for a specific port.
- *
- * INPUT:
- * unit -- Device ID
- * port -- Index of port number
- *
- * OUTPUT:
- * state -- FALSE:Disable
- * TRUE: Enable
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_getAnMode(
- const UI32_T unit,
- const UI32_T port,
- BOOL_T *ptr_state);
-
-/* FUNCTION NAME: air_port_setLocalAdvAbility
- * PURPOSE:
- * Set the auto-negotiation advertisement for a
- * specific port.
- *
- * INPUT:
- * unit -- Device ID
- * port -- Index of port number
- * adv -- AN advertisement setting
- *
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_setLocalAdvAbility(
- const UI32_T unit,
- const UI32_T port,
- const AIR_AN_ADV_T adv);
-
-/* FUNCTION NAME: air_port_getLocalAdvAbility
- * PURPOSE:
- * Get the auto-negotiation advertisement for a
- * specific port.
- *
- * INPUT:
- * unit -- Device ID
- * port -- Index of port number
- *
- * OUTPUT:
- * ptr_adv -- AN advertisement setting
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_getLocalAdvAbility(
- const UI32_T unit,
- const UI32_T port,
- AIR_AN_ADV_T *ptr_adv);
-
-/* FUNCTION NAME: air_port_getRemoteAdvAbility
- * PURPOSE:
- * Get the auto-negotiation remote advertisement for a
- * specific port.
- *
- * INPUT:
- * unit -- Device ID
- * port -- Index of port number
- *
- * OUTPUT:
- * ptr_lp_adv -- AN advertisement of link partner
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_getRemoteAdvAbility(
- const UI32_T unit,
- const UI32_T port,
- AIR_AN_ADV_T *ptr_lp_adv);
-
-/* FUNCTION NAME: air_port_setSpeed
- * PURPOSE:
- * Set the speed for a specific port.
- * This setting is used on force mode only.
- *
- * INPUT:
- * unit -- Device ID
- * port -- Index of port number
- * speed -- AIR_PORT_SPEED_10M: 10Mbps
- * AIR_PORT_SPEED_100M: 100Mbps
- * AIR_PORT_SPEED_1000M:1Gbps
- * AIR_PORT_SPEED_2500M:2.5Gbps (Port5, Port6)
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_setSpeed(
- const UI32_T unit,
- const UI32_T port,
- const UI32_T speed);
-
-/* FUNCTION NAME: air_port_getSpeed
- * PURPOSE:
- * Get the speed for a specific port.
- *
- * INPUT:
- * unit -- Device ID
- * port -- Index of port number
- *
- * OUTPUT:
- * ptr_speed -- AIR_PORT_SPEED_10M: 10Mbps
- * AIR_PORT_SPEED_100M: 100Mbps
- * AIR_PORT_SPEED_1000M:1Gbps
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_getSpeed(
- const UI32_T unit,
- const UI32_T port,
- UI32_T *ptr_speed);
-
-/* FUNCTION NAME: air_port_setDuplex
- * PURPOSE:
- * Get the duplex for a specific port.
- * This setting is used on force mode only.
- *
- * INPUT:
- * unit -- Device ID
- * port -- Index of port number
- * duplex -- AIR_PORT_DUPLEX_HALF
- * AIR_PORT_DUPLEX_FULL
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_setDuplex(
- const UI32_T unit,
- const UI32_T port,
- const BOOL_T duplex);
-
-/* FUNCTION NAME: air_port_getDuplex
- * PURPOSE:
- * Get the duplex for a specific port.
- *
- * INPUT:
- * unit -- Device ID
- * port -- Index of port number
- *
- * OUTPUT:
- * ptr_duplex -- AIR_PORT_DUPLEX_HALF
- * AIR_PORT_DUPLEX_FULL
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_getDuplex(
- const UI32_T unit,
- const UI32_T port,
- BOOL_T *ptr_duplex);
-
-/* FUNCTION NAME: air_port_getLink
- * PURPOSE:
- * Get the physical link status for a specific port.
- *
- * INPUT:
- * unit -- Device ID
- * port -- Index of port number
- *
- * OUTPUT:
- * ptr_ps -- AIR_PORT_STATUS_T
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_getLink(
- const UI32_T unit,
- const UI32_T port,
- AIR_PORT_STATUS_T *ptr_ps);
-
-/* FUNCTION NAME: air_port_setBckPres
- * PURPOSE:
- * Set the back pressure configuration for a specific port.
- *
- * INPUT:
- * unit -- Device ID
- * port -- Index of port number
- * bckPres -- FALSE:Disable
- * TRUE: Enable
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_setBckPres(
- const UI32_T unit,
- const UI32_T port,
- const BOOL_T bckPres);
-
-/* FUNCTION NAME: air_port_getBckPres
- * PURPOSE:
- * Get the back pressure configuration for a specific port.
- *
- * INPUT:
- * unit -- Device ID
- * port -- Index of port number
- *
- * OUTPUT:
- * ptr_bckPres -- FALSE:Disable
- * TRUE: Enable
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_getBckPres(
- const UI32_T unit,
- const UI32_T port,
- BOOL_T *ptr_bckPres);
-
-/* FUNCTION NAME: air_port_setFlowCtrl
- * PURPOSE:
- * Set the flow control configuration for specific port.
- *
- * INPUT:
- * unit -- Select device ID
- * port -- Select port number (0 - 6)
- * dir -- Directions of AIR_PORT_TX or AIR_PORT_RX
- * fc_en -- TRUE: Enable select port flow control
- * FALSE:Disable select port flow control
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_setFlowCtrl(
- const UI32_T unit,
- const UI32_T port,
- const BOOL_T dir,
- const BOOL_T fc_en);
-
-/* FUNCTION NAME: air_port_getFlowCtrl
- * PURPOSE:
- * Get the flow control configuration for specific port.
- *
- * INPUT:
- * unit -- Select device ID
- * port -- Select port number (0..6)
- * dir -- AIR_PORT_TX
- * AIR_PORT_RX
- * OUTPUT:
- * ptr_fc_en -- FALSE: Port flow control disable
- * TRUE: Port flow control enable
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_getFlowCtrl(
- const UI32_T unit,
- const UI32_T port,
- const BOOL_T dir,
- BOOL_T *ptr_fc_en);
-
-/* FUNCTION NAME: air_port_setJumbo
- * PURPOSE:
- * Set accepting jumbo frmes with specificied size.
- *
- * INPUT:
- * unit -- Select device ID
- * pkt_len -- Select max packet length
- * RX_PKT_LEN_1518
- * RX_PKT_LEN_1536
- * RX_PKT_LEN_1552
- * RX_PKT_LEN_MAX_JUMBO
- * frame_len -- Select max lenght of jumbo frames
- * Range : 2 - 15
- * Units : K Bytes
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_setJumbo(
- const UI32_T unit,
- const UI32_T pkt_len,
- const UI32_T frame_len);
-
-/* FUNCTION NAME: air_port_getJumbo
- * PURPOSE:
- * Get accepting jumbo frmes with specificied size.
- *
- * INPUT:
- * unit -- Select device ID
- *
- * OUTPUT:
- * ptr_pkt_len -- Select max packet length
- * RX_PKT_LEN_1518
- * RX_PKT_LEN_1536
- * RX_PKT_LEN_1552
- * RX_PKT_LEN_MAX_JUMBO
- * ptr_frame_len -- Select max lenght of jumbo frames
- * Range : 2 - 15
- * Units : K Bytes
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_getJumbo(
- const UI32_T unit,
- UI32_T *ptr_pkt_len,
- UI32_T *ptr_frame_len);
-
-
-/* FUNCTION NAME: air_port_setPsMode
- * PURPOSE:
- * Set the power saving mode for a specific port.
- *
- * INPUT:
- * unit -- Device ID
- * port -- Index of port number
- * mode -- Bit-map:
- * AIR_PORT_PS_LINKSTATUS
- * AIR_PORT_PS_EEE
- * FALSE: Disable / TRUE: Enable
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_setPsMode(
- const UI32_T unit,
- const UI32_T port,
- const UI32_T mode);
-
-/* FUNCTION NAME: air_port_getPsMode
- * PURPOSE:
- * Get the power saving mode for a specific port.
- *
- * INPUT:
- * unit -- Device ID
- * port -- Index of port number
- * OUTPUT:
- * ptr_mode -- Bit-map:
- * AIR_PORT_PS_LINKSTATUS
- * AIR_PORT_PS_EEE
- * FALSE: Disable / TRUE: Enable
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_getPsMode(
- const UI32_T unit,
- const UI32_T port,
- UI32_T *ptr_mode);
-
-/* FUNCTION NAME: air_port_setSmtSpdDwn
- * PURPOSE:
- * Set Smart speed down feature for a specific port.
- *
- * INPUT:
- * unit -- Device ID
- * port -- Index of port number
- * state -- FALSE:Disable
- * TRUE: Enable
- * time -- AIR_PORT_SSD_2T
- * AIR_PORT_SSD_3T
- * AIR_PORT_SSD_4T
- * AIR_PORT_SSD_5T
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_setSmtSpdDwn(
- const UI32_T unit,
- const UI32_T port,
- const BOOL_T state,
- const UI32_T time);
-
-/* FUNCTION NAME: air_port_getSmtSpdDwn
- * PURPOSE:
- * Get Smart speed down feature for a specific port.
- *
- * INPUT:
- * unit -- Device ID
- * port -- Index of port number
- *
- * OUTPUT:
- * ptr_state -- FALSE:Disable
- * TRUE: Enable
- * ptr_time -- AIR_PORT_SSD_2T
- * AIR_PORT_SSD_3T
- * AIR_PORT_SSD_4T
- * AIR_PORT_SSD_5T
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_getSmtSpdDwn(
- const UI32_T unit,
- const UI32_T port,
- UI32_T *ptr_state,
- UI32_T *ptr_time);
-
-/* FUNCTION NAME: air_port_setEnable
- * PURPOSE:
- * Set powerdown state for a specific port.
- *
- * INPUT:
- * unit -- Device ID
- * port -- Index of port number
- * state -- FALSE:Disable
- * TRUE: Enable
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_setEnable(
- const UI32_T unit,
- const UI32_T port,
- const BOOL_T state);
-
-/* FUNCTION NAME: air_port_getEnable
- * PURPOSE:
- * Get powerdown state for a specific port.
- *
- * INPUT:
- * unit -- Device ID
- * port -- Index of port number
- *
- * OUTPUT:
- * ptr_state -- FALSE:Disable
- * TRUE: Enable
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_getEnable(
- const UI32_T unit,
- const UI32_T port,
- UI32_T *ptr_state);
-
-/* FUNCTION NAME: air_port_setSpTag
- * PURPOSE:
- * Set special tag state of a specific port.
- *
- * INPUT:
- * unit -- Device ID
- * port -- Index of port number
- * sptag_en -- TRUE: Enable special tag
- * FALSE: Disable special tag
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_setSpTag(
- const UI32_T unit,
- const UI32_T port,
- const BOOL_T sptag_en);
-
-/* FUNCTION NAME: air_port_getSpTag
- * PURPOSE:
- * Get special tag state of a specific port.
- *
- * INPUT:
- * unit -- Device ID
- * port -- Index of port number
- * OUTPUT:
- * ptr_sptag_en -- TRUE: Special tag enable
- * FALSE: Special tag disable
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_getSpTag(
- const UI32_T unit,
- const UI32_T port,
- BOOL_T *ptr_sptag_en);
-
-/* FUNCTION NAME: air_port_set5GBaseRModeEnable
- * PURPOSE:
- * Set the port5 5GBase-R mode enable
- *
- * INPUT:
- * unit -- Device ID
- *
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_set5GBaseRModeEn(
- const UI32_T unit);
-
-/* FUNCTION NAME: air_port_setHsgmiiModeEnable
- * PURPOSE:
- * Set the port5 HSGMII mode enable
- *
- * INPUT:
- * unit -- Device ID
- *
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_setHsgmiiModeEn(
- const UI32_T unit);
-
-/* FUNCTION NAME: air_port_setSgmiiMode
- * PURPOSE:
- * Set the port5 SGMII mode for AN or force
- *
- * INPUT:
- * unit -- Device ID
- * mode -- AIR_PORT_SGMII_MODE_AN
- * AIR_PORT_SGMII_MODE_FORCE
- * speed -- AIR_PORT_SPEED_10M: 10Mbps
- * AIR_PORT_SPEED_100M: 100Mbps
- * AIR_PORT_SPEED_1000M: 1Gbps
- *
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_setSgmiiMode(
- const UI32_T unit,
- const UI32_T mode,
- const UI32_T speed);
-
-
-/* FUNCTION NAME: air_port_setRmiiMode
- * PURPOSE:
- * Set the port5 RMII mode for 100Mbps or 10Mbps
- *
- * INPUT:
- * unit -- Device ID
- * speed -- AIR_PORT_SPEED_10M: 10Mbps
- * AIR_PORT_SPEED_100M: 100Mbps
- *
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_setRmiiMode(
- const UI32_T unit,
- const UI32_T speed);
-
-/* FUNCTION NAME: air_port_setRgmiiMode
- * PURPOSE:
- * Set the port5 RGMII mode for 1Gbps or 100Mbps or 10Mbps
- *
- * INPUT:
- * unit -- Device ID
- * speed -- AIR_PORT_SPEED_10M: 10Mbps
- * AIR_PORT_SPEED_100M: 100Mbps
- * AIR_PORT_SPEED_1000M: 1Gbps
- *
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_BAD_PARAMETER
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_port_setRgmiiMode(
- const UI32_T unit,
- const UI32_T speed);
-
-#endif /* AIR_PORT_H */
-
+/* FILE NAME: air_port.h
+ * PURPOSE:
+ * Define port function in AIR SDK.
+ *
+ * NOTES:
+ * None
+ */
+
+#ifndef AIR_PORT_H
+#define AIR_PORT_H
+
+/* INCLUDE FILE DECLARATIONS
+ */
+
+/* NAMING CONSTANT DECLARATIONS
+ */
+#define AIR_MAX_NUM_OF_UNIT (1)
+#define AIR_DST_DEFAULT_PORT (31)
+#define AIR_PORT_TX (0x00)
+#define AIR_PORT_RX (0x01)
+#define AIR_MAX_NUM_OF_PORTS (7)
+#define AIR_MAX_NUM_OF_GIGA_PORTS (5)
+#define AIR_SGMII_PORT_OFFSET_BEGIN (5)
+#define AIR_SGMII_PORT_OFFSET_END (6)
+#define AIR_ALL_PORT_BITMAP (0x7F)
+
+/* Definition of Power Saving mode */
+#define AIR_PORT_PS_LINKSTATUS (0x1 << 0)
+#define AIR_PORT_PS_EEE (0x1 << 1)
+#define AIR_PORT_PS_MASK (0x3)
+
+/* MACRO FUNCTION DECLARATIONS
+ */
+
+/* DATA TYPE DECLARATIONS
+ */
+/* AIR_PORT_BITMAP_T is the data type for physical port bitmap. */
+#define AIR_BITMAP_SIZE(bit_num) ((((bit_num) - 1) / AIR_MAX_NUM_OF_PORTS) + 1)
+#define AIR_PORT_BITMAP_SIZE AIR_BITMAP_SIZE(AIR_MAX_NUM_OF_PORTS)
+typedef UI32_T AIR_PORT_BITMAP_T[AIR_PORT_BITMAP_SIZE];
+
+#define AIR_INVALID_ID (0xFFFFFFFF)
+#define AIR_PORT_INVALID (AIR_INVALID_ID)
+
+/* Definition of SGMII mode */
+typedef enum
+{
+ AIR_PORT_SGMII_MODE_AN,
+ AIR_PORT_SGMII_MODE_FORCE,
+ AIR_PORT_SGMII_MODE_LAST
+}AIR_PORT_SGMII_MODE_T;
+
+/* Definition of port speed */
+typedef enum
+{
+ AIR_PORT_SPEED_10M,
+ AIR_PORT_SPEED_100M,
+ AIR_PORT_SPEED_1000M,
+ AIR_PORT_SPEED_2500M,
+ AIR_PORT_SPEED_LAST
+}AIR_PORT_SPEED_T;
+
+typedef enum
+{
+ AIR_PORT_DUPLEX_HALF,
+ AIR_PORT_DUPLEX_FULL,
+ AIR_PORT_DUPLEX_LAST
+}AIR_PORT_DUPLEX_T;
+
+typedef enum
+{
+ AIR_PORT_LINK_DOWN,
+ AIR_PORT_LINK_UP,
+ AIR_PORT_LINK_LAST
+}AIR_PORT_LINK_T;
+
+/* Definition of Smart speed down will occur after AN failed how many times */
+typedef enum
+{
+ AIR_PORT_SSD_2T,
+ AIR_PORT_SSD_3T,
+ AIR_PORT_SSD_4T,
+ AIR_PORT_SSD_5T,
+ AIR_PORT_SSD_LAST
+}AIR_PORT_SSD_T;
+
+typedef enum
+{
+ AIR_PORT_VLAN_MODE_PORT_MATRIX = 0, /* Port matrix mode */
+ AIR_PORT_VLAN_MODE_FALLBACK, /* Fallback mode */
+ AIR_PORT_VLAN_MODE_CHECK, /* Check mode */
+ AIR_PORT_VLAN_MODE_SECURITY, /* Security mode */
+ AIR_PORT_VLAN_MODE_LAST
+} AIR_PORT_VLAN_MODE_T;
+
+/* Definition of AN Advertisement Register */
+typedef struct AIR_AN_ADV_S
+{
+ BOOL_T advCap10HDX; /* Advertises 10 BASE-T HDX */
+ BOOL_T advCap10FDX; /* Advertises 10 BASE-T FDX */
+ BOOL_T advCap100HDX; /* Advertises 100 BASE-T HDX */
+ BOOL_T advCap100FDX; /* Advertises 100 BASE-T FDX */
+ BOOL_T advCap1000FDX; /* Advertises 1000 BASE-T FDX */
+ BOOL_T advPause; /* Advertieses Asynchronous Pause */
+}AIR_AN_ADV_T;
+
+/* Definition of Link Status of a specific port */
+typedef struct AIR_PORT_STATUS_S
+{
+ BOOL_T link;
+ BOOL_T duplex;
+ UI32_T speed;
+}AIR_PORT_STATUS_T;
+
+/* EXPORTED SUBPROGRAM SPECIFICATIONS
+ */
+/* FUNCTION NAME: air_port_setPortMatrix
+ * PURPOSE:
+ * Set port matrix from the specified device.
+ *
+ * INPUT:
+ * unit -- Unit id
+ * port -- Port id
+ * port_bitmap -- Matrix port bitmap
+ *
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_OTHERS
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_port_setPortMatrix(
+ const UI32_T unit,
+ const UI32_T port,
+ const UI32_T port_bitmap);
+
+/* FUNCTION NAME: air_port_getPortMatrix
+ * PURPOSE:
+ * Get port matrix from the specified device.
+ *
+ * INPUT:
+ * unit -- Unit id
+ * port -- Port id
+ *
+ * OUTPUT:
+ * p_port_bitmap -- Matrix port bitmap
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_OTHERS
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_port_getPortMatrix(
+ const UI32_T unit,
+ const UI32_T port,
+ UI32_T *p_port_bitmap);
+
+/* FUNCTION NAME: air_port_setVlanMode
+ * PURPOSE:
+ * Set port-based vlan mechanism from the specified device.
+ *
+ * INPUT:
+ * unit -- Unit id
+ * port -- Port id
+ * mode -- Port vlan mode
+ *
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_OTHERS
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_port_setVlanMode(
+ const UI32_T unit,
+ const UI32_T port,
+ const AIR_PORT_VLAN_MODE_T mode);
+
+/* FUNCTION NAME: air_port_getVlanMode
+ * PURPOSE:
+ * Get port-based vlan mechanism from the specified device.
+ *
+ * INPUT:
+ * unit -- Unit id
+ * port -- Port id
+ *
+ * OUTPUT:
+ * p_mode -- Port vlan mode
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_OTHERS
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_port_getVlanMode(
+ const UI32_T unit,
+ const UI32_T port,
+ AIR_PORT_VLAN_MODE_T *p_mode);
+
+/* FUNCTION NAME: air_port_setAnMode
+ * PURPOSE:
+ * Set the auto-negotiation mode for a specific port.(Auto or Forced)
+ *
+ * INPUT:
+ * unit -- Device ID
+ * port -- Index of port number
+ * state -- FALSE:Disable
+ * TRUE: Enable
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_setAnMode(
+ const UI32_T unit,
+ const UI32_T port,
+ const BOOL_T state);
+
+/* FUNCTION NAME: air_port_getAnMode
+ * PURPOSE:
+ * Get the auto-negotiation mode for a specific port.
+ *
+ * INPUT:
+ * unit -- Device ID
+ * port -- Index of port number
+ *
+ * OUTPUT:
+ * state -- FALSE:Disable
+ * TRUE: Enable
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_getAnMode(
+ const UI32_T unit,
+ const UI32_T port,
+ BOOL_T *ptr_state);
+
+/* FUNCTION NAME: air_port_setLocalAdvAbility
+ * PURPOSE:
+ * Set the auto-negotiation advertisement for a
+ * specific port.
+ *
+ * INPUT:
+ * unit -- Device ID
+ * port -- Index of port number
+ * adv -- AN advertisement setting
+ *
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_setLocalAdvAbility(
+ const UI32_T unit,
+ const UI32_T port,
+ const AIR_AN_ADV_T adv);
+
+/* FUNCTION NAME: air_port_getLocalAdvAbility
+ * PURPOSE:
+ * Get the auto-negotiation advertisement for a
+ * specific port.
+ *
+ * INPUT:
+ * unit -- Device ID
+ * port -- Index of port number
+ *
+ * OUTPUT:
+ * ptr_adv -- AN advertisement setting
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_getLocalAdvAbility(
+ const UI32_T unit,
+ const UI32_T port,
+ AIR_AN_ADV_T *ptr_adv);
+
+/* FUNCTION NAME: air_port_getRemoteAdvAbility
+ * PURPOSE:
+ * Get the auto-negotiation remote advertisement for a
+ * specific port.
+ *
+ * INPUT:
+ * unit -- Device ID
+ * port -- Index of port number
+ *
+ * OUTPUT:
+ * ptr_lp_adv -- AN advertisement of link partner
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_getRemoteAdvAbility(
+ const UI32_T unit,
+ const UI32_T port,
+ AIR_AN_ADV_T *ptr_lp_adv);
+
+/* FUNCTION NAME: air_port_setSpeed
+ * PURPOSE:
+ * Set the speed for a specific port.
+ * This setting is used on force mode only.
+ *
+ * INPUT:
+ * unit -- Device ID
+ * port -- Index of port number
+ * speed -- AIR_PORT_SPEED_10M: 10Mbps
+ * AIR_PORT_SPEED_100M: 100Mbps
+ * AIR_PORT_SPEED_1000M:1Gbps
+ * AIR_PORT_SPEED_2500M:2.5Gbps (Port5, Port6)
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_setSpeed(
+ const UI32_T unit,
+ const UI32_T port,
+ const UI32_T speed);
+
+/* FUNCTION NAME: air_port_getSpeed
+ * PURPOSE:
+ * Get the speed for a specific port.
+ *
+ * INPUT:
+ * unit -- Device ID
+ * port -- Index of port number
+ *
+ * OUTPUT:
+ * ptr_speed -- AIR_PORT_SPEED_10M: 10Mbps
+ * AIR_PORT_SPEED_100M: 100Mbps
+ * AIR_PORT_SPEED_1000M:1Gbps
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_getSpeed(
+ const UI32_T unit,
+ const UI32_T port,
+ UI32_T *ptr_speed);
+
+/* FUNCTION NAME: air_port_setDuplex
+ * PURPOSE:
+ * Get the duplex for a specific port.
+ * This setting is used on force mode only.
+ *
+ * INPUT:
+ * unit -- Device ID
+ * port -- Index of port number
+ * duplex -- AIR_PORT_DUPLEX_HALF
+ * AIR_PORT_DUPLEX_FULL
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_setDuplex(
+ const UI32_T unit,
+ const UI32_T port,
+ const BOOL_T duplex);
+
+/* FUNCTION NAME: air_port_getDuplex
+ * PURPOSE:
+ * Get the duplex for a specific port.
+ *
+ * INPUT:
+ * unit -- Device ID
+ * port -- Index of port number
+ *
+ * OUTPUT:
+ * ptr_duplex -- AIR_PORT_DUPLEX_HALF
+ * AIR_PORT_DUPLEX_FULL
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_getDuplex(
+ const UI32_T unit,
+ const UI32_T port,
+ BOOL_T *ptr_duplex);
+
+/* FUNCTION NAME: air_port_getLink
+ * PURPOSE:
+ * Get the physical link status for a specific port.
+ *
+ * INPUT:
+ * unit -- Device ID
+ * port -- Index of port number
+ *
+ * OUTPUT:
+ * ptr_ps -- AIR_PORT_STATUS_T
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_getLink(
+ const UI32_T unit,
+ const UI32_T port,
+ AIR_PORT_STATUS_T *ptr_ps);
+
+/* FUNCTION NAME: air_port_setBckPres
+ * PURPOSE:
+ * Set the back pressure configuration for a specific port.
+ *
+ * INPUT:
+ * unit -- Device ID
+ * port -- Index of port number
+ * bckPres -- FALSE:Disable
+ * TRUE: Enable
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_setBckPres(
+ const UI32_T unit,
+ const UI32_T port,
+ const BOOL_T bckPres);
+
+/* FUNCTION NAME: air_port_getBckPres
+ * PURPOSE:
+ * Get the back pressure configuration for a specific port.
+ *
+ * INPUT:
+ * unit -- Device ID
+ * port -- Index of port number
+ *
+ * OUTPUT:
+ * ptr_bckPres -- FALSE:Disable
+ * TRUE: Enable
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_getBckPres(
+ const UI32_T unit,
+ const UI32_T port,
+ BOOL_T *ptr_bckPres);
+
+/* FUNCTION NAME: air_port_setFlowCtrl
+ * PURPOSE:
+ * Set the flow control configuration for specific port.
+ *
+ * INPUT:
+ * unit -- Select device ID
+ * port -- Select port number (0 - 6)
+ * dir -- Directions of AIR_PORT_TX or AIR_PORT_RX
+ * fc_en -- TRUE: Enable select port flow control
+ * FALSE:Disable select port flow control
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_setFlowCtrl(
+ const UI32_T unit,
+ const UI32_T port,
+ const BOOL_T dir,
+ const BOOL_T fc_en);
+
+/* FUNCTION NAME: air_port_getFlowCtrl
+ * PURPOSE:
+ * Get the flow control configuration for specific port.
+ *
+ * INPUT:
+ * unit -- Select device ID
+ * port -- Select port number (0..6)
+ * dir -- AIR_PORT_TX
+ * AIR_PORT_RX
+ * OUTPUT:
+ * ptr_fc_en -- FALSE: Port flow control disable
+ * TRUE: Port flow control enable
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_getFlowCtrl(
+ const UI32_T unit,
+ const UI32_T port,
+ const BOOL_T dir,
+ BOOL_T *ptr_fc_en);
+
+/* FUNCTION NAME: air_port_setJumbo
+ * PURPOSE:
+ * Set accepting jumbo frmes with specificied size.
+ *
+ * INPUT:
+ * unit -- Select device ID
+ * pkt_len -- Select max packet length
+ * RX_PKT_LEN_1518
+ * RX_PKT_LEN_1536
+ * RX_PKT_LEN_1552
+ * RX_PKT_LEN_MAX_JUMBO
+ * frame_len -- Select max lenght of jumbo frames
+ * Range : 2 - 15
+ * Units : K Bytes
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_setJumbo(
+ const UI32_T unit,
+ const UI32_T pkt_len,
+ const UI32_T frame_len);
+
+/* FUNCTION NAME: air_port_getJumbo
+ * PURPOSE:
+ * Get accepting jumbo frmes with specificied size.
+ *
+ * INPUT:
+ * unit -- Select device ID
+ *
+ * OUTPUT:
+ * ptr_pkt_len -- Select max packet length
+ * RX_PKT_LEN_1518
+ * RX_PKT_LEN_1536
+ * RX_PKT_LEN_1552
+ * RX_PKT_LEN_MAX_JUMBO
+ * ptr_frame_len -- Select max lenght of jumbo frames
+ * Range : 2 - 15
+ * Units : K Bytes
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_getJumbo(
+ const UI32_T unit,
+ UI32_T *ptr_pkt_len,
+ UI32_T *ptr_frame_len);
+
+
+/* FUNCTION NAME: air_port_setPsMode
+ * PURPOSE:
+ * Set the power saving mode for a specific port.
+ *
+ * INPUT:
+ * unit -- Device ID
+ * port -- Index of port number
+ * mode -- Bit-map:
+ * AIR_PORT_PS_LINKSTATUS
+ * AIR_PORT_PS_EEE
+ * FALSE: Disable / TRUE: Enable
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_setPsMode(
+ const UI32_T unit,
+ const UI32_T port,
+ const UI32_T mode);
+
+/* FUNCTION NAME: air_port_getPsMode
+ * PURPOSE:
+ * Get the power saving mode for a specific port.
+ *
+ * INPUT:
+ * unit -- Device ID
+ * port -- Index of port number
+ * OUTPUT:
+ * ptr_mode -- Bit-map:
+ * AIR_PORT_PS_LINKSTATUS
+ * AIR_PORT_PS_EEE
+ * FALSE: Disable / TRUE: Enable
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_getPsMode(
+ const UI32_T unit,
+ const UI32_T port,
+ UI32_T *ptr_mode);
+
+/* FUNCTION NAME: air_port_setSmtSpdDwn
+ * PURPOSE:
+ * Set Smart speed down feature for a specific port.
+ *
+ * INPUT:
+ * unit -- Device ID
+ * port -- Index of port number
+ * state -- FALSE:Disable
+ * TRUE: Enable
+ * time -- AIR_PORT_SSD_2T
+ * AIR_PORT_SSD_3T
+ * AIR_PORT_SSD_4T
+ * AIR_PORT_SSD_5T
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_setSmtSpdDwn(
+ const UI32_T unit,
+ const UI32_T port,
+ const BOOL_T state,
+ const UI32_T time);
+
+/* FUNCTION NAME: air_port_getSmtSpdDwn
+ * PURPOSE:
+ * Get Smart speed down feature for a specific port.
+ *
+ * INPUT:
+ * unit -- Device ID
+ * port -- Index of port number
+ *
+ * OUTPUT:
+ * ptr_state -- FALSE:Disable
+ * TRUE: Enable
+ * ptr_time -- AIR_PORT_SSD_2T
+ * AIR_PORT_SSD_3T
+ * AIR_PORT_SSD_4T
+ * AIR_PORT_SSD_5T
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_getSmtSpdDwn(
+ const UI32_T unit,
+ const UI32_T port,
+ UI32_T *ptr_state,
+ UI32_T *ptr_time);
+
+/* FUNCTION NAME: air_port_setEnable
+ * PURPOSE:
+ * Set powerdown state for a specific port.
+ *
+ * INPUT:
+ * unit -- Device ID
+ * port -- Index of port number
+ * state -- FALSE:Disable
+ * TRUE: Enable
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_setEnable(
+ const UI32_T unit,
+ const UI32_T port,
+ const BOOL_T state);
+
+/* FUNCTION NAME: air_port_getEnable
+ * PURPOSE:
+ * Get powerdown state for a specific port.
+ *
+ * INPUT:
+ * unit -- Device ID
+ * port -- Index of port number
+ *
+ * OUTPUT:
+ * ptr_state -- FALSE:Disable
+ * TRUE: Enable
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_getEnable(
+ const UI32_T unit,
+ const UI32_T port,
+ UI32_T *ptr_state);
+
+/* FUNCTION NAME: air_port_setSpTag
+ * PURPOSE:
+ * Set special tag state of a specific port.
+ *
+ * INPUT:
+ * unit -- Device ID
+ * port -- Index of port number
+ * sptag_en -- TRUE: Enable special tag
+ * FALSE: Disable special tag
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_setSpTag(
+ const UI32_T unit,
+ const UI32_T port,
+ const BOOL_T sptag_en);
+
+/* FUNCTION NAME: air_port_getSpTag
+ * PURPOSE:
+ * Get special tag state of a specific port.
+ *
+ * INPUT:
+ * unit -- Device ID
+ * port -- Index of port number
+ * OUTPUT:
+ * ptr_sptag_en -- TRUE: Special tag enable
+ * FALSE: Special tag disable
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_getSpTag(
+ const UI32_T unit,
+ const UI32_T port,
+ BOOL_T *ptr_sptag_en);
+
+/* FUNCTION NAME: air_port_set5GBaseRModeEnable
+ * PURPOSE:
+ * Set the port5 5GBase-R mode enable
+ *
+ * INPUT:
+ * unit -- Device ID
+ *
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_set5GBaseRModeEn(
+ const UI32_T unit);
+
+/* FUNCTION NAME: air_port_setHsgmiiModeEnable
+ * PURPOSE:
+ * Set the port5 HSGMII mode enable
+ *
+ * INPUT:
+ * unit -- Device ID
+ *
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_setHsgmiiModeEn(
+ const UI32_T unit);
+
+/* FUNCTION NAME: air_port_setSgmiiMode
+ * PURPOSE:
+ * Set the port5 SGMII mode for AN or force
+ *
+ * INPUT:
+ * unit -- Device ID
+ * mode -- AIR_PORT_SGMII_MODE_AN
+ * AIR_PORT_SGMII_MODE_FORCE
+ * speed -- AIR_PORT_SPEED_10M: 10Mbps
+ * AIR_PORT_SPEED_100M: 100Mbps
+ * AIR_PORT_SPEED_1000M: 1Gbps
+ *
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_setSgmiiMode(
+ const UI32_T unit,
+ const UI32_T mode,
+ const UI32_T speed);
+
+
+/* FUNCTION NAME: air_port_setRmiiMode
+ * PURPOSE:
+ * Set the port5 RMII mode for 100Mbps or 10Mbps
+ *
+ * INPUT:
+ * unit -- Device ID
+ * speed -- AIR_PORT_SPEED_10M: 10Mbps
+ * AIR_PORT_SPEED_100M: 100Mbps
+ *
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_setRmiiMode(
+ const UI32_T unit,
+ const UI32_T speed);
+
+/* FUNCTION NAME: air_port_setRgmiiMode
+ * PURPOSE:
+ * Set the port5 RGMII mode for 1Gbps or 100Mbps or 10Mbps
+ *
+ * INPUT:
+ * unit -- Device ID
+ * speed -- AIR_PORT_SPEED_10M: 10Mbps
+ * AIR_PORT_SPEED_100M: 100Mbps
+ * AIR_PORT_SPEED_1000M: 1Gbps
+ *
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_BAD_PARAMETER
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_port_setRgmiiMode(
+ const UI32_T unit,
+ const UI32_T speed);
+
+#endif /* AIR_PORT_H */
+
diff --git a/feed/app/switch/src/an8855_sdk/api/inc/air_ver.h b/feed/app/switch/src/an8855_sdk/api/inc/air_ver.h
index 0681b6c..d702769 100644
--- a/feed/app/switch/src/an8855_sdk/api/inc/air_ver.h
+++ b/feed/app/switch/src/an8855_sdk/api/inc/air_ver.h
@@ -1,29 +1,29 @@
-/* FILE NAME: air_ver.h
- * PURPOSE:
- * Define the version for AIR SDK.
- *
- * NOTES:
- * None
- */
-
-#ifndef AIR_VER_H
-#define AIR_VER_H
-
-/* INCLUDE FILE DECLARATIONS
- */
-
-/* NAMING CONSTANT DECLARATIONS
- */
-#define AIR_VER_SDK "v1.0.1"
-
-/* MACRO FUNCTION DECLARATIONS
- */
-
-/* DATA TYPE DECLARATIONS
- */
-
-/* EXPORTED SUBPROGRAM SPECIFICATIONS
- */
-
-#endif /* AIR_VER_H */
-
+/* FILE NAME: air_ver.h
+ * PURPOSE:
+ * Define the version for AIR SDK.
+ *
+ * NOTES:
+ * None
+ */
+
+#ifndef AIR_VER_H
+#define AIR_VER_H
+
+/* INCLUDE FILE DECLARATIONS
+ */
+
+/* NAMING CONSTANT DECLARATIONS
+ */
+#define AIR_VER_SDK "v1.0.1"
+
+/* MACRO FUNCTION DECLARATIONS
+ */
+
+/* DATA TYPE DECLARATIONS
+ */
+
+/* EXPORTED SUBPROGRAM SPECIFICATIONS
+ */
+
+#endif /* AIR_VER_H */
+
diff --git a/feed/app/switch/src/an8855_sdk/api/inc/air_vlan.h b/feed/app/switch/src/an8855_sdk/api/inc/air_vlan.h
index 1ae6237..3db12e2 100644
--- a/feed/app/switch/src/an8855_sdk/api/inc/air_vlan.h
+++ b/feed/app/switch/src/an8855_sdk/api/inc/air_vlan.h
@@ -1,977 +1,977 @@
-/* FILE NAME: air_vlan.h
- * PURPOSE:
- * Define the vlan functions in AIR SDK.
- * NOTES:
- */
-
-#ifndef AIR_VLAN_H
-#define AIR_VLAN_H
-
-/* INCLUDE FILE DECLARATIONS
- */
-
-/* NAMING CONSTANT DECLARATIONS
- */
-#define AIR_VLAN_ID_MIN 0
-#define AIR_VLAN_ID_MAX 4095
-#define AIR_DEFAULT_VLAN_ID 1
-
-#define AIR_FILTER_ID_MAX 7
-
-/* MACRO FUNCTION DECLARATIONS
- */
-
-/* DATA TYPE DECLARATIONS
- */
-typedef enum
-{
- AIR_VLAN_PORT_EGS_TAG_CTL_TYPE_UNTAGGED = 0,
- AIR_VLAN_PORT_EGS_TAG_CTL_TYPE_TAGGED = 2,
- AIR_VLAN_PORT_EGS_TAG_CTL_TYPE_LAST,
-} AIR_VLAN_PORT_EGS_TAG_CTL_TYPE_T;
-
-typedef enum
-{
- AIR_PORT_EGS_TAG_ATTR_UNTAGGED = 0,
- AIR_PORT_EGS_TAG_ATTR_SWAP,
- AIR_PORT_EGS_TAG_ATTR_TAGGED,
- AIR_PORT_EGS_TAG_ATTR_STACK,
- AIR_PORT_EGS_TAG_ATTR_LAST
-} AIR_PORT_EGS_TAG_ATTR_T;
-
-typedef enum
-{
- AIR_VLAN_ACCEPT_FRAME_TYPE_ALL = 0, /* untagged, priority-tagged and tagged */
- AIR_VLAN_ACCEPT_FRAME_TYPE_TAG_ONLY, /* tagged */
- AIR_VLAN_ACCEPT_FRAME_TYPE_UNTAG_ONLY, /* untagged and priority-tagged */
- AIR_VLAN_ACCEPT_FRAME_TYPE_RESERVED, /* reserved */
- AIR_VLAN_ACCEPT_FRAME_TYPE_LAST
-} AIR_VLAN_ACCEPT_FRAME_TYPE_T;
-
-typedef enum
-{
- AIR_LEAKY_PKT_TYPE_UNICAST = 0, /* unicast pkt */
- AIR_LEAKY_PKT_TYPE_MULTICAST, /* multicast pkt */
- AIR_LEAKY_PKT_TYPE_BROADCAST, /* broadcast pkt */
- AIR_LEAKY_PKT_TYPE_LAST
-} AIR_LEAKY_PKT_TYPE_T;
-
-typedef enum
-{
- AIR_VLAN_PORT_ATTR_USER_PORT = 0, /* user port */
- AIR_VLAN_PORT_ATTR_STACK_PORT, /* stack port */
- AIR_VLAN_PORT_ATTR_TRANSLATION_PORT, /* translation port */
- AIR_VLAN_PORT_ATTR_TRANSPARENT_PORT, /* transparent port */
- AIR_VLAN_PORT_ATTR_LAST
-} AIR_VLAN_PORT_ATTR_T;
-
-typedef enum
-{
- AIR_IGR_PORT_EG_TAG_ATTR_DISABLE = 0,
- AIR_IGR_PORT_EG_TAG_ATTR_CONSISTENT,
- AIR_IGR_PORT_EG_TAG_ATTR_UNTAGGED = 4,
- AIR_IGR_PORT_EG_TAG_ATTR_SWAP,
- AIR_IGR_PORT_EG_TAG_ATTR_TAGGED,
- AIR_IGR_PORT_EG_TAG_ATTR_STACK,
- AIR_IGR_PORT_EG_TAG_ATTR_LAST
-} AIR_IGR_PORT_EG_TAG_ATTR_T;
-
-typedef union AIR_VLAN_ENTRY_S
-{
- UI8_T valid : 1;
- struct
- {
- UI32_T vlan_table0;
- UI32_T vlan_table1;
- } vlan_table;
- struct
- {
- UI64_T valid : 1;
- UI64_T fid : 4;
- UI64_T ivl : 1;
- UI64_T copy_pri : 1;
- UI64_T user_pri : 3;
- UI64_T eg_ctrl_en : 1;
- UI64_T eg_con : 1;
- UI64_T eg_ctrl : 14;
- UI64_T port_mem : 7;
- UI64_T port_stag : 1;
- UI64_T stag : 12;
- UI64_T unm_vlan_drop : 1;
- } vlan_entry_format;
-} AIR_VLAN_ENTRY_T;
-
-typedef union AIR_VLAN_ENTRY_ATTR_S
-{
- UI8_T valid : 1;
- struct
- {
- UI32_T vlan_table0;
- UI32_T vlan_table1;
- UI32_T vlan_table2;
- UI32_T vlan_table3;
- UI32_T vlan_table4;
- } vlan_table;
- struct
- {
- UI64_T valid : 1;
- UI64_T fid : 4;
- UI64_T ivl : 1;
- UI64_T copy_pri : 1;
- UI64_T user_pri : 3;
- UI64_T eg_ctrl_en : 1;
- UI64_T eg_con : 1;
- UI64_T eg_ctrl : 14;
- UI64_T port_mem : 7;
- UI64_T port_stag : 1;
- UI64_T stag : 12;
- UI64_T unm_vlan_drop : 1;
- } vlan_entry_format;
-#if 0
- struct
- {
- UI64_T valid : 1;
- UI64_T type : 3;
- UI64_T mac_addr : 48;
- UI64_T mac_mask_len : 6;
- UI64_T priority : 3;
- UI64_T :0;
- UI64_T vid : 12;
- } mac_based_vlan_entry_format;
- struct
- {
- UI64_T valid : 1;
- UI64_T type : 3;
- UI64_T check_field : 36;
- UI64_T :0;
- UI64_T check_field_mask : 36;
- UI64_T untagged_packet : 1;
- UI64_T vlan_priority : 3;
- UI64_T svid : 12;
- } qinq_based_vlan_entry_format;
- struct
- {
- UI64_T valid : 1;
- UI64_T type : 3;
- UI64_T ipv4 : 32;
- UI64_T :0;
- UI64_T subnetmask : 32;
- UI64_T priority : 3;
- UI64_T cvid : 12;
- } ipv4_based_vlan_entry_format;
- struct
- {
- UI64_T valid : 1;
- UI64_T :0;
- UI64_T ipv6_high : 64;
- UI64_T ipv6_low : 64;
- UI64_T subnetmask : 8;
- UI64_T priority : 3;
- UI64_T cvid : 12;
- } ipv6_based_vlan_entry_format;
-#endif
-} AIR_VLAN_ENTRY_ATTR_T;
-
-void
-_air_vlan_readEntry(
- const UI32_T unit,
- const UI16_T vid,
- AIR_VLAN_ENTRY_T* vlan_entry);
-
-void
-_air_vlan_writeEntry(
- const UI32_T unit,
- const UI16_T vid,
- AIR_VLAN_ENTRY_T* vlan_entry);
-
-void
-_air_untagged_vlan_readEntry(
- const UI32_T unit,
- const UI16_T vid,
- AIR_VLAN_ENTRY_ATTR_T* vlan_entry);
-
-void
-_air_untagged_vlan_writeEntry(
- const UI32_T unit,
- const UI16_T vid,
- AIR_VLAN_ENTRY_ATTR_T* vlan_entry);
-
-/* EXPORTED SUBPROGRAM SPECIFICATIONS
- */
-/* FUNCTION NAME: air_vlan_create
- * PURPOSE:
- * Create the vlan in the specified device.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * p_attr -- vlan attr
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Vlan creation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_create(
- const UI32_T unit,
- const UI16_T vid,
- AIR_VLAN_ENTRY_ATTR_T *p_attr);
-
-/* FUNCTION NAME: air_vlan_destroy
- * PURPOSE:
- * Destroy the vlan in the specified device.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Vlan destroy failed.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_destroy(
- const UI32_T unit,
- const UI16_T vid);
-
-/* FUNCTION NAME: air_vlan_destroyAll
- * PURPOSE:
- * Destroy the vlan in the specified device.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Vlan destroy failed.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_destroyAll(
- const UI32_T unit,
- const UI32_T keep_and_restore_default_vlan);
-
-/* FUNCTION NAME: air_vlan_reset
- * PURPOSE:
- * Destroy the vlan in the specified device.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully reset the data.
- * AIR_E_OTHERS -- Vlan reset failed.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_reset(
- const UI32_T unit,
- const UI16_T vid);
-
-/* FUNCTION NAME: air_vlan_setFid
- * PURPOSE:
- * Set the filter id of the vlan to the specified device.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * fid -- filter id
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setFid(
- const UI32_T unit,
- const UI16_T vid,
- const UI8_T fid);
-
-/* FUNCTION NAME: air_vlan_getFid
- * PURPOSE:
- * Get the filter id of the vlan from the specified device.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id to be created
- * OUTPUT:
- * p_fid -- filter id
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getFid(
- const UI32_T unit,
- const UI16_T vid,
- UI8_T *p_fid);
-
-/* FUNCTION NAME: air_vlan_addMemberPort
- * PURPOSE:
- * Add one vlan member to the specified device.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * port -- port id
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_addMemberPort(
- const UI32_T unit,
- const UI16_T vid,
- const UI32_T port);
-
-/* FUNCTION NAME: air_vlan_delMemberPort
- * PURPOSE:
- * Delete one vlan member from the specified device.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * port -- port id
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_delMemberPort(
- const UI32_T unit,
- const UI16_T vid,
- const UI32_T port);
-
-/* FUNCTION NAME: air_vlan_setMemberPort
- * PURPOSE:
- * Replace the vlan members in the specified device.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * port_bitmap -- member port bitmap
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setMemberPort(
- const UI32_T unit,
- const UI16_T vid,
- const UI32_T port_bitmap);
-
-/* FUNCTION NAME: air_vlan_getMemberPort
- * PURPOSE:
- * Get the vlan members from the specified device.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * OUTPUT:
- * port_bitmap -- member port bitmap
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getMemberPort(
- const UI32_T unit,
- const UI16_T vid,
- UI32_T *p_port_bitmap);
-
-/* FUNCTION NAME: air_vlan_setIVL
- * PURPOSE:
- * Set L2 lookup mode IVL/SVL for L2 traffic.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * enable -- enable IVL
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setIVL(
- const UI32_T unit,
- const UI16_T vid,
- const BOOL_T enable);
-
-/* FUNCTION NAME: air_vlan_getIVL
- * PURPOSE:
- * Get L2 lookup mode IVL/SVL for L2 traffic.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * OUTPUT:
- * p_enable -- enable IVL
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getIVL(
- const UI32_T unit,
- const UI16_T vid,
- BOOL_T *p_enable);
-
-/* FUNCTION NAME: air_vlan_setPortAcceptFrameType
- * PURPOSE:
- * Set vlan accept frame type of the port from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * type -- accept frame type
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setPortAcceptFrameType(
- const UI32_T unit,
- const UI32_T port,
- const AIR_VLAN_ACCEPT_FRAME_TYPE_T type);
-
-/* FUNCTION NAME: air_vlan_getPortAcceptFrameType
- * PURPOSE:
- * Get vlan accept frame type of the port from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * OUTPUT:
- * p_type -- accept frame type
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getPortAcceptFrameType(
- const UI32_T unit,
- const UI32_T port,
- AIR_VLAN_ACCEPT_FRAME_TYPE_T *p_type);
-
-/* FUNCTION NAME: air_vlan_setPortLeakyVlanEnable
- * PURPOSE:
- * Set leaky vlan enable of the port from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * pkt_type -- packet type
- * enable -- enable leaky
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setPortLeakyVlanEnable(
- const UI32_T unit,
- const UI32_T port,
- AIR_LEAKY_PKT_TYPE_T pkt_type,
- const BOOL_T enable);
-
-/* FUNCTION NAME: air_vlan_getPortLeakyVlanEnable
- * PURPOSE:
- * Get leaky vlan enable of the port from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * pkt_type -- packet type
- * OUTPUT:
- * p_enable -- enable leaky
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getPortLeakyVlanEnable(
- const UI32_T unit,
- const UI32_T port,
- AIR_LEAKY_PKT_TYPE_T pkt_type,
- BOOL_T *p_enable);
-
-/* FUNCTION NAME: air_vlan_setPortAttr
- * PURPOSE:
- * Set vlan port attribute from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * attr -- vlan port attr
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setPortAttr(
- const UI32_T unit,
- const UI32_T port,
- const AIR_VLAN_PORT_ATTR_T attr);
-
-/* FUNCTION NAME: air_vlan_getPortAttr
- * PURPOSE:
- * Get vlan port attribute from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * OUTPUT:
- * p_attr -- vlan port attr
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getPortAttr(
- const UI32_T unit,
- const UI32_T port,
- AIR_VLAN_PORT_ATTR_T *p_attr);
-
-/* FUNCTION NAME: air_vlan_setIgrPortTagAttr
- * PURPOSE:
- * Set vlan incoming port egress tag attribute from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * attr -- egress tag attr
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setIgrPortTagAttr(
- const UI32_T unit,
- const UI32_T port,
- const AIR_IGR_PORT_EG_TAG_ATTR_T attr);
-
-/* FUNCTION NAME: air_vlan_getIgrPortTagAttr
- * PURPOSE:
- * Get vlan incoming port egress tag attribute from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * OUTPUT:
- * p_attr -- egress tag attr
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getIgrPortTagAttr(
- const UI32_T unit,
- const UI32_T port,
- AIR_IGR_PORT_EG_TAG_ATTR_T *p_attr);
-
-/* FUNCTION NAME: air_vlan_setPortEgsTagAttr
- * PURPOSE:
- * Set vlan port egress tag attribute from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * attr -- egress tag attr
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setPortEgsTagAttr(
- const UI32_T unit,
- const UI32_T port,
- const AIR_PORT_EGS_TAG_ATTR_T attr);
-
-/* FUNCTION NAME: air_vlan_getPortEgsTagAttr
- * PURPOSE:
- * Get vlan port egress tag attribute from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * OUTPUT:
- * p_attr -- egress tag attr
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getPortEgsTagAttr(
- const UI32_T unit,
- const UI32_T port,
- AIR_PORT_EGS_TAG_ATTR_T *p_attr);
-
-/* FUNCTION NAME: air_vlan_setPortOuterTPID
- * PURPOSE:
- * Set stack tag TPID of the port from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * tpid -- TPID
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setPortOuterTPID(
- const UI32_T unit,
- const UI32_T port,
- const UI16_T tpid);
-
-/* FUNCTION NAME: air_vlan_getPortOuterTPID
- * PURPOSE:
- * Get stack tag TPID of the port from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * OUTPUT:
- * p_tpid -- TPID
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getPortOuterTPID(
- const UI32_T unit,
- const UI32_T port,
- UI16_T *p_tpid);
-
-/* FUNCTION NAME: air_vlan_setPortPVID
- * PURPOSE:
- * Set PVID of the port from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * pvid -- native vlan id
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setPortPVID(
- const UI32_T unit,
- const UI32_T port,
- const UI16_T pvid);
-
-/* FUNCTION NAME: air_vlan_getPortPVID
- * PURPOSE:
- * Get PVID of the port from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * OUTPUT:
- * p_pvid -- native vlan id
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getPortPVID(
- const UI32_T unit,
- const UI32_T port,
- UI16_T *p_pvid);
-
-/* FUNCTION NAME: air_vlan_setServiceTag
- * PURPOSE:
- * Set Vlan service tag.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * stag -- service stag
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setServiceTag(
- const UI32_T unit,
- const UI16_T vid,
- const UI16_T stag);
-
-/* FUNCTION NAME: air_vlan_getServiceTag
- * PURPOSE:
- * Get Vlan service tag.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * OUTPUT:
- * p_stag -- service stag
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getServiceTag(
- const UI32_T unit,
- const UI16_T vid,
- UI16_T *p_stag);
-
-/* FUNCTION NAME: air_vlan_setEgsTagCtlEnable
- * PURPOSE:
- * Set per vlan egress tag control.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * enable -- enable vlan egress tag control
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setEgsTagCtlEnable(
- const UI32_T unit,
- const UI16_T vid,
- const BOOL_T enable);
-
-/* FUNCTION NAME: air_vlan_getEgsTagCtlEnable
- * PURPOSE:
- * Get per vlan egress tag control.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * OUTPUT:
- * p_enable -- enable vlan egress tag control
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getEgsTagCtlEnable(
- const UI32_T unit,
- const UI16_T vid,
- BOOL_T *p_enable);
-
-/* FUNCTION NAME: air_vlan_setEgsTagConsistent
- * PURPOSE:
- * Set per vlan egress tag consistent.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * enable -- enable vlan egress tag consistent
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setEgsTagConsistent(
- const UI32_T unit,
- const UI16_T vid,
- const BOOL_T enable);
-
-/* FUNCTION NAME: air_vlan_getEgsTagConsistent
- * PURPOSE:
- * Get per vlan egress tag consistent.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * OUTPUT:
- * p_enable -- enable vlan egress tag consistent
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getEgsTagConsistent(
- const UI32_T unit,
- const UI16_T vid,
- BOOL_T *p_enable);
-
-/* FUNCTION NAME: air_vlan_setPortBasedStag
- * PURPOSE:
- * Set vlan port based stag enable.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * enable -- vlan port based stag enable
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setPortBasedStag(
- const UI32_T unit,
- const UI16_T vid,
- const BOOL_T enable);
-
-/* FUNCTION NAME: air_vlan_getPortBasedStag
- * PURPOSE:
- * Get vlan port based stag enable.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * OUTPUT:
- * p_enable -- vlan port based stag enable
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getPortBasedStag(
- const UI32_T unit,
- const UI16_T vid,
- BOOL_T *p_enable);
-
-/* FUNCTION NAME: air_vlan_setPortEgsTagCtl
- * PURPOSE:
- * Set vlan port egress tag control.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * port -- port id
- * tag_ctl -- egress tag control
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setPortEgsTagCtl(
- const UI32_T unit,
- const UI16_T vid,
- const UI32_T port,
- const AIR_VLAN_PORT_EGS_TAG_CTL_TYPE_T tag_ctl);
-
-/* FUNCTION NAME: air_vlan_getPortEgsTagCtl
- * PURPOSE:
- * Get vlan port egress tag control.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * OUTPUT:
- * p_tag_ctl -- egress tag control
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getPortEgsTagCtl(
- const UI32_T unit,
- const UI16_T vid,
- const UI32_T port,
- AIR_VLAN_PORT_EGS_TAG_CTL_TYPE_T *ptr_tag_ctl);
-
-#endif /* AIR_VLAN_H */
-
+/* FILE NAME: air_vlan.h
+ * PURPOSE:
+ * Define the vlan functions in AIR SDK.
+ * NOTES:
+ */
+
+#ifndef AIR_VLAN_H
+#define AIR_VLAN_H
+
+/* INCLUDE FILE DECLARATIONS
+ */
+
+/* NAMING CONSTANT DECLARATIONS
+ */
+#define AIR_VLAN_ID_MIN 0
+#define AIR_VLAN_ID_MAX 4095
+#define AIR_DEFAULT_VLAN_ID 1
+
+#define AIR_FILTER_ID_MAX 7
+
+/* MACRO FUNCTION DECLARATIONS
+ */
+
+/* DATA TYPE DECLARATIONS
+ */
+typedef enum
+{
+ AIR_VLAN_PORT_EGS_TAG_CTL_TYPE_UNTAGGED = 0,
+ AIR_VLAN_PORT_EGS_TAG_CTL_TYPE_TAGGED = 2,
+ AIR_VLAN_PORT_EGS_TAG_CTL_TYPE_LAST,
+} AIR_VLAN_PORT_EGS_TAG_CTL_TYPE_T;
+
+typedef enum
+{
+ AIR_PORT_EGS_TAG_ATTR_UNTAGGED = 0,
+ AIR_PORT_EGS_TAG_ATTR_SWAP,
+ AIR_PORT_EGS_TAG_ATTR_TAGGED,
+ AIR_PORT_EGS_TAG_ATTR_STACK,
+ AIR_PORT_EGS_TAG_ATTR_LAST
+} AIR_PORT_EGS_TAG_ATTR_T;
+
+typedef enum
+{
+ AIR_VLAN_ACCEPT_FRAME_TYPE_ALL = 0, /* untagged, priority-tagged and tagged */
+ AIR_VLAN_ACCEPT_FRAME_TYPE_TAG_ONLY, /* tagged */
+ AIR_VLAN_ACCEPT_FRAME_TYPE_UNTAG_ONLY, /* untagged and priority-tagged */
+ AIR_VLAN_ACCEPT_FRAME_TYPE_RESERVED, /* reserved */
+ AIR_VLAN_ACCEPT_FRAME_TYPE_LAST
+} AIR_VLAN_ACCEPT_FRAME_TYPE_T;
+
+typedef enum
+{
+ AIR_LEAKY_PKT_TYPE_UNICAST = 0, /* unicast pkt */
+ AIR_LEAKY_PKT_TYPE_MULTICAST, /* multicast pkt */
+ AIR_LEAKY_PKT_TYPE_BROADCAST, /* broadcast pkt */
+ AIR_LEAKY_PKT_TYPE_LAST
+} AIR_LEAKY_PKT_TYPE_T;
+
+typedef enum
+{
+ AIR_VLAN_PORT_ATTR_USER_PORT = 0, /* user port */
+ AIR_VLAN_PORT_ATTR_STACK_PORT, /* stack port */
+ AIR_VLAN_PORT_ATTR_TRANSLATION_PORT, /* translation port */
+ AIR_VLAN_PORT_ATTR_TRANSPARENT_PORT, /* transparent port */
+ AIR_VLAN_PORT_ATTR_LAST
+} AIR_VLAN_PORT_ATTR_T;
+
+typedef enum
+{
+ AIR_IGR_PORT_EG_TAG_ATTR_DISABLE = 0,
+ AIR_IGR_PORT_EG_TAG_ATTR_CONSISTENT,
+ AIR_IGR_PORT_EG_TAG_ATTR_UNTAGGED = 4,
+ AIR_IGR_PORT_EG_TAG_ATTR_SWAP,
+ AIR_IGR_PORT_EG_TAG_ATTR_TAGGED,
+ AIR_IGR_PORT_EG_TAG_ATTR_STACK,
+ AIR_IGR_PORT_EG_TAG_ATTR_LAST
+} AIR_IGR_PORT_EG_TAG_ATTR_T;
+
+typedef union AIR_VLAN_ENTRY_S
+{
+ UI8_T valid : 1;
+ struct
+ {
+ UI32_T vlan_table0;
+ UI32_T vlan_table1;
+ } vlan_table;
+ struct
+ {
+ UI64_T valid : 1;
+ UI64_T fid : 4;
+ UI64_T ivl : 1;
+ UI64_T copy_pri : 1;
+ UI64_T user_pri : 3;
+ UI64_T eg_ctrl_en : 1;
+ UI64_T eg_con : 1;
+ UI64_T eg_ctrl : 14;
+ UI64_T port_mem : 7;
+ UI64_T port_stag : 1;
+ UI64_T stag : 12;
+ UI64_T unm_vlan_drop : 1;
+ } vlan_entry_format;
+} AIR_VLAN_ENTRY_T;
+
+typedef union AIR_VLAN_ENTRY_ATTR_S
+{
+ UI8_T valid : 1;
+ struct
+ {
+ UI32_T vlan_table0;
+ UI32_T vlan_table1;
+ UI32_T vlan_table2;
+ UI32_T vlan_table3;
+ UI32_T vlan_table4;
+ } vlan_table;
+ struct
+ {
+ UI64_T valid : 1;
+ UI64_T fid : 4;
+ UI64_T ivl : 1;
+ UI64_T copy_pri : 1;
+ UI64_T user_pri : 3;
+ UI64_T eg_ctrl_en : 1;
+ UI64_T eg_con : 1;
+ UI64_T eg_ctrl : 14;
+ UI64_T port_mem : 7;
+ UI64_T port_stag : 1;
+ UI64_T stag : 12;
+ UI64_T unm_vlan_drop : 1;
+ } vlan_entry_format;
+#if 0
+ struct
+ {
+ UI64_T valid : 1;
+ UI64_T type : 3;
+ UI64_T mac_addr : 48;
+ UI64_T mac_mask_len : 6;
+ UI64_T priority : 3;
+ UI64_T :0;
+ UI64_T vid : 12;
+ } mac_based_vlan_entry_format;
+ struct
+ {
+ UI64_T valid : 1;
+ UI64_T type : 3;
+ UI64_T check_field : 36;
+ UI64_T :0;
+ UI64_T check_field_mask : 36;
+ UI64_T untagged_packet : 1;
+ UI64_T vlan_priority : 3;
+ UI64_T svid : 12;
+ } qinq_based_vlan_entry_format;
+ struct
+ {
+ UI64_T valid : 1;
+ UI64_T type : 3;
+ UI64_T ipv4 : 32;
+ UI64_T :0;
+ UI64_T subnetmask : 32;
+ UI64_T priority : 3;
+ UI64_T cvid : 12;
+ } ipv4_based_vlan_entry_format;
+ struct
+ {
+ UI64_T valid : 1;
+ UI64_T :0;
+ UI64_T ipv6_high : 64;
+ UI64_T ipv6_low : 64;
+ UI64_T subnetmask : 8;
+ UI64_T priority : 3;
+ UI64_T cvid : 12;
+ } ipv6_based_vlan_entry_format;
+#endif
+} AIR_VLAN_ENTRY_ATTR_T;
+
+void
+_air_vlan_readEntry(
+ const UI32_T unit,
+ const UI16_T vid,
+ AIR_VLAN_ENTRY_T* vlan_entry);
+
+void
+_air_vlan_writeEntry(
+ const UI32_T unit,
+ const UI16_T vid,
+ AIR_VLAN_ENTRY_T* vlan_entry);
+
+void
+_air_untagged_vlan_readEntry(
+ const UI32_T unit,
+ const UI16_T vid,
+ AIR_VLAN_ENTRY_ATTR_T* vlan_entry);
+
+void
+_air_untagged_vlan_writeEntry(
+ const UI32_T unit,
+ const UI16_T vid,
+ AIR_VLAN_ENTRY_ATTR_T* vlan_entry);
+
+/* EXPORTED SUBPROGRAM SPECIFICATIONS
+ */
+/* FUNCTION NAME: air_vlan_create
+ * PURPOSE:
+ * Create the vlan in the specified device.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * p_attr -- vlan attr
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Vlan creation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_create(
+ const UI32_T unit,
+ const UI16_T vid,
+ AIR_VLAN_ENTRY_ATTR_T *p_attr);
+
+/* FUNCTION NAME: air_vlan_destroy
+ * PURPOSE:
+ * Destroy the vlan in the specified device.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Vlan destroy failed.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_destroy(
+ const UI32_T unit,
+ const UI16_T vid);
+
+/* FUNCTION NAME: air_vlan_destroyAll
+ * PURPOSE:
+ * Destroy the vlan in the specified device.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Vlan destroy failed.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_destroyAll(
+ const UI32_T unit,
+ const UI32_T keep_and_restore_default_vlan);
+
+/* FUNCTION NAME: air_vlan_reset
+ * PURPOSE:
+ * Destroy the vlan in the specified device.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully reset the data.
+ * AIR_E_OTHERS -- Vlan reset failed.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_reset(
+ const UI32_T unit,
+ const UI16_T vid);
+
+/* FUNCTION NAME: air_vlan_setFid
+ * PURPOSE:
+ * Set the filter id of the vlan to the specified device.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * fid -- filter id
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setFid(
+ const UI32_T unit,
+ const UI16_T vid,
+ const UI8_T fid);
+
+/* FUNCTION NAME: air_vlan_getFid
+ * PURPOSE:
+ * Get the filter id of the vlan from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id to be created
+ * OUTPUT:
+ * p_fid -- filter id
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getFid(
+ const UI32_T unit,
+ const UI16_T vid,
+ UI8_T *p_fid);
+
+/* FUNCTION NAME: air_vlan_addMemberPort
+ * PURPOSE:
+ * Add one vlan member to the specified device.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * port -- port id
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_addMemberPort(
+ const UI32_T unit,
+ const UI16_T vid,
+ const UI32_T port);
+
+/* FUNCTION NAME: air_vlan_delMemberPort
+ * PURPOSE:
+ * Delete one vlan member from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * port -- port id
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_delMemberPort(
+ const UI32_T unit,
+ const UI16_T vid,
+ const UI32_T port);
+
+/* FUNCTION NAME: air_vlan_setMemberPort
+ * PURPOSE:
+ * Replace the vlan members in the specified device.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * port_bitmap -- member port bitmap
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setMemberPort(
+ const UI32_T unit,
+ const UI16_T vid,
+ const UI32_T port_bitmap);
+
+/* FUNCTION NAME: air_vlan_getMemberPort
+ * PURPOSE:
+ * Get the vlan members from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * OUTPUT:
+ * port_bitmap -- member port bitmap
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getMemberPort(
+ const UI32_T unit,
+ const UI16_T vid,
+ UI32_T *p_port_bitmap);
+
+/* FUNCTION NAME: air_vlan_setIVL
+ * PURPOSE:
+ * Set L2 lookup mode IVL/SVL for L2 traffic.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * enable -- enable IVL
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setIVL(
+ const UI32_T unit,
+ const UI16_T vid,
+ const BOOL_T enable);
+
+/* FUNCTION NAME: air_vlan_getIVL
+ * PURPOSE:
+ * Get L2 lookup mode IVL/SVL for L2 traffic.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * OUTPUT:
+ * p_enable -- enable IVL
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getIVL(
+ const UI32_T unit,
+ const UI16_T vid,
+ BOOL_T *p_enable);
+
+/* FUNCTION NAME: air_vlan_setPortAcceptFrameType
+ * PURPOSE:
+ * Set vlan accept frame type of the port from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * type -- accept frame type
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setPortAcceptFrameType(
+ const UI32_T unit,
+ const UI32_T port,
+ const AIR_VLAN_ACCEPT_FRAME_TYPE_T type);
+
+/* FUNCTION NAME: air_vlan_getPortAcceptFrameType
+ * PURPOSE:
+ * Get vlan accept frame type of the port from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * OUTPUT:
+ * p_type -- accept frame type
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getPortAcceptFrameType(
+ const UI32_T unit,
+ const UI32_T port,
+ AIR_VLAN_ACCEPT_FRAME_TYPE_T *p_type);
+
+/* FUNCTION NAME: air_vlan_setPortLeakyVlanEnable
+ * PURPOSE:
+ * Set leaky vlan enable of the port from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * pkt_type -- packet type
+ * enable -- enable leaky
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setPortLeakyVlanEnable(
+ const UI32_T unit,
+ const UI32_T port,
+ AIR_LEAKY_PKT_TYPE_T pkt_type,
+ const BOOL_T enable);
+
+/* FUNCTION NAME: air_vlan_getPortLeakyVlanEnable
+ * PURPOSE:
+ * Get leaky vlan enable of the port from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * pkt_type -- packet type
+ * OUTPUT:
+ * p_enable -- enable leaky
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getPortLeakyVlanEnable(
+ const UI32_T unit,
+ const UI32_T port,
+ AIR_LEAKY_PKT_TYPE_T pkt_type,
+ BOOL_T *p_enable);
+
+/* FUNCTION NAME: air_vlan_setPortAttr
+ * PURPOSE:
+ * Set vlan port attribute from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * attr -- vlan port attr
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setPortAttr(
+ const UI32_T unit,
+ const UI32_T port,
+ const AIR_VLAN_PORT_ATTR_T attr);
+
+/* FUNCTION NAME: air_vlan_getPortAttr
+ * PURPOSE:
+ * Get vlan port attribute from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * OUTPUT:
+ * p_attr -- vlan port attr
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getPortAttr(
+ const UI32_T unit,
+ const UI32_T port,
+ AIR_VLAN_PORT_ATTR_T *p_attr);
+
+/* FUNCTION NAME: air_vlan_setIgrPortTagAttr
+ * PURPOSE:
+ * Set vlan incoming port egress tag attribute from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * attr -- egress tag attr
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setIgrPortTagAttr(
+ const UI32_T unit,
+ const UI32_T port,
+ const AIR_IGR_PORT_EG_TAG_ATTR_T attr);
+
+/* FUNCTION NAME: air_vlan_getIgrPortTagAttr
+ * PURPOSE:
+ * Get vlan incoming port egress tag attribute from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * OUTPUT:
+ * p_attr -- egress tag attr
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getIgrPortTagAttr(
+ const UI32_T unit,
+ const UI32_T port,
+ AIR_IGR_PORT_EG_TAG_ATTR_T *p_attr);
+
+/* FUNCTION NAME: air_vlan_setPortEgsTagAttr
+ * PURPOSE:
+ * Set vlan port egress tag attribute from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * attr -- egress tag attr
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setPortEgsTagAttr(
+ const UI32_T unit,
+ const UI32_T port,
+ const AIR_PORT_EGS_TAG_ATTR_T attr);
+
+/* FUNCTION NAME: air_vlan_getPortEgsTagAttr
+ * PURPOSE:
+ * Get vlan port egress tag attribute from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * OUTPUT:
+ * p_attr -- egress tag attr
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getPortEgsTagAttr(
+ const UI32_T unit,
+ const UI32_T port,
+ AIR_PORT_EGS_TAG_ATTR_T *p_attr);
+
+/* FUNCTION NAME: air_vlan_setPortOuterTPID
+ * PURPOSE:
+ * Set stack tag TPID of the port from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * tpid -- TPID
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setPortOuterTPID(
+ const UI32_T unit,
+ const UI32_T port,
+ const UI16_T tpid);
+
+/* FUNCTION NAME: air_vlan_getPortOuterTPID
+ * PURPOSE:
+ * Get stack tag TPID of the port from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * OUTPUT:
+ * p_tpid -- TPID
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getPortOuterTPID(
+ const UI32_T unit,
+ const UI32_T port,
+ UI16_T *p_tpid);
+
+/* FUNCTION NAME: air_vlan_setPortPVID
+ * PURPOSE:
+ * Set PVID of the port from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * pvid -- native vlan id
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setPortPVID(
+ const UI32_T unit,
+ const UI32_T port,
+ const UI16_T pvid);
+
+/* FUNCTION NAME: air_vlan_getPortPVID
+ * PURPOSE:
+ * Get PVID of the port from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * OUTPUT:
+ * p_pvid -- native vlan id
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getPortPVID(
+ const UI32_T unit,
+ const UI32_T port,
+ UI16_T *p_pvid);
+
+/* FUNCTION NAME: air_vlan_setServiceTag
+ * PURPOSE:
+ * Set Vlan service tag.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * stag -- service stag
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setServiceTag(
+ const UI32_T unit,
+ const UI16_T vid,
+ const UI16_T stag);
+
+/* FUNCTION NAME: air_vlan_getServiceTag
+ * PURPOSE:
+ * Get Vlan service tag.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * OUTPUT:
+ * p_stag -- service stag
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getServiceTag(
+ const UI32_T unit,
+ const UI16_T vid,
+ UI16_T *p_stag);
+
+/* FUNCTION NAME: air_vlan_setEgsTagCtlEnable
+ * PURPOSE:
+ * Set per vlan egress tag control.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * enable -- enable vlan egress tag control
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setEgsTagCtlEnable(
+ const UI32_T unit,
+ const UI16_T vid,
+ const BOOL_T enable);
+
+/* FUNCTION NAME: air_vlan_getEgsTagCtlEnable
+ * PURPOSE:
+ * Get per vlan egress tag control.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * OUTPUT:
+ * p_enable -- enable vlan egress tag control
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getEgsTagCtlEnable(
+ const UI32_T unit,
+ const UI16_T vid,
+ BOOL_T *p_enable);
+
+/* FUNCTION NAME: air_vlan_setEgsTagConsistent
+ * PURPOSE:
+ * Set per vlan egress tag consistent.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * enable -- enable vlan egress tag consistent
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setEgsTagConsistent(
+ const UI32_T unit,
+ const UI16_T vid,
+ const BOOL_T enable);
+
+/* FUNCTION NAME: air_vlan_getEgsTagConsistent
+ * PURPOSE:
+ * Get per vlan egress tag consistent.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * OUTPUT:
+ * p_enable -- enable vlan egress tag consistent
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getEgsTagConsistent(
+ const UI32_T unit,
+ const UI16_T vid,
+ BOOL_T *p_enable);
+
+/* FUNCTION NAME: air_vlan_setPortBasedStag
+ * PURPOSE:
+ * Set vlan port based stag enable.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * enable -- vlan port based stag enable
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setPortBasedStag(
+ const UI32_T unit,
+ const UI16_T vid,
+ const BOOL_T enable);
+
+/* FUNCTION NAME: air_vlan_getPortBasedStag
+ * PURPOSE:
+ * Get vlan port based stag enable.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * OUTPUT:
+ * p_enable -- vlan port based stag enable
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getPortBasedStag(
+ const UI32_T unit,
+ const UI16_T vid,
+ BOOL_T *p_enable);
+
+/* FUNCTION NAME: air_vlan_setPortEgsTagCtl
+ * PURPOSE:
+ * Set vlan port egress tag control.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * port -- port id
+ * tag_ctl -- egress tag control
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setPortEgsTagCtl(
+ const UI32_T unit,
+ const UI16_T vid,
+ const UI32_T port,
+ const AIR_VLAN_PORT_EGS_TAG_CTL_TYPE_T tag_ctl);
+
+/* FUNCTION NAME: air_vlan_getPortEgsTagCtl
+ * PURPOSE:
+ * Get vlan port egress tag control.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * OUTPUT:
+ * p_tag_ctl -- egress tag control
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getPortEgsTagCtl(
+ const UI32_T unit,
+ const UI16_T vid,
+ const UI32_T port,
+ AIR_VLAN_PORT_EGS_TAG_CTL_TYPE_T *ptr_tag_ctl);
+
+#endif /* AIR_VLAN_H */
+
diff --git a/feed/app/switch/src/an8855_sdk/api/src/air_aml.c b/feed/app/switch/src/an8855_sdk/api/src/air_aml.c
index 38b85a4..2e4119c 100644
--- a/feed/app/switch/src/an8855_sdk/api/src/air_aml.c
+++ b/feed/app/switch/src/an8855_sdk/api/src/air_aml.c
@@ -1,218 +1,218 @@
-/* FILE NAME: air_aml.c
- * PURPOSE:
- * It provides access management layer function.
- * NOTES:
- *
- */
-
-/* INCLUDE FILE DECLARATIONS
- */
-#include "air.h"
-
-/* NAMING CONSTANT DECLARATIONS
- */
-
-/* MACRO FUNCTION DECLARATIONS
- */
-
-/* DATA TYPE DECLARATIONS
- */
-
-/* GLOBAL VARIABLE DECLARATIONS
- */
-AML_DEV_ACCESS_T _ext_dev_access;
-
-/* EXPORTED SUBPROGRAM BODIES
- */
-
-/* LOCAL SUBPROGRAM BODIES
- */
-/* FUNCTION NAME: aml_readReg
- * PURPOSE:
- * To read data from the register of the specified chip unit.
- * INPUT:
- * unit -- the device unit
- * addr_offset -- the address of register
- * OUTPUT:
- * ptr_data -- pointer for the register data
- * RETURN:
- * NPS_E_OK -- Successfully read the data.
- * NPS_E_OTHERS -- Failed to read the data.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-aml_readReg(
- const UI32_T unit,
- const UI32_T addr_offset,
- UI32_T *ptr_data)
-{
- AIR_CHECK_PTR(ptr_data);
-
- if (!_ext_dev_access.read_callback)
- {
- return AIR_E_OTHERS;
- }
-
- return _ext_dev_access.read_callback(unit, addr_offset, ptr_data);
-}
-
-/* FUNCTION NAME: aml_writeReg
- * PURPOSE:
- * To write data to the register of the specified chip unit.
- * INPUT:
- * unit -- the device unit
- * addr_offset -- the address of register
- * data -- written data
- * OUTPUT:
- * none
- * RETURN:
- * NPS_E_OK -- Successfully write the data.
- * NPS_E_OTHERS -- Failed to write the data.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-aml_writeReg(
- const UI32_T unit,
- const UI32_T addr_offset,
- const UI32_T data)
-{
- if (!_ext_dev_access.write_callback)
- {
- return AIR_E_OTHERS;
- }
-
- return _ext_dev_access.write_callback(unit, addr_offset, data);
-}
-
-/* FUNCTION NAME: aml_readPhyReg
- * PURPOSE:
- * To read data from the phy register of the specified chip unit in Clause22.
- * INPUT:
- * unit -- the device unit
- * port_id -- physical port number
- * addr_offset -- the address of phy register
- * OUTPUT:
- * ptr_data -- pointer for the register data
- * RETURN:
- * NPS_E_OK -- Successfully read the data.
- * NPS_E_OTHERS -- Failed to read the data.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-aml_readPhyReg(
- const UI32_T unit,
- const UI32_T port_id,
- const UI32_T addr_offset,
- UI32_T *ptr_data)
-{
- AIR_CHECK_PTR(ptr_data);
-
- if (!_ext_dev_access.phy_read_callback)
- {
- return AIR_E_OTHERS;
- }
-
- return _ext_dev_access.phy_read_callback(unit, port_id, addr_offset, ptr_data);
-}
-
-/* FUNCTION NAME: aml_writePhyReg
- * PURPOSE:
- * To write data to the phy register of the specified chip unit in Clause22.
- * INPUT:
- * unit -- the device unit
- * port_id -- physical port number
- * addr_offset -- the address of phy register
- * data -- written data
- * OUTPUT:
- * none
- * RETURN:
- * NPS_E_OK -- Successfully write the data.
- * NPS_E_OTHERS -- Failed to write the data.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-aml_writePhyReg(
- const UI32_T unit,
- const UI32_T port_id,
- const UI32_T addr_offset,
- const UI32_T data)
-{
- if (!_ext_dev_access.phy_write_callback)
- {
- return AIR_E_OTHERS;
- }
-
- return _ext_dev_access.phy_write_callback(unit, port_id, addr_offset, data);
-}
-
-/* FUNCTION NAME: aml_readPhyRegCL45
- * PURPOSE:
- * To read data from the phy register of the specified chip unit in Clause45.
- * INPUT:
- * unit -- the device unit
- * port_id -- physical port number
- * dev_type -- phy register type
- * addr_offset -- the address of phy register
- * OUTPUT:
- * ptr_data -- pointer for the register data
- * RETURN:
- * NPS_E_OK -- Successfully read the data.
- * NPS_E_OTHERS -- Failed to read the data.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-aml_readPhyRegCL45(
- const UI32_T unit,
- const UI32_T port_id,
- const UI32_T dev_type,
- const UI32_T addr_offset,
- UI32_T *ptr_data)
-{
- AIR_CHECK_PTR(ptr_data);
-
- if (!_ext_dev_access.phy_cl45_read_callback)
- {
- return AIR_E_OTHERS;
- }
-
- return _ext_dev_access.phy_cl45_read_callback(unit, port_id, dev_type, addr_offset, ptr_data);
-}
-
-/* FUNCTION NAME: aml_writePhyRegCL45
- * PURPOSE:
- * To write data to the phy register of the specified chip unit in Clause45.
- * INPUT:
- * unit -- the device unit
- * port_id -- physical port number
- * dev_type -- phy register offset
- * addr_offset -- the address of phy register
- * data -- written data
- * OUTPUT:
- * none
- * RETURN:
- * NPS_E_OK -- Successfully write the data.
- * NPS_E_OTHERS -- Failed to write the data.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-aml_writePhyRegCL45(
- const UI32_T unit,
- const UI32_T port_id,
- const UI32_T dev_type,
- const UI32_T addr_offset,
- const UI32_T data)
-{
- if (!_ext_dev_access.phy_cl45_write_callback)
- {
- return AIR_E_OTHERS;
- }
-
- return _ext_dev_access.phy_cl45_write_callback(unit, port_id, dev_type, addr_offset, data);
-}
-
+/* FILE NAME: air_aml.c
+ * PURPOSE:
+ * It provides access management layer function.
+ * NOTES:
+ *
+ */
+
+/* INCLUDE FILE DECLARATIONS
+ */
+#include "air.h"
+
+/* NAMING CONSTANT DECLARATIONS
+ */
+
+/* MACRO FUNCTION DECLARATIONS
+ */
+
+/* DATA TYPE DECLARATIONS
+ */
+
+/* GLOBAL VARIABLE DECLARATIONS
+ */
+AML_DEV_ACCESS_T _ext_dev_access;
+
+/* EXPORTED SUBPROGRAM BODIES
+ */
+
+/* LOCAL SUBPROGRAM BODIES
+ */
+/* FUNCTION NAME: aml_readReg
+ * PURPOSE:
+ * To read data from the register of the specified chip unit.
+ * INPUT:
+ * unit -- the device unit
+ * addr_offset -- the address of register
+ * OUTPUT:
+ * ptr_data -- pointer for the register data
+ * RETURN:
+ * NPS_E_OK -- Successfully read the data.
+ * NPS_E_OTHERS -- Failed to read the data.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+aml_readReg(
+ const UI32_T unit,
+ const UI32_T addr_offset,
+ UI32_T *ptr_data)
+{
+ AIR_CHECK_PTR(ptr_data);
+
+ if (!_ext_dev_access.read_callback)
+ {
+ return AIR_E_OTHERS;
+ }
+
+ return _ext_dev_access.read_callback(unit, addr_offset, ptr_data);
+}
+
+/* FUNCTION NAME: aml_writeReg
+ * PURPOSE:
+ * To write data to the register of the specified chip unit.
+ * INPUT:
+ * unit -- the device unit
+ * addr_offset -- the address of register
+ * data -- written data
+ * OUTPUT:
+ * none
+ * RETURN:
+ * NPS_E_OK -- Successfully write the data.
+ * NPS_E_OTHERS -- Failed to write the data.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+aml_writeReg(
+ const UI32_T unit,
+ const UI32_T addr_offset,
+ const UI32_T data)
+{
+ if (!_ext_dev_access.write_callback)
+ {
+ return AIR_E_OTHERS;
+ }
+
+ return _ext_dev_access.write_callback(unit, addr_offset, data);
+}
+
+/* FUNCTION NAME: aml_readPhyReg
+ * PURPOSE:
+ * To read data from the phy register of the specified chip unit in Clause22.
+ * INPUT:
+ * unit -- the device unit
+ * port_id -- physical port number
+ * addr_offset -- the address of phy register
+ * OUTPUT:
+ * ptr_data -- pointer for the register data
+ * RETURN:
+ * NPS_E_OK -- Successfully read the data.
+ * NPS_E_OTHERS -- Failed to read the data.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+aml_readPhyReg(
+ const UI32_T unit,
+ const UI32_T port_id,
+ const UI32_T addr_offset,
+ UI32_T *ptr_data)
+{
+ AIR_CHECK_PTR(ptr_data);
+
+ if (!_ext_dev_access.phy_read_callback)
+ {
+ return AIR_E_OTHERS;
+ }
+
+ return _ext_dev_access.phy_read_callback(unit, port_id, addr_offset, ptr_data);
+}
+
+/* FUNCTION NAME: aml_writePhyReg
+ * PURPOSE:
+ * To write data to the phy register of the specified chip unit in Clause22.
+ * INPUT:
+ * unit -- the device unit
+ * port_id -- physical port number
+ * addr_offset -- the address of phy register
+ * data -- written data
+ * OUTPUT:
+ * none
+ * RETURN:
+ * NPS_E_OK -- Successfully write the data.
+ * NPS_E_OTHERS -- Failed to write the data.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+aml_writePhyReg(
+ const UI32_T unit,
+ const UI32_T port_id,
+ const UI32_T addr_offset,
+ const UI32_T data)
+{
+ if (!_ext_dev_access.phy_write_callback)
+ {
+ return AIR_E_OTHERS;
+ }
+
+ return _ext_dev_access.phy_write_callback(unit, port_id, addr_offset, data);
+}
+
+/* FUNCTION NAME: aml_readPhyRegCL45
+ * PURPOSE:
+ * To read data from the phy register of the specified chip unit in Clause45.
+ * INPUT:
+ * unit -- the device unit
+ * port_id -- physical port number
+ * dev_type -- phy register type
+ * addr_offset -- the address of phy register
+ * OUTPUT:
+ * ptr_data -- pointer for the register data
+ * RETURN:
+ * NPS_E_OK -- Successfully read the data.
+ * NPS_E_OTHERS -- Failed to read the data.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+aml_readPhyRegCL45(
+ const UI32_T unit,
+ const UI32_T port_id,
+ const UI32_T dev_type,
+ const UI32_T addr_offset,
+ UI32_T *ptr_data)
+{
+ AIR_CHECK_PTR(ptr_data);
+
+ if (!_ext_dev_access.phy_cl45_read_callback)
+ {
+ return AIR_E_OTHERS;
+ }
+
+ return _ext_dev_access.phy_cl45_read_callback(unit, port_id, dev_type, addr_offset, ptr_data);
+}
+
+/* FUNCTION NAME: aml_writePhyRegCL45
+ * PURPOSE:
+ * To write data to the phy register of the specified chip unit in Clause45.
+ * INPUT:
+ * unit -- the device unit
+ * port_id -- physical port number
+ * dev_type -- phy register offset
+ * addr_offset -- the address of phy register
+ * data -- written data
+ * OUTPUT:
+ * none
+ * RETURN:
+ * NPS_E_OK -- Successfully write the data.
+ * NPS_E_OTHERS -- Failed to write the data.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+aml_writePhyRegCL45(
+ const UI32_T unit,
+ const UI32_T port_id,
+ const UI32_T dev_type,
+ const UI32_T addr_offset,
+ const UI32_T data)
+{
+ if (!_ext_dev_access.phy_cl45_write_callback)
+ {
+ return AIR_E_OTHERS;
+ }
+
+ return _ext_dev_access.phy_cl45_write_callback(unit, port_id, dev_type, addr_offset, data);
+}
+
diff --git a/feed/app/switch/src/an8855_sdk/api/src/air_cmd.c b/feed/app/switch/src/an8855_sdk/api/src/air_cmd.c
index 95c11e8..6dfe416 100644
--- a/feed/app/switch/src/an8855_sdk/api/src/air_cmd.c
+++ b/feed/app/switch/src/an8855_sdk/api/src/air_cmd.c
@@ -1,8022 +1,8046 @@
-/* FILE NAME: air_cmd.c
- * PURPOSE:
- * Define the command line function in AIR SDK.
- * NOTES:
- */
-
-/* INCLUDE FILE DECLARATIONS
-*/
-#include "air.h"
-
-/* NAMING CONSTANT DECLARATIONS
-*/
-
-/* MACRO FUNCTION DECLARATIONS
-*/
-#define MAC_STR "%02X%02X%02X%02X%02X%02X"
-#define MAC2STR(m) (m)[0],(m)[1],(m)[2],(m)[3],(m)[4],(m)[5]
-#define AIR_MAC_LEN (12)
-#define CMD_NO_PARA (0xFFFFFFFF)
-#define CMD_VARIABLE_PARA (0xFFFFFFFE)
-#define L2_WDOG_KICK_NUM (100)
-
-#define TOLOWER(x) ((x) | 0x20)
-#define isxdigit(c) (('0' <= (c) && (c) <= '9') || ('a' <= (c) && (c) <= 'f') || ('A' <= (c) && (c) <= 'F'))
-#define isdigit(c) ('0' <= (c) && (c) <= '9')
-#define CMD_CHECK_PARA(__shift__, __op__, __size__) do \
-{ \
- if ((__shift__) __op__ (__size__)) \
- { \
- ; \
- } \
- else \
- { \
- return (AIR_E_BAD_PARAMETER); \
- } \
-} while(0)
-
-/* DATA TYPE DECLARATIONS
-*/
-typedef struct {
- C8_T* name;
- AIR_ERROR_NO_T (*func)(UI32_T argc, C8_T *argv[]);
- UI32_T argc_min;
- C8_T* argc_errmsg;
-} AIR_CMD_T;
-
-/* GLOBAL VARIABLE DECLARATIONS
-*/
-
-/* LOCAL SUBPROGRAM DECLARATIONS
-*/
-/* String Utility */
-static BOOL_T _strcmp(const char *s1, const char *s2);
-static C8_T * _strtok_r(C8_T *s, const C8_T *delim, C8_T **last);
-static C8_T * _strtok(C8_T *s, const C8_T *delim, C8_T **last);
-UI32_T _strtoul(const C8_T *cp, C8_T **endp, UI32_T base);
-static I32_T _strtol(const C8_T *cp, C8_T **endp, UI32_T base);
-
-/* Type Converter */
-static AIR_ERROR_NO_T _str2mac(C8_T *str, C8_T *mac);
-static AIR_ERROR_NO_T _hex2bit(const UI32_T hex, UI32_T *ptr_bit);
-static AIR_ERROR_NO_T _hex2bitstr(const UI32_T hex, C8_T *ptr_bit_str, UI32_T str_len);
-static AIR_ERROR_NO_T _portListStr2Ary(const C8_T *str, UI32_T *ary, const UI32_T ary_num);
-
-/* Register Operation */
-static AIR_ERROR_NO_T doRegRead(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doRegWrite(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doReg(UI32_T argc, C8_T *argv[]);
-
-/* PHY Operation */
-static AIR_ERROR_NO_T doPhyCL22Read(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPhyCL22Write(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPhyCL22(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPhyCL45Read(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPhyCL45Write(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPhyCL45(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPhy(UI32_T argc, C8_T *argv[]);
-
-/* Porting setting */
-static AIR_ERROR_NO_T doPortSetMatrix(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPortSetVlanMode(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPortSet(UI32_T argc, C8_T *argv[]);
-
-static AIR_ERROR_NO_T doPortGetMatrix(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPortGetVlanMode(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPortGet(UI32_T argc, C8_T *argv[]);
-
-static AIR_ERROR_NO_T doPort(UI32_T argc, C8_T *argv[]);
-
-/* Vlan setting */
-static AIR_ERROR_NO_T doVlanInitiate(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanCreate(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanDestroy(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanDestroyAll(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanDump(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanAddPortMem(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanDelPortMem(UI32_T argc, C8_T *argv[]);
-
-static AIR_ERROR_NO_T doVlanSetFid(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanSetMemPort(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanSetIVL(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanSetPortBaseStag(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanSetStag(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanSetEgsTagCtlEn(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanSetEgsTagCtlCon(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanSetEgsTagCtl(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanSetPortActFrame(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanSetLeakyVlanEn(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanSetPortVlanAttr(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanSetIgsPortETagAttr(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanSetPortETagAttr(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanSetPortOuterTPID(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanSetPvid(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanSet(UI32_T argc, C8_T *argv[]);
-
-static AIR_ERROR_NO_T doVlanGetPortActFrame(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanGetLeakyVlanEn(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanGetPortVlanAttr(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanGetIgsPortETagAttr(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanGetPortETagAttr(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanGetPortOuterTPID(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanGetPvid(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doVlanGet(UI32_T argc, C8_T *argv[]);
-
-static AIR_ERROR_NO_T doVlan(UI32_T argc, C8_T *argv[]);
-
-static AIR_ERROR_NO_T doFlowCtrl(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doJumbo(UI32_T argc, C8_T *argv[]);
-
-static AIR_ERROR_NO_T doL2Add(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doL2Del(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doL2Clear(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doL2Get(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doL2Set(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doL2Dump(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doL2(UI32_T argc, C8_T *argv[]);
-
-static AIR_ERROR_NO_T doAnMode(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doLocalAdv(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doRemoteAdv(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPortSpeed(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPortDuplex(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPortStatus(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPortBckPres(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPortPsMode(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPortSmtSpdDwn(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPortSpTag(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPortEnable(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPort5GBaseRMode(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPortHsgmiiMode(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPortSgmiiMode(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPortRmiiMode(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doPortRgmiiMode(UI32_T argc, C8_T *argv[]);
-
-static AIR_ERROR_NO_T doSptagEn(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doSptagMode(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doSptagDecode(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doSptagEncode(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doSptag(UI32_T argc, C8_T *argv[]);
-
-static AIR_ERROR_NO_T doMacAddr(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T _printMacEntry(AIR_MAC_ENTRY_T * mt, UI32_T age_unit, UI8_T count, UI8_T title);
-static AIR_ERROR_NO_T doGetMacAddr(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doMacAddrAgeOut(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doDumpMacAddr(UI32_T argc, C8_T *argv[]);
-
-static AIR_ERROR_NO_T doLagMember(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doLagMemberCnt(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doLagPtseed(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doLagHashtype(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doLagDstInfo(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doLagState(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doLagSpsel(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doLagGet(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doLagSet(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doLag(UI32_T argc, C8_T *argv[]);
-
-static AIR_ERROR_NO_T doStpPortstate(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doStpGet(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doStpSet(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doStp(UI32_T argc, C8_T *argv[]);
-
-static AIR_ERROR_NO_T doMirrorGetSid(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doMirrorDelSid(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doMirrorAddRlist(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doMirrorAddTlist(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doMirrorSetSessionEnable(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doMirrorSetSession(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doMirrorSet(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doMirrorAdd(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doMirrorGet(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doMirrorDel(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doMirror(UI32_T argc,C8_T *argv[]);
-
-static AIR_ERROR_NO_T doMibClearPort(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doMibClearAcl(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doMibGetPort(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doMibGetAcl(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doMibClear(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doMibGet(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doMib(UI32_T argc, C8_T *argv[]);
-
-static AIR_ERROR_NO_T doQosScheduleAlgo(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doQosTrustMode(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doQosPri2Queue(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doQosDscp2Pri(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doQosRateLimitEnable(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doQosRateLimit(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doQosPortPriority(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doQosRateLimitExMngFrm(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doQosGet(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doQosSet(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doQos(UI32_T argc, C8_T *argv[]);
-
-static AIR_ERROR_NO_T doDiagTxComply(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doDiagSet(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doDiagGet(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doDiag(UI32_T argc, C8_T *argv[]);
-
-static AIR_ERROR_NO_T doLedMode(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doLedState(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doLedUsrDef(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doLedBlkTime(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doLedSet(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doLedGet(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doLed(UI32_T argc, C8_T *argv[]);
-
-static AIR_ERROR_NO_T doSwitchCpuPortEn(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doSwitchCpuPort(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doSwitchPhyLCIntrEn(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doSwitchPhyLCIntrSts(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doSwitchSet(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doSwitchGet(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doSwitch(UI32_T argc, C8_T *argv[]);
-
-static AIR_ERROR_NO_T doShowVersion(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doShow(UI32_T argc, C8_T *argv[]);
-
-static AIR_ERROR_NO_T doStormEnable(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doStormRate(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doFldMode(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doSaLearning(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doSaLimit(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doSecGet(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doSecSet(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doSec(UI32_T argc, C8_T *argv[]);
-
-static void _air_acl_printRuleMap(UI32_T *rule_map, UI32_T ary_num);
-static AIR_ERROR_NO_T doAclEn(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doAclRule(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doAclUdfRule(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doAclRmvRule(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doAclRmvUdfRule(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doAclAction(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doAclRmvAction(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doAclDumpAction(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doAclTrtcm(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doAclTrtcmEn(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doAclRmvTrtcm(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doAclPortEn(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doAclDropEn(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doAclDropThrsh(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doAclDropPbb(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doAclMeter(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doAclDump(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doAclSet(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doAclGet(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doAclDel(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doAclClear(UI32_T argc, C8_T *argv[]);
-static AIR_ERROR_NO_T doAcl(UI32_T argc, C8_T *argv[]);
-
-static AIR_ERROR_NO_T subcmd(const AIR_CMD_T tab[], UI32_T argc, C8_T *argv[]);
-
-/* STATIC VARIABLE DECLARATIONS
-*/
-const static C8_T *_sptag_vpm[] =
-{
- "untagged",
- "8100",
- "predefined",
- "unknown"
-};
-
-const static C8_T *_sptag_pt[] =
-{
- "disable pass through",
- "enable pass through"
-};
-
-const static C8_T *_air_mac_address_forward_control_string [] =
-{
- "Default",
- "CPU include",
- "CPU exclude",
- "CPU only",
- "Drop"
-};
-
-static AIR_CMD_T regCmds[] =
-{
- {"r", doRegRead, 1, "reg r <reg(4'hex)>"},
- {"w", doRegWrite, 2, "reg w <reg(4'hex)> <value(8'hex)>"},
-
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T phyCL22Cmds[] =
-{
- {"r", doPhyCL22Read, 2, "phy cl22 r <port(0..4)> <reg(2'hex)>"},
- {"w", doPhyCL22Write, 3, "phy cl22 w <port(0..4)> <reg(2'hex)> <value(4'hex)>"},
-
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T phyCL45Cmds[] =
-{
- {"r", doPhyCL45Read, 3, "phy cl45 r <port(0..4)> <dev(2'hex)> <reg(3'hex)>"},
- {"w", doPhyCL45Write, 4, "phy cl45 w <port(0..4)> <dev(2'hex)> <reg(3'hex)> <value(4'hex)>"},
-
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T phyCmds[] =
-{
- {"cl22", doPhyCL22, 0, NULL},
- {"cl45", doPhyCL45, 0, NULL},
-
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T portSetCmds[] =
-{
- {"matrix", doPortSetMatrix, 2, "port set matrix <port(0..6)> <matrix(6:0)>"},
- {"vlanMode", doPortSetVlanMode, 2, "port set vlanMode <port(0..6)> <vlanMode(0:matrix,1:fallback,2:check,3:security)>"},
- {"flowCtrl", doFlowCtrl, 3, "port set flowCtrl <port(0..6)> <dir(0:Tx,1:Rx)> <fc_en(1:En,0:Dis)>"},
- {"jumbo", doJumbo, 2, "port set jumbo <pkt_len(0:1518,1:1536,2:1552,3:max)> <frame_len(2..15)>"},
- {"anMode", doAnMode, 2, "port set anMode <port(0..4)> <en(0:force,1:AN)>"},
- {"localAdv", doLocalAdv, 7, "port set localAdv <port(0..4)> <10H(1:En,0:Dis)> <10F(1:En,0:Dis)> <100H(1:En,0:Dis)> <100F(1:En,0:Dis)> <1000F(1:En,0:Dis)> <pause(1:En,0:Dis)>"},
- {"speed", doPortSpeed, 2, "port set speed <port(0..4)> <speed(0:10M,1:100M,2:1G,3:2.5G)>"},
- {"duplex", doPortDuplex, 2, "port set duplex <port(0..4)> <duplex(0:half,1:full)>"},
- {"bckPres", doPortBckPres, 2, "port set bckPres <port(0..6)> <bckPres(1:En,0:Dis)>"},
- {"psMode", doPortPsMode, 3, "port set psMode <port(0..4)> <ls(1:En,0:Dis)> <eee(1:En,0:Dis)>"},
- {"smtSpdDwn", doPortSmtSpdDwn, 3, "port set smtSpdDwn <port(0..4)> <en(1:En,0:Dis)> <retry(2..5)>"},
- {"spTag", doPortSpTag, 2, "port set spTag <port(0..6)> <en(1:En,0:Dis)>"},
- {"enable", doPortEnable, 2, "port set enable <port(0..4)> <en(1:En,0:Dis)>"},
- {"5GBaseRMode", doPort5GBaseRMode, CMD_NO_PARA, "port set 5GBaseRMode"},
- {"hsgmiiMode", doPortHsgmiiMode, CMD_NO_PARA, "port set hsgmiiMode"},
- {"sgmiiMode", doPortSgmiiMode, 2, "port set sgmiiMode <mode(0:AN,1:Force)> <speed(0:10M,1:100M,2:1G)>"},
- {"rmiiMode", doPortRmiiMode, 1, "port set rmiiMode <speed(0:10M,1:100M)>"},
- {"rgmiiMode", doPortRgmiiMode, 1, "port set rgmiiMode <speed(0:10M,1:100M,2:1G)>"},
-
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T portGetCmds[] =
-{
- {"matrix", doPortGetMatrix, 1, "port get matrix <port(0..6)>"},
- {"vlanMode", doPortGetVlanMode, 1, "port get vlanMode <port(0..6)>"},
- {"flowCtrl", doFlowCtrl, 2, "port get flowCtrl <port(0..6)> <dir(0:Tx,1:Rx)>"},
- {"jumbo", doJumbo, CMD_NO_PARA, "port get jumbo"},
- {"anMode", doAnMode, 1, "port get anMode <port(0..4)>"},
- {"localAdv", doLocalAdv, 1, "port get localAdv <port(0..4)>"},
- {"remoteAdv", doRemoteAdv, 1, "port get remoteAdv <port(0..4)>"},
- {"speed", doPortSpeed, 1, "port get speed <port(0..4)>"},
- {"duplex", doPortDuplex, 1, "port get duplex <port(0..4)>"},
- {"status", doPortStatus, 1, "port get status <port(0..4)>"},
- {"bckPres", doPortBckPres, 1, "port get bckPres <port(0..6)>"},
- {"psMode", doPortPsMode, 1, "port get psMode <port(0..4)>"},
- {"smtSpdDwn", doPortSmtSpdDwn, 1, "port get smtSpdDwn <port(0..4)>"},
- {"spTag", doPortSpTag, 1, "port get spTag <port(0..6)>"},
- {"enable", doPortEnable, 1, "port get enable <port(0..4)>"},
-
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T portCmds[] =
-{
- {"set", doPortSet, 0, NULL},
- {"get", doPortGet, 0, NULL},
-
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T sptagCmds[] =
-{
- {"setEnable", doSptagEn, 2, "sptag setEnable port<port(0..6)> enable<1:enable 0:disable>"},
- {"getEnable", doSptagEn, 1, "sptag getEnable port<port(0..6)>"},
- {"setmode", doSptagMode, 2, "sptag setmode port<port(0..6)> mode<0:inset 1:replace>"},
- {"getmode", doSptagMode, 1, "sptag getmode port<port(0..6)>"},
- {"encode", doSptagEncode, 7, "sptag encode mode={ insert | replace } opc={ portmap | portid | lookup } dp={bitimap hex} vpm={ untagged | 8100 | 88a8 } pri=<UINT> cfi=<UINT> vid=<UINT> "},
- {"decode", doSptagDecode, 4, "sptag decode <byte(hex)> <byte(hex)> <byte(hex)> <byte(hex)>"},
-
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T vlanSetCmds[] =
-{
- {"fid", doVlanSetFid, 2, "vlan set fid <vid(0..4095)> <fid(0..7)>"},
- {"memPort", doVlanSetMemPort, 2, "vlan set memPort <vid(0..4095)> <bitmap(6:0)>"},
- {"ivl", doVlanSetIVL, 2, "vlan set ivl <vid(0..4095)> <(1:En,0:Dis)>"},
- {"portBaseStag", doVlanSetPortBaseStag, 2, "vlan set portBaseStag <vid(0..4095)> <(1:En,0:Dis)>"},
- {"stag", doVlanSetStag, 2, "vlan set stag <vid(0..4095)> <stag(0..4095)>"},
- {"egsTagCtlEn", doVlanSetEgsTagCtlEn, 2, "vlan set egsTagCtlEn <vid(0..4095)> <(1:En,0:Dis)>"},
- {"egsTagCtlCon", doVlanSetEgsTagCtlCon, 2, "vlan set egsTagCtlCon <vid(0..4095)> <(1:En,0:Dis)>"},
- {"egsTagCtl", doVlanSetEgsTagCtl, 3, "vlan set egsTagCtl <vid(0..4095)> <port(0..6)> <ctlType(0:untag,2:tagged)>"},
-
- {"portActFrame", doVlanSetPortActFrame, 2, "vlan set portActFrame <port(0..6)> <frameType(0:all,1:tagged,2:untagged)>"},
- {"leakyVlanEn", doVlanSetLeakyVlanEn, 3, "vlan set LeakyVlanEn <port(0..6)> <pktType(0:uc,1:mc,2:bc,3:ipmc)> <(1:En,0:Dis)>"},
- {"portVlanAttr", doVlanSetPortVlanAttr, 2, "vlan set portVlanAttr <port(0..6)> <vlanAttr(0:user,1:stack,2:translation,3:transparent)>"},
- {"igsPortETagAttr", doVlanSetIgsPortETagAttr, 2, "vlan set igsPortETagAttr <port(0..6)> <egsTagAttr(0:disable,1:consistent,4:untagged,5:swap,6:tagged,7:stack)>"},
- {"portEgsTagAttr", doVlanSetPortETagAttr, 2, "vlan set portEgsTagAttr <port(0..6)> <egsTagAttr(0:untagged,1:swap,2:tagged,3:stack)>"},
- {"portOuterTPID", doVlanSetPortOuterTPID, 2, "vlan set portOuterTPID <port(0..6)> <TPID(hex)>"},
- {"pvid", doVlanSetPvid, 2, "vlan set pvid <port(0..6)> <vid(0..4095)>"},
-
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T vlanGetCmds[] =
-{
- {"portActFrame", doVlanGetPortActFrame, 1, "vlan get portActFrame <port(0..6)>"},
- {"leakyVlanEn", doVlanGetLeakyVlanEn, 1, "vlan get leakyVlanEn <port(0..6)>"},
- {"portVlanAttr", doVlanGetPortVlanAttr, 1, "vlan get portVlanAttr <port(0..6)>"},
- {"igsPortETagAttr", doVlanGetIgsPortETagAttr, 1, "vlan get igsPortETagAttr <port(0..6)>"},
- {"portEgsTagAttr", doVlanGetPortETagAttr, 1, "vlan get portEgsTagAttr <port(0..6)>"},
- {"portOuterTPID", doVlanGetPortOuterTPID, 1, "vlan get portOuterTPID <port(0..6)>"},
- {"pvid", doVlanGetPvid, 1, "vlan get pvid <port(0..6)>"},
-
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T vlanCmds[] =
-{
- {"initiate", doVlanInitiate, 9, "vlan initiate <vid(0..4095)> <fid(0..7)> <bitmap(6:0)> <ivl(1:En,0:Dis)> <portbasestag(1:En,0:Dis)> <stag(0..4095)> <egstagctlen(1:En,0:Dis)> <egstagcon(1:En,0:Dis)> <taggedbitmap(6:0)>"},
- {"create", doVlanCreate, 1, "vlan create <vid(0..4095)>"},
- {"destroy", doVlanDestroy, 1, "vlan destroy [ <vid(0..4095)> | <vidRange(vid0-vid1)> ]"},
- {"destroyAll", doVlanDestroyAll, 0, "vlan destroyAll [ <restoreDefVlan(0:false,1:true)> | ]"},
- {"dump", doVlanDump, 0, "vlan dump [ <vid(0..4095)> | <vidRange(vid0-vid1)> | ]"},
- {"addPortMem", doVlanAddPortMem, 2, "vlan addPortMem <vid(0..4095)> <port(0..6)>"},
- {"delPortMem", doVlanDelPortMem, 2, "vlan addPortMem <vid(0..4095)> <port(0..6)>"},
- {"set", doVlanSet, 0, NULL},
- {"get", doVlanGet, 0, NULL},
-
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T l2ClearCmds[] =
-{
- {"mac", doMacAddr, CMD_NO_PARA, "l2 clear mac"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T l2DelCmds[] =
-{
- {"mac", doMacAddr, 3, "l2 del mac <mac(12'hex)> [ vid <vid(0..4095)> | fid <fid(0..15)> ]"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T l2AddCmds[] =
-{
- {"mac", doMacAddr, 7, "l2 add mac <static(0:dynamic,1:static)> <unauth(0:auth,1:unauth)> <mac(12'hex)> <portlist(uintlist)> [ vid <vid(0..4095)> | fid <fid(0..15)> ] <src_mac_forward=(0:default,1:cpu-exclude,2:cpu-include,3:cpu-only,4:drop)>"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T l2SetCmds[] =
-{
- {"macAddrAgeOut", doMacAddrAgeOut, 1, "l2 set macAddrAgeOut <time(1, 1000000)>"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T l2GetCmds[] =
-{
- {"mac", doGetMacAddr, 3, "l2 get mac <mac(12'hex)> [ vid <vid(0..4095)> | fid <fid(0..15)> ]"},
- {"macAddrAgeOut", doMacAddrAgeOut, CMD_NO_PARA, "l2 get macAddrAgeOut"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T l2DumpCmds[] =
-{
- {"mac", doDumpMacAddr, 0, "l2 dump mac"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T l2Cmds[] =
-{
- {"add", doL2Add, 0, NULL},
- {"del", doL2Del, 0, NULL},
- {"clear", doL2Clear, 0, NULL},
- {"get", doL2Get, 0, NULL},
- {"set", doL2Set, 0, NULL},
- {"dump", doL2Dump, 0, NULL},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T lagGetCmds[] =
-{
- {"member", doLagMember, 1, "lag get member group_id(0 or 1)"},
- {"dstInfo", doLagDstInfo, CMD_NO_PARA, "lag get dstInfo"},
- {"ptseed", doLagPtseed, CMD_NO_PARA, "lag get ptseed"},
- {"hashtype", doLagHashtype, CMD_NO_PARA, "lag get hashtype"},
- {"state", doLagState, CMD_NO_PARA, "lag get state"},
- {"spsel", doLagSpsel, CMD_NO_PARA, "lag get spsel"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T lagSetCmds[] =
-{
- {"member", doLagMember, 4, "lag set member <group_id(0 or 1)> <member_index(0..3)> <enable(0,1)> <port index(0..6)>"},
- {"dstInfo", doLagDstInfo, 7, "lag set dstInfo <sp(1:En,0:Dis)> <sa(1:En,0:Dis)> <da(1:En,0:Dis)> <sip(1:En,0:Dis)> <dip(1:En,0:Dis)> <sport(1:En,0:Dis)> <dport(1:En,0:Dis)>"},
- {"ptseed", doLagPtseed, 1, "lag set ptseed <hex32>"},
- {"hashtype", doLagHashtype, 1, "lag set hashtype <0-crc32lsb;1-crc32msb;2-crc16;3-xor4>"},
- {"state", doLagState, 1, "lag set state <state(1:En,0:Dis)>"},
- {"spsel", doLagSpsel, 1, "lag set spsel <soure port enable(1:En,0:Dis)>"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T lagCmds[] =
-{
- {"get", doLagGet, 0, NULL},
- {"set", doLagSet, 0, NULL},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T stpGetCmds[] =
-{
- {"portstate", doStpPortstate, 2, "stp get portstate <port(0..6)> <fid(0..15)>"},
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T stpSetCmds[] =
-{
- {"portstate", doStpPortstate, 3, "stp set portstate <port(0..6)> <fid(0..15)> <state(0:disable,1:listen,2:learn,3:forward)>"},
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T stpCmds[] =
-{
- {"get", doStpGet, 0, NULL},
- {"set", doStpSet, 0, NULL},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T mirrorSetCmds[] =
-{
- {"session", doMirrorSetSession, 6, "mirror set session <sid(0,1)> <dst_port(UINT)> <state(1:En,0:Dis)> <tag(1:on, 0:off)> <list(UINTLIST)> <dir(0:none,1:tx,2:rx,3:both)>"},
- {"session-enable", doMirrorSetSessionEnable, 2, "mirror set session-enable <sid(0,1)> <state(1:En,0:Dis)>"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T mirrorAddCmds[] =
-{
- {"session-rlist", doMirrorAddRlist, 2, "mirror add session-rlist <sid(0,1)> <list(UINTLIST)>"},
- {"session-tlist", doMirrorAddTlist, 2, "mirror add session-tlist <sid(0,1)> <list(UINTLIST)>"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T mirrorGetCmds[] =
-{
- {"session", doMirrorGetSid, 1, "mirror get session <sid(0,1)>"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T mirrorDelCmds[] =
-{
- {"session", doMirrorDelSid, 1, "mirror del session <sid(0,1)>"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T mirrorCmds[] =
-{
- {"set", doMirrorSet, 0, NULL},
- {"add", doMirrorAdd, 0, NULL},
- {"get", doMirrorGet, 0, NULL},
- {"del", doMirrorDel, 0, NULL},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T mibClearCmds[] =
-{
- {"port", doMibClearPort, 1, "mib clear port <port(0..6)>"},
- {"all", doMibClearPort, 0, "mib clear all"},
- {"acl", doMibClearAcl, 0, "mib clear acl"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T mibGetCmds[] =
-{
- {"port", doMibGetPort, 1, "mib get port <port(0..6)>"},
- {"acl", doMibGetAcl, 1, "mib get acl <event(0..7)>"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T mibCmds[] =
-{
- {"clear", doMibClear, 0, NULL},
- {"get", doMibGet, 0, NULL},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T qosGetCmds[] =
-{
- {"scheduleAlgo", doQosScheduleAlgo, 2, "qos get scheduleAlgo <portlist(UINTLIST)> <queue(UINT)>"},
- {"trustMode", doQosTrustMode, 1, "qos get trustMode <portlist(UINTLIST)>"},
- {"pri2Queue", doQosPri2Queue, 0, "qos get pri2Queue"},
- {"dscp2Pri", doQosDscp2Pri, 1, "qos get dscp2Pri <dscp(0..63)>"},
- {"rateLimitEnable", doQosRateLimitEnable, 1, "qos get rateLimitEnable <portlist(UINTLIST)>"},
- {"rateLimit", doQosRateLimit, 1, "qos get rateLimit <portlist(UINTLIST)>"},
- {"portPriority", doQosPortPriority, 1, "qos get portPriority <portlist(UINTLIST)>"},
- {"rateLmtExMngFrm", doQosRateLimitExMngFrm, 0, "qos get rateLmtExMngFrm"},
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T qosSetCmds[] =
-{
- {"scheduleAlgo", doQosScheduleAlgo, 4, "qos set scheduleAlgo <portlist(UINTLIST)> <queue(UINT)> <scheduler(0:SP,1:WRR,2:WFQ)> <weight(0..128)>, weight 0 is valid only on sp mode"},
- {"trustMode", doQosTrustMode, 2, "qos set trustMode <portlist(UINTLIST)> <mode(0:port,1:1p-port,2:dscp-port,3:dscp-1p-port>"},
- {"pri2Queue", doQosPri2Queue, 2, "qos set pri2Queue <priority(0..7)> <queue(0..7)>"},
- {"dscp2Pri", doQosDscp2Pri, 2, "qos set dscp2Pri <dscp(0..63)> <priority(0..7)>"},
- {"rateLimitEnable", doQosRateLimitEnable, 3, "qos set rateLimitEnable <portlist(UINTLIST)> <dir(0:egress,1:ingress)> <rate_en(1:En,0:Dis)>"},
- {"rateLimit", doQosRateLimit, 5, "qos set rateLimit <portlist(UINTLIST)> <I_CIR(0..80000)> <I_CBS(0..127)> <E_CIR(0..80000)> <E_CBS(0..127)>"},
- {"portPriority", doQosPortPriority, 2, "qos set portPriority <portlist(UINTLIST)> <priority(0..7)>"},
- {"rateLmtExMngFrm", doQosRateLimitExMngFrm, 2, "qos set rateLmtExMngFrm <dir(0:egress)> <en(0:include,1:exclude)>"},
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T qosCmds[] =
-{
- {"get", doQosGet, 0, NULL},
- {"set", doQosSet, 0, NULL},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T diagSetCmds[] =
-{
- {"txComply", doDiagTxComply, 2, "diag set txComply <phy(0..5)> <mode(0..8)>"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T diagGetCmds[] =
-{
- {"txComply", doDiagTxComply, 1, "diag get txComply <phy(0..5)>"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T diagCmds[] =
-{
- {"set", doDiagSet, 0, NULL},
- {"get", doDiagGet, 0, NULL},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T ledSetCmds[] =
-{
- {"mode", doLedMode, 1, "led set mode <mode(0:disable, 1..3:2 LED, 4:user-define)>"},
- {"state", doLedState, 2, "led set state <led(0..1)> <state(1:En,0:Dis)>"},
- {"usr", doLedUsrDef, 4, "led set usr <led(0..1)> <polarity(0:low, 1:high)> <on_evt(7'bin)> <blink_evt(10'bin)>"},
- {"time", doLedBlkTime, 1, "led set time <time(0..5:32ms~1024ms)>"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T ledGetCmds[] =
-{
- {"mode", doLedMode, CMD_NO_PARA, "led get mode"},
- {"state", doLedState, 1, "led get state <led(0..1)>"},
- {"usr", doLedUsrDef, 1, "led get usr <led(0..1)>"},
- {"time", doLedBlkTime, CMD_NO_PARA, "led get time"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T ledCmds[] =
-{
- {"set", doLedSet, 0, NULL},
- {"get", doLedGet, 0, NULL},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T showCmds[] =
-{
- {"version", doShowVersion, 0, NULL},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T secGetCmds[] =
-{
- {"stormEnable", doStormEnable, 2, "sec get stormEnable <port(0..6)> <type(0:bcst,1:mcst,2:ucst)>"},
- {"stormRate", doStormRate, 2, "sec get stormRate <port(0..6)> <type(0:bcst,1:mcst,2:ucst)>"},
- {"fldMode", doFldMode, 2, "sec get fldMode <port(0..6)> <type(0:bcst,1:mcst,2:ucst,3:qury>"},
- {"saLearning", doSaLearning, 1, "sec get saLearning <port(0..6)>"},
- {"saLimit", doSaLimit, 1, "sec get saLimit <port(0..6)>"},
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T secSetCmds[] =
-{
- {"stormEnable", doStormEnable, 3, "sec set stormEnable <port(0..6)> <type(0:bcst,1:mcst,2:ucst)> <en(1:En,0:Dis)>"},
- {"stormRate", doStormRate, 4, "sec set stormRate <port(0..6)> <type(0:bcst,1:mcst,2:ucst)> <count(0..255)> <unit(0:64k,1:256k,2:1M,3:4M,4:16M)>"},
- {"fldMode", doFldMode, 3, "sec set fldMode <port(0..6)> <type(0:bcst,1:mcst,2:ucst,3:qury> <en(1:En,0:Dis)>"},
- {"saLearning", doSaLearning, 2, "sec set saLearning <port(0..6)> <learn(0:disable,1:enable)>"},
- {"saLimit", doSaLimit, 3, "sec set saLimit <port(0..6)> <mode(0:disable,1:enable)> <count(0..4095)>"},
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T secCmds[] =
-{
- {"get", doSecGet, 0, NULL},
- {"set", doSecSet, 0, NULL},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T switchSetCmds[] =
-{
- {"cpuPortEn", doSwitchCpuPortEn, 1, "switch set cpuPortEn <cpu_en(1:En,0:Dis)>"},
- {"cpuPort", doSwitchCpuPort, 1, "switch set cpuPort <port_number>"},
- {"phyLCIntrEn", doSwitchPhyLCIntrEn, 2, "switch set phyLCIntrEn <phy(0..6)> <(1:En,0:Dis)>"},
- {"phyLCIntrSts", doSwitchPhyLCIntrSts, 2, "switch set phyLCIntrSts <phy(0..6)> <(1:Clear)>"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T switchGetCmds[] =
-{
- {"cpuPortEn", doSwitchCpuPortEn, CMD_NO_PARA, "switch get cpuPortEn"},
- {"cpuPort", doSwitchCpuPort, CMD_NO_PARA, "switch get cpuPort"},
- {"phyLCIntrEn", doSwitchPhyLCIntrEn, 1, "switch get phyLCIntrEn <phy(0..6)>"},
- {"phyLCIntrSts", doSwitchPhyLCIntrSts, 1, "switch get phyLCIntrSts <phy(0..6)>"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T switchCmds[] =
-{
- {"set", doSwitchSet, 0, NULL},
- {"get", doSwitchGet, 0, NULL},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T aclSetCmds[] =
-{
- {"en", doAclEn, 1, "acl set en <en(1:En,0:Dis)>"},
- {"rule", doAclRule, CMD_VARIABLE_PARA, "acl set rule <idx(0..127)>\n <state(0:Dis,1:En)> <reverse(0:Dis,1:En)> <end(0:Dis,1:En)>\n <portmap(7'bin)><ipv6(0:Dis,1:En,2:Not care)>\n[ dmac <dmac(12'hex)> <dmac_mask(12'hex)> ]\n[ smac <smac(12'hex)> <smac_mask(12'hex)> ]\n[ stag <stag(4'hex)> <stag_mask(4'hex)> ]\n[ ctag <ctag(4'hex)> <ctag_mask(4'hex)> ]\n[ etype <etype(4'hex)> <etype_mask(4'hex)> ]\n[ dip <dip(IPADDR)> <dip_mask(IPADDR)> ]\n[ sip <sip(IPADDR)> <sip_mask(IPADDR)> ]\n[ dscp <dscp(2'hex)> <dscp_mask(2'hex)> ]\n[ protocol <protocol(12'hex)> <protocol_mask(12'hex)> ]\n[ dport <dport(4'hex)> <dport_mask(4'hex)> ]\n[ sport <sport(4'hex)> <sport_mask(4'hex)> ]\n[ flow_label <flow_label(4'hex)> <flow_label_mask(4'hex)> ]\n[ udf <udf(4'hex)> <udf_mask(4'hex)> ] "},
- {"udfRule", doAclUdfRule, 7, "acl set udfRule <idx(0..15)> <mode(0:pattern, 1:threshold)> [ <pat(4'hex)> <mask(4'hex)> | <low(4'hex)> <high(4'hex)> ] <start(0:MAC header, 1:L2 payload, 2:IPv4 header, 3:IPv6 header, 4:L3 payload, 5:TCP header, 6:UDP header, 7: L4 payload)> <offset(0..127,unit:2 bytes)> <portmap(7'bin)>"},
- {"action", doAclAction, CMD_VARIABLE_PARA, "acl set action <idx(0..127)> \n[ forward <forward(0:Default,4:Exclude CPU,5:Include CPU,6:CPU only,7:Drop)> ]\n[ egtag <egtag(0:Default,1:Consistent,4:Untag,5:Swap,6:Tag,7:Stack)> ]\n[ mirrormap <mirrormap(2'bin)> ]\n[ priority <priority(0..7)> ]\n[ redirect <redirect(0:Dst,1:Vlan)> <portmap(7'bin)> ]\n[ leaky_vlan <leaky_vlan(1:En,0:Dis)> ]\n[ cnt_idx <cnt_idx(0..63)> ]\n[ rate_idx <rate_idx(0..31)> ] \n[ attack_idx <attack_idx(0..95)> ] \n[ vid <vid(0..4095)> ] \n[ manage <manage(1:En,0:Dis)> ] \n[ bpdu <bpdu(1:En,0:Dis)> ]\n[ class <class(0:Original,1:Defined)>[0..7] ]\n[ drop_pcd <drop_pcd(0:Original,1:Defined)> [red <red(0..7)>][yellow <yellow(0..7)>][green <green(0..7)>] ]\n[ color <color(0:Defined,1:Trtcm)> [ <defined_color(0:Dis,1:Green,2:Yellow,3:Red)> | <trtcm_idx(0..31)> ] ]"},
- {"trtcm", doAclTrtcm, 5, "acl set trtcm <idx(1..31)> <cir(4'hex)> <pir(4'hex)> <cbs(4'hex)> <pbs(4'hex)>"},
- {"trtcmEn", doAclTrtcmEn, 1, "acl set trtcmEn <en(1:En,0:Dis)>"},
- {"portEn", doAclPortEn, 2, "acl set portEn <port(0..6)> <en(1:En,0:Dis)>"},
- {"dropEn", doAclDropEn, 2, "acl set dropEn <port(0..6)> <en(1:En,0:Dis)>"},
- {"dropThrsh", doAclDropThrsh, 5, "acl set dropThrsh <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)> <high(0..2047)> <low(0..2047)>"},
- {"dropPbb", doAclDropPbb, 4, "acl set dropPbb <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)> <probability(0..1023)>"},
- {"meter", doAclMeter, 3, "acl set meter <idx(0..31)> <en(1:En,0:Dis)> <rate(0..65535)>\n Note: Limit rate = rate * 64Kbps"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T aclGetCmds[] =
-{
- {"en", doAclEn, CMD_NO_PARA, "acl get en"},
- {"rule", doAclRule, 1, "acl get rule <idx(0..127)> "},
- {"udfRule", doAclUdfRule, 1, "acl get udfRule <idx(0..15)>"},
- {"action", doAclAction, 1, "acl get action <idx(0..127)>"},
- {"trtcm", doAclTrtcm, 1, "acl get trtcm <idx(1..31)>"},
- {"trtcmEn", doAclTrtcmEn, CMD_NO_PARA, "acl get trtcmEn"},
- {"portEn", doAclPortEn, 1, "acl get portEn <port(0..6)>"},
- {"dropEn", doAclDropEn, 1, "acl get dropEn <port(0..6)>"},
- {"dropThrsh", doAclDropThrsh, 3, "acl get dropThrsh <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)>"},
- {"dropPbb", doAclDropPbb, 3, "acl get dropPbb <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)>"},
- {"meter", doAclMeter, 1, "acl get meter <idx(0..31)>"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T aclDelCmds[] =
-{
- {"rule", doAclRmvRule, 1, "acl del rule <idx(0..127)>"},
- {"udfRule", doAclRmvUdfRule, 1, "acl del udfRule <idx(0..15)>"},
- {"action", doAclRmvAction, 1, "acl del action <idx(0..127)>"},
- {"trtcm", doAclRmvTrtcm, 1, "acl del trtcm <idx(0..31)>"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T aclClearCmds[] =
-{
- {"rule", doAclRmvRule, CMD_NO_PARA, "acl clear rule"},
- {"udfRule", doAclRmvUdfRule, CMD_NO_PARA, "acl clear udfRule"},
- {"action", doAclRmvAction, CMD_NO_PARA, "acl clear action"},
- {"trtcm", doAclRmvTrtcm, CMD_NO_PARA, "acl clear trtcm"},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T aclCmds[] =
-{
- {"set", doAclSet, 0, NULL},
- {"get", doAclGet, 0, NULL},
- {"del", doAclDel, 0, NULL},
- {"clear", doAclClear, 0, NULL},
- {"dump", doAclDump, 0, NULL},
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-static AIR_CMD_T Cmds[] =
-{
- {"reg", doReg, 0, NULL},
- {"phy", doPhy, 0, NULL},
- {"port", doPort, 0, NULL},
- {"vlan", doVlan, 0, NULL},
- {"l2", doL2, 0, NULL},
- {"lag", doLag, 0, NULL},
- {"stp", doStp, 0, NULL},
- {"mirror", doMirror, 0, NULL},
- {"mib", doMib, 0, NULL},
- {"qos", doQos, 0, NULL},
- {"diag", doDiag, 0, NULL},
- {"led", doLed, 0, NULL},
- {"switch", doSwitch, 0, NULL},
- {"show", doShow, 0, NULL},
- {"sec", doSec, 0, NULL},
- {"acl", doAcl, 0, NULL},
- {"sptag", doSptag, 0, NULL},
-
- /* last entry, do not modify this entry */
- {NULL, NULL, 0, NULL},
-};
-
-/* EXPORTED SUBPROGRAM BODIES
-*/
-
-/* LOCAL SUBPROGRAM BODIES
-*/
-static BOOL_T
-_strcmp(const char *s1, const char *s2)
-{
- while(*s1 == *s2++)
- if (*s1++ == '\0')
- return (0);
- return (*(const unsigned char *)s1 - *(const unsigned char *)(s2 -1));
-}
-
-static C8_T *
-_strtok_r(
- C8_T *s,
- const C8_T *delim,
- C8_T **last)
-{
- char *spanp;
- int c = 0, sc = 0;
- char *tok;
-
- if (s == NULL && (s = *last) == NULL)
- {
- return (NULL);
- }
-
- /*
- * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
- */
- for (;;)
- {
- c = *s++;
- spanp = (char *)delim;
- do
- {
- if (c == (sc = *spanp++))
- {
- break;
- }
- } while (sc != 0);
- if (sc == 0)
- {
- break;
- }
- }
-
- if (c == 0)
- { /* no non-delimiter characters */
- *last = NULL;
- return (NULL);
- }
- tok = s - 1;
-
- /*
- * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
- * Note that delim must have one NUL; we stop if we see that, too.
- */
- for (;;)
- {
- c = *s++;
- spanp = (char *)delim;
- do
- {
- if ((sc = *spanp++) == c)
- {
- if (c == 0)
- {
- s = NULL;
- }
- else
- {
- s[-1] = 0;
- }
- *last = s;
- return (tok);
- }
- } while (sc != 0);
- }
- /* NOTREACHED */
-}
-
-static C8_T *
-_strtok(
- C8_T *s,
- const C8_T *delim,
- C8_T **last)
-{
- return _strtok_r(s, delim, last);
-}
-
-UI32_T
-_strtoul(
- const C8_T *cp,
- C8_T **endp,
- UI32_T base)
-{
- UI32_T result = 0, value = 0;
-
- if (!base)
- {
- base = 10;
- if (*cp == '0')
- {
- base = 8;
- cp++;
- if ((TOLOWER(*cp) == 'x') && isxdigit(cp[1]))
- {
- cp++;
- base = 16;
- }
- }
- }
- else if (base == 16)
- {
- if (cp[0] == '0' && TOLOWER(cp[1]) == 'x')
- {
- cp += 2;
- }
- }
- while (isxdigit(*cp) &&
- (value = isdigit(*cp) ? *cp-'0' : TOLOWER(*cp)-'a'+10) < base)
- {
- result = result*base + value;
- cp++;
- }
- if (endp)
- {
- *endp = (char *)cp;
- }
- return result;
-}
-
-static I32_T
-_strtol(
- const C8_T *cp,
- C8_T **endp,
- UI32_T base)
-{
- if(*cp=='-')
- {
- return -_strtoul(cp + 1, endp, base);
- }
- return _strtoul(cp, endp, base);
-}
-
-static AIR_ERROR_NO_T
-_str2mac(
- C8_T *str,
- C8_T *mac)
-{
- UI32_T i = 0;
- C8_T tmpstr[3];
-
- /* check str */
- AIR_CHECK_PTR(str);
- AIR_PARAM_CHK(strlen(str) != AIR_MAC_LEN, AIR_E_BAD_PARAMETER);
- AIR_CHECK_PTR(mac);
-
- for(i=0; i<6; i++)
- {
- strncpy(tmpstr, str+(i*2), 2);
- tmpstr[2] = '\0';
- mac[i] = _strtoul(tmpstr, NULL, 16);
- }
-
- return AIR_E_OK;
-}
-
-static AIR_ERROR_NO_T
-_str2ipv4(
- const C8_T *ptr_str,
- UI32_T *ptr_addr)
-{
- UI32_T value = 0, idx = 0, shift = 0;
-
- AIR_CHECK_PTR(ptr_str);
- AIR_CHECK_PTR(ptr_addr);
-
- /* e.g. 192.168.1.2, strlen = 11 */
- for (idx = 0; idx < strlen(ptr_str); idx++)
- {
- if (('0' <= ptr_str[idx]) && ('9' >= ptr_str[idx]))
- {
- value = (value * 10) + (ptr_str[idx] - '0');
- }
- else if ('.' == ptr_str[idx])
- {
- CMD_CHECK_PARA(value, <, 256); /* Error: invalid value */
- CMD_CHECK_PARA(shift, <, 4); /* Error: mem-overwrite */
- *ptr_addr |= value << (24 - shift * 8);
- shift += 1;
- value = 0;
- }
- else
- {
- return AIR_E_BAD_PARAMETER; /* Error: not a digit number or dot */
- }
- }
- CMD_CHECK_PARA(value, <, 256); /* Error: invalid value */
- CMD_CHECK_PARA(shift, ==, 3); /* Error: not an ipv4 addr */
- *ptr_addr |= value << (24 - shift * 8);
-
- return AIR_E_OK;
-}
-
-AIR_ERROR_NO_T
-_str2ipv6(
- const C8_T *ptr_str,
- UI8_T *ptr_addr)
-{
- UI32_T hex_value = 0, dec_value = 0, idx = 0;
- BOOL_T double_colon = FALSE, ipv4_compatible = FALSE;
- UI32_T double_colon_pos = 0, last_pos = 0;
- UI8_T tmp_ipv6[16] = {0};
-
- AIR_CHECK_PTR(ptr_str);
- AIR_CHECK_PTR(ptr_addr);
-
- /* e.g. invalid:
- * 3ffe::c0a8:0: last cannot be colon except double-colon
- * 3ffe:::c0a8:0 triple-colon
- * 3ffe::c0a8::0 two double-colons
- */
-
- /* e.g. valid:
- * 3ffe::c0a8:0 strlen = 12 (double-colon in middle)
- * 3ffe:c0a8:0:: strlen = 13 (double-colon in last)
- * ::3ffe:c0a8:0 strlen = 13 (double-colon in first)
- * 3ffe::192.168.0.0 strlen = 17 (IPv4-compatible address)
- */
- for (idx = 0; idx < strlen(ptr_str); idx++)
- {
- if (('0' <= ptr_str[idx]) && ('9' >= ptr_str[idx]))
- {
- hex_value = (hex_value << 4) + (ptr_str[idx] - '0');
- dec_value = (dec_value * 10) + (ptr_str[idx] - '0');
- }
- else if (('a' <= ptr_str[idx]) && ('f' >= ptr_str[idx]))
- {
- hex_value = (hex_value << 4) + (ptr_str[idx] - 'a') + 10;
- }
- else if (('A' <= ptr_str[idx]) && ('F' >= ptr_str[idx]))
- {
- hex_value = (hex_value << 4) + (ptr_str[idx] - 'A') + 10;
- }
- else if (':' == ptr_str[idx])
- {
- /* must belong to double-colon, calculate from last */
- if (0 == idx)
- {
- continue;
- }
- /* not the first ch but a double-colon */
- else if (':' == ptr_str[idx - 1])
- {
- CMD_CHECK_PARA(double_colon, ==, FALSE); /* Error: triple-colon or two double-colons */
- double_colon = TRUE;
- }
- /* not the first ch and a double-colon */
- else
- {
- CMD_CHECK_PARA(double_colon_pos, <, 15); /* Error: only 16 units for UI8_T */
- CMD_CHECK_PARA(last_pos, <, 15); /* Error: only 16 units for UI8_T */
- tmp_ipv6[last_pos] = (UI8_T)((hex_value >> 8) & 0xff);
- tmp_ipv6[last_pos + 1] = (UI8_T)((hex_value >> 0) & 0xff);
- double_colon_pos += (FALSE == double_colon)? 2 : 0;
- last_pos += 2;
- hex_value = 0;
- dec_value = 0;
- }
- }
- else if ('.' == ptr_str[idx])
- {
- CMD_CHECK_PARA(last_pos, <, 16); /* Error: only 16 units for UI8_T */
- tmp_ipv6[last_pos] = dec_value;
- last_pos += 1;
- dec_value = 0;
- ipv4_compatible = TRUE;
- }
- else
- {
- return AIR_E_BAD_PARAMETER; /* Error: not a hex number or colon */
- }
- }
-
- /* last data */
- if (':' != ptr_str[idx - 1])
- {
- if (FALSE == ipv4_compatible)
- {
- CMD_CHECK_PARA(last_pos, <, 15); /* Error: only 16 units for UI8_T */
- tmp_ipv6[last_pos] = (UI8_T)((hex_value >> 8) & 0xff);
- tmp_ipv6[last_pos + 1] = (UI8_T)((hex_value >> 0) & 0xff);
- last_pos += 2;
- }
- else
- {
- CMD_CHECK_PARA(last_pos, <, 16); /* Error: only 16 units for UI8_T */
- tmp_ipv6[last_pos] = dec_value;
- last_pos += 1;
- }
- }
- else
- {
- if (':' != ptr_str[idx - 2])
- {
- return AIR_E_BAD_PARAMETER; /* Error: last cannot be colon except double-colon */
- }
- }
-
- /* move tmp_ipv6 to ptr_value */
- if (TRUE == double_colon)
- {
- /* e.g.
- * 3ffe::c0a8:0 double_colon_pos = 2, last_pos = 4+2, tmp_ipv6 = {3f,fe,c0,a8,00,00,...}
- * 3ffe:c0a8:0:: double_colon_pos = 6, last_pos = 6, tmp_ipv6 = {3f,fe,c0,a8,00,00,...}
- * ::3ffe:c0a8:0 double_colon_pos = 0, last_pos = 4+2, tmp_ipv6 = {3f,fe,c0,a8,00,00,...}
- * 3ffe::192.168.0.0 double_colon_pos = 2, last_pos = 5+1, tmp_ipv6 = {3f,fe,c0,a8,00,00,...}
- *
- * 0 1 2 3 4 5 6 7 8 9 a b c d e f
- * 3ffe::c0a8:0 ptr_value = {3f,fe,--,--,--,--,--,--,--,--,--,--,--,--,--,--}
- * 3ffe:c0a8:0:: ptr_value = {3f,fe,c0,a8,00,00,--,--,--,--,--,--,--,--,--,--}
- * ::3ffe:c0a8:0 ptr_value = {--,--,--,--,--,--,--,--,--,--,--,--,--,--,--,--}
- * 3ffe::192.168.0.0 ptr_value = {3f,fe,--,--,--,--,--,--,--,--,--,--,--,--,--,--}
- */
- for (idx = 0; idx < double_colon_pos; idx++)
- {
- ptr_addr[idx] = tmp_ipv6[idx];
- }
- /* e.g.
- * 0 1 2 3 4 5 6 7 8 9 a b c d e f
- * 3ffe::c0a8:0 ptr_value = {3f,fe,--,--,--,--,--,--,--,--,--,--,c0,a8,00,00}
- * 3ffe:c0a8:0:: ptr_value = {3f,fe,c0,a8,00,00,--,--,--,--,--,--,--,--,--,--}
- * ::3ffe:c0a8:0 ptr_value = {--,--,--,--,--,--,--,--,--,--,3f,fe,c0,a8,00,00}
- * 3ffe::192.168.0.0 ptr_value = {3f,fe,--,--,--,--,--,--,--,--,--,--,c0,a8,00,00}
- */
- for (idx = double_colon_pos; idx < last_pos; idx++)
- {
- ptr_addr[16 - (last_pos - idx)] = tmp_ipv6[idx];
- }
- }
- else
- {
- for (idx = 0; idx < 16; idx++)
- {
- ptr_addr[idx] = tmp_ipv6[idx];
- }
- }
-
- return AIR_E_OK;
-}
-
-void
-_showIpv6Str(
- const UI8_T *ptr_ipv6,
- C8_T *ptr_str)
-{
- UI32_T idx = 0, next = 0, last = 16;
- UI32_T cont_zero = 0;
-
- while (idx < last)
- {
- if ((0 == cont_zero) && (0 == ptr_ipv6[idx]) && (0 == ptr_ipv6[idx + 1]))
- {
- next = idx + 2;
-
- while (next < last)
- {
- if ((ptr_ipv6[next]) || (ptr_ipv6[next + 1]))
- {
- AIR_PRINT(
- ptr_str + strlen(ptr_str),
- 40 - strlen(ptr_str),
- "%s", (cont_zero) ? (":") : (":0"));
- break;
- }
-
- if (0 == cont_zero)
- {
- cont_zero = 1;
- }
- next += 2;
- }
-
- if (next == last)
- {
-
- AIR_PRINT(
- ptr_str + strlen(ptr_str),
- 40 - strlen(ptr_str),
- "%s", (cont_zero) ? ("::") : (":0"));
- }
-
- idx = next;
- }
- else
- {
- if (idx)
- {
- AIR_PRINT(
- ptr_str + strlen(ptr_str),
- 40 - strlen(ptr_str),
- ":");
- }
-
- if (ptr_ipv6[idx])
- {
- AIR_PRINT(
- ptr_str + strlen(ptr_str),
- 40 - strlen(ptr_str),
- "%0x%02x", ptr_ipv6[idx], ptr_ipv6[idx + 1]);
- }
- else
- {
- AIR_PRINT(
- ptr_str + strlen(ptr_str),
- 40 - strlen(ptr_str),
- "%0x", ptr_ipv6[idx + 1]);
- }
-
- idx += 2;
- }
- }
-}
-
-static AIR_ERROR_NO_T
-_hex2bit(
- const UI32_T hex,
- UI32_T *ptr_bit)
-{
- UI32_T i = 0;
-
- /* Mistake proofing */
- AIR_CHECK_PTR(ptr_bit);
-
- (*ptr_bit) = 0;
- for(i=0; i<AIR_MAX_NUM_OF_PORTS; i++)
- {
- if(hex & BIT(i))
- {
- (*ptr_bit) |= BITS_OFF_L(1UL, 4*(AIR_MAX_NUM_OF_PORTS - i - 1), 4);
- }
- }
- return AIR_E_OK;
-}
-
-static AIR_ERROR_NO_T
-_hex2bitstr(
- const UI32_T hex,
- C8_T *ptr_bit_str,
- UI32_T str_len)
-{
- UI32_T i = 0;
- C8_T str_bitmap[AIR_MAX_NUM_OF_PORTS+1];
-
- /* Mistake proofing */
- AIR_CHECK_PTR(ptr_bit_str);
- AIR_PARAM_CHK(str_len <= AIR_MAX_NUM_OF_PORTS, AIR_E_BAD_PARAMETER);
-
- memset(str_bitmap, 0, AIR_MAX_NUM_OF_PORTS+1);
-
- for(i=0; i<AIR_MAX_NUM_OF_PORTS; i++)
- {
- if(hex & BIT(i))
- {
- str_bitmap[i] = '1';
- }
- else
- {
- str_bitmap[i] = '-';
- }
- }
- str_bitmap[i] = '\0';
- strncpy(ptr_bit_str, str_bitmap, i+1);
-
- return AIR_E_OK;
-}
-
-static AIR_ERROR_NO_T
-_portListStr2Ary(
- const C8_T *str,
- UI32_T *ary,
- const UI32_T ary_num)
-{
- UI32_T i = 0;
- UI32_T str_len = 0;
- UI32_T val = 0;
- C8_T *str2;
- C8_T *pch;
- C8_T *last;
-
- /* Mistake proofing */
- AIR_CHECK_PTR(str);
- AIR_CHECK_PTR(ary);
- AIR_PARAM_CHK(0 == ary_num, AIR_E_BAD_PARAMETER);
-
- /* Allocate new string */
- str_len = strlen(str);
- str2 = AIR_MALLOC(str_len+1);
- AIR_CHECK_PTR(str2);
- memset(str2, 0, str_len+1);
- strncpy(str2, str, str_len+1);
-
- /* clear array */
- memset(ary, 0, ary_num*4);
-
- /* split string by ',' */
- pch = _strtok(str2, ",", &last);
- while(NULL != pch)
- {
- val = _strtoul(pch, NULL, 0);
- ary[val/32] |= BIT(val%32);
- pch = _strtok(NULL, ",", &last);
- }
-
- AIR_FREE(str2);
- return AIR_E_OK;
-}
-
-static AIR_ERROR_NO_T
-doRegRead(
- UI32_T argc,
- C8_T *argv[])
-{
- UI32_T reg = 0, val = 0;
-
- reg = _strtoul(argv[0], NULL, 16);
- aml_readReg(0, reg, &val);
- AIR_PRINT("Read reg=0x%x, value=0x%x\n", reg, val);
-
- return AIR_E_OK;
-}
-
-static AIR_ERROR_NO_T
-doRegWrite(
- UI32_T argc,
- C8_T *argv[])
-{
- UI32_T reg = 0, val = 0;
-
- reg = _strtoul(argv[0], NULL, 16);
- val = _strtoul(argv[1], NULL, 16);
- aml_writeReg(0, reg, val);
- AIR_PRINT("Write reg=0x%x, value=0x%x\n", reg, val);
-
- return AIR_E_OK;
-}
-
-static AIR_ERROR_NO_T
-doReg(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(regCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doPhyCL22Read(
- UI32_T argc,
- C8_T *argv[])
-{
- UI32_T port = 0, reg = 0, val = 0;
-
- port = _strtoul(argv[0], NULL, 0);
- reg = _strtoul(argv[1], NULL, 16);
- aml_readPhyReg(0, port, reg, &val);
- AIR_PRINT("Phy read port=%d, reg=0x%x, value=0x%x\n", port, reg, val);
-
- return AIR_E_OK;
-}
-
-static AIR_ERROR_NO_T
-doPhyCL22Write(
- UI32_T argc,
- C8_T *argv[])
-{
- UI32_T port = 0, reg = 0, val = 0;
-
- port = _strtoul(argv[0], NULL, 0);
- reg = _strtoul(argv[1], NULL, 16);
- val = _strtoul(argv[2], NULL, 16);
- aml_writePhyReg(0, port, reg, val);
- AIR_PRINT("Phy write port=%d, reg=0x%x, value=0x%x\n", port, reg, val);
-
- return AIR_E_OK;
-}
-
-static AIR_ERROR_NO_T
-doPhyCL22(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(phyCL22Cmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doPhyCL45Read(
- UI32_T argc,
- C8_T *argv[])
-{
- UI32_T port = 0, dev = 0, reg = 0, val = 0;
-
- port = _strtoul(argv[0], NULL, 0);
- dev = _strtoul(argv[1], NULL, 16);
- reg = _strtoul(argv[2], NULL, 16);
- aml_readPhyRegCL45(0, port, dev, reg, &val);
- AIR_PRINT("Phy read port=%d, dev=0x%x, reg=0x%x, value=0x%x\n", port, dev, reg, val);
-
- return AIR_E_OK;
-}
-
-static AIR_ERROR_NO_T
-doPhyCL45Write(
- UI32_T argc,
- C8_T *argv[])
-{
- UI32_T port = 0, dev = 0, reg = 0, val = 0;
-
- port = _strtoul(argv[0], NULL, 0);
- dev = _strtoul(argv[1], NULL, 16);
- reg = _strtoul(argv[2], NULL, 16);
- val = _strtoul(argv[3], NULL, 16);
- aml_writePhyRegCL45(0, port, dev, reg, val);
- AIR_PRINT("Phy write port=%d, dev=0x%x, reg=0x%x, value=0x%x\n", port, dev, reg, val);
-
- return AIR_E_OK;
-}
-
-static AIR_ERROR_NO_T
-doPhyCL45(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(phyCL45Cmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doPhy(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(phyCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doPortSetMatrix(UI32_T argc, C8_T *argv[])
-{
- UI32_T port = 0;
- UI32_T matrix = 0;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- port = _strtoul(argv[0], NULL, 0);
- matrix = _strtoul(argv[1], NULL, 16);
- rc = air_port_setPortMatrix(0, port, matrix);
- if (rc != AIR_E_OK)
- {
- AIR_PRINT("Error: Operation failed!\n");
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doPortSetVlanMode(UI32_T argc, C8_T *argv[])
-{
- UI32_T port = 0;
- AIR_PORT_VLAN_MODE_T vlan_mode;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- port = _strtoul(argv[0], NULL, 0);
- vlan_mode = _strtoul(argv[1], NULL, 0);
- rc = air_port_setVlanMode(0, port, vlan_mode);
- if (rc != AIR_E_OK)
- {
- AIR_PRINT("Error: Operation failed!\n");
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doPortSet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(portSetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doPortGetMatrix(UI32_T argc, C8_T *argv[])
-{
- UI32_T port = 0;
- UI32_T matrix = 0;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- port = _strtoul(argv[0], NULL, 0);
- rc = air_port_getPortMatrix(0, port, &matrix);
- if (rc != AIR_E_OK)
- {
- AIR_PRINT("Error: Operation failed!\n");
- return rc;
- }
- AIR_PRINT("Port %d Matrix: %2x\n", port, matrix);
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doPortGetVlanMode(UI32_T argc, C8_T *argv[])
-{
- UI32_T port = 0;
- AIR_PORT_VLAN_MODE_T vlan_mode;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- port = _strtoul(argv[0], NULL, 0);
- rc = air_port_getVlanMode(0, port, &vlan_mode);
- if (rc != AIR_E_OK)
- {
- AIR_PRINT("Error: Operation failed!\n");
- return rc;
- }
- AIR_PRINT("Port %d Vlan Mode: ", port);
- switch(vlan_mode)
- {
- case AIR_PORT_VLAN_MODE_PORT_MATRIX:
- AIR_PRINT("matrix(%d)\n", vlan_mode);
- break;
- case AIR_PORT_VLAN_MODE_FALLBACK:
- AIR_PRINT("fallback(%d)\n", vlan_mode);
- break;
- case AIR_PORT_VLAN_MODE_CHECK:
- AIR_PRINT("check(%d)\n", vlan_mode);
- break;
- case AIR_PORT_VLAN_MODE_SECURITY:
- AIR_PRINT("security(%d)\n", vlan_mode);
- break;
- default:
- AIR_PRINT("unknown(%d)\n", vlan_mode);
- break;
- };
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doPortGet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(portGetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doPort(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(portCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doVlanInitiate(UI32_T argc, C8_T *argv[])
-{
- UI16_T vid = 0;
- AIR_VLAN_ENTRY_ATTR_T vlan_entry = {0};
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- vid = _strtoul(argv[0], NULL, 0);
- if (9 == argc)
- {
- vlan_entry.vlan_entry_format.fid = _strtoul(argv[1], NULL, 0);
- vlan_entry.vlan_entry_format.port_mem = _strtoul(argv[2], NULL, 0);
- vlan_entry.vlan_entry_format.ivl = _strtoul(argv[3], NULL, 0);
- vlan_entry.vlan_entry_format.port_stag = _strtoul(argv[4], NULL, 0);
- vlan_entry.vlan_entry_format.stag = _strtoul(argv[5], NULL, 0);
- vlan_entry.vlan_entry_format.eg_ctrl_en = _strtoul(argv[6], NULL, 0);
- vlan_entry.vlan_entry_format.eg_con = _strtoul(argv[7], NULL, 0);
- vlan_entry.vlan_entry_format.eg_ctrl = _strtoul(argv[8], NULL, 0);
-
- rc = air_vlan_create(0, vid, &vlan_entry);
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- rc = AIR_E_BAD_PARAMETER;
- }
-
- switch (rc)
- {
- case AIR_E_OK: break;
- case AIR_E_ENTRY_EXISTS: AIR_PRINT("VLAN already exist!\n"); break;
- default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanCreate(UI32_T argc, C8_T *argv[])
-{
- UI16_T vid = 0;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- vid = _strtoul(argv[0], NULL, 0);
- rc = air_vlan_create(0, vid, NULL);
-
- switch (rc)
- {
- case AIR_E_OK: break;
- case AIR_E_ENTRY_EXISTS: AIR_PRINT("VLAN already exist!\n"); break;
- default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanDestroy(UI32_T argc, C8_T *argv[])
-{
- C8_T *token = NULL;
- UI16_T vid = 0, vid_limit = AIR_VLAN_ID_MAX;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- if (argc > 0)
- {
- if (isdigit(argv[0][0]))
- {
- token = _strtok(argv[0], "-", &argv[0]);
- vid = _strtoul(token, NULL, 0);
- if ((token = _strtok(argv[0], "-", &argv[0])))
- vid_limit = _strtoul(token, NULL, 0);
- else
- vid_limit = vid;
- if (AIR_VLAN_ID_MAX < vid_limit)
- {
- AIR_PRINT("vid number should less than %d!\n", AIR_VLAN_ID_MAX);
- return AIR_E_BAD_PARAMETER;
- }
- if (vid > vid_limit)
- {
- AIR_PRINT("vid0 should less than vid1!\n");
- return AIR_E_BAD_PARAMETER;
- }
- }
- else
- {
- AIR_PRINT("Bad parameter!\n");
- return AIR_E_BAD_PARAMETER;
- }
- }
-
- for (; vid <= vid_limit; vid++)
- {
- rc = air_vlan_destroy(0, vid);
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanDestroyAll(UI32_T argc, C8_T *argv[])
-{
- UI32_T restore_def_vlan = 0;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- if (argc > 0)
- {
- restore_def_vlan = _strtoul(argv[0], NULL, 0);
- }
-
- rc = air_vlan_destroyAll(0, restore_def_vlan);
- if (rc != AIR_E_OK)
- {
- AIR_PRINT("Error: Operation failed!\n");
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanDump(UI32_T argc, C8_T *argv[])
-{
- C8_T *token = NULL;
- UI16_T port = 0, valid_count = 0, vid = 0, vid_limit = AIR_VLAN_ID_MAX;
- AIR_PORT_EGS_TAG_ATTR_T tag_ctl[AIR_MAX_NUM_OF_PORTS] = {0};
- AIR_VLAN_ENTRY_T vlan_entry = {0};
-
- if (argc > 0)
- {
- if (isdigit(argv[0][0]))
- {
- token = _strtok(argv[0], "-", &argv[0]);
- vid = _strtoul(token, NULL, 0);
- if ((token = _strtok(argv[0], "-", &argv[0])))
- vid_limit = _strtoul(token, NULL, 0);
- else
- vid_limit = vid;
- if (AIR_VLAN_ID_MAX < vid_limit)
- {
- AIR_PRINT("vid number should less than %d!\n", AIR_VLAN_ID_MAX);
- return AIR_E_BAD_PARAMETER;
- }
- if (vid > vid_limit)
- {
- AIR_PRINT("vid0 should less than vid1!\n");
- return AIR_E_BAD_PARAMETER;
- }
- }
- else
- {
- AIR_PRINT("Bad parameter!\n");
- return AIR_E_BAD_PARAMETER;
- }
- }
-
- for (valid_count = 0; vid <= vid_limit; vid++)
- {
- _air_vlan_readEntry(0, vid, &vlan_entry);
- if (vlan_entry.valid)
- {
- valid_count++;
- if (1 == valid_count)
- AIR_PRINT(" Vid Fid MemPort Ivl PortBaseStag Stag EgsTagCtlEn EgsTagCon EgsTagCtl\n======================================================================\n");
- for (port = 0; port < AIR_MAX_NUM_OF_PORTS; port++)
- tag_ctl[port] = (vlan_entry.vlan_entry_format.eg_ctrl >> (port * 2)) & 0x3;
- AIR_PRINT("%4d %3d %2x %3d %12d %4d %11d %9d %1x%1x%1x%1x%1x%1x%1x\n",
- vid, vlan_entry.vlan_entry_format.fid, vlan_entry.vlan_entry_format.port_mem, vlan_entry.vlan_entry_format.ivl,
- vlan_entry.vlan_entry_format.port_stag, vlan_entry.vlan_entry_format.stag, vlan_entry.vlan_entry_format.eg_ctrl_en, vlan_entry.vlan_entry_format.eg_con,
- tag_ctl[6], tag_ctl[5], tag_ctl[4], tag_ctl[3], tag_ctl[2], tag_ctl[1], tag_ctl[0]);
- }
- }
-
- if (!valid_count)
- AIR_PRINT("not found!\n");
- else
- AIR_PRINT("Found %d valid entries!\n", valid_count);
-
- return AIR_E_OK;
-}
-
-static AIR_ERROR_NO_T
-doVlanAddPortMem(UI32_T argc, C8_T *argv[])
-{
- UI16_T vid = 0, port = 0;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- vid = _strtoul(argv[0], NULL, 0);
- port = _strtoul(argv[1], NULL, 0);
- rc = air_vlan_addMemberPort(0, vid, port);
- switch (rc)
- {
- case AIR_E_OK: break;
- case AIR_E_ENTRY_NOT_FOUND: AIR_PRINT("VLAN not found!\n"); break;
- default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanDelPortMem(UI32_T argc, C8_T *argv[])
-{
- UI16_T vid = 0, port = 0;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- vid = _strtoul(argv[0], NULL, 0);
- port = _strtoul(argv[1], NULL, 0);
- rc = air_vlan_delMemberPort(0, vid, port);
- switch (rc)
- {
- case AIR_E_OK: break;
- case AIR_E_ENTRY_NOT_FOUND: AIR_PRINT("VLAN not found!\n"); break;
- default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanSetFid(UI32_T argc, C8_T *argv[])
-{
- UI16_T vid = 0;
- UI8_T fid = 0;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- vid = _strtoul(argv[0], NULL, 0);
- fid = _strtoul(argv[1], NULL, 0);
- rc = air_vlan_setFid(0, vid, fid);
- switch (rc)
- {
- case AIR_E_OK: break;
- case AIR_E_ENTRY_NOT_FOUND: AIR_PRINT("VLAN not found!\n"); break;
- default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanSetMemPort(UI32_T argc, C8_T *argv[])
-{
- UI16_T vid = 0, port_bitmap = 0;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- vid = _strtoul(argv[0], NULL, 0);
- port_bitmap = _strtoul(argv[1], NULL, 16);
- rc = air_vlan_setMemberPort(0, vid, port_bitmap);
- switch (rc)
- {
- case AIR_E_OK: break;
- case AIR_E_ENTRY_NOT_FOUND: AIR_PRINT("VLAN not found!\n"); break;
- default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanSetIVL(UI32_T argc, C8_T *argv[])
-{
- UI16_T vid = 0;
- BOOL_T enable = TRUE;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- vid = _strtoul(argv[0], NULL, 0);
- enable = _strtoul(argv[1], NULL, 0);
- rc = air_vlan_setIVL(0, vid, enable);
- switch (rc)
- {
- case AIR_E_OK: break;
- case AIR_E_ENTRY_NOT_FOUND: AIR_PRINT("VLAN not found!\n"); break;
- default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanSetPortBaseStag(UI32_T argc, C8_T *argv[])
-{
- UI16_T vid = 0;
- BOOL_T enable = TRUE;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- vid = _strtoul(argv[0], NULL, 0);
- enable = _strtoul(argv[1], NULL, 0);
- rc = air_vlan_setPortBasedStag(0, vid, enable);
- switch (rc)
- {
- case AIR_E_OK: break;
- case AIR_E_ENTRY_NOT_FOUND: AIR_PRINT("VLAN not found!\n"); break;
- default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanSetStag(UI32_T argc, C8_T *argv[])
-{
- UI16_T vid = 0, stag = 0;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- vid = _strtoul(argv[0], NULL, 0);
- stag = _strtoul(argv[1], NULL, 0);
- rc = air_vlan_setServiceTag(0, vid, stag);
- switch (rc)
- {
- case AIR_E_OK: break;
- case AIR_E_ENTRY_NOT_FOUND: AIR_PRINT("VLAN not found!\n"); break;
- default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanSetEgsTagCtlEn(UI32_T argc, C8_T *argv[])
-{
- UI16_T vid = 0;
- BOOL_T enable = TRUE;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- vid = _strtoul(argv[0], NULL, 0);
- enable = _strtoul(argv[1], NULL, 0);
- rc = air_vlan_setEgsTagCtlEnable(0, vid, enable);
- switch (rc)
- {
- case AIR_E_OK: break;
- case AIR_E_ENTRY_NOT_FOUND: AIR_PRINT("VLAN not found!\n"); break;
- default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanSetEgsTagCtlCon(UI32_T argc, C8_T *argv[])
-{
- UI16_T vid = 0;
- BOOL_T enable = TRUE;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- vid = _strtoul(argv[0], NULL, 0);
- enable = _strtoul(argv[1], NULL, 0);
- rc = air_vlan_setEgsTagConsistent(0, vid, enable);
- switch (rc)
- {
- case AIR_E_OK: break;
- case AIR_E_ENTRY_NOT_FOUND: AIR_PRINT("VLAN not found!\n"); break;
- default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanSetEgsTagCtl(UI32_T argc, C8_T *argv[])
-{
- UI16_T vid = 0, port = 0;
- AIR_PORT_EGS_TAG_ATTR_T tag_ctl = AIR_PORT_EGS_TAG_ATTR_UNTAGGED;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- vid = _strtoul(argv[0], NULL, 0);
- port = _strtoul(argv[1], NULL, 0);
- tag_ctl = _strtoul(argv[2], NULL, 0);
- rc = air_vlan_setPortEgsTagCtl(0, vid, port, tag_ctl);
- switch (rc)
- {
- case AIR_E_OK: break;
- case AIR_E_ENTRY_NOT_FOUND: AIR_PRINT("VLAN not found!\n"); break;
- default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanSetPortActFrame(UI32_T argc, C8_T *argv[])
-{
- UI16_T port = 0;
- AIR_VLAN_ACCEPT_FRAME_TYPE_T type = AIR_VLAN_ACCEPT_FRAME_TYPE_ALL;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- port = _strtoul(argv[0], NULL, 0);
- type = _strtoul(argv[1], NULL, 0);
- rc = air_vlan_setPortAcceptFrameType(0, port, type);
- if (rc != AIR_E_OK)
- {
- AIR_PRINT("Error: Operation failed!\n");
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanSetLeakyVlanEn(UI32_T argc, C8_T *argv[])
-{
- UI16_T port = 0;
- AIR_LEAKY_PKT_TYPE_T pkt_type = AIR_LEAKY_PKT_TYPE_UNICAST;
- BOOL_T enable = TRUE;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- port = _strtoul(argv[0], NULL, 0);
- pkt_type = _strtoul(argv[1], NULL, 0);
- enable = _strtoul(argv[2], NULL, 0);
- rc = air_vlan_setPortLeakyVlanEnable(0, port, pkt_type, enable);
- if (rc != AIR_E_OK)
- {
- AIR_PRINT("Error: Operation failed!\n");
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanSetPortVlanAttr(UI32_T argc, C8_T *argv[])
-{
- UI16_T port = 0;
- AIR_VLAN_PORT_ATTR_T attr = AIR_VLAN_PORT_ATTR_USER_PORT;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- port = _strtoul(argv[0], NULL, 0);
- attr = _strtoul(argv[1], NULL, 0);
- rc = air_vlan_setPortAttr(0, port, attr);
- if (rc != AIR_E_OK)
- {
- AIR_PRINT("Error: Operation failed!\n");
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanSetIgsPortETagAttr(UI32_T argc, C8_T *argv[])
-{
- UI16_T port = 0;
- AIR_IGR_PORT_EG_TAG_ATTR_T attr = AIR_IGR_PORT_EG_TAG_ATTR_DISABLE;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- port = _strtoul(argv[0], NULL, 0);
- attr = _strtoul(argv[1], NULL, 0);
- rc = air_vlan_setIgrPortTagAttr(0, port, attr);
- if (rc != AIR_E_OK)
- {
- AIR_PRINT("Error: Operation failed!\n");
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanSetPortETagAttr(UI32_T argc, C8_T *argv[])
-{
- UI16_T port = 0;
- AIR_PORT_EGS_TAG_ATTR_T attr = AIR_PORT_EGS_TAG_ATTR_UNTAGGED;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- port = _strtoul(argv[0], NULL, 0);
- attr = _strtoul(argv[1], NULL, 0);
- rc = air_vlan_setPortEgsTagAttr(0, port, attr);
- if (rc != AIR_E_OK)
- {
- AIR_PRINT("Error: Operation failed!\n");
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanSetPortOuterTPID(UI32_T argc, C8_T *argv[])
-{
- UI16_T port = 0, tpid = 0;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- port = _strtoul(argv[0], NULL, 0);
- tpid = _strtoul(argv[1], NULL, 16);
- rc = air_vlan_setPortOuterTPID(0, port, tpid);
- if (rc != AIR_E_OK)
- {
- AIR_PRINT("Error: Operation failed!\n");
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanSetPvid(UI32_T argc, C8_T *argv[])
-{
- UI16_T port = 0, pvid = 0;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- port = _strtoul(argv[0], NULL, 0);
- pvid = _strtoul(argv[1], NULL, 0);
- rc = air_vlan_setPortPVID(0, port, pvid);
- if (rc != AIR_E_OK)
- {
- AIR_PRINT("Error: Operation failed!\n");
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanSet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(vlanSetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doVlanGetPortActFrame(UI32_T argc, C8_T *argv[])
-{
- UI32_T port = 0;
- AIR_VLAN_ACCEPT_FRAME_TYPE_T type;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- port = _strtoul(argv[0], NULL, 0);
- rc = air_vlan_getPortAcceptFrameType(0, port, &type);
- if (rc != AIR_E_OK)
- {
- AIR_PRINT("Error: Operation failed!\n");
- return rc;
- }
- AIR_PRINT("Port %d Acceptable Frame Type: ", port);
- switch(type)
- {
- case AIR_VLAN_ACCEPT_FRAME_TYPE_ALL:
- AIR_PRINT("all(%d)\n", type);
- break;
- case AIR_VLAN_ACCEPT_FRAME_TYPE_TAG_ONLY:
- AIR_PRINT("tagged-only(%d)\n", type);
- break;
- case AIR_VLAN_ACCEPT_FRAME_TYPE_UNTAG_ONLY:
- AIR_PRINT("untagged-only(%d)\n", type);
- break;
- default:
- AIR_PRINT("unknown(%d)\n", type);
- break;
- };
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanGetLeakyVlanEn(UI32_T argc, C8_T *argv[])
-{
- UI32_T port = 0;
- BOOL_T uc = FALSE, mc = FALSE, bc = FALSE;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- port = _strtoul(argv[0], NULL, 0);
- rc += air_vlan_getPortLeakyVlanEnable(0, port, AIR_LEAKY_PKT_TYPE_UNICAST, &uc);
- rc += air_vlan_getPortLeakyVlanEnable(0, port, AIR_LEAKY_PKT_TYPE_MULTICAST, &mc);
- rc += air_vlan_getPortLeakyVlanEnable(0, port, AIR_LEAKY_PKT_TYPE_BROADCAST, &bc);
- if (rc != AIR_E_OK)
- {
- AIR_PRINT("Error: Operation failed!\n");
- return rc;
- }
-
- AIR_PRINT("Port %d Leaky Vlan Enable\n", port);
- AIR_PRINT("Unicast : %s\n", uc ? "TRUE" : "FALSE");
- AIR_PRINT("Multicast : %s\n", mc ? "TRUE" : "FALSE");
- AIR_PRINT("Broadcast : %s\n", bc ? "TRUE" : "FALSE");
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanGetPortVlanAttr(UI32_T argc, C8_T *argv[])
-{
- UI32_T port = 0;
- AIR_VLAN_PORT_ATTR_T attr;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- port = _strtoul(argv[0], NULL, 0);
- rc = air_vlan_getPortAttr(0, port, &attr);
- if (rc != AIR_E_OK)
- {
- AIR_PRINT("Error: Operation failed!\n");
- return rc;
- }
- AIR_PRINT("Port %d Vlan Attr: ", port);
- switch(attr)
- {
- case AIR_VLAN_PORT_ATTR_USER_PORT:
- AIR_PRINT("user port(%d)\n", attr);
- break;
- case AIR_VLAN_PORT_ATTR_STACK_PORT:
- AIR_PRINT("stack port(%d)\n", attr);
- break;
- case AIR_VLAN_PORT_ATTR_TRANSLATION_PORT:
- AIR_PRINT("translation port(%d)\n", attr);
- break;
- case AIR_VLAN_PORT_ATTR_TRANSPARENT_PORT:
- AIR_PRINT("transparent port(%d)\n", attr);
- break;
- default:
- AIR_PRINT("unknown(%d)\n", attr);
- break;
- };
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanGetIgsPortETagAttr(UI32_T argc, C8_T *argv[])
-{
- UI32_T port = 0;
- AIR_IGR_PORT_EG_TAG_ATTR_T attr;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- port = _strtoul(argv[0], NULL, 0);
- rc = air_vlan_getIgrPortTagAttr(0, port, &attr);
- if (rc != AIR_E_OK)
- {
- AIR_PRINT("Error: Operation failed!\n");
- return rc;
- }
- AIR_PRINT("Port %d Incomming Port Egress Tag Attr: ", port);
- switch(attr)
- {
- case AIR_IGR_PORT_EG_TAG_ATTR_DISABLE:
- AIR_PRINT("disable(%d)\n", attr);
- break;
- case AIR_IGR_PORT_EG_TAG_ATTR_CONSISTENT:
- AIR_PRINT("consistent(%d)\n", attr);
- break;
- case AIR_IGR_PORT_EG_TAG_ATTR_UNTAGGED:
- AIR_PRINT("untagged(%d)\n", attr);
- break;
- case AIR_IGR_PORT_EG_TAG_ATTR_SWAP:
- AIR_PRINT("swap(%d)\n", attr);
- break;
- case AIR_IGR_PORT_EG_TAG_ATTR_TAGGED:
- AIR_PRINT("tagged(%d)\n", attr);
- break;
- case AIR_IGR_PORT_EG_TAG_ATTR_STACK:
- AIR_PRINT("stack(%d)\n", attr);
- break;
- default:
- AIR_PRINT("unknown(%d)\n", attr);
- break;
- };
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanGetPortETagAttr(UI32_T argc, C8_T *argv[])
-{
- UI32_T port = 0;
- AIR_PORT_EGS_TAG_ATTR_T attr;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- port = _strtoul(argv[0], NULL, 0);
- rc = air_vlan_getPortEgsTagAttr(0, port, &attr);
- if (rc != AIR_E_OK)
- {
- AIR_PRINT("Error: Operation failed!\n");
- return rc;
- }
- AIR_PRINT("Port %d Egress Tag Attr: ", port);
- switch(attr)
- {
- case AIR_PORT_EGS_TAG_ATTR_UNTAGGED:
- AIR_PRINT("untagged(%d)\n", attr);
- break;
- case AIR_PORT_EGS_TAG_ATTR_SWAP:
- AIR_PRINT("swap(%d)\n", attr);
- break;
- case AIR_PORT_EGS_TAG_ATTR_TAGGED:
- AIR_PRINT("tagged(%d)\n", attr);
- break;
- case AIR_PORT_EGS_TAG_ATTR_STACK:
- AIR_PRINT("stack(%d)\n", attr);
- break;
- default:
- AIR_PRINT("unknown(%d)\n", attr);
- break;
- };
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanGetPortOuterTPID(UI32_T argc, C8_T *argv[])
-{
- UI32_T port = 0;
- UI16_T tpid = 0;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- port = _strtoul(argv[0], NULL, 0);
- rc = air_vlan_getPortOuterTPID(0, port, &tpid);
- if (rc != AIR_E_OK)
- {
- AIR_PRINT("Error: Operation failed!\n");
- return rc;
- }
- AIR_PRINT("Port %d Outer TPID: %4x\n", port, tpid);
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanGetPvid(UI32_T argc, C8_T *argv[])
-{
- UI32_T port = 0;
- UI16_T pvid = 0;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- port = _strtoul(argv[0], NULL, 0);
- rc = air_vlan_getPortPVID(0, port, &pvid);
- if (rc != AIR_E_OK)
- {
- AIR_PRINT("Error: Operation failed!\n");
- return rc;
- }
- AIR_PRINT("Port %d PVID: %d\n", port, pvid);
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doVlanGet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(vlanGetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doVlan(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(vlanCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doJumbo(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- I32_T pkt_len = 0, frame_len = 0;
-
- if(0 == argc)
- {
- /* get command */
- ret = air_port_getJumbo(0, &pkt_len, &frame_len);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Get ");
- switch(pkt_len)
- {
- case 0:
- AIR_PRINT("RX_1518 ");
- break;
- case 1:
- AIR_PRINT("RX_1536 ");
- break;
- case 2:
- AIR_PRINT("RX_1552 ");
- break;
- case 3:
- AIR_PRINT("RX_JUMBO ");
- break;
- }
- AIR_PRINT("frames lengths %d KBytes\n", frame_len);
- }
- else
- {
- AIR_PRINT("Get Jumbo Fail.\n");
- }
- }
- else
- {
- /* set command */
- pkt_len = _strtol(argv[0], NULL, 10);
- frame_len = _strtol(argv[1], NULL, 10);
-
- ret = air_port_setJumbo(0, pkt_len, frame_len);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Set ");
- switch(pkt_len)
- {
- case 0:
- AIR_PRINT("RX_1518 ");
- break;
- case 1:
- AIR_PRINT("RX_1536 ");
- break;
- case 2:
- AIR_PRINT("RX_1552 ");
- break;
- case 3:
- AIR_PRINT("RX_JUMBO ");
- break;
- }
- AIR_PRINT("frames lengths %d KBytes\n", frame_len);
- }
- else
- AIR_PRINT("Set Jumbo Fail.\n");
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doFlowCtrl(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- BOOL_T fc_en = 0, dir = 0;
- I32_T port = 0;
-
- port = _strtol(argv[0], NULL, 10);
- dir = _strtol(argv[1], NULL, 10);
-
- if(2 == argc)
- {
- /* get command */
- ret = air_port_getFlowCtrl(0, port, dir, &fc_en);
- if(ret == AIR_E_OK)
- AIR_PRINT("Get Port%02d %s Flow Control %s\n", port, ((dir)?"RX":"TX"), ((fc_en)?"Enable":"Disable"));
- else
- AIR_PRINT("Get Flow Control Fail.\n");
- }
- else
- {
- /* set command */
- fc_en = _strtol(argv[2], NULL, 10);
-
- ret = air_port_setFlowCtrl(0, port, dir, fc_en);
- if(ret == AIR_E_OK)
- AIR_PRINT("Set Port%02d %s Flow Control %s\n", port, ((dir)?"RX":"TX"), ((fc_en)?"Enable":"Disable"));
- else
- AIR_PRINT("Set Flow Control Fail.\n");
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doL2Set(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(l2SetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doL2Get(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(l2GetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doL2Clear(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(l2ClearCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doL2Del(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(l2DelCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doL2Add(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(l2AddCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doL2(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(l2Cmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doAnMode(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T port = 0;
- BOOL_T en = 0;
-
- port = _strtol(argv[0], NULL, 10);
-
- if(1 == argc)
- {
- /* port get anCap <port> */
- ret = air_port_getAnMode(0, port, &en);
- if(ret == AIR_E_OK)
- AIR_PRINT("Get Port%02d Auto-Negotiation %s\n", port, ((en)?"Enabled":"Disabled"));
- else
- AIR_PRINT("Get Port%02d Auto-Negotiation Fail.\n", port);
- }
- else if(2 == argc)
- {
- /* "port set anMode <port> <en> */
- en = _strtol(argv[1], NULL, 10);
- ret = air_port_setAnMode(0, port, en);
- if(ret == AIR_E_OK)
- AIR_PRINT("Set Port%02d Auto-Negotiation Mode:%s\n", port, ((en)?"Enabled":"Disabled"));
- else
- AIR_PRINT("Set Port%02d Auto-Negotiation Fail.\n", port);
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doLocalAdv(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T port = 0;
- AIR_AN_ADV_T adv;
-
- memset(&adv, 0, sizeof(AIR_AN_ADV_T));
- port = _strtol(argv[0], NULL, 10);
-
- if(1 == argc)
- {
- /* port get localAdv <port> */
- ret = air_port_getLocalAdvAbility(0, port, &adv);
- AIR_PRINT("Get Port%02d Local Auto-Negotiation Advertisement: ", port);
- if(AIR_E_OK != ret)
- {
- AIR_PRINT("Fail!\n");
- }
- }
- else if(7 == argc)
- {
- /* port set localAdv <port> <10H> <10F> <100H> <100F> <1000F> <pause> */
- adv.advCap10HDX = _strtol(argv[1], NULL, 0) & BIT(0);
- adv.advCap10FDX = _strtol(argv[2], NULL, 0) & BIT(0);
- adv.advCap100HDX = _strtol(argv[3], NULL, 0) & BIT(0);
- adv.advCap100FDX = _strtol(argv[4], NULL, 0) & BIT(0);
- adv.advCap1000FDX = _strtol(argv[5], NULL, 0) & BIT(0);
- adv.advPause = _strtol(argv[6], NULL, 0) & BIT(0);
- ret = air_port_setLocalAdvAbility(0, port, adv);
- AIR_PRINT("Set Port%02d Local Auto-Negotiation Advertisement: ", port);
- if(AIR_E_OK != ret)
- {
- AIR_PRINT("Fail!\n");
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("\n");
- AIR_PRINT("\tAdvertise 10BASE-T Half Duplex: %s\n", (adv.advCap10HDX)?"Effective":"Not Effective" );
- AIR_PRINT("\tAdvertise 10BASE-T Full Duplex: %s\n", (adv.advCap10FDX)?"Effective":"Not Effective" );
- AIR_PRINT("\tAdvertise 100BASE-T Half Duplex: %s\n", (adv.advCap100HDX)?"Effective":"Not Effective" );
- AIR_PRINT("\tAdvertise 100BASE-T Full Duplex: %s\n", (adv.advCap100FDX)?"Effective":"Not Effective" );
- AIR_PRINT("\tAdvertise 1000BASE-T Full Duplex: %s\n", (adv.advCap1000FDX)?"Effective":"Not Effective" );
- AIR_PRINT("\tAdvertise Asynchronous Pause: %s\n", (adv.advPause)?"Effective":"Not Effective" );
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doRemoteAdv(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T port = 0;
- AIR_AN_ADV_T lp_adv;
-
- memset(&lp_adv, 0, sizeof(AIR_AN_ADV_T));
- port = _strtol(argv[0], NULL, 10);
-
- if(1 == argc)
- {
- /* port get remoteAdv <port> */
- ret = air_port_getRemoteAdvAbility(0, port, &lp_adv);
- AIR_PRINT("Get Port%02d Remote Auto-Negotiation Advertisement: ", port);
- if(AIR_E_OK != ret)
- {
- AIR_PRINT("Fail!\n");
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("\n");
- AIR_PRINT("\tAdvertise 10BASE-T Half Duplex: %s\n", lp_adv.advCap10HDX?"Effective":"Not Effective" );
- AIR_PRINT("\tAdvertise 10BASE-T Full Duplex: %s\n", lp_adv.advCap10FDX?"Effective":"Not Effective" );
- AIR_PRINT("\tAdvertise 100BASE-T Half Duplex: %s\n", lp_adv.advCap100HDX?"Effective":"Not Effective" );
- AIR_PRINT("\tAdvertise 100BASE-T Full Duplex: %s\n", lp_adv.advCap100FDX?"Effective":"Not Effective" );
- AIR_PRINT("\tAdvertise 1000BASE-T Full Duplex: %s\n", (lp_adv.advCap1000FDX)?"Effective":"Not Effective" );
- AIR_PRINT("\tAdvertise Asynchronous Pause: %s\n", (lp_adv.advPause)?"Effective":"Not Effective" );
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doPortSpeed(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T port = 0;
- UI32_T speed = 0;
-
- port = _strtol(argv[0], NULL, 10);
-
- if(1 == argc)
- {
- /* port get speed <port> */
- ret = air_port_getSpeed(0, port, &speed);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Get Port%02d Speed:", port);
- }
- else
- {
- AIR_PRINT("Get Port%02d Speed Fail!\n", port);
- }
- }
- else if(2 == argc)
- {
- /* port set speed <port> <speed> */
- speed = _strtol(argv[1], NULL, 10);
- ret = air_port_setSpeed(0, port, speed);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Set Port%02d Speed:", port);
- }
- else
- {
- AIR_PRINT("Set Port%02d Speed Fail!\n", port);
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- if(ret == AIR_E_OK)
- {
- switch(speed)
- {
- case AIR_PORT_SPEED_10M:
- AIR_PRINT(" 10 Mbps\n");
- break;
- case AIR_PORT_SPEED_100M:
- AIR_PRINT(" 100 Mbps\n");
- break;
- case AIR_PORT_SPEED_1000M:
- AIR_PRINT(" 1 Gbps\n");
- break;
- case AIR_PORT_SPEED_2500M:
- AIR_PRINT(" 2.5 Gbps\n");
- break;
- default:
- AIR_PRINT(" Reserved\n");
- break;
- }
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doPortDuplex(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T port = 0;
- UI32_T duplex = 0;
-
- port = _strtol(argv[0], NULL, 10);
-
- if(1 == argc)
- {
- /* port get duplex <port> */
- ret = air_port_getDuplex(0, port, &duplex);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Get Port%02d Duplex:%s\n", port, duplex?"Full":"Half");
- }
- else
- {
- AIR_PRINT("Get Port%02d Duplex Fail!\n", port);
- }
- }
- else if(2 == argc)
- {
- /* port set duplex <port> <duplex> */
- duplex = _strtol(argv[1], NULL, 10);
- ret = air_port_setDuplex(0, port, duplex);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Set Port%02d Duplex:%s\n", port, duplex?"Full":"Half");
- }
- else
- {
- AIR_PRINT("Set Port%02d Duplex Fail!\n", port);
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doPortStatus(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T port = 0;
- AIR_PORT_STATUS_T ps;
-
- memset(&ps, 0, sizeof(AIR_PORT_STATUS_T));
- port = _strtol(argv[0], NULL, 10);
-
- if(1 == argc)
- {
- /* port get status <port> */
- ret = air_port_getLink(0, port, &ps);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Get Port%02d Link-Status\n", port);
- AIR_PRINT("\tLink: %s\n", ps.link?"Up":"Down");
- AIR_PRINT("\tDuplex: %s\n", ps.duplex?"Full":"Half");
- AIR_PRINT("\tSpeed: ");
- switch(ps.speed)
- {
- case AIR_PORT_SPEED_10M:
- AIR_PRINT("10 Mbps\n");
- break;
- case AIR_PORT_SPEED_100M:
- AIR_PRINT("100 Mbps\n");
- break;
- case AIR_PORT_SPEED_1000M:
- AIR_PRINT("1 Gbps\n");
- break;
- case AIR_PORT_SPEED_2500M:
- AIR_PRINT("2.5 Gbps\n");
- break;
- default:
- AIR_PRINT("Reserved\n");
- break;
- }
- }
- else
- AIR_PRINT("Get Port%02d Link-Status Fail!", port);
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doPortBckPres(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T port = 0;
- UI32_T bckPres = 0;
-
- port = _strtol(argv[0], NULL, 10);
-
- if(1 == argc)
- {
- /* port get bckPres <port> */
- ret = air_port_getBckPres(0, port, &bckPres);
- if(ret == AIR_E_OK)
- AIR_PRINT("Get Port%02d BckPres:%s\n", port, bckPres?"Enabled":"Disabled");
- else
- AIR_PRINT("Get Port%02d BckPres Fail!\n", port);
- }
- else if(2 == argc)
- {
- /* port set bckPres <port> <bckPres> */
- bckPres = _strtol(argv[1], NULL, 10);
- ret = air_port_setBckPres(0, port, bckPres);
- if(ret == AIR_E_OK)
- AIR_PRINT("Set Port%02d BckPres:%s\n", port, bckPres?"Enabled":"Disabled");
- else
- AIR_PRINT("Set Port%02d BckPres Fail!\n", port);
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doPortPsMode(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T port = 0;
- UI32_T mode = 0;
- BOOL_T ls_en = 0;
- BOOL_T eee_en = 0;
-
- port = _strtol(argv[0], NULL, 10);
-
- if(1 == argc)
- {
- /* port get psMode <port> */
- ret = air_port_getPsMode(0, port, &mode);
- AIR_PRINT("Get Port%02d Power-Saving: ", port);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Done\n");
- }
- else
- {
- AIR_PRINT("Fail!\n");
- }
- }
- else if(3 == argc)
- {
- /* port set psMode <port> <ls> <eee> */
- ls_en = _strtol(argv[1], NULL, 0);
- eee_en = _strtol(argv[2], NULL, 0);
- if(TRUE == ls_en)
- {
- mode |= AIR_PORT_PS_LINKSTATUS;
- }
- if(TRUE == eee_en)
- {
- mode |= AIR_PORT_PS_EEE;
- }
- ret = air_port_setPsMode(0, port, mode);
- AIR_PRINT("Set Port%02d Power-Saving: ", port);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Done\n");
- }
- else
- {
- AIR_PRINT("Fail!\n");
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("\tLink status:%s\n", (mode & AIR_PORT_PS_LINKSTATUS)?"Enable":"Disable");
- AIR_PRINT("\tEEE:%s\n", (mode & AIR_PORT_PS_EEE)?"Enable":"Disable");
- }
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doPortSmtSpdDwn(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T port = 0;
- UI32_T state = 0;
- UI32_T retry = 0;
-
- port = _strtol(argv[0], NULL, 10);
-
- if(1 == argc)
- {
- /* port get smtSpdDwn <port> */
- ret = air_port_getSmtSpdDwn(0, port, &state, &retry);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Get Port%02d Smart Speed Down: %s\n", port, state?"Enabled":"Disabled");
- AIR_PRINT("Get Port%02d Retry Time: %d\n", port, retry + 2);
- }
- else
- AIR_PRINT("Get Port%02d Smart-SpeedDown Fail!\n", port);
- }
- else if(3 == argc)
- {
- /* port set smtSpdDwn <port> <en> <retry> */
- state = _strtol(argv[1], NULL, 10);
- retry = _strtol(argv[2], NULL, 10);
- if(retry >= 2)
- {
- ret = air_port_setSmtSpdDwn(0, port, state, retry - 2);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Set Port%02d Smart Speed Down: %s\n", port, state?"Enabled":"Disabled");
- AIR_PRINT("Set Port%02d Retry Time: %d\n", port, retry);
- }
- else
- AIR_PRINT("Set Port%02d Smart-SpeedDown Fail!\n", port);
- }
- else
- {
- ret = AIR_E_BAD_PARAMETER;
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doPortSpTag(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T port = 0;
- BOOL_T sptag_en = FALSE;
-
- port = _strtol(argv[0], NULL, 10);
-
- if(1 == argc)
- {
- /* port get spTag <port> */
- ret = air_port_getSpTag(0, port, &sptag_en);
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("Get Port%02d Special Tag %s\n", port, ((sptag_en)?"Enabled":"Disabled"));
- }
- else
- {
- AIR_PRINT("Get Port%02d Special Tag Fail.\n", port);
- }
- }
- else if(2 == argc)
- {
- /* port set spTag <port> <en> */
- sptag_en = _strtol(argv[1], NULL, 10);
- ret = air_port_setSpTag(0, port, sptag_en);
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("Set Port%02d Special Tag:%s\n", port, ((sptag_en)?"Enabled":"Disabled"));
- }
- else
- {
- AIR_PRINT("Set Port%02d Special Tag Fail.\n", port);
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doPortEnable(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T port = 0;
- UI32_T state = 0;
-
- port = _strtol(argv[0], NULL, 10);
-
- if(1 == argc)
- {
- /* port get enable <port> */
- ret = air_port_getEnable(0, port, &state);
- if(ret == AIR_E_OK)
- AIR_PRINT("Get Port%02d State:%s\n", port, state?"Enable":"Disable");
- else
- AIR_PRINT("Get Port%02d State Fail!\n", port);
- }
- else if(2 == argc)
- {
- /* port set enable <port> <en> */
- state = _strtol(argv[1], NULL, 10);
- ret = air_port_setEnable(0, port, state);
- if(ret == AIR_E_OK)
- AIR_PRINT("Set Port%02d State:%s\n", port, state?"Enable":"Disable");
- else
- AIR_PRINT("Set Port%02d State Fail!\n", port);
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doPort5GBaseRMode(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
-
- if(0 == argc)
- {
- /* port set 5GBaseRMode */
- ret = air_port_set5GBaseRModeEn(0);
- if(ret == AIR_E_OK)
- AIR_PRINT("Set Port05 Mode: 5GBase-R\n");
- else
- AIR_PRINT("Set Port05 HSGMII Mode Fail.\n");
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doPortHsgmiiMode(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
-
- if(0 == argc)
- {
- /* port set hsgmiiMode */
- ret = air_port_setHsgmiiModeEn(0);
- if(ret == AIR_E_OK)
- AIR_PRINT("Set Port05 Mode: HSGMII\n");
- else
- AIR_PRINT("Set Port05 HSGMII Mode Fail.\n");
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doPortSgmiiMode(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T mode = 0;
- UI32_T speed = 0;
-
- if(2 == argc)
- {
- /* port set sgmiiMode <mode(0:AN,1:Force)> <speed> */
- mode = _strtol(argv[0], NULL, 10);
- speed = _strtol(argv[1], NULL, 10);
- ret = air_port_setSgmiiMode(0, mode, speed);
- if(ret == AIR_E_OK)
- AIR_PRINT("Set Port05 SGMII Mode:%s\nIf in Force Mode, speed:", mode?"Force":"AN");
- else
- AIR_PRINT("Set Port05 SGMII Mode Fail.\n");
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- if(ret == AIR_E_OK)
- {
- switch(speed)
- {
- case AIR_PORT_SPEED_10M:
- AIR_PRINT(" 10 Mbps\n");
- break;
- case AIR_PORT_SPEED_100M:
- AIR_PRINT(" 100 Mbps\n");
- break;
- case AIR_PORT_SPEED_1000M:
- AIR_PRINT(" 1 Gbps\n");
- break;
- default:
- AIR_PRINT(" Reserved\n");
- break;
- }
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doPortRmiiMode(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T speed = 0;
-
- if(1 == argc)
- {
- /* port set rmiiMode <speed> */
- speed = _strtol(argv[0], NULL, 10);
- ret = air_port_setRmiiMode(0, speed);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Set Port05 RMII Mode Speed:");
- }
- else
- {
- AIR_PRINT("Set Port05 RMII Mode Fail!\n");
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- if(ret == AIR_E_OK)
- {
- switch(speed)
- {
- case AIR_PORT_SPEED_10M:
- AIR_PRINT(" 10 Mbps\n");
- break;
- case AIR_PORT_SPEED_100M:
- AIR_PRINT(" 100 Mbps\n");
- break;
- default:
- AIR_PRINT(" Reserved\n");
- break;
- }
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doPortRgmiiMode(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T speed = 0;
-
- if(1 == argc)
- {
- /* port set rgmiiMode <speed> */
- speed = _strtol(argv[0], NULL, 10);
- ret = air_port_setRgmiiMode(0, speed);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Set Port05 RGMII Mode Speed:");
- }
- else
- {
- AIR_PRINT("Set Port05 RGMII Mode Fail!\n");
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- if(ret == AIR_E_OK)
- {
- switch(speed)
- {
- case AIR_PORT_SPEED_10M:
- AIR_PRINT(" 10 Mbps\n");
- break;
- case AIR_PORT_SPEED_100M:
- AIR_PRINT(" 100 Mbps\n");
- break;
- case AIR_PORT_SPEED_1000M:
- AIR_PRINT(" 1 Gbps\n");
- break;
- default:
- AIR_PRINT(" Reserved\n");
- break;
- }
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doSptagEn(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T port = 0;
- BOOL_T sp_en = FALSE;
-
- port = _strtol(argv[0], NULL, 10);
- if (2 == argc)
- {
- sp_en = _strtol(argv[1], NULL, 10);
- ret = air_sptag_setState(0,port,sp_en);
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("set port %d SpTag state %s sucess\n", port,sp_en?"Enable":"Disable");
- }
- else
- {
- AIR_PRINT("set port %d SpTag state %s fail\n", port,sp_en?"Enable":"Disable");
- }
- }
- else if(1 == argc)
- {
- air_sptag_getState(0,port,&sp_en);
- AIR_PRINT("get port %d SpTag state: %s \n", port,sp_en?"Enable":"Disable");
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doSptagMode(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T port = 0;
- BOOL_T sp_mode = FALSE;
-
-
- port = _strtol(argv[0], NULL, 10);
- if (2 == argc)
- {
- sp_mode = _strtol(argv[1], NULL, 10);
- ret = air_sptag_setMode(0,port,sp_mode);
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("set port %d SpTag Mode %s sucess\n", port,sp_mode?"replace":"insert");
- }
- else
- {
- AIR_PRINT("set port %d SpTag state %s fail\n", port,sp_mode?"replace":"insert");
- }
- }
- else if(1 == argc)
- {
- air_sptag_getMode(0,port,&sp_mode);
- AIR_PRINT("get port %d SpTag state: %s \n", port,sp_mode?"replace":"insert");
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doSptagDecode(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- AIR_SPTAG_RX_PARA_T sptag_rx = {0};
- UI8_T buf[AIR_STAG_BUF_LEN] = {0};
- UI32_T len = AIR_STAG_BUF_LEN, i = 0;
-
- if (4 == argc)
- {
- for(i = 0; i < len; i++)
- {
- buf[i] = _strtoul(argv[i], NULL, 16);
- }
-
- ret = air_sptag_decodeRx(0, buf, len, &sptag_rx);
- if (AIR_E_OK != ret)
- {
- AIR_PRINT("SpTag decode fail\n");
- return ret;
- }
-
- AIR_PRINT("SpTag decode success:\n");
- AIR_PRINT("RSN : %s\n", _sptag_pt[sptag_rx.rsn]);
- AIR_PRINT("VPM : %s\n", _sptag_vpm[sptag_rx.vpm]);
- AIR_PRINT("SPN : %d\n", sptag_rx.spn);
- AIR_PRINT("PRI : %d\n", sptag_rx.pri);
- AIR_PRINT("CFI : %d\n", sptag_rx.cfi);
- AIR_PRINT("VID : %d\n", sptag_rx.vid);
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doSptagEncode(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- AIR_STAG_TX_PARA_T sptag_tx = {0};
- UI8_T buf[AIR_STAG_BUF_LEN] = {0};
- UI32_T len = AIR_STAG_BUF_LEN;
- char str[128] = {'\0'};
- UI32_T data = 0;
- AIR_STAG_MODE_T mode = AIR_STAG_MODE_LAST;
-
- if (7 == argc)
- {
- if(_strcmp(argv[0],"mode=replace") == 0)
- mode = AIR_STAG_MODE_REPLACE;
- else if(_strcmp(argv[0],"mode=insert") == 0)
- mode = AIR_STAG_MODE_INSERT;
- else
- printf("mode is wrong!!");
-
- if(_strcmp(argv[1],"opc=portmap") == 0)
- sptag_tx.opc = AIR_STAG_OPC_PORTMAP;
- else if(_strcmp(argv[1],"opc=portid") == 0)
- sptag_tx.opc = AIR_STAG_OPC_PORTID;
- else if(_strcmp(argv[1],"opc=lookup") == 0)
- sptag_tx.opc = AIR_STAG_OPC_LOOKUP;
- else
- printf("opc is wrong!!");
-
- if(sscanf(argv[2],"dp=%x",&data) != -1)
- {
- sptag_tx.pbm = data;
- AIR_PRINT("sptag_tx.pbm %x\n",sptag_tx.pbm);
- }
-
- if(_strcmp(argv[3],"vpm=untagged") == 0)
- sptag_tx.vpm = AIR_STAG_VPM_UNTAG;
- else if(_strcmp(argv[3],"vpm=8100") == 0)
- sptag_tx.vpm = AIR_STAG_VPM_TPID_8100;
- else if(_strcmp(argv[3],"vpm=88a8") == 0)
- sptag_tx.vpm = AIR_STAG_VPM_TPID_88A8;
- else
- printf("vpm is wrong!!");
-
- if(sscanf(argv[4],"pri=%d",&data) != -1)
- {
- sptag_tx.pri = data;
- AIR_PRINT("sptag_tx.pri %d\n",sptag_tx.pri);
- }
-
- if(sscanf(argv[5],"cfi=%d",&data) != -1)
- {
- sptag_tx.cfi = data;
- AIR_PRINT("sptag_tx.cfi %d\n",sptag_tx.cfi);
- }
-
- if(sscanf(argv[6],"vid=%d",&data) != -1)
- {
- sptag_tx.vid = data;
- AIR_PRINT("sptag_tx.vid %d\n",sptag_tx.vid);
- }
-
- ret = air_sptag_encodeTx(0,mode, &sptag_tx, (UI8_T *)&buf, &len);
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("SpTag encode sucess, returned len=%d\n", len);
- AIR_PRINT("Encoded SpTag: %02x %02x %02x %02x\n", buf[0], buf[1], buf[2], buf[3]);
- }
- else
- {
- AIR_PRINT("SpTag encode fail\n");
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doSptag(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(sptagCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doL2Dump(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(l2DumpCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doMacAddr(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- AIR_MAC_ENTRY_T mt;
- UI32_T fwd = 0;
-
- memset(&mt, 0, sizeof(AIR_MAC_ENTRY_T));
-
- if(0 == argc)
- {
- /* l2 clear mac */
- ret = air_l2_clearMacAddr(0);
- if(ret == AIR_E_OK)
- AIR_PRINT("Clear MAC Address Table Done.\n");
- else
- AIR_PRINT("Clear MAC Address Table Fail.\n");
- }
- else if(3 == argc)
- {
- /* l2 del mac <mac(12'hex)> { vid <vid(0..4095)> | fid <fid(0..15)> } */
- ret = _str2mac(argv[0], (C8_T *)mt.mac);
- if(ret != AIR_E_OK)
- {
- AIR_PRINT("Unrecognized command.\n");
- return ret;
- }
-
- /* check argument 1 */
- if(FALSE == _strcmp(argv[1], "vid"))
- {
- /* get mac entry by MAC address & vid */
- mt.cvid = _strtoul(argv[2], NULL, 0);
- mt.flags |= AIR_L2_MAC_ENTRY_FLAGS_IVL;
- AIR_PRINT("Get MAC Address:" MAC_STR " with vid:%u", MAC2STR(mt.mac), mt.cvid);
- }
- else if(FALSE == _strcmp(argv[1], "fid"))
- {
- /* get mac entry by MAC address & fid */
- mt.fid = _strtoul(argv[2], NULL, 0);
- AIR_PRINT("Get MAC Address:" MAC_STR " with fid:%u", MAC2STR(mt.mac), mt.fid);
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
- ret = air_l2_delMacAddr(0, &mt);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT(" Done.\n");
- }
- else
- AIR_PRINT("\n Fail!\n");
- }
- else if(7 == argc)
- {
- /* l2 add mac <static(0:dynamic,1:static)> <unauth(0:auth,1:unauth)> <mac(12'hex)> <portlist(uintlist)> [ vid <vid(0..4095)> | fid <fid(0..15)> ] <src_mac_forward=(0:default,1:cpu-include,2:cpu-exclude,3:cpu-only,4:drop)> */
- if(argv[0])
- mt.flags |= AIR_L2_MAC_ENTRY_FLAGS_STATIC;
-
- if(argv[1])
- mt.flags |= AIR_L2_MAC_ENTRY_FLAGS_UNAUTH;
-
- ret = _str2mac(argv[2], (C8_T *)mt.mac);
- if(ret != AIR_E_OK)
- {
- AIR_PRINT("Unrecognized command.\n");
- return ret;
- }
-
- ret = _portListStr2Ary(argv[3], mt.port_bitmap, 1);
- if(ret != AIR_E_OK)
- {
- AIR_PRINT("Unrecognized command.\n");
- return ret;
- }
-
- /* check argument fid or vid */
- if(FALSE == _strcmp(argv[4], "vid"))
- {
- /* get mac entry by MAC address & vid */
- mt.cvid = _strtoul(argv[5], NULL, 0);
- mt.flags |= AIR_L2_MAC_ENTRY_FLAGS_IVL;
- }
- else if(FALSE == _strcmp(argv[4], "fid"))
- {
- /* get mac entry by MAC address & fid */
- mt.fid = _strtoul(argv[5], NULL, 0);
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
- fwd = _strtoul(argv[6], NULL, 0);
- if(0 == fwd)
- mt.sa_fwd = AIR_L2_FWD_CTRL_DEFAULT;
- else if(1 == fwd)
- mt.sa_fwd = AIR_L2_FWD_CTRL_CPU_INCLUDE;
- else if(2 == fwd)
- mt.sa_fwd = AIR_L2_FWD_CTRL_CPU_EXCLUDE;
- else if(3 == fwd)
- mt.sa_fwd = AIR_L2_FWD_CTRL_CPU_ONLY;
- else if(4 == fwd)
- mt.sa_fwd = AIR_L2_FWD_CTRL_DROP;
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
- ret = air_l2_addMacAddr(0, &mt);
- AIR_PRINT("Add MAC Address:" MAC_STR, MAC2STR(mt.mac));
- if(ret == AIR_E_OK)
- AIR_PRINT(" Done.\n");
- else
- AIR_PRINT(" Fail.\n");
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-_printMacEntry(
- AIR_MAC_ENTRY_T *mt,
- UI32_T age_unit,
- UI8_T count,
- UI8_T title)
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- I32_T i = 0, j = 0;
- UI8_T first = 0;
- UI8_T find = 0;
- if(title)
- {
- AIR_PRINT("%-6s%-15s%-5s%-5s%-5s%-10s%-10s%-6s\n",
- "unit",
- "mac",
- "ivl",
- "vid",
- "fid",
- "age-time",
- "forward",
- "port");
- return ret;
- }
- for(i = 0; i < count; i++)
- {
- AIR_PRINT("%-6d", age_unit);
- AIR_PRINT(MAC_STR, MAC2STR(mt[i].mac));
- AIR_PRINT("...");
- if(mt[i].flags & AIR_L2_MAC_ENTRY_FLAGS_IVL)
- {
- AIR_PRINT("%-3s..", "ivl");
- AIR_PRINT("%-5d", mt[i].cvid);
- AIR_PRINT("%-5s", ".....");
- }
- else
- {
- AIR_PRINT("%-3s..", "svl");
- AIR_PRINT("%-5s", ".....");
- AIR_PRINT("%-5d", mt[i].fid);
- }
- if(mt[i].flags & AIR_L2_MAC_ENTRY_FLAGS_STATIC)
- {
- AIR_PRINT("%-10s.", "static");
- }
- else
- {
- AIR_PRINT("%d sec..", mt[i].timer);
- }
- AIR_PRINT("%-10s", _air_mac_address_forward_control_string[mt[i].sa_fwd]);
- first = 0;
- find = 0;
- for (j = (AIR_MAX_NUM_OF_PORTS - 1); j >= 0; j--)
- {
- if((mt[i].port_bitmap[0]) & (1 << j))
- {
- first = j;
- find = 1;
- break;
- }
- }
- if(find)
- {
- for (j = 0; j < AIR_MAX_NUM_OF_PORTS; j++)
- {
- if((mt[i].port_bitmap[0]) & (1 << j))
- {
- if(j == first)
- AIR_PRINT("%-2d", j);
- else
- AIR_PRINT("%-2d,", j);
- }
- }
- }
- else
- AIR_PRINT("no dst port");
- AIR_PRINT("\n");
- }
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doGetMacAddr(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI8_T count = 0;
- AIR_MAC_ENTRY_T * ptr_mt;
-
- if(3 == argc)
- {
- ptr_mt = AIR_MALLOC(sizeof(AIR_MAC_ENTRY_T));
- if (NULL == ptr_mt)
- {
- AIR_PRINT("***Error***, allocate memory fail\n");
- return AIR_E_OTHERS;
- }
- memset(ptr_mt, 0, sizeof(AIR_MAC_ENTRY_T));
- /* l2 get mac <mac(12'hex)> { vid <vid(0..4095)> | fid <fid(0..15)> } */
- ret = _str2mac(argv[0], (C8_T *)ptr_mt->mac);
- if(ret != AIR_E_OK)
- {
- AIR_PRINT("Unrecognized command.\n");
- AIR_FREE(ptr_mt);
- return ret;
- }
-
- /* check argument 1 */
- if(FALSE == _strcmp(argv[1], "vid"))
- {
- /* get mac entry by MAC address & vid */
- ptr_mt->cvid = _strtoul(argv[2], NULL, 0);
- ptr_mt->flags |= AIR_L2_MAC_ENTRY_FLAGS_IVL;
- AIR_PRINT("Get MAC Address:" MAC_STR " with vid:%u", MAC2STR(ptr_mt->mac), ptr_mt->cvid);
- }
- else if(FALSE == _strcmp(argv[1], "fid"))
- {
- /* get mac entry by MAC address & fid */
- ptr_mt->fid = _strtoul(argv[2], NULL, 0);
- AIR_PRINT("Get MAC Address:" MAC_STR " with fid:%u", MAC2STR(ptr_mt->mac), ptr_mt->fid);
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- AIR_FREE(ptr_mt);
- return AIR_E_BAD_PARAMETER;
- }
- ret = air_l2_getMacAddr(0, &count, ptr_mt);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT(" Done.\n");
- _printMacEntry(ptr_mt, 0, 1, TRUE);
- _printMacEntry(ptr_mt, 0, 1, FALSE);
- }
- else
- AIR_PRINT("\n Not found!\n");
- AIR_FREE(ptr_mt);
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doMacAddrAgeOut(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T time = 0;
- if(0 == argc)
- {
- /* l2 get macAddrAgeOut */
- ret = air_l2_getMacAddrAgeOut(0, &time);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Get MAC Address Age Out Time Done.\n");
- }
- else
- {
- AIR_PRINT("Get MAC Address Age Out Time Fail.\n");
- }
- }
- else if(1 == argc)
- {
- /* l2 set macAddrAgeOut <time(1, 1000000)> */
- time = _strtoul(argv[0], NULL, 0);
- if(time < 1 || time > 1000000)
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
- ret = air_l2_setMacAddrAgeOut(0, time);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Set MAC Address Age Out Time Done.\n");
- }
- else
- {
- AIR_PRINT("Set MAC Address Age Out Time Fail.\n");
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("MAC Address Age Out Time: %u seconds.\n", time);
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doDumpMacAddr(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- AIR_MAC_ENTRY_T *ptr_mt;
- UI8_T count = 0;
- UI32_T bucket_size = 0;
- UI32_T total_count = 0;
-
- if(0 != argc)
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
- /* get unit of aging time */
- ret = air_l2_getMacBucketSize(0, &bucket_size);
- if(ret != AIR_E_OK)
- {
- AIR_PRINT("Get MAC Age Time Fail!\n");
- return ret;
- }
- ptr_mt = AIR_MALLOC(sizeof(AIR_MAC_ENTRY_T) * bucket_size);
- if (NULL == ptr_mt)
- {
- AIR_PRINT("***Error***, allocate memory fail\n");
- return AIR_E_OTHERS;
- }
- memset(ptr_mt, 0, sizeof(AIR_MAC_ENTRY_T) * bucket_size);
- _printMacEntry(ptr_mt, 0, count, TRUE);
- /* get 1st entry of MAC table */
- ret = air_l2_getMacAddr(0, &count, ptr_mt);
- switch(ret)
- {
- case AIR_E_ENTRY_NOT_FOUND:
- AIR_FREE(ptr_mt);
- AIR_PRINT("Not Found!\n");
- return ret;
- case AIR_E_TIMEOUT:
- AIR_FREE(ptr_mt);
- AIR_PRINT("Time Out!\n");
- return ret;
- case AIR_E_BAD_PARAMETER:
- AIR_FREE(ptr_mt);
- AIR_PRINT("Bad Parameter!\n");
- return ret;
- default:
- break;
- }
- total_count += count;
- _printMacEntry(ptr_mt, 0, count, FALSE);
-
- /* get other entries of MAC table */
- while(1)
- {
- memset(ptr_mt, 0, sizeof(AIR_MAC_ENTRY_T) * bucket_size);
- ret = air_l2_getNextMacAddr(0, &count, ptr_mt);
- if(AIR_E_OK != ret)
- {
- break;
- }
- total_count += count;
- _printMacEntry(ptr_mt, 0, count, FALSE);
- }
- switch(ret)
- {
- case AIR_E_TIMEOUT:
- AIR_PRINT("Time Out!\n");
- break;
- case AIR_E_BAD_PARAMETER:
- AIR_PRINT("Bad Parameter!\n");
- break;
- default:
- AIR_PRINT("Found %u %s\n", total_count, (total_count>1)?"entries":"entry");
- break;
- }
- AIR_FREE(ptr_mt);
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doLagMember(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T portrunk_index = 0, member_index = 0, member_enable = 0, port_index = 0, i = 0;
- AIR_LAG_PTGINFO_T member;
- memset(&member,0,sizeof(AIR_LAG_PTGINFO_T));
-
- if(4 == argc)
- {
- /* lag set member <port trunk index> <member index> <member enable> <port_index>*/
- portrunk_index = _strtol(argv[0], NULL, 10);
- member_index = _strtol(argv[1], NULL, 10);
- member_enable = _strtol(argv[2], NULL, 10);
- port_index = _strtol(argv[3], NULL, 10);
- ret = air_lag_setMember(0, portrunk_index, member_index, member_enable,port_index);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Set port trunk index %d member_index:%d member_enable:%d, port_index:%d ok.\n", portrunk_index, member_index, member_enable,port_index);
- }
- else
- {
- AIR_PRINT("Set port trunk index %d member_index:%d member_enable:%d, port_index:%d fail.\n", portrunk_index, member_index, member_enable,port_index);
- }
- memset(&member,0,sizeof(member));
- air_lag_getMember(0, portrunk_index, &member);
- if(! member.csr_gp_enable[0])
- {
- AIR_PRINT("\r\n!!!!!!!!!Port trunk index %d member_index:0 must be set,or else have taffic issues.\n", portrunk_index);
- }
- }
- else if(1 == argc)
- {
- portrunk_index = _strtol(argv[0], NULL, 10);
-
- /* lag get member <port> */
- memset(&member,0,sizeof(member));
- ret = air_lag_getMember(0, portrunk_index, &member);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Get port trunk %u member:\n", portrunk_index);
- for(i = 0; i < AIR_LAG_MAX_MEM_NUM; i++)
- {
- if(member.csr_gp_enable[i])
- AIR_PRINT("port %d \r\n", member.csr_gp_port[i]);
- }
- AIR_PRINT("\r\n");
- }
- else
- {
- AIR_PRINT("Get port trunk:%u Member Fail.\n", portrunk_index);
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-
-static AIR_ERROR_NO_T
-doLagDstInfo(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- AIR_LAG_DISTINFO_T dstInfo;
-
- memset(&dstInfo, 0, sizeof(AIR_LAG_DISTINFO_T));
- if(7 == argc)
- {
- /* lag set dstInfo <sp> <sa> <da> <sip> <dip> <sport> <dport> */
- dstInfo.sp = _strtol(argv[0], NULL, 10) & BIT(0);
- dstInfo.sa = _strtol(argv[1], NULL, 10) & BIT(0);
- dstInfo.da = _strtol(argv[2], NULL, 10) & BIT(0);
- dstInfo.sip = _strtol(argv[3], NULL, 10) & BIT(0);
- dstInfo.dip = _strtol(argv[4], NULL, 10) & BIT(0);
- dstInfo.sport = _strtol(argv[5], NULL, 10) & BIT(0);
- dstInfo.dport = _strtol(argv[6], NULL, 10) & BIT(0);
- ret = air_lag_setDstInfo(0, dstInfo);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Set LAG packet distrubution.\n");
- }
- else
- {
- AIR_PRINT("Set LAG packet distrubution Fail.\n");
- }
- }
- else if(0 == argc)
- {
- /* lag get dstInfo */
- ret = air_lag_getDstInfo(0, &dstInfo);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Get LAG packet distrubution:\n");
- }
- else
- {
- AIR_PRINT("Get LAG packet distrubution Fail.\n");
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("%-5s|%-5s|%-5s|%-5s|%-5s|%-5s|%-5s\n",
- "SP", "SA", "DA", "SIP", "DIP", "SPORT", "DPORT");
- AIR_PRINT("%-5s|%-5s|%-5s|%-5s|%-5s|%-5s|%-5s\n",
- (dstInfo.sp)?"En":"Dis",
- (dstInfo.sa)?"En":"Dis",
- (dstInfo.da)?"En":"Dis",
- (dstInfo.sip)?"En":"Dis",
- (dstInfo.dip)?"En":"Dis",
- (dstInfo.sport)?"En":"Dis",
- (dstInfo.dport)?"En":"Dis");
- }
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doLagHashtype(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T hashtype = 0;
-
- if(1 == argc)
- {
- hashtype = _strtol(argv[0], NULL, 10);
- ret = air_lag_sethashtype(0, hashtype);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Set LAG hashtype Ok.\n");
- }
- else
- {
- AIR_PRINT("Set LAG hashtype Fail.\n");
- }
- }
- else if(0 == argc)
- {
- /* lag get dstInfo */
- ret = air_lag_gethashtype(0, &hashtype);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Get LAG hashtype:\n");
- }
- else
- {
- AIR_PRINT("Get LLAG hashtype Fail.\n");
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
- if(ret == AIR_E_OK)
- {
- switch (hashtype)
- {
- case 0:
- AIR_PRINT("hashtype:crc32lsb.\n");
- break;
- case 1:
- AIR_PRINT("hashtype:crc32msb.\n");
- break;
- case 2:
- AIR_PRINT("hashtype:crc16.\n");
- break;
- case 3:
- AIR_PRINT("hashtype:xor4.\n");
- break;
- default:
- AIR_PRINT("wrong hashtype:%d.\n",hashtype);
- }
-
- }
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doLagPtseed(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T ptseed = 0;
-
- if(1 == argc)
- {
- ptseed = _strtol(argv[0], NULL, 16);
- ret = air_lag_setPTSeed(0, ptseed);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Set LAG Port Seed:%x(hex) ok\n",ptseed);
- }
- else
- {
- AIR_PRINT("Set LAG Port Seed:%x(hex) fail\n",ptseed);
- }
- }
- else if(0 == argc)
- {
- /* lag get seed */
- ret = air_lag_getPTSeed(0, &ptseed);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Get port trunk seed: %x(hex)\n",ptseed);
- }
- else
- {
- AIR_PRINT("Get port trunk seed Fail.\n");
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doLagSpsel(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T port = 0;
- UI32_T state = 0;
-
- if(1 == argc)
- {
- /* lag set spsel <state> */
- state = _strtol(argv[0], NULL, 10);
- ret = air_lag_setSpSel(0,state);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Set source port compare function:%s.\n", (state)?"Enabled":"Disabled");
- }
- else
- {
- AIR_PRINT("Set source port compare function Fail.\n");
- }
- }
- else if(0 == argc)
- {
- /* lag get spsel*/
- ret = air_lag_getSpSel(0, &state);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Get source port compare function:%s.\n", (state)?"Enabled":"Disabled");
- }
- else
- {
- AIR_PRINT("Get source port compare function Fail.\n");
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-
-static AIR_ERROR_NO_T
-doLagState(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T port = 0;
- UI32_T state = 0;
-
- if(1 == argc)
- {
- /* lag set state <state> */
- state = _strtol(argv[0], NULL, 10);
- ret = air_lag_set_ptgc_state(0,state);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Set LAG Port Trunk State:%s.\n", (state)?"Enabled":"Disabled");
- }
- else
- {
- AIR_PRINT("Set LAG Port Trunk State Fail.\n");
- }
- }
- else if(0 == argc)
- {
- /* lag get state*/
- ret = air_lag_get_ptgc_state(0, &state);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Get LAG Port Trunk State:%s.\n", (state)?"Enabled":"Disabled");
- }
- else
- {
- AIR_PRINT("Get LAG Port Trunk State Fail.\n");
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doLagGet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(lagGetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doLagSet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(lagSetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doLag(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(lagCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doStpPortstate(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T port = 0;
- UI32_T fid = 0;
- UI32_T state = 0;
-
- port = _strtol(argv[0], NULL, 10);
- fid = _strtol(argv[1], NULL, 10);
- if(3 == argc)
- {
- /* stp set portstate <port> <fid(0..15)> <state> */
- state = _strtol(argv[2], NULL, 10);
- ret = air_stp_setPortstate(0, port, fid, state);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Set STP Port:%u FID:%u State:", port, fid);
- switch(state)
- {
- case AIR_STP_STATE_DISABLE:
- AIR_PRINT("Disable(STP) / Discard(RSTP).\n");
- break;
- case AIR_STP_STATE_LISTEN:
- AIR_PRINT("Listening(STP) / Discard(RSTP).\n");
- break;
- case AIR_STP_STATE_LEARN:
- AIR_PRINT("Learning(STP) / Learning(RSTP).\n");
- break;
- case AIR_STP_STATE_FORWARD:
- AIR_PRINT("Forwarding(STP) / Forwarding(RSTP).\n");
- break;
- default:
- break;
- }
- }
- else
- {
- AIR_PRINT("Set STP Port:%u FID:%u State Fail.", port, fid);
- }
- }
- else if(2 == argc)
- {
- /* stp get portstate <port> <fid(0..15)> */
- ret = air_stp_getPortstate(0, port, fid, &state);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Get STP Port:%u FID:%u State:", port, fid);
- switch(state)
- {
- case AIR_STP_STATE_DISABLE:
- AIR_PRINT("Disable(STP) / Discard(RSTP).\n");
- break;
- case AIR_STP_STATE_LISTEN:
- AIR_PRINT("Listening(STP) / Discard(RSTP).\n");
- break;
- case AIR_STP_STATE_LEARN:
- AIR_PRINT("Learning(STP) / Learning(RSTP).\n");
- break;
- case AIR_STP_STATE_FORWARD:
- AIR_PRINT("Forwarding(STP) / Forwarding(RSTP).\n");
- break;
- default:
- break;
- }
- }
- else
- {
- AIR_PRINT("Get STP Port:%u FID:%u State Fail.", port, fid);
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doStpGet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(stpGetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doStpSet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(stpSetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doStp(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(stpCmds, argc, argv);
-}
-
-static void
-_mir_printPortList(UI32_T * mt)
-{
- I8_T j = 0;
- UI8_T first = 0;
- UI8_T find = 0;
- for(j = (AIR_MAX_NUM_OF_PORTS - 1); j >= 0; j--)
- {
- if((*mt) & (1 << j))
- {
- first = j;
- find = 1;
- break;
- }
- }
- if(find)
- {
- for(j = 0; j < AIR_MAX_NUM_OF_PORTS; j++)
- {
- if((*mt) & (1 << j))
- {
- if(j == first)
- AIR_PRINT("%-2d", j);
- else
- AIR_PRINT("%-2d,", j);
- }
- }
- }
- else
- AIR_PRINT("NULL");
- AIR_PRINT("\n");
-}
-
-static void
-_mir_printSrcPortList(
- const UI32_T unit,
- const UI32_T sessionid)
-{
-
- I8_T i = 0;
- AIR_MIR_SESSION_T session;
- AIR_PORT_BITMAP_T txPbm = {0}, rxPbm = {0};
-
- for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
- {
- memset(&session, 0, sizeof(session));
- session.src_port = i;
- air_mir_getMirrorPort(unit, sessionid, &session);
-
- if(session.flags & AIR_MIR_SESSION_FLAGS_DIR_TX)
- {
- txPbm[0] |= (1 << i);
- }
- if(session.flags & AIR_MIR_SESSION_FLAGS_DIR_RX)
- {
- rxPbm[0] |= (1 << i);
- }
- }
- AIR_PRINT("Src PortList\n");
- AIR_PRINT(" - Rx portlist = ");
- _mir_printPortList(rxPbm);
- AIR_PRINT(" - Tx portlist = ");
- _mir_printPortList(txPbm);
-}
-
-static void
-_mir_printSession(
- const UI32_T unit,
- const UI32_T session_id,
- const AIR_MIR_SESSION_T *ptr_session)
-{
-
- AIR_PRINT("Session id: %d\n", session_id);
- AIR_PRINT("State: %s \n", (ptr_session->flags & AIR_MIR_SESSION_FLAGS_ENABLE)? "enable": "disable");
- AIR_PRINT("Tx tag: %s \n", (ptr_session->flags & AIR_MIR_SESSION_FLAGS_TX_TAG_OBEY_CFG)? "On": "Off");
- AIR_PRINT("Dst port: %d \n", ptr_session->dst_port);
- _mir_printSrcPortList(unit,session_id);
-}
-
-static AIR_ERROR_NO_T
-doMirrorGetSid(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T rc = AIR_E_OK;
- UI32_T session_id = 0;
- AIR_MIR_SESSION_T session = {0};
- I8_T i = 0;
-
- session_id = _strtoul(argv[0], NULL, 0);
- rc = air_mir_getSession(0, session_id, &session);
- if (AIR_E_OK != rc)
- {
- AIR_PRINT("***Error***, get mirror session fail\n");
- return rc;
- }
- /* print session information */
- if(session.dst_port == AIR_PORT_INVALID)
- {
- AIR_PRINT("Session id %d not found\n", session_id);
- }
- else
- {
- _mir_printSession(0, session_id, &session);
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doMirrorDelSid(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T rc = AIR_E_OK;
- UI32_T session_id = 0;
- AIR_MIR_SESSION_T session = {0};
- UI8_T i = 0;
-
- session_id = _strtoul(argv[0], NULL, 0);
- rc = air_mir_delSession(0, session_id);
- if (AIR_E_OK != rc)
- {
- AIR_PRINT("***Error***, del mirror session fail\n");
- return rc;
- }
- for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
- {
- session.src_port = i;
- rc = air_mir_setMirrorPort(0, session_id, &session);
- if (AIR_E_OK != rc)
- {
- AIR_PRINT("***Error***,port=%u error\n", i);
- return rc;
- }
- }
- if (rc != AIR_E_OK)
- {
- AIR_PRINT("***Error***, delete mirror session fail\n");
- }
- else
- AIR_PRINT("***OK***, delete mirror session success\n");
-
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doMirrorAddRlist(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T rc = AIR_E_OK;
- UI32_T session_id = 0;
- AIR_MIR_SESSION_T session = {0};
- AIR_PORT_BITMAP_T rxPbm = {0};
- UI8_T i = 0;
-
- /*mirror add session-rlist <sid(0..3)> <list(UINTLIST)>*/
- session_id = _strtoul(argv[0], NULL, 0);
- rc = _portListStr2Ary(argv[1], rxPbm, 1);
- if(rc != AIR_E_OK)
- {
- AIR_PRINT("Unrecognized command.\n");
- return rc;
- }
- if(!rxPbm[0])
- {
- for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
- {
- memset(&session, 0, sizeof(AIR_MIR_SESSION_T));
- session.src_port = i;
- rc = air_mir_getMirrorPort(0, session_id, &session);
- if (AIR_E_OK != rc)
- {
- AIR_PRINT("***Error***,get port=%u error\n", i);
- return rc;
- }
-
- session.flags &= ~AIR_MIR_SESSION_FLAGS_DIR_RX;
- session.src_port = i;
- rc = air_mir_setMirrorPort(0, session_id, &session);
- if (AIR_E_OK != rc)
- {
- AIR_PRINT("***Error***,set rx port=%u error\n", i);
- return rc;
- }
- }
- }
- else
- {
- for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
- {
- if(rxPbm[0] & (1 << i))
- {
- memset(&session, 0, sizeof(AIR_MIR_SESSION_T));
- session.src_port = i;
- rc = air_mir_getMirrorPort(0, session_id, &session);
- if (AIR_E_OK != rc)
- {
- AIR_PRINT("***Error***,get port=%u error\n", i);
- return rc;
- }
-
- session.flags |= AIR_MIR_SESSION_FLAGS_DIR_RX;
- session.src_port = i;
- rc = air_mir_setMirrorPort(0, session_id, &session);
- if (AIR_E_OK != rc)
- {
- AIR_PRINT("***Error***,port=%u error\n", i);
- return rc;
- }
- }
- }
- }
-
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doMirrorAddTlist(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T rc = AIR_E_OK;
- UI32_T session_id = 0;
- AIR_MIR_SESSION_T session = {0};
- AIR_PORT_BITMAP_T txPbm = {0};
- UI8_T i = 0;
-
- /*mirror add session-tlist <sid(0..3)> <list(UINTLIST)>*/
- session_id = _strtoul(argv[0], NULL, 0);
- rc = _portListStr2Ary(argv[1], txPbm, 1);
- if(rc != AIR_E_OK)
- {
- AIR_PRINT("Unrecognized command.\n");
- return rc;
- }
- if(!txPbm[0])
- {
- for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
- {
- memset(&session, 0, sizeof(AIR_MIR_SESSION_T));
- session.src_port = i;
- rc = air_mir_getMirrorPort(0, session_id, &session);
- if (AIR_E_OK != rc)
- {
- AIR_PRINT("***Error***,get port=%u error\n", i);
- return rc;
- }
-
- session.flags &= ~AIR_MIR_SESSION_FLAGS_DIR_TX;
- session.src_port = i;
- rc = air_mir_setMirrorPort(0, session_id, &session);
- if (AIR_E_OK != rc)
- {
- AIR_PRINT("***Error***,set rx port=%u error\n", i);
- return rc;
- }
- }
- }
- else
- {
- for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
- {
- if(txPbm[0] & (1 << i))
- {
- memset(&session, 0, sizeof(AIR_MIR_SESSION_T));
- session.src_port = i;
- rc = air_mir_getMirrorPort(0, session_id, &session);
- if (AIR_E_OK != rc)
- {
- AIR_PRINT("***Error***,get port=%u error\n", i);
- return rc;
- }
-
- session.flags |= AIR_MIR_SESSION_FLAGS_DIR_TX;
- session.src_port = i;
- rc = air_mir_setMirrorPort(0, session_id, &session);
- if (AIR_E_OK != rc)
- {
- AIR_PRINT("***Error***,port=%u error\n", i);
- return rc;
- }
- }
- }
- }
-
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doMirrorSetSessionEnable(
- UI32_T argc,
- C8_T *argv[])
-
-{
- AIR_ERROR_NO_T rc = AIR_E_OK;
- UI32_T session_id = 0;
- UI32_T enable = 0;
- BOOL_T tmp_en = FALSE;
-
- /*mirror set session-enable <sid(0..3)> <state(1:En,0:Dis)>*/
- session_id = _strtoul(argv[0], NULL, 0);
- enable = _strtoul(argv[1], NULL, 0);
- if(enable)
- tmp_en = TRUE;
- /* set port mirror state */
- rc = air_mir_setSessionAdminMode(0, session_id, tmp_en);
- if(AIR_E_OK!=rc)
- {
- AIR_PRINT("***Error***\n");
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doMirrorSetSession(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T rc = AIR_E_OK;
- UI32_T session_id = 0;
- UI32_T dst_port = 0;
- UI8_T enable = 0;
- UI8_T tag_en = 0;
- UI8_T dir = 0;
- AIR_MIR_SESSION_T session = {0};
- AIR_PORT_BITMAP_T rxPbm = {0};
- I8_T i = 0;
-
- /*mirror set session <sid(0..3)> <dst_port(UINT)> <state(1:En,0:Dis)> <tag(1:on, 0:off)> <list(UINTLIST)> <dir(0:none,1:tx,2:rx,3:both)>*/
- session_id = _strtoul(argv[0], NULL, 0);
- dst_port = _strtoul(argv[1], NULL, 0);
- AIR_PRINT("session id %d dst port %d.\n", session_id, dst_port);
- session.dst_port = dst_port;
- enable = _strtoul(argv[2], NULL, 0);
- if(enable)
- {
- session.flags |= AIR_MIR_SESSION_FLAGS_ENABLE;
- }
- else
- {
- session.flags &= ~AIR_MIR_SESSION_FLAGS_ENABLE;
- }
- tag_en = _strtoul(argv[3], NULL, 0);
- if(tag_en)
- {
- session.flags |= AIR_MIR_SESSION_FLAGS_TX_TAG_OBEY_CFG;
- }
- else
- {
- session.flags &= ~AIR_MIR_SESSION_FLAGS_TX_TAG_OBEY_CFG;
- }
- rc = _portListStr2Ary(argv[4], rxPbm, 1);
- if(rc != AIR_E_OK)
- {
- AIR_PRINT("Unrecognized command.\n");
- return rc;
- }
- AIR_PRINT("pbm %x.\n", rxPbm);
- dir = _strtoul(argv[5], NULL, 0);
- if(dir == 1)
- {
- session.flags |= AIR_MIR_SESSION_FLAGS_DIR_TX;
- }
- else if(dir == 2)
- {
- session.flags |= AIR_MIR_SESSION_FLAGS_DIR_RX;
- }
- else if(dir == 3)
- {
- session.flags |= AIR_MIR_SESSION_FLAGS_DIR_TX;
- session.flags |= AIR_MIR_SESSION_FLAGS_DIR_RX;
- }
- else if (!dir)
- {
- session.flags &= ~AIR_MIR_SESSION_FLAGS_DIR_TX;
- session.flags &= ~AIR_MIR_SESSION_FLAGS_DIR_RX;
- }
- else
- {
- return AIR_E_BAD_PARAMETER;
- }
- for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
- {
- if(rxPbm[0] & (1 << i))
- {
- session.src_port = i;
- /* set port mirror session */
- rc = air_mir_addSession(0, session_id, &session);
-
- if(AIR_E_OK!=rc)
- {
- AIR_PRINT("***Error***,dst-port=%u, src-port=%u error\n", session.dst_port, session.src_port);
- return rc;
- }
- else
- AIR_PRINT("add session %d,dst-port=%u, src-port=%u\n", session_id, session.dst_port, session.src_port);
- }
- }
-
- return rc;
-}
-
-
-
-static AIR_ERROR_NO_T
-doMirrorSet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(mirrorSetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doMirrorAdd(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(mirrorAddCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doMirrorGet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(mirrorGetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doMirrorDel(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(mirrorDelCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doMirror(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(mirrorCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doMibClearPort(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T port = 0;
-
- if(1 == argc)
- {
- /* mib clear port */
- port = _strtoul(argv[0], NULL, 0);
- ret = air_mib_clear_by_port(0,port);
- AIR_PRINT("Clear port %d mib stats",port);
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("Done.\n");
- }
- else
- {
- AIR_PRINT("Fail.\n");
- }
- }
- else if(0 == argc)
- {
- /*restart mib counter*/
- air_mib_clear(0);
- AIR_PRINT("Clear all mib stats",port);
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doMibClearAcl(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T port = 0;
-
- if(0 == argc)
- {
- /* mib clear acl */
- ret = air_mib_clearAclEvent(0);
- AIR_PRINT("Clear ACL Event Counter ");
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("Done.\n");
- }
- else
- {
- AIR_PRINT("Fail.\n");
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doMibGetPort(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T port = 0;
- UI32_T tmp32 = 0xffffffff;
- AIR_MIB_CNT_RX_T rx_mib = {0};
- AIR_MIB_CNT_TX_T tx_mib = {0};
-
- port = _strtoul(argv[0], NULL, 0);
- if(1 == argc)
- {
- /* mib get <port(0..6)> */
- ret = air_mib_get(0, port, &rx_mib, &tx_mib);
- AIR_PRINT("Get MIB Counter of Port %u ", port);
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("Done.\n");
- AIR_PRINT("RX Drop Packet : %u\n", rx_mib.RDPC);
- AIR_PRINT("RX filtering Packet : %u\n", rx_mib.RFPC);
- AIR_PRINT("RX Unicast Packet : %u\n", rx_mib.RUPC);
- AIR_PRINT("RX Multicast Packet : %u\n", rx_mib.RMPC);
- AIR_PRINT("RX Broadcast Packet : %u\n", rx_mib.RBPC);
- AIR_PRINT("RX Alignment Error Packet : %u\n", rx_mib.RAEPC);
- AIR_PRINT("RX CRC Packet : %u\n", rx_mib.RCEPC);
- AIR_PRINT("RX Undersize Packet : %u\n", rx_mib.RUSPC);
- AIR_PRINT("RX Fragment Error Packet : %u\n", rx_mib.RFEPC);
- AIR_PRINT("RX Oversize Packet : %u\n", rx_mib.ROSPC);
- AIR_PRINT("RX Jabber Error Packet : %u\n", rx_mib.RJEPC);
- AIR_PRINT("RX Pause Packet : %u\n", rx_mib.RPPC);
- AIR_PRINT("RX Packet Length 64 bytes : %u\n", rx_mib.RL64PC);
- AIR_PRINT("RX Packet Length 65 ~ 127 bytes : %u\n", rx_mib.RL65PC);
- AIR_PRINT("RX Packet Length 128 ~ 255 bytes : %u\n", rx_mib.RL128PC);
- AIR_PRINT("RX Packet Length 256 ~ 511 bytes : %u\n", rx_mib.RL256PC);
- AIR_PRINT("RX Packet Length 512 ~ 1023 bytes : %u\n", rx_mib.RL512PC);
- AIR_PRINT("RX Packet Length 1024 ~ 1518 bytes: %u\n", rx_mib.RL1024PC);
- AIR_PRINT("RX Packet Length 1519 ~ max bytes : %u\n", rx_mib.RL1519PC);
- AIR_PRINT("RX_CTRL Drop Packet : %u\n", rx_mib.RCDPC);
- AIR_PRINT("RX Ingress Drop Packet : %u\n", rx_mib.RIDPC);
- AIR_PRINT("RX ARL Drop Packet : %u\n", rx_mib.RADPC);
- AIR_PRINT("FLow Control Drop Packet : %u\n", rx_mib.FCDPC);
- AIR_PRINT("WRED Drop Packtet : %u\n", rx_mib.WRDPC);
- AIR_PRINT("Mirror Drop Packet : %u\n", rx_mib.MRDPC);
- AIR_PRINT("RX sFlow Sampling Packet : %u\n", rx_mib.SFSPC);
- AIR_PRINT("Rx sFlow Total Packet : %u\n", rx_mib.SFTPC);
- AIR_PRINT("Port Control Drop Packet : %u\n", rx_mib.RXC_DPC);
- AIR_PRINT("RX Octets good or bad packtes l32 : %u\n", (UI32_T)(rx_mib.ROC & tmp32));
- AIR_PRINT("RX Octets good or bad packtes h32 : %u\n", (UI32_T)((rx_mib.ROC >> 32) & tmp32));
- AIR_PRINT("RX Octets bad packets l32 : %u\n", (UI32_T)(rx_mib.ROC2 & tmp32));
- AIR_PRINT("RX Octets bad packets h32 : %u\n", (UI32_T)((rx_mib.ROC2 >> 32) & tmp32));
- AIR_PRINT("\n");
- AIR_PRINT("TX Drop Packet : %u\n", tx_mib.TDPC);
- AIR_PRINT("TX CRC Packet : %u\n", tx_mib.TCRC);
- AIR_PRINT("TX Unicast Packet : %u\n", tx_mib.TUPC);
- AIR_PRINT("TX Multicast Packet : %u\n", tx_mib.TMPC);
- AIR_PRINT("TX Broadcast Packet : %u\n", tx_mib.TBPC);
- AIR_PRINT("TX Collision Event Count : %u\n", tx_mib.TCEC);
- AIR_PRINT("TX Single Collision Event Count : %u\n", tx_mib.TSCEC);
- AIR_PRINT("TX Multiple Conllision Event Count: %u\n", tx_mib.TMCEC);
- AIR_PRINT("TX Deferred Event Count : %u\n", tx_mib.TDEC);
- AIR_PRINT("TX Late Collision Event Count : %u\n", tx_mib.TLCEC);
- AIR_PRINT("TX Excessive Collision Event Count: %u\n", tx_mib.TXCEC);
- AIR_PRINT("TX Pause Packet : %u\n", tx_mib.TPPC);
- AIR_PRINT("TX Packet Length 64 bytes : %u\n", tx_mib.TL64PC);
- AIR_PRINT("TX Packet Length 65 ~ 127 bytes : %u\n", tx_mib.TL65PC);
- AIR_PRINT("TX Packet Length 128 ~ 255 bytes : %u\n", tx_mib.TL128PC);
- AIR_PRINT("TX Packet Length 256 ~ 511 bytes : %u\n", tx_mib.TL256PC);
- AIR_PRINT("TX Packet Length 512 ~ 1023 bytes : %u\n", tx_mib.TL512PC);
- AIR_PRINT("TX Packet Length 1024 ~ 1518 bytes: %u\n", tx_mib.TL1024PC);
- AIR_PRINT("TX Packet Length 1519 ~ max bytes : %u\n", tx_mib.TL1519PC);
- AIR_PRINT("TX Oversize Drop Packet : %u\n", tx_mib.TODPC);
- AIR_PRINT("TX Octets good or bad packtes l32 : %u\n", (UI32_T)(tx_mib.TOC & tmp32));
- AIR_PRINT("TX Octets good or bad packtes h32 : %u\n", (UI32_T)((tx_mib.TOC >> 32) & tmp32));
- AIR_PRINT("TX Octets bad packets l32 : %u\n", (UI32_T)(tx_mib.TOC2 & tmp32));
- AIR_PRINT("TX Octets bad packets h32 : %u\n", (UI32_T)((tx_mib.TOC2 >> 32) & tmp32));
- }
- else
- {
- AIR_PRINT("Fail.\n");
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doMibGetAcl(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T event = 0;
- UI32_T cnt = 0;
-
- if(1 == argc)
- {
- /* mib get acl <event(0..7)> */
- event = _strtoul(argv[0], NULL, 0);
- ret = air_mib_getAclEvent(0, event, &cnt);
- AIR_PRINT("Get counter of ACL event %u ", event);
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("Done.\n");
- AIR_PRINT("ACL Event Counter:%u\n", cnt);
- }
- else
- {
- AIR_PRINT("Fail.\n");
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doMibClear(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(mibClearCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doMibGet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(mibGetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doMib(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(mibCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doQosRateLimitExMngFrm(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T dir = 0;
- BOOL_T enable = FALSE;
-
- dir = _strtoul(argv[0], NULL, 0);
- if(2 == argc)
- {
- if(dir == 0)
- dir = AIR_QOS_RATE_DIR_EGRESS;
- else if(dir == 1)
- dir = AIR_QOS_RATE_DIR_INGRESS;
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- return ret;
- }
- enable = _strtoul(argv[1], NULL, 0);
- ret = air_qos_setRateLimitExMngFrm(0, dir, enable);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Success.\n");
- AIR_PRINT("Set %s Rate Limit Control %s management frame.\n",
- (AIR_QOS_RATE_DIR_INGRESS == dir)?"Ingress":"Egress",
- (TRUE == enable)?"exclude":"include");
- }
- else
- {
- AIR_PRINT("Fail.\n");
- return ret;
- }
- }
- else if(0 == argc)
- {
- dir = AIR_QOS_RATE_DIR_EGRESS;
- ret = air_qos_getRateLimitExMngFrm(0, dir, &enable);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Success.\n");
- AIR_PRINT("Get %s Rate Limit Control %s management frame.\n",
- (AIR_QOS_RATE_DIR_INGRESS == dir)?"Ingress":"Egress",
- (TRUE == enable)?"exclude":"include");
- }
- else
- {
- AIR_PRINT("Fail.\n");
- return ret;
- }
- dir = AIR_QOS_RATE_DIR_INGRESS;
- ret = air_qos_getRateLimitExMngFrm(0, dir, &enable);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Success.\n");
- AIR_PRINT("Get %s Rate Limit Control %s management frame.\n",
- (AIR_QOS_RATE_DIR_INGRESS == dir)?"Ingress":"Egress",
- (TRUE == enable)?"exclude":"include");
- }
- else
- {
- AIR_PRINT("Fail.\n");
- return ret;
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-
-}
-
-static AIR_ERROR_NO_T
-doQosPortPriority(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- AIR_PORT_BITMAP_T portlist = {0};
- UI32_T priority = 0;
- UI8_T i = 0;
-
- ret = _portListStr2Ary(argv[0], portlist, 1);
- if(ret != AIR_E_OK)
- {
- AIR_PRINT("Unrecognized command.\n");
- return ret;
- }
- if(2 == argc)
- {
- priority = _strtoul(argv[1], NULL, 0);
- for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
- {
- if(portlist[0] & (1 << i))
- {
- ret = air_qos_setPortPriority(0, i, priority);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Set Port%02d port based priority %d Success.\n", i, priority);
- }
- else
- {
- AIR_PRINT("Set Port%02d port based priority %d Fail.\n", i, priority);
- }
- }
- }
- }
- else if(1 == argc)
- {
- for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
- {
- if(portlist[0] & (1 << i))
- {
- ret = air_qos_getPortPriority(0, i, &priority);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Get Port%d port based priority %d.\n", i, priority);
- }
- else
- {
- AIR_PRINT("Get Port%d port based priority Fail.\n", i);
- }
- }
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doQosRateLimit(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- AIR_PORT_BITMAP_T portlist = {0};
- AIR_QOS_RATE_LIMIT_CFG_T rl = {0};
- UI8_T i = 0;
-
- ret = _portListStr2Ary(argv[0], portlist, 1);
- if(ret != AIR_E_OK)
- {
- AIR_PRINT("Unrecognized command.\n");
- return ret;
- }
- if(5 == argc)
- {
- rl.ingress_cir = _strtoul(argv[1], NULL, 0);
- rl.ingress_cbs = _strtoul(argv[2], NULL, 0);
- rl.egress_cir = _strtoul(argv[3], NULL, 0);
- rl.egress_cbs = _strtoul(argv[4], NULL, 0);
- rl.flags |= AIR_QOS_RATE_LIMIT_CFG_FLAGS_ENABLE_INGRESS;
- rl.flags |= AIR_QOS_RATE_LIMIT_CFG_FLAGS_ENABLE_EGRESS;
- for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
- {
- if(portlist[0] & (1 << i))
- {
- ret = air_qos_setRateLimit(0, i, &rl);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Set Port%02d Ingress CIR %d CBS %d Egress CIR %d CBS %d Success.\n", i, rl.ingress_cir, rl.ingress_cbs, rl.egress_cir, rl.egress_cbs);
- }
- else
- {
- AIR_PRINT("Set Port%02d Ingress CIR %d CBS %d Egress CIR %d CBS %d Fail.\n", i, rl.ingress_cir, rl.ingress_cbs, rl.egress_cir, rl.egress_cbs);
- }
- }
- }
- }
- else if(1 == argc)
- {
- for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
- {
- if(portlist[0] & (1 << i))
- {
- ret = air_qos_getRateLimit(0, i, &rl);
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("Get Port%02d Ingress CIR %d CBS %d Egress CIR %d CBS %d\n", i, rl.ingress_cir, rl.ingress_cbs, rl.egress_cir, rl.egress_cbs);
- }
- else
- {
- AIR_PRINT("Get Port%02d Rate Info Fail.\n", i);
- }
- }
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doQosRateLimitEnable(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- AIR_PORT_BITMAP_T portlist = {0};
- C8_T sten[2][10] = {"Disable", "Enable"};
- C8_T stdir[2][10] = {"Egress", "Ingress"};
- UI32_T dir = 0, en = 0;
- AIR_QOS_RATE_DIR_T tmp_dir = AIR_QOS_RATE_DIR_LAST;
- BOOL_T state = FALSE;
- UI8_T i = 0;
-
- ret = _portListStr2Ary(argv[0], portlist, 1);
- if(ret != AIR_E_OK)
- {
- AIR_PRINT("Unrecognized command.\n");
- return ret;
- }
- if(3 == argc)
- {
- dir = _strtoul(argv[1], NULL, 0);
- en = _strtoul(argv[2], NULL, 0);
- if(dir == 0)
- tmp_dir = AIR_QOS_RATE_DIR_EGRESS;
- else if(dir == 1)
- tmp_dir = AIR_QOS_RATE_DIR_INGRESS;
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
- if(en)
- state= TRUE;
- else
- state = FALSE;
-
- for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
- {
- if(portlist[0] & (1 << i))
- {
- ret = air_qos_setRateLimitEnable(0, i, tmp_dir, state);
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("Set Port%02d %s rate %s Success.\n", i, stdir[dir], sten[en]);
- }
- else
- {
- AIR_PRINT("Set Port%02d %s rate %s Fail.\n", i, stdir[dir], sten[en]);
- }
- }
- }
- }
- else if(1 == argc)
- {
- for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
- {
- if(portlist[0] & (1 << i))
- {
- tmp_dir = AIR_QOS_RATE_DIR_EGRESS;
- dir = 0;
- ret = air_qos_getRateLimitEnable(0, i, tmp_dir, &state);
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("Get Port%02d %s rate %s Success.\n", i, stdir[dir], sten[state]);
- }
- else
- {
- AIR_PRINT("Get Port%02d %s rate state Fail.\n", i, stdir[dir]);
- }
- tmp_dir = AIR_QOS_RATE_DIR_INGRESS;
- dir = 1;
- ret = air_qos_getRateLimitEnable(0, i, tmp_dir, &state);
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("Get Port%02d %s rate %s Success.\n", i, stdir[dir], sten[state]);
- }
- else
- {
- AIR_PRINT("Get Port%02d %s rate state Fail.\n", i, stdir[dir]);
- }
- }
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-
-}
-
-static AIR_ERROR_NO_T
-doQosDscp2Pri(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T dscp = 0, priority = 0;
-
- dscp = _strtoul(argv[0], NULL, 0);
- if(2 == argc)
- {
- priority = _strtoul(argv[1], NULL, 0);
- ret = air_qos_setDscp2Pri(0, dscp, priority);
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("Set DSCP %d to priority %d Success.\n", dscp, priority);
- }
- else
- {
- AIR_PRINT("Set DSCP %d to priority %d Fail.\n", dscp, priority);
- }
- }
- else if(1 == argc)
- {
- ret = air_qos_getDscp2Pri(0, dscp, &priority);
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("Get DSCP %d to priority %d\n", dscp, priority);
- }
- else
- {
- AIR_PRINT("Get DSCP %d to priority Fail.\n", dscp);
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doQosPri2Queue(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T priority = 0, queue = 0;
-
- priority = _strtoul(argv[1], NULL, 0);
-
- if(2 == argc)
- {
- priority = _strtoul(argv[0], NULL, 0);
- queue = _strtoul(argv[1], NULL, 0);
- ret = air_qos_setPri2Queue(0, priority, queue);
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("Set priority %d to queue %d Success.\n", priority, queue);
- }
- else
- {
- AIR_PRINT("Set priority %d to queue %d Fail.\n", priority, queue);
- }
- }
- else
- {
- for(; priority < AIR_QOS_QUEUE_MAX_NUM; priority++)
- {
- ret = air_qos_getPri2Queue(0, priority, &queue);
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("Get priority %d to queue %d\n", priority, queue);
- }
- else
- {
- AIR_PRINT("Get priority %d to queue Fail.\n", priority);
- }
- }
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doQosTrustMode(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T mode = 0;
- C8_T bs[4][13] = {"port", "1p_port", "dscp_port", "dscp_1p_port"};
- AIR_QOS_TRUST_MODE_T mode_t = AIR_QOS_TRUST_MODE_LAST;
- AIR_PORT_BITMAP_T portlist = {0};
- UI8_T i = 0;
-
- ret = _portListStr2Ary(argv[0], portlist, 1);
- if(ret != AIR_E_OK)
- {
- AIR_PRINT("Unrecognized command.\n");
- return ret;
- }
- if(2 == argc)
- {
- mode = _strtoul(argv[1], NULL, 0);
- if(mode == 0)
- mode_t = AIR_QOS_TRUST_MODE_PORT;
- else if(mode == 1)
- mode_t = AIR_QOS_TRUST_MODE_1P_PORT;
- else if(mode == 2)
- mode_t = AIR_QOS_TRUST_MODE_DSCP_PORT;
- else if(mode == 3)
- mode_t = AIR_QOS_TRUST_MODE_DSCP_1P_PORT;
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
- for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
- {
- if(portlist[0] & (1 << i))
- {
- ret = air_qos_setTrustMode(0, i, mode_t);
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("port %d Set Trust mode %s Success.\n", i, bs[mode]);
- }
- else
- {
- AIR_PRINT("port %d Set Trust mode %s Fail.\n", i, bs[mode]);
- }
- }
- }
- }
- else if(1 == argc)
- {
- for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
- {
- if(portlist[0] & (1 << i))
- {
- mode_t = AIR_QOS_TRUST_MODE_LAST;
- ret = air_qos_getTrustMode(0, i, &mode_t);
- if(AIR_E_OK == ret)
- {
- if(mode_t == AIR_QOS_TRUST_MODE_PORT)
- mode = 0;
- else if(mode_t == AIR_QOS_TRUST_MODE_1P_PORT)
- mode = 1;
- else if(mode_t == AIR_QOS_TRUST_MODE_DSCP_PORT)
- mode = 2;
- else if(mode_t == AIR_QOS_TRUST_MODE_DSCP_1P_PORT)
- mode = 3;
- else
- {
- AIR_PRINT("port %d Get Trust mode Fail.\n", i);
- return AIR_E_OTHERS;
- }
- AIR_PRINT("port %d Get Trust mode %s\n", i, bs[mode]);
- }
- else
- {
- AIR_PRINT("port %d Get Trust mode Fail.\n", i);
- }
- }
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doQosScheduleAlgo(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- AIR_PORT_BITMAP_T portlist = {0};
- AIR_QOS_SCH_MODE_T sch_mode = AIR_QOS_SCH_MODE_LAST;
- UI32_T scheduler = 0;
- UI8_T queue = 0;
- C8_T sche[3][5] = {"SP", "WRR", "WFQ"};
- UI32_T weight = AIR_QOS_SHAPER_NOSETTING;
- UI8_T i = 0;
-
- ret = _portListStr2Ary(argv[0], portlist, 1);
- if(ret != AIR_E_OK)
- {
- AIR_PRINT("Unrecognized command.\n");
- return ret;
- }
- AIR_PRINT("port list is %d\n", portlist[0]);
- if(4 == argc)
- {
- queue = _strtoul(argv[1], NULL, 0);
- AIR_PRINT("queue is %d\n", queue);
- scheduler = _strtoul(argv[2], NULL, 0);
- AIR_PRINT("scheduler is %d\n", scheduler);
- weight = _strtoul(argv[3], NULL, 0);
- AIR_PRINT("weight is %d\n", weight);
- if(scheduler == 0)
- {
- sch_mode = AIR_QOS_SCH_MODE_SP;
- weight = AIR_QOS_SHAPER_NOSETTING;
- if(weight != AIR_QOS_SHAPER_NOSETTING)
- AIR_PRINT("[Warning] SP schedule mode no need weight\n");
- }
- else if(scheduler == 1)
- {
- sch_mode = AIR_QOS_SCH_MODE_WRR;
- if(weight == AIR_QOS_SHAPER_NOSETTING)
- {
- AIR_PRINT("[Warning] No weight value input , plz check\n");
- return AIR_E_BAD_PARAMETER;
- }
- AIR_PRINT("sch_mode is 1\n");
- }
- else if(scheduler == 2)
- {
- sch_mode = AIR_QOS_SCH_MODE_WFQ;
- if(weight == AIR_QOS_SHAPER_NOSETTING)
- {
- AIR_PRINT("[Warning] No weight value input , plz check\n");
- return AIR_E_BAD_PARAMETER;
- }
- }
- else
- {
- AIR_PRINT("Unknown schedule mode, plz check again\n");
- return AIR_E_BAD_PARAMETER;
- }
- for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
- {
- if(portlist[0] & (1 << i))
- {
- AIR_PRINT("port %d\n", i);
- ret = air_qos_setScheduleAlgo(0, i, queue, sch_mode, weight);
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("Set Port%02d Scheduler %s Success.\n", i, sche[scheduler]);
- }
- else
- {
- AIR_PRINT("Set Port%02d Scheduler %s Fail.\n", i, sche[scheduler]);
- }
- }
- }
- }
- else if(2 == argc)
- {
- queue = _strtoul(argv[1], NULL, 0);
- for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
- {
- if(portlist[0] & (1 << i))
- {
- ret = air_qos_getScheduleAlgo(0, i, queue, &sch_mode, &weight);
- if(AIR_E_OK == ret)
- {
- if(sch_mode == AIR_QOS_SCH_MODE_SP)
- AIR_PRINT("Get Port%02d queue %d Scheduler %s\n", i, queue, sche[sch_mode]);
- else if((sch_mode == AIR_QOS_SCH_MODE_WRR) || (sch_mode == AIR_QOS_SCH_MODE_WFQ))
- AIR_PRINT("Get Port%02d queue %d Scheduler %s weight %d\n", i, queue, sche[sch_mode], weight);
- else
- AIR_PRINT("Get Port%02d queue %d Scheduler unknown\n", i, queue);
- }
- else
- {
- AIR_PRINT("Get Port%02d queue %d Scheduler Fail.\n", i, queue);
- }
- }
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doQosGet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(qosGetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doQosSet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(qosSetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doQos(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(qosCmds, argc, argv);
-}
-static AIR_ERROR_NO_T
-doDiagTxComply(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T phy = 0;
- UI32_T mode = 0;
-
- phy = _strtoul(argv[0], NULL, 0);
- if(2 == argc)
- {
- /* diag set txComply <phy(0~5)> <mode(0~8)> */
- mode = _strtoul(argv[1], NULL, 0);
- ret = air_diag_setTxComplyMode(0, phy, mode);
- AIR_PRINT("Set diagnostic function: PHY %u Tx Compliance mode = %u ", phy, mode);
- }
- else if(1 == argc)
- {
- /* diag get txComply <phy(0~5)> */
- ret = air_diag_getTxComplyMode(0, phy, &mode);
- AIR_PRINT("Get diagnostic function: PHY %u Tx Compliance mode ", phy);
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
-
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("Done.\n\tMode=");
- switch(mode)
- {
- case AIR_DIAG_TXCOMPLY_MODE_10M_NLP:
- AIR_PRINT("%s\n", "10M_NLP");
- break;
- case AIR_DIAG_TXCOMPLY_MODE_10M_RANDOM:
- AIR_PRINT("%s\n", "10M_Random");
- break;
- case AIR_DIAG_TXCOMPLY_MODE_10M_SINE:
- AIR_PRINT("%s\n", "10M_Sine");
- break;
- case AIR_DIAG_TXCOMPLY_MODE_100M_PAIR_A:
- AIR_PRINT("%s\n", "100M_Pair_a");
- break;
- case AIR_DIAG_TXCOMPLY_MODE_100M_PAIR_B:
- AIR_PRINT("%s\n", "100M_Pair_b");
- break;
- case AIR_DIAG_TXCOMPLY_MODE_1000M_TM1:
- AIR_PRINT("%s\n", "1000M_TM1");
- break;
- case AIR_DIAG_TXCOMPLY_MODE_1000M_TM2:
- AIR_PRINT("%s\n", "1000M_TM2");
- break;
- case AIR_DIAG_TXCOMPLY_MODE_1000M_TM3:
- AIR_PRINT("%s\n", "1000M_TM3");
- break;
- case AIR_DIAG_TXCOMPLY_MODE_1000M_TM4:
- AIR_PRINT("%s\n", "1000M_TM4");
- break;
- default:
- break;
- }
- }
- else
- if(AIR_E_OTHERS == ret)
- {
- AIR_PRINT("isn't setting.\n");
- }
- else
- {
- AIR_PRINT("Fail.\n");
- }
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doDiagSet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(diagSetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doDiagGet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(diagGetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doDiag(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(diagCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doLedMode(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T mode = 0;
-
- if(1 == argc)
- {
- /* led set mode <mode(0:disable, 1~3:2 LED, 4:User-Define)> */
- mode = _strtoul(argv[0], NULL, 0);
- ret = air_led_setMode(0, 0, mode);
- AIR_PRINT("Set LED mode ");
- }
- else if(0 == argc)
- {
- /* led get mode */
- ret = air_led_getMode(0, 0, &mode);
- AIR_PRINT("Get LED mode ");
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
-
- if(AIR_E_OK == ret)
- {
- switch(mode)
- {
- case AIR_LED_MODE_DISABLE:
- AIR_PRINT(": Disabled.\n");
- break;
- case AIR_LED_MODE_2LED_MODE0:
- AIR_PRINT(": LED 0:Link / LED 1:Activity.\n");
- break;
- case AIR_LED_MODE_2LED_MODE1:
- AIR_PRINT(": LED 0:1000M Activity / LED 1:100M Activity.\n");
- break;
- case AIR_LED_MODE_2LED_MODE2:
- AIR_PRINT(": LED 0:1000M Activity / LED 1:10&100M Activity.\n");
- break;
- case AIR_LED_MODE_USER_DEFINE:
- AIR_PRINT(": User-Defined.\n");
- break;
- default:
- AIR_PRINT(": Fail.\n");
- break;
- }
- }
- else
- if(AIR_E_OTHERS == ret)
- {
- AIR_PRINT(": Unrecognized.\n");
- }
- else
- {
- AIR_PRINT("Fail.\n");
- }
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doLedState(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI8_T entity = 0;
- BOOL_T state = FALSE;
-
- entity = _strtoul(argv[0], NULL, 0);
- if(2 == argc)
- {
- /* led set state <led(0..1)> <state(1:En 0:Dis)> */
- state = _strtoul(argv[1], NULL, 0);
- ret = air_led_setState(0, 0, entity, state);
- AIR_PRINT("Set LED %u state ", entity);
- }
- else if(1 == argc)
- {
- /* led get state <led(0..1)> */
- ret = air_led_getState(0, 0, entity, &state);
- AIR_PRINT("Get LED %u state ", entity );
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
-
- if(AIR_E_OK == ret)
- {
- AIR_PRINT(": %s.\n", (state)?"Enable":"Disabled");
- }
- else
- if(AIR_E_OTHERS == ret)
- {
- AIR_PRINT(": Unrecognized.\n");
- }
- else
- {
- AIR_PRINT("Fail.\n");
- }
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doLedUsrDef(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T i = 0;
- UI8_T entity = 0;
- BOOL_T polarity = LOW;
- UI32_T on_evt_map = 0;
- UI32_T blk_evt_map = 0;
- AIR_LED_ON_EVT_T on_evt;
- AIR_LED_BLK_EVT_T blk_evt;
-
- entity = _strtoul(argv[0], NULL, 0);
- if(4 == argc)
- {
- /* led set usr <led(0..1)> <polarity(0:low, 1:high)> <on_evt(7'bin)> <blink_evt(10'bin)> */
- polarity = _strtoul(argv[1], NULL, 0);
- on_evt_map = _strtoul(argv[2], NULL, 2);
- blk_evt_map = _strtoul(argv[3], NULL, 2);
-
- memset(&on_evt, 0, sizeof(AIR_LED_ON_EVT_T));
- if(on_evt_map & BIT(0))
- {
- on_evt.link_1000m = TRUE;
- }
- if(on_evt_map & BIT(1))
- {
- on_evt.link_100m = TRUE;
- }
- if(on_evt_map & BIT(2))
- {
- on_evt.link_10m = TRUE;
- }
- if(on_evt_map & BIT(3))
- {
- on_evt.link_dn = TRUE;
- }
- if(on_evt_map & BIT(4))
- {
- on_evt.fdx = TRUE;
- }
- if(on_evt_map & BIT(5))
- {
- on_evt.hdx = TRUE;
- }
- if(on_evt_map & BIT(6))
- {
- on_evt.force = TRUE;
- }
-
- memset(&blk_evt, 0, sizeof(AIR_LED_BLK_EVT_T));
- if(blk_evt_map & BIT(0))
- {
- blk_evt.tx_act_1000m = TRUE;
- }
- if(blk_evt_map & BIT(1))
- {
- blk_evt.rx_act_1000m = TRUE;
- }
- if(blk_evt_map & BIT(2))
- {
- blk_evt.tx_act_100m = TRUE;
- }
- if(blk_evt_map & BIT(3))
- {
- blk_evt.rx_act_100m = TRUE;
- }
- if(blk_evt_map & BIT(4))
- {
- blk_evt.tx_act_10m = TRUE;
- }
- if(blk_evt_map & BIT(5))
- {
- blk_evt.rx_act_10m = TRUE;
- }
- if(blk_evt_map & BIT(6))
- {
- blk_evt.cls = TRUE;
- }
- if(blk_evt_map & BIT(7))
- {
- blk_evt.rx_crc = TRUE;
- }
- if(blk_evt_map & BIT(8))
- {
- blk_evt.rx_idle = TRUE;
- }
- if(blk_evt_map & BIT(9))
- {
- blk_evt.force = TRUE;
- }
- ret = air_led_setUsrDef(0, 0, entity, polarity, on_evt, blk_evt);
- AIR_PRINT("Set LED %u User-define ", entity);
- }
- else if(1 == argc)
- {
- /* led get usr <led(0..1)> */
- ret = air_led_getUsrDef(0, 0, entity, &polarity, &on_evt, &blk_evt);
- AIR_PRINT("Get LED %u User-define ", entity );
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
-
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("Done.\n");
- AIR_PRINT("Polarity:%u.\n", polarity);
- AIR_PRINT("On Event:\n");
- i = 6;
- AIR_PRINT("\t(%u)Force on :%s\n", i--, (on_evt.force)?"On":"Off");
- AIR_PRINT("\t(%u)Half Duplex :%s\n", i--, (on_evt.hdx)?"On":"Off");
- AIR_PRINT("\t(%u)Full Duplex :%s\n", i--, (on_evt.fdx)?"On":"Off");
- AIR_PRINT("\t(%u)Link Down :%s\n", i--, (on_evt.link_dn)?"On":"Off");
- AIR_PRINT("\t(%u)Link 10M :%s\n", i--, (on_evt.link_10m)?"On":"Off");
- AIR_PRINT("\t(%u)Link 100M :%s\n", i--, (on_evt.link_100m)?"On":"Off");
- AIR_PRINT("\t(%u)Link 1000M :%s\n", i--, (on_evt.link_1000m)?"On":"Off");
-
- AIR_PRINT("Blinking Event:\n");
- i = 9;
- AIR_PRINT("\t(%u)Force blinks :%s\n", i--, (blk_evt.force)?"On":"Off");
- AIR_PRINT("\t(%u)Rx Idle Error :%s\n", i--, (blk_evt.rx_idle)?"On":"Off");
- AIR_PRINT("\t(%u)Rx CRC Error :%s\n", i--, (blk_evt.rx_crc)?"On":"Off");
- AIR_PRINT("\t(%u)Collision :%s\n", i--, (blk_evt.cls)?"On":"Off");
- AIR_PRINT("\t(%u)10Mbps RX Activity :%s\n", i--, (blk_evt.rx_act_10m)?"On":"Off");
- AIR_PRINT("\t(%u)10Mbps TX Activity :%s\n", i--, (blk_evt.tx_act_10m)?"On":"Off");
- AIR_PRINT("\t(%u)100Mbps RX Activity :%s\n", i--, (blk_evt.rx_act_100m)?"On":"Off");
- AIR_PRINT("\t(%u)100Mbps TX Activity :%s\n", i--, (blk_evt.tx_act_100m)?"On":"Off");
- AIR_PRINT("\t(%u)1000Mbps RX Activity :%s\n", i--, (blk_evt.rx_act_1000m)?"On":"Off");
- AIR_PRINT("\t(%u)1000Mbps TX Activity :%s\n", i--, (blk_evt.tx_act_1000m)?"On":"Off");
- }
- else
- {
- AIR_PRINT("Fail.\n");
- }
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doLedBlkTime(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- AIR_LED_BLK_DUR_T time = 0;
-
- if(1 == argc)
- {
- /* led set time <time(0~5)> */
- time = _strtoul(argv[0], NULL, 0);
- ret = air_led_setBlkTime(0, 0, time);
- AIR_PRINT("Set Blinking Duration ");
- }
- else if(0 == argc)
- {
- /* led get time */
- ret = air_led_getBlkTime(0, 0, &time);
- AIR_PRINT("Get Blinking Duration ");
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
-
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("Done.\n");
- AIR_PRINT("\tBlinking duration : %u (ms)\n", (32 << time) );
- }
- else
- {
- AIR_PRINT("Fail.\n");
- }
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doLedSet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(ledSetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doLedGet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(ledGetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doLed(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(ledCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doShowVersion(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_PRINT("VERSION: %s\n", AIR_VER_SDK);
-
- return AIR_E_OK;
-}
-
-static AIR_ERROR_NO_T
-doShow(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(showCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doStormRate(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T port = 0, type = 0;
- UI32_T unit = 0, count = 0;
- C8_T stype[3][5] = {"Bcst", "Mcst", "Ucst"};
- UI32_T kb = 0;
-
- port = _strtol(argv[0], NULL, 10);
- type = _strtol(argv[1], NULL, 10);
- if(4 == argc)
- {
- count = _strtol(argv[2], NULL, 10);
- unit = _strtol(argv[3], NULL, 10);
-
- if(0 == unit)
- kb = 64;
- else if(1 == unit)
- kb = 256;
- else if(2 == unit)
- kb = 1024;
- else if(3 == unit)
- kb = 4096;
- else
- kb = 16384;
- ret = air_sec_setStormRate(0, port, type, count, unit);
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("Set Port%02d %s storm rate (%d * %d) = %d Kbps\n", port, stype[type], count, kb, (count*kb));
- }
- else
- {
- AIR_PRINT("Set Port%02d %s storm rate Fail.\n", port, stype[type]);
- AIR_PRINT("Note: Port(0..4) can only select unit(0..3), port(5..6) can only select unit(4)\n");
- }
- }
- else if(2 == argc)
- {
- ret = air_sec_getStormRate(0, port, type, &count, &unit);
- if(AIR_E_OK == ret)
- {
- if(0 == unit)
- kb = 64;
- else if(1 == unit)
- kb = 256;
- else if(2 == unit)
- kb = 1024;
- else if(3 == unit)
- kb = 4096;
- else
- kb = 16384;
- AIR_PRINT("Port%02d %s storm rate (%d * %d) = %d Kbps\n", port, stype[type], count, kb, (count*kb));
- }
- else
- {
- AIR_PRINT("Get Port%02d %s storm rate Fail\n", port, stype[type]);
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doFldMode(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T port = 0, type = 0;
- BOOL_T fld_en = 0;
- C8_T stype[4][5] = {"Bcst", "Mcst", "Ucst", "Qury"};
- C8_T sen[2][10] = {"Disable", "Enable"};
-
- port = _strtol(argv[0], NULL, 10);
- type = _strtol(argv[1], NULL, 10);
-
- if(2 == argc)
- {
- ret = air_sec_getFldMode(0, port, type, &fld_en);
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("Get Port%02d flooding %s frame %s\n", port, stype[type], sen[fld_en]);
- }
- else
- {
- AIR_PRINT("Get Port%02d flooding %s frame Fail\n", port, stype[type]);
- }
- }
- else if(3 == argc)
- {
- fld_en = _strtol(argv[2], NULL, 10);
- ret = air_sec_setFldMode(0, port, type, fld_en);
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("Set Port%02d flooding %s frame %s Success\n", port, stype[type], sen[fld_en]);
- }
- else
- {
- AIR_PRINT("Set Port%02d flooding %s frame %s Fail\n", port, stype[type], sen[fld_en]);
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doStormEnable(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T port = 0, type = 0;
- BOOL_T en = 0;
- C8_T sen[2][10] = {"Disable", "Enable"};
- C8_T stype[3][5] = {"Bcst", "Mcst", "Ucst"};
-
- port = _strtol(argv[0], NULL, 10);
- type = _strtol(argv[1], NULL, 10);
- if(3 == argc)
- {
- en = _strtol(argv[2], NULL, 10);
- ret = air_sec_setStormEnable(0, port, type, en);
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("Set Port%02d %s storm %s Success.\n", port, stype[type], sen[en]);
- }
- else
- {
- AIR_PRINT("Set Port%02d %s storm %s Fail.\n", port, stype[type], sen[en]);
- }
- }
- else if(2 == argc)
- {
- ret = air_sec_getStormEnable(0, port, type, &en);
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("Port%02d %s storm %s\n", port, stype[type], sen[en]);
- }
- else
- {
- AIR_PRINT("Get Port%02d %s storm Fail\n", port, stype[type]);
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doSaLearning(UI32_T argc, C8_T *argv[])
-{
- UI32_T port = 0;
- AIR_SEC_PORTSEC_PORT_CONFIG_T port_config;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- port = _strtoul(argv[0], NULL, 0);
- if(2 == argc)
- {
- memset(&port_config, 0, sizeof(AIR_SEC_PORTSEC_PORT_CONFIG_T));
- rc = air_sec_getPortSecPortCfg(0, port, &port_config);
- port_config.sa_lrn_en = _strtoul(argv[1], NULL, 0);
- rc = air_sec_setPortSecPortCfg(0, port, port_config);
- if(AIR_E_OK == rc)
- {
- AIR_PRINT("Set Port%02d sa learn %s Success.\n", port, port_config.sa_lrn_en?"Enable":"Disable");
- }
- else
- {
- AIR_PRINT("Set Port%02d sa learn %s Fail.\n", port, port_config.sa_lrn_en?"Enable":"Disable");
- }
- }
- else if(1 == argc)
- {
- rc = air_sec_getPortSecPortCfg(0, port, &port_config);
- if(AIR_E_OK == rc)
- {
- AIR_PRINT("Port%02d sa learn: %s\n", port, port_config.sa_lrn_en?"Enable":"Disable");
- }
- else
- {
- AIR_PRINT("Get Port%02d sa learn Fail\n", port);
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- rc = AIR_E_BAD_PARAMETER;
- }
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doSaLimit(UI32_T argc, C8_T *argv[])
-{
- UI32_T port = 0;
- AIR_SEC_PORTSEC_PORT_CONFIG_T port_config;
- AIR_ERROR_NO_T rc = AIR_E_OK;
-
- port = _strtoul(argv[0], NULL, 0);
- if(3 == argc)
- {
- memset(&port_config, 0, sizeof(AIR_SEC_PORTSEC_PORT_CONFIG_T));
- rc = air_sec_getPortSecPortCfg(0, port, &port_config);
- port_config.sa_lmt_en = _strtoul(argv[1], NULL, 0);
- port_config.sa_lmt_cnt = _strtoul(argv[2], NULL, 0);
- rc = air_sec_setPortSecPortCfg(0, port, port_config);
- if(AIR_E_OK == rc)
- {
- AIR_PRINT("Set Port%02d sa limit %s Success.\n", port, port_config.sa_lmt_en?"Enable":"Disable");
- }
- else
- {
- AIR_PRINT("Set Port%02d sa limit %s Fail.\n", port, port_config.sa_lmt_en?"Enable":"Disable");
- }
- }
- else if(1 == argc)
- {
- rc = air_sec_getPortSecPortCfg(0, port, &port_config);
- if(AIR_E_OK == rc)
- {
- AIR_PRINT("Port%02d ", port);
- AIR_PRINT("sa limit: %s\n", port_config.sa_lmt_en?"Enable":"Disable");
- if(TRUE == (port_config.sa_lmt_en && (AIR_MAX_NUM_OF_MAC == port_config.sa_lmt_cnt)))
- {
- AIR_PRINT("Sa learning without limitation\n");
- }
- else if(TRUE == (port_config.sa_lmt_en && (AIR_MAX_NUM_OF_MAC > port_config.sa_lmt_cnt)))
- {
- AIR_PRINT("Rx sa allowable learning number: %d\n", port_config.sa_lmt_cnt);
- }
- }
- else
- {
- AIR_PRINT("Get Port%02d sa limit Fail\n", port);
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- rc = AIR_E_BAD_PARAMETER;
- }
-
- return rc;
-}
-
-static AIR_ERROR_NO_T
-doSecGet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(secGetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doSecSet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(secSetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doSec(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(secCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doSwitchCpuPortEn(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- BOOL_T cpu_en = FALSE;
-
- if(0 == argc)
- {
- /* switch get sysPhyEn */
- ret = air_switch_getCpuPortEn(0, &cpu_en);
- AIR_PRINT("Get Cpu Port State ");
- if(ret == AIR_E_OK)
- {
- AIR_PRINT(": %s\n", cpu_en?"Enable":"Disable");
- }
- else
- {
- AIR_PRINT("Fail!\n");
- }
- }
- else if(1 == argc)
- {
- /* switch set sysPhyEn <phy_en> */
- cpu_en = _strtol(argv[0], NULL, 0);
- ret = air_switch_setCpuPortEn(0, cpu_en);
- AIR_PRINT("Set CPU port State ");
- if(ret == AIR_E_OK)
- {
- AIR_PRINT(": %s\n", cpu_en?"Enable":"Disable");
- }
- else
- {
- AIR_PRINT("Fail!\n");
- }
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doSwitchCpuPort(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- BOOL_T cpu_en = FALSE;
- UI32_T port = 0;
- C8_T str_temp[AIR_MAX_NUM_OF_PORTS+1];
-
- if(1 == argc)
- {
- /* switch set cpuPort <portnumber> */
- port = _strtol(argv[0], NULL, 10);
- ret = air_switch_setCpuPort(0, port);
- AIR_PRINT("Set CPU Port ");
- }
- else if(0 == argc)
- {
- /* switch get cpuPort */
- ret = air_switch_getCpuPort(0, &port);
- AIR_PRINT("Get CPU Port ");
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- if(AIR_E_OK == ret)
- {
- AIR_PRINT(": %d\n", port);
- }
- else
- {
- AIR_PRINT("Fail!\n");
- }
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doSwitchPhyLCIntrEn(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T phy = 0;
- BOOL_T enable = FALSE;
-
- if(2 == argc)
- {
- /* switch set phyLCIntrEn <phy(0..6)> <(1:En,0:Dis)> */
- phy = _strtol(argv[0], NULL, 10);
- enable = _strtol(argv[1], NULL, 10);
- ret = air_switch_setSysIntrEn(0, (phy + AIR_SYS_INTR_TYPE_PHY0_LC), enable);
- }
- else if(1 == argc)
- {
- /* switch get phyLCIntrEn <phy(0..6)> */
- phy = _strtol(argv[0], NULL, 10);
- ret = air_switch_getSysIntrEn(0, (phy + AIR_SYS_INTR_TYPE_PHY0_LC), &enable);
- AIR_PRINT("PHY(%d) LinkChange interrupt : %s\n", phy, (TRUE == enable) ? "enable" : "disable");
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doSwitchPhyLCIntrSts(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T phy = 0;
- BOOL_T enable = FALSE;
-
- if(2 == argc)
- {
- /* switch set phyLCIntrSts <phy(0..6)> <(1:En)> */
- phy = _strtol(argv[0], NULL, 10);
- enable = _strtol(argv[1], NULL, 10);
- ret = air_switch_setSysIntrStatus(0, (phy + AIR_SYS_INTR_TYPE_PHY0_LC), enable);
- }
- else if(1 == argc)
- {
- /* switch get phyLCIntrSts <phy(0..6)> */
- phy = _strtol(argv[0], NULL, 10);
- ret = air_switch_getSysIntrStatus(0, (phy + AIR_SYS_INTR_TYPE_PHY0_LC), &enable);
- AIR_PRINT("PHY(%d) LinkChange interrupt state : %s\n", phy, (TRUE == enable) ? "set" : "unset");
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- ret = AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-
-static AIR_ERROR_NO_T
-doSwitchSet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(switchSetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doSwitchGet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(switchGetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doSwitch(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(switchCmds, argc, argv);
-}
-
-static void _air_acl_printRuleMap(UI32_T *rule_map, UI32_T ary_num)
-{
- UI32_T i;
- BOOL_T first;
-
- first = TRUE;
- for(i=0; i<ary_num*32; i++)
- {
- if(rule_map[i/32] & BIT(i%32))
- {
- if(TRUE == first)
- {
- AIR_PRINT("%u", i);
- first = FALSE;
- }
- else
- {
- AIR_PRINT(",%u", i);
- }
- }
- }
- AIR_PRINT("\n");
-}
-
-static AIR_ERROR_NO_T
-doAclEn(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T argi=0;
- UI32_T port = 0;
- BOOL_T en = FALSE;
-
- if(1 == argc)
- {
- /* acl set en <en(1:En,0:Dis)> */
- en = _strtoul(argv[argi++], NULL, 2);
- ret = air_acl_setGlobalState(0, en);
- AIR_PRINT("Set Global ACL function ");
- }
- else if(0 == argc)
- {
- /* acl get en */
- ret = air_acl_getGlobalState(0, &en);
- AIR_PRINT("Get Global ACL function ");
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
-
- if(ret == AIR_E_OK)
- {
- AIR_PRINT(": %s\n", (TRUE == en)?"Enable":"Disable");
- }
- else
- {
- AIR_PRINT("Fail!\n");
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doAclRule(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T rule_idx = 0;
- BOOL_T state = FALSE, reverse = FALSE, end = FALSE;
- UI32_T argi = 0, ipv6 = 0, i = 0;
- AIR_ACL_RULE_T rule;
- UI8_T tmp_ip[16] = {0};
- C8_T str_temp[AIR_MAX_NUM_OF_PORTS+1];
- C8_T str[40];
-
- memset(&rule, 0, sizeof(AIR_ACL_RULE_T));
- if(argc >= 6)
- {
- /* acl set rule <idx(0..255)> <state(0:Dis,1:En)> <reverse(0:Dis,1:En)> <end(0:Dis,1:En)> <portmap(7'bin)>
- <ipv6(0:Dis,1:En,2:Not care)>
- [ dmac <dmac(12'hex)> <dmac_mask(12'hex)> ]
- [ smac <smac(12'hex)> <smac_mask(12'hex)> ]
- [ stag <stag(4'hex)> <stag_mask(4'hex)> ]
- [ ctag <ctag(4'hex)> <ctag_mask(4'hex)> ]
- [ etype <etype(4'hex)> <etype_mask(4'hex)> ]
- [ dip <dip(IPADDR)> <dip_mask(IPADDR)> ]
- [ sip <sip(IPADDR)> <sip_mask(IPADDR)> ]
- [ dscp <dscp(2'hex)> <dscp_mask(2'hex)> ]
- [ protocol <protocol(2'hex)> <protocol_mask(2'hex)> ]
- [ dport <dport(4'hex)> <dport_mask(4'hex)> ]
- [ sport <sport(4'hex)> <sport_mask(4'hex)> ]
- [ flow_label <flow_label(4'hex)> <flow_label_mask(4'hex)> ]
- [ udf <udf(4'hex)> <udf_mask(4'hex)> ] */
-
- rule_idx = _strtoul(argv[argi++], NULL, 0);
-
- rule.ctrl.rule_en = _strtoul(argv[argi++], NULL, 0);
- rule.ctrl.reverse = _strtoul(argv[argi++], NULL, 0);
- rule.ctrl.end = _strtoul(argv[argi++], NULL, 0);
-
- rule.key.portmap = _strtoul(argv[argi++], NULL, 2);
- rule.mask.portmap = (~rule.key.portmap) & AIR_ALL_PORT_BITMAP;
-
- ipv6 = _strtoul(argv[argi++], NULL, 0);
- if(0 == ipv6)
- {
- rule.key.isipv6 = FALSE;
- rule.mask.isipv6 = TRUE;
- }
- else if(1 == ipv6)
- {
- rule.key.isipv6 = TRUE;
- rule.mask.isipv6 = TRUE;
- }
- else
- {
- rule.mask.isipv6 = FALSE;
- }
-
- if(0 == _strcmp(argv[argi], "dmac"))
- {
- argi++;
- _str2mac(argv[argi++], rule.key.dmac);
- _str2mac(argv[argi++], rule.mask.dmac);
- rule.key.fieldmap |= 1 << AIR_ACL_DMAC;
- }
-
- if(0 == _strcmp(argv[argi], "smac"))
- {
- argi++;
- _str2mac(argv[argi++], rule.key.smac);
- _str2mac(argv[argi++], rule.mask.smac);
- rule.key.fieldmap |= 1 << AIR_ACL_SMAC;
- }
-
- if(0 == _strcmp(argv[argi], "stag"))
- {
- argi++;
- rule.key.stag = _strtoul(argv[argi++], NULL, 16);
- rule.mask.stag = _strtoul(argv[argi++], NULL, 16);
- rule.key.fieldmap |= 1 << AIR_ACL_STAG;
- }
-
- if(0 == _strcmp(argv[argi], "ctag"))
- {
- argi++;
- rule.key.ctag = _strtoul(argv[argi++], NULL, 16);
- rule.mask.ctag = _strtoul(argv[argi++], NULL, 16);
- rule.key.fieldmap |= 1 << AIR_ACL_CTAG;
- }
-
- if(0 == _strcmp(argv[argi], "etype"))
- {
- argi++;
- rule.key.etype= _strtoul(argv[argi++], NULL, 16);
- rule.mask.etype = _strtoul(argv[argi++], NULL, 16);
- rule.key.fieldmap |= 1 << AIR_ACL_ETYPE;
- }
-
- if(0 == _strcmp(argv[argi], "dip"))
- {
- argi++;
- if(0 == ipv6)
- {
- _str2ipv4(argv[argi++], rule.key.dip);
- _str2ipv4(argv[argi++], rule.mask.dip);
- }
- else if(1 == ipv6)
- {
- _str2ipv6(argv[argi++], tmp_ip);
- rule.key.dip[3] = (tmp_ip[0]<<24) | (tmp_ip[1]<<16) | (tmp_ip[2]<<8) | tmp_ip[3];
- rule.key.dip[2] = (tmp_ip[4]<<24) | (tmp_ip[5]<<16) | (tmp_ip[6]<<8) | tmp_ip[7];
- rule.key.dip[1] = (tmp_ip[8]<<24) | (tmp_ip[9]<<16) | (tmp_ip[10]<<8) | tmp_ip[11];
- rule.key.dip[0] = (tmp_ip[12]<<24) | (tmp_ip[13]<<16) | (tmp_ip[14]<<8) | tmp_ip[15];
- _str2ipv6(argv[argi++], tmp_ip);
- rule.mask.dip[3] = (tmp_ip[0]<<24) | (tmp_ip[1]<<16) | (tmp_ip[2]<<8) | tmp_ip[3];
- rule.mask.dip[2] = (tmp_ip[4]<<24) | (tmp_ip[5]<<16) | (tmp_ip[6]<<8) | tmp_ip[7];
- rule.mask.dip[1] = (tmp_ip[8]<<24) | (tmp_ip[9]<<16) | (tmp_ip[10]<<8) | tmp_ip[11];
- rule.mask.dip[0] = (tmp_ip[12]<<24) | (tmp_ip[13]<<16) | (tmp_ip[14]<<8) | tmp_ip[15];
- }
- rule.key.fieldmap |= 1 << AIR_ACL_DIP;
- }
-
- if(0 == _strcmp(argv[argi], "sip"))
- {
- argi++;
- if(0 == ipv6)
- {
- _str2ipv4(argv[argi++], rule.key.sip);
- _str2ipv4(argv[argi++], rule.mask.sip);
- }
- else if(1 == ipv6)
- {
- _str2ipv6(argv[argi++], tmp_ip);
- rule.key.sip[3] = (tmp_ip[0]<<24) | (tmp_ip[1]<<16) | (tmp_ip[2]<<8) | tmp_ip[3];
- rule.key.sip[2] = (tmp_ip[4]<<24) | (tmp_ip[5]<<16) | (tmp_ip[6]<<8) | tmp_ip[7];
- rule.key.sip[1] = (tmp_ip[8]<<24) | (tmp_ip[9]<<16) | (tmp_ip[10]<<8) | tmp_ip[11];
- rule.key.sip[0] = (tmp_ip[12]<<24) | (tmp_ip[13]<<16) | (tmp_ip[14]<<8) | tmp_ip[15];
- _str2ipv6(argv[argi++], tmp_ip);
- rule.mask.sip[3] = (tmp_ip[0]<<24) | (tmp_ip[1]<<16) | (tmp_ip[2]<<8) | tmp_ip[3];
- rule.mask.sip[2] = (tmp_ip[4]<<24) | (tmp_ip[5]<<16) | (tmp_ip[6]<<8) | tmp_ip[7];
- rule.mask.sip[1] = (tmp_ip[8]<<24) | (tmp_ip[9]<<16) | (tmp_ip[10]<<8) | tmp_ip[11];
- rule.mask.sip[0] = (tmp_ip[12]<<24) | (tmp_ip[13]<<16) | (tmp_ip[14]<<8) | tmp_ip[15];
- }
- rule.key.fieldmap |= 1 << AIR_ACL_SIP;
- }
-
- if(0 == _strcmp(argv[argi], "dscp"))
- {
- argi++;
- rule.key.dscp = _strtoul(argv[argi++], NULL, 16);
- rule.mask.dscp = _strtoul(argv[argi++], NULL, 16);
- rule.key.fieldmap |= 1 << AIR_ACL_DSCP;
- }
-
- if(0 == _strcmp(argv[argi], "protocol"))
- {
- argi++;
- rule.key.protocol = _strtoul(argv[argi++], NULL, 16);
- rule.mask.protocol = _strtoul(argv[argi++], NULL, 16);
- rule.key.fieldmap |= 1 << AIR_ACL_PROTOCOL;
- }
-
- if(0 == _strcmp(argv[argi], "dport"))
- {
- argi++;
- rule.key.dport = _strtoul(argv[argi++], NULL, 16);
- rule.mask.dport = _strtoul(argv[argi++], NULL, 16);
- rule.key.fieldmap |= 1 << AIR_ACL_DPORT;
- }
-
- if(0 == _strcmp(argv[argi], "sport"))
- {
- argi++;
- rule.key.sport = _strtoul(argv[argi++], NULL, 16);
- rule.mask.sport = _strtoul(argv[argi++], NULL, 16);
- rule.key.fieldmap |= 1 << AIR_ACL_SPORT;
- }
-
- if(0 == _strcmp(argv[argi], "flow_label"))
- {
- argi++;
- rule.key.flow_label= _strtoul(argv[argi++], NULL, 16);
- rule.mask.flow_label= _strtoul(argv[argi++], NULL, 16);
- rule.key.fieldmap |= 1 << AIR_ACL_FLOW_LABEL;
- }
-
- if(0 == _strcmp(argv[argi], "udf"))
- {
- argi++;
- rule.key.udf = _strtoul(argv[argi++], NULL, 16);
- rule.mask.udf = _strtoul(argv[argi++], NULL, 16);
- rule.key.fieldmap |= 1 << AIR_ACL_UDF;
- }
-
- rule.mask.fieldmap = rule.key.fieldmap;
- ret = air_acl_setRule(0, rule_idx, &rule);
- if(ret < AIR_E_LAST)
- AIR_PRINT("Set ACL Rule(%u): %s\n", rule_idx, air_error_getString(ret));
- }
- else if(1 == argc)
- {
- rule_idx = _strtoul(argv[0], NULL, 0);
- ret = air_acl_getRule(0, rule_idx, &rule);
- if(ret < AIR_E_LAST)
- AIR_PRINT("Get ACL Rule(%u): %s\n", rule_idx, air_error_getString(ret));
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
-
- if(AIR_E_OK == ret)
- {
- if(TRUE == rule.ctrl.rule_en)
- {
- AIR_PRINT("\t Rule end : %s\n", (TRUE == rule.ctrl.end)?"Enable":"Disable");
- AIR_PRINT("\t Rule reverse : %s\n", (TRUE == rule.ctrl.reverse)?"Enable":"Disable");
- _hex2bitstr((~rule.mask.portmap) & AIR_ALL_PORT_BITMAP, str_temp, AIR_MAX_NUM_OF_PORTS+1);
- AIR_PRINT("\t Portmap[0:6] : %s\n", str_temp);
- for(i = AIR_ACL_DMAC; i < AIR_ACL_FIELD_TYPE_LAST; i++)
- {
- if((1 << i) & rule.mask.fieldmap)
- {
- switch (i)
- {
- case AIR_ACL_DMAC:
- AIR_PRINT("\t dmac: ");
- AIR_PRINT("%02x-%02x-%02x-%02x-%02x-%02x",
- rule.key.dmac[0], rule.key.dmac[1], rule.key.dmac[2],
- rule.key.dmac[3], rule.key.dmac[4], rule.key.dmac[5]);
- AIR_PRINT(", dmac-mask: ");
- AIR_PRINT("%02x-%02x-%02x-%02x-%02x-%02x\n",
- rule.mask.dmac[0], rule.mask.dmac[1], rule.mask.dmac[2],
- rule.mask.dmac[3], rule.mask.dmac[4], rule.mask.dmac[5]);
- break;
- case AIR_ACL_SMAC:
- AIR_PRINT("\t smac: ");
- AIR_PRINT("%02x-%02x-%02x-%02x-%02x-%02x",
- rule.key.smac[0], rule.key.smac[1], rule.key.smac[2],
- rule.key.smac[3], rule.key.smac[4], rule.key.smac[5]);
- AIR_PRINT(", smac-mask: ");
- AIR_PRINT("%02x-%02x-%02x-%02x-%02x-%02x\n",
- rule.mask.smac[0], rule.mask.smac[1], rule.mask.smac[2],
- rule.mask.smac[3], rule.mask.smac[4], rule.mask.smac[5]);
- break;
- case AIR_ACL_ETYPE:
- AIR_PRINT("\t etype: 0x%x, etype-mask: 0x%x\n", rule.key.etype, rule.mask.etype);
- break;
- case AIR_ACL_STAG:
- AIR_PRINT("\t stag: 0x%x, stag-mask: 0x%x\n", rule.key.stag, rule.mask.stag);
- break;
- case AIR_ACL_CTAG:
- AIR_PRINT("\t ctag: 0x%x, ctag-mask: 0x%x\n", rule.key.ctag, rule.mask.ctag);
- break;
- case AIR_ACL_DPORT:
- AIR_PRINT("\t dport: 0x%x, dport-mask: 0x%x\n", rule.key.dport, rule.mask.dport);
- break;
- case AIR_ACL_SPORT:
- AIR_PRINT("\t sport: 0x%x, sport-mask: 0x%x\n", rule.key.sport, rule.mask.sport);
- break;
- case AIR_ACL_UDF:
- AIR_PRINT("\t udf: 0x%x, udf-mask: 0x%x\n", rule.key.udf, rule.mask.udf);
- break;
- case AIR_ACL_DIP:
- if (0 == rule.key.isipv6)
- {
- AIR_PRINT("\t dip: ");
- AIR_PRINT("%d.%d.%d.%d",
- ((rule.key.dip[0])&0xFF000000)>>24,((rule.key.dip[0])&0x00FF0000)>>16,
- ((rule.key.dip[0])&0x0000FF00)>>8, ((rule.key.dip[0])&0x000000FF));
- AIR_PRINT(", dip-mask: ");
- AIR_PRINT("%d.%d.%d.%d\n ",
- ((rule.mask.dip[0])&0xFF000000)>>24,((rule.mask.dip[0])&0x00FF0000)>>16,
- ((rule.mask.dip[0])&0x0000FF00)>>8, ((rule.mask.dip[0])&0x000000FF));
- }
- else
- {
- for(i=0; i<4; i++){
- tmp_ip[i] = (rule.key.dip[3] >> (8*(3-i))) & 0xff;
- AIR_PRINT("get tmp_ip[%d]=0x%x\n", i, tmp_ip[i]);
- }
- for(i=4; i<8; i++){
- tmp_ip[i] = (rule.key.dip[2] >> (8*(7-i))) & 0xff;
- }
- for(i=8; i<12; i++){
- tmp_ip[i] = (rule.key.dip[1] >> (8*(11-i))) & 0xff;
- }
- for(i=12; i<16; i++){
- tmp_ip[i] = (rule.key.dip[0] >> (8*(15-i))) & 0xff;
- }
-
- AIR_PRINT("\t dip: ");
- AIR_PRINT("%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
- tmp_ip[0], tmp_ip[1],tmp_ip[2], tmp_ip[3],tmp_ip[4], tmp_ip[5],tmp_ip[6], tmp_ip[7],
- tmp_ip[8], tmp_ip[9],tmp_ip[10], tmp_ip[11],tmp_ip[12], tmp_ip[13],tmp_ip[14], tmp_ip[15]);
- for(i=0; i<4; i++){
- tmp_ip[i] = (rule.mask.dip[3] >> (8*(3-i))) & 0xff;
- }
- for(i=4; i<8; i++){
- tmp_ip[i] = (rule.mask.dip[2] >> (8*(7-i))) & 0xff;
- }
- for(i=8; i<12; i++){
- tmp_ip[i] = (rule.mask.dip[1] >> (8*(11-i))) & 0xff;
- }
- for(i=12; i<16; i++){
- tmp_ip[i] = (rule.mask.dip[0] >> (8*(15-i))) & 0xff;
- }
- AIR_PRINT(", dip-mask: ");
- AIR_PRINT("%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
- tmp_ip[0], tmp_ip[1],tmp_ip[2], tmp_ip[3],tmp_ip[4], tmp_ip[5],tmp_ip[6], tmp_ip[7],
- tmp_ip[8], tmp_ip[9],tmp_ip[10], tmp_ip[11],tmp_ip[12], tmp_ip[13],tmp_ip[14], tmp_ip[15]);
- }
- break;
- case AIR_ACL_SIP:
- if (0 == rule.key.isipv6)
- {
- AIR_PRINT("\t sip: ");
- AIR_PRINT("%d.%d.%d.%d ",
- ((rule.key.sip[0])&0xFF000000)>>24,((rule.key.sip[0])&0x00FF0000)>>16,
- ((rule.key.sip[0])&0x0000FF00)>>8, ((rule.key.sip[0])&0x000000FF));
- AIR_PRINT(", sip-mask: ");
- AIR_PRINT("%d.%d.%d.%d\n ",
- ((rule.mask.sip[0])&0xFF000000)>>24,((rule.mask.sip[0])&0x00FF0000)>>16,
- ((rule.mask.sip[0])&0x0000FF00)>>8, ((rule.mask.sip[0])&0x000000FF));
- }
- else
- {
- for(i=0; i<4; i++){
- tmp_ip[i] = (rule.key.sip[3] >> (8*(3-i))) & 0xff;
- }
- for(i=4; i<8; i++){
- tmp_ip[i] = (rule.key.sip[2] >> (8*(7-i))) & 0xff;
- }
- for(i=8; i<12; i++){
- tmp_ip[i] = (rule.key.sip[1] >> (8*(11-i))) & 0xff;
- }
- for(i=12; i<16; i++){
- tmp_ip[i] = (rule.key.sip[0] >> (8*(15-i))) & 0xff;
- }
- AIR_PRINT("\t sip: ");
- AIR_PRINT("%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
- tmp_ip[0], tmp_ip[1],tmp_ip[2], tmp_ip[3],tmp_ip[4], tmp_ip[5],tmp_ip[6], tmp_ip[7],
- tmp_ip[8], tmp_ip[9],tmp_ip[10], tmp_ip[11],tmp_ip[12], tmp_ip[13],tmp_ip[14], tmp_ip[15]);
- for(i=0; i<4; i++){
- tmp_ip[i] = (rule.mask.sip[3] >> (8*(3-i))) & 0xff;
- }
- for(i=4; i<8; i++){
- tmp_ip[i] = (rule.mask.sip[2] >> (8*(7-i))) & 0xff;
- }
- for(i=8; i<12; i++){
- tmp_ip[i] = (rule.mask.sip[1] >> (8*(11-i))) & 0xff;
- }
- for(i=12; i<16; i++){
- tmp_ip[i] = (rule.mask.sip[0] >> (8*(15-i))) & 0xff;
- }
- AIR_PRINT(", sip-mask: ");
- AIR_PRINT("%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
- tmp_ip[0], tmp_ip[1],tmp_ip[2], tmp_ip[3],tmp_ip[4], tmp_ip[5],tmp_ip[6], tmp_ip[7],
- tmp_ip[8], tmp_ip[9],tmp_ip[10], tmp_ip[11],tmp_ip[12], tmp_ip[13],tmp_ip[14], tmp_ip[15]);
- }
- break;
- case AIR_ACL_DSCP:
- AIR_PRINT("\t dscp: 0x%x, dscp-mask: 0x%x\n", rule.key.dscp, rule.mask.dscp);
- break;
- case AIR_ACL_PROTOCOL:
- AIR_PRINT("\t protocol: 0x%x, protocol-mask: 0x%x\n", rule.key.protocol, rule.mask.protocol);
- break;
- case AIR_ACL_FLOW_LABEL:
- AIR_PRINT("\t flow-label: 0x%x, flow-label-mask: 0x%x\n", rule.key.flow_label, rule.mask.flow_label);
- break;
- default:
- AIR_PRINT("error\n");
- break;
- }
- }
- }
- }
- else
- {
- AIR_PRINT("Entry is Invalid.\n");
- }
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doAclRmvRule(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T rule_idx = 0;
-
- if(1 == argc)
- {
- /* acl del rule <idx(0..127)> */
- rule_idx = _strtoul(argv[0], NULL, 0);
- ret = air_acl_delRule(0, rule_idx);
- if(ret < AIR_E_LAST)
- AIR_PRINT("Delete ACL Rule(%u): %s\n", rule_idx, air_error_getString(ret));
- }
- else if(0 == argc)
- {
- /* acl clear rule */
- ret = air_acl_clearRule(0);
- if(ret < AIR_E_LAST)
- AIR_PRINT("Clear ACL Rule: %s\n", air_error_getString(ret));
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doAclUdfRule(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T rule_idx;
- AIR_ACL_UDF_RULE_T rule;
- C8_T start_addr[8][12]=
- {
- "MAC header",
- "L2 payload",
- "IPv4 header",
- "IPv6 header",
- "L3 payload",
- "TCP header",
- "UDP header",
- "L4 payload"
- };
- C8_T str_temp[AIR_MAX_NUM_OF_PORTS+1];
-
- memset(&rule, 0, sizeof(AIR_ACL_UDF_RULE_T));
- if(7 == argc)
- {
- /* acl set rule <idx(0..255)> <mode(0:pattern, 1:threshold)> [ <pat(4'hex)> <mask(4'hex)> | <low(4'hex)> <high(4'hex)> ] <start(0:MAC,1:ether,2:IP,3:IP_data,4:TCP/UDP,5:TCP/UDP data,6:IPv6)> <offset(0..62,unit:2 bytes)> <portmap(7'bin)> */
- rule_idx = _strtoul(argv[0], NULL, 0);
- rule.cmp_sel = _strtoul(argv[1], NULL, 2);
- if(AIR_ACL_RULE_CMP_SEL_PATTERN == rule.cmp_sel)
- {
- rule.pattern = _strtoul(argv[2], NULL, 16);
- rule.mask = _strtoul(argv[3], NULL, 16);
- }
- else
- {
- rule.low_threshold = _strtoul(argv[2], NULL, 16);
- rule.high_threshold = _strtoul(argv[3], NULL, 16);
- }
- rule.offset_format = _strtoul(argv[4], NULL, 0);
- rule.offset = _strtoul(argv[5], NULL, 0);
- rule.portmap = _strtoul(argv[6], NULL, 2);
- rule.valid = TRUE;
- ret = air_acl_setUdfRule(0, rule_idx, rule);
- if(ret < AIR_E_LAST)
- AIR_PRINT("Set ACL UDF Rule(%u): %s\n", rule_idx, air_error_getString(ret));
- }
- else if(1 == argc)
- {
- rule_idx = _strtoul(argv[0], NULL, 0);
- ret = air_acl_getUdfRule(0, rule_idx, &rule);
- if(ret < AIR_E_LAST)
- AIR_PRINT("Get ACL UDF Rule(%u): %s\n", rule_idx, air_error_getString(ret));
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
-
- if(AIR_E_OK == ret)
- {
- if(TRUE == rule.valid)
- {
- AIR_PRINT("\tMode : %s\n", (AIR_ACL_RULE_CMP_SEL_PATTERN == rule.cmp_sel)?"Pattern":"Threshold");
- if(AIR_ACL_RULE_CMP_SEL_PATTERN == rule.cmp_sel)
- {
- AIR_PRINT("\tPattern : 0x%04X\n", rule.pattern);
- AIR_PRINT("\tMask : 0x%04X\n", rule.mask);
- }
- else
- {
- AIR_PRINT("\tLow Threshold : 0x%04X\n", rule.low_threshold);
- AIR_PRINT("\tHigh Threshold: 0x%04X\n", rule.high_threshold);
- }
- AIR_PRINT("\tOffset Start : %s\n", start_addr[rule.offset_format]);
- AIR_PRINT("\tOffset : %u %s\n", rule.offset*2, (0==rule.offset)?"Byte":"Bytes");
- _hex2bitstr(rule.portmap, str_temp, AIR_MAX_NUM_OF_PORTS+1);
- AIR_PRINT("\tPortmap[0:6] : %s\n", str_temp);
- }
- else
- {
- AIR_PRINT("Entry is Invalid.\n");
- }
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doAclRmvUdfRule(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T rule_idx;
-
- if(1 == argc)
- {
- /* acl del udfRule <idx(0..15)> */
- rule_idx = _strtoul(argv[0], NULL, 0);
- ret = air_acl_delUdfRule(0, rule_idx);
- if(ret < AIR_E_LAST)
- AIR_PRINT("Delete ACL UDF Rule(%u): %s\n", rule_idx, air_error_getString(ret));
- }
- else if(0 == argc)
- {
- /* acl clear udfRule */
- ret = air_acl_clearUdfRule(0);
- if(ret < AIR_E_LAST)
- AIR_PRINT("Clear ACL UDF Rule: %s\n", air_error_getString(ret));
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doAclAction(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T argi = 0;
- UI32_T act_idx;
- AIR_ACL_ACTION_T act;
- UI32_T redirect, trtcm, fwd;
- C8_T fwding[AIR_ACL_ACT_FWD_LAST][25] =
- {
- "Default",
- "Default",
- "Default",
- "Default",
- "Default & CPU excluded",
- "Default & CPU included",
- "CPU only",
- "Drop"
- };
- C8_T trtcm_usr[AIR_ACL_ACT_USR_TCM_LAST][8] =
- {
- "Default",
- "Green",
- "Yellow",
- "Red"
- };
- C8_T egtag[AIR_ACL_ACT_EGTAG_LAST][11] =
- {
- "Default",
- "Consistent",
- "",
- "",
- "Untag",
- "Swap",
- "Tag",
- "Stack"
- };
- C8_T str_temp[20];
-
- memset(&act, 0, sizeof(AIR_ACL_ACTION_T));
- if(2 < argc)
- {
- /* acl set action <idx(0..127)>
- [ forward <forward(0:Default,4:Exclude CPU,5:Include CPU,6:CPU only,7:Drop)> ]
- [ egtag <egtag(0:Default,1:Consistent,4:Untag,5:Swap,6:Tag,7:Stack)> ]
- [ mirrormap <mirrormap(2'bin)> ]
- [ priority <priority(0..7)> ]
- [ redirect <redirect(0:Dst,1:Vlan)> <portmap(7'bin)> ]
- [ leaky_vlan <leaky_vlan(1:En,0:Dis)> ]
- [ cnt_idx <cnt_idx(0..63)> ]
- [ rate_idx <rate_idx(0..31)> ]
- [ attack_idx <attack_idx(0..95)> ]
- [ vid <vid(0..4095)> ]
- [ manage <manage(1:En,0:Dis)> ]
- [ bpdu <bpdu(1:En,0:Dis)> ]
- [ class <class(0:Original,1:Defined)>[0..7] ]
- [ drop_pcd <drop_pcd(0:Original,1:Defined)> [red <red(0..7)>][yellow <yellow(0..7)>][green <green(0..7)>] ]
- [ color <color(0:Defined,1:Trtcm)> [ <defined_color(0:Dis,1:Green,2:Yellow,3:Red)> | <trtcm_idx(0..31)> ] ]*/
-
- act_idx = _strtoul(argv[argi++], NULL, 0);
- if(0 == _strcmp(argv[argi], "forward"))
- {
- argi++;
- fwd = _strtoul(argv[argi++], NULL, 0);
- act.fwd_en = TRUE;
- act.fwd = fwd;
- }
-
- if(0 == _strcmp(argv[argi], "egtag"))
- {
- argi++;
- act.egtag_en = TRUE;
- act.egtag = _strtoul(argv[argi++], NULL, 0);
- }
-
- if(0 == _strcmp(argv[argi], "mirrormap"))
- {
- argi++;
- act.mirrormap = _strtoul(argv[argi++], NULL, 2);
- }
-
- if(0 == _strcmp(argv[argi], "priority"))
- {
- argi++;
- act.pri_user_en = TRUE;
- act.pri_user= _strtoul(argv[argi++], NULL, 0);
- }
-
- if(0 == _strcmp(argv[argi], "redirect"))
- {
- argi++;
- redirect = _strtoul(argv[argi++], NULL, 0);
- if(0 == redirect)
- {
- act.port_en = TRUE;
- act.dest_port_sel = TRUE;
- act.portmap = _strtoul(argv[argi++], NULL, 2);
- }
- else
- {
- act.port_en = TRUE;
- act.vlan_port_sel = TRUE;
- act.portmap = _strtoul(argv[argi++], NULL, 2);
- }
- }
-
- if(0 == _strcmp(argv[argi], "leaky_vlan"))
- {
- argi++;
- act.lyvlan_en = TRUE;
- act.lyvlan = _strtoul(argv[argi++], NULL, 0);
- }
-
- /* ACL event counter */
- if(0 == _strcmp(argv[argi], "cnt_idx"))
- {
- argi++;
- act.cnt_en = TRUE;
- act.cnt_idx = _strtol(argv[argi++], NULL, 0);
- }
-
- if(0 == _strcmp(argv[argi], "rate_idx"))
- {
- argi++;
- act.rate_en = TRUE;
- act.rate_idx = _strtol(argv[argi++], NULL, 0);
- }
-
- if(0 == _strcmp(argv[argi], "attack_idx"))
- {
- argi++;
- act.attack_en = TRUE;
- act.attack_idx = _strtol(argv[argi++], NULL, 0);
- }
-
- if(0 == _strcmp(argv[argi], "vid"))
- {
- argi++;
- act.vlan_en = TRUE;
- act.vlan_idx = _strtol(argv[argi++], NULL, 0);
- }
-
- /* Management frame */
- if(0 == _strcmp(argv[argi], "manage"))
- {
- argi++;
- act.mang = _strtoul(argv[argi++], NULL, 2);
- }
-
- if(0 == _strcmp(argv[argi], "bpdu"))
- {
- argi++;
- act.bpdu = _strtoul(argv[argi++], NULL, 2);
- }
-
- /* DSCP class remap */
- if(0 == _strcmp(argv[argi], "class"))
- {
- argi++;
- act.trtcm_en = TRUE;
- act.trtcm.cls_slr_sel = _strtoul(argv[argi++], NULL, 2);
- if(TRUE == act.trtcm.cls_slr_sel)
- {
- act.trtcm.cls_slr = _strtoul(argv[argi++], NULL, 0);
- }
- }
- if(0 == _strcmp(argv[argi], "drop_pcd"))
- {
- argi++;
- act.trtcm_en = TRUE;
- act.trtcm.drop_pcd_sel = _strtoul(argv[argi++], NULL, 2);
- if(TRUE == act.trtcm.drop_pcd_sel)
- {
- if(0 == _strcmp(argv[argi], "red"))
- {
- argi++;
- act.trtcm.drop_pcd_r= _strtoul(argv[argi++], NULL, 0);
- }
- if(0 == _strcmp(argv[argi], "yellow"))
- {
- argi++;
- act.trtcm.drop_pcd_y= _strtoul(argv[argi++], NULL, 0);
- }
- if(0 == _strcmp(argv[argi], "green"))
- {
- argi++;
- act.trtcm.drop_pcd_g= _strtoul(argv[argi++], NULL, 0);
- }
- }
- }
-
- /* trTCM */
- if(0 == _strcmp(argv[argi], "color"))
- {
- argi++;
- act.trtcm_en = TRUE;
- act.trtcm.tcm_sel = _strtoul(argv[argi++], NULL, 2);
- trtcm = _strtoul(argv[argi++], NULL, 0);
- if(FALSE == act.trtcm.tcm_sel)
- {
- act.trtcm.usr_tcm = trtcm;
- }
- else
- {
- act.trtcm.tcm_idx = trtcm;
- }
- }
- ret = air_acl_setAction(0, act_idx, act);
- AIR_PRINT("Set ACL Action(%u): %s\n", act_idx, air_error_getString(ret));
- }
- else if(1 == argc)
- {
- /* acl get action <idx(0..127)> */
- act_idx = _strtoul(argv[argi++], NULL, 0);
- ret = air_acl_getAction(0, act_idx, &act);
- AIR_PRINT("Get ACL Action(%u): %s\n", act_idx, air_error_getString(ret));
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
-
- if(AIR_E_OK == ret)
- {
- if(TRUE == act.fwd_en)
- {
- AIR_PRINT("\t Forwarding : %s\n", fwding[act.fwd]);
- }
-
- if(TRUE == act.egtag_en)
- {
- AIR_PRINT("\t Egress tag : %s\n", egtag[act.egtag]);
- }
-
- if(act.mirrormap)
- {
- AIR_PRINT("\t Mirror Session Map : %u\n", act.mirrormap);
- }
-
- if(TRUE == act.pri_user_en)
- {
- AIR_PRINT("\t User Priority : %u\n", act.pri_user);
- }
-
- if(TRUE == act.port_en)
- {
- _hex2bitstr(act.portmap, str_temp, AIR_MAX_NUM_OF_PORTS+1);
- if(TRUE == act.dest_port_sel)
- {
- AIR_PRINT("\t Destination Port[0:6]: %s\n", str_temp);
- }
- else
- {
- AIR_PRINT("\t VLAN Port[0:6] : %s\n", str_temp);
- }
- }
-
- if(TRUE == act.lyvlan_en)
- {
- AIR_PRINT("\t Leaky VLAN : %s\n", (TRUE == act.lyvlan)?"Enable":"Disable");
- }
- AIR_PRINT("\t Management Frame : %s\n", (TRUE == act.mang)?"Enable":"Disable");
- AIR_PRINT("\t BPDU Frame : %s\n", (TRUE == act.bpdu)?"Enable":"Disable");
-
- if(TRUE == act.cnt_en)
- {
- AIR_PRINT("\t Event Index : %u\n", act.cnt_idx);
- }
-
- /* trTCM*/
- if(TRUE == act.trtcm_en)
- {
- if(TRUE == act.trtcm.cls_slr_sel)
- {
- AIR_PRINT("\t Class Selector Remap : %u\n", act.trtcm.cls_slr);
- }
- else
- {
- AIR_PRINT("\t Class Selector Remap : %s\n", "Disable");
- }
- if(TRUE == act.trtcm.drop_pcd_sel)
- {
- AIR_PRINT("\t Drop Precedence Remap(Red): %u\n", act.trtcm.drop_pcd_r);
- AIR_PRINT("\t Drop Precedence Remap(Yel): %u\n", act.trtcm.drop_pcd_y);
- AIR_PRINT("\t Drop Precedence Remap(Gre): %u\n", act.trtcm.drop_pcd_g);
- }
- else
- {
- AIR_PRINT("\t Drop Precedence Remap: %s\n", "Disable");
- }
-
- if(TRUE == act.trtcm.tcm_sel)
- {
- AIR_PRINT("\t trTCM Meter Index : %u\n", act.trtcm.tcm_idx);
- }
- else
- {
- AIR_PRINT("\t trTCM User Defined : %s\n", trtcm_usr[act.trtcm.usr_tcm]);
- }
- }
- /* rate control */
- if(TRUE == act.rate_en)
- {
- AIR_PRINT("\t Rate Control Index : %u\n", act.rate_idx);
- }
-
- if(TRUE == act.attack_en)
- {
- AIR_PRINT("\t Attack Rate Control Index: %u\n", act.attack_idx);
- }
-
- if(TRUE == act.vlan_en)
- {
- AIR_PRINT("\t ACL VLAN Index : %u\n", act.vlan_idx);
- }
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doAclRmvAction(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T act_idx;
-
- if(1 == argc)
- {
- /* acl del action <idx(0..127)> */
- act_idx = _strtoul(argv[0], NULL, 0);
- ret = air_acl_delAction(0, act_idx);
- if(ret < AIR_E_LAST)
- AIR_PRINT("Delete ACL Action(%u): %s\n", act_idx, air_error_getString(ret));
- }
- else if(0 == argc)
- {
- /* acl clear action */
- ret = air_acl_clearAction(0);
- if(ret < AIR_E_LAST)
- AIR_PRINT("Clear ACL Action: %s\n", air_error_getString(ret));
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doAclTrtcm(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T argi = 0;
- UI32_T tcm_idx;
- AIR_ACL_TRTCM_T tcm;
-
- memset(&tcm, 0, sizeof(AIR_ACL_TRTCM_T));
- if(5 == argc)
- {
- /* acl set trtcm <idx(0..31)> <cir(4'hex)> <pir(4'hex)> <cbs(4'hex)> <pbs(4'hex)> */
- tcm_idx = _strtoul(argv[argi++], NULL, 0);
- tcm.cir = _strtoul(argv[argi++], NULL, 16);
- tcm.pir = _strtoul(argv[argi++], NULL, 16);
- tcm.cbs = _strtoul(argv[argi++], NULL, 16);
- tcm.pbs = _strtoul(argv[argi++], NULL, 16);
-
- ret = air_acl_setTrtcm(0, tcm_idx, tcm);
- if(ret < AIR_E_LAST)
- AIR_PRINT("Set ACL trTCM(%u): %s\n", tcm_idx, air_error_getString(ret));
- }
- else if(1 == argc)
- {
- /* acl get trtcm <idx(1..31)> */
- tcm_idx = _strtoul(argv[argi++], NULL, 0);
- ret = air_acl_getTrtcm(0, tcm_idx, &tcm);
- if(ret < AIR_E_LAST)
- AIR_PRINT("Get ACL trTCM(%u): %s\n", tcm_idx, air_error_getString(ret));
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
-
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("\t CIR: 0x%04X(unit:64Kbps)\n", tcm.cir);
- AIR_PRINT("\t PIR: 0x%04X(unit:64Kbps)\n", tcm.pir);
- AIR_PRINT("\t CBS: 0x%04X(unit:Byte)\n", tcm.cbs);
- AIR_PRINT("\t PBS: 0x%04X(unit:Byte)\n", tcm.pbs);
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doAclTrtcmEn(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- BOOL_T state = FALSE;
-
- if (1 == argc)
- {
- /* acl set trtcmEn <en(1:En,0:Dis)> */
- state = _strtol(argv[0], NULL, 10);
- ret = air_acl_setTrtcmEnable(0, state);
- AIR_PRINT("Set trTCM State ");
- }
- else if (0 == argc)
- {
- /* acl get trtcmEn */
- ret = air_acl_getTrtcmEnable(0, &state);
- AIR_PRINT("Get trTCM State ");
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
-
- if (ret == AIR_E_OK)
- {
- AIR_PRINT(": %s\n", (TRUE == state) ? "Enable" : "Disable");
- }
- else
- {
- AIR_PRINT("Fail!\n");
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doAclRmvTrtcm(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T tcm_idx;
-
- if(1 == argc)
- {
- /* acl del trtcm <idx(1..31)> */
- tcm_idx = _strtoul(argv[0], NULL, 0);
- ret = air_acl_delTrtcm(0, tcm_idx);
- if(ret < AIR_E_LAST)
- AIR_PRINT("Delete ACL TRTCM(%u): %s\n", tcm_idx, air_error_getString(ret));
- }
- else if(0 == argc)
- {
- /* acl clear trtcm */
- ret = air_acl_clearTrtcm(0);
- if(ret < AIR_E_LAST)
- AIR_PRINT("Clear ACL TRTCM: %s\n", air_error_getString(ret));
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doAclPortEn(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T argi=0;
- UI32_T port = 0;
- BOOL_T en;
-
- if(2 == argc)
- {
- /* acl set portEn <port(0..6)> <en(1:En,0:Dis)> */
- port = _strtoul(argv[argi++], NULL, 0);
- en = _strtoul(argv[argi++], NULL, 2);
- ret = air_acl_setPortEnable(0, port, en);
- AIR_PRINT("Set Port:%u ACL function ", port);
- }
- else if(1 == argc)
- {
- /* acl get portEn <port(0..6)> */
- port = _strtoul(argv[argi++], NULL, 0);
- ret = air_acl_getPortEnable(0, port, &en);
- AIR_PRINT("Get Port:%u ACL function ", port);
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
-
- if(ret == AIR_E_OK)
- {
- AIR_PRINT(": %s\n", (TRUE == en)?"Enable":"Disable");
- }
- else
- {
- AIR_PRINT("Fail!\n");
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doAclDropEn(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T argi=0;
- UI32_T port = 0;
- BOOL_T en;
-
- if(2 == argc)
- {
- /* acl set dropEn <port(0..6)> <en(1:En,0:Dis)> */
- port = _strtoul(argv[argi++], NULL, 0);
- en = _strtoul(argv[argi++], NULL, 2);
- ret = air_acl_setDropEnable(0, port, en);
- AIR_PRINT("Set ACL Drop precedence ");
- }
- else if(1 == argc)
- {
- /* acl set dropEn <port(0..6)> */
- port = _strtoul(argv[argi++], NULL, 0);
- ret = air_acl_getDropEnable(0, port, &en);
- AIR_PRINT("Get ACL Drop precedence ");
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
-
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("(Port %u):%s\n",
- port,
- (TRUE == en)?"Enable":"Disable");
- }
- else
- {
- AIR_PRINT("Fail!\n");
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doAclDropThrsh(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T argi=0;
- UI32_T port = 0;
- AIR_ACL_DP_COLOR_T color;
- UI8_T queue;
- UI32_T high, low;
- C8_T dp_color[AIR_ACL_DP_COLOR_LAST][7] =
- {
- "Green",
- "Yellow",
- "Red"
- };
-
- if(5 == argc)
- {
- /* acl set dropThrsh <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)> <high(0..2047)> <low(0..2047) */
- port = _strtoul(argv[argi++], NULL, 0);
- color = _strtoul(argv[argi++], NULL, 0);
- queue = _strtoul(argv[argi++], NULL, 0);
- high = _strtoul(argv[argi++], NULL, 0);
- low = _strtoul(argv[argi++], NULL, 0);
- ret = air_acl_setDropThreshold(0, port, color, queue, high, low);
- AIR_PRINT("Set ACL Drop precedence ");
- }
- else if(3 == argc)
- {
- /* acl get dropThrsh <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)> */
- port = _strtoul(argv[argi++], NULL, 0);
- color = _strtoul(argv[argi++], NULL, 0);
- queue = _strtoul(argv[argi++], NULL, 0);
- ret = air_acl_getDropThreshold(0, port, color, queue, &high, &low);
- AIR_PRINT("Get ACL Drop precedence ");
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
-
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("(Port %u, color:%s, queue:%u):\n",
- port,
- dp_color[color],
- queue);
- AIR_PRINT("\tHigh Threshold :%u\n", high);
- AIR_PRINT("\tLow Threshold :%u\n", low);
- }
- else
- {
- AIR_PRINT("Fail!\n");
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doAclDropPbb(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T argi=0;
- UI32_T port = 0;
- AIR_ACL_DP_COLOR_T color;
- UI8_T queue;
- UI32_T pbb;
- C8_T dp_color[AIR_ACL_DP_COLOR_LAST][7] =
- {
- "Green",
- "Yellow",
- "Red"
- };
-
- if(4 == argc)
- {
- /* acl set dropPbb <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)> <probability(0..1023) */
- port = _strtoul(argv[argi++], NULL, 0);
- color = _strtoul(argv[argi++], NULL, 0);
- queue = _strtoul(argv[argi++], NULL, 0);
- pbb = _strtoul(argv[argi++], NULL, 0);
- ret = air_acl_setDropProbability(0, port, color, queue, pbb);
- AIR_PRINT("Set ACL Drop precedence ");
- }
- else if(3 == argc)
- {
- /* acl get dropPbb <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)> */
- port = _strtoul(argv[argi++], NULL, 0);
- color = _strtoul(argv[argi++], NULL, 0);
- queue = _strtoul(argv[argi++], NULL, 0);
- ret = air_acl_getDropProbability(0, port, color, queue, &pbb);
- AIR_PRINT("Get ACL Drop precedence ");
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
-
- if(ret == AIR_E_OK)
- {
- AIR_PRINT("(Port %u, color:%s, queue %u):\n",
- port,
- dp_color[color],
- queue);
- AIR_PRINT("\tDrop probability:%u(unit=1/1023)\n", pbb);
- }
- else
- {
- AIR_PRINT("Fail!\n");
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doAclMeter(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T argi = 0;
- UI32_T meter_idx, state, rate;
-
- if(3 == argc)
- {
- /* acl set meter <idx(0..31)> <en(1:En,0:Dis)> <rate(0..65535)>
- Note: Limit rate = rate * 64Kbps */
- meter_idx = _strtoul(argv[argi++], NULL, 0);
- state = _strtoul(argv[argi++], NULL, 2);
- rate = _strtoul(argv[argi++], NULL, 0);
-
- ret = air_acl_setMeterTable(0, meter_idx, state, rate);
- if(ret < AIR_E_LAST)
- AIR_PRINT("Set ACL Meter(%u): %s\n", meter_idx, air_error_getString(ret));
- }
- else if(1 == argc)
- {
- /* acl get meter <idx(0..31)> */
- meter_idx = _strtoul(argv[argi++], NULL, 0);
- ret = air_acl_getMeterTable(0, meter_idx, &state, &rate);
- if(ret < AIR_E_LAST)
- AIR_PRINT("Get ACL Meter(%u): %s\n", meter_idx, air_error_getString(ret));
- }
- else
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
-
- if(AIR_E_OK == ret)
- {
- AIR_PRINT("\t State: %s\n", (TRUE == state)?"Enable":"Disable");
- if(TRUE == state)
- {
- AIR_PRINT("\t Rate : %u(unit:64Kbps)\n", rate);
- }
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doAclDump(
- UI32_T argc,
- C8_T *argv[])
-{
- AIR_ERROR_NO_T ret = AIR_E_OK;
- UI32_T i, cnt = 0;
- AIR_ACL_CTRL_T ctrl;
-
- if(0 != argc)
- {
- AIR_PRINT("Unrecognized command.\n");
- return AIR_E_BAD_PARAMETER;
- }
-
- for(i=0; i<ACL_MAX_RULE_NUM; i++)
- {
- memset(&ctrl, 0, sizeof(AIR_ACL_CTRL_T));
- ret = air_acl_getRuleCtrl(0, i, &ctrl);
- if(AIR_E_OK == ret)
- {
- if(TRUE == ctrl.rule_en)
- {
- cnt++;
- AIR_PRINT("\t Entry-%d vaild\n", i);
- }
- }
- }
- if(0 == cnt)
- {
- AIR_PRINT("\t No entry vaild\n");
- }
-
- return ret;
-}
-
-static AIR_ERROR_NO_T
-doAclSet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(aclSetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doAclGet(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(aclGetCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doAclDel(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(aclDelCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doAclClear(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(aclClearCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-doAcl(
- UI32_T argc,
- C8_T *argv[])
-{
- return subcmd(aclCmds, argc, argv);
-}
-
-static AIR_ERROR_NO_T
-subcmd(
- const AIR_CMD_T tab[],
- UI32_T argc,
- C8_T *argv[])
-{
- const AIR_CMD_T *cmdp;
- I32_T found = 0;
- I32_T i, len;
-
- if (argc < 1)
- {
- goto print_out_cmds;
- }
-
- for (cmdp = tab; cmdp->name != NULL; cmdp++)
- {
- if (strlen(argv[0]) == strlen(cmdp->name))
- {
- if (strncmp(argv[0], cmdp->name, strlen(argv[0])) == 0)
- {
- found = 1;
- break;
- }
- }
- }
-
- if(!found)
- {
- C8_T buf[66];
-
-print_out_cmds:
- AIR_PRINT("valid subcommands:\n");
- memset(buf, ' ', sizeof(buf));
- buf[64] = '\n';
- buf[65] = '\0';
-
- for (i=0, cmdp = tab; cmdp->name != NULL; cmdp++)
- {
- len = strlen(cmdp->name);
- strncpy(&buf[i*16], cmdp->name, (len > 16) ? 16 : len);
- if(3 == i)
- {
- AIR_PRINT("%s\n", buf);
- memset(buf, ' ', sizeof(buf));
- buf[64] = '\n';
- buf[65] = '\0';
- }
- i = (i + 1) % 4;
- }
-
- if (0 != i)
- AIR_PRINT("%s\n", buf);
-
- return AIR_E_BAD_PARAMETER;
- }
-
- if (CMD_NO_PARA == cmdp->argc_min)
- {
- if (argc != 1)
- {
- if (cmdp->argc_errmsg != NULL)
- {
- AIR_PRINT("Usage: %s\n", cmdp->argc_errmsg);
- }
-
- return AIR_E_BAD_PARAMETER;
- }
- }
- else if (CMD_VARIABLE_PARA == cmdp->argc_min)
- {
- if (argc < 3)
- {
- if (cmdp->argc_errmsg != NULL)
- {
- AIR_PRINT("Usage: %s\n", cmdp->argc_errmsg);
- }
-
- return AIR_E_BAD_PARAMETER;
- }
- }
- else
- {
- if ((argc <= cmdp->argc_min) || ((cmdp->argc_min != 0) && (argc != (cmdp->argc_min + 1))))
- {
- if (cmdp->argc_errmsg != NULL)
- {
- AIR_PRINT("Usage: %s\n", cmdp->argc_errmsg);
- }
-
- return AIR_E_BAD_PARAMETER;
- }
- }
-
- if (cmdp->func)
- {
- argc--;
- argv++;
- return (*cmdp->func)(argc, argv);
- }
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_parse_cmd
- * PURPOSE:
- * This function is used process diagnostic cmd
- * INPUT:
- * argc -- parameter number
- * argv -- parameter strings
- * OUTPUT:
- * None
- * RETURN:
- * NPS_E_OK -- Successfully read the data.
- * NPS_E_OTHERS -- Failed to read the data.
- * NOTES:
- *
- */
-AIR_ERROR_NO_T
-air_parse_cmd(
- const UI32_T argc,
- const C8_T **argv)
-{
- return subcmd(Cmds, argc, (C8_T **)argv);
-}
-
+/* FILE NAME: air_cmd.c
+ * PURPOSE:
+ * Define the command line function in AIR SDK.
+ * NOTES:
+ */
+
+/* INCLUDE FILE DECLARATIONS
+*/
+#include "air.h"
+
+/* NAMING CONSTANT DECLARATIONS
+*/
+
+/* MACRO FUNCTION DECLARATIONS
+*/
+#define MAC_STR "%02X%02X%02X%02X%02X%02X"
+#define MAC2STR(m) (m)[0],(m)[1],(m)[2],(m)[3],(m)[4],(m)[5]
+#define AIR_MAC_LEN (12)
+#define CMD_NO_PARA (0xFFFFFFFF)
+#define CMD_VARIABLE_PARA (0xFFFFFFFE)
+#define L2_WDOG_KICK_NUM (100)
+
+#define TOLOWER(x) ((x) | 0x20)
+#define isxdigit(c) (('0' <= (c) && (c) <= '9') || ('a' <= (c) && (c) <= 'f') || ('A' <= (c) && (c) <= 'F'))
+#define isdigit(c) ('0' <= (c) && (c) <= '9')
+#define CMD_CHECK_PARA(__shift__, __op__, __size__) do \
+{ \
+ if ((__shift__) __op__ (__size__)) \
+ { \
+ ; \
+ } \
+ else \
+ { \
+ return (AIR_E_BAD_PARAMETER); \
+ } \
+} while(0)
+
+/* DATA TYPE DECLARATIONS
+*/
+typedef struct {
+ C8_T* name;
+ AIR_ERROR_NO_T (*func)(UI32_T argc, C8_T *argv[]);
+ UI32_T argc_min;
+ C8_T* argc_errmsg;
+} AIR_CMD_T;
+
+/* GLOBAL VARIABLE DECLARATIONS
+*/
+
+/* LOCAL SUBPROGRAM DECLARATIONS
+*/
+/* String Utility */
+static BOOL_T _strcmp(const char *s1, const char *s2);
+static C8_T * _strtok_r(C8_T *s, const C8_T *delim, C8_T **last);
+static C8_T * _strtok(C8_T *s, const C8_T *delim, C8_T **last);
+UI32_T _strtoul(const C8_T *cp, C8_T **endp, UI32_T base);
+static I32_T _strtol(const C8_T *cp, C8_T **endp, UI32_T base);
+
+/* Type Converter */
+static AIR_ERROR_NO_T _str2mac(C8_T *str, C8_T *mac);
+static AIR_ERROR_NO_T _hex2bit(const UI32_T hex, UI32_T *ptr_bit);
+static AIR_ERROR_NO_T _hex2bitstr(const UI32_T hex, C8_T *ptr_bit_str, UI32_T str_len);
+static AIR_ERROR_NO_T _portListStr2Ary(const C8_T *str, UI32_T *ary, const UI32_T ary_num);
+
+/* Register Operation */
+static AIR_ERROR_NO_T doRegRead(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doRegWrite(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doReg(UI32_T argc, C8_T *argv[]);
+
+/* PHY Operation */
+static AIR_ERROR_NO_T doPhyCL22Read(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPhyCL22Write(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPhyCL22(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPhyCL45Read(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPhyCL45Write(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPhyCL45(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPhy(UI32_T argc, C8_T *argv[]);
+
+/* Porting setting */
+static AIR_ERROR_NO_T doPortSetMatrix(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPortSetVlanMode(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPortSet(UI32_T argc, C8_T *argv[]);
+
+static AIR_ERROR_NO_T doPortGetMatrix(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPortGetVlanMode(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPortGet(UI32_T argc, C8_T *argv[]);
+
+static AIR_ERROR_NO_T doPort(UI32_T argc, C8_T *argv[]);
+
+/* Vlan setting */
+static AIR_ERROR_NO_T doVlanInitiate(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanCreate(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanDestroy(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanDestroyAll(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanDump(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanAddPortMem(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanDelPortMem(UI32_T argc, C8_T *argv[]);
+
+static AIR_ERROR_NO_T doVlanSetFid(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanSetMemPort(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanSetIVL(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanSetPortBaseStag(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanSetStag(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanSetEgsTagCtlEn(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanSetEgsTagCtlCon(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanSetEgsTagCtl(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanSetPortActFrame(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanSetLeakyVlanEn(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanSetPortVlanAttr(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanSetIgsPortETagAttr(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanSetPortETagAttr(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanSetPortOuterTPID(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanSetPvid(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanSet(UI32_T argc, C8_T *argv[]);
+
+static AIR_ERROR_NO_T doVlanGetPortActFrame(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanGetLeakyVlanEn(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanGetPortVlanAttr(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanGetIgsPortETagAttr(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanGetPortETagAttr(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanGetPortOuterTPID(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanGetPvid(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doVlanGet(UI32_T argc, C8_T *argv[]);
+
+static AIR_ERROR_NO_T doVlan(UI32_T argc, C8_T *argv[]);
+
+static AIR_ERROR_NO_T doFlowCtrl(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doJumbo(UI32_T argc, C8_T *argv[]);
+
+static AIR_ERROR_NO_T doL2Add(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doL2Del(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doL2Clear(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doL2Get(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doL2Set(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doL2Dump(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doL2(UI32_T argc, C8_T *argv[]);
+
+static AIR_ERROR_NO_T doAnMode(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doLocalAdv(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doRemoteAdv(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPortSpeed(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPortDuplex(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPortStatus(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPortBckPres(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPortPsMode(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPortSmtSpdDwn(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPortSpTag(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPortEnable(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPort5GBaseRMode(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPortHsgmiiMode(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPortSgmiiMode(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPortRmiiMode(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doPortRgmiiMode(UI32_T argc, C8_T *argv[]);
+
+static AIR_ERROR_NO_T doSptagEn(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doSptagMode(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doSptagDecode(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doSptagEncode(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doSptag(UI32_T argc, C8_T *argv[]);
+
+static AIR_ERROR_NO_T doMacAddr(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T _printMacEntry(AIR_MAC_ENTRY_T * mt, UI32_T age_unit, UI8_T count, UI8_T title);
+static AIR_ERROR_NO_T doGetMacAddr(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doMacAddrAgeOut(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doDumpMacAddr(UI32_T argc, C8_T *argv[]);
+
+static AIR_ERROR_NO_T doLagMember(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doLagMemberCnt(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doLagPtseed(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doLagHashtype(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doLagDstInfo(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doLagState(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doLagSpsel(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doLagGet(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doLagSet(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doLag(UI32_T argc, C8_T *argv[]);
+
+static AIR_ERROR_NO_T doStpPortstate(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doStpGet(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doStpSet(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doStp(UI32_T argc, C8_T *argv[]);
+
+static AIR_ERROR_NO_T doMirrorGetSid(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doMirrorDelSid(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doMirrorAddRlist(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doMirrorAddTlist(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doMirrorSetSessionEnable(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doMirrorSetSession(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doMirrorSet(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doMirrorAdd(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doMirrorGet(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doMirrorDel(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doMirror(UI32_T argc,C8_T *argv[]);
+
+static AIR_ERROR_NO_T doMibClearPort(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doMibClearAcl(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doMibGetPort(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doMibGetAcl(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doMibClear(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doMibGet(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doMib(UI32_T argc, C8_T *argv[]);
+
+static AIR_ERROR_NO_T doQosScheduleAlgo(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doQosTrustMode(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doQosPri2Queue(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doQosDscp2Pri(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doQosRateLimitEnable(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doQosRateLimit(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doQosPortPriority(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doQosRateLimitExMngFrm(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doQosGet(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doQosSet(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doQos(UI32_T argc, C8_T *argv[]);
+
+static AIR_ERROR_NO_T doDiagTxComply(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doDiagSet(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doDiagGet(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doDiag(UI32_T argc, C8_T *argv[]);
+
+static AIR_ERROR_NO_T doLedMode(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doLedState(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doLedUsrDef(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doLedBlkTime(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doLedSet(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doLedGet(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doLed(UI32_T argc, C8_T *argv[]);
+
+static AIR_ERROR_NO_T doSwitchCpuPortEn(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doSwitchCpuPort(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doSwitchPhyLCIntrEn(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doSwitchPhyLCIntrSts(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doSwitchSet(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doSwitchGet(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doSwitch(UI32_T argc, C8_T *argv[]);
+
+static AIR_ERROR_NO_T doShowVersion(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doShow(UI32_T argc, C8_T *argv[]);
+
+static AIR_ERROR_NO_T doStormEnable(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doStormRate(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doFldMode(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doSaLearning(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doSaLimit(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doSecGet(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doSecSet(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doSec(UI32_T argc, C8_T *argv[]);
+
+static void _air_acl_printRuleMap(UI32_T *rule_map, UI32_T ary_num);
+static AIR_ERROR_NO_T doAclEn(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doAclRule(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doAclUdfRule(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doAclRmvRule(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doAclRmvUdfRule(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doAclAction(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doAclRmvAction(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doAclDumpAction(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doAclTrtcm(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doAclTrtcmEn(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doAclRmvTrtcm(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doAclPortEn(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doAclDropEn(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doAclDropThrsh(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doAclDropPbb(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doAclMeter(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doAclDump(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doAclSet(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doAclGet(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doAclDel(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doAclClear(UI32_T argc, C8_T *argv[]);
+static AIR_ERROR_NO_T doAcl(UI32_T argc, C8_T *argv[]);
+
+static AIR_ERROR_NO_T subcmd(const AIR_CMD_T tab[], UI32_T argc, C8_T *argv[]);
+
+/* STATIC VARIABLE DECLARATIONS
+*/
+const static C8_T *_sptag_vpm[] =
+{
+ "untagged",
+ "8100",
+ "predefined",
+ "unknown"
+};
+
+const static C8_T *_sptag_pt[] =
+{
+ "disable pass through",
+ "enable pass through"
+};
+
+const static C8_T *_air_mac_address_forward_control_string [] =
+{
+ "Default",
+ "CPU include",
+ "CPU exclude",
+ "CPU only",
+ "Drop"
+};
+
+static AIR_CMD_T regCmds[] =
+{
+ {"r", doRegRead, 1, "reg r <reg(4'hex)>"},
+ {"w", doRegWrite, 2, "reg w <reg(4'hex)> <value(8'hex)>"},
+
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T phyCL22Cmds[] =
+{
+ {"r", doPhyCL22Read, 2, "phy cl22 r <port(0..4)> <reg(2'hex)>"},
+ {"w", doPhyCL22Write, 3, "phy cl22 w <port(0..4)> <reg(2'hex)> <value(4'hex)>"},
+
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T phyCL45Cmds[] =
+{
+ {"r", doPhyCL45Read, 3, "phy cl45 r <port(0..4)> <dev(2'hex)> <reg(3'hex)>"},
+ {"w", doPhyCL45Write, 4, "phy cl45 w <port(0..4)> <dev(2'hex)> <reg(3'hex)> <value(4'hex)>"},
+
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T phyCmds[] =
+{
+ {"cl22", doPhyCL22, 0, NULL},
+ {"cl45", doPhyCL45, 0, NULL},
+
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T portSetCmds[] =
+{
+ {"matrix", doPortSetMatrix, 2, "port set matrix <port(0..6)> <matrix(6:0)>"},
+ {"vlanMode", doPortSetVlanMode, 2, "port set vlanMode <port(0..6)> <vlanMode(0:matrix,1:fallback,2:check,3:security)>"},
+ {"flowCtrl", doFlowCtrl, 3, "port set flowCtrl <port(0..6)> <dir(0:Tx,1:Rx)> <fc_en(1:En,0:Dis)>"},
+ {"jumbo", doJumbo, 2, "port set jumbo <pkt_len(0:1518,1:1536,2:1552,3:max)> <frame_len(2..15)>"},
+ {"anMode", doAnMode, 2, "port set anMode <port(0..4)> <en(0:force,1:AN)>"},
+ {"localAdv", doLocalAdv, 7, "port set localAdv <port(0..4)> <10H(1:En,0:Dis)> <10F(1:En,0:Dis)> <100H(1:En,0:Dis)> <100F(1:En,0:Dis)> <1000F(1:En,0:Dis)> <pause(1:En,0:Dis)>"},
+ {"speed", doPortSpeed, 2, "port set speed <port(0..4)> <speed(0:10M,1:100M,2:1G,3:2.5G)>"},
+ {"duplex", doPortDuplex, 2, "port set duplex <port(0..4)> <duplex(0:half,1:full)>"},
+ {"bckPres", doPortBckPres, 2, "port set bckPres <port(0..6)> <bckPres(1:En,0:Dis)>"},
+ {"psMode", doPortPsMode, 3, "port set psMode <port(0..4)> <ls(1:En,0:Dis)> <eee(1:En,0:Dis)>"},
+ {"smtSpdDwn", doPortSmtSpdDwn, 3, "port set smtSpdDwn <port(0..4)> <en(1:En,0:Dis)> <retry(2..5)>"},
+ {"spTag", doPortSpTag, 2, "port set spTag <port(0..6)> <en(1:En,0:Dis)>"},
+ {"enable", doPortEnable, 2, "port set enable <port(0..4)> <en(1:En,0:Dis)>"},
+ {"5GBaseRMode", doPort5GBaseRMode, CMD_NO_PARA, "port set 5GBaseRMode"},
+ {"hsgmiiMode", doPortHsgmiiMode, CMD_NO_PARA, "port set hsgmiiMode"},
+ {"sgmiiMode", doPortSgmiiMode, 2, "port set sgmiiMode <mode(0:AN,1:Force)> <speed(0:10M,1:100M,2:1G)>"},
+ {"rmiiMode", doPortRmiiMode, 1, "port set rmiiMode <speed(0:10M,1:100M)>"},
+ {"rgmiiMode", doPortRgmiiMode, 1, "port set rgmiiMode <speed(0:10M,1:100M,2:1G)>"},
+
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T portGetCmds[] =
+{
+ {"matrix", doPortGetMatrix, 1, "port get matrix <port(0..6)>"},
+ {"vlanMode", doPortGetVlanMode, 1, "port get vlanMode <port(0..6)>"},
+ {"flowCtrl", doFlowCtrl, 2, "port get flowCtrl <port(0..6)> <dir(0:Tx,1:Rx)>"},
+ {"jumbo", doJumbo, CMD_NO_PARA, "port get jumbo"},
+ {"anMode", doAnMode, 1, "port get anMode <port(0..4)>"},
+ {"localAdv", doLocalAdv, 1, "port get localAdv <port(0..4)>"},
+ {"remoteAdv", doRemoteAdv, 1, "port get remoteAdv <port(0..4)>"},
+ {"speed", doPortSpeed, 1, "port get speed <port(0..4)>"},
+ {"duplex", doPortDuplex, 1, "port get duplex <port(0..4)>"},
+ {"status", doPortStatus, 1, "port get status <port(0..4)>"},
+ {"bckPres", doPortBckPres, 1, "port get bckPres <port(0..6)>"},
+ {"psMode", doPortPsMode, 1, "port get psMode <port(0..4)>"},
+ {"smtSpdDwn", doPortSmtSpdDwn, 1, "port get smtSpdDwn <port(0..4)>"},
+ {"spTag", doPortSpTag, 1, "port get spTag <port(0..6)>"},
+ {"enable", doPortEnable, 1, "port get enable <port(0..4)>"},
+
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T portCmds[] =
+{
+ {"set", doPortSet, 0, NULL},
+ {"get", doPortGet, 0, NULL},
+
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T sptagCmds[] =
+{
+ {"setEnable", doSptagEn, 2, "sptag setEnable port<port(0..6)> enable<1:enable 0:disable>"},
+ {"getEnable", doSptagEn, 1, "sptag getEnable port<port(0..6)>"},
+ {"setmode", doSptagMode, 2, "sptag setmode port<port(0..6)> mode<0:inset 1:replace>"},
+ {"getmode", doSptagMode, 1, "sptag getmode port<port(0..6)>"},
+ {"encode", doSptagEncode, 7, "sptag encode mode={ insert | replace } opc={ portmap | portid | lookup } dp={bitimap hex} vpm={ untagged | 8100 | 88a8 } pri=<UINT> cfi=<UINT> vid=<UINT> "},
+ {"decode", doSptagDecode, 4, "sptag decode <byte(hex)> <byte(hex)> <byte(hex)> <byte(hex)>"},
+
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T vlanSetCmds[] =
+{
+ {"fid", doVlanSetFid, 2, "vlan set fid <vid(0..4095)> <fid(0..7)>"},
+ {"memPort", doVlanSetMemPort, 2, "vlan set memPort <vid(0..4095)> <bitmap(6:0)>"},
+ {"ivl", doVlanSetIVL, 2, "vlan set ivl <vid(0..4095)> <(1:En,0:Dis)>"},
+ {"portBaseStag", doVlanSetPortBaseStag, 2, "vlan set portBaseStag <vid(0..4095)> <(1:En,0:Dis)>"},
+ {"stag", doVlanSetStag, 2, "vlan set stag <vid(0..4095)> <stag(0..4095)>"},
+ {"egsTagCtlEn", doVlanSetEgsTagCtlEn, 2, "vlan set egsTagCtlEn <vid(0..4095)> <(1:En,0:Dis)>"},
+ {"egsTagCtlCon", doVlanSetEgsTagCtlCon, 2, "vlan set egsTagCtlCon <vid(0..4095)> <(1:En,0:Dis)>"},
+ {"egsTagCtl", doVlanSetEgsTagCtl, 3, "vlan set egsTagCtl <vid(0..4095)> <port(0..6)> <ctlType(0:untag,2:tagged)>"},
+
+ {"portActFrame", doVlanSetPortActFrame, 2, "vlan set portActFrame <port(0..6)> <frameType(0:all,1:tagged,2:untagged)>"},
+ {"leakyVlanEn", doVlanSetLeakyVlanEn, 3, "vlan set LeakyVlanEn <port(0..6)> <pktType(0:uc,1:mc,2:bc,3:ipmc)> <(1:En,0:Dis)>"},
+ {"portVlanAttr", doVlanSetPortVlanAttr, 2, "vlan set portVlanAttr <port(0..6)> <vlanAttr(0:user,1:stack,2:translation,3:transparent)>"},
+ {"igsPortETagAttr", doVlanSetIgsPortETagAttr, 2, "vlan set igsPortETagAttr <port(0..6)> <egsTagAttr(0:disable,1:consistent,4:untagged,5:swap,6:tagged,7:stack)>"},
+ {"portEgsTagAttr", doVlanSetPortETagAttr, 2, "vlan set portEgsTagAttr <port(0..6)> <egsTagAttr(0:untagged,1:swap,2:tagged,3:stack)>"},
+ {"portOuterTPID", doVlanSetPortOuterTPID, 2, "vlan set portOuterTPID <port(0..6)> <TPID(hex)>"},
+ {"pvid", doVlanSetPvid, 2, "vlan set pvid <port(0..6)> <vid(0..4095)>"},
+
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T vlanGetCmds[] =
+{
+ {"portActFrame", doVlanGetPortActFrame, 1, "vlan get portActFrame <port(0..6)>"},
+ {"leakyVlanEn", doVlanGetLeakyVlanEn, 1, "vlan get leakyVlanEn <port(0..6)>"},
+ {"portVlanAttr", doVlanGetPortVlanAttr, 1, "vlan get portVlanAttr <port(0..6)>"},
+ {"igsPortETagAttr", doVlanGetIgsPortETagAttr, 1, "vlan get igsPortETagAttr <port(0..6)>"},
+ {"portEgsTagAttr", doVlanGetPortETagAttr, 1, "vlan get portEgsTagAttr <port(0..6)>"},
+ {"portOuterTPID", doVlanGetPortOuterTPID, 1, "vlan get portOuterTPID <port(0..6)>"},
+ {"pvid", doVlanGetPvid, 1, "vlan get pvid <port(0..6)>"},
+
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T vlanCmds[] =
+{
+ {"initiate", doVlanInitiate, 9, "vlan initiate <vid(0..4095)> <fid(0..7)> <bitmap(6:0)> <ivl(1:En,0:Dis)> <portbasestag(1:En,0:Dis)> <stag(0..4095)> <egstagctlen(1:En,0:Dis)> <egstagcon(1:En,0:Dis)> <taggedbitmap(6:0)>"},
+ {"create", doVlanCreate, 1, "vlan create <vid(0..4095)>"},
+ {"destroy", doVlanDestroy, 1, "vlan destroy [ <vid(0..4095)> | <vidRange(vid0-vid1)> ]"},
+ {"destroyAll", doVlanDestroyAll, 0, "vlan destroyAll [ <restoreDefVlan(0:false,1:true)> | ]"},
+ {"dump", doVlanDump, 0, "vlan dump [ <vid(0..4095)> | <vidRange(vid0-vid1)> | ]"},
+ {"addPortMem", doVlanAddPortMem, 2, "vlan addPortMem <vid(0..4095)> <port(0..6)>"},
+ {"delPortMem", doVlanDelPortMem, 2, "vlan addPortMem <vid(0..4095)> <port(0..6)>"},
+ {"set", doVlanSet, 0, NULL},
+ {"get", doVlanGet, 0, NULL},
+
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T l2ClearCmds[] =
+{
+ {"mac", doMacAddr, CMD_NO_PARA, "l2 clear mac"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T l2DelCmds[] =
+{
+ {"mac", doMacAddr, 3, "l2 del mac <mac(12'hex)> [ vid <vid(0..4095)> | fid <fid(0..15)> ]"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T l2AddCmds[] =
+{
+ {"mac", doMacAddr, 7, "l2 add mac <static(0:dynamic,1:static)> <unauth(0:auth,1:unauth)> <mac(12'hex)> <portlist(uintlist)> [ vid <vid(0..4095)> | fid <fid(0..15)> ] <src_mac_forward=(0:default,1:cpu-exclude,2:cpu-include,3:cpu-only,4:drop)>"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T l2SetCmds[] =
+{
+ {"macAddrAgeOut", doMacAddrAgeOut, 1, "l2 set macAddrAgeOut <time(1, 1000000)>"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T l2GetCmds[] =
+{
+ {"mac", doGetMacAddr, 3, "l2 get mac <mac(12'hex)> [ vid <vid(0..4095)> | fid <fid(0..15)> ]"},
+ {"macAddrAgeOut", doMacAddrAgeOut, CMD_NO_PARA, "l2 get macAddrAgeOut"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T l2DumpCmds[] =
+{
+ {"mac", doDumpMacAddr, 0, "l2 dump mac"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T l2Cmds[] =
+{
+ {"add", doL2Add, 0, NULL},
+ {"del", doL2Del, 0, NULL},
+ {"clear", doL2Clear, 0, NULL},
+ {"get", doL2Get, 0, NULL},
+ {"set", doL2Set, 0, NULL},
+ {"dump", doL2Dump, 0, NULL},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T lagGetCmds[] =
+{
+ {"member", doLagMember, 1, "lag get member group_id(0 or 1)"},
+ {"dstInfo", doLagDstInfo, CMD_NO_PARA, "lag get dstInfo"},
+ {"ptseed", doLagPtseed, CMD_NO_PARA, "lag get ptseed"},
+ {"hashtype", doLagHashtype, CMD_NO_PARA, "lag get hashtype"},
+ {"state", doLagState, CMD_NO_PARA, "lag get state"},
+ {"spsel", doLagSpsel, CMD_NO_PARA, "lag get spsel"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T lagSetCmds[] =
+{
+ {"member", doLagMember, 4, "lag set member <group_id(0 or 1)> <member_index(0..3)> <enable(0,1)> <port index(0..6)>"},
+ {"dstInfo", doLagDstInfo, 7, "lag set dstInfo <sp(1:En,0:Dis)> <sa(1:En,0:Dis)> <da(1:En,0:Dis)> <sip(1:En,0:Dis)> <dip(1:En,0:Dis)> <sport(1:En,0:Dis)> <dport(1:En,0:Dis)>"},
+ {"ptseed", doLagPtseed, 1, "lag set ptseed <hex32>"},
+ {"hashtype", doLagHashtype, 1, "lag set hashtype <0-crc32lsb;1-crc32msb;2-crc16;3-xor4>"},
+ {"state", doLagState, 1, "lag set state <state(1:En,0:Dis)>"},
+ {"spsel", doLagSpsel, 1, "lag set spsel <soure port enable(1:En,0:Dis)>"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T lagCmds[] =
+{
+ {"get", doLagGet, 0, NULL},
+ {"set", doLagSet, 0, NULL},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T stpGetCmds[] =
+{
+ {"portstate", doStpPortstate, 2, "stp get portstate <port(0..6)> <fid(0..15)>"},
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T stpSetCmds[] =
+{
+ {"portstate", doStpPortstate, 3, "stp set portstate <port(0..6)> <fid(0..15)> <state(0:disable,1:listen,2:learn,3:forward)>"},
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T stpCmds[] =
+{
+ {"get", doStpGet, 0, NULL},
+ {"set", doStpSet, 0, NULL},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T mirrorSetCmds[] =
+{
+ {"session", doMirrorSetSession, 6, "mirror set session <sid(0,1)> <dst_port(UINT)> <state(1:En,0:Dis)> <tag(1:on, 0:off)> <list(UINTLIST)> <dir(0:none,1:tx,2:rx,3:both)>"},
+ {"session-enable", doMirrorSetSessionEnable, 2, "mirror set session-enable <sid(0,1)> <state(1:En,0:Dis)>"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T mirrorAddCmds[] =
+{
+ {"session-rlist", doMirrorAddRlist, 2, "mirror add session-rlist <sid(0,1)> <list(UINTLIST)>"},
+ {"session-tlist", doMirrorAddTlist, 2, "mirror add session-tlist <sid(0,1)> <list(UINTLIST)>"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T mirrorGetCmds[] =
+{
+ {"session", doMirrorGetSid, 1, "mirror get session <sid(0,1)>"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T mirrorDelCmds[] =
+{
+ {"session", doMirrorDelSid, 1, "mirror del session <sid(0,1)>"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T mirrorCmds[] =
+{
+ {"set", doMirrorSet, 0, NULL},
+ {"add", doMirrorAdd, 0, NULL},
+ {"get", doMirrorGet, 0, NULL},
+ {"del", doMirrorDel, 0, NULL},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T mibClearCmds[] =
+{
+ {"port", doMibClearPort, 1, "mib clear port <port(0..6)>"},
+ {"all", doMibClearPort, 0, "mib clear all"},
+ {"acl", doMibClearAcl, 0, "mib clear acl"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T mibGetCmds[] =
+{
+ {"port", doMibGetPort, 1, "mib get port <port(0..6)>"},
+ {"acl", doMibGetAcl, 1, "mib get acl <event(0..7)>"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T mibCmds[] =
+{
+ {"clear", doMibClear, 0, NULL},
+ {"get", doMibGet, 0, NULL},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T qosGetCmds[] =
+{
+ {"scheduleAlgo", doQosScheduleAlgo, 2, "qos get scheduleAlgo <portlist(UINTLIST)> <queue(UINT)>"},
+ {"trustMode", doQosTrustMode, 1, "qos get trustMode <portlist(UINTLIST)>"},
+ {"pri2Queue", doQosPri2Queue, 0, "qos get pri2Queue"},
+ {"dscp2Pri", doQosDscp2Pri, 1, "qos get dscp2Pri <dscp(0..63)>"},
+ {"rateLimitEnable", doQosRateLimitEnable, 1, "qos get rateLimitEnable <portlist(UINTLIST)>"},
+ {"rateLimit", doQosRateLimit, 1, "qos get rateLimit <portlist(UINTLIST)>"},
+ {"portPriority", doQosPortPriority, 1, "qos get portPriority <portlist(UINTLIST)>"},
+ {"rateLmtExMngFrm", doQosRateLimitExMngFrm, 0, "qos get rateLmtExMngFrm"},
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T qosSetCmds[] =
+{
+ {"scheduleAlgo", doQosScheduleAlgo, 4, "qos set scheduleAlgo <portlist(UINTLIST)> <queue(UINT)> <scheduler(0:SP,1:WRR,2:WFQ)> <weight(0..128)>, weight 0 is valid only on sp mode"},
+ {"trustMode", doQosTrustMode, 2, "qos set trustMode <portlist(UINTLIST)> <mode(0:port,1:1p-port,2:dscp-port,3:dscp-1p-port>"},
+ {"pri2Queue", doQosPri2Queue, 2, "qos set pri2Queue <priority(0..7)> <queue(0..7)>"},
+ {"dscp2Pri", doQosDscp2Pri, 2, "qos set dscp2Pri <dscp(0..63)> <priority(0..7)>"},
+ {"rateLimitEnable", doQosRateLimitEnable, 3, "qos set rateLimitEnable <portlist(UINTLIST)> <dir(0:egress,1:ingress)> <rate_en(1:En,0:Dis)>"},
+ {"rateLimit", doQosRateLimit, 5, "qos set rateLimit <portlist(UINTLIST)> <I_CIR(0..80000)> <I_CBS(0..127)> <E_CIR(0..80000)> <E_CBS(0..127)>"},
+ {"portPriority", doQosPortPriority, 2, "qos set portPriority <portlist(UINTLIST)> <priority(0..7)>"},
+ {"rateLmtExMngFrm", doQosRateLimitExMngFrm, 2, "qos set rateLmtExMngFrm <dir(0:egress)> <en(0:include,1:exclude)>"},
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T qosCmds[] =
+{
+ {"get", doQosGet, 0, NULL},
+ {"set", doQosSet, 0, NULL},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T diagSetCmds[] =
+{
+ {"txComply", doDiagTxComply, 2, "diag set txComply <phy(0..5)> <mode(0..8)>"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T diagGetCmds[] =
+{
+ {"txComply", doDiagTxComply, 1, "diag get txComply <phy(0..5)>"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T diagCmds[] =
+{
+ {"set", doDiagSet, 0, NULL},
+ {"get", doDiagGet, 0, NULL},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T ledSetCmds[] =
+{
+ {"mode", doLedMode, 1, "led set mode <mode(0:disable, 1..3:2 LED, 4:user-define)>"},
+ {"state", doLedState, 2, "led set state <led(0..1)> <state(1:En,0:Dis)>"},
+ {"usr", doLedUsrDef, 4, "led set usr <led(0..1)> <polarity(0:low, 1:high)> <on_evt(7'bin)> <blink_evt(10'bin)>"},
+ {"time", doLedBlkTime, 1, "led set time <time(0..5:32ms~1024ms)>"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T ledGetCmds[] =
+{
+ {"mode", doLedMode, CMD_NO_PARA, "led get mode"},
+ {"state", doLedState, 1, "led get state <led(0..1)>"},
+ {"usr", doLedUsrDef, 1, "led get usr <led(0..1)>"},
+ {"time", doLedBlkTime, CMD_NO_PARA, "led get time"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T ledCmds[] =
+{
+ {"set", doLedSet, 0, NULL},
+ {"get", doLedGet, 0, NULL},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T showCmds[] =
+{
+ {"version", doShowVersion, 0, NULL},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T secGetCmds[] =
+{
+ {"stormEnable", doStormEnable, 2, "sec get stormEnable <port(0..6)> <type(0:bcst,1:mcst,2:ucst)>"},
+ {"stormRate", doStormRate, 2, "sec get stormRate <port(0..6)> <type(0:bcst,1:mcst,2:ucst)>"},
+ {"fldMode", doFldMode, 2, "sec get fldMode <port(0..6)> <type(0:bcst,1:mcst,2:ucst,3:qury>"},
+ {"saLearning", doSaLearning, 1, "sec get saLearning <port(0..6)>"},
+ {"saLimit", doSaLimit, 1, "sec get saLimit <port(0..6)>"},
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T secSetCmds[] =
+{
+ {"stormEnable", doStormEnable, 3, "sec set stormEnable <port(0..6)> <type(0:bcst,1:mcst,2:ucst)> <en(1:En,0:Dis)>"},
+ {"stormRate", doStormRate, 4, "sec set stormRate <port(0..6)> <type(0:bcst,1:mcst,2:ucst)> <count(0..255)> <unit(0:64k,1:256k,2:1M,3:4M,4:16M)>"},
+ {"fldMode", doFldMode, 3, "sec set fldMode <port(0..6)> <type(0:bcst,1:mcst,2:ucst,3:qury> <en(1:En,0:Dis)>"},
+ {"saLearning", doSaLearning, 2, "sec set saLearning <port(0..6)> <learn(0:disable,1:enable)>"},
+ {"saLimit", doSaLimit, 3, "sec set saLimit <port(0..6)> <mode(0:disable,1:enable)> <count(0..4095)>"},
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T secCmds[] =
+{
+ {"get", doSecGet, 0, NULL},
+ {"set", doSecSet, 0, NULL},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T switchSetCmds[] =
+{
+ {"cpuPortEn", doSwitchCpuPortEn, 1, "switch set cpuPortEn <cpu_en(1:En,0:Dis)>"},
+ {"cpuPort", doSwitchCpuPort, 1, "switch set cpuPort <port_number>"},
+ {"phyLCIntrEn", doSwitchPhyLCIntrEn, 2, "switch set phyLCIntrEn <phy(0..6)> <(1:En,0:Dis)>"},
+ {"phyLCIntrSts", doSwitchPhyLCIntrSts, 2, "switch set phyLCIntrSts <phy(0..6)> <(1:Clear)>"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T switchGetCmds[] =
+{
+ {"cpuPortEn", doSwitchCpuPortEn, CMD_NO_PARA, "switch get cpuPortEn"},
+ {"cpuPort", doSwitchCpuPort, CMD_NO_PARA, "switch get cpuPort"},
+ {"phyLCIntrEn", doSwitchPhyLCIntrEn, 1, "switch get phyLCIntrEn <phy(0..6)>"},
+ {"phyLCIntrSts", doSwitchPhyLCIntrSts, 1, "switch get phyLCIntrSts <phy(0..6)>"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T switchCmds[] =
+{
+ {"set", doSwitchSet, 0, NULL},
+ {"get", doSwitchGet, 0, NULL},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T aclSetCmds[] =
+{
+ {"en", doAclEn, 1, "acl set en <en(1:En,0:Dis)>"},
+ {"rule", doAclRule, CMD_VARIABLE_PARA, "acl set rule <idx(0..127)>\n <state(0:Dis,1:En)> <reverse(0:Dis,1:En)> <end(0:Dis,1:En)>\n <portmap(7'bin)><ipv6(0:Dis,1:En,2:Not care)>\n[ dmac <dmac(12'hex)> <dmac_mask(12'hex)> ]\n[ smac <smac(12'hex)> <smac_mask(12'hex)> ]\n[ stag <stag(4'hex)> <stag_mask(4'hex)> ]\n[ ctag <ctag(4'hex)> <ctag_mask(4'hex)> ]\n[ etype <etype(4'hex)> <etype_mask(4'hex)> ]\n[ dip <dip(IPADDR)> <dip_mask(IPADDR)> ]\n[ sip <sip(IPADDR)> <sip_mask(IPADDR)> ]\n[ dscp <dscp(2'hex)> <dscp_mask(2'hex)> ]\n[ protocol <protocol(12'hex)> <protocol_mask(12'hex)> ]\n[ dport <dport(4'hex)> <dport_mask(4'hex)> ]\n[ sport <sport(4'hex)> <sport_mask(4'hex)> ]\n[ flow_label <flow_label(4'hex)> <flow_label_mask(4'hex)> ]\n[ udf <udf(4'hex)> <udf_mask(4'hex)> ] "},
+ {"udfRule", doAclUdfRule, 7, "acl set udfRule <idx(0..15)> <mode(0:pattern, 1:threshold)> [ <pat(4'hex)> <mask(4'hex)> | <low(4'hex)> <high(4'hex)> ] <start(0:MAC header, 1:L2 payload, 2:IPv4 header, 3:IPv6 header, 4:L3 payload, 5:TCP header, 6:UDP header, 7: L4 payload)> <offset(0..127,unit:2 bytes)> <portmap(7'bin)>"},
+ {"action", doAclAction, CMD_VARIABLE_PARA, "acl set action <idx(0..127)> \n[ forward <forward(0:Default,4:Exclude CPU,5:Include CPU,6:CPU only,7:Drop)> ]\n[ egtag <egtag(0:Default,1:Consistent,4:Untag,5:Swap,6:Tag,7:Stack)> ]\n[ mirrormap <mirrormap(2'bin)> ]\n[ priority <priority(0..7)> ]\n[ redirect <redirect(0:Dst,1:Vlan)> <portmap(7'bin)> ]\n[ leaky_vlan <leaky_vlan(1:En,0:Dis)> ]\n[ cnt_idx <cnt_idx(0..63)> ]\n[ rate_idx <rate_idx(0..31)> ] \n[ attack_idx <attack_idx(0..95)> ] \n[ vid <vid(0..4095)> ] \n[ manage <manage(1:En,0:Dis)> ] \n[ bpdu <bpdu(1:En,0:Dis)> ]\n[ class <class(0:Original,1:Defined)>[0..7] ]\n[ drop_pcd <drop_pcd(0:Original,1:Defined)> [red <red(0..7)>][yellow <yellow(0..7)>][green <green(0..7)>] ]\n[ color <color(0:Defined,1:Trtcm)> [ <defined_color(0:Dis,1:Green,2:Yellow,3:Red)> | <trtcm_idx(0..31)> ] ]"},
+ {"trtcm", doAclTrtcm, 5, "acl set trtcm <idx(1..31)> <cir(4'hex)> <pir(4'hex)> <cbs(4'hex)> <pbs(4'hex)>"},
+ {"trtcmEn", doAclTrtcmEn, 1, "acl set trtcmEn <en(1:En,0:Dis)>"},
+ {"portEn", doAclPortEn, 2, "acl set portEn <port(0..6)> <en(1:En,0:Dis)>"},
+ {"dropEn", doAclDropEn, 2, "acl set dropEn <port(0..6)> <en(1:En,0:Dis)>"},
+ {"dropThrsh", doAclDropThrsh, 5, "acl set dropThrsh <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)> <high(0..2047)> <low(0..2047)>"},
+ {"dropPbb", doAclDropPbb, 4, "acl set dropPbb <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)> <probability(0..1023)>"},
+ {"meter", doAclMeter, 3, "acl set meter <idx(0..31)> <en(1:En,0:Dis)> <rate(0..65535)>\n Note: Limit rate = rate * 64Kbps"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T aclGetCmds[] =
+{
+ {"en", doAclEn, CMD_NO_PARA, "acl get en"},
+ {"rule", doAclRule, 1, "acl get rule <idx(0..127)> "},
+ {"udfRule", doAclUdfRule, 1, "acl get udfRule <idx(0..15)>"},
+ {"action", doAclAction, 1, "acl get action <idx(0..127)>"},
+ {"trtcm", doAclTrtcm, 1, "acl get trtcm <idx(1..31)>"},
+ {"trtcmEn", doAclTrtcmEn, CMD_NO_PARA, "acl get trtcmEn"},
+ {"portEn", doAclPortEn, 1, "acl get portEn <port(0..6)>"},
+ {"dropEn", doAclDropEn, 1, "acl get dropEn <port(0..6)>"},
+ {"dropThrsh", doAclDropThrsh, 3, "acl get dropThrsh <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)>"},
+ {"dropPbb", doAclDropPbb, 3, "acl get dropPbb <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)>"},
+ {"meter", doAclMeter, 1, "acl get meter <idx(0..31)>"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T aclDelCmds[] =
+{
+ {"rule", doAclRmvRule, 1, "acl del rule <idx(0..127)>"},
+ {"udfRule", doAclRmvUdfRule, 1, "acl del udfRule <idx(0..15)>"},
+ {"action", doAclRmvAction, 1, "acl del action <idx(0..127)>"},
+ {"trtcm", doAclRmvTrtcm, 1, "acl del trtcm <idx(0..31)>"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T aclClearCmds[] =
+{
+ {"rule", doAclRmvRule, CMD_NO_PARA, "acl clear rule"},
+ {"udfRule", doAclRmvUdfRule, CMD_NO_PARA, "acl clear udfRule"},
+ {"action", doAclRmvAction, CMD_NO_PARA, "acl clear action"},
+ {"trtcm", doAclRmvTrtcm, CMD_NO_PARA, "acl clear trtcm"},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T aclCmds[] =
+{
+ {"set", doAclSet, 0, NULL},
+ {"get", doAclGet, 0, NULL},
+ {"del", doAclDel, 0, NULL},
+ {"clear", doAclClear, 0, NULL},
+ {"dump", doAclDump, 0, NULL},
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+static AIR_CMD_T Cmds[] =
+{
+ {"reg", doReg, 0, NULL},
+ {"phy", doPhy, 0, NULL},
+ {"port", doPort, 0, NULL},
+ {"vlan", doVlan, 0, NULL},
+ {"l2", doL2, 0, NULL},
+ {"lag", doLag, 0, NULL},
+ {"stp", doStp, 0, NULL},
+ {"mirror", doMirror, 0, NULL},
+ {"mib", doMib, 0, NULL},
+ {"qos", doQos, 0, NULL},
+ {"diag", doDiag, 0, NULL},
+ {"led", doLed, 0, NULL},
+ {"switch", doSwitch, 0, NULL},
+ {"show", doShow, 0, NULL},
+ {"sec", doSec, 0, NULL},
+ {"acl", doAcl, 0, NULL},
+ {"sptag", doSptag, 0, NULL},
+
+ /* last entry, do not modify this entry */
+ {NULL, NULL, 0, NULL},
+};
+
+/* EXPORTED SUBPROGRAM BODIES
+*/
+
+/* LOCAL SUBPROGRAM BODIES
+*/
+static BOOL_T
+_strcmp(const char *s1, const char *s2)
+{
+ while(*s1 == *s2++)
+ if (*s1++ == '\0')
+ return (0);
+ return (*(const unsigned char *)s1 - *(const unsigned char *)(s2 -1));
+}
+
+static C8_T *
+_strtok_r(
+ C8_T *s,
+ const C8_T *delim,
+ C8_T **last)
+{
+ char *spanp;
+ int c = 0, sc = 0;
+ char *tok;
+
+ if (s == NULL && (s = *last) == NULL)
+ {
+ return (NULL);
+ }
+
+ /*
+ * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
+ */
+ for (;;)
+ {
+ c = *s++;
+ spanp = (char *)delim;
+ do
+ {
+ if (c == (sc = *spanp++))
+ {
+ break;
+ }
+ } while (sc != 0);
+ if (sc == 0)
+ {
+ break;
+ }
+ }
+
+ if (c == 0)
+ { /* no non-delimiter characters */
+ *last = NULL;
+ return (NULL);
+ }
+ tok = s - 1;
+
+ /*
+ * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
+ * Note that delim must have one NUL; we stop if we see that, too.
+ */
+ for (;;)
+ {
+ c = *s++;
+ spanp = (char *)delim;
+ do
+ {
+ if ((sc = *spanp++) == c)
+ {
+ if (c == 0)
+ {
+ s = NULL;
+ }
+ else
+ {
+ s[-1] = 0;
+ }
+ *last = s;
+ return (tok);
+ }
+ } while (sc != 0);
+ }
+ /* NOTREACHED */
+}
+
+static C8_T *
+_strtok(
+ C8_T *s,
+ const C8_T *delim,
+ C8_T **last)
+{
+ return _strtok_r(s, delim, last);
+}
+
+UI32_T
+_strtoul(
+ const C8_T *cp,
+ C8_T **endp,
+ UI32_T base)
+{
+ UI32_T result = 0, value = 0;
+
+ if (!base)
+ {
+ base = 10;
+ if (*cp == '0')
+ {
+ base = 8;
+ cp++;
+ if ((TOLOWER(*cp) == 'x') && isxdigit(cp[1]))
+ {
+ cp++;
+ base = 16;
+ }
+ }
+ }
+ else if (base == 16)
+ {
+ if (cp[0] == '0' && TOLOWER(cp[1]) == 'x')
+ {
+ cp += 2;
+ }
+ }
+ while (isxdigit(*cp) &&
+ (value = isdigit(*cp) ? *cp-'0' : TOLOWER(*cp)-'a'+10) < base)
+ {
+ result = result*base + value;
+ cp++;
+ }
+ if (endp)
+ {
+ *endp = (char *)cp;
+ }
+ return result;
+}
+
+static I32_T
+_strtol(
+ const C8_T *cp,
+ C8_T **endp,
+ UI32_T base)
+{
+ if(*cp=='-')
+ {
+ return -_strtoul(cp + 1, endp, base);
+ }
+ return _strtoul(cp, endp, base);
+}
+
+static AIR_ERROR_NO_T
+_str2mac(
+ C8_T *str,
+ C8_T *mac)
+{
+ UI32_T i = 0;
+ C8_T tmpstr[3];
+
+ /* check str */
+ AIR_CHECK_PTR(str);
+ AIR_PARAM_CHK(strlen(str) != AIR_MAC_LEN, AIR_E_BAD_PARAMETER);
+ AIR_CHECK_PTR(mac);
+
+ for(i=0; i<6; i++)
+ {
+ strncpy(tmpstr, str+(i*2), 2);
+ tmpstr[2] = '\0';
+ mac[i] = _strtoul(tmpstr, NULL, 16);
+ }
+
+ return AIR_E_OK;
+}
+
+static AIR_ERROR_NO_T
+_str2ipv4(
+ const C8_T *ptr_str,
+ UI32_T *ptr_addr)
+{
+ UI32_T value = 0, idx = 0, shift = 0;
+
+ AIR_CHECK_PTR(ptr_str);
+ AIR_CHECK_PTR(ptr_addr);
+
+ /* e.g. 192.168.1.2, strlen = 11 */
+ for (idx = 0; idx < strlen(ptr_str); idx++)
+ {
+ if (('0' <= ptr_str[idx]) && ('9' >= ptr_str[idx]))
+ {
+ value = (value * 10) + (ptr_str[idx] - '0');
+ }
+ else if ('.' == ptr_str[idx])
+ {
+ CMD_CHECK_PARA(value, <, 256); /* Error: invalid value */
+ CMD_CHECK_PARA(shift, <, 4); /* Error: mem-overwrite */
+ *ptr_addr |= value << (24 - shift * 8);
+ shift += 1;
+ value = 0;
+ }
+ else
+ {
+ return AIR_E_BAD_PARAMETER; /* Error: not a digit number or dot */
+ }
+ }
+ CMD_CHECK_PARA(value, <, 256); /* Error: invalid value */
+ CMD_CHECK_PARA(shift, ==, 3); /* Error: not an ipv4 addr */
+ *ptr_addr |= value << (24 - shift * 8);
+
+ return AIR_E_OK;
+}
+
+AIR_ERROR_NO_T
+_str2ipv6(
+ const C8_T *ptr_str,
+ UI8_T *ptr_addr)
+{
+ UI32_T hex_value = 0, dec_value = 0, idx = 0;
+ BOOL_T double_colon = FALSE, ipv4_compatible = FALSE;
+ UI32_T double_colon_pos = 0, last_pos = 0;
+ UI8_T tmp_ipv6[16] = {0};
+
+ AIR_CHECK_PTR(ptr_str);
+ AIR_CHECK_PTR(ptr_addr);
+
+ /* e.g. invalid:
+ * 3ffe::c0a8:0: last cannot be colon except double-colon
+ * 3ffe:::c0a8:0 triple-colon
+ * 3ffe::c0a8::0 two double-colons
+ */
+
+ /* e.g. valid:
+ * 3ffe::c0a8:0 strlen = 12 (double-colon in middle)
+ * 3ffe:c0a8:0:: strlen = 13 (double-colon in last)
+ * ::3ffe:c0a8:0 strlen = 13 (double-colon in first)
+ * 3ffe::192.168.0.0 strlen = 17 (IPv4-compatible address)
+ */
+ for (idx = 0; idx < strlen(ptr_str); idx++)
+ {
+ if (('0' <= ptr_str[idx]) && ('9' >= ptr_str[idx]))
+ {
+ hex_value = (hex_value << 4) + (ptr_str[idx] - '0');
+ dec_value = (dec_value * 10) + (ptr_str[idx] - '0');
+ }
+ else if (('a' <= ptr_str[idx]) && ('f' >= ptr_str[idx]))
+ {
+ hex_value = (hex_value << 4) + (ptr_str[idx] - 'a') + 10;
+ }
+ else if (('A' <= ptr_str[idx]) && ('F' >= ptr_str[idx]))
+ {
+ hex_value = (hex_value << 4) + (ptr_str[idx] - 'A') + 10;
+ }
+ else if (':' == ptr_str[idx])
+ {
+ /* must belong to double-colon, calculate from last */
+ if (0 == idx)
+ {
+ continue;
+ }
+ /* not the first ch but a double-colon */
+ else if (':' == ptr_str[idx - 1])
+ {
+ CMD_CHECK_PARA(double_colon, ==, FALSE); /* Error: triple-colon or two double-colons */
+ double_colon = TRUE;
+ }
+ /* not the first ch and a double-colon */
+ else
+ {
+ CMD_CHECK_PARA(double_colon_pos, <, 15); /* Error: only 16 units for UI8_T */
+ CMD_CHECK_PARA(last_pos, <, 15); /* Error: only 16 units for UI8_T */
+ tmp_ipv6[last_pos] = (UI8_T)((hex_value >> 8) & 0xff);
+ tmp_ipv6[last_pos + 1] = (UI8_T)((hex_value >> 0) & 0xff);
+ double_colon_pos += (FALSE == double_colon)? 2 : 0;
+ last_pos += 2;
+ hex_value = 0;
+ dec_value = 0;
+ }
+ }
+ else if ('.' == ptr_str[idx])
+ {
+ CMD_CHECK_PARA(last_pos, <, 16); /* Error: only 16 units for UI8_T */
+ tmp_ipv6[last_pos] = dec_value;
+ last_pos += 1;
+ dec_value = 0;
+ ipv4_compatible = TRUE;
+ }
+ else
+ {
+ return AIR_E_BAD_PARAMETER; /* Error: not a hex number or colon */
+ }
+ }
+
+ /* last data */
+ if ((idx != 0) && (':' != ptr_str[idx - 1]))
+ {
+ if (FALSE == ipv4_compatible)
+ {
+ CMD_CHECK_PARA(last_pos, <, 15); /* Error: only 16 units for UI8_T */
+ tmp_ipv6[last_pos] = (UI8_T)((hex_value >> 8) & 0xff);
+ tmp_ipv6[last_pos + 1] = (UI8_T)((hex_value >> 0) & 0xff);
+ last_pos += 2;
+ }
+ else
+ {
+ CMD_CHECK_PARA(last_pos, <, 16); /* Error: only 16 units for UI8_T */
+ tmp_ipv6[last_pos] = dec_value;
+ last_pos += 1;
+ }
+ }
+ else
+ {
+ if ((idx >= 2) && (':' != ptr_str[idx - 2]))
+ {
+ return AIR_E_BAD_PARAMETER; /* Error: last cannot be colon except double-colon */
+ }
+ }
+
+ /* move tmp_ipv6 to ptr_value */
+ if (TRUE == double_colon)
+ {
+ /* e.g.
+ * 3ffe::c0a8:0 double_colon_pos = 2, last_pos = 4+2, tmp_ipv6 = {3f,fe,c0,a8,00,00,...}
+ * 3ffe:c0a8:0:: double_colon_pos = 6, last_pos = 6, tmp_ipv6 = {3f,fe,c0,a8,00,00,...}
+ * ::3ffe:c0a8:0 double_colon_pos = 0, last_pos = 4+2, tmp_ipv6 = {3f,fe,c0,a8,00,00,...}
+ * 3ffe::192.168.0.0 double_colon_pos = 2, last_pos = 5+1, tmp_ipv6 = {3f,fe,c0,a8,00,00,...}
+ *
+ * 0 1 2 3 4 5 6 7 8 9 a b c d e f
+ * 3ffe::c0a8:0 ptr_value = {3f,fe,--,--,--,--,--,--,--,--,--,--,--,--,--,--}
+ * 3ffe:c0a8:0:: ptr_value = {3f,fe,c0,a8,00,00,--,--,--,--,--,--,--,--,--,--}
+ * ::3ffe:c0a8:0 ptr_value = {--,--,--,--,--,--,--,--,--,--,--,--,--,--,--,--}
+ * 3ffe::192.168.0.0 ptr_value = {3f,fe,--,--,--,--,--,--,--,--,--,--,--,--,--,--}
+ */
+ for (idx = 0; idx < double_colon_pos; idx++)
+ {
+ ptr_addr[idx] = tmp_ipv6[idx];
+ }
+ /* e.g.
+ * 0 1 2 3 4 5 6 7 8 9 a b c d e f
+ * 3ffe::c0a8:0 ptr_value = {3f,fe,--,--,--,--,--,--,--,--,--,--,c0,a8,00,00}
+ * 3ffe:c0a8:0:: ptr_value = {3f,fe,c0,a8,00,00,--,--,--,--,--,--,--,--,--,--}
+ * ::3ffe:c0a8:0 ptr_value = {--,--,--,--,--,--,--,--,--,--,3f,fe,c0,a8,00,00}
+ * 3ffe::192.168.0.0 ptr_value = {3f,fe,--,--,--,--,--,--,--,--,--,--,c0,a8,00,00}
+ */
+ for (idx = double_colon_pos; idx < last_pos; idx++)
+ {
+ ptr_addr[16 - (last_pos - idx)] = tmp_ipv6[idx];
+ }
+ }
+ else
+ {
+ for (idx = 0; idx < 16; idx++)
+ {
+ ptr_addr[idx] = tmp_ipv6[idx];
+ }
+ }
+
+ return AIR_E_OK;
+}
+
+void
+_showIpv6Str(
+ const UI8_T *ptr_ipv6,
+ C8_T *ptr_str)
+{
+ UI32_T idx = 0, next = 0, last = 16;
+ UI32_T cont_zero = 0;
+
+ while (idx < last)
+ {
+ if ((0 == cont_zero) && (0 == ptr_ipv6[idx]) && (0 == ptr_ipv6[idx + 1]))
+ {
+ next = idx + 2;
+
+ while (next < last)
+ {
+ if ((ptr_ipv6[next]) || (ptr_ipv6[next + 1]))
+ {
+ AIR_PRINT(
+ ptr_str + strlen(ptr_str),
+ 40 - strlen(ptr_str),
+ "%s", (cont_zero) ? (":") : (":0"));
+ break;
+ }
+
+ if (0 == cont_zero)
+ {
+ cont_zero = 1;
+ }
+ next += 2;
+ }
+
+ if (next == last)
+ {
+
+ AIR_PRINT(
+ ptr_str + strlen(ptr_str),
+ 40 - strlen(ptr_str),
+ "%s", (cont_zero) ? ("::") : (":0"));
+ }
+
+ idx = next;
+ }
+ else
+ {
+ if (idx)
+ {
+ AIR_PRINT(
+ ptr_str + strlen(ptr_str),
+ 40 - strlen(ptr_str),
+ ":");
+ }
+
+ if (ptr_ipv6[idx])
+ {
+ AIR_PRINT(
+ ptr_str + strlen(ptr_str),
+ 40 - strlen(ptr_str),
+ "%0x%02x", ptr_ipv6[idx], ptr_ipv6[idx + 1]);
+ }
+ else
+ {
+ AIR_PRINT(
+ ptr_str + strlen(ptr_str),
+ 40 - strlen(ptr_str),
+ "%0x", ptr_ipv6[idx + 1]);
+ }
+
+ idx += 2;
+ }
+ }
+}
+
+static AIR_ERROR_NO_T
+_hex2bit(
+ const UI32_T hex,
+ UI32_T *ptr_bit)
+{
+ UI32_T i = 0;
+
+ /* Mistake proofing */
+ AIR_CHECK_PTR(ptr_bit);
+
+ (*ptr_bit) = 0;
+ for(i=0; i<AIR_MAX_NUM_OF_PORTS; i++)
+ {
+ if(hex & BIT(i))
+ {
+ (*ptr_bit) |= BITS_OFF_L(1UL, 4*(AIR_MAX_NUM_OF_PORTS - i - 1), 4);
+ }
+ }
+ return AIR_E_OK;
+}
+
+static AIR_ERROR_NO_T
+_hex2bitstr(
+ const UI32_T hex,
+ C8_T *ptr_bit_str,
+ UI32_T str_len)
+{
+ UI32_T i = 0;
+ C8_T str_bitmap[AIR_MAX_NUM_OF_PORTS+1];
+
+ /* Mistake proofing */
+ AIR_CHECK_PTR(ptr_bit_str);
+ AIR_PARAM_CHK(str_len <= AIR_MAX_NUM_OF_PORTS, AIR_E_BAD_PARAMETER);
+
+ memset(str_bitmap, 0, AIR_MAX_NUM_OF_PORTS+1);
+
+ for(i=0; i<AIR_MAX_NUM_OF_PORTS; i++)
+ {
+ if(hex & BIT(i))
+ {
+ str_bitmap[i] = '1';
+ }
+ else
+ {
+ str_bitmap[i] = '-';
+ }
+ }
+ str_bitmap[i] = '\0';
+ strncpy(ptr_bit_str, str_bitmap, i+1);
+
+ return AIR_E_OK;
+}
+
+static AIR_ERROR_NO_T
+_portListStr2Ary(
+ const C8_T *str,
+ UI32_T *ary,
+ const UI32_T ary_num)
+{
+ UI32_T i = 0;
+ UI32_T str_len = 0;
+ UI32_T val = 0;
+ C8_T *str2;
+ C8_T *pch;
+ C8_T *last;
+
+ /* Mistake proofing */
+ AIR_CHECK_PTR(str);
+ AIR_CHECK_PTR(ary);
+ AIR_PARAM_CHK(0 == ary_num, AIR_E_BAD_PARAMETER);
+
+ /* Allocate new string */
+ str_len = strlen(str);
+ str2 = AIR_MALLOC(str_len+1);
+ AIR_CHECK_PTR(str2);
+ memset(str2, 0, str_len+1);
+ strncpy(str2, str, str_len+1);
+
+ /* clear array */
+ memset(ary, 0, ary_num*4);
+
+ /* split string by ',' */
+ pch = _strtok(str2, ",", &last);
+ while(NULL != pch)
+ {
+ val = _strtoul(pch, NULL, 0);
+ ary[val/32] |= BIT(val%32);
+ pch = _strtok(NULL, ",", &last);
+ }
+
+ AIR_FREE(str2);
+ return AIR_E_OK;
+}
+
+static AIR_ERROR_NO_T
+doRegRead(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ UI32_T reg = 0, val = 0;
+
+ reg = _strtoul(argv[0], NULL, 16);
+ aml_readReg(0, reg, &val);
+ AIR_PRINT("Read reg=0x%x, value=0x%x\n", reg, val);
+
+ return AIR_E_OK;
+}
+
+static AIR_ERROR_NO_T
+doRegWrite(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ UI32_T reg = 0, val = 0;
+
+ reg = _strtoul(argv[0], NULL, 16);
+ val = _strtoul(argv[1], NULL, 16);
+ aml_writeReg(0, reg, val);
+ AIR_PRINT("Write reg=0x%x, value=0x%x\n", reg, val);
+
+ return AIR_E_OK;
+}
+
+static AIR_ERROR_NO_T
+doReg(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(regCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doPhyCL22Read(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ UI32_T port = 0, reg = 0, val = 0;
+
+ port = _strtoul(argv[0], NULL, 0);
+ reg = _strtoul(argv[1], NULL, 16);
+ aml_readPhyReg(0, port, reg, &val);
+ AIR_PRINT("Phy read port=%d, reg=0x%x, value=0x%x\n", port, reg, val);
+
+ return AIR_E_OK;
+}
+
+static AIR_ERROR_NO_T
+doPhyCL22Write(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ UI32_T port = 0, reg = 0, val = 0;
+
+ port = _strtoul(argv[0], NULL, 0);
+ reg = _strtoul(argv[1], NULL, 16);
+ val = _strtoul(argv[2], NULL, 16);
+ aml_writePhyReg(0, port, reg, val);
+ AIR_PRINT("Phy write port=%d, reg=0x%x, value=0x%x\n", port, reg, val);
+
+ return AIR_E_OK;
+}
+
+static AIR_ERROR_NO_T
+doPhyCL22(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(phyCL22Cmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doPhyCL45Read(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ UI32_T port = 0, dev = 0, reg = 0, val = 0;
+
+ port = _strtoul(argv[0], NULL, 0);
+ dev = _strtoul(argv[1], NULL, 16);
+ reg = _strtoul(argv[2], NULL, 16);
+ aml_readPhyRegCL45(0, port, dev, reg, &val);
+ AIR_PRINT("Phy read port=%d, dev=0x%x, reg=0x%x, value=0x%x\n", port, dev, reg, val);
+
+ return AIR_E_OK;
+}
+
+static AIR_ERROR_NO_T
+doPhyCL45Write(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ UI32_T port = 0, dev = 0, reg = 0, val = 0;
+
+ port = _strtoul(argv[0], NULL, 0);
+ dev = _strtoul(argv[1], NULL, 16);
+ reg = _strtoul(argv[2], NULL, 16);
+ val = _strtoul(argv[3], NULL, 16);
+ aml_writePhyRegCL45(0, port, dev, reg, val);
+ AIR_PRINT("Phy write port=%d, dev=0x%x, reg=0x%x, value=0x%x\n", port, dev, reg, val);
+
+ return AIR_E_OK;
+}
+
+static AIR_ERROR_NO_T
+doPhyCL45(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(phyCL45Cmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doPhy(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(phyCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doPortSetMatrix(UI32_T argc, C8_T *argv[])
+{
+ UI32_T port = 0;
+ UI32_T matrix = 0;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ port = _strtoul(argv[0], NULL, 0);
+ matrix = _strtoul(argv[1], NULL, 16);
+ rc = air_port_setPortMatrix(0, port, matrix);
+ if (rc != AIR_E_OK)
+ {
+ AIR_PRINT("Error: Operation failed!\n");
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doPortSetVlanMode(UI32_T argc, C8_T *argv[])
+{
+ UI32_T port = 0;
+ AIR_PORT_VLAN_MODE_T vlan_mode;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ port = _strtoul(argv[0], NULL, 0);
+ vlan_mode = _strtoul(argv[1], NULL, 0);
+ rc = air_port_setVlanMode(0, port, vlan_mode);
+ if (rc != AIR_E_OK)
+ {
+ AIR_PRINT("Error: Operation failed!\n");
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doPortSet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(portSetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doPortGetMatrix(UI32_T argc, C8_T *argv[])
+{
+ UI32_T port = 0;
+ UI32_T matrix = 0;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ port = _strtoul(argv[0], NULL, 0);
+ rc = air_port_getPortMatrix(0, port, &matrix);
+ if (rc != AIR_E_OK)
+ {
+ AIR_PRINT("Error: Operation failed!\n");
+ return rc;
+ }
+ AIR_PRINT("Port %d Matrix: %2x\n", port, matrix);
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doPortGetVlanMode(UI32_T argc, C8_T *argv[])
+{
+ UI32_T port = 0;
+ AIR_PORT_VLAN_MODE_T vlan_mode;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ port = _strtoul(argv[0], NULL, 0);
+ rc = air_port_getVlanMode(0, port, &vlan_mode);
+ if (rc != AIR_E_OK)
+ {
+ AIR_PRINT("Error: Operation failed!\n");
+ return rc;
+ }
+ AIR_PRINT("Port %d Vlan Mode: ", port);
+ switch(vlan_mode)
+ {
+ case AIR_PORT_VLAN_MODE_PORT_MATRIX:
+ AIR_PRINT("matrix(%d)\n", vlan_mode);
+ break;
+ case AIR_PORT_VLAN_MODE_FALLBACK:
+ AIR_PRINT("fallback(%d)\n", vlan_mode);
+ break;
+ case AIR_PORT_VLAN_MODE_CHECK:
+ AIR_PRINT("check(%d)\n", vlan_mode);
+ break;
+ case AIR_PORT_VLAN_MODE_SECURITY:
+ AIR_PRINT("security(%d)\n", vlan_mode);
+ break;
+ default:
+ AIR_PRINT("unknown(%d)\n", vlan_mode);
+ break;
+ };
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doPortGet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(portGetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doPort(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(portCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doVlanInitiate(UI32_T argc, C8_T *argv[])
+{
+ UI16_T vid = 0;
+ AIR_VLAN_ENTRY_ATTR_T vlan_entry = {0};
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ vid = _strtoul(argv[0], NULL, 0);
+ if (9 == argc)
+ {
+ vlan_entry.vlan_entry_format.fid = _strtoul(argv[1], NULL, 0);
+ vlan_entry.vlan_entry_format.port_mem = _strtoul(argv[2], NULL, 0);
+ vlan_entry.vlan_entry_format.ivl = _strtoul(argv[3], NULL, 0);
+ vlan_entry.vlan_entry_format.port_stag = _strtoul(argv[4], NULL, 0);
+ vlan_entry.vlan_entry_format.stag = _strtoul(argv[5], NULL, 0);
+ vlan_entry.vlan_entry_format.eg_ctrl_en = _strtoul(argv[6], NULL, 0);
+ vlan_entry.vlan_entry_format.eg_con = _strtoul(argv[7], NULL, 0);
+ vlan_entry.vlan_entry_format.eg_ctrl = _strtoul(argv[8], NULL, 0);
+
+ rc = air_vlan_create(0, vid, &vlan_entry);
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ rc = AIR_E_BAD_PARAMETER;
+ }
+
+ switch (rc)
+ {
+ case AIR_E_OK: break;
+ case AIR_E_ENTRY_EXISTS: AIR_PRINT("VLAN already exist!\n"); break;
+ default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanCreate(UI32_T argc, C8_T *argv[])
+{
+ UI16_T vid = 0;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ vid = _strtoul(argv[0], NULL, 0);
+ rc = air_vlan_create(0, vid, NULL);
+
+ switch (rc)
+ {
+ case AIR_E_OK: break;
+ case AIR_E_ENTRY_EXISTS: AIR_PRINT("VLAN already exist!\n"); break;
+ default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanDestroy(UI32_T argc, C8_T *argv[])
+{
+ C8_T *token = NULL;
+ UI16_T vid = 0, vid_limit = AIR_VLAN_ID_MAX;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ if (argc > 0)
+ {
+ if (isdigit(argv[0][0]))
+ {
+ token = _strtok(argv[0], "-", &argv[0]);
+ vid = _strtoul(token, NULL, 0);
+ if ((token = _strtok(argv[0], "-", &argv[0])))
+ vid_limit = _strtoul(token, NULL, 0);
+ else
+ vid_limit = vid;
+ if (AIR_VLAN_ID_MAX < vid_limit)
+ {
+ AIR_PRINT("vid number should less than %d!\n", AIR_VLAN_ID_MAX);
+ return AIR_E_BAD_PARAMETER;
+ }
+ if (vid > vid_limit)
+ {
+ AIR_PRINT("vid0 should less than vid1!\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+ }
+ else
+ {
+ AIR_PRINT("Bad parameter!\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+ }
+
+ for (; vid <= vid_limit; vid++)
+ {
+ rc = air_vlan_destroy(0, vid);
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanDestroyAll(UI32_T argc, C8_T *argv[])
+{
+ UI32_T restore_def_vlan = 0;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ if (argc > 0)
+ {
+ restore_def_vlan = _strtoul(argv[0], NULL, 0);
+ }
+
+ rc = air_vlan_destroyAll(0, restore_def_vlan);
+ if (rc != AIR_E_OK)
+ {
+ AIR_PRINT("Error: Operation failed!\n");
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanDump(UI32_T argc, C8_T *argv[])
+{
+ C8_T *token = NULL;
+ UI16_T port = 0, valid_count = 0, vid = 0, vid_limit = AIR_VLAN_ID_MAX;
+ AIR_PORT_EGS_TAG_ATTR_T tag_ctl[AIR_MAX_NUM_OF_PORTS] = {0};
+ AIR_VLAN_ENTRY_T vlan_entry = {0};
+
+ if (argc > 0)
+ {
+ if (isdigit(argv[0][0]))
+ {
+ token = _strtok(argv[0], "-", &argv[0]);
+ vid = _strtoul(token, NULL, 0);
+ if ((token = _strtok(argv[0], "-", &argv[0])))
+ vid_limit = _strtoul(token, NULL, 0);
+ else
+ vid_limit = vid;
+ if (AIR_VLAN_ID_MAX < vid_limit)
+ {
+ AIR_PRINT("vid number should less than %d!\n", AIR_VLAN_ID_MAX);
+ return AIR_E_BAD_PARAMETER;
+ }
+ if (vid > vid_limit)
+ {
+ AIR_PRINT("vid0 should less than vid1!\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+ }
+ else
+ {
+ AIR_PRINT("Bad parameter!\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+ }
+
+ for (valid_count = 0; vid <= vid_limit; vid++)
+ {
+ _air_vlan_readEntry(0, vid, &vlan_entry);
+ if (vlan_entry.valid)
+ {
+ valid_count++;
+ if (1 == valid_count)
+ AIR_PRINT(" Vid Fid MemPort Ivl PortBaseStag Stag EgsTagCtlEn EgsTagCon EgsTagCtl\n======================================================================\n");
+ for (port = 0; port < AIR_MAX_NUM_OF_PORTS; port++)
+ tag_ctl[port] = (vlan_entry.vlan_entry_format.eg_ctrl >> (port * 2)) & 0x3;
+ AIR_PRINT("%4d %3d %2x %3d %12d %4d %11d %9d %1x%1x%1x%1x%1x%1x%1x\n",
+ vid, vlan_entry.vlan_entry_format.fid, vlan_entry.vlan_entry_format.port_mem, vlan_entry.vlan_entry_format.ivl,
+ vlan_entry.vlan_entry_format.port_stag, vlan_entry.vlan_entry_format.stag, vlan_entry.vlan_entry_format.eg_ctrl_en, vlan_entry.vlan_entry_format.eg_con,
+ tag_ctl[6], tag_ctl[5], tag_ctl[4], tag_ctl[3], tag_ctl[2], tag_ctl[1], tag_ctl[0]);
+ }
+ }
+
+ if (!valid_count)
+ AIR_PRINT("not found!\n");
+ else
+ AIR_PRINT("Found %d valid entries!\n", valid_count);
+
+ return AIR_E_OK;
+}
+
+static AIR_ERROR_NO_T
+doVlanAddPortMem(UI32_T argc, C8_T *argv[])
+{
+ UI16_T vid = 0, port = 0;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ vid = _strtoul(argv[0], NULL, 0);
+ port = _strtoul(argv[1], NULL, 0);
+ rc = air_vlan_addMemberPort(0, vid, port);
+ switch (rc)
+ {
+ case AIR_E_OK: break;
+ case AIR_E_ENTRY_NOT_FOUND: AIR_PRINT("VLAN not found!\n"); break;
+ default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanDelPortMem(UI32_T argc, C8_T *argv[])
+{
+ UI16_T vid = 0, port = 0;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ vid = _strtoul(argv[0], NULL, 0);
+ port = _strtoul(argv[1], NULL, 0);
+ rc = air_vlan_delMemberPort(0, vid, port);
+ switch (rc)
+ {
+ case AIR_E_OK: break;
+ case AIR_E_ENTRY_NOT_FOUND: AIR_PRINT("VLAN not found!\n"); break;
+ default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanSetFid(UI32_T argc, C8_T *argv[])
+{
+ UI16_T vid = 0;
+ UI8_T fid = 0;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ vid = _strtoul(argv[0], NULL, 0);
+ fid = _strtoul(argv[1], NULL, 0);
+ rc = air_vlan_setFid(0, vid, fid);
+ switch (rc)
+ {
+ case AIR_E_OK: break;
+ case AIR_E_ENTRY_NOT_FOUND: AIR_PRINT("VLAN not found!\n"); break;
+ default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanSetMemPort(UI32_T argc, C8_T *argv[])
+{
+ UI16_T vid = 0, port_bitmap = 0;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ vid = _strtoul(argv[0], NULL, 0);
+ port_bitmap = _strtoul(argv[1], NULL, 16);
+ rc = air_vlan_setMemberPort(0, vid, port_bitmap);
+ switch (rc)
+ {
+ case AIR_E_OK: break;
+ case AIR_E_ENTRY_NOT_FOUND: AIR_PRINT("VLAN not found!\n"); break;
+ default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanSetIVL(UI32_T argc, C8_T *argv[])
+{
+ UI16_T vid = 0;
+ BOOL_T enable = TRUE;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ vid = _strtoul(argv[0], NULL, 0);
+ enable = _strtoul(argv[1], NULL, 0);
+ rc = air_vlan_setIVL(0, vid, enable);
+ switch (rc)
+ {
+ case AIR_E_OK: break;
+ case AIR_E_ENTRY_NOT_FOUND: AIR_PRINT("VLAN not found!\n"); break;
+ default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanSetPortBaseStag(UI32_T argc, C8_T *argv[])
+{
+ UI16_T vid = 0;
+ BOOL_T enable = TRUE;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ vid = _strtoul(argv[0], NULL, 0);
+ enable = _strtoul(argv[1], NULL, 0);
+ rc = air_vlan_setPortBasedStag(0, vid, enable);
+ switch (rc)
+ {
+ case AIR_E_OK: break;
+ case AIR_E_ENTRY_NOT_FOUND: AIR_PRINT("VLAN not found!\n"); break;
+ default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanSetStag(UI32_T argc, C8_T *argv[])
+{
+ UI16_T vid = 0, stag = 0;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ vid = _strtoul(argv[0], NULL, 0);
+ stag = _strtoul(argv[1], NULL, 0);
+ rc = air_vlan_setServiceTag(0, vid, stag);
+ switch (rc)
+ {
+ case AIR_E_OK: break;
+ case AIR_E_ENTRY_NOT_FOUND: AIR_PRINT("VLAN not found!\n"); break;
+ default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanSetEgsTagCtlEn(UI32_T argc, C8_T *argv[])
+{
+ UI16_T vid = 0;
+ BOOL_T enable = TRUE;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ vid = _strtoul(argv[0], NULL, 0);
+ enable = _strtoul(argv[1], NULL, 0);
+ rc = air_vlan_setEgsTagCtlEnable(0, vid, enable);
+ switch (rc)
+ {
+ case AIR_E_OK: break;
+ case AIR_E_ENTRY_NOT_FOUND: AIR_PRINT("VLAN not found!\n"); break;
+ default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanSetEgsTagCtlCon(UI32_T argc, C8_T *argv[])
+{
+ UI16_T vid = 0;
+ BOOL_T enable = TRUE;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ vid = _strtoul(argv[0], NULL, 0);
+ enable = _strtoul(argv[1], NULL, 0);
+ rc = air_vlan_setEgsTagConsistent(0, vid, enable);
+ switch (rc)
+ {
+ case AIR_E_OK: break;
+ case AIR_E_ENTRY_NOT_FOUND: AIR_PRINT("VLAN not found!\n"); break;
+ default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanSetEgsTagCtl(UI32_T argc, C8_T *argv[])
+{
+ UI16_T vid = 0, port = 0;
+ AIR_PORT_EGS_TAG_ATTR_T tag_ctl = AIR_PORT_EGS_TAG_ATTR_UNTAGGED;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ vid = _strtoul(argv[0], NULL, 0);
+ port = _strtoul(argv[1], NULL, 0);
+ tag_ctl = _strtoul(argv[2], NULL, 0);
+ rc = air_vlan_setPortEgsTagCtl(0, vid, port, tag_ctl);
+ switch (rc)
+ {
+ case AIR_E_OK: break;
+ case AIR_E_ENTRY_NOT_FOUND: AIR_PRINT("VLAN not found!\n"); break;
+ default: AIR_PRINT("Error %d: Operation failed!\n", rc); break;
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanSetPortActFrame(UI32_T argc, C8_T *argv[])
+{
+ UI16_T port = 0;
+ AIR_VLAN_ACCEPT_FRAME_TYPE_T type = AIR_VLAN_ACCEPT_FRAME_TYPE_ALL;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ port = _strtoul(argv[0], NULL, 0);
+ type = _strtoul(argv[1], NULL, 0);
+ rc = air_vlan_setPortAcceptFrameType(0, port, type);
+ if (rc != AIR_E_OK)
+ {
+ AIR_PRINT("Error: Operation failed!\n");
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanSetLeakyVlanEn(UI32_T argc, C8_T *argv[])
+{
+ UI16_T port = 0;
+ AIR_LEAKY_PKT_TYPE_T pkt_type = AIR_LEAKY_PKT_TYPE_UNICAST;
+ BOOL_T enable = TRUE;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ port = _strtoul(argv[0], NULL, 0);
+ pkt_type = _strtoul(argv[1], NULL, 0);
+ enable = _strtoul(argv[2], NULL, 0);
+ rc = air_vlan_setPortLeakyVlanEnable(0, port, pkt_type, enable);
+ if (rc != AIR_E_OK)
+ {
+ AIR_PRINT("Error: Operation failed!\n");
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanSetPortVlanAttr(UI32_T argc, C8_T *argv[])
+{
+ UI16_T port = 0;
+ AIR_VLAN_PORT_ATTR_T attr = AIR_VLAN_PORT_ATTR_USER_PORT;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ port = _strtoul(argv[0], NULL, 0);
+ attr = _strtoul(argv[1], NULL, 0);
+ rc = air_vlan_setPortAttr(0, port, attr);
+ if (rc != AIR_E_OK)
+ {
+ AIR_PRINT("Error: Operation failed!\n");
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanSetIgsPortETagAttr(UI32_T argc, C8_T *argv[])
+{
+ UI16_T port = 0;
+ AIR_IGR_PORT_EG_TAG_ATTR_T attr = AIR_IGR_PORT_EG_TAG_ATTR_DISABLE;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ port = _strtoul(argv[0], NULL, 0);
+ attr = _strtoul(argv[1], NULL, 0);
+ rc = air_vlan_setIgrPortTagAttr(0, port, attr);
+ if (rc != AIR_E_OK)
+ {
+ AIR_PRINT("Error: Operation failed!\n");
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanSetPortETagAttr(UI32_T argc, C8_T *argv[])
+{
+ UI16_T port = 0;
+ AIR_PORT_EGS_TAG_ATTR_T attr = AIR_PORT_EGS_TAG_ATTR_UNTAGGED;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ port = _strtoul(argv[0], NULL, 0);
+ attr = _strtoul(argv[1], NULL, 0);
+ rc = air_vlan_setPortEgsTagAttr(0, port, attr);
+ if (rc != AIR_E_OK)
+ {
+ AIR_PRINT("Error: Operation failed!\n");
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanSetPortOuterTPID(UI32_T argc, C8_T *argv[])
+{
+ UI16_T port = 0, tpid = 0;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ port = _strtoul(argv[0], NULL, 0);
+ tpid = _strtoul(argv[1], NULL, 16);
+ rc = air_vlan_setPortOuterTPID(0, port, tpid);
+ if (rc != AIR_E_OK)
+ {
+ AIR_PRINT("Error: Operation failed!\n");
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanSetPvid(UI32_T argc, C8_T *argv[])
+{
+ UI16_T port = 0, pvid = 0;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ port = _strtoul(argv[0], NULL, 0);
+ pvid = _strtoul(argv[1], NULL, 0);
+ rc = air_vlan_setPortPVID(0, port, pvid);
+ if (rc != AIR_E_OK)
+ {
+ AIR_PRINT("Error: Operation failed!\n");
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanSet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(vlanSetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doVlanGetPortActFrame(UI32_T argc, C8_T *argv[])
+{
+ UI32_T port = 0;
+ AIR_VLAN_ACCEPT_FRAME_TYPE_T type;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ port = _strtoul(argv[0], NULL, 0);
+ rc = air_vlan_getPortAcceptFrameType(0, port, &type);
+ if (rc != AIR_E_OK)
+ {
+ AIR_PRINT("Error: Operation failed!\n");
+ return rc;
+ }
+ AIR_PRINT("Port %d Acceptable Frame Type: ", port);
+ switch(type)
+ {
+ case AIR_VLAN_ACCEPT_FRAME_TYPE_ALL:
+ AIR_PRINT("all(%d)\n", type);
+ break;
+ case AIR_VLAN_ACCEPT_FRAME_TYPE_TAG_ONLY:
+ AIR_PRINT("tagged-only(%d)\n", type);
+ break;
+ case AIR_VLAN_ACCEPT_FRAME_TYPE_UNTAG_ONLY:
+ AIR_PRINT("untagged-only(%d)\n", type);
+ break;
+ default:
+ AIR_PRINT("unknown(%d)\n", type);
+ break;
+ };
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanGetLeakyVlanEn(UI32_T argc, C8_T *argv[])
+{
+ UI32_T port = 0;
+ BOOL_T uc = FALSE, mc = FALSE, bc = FALSE;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ port = _strtoul(argv[0], NULL, 0);
+ rc += air_vlan_getPortLeakyVlanEnable(0, port, AIR_LEAKY_PKT_TYPE_UNICAST, &uc);
+ rc += air_vlan_getPortLeakyVlanEnable(0, port, AIR_LEAKY_PKT_TYPE_MULTICAST, &mc);
+ rc += air_vlan_getPortLeakyVlanEnable(0, port, AIR_LEAKY_PKT_TYPE_BROADCAST, &bc);
+ if (rc != AIR_E_OK)
+ {
+ AIR_PRINT("Error: Operation failed!\n");
+ return rc;
+ }
+
+ AIR_PRINT("Port %d Leaky Vlan Enable\n", port);
+ AIR_PRINT("Unicast : %s\n", uc ? "TRUE" : "FALSE");
+ AIR_PRINT("Multicast : %s\n", mc ? "TRUE" : "FALSE");
+ AIR_PRINT("Broadcast : %s\n", bc ? "TRUE" : "FALSE");
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanGetPortVlanAttr(UI32_T argc, C8_T *argv[])
+{
+ UI32_T port = 0;
+ AIR_VLAN_PORT_ATTR_T attr;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ port = _strtoul(argv[0], NULL, 0);
+ rc = air_vlan_getPortAttr(0, port, &attr);
+ if (rc != AIR_E_OK)
+ {
+ AIR_PRINT("Error: Operation failed!\n");
+ return rc;
+ }
+ AIR_PRINT("Port %d Vlan Attr: ", port);
+ switch(attr)
+ {
+ case AIR_VLAN_PORT_ATTR_USER_PORT:
+ AIR_PRINT("user port(%d)\n", attr);
+ break;
+ case AIR_VLAN_PORT_ATTR_STACK_PORT:
+ AIR_PRINT("stack port(%d)\n", attr);
+ break;
+ case AIR_VLAN_PORT_ATTR_TRANSLATION_PORT:
+ AIR_PRINT("translation port(%d)\n", attr);
+ break;
+ case AIR_VLAN_PORT_ATTR_TRANSPARENT_PORT:
+ AIR_PRINT("transparent port(%d)\n", attr);
+ break;
+ default:
+ AIR_PRINT("unknown(%d)\n", attr);
+ break;
+ };
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanGetIgsPortETagAttr(UI32_T argc, C8_T *argv[])
+{
+ UI32_T port = 0;
+ AIR_IGR_PORT_EG_TAG_ATTR_T attr;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ port = _strtoul(argv[0], NULL, 0);
+ rc = air_vlan_getIgrPortTagAttr(0, port, &attr);
+ if (rc != AIR_E_OK)
+ {
+ AIR_PRINT("Error: Operation failed!\n");
+ return rc;
+ }
+ AIR_PRINT("Port %d Incomming Port Egress Tag Attr: ", port);
+ switch(attr)
+ {
+ case AIR_IGR_PORT_EG_TAG_ATTR_DISABLE:
+ AIR_PRINT("disable(%d)\n", attr);
+ break;
+ case AIR_IGR_PORT_EG_TAG_ATTR_CONSISTENT:
+ AIR_PRINT("consistent(%d)\n", attr);
+ break;
+ case AIR_IGR_PORT_EG_TAG_ATTR_UNTAGGED:
+ AIR_PRINT("untagged(%d)\n", attr);
+ break;
+ case AIR_IGR_PORT_EG_TAG_ATTR_SWAP:
+ AIR_PRINT("swap(%d)\n", attr);
+ break;
+ case AIR_IGR_PORT_EG_TAG_ATTR_TAGGED:
+ AIR_PRINT("tagged(%d)\n", attr);
+ break;
+ case AIR_IGR_PORT_EG_TAG_ATTR_STACK:
+ AIR_PRINT("stack(%d)\n", attr);
+ break;
+ default:
+ AIR_PRINT("unknown(%d)\n", attr);
+ break;
+ };
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanGetPortETagAttr(UI32_T argc, C8_T *argv[])
+{
+ UI32_T port = 0;
+ AIR_PORT_EGS_TAG_ATTR_T attr;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ port = _strtoul(argv[0], NULL, 0);
+ rc = air_vlan_getPortEgsTagAttr(0, port, &attr);
+ if (rc != AIR_E_OK)
+ {
+ AIR_PRINT("Error: Operation failed!\n");
+ return rc;
+ }
+ AIR_PRINT("Port %d Egress Tag Attr: ", port);
+ switch(attr)
+ {
+ case AIR_PORT_EGS_TAG_ATTR_UNTAGGED:
+ AIR_PRINT("untagged(%d)\n", attr);
+ break;
+ case AIR_PORT_EGS_TAG_ATTR_SWAP:
+ AIR_PRINT("swap(%d)\n", attr);
+ break;
+ case AIR_PORT_EGS_TAG_ATTR_TAGGED:
+ AIR_PRINT("tagged(%d)\n", attr);
+ break;
+ case AIR_PORT_EGS_TAG_ATTR_STACK:
+ AIR_PRINT("stack(%d)\n", attr);
+ break;
+ default:
+ AIR_PRINT("unknown(%d)\n", attr);
+ break;
+ };
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanGetPortOuterTPID(UI32_T argc, C8_T *argv[])
+{
+ UI32_T port = 0;
+ UI16_T tpid = 0;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ port = _strtoul(argv[0], NULL, 0);
+ rc = air_vlan_getPortOuterTPID(0, port, &tpid);
+ if (rc != AIR_E_OK)
+ {
+ AIR_PRINT("Error: Operation failed!\n");
+ return rc;
+ }
+ AIR_PRINT("Port %d Outer TPID: %4x\n", port, tpid);
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanGetPvid(UI32_T argc, C8_T *argv[])
+{
+ UI32_T port = 0;
+ UI16_T pvid = 0;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ port = _strtoul(argv[0], NULL, 0);
+ rc = air_vlan_getPortPVID(0, port, &pvid);
+ if (rc != AIR_E_OK)
+ {
+ AIR_PRINT("Error: Operation failed!\n");
+ return rc;
+ }
+ AIR_PRINT("Port %d PVID: %d\n", port, pvid);
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doVlanGet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(vlanGetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doVlan(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(vlanCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doJumbo(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ I32_T pkt_len = 0, frame_len = 0;
+
+ if(0 == argc)
+ {
+ /* get command */
+ ret = air_port_getJumbo(0, &pkt_len, &frame_len);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Get ");
+ switch(pkt_len)
+ {
+ case 0:
+ AIR_PRINT("RX_1518 ");
+ break;
+ case 1:
+ AIR_PRINT("RX_1536 ");
+ break;
+ case 2:
+ AIR_PRINT("RX_1552 ");
+ break;
+ case 3:
+ AIR_PRINT("RX_JUMBO ");
+ break;
+ }
+ AIR_PRINT("frames lengths %d KBytes\n", frame_len);
+ }
+ else
+ {
+ AIR_PRINT("Get Jumbo Fail.\n");
+ }
+ }
+ else
+ {
+ /* set command */
+ pkt_len = _strtol(argv[0], NULL, 10);
+ frame_len = _strtol(argv[1], NULL, 10);
+
+ ret = air_port_setJumbo(0, pkt_len, frame_len);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Set ");
+ switch(pkt_len)
+ {
+ case 0:
+ AIR_PRINT("RX_1518 ");
+ break;
+ case 1:
+ AIR_PRINT("RX_1536 ");
+ break;
+ case 2:
+ AIR_PRINT("RX_1552 ");
+ break;
+ case 3:
+ AIR_PRINT("RX_JUMBO ");
+ break;
+ }
+ AIR_PRINT("frames lengths %d KBytes\n", frame_len);
+ }
+ else
+ AIR_PRINT("Set Jumbo Fail.\n");
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doFlowCtrl(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ BOOL_T fc_en = 0, dir = 0;
+ I32_T port = 0;
+
+ port = _strtol(argv[0], NULL, 10);
+ dir = _strtol(argv[1], NULL, 10);
+
+ if(2 == argc)
+ {
+ /* get command */
+ ret = air_port_getFlowCtrl(0, port, dir, &fc_en);
+ if(ret == AIR_E_OK)
+ AIR_PRINT("Get Port%02d %s Flow Control %s\n", port, ((dir)?"RX":"TX"), ((fc_en)?"Enable":"Disable"));
+ else
+ AIR_PRINT("Get Flow Control Fail.\n");
+ }
+ else
+ {
+ /* set command */
+ fc_en = _strtol(argv[2], NULL, 10);
+
+ ret = air_port_setFlowCtrl(0, port, dir, fc_en);
+ if(ret == AIR_E_OK)
+ AIR_PRINT("Set Port%02d %s Flow Control %s\n", port, ((dir)?"RX":"TX"), ((fc_en)?"Enable":"Disable"));
+ else
+ AIR_PRINT("Set Flow Control Fail.\n");
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doL2Set(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(l2SetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doL2Get(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(l2GetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doL2Clear(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(l2ClearCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doL2Del(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(l2DelCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doL2Add(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(l2AddCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doL2(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(l2Cmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doAnMode(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T port = 0;
+ BOOL_T en = 0;
+
+ port = _strtol(argv[0], NULL, 10);
+
+ if(1 == argc)
+ {
+ /* port get anCap <port> */
+ ret = air_port_getAnMode(0, port, &en);
+ if(ret == AIR_E_OK)
+ AIR_PRINT("Get Port%02d Auto-Negotiation %s\n", port, ((en)?"Enabled":"Disabled"));
+ else
+ AIR_PRINT("Get Port%02d Auto-Negotiation Fail.\n", port);
+ }
+ else if(2 == argc)
+ {
+ /* "port set anMode <port> <en> */
+ en = _strtol(argv[1], NULL, 10);
+ ret = air_port_setAnMode(0, port, en);
+ if(ret == AIR_E_OK)
+ AIR_PRINT("Set Port%02d Auto-Negotiation Mode:%s\n", port, ((en)?"Enabled":"Disabled"));
+ else
+ AIR_PRINT("Set Port%02d Auto-Negotiation Fail.\n", port);
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doLocalAdv(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T port = 0;
+ AIR_AN_ADV_T adv;
+
+ memset(&adv, 0, sizeof(AIR_AN_ADV_T));
+ port = _strtol(argv[0], NULL, 10);
+
+ if(1 == argc)
+ {
+ /* port get localAdv <port> */
+ ret = air_port_getLocalAdvAbility(0, port, &adv);
+ AIR_PRINT("Get Port%02d Local Auto-Negotiation Advertisement: ", port);
+ if(AIR_E_OK != ret)
+ {
+ AIR_PRINT("Fail!\n");
+ }
+ }
+ else if(7 == argc)
+ {
+ /* port set localAdv <port> <10H> <10F> <100H> <100F> <1000F> <pause> */
+ adv.advCap10HDX = _strtol(argv[1], NULL, 0) & BIT(0);
+ adv.advCap10FDX = _strtol(argv[2], NULL, 0) & BIT(0);
+ adv.advCap100HDX = _strtol(argv[3], NULL, 0) & BIT(0);
+ adv.advCap100FDX = _strtol(argv[4], NULL, 0) & BIT(0);
+ adv.advCap1000FDX = _strtol(argv[5], NULL, 0) & BIT(0);
+ adv.advPause = _strtol(argv[6], NULL, 0) & BIT(0);
+ ret = air_port_setLocalAdvAbility(0, port, adv);
+ AIR_PRINT("Set Port%02d Local Auto-Negotiation Advertisement: ", port);
+ if(AIR_E_OK != ret)
+ {
+ AIR_PRINT("Fail!\n");
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("\n");
+ AIR_PRINT("\tAdvertise 10BASE-T Half Duplex: %s\n", (adv.advCap10HDX)?"Effective":"Not Effective" );
+ AIR_PRINT("\tAdvertise 10BASE-T Full Duplex: %s\n", (adv.advCap10FDX)?"Effective":"Not Effective" );
+ AIR_PRINT("\tAdvertise 100BASE-T Half Duplex: %s\n", (adv.advCap100HDX)?"Effective":"Not Effective" );
+ AIR_PRINT("\tAdvertise 100BASE-T Full Duplex: %s\n", (adv.advCap100FDX)?"Effective":"Not Effective" );
+ AIR_PRINT("\tAdvertise 1000BASE-T Full Duplex: %s\n", (adv.advCap1000FDX)?"Effective":"Not Effective" );
+ AIR_PRINT("\tAdvertise Asynchronous Pause: %s\n", (adv.advPause)?"Effective":"Not Effective" );
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doRemoteAdv(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T port = 0;
+ AIR_AN_ADV_T lp_adv;
+
+ memset(&lp_adv, 0, sizeof(AIR_AN_ADV_T));
+ port = _strtol(argv[0], NULL, 10);
+
+ if(1 == argc)
+ {
+ /* port get remoteAdv <port> */
+ ret = air_port_getRemoteAdvAbility(0, port, &lp_adv);
+ AIR_PRINT("Get Port%02d Remote Auto-Negotiation Advertisement: ", port);
+ if(AIR_E_OK != ret)
+ {
+ AIR_PRINT("Fail!\n");
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("\n");
+ AIR_PRINT("\tAdvertise 10BASE-T Half Duplex: %s\n", lp_adv.advCap10HDX?"Effective":"Not Effective" );
+ AIR_PRINT("\tAdvertise 10BASE-T Full Duplex: %s\n", lp_adv.advCap10FDX?"Effective":"Not Effective" );
+ AIR_PRINT("\tAdvertise 100BASE-T Half Duplex: %s\n", lp_adv.advCap100HDX?"Effective":"Not Effective" );
+ AIR_PRINT("\tAdvertise 100BASE-T Full Duplex: %s\n", lp_adv.advCap100FDX?"Effective":"Not Effective" );
+ AIR_PRINT("\tAdvertise 1000BASE-T Full Duplex: %s\n", (lp_adv.advCap1000FDX)?"Effective":"Not Effective" );
+ AIR_PRINT("\tAdvertise Asynchronous Pause: %s\n", (lp_adv.advPause)?"Effective":"Not Effective" );
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doPortSpeed(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T port = 0;
+ UI32_T speed = 0;
+
+ port = _strtol(argv[0], NULL, 10);
+
+ if(1 == argc)
+ {
+ /* port get speed <port> */
+ ret = air_port_getSpeed(0, port, &speed);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Get Port%02d Speed:", port);
+ }
+ else
+ {
+ AIR_PRINT("Get Port%02d Speed Fail!\n", port);
+ }
+ }
+ else if(2 == argc)
+ {
+ /* port set speed <port> <speed> */
+ speed = _strtol(argv[1], NULL, 10);
+ ret = air_port_setSpeed(0, port, speed);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Set Port%02d Speed:", port);
+ }
+ else
+ {
+ AIR_PRINT("Set Port%02d Speed Fail!\n", port);
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ if(ret == AIR_E_OK)
+ {
+ switch(speed)
+ {
+ case AIR_PORT_SPEED_10M:
+ AIR_PRINT(" 10 Mbps\n");
+ break;
+ case AIR_PORT_SPEED_100M:
+ AIR_PRINT(" 100 Mbps\n");
+ break;
+ case AIR_PORT_SPEED_1000M:
+ AIR_PRINT(" 1 Gbps\n");
+ break;
+ case AIR_PORT_SPEED_2500M:
+ AIR_PRINT(" 2.5 Gbps\n");
+ break;
+ default:
+ AIR_PRINT(" Reserved\n");
+ break;
+ }
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doPortDuplex(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T port = 0;
+ UI32_T duplex = 0;
+
+ port = _strtol(argv[0], NULL, 10);
+
+ if(1 == argc)
+ {
+ /* port get duplex <port> */
+ ret = air_port_getDuplex(0, port, &duplex);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Get Port%02d Duplex:%s\n", port, duplex?"Full":"Half");
+ }
+ else
+ {
+ AIR_PRINT("Get Port%02d Duplex Fail!\n", port);
+ }
+ }
+ else if(2 == argc)
+ {
+ /* port set duplex <port> <duplex> */
+ duplex = _strtol(argv[1], NULL, 10);
+ ret = air_port_setDuplex(0, port, duplex);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Set Port%02d Duplex:%s\n", port, duplex?"Full":"Half");
+ }
+ else
+ {
+ AIR_PRINT("Set Port%02d Duplex Fail!\n", port);
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doPortStatus(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T port = 0;
+ AIR_PORT_STATUS_T ps;
+
+ memset(&ps, 0, sizeof(AIR_PORT_STATUS_T));
+ port = _strtol(argv[0], NULL, 10);
+
+ if(1 == argc)
+ {
+ /* port get status <port> */
+ ret = air_port_getLink(0, port, &ps);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Get Port%02d Link-Status\n", port);
+ AIR_PRINT("\tLink: %s\n", ps.link?"Up":"Down");
+ AIR_PRINT("\tDuplex: %s\n", ps.duplex?"Full":"Half");
+ AIR_PRINT("\tSpeed: ");
+ switch(ps.speed)
+ {
+ case AIR_PORT_SPEED_10M:
+ AIR_PRINT("10 Mbps\n");
+ break;
+ case AIR_PORT_SPEED_100M:
+ AIR_PRINT("100 Mbps\n");
+ break;
+ case AIR_PORT_SPEED_1000M:
+ AIR_PRINT("1 Gbps\n");
+ break;
+ case AIR_PORT_SPEED_2500M:
+ AIR_PRINT("2.5 Gbps\n");
+ break;
+ default:
+ AIR_PRINT("Reserved\n");
+ break;
+ }
+ }
+ else
+ AIR_PRINT("Get Port%02d Link-Status Fail!", port);
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doPortBckPres(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T port = 0;
+ UI32_T bckPres = 0;
+
+ port = _strtol(argv[0], NULL, 10);
+
+ if(1 == argc)
+ {
+ /* port get bckPres <port> */
+ ret = air_port_getBckPres(0, port, &bckPres);
+ if(ret == AIR_E_OK)
+ AIR_PRINT("Get Port%02d BckPres:%s\n", port, bckPres?"Enabled":"Disabled");
+ else
+ AIR_PRINT("Get Port%02d BckPres Fail!\n", port);
+ }
+ else if(2 == argc)
+ {
+ /* port set bckPres <port> <bckPres> */
+ bckPres = _strtol(argv[1], NULL, 10);
+ ret = air_port_setBckPres(0, port, bckPres);
+ if(ret == AIR_E_OK)
+ AIR_PRINT("Set Port%02d BckPres:%s\n", port, bckPres?"Enabled":"Disabled");
+ else
+ AIR_PRINT("Set Port%02d BckPres Fail!\n", port);
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doPortPsMode(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T port = 0;
+ UI32_T mode = 0;
+ BOOL_T ls_en = 0;
+ BOOL_T eee_en = 0;
+
+ port = _strtol(argv[0], NULL, 10);
+
+ if(1 == argc)
+ {
+ /* port get psMode <port> */
+ ret = air_port_getPsMode(0, port, &mode);
+ AIR_PRINT("Get Port%02d Power-Saving: ", port);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Done\n");
+ }
+ else
+ {
+ AIR_PRINT("Fail!\n");
+ }
+ }
+ else if(3 == argc)
+ {
+ /* port set psMode <port> <ls> <eee> */
+ ls_en = _strtol(argv[1], NULL, 0);
+ eee_en = _strtol(argv[2], NULL, 0);
+ if(TRUE == ls_en)
+ {
+ mode |= AIR_PORT_PS_LINKSTATUS;
+ }
+ if(TRUE == eee_en)
+ {
+ mode |= AIR_PORT_PS_EEE;
+ }
+ ret = air_port_setPsMode(0, port, mode);
+ AIR_PRINT("Set Port%02d Power-Saving: ", port);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Done\n");
+ }
+ else
+ {
+ AIR_PRINT("Fail!\n");
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("\tLink status:%s\n", (mode & AIR_PORT_PS_LINKSTATUS)?"Enable":"Disable");
+ AIR_PRINT("\tEEE:%s\n", (mode & AIR_PORT_PS_EEE)?"Enable":"Disable");
+ }
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doPortSmtSpdDwn(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T port = 0;
+ UI32_T state = 0;
+ UI32_T retry = 0;
+
+ port = _strtol(argv[0], NULL, 10);
+
+ if(1 == argc)
+ {
+ /* port get smtSpdDwn <port> */
+ ret = air_port_getSmtSpdDwn(0, port, &state, &retry);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Get Port%02d Smart Speed Down: %s\n", port, state?"Enabled":"Disabled");
+ AIR_PRINT("Get Port%02d Retry Time: %d\n", port, retry + 2);
+ }
+ else
+ AIR_PRINT("Get Port%02d Smart-SpeedDown Fail!\n", port);
+ }
+ else if(3 == argc)
+ {
+ /* port set smtSpdDwn <port> <en> <retry> */
+ state = _strtol(argv[1], NULL, 10);
+ retry = _strtol(argv[2], NULL, 10);
+ if(retry >= 2)
+ {
+ ret = air_port_setSmtSpdDwn(0, port, state, retry - 2);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Set Port%02d Smart Speed Down: %s\n", port, state?"Enabled":"Disabled");
+ AIR_PRINT("Set Port%02d Retry Time: %d\n", port, retry);
+ }
+ else
+ AIR_PRINT("Set Port%02d Smart-SpeedDown Fail!\n", port);
+ }
+ else
+ {
+ ret = AIR_E_BAD_PARAMETER;
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doPortSpTag(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T port = 0;
+ BOOL_T sptag_en = FALSE;
+
+ port = _strtol(argv[0], NULL, 10);
+
+ if(1 == argc)
+ {
+ /* port get spTag <port> */
+ ret = air_port_getSpTag(0, port, &sptag_en);
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("Get Port%02d Special Tag %s\n", port, ((sptag_en)?"Enabled":"Disabled"));
+ }
+ else
+ {
+ AIR_PRINT("Get Port%02d Special Tag Fail.\n", port);
+ }
+ }
+ else if(2 == argc)
+ {
+ /* port set spTag <port> <en> */
+ sptag_en = _strtol(argv[1], NULL, 10);
+ ret = air_port_setSpTag(0, port, sptag_en);
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("Set Port%02d Special Tag:%s\n", port, ((sptag_en)?"Enabled":"Disabled"));
+ }
+ else
+ {
+ AIR_PRINT("Set Port%02d Special Tag Fail.\n", port);
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doPortEnable(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T port = 0;
+ UI32_T state = 0;
+
+ port = _strtol(argv[0], NULL, 10);
+
+ if(1 == argc)
+ {
+ /* port get enable <port> */
+ ret = air_port_getEnable(0, port, &state);
+ if(ret == AIR_E_OK)
+ AIR_PRINT("Get Port%02d State:%s\n", port, state?"Enable":"Disable");
+ else
+ AIR_PRINT("Get Port%02d State Fail!\n", port);
+ }
+ else if(2 == argc)
+ {
+ /* port set enable <port> <en> */
+ state = _strtol(argv[1], NULL, 10);
+ ret = air_port_setEnable(0, port, state);
+ if(ret == AIR_E_OK)
+ AIR_PRINT("Set Port%02d State:%s\n", port, state?"Enable":"Disable");
+ else
+ AIR_PRINT("Set Port%02d State Fail!\n", port);
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doPort5GBaseRMode(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+
+ if(0 == argc)
+ {
+ /* port set 5GBaseRMode */
+ ret = air_port_set5GBaseRModeEn(0);
+ if(ret == AIR_E_OK)
+ AIR_PRINT("Set Port05 Mode: 5GBase-R\n");
+ else
+ AIR_PRINT("Set Port05 HSGMII Mode Fail.\n");
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doPortHsgmiiMode(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+
+ if(0 == argc)
+ {
+ /* port set hsgmiiMode */
+ ret = air_port_setHsgmiiModeEn(0);
+ if(ret == AIR_E_OK)
+ AIR_PRINT("Set Port05 Mode: HSGMII\n");
+ else
+ AIR_PRINT("Set Port05 HSGMII Mode Fail.\n");
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doPortSgmiiMode(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T mode = 0;
+ UI32_T speed = 0;
+
+ if(2 == argc)
+ {
+ /* port set sgmiiMode <mode(0:AN,1:Force)> <speed> */
+ mode = _strtol(argv[0], NULL, 10);
+ speed = _strtol(argv[1], NULL, 10);
+ ret = air_port_setSgmiiMode(0, mode, speed);
+ if(ret == AIR_E_OK)
+ AIR_PRINT("Set Port05 SGMII Mode:%s\nIf in Force Mode, speed:", mode?"Force":"AN");
+ else
+ AIR_PRINT("Set Port05 SGMII Mode Fail.\n");
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ if(ret == AIR_E_OK)
+ {
+ switch(speed)
+ {
+ case AIR_PORT_SPEED_10M:
+ AIR_PRINT(" 10 Mbps\n");
+ break;
+ case AIR_PORT_SPEED_100M:
+ AIR_PRINT(" 100 Mbps\n");
+ break;
+ case AIR_PORT_SPEED_1000M:
+ AIR_PRINT(" 1 Gbps\n");
+ break;
+ default:
+ AIR_PRINT(" Reserved\n");
+ break;
+ }
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doPortRmiiMode(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T speed = 0;
+
+ if(1 == argc)
+ {
+ /* port set rmiiMode <speed> */
+ speed = _strtol(argv[0], NULL, 10);
+ ret = air_port_setRmiiMode(0, speed);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Set Port05 RMII Mode Speed:");
+ }
+ else
+ {
+ AIR_PRINT("Set Port05 RMII Mode Fail!\n");
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ if(ret == AIR_E_OK)
+ {
+ switch(speed)
+ {
+ case AIR_PORT_SPEED_10M:
+ AIR_PRINT(" 10 Mbps\n");
+ break;
+ case AIR_PORT_SPEED_100M:
+ AIR_PRINT(" 100 Mbps\n");
+ break;
+ default:
+ AIR_PRINT(" Reserved\n");
+ break;
+ }
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doPortRgmiiMode(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T speed = 0;
+
+ if(1 == argc)
+ {
+ /* port set rgmiiMode <speed> */
+ speed = _strtol(argv[0], NULL, 10);
+ ret = air_port_setRgmiiMode(0, speed);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Set Port05 RGMII Mode Speed:");
+ }
+ else
+ {
+ AIR_PRINT("Set Port05 RGMII Mode Fail!\n");
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ if(ret == AIR_E_OK)
+ {
+ switch(speed)
+ {
+ case AIR_PORT_SPEED_10M:
+ AIR_PRINT(" 10 Mbps\n");
+ break;
+ case AIR_PORT_SPEED_100M:
+ AIR_PRINT(" 100 Mbps\n");
+ break;
+ case AIR_PORT_SPEED_1000M:
+ AIR_PRINT(" 1 Gbps\n");
+ break;
+ default:
+ AIR_PRINT(" Reserved\n");
+ break;
+ }
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doSptagEn(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T port = 0;
+ BOOL_T sp_en = FALSE;
+
+ port = _strtol(argv[0], NULL, 10);
+ if (2 == argc)
+ {
+ sp_en = _strtol(argv[1], NULL, 10);
+ ret = air_sptag_setState(0,port,sp_en);
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("set port %d SpTag state %s sucess\n", port,sp_en?"Enable":"Disable");
+ }
+ else
+ {
+ AIR_PRINT("set port %d SpTag state %s fail\n", port,sp_en?"Enable":"Disable");
+ }
+ }
+ else if(1 == argc)
+ {
+ air_sptag_getState(0,port,&sp_en);
+ AIR_PRINT("get port %d SpTag state: %s \n", port,sp_en?"Enable":"Disable");
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doSptagMode(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T port = 0;
+ BOOL_T sp_mode = FALSE;
+
+
+ port = _strtol(argv[0], NULL, 10);
+ if (2 == argc)
+ {
+ sp_mode = _strtol(argv[1], NULL, 10);
+ ret = air_sptag_setMode(0,port,sp_mode);
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("set port %d SpTag Mode %s sucess\n", port,sp_mode?"replace":"insert");
+ }
+ else
+ {
+ AIR_PRINT("set port %d SpTag state %s fail\n", port,sp_mode?"replace":"insert");
+ }
+ }
+ else if(1 == argc)
+ {
+ air_sptag_getMode(0,port,&sp_mode);
+ AIR_PRINT("get port %d SpTag state: %s \n", port,sp_mode?"replace":"insert");
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doSptagDecode(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ AIR_SPTAG_RX_PARA_T sptag_rx = {0};
+ UI8_T buf[AIR_STAG_BUF_LEN] = {0};
+ UI32_T len = AIR_STAG_BUF_LEN, i = 0;
+
+ if (4 == argc)
+ {
+ for(i = 0; i < len; i++)
+ {
+ buf[i] = _strtoul(argv[i], NULL, 16);
+ }
+
+ ret = air_sptag_decodeRx(0, buf, len, &sptag_rx);
+ if (AIR_E_OK != ret)
+ {
+ AIR_PRINT("SpTag decode fail\n");
+ return ret;
+ }
+
+ AIR_PRINT("SpTag decode success:\n");
+ AIR_PRINT("RSN : %s\n", _sptag_pt[sptag_rx.rsn]);
+ AIR_PRINT("VPM : %s\n", _sptag_vpm[sptag_rx.vpm]);
+ AIR_PRINT("SPN : %d\n", sptag_rx.spn);
+ AIR_PRINT("PRI : %d\n", sptag_rx.pri);
+ AIR_PRINT("CFI : %d\n", sptag_rx.cfi);
+ AIR_PRINT("VID : %d\n", sptag_rx.vid);
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doSptagEncode(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ AIR_STAG_TX_PARA_T sptag_tx = {0};
+ C8_T *token = NULL;
+ UI8_T buf[AIR_STAG_BUF_LEN] = {0};
+ UI32_T len = AIR_STAG_BUF_LEN;
+ char str[128] = {'\0'};
+ UI32_T data = 0;
+ AIR_STAG_MODE_T mode = AIR_STAG_MODE_LAST;
+
+ if (7 == argc)
+ {
+ if(_strcmp(argv[0],"mode=replace") == 0)
+ mode = AIR_STAG_MODE_REPLACE;
+ else if(_strcmp(argv[0],"mode=insert") == 0)
+ mode = AIR_STAG_MODE_INSERT;
+ else
+ printf("mode is wrong!!");
+
+ if(_strcmp(argv[1],"opc=portmap") == 0)
+ sptag_tx.opc = AIR_STAG_OPC_PORTMAP;
+ else if(_strcmp(argv[1],"opc=portid") == 0)
+ sptag_tx.opc = AIR_STAG_OPC_PORTID;
+ else if(_strcmp(argv[1],"opc=lookup") == 0)
+ sptag_tx.opc = AIR_STAG_OPC_LOOKUP;
+ else
+ printf("opc is wrong!!");
+
+ token = _strtok(argv[2], "=", &argv[2]);
+ if(_strcmp(token,"dp") != 0) {
+ AIR_PRINT("Bad parameter\r\n");
+ } else {
+ if ((token = _strtok(argv[2], "=", &argv[2]))) {
+ data = _strtoul(token, NULL, 16);
+ sptag_tx.pbm = data;
+ AIR_PRINT("sptag_tx.pbm %x\n",sptag_tx.pbm);
+ }
+ }
+
+ if(_strcmp(argv[3],"vpm=untagged") == 0)
+ sptag_tx.vpm = AIR_STAG_VPM_UNTAG;
+ else if(_strcmp(argv[3],"vpm=8100") == 0)
+ sptag_tx.vpm = AIR_STAG_VPM_TPID_8100;
+ else if(_strcmp(argv[3],"vpm=88a8") == 0)
+ sptag_tx.vpm = AIR_STAG_VPM_TPID_88A8;
+ else
+ printf("vpm is wrong!!");
+
+ token = _strtok(argv[4], "=", &argv[4]);
+ if(_strcmp(token, "pri") != 0) {
+ AIR_PRINT("Bad parameter\r\n");
+ } else {
+ if ((token = _strtok(argv[4], "=", &argv[4]))) {
+ data = _strtoul(token, NULL, 0);
+ sptag_tx.pri = data;
+ AIR_PRINT("sptag_tx.pri %d\n",sptag_tx.pri);
+ }
+ }
+
+ token = _strtok(argv[5], "=", &argv[5]);
+ if(_strcmp(token, "cfi") != 0) {
+ AIR_PRINT("Bad parameter\r\n");
+ } else {
+ if ((token = _strtok(argv[5], "=", &argv[5]))) {
+ data = _strtoul(token, NULL, 0);
+ sptag_tx.cfi = data;
+ AIR_PRINT("sptag_tx.cfi %d\n",sptag_tx.cfi);
+ }
+ }
+
+ token = _strtok(argv[6], "=", &argv[6]);
+ if(_strcmp(token, "vid") != 0) {
+ AIR_PRINT("Bad parameter\r\n");
+ } else {
+ if ((token = _strtok(argv[6], "=", &argv[6]))) {
+ data = _strtoul(token, NULL, 0);
+ sptag_tx.vid = data;
+ AIR_PRINT("sptag_tx.vid %d\n",sptag_tx.vid);
+ }
+ }
+
+ ret = air_sptag_encodeTx(0,mode, &sptag_tx, (UI8_T *)&buf, &len);
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("SpTag encode sucess, returned len=%d\n", len);
+ AIR_PRINT("Encoded SpTag: %02x %02x %02x %02x\n", buf[0], buf[1], buf[2], buf[3]);
+ }
+ else
+ {
+ AIR_PRINT("SpTag encode fail\n");
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doSptag(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(sptagCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doL2Dump(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(l2DumpCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doMacAddr(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ AIR_MAC_ENTRY_T mt;
+ UI32_T fwd = 0;
+
+ memset(&mt, 0, sizeof(AIR_MAC_ENTRY_T));
+
+ if(0 == argc)
+ {
+ /* l2 clear mac */
+ ret = air_l2_clearMacAddr(0);
+ if(ret == AIR_E_OK)
+ AIR_PRINT("Clear MAC Address Table Done.\n");
+ else
+ AIR_PRINT("Clear MAC Address Table Fail.\n");
+ }
+ else if(3 == argc)
+ {
+ /* l2 del mac <mac(12'hex)> { vid <vid(0..4095)> | fid <fid(0..15)> } */
+ ret = _str2mac(argv[0], (C8_T *)mt.mac);
+ if(ret != AIR_E_OK)
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return ret;
+ }
+
+ /* check argument 1 */
+ if(FALSE == _strcmp(argv[1], "vid"))
+ {
+ /* get mac entry by MAC address & vid */
+ mt.cvid = _strtoul(argv[2], NULL, 0);
+ mt.flags |= AIR_L2_MAC_ENTRY_FLAGS_IVL;
+ AIR_PRINT("Get MAC Address:" MAC_STR " with vid:%u", MAC2STR(mt.mac), mt.cvid);
+ }
+ else if(FALSE == _strcmp(argv[1], "fid"))
+ {
+ /* get mac entry by MAC address & fid */
+ mt.fid = _strtoul(argv[2], NULL, 0);
+ AIR_PRINT("Get MAC Address:" MAC_STR " with fid:%u", MAC2STR(mt.mac), mt.fid);
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+ ret = air_l2_delMacAddr(0, &mt);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT(" Done.\n");
+ }
+ else
+ AIR_PRINT("\n Fail!\n");
+ }
+ else if(7 == argc)
+ {
+ /* l2 add mac <static(0:dynamic,1:static)> <unauth(0:auth,1:unauth)> <mac(12'hex)> <portlist(uintlist)> [ vid <vid(0..4095)> | fid <fid(0..15)> ] <src_mac_forward=(0:default,1:cpu-include,2:cpu-exclude,3:cpu-only,4:drop)> */
+ if(argv[0])
+ mt.flags |= AIR_L2_MAC_ENTRY_FLAGS_STATIC;
+
+ if(argv[1])
+ mt.flags |= AIR_L2_MAC_ENTRY_FLAGS_UNAUTH;
+
+ ret = _str2mac(argv[2], (C8_T *)mt.mac);
+ if(ret != AIR_E_OK)
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return ret;
+ }
+
+ ret = _portListStr2Ary(argv[3], mt.port_bitmap, 1);
+ if(ret != AIR_E_OK)
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return ret;
+ }
+
+ /* check argument fid or vid */
+ if(FALSE == _strcmp(argv[4], "vid"))
+ {
+ /* get mac entry by MAC address & vid */
+ mt.cvid = _strtoul(argv[5], NULL, 0);
+ mt.flags |= AIR_L2_MAC_ENTRY_FLAGS_IVL;
+ }
+ else if(FALSE == _strcmp(argv[4], "fid"))
+ {
+ /* get mac entry by MAC address & fid */
+ mt.fid = _strtoul(argv[5], NULL, 0);
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+ fwd = _strtoul(argv[6], NULL, 0);
+ if(0 == fwd)
+ mt.sa_fwd = AIR_L2_FWD_CTRL_DEFAULT;
+ else if(1 == fwd)
+ mt.sa_fwd = AIR_L2_FWD_CTRL_CPU_INCLUDE;
+ else if(2 == fwd)
+ mt.sa_fwd = AIR_L2_FWD_CTRL_CPU_EXCLUDE;
+ else if(3 == fwd)
+ mt.sa_fwd = AIR_L2_FWD_CTRL_CPU_ONLY;
+ else if(4 == fwd)
+ mt.sa_fwd = AIR_L2_FWD_CTRL_DROP;
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+ ret = air_l2_addMacAddr(0, &mt);
+ AIR_PRINT("Add MAC Address:" MAC_STR, MAC2STR(mt.mac));
+ if(ret == AIR_E_OK)
+ AIR_PRINT(" Done.\n");
+ else
+ AIR_PRINT(" Fail.\n");
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+_printMacEntry(
+ AIR_MAC_ENTRY_T *mt,
+ UI32_T age_unit,
+ UI8_T count,
+ UI8_T title)
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ I32_T i = 0, j = 0;
+ UI8_T first = 0;
+ UI8_T find = 0;
+ if(title)
+ {
+ AIR_PRINT("%-6s%-15s%-5s%-5s%-5s%-10s%-10s%-6s\n",
+ "unit",
+ "mac",
+ "ivl",
+ "vid",
+ "fid",
+ "age-time",
+ "forward",
+ "port");
+ return ret;
+ }
+ for(i = 0; i < count; i++)
+ {
+ AIR_PRINT("%-6d", age_unit);
+ AIR_PRINT(MAC_STR, MAC2STR(mt[i].mac));
+ AIR_PRINT("...");
+ if(mt[i].flags & AIR_L2_MAC_ENTRY_FLAGS_IVL)
+ {
+ AIR_PRINT("%-3s..", "ivl");
+ AIR_PRINT("%-5d", mt[i].cvid);
+ AIR_PRINT("%-5s", ".....");
+ }
+ else
+ {
+ AIR_PRINT("%-3s..", "svl");
+ AIR_PRINT("%-5s", ".....");
+ AIR_PRINT("%-5d", mt[i].fid);
+ }
+ if(mt[i].flags & AIR_L2_MAC_ENTRY_FLAGS_STATIC)
+ {
+ AIR_PRINT("%-10s.", "static");
+ }
+ else
+ {
+ AIR_PRINT("%d sec..", mt[i].timer);
+ }
+ AIR_PRINT("%-10s", _air_mac_address_forward_control_string[mt[i].sa_fwd]);
+ first = 0;
+ find = 0;
+ for (j = (AIR_MAX_NUM_OF_PORTS - 1); j >= 0; j--)
+ {
+ if((mt[i].port_bitmap[0]) & (1 << j))
+ {
+ first = j;
+ find = 1;
+ break;
+ }
+ }
+ if(find)
+ {
+ for (j = 0; j < AIR_MAX_NUM_OF_PORTS; j++)
+ {
+ if((mt[i].port_bitmap[0]) & (1 << j))
+ {
+ if(j == first)
+ AIR_PRINT("%-2d", j);
+ else
+ AIR_PRINT("%-2d,", j);
+ }
+ }
+ }
+ else
+ AIR_PRINT("no dst port");
+ AIR_PRINT("\n");
+ }
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doGetMacAddr(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI8_T count = 0;
+ AIR_MAC_ENTRY_T * ptr_mt;
+
+ if(3 == argc)
+ {
+ ptr_mt = AIR_MALLOC(sizeof(AIR_MAC_ENTRY_T));
+ if (NULL == ptr_mt)
+ {
+ AIR_PRINT("***Error***, allocate memory fail\n");
+ return AIR_E_OTHERS;
+ }
+ memset(ptr_mt, 0, sizeof(AIR_MAC_ENTRY_T));
+ /* l2 get mac <mac(12'hex)> { vid <vid(0..4095)> | fid <fid(0..15)> } */
+ ret = _str2mac(argv[0], (C8_T *)ptr_mt->mac);
+ if(ret != AIR_E_OK)
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ AIR_FREE(ptr_mt);
+ return ret;
+ }
+
+ /* check argument 1 */
+ if(FALSE == _strcmp(argv[1], "vid"))
+ {
+ /* get mac entry by MAC address & vid */
+ ptr_mt->cvid = _strtoul(argv[2], NULL, 0);
+ ptr_mt->flags |= AIR_L2_MAC_ENTRY_FLAGS_IVL;
+ AIR_PRINT("Get MAC Address:" MAC_STR " with vid:%u", MAC2STR(ptr_mt->mac), ptr_mt->cvid);
+ }
+ else if(FALSE == _strcmp(argv[1], "fid"))
+ {
+ /* get mac entry by MAC address & fid */
+ ptr_mt->fid = _strtoul(argv[2], NULL, 0);
+ AIR_PRINT("Get MAC Address:" MAC_STR " with fid:%u", MAC2STR(ptr_mt->mac), ptr_mt->fid);
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ AIR_FREE(ptr_mt);
+ return AIR_E_BAD_PARAMETER;
+ }
+ ret = air_l2_getMacAddr(0, &count, ptr_mt);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT(" Done.\n");
+ _printMacEntry(ptr_mt, 0, 1, TRUE);
+ _printMacEntry(ptr_mt, 0, 1, FALSE);
+ }
+ else
+ AIR_PRINT("\n Not found!\n");
+ AIR_FREE(ptr_mt);
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doMacAddrAgeOut(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T time = 0;
+ if(0 == argc)
+ {
+ /* l2 get macAddrAgeOut */
+ ret = air_l2_getMacAddrAgeOut(0, &time);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Get MAC Address Age Out Time Done.\n");
+ }
+ else
+ {
+ AIR_PRINT("Get MAC Address Age Out Time Fail.\n");
+ }
+ }
+ else if(1 == argc)
+ {
+ /* l2 set macAddrAgeOut <time(1, 1000000)> */
+ time = _strtoul(argv[0], NULL, 0);
+ if(time < 1 || time > 1000000)
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+ ret = air_l2_setMacAddrAgeOut(0, time);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Set MAC Address Age Out Time Done.\n");
+ }
+ else
+ {
+ AIR_PRINT("Set MAC Address Age Out Time Fail.\n");
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("MAC Address Age Out Time: %u seconds.\n", time);
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doDumpMacAddr(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ AIR_MAC_ENTRY_T *ptr_mt;
+ UI8_T count = 0;
+ UI32_T bucket_size = 0;
+ UI32_T total_count = 0;
+
+ if(0 != argc)
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+ /* get unit of aging time */
+ ret = air_l2_getMacBucketSize(0, &bucket_size);
+ if(ret != AIR_E_OK)
+ {
+ AIR_PRINT("Get MAC Age Time Fail!\n");
+ return ret;
+ }
+ ptr_mt = AIR_MALLOC(sizeof(AIR_MAC_ENTRY_T) * bucket_size);
+ if (NULL == ptr_mt)
+ {
+ AIR_PRINT("***Error***, allocate memory fail\n");
+ return AIR_E_OTHERS;
+ }
+ memset(ptr_mt, 0, sizeof(AIR_MAC_ENTRY_T) * bucket_size);
+ _printMacEntry(ptr_mt, 0, count, TRUE);
+ /* get 1st entry of MAC table */
+ ret = air_l2_getMacAddr(0, &count, ptr_mt);
+ switch(ret)
+ {
+ case AIR_E_ENTRY_NOT_FOUND:
+ AIR_FREE(ptr_mt);
+ AIR_PRINT("Not Found!\n");
+ return ret;
+ case AIR_E_TIMEOUT:
+ AIR_FREE(ptr_mt);
+ AIR_PRINT("Time Out!\n");
+ return ret;
+ case AIR_E_BAD_PARAMETER:
+ AIR_FREE(ptr_mt);
+ AIR_PRINT("Bad Parameter!\n");
+ return ret;
+ default:
+ break;
+ }
+ total_count += count;
+ _printMacEntry(ptr_mt, 0, count, FALSE);
+
+ /* get other entries of MAC table */
+ while(1)
+ {
+ memset(ptr_mt, 0, sizeof(AIR_MAC_ENTRY_T) * bucket_size);
+ ret = air_l2_getNextMacAddr(0, &count, ptr_mt);
+ if(AIR_E_OK != ret)
+ {
+ break;
+ }
+ total_count += count;
+ _printMacEntry(ptr_mt, 0, count, FALSE);
+ }
+ switch(ret)
+ {
+ case AIR_E_TIMEOUT:
+ AIR_PRINT("Time Out!\n");
+ break;
+ case AIR_E_BAD_PARAMETER:
+ AIR_PRINT("Bad Parameter!\n");
+ break;
+ default:
+ AIR_PRINT("Found %u %s\n", total_count, (total_count>1)?"entries":"entry");
+ break;
+ }
+ AIR_FREE(ptr_mt);
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doLagMember(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T portrunk_index = 0, member_index = 0, member_enable = 0, port_index = 0, i = 0;
+ AIR_LAG_PTGINFO_T member;
+ memset(&member,0,sizeof(AIR_LAG_PTGINFO_T));
+
+ if(4 == argc)
+ {
+ /* lag set member <port trunk index> <member index> <member enable> <port_index>*/
+ portrunk_index = _strtol(argv[0], NULL, 10);
+ member_index = _strtol(argv[1], NULL, 10);
+ member_enable = _strtol(argv[2], NULL, 10);
+ port_index = _strtol(argv[3], NULL, 10);
+ ret = air_lag_setMember(0, portrunk_index, member_index, member_enable,port_index);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Set port trunk index %d member_index:%d member_enable:%d, port_index:%d ok.\n", portrunk_index, member_index, member_enable,port_index);
+ }
+ else
+ {
+ AIR_PRINT("Set port trunk index %d member_index:%d member_enable:%d, port_index:%d fail.\n", portrunk_index, member_index, member_enable,port_index);
+ }
+ memset(&member,0,sizeof(member));
+ air_lag_getMember(0, portrunk_index, &member);
+ if(! member.csr_gp_enable[0])
+ {
+ AIR_PRINT("\r\n!!!!!!!!!Port trunk index %d member_index:0 must be set,or else have taffic issues.\n", portrunk_index);
+ }
+ }
+ else if(1 == argc)
+ {
+ portrunk_index = _strtol(argv[0], NULL, 10);
+
+ /* lag get member <port> */
+ memset(&member,0,sizeof(member));
+ ret = air_lag_getMember(0, portrunk_index, &member);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Get port trunk %u member:\n", portrunk_index);
+ for(i = 0; i < AIR_LAG_MAX_MEM_NUM; i++)
+ {
+ if(member.csr_gp_enable[i])
+ AIR_PRINT("port %d \r\n", member.csr_gp_port[i]);
+ }
+ AIR_PRINT("\r\n");
+ }
+ else
+ {
+ AIR_PRINT("Get port trunk:%u Member Fail.\n", portrunk_index);
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+
+static AIR_ERROR_NO_T
+doLagDstInfo(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ AIR_LAG_DISTINFO_T dstInfo;
+
+ memset(&dstInfo, 0, sizeof(AIR_LAG_DISTINFO_T));
+ if(7 == argc)
+ {
+ /* lag set dstInfo <sp> <sa> <da> <sip> <dip> <sport> <dport> */
+ dstInfo.sp = _strtol(argv[0], NULL, 10) & BIT(0);
+ dstInfo.sa = _strtol(argv[1], NULL, 10) & BIT(0);
+ dstInfo.da = _strtol(argv[2], NULL, 10) & BIT(0);
+ dstInfo.sip = _strtol(argv[3], NULL, 10) & BIT(0);
+ dstInfo.dip = _strtol(argv[4], NULL, 10) & BIT(0);
+ dstInfo.sport = _strtol(argv[5], NULL, 10) & BIT(0);
+ dstInfo.dport = _strtol(argv[6], NULL, 10) & BIT(0);
+ ret = air_lag_setDstInfo(0, dstInfo);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Set LAG packet distrubution.\n");
+ }
+ else
+ {
+ AIR_PRINT("Set LAG packet distrubution Fail.\n");
+ }
+ }
+ else if(0 == argc)
+ {
+ /* lag get dstInfo */
+ ret = air_lag_getDstInfo(0, &dstInfo);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Get LAG packet distrubution:\n");
+ }
+ else
+ {
+ AIR_PRINT("Get LAG packet distrubution Fail.\n");
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("%-5s|%-5s|%-5s|%-5s|%-5s|%-5s|%-5s\n",
+ "SP", "SA", "DA", "SIP", "DIP", "SPORT", "DPORT");
+ AIR_PRINT("%-5s|%-5s|%-5s|%-5s|%-5s|%-5s|%-5s\n",
+ (dstInfo.sp)?"En":"Dis",
+ (dstInfo.sa)?"En":"Dis",
+ (dstInfo.da)?"En":"Dis",
+ (dstInfo.sip)?"En":"Dis",
+ (dstInfo.dip)?"En":"Dis",
+ (dstInfo.sport)?"En":"Dis",
+ (dstInfo.dport)?"En":"Dis");
+ }
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doLagHashtype(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T hashtype = 0;
+
+ if(1 == argc)
+ {
+ hashtype = _strtol(argv[0], NULL, 10);
+ ret = air_lag_sethashtype(0, hashtype);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Set LAG hashtype Ok.\n");
+ }
+ else
+ {
+ AIR_PRINT("Set LAG hashtype Fail.\n");
+ }
+ }
+ else if(0 == argc)
+ {
+ /* lag get dstInfo */
+ ret = air_lag_gethashtype(0, &hashtype);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Get LAG hashtype:\n");
+ }
+ else
+ {
+ AIR_PRINT("Get LLAG hashtype Fail.\n");
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+ if(ret == AIR_E_OK)
+ {
+ switch (hashtype)
+ {
+ case 0:
+ AIR_PRINT("hashtype:crc32lsb.\n");
+ break;
+ case 1:
+ AIR_PRINT("hashtype:crc32msb.\n");
+ break;
+ case 2:
+ AIR_PRINT("hashtype:crc16.\n");
+ break;
+ case 3:
+ AIR_PRINT("hashtype:xor4.\n");
+ break;
+ default:
+ AIR_PRINT("wrong hashtype:%d.\n",hashtype);
+ }
+
+ }
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doLagPtseed(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T ptseed = 0;
+
+ if(1 == argc)
+ {
+ ptseed = _strtol(argv[0], NULL, 16);
+ ret = air_lag_setPTSeed(0, ptseed);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Set LAG Port Seed:%x(hex) ok\n",ptseed);
+ }
+ else
+ {
+ AIR_PRINT("Set LAG Port Seed:%x(hex) fail\n",ptseed);
+ }
+ }
+ else if(0 == argc)
+ {
+ /* lag get seed */
+ ret = air_lag_getPTSeed(0, &ptseed);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Get port trunk seed: %x(hex)\n",ptseed);
+ }
+ else
+ {
+ AIR_PRINT("Get port trunk seed Fail.\n");
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doLagSpsel(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T port = 0;
+ UI32_T state = 0;
+
+ if(1 == argc)
+ {
+ /* lag set spsel <state> */
+ state = _strtol(argv[0], NULL, 10);
+ ret = air_lag_setSpSel(0,state);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Set source port compare function:%s.\n", (state)?"Enabled":"Disabled");
+ }
+ else
+ {
+ AIR_PRINT("Set source port compare function Fail.\n");
+ }
+ }
+ else if(0 == argc)
+ {
+ /* lag get spsel*/
+ ret = air_lag_getSpSel(0, &state);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Get source port compare function:%s.\n", (state)?"Enabled":"Disabled");
+ }
+ else
+ {
+ AIR_PRINT("Get source port compare function Fail.\n");
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+
+static AIR_ERROR_NO_T
+doLagState(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T port = 0;
+ UI32_T state = 0;
+
+ if(1 == argc)
+ {
+ /* lag set state <state> */
+ state = _strtol(argv[0], NULL, 10);
+ ret = air_lag_set_ptgc_state(0,state);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Set LAG Port Trunk State:%s.\n", (state)?"Enabled":"Disabled");
+ }
+ else
+ {
+ AIR_PRINT("Set LAG Port Trunk State Fail.\n");
+ }
+ }
+ else if(0 == argc)
+ {
+ /* lag get state*/
+ ret = air_lag_get_ptgc_state(0, &state);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Get LAG Port Trunk State:%s.\n", (state)?"Enabled":"Disabled");
+ }
+ else
+ {
+ AIR_PRINT("Get LAG Port Trunk State Fail.\n");
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doLagGet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(lagGetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doLagSet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(lagSetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doLag(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(lagCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doStpPortstate(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T port = 0;
+ UI32_T fid = 0;
+ UI32_T state = 0;
+
+ port = _strtol(argv[0], NULL, 10);
+ fid = _strtol(argv[1], NULL, 10);
+ if(3 == argc)
+ {
+ /* stp set portstate <port> <fid(0..15)> <state> */
+ state = _strtol(argv[2], NULL, 10);
+ ret = air_stp_setPortstate(0, port, fid, state);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Set STP Port:%u FID:%u State:", port, fid);
+ switch(state)
+ {
+ case AIR_STP_STATE_DISABLE:
+ AIR_PRINT("Disable(STP) / Discard(RSTP).\n");
+ break;
+ case AIR_STP_STATE_LISTEN:
+ AIR_PRINT("Listening(STP) / Discard(RSTP).\n");
+ break;
+ case AIR_STP_STATE_LEARN:
+ AIR_PRINT("Learning(STP) / Learning(RSTP).\n");
+ break;
+ case AIR_STP_STATE_FORWARD:
+ AIR_PRINT("Forwarding(STP) / Forwarding(RSTP).\n");
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ AIR_PRINT("Set STP Port:%u FID:%u State Fail.", port, fid);
+ }
+ }
+ else if(2 == argc)
+ {
+ /* stp get portstate <port> <fid(0..15)> */
+ ret = air_stp_getPortstate(0, port, fid, &state);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Get STP Port:%u FID:%u State:", port, fid);
+ switch(state)
+ {
+ case AIR_STP_STATE_DISABLE:
+ AIR_PRINT("Disable(STP) / Discard(RSTP).\n");
+ break;
+ case AIR_STP_STATE_LISTEN:
+ AIR_PRINT("Listening(STP) / Discard(RSTP).\n");
+ break;
+ case AIR_STP_STATE_LEARN:
+ AIR_PRINT("Learning(STP) / Learning(RSTP).\n");
+ break;
+ case AIR_STP_STATE_FORWARD:
+ AIR_PRINT("Forwarding(STP) / Forwarding(RSTP).\n");
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ AIR_PRINT("Get STP Port:%u FID:%u State Fail.", port, fid);
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doStpGet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(stpGetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doStpSet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(stpSetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doStp(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(stpCmds, argc, argv);
+}
+
+static void
+_mir_printPortList(UI32_T * mt)
+{
+ I8_T j = 0;
+ UI8_T first = 0;
+ UI8_T find = 0;
+ for(j = (AIR_MAX_NUM_OF_PORTS - 1); j >= 0; j--)
+ {
+ if((*mt) & (1 << j))
+ {
+ first = j;
+ find = 1;
+ break;
+ }
+ }
+ if(find)
+ {
+ for(j = 0; j < AIR_MAX_NUM_OF_PORTS; j++)
+ {
+ if((*mt) & (1 << j))
+ {
+ if(j == first)
+ AIR_PRINT("%-2d", j);
+ else
+ AIR_PRINT("%-2d,", j);
+ }
+ }
+ }
+ else
+ AIR_PRINT("NULL");
+ AIR_PRINT("\n");
+}
+
+static void
+_mir_printSrcPortList(
+ const UI32_T unit,
+ const UI32_T sessionid)
+{
+ I8_T i = 0;
+ AIR_MIR_SESSION_T session;
+ AIR_PORT_BITMAP_T txPbm = {0}, rxPbm = {0};
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
+ {
+ memset(&session, 0, sizeof(session));
+ session.src_port = i;
+ rc = air_mir_getMirrorPort(unit, sessionid, &session);
+ if (AIR_E_OK != rc)
+ {
+ AIR_PRINT("***Error***,get port=%u error\n", i);
+ return rc;
+ }
+
+ if(session.flags & AIR_MIR_SESSION_FLAGS_DIR_TX)
+ {
+ txPbm[0] |= (1 << i);
+ }
+ if(session.flags & AIR_MIR_SESSION_FLAGS_DIR_RX)
+ {
+ rxPbm[0] |= (1 << i);
+ }
+ }
+ AIR_PRINT("Src PortList\n");
+ AIR_PRINT(" - Rx portlist = ");
+ _mir_printPortList(rxPbm);
+ AIR_PRINT(" - Tx portlist = ");
+ _mir_printPortList(txPbm);
+}
+
+static void
+_mir_printSession(
+ const UI32_T unit,
+ const UI32_T session_id,
+ const AIR_MIR_SESSION_T *ptr_session)
+{
+
+ AIR_PRINT("Session id: %d\n", session_id);
+ AIR_PRINT("State: %s \n", (ptr_session->flags & AIR_MIR_SESSION_FLAGS_ENABLE)? "enable": "disable");
+ AIR_PRINT("Tx tag: %s \n", (ptr_session->flags & AIR_MIR_SESSION_FLAGS_TX_TAG_OBEY_CFG)? "On": "Off");
+ AIR_PRINT("Dst port: %d \n", ptr_session->dst_port);
+ _mir_printSrcPortList(unit,session_id);
+}
+
+static AIR_ERROR_NO_T
+doMirrorGetSid(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+ UI32_T session_id = 0;
+ AIR_MIR_SESSION_T session = {0};
+ I8_T i = 0;
+
+ session_id = _strtoul(argv[0], NULL, 0);
+ rc = air_mir_getSession(0, session_id, &session);
+ if (AIR_E_OK != rc)
+ {
+ AIR_PRINT("***Error***, get mirror session fail\n");
+ return rc;
+ }
+ /* print session information */
+ if(session.dst_port == AIR_PORT_INVALID)
+ {
+ AIR_PRINT("Session id %d not found\n", session_id);
+ }
+ else
+ {
+ _mir_printSession(0, session_id, &session);
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doMirrorDelSid(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+ UI32_T session_id = 0;
+ AIR_MIR_SESSION_T session = {0};
+ UI8_T i = 0;
+
+ session_id = _strtoul(argv[0], NULL, 0);
+ rc = air_mir_delSession(0, session_id);
+ if (AIR_E_OK != rc)
+ {
+ AIR_PRINT("***Error***, del mirror session fail\n");
+ return rc;
+ }
+ for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
+ {
+ session.src_port = i;
+ rc = air_mir_setMirrorPort(0, session_id, &session);
+ if (AIR_E_OK != rc)
+ {
+ AIR_PRINT("***Error***,port=%u error\n", i);
+ return rc;
+ }
+ }
+ if (rc != AIR_E_OK)
+ {
+ AIR_PRINT("***Error***, delete mirror session fail\n");
+ }
+ else
+ AIR_PRINT("***OK***, delete mirror session success\n");
+
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doMirrorAddRlist(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+ UI32_T session_id = 0;
+ AIR_MIR_SESSION_T session = {0};
+ AIR_PORT_BITMAP_T rxPbm = {0};
+ UI8_T i = 0;
+
+ /*mirror add session-rlist <sid(0..3)> <list(UINTLIST)>*/
+ session_id = _strtoul(argv[0], NULL, 0);
+ rc = _portListStr2Ary(argv[1], rxPbm, 1);
+ if(rc != AIR_E_OK)
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return rc;
+ }
+ if(!rxPbm[0])
+ {
+ for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
+ {
+ memset(&session, 0, sizeof(AIR_MIR_SESSION_T));
+ session.src_port = i;
+ rc = air_mir_getMirrorPort(0, session_id, &session);
+ if (AIR_E_OK != rc)
+ {
+ AIR_PRINT("***Error***,get port=%u error\n", i);
+ return rc;
+ }
+
+ session.flags &= ~AIR_MIR_SESSION_FLAGS_DIR_RX;
+ session.src_port = i;
+ rc = air_mir_setMirrorPort(0, session_id, &session);
+ if (AIR_E_OK != rc)
+ {
+ AIR_PRINT("***Error***,set rx port=%u error\n", i);
+ return rc;
+ }
+ }
+ }
+ else
+ {
+ for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
+ {
+ if(rxPbm[0] & (1 << i))
+ {
+ memset(&session, 0, sizeof(AIR_MIR_SESSION_T));
+ session.src_port = i;
+ rc = air_mir_getMirrorPort(0, session_id, &session);
+ if (AIR_E_OK != rc)
+ {
+ AIR_PRINT("***Error***,get port=%u error\n", i);
+ return rc;
+ }
+
+ session.flags |= AIR_MIR_SESSION_FLAGS_DIR_RX;
+ session.src_port = i;
+ rc = air_mir_setMirrorPort(0, session_id, &session);
+ if (AIR_E_OK != rc)
+ {
+ AIR_PRINT("***Error***,port=%u error\n", i);
+ return rc;
+ }
+ }
+ }
+ }
+
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doMirrorAddTlist(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+ UI32_T session_id = 0;
+ AIR_MIR_SESSION_T session = {0};
+ AIR_PORT_BITMAP_T txPbm = {0};
+ UI8_T i = 0;
+
+ /*mirror add session-tlist <sid(0..3)> <list(UINTLIST)>*/
+ session_id = _strtoul(argv[0], NULL, 0);
+ rc = _portListStr2Ary(argv[1], txPbm, 1);
+ if(rc != AIR_E_OK)
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return rc;
+ }
+ if(!txPbm[0])
+ {
+ for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
+ {
+ memset(&session, 0, sizeof(AIR_MIR_SESSION_T));
+ session.src_port = i;
+ rc = air_mir_getMirrorPort(0, session_id, &session);
+ if (AIR_E_OK != rc)
+ {
+ AIR_PRINT("***Error***,get port=%u error\n", i);
+ return rc;
+ }
+
+ session.flags &= ~AIR_MIR_SESSION_FLAGS_DIR_TX;
+ session.src_port = i;
+ rc = air_mir_setMirrorPort(0, session_id, &session);
+ if (AIR_E_OK != rc)
+ {
+ AIR_PRINT("***Error***,set rx port=%u error\n", i);
+ return rc;
+ }
+ }
+ }
+ else
+ {
+ for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
+ {
+ if(txPbm[0] & (1 << i))
+ {
+ memset(&session, 0, sizeof(AIR_MIR_SESSION_T));
+ session.src_port = i;
+ rc = air_mir_getMirrorPort(0, session_id, &session);
+ if (AIR_E_OK != rc)
+ {
+ AIR_PRINT("***Error***,get port=%u error\n", i);
+ return rc;
+ }
+
+ session.flags |= AIR_MIR_SESSION_FLAGS_DIR_TX;
+ session.src_port = i;
+ rc = air_mir_setMirrorPort(0, session_id, &session);
+ if (AIR_E_OK != rc)
+ {
+ AIR_PRINT("***Error***,port=%u error\n", i);
+ return rc;
+ }
+ }
+ }
+ }
+
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doMirrorSetSessionEnable(
+ UI32_T argc,
+ C8_T *argv[])
+
+{
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+ UI32_T session_id = 0;
+ UI32_T enable = 0;
+ BOOL_T tmp_en = FALSE;
+
+ /*mirror set session-enable <sid(0..3)> <state(1:En,0:Dis)>*/
+ session_id = _strtoul(argv[0], NULL, 0);
+ enable = _strtoul(argv[1], NULL, 0);
+ if(enable)
+ tmp_en = TRUE;
+ /* set port mirror state */
+ rc = air_mir_setSessionAdminMode(0, session_id, tmp_en);
+ if(AIR_E_OK!=rc)
+ {
+ AIR_PRINT("***Error***\n");
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doMirrorSetSession(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+ UI32_T session_id = 0;
+ UI32_T dst_port = 0;
+ UI8_T enable = 0;
+ UI8_T tag_en = 0;
+ UI8_T dir = 0;
+ AIR_MIR_SESSION_T session = {0};
+ AIR_PORT_BITMAP_T rxPbm = {0};
+ I8_T i = 0;
+
+ /*mirror set session <sid(0..3)> <dst_port(UINT)> <state(1:En,0:Dis)> <tag(1:on, 0:off)> <list(UINTLIST)> <dir(0:none,1:tx,2:rx,3:both)>*/
+ session_id = _strtoul(argv[0], NULL, 0);
+ dst_port = _strtoul(argv[1], NULL, 0);
+ AIR_PRINT("session id %d dst port %d.\n", session_id, dst_port);
+ session.dst_port = dst_port;
+ enable = _strtoul(argv[2], NULL, 0);
+ if(enable)
+ {
+ session.flags |= AIR_MIR_SESSION_FLAGS_ENABLE;
+ }
+ else
+ {
+ session.flags &= ~AIR_MIR_SESSION_FLAGS_ENABLE;
+ }
+ tag_en = _strtoul(argv[3], NULL, 0);
+ if(tag_en)
+ {
+ session.flags |= AIR_MIR_SESSION_FLAGS_TX_TAG_OBEY_CFG;
+ }
+ else
+ {
+ session.flags &= ~AIR_MIR_SESSION_FLAGS_TX_TAG_OBEY_CFG;
+ }
+ rc = _portListStr2Ary(argv[4], rxPbm, 1);
+ if(rc != AIR_E_OK)
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return rc;
+ }
+ AIR_PRINT("pbm %x.\n", rxPbm);
+ dir = _strtoul(argv[5], NULL, 0);
+ if(dir == 1)
+ {
+ session.flags |= AIR_MIR_SESSION_FLAGS_DIR_TX;
+ }
+ else if(dir == 2)
+ {
+ session.flags |= AIR_MIR_SESSION_FLAGS_DIR_RX;
+ }
+ else if(dir == 3)
+ {
+ session.flags |= AIR_MIR_SESSION_FLAGS_DIR_TX;
+ session.flags |= AIR_MIR_SESSION_FLAGS_DIR_RX;
+ }
+ else if (!dir)
+ {
+ session.flags &= ~AIR_MIR_SESSION_FLAGS_DIR_TX;
+ session.flags &= ~AIR_MIR_SESSION_FLAGS_DIR_RX;
+ }
+ else
+ {
+ return AIR_E_BAD_PARAMETER;
+ }
+ for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
+ {
+ if(rxPbm[0] & (1 << i))
+ {
+ session.src_port = i;
+ /* set port mirror session */
+ rc = air_mir_addSession(0, session_id, &session);
+
+ if(AIR_E_OK!=rc)
+ {
+ AIR_PRINT("***Error***,dst-port=%u, src-port=%u error\n", session.dst_port, session.src_port);
+ return rc;
+ }
+ else
+ AIR_PRINT("add session %d,dst-port=%u, src-port=%u\n", session_id, session.dst_port, session.src_port);
+ }
+ }
+
+ return rc;
+}
+
+
+
+static AIR_ERROR_NO_T
+doMirrorSet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(mirrorSetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doMirrorAdd(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(mirrorAddCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doMirrorGet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(mirrorGetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doMirrorDel(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(mirrorDelCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doMirror(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(mirrorCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doMibClearPort(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T port = 0;
+
+ if(1 == argc)
+ {
+ /* mib clear port */
+ port = _strtoul(argv[0], NULL, 0);
+ ret = air_mib_clear_by_port(0,port);
+ AIR_PRINT("Clear port %d mib stats",port);
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("Done.\n");
+ }
+ else
+ {
+ AIR_PRINT("Fail.\n");
+ }
+ }
+ else if(0 == argc)
+ {
+ /*restart mib counter*/
+ air_mib_clear(0);
+ AIR_PRINT("Clear all mib stats",port);
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doMibClearAcl(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T port = 0;
+
+ if(0 == argc)
+ {
+ /* mib clear acl */
+ ret = air_mib_clearAclEvent(0);
+ AIR_PRINT("Clear ACL Event Counter ");
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("Done.\n");
+ }
+ else
+ {
+ AIR_PRINT("Fail.\n");
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doMibGetPort(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T port = 0;
+ UI32_T tmp32 = 0xffffffff;
+ AIR_MIB_CNT_RX_T rx_mib = {0};
+ AIR_MIB_CNT_TX_T tx_mib = {0};
+
+ port = _strtoul(argv[0], NULL, 0);
+ if(1 == argc)
+ {
+ /* mib get <port(0..6)> */
+ ret = air_mib_get(0, port, &rx_mib, &tx_mib);
+ AIR_PRINT("Get MIB Counter of Port %u ", port);
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("Done.\n");
+ AIR_PRINT("RX Drop Packet : %u\n", rx_mib.RDPC);
+ AIR_PRINT("RX filtering Packet : %u\n", rx_mib.RFPC);
+ AIR_PRINT("RX Unicast Packet : %u\n", rx_mib.RUPC);
+ AIR_PRINT("RX Multicast Packet : %u\n", rx_mib.RMPC);
+ AIR_PRINT("RX Broadcast Packet : %u\n", rx_mib.RBPC);
+ AIR_PRINT("RX Alignment Error Packet : %u\n", rx_mib.RAEPC);
+ AIR_PRINT("RX CRC Packet : %u\n", rx_mib.RCEPC);
+ AIR_PRINT("RX Undersize Packet : %u\n", rx_mib.RUSPC);
+ AIR_PRINT("RX Fragment Error Packet : %u\n", rx_mib.RFEPC);
+ AIR_PRINT("RX Oversize Packet : %u\n", rx_mib.ROSPC);
+ AIR_PRINT("RX Jabber Error Packet : %u\n", rx_mib.RJEPC);
+ AIR_PRINT("RX Pause Packet : %u\n", rx_mib.RPPC);
+ AIR_PRINT("RX Packet Length 64 bytes : %u\n", rx_mib.RL64PC);
+ AIR_PRINT("RX Packet Length 65 ~ 127 bytes : %u\n", rx_mib.RL65PC);
+ AIR_PRINT("RX Packet Length 128 ~ 255 bytes : %u\n", rx_mib.RL128PC);
+ AIR_PRINT("RX Packet Length 256 ~ 511 bytes : %u\n", rx_mib.RL256PC);
+ AIR_PRINT("RX Packet Length 512 ~ 1023 bytes : %u\n", rx_mib.RL512PC);
+ AIR_PRINT("RX Packet Length 1024 ~ 1518 bytes: %u\n", rx_mib.RL1024PC);
+ AIR_PRINT("RX Packet Length 1519 ~ max bytes : %u\n", rx_mib.RL1519PC);
+ AIR_PRINT("RX_CTRL Drop Packet : %u\n", rx_mib.RCDPC);
+ AIR_PRINT("RX Ingress Drop Packet : %u\n", rx_mib.RIDPC);
+ AIR_PRINT("RX ARL Drop Packet : %u\n", rx_mib.RADPC);
+ AIR_PRINT("FLow Control Drop Packet : %u\n", rx_mib.FCDPC);
+ AIR_PRINT("WRED Drop Packtet : %u\n", rx_mib.WRDPC);
+ AIR_PRINT("Mirror Drop Packet : %u\n", rx_mib.MRDPC);
+ AIR_PRINT("RX sFlow Sampling Packet : %u\n", rx_mib.SFSPC);
+ AIR_PRINT("Rx sFlow Total Packet : %u\n", rx_mib.SFTPC);
+ AIR_PRINT("Port Control Drop Packet : %u\n", rx_mib.RXC_DPC);
+ AIR_PRINT("RX Octets good or bad packtes l32 : %u\n", (UI32_T)(rx_mib.ROC & tmp32));
+ AIR_PRINT("RX Octets good or bad packtes h32 : %u\n", (UI32_T)((rx_mib.ROC >> 32) & tmp32));
+ AIR_PRINT("RX Octets bad packets l32 : %u\n", (UI32_T)(rx_mib.ROC2 & tmp32));
+ AIR_PRINT("RX Octets bad packets h32 : %u\n", (UI32_T)((rx_mib.ROC2 >> 32) & tmp32));
+ AIR_PRINT("\n");
+ AIR_PRINT("TX Drop Packet : %u\n", tx_mib.TDPC);
+ AIR_PRINT("TX CRC Packet : %u\n", tx_mib.TCRC);
+ AIR_PRINT("TX Unicast Packet : %u\n", tx_mib.TUPC);
+ AIR_PRINT("TX Multicast Packet : %u\n", tx_mib.TMPC);
+ AIR_PRINT("TX Broadcast Packet : %u\n", tx_mib.TBPC);
+ AIR_PRINT("TX Collision Event Count : %u\n", tx_mib.TCEC);
+ AIR_PRINT("TX Single Collision Event Count : %u\n", tx_mib.TSCEC);
+ AIR_PRINT("TX Multiple Conllision Event Count: %u\n", tx_mib.TMCEC);
+ AIR_PRINT("TX Deferred Event Count : %u\n", tx_mib.TDEC);
+ AIR_PRINT("TX Late Collision Event Count : %u\n", tx_mib.TLCEC);
+ AIR_PRINT("TX Excessive Collision Event Count: %u\n", tx_mib.TXCEC);
+ AIR_PRINT("TX Pause Packet : %u\n", tx_mib.TPPC);
+ AIR_PRINT("TX Packet Length 64 bytes : %u\n", tx_mib.TL64PC);
+ AIR_PRINT("TX Packet Length 65 ~ 127 bytes : %u\n", tx_mib.TL65PC);
+ AIR_PRINT("TX Packet Length 128 ~ 255 bytes : %u\n", tx_mib.TL128PC);
+ AIR_PRINT("TX Packet Length 256 ~ 511 bytes : %u\n", tx_mib.TL256PC);
+ AIR_PRINT("TX Packet Length 512 ~ 1023 bytes : %u\n", tx_mib.TL512PC);
+ AIR_PRINT("TX Packet Length 1024 ~ 1518 bytes: %u\n", tx_mib.TL1024PC);
+ AIR_PRINT("TX Packet Length 1519 ~ max bytes : %u\n", tx_mib.TL1519PC);
+ AIR_PRINT("TX Oversize Drop Packet : %u\n", tx_mib.TODPC);
+ AIR_PRINT("TX Octets good or bad packtes l32 : %u\n", (UI32_T)(tx_mib.TOC & tmp32));
+ AIR_PRINT("TX Octets good or bad packtes h32 : %u\n", (UI32_T)((tx_mib.TOC >> 32) & tmp32));
+ AIR_PRINT("TX Octets bad packets l32 : %u\n", (UI32_T)(tx_mib.TOC2 & tmp32));
+ AIR_PRINT("TX Octets bad packets h32 : %u\n", (UI32_T)((tx_mib.TOC2 >> 32) & tmp32));
+ }
+ else
+ {
+ AIR_PRINT("Fail.\n");
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doMibGetAcl(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T event = 0;
+ UI32_T cnt = 0;
+
+ if(1 == argc)
+ {
+ /* mib get acl <event(0..7)> */
+ event = _strtoul(argv[0], NULL, 0);
+ ret = air_mib_getAclEvent(0, event, &cnt);
+ AIR_PRINT("Get counter of ACL event %u ", event);
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("Done.\n");
+ AIR_PRINT("ACL Event Counter:%u\n", cnt);
+ }
+ else
+ {
+ AIR_PRINT("Fail.\n");
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doMibClear(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(mibClearCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doMibGet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(mibGetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doMib(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(mibCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doQosRateLimitExMngFrm(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T dir = 0;
+ BOOL_T enable = FALSE;
+
+ if(2 == argc)
+ {
+ dir = _strtoul(argv[0], NULL, 0);
+ if(dir == 0)
+ dir = AIR_QOS_RATE_DIR_EGRESS;
+ else if(dir == 1)
+ dir = AIR_QOS_RATE_DIR_INGRESS;
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ return ret;
+ }
+ enable = _strtoul(argv[1], NULL, 0);
+ ret = air_qos_setRateLimitExMngFrm(0, dir, enable);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Success.\n");
+ AIR_PRINT("Set %s Rate Limit Control %s management frame.\n",
+ (AIR_QOS_RATE_DIR_INGRESS == dir)?"Ingress":"Egress",
+ (TRUE == enable)?"exclude":"include");
+ }
+ else
+ {
+ AIR_PRINT("Fail.\n");
+ return ret;
+ }
+ }
+ else if(0 == argc)
+ {
+ dir = AIR_QOS_RATE_DIR_EGRESS;
+ ret = air_qos_getRateLimitExMngFrm(0, dir, &enable);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Success.\n");
+ AIR_PRINT("Get %s Rate Limit Control %s management frame.\n",
+ (AIR_QOS_RATE_DIR_INGRESS == dir)?"Ingress":"Egress",
+ (TRUE == enable)?"exclude":"include");
+ }
+ else
+ {
+ AIR_PRINT("Fail.\n");
+ return ret;
+ }
+ dir = AIR_QOS_RATE_DIR_INGRESS;
+ ret = air_qos_getRateLimitExMngFrm(0, dir, &enable);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Success.\n");
+ AIR_PRINT("Get %s Rate Limit Control %s management frame.\n",
+ (AIR_QOS_RATE_DIR_INGRESS == dir)?"Ingress":"Egress",
+ (TRUE == enable)?"exclude":"include");
+ }
+ else
+ {
+ AIR_PRINT("Fail.\n");
+ return ret;
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+
+}
+
+static AIR_ERROR_NO_T
+doQosPortPriority(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ AIR_PORT_BITMAP_T portlist = {0};
+ UI32_T priority = 0;
+ UI8_T i = 0;
+
+ ret = _portListStr2Ary(argv[0], portlist, 1);
+ if(ret != AIR_E_OK)
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return ret;
+ }
+ if(2 == argc)
+ {
+ priority = _strtoul(argv[1], NULL, 0);
+ for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
+ {
+ if(portlist[0] & (1 << i))
+ {
+ ret = air_qos_setPortPriority(0, i, priority);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Set Port%02d port based priority %d Success.\n", i, priority);
+ }
+ else
+ {
+ AIR_PRINT("Set Port%02d port based priority %d Fail.\n", i, priority);
+ }
+ }
+ }
+ }
+ else if(1 == argc)
+ {
+ for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
+ {
+ if(portlist[0] & (1 << i))
+ {
+ ret = air_qos_getPortPriority(0, i, &priority);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Get Port%d port based priority %d.\n", i, priority);
+ }
+ else
+ {
+ AIR_PRINT("Get Port%d port based priority Fail.\n", i);
+ }
+ }
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doQosRateLimit(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ AIR_PORT_BITMAP_T portlist = {0};
+ AIR_QOS_RATE_LIMIT_CFG_T rl = {0};
+ UI8_T i = 0;
+
+ ret = _portListStr2Ary(argv[0], portlist, 1);
+ if(ret != AIR_E_OK)
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return ret;
+ }
+ if(5 == argc)
+ {
+ rl.ingress_cir = _strtoul(argv[1], NULL, 0);
+ rl.ingress_cbs = _strtoul(argv[2], NULL, 0);
+ rl.egress_cir = _strtoul(argv[3], NULL, 0);
+ rl.egress_cbs = _strtoul(argv[4], NULL, 0);
+ rl.flags |= AIR_QOS_RATE_LIMIT_CFG_FLAGS_ENABLE_INGRESS;
+ rl.flags |= AIR_QOS_RATE_LIMIT_CFG_FLAGS_ENABLE_EGRESS;
+ for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
+ {
+ if(portlist[0] & (1 << i))
+ {
+ ret = air_qos_setRateLimit(0, i, &rl);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Set Port%02d Ingress CIR %d CBS %d Egress CIR %d CBS %d Success.\n", i, rl.ingress_cir, rl.ingress_cbs, rl.egress_cir, rl.egress_cbs);
+ }
+ else
+ {
+ AIR_PRINT("Set Port%02d Ingress CIR %d CBS %d Egress CIR %d CBS %d Fail.\n", i, rl.ingress_cir, rl.ingress_cbs, rl.egress_cir, rl.egress_cbs);
+ }
+ }
+ }
+ }
+ else if(1 == argc)
+ {
+ for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
+ {
+ if(portlist[0] & (1 << i))
+ {
+ ret = air_qos_getRateLimit(0, i, &rl);
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("Get Port%02d Ingress CIR %d CBS %d Egress CIR %d CBS %d\n", i, rl.ingress_cir, rl.ingress_cbs, rl.egress_cir, rl.egress_cbs);
+ }
+ else
+ {
+ AIR_PRINT("Get Port%02d Rate Info Fail.\n", i);
+ }
+ }
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doQosRateLimitEnable(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ AIR_PORT_BITMAP_T portlist = {0};
+ C8_T sten[2][10] = {"Disable", "Enable"};
+ C8_T stdir[2][10] = {"Egress", "Ingress"};
+ UI32_T dir = 0, en = 0;
+ AIR_QOS_RATE_DIR_T tmp_dir = AIR_QOS_RATE_DIR_LAST;
+ BOOL_T state = FALSE;
+ UI8_T i = 0;
+
+ ret = _portListStr2Ary(argv[0], portlist, 1);
+ if(ret != AIR_E_OK)
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return ret;
+ }
+ if(3 == argc)
+ {
+ dir = _strtoul(argv[1], NULL, 0);
+ en = _strtoul(argv[2], NULL, 0);
+ if(dir == 0)
+ tmp_dir = AIR_QOS_RATE_DIR_EGRESS;
+ else if(dir == 1)
+ tmp_dir = AIR_QOS_RATE_DIR_INGRESS;
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+ if(en)
+ state= TRUE;
+ else
+ state = FALSE;
+
+ for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
+ {
+ if(portlist[0] & (1 << i))
+ {
+ ret = air_qos_setRateLimitEnable(0, i, tmp_dir, state);
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("Set Port%02d %s rate %s Success.\n", i, stdir[dir], sten[en]);
+ }
+ else
+ {
+ AIR_PRINT("Set Port%02d %s rate %s Fail.\n", i, stdir[dir], sten[en]);
+ }
+ }
+ }
+ }
+ else if(1 == argc)
+ {
+ for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
+ {
+ if(portlist[0] & (1 << i))
+ {
+ tmp_dir = AIR_QOS_RATE_DIR_EGRESS;
+ dir = 0;
+ ret = air_qos_getRateLimitEnable(0, i, tmp_dir, &state);
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("Get Port%02d %s rate %s Success.\n", i, stdir[dir], sten[state]);
+ }
+ else
+ {
+ AIR_PRINT("Get Port%02d %s rate state Fail.\n", i, stdir[dir]);
+ }
+ tmp_dir = AIR_QOS_RATE_DIR_INGRESS;
+ dir = 1;
+ ret = air_qos_getRateLimitEnable(0, i, tmp_dir, &state);
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("Get Port%02d %s rate %s Success.\n", i, stdir[dir], sten[state]);
+ }
+ else
+ {
+ AIR_PRINT("Get Port%02d %s rate state Fail.\n", i, stdir[dir]);
+ }
+ }
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+
+}
+
+static AIR_ERROR_NO_T
+doQosDscp2Pri(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T dscp = 0, priority = 0;
+
+ dscp = _strtoul(argv[0], NULL, 0);
+ if(2 == argc)
+ {
+ priority = _strtoul(argv[1], NULL, 0);
+ ret = air_qos_setDscp2Pri(0, dscp, priority);
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("Set DSCP %d to priority %d Success.\n", dscp, priority);
+ }
+ else
+ {
+ AIR_PRINT("Set DSCP %d to priority %d Fail.\n", dscp, priority);
+ }
+ }
+ else if(1 == argc)
+ {
+ ret = air_qos_getDscp2Pri(0, dscp, &priority);
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("Get DSCP %d to priority %d\n", dscp, priority);
+ }
+ else
+ {
+ AIR_PRINT("Get DSCP %d to priority Fail.\n", dscp);
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doQosPri2Queue(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T priority = 0, queue = 0;
+
+ priority = _strtoul(argv[1], NULL, 0);
+
+ if(2 == argc)
+ {
+ priority = _strtoul(argv[0], NULL, 0);
+ queue = _strtoul(argv[1], NULL, 0);
+ ret = air_qos_setPri2Queue(0, priority, queue);
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("Set priority %d to queue %d Success.\n", priority, queue);
+ }
+ else
+ {
+ AIR_PRINT("Set priority %d to queue %d Fail.\n", priority, queue);
+ }
+ }
+ else
+ {
+ for(; priority < AIR_QOS_QUEUE_MAX_NUM; priority++)
+ {
+ ret = air_qos_getPri2Queue(0, priority, &queue);
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("Get priority %d to queue %d\n", priority, queue);
+ }
+ else
+ {
+ AIR_PRINT("Get priority %d to queue Fail.\n", priority);
+ }
+ }
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doQosTrustMode(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T mode = 0;
+ C8_T bs[4][13] = {"port", "1p_port", "dscp_port", "dscp_1p_port"};
+ AIR_QOS_TRUST_MODE_T mode_t = AIR_QOS_TRUST_MODE_LAST;
+ AIR_PORT_BITMAP_T portlist = {0};
+ UI8_T i = 0;
+
+ ret = _portListStr2Ary(argv[0], portlist, 1);
+ if(ret != AIR_E_OK)
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return ret;
+ }
+ if(2 == argc)
+ {
+ mode = _strtoul(argv[1], NULL, 0);
+ if(mode == 0)
+ mode_t = AIR_QOS_TRUST_MODE_PORT;
+ else if(mode == 1)
+ mode_t = AIR_QOS_TRUST_MODE_1P_PORT;
+ else if(mode == 2)
+ mode_t = AIR_QOS_TRUST_MODE_DSCP_PORT;
+ else if(mode == 3)
+ mode_t = AIR_QOS_TRUST_MODE_DSCP_1P_PORT;
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+ for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
+ {
+ if(portlist[0] & (1 << i))
+ {
+ ret = air_qos_setTrustMode(0, i, mode_t);
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("port %d Set Trust mode %s Success.\n", i, bs[mode]);
+ }
+ else
+ {
+ AIR_PRINT("port %d Set Trust mode %s Fail.\n", i, bs[mode]);
+ }
+ }
+ }
+ }
+ else if(1 == argc)
+ {
+ for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
+ {
+ if(portlist[0] & (1 << i))
+ {
+ mode_t = AIR_QOS_TRUST_MODE_LAST;
+ ret = air_qos_getTrustMode(0, i, &mode_t);
+ if(AIR_E_OK == ret)
+ {
+ if(mode_t == AIR_QOS_TRUST_MODE_PORT)
+ mode = 0;
+ else if(mode_t == AIR_QOS_TRUST_MODE_1P_PORT)
+ mode = 1;
+ else if(mode_t == AIR_QOS_TRUST_MODE_DSCP_PORT)
+ mode = 2;
+ else if(mode_t == AIR_QOS_TRUST_MODE_DSCP_1P_PORT)
+ mode = 3;
+ else
+ {
+ AIR_PRINT("port %d Get Trust mode Fail.\n", i);
+ return AIR_E_OTHERS;
+ }
+ AIR_PRINT("port %d Get Trust mode %s\n", i, bs[mode]);
+ }
+ else
+ {
+ AIR_PRINT("port %d Get Trust mode Fail.\n", i);
+ }
+ }
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doQosScheduleAlgo(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ AIR_PORT_BITMAP_T portlist = {0};
+ AIR_QOS_SCH_MODE_T sch_mode = AIR_QOS_SCH_MODE_LAST;
+ UI32_T scheduler = 0;
+ UI8_T queue = 0;
+ C8_T sche[3][5] = {"SP", "WRR", "WFQ"};
+ UI32_T weight = AIR_QOS_SHAPER_NOSETTING;
+ UI8_T i = 0;
+
+ ret = _portListStr2Ary(argv[0], portlist, 1);
+ if(ret != AIR_E_OK)
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return ret;
+ }
+ AIR_PRINT("port list is %d\n", portlist[0]);
+ if(4 == argc)
+ {
+ queue = _strtoul(argv[1], NULL, 0);
+ AIR_PRINT("queue is %d\n", queue);
+ scheduler = _strtoul(argv[2], NULL, 0);
+ AIR_PRINT("scheduler is %d\n", scheduler);
+ weight = _strtoul(argv[3], NULL, 0);
+ AIR_PRINT("weight is %d\n", weight);
+ if(scheduler == 0)
+ {
+ sch_mode = AIR_QOS_SCH_MODE_SP;
+ weight = AIR_QOS_SHAPER_NOSETTING;
+ if(weight != AIR_QOS_SHAPER_NOSETTING)
+ AIR_PRINT("[Warning] SP schedule mode no need weight\n");
+ }
+ else if(scheduler == 1)
+ {
+ sch_mode = AIR_QOS_SCH_MODE_WRR;
+ if(weight == AIR_QOS_SHAPER_NOSETTING)
+ {
+ AIR_PRINT("[Warning] No weight value input , plz check\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+ AIR_PRINT("sch_mode is 1\n");
+ }
+ else if(scheduler == 2)
+ {
+ sch_mode = AIR_QOS_SCH_MODE_WFQ;
+ if(weight == AIR_QOS_SHAPER_NOSETTING)
+ {
+ AIR_PRINT("[Warning] No weight value input , plz check\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unknown schedule mode, plz check again\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+ for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
+ {
+ if(portlist[0] & (1 << i))
+ {
+ AIR_PRINT("port %d\n", i);
+ ret = air_qos_setScheduleAlgo(0, i, queue, sch_mode, weight);
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("Set Port%02d Scheduler %s Success.\n", i, sche[scheduler]);
+ }
+ else
+ {
+ AIR_PRINT("Set Port%02d Scheduler %s Fail.\n", i, sche[scheduler]);
+ }
+ }
+ }
+ }
+ else if(2 == argc)
+ {
+ queue = _strtoul(argv[1], NULL, 0);
+ for(i = 0; i < AIR_MAX_NUM_OF_PORTS; i++)
+ {
+ if(portlist[0] & (1 << i))
+ {
+ ret = air_qos_getScheduleAlgo(0, i, queue, &sch_mode, &weight);
+ if(AIR_E_OK == ret)
+ {
+ if(sch_mode == AIR_QOS_SCH_MODE_SP)
+ AIR_PRINT("Get Port%02d queue %d Scheduler %s\n", i, queue, sche[sch_mode]);
+ else if((sch_mode == AIR_QOS_SCH_MODE_WRR) || (sch_mode == AIR_QOS_SCH_MODE_WFQ))
+ AIR_PRINT("Get Port%02d queue %d Scheduler %s weight %d\n", i, queue, sche[sch_mode], weight);
+ else
+ AIR_PRINT("Get Port%02d queue %d Scheduler unknown\n", i, queue);
+ }
+ else
+ {
+ AIR_PRINT("Get Port%02d queue %d Scheduler Fail.\n", i, queue);
+ }
+ }
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doQosGet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(qosGetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doQosSet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(qosSetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doQos(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(qosCmds, argc, argv);
+}
+static AIR_ERROR_NO_T
+doDiagTxComply(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T phy = 0;
+ UI32_T mode = 0;
+
+ phy = _strtoul(argv[0], NULL, 0);
+ if(2 == argc)
+ {
+ /* diag set txComply <phy(0~5)> <mode(0~8)> */
+ mode = _strtoul(argv[1], NULL, 0);
+ ret = air_diag_setTxComplyMode(0, phy, mode);
+ AIR_PRINT("Set diagnostic function: PHY %u Tx Compliance mode = %u ", phy, mode);
+ }
+ else if(1 == argc)
+ {
+ /* diag get txComply <phy(0~5)> */
+ ret = air_diag_getTxComplyMode(0, phy, &mode);
+ AIR_PRINT("Get diagnostic function: PHY %u Tx Compliance mode ", phy);
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("Done.\n\tMode=");
+ switch(mode)
+ {
+ case AIR_DIAG_TXCOMPLY_MODE_10M_NLP:
+ AIR_PRINT("%s\n", "10M_NLP");
+ break;
+ case AIR_DIAG_TXCOMPLY_MODE_10M_RANDOM:
+ AIR_PRINT("%s\n", "10M_Random");
+ break;
+ case AIR_DIAG_TXCOMPLY_MODE_10M_SINE:
+ AIR_PRINT("%s\n", "10M_Sine");
+ break;
+ case AIR_DIAG_TXCOMPLY_MODE_100M_PAIR_A:
+ AIR_PRINT("%s\n", "100M_Pair_a");
+ break;
+ case AIR_DIAG_TXCOMPLY_MODE_100M_PAIR_B:
+ AIR_PRINT("%s\n", "100M_Pair_b");
+ break;
+ case AIR_DIAG_TXCOMPLY_MODE_1000M_TM1:
+ AIR_PRINT("%s\n", "1000M_TM1");
+ break;
+ case AIR_DIAG_TXCOMPLY_MODE_1000M_TM2:
+ AIR_PRINT("%s\n", "1000M_TM2");
+ break;
+ case AIR_DIAG_TXCOMPLY_MODE_1000M_TM3:
+ AIR_PRINT("%s\n", "1000M_TM3");
+ break;
+ case AIR_DIAG_TXCOMPLY_MODE_1000M_TM4:
+ AIR_PRINT("%s\n", "1000M_TM4");
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ if(AIR_E_OTHERS == ret)
+ {
+ AIR_PRINT("isn't setting.\n");
+ }
+ else
+ {
+ AIR_PRINT("Fail.\n");
+ }
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doDiagSet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(diagSetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doDiagGet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(diagGetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doDiag(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(diagCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doLedMode(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T mode = 0;
+
+ if(1 == argc)
+ {
+ /* led set mode <mode(0:disable, 1~3:2 LED, 4:User-Define)> */
+ mode = _strtoul(argv[0], NULL, 0);
+ ret = air_led_setMode(0, 0, mode);
+ AIR_PRINT("Set LED mode ");
+ }
+ else if(0 == argc)
+ {
+ /* led get mode */
+ ret = air_led_getMode(0, 0, &mode);
+ AIR_PRINT("Get LED mode ");
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+
+ if(AIR_E_OK == ret)
+ {
+ switch(mode)
+ {
+ case AIR_LED_MODE_DISABLE:
+ AIR_PRINT(": Disabled.\n");
+ break;
+ case AIR_LED_MODE_2LED_MODE0:
+ AIR_PRINT(": LED 0:Link / LED 1:Activity.\n");
+ break;
+ case AIR_LED_MODE_2LED_MODE1:
+ AIR_PRINT(": LED 0:1000M Activity / LED 1:100M Activity.\n");
+ break;
+ case AIR_LED_MODE_2LED_MODE2:
+ AIR_PRINT(": LED 0:1000M Activity / LED 1:10&100M Activity.\n");
+ break;
+ case AIR_LED_MODE_USER_DEFINE:
+ AIR_PRINT(": User-Defined.\n");
+ break;
+ default:
+ AIR_PRINT(": Fail.\n");
+ break;
+ }
+ }
+ else
+ if(AIR_E_OTHERS == ret)
+ {
+ AIR_PRINT(": Unrecognized.\n");
+ }
+ else
+ {
+ AIR_PRINT("Fail.\n");
+ }
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doLedState(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI8_T entity = 0;
+ BOOL_T state = FALSE;
+
+ entity = _strtoul(argv[0], NULL, 0);
+ if(2 == argc)
+ {
+ /* led set state <led(0..1)> <state(1:En 0:Dis)> */
+ state = _strtoul(argv[1], NULL, 0);
+ ret = air_led_setState(0, 0, entity, state);
+ AIR_PRINT("Set LED %u state ", entity);
+ }
+ else if(1 == argc)
+ {
+ /* led get state <led(0..1)> */
+ ret = air_led_getState(0, 0, entity, &state);
+ AIR_PRINT("Get LED %u state ", entity );
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT(": %s.\n", (state)?"Enable":"Disabled");
+ }
+ else
+ if(AIR_E_OTHERS == ret)
+ {
+ AIR_PRINT(": Unrecognized.\n");
+ }
+ else
+ {
+ AIR_PRINT("Fail.\n");
+ }
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doLedUsrDef(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T i = 0;
+ UI8_T entity = 0;
+ BOOL_T polarity = LOW;
+ UI32_T on_evt_map = 0;
+ UI32_T blk_evt_map = 0;
+ AIR_LED_ON_EVT_T on_evt;
+ AIR_LED_BLK_EVT_T blk_evt;
+
+ entity = _strtoul(argv[0], NULL, 0);
+ if(4 == argc)
+ {
+ /* led set usr <led(0..1)> <polarity(0:low, 1:high)> <on_evt(7'bin)> <blink_evt(10'bin)> */
+ polarity = _strtoul(argv[1], NULL, 0);
+ on_evt_map = _strtoul(argv[2], NULL, 2);
+ blk_evt_map = _strtoul(argv[3], NULL, 2);
+
+ memset(&on_evt, 0, sizeof(AIR_LED_ON_EVT_T));
+ if(on_evt_map & BIT(0))
+ {
+ on_evt.link_1000m = TRUE;
+ }
+ if(on_evt_map & BIT(1))
+ {
+ on_evt.link_100m = TRUE;
+ }
+ if(on_evt_map & BIT(2))
+ {
+ on_evt.link_10m = TRUE;
+ }
+ if(on_evt_map & BIT(3))
+ {
+ on_evt.link_dn = TRUE;
+ }
+ if(on_evt_map & BIT(4))
+ {
+ on_evt.fdx = TRUE;
+ }
+ if(on_evt_map & BIT(5))
+ {
+ on_evt.hdx = TRUE;
+ }
+ if(on_evt_map & BIT(6))
+ {
+ on_evt.force = TRUE;
+ }
+
+ memset(&blk_evt, 0, sizeof(AIR_LED_BLK_EVT_T));
+ if(blk_evt_map & BIT(0))
+ {
+ blk_evt.tx_act_1000m = TRUE;
+ }
+ if(blk_evt_map & BIT(1))
+ {
+ blk_evt.rx_act_1000m = TRUE;
+ }
+ if(blk_evt_map & BIT(2))
+ {
+ blk_evt.tx_act_100m = TRUE;
+ }
+ if(blk_evt_map & BIT(3))
+ {
+ blk_evt.rx_act_100m = TRUE;
+ }
+ if(blk_evt_map & BIT(4))
+ {
+ blk_evt.tx_act_10m = TRUE;
+ }
+ if(blk_evt_map & BIT(5))
+ {
+ blk_evt.rx_act_10m = TRUE;
+ }
+ if(blk_evt_map & BIT(6))
+ {
+ blk_evt.cls = TRUE;
+ }
+ if(blk_evt_map & BIT(7))
+ {
+ blk_evt.rx_crc = TRUE;
+ }
+ if(blk_evt_map & BIT(8))
+ {
+ blk_evt.rx_idle = TRUE;
+ }
+ if(blk_evt_map & BIT(9))
+ {
+ blk_evt.force = TRUE;
+ }
+ ret = air_led_setUsrDef(0, 0, entity, polarity, on_evt, blk_evt);
+ AIR_PRINT("Set LED %u User-define ", entity);
+ }
+ else if(1 == argc)
+ {
+ /* led get usr <led(0..1)> */
+ ret = air_led_getUsrDef(0, 0, entity, &polarity, &on_evt, &blk_evt);
+ AIR_PRINT("Get LED %u User-define ", entity );
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("Done.\n");
+ AIR_PRINT("Polarity:%u.\n", polarity);
+ AIR_PRINT("On Event:\n");
+ i = 6;
+ AIR_PRINT("\t(%u)Force on :%s\n", i--, (on_evt.force)?"On":"Off");
+ AIR_PRINT("\t(%u)Half Duplex :%s\n", i--, (on_evt.hdx)?"On":"Off");
+ AIR_PRINT("\t(%u)Full Duplex :%s\n", i--, (on_evt.fdx)?"On":"Off");
+ AIR_PRINT("\t(%u)Link Down :%s\n", i--, (on_evt.link_dn)?"On":"Off");
+ AIR_PRINT("\t(%u)Link 10M :%s\n", i--, (on_evt.link_10m)?"On":"Off");
+ AIR_PRINT("\t(%u)Link 100M :%s\n", i--, (on_evt.link_100m)?"On":"Off");
+ AIR_PRINT("\t(%u)Link 1000M :%s\n", i, (on_evt.link_1000m)?"On":"Off");
+
+ AIR_PRINT("Blinking Event:\n");
+ i = 9;
+ AIR_PRINT("\t(%u)Force blinks :%s\n", i--, (blk_evt.force)?"On":"Off");
+ AIR_PRINT("\t(%u)Rx Idle Error :%s\n", i--, (blk_evt.rx_idle)?"On":"Off");
+ AIR_PRINT("\t(%u)Rx CRC Error :%s\n", i--, (blk_evt.rx_crc)?"On":"Off");
+ AIR_PRINT("\t(%u)Collision :%s\n", i--, (blk_evt.cls)?"On":"Off");
+ AIR_PRINT("\t(%u)10Mbps RX Activity :%s\n", i--, (blk_evt.rx_act_10m)?"On":"Off");
+ AIR_PRINT("\t(%u)10Mbps TX Activity :%s\n", i--, (blk_evt.tx_act_10m)?"On":"Off");
+ AIR_PRINT("\t(%u)100Mbps RX Activity :%s\n", i--, (blk_evt.rx_act_100m)?"On":"Off");
+ AIR_PRINT("\t(%u)100Mbps TX Activity :%s\n", i--, (blk_evt.tx_act_100m)?"On":"Off");
+ AIR_PRINT("\t(%u)1000Mbps RX Activity :%s\n", i--, (blk_evt.rx_act_1000m)?"On":"Off");
+ AIR_PRINT("\t(%u)1000Mbps TX Activity :%s\n", i, (blk_evt.tx_act_1000m)?"On":"Off");
+ }
+ else
+ {
+ AIR_PRINT("Fail.\n");
+ }
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doLedBlkTime(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ AIR_LED_BLK_DUR_T time = 0;
+
+ if(1 == argc)
+ {
+ /* led set time <time(0~5)> */
+ time = _strtoul(argv[0], NULL, 0);
+ ret = air_led_setBlkTime(0, 0, time);
+ AIR_PRINT("Set Blinking Duration ");
+ }
+ else if(0 == argc)
+ {
+ /* led get time */
+ ret = air_led_getBlkTime(0, 0, &time);
+ AIR_PRINT("Get Blinking Duration ");
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("Done.\n");
+ AIR_PRINT("\tBlinking duration : %u (ms)\n", (32 << time) );
+ }
+ else
+ {
+ AIR_PRINT("Fail.\n");
+ }
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doLedSet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(ledSetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doLedGet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(ledGetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doLed(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(ledCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doShowVersion(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_PRINT("VERSION: %s\n", AIR_VER_SDK);
+
+ return AIR_E_OK;
+}
+
+static AIR_ERROR_NO_T
+doShow(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(showCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doStormRate(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T port = 0, type = 0;
+ UI32_T unit = 0, count = 0;
+ C8_T stype[3][5] = {"Bcst", "Mcst", "Ucst"};
+ UI32_T kb = 0;
+
+ port = _strtol(argv[0], NULL, 10);
+ type = _strtol(argv[1], NULL, 10);
+ if(4 == argc)
+ {
+ count = _strtol(argv[2], NULL, 10);
+ unit = _strtol(argv[3], NULL, 10);
+
+ if(0 == unit)
+ kb = 64;
+ else if(1 == unit)
+ kb = 256;
+ else if(2 == unit)
+ kb = 1024;
+ else if(3 == unit)
+ kb = 4096;
+ else
+ kb = 16384;
+ ret = air_sec_setStormRate(0, port, type, count, unit);
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("Set Port%02d %s storm rate (%d * %d) = %d Kbps\n", port, stype[type], count, kb, (count*kb));
+ }
+ else
+ {
+ AIR_PRINT("Set Port%02d %s storm rate Fail.\n", port, stype[type]);
+ AIR_PRINT("Note: Port(0..4) can only select unit(0..3), port(5..6) can only select unit(4)\n");
+ }
+ }
+ else if(2 == argc)
+ {
+ ret = air_sec_getStormRate(0, port, type, &count, &unit);
+ if(AIR_E_OK == ret)
+ {
+ if(0 == unit)
+ kb = 64;
+ else if(1 == unit)
+ kb = 256;
+ else if(2 == unit)
+ kb = 1024;
+ else if(3 == unit)
+ kb = 4096;
+ else
+ kb = 16384;
+ AIR_PRINT("Port%02d %s storm rate (%d * %d) = %d Kbps\n", port, stype[type], count, kb, (count*kb));
+ }
+ else
+ {
+ AIR_PRINT("Get Port%02d %s storm rate Fail\n", port, stype[type]);
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doFldMode(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T port = 0, type = 0;
+ BOOL_T fld_en = 0;
+ C8_T stype[4][5] = {"Bcst", "Mcst", "Ucst", "Qury"};
+ C8_T sen[2][10] = {"Disable", "Enable"};
+
+ port = _strtol(argv[0], NULL, 10);
+ type = _strtol(argv[1], NULL, 10);
+
+ if(2 == argc)
+ {
+ ret = air_sec_getFldMode(0, port, type, &fld_en);
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("Get Port%02d flooding %s frame %s\n", port, stype[type], sen[fld_en]);
+ }
+ else
+ {
+ AIR_PRINT("Get Port%02d flooding %s frame Fail\n", port, stype[type]);
+ }
+ }
+ else if(3 == argc)
+ {
+ fld_en = _strtol(argv[2], NULL, 10);
+ ret = air_sec_setFldMode(0, port, type, fld_en);
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("Set Port%02d flooding %s frame %s Success\n", port, stype[type], sen[fld_en]);
+ }
+ else
+ {
+ AIR_PRINT("Set Port%02d flooding %s frame %s Fail\n", port, stype[type], sen[fld_en]);
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doStormEnable(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T port = 0, type = 0;
+ BOOL_T en = 0;
+ C8_T sen[2][10] = {"Disable", "Enable"};
+ C8_T stype[3][5] = {"Bcst", "Mcst", "Ucst"};
+
+ port = _strtol(argv[0], NULL, 10);
+ type = _strtol(argv[1], NULL, 10);
+ if(3 == argc)
+ {
+ en = _strtol(argv[2], NULL, 10);
+ ret = air_sec_setStormEnable(0, port, type, en);
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("Set Port%02d %s storm %s Success.\n", port, stype[type], sen[en]);
+ }
+ else
+ {
+ AIR_PRINT("Set Port%02d %s storm %s Fail.\n", port, stype[type], sen[en]);
+ }
+ }
+ else if(2 == argc)
+ {
+ ret = air_sec_getStormEnable(0, port, type, &en);
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("Port%02d %s storm %s\n", port, stype[type], sen[en]);
+ }
+ else
+ {
+ AIR_PRINT("Get Port%02d %s storm Fail\n", port, stype[type]);
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doSaLearning(UI32_T argc, C8_T *argv[])
+{
+ UI32_T port = 0;
+ AIR_SEC_PORTSEC_PORT_CONFIG_T port_config;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ port = _strtoul(argv[0], NULL, 0);
+ if(2 == argc)
+ {
+ memset(&port_config, 0, sizeof(AIR_SEC_PORTSEC_PORT_CONFIG_T));
+ rc = air_sec_getPortSecPortCfg(0, port, &port_config);
+ port_config.sa_lrn_en = _strtoul(argv[1], NULL, 0);
+ rc = air_sec_setPortSecPortCfg(0, port, port_config);
+ if(AIR_E_OK == rc)
+ {
+ AIR_PRINT("Set Port%02d sa learn %s Success.\n", port, port_config.sa_lrn_en?"Enable":"Disable");
+ }
+ else
+ {
+ AIR_PRINT("Set Port%02d sa learn %s Fail.\n", port, port_config.sa_lrn_en?"Enable":"Disable");
+ }
+ }
+ else if(1 == argc)
+ {
+ rc = air_sec_getPortSecPortCfg(0, port, &port_config);
+ if(AIR_E_OK == rc)
+ {
+ AIR_PRINT("Port%02d sa learn: %s\n", port, port_config.sa_lrn_en?"Enable":"Disable");
+ }
+ else
+ {
+ AIR_PRINT("Get Port%02d sa learn Fail\n", port);
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ rc = AIR_E_BAD_PARAMETER;
+ }
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doSaLimit(UI32_T argc, C8_T *argv[])
+{
+ UI32_T port = 0;
+ AIR_SEC_PORTSEC_PORT_CONFIG_T port_config;
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+
+ port = _strtoul(argv[0], NULL, 0);
+ if(3 == argc)
+ {
+ memset(&port_config, 0, sizeof(AIR_SEC_PORTSEC_PORT_CONFIG_T));
+ rc = air_sec_getPortSecPortCfg(0, port, &port_config);
+ port_config.sa_lmt_en = _strtoul(argv[1], NULL, 0);
+ port_config.sa_lmt_cnt = _strtoul(argv[2], NULL, 0);
+ rc = air_sec_setPortSecPortCfg(0, port, port_config);
+ if(AIR_E_OK == rc)
+ {
+ AIR_PRINT("Set Port%02d sa limit %s Success.\n", port, port_config.sa_lmt_en?"Enable":"Disable");
+ }
+ else
+ {
+ AIR_PRINT("Set Port%02d sa limit %s Fail.\n", port, port_config.sa_lmt_en?"Enable":"Disable");
+ }
+ }
+ else if(1 == argc)
+ {
+ rc = air_sec_getPortSecPortCfg(0, port, &port_config);
+ if(AIR_E_OK == rc)
+ {
+ AIR_PRINT("Port%02d ", port);
+ AIR_PRINT("sa limit: %s\n", port_config.sa_lmt_en?"Enable":"Disable");
+ if(TRUE == (port_config.sa_lmt_en && (AIR_MAX_NUM_OF_MAC == port_config.sa_lmt_cnt)))
+ {
+ AIR_PRINT("Sa learning without limitation\n");
+ }
+ else if(TRUE == (port_config.sa_lmt_en && (AIR_MAX_NUM_OF_MAC > port_config.sa_lmt_cnt)))
+ {
+ AIR_PRINT("Rx sa allowable learning number: %d\n", port_config.sa_lmt_cnt);
+ }
+ }
+ else
+ {
+ AIR_PRINT("Get Port%02d sa limit Fail\n", port);
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ rc = AIR_E_BAD_PARAMETER;
+ }
+
+ return rc;
+}
+
+static AIR_ERROR_NO_T
+doSecGet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(secGetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doSecSet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(secSetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doSec(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(secCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doSwitchCpuPortEn(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ BOOL_T cpu_en = FALSE;
+
+ if(0 == argc)
+ {
+ /* switch get sysPhyEn */
+ ret = air_switch_getCpuPortEn(0, &cpu_en);
+ AIR_PRINT("Get Cpu Port State ");
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT(": %s\n", cpu_en?"Enable":"Disable");
+ }
+ else
+ {
+ AIR_PRINT("Fail!\n");
+ }
+ }
+ else if(1 == argc)
+ {
+ /* switch set sysPhyEn <phy_en> */
+ cpu_en = _strtol(argv[0], NULL, 0);
+ ret = air_switch_setCpuPortEn(0, cpu_en);
+ AIR_PRINT("Set CPU port State ");
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT(": %s\n", cpu_en?"Enable":"Disable");
+ }
+ else
+ {
+ AIR_PRINT("Fail!\n");
+ }
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doSwitchCpuPort(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ BOOL_T cpu_en = FALSE;
+ UI32_T port = 0;
+ C8_T str_temp[AIR_MAX_NUM_OF_PORTS+1];
+
+ if(1 == argc)
+ {
+ /* switch set cpuPort <portnumber> */
+ port = _strtol(argv[0], NULL, 10);
+ ret = air_switch_setCpuPort(0, port);
+ AIR_PRINT("Set CPU Port ");
+ }
+ else if(0 == argc)
+ {
+ /* switch get cpuPort */
+ ret = air_switch_getCpuPort(0, &port);
+ AIR_PRINT("Get CPU Port ");
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT(": %d\n", port);
+ }
+ else
+ {
+ AIR_PRINT("Fail!\n");
+ }
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doSwitchPhyLCIntrEn(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T phy = 0;
+ BOOL_T enable = FALSE;
+
+ if(2 == argc)
+ {
+ /* switch set phyLCIntrEn <phy(0..6)> <(1:En,0:Dis)> */
+ phy = _strtol(argv[0], NULL, 10);
+ enable = _strtol(argv[1], NULL, 10);
+ ret = air_switch_setSysIntrEn(0, (phy + AIR_SYS_INTR_TYPE_PHY0_LC), enable);
+ }
+ else if(1 == argc)
+ {
+ /* switch get phyLCIntrEn <phy(0..6)> */
+ phy = _strtol(argv[0], NULL, 10);
+ ret = air_switch_getSysIntrEn(0, (phy + AIR_SYS_INTR_TYPE_PHY0_LC), &enable);
+ AIR_PRINT("PHY(%d) LinkChange interrupt : %s\n", phy, (TRUE == enable) ? "enable" : "disable");
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doSwitchPhyLCIntrSts(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T phy = 0;
+ BOOL_T enable = FALSE;
+
+ if(2 == argc)
+ {
+ /* switch set phyLCIntrSts <phy(0..6)> <(1:En)> */
+ phy = _strtol(argv[0], NULL, 10);
+ enable = _strtol(argv[1], NULL, 10);
+ ret = air_switch_setSysIntrStatus(0, (phy + AIR_SYS_INTR_TYPE_PHY0_LC), enable);
+ }
+ else if(1 == argc)
+ {
+ /* switch get phyLCIntrSts <phy(0..6)> */
+ phy = _strtol(argv[0], NULL, 10);
+ ret = air_switch_getSysIntrStatus(0, (phy + AIR_SYS_INTR_TYPE_PHY0_LC), &enable);
+ AIR_PRINT("PHY(%d) LinkChange interrupt state : %s\n", phy, (TRUE == enable) ? "set" : "unset");
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ ret = AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+
+static AIR_ERROR_NO_T
+doSwitchSet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(switchSetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doSwitchGet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(switchGetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doSwitch(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(switchCmds, argc, argv);
+}
+
+static void _air_acl_printRuleMap(UI32_T *rule_map, UI32_T ary_num)
+{
+ UI32_T i;
+ BOOL_T first;
+
+ first = TRUE;
+ for(i=0; i<ary_num*32; i++)
+ {
+ if(rule_map[i/32] & BIT(i%32))
+ {
+ if(TRUE == first)
+ {
+ AIR_PRINT("%u", i);
+ first = FALSE;
+ }
+ else
+ {
+ AIR_PRINT(",%u", i);
+ }
+ }
+ }
+ AIR_PRINT("\n");
+}
+
+static AIR_ERROR_NO_T
+doAclEn(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T argi=0;
+ UI32_T port = 0;
+ BOOL_T en = FALSE;
+
+ if(1 == argc)
+ {
+ /* acl set en <en(1:En,0:Dis)> */
+ en = _strtoul(argv[argi++], NULL, 2);
+ ret = air_acl_setGlobalState(0, en);
+ AIR_PRINT("Set Global ACL function ");
+ }
+ else if(0 == argc)
+ {
+ /* acl get en */
+ ret = air_acl_getGlobalState(0, &en);
+ AIR_PRINT("Get Global ACL function ");
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT(": %s\n", (TRUE == en)?"Enable":"Disable");
+ }
+ else
+ {
+ AIR_PRINT("Fail!\n");
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doAclRule(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T rule_idx = 0;
+ BOOL_T state = FALSE, reverse = FALSE, end = FALSE;
+ UI32_T argi = 0, ipv6 = 0, i = 0;
+ AIR_ACL_RULE_T rule;
+ UI8_T tmp_ip[16] = {0};
+ C8_T str_temp[AIR_MAX_NUM_OF_PORTS+1];
+ C8_T str[40];
+
+ memset(&rule, 0, sizeof(AIR_ACL_RULE_T));
+ if(argc >= 6)
+ {
+ /* acl set rule <idx(0..255)> <state(0:Dis,1:En)> <reverse(0:Dis,1:En)> <end(0:Dis,1:En)> <portmap(7'bin)>
+ <ipv6(0:Dis,1:En,2:Not care)>
+ [ dmac <dmac(12'hex)> <dmac_mask(12'hex)> ]
+ [ smac <smac(12'hex)> <smac_mask(12'hex)> ]
+ [ stag <stag(4'hex)> <stag_mask(4'hex)> ]
+ [ ctag <ctag(4'hex)> <ctag_mask(4'hex)> ]
+ [ etype <etype(4'hex)> <etype_mask(4'hex)> ]
+ [ dip <dip(IPADDR)> <dip_mask(IPADDR)> ]
+ [ sip <sip(IPADDR)> <sip_mask(IPADDR)> ]
+ [ dscp <dscp(2'hex)> <dscp_mask(2'hex)> ]
+ [ protocol <protocol(2'hex)> <protocol_mask(2'hex)> ]
+ [ dport <dport(4'hex)> <dport_mask(4'hex)> ]
+ [ sport <sport(4'hex)> <sport_mask(4'hex)> ]
+ [ flow_label <flow_label(4'hex)> <flow_label_mask(4'hex)> ]
+ [ udf <udf(4'hex)> <udf_mask(4'hex)> ] */
+
+ rule_idx = _strtoul(argv[argi++], NULL, 0);
+
+ rule.ctrl.rule_en = _strtoul(argv[argi++], NULL, 0);
+ rule.ctrl.reverse = _strtoul(argv[argi++], NULL, 0);
+ rule.ctrl.end = _strtoul(argv[argi++], NULL, 0);
+
+ rule.key.portmap = _strtoul(argv[argi++], NULL, 2);
+ rule.mask.portmap = (~rule.key.portmap) & AIR_ALL_PORT_BITMAP;
+
+ ipv6 = _strtoul(argv[argi++], NULL, 0);
+ if(0 == ipv6)
+ {
+ rule.key.isipv6 = FALSE;
+ rule.mask.isipv6 = TRUE;
+ }
+ else if(1 == ipv6)
+ {
+ rule.key.isipv6 = TRUE;
+ rule.mask.isipv6 = TRUE;
+ }
+ else
+ {
+ rule.mask.isipv6 = FALSE;
+ }
+
+ if((argi < argc) && (0 == _strcmp(argv[argi], "dmac")))
+ {
+ argi++;
+ _str2mac(argv[argi++], rule.key.dmac);
+ _str2mac(argv[argi++], rule.mask.dmac);
+ rule.key.fieldmap |= 1 << AIR_ACL_DMAC;
+ }
+ if((argi < argc) && (0 == _strcmp(argv[argi], "smac")))
+ {
+ argi++;
+ _str2mac(argv[argi++], rule.key.smac);
+ _str2mac(argv[argi++], rule.mask.smac);
+ rule.key.fieldmap |= 1 << AIR_ACL_SMAC;
+ }
+
+ if((argi < argc) && (0 == _strcmp(argv[argi], "stag")))
+ {
+ argi++;
+ rule.key.stag = _strtoul(argv[argi++], NULL, 16);
+ rule.mask.stag = _strtoul(argv[argi++], NULL, 16);
+ rule.key.fieldmap |= 1 << AIR_ACL_STAG;
+ }
+
+ if((argi < argc) && (0 == _strcmp(argv[argi], "ctag")))
+ {
+ argi++;
+ rule.key.ctag = _strtoul(argv[argi++], NULL, 16);
+ rule.mask.ctag = _strtoul(argv[argi++], NULL, 16);
+ rule.key.fieldmap |= 1 << AIR_ACL_CTAG;
+ }
+
+ if((argi < argc) && (0 == _strcmp(argv[argi], "etype")))
+ {
+ argi++;
+ rule.key.etype= _strtoul(argv[argi++], NULL, 16);
+ rule.mask.etype = _strtoul(argv[argi++], NULL, 16);
+ rule.key.fieldmap |= 1 << AIR_ACL_ETYPE;
+ }
+
+ if((argi < argc) && (0 == _strcmp(argv[argi], "dip")))
+ {
+ argi++;
+ if(0 == ipv6)
+ {
+ _str2ipv4(argv[argi++], rule.key.dip);
+ _str2ipv4(argv[argi++], rule.mask.dip);
+ }
+ else if(1 == ipv6)
+ {
+ _str2ipv6(argv[argi++], tmp_ip);
+ rule.key.dip[3] = (tmp_ip[0]<<24) | (tmp_ip[1]<<16) | (tmp_ip[2]<<8) | tmp_ip[3];
+ rule.key.dip[2] = (tmp_ip[4]<<24) | (tmp_ip[5]<<16) | (tmp_ip[6]<<8) | tmp_ip[7];
+ rule.key.dip[1] = (tmp_ip[8]<<24) | (tmp_ip[9]<<16) | (tmp_ip[10]<<8) | tmp_ip[11];
+ rule.key.dip[0] = (tmp_ip[12]<<24) | (tmp_ip[13]<<16) | (tmp_ip[14]<<8) | tmp_ip[15];
+ _str2ipv6(argv[argi++], tmp_ip);
+ rule.mask.dip[3] = (tmp_ip[0]<<24) | (tmp_ip[1]<<16) | (tmp_ip[2]<<8) | tmp_ip[3];
+ rule.mask.dip[2] = (tmp_ip[4]<<24) | (tmp_ip[5]<<16) | (tmp_ip[6]<<8) | tmp_ip[7];
+ rule.mask.dip[1] = (tmp_ip[8]<<24) | (tmp_ip[9]<<16) | (tmp_ip[10]<<8) | tmp_ip[11];
+ rule.mask.dip[0] = (tmp_ip[12]<<24) | (tmp_ip[13]<<16) | (tmp_ip[14]<<8) | tmp_ip[15];
+ }
+ rule.key.fieldmap |= 1 << AIR_ACL_DIP;
+ }
+
+ if((argi < argc) && (0 == _strcmp(argv[argi], "sip")))
+ {
+ argi++;
+ if(0 == ipv6)
+ {
+ _str2ipv4(argv[argi++], rule.key.sip);
+ _str2ipv4(argv[argi++], rule.mask.sip);
+ }
+ else if(1 == ipv6)
+ {
+ _str2ipv6(argv[argi++], tmp_ip);
+ rule.key.sip[3] = (tmp_ip[0]<<24) | (tmp_ip[1]<<16) | (tmp_ip[2]<<8) | tmp_ip[3];
+ rule.key.sip[2] = (tmp_ip[4]<<24) | (tmp_ip[5]<<16) | (tmp_ip[6]<<8) | tmp_ip[7];
+ rule.key.sip[1] = (tmp_ip[8]<<24) | (tmp_ip[9]<<16) | (tmp_ip[10]<<8) | tmp_ip[11];
+ rule.key.sip[0] = (tmp_ip[12]<<24) | (tmp_ip[13]<<16) | (tmp_ip[14]<<8) | tmp_ip[15];
+ _str2ipv6(argv[argi++], tmp_ip);
+ rule.mask.sip[3] = (tmp_ip[0]<<24) | (tmp_ip[1]<<16) | (tmp_ip[2]<<8) | tmp_ip[3];
+ rule.mask.sip[2] = (tmp_ip[4]<<24) | (tmp_ip[5]<<16) | (tmp_ip[6]<<8) | tmp_ip[7];
+ rule.mask.sip[1] = (tmp_ip[8]<<24) | (tmp_ip[9]<<16) | (tmp_ip[10]<<8) | tmp_ip[11];
+ rule.mask.sip[0] = (tmp_ip[12]<<24) | (tmp_ip[13]<<16) | (tmp_ip[14]<<8) | tmp_ip[15];
+ }
+ rule.key.fieldmap |= 1 << AIR_ACL_SIP;
+ }
+
+ if((argi < argc) && (0 == _strcmp(argv[argi], "dscp")))
+ {
+ argi++;
+ rule.key.dscp = _strtoul(argv[argi++], NULL, 16);
+ rule.mask.dscp = _strtoul(argv[argi++], NULL, 16);
+ rule.key.fieldmap |= 1 << AIR_ACL_DSCP;
+ }
+
+ if((argi < argc) && (0 == _strcmp(argv[argi], "protocol")))
+ {
+ argi++;
+ rule.key.protocol = _strtoul(argv[argi++], NULL, 16);
+ rule.mask.protocol = _strtoul(argv[argi++], NULL, 16);
+ rule.key.fieldmap |= 1 << AIR_ACL_PROTOCOL;
+ }
+
+ if((argi < argc) && (0 == _strcmp(argv[argi], "dport")))
+ {
+ argi++;
+ rule.key.dport = _strtoul(argv[argi++], NULL, 16);
+ rule.mask.dport = _strtoul(argv[argi++], NULL, 16);
+ rule.key.fieldmap |= 1 << AIR_ACL_DPORT;
+ }
+
+ if((argi < argc) && (0 == _strcmp(argv[argi], "sport")))
+ {
+ argi++;
+ rule.key.sport = _strtoul(argv[argi++], NULL, 16);
+ rule.mask.sport = _strtoul(argv[argi++], NULL, 16);
+ rule.key.fieldmap |= 1 << AIR_ACL_SPORT;
+ }
+
+ if((argi < argc) && (0 == _strcmp(argv[argi], "flow_label")))
+ {
+ argi++;
+ rule.key.flow_label= _strtoul(argv[argi++], NULL, 16);
+ rule.mask.flow_label= _strtoul(argv[argi++], NULL, 16);
+ rule.key.fieldmap |= 1 << AIR_ACL_FLOW_LABEL;
+ }
+
+ if((argi < argc) && (0 == _strcmp(argv[argi], "udf")))
+ {
+ argi++;
+ rule.key.udf = _strtoul(argv[argi++], NULL, 16);
+ rule.mask.udf = _strtoul(argv[argi++], NULL, 16);
+ rule.key.fieldmap |= 1 << AIR_ACL_UDF;
+ }
+ rule.mask.fieldmap = rule.key.fieldmap;
+ ret = air_acl_setRule(0, rule_idx, &rule);
+ if(ret < AIR_E_LAST)
+ AIR_PRINT("Set ACL Rule(%u): %s\n", rule_idx, air_error_getString(ret));
+ }
+ else if(1 == argc)
+ {
+ rule_idx = _strtoul(argv[0], NULL, 0);
+ ret = air_acl_getRule(0, rule_idx, &rule);
+ if(ret < AIR_E_LAST)
+ AIR_PRINT("Get ACL Rule(%u): %s\n", rule_idx, air_error_getString(ret));
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+
+ if(AIR_E_OK == ret)
+ {
+ if(TRUE == rule.ctrl.rule_en)
+ {
+ AIR_PRINT("\t Rule end : %s\n", (TRUE == rule.ctrl.end)?"Enable":"Disable");
+ AIR_PRINT("\t Rule reverse : %s\n", (TRUE == rule.ctrl.reverse)?"Enable":"Disable");
+ _hex2bitstr((~rule.mask.portmap) & AIR_ALL_PORT_BITMAP, str_temp, AIR_MAX_NUM_OF_PORTS+1);
+ AIR_PRINT("\t Portmap[0:6] : %s\n", str_temp);
+ for(i = AIR_ACL_DMAC; i < AIR_ACL_FIELD_TYPE_LAST; i++)
+ {
+ if((1 << i) & rule.mask.fieldmap)
+ {
+ switch (i)
+ {
+ case AIR_ACL_DMAC:
+ AIR_PRINT("\t dmac: ");
+ AIR_PRINT("%02x-%02x-%02x-%02x-%02x-%02x",
+ rule.key.dmac[0], rule.key.dmac[1], rule.key.dmac[2],
+ rule.key.dmac[3], rule.key.dmac[4], rule.key.dmac[5]);
+ AIR_PRINT(", dmac-mask: ");
+ AIR_PRINT("%02x-%02x-%02x-%02x-%02x-%02x\n",
+ rule.mask.dmac[0], rule.mask.dmac[1], rule.mask.dmac[2],
+ rule.mask.dmac[3], rule.mask.dmac[4], rule.mask.dmac[5]);
+ break;
+ case AIR_ACL_SMAC:
+ AIR_PRINT("\t smac: ");
+ AIR_PRINT("%02x-%02x-%02x-%02x-%02x-%02x",
+ rule.key.smac[0], rule.key.smac[1], rule.key.smac[2],
+ rule.key.smac[3], rule.key.smac[4], rule.key.smac[5]);
+ AIR_PRINT(", smac-mask: ");
+ AIR_PRINT("%02x-%02x-%02x-%02x-%02x-%02x\n",
+ rule.mask.smac[0], rule.mask.smac[1], rule.mask.smac[2],
+ rule.mask.smac[3], rule.mask.smac[4], rule.mask.smac[5]);
+ break;
+ case AIR_ACL_ETYPE:
+ AIR_PRINT("\t etype: 0x%x, etype-mask: 0x%x\n", rule.key.etype, rule.mask.etype);
+ break;
+ case AIR_ACL_STAG:
+ AIR_PRINT("\t stag: 0x%x, stag-mask: 0x%x\n", rule.key.stag, rule.mask.stag);
+ break;
+ case AIR_ACL_CTAG:
+ AIR_PRINT("\t ctag: 0x%x, ctag-mask: 0x%x\n", rule.key.ctag, rule.mask.ctag);
+ break;
+ case AIR_ACL_DPORT:
+ AIR_PRINT("\t dport: 0x%x, dport-mask: 0x%x\n", rule.key.dport, rule.mask.dport);
+ break;
+ case AIR_ACL_SPORT:
+ AIR_PRINT("\t sport: 0x%x, sport-mask: 0x%x\n", rule.key.sport, rule.mask.sport);
+ break;
+ case AIR_ACL_UDF:
+ AIR_PRINT("\t udf: 0x%x, udf-mask: 0x%x\n", rule.key.udf, rule.mask.udf);
+ break;
+ case AIR_ACL_DIP:
+ if (0 == rule.key.isipv6)
+ {
+ AIR_PRINT("\t dip: ");
+ AIR_PRINT("%d.%d.%d.%d",
+ ((rule.key.dip[0])&0xFF000000)>>24,((rule.key.dip[0])&0x00FF0000)>>16,
+ ((rule.key.dip[0])&0x0000FF00)>>8, ((rule.key.dip[0])&0x000000FF));
+ AIR_PRINT(", dip-mask: ");
+ AIR_PRINT("%d.%d.%d.%d\n ",
+ ((rule.mask.dip[0])&0xFF000000)>>24,((rule.mask.dip[0])&0x00FF0000)>>16,
+ ((rule.mask.dip[0])&0x0000FF00)>>8, ((rule.mask.dip[0])&0x000000FF));
+ }
+ else
+ {
+ for(i=0; i<4; i++){
+ tmp_ip[i] = (rule.key.dip[3] >> (8*(3-i))) & 0xff;
+ AIR_PRINT("get tmp_ip[%d]=0x%x\n", i, tmp_ip[i]);
+ }
+ for(i=4; i<8; i++){
+ tmp_ip[i] = (rule.key.dip[2] >> (8*(7-i))) & 0xff;
+ }
+ for(i=8; i<12; i++){
+ tmp_ip[i] = (rule.key.dip[1] >> (8*(11-i))) & 0xff;
+ }
+ for(i=12; i<16; i++){
+ tmp_ip[i] = (rule.key.dip[0] >> (8*(15-i))) & 0xff;
+ }
+
+ AIR_PRINT("\t dip: ");
+ AIR_PRINT("%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
+ tmp_ip[0], tmp_ip[1],tmp_ip[2], tmp_ip[3],tmp_ip[4], tmp_ip[5],tmp_ip[6], tmp_ip[7],
+ tmp_ip[8], tmp_ip[9],tmp_ip[10], tmp_ip[11],tmp_ip[12], tmp_ip[13],tmp_ip[14], tmp_ip[15]);
+ for(i=0; i<4; i++){
+ tmp_ip[i] = (rule.mask.dip[3] >> (8*(3-i))) & 0xff;
+ }
+ for(i=4; i<8; i++){
+ tmp_ip[i] = (rule.mask.dip[2] >> (8*(7-i))) & 0xff;
+ }
+ for(i=8; i<12; i++){
+ tmp_ip[i] = (rule.mask.dip[1] >> (8*(11-i))) & 0xff;
+ }
+ for(i=12; i<16; i++){
+ tmp_ip[i] = (rule.mask.dip[0] >> (8*(15-i))) & 0xff;
+ }
+ AIR_PRINT(", dip-mask: ");
+ AIR_PRINT("%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
+ tmp_ip[0], tmp_ip[1],tmp_ip[2], tmp_ip[3],tmp_ip[4], tmp_ip[5],tmp_ip[6], tmp_ip[7],
+ tmp_ip[8], tmp_ip[9],tmp_ip[10], tmp_ip[11],tmp_ip[12], tmp_ip[13],tmp_ip[14], tmp_ip[15]);
+ }
+ break;
+ case AIR_ACL_SIP:
+ if (0 == rule.key.isipv6)
+ {
+ AIR_PRINT("\t sip: ");
+ AIR_PRINT("%d.%d.%d.%d ",
+ ((rule.key.sip[0])&0xFF000000)>>24,((rule.key.sip[0])&0x00FF0000)>>16,
+ ((rule.key.sip[0])&0x0000FF00)>>8, ((rule.key.sip[0])&0x000000FF));
+ AIR_PRINT(", sip-mask: ");
+ AIR_PRINT("%d.%d.%d.%d\n ",
+ ((rule.mask.sip[0])&0xFF000000)>>24,((rule.mask.sip[0])&0x00FF0000)>>16,
+ ((rule.mask.sip[0])&0x0000FF00)>>8, ((rule.mask.sip[0])&0x000000FF));
+ }
+ else
+ {
+ for(i=0; i<4; i++){
+ tmp_ip[i] = (rule.key.sip[3] >> (8*(3-i))) & 0xff;
+ }
+ for(i=4; i<8; i++){
+ tmp_ip[i] = (rule.key.sip[2] >> (8*(7-i))) & 0xff;
+ }
+ for(i=8; i<12; i++){
+ tmp_ip[i] = (rule.key.sip[1] >> (8*(11-i))) & 0xff;
+ }
+ for(i=12; i<16; i++){
+ tmp_ip[i] = (rule.key.sip[0] >> (8*(15-i))) & 0xff;
+ }
+ AIR_PRINT("\t sip: ");
+ AIR_PRINT("%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
+ tmp_ip[0], tmp_ip[1],tmp_ip[2], tmp_ip[3],tmp_ip[4], tmp_ip[5],tmp_ip[6], tmp_ip[7],
+ tmp_ip[8], tmp_ip[9],tmp_ip[10], tmp_ip[11],tmp_ip[12], tmp_ip[13],tmp_ip[14], tmp_ip[15]);
+ for(i=0; i<4; i++){
+ tmp_ip[i] = (rule.mask.sip[3] >> (8*(3-i))) & 0xff;
+ }
+ for(i=4; i<8; i++){
+ tmp_ip[i] = (rule.mask.sip[2] >> (8*(7-i))) & 0xff;
+ }
+ for(i=8; i<12; i++){
+ tmp_ip[i] = (rule.mask.sip[1] >> (8*(11-i))) & 0xff;
+ }
+ for(i=12; i<16; i++){
+ tmp_ip[i] = (rule.mask.sip[0] >> (8*(15-i))) & 0xff;
+ }
+ AIR_PRINT(", sip-mask: ");
+ AIR_PRINT("%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
+ tmp_ip[0], tmp_ip[1],tmp_ip[2], tmp_ip[3],tmp_ip[4], tmp_ip[5],tmp_ip[6], tmp_ip[7],
+ tmp_ip[8], tmp_ip[9],tmp_ip[10], tmp_ip[11],tmp_ip[12], tmp_ip[13],tmp_ip[14], tmp_ip[15]);
+ }
+ break;
+ case AIR_ACL_DSCP:
+ AIR_PRINT("\t dscp: 0x%x, dscp-mask: 0x%x\n", rule.key.dscp, rule.mask.dscp);
+ break;
+ case AIR_ACL_PROTOCOL:
+ AIR_PRINT("\t protocol: 0x%x, protocol-mask: 0x%x\n", rule.key.protocol, rule.mask.protocol);
+ break;
+ case AIR_ACL_FLOW_LABEL:
+ AIR_PRINT("\t flow-label: 0x%x, flow-label-mask: 0x%x\n", rule.key.flow_label, rule.mask.flow_label);
+ break;
+ default:
+ AIR_PRINT("error\n");
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ AIR_PRINT("Entry is Invalid.\n");
+ }
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doAclRmvRule(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T rule_idx = 0;
+
+ if(1 == argc)
+ {
+ /* acl del rule <idx(0..127)> */
+ rule_idx = _strtoul(argv[0], NULL, 0);
+ ret = air_acl_delRule(0, rule_idx);
+ if(ret < AIR_E_LAST)
+ AIR_PRINT("Delete ACL Rule(%u): %s\n", rule_idx, air_error_getString(ret));
+ }
+ else if(0 == argc)
+ {
+ /* acl clear rule */
+ ret = air_acl_clearRule(0);
+ if(ret < AIR_E_LAST)
+ AIR_PRINT("Clear ACL Rule: %s\n", air_error_getString(ret));
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doAclUdfRule(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T rule_idx;
+ AIR_ACL_UDF_RULE_T rule;
+ C8_T start_addr[8][12]=
+ {
+ "MAC header",
+ "L2 payload",
+ "IPv4 header",
+ "IPv6 header",
+ "L3 payload",
+ "TCP header",
+ "UDP header",
+ "L4 payload"
+ };
+ C8_T str_temp[AIR_MAX_NUM_OF_PORTS+1];
+
+ memset(&rule, 0, sizeof(AIR_ACL_UDF_RULE_T));
+ if(7 == argc)
+ {
+ /* acl set rule <idx(0..255)> <mode(0:pattern, 1:threshold)> [ <pat(4'hex)> <mask(4'hex)> | <low(4'hex)> <high(4'hex)> ] <start(0:MAC,1:ether,2:IP,3:IP_data,4:TCP/UDP,5:TCP/UDP data,6:IPv6)> <offset(0..62,unit:2 bytes)> <portmap(7'bin)> */
+ rule_idx = _strtoul(argv[0], NULL, 0);
+ rule.cmp_sel = _strtoul(argv[1], NULL, 2);
+ if(AIR_ACL_RULE_CMP_SEL_PATTERN == rule.cmp_sel)
+ {
+ rule.pattern = _strtoul(argv[2], NULL, 16);
+ rule.mask = _strtoul(argv[3], NULL, 16);
+ }
+ else
+ {
+ rule.low_threshold = _strtoul(argv[2], NULL, 16);
+ rule.high_threshold = _strtoul(argv[3], NULL, 16);
+ }
+ rule.offset_format = _strtoul(argv[4], NULL, 0);
+ rule.offset = _strtoul(argv[5], NULL, 0);
+ rule.portmap = _strtoul(argv[6], NULL, 2);
+ rule.valid = TRUE;
+ ret = air_acl_setUdfRule(0, rule_idx, rule);
+ if(ret < AIR_E_LAST)
+ AIR_PRINT("Set ACL UDF Rule(%u): %s\n", rule_idx, air_error_getString(ret));
+ }
+ else if(1 == argc)
+ {
+ rule_idx = _strtoul(argv[0], NULL, 0);
+ ret = air_acl_getUdfRule(0, rule_idx, &rule);
+ if(ret < AIR_E_LAST)
+ AIR_PRINT("Get ACL UDF Rule(%u): %s\n", rule_idx, air_error_getString(ret));
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+
+ if(AIR_E_OK == ret)
+ {
+ if(TRUE == rule.valid)
+ {
+ AIR_PRINT("\tMode : %s\n", (AIR_ACL_RULE_CMP_SEL_PATTERN == rule.cmp_sel)?"Pattern":"Threshold");
+ if(AIR_ACL_RULE_CMP_SEL_PATTERN == rule.cmp_sel)
+ {
+ AIR_PRINT("\tPattern : 0x%04X\n", rule.pattern);
+ AIR_PRINT("\tMask : 0x%04X\n", rule.mask);
+ }
+ else
+ {
+ AIR_PRINT("\tLow Threshold : 0x%04X\n", rule.low_threshold);
+ AIR_PRINT("\tHigh Threshold: 0x%04X\n", rule.high_threshold);
+ }
+ AIR_PRINT("\tOffset Start : %s\n", start_addr[rule.offset_format]);
+ AIR_PRINT("\tOffset : %u %s\n", rule.offset*2, (0==rule.offset)?"Byte":"Bytes");
+ _hex2bitstr(rule.portmap, str_temp, AIR_MAX_NUM_OF_PORTS+1);
+ AIR_PRINT("\tPortmap[0:6] : %s\n", str_temp);
+ }
+ else
+ {
+ AIR_PRINT("Entry is Invalid.\n");
+ }
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doAclRmvUdfRule(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T rule_idx;
+
+ if(1 == argc)
+ {
+ /* acl del udfRule <idx(0..15)> */
+ rule_idx = _strtoul(argv[0], NULL, 0);
+ ret = air_acl_delUdfRule(0, rule_idx);
+ if(ret < AIR_E_LAST)
+ AIR_PRINT("Delete ACL UDF Rule(%u): %s\n", rule_idx, air_error_getString(ret));
+ }
+ else if(0 == argc)
+ {
+ /* acl clear udfRule */
+ ret = air_acl_clearUdfRule(0);
+ if(ret < AIR_E_LAST)
+ AIR_PRINT("Clear ACL UDF Rule: %s\n", air_error_getString(ret));
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doAclAction(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T argi = 0;
+ UI32_T act_idx;
+ AIR_ACL_ACTION_T act;
+ UI32_T redirect, trtcm, fwd;
+ C8_T fwding[AIR_ACL_ACT_FWD_LAST][25] =
+ {
+ "Default",
+ "Default",
+ "Default",
+ "Default",
+ "Default & CPU excluded",
+ "Default & CPU included",
+ "CPU only",
+ "Drop"
+ };
+ C8_T trtcm_usr[AIR_ACL_ACT_USR_TCM_LAST][8] =
+ {
+ "Default",
+ "Green",
+ "Yellow",
+ "Red"
+ };
+ C8_T egtag[AIR_ACL_ACT_EGTAG_LAST][11] =
+ {
+ "Default",
+ "Consistent",
+ "",
+ "",
+ "Untag",
+ "Swap",
+ "Tag",
+ "Stack"
+ };
+ C8_T str_temp[20];
+
+ memset(&act, 0, sizeof(AIR_ACL_ACTION_T));
+ if(2 < argc)
+ {
+ /* acl set action <idx(0..127)>
+ [ forward <forward(0:Default,4:Exclude CPU,5:Include CPU,6:CPU only,7:Drop)> ]
+ [ egtag <egtag(0:Default,1:Consistent,4:Untag,5:Swap,6:Tag,7:Stack)> ]
+ [ mirrormap <mirrormap(2'bin)> ]
+ [ priority <priority(0..7)> ]
+ [ redirect <redirect(0:Dst,1:Vlan)> <portmap(7'bin)> ]
+ [ leaky_vlan <leaky_vlan(1:En,0:Dis)> ]
+ [ cnt_idx <cnt_idx(0..63)> ]
+ [ rate_idx <rate_idx(0..31)> ]
+ [ attack_idx <attack_idx(0..95)> ]
+ [ vid <vid(0..4095)> ]
+ [ manage <manage(1:En,0:Dis)> ]
+ [ bpdu <bpdu(1:En,0:Dis)> ]
+ [ class <class(0:Original,1:Defined)>[0..7] ]
+ [ drop_pcd <drop_pcd(0:Original,1:Defined)> [red <red(0..7)>][yellow <yellow(0..7)>][green <green(0..7)>] ]
+ [ color <color(0:Defined,1:Trtcm)> [ <defined_color(0:Dis,1:Green,2:Yellow,3:Red)> | <trtcm_idx(0..31)> ] ]*/
+
+ act_idx = _strtoul(argv[argi++], NULL, 0);
+ if((argi < argc) && (0 == _strcmp(argv[argi], "forward")))
+ {
+ argi++;
+ fwd = _strtoul(argv[argi++], NULL, 0);
+ act.fwd_en = TRUE;
+ act.fwd = fwd;
+ }
+
+ if((argi < argc) && (0 == _strcmp(argv[argi], "egtag")))
+ {
+ argi++;
+ act.egtag_en = TRUE;
+ act.egtag = _strtoul(argv[argi++], NULL, 0);
+ }
+
+ if((argi < argc) && (0 == _strcmp(argv[argi], "mirrormap")))
+ {
+ argi++;
+ act.mirrormap = _strtoul(argv[argi++], NULL, 2);
+ }
+
+ if((argi < argc) && (0 == _strcmp(argv[argi], "priority")))
+ {
+ argi++;
+ act.pri_user_en = TRUE;
+ act.pri_user= _strtoul(argv[argi++], NULL, 0);
+ }
+
+ if((argi < argc) && (0 == _strcmp(argv[argi], "redirect")))
+ {
+ argi++;
+ redirect = _strtoul(argv[argi++], NULL, 0);
+ if(0 == redirect)
+ {
+ act.port_en = TRUE;
+ act.dest_port_sel = TRUE;
+ act.portmap = _strtoul(argv[argi++], NULL, 2);
+ }
+ else
+ {
+ act.port_en = TRUE;
+ act.vlan_port_sel = TRUE;
+ act.portmap = _strtoul(argv[argi++], NULL, 2);
+ }
+ }
+
+ if((argi < argc) && (0 == _strcmp(argv[argi], "leaky_vlan")))
+ {
+ argi++;
+ act.lyvlan_en = TRUE;
+ act.lyvlan = _strtoul(argv[argi++], NULL, 0);
+ }
+
+ /* ACL event counter */
+ if((argi < argc) && (0 == _strcmp(argv[argi], "cnt_idx")))
+ {
+ argi++;
+ act.cnt_en = TRUE;
+ act.cnt_idx = _strtol(argv[argi++], NULL, 0);
+ }
+
+ if((argi < argc) && (0 == _strcmp(argv[argi], "rate_idx")))
+ {
+ argi++;
+ act.rate_en = TRUE;
+ act.rate_idx = _strtol(argv[argi++], NULL, 0);
+ }
+
+ if((argi < argc) && (0 == _strcmp(argv[argi], "attack_idx")))
+ {
+ argi++;
+ act.attack_en = TRUE;
+ act.attack_idx = _strtol(argv[argi++], NULL, 0);
+ }
+
+ if((argi < argc) && (0 == _strcmp(argv[argi], "vid")))
+ {
+ argi++;
+ act.vlan_en = TRUE;
+ act.vlan_idx = _strtol(argv[argi++], NULL, 0);
+ }
+
+ /* Management frame */
+ if((argi < argc) && (0 == _strcmp(argv[argi], "manage")))
+ {
+ argi++;
+ act.mang = _strtoul(argv[argi++], NULL, 2);
+ }
+
+ if((argi < argc) && (0 == _strcmp(argv[argi], "bpdu")))
+ {
+ argi++;
+ act.bpdu = _strtoul(argv[argi++], NULL, 2);
+ }
+
+ /* DSCP class remap */
+ if((argi < argc) && (0 == _strcmp(argv[argi], "class")))
+ {
+ argi++;
+ act.trtcm_en = TRUE;
+ act.trtcm.cls_slr_sel = _strtoul(argv[argi++], NULL, 2);
+ if(TRUE == act.trtcm.cls_slr_sel)
+ {
+ act.trtcm.cls_slr = _strtoul(argv[argi++], NULL, 0);
+ }
+ }
+ if((argi < argc) && (0 == _strcmp(argv[argi], "drop_pcd")))
+ {
+ argi++;
+ act.trtcm_en = TRUE;
+ act.trtcm.drop_pcd_sel = _strtoul(argv[argi++], NULL, 2);
+ if(TRUE == act.trtcm.drop_pcd_sel)
+ {
+ if(0 == _strcmp(argv[argi], "red"))
+ {
+ argi++;
+ act.trtcm.drop_pcd_r= _strtoul(argv[argi++], NULL, 0);
+ }
+ if(0 == _strcmp(argv[argi], "yellow"))
+ {
+ argi++;
+ act.trtcm.drop_pcd_y= _strtoul(argv[argi++], NULL, 0);
+ }
+ if(0 == _strcmp(argv[argi], "green"))
+ {
+ argi++;
+ act.trtcm.drop_pcd_g= _strtoul(argv[argi++], NULL, 0);
+ }
+ }
+ }
+
+ /* trTCM */
+ if((argi < argc) && (0 == _strcmp(argv[argi], "color")))
+ {
+ argi++;
+ act.trtcm_en = TRUE;
+ act.trtcm.tcm_sel = _strtoul(argv[argi++], NULL, 2);
+ trtcm = _strtoul(argv[argi++], NULL, 0);
+ if(FALSE == act.trtcm.tcm_sel)
+ {
+ act.trtcm.usr_tcm = trtcm;
+ }
+ else
+ {
+ act.trtcm.tcm_idx = trtcm;
+ }
+ }
+ ret = air_acl_setAction(0, act_idx, act);
+ AIR_PRINT("Set ACL Action(%u): %s\n", act_idx, air_error_getString(ret));
+ }
+ else if(1 == argc)
+ {
+ /* acl get action <idx(0..127)> */
+ act_idx = _strtoul(argv[argi++], NULL, 0);
+ ret = air_acl_getAction(0, act_idx, &act);
+ AIR_PRINT("Get ACL Action(%u): %s\n", act_idx, air_error_getString(ret));
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+
+ if(AIR_E_OK == ret)
+ {
+ if(TRUE == act.fwd_en)
+ {
+ AIR_PRINT("\t Forwarding : %s\n", fwding[act.fwd]);
+ }
+
+ if(TRUE == act.egtag_en)
+ {
+ AIR_PRINT("\t Egress tag : %s\n", egtag[act.egtag]);
+ }
+
+ if(act.mirrormap)
+ {
+ AIR_PRINT("\t Mirror Session Map : %u\n", act.mirrormap);
+ }
+
+ if(TRUE == act.pri_user_en)
+ {
+ AIR_PRINT("\t User Priority : %u\n", act.pri_user);
+ }
+
+ if(TRUE == act.port_en)
+ {
+ _hex2bitstr(act.portmap, str_temp, AIR_MAX_NUM_OF_PORTS+1);
+ if(TRUE == act.dest_port_sel)
+ {
+ AIR_PRINT("\t Destination Port[0:6]: %s\n", str_temp);
+ }
+ else
+ {
+ AIR_PRINT("\t VLAN Port[0:6] : %s\n", str_temp);
+ }
+ }
+
+ if(TRUE == act.lyvlan_en)
+ {
+ AIR_PRINT("\t Leaky VLAN : %s\n", (TRUE == act.lyvlan)?"Enable":"Disable");
+ }
+ AIR_PRINT("\t Management Frame : %s\n", (TRUE == act.mang)?"Enable":"Disable");
+ AIR_PRINT("\t BPDU Frame : %s\n", (TRUE == act.bpdu)?"Enable":"Disable");
+
+ if(TRUE == act.cnt_en)
+ {
+ AIR_PRINT("\t Event Index : %u\n", act.cnt_idx);
+ }
+
+ /* trTCM*/
+ if(TRUE == act.trtcm_en)
+ {
+ if(TRUE == act.trtcm.cls_slr_sel)
+ {
+ AIR_PRINT("\t Class Selector Remap : %u\n", act.trtcm.cls_slr);
+ }
+ else
+ {
+ AIR_PRINT("\t Class Selector Remap : %s\n", "Disable");
+ }
+ if(TRUE == act.trtcm.drop_pcd_sel)
+ {
+ AIR_PRINT("\t Drop Precedence Remap(Red): %u\n", act.trtcm.drop_pcd_r);
+ AIR_PRINT("\t Drop Precedence Remap(Yel): %u\n", act.trtcm.drop_pcd_y);
+ AIR_PRINT("\t Drop Precedence Remap(Gre): %u\n", act.trtcm.drop_pcd_g);
+ }
+ else
+ {
+ AIR_PRINT("\t Drop Precedence Remap: %s\n", "Disable");
+ }
+
+ if(TRUE == act.trtcm.tcm_sel)
+ {
+ AIR_PRINT("\t trTCM Meter Index : %u\n", act.trtcm.tcm_idx);
+ }
+ else
+ {
+ AIR_PRINT("\t trTCM User Defined : %s\n", trtcm_usr[act.trtcm.usr_tcm]);
+ }
+ }
+ /* rate control */
+ if(TRUE == act.rate_en)
+ {
+ AIR_PRINT("\t Rate Control Index : %u\n", act.rate_idx);
+ }
+
+ if(TRUE == act.attack_en)
+ {
+ AIR_PRINT("\t Attack Rate Control Index: %u\n", act.attack_idx);
+ }
+
+ if(TRUE == act.vlan_en)
+ {
+ AIR_PRINT("\t ACL VLAN Index : %u\n", act.vlan_idx);
+ }
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doAclRmvAction(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T act_idx;
+
+ if(1 == argc)
+ {
+ /* acl del action <idx(0..127)> */
+ act_idx = _strtoul(argv[0], NULL, 0);
+ ret = air_acl_delAction(0, act_idx);
+ if(ret < AIR_E_LAST)
+ AIR_PRINT("Delete ACL Action(%u): %s\n", act_idx, air_error_getString(ret));
+ }
+ else if(0 == argc)
+ {
+ /* acl clear action */
+ ret = air_acl_clearAction(0);
+ if(ret < AIR_E_LAST)
+ AIR_PRINT("Clear ACL Action: %s\n", air_error_getString(ret));
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doAclTrtcm(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T argi = 0;
+ UI32_T tcm_idx;
+ AIR_ACL_TRTCM_T tcm;
+
+ memset(&tcm, 0, sizeof(AIR_ACL_TRTCM_T));
+ if(5 == argc)
+ {
+ /* acl set trtcm <idx(0..31)> <cir(4'hex)> <pir(4'hex)> <cbs(4'hex)> <pbs(4'hex)> */
+ tcm_idx = _strtoul(argv[argi++], NULL, 0);
+ tcm.cir = _strtoul(argv[argi++], NULL, 16);
+ tcm.pir = _strtoul(argv[argi++], NULL, 16);
+ tcm.cbs = _strtoul(argv[argi++], NULL, 16);
+ tcm.pbs = _strtoul(argv[argi++], NULL, 16);
+
+ ret = air_acl_setTrtcm(0, tcm_idx, tcm);
+ if(ret < AIR_E_LAST)
+ AIR_PRINT("Set ACL trTCM(%u): %s\n", tcm_idx, air_error_getString(ret));
+ }
+ else if(1 == argc)
+ {
+ /* acl get trtcm <idx(1..31)> */
+ tcm_idx = _strtoul(argv[argi++], NULL, 0);
+ ret = air_acl_getTrtcm(0, tcm_idx, &tcm);
+ if(ret < AIR_E_LAST)
+ AIR_PRINT("Get ACL trTCM(%u): %s\n", tcm_idx, air_error_getString(ret));
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("\t CIR: 0x%04X(unit:64Kbps)\n", tcm.cir);
+ AIR_PRINT("\t PIR: 0x%04X(unit:64Kbps)\n", tcm.pir);
+ AIR_PRINT("\t CBS: 0x%04X(unit:Byte)\n", tcm.cbs);
+ AIR_PRINT("\t PBS: 0x%04X(unit:Byte)\n", tcm.pbs);
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doAclTrtcmEn(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ BOOL_T state = FALSE;
+
+ if (1 == argc)
+ {
+ /* acl set trtcmEn <en(1:En,0:Dis)> */
+ state = _strtol(argv[0], NULL, 10);
+ ret = air_acl_setTrtcmEnable(0, state);
+ AIR_PRINT("Set trTCM State ");
+ }
+ else if (0 == argc)
+ {
+ /* acl get trtcmEn */
+ ret = air_acl_getTrtcmEnable(0, &state);
+ AIR_PRINT("Get trTCM State ");
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+
+ if (ret == AIR_E_OK)
+ {
+ AIR_PRINT(": %s\n", (TRUE == state) ? "Enable" : "Disable");
+ }
+ else
+ {
+ AIR_PRINT("Fail!\n");
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doAclRmvTrtcm(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T tcm_idx;
+
+ if(1 == argc)
+ {
+ /* acl del trtcm <idx(1..31)> */
+ tcm_idx = _strtoul(argv[0], NULL, 0);
+ ret = air_acl_delTrtcm(0, tcm_idx);
+ if(ret < AIR_E_LAST)
+ AIR_PRINT("Delete ACL TRTCM(%u): %s\n", tcm_idx, air_error_getString(ret));
+ }
+ else if(0 == argc)
+ {
+ /* acl clear trtcm */
+ ret = air_acl_clearTrtcm(0);
+ if(ret < AIR_E_LAST)
+ AIR_PRINT("Clear ACL TRTCM: %s\n", air_error_getString(ret));
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doAclPortEn(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T argi=0;
+ UI32_T port = 0;
+ BOOL_T en;
+
+ if(2 == argc)
+ {
+ /* acl set portEn <port(0..6)> <en(1:En,0:Dis)> */
+ port = _strtoul(argv[argi++], NULL, 0);
+ en = _strtoul(argv[argi++], NULL, 2);
+ ret = air_acl_setPortEnable(0, port, en);
+ AIR_PRINT("Set Port:%u ACL function ", port);
+ }
+ else if(1 == argc)
+ {
+ /* acl get portEn <port(0..6)> */
+ port = _strtoul(argv[argi++], NULL, 0);
+ ret = air_acl_getPortEnable(0, port, &en);
+ AIR_PRINT("Get Port:%u ACL function ", port);
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT(": %s\n", (TRUE == en)?"Enable":"Disable");
+ }
+ else
+ {
+ AIR_PRINT("Fail!\n");
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doAclDropEn(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T argi=0;
+ UI32_T port = 0;
+ BOOL_T en;
+
+ if(2 == argc)
+ {
+ /* acl set dropEn <port(0..6)> <en(1:En,0:Dis)> */
+ port = _strtoul(argv[argi++], NULL, 0);
+ en = _strtoul(argv[argi++], NULL, 2);
+ ret = air_acl_setDropEnable(0, port, en);
+ AIR_PRINT("Set ACL Drop precedence ");
+ }
+ else if(1 == argc)
+ {
+ /* acl set dropEn <port(0..6)> */
+ port = _strtoul(argv[argi++], NULL, 0);
+ ret = air_acl_getDropEnable(0, port, &en);
+ AIR_PRINT("Get ACL Drop precedence ");
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("(Port %u):%s\n",
+ port,
+ (TRUE == en)?"Enable":"Disable");
+ }
+ else
+ {
+ AIR_PRINT("Fail!\n");
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doAclDropThrsh(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T argi=0;
+ UI32_T port = 0;
+ AIR_ACL_DP_COLOR_T color;
+ UI8_T queue;
+ UI32_T high, low;
+ C8_T dp_color[AIR_ACL_DP_COLOR_LAST][7] =
+ {
+ "Green",
+ "Yellow",
+ "Red"
+ };
+
+ if(5 == argc)
+ {
+ /* acl set dropThrsh <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)> <high(0..2047)> <low(0..2047) */
+ port = _strtoul(argv[argi++], NULL, 0);
+ color = _strtoul(argv[argi++], NULL, 0);
+ queue = _strtoul(argv[argi++], NULL, 0);
+ high = _strtoul(argv[argi++], NULL, 0);
+ low = _strtoul(argv[argi++], NULL, 0);
+ ret = air_acl_setDropThreshold(0, port, color, queue, high, low);
+ AIR_PRINT("Set ACL Drop precedence ");
+ }
+ else if(3 == argc)
+ {
+ /* acl get dropThrsh <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)> */
+ port = _strtoul(argv[argi++], NULL, 0);
+ color = _strtoul(argv[argi++], NULL, 0);
+ queue = _strtoul(argv[argi++], NULL, 0);
+ ret = air_acl_getDropThreshold(0, port, color, queue, &high, &low);
+ AIR_PRINT("Get ACL Drop precedence ");
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("(Port %u, color:%s, queue:%u):\n",
+ port,
+ dp_color[color],
+ queue);
+ AIR_PRINT("\tHigh Threshold :%u\n", high);
+ AIR_PRINT("\tLow Threshold :%u\n", low);
+ }
+ else
+ {
+ AIR_PRINT("Fail!\n");
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doAclDropPbb(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T argi=0;
+ UI32_T port = 0;
+ AIR_ACL_DP_COLOR_T color;
+ UI8_T queue;
+ UI32_T pbb;
+ C8_T dp_color[AIR_ACL_DP_COLOR_LAST][7] =
+ {
+ "Green",
+ "Yellow",
+ "Red"
+ };
+
+ if(4 == argc)
+ {
+ /* acl set dropPbb <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)> <probability(0..1023) */
+ port = _strtoul(argv[argi++], NULL, 0);
+ color = _strtoul(argv[argi++], NULL, 0);
+ queue = _strtoul(argv[argi++], NULL, 0);
+ pbb = _strtoul(argv[argi++], NULL, 0);
+ ret = air_acl_setDropProbability(0, port, color, queue, pbb);
+ AIR_PRINT("Set ACL Drop precedence ");
+ }
+ else if(3 == argc)
+ {
+ /* acl get dropPbb <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)> */
+ port = _strtoul(argv[argi++], NULL, 0);
+ color = _strtoul(argv[argi++], NULL, 0);
+ queue = _strtoul(argv[argi++], NULL, 0);
+ ret = air_acl_getDropProbability(0, port, color, queue, &pbb);
+ AIR_PRINT("Get ACL Drop precedence ");
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+
+ if(ret == AIR_E_OK)
+ {
+ AIR_PRINT("(Port %u, color:%s, queue %u):\n",
+ port,
+ dp_color[color],
+ queue);
+ AIR_PRINT("\tDrop probability:%u(unit=1/1023)\n", pbb);
+ }
+ else
+ {
+ AIR_PRINT("Fail!\n");
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doAclMeter(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T argi = 0;
+ UI32_T meter_idx, state, rate;
+
+ if(3 == argc)
+ {
+ /* acl set meter <idx(0..31)> <en(1:En,0:Dis)> <rate(0..65535)>
+ Note: Limit rate = rate * 64Kbps */
+ meter_idx = _strtoul(argv[argi++], NULL, 0);
+ state = _strtoul(argv[argi++], NULL, 2);
+ rate = _strtoul(argv[argi++], NULL, 0);
+
+ ret = air_acl_setMeterTable(0, meter_idx, state, rate);
+ if(ret < AIR_E_LAST)
+ AIR_PRINT("Set ACL Meter(%u): %s\n", meter_idx, air_error_getString(ret));
+ }
+ else if(1 == argc)
+ {
+ /* acl get meter <idx(0..31)> */
+ meter_idx = _strtoul(argv[argi++], NULL, 0);
+ ret = air_acl_getMeterTable(0, meter_idx, &state, &rate);
+ if(ret < AIR_E_LAST)
+ AIR_PRINT("Get ACL Meter(%u): %s\n", meter_idx, air_error_getString(ret));
+ }
+ else
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+
+ if(AIR_E_OK == ret)
+ {
+ AIR_PRINT("\t State: %s\n", (TRUE == state)?"Enable":"Disable");
+ if(TRUE == state)
+ {
+ AIR_PRINT("\t Rate : %u(unit:64Kbps)\n", rate);
+ }
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doAclDump(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ AIR_ERROR_NO_T ret = AIR_E_OK;
+ UI32_T i, cnt = 0;
+ AIR_ACL_CTRL_T ctrl;
+
+ if(0 != argc)
+ {
+ AIR_PRINT("Unrecognized command.\n");
+ return AIR_E_BAD_PARAMETER;
+ }
+
+ for(i=0; i<ACL_MAX_RULE_NUM; i++)
+ {
+ memset(&ctrl, 0, sizeof(AIR_ACL_CTRL_T));
+ ret = air_acl_getRuleCtrl(0, i, &ctrl);
+ if(AIR_E_OK == ret)
+ {
+ if(TRUE == ctrl.rule_en)
+ {
+ cnt++;
+ AIR_PRINT("\t Entry-%d vaild\n", i);
+ }
+ }
+ }
+ if(0 == cnt)
+ {
+ AIR_PRINT("\t No entry vaild\n");
+ }
+
+ return ret;
+}
+
+static AIR_ERROR_NO_T
+doAclSet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(aclSetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doAclGet(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(aclGetCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doAclDel(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(aclDelCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doAclClear(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(aclClearCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+doAcl(
+ UI32_T argc,
+ C8_T *argv[])
+{
+ return subcmd(aclCmds, argc, argv);
+}
+
+static AIR_ERROR_NO_T
+subcmd(
+ const AIR_CMD_T tab[],
+ UI32_T argc,
+ C8_T *argv[])
+{
+ const AIR_CMD_T *cmdp;
+ I32_T found = 0;
+ I32_T i, len;
+
+ if (argc < 1)
+ {
+ goto print_out_cmds;
+ }
+
+ for (cmdp = tab; cmdp->name != NULL; cmdp++)
+ {
+ if (strlen(argv[0]) == strlen(cmdp->name))
+ {
+ if (strncmp(argv[0], cmdp->name, strlen(argv[0])) == 0)
+ {
+ found = 1;
+ break;
+ }
+ }
+ }
+
+ if(!found)
+ {
+ C8_T buf[66];
+
+print_out_cmds:
+ AIR_PRINT("valid subcommands:\n");
+ memset(buf, ' ', sizeof(buf));
+ buf[64] = '\n';
+ buf[65] = '\0';
+
+ for (i=0, cmdp = tab; cmdp->name != NULL; cmdp++)
+ {
+ len = strlen(cmdp->name);
+ strncpy(&buf[i*16], cmdp->name, (len > 16) ? 16 : len);
+ if(3 == i)
+ {
+ AIR_PRINT("%s\n", buf);
+ memset(buf, ' ', sizeof(buf));
+ buf[64] = '\n';
+ buf[65] = '\0';
+ }
+ i = (i + 1) % 4;
+ }
+
+ if (0 != i)
+ AIR_PRINT("%s\n", buf);
+
+ return AIR_E_BAD_PARAMETER;
+ }
+
+ if (CMD_NO_PARA == cmdp->argc_min)
+ {
+ if (argc != 1)
+ {
+ if (cmdp->argc_errmsg != NULL)
+ {
+ AIR_PRINT("Usage: %s\n", cmdp->argc_errmsg);
+ }
+
+ return AIR_E_BAD_PARAMETER;
+ }
+ }
+ else if (CMD_VARIABLE_PARA == cmdp->argc_min)
+ {
+ if (argc < 3)
+ {
+ if (cmdp->argc_errmsg != NULL)
+ {
+ AIR_PRINT("Usage: %s\n", cmdp->argc_errmsg);
+ }
+
+ return AIR_E_BAD_PARAMETER;
+ }
+ }
+ else
+ {
+ if ((argc <= cmdp->argc_min) || ((cmdp->argc_min != 0) && (argc != (cmdp->argc_min + 1))))
+ {
+ if (cmdp->argc_errmsg != NULL)
+ {
+ AIR_PRINT("Usage: %s\n", cmdp->argc_errmsg);
+ }
+
+ return AIR_E_BAD_PARAMETER;
+ }
+ }
+
+ if (cmdp->func)
+ {
+ argc--;
+ argv++;
+ return (*cmdp->func)(argc, argv);
+ }
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_parse_cmd
+ * PURPOSE:
+ * This function is used process diagnostic cmd
+ * INPUT:
+ * argc -- parameter number
+ * argv -- parameter strings
+ * OUTPUT:
+ * None
+ * RETURN:
+ * NPS_E_OK -- Successfully read the data.
+ * NPS_E_OTHERS -- Failed to read the data.
+ * NOTES:
+ *
+ */
+AIR_ERROR_NO_T
+air_parse_cmd(
+ const UI32_T argc,
+ const C8_T **argv)
+{
+ return subcmd(Cmds, argc, (C8_T **)argv);
+}
+
diff --git a/feed/app/switch/src/an8855_sdk/api/src/air_error.c b/feed/app/switch/src/an8855_sdk/api/src/air_error.c
index 3323e54..abe27dd 100644
--- a/feed/app/switch/src/an8855_sdk/api/src/air_error.c
+++ b/feed/app/switch/src/an8855_sdk/api/src/air_error.c
@@ -1,73 +1,73 @@
-/* FILE NAME: air_error.c
- * PURPOSE:
- * Define the software modules in AIR SDK.
- * NOTES:
- */
-
-/* INCLUDE FILE DECLARATIONS
- */
-#include "air.h"
-
-/* NAMING CONSTANT DECLARATIONS
- */
-
-/* MACRO FUNCTION DECLARATIONS
- */
-
-/* DATA TYPE DECLARATIONS
- */
-
-/* GLOBAL VARIABLE DECLARATIONS
- */
-
-/* LOCAL SUBPROGRAM DECLARATIONS
- */
-
-/* STATIC VARIABLE DECLARATIONS
- */
-static C8_T *_air_error_cause[AIR_E_LAST] =
-{
- "OK",
- "NOT_OK",
- "BAD_PARAMETER",
- "TABLE_FULL",
- "ENTRY_NOT_FOUND",
- "ENTRY_EXISTS",
- "NOT_SUPPORT",
- "TIMEOUT",
-};
-
-/* EXPORTED SUBPROGRAM BODIES
- */
-
-/* LOCAL SUBPROGRAM BODIES
- */
-/* FUNCTION NAME: air_error_getString
- * PURPOSE:
- * To obtain the error string of the specified error code
- *
- * INPUT:
- * The specified error code
- * OUTPUT:
- * None
- * RETURN:
- * Pointer to the target error string
- *
- * NOTES:
- *
- *
- */
-C8_T *
-air_error_getString(
-const AIR_ERROR_NO_T cause )
-{
- if(cause < AIR_E_LAST)
- {
- return _air_error_cause[cause];
- }
- else
- {
- return "";
- }
-}
-
+/* FILE NAME: air_error.c
+ * PURPOSE:
+ * Define the software modules in AIR SDK.
+ * NOTES:
+ */
+
+/* INCLUDE FILE DECLARATIONS
+ */
+#include "air.h"
+
+/* NAMING CONSTANT DECLARATIONS
+ */
+
+/* MACRO FUNCTION DECLARATIONS
+ */
+
+/* DATA TYPE DECLARATIONS
+ */
+
+/* GLOBAL VARIABLE DECLARATIONS
+ */
+
+/* LOCAL SUBPROGRAM DECLARATIONS
+ */
+
+/* STATIC VARIABLE DECLARATIONS
+ */
+static C8_T *_air_error_cause[AIR_E_LAST] =
+{
+ "OK",
+ "NOT_OK",
+ "BAD_PARAMETER",
+ "TABLE_FULL",
+ "ENTRY_NOT_FOUND",
+ "ENTRY_EXISTS",
+ "NOT_SUPPORT",
+ "TIMEOUT",
+};
+
+/* EXPORTED SUBPROGRAM BODIES
+ */
+
+/* LOCAL SUBPROGRAM BODIES
+ */
+/* FUNCTION NAME: air_error_getString
+ * PURPOSE:
+ * To obtain the error string of the specified error code
+ *
+ * INPUT:
+ * The specified error code
+ * OUTPUT:
+ * None
+ * RETURN:
+ * Pointer to the target error string
+ *
+ * NOTES:
+ *
+ *
+ */
+C8_T *
+air_error_getString(
+const AIR_ERROR_NO_T cause )
+{
+ if(cause < AIR_E_LAST)
+ {
+ return _air_error_cause[cause];
+ }
+ else
+ {
+ return "";
+ }
+}
+
diff --git a/feed/app/switch/src/an8855_sdk/api/src/air_init.c b/feed/app/switch/src/an8855_sdk/api/src/air_init.c
index 8a4f96f..63664dc 100644
--- a/feed/app/switch/src/an8855_sdk/api/src/air_init.c
+++ b/feed/app/switch/src/an8855_sdk/api/src/air_init.c
@@ -1,147 +1,147 @@
-/* FILE NAME: air_init.c
- * PURPOSE:
- * Define the initialization function in AIR SDK.
- *
- * NOTES:
- * None
- */
-
-/* INCLUDE FILE DECLARATIONS
- */
-#include "air.h"
-
-/* NAMING CONSTANT DECLARATIONS
- */
-
-/* MACRO FUNCTION DECLARATIONS
- */
-
-/* DATA TYPE DECLARATIONS
- */
-
-/* GLOBAL VARIABLE DECLARATIONS
- */
-AIR_PRINTF _ext_printf;
-AIR_UDELAY _ext_udelay;
-AIR_MALLOC _ext_malloc;
-AIR_FREE _ext_free;
-
-/* LOCAL SUBPROGRAM DECLARATIONS
- */
-
-/* STATIC VARIABLE DECLARATIONS
- */
-
-/* EXPORTED SUBPROGRAM BODIES
- */
-
-/* LOCAL SUBPROGRAM BODIES
- */
-
-/* FUNCTION NAME: air_init
- * PURPOSE:
- * This API is used to initialize the SDK.
- *
- * INPUT:
- * unit -- The device unit
- * ptr_init_param -- The sdk callback functions.
- *
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_OTHERS
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_init(
- const UI32_T unit,
- AIR_INIT_PARAM_T *ptr_init_param)
-{
- AIR_ERROR_NO_T rc = AIR_E_OK;
- UI32_T u32dat = 0;
- UI8_T port = 0;
- AIR_LED_ON_EVT_T on_evt;
- AIR_LED_BLK_EVT_T blk_evt;
-
- /* check point */
- AIR_CHECK_PTR(ptr_init_param);
-
- _ext_dev_access.read_callback = ptr_init_param->dev_access.read_callback;
- _ext_dev_access.write_callback = ptr_init_param->dev_access.write_callback;
- _ext_dev_access.phy_read_callback = ptr_init_param->dev_access.phy_read_callback;
- _ext_dev_access.phy_write_callback = ptr_init_param->dev_access.phy_write_callback;
- _ext_dev_access.phy_cl45_read_callback = ptr_init_param->dev_access.phy_cl45_read_callback;
- _ext_dev_access.phy_cl45_write_callback = ptr_init_param->dev_access.phy_cl45_write_callback;
- _ext_printf = ptr_init_param->printf;
- _ext_udelay = ptr_init_param->udelay;
- _ext_malloc = ptr_init_param->malloc;
- _ext_free = ptr_init_param->free;
-
- return rc;
-}
-
-/* FUNCTION NAME: air_hw_reset
- * PURPOSE:
- * This API is used to reset hardware.
- *
- * INPUT:
- * unit -- The device unit
- *
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_OTHERS
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_hw_reset(
- const UI32_T unit)
-{
- AIR_PRINT(">>>>> enct_hw_reset\n");
- /* Set an8855 reset pin to 0 */
-
- /* Delay 100ms */
-
- /* Set an8855 reset pin to 1 */
-
- /* Delay 600ms */
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_set_gpio_pin_mux
- * PURPOSE:
- * This API is used to set gpio pin mux.
- *
- * INPUT:
- * unit -- The device unit
- *
- * OUTPUT:
- * None
- *
- * RETURN:
- * AIR_E_OK
- * AIR_E_OTHERS
- *
- * NOTES:
- * None
- */
-AIR_ERROR_NO_T
-air_set_gpio_pin_mux(
- const UI32_T unit)
-{
- AIR_PRINT(">>>>> enct_set_gpio_pin_mux\n");
- /* Set GPIO_MODE0 */
- /* Implementation for SLT HW */
- aml_writeReg(unit, GPIO_MODE0, 0x11111111);
-
- return AIR_E_OK;
-}
+/* FILE NAME: air_init.c
+ * PURPOSE:
+ * Define the initialization function in AIR SDK.
+ *
+ * NOTES:
+ * None
+ */
+
+/* INCLUDE FILE DECLARATIONS
+ */
+#include "air.h"
+
+/* NAMING CONSTANT DECLARATIONS
+ */
+
+/* MACRO FUNCTION DECLARATIONS
+ */
+
+/* DATA TYPE DECLARATIONS
+ */
+
+/* GLOBAL VARIABLE DECLARATIONS
+ */
+AIR_PRINTF _ext_printf;
+AIR_UDELAY _ext_udelay;
+AIR_MALLOC _ext_malloc;
+AIR_FREE _ext_free;
+
+/* LOCAL SUBPROGRAM DECLARATIONS
+ */
+
+/* STATIC VARIABLE DECLARATIONS
+ */
+
+/* EXPORTED SUBPROGRAM BODIES
+ */
+
+/* LOCAL SUBPROGRAM BODIES
+ */
+
+/* FUNCTION NAME: air_init
+ * PURPOSE:
+ * This API is used to initialize the SDK.
+ *
+ * INPUT:
+ * unit -- The device unit
+ * ptr_init_param -- The sdk callback functions.
+ *
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_OTHERS
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_init(
+ const UI32_T unit,
+ AIR_INIT_PARAM_T *ptr_init_param)
+{
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+ UI32_T u32dat = 0;
+ UI8_T port = 0;
+ AIR_LED_ON_EVT_T on_evt;
+ AIR_LED_BLK_EVT_T blk_evt;
+
+ /* check point */
+ AIR_CHECK_PTR(ptr_init_param);
+
+ _ext_dev_access.read_callback = ptr_init_param->dev_access.read_callback;
+ _ext_dev_access.write_callback = ptr_init_param->dev_access.write_callback;
+ _ext_dev_access.phy_read_callback = ptr_init_param->dev_access.phy_read_callback;
+ _ext_dev_access.phy_write_callback = ptr_init_param->dev_access.phy_write_callback;
+ _ext_dev_access.phy_cl45_read_callback = ptr_init_param->dev_access.phy_cl45_read_callback;
+ _ext_dev_access.phy_cl45_write_callback = ptr_init_param->dev_access.phy_cl45_write_callback;
+ _ext_printf = ptr_init_param->printf;
+ _ext_udelay = ptr_init_param->udelay;
+ _ext_malloc = ptr_init_param->malloc;
+ _ext_free = ptr_init_param->free;
+
+ return rc;
+}
+
+/* FUNCTION NAME: air_hw_reset
+ * PURPOSE:
+ * This API is used to reset hardware.
+ *
+ * INPUT:
+ * unit -- The device unit
+ *
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_OTHERS
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_hw_reset(
+ const UI32_T unit)
+{
+ AIR_PRINT(">>>>> enct_hw_reset\n");
+ /* Set an8855 reset pin to 0 */
+
+ /* Delay 100ms */
+
+ /* Set an8855 reset pin to 1 */
+
+ /* Delay 600ms */
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_set_gpio_pin_mux
+ * PURPOSE:
+ * This API is used to set gpio pin mux.
+ *
+ * INPUT:
+ * unit -- The device unit
+ *
+ * OUTPUT:
+ * None
+ *
+ * RETURN:
+ * AIR_E_OK
+ * AIR_E_OTHERS
+ *
+ * NOTES:
+ * None
+ */
+AIR_ERROR_NO_T
+air_set_gpio_pin_mux(
+ const UI32_T unit)
+{
+ AIR_PRINT(">>>>> enct_set_gpio_pin_mux\n");
+ /* Set GPIO_MODE0 */
+ /* Implementation for SLT HW */
+ aml_writeReg(unit, GPIO_MODE0, 0x11111111);
+
+ return AIR_E_OK;
+}
diff --git a/feed/app/switch/src/an8855_sdk/api/src/air_port.c b/feed/app/switch/src/an8855_sdk/api/src/air_port.c
index 09dcef1..d33bf70 100644
--- a/feed/app/switch/src/an8855_sdk/api/src/air_port.c
+++ b/feed/app/switch/src/an8855_sdk/api/src/air_port.c
@@ -390,8 +390,8 @@
AIR_CHECK_PTR(ptr_speed);
/* Read data from register */
- aml_readPhyReg(unit, port, 0x0, &u32dat);
- (*ptr_speed) = (BITS_OFF_R(u32dat, 6, 1) << 1) | BITS_OFF_R(u32dat, 13, 1);
+ aml_readReg(unit, PMSR(port), &u32dat);
+ (*ptr_speed) = BITS_OFF_R(u32dat, 28, 3);
return ret;
}
@@ -491,8 +491,8 @@
AIR_CHECK_PTR(ptr_duplex);
/* Read data from register */
- aml_readPhyReg(unit, port, 0x0, &u32dat);
- (*ptr_duplex) = BITS_OFF_R(u32dat, 8, 1);
+ aml_readReg(unit, PMSR(port), &u32dat);
+ (*ptr_duplex) = BITS_OFF_R(u32dat, 25, 1);
return AIR_E_OK;
}
diff --git a/feed/app/switch/src/an8855_sdk/api/src/air_vlan.c b/feed/app/switch/src/an8855_sdk/api/src/air_vlan.c
index 6629165..94f296e 100644
--- a/feed/app/switch/src/an8855_sdk/api/src/air_vlan.c
+++ b/feed/app/switch/src/an8855_sdk/api/src/air_vlan.c
@@ -1,1448 +1,1449 @@
-/* FILE NAME: air_vlan.c
- * PURPOSE:
- * Define the VLAN function in AIR SDK.
- * NOTES:
- */
-
-/* INCLUDE FILE DECLARATIONS
- */
-#include "air.h"
-
-/* NAMING CONSTANT DECLARATIONS
- */
-
-/* MACRO FUNCTION DECLARATIONS
- */
-
-/* DATA TYPE DECLARATIONS
- */
-
-/* GLOBAL VARIABLE DECLARATIONS
- */
-
-/* LOCAL SUBPROGRAM DECLARATIONS
- */
-
-/* STATIC VARIABLE DECLARATIONS
- */
-
-/* EXPORTED SUBPROGRAM BODIES
- */
-
-/* LOCAL SUBPROGRAM BODIES
-*/
-void
-_air_vlan_readEntry(
- const UI32_T unit,
- const UI16_T vid,
- AIR_VLAN_ENTRY_T* vlan_entry)
-{
- UI32_T val = 0;
- val = (0x80000000 + vid); //r_vid_cmd
- aml_writeReg(unit, VTCR, val);
-
- for (;;)
- {
- aml_readReg(unit, VTCR, &val);
- if ((val & 0x80000000) == 0)
- break;
- AIR_UDELAY(10);
- }
-
- aml_readReg(unit, VLNRDATA0, &(vlan_entry->vlan_table.vlan_table0));
- aml_readReg(unit, VLNRDATA1, &(vlan_entry->vlan_table.vlan_table1));
-}
-
-void
-_air_vlan_writeEntry(
- const UI32_T unit,
- const UI16_T vid,
- AIR_VLAN_ENTRY_T* vlan_entry)
-{
- UI32_T val = 0;
-
- aml_writeReg(unit, VLNWDATA0, vlan_entry->vlan_table.vlan_table0);
- aml_writeReg(unit, VLNWDATA1, vlan_entry->vlan_table.vlan_table1);
- aml_writeReg(unit, VLNWDATA2, 0);
- aml_writeReg(unit, VLNWDATA3, 0);
- aml_writeReg(unit, VLNWDATA4, 0);
-
- val = (0x80001000 + vid); //w_vid_cmd
- aml_writeReg(unit, VTCR, val);
-
- for (;;)
- {
- aml_readReg(unit, VTCR, &val);
- if ((val & 0x80000000) == 0)
- break;
- AIR_UDELAY(10);
- }
-}
-
-void
-_air_untagged_vlan_readEntry(
- const UI32_T unit,
- const UI16_T vid,
- AIR_VLAN_ENTRY_ATTR_T* vlan_entry)
-{
- UI32_T val = 0;
- val = (0x80000000 + vid); //r_vid_cmd
- aml_writeReg(unit, VTCR, val);
-
- for (;;)
- {
- aml_readReg(unit, VTCR, &val);
- if ((val & 0x80000000) == 0)
- break;
- AIR_UDELAY(10);
- }
-
- aml_readReg(unit, VLNRDATA0, &(vlan_entry->vlan_table.vlan_table0));
- aml_readReg(unit, VLNRDATA1, &(vlan_entry->vlan_table.vlan_table1));
- aml_readReg(unit, VLNRDATA2, &(vlan_entry->vlan_table.vlan_table2));
- aml_readReg(unit, VLNRDATA3, &(vlan_entry->vlan_table.vlan_table3));
- aml_readReg(unit, VLNRDATA4, &(vlan_entry->vlan_table.vlan_table4));
-}
-
-void
-_air_untagged_vlan_writeEntry(
- const UI32_T unit,
- const UI16_T vid,
- AIR_VLAN_ENTRY_ATTR_T* vlan_entry)
-{
- UI32_T val = 0;
-
- aml_writeReg(unit, VLNWDATA0, vlan_entry->vlan_table.vlan_table0);
- aml_writeReg(unit, VLNWDATA1, vlan_entry->vlan_table.vlan_table1);
- aml_writeReg(unit, VLNWDATA2, vlan_entry->vlan_table.vlan_table2);
- aml_writeReg(unit, VLNWDATA3, vlan_entry->vlan_table.vlan_table3);
- aml_writeReg(unit, VLNWDATA4, vlan_entry->vlan_table.vlan_table4);
-
- val = (0x80001000 + vid); //w_vid_cmd
- aml_writeReg(unit, VTCR, val);
-
- for (;;)
- {
- aml_readReg(unit, VTCR, &val);
- if ((val & 0x80000000) == 0)
- break;
- AIR_UDELAY(10);
- }
-}
-
-/* FUNCTION NAME: air_vlan_create
- * PURPOSE:
- * Create the vlan in the specified device.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * p_attr -- vlan attr
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Vlan creation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_create(
- const UI32_T unit,
- const UI16_T vid,
- AIR_VLAN_ENTRY_ATTR_T *p_attr)
-{
- AIR_VLAN_ENTRY_T vlan_entry = {0};
-
- AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
-
- _air_vlan_readEntry(unit, vid, &vlan_entry);
- if (vlan_entry.valid)
- return AIR_E_ENTRY_EXISTS;
-
- if (NULL != p_attr)
- {
- p_attr->valid = 1;
- _air_untagged_vlan_writeEntry(unit, vid, p_attr);
- }
- else
- {
- memset(&vlan_entry, 0, sizeof(vlan_entry));
- vlan_entry.valid = 1;
- _air_untagged_vlan_writeEntry(unit, vid, &vlan_entry);
- }
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_destroy
- * PURPOSE:
- * Destroy the vlan in the specified device.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Vlan destroy failed.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_destroy(
- const UI32_T unit,
- const UI16_T vid)
-{
- AIR_VLAN_ENTRY_T vlan_entry = {0};
-
- AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
-
- _air_vlan_writeEntry(unit, vid, &vlan_entry);
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_destroyAll
- * PURPOSE:
- * Destroy the vlan in the specified device.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Vlan destroy failed.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_destroyAll(
- const UI32_T unit,
- const UI32_T keep_and_restore_default_vlan)
-{
- UI16_T vid = 0;
-
- for (vid = AIR_VLAN_ID_MIN; vid <= AIR_VLAN_ID_MAX; vid++)
- {
- if (keep_and_restore_default_vlan)
- {
- air_vlan_reset(unit, vid);
- }
- else
- {
- air_vlan_destroy(unit, vid);
- }
- }
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_reset
- * PURPOSE:
- * Destroy the vlan in the specified device.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully reset the data.
- * AIR_E_OTHERS -- Vlan reset failed.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_reset(
- const UI32_T unit,
- const UI16_T vid)
-{
- AIR_VLAN_ENTRY_T vlan_entry = {0};
-
- AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
-
- vlan_entry.vlan_entry_format.port_mem = AIR_ALL_PORT_BITMAP;
- vlan_entry.valid = TRUE;
-
- _air_vlan_writeEntry(unit, vid, &vlan_entry);
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_setFid
- * PURPOSE:
- * Set the filter id of the vlan to the specified device.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * fid -- filter id
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setFid(
- const UI32_T unit,
- const UI16_T vid,
- const UI8_T fid)
-{
- AIR_VLAN_ENTRY_T vlan_entry = {0};
-
- /* VID check */
- AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
- AIR_PARAM_CHK((fid > AIR_FILTER_ID_MAX), AIR_E_BAD_PARAMETER);
-
- _air_vlan_readEntry(unit, vid, &vlan_entry);
- if (!vlan_entry.valid)
- return AIR_E_ENTRY_NOT_FOUND;
-
- vlan_entry.vlan_entry_format.fid = fid;
- _air_vlan_writeEntry(unit, vid, &vlan_entry);
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_getFid
- * PURPOSE:
- * Get the filter id of the vlan from the specified device.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id to be created
- * OUTPUT:
- * ptr_fid -- filter id
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getFid(
- const UI32_T unit,
- const UI16_T vid,
- UI8_T *ptr_fid)
-{
- AIR_VLAN_ENTRY_T vlan_entry = {0};
-
- AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
- AIR_CHECK_PTR(ptr_fid);
-
- _air_vlan_readEntry(unit, vid, &vlan_entry);
- if (!vlan_entry.valid)
- return AIR_E_ENTRY_NOT_FOUND;
-
- *ptr_fid = vlan_entry.vlan_entry_format.fid;
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_addMemberPort
- * PURPOSE:
- * Add one vlan member to the specified device.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * port -- port id
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_addMemberPort(
- const UI32_T unit,
- const UI16_T vid,
- const UI32_T port)
-{
- AIR_VLAN_ENTRY_T vlan_entry = {0};
-
- AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
- AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
-
- _air_vlan_readEntry(unit, vid, &vlan_entry);
- if (!vlan_entry.valid)
- return AIR_E_ENTRY_NOT_FOUND;
-
- vlan_entry.vlan_entry_format.port_mem |= 1 << port;
- _air_vlan_writeEntry(unit, vid, &vlan_entry);
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_delMemberPort
- * PURPOSE:
- * Delete one vlan member from the specified device.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * port -- port id
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_delMemberPort(
- const UI32_T unit,
- const UI16_T vid,
- const UI32_T port)
-{
- AIR_VLAN_ENTRY_T vlan_entry = {0};
-
- AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
- AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
-
- _air_vlan_readEntry(unit, vid, &vlan_entry);
- if (!vlan_entry.valid)
- return AIR_E_ENTRY_NOT_FOUND;
-
- vlan_entry.vlan_entry_format.port_mem &= ~(1 << port);
- _air_vlan_writeEntry(unit, vid, &vlan_entry);
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_setMemberPort
- * PURPOSE:
- * Replace the vlan members in the specified device.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * port_bitmap -- member port bitmap
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setMemberPort(
- const UI32_T unit,
- const UI16_T vid,
- const UI32_T port_bitmap)
-{
- AIR_VLAN_ENTRY_T vlan_entry = {0};
-
- AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
- AIR_PARAM_CHK((port_bitmap & (~AIR_ALL_PORT_BITMAP)), AIR_E_BAD_PARAMETER);
-
- _air_vlan_readEntry(unit, vid, &vlan_entry);
- if (!vlan_entry.valid)
- return AIR_E_ENTRY_NOT_FOUND;
-
- vlan_entry.vlan_entry_format.port_mem = port_bitmap;
- _air_vlan_writeEntry(unit, vid, &vlan_entry);
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_getMemberPort
- * PURPOSE:
- * Get the vlan members from the specified device.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * OUTPUT:
- * port_bitmap -- member port bitmap
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getMemberPort(
- const UI32_T unit,
- const UI16_T vid,
- UI32_T *ptr_port_bitmap)
-{
- AIR_VLAN_ENTRY_T vlan_entry = {0};
-
- AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
- AIR_CHECK_PTR(ptr_port_bitmap);
-
- _air_vlan_readEntry(unit, vid, &vlan_entry);
- if (!vlan_entry.valid)
- return AIR_E_ENTRY_NOT_FOUND;
-
- *ptr_port_bitmap = vlan_entry.vlan_entry_format.port_mem;
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_setIVL
- * PURPOSE:
- * Set L2 lookup mode IVL/SVL for L2 traffic.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * enable -- enable IVL
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setIVL(
- const UI32_T unit,
- const UI16_T vid,
- const BOOL_T enable)
-{
- AIR_VLAN_ENTRY_T vlan_entry = {0};
-
- AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
-
- _air_vlan_readEntry(unit, vid, &vlan_entry);
- if (!vlan_entry.valid)
- return AIR_E_ENTRY_NOT_FOUND;
-
- vlan_entry.vlan_entry_format.ivl = enable ? 1 : 0;
- _air_vlan_writeEntry(unit, vid, &vlan_entry);
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_getIVL
- * PURPOSE:
- * Get L2 lookup mode IVL/SVL for L2 traffic.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * OUTPUT:
- * ptr_enable -- enable IVL
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getIVL(
- const UI32_T unit,
- const UI16_T vid,
- BOOL_T *ptr_enable)
-{
- AIR_VLAN_ENTRY_T vlan_entry = {0};
-
- AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
- AIR_CHECK_PTR(ptr_enable);
-
- _air_vlan_readEntry(unit, vid, &vlan_entry);
- if (!vlan_entry.valid)
- return AIR_E_ENTRY_NOT_FOUND;
-
- *ptr_enable = vlan_entry.vlan_entry_format.ivl;
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_setPortAcceptFrameType
- * PURPOSE:
- * Set vlan accept frame type of the port from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * type -- accept frame type
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setPortAcceptFrameType(
- const UI32_T unit,
- const UI32_T port,
- const AIR_VLAN_ACCEPT_FRAME_TYPE_T type)
-{
- AIR_ERROR_NO_T rc = AIR_E_OK;
- UI32_T val = 0;
-
- AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
- AIR_PARAM_CHK((type >= AIR_VLAN_ACCEPT_FRAME_TYPE_LAST), AIR_E_BAD_PARAMETER);
-
- aml_readReg(unit, PVC(port), &val);
- val &= ~PVC_ACC_FRM_MASK;
- val |= (type & PVC_ACC_FRM_RELMASK) << PVC_ACC_FRM_OFFT;
- aml_writeReg(unit, PVC(port), val);
-
- return rc;
-}
-
-/* FUNCTION NAME: air_vlan_getPortAcceptFrameType
- * PURPOSE:
- * Get vlan accept frame type of the port from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * OUTPUT:
- * ptr_type -- accept frame type
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getPortAcceptFrameType(
- const UI32_T unit,
- const UI32_T port,
- AIR_VLAN_ACCEPT_FRAME_TYPE_T *ptr_type)
-{
- AIR_ERROR_NO_T rc = AIR_E_OK;
- UI32_T val = 0;
-
- AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
- AIR_CHECK_PTR(ptr_type);
-
- aml_readReg(unit, PVC(port), &val);
- *ptr_type = (val >> PVC_ACC_FRM_OFFT) & PVC_ACC_FRM_RELMASK;
-
- return rc;
-}
-
-/* FUNCTION NAME: air_vlan_setPortLeakyVlanEnable
- * PURPOSE:
- * Set leaky vlan enable of the port from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * pkt_type -- packet type
- * enable -- enable leaky
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setPortLeakyVlanEnable(
- const UI32_T unit,
- const UI32_T port,
- AIR_LEAKY_PKT_TYPE_T pkt_type,
- const BOOL_T enable)
-{
- AIR_ERROR_NO_T rc = AIR_E_OK;
- UI32_T val = 0;
-
- AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
- AIR_PARAM_CHK((pkt_type >= AIR_LEAKY_PKT_TYPE_LAST), AIR_E_BAD_PARAMETER);
-
- aml_readReg(unit, PVC(port), &val);
-
- if (pkt_type == AIR_LEAKY_PKT_TYPE_UNICAST)
- {
- if (enable)
- {
- val |= PVC_UC_LKYV_EN_MASK;
- }
- else
- {
- val &= ~PVC_UC_LKYV_EN_MASK;
- }
- }
- else if (pkt_type == AIR_LEAKY_PKT_TYPE_MULTICAST)
- {
- if (enable)
- {
- val |= PVC_MC_LKYV_EN_MASK;
- }
- else
- {
- val &= ~PVC_MC_LKYV_EN_MASK;
- }
- }
- else
- {
- if (enable)
- {
- val |= PVC_BC_LKYV_EN_MASK;
- }
- else
- {
- val &= ~PVC_BC_LKYV_EN_MASK;
- }
- }
-
- aml_writeReg(unit, PVC(port), val);
-
- return rc;
-}
-
-/* FUNCTION NAME: air_vlan_getPortLeakyVlanEnable
- * PURPOSE:
- * Get leaky vlan enable of the port from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * pkt_type -- packet type
- * OUTPUT:
- * ptr_enable -- enable leaky
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getPortLeakyVlanEnable(
- const UI32_T unit,
- const UI32_T port,
- AIR_LEAKY_PKT_TYPE_T pkt_type,
- BOOL_T *ptr_enable)
-{
- AIR_ERROR_NO_T rc = AIR_E_OK;
- UI32_T val = 0;
-
- AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
- AIR_PARAM_CHK((pkt_type >= AIR_LEAKY_PKT_TYPE_LAST), AIR_E_BAD_PARAMETER);
- AIR_CHECK_PTR(ptr_enable);
-
- aml_readReg(unit, PVC(port), &val);
-
- if (pkt_type == AIR_LEAKY_PKT_TYPE_UNICAST)
- {
- *ptr_enable = val & PVC_UC_LKYV_EN_MASK ? TRUE : FALSE;
- }
- else if (pkt_type == AIR_LEAKY_PKT_TYPE_MULTICAST)
- {
- *ptr_enable = val & PVC_MC_LKYV_EN_MASK ? TRUE : FALSE;
- }
- else
- {
- *ptr_enable = val & PVC_BC_LKYV_EN_MASK ? TRUE : FALSE;
- }
-
- return rc;
-}
-
-/* FUNCTION NAME: air_vlan_setPortAttr
- * PURPOSE:
- * Set vlan port attribute from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * attr -- vlan port attr
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setPortAttr(
- const UI32_T unit,
- const UI32_T port,
- const AIR_VLAN_PORT_ATTR_T attr)
-{
- AIR_ERROR_NO_T rc = AIR_E_OK;
- UI32_T val = 0;
-
- AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
- AIR_PARAM_CHK((attr >= AIR_VLAN_PORT_ATTR_LAST), AIR_E_BAD_PARAMETER);
-
- aml_readReg(unit, PVC(port), &val);
- val &= ~PVC_VLAN_ATTR_MASK;
- val |= (attr & PVC_VLAN_ATTR_RELMASK) << PVC_VLAN_ATTR_OFFT;
- aml_writeReg(unit, PVC(port), val);
-
- return rc;
-}
-
-/* FUNCTION NAME: air_vlan_getPortAttr
- * PURPOSE:
- * Get vlan port attribute from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * OUTPUT:
- * ptr_attr -- vlan port attr
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getPortAttr(
- const UI32_T unit,
- const UI32_T port,
- AIR_VLAN_PORT_ATTR_T *ptr_attr)
-{
- AIR_ERROR_NO_T rc = AIR_E_OK;
- UI32_T val = 0;
-
- AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
- AIR_CHECK_PTR(ptr_attr);
-
- aml_readReg(unit, PVC(port), &val);
- *ptr_attr = (val >> PVC_VLAN_ATTR_OFFT) & PVC_VLAN_ATTR_RELMASK;
-
- return rc;
-}
-
-/* FUNCTION NAME: air_vlan_setIgrPortTagAttr
- * PURPOSE:
- * Set vlan incoming port egress tag attribute from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * attr -- egress tag attr
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setIgrPortTagAttr(
- const UI32_T unit,
- const UI32_T port,
- const AIR_IGR_PORT_EG_TAG_ATTR_T attr)
-{
- UI32_T val = 0;
-
- AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
- AIR_PARAM_CHK((attr >= AIR_IGR_PORT_EG_TAG_ATTR_LAST), AIR_E_BAD_PARAMETER);
-
- aml_readReg(unit, PVC(port), &val);
- val &= ~PVC_EG_TAG_MASK;
- val |= (attr & PVC_EG_TAG_RELMASK) << PVC_EG_TAG_OFFT;
- aml_writeReg(unit, PVC(port), val);
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_getIgrPortTagAttr
- * PURPOSE:
- * Get vlan incoming port egress tag attribute from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * OUTPUT:
- * ptr_attr -- egress tag attr
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getIgrPortTagAttr(
- const UI32_T unit,
- const UI32_T port,
- AIR_IGR_PORT_EG_TAG_ATTR_T *ptr_attr)
-{
- UI32_T val = 0;
-
- AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
- AIR_CHECK_PTR(ptr_attr);
-
- aml_readReg(unit, PVC(port), &val);
- *ptr_attr = (val >> PVC_EG_TAG_OFFT) & PVC_EG_TAG_RELMASK;
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_setPortEgsTagAttr
- * PURPOSE:
- * Set vlan port egress tag attribute from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * attr -- egress tag attr
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setPortEgsTagAttr(
- const UI32_T unit,
- const UI32_T port,
- const AIR_PORT_EGS_TAG_ATTR_T attr)
-{
- UI32_T val = 0;
-
- AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
- AIR_PARAM_CHK((attr >= AIR_PORT_EGS_TAG_ATTR_LAST), AIR_E_BAD_PARAMETER);
-
- aml_readReg(unit, PCR(port), &val);
- val &= ~PCR_EG_TAG_MASK;
- val |= (attr & PCR_EG_TAG_RELMASK) << PCR_EG_TAG_OFFT;
- aml_writeReg(unit, PCR(port), val);
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_getPortEgsTagAttr
- * PURPOSE:
- * Get vlan port egress tag attribute from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * OUTPUT:
- * ptr_attr -- egress tag attr
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getPortEgsTagAttr(
- const UI32_T unit,
- const UI32_T port,
- AIR_PORT_EGS_TAG_ATTR_T *ptr_attr)
-{
- UI32_T val = 0;
-
- AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
- AIR_CHECK_PTR(ptr_attr);
-
- aml_readReg(unit, PCR(port), &val);
- *ptr_attr = (val >> PCR_EG_TAG_OFFT) & PCR_EG_TAG_RELMASK;
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_setPortOuterTPID
- * PURPOSE:
- * Set stack tag TPID of the port from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * tpid -- TPID
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setPortOuterTPID(
- const UI32_T unit,
- const UI32_T port,
- const UI16_T tpid)
-{
- UI32_T val = 0;
-
- AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
-
- aml_readReg(unit, PVC(port), &val);
- val &= ~PVC_STAG_VPID_MASK;
- val |= (tpid & PVC_STAG_VPID_RELMASK) << PVC_STAG_VPID_OFFT;
- aml_writeReg(unit, PVC(port), val);
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_getPortOuterTPID
- * PURPOSE:
- * Get stack tag TPID of the port from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * OUTPUT:
- * ptr_tpid -- TPID
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getPortOuterTPID(
- const UI32_T unit,
- const UI32_T port,
- UI16_T *ptr_tpid)
-{
- UI32_T val = 0;
-
- AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
- AIR_CHECK_PTR(ptr_tpid);
-
- aml_readReg(unit, PVC(port), &val);
- *ptr_tpid = (val >> PVC_STAG_VPID_OFFT) & PVC_STAG_VPID_RELMASK;
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_setPortPVID
- * PURPOSE:
- * Set PVID of the port from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * pvid -- native vlan id
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setPortPVID(
- const UI32_T unit,
- const UI32_T port,
- const UI16_T pvid)
-{
- UI32_T val = 0;
-
- AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
- AIR_PARAM_CHK((pvid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
-
- aml_readReg(unit, PVID(port), &val);
- val &= ~PVID_PCVID_MASK;
- val |= (pvid & PVID_PCVID_RELMASK) << PVID_PCVID_OFFT;
- aml_writeReg(unit, PVID(port), val);
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_getPortPVID
- * PURPOSE:
- * Get PVID of the port from the specified device.
- * INPUT:
- * unit -- unit id
- * port -- port id
- * OUTPUT:
- * ptr_pvid -- native vlan id
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getPortPVID(
- const UI32_T unit,
- const UI32_T port,
- UI16_T *ptr_pvid)
-{
- UI32_T val = 0;
-
- AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
- AIR_CHECK_PTR(ptr_pvid);
-
- aml_readReg(unit, PVID(port), &val);
- *ptr_pvid = (val >> PVID_PCVID_OFFT) & PVID_PCVID_RELMASK;
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_setServiceTag
- * PURPOSE:
- * Set Vlan service tag.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * stag -- service stag
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setServiceTag(
- const UI32_T unit,
- const UI16_T vid,
- const UI16_T stag)
-{
- AIR_VLAN_ENTRY_T vlan_entry = {0};
-
- AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
- AIR_PARAM_CHK((stag > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
-
- _air_vlan_readEntry(unit, vid, &vlan_entry);
- if (!vlan_entry.valid)
- return AIR_E_ENTRY_NOT_FOUND;
-
- vlan_entry.vlan_entry_format.stag = stag;
- _air_vlan_writeEntry(unit, vid, &vlan_entry);
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_getServiceTag
- * PURPOSE:
- * Get Vlan service tag.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * OUTPUT:
- * ptr_stag -- service stag
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getServiceTag(
- const UI32_T unit,
- const UI16_T vid,
- UI16_T *ptr_stag)
-{
- AIR_VLAN_ENTRY_T vlan_entry = {0};
-
- AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
- AIR_CHECK_PTR(ptr_stag);
-
- _air_vlan_readEntry(unit, vid, &vlan_entry);
- if (!vlan_entry.valid)
- return AIR_E_ENTRY_NOT_FOUND;
-
- *ptr_stag = vlan_entry.vlan_entry_format.stag;
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_setEgsTagCtlEnable
- * PURPOSE:
- * Set per vlan egress tag control.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * enable -- enable vlan egress tag control
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setEgsTagCtlEnable(
- const UI32_T unit,
- const UI16_T vid,
- const BOOL_T enable)
-{
- AIR_VLAN_ENTRY_T vlan_entry = {0};
-
- AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
-
- _air_vlan_readEntry(unit, vid, &vlan_entry);
- if (!vlan_entry.valid)
- return AIR_E_ENTRY_NOT_FOUND;
-
- vlan_entry.vlan_entry_format.eg_ctrl_en = enable ? 1 : 0;
- _air_vlan_writeEntry(unit, vid, &vlan_entry);
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_getEgsTagCtlEnable
- * PURPOSE:
- * Get per vlan egress tag control.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * OUTPUT:
- * ptr_enable -- enable vlan egress tag control
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getEgsTagCtlEnable(
- const UI32_T unit,
- const UI16_T vid,
- BOOL_T *ptr_enable)
-{
- AIR_VLAN_ENTRY_T vlan_entry = {0};
-
- AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
- AIR_CHECK_PTR(ptr_enable);
-
- _air_vlan_readEntry(unit, vid, &vlan_entry);
- if (!vlan_entry.valid)
- return AIR_E_ENTRY_NOT_FOUND;
-
- *ptr_enable = vlan_entry.vlan_entry_format.eg_ctrl_en;
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_setEgsTagConsistent
- * PURPOSE:
- * Set per vlan egress tag consistent.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * enable -- enable vlan egress tag consistent
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setEgsTagConsistent(
- const UI32_T unit,
- const UI16_T vid,
- const BOOL_T enable)
-{
- AIR_VLAN_ENTRY_T vlan_entry = {0};
-
- AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
-
- _air_vlan_readEntry(unit, vid, &vlan_entry);
- if (!vlan_entry.valid)
- return AIR_E_ENTRY_NOT_FOUND;
-
- vlan_entry.vlan_entry_format.eg_con = enable;
- _air_vlan_writeEntry(unit, vid, &vlan_entry);
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_getEgsTagConsistent
- * PURPOSE:
- * Get per vlan egress tag consistent.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * OUTPUT:
- * ptr_enable -- enable vlan egress tag consistent
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getEgsTagConsistent(
- const UI32_T unit,
- const UI16_T vid,
- BOOL_T *ptr_enable)
-{
- AIR_VLAN_ENTRY_T vlan_entry = {0};
-
- AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
- AIR_CHECK_PTR(ptr_enable);
-
- _air_vlan_readEntry(unit, vid, &vlan_entry);
- if (!vlan_entry.valid)
- return AIR_E_ENTRY_NOT_FOUND;
-
- *ptr_enable = vlan_entry.vlan_entry_format.eg_con;
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_setPortBasedStag
- * PURPOSE:
- * Set vlan port based stag enable.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * enable -- vlan port based stag enable
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setPortBasedStag(
- const UI32_T unit,
- const UI16_T vid,
- const BOOL_T enable)
-{
- AIR_VLAN_ENTRY_T vlan_entry = {0};
-
- AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
-
- _air_vlan_readEntry(unit, vid, &vlan_entry);
- if (!vlan_entry.valid)
- return AIR_E_ENTRY_NOT_FOUND;
-
- vlan_entry.vlan_entry_format.port_stag = enable;
- _air_vlan_writeEntry(unit, vid, &vlan_entry);
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_getPortBasedStag
- * PURPOSE:
- * Get vlan port based stag enable.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * OUTPUT:
- * ptr_enable -- vlan port based stag enable
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getPortBasedStag(
- const UI32_T unit,
- const UI16_T vid,
- BOOL_T *ptr_enable)
-{
- AIR_VLAN_ENTRY_T vlan_entry = {0};
-
- AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
- AIR_CHECK_PTR(ptr_enable);
-
- _air_vlan_readEntry(unit, vid, &vlan_entry);
- if (!vlan_entry.valid)
- return AIR_E_ENTRY_NOT_FOUND;
-
- *ptr_enable = vlan_entry.vlan_entry_format.port_stag;
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_setPortEgsTagCtl
- * PURPOSE:
- * Set vlan port egress tag control.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * port -- port id
- * tag_ctl -- egress tag control
- * OUTPUT:
- * None
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_setPortEgsTagCtl(
- const UI32_T unit,
- const UI16_T vid,
- const UI32_T port,
- const AIR_VLAN_PORT_EGS_TAG_CTL_TYPE_T tag_ctl)
-{
- AIR_VLAN_ENTRY_T vlan_entry = {0};
-
- AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
- AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
- AIR_PARAM_CHK((tag_ctl >= AIR_PORT_EGS_TAG_ATTR_LAST), AIR_E_BAD_PARAMETER);
-
- _air_vlan_readEntry(unit, vid, &vlan_entry);
- if (!vlan_entry.valid)
- return AIR_E_ENTRY_NOT_FOUND;
-
- vlan_entry.vlan_entry_format.eg_ctrl &= ~(0x3 << (port * 2));
- vlan_entry.vlan_entry_format.eg_ctrl |= (tag_ctl & 0x3) << (port * 2);
- _air_vlan_writeEntry(unit, vid, &vlan_entry);
-
- return AIR_E_OK;
-}
-
-/* FUNCTION NAME: air_vlan_getPortEgsTagCtl
- * PURPOSE:
- * Get vlan port egress tag control.
- * INPUT:
- * unit -- unit id
- * vid -- vlan id
- * OUTPUT:
- * ptr_tag_ctl -- egress tag control
- * RETURN:
- * AIR_E_OK -- Successfully read the data.
- * AIR_E_OTHERS -- Operation failed.
- * AIR_E_BAD_PARAMETER -- Invalid parameter.
- * NOTES:
- * none
- */
-AIR_ERROR_NO_T
-air_vlan_getPortEgsTagCtl(
- const UI32_T unit,
- const UI16_T vid,
- const UI32_T port,
- AIR_VLAN_PORT_EGS_TAG_CTL_TYPE_T *ptr_tag_ctl)
-{
- AIR_VLAN_ENTRY_T vlan_entry = {0};
-
- AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
- AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
- AIR_CHECK_PTR(ptr_tag_ctl);
-
- _air_vlan_readEntry(unit, vid, &vlan_entry);
- if (!vlan_entry.valid)
- return AIR_E_ENTRY_NOT_FOUND;
-
- *ptr_tag_ctl = (vlan_entry.vlan_entry_format.eg_ctrl >> (port * 2)) & 0x3;
-
- return AIR_E_OK;
-}
+/* FILE NAME: air_vlan.c
+ * PURPOSE:
+ * Define the VLAN function in AIR SDK.
+ * NOTES:
+ */
+
+/* INCLUDE FILE DECLARATIONS
+ */
+#include "air.h"
+
+/* NAMING CONSTANT DECLARATIONS
+ */
+
+/* MACRO FUNCTION DECLARATIONS
+ */
+
+/* DATA TYPE DECLARATIONS
+ */
+
+/* GLOBAL VARIABLE DECLARATIONS
+ */
+
+/* LOCAL SUBPROGRAM DECLARATIONS
+ */
+
+/* STATIC VARIABLE DECLARATIONS
+ */
+
+/* EXPORTED SUBPROGRAM BODIES
+ */
+
+/* LOCAL SUBPROGRAM BODIES
+*/
+void
+_air_vlan_readEntry(
+ const UI32_T unit,
+ const UI16_T vid,
+ AIR_VLAN_ENTRY_T* vlan_entry)
+{
+ UI32_T val = 0;
+ val = (0x80000000 + vid); //r_vid_cmd
+ aml_writeReg(unit, VTCR, val);
+
+ for (;;)
+ {
+ aml_readReg(unit, VTCR, &val);
+ if ((val & 0x80000000) == 0)
+ break;
+ AIR_UDELAY(10);
+ }
+
+ aml_readReg(unit, VLNRDATA0, &(vlan_entry->vlan_table.vlan_table0));
+ aml_readReg(unit, VLNRDATA1, &(vlan_entry->vlan_table.vlan_table1));
+}
+
+void
+_air_vlan_writeEntry(
+ const UI32_T unit,
+ const UI16_T vid,
+ AIR_VLAN_ENTRY_T* vlan_entry)
+{
+ UI32_T val = 0;
+
+ aml_writeReg(unit, VLNWDATA0, vlan_entry->vlan_table.vlan_table0);
+ aml_writeReg(unit, VLNWDATA1, vlan_entry->vlan_table.vlan_table1);
+ aml_writeReg(unit, VLNWDATA2, 0);
+ aml_writeReg(unit, VLNWDATA3, 0);
+ aml_writeReg(unit, VLNWDATA4, 0);
+
+ val = (0x80001000 + vid); //w_vid_cmd
+ aml_writeReg(unit, VTCR, val);
+
+ for (;;)
+ {
+ aml_readReg(unit, VTCR, &val);
+ if ((val & 0x80000000) == 0)
+ break;
+ AIR_UDELAY(10);
+ }
+}
+
+void
+_air_untagged_vlan_readEntry(
+ const UI32_T unit,
+ const UI16_T vid,
+ AIR_VLAN_ENTRY_ATTR_T* vlan_entry)
+{
+ UI32_T val = 0;
+ val = (0x80000000 + vid); //r_vid_cmd
+ aml_writeReg(unit, VTCR, val);
+
+ for (;;)
+ {
+ aml_readReg(unit, VTCR, &val);
+ if ((val & 0x80000000) == 0)
+ break;
+ AIR_UDELAY(10);
+ }
+
+ aml_readReg(unit, VLNRDATA0, &(vlan_entry->vlan_table.vlan_table0));
+ aml_readReg(unit, VLNRDATA1, &(vlan_entry->vlan_table.vlan_table1));
+ aml_readReg(unit, VLNRDATA2, &(vlan_entry->vlan_table.vlan_table2));
+ aml_readReg(unit, VLNRDATA3, &(vlan_entry->vlan_table.vlan_table3));
+ aml_readReg(unit, VLNRDATA4, &(vlan_entry->vlan_table.vlan_table4));
+}
+
+void
+_air_untagged_vlan_writeEntry(
+ const UI32_T unit,
+ const UI16_T vid,
+ AIR_VLAN_ENTRY_ATTR_T* vlan_entry)
+{
+ UI32_T val = 0;
+
+ aml_writeReg(unit, VLNWDATA0, vlan_entry->vlan_table.vlan_table0);
+ aml_writeReg(unit, VLNWDATA1, vlan_entry->vlan_table.vlan_table1);
+ aml_writeReg(unit, VLNWDATA2, vlan_entry->vlan_table.vlan_table2);
+ aml_writeReg(unit, VLNWDATA3, vlan_entry->vlan_table.vlan_table3);
+ aml_writeReg(unit, VLNWDATA4, vlan_entry->vlan_table.vlan_table4);
+
+ val = (0x80001000 + vid); //w_vid_cmd
+ aml_writeReg(unit, VTCR, val);
+
+ for (;;)
+ {
+ aml_readReg(unit, VTCR, &val);
+ if ((val & 0x80000000) == 0)
+ break;
+ AIR_UDELAY(10);
+ }
+}
+
+/* FUNCTION NAME: air_vlan_create
+ * PURPOSE:
+ * Create the vlan in the specified device.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * p_attr -- vlan attr
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Vlan creation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_create(
+ const UI32_T unit,
+ const UI16_T vid,
+ AIR_VLAN_ENTRY_ATTR_T *p_attr)
+{
+ AIR_VLAN_ENTRY_T vlan_entry = {0};
+ AIR_VLAN_ENTRY_ATTR_T vlan_attr_entry = {0};
+
+ AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+
+ _air_vlan_readEntry(unit, vid, &vlan_entry);
+ if (vlan_entry.valid)
+ return AIR_E_ENTRY_EXISTS;
+
+ if (NULL != p_attr)
+ {
+ p_attr->valid = 1;
+ _air_untagged_vlan_writeEntry(unit, vid, p_attr);
+ }
+ else
+ {
+ memset(&vlan_attr_entry, 0, sizeof(vlan_attr_entry));
+ vlan_attr_entry.valid = 1;
+ _air_untagged_vlan_writeEntry(unit, vid, &vlan_attr_entry);
+ }
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_destroy
+ * PURPOSE:
+ * Destroy the vlan in the specified device.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Vlan destroy failed.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_destroy(
+ const UI32_T unit,
+ const UI16_T vid)
+{
+ AIR_VLAN_ENTRY_T vlan_entry = {0};
+
+ AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+
+ _air_vlan_writeEntry(unit, vid, &vlan_entry);
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_destroyAll
+ * PURPOSE:
+ * Destroy the vlan in the specified device.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Vlan destroy failed.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_destroyAll(
+ const UI32_T unit,
+ const UI32_T keep_and_restore_default_vlan)
+{
+ UI16_T vid = 0;
+
+ for (vid = AIR_VLAN_ID_MIN; vid <= AIR_VLAN_ID_MAX; vid++)
+ {
+ if (keep_and_restore_default_vlan)
+ {
+ air_vlan_reset(unit, vid);
+ }
+ else
+ {
+ air_vlan_destroy(unit, vid);
+ }
+ }
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_reset
+ * PURPOSE:
+ * Destroy the vlan in the specified device.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully reset the data.
+ * AIR_E_OTHERS -- Vlan reset failed.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_reset(
+ const UI32_T unit,
+ const UI16_T vid)
+{
+ AIR_VLAN_ENTRY_T vlan_entry = {0};
+
+ AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+
+ vlan_entry.vlan_entry_format.port_mem = AIR_ALL_PORT_BITMAP;
+ vlan_entry.valid = TRUE;
+
+ _air_vlan_writeEntry(unit, vid, &vlan_entry);
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_setFid
+ * PURPOSE:
+ * Set the filter id of the vlan to the specified device.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * fid -- filter id
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setFid(
+ const UI32_T unit,
+ const UI16_T vid,
+ const UI8_T fid)
+{
+ AIR_VLAN_ENTRY_T vlan_entry = {0};
+
+ /* VID check */
+ AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+ AIR_PARAM_CHK((fid > AIR_FILTER_ID_MAX), AIR_E_BAD_PARAMETER);
+
+ _air_vlan_readEntry(unit, vid, &vlan_entry);
+ if (!vlan_entry.valid)
+ return AIR_E_ENTRY_NOT_FOUND;
+
+ vlan_entry.vlan_entry_format.fid = fid;
+ _air_vlan_writeEntry(unit, vid, &vlan_entry);
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_getFid
+ * PURPOSE:
+ * Get the filter id of the vlan from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id to be created
+ * OUTPUT:
+ * ptr_fid -- filter id
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getFid(
+ const UI32_T unit,
+ const UI16_T vid,
+ UI8_T *ptr_fid)
+{
+ AIR_VLAN_ENTRY_T vlan_entry = {0};
+
+ AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+ AIR_CHECK_PTR(ptr_fid);
+
+ _air_vlan_readEntry(unit, vid, &vlan_entry);
+ if (!vlan_entry.valid)
+ return AIR_E_ENTRY_NOT_FOUND;
+
+ *ptr_fid = vlan_entry.vlan_entry_format.fid;
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_addMemberPort
+ * PURPOSE:
+ * Add one vlan member to the specified device.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * port -- port id
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_addMemberPort(
+ const UI32_T unit,
+ const UI16_T vid,
+ const UI32_T port)
+{
+ AIR_VLAN_ENTRY_T vlan_entry = {0};
+
+ AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+ AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
+
+ _air_vlan_readEntry(unit, vid, &vlan_entry);
+ if (!vlan_entry.valid)
+ return AIR_E_ENTRY_NOT_FOUND;
+
+ vlan_entry.vlan_entry_format.port_mem |= 1 << port;
+ _air_vlan_writeEntry(unit, vid, &vlan_entry);
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_delMemberPort
+ * PURPOSE:
+ * Delete one vlan member from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * port -- port id
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_delMemberPort(
+ const UI32_T unit,
+ const UI16_T vid,
+ const UI32_T port)
+{
+ AIR_VLAN_ENTRY_T vlan_entry = {0};
+
+ AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+ AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
+
+ _air_vlan_readEntry(unit, vid, &vlan_entry);
+ if (!vlan_entry.valid)
+ return AIR_E_ENTRY_NOT_FOUND;
+
+ vlan_entry.vlan_entry_format.port_mem &= ~(1 << port);
+ _air_vlan_writeEntry(unit, vid, &vlan_entry);
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_setMemberPort
+ * PURPOSE:
+ * Replace the vlan members in the specified device.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * port_bitmap -- member port bitmap
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setMemberPort(
+ const UI32_T unit,
+ const UI16_T vid,
+ const UI32_T port_bitmap)
+{
+ AIR_VLAN_ENTRY_T vlan_entry = {0};
+
+ AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+ AIR_PARAM_CHK((port_bitmap & (~AIR_ALL_PORT_BITMAP)), AIR_E_BAD_PARAMETER);
+
+ _air_vlan_readEntry(unit, vid, &vlan_entry);
+ if (!vlan_entry.valid)
+ return AIR_E_ENTRY_NOT_FOUND;
+
+ vlan_entry.vlan_entry_format.port_mem = port_bitmap;
+ _air_vlan_writeEntry(unit, vid, &vlan_entry);
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_getMemberPort
+ * PURPOSE:
+ * Get the vlan members from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * OUTPUT:
+ * port_bitmap -- member port bitmap
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getMemberPort(
+ const UI32_T unit,
+ const UI16_T vid,
+ UI32_T *ptr_port_bitmap)
+{
+ AIR_VLAN_ENTRY_T vlan_entry = {0};
+
+ AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+ AIR_CHECK_PTR(ptr_port_bitmap);
+
+ _air_vlan_readEntry(unit, vid, &vlan_entry);
+ if (!vlan_entry.valid)
+ return AIR_E_ENTRY_NOT_FOUND;
+
+ *ptr_port_bitmap = vlan_entry.vlan_entry_format.port_mem;
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_setIVL
+ * PURPOSE:
+ * Set L2 lookup mode IVL/SVL for L2 traffic.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * enable -- enable IVL
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setIVL(
+ const UI32_T unit,
+ const UI16_T vid,
+ const BOOL_T enable)
+{
+ AIR_VLAN_ENTRY_T vlan_entry = {0};
+
+ AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+
+ _air_vlan_readEntry(unit, vid, &vlan_entry);
+ if (!vlan_entry.valid)
+ return AIR_E_ENTRY_NOT_FOUND;
+
+ vlan_entry.vlan_entry_format.ivl = enable ? 1 : 0;
+ _air_vlan_writeEntry(unit, vid, &vlan_entry);
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_getIVL
+ * PURPOSE:
+ * Get L2 lookup mode IVL/SVL for L2 traffic.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * OUTPUT:
+ * ptr_enable -- enable IVL
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getIVL(
+ const UI32_T unit,
+ const UI16_T vid,
+ BOOL_T *ptr_enable)
+{
+ AIR_VLAN_ENTRY_T vlan_entry = {0};
+
+ AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+ AIR_CHECK_PTR(ptr_enable);
+
+ _air_vlan_readEntry(unit, vid, &vlan_entry);
+ if (!vlan_entry.valid)
+ return AIR_E_ENTRY_NOT_FOUND;
+
+ *ptr_enable = vlan_entry.vlan_entry_format.ivl;
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_setPortAcceptFrameType
+ * PURPOSE:
+ * Set vlan accept frame type of the port from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * type -- accept frame type
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setPortAcceptFrameType(
+ const UI32_T unit,
+ const UI32_T port,
+ const AIR_VLAN_ACCEPT_FRAME_TYPE_T type)
+{
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+ UI32_T val = 0;
+
+ AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
+ AIR_PARAM_CHK((type >= AIR_VLAN_ACCEPT_FRAME_TYPE_LAST), AIR_E_BAD_PARAMETER);
+
+ aml_readReg(unit, PVC(port), &val);
+ val &= ~PVC_ACC_FRM_MASK;
+ val |= (type & PVC_ACC_FRM_RELMASK) << PVC_ACC_FRM_OFFT;
+ aml_writeReg(unit, PVC(port), val);
+
+ return rc;
+}
+
+/* FUNCTION NAME: air_vlan_getPortAcceptFrameType
+ * PURPOSE:
+ * Get vlan accept frame type of the port from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * OUTPUT:
+ * ptr_type -- accept frame type
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getPortAcceptFrameType(
+ const UI32_T unit,
+ const UI32_T port,
+ AIR_VLAN_ACCEPT_FRAME_TYPE_T *ptr_type)
+{
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+ UI32_T val = 0;
+
+ AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
+ AIR_CHECK_PTR(ptr_type);
+
+ aml_readReg(unit, PVC(port), &val);
+ *ptr_type = (val >> PVC_ACC_FRM_OFFT) & PVC_ACC_FRM_RELMASK;
+
+ return rc;
+}
+
+/* FUNCTION NAME: air_vlan_setPortLeakyVlanEnable
+ * PURPOSE:
+ * Set leaky vlan enable of the port from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * pkt_type -- packet type
+ * enable -- enable leaky
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setPortLeakyVlanEnable(
+ const UI32_T unit,
+ const UI32_T port,
+ AIR_LEAKY_PKT_TYPE_T pkt_type,
+ const BOOL_T enable)
+{
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+ UI32_T val = 0;
+
+ AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
+ AIR_PARAM_CHK((pkt_type >= AIR_LEAKY_PKT_TYPE_LAST), AIR_E_BAD_PARAMETER);
+
+ aml_readReg(unit, PVC(port), &val);
+
+ if (pkt_type == AIR_LEAKY_PKT_TYPE_UNICAST)
+ {
+ if (enable)
+ {
+ val |= PVC_UC_LKYV_EN_MASK;
+ }
+ else
+ {
+ val &= ~PVC_UC_LKYV_EN_MASK;
+ }
+ }
+ else if (pkt_type == AIR_LEAKY_PKT_TYPE_MULTICAST)
+ {
+ if (enable)
+ {
+ val |= PVC_MC_LKYV_EN_MASK;
+ }
+ else
+ {
+ val &= ~PVC_MC_LKYV_EN_MASK;
+ }
+ }
+ else
+ {
+ if (enable)
+ {
+ val |= PVC_BC_LKYV_EN_MASK;
+ }
+ else
+ {
+ val &= ~PVC_BC_LKYV_EN_MASK;
+ }
+ }
+
+ aml_writeReg(unit, PVC(port), val);
+
+ return rc;
+}
+
+/* FUNCTION NAME: air_vlan_getPortLeakyVlanEnable
+ * PURPOSE:
+ * Get leaky vlan enable of the port from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * pkt_type -- packet type
+ * OUTPUT:
+ * ptr_enable -- enable leaky
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getPortLeakyVlanEnable(
+ const UI32_T unit,
+ const UI32_T port,
+ AIR_LEAKY_PKT_TYPE_T pkt_type,
+ BOOL_T *ptr_enable)
+{
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+ UI32_T val = 0;
+
+ AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
+ AIR_PARAM_CHK((pkt_type >= AIR_LEAKY_PKT_TYPE_LAST), AIR_E_BAD_PARAMETER);
+ AIR_CHECK_PTR(ptr_enable);
+
+ aml_readReg(unit, PVC(port), &val);
+
+ if (pkt_type == AIR_LEAKY_PKT_TYPE_UNICAST)
+ {
+ *ptr_enable = val & PVC_UC_LKYV_EN_MASK ? TRUE : FALSE;
+ }
+ else if (pkt_type == AIR_LEAKY_PKT_TYPE_MULTICAST)
+ {
+ *ptr_enable = val & PVC_MC_LKYV_EN_MASK ? TRUE : FALSE;
+ }
+ else
+ {
+ *ptr_enable = val & PVC_BC_LKYV_EN_MASK ? TRUE : FALSE;
+ }
+
+ return rc;
+}
+
+/* FUNCTION NAME: air_vlan_setPortAttr
+ * PURPOSE:
+ * Set vlan port attribute from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * attr -- vlan port attr
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setPortAttr(
+ const UI32_T unit,
+ const UI32_T port,
+ const AIR_VLAN_PORT_ATTR_T attr)
+{
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+ UI32_T val = 0;
+
+ AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
+ AIR_PARAM_CHK((attr >= AIR_VLAN_PORT_ATTR_LAST), AIR_E_BAD_PARAMETER);
+
+ aml_readReg(unit, PVC(port), &val);
+ val &= ~PVC_VLAN_ATTR_MASK;
+ val |= (attr & PVC_VLAN_ATTR_RELMASK) << PVC_VLAN_ATTR_OFFT;
+ aml_writeReg(unit, PVC(port), val);
+
+ return rc;
+}
+
+/* FUNCTION NAME: air_vlan_getPortAttr
+ * PURPOSE:
+ * Get vlan port attribute from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * OUTPUT:
+ * ptr_attr -- vlan port attr
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getPortAttr(
+ const UI32_T unit,
+ const UI32_T port,
+ AIR_VLAN_PORT_ATTR_T *ptr_attr)
+{
+ AIR_ERROR_NO_T rc = AIR_E_OK;
+ UI32_T val = 0;
+
+ AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
+ AIR_CHECK_PTR(ptr_attr);
+
+ aml_readReg(unit, PVC(port), &val);
+ *ptr_attr = (val >> PVC_VLAN_ATTR_OFFT) & PVC_VLAN_ATTR_RELMASK;
+
+ return rc;
+}
+
+/* FUNCTION NAME: air_vlan_setIgrPortTagAttr
+ * PURPOSE:
+ * Set vlan incoming port egress tag attribute from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * attr -- egress tag attr
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setIgrPortTagAttr(
+ const UI32_T unit,
+ const UI32_T port,
+ const AIR_IGR_PORT_EG_TAG_ATTR_T attr)
+{
+ UI32_T val = 0;
+
+ AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
+ AIR_PARAM_CHK((attr >= AIR_IGR_PORT_EG_TAG_ATTR_LAST), AIR_E_BAD_PARAMETER);
+
+ aml_readReg(unit, PVC(port), &val);
+ val &= ~PVC_EG_TAG_MASK;
+ val |= (attr & PVC_EG_TAG_RELMASK) << PVC_EG_TAG_OFFT;
+ aml_writeReg(unit, PVC(port), val);
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_getIgrPortTagAttr
+ * PURPOSE:
+ * Get vlan incoming port egress tag attribute from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * OUTPUT:
+ * ptr_attr -- egress tag attr
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getIgrPortTagAttr(
+ const UI32_T unit,
+ const UI32_T port,
+ AIR_IGR_PORT_EG_TAG_ATTR_T *ptr_attr)
+{
+ UI32_T val = 0;
+
+ AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
+ AIR_CHECK_PTR(ptr_attr);
+
+ aml_readReg(unit, PVC(port), &val);
+ *ptr_attr = (val >> PVC_EG_TAG_OFFT) & PVC_EG_TAG_RELMASK;
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_setPortEgsTagAttr
+ * PURPOSE:
+ * Set vlan port egress tag attribute from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * attr -- egress tag attr
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setPortEgsTagAttr(
+ const UI32_T unit,
+ const UI32_T port,
+ const AIR_PORT_EGS_TAG_ATTR_T attr)
+{
+ UI32_T val = 0;
+
+ AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
+ AIR_PARAM_CHK((attr >= AIR_PORT_EGS_TAG_ATTR_LAST), AIR_E_BAD_PARAMETER);
+
+ aml_readReg(unit, PCR(port), &val);
+ val &= ~PCR_EG_TAG_MASK;
+ val |= (attr & PCR_EG_TAG_RELMASK) << PCR_EG_TAG_OFFT;
+ aml_writeReg(unit, PCR(port), val);
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_getPortEgsTagAttr
+ * PURPOSE:
+ * Get vlan port egress tag attribute from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * OUTPUT:
+ * ptr_attr -- egress tag attr
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getPortEgsTagAttr(
+ const UI32_T unit,
+ const UI32_T port,
+ AIR_PORT_EGS_TAG_ATTR_T *ptr_attr)
+{
+ UI32_T val = 0;
+
+ AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
+ AIR_CHECK_PTR(ptr_attr);
+
+ aml_readReg(unit, PCR(port), &val);
+ *ptr_attr = (val >> PCR_EG_TAG_OFFT) & PCR_EG_TAG_RELMASK;
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_setPortOuterTPID
+ * PURPOSE:
+ * Set stack tag TPID of the port from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * tpid -- TPID
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setPortOuterTPID(
+ const UI32_T unit,
+ const UI32_T port,
+ const UI16_T tpid)
+{
+ UI32_T val = 0;
+
+ AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
+
+ aml_readReg(unit, PVC(port), &val);
+ val &= ~PVC_STAG_VPID_MASK;
+ val |= (tpid & PVC_STAG_VPID_RELMASK) << PVC_STAG_VPID_OFFT;
+ aml_writeReg(unit, PVC(port), val);
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_getPortOuterTPID
+ * PURPOSE:
+ * Get stack tag TPID of the port from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * OUTPUT:
+ * ptr_tpid -- TPID
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getPortOuterTPID(
+ const UI32_T unit,
+ const UI32_T port,
+ UI16_T *ptr_tpid)
+{
+ UI32_T val = 0;
+
+ AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
+ AIR_CHECK_PTR(ptr_tpid);
+
+ aml_readReg(unit, PVC(port), &val);
+ *ptr_tpid = (val >> PVC_STAG_VPID_OFFT) & PVC_STAG_VPID_RELMASK;
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_setPortPVID
+ * PURPOSE:
+ * Set PVID of the port from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * pvid -- native vlan id
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setPortPVID(
+ const UI32_T unit,
+ const UI32_T port,
+ const UI16_T pvid)
+{
+ UI32_T val = 0;
+
+ AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
+ AIR_PARAM_CHK((pvid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+
+ aml_readReg(unit, PVID(port), &val);
+ val &= ~PVID_PCVID_MASK;
+ val |= (pvid & PVID_PCVID_RELMASK) << PVID_PCVID_OFFT;
+ aml_writeReg(unit, PVID(port), val);
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_getPortPVID
+ * PURPOSE:
+ * Get PVID of the port from the specified device.
+ * INPUT:
+ * unit -- unit id
+ * port -- port id
+ * OUTPUT:
+ * ptr_pvid -- native vlan id
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getPortPVID(
+ const UI32_T unit,
+ const UI32_T port,
+ UI16_T *ptr_pvid)
+{
+ UI32_T val = 0;
+
+ AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
+ AIR_CHECK_PTR(ptr_pvid);
+
+ aml_readReg(unit, PVID(port), &val);
+ *ptr_pvid = (val >> PVID_PCVID_OFFT) & PVID_PCVID_RELMASK;
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_setServiceTag
+ * PURPOSE:
+ * Set Vlan service tag.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * stag -- service stag
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setServiceTag(
+ const UI32_T unit,
+ const UI16_T vid,
+ const UI16_T stag)
+{
+ AIR_VLAN_ENTRY_T vlan_entry = {0};
+
+ AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+ AIR_PARAM_CHK((stag > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+
+ _air_vlan_readEntry(unit, vid, &vlan_entry);
+ if (!vlan_entry.valid)
+ return AIR_E_ENTRY_NOT_FOUND;
+
+ vlan_entry.vlan_entry_format.stag = stag;
+ _air_vlan_writeEntry(unit, vid, &vlan_entry);
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_getServiceTag
+ * PURPOSE:
+ * Get Vlan service tag.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * OUTPUT:
+ * ptr_stag -- service stag
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getServiceTag(
+ const UI32_T unit,
+ const UI16_T vid,
+ UI16_T *ptr_stag)
+{
+ AIR_VLAN_ENTRY_T vlan_entry = {0};
+
+ AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+ AIR_CHECK_PTR(ptr_stag);
+
+ _air_vlan_readEntry(unit, vid, &vlan_entry);
+ if (!vlan_entry.valid)
+ return AIR_E_ENTRY_NOT_FOUND;
+
+ *ptr_stag = vlan_entry.vlan_entry_format.stag;
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_setEgsTagCtlEnable
+ * PURPOSE:
+ * Set per vlan egress tag control.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * enable -- enable vlan egress tag control
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setEgsTagCtlEnable(
+ const UI32_T unit,
+ const UI16_T vid,
+ const BOOL_T enable)
+{
+ AIR_VLAN_ENTRY_T vlan_entry = {0};
+
+ AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+
+ _air_vlan_readEntry(unit, vid, &vlan_entry);
+ if (!vlan_entry.valid)
+ return AIR_E_ENTRY_NOT_FOUND;
+
+ vlan_entry.vlan_entry_format.eg_ctrl_en = enable ? 1 : 0;
+ _air_vlan_writeEntry(unit, vid, &vlan_entry);
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_getEgsTagCtlEnable
+ * PURPOSE:
+ * Get per vlan egress tag control.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * OUTPUT:
+ * ptr_enable -- enable vlan egress tag control
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getEgsTagCtlEnable(
+ const UI32_T unit,
+ const UI16_T vid,
+ BOOL_T *ptr_enable)
+{
+ AIR_VLAN_ENTRY_T vlan_entry = {0};
+
+ AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+ AIR_CHECK_PTR(ptr_enable);
+
+ _air_vlan_readEntry(unit, vid, &vlan_entry);
+ if (!vlan_entry.valid)
+ return AIR_E_ENTRY_NOT_FOUND;
+
+ *ptr_enable = vlan_entry.vlan_entry_format.eg_ctrl_en;
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_setEgsTagConsistent
+ * PURPOSE:
+ * Set per vlan egress tag consistent.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * enable -- enable vlan egress tag consistent
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setEgsTagConsistent(
+ const UI32_T unit,
+ const UI16_T vid,
+ const BOOL_T enable)
+{
+ AIR_VLAN_ENTRY_T vlan_entry = {0};
+
+ AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+
+ _air_vlan_readEntry(unit, vid, &vlan_entry);
+ if (!vlan_entry.valid)
+ return AIR_E_ENTRY_NOT_FOUND;
+
+ vlan_entry.vlan_entry_format.eg_con = enable;
+ _air_vlan_writeEntry(unit, vid, &vlan_entry);
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_getEgsTagConsistent
+ * PURPOSE:
+ * Get per vlan egress tag consistent.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * OUTPUT:
+ * ptr_enable -- enable vlan egress tag consistent
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getEgsTagConsistent(
+ const UI32_T unit,
+ const UI16_T vid,
+ BOOL_T *ptr_enable)
+{
+ AIR_VLAN_ENTRY_T vlan_entry = {0};
+
+ AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+ AIR_CHECK_PTR(ptr_enable);
+
+ _air_vlan_readEntry(unit, vid, &vlan_entry);
+ if (!vlan_entry.valid)
+ return AIR_E_ENTRY_NOT_FOUND;
+
+ *ptr_enable = vlan_entry.vlan_entry_format.eg_con;
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_setPortBasedStag
+ * PURPOSE:
+ * Set vlan port based stag enable.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * enable -- vlan port based stag enable
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setPortBasedStag(
+ const UI32_T unit,
+ const UI16_T vid,
+ const BOOL_T enable)
+{
+ AIR_VLAN_ENTRY_T vlan_entry = {0};
+
+ AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+
+ _air_vlan_readEntry(unit, vid, &vlan_entry);
+ if (!vlan_entry.valid)
+ return AIR_E_ENTRY_NOT_FOUND;
+
+ vlan_entry.vlan_entry_format.port_stag = enable;
+ _air_vlan_writeEntry(unit, vid, &vlan_entry);
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_getPortBasedStag
+ * PURPOSE:
+ * Get vlan port based stag enable.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * OUTPUT:
+ * ptr_enable -- vlan port based stag enable
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getPortBasedStag(
+ const UI32_T unit,
+ const UI16_T vid,
+ BOOL_T *ptr_enable)
+{
+ AIR_VLAN_ENTRY_T vlan_entry = {0};
+
+ AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+ AIR_CHECK_PTR(ptr_enable);
+
+ _air_vlan_readEntry(unit, vid, &vlan_entry);
+ if (!vlan_entry.valid)
+ return AIR_E_ENTRY_NOT_FOUND;
+
+ *ptr_enable = vlan_entry.vlan_entry_format.port_stag;
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_setPortEgsTagCtl
+ * PURPOSE:
+ * Set vlan port egress tag control.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * port -- port id
+ * tag_ctl -- egress tag control
+ * OUTPUT:
+ * None
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_setPortEgsTagCtl(
+ const UI32_T unit,
+ const UI16_T vid,
+ const UI32_T port,
+ const AIR_VLAN_PORT_EGS_TAG_CTL_TYPE_T tag_ctl)
+{
+ AIR_VLAN_ENTRY_T vlan_entry = {0};
+
+ AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+ AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
+ AIR_PARAM_CHK((tag_ctl >= AIR_PORT_EGS_TAG_ATTR_LAST), AIR_E_BAD_PARAMETER);
+
+ _air_vlan_readEntry(unit, vid, &vlan_entry);
+ if (!vlan_entry.valid)
+ return AIR_E_ENTRY_NOT_FOUND;
+
+ vlan_entry.vlan_entry_format.eg_ctrl &= ~(0x3 << (port * 2));
+ vlan_entry.vlan_entry_format.eg_ctrl |= (tag_ctl & 0x3) << (port * 2);
+ _air_vlan_writeEntry(unit, vid, &vlan_entry);
+
+ return AIR_E_OK;
+}
+
+/* FUNCTION NAME: air_vlan_getPortEgsTagCtl
+ * PURPOSE:
+ * Get vlan port egress tag control.
+ * INPUT:
+ * unit -- unit id
+ * vid -- vlan id
+ * OUTPUT:
+ * ptr_tag_ctl -- egress tag control
+ * RETURN:
+ * AIR_E_OK -- Successfully read the data.
+ * AIR_E_OTHERS -- Operation failed.
+ * AIR_E_BAD_PARAMETER -- Invalid parameter.
+ * NOTES:
+ * none
+ */
+AIR_ERROR_NO_T
+air_vlan_getPortEgsTagCtl(
+ const UI32_T unit,
+ const UI16_T vid,
+ const UI32_T port,
+ AIR_VLAN_PORT_EGS_TAG_CTL_TYPE_T *ptr_tag_ctl)
+{
+ AIR_VLAN_ENTRY_T vlan_entry = {0};
+
+ AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
+ AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
+ AIR_CHECK_PTR(ptr_tag_ctl);
+
+ _air_vlan_readEntry(unit, vid, &vlan_entry);
+ if (!vlan_entry.valid)
+ return AIR_E_ENTRY_NOT_FOUND;
+
+ *ptr_tag_ctl = (vlan_entry.vlan_entry_format.eg_ctrl >> (port * 2)) & 0x3;
+
+ return AIR_E_OK;
+}
diff --git a/feed/app/switch/src/an8855_sdk/core/an8855_mdio.h b/feed/app/switch/src/an8855_sdk/core/an8855_mdio.h
index c2d4bd7..5322393 100644
--- a/feed/app/switch/src/an8855_sdk/core/an8855_mdio.h
+++ b/feed/app/switch/src/an8855_sdk/core/an8855_mdio.h
@@ -1,203 +1,203 @@
-/* FILE NAME: an8855_mdio.h
- * PURPOSE:
- * It provides AN8855 mdio access API.
- * NOTES:
- *
- */
-
-#ifndef AN8855_MDIO_H
-#define AN8855_MDIO_H
-
-/* INCLUDE FILE DECLARATIONS
- */
-//#include "CTP_type.h"
-//#include "CTP_shell.h"
-//#include "common.h"
-//#include "eth.h"
-
-/* NAMING CONSTANT DECLARATIONS
- */
-
-/* MACRO FUNCTION DECLARATIONS
- */
-/* Attention!! Customer should define udelay function */
-void delayUs(int usecond);
-#define an8855_udelay(us) delayUs(us)
-
-/* Attention!! Customer should define dbg_print to get dbg output */
-#ifndef dbg_print
-#define dbg_print(...)
-#endif
-
-#define AN8855_PHY_NUM 5
-
-/* DATA TYPE DECLARATIONS
- */
-#ifndef NULL
-#define NULL 0L
-#endif
-
-#ifndef u32
-#define u32 unsigned int
-#endif
-
-#ifndef u16
-#define u16 unsigned short
-#endif
-
-#ifndef u8
-#define u8 unsigned char
-#endif
-
-typedef u32 (*AIR_MII_READ_FUNC_T) (u32 phy_addr, u32 reg, u32 *p_data);
-
-typedef u32 (*AIR_MII_WRITE_FUNC_T) (u32 phy_addr, u32 reg, u32 data);
-
-typedef u32 (*AIR_MII_C45_READ_FUNC_T) (u32 phy_addr, u32 dev, u32 reg, u32 *p_data);
-
-typedef u32 (*AIR_MII_C45_WRITE_FUNC_T) (u32 phy_addr, u32 dev, u32 reg, u32 data);
-
-extern u32 g_smi_addr;
-
-/* EXPORTED SUBPROGRAM SPECIFICATIONS
- */
-
-/* FUNCTION NAME: an8855_set_smi_addr
- * PURPOSE:
- * This API is used to set an8855 smi address.
- * INPUT:
- * smi_addr -- AN8855 smi address
- * OUTPUT:
- * RETURN:
- * NOTES:
- * None
- */
-void
-an8855_set_smi_addr(u32 smi_addr);
-
-/* FUNCTION NAME: an8855_set_mii_callback
- * PURPOSE:
- * This API is used to set an8855 mii access callbacks.
- * INPUT:
- * mii_read -- mii read api function
- * mii_write -- mii write api function
- * OUTPUT:
- * RETURN:
- * 0 -- Successfully set callback.
- * -1 -- Setting callback failed.
- * NOTES:
- * None
- */
-int
-an8855_set_mii_callback(
- AIR_MII_READ_FUNC_T mii_read,
- AIR_MII_WRITE_FUNC_T mii_write,
- AIR_MII_C45_READ_FUNC_T mii_c45_read,
- AIR_MII_C45_WRITE_FUNC_T mii_c45_write);
-
-/* FUNCTION NAME: an8855_reg_read
- * PURPOSE:
- * This API is used read an8855 registers.
- * INPUT:
- * reg -- register offset
- * OUTPUT:
- * RETURN:
- * Register value
- * NOTES:
- * Attention!! Customer should implement mdio mutex
- * lock in this func
- */
-u32
-an8855_reg_read(u32 reg);
-
-/* FUNCTION NAME: an8855_reg_write
- * PURPOSE:
- * This API is used write an8855 registers.
- * INPUT:
- * reg -- register offset
- * val -- register value
- * OUTPUT:
- * RETURN:
- * NOTES:
- * Attention!! Customer should implement mdio mutex
- * lock in this func
- */
-void
-an8855_reg_write(u32 reg, u32 val);
-
-/* FUNCTION NAME: an8855_phy_read
- * PURPOSE:
- * This API is used read an8855 phy registers.
- * INPUT:
- * port_num -- port number, 0~4
- * reg -- phy register offset
- * OUTPUT:
- * p_val -- phy register value
- * RETURN:
- * 0 -- read success
- * -1 -- read failure
- * NOTES:
- * Attention!! Customer should implement mii mutex
- * lock in this func
- */
-int
-an8855_phy_read(u32 port_num, u32 reg, u32 *p_val);
-
-/* FUNCTION NAME: an8855_phy_write
- * PURPOSE:
- * This API is used write an8855 phy registers.
- * INPUT:
- * port_num -- port number, 0~4
- * reg -- phy register offset
- * val -- phy register value
- * OUTPUT:
- * RETURN:
- * 0 -- write success
- * -1 -- write failure
- * NOTES:
- * Attention!! Customer should implement mii mutex
- * lock in this func
- */
-int
-an8855_phy_write(u32 port_num, u32 reg, u32 val);
-
-/* FUNCTION NAME: an8855_phy_read_cl45
- * PURPOSE:
- * This API is used read an8855 phy registers.
- * INPUT:
- * port_num -- port number, 0~4
- * dev_addr -- phy device type
- * reg_addr -- phy register offset
- * OUTPUT:
- * p_val -- phy register value
- * RETURN:
- * 0 -- read success
- * -1 -- read failure
- * NOTES:
- * Attention!! Customer should implement mii mutex
- * lock in this func or before/after calling this func
- */
-u32
-an8855_phy_read_cl45(u32 port_num, u32 dev_addr, u32 reg_addr, u32 *p_val);
-
-/* FUNCTION NAME: an8855_phy_write_cl45
- * PURPOSE:
- * This API is used write an8855 phy registers.
- * INPUT:
- * port_num -- port number, 0~4
- * dev_addr -- phy device type
- * reg_addr -- phy register offset
- * val -- phy register value
- * OUTPUT:
- * RETURN:
- * 0 -- write success
- * -1 -- write failure
- * NOTES:
- * Attention!! Customer should implement mii mutex
- * lock in this func or before/after calling this func
- */
-int
-an8855_phy_write_cl45(u32 port_num, u32 dev_addr, u32 reg_addr, u32 val);
-
-#endif /* End of AN8855_MDIO_H */
-
+/* FILE NAME: an8855_mdio.h
+ * PURPOSE:
+ * It provides AN8855 mdio access API.
+ * NOTES:
+ *
+ */
+
+#ifndef AN8855_MDIO_H
+#define AN8855_MDIO_H
+
+/* INCLUDE FILE DECLARATIONS
+ */
+//#include "CTP_type.h"
+//#include "CTP_shell.h"
+//#include "common.h"
+//#include "eth.h"
+
+/* NAMING CONSTANT DECLARATIONS
+ */
+
+/* MACRO FUNCTION DECLARATIONS
+ */
+/* Attention!! Customer should define udelay function */
+void delayUs(int usecond);
+#define an8855_udelay(us) delayUs(us)
+
+/* Attention!! Customer should define dbg_print to get dbg output */
+#ifndef dbg_print
+#define dbg_print(...)
+#endif
+
+#define AN8855_PHY_NUM 5
+
+/* DATA TYPE DECLARATIONS
+ */
+#ifndef NULL
+#define NULL 0L
+#endif
+
+#ifndef u32
+#define u32 unsigned int
+#endif
+
+#ifndef u16
+#define u16 unsigned short
+#endif
+
+#ifndef u8
+#define u8 unsigned char
+#endif
+
+typedef u32 (*AIR_MII_READ_FUNC_T) (u32 phy_addr, u32 reg, u32 *p_data);
+
+typedef u32 (*AIR_MII_WRITE_FUNC_T) (u32 phy_addr, u32 reg, u32 data);
+
+typedef u32 (*AIR_MII_C45_READ_FUNC_T) (u32 phy_addr, u32 dev, u32 reg, u32 *p_data);
+
+typedef u32 (*AIR_MII_C45_WRITE_FUNC_T) (u32 phy_addr, u32 dev, u32 reg, u32 data);
+
+extern u32 g_smi_addr;
+
+/* EXPORTED SUBPROGRAM SPECIFICATIONS
+ */
+
+/* FUNCTION NAME: an8855_set_smi_addr
+ * PURPOSE:
+ * This API is used to set an8855 smi address.
+ * INPUT:
+ * smi_addr -- AN8855 smi address
+ * OUTPUT:
+ * RETURN:
+ * NOTES:
+ * None
+ */
+void
+an8855_set_smi_addr(u32 smi_addr);
+
+/* FUNCTION NAME: an8855_set_mii_callback
+ * PURPOSE:
+ * This API is used to set an8855 mii access callbacks.
+ * INPUT:
+ * mii_read -- mii read api function
+ * mii_write -- mii write api function
+ * OUTPUT:
+ * RETURN:
+ * 0 -- Successfully set callback.
+ * -1 -- Setting callback failed.
+ * NOTES:
+ * None
+ */
+int
+an8855_set_mii_callback(
+ AIR_MII_READ_FUNC_T mii_read,
+ AIR_MII_WRITE_FUNC_T mii_write,
+ AIR_MII_C45_READ_FUNC_T mii_c45_read,
+ AIR_MII_C45_WRITE_FUNC_T mii_c45_write);
+
+/* FUNCTION NAME: an8855_reg_read
+ * PURPOSE:
+ * This API is used read an8855 registers.
+ * INPUT:
+ * reg -- register offset
+ * OUTPUT:
+ * RETURN:
+ * Register value
+ * NOTES:
+ * Attention!! Customer should implement mdio mutex
+ * lock in this func
+ */
+u32
+an8855_reg_read(u32 reg);
+
+/* FUNCTION NAME: an8855_reg_write
+ * PURPOSE:
+ * This API is used write an8855 registers.
+ * INPUT:
+ * reg -- register offset
+ * val -- register value
+ * OUTPUT:
+ * RETURN:
+ * NOTES:
+ * Attention!! Customer should implement mdio mutex
+ * lock in this func
+ */
+void
+an8855_reg_write(u32 reg, u32 val);
+
+/* FUNCTION NAME: an8855_phy_read
+ * PURPOSE:
+ * This API is used read an8855 phy registers.
+ * INPUT:
+ * port_num -- port number, 0~4
+ * reg -- phy register offset
+ * OUTPUT:
+ * p_val -- phy register value
+ * RETURN:
+ * 0 -- read success
+ * -1 -- read failure
+ * NOTES:
+ * Attention!! Customer should implement mii mutex
+ * lock in this func
+ */
+int
+an8855_phy_read(u32 port_num, u32 reg, u32 *p_val);
+
+/* FUNCTION NAME: an8855_phy_write
+ * PURPOSE:
+ * This API is used write an8855 phy registers.
+ * INPUT:
+ * port_num -- port number, 0~4
+ * reg -- phy register offset
+ * val -- phy register value
+ * OUTPUT:
+ * RETURN:
+ * 0 -- write success
+ * -1 -- write failure
+ * NOTES:
+ * Attention!! Customer should implement mii mutex
+ * lock in this func
+ */
+int
+an8855_phy_write(u32 port_num, u32 reg, u32 val);
+
+/* FUNCTION NAME: an8855_phy_read_cl45
+ * PURPOSE:
+ * This API is used read an8855 phy registers.
+ * INPUT:
+ * port_num -- port number, 0~4
+ * dev_addr -- phy device type
+ * reg_addr -- phy register offset
+ * OUTPUT:
+ * p_val -- phy register value
+ * RETURN:
+ * 0 -- read success
+ * -1 -- read failure
+ * NOTES:
+ * Attention!! Customer should implement mii mutex
+ * lock in this func or before/after calling this func
+ */
+u32
+an8855_phy_read_cl45(u32 port_num, u32 dev_addr, u32 reg_addr, u32 *p_val);
+
+/* FUNCTION NAME: an8855_phy_write_cl45
+ * PURPOSE:
+ * This API is used write an8855 phy registers.
+ * INPUT:
+ * port_num -- port number, 0~4
+ * dev_addr -- phy device type
+ * reg_addr -- phy register offset
+ * val -- phy register value
+ * OUTPUT:
+ * RETURN:
+ * 0 -- write success
+ * -1 -- write failure
+ * NOTES:
+ * Attention!! Customer should implement mii mutex
+ * lock in this func or before/after calling this func
+ */
+int
+an8855_phy_write_cl45(u32 port_num, u32 dev_addr, u32 reg_addr, u32 val);
+
+#endif /* End of AN8855_MDIO_H */
+
diff --git a/feed/app/switch/src/an8855_sdk/core/an8855_phy.h b/feed/app/switch/src/an8855_sdk/core/an8855_phy.h
index 3c810e7..70836e8 100644
--- a/feed/app/switch/src/an8855_sdk/core/an8855_phy.h
+++ b/feed/app/switch/src/an8855_sdk/core/an8855_phy.h
@@ -1,409 +1,409 @@
-/* FILE NAME: an8855_phy.h
- * PURPOSE:
- * It provides AN8855 phy definition.
- * NOTES:
- *
- */
-
-#ifndef _AN8855_PHY_H_
-#define _AN8855_PHY_H_
-
-
-/* Type Definitions */
-#define int8_t char
-#define uint8_t unsigned char
-#define int16_t short
-#define uint16_t unsigned short
-#define int32_t int
-#define uint32_t unsigned int
-/* DATA TYPE DECLARATIONS
- */
-typedef int BOOL_T;
-typedef signed char I8_T;
-typedef unsigned char UI8_T;
-typedef signed short I16_T;
-typedef unsigned short UI16_T;
-typedef signed int I32_T;
-typedef unsigned int UI32_T;
-typedef char C8_T;
-typedef unsigned long long UI64_T;
-
-typedef UI8_T AIR_MAC_T[6];
-
-/* Debug flags */
-//#define _MDIO_BOOTS_MODE 1 // Boots for preamble
-#define _DEBUG_PRINT 1 // Debug print for Arduino
-//#define _DEBUG_PRINT_eFuse 1
-#define _write_eFuse 1
-
-#define _DEBUG_SCAN_ALL 0 // Scan all Code for SerDes Calibration
-#define _WRITE_RG_DIR 1 // Write RG directly for Calibration
-#define _USER_DEFINE_MODE 0 // Replace to user-defined RG for Calibration
-#define _DEBUG_MANUAL 1 // dbg_20210604 // manual dbg_20210604
-/**************************************************************************/
-
-/* Phy Address */
-//#define phyadd_common 0x1d // EN8801
-//#define PHY_NUM 1 // EN8801
-//#define phyadd_common 0x9 // EN7523
-//#define PHY_NUM 4 // EN7523
-//#define phyadd_common 0x0 // EN8850
-//#define PHY_NUM 5 // EN8850
-#define PHY_NUM 4 // EN8851
-#define CALIPOLARITY 1
-
-#define TXAMP_offset 0 // for 8851
-
-/* On/Off */
-//#define ENABLE 1
-//#define DISABLE 0
-#define Relay_ENABLE 1
-#define Relay_DISABLE 0
-
-/* FT Pattern */
-#define _MDIO 0x0
-#define _I2C 0x1
-#define FT_USB3_T101 0x0
-#define FT_PCIE0_T101 0x1
-#define FT_PCIE1_T101 0x2
-#define FT_PON_T101 0x3
-
-/********* Digital pin definition *************/
-#define Relay_Tx_PN 22 // relay 1
-#define Relay_R_R50 23 // relay 2
-#define Relay_Tx_Vol 24 // relay 3
-#define Relay_Rx_Vol 25 // relay 4
-#define Relay_DUT_GND 26 // relay 5
-#define Relay_I2C 27 // PIN for SCL&SDA , relay 6
-//#define Relay_I2C_SCL 27 // PIN for SCL&SDA , relay 6
-//#define Relay_I2C_SDA 28 // PIN for SCL&SDA , relay 6
-
-#define pin_MDIO 36 // PIN for MDIO
-#define pin_MDC 37 // PIN for MDC
-#define FT_PATTERN_bit0 49 // PIN for FT0
-#define FT_PATTERN_bit1 48 // PIN for FT1
-#define Relay_MDIO 35 // PIN for MDIO relay, relay 7
-
-/***********************************************/
-/* Use for I/O register PORTA control */
-#define POR_Relay_Tx_PN D22 // use for PORTA control, relay 1
-#define POR_Relay_R_R50 D23 // use for PORTA control, relay 2
-#define POR_Relay_Tx_Vol D24 // use for PORTA control, relay 3
-#define POR_Relay_Rx_Vol D25 // use for PORTA control, relay 4
-#define POR_Relay_DUT_GND D26 // use for PORTA control, relay 5
-//#define POR_Relay_I2C D27 // use for PORTA control, relay 6
-#define POR_Relay_I2C_SCL D27 // use for PORTA control, relay 6
-#define POR_Relay_I2C_SDA D28 // use for PORTA control, relay 7
-
-/* Use for I/O register PORTC control */
-#define POR_MDIO D36 // use for PORTC control
-#define POR_MDC D37 // use for PORTC control
-#define POR_Relay_MDIO D35 // use for PORTC control, relay 7
-
-/* Use for I/O register PORTL control */
-#define POR_FT_PATTERN_bit0 D49 // use for PORTL control
-#define POR_FT_PATTERN_bit1 D48 // use for PORTL control
-
-
-/* I/O register Port A */
-#define D22 0
-#define D23 1
-#define D24 2
-#define D25 3
-#define D26 4
-#define D27 5
-#define D28 6
-#define D29 7
-
-/* I/O register Port C */
-#define D37 0
-#define D36 1
-#define D35 2
-#define D34 3
-#define D33 4
-#define D32 5
-#define D31 6
-#define D30 7
-
-/* I/O register Port L */
-#define D49 0
-#define D48 1
-#define D47 2
-#define D46 3
-#define D45 4
-#define D44 5
-#define D43 6
-#define D42 7
-
-/* I/O register Port D */
-#define D21 0
-#define D20 1
-#define D19 2
-#define D18 3
-
-
-/***************************************************************************
-**************************************************************************
-* MDC/MDIO
-***************************************************************************
-***************************************************************************/
-#define SET_HIGH(data, nbit) ((data)|=(nbit))
-#define SET_LOW(data, nbit) ((data)&=~(nbit))
-
-#define MDIO_ONE _BV(POR_MDIO)
-#define MDIO_ZERO 0x00
-#define MDC_ONE _BV(POR_MDC)
-#define MDC_ZERO 0x00
-
-#define delay_us delayMicroseconds(0)
-
-#define ANACAL_INIT 0x01
-#define ANACAL_ERROR 0xFD
-#define ANACAL_SATURATION 0xFE
-#define ANACAL_FINISH 0xFF
-#define ANACAL_PAIR_A 0
-#define ANACAL_PAIR_B 1
-#define ANACAL_PAIR_C 2
-#define ANACAL_PAIR_D 3
-#define DAC_IN_0V 0x000
-#define DAC_IN_2V 0x0f0 // +/-1V
-
-#define ZCAL_MIDDLE 0x20
-#define TX_OFFSET_0mV_idx 31
-#define TX_AMP_MIDDLE 0x20
-
-#define TX_i2mpb_hbt_ofs 0x4 // 8851 fine tune 100M v1 (20220414)
-#define R50_OFFSET_VALUE 0x5
-
-//============== definition value for GbE ===================//
-#define BG_VOLTAGE_OUT 0xc0
-#define FORCE_MDI 2
-#define FORCE_MDIX 3
-#define LDO_1p15_VOSEL_1 1
-#define RX_CAL_VALUE_9 0x3
-#define RX_CAL_HVGA_BW_2 0x2
-#define RX_CAL_DCO_Normal 0x0
-#define RX_CAL_DCO_BYPASS_TX_RX 0x3
-#define RX_CAL_DCO_0xF 0xF
-
-#define TANA_MON_DCV_SEL__MASK 0xE0
-#define TANA_MON_DCV_SEL__MPX_TANA_A 0x20
-#define TANA_MON_DCV_SEL__MPX_TANA_B 0x40
-#define TANA_MON_DCV_SEL__MPX_TANA_C 0x60
-#define TANA_MON_DCV_SEL__MPX_TANA_D 0x80
-#define TANA_MON_DCV_SEL__MONVC__MASK 0x008000C8
-#define TANA_MON_DCV__TANA__VBG_MON 0x000000C0
-#define TANA_MON_DCV__TANA__MONVC 0x000000C8
-
-#define AN_disable_force_1000M 0x0140
-#define BG_voltage_output 0xc000
-#define Fix_mdi 0x1010
-#define Disable_tx_slew_control 0x0000
-#define LDO_control 0x0100
-#define Cal_control_BG 0x1110
-#define Cal_control_R50 0x1100
-#define Cal_control_TX_AMP 0x1100
-#define Cal_control_TX_OFST 0x0100
-#define Cal_control_R50_pairA_ENABLE 0x1101
-#define Disable_all 0x0
-#define Zcalen_A_ENABLE 0x0000
-#define Zcalen_B_ENABLE 0x1000
-#define Zcalen_C_ENABLE 0x0100
-#define Zcalen_D_ENABLE 0x0010
-#define MASK_MSB_8bit 0xff00
-#define MASK_LSB_8bit 0x00ff
-#define MASK_r50ohm_rsel_tx_a 0x7f00
-#define MASK_r50ohm_rsel_tx_b 0x007f
-#define MASK_r50ohm_rsel_tx_c 0x7f00
-#define MASK_r50ohm_rsel_tx_d 0x007f
-#define Rg_r50ohm_rsel_tx_a_en 0x8000
-#define Rg_r50ohm_rsel_tx_b_en 0x0080
-#define Rg_r50ohm_rsel_tx_c_en 0x8000
-#define Rg_r50ohm_rsel_tx_d_en 0x0080
-#define Rg_txvos_calen_ENABLE 0x0001
-#define Bypass_tx_offset_cal 0x8000
-#define Enable_Tx_VLD 0xf808
-#define Rg_txg_calen_a_ENABLE 0x1000
-#define Rg_txg_calen_b_ENABLE 0x0100
-#define Rg_txg_calen_c_ENABLE 0x0010
-#define Rg_txg_calen_d_ENABLE 0x0001
-#define Force_dasn_dac_in0_ENABLE 0x8000
-#define Force_dasn_dac_in1_ENABLE 0x8000
-#define MASK_cr_tx_amp_offset_MSB 0x3f00
-#define MASK_cr_tx_amp_offset_LSB 0x003f
-#define Rg_cal_refsel_ENABLE 0x0010
-#define MASK_da_tx_i2mpb_a_gbe 0xfc00
-#define MASK_da_tx_i2mpb_b_c_d_gbe 0x3f00
-
-#define LED_basic_control_en_active_low 0x800a
-#define LED_led0_en_active_high 0xc007
-#define LED_led0_force_blinking 0x0200
-
-
-
-/*phy calibration use*/
-//Type defines
-typedef unsigned char UINT8;
-typedef unsigned short UINT16;
-typedef unsigned long UINT32;
-
-typedef struct
-{
- UINT16 DATA_Lo;
- UINT8 DATA_Hi;
-}TR_DATA_T;
-
-//CL22 Reg Support Page Select//
-#define RgAddr_Reg1Fh 0x1f
-#define CL22_Page_Reg 0x0000
-#define CL22_Page_ExtReg 0x0001
-#define CL22_Page_MiscReg 0x0002
-#define CL22_Page_LpiReg 0x0003
-#define CL22_Page_tReg 0x02A3
-#define CL22_Page_TrReg 0x52B5
-
-//CL45 Reg Support DEVID//
-#define DEVID_03 0x03
-#define DEVID_07 0x07
-#define DEVID_1E 0x1E
-#define DEVID_1F 0x1F
-
-//TokenRing Reg Access//
-#define TrReg_PKT_XMT_STA 0x8000
-#define TrReg_WR 0x8000
-#define TrReg_RD 0xA000
-
-/* ----------------- gephy_all Bit Field Definitions ------------------- */
-
-
-
-//-------------------------------------
-//0x0000
-#define RgAddr_Reg00h 0x00
-
-//0x51e01200
-#define RgAddr_dev1Eh_reg120h 0x0120
-//0x51e01220
-#define RgAddr_dev1Eh_reg122h 0x0122
-//0x51e01440
-#define RgAddr_dev1Eh_reg144h 0x0144
-//0x51e014a0
-#define RgAddr_dev1Eh_reg14Ah 0x014a
-//0x51e019b0
-#define RgAddr_dev1Eh_reg19Bh 0x019b
-//0x51e02340
-#define RgAddr_dev1Eh_reg234h 0x0234
-//0x51e02380
-#define RgAddr_dev1Eh_reg238h 0x0238
-//0x51e02390
-#define RgAddr_dev1Eh_reg239h 0x0239
-//0x51f02680
-#define RgAddr_dev1Fh_reg268h 0x0268
-//0x51e02d10
-#define RgAddr_dev1Eh_reg2D1h 0x02d1
-//0x51e03230
-#define RgAddr_dev1Eh_reg323h 0x0323
-//0x51e03240
-#define RgAddr_dev1Eh_reg324h 0x0324
-//0x51e03260
-#define RgAddr_dev1Eh_reg326h 0x0326
-
-//0x51f01000
-#define RgAddr_dev1Fh_reg100h 0x0100
-//0x51e01450
-#define RgAddr_dev1Eh_reg145h 0x0145
-//0x51f00ff0
-#define RgAddr_dev1Fh_reg0FFh 0x00ff
-//0x51e00db0
-#define RgAddr_dev1Eh_reg0DBh 0x00db
-//0x51e00dc0
-#define RgAddr_dev1Eh_reg0DCh 0x00dc
-//0x51e00e00
-#define RgAddr_dev1Eh_reg0E0h 0x00e0
-//0x51e00e10
-#define RgAddr_dev1Eh_reg0E1h 0x00e1
-//0x51e00e00
-#define RgAddr_dev1Eh_reg0E0h 0x00e0
-//0x51e017a0
-#define RgAddr_dev1Eh_reg17Ah 0x017a
-//0x51f01150
-#define RgAddr_dev1Fh_reg115h 0x0115
-//0x51f01000
-#define RgAddr_dev1Fh_reg100h 0x0100
-//0x51e01450
-#define RgAddr_dev1Eh_reg145h 0x0145
-//0x51e01450
-#define RgAddr_dev1Eh_reg145h 0x0145
-//0x51e01850
-#define RgAddr_dev1Eh_reg185h 0x0185
-//0x51e00fb0
-#define RgAddr_dev1Eh_reg0FBh 0x00fb
-//0x51e01740
-#define RgAddr_dev1Eh_reg174h 0x0174
-//0x51e01750
-#define RgAddr_dev1Eh_reg175h 0x0175
-//0x51e01850
-#define RgAddr_dev1Eh_reg185h 0x0185
-//0x51e00fb0
-#define RgAddr_dev1Eh_reg0FBh 0x00fb
-//0x51e00960
-#define RgAddr_dev1Eh_reg096h 0x0096
-//0x51e003e0
-#define RgAddr_dev1Eh_reg03Eh 0x003e
-//0x51e00dd0
-#define RgAddr_dev1Eh_reg0DDh 0x00dd
-//0x51e017d0
-#define RgAddr_dev1Eh_reg17Dh 0x017d
-//0x51e01810
-#define RgAddr_dev1Eh_reg181h 0x0181
-//0x51e00120
-#define RgAddr_dev1Eh_reg012h 0x0012
-//0x51e017e0
-#define RgAddr_dev1Eh_reg17Eh 0x017e
-//0x51e01820
-#define RgAddr_dev1Eh_reg182h 0x0182
-//0x51e00170
-#define RgAddr_dev1Eh_reg017h 0x0017
-//0x51e01830
-#define RgAddr_dev1Eh_reg183h 0x0183
-//0x51e00190
-#define RgAddr_dev1Eh_reg019h 0x0019
-//0x51e01800
-#define RgAddr_dev1Eh_reg180h 0x0180
-//0x51e01840
-#define RgAddr_dev1Eh_reg184h 0x0184
-//0x51e00210
-#define RgAddr_dev1Eh_reg021h 0x0021
-//0x51e01720
-#define RgAddr_dev1Eh_reg172h 0x0172
-//0x51e01730
-#define RgAddr_dev1Eh_reg173h 0x0173
-//0x51e017c0
-#define RgAddr_dev1Eh_reg17Ch 0x017c
-//0x51e017f0
-#define RgAddr_dev1Eh_reg17Fh 0x017f
-
-//0x52b5100
-#define RgAddr_TrReg10h 0x10
-//0x52b5110
-#define RgAddr_TrReg11h 0x11
-//0x52b5120
-#define RgAddr_TrReg12h 0x12
-
-//0x31c0
-#define RgAddr_LpiReg1Ch 0x1c
-//0x31d0
-#define RgAddr_LpiReg1Dh 0x1d
-uint8_t BG_Calibration(uint8_t phyadd, int8_t calipolarity);
-uint8_t R50_Calibration(uint8_t phyadd, uint8_t phyadd_common);
-uint8_t TX_OFS_Calibration(uint8_t phyadd, uint8_t phyadd_common);
-uint8_t TX_AMP_Calibration(uint8_t phyadd, uint8_t phyadd_common);
-//void config_gphy_port(UINT8, UINT8);
-
-void set_gphy_reg_cl22(uint8_t, uint8_t, uint16_t);
-uint16_t get_gphy_reg_cl45(uint8_t, uint8_t, uint16_t);
-void set_gphy_reg_cl45(uint8_t, uint8_t, uint16_t, uint16_t);
-void anacal_exe(uint8_t);
-
-#endif /* _AN8855_PHY_H_ */
-
+/* FILE NAME: an8855_phy.h
+ * PURPOSE:
+ * It provides AN8855 phy definition.
+ * NOTES:
+ *
+ */
+
+#ifndef _AN8855_PHY_H_
+#define _AN8855_PHY_H_
+
+
+/* Type Definitions */
+#define int8_t char
+#define uint8_t unsigned char
+#define int16_t short
+#define uint16_t unsigned short
+#define int32_t int
+#define uint32_t unsigned int
+/* DATA TYPE DECLARATIONS
+ */
+typedef int BOOL_T;
+typedef signed char I8_T;
+typedef unsigned char UI8_T;
+typedef signed short I16_T;
+typedef unsigned short UI16_T;
+typedef signed int I32_T;
+typedef unsigned int UI32_T;
+typedef char C8_T;
+typedef unsigned long long UI64_T;
+
+typedef UI8_T AIR_MAC_T[6];
+
+/* Debug flags */
+//#define _MDIO_BOOTS_MODE 1 // Boots for preamble
+#define _DEBUG_PRINT 1 // Debug print for Arduino
+//#define _DEBUG_PRINT_eFuse 1
+#define _write_eFuse 1
+
+#define _DEBUG_SCAN_ALL 0 // Scan all Code for SerDes Calibration
+#define _WRITE_RG_DIR 1 // Write RG directly for Calibration
+#define _USER_DEFINE_MODE 0 // Replace to user-defined RG for Calibration
+#define _DEBUG_MANUAL 1 // dbg_20210604 // manual dbg_20210604
+/**************************************************************************/
+
+/* Phy Address */
+//#define phyadd_common 0x1d // EN8801
+//#define PHY_NUM 1 // EN8801
+//#define phyadd_common 0x9 // EN7523
+//#define PHY_NUM 4 // EN7523
+//#define phyadd_common 0x0 // EN8850
+//#define PHY_NUM 5 // EN8850
+#define PHY_NUM 4 // EN8851
+#define CALIPOLARITY 1
+
+#define TXAMP_offset 0 // for 8851
+
+/* On/Off */
+//#define ENABLE 1
+//#define DISABLE 0
+#define Relay_ENABLE 1
+#define Relay_DISABLE 0
+
+/* FT Pattern */
+#define _MDIO 0x0
+#define _I2C 0x1
+#define FT_USB3_T101 0x0
+#define FT_PCIE0_T101 0x1
+#define FT_PCIE1_T101 0x2
+#define FT_PON_T101 0x3
+
+/********* Digital pin definition *************/
+#define Relay_Tx_PN 22 // relay 1
+#define Relay_R_R50 23 // relay 2
+#define Relay_Tx_Vol 24 // relay 3
+#define Relay_Rx_Vol 25 // relay 4
+#define Relay_DUT_GND 26 // relay 5
+#define Relay_I2C 27 // PIN for SCL&SDA , relay 6
+//#define Relay_I2C_SCL 27 // PIN for SCL&SDA , relay 6
+//#define Relay_I2C_SDA 28 // PIN for SCL&SDA , relay 6
+
+#define pin_MDIO 36 // PIN for MDIO
+#define pin_MDC 37 // PIN for MDC
+#define FT_PATTERN_bit0 49 // PIN for FT0
+#define FT_PATTERN_bit1 48 // PIN for FT1
+#define Relay_MDIO 35 // PIN for MDIO relay, relay 7
+
+/***********************************************/
+/* Use for I/O register PORTA control */
+#define POR_Relay_Tx_PN D22 // use for PORTA control, relay 1
+#define POR_Relay_R_R50 D23 // use for PORTA control, relay 2
+#define POR_Relay_Tx_Vol D24 // use for PORTA control, relay 3
+#define POR_Relay_Rx_Vol D25 // use for PORTA control, relay 4
+#define POR_Relay_DUT_GND D26 // use for PORTA control, relay 5
+//#define POR_Relay_I2C D27 // use for PORTA control, relay 6
+#define POR_Relay_I2C_SCL D27 // use for PORTA control, relay 6
+#define POR_Relay_I2C_SDA D28 // use for PORTA control, relay 7
+
+/* Use for I/O register PORTC control */
+#define POR_MDIO D36 // use for PORTC control
+#define POR_MDC D37 // use for PORTC control
+#define POR_Relay_MDIO D35 // use for PORTC control, relay 7
+
+/* Use for I/O register PORTL control */
+#define POR_FT_PATTERN_bit0 D49 // use for PORTL control
+#define POR_FT_PATTERN_bit1 D48 // use for PORTL control
+
+
+/* I/O register Port A */
+#define D22 0
+#define D23 1
+#define D24 2
+#define D25 3
+#define D26 4
+#define D27 5
+#define D28 6
+#define D29 7
+
+/* I/O register Port C */
+#define D37 0
+#define D36 1
+#define D35 2
+#define D34 3
+#define D33 4
+#define D32 5
+#define D31 6
+#define D30 7
+
+/* I/O register Port L */
+#define D49 0
+#define D48 1
+#define D47 2
+#define D46 3
+#define D45 4
+#define D44 5
+#define D43 6
+#define D42 7
+
+/* I/O register Port D */
+#define D21 0
+#define D20 1
+#define D19 2
+#define D18 3
+
+
+/***************************************************************************
+**************************************************************************
+* MDC/MDIO
+***************************************************************************
+***************************************************************************/
+#define SET_HIGH(data, nbit) ((data)|=(nbit))
+#define SET_LOW(data, nbit) ((data)&=~(nbit))
+
+#define MDIO_ONE _BV(POR_MDIO)
+#define MDIO_ZERO 0x00
+#define MDC_ONE _BV(POR_MDC)
+#define MDC_ZERO 0x00
+
+#define delay_us delayMicroseconds(0)
+
+#define ANACAL_INIT 0x01
+#define ANACAL_ERROR 0xFD
+#define ANACAL_SATURATION 0xFE
+#define ANACAL_FINISH 0xFF
+#define ANACAL_PAIR_A 0
+#define ANACAL_PAIR_B 1
+#define ANACAL_PAIR_C 2
+#define ANACAL_PAIR_D 3
+#define DAC_IN_0V 0x000
+#define DAC_IN_2V 0x0f0 // +/-1V
+
+#define ZCAL_MIDDLE 0x20
+#define TX_OFFSET_0mV_idx 31
+#define TX_AMP_MIDDLE 0x20
+
+#define TX_i2mpb_hbt_ofs 0x4 // 8851 fine tune 100M v1 (20220414)
+#define R50_OFFSET_VALUE 0x5
+
+//============== definition value for GbE ===================//
+#define BG_VOLTAGE_OUT 0xc0
+#define FORCE_MDI 2
+#define FORCE_MDIX 3
+#define LDO_1p15_VOSEL_1 1
+#define RX_CAL_VALUE_9 0x3
+#define RX_CAL_HVGA_BW_2 0x2
+#define RX_CAL_DCO_Normal 0x0
+#define RX_CAL_DCO_BYPASS_TX_RX 0x3
+#define RX_CAL_DCO_0xF 0xF
+
+#define TANA_MON_DCV_SEL__MASK 0xE0
+#define TANA_MON_DCV_SEL__MPX_TANA_A 0x20
+#define TANA_MON_DCV_SEL__MPX_TANA_B 0x40
+#define TANA_MON_DCV_SEL__MPX_TANA_C 0x60
+#define TANA_MON_DCV_SEL__MPX_TANA_D 0x80
+#define TANA_MON_DCV_SEL__MONVC__MASK 0x008000C8
+#define TANA_MON_DCV__TANA__VBG_MON 0x000000C0
+#define TANA_MON_DCV__TANA__MONVC 0x000000C8
+
+#define AN_disable_force_1000M 0x0140
+#define BG_voltage_output 0xc000
+#define Fix_mdi 0x1010
+#define Disable_tx_slew_control 0x0000
+#define LDO_control 0x0100
+#define Cal_control_BG 0x1110
+#define Cal_control_R50 0x1100
+#define Cal_control_TX_AMP 0x1100
+#define Cal_control_TX_OFST 0x0100
+#define Cal_control_R50_pairA_ENABLE 0x1101
+#define Disable_all 0x0
+#define Zcalen_A_ENABLE 0x0000
+#define Zcalen_B_ENABLE 0x1000
+#define Zcalen_C_ENABLE 0x0100
+#define Zcalen_D_ENABLE 0x0010
+#define MASK_MSB_8bit 0xff00
+#define MASK_LSB_8bit 0x00ff
+#define MASK_r50ohm_rsel_tx_a 0x7f00
+#define MASK_r50ohm_rsel_tx_b 0x007f
+#define MASK_r50ohm_rsel_tx_c 0x7f00
+#define MASK_r50ohm_rsel_tx_d 0x007f
+#define Rg_r50ohm_rsel_tx_a_en 0x8000
+#define Rg_r50ohm_rsel_tx_b_en 0x0080
+#define Rg_r50ohm_rsel_tx_c_en 0x8000
+#define Rg_r50ohm_rsel_tx_d_en 0x0080
+#define Rg_txvos_calen_ENABLE 0x0001
+#define Bypass_tx_offset_cal 0x8000
+#define Enable_Tx_VLD 0xf808
+#define Rg_txg_calen_a_ENABLE 0x1000
+#define Rg_txg_calen_b_ENABLE 0x0100
+#define Rg_txg_calen_c_ENABLE 0x0010
+#define Rg_txg_calen_d_ENABLE 0x0001
+#define Force_dasn_dac_in0_ENABLE 0x8000
+#define Force_dasn_dac_in1_ENABLE 0x8000
+#define MASK_cr_tx_amp_offset_MSB 0x3f00
+#define MASK_cr_tx_amp_offset_LSB 0x003f
+#define Rg_cal_refsel_ENABLE 0x0010
+#define MASK_da_tx_i2mpb_a_gbe 0xfc00
+#define MASK_da_tx_i2mpb_b_c_d_gbe 0x3f00
+
+#define LED_basic_control_en_active_low 0x800a
+#define LED_led0_en_active_high 0xc007
+#define LED_led0_force_blinking 0x0200
+
+
+
+/*phy calibration use*/
+//Type defines
+typedef unsigned char UINT8;
+typedef unsigned short UINT16;
+typedef unsigned long UINT32;
+
+typedef struct
+{
+ UINT16 DATA_Lo;
+ UINT8 DATA_Hi;
+}TR_DATA_T;
+
+//CL22 Reg Support Page Select//
+#define RgAddr_Reg1Fh 0x1f
+#define CL22_Page_Reg 0x0000
+#define CL22_Page_ExtReg 0x0001
+#define CL22_Page_MiscReg 0x0002
+#define CL22_Page_LpiReg 0x0003
+#define CL22_Page_tReg 0x02A3
+#define CL22_Page_TrReg 0x52B5
+
+//CL45 Reg Support DEVID//
+#define DEVID_03 0x03
+#define DEVID_07 0x07
+#define DEVID_1E 0x1E
+#define DEVID_1F 0x1F
+
+//TokenRing Reg Access//
+#define TrReg_PKT_XMT_STA 0x8000
+#define TrReg_WR 0x8000
+#define TrReg_RD 0xA000
+
+/* ----------------- gephy_all Bit Field Definitions ------------------- */
+
+
+
+//-------------------------------------
+//0x0000
+#define RgAddr_Reg00h 0x00
+
+//0x51e01200
+#define RgAddr_dev1Eh_reg120h 0x0120
+//0x51e01220
+#define RgAddr_dev1Eh_reg122h 0x0122
+//0x51e01440
+#define RgAddr_dev1Eh_reg144h 0x0144
+//0x51e014a0
+#define RgAddr_dev1Eh_reg14Ah 0x014a
+//0x51e019b0
+#define RgAddr_dev1Eh_reg19Bh 0x019b
+//0x51e02340
+#define RgAddr_dev1Eh_reg234h 0x0234
+//0x51e02380
+#define RgAddr_dev1Eh_reg238h 0x0238
+//0x51e02390
+#define RgAddr_dev1Eh_reg239h 0x0239
+//0x51f02680
+#define RgAddr_dev1Fh_reg268h 0x0268
+//0x51e02d10
+#define RgAddr_dev1Eh_reg2D1h 0x02d1
+//0x51e03230
+#define RgAddr_dev1Eh_reg323h 0x0323
+//0x51e03240
+#define RgAddr_dev1Eh_reg324h 0x0324
+//0x51e03260
+#define RgAddr_dev1Eh_reg326h 0x0326
+
+//0x51f01000
+#define RgAddr_dev1Fh_reg100h 0x0100
+//0x51e01450
+#define RgAddr_dev1Eh_reg145h 0x0145
+//0x51f00ff0
+#define RgAddr_dev1Fh_reg0FFh 0x00ff
+//0x51e00db0
+#define RgAddr_dev1Eh_reg0DBh 0x00db
+//0x51e00dc0
+#define RgAddr_dev1Eh_reg0DCh 0x00dc
+//0x51e00e00
+#define RgAddr_dev1Eh_reg0E0h 0x00e0
+//0x51e00e10
+#define RgAddr_dev1Eh_reg0E1h 0x00e1
+//0x51e00e00
+#define RgAddr_dev1Eh_reg0E0h 0x00e0
+//0x51e017a0
+#define RgAddr_dev1Eh_reg17Ah 0x017a
+//0x51f01150
+#define RgAddr_dev1Fh_reg115h 0x0115
+//0x51f01000
+#define RgAddr_dev1Fh_reg100h 0x0100
+//0x51e01450
+#define RgAddr_dev1Eh_reg145h 0x0145
+//0x51e01450
+#define RgAddr_dev1Eh_reg145h 0x0145
+//0x51e01850
+#define RgAddr_dev1Eh_reg185h 0x0185
+//0x51e00fb0
+#define RgAddr_dev1Eh_reg0FBh 0x00fb
+//0x51e01740
+#define RgAddr_dev1Eh_reg174h 0x0174
+//0x51e01750
+#define RgAddr_dev1Eh_reg175h 0x0175
+//0x51e01850
+#define RgAddr_dev1Eh_reg185h 0x0185
+//0x51e00fb0
+#define RgAddr_dev1Eh_reg0FBh 0x00fb
+//0x51e00960
+#define RgAddr_dev1Eh_reg096h 0x0096
+//0x51e003e0
+#define RgAddr_dev1Eh_reg03Eh 0x003e
+//0x51e00dd0
+#define RgAddr_dev1Eh_reg0DDh 0x00dd
+//0x51e017d0
+#define RgAddr_dev1Eh_reg17Dh 0x017d
+//0x51e01810
+#define RgAddr_dev1Eh_reg181h 0x0181
+//0x51e00120
+#define RgAddr_dev1Eh_reg012h 0x0012
+//0x51e017e0
+#define RgAddr_dev1Eh_reg17Eh 0x017e
+//0x51e01820
+#define RgAddr_dev1Eh_reg182h 0x0182
+//0x51e00170
+#define RgAddr_dev1Eh_reg017h 0x0017
+//0x51e01830
+#define RgAddr_dev1Eh_reg183h 0x0183
+//0x51e00190
+#define RgAddr_dev1Eh_reg019h 0x0019
+//0x51e01800
+#define RgAddr_dev1Eh_reg180h 0x0180
+//0x51e01840
+#define RgAddr_dev1Eh_reg184h 0x0184
+//0x51e00210
+#define RgAddr_dev1Eh_reg021h 0x0021
+//0x51e01720
+#define RgAddr_dev1Eh_reg172h 0x0172
+//0x51e01730
+#define RgAddr_dev1Eh_reg173h 0x0173
+//0x51e017c0
+#define RgAddr_dev1Eh_reg17Ch 0x017c
+//0x51e017f0
+#define RgAddr_dev1Eh_reg17Fh 0x017f
+
+//0x52b5100
+#define RgAddr_TrReg10h 0x10
+//0x52b5110
+#define RgAddr_TrReg11h 0x11
+//0x52b5120
+#define RgAddr_TrReg12h 0x12
+
+//0x31c0
+#define RgAddr_LpiReg1Ch 0x1c
+//0x31d0
+#define RgAddr_LpiReg1Dh 0x1d
+uint8_t BG_Calibration(uint8_t phyadd, int8_t calipolarity);
+uint8_t R50_Calibration(uint8_t phyadd, uint8_t phyadd_common);
+uint8_t TX_OFS_Calibration(uint8_t phyadd, uint8_t phyadd_common);
+uint8_t TX_AMP_Calibration(uint8_t phyadd, uint8_t phyadd_common);
+//void config_gphy_port(UINT8, UINT8);
+
+void set_gphy_reg_cl22(uint8_t, uint8_t, uint16_t);
+uint16_t get_gphy_reg_cl45(uint8_t, uint8_t, uint16_t);
+void set_gphy_reg_cl45(uint8_t, uint8_t, uint16_t, uint16_t);
+void anacal_exe(uint8_t);
+
+#endif /* _AN8855_PHY_H_ */
+
diff --git a/feed/app/switch/src/an8855_sdk/core/an8855_phy_cal.c b/feed/app/switch/src/an8855_sdk/core/an8855_phy_cal.c
index c2e8e5c..9eb52e1 100644
--- a/feed/app/switch/src/an8855_sdk/core/an8855_phy_cal.c
+++ b/feed/app/switch/src/an8855_sdk/core/an8855_phy_cal.c
@@ -1,967 +1,967 @@
-/* FILE NAME: an8855_phy_cal.c
-* PURPOSE:
-* It provides an8855 switch phy calibration function.
-*
-* NOTES:
-*
-*/
-
-/* INCLUDE FILE DECLARATIONS
-*/
-#include "an8855_mdio.h"
-#include "an8855_phy.h"
-//#include "swk_gphy_reg.h"
-//#include "gphy_calibration.h"
-//#include "gsw_reg.h"
-
-/* NAMING CONSTANT DECLARATIONS
- */
-#define MII_BMCR (0)
-#define BMCR_PDOWN (0x0800)
-/* MACRO FUNCTION DECLARATIONS
- */
-
-#define FULL_BITS(_n_) ((1UL << (_n_)) - 1)
-
-/* DATA TYPE DECLARATIONS
- */
-
-/* GLOBAL VARIABLE DECLARATIONS
- */
-/* Zcal to R50 mapping table (20220404) */
-const uint8_t ZCAL_TO_R50ohm_TBL[64] =
-{
- 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
- 127, 127, 127, 127, 127, 123, 118, 114, 110, 106, 102, 98, 96, 92, 88, 85,
- 82, 80, 76, 72, 70, 67, 64, 62, 60, 56, 54, 52, 49, 48, 45, 43,
- 40, 39, 36, 34, 32, 32, 30, 28, 25, 24, 22, 20, 18, 16, 16, 14
-};
-
-/* Tx offset table, value is from small to big */
-const uint8_t EN753x_TX_OFS_TBL[64] =
-{
- 0x3f, 0x3e, 0x3d, 0x3c, 0x3b, 0x3a, 0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x30,
- 0x2f, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
-};
-
-#define TOTAL_PATCH_C45_ITEMS (15)
-#define TOTAL_PATCH_TR_ITEMS (19)
-const uint16_t C45_PATCH_TABLE[TOTAL_PATCH_C45_ITEMS][3] =
-{
- {0x1E, 0x120, 0x8014},
- {0x1E, 0x122, 0xFFFF},
- {0x1E, 0x122, 0xFFFF},
- {0x1E, 0x144, 0x0200},
- {0x1E, 0x14A, 0xEE20},
- {0x1E, 0x189, 0x0110},
- {0x1E, 0x19B, 0x0111},
- {0x1E, 0x234, 0x0181},
- {0x1E, 0x238, 0x0120},
- {0x1E, 0x239, 0x0117},
- {0x1F, 0x268, 0x07F4},
- {0x1E, 0x2d1, 0x0733},
- {0x1E, 0x323, 0x0011},
- {0x1E, 0x324, 0x013F},
- {0x1E, 0x326, 0x0037},
-};
-
-const uint32_t TR_PATCH_TABLE[TOTAL_PATCH_TR_ITEMS][2] =
-{
- {0x83AA, 0x055a0 },
- {0x83AE, 0x7FF3F },
- {0x8F80, 0x0001e },
- {0x8F82, 0x6FB90A},
- {0x8FAE, 0x060671},
- {0x8FB0, 0xE2F00 },
- {0x8ECC, 0x444444},
- {0x9686, 0x00000 },
- {0x968C, 0x2EBAEF},
- {0x9690, 0x00000b},
- {0x9698, 0x0504D },
- {0x969A, 0x2314f },
- {0x969E, 0x03028 },
- {0x96A0, 0x05010 },
- {0x96A2, 0x40001 },
- {0x96A6, 0x018670},
- {0x96A8, 0x0024A },
- {0x96B6, 0x00072 },
- {0x96B8, 0x03210 },
-};
-
-#define TOTAL_NUMBER_OF_PATCH (14)
-static uint16_t eee_patch_table[TOTAL_NUMBER_OF_PATCH][2] = {
- {RgAddr_dev1Eh_reg120h, 0x8014},
- {RgAddr_dev1Eh_reg122h, 0xFFFF},
- {RgAddr_dev1Eh_reg122h, 0xFFFF},
- {RgAddr_dev1Eh_reg144h, 0x0200},
- {RgAddr_dev1Eh_reg14Ah, 0xEE20},
- {RgAddr_dev1Eh_reg19Bh, 0x0111},
- {RgAddr_dev1Eh_reg234h, 0x1181},
- {RgAddr_dev1Eh_reg238h, 0x0120},
- {RgAddr_dev1Eh_reg239h, 0x0117},
- {RgAddr_dev1Fh_reg268h, 0x07F4},
- {RgAddr_dev1Eh_reg2D1h, 0x0733},
- {RgAddr_dev1Eh_reg323h, 0x0011},
- {RgAddr_dev1Eh_reg324h, 0x013F},
- {RgAddr_dev1Eh_reg326h, 0x0037}
-};
-
-#define TOTAL_NUMBER_OF_TR (19)
-static uint16_t tr_reg_table[TOTAL_NUMBER_OF_TR][3] = {
- {0x55A0, 0x0000, 0x83AA},
- {0xFF3F, 0x0007, 0x83AE},
- {0x001E, 0x0000, 0x8F80},
- {0xB90A, 0x006F, 0x8F82},
- {0x0671, 0x0006, 0x8FAE},
- {0x2F00, 0x000E, 0x8FB0},
- {0x4444, 0x0044, 0x8ECC},
- {0x0004, 0x0000, 0x9686},
- {0xBAEF, 0x002E, 0x968C},
- {0x000B, 0x0000, 0x9690},
- {0x504D, 0x0000, 0x9698},
- {0x314F, 0x0002, 0x969A},
- {0x3028, 0x0000, 0x969E},
- {0x5010, 0x0000, 0x96A0},
- {0x0001, 0x0004, 0x96A2},
- {0x8670, 0x0001, 0x96A6},
- {0x024A, 0x0000, 0x96A8},
- {0x0072, 0x0000, 0x96B6},
- {0x3210, 0x0000, 0x96B8}
-};
-
-void TR_RegWr(uint16_t phyadd, uint16_t tr_reg_addr, uint32_t tr_data);
-
-uint16_t get_gphy_reg_cl22(uint8_t phyad, uint8_t reg)
-{
- uint32_t rdata = 0;
-
- an8855_phy_read(phyad-g_smi_addr, reg, &rdata);
-
- return ((uint16_t)rdata);
- /*
- gsw_top_reg_REG_PHY_IAC REG_PHY_IAC_val;
- gsw_top_reg_REG_PHY_IAD REG_PHY_IAD_val;
-
- // Wait until done
- do
- {
- REG_PHY_IAC_val.Raw = io_read32(RgAddr_gsw_top_reg_REG_PHY_IAC);
- }
- while(REG_PHY_IAC_val.Bits.csr_phy_acs_st);
-
- // Set address
- REG_PHY_IAC_val.Bits.csr_mdio_st = 1;
- REG_PHY_IAC_val.Bits.csr_mdio_cmd = 2;
- REG_PHY_IAC_val.Bits.csr_mdio_phy_addr = phyad;
- REG_PHY_IAC_val.Bits.csr_mdio_reg_addr = reg;
- REG_PHY_IAC_val.Bits.csr_phy_acs_st = 1;
- io_write32(RgAddr_gsw_top_reg_REG_PHY_IAC, REG_PHY_IAC_val.Raw);
- // Wait until done
- do
- {
- REG_PHY_IAC_val.Raw = io_read32(RgAddr_gsw_top_reg_REG_PHY_IAC);
- }
- while(REG_PHY_IAC_val.Bits.csr_phy_acs_st);
-
- REG_PHY_IAD_val.Raw = io_read32(RgAddr_gsw_top_reg_REG_PHY_IAD);
-
- return REG_PHY_IAD_val.Raw;
- */
-}
-
-/* EXPORTED SUBPROGRAM BODIES
- */
-void gphy_config(void)
-{
- uint8_t port = 1;
- uint8_t phy_base = 0, phys_in_chip = 8;
-
- for (port = 1; port <= phys_in_chip; port++)
- {
- set_gphy_reg_cl45(phy_base + port, 0x7, 0x3c, 0x0006); // Enable EEE
- set_gphy_reg_cl45(phy_base + port, 0x1e, 0x3e, 0xf000); // force on TXVLD
- }
-}
-
-static void set_gphy_TrReg(uint8_t prtid, uint16_t parm_1, uint16_t parm_2, uint16_t parm_3)
-{
- set_gphy_reg_cl22(prtid, RgAddr_TrReg11h, parm_1);
- set_gphy_reg_cl22(prtid, RgAddr_TrReg12h, parm_2);
- set_gphy_reg_cl22(prtid, RgAddr_TrReg10h, parm_3);
-}
-
-static void gphy_eee_patch(uint8_t phy_base)
-{
- UI8_T port = 1, index = 0, phy_addr = 1;
- UI16_T data = 0;
-
- for (port = 1; port <=8; port++)
- {
- phy_addr = phy_base + port;
- data = get_gphy_reg_cl22(phy_addr, MII_BMCR);
- set_gphy_reg_cl22(phy_addr, MII_BMCR, data & ~(BMCR_PDOWN)); /* PHY power on */
-
- /* Change EEE RG default value */
- for (index = 0; index < TOTAL_NUMBER_OF_PATCH; index++)
- {
- set_gphy_reg_cl45(phy_addr, DEVID_1E, eee_patch_table[index][0], eee_patch_table[index][1]);
- }
-
- set_gphy_reg_cl22(phy_addr, RgAddr_Reg1Fh, CL22_Page_TrReg); /* change CL22page to LpiReg(0x3) */
- for (index = 0; index < TOTAL_NUMBER_OF_TR; index++)
- {
- set_gphy_TrReg(phy_addr, tr_reg_table[index][0], tr_reg_table[index][1], tr_reg_table[index][2]);
- }
-
- set_gphy_reg_cl22(phy_addr, RgAddr_Reg1Fh, CL22_Page_LpiReg); /* change CL22page to LpiReg(0x3) */
- set_gphy_reg_cl22(phy_addr, RgAddr_LpiReg1Ch, 0x0c92); /* Fine turn SigDet for B2B LPI link down issue */
- set_gphy_reg_cl22(phy_addr, RgAddr_LpiReg1Dh, 0x0001); /* Enable "lpi_quit_waitafesigdet_en" for LPI link down issue */
-
- set_gphy_reg_cl22(phy_addr, RgAddr_Reg1Fh, CL22_Page_Reg); /* change CL22page to Reg(0x0) */
- }
-}
-
-void gphy_calibration(uint8_t phy_base)
-{
- uint8_t port = 1, phy_addr = 1 ,phy_group = 1, index = 0;
- uint8_t phys_in_chip = 5;
-
- BG_Calibration(phy_base, 0x1);
- if (phys_in_chip > 4)
- {
- BG_Calibration(phy_base + 0x4, 0x1);
- }
-
- for (port = 0; port < phys_in_chip; port++)
- {
- if (port < 4)
- {
- phy_group = phy_base; /* PHY group 1 */
- }
- else
- {
- phy_group = phy_base + 0x04; /* PHY group 2 */
- }
- phy_addr = phy_base + port;
- R50_Calibration(phy_addr, phy_group);
- TX_OFS_Calibration(phy_addr, phy_group);
- TX_AMP_Calibration(phy_addr, phy_group);
- }
-
- for (port = 0; port < phys_in_chip; port++)
- {
- phy_addr = phy_base + port;
- set_gphy_reg_cl45(phy_addr, 0x1e, 0x017d, 0x0000);
- set_gphy_reg_cl45(phy_addr, 0x1e, 0x017e, 0x0000);
- set_gphy_reg_cl45(phy_addr, 0x1e, 0x017f, 0x0000);
- set_gphy_reg_cl45(phy_addr, 0x1e, 0x0180, 0x0000);
- set_gphy_reg_cl45(phy_addr, 0x1e, 0x0181, 0x0000);
- set_gphy_reg_cl45(phy_addr, 0x1e, 0x0182, 0x0000);
- set_gphy_reg_cl45(phy_addr, 0x1e, 0x0183, 0x0000);
- set_gphy_reg_cl45(phy_addr, 0x1e, 0x0184, 0x0000);
- set_gphy_reg_cl45(phy_addr, 0x1e, 0x00db, 0x0000); // disable analog calibration circuit
- set_gphy_reg_cl45(phy_addr, 0x1e, 0x00dc, 0x0000); // disable Tx offset calibration circuit
- set_gphy_reg_cl45(phy_addr, 0x1e, 0x003e, 0x0000); // disable Tx VLD force mode
- set_gphy_reg_cl45(phy_addr, 0x1e, 0x00dd, 0x0000); // disable Tx offset/amplitude calibration circuit
- set_gphy_reg_cl45(phy_addr, 0x1e, 0x0145, 0x1000); // enable auto MDI/MDIX
-
- set_gphy_reg_cl22(phy_addr, 0, 0x1200);
- /* GPHY Rx low pass filter */
- set_gphy_reg_cl45(phy_addr, 0x1e, 0xc7, 0xd000);
- /* patch */
- for (index = 0; index < TOTAL_PATCH_C45_ITEMS; index++)
- {
- set_gphy_reg_cl45(phy_addr, C45_PATCH_TABLE[index][0], C45_PATCH_TABLE[index][1], C45_PATCH_TABLE[index][2]);
- }
- for (index = 0; index < TOTAL_PATCH_TR_ITEMS; index++)
- {
- TR_RegWr(phy_addr, TR_PATCH_TABLE[index][0], TR_PATCH_TABLE[index][1]);
- }
- set_gphy_reg_cl22(phy_addr, 0x1f, 0x0 );
- set_gphy_reg_cl22(phy_addr, 0x1f, 0x3 );
- set_gphy_reg_cl22(phy_addr, 0x1c, 0xc92);
- set_gphy_reg_cl22(phy_addr, 0x1d, 0x01 );
- set_gphy_reg_cl22(phy_addr, 0x1f, 0x0 );
- }
- gphy_eee_patch(phy_base);
-}
-
-/* LOCAL SUBPROGRAM BODIES
- */
-void TR_RegWr(uint16_t phyadd, uint16_t tr_reg_addr, uint32_t tr_data)
-{
- set_gphy_reg_cl22(phyadd, 0x1F, 0x52b5); /* page select */
- set_gphy_reg_cl22(phyadd, 0x11, (uint16_t)(tr_data & 0xffff));
- set_gphy_reg_cl22(phyadd, 0x12, (uint16_t)(tr_data >> 16));
- set_gphy_reg_cl22(phyadd, 0x10, (uint16_t)(tr_reg_addr | TrReg_WR));
- set_gphy_reg_cl22(phyadd, 0x1F, 0x0); /* page resetore */
- return;
-}
-
-uint8_t BG_Calibration(uint8_t phyadd, int8_t calipolarity)
-{
- int8_t rg_zcal_ctrl = 0, calibration_polarity = 0;
- uint8_t all_ana_cal_status = 1;
- uint16_t ad_cal_comp_out_init = 0;
-
- /* setting */
- set_gphy_reg_cl22(phyadd, RgAddr_Reg1Fh, CL22_Page_Reg); // g0
- set_gphy_reg_cl22(phyadd, RgAddr_Reg00h, AN_disable_force_1000M); // AN disable, force 1000M
- set_gphy_reg_cl45(phyadd, DEVID_1F, RgAddr_dev1Fh_reg100h, BG_voltage_output);// BG voltage output
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg145h, Fix_mdi);// fix mdi
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Fh_reg0FFh, 0x2);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Cal_control_BG);// 1e_db[12]:rg_cal_ckinv, [8]:rg_ana_calen, [4]:rg_rext_calen
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Disable_all);// 1e_dc[0]:rg_txvos_calen
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0E1h, Disable_all);// 1e_e1[4]:rg_cal_refsel(0:1.2V) enable BG 1.2V to REXT PAD
-
- /* calibrate */
- rg_zcal_ctrl = ZCAL_MIDDLE;
-
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0E0h, (uint16_t)rg_zcal_ctrl);
-
- anacal_exe(phyadd);
- if (all_ana_cal_status == 0)
- {
- all_ana_cal_status = ANACAL_ERROR;
- }
- ad_cal_comp_out_init = (get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Ah) >> 8) & 0x1;
-
-
- if (ad_cal_comp_out_init == 1)
- {
- calibration_polarity = -calipolarity;
- }
- else // ad_cal_comp_out_init == 0
- {
- calibration_polarity = calipolarity;
- }
-
- while (all_ana_cal_status < ANACAL_ERROR)
- {
- rg_zcal_ctrl += calibration_polarity;
-
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0E0h, (uint16_t)rg_zcal_ctrl);
-
-
- anacal_exe(phyadd);
-
- if (all_ana_cal_status == 0)
- {
- all_ana_cal_status = ANACAL_ERROR;
- }
-
- else if (((get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Ah) >> 8) & 0x1) != ad_cal_comp_out_init)
- {
- all_ana_cal_status = ANACAL_FINISH;
- }
- else
- {
- if ((rg_zcal_ctrl == 0x3F) || (rg_zcal_ctrl == 0x00))
- {
- all_ana_cal_status = ANACAL_SATURATION; // need to FT
- rg_zcal_ctrl = ZCAL_MIDDLE; // 0 dB
- }
- }
- }
-
- if (all_ana_cal_status == ANACAL_ERROR)
- {
- rg_zcal_ctrl = ZCAL_MIDDLE; // 0 dB
-
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0E0h, (uint16_t)rg_zcal_ctrl);
- }
- else
- {
- // rg_zcal_ctrl[5:0] rg_rext_trim[13:8]
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0E0h, (uint16_t)((rg_zcal_ctrl << 8) | rg_zcal_ctrl));
-
- // 1f_115[2:0](rg_bg_rasel) = rg_zcal_ctrl[5:3]
- set_gphy_reg_cl45(phyadd, DEVID_1F, RgAddr_dev1Fh_reg115h, (uint16_t)((rg_zcal_ctrl & 0x3f) >> 3));
- }
-
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Disable_all);
- return all_ana_cal_status;
-}
-
-uint8_t R50_Calibration(uint8_t phyadd, uint8_t phyadd_common)
-{
- int8_t rg_zcal_ctrl = 0, rg_r50ohm_rsel_tx = 0, calibration_polarity = 0;
- uint8_t all_ana_cal_status = 1;
- int16_t backup_dev1e_e0 = 0, ad_cal_comp_out_init = 0, calibration_pair = 0;
-
- /* setting */
- set_gphy_reg_cl22(phyadd, RgAddr_Reg1Fh, CL22_Page_Reg); // g0
- set_gphy_reg_cl22(phyadd, RgAddr_Reg00h, AN_disable_force_1000M); // AN disable, force 1000M
-
- set_gphy_reg_cl45(phyadd_common, DEVID_1F, RgAddr_dev1Fh_reg100h, BG_voltage_output); // BG voltage output
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg145h, Fix_mdi); // fix mdi
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg185h, Disable_tx_slew_control); // disable tx slew control
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0FBh, LDO_control); // ldo
- set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Cal_control_R50); // 1e_db[12]:rg_cal_ckinv, [8]:rg_ana_calen, [4]:rg_rext_calen
- set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Disable_all); // 1e_dc[0]:rg_txvos_calen
- set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0E1h, Disable_all); // 1e_e1[4]:rg_cal_refsel(0:1.2V) enable BG 1.2V to REXT PAD
-
- for (calibration_pair = ANACAL_PAIR_A; calibration_pair <= ANACAL_PAIR_D; calibration_pair++)
- {
- all_ana_cal_status = 1;
-
- if (calibration_pair == ANACAL_PAIR_A)
- {
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Cal_control_R50_pairA_ENABLE); // 1e_db[12]:rg_cal_ckinv, [8]:rg_ana_calen, [4]:rg_rext_calen, [0]:rg_zcalen_a
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Zcalen_A_ENABLE);
- }
- else if (calibration_pair == ANACAL_PAIR_B)
- {
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Cal_control_R50); // 1e_db[12]:rg_cal_ckinv, [8]:rg_ana_calen, [4]:rg_rext_calen, [0]:rg_zcalen_a
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Zcalen_B_ENABLE); // 1e_dc[12]:rg_zcalen_b
- }
- else if (calibration_pair == ANACAL_PAIR_C)
- {
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Cal_control_R50); // 1e_db[12]:rg_cal_ckinv, [8]:rg_ana_calen, [4]:rg_rext_calen, [0]:rg_zcalen_a
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Zcalen_C_ENABLE); // 1e_dc[8]:rg_zcalen_c
- }
- else // if(calibration_pair == ANACAL_PAIR_D)
- {
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Cal_control_R50); // 1e_db[12]:rg_cal_ckinv, [8]:rg_ana_calen, [4]:rg_rext_calen, [0]:rg_zcalen_a
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Zcalen_D_ENABLE); // 1e_dc[4]:rg_zcalen_d
- }
-
- /* calibrate */
- rg_zcal_ctrl = ZCAL_MIDDLE; // start with 0 dB
-
- backup_dev1e_e0 = (get_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0E0h)&(~0x003f));
- set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0E0h, (backup_dev1e_e0 | rg_zcal_ctrl));
-
- anacal_exe(phyadd_common);
- if (all_ana_cal_status == 0)
- {
- all_ana_cal_status = ANACAL_ERROR;
- }
-
- ad_cal_comp_out_init = (get_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg17Ah) >> 8) & 0x1; // 1e_17a[8]:ad_cal_comp_out
-
- if (ad_cal_comp_out_init == 1)
- {
- calibration_polarity = -1;
- }
- else
- {
- calibration_polarity = 1;
- }
-
- while (all_ana_cal_status < ANACAL_ERROR)
- {
- rg_zcal_ctrl += calibration_polarity;
-
- set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0E0h, (backup_dev1e_e0 | rg_zcal_ctrl));
-
- anacal_exe(phyadd_common);
-
- if (all_ana_cal_status == 0)
- {
- all_ana_cal_status = ANACAL_ERROR;
- }
- else if (((get_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg17Ah) >> 8) & 0x1) != ad_cal_comp_out_init)
- {
- all_ana_cal_status = ANACAL_FINISH;
- }
- else
- {
- if ((rg_zcal_ctrl == 0x3F) || (rg_zcal_ctrl == 0x00))
- {
- all_ana_cal_status = ANACAL_SATURATION; // need to FT
- rg_zcal_ctrl = ZCAL_MIDDLE; // 0 dB
- }
- }
- }
-
- if (all_ana_cal_status == ANACAL_ERROR)
- {
- rg_r50ohm_rsel_tx = ZCAL_MIDDLE; // 0 dB
- }
- else
- {
- if (rg_zcal_ctrl > (0x3F - R50_OFFSET_VALUE))
- {
- all_ana_cal_status = ANACAL_SATURATION; // need to FT
- rg_zcal_ctrl = ZCAL_MIDDLE; // 0 dB
- }
- else
- {
- rg_zcal_ctrl += R50_OFFSET_VALUE;
- }
-
- rg_r50ohm_rsel_tx = ZCAL_TO_R50ohm_TBL[rg_zcal_ctrl];
- }
-
- if (calibration_pair == ANACAL_PAIR_A)
- {
- // cr_r50ohm_rsel_tx_a
- ad_cal_comp_out_init = get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg174h)&(~MASK_r50ohm_rsel_tx_a);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg174h, (ad_cal_comp_out_init | (((rg_r50ohm_rsel_tx << 8) & MASK_MSB_8bit) | Rg_r50ohm_rsel_tx_a_en))); // 1e_174[15:8]
- }
- else if (calibration_pair == ANACAL_PAIR_B)
- {
- // cr_r50ohm_rsel_tx_b
- ad_cal_comp_out_init = get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg174h)&(~MASK_r50ohm_rsel_tx_b);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg174h, (ad_cal_comp_out_init | (((rg_r50ohm_rsel_tx << 0) & MASK_LSB_8bit) | Rg_r50ohm_rsel_tx_b_en))); // 1e_174[7:0]
- }
- else if (calibration_pair == ANACAL_PAIR_C)
- {
- // cr_r50ohm_rsel_tx_c
- ad_cal_comp_out_init = get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg175h)&(~MASK_r50ohm_rsel_tx_c);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg175h, (ad_cal_comp_out_init | (((rg_r50ohm_rsel_tx << 8) & MASK_MSB_8bit) | Rg_r50ohm_rsel_tx_c_en))); // 1e_175[15:8]
- }
- else // if(calibration_pair == ANACAL_PAIR_D)
- {
- // cr_r50ohm_rsel_tx_d
- ad_cal_comp_out_init = get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg175h)&(~MASK_r50ohm_rsel_tx_d);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg175h, (ad_cal_comp_out_init | (((rg_r50ohm_rsel_tx << 0) & MASK_LSB_8bit) | Rg_r50ohm_rsel_tx_d_en))); // 1e_175[7:0]
- }
- }
-
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Disable_all);
- set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Disable_all);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Disable_all);
-
- return all_ana_cal_status;
-}
-
-uint8_t TX_OFS_Calibration(uint8_t phyadd, uint8_t phyadd_common)
-{
- int8_t tx_offset_index = 0, calibration_polarity = 0;
- uint8_t all_ana_cal_status = 1, tx_offset_reg_shift = 0, tbl_idx = 0;
- int16_t ad_cal_comp_out_init = 0, calibration_pair = 0, tx_offset_reg = 0, reg_temp = 0;
-
- /* setting */
- set_gphy_reg_cl22(phyadd, RgAddr_Reg1Fh, CL22_Page_Reg); // g0
- set_gphy_reg_cl22(phyadd, RgAddr_Reg00h, AN_disable_force_1000M); // AN disable, force 1000M
-
- set_gphy_reg_cl45(phyadd, DEVID_1F, RgAddr_dev1Fh_reg100h, BG_voltage_output); // BG voltage output
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg145h, Fix_mdi); // fix mdi
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg185h, Disable_tx_slew_control); // disable tx slew control
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0FBh, LDO_control); // ldo
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Cal_control_TX_OFST); // 1e_db[12]:rg_cal_ckinv, [8]:rg_ana_calen, [4]:rg_rext_calen
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Rg_txvos_calen_ENABLE); // 1e_dc[0]:rg_txvos_calen
- set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Cal_control_TX_OFST); // 1e_db[12]:rg_cal_ckinv, [8]:rg_ana_calen, [4]:rg_rext_calen
- set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Rg_txvos_calen_ENABLE); // 1e_dc[0]:rg_txvos_calen
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0E1h, Disable_all); // 1e_e1[4]:rg_cal_refsel(0:1.2V) enable BG 1.2V to REXT PAD
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg096h, Bypass_tx_offset_cal); // 1e_96[15]:bypass_tx_offset_cal, Hw bypass, Fw cal
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg03Eh, Enable_Tx_VLD); // 1e_3e:enable Tx VLD
-
- for (calibration_pair = ANACAL_PAIR_A; calibration_pair <= ANACAL_PAIR_D; calibration_pair++)
- {
- all_ana_cal_status = 1;
-
- tbl_idx = TX_OFFSET_0mV_idx;
- tx_offset_index = EN753x_TX_OFS_TBL[tbl_idx];
-
- if (calibration_pair == ANACAL_PAIR_A)
- {
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DDh, Rg_txg_calen_a_ENABLE); // 1e_dd[12]:rg_txg_calen_a
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Dh, (Force_dasn_dac_in0_ENABLE | DAC_IN_0V)); // 1e_17d:dac_in0_a
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg181h, (Force_dasn_dac_in1_ENABLE | DAC_IN_0V)); // 1e_181:dac_in1_a
-
- reg_temp = (get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg172h)&(~MASK_cr_tx_amp_offset_MSB));
- tx_offset_reg_shift = 8; // 1e_172[13:8]
- tx_offset_reg = RgAddr_dev1Eh_reg172h;
- }
- else if (calibration_pair == ANACAL_PAIR_B)
- {
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DDh, Rg_txg_calen_b_ENABLE); // 1e_dd[8]:rg_txg_calen_b
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Eh, (Force_dasn_dac_in0_ENABLE | DAC_IN_0V)); // 1e_17e:dac_in0_b
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg182h, (Force_dasn_dac_in1_ENABLE | DAC_IN_0V)); // 1e_182:dac_in1_b
-
- reg_temp = (get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg172h)&(~MASK_cr_tx_amp_offset_LSB));
- tx_offset_reg_shift = 0; // 1e_172[5:0]
- tx_offset_reg = RgAddr_dev1Eh_reg172h;
- }
- else if (calibration_pair == ANACAL_PAIR_C)
- {
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DDh, Rg_txg_calen_c_ENABLE); // 1e_dd[4]:rg_txg_calen_c
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Fh, (Force_dasn_dac_in0_ENABLE | DAC_IN_0V)); // 1e_17f:dac_in0_c
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg183h, (Force_dasn_dac_in1_ENABLE | DAC_IN_0V)); // 1e_183:dac_in1_c
-
- reg_temp = (get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg173h)&(~MASK_cr_tx_amp_offset_MSB));
- tx_offset_reg_shift = 8; // 1e_173[13:8]
- tx_offset_reg = RgAddr_dev1Eh_reg173h;
- }
- else // if(calibration_pair == ANACAL_PAIR_D)
- {
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DDh, Rg_txg_calen_d_ENABLE); // 1e_dd[0]:rg_txg_calen_d
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg180h, (Force_dasn_dac_in0_ENABLE | DAC_IN_0V)); // 1e_180:dac_in0_d
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg184h, (Force_dasn_dac_in1_ENABLE | DAC_IN_0V)); // 1e_184:dac_in1_d
-
- reg_temp = (get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg173h)&(~MASK_cr_tx_amp_offset_LSB));
- tx_offset_reg_shift = 0; // 1e_173[5:0]
- tx_offset_reg = RgAddr_dev1Eh_reg173h;
- }
-
- /* calibrate */
- //tx_offset_index = TX_AMP_OFFSET_0mV;
- tbl_idx = TX_OFFSET_0mV_idx;
- tx_offset_index = EN753x_TX_OFS_TBL[tbl_idx];
- set_gphy_reg_cl45(phyadd, DEVID_1E, tx_offset_reg, (reg_temp | (tx_offset_index << tx_offset_reg_shift))); // 1e_172, 1e_173
-
- anacal_exe(phyadd_common);
- if (all_ana_cal_status == 0)
- {
- all_ana_cal_status = ANACAL_ERROR;
- }
-
- ad_cal_comp_out_init = (get_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg17Ah) >> 8) & 0x1; // 1e_17a[8]:ad_cal_comp_out
-
- if (ad_cal_comp_out_init == 1)
- {
- calibration_polarity = -1;
- }
- else
- {
- calibration_polarity = 1;
- }
-
- while (all_ana_cal_status < ANACAL_ERROR)
- {
- tbl_idx += calibration_polarity;
- tx_offset_index = EN753x_TX_OFS_TBL[tbl_idx];
-
- set_gphy_reg_cl45(phyadd, DEVID_1E, tx_offset_reg, (reg_temp | (tx_offset_index << tx_offset_reg_shift))); // 1e_172, 1e_173
-
- anacal_exe(phyadd_common);
-
- if (all_ana_cal_status == 0)
- {
- all_ana_cal_status = ANACAL_ERROR;
- }
- else if (((get_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg17Ah) >> 8) & 0x1) != ad_cal_comp_out_init)
- {
- all_ana_cal_status = ANACAL_FINISH;
- }
- else
- {
- if ((tx_offset_index == 0x3f) || (tx_offset_index == 0x1f))
- {
- all_ana_cal_status = ANACAL_SATURATION; // need to FT
- }
- }
- }
-
- if (all_ana_cal_status == ANACAL_ERROR)
- {
- tbl_idx = TX_OFFSET_0mV_idx;
- tx_offset_index = EN753x_TX_OFS_TBL[tbl_idx];
-
- set_gphy_reg_cl45(phyadd, DEVID_1E, tx_offset_reg, (reg_temp | (tx_offset_index << tx_offset_reg_shift))); // cr_tx_amp_offset_a/b/c/d, 1e_172, 1e_173
- }
- }
-
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Dh, Disable_all);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Eh, Disable_all);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Fh, Disable_all);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg180h, Disable_all);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg181h, Disable_all);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg182h, Disable_all);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg183h, Disable_all);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg184h, Disable_all);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Disable_all); // disable analog calibration circuit
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Disable_all); // disable Tx offset calibration circuit
- set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Disable_all); // disable analog calibration circuit
- set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Disable_all); // disable Tx offset calibration circuit
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg03Eh, Disable_all); // disable Tx VLD force mode
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DDh, Disable_all); // disable Tx offset/amplitude calibration circuit
-
- return all_ana_cal_status;
-}
-
-uint8_t TX_AMP_Calibration(uint8_t phyadd, uint8_t phyadd_common)
-{
- int8_t tx_amp_index = 0, calibration_polarity = 0;
- uint8_t all_ana_cal_status = 1, tx_amp_reg_shift = 0;
- uint8_t tx_amp_reg = 0, tx_amp_reg_100 = 0, tst_offset = 0, hbt_offset = 0, gbe_offset = 0, tbt_offset = 0;
- uint16_t ad_cal_comp_out_init = 0, calibration_pair = 0, reg_temp = 0;
-
- //phyadd_common = phyadd;
-
- /* setting */
- set_gphy_reg_cl22(phyadd, RgAddr_Reg1Fh, CL22_Page_Reg); // g0
- set_gphy_reg_cl22(phyadd, RgAddr_Reg00h, AN_disable_force_1000M); // AN disable, force 1000M
-
- set_gphy_reg_cl45(phyadd, DEVID_1F, RgAddr_dev1Fh_reg100h, BG_voltage_output); // BG voltage output
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg145h, Fix_mdi); // fix mdi
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg185h, Disable_tx_slew_control); // disable tx slew control
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0FBh, LDO_control); // ldo
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Cal_control_TX_AMP); // 1e_db[12]:rg_cal_ckinv, [8]:rg_ana_calen, [4]:rg_rext_calen
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Rg_txvos_calen_ENABLE); // 1e_dc[0]:rg_txvos_calen
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0E1h, Rg_cal_refsel_ENABLE); // 1e_e1[4]:rg_cal_refsel(0:1.2V) enable BG 1.2V to REXT PAD
- set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Cal_control_TX_AMP); // 1e_db[12]:rg_cal_ckinv, [8]:rg_ana_calen, [4]:rg_rext_calen
- set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Rg_txvos_calen_ENABLE); // 1e_dc[0]:rg_txvos_calen
- set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0E1h, Rg_cal_refsel_ENABLE); // 1e_e1[4]:rg_cal_refsel(0:1.2V) enable BG 1.2V to REXT PAD
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg096h, Bypass_tx_offset_cal); // 1e_96[15]:bypass_tx_offset_cal, Hw bypass, Fw cal
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg03Eh, Enable_Tx_VLD); // 1e_3e:enable Tx VLD
-
- for (calibration_pair = ANACAL_PAIR_A; calibration_pair <= ANACAL_PAIR_D; calibration_pair++)
- //for (calibration_pair = ANACAL_PAIR_A; calibration_pair <= ANACAL_PAIR_B; calibration_pair++) // debugging
- {
- all_ana_cal_status = 1;
-
- /* calibrate */
- tx_amp_index = TX_AMP_MIDDLE; // start with 0 dB
- if (calibration_pair == ANACAL_PAIR_A)
- {
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DDh, Rg_txg_calen_a_ENABLE); // 1e_dd[12]:rg_txg_calen_a amp calibration enable
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Dh, (Force_dasn_dac_in0_ENABLE | DAC_IN_2V)); // 1e_17d:dac_in0_a
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg181h, (Force_dasn_dac_in1_ENABLE | DAC_IN_2V)); // 1e_181:dac_in1_a
-
- reg_temp = (get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg012h)&(~MASK_da_tx_i2mpb_a_gbe));
- tx_amp_reg_shift = 10; // 1e_12[15:10]
- tx_amp_reg = RgAddr_dev1Eh_reg012h;
- tx_amp_reg_100 = 0x16;
- }
- else if (calibration_pair == ANACAL_PAIR_B)
- {
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DDh, Rg_txg_calen_b_ENABLE); // 1e_dd[8]:rg_txg_calen_b amp calibration enable
- //Serial.println(Rg_txg_calen_b_ENABLE, HEX);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Eh, (Force_dasn_dac_in0_ENABLE | DAC_IN_2V)); // 1e_17e:dac_in0_b
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg182h, (Force_dasn_dac_in1_ENABLE | DAC_IN_2V)); // 1e_182:dac_in1_b
-
- reg_temp = (get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg017h)&(~MASK_da_tx_i2mpb_b_c_d_gbe));
- tx_amp_reg_shift = 8; // 1e_17[13:8]
- tx_amp_reg = RgAddr_dev1Eh_reg017h;
- tx_amp_reg_100 = 0x18;
- }
- else if (calibration_pair == ANACAL_PAIR_C)
- {
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DDh, Rg_txg_calen_c_ENABLE); // 1e_dd[4]:rg_txg_calen_c amp calibration enable
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Fh, (Force_dasn_dac_in0_ENABLE | DAC_IN_2V)); // 1e_17f:dac_in0_c
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg183h, (Force_dasn_dac_in1_ENABLE | DAC_IN_2V)); // 1e_183:dac_in1_c
-
- reg_temp = (get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg019h)&(~MASK_da_tx_i2mpb_b_c_d_gbe));
- tx_amp_reg_shift = 8; // 1e_19[13:8]
- tx_amp_reg = RgAddr_dev1Eh_reg019h;
- tx_amp_reg_100 = 0x20;
- }
- else //if(calibration_pair == ANACAL_PAIR_D)
- {
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DDh, Rg_txg_calen_d_ENABLE); // 1e_dd[0]:rg_txg_calen_d amp calibration enable
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg180h, (Force_dasn_dac_in0_ENABLE | DAC_IN_2V)); // 1e_180:dac_in0_d
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg184h, (Force_dasn_dac_in1_ENABLE | DAC_IN_2V)); // 1e_184:dac_in1_d
-
- reg_temp = (get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg021h)&(~MASK_da_tx_i2mpb_b_c_d_gbe));
- tx_amp_reg_shift = 8; // 1e_21[13:8]
- tx_amp_reg = RgAddr_dev1Eh_reg021h;
- tx_amp_reg_100 = 0x22;
- }
-
- /* calibrate */
- tx_amp_index = TX_AMP_MIDDLE; // start with 0 dB
-
- set_gphy_reg_cl45(phyadd, DEVID_1E, tx_amp_reg, (reg_temp | (tx_amp_index << tx_amp_reg_shift))); // 1e_12/17/19/21
-
- anacal_exe(phyadd_common);
- if (all_ana_cal_status == 0)
- {
- all_ana_cal_status = ANACAL_ERROR;
- }
-
-
- ad_cal_comp_out_init = (get_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg17Ah) >> 8) & 0x1; // 1e_17a[8]:ad_cal_comp_out
- //Serial.println(ad_cal_comp_out_init, HEX);
-
- if (ad_cal_comp_out_init == 1)
- {
- calibration_polarity = -1;
- }
- else
- {
- calibration_polarity = 1;
- }
- while (all_ana_cal_status < ANACAL_ERROR)
- {
- tx_amp_index += calibration_polarity;
- //Serial.println(tx_amp_index, HEX);
-
- set_gphy_reg_cl45(phyadd, DEVID_1E, tx_amp_reg, (reg_temp | (tx_amp_index << tx_amp_reg_shift)));
-
- anacal_exe(phyadd_common);
-
- if (all_ana_cal_status == 0)
- {
- all_ana_cal_status = ANACAL_ERROR;
- }
- else if (((get_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg17Ah) >> 8) & 0x1) != ad_cal_comp_out_init)
- {
- all_ana_cal_status = ANACAL_FINISH;
- //Serial.print(" tx_amp_index: ");
- //Serial.println(tx_amp_index, HEX);
- //reg_temp = get_gphy_reg_cl45(phyadd, 0x1e, tx_amp_reg)&(~0xff00);
- //set_gphy_reg_cl45(phyadd, 0x1e, tx_amp_reg, (reg_temp|((tx_amp_index + tst_offset)<<tx_amp_reg_shift))); // for gbe(DAC)
- }
- else
- {
- if ((tx_amp_index == 0x3f) || (tx_amp_index == 0x00))
- {
- all_ana_cal_status = ANACAL_SATURATION; // need to FT
- tx_amp_index = TX_AMP_MIDDLE;
- }
- }
- }
-
- if (all_ana_cal_status == ANACAL_ERROR)
- {
- tx_amp_index = TX_AMP_MIDDLE;
- }
-
- // da_tx_i2mpb_a_gbe / b/c/d, only GBE for now
- set_gphy_reg_cl45(phyadd, DEVID_1E, tx_amp_reg, ((tx_amp_index - TXAMP_offset) | ((tx_amp_index - TXAMP_offset) << tx_amp_reg_shift))); // // temp modify
- set_gphy_reg_cl45(phyadd, DEVID_1E, tx_amp_reg_100, ((tx_amp_index - TXAMP_offset) | ((tx_amp_index + TX_i2mpb_hbt_ofs) << tx_amp_reg_shift)));
- }
-
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Dh, Disable_all);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Eh, Disable_all);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Fh, Disable_all);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg180h, Disable_all);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg181h, Disable_all);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg182h, Disable_all);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg183h, Disable_all);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg184h, Disable_all);
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Disable_all); // disable analog calibration circuit
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Disable_all); // disable Tx offset calibration circuit
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg03Eh, Disable_all); // disable Tx VLD force mode
- set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DDh, Disable_all); // disable Tx offset/amplitude calibration circuit
-
- return all_ana_cal_status;
-}
-
-void set_gphy_reg_cl22(uint8_t phyad, uint8_t reg, uint16_t value)
-{
- an8855_phy_write(phyad-g_smi_addr, reg, value);
- /*
- gsw_top_reg_REG_PHY_IAC REG_PHY_IAC_val;
- gsw_top_reg_REG_PHY_IAD REG_PHY_IAD_val;
-
- // Wait until done
- do
- {
- REG_PHY_IAC_val.Raw = io_read32(RgAddr_gsw_top_reg_REG_PHY_IAC);
- }
- while(REG_PHY_IAC_val.Bits.csr_phy_acs_st);
-
- // Set address
- REG_PHY_IAC_val.Bits.csr_mdio_st = 1;
- REG_PHY_IAC_val.Bits.csr_mdio_cmd = 1;
- REG_PHY_IAC_val.Bits.csr_mdio_phy_addr = phyad;
- REG_PHY_IAC_val.Bits.csr_mdio_reg_addr = reg;
- REG_PHY_IAC_val.Bits.csr_mdio_wr_data = value;
- REG_PHY_IAC_val.Bits.csr_phy_acs_st = 1;
-
- io_write32(RgAddr_gsw_top_reg_REG_PHY_IAC, REG_PHY_IAC_val.Raw);
- */
-}
-
-UINT16 get_gphy_reg_cl45(uint8_t prtid, uint8_t devid, uint16_t reg)
-{
- UINT32 rdata = 0;
-
- an8855_phy_read_cl45(prtid-g_smi_addr, devid, reg, &rdata);
- return ((UINT16)rdata);
- /*
- gsw_top_reg_REG_PHY_IAC REG_PHY_IAC_val;
- gsw_top_reg_REG_PHY_IAD REG_PHY_IAD_val;
-
- // Wait until done
- do
- {
- REG_PHY_IAC_val.Raw = io_read32(RgAddr_gsw_top_reg_REG_PHY_IAC);
- }
- while(REG_PHY_IAC_val.Bits.csr_phy_acs_st);
-
- // Set address
- REG_PHY_IAC_val.Bits.csr_mdio_st = 0;
- REG_PHY_IAC_val.Bits.csr_mdio_cmd = 0;
- REG_PHY_IAC_val.Bits.csr_mdio_phy_addr = prtid;
- REG_PHY_IAC_val.Bits.csr_mdio_reg_addr = devid;
- REG_PHY_IAC_val.Bits.csr_mdio_wr_data = reg;
- REG_PHY_IAC_val.Bits.csr_phy_acs_st = 1;
-
- io_write32(RgAddr_gsw_top_reg_REG_PHY_IAC, REG_PHY_IAC_val.Raw);
-
- // Wait until done
- do
- {
- REG_PHY_IAC_val.Raw = io_read32(RgAddr_gsw_top_reg_REG_PHY_IAC);
- }
- while(REG_PHY_IAC_val.Bits.csr_phy_acs_st);
-
- // Read value
- REG_PHY_IAC_val.Bits.csr_mdio_st = 0;
- REG_PHY_IAC_val.Bits.csr_mdio_cmd = 3;
- REG_PHY_IAC_val.Bits.csr_mdio_phy_addr = prtid;
- REG_PHY_IAC_val.Bits.csr_mdio_reg_addr = devid;
- REG_PHY_IAC_val.Bits.csr_mdio_wr_data = 0;
- REG_PHY_IAC_val.Bits.csr_phy_acs_st = 1;
- io_write32(RgAddr_gsw_top_reg_REG_PHY_IAC, REG_PHY_IAC_val.Raw);
-
- // Wait until done
- do
- {
- REG_PHY_IAC_val.Raw = io_read32(RgAddr_gsw_top_reg_REG_PHY_IAC);
- }
- while(REG_PHY_IAC_val.Bits.csr_phy_acs_st);
-
- REG_PHY_IAD_val.Raw = io_read32(RgAddr_gsw_top_reg_REG_PHY_IAD);
-
- return REG_PHY_IAD_val.Raw;
- */
-}
-
-void set_gphy_reg_cl45(uint8_t prtid, uint8_t devid, uint16_t reg, uint16_t value)
-{
- an8855_phy_write_cl45(prtid-g_smi_addr, devid, reg, value);
- /*
- gsw_top_reg_REG_PHY_IAC REG_PHY_IAC_val;
-
- // Wait until done
- do
- {
- REG_PHY_IAC_val.Raw = io_read32(RgAddr_gsw_top_reg_REG_PHY_IAC);
- }
- while(REG_PHY_IAC_val.Bits.csr_phy_acs_st);
-
- // Set address
- REG_PHY_IAC_val.Bits.csr_mdio_st = 0;
- REG_PHY_IAC_val.Bits.csr_mdio_cmd = 0;
- REG_PHY_IAC_val.Bits.csr_mdio_phy_addr = prtid;
- REG_PHY_IAC_val.Bits.csr_mdio_reg_addr = devid;
- REG_PHY_IAC_val.Bits.csr_mdio_wr_data = reg;
- REG_PHY_IAC_val.Bits.csr_phy_acs_st = 1;
-
- io_write32(RgAddr_gsw_top_reg_REG_PHY_IAC, REG_PHY_IAC_val.Raw);
-
- // Wait until done
- do
- {
- REG_PHY_IAC_val.Raw = io_read32(RgAddr_gsw_top_reg_REG_PHY_IAC);
- }
- while(REG_PHY_IAC_val.Bits.csr_phy_acs_st);
-
- // Write value
- REG_PHY_IAC_val.Bits.csr_mdio_st = 0;
- REG_PHY_IAC_val.Bits.csr_mdio_cmd = 1;
- REG_PHY_IAC_val.Bits.csr_mdio_phy_addr = prtid;
- REG_PHY_IAC_val.Bits.csr_mdio_reg_addr = devid;
- REG_PHY_IAC_val.Bits.csr_mdio_wr_data = value;
- REG_PHY_IAC_val.Bits.csr_phy_acs_st = 1;
-
- io_write32(RgAddr_gsw_top_reg_REG_PHY_IAC, REG_PHY_IAC_val.Raw);
- */
-}
-
-void anacal_exe(uint8_t phyadd_common)
-{
- set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg17Ch, 1);// da_calin_flag pull high
- an8855_udelay(1000);
- set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg17Ch, 0);// da_calin_flag pull low
-}
-
+/* FILE NAME: an8855_phy_cal.c
+* PURPOSE:
+* It provides an8855 switch phy calibration function.
+*
+* NOTES:
+*
+*/
+
+/* INCLUDE FILE DECLARATIONS
+*/
+#include "an8855_mdio.h"
+#include "an8855_phy.h"
+//#include "swk_gphy_reg.h"
+//#include "gphy_calibration.h"
+//#include "gsw_reg.h"
+
+/* NAMING CONSTANT DECLARATIONS
+ */
+#define MII_BMCR (0)
+#define BMCR_PDOWN (0x0800)
+/* MACRO FUNCTION DECLARATIONS
+ */
+
+#define FULL_BITS(_n_) ((1UL << (_n_)) - 1)
+
+/* DATA TYPE DECLARATIONS
+ */
+
+/* GLOBAL VARIABLE DECLARATIONS
+ */
+/* Zcal to R50 mapping table (20220404) */
+const uint8_t ZCAL_TO_R50ohm_TBL[64] =
+{
+ 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
+ 127, 127, 127, 127, 127, 123, 118, 114, 110, 106, 102, 98, 96, 92, 88, 85,
+ 82, 80, 76, 72, 70, 67, 64, 62, 60, 56, 54, 52, 49, 48, 45, 43,
+ 40, 39, 36, 34, 32, 32, 30, 28, 25, 24, 22, 20, 18, 16, 16, 14
+};
+
+/* Tx offset table, value is from small to big */
+const uint8_t EN753x_TX_OFS_TBL[64] =
+{
+ 0x3f, 0x3e, 0x3d, 0x3c, 0x3b, 0x3a, 0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x30,
+ 0x2f, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20,
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
+};
+
+#define TOTAL_PATCH_C45_ITEMS (15)
+#define TOTAL_PATCH_TR_ITEMS (19)
+const uint16_t C45_PATCH_TABLE[TOTAL_PATCH_C45_ITEMS][3] =
+{
+ {0x1E, 0x120, 0x8014},
+ {0x1E, 0x122, 0xFFFF},
+ {0x1E, 0x122, 0xFFFF},
+ {0x1E, 0x144, 0x0200},
+ {0x1E, 0x14A, 0xEE20},
+ {0x1E, 0x189, 0x0110},
+ {0x1E, 0x19B, 0x0111},
+ {0x1E, 0x234, 0x0181},
+ {0x1E, 0x238, 0x0120},
+ {0x1E, 0x239, 0x0117},
+ {0x1F, 0x268, 0x07F4},
+ {0x1E, 0x2d1, 0x0733},
+ {0x1E, 0x323, 0x0011},
+ {0x1E, 0x324, 0x013F},
+ {0x1E, 0x326, 0x0037},
+};
+
+const uint32_t TR_PATCH_TABLE[TOTAL_PATCH_TR_ITEMS][2] =
+{
+ {0x83AA, 0x055a0 },
+ {0x83AE, 0x7FF3F },
+ {0x8F80, 0x0001e },
+ {0x8F82, 0x6FB90A},
+ {0x8FAE, 0x060671},
+ {0x8FB0, 0xE2F00 },
+ {0x8ECC, 0x444444},
+ {0x9686, 0x00000 },
+ {0x968C, 0x2EBAEF},
+ {0x9690, 0x00000b},
+ {0x9698, 0x0504D },
+ {0x969A, 0x2314f },
+ {0x969E, 0x03028 },
+ {0x96A0, 0x05010 },
+ {0x96A2, 0x40001 },
+ {0x96A6, 0x018670},
+ {0x96A8, 0x0024A },
+ {0x96B6, 0x00072 },
+ {0x96B8, 0x03210 },
+};
+
+#define TOTAL_NUMBER_OF_PATCH (14)
+static uint16_t eee_patch_table[TOTAL_NUMBER_OF_PATCH][2] = {
+ {RgAddr_dev1Eh_reg120h, 0x8014},
+ {RgAddr_dev1Eh_reg122h, 0xFFFF},
+ {RgAddr_dev1Eh_reg122h, 0xFFFF},
+ {RgAddr_dev1Eh_reg144h, 0x0200},
+ {RgAddr_dev1Eh_reg14Ah, 0xEE20},
+ {RgAddr_dev1Eh_reg19Bh, 0x0111},
+ {RgAddr_dev1Eh_reg234h, 0x1181},
+ {RgAddr_dev1Eh_reg238h, 0x0120},
+ {RgAddr_dev1Eh_reg239h, 0x0117},
+ {RgAddr_dev1Fh_reg268h, 0x07F4},
+ {RgAddr_dev1Eh_reg2D1h, 0x0733},
+ {RgAddr_dev1Eh_reg323h, 0x0011},
+ {RgAddr_dev1Eh_reg324h, 0x013F},
+ {RgAddr_dev1Eh_reg326h, 0x0037}
+};
+
+#define TOTAL_NUMBER_OF_TR (19)
+static uint16_t tr_reg_table[TOTAL_NUMBER_OF_TR][3] = {
+ {0x55A0, 0x0000, 0x83AA},
+ {0xFF3F, 0x0007, 0x83AE},
+ {0x001E, 0x0000, 0x8F80},
+ {0xB90A, 0x006F, 0x8F82},
+ {0x0671, 0x0006, 0x8FAE},
+ {0x2F00, 0x000E, 0x8FB0},
+ {0x4444, 0x0044, 0x8ECC},
+ {0x0004, 0x0000, 0x9686},
+ {0xBAEF, 0x002E, 0x968C},
+ {0x000B, 0x0000, 0x9690},
+ {0x504D, 0x0000, 0x9698},
+ {0x314F, 0x0002, 0x969A},
+ {0x3028, 0x0000, 0x969E},
+ {0x5010, 0x0000, 0x96A0},
+ {0x0001, 0x0004, 0x96A2},
+ {0x8670, 0x0001, 0x96A6},
+ {0x024A, 0x0000, 0x96A8},
+ {0x0072, 0x0000, 0x96B6},
+ {0x3210, 0x0000, 0x96B8}
+};
+
+void TR_RegWr(uint16_t phyadd, uint16_t tr_reg_addr, uint32_t tr_data);
+
+uint16_t get_gphy_reg_cl22(uint8_t phyad, uint8_t reg)
+{
+ uint32_t rdata = 0;
+
+ an8855_phy_read(phyad-g_smi_addr, reg, &rdata);
+
+ return ((uint16_t)rdata);
+ /*
+ gsw_top_reg_REG_PHY_IAC REG_PHY_IAC_val;
+ gsw_top_reg_REG_PHY_IAD REG_PHY_IAD_val;
+
+ // Wait until done
+ do
+ {
+ REG_PHY_IAC_val.Raw = io_read32(RgAddr_gsw_top_reg_REG_PHY_IAC);
+ }
+ while(REG_PHY_IAC_val.Bits.csr_phy_acs_st);
+
+ // Set address
+ REG_PHY_IAC_val.Bits.csr_mdio_st = 1;
+ REG_PHY_IAC_val.Bits.csr_mdio_cmd = 2;
+ REG_PHY_IAC_val.Bits.csr_mdio_phy_addr = phyad;
+ REG_PHY_IAC_val.Bits.csr_mdio_reg_addr = reg;
+ REG_PHY_IAC_val.Bits.csr_phy_acs_st = 1;
+ io_write32(RgAddr_gsw_top_reg_REG_PHY_IAC, REG_PHY_IAC_val.Raw);
+ // Wait until done
+ do
+ {
+ REG_PHY_IAC_val.Raw = io_read32(RgAddr_gsw_top_reg_REG_PHY_IAC);
+ }
+ while(REG_PHY_IAC_val.Bits.csr_phy_acs_st);
+
+ REG_PHY_IAD_val.Raw = io_read32(RgAddr_gsw_top_reg_REG_PHY_IAD);
+
+ return REG_PHY_IAD_val.Raw;
+ */
+}
+
+/* EXPORTED SUBPROGRAM BODIES
+ */
+void gphy_config(void)
+{
+ uint8_t port = 1;
+ uint8_t phy_base = 0, phys_in_chip = 8;
+
+ for (port = 1; port <= phys_in_chip; port++)
+ {
+ set_gphy_reg_cl45(phy_base + port, 0x7, 0x3c, 0x0006); // Enable EEE
+ set_gphy_reg_cl45(phy_base + port, 0x1e, 0x3e, 0xf000); // force on TXVLD
+ }
+}
+
+static void set_gphy_TrReg(uint8_t prtid, uint16_t parm_1, uint16_t parm_2, uint16_t parm_3)
+{
+ set_gphy_reg_cl22(prtid, RgAddr_TrReg11h, parm_1);
+ set_gphy_reg_cl22(prtid, RgAddr_TrReg12h, parm_2);
+ set_gphy_reg_cl22(prtid, RgAddr_TrReg10h, parm_3);
+}
+
+static void gphy_eee_patch(uint8_t phy_base)
+{
+ UI8_T port = 1, index = 0, phy_addr = 1;
+ UI16_T data = 0;
+
+ for (port = 1; port <=8; port++)
+ {
+ phy_addr = phy_base + port;
+ data = get_gphy_reg_cl22(phy_addr, MII_BMCR);
+ set_gphy_reg_cl22(phy_addr, MII_BMCR, data & ~(BMCR_PDOWN)); /* PHY power on */
+
+ /* Change EEE RG default value */
+ for (index = 0; index < TOTAL_NUMBER_OF_PATCH; index++)
+ {
+ set_gphy_reg_cl45(phy_addr, DEVID_1E, eee_patch_table[index][0], eee_patch_table[index][1]);
+ }
+
+ set_gphy_reg_cl22(phy_addr, RgAddr_Reg1Fh, CL22_Page_TrReg); /* change CL22page to LpiReg(0x3) */
+ for (index = 0; index < TOTAL_NUMBER_OF_TR; index++)
+ {
+ set_gphy_TrReg(phy_addr, tr_reg_table[index][0], tr_reg_table[index][1], tr_reg_table[index][2]);
+ }
+
+ set_gphy_reg_cl22(phy_addr, RgAddr_Reg1Fh, CL22_Page_LpiReg); /* change CL22page to LpiReg(0x3) */
+ set_gphy_reg_cl22(phy_addr, RgAddr_LpiReg1Ch, 0x0c92); /* Fine turn SigDet for B2B LPI link down issue */
+ set_gphy_reg_cl22(phy_addr, RgAddr_LpiReg1Dh, 0x0001); /* Enable "lpi_quit_waitafesigdet_en" for LPI link down issue */
+
+ set_gphy_reg_cl22(phy_addr, RgAddr_Reg1Fh, CL22_Page_Reg); /* change CL22page to Reg(0x0) */
+ }
+}
+
+void gphy_calibration(uint8_t phy_base)
+{
+ uint8_t port = 1, phy_addr = 1 ,phy_group = 1, index = 0;
+ uint8_t phys_in_chip = 5;
+
+ BG_Calibration(phy_base, 0x1);
+ if (phys_in_chip > 4)
+ {
+ BG_Calibration(phy_base + 0x4, 0x1);
+ }
+
+ for (port = 0; port < phys_in_chip; port++)
+ {
+ if (port < 4)
+ {
+ phy_group = phy_base; /* PHY group 1 */
+ }
+ else
+ {
+ phy_group = phy_base + 0x04; /* PHY group 2 */
+ }
+ phy_addr = phy_base + port;
+ R50_Calibration(phy_addr, phy_group);
+ TX_OFS_Calibration(phy_addr, phy_group);
+ TX_AMP_Calibration(phy_addr, phy_group);
+ }
+
+ for (port = 0; port < phys_in_chip; port++)
+ {
+ phy_addr = phy_base + port;
+ set_gphy_reg_cl45(phy_addr, 0x1e, 0x017d, 0x0000);
+ set_gphy_reg_cl45(phy_addr, 0x1e, 0x017e, 0x0000);
+ set_gphy_reg_cl45(phy_addr, 0x1e, 0x017f, 0x0000);
+ set_gphy_reg_cl45(phy_addr, 0x1e, 0x0180, 0x0000);
+ set_gphy_reg_cl45(phy_addr, 0x1e, 0x0181, 0x0000);
+ set_gphy_reg_cl45(phy_addr, 0x1e, 0x0182, 0x0000);
+ set_gphy_reg_cl45(phy_addr, 0x1e, 0x0183, 0x0000);
+ set_gphy_reg_cl45(phy_addr, 0x1e, 0x0184, 0x0000);
+ set_gphy_reg_cl45(phy_addr, 0x1e, 0x00db, 0x0000); // disable analog calibration circuit
+ set_gphy_reg_cl45(phy_addr, 0x1e, 0x00dc, 0x0000); // disable Tx offset calibration circuit
+ set_gphy_reg_cl45(phy_addr, 0x1e, 0x003e, 0x0000); // disable Tx VLD force mode
+ set_gphy_reg_cl45(phy_addr, 0x1e, 0x00dd, 0x0000); // disable Tx offset/amplitude calibration circuit
+ set_gphy_reg_cl45(phy_addr, 0x1e, 0x0145, 0x1000); // enable auto MDI/MDIX
+
+ set_gphy_reg_cl22(phy_addr, 0, 0x1200);
+ /* GPHY Rx low pass filter */
+ set_gphy_reg_cl45(phy_addr, 0x1e, 0xc7, 0xd000);
+ /* patch */
+ for (index = 0; index < TOTAL_PATCH_C45_ITEMS; index++)
+ {
+ set_gphy_reg_cl45(phy_addr, C45_PATCH_TABLE[index][0], C45_PATCH_TABLE[index][1], C45_PATCH_TABLE[index][2]);
+ }
+ for (index = 0; index < TOTAL_PATCH_TR_ITEMS; index++)
+ {
+ TR_RegWr(phy_addr, TR_PATCH_TABLE[index][0], TR_PATCH_TABLE[index][1]);
+ }
+ set_gphy_reg_cl22(phy_addr, 0x1f, 0x0 );
+ set_gphy_reg_cl22(phy_addr, 0x1f, 0x3 );
+ set_gphy_reg_cl22(phy_addr, 0x1c, 0xc92);
+ set_gphy_reg_cl22(phy_addr, 0x1d, 0x01 );
+ set_gphy_reg_cl22(phy_addr, 0x1f, 0x0 );
+ }
+ gphy_eee_patch(phy_base);
+}
+
+/* LOCAL SUBPROGRAM BODIES
+ */
+void TR_RegWr(uint16_t phyadd, uint16_t tr_reg_addr, uint32_t tr_data)
+{
+ set_gphy_reg_cl22(phyadd, 0x1F, 0x52b5); /* page select */
+ set_gphy_reg_cl22(phyadd, 0x11, (uint16_t)(tr_data & 0xffff));
+ set_gphy_reg_cl22(phyadd, 0x12, (uint16_t)(tr_data >> 16));
+ set_gphy_reg_cl22(phyadd, 0x10, (uint16_t)(tr_reg_addr | TrReg_WR));
+ set_gphy_reg_cl22(phyadd, 0x1F, 0x0); /* page resetore */
+ return;
+}
+
+uint8_t BG_Calibration(uint8_t phyadd, int8_t calipolarity)
+{
+ int8_t rg_zcal_ctrl = 0, calibration_polarity = 0;
+ uint8_t all_ana_cal_status = 1;
+ uint16_t ad_cal_comp_out_init = 0;
+
+ /* setting */
+ set_gphy_reg_cl22(phyadd, RgAddr_Reg1Fh, CL22_Page_Reg); // g0
+ set_gphy_reg_cl22(phyadd, RgAddr_Reg00h, AN_disable_force_1000M); // AN disable, force 1000M
+ set_gphy_reg_cl45(phyadd, DEVID_1F, RgAddr_dev1Fh_reg100h, BG_voltage_output);// BG voltage output
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg145h, Fix_mdi);// fix mdi
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Fh_reg0FFh, 0x2);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Cal_control_BG);// 1e_db[12]:rg_cal_ckinv, [8]:rg_ana_calen, [4]:rg_rext_calen
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Disable_all);// 1e_dc[0]:rg_txvos_calen
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0E1h, Disable_all);// 1e_e1[4]:rg_cal_refsel(0:1.2V) enable BG 1.2V to REXT PAD
+
+ /* calibrate */
+ rg_zcal_ctrl = ZCAL_MIDDLE;
+
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0E0h, (uint16_t)rg_zcal_ctrl);
+
+ anacal_exe(phyadd);
+ if (all_ana_cal_status == 0)
+ {
+ all_ana_cal_status = ANACAL_ERROR;
+ }
+ ad_cal_comp_out_init = (get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Ah) >> 8) & 0x1;
+
+
+ if (ad_cal_comp_out_init == 1)
+ {
+ calibration_polarity = -calipolarity;
+ }
+ else // ad_cal_comp_out_init == 0
+ {
+ calibration_polarity = calipolarity;
+ }
+
+ while (all_ana_cal_status < ANACAL_ERROR)
+ {
+ rg_zcal_ctrl += calibration_polarity;
+
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0E0h, (uint16_t)rg_zcal_ctrl);
+
+
+ anacal_exe(phyadd);
+
+ if (all_ana_cal_status == 0)
+ {
+ all_ana_cal_status = ANACAL_ERROR;
+ }
+
+ else if (((get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Ah) >> 8) & 0x1) != ad_cal_comp_out_init)
+ {
+ all_ana_cal_status = ANACAL_FINISH;
+ }
+ else
+ {
+ if ((rg_zcal_ctrl == 0x3F) || (rg_zcal_ctrl == 0x00))
+ {
+ all_ana_cal_status = ANACAL_SATURATION; // need to FT
+ rg_zcal_ctrl = ZCAL_MIDDLE; // 0 dB
+ }
+ }
+ }
+
+ if (all_ana_cal_status == ANACAL_ERROR)
+ {
+ rg_zcal_ctrl = ZCAL_MIDDLE; // 0 dB
+
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0E0h, (uint16_t)rg_zcal_ctrl);
+ }
+ else
+ {
+ // rg_zcal_ctrl[5:0] rg_rext_trim[13:8]
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0E0h, (uint16_t)((rg_zcal_ctrl << 8) | rg_zcal_ctrl));
+
+ // 1f_115[2:0](rg_bg_rasel) = rg_zcal_ctrl[5:3]
+ set_gphy_reg_cl45(phyadd, DEVID_1F, RgAddr_dev1Fh_reg115h, (uint16_t)((rg_zcal_ctrl & 0x3f) >> 3));
+ }
+
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Disable_all);
+ return all_ana_cal_status;
+}
+
+uint8_t R50_Calibration(uint8_t phyadd, uint8_t phyadd_common)
+{
+ int8_t rg_zcal_ctrl = 0, rg_r50ohm_rsel_tx = 0, calibration_polarity = 0;
+ uint8_t all_ana_cal_status = 1;
+ int16_t backup_dev1e_e0 = 0, ad_cal_comp_out_init = 0, calibration_pair = 0;
+
+ /* setting */
+ set_gphy_reg_cl22(phyadd, RgAddr_Reg1Fh, CL22_Page_Reg); // g0
+ set_gphy_reg_cl22(phyadd, RgAddr_Reg00h, AN_disable_force_1000M); // AN disable, force 1000M
+
+ set_gphy_reg_cl45(phyadd_common, DEVID_1F, RgAddr_dev1Fh_reg100h, BG_voltage_output); // BG voltage output
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg145h, Fix_mdi); // fix mdi
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg185h, Disable_tx_slew_control); // disable tx slew control
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0FBh, LDO_control); // ldo
+ set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Cal_control_R50); // 1e_db[12]:rg_cal_ckinv, [8]:rg_ana_calen, [4]:rg_rext_calen
+ set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Disable_all); // 1e_dc[0]:rg_txvos_calen
+ set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0E1h, Disable_all); // 1e_e1[4]:rg_cal_refsel(0:1.2V) enable BG 1.2V to REXT PAD
+
+ for (calibration_pair = ANACAL_PAIR_A; calibration_pair <= ANACAL_PAIR_D; calibration_pair++)
+ {
+ all_ana_cal_status = 1;
+
+ if (calibration_pair == ANACAL_PAIR_A)
+ {
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Cal_control_R50_pairA_ENABLE); // 1e_db[12]:rg_cal_ckinv, [8]:rg_ana_calen, [4]:rg_rext_calen, [0]:rg_zcalen_a
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Zcalen_A_ENABLE);
+ }
+ else if (calibration_pair == ANACAL_PAIR_B)
+ {
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Cal_control_R50); // 1e_db[12]:rg_cal_ckinv, [8]:rg_ana_calen, [4]:rg_rext_calen, [0]:rg_zcalen_a
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Zcalen_B_ENABLE); // 1e_dc[12]:rg_zcalen_b
+ }
+ else if (calibration_pair == ANACAL_PAIR_C)
+ {
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Cal_control_R50); // 1e_db[12]:rg_cal_ckinv, [8]:rg_ana_calen, [4]:rg_rext_calen, [0]:rg_zcalen_a
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Zcalen_C_ENABLE); // 1e_dc[8]:rg_zcalen_c
+ }
+ else // if(calibration_pair == ANACAL_PAIR_D)
+ {
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Cal_control_R50); // 1e_db[12]:rg_cal_ckinv, [8]:rg_ana_calen, [4]:rg_rext_calen, [0]:rg_zcalen_a
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Zcalen_D_ENABLE); // 1e_dc[4]:rg_zcalen_d
+ }
+
+ /* calibrate */
+ rg_zcal_ctrl = ZCAL_MIDDLE; // start with 0 dB
+
+ backup_dev1e_e0 = (get_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0E0h)&(~0x003f));
+ set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0E0h, (backup_dev1e_e0 | rg_zcal_ctrl));
+
+ anacal_exe(phyadd_common);
+ if (all_ana_cal_status == 0)
+ {
+ all_ana_cal_status = ANACAL_ERROR;
+ }
+
+ ad_cal_comp_out_init = (get_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg17Ah) >> 8) & 0x1; // 1e_17a[8]:ad_cal_comp_out
+
+ if (ad_cal_comp_out_init == 1)
+ {
+ calibration_polarity = -1;
+ }
+ else
+ {
+ calibration_polarity = 1;
+ }
+
+ while (all_ana_cal_status < ANACAL_ERROR)
+ {
+ rg_zcal_ctrl += calibration_polarity;
+
+ set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0E0h, (backup_dev1e_e0 | rg_zcal_ctrl));
+
+ anacal_exe(phyadd_common);
+
+ if (all_ana_cal_status == 0)
+ {
+ all_ana_cal_status = ANACAL_ERROR;
+ }
+ else if (((get_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg17Ah) >> 8) & 0x1) != ad_cal_comp_out_init)
+ {
+ all_ana_cal_status = ANACAL_FINISH;
+ }
+ else
+ {
+ if ((rg_zcal_ctrl == 0x3F) || (rg_zcal_ctrl == 0x00))
+ {
+ all_ana_cal_status = ANACAL_SATURATION; // need to FT
+ rg_zcal_ctrl = ZCAL_MIDDLE; // 0 dB
+ }
+ }
+ }
+
+ if (all_ana_cal_status == ANACAL_ERROR)
+ {
+ rg_r50ohm_rsel_tx = ZCAL_MIDDLE; // 0 dB
+ }
+ else
+ {
+ if (rg_zcal_ctrl > (0x3F - R50_OFFSET_VALUE))
+ {
+ all_ana_cal_status = ANACAL_SATURATION; // need to FT
+ rg_zcal_ctrl = ZCAL_MIDDLE; // 0 dB
+ }
+ else
+ {
+ rg_zcal_ctrl += R50_OFFSET_VALUE;
+ }
+
+ rg_r50ohm_rsel_tx = ZCAL_TO_R50ohm_TBL[rg_zcal_ctrl];
+ }
+
+ if (calibration_pair == ANACAL_PAIR_A)
+ {
+ // cr_r50ohm_rsel_tx_a
+ ad_cal_comp_out_init = get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg174h)&(~MASK_r50ohm_rsel_tx_a);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg174h, (ad_cal_comp_out_init | (((rg_r50ohm_rsel_tx << 8) & MASK_MSB_8bit) | Rg_r50ohm_rsel_tx_a_en))); // 1e_174[15:8]
+ }
+ else if (calibration_pair == ANACAL_PAIR_B)
+ {
+ // cr_r50ohm_rsel_tx_b
+ ad_cal_comp_out_init = get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg174h)&(~MASK_r50ohm_rsel_tx_b);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg174h, (ad_cal_comp_out_init | (((rg_r50ohm_rsel_tx << 0) & MASK_LSB_8bit) | Rg_r50ohm_rsel_tx_b_en))); // 1e_174[7:0]
+ }
+ else if (calibration_pair == ANACAL_PAIR_C)
+ {
+ // cr_r50ohm_rsel_tx_c
+ ad_cal_comp_out_init = get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg175h)&(~MASK_r50ohm_rsel_tx_c);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg175h, (ad_cal_comp_out_init | (((rg_r50ohm_rsel_tx << 8) & MASK_MSB_8bit) | Rg_r50ohm_rsel_tx_c_en))); // 1e_175[15:8]
+ }
+ else // if(calibration_pair == ANACAL_PAIR_D)
+ {
+ // cr_r50ohm_rsel_tx_d
+ ad_cal_comp_out_init = get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg175h)&(~MASK_r50ohm_rsel_tx_d);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg175h, (ad_cal_comp_out_init | (((rg_r50ohm_rsel_tx << 0) & MASK_LSB_8bit) | Rg_r50ohm_rsel_tx_d_en))); // 1e_175[7:0]
+ }
+ }
+
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Disable_all);
+ set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Disable_all);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Disable_all);
+
+ return all_ana_cal_status;
+}
+
+uint8_t TX_OFS_Calibration(uint8_t phyadd, uint8_t phyadd_common)
+{
+ int8_t tx_offset_index = 0, calibration_polarity = 0;
+ uint8_t all_ana_cal_status = 1, tx_offset_reg_shift = 0, tbl_idx = 0;
+ int16_t ad_cal_comp_out_init = 0, calibration_pair = 0, tx_offset_reg = 0, reg_temp = 0;
+
+ /* setting */
+ set_gphy_reg_cl22(phyadd, RgAddr_Reg1Fh, CL22_Page_Reg); // g0
+ set_gphy_reg_cl22(phyadd, RgAddr_Reg00h, AN_disable_force_1000M); // AN disable, force 1000M
+
+ set_gphy_reg_cl45(phyadd, DEVID_1F, RgAddr_dev1Fh_reg100h, BG_voltage_output); // BG voltage output
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg145h, Fix_mdi); // fix mdi
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg185h, Disable_tx_slew_control); // disable tx slew control
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0FBh, LDO_control); // ldo
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Cal_control_TX_OFST); // 1e_db[12]:rg_cal_ckinv, [8]:rg_ana_calen, [4]:rg_rext_calen
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Rg_txvos_calen_ENABLE); // 1e_dc[0]:rg_txvos_calen
+ set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Cal_control_TX_OFST); // 1e_db[12]:rg_cal_ckinv, [8]:rg_ana_calen, [4]:rg_rext_calen
+ set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Rg_txvos_calen_ENABLE); // 1e_dc[0]:rg_txvos_calen
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0E1h, Disable_all); // 1e_e1[4]:rg_cal_refsel(0:1.2V) enable BG 1.2V to REXT PAD
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg096h, Bypass_tx_offset_cal); // 1e_96[15]:bypass_tx_offset_cal, Hw bypass, Fw cal
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg03Eh, Enable_Tx_VLD); // 1e_3e:enable Tx VLD
+
+ for (calibration_pair = ANACAL_PAIR_A; calibration_pair <= ANACAL_PAIR_D; calibration_pair++)
+ {
+ all_ana_cal_status = 1;
+
+ tbl_idx = TX_OFFSET_0mV_idx;
+ tx_offset_index = EN753x_TX_OFS_TBL[tbl_idx];
+
+ if (calibration_pair == ANACAL_PAIR_A)
+ {
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DDh, Rg_txg_calen_a_ENABLE); // 1e_dd[12]:rg_txg_calen_a
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Dh, (Force_dasn_dac_in0_ENABLE | DAC_IN_0V)); // 1e_17d:dac_in0_a
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg181h, (Force_dasn_dac_in1_ENABLE | DAC_IN_0V)); // 1e_181:dac_in1_a
+
+ reg_temp = (get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg172h)&(~MASK_cr_tx_amp_offset_MSB));
+ tx_offset_reg_shift = 8; // 1e_172[13:8]
+ tx_offset_reg = RgAddr_dev1Eh_reg172h;
+ }
+ else if (calibration_pair == ANACAL_PAIR_B)
+ {
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DDh, Rg_txg_calen_b_ENABLE); // 1e_dd[8]:rg_txg_calen_b
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Eh, (Force_dasn_dac_in0_ENABLE | DAC_IN_0V)); // 1e_17e:dac_in0_b
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg182h, (Force_dasn_dac_in1_ENABLE | DAC_IN_0V)); // 1e_182:dac_in1_b
+
+ reg_temp = (get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg172h)&(~MASK_cr_tx_amp_offset_LSB));
+ tx_offset_reg_shift = 0; // 1e_172[5:0]
+ tx_offset_reg = RgAddr_dev1Eh_reg172h;
+ }
+ else if (calibration_pair == ANACAL_PAIR_C)
+ {
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DDh, Rg_txg_calen_c_ENABLE); // 1e_dd[4]:rg_txg_calen_c
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Fh, (Force_dasn_dac_in0_ENABLE | DAC_IN_0V)); // 1e_17f:dac_in0_c
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg183h, (Force_dasn_dac_in1_ENABLE | DAC_IN_0V)); // 1e_183:dac_in1_c
+
+ reg_temp = (get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg173h)&(~MASK_cr_tx_amp_offset_MSB));
+ tx_offset_reg_shift = 8; // 1e_173[13:8]
+ tx_offset_reg = RgAddr_dev1Eh_reg173h;
+ }
+ else // if(calibration_pair == ANACAL_PAIR_D)
+ {
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DDh, Rg_txg_calen_d_ENABLE); // 1e_dd[0]:rg_txg_calen_d
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg180h, (Force_dasn_dac_in0_ENABLE | DAC_IN_0V)); // 1e_180:dac_in0_d
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg184h, (Force_dasn_dac_in1_ENABLE | DAC_IN_0V)); // 1e_184:dac_in1_d
+
+ reg_temp = (get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg173h)&(~MASK_cr_tx_amp_offset_LSB));
+ tx_offset_reg_shift = 0; // 1e_173[5:0]
+ tx_offset_reg = RgAddr_dev1Eh_reg173h;
+ }
+
+ /* calibrate */
+ //tx_offset_index = TX_AMP_OFFSET_0mV;
+ tbl_idx = TX_OFFSET_0mV_idx;
+ tx_offset_index = EN753x_TX_OFS_TBL[tbl_idx];
+ set_gphy_reg_cl45(phyadd, DEVID_1E, tx_offset_reg, (reg_temp | (tx_offset_index << tx_offset_reg_shift))); // 1e_172, 1e_173
+
+ anacal_exe(phyadd_common);
+ if (all_ana_cal_status == 0)
+ {
+ all_ana_cal_status = ANACAL_ERROR;
+ }
+
+ ad_cal_comp_out_init = (get_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg17Ah) >> 8) & 0x1; // 1e_17a[8]:ad_cal_comp_out
+
+ if (ad_cal_comp_out_init == 1)
+ {
+ calibration_polarity = -1;
+ }
+ else
+ {
+ calibration_polarity = 1;
+ }
+
+ while (all_ana_cal_status < ANACAL_ERROR)
+ {
+ tbl_idx += calibration_polarity;
+ tx_offset_index = EN753x_TX_OFS_TBL[tbl_idx];
+
+ set_gphy_reg_cl45(phyadd, DEVID_1E, tx_offset_reg, (reg_temp | (tx_offset_index << tx_offset_reg_shift))); // 1e_172, 1e_173
+
+ anacal_exe(phyadd_common);
+
+ if (all_ana_cal_status == 0)
+ {
+ all_ana_cal_status = ANACAL_ERROR;
+ }
+ else if (((get_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg17Ah) >> 8) & 0x1) != ad_cal_comp_out_init)
+ {
+ all_ana_cal_status = ANACAL_FINISH;
+ }
+ else
+ {
+ if ((tx_offset_index == 0x3f) || (tx_offset_index == 0x1f))
+ {
+ all_ana_cal_status = ANACAL_SATURATION; // need to FT
+ }
+ }
+ }
+
+ if (all_ana_cal_status == ANACAL_ERROR)
+ {
+ tbl_idx = TX_OFFSET_0mV_idx;
+ tx_offset_index = EN753x_TX_OFS_TBL[tbl_idx];
+
+ set_gphy_reg_cl45(phyadd, DEVID_1E, tx_offset_reg, (reg_temp | (tx_offset_index << tx_offset_reg_shift))); // cr_tx_amp_offset_a/b/c/d, 1e_172, 1e_173
+ }
+ }
+
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Dh, Disable_all);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Eh, Disable_all);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Fh, Disable_all);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg180h, Disable_all);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg181h, Disable_all);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg182h, Disable_all);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg183h, Disable_all);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg184h, Disable_all);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Disable_all); // disable analog calibration circuit
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Disable_all); // disable Tx offset calibration circuit
+ set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Disable_all); // disable analog calibration circuit
+ set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Disable_all); // disable Tx offset calibration circuit
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg03Eh, Disable_all); // disable Tx VLD force mode
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DDh, Disable_all); // disable Tx offset/amplitude calibration circuit
+
+ return all_ana_cal_status;
+}
+
+uint8_t TX_AMP_Calibration(uint8_t phyadd, uint8_t phyadd_common)
+{
+ int8_t tx_amp_index = 0, calibration_polarity = 0;
+ uint8_t all_ana_cal_status = 1, tx_amp_reg_shift = 0;
+ uint8_t tx_amp_reg = 0, tx_amp_reg_100 = 0, tst_offset = 0, hbt_offset = 0, gbe_offset = 0, tbt_offset = 0;
+ uint16_t ad_cal_comp_out_init = 0, calibration_pair = 0, reg_temp = 0;
+
+ //phyadd_common = phyadd;
+
+ /* setting */
+ set_gphy_reg_cl22(phyadd, RgAddr_Reg1Fh, CL22_Page_Reg); // g0
+ set_gphy_reg_cl22(phyadd, RgAddr_Reg00h, AN_disable_force_1000M); // AN disable, force 1000M
+
+ set_gphy_reg_cl45(phyadd, DEVID_1F, RgAddr_dev1Fh_reg100h, BG_voltage_output); // BG voltage output
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg145h, Fix_mdi); // fix mdi
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg185h, Disable_tx_slew_control); // disable tx slew control
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0FBh, LDO_control); // ldo
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Cal_control_TX_AMP); // 1e_db[12]:rg_cal_ckinv, [8]:rg_ana_calen, [4]:rg_rext_calen
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Rg_txvos_calen_ENABLE); // 1e_dc[0]:rg_txvos_calen
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0E1h, Rg_cal_refsel_ENABLE); // 1e_e1[4]:rg_cal_refsel(0:1.2V) enable BG 1.2V to REXT PAD
+ set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Cal_control_TX_AMP); // 1e_db[12]:rg_cal_ckinv, [8]:rg_ana_calen, [4]:rg_rext_calen
+ set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Rg_txvos_calen_ENABLE); // 1e_dc[0]:rg_txvos_calen
+ set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg0E1h, Rg_cal_refsel_ENABLE); // 1e_e1[4]:rg_cal_refsel(0:1.2V) enable BG 1.2V to REXT PAD
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg096h, Bypass_tx_offset_cal); // 1e_96[15]:bypass_tx_offset_cal, Hw bypass, Fw cal
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg03Eh, Enable_Tx_VLD); // 1e_3e:enable Tx VLD
+
+ for (calibration_pair = ANACAL_PAIR_A; calibration_pair <= ANACAL_PAIR_D; calibration_pair++)
+ //for (calibration_pair = ANACAL_PAIR_A; calibration_pair <= ANACAL_PAIR_B; calibration_pair++) // debugging
+ {
+ all_ana_cal_status = 1;
+
+ /* calibrate */
+ tx_amp_index = TX_AMP_MIDDLE; // start with 0 dB
+ if (calibration_pair == ANACAL_PAIR_A)
+ {
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DDh, Rg_txg_calen_a_ENABLE); // 1e_dd[12]:rg_txg_calen_a amp calibration enable
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Dh, (Force_dasn_dac_in0_ENABLE | DAC_IN_2V)); // 1e_17d:dac_in0_a
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg181h, (Force_dasn_dac_in1_ENABLE | DAC_IN_2V)); // 1e_181:dac_in1_a
+
+ reg_temp = (get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg012h)&(~MASK_da_tx_i2mpb_a_gbe));
+ tx_amp_reg_shift = 10; // 1e_12[15:10]
+ tx_amp_reg = RgAddr_dev1Eh_reg012h;
+ tx_amp_reg_100 = 0x16;
+ }
+ else if (calibration_pair == ANACAL_PAIR_B)
+ {
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DDh, Rg_txg_calen_b_ENABLE); // 1e_dd[8]:rg_txg_calen_b amp calibration enable
+ //Serial.println(Rg_txg_calen_b_ENABLE, HEX);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Eh, (Force_dasn_dac_in0_ENABLE | DAC_IN_2V)); // 1e_17e:dac_in0_b
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg182h, (Force_dasn_dac_in1_ENABLE | DAC_IN_2V)); // 1e_182:dac_in1_b
+
+ reg_temp = (get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg017h)&(~MASK_da_tx_i2mpb_b_c_d_gbe));
+ tx_amp_reg_shift = 8; // 1e_17[13:8]
+ tx_amp_reg = RgAddr_dev1Eh_reg017h;
+ tx_amp_reg_100 = 0x18;
+ }
+ else if (calibration_pair == ANACAL_PAIR_C)
+ {
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DDh, Rg_txg_calen_c_ENABLE); // 1e_dd[4]:rg_txg_calen_c amp calibration enable
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Fh, (Force_dasn_dac_in0_ENABLE | DAC_IN_2V)); // 1e_17f:dac_in0_c
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg183h, (Force_dasn_dac_in1_ENABLE | DAC_IN_2V)); // 1e_183:dac_in1_c
+
+ reg_temp = (get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg019h)&(~MASK_da_tx_i2mpb_b_c_d_gbe));
+ tx_amp_reg_shift = 8; // 1e_19[13:8]
+ tx_amp_reg = RgAddr_dev1Eh_reg019h;
+ tx_amp_reg_100 = 0x20;
+ }
+ else //if(calibration_pair == ANACAL_PAIR_D)
+ {
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DDh, Rg_txg_calen_d_ENABLE); // 1e_dd[0]:rg_txg_calen_d amp calibration enable
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg180h, (Force_dasn_dac_in0_ENABLE | DAC_IN_2V)); // 1e_180:dac_in0_d
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg184h, (Force_dasn_dac_in1_ENABLE | DAC_IN_2V)); // 1e_184:dac_in1_d
+
+ reg_temp = (get_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg021h)&(~MASK_da_tx_i2mpb_b_c_d_gbe));
+ tx_amp_reg_shift = 8; // 1e_21[13:8]
+ tx_amp_reg = RgAddr_dev1Eh_reg021h;
+ tx_amp_reg_100 = 0x22;
+ }
+
+ /* calibrate */
+ tx_amp_index = TX_AMP_MIDDLE; // start with 0 dB
+
+ set_gphy_reg_cl45(phyadd, DEVID_1E, tx_amp_reg, (reg_temp | (tx_amp_index << tx_amp_reg_shift))); // 1e_12/17/19/21
+
+ anacal_exe(phyadd_common);
+ if (all_ana_cal_status == 0)
+ {
+ all_ana_cal_status = ANACAL_ERROR;
+ }
+
+
+ ad_cal_comp_out_init = (get_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg17Ah) >> 8) & 0x1; // 1e_17a[8]:ad_cal_comp_out
+ //Serial.println(ad_cal_comp_out_init, HEX);
+
+ if (ad_cal_comp_out_init == 1)
+ {
+ calibration_polarity = -1;
+ }
+ else
+ {
+ calibration_polarity = 1;
+ }
+ while (all_ana_cal_status < ANACAL_ERROR)
+ {
+ tx_amp_index += calibration_polarity;
+ //Serial.println(tx_amp_index, HEX);
+
+ set_gphy_reg_cl45(phyadd, DEVID_1E, tx_amp_reg, (reg_temp | (tx_amp_index << tx_amp_reg_shift)));
+
+ anacal_exe(phyadd_common);
+
+ if (all_ana_cal_status == 0)
+ {
+ all_ana_cal_status = ANACAL_ERROR;
+ }
+ else if (((get_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg17Ah) >> 8) & 0x1) != ad_cal_comp_out_init)
+ {
+ all_ana_cal_status = ANACAL_FINISH;
+ //Serial.print(" tx_amp_index: ");
+ //Serial.println(tx_amp_index, HEX);
+ //reg_temp = get_gphy_reg_cl45(phyadd, 0x1e, tx_amp_reg)&(~0xff00);
+ //set_gphy_reg_cl45(phyadd, 0x1e, tx_amp_reg, (reg_temp|((tx_amp_index + tst_offset)<<tx_amp_reg_shift))); // for gbe(DAC)
+ }
+ else
+ {
+ if ((tx_amp_index == 0x3f) || (tx_amp_index == 0x00))
+ {
+ all_ana_cal_status = ANACAL_SATURATION; // need to FT
+ tx_amp_index = TX_AMP_MIDDLE;
+ }
+ }
+ }
+
+ if (all_ana_cal_status == ANACAL_ERROR)
+ {
+ tx_amp_index = TX_AMP_MIDDLE;
+ }
+
+ // da_tx_i2mpb_a_gbe / b/c/d, only GBE for now
+ set_gphy_reg_cl45(phyadd, DEVID_1E, tx_amp_reg, ((tx_amp_index - TXAMP_offset) | ((tx_amp_index - TXAMP_offset) << tx_amp_reg_shift))); // // temp modify
+ set_gphy_reg_cl45(phyadd, DEVID_1E, tx_amp_reg_100, ((tx_amp_index - TXAMP_offset) | ((tx_amp_index + TX_i2mpb_hbt_ofs) << tx_amp_reg_shift)));
+ }
+
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Dh, Disable_all);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Eh, Disable_all);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg17Fh, Disable_all);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg180h, Disable_all);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg181h, Disable_all);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg182h, Disable_all);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg183h, Disable_all);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg184h, Disable_all);
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DBh, Disable_all); // disable analog calibration circuit
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DCh, Disable_all); // disable Tx offset calibration circuit
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg03Eh, Disable_all); // disable Tx VLD force mode
+ set_gphy_reg_cl45(phyadd, DEVID_1E, RgAddr_dev1Eh_reg0DDh, Disable_all); // disable Tx offset/amplitude calibration circuit
+
+ return all_ana_cal_status;
+}
+
+void set_gphy_reg_cl22(uint8_t phyad, uint8_t reg, uint16_t value)
+{
+ an8855_phy_write(phyad-g_smi_addr, reg, value);
+ /*
+ gsw_top_reg_REG_PHY_IAC REG_PHY_IAC_val;
+ gsw_top_reg_REG_PHY_IAD REG_PHY_IAD_val;
+
+ // Wait until done
+ do
+ {
+ REG_PHY_IAC_val.Raw = io_read32(RgAddr_gsw_top_reg_REG_PHY_IAC);
+ }
+ while(REG_PHY_IAC_val.Bits.csr_phy_acs_st);
+
+ // Set address
+ REG_PHY_IAC_val.Bits.csr_mdio_st = 1;
+ REG_PHY_IAC_val.Bits.csr_mdio_cmd = 1;
+ REG_PHY_IAC_val.Bits.csr_mdio_phy_addr = phyad;
+ REG_PHY_IAC_val.Bits.csr_mdio_reg_addr = reg;
+ REG_PHY_IAC_val.Bits.csr_mdio_wr_data = value;
+ REG_PHY_IAC_val.Bits.csr_phy_acs_st = 1;
+
+ io_write32(RgAddr_gsw_top_reg_REG_PHY_IAC, REG_PHY_IAC_val.Raw);
+ */
+}
+
+UINT16 get_gphy_reg_cl45(uint8_t prtid, uint8_t devid, uint16_t reg)
+{
+ UINT32 rdata = 0;
+
+ an8855_phy_read_cl45(prtid-g_smi_addr, devid, reg, &rdata);
+ return ((UINT16)rdata);
+ /*
+ gsw_top_reg_REG_PHY_IAC REG_PHY_IAC_val;
+ gsw_top_reg_REG_PHY_IAD REG_PHY_IAD_val;
+
+ // Wait until done
+ do
+ {
+ REG_PHY_IAC_val.Raw = io_read32(RgAddr_gsw_top_reg_REG_PHY_IAC);
+ }
+ while(REG_PHY_IAC_val.Bits.csr_phy_acs_st);
+
+ // Set address
+ REG_PHY_IAC_val.Bits.csr_mdio_st = 0;
+ REG_PHY_IAC_val.Bits.csr_mdio_cmd = 0;
+ REG_PHY_IAC_val.Bits.csr_mdio_phy_addr = prtid;
+ REG_PHY_IAC_val.Bits.csr_mdio_reg_addr = devid;
+ REG_PHY_IAC_val.Bits.csr_mdio_wr_data = reg;
+ REG_PHY_IAC_val.Bits.csr_phy_acs_st = 1;
+
+ io_write32(RgAddr_gsw_top_reg_REG_PHY_IAC, REG_PHY_IAC_val.Raw);
+
+ // Wait until done
+ do
+ {
+ REG_PHY_IAC_val.Raw = io_read32(RgAddr_gsw_top_reg_REG_PHY_IAC);
+ }
+ while(REG_PHY_IAC_val.Bits.csr_phy_acs_st);
+
+ // Read value
+ REG_PHY_IAC_val.Bits.csr_mdio_st = 0;
+ REG_PHY_IAC_val.Bits.csr_mdio_cmd = 3;
+ REG_PHY_IAC_val.Bits.csr_mdio_phy_addr = prtid;
+ REG_PHY_IAC_val.Bits.csr_mdio_reg_addr = devid;
+ REG_PHY_IAC_val.Bits.csr_mdio_wr_data = 0;
+ REG_PHY_IAC_val.Bits.csr_phy_acs_st = 1;
+ io_write32(RgAddr_gsw_top_reg_REG_PHY_IAC, REG_PHY_IAC_val.Raw);
+
+ // Wait until done
+ do
+ {
+ REG_PHY_IAC_val.Raw = io_read32(RgAddr_gsw_top_reg_REG_PHY_IAC);
+ }
+ while(REG_PHY_IAC_val.Bits.csr_phy_acs_st);
+
+ REG_PHY_IAD_val.Raw = io_read32(RgAddr_gsw_top_reg_REG_PHY_IAD);
+
+ return REG_PHY_IAD_val.Raw;
+ */
+}
+
+void set_gphy_reg_cl45(uint8_t prtid, uint8_t devid, uint16_t reg, uint16_t value)
+{
+ an8855_phy_write_cl45(prtid-g_smi_addr, devid, reg, value);
+ /*
+ gsw_top_reg_REG_PHY_IAC REG_PHY_IAC_val;
+
+ // Wait until done
+ do
+ {
+ REG_PHY_IAC_val.Raw = io_read32(RgAddr_gsw_top_reg_REG_PHY_IAC);
+ }
+ while(REG_PHY_IAC_val.Bits.csr_phy_acs_st);
+
+ // Set address
+ REG_PHY_IAC_val.Bits.csr_mdio_st = 0;
+ REG_PHY_IAC_val.Bits.csr_mdio_cmd = 0;
+ REG_PHY_IAC_val.Bits.csr_mdio_phy_addr = prtid;
+ REG_PHY_IAC_val.Bits.csr_mdio_reg_addr = devid;
+ REG_PHY_IAC_val.Bits.csr_mdio_wr_data = reg;
+ REG_PHY_IAC_val.Bits.csr_phy_acs_st = 1;
+
+ io_write32(RgAddr_gsw_top_reg_REG_PHY_IAC, REG_PHY_IAC_val.Raw);
+
+ // Wait until done
+ do
+ {
+ REG_PHY_IAC_val.Raw = io_read32(RgAddr_gsw_top_reg_REG_PHY_IAC);
+ }
+ while(REG_PHY_IAC_val.Bits.csr_phy_acs_st);
+
+ // Write value
+ REG_PHY_IAC_val.Bits.csr_mdio_st = 0;
+ REG_PHY_IAC_val.Bits.csr_mdio_cmd = 1;
+ REG_PHY_IAC_val.Bits.csr_mdio_phy_addr = prtid;
+ REG_PHY_IAC_val.Bits.csr_mdio_reg_addr = devid;
+ REG_PHY_IAC_val.Bits.csr_mdio_wr_data = value;
+ REG_PHY_IAC_val.Bits.csr_phy_acs_st = 1;
+
+ io_write32(RgAddr_gsw_top_reg_REG_PHY_IAC, REG_PHY_IAC_val.Raw);
+ */
+}
+
+void anacal_exe(uint8_t phyadd_common)
+{
+ set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg17Ch, 1);// da_calin_flag pull high
+ an8855_udelay(1000);
+ set_gphy_reg_cl45(phyadd_common, DEVID_1E, RgAddr_dev1Eh_reg17Ch, 0);// da_calin_flag pull low
+}
+
diff --git a/feed/app/switch/src/an8855_sdk/core/an8855_reg.h b/feed/app/switch/src/an8855_sdk/core/an8855_reg.h
index 3459cef..b444697 100644
--- a/feed/app/switch/src/an8855_sdk/core/an8855_reg.h
+++ b/feed/app/switch/src/an8855_sdk/core/an8855_reg.h
@@ -1,191 +1,191 @@
- /* FILE NAME: an8855_reg.h
- * PURPOSE:
- * It provides AN8855 register definition.
- * NOTES:
- *
- */
-
-#ifndef AN8855_REG_H
-#define AN8855_REG_H
-
-#define PORT_CTRL_BASE 0x10208000
-#define PORT_CTRL_PORT_OFFSET 0x200
-#define PORT_CTRL_REG(p, r) (PORT_CTRL_BASE + (p) * PORT_CTRL_PORT_OFFSET + (r))
-#define PCR(p) PORT_CTRL_REG(p, 0x04)
-
-#define PORT_MAC_CTRL_BASE 0x10210000
-#define PORT_MAC_CTRL_PORT_OFFSET 0x200
-#define PORT_MAC_CTRL_REG(p, r) (PORT_MAC_CTRL_BASE + (p) * PORT_MAC_CTRL_PORT_OFFSET + (r))
-#define PMCR(p) PORT_MAC_CTRL_REG(p, 0x00)
-
-/* Port debug count register */
-#define DBG_CNT_BASE 0x3018
-#define DBG_CNT_PORT_BASE 0x100
-#define DBG_CNT(p) (DBG_CNT_BASE + (p) * DBG_CNT_PORT_BASE)
-#define DIS_CLR (1 << 31)
-
-#define GMACCR (PORT_MAC_CTRL_BASE + 0x30e0)
-#define MTCC_LMT_S 8
-#define MAX_RX_JUMBO_S 4
-
-/* Values of MAX_RX_PKT_LEN */
-#define RX_PKT_LEN_1518 0
-#define RX_PKT_LEN_1536 1
-#define RX_PKT_LEN_1522 2
-#define RX_PKT_LEN_MAX_JUMBO 3
-
-/* Fields of PMCR */
-#define FORCE_MODE (1 << 31)
-#define IPG_CFG_S 20
-#define IPG_CFG_M 0x300000
-#define EXT_PHY (1 << 19)
-#define MAC_MODE (1 << 18)
-#define MAC_TX_EN (1 << 16)
-#define MAC_RX_EN (1 << 15)
-#define MAC_PRE (1 << 14)
-#define BKOFF_EN (1 << 12)
-#define BACKPR_EN (1 << 11)
-#define FORCE_EEE1G (1 << 7)
-#define FORCE_EEE100 (1 << 6)
-#define FORCE_RX_FC (1 << 5)
-#define FORCE_TX_FC (1 << 4)
-#define FORCE_SPD_S 28
-#define FORCE_SPD_M 0x70000000
-#define FORCE_DPX (1 << 25)
-#define FORCE_LINK (1 << 24)
-
-/* Fields of PMSR */
-#define EEE1G_STS (1 << 7)
-#define EEE100_STS (1 << 6)
-#define RX_FC_STS (1 << 5)
-#define TX_FC_STS (1 << 4)
-#define MAC_SPD_STS_S 28
-#define MAC_SPD_STS_M 0x70000000
-#define MAC_DPX_STS (1 << 25)
-#define MAC_LNK_STS (1 << 24)
-
-/* Values of MAC_SPD_STS */
-#define MAC_SPD_10 0
-#define MAC_SPD_100 1
-#define MAC_SPD_1000 2
-#define MAC_SPD_2500 3
-
-/* Values of IPG_CFG */
-#define IPG_96BIT 0
-#define IPG_96BIT_WITH_SHORT_IPG 1
-#define IPG_64BIT 2
-
-#define SGMII_REG_BASE 0x5000
-#define SGMII_REG_PORT_BASE 0x1000
-#define SGMII_REG(p, r) (SGMII_REG_BASE + (p) * SGMII_REG_PORT_BASE + (r))
-#define PCS_CONTROL_1(p) SGMII_REG(p, 0x00)
-#define SGMII_MODE(p) SGMII_REG(p, 0x20)
-#define QPHY_PWR_STATE_CTRL(p) SGMII_REG(p, 0xe8)
-#define PHYA_CTRL_SIGNAL3(p) SGMII_REG(p, 0x128)
-
-/* Fields of PCS_CONTROL_1 */
-#define SGMII_LINK_STATUS (1 << 18)
-#define SGMII_AN_ENABLE (1 << 12)
-#define SGMII_AN_RESTART (1 << 9)
-
-/* Fields of SGMII_MODE */
-#define SGMII_REMOTE_FAULT_DIS (1 << 8)
-#define SGMII_IF_MODE_FORCE_DUPLEX (1 << 4)
-#define SGMII_IF_MODE_FORCE_SPEED_S 0x2
-#define SGMII_IF_MODE_FORCE_SPEED_M 0x0c
-#define SGMII_IF_MODE_ADVERT_AN (1 << 1)
-
-/* Values of SGMII_IF_MODE_FORCE_SPEED */
-#define SGMII_IF_MODE_FORCE_SPEED_10 0
-#define SGMII_IF_MODE_FORCE_SPEED_100 1
-#define SGMII_IF_MODE_FORCE_SPEED_1000 2
-
-/* Fields of QPHY_PWR_STATE_CTRL */
-#define PHYA_PWD (1 << 4)
-
-/* Fields of PHYA_CTRL_SIGNAL3 */
-#define RG_TPHY_SPEED_S 2
-#define RG_TPHY_SPEED_M 0x0c
-
-/* Values of RG_TPHY_SPEED */
-#define RG_TPHY_SPEED_1000 0
-#define RG_TPHY_SPEED_2500 1
-
-#define SYS_CTRL 0x7000
-#define SW_PHY_RST (1 << 2)
-#define SW_SYS_RST (1 << 1)
-#define SW_REG_RST (1 << 0)
-
-#define PHY_IAC (0x1000e000)
-#define IAC_MAX_BUSY_TIME (1000)
-
-#define CLKGEN_CTRL 0x7500
-#define CLK_SKEW_OUT_S 8
-#define CLK_SKEW_OUT_M 0x300
-#define CLK_SKEW_IN_S 6
-#define CLK_SKEW_IN_M 0xc0
-#define RXCLK_NO_DELAY (1 << 5)
-#define TXCLK_NO_REVERSE (1 << 4)
-#define GP_MODE_S 1
-#define GP_MODE_M 0x06
-#define GP_CLK_EN (1 << 0)
-
-/* Values of GP_MODE */
-#define GP_MODE_RGMII 0
-#define GP_MODE_MII 1
-#define GP_MODE_REV_MII 2
-
-/* Values of CLK_SKEW_IN */
-#define CLK_SKEW_IN_NO_CHANGE 0
-#define CLK_SKEW_IN_DELAY_100PPS 1
-#define CLK_SKEW_IN_DELAY_200PPS 2
-#define CLK_SKEW_IN_REVERSE 3
-
-/* Values of CLK_SKEW_OUT */
-#define CLK_SKEW_OUT_NO_CHANGE 0
-#define CLK_SKEW_OUT_DELAY_100PPS 1
-#define CLK_SKEW_OUT_DELAY_200PPS 2
-#define CLK_SKEW_OUT_REVERSE 3
-
-#define HWSTRAP 0x7800
-#define XTAL_FSEL_S 7
-#define XTAL_FSEL_M (1 << 7)
-
-#define XTAL_40MHZ 0
-#define XTAL_25MHZ 1
-
-#define PLLGP_EN 0x7820
-#define EN_COREPLL (1 << 2)
-#define SW_CLKSW (1 << 1)
-#define SW_PLLGP (1 << 0)
-
-#define PLLGP_CR0 0x78a8
-#define RG_COREPLL_EN (1 << 22)
-#define RG_COREPLL_POSDIV_S 23
-#define RG_COREPLL_POSDIV_M 0x3800000
-#define RG_COREPLL_SDM_PCW_S 1
-#define RG_COREPLL_SDM_PCW_M 0x3ffffe
-#define RG_COREPLL_SDM_PCW_CHG (1 << 0)
-
-#define MHWSTRAP 0x7804
-#define TOP_SIG_SR 0x780c
-#define PAD_DUAL_SGMII_EN (1 << 1)
-
-/* RGMII and SGMII PLL clock */
-#define ANA_PLLGP_CR2 0x78b0
-#define ANA_PLLGP_CR5 0x78bc
-
-/* Efuse Register Define */
-#define GBE_EFUSE 0x7bc8
-#define GBE_SEL_EFUSE_EN (1 << 0)
-
-/* GPIO_PAD_0 */
-#define GPIO_MODE0 0x7c0c
-#define GPIO_MODE0_S 0
-#define GPIO_MODE0_M 0xf
-#define GPIO_0_INTERRUPT_MODE 0x1
-
-#define SMT0_IOLB 0x7f04
-#define SMT_IOLB_5_SMI_MDC_EN (1 << 5)
-
-#endif /* End of AN8855_REG_H */
+ /* FILE NAME: an8855_reg.h
+ * PURPOSE:
+ * It provides AN8855 register definition.
+ * NOTES:
+ *
+ */
+
+#ifndef AN8855_REG_H
+#define AN8855_REG_H
+
+#define PORT_CTRL_BASE 0x10208000
+#define PORT_CTRL_PORT_OFFSET 0x200
+#define PORT_CTRL_REG(p, r) (PORT_CTRL_BASE + (p) * PORT_CTRL_PORT_OFFSET + (r))
+#define PCR(p) PORT_CTRL_REG(p, 0x04)
+
+#define PORT_MAC_CTRL_BASE 0x10210000
+#define PORT_MAC_CTRL_PORT_OFFSET 0x200
+#define PORT_MAC_CTRL_REG(p, r) (PORT_MAC_CTRL_BASE + (p) * PORT_MAC_CTRL_PORT_OFFSET + (r))
+#define PMCR(p) PORT_MAC_CTRL_REG(p, 0x00)
+
+/* Port debug count register */
+#define DBG_CNT_BASE 0x3018
+#define DBG_CNT_PORT_BASE 0x100
+#define DBG_CNT(p) (DBG_CNT_BASE + (p) * DBG_CNT_PORT_BASE)
+#define DIS_CLR (1 << 31)
+
+#define GMACCR (PORT_MAC_CTRL_BASE + 0x30e0)
+#define MTCC_LMT_S 8
+#define MAX_RX_JUMBO_S 4
+
+/* Values of MAX_RX_PKT_LEN */
+#define RX_PKT_LEN_1518 0
+#define RX_PKT_LEN_1536 1
+#define RX_PKT_LEN_1522 2
+#define RX_PKT_LEN_MAX_JUMBO 3
+
+/* Fields of PMCR */
+#define FORCE_MODE (1 << 31)
+#define IPG_CFG_S 20
+#define IPG_CFG_M 0x300000
+#define EXT_PHY (1 << 19)
+#define MAC_MODE (1 << 18)
+#define MAC_TX_EN (1 << 16)
+#define MAC_RX_EN (1 << 15)
+#define MAC_PRE (1 << 14)
+#define BKOFF_EN (1 << 12)
+#define BACKPR_EN (1 << 11)
+#define FORCE_EEE1G (1 << 7)
+#define FORCE_EEE100 (1 << 6)
+#define FORCE_RX_FC (1 << 5)
+#define FORCE_TX_FC (1 << 4)
+#define FORCE_SPD_S 28
+#define FORCE_SPD_M 0x70000000
+#define FORCE_DPX (1 << 25)
+#define FORCE_LINK (1 << 24)
+
+/* Fields of PMSR */
+#define EEE1G_STS (1 << 7)
+#define EEE100_STS (1 << 6)
+#define RX_FC_STS (1 << 5)
+#define TX_FC_STS (1 << 4)
+#define MAC_SPD_STS_S 28
+#define MAC_SPD_STS_M 0x70000000
+#define MAC_DPX_STS (1 << 25)
+#define MAC_LNK_STS (1 << 24)
+
+/* Values of MAC_SPD_STS */
+#define MAC_SPD_10 0
+#define MAC_SPD_100 1
+#define MAC_SPD_1000 2
+#define MAC_SPD_2500 3
+
+/* Values of IPG_CFG */
+#define IPG_96BIT 0
+#define IPG_96BIT_WITH_SHORT_IPG 1
+#define IPG_64BIT 2
+
+#define SGMII_REG_BASE 0x5000
+#define SGMII_REG_PORT_BASE 0x1000
+#define SGMII_REG(p, r) (SGMII_REG_BASE + (p) * SGMII_REG_PORT_BASE + (r))
+#define PCS_CONTROL_1(p) SGMII_REG(p, 0x00)
+#define SGMII_MODE(p) SGMII_REG(p, 0x20)
+#define QPHY_PWR_STATE_CTRL(p) SGMII_REG(p, 0xe8)
+#define PHYA_CTRL_SIGNAL3(p) SGMII_REG(p, 0x128)
+
+/* Fields of PCS_CONTROL_1 */
+#define SGMII_LINK_STATUS (1 << 18)
+#define SGMII_AN_ENABLE (1 << 12)
+#define SGMII_AN_RESTART (1 << 9)
+
+/* Fields of SGMII_MODE */
+#define SGMII_REMOTE_FAULT_DIS (1 << 8)
+#define SGMII_IF_MODE_FORCE_DUPLEX (1 << 4)
+#define SGMII_IF_MODE_FORCE_SPEED_S 0x2
+#define SGMII_IF_MODE_FORCE_SPEED_M 0x0c
+#define SGMII_IF_MODE_ADVERT_AN (1 << 1)
+
+/* Values of SGMII_IF_MODE_FORCE_SPEED */
+#define SGMII_IF_MODE_FORCE_SPEED_10 0
+#define SGMII_IF_MODE_FORCE_SPEED_100 1
+#define SGMII_IF_MODE_FORCE_SPEED_1000 2
+
+/* Fields of QPHY_PWR_STATE_CTRL */
+#define PHYA_PWD (1 << 4)
+
+/* Fields of PHYA_CTRL_SIGNAL3 */
+#define RG_TPHY_SPEED_S 2
+#define RG_TPHY_SPEED_M 0x0c
+
+/* Values of RG_TPHY_SPEED */
+#define RG_TPHY_SPEED_1000 0
+#define RG_TPHY_SPEED_2500 1
+
+#define SYS_CTRL 0x7000
+#define SW_PHY_RST (1 << 2)
+#define SW_SYS_RST (1 << 1)
+#define SW_REG_RST (1 << 0)
+
+#define PHY_IAC (0x1000e000)
+#define IAC_MAX_BUSY_TIME (1000)
+
+#define CLKGEN_CTRL 0x7500
+#define CLK_SKEW_OUT_S 8
+#define CLK_SKEW_OUT_M 0x300
+#define CLK_SKEW_IN_S 6
+#define CLK_SKEW_IN_M 0xc0
+#define RXCLK_NO_DELAY (1 << 5)
+#define TXCLK_NO_REVERSE (1 << 4)
+#define GP_MODE_S 1
+#define GP_MODE_M 0x06
+#define GP_CLK_EN (1 << 0)
+
+/* Values of GP_MODE */
+#define GP_MODE_RGMII 0
+#define GP_MODE_MII 1
+#define GP_MODE_REV_MII 2
+
+/* Values of CLK_SKEW_IN */
+#define CLK_SKEW_IN_NO_CHANGE 0
+#define CLK_SKEW_IN_DELAY_100PPS 1
+#define CLK_SKEW_IN_DELAY_200PPS 2
+#define CLK_SKEW_IN_REVERSE 3
+
+/* Values of CLK_SKEW_OUT */
+#define CLK_SKEW_OUT_NO_CHANGE 0
+#define CLK_SKEW_OUT_DELAY_100PPS 1
+#define CLK_SKEW_OUT_DELAY_200PPS 2
+#define CLK_SKEW_OUT_REVERSE 3
+
+#define HWSTRAP 0x7800
+#define XTAL_FSEL_S 7
+#define XTAL_FSEL_M (1 << 7)
+
+#define XTAL_40MHZ 0
+#define XTAL_25MHZ 1
+
+#define PLLGP_EN 0x7820
+#define EN_COREPLL (1 << 2)
+#define SW_CLKSW (1 << 1)
+#define SW_PLLGP (1 << 0)
+
+#define PLLGP_CR0 0x78a8
+#define RG_COREPLL_EN (1 << 22)
+#define RG_COREPLL_POSDIV_S 23
+#define RG_COREPLL_POSDIV_M 0x3800000
+#define RG_COREPLL_SDM_PCW_S 1
+#define RG_COREPLL_SDM_PCW_M 0x3ffffe
+#define RG_COREPLL_SDM_PCW_CHG (1 << 0)
+
+#define MHWSTRAP 0x7804
+#define TOP_SIG_SR 0x780c
+#define PAD_DUAL_SGMII_EN (1 << 1)
+
+/* RGMII and SGMII PLL clock */
+#define ANA_PLLGP_CR2 0x78b0
+#define ANA_PLLGP_CR5 0x78bc
+
+/* Efuse Register Define */
+#define GBE_EFUSE 0x7bc8
+#define GBE_SEL_EFUSE_EN (1 << 0)
+
+/* GPIO_PAD_0 */
+#define GPIO_MODE0 0x7c0c
+#define GPIO_MODE0_S 0
+#define GPIO_MODE0_M 0xf
+#define GPIO_0_INTERRUPT_MODE 0x1
+
+#define SMT0_IOLB 0x7f04
+#define SMT_IOLB_5_SMI_MDC_EN (1 << 5)
+
+#endif /* End of AN8855_REG_H */
diff --git a/feed/app/switch/src/switch_753x.c b/feed/app/switch/src/switch_753x.c
index 9218e57..03e9778 100644
--- a/feed/app/switch/src/switch_753x.c
+++ b/feed/app/switch/src/switch_753x.c
@@ -15,11 +15,12 @@
#include "switch_fun.h"
#include "switch_fun_an8855.h"
-#define SWITCH_APP_VERSION "1.0.1"
+#define SWITCH_APP_VERSION "1.0.7"
struct mt753x_attr *attres;
int chip_name;
bool nl_init_flag;
+bool air_skip_check_flag;
struct switch_func_s *p_switch_func;
static void usage(char *cmd)
@@ -480,6 +481,12 @@
FILE *fp = NULL;
char buff[255];
+ /*judge an8855, must be placed before reg_read*/
+ if (air_skip_check_flag) {
+ temp = 0x8855;
+ return temp;
+ }
+
/*judge jaguar embedded switch */
fp = fopen("/proc/device-tree/compatible", "r");
if (fp != NULL) {
@@ -504,11 +511,6 @@
if (temp == 0x7531)
return temp;
- /*judge an8855 */
- reg_read(0x10005000, &temp);
- if (temp == 0x8855)
- return temp;
-
return -1;
}
@@ -639,6 +641,8 @@
int main(int argc, char *argv[])
{
int err = -EINVAL;
+ FILE *fp = NULL;
+ char buff[255];
attres = (struct mt753x_attr *)malloc(sizeof(struct mt753x_attr));
if (attres == NULL) {
@@ -649,28 +653,35 @@
attres->port_num = -1;
attres->phy_dev = -1;
nl_init_flag = true;
+ air_skip_check_flag = false;
- /* dsa netlink family might not be enabled. Try gsw netlink family. */
- err = mt753x_netlink_init(MT753X_DSA_GENL_NAME);
- if (!err)
- chip_name = get_chip_name();
+ fp = fopen("/proc/air_sw/device", "r");
+ if (fp != NULL) {
+ if (fgets(buff, 255, (FILE *) fp) && strstr(buff, "an8855"))
+ air_skip_check_flag = true;
- if (err < 0) {
- err = mt753x_netlink_init(MT753X_GENL_NAME);
- if (!err)
- chip_name = get_chip_name();
- }
+ if ((fclose(fp) == 0) && air_skip_check_flag) {
+ err = mt753x_netlink_init(AN8855_DSA_GENL_NAME);
+ if (!err)
+ chip_name = get_chip_name();
- if (err < 0) {
- err = mt753x_netlink_init(AN8855_DSA_GENL_NAME);
+ if (err < 0) {
+ err = mt753x_netlink_init(AN8855_GENL_NAME);
+ if (!err)
+ chip_name = get_chip_name();
+ }
+ }
+ } else {
+ /* dsa netlink family might not be enabled. Try gsw netlink family. */
+ err = mt753x_netlink_init(MT753X_DSA_GENL_NAME);
if (!err)
chip_name = get_chip_name();
- }
- if (err < 0) {
- err = mt753x_netlink_init(AN8855_GENL_NAME);
- if (!err)
- chip_name = get_chip_name();
+ if (err < 0) {
+ err = mt753x_netlink_init(MT753X_GENL_NAME);
+ if (!err)
+ chip_name = get_chip_name();
+ }
}
if (err < 0) {
diff --git a/feed/app/switch/src/switch_extend.h b/feed/app/switch/src/switch_extend.h
index c352767..a35316e 100644
--- a/feed/app/switch/src/switch_extend.h
+++ b/feed/app/switch/src/switch_extend.h
@@ -154,7 +154,7 @@
#define REG_VAWD2_ADDR (0x0098)
#define REG_VLAN_ID_BASE (0x0100)
-#define REG_CPGC_ADDR (0xB0)
+#define REG_CPGC_ADDR (0xB0)
#define REG_CPCG_COL_EN_OFFT (0)
#define REG_CPCG_COL_EN_RELMASK (0x00000001)
#define REG_CPCG_COL_EN_MASK (REG_CPCG_COL_EN_RELMASK << REG_CPCG_COL_EN_OFFT)
@@ -336,7 +336,7 @@
" 1: Blocking/Listening/Discarding\n" \
" 2: Learning\n" \
" 3: Forwarding\n"
-#define HELP_COLLISION_POOL_EN "collision-pool enable [enable 0|1] \n"
-#define HELP_EEE_EN "eee [enable|disable] ([port|portMap]) \n"
+#define HELP_COLLISION_POOL_EN "collision-pool enable [enable 0|1]\n"
+#define HELP_EEE_EN "eee [enable|disable] ([port|portMap])\n"
//#endif //SQA_VERIFY
diff --git a/feed/app/switch/src/switch_fun.c b/feed/app/switch/src/switch_fun.c
index 4745cf5..4239e1a 100644
--- a/feed/app/switch/src/switch_fun.c
+++ b/feed/app/switch/src/switch_fun.c
@@ -1,6 +1,6 @@
/*
-* switch_fun.c: switch function sets
-*/
+ * switch_fun.c: switch function sets
+ */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -202,7 +202,7 @@
int ret;
if (port_num > 31) {
- printf("Invalid Port or PHY addr \n");
+ printf("Invalid Port or PHY addr\n");
return -1;
}
@@ -225,7 +225,7 @@
int ret;
if (port_num > 31) {
- printf("Invalid Port or PHY addr \n");
+ printf("Invalid Port or PHY addr\n");
return -1;
}
@@ -249,7 +249,7 @@
int ret;
if (port_num > 31) {
- printf("Invalid Port or PHY addr \n");
+ printf("Invalid Port or PHY addr\n");
return -1;
}
@@ -273,7 +273,7 @@
int ret;
if (port_num > 31) {
- printf("Invalid Port or PHY addr \n");
+ printf("Invalid Port or PHY addr\n");
return -1;
}
@@ -335,8 +335,8 @@
}
printf("mii_mgr_cl45:");
- printf("Read: port#=%d, device=0x%x, reg=0x%x, value=0x%x\n", port_num,
- 0x1E, MT7530_T10_TEST_CONTROL, value);
+ printf("Read: port#=%d, device=0x%x, reg=0x%x, value=0x%x\n",
+ port_num, 0x1E, MT7530_T10_TEST_CONTROL, value);
if (!strncmp(argv[3], "auto", 5)) {
value &= (~(0x3 << 3));
@@ -349,8 +349,8 @@
printf("invaild parameter\n");
return;
}
- printf("Write: port#=%d, device=0x%x, reg=0x%x. value=0x%x\n", port_num,
- 0x1E, MT7530_T10_TEST_CONTROL, value);
+ printf("Write: port#=%d, device=0x%x, reg=0x%x. value=0x%x\n",
+ port_num, 0x1E, MT7530_T10_TEST_CONTROL, value);
if (nl_init_flag == true)
ret =
@@ -408,16 +408,15 @@
goto error;
printf("port = %x, ch_addr = %x, node_addr=%x, data_addr=%x\n",
- port_num, ch_addr, node_addr, data_addr);
+ port_num, ch_addr, node_addr, data_addr);
tr_reg_control =
(1 << 15) | (1 << 13) | (ch_addr << 11) | (node_addr << 7) |
(data_addr << 1);
mii_mgr_write(port_num, 16, tr_reg_control); // r16 = tr_reg_control
mii_mgr_read(port_num, 17, &val_l);
mii_mgr_read(port_num, 18, &val_h);
- printf
- ("switch trreg read tr_reg_control=%x, value_H=%x, value_L=%x\n",
- tr_reg_control, val_h, val_l);
+ printf("switch trreg read tr_reg_control=%x, value_H=%x, value_L=%x\n",
+ tr_reg_control, val_h, val_l);
} else if (argv[2][0] == 'w') {
if (argc != 9)
return -1;
@@ -456,16 +455,15 @@
goto error;
printf("port = %x, ch_addr = %x, node_addr=%x, data_addr=%x\n",
- port_num, ch_addr, node_addr, data_addr);
+ port_num, ch_addr, node_addr, data_addr);
tr_reg_control =
(1 << 15) | (0 << 13) | (ch_addr << 11) | (node_addr << 7) |
(data_addr << 1);
mii_mgr_write(port_num, 17, val_l);
mii_mgr_write(port_num, 18, val_h);
mii_mgr_write(port_num, 16, tr_reg_control); // r16 = tr_reg_control
- printf
- ("switch trreg Write tr_reg_control=%x, value_H=%x, value_L=%x\n",
- tr_reg_control, val_h, val_l);
+ printf("switch trreg Write tr_reg_control=%x, value_H=%x, value_L=%x\n",
+ tr_reg_control, val_h, val_l);
} else
return -1;
@@ -497,9 +495,8 @@
reg = REG_VTCR_ADDR;
while (1) { // wait until not busy
reg_read(reg, &value);
- if ((value & REG_VTCR_BUSY_MASK) == 0) {
+ if ((value & REG_VTCR_BUSY_MASK) == 0)
break;
- }
}
reg_write(REG_VAWD1_ADDR, vawd1);
printf("write reg: %x, value: %x\n", REG_VAWD1_ADDR, vawd1);
@@ -521,11 +518,17 @@
{
unsigned int vawd1 = 0, vawd2 = 0;
unsigned char tbl_idx = 0;
+ unsigned int max_index = 0;
char *endptr;
+ if (chip_name == 0x7531 || chip_name == 0x7988)
+ max_index = 256;
+ else
+ max_index = 64;
+
errno = 0;
tbl_idx = strtoul(argv[3], &endptr, 10);
- if (errno != 0 || *endptr != '\0') {
+ if (errno != 0 || *endptr != '\0' || tbl_idx >= max_index) {
printf("Error: wrong ACL rule table index\n");
return;
}
@@ -589,11 +592,17 @@
{
unsigned int vawd1 = 0, vawd2 = 0;
unsigned char tbl_idx = 0;
+ unsigned int max_index = 0;
char *endptr;
+ if (chip_name == 0x7531 || chip_name == 0x7988)
+ max_index = 128;
+ else
+ max_index = 32;
+
errno = 0;
tbl_idx = strtoul(argv[3], &endptr, 10);
- if (errno != 0 || *endptr != '\0') {
+ if (errno != 0 || *endptr != '\0' || tbl_idx >= max_index) {
printf("Error: wrong ACL mask table index\n");
return;
}
@@ -628,7 +637,8 @@
printf("Rule_control_tbl_idx:%d\n", tbl_idx);
- if (tbl_idx >= max_index) { /* Check the input parameters is right or not. */
+ if (tbl_idx >= max_index) {
+ /* Check the input parameters is right or not. */
printf(HELP_ACL_RULE_TBL_ADD);
return;
}
@@ -636,9 +646,8 @@
while (1) { // wait until not busy
reg_read(reg, &value);
- if ((value & REG_VTCR_BUSY_MASK) == 0) {
+ if ((value & REG_VTCR_BUSY_MASK) == 0)
break;
- }
}
reg_write(REG_VAWD1_ADDR, vawd1);
printf("write reg: %x, value: %x\n", REG_VAWD1_ADDR, vawd1);
@@ -651,9 +660,8 @@
while (1) { // wait until not busy
reg_read(reg, &value);
- if ((value & REG_VTCR_BUSY_MASK) == 0) {
+ if ((value & REG_VTCR_BUSY_MASK) == 0)
break;
- }
}
}
@@ -661,11 +669,17 @@
{
unsigned int vawd1 = 0, vawd2 = 0;
unsigned char tbl_idx = 0;
+ unsigned int max_index = 0;
char *endptr;
+ if (chip_name == 0x7531 || chip_name == 0x7988)
+ max_index = 128;
+ else
+ max_index = 32;
+
errno = 0;
tbl_idx = strtoul(argv[3], &endptr, 10);
- if (errno != 0 || *endptr != '\0') {
+ if (errno != 0 || *endptr != '\0' || tbl_idx >= max_index) {
printf("Error: wrong ACL rule control table index\n");
return;
}
@@ -727,11 +741,12 @@
{
unsigned int vawd1 = 0, vawd2 = 0;
unsigned char tbl_idx = 0;
+ unsigned int max_index = 32;
char *endptr;
errno = 0;
tbl_idx = strtoul(argv[3], &endptr, 10);
- if (errno != 0 || *endptr != '\0') {
+ if (errno != 0 || *endptr != '\0' || tbl_idx >= max_index) {
printf("Error: wrong ACL rate control table index\n");
return;
}
@@ -802,9 +817,8 @@
if (len2 == 12) {
if (!argv[4] || strlen(argv[4]) != len2) {
- printf
- ("The [%s] format error, should be of length %d\n",
- argv[4], len2);
+ printf("The [%s] format error, should be of length %d\n",
+ argv[4], len2);
return -1;
}
}
@@ -816,8 +830,7 @@
for (i = 0; i < 7; i++) {
if (argv[5][i] != '0' && argv[5][i] != '1') {
- printf
- ("portmap format error, should be of combination of 0 or 1\n");
+ printf("portmap format error, should be of combination of 0 or 1\n");
return -1;
}
*port += (argv[5][i] - '0') * (1 << i);
@@ -890,7 +903,6 @@
error:
printf("Error: string converting\n");
- return;
}
void acl_dip_meter(int argc, char *argv[])
@@ -1214,8 +1226,7 @@
table_size = 0x40;
reg_write(REG_ATC_ADDR, 0x811c); //dip search command
}
- printf
- ("hash port(0:6) rsp_cnt flag timer dip-address ATRD\n");
+ printf("hash port(0:6) rsp_cnt flag timer dip-address ATRD\n");
for (i = 0; i < table_size; i++) {
while (1) {
reg_read(REG_ATC_ADDR, &value);
@@ -1292,10 +1303,6 @@
reg_write(REG_ATA1_ADDR, value);
printf("REG_ATA1_ADDR is 0x%x\n\r", value);
-#if 0
- reg_write(REG_ATA2_ADDR, value);
- printf("REG_ATA2_ADDR is 0x%x\n\r", value);
-#endif
if (!argv[4] || strlen(argv[4]) != 8) {
printf("portmap format error, should be of length 7\n");
return;
@@ -1303,8 +1310,7 @@
j = 0;
for (i = 0; i < 7; i++) {
if (argv[4][i] != '0' && argv[4][i] != '1') {
- printf
- ("portmap format error, should be of combination of 0 or 1\n");
+ printf("portmap format error, should be of combination of 0 or 1\n");
return;
}
j += (argv[4][i] - '0') * (1 << i);
@@ -1368,7 +1374,6 @@
void dip_clear(int argc, char *argv[])
{
-
unsigned int value = 0;
reg_write(REG_ATC_ADDR, 0x8102); //clear all dip
@@ -1481,8 +1486,7 @@
j = 0;
for (i = 0; i < 7; i++) {
if (argv[5][i] != '0' && argv[5][i] != '1') {
- printf
- ("portmap format error, should be of combination of 0 or 1\n");
+ printf("portmap format error, should be of combination of 0 or 1\n");
return;
}
j += (argv[5][i] - '0') * (1 << i);
@@ -1571,8 +1575,7 @@
table_end = 0x3F;
reg_write(REG_ATC_ADDR, 0x800C);
}
- printf
- ("hash port(0:6) fid vid age(s) mac-address filter my_mac\n");
+ printf("hash port(0:6) fid vid age(s) mac-address filter my_mac\n");
for (i = 0; i < table_size; i++) {
while (1) {
reg_read(REG_ATC_ADDR, &value);
@@ -1623,8 +1626,7 @@
}
break;
} else if ((value & 0x4000) && (((value >> 15) & 0x1) == 0) && (((value >> 16) & 0xfff) == table_end)) { //at_table_end
- printf("found the last entry %d (not ready)\n",
- i);
+ printf("found the last entry %d (not ready)\n", i);
return;
} else
usleep(5);
@@ -1702,8 +1704,7 @@
j = 0;
for (i = 0; i < 7; i++) {
if (argv[3][i] != '0' && argv[3][i] != '1') {
- printf
- ("portmap format error, should be of combination of 0 or 1\n");
+ printf("portmap format error, should be of combination of 0 or 1\n");
return;
}
j += (argv[3][i] - '0') * (1 << i);
@@ -2154,8 +2155,7 @@
}
if (eg_tag)
- printf
- (" vid fid portmap s-tag\teg_tag(0:untagged 2:tagged)\n");
+ printf(" vid fid portmap s-tag\teg_tag(0:untagged 2:tagged)\n");
else
printf(" vid fid portmap s-tag\n");
@@ -2305,8 +2305,7 @@
vlan_mem = 0;
for (i = 0; i < 8; i++) {
if (argv[5][i] != '0' && argv[5][i] != '1') {
- printf
- ("portmap format error, should be of combination of 0 or 1\n");
+ printf("portmap format error, should be of combination of 0 or 1\n");
return;
}
vlan_mem += (argv[5][i] - '0') * (1 << i);
@@ -2316,8 +2315,7 @@
if (argc > 6) {
stag = strtoul(argv[6], NULL, 16);
if (stag < 0 || 0xfff < stag) {
- printf
- ("wrong stag id range, should be within 0~4095\n");
+ printf("wrong stag id range, should be within 0~4095\n");
return;
}
//printf("STAG is 0x%x\n", stag);
@@ -2338,15 +2336,13 @@
if (argc > 8 && !eg_con) {
if (strlen(argv[8]) != 8) {
- printf
- ("egtag portmap format error, should be of length 7\n");
+ printf("egtag portmap format error, should be of length 7\n");
return;
}
for (i = 0; i < 8; i++) {
if (argv[8][i] < '0' || argv[8][i] > '3') {
- printf
- ("egtag portmap format error, should be of combination of 0 or 3\n");
+ printf("egtag portmap format error, should be of combination of 0 or 3\n");
return;
}
//eg_tag += (argv[8][i] - '0') * (1 << i * 2);
@@ -2592,13 +2588,13 @@
/*Software Register Reset and Software System Reset */
reg_write(0x7000, 0x3);
reg_read(0x7000, &value);
- printf("SYS_CTRL(0x7000) register value =0x%x \n", value);
+ printf("SYS_CTRL(0x7000) register value =0x%x\n", value);
if (chip_name == 0x7531) {
reg_write(0x7c0c, 0x11111111);
reg_read(0x7c0c, &value);
- printf("GPIO Mode (0x7c0c) select value =0x%x \n", value);
+ printf("GPIO Mode (0x7c0c) select value =0x%x\n", value);
}
- printf("Switch Software Reset !!! \n");
+ printf("Switch Software Reset !!!\n");
}
void phy_set_fc(int argc, char *argv[])
@@ -2633,8 +2629,7 @@
}
mii_mgr_write(port, 4, phy_value);
printf("write phy_value:0x%x\r\n", phy_value);
- return;
-} /*end phy_set_fc */
+}
void phy_set_an(int argc, char *argv[])
{
@@ -2664,7 +2659,7 @@
phy_value |= (auto_negotiation_en << 12);
mii_mgr_write(port, 0, phy_value);
printf("write phy_value:0x%x\r\n", phy_value);
-} /*end phy_set_an */
+}
void set_mac_pfc(int argc, char *argv[])
{
@@ -2887,9 +2882,8 @@
port = atoi(argv[3]);
- for (i = 0; i < 8; i++) {
+ for (i = 0; i < 8; i++)
weight[i] = atoi(argv[i + 4]);
- }
/* MT7530 total 7 port */
if (port < 0 || port > 6) {
@@ -3087,7 +3081,7 @@
reg_read(reg, &value);
printf("SetVid: index:%d active:%d vid:%d portMap:%x tagPortMap:%x\r\n",
- index, active, vid, portMap, tagPortMap);
+ index, active, vid, portMap, tagPortMap);
return 0;
} /*end macMT753xVlanSetVid */
@@ -3140,8 +3134,8 @@
macMT753xVlanSetPvid(port, pvid);
printf("port:%d pvid:%d,vlancap: max_port:%d maxvid:%d\r\n",
- port, pvid, SWITCH_MAX_PORT, MAX_VID_VALUE);
-} /*end doVlanSetPvid */
+ port, pvid, SWITCH_MAX_PORT, MAX_VID_VALUE);
+}
void doVlanSetVid(int argc, char *argv[])
{
@@ -3212,9 +3206,9 @@
}
}
macMT753xVlanSetVid(index, active, vid, portMap, tagPortMap,
- ivl_en, fid, stag);
+ ivl_en, fid, stag);
printf("index:%d active:%d vid:%d\r\n", index, active, vid);
-} /*end doVlanSetVid */
+}
void doVlanSetAccFrm(int argc, char *argv[])
{
@@ -3247,7 +3241,7 @@
printf("write reg: %x, value: %x\n", reg, value);
reg_write(reg, value);
-} /*end doVlanSetAccFrm */
+}
void doVlanSetPortAttr(int argc, char *argv[])
{
@@ -3407,9 +3401,8 @@
reg = 0xa0;
reg_read(reg, &value);
value &= (~(1 << 20));
- if (!aging_en) {
+ if (!aging_en)
value |= (1 << 20);
- }
aging_unit = (time / 0x100) + 1;
aging_cnt = (time / aging_unit);
@@ -3497,9 +3490,8 @@
if (errno != 0 || *endptr != '\0' || igmp_mir > 1)
goto error;
- printf
- ("port:%d, port_tx_mir:%d, port_rx_mir:%d, acl_mir:%d, vlan_mis:%d, igmp_mir:%d\n",
- port, port_tx_mir, port_rx_mir, acl_mir, vlan_mis, igmp_mir);
+ printf("port:%d, port_tx_mir:%d, port_rx_mir:%d, acl_mir:%d, vlan_mis:%d, igmp_mir:%d\n",
+ port, port_tx_mir, port_rx_mir, acl_mir, vlan_mis, igmp_mir);
reg = REG_PCR_P0_ADDR + port * 0x100;
reg_read(reg, &value);
@@ -3581,37 +3573,26 @@
if (on_off == 1) {
if (chip_name == 0x7530) {
if (bw > 1000000) {
- printf
- ("\n**Charge rate(%d) is larger than line rate(1000000kbps)**\n",
- bw);
+ printf("\n**Charge rate(%d) is larger than line rate(1000000kbps)**\n", bw);
return;
}
- value =
- ((bw / 32) << 16) + (1 << 15) + (7 << 8) +
- (1 << 7) + 0x0f;
+ value = ((bw / 32) << 16) + (1 << 15) + (7 << 8) + (1 << 7) + 0x0f;
} else if (chip_name == 0x7531 || chip_name == 0x7988) {
if ((chip_name == 0x7531) && (bw > 2500000)) {
- printf
- ("\n**Charge rate(%d) is larger than line rate(2500000kbps)**\n",
- bw);
+ printf("\n**Charge rate(%d) is larger than line rate(2500000kbps)**\n", bw);
return;
}
if ((chip_name == 0x7988) && (bw > 4000000)) {
- printf
- ("\n**Charge rate(%d) is larger than line rate(4000000kbps)**\n",
- bw);
+ printf("\n**Charge rate(%d) is larger than line rate(4000000kbps)**\n", bw);
return;
}
if (bw / 32 >= 65536) //supoort 2.5G case
- value =
- ((bw / 32) << 16) + (1 << 15) + (1 << 14) +
- (1 << 12) + (7 << 8) + 0xf;
+ value = ((bw / 32) << 16) + (1 << 15) + (1 << 14) + (1 << 12) +
+ (7 << 8) + 0xf;
else
- value =
- ((bw / 32) << 16) + (1 << 15) + (1 << 14) +
- (7 << 8) + 0xf;
+ value = ((bw / 32) << 16) + (1 << 15) + (1 << 14) + (7 << 8) + 0xf;
} else
printf("unknow chip\n");
}
@@ -3705,36 +3686,25 @@
if (on_off == 1) {
if (chip_name == 0x7530) {
if (bw < 0 || bw > 1000000) {
- printf
- ("\n**Charge rate(%d) is larger than line rate(1000000kbps)**\n",
- bw);
+ printf("\n**Charge rate(%d) is larger than line rate(1000000kbps)**\n", bw);
return;
}
- value =
- ((bw / 32) << 16) + (1 << 15) + (7 << 8) +
- (1 << 7) + 0xf;
+ value = ((bw / 32) << 16) + (1 << 15) + (7 << 8) + (1 << 7) + 0xf;
} else if (chip_name == 0x7531 || chip_name == 0x7988) {
if ((chip_name == 0x7531) && (bw < 0 || bw > 2500000)) {
- printf
- ("\n**Charge rate(%d) is larger than line rate(2500000kbps)**\n",
- bw);
+ printf("\n**Charge rate(%d) is larger than line rate(2500000kbps)**\n", bw);
return;
}
if ((chip_name == 0x7988) && (bw < 0 || bw > 4000000)) {
- printf
- ("\n**Charge rate(%d) is larger than line rate(4000000kbps)**\n",
- bw);
+ printf("\n**Charge rate(%d) is larger than line rate(4000000kbps)**\n", bw);
return;
}
if (bw / 32 >= 65536) //support 2.5G cases
- value =
- ((bw / 32) << 16) + (1 << 15) + (1 << 14) +
- (1 << 12) + (7 << 8) + 0xf;
+ value = ((bw / 32) << 16) + (1 << 15) + (1 << 14) + (1 << 12) +
+ (7 << 8) + 0xf;
else
- value =
- ((bw / 32) << 16) + (1 << 15) + (1 << 14) +
- (7 << 8) + 0xf;
+ value = ((bw / 32) << 16) + (1 << 15) + (1 << 14) + (7 << 8) + 0xf;
} else
printf("unknow chip\n");
}
@@ -3834,14 +3804,13 @@
enable = atoi(argv[3]);
- printf("collision pool enable: %d \n", enable);
-
/*Check the input parameters is right or not. */
if (enable > 1) {
printf(HELP_COLLISION_POOL_EN);
return;
}
+ printf("collision pool enable: %d\n", enable);
if (chip_name == 0x7531 || chip_name == 0x7988) {
reg = REG_CPGC_ADDR;
if (enable == 1) {
@@ -3912,8 +3881,7 @@
if (value & REG_CPCG_COL_EN_MASK)
table_dump_internal(COLLISION_TABLE);
else
- printf
- ("\ncollision pool is disabled, please enable it before use this command.\n");
+ printf("\ncollision pool is disabled, please enable it before use this command.\n");
} else {
printf("\nCommand not support by this chip.\n");
}
@@ -3929,8 +3897,7 @@
if (value & REG_CPCG_COL_EN_MASK)
dip_dump_internal(COLLISION_TABLE);
else
- printf
- ("\ncollision pool is disabled, please enable it before use this command.\n");
+ printf("\ncollision pool is disabled, please enable it before use this command.\n");
} else {
printf("\nCommand not support by this chip.\n");
}
@@ -3946,8 +3913,7 @@
if (value & REG_CPCG_COL_EN_MASK)
sip_dump_internal(COLLISION_TABLE);
else
- printf
- ("\ncollision pool is disabled, please enable it before use this command.\n");
+ printf("\ncollision pool is disabled, please enable it before use this command.\n");
} else {
printf("\nCommand not support by this chip.\n");
}
@@ -4229,15 +4195,13 @@
port_map = 0;
for (p = 0; p < MAX_PHY_PORT; p++) {
if (argv[3][p] != '0' && argv[3][p] != '1') {
- printf
- ("portmap format error, should be combination of 0 or 1\n");
+ printf("portmap format error, should be combination of 0 or 1\n");
goto error;
}
port_map |= ((argv[3][p] - '0') << p);
}
} else {
- printf
- ("port_no or portmap format error, should be length of 1 or 5\n");
+ printf("port_no or portmap format error, should be length of 1 or 5\n");
goto error;
}
} else {
@@ -4284,7 +4248,6 @@
return;
error:
printf(HELP_EEE_EN);
- return;
}
void eee_dump(int argc, char *argv[])
@@ -4395,7 +4358,7 @@
reg_write(0x4fe0, 0x800000f0);
}
-void exit_free()
+void exit_free(void)
{
free(attres);
attres = NULL;
diff --git a/feed/app/switch/src/switch_fun.h b/feed/app/switch/src/switch_fun.h
index cc16c20..7ca1b0a 100644
--- a/feed/app/switch/src/switch_fun.h
+++ b/feed/app/switch/src/switch_fun.h
@@ -102,9 +102,9 @@
int mii_mgr_read(unsigned int port_num, unsigned int reg, unsigned int *value);
int mii_mgr_write(unsigned int port_num, unsigned int reg, unsigned int value);
int mii_mgr_c45_read(unsigned int port_num, unsigned int dev, unsigned int reg,
- unsigned int *value);
+ unsigned int *value);
int mii_mgr_c45_write(unsigned int port_num, unsigned int dev, unsigned int reg,
- unsigned int value);
+ unsigned int value);
/*phy setting*/
int phy_dump(int phy_addr);
@@ -222,5 +222,5 @@
void read_free_page_counters(int argc, char *argv[]);
void phy_crossover(int argc, char *argv[]);
-void exit_free();
+void exit_free(void);
#endif
diff --git a/feed/app/switch/src/switch_fun_an8855.c b/feed/app/switch/src/switch_fun_an8855.c
index e5ec490..3f5d9f6 100644
--- a/feed/app/switch/src/switch_fun_an8855.c
+++ b/feed/app/switch/src/switch_fun_an8855.c
@@ -1,6 +1,6 @@
/*
-* switch_fun.c: switch function sets
-*/
+ * switch_fun.c: switch function sets
+ */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -18,9 +18,8 @@
#include "switch_fun_an8855.h"
#define MAC_STR "%02X%02X%02X%02X%02X%02X"
-#define MAC2STR(m) (m)[0],(m)[1],(m)[2],(m)[3],(m)[4],(m)[5]
-const static C8_T *mac_address_forward_control_string[] = {
+const static C8_T * mac_address_forward_control_string[] = {
"Default",
"CPU include",
"CPU exclude",
@@ -105,14 +104,13 @@
};
AIR_ERROR_NO_T
-an8855_reg_read(const UI32_T unit, const UI32_T addr_offset, UI32_T * ptr_data)
+an8855_reg_read(const UI32_T unit, const UI32_T addr_offset, UI32_T *ptr_data)
{
int ret;
ret = reg_read(addr_offset, ptr_data);
- if (ret < 0) {
+ if (ret < 0)
return AIR_E_OTHERS;
- }
return AIR_E_OK;
}
@@ -123,9 +121,8 @@
int ret;
ret = reg_write(addr_offset, data);
- if (ret < 0) {
+ if (ret < 0)
return AIR_E_OTHERS;
- }
return AIR_E_OK;
}
@@ -133,14 +130,13 @@
AIR_ERROR_NO_T
an8855_phy_cl22_read(const UI32_T unit,
const UI32_T port_id,
- const UI32_T addr_offset, UI32_T * ptr_data)
+ const UI32_T addr_offset, UI32_T *ptr_data)
{
int ret;
ret = mii_mgr_read(port_id, addr_offset, ptr_data);
- if (ret < 0) {
+ if (ret < 0)
return AIR_E_OTHERS;
- }
return AIR_E_OK;
}
@@ -153,9 +149,9 @@
int ret;
ret = mii_mgr_write(port_id, addr_offset, data);
- if (ret < 0) {
+ if (ret < 0)
return AIR_E_OTHERS;
- }
+
return AIR_E_OK;
}
@@ -164,14 +160,14 @@
an8855_phy_cl45_read(const UI32_T unit,
const UI32_T port_id,
const UI32_T dev_type,
- const UI32_T addr_offset, UI32_T * ptr_data)
+ const UI32_T addr_offset, UI32_T *ptr_data)
{
int ret;
ret = mii_mgr_c45_read(port_id, dev_type, addr_offset, ptr_data);
- if (ret < 0) {
+ if (ret < 0)
return AIR_E_OTHERS;
- }
+
return AIR_E_OK;
}
@@ -185,9 +181,9 @@
int ret;
ret = mii_mgr_c45_write(port_id, dev_type, addr_offset, data);
- if (ret < 0) {
+ if (ret < 0)
return AIR_E_OTHERS;
- }
+
return AIR_E_OK;
}
@@ -198,12 +194,13 @@
}
static AIR_ERROR_NO_T
-_printMacEntry(AIR_MAC_ENTRY_T * mt, UI32_T age_unit, UI8_T count, UI8_T title)
+_printMacEntry(AIR_MAC_ENTRY_T *mt, UI32_T age_unit, UI8_T count, UI8_T title)
{
AIR_ERROR_NO_T ret = AIR_E_OK;
I32_T i = 0, j = 0;
UI8_T first = 0;
UI8_T find = 0;
+
if (title) {
printf("%-6s%-15s%-5s%-5s%-5s%-10s%-10s%-6s\n",
"unit",
@@ -213,7 +210,8 @@
}
for (i = 0; i < count; i++) {
printf("%-6d", age_unit);
- printf(MAC_STR, MAC2STR(mt[i].mac));
+ printf(MAC_STR, mt[i].mac[0], mt[i].mac[1], mt[i].mac[2],
+ mt[i].mac[3], mt[i].mac[4], mt[i].mac[5]);
printf("...");
if (mt[i].flags & AIR_L2_MAC_ENTRY_FLAGS_IVL) {
printf("%-3s..", "ivl");
@@ -224,11 +222,11 @@
printf("%-5s", ".....");
printf("%-5d", mt[i].fid);
}
- if (mt[i].flags & AIR_L2_MAC_ENTRY_FLAGS_STATIC) {
+ if (mt[i].flags & AIR_L2_MAC_ENTRY_FLAGS_STATIC)
printf("%-7s.", "static");
- } else {
+ else
printf("%d sec..", mt[i].timer);
- }
+
printf("%-10s",
mac_address_forward_control_string[mt[i].sa_fwd]);
first = 0;
@@ -256,7 +254,7 @@
return ret;
}
-static AIR_ERROR_NO_T _str2mac(C8_T * str, C8_T * mac)
+static AIR_ERROR_NO_T _str2mac(C8_T *str, C8_T *mac)
{
UI32_T i;
C8_T tmpstr[3];
@@ -307,9 +305,9 @@
while (1) {
memset(ptr_mt, 0, sizeof(AIR_MAC_ENTRY_T) * bucket_size);
ret = air_l2_getNextMacAddr(0, &count, ptr_mt);
- if (AIR_E_OK != ret) {
+ if (ret != AIR_E_OK)
break;
- }
+
total_count += count;
_printMacEntry(ptr_mt, 0, count, FALSE);
}
@@ -328,7 +326,6 @@
DUMP_ERROR:
free(ptr_mt);
- return;
}
void an8855_table_dump(int argc, char *argv[])
@@ -342,6 +339,7 @@
AIR_MAC_ENTRY_T mt;
unsigned int i = 0;
unsigned int age_time = 0;
+
memset(&mt, 0, sizeof(AIR_MAC_ENTRY_T));
if (!argv[2] || strlen(argv[2]) != 12) {
printf("MAC address format error, should be of length 12\n");
@@ -354,7 +352,7 @@
}
if (argc > 4) {
mt.cvid = strtoul(argv[4], NULL, 0);
- if (4095 < mt.cvid) {
+ if (mt.cvid > 4095) {
printf("wrong vid range, should be within 0~4095\n");
return;
}
@@ -379,9 +377,9 @@
printf("wrong age range, should be within 1~1000000\n");
return;
}
- } else {
+ } else
mt.flags |= AIR_L2_MAC_ENTRY_FLAGS_STATIC;
- }
+
mt.sa_fwd = AIR_L2_FWD_CTRL_DEFAULT;
ret = air_l2_addMacAddr(0, &mt);
if (ret == AIR_E_OK) {
@@ -389,16 +387,14 @@
usleep(5000);
if (!(mt.flags & AIR_L2_MAC_ENTRY_FLAGS_STATIC)) {
ret = air_l2_setMacAddrAgeOut(0, age_time);
- if (ret == AIR_E_OK) {
+ if (ret == AIR_E_OK)
printf("set age out time done.\n");
- } else {
+ else
printf("set age out time fail.\n");
- }
+
}
- } else {
+ } else
printf("add mac address fail.\n");
- }
- return;
}
void an8855_table_search_mac_vid(int argc, char *argv[])
@@ -414,7 +410,7 @@
}
ptr_mt = malloc(sizeof(AIR_MAC_ENTRY_T));
- if (NULL == ptr_mt) {
+ if (ptr_mt == NULL) {
printf("Error, malloc fail\n");
return;
}
@@ -443,7 +439,6 @@
printf("\n Not found!\n");
}
free(ptr_mt);
- return;
}
void an8855_table_search_mac_fid(int argc, char *argv[])
@@ -459,7 +454,7 @@
}
ptr_mt = malloc(sizeof(AIR_MAC_ENTRY_T));
- if (NULL == ptr_mt) {
+ if (ptr_mt == NULL) {
printf("Error, malloc fail\n");
return;
}
@@ -483,11 +478,10 @@
if (ret == AIR_E_OK) {
_printMacEntry(ptr_mt, 0, 1, TRUE);
_printMacEntry(ptr_mt, 0, 1, FALSE);
- } else {
+ } else
printf("\n Not found!\n");
- }
+
free(ptr_mt);
- return;
}
void an8855_table_del_fid(int argc, char *argv[])
@@ -516,12 +510,10 @@
}
ret = air_l2_delMacAddr(0, &mt);
- if (ret == AIR_E_OK) {
+ if (ret == AIR_E_OK)
printf("Done.\n");
- } else {
+ else
printf("Fail.\n");
- }
- return;
}
void an8855_table_del_vid(int argc, char *argv[])
@@ -551,12 +543,11 @@
}
ret = air_l2_delMacAddr(0, &mt);
- if (ret == AIR_E_OK) {
+ if (ret == AIR_E_OK)
printf("Done.\n");
- } else {
+ else
printf("Fail.\n");
- }
- return;
+
}
void an8855_table_clear(int argc, char *argv[])
@@ -568,7 +559,7 @@
printf("Clear MAC Address Table Done.\n");
else
printf("Clear MAC Address Table Fail.\n");
- return;
+
}
void an8855_set_mirror_to(int argc, char *argv[])
@@ -577,7 +568,7 @@
AIR_MIR_SESSION_T session = { 0 };
idx = strtoul(argv[3], NULL, 0);
- if (idx < 0 || MAX_PORT < idx) {
+ if (idx < 0 || idx > MAX_PORT) {
printf("wrong port member, should be within 0~%d\n", MAX_PORT);
return;
}
@@ -598,12 +589,12 @@
idx = _strtoul(argv[3], NULL, 0);
mirror = _strtoul(argv[4], NULL, 0);
- if (idx < 0 || MAX_PORT < idx) {
+ if (idx < 0 || idx > MAX_PORT) {
printf("wrong port member, should be within 0~%d\n", MAX_PORT);
return;
}
- if (mirror < 0 || 3 < mirror) {
+ if (mirror < 0 || mirror > 3) {
printf("wrong mirror setting, should be within 0~3\n");
return;
}
@@ -642,9 +633,9 @@
if (eg_tag)
printf
- (" vid fid portmap s-tag\teg_tag(0:untagged 2:tagged)\n");
+ (" vid fid portmap s-tag\teg_tag(0:untagged 2:tagged)\n");
else
- printf(" vid fid portmap s-tag\n");
+ printf(" vid fid portmap s-tag\n");
for (i = 1; i < 4096; i++) {
_air_vlan_readEntry(0, i, &vlan_entry);
@@ -652,73 +643,43 @@
if (vlan_entry.valid) {
printf(" %4d ", i);
printf(" %2d ", vlan_entry.vlan_entry_format.fid);
- printf(" %c",
- (vlan_entry.
- vlan_entry_format.port_mem & 0b0000001) ? '1' :
- '-');
- printf("%c",
- (vlan_entry.
- vlan_entry_format.port_mem & 0b0000010) ? '1' :
- '-');
- printf("%c",
- (vlan_entry.
- vlan_entry_format.port_mem & 0b0000100) ? '1' :
- '-');
- printf("%c",
- (vlan_entry.
- vlan_entry_format.port_mem & 0b0001000) ? '1' :
- '-');
- printf("%c",
- (vlan_entry.
- vlan_entry_format.port_mem & 0b0010000) ? '1' :
- '-');
- printf("%c",
- (vlan_entry.
- vlan_entry_format.port_mem & 0b0100000) ? '1' :
- '-');
- printf("%c",
- (vlan_entry.
- vlan_entry_format.port_mem & 0b1000000) ? '1' :
- '-');
+ printf(" %c", (vlan_entry.vlan_entry_format.port_mem & 0b0000001)
+ ? '1' : '-');
+ printf("%c", (vlan_entry.vlan_entry_format.port_mem & 0b0000010)
+ ? '1' : '-');
+ printf("%c", (vlan_entry.vlan_entry_format.port_mem & 0b0000100)
+ ? '1' : '-');
+ printf("%c", (vlan_entry.vlan_entry_format.port_mem & 0b0001000)
+ ? '1' : '-');
+ printf("%c", (vlan_entry.vlan_entry_format.port_mem & 0b0010000)
+ ? '1' : '-');
+ printf("%c", (vlan_entry.vlan_entry_format.port_mem & 0b0100000)
+ ? '1' : '-');
+ printf("%c", (vlan_entry.vlan_entry_format.port_mem & 0b1000000)
+ ? '1' : '-');
printf(" %4d", vlan_entry.vlan_entry_format.eg_ctrl);
if (eg_tag) {
printf("\t");
if (vlan_entry.vlan_entry_format.eg_con
- && vlan_entry.
- vlan_entry_format.eg_ctrl_en) {
+ && vlan_entry.vlan_entry_format.eg_ctrl_en) {
/* VTAG_EN=1 and EG_CON=1 */
printf("CONSISTENT");
- } else if (vlan_entry.
- vlan_entry_format.eg_ctrl_en) {
+ } else if (vlan_entry.vlan_entry_format.eg_ctrl_en) {
/* VTAG_EN=1 */
printf("%d",
- (vlan_entry.
- vlan_entry_format.eg_ctrl >> 0)
- & 0x3);
+ (vlan_entry.vlan_entry_format.eg_ctrl >> 0) & 0x3);
printf("%d",
- (vlan_entry.
- vlan_entry_format.eg_ctrl >> 2)
- & 0x3);
+ (vlan_entry.vlan_entry_format.eg_ctrl >> 2) & 0x3);
printf("%d",
- (vlan_entry.
- vlan_entry_format.eg_ctrl >> 4)
- & 0x3);
+ (vlan_entry.vlan_entry_format.eg_ctrl >> 4) & 0x3);
printf("%d",
- (vlan_entry.
- vlan_entry_format.eg_ctrl >> 6)
- & 0x3);
+ (vlan_entry.vlan_entry_format.eg_ctrl >> 6) & 0x3);
printf("%d",
- (vlan_entry.
- vlan_entry_format.eg_ctrl >> 8)
- & 0x3);
+ (vlan_entry.vlan_entry_format.eg_ctrl >> 8) & 0x3);
printf("%d",
- (vlan_entry.
- vlan_entry_format.eg_ctrl >> 10)
- & 0x3);
+ (vlan_entry.vlan_entry_format.eg_ctrl >> 10) & 0x3);
printf("%d",
- (vlan_entry.
- vlan_entry_format.eg_ctrl >> 12)
- & 0x3);
+ (vlan_entry.vlan_entry_format.eg_ctrl >> 12) & 0x3);
} else {
/* VTAG_EN=0 */
printf("DISABLED");
@@ -802,7 +763,7 @@
if (argc > 7) {
eg_con = strtoul(argv[7], NULL, 2);
- eg_con = ! !eg_con;
+ eg_con = !!eg_con;
vlan_entry.vlan_entry_format.eg_con = eg_con;
vlan_entry.vlan_entry_format.eg_ctrl_en = 1;
}
@@ -817,8 +778,8 @@
for (i = 0; i < SWITCH_MAX_PORT; i++) {
if (argv[8][i] < '0' || argv[8][i] > '3') {
- printf
- ("egtag portmap format error, should be of combination of 0 or 3\n");
+ printf("egtag portmap format error,");
+ printf("should be of combination of 0 or 3\n");
return;
}
eg_tag |= (argv[8][i] - '0') << (i * 2);
@@ -947,8 +908,8 @@
return;
}
- printf("\r\nswitch qos base : %d. (port-based:0, tag-based:1,\
- dscp-based:2, acl-based:3, arl-based:4, stag-based:5)\n", base);
+ printf("\r\nswitch qos base : %d. (port-based:0, tag-based:1,", base);
+ printf("dscp-based:2, acl-based:3, arl-based:4, stag-based:5)\n");
reg_read(0x10208030 + 0x200 * port, &value);
an8855_get_upw(&value, base);
reg_write(0x10208030 + 0x200 * port, value);
@@ -962,9 +923,8 @@
port = _strtoul(argv[3], NULL, 10);
- for (i = 0; i < 8; i++) {
+ for (i = 0; i < 8; i++)
weight[i] = _strtoul(argv[i + 4], NULL, 10);
- }
/* MT7530 total 7 port */
if (port < 0 || port > 6) {
@@ -978,13 +938,15 @@
return;
}
}
- printf("port: %x, q0: %x, q1: %x, q2: %x, q3: %x, \
- q4: %x, q5: %x, q6: %x, q7: %x\n", port, weight[0], weight[1], weight[2], weight[3], weight[4], weight[5], weight[6], weight[7]);
+ printf("port: %x, q0: %x, q1: %x, q2: %x, q3: %x,",
+ port, weight[0], weight[1], weight[2], weight[3]);
+ printf("q4: %x, q5: %x, q6: %x, q7: %x\n",
+ weight[4], weight[5], weight[6], weight[7]);
- for (queue = 0; queue < 8; queue++) {
+ for (queue = 0; queue < 8; queue++)
air_qos_setScheduleAlgo(0, port, queue, AIR_QOS_SCH_MODE_WFQ,
weight[queue]);
- }
+
}
void an8855_qos_set_portpri(int argc, char *argv[])
@@ -1096,17 +1058,19 @@
}
}
- printf("index: %x, active: %x, vid: %x, portMap: %x, \
- tagPortMap: %x, ivl_en: %x, fid: %x, stag: %x\n", index, active, vid, portMap, tagPortMap, ivl_en, fid, stag);
+ printf("index: %x, active: %x, vid: %x, portMap: %x,",
+ index, active, vid, portMap);
+ printf("tagPortMap: %x, ivl_en: %x, fid: %x, stag: %x\n",
+ tagPortMap, ivl_en, fid, stag);
- vlan_entry.valid = ! !active;
+ vlan_entry.valid = !!active;
vlan_entry.vlan_entry_format.port_mem = portMap;
/* Total 6 ports */
for (i = 0; i < SWITCH_MAX_PORT; i++) {
if (tagPortMap & (1 << i))
vlan_entry.vlan_entry_format.eg_ctrl |= 0x2 << (i * 2);
}
- vlan_entry.vlan_entry_format.ivl = ! !ivl_en;
+ vlan_entry.vlan_entry_format.ivl = !!ivl_en;
vlan_entry.vlan_entry_format.fid = fid;
vlan_entry.vlan_entry_format.stag = stag;
@@ -1234,9 +1198,8 @@
return;
}
- for (port = 0; port < 6; port++) {
+ for (port = 0; port < 6; port++)
air_l2_setAgeEnable(0, port, aging_en);
- }
air_l2_setMacAddrAgeOut(0, time);
}
@@ -1264,9 +1227,8 @@
session.dst_port = mirror_port;
session.flags |= AIR_MIR_SESSION_FLAGS_ENABLE;
air_mir_addSession(0, 0, &session);
- } else {
+ } else
air_mir_delSession(0, 0);
- }
air_mir_setSessionAdminMode(0, 0, (int)mirror_en);
} /*end doMirrorEn */
@@ -1285,13 +1247,14 @@
vlan_mis = _strtoul(argv[7], NULL, 10);
igmp_mir = _strtoul(argv[8], NULL, 10);
- printf
- ("port:%d, port_tx_mir:%d, port_rx_mir:%d, acl_mir:%d, vlan_mis:%d, igmp_mir:%d\n",
- port, port_tx_mir, port_rx_mir, acl_mir, vlan_mis, igmp_mir);
+ printf("port:%d, port_tx_mir:%d, port_rx_mir:%d, ",
+ port, port_tx_mir, port_rx_mir);
+ printf("acl_mir:%d, vlan_mis:%d, igmp_mir:%d\n",
+ acl_mir, vlan_mis, igmp_mir);
/*Check the input parameters is right or not. */
- //if((port >= vlanCap->max_port_no) || (port_tx_mir > 1) || (port_rx_mir > 1) || (acl_mir > 1) || (vlan_mis > 1)){
- if ((port >= SWITCH_MAX_PORT) || (port_tx_mir > 1) || (port_rx_mir > 1) || (acl_mir > 1) || (vlan_mis > 1)) { // also allow CPU port (port6)
+ if ((port >= SWITCH_MAX_PORT) || (port_tx_mir > 1) || (port_rx_mir > 1)
+ || (acl_mir > 1) || (vlan_mis > 1)) { // also allow CPU port (port6)
printf(HELP_MIRROR_PORTBASED);
return;
}
@@ -1312,11 +1275,7 @@
air_mir_setMirrorPort(0, 0, &session);
- /*
-
- not support acl/vlan/igmp mismatch
-
- */
+ /* not support acl/vlan/igmp mismatch */
} /*end doMirrorPortBased */
void an8855_doStp(int argc, char *argv[])
@@ -1346,35 +1305,40 @@
{
AIR_ERROR_NO_T ret = AIR_E_OK;
AIR_QOS_RATE_LIMIT_CFG_T rl = { 0 };
+
if (on_off) {
ret =
air_qos_setRateLimitEnable(0, port,
AIR_QOS_RATE_DIR_INGRESS, TRUE);
- if (AIR_E_OK != ret) {
+ if (ret != AIR_E_OK) {
printf("an8855 set ingress ratelimit eanble fail\n");
return;
}
+ ret = air_qos_getRateLimit(0, port, &rl);
+ if (ret != AIR_E_OK) {
+ printf("an8855 get port %d ratelimit fail\n",
+ port);
+ return;
+ }
rl.ingress_cir = bw;
rl.flags |= AIR_QOS_RATE_LIMIT_CFG_FLAGS_ENABLE_INGRESS;
ret = air_qos_setRateLimit(0, port, &rl);
- if (AIR_E_OK != ret) {
+ if (ret != AIR_E_OK) {
printf("an8855 set ingress ratelimit value %d fail\n",
bw);
return;
- } else {
- printf("an8855 set ingress ratelimit value %d ok\n",
- bw);
}
+ printf("an8855 set ingress ratelimit value %d ok\n", bw);
} else {
ret =
air_qos_setRateLimitEnable(0, port,
AIR_QOS_RATE_DIR_INGRESS, FALSE);
- if (AIR_E_OK != ret) {
+ if (ret != AIR_E_OK) {
printf("an8855 set ingress ratelimit disable fail\n");
return;
- } else {
- printf("an8855 set ingress ratelimit disable ok\n");
}
+ printf("an8855 set ingress ratelimit disable ok\n");
+
}
}
@@ -1382,34 +1346,41 @@
{
AIR_ERROR_NO_T ret = AIR_E_OK;
AIR_QOS_RATE_LIMIT_CFG_T rl = { 0 };
+
if (on_off) {
ret =
air_qos_setRateLimitEnable(0, port, AIR_QOS_RATE_DIR_EGRESS,
TRUE);
- if (AIR_E_OK != ret) {
+ if (ret != AIR_E_OK) {
printf("an8855 set egress ratelimit eanble fail\n");
return;
}
+ ret = air_qos_getRateLimit(0, port, &rl);
+ if (ret != AIR_E_OK) {
+ printf("an8855 get port %d ratelimit fail\n",
+ port);
+ return;
+ }
rl.egress_cir = bw;
rl.flags |= AIR_QOS_RATE_LIMIT_CFG_FLAGS_ENABLE_EGRESS;
ret = air_qos_setRateLimit(0, port, &rl);
- if (AIR_E_OK != ret) {
+ if (ret != AIR_E_OK) {
printf("an8855 set egress ratelimit value %d fail\n",
bw);
return;
- } else {
- printf("an8855 set egress ratelimit value %d ok\n", bw);
}
+ printf("an8855 set egress ratelimit value %d ok\n", bw);
+
} else {
ret =
air_qos_setRateLimitEnable(0, port, AIR_QOS_RATE_DIR_EGRESS,
FALSE);
- if (AIR_E_OK != ret) {
+ if (ret != AIR_E_OK) {
printf("an8855 set egress ratelimit disable fail\n");
return;
- } else {
- printf("an8855 set egress ratelimit disable ok\n");
}
+ printf("an8855 set egress ratelimit disable ok\n");
+
}
}
@@ -1422,9 +1393,9 @@
bw = _strtoul(argv[4], NULL, 0);
on_off = 1;
} else if (argv[2][1] == 'f') {
- if (argc != 4) {
+ if (argc != 4)
return;
- }
+
on_off = 0;
}
@@ -1441,9 +1412,9 @@
bw = _strtoul(argv[4], NULL, 0);
on_off = 1;
} else if (argv[2][1] == 'f') {
- if (argc != 4) {
+ if (argc != 4)
return;
- }
+
on_off = 0;
}
@@ -1554,35 +1525,35 @@
queue[6] = (value & 0x3F0000) >> 16;
queue[7] = (value & 0x3F000000) >> 24;
- printf("<===Free Page=======Current============Minimal=========> \n ");
- printf(" \n ");
- printf(" page counter %u %u \n ",
+ printf("<===Free Page=======Current============Minimal=========>\n");
+ printf("\n");
+ printf(" page counter %u %u\n",
free_page, free_page_min);
- printf(" \n ");
- printf("========================================================= \n ");
- printf("<===Type=======High threshold======Low threshold=========\n ");
- printf(" \n ");
- printf(" system: %u %u \n",
+ printf("\n");
+ printf("=========================================================\n");
+ printf("<===Type=======High threshold======Low threshold=========\n");
+ printf("\n");
+ printf(" system: %u %u\n",
fc_free_blk_hithd * 2, fc_free_blk_lothd * 2);
- printf(" port: %u %u \n",
+ printf(" port: %u %u\n",
fc_port_blk_hi_thd * 2, fc_port_blk_thd * 2);
- printf(" queue 0: %u NA \n",
+ printf(" queue 0: %u NA\n",
queue[0]);
- printf(" queue 1: %u NA \n",
+ printf(" queue 1: %u NA\n",
queue[1]);
- printf(" queue 2: %u NA \n",
+ printf(" queue 2: %u NA\n",
queue[2]);
- printf(" queue 3: %u NA \n",
+ printf(" queue 3: %u NA\n",
queue[3]);
- printf(" queue 4: %u NA \n",
+ printf(" queue 4: %u NA\n",
queue[4]);
- printf(" queue 5: %u NA \n",
+ printf(" queue 5: %u NA\n",
queue[5]);
- printf(" queue 6: %u NA \n",
+ printf(" queue 6: %u NA\n",
queue[6]);
- printf(" queue 7: %u NA \n",
+ printf(" queue 7: %u NA\n",
queue[7]);
- printf("=========================================================\n ");
+ printf("=========================================================\n");
}
void an8855_eee_enable(int argc, char *argv[])
@@ -1618,8 +1589,8 @@
port_map = 0;
for (p = 0; p < MAX_PHY_PORT; p++) {
if (argv[3][p] != '0' && argv[3][p] != '1') {
- printf
- ("portmap format error, should be combination of 0 or 1\n");
+ printf("portmap format error, ");
+ printf("should be combination of 0 or 1\n");
goto error;
}
port_map |= ((argv[3][p] - '0') << p);
@@ -1636,11 +1607,11 @@
for (port_num = 0; port_num < MAX_PHY_PORT; port_num++) {
if (port_map & (1 << port_num)) {
air_port_getPsMode(0, port_num, &mode);
- if (enable) {
+ if (enable)
mode |= AIR_PORT_PS_EEE;
- } else {
+ else
mode &= ~AIR_PORT_PS_EEE;
- }
+
air_port_setPsMode(0, port_num, mode);
}
}
@@ -1648,7 +1619,6 @@
error:
printf(HELP_EEE_EN);
- return;
}
void an8855_eee_dump(int argc, char *argv[])
@@ -1694,107 +1664,106 @@
AIR_MIB_CNT_RX_T rx_mib[7];
AIR_MIB_CNT_TX_T tx_mib[7];
- printf("===================== %8s %8s %8s %8s %8s %8s %8s\n",
+ printf("======================== %8s %8s %8s %8s %8s %8s %8s\n",
"Port0", "Port1", "Port2", "Port3", "Port4", "Port5", "Port6");
- for (port = 0; port < 7; port++) {
+ for (port = 0; port < 7; port++)
air_mib_get(0, port, &rx_mib[port], &tx_mib[port]);
- }
printf("Tx Drop Packet :");
- for (port = 0; port < 7; port++) {
+ for (port = 0; port < 7; port++)
printf("%8u ", tx_mib[port].TDPC);
- }
+
printf("\n");
printf("Tx CRC Error :");
- for (port = 0; port < 7; port++) {
+ for (port = 0; port < 7; port++)
printf("%8u ", tx_mib[port].TCRC);
- }
+
printf("\n");
printf("Tx Unicast Packet :");
- for (port = 0; port < 7; port++) {
+ for (port = 0; port < 7; port++)
printf("%8u ", tx_mib[port].TUPC);
- }
+
printf("\n");
printf("Tx Multicast Packet :");
- for (port = 0; port < 7; port++) {
+ for (port = 0; port < 7; port++)
printf("%8u ", tx_mib[port].TMPC);
- }
+
printf("\n");
printf("Tx Broadcast Packet :");
- for (port = 0; port < 7; port++) {
+ for (port = 0; port < 7; port++)
printf("%8u ", tx_mib[port].TBPC);
- }
+
printf("\n");
printf("Tx Collision Event :");
- for (port = 0; port < 7; port++) {
+ for (port = 0; port < 7; port++)
printf("%8u ", tx_mib[port].TCEC);
- }
+
printf("\n");
printf("Tx Pause Packet :");
- for (port = 0; port < 7; port++) {
+ for (port = 0; port < 7; port++)
printf("%8u ", tx_mib[port].TPPC);
- }
+
printf("\n");
printf("Rx Drop Packet :");
- for (port = 0; port < 7; port++) {
+ for (port = 0; port < 7; port++)
printf("%8u ", rx_mib[port].RDPC);
- }
+
printf("\n");
printf("Rx Filtering Packet :");
- for (port = 0; port < 7; port++) {
+ for (port = 0; port < 7; port++)
printf("%8u ", rx_mib[port].RFPC);
- }
+
printf("\n");
printf("Rx Unicast Packet :");
- for (port = 0; port < 7; port++) {
+ for (port = 0; port < 7; port++)
printf("%8u ", rx_mib[port].RUPC);
- }
+
printf("\n");
printf("Rx Multicast Packet :");
- for (port = 0; port < 7; port++) {
+ for (port = 0; port < 7; port++)
printf("%8u ", rx_mib[port].RMPC);
- }
+
printf("\n");
printf("Rx Broadcast Packet :");
- for (port = 0; port < 7; port++) {
+ for (port = 0; port < 7; port++)
printf("%8u ", rx_mib[port].RBPC);
- }
+
printf("\n");
printf("Rx Alignment Error :");
- for (port = 0; port < 7; port++) {
+ for (port = 0; port < 7; port++)
printf("%8u ", rx_mib[port].RAEPC);
- }
+
printf("\n");
printf("Rx CRC Error :");
- for (port = 0; port < 7; port++) {
+ for (port = 0; port < 7; port++)
printf("%8u ", rx_mib[port].RCEPC);
- }
+
printf("\n");
printf("Rx Undersize Error :");
- for (port = 0; port < 7; port++) {
+ for (port = 0; port < 7; port++)
printf("%8u ", rx_mib[port].RUSPC);
- }
+
printf("\n");
printf("Rx Fragment Error :");
- for (port = 0; port < 7; port++) {
+ for (port = 0; port < 7; port++)
printf("%8u ", rx_mib[port].RFEPC);
- }
+
printf("\n");
printf("Rx Oversize Error :");
- for (port = 0; port < 7; port++) {
+ for (port = 0; port < 7; port++)
printf("%8u ", rx_mib[port].ROSPC);
- }
+
printf("\n");
printf("Rx Jabber Error :");
- for (port = 0; port < 7; port++) {
+ for (port = 0; port < 7; port++)
printf("%8u ", rx_mib[port].RJEPC);
- }
+
printf("\n");
printf("Rx Pause Packet :");
- for (port = 0; port < 7; port++) {
+ for (port = 0; port < 7; port++)
printf("%8u ", rx_mib[port].RPPC);
- }
+
printf("\n");
}
diff --git a/feed/app/switch/src/switch_fun_an8855.h b/feed/app/switch/src/switch_fun_an8855.h
index 1d67080..9be440f 100644
--- a/feed/app/switch/src/switch_fun_an8855.h
+++ b/feed/app/switch/src/switch_fun_an8855.h
@@ -1,6 +1,6 @@
/*
-* switch_fun.h: switch function sets
-*/
+ * switch_fun.h: switch function sets
+ */
#ifndef SWITCH_FUN_AN8855_H
#define SWITCH_FUN_AN8855_H
@@ -16,7 +16,7 @@
AIR_ERROR_NO_T
an8855_phy_cl22_read(const UI32_T unit,
const UI32_T port_id,
- const UI32_T addr_offset, UI32_T * ptr_data);
+ const UI32_T addr_offset, UI32_T *ptr_data);
AIR_ERROR_NO_T
an8855_phy_cl22_write(const UI32_T unit,
@@ -27,7 +27,7 @@
an8855_phy_cl45_read(const UI32_T unit,
const UI32_T port_id,
const UI32_T dev_type,
- const UI32_T addr_offset, UI32_T * ptr_data);
+ const UI32_T addr_offset, UI32_T *ptr_data);
AIR_ERROR_NO_T
an8855_phy_cl45_write(const UI32_T unit,
@@ -40,38 +40,6 @@
void an8855_not_supported(int argc, char *argv[]);
-#if 0
-/*acl setting*/
-void an8855_acl_mac_add(int argc, char *argv[]);
-void an8855_acl_dip_meter(int argc, char *argv[]);
-void an8855_acl_dip_trtcm(int argc, char *argv[]);
-void an8855_acl_ethertype(int argc, char *argv[]);
-void an8855_acl_ethertype(int argc, char *argv[]);
-void an8855_acl_dip_modify(int argc, char *argv[]);
-void an8855_acl_dip_pppoe(int argc, char *argv[]);
-void an8855_acl_dip_add(int argc, char *argv[]);
-void an8855_acl_l4_add(int argc, char *argv[]);
-void an8855_acl_sp_add(int argc, char *argv[]);
-
-void an8855_acl_port_enable(int argc, char *argv[]);
-void an8855_acl_table_add(int argc, char *argv[]);
-void an8855_acl_mask_table_add(int argc, char *argv[]);
-void an8855_acl_rule_table_add(int argc, char *argv[]);
-void an8855_acl_rate_table_add(int argc, char *argv[]);
-
-/*dip table*/
-void an8855_dip_dump(void);
-void an8855_dip_add(int argc, char *argv[]);
-void an8855_dip_del(int argc, char *argv[]);
-void an8855_dip_clear(void);
-
-/*sip table*/
-void an8855_sip_dump(void);
-void an8855_sip_add(int argc, char *argv[]);
-void an8855_sip_del(int argc, char *argv[]);
-void an8855_sip_clear(void);
-#endif
-
/*stp*/
void an8855_doStp(int argc, char *argv[]);
diff --git a/feed/app/switch/src/switch_ioctl.c b/feed/app/switch/src/switch_ioctl.c
index f6b97d4..dd9e621 100644
--- a/feed/app/switch/src/switch_ioctl.c
+++ b/feed/app/switch/src/switch_ioctl.c
@@ -164,7 +164,7 @@
break;
}
}
- //printf(" PHY Indirect Access Control(0x701c) register read value =0x%x \n", reg_value);
+ //printf(" PHY Indirect Access Control(0x701c) register read value =0x%x\n", reg_value);
*value = reg_value;
return 0;
@@ -205,7 +205,7 @@
}
}
- //printf(" PHY Indirect Access Control(0x701c) register write value =0x%x \n", reg_value);
+ //printf(" PHY Indirect Access Control(0x701c) register write value =0x%x\n", reg_value);
return 0;
}
@@ -332,7 +332,7 @@
} else {
printf("MDIO cl45 set dev opeartion timeout\n");
reg_value = 0;
- ret = -1;
+ ret = -1;
goto out;
}
}
@@ -351,12 +351,12 @@
} else {
printf("MDIO cl45 read reg opeartion timeout\n");
reg_value = 0;
- ret = -1;
+ ret = -1;
break;
}
}
out:
- //printf(" PHY Indirect Access Control(0x701c) register read value =0x%x \n", reg_value);
+ //printf(" PHY Indirect Access Control(0x701c) register read value =0x%x\n", reg_value);
*value = reg_value;
return ret;
@@ -384,7 +384,7 @@
loop_cnt++;
else {
printf("MDIO cl45 set dev opeartion timeout\n");
- ret = -1;
+ ret = -1;
goto out;
}
}
@@ -401,12 +401,12 @@
loop_cnt++;
else {
printf("MDIO cl45 write reg opeartion timeout\n");
- ret = -1;
+ ret = -1;
break;
}
}
out:
- //printf(" PHY Indirect Access Control(0x701c) register write value =0x%x \n", reg_value);
+ //printf(" PHY Indirect Access Control(0x701c) register write value =0x%x\n", reg_value);
return ret;
}
diff --git a/feed/app/switch/src/switch_ioctl.h b/feed/app/switch/src/switch_ioctl.h
index dffe9c7..3ee43d7 100644
--- a/feed/app/switch/src/switch_ioctl.h
+++ b/feed/app/switch/src/switch_ioctl.h
@@ -8,48 +8,43 @@
#define ETH_DEVNAME "eth0"
#define BR_DEVNAME "br-lan"
-#define RAETH_MII_READ 0x89F3
-#define RAETH_MII_WRITE 0x89F4
-#define RAETH_ESW_PHY_DUMP 0x89F7
+#define RAETH_MII_READ 0x89F3
+#define RAETH_MII_WRITE 0x89F4
+#define RAETH_ESW_PHY_DUMP 0x89F7
struct esw_reg {
- unsigned int off;
- unsigned int val;
+ unsigned int off;
+ unsigned int val;
};
struct ra_mii_ioctl_data {
- __u16 phy_id;
- __u16 reg_num;
- __u32 val_in;
- __u32 val_out;
-/*
- __u32 port_num;
- __u32 dev_addr;
- __u32 reg_addr;
-*/
+ __u16 phy_id;
+ __u16 reg_num;
+ __u32 val_in;
+ __u32 val_out;
};
struct ra_switch_ioctl_data {
- unsigned int cmd;
- unsigned int on_off;
- unsigned int port;
- unsigned int bw;
- unsigned int vid;
- unsigned int fid;
- unsigned int port_map;
- unsigned int rx_port_map;
- unsigned int tx_port_map;
- unsigned int igmp_query_interval;
- unsigned int reg_addr;
- unsigned int reg_val;
- unsigned int mode;
- unsigned int qos_queue_num;
- unsigned int qos_type;
- unsigned int qos_pri;
- unsigned int qos_dscp;
- unsigned int qos_table_idx;
- unsigned int qos_weight;
- unsigned char mac[6];
+ unsigned int cmd;
+ unsigned int on_off;
+ unsigned int port;
+ unsigned int bw;
+ unsigned int vid;
+ unsigned int fid;
+ unsigned int port_map;
+ unsigned int rx_port_map;
+ unsigned int tx_port_map;
+ unsigned int igmp_query_interval;
+ unsigned int reg_addr;
+ unsigned int reg_val;
+ unsigned int mode;
+ unsigned int qos_queue_num;
+ unsigned int qos_type;
+ unsigned int qos_pri;
+ unsigned int qos_dscp;
+ unsigned int qos_table_idx;
+ unsigned int qos_weight;
+ unsigned char mac[6];
};
extern int chip_name;
@@ -60,11 +55,11 @@
int reg_write_ioctl(unsigned int offset, unsigned int value);
int phy_dump_ioctl(unsigned int phy_addr);
int mii_mgr_cl22_read_ioctl(unsigned int port_num, unsigned int reg,
- unsigned int *value);
+ unsigned int *value);
int mii_mgr_cl22_write_ioctl(unsigned int port_num, unsigned int reg,
- unsigned int value);
+ unsigned int value);
int mii_mgr_cl45_read_ioctl(unsigned int port_num, unsigned int dev,
- unsigned int reg, unsigned int *value);
+ unsigned int reg, unsigned int *value);
int mii_mgr_cl45_write_ioctl(unsigned int port_num, unsigned int dev,
- unsigned int reg, unsigned int value);
+ unsigned int reg, unsigned int value);
#endif
diff --git a/feed/app/switch/src/switch_netlink.h b/feed/app/switch/src/switch_netlink.h
index cb812d5..94d8389 100644
--- a/feed/app/switch/src/switch_netlink.h
+++ b/feed/app/switch/src/switch_netlink.h
@@ -1,6 +1,6 @@
/*
* switch_netlink.h: switch(netlink) set API
- *
+ *
* Author: Sirui Zhao <Sirui.Zhao@mediatek.com>
*/
#ifndef MT753X_NETLINK_H
@@ -54,20 +54,16 @@
int mt753x_netlink_init(const char *name);
void mt753x_netlink_free(void);
void mt753x_list_swdev(struct mt753x_attr *arg, int cmd);
-int reg_read_netlink(struct mt753x_attr *arg, unsigned int offset,
- unsigned int *value);
-int reg_write_netlink(struct mt753x_attr *arg, unsigned int offset,
- unsigned int value);
+int reg_read_netlink(struct mt753x_attr *arg, unsigned int offset, unsigned int *value);
+int reg_write_netlink(struct mt753x_attr *arg, unsigned int offset, unsigned int value);
int phy_cl22_read_netlink(struct mt753x_attr *arg, unsigned int port_num,
- unsigned int phy_addr, unsigned int *value);
+ unsigned int phy_addr, unsigned int *value);
int phy_cl22_write_netlink(struct mt753x_attr *arg, unsigned int port_num,
- unsigned int phy_addr, unsigned int value);
+ unsigned int phy_addr, unsigned int value);
int phy_cl45_read_netlink(struct mt753x_attr *arg, unsigned int port_num,
- unsigned int phy_dev, unsigned int phy_addr,
- unsigned int *value);
+ unsigned int phy_dev, unsigned int phy_addr, unsigned int *value);
int phy_cl45_write_netlink(struct mt753x_attr *arg, unsigned int port_num,
- unsigned int phy_dev, unsigned int phy_addr,
- unsigned int value);
+ unsigned int phy_dev, unsigned int phy_addr, unsigned int value);
int phy_dump_netlink(struct mt753x_attr *arg, int phy_addr);
#endif