Commit 65b5b420 authored by Amit Kumar Salecha's avatar Amit Kumar Salecha Committed by David S. Miller

qlcnic: add driver debug support

Add debug print in driver, can be tuned by ethtool msg level
callback.
Signed-off-by: default avatarAmit Kumar Salecha <amit.salecha@qlogic.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent aa5e18c0
...@@ -961,6 +961,7 @@ struct qlcnic_adapter { ...@@ -961,6 +961,7 @@ struct qlcnic_adapter {
u8 reset_ack_timeo; u8 reset_ack_timeo;
u8 dev_init_timeo; u8 dev_init_timeo;
u8 rsrd1; u8 rsrd1;
u16 msg_enable;
u8 mac_addr[ETH_ALEN]; u8 mac_addr[ETH_ALEN];
...@@ -1135,4 +1136,11 @@ static inline u32 qlcnic_tx_avail(struct qlcnic_host_tx_ring *tx_ring) ...@@ -1135,4 +1136,11 @@ static inline u32 qlcnic_tx_avail(struct qlcnic_host_tx_ring *tx_ring)
extern const struct ethtool_ops qlcnic_ethtool_ops; extern const struct ethtool_ops qlcnic_ethtool_ops;
#define QLCDB(adapter, lvl, _fmt, _args...) do { \
if (NETIF_MSG_##lvl & adapter->msg_enable) \
printk(KERN_INFO "%s: %s: " _fmt, \
dev_name(&adapter->pdev->dev), \
__func__, ##_args); \
} while (0)
#endif /* __QLCNIC_H_ */ #endif /* __QLCNIC_H_ */
...@@ -998,6 +998,20 @@ static int qlcnic_set_flags(struct net_device *netdev, u32 data) ...@@ -998,6 +998,20 @@ static int qlcnic_set_flags(struct net_device *netdev, u32 data)
return 0; return 0;
} }
static u32 qlcnic_get_msglevel(struct net_device *netdev)
{
struct qlcnic_adapter *adapter = netdev_priv(netdev);
return adapter->msg_enable;
}
static void qlcnic_set_msglevel(struct net_device *netdev, u32 msglvl)
{
struct qlcnic_adapter *adapter = netdev_priv(netdev);
adapter->msg_enable = msglvl;
}
const struct ethtool_ops qlcnic_ethtool_ops = { const struct ethtool_ops qlcnic_ethtool_ops = {
.get_settings = qlcnic_get_settings, .get_settings = qlcnic_get_settings,
.set_settings = qlcnic_set_settings, .set_settings = qlcnic_set_settings,
...@@ -1029,4 +1043,6 @@ const struct ethtool_ops qlcnic_ethtool_ops = { ...@@ -1029,4 +1043,6 @@ const struct ethtool_ops qlcnic_ethtool_ops = {
.get_flags = ethtool_op_get_flags, .get_flags = ethtool_op_get_flags,
.set_flags = qlcnic_set_flags, .set_flags = qlcnic_set_flags,
.phys_id = qlcnic_blink_led, .phys_id = qlcnic_blink_led,
.set_msglevel = qlcnic_set_msglevel,
.get_msglevel = qlcnic_get_msglevel,
}; };
...@@ -294,8 +294,12 @@ qlcnic_pcie_sem_lock(struct qlcnic_adapter *adapter, int sem, u32 id_reg) ...@@ -294,8 +294,12 @@ qlcnic_pcie_sem_lock(struct qlcnic_adapter *adapter, int sem, u32 id_reg)
done = QLCRD32(adapter, QLCNIC_PCIE_REG(PCIE_SEM_LOCK(sem))); done = QLCRD32(adapter, QLCNIC_PCIE_REG(PCIE_SEM_LOCK(sem)));
if (done == 1) if (done == 1)
break; break;
if (++timeout >= QLCNIC_PCIE_SEM_TIMEOUT) if (++timeout >= QLCNIC_PCIE_SEM_TIMEOUT) {
dev_err(&adapter->pdev->dev,
"Failed to acquire sem=%d lock;reg_id=%d\n",
sem, id_reg);
return -EIO; return -EIO;
}
msleep(1); msleep(1);
} }
......
...@@ -1742,6 +1742,7 @@ static void qlcnic_tx_timeout_task(struct work_struct *work) ...@@ -1742,6 +1742,7 @@ static void qlcnic_tx_timeout_task(struct work_struct *work)
request_reset: request_reset:
adapter->need_fw_reset = 1; adapter->need_fw_reset = 1;
clear_bit(__QLCNIC_RESETTING, &adapter->state); clear_bit(__QLCNIC_RESETTING, &adapter->state);
QLCDB(adapter, DRV, "Resetting adapter\n");
} }
static struct net_device_stats *qlcnic_get_stats(struct net_device *netdev) static struct net_device_stats *qlcnic_get_stats(struct net_device *netdev)
...@@ -2046,6 +2047,7 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter) ...@@ -2046,6 +2047,7 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter)
} }
prev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); prev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE);
QLCDB(adapter, HW, "Device state = %u\n", prev_state);
switch (prev_state) { switch (prev_state) {
case QLCNIC_DEV_COLD: case QLCNIC_DEV_COLD:
...@@ -2082,8 +2084,11 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter) ...@@ -2082,8 +2084,11 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter)
} while ((QLCRD32(adapter, QLCNIC_CRB_DEV_STATE) != QLCNIC_DEV_READY) } while ((QLCRD32(adapter, QLCNIC_CRB_DEV_STATE) != QLCNIC_DEV_READY)
&& --dev_init_timeo); && --dev_init_timeo);
if (!dev_init_timeo) if (!dev_init_timeo) {
dev_err(&adapter->pdev->dev,
"Waiting for device to initialize timeout\n");
return -1; return -1;
}
if (qlcnic_api_lock(adapter)) if (qlcnic_api_lock(adapter))
return -1; return -1;
...@@ -2113,6 +2118,7 @@ qlcnic_fwinit_work(struct work_struct *work) ...@@ -2113,6 +2118,7 @@ qlcnic_fwinit_work(struct work_struct *work)
return; return;
} }
QLCDB(adapter, DRV, "Resetting FW\n");
if (!qlcnic_start_firmware(adapter)) { if (!qlcnic_start_firmware(adapter)) {
qlcnic_schedule_work(adapter, qlcnic_attach_work, 0); qlcnic_schedule_work(adapter, qlcnic_attach_work, 0);
return; return;
...@@ -2121,10 +2127,15 @@ qlcnic_fwinit_work(struct work_struct *work) ...@@ -2121,10 +2127,15 @@ qlcnic_fwinit_work(struct work_struct *work)
goto err_ret; goto err_ret;
} }
if (adapter->fw_wait_cnt++ > (adapter->dev_init_timeo / 2)) if (adapter->fw_wait_cnt++ > (adapter->dev_init_timeo / 2)) {
dev_err(&adapter->pdev->dev,
"Waiting for device to reset timeout\n");
goto err_ret; goto err_ret;
}
dev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); dev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE);
QLCDB(adapter, HW, "Func waiting: Device state=%d\n", dev_state);
switch (dev_state) { switch (dev_state) {
case QLCNIC_DEV_READY: case QLCNIC_DEV_READY:
if (!qlcnic_start_firmware(adapter)) { if (!qlcnic_start_firmware(adapter)) {
...@@ -2177,6 +2188,8 @@ qlcnic_detach_work(struct work_struct *work) ...@@ -2177,6 +2188,8 @@ qlcnic_detach_work(struct work_struct *work)
return; return;
err_ret: err_ret:
dev_err(&adapter->pdev->dev, "detach failed; status=%d temp=%d\n",
status, adapter->temp);
qlcnic_clr_all_drv_state(adapter); qlcnic_clr_all_drv_state(adapter);
} }
...@@ -2194,6 +2207,7 @@ qlcnic_dev_request_reset(struct qlcnic_adapter *adapter) ...@@ -2194,6 +2207,7 @@ qlcnic_dev_request_reset(struct qlcnic_adapter *adapter)
if (state != QLCNIC_DEV_INITALIZING && state != QLCNIC_DEV_NEED_RESET) { if (state != QLCNIC_DEV_INITALIZING && state != QLCNIC_DEV_NEED_RESET) {
QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_NEED_RESET); QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_NEED_RESET);
set_bit(__QLCNIC_START_FW, &adapter->state); set_bit(__QLCNIC_START_FW, &adapter->state);
QLCDB(adapter, DRV, "NEED_RESET state set\n");
} }
qlcnic_api_unlock(adapter); qlcnic_api_unlock(adapter);
...@@ -2290,8 +2304,11 @@ qlcnic_check_health(struct qlcnic_adapter *adapter) ...@@ -2290,8 +2304,11 @@ qlcnic_check_health(struct qlcnic_adapter *adapter)
QLCNIC_DEV_NEED_RESET; QLCNIC_DEV_NEED_RESET;
if ((auto_fw_reset == AUTO_FW_RESET_ENABLED) && if ((auto_fw_reset == AUTO_FW_RESET_ENABLED) &&
!test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) !test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) {
qlcnic_schedule_work(adapter, qlcnic_detach_work, 0); qlcnic_schedule_work(adapter, qlcnic_detach_work, 0);
QLCDB(adapter, DRV, "fw recovery scheduled.\n");
}
return 1; return 1;
} }
......
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