Skip to content

Commit fd8d7e4

Browse files
committed
ice: Introduce ice_get_phy_model() wrapper
JIRA: https://issues.redhat.com/browse/RHEL-29207 Upstream commit(s): commit 5e07764 Author: Sergey Temerkhanov <sergey.temerkhanov@intel.com> Date: Wed Aug 21 15:09:53 2024 +0200 ice: Introduce ice_get_phy_model() wrapper Introduce ice_get_phy_model() to improve code readability Signed-off-by: Sergey Temerkhanov <sergey.temerkhanov@intel.com> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Reviewed-by: Simon Horman <horms@kernel.org> Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Signed-off-by: Petr Oros <poros@redhat.com>
1 parent 88269ec commit fd8d7e4

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,5 +1046,10 @@ 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+
10491054
extern const struct xdp_metadata_ops ice_xdp_md_ops;
10501055
#endif /* _ICE_H_ */

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ ice_ptp_port_phy_stop(struct ice_ptp_port *ptp_port)
13111311

13121312
mutex_lock(&ptp_port->ps_lock);
13131313

1314-
switch (hw->ptp.phy_model) {
1314+
switch (ice_get_phy_model(hw)) {
13151315
case ICE_PHY_ETH56G:
13161316
err = ice_stop_phy_timer_eth56g(hw, port, true);
13171317
break;
@@ -1357,7 +1357,7 @@ ice_ptp_port_phy_restart(struct ice_ptp_port *ptp_port)
13571357

13581358
mutex_lock(&ptp_port->ps_lock);
13591359

1360-
switch (hw->ptp.phy_model) {
1360+
switch (ice_get_phy_model(hw)) {
13611361
case ICE_PHY_ETH56G:
13621362
err = ice_start_phy_timer_eth56g(hw, port);
13631363
break;
@@ -1420,8 +1420,7 @@ void ice_ptp_link_change(struct ice_pf *pf, bool linkup)
14201420
/* Skip HW writes if reset is in progress */
14211421
if (pf->hw.reset_ongoing)
14221422
return;
1423-
1424-
switch (hw->ptp.phy_model) {
1423+
switch (ice_get_phy_model(hw)) {
14251424
case ICE_PHY_E810:
14261425
/* Do not reconfigure E810 PHY */
14271426
return;
@@ -1454,7 +1453,7 @@ static int ice_ptp_cfg_phy_interrupt(struct ice_pf *pf, bool ena, u32 threshold)
14541453

14551454
ice_ptp_reset_ts_memory(hw);
14561455

1457-
switch (hw->ptp.phy_model) {
1456+
switch (ice_get_phy_model(hw)) {
14581457
case ICE_PHY_ETH56G: {
14591458
int port;
14601459

@@ -1493,7 +1492,7 @@ static int ice_ptp_cfg_phy_interrupt(struct ice_pf *pf, bool ena, u32 threshold)
14931492
case ICE_PHY_UNSUP:
14941493
default:
14951494
dev_warn(dev, "%s: Unexpected PHY model %d\n", __func__,
1496-
hw->ptp.phy_model);
1495+
ice_get_phy_model(hw));
14971496
return -EOPNOTSUPP;
14981497
}
14991498
}
@@ -2055,7 +2054,7 @@ ice_ptp_settime64(struct ptp_clock_info *info, const struct timespec64 *ts)
20552054
/* For Vernier mode on E82X, we need to recalibrate after new settime.
20562055
* Start with marking timestamps as invalid.
20572056
*/
2058-
if (hw->ptp.phy_model == ICE_PHY_E82X) {
2057+
if (ice_get_phy_model(hw) == ICE_PHY_E82X) {
20592058
err = ice_ptp_clear_phy_offset_ready_e82x(hw);
20602059
if (err)
20612060
dev_warn(ice_pf_to_dev(pf), "Failed to mark timestamps as invalid before settime\n");
@@ -2079,7 +2078,7 @@ ice_ptp_settime64(struct ptp_clock_info *info, const struct timespec64 *ts)
20792078
ice_ptp_enable_all_perout(pf);
20802079

20812080
/* Recalibrate and re-enable timestamp blocks for E822/E823 */
2082-
if (hw->ptp.phy_model == ICE_PHY_E82X)
2081+
if (ice_get_phy_model(hw) == ICE_PHY_E82X)
20832082
ice_ptp_restart_all_phy(pf);
20842083
exit:
20852084
if (err) {
@@ -3260,7 +3259,7 @@ static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port)
32603259

32613260
mutex_init(&ptp_port->ps_lock);
32623261

3263-
switch (hw->ptp.phy_model) {
3262+
switch (ice_get_phy_model(hw)) {
32643263
case ICE_PHY_ETH56G:
32653264
return ice_ptp_init_tx_eth56g(pf, &ptp_port->tx,
32663265
ptp_port->port_num);
@@ -3358,7 +3357,7 @@ static void ice_ptp_remove_auxbus_device(struct ice_pf *pf)
33583357
*/
33593358
static void ice_ptp_init_tx_interrupt_mode(struct ice_pf *pf)
33603359
{
3361-
switch (pf->hw.ptp.phy_model) {
3360+
switch (ice_get_phy_model(&pf->hw)) {
33623361
case ICE_PHY_E82X:
33633362
/* E822 based PHY has the clock owner process the interrupt
33643363
* for all ports.

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ static u32 ice_ptp_tmr_cmd_to_port_reg(struct ice_hw *hw,
827827
/* Certain hardware families share the same register values for the
828828
* port register and source timer register.
829829
*/
830-
switch (hw->ptp.phy_model) {
830+
switch (ice_get_phy_model(hw)) {
831831
case ICE_PHY_E810:
832832
return ice_ptp_tmr_cmd_to_src_reg(hw, cmd) & TS_CMD_MASK_E810;
833833
default:
@@ -5639,7 +5639,7 @@ void ice_ptp_init_hw(struct ice_hw *hw)
56395639
static int ice_ptp_write_port_cmd(struct ice_hw *hw, u8 port,
56405640
enum ice_ptp_tmr_cmd cmd)
56415641
{
5642-
switch (hw->ptp.phy_model) {
5642+
switch (ice_get_phy_model(hw)) {
56435643
case ICE_PHY_ETH56G:
56445644
return ice_ptp_write_port_cmd_eth56g(hw, port, cmd);
56455645
case ICE_PHY_E82X:
@@ -5704,7 +5704,7 @@ static int ice_ptp_port_cmd(struct ice_hw *hw, enum ice_ptp_tmr_cmd cmd)
57045704
u32 port;
57055705

57065706
/* PHY models which can program all ports simultaneously */
5707-
switch (hw->ptp.phy_model) {
5707+
switch (ice_get_phy_model(hw)) {
57085708
case ICE_PHY_E810:
57095709
return ice_ptp_port_cmd_e810(hw, cmd);
57105710
default:
@@ -5783,7 +5783,7 @@ int ice_ptp_init_time(struct ice_hw *hw, u64 time)
57835783

57845784
/* PHY timers */
57855785
/* Fill Rx and Tx ports and send msg to PHY */
5786-
switch (hw->ptp.phy_model) {
5786+
switch (ice_get_phy_model(hw)) {
57875787
case ICE_PHY_ETH56G:
57885788
err = ice_ptp_prep_phy_time_eth56g(hw,
57895789
(u32)(time & 0xFFFFFFFF));
@@ -5829,7 +5829,7 @@ int ice_ptp_write_incval(struct ice_hw *hw, u64 incval)
58295829
wr32(hw, GLTSYN_SHADJ_L(tmr_idx), lower_32_bits(incval));
58305830
wr32(hw, GLTSYN_SHADJ_H(tmr_idx), upper_32_bits(incval));
58315831

5832-
switch (hw->ptp.phy_model) {
5832+
switch (ice_get_phy_model(hw)) {
58335833
case ICE_PHY_ETH56G:
58345834
err = ice_ptp_prep_phy_incval_eth56g(hw, incval);
58355835
break;
@@ -5898,7 +5898,7 @@ int ice_ptp_adj_clock(struct ice_hw *hw, s32 adj)
58985898
wr32(hw, GLTSYN_SHADJ_L(tmr_idx), 0);
58995899
wr32(hw, GLTSYN_SHADJ_H(tmr_idx), adj);
59005900

5901-
switch (hw->ptp.phy_model) {
5901+
switch (ice_get_phy_model(hw)) {
59025902
case ICE_PHY_ETH56G:
59035903
err = ice_ptp_prep_phy_adj_eth56g(hw, adj);
59045904
break;
@@ -5931,7 +5931,7 @@ int ice_ptp_adj_clock(struct ice_hw *hw, s32 adj)
59315931
*/
59325932
int ice_read_phy_tstamp(struct ice_hw *hw, u8 block, u8 idx, u64 *tstamp)
59335933
{
5934-
switch (hw->ptp.phy_model) {
5934+
switch (ice_get_phy_model(hw)) {
59355935
case ICE_PHY_ETH56G:
59365936
return ice_read_ptp_tstamp_eth56g(hw, block, idx, tstamp);
59375937
case ICE_PHY_E810:
@@ -5961,7 +5961,7 @@ int ice_read_phy_tstamp(struct ice_hw *hw, u8 block, u8 idx, u64 *tstamp)
59615961
*/
59625962
int ice_clear_phy_tstamp(struct ice_hw *hw, u8 block, u8 idx)
59635963
{
5964-
switch (hw->ptp.phy_model) {
5964+
switch (ice_get_phy_model(hw)) {
59655965
case ICE_PHY_ETH56G:
59665966
return ice_clear_ptp_tstamp_eth56g(hw, block, idx);
59675967
case ICE_PHY_E810:
@@ -6024,7 +6024,7 @@ static int ice_get_pf_c827_idx(struct ice_hw *hw, u8 *idx)
60246024
*/
60256025
void ice_ptp_reset_ts_memory(struct ice_hw *hw)
60266026
{
6027-
switch (hw->ptp.phy_model) {
6027+
switch (ice_get_phy_model(hw)) {
60286028
case ICE_PHY_ETH56G:
60296029
ice_ptp_reset_ts_memory_eth56g(hw);
60306030
break;
@@ -6053,7 +6053,7 @@ int ice_ptp_init_phc(struct ice_hw *hw)
60536053
/* Clear event err indications for auxiliary pins */
60546054
(void)rd32(hw, GLTSYN_STAT(src_idx));
60556055

6056-
switch (hw->ptp.phy_model) {
6056+
switch (ice_get_phy_model(hw)) {
60576057
case ICE_PHY_ETH56G:
60586058
return ice_ptp_init_phc_eth56g(hw);
60596059
case ICE_PHY_E810:
@@ -6078,7 +6078,7 @@ int ice_ptp_init_phc(struct ice_hw *hw)
60786078
*/
60796079
int ice_get_phy_tx_tstamp_ready(struct ice_hw *hw, u8 block, u64 *tstamp_ready)
60806080
{
6081-
switch (hw->ptp.phy_model) {
6081+
switch (ice_get_phy_model(hw)) {
60826082
case ICE_PHY_ETH56G:
60836083
return ice_get_phy_tx_tstamp_ready_eth56g(hw, block,
60846084
tstamp_ready);

0 commit comments

Comments
 (0)