[qca-ssdk]: the PTP config should comply with the running option
This patch also fixed the mac address display issue in the ptp
enhancedTimestampEngine feature.
Change-Id: I958879ff1e51f70cc050edb4711768fb9b872e9a
Signed-off-by: Luo Jie <luoj@codeaurora.org>
diff --git a/include/hsl/phy/hsl_phy.h b/include/hsl/phy/hsl_phy.h
index ed94075..0fb0e57 100755
--- a/include/hsl/phy/hsl_phy.h
+++ b/include/hsl/phy/hsl_phy.h
@@ -213,6 +213,7 @@
typedef sw_error_t(*hsl_phy_get_status) (a_uint32_t dev_id,
a_uint32_t phy_id, struct port_phy_status *phy_status);
+/*qca808x_end*/
typedef sw_error_t(*hsl_phy_ptp_security_set) (a_uint32_t dev_id,
a_uint32_t phy_id, fal_ptp_security_t *sec);
@@ -398,6 +399,7 @@
hsl_phy_ptp_reference_clock_get phy_ptp_reference_clock_get;
} hsl_phy_ptp_ops_t;
+/*qca808x_start*/
typedef struct hsl_phy_ops_s {
hsl_phy_init phy_init;
@@ -462,7 +464,9 @@
hsl_phy_counter_show phy_counter_show;
hsl_phy_serdes_reset phy_serdes_reset;
hsl_phy_get_status phy_get_status;
+/*qca808x_end*/
hsl_phy_ptp_ops_t phy_ptp_ops;
+/*qca808x_start*/
} hsl_phy_ops_t;
typedef struct phy_driver_instance {
diff --git a/include/hsl/phy/qca808x_phy.h b/include/hsl/phy/qca808x_phy.h
index 2dffec3..e27bd63 100755
--- a/include/hsl/phy/qca808x_phy.h
+++ b/include/hsl/phy/qca808x_phy.h
@@ -486,6 +486,14 @@
qca808x_phy_set_force_speed(a_uint32_t dev_id, a_uint32_t phy_id,
fal_port_speed_t speed);
+void qca808x_phydev_init(a_uint32_t dev_id, a_uint32_t port_id);
+
+void qca808x_phydev_deinit(a_uint32_t dev_id, a_uint32_t port_id);
+
+a_int32_t qca808x_phy_driver_register(void);
+
+void qca808x_phy_driver_unregister(void);
+
int qca808x_phy_init(a_uint32_t dev_id, a_uint32_t port_bmp);
void qca808x_phy_exit(a_uint32_t dev_id, a_uint32_t port_id);
diff --git a/include/hsl/phy/qca808x_ptp.h b/include/hsl/phy/qca808x_ptp.h
index 89e1b04..30ab615 100755
--- a/include/hsl/phy/qca808x_ptp.h
+++ b/include/hsl/phy/qca808x_ptp.h
@@ -203,12 +203,6 @@
void qca808x_phy_ptp_api_ops_init(hsl_phy_ptp_ops_t *phy_ptp_ops);
-void qca808x_phydev_init(a_uint32_t dev_id, a_uint32_t port_id);
-void qca808x_phydev_deinit(a_uint32_t dev_id, a_uint32_t port_id);
-
-a_int32_t qca808x_phy_driver_register(void);
-void qca808x_phy_driver_unregister(void);
-
void qca808x_ptp_gm_gps_seconds_sync_enable(a_uint32_t dev_id,
a_uint32_t phy_addr, a_bool_t en);
diff --git a/src/hsl/phy/hsl_phy.c b/src/hsl/phy/hsl_phy.c
index 5d43b4d..f49adda 100755
--- a/src/hsl/phy/hsl_phy.c
+++ b/src/hsl/phy/hsl_phy.c
@@ -82,7 +82,7 @@
#endif
#ifdef IN_QCA808X_PHY
/*qca808x_start*/
- {QCA808X_PHY_CHIP, {0}, NULL, qca808x_phy_init, NULL},
+ {QCA808X_PHY_CHIP, {0}, NULL, qca808x_phy_init, qca808x_phy_exit},
/*qca808x_end*/
#else
{QCA808X_PHY_CHIP, {0}, NULL, NULL, NULL},
diff --git a/src/hsl/phy/qca808x_phy.c b/src/hsl/phy/qca808x_phy.c
index 258795b..ff1c776 100755
--- a/src/hsl/phy/qca808x_phy.c
+++ b/src/hsl/phy/qca808x_phy.c
@@ -11,6 +11,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+/*qca808x_start*/
#include "sw.h"
#include "fal_port_ctrl.h"
#include "hsl_api.h"
@@ -18,7 +19,9 @@
#include "hsl_phy.h"
#include "ssdk_plat.h"
#include "qca808x_phy.h"
+/*qca808x_end*/
#include "qca808x_ptp.h"
+/*qca808x_start*/
#define PHY_INVALID_DATA 0xffff
#define PHY_RTN_ON_READ_ERROR(phy_data) \
@@ -1790,8 +1793,10 @@
qca808x_phy_api_ops->phy_counter_get = qca808x_phy_get_counter;
qca808x_phy_api_ops->phy_counter_show = qca808x_phy_show_counter;
+/*qca808x_end*/
qca808x_phy_ptp_api_ops_init(&qca808x_phy_api_ops->phy_ptp_ops);
+/*qca808x_start*/
ret = hsl_phy_api_ops_register(QCA808X_PHY_CHIP, qca808x_phy_api_ops);
if (ret == SW_OK) {
@@ -1810,7 +1815,9 @@
*/
int qca808x_phy_init(a_uint32_t dev_id, a_uint32_t port_bmp)
{
+/*qca808x_end*/
a_uint32_t port_id = 0;
+/*qca808x_start*/
a_int32_t ret = 0;
if(phy_ops_flag == A_FALSE &&
@@ -1819,6 +1826,7 @@
}
qca808x_phy_hw_init(dev_id, port_bmp);
+/*qca808x_end*/
for (port_id = 0; port_id < SW_MAX_NR_PORT; port_id ++)
{
if (port_bmp & (0x1 << port_id)) {
@@ -1827,11 +1835,13 @@
}
ret = qca808x_phy_driver_register();
+/*qca808x_start*/
return ret;
}
void qca808x_phy_exit(a_uint32_t dev_id, a_uint32_t port_bmp)
{
+/*qca808x_end*/
a_uint32_t port_id = 0;
qca808x_phy_driver_unregister();
@@ -1841,4 +1851,6 @@
qca808x_phydev_deinit(dev_id, port_id);
}
}
+/*qca808x_start*/
}
+/*qca808x_end*/
diff --git a/src/hsl/phy/qca808x_ptp.c b/src/hsl/phy/qca808x_ptp.c
index aef2e81..6f1ab0f 100755
--- a/src/hsl/phy/qca808x_ptp.c
+++ b/src/hsl/phy/qca808x_ptp.c
@@ -1881,17 +1881,17 @@
SW_RTN_ON_ERROR(qca808x_ptp_rx_filt_mac_da0_reg_get(dev_id,
phy_id, &ptp_rx_filt_mac_da0_reg));
- ts_engine->dmac_addr.uc[0] = ptp_rx_filt_mac_da0_reg.bf.mac_addr << 8;
+ ts_engine->dmac_addr.uc[0] = ptp_rx_filt_mac_da0_reg.bf.mac_addr >> 8;
ts_engine->dmac_addr.uc[1] = ptp_rx_filt_mac_da0_reg.bf.mac_addr & 0xff;
SW_RTN_ON_ERROR(qca808x_ptp_rx_filt_mac_da1_reg_get(dev_id,
phy_id, &ptp_rx_filt_mac_da1_reg));
- ts_engine->dmac_addr.uc[2] = ptp_rx_filt_mac_da1_reg.bf.mac_addr << 8;
+ ts_engine->dmac_addr.uc[2] = ptp_rx_filt_mac_da1_reg.bf.mac_addr >> 8;
ts_engine->dmac_addr.uc[3] = ptp_rx_filt_mac_da1_reg.bf.mac_addr & 0xff;
SW_RTN_ON_ERROR(qca808x_ptp_rx_filt_mac_da2_reg_get(dev_id,
phy_id, &ptp_rx_filt_mac_da2_reg));
- ts_engine->dmac_addr.uc[4] = ptp_rx_filt_mac_da2_reg.bf.mac_addr << 8;
+ ts_engine->dmac_addr.uc[4] = ptp_rx_filt_mac_da2_reg.bf.mac_addr >> 8;
ts_engine->dmac_addr.uc[5] = ptp_rx_filt_mac_da2_reg.bf.mac_addr & 0xff;
SW_RTN_ON_ERROR(qca808x_ptp_rx_filt_layer4_protocol_reg_get(dev_id,
@@ -2132,17 +2132,17 @@
SW_RTN_ON_ERROR(qca808x_ptp_tx_filt_mac_da0_reg_get(dev_id,
phy_id, &ptp_tx_filt_mac_da0_reg));
- ts_engine->dmac_addr.uc[0] = ptp_tx_filt_mac_da0_reg.bf.mac_addr << 8;
+ ts_engine->dmac_addr.uc[0] = ptp_tx_filt_mac_da0_reg.bf.mac_addr >> 8;
ts_engine->dmac_addr.uc[1] = ptp_tx_filt_mac_da0_reg.bf.mac_addr & 0xff;
SW_RTN_ON_ERROR(qca808x_ptp_tx_filt_mac_da1_reg_get(dev_id,
phy_id, &ptp_tx_filt_mac_da1_reg));
- ts_engine->dmac_addr.uc[2] = ptp_tx_filt_mac_da1_reg.bf.mac_addr << 8;
+ ts_engine->dmac_addr.uc[2] = ptp_tx_filt_mac_da1_reg.bf.mac_addr >> 8;
ts_engine->dmac_addr.uc[3] = ptp_tx_filt_mac_da1_reg.bf.mac_addr & 0xff;
SW_RTN_ON_ERROR(qca808x_ptp_tx_filt_mac_da2_reg_get(dev_id,
phy_id, &ptp_tx_filt_mac_da2_reg));
- ts_engine->dmac_addr.uc[4] = ptp_tx_filt_mac_da2_reg.bf.mac_addr << 8;
+ ts_engine->dmac_addr.uc[4] = ptp_tx_filt_mac_da2_reg.bf.mac_addr >> 8;
ts_engine->dmac_addr.uc[5] = ptp_tx_filt_mac_da2_reg.bf.mac_addr & 0xff;
SW_RTN_ON_ERROR(qca808x_ptp_tx_filt_layer4_protocol_reg_get(dev_id,
diff --git a/src/hsl/phy/qca808x_ptp_linux.c b/src/hsl/phy/qca808x_ptp_linux.c
index 93916bc..6a6f17d 100755
--- a/src/hsl/phy/qca808x_ptp_linux.c
+++ b/src/hsl/phy/qca808x_ptp_linux.c
@@ -1339,7 +1339,15 @@
static int qca808x_hwtstamp(struct phy_device *phydev, struct ifreq *ifr)
{
struct hwtstamp_config cfg;
+ sw_error_t ret = SW_OK;
+ fal_ptp_config_t ptp_config = {0};
qca808x_priv *priv = phydev->priv;
+ struct qca808x_phy_info *pdata = priv->phy_info;
+ struct qca808x_ptp_clock *clock = priv->clock;
+
+ if (!pdata || !clock) {
+ return -EFAULT;
+ }
if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg)))
return -EFAULT;
@@ -1374,6 +1382,37 @@
return -ERANGE;
}
+ mutex_lock(&clock->tsreg_lock);
+ ret = qca808x_phy_ptp_config_get(pdata->dev_id, pdata->phy_addr, &ptp_config);
+ if (ret != SW_OK) {
+ mutex_unlock(&clock->tsreg_lock);
+ return -EFAULT;
+ }
+ switch (priv->hwts_tx_type) {
+ case HWTSTAMP_TX_ON:
+ ptp_config.ptp_en = A_TRUE;
+ ptp_config.step_mode = FAL_TWO_STEP_MODE;
+ break;
+ case HWTSTAMP_TX_ONESTEP_SYNC:
+ case HWTSTAMP_TX_ONESTEP_P2P:
+ ptp_config.ptp_en = A_TRUE;
+ ptp_config.step_mode = FAL_ONE_STEP_MODE;
+ break;
+ case HWTSTAMP_TX_OFF:
+ default:
+ ptp_config.ptp_en = A_FALSE;
+ ptp_config.step_mode = FAL_TWO_STEP_MODE;
+ break;
+ }
+ ret = qca808x_phy_ptp_config_set(pdata->dev_id, pdata->phy_addr, &ptp_config);
+ mutex_unlock(&clock->tsreg_lock);
+ if (ret != SW_OK) {
+ return -EFAULT;
+ }
+
+ pdata->clock_mode = ptp_config.clock_mode;
+ pdata->step_mode = ptp_config.step_mode;
+
return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0;
}
@@ -1517,6 +1556,7 @@
switch (priv->hwts_tx_type) {
case HWTSTAMP_TX_ONESTEP_SYNC:
if (msg_type == QCA808X_PTP_MSG_SYNC) {
+ skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
kfree_skb(skb);
return;
}
@@ -1524,6 +1564,7 @@
case HWTSTAMP_TX_ONESTEP_P2P:
if (msg_type == QCA808X_PTP_MSG_PRESP ||
msg_type == QCA808X_PTP_MSG_SYNC) {
+ skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
kfree_skb(skb);
return;
}
@@ -1706,7 +1747,7 @@
void qca808x_phydev_deinit(a_uint32_t dev_id, a_uint32_t port_id)
{
- struct qca808x_phy_info *pdata;
+ struct qca808x_phy_info *pdata, *pnext;
#if defined(IN_PHY_I2C_MODE)
/* in i2c mode, need to remove the fake phy device
@@ -1715,7 +1756,7 @@
sfp_phy_device_remove(dev_id, port_id);
}
#endif
- list_for_each_entry(pdata, &g_qca808x_phy_list, list) {
+ list_for_each_entry_safe(pdata, pnext, &g_qca808x_phy_list, list) {
list_del(&pdata->list);
kfree(pdata);
}