qlcnic: refactor 83xx diagnostic IRQ test
authorJitendra Kalsaria <jitendra.kalsaria@qlogic.com>
Sat, 9 Feb 2013 09:29:52 +0000 (09:29 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 11 Feb 2013 07:04:13 +0000 (02:04 -0500)
Cleanly separate 83xx diagnostic IRQ test from 82xx

Signed-off-by: Jitendra Kalsaria <jitendra.kalsaria@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.h
drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c

index 3d4813121d2e968c88f1fb5c45e50deb0c3331c2..36c1474863661f96e90c59eb0189feb43817c530 100644 (file)
@@ -2744,25 +2744,37 @@ int qlcnic_83xx_get_registers(struct qlcnic_adapter *adapter, u32 *regs_buff)
        return i;
 }
 
-int qlcnic_83xx_interrupt_test(struct qlcnic_adapter *adapter,
-                              struct qlcnic_cmd_args *cmd)
+int qlcnic_83xx_interrupt_test(struct net_device *netdev)
 {
-       u8 val;
-       int ret;
+       struct qlcnic_adapter *adapter = netdev_priv(netdev);
+       struct qlcnic_hardware_context *ahw = adapter->ahw;
+       struct qlcnic_cmd_args cmd;
        u32 data;
        u16 intrpt_id, id;
+       u8 val;
+       int ret, max_sds_rings = adapter->max_sds_rings;
+
+       if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state))
+               return -EIO;
+
+       ret = qlcnic_83xx_diag_alloc_res(netdev, QLCNIC_INTERRUPT_TEST);
+       if (ret)
+               goto fail_diag_irq;
+
+       ahw->diag_cnt = 0;
+       qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_INTRPT_TEST);
 
        if (adapter->flags & QLCNIC_MSIX_ENABLED)
-               intrpt_id = adapter->ahw->intr_tbl[0].id;
+               intrpt_id = ahw->intr_tbl[0].id;
        else
-               intrpt_id = QLCRDX(adapter->ahw, QLCNIC_DEF_INT_ID);
+               intrpt_id = QLCRDX(ahw, QLCNIC_DEF_INT_ID);
 
-       cmd->req.arg[1] = 1;
-       cmd->req.arg[2] = intrpt_id;
-       cmd->req.arg[3] = BIT_0;
+       cmd.req.arg[1] = 1;
+       cmd.req.arg[2] = intrpt_id;
+       cmd.req.arg[3] = BIT_0;
 
-       ret = qlcnic_issue_cmd(adapter, cmd);
-       data = cmd->rsp.arg[2];
+       ret = qlcnic_issue_cmd(adapter, &cmd);
+       data = cmd.rsp.arg[2];
        id = LSW(data);
        val = LSB(MSW(data));
        if (id != intrpt_id)
@@ -2770,9 +2782,21 @@ int qlcnic_83xx_interrupt_test(struct qlcnic_adapter *adapter,
                         "Interrupt generated: 0x%x, requested:0x%x\n",
                         id, intrpt_id);
        if (val)
-               dev_info(&adapter->pdev->dev,
+               dev_err(&adapter->pdev->dev,
                         "Interrupt test error: 0x%x\n", val);
+       if (ret)
+               goto done;
+
+       msleep(20);
+       ret = !ahw->diag_cnt;
 
+done:
+       qlcnic_free_mbx_args(&cmd);
+       qlcnic_83xx_diag_free_res(netdev, max_sds_rings);
+
+fail_diag_irq:
+       adapter->max_sds_rings = max_sds_rings;
+       clear_bit(__QLCNIC_RESETTING, &adapter->state);
        return ret;
 }
 
index 87f2e08c31f4407bffd78fce985473c362df44f7..f60e28ab99417419bd7837cf06603ce9e498e2c3 100644 (file)
@@ -429,7 +429,6 @@ int qlcnic_83xx_reg_test(struct qlcnic_adapter *);
 int qlcnic_83xx_get_regs_len(struct qlcnic_adapter *);
 int qlcnic_83xx_get_registers(struct qlcnic_adapter *, u32 *);
 int qlcnic_83xx_loopback_test(struct net_device *, u8);
-int qlcnic_83xx_interrupt_test(struct qlcnic_adapter *,
-                              struct qlcnic_cmd_args *);
+int qlcnic_83xx_interrupt_test(struct net_device *);
 int qlcnic_83xx_flash_test(struct qlcnic_adapter *);
 #endif
index 58e255437d5afc0165f4ed4ba6bcfa31733953ca..5641f8ec49abab443b1122bfa19c51000408e493 100644 (file)
@@ -823,38 +823,36 @@ static int qlcnic_get_sset_count(struct net_device *dev, int sset)
 static int qlcnic_irq_test(struct net_device *netdev)
 {
        struct qlcnic_adapter *adapter = netdev_priv(netdev);
-       int max_sds_rings = adapter->max_sds_rings;
-       int ret;
+       struct qlcnic_hardware_context *ahw = adapter->ahw;
        struct qlcnic_cmd_args cmd;
+       int ret, max_sds_rings = adapter->max_sds_rings;
+
+       if (qlcnic_83xx_check(adapter))
+               return qlcnic_83xx_interrupt_test(netdev);
 
        if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state))
                return -EIO;
 
        ret = qlcnic_diag_alloc_res(netdev, QLCNIC_INTERRUPT_TEST);
        if (ret)
-               goto clear_it;
+               goto clear_diag_irq;
 
-       adapter->ahw->diag_cnt = 0;
+       ahw->diag_cnt = 0;
        qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_INTRPT_TEST);
 
-       if (qlcnic_83xx_check(adapter)) {
-               ret = qlcnic_83xx_interrupt_test(adapter, &cmd);
-       } else {
-               cmd.req.arg[1] = adapter->ahw->pci_func;
-               ret = qlcnic_issue_cmd(adapter, &cmd);
-       }
-
+       cmd.req.arg[1] = ahw->pci_func;
+       ret = qlcnic_issue_cmd(adapter, &cmd);
        if (ret)
                goto done;
 
        usleep_range(1000, 12000);
-       ret = !adapter->ahw->diag_cnt;
+       ret = !ahw->diag_cnt;
 
 done:
        qlcnic_free_mbx_args(&cmd);
        qlcnic_diag_free_res(netdev, max_sds_rings);
 
-clear_it:
+clear_diag_irq:
        adapter->max_sds_rings = max_sds_rings;
        clear_bit(__QLCNIC_RESETTING, &adapter->state);
        return ret;