Skip to content

Commit 4fa7011

Browse files
committed
Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue
Tony Nguyen says: ==================== Intel Wired LAN Driver Updates 2023-09-18 (ice) This series contains updates to ice driver only. Sergey prepends ICE_ to PTP timer commands to clearly convey namespace of commands. Karol adds retrying to acquire hardware semaphore for cross-timestamping and avoids writing to timestamp registers on E822 devices. He also renames some defines to be more clear and align with the data sheet. Additionally, a range check is moved in order to reduce duplicated code. Jake adds cross-timestamping support for E823 devices as well as adds checks against netlist to aid in determining support for GNSS. He also corrects improper pin assignment for certain E810-T devices and refactors/cleanups PTP related code such as adding PHY model to ease checks for different needed implementations, removing unneeded EXTTS flag, and adding macro to check for source timer owner. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents a76c22e + 89776a6 commit 4fa7011

11 files changed

Lines changed: 308 additions & 151 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,10 @@
196196

197197
#define ice_pf_to_dev(pf) (&((pf)->pdev->dev))
198198

199+
#define ice_pf_src_tmr_owned(pf) ((pf)->hw.func_caps.ts_func_info.src_tmr_owned)
200+
199201
enum ice_feature {
200202
ICE_F_DSCP,
201-
ICE_F_PTP_EXTTS,
202203
ICE_F_PHY_RCLK,
203204
ICE_F_SMA_CTRL,
204205
ICE_F_CGU,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,6 +1393,7 @@ struct ice_aqc_link_topo_params {
13931393
#define ICE_AQC_LINK_TOPO_NODE_TYPE_ID_EEPROM 8
13941394
#define ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_CTRL 9
13951395
#define ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_MUX 10
1396+
#define ICE_AQC_LINK_TOPO_NODE_TYPE_GPS 11
13961397
#define ICE_AQC_LINK_TOPO_NODE_CTX_S 4
13971398
#define ICE_AQC_LINK_TOPO_NODE_CTX_M \
13981399
(0xF << ICE_AQC_LINK_TOPO_NODE_CTX_S)
@@ -1435,6 +1436,7 @@ struct ice_aqc_get_link_topo {
14351436
#define ICE_AQC_GET_LINK_TOPO_NODE_NR_E822_PHY 0x30
14361437
#define ICE_AQC_GET_LINK_TOPO_NODE_NR_C827 0x31
14371438
#define ICE_AQC_GET_LINK_TOPO_NODE_NR_GEN_CLK_MUX 0x47
1439+
#define ICE_AQC_GET_LINK_TOPO_NODE_NR_GEN_GPS 0x48
14381440
u8 rsvd[9];
14391441
};
14401442

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2764,6 +2764,21 @@ bool ice_is_pf_c827(struct ice_hw *hw)
27642764
return false;
27652765
}
27662766

2767+
/**
2768+
* ice_is_gps_in_netlist
2769+
* @hw: pointer to the hw struct
2770+
*
2771+
* Check if the GPS generic device is present in the netlist
2772+
*/
2773+
bool ice_is_gps_in_netlist(struct ice_hw *hw)
2774+
{
2775+
if (ice_find_netlist_node(hw, ICE_AQC_LINK_TOPO_NODE_TYPE_GPS,
2776+
ICE_AQC_GET_LINK_TOPO_NODE_NR_GEN_GPS, NULL))
2777+
return false;
2778+
2779+
return true;
2780+
}
2781+
27672782
/**
27682783
* ice_aq_list_caps - query function/device capabilities
27692784
* @hw: pointer to the HW struct

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ ice_aq_get_phy_caps(struct ice_port_info *pi, bool qual_mods, u8 report_mode,
9393
struct ice_aqc_get_phy_caps_data *caps,
9494
struct ice_sq_cd *cd);
9595
bool ice_is_pf_c827(struct ice_hw *hw);
96+
bool ice_is_gps_in_netlist(struct ice_hw *hw);
9697
int
9798
ice_find_netlist_node(struct ice_hw *hw, u8 node_type_ctx, u8 node_part_number,
9899
u16 *node_handle);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,9 @@ bool ice_gnss_is_gps_present(struct ice_hw *hw)
389389
if (!hw->func_caps.ts_func_info.src_tmr_owned)
390390
return false;
391391

392+
if (!ice_is_gps_in_netlist(hw))
393+
return false;
394+
392395
#if IS_ENABLED(CONFIG_PTP_1588_CLOCK)
393396
if (ice_is_e810t(hw)) {
394397
int err;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3989,11 +3989,10 @@ void ice_init_feature_support(struct ice_pf *pf)
39893989
case ICE_DEV_ID_E810_XXV_QSFP:
39903990
case ICE_DEV_ID_E810_XXV_SFP:
39913991
ice_set_feature_support(pf, ICE_F_DSCP);
3992-
ice_set_feature_support(pf, ICE_F_PTP_EXTTS);
39933992
if (ice_is_phy_rclk_present(&pf->hw))
39943993
ice_set_feature_support(pf, ICE_F_PHY_RCLK);
39953994
/* If we don't own the timer - don't enable other caps */
3996-
if (!pf->hw.func_caps.ts_func_info.src_tmr_owned)
3995+
if (!ice_pf_src_tmr_owned(pf))
39973996
break;
39983997
if (ice_is_cgu_present(&pf->hw))
39993998
ice_set_feature_support(pf, ICE_F_CGU);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3159,7 +3159,7 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)
31593159

