Skip to content

Commit 9124c11

Browse files
committed
Merge: ice: Implement PTP support for E830 devices
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6828 JIRA: https://issues.redhat.com/browse/RHEL-89579 Patches implement PTP support for E830 devices. Signed-off-by: Petr Oros <poros@redhat.com> Approved-by: Michal Schmidt <mschmidt@redhat.com> Approved-by: mheib <mheib@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Augusto Caringi <acaringi@redhat.com>
2 parents d4dd482 + 9797df3 commit 9124c11

File tree

16 files changed

+776
-607
lines changed

16 files changed

+776
-607
lines changed

drivers/net/ethernet/intel/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ config ICE_SWITCHDEV
351351
config ICE_HWTS
352352
bool "Support HW cross-timestamp on platforms with PTM support"
353353
default y
354-
depends on ICE && X86
354+
depends on ICE && X86 && PCIE_PTM
355355
help
356356
Say Y to enable hardware supported cross-timestamping on platforms
357357
with PCIe PTM support. The cross-timestamp is available through

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,10 +1046,5 @@ static inline void ice_clear_rdma_cap(struct ice_pf *pf)
10461046
clear_bit(ICE_FLAG_RDMA_ENA, pf->flags);
10471047
}
10481048

1049-
static inline enum ice_phy_model ice_get_phy_model(const struct ice_hw *hw)
1050-
{
1051-
return hw->ptp.phy_model;
1052-
}
1053-
10541049
extern const struct xdp_metadata_ops ice_xdp_md_ops;
10551050
#endif /* _ICE_H_ */

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

Lines changed: 92 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -185,128 +185,14 @@ static int ice_set_mac_type(struct ice_hw *hw)
185185
* ice_is_generic_mac - check if device's mac_type is generic
186186
* @hw: pointer to the hardware structure
187187
*
188-
* Return: true if mac_type is generic (with SBQ support), false if not
188+
* Return: true if mac_type is ICE_MAC_GENERIC*, false otherwise.
189189
*/
190190
bool ice_is_generic_mac(struct ice_hw *hw)
191191
{
192192
return (hw->mac_type == ICE_MAC_GENERIC ||
193193
hw->mac_type == ICE_MAC_GENERIC_3K_E825);
194194
}
195195

