Skip to content

Commit 4690a7e

Browse files
Sony Chackodavem330
authored andcommitted
qlcnic: diagnostics routine changes
Test and set diagnostics mode bit before starting diagnostics tests. Stop diagnostics tests if adapter is resetting. Signed-off-by: Sony Chacko <[email protected]> Signed-off-by: Shahed Shaikh <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b17f2cc commit 4690a7e

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

drivers/net/ethernet/qlogic/qlcnic/qlcnic.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,7 @@ struct qlcnic_ipaddr {
931931
#define __QLCNIC_SRIOV_ENABLE 10
932932
#define __QLCNIC_SRIOV_CAPABLE 11
933933
#define __QLCNIC_MBX_POLL_ENABLE 12
934+
#define __QLCNIC_DIAG_MODE 13
934935

935936
#define QLCNIC_INTERRUPT_TEST 1
936937
#define QLCNIC_LOOPBACK_TEST 2
@@ -1476,6 +1477,7 @@ int qlcnic_send_lro_cleanup(struct qlcnic_adapter *adapter);
14761477
void qlcnic_update_cmd_producer(struct qlcnic_host_tx_ring *);
14771478

14781479
/* Functions from qlcnic_ethtool.c */
1480+
14791481
int qlcnic_check_loopback_buff(unsigned char *, u8 []);
14801482
int qlcnic_do_lb_test(struct qlcnic_adapter *, u8);
14811483
int qlcnic_loopback_test(struct net_device *, u8);
@@ -1885,6 +1887,16 @@ static inline void qlcnic_enable_int(struct qlcnic_host_sds_ring *sds_ring)
18851887
writel(0xfbff, adapter->tgt_mask_reg);
18861888
}
18871889

1890+
static inline int qlcnic_get_diag_lock(struct qlcnic_adapter *adapter)
1891+
{
1892+
return test_and_set_bit(__QLCNIC_DIAG_MODE, &adapter->state);
1893+
}
1894+
1895+
static inline void qlcnic_release_diag_lock(struct qlcnic_adapter *adapter)
1896+
{
1897+
clear_bit(__QLCNIC_DIAG_MODE, &adapter->state);
1898+
}
1899+
18881900
extern const struct ethtool_ops qlcnic_sriov_vf_ethtool_ops;
18891901
extern const struct ethtool_ops qlcnic_ethtool_ops;
18901902
extern const struct ethtool_ops qlcnic_ethtool_failed_ops;

drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,16 +1593,24 @@ int qlcnic_83xx_loopback_test(struct net_device *netdev, u8 mode)
15931593
struct qlcnic_hardware_context *ahw = adapter->ahw;
15941594
int ret = 0, loop = 0, max_sds_rings = adapter->max_sds_rings;
15951595

1596-
QLCDB(adapter, DRV, "%s loopback test in progress\n",
1597-
mode == QLCNIC_ILB_MODE ? "internal" : "external");
15981596
if (ahw->op_mode == QLCNIC_NON_PRIV_FUNC) {
1599-
dev_warn(&adapter->pdev->dev,
1600-
"Loopback test not supported for non privilege function\n");
1597+
netdev_warn(netdev,
1598+
"Loopback test not supported in non privileged mode\n");
16011599
return ret;
16021600
}
16031601

1604-
if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state))
1602+
if (test_bit(__QLCNIC_RESETTING, &adapter->state)) {
1603+
netdev_info(netdev, "Device is resetting\n");
16051604
return -EBUSY;
1605+
}
1606+
1607+
if (qlcnic_get_diag_lock(adapter)) {
1608+
netdev_info(netdev, "Device is in diagnostics mode\n");
1609+
return -EBUSY;
1610+
}
1611+
1612+
netdev_info(netdev, "%s loopback test in progress\n",
1613+
mode == QLCNIC_ILB_MODE ? "internal" : "external");
16061614

16071615
ret = qlcnic_83xx_diag_alloc_res(netdev, QLCNIC_LOOPBACK_TEST,
16081616
max_sds_rings);
@@ -1643,7 +1651,7 @@ int qlcnic_83xx_loopback_test(struct net_device *netdev, u8 mode)
16431651

16441652
fail_diag_alloc:
16451653
adapter->max_sds_rings = max_sds_rings;
1646-
clear_bit(__QLCNIC_RESETTING, &adapter->state);
1654+
qlcnic_release_diag_lock(adapter);
16471655
return ret;
16481656
}
16491657

@@ -3118,8 +3126,10 @@ int qlcnic_83xx_interrupt_test(struct net_device *netdev)
31183126
u8 val;
31193127
int ret, max_sds_rings = adapter->max_sds_rings;
31203128

3121-
if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state))
3122-
return -EIO;
3129+
if (qlcnic_get_diag_lock(adapter)) {
3130+
netdev_info(netdev, "Device in diagnostics mode\n");
3131+
return -EBUSY;
3132+
}
31233133

31243134
ret = qlcnic_83xx_diag_alloc_res(netdev, QLCNIC_INTERRUPT_TEST,
31253135
max_sds_rings);
@@ -3161,7 +3171,7 @@ int qlcnic_83xx_interrupt_test(struct net_device *netdev)
31613171

31623172
fail_diag_irq:
31633173
adapter->max_sds_rings = max_sds_rings;
3164-
clear_bit(__QLCNIC_RESETTING, &adapter->state);
3174+
qlcnic_release_diag_lock(adapter);
31653175
return ret;
31663176
}
31673177

0 commit comments

Comments
 (0)