[qca-ssdk-shell] support eee property configuration

Change-Id: Ide9adfa6760445e97d1583ed8da35be79949f93a
Signed-off-by: esong <song@codeaurora.org>
diff --git a/include/api/api_desc.h b/include/api/api_desc.h
index 0225849..efaf8a5 100755
--- a/include/api/api_desc.h
+++ b/include/api/api_desc.h
@@ -479,6 +479,16 @@
     SW_PARAM_DEF(SW_API_PT_PROMISC_MODE_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"),\
     SW_PARAM_DEF(SW_API_PT_PROMISC_MODE_GET, SW_ENABLE, 4, SW_PARAM_PTR|SW_PARAM_OUT, "Enable"),
 
+#define SW_API_PT_INTERFACE_EEE_CFG_SET_DESC \
+    SW_PARAM_DEF(SW_API_PT_INTERFACE_EEE_CFG_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \
+    SW_PARAM_DEF(SW_API_PT_INTERFACE_EEE_CFG_SET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \
+    SW_PARAM_DEF(SW_API_PT_INTERFACE_EEE_CFG_SET, SW_PORT_EEE_CONFIG, sizeof(fal_port_eee_cfg_t), SW_PARAM_PTR|SW_PARAM_IN, "EEE"),
+
+#define SW_API_PT_INTERFACE_EEE_CFG_GET_DESC \
+    SW_PARAM_DEF(SW_API_PT_INTERFACE_EEE_CFG_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \
+    SW_PARAM_DEF(SW_API_PT_INTERFACE_EEE_CFG_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \
+    SW_PARAM_DEF(SW_API_PT_INTERFACE_EEE_CFG_GET, SW_PORT_EEE_CONFIG, sizeof(fal_port_eee_cfg_t), SW_PARAM_PTR|SW_PARAM_OUT, "EEE"),
+
 #define SW_API_VLAN_ADD_DESC \
     SW_PARAM_DEF(SW_API_VLAN_ADD, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \
     SW_PARAM_DEF(SW_API_VLAN_ADD, SW_UINT32, 4, SW_PARAM_IN, "Vlan Id"),
diff --git a/include/api/sw_api.h b/include/api/sw_api.h
old mode 100644
new mode 100755
index 92efbcf..c0d34c8
--- a/include/api/sw_api.h
+++ b/include/api/sw_api.h
@@ -228,6 +228,7 @@
 	SW_POLICER_GLOBAL_COUNTER,
 	SW_PHY_DUMP,
 	SW_RESOURCE_SCHE,
+	SW_PORT_EEE_CONFIG,
 } sw_data_type_e;
 
     typedef struct
diff --git a/include/api/sw_ioctl.h b/include/api/sw_ioctl.h
index feee915..a62841b 100755
--- a/include/api/sw_ioctl.h
+++ b/include/api/sw_ioctl.h
@@ -121,7 +121,8 @@
 #define SW_API_PT_INTERFACE_3AZ_STATUS_GET  (76 + SW_API_PORT_OFFSET)
 #define SW_API_PT_PROMISC_MODE_SET   (77  + SW_API_PORT_OFFSET)
 #define SW_API_PT_PROMISC_MODE_GET   (78  + SW_API_PORT_OFFSET)
-
+#define SW_API_PT_INTERFACE_EEE_CFG_SET  (79 + SW_API_PORT_OFFSET)
+#define SW_API_PT_INTERFACE_EEE_CFG_GET  (80 + SW_API_PORT_OFFSET)
 
     /*vlan*/
 #define SW_API_VLAN_OFFSET         110
diff --git a/include/fal/fal_api.h b/include/fal/fal_api.h
index b1fa983..1aef454 100755
--- a/include/fal/fal_api.h
+++ b/include/fal/fal_api.h
@@ -121,7 +121,9 @@
     SW_API_DEF(SW_API_PT_INTERFACE_3AZ_STATUS_SET, fal_port_interface_3az_status_set), \
     SW_API_DEF(SW_API_PT_INTERFACE_3AZ_STATUS_GET, fal_port_interface_3az_status_get), \
     SW_API_DEF(SW_API_PT_PROMISC_MODE_SET, fal_port_promisc_mode_set),  \
-    SW_API_DEF(SW_API_PT_PROMISC_MODE_GET, fal_port_promisc_mode_get),
+    SW_API_DEF(SW_API_PT_PROMISC_MODE_GET, fal_port_promisc_mode_get), \
+    SW_API_DEF(SW_API_PT_INTERFACE_EEE_CFG_SET, fal_port_interface_eee_cfg_set),  \
+    SW_API_DEF(SW_API_PT_INTERFACE_EEE_CFG_GET, fal_port_interface_eee_cfg_get),
 /*qca808x_start*/\
 /*end of PORTCONTROL_API*/
 #define PORTCONTROL_API_PARAM \
@@ -223,6 +225,9 @@
     SW_API_DESC(SW_API_PT_INTERFACE_3AZ_STATUS_GET)\
     SW_API_DESC(SW_API_PT_PROMISC_MODE_SET)  \
     SW_API_DESC(SW_API_PT_PROMISC_MODE_GET)  \
+    SW_API_DESC(SW_API_PT_INTERFACE_EEE_CFG_SET)  \
+    SW_API_DESC(SW_API_PT_INTERFACE_EEE_CFG_GET)
+
 /*qca808x_start*/\
 /*end of PORTCONTROL_API_PARAM*/
 /*qca808x_end*/
diff --git a/include/fal/fal_port_ctrl.h b/include/fal/fal_port_ctrl.h
index 6f98b01..7e4c0b5 100755
--- a/include/fal/fal_port_ctrl.h
+++ b/include/fal/fal_port_ctrl.h
@@ -137,6 +137,14 @@
 #define FAL_PHY_INTR_WOL_STATUS   0x80
 #define FAL_PHY_INTR_POE_STATUS   0x100
 
+    /* phy eee */
+#define FAL_PHY_EEE_10BASE_T  0x1
+#define FAL_PHY_EEE_100BASE_T  0x2
+#define FAL_PHY_EEE_1000BASE_T  0x4
+#define FAL_PHY_EEE_2500BASE_T  0x8
+#define FAL_PHY_EEE_5000BASE_T  0x10
+#define FAL_PHY_EEE_10000BASE_T  0x20
+
     typedef enum
     {
         FAL_NO_HEADER_EN = 0,
@@ -259,6 +267,16 @@
 } fal_port_counter_info_t;
 
 /*above is new add for malibu phy*/
+typedef struct {
+	a_uint32_t enable;
+	a_uint32_t capability;
+	a_uint32_t lpi_sleep_timer;
+	a_uint32_t advertisement;
+	a_uint32_t lpi_tx_enable;
+	a_uint32_t eee_status;
+	a_uint32_t lpi_wakeup_timer;
+	a_uint32_t link_partner_advertisement;
+} fal_port_eee_cfg_t;
 /*qca808x_end*/
 enum
 {
@@ -705,6 +723,12 @@
  fal_port_promisc_mode_set(a_uint32_t dev_id,fal_port_t port_id,a_bool_t enable);
  sw_error_t
  fal_port_promisc_mode_get(a_uint32_t dev_id,fal_port_t port_id,a_bool_t *enable);
+ sw_error_t
+fal_port_interface_eee_cfg_set(a_uint32_t dev_id, fal_port_t port_id,
+	fal_port_eee_cfg_t *port_eee_cfg);
+sw_error_t
+fal_port_interface_eee_cfg_get(a_uint32_t dev_id, fal_port_t port_id,
+	fal_port_eee_cfg_t *port_eee_cfg);
 /*qca808x_start*/
 #ifdef __cplusplus
 }
diff --git a/include/shell/shell_io.h b/include/shell/shell_io.h
index c8169b7..28cc1a2 100755
--- a/include/shell/shell_io.h
+++ b/include/shell/shell_io.h
@@ -634,6 +634,11 @@
 /*qca808x_start*/
 sw_error_t
 cmd_data_check_interface_mode(char *cmd_str, a_uint32_t * arg_val, a_uint32_t size);
+sw_error_t
+cmd_data_check_port_eee_config(char *cmd_str, void * val, a_uint32_t size);
+
+void
+cmd_data_print_port_eee_config(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size);
 /*qca808x_end*/
 sw_error_t
 cmd_data_check_newadr_lrn(char *cmd_str, void * val, a_uint32_t size);
diff --git a/src/fal_uk/fal_port_ctrl.c b/src/fal_uk/fal_port_ctrl.c
index 58a516b..0849de2 100755
--- a/src/fal_uk/fal_port_ctrl.c
+++ b/src/fal_uk/fal_port_ctrl.c
@@ -882,3 +882,26 @@
 
 	return rv;
 }
+sw_error_t
+fal_port_interface_eee_cfg_set(a_uint32_t dev_id, fal_port_t port_id,
+	fal_port_eee_cfg_t *port_eee_cfg)
+{
+	sw_error_t rv;
+
+	rv = sw_uk_exec(SW_API_PT_INTERFACE_EEE_CFG_SET, dev_id, port_id, port_eee_cfg);
+
+	return rv;
+}
+sw_error_t
+fal_port_interface_eee_cfg_get(a_uint32_t dev_id, fal_port_t port_id,
+	fal_port_eee_cfg_t *port_eee_cfg)
+
+{
+	sw_error_t rv;
+
+	rv = sw_uk_exec(SW_API_PT_INTERFACE_EEE_CFG_GET, dev_id, port_id, port_eee_cfg);
+
+	return rv;
+
+    return rv;
+}
\ No newline at end of file
diff --git a/src/shell/shell_config.c b/src/shell/shell_config.c
index ab2cc5d..62c1ca6 100755
--- a/src/shell/shell_config.c
+++ b/src/shell/shell_config.c
@@ -121,6 +121,8 @@
             {"srcfilter", "get", "get port source filter bypass", "<port_id>", SW_API_PT_SOURCE_FILTER_GET, NULL},
             {"frameMaxSize", "get", "get port frame max size", "<port_id>", SW_API_PT_FRAME_MAX_SIZE_GET},
             {"frameMaxSize", "set", "set port frame max size", "<port_id> <frame_max_size>", SW_API_PT_FRAME_MAX_SIZE_SET},
+            {"eeecfg", "set", "set interface eee info", "<port_id>", SW_API_PT_INTERFACE_EEE_CFG_SET, NULL},
+            {"eeecfg", "get", "get interface eee info", "<port_id>", SW_API_PT_INTERFACE_EEE_CFG_GET, NULL},
 /*qca808x_start*/
             {NULL, NULL, NULL, NULL, (int)NULL, NULL},/*end of desc*/
         },
diff --git a/src/shell/shell_io.c b/src/shell/shell_io.c
index 1abc42e..a6470f9 100755
--- a/src/shell/shell_io.c
+++ b/src/shell/shell_io.c
@@ -245,6 +245,7 @@
 /*qca808x_start*/
 	SW_TYPE_DEF(SW_CROSSOVER_MODE, cmd_data_check_crossover_mode, cmd_data_print_crossover_mode),
     SW_TYPE_DEF(SW_CROSSOVER_STATUS, cmd_data_check_crossover_status, cmd_data_print_crossover_status),
+	SW_TYPE_DEF(SW_PORT_EEE_CONFIG, cmd_data_check_port_eee_config, cmd_data_print_port_eee_config),
 /*qca808x_end*/
     SW_TYPE_DEF(SW_PREFER_MEDIUM, cmd_data_check_prefer_medium, cmd_data_print_prefer_medium),
     SW_TYPE_DEF(SW_FIBER_MODE, cmd_data_check_fiber_mode, cmd_data_print_fiber_mode),
@@ -8939,6 +8940,228 @@
 {
     dprintf("[%s]:%d", param_name, *(a_uint32_t *) buf);
 }
+sw_error_t
+cmd_data_check_port_eee_config(char *cmd_str, void * val, a_uint32_t size)
+{
+    char *cmd;
+    sw_error_t rv;
+    fal_port_eee_cfg_t cfg;
+
+    aos_mem_zero(&cfg, sizeof (fal_port_eee_cfg_t));
+
+    do
+    {
+        cmd = get_sub_cmd("eee_enable", "yes");
+        SW_RTN_ON_NULL_PARAM(cmd);
+
+        if (!strncasecmp(cmd, "quit", 4))
+        {
+
+            return SW_BAD_VALUE;
+        }
+        else if (!strncasecmp(cmd, "help", 4))
+        {
+            dprintf("usage: <yes/no/y/n>\n");
+            rv = SW_BAD_VALUE;
+        }
+        else
+        {
+            rv = cmd_data_check_confirm(cmd, A_FALSE, &(cfg.enable),
+                                        sizeof (a_bool_t));
+            if (SW_OK != rv)
+                dprintf("usage: <yes/no/y/n>\n");
+        }
+    }
+    while (talk_mode && (SW_OK != rv));
+    do
+    {
+        cmd = get_sub_cmd("eee_capability", "0-0xffff");
+		SW_RTN_ON_NULL_PARAM(cmd);
+
+        if (!strncasecmp(cmd, "quit", 4))
+        {
+            return SW_BAD_VALUE;
+        }
+        else if (!strncasecmp(cmd, "help", 4))
+        {
+            dprintf("usage: integer\n");
+            rv = SW_BAD_VALUE;
+        }
+        else
+        {
+            rv = cmd_data_check_uint32(cmd, &(cfg.capability), sizeof (a_uint32_t));
+            if (SW_OK != rv)
+                dprintf("usage: integer\n");
+        }
+    }
+    while (talk_mode && (SW_OK != rv));
+
+    do
+    {
+        cmd = get_sub_cmd("lpi_sleep_timer", "0-0xffff");
+		SW_RTN_ON_NULL_PARAM(cmd);
+
+        if (!strncasecmp(cmd, "quit", 4))
+        {
+            return SW_BAD_VALUE;
+        }
+        else if (!strncasecmp(cmd, "help", 4))
+        {
+            dprintf("usage: integer\n");
+            rv = SW_BAD_VALUE;
+        }
+        else
+        {
+            rv = cmd_data_check_uint32(cmd, &(cfg.lpi_sleep_timer), sizeof (a_uint32_t));
+            if (SW_OK != rv)
+                dprintf("usage: integer\n");
+        }
+    }
+    while (talk_mode && (SW_OK != rv));
+
+    do
+    {
+        cmd = get_sub_cmd("advertisement", "0-0xffff");
+		SW_RTN_ON_NULL_PARAM(cmd);
+
+        if (!strncasecmp(cmd, "quit", 4))
+        {
+            return SW_BAD_VALUE;
+        }
+        else if (!strncasecmp(cmd, "help", 4))
+        {
+            dprintf("usage: integer\n");
+            rv = SW_BAD_VALUE;
+        }
+        else
+        {
+            rv = cmd_data_check_uint32(cmd, &(cfg.advertisement), sizeof (a_uint32_t));
+            if (SW_OK != rv)
+                dprintf("usage: integer\n");
+        }
+    }
+    while (talk_mode && (SW_OK != rv));
+
+    do
+    {
+        cmd = get_sub_cmd("lpi_tx_enable", "0x1");
+		SW_RTN_ON_NULL_PARAM(cmd);
+
+        if (!strncasecmp(cmd, "quit", 4))
+        {
+            return SW_BAD_VALUE;
+        }
+        else if (!strncasecmp(cmd, "help", 4))
+        {
+            dprintf("usage: integer\n");
+            rv = SW_BAD_VALUE;
+        }
+        else
+        {
+            rv = cmd_data_check_uint32(cmd, &(cfg.lpi_tx_enable), sizeof (a_uint32_t));
+            if (SW_OK != rv)
+                dprintf("usage: integer\n");
+        }
+    }
+    while (talk_mode && (SW_OK != rv));
+
+    do
+    {
+        cmd = get_sub_cmd("eee_status", "0-0xffff");
+		SW_RTN_ON_NULL_PARAM(cmd);
+
+        if (!strncasecmp(cmd, "quit", 4))
+        {
+            return SW_BAD_VALUE;
+        }
+        else if (!strncasecmp(cmd, "help", 4))
+        {
+            dprintf("usage: integer\n");
+            rv = SW_BAD_VALUE;
+        }
+        else
+        {
+            rv = cmd_data_check_uint32(cmd, &(cfg.eee_status), sizeof (a_uint32_t));
+            if (SW_OK != rv)
+                dprintf("usage: integer\n");
+        }
+    }
+    while (talk_mode && (SW_OK != rv));
+
+    do
+    {
+        cmd = get_sub_cmd("lpi_wakeup_timer", "0-0xffff");
+		SW_RTN_ON_NULL_PARAM(cmd);
+
+        if (!strncasecmp(cmd, "quit", 4))
+        {
+            return SW_BAD_VALUE;
+        }
+        else if (!strncasecmp(cmd, "help", 4))
+        {
+            dprintf("usage: integer\n");
+            rv = SW_BAD_VALUE;
+        }
+        else
+        {
+            rv = cmd_data_check_uint32(cmd, &(cfg.lpi_wakeup_timer), sizeof (a_uint32_t));
+            if (SW_OK != rv)
+                dprintf("usage: integer\n");
+        }
+    }
+    while (talk_mode && (SW_OK != rv));
+
+    do
+    {
+        cmd = get_sub_cmd("link_partner_advertisement", "0-0xffff");
+		SW_RTN_ON_NULL_PARAM(cmd);
+
+        if (!strncasecmp(cmd, "quit", 4))
+        {
+            return SW_BAD_VALUE;
+        }
+        else if (!strncasecmp(cmd, "help", 4))
+        {
+            dprintf("usage: integer\n");
+            rv = SW_BAD_VALUE;
+        }
+        else
+        {
+            rv = cmd_data_check_uint32(cmd, &(cfg.link_partner_advertisement), sizeof (a_uint32_t));
+            if (SW_OK != rv)
+                dprintf("usage: integer\n");
+        }
+    }
+    while (talk_mode && (SW_OK != rv));
+
+    *(fal_port_eee_cfg_t *)val = cfg;
+    return SW_OK;
+}
+void
+cmd_data_print_port_eee_config(a_uint8_t * param_name, a_uint32_t * buf, a_uint32_t size)
+{
+    fal_port_eee_cfg_t *cfg;
+
+    cfg = (fal_port_eee_cfg_t *) buf;
+
+    if (A_TRUE == cfg->enable)
+    {
+        dprintf("\n[eee_enable]:yes  ");
+    }
+    else
+    {
+        dprintf("\n[eee_enable]:no  ");
+    }
+    dprintf("\n[eee_capability]:0x%x", cfg->capability);
+    dprintf("\n[eee_lpi_sleep_timer]:0x%x", cfg->lpi_sleep_timer);
+    dprintf("\n[eee_advertisement]:0x%x", cfg->advertisement);
+    dprintf("\n[eee_lpi_tx_enable]:0x%x", cfg->lpi_tx_enable);
+    dprintf("\n[eee_status]:0x%x  ", cfg->eee_status);
+    dprintf("\n[eee_lpi_wakeup_timer]:0x%x  ", cfg->lpi_wakeup_timer);
+    dprintf("\n[eee_link_partner_advertisement]:0x%x  ", cfg->link_partner_advertisement);
+
+    return;
+}
 
 char*
 cmd_cpu_mode(hsl_init_mode mode)