Skip to content

Commit 54c52ff

Browse files
kolacinskikaroljfvogel
authored andcommitted
ice: Add correct PHY lane assignment
[ Upstream commit 258f5f9 ] Driver always naively assumes, that for PTP purposes, PHY lane to configure is corresponding to PF ID. This is not true for some port configurations, e.g.: - 2x50G per quad, where lanes used are 0 and 2 on each quad, but PF IDs are 0 and 1 - 100G per quad on 2 quads, where lanes used are 0 and 4, but PF IDs are 0 and 1 Use correct PHY lane assignment by getting and parsing port options. This is read from the NVM by the FW and provided to the driver with the indication of active port split. Remove ice_is_muxed_topo(), which is no longer needed. Fixes: 4409ea1 ("ice: Adjust PTP init for 2x50G E825C devices") Reviewed-by: Przemek Kitszel <[email protected]> Reviewed-by: Arkadiusz Kubalewski <[email protected]> Signed-off-by: Karol Kolacinski <[email protected]> Signed-off-by: Grzegorz Nitka <[email protected]> Tested-by: Pucha Himasekhar Reddy <[email protected]> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 11a642ad58a2a0f7b63ae642d6ecda88f2189636) Signed-off-by: Jack Vogel <[email protected]>
1 parent 09d2229 commit 54c52ff

File tree

8 files changed

+68
-45
lines changed

8 files changed

