Commit 323ff71e authored by Sathya Perla's avatar Sathya Perla Committed by David S. Miller

be2net: cleanup code related to be_link_status_query()

1) link_status_query() is always called to query the link-speed (speed
after applying qos). When there is no qos setting, link-speed is derived from
port-speed. Do all this inside this routine and hide this from the callers.

2) adpater->phy.forced_port_speed is not being set anywhere after being
initialized. Get rid of this variable.

3) Ignore async link_speed notifications till the initial value has been
fetched from FW.
Signed-off-by: default avatarSathya Perla <sathya.perla@emulex.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 55f5c3c5
...@@ -337,7 +337,6 @@ struct phy_info { ...@@ -337,7 +337,6 @@ struct phy_info {
u16 auto_speeds_supported; u16 auto_speeds_supported;
u16 fixed_speeds_supported; u16 fixed_speeds_supported;
int link_speed; int link_speed;
int forced_port_speed;
u32 dac_cable_len; u32 dac_cable_len;
u32 advertising; u32 advertising;
u32 supported; u32 supported;
......
...@@ -165,14 +165,13 @@ static void be_async_grp5_cos_priority_process(struct be_adapter *adapter, ...@@ -165,14 +165,13 @@ static void be_async_grp5_cos_priority_process(struct be_adapter *adapter,
} }
} }
/* Grp5 QOS Speed evt */ /* Grp5 QOS Speed evt: qos_link_speed is in units of 10 Mbps */
static void be_async_grp5_qos_speed_process(struct be_adapter *adapter, static void be_async_grp5_qos_speed_process(struct be_adapter *adapter,
struct be_async_event_grp5_qos_link_speed *evt) struct be_async_event_grp5_qos_link_speed *evt)
{ {
if (evt->physical_port == adapter->port_num) { if (adapter->phy.link_speed >= 0 &&
/* qos_link_speed is in units of 10 Mbps */ evt->physical_port == adapter->port_num)
adapter->phy.link_speed = evt->qos_link_speed * 10; adapter->phy.link_speed = le16_to_cpu(evt->qos_link_speed) * 10;
}
} }
/*Grp5 PVID evt*/ /*Grp5 PVID evt*/
...@@ -1326,9 +1325,28 @@ int lancer_cmd_get_pport_stats(struct be_adapter *adapter, ...@@ -1326,9 +1325,28 @@ int lancer_cmd_get_pport_stats(struct be_adapter *adapter,
return status; return status;
} }
/* Uses synchronous mcc */ static int be_mac_to_link_speed(int mac_speed)
int be_cmd_link_status_query(struct be_adapter *adapter, u8 *mac_speed, {
u16 *link_speed, u8 *link_status, u32 dom) switch (mac_speed) {
case PHY_LINK_SPEED_ZERO:
return 0;
case PHY_LINK_SPEED_10MBPS:
return 10;
case PHY_LINK_SPEED_100MBPS:
return 100;
case PHY_LINK_SPEED_1GBPS:
return 1000;
case PHY_LINK_SPEED_10GBPS:
return 10000;
}
return 0;
}
/* Uses synchronous mcc
* Returns link_speed in Mbps
*/
int be_cmd_link_status_query(struct be_adapter *adapter, u16 *link_speed,
u8 *link_status, u32 dom)
{ {
struct be_mcc_wrb *wrb; struct be_mcc_wrb *wrb;
struct be_cmd_req_link_status *req; struct be_cmd_req_link_status *req;
...@@ -1357,11 +1375,13 @@ int be_cmd_link_status_query(struct be_adapter *adapter, u8 *mac_speed, ...@@ -1357,11 +1375,13 @@ int be_cmd_link_status_query(struct be_adapter *adapter, u8 *mac_speed,
status = be_mcc_notify_wait(adapter); status = be_mcc_notify_wait(adapter);
if (!status) { if (!status) {
struct be_cmd_resp_link_status *resp = embedded_payload(wrb); struct be_cmd_resp_link_status *resp = embedded_payload(wrb);
if (resp->mac_speed != PHY_LINK_SPEED_ZERO) { if (link_speed) {
if (link_speed) *link_speed = resp->link_speed ?
*link_speed = le16_to_cpu(resp->link_speed); le16_to_cpu(resp->link_speed) * 10 :
if (mac_speed) be_mac_to_link_speed(resp->mac_speed);
*mac_speed = resp->mac_speed;
if (!resp->logical_link_status)
*link_speed = 0;
} }
if (link_status) if (link_status)
*link_status = resp->logical_link_status; *link_status = resp->logical_link_status;
......
...@@ -1714,8 +1714,8 @@ extern int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q, ...@@ -1714,8 +1714,8 @@ extern int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q,
int type); int type);
extern int be_cmd_rxq_destroy(struct be_adapter *adapter, extern int be_cmd_rxq_destroy(struct be_adapter *adapter,
struct be_queue_info *q); struct be_queue_info *q);
extern int be_cmd_link_status_query(struct be_adapter *adapter, u8 *mac_speed, extern int be_cmd_link_status_query(struct be_adapter *adapter, u16 *link_speed,
u16 *link_speed, u8 *link_status, u32 dom); u8 *link_status, u32 dom);
extern int be_cmd_reset(struct be_adapter *adapter); extern int be_cmd_reset(struct be_adapter *adapter);
extern int be_cmd_get_stats(struct be_adapter *adapter, extern int be_cmd_get_stats(struct be_adapter *adapter,
struct be_dma_mem *nonemb_cmd); struct be_dma_mem *nonemb_cmd);
......
...@@ -512,28 +512,6 @@ static u32 convert_to_et_setting(u32 if_type, u32 if_speeds) ...@@ -512,28 +512,6 @@ static u32 convert_to_et_setting(u32 if_type, u32 if_speeds)
return val; return val;
} }
static int convert_to_et_speed(u32 be_speed)
{
int et_speed = SPEED_10000;
switch (be_speed) {
case PHY_LINK_SPEED_10MBPS:
et_speed = SPEED_10;
break;
case PHY_LINK_SPEED_100MBPS:
et_speed = SPEED_100;
break;
case PHY_LINK_SPEED_1GBPS:
et_speed = SPEED_1000;
break;
case PHY_LINK_SPEED_10GBPS:
et_speed = SPEED_10000;
break;
}
return et_speed;
}
bool be_pause_supported(struct be_adapter *adapter) bool be_pause_supported(struct be_adapter *adapter)
{ {
return (adapter->phy.interface_type == PHY_TYPE_SFP_PLUS_10GB || return (adapter->phy.interface_type == PHY_TYPE_SFP_PLUS_10GB ||
...@@ -544,27 +522,16 @@ bool be_pause_supported(struct be_adapter *adapter) ...@@ -544,27 +522,16 @@ bool be_pause_supported(struct be_adapter *adapter)
static int be_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) static int be_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
{ {
struct be_adapter *adapter = netdev_priv(netdev); struct be_adapter *adapter = netdev_priv(netdev);
u8 port_speed = 0;
u16 link_speed = 0;
u8 link_status; u8 link_status;
u32 et_speed = 0; u16 link_speed = 0;
int status; int status;
if (adapter->phy.link_speed < 0 || !(netdev->flags & IFF_UP)) { if (adapter->phy.link_speed < 0) {
if (adapter->phy.forced_port_speed < 0) { status = be_cmd_link_status_query(adapter, &link_speed,
status = be_cmd_link_status_query(adapter, &port_speed, &link_status, 0);
&link_speed, &link_status, 0); if (!status)
if (!status) be_link_status_update(adapter, link_status);
be_link_status_update(adapter, link_status); ethtool_cmd_speed_set(ecmd, link_speed);
if (link_speed)
et_speed = link_speed * 10;
else if (link_status)
et_speed = convert_to_et_speed(port_speed);
} else {
et_speed = adapter->phy.forced_port_speed;
}
ethtool_cmd_speed_set(ecmd, et_speed);
status = be_cmd_get_phy_info(adapter); status = be_cmd_get_phy_info(adapter);
if (status) if (status)
...@@ -773,8 +740,8 @@ static void ...@@ -773,8 +740,8 @@ static void
be_self_test(struct net_device *netdev, struct ethtool_test *test, u64 *data) be_self_test(struct net_device *netdev, struct ethtool_test *test, u64 *data)
{ {
struct be_adapter *adapter = netdev_priv(netdev); struct be_adapter *adapter = netdev_priv(netdev);
u8 mac_speed = 0; int status;
u16 qos_link_speed = 0; u8 link_status = 0;
memset(data, 0, sizeof(u64) * ETHTOOL_TESTS_NUM); memset(data, 0, sizeof(u64) * ETHTOOL_TESTS_NUM);
...@@ -798,11 +765,11 @@ be_self_test(struct net_device *netdev, struct ethtool_test *test, u64 *data) ...@@ -798,11 +765,11 @@ be_self_test(struct net_device *netdev, struct ethtool_test *test, u64 *data)
test->flags |= ETH_TEST_FL_FAILED; test->flags |= ETH_TEST_FL_FAILED;
} }
if (be_cmd_link_status_query(adapter, &mac_speed, status = be_cmd_link_status_query(adapter, NULL, &link_status, 0);
&qos_link_speed, NULL, 0) != 0) { if (status) {
test->flags |= ETH_TEST_FL_FAILED; test->flags |= ETH_TEST_FL_FAILED;
data[4] = -1; data[4] = -1;
} else if (!mac_speed) { } else if (!link_status) {
test->flags |= ETH_TEST_FL_FAILED; test->flags |= ETH_TEST_FL_FAILED;
data[4] = 1; data[4] = 1;
} }
......
...@@ -2440,8 +2440,7 @@ static int be_open(struct net_device *netdev) ...@@ -2440,8 +2440,7 @@ static int be_open(struct net_device *netdev)
be_eq_notify(adapter, eqo->q.id, true, false, 0); be_eq_notify(adapter, eqo->q.id, true, false, 0);
} }
status = be_cmd_link_status_query(adapter, NULL, NULL, status = be_cmd_link_status_query(adapter, NULL, &link_status, 0);
&link_status, 0);
if (!status) if (!status)
be_link_status_update(adapter, link_status); be_link_status_update(adapter, link_status);
...@@ -2670,7 +2669,6 @@ static void be_setup_init(struct be_adapter *adapter) ...@@ -2670,7 +2669,6 @@ static void be_setup_init(struct be_adapter *adapter)
adapter->be3_native = false; adapter->be3_native = false;
adapter->promiscuous = false; adapter->promiscuous = false;
adapter->eq_next_idx = 0; adapter->eq_next_idx = 0;
adapter->phy.forced_port_speed = -1;
} }
static int be_get_mac_addr(struct be_adapter *adapter, u8 *mac, u32 if_handle, static int be_get_mac_addr(struct be_adapter *adapter, u8 *mac, u32 if_handle,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment