aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/benet/be_cmds.c37
-rw-r--r--drivers/net/benet/be_cmds.h45
-rw-r--r--drivers/net/benet/be_ethtool.c36
-rw-r--r--drivers/net/benet/be_main.c5
4 files changed, 117 insertions, 6 deletions
diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c
index 827d86b5e70b..cc75dd0df0d8 100644
--- a/drivers/net/benet/be_cmds.c
+++ b/drivers/net/benet/be_cmds.c
@@ -834,7 +834,7 @@ int be_cmd_get_stats(struct be_adapter *adapter, struct be_dma_mem *nonemb_cmd)
834 834
835/* Uses synchronous mcc */ 835/* Uses synchronous mcc */
836int be_cmd_link_status_query(struct be_adapter *adapter, 836int be_cmd_link_status_query(struct be_adapter *adapter,
837 bool *link_up) 837 bool *link_up, u8 *mac_speed, u16 *link_speed)
838{ 838{
839 struct be_mcc_wrb *wrb; 839 struct be_mcc_wrb *wrb;
840 struct be_cmd_req_link_status *req; 840 struct be_cmd_req_link_status *req;
@@ -855,8 +855,11 @@ int be_cmd_link_status_query(struct be_adapter *adapter,
855 status = be_mcc_notify_wait(adapter); 855 status = be_mcc_notify_wait(adapter);
856 if (!status) { 856 if (!status) {
857 struct be_cmd_resp_link_status *resp = embedded_payload(wrb); 857 struct be_cmd_resp_link_status *resp = embedded_payload(wrb);
858 if (resp->mac_speed != PHY_LINK_SPEED_ZERO) 858 if (resp->mac_speed != PHY_LINK_SPEED_ZERO) {
859 *link_up = true; 859 *link_up = true;
860 *link_speed = le16_to_cpu(resp->link_speed);
861 *mac_speed = resp->mac_speed;
862 }
860 } 863 }
861 864
862 spin_unlock_bh(&adapter->mcc_lock); 865 spin_unlock_bh(&adapter->mcc_lock);
@@ -1188,6 +1191,36 @@ int be_cmd_get_beacon_state(struct be_adapter *adapter, u8 port_num, u32 *state)
1188 return status; 1191 return status;
1189} 1192}
1190 1193
1194/* Uses sync mcc */
1195int be_cmd_read_port_type(struct be_adapter *adapter, u32 port,
1196 u8 *connector)
1197{
1198 struct be_mcc_wrb *wrb;
1199 struct be_cmd_req_port_type *req;
1200 int status;
1201
1202 spin_lock_bh(&adapter->mcc_lock);
1203
1204 wrb = wrb_from_mccq(adapter);
1205 req = embedded_payload(wrb);
1206
1207 be_wrb_hdr_prepare(wrb, sizeof(struct be_cmd_resp_port_type), true, 0);
1208
1209 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
1210 OPCODE_COMMON_READ_TRANSRECV_DATA, sizeof(*req));
1211
1212 req->port = cpu_to_le32(port);
1213 req->page_num = cpu_to_le32(TR_PAGE_A0);
1214 status = be_mcc_notify_wait(adapter);
1215 if (!status) {
1216 struct be_cmd_resp_port_type *resp = embedded_payload(wrb);
1217 *connector = resp->data.connector;
1218 }
1219
1220 spin_unlock_bh(&adapter->mcc_lock);
1221 return status;
1222}
1223
1191int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd, 1224int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd,
1192 u32 flash_type, u32 flash_opcode, u32 buf_size) 1225 u32 flash_type, u32 flash_opcode, u32 buf_size)
1193{ 1226{
diff --git a/drivers/net/benet/be_cmds.h b/drivers/net/benet/be_cmds.h
index fe9f535eff12..76410c1d5669 100644
--- a/drivers/net/benet/be_cmds.h
+++ b/drivers/net/benet/be_cmds.h
@@ -140,6 +140,7 @@ struct be_mcc_mailbox {
140#define OPCODE_COMMON_FUNCTION_RESET 61 140#define OPCODE_COMMON_FUNCTION_RESET 61
141#define OPCODE_COMMON_ENABLE_DISABLE_BEACON 69 141#define OPCODE_COMMON_ENABLE_DISABLE_BEACON 69
142#define OPCODE_COMMON_GET_BEACON_STATE 70 142#define OPCODE_COMMON_GET_BEACON_STATE 70
143#define OPCODE_COMMON_READ_TRANSRECV_DATA 73
143 144
144#define OPCODE_ETH_ACPI_CONFIG 2 145#define OPCODE_ETH_ACPI_CONFIG 2
145#define OPCODE_ETH_PROMISCUOUS 3 146#define OPCODE_ETH_PROMISCUOUS 3
@@ -635,9 +636,47 @@ struct be_cmd_resp_link_status {
635 u8 mac_fault; 636 u8 mac_fault;
636 u8 mgmt_mac_duplex; 637 u8 mgmt_mac_duplex;
637 u8 mgmt_mac_speed; 638 u8 mgmt_mac_speed;
638 u16 rsvd0; 639 u16 link_speed;
640 u32 rsvd0;
639} __packed; 641} __packed;
640 642
643/******************** Port Identification ***************************/
644/* Identifies the type of port attached to NIC */
645struct be_cmd_req_port_type {
646 struct be_cmd_req_hdr hdr;
647 u32 page_num;
648 u32 port;
649};
650
651enum {
652 TR_PAGE_A0 = 0xa0,
653 TR_PAGE_A2 = 0xa2
654};
655
656struct be_cmd_resp_port_type {
657 struct be_cmd_resp_hdr hdr;
658 u32 page_num;
659 u32 port;
660 struct data {
661 u8 identifier;
662 u8 identifier_ext;
663 u8 connector;
664 u8 transceiver[8];
665 u8 rsvd0[3];
666 u8 length_km;
667 u8 length_hm;
668 u8 length_om1;
669 u8 length_om2;
670 u8 length_cu;
671 u8 length_cu_m;
672 u8 vendor_name[16];
673 u8 rsvd;
674 u8 vendor_oui[3];
675 u8 vendor_pn[16];
676 u8 vendor_rev[4];
677 } data;
678};
679
641/******************** Get FW Version *******************/ 680/******************** Get FW Version *******************/
642struct be_cmd_req_get_fw_version { 681struct be_cmd_req_get_fw_version {
643 struct be_cmd_req_hdr hdr; 682 struct be_cmd_req_hdr hdr;
@@ -776,7 +815,7 @@ extern int be_cmd_rxq_create(struct be_adapter *adapter,
776extern int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q, 815extern int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q,
777 int type); 816 int type);
778extern int be_cmd_link_status_query(struct be_adapter *adapter, 817extern int be_cmd_link_status_query(struct be_adapter *adapter,
779 bool *link_up); 818 bool *link_up, u8 *mac_speed, u16 *link_speed);
780extern int be_cmd_reset(struct be_adapter *adapter); 819extern int be_cmd_reset(struct be_adapter *adapter);
781extern int be_cmd_get_stats(struct be_adapter *adapter, 820extern int be_cmd_get_stats(struct be_adapter *adapter,
782 struct be_dma_mem *nonemb_cmd); 821 struct be_dma_mem *nonemb_cmd);
@@ -802,6 +841,8 @@ extern int be_cmd_set_beacon_state(struct be_adapter *adapter,
802 u8 port_num, u8 beacon, u8 status, u8 state); 841 u8 port_num, u8 beacon, u8 status, u8 state);
803extern int be_cmd_get_beacon_state(struct be_adapter *adapter, 842extern int be_cmd_get_beacon_state(struct be_adapter *adapter,
804 u8 port_num, u32 *state); 843 u8 port_num, u32 *state);
844extern int be_cmd_read_port_type(struct be_adapter *adapter, u32 port,
845 u8 *connector);
805extern int be_cmd_write_flashrom(struct be_adapter *adapter, 846extern int be_cmd_write_flashrom(struct be_adapter *adapter,
806 struct be_dma_mem *cmd, u32 flash_oper, 847 struct be_dma_mem *cmd, u32 flash_oper,
807 u32 flash_opcode, u32 buf_size); 848 u32 flash_opcode, u32 buf_size);
diff --git a/drivers/net/benet/be_ethtool.c b/drivers/net/benet/be_ethtool.c
index 280471e18695..edebce994906 100644
--- a/drivers/net/benet/be_ethtool.c
+++ b/drivers/net/benet/be_ethtool.c
@@ -293,9 +293,43 @@ static int be_get_sset_count(struct net_device *netdev, int stringset)
293 293
294static int be_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) 294static int be_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
295{ 295{
296 ecmd->speed = SPEED_10000; 296 struct be_adapter *adapter = netdev_priv(netdev);
297 u8 mac_speed = 0, connector = 0;
298 u16 link_speed = 0;
299 bool link_up = false;
300
301 be_cmd_link_status_query(adapter, &link_up, &mac_speed, &link_speed);
302
303 /* link_speed is in units of 10 Mbps */
304 if (link_speed) {
305 ecmd->speed = link_speed*10;
306 } else {
307 switch (mac_speed) {
308 case PHY_LINK_SPEED_1GBPS:
309 ecmd->speed = SPEED_1000;
310 break;
311 case PHY_LINK_SPEED_10GBPS:
312 ecmd->speed = SPEED_10000;
313 break;
314 }
315 }
297 ecmd->duplex = DUPLEX_FULL; 316 ecmd->duplex = DUPLEX_FULL;
298 ecmd->autoneg = AUTONEG_DISABLE; 317 ecmd->autoneg = AUTONEG_DISABLE;
318 ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_TP);
319
320 be_cmd_read_port_type(adapter, adapter->port_num, &connector);
321 switch (connector) {
322 case 7:
323 ecmd->port = PORT_FIBRE;
324 break;
325 default:
326 ecmd->port = PORT_TP;
327 break;
328 }
329
330 ecmd->phy_address = adapter->port_num;
331 ecmd->transceiver = XCVR_INTERNAL;
332
299 return 0; 333 return 0;
300} 334}
301 335
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c
index 21b0657de9e8..4520db716b43 100644
--- a/drivers/net/benet/be_main.c
+++ b/drivers/net/benet/be_main.c
@@ -1586,6 +1586,8 @@ static int be_open(struct net_device *netdev)
1586 struct be_eq_obj *tx_eq = &adapter->tx_eq; 1586 struct be_eq_obj *tx_eq = &adapter->tx_eq;
1587 bool link_up; 1587 bool link_up;
1588 int status; 1588 int status;
1589 u8 mac_speed;
1590 u16 link_speed;
1589 1591
1590 /* First time posting */ 1592 /* First time posting */
1591 be_post_rx_frags(adapter); 1593 be_post_rx_frags(adapter);
@@ -1604,7 +1606,8 @@ static int be_open(struct net_device *netdev)
1604 /* Rx compl queue may be in unarmed state; rearm it */ 1606 /* Rx compl queue may be in unarmed state; rearm it */
1605 be_cq_notify(adapter, adapter->rx_obj.cq.id, true, 0); 1607 be_cq_notify(adapter, adapter->rx_obj.cq.id, true, 0);
1606 1608
1607 status = be_cmd_link_status_query(adapter, &link_up); 1609 status = be_cmd_link_status_query(adapter, &link_up, &mac_speed,
1610 &link_speed);
1608 if (status) 1611 if (status)
1609 return status; 1612 return status;
1610 be_link_status_update(adapter, link_up); 1613 be_link_status_update(adapter, link_up);