
Intel listed total 28 commits that need us to back port. There are 9 commits that are already included in our code base. The commit "ice: Add support for E825-C TS PLL handling" will not be back ported since we're not dealing with E825 for 24.09. So we need back port 18 commits. These commits were introduced in linux-6.9.y and linux-6.10.y. To back port these 18 commits successfully, we totally back ported 37 upstream commits. 1) The patches 1-15 are cherry picked to fix the conflicts for patch 16 ("ice: introduce PTP state machine") and patch 36 "ice: Introduce ice_ptp_hw struct". Also will be helpful for the subsequent commits back porting. 2) The patches 24-27 are cherry picked to fix the conflicts for patch 28 ("ice: Fix debugfs with devlink reload") 3) The minor adjust was done for the patches 17, 21, 23 and 33 to fit with the context change. Verification: - installs from iso succeed on servers with ice(Intel Ethernet Controller E810-XXVDA4T Westport Channel) and i40e hw(Intel Ethernet Controller X710) for rt and std. - interfaces are up and pass packets for rt and std. - create vfs, ensure that they are picked up by the new iavf driver and that the interface can come up and pass packets on rt and std system. - Check dmesg to see DDP package is loaded successfully and the version is 1.3.36.0 for rt and std. Story: 2011056 Task: 50950 Change-Id: I9aef0378ea01451684341093a167eaead3edc458 Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
629 lines
20 KiB
Diff
629 lines
20 KiB
Diff
From 1ce01cb7cdb0bf4c18a546a62f224c8032d75ebd Mon Sep 17 00:00:00 2001
|
|
From: Karol Kolacinski <karol.kolacinski@intel.com>
|
|
Date: Tue, 28 May 2024 16:03:51 -0700
|
|
Subject: [PATCH 36/36] ice: Introduce ice_ptp_hw struct
|
|
|
|
Create new ice_ptp_hw struct and use it for all HW and PTP-related
|
|
fields from struct ice_hw.
|
|
Replace definitions with struct fields, which values are set accordingly
|
|
to a specific device.
|
|
|
|
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
|
|
Reviewed-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
|
|
Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com>
|
|
Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com>
|
|
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
|
|
Link: https://lore.kernel.org/r/20240528-next-2024-05-28-ptp-refactors-v1-1-c082739bb6f6@intel.com
|
|
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|
(cherry picked from commit d551d075b043821880b8afc0010ef70d050716d0)
|
|
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
|
|
---
|
|
drivers/net/ethernet/intel/ice/ice_common.c | 24 ++++
|
|
drivers/net/ethernet/intel/ice/ice_common.h | 1 +
|
|
drivers/net/ethernet/intel/ice/ice_ptp.c | 22 ++--
|
|
drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 134 ++++++++++++--------
|
|
drivers/net/ethernet/intel/ice/ice_ptp_hw.h | 4 +-
|
|
drivers/net/ethernet/intel/ice/ice_type.h | 17 ++-
|
|
6 files changed, 126 insertions(+), 76 deletions(-)
|
|
|
|
diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
|
|
index 59ede77a1473..147004e0170b 100644
|
|
--- a/drivers/net/ethernet/intel/ice/ice_common.c
|
|
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
|
|
@@ -209,6 +209,30 @@ bool ice_is_e810t(struct ice_hw *hw)
|
|
return false;
|
|
}
|
|
|
|
+/**
|
|
+ * ice_is_e822 - Check if a device is E822 family device
|
|
+ * @hw: pointer to the hardware structure
|
|
+ *
|
|
+ * Return: true if the device is E822 based, false if not.
|
|
+ */
|
|
+bool ice_is_e822(struct ice_hw *hw)
|
|
+{
|
|
+ switch (hw->device_id) {
|
|
+ case ICE_DEV_ID_E822C_BACKPLANE:
|
|
+ case ICE_DEV_ID_E822C_QSFP:
|
|
+ case ICE_DEV_ID_E822C_SFP:
|
|
+ case ICE_DEV_ID_E822C_10G_BASE_T:
|
|
+ case ICE_DEV_ID_E822C_SGMII:
|
|
+ case ICE_DEV_ID_E822L_BACKPLANE:
|
|
+ case ICE_DEV_ID_E822L_SFP:
|
|
+ case ICE_DEV_ID_E822L_10G_BASE_T:
|
|
+ case ICE_DEV_ID_E822L_SGMII:
|
|
+ return true;
|
|
+ default:
|
|
+ return false;
|
|
+ }
|
|
+}
|
|
+
|
|
/**
|
|
* ice_is_e823
|
|
* @hw: pointer to the hardware structure
|
|
diff --git a/drivers/net/ethernet/intel/ice/ice_common.h b/drivers/net/ethernet/intel/ice/ice_common.h
|
|
index 1c3c29d30815..9d38777310e5 100644
|
|
--- a/drivers/net/ethernet/intel/ice/ice_common.h
|
|
+++ b/drivers/net/ethernet/intel/ice/ice_common.h
|
|
@@ -245,6 +245,7 @@ void
|
|
ice_stat_update32(struct ice_hw *hw, u32 reg, bool prev_stat_loaded,
|
|
u64 *prev_stat, u64 *cur_stat);
|
|
bool ice_is_e810t(struct ice_hw *hw);
|
|
+bool ice_is_e822(struct ice_hw *hw);
|
|
bool ice_is_e823(struct ice_hw *hw);
|
|
int
|
|
ice_sched_query_elem(struct ice_hw *hw, u32 node_teid,
|
|
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
|
|
index ceb4ba19c511..bb1572a353d0 100644
|
|
--- a/drivers/net/ethernet/intel/ice/ice_ptp.c
|
|
+++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
|
|
@@ -812,7 +812,7 @@ static enum ice_tx_tstamp_work ice_ptp_tx_tstamp_owner(struct ice_pf *pf)
|
|
}
|
|
mutex_unlock(&pf->ptp.ports_owner.lock);
|
|
|
|
- for (i = 0; i < ICE_MAX_QUAD; i++) {
|
|
+ for (i = 0; i < ICE_GET_QUAD_NUM(pf->hw.ptp.num_lports); i++) {
|
|
u64 tstamp_ready;
|
|
int err;
|
|
|
|
@@ -1026,7 +1026,7 @@ ice_ptp_release_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx)
|
|
static int
|
|
ice_ptp_init_tx_e82x(struct ice_pf *pf, struct ice_ptp_tx *tx, u8 port)
|
|
{
|
|
- tx->block = port / ICE_PORTS_PER_QUAD;
|
|
+ tx->block = ICE_GET_QUAD_NUM(port);
|
|
tx->offset = (port % ICE_PORTS_PER_QUAD) * INDEX_PER_PORT_E82X;
|
|
tx->len = INDEX_PER_PORT_E82X;
|
|
tx->has_ready_bitmap = 1;
|
|
@@ -1248,8 +1248,8 @@ static u64 ice_base_incval(struct ice_pf *pf)
|
|
*/
|
|
static int ice_ptp_check_tx_fifo(struct ice_ptp_port *port)
|
|
{
|
|
- int quad = port->port_num / ICE_PORTS_PER_QUAD;
|
|
int offs = port->port_num % ICE_PORTS_PER_QUAD;
|
|
+ int quad = ICE_GET_QUAD_NUM(port->port_num);
|
|
struct ice_pf *pf;
|
|
struct ice_hw *hw;
|
|
u32 val, phy_sts;
|
|
@@ -1448,7 +1448,7 @@ void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup)
|
|
if (pf->ptp.state != ICE_PTP_READY)
|
|
return;
|
|
|
|
- if (WARN_ON_ONCE(port >= ICE_NUM_EXTERNAL_PORTS))
|
|
+ if (WARN_ON_ONCE(port >= hw->ptp.num_lports))
|
|
return;
|
|
|
|
ptp_port = &pf->ptp.port;
|
|
@@ -1458,7 +1458,7 @@ void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup)
|
|
/* Update cached link status for this port immediately */
|
|
ptp_port->link_up = linkup;
|
|
|
|
- switch (hw->phy_model) {
|
|
+ switch (hw->ptp.phy_model) {
|
|
case ICE_PHY_E810:
|
|
/* Do not reconfigure E810 PHY */
|
|
return;
|
|
@@ -1487,7 +1487,7 @@ static int ice_ptp_cfg_phy_interrupt(struct ice_pf *pf, bool ena, u32 threshold)
|
|
|
|
ice_ptp_reset_ts_memory(hw);
|
|
|
|
- for (quad = 0; quad < ICE_MAX_QUAD; quad++) {
|
|
+ for (quad = 0; quad < ICE_GET_QUAD_NUM(hw->ptp.num_lports); quad++) {
|
|
err = ice_read_quad_reg_e82x(hw, quad, Q_REG_TX_MEM_GBL_CFG,
|
|
&val);
|
|
if (err)
|
|
@@ -2038,7 +2038,7 @@ ice_ptp_settime64(struct ptp_clock_info *info, const struct timespec64 *ts)
|
|
ice_ptp_enable_all_clkout(pf);
|
|
|
|
/* Recalibrate and re-enable timestamp blocks for E822/E823 */
|
|
- if (hw->phy_model == ICE_PHY_E82X)
|
|
+ if (hw->ptp.phy_model == ICE_PHY_E82X)
|
|
ice_ptp_restart_all_phy(pf);
|
|
exit:
|
|
if (err) {
|
|
@@ -2652,7 +2652,7 @@ static void ice_ptp_maybe_trigger_tx_interrupt(struct ice_pf *pf)
|
|
if (!ice_pf_src_tmr_owned(pf))
|
|
return;
|
|
|
|
- for (i = 0; i < ICE_MAX_QUAD; i++) {
|
|
+ for (i = 0; i < ICE_GET_QUAD_NUM(hw->ptp.num_lports); i++) {
|
|
u64 tstamp_ready;
|
|
int err;
|
|
|
|
@@ -3152,7 +3152,7 @@ static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port)
|
|
|
|
mutex_init(&ptp_port->ps_lock);
|
|
|
|
- switch (hw->phy_model) {
|
|
+ switch (hw->ptp.phy_model) {
|
|
case ICE_PHY_E810:
|
|
return ice_ptp_init_tx_e810(pf, &ptp_port->tx);
|
|
case ICE_PHY_E82X:
|
|
@@ -3245,7 +3245,7 @@ static void ice_ptp_remove_auxbus_device(struct ice_pf *pf)
|
|
*/
|
|
static void ice_ptp_init_tx_interrupt_mode(struct ice_pf *pf)
|
|
{
|
|
- switch (pf->hw.phy_model) {
|
|
+ switch (pf->hw.ptp.phy_model) {
|
|
case ICE_PHY_E82X:
|
|
/* E822 based PHY has the clock owner process the interrupt
|
|
* for all ports.
|
|
@@ -3281,7 +3281,7 @@ void ice_ptp_init(struct ice_pf *pf)
|
|
|
|
ptp->state = ICE_PTP_INITIALIZING;
|
|
|
|
- ice_ptp_init_phy_model(hw);
|
|
+ ice_ptp_init_hw(hw);
|
|
|
|
ice_ptp_init_tx_interrupt_mode(pf);
|
|
|
|
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
|
|
index 7337e7e710ed..313a72dad813 100644
|
|
--- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
|
|
+++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
|
|
@@ -285,18 +285,21 @@ static void ice_ptp_exec_tmr_cmd(struct ice_hw *hw)
|
|
|
|
/**
|
|
* ice_fill_phy_msg_e82x - Fill message data for a PHY register access
|
|
+ * @hw: pointer to the HW struct
|
|
* @msg: the PHY message buffer to fill in
|
|
* @port: the port to access
|
|
* @offset: the register offset
|
|
*/
|
|
-static void
|
|
-ice_fill_phy_msg_e82x(struct ice_sbq_msg_input *msg, u8 port, u16 offset)
|
|
+static void ice_fill_phy_msg_e82x(struct ice_hw *hw,
|
|
+ struct ice_sbq_msg_input *msg, u8 port,
|
|
+ u16 offset)
|
|
{
|
|
int phy_port, phy, quadtype;
|
|
|
|
- phy_port = port % ICE_PORTS_PER_PHY_E82X;
|
|
- phy = port / ICE_PORTS_PER_PHY_E82X;
|
|
- quadtype = (port / ICE_PORTS_PER_QUAD) % ICE_QUADS_PER_PHY_E82X;
|
|
+ phy_port = port % hw->ptp.ports_per_phy;
|
|
+ phy = port / hw->ptp.ports_per_phy;
|
|
+ quadtype = ICE_GET_QUAD_NUM(port) %
|
|
+ ICE_GET_QUAD_NUM(hw->ptp.ports_per_phy);
|
|
|
|
if (quadtype == 0) {
|
|
msg->msg_addr_low = P_Q0_L(P_0_BASE + offset, phy_port);
|
|
@@ -427,7 +430,7 @@ ice_read_phy_reg_e82x(struct ice_hw *hw, u8 port, u16 offset, u32 *val)
|
|
struct ice_sbq_msg_input msg = {0};
|
|
int err;
|
|
|
|
- ice_fill_phy_msg_e82x(&msg, port, offset);
|
|
+ ice_fill_phy_msg_e82x(hw, &msg, port, offset);
|
|
msg.opcode = ice_sbq_msg_rd;
|
|
|
|
err = ice_sbq_rw_reg(hw, &msg);
|
|
@@ -504,7 +507,7 @@ ice_write_phy_reg_e82x(struct ice_hw *hw, u8 port, u16 offset, u32 val)
|
|
struct ice_sbq_msg_input msg = {0};
|
|
int err;
|
|
|
|
- ice_fill_phy_msg_e82x(&msg, port, offset);
|
|
+ ice_fill_phy_msg_e82x(hw, &msg, port, offset);
|
|
msg.opcode = ice_sbq_msg_wr;
|
|
msg.data = val;
|
|
|
|
@@ -614,24 +617,30 @@ ice_write_64b_phy_reg_e82x(struct ice_hw *hw, u8 port, u16 low_addr, u64 val)
|
|
|
|
/**
|
|
* ice_fill_quad_msg_e82x - Fill message data for quad register access
|
|
+ * @hw: pointer to the HW struct
|
|
* @msg: the PHY message buffer to fill in
|
|
* @quad: the quad to access
|
|
* @offset: the register offset
|
|
*
|
|
* Fill a message buffer for accessing a register in a quad shared between
|
|
* multiple PHYs.
|
|
+ *
|
|
+ * Return:
|
|
+ * * %0 - OK
|
|
+ * * %-EINVAL - invalid quad number
|
|
*/
|
|
-static int
|
|
-ice_fill_quad_msg_e82x(struct ice_sbq_msg_input *msg, u8 quad, u16 offset)
|
|
+static int ice_fill_quad_msg_e82x(struct ice_hw *hw,
|
|
+ struct ice_sbq_msg_input *msg, u8 quad,
|
|
+ u16 offset)
|
|
{
|
|
u32 addr;
|
|
|
|
- if (quad >= ICE_MAX_QUAD)
|
|
+ if (quad >= ICE_GET_QUAD_NUM(hw->ptp.num_lports))
|
|
return -EINVAL;
|
|
|
|
msg->dest_dev = rmn_0;
|
|
|
|
- if ((quad % ICE_QUADS_PER_PHY_E82X) == 0)
|
|
+ if (!(quad % ICE_GET_QUAD_NUM(hw->ptp.ports_per_phy)))
|
|
addr = Q_0_BASE + offset;
|
|
else
|
|
addr = Q_1_BASE + offset;
|
|
@@ -658,7 +667,7 @@ ice_read_quad_reg_e82x(struct ice_hw *hw, u8 quad, u16 offset, u32 *val)
|
|
struct ice_sbq_msg_input msg = {0};
|
|
int err;
|
|
|
|
- err = ice_fill_quad_msg_e82x(&msg, quad, offset);
|
|
+ err = ice_fill_quad_msg_e82x(hw, &msg, quad, offset);
|
|
if (err)
|
|
return err;
|
|
|
|
@@ -692,7 +701,7 @@ ice_write_quad_reg_e82x(struct ice_hw *hw, u8 quad, u16 offset, u32 val)
|
|
struct ice_sbq_msg_input msg = {0};
|
|
int err;
|
|
|
|
- err = ice_fill_quad_msg_e82x(&msg, quad, offset);
|
|
+ err = ice_fill_quad_msg_e82x(hw, &msg, quad, offset);
|
|
if (err)
|
|
return err;
|
|
|
|
@@ -813,7 +822,7 @@ static void ice_ptp_reset_ts_memory_e82x(struct ice_hw *hw)
|
|
{
|
|
unsigned int quad;
|
|
|
|
- for (quad = 0; quad < ICE_MAX_QUAD; quad++)
|
|
+ for (quad = 0; quad < ICE_GET_QUAD_NUM(hw->ptp.num_lports); quad++)
|
|
ice_ptp_reset_ts_memory_quad_e82x(hw, quad);
|
|
}
|
|
|
|
@@ -1110,7 +1119,7 @@ static int ice_ptp_set_vernier_wl(struct ice_hw *hw)
|
|
{
|
|
u8 port;
|
|
|
|
- for (port = 0; port < ICE_NUM_EXTERNAL_PORTS; port++) {
|
|
+ for (port = 0; port < hw->ptp.num_lports; port++) {
|
|
int err;
|
|
|
|
err = ice_write_phy_reg_e82x(hw, port, P_REG_WL,
|
|
@@ -1175,7 +1184,7 @@ ice_ptp_prep_phy_time_e82x(struct ice_hw *hw, u32 time)
|
|
*/
|
|
phy_time = (u64)time << 32;
|
|
|
|
- for (port = 0; port < ICE_NUM_EXTERNAL_PORTS; port++) {
|
|
+ for (port = 0; port < hw->ptp.num_lports; port++) {
|
|
/* Tx case */
|
|
err = ice_write_64b_phy_reg_e82x(hw, port,
|
|
P_REG_TX_TIMER_INC_PRE_L,
|
|
@@ -1278,7 +1287,7 @@ ice_ptp_prep_phy_adj_e82x(struct ice_hw *hw, s32 adj)
|
|
else
|
|
cycles = -(((s64)-adj) << 32);
|
|
|
|
- for (port = 0; port < ICE_NUM_EXTERNAL_PORTS; port++) {
|
|
+ for (port = 0; port < hw->ptp.num_lports; port++) {
|
|
int err;
|
|
|
|
err = ice_ptp_prep_port_adj_e82x(hw, port, cycles);
|
|
@@ -1304,7 +1313,7 @@ ice_ptp_prep_phy_incval_e82x(struct ice_hw *hw, u64 incval)
|
|
int err;
|
|
u8 port;
|
|
|
|
- for (port = 0; port < ICE_NUM_EXTERNAL_PORTS; port++) {
|
|
+ for (port = 0; port < hw->ptp.num_lports; port++) {
|
|
err = ice_write_40b_phy_reg_e82x(hw, port, P_REG_TIMETUS_L,
|
|
incval);
|
|
if (err)
|
|
@@ -1460,7 +1469,7 @@ ice_ptp_one_port_cmd(struct ice_hw *hw, u8 configured_port,
|
|
{
|
|
u8 port;
|
|
|
|
- for (port = 0; port < ICE_NUM_EXTERNAL_PORTS; port++) {
|
|
+ for (port = 0; port < hw->ptp.num_lports; port++) {
|
|
enum ice_ptp_tmr_cmd cmd;
|
|
int err;
|
|
|
|
@@ -1490,7 +1499,7 @@ ice_ptp_port_cmd_e82x(struct ice_hw *hw, enum ice_ptp_tmr_cmd cmd)
|
|
{
|
|
u8 port;
|
|
|
|
- for (port = 0; port < ICE_NUM_EXTERNAL_PORTS; port++) {
|
|
+ for (port = 0; port < hw->ptp.num_lports; port++) {
|
|
int err;
|
|
|
|
err = ice_ptp_write_port_cmd_e82x(hw, port, cmd);
|
|
@@ -1603,7 +1612,7 @@ static void ice_phy_cfg_lane_e82x(struct ice_hw *hw, u8 port)
|
|
return;
|
|
}
|
|
|
|
- quad = port / ICE_PORTS_PER_QUAD;
|
|
+ quad = ICE_GET_QUAD_NUM(port);
|
|
|
|
err = ice_read_quad_reg_e82x(hw, quad, Q_REG_TX_MEM_GBL_CFG, &val);
|
|
if (err) {
|
|
@@ -2632,6 +2641,17 @@ ice_get_phy_tx_tstamp_ready_e82x(struct ice_hw *hw, u8 quad, u64 *tstamp_ready)
|
|
return 0;
|
|
}
|
|
|
|
+/**
|
|
+ * ice_ptp_init_phy_e82x - initialize PHY parameters
|
|
+ * @ptp: pointer to the PTP HW struct
|
|
+ */
|
|
+static void ice_ptp_init_phy_e82x(struct ice_ptp_hw *ptp)
|
|
+{
|
|
+ ptp->phy_model = ICE_PHY_E82X;
|
|
+ ptp->num_lports = 8;
|
|
+ ptp->ports_per_phy = 8;
|
|
+}
|
|
+
|
|
/* E810 functions
|
|
*
|
|
* The following functions operate on the E810 series devices which use
|
|
@@ -2859,17 +2879,21 @@ static int ice_clear_phy_tstamp_e810(struct ice_hw *hw, u8 lport, u8 idx)
|
|
}
|
|
|
|
/**
|
|
- * ice_ptp_init_phy_e810 - Enable PTP function on the external PHY
|
|
+ * ice_ptp_init_phc_e810 - Perform E810 specific PHC initialization
|
|
* @hw: pointer to HW struct
|
|
*
|
|
- * Enable the timesync PTP functionality for the external PHY connected to
|
|
- * this function.
|
|
+ * Perform E810-specific PTP hardware clock initialization steps.
|
|
+ *
|
|
+ * Return: 0 on success, other error codes when failed to initialize TimeSync
|
|
*/
|
|
-int ice_ptp_init_phy_e810(struct ice_hw *hw)
|
|
+static int ice_ptp_init_phc_e810(struct ice_hw *hw)
|
|
{
|
|
u8 tmr_idx;
|
|
int err;
|
|
|
|
+ /* Ensure synchronization delay is zero */
|
|
+ wr32(hw, GLTSYN_SYNC_DLAY, 0);
|
|
+
|
|
tmr_idx = hw->func_caps.ts_func_info.tmr_index_owned;
|
|
err = ice_write_phy_reg_e810(hw, ETH_GLTSYN_ENA(tmr_idx),
|
|
GLTSYN_ENA_TSYN_ENA_M);
|
|
@@ -2880,21 +2904,6 @@ int ice_ptp_init_phy_e810(struct ice_hw *hw)
|
|
return err;
|
|
}
|
|
|
|
-/**
|
|
- * ice_ptp_init_phc_e810 - Perform E810 specific PHC initialization
|
|
- * @hw: pointer to HW struct
|
|
- *
|
|
- * Perform E810-specific PTP hardware clock initialization steps.
|
|
- */
|
|
-static int ice_ptp_init_phc_e810(struct ice_hw *hw)
|
|
-{
|
|
- /* Ensure synchronization delay is zero */
|
|
- wr32(hw, GLTSYN_SYNC_DLAY, 0);
|
|
-
|
|
- /* Initialize the PHY */
|
|
- return ice_ptp_init_phy_e810(hw);
|
|
-}
|
|
-
|
|
/**
|
|
* ice_ptp_prep_phy_time_e810 - Prepare PHY port with initial time
|
|
* @hw: Board private structure
|
|
@@ -3238,6 +3247,17 @@ int ice_read_pca9575_reg_e810t(struct ice_hw *hw, u8 offset, u8 *data)
|
|
return ice_aq_read_i2c(hw, link_topo, 0, addr, 1, data, NULL);
|
|
}
|
|
|
|
+/**
|
|
+ * ice_ptp_init_phy_e810 - initialize PHY parameters
|
|
+ * @ptp: pointer to the PTP HW struct
|
|
+ */
|
|
+static void ice_ptp_init_phy_e810(struct ice_ptp_hw *ptp)
|
|
+{
|
|
+ ptp->phy_model = ICE_PHY_E810;
|
|
+ ptp->num_lports = 8;
|
|
+ ptp->ports_per_phy = 4;
|
|
+}
|
|
+
|
|
/* Device agnostic functions
|
|
*
|
|
* The following functions implement shared behavior common to both E822 and
|
|
@@ -3295,18 +3315,22 @@ void ice_ptp_unlock(struct ice_hw *hw)
|
|
}
|
|
|
|
/**
|
|
- * ice_ptp_init_phy_model - Initialize hw->phy_model based on device type
|
|
+ * ice_ptp_init_hw - Initialize hw based on device type
|
|
* @hw: pointer to the HW structure
|
|
*
|
|
- * Determine the PHY model for the device, and initialize hw->phy_model
|
|
+ * Determine the PHY model for the device, and initialize hw
|
|
* for use by other functions.
|
|
*/
|
|
-void ice_ptp_init_phy_model(struct ice_hw *hw)
|
|
+void ice_ptp_init_hw(struct ice_hw *hw)
|
|
{
|
|
- if (ice_is_e810(hw))
|
|
- hw->phy_model = ICE_PHY_E810;
|
|
+ struct ice_ptp_hw *ptp = &hw->ptp;
|
|
+
|
|
+ if (ice_is_e822(hw) || ice_is_e823(hw))
|
|
+ ice_ptp_init_phy_e82x(ptp);
|
|
+ else if (ice_is_e810(hw))
|
|
+ ice_ptp_init_phy_e810(ptp);
|
|
else
|
|
- hw->phy_model = ICE_PHY_E82X;
|
|
+ ptp->phy_model = ICE_PHY_UNSUP;
|
|
}
|
|
|
|
/**
|
|
@@ -3327,7 +3351,7 @@ static int ice_ptp_tmr_cmd(struct ice_hw *hw, enum ice_ptp_tmr_cmd cmd)
|
|
ice_ptp_src_cmd(hw, cmd);
|
|
|
|
/* Next, prepare the ports */
|
|
- switch (hw->phy_model) {
|
|
+ switch (hw->ptp.phy_model) {
|
|
case ICE_PHY_E810:
|
|
err = ice_ptp_port_cmd_e810(hw, cmd);
|
|
break;
|
|
@@ -3379,7 +3403,7 @@ int ice_ptp_init_time(struct ice_hw *hw, u64 time)
|
|
|
|
/* PHY timers */
|
|
/* Fill Rx and Tx ports and send msg to PHY */
|
|
- switch (hw->phy_model) {
|
|
+ switch (hw->ptp.phy_model) {
|
|
case ICE_PHY_E810:
|
|
err = ice_ptp_prep_phy_time_e810(hw, time & 0xFFFFFFFF);
|
|
break;
|
|
@@ -3421,7 +3445,7 @@ int ice_ptp_write_incval(struct ice_hw *hw, u64 incval)
|
|
wr32(hw, GLTSYN_SHADJ_L(tmr_idx), lower_32_bits(incval));
|
|
wr32(hw, GLTSYN_SHADJ_H(tmr_idx), upper_32_bits(incval));
|
|
|
|
- switch (hw->phy_model) {
|
|
+ switch (hw->ptp.phy_model) {
|
|
case ICE_PHY_E810:
|
|
err = ice_ptp_prep_phy_incval_e810(hw, incval);
|
|
break;
|
|
@@ -3487,7 +3511,7 @@ int ice_ptp_adj_clock(struct ice_hw *hw, s32 adj)
|
|
wr32(hw, GLTSYN_SHADJ_L(tmr_idx), 0);
|
|
wr32(hw, GLTSYN_SHADJ_H(tmr_idx), adj);
|
|
|
|
- switch (hw->phy_model) {
|
|
+ switch (hw->ptp.phy_model) {
|
|
case ICE_PHY_E810:
|
|
err = ice_ptp_prep_phy_adj_e810(hw, adj);
|
|
break;
|
|
@@ -3517,7 +3541,7 @@ int ice_ptp_adj_clock(struct ice_hw *hw, s32 adj)
|
|
*/
|
|
int ice_read_phy_tstamp(struct ice_hw *hw, u8 block, u8 idx, u64 *tstamp)
|
|
{
|
|
- switch (hw->phy_model) {
|
|
+ switch (hw->ptp.phy_model) {
|
|
case ICE_PHY_E810:
|
|
return ice_read_phy_tstamp_e810(hw, block, idx, tstamp);
|
|
case ICE_PHY_E82X:
|
|
@@ -3545,7 +3569,7 @@ int ice_read_phy_tstamp(struct ice_hw *hw, u8 block, u8 idx, u64 *tstamp)
|
|
*/
|
|
int ice_clear_phy_tstamp(struct ice_hw *hw, u8 block, u8 idx)
|
|
{
|
|
- switch (hw->phy_model) {
|
|
+ switch (hw->ptp.phy_model) {
|
|
case ICE_PHY_E810:
|
|
return ice_clear_phy_tstamp_e810(hw, block, idx);
|
|
case ICE_PHY_E82X:
|
|
@@ -3606,7 +3630,7 @@ int ice_get_pf_c827_idx(struct ice_hw *hw, u8 *idx)
|
|
*/
|
|
void ice_ptp_reset_ts_memory(struct ice_hw *hw)
|
|
{
|
|
- switch (hw->phy_model) {
|
|
+ switch (hw->ptp.phy_model) {
|
|
case ICE_PHY_E82X:
|
|
ice_ptp_reset_ts_memory_e82x(hw);
|
|
break;
|
|
@@ -3632,7 +3656,7 @@ int ice_ptp_init_phc(struct ice_hw *hw)
|
|
/* Clear event err indications for auxiliary pins */
|
|
(void)rd32(hw, GLTSYN_STAT(src_idx));
|
|
|
|
- switch (hw->phy_model) {
|
|
+ switch (hw->ptp.phy_model) {
|
|
case ICE_PHY_E810:
|
|
return ice_ptp_init_phc_e810(hw);
|
|
case ICE_PHY_E82X:
|
|
@@ -3655,7 +3679,7 @@ int ice_ptp_init_phc(struct ice_hw *hw)
|
|
*/
|
|
int ice_get_phy_tx_tstamp_ready(struct ice_hw *hw, u8 block, u64 *tstamp_ready)
|
|
{
|
|
- switch (hw->phy_model) {
|
|
+ switch (hw->ptp.phy_model) {
|
|
case ICE_PHY_E810:
|
|
return ice_get_phy_tx_tstamp_ready_e810(hw, block,
|
|
tstamp_ready);
|
|
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.h b/drivers/net/ethernet/intel/ice/ice_ptp_hw.h
|
|
index 7e8fd369ef7c..d788221eba57 100644
|
|
--- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.h
|
|
+++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.h
|
|
@@ -211,6 +211,7 @@ int ice_read_phy_tstamp(struct ice_hw *hw, u8 block, u8 idx, u64 *tstamp);
|
|
int ice_clear_phy_tstamp(struct ice_hw *hw, u8 block, u8 idx);
|
|
void ice_ptp_reset_ts_memory(struct ice_hw *hw);
|
|
int ice_ptp_init_phc(struct ice_hw *hw);
|
|
+void ice_ptp_init_hw(struct ice_hw *hw);
|
|
int ice_get_phy_tx_tstamp_ready(struct ice_hw *hw, u8 block, u64 *tstamp_ready);
|
|
|
|
/* E822 family functions */
|
|
@@ -265,7 +266,6 @@ int ice_phy_cfg_tx_offset_e82x(struct ice_hw *hw, u8 port);
|
|
int ice_phy_cfg_rx_offset_e82x(struct ice_hw *hw, u8 port);
|
|
|
|
/* E810 family functions */
|
|
-int ice_ptp_init_phy_e810(struct ice_hw *hw);
|
|
int ice_read_sma_ctrl_e810t(struct ice_hw *hw, u8 *data);
|
|
int ice_write_sma_ctrl_e810t(struct ice_hw *hw, u8 data);
|
|
int ice_read_pca9575_reg_e810t(struct ice_hw *hw, u8 offset, u8 *data);
|
|
@@ -280,8 +280,6 @@ int ice_get_cgu_state(struct ice_hw *hw, u8 dpll_idx,
|
|
u8 *ref_state, u8 *eec_mode, s64 *phase_offset,
|
|
enum dpll_lock_status *dpll_state);
|
|
int ice_get_cgu_rclk_pin_info(struct ice_hw *hw, u8 *base_idx, u8 *pin_num);
|
|
-
|
|
-void ice_ptp_init_phy_model(struct ice_hw *hw);
|
|
int ice_cgu_get_output_pin_state_caps(struct ice_hw *hw, u8 pin_id,
|
|
unsigned long *caps);
|
|
|
|
diff --git a/drivers/net/ethernet/intel/ice/ice_type.h b/drivers/net/ethernet/intel/ice/ice_type.h
|
|
index 28e47bb78eaf..6fc4cd1030d0 100644
|
|
--- a/drivers/net/ethernet/intel/ice/ice_type.h
|
|
+++ b/drivers/net/ethernet/intel/ice/ice_type.h
|
|
@@ -807,6 +807,9 @@ struct ice_mbx_data {
|
|
u16 async_watermark_val;
|
|
};
|
|
|
|
+#define ICE_PORTS_PER_QUAD 4
|
|
+#define ICE_GET_QUAD_NUM(port) ((port) / ICE_PORTS_PER_QUAD)
|
|
+
|
|
/* PHY model */
|
|
enum ice_phy_model {
|
|
ICE_PHY_UNSUP = -1,
|
|
@@ -814,6 +817,12 @@ enum ice_phy_model {
|
|
ICE_PHY_E82X,
|
|
};
|
|
|
|
+struct ice_ptp_hw {
|
|
+ enum ice_phy_model phy_model;
|
|
+ u8 num_lports;
|
|
+ u8 ports_per_phy;
|
|
+};
|
|
+
|
|
/* Port hardware description */
|
|
struct ice_hw {
|
|
u8 __iomem *hw_addr;
|
|
@@ -835,7 +844,6 @@ struct ice_hw {
|
|
u8 revision_id;
|
|
|
|
u8 pf_id; /* device profile info */
|
|
- enum ice_phy_model phy_model;
|
|
|
|
u16 max_burst_size; /* driver sets this value */
|
|
|
|
@@ -896,12 +904,7 @@ struct ice_hw {
|
|
/* INTRL granularity in 1 us */
|
|
u8 intrl_gran;
|
|
|
|
-#define ICE_MAX_QUAD 2
|
|
-#define ICE_QUADS_PER_PHY_E82X 2
|
|
-#define ICE_PORTS_PER_PHY_E82X 8
|
|
-#define ICE_PORTS_PER_QUAD 4
|
|
-#define ICE_PORTS_PER_PHY_E810 4
|
|
-#define ICE_NUM_EXTERNAL_PORTS (ICE_MAX_QUAD * ICE_PORTS_PER_QUAD)
|
|
+ struct ice_ptp_hw ptp;
|
|
|
|
/* Active package version (currently active) */
|
|
struct ice_pkg_ver active_pkg_ver;
|
|
--
|
|
2.43.0
|
|
|