196-
/**
197-
* ice_is_e810
198-
* @hw: pointer to the hardware structure
199-
*
200-
* returns true if the device is E810 based, false if not.
201-
*/
202-
bool ice_is_e810(struct ice_hw *hw)
203-
{
204-
return hw->mac_type == ICE_MAC_E810;
205-
}
206-
207-
/**
208-
* ice_is_e810t
209-
* @hw: pointer to the hardware structure
210-
*
211-
* returns true if the device is E810T based, false if not.
212-
*/
213-
bool ice_is_e810t(struct ice_hw *hw)
214-
{
215-
switch (hw->device_id) {
216-
case ICE_DEV_ID_E810C_SFP:
217-
switch (hw->subsystem_device_id) {
218-
case ICE_SUBDEV_ID_E810T:
219-
case ICE_SUBDEV_ID_E810T2:
220-
case ICE_SUBDEV_ID_E810T3:
221-
case ICE_SUBDEV_ID_E810T4:
222-
case ICE_SUBDEV_ID_E810T6:
223-
case ICE_SUBDEV_ID_E810T7:
224-
return true;
225-
}
226-
break;
227-
case ICE_DEV_ID_E810C_QSFP:
228-
switch (hw->subsystem_device_id) {
229-
case ICE_SUBDEV_ID_E810T2:
230-
case ICE_SUBDEV_ID_E810T3:
231-
case ICE_SUBDEV_ID_E810T5:
232-
return true;
233-
}
234-
break;
235-
default:
236-
break;
237-
}
238-
239-
return false;
240-
}
241-
242-
/**
243-
* ice_is_e822 - Check if a device is E822 family device
244-
* @hw: pointer to the hardware structure
245-
*
246-
* Return: true if the device is E822 based, false if not.
247-
*/
248-
bool ice_is_e822(struct ice_hw *hw)
249-
{
250-
switch (hw->device_id) {
251-
case ICE_DEV_ID_E822C_BACKPLANE:
252-
case ICE_DEV_ID_E822C_QSFP:
253-
case ICE_DEV_ID_E822C_SFP:
254-
case ICE_DEV_ID_E822C_10G_BASE_T:
255-
case ICE_DEV_ID_E822C_SGMII:
256-
case ICE_DEV_ID_E822L_BACKPLANE:
257-
case ICE_DEV_ID_E822L_SFP:
258-
case ICE_DEV_ID_E822L_10G_BASE_T:
259-
case ICE_DEV_ID_E822L_SGMII:
260-
return true;
261-
default:
262-
return false;
263-
}
264-
}
265-
266-
/**
267-
* ice_is_e823
268-
* @hw: pointer to the hardware structure
269-
*
270-
* returns true if the device is E823-L or E823-C based, false if not.
271-
*/
272-
bool ice_is_e823(struct ice_hw *hw)
273-
{
274-
switch (hw->device_id) {
275-
case ICE_DEV_ID_E823L_BACKPLANE:
276-
case ICE_DEV_ID_E823L_SFP:
277-
case ICE_DEV_ID_E823L_10G_BASE_T:
278-
case ICE_DEV_ID_E823L_1GBE:
279-
case ICE_DEV_ID_E823L_QSFP:
280-
case ICE_DEV_ID_E823C_BACKPLANE:
281-
case ICE_DEV_ID_E823C_QSFP:
282-
case ICE_DEV_ID_E823C_SFP:
283-
case ICE_DEV_ID_E823C_10G_BASE_T:
284-
case ICE_DEV_ID_E823C_SGMII:
285-
return true;
286-
default:
287-
return false;
288-
}
289-
}
290-
291-
/**
292-
* ice_is_e825c - Check if a device is E825C family device
293-
* @hw: pointer to the hardware structure
294-
*
295-
* Return: true if the device is E825-C based, false if not.
296-
*/
297-
bool ice_is_e825c(struct ice_hw *hw)
298-
{
299-
switch (hw->device_id) {
300-
case ICE_DEV_ID_E825C_BACKPLANE:
301-
case ICE_DEV_ID_E825C_QSFP:
302-
case ICE_DEV_ID_E825C_SFP:
303-
case ICE_DEV_ID_E825C_SGMII:
304-
return true;
305-
default:
306-
return false;
307-
}
308-
}
309-
310196
/**
311197
* ice_is_pf_c827 - check if pf contains c827 phy
312198
* @hw: pointer to the hw struct
@@ -2388,7 +2274,7 @@ ice_parse_1588_func_caps(struct ice_hw *hw, struct ice_hw_func_caps *func_p,
23882274
info->tmr_index_owned = ((number & ICE_TS_TMR_IDX_OWND_M) != 0);
23892275
info->tmr_index_assoc = ((number & ICE_TS_TMR_IDX_ASSOC_M) != 0);
23902276

2391-
if (!ice_is_e825c(hw)) {
2277+
if (hw->mac_type != ICE_MAC_GENERIC_3K_E825) {
23922278
info->clk_freq = FIELD_GET(ICE_TS_CLK_FREQ_M, number);
23932279
info->clk_src = ((number & ICE_TS_CLK_SRC_M) != 0);
23942280
} else {
@@ -5922,6 +5808,96 @@ ice_aq_write_i2c(struct ice_hw *hw, struct ice_aqc_link_topo_addr topo_addr,
59225808
return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
59235809
}
59245810

5811+
/**
5812+
* ice_get_pca9575_handle - find and return the PCA9575 controller
5813+
* @hw: pointer to the hw struct
5814+
* @pca9575_handle: GPIO controller's handle
5815+
*
5816+
* Find and return the GPIO controller's handle in the netlist.
5817+
* When found - the value will be cached in the hw structure and following calls
5818+
* will return cached value.
5819+
*
5820+
* Return: 0 on success, -ENXIO when there's no PCA9575 present.
5821+
*/
5822+
int ice_get_pca9575_handle(struct ice_hw *hw, u16 *pca9575_handle)
5823+
{
5824+
struct ice_aqc_get_link_topo *cmd;
5825+
struct ice_aq_desc desc;
5826+
int err;
5827+
u8 idx;
5828+
5829+
/* If handle was read previously return cached value */
5830+
if (hw->io_expander_handle) {
5831+
*pca9575_handle = hw->io_expander_handle;
5832+
return 0;
5833+
}
5834+
5835+
#define SW_PCA9575_SFP_TOPO_IDX 2
5836+
#define SW_PCA9575_QSFP_TOPO_IDX 1
5837+
5838+
/* Check if the SW IO expander controlling SMA exists in the netlist. */
5839+
if (hw->device_id == ICE_DEV_ID_E810C_SFP)
5840+
idx = SW_PCA9575_SFP_TOPO_IDX;
5841+
else if (hw->device_id == ICE_DEV_ID_E810C_QSFP)
5842+
idx = SW_PCA9575_QSFP_TOPO_IDX;
5843+
else
5844+
return -ENXIO;
5845+
5846+
/* If handle was not detected read it from the netlist */
5847+
ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_get_link_topo);
5848+
cmd = &desc.params.get_link_topo;
5849+
cmd->addr.topo_params.node_type_ctx =
5850+
ICE_AQC_LINK_TOPO_NODE_TYPE_GPIO_CTRL;
5851+
cmd->addr.topo_params.index = idx;
5852+
5853+
err = ice_aq_send_cmd(hw, &desc, NULL, 0, NULL);
5854+
if (err)
5855+
return -ENXIO;
5856+
5857+
/* Verify if we found the right IO expander type */
5858+
if (desc.params.get_link_topo.node_part_num !=
5859+
ICE_AQC_GET_LINK_TOPO_NODE_NR_PCA9575)
5860+
return -ENXIO;
5861+
5862+
/* If present save the handle and return it */
5863+
hw->io_expander_handle =
5864+
le16_to_cpu(desc.params.get_link_topo.addr.handle);
5865+
*pca9575_handle = hw->io_expander_handle;
5866+
5867+
return 0;
5868+
}
5869+
5870+
/**
5871+
* ice_read_pca9575_reg - read the register from the PCA9575 controller
5872+
* @hw: pointer to the hw struct
5873+
* @offset: GPIO controller register offset
5874+
* @data: pointer to data to be read from the GPIO controller
5875+
*
5876+
* Return: 0 on success, negative error code otherwise.
5877+
*/
5878+
int ice_read_pca9575_reg(struct ice_hw *hw, u8 offset, u8 *data)
5879+
{
5880+
struct ice_aqc_link_topo_addr link_topo;
5881+
__le16 addr;
5882+
u16 handle;
5883+
int err;
5884+
5885+
memset(&link_topo, 0, sizeof(link_topo));
5886+
5887+
err = ice_get_pca9575_handle(hw, &handle);
5888+
if (err)
5889+
return err;
5890+
5891+
link_topo.handle = cpu_to_le16(handle);
5892+
link_topo.topo_params.node_type_ctx =
5893+
FIELD_PREP(ICE_AQC_LINK_TOPO_NODE_CTX_M,
5894+
ICE_AQC_LINK_TOPO_NODE_CTX_PROVIDED);
5895+
5896+
addr = cpu_to_le16((u16)offset);
5897+
5898+
return ice_aq_read_i2c(hw, link_topo, 0, addr, 1, data, NULL);
5899+
}
5900+
59255901
/**
59265902
* ice_aq_set_gpio
59275903
* @hw: pointer to the hw struct

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ int
132132
ice_aq_manage_mac_write(struct ice_hw *hw, const u8 *mac_addr, u8 flags,
133133
struct ice_sq_cd *cd);
134134
bool ice_is_generic_mac(struct ice_hw *hw);
135-
bool ice_is_e810(struct ice_hw *hw);
136135
int ice_clear_pf_cfg(struct ice_hw *hw);
137136
int
138137
ice_aq_set_phy_cfg(struct ice_hw *hw, struct ice_port_info *pi,
@@ -275,10 +274,6 @@ ice_stat_update40(struct ice_hw *hw, u32 reg, bool prev_stat_loaded,
275274
void
276275
ice_stat_update32(struct ice_hw *hw, u32 reg, bool prev_stat_loaded,
277276
u64 *prev_stat, u64 *cur_stat);
278-
bool ice_is_e810t(struct ice_hw *hw);
279-
bool ice_is_e822(struct ice_hw *hw);
280-
bool ice_is_e823(struct ice_hw *hw);
281-
bool ice_is_e825c(struct ice_hw *hw);
282277
int
283278
ice_sched_query_elem(struct ice_hw *hw, u32 node_teid,
284279
struct ice_aqc_txsched_elem_data *buf);
@@ -305,5 +300,7 @@ int
305300
ice_aq_write_i2c(struct ice_hw *hw, struct ice_aqc_link_topo_addr topo_addr,
306301
u16 bus_addr, __le16 addr, u8 params, const u8 *data,
307302
struct ice_sq_cd *cd);
303+
int ice_get_pca9575_handle(struct ice_hw *hw, u16 *pca9575_handle);
304+
int ice_read_pca9575_reg(struct ice_hw *hw, u8 offset, u8 *data);
308305
bool ice_fw_supports_report_dflt_cfg(struct ice_hw *hw);
309306
#endif /* _ICE_COMMON_H_ */

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,14 +2312,14 @@ ice_get_set_tx_topo(struct ice_hw *hw, u8 *buf, u16 buf_size,
23122312
cmd->set_flags |= ICE_AQC_TX_TOPO_FLAGS_SRC_RAM |
23132313
ICE_AQC_TX_TOPO_FLAGS_LOAD_NEW;
23142314

2315-
if (ice_is_e825c(hw))
2315+
if (hw->mac_type == ICE_MAC_GENERIC_3K_E825)
23162316
desc.flags |= cpu_to_le16(ICE_AQ_FLAG_RD);
23172317
} else {
23182318
ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_get_tx_topo);
23192319
cmd->get_flags = ICE_AQC_TX_TOPO_GET_RAM;
23202320
}
23212321

