Skip to content

Commit 258f5f9

Browse files
kolacinskikarolanguy11
authored andcommitted
ice: Add correct PHY lane assignment
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]>
1 parent 2e60560 commit 258f5f9

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
@@ -1665,6 +1665,7 @@ struct ice_aqc_get_port_options_elem {
16651665
#define ICE_AQC_PORT_OPT_MAX_LANE_25G 5
16661666
#define ICE_AQC_PORT_OPT_MAX_LANE_50G 6
16671667
#define ICE_AQC_PORT_OPT_MAX_LANE_100G 7
1668+
#define ICE_AQC_PORT_OPT_MAX_LANE_200G 8
16681669

16691670
u8 global_scid[2];
16701671
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
@@ -4095,6 +4095,57 @@ ice_aq_set_port_option(struct ice_hw *hw, u8 lport, u8 lport_valid,
40954095
return ice_aq_send_cmd(hw, &desc, NULL, 0, NULL);
40964096
}
40974097

4098+
/**
4099+
* ice_get_phy_lane_number - Get PHY lane number for current adapter
4100+
* @hw: pointer to the hw struct
4101+
*
4102+
* Return: PHY lane number on success, negative error code otherwise.
4103+
*/
4104+
int ice_get_phy_lane_number(struct ice_hw *hw)
4105+
{
4106+
struct ice_aqc_get_port_options_elem *options;
4107+
unsigned int lport = 0;
4108+
unsigned int lane;
4109+
int err;
4110+
4111+
options = kcalloc(ICE_AQC_PORT_OPT_MAX, sizeof(*options), GFP_KERNEL);
4112+
if (!options)
4113+
return -ENOMEM;
4114+
4115+
for (lane = 0; lane < ICE_MAX_PORT_PER_PCI_DEV; lane++) {
4116+
u8 options_count = ICE_AQC_PORT_OPT_MAX;
4117+
u8 speed, active_idx, pending_idx;
4118+
bool active_valid, pending_valid;
4119+
4120+
err = ice_aq_get_port_options(hw, options, &options_count, lane,
4121+
true, &active_idx, &active_valid,
4122+
&pending_idx, &pending_valid);
4123+
if (err)
4124+
goto err;
4125+
4126+
if (!active_valid)
4127+
continue;
4128+
4129+
speed = options[active_idx].max_lane_speed;
4130+
/* If we don't get speed for this lane, it's unoccupied */
4131+
if (speed > ICE_AQC_PORT_OPT_MAX_LANE_200G)
4132+
continue;
4133+
4134+
if (hw->pf_id == lport) {
4135+
kfree(options);
4136+
return lane;
4137+
}
4138+
4139+
lport++;
4140+
}
4141+
4142+
/* PHY lane not found */
4143+
err = -ENXIO;
4144+
err:
4145+
kfree(options);
4146+
return err;
4147+
}
4148+
40984149
/**
40994150
* ice_aq_sff_eeprom
41004151
* @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))
@@ -6790,7 +6790,7 @@ static int ice_up_complete(struct ice_vsi *vsi)
67906790
ice_print_link_msg(vsi, true);
67916791
netif_tx_start_all_queues(vsi->netdev);
67926792
netif_carrier_on(vsi->netdev);
6793-
ice_ptp_link_change(pf, pf->hw.pf_id, true);
6793+
ice_ptp_link_change(pf, true);
67946794
}
67956795

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

72617261
if (vsi->netdev) {
72627262
vlan_err = ice_vsi_del_vlan_zero(vsi);
7263-
ice_ptp_link_change(vsi->back, vsi->back->hw.pf_id, false);
7263+
ice_ptp_link_change(vsi->back, false);
72647264
netif_carrier_off(vsi->netdev);
72657265
netif_tx_disable(vsi->netdev);
72667266
}

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,25 +1388,17 @@ ice_ptp_port_phy_restart(struct ice_ptp_port *ptp_port)
13881388
/**
13891389
* ice_ptp_link_change - Reconfigure PTP after link status change
13901390
* @pf: Board private structure
1391-
* @port: Port for which the PHY start is set
13921391
* @linkup: Link is up or down
13931392
*/
1394-
void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup)
1393+
void ice_ptp_link_change(struct ice_pf *pf, bool linkup)
13951394
{
13961395
struct ice_ptp_port *ptp_port;
13971396
struct ice_hw *hw = &pf->hw;
13981397

13991398
if (pf->ptp.state != ICE_PTP_READY)
14001399
return;
14011400

1402-
if (WARN_ON_ONCE(port >= hw->ptp.num_lports))
1403-
return;
1404-
14051401
ptp_port = &pf->ptp.port;
1406-
if (ice_is_e825c(hw) && hw->ptp.is_2x50g_muxed_topo)
1407-
port *= 2;
1408-
if (WARN_ON_ONCE(ptp_port->port_num != port))
1409-
return;
14101402

14111403
/* Update cached link status for this port immediately */
14121404
ptp_port->link_up = linkup;
@@ -3164,10 +3156,17 @@ void ice_ptp_init(struct ice_pf *pf)
31643156
{
31653157
struct ice_ptp *ptp = &pf->ptp;
31663158
struct ice_hw *hw = &pf->hw;
3167-
int err;
3159+
int lane_num, err;
31683160

31693161
ptp->state = ICE_PTP_INITIALIZING;
31703162

3163+
lane_num = ice_get_phy_lane_number(hw);
3164+
if (lane_num < 0) {
3165+
err = lane_num;
3166+
goto err_exit;
3167+
}
3168+
3169+
ptp->port.port_num = (u8)lane_num;
31713170
ice_ptp_init_hw(hw);
31723171

31733172
ice_ptp_init_tx_interrupt_mode(pf);
@@ -3188,10 +3187,6 @@ void ice_ptp_init(struct ice_pf *pf)
31883187
if (err)
31893188
goto err_exit;
31903189

3191-
ptp->port.port_num = hw->pf_id;
3192-
if (ice_is_e825c(hw) && hw->ptp.is_2x50g_muxed_topo)
3193-
ptp->port.port_num = hw->pf_id * 2;
3194-
31953190
err = ice_ptp_init_port(pf, &ptp->port);
31963191
if (err)
31973192
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
@@ -310,7 +310,7 @@ void ice_ptp_prepare_for_reset(struct ice_pf *pf,
310310
enum ice_reset_req reset_type);
311311
void ice_ptp_init(struct ice_pf *pf);
312312
void ice_ptp_release(struct ice_pf *pf);
313-
void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup);
313+
void ice_ptp_link_change(struct ice_pf *pf, bool linkup);
314314
#else /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */
315315
static inline int ice_ptp_set_ts_config(struct ice_pf *pf, struct ifreq *ifr)
316316
{
@@ -358,7 +358,7 @@ static inline void ice_ptp_prepare_for_reset(struct ice_pf *pf,
358358
}
359359
static inline void ice_ptp_init(struct ice_pf *pf) { }
360360
static inline void ice_ptp_release(struct ice_pf *pf) { }
361-
static inline void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup)
361+
static inline void ice_ptp_link_change(struct ice_pf *pf, bool linkup)
362362
{
363363
}
364364

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

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

2724-
/**
2725-
* ice_is_muxed_topo - detect breakout 2x50G topology for E825C
2726-
* @hw: pointer to the HW struct
2727-
*
2728-
* Return: true if it's 2x50 breakout topology, false otherwise
2729-
*/
2730-
static bool ice_is_muxed_topo(struct ice_hw *hw)
2731-
{
2732-
u8 link_topo;
2733-
bool mux;
2734-
u32 val;
2735-
2736-
val = rd32(hw, GLGEN_SWITCH_MODE_CONFIG);
2737-
mux = FIELD_GET(GLGEN_SWITCH_MODE_CONFIG_25X4_QUAD_M, val);
2738-
val = rd32(hw, GLGEN_MAC_LINK_TOPO);
2739-
link_topo = FIELD_GET(GLGEN_MAC_LINK_TOPO_LINK_TOPO_M, val);
2740-
2741-
return (mux && link_topo == ICE_LINK_TOPO_UP_TO_2_LINKS);
2742-
}
2743-
27442724
/**
27452725
* ice_ptp_init_phy_e825 - initialize PHY parameters
27462726
* @hw: pointer to the HW struct
@@ -2763,12 +2743,8 @@ static void ice_ptp_init_phy_e825(struct ice_hw *hw)
27632743

27642744
ice_sb_access_ena_eth56g(hw, true);
27652745
err = ice_read_phy_eth56g(hw, hw->pf_id, PHY_REG_REVISION, &phy_rev);
2766-
if (err || phy_rev != PHY_REVISION_ETH56G) {
2746+
if (err || phy_rev != PHY_REVISION_ETH56G)
27672747
ptp->phy_model = ICE_PHY_UNSUP;
2768-
return;
2769-
}
2770-
2771-
ptp->is_2x50g_muxed_topo = ice_is_muxed_topo(hw);
27722748
}
27732749

27742750
/* 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)