Skip to content

Commit e63d2ea

Browse files
Merge patch series "qla2xxx driver enhancements"
Nilesh Javali <[email protected]> says: Please apply the qla2xxx driver enhancements to the SCSI tree at your earliest convenience. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
2 parents 8fe66ba + f7d1ba3 commit e63d2ea

18 files changed

+529
-671
lines changed

drivers/scsi/qla2xxx/qla_attr.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,7 +2732,7 @@ qla2x00_dev_loss_tmo_callbk(struct fc_rport *rport)
27322732
spin_lock_irqsave(host->host_lock, flags);
27332733
/* Confirm port has not reappeared before clearing pointers. */
27342734
if (rport->port_state != FC_PORTSTATE_ONLINE) {
2735-
fcport->rport = fcport->drport = NULL;
2735+
fcport->rport = NULL;
27362736
*((fc_port_t **)rport->dd_data) = NULL;
27372737
}
27382738
spin_unlock_irqrestore(host->host_lock, flags);
@@ -3171,8 +3171,7 @@ qla24xx_vport_delete(struct fc_vport *fc_vport)
31713171

31723172
set_bit(VPORT_DELETE, &vha->dpc_flags);
31733173

3174-
while (test_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags) ||
3175-
test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags))
3174+
while (test_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags))
31763175
msleep(1000);
31773176

31783177

