Skip to content

Commit f036e4f

Browse files
Rajesh Borundiadavem330
authored andcommitted
qlcnic: VF reset recovery implementation.
o Implement recovery mechanism for VF to recover from adapter resets. Signed-off-by: Manish Chopra <[email protected]> Signed-off-by: Sucheta Chakraborty <[email protected]> Signed-off-by: Rajesh Borundia <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 97d8105 commit f036e4f

File tree

8 files changed

+440
-43
lines changed

8 files changed

+440
-43
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,7 @@ struct qlcnic_adapter {
976976
u8 fw_fail_cnt;
977977
u8 tx_timeo_cnt;
978978
u8 need_fw_reset;
979+
u8 reset_ctx_cnt;
979980

980981
u16 is_up;
981982
u16 pvid;

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,13 @@ inline void qlcnic_83xx_enable_legacy_msix_mbx_intr(struct qlcnic_adapter
339339
writel(0, adapter->ahw->pci_base0 + mask);
340340
}
341341

342-
inline void qlcnic_83xx_disable_mbx_intr(struct qlcnic_adapter *adapter)
342+
void qlcnic_83xx_disable_mbx_intr(struct qlcnic_adapter *adapter)
343343
{
344344
u32 mask;
345345

346346
mask = QLCRDX(adapter->ahw, QLCNIC_DEF_INT_MASK);
347347
writel(1, adapter->ahw->pci_base0 + mask);
348+
QLCWRX(adapter->ahw, QLCNIC_MBX_INTR_ENBL, 0);
348349
}
349350

350351
static inline void qlcnic_83xx_get_mbx_data(struct qlcnic_adapter *adapter,
@@ -453,17 +454,15 @@ irqreturn_t qlcnic_83xx_tmp_intr(int irq, void *data)
453454

454455
void qlcnic_83xx_free_mbx_intr(struct qlcnic_adapter *adapter)
455456
{
456-
u32 val = 0, num_msix = adapter->ahw->num_msix - 1;
457+
u32 num_msix;
458+
459+
qlcnic_83xx_disable_mbx_intr(adapter);
457460

458461
if (adapter->flags & QLCNIC_MSIX_ENABLED)
459462
num_msix = adapter->ahw->num_msix - 1;
460463
else
461464
num_msix = 0;
462465

463-
QLCWRX(adapter->ahw, QLCNIC_MBX_INTR_ENBL, val);
464-
465-
qlcnic_83xx_disable_mbx_intr(adapter);
466-
467466
msleep(20);
468467
synchronize_irq(adapter->msix_entries[num_msix].vector);
469468
free_irq(adapter->msix_entries[num_msix].vector, adapter);

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,18 @@ struct qlc_83xx_idc {
317317
char **name;
318318
};
319319

320+
/* Device States */
321+
enum qlcnic_83xx_states {
322+
QLC_83XX_IDC_DEV_UNKNOWN,
323+
QLC_83XX_IDC_DEV_COLD,
324+
QLC_83XX_IDC_DEV_INIT,
325+
QLC_83XX_IDC_DEV_READY,
326+
QLC_83XX_IDC_DEV_NEED_RESET,
327+
QLC_83XX_IDC_DEV_NEED_QUISCENT,
328+
QLC_83XX_IDC_DEV_FAILED,
329+
QLC_83XX_IDC_DEV_QUISCENT
330+
};
331+
320332
#define QLCNIC_MBX_RSP(reg) LSW(reg)
321333
#define QLCNIC_MBX_NUM_REGS(reg) (MSW(reg) & 0x1FF)
322334
#define QLCNIC_MBX_STATUS(reg) (((reg) >> 25) & 0x7F)
@@ -536,6 +548,7 @@ void qlcnic_83xx_config_intr_coal(struct qlcnic_adapter *);
536548
irqreturn_t qlcnic_83xx_handle_aen(int, void *);
537549
int qlcnic_83xx_get_port_info(struct qlcnic_adapter *);
538550
void qlcnic_83xx_enable_mbx_intrpt(struct qlcnic_adapter *);
551+
void qlcnic_83xx_disable_mbx_intr(struct qlcnic_adapter *);
539552
irqreturn_t qlcnic_83xx_clear_legacy_intr(struct qlcnic_adapter *);
540553
irqreturn_t qlcnic_83xx_intr(int, void *);
541554
irqreturn_t qlcnic_83xx_tmp_intr(int, void *);

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

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,6 @@ static const char *const qlc_83xx_idc_states[] = {
115115
"Quiesce"
116116
};
117117

118-
/* Device States */
119-
enum qlcnic_83xx_states {
120-
QLC_83XX_IDC_DEV_UNKNOWN,
121-
QLC_83XX_IDC_DEV_COLD,
122-
QLC_83XX_IDC_DEV_INIT,
123-
QLC_83XX_IDC_DEV_READY,
124-
QLC_83XX_IDC_DEV_NEED_RESET,
125-
QLC_83XX_IDC_DEV_NEED_QUISCENT,
126-
QLC_83XX_IDC_DEV_FAILED,
127-
QLC_83XX_IDC_DEV_QUISCENT
128-
};
129-
130118
static int
131119
qlcnic_83xx_idc_check_driver_presence_reg(struct qlcnic_adapter *adapter)
132120
{
@@ -162,7 +150,8 @@ static int qlcnic_83xx_idc_update_audit_reg(struct qlcnic_adapter *adapter,
162150
return -EBUSY;
163151
}
164152

165-
val = adapter->portnum & 0xf;
153+
val = QLCRDX(adapter->ahw, QLC_83XX_IDC_DRV_AUDIT);
154+
val |= (adapter->portnum & 0xf);
166155
val |= mode << 7;
167156
if (mode)
168157
seconds = jiffies / HZ - adapter->ahw->idc.sec_counter;
@@ -401,14 +390,18 @@ static void qlcnic_83xx_idc_detach_driver(struct qlcnic_adapter *adapter)
401390
struct net_device *netdev = adapter->netdev;
402391

403392
netif_device_detach(netdev);
393+
404394
/* Disable mailbox interrupt */
405-
QLCWRX(adapter->ahw, QLCNIC_MBX_INTR_ENBL, 0);
395+
qlcnic_83xx_disable_mbx_intr(adapter);
406396
qlcnic_down(adapter, netdev);
407397
for (i = 0; i < adapter->ahw->num_msix; i++) {
408398
adapter->ahw->intr_tbl[i].id = i;
409399
adapter->ahw->intr_tbl[i].enabled = 0;
410400
adapter->ahw->intr_tbl[i].src = 0;
411401
}
402+
403+
if (qlcnic_sriov_pf_check(adapter))
404+
qlcnic_sriov_pf_reset(adapter);
412405
}
413406

414407
/**
@@ -610,9 +603,15 @@ static int qlcnic_83xx_idc_check_fan_failure(struct qlcnic_adapter *adapter)
610603

611604
static int qlcnic_83xx_idc_reattach_driver(struct qlcnic_adapter *adapter)
612605
{
606+
int err;
607+
613608
/* register for NIC IDC AEN Events */
614609
qlcnic_83xx_register_nic_idc_func(adapter, 1);
615610

611+
err = qlcnic_sriov_pf_reinit(adapter);
612+
if (err)
613+
return err;
614+
616615
qlcnic_83xx_enable_mbx_intrpt(adapter);
617616

618617
if (qlcnic_83xx_configure_opmode(adapter)) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ enum {
669669
#define QLCNIC_CMDPEG_CHECK_RETRY_COUNT 60
670670
#define QLCNIC_CMDPEG_CHECK_DELAY 500
671671
#define QLCNIC_HEARTBEAT_PERIOD_MSECS 200
672-
#define QLCNIC_HEARTBEAT_CHECK_RETRY_COUNT 45
672+
#define QLCNIC_HEARTBEAT_CHECK_RETRY_COUNT 10
673673

674674
#define QLCNIC_MAX_MC_COUNT 38
675675
#define QLCNIC_WATCHDOG_TIMEOUTVALUE 5

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ void qlcnic_sriov_pf_handle_flr(struct qlcnic_sriov *, struct qlcnic_vf_info *);
197197
bool qlcnic_sriov_soft_flr_check(struct qlcnic_adapter *,
198198
struct qlcnic_bc_trans *,
199199
struct qlcnic_vf_info *);
200+
void qlcnic_sriov_pf_reset(struct qlcnic_adapter *);
201+
int qlcnic_sriov_pf_reinit(struct qlcnic_adapter *);
200202
#else
201203
static inline void qlcnic_sriov_pf_disable(struct qlcnic_adapter *adapter) {}
202204
static inline void qlcnic_sriov_pf_cleanup(struct qlcnic_adapter *adapter) {}
@@ -227,6 +229,9 @@ static inline bool qlcnic_sriov_soft_flr_check(struct qlcnic_adapter *adapter,
227229
struct qlcnic_bc_trans *trans,
228230
struct qlcnic_vf_info *vf)
229231
{ return false; }
232+
static inline void qlcnic_sriov_pf_reset(struct qlcnic_adapter *adapter) {}
233+
static inline int qlcnic_sriov_pf_reinit(struct qlcnic_adapter *adapter)
234+
{ return 0; }
230235
#endif
231236

232237
#endif

0 commit comments

Comments
 (0)