Skip to content

Commit 900a62a

Browse files
committed
Merge: Revert "Merge: scsi: fnic: driver update"
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/5066 JIRA: https://issues.redhat.com/browse/RHEL-36420 Upstream Status: RHEL-only This reverts commit 21cbb18, reversing changes made to 2cbf058. Bring fnic driver up to date with what's upstream as of v6.9 Signed-off-by: John Meneghini <[email protected]> Approved-by: Lucas Zampieri <[email protected]> Approved-by: Maurizio Lombardi <[email protected]> Approved-by: CKI KWF Bot <[email protected]> Merged-by: Lucas Zampieri <[email protected]>
2 parents 901bada + 866a49f commit 900a62a

File tree

13 files changed

+821
-1141
lines changed

13 files changed

+821
-1141
lines changed

drivers/scsi/fnic/fnic.h

Lines changed: 31 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
#define DRV_NAME "fnic"
4141
#define DRV_DESCRIPTION "Cisco FCoE HBA Driver"
42-
#define DRV_VERSION "1.7.0.0"
42+
#define DRV_VERSION "1.6.0.53"
4343
#define PFX DRV_NAME ": "
4444
#define DFX DRV_NAME "%d: "
4545

@@ -48,6 +48,7 @@
4848
#define FNIC_MIN_IO_REQ 256 /* Min IO throttle count */
4949
#define FNIC_MAX_IO_REQ 1024 /* scsi_cmnd tag map entries */
5050
#define FNIC_DFLT_IO_REQ 256 /* Default scsi_cmnd tag map entries */
51+
#define FNIC_IO_LOCKS 64 /* IO locks: power of 2 */
5152
#define FNIC_DFLT_QUEUE_DEPTH 256
5253
#define FNIC_STATS_RATE_LIMIT 4 /* limit rate at which stats are pulled up */
5354

@@ -88,28 +89,15 @@
8889
#define FNIC_DEV_RST_ABTS_PENDING BIT(21)
8990

9091
/*
91-
* fnic private data per SCSI command.
92+
* Usage of the scsi_cmnd scratchpad.
9293
* These fields are locked by the hashed io_req_lock.
9394
*/
94-
struct fnic_cmd_priv {
95-
struct fnic_io_req *io_req;
96-
enum fnic_ioreq_state state;
97-
u32 flags;
98-
u16 abts_status;
99-
u16 lr_status;
100-
};
101-
102-
static inline struct fnic_cmd_priv *fnic_priv(struct scsi_cmnd *cmd)
103-
{
104-
return scsi_cmd_priv(cmd);
105-
}
106-
107-
static inline u64 fnic_flags_and_state(struct scsi_cmnd *cmd)
108-
{
109-
struct fnic_cmd_priv *fcmd = fnic_priv(cmd);
110-
111-
return ((u64)fcmd->flags << 32) | fcmd->state;
112-
}
95+
#define CMD_SP(Cmnd) ((Cmnd)->SCp.ptr)
96+
#define CMD_STATE(Cmnd) ((Cmnd)->SCp.phase)
97+
#define CMD_ABTS_STATUS(Cmnd) ((Cmnd)->SCp.Message)
98+
#define CMD_LR_STATUS(Cmnd) ((Cmnd)->SCp.have_data_in)
99+
#define CMD_TAG(Cmnd) ((Cmnd)->SCp.sent_command)
100+
#define CMD_FLAGS(Cmnd) ((Cmnd)->SCp.Status)
113101

114102
#define FCPIO_INVALID_CODE 0x100 /* hdr_status value unused by firmware */
115103

@@ -120,7 +108,7 @@ static inline u64 fnic_flags_and_state(struct scsi_cmnd *cmd)
120108
#define FNIC_ABT_TERM_DELAY_TIMEOUT 500 /* mSec */
121109

122110
#define FNIC_MAX_FCP_TARGET 256
123-
#define FNIC_PCI_OFFSET 2
111+
124112
/**
125113
* state_flags to identify host state along along with fnic's state
126114
**/
@@ -155,56 +143,39 @@ do { \
155143
} while (0); \
156144
} while (0)
157145

