diff options
author | Ajit Khaparde <ajit.khaparde@emulex.com> | 2011-02-20 06:42:07 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-02-22 13:26:46 -0500 |
commit | 609ff3bb8f6cd38c68c719bbc3c31d6b0b9ce894 (patch) | |
tree | d0b1c965750782ad9daa44099cfd296caef5d0f7 | |
parent | 3968fa1e58896187ee5629db0720d93b9313ad9f (diff) |
be2net: add code to display temperature of ASIC
Add support to display temperature of ASIC via ethtool -S
From: Somnath K <somnath.kotur@emulex.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@emulex.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/benet/be.h | 7 | ||||
-rw-r--r-- | drivers/net/benet/be_cmds.c | 44 | ||||
-rw-r--r-- | drivers/net/benet/be_cmds.h | 16 | ||||
-rw-r--r-- | drivers/net/benet/be_ethtool.c | 11 |
4 files changed, 76 insertions, 2 deletions
diff --git a/drivers/net/benet/be.h b/drivers/net/benet/be.h index 7bf8dd4edeb4..46b951f2b045 100644 --- a/drivers/net/benet/be.h +++ b/drivers/net/benet/be.h | |||
@@ -225,6 +225,10 @@ struct be_rx_obj { | |||
225 | u32 cache_line_barrier[15]; | 225 | u32 cache_line_barrier[15]; |
226 | }; | 226 | }; |
227 | 227 | ||
228 | struct be_drv_stats { | ||
229 | u8 be_on_die_temperature; | ||
230 | }; | ||
231 | |||
228 | struct be_vf_cfg { | 232 | struct be_vf_cfg { |
229 | unsigned char vf_mac_addr[ETH_ALEN]; | 233 | unsigned char vf_mac_addr[ETH_ALEN]; |
230 | u32 vf_if_handle; | 234 | u32 vf_if_handle; |
@@ -234,6 +238,7 @@ struct be_vf_cfg { | |||
234 | }; | 238 | }; |
235 | 239 | ||
236 | #define BE_INVALID_PMAC_ID 0xffffffff | 240 | #define BE_INVALID_PMAC_ID 0xffffffff |
241 | |||
237 | struct be_adapter { | 242 | struct be_adapter { |
238 | struct pci_dev *pdev; | 243 | struct pci_dev *pdev; |
239 | struct net_device *netdev; | 244 | struct net_device *netdev; |
@@ -269,6 +274,7 @@ struct be_adapter { | |||
269 | u32 big_page_size; /* Compounded page size shared by rx wrbs */ | 274 | u32 big_page_size; /* Compounded page size shared by rx wrbs */ |
270 | 275 | ||
271 | u8 msix_vec_next_idx; | 276 | u8 msix_vec_next_idx; |
277 | struct be_drv_stats drv_stats; | ||
272 | 278 | ||
273 | struct vlan_group *vlan_grp; | 279 | struct vlan_group *vlan_grp; |
274 | u16 vlans_added; | 280 | u16 vlans_added; |
@@ -281,6 +287,7 @@ struct be_adapter { | |||
281 | struct be_dma_mem stats_cmd; | 287 | struct be_dma_mem stats_cmd; |
282 | /* Work queue used to perform periodic tasks like getting statistics */ | 288 | /* Work queue used to perform periodic tasks like getting statistics */ |
283 | struct delayed_work work; | 289 | struct delayed_work work; |
290 | u16 work_counter; | ||
284 | 291 | ||
285 | /* Ethtool knobs and info */ | 292 | /* Ethtool knobs and info */ |
286 | bool rx_csum; /* BE card must perform rx-checksumming */ | 293 | bool rx_csum; /* BE card must perform rx-checksumming */ |
diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c index 59d25acf4374..ff62aaea9a45 100644 --- a/drivers/net/benet/be_cmds.c +++ b/drivers/net/benet/be_cmds.c | |||
@@ -18,6 +18,9 @@ | |||
18 | #include "be.h" | 18 | #include "be.h" |
19 | #include "be_cmds.h" | 19 | #include "be_cmds.h" |
20 | 20 | ||
21 | /* Must be a power of 2 or else MODULO will BUG_ON */ | ||
22 | static int be_get_temp_freq = 32; | ||
23 | |||
21 | static void be_mcc_notify(struct be_adapter *adapter) | 24 | static void be_mcc_notify(struct be_adapter *adapter) |
22 | { | 25 | { |
23 | struct be_queue_info *mccq = &adapter->mcc_obj.q; | 26 | struct be_queue_info *mccq = &adapter->mcc_obj.q; |
@@ -1069,6 +1072,9 @@ int be_cmd_get_stats(struct be_adapter *adapter, struct be_dma_mem *nonemb_cmd) | |||
1069 | struct be_sge *sge; | 1072 | struct be_sge *sge; |
1070 | int status = 0; | 1073 | int status = 0; |
1071 | 1074 | ||
1075 | if (MODULO(adapter->work_counter, be_get_temp_freq) == 0) | ||
1076 | be_cmd_get_die_temperature(adapter); | ||
1077 | |||
1072 | spin_lock_bh(&adapter->mcc_lock); | 1078 | spin_lock_bh(&adapter->mcc_lock); |
1073 | 1079 | ||
1074 | wrb = wrb_from_mccq(adapter); | 1080 | wrb = wrb_from_mccq(adapter); |
@@ -1136,6 +1142,44 @@ err: | |||
1136 | return status; | 1142 | return status; |
1137 | } | 1143 | } |
1138 | 1144 | ||
1145 | /* Uses synchronous mcc */ | ||
1146 | int be_cmd_get_die_temperature(struct be_adapter *adapter) | ||
1147 | { | ||
1148 | struct be_mcc_wrb *wrb; | ||
1149 | struct be_cmd_req_get_cntl_addnl_attribs *req; | ||
1150 | int status; | ||
1151 | |||
1152 | spin_lock_bh(&adapter->mcc_lock); | ||
1153 | |||
1154 | wrb = wrb_from_mccq(adapter); | ||
1155 | if (!wrb) { | ||
1156 | status = -EBUSY; | ||
1157 | goto err; | ||
1158 | } | ||
1159 | req = embedded_payload(wrb); | ||
1160 | |||
1161 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, | ||
1162 | OPCODE_COMMON_GET_CNTL_ADDITIONAL_ATTRIBUTES); | ||
1163 | |||
1164 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, | ||
1165 | OPCODE_COMMON_GET_CNTL_ADDITIONAL_ATTRIBUTES, sizeof(*req)); | ||
1166 | |||
1167 | status = be_mcc_notify_wait(adapter); | ||
1168 | if (!status) { | ||
1169 | struct be_cmd_resp_get_cntl_addnl_attribs *resp = | ||
1170 | embedded_payload(wrb); | ||
1171 | adapter->drv_stats.be_on_die_temperature = | ||
1172 | resp->on_die_temperature; | ||
1173 | } | ||
1174 | /* If IOCTL fails once, do not bother issuing it again */ | ||
1175 | else | ||
1176 | be_get_temp_freq = 0; | ||
1177 | |||
1178 | err: | ||
1179 | spin_unlock_bh(&adapter->mcc_lock); | ||
1180 | return status; | ||
1181 | } | ||
1182 | |||
1139 | /* Uses Mbox */ | 1183 | /* Uses Mbox */ |
1140 | int be_cmd_get_fw_ver(struct be_adapter *adapter, char *fw_ver) | 1184 | int be_cmd_get_fw_ver(struct be_adapter *adapter, char *fw_ver) |
1141 | { | 1185 | { |
diff --git a/drivers/net/benet/be_cmds.h b/drivers/net/benet/be_cmds.h index a5af2963e7ef..6e89de82a5e9 100644 --- a/drivers/net/benet/be_cmds.h +++ b/drivers/net/benet/be_cmds.h | |||
@@ -189,6 +189,7 @@ struct be_mcc_mailbox { | |||
189 | #define OPCODE_COMMON_GET_BEACON_STATE 70 | 189 | #define OPCODE_COMMON_GET_BEACON_STATE 70 |
190 | #define OPCODE_COMMON_READ_TRANSRECV_DATA 73 | 190 | #define OPCODE_COMMON_READ_TRANSRECV_DATA 73 |
191 | #define OPCODE_COMMON_GET_PHY_DETAILS 102 | 191 | #define OPCODE_COMMON_GET_PHY_DETAILS 102 |
192 | #define OPCODE_COMMON_GET_CNTL_ADDITIONAL_ATTRIBUTES 121 | ||
192 | 193 | ||
193 | #define OPCODE_ETH_RSS_CONFIG 1 | 194 | #define OPCODE_ETH_RSS_CONFIG 1 |
194 | #define OPCODE_ETH_ACPI_CONFIG 2 | 195 | #define OPCODE_ETH_ACPI_CONFIG 2 |
@@ -668,6 +669,20 @@ struct be_cmd_resp_get_stats { | |||
668 | struct be_hw_stats hw_stats; | 669 | struct be_hw_stats hw_stats; |
669 | }; | 670 | }; |
670 | 671 | ||
672 | struct be_cmd_req_get_cntl_addnl_attribs { | ||
673 | struct be_cmd_req_hdr hdr; | ||
674 | u8 rsvd[8]; | ||
675 | }; | ||
676 | |||
677 | struct be_cmd_resp_get_cntl_addnl_attribs { | ||
678 | struct be_cmd_resp_hdr hdr; | ||
679 | u16 ipl_file_number; | ||
680 | u8 ipl_file_version; | ||
681 | u8 rsvd0; | ||
682 | u8 on_die_temperature; /* in degrees centigrade*/ | ||
683 | u8 rsvd1[3]; | ||
684 | }; | ||
685 | |||
671 | struct be_cmd_req_vlan_config { | 686 | struct be_cmd_req_vlan_config { |
672 | struct be_cmd_req_hdr hdr; | 687 | struct be_cmd_req_hdr hdr; |
673 | u8 interface_id; | 688 | u8 interface_id; |
@@ -1099,4 +1114,5 @@ extern int be_cmd_get_phy_info(struct be_adapter *adapter, | |||
1099 | struct be_dma_mem *cmd); | 1114 | struct be_dma_mem *cmd); |
1100 | extern int be_cmd_set_qos(struct be_adapter *adapter, u32 bps, u32 domain); | 1115 | extern int be_cmd_set_qos(struct be_adapter *adapter, u32 bps, u32 domain); |
1101 | extern void be_detect_dump_ue(struct be_adapter *adapter); | 1116 | extern void be_detect_dump_ue(struct be_adapter *adapter); |
1117 | extern int be_cmd_get_die_temperature(struct be_adapter *adapter); | ||
1102 | 1118 | ||
diff --git a/drivers/net/benet/be_ethtool.c b/drivers/net/benet/be_ethtool.c index 0833cbdb9b53..47666933c55a 100644 --- a/drivers/net/benet/be_ethtool.c +++ b/drivers/net/benet/be_ethtool.c | |||
@@ -27,7 +27,7 @@ struct be_ethtool_stat { | |||
27 | }; | 27 | }; |
28 | 28 | ||
29 | enum {NETSTAT, PORTSTAT, MISCSTAT, DRVSTAT_TX, DRVSTAT_RX, ERXSTAT, | 29 | enum {NETSTAT, PORTSTAT, MISCSTAT, DRVSTAT_TX, DRVSTAT_RX, ERXSTAT, |
30 | PMEMSTAT}; | 30 | PMEMSTAT, DRVSTAT}; |
31 | #define FIELDINFO(_struct, field) FIELD_SIZEOF(_struct, field), \ | 31 | #define FIELDINFO(_struct, field) FIELD_SIZEOF(_struct, field), \ |
32 | offsetof(_struct, field) | 32 | offsetof(_struct, field) |
33 | #define NETSTAT_INFO(field) #field, NETSTAT,\ | 33 | #define NETSTAT_INFO(field) #field, NETSTAT,\ |
@@ -46,6 +46,9 @@ enum {NETSTAT, PORTSTAT, MISCSTAT, DRVSTAT_TX, DRVSTAT_RX, ERXSTAT, | |||
46 | FIELDINFO(struct be_erx_stats, field) | 46 | FIELDINFO(struct be_erx_stats, field) |
47 | #define PMEMSTAT_INFO(field) #field, PMEMSTAT,\ | 47 | #define PMEMSTAT_INFO(field) #field, PMEMSTAT,\ |
48 | FIELDINFO(struct be_pmem_stats, field) | 48 | FIELDINFO(struct be_pmem_stats, field) |
49 | #define DRVSTAT_INFO(field) #field, DRVSTAT,\ | ||
50 | FIELDINFO(struct be_drv_stats, \ | ||
51 | field) | ||
49 | 52 | ||
50 | static const struct be_ethtool_stat et_stats[] = { | 53 | static const struct be_ethtool_stat et_stats[] = { |
51 | {NETSTAT_INFO(rx_packets)}, | 54 | {NETSTAT_INFO(rx_packets)}, |
@@ -105,7 +108,8 @@ static const struct be_ethtool_stat et_stats[] = { | |||
105 | {MISCSTAT_INFO(rx_drops_mtu)}, | 108 | {MISCSTAT_INFO(rx_drops_mtu)}, |
106 | {MISCSTAT_INFO(port0_jabber_events)}, | 109 | {MISCSTAT_INFO(port0_jabber_events)}, |
107 | {MISCSTAT_INFO(port1_jabber_events)}, | 110 | {MISCSTAT_INFO(port1_jabber_events)}, |
108 | {PMEMSTAT_INFO(eth_red_drops)} | 111 | {PMEMSTAT_INFO(eth_red_drops)}, |
112 | {DRVSTAT_INFO(be_on_die_temperature)} | ||
109 | }; | 113 | }; |
110 | #define ETHTOOL_STATS_NUM ARRAY_SIZE(et_stats) | 114 | #define ETHTOOL_STATS_NUM ARRAY_SIZE(et_stats) |
111 | 115 | ||
@@ -285,6 +289,9 @@ be_get_ethtool_stats(struct net_device *netdev, | |||
285 | case PMEMSTAT: | 289 | case PMEMSTAT: |
286 | p = &hw_stats->pmem; | 290 | p = &hw_stats->pmem; |
287 | break; | 291 | break; |
292 | case DRVSTAT: | ||
293 | p = &adapter->drv_stats; | ||
294 | break; | ||
288 | } | 295 | } |
289 | 296 | ||
290 | p = (u8 *)p + et_stats[i].offset; | 297 | p = (u8 *)p + et_stats[i].offset; |