Merge "[qca-ssdk] add pppoe vrfid"
diff --git a/include/api/api_desc.h b/include/api/api_desc.h
index 47e339b..09531ec 100755
--- a/include/api/api_desc.h
+++ b/include/api/api_desc.h
@@ -358,18 +358,18 @@
#define SW_API_PT_MAGIC_FRAME_MAC_SET_DESC \
SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \
SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_SET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \
- SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_SET, SW_MACADDR, sizeof(fal_mac_addr_t), SW_PARAM_PTR|SW_PARAM_IN, "Magic mac"),
+ SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_SET, SW_MACADDR, sizeof(fal_mac_addr_t), SW_PARAM_PTR|SW_PARAM_IN, "[Magic mac]"),
#define SW_API_PT_MAGIC_FRAME_MAC_GET_DESC \
SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \
SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \
- SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_GET, SW_MACADDR, sizeof(fal_mac_addr_t), SW_PARAM_PTR|SW_PARAM_OUT, "Magic mac"),
+ SW_PARAM_DEF(SW_API_PT_MAGIC_FRAME_MAC_GET, SW_MACADDR, sizeof(fal_mac_addr_t), SW_PARAM_PTR|SW_PARAM_OUT, "[Magic mac]"),
#define SW_API_PT_PHY_ID_GET_DESC \
SW_PARAM_DEF(SW_API_PT_PHY_ID_GET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \
SW_PARAM_DEF(SW_API_PT_PHY_ID_GET, SW_UINT32, 4, SW_PARAM_IN, "Port ID"), \
- SW_PARAM_DEF(SW_API_PT_PHY_ID_GET, SW_UINT16, 4, SW_PARAM_PTR|SW_PARAM_OUT, "Org ID"), \
- SW_PARAM_DEF(SW_API_PT_PHY_ID_GET, SW_UINT16, 4, SW_PARAM_PTR|SW_PARAM_OUT, "Rev ID"),
+ SW_PARAM_DEF(SW_API_PT_PHY_ID_GET, SW_UINT16, 2, SW_PARAM_PTR|SW_PARAM_OUT, "Org ID"), \
+ SW_PARAM_DEF(SW_API_PT_PHY_ID_GET, SW_UINT16, 2, SW_PARAM_PTR|SW_PARAM_OUT, "Rev ID"),
#define SW_API_PT_WOL_STATUS_SET_DESC \
SW_PARAM_DEF(SW_API_PT_WOL_STATUS_SET, SW_UINT32, 4, SW_PARAM_IN, "Dev ID"), \
diff --git a/include/hsl/dess/dess_init.h b/include/hsl/dess/dess_init.h
index d8a2192..389f00b 100755
--- a/include/hsl/dess/dess_init.h
+++ b/include/hsl/dess/dess_init.h
@@ -1,44 +1,55 @@
-/*
- * Copyright (c) 2014, The Linux Foundation. All rights reserved.
- * Permission to use, copy, modify, and/or distribute this software for
- * any purpose with or without fee is hereby granted, provided that the
- * above copyright notice and this permission notice appear in all copies.
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-
-/**
- * @defgroup dess_init DESS_INIT
- * @{
- */
-#ifndef _DESS_INIT_H_
-#define _DESS_INIT_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#include "init/ssdk_init.h"
-
-
- sw_error_t
- dess_init(a_uint32_t dev_id, ssdk_init_cfg *cfg);
-
-
- sw_error_t
- dess_cleanup(a_uint32_t dev_id);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _DESS_INIT_H_ */
-/**
- * @}
- */
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all copies.
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
+/**
+ * @defgroup dess_init DESS_INIT
+ * @{
+ */
+#ifndef _DESS_INIT_H_
+#define _DESS_INIT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include "init/ssdk_init.h"
+
+enum dess_port_cfg {
+ PORT_WRAPPER_PSGMII = 0,
+ PORT_WRAPPER_PSGMII_RGMII5,
+ PORT_WRAPPER_PSGMII_RMII0,
+ PORT_WRAPPER_PSGMII_RMII1,
+ PORT_WRAPPER_PSGMII_RMII0_RMII1,
+ PORT_WRAPPER_PSGMII_RGMII4,
+ PORT_WRAPPER_MAX
+};
+
+
+
+ sw_error_t
+ dess_init(a_uint32_t dev_id, ssdk_init_cfg *cfg);
+
+
+ sw_error_t
+ dess_cleanup(a_uint32_t dev_id);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _DESS_INIT_H_ */
+/**
+ * @}
+ */
diff --git a/include/hsl/phy/malibu_phy.h b/include/hsl/phy/malibu_phy.h
index 4d1c02d..ff78ba9 100755
--- a/include/hsl/phy/malibu_phy.h
+++ b/include/hsl/phy/malibu_phy.h
@@ -37,6 +37,7 @@
#define BIT_1 1
#define BIT_0 0
#define COMBO_PHY_ID 4
+#define PSGMII_ID 5
/* PHY Registers */
#define MALIBU_PHY_CONTROL 0
@@ -71,8 +72,12 @@
#define MALIBU_PHY_MMD3_WOL_MAGIC_MAC_CTRL3 0x804c
#define MALIBU_PHY_MMD3_WOL_CTRL 0x8012
+#define MALIBU_PSGMII_FIFI_CTRL 0x6e
+#define MALIBU_PSGMII_CALIB_CTRL 0x27
+
#define MALIBU_PHY_MMD7_NUM 7
#define MALIBU_PHY_MMD3_NUM 3
+#define MALIBU_PHY_MMD1_NUM 1
#define MALIBU_PHY_SGMII_STATUS 0x1a /* sgmii_status Register */
#define MALIBU_PHY4_AUTO_SGMII_SELECT 0x40
diff --git a/include/init/ssdk_init.h b/include/init/ssdk_init.h
index e2dd01f..ddad523 100755
--- a/include/init/ssdk_init.h
+++ b/include/init/ssdk_init.h
@@ -116,8 +116,9 @@
/* chip specific parameter */
void * chip_spec_cfg;
- /* port cfg */
- ssdk_port_cfg port_cfg;
+ /* port cfg */
+ ssdk_port_cfg port_cfg;
+ a_uint32_t mac_mode;
} ssdk_init_cfg;
typedef struct
diff --git a/include/init/ssdk_plat.h b/include/init/ssdk_plat.h
index 0ce16bd..75df79d 100755
--- a/include/init/ssdk_plat.h
+++ b/include/init/ssdk_plat.h
@@ -172,6 +172,11 @@
};
+struct qca961x_mdio_data {
+ struct mii_bus *mii_bus;
+ void __iomem *membase;
+ int phy_irq[PHY_MAX_ADDR];
+};
#define qca_phy_priv_get(_dev) \
container_of(_dev, struct qca_phy_priv, sw_dev)
diff --git a/src/hsl/dess/dess_init.c b/src/hsl/dess/dess_init.c
index 1c37df1..c45f066 100755
--- a/src/hsl/dess/dess_init.c
+++ b/src/hsl/dess/dess_init.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all copies.
@@ -57,39 +57,21 @@
PORT0 always connect to external DMA device.
MAC1..MAC4 connect to internal PHY0..PHY3.
*/
-enum dess_port_cfg {
- PORT_WRAPPER_PSGMII = 0,
- PORT_WRAPPER_PSGMII_RGMII,
- PORT_WRAPPER_PSGMII_RMII0,
- PORT_WRAPPER_PSGMII_RMII1,
- PORT_WRAPPER_PSGMII_RMII0_RMII1,
- PORT_WRAPPER_SGMII,
- PORT_WRAPPER_SGMII_RGMII,
- PORT_WRAPPER_SGMII_RMII0,
- PORT_WRAPPER_SGMII_RMII1,
- PORT_WRAPPER_SGMII_RMII0_RMII1,
- PORT_WRAPPER_MAX
-};
+
a_uint32_t dess_pbmp[PORT_WRAPPER_MAX] = {
((1<<1) | (1<<2) | (1<<3) | (1<<4) | (1<<5)), /*PORT_WRAPPER_PSGMII*/
- ((1<<1) | (1<<2) | (1<<3) | (1<<4) | (1<<5)), /*PORT_WRAPPER_PSGMII_RGMII*/
+ ((1<<1) | (1<<2) | (1<<3) | (1<<4) | (1<<5)), /*PORT_WRAPPER_PSGMII_RGMII5*/
((1<<1) | (1<<2) | (1<<3) | (1<<4) | (1<<5)), /*PORT_WRAPPER_PSGMII_RMII0*/
((1<<1) | (1<<2) | (1<<3) | (1<<4) | (1<<5)), /*PORT_WRAPPER_PSGMII_RMII1*/
((1<<1) | (1<<2) | (1<<3) | (1<<4) | (1<<5)), /*PORT_WRAPPER_PSGMII_RMII0_RMII1*/
- (1<<1), /*PORT_WRAPPER_SGMII*/
- ((1<<1) | (1<<5)), /*PORT_WRAPPER_SGMII_RGMII*/
- ((1<<1) | (1<<5)), /*PORT_WRAPPER_SGMII_RMII0*/
- ((1<<1) | (1<<4)), /*PORT_WRAPPER_SGMII_RMII1*/
- ((1<<1) | (1<<4) | (1<<5)) /*PORT_WRAPPER_SGMII_RMII0_RMII1*/
+ ((1<<1) | (1<<2) | (1<<3) | (1<<4) | (1<<5)), /*PORT_WRAPPER_SGMII_RGMII4*/
};
enum dess_port_cfg dess_get_port_config()
{
- /*get the efused id*/
-
- return PORT_WRAPPER_PSGMII;
+ return dess_cfg[0]->mac_mode;
}
a_bool_t dess_mac_port_valid_check(fal_port_t port_id)
diff --git a/src/hsl/dess/dess_port_ctrl.c b/src/hsl/dess/dess_port_ctrl.c
index 2599321..618302d 100755
--- a/src/hsl/dess/dess_port_ctrl.c
+++ b/src/hsl/dess/dess_port_ctrl.c
@@ -73,7 +73,12 @@
{
return SW_BAD_PARAM;
}
+ rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id);
+ SW_RTN_ON_ERROR (rv);
+ rv = phy_drv->phy_duplex_set (dev_id, phy_id, duplex);
+ SW_RTN_ON_ERROR (rv);
+#if 0
HSL_REG_ENTRY_GET (rv, dev_id, PORT_STATUS, port_id,
(a_uint8_t *) (®_val), sizeof (a_uint32_t));
@@ -126,6 +131,7 @@
HSL_REG_ENTRY_SET (rv, dev_id, PORT_STATUS, port_id,
(a_uint8_t *) (®_save), sizeof (a_uint32_t));
+ #endif
return rv;
}
@@ -134,7 +140,8 @@
fal_port_duplex_t * pduplex)
{
sw_error_t rv = SW_OK;
- a_uint32_t reg, field;
+ a_uint32_t phy_id,reg, field;
+ hsl_phy_ops_t *phy_drv;
HSL_DEV_ID_CHECK (dev_id);
@@ -143,6 +150,17 @@
return SW_BAD_PARAM;
}
+ SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id));
+ if (NULL == phy_drv->phy_duplex_get)
+ return SW_NOT_SUPPORTED;
+
+ rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id);
+ SW_RTN_ON_ERROR (rv);
+
+ rv = phy_drv->phy_duplex_get (dev_id, phy_id, pduplex);
+ SW_RTN_ON_ERROR (rv);
+
+#if 0
HSL_REG_ENTRY_GET (rv, dev_id, PORT_STATUS, port_id,
(a_uint8_t *) (®), sizeof (a_uint32_t));
SW_GET_FIELD_BY_REG (PORT_STATUS, DUPLEX_MODE, field, reg);
@@ -155,6 +173,8 @@
*pduplex = FAL_HALF_DUPLEX;
}
+#endif
+
return rv;
}
@@ -182,6 +202,12 @@
return SW_BAD_PARAM;
}
+ rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id);
+ SW_RTN_ON_ERROR (rv);
+
+ rv = phy_drv->phy_speed_set (dev_id, phy_id, speed);
+ SW_RTN_ON_ERROR (rv);
+#if 0
HSL_REG_ENTRY_GET (rv, dev_id, PORT_STATUS, port_id,
(a_uint8_t *) (®_val), sizeof (a_uint32_t));
@@ -243,6 +269,7 @@
HSL_REG_ENTRY_SET (rv, dev_id, PORT_STATUS, port_id,
(a_uint8_t *) (®_save), sizeof (a_uint32_t));
+ #endif
return rv;
}
@@ -251,7 +278,8 @@
fal_port_speed_t * pspeed)
{
sw_error_t rv = SW_OK;
- a_uint32_t reg, field;
+ a_uint32_t phy_id,reg, field;
+ hsl_phy_ops_t *phy_drv;
HSL_DEV_ID_CHECK (dev_id);
@@ -260,6 +288,17 @@
return SW_BAD_PARAM;
}
+ SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get (dev_id));
+ if (NULL == phy_drv->phy_speed_get)
+ return SW_NOT_SUPPORTED;
+
+ rv = hsl_port_prop_get_phyid (dev_id, port_id, &phy_id);
+ SW_RTN_ON_ERROR (rv);
+
+ rv = phy_drv->phy_speed_get (dev_id, phy_id, pspeed);
+ SW_RTN_ON_ERROR (rv);
+
+#if 0
HSL_REG_ENTRY_GET (rv, dev_id, PORT_STATUS, port_id,
(a_uint8_t *) (®), sizeof (a_uint32_t));
SW_RTN_ON_ERROR (rv);
@@ -282,6 +321,7 @@
*pspeed = FAL_SPEED_BUTT;
rv = SW_READ_ERROR;
}
+#endif
return rv;
}
diff --git a/src/hsl/phy/malibu_phy.c b/src/hsl/phy/malibu_phy.c
index ec7f548..7b873de 100755
--- a/src/hsl/phy/malibu_phy.c
+++ b/src/hsl/phy/malibu_phy.c
@@ -270,6 +270,26 @@
/******************************************************************************
*
+* malibu_phy_reset - reset the phy
+*
+* reset the phy
+*/
+sw_error_t malibu_phy_reset(a_uint32_t dev_id, a_uint32_t phy_id)
+{
+ a_uint16_t phy_data;
+
+ if (phy_id == COMBO_PHY_ID)
+ __phy_reg_pages_sel_by_active_medium(dev_id, phy_id);
+
+ phy_data = malibu_phy_reg_read(dev_id, phy_id, MALIBU_PHY_CONTROL);
+ malibu_phy_reg_write(dev_id, phy_id, MALIBU_PHY_CONTROL,
+ phy_data | MALIBU_CTRL_SOFTWARE_RESET);
+
+ return SW_OK;
+}
+
+/******************************************************************************
+*
* malibu_phy_set_powersave - set power saving status
*
* set power saving status
@@ -582,6 +602,7 @@
if (mode == PHY_MDIX_AUTO) {
phy_data |= MALIBU_PHY_MDIX_AUTO;
} else if (mode == PHY_MDIX_MDIX) {
+ phy_data &= ~MALIBU_PHY_MDIX_AUTO;
phy_data |= MALIBU_PHY_MDIX;
} else if (mode == PHY_MDIX_MDI) {
phy_data &= ~MALIBU_PHY_MDIX_AUTO;
@@ -591,6 +612,7 @@
malibu_phy_reg_write(dev_id, phy_id, MALIBU_PHY_SPEC_CONTROL, phy_data);
+ malibu_phy_reset(dev_id, phy_id);
return SW_OK;
}
@@ -732,7 +754,7 @@
{
a_uint16_t phy_data;
- phy_data == malibu_phy_mmd_read(dev_id, phy_id, MALIBU_PHY_MMD3_NUM,
+ phy_data = malibu_phy_mmd_read(dev_id, phy_id, MALIBU_PHY_MMD3_NUM,
MALIBU_PHY_MMD3_ADDR_REMOTE_LOOPBACK_CTRL);
if (enable == A_TRUE) {
@@ -760,7 +782,7 @@
{
a_uint16_t phy_data;
- phy_data == malibu_phy_mmd_read(dev_id, phy_id, MALIBU_PHY_MMD3_NUM,
+ phy_data = malibu_phy_mmd_read(dev_id, phy_id, MALIBU_PHY_MMD3_NUM,
MALIBU_PHY_MMD3_ADDR_REMOTE_LOOPBACK_CTRL);
if (phy_data & 0x0001) {
@@ -1065,26 +1087,6 @@
/******************************************************************************
*
-* malibu_phy_reset - reset the phy
-*
-* reset the phy
-*/
-sw_error_t malibu_phy_reset(a_uint32_t dev_id, a_uint32_t phy_id)
-{
- a_uint16_t phy_data;
-
- if (phy_id == COMBO_PHY_ID)
- __phy_reg_pages_sel_by_active_medium(dev_id, phy_id);
-
- phy_data = malibu_phy_reg_read(dev_id, phy_id, MALIBU_PHY_CONTROL);
- malibu_phy_reg_write(dev_id, phy_id, MALIBU_PHY_CONTROL,
- phy_data | MALIBU_CTRL_SOFTWARE_RESET);
-
- return SW_OK;
-}
-
-/******************************************************************************
-*
* malibu_phy_off - power off the phy
*
* Power off the phy
@@ -1608,88 +1610,6 @@
/******************************************************************************
*
-* malibu_phy_set_speed - Determines the speed of phy ports associated with the
-* specified device.
-*/
-sw_error_t
-malibu_phy_set_speed(a_uint32_t dev_id, a_uint32_t phy_id,
- fal_port_speed_t speed)
-{
- a_uint16_t phy_data = 0;
- a_uint16_t phy_status = 0;
-
- a_uint32_t autoneg, oldneg;
- fal_port_duplex_t old_duplex;
-
- if (phy_id == COMBO_PHY_ID) {
- if (MALIBU_PHY_MEDIUM_COPPER !=
- __phy_active_medium_get(dev_id, phy_id))
-
- return SW_NOT_SUPPORTED;
-
- __phy_reg_pages_sel(dev_id, phy_id, MALIBU_PHY_COPPER_PAGES);
- }
-
- if (FAL_SPEED_1000 == speed) {
- phy_data |= MALIBU_CTRL_SPEED_1000;
- } else if (FAL_SPEED_100 == speed) {
- phy_data |= MALIBU_CTRL_SPEED_100;
- } else if (FAL_SPEED_10 == speed) {
- phy_data |= MALIBU_CTRL_SPEED_10;
- } else {
- return SW_BAD_PARAM;
- }
-
- phy_data &= ~MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
-
- (void)malibu_phy_get_autoneg_adv(dev_id, phy_id, &autoneg);
- oldneg = autoneg;
- autoneg &= ~FAL_PHY_ADV_GE_SPEED_ALL;
-
- (void)malibu_phy_get_duplex(dev_id, phy_id, &old_duplex);
-
- if (old_duplex == FAL_FULL_DUPLEX) {
- phy_data |= MALIBU_CTRL_FULL_DUPLEX;
-
- if (FAL_SPEED_1000 == speed) {
- autoneg |= FAL_PHY_ADV_1000T_FD;
- } else if (FAL_SPEED_100 == speed) {
- autoneg |= FAL_PHY_ADV_100TX_FD;
- } else {
- autoneg |= FAL_PHY_ADV_10T_FD;
- }
- } else if (old_duplex == FAL_HALF_DUPLEX) {
- phy_data &= ~MALIBU_CTRL_FULL_DUPLEX;
-
- if (FAL_SPEED_100 == speed) {
- autoneg |= FAL_PHY_ADV_100TX_HD;
- } else {
- autoneg |= FAL_PHY_ADV_10T_HD;
- }
- } else {
- return SW_FAIL;
- }
-
- (void)malibu_phy_set_autoneg_adv(dev_id, phy_id, autoneg);
- (void)malibu_phy_restart_autoneg(dev_id, phy_id);
- if (malibu_phy_get_link_status(dev_id, phy_id)) {
- do {
- phy_status =
- malibu_phy_reg_read(dev_id, phy_id,
- MALIBU_PHY_STATUS);
- }
- while (!MALIBU_AUTONEG_DONE(phy_status));
- }
-
- malibu_phy_reg_write(dev_id, phy_id, MALIBU_PHY_CONTROL, phy_data);
- (void)malibu_phy_set_autoneg_adv(dev_id, phy_id, oldneg);
-
- return SW_OK;
-
-}
-
-/******************************************************************************
-*
* malibu_phy_get_duplex - Determines the speed of phy ports associated with the
* specified device.
*/
@@ -1716,6 +1636,80 @@
/******************************************************************************
*
+* malibu_phy_set_speed - Determines the speed of phy ports associated with the
+* specified device.
+*/
+sw_error_t
+malibu_phy_set_speed(a_uint32_t dev_id, a_uint32_t phy_id,
+ fal_port_speed_t speed)
+{
+ a_uint16_t phy_data = 0;
+ a_uint16_t phy_status = 0;
+
+ a_uint32_t autoneg, oldneg;
+ fal_port_duplex_t old_duplex;
+
+ if (phy_id == COMBO_PHY_ID) {
+ if (MALIBU_PHY_MEDIUM_COPPER !=
+ __phy_active_medium_get(dev_id, phy_id))
+
+ return SW_NOT_SUPPORTED;
+
+ __phy_reg_pages_sel(dev_id, phy_id, MALIBU_PHY_COPPER_PAGES);
+ }
+
+ phy_data = malibu_phy_reg_read(dev_id, phy_id, MALIBU_PHY_CONTROL);
+
+ malibu_phy_get_duplex(dev_id, phy_id, &old_duplex);
+
+ if (old_duplex == FAL_FULL_DUPLEX) {
+ phy_data |= MALIBU_CTRL_FULL_DUPLEX;
+
+ if (FAL_SPEED_1000 == speed) {
+ phy_data |= MALIBU_CTRL_SPEED_1000;
+ phy_data &= ~MALIBU_CTRL_SPEED_100;
+ phy_data |= MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
+ } else if (FAL_SPEED_100 == speed) {
+ phy_data |= MALIBU_CTRL_SPEED_100;
+ phy_data &= ~MALIBU_CTRL_SPEED_1000;
+ phy_data &= ~MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
+ } else if (FAL_SPEED_10 == speed){
+ phy_data &= ~MALIBU_CTRL_SPEED_100;
+ phy_data &= ~MALIBU_CTRL_SPEED_1000;
+ phy_data &= ~MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
+ } else {
+ return SW_BAD_PARAM;
+ }
+ } else if (old_duplex == FAL_HALF_DUPLEX) {
+ phy_data &= ~MALIBU_CTRL_FULL_DUPLEX;
+
+ if (FAL_SPEED_100 == speed) {
+ phy_data |= MALIBU_CTRL_SPEED_100;
+ phy_data &= ~MALIBU_CTRL_SPEED_1000;
+ phy_data &= ~MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
+ } else if (FAL_SPEED_10 == speed) {
+ phy_data &= ~MALIBU_CTRL_SPEED_100;
+ phy_data &= ~MALIBU_CTRL_SPEED_1000;
+ phy_data &= ~MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
+ } else if (FAL_SPEED_10000== speed){
+ phy_data |= MALIBU_CTRL_FULL_DUPLEX;
+ phy_data |= MALIBU_CTRL_SPEED_1000;
+ phy_data &= ~MALIBU_CTRL_SPEED_100;
+ phy_data |= MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
+ } else {
+ return SW_BAD_PARAM;
+ }
+ } else {
+ return SW_FAIL;
+ }
+
+ malibu_phy_reg_write(dev_id, phy_id, MALIBU_PHY_CONTROL, phy_data);
+ return SW_OK;
+
+}
+
+/******************************************************************************
+*
* malibu_phy_set_duplex - Determines the speed of phy ports associated with the
* specified device.
*/
@@ -1749,6 +1743,18 @@
} else {
return SW_BAD_PARAM;
}
+ } else {
+
+ if (duplex == FAL_FULL_DUPLEX) {
+ phy_data |= MALIBU_CTRL_FULL_DUPLEX;
+ phy_data &= ~MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
+ } else if (duplex == FAL_HALF_DUPLEX) {
+ phy_data &= ~MALIBU_CTRL_FULL_DUPLEX;
+ phy_data &= ~MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
+ } else {
+ return SW_BAD_PARAM;
+ }
+ }
malibu_phy_reg_write(dev_id, phy_id,
MALIBU_PHY_CONTROL,
phy_data);
@@ -1756,115 +1762,64 @@
return SW_OK;
}
- if (A_TRUE == malibu_phy_autoneg_status(dev_id, phy_id))
- phy_data &= ~MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
-
- (void)malibu_phy_get_autoneg_adv(dev_id, phy_id,
- &autoneg);
- oldneg = autoneg;
- autoneg &= ~FAL_PHY_ADV_BX_SPEED_ALL;
- (void)malibu_phy_get_speed(dev_id, phy_id, &old_speed);
-
- if (FAL_SPEED_1000 == old_speed) {
- phy_data |= MALIBU_CTRL_SPEED_1000;
- } else {
- return SW_FAIL;
- }
-
- if (duplex == FAL_FULL_DUPLEX) {
- phy_data |= MALIBU_CTRL_FULL_DUPLEX;
-
- if (FAL_SPEED_1000 == old_speed) {
- autoneg = FAL_PHY_ADV_1000BX_FD;
- }
- } else if (duplex == FAL_HALF_DUPLEX) {
- phy_data &= ~MALIBU_CTRL_FULL_DUPLEX;
-
- if (FAL_SPEED_1000 == old_speed) {
- autoneg = FAL_PHY_ADV_1000BX_HD;
- }
- } else {
- return SW_BAD_PARAM;
- }
-
- (void)malibu_phy_set_autoneg_adv(dev_id, phy_id,
- autoneg);
- (void)malibu_phy_restart_autoneg(dev_id, phy_id);
- if (malibu_phy_get_link_status(dev_id, phy_id)) {
- do {
- phy_status =
- malibu_phy_reg_read(dev_id, phy_id,
- MALIBU_PHY_STATUS);
- }
- while (!MALIBU_AUTONEG_DONE(phy_status));
- }
-
- malibu_phy_reg_write(dev_id, phy_id, MALIBU_PHY_CONTROL,
- phy_data);
- (void)malibu_phy_set_autoneg_adv(dev_id, phy_id,
- oldneg);
-
- return SW_OK;
-
} else {
__phy_reg_pages_sel(dev_id, phy_id,
MALIBU_PHY_COPPER_PAGES);
}
- }
- if (A_TRUE == malibu_phy_autoneg_status(dev_id, phy_id))
- phy_data &= ~MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
+ phy_data = malibu_phy_reg_read(dev_id, phy_id, MALIBU_PHY_CONTROL);
- (void)malibu_phy_get_autoneg_adv(dev_id, phy_id, &autoneg);
- oldneg = autoneg;
- autoneg &= ~FAL_PHY_ADV_GE_SPEED_ALL;
- (void)malibu_phy_get_speed(dev_id, phy_id, &old_speed);
+ malibu_phy_get_speed(dev_id, phy_id, &old_speed);
- if (FAL_SPEED_1000 == old_speed) {
- phy_data |= MALIBU_CTRL_SPEED_1000;
- } else if (FAL_SPEED_100 == old_speed) {
- phy_data |= MALIBU_CTRL_SPEED_100;
- } else if (FAL_SPEED_10 == old_speed) {
- phy_data |= MALIBU_CTRL_SPEED_10;
- } else {
- return SW_FAIL;
- }
+ if (old_speed == FAL_SPEED_1000) {
- if (duplex == FAL_FULL_DUPLEX) {
+ phy_data |= MALIBU_CTRL_SPEED_1000;
+ phy_data &= ~MALIBU_CTRL_SPEED_100;
+ phy_data |= MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
+
+ if (duplex == FAL_FULL_DUPLEX) {
phy_data |= MALIBU_CTRL_FULL_DUPLEX;
- if (FAL_SPEED_1000 == old_speed) {
- autoneg = FAL_PHY_ADV_1000T_FD;
- } else if (FAL_SPEED_100 == old_speed) {
- autoneg = FAL_PHY_ADV_100TX_FD;
+ } else if (duplex == FAL_HALF_DUPLEX) {
+
+ return SW_NOT_SUPPORTED;
} else {
- autoneg = FAL_PHY_ADV_10T_FD;
+ return SW_BAD_PARAM;
}
- } else if (duplex == FAL_HALF_DUPLEX) {
+ } else if (old_speed == FAL_SPEED_100) {
+ phy_data |= MALIBU_CTRL_SPEED_100;
+ phy_data &= ~MALIBU_CTRL_SPEED_1000;
+ phy_data &= ~MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
+
+ if (duplex == FAL_FULL_DUPLEX) {
+ phy_data |= MALIBU_CTRL_FULL_DUPLEX;
+
+ } else if (duplex == FAL_HALF_DUPLEX) {
+
phy_data &= ~MALIBU_CTRL_FULL_DUPLEX;
- if (FAL_SPEED_100 == old_speed) {
- autoneg = FAL_PHY_ADV_100TX_HD;
} else {
- autoneg = FAL_PHY_ADV_10T_HD;
- }
- } else {
return SW_BAD_PARAM;
- }
+ }
+ } else if (old_speed == FAL_SPEED_10) {
+ phy_data &= ~MALIBU_CTRL_SPEED_100;
+ phy_data &= ~MALIBU_CTRL_SPEED_1000;
+ phy_data &= ~MALIBU_CTRL_AUTONEGOTIATION_ENABLE;
- (void)malibu_phy_set_autoneg_adv(dev_id, phy_id, autoneg);
- (void)malibu_phy_restart_autoneg(dev_id, phy_id);
- if (malibu_phy_get_link_status(dev_id, phy_id)) {
- do {
- phy_status =
- malibu_phy_reg_read(dev_id, phy_id,
- MALIBU_PHY_STATUS);
+ if (duplex == FAL_FULL_DUPLEX) {
+ phy_data |= MALIBU_CTRL_FULL_DUPLEX;
+
+ } else if (duplex == FAL_HALF_DUPLEX) {
+
+ phy_data &= ~MALIBU_CTRL_FULL_DUPLEX;
+
+ } else {
+ return SW_BAD_PARAM;
}
- while (!MALIBU_AUTONEG_DONE(phy_status));
- }
-
- malibu_phy_reg_write(dev_id, phy_id, MALIBU_PHY_CONTROL, phy_data);
- (void)malibu_phy_set_autoneg_adv(dev_id, phy_id, oldneg);
+ } else {
+ return SW_FAIL;
+ }
+ malibu_phy_reg_write(dev_id, phy_id, MALIBU_PHY_CONTROL, phy_data);
return SW_OK;
}
@@ -2006,6 +1961,8 @@
malibu_phy_interface_set_mode(a_uint32_t dev_id, a_uint32_t phy_id, fal_port_interface_mode_t interface_mode)
{
a_uint16_t phy_data;
+ a_uint16_t phy_data1 = 0;
+
if (phy_id != COMBO_PHY_ID)
return SW_NOT_SUPPORTED;
phy_data = malibu_phy_reg_read(dev_id, phy_id, MALIBU_PHY_CHIP_CONFIG);
@@ -2027,6 +1984,17 @@
malibu_phy_reg_write(dev_id, phy_id, MALIBU_PHY_CHIP_CONFIG, phy_data);
+/* reset operation */
+ phy_data1 = malibu_phy_mmd_read(0, PSGMII_ID, MALIBU_PHY_MMD1_NUM,
+ MALIBU_PSGMII_CALIB_CTRL);
+ phy_data1 |= 0x4000;
+ malibu_phy_mmd_write(0, PSGMII_ID, MALIBU_PHY_MMD1_NUM,
+ MALIBU_PSGMII_CALIB_CTRL, phy_data1);
+
+ phy_data1 &= 0xbfff;
+ malibu_phy_mmd_write(0, PSGMII_ID, MALIBU_PHY_MMD1_NUM,
+ MALIBU_PSGMII_CALIB_CTRL, phy_data1);
+
return SW_OK;
}
@@ -2202,6 +2170,25 @@
return SW_OK;
}
+/******************************************************************************
+*
+* malibu_phy_hw_register init to avoid packet loss
+*
+*/
+sw_error_t
+malibu_phy_hw_init(void)
+{
+ a_uint16_t phy_data = 0;
+ phy_data = malibu_phy_mmd_read(0, PSGMII_ID, MALIBU_PHY_MMD1_NUM,
+ MALIBU_PSGMII_FIFI_CTRL);
+ phy_data &= 0xbfff;
+
+ malibu_phy_mmd_write(0, PSGMII_ID, MALIBU_PHY_MMD1_NUM,
+ MALIBU_PSGMII_FIFI_CTRL, phy_data);
+ return SW_OK;
+}
+
+
static int malibu_phy_probe(struct phy_device *pdev)
{
int ret;
@@ -2222,7 +2209,7 @@
malibu_phy_api_ops.phy_powersave_get = malibu_phy_get_powersave;
malibu_phy_api_ops.phy_cdt = malibu_phy_cdt;
malibu_phy_api_ops.phy_link_status_get = malibu_phy_get_link_status;
- malibu_phy_api_ops.phy_mdix_set = malibu_phy_set_mdix;
+ malibu_phy_api_ops.phy_mdix_set = malibu_phy_set_mdix;
malibu_phy_api_ops.phy_mdix_get = malibu_phy_get_mdix;
malibu_phy_api_ops.phy_mdix_status_get = malibu_phy_get_mdix_status;
malibu_phy_api_ops.phy_8023az_set = malibu_phy_set_8023az;
@@ -2249,13 +2236,16 @@
malibu_phy_api_ops.phy_magic_frame_mac_set = malibu_phy_set_magic_frame_mac;
malibu_phy_api_ops.phy_magic_frame_mac_get = malibu_phy_get_magic_frame_mac;
malibu_phy_api_ops.phy_wol_status_set = malibu_phy_set_wol_status;
- malibu_phy_api_ops.phy_wol_status_get = malibu_phy_set_wol_status;
+ malibu_phy_api_ops.phy_wol_status_get = malibu_phy_get_wol_status;
malibu_phy_api_ops.phy_interface_mode_set = malibu_phy_interface_set_mode;
malibu_phy_api_ops.phy_interface_mode_get = malibu_phy_interface_get_mode;
malibu_phy_api_ops.phy_interface_mode_status_get = malibu_phy_interface_get_mode_status;
ret = hsl_phy_api_ops_register(&malibu_phy_api_ops);
+
+ malibu_phy_hw_init();
+
return ret;
}
diff --git a/src/init/ssdk_init.c b/src/init/ssdk_init.c
index 794d1f9..06ff400 100755
--- a/src/init/ssdk_init.c
+++ b/src/init/ssdk_init.c
@@ -1115,8 +1115,13 @@
const __be32 *prop = NULL;
struct device_node *mdio_node = NULL;
struct platform_device *mdio_plat = NULL;
+ struct qca961x_mdio_data *mdio_data = NULL;
- mdio_node = of_find_compatible_node(NULL, NULL, "virtual,mdio-gpio");
+ if(ssdk_dt_global.switch_reg_access_mode == HSL_REG_LOCAL_BUS)
+ mdio_node = of_find_compatible_node(NULL, NULL, "qcom,qca961x-mdio");
+ else
+ mdio_node = of_find_compatible_node(NULL, NULL, "virtual,mdio-gpio");
+
if (!mdio_node) {
printk("getting virtual,mdio-gpio failed\n");
return 1;
@@ -1128,7 +1133,18 @@
return 1;
}
- miibus = dev_get_drvdata(&mdio_plat->dev);
+ if(ssdk_dt_global.switch_reg_access_mode == HSL_REG_LOCAL_BUS)
+ {
+ mdio_data = dev_get_drvdata(&mdio_plat->dev);
+ if (!mdio_data) {
+ printk("cannot get mdio_data reference from device data\n");
+ return 1;
+ }
+ miibus = mdio_data->mii_bus;
+ }
+ else
+ miibus = dev_get_drvdata(&mdio_plat->dev);
+
if (!miibus) {
printk("cannot get mii bus reference from device data\n");
return 1;
@@ -1188,6 +1204,9 @@
printk("ssdk_plat_init start\n");
mutex_init(&switch_mdio_lock);
+ if(miibus_get())
+ return -ENODEV;
+
if(ssdk_dt_global.switch_reg_access_mode == HSL_REG_LOCAL_BUS) {
if (!request_mem_region(ssdk_dt_global.switchreg_base_addr,
ssdk_dt_global.switchreg_size, "switch_mem")) {
@@ -1218,9 +1237,6 @@
}
if(ssdk_dt_global.switch_reg_access_mode == HSL_REG_MDIO) {
- if(miibus_get())
- return -ENODEV;
-
if(driver_find(qca_phy_driver.name, &mdio_bus_type)){
printk("QCA PHY driver had been Registered\n");
return 0;
@@ -1561,7 +1577,7 @@
struct device_node *switch_node = NULL;
struct device_node *psgmii_node = NULL;
a_uint32_t len = 0;
- const __be32 *reg_cfg;
+ const __be32 *reg_cfg, *mac_mode;
/*
@@ -1626,6 +1642,13 @@
if(!strcmp(ssdk_dt_global.psgmii_reg_access_str, "local bus"))
ssdk_dt_global.psgmii_reg_access_mode = HSL_REG_LOCAL_BUS;
+ mac_mode = of_get_property(switch_node, "switch_mac_mode", &len);
+ if(!mac_mode) {
+ printk("%s: error reading device node properties for mac mode\n", switch_node->name);
+ return SW_BAD_PARAM;
+ }
+ cfg->mac_mode = be32_to_cpup(mac_mode);
+ printk("mac mode=%d\n", be32_to_cpup(mac_mode));
return SW_OK;
}
#endif
@@ -1696,6 +1719,7 @@
qca_switch_reg_write(0, 0x0e38, (a_uint8_t *)®_value, 4);
fal_ip_vrf_base_addr_set(0, 0, 0);
+ /*TODO:set mac mode in gcc*/
return 0;
}
diff --git a/src/ref/ref_uci.c b/src/ref/ref_uci.c
index 9b3e07e..aacdd51 100755
--- a/src/ref/ref_uci.c
+++ b/src/ref/ref_uci.c
@@ -66,6 +66,7 @@
static char *lb_dflt_str = "0";
static char *cookie_dflt_str = "0";
static char *priority_dflt_str = "no";
+static char *param_dflt_str = " ";
static int
parse_qos_qtxbufsts(struct switch_val *val)
@@ -3766,6 +3767,8 @@
parameter_length ++;
val_ptr[7] = vrf_temp;
parameter_length ++;
+ val_ptr[12] = param_dflt_str;
+ parameter_length ++;
switch_ext_p = val->value.ext_val;
while(switch_ext_p) {
ext_value_p = switch_ext_p;
@@ -3799,6 +3802,9 @@
val_ptr[10] = ext_value_p->option_value;
} else if(!strcmp(ext_value_p->option_name, "counter")) {
val_ptr[11] = ext_value_p->option_value;
+ } else if(!strcmp(ext_value_p->option_name, "counter_id")) {
+ val_ptr[12] = ext_value_p->option_value;
+ parameter_length --;
} else {
rv = -1;
break;
@@ -4351,6 +4357,8 @@
switch_ext_p = val->value.ext_val;
val_ptr[4] = vrf_dflt_str;
parameter_length ++;
+ val_ptr[12] = param_dflt_str;
+ parameter_length ++;
while(switch_ext_p) {
ext_value_p = switch_ext_p;
@@ -4382,7 +4390,10 @@
val_ptr[10] = ext_value_p->option_value;
} else if(!strcmp(ext_value_p->option_name, "counter")) {
val_ptr[11] = ext_value_p->option_value;
- } else {
+ } else if(!strcmp(ext_value_p->option_name, "counter_id")) {
+ val_ptr[12] = ext_value_p->option_value;
+ parameter_length --;
+ } else {
rv = -1;
break;
}
@@ -4406,7 +4417,11 @@
parameter_length ++;
val_ptr[5] = lb_dflt_str;
parameter_length ++;
- val_ptr[15] = priority_dflt_str;
+ val_ptr[15] = param_dflt_str;
+ parameter_length ++;
+ val_ptr[16] = priority_dflt_str;
+ parameter_length ++;
+ val_ptr[17] = param_dflt_str;
parameter_length ++;
while(switch_ext_p) {
ext_value_p = switch_ext_p;
@@ -4447,9 +4462,15 @@
val_ptr[13] = ext_value_p->option_value;
} else if(!strcmp(ext_value_p->option_name, "counter")) {
val_ptr[14] = ext_value_p->option_value;
- } else if(!strcmp(ext_value_p->option_name, "priority")) {
+ } else if(!strcmp(ext_value_p->option_name, "counter_id")) {
val_ptr[15] = ext_value_p->option_value;
parameter_length --;
+ } else if(!strcmp(ext_value_p->option_name, "priority")) {
+ val_ptr[16] = ext_value_p->option_value;
+ parameter_length --;
+ } else if(!strcmp(ext_value_p->option_name, "priority_val")) {
+ val_ptr[17] = ext_value_p->option_value;
+ parameter_length --;
} else {
rv = -1;
break;
@@ -4468,6 +4489,10 @@
struct switch_ext *switch_ext_p, *switch_ext_tmp, *ext_value_p;
int rv = 0;
switch_ext_p = val->value.ext_val;
+ val_ptr[13] = param_dflt_str;
+ parameter_length ++;
+ val_ptr[15] = param_dflt_str;
+ parameter_length ++;
while(switch_ext_p) {
ext_value_p = switch_ext_p;
@@ -4500,9 +4525,15 @@
val_ptr[11] = ext_value_p->option_value;
} else if(!strcmp(ext_value_p->option_name, "counter")) {
val_ptr[12] = ext_value_p->option_value;
- } else if(!strcmp(ext_value_p->option_name, "priority")) {
+ } else if(!strcmp(ext_value_p->option_name, "counter_id")) {
val_ptr[13] = ext_value_p->option_value;
- } else {
+ parameter_length --;
+ } else if(!strcmp(ext_value_p->option_name, "priority")) {
+ val_ptr[14] = ext_value_p->option_value;
+ } else if(!strcmp(ext_value_p->option_name, "priority_val")) {
+ val_ptr[15] = ext_value_p->option_value;
+ parameter_length --;
+ } else {
rv = -1;
break;
}
diff --git a/src/shell_lib/shell_config.c b/src/shell_lib/shell_config.c
index 15584b6..2b6c9a4 100755
--- a/src/shell_lib/shell_config.c
+++ b/src/shell_lib/shell_config.c
@@ -529,6 +529,7 @@
{"natunksess", "set", "set nat unkown session command", "<forward|drop|cpycpu|rdtcpu>", SW_API_NAT_UNK_SESSION_CMD_SET, NULL},
{"prvbasemask", "set", "set nat prv base mask", "<ip4 mask>", SW_API_PRV_BASE_MASK_SET, NULL},
{"global", "set", "set global nat function", "<enable|disable> <enable:sync counter|disable:unsync counter>", SW_API_NAT_GLOBAL_SET, NULL},
+ {"flowentry", "set", "add flow entry", "", SW_API_FLOW_ADD, NULL},
{"flowentry", "add", "add flow entry", "", SW_API_FLOW_ADD, NULL},
{"flowentry", "del", "del flow entry", "<del_mode>", SW_API_FLOW_DEL, NULL},
{"flowentry", "next", "next flow entry", "<next_mode>", SW_API_FLOW_NEXT, NULL},