Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b1af26c

Browse files
Quinn Tranmartinkpetersen
authored andcommitted
scsi: qla2xxx: edif: Flush stale events and msgs on session down
On session down, driver will flush all stale messages and doorbell events. This prevents authentication application from having to process stale data. Link: https://lore.kernel.org/r/[email protected] Fixes: 4de067e ("scsi: qla2xxx: edif: Add N2N support for EDIF") Reviewed-by: Himanshu Madhani <[email protected]> Co-developed-by: Karunakara Merugu <[email protected]> Signed-off-by: Karunakara Merugu <[email protected]> Signed-off-by: Quinn Tran <[email protected]> Signed-off-by: Nilesh Javali <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent b492d6a commit b1af26c

File tree

3 files changed

+98
-1
lines changed

3 files changed

+98
-1
lines changed

drivers/scsi/qla2xxx/qla_edif.c

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1593,6 +1593,40 @@ qla_enode_stop(scsi_qla_host_t *vha)
15931593
spin_unlock_irqrestore(&vha->pur_cinfo.pur_lock, flags);
15941594
}
15951595

1596+
static void qla_enode_clear(scsi_qla_host_t *vha, port_id_t portid)
1597+
{
1598+
unsigned long flags;
1599+
struct enode *e, *tmp;
1600+
struct purexevent *purex;
1601+
LIST_HEAD(enode_list);
1602+
1603+
if (vha->pur_cinfo.enode_flags != ENODE_ACTIVE) {
1604+
ql_dbg(ql_dbg_edif, vha, 0x09102,
1605+
"%s enode not active\n", __func__);
1606+
return;
1607+
}
1608+
spin_lock_irqsave(&vha->pur_cinfo.pur_lock, flags);
1609+
list_for_each_entry_safe(e, tmp, &vha->pur_cinfo.head, list) {
1610+
purex = &e->u.purexinfo;
1611+
if (purex->pur_info.pur_sid.b24 == portid.b24) {
1612+
ql_dbg(ql_dbg_edif, vha, 0x911d,
1613+
"%s free ELS sid=%06x. xchg %x, nb=%xh\n",
1614+
__func__, portid.b24,
1615+
purex->pur_info.pur_rx_xchg_address,
1616+
purex->pur_info.pur_bytes_rcvd);
1617+
1618+
list_del_init(&e->list);
1619+
list_add_tail(&e->list, &enode_list);
1620+
}
1621+
}
1622+
spin_unlock_irqrestore(&vha->pur_cinfo.pur_lock, flags);
1623+
1624+
list_for_each_entry_safe(e, tmp, &enode_list, list) {
1625+
list_del_init(&e->list);
1626+
qla_enode_free(vha, e);
1627+
}
1628+
}
1629+
15961630
/*
15971631
* allocate enode struct and populate buffer
15981632
* returns: enode pointer with buffers
@@ -1792,6 +1826,57 @@ qla_edb_node_free(scsi_qla_host_t *vha, struct edb_node *node)
17921826
node->ntype = N_UNDEF;
17931827
}
17941828

1829+
static void qla_edb_clear(scsi_qla_host_t *vha, port_id_t portid)
1830+
{
1831+
unsigned long flags;
1832+
struct edb_node *e, *tmp;
1833+
port_id_t sid;
1834+
LIST_HEAD(edb_list);
1835+
1836+
if (vha->e_dbell.db_flags != EDB_ACTIVE) {
1837+
/* doorbell list not enabled */
1838+
ql_dbg(ql_dbg_edif, vha, 0x09102,
1839+
"%s doorbell not enabled\n", __func__);
1840+
return;
1841+
}
1842+
1843+
/* grab lock so list doesn't move */
1844+
spin_lock_irqsave(&vha->e_dbell.db_lock, flags);
1845+
list_for_each_entry_safe(e, tmp, &vha->e_dbell.head, list) {
1846+
switch (e->ntype) {
1847+
case VND_CMD_AUTH_STATE_NEEDED:
1848+
case VND_CMD_AUTH_STATE_SESSION_SHUTDOWN:
1849+
sid = e->u.plogi_did;
1850+
break;
1851+
case VND_CMD_AUTH_STATE_ELS_RCVD:
1852+
sid = e->u.els_sid;
1853+
break;
1854+
case VND_CMD_AUTH_STATE_SAUPDATE_COMPL:
1855+
/* app wants to see this */
1856+
continue;
1857+
default:
1858+
ql_log(ql_log_warn, vha, 0x09102,
1859+
"%s unknown node type: %x\n", __func__, e->ntype);
1860+
sid.b24 = 0;
1861+
break;
1862+
}
1863+
if (sid.b24 == portid.b24) {
1864+
ql_dbg(ql_dbg_edif, vha, 0x910f,
1865+
"%s free doorbell event : node type = %x %p\n",
1866+
__func__, e->ntype, e);
1867+
list_del_init(&e->list);
1868+
list_add_tail(&e->list, &edb_list);
1869+
}
1870+
}
1871+
spin_unlock_irqrestore(&vha->e_dbell.db_lock, flags);
1872+
1873+
list_for_each_entry_safe(e, tmp, &edb_list, list) {
1874+
qla_edb_node_free(vha, e);
1875+
list_del_init(&e->list);
1876+
kfree(e);
1877+
}
1878+
}
1879+
17951880
/* function called when app is stopping */
17961881

