Skip to content

Commit 7cab44f

Browse files
stemerkkuba-moo
authored andcommitted
ice: Introduce ETH56G PHY model for E825C products
E825C products feature a new PHY model - ETH56G. Introduces all necessary PHY definitions, functions etc. for ETH56G PHY, analogous to E82X and E810 ones with addition of a few HW-specific functionalities for ETH56G like one-step timestamping. It ensures correct PTP initialization and operation for E825C products. Co-developed-by: Jacob Keller <[email protected]> Signed-off-by: Jacob Keller <[email protected]> Co-developed-by: Michal Michalik <[email protected]> Signed-off-by: Michal Michalik <[email protected]> Signed-off-by: Sergey Temerkhanov <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Reviewed-by: Arkadiusz Kubalewski <[email protected]> Co-developed-by: Karol Kolacinski <[email protected]> Signed-off-by: Karol Kolacinski <[email protected]> Tested-by: Pucha Himasekhar Reddy <[email protected]> Signed-off-by: Jacob Keller <[email protected]> Link: https://lore.kernel.org/r/20240528-next-2024-05-28-ptp-refactors-v1-7-c082739bb6f6@intel.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 1f374d5 commit 7cab44f

File tree

9 files changed

+2613
-154
lines changed

9 files changed

+2613
-154
lines changed

drivers/net/ethernet/intel/ice/ice_common.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3067,11 +3067,13 @@ bool ice_is_100m_speed_supported(struct ice_hw *hw)
30673067
* Note: In the structure of [phy_type_low, phy_type_high], there should
30683068
* be one bit set, as this function will convert one PHY type to its
30693069
* speed.
3070-
* If no bit gets set, ICE_AQ_LINK_SPEED_UNKNOWN will be returned
3071-
* If more than one bit gets set, ICE_AQ_LINK_SPEED_UNKNOWN will be returned
3070+
*
3071+
* Return:
3072+
* * PHY speed for recognized PHY type
3073+
* * If no bit gets set, ICE_AQ_LINK_SPEED_UNKNOWN will be returned
3074+
* * If more than one bit gets set, ICE_AQ_LINK_SPEED_UNKNOWN will be returned
30723075
*/
3073-
static u16
3074-
ice_get_link_speed_based_on_phy_type(u64 phy_type_low, u64 phy_type_high)
3076+
u16 ice_get_link_speed_based_on_phy_type(u64 phy_type_low, u64 phy_type_high)
30753077
{
30763078
u16 speed_phy_type_high = ICE_AQ_LINK_SPEED_UNKNOWN;
30773079
u16 speed_phy_type_low = ICE_AQ_LINK_SPEED_UNKNOWN;

drivers/net/ethernet/intel/ice/ice_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ int
262262
ice_aq_get_gpio(struct ice_hw *hw, u16 gpio_ctrl_handle, u8 pin_idx,
263263
bool *value, struct ice_sq_cd *cd);
264264
bool ice_is_100m_speed_supported(struct ice_hw *hw);
265+
u16 ice_get_link_speed_based_on_phy_type(u64 phy_type_low, u64 phy_type_high);
265266
int
266267
ice_aq_set_lldp_mib(struct ice_hw *hw, u8 mib_type, void *buf, u16 buf_size,
267268
struct ice_sq_cd *cd);

drivers/net/ethernet/intel/ice/ice_ptp.c

Lines changed: 82 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,28 @@ ice_ptp_release_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx)
10111011
tx->len = 0;
10121012
}
10131013

1014+
/**
1015+
* ice_ptp_init_tx_eth56g - Initialize tracking for Tx timestamps
1016+
* @pf: Board private structure
1017+
* @tx: the Tx tracking structure to initialize
1018+
* @port: the port this structure tracks
1019+
*
1020+
* Initialize the Tx timestamp tracker for this port. ETH56G PHYs
1021+
* have independent memory blocks for all ports.
1022+
*
1023+
* Return: 0 for success, -ENOMEM when failed to allocate Tx tracker
1024+
*/
1025+
static int ice_ptp_init_tx_eth56g(struct ice_pf *pf, struct ice_ptp_tx *tx,
1026+
u8 port)
1027+
{
1028+
tx->block = port;
1029+
tx->offset = 0;
1030+
tx->len = INDEX_PER_PORT_ETH56G;
1031+
tx->has_ready_bitmap = 1;
1032+
1033+
return ice_ptp_alloc_tx_tracker(tx);
1034+
}
1035+
10141036
/**
10151037
* ice_ptp_init_tx_e82x - Initialize tracking for Tx timestamps
10161038
* @pf: Board private structure
@@ -1341,10 +1363,19 @@ ice_ptp_port_phy_stop(struct ice_ptp_port *ptp_port)
13411363

13421364
mutex_lock(&ptp_port->ps_lock);
13431365

1344-
kthread_cancel_delayed_work_sync(&ptp_port->ov_work);
1366+
switch (hw->ptp.phy_model) {
1367+
case ICE_PHY_ETH56G:
1368+
err = ice_stop_phy_timer_eth56g(hw, port, true);
1369+
break;
1370+
case ICE_PHY_E82X:
1371+
kthread_cancel_delayed_work_sync(&ptp_port->ov_work);
13451372

1346-
err = ice_stop_phy_timer_e82x(hw, port, true);
1347-
if (err)
1373+
err = ice_stop_phy_timer_e82x(hw, port, true);
1374+
break;
1375+
default:
1376+
err = -ENODEV;
1377+
}
1378+
if (err && err != -EBUSY)
13481379
dev_err(ice_pf_to_dev(pf), "PTP failed to set PHY port %d down, err %d\n",
13491380
port, err);
13501381

@@ -1378,27 +1409,39 @@ ice_ptp_port_phy_restart(struct ice_ptp_port *ptp_port)
13781409

13791410
mutex_lock(&ptp_port->ps_lock);
13801411

1381-
kthread_cancel_delayed_work_sync(&ptp_port->ov_work);
1412+
switch (hw->ptp.phy_model) {
1413+
case ICE_PHY_ETH56G:
1414+
err = ice_start_phy_timer_eth56g(hw, port);
1415+
break;
1416+
case ICE_PHY_E82X:
1417+
/* Start the PHY timer in Vernier mode */
1418+
kthread_cancel_delayed_work_sync(&ptp_port->ov_work);
13821419

