aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/emulex/benet
diff options
context:
space:
mode:
authorSathya Perla <sathya.perla@emulex.com>2012-09-28 00:39:43 -0400
committerDavid S. Miller <davem@davemloft.net>2012-09-30 02:15:34 -0400
commit323ff71e566994f77761e221361de5b4a52a612f (patch)
tree13e683ac12e63991b1166e0206381276b8c45276 /drivers/net/ethernet/emulex/benet
parent55f5c3c55b5a682c4bb37628979c5909f9de7b30 (diff)
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: Sathya Perla <sathya.perla@emulex.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/emulex/benet')
-rw-r--r--drivers/net/ethernet/emulex/benet/be.h1
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.c46
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.h4
-rw-r--r--drivers/net/ethernet/emulex/benet/be_ethtool.c57
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c4
5 files changed, 48 insertions, 64 deletions
diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h
index 5b622993ff17..cf4c05bdf5fe 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -337,7 +337,6 @@ struct phy_info {
337 u16 auto_speeds_supported; 337 u16 auto_speeds_supported;
338 u16 fixed_speeds_supported; 338 u16 fixed_speeds_supported;
339 int link_speed; 339 int link_speed;
340 int forced_port_speed;
341 u32 dac_cable_len; 340 u32 dac_cable_len;
342 u32 advertising; 341 u32 advertising;
343 u32 supported; 342 u32 supported;
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 6fbfb207fa5a..46a19affbc21 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -165,14 +165,13 @@ static void be_async_grp5_cos_priority_process(struct be_adapter *adapter,
165 } 165 }
166} 166}
167 167
168/* Grp5 QOS Speed evt */ 168/* Grp5 QOS Speed evt: qos_link_speed is in units of 10 Mbps */
169static void be_async_grp5_qos_speed_process(struct be_adapter *adapter, 169static void be_async_grp5_qos_speed_process(struct be_adapter *adapter,
170 struct be_async_event_grp5_qos_link_speed *evt) 170 struct be_async_event_grp5_qos_link_speed *evt)
171{ 171{
172 if (evt->physical_port == adapter->port_num) { 172 if (adapter->phy.link_speed >= 0 &&
173 /* qos_link_speed is in units of 10 Mbps */ 173 evt->physical_port == adapter->port_num)
174 adapter->phy.link_speed = evt->qos_link_speed * 10; 174 adapter->phy.link_speed = le16_to_cpu(evt->qos_link_speed) * 10;
175 }
176} 175}
177 176
178/*Grp5 PVID evt*/ 177/*Grp5 PVID evt*/
@@ -1326,9 +1325,28 @@ err:
1326 return status; 1325 return status;
1327} 1326}
1328 1327
1329/* Uses synchronous mcc */ 1328static int be_mac_to_link_speed(int mac_speed)
1330int be_cmd_link_status_query(struct be_adapter *adapter, u8 *mac_speed, 1329{
1331 u16 *link_speed, u8 *link_status, u32 dom) 1330 switch (mac_speed) {
1331 case PHY_LINK_SPEED_ZERO:
1332 return 0;
1333 case PHY_LINK_SPEED_10MBPS:
1334 return 10;
1335 case PHY_LINK_SPEED_100MBPS:
1336 return 100;
1337 case PHY_LINK_SPEED_1GBPS:
1338 return 1000;
1339 case PHY_LINK_SPEED_10GBPS:
1340 return 10000;
1341 }
1342 return 0;
1343}
1344
1345/* Uses synchronous mcc
1346 * Returns link_speed in Mbps
1347 */
1348int be_cmd_link_status_query(struct be_adapter *adapter, u16 *link_speed,
1349 u8 *link_status, u32 dom)
1332{ 1350{
1333 struct be_mcc_wrb *wrb; 1351 struct be_mcc_wrb *wrb;
1334 struct be_cmd_req_link_status *req; 1352 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 status = be_mcc_notify_wait(adapter); 1375 status = be_mcc_notify_wait(adapter);
1358 if (!status) { 1376 if (!status) {
1359 struct be_cmd_resp_link_status *resp = embedded_payload(wrb); 1377 struct be_cmd_resp_link_status *resp = embedded_payload(wrb);
1360 if (resp->mac_speed != PHY_LINK_SPEED_ZERO) { 1378 if (link_speed) {
1361 if (link_speed) 1379 *link_speed = resp->link_speed ?
1362 *link_speed = le16_to_cpu(resp->link_speed); 1380 le16_to_cpu(resp->link_speed) * 10 :
1363 if (mac_speed) 1381 be_mac_to_link_speed(resp->mac_speed);
1364 *mac_speed = resp->mac_speed; 1382
1383 if (!resp->logical_link_status)
1384 *link_speed = 0;
1365 } 1385 }
1366 if (link_status) 1386 if (link_status)
1367 *link_status = resp->logical_link_status; 1387 *link_status = resp->logical_link_status;
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 1f5b83975f21..0936e21e3cff 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -1714,8 +1714,8 @@ extern int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q,
1714 int type); 1714 int type);
1715extern int be_cmd_rxq_destroy(struct be_adapter *adapter, 1715extern int be_cmd_rxq_destroy(struct be_adapter *adapter,
1716 struct be_queue_info *q); 1716 struct be_queue_info *q);
1717extern int be_cmd_link_status_query(struct be_adapter *adapter, u8 *mac_speed, 1717extern int be_cmd_link_status_query(struct be_adapter *adapter, u16 *link_speed,
1718 u16 *link_speed, u8 *link_status, u32 dom); 1718 u8 *link_status, u32 dom);
1719extern int be_cmd_reset(struct be_adapter *adapter); 1719extern int be_cmd_reset(struct be_adapter *adapter);
1720extern int be_cmd_get_stats(struct be_adapter *adapter, 1720extern int be_cmd_get_stats(struct be_adapter *adapter,
1721 struct be_dma_mem *nonemb_cmd); 1721 struct be_dma_mem *nonemb_cmd);
diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c b/drivers/net/ethernet/emulex/benet/be_ethtool.c
index c0e700653f96..8e6fb0ba6aa9 100644
--- a/drivers/net/ethernet/emulex/benet/be_ethtool.c
+++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c
@@ -512,28 +512,6 @@ static u32 convert_to_et_setting(u32 if_type, u32 if_speeds)
512 return val; 512 return val;
513} 513}
514 514
515static int convert_to_et_speed(u32 be_speed)
516{
517 int et_speed = SPEED_10000;
518
519 switch (be_speed) {
520 case PHY_LINK_SPEED_10MBPS:
521 et_speed = SPEED_10;
522 break;
523 case PHY_LINK_SPEED_100MBPS:
524 et_speed = SPEED_100;
525 break;
526 case PHY_LINK_SPEED_1GBPS:
527 et_speed = SPEED_1000;
528 break;
529 case PHY_LINK_SPEED_10GBPS:
530 et_speed = SPEED_10000;
531 break;
532 }
533
534 return et_speed;
535}
536
537bool be_pause_supported(struct be_adapter *adapter) 515bool be_pause_supported(struct be_adapter *adapter)
538{ 516{
539 return (adapter->phy.interface_type == PHY_TYPE_SFP_PLUS_10GB || 517 return (adapter->phy.interface_type == PHY_TYPE_SFP_PLUS_10GB ||
@@ -544,27 +522,16 @@ bool be_pause_supported(struct be_adapter *adapter)
544static int be_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) 522static int be_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
545{ 523{
546 struct be_adapter *adapter = netdev_priv(netdev); 524 struct be_adapter *adapter = netdev_priv(netdev);
547 u8 port_speed = 0;
548 u16 link_speed = 0;
549 u8 link_status; 525 u8 link_status;
550 u32 et_speed = 0; 526 u16 link_speed = 0;
551 int status; 527 int status;
552 528
553 if (adapter->phy.link_speed < 0 || !(netdev->flags & IFF_UP)) { 529 if (adapter->phy.link_speed < 0) {
554 if (adapter->phy.forced_port_speed < 0) { 530 status = be_cmd_link_status_query(adapter, &link_speed,
555 status = be_cmd_link_status_query(adapter, &port_speed, 531 &link_status, 0);
556 &link_speed, &link_status, 0); 532 if (!status)
557 if (!status) 533 be_link_status_update(adapter, link_status);
558 be_link_status_update(adapter, link_status); 534 ethtool_cmd_speed_set(ecmd, link_speed);
559 if (link_speed)
560 et_speed = link_speed * 10;
561 else if (link_status)
562 et_speed = convert_to_et_speed(port_speed);
563 } else {
564 et_speed = adapter->phy.forced_port_speed;
565 }
566
567 ethtool_cmd_speed_set(ecmd, et_speed);
568 535
569 status = be_cmd_get_phy_info(adapter); 536 status = be_cmd_get_phy_info(adapter);
570 if (status) 537 if (status)
@@ -773,8 +740,8 @@ static void
773be_self_test(struct net_device *netdev, struct ethtool_test *test, u64 *data) 740be_self_test(struct net_device *netdev, struct ethtool_test *test, u64 *data)
774{ 741{
775 struct be_adapter *adapter = netdev_priv(netdev); 742 struct be_adapter *adapter = netdev_priv(netdev);
776 u8 mac_speed = 0; 743 int status;
777 u16 qos_link_speed = 0; 744 u8 link_status = 0;
778 745
779 memset(data, 0, sizeof(u64) * ETHTOOL_TESTS_NUM); 746 memset(data, 0, sizeof(u64) * ETHTOOL_TESTS_NUM);
780 747
@@ -798,11 +765,11 @@ be_self_test(struct net_device *netdev, struct ethtool_test *test, u64 *data)
798 test->flags |= ETH_TEST_FL_FAILED; 765 test->flags |= ETH_TEST_FL_FAILED;
799 } 766 }
800 767
801 if (be_cmd_link_status_query(adapter, &mac_speed, 768 status = be_cmd_link_status_query(adapter, NULL, &link_status, 0);
802 &qos_link_speed, NULL, 0) != 0) { 769 if (status) {
803 test->flags |= ETH_TEST_FL_FAILED; 770 test->flags |= ETH_TEST_FL_FAILED;
804 data[4] = -1; 771 data[4] = -1;
805 } else if (!mac_speed) { 772 } else if (!link_status) {
806 test->flags |= ETH_TEST_FL_FAILED; 773 test->flags |= ETH_TEST_FL_FAILED;
807 data[4] = 1; 774 data[4] = 1;
808 } 775 }
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index b712091bc218..4855dd627c7f 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -2440,8 +2440,7 @@ static int be_open(struct net_device *netdev)
2440 be_eq_notify(adapter, eqo->q.id, true, false, 0); 2440 be_eq_notify(adapter, eqo->q.id, true, false, 0);
2441 } 2441 }
2442 2442
2443 status = be_cmd_link_status_query(adapter, NULL, NULL, 2443 status = be_cmd_link_status_query(adapter, NULL, &link_status, 0);
2444 &link_status, 0);
2445 if (!status) 2444 if (!status)
2446 be_link_status_update(adapter, link_status); 2445 be_link_status_update(adapter, link_status);
2447 2446
@@ -2670,7 +2669,6 @@ static void be_setup_init(struct be_adapter *adapter)
2670 adapter->be3_native = false; 2669 adapter->be3_native = false;
2671 adapter->promiscuous = false; 2670 adapter->promiscuous = false;
2672 adapter->eq_next_idx = 0; 2671 adapter->eq_next_idx = 0;
2673 adapter->phy.forced_port_speed = -1;
2674} 2672}
2675 2673
2676static int be_get_mac_addr(struct be_adapter *adapter, u8 *mac, u32 if_handle, 2674static int be_get_mac_addr(struct be_adapter *adapter, u8 *mac, u32 if_handle,