17971882
void
@@ -2378,7 +2463,7 @@ void qla24xx_auth_els(scsi_qla_host_t *vha, void **pkt, struct rsp_que **rsp)
23782463
ql_dbg(ql_dbg_edif, host, 0x0910c,
23792464
"%s COMPLETE purex->pur_info.pur_bytes_rcvd =%xh s:%06x -> d:%06x xchg=%xh\n",
23802465
__func__, purex->pur_info.pur_bytes_rcvd, purex->pur_info.pur_sid.b24,
2381-
purex->pur_info.pur_did.b24, p->rx_xchg_addr);
2466+
purex->pur_info.pur_did.b24, purex->pur_info.pur_rx_xchg_address);
23822467

23832468
qla_edb_eventcreate(host, VND_CMD_AUTH_STATE_ELS_RCVD, sid, 0, NULL);
23842469
}
@@ -3401,3 +3486,12 @@ void qla_edif_sess_down(struct scsi_qla_host *vha, struct fc_port *sess)
34013486
qla2x00_post_aen_work(vha, FCH_EVT_PORT_OFFLINE, sess->d_id.b24);
34023487
}
34033488
}
3489+
3490+
void qla_edif_clear_appdata(struct scsi_qla_host *vha, struct fc_port *fcport)
3491+
{
3492+
if (!(fcport->flags & FCF_FCSP_DEVICE))
3493+
return;
3494+
3495+
qla_edb_clear(vha, fcport->d_id);
3496+
qla_enode_clear(vha, fcport->d_id);
3497+
}

drivers/scsi/qla2xxx/qla_gbl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ void qlt_chk_edif_rx_sa_delete_pending(scsi_qla_host_t *vha, fc_port_t *fcport,
142142
void qla2x00_release_all_sadb(struct scsi_qla_host *vha, struct fc_port *fcport);
143143
int qla_edif_process_els(scsi_qla_host_t *vha, struct bsg_job *bsgjob);
144144
void qla_edif_sess_down(struct scsi_qla_host *vha, struct fc_port *sess);
145+
void qla_edif_clear_appdata(struct scsi_qla_host *vha,
146+
struct fc_port *fcport);
145147
const char *sc_to_str(uint16_t cmd);
146148

147149
/*

drivers/scsi/qla2xxx/qla_target.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,7 @@ void qlt_free_session_done(struct work_struct *work)
10031003
"%s bypassing release_all_sadb\n",
10041004
__func__);
10051005
}
1006+
qla_edif_clear_appdata(vha, sess);
10061007
qla_edif_sess_down(vha, sess);
10071008
}
10081009
qla2x00_mark_device_lost(vha, sess, 0);

0 commit comments

Comments
 (0)