drivers/scsi/qla2xxx/qla_def.h

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,13 @@ struct els_reject {
384384
struct req_que;
385385
struct qla_tgt_sess;
386386

387+
struct qla_buf_dsc {
388+
u16 tag;
389+
#define TAG_FREED 0xffff
390+
void *buf;
391+
dma_addr_t buf_dma;
392+
};
393+
387394
/*
388395
* SCSI Request Block
389396
*/
@@ -392,14 +399,16 @@ struct srb_cmd {
392399
uint32_t request_sense_length;
393400
uint32_t fw_sense_length;
394401
uint8_t *request_sense_ptr;
395-
struct ct6_dsd *ct6_ctx;
396402
struct crc_context *crc_ctx;
403+
struct ct6_dsd ct6_ctx;
404+
struct qla_buf_dsc buf_dsc;
397405
};
398406

399407
/*
400408
* SRB flag definitions
401409
*/
402410
#define SRB_DMA_VALID BIT_0 /* Command sent to ISP */
411+
#define SRB_GOT_BUF BIT_1
403412
#define SRB_FCP_CMND_DMA_VALID BIT_12 /* DIF: DSD List valid */
404413
#define SRB_CRC_CTX_DMA_VALID BIT_2 /* DIF: context DMA valid */
405414
#define SRB_CRC_PROT_DMA_VALID BIT_4 /* DIF: prot DMA valid */
@@ -2485,7 +2494,6 @@ struct ct_sns_desc {
24852494

24862495
enum discovery_state {
24872496
DSC_DELETED,
2488-
DSC_GNN_ID,
24892497
DSC_GNL,
24902498
DSC_LOGIN_PEND,
24912499
DSC_LOGIN_FAILED,
@@ -2596,7 +2604,7 @@ typedef struct fc_port {
25962604

25972605
int login_retry;
25982606

2599-
struct fc_rport *rport, *drport;
2607+
struct fc_rport *rport;
26002608
u32 supported_classes;
26012609

26022610
uint8_t fc4_type;
@@ -2699,7 +2707,6 @@ extern const char *const port_state_str[5];
26992707

27002708
static const char *const port_dstate_str[] = {
27012709
[DSC_DELETED] = "DELETED",
2702-
[DSC_GNN_ID] = "GNN_ID",
27032710
[DSC_GNL] = "GNL",
27042711
[DSC_LOGIN_PEND] = "LOGIN_PEND",
27052712
[DSC_LOGIN_FAILED] = "LOGIN_FAILED",
@@ -3462,6 +3469,7 @@ struct qla_msix_entry {
34623469
int have_irq;
34633470
int in_use;
34643471
uint32_t vector;
3472+
uint32_t vector_base0;
34653473
uint16_t entry;
34663474
char name[30];
34673475
void *handle;
@@ -3479,7 +3487,6 @@ enum qla_work_type {
34793487
QLA_EVT_ASYNC_ADISC,
34803488
QLA_EVT_UEVENT,
34813489
QLA_EVT_AENFX,
3482-
QLA_EVT_GPNID,
34833490
QLA_EVT_UNMAP,
34843491
QLA_EVT_NEW_SESS,
34853492
QLA_EVT_GPDB,
@@ -3493,7 +3500,6 @@ enum qla_work_type {
34933500
QLA_EVT_GPNFT,
34943501
QLA_EVT_GPNFT_DONE,
34953502
QLA_EVT_GNNFT_DONE,
3496-
QLA_EVT_GNNID,
34973503
QLA_EVT_GFPNID,
34983504
QLA_EVT_SP_RETRY,
34993505
QLA_EVT_IIDMA,
@@ -3534,17 +3540,14 @@ struct qla_work_evt {
35343540
struct {
35353541
srb_t *sp;
35363542
} iosb;
3537-
struct {
3538-
port_id_t id;
3539-
} gpnid;
35403543
struct {
35413544
port_id_t id;
35423545
u8 port_name[8];
35433546
u8 node_name[8];
35443547
void *pla;
35453548
u8 fc4_type;
35463549
} new_sess;
3547-
struct { /*Get PDB, Get Speed, update fcport, gnl, gidpn */
3550+
struct { /*Get PDB, Get Speed, update fcport, gnl */
35483551
fc_port_t *fcport;
35493552
u8 opt;
35503553
} fcport;
@@ -3729,6 +3732,19 @@ struct qla_fw_resources {
37293732

37303733
#define QLA_IOCB_PCT_LIMIT 95
37313734

3735+
struct qla_buf_pool {
3736+
u16 num_bufs;
3737+
u16 num_active;
3738+
u16 max_used;
3739+
u16 num_alloc;
3740+
u16 prev_max;
3741+
u16 pad;
3742+
uint32_t take_snapshot:1;
3743+
unsigned long *buf_map;
3744+
void **buf_array;
3745+
dma_addr_t *dma_array;
3746+
};
3747+
37323748
/*Queue pair data structure */
37333749
struct qla_qpair {
37343750
spinlock_t qp_lock;
@@ -3782,6 +3798,7 @@ struct qla_qpair {
37823798
struct qla_tgt_counters tgt_counters;
37833799
uint16_t cpuid;
37843800
struct qla_fw_resources fwres ____cacheline_aligned;
3801+
struct qla_buf_pool buf_pool;
37853802
u32 cmd_cnt;
37863803
u32 cmd_completion_cnt;
37873804
u32 prev_completion_cnt;
@@ -3942,7 +3959,6 @@ struct qlt_hw_data {
39423959
__le32 __iomem *atio_q_out;
39433960

39443961
const struct qla_tgt_func_tmpl *tgt_ops;
3945-
struct qla_tgt_vp_map *tgt_vp_map;
39463962

39473963
int saved_set;
39483964
__le16 saved_exchange_count;
@@ -4110,6 +4126,7 @@ struct qla_hw_data {
41104126
struct req_que **req_q_map;
41114127
struct rsp_que **rsp_q_map;
41124128
struct qla_qpair **queue_pair_map;
4129+
struct qla_qpair **qp_cpu_map;
41134130
unsigned long req_qid_map[(QLA_MAX_QUEUES / 8) / sizeof(unsigned long)];
41144131
unsigned long rsp_qid_map[(QLA_MAX_QUEUES / 8) / sizeof(unsigned long)];
41154132
unsigned long qpair_qid_map[(QLA_MAX_QUEUES / 8)
@@ -4766,6 +4783,7 @@ struct qla_hw_data {
47664783
spinlock_t sadb_lock; /* protects list */
47674784
struct els_reject elsrej;
47684785
u8 edif_post_stop_cnt_down;
4786+
struct qla_vp_map *vp_map;
47694787
};
47704788

47714789
#define RX_ELS_SIZE (roundup(sizeof(struct enode) + ELS_MAX_PAYLOAD, SMP_CACHE_BYTES))
@@ -4861,6 +4879,7 @@ typedef struct scsi_qla_host {
48614879
#define LOOP_READY 5
48624880
#define LOOP_DEAD 6
48634881

4882+
unsigned long buf_expired;
48644883
unsigned long relogin_jif;
48654884
unsigned long dpc_flags;
48664885
#define RESET_MARKER_NEEDED 0 /* Send marker to ISP. */
@@ -4876,7 +4895,6 @@ typedef struct scsi_qla_host {
48764895
#define ISP_ABORT_RETRY 10 /* ISP aborted. */
48774896
#define BEACON_BLINK_NEEDED 11
48784897
#define REGISTER_FDMI_NEEDED 12
4879-
#define FCPORT_UPDATE_NEEDED 13
48804898
#define VP_DPC_NEEDED 14 /* wake up for VP dpc handling */
48814899
#define UNLOADING 15
48824900
#define NPIV_CONFIG_NEEDED 16
@@ -5026,7 +5044,6 @@ typedef struct scsi_qla_host {
50265044
uint8_t n2n_port_name[WWN_SIZE];
50275045
uint16_t n2n_id;
50285046
__le16 dport_data[4];
5029-
struct list_head gpnid_list;
50305047
struct fab_scan scan;
50315048
uint8_t scm_fabric_connection_flags;
50325049

@@ -5068,7 +5085,7 @@ struct qla27xx_image_status {
50685085
#define SET_AL_PA 2
50695086
#define RESET_VP_IDX 3
50705087
#define RESET_AL_PA 4
5071-
struct qla_tgt_vp_map {
5088+
struct qla_vp_map {
50725089
uint8_t idx;
50735090
scsi_qla_host_t *vha;
50745091
};

drivers/scsi/qla2xxx/qla_edif.c

Lines changed: 59 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,49 @@ void qla2x00_release_all_sadb(struct scsi_qla_host *vha, struct fc_port *fcport)
479479
spin_unlock_irqrestore(&ha->sadb_lock, flags);
480480
}
481481

482+
/**
483+
* qla_delete_n2n_sess_and_wait: search for N2N session, tear it down and
484+
* wait for tear down to complete. In N2N topology, there is only one
485+
* session being active in tracking the remote device.
486+
* @vha: host adapter pointer
487+
* return code: 0 - found the session and completed the tear down.
488+
* 1 - timeout occurred. Caller to use link bounce to reset.
489+
*/
490+
static int qla_delete_n2n_sess_and_wait(scsi_qla_host_t *vha)
491+
{
492+
struct fc_port *fcport;
493+
int rc = -EIO;
494+
ulong expire = jiffies + 23 * HZ;
495+
496+
if (!N2N_TOPO(vha->hw))
497+
return 0;
498+
499+
fcport = NULL;
500+
list_for_each_entry(fcport, &vha->vp_fcports, list) {
501+
if (!fcport->n2n_flag)
502+
continue;
503+
504+
ql_dbg(ql_dbg_disc, fcport->vha, 0x2016,
505+
"%s reset sess at app start \n", __func__);
506+
507+
qla_edif_sa_ctl_init(vha, fcport);
508+
qlt_schedule_sess_for_deletion(fcport);
509+
510+
while (time_before_eq(jiffies, expire)) {
511+
if (fcport->disc_state != DSC_DELETE_PEND) {
512+
rc = 0;
513+
break;
514+
}
515+
msleep(1);
516+
}
517+
518+
set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
519+
break;
520+
}
521+
522+
return rc;
523+
}
524+
482525
/**
483526
* qla_edif_app_start: application has announce its present
484527
* @vha: host adapter pointer
@@ -518,18 +561,17 @@ qla_edif_app_start(scsi_qla_host_t *vha, struct bsg_job *bsg_job)
518561
fcport->n2n_link_reset_cnt = 0;
519562

520563
if (vha->hw->flags.n2n_fw_acc_sec) {
521-
list_for_each_entry_safe(fcport, tf, &vha->vp_fcports, list)
522-
qla_edif_sa_ctl_init(vha, fcport);
523-
564+
bool link_bounce = false;
524565
/*
525566
* While authentication app was not running, remote device
526567
* could still try to login with this local port. Let's
527-
* clear the state and try again.
568+
* reset the session, reconnect and re-authenticate.
528569
*/
529-
qla2x00_wait_for_sess_deletion(vha);
570+
if (qla_delete_n2n_sess_and_wait(vha))
571+
link_bounce = true;
530572

531-
/* bounce the link to get the other guy to relogin */
532-
if (!vha->hw->flags.n2n_bigger) {
573+
/* bounce the link to start login */
574+
if (!vha->hw->flags.n2n_bigger || link_bounce) {
533575
set_bit(N2N_LINK_RESET, &vha->dpc_flags);
534576
qla2xxx_wake_dpc(vha);
535577
}
@@ -925,7 +967,9 @@ qla_edif_app_getfcinfo(scsi_qla_host_t *vha, struct bsg_job *bsg_job)
925967
if (!(fcport->flags & FCF_FCSP_DEVICE))
926968
continue;
927969

928-
tdid = app_req.remote_pid;
970+
tdid.b.domain = app_req.remote_pid.domain;
971+
tdid.b.area = app_req.remote_pid.area;
972+
tdid.b.al_pa = app_req.remote_pid.al_pa;
929973

930974
ql_dbg(ql_dbg_edif, vha, 0x2058,
931975
"APP request entry - portid=%06x.\n", tdid.b24);
@@ -3007,26 +3051,16 @@ qla28xx_start_scsi_edif(srb_t *sp)
30073051
goto queuing_error;
30083052
}
30093053

3010-
ctx = sp->u.scmd.ct6_ctx =
3011-
mempool_alloc(ha->ctx_mempool, GFP_ATOMIC);
3012-
if (!ctx) {
3013-
ql_log(ql_log_fatal, vha, 0x3010,
3014-
"Failed to allocate ctx for cmd=%p.\n", cmd);
3015-
goto queuing_error;
3016-
}
3017-
3018-
memset(ctx, 0, sizeof(struct ct6_dsd));
3019-
ctx->fcp_cmnd = dma_pool_zalloc(ha->fcp_cmnd_dma_pool,
3020-
GFP_ATOMIC, &ctx->fcp_cmnd_dma);
3021-
if (!ctx->fcp_cmnd) {
3054+
if (qla_get_buf(vha, sp->qpair, &sp->u.scmd.buf_dsc)) {
30223055
ql_log(ql_log_fatal, vha, 0x3011,
3023-
"Failed to allocate fcp_cmnd for cmd=%p.\n", cmd);
3056+
"Failed to allocate buf for fcp_cmnd for cmd=%p.\n", cmd);
30243057
goto queuing_error;
30253058
}
30263059

3027-
/* Initialize the DSD list and dma handle */
3028-
INIT_LIST_HEAD(&ctx->dsd_list);
3029-
ctx->dsd_use_cnt = 0;
3060+
sp->flags |= SRB_GOT_BUF;
3061+
ctx = &sp->u.scmd.ct6_ctx;
3062+
ctx->fcp_cmnd = sp->u.scmd.buf_dsc.buf;
3063+
ctx->fcp_cmnd_dma = sp->u.scmd.buf_dsc.buf_dma;
30303064

30313065
if (cmd->cmd_len > 16) {
30323066
additional_cdb_len = cmd->cmd_len - 16;
@@ -3145,7 +3179,6 @@ qla28xx_start_scsi_edif(srb_t *sp)
31453179
cmd_pkt->fcp_cmnd_dseg_len = cpu_to_le16(ctx->fcp_cmnd_len);
31463180
put_unaligned_le64(ctx->fcp_cmnd_dma, &cmd_pkt->fcp_cmnd_dseg_address);
31473181

3148-
sp->flags |= SRB_FCP_CMND_DMA_VALID;
31493182
cmd_pkt->byte_count = cpu_to_le32((uint32_t)scsi_bufflen(cmd));
31503183
/* Set total data segment count. */
31513184
cmd_pkt->entry_count = (uint8_t)req_cnt;
@@ -3177,15 +3210,11 @@ qla28xx_start_scsi_edif(srb_t *sp)
31773210
return QLA_SUCCESS;
31783211

31793212
queuing_error_fcp_cmnd:
3180-
dma_pool_free(ha->fcp_cmnd_dma_pool, ctx->fcp_cmnd, ctx->fcp_cmnd_dma);
31813213
queuing_error:
31823214
if (tot_dsds)
31833215
scsi_dma_unmap(cmd);
31843216

3185-
if (sp->u.scmd.ct6_ctx) {
3186-
mempool_free(sp->u.scmd.ct6_ctx, ha->ctx_mempool);
3187-
sp->u.scmd.ct6_ctx = NULL;
3188-
}
3217+
qla_put_buf(sp->qpair, &sp->u.scmd.buf_dsc);
31893218
qla_put_fw_resources(sp->qpair, &sp->iores);
31903219
spin_unlock_irqrestore(lock, flags);
31913220

drivers/scsi/qla2xxx/qla_edif.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,6 @@ struct enode {
145145
(qla_ini_mode_enabled(_s->vha) && (_s->disc_state == DSC_DELETE_PEND || \
146146
_s->disc_state == DSC_DELETED))
147147

148+
#define EDIF_CAP(_ha) (ql2xsecenable && IS_QLA28XX(_ha))
149+
148150
#endif /* __QLA_EDIF_H */

drivers/scsi/qla2xxx/qla_edif_bsg.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,20 @@ struct app_plogi_reply {
8989
struct app_pinfo_req {
9090
struct app_id app_info;
9191
uint8_t num_ports;
92-
port_id_t remote_pid;
92+
struct {
93+
#ifdef __BIG_ENDIAN
94+
uint8_t domain;
95+
uint8_t area;
96+
uint8_t al_pa;
97+
#elif defined(__LITTLE_ENDIAN)
98+
uint8_t al_pa;
99+
uint8_t area;
100+
uint8_t domain;
101+
#else
102+
#error "__BIG_ENDIAN or __LITTLE_ENDIAN must be defined!"
103+
#endif
104+
uint8_t rsvd_1;
105+
} remote_pid;
93106
uint8_t version;
94107
uint8_t pad[VND_CMD_PAD_SIZE];
95108
uint8_t reserved[VND_CMD_APP_RESERVED_SIZE];

0 commit comments

Comments
 (0)