Skip to content

Commit 8077c72

Browse files
jahay1anguy11
authored andcommitted
idpf: add controlq init and reset checks
At the end of the probe, initialize and schedule the event workqueue. It calls the hard reset function where reset checks are done to find if the device is out of the reset. Control queue initialization and the necessary control queue support is added. Introduce function pointers for the register operations which are different between PF and VF devices. Signed-off-by: Joshua Hay <[email protected]> Co-developed-by: Alan Brady <[email protected]> Signed-off-by: Alan Brady <[email protected]> Co-developed-by: Madhu Chittim <[email protected]> Signed-off-by: Madhu Chittim <[email protected]> Co-developed-by: Phani Burra <[email protected]> Signed-off-by: Phani Burra <[email protected]> Co-developed-by: Shailendra Bhatnagar <[email protected]> Signed-off-by: Shailendra Bhatnagar <[email protected]> Reviewed-by: Sridhar Samudrala <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Co-developed-by: Pavan Kumar Linga <[email protected]> Signed-off-by: Pavan Kumar Linga <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent e850efe commit 8077c72

14 files changed

+1851
-3
lines changed

drivers/net/ethernet/intel/idpf/Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,10 @@
66
obj-$(CONFIG_IDPF) += idpf.o
77

88
idpf-y := \
9-
idpf_main.o
9+
idpf_controlq.o \
10+
idpf_controlq_setup.o \
11+
idpf_dev.o \
12+
idpf_lib.o \
13+
idpf_main.o \
14+
idpf_virtchnl.o \
15+
idpf_vf_dev.o

drivers/net/ethernet/intel/idpf/idpf.h

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,141 @@
44
#ifndef _IDPF_H_
55
#define _IDPF_H_
66

7+
/* Forward declaration */
8+
struct idpf_adapter;
9+
710
#include <linux/aer.h>
811
#include <linux/etherdevice.h>
912
#include <linux/pci.h>
1013

1114
#include "idpf_controlq.h"
1215

16+
/* Default Mailbox settings */
17+
#define IDPF_NUM_DFLT_MBX_Q 2 /* includes both TX and RX */
18+
#define IDPF_DFLT_MBX_Q_LEN 64
19+
#define IDPF_DFLT_MBX_ID -1
20+
1321
/* available message levels */
1422
#define IDPF_AVAIL_NETIF_M (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK)
1523

24+
/**
25+
* enum idpf_state - State machine to handle bring up
26+
* @__IDPF_STARTUP: Start the state machine
27+
* @__IDPF_STATE_LAST: Must be last, used to determine size
28+
*/
29+
enum idpf_state {
30+
__IDPF_STARTUP,
31+
__IDPF_STATE_LAST,
32+
};
33+
34+
/**
35+
* enum idpf_flags - Hard reset causes.
36+
* @IDPF_HR_FUNC_RESET: Hard reset when TxRx timeout
37+
* @IDPF_HR_DRV_LOAD: Set on driver load for a clean HW
38+
* @IDPF_HR_RESET_IN_PROG: Reset in progress
39+
* @IDPF_REMOVE_IN_PROG: Driver remove in progress
40+
* @IDPF_FLAGS_NBITS: Must be last
41+
*/
42+
enum idpf_flags {
43+
IDPF_HR_FUNC_RESET,
44+
IDPF_HR_DRV_LOAD,
45+
IDPF_HR_RESET_IN_PROG,
46+
IDPF_REMOVE_IN_PROG,
47+
IDPF_FLAGS_NBITS,
48+
};
49+
50+
/**
51+
* struct idpf_reset_reg - Reset register offsets/masks
52+
* @rstat: Reset status register
53+
* @rstat_m: Reset status mask
54+
*/
55+
struct idpf_reset_reg {
56+
void __iomem *rstat;
57+
u32 rstat_m;
58+
};
59+
60+
/**
61+
* struct idpf_reg_ops - Device specific register operation function pointers
62+
* @ctlq_reg_init: Mailbox control queue register initialization
63+
* @reset_reg_init: Reset register initialization
64+
* @trigger_reset: Trigger a reset to occur
65+
*/
66+
struct idpf_reg_ops {
67+
void (*ctlq_reg_init)(struct idpf_ctlq_create_info *cq);
68+
void (*reset_reg_init)(struct idpf_adapter *adapter);
69+
void (*trigger_reset)(struct idpf_adapter *adapter,
70+
enum idpf_flags trig_cause);
71+
};
72+
73+
/**
74+
* struct idpf_dev_ops - Device specific operations
75+
* @reg_ops: Register operations
76+
*/
77+
struct idpf_dev_ops {
78+
struct idpf_reg_ops reg_ops;
79+
};
80+
1681
/**
1782
* struct idpf_adapter - Device data struct generated on probe
1883
* @pdev: PCI device struct given on probe
1984
* @msg_enable: Debug message level enabled
85+
* @state: Init state machine
86+
* @flags: See enum idpf_flags
87+
* @reset_reg: See struct idpf_reset_reg
2088
* @hw: Device access data
89+
* @vc_event_task: Task to handle out of band virtchnl event notifications
90+
* @vc_event_wq: Workqueue for virtchnl events
91+
* @dev_ops: See idpf_dev_ops
92+
* @vport_ctrl_lock: Lock to protect the vport control flow
2193
*/
2294
struct idpf_adapter {
2395
struct pci_dev *pdev;
2496
u32 msg_enable;
97+
enum idpf_state state;
98+
DECLARE_BITMAP(flags, IDPF_FLAGS_NBITS);
99+
struct idpf_reset_reg reset_reg;
25100
struct idpf_hw hw;
101+
102+
struct delayed_work vc_event_task;
103+
struct workqueue_struct *vc_event_wq;
104+
105+
struct idpf_dev_ops dev_ops;
106+
107+
struct mutex vport_ctrl_lock;
26108
};
27109

110+
/**
111+
* idpf_get_reg_addr - Get BAR0 register address
112+
* @adapter: private data struct
113+
* @reg_offset: register offset value
114+
*
115+
* Based on the register offset, return the actual BAR0 register address
116+
*/
117+
static inline void __iomem *idpf_get_reg_addr(struct idpf_adapter *adapter,
118+
resource_size_t reg_offset)
119+
{
120+
return (void __iomem *)(adapter->hw.hw_addr + reg_offset);
121+
}
122+
123+
/**
124+
* idpf_is_reset_detected - check if we were reset at some point
125+
* @adapter: driver specific private structure
126+
*
127+
* Returns true if we are either in reset currently or were previously reset.
128+
*/
129+
static inline bool idpf_is_reset_detected(struct idpf_adapter *adapter)
130+
{
131+
if (!adapter->hw.arq)
132+
return true;
133+
134+
return !(readl(idpf_get_reg_addr(adapter, adapter->hw.arq->reg.len)) &
135+
adapter->hw.arq->reg.len_mask);
136+
}
137+
138+
void idpf_vc_event_task(struct work_struct *work);
139+
void idpf_dev_ops_init(struct idpf_adapter *adapter);
140+
void idpf_vf_dev_ops_init(struct idpf_adapter *adapter);
141+
int idpf_init_dflt_mbx(struct idpf_adapter *adapter);
142+
void idpf_deinit_dflt_mbx(struct idpf_adapter *adapter);
143+
28144
#endif /* !_IDPF_H_ */

0 commit comments

Comments
 (0)