2322-
if (!ice_is_e825c(hw))
2322+
if (hw->mac_type != ICE_MAC_GENERIC_3K_E825)
23232323
desc.flags |= cpu_to_le16(ICE_AQ_FLAG_RD);
23242324

23252325
status = ice_aq_send_cmd(hw, &desc, buf, buf_size, cd);

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

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -381,32 +381,23 @@ void ice_gnss_exit(struct ice_pf *pf)
381381
}
382382

383383
/**
384-
* ice_gnss_is_gps_present - Check if GPS HW is present
384+
* ice_gnss_is_module_present - Check if GNSS HW is present
385385
* @hw: pointer to HW struct
386+
*
387+
* Return: true when GNSS is present, false otherwise.
386388
*/
387-
bool ice_gnss_is_gps_present(struct ice_hw *hw)
389+
bool ice_gnss_is_module_present(struct ice_hw *hw)
388390
{
389-
if (!hw->func_caps.ts_func_info.src_tmr_owned)
390-
return false;
391+
int err;
392+
u8 data;
391393

392-
if (!ice_is_gps_in_netlist(hw))
394+
if (!hw->func_caps.ts_func_info.src_tmr_owned ||
395+
!ice_is_gps_in_netlist(hw))
393396
return false;
394397

395-
#if IS_ENABLED(CONFIG_PTP_1588_CLOCK)
396-
if (ice_is_e810t(hw)) {
397-
int err;
398-
u8 data;
399-
400-
err = ice_read_pca9575_reg(hw, ICE_PCA9575_P0_IN, &data);
401-
if (err || !!(data & ICE_P0_GNSS_PRSNT_N))
402-
return false;
403-
} else {
404-
return false;
405-
}
406-
#else
407-
if (!ice_is_e810t(hw))
398+
err = ice_read_pca9575_reg(hw, ICE_PCA9575_P0_IN, &data);
399+
if (err || !!(data & ICE_P0_GNSS_PRSNT_N))
408400
return false;
409-
#endif /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */
410401

411402
return true;
412403
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ struct gnss_serial {
3737
#if IS_ENABLED(CONFIG_GNSS)
3838
void ice_gnss_init(struct ice_pf *pf);
3939
void ice_gnss_exit(struct ice_pf *pf);
40-
bool ice_gnss_is_gps_present(struct ice_hw *hw);
40+
bool ice_gnss_is_module_present(struct ice_hw *hw);
4141
#else
4242
static inline void ice_gnss_init(struct ice_pf *pf) { }
4343
static inline void ice_gnss_exit(struct ice_pf *pf) { }
44-
static inline bool ice_gnss_is_gps_present(struct ice_hw *hw)
44+
static inline bool ice_gnss_is_module_present(struct ice_hw *hw)
4545
{
4646
return false;
4747
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,10 +533,22 @@
533533
#define PFPM_WUS_MAG_M BIT(1)
534534
#define PFPM_WUS_MNG_M BIT(3)
535535
#define PFPM_WUS_FW_RST_WK_M BIT(31)
536+
#define E830_PRTMAC_TS_TX_MEM_VALID_H 0x001E2020
537+
#define E830_PRTMAC_TS_TX_MEM_VALID_L 0x001E2000
536538
#define E830_PRTMAC_CL01_PS_QNT 0x001E32A0
537539
#define E830_PRTMAC_CL01_PS_QNT_CL0_M GENMASK(15, 0)
538540
#define E830_PRTMAC_CL01_QNT_THR 0x001E3320
539541
#define E830_PRTMAC_CL01_QNT_THR_CL0_M GENMASK(15, 0)
542+
#define E830_PRTTSYN_TXTIME_H(_i) (0x001E5800 + ((_i) * 32))
543+
#define E830_PRTTSYN_TXTIME_L(_i) (0x001E5000 + ((_i) * 32))
544+
#define E830_GLPTM_ART_CTL 0x00088B50
545+
#define E830_GLPTM_ART_CTL_ACTIVE_M BIT(0)
546+
#define E830_GLPTM_ART_TIME_H 0x00088B54
547+
#define E830_GLPTM_ART_TIME_L 0x00088B58
548+
#define E830_GLTSYN_PTMTIME_H(_i) (0x00088B48 + ((_i) * 4))
549+
#define E830_GLTSYN_PTMTIME_L(_i) (0x00088B40 + ((_i) * 4))
550+
#define E830_PFPTM_SEM 0x00088B00
551+
#define E830_PFPTM_SEM_BUSY_M BIT(0)
540552
#define VFINT_DYN_CTLN(_i) (0x00003800 + ((_i) * 4))
541553
#define VFINT_DYN_CTLN_CLEARPBA_M BIT(1)
542554

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3885,7 +3885,7 @@ void ice_init_feature_support(struct ice_pf *pf)
38853885
ice_set_feature_support(pf, ICE_F_CGU);
38863886
if (ice_is_clock_mux_in_netlist(&pf->hw))
38873887
ice_set_feature_support(pf, ICE_F_SMA_CTRL);
3888-
if (ice_gnss_is_gps_present(&pf->hw))
3888+
if (ice_gnss_is_module_present(&pf->hw))
38893889
ice_set_feature_support(pf, ICE_F_GNSS);
38903890
break;
38913891
default:

0 commit comments

Comments
 (0)