Skip to content

Commit 05eb60e

Browse files
Peiyang WangPaolo Abeni
authored andcommitted
net: hns3: using user configure after hardware reset
When a reset occurring, it's supposed to recover user's configuration. Currently, the port info(speed, duplex and autoneg) is stored in hclge_mac and will be scheduled updated. Consider the case that reset was happened consecutively. During the first reset, the port info is configured with a temporary value cause the PHY is reset and looking for best link config. Second reset start and use pervious configuration which is not the user's. The specific process is as follows: +------+ +----+ +----+ | USER | | PF | | HW | +---+--+ +-+--+ +-+--+ | ethtool --reset | | +------------------->| reset command | | ethtool --reset +-------------------->| +------------------->| +---+ | +---+ | | | | |reset currently | | HW RESET | | |and wait to do | | | |<--+ | | | | send pervious cfg |<--+ | | (1000M FULL AN_ON) | | +-------------------->| | | read cfg(time task) | | | (10M HALF AN_OFF) +---+ | |<--------------------+ | cfg take effect | | reset command |<--+ | +-------------------->| | | +---+ | | send pervious cfg | | HW RESET | | (10M HALF AN_OFF) |<--+ | +-------------------->| | | read cfg(time task) | | | (10M HALF AN_OFF) +---+ | |<--------------------+ | cfg take effect | | | | | | read cfg(time task) |<--+ | | (10M HALF AN_OFF) | | |<--------------------+ | | | v v v To avoid aboved situation, this patch introduced req_speed, req_duplex, req_autoneg to store user's configuration and it only be used after hardware reset and to recover user's configuration Fixes: f5f2b3e ("net: hns3: add support for imp-controlled PHYs") Signed-off-by: Peiyang Wang <[email protected]> Signed-off-by: Jijie Shao <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 2ddc0dd commit 05eb60e

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,6 +1537,9 @@ static int hclge_configure(struct hclge_dev *hdev)
15371537
cfg.default_speed, ret);
15381538
return ret;
15391539
}
1540+
hdev->hw.mac.req_speed = hdev->hw.mac.speed;
1541+
hdev->hw.mac.req_autoneg = AUTONEG_ENABLE;
1542+
hdev->hw.mac.req_duplex = DUPLEX_FULL;
15401543

15411544
hclge_parse_link_mode(hdev, cfg.speed_ability);
15421545

@@ -3342,9 +3345,9 @@ hclge_set_phy_link_ksettings(struct hnae3_handle *handle,
33423345
return ret;
33433346
}
33443347

3345-
hdev->hw.mac.autoneg = cmd->base.autoneg;
3346-
hdev->hw.mac.speed = cmd->base.speed;
3347-
hdev->hw.mac.duplex = cmd->base.duplex;
3348+
hdev->hw.mac.req_autoneg = cmd->base.autoneg;
3349+
hdev->hw.mac.req_speed = cmd->base.speed;
3350+
hdev->hw.mac.req_duplex = cmd->base.duplex;
33483351
linkmode_copy(hdev->hw.mac.advertising, cmd->link_modes.advertising);
33493352

33503353
return 0;
@@ -3377,9 +3380,9 @@ static int hclge_tp_port_init(struct hclge_dev *hdev)
33773380
if (!hnae3_dev_phy_imp_supported(hdev))
33783381
return 0;
33793382

3380-
cmd.base.autoneg = hdev->hw.mac.autoneg;
3381-
cmd.base.speed = hdev->hw.mac.speed;
3382-
cmd.base.duplex = hdev->hw.mac.duplex;
3383+
cmd.base.autoneg = hdev->hw.mac.req_autoneg;
3384+
cmd.base.speed = hdev->hw.mac.req_speed;
3385+
cmd.base.duplex = hdev->hw.mac.req_duplex;
33833386
linkmode_copy(cmd.link_modes.advertising, hdev->hw.mac.advertising);
33843387

33853388
return hclge_set_phy_link_ksettings(&hdev->vport->nic, &cmd);

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,14 @@ struct hclge_mac {
279279
u8 media_type; /* port media type, e.g. fibre/copper/backplane */
280280
u8 mac_addr[ETH_ALEN];
281281
u8 autoneg;
282+
u8 req_autoneg;
282283
u8 duplex;
284+
u8 req_duplex;
283285
u8 support_autoneg;
284286
u8 speed_type; /* 0: sfp speed, 1: active speed */
285287
u8 lane_num;
286288
u32 speed;
289+
u32 req_speed;
287290
u32 max_speed;
288291
u32 speed_ability; /* speed ability supported by current media */
289292
u32 module_type; /* sub media type, e.g. kr/cr/sr/lr */

0 commit comments

Comments
 (0)