31603160
ena_mask &= ~PFINT_OICR_TSYN_EVNT_M;
31613161

3162-
if (hw->func_caps.ts_func_info.src_tmr_owned) {
3162+
if (ice_pf_src_tmr_owned(pf)) {
31633163
/* Save EVENTs from GLTSYN register */
31643164
pf->ptp.ext_ts_irq |= gltsyn_stat &
31653165
(GLTSYN_STAT_EVENT0_M |

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

Lines changed: 68 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ static void ice_clear_ptp_clock_index(struct ice_pf *pf)
436436
int err;
437437

438438
/* Do not clear the index if we don't own the timer */
439-
if (!hw->func_caps.ts_func_info.src_tmr_owned)
439+
if (!ice_pf_src_tmr_owned(pf))
440440
return;
441441

442442
tmr_idx = hw->func_caps.ts_func_info.tmr_index_assoc;
@@ -1366,6 +1366,7 @@ ice_ptp_port_phy_restart(struct ice_ptp_port *ptp_port)
13661366
void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup)
13671367
{
13681368
struct ice_ptp_port *ptp_port;
1369+
struct ice_hw *hw = &pf->hw;
13691370

13701371
if (!test_bit(ICE_FLAG_PTP, pf->flags))
13711372
return;
@@ -1380,11 +1381,16 @@ void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup)
13801381
/* Update cached link status for this port immediately */
13811382
ptp_port->link_up = linkup;
13821383

1383-
/* E810 devices do not need to reconfigure the PHY */
1384-
if (ice_is_e810(&pf->hw))
1384+
switch (hw->phy_model) {
1385+
case ICE_PHY_E810:
1386+
/* Do not reconfigure E810 PHY */
13851387
return;
1386-
1387-
ice_ptp_port_phy_restart(ptp_port);
1388+
case ICE_PHY_E822:
1389+
ice_ptp_port_phy_restart(ptp_port);
1390+
return;
1391+
default:
1392+
dev_warn(ice_pf_to_dev(pf), "%s: Unknown PHY type\n", __func__);
1393+
}
13881394
}
13891395

13901396
/**
@@ -1976,21 +1982,32 @@ ice_ptp_get_syncdevicetime(ktime_t *device,
19761982
u32 hh_lock, hh_art_ctl;
19771983
int i;
19781984

1979-
/* Get the HW lock */
1980-
hh_lock = rd32(hw, PFHH_SEM + (PFTSYN_SEM_BYTES * hw->pf_id));
1985+
#define MAX_HH_HW_LOCK_TRIES 5
1986+
#define MAX_HH_CTL_LOCK_TRIES 100
1987+
1988+
for (i = 0; i < MAX_HH_HW_LOCK_TRIES; i++) {
1989+
/* Get the HW lock */
1990+
hh_lock = rd32(hw, PFHH_SEM + (PFTSYN_SEM_BYTES * hw->pf_id));
1991+
if (hh_lock & PFHH_SEM_BUSY_M) {
1992+
usleep_range(10000, 15000);
1993+
continue;
1994+
}
1995+
break;
1996+
}
19811997
if (hh_lock & PFHH_SEM_BUSY_M) {
19821998
dev_err(ice_pf_to_dev(pf), "PTP failed to get hh lock\n");
1983-
return -EFAULT;
1999+
return -EBUSY;
19842000
}
19852001

2002+
/* Program cmd to master timer */
2003+
ice_ptp_src_cmd(hw, ICE_PTP_READ_TIME);
2004+
19862005
/* Start the ART and device clock sync sequence */
19872006
hh_art_ctl = rd32(hw, GLHH_ART_CTL);
19882007
hh_art_ctl = hh_art_ctl | GLHH_ART_CTL_ACTIVE_M;
19892008
wr32(hw, GLHH_ART_CTL, hh_art_ctl);
19902009

1991-
#define MAX_HH_LOCK_TRIES 100
1992-
1993-
for (i = 0; i < MAX_HH_LOCK_TRIES; i++) {
2010+
for (i = 0; i < MAX_HH_CTL_LOCK_TRIES; i++) {
19942011
/* Wait for sync to complete */
19952012
hh_art_ctl = rd32(hw, GLHH_ART_CTL);
19962013
if (hh_art_ctl & GLHH_ART_CTL_ACTIVE_M) {
@@ -2014,34 +2031,38 @@ ice_ptp_get_syncdevicetime(ktime_t *device,
20142031
break;
20152032
}
20162033
}
2034+
2035+
/* Clear the master timer */
2036+
ice_ptp_src_cmd(hw, ICE_PTP_NOP);
2037+
20172038
/* Release HW lock */
20182039
hh_lock = rd32(hw, PFHH_SEM + (PFTSYN_SEM_BYTES * hw->pf_id));
20192040
hh_lock = hh_lock & ~PFHH_SEM_BUSY_M;
20202041
wr32(hw, PFHH_SEM + (PFTSYN_SEM_BYTES * hw->pf_id), hh_lock);
20212042

2022-
if (i == MAX_HH_LOCK_TRIES)
2043+
if (i == MAX_HH_CTL_LOCK_TRIES)
20232044
return -ETIMEDOUT;
20242045

20252046
return 0;
20262047
}
20272048

20282049
/**
2029-
* ice_ptp_getcrosststamp_e822 - Capture a device cross timestamp
2050+
* ice_ptp_getcrosststamp_e82x - Capture a device cross timestamp
20302051
* @info: the driver's PTP info structure
20312052
* @cts: The memory to fill the cross timestamp info
20322053
*
20332054
* Capture a cross timestamp between the ART and the device PTP hardware
20342055
* clock. Fill the cross timestamp information and report it back to the
20352056
* caller.
20362057
*
2037-
* This is only valid for E822 devices which have support for generating the
2038-
* cross timestamp via PCIe PTM.
2058+
* This is only valid for E822 and E823 devices which have support for
2059+
* generating the cross timestamp via PCIe PTM.
20392060
*
20402061
* In order to correctly correlate the ART timestamp back to the TSC time, the
20412062
* CPU must have X86_FEATURE_TSC_KNOWN_FREQ.
20422063
*/
20432064
static int
2044-
ice_ptp_getcrosststamp_e822(struct ptp_clock_info *info,
2065+
ice_ptp_getcrosststamp_e82x(struct ptp_clock_info *info,
20452066
struct system_device_crosststamp *cts)
20462067
{
20472068
struct ice_pf *pf = ptp_info_to_pf(info);
@@ -2246,18 +2267,20 @@ ice_ptp_setup_sma_pins_e810t(struct ice_pf *pf, struct ptp_clock_info *info)
22462267
static void
22472268
ice_ptp_setup_pins_e810(struct ice_pf *pf, struct ptp_clock_info *info)
22482269
{
2249-
info->n_per_out = N_PER_OUT_E810;
2250-
2251-
if (ice_is_feature_supported(pf, ICE_F_PTP_EXTTS))
2252-
info->n_ext_ts = N_EXT_TS_E810;
2253-
22542270
if (ice_is_feature_supported(pf, ICE_F_SMA_CTRL)) {
22552271
info->n_ext_ts = N_EXT_TS_E810;
2272+
info->n_per_out = N_PER_OUT_E810T;
22562273
info->n_pins = NUM_PTP_PINS_E810T;
22572274
info->verify = ice_verify_pin_e810t;
22582275

22592276
/* Complete setup of the SMA pins */
22602277
ice_ptp_setup_sma_pins_e810t(pf, info);
2278+
} else if (ice_is_e810t(&pf->hw)) {
2279+
info->n_ext_ts = N_EXT_TS_NO_SMA_E810T;
2280+
info->n_per_out = N_PER_OUT_NO_SMA_E810T;
2281+
} else {
2282+
info->n_per_out = N_PER_OUT_E810;
2283+
info->n_ext_ts = N_EXT_TS_E810;
22612284
}
22622285
}
22632286

@@ -2275,22 +2298,22 @@ ice_ptp_setup_pins_e823(struct ice_pf *pf, struct ptp_clock_info *info)
22752298
}
22762299

22772300
/**
2278-
* ice_ptp_set_funcs_e822 - Set specialized functions for E822 support
2301+
* ice_ptp_set_funcs_e82x - Set specialized functions for E82x support
22792302
* @pf: Board private structure
22802303
* @info: PTP info to fill
22812304
*
2282-
* Assign functions to the PTP capabiltiies structure for E822 devices.
2305+
* Assign functions to the PTP capabiltiies structure for E82x devices.
22832306
* Functions which operate across all device families should be set directly
2284-
* in ice_ptp_set_caps. Only add functions here which are distinct for E822
2307+
* in ice_ptp_set_caps. Only add functions here which are distinct for E82x
22852308
* devices.
22862309
*/
22872310
static void
2288-
ice_ptp_set_funcs_e822(struct ice_pf *pf, struct ptp_clock_info *info)
2311+
ice_ptp_set_funcs_e82x(struct ice_pf *pf, struct ptp_clock_info *info)
22892312
{
22902313
#ifdef CONFIG_ICE_HWTS
22912314
if (boot_cpu_has(X86_FEATURE_ART) &&
22922315
boot_cpu_has(X86_FEATURE_TSC_KNOWN_FREQ))
2293-
info->getcrosststamp = ice_ptp_getcrosststamp_e822;
2316+
info->getcrosststamp = ice_ptp_getcrosststamp_e82x;
22942317
#endif /* CONFIG_ICE_HWTS */
22952318
}
22962319

@@ -2324,6 +2347,8 @@ ice_ptp_set_funcs_e810(struct ice_pf *pf, struct ptp_clock_info *info)
23242347
static void
23252348
ice_ptp_set_funcs_e823(struct ice_pf *pf, struct ptp_clock_info *info)
23262349
{
2350+
ice_ptp_set_funcs_e82x(pf, info);
2351+
23272352
info->enable = ice_ptp_gpio_enable_e823;
23282353
ice_ptp_setup_pins_e823(pf, info);
23292354
}
@@ -2351,7 +2376,7 @@ static void ice_ptp_set_caps(struct ice_pf *pf)
23512376
else if (ice_is_e823(&pf->hw))
23522377
ice_ptp_set_funcs_e823(pf, info);
23532378
else
2354-
ice_ptp_set_funcs_e822(pf, info);
2379+
ice_ptp_set_funcs_e82x(pf, info);
23552380
}
23562381

23572382
/**
@@ -2474,7 +2499,7 @@ void ice_ptp_reset(struct ice_pf *pf)
24742499
if (test_bit(ICE_PFR_REQ, pf->state))
24752500
goto pfr;
24762501

2477-
if (!hw->func_caps.ts_func_info.src_tmr_owned)
2502+
if (!ice_pf_src_tmr_owned(pf))
24782503
goto reset_ts;
24792504

24802505
err = ice_ptp_init_phc(hw);
@@ -2685,14 +2710,22 @@ static int ice_ptp_init_work(struct ice_pf *pf, struct ice_ptp *ptp)
26852710
*/
26862711
static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port)
26872712
{
2713+
struct ice_hw *hw = &pf->hw;
2714+
26882715
mutex_init(&ptp_port->ps_lock);
26892716

2690-
if (ice_is_e810(&pf->hw))
2717+
switch (hw->phy_model) {
2718+
case ICE_PHY_E810:
26912719
return ice_ptp_init_tx_e810(pf, &ptp_port->tx);
2720+
case ICE_PHY_E822:
2721+
kthread_init_delayed_work(&ptp_port->ov_work,
2722+
ice_ptp_wait_for_offsets);
26922723

2693-
kthread_init_delayed_work(&ptp_port->ov_work,
2694-
ice_ptp_wait_for_offsets);
2695-
return ice_ptp_init_tx_e822(pf, &ptp_port->tx, ptp_port->port_num);
2724+
return ice_ptp_init_tx_e822(pf, &ptp_port->tx,
2725+
ptp_port->port_num);
2726+
default:
2727+
return -ENODEV;
2728+
}
26962729
}
26972730

26982731
/**
@@ -2713,10 +2746,12 @@ void ice_ptp_init(struct ice_pf *pf)
27132746
struct ice_hw *hw = &pf->hw;
27142747
int err;
27152748

2749+
ice_ptp_init_phy_model(hw);
2750+
27162751
/* If this function owns the clock hardware, it must allocate and
27172752
* configure the PTP clock device to represent it.
27182753
*/
2719-
if (hw->func_caps.ts_func_info.src_tmr_owned) {
2754+
if (ice_pf_src_tmr_owned(pf)) {
27202755
err = ice_ptp_init_owner(pf);
27212756
if (err)
27222757
goto err;

0 commit comments

Comments
 (0)