Merge "[qca-ssdk]: add HPPE rss hash UCI feature"
diff --git a/include/fal/fal_port_ctrl.h b/include/fal/fal_port_ctrl.h
index dd38918..741c73e 100755
--- a/include/fal/fal_port_ctrl.h
+++ b/include/fal/fal_port_ctrl.h
@@ -68,6 +68,7 @@
 #define FAL_PHY_ADV_10000T_FD    0x4000
 #define FAL_PHY_ADV_10000BX_FD    0x8000
 
+#define FAL_DEFAULT_MAX_FRAME_SIZE 0x5ee
 
 #define FAL_PHY_ADV_FE_SPEED_ALL   \
     (FAL_PHY_ADV_10T_HD | FAL_PHY_ADV_10T_FD | FAL_PHY_ADV_100TX_HD |\
diff --git a/include/hsl/hppe/hppe_init.h b/include/hsl/hppe/hppe_init.h
index 9423f70..4f52e2b 100755
--- a/include/hsl/hppe/hppe_init.h
+++ b/include/hsl/hppe/hppe_init.h
@@ -25,14 +25,19 @@
 #endif /* __cplusplus */
 
 #include "init/ssdk_init.h"
+
 #define MII_PHYADDR_C45 (1<<30)
 #define HPPE_GCC_UNIPHY_REG_INC 0x100
 #define HPPE_TO_XGMAC_PORT_ID(port_id)  (port_id - 5)
 #define HPPE_TO_GMAC_PORT_ID(port_id) (port_id -1)
+#define HPPE_MAX_FRAME_SIZE 0x3FFF
+#define HPPE_FCS_LEN  4
+
 #define HPPE_MUX_PORT1  5
 #define HPPE_MUX_PORT2  6
 #define HPPE_PORT_GMAC_TYPE	1
 #define HPPE_PORT_XGMAC_TYPE	2
+
 #define HPPE_UNIPHY_INSTANCE0	0
 #define HPPE_UNIPHY_INSTANCE1	1
 #define HPPE_UNIPHY_INSTANCE2	2
@@ -45,8 +50,8 @@
 #define HPPE_UNIPHY_INDIRECT_DATA  0x20
 
 sw_error_t hppe_init(a_uint32_t dev_id, ssdk_init_cfg *cfg);
-
-
+a_bool_t hppe_mac_port_valid_check(fal_port_t port_id);
+a_bool_t hppe_xgmac_port_check(fal_port_t port_id);
 sw_error_t hppe_cleanup(a_uint32_t dev_id);
 
 #ifdef __cplusplus
diff --git a/include/hsl/hppe/hppe_xgmacmib.h b/include/hsl/hppe/hppe_xgmacmib.h
index 15f1c2c..40997c6 100755
--- a/include/hsl/hppe/hppe_xgmacmib.h
+++ b/include/hsl/hppe/hppe_xgmacmib.h
@@ -20,96 +20,96 @@
 #ifndef _HPPE_XGMACMIB_H_
 #define _HPPE_XGMACMIB_H_
 
-#define MMC_CONTROL_MAX_ENTRY	7
-#define MMC_RECEIVE_INTERRUPT_MAX_ENTRY	7
-#define MMC_TRANSMIT_INTERRUPT_MAX_ENTRY	7
-#define MMC_RECEIVE_INTERRUPT_ENABLE_MAX_ENTRY	7
-#define MMC_TRANSMIT_INTERRUPT_ENABLE_MAX_ENTRY	7
-#define TX_OCTET_COUNT_GOOD_BAD_LOW_MAX_ENTRY	7
-#define TX_OCTET_COUNT_GOOD_BAD_HIGH_MAX_ENTRY	7
-#define TX_FRAME_COUNT_GOOD_BAD_LOW_MAX_ENTRY	7
-#define TX_FRAME_COUNT_GOOD_BAD_HIGH_MAX_ENTRY	7
-#define TX_BROADCAST_FRAMES_GOOD_LOW_MAX_ENTRY	7
-#define TX_BROADCAST_FRAMES_GOOD_HIGH_MAX_ENTRY	7
-#define TX_MULTICAST_FRAMES_GOOD_LOW_MAX_ENTRY	7
-#define TX_MULTICAST_FRAMES_GOOD_HIGH_MAX_ENTRY	7
-#define TX_64OCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	7
-#define TX_64OCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	7
-#define TX_65TO127OCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	7
-#define TX_65TO127OCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	7
-#define TX_128TO255OCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	7
-#define TX_128TO255OCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	7
-#define TX_256TO511OCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	7
-#define TX_256TO511OCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	7
-#define TX_512TO1023OCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	7
-#define TX_512TO1023OCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	7
-#define TX_1024TOMAXOCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	7
-#define TX_1024TOMAXOCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	7
-#define TX_UNICAST_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	7
-#define TX_UNICAST_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	7
-#define TX_MULTICAST_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	7
-#define TX_MULTICAST_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	7
-#define TX_BROADCAST_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	7
-#define TX_BROADCAST_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	7
-#define TX_UNDERFLOW_ERROR_FRAMES_LOW_MAX_ENTRY	7
-#define TX_UNDERFLOW_ERROR_FRAMES_HIGH_MAX_ENTRY	7
-#define TX_OCTET_COUNT_GOOD_LOW_MAX_ENTRY	7
-#define TX_OCTET_COUNT_GOOD_HIGH_MAX_ENTRY	7
-#define TX_FRAME_COUNT_GOOD_LOW_MAX_ENTRY	7
-#define TX_FRAME_COUNT_GOOD_HIGH_MAX_ENTRY	7
-#define TX_PAUSE_FRAMES_LOW_MAX_ENTRY	7
-#define TX_PAUSE_FRAMES_HIGH_MAX_ENTRY	7
-#define TX_VLAN_FRAMES_GOOD_LOW_MAX_ENTRY	7
-#define TX_VLAN_FRAMES_GOOD_HIGH_MAX_ENTRY	7
-#define TX_LPI_USEC_CNTR_MAX_ENTRY	7
-#define TX_LPI_TRAN_CNTR_MAX_ENTRY	7
-#define RX_FRAME_COUNT_GOOD_BAD_LOW_MAX_ENTRY	7
-#define RX_FRAME_COUNT_GOOD_BAD_HIGH_MAX_ENTRY	7
-#define RX_OCTET_COUNT_GOOD_BAD_LOW_MAX_ENTRY	7
-#define RX_OCTET_COUNT_GOOD_BAD_HIGH_MAX_ENTRY	7
-#define RX_OCTET_COUNT_GOOD_LOW_MAX_ENTRY	7
-#define RX_OCTET_COUNT_GOOD_HIGH_MAX_ENTRY	7
-#define RX_BROADCAST_FRAMES_GOOD_LOW_MAX_ENTRY	7
-#define RX_BROADCAST_FRAMES_GOOD_HIGH_MAX_ENTRY	7
-#define RX_MULTICAST_FRAMES_GOOD_LOW_MAX_ENTRY	7
-#define RX_MULTICAST_FRAMES_GOOD_HIGH_MAX_ENTRY	7
-#define RX_CRC_ERROR_FRAMES_LOW_MAX_ENTRY	7
-#define RX_CRC_ERROR_FRAMES_HIGH_MAX_ENTRY	7
-#define RX_RUNT_ERROR_FRAMES_MAX_ENTRY	7
-#define RX_JABBER_ERROR_FRAMES_MAX_ENTRY	7
-#define RX_UNDERSIZE_FRAMES_GOOD_MAX_ENTRY	7
-#define RX_OVERSIZE_FRAMES_GOOD_MAX_ENTRY	7
-#define RX_64OCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	7
-#define RX_64OCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	7
-#define RX_65TO127OCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	7
-#define RX_65TO127OCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	7
-#define RX_128TO255OCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	7
-#define RX_128TO255OCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	7
-#define RX_256TO511OCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	7
-#define RX_256TO511OCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	7
-#define RX_512TO1023OCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	7
-#define RX_512TO1023OCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	7
-#define RX_1024TOMAXOCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	7
-#define RX_1024TOMAXOCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	7
-#define RX_UNICAST_FRAMES_GOOD_LOW_MAX_ENTRY	7
-#define RX_UNICAST_FRAMES_GOOD_HIGH_MAX_ENTRY	7
-#define RX_LENGTH_ERROR_FRAMES_LOW_MAX_ENTRY	7
-#define RX_LENGTH_ERROR_FRAMES_HIGH_MAX_ENTRY	7
-#define RX_OUTOFRANGE_FRAMES_LOW_MAX_ENTRY	7
-#define RX_OUTOFRANGE_FRAMES_HIGH_MAX_ENTRY	7
-#define RX_PAUSE_FRAMES_LOW_MAX_ENTRY	7
-#define RX_PAUSE_FRAMES_HIGH_MAX_ENTRY	7
-#define RX_FIFOOVERFLOW_FRAMES_LOW_MAX_ENTRY	7
-#define RX_FIFOOVERFLOW_FRAMES_HIGH_MAX_ENTRY	7
-#define RX_VLAN_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	7
-#define RX_VLAN_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	7
-#define RX_WATCHDOG_ERROR_FRAMES_MAX_ENTRY	7
-#define RX_LPI_USEC_CNTR_MAX_ENTRY	7
-#define RX_LPI_TRAN_CNTR_MAX_ENTRY	7
-#define RX_DISCARD_FRAME_COUNT_GOOD_BAD_LOW_MAX_ENTRY	7
-#define RX_DISCARD_FRAME_COUNT_GOOD_BAD_HIGH_MAX_ENTRY	7
-#define RX_DISCARD_OCTET_COUNT_GOOD_BAD_LOW_MAX_ENTRY	7
-#define RX_DISCARD_OCTET_COUNT_GOOD_BAD_HIGH_MAX_ENTRY	7
+#define MMC_CONTROL_MAX_ENTRY	2
+#define MMC_RECEIVE_INTERRUPT_MAX_ENTRY	2
+#define MMC_TRANSMIT_INTERRUPT_MAX_ENTRY	2
+#define MMC_RECEIVE_INTERRUPT_ENABLE_MAX_ENTRY	2
+#define MMC_TRANSMIT_INTERRUPT_ENABLE_MAX_ENTRY	2
+#define TX_OCTET_COUNT_GOOD_BAD_LOW_MAX_ENTRY	2
+#define TX_OCTET_COUNT_GOOD_BAD_HIGH_MAX_ENTRY	2
+#define TX_FRAME_COUNT_GOOD_BAD_LOW_MAX_ENTRY	2
+#define TX_FRAME_COUNT_GOOD_BAD_HIGH_MAX_ENTRY	2
+#define TX_BROADCAST_FRAMES_GOOD_LOW_MAX_ENTRY	2
+#define TX_BROADCAST_FRAMES_GOOD_HIGH_MAX_ENTRY	 2
+#define TX_MULTICAST_FRAMES_GOOD_LOW_MAX_ENTRY	2
+#define TX_MULTICAST_FRAMES_GOOD_HIGH_MAX_ENTRY	2
+#define TX_64OCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	2
+#define TX_64OCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	2
+#define TX_65TO127OCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	2
+#define TX_65TO127OCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	2
+#define TX_128TO255OCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	2
+#define TX_128TO255OCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	2
+#define TX_256TO511OCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	2
+#define TX_256TO511OCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	2
+#define TX_512TO1023OCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	2
+#define TX_512TO1023OCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	2
+#define TX_1024TOMAXOCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	2
+#define TX_1024TOMAXOCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	2
+#define TX_UNICAST_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	2
+#define TX_UNICAST_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	2
+#define TX_MULTICAST_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	2
+#define TX_MULTICAST_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	2
+#define TX_BROADCAST_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	2
+#define TX_BROADCAST_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	2
+#define TX_UNDERFLOW_ERROR_FRAMES_LOW_MAX_ENTRY	2
+#define TX_UNDERFLOW_ERROR_FRAMES_HIGH_MAX_ENTRY	2
+#define TX_OCTET_COUNT_GOOD_LOW_MAX_ENTRY	 2
+#define TX_OCTET_COUNT_GOOD_HIGH_MAX_ENTRY	2
+#define TX_FRAME_COUNT_GOOD_LOW_MAX_ENTRY	 2
+#define TX_FRAME_COUNT_GOOD_HIGH_MAX_ENTRY	2
+#define TX_PAUSE_FRAMES_LOW_MAX_ENTRY	 2
+#define TX_PAUSE_FRAMES_HIGH_MAX_ENTRY	2
+#define TX_VLAN_FRAMES_GOOD_LOW_MAX_ENTRY	2
+#define TX_VLAN_FRAMES_GOOD_HIGH_MAX_ENTRY	2
+#define TX_LPI_USEC_CNTR_MAX_ENTRY	2
+#define TX_LPI_TRAN_CNTR_MAX_ENTRY	2
+#define RX_FRAME_COUNT_GOOD_BAD_LOW_MAX_ENTRY	2
+#define RX_FRAME_COUNT_GOOD_BAD_HIGH_MAX_ENTRY	2
+#define RX_OCTET_COUNT_GOOD_BAD_LOW_MAX_ENTRY	2
+#define RX_OCTET_COUNT_GOOD_BAD_HIGH_MAX_ENTRY	2
+#define RX_OCTET_COUNT_GOOD_LOW_MAX_ENTRY	2
+#define RX_OCTET_COUNT_GOOD_HIGH_MAX_ENTRY	2
+#define RX_BROADCAST_FRAMES_GOOD_LOW_MAX_ENTRY	2
+#define RX_BROADCAST_FRAMES_GOOD_HIGH_MAX_ENTRY	2
+#define RX_MULTICAST_FRAMES_GOOD_LOW_MAX_ENTRY	2
+#define RX_MULTICAST_FRAMES_GOOD_HIGH_MAX_ENTRY	2
+#define RX_CRC_ERROR_FRAMES_LOW_MAX_ENTRY	2
+#define RX_CRC_ERROR_FRAMES_HIGH_MAX_ENTRY	2
+#define RX_RUNT_ERROR_FRAMES_MAX_ENTRY	2
+#define RX_JABBER_ERROR_FRAMES_MAX_ENTRY	2
+#define RX_UNDERSIZE_FRAMES_GOOD_MAX_ENTRY	2
+#define RX_OVERSIZE_FRAMES_GOOD_MAX_ENTRY	2
+#define RX_64OCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	2
+#define RX_64OCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	2
+#define RX_65TO127OCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	2
+#define RX_65TO127OCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	2
+#define RX_128TO255OCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	2
+#define RX_128TO255OCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	2
+#define RX_256TO511OCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	2
+#define RX_256TO511OCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	2
+#define RX_512TO1023OCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	2
+#define RX_512TO1023OCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	2
+#define RX_1024TOMAXOCTETS_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	2
+#define RX_1024TOMAXOCTETS_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	2
+#define RX_UNICAST_FRAMES_GOOD_LOW_MAX_ENTRY	2
+#define RX_UNICAST_FRAMES_GOOD_HIGH_MAX_ENTRY	2
+#define RX_LENGTH_ERROR_FRAMES_LOW_MAX_ENTRY	2
+#define RX_LENGTH_ERROR_FRAMES_HIGH_MAX_ENTRY	2
+#define RX_OUTOFRANGE_FRAMES_LOW_MAX_ENTRY	2
+#define RX_OUTOFRANGE_FRAMES_HIGH_MAX_ENTRY	2
+#define RX_PAUSE_FRAMES_LOW_MAX_ENTRY	2
+#define RX_PAUSE_FRAMES_HIGH_MAX_ENTRY	2
+#define RX_FIFOOVERFLOW_FRAMES_LOW_MAX_ENTRY	2
+#define RX_FIFOOVERFLOW_FRAMES_HIGH_MAX_ENTRY	2
+#define RX_VLAN_FRAMES_GOOD_BAD_LOW_MAX_ENTRY	2
+#define RX_VLAN_FRAMES_GOOD_BAD_HIGH_MAX_ENTRY	2
+#define RX_WATCHDOG_ERROR_FRAMES_MAX_ENTRY	2
+#define RX_LPI_USEC_CNTR_MAX_ENTRY	2
+#define RX_LPI_TRAN_CNTR_MAX_ENTRY	2
+#define RX_DISCARD_FRAME_COUNT_GOOD_BAD_LOW_MAX_ENTRY	2
+#define RX_DISCARD_FRAME_COUNT_GOOD_BAD_HIGH_MAX_ENTRY	2
+#define RX_DISCARD_OCTET_COUNT_GOOD_BAD_LOW_MAX_ENTRY	2
+#define RX_DISCARD_OCTET_COUNT_GOOD_BAD_HIGH_MAX_ENTRY	2
 
 sw_error_t
 hppe_mmc_control_get(
diff --git a/src/adpt/hppe/adpt_hppe_mib.c b/src/adpt/hppe/adpt_hppe_mib.c
index dc2a516..70be1fd 100755
--- a/src/adpt/hppe/adpt_hppe_mib.c
+++ b/src/adpt/hppe/adpt_hppe_mib.c
@@ -24,13 +24,8 @@
 #include "hppe_xgmacmib_reg.h"
 #include "hppe_xgmacmib.h"
 
-#define to_xgmac_port_id(port_id)  (port_id - 5)
+#include "hppe_init.h"
 
-static a_bool_t
-xgmac_port_check(fal_port_t port_id)
-{
-	return ((port_id == 5) ||( port_id == 6));
-}
 sw_error_t
 adpt_hppe_mib_cpukeep_get(a_uint32_t dev_id, a_bool_t *enable)
 {
@@ -89,7 +84,7 @@
 	ADPT_NULL_POINT_CHECK(mib_info);
 	memset(mib_info, 0, sizeof(fal_mib_info_t));
 
-	port_id = port_id -1;
+	port_id = HPPE_TO_GMAC_PORT_ID(port_id);
 	hppe_rxbroad_get(dev_id, (a_uint32_t)port_id, (union rxbroad_u *)&mib_info->RxBroad);
 	hppe_rxpause_get(dev_id, (a_uint32_t)port_id, (union rxpause_u *)&mib_info->RxPause);
 	hppe_rxmulti_get(dev_id, (a_uint32_t)port_id, (union rxmulti_u *)&mib_info->RxMulti);
@@ -146,7 +141,7 @@
 	ADPT_NULL_POINT_CHECK(mib_info);
 	memset(mib_info, 0, sizeof(fal_mib_info_t));
 
-	port_id = port_id -1;
+	port_id = HPPE_TO_GMAC_PORT_ID(port_id);
 	hppe_txbroad_get(dev_id, (a_uint32_t)port_id, (union txbroad_u *)&mib_info->TxBroad);
 	hppe_txpause_get(dev_id, (a_uint32_t)port_id, (union txpause_u *)&mib_info->TxPause);
 	hppe_txmulti_get(dev_id, (a_uint32_t)port_id, (union txmulti_u *)&mib_info->TxMulti);
@@ -204,7 +199,6 @@
 sw_error_t
 adpt_hppe_mib_port_flush_counters(a_uint32_t dev_id, fal_port_t port_id)
 {
-	a_uint32_t gmac_port_id = 0, xgmac_port_id = 0;
 	union mmc_control_u mmc_control;
 
 	memset(&mmc_control, 0, sizeof(mmc_control));
@@ -213,14 +207,20 @@
 	if(port_id < 1 || port_id > 7)
 		return SW_BAD_PARAM;
 	/*GMAC*/
-	gmac_port_id = port_id -1;
-	hppe_mac_mib_ctrl_mib_reset_set(dev_id, gmac_port_id, A_TRUE);
-	hppe_mac_mib_ctrl_mib_reset_set(dev_id, gmac_port_id, A_FALSE);
+	if(!hppe_xgmac_port_check(port_id))
+	{
+		port_id = HPPE_TO_GMAC_PORT_ID(port_id);
+		hppe_mac_mib_ctrl_mib_reset_set(dev_id, port_id, A_TRUE);
+		hppe_mac_mib_ctrl_mib_reset_set(dev_id, port_id, A_FALSE);
+	}
 	/*XGMAC*/
-	xgmac_port_id = to_xgmac_port_id(port_id);
-	hppe_mmc_control_get(dev_id, xgmac_port_id, &mmc_control);
+	else
+	{
+		port_id = HPPE_TO_XGMAC_PORT_ID(port_id);
+		hppe_mmc_control_get(dev_id, port_id, &mmc_control);
 	mmc_control.bf.cntrst = 1;
-	hppe_mmc_control_set(dev_id, xgmac_port_id, &mmc_control);
+		hppe_mmc_control_set(dev_id, port_id, &mmc_control);
+	}
 
 	return SW_OK;
 }
@@ -251,7 +251,7 @@
 	ADPT_NULL_POINT_CHECK(mib_info);
 	memset(mib_info, 0, sizeof(fal_mib_info_t));
 
-	port_id = port_id -1;
+	port_id = HPPE_TO_GMAC_PORT_ID(port_id);
 	hppe_rxbroad_get(dev_id, (a_uint32_t)port_id, (union rxbroad_u *)&mib_info->RxBroad);
 	hppe_rxpause_get(dev_id, (a_uint32_t)port_id, (union rxpause_u *)&mib_info->RxPause);
 	hppe_rxmulti_get(dev_id, (a_uint32_t)port_id, (union rxmulti_u *)&mib_info->RxMulti);
@@ -332,12 +332,12 @@
 	ADPT_NULL_POINT_CHECK(mib_info);
 	memset(mib_info, 0, sizeof( * mib_info ));
 
-	if(!(xgmac_port_check(port_id)))
+	if(!(hppe_xgmac_port_check(port_id)))
 	{
 		printk("this port is not xg port!\n");
 		return SW_FAIL;
 	}
-	port_id = to_xgmac_port_id(port_id);
+	port_id = HPPE_TO_XGMAC_PORT_ID(port_id);
 
 	/*get tx xgmib information*/
 	data_low = 0; data_high = 0;
@@ -581,12 +581,12 @@
 	ADPT_NULL_POINT_CHECK(mib_info);
 	memset(mib_info, 0, sizeof(* mib_info));
 
-	if(!(xgmac_port_check(port_id)))
+	if(!(hppe_xgmac_port_check(port_id)))
 	{
 		printk("this port is not xg port!\n");
 		return SW_FAIL;
 	}
-	port_id = to_xgmac_port_id(port_id);
+	port_id = HPPE_TO_XGMAC_PORT_ID(port_id);
 
 	/*get tx xgmib information*/
 	data_low = 0; data_high = 0;
@@ -700,12 +700,12 @@
 	ADPT_NULL_POINT_CHECK(mib_info);
 	memset(mib_info, 0, sizeof(* mib_info));
 
-	if(!(xgmac_port_check(port_id)))
+	if(!(hppe_xgmac_port_check(port_id)))
 	{
 		printk("this port is not xg port!\n");
 		return SW_FAIL;
 	}
-	port_id = to_xgmac_port_id(port_id);
+	port_id = HPPE_TO_XGMAC_PORT_ID(port_id);
 
 	/*get tx xgmib information*/
 	data_low = 0; data_high = 0;
diff --git a/src/adpt/hppe/adpt_hppe_portctrl.c b/src/adpt/hppe/adpt_hppe_portctrl.c
index 764eebd..9ab4a9a 100755
--- a/src/adpt/hppe/adpt_hppe_portctrl.c
+++ b/src/adpt/hppe/adpt_hppe_portctrl.c
@@ -36,20 +36,122 @@
 #include "hppe_init.h"
 #include "ssdk_init.h"
 
-extern a_bool_t hppe_mac_port_valid_check (fal_port_t port_id);
-
 static a_bool_t
 __adpt_hppe_port_phy_connected (a_uint32_t dev_id, fal_port_t port_id)
 {
   if (0 == port_id)
-    {
       return A_FALSE;
-    }
   else
-    {
-
       return hppe_mac_port_valid_check (port_id);
-    }
+}
+
+static sw_error_t
+__adpt_hppe_port_xgmac_loopback_get(a_uint32_t dev_id, fal_port_t port_id,
+				 a_bool_t * enable)
+{
+	sw_error_t rv = SW_OK;
+
+	port_id = HPPE_TO_XGMAC_PORT_ID(port_id);
+	rv = hppe_mac_rx_configuration_lm_get(dev_id, port_id, (a_uint32_t*)enable);
+
+	return rv;
+}
+
+static sw_error_t
+__adpt_hppe_port_gmac_loopback_get(a_uint32_t dev_id, fal_port_t port_id,
+				 a_bool_t * enable)
+{
+	sw_error_t rv = SW_OK;
+
+	port_id = HPPE_TO_GMAC_PORT_ID(port_id);
+	rv = hppe_mac_ctrl2_mac_loop_back_get(dev_id, port_id, (a_uint32_t*)enable);
+
+	return rv;
+}
+
+static sw_error_t
+__adpt_hppe_port_xgmac_loopback_set(a_uint32_t dev_id, fal_port_t port_id,
+				 a_bool_t enable)
+{
+	sw_error_t rv = SW_OK;
+
+	port_id = HPPE_TO_XGMAC_PORT_ID(port_id);
+	rv = hppe_mac_rx_configuration_lm_set(dev_id, port_id, (a_uint32_t)enable);
+
+	return rv;
+}
+
+static sw_error_t
+__adpt_hppe_port_gmac_loopback_set(a_uint32_t dev_id, fal_port_t port_id,
+				 a_bool_t enable)
+{
+	sw_error_t rv = SW_OK;
+
+	port_id = HPPE_TO_GMAC_PORT_ID(port_id);
+	rv = hppe_mac_ctrl2_mac_loop_back_set(dev_id, port_id, (a_uint32_t)enable);
+
+	return rv;
+}
+
+static sw_error_t
+__adpt_hppe_port_jumbo_size_set(a_uint32_t dev_id, fal_port_t port_id,
+		a_uint32_t jumbo_size)
+{
+	sw_error_t rv = SW_OK;
+
+	port_id = HPPE_TO_GMAC_PORT_ID(port_id);
+	rv = hppe_mac_jumbo_size_mac_jumbo_size_set(dev_id, port_id, jumbo_size);
+
+	return rv;
+}
+
+static sw_error_t
+__adpt_xgmac_port_max_frame_size_get(a_uint32_t dev_id, fal_port_t port_id,
+		a_uint32_t *max_frame)
+{
+	sw_error_t rv = SW_OK;
+
+	port_id = HPPE_TO_XGMAC_PORT_ID(port_id);
+	rv = hppe_mac_rx_configuration_gpsl_get(dev_id,port_id, max_frame);
+
+	return rv;
+}
+
+static sw_error_t
+__adpt_gmac_port_max_frame_size_get(a_uint32_t dev_id, fal_port_t port_id,
+		a_uint32_t *max_frame)
+{
+	sw_error_t rv = SW_OK;
+
+	port_id = HPPE_TO_GMAC_PORT_ID(port_id);
+	rv = hppe_mac_jumbo_size_mac_jumbo_size_get(dev_id, port_id, max_frame);
+
+	return rv;
+}
+
+static sw_error_t
+__adpt_xgmac_port_max_frame_size_set(a_uint32_t dev_id, fal_port_t port_id,
+		a_uint32_t max_frame)
+{
+	sw_error_t rv = SW_OK;
+
+	port_id = HPPE_TO_XGMAC_PORT_ID(port_id);
+	rv |= hppe_mac_tx_configuration_jd_set(dev_id, port_id, (a_uint32_t)A_TRUE);
+	rv |= hppe_mac_rx_configuration_gpsl_set(dev_id, port_id, max_frame);
+
+	return rv;
+}
+
+static sw_error_t
+__adpt_gmac_port_max_frame_size_set(a_uint32_t dev_id, fal_port_t port_id,
+		a_uint32_t max_frame)
+{
+	sw_error_t rv = SW_OK;
+
+	port_id = HPPE_TO_GMAC_PORT_ID(port_id);
+	rv |= hppe_mac_ctrl2_maxfr_set(dev_id, port_id, max_frame);
+
+	return rv;
 }
 static sw_error_t
 __adpt_xgmac_port_rx_status_get(a_uint32_t dev_id, fal_port_t port_id, a_uint32_t* port_rxmac_status)
@@ -639,20 +741,75 @@
 	return rv;
 
 }
+
+sw_error_t
+adpt_hppe_port_mru_set(a_uint32_t dev_id, fal_port_t port_id,
+		fal_mru_ctrl_t *ctrl)
+{
+	ADPT_DEV_ID_CHECK(dev_id);
+	ADPT_NULL_POINT_CHECK(ctrl);
+
+	hppe_mru_mtu_ctrl_tbl_mru_set(dev_id, port_id, ctrl->mru_size);
+	hppe_mru_mtu_ctrl_tbl_mru_cmd_set(dev_id, port_id, (a_uint32_t)ctrl->action);
+
+	return SW_OK;
+}
+
+sw_error_t
+adpt_hppe_port_mtu_set(a_uint32_t dev_id, fal_port_t port_id,
+		fal_mtu_ctrl_t *ctrl)
+{
+	union mru_mtu_ctrl_tbl_u mru_mtu_ctrl_tbl;
+
+	memset(&mru_mtu_ctrl_tbl, 0, sizeof(mru_mtu_ctrl_tbl));
+	ADPT_DEV_ID_CHECK(dev_id);
+	ADPT_NULL_POINT_CHECK(ctrl);
+
+	hppe_mru_mtu_ctrl_tbl_get(dev_id, port_id, &mru_mtu_ctrl_tbl);
+	mru_mtu_ctrl_tbl.bf.mtu = ctrl->mtu_size;
+	mru_mtu_ctrl_tbl.bf.mtu_cmd = (a_uint32_t)ctrl->action;
+	hppe_mru_mtu_ctrl_tbl_set(dev_id, port_id, &mru_mtu_ctrl_tbl);
+
+	if ((port_id >= 0) && (port_id <= 7))
+	{
+		hppe_mc_mtu_ctrl_tbl_mtu_set(dev_id, port_id, ctrl->mtu_size);
+		hppe_mc_mtu_ctrl_tbl_mtu_cmd_set(dev_id, port_id, (a_uint32_t)ctrl->action);
+	}
+
+	return SW_OK;
+}
+
 sw_error_t
 adpt_hppe_port_max_frame_size_set(a_uint32_t dev_id, fal_port_t port_id,
 		a_uint32_t max_frame)
 {
-	union mac_ctrl2_u mac_ctrl2;
+	fal_mtu_ctrl_t mtu_ctrl;
+	fal_mru_ctrl_t mru_ctrl;
+	a_uint32_t port_mac_type = 0;
+	sw_error_t rv = SW_OK;
 
-	memset(&mac_ctrl2, 0, sizeof(mac_ctrl2));
 	ADPT_DEV_ID_CHECK(dev_id);
+	mtu_ctrl.mtu_size = max_frame - HPPE_FCS_LEN;
+	mtu_ctrl.action = FAL_MAC_DROP;
+	rv |= adpt_hppe_port_mtu_set( dev_id, port_id, &mtu_ctrl);
+	mru_ctrl.mru_size = max_frame - HPPE_FCS_LEN;
+	mru_ctrl.action = FAL_MAC_DROP;
+	rv |= adpt_hppe_port_mru_set( dev_id, port_id, &mru_ctrl);
 
-	port_id = port_id -1;
-	hppe_mac_ctrl2_get(dev_id, port_id, &mac_ctrl2);
-	mac_ctrl2.bf.maxfr = max_frame;
-	hppe_mac_ctrl2_set(dev_id, port_id, &mac_ctrl2);
-	return SW_OK;
+	port_mac_type =qca_hppe_port_mac_type_get(dev_id, port_id);
+	if (port_mac_type == HPPE_PORT_XGMAC_TYPE)
+		rv |= __adpt_xgmac_port_max_frame_size_set( dev_id, port_id, max_frame);
+	else if (port_mac_type == HPPE_PORT_GMAC_TYPE)
+	{
+		/*for gmac, rxtoolong have counters when package length is longer than jumbo size and shorter than max frame size,
+		   when package length is longer than max frame size, the rxbadbyte have counters.*/
+		rv |= __adpt_hppe_port_jumbo_size_set(dev_id, port_id, max_frame);
+		rv |= __adpt_gmac_port_max_frame_size_set( dev_id, port_id, HPPE_MAX_FRAME_SIZE);
+	}
+	else
+		return SW_BAD_VALUE;
+
+	return rv;
 }
 
 sw_error_t
@@ -766,22 +923,6 @@
 }
 
 sw_error_t
-adpt_hppe_port_mru_set(a_uint32_t dev_id, fal_port_t port_id,
-		fal_mru_ctrl_t *ctrl)
-{
-	union mru_mtu_ctrl_tbl_u mru_mtu_ctrl_tbl;
-
-	memset(&mru_mtu_ctrl_tbl, 0, sizeof(mru_mtu_ctrl_tbl));
-	ADPT_DEV_ID_CHECK(dev_id);
-	ADPT_NULL_POINT_CHECK(ctrl);
-
-	hppe_mru_mtu_ctrl_tbl_get(dev_id, port_id, &mru_mtu_ctrl_tbl);
-	mru_mtu_ctrl_tbl.bf.mru = ctrl->mru_size;
-	mru_mtu_ctrl_tbl.bf.mru_cmd = (a_uint32_t)ctrl->action;
-
-	return hppe_mru_mtu_ctrl_tbl_set(dev_id, port_id, &mru_mtu_ctrl_tbl);
-}
-sw_error_t
 adpt_hppe_port_autoneg_status_get(a_uint32_t dev_id, fal_port_t port_id,
 					a_bool_t * status)
 {
@@ -919,23 +1060,21 @@
 adpt_hppe_port_mac_loopback_set(a_uint32_t dev_id, fal_port_t port_id,
 				 a_bool_t enable)
 {
-	union mac_ctrl2_u mac_ctrl2;
+	sw_error_t rv = SW_OK;
+	a_uint32_t port_mac_type = 0;
 
-	memset(&mac_ctrl2, 0, sizeof(mac_ctrl2));
 	ADPT_DEV_ID_CHECK(dev_id);
+	port_mac_type = qca_hppe_port_mac_type_get(dev_id, port_id);
+	if (port_mac_type == HPPE_PORT_XGMAC_TYPE)
+		rv = __adpt_hppe_port_xgmac_loopback_set( dev_id, port_id, enable);
+	else if(port_mac_type == HPPE_PORT_GMAC_TYPE)
+		rv = __adpt_hppe_port_gmac_loopback_set( dev_id, port_id, enable);
+	else
+		return SW_BAD_VALUE;
 
-	port_id = port_id - 1;
-	hppe_mac_ctrl2_get(dev_id, port_id, &mac_ctrl2);
-
-	if (A_TRUE == enable)
-		mac_ctrl2.bf.mac_loop_back = 1;
-	if (A_FALSE== enable)
-		mac_ctrl2.bf.mac_loop_back = 0;
-
-	hppe_mac_ctrl2_set(dev_id, port_id, &mac_ctrl2);
-
-	return SW_OK;
+	return rv;
 }
+
 sw_error_t
 adpt_hppe_port_phy_id_get(a_uint32_t dev_id, fal_port_t port_id,
 		      a_uint16_t * org_id, a_uint16_t * rev_id)
@@ -977,7 +1116,6 @@
 	ADPT_DEV_ID_CHECK(dev_id);
 	ADPT_NULL_POINT_CHECK(ctrl);
 
-
 	rv = hppe_mru_mtu_ctrl_tbl_get(dev_id, port_id, &mru_mtu_ctrl_tbl);
 
 	if( rv != SW_OK )
@@ -1208,42 +1346,6 @@
 }
 
 sw_error_t
-adpt_hppe_port_mtu_set(a_uint32_t dev_id, fal_port_t port_id,
-		fal_mtu_ctrl_t *ctrl)
-{
-	union mru_mtu_ctrl_tbl_u mru_mtu_ctrl_tbl;
-	union mac_jumbo_size_u mac_jumbo_ctrl;
-	union mc_mtu_ctrl_tbl_u mc_mtu_ctrl_tb;
-
-	memset(&mru_mtu_ctrl_tbl, 0, sizeof(mru_mtu_ctrl_tbl));
-	memset(&mac_jumbo_ctrl, 0, sizeof(mac_jumbo_ctrl));
-	memset(&mc_mtu_ctrl_tb, 0, sizeof(mc_mtu_ctrl_tb));
-	ADPT_DEV_ID_CHECK(dev_id);
-	ADPT_NULL_POINT_CHECK(ctrl);
-
-	if ((port_id > 0) && (port_id < 7))
-	{
-		hppe_mac_jumbo_size_get(dev_id, port_id - 1, &mac_jumbo_ctrl);
-		mac_jumbo_ctrl.bf.mac_jumbo_size = ctrl->mtu_size;
-		hppe_mac_jumbo_size_set(dev_id, port_id - 1, &mac_jumbo_ctrl);
-	}
-
-	hppe_mru_mtu_ctrl_tbl_get(dev_id, port_id, &mru_mtu_ctrl_tbl);
-	mru_mtu_ctrl_tbl.bf.mtu = ctrl->mtu_size;
-	mru_mtu_ctrl_tbl.bf.mtu_cmd = (a_uint32_t)ctrl->action;
-	hppe_mru_mtu_ctrl_tbl_set(dev_id, port_id, &mru_mtu_ctrl_tbl);
-
-	if ((port_id >= 0) && (port_id <= 7))
-	{
-		hppe_mc_mtu_ctrl_tbl_get(dev_id, port_id, &mc_mtu_ctrl_tb);
-		mc_mtu_ctrl_tb.bf.mtu = ctrl->mtu_size;
-		mc_mtu_ctrl_tb.bf.mtu_cmd = (a_uint32_t)ctrl->action;
-		hppe_mc_mtu_ctrl_tbl_set(dev_id, port_id, &mc_mtu_ctrl_tb);
-	}
-
-	return SW_OK;
-}
-sw_error_t
 adpt_hppe_port_link_status_get(a_uint32_t dev_id, fal_port_t port_id,
 				     a_bool_t * status)
 {
@@ -1376,28 +1478,29 @@
 	return rv;
 
 }
+
 sw_error_t
 adpt_hppe_port_max_frame_size_get(a_uint32_t dev_id, fal_port_t port_id,
 		a_uint32_t *max_frame)
 {
 	sw_error_t rv = SW_OK;
-	union mac_ctrl2_u mac_ctrl2;
+	a_uint32_t port_mac_type = 0;
 
-	memset(&mac_ctrl2, 0, sizeof(mac_ctrl2));
 	ADPT_DEV_ID_CHECK(dev_id);
 	ADPT_NULL_POINT_CHECK(max_frame);
 
+	port_mac_type =qca_hppe_port_mac_type_get(dev_id, port_id);
+	if (port_mac_type == HPPE_PORT_XGMAC_TYPE)
+		rv = __adpt_xgmac_port_max_frame_size_get( dev_id, port_id, max_frame);
+	else if (port_mac_type == HPPE_PORT_GMAC_TYPE)
+		rv = __adpt_gmac_port_max_frame_size_get( dev_id, port_id, max_frame);
+	else
+		return SW_BAD_VALUE;
 
-	rv = hppe_mac_ctrl2_get(dev_id, port_id, &mac_ctrl2);
-
-	if( rv != SW_OK )
-		return rv;
-
-	*max_frame = mac_ctrl2.bf.maxfr;
-
-	return SW_OK;
+	return rv;
 }
 
+
 sw_error_t
 adpt_hppe_port_combo_prefer_medium_set(a_uint32_t dev_id,
 					     a_uint32_t port_id,
@@ -1709,26 +1812,26 @@
 	return rv;
 
 }
+
 sw_error_t
 adpt_hppe_port_mac_loopback_get(a_uint32_t dev_id, fal_port_t port_id,
 				 a_bool_t * enable)
 {
 	sw_error_t rv = SW_OK;
-	union mac_ctrl2_u mac_ctrl2;
+	a_uint32_t port_mac_type = 0;
 
-	memset(&mac_ctrl2, 0, sizeof(mac_ctrl2));
 	ADPT_DEV_ID_CHECK(dev_id);
 	ADPT_NULL_POINT_CHECK(enable);
 
-	port_id = port_id - 1;
-	rv = hppe_mac_ctrl2_get(dev_id, port_id, &mac_ctrl2);
+	port_mac_type = qca_hppe_port_mac_type_get(dev_id, port_id);
+	if (port_mac_type == HPPE_PORT_XGMAC_TYPE)
+		rv = __adpt_hppe_port_xgmac_loopback_get( dev_id, port_id, enable);
+	else if (port_mac_type == HPPE_PORT_GMAC_TYPE)
+		rv = __adpt_hppe_port_gmac_loopback_get( dev_id, port_id, enable);
+	else
+		return SW_BAD_VALUE;
 
-	if( rv != SW_OK )
-		return rv;
-
-	*enable = mac_ctrl2.bf.mac_loop_back;
-
-	return SW_OK;
+	return rv;
 }
 
 sw_error_t
diff --git a/src/hsl/hppe/hppe_init.c b/src/hsl/hppe/hppe_init.c
index d589a4c..401e4b9 100755
--- a/src/hsl/hppe/hppe_init.c
+++ b/src/hsl/hppe/hppe_init.c
@@ -59,6 +59,10 @@
 	return hppe_cfg[0]->mac_mode;
 }
 