+68
-45
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,7 @@ struct ice_aqc_get_port_options_elem {
16481648
#define ICE_AQC_PORT_OPT_MAX_LANE_25G 5
16491649
#define ICE_AQC_PORT_OPT_MAX_LANE_50G 6
16501650
#define ICE_AQC_PORT_OPT_MAX_LANE_100G 7
1651+
#define ICE_AQC_PORT_OPT_MAX_LANE_200G 8
16511652

16521653
u8 global_scid[2];
16531654
u8 phy_scid[2];

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4074,6 +4074,57 @@ ice_aq_set_port_option(struct ice_hw *hw, u8 lport, u8 lport_valid,
40744074
return ice_aq_send_cmd(hw, &desc, NULL, 0, NULL);
40754075
}
40764076

4077+
/**
4078+
* ice_get_phy_lane_number - Get PHY lane number for current adapter
4079+
* @hw: pointer to the hw struct
4080+
*
4081+
* Return: PHY lane number on success, negative error code otherwise.
4082+
*/
4083+
int ice_get_phy_lane_number(struct ice_hw *hw)
4084+
{
4085+
struct ice_aqc_get_port_options_elem *options;
4086+
unsigned int lport = 0;
4087+
unsigned int lane;
4088+
int err;
4089+
4090+
options = kcalloc(ICE_AQC_PORT_OPT_MAX, sizeof(*options), GFP_KERNEL);
4091+
if (!options)
4092+
return -ENOMEM;
4093+
4094+
for (lane = 0; lane < ICE_MAX_PORT_PER_PCI_DEV; lane++) {
4095+
u8 options_count = ICE_AQC_PORT_OPT_MAX;
4096+
u8 speed, active_idx, pending_idx;
4097+
bool active_valid, pending_valid;
4098+
4099+
err = ice_aq_get_port_options(hw, options, &options_count, lane,
4100+
true, &active_idx, &active_valid,
4101+
&pending_idx, &pending_valid);
4102+
if (err)
4103+
goto err;
4104+
4105+
if (!active_valid)
4106+
continue;
4107+
4108+
speed = options[active_idx].max_lane_speed;
4109+
/* If we don't get speed for this lane, it's unoccupied */
4110+
if (speed > ICE_AQC_PORT_OPT_MAX_LANE_200G)
4111+
continue;
4112+
4113+
if (hw->pf_id == lport) {
4114+
kfree(options);
4115+
return lane;
4116+
}
4117+
4118+
lport++;
4119+
}
4120+
4121+
/* PHY lane not found */
4122+
err = -ENXIO;
4123+
err:
4124+
kfree(options);
4125+
return err;
4126+
}
4127+
40774128
/**
40784129
* ice_aq_sff_eeprom
40794130
* @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
@@ -193,6 +193,7 @@ ice_aq_get_port_options(struct ice_hw *hw,
193193
int
194194
ice_aq_set_port_option(struct ice_hw *hw, u8 lport, u8 lport_valid,
195195
u8 new_option);
196+
int ice_get_phy_lane_number(struct ice_hw *hw);
196197
int
197198
ice_aq_sff_eeprom(struct ice_hw *hw, u16 lport, u8 bus_addr,
198199
u16 mem_addr, u8 page, u8 set_page, u8 *data, u8 length,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ ice_link_event(struct ice_pf *pf, struct ice_port_info *pi, bool link_up,
11441144
if (link_up == old_link && link_speed == old_link_speed)
11451145
return 0;
11461146

1147-
ice_ptp_link_change(pf, pf->hw.pf_id, link_up);
1147+
ice_ptp_link_change(pf, link_up);
11481148

11491149
if (ice_is_dcb_active(pf)) {
11501150
if (test_bit(ICE_FLAG_DCB_ENA, pf->flags))
@@ -6744,7 +6744,7 @@ static int ice_up_complete(struct ice_vsi *vsi)
67446744
ice_print_link_msg(vsi, true);
67456745
netif_tx_start_all_queues(vsi->netdev);
67466746
netif_carrier_on(vsi->netdev);
6747-
ice_ptp_link_change(pf, pf->hw.pf_id, true);
6747+
ice_ptp_link_change(pf, true);
67486748
}
67496749

67506750
/* Perform an initial read of the statistics registers now to
@@ -7214,7 +7214,7 @@ int ice_down(struct ice_vsi *vsi)
72147214

72157215
if (vsi->netdev) {
72167216
vlan_err = ice_vsi_del_vlan_zero(vsi);
7217-
ice_ptp_link_change(vsi->back, vsi->back->hw.pf_id, false);
7217+
ice_ptp_link_change(vsi->back, false);
72187218
netif_carrier_off(vsi->netdev);
72197219
netif_tx_disable(vsi->netdev);
72207220
}

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,25 +1466,17 @@ ice_ptp_port_phy_restart(struct ice_ptp_port *ptp_port)
14661466
/**
14671467
* ice_ptp_link_change - Reconfigure PTP after link status change
14681468
* @pf: Board private structure
1469-
* @port: Port for which the PHY start is set
14701469
* @linkup: Link is up or down
14711470
*/
1472-
void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup)
1471+
void ice_ptp_link_change(struct ice_pf *pf, bool linkup)
14731472
{
14741473
struct ice_ptp_port *ptp_port;
14751474
struct ice_hw *hw = &pf->hw;
14761475

14771476
if (pf->ptp.state != ICE_PTP_READY)
14781477
return;
14791478

1480-
if (WARN_ON_ONCE(port >= hw->ptp.num_lports))
1481-
return;
1482-
14831479
ptp_port = &pf->ptp.port;
1484-
if (ice_is_e825c(hw) && hw->ptp.is_2x50g_muxed_topo)
1485-
port *= 2;
1486-
if (WARN_ON_ONCE(ptp_port->port_num != port))
1487-
return;
14881480

14891481
/* Update cached link status for this port immediately */
14901482
ptp_port->link_up = linkup;
@@ -3383,10 +3375,17 @@ void ice_ptp_init(struct ice_pf *pf)
33833375
{
33843376
struct ice_ptp *ptp = &pf->ptp;
33853377
struct ice_hw *hw = &pf->hw;
3386-
int err;
3378+
int lane_num, err;
33873379

33883380
ptp->state = ICE_PTP_INITIALIZING;
33893381

3382+
lane_num = ice_get_phy_lane_number(hw);
3383+
if (lane_num < 0) {
3384+
err = lane_num;
3385+
goto err_exit;
3386+
}
3387+
3388+
ptp->port.port_num = (u8)lane_num;
33903389
ice_ptp_init_hw(hw);
33913390

33923391
ice_ptp_init_tx_interrupt_mode(pf);
@@ -3407,10 +3406,6 @@ void ice_ptp_init(struct ice_pf *pf)
34073406
if (err)
34083407
goto err_exit;
34093408

3410-
ptp->port.port_num = hw->pf_id;
3411-
if (ice_is_e825c(hw) && hw->ptp.is_2x50g_muxed_topo)
3412-
ptp->port.port_num = hw->pf_id * 2;
3413-
34143409
err = ice_ptp_init_port(pf, &ptp->port);
34153410
if (err)
34163411
goto err_exit;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ void ice_ptp_prepare_for_reset(struct ice_pf *pf,
332332
enum ice_reset_req reset_type);
333333
void ice_ptp_init(struct ice_pf *pf);
334334
void ice_ptp_release(struct ice_pf *pf);
335-
void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup);
335+
void ice_ptp_link_change(struct ice_pf *pf, bool linkup);
336336
#else /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */
337337
static inline int ice_ptp_set_ts_config(struct ice_pf *pf, struct ifreq *ifr)
338338
{
@@ -380,7 +380,7 @@ static inline void ice_ptp_prepare_for_reset(struct ice_pf *pf,
380380
}
381381
static inline void ice_ptp_init(struct ice_pf *pf) { }
382382
static inline void ice_ptp_release(struct ice_pf *pf) { }
383-
static inline void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup)
383+
static inline void ice_ptp_link_change(struct ice_pf *pf, bool linkup)
384384
{
385385
}
386386

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

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2698,26 +2698,6 @@ static int ice_get_phy_tx_tstamp_ready_eth56g(struct ice_hw *hw, u8 port,
26982698
return 0;
26992699
}
27002700

2701-
/**
2702-
* ice_is_muxed_topo - detect breakout 2x50G topology for E825C
2703-
* @hw: pointer to the HW struct
2704-
*
2705-
* Return: true if it's 2x50 breakout topology, false otherwise
2706-
*/
2707-
static bool ice_is_muxed_topo(struct ice_hw *hw)
2708-
{
2709-
u8 link_topo;
2710-
bool mux;
2711-
u32 val;
2712-
2713-
val = rd32(hw, GLGEN_SWITCH_MODE_CONFIG);
2714-
mux = FIELD_GET(GLGEN_SWITCH_MODE_CONFIG_25X4_QUAD_M, val);
2715-
val = rd32(hw, GLGEN_MAC_LINK_TOPO);
2716-
link_topo = FIELD_GET(GLGEN_MAC_LINK_TOPO_LINK_TOPO_M, val);
2717-
2718-
return (mux && link_topo == ICE_LINK_TOPO_UP_TO_2_LINKS);
2719-
}
2720-
27212701
/**
27222702
* ice_ptp_init_phy_e825 - initialize PHY parameters
27232703
* @hw: pointer to the HW struct
@@ -2740,12 +2720,8 @@ static void ice_ptp_init_phy_e825(struct ice_hw *hw)
27402720

27412721
ice_sb_access_ena_eth56g(hw, true);
27422722
err = ice_read_phy_eth56g(hw, hw->pf_id, PHY_REG_REVISION, &phy_rev);
2743-
if (err || phy_rev != PHY_REVISION_ETH56G) {
2723+
if (err || phy_rev != PHY_REVISION_ETH56G)
27442724
ptp->phy_model = ICE_PHY_UNSUP;
2745-
return;
2746-
}
2747-
2748-
ptp->is_2x50g_muxed_topo = ice_is_muxed_topo(hw);
27492725
}
27502726

27512727
/* E822 family functions

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,6 @@ struct ice_ptp_hw {
880880
union ice_phy_params phy;
881881
u8 num_lports;
882882
u8 ports_per_phy;
883-
bool is_2x50g_muxed_topo;
884883
};
885884

886885
/* Port hardware description */

0 commit comments

Comments
 (0)