aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmit Kumar Salecha <amit.salecha@qlogic.com>2010-04-01 15:01:33 -0400
committerDavid S. Miller <davem@davemloft.net>2010-04-03 17:19:15 -0400
commit65b5b420b5974d86ee030b0a15cd9e6f228071f4 (patch)
tree5ddf10e7f5a3ed54dd6fc75f90c41c4694ff6061
parentaa5e18c04af8706251768e6aba83465e31de7810 (diff)
qlcnic: add driver debug support
Add debug print in driver, can be tuned by ethtool msg level callback. Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/qlcnic/qlcnic.h8
-rw-r--r--drivers/net/qlcnic/qlcnic_ethtool.c16
-rw-r--r--drivers/net/qlcnic/qlcnic_hw.c6
-rw-r--r--drivers/net/qlcnic/qlcnic_main.c23
4 files changed, 49 insertions, 4 deletions
diff --git a/drivers/net/qlcnic/qlcnic.h b/drivers/net/qlcnic/qlcnic.h
index 87cd1a7ef9ca..68687e24aae2 100644
--- a/drivers/net/qlcnic/qlcnic.h
+++ b/drivers/net/qlcnic/qlcnic.h
@@ -961,6 +961,7 @@ struct qlcnic_adapter {
961 u8 reset_ack_timeo; 961 u8 reset_ack_timeo;
962 u8 dev_init_timeo; 962 u8 dev_init_timeo;
963 u8 rsrd1; 963 u8 rsrd1;
964 u16 msg_enable;
964 965
965 u8 mac_addr[ETH_ALEN]; 966 u8 mac_addr[ETH_ALEN];
966 967
@@ -1135,4 +1136,11 @@ static inline u32 qlcnic_tx_avail(struct qlcnic_host_tx_ring *tx_ring)
1135 1136
1136extern const struct ethtool_ops qlcnic_ethtool_ops; 1137extern const struct ethtool_ops qlcnic_ethtool_ops;
1137 1138
1139#define QLCDB(adapter, lvl, _fmt, _args...) do { \
1140 if (NETIF_MSG_##lvl & adapter->msg_enable) \
1141 printk(KERN_INFO "%s: %s: " _fmt, \
1142 dev_name(&adapter->pdev->dev), \
1143 __func__, ##_args); \
1144 } while (0)
1145
1138#endif /* __QLCNIC_H_ */ 1146#endif /* __QLCNIC_H_ */
diff --git a/drivers/net/qlcnic/qlcnic_ethtool.c b/drivers/net/qlcnic/qlcnic_ethtool.c
index f83e15fe3e1b..08d6f105371f 100644
--- a/drivers/net/qlcnic/qlcnic_ethtool.c
+++ b/drivers/net/qlcnic/qlcnic_ethtool.c
@@ -998,6 +998,20 @@ static int qlcnic_set_flags(struct net_device *netdev, u32 data)
998 return 0; 998 return 0;
999} 999}
1000 1000
1001static u32 qlcnic_get_msglevel(struct net_device *netdev)
1002{
1003 struct qlcnic_adapter *adapter = netdev_priv(netdev);
1004
1005 return adapter->msg_enable;
1006}
1007
1008static void qlcnic_set_msglevel(struct net_device *netdev, u32 msglvl)
1009{
1010 struct qlcnic_adapter *adapter = netdev_priv(netdev);
1011
1012 adapter->msg_enable = msglvl;
1013}
1014
1001const struct ethtool_ops qlcnic_ethtool_ops = { 1015const struct ethtool_ops qlcnic_ethtool_ops = {
1002 .get_settings = qlcnic_get_settings, 1016 .get_settings = qlcnic_get_settings,
1003 .set_settings = qlcnic_set_settings, 1017 .set_settings = qlcnic_set_settings,
@@ -1029,4 +1043,6 @@ const struct ethtool_ops qlcnic_ethtool_ops = {
1029 .get_flags = ethtool_op_get_flags, 1043 .get_flags = ethtool_op_get_flags,
1030 .set_flags = qlcnic_set_flags, 1044 .set_flags = qlcnic_set_flags,
1031 .phys_id = qlcnic_blink_led, 1045 .phys_id = qlcnic_blink_led,
1046 .set_msglevel = qlcnic_set_msglevel,
1047 .get_msglevel = qlcnic_get_msglevel,
1032}; 1048};
diff --git a/drivers/net/qlcnic/qlcnic_hw.c b/drivers/net/qlcnic/qlcnic_hw.c
index 0933c2da39eb..14c999ab4222 100644
--- a/drivers/net/qlcnic/qlcnic_hw.c
+++ b/drivers/net/qlcnic/qlcnic_hw.c
@@ -294,8 +294,12 @@ qlcnic_pcie_sem_lock(struct qlcnic_adapter *adapter, int sem, u32 id_reg)
294 done = QLCRD32(adapter, QLCNIC_PCIE_REG(PCIE_SEM_LOCK(sem))); 294 done = QLCRD32(adapter, QLCNIC_PCIE_REG(PCIE_SEM_LOCK(sem)));
295 if (done == 1) 295 if (done == 1)
296 break; 296 break;
297 if (++timeout >= QLCNIC_PCIE_SEM_TIMEOUT) 297 if (++timeout >= QLCNIC_PCIE_SEM_TIMEOUT) {
298 dev_err(&adapter->pdev->dev,
299 "Failed to acquire sem=%d lock;reg_id=%d\n",
300 sem, id_reg);
298 return -EIO; 301 return -EIO;
302 }
299 msleep(1); 303 msleep(1);
300 } 304 }
301 305
diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c
index 38e082969253..039f69382dc9 100644
--- a/drivers/net/qlcnic/qlcnic_main.c
+++ b/drivers/net/qlcnic/qlcnic_main.c
@@ -1742,6 +1742,7 @@ static void qlcnic_tx_timeout_task(struct work_struct *work)
1742request_reset: 1742request_reset:
1743 adapter->need_fw_reset = 1; 1743 adapter->need_fw_reset = 1;
1744 clear_bit(__QLCNIC_RESETTING, &adapter->state); 1744 clear_bit(__QLCNIC_RESETTING, &adapter->state);
1745 QLCDB(adapter, DRV, "Resetting adapter\n");
1745} 1746}
1746 1747
1747static struct net_device_stats *qlcnic_get_stats(struct net_device *netdev) 1748static struct net_device_stats *qlcnic_get_stats(struct net_device *netdev)
@@ -2046,6 +2047,7 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter)
2046 } 2047 }
2047 2048
2048 prev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); 2049 prev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE);
2050 QLCDB(adapter, HW, "Device state = %u\n", prev_state);
2049 2051
2050 switch (prev_state) { 2052 switch (prev_state) {
2051 case QLCNIC_DEV_COLD: 2053 case QLCNIC_DEV_COLD:
@@ -2082,8 +2084,11 @@ start_fw:
2082 } while ((QLCRD32(adapter, QLCNIC_CRB_DEV_STATE) != QLCNIC_DEV_READY) 2084 } while ((QLCRD32(adapter, QLCNIC_CRB_DEV_STATE) != QLCNIC_DEV_READY)
2083 && --dev_init_timeo); 2085 && --dev_init_timeo);
2084 2086
2085 if (!dev_init_timeo) 2087 if (!dev_init_timeo) {
2088 dev_err(&adapter->pdev->dev,
2089 "Waiting for device to initialize timeout\n");
2086 return -1; 2090 return -1;
2091 }
2087 2092
2088 if (qlcnic_api_lock(adapter)) 2093 if (qlcnic_api_lock(adapter))
2089 return -1; 2094 return -1;
@@ -2113,6 +2118,7 @@ qlcnic_fwinit_work(struct work_struct *work)
2113 return; 2118 return;
2114 } 2119 }
2115 2120
2121 QLCDB(adapter, DRV, "Resetting FW\n");
2116 if (!qlcnic_start_firmware(adapter)) { 2122 if (!qlcnic_start_firmware(adapter)) {
2117 qlcnic_schedule_work(adapter, qlcnic_attach_work, 0); 2123 qlcnic_schedule_work(adapter, qlcnic_attach_work, 0);
2118 return; 2124 return;
@@ -2121,10 +2127,15 @@ qlcnic_fwinit_work(struct work_struct *work)
2121 goto err_ret; 2127 goto err_ret;
2122 } 2128 }
2123 2129
2124 if (adapter->fw_wait_cnt++ > (adapter->dev_init_timeo / 2)) 2130 if (adapter->fw_wait_cnt++ > (adapter->dev_init_timeo / 2)) {
2131 dev_err(&adapter->pdev->dev,
2132 "Waiting for device to reset timeout\n");
2125 goto err_ret; 2133 goto err_ret;
2134 }
2126 2135
2127 dev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); 2136 dev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE);
2137 QLCDB(adapter, HW, "Func waiting: Device state=%d\n", dev_state);
2138
2128 switch (dev_state) { 2139 switch (dev_state) {
2129 case QLCNIC_DEV_READY: 2140 case QLCNIC_DEV_READY:
2130 if (!qlcnic_start_firmware(adapter)) { 2141 if (!qlcnic_start_firmware(adapter)) {
@@ -2177,6 +2188,8 @@ qlcnic_detach_work(struct work_struct *work)
2177 return; 2188 return;
2178 2189
2179err_ret: 2190err_ret:
2191 dev_err(&adapter->pdev->dev, "detach failed; status=%d temp=%d\n",
2192 status, adapter->temp);
2180 qlcnic_clr_all_drv_state(adapter); 2193 qlcnic_clr_all_drv_state(adapter);
2181 2194
2182} 2195}
@@ -2194,6 +2207,7 @@ qlcnic_dev_request_reset(struct qlcnic_adapter *adapter)
2194 if (state != QLCNIC_DEV_INITALIZING && state != QLCNIC_DEV_NEED_RESET) { 2207 if (state != QLCNIC_DEV_INITALIZING && state != QLCNIC_DEV_NEED_RESET) {
2195 QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_NEED_RESET); 2208 QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_NEED_RESET);
2196 set_bit(__QLCNIC_START_FW, &adapter->state); 2209 set_bit(__QLCNIC_START_FW, &adapter->state);
2210 QLCDB(adapter, DRV, "NEED_RESET state set\n");
2197 } 2211 }
2198 2212
2199 qlcnic_api_unlock(adapter); 2213 qlcnic_api_unlock(adapter);
@@ -2290,8 +2304,11 @@ detach:
2290 QLCNIC_DEV_NEED_RESET; 2304 QLCNIC_DEV_NEED_RESET;
2291 2305
2292 if ((auto_fw_reset == AUTO_FW_RESET_ENABLED) && 2306 if ((auto_fw_reset == AUTO_FW_RESET_ENABLED) &&
2293 !test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) 2307 !test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) {
2308
2294 qlcnic_schedule_work(adapter, qlcnic_detach_work, 0); 2309 qlcnic_schedule_work(adapter, qlcnic_detach_work, 0);
2310 QLCDB(adapter, DRV, "fw recovery scheduled.\n");
2311 }
2295 2312
2296 return 1; 2313 return 1;
2297} 2314}