+a_bool_t hppe_xgmac_port_check(fal_port_t port_id)
+{
+	return ((port_id == 5) ||( port_id == 6));
+}
 a_bool_t hppe_mac_port_valid_check(fal_port_t port_id)
 {
 	a_uint32_t bitmap = 0;
diff --git a/src/init/ssdk_init.c b/src/init/ssdk_init.c
index fb80096..58046b6 100755
--- a/src/init/ssdk_init.c
+++ b/src/init/ssdk_init.c
@@ -3247,7 +3247,7 @@
 		qca_switch_reg_write(0, 0x00003008 + (xgmac_addr_delta*i), (a_uint8_t *)&val, 4);
 		val = 0x00000001;
 		qca_switch_reg_write(0, 0x00003090 + (xgmac_addr_delta*i), (a_uint8_t *)&val, 4);
-		val = 0x00000002;
+		val = 0xffff0002;
 		qca_switch_reg_write(0, 0x00003070 + (xgmac_addr_delta*i), (a_uint8_t *)&val, 4);
 		val = 0x40000;
 		qca_switch_reg_write(0, 0x00003050 + (xgmac_addr_delta*i), (a_uint8_t *)&val, 4);
@@ -4033,6 +4033,7 @@
 #else
 	struct net_device *dev = (struct net_device *)ptr;
 #endif
+	a_uint32_t port_id, eth_num = 3, dev_id = 0;
 
 	switch (event) {
 #ifdef IN_RFS
@@ -4049,16 +4050,21 @@
 			break;
 #endif
 #endif
-
 		case NETDEV_CHANGEMTU:
 			if(dev->type == ARPHRD_ETHER) {
-				fal_frame_max_size_set(0, dev->mtu + 18);
+				if(qca_phy_priv_global->version== QCA_VER_HPPE)
+				{
+					port_id = dev->name[eth_num] - '0' +1;
+					fal_port_max_frame_size_set(dev_id, port_id, dev->mtu);
+				}
+				else
+					fal_frame_max_size_set(0, dev->mtu + 18);
 			}
 			break;
-                }
+	}
+
 	return NOTIFY_DONE;
 }