158-
#define FNIC_MAIN_DBG(kern_level, host, fnic_num, fmt, args...) \
146+
#define FNIC_MAIN_DBG(kern_level, host, fmt, args...) \
159147
FNIC_CHECK_LOGGING(FNIC_MAIN_LOGGING, \
160-
shost_printk(kern_level, host, \
161-
"fnic<%d>: %s: %d: " fmt, fnic_num,\
162-
__func__, __LINE__, ##args);)
148+
shost_printk(kern_level, host, fmt, ##args);)
163149

164-
#define FNIC_FCS_DBG(kern_level, host, fnic_num, fmt, args...) \
150+
#define FNIC_FCS_DBG(kern_level, host, fmt, args...) \
165151
FNIC_CHECK_LOGGING(FNIC_FCS_LOGGING, \
166-
shost_printk(kern_level, host, \
167-
"fnic<%d>: %s: %d: " fmt, fnic_num,\
168-
__func__, __LINE__, ##args);)
152+
shost_printk(kern_level, host, fmt, ##args);)
169153

170-
#define FNIC_SCSI_DBG(kern_level, host, fnic_num, fmt, args...) \
154+
#define FNIC_SCSI_DBG(kern_level, host, fmt, args...) \
171155
FNIC_CHECK_LOGGING(FNIC_SCSI_LOGGING, \
172-
shost_printk(kern_level, host, \
173-
"fnic<%d>: %s: %d: " fmt, fnic_num,\
174-
__func__, __LINE__, ##args);)
156+
shost_printk(kern_level, host, fmt, ##args);)
175157

176-
#define FNIC_ISR_DBG(kern_level, host, fnic_num, fmt, args...) \
158+
#define FNIC_ISR_DBG(kern_level, host, fmt, args...) \
177159
FNIC_CHECK_LOGGING(FNIC_ISR_LOGGING, \
178-
shost_printk(kern_level, host, \
179-
"fnic<%d>: %s: %d: " fmt, fnic_num,\
180-
__func__, __LINE__, ##args);)
160+
shost_printk(kern_level, host, fmt, ##args);)
181161

182162
#define FNIC_MAIN_NOTE(kern_level, host, fmt, args...) \
183163
shost_printk(kern_level, host, fmt, ##args)
184164

185-
#define FNIC_WQ_COPY_MAX 64
186-
#define FNIC_WQ_MAX 1
187-
#define FNIC_RQ_MAX 1
188-
#define FNIC_CQ_MAX (FNIC_WQ_COPY_MAX + FNIC_WQ_MAX + FNIC_RQ_MAX)
189-
#define FNIC_DFLT_IO_COMPLETIONS 256
190-
191-
#define FNIC_MQ_CQ_INDEX 2
192-
193165
extern const char *fnic_state_str[];
194166

195167
enum fnic_intx_intr_index {
196168
FNIC_INTX_WQ_RQ_COPYWQ,
197-
FNIC_INTX_DUMMY,
198-
FNIC_INTX_NOTIFY,
199169
FNIC_INTX_ERR,
170+
FNIC_INTX_NOTIFY,
200171
FNIC_INTX_INTR_MAX,
201172
};
202173

203174
enum fnic_msix_intr_index {
204175
FNIC_MSIX_RQ,
205176
FNIC_MSIX_WQ,
206177
FNIC_MSIX_WQ_COPY,
207-
FNIC_MSIX_ERR_NOTIFY = FNIC_MSIX_WQ_COPY + FNIC_WQ_COPY_MAX,
178+
FNIC_MSIX_ERR_NOTIFY,
208179
FNIC_MSIX_INTR_MAX,
209180
};
210181

@@ -213,7 +184,6 @@ struct fnic_msix_entry {
213184
char devname[IFNAMSIZ + 11];
214185
irqreturn_t (*isr)(int, void *);
215186
void *devid;
216-
int irq_num;
217187
};
218188

219189
enum fnic_state {
@@ -223,6 +193,12 @@ enum fnic_state {
223193
FNIC_IN_ETH_TRANS_FC_MODE,
224194
};
225195

196+
#define FNIC_WQ_COPY_MAX 1
197+
#define FNIC_WQ_MAX 1
198+
#define FNIC_RQ_MAX 1
199+
#define FNIC_CQ_MAX (FNIC_WQ_COPY_MAX + FNIC_WQ_MAX + FNIC_RQ_MAX)
200+
#define FNIC_DFLT_IO_COMPLETIONS 256
201+
226202
struct mempool;
227203

228204
enum fnic_evt {
@@ -237,16 +213,8 @@ struct fnic_event {
237213
enum fnic_evt event;
238214
};
239215

240-
struct fnic_cpy_wq {
241-
unsigned long hw_lock_flags;
242-
u16 active_ioreq_count;
243-
u16 ioreq_table_size;
244-
____cacheline_aligned struct fnic_io_req **io_req_table;
245-
};
246-
247216
/* Per-instance private data structure */
248217
struct fnic {
249-
int fnic_num;
250218
struct fc_lport *lport;
251219
struct fcoe_ctlr ctlr; /* FIP FCoE controller structure */
252220
struct vnic_dev_bar bar0;
@@ -267,9 +235,6 @@ struct fnic {
267235
unsigned int wq_count;
268236
unsigned int cq_count;
269237

270-
struct mutex sgreset_mutex;
271-
spinlock_t sgreset_lock; /* lock for sgreset */
272-
struct scsi_cmnd *sgreset_sc;
273238
struct dentry *fnic_stats_debugfs_host;
274239
struct dentry *fnic_stats_debugfs_file;
275240
struct dentry *fnic_reset_debugfs_file;
@@ -313,11 +278,10 @@ struct fnic {
313278
struct fnic_host_tag *tags;
314279
mempool_t *io_req_pool;
315280
mempool_t *io_sgl_pool[FNIC_SGL_NUM_CACHES];
281+
spinlock_t io_req_lock[FNIC_IO_LOCKS]; /* locks for scsi cmnds */
316282

317-
unsigned int copy_wq_base;
318283
struct work_struct link_work;
319284
struct work_struct frame_work;
320-
struct work_struct flush_work;
321285
struct sk_buff_head frame_queue;
322286
struct sk_buff_head tx_queue;
323287

@@ -334,9 +298,7 @@ struct fnic {
334298
/*** FIP related data members -- end ***/
335299

336300
/* copy work queue cache line section */
337-
____cacheline_aligned struct vnic_wq_copy hw_copy_wq[FNIC_WQ_COPY_MAX];
338-
____cacheline_aligned struct fnic_cpy_wq sw_copy_wq[FNIC_WQ_COPY_MAX];
339-
301+
____cacheline_aligned struct vnic_wq_copy wq_copy[FNIC_WQ_COPY_MAX];
340302
/* completion queue cache line section */
341303
____cacheline_aligned struct vnic_cq cq[FNIC_CQ_MAX];
342304

@@ -364,7 +326,6 @@ extern struct device_attribute *fnic_attrs[];
364326

365327
void fnic_clear_intr_mode(struct fnic *fnic);
366328
int fnic_set_intr_mode(struct fnic *fnic);
367-
int fnic_set_intr_mode_msix(struct fnic *fnic);
368329
void fnic_free_intr(struct fnic *fnic);
369330
int fnic_request_intr(struct fnic *fnic);
370331

@@ -376,7 +337,7 @@ void fnic_handle_event(struct work_struct *work);
376337
int fnic_rq_cmpl_handler(struct fnic *fnic, int);
377338
int fnic_alloc_rq_frame(struct vnic_rq *rq);
378339
void fnic_free_rq_buf(struct vnic_rq *rq, struct vnic_rq_buf *buf);
379-
void fnic_flush_tx(struct work_struct *work);
340+
void fnic_flush_tx(struct fnic *);
380341
void fnic_eth_send(struct fcoe_ctlr *, struct sk_buff *skb);
381342
void fnic_set_port_id(struct fc_lport *, u32, struct fc_frame *);
382343
void fnic_update_mac(struct fc_lport *, u8 *new);
@@ -391,15 +352,15 @@ void fnic_scsi_cleanup(struct fc_lport *);
391352
void fnic_scsi_abort_io(struct fc_lport *);
392353
void fnic_empty_scsi_cleanup(struct fc_lport *);
393354
void fnic_exch_mgr_reset(struct fc_lport *, u32, u32);
394-
int fnic_wq_copy_cmpl_handler(struct fnic *fnic, int copy_work_to_do, unsigned int cq_index);
355+
int fnic_wq_copy_cmpl_handler(struct fnic *fnic, int);
395356
int fnic_wq_cmpl_handler(struct fnic *fnic, int);
396357
int fnic_flogi_reg_handler(struct fnic *fnic, u32);
397358
void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq,
398359
struct fcpio_host_req *desc);
399360
int fnic_fw_reset_handler(struct fnic *fnic);
400361
void fnic_terminate_rport_io(struct fc_rport *);
401362
const char *fnic_state_to_str(unsigned int state);
402-
void fnic_mq_map_queues_cpus(struct Scsi_Host *host);
363+
403364
void fnic_log_q_error(struct fnic *fnic);
404365
void fnic_handle_link_event(struct fnic *fnic);
405366

drivers/scsi/fnic/fnic_attrs.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,22 @@ static ssize_t fnic_show_state(struct device *dev,
2626
struct fc_lport *lp = shost_priv(class_to_shost(dev));
2727
struct fnic *fnic = lport_priv(lp);
2828

29-
return sysfs_emit(buf, "%s\n", fnic_state_str[fnic->state]);
29+
return snprintf(buf, PAGE_SIZE, "%s\n", fnic_state_str[fnic->state]);
3030
}
3131

3232
static ssize_t fnic_show_drv_version(struct device *dev,
3333
struct device_attribute *attr, char *buf)
3434
{
35-
return sysfs_emit(buf, "%s\n", DRV_VERSION);
35+
return snprintf(buf, PAGE_SIZE, "%s\n", DRV_VERSION);
3636
}
3737

3838
static ssize_t fnic_show_link_state(struct device *dev,
3939
struct device_attribute *attr, char *buf)
4040
{
4141
struct fc_lport *lp = shost_priv(class_to_shost(dev));
4242

43-
return sysfs_emit(buf, "%s\n", (lp->link_up) ? "Link Up" : "Link Down");
43+
return snprintf(buf, PAGE_SIZE, "%s\n", (lp->link_up)
44+
? "Link Up" : "Link Down");
4445
}
4546

4647
static DEVICE_ATTR(fnic_state, S_IRUGO, fnic_show_state, NULL);

drivers/scsi/fnic/fnic_debugfs.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,9 @@ int fnic_debugfs_init(void)
6666
fc_trc_flag->fnic_trace = 2;
6767
fc_trc_flag->fc_trace = 3;
6868
fc_trc_flag->fc_clear = 4;
69-
return 0;
7069
}
7170

72-
return -ENOMEM;
71+
return 0;
7372
}
7473

7574
/*
@@ -87,7 +86,8 @@ void fnic_debugfs_terminate(void)
8786
debugfs_remove(fnic_trace_debugfs_root);
8887
fnic_trace_debugfs_root = NULL;
8988

90-
vfree(fc_trc_flag);
89+
if (fc_trc_flag)
90+
vfree(fc_trc_flag);
9191
}
9292

9393
/*
@@ -216,21 +216,25 @@ static int fnic_trace_debugfs_open(struct inode *inode,
216216
return -ENOMEM;
217217

218218
if (*rdata_ptr == fc_trc_flag->fnic_trace) {
219-
fnic_dbg_prt->buffer = vzalloc(array3_size(3, trace_max_pages,
219+
fnic_dbg_prt->buffer = vmalloc(array3_size(3, trace_max_pages,
220220
PAGE_SIZE));
221221
if (!fnic_dbg_prt->buffer) {
222222
kfree(fnic_dbg_prt);
223223
return -ENOMEM;
224224
}
225+
memset((void *)fnic_dbg_prt->buffer, 0,
226+
3 * (trace_max_pages * PAGE_SIZE));
225227
fnic_dbg_prt->buffer_len = fnic_get_trace_data(fnic_dbg_prt);
226228
} else {
227229
fnic_dbg_prt->buffer =
228-
vzalloc(array3_size(3, fnic_fc_trace_max_pages,
230+
vmalloc(array3_size(3, fnic_fc_trace_max_pages,
229231
PAGE_SIZE));
230232
if (!fnic_dbg_prt->buffer) {
231233
kfree(fnic_dbg_prt);
232234
return -ENOMEM;
233235
}
236+
memset((void *)fnic_dbg_prt->buffer, 0,
237+
3 * (fnic_fc_trace_max_pages * PAGE_SIZE));
234238
fnic_dbg_prt->buffer_len =
235239
fnic_fc_trace_get_data(fnic_dbg_prt, *rdata_ptr);
236240
}

0 commit comments

Comments
 (0)