1383-
/* temporarily disable Tx timestamps while calibrating PHY offset */
1384-
spin_lock_irqsave(&ptp_port->tx.lock, flags);
1385-
ptp_port->tx.calibrating = true;
1386-
spin_unlock_irqrestore(&ptp_port->tx.lock, flags);
1387-
ptp_port->tx_fifo_busy_cnt = 0;
1420+
/* temporarily disable Tx timestamps while calibrating
1421+
* PHY offset
1422+
*/
1423+
spin_lock_irqsave(&ptp_port->tx.lock, flags);
1424+
ptp_port->tx.calibrating = true;
1425+
spin_unlock_irqrestore(&ptp_port->tx.lock, flags);
1426+
ptp_port->tx_fifo_busy_cnt = 0;
13881427

1389-
/* Start the PHY timer in Vernier mode */
1390-
err = ice_start_phy_timer_e82x(hw, port);
1391-
if (err)
1392-
goto out_unlock;
1428+
/* Start the PHY timer in Vernier mode */
1429+
err = ice_start_phy_timer_e82x(hw, port);
1430+
if (err)
1431+
break;
13931432

1394-
/* Enable Tx timestamps right away */
1395-
spin_lock_irqsave(&ptp_port->tx.lock, flags);
1396-
ptp_port->tx.calibrating = false;
1397-
spin_unlock_irqrestore(&ptp_port->tx.lock, flags);
1433+
/* Enable Tx timestamps right away */
1434+
spin_lock_irqsave(&ptp_port->tx.lock, flags);
1435+
ptp_port->tx.calibrating = false;
1436+
spin_unlock_irqrestore(&ptp_port->tx.lock, flags);
13981437

1399-
kthread_queue_delayed_work(pf->ptp.kworker, &ptp_port->ov_work, 0);
1438+
kthread_queue_delayed_work(pf->ptp.kworker, &ptp_port->ov_work,
1439+
0);
1440+
break;
1441+
default:
1442+
err = -ENODEV;
1443+
}
14001444

1401-
out_unlock:
14021445
if (err)
14031446
dev_err(ice_pf_to_dev(pf), "PTP failed to set PHY port %d up, err %d\n",
14041447
port, err);
@@ -1436,6 +1479,7 @@ void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup)
14361479
case ICE_PHY_E810:
14371480
/* Do not reconfigure E810 PHY */
14381481
return;
1482+
case ICE_PHY_ETH56G:
14391483
case ICE_PHY_E82X:
14401484
ice_ptp_port_phy_restart(ptp_port);
14411485
return;
@@ -1465,6 +1509,22 @@ static int ice_ptp_cfg_phy_interrupt(struct ice_pf *pf, bool ena, u32 threshold)
14651509
ice_ptp_reset_ts_memory(hw);
14661510

14671511
switch (hw->ptp.phy_model) {
1512+
case ICE_PHY_ETH56G: {
1513+
int port;
1514+
1515+
for (port = 0; port < hw->ptp.num_lports; port++) {
1516+
int err;
1517+
1518+
err = ice_phy_cfg_intr_eth56g(hw, port, ena, threshold);
1519+
if (err) {
1520+
dev_err(dev, "Failed to configure PHY interrupt for port %d, err %d\n",
1521+
port, err);
1522+
return err;
1523+
}
1524+
}
1525+
1526+
return 0;
1527+
}
14681528
case ICE_PHY_E82X: {
14691529
int quad;
14701530

@@ -3075,6 +3135,9 @@ static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port)
30753135
mutex_init(&ptp_port->ps_lock);
30763136

30773137
switch (hw->ptp.phy_model) {
3138+
case ICE_PHY_ETH56G:
3139+
return ice_ptp_init_tx_eth56g(pf, &ptp_port->tx,
3140+
ptp_port->port_num);
30783141
case ICE_PHY_E810:
30793142
return ice_ptp_init_tx_e810(pf, &ptp_port->tx);
30803143
case ICE_PHY_E82X:

drivers/net/ethernet/intel/ice/ice_ptp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ struct ice_ptp_tx {
153153
#define INDEX_PER_QUAD 64
154154
#define INDEX_PER_PORT_E82X 16
155155
#define INDEX_PER_PORT_E810 64
156+
#define INDEX_PER_PORT_ETH56G 64
156157

157158
/**
158159
* struct ice_ptp_port - data used to initialize an external port for PTP

0 commit comments

Comments
 (0)