Skip to content

Commit 9243626

Browse files
Karan Tilak Kumarmartinkpetersen
authored andcommitted
scsi: fnic: Modify fnic interfaces to use FDLS
Modify fnic driver interfaces to use FDLS and supporting functions. Refactor code in fnic_probe and fnic_remove. Get fnic from shost_priv. Add error handling in stats processing functions. Modify some print statements. Add support to do module unload cleanup. Use placeholder functions/modify function declarations to not break compilation. Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com> Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com> Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com> Co-developed-by: Arun Easi <aeasi@cisco.com> Signed-off-by: Arun Easi <aeasi@cisco.com> Co-developed-by: Karan Tilak Kumar <kartilak@cisco.com> Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com> Link: https://lore.kernel.org/r/20241212020312.4786-12-kartilak@cisco.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 6335be1 commit 9243626

File tree

9 files changed

+398
-247
lines changed

9 files changed

+398
-247
lines changed

drivers/scsi/fnic/fnic.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
#define IS_FNIC_FCP_INITIATOR(fnic) (fnic->role == FNIC_ROLE_FCP_INITIATOR)
8686

8787
#define FNIC_FW_RESET_TIMEOUT 60000 /* mSec */
88+
#define FNIC_FCOE_MAX_CMD_LEN 16
8889
/* Retry supported by rport (returned by PRLI service parameters) */
8990
#define FNIC_FC_RP_FLAGS_RETRY 0x1
9091