-//#endif
 
 static int __init regi_init(void)
 {
diff --git a/src/shell_lib/shell_io.c b/src/shell_lib/shell_io.c
index 4ba0dfa..5798b47 100755
--- a/src/shell_lib/shell_io.c
+++ b/src/shell_lib/shell_io.c
@@ -707,7 +707,7 @@
 
     do
     {
-        cmd = get_sub_cmd("mtu_action", "0");
+        cmd = get_sub_cmd("mtu_action", "forward");
         SW_RTN_ON_NULL_PARAM(cmd);
 
         if (!strncasecmp(cmd, "quit", 4))
@@ -720,7 +720,7 @@
         }
         else
         {
-            rv = cmd_data_check_uint32(cmd, (a_uint32_t *)&(entry.action), sizeof (a_uint32_t));
+            rv = cmd_data_check_maccmd(cmd, &(entry.action), sizeof (a_uint32_t));
         }
     }
     while (talk_mode && (SW_OK != rv));
@@ -760,7 +760,7 @@
 
     do
     {
-        cmd = get_sub_cmd("mru_action", "0");
+        cmd = get_sub_cmd("mru_action", "forward");
         SW_RTN_ON_NULL_PARAM(cmd);
 
         if (!strncasecmp(cmd, "quit", 4))
@@ -773,7 +773,7 @@
         }
         else
         {
-            rv = cmd_data_check_uint32(cmd, (a_uint32_t *)&(entry.action), sizeof (a_uint32_t));
+            rv = cmd_data_check_maccmd(cmd, &(entry.action), sizeof (a_uint32_t));
         }
     }
     while (talk_mode && (SW_OK != rv));