@@ -344,6 +345,7 @@ struct fnic {
344345
int fnic_num;
345346
enum fnic_role_e role;
346347
struct fnic_iport_s iport;
348+
struct Scsi_Host *host;
347349
struct fc_lport *lport;
348350
struct fcoe_ctlr ctlr; /* FIP FCoE controller structure */
349351
struct vnic_dev_bar bar0;
@@ -464,11 +466,6 @@ struct fnic {
464466
____cacheline_aligned struct vnic_intr intr[FNIC_MSIX_INTR_MAX];
465467
};
466468

467-
static inline struct fnic *fnic_from_ctlr(struct fcoe_ctlr *fip)
468-
{
469-
return container_of(fip, struct fnic, ctlr);
470-
}
471-
472469
extern struct workqueue_struct *fnic_event_queue;
473470
extern struct workqueue_struct *fnic_fip_queue;
474471
extern const struct attribute_group *fnic_host_groups[];
@@ -500,6 +497,7 @@ int fnic_eh_host_reset_handler(struct scsi_cmnd *sc);
500497
int fnic_host_reset(struct Scsi_Host *shost);
501498
void fnic_reset(struct Scsi_Host *shost);
502499
int fnic_issue_fc_host_lip(struct Scsi_Host *shost);
500+
void fnic_get_host_port_state(struct Scsi_Host *shost);
503501
void fnic_scsi_fcpio_reset(struct fnic *fnic);
504502
int fnic_wq_copy_cmpl_handler(struct fnic *fnic, int copy_work_to_do, unsigned int cq_index);
505503
int fnic_wq_cmpl_handler(struct fnic *fnic, int);
@@ -512,7 +510,7 @@ const char *fnic_state_to_str(unsigned int state);
512510
void fnic_mq_map_queues_cpus(struct Scsi_Host *host);
513511
void fnic_log_q_error(struct fnic *fnic);
514512
void fnic_handle_link_event(struct fnic *fnic);
515-
void fnic_stats_debugfs_init(struct fnic *fnic);
513+
int fnic_stats_debugfs_init(struct fnic *fnic);
516514
void fnic_stats_debugfs_remove(struct fnic *fnic);
517515
int fnic_is_abts_pending(struct fnic *, struct scsi_cmnd *);
518516

@@ -541,6 +539,10 @@ unsigned int fnic_count_lun_ioreqs_wq(struct fnic *fnic, u32 hwq,
541539
struct scsi_device *device);
542540
unsigned int fnic_count_lun_ioreqs(struct fnic *fnic,
543541
struct scsi_device *device);
542+
void fnic_scsi_unload(struct fnic *fnic);
543+
void fnic_scsi_unload_cleanup(struct fnic *fnic);
544+
int fnic_get_debug_info(struct stats_debug_info *info,
545+
struct fnic *fnic);
544546

545547
struct fnic_scsi_iter_data {
546548
struct fnic *fnic;

drivers/scsi/fnic/fnic_attrs.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
static ssize_t fnic_show_state(struct device *dev,
1212
struct device_attribute *attr, char *buf)
1313
{
14-
struct fc_lport *lp = shost_priv(class_to_shost(dev));
15-
struct fnic *fnic = lport_priv(lp);
14+
struct fnic *fnic =
15+
*((struct fnic **) shost_priv(class_to_shost(dev)));
1616

1717
return sysfs_emit(buf, "%s\n", fnic_state_str[fnic->state]);
1818
}
@@ -26,9 +26,13 @@ static ssize_t fnic_show_drv_version(struct device *dev,
2626
static ssize_t fnic_show_link_state(struct device *dev,
2727
struct device_attribute *attr, char *buf)
2828
{
29-
struct fc_lport *lp = shost_priv(class_to_shost(dev));
29+
struct fnic *fnic =
30+
*((struct fnic **) shost_priv(class_to_shost(dev)));
3031

31-
return sysfs_emit(buf, "%s\n", (lp->link_up) ? "Link Up" : "Link Down");
32+
return sysfs_emit(buf, "%s\n",
33+
((fnic->iport.state != FNIC_IPORT_STATE_INIT) &&
34+
(fnic->iport.state != FNIC_IPORT_STATE_LINK_WAIT)) ?
35+
"Link Up" : "Link Down");
3236
}
3337

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

drivers/scsi/fnic/fnic_debugfs.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
#include <linux/vmalloc.h>
88
#include "fnic.h"
99

10+
extern int fnic_get_debug_info(struct stats_debug_info *debug_buffer,
11+
struct fnic *fnic);
12+
1013
static struct dentry *fnic_trace_debugfs_root;
1114
static struct dentry *fnic_trace_debugfs_file;
1215
static struct dentry *fnic_trace_enable;
@@ -593,6 +596,7 @@ static int fnic_stats_debugfs_open(struct inode *inode,
593596
debug->buf_size = buf_size;
594597
memset((void *)debug->debug_buffer, 0, buf_size);
595598
debug->buffer_len = fnic_get_stats_data(debug, fnic_stats);
599+
debug->buffer_len += fnic_get_debug_info(debug, fnic);
596600

597601
file->private_data = debug;
598602

@@ -673,26 +677,48 @@ static const struct file_operations fnic_reset_debugfs_fops = {
673677
* It will create file stats and reset_stats under statistics/host# directory
674678
* to log per fnic stats.
675679
*/
676-
void fnic_stats_debugfs_init(struct fnic *fnic)
680+
int fnic_stats_debugfs_init(struct fnic *fnic)
677681
{
682+
int rc = -1;
678683
char name[16];
679684

680685
snprintf(name, sizeof(name), "host%d", fnic->lport->host->host_no);
681686

687+
if (!fnic_stats_debugfs_root) {
688+
pr_debug("fnic_stats root doesn't exist\n");
689+
return rc;
690+
}
691+
682692
fnic->fnic_stats_debugfs_host = debugfs_create_dir(name,
683693
fnic_stats_debugfs_root);
684694

695+
if (!fnic->fnic_stats_debugfs_host) {
696+
pr_debug("Cannot create host directory\n");
697+
return rc;
698+
}
699+
685700
fnic->fnic_stats_debugfs_file = debugfs_create_file("stats",
686701
S_IFREG|S_IRUGO|S_IWUSR,
687702
fnic->fnic_stats_debugfs_host,
688703
fnic,
689704
&fnic_stats_debugfs_fops);
690705

706+
if (!fnic->fnic_stats_debugfs_file) {
707+
pr_debug("Cannot create host stats file\n");
708+
return rc;
709+
}
710+
691711
fnic->fnic_reset_debugfs_file = debugfs_create_file("reset_stats",
692712
S_IFREG|S_IRUGO|S_IWUSR,
693713
fnic->fnic_stats_debugfs_host,
694714
fnic,
695715
&fnic_reset_debugfs_fops);
716+
if (!fnic->fnic_reset_debugfs_file) {
717+
pr_debug("Cannot create host stats file\n");
718+
return rc;
719+
}
720+
rc = 0;
721+
return rc;
696722
}
697723

698724
/*

drivers/scsi/fnic/fnic_fcs.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,22 @@ static inline void fnic_fdls_set_fcoe_dstmac(struct fnic *fnic,
6363
memcpy(fnic->iport.fcfmac, dst_mac, 6);
6464
}
6565

66+
void fnic_get_host_port_state(struct Scsi_Host *shost)
67+
{
68+
struct fnic *fnic = *((struct fnic **) shost_priv(shost));
69+
struct fnic_iport_s *iport = &fnic->iport;
70+
unsigned long flags;
71+
72+
spin_lock_irqsave(&fnic->fnic_lock, flags);
73+
if (!fnic->link_status)
74+
fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
75+
else if (iport->state == FNIC_IPORT_STATE_READY)
76+
fc_host_port_state(shost) = FC_PORTSTATE_ONLINE;
77+
else
78+
fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE;
79+
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
80+
}
81+
6682
void fnic_fdls_link_status_change(struct fnic *fnic, int linkup)
6783
{
6884
struct fnic_iport_s *iport = &fnic->iport;

0 commit comments

Comments
 (0)