Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: zfcp: trace FC Endpoint Security of FCP devices and connections

Trace changes in Fibre Channel Endpoint Security capabilities of FCP
devices as well as changes in Fibre Channel Endpoint Security state of
their connections to FC remote ports as FC Endpoint Security changes with
trace level 3 in HBA DBF.

A change in FC Endpoint Security capabilities of FCP devices is traced as
response to FSF command FSF_QTCB_EXCHANGE_PORT_DATA with a trace tag of
"fsfcesa" and a WWPN of ZFCP_DBF_INVALID_WWPN = 0x0000000000000000 (see
FC-FS-4 §18 "Name_Identifier Formats", NAA field).

A change in FC Endpoint Security state of connections between FCP devices
and FC remote ports is traced as response to FSF command
FSF_QTCB_OPEN_PORT_WITH_DID with a trace tag of "fsfcesp".

Example trace record of FC Endpoint Security capability change of FCP
device formatted with zfcpdbf from s390-tools:

Timestamp : ...
Area : HBA
Subarea : 00
Level : 3
Exception : -
CPU ID : ...
Caller : 0x...
Record ID : 5 ZFCP_DBF_HBA_FCES
Tag : fsfcesa FSF FC Endpoint Security adapter
Request ID : 0x...
Request status : 0x00000010
FSF cmnd : 0x0000000e FSF_QTCB_EXCHANGE_PORT_DATA
FSF sequence no: 0x...
FSF issued : ...
FSF stat : 0x00000000 FSF_GOOD
FSF stat qual : n/a
Prot stat : n/a
Prot stat qual : n/a
Port handle : 0x00000000 none (invalid)
LUN handle : n/a
WWPN : 0x0000000000000000 ZFCP_DBF_INVALID_WWPN
FCES old : 0x00000000 old FC Endpoint Security
FCES new : 0x00000007 new FC Endpoint Security

Example trace record of FC Endpoint Security change of connection to
FC remote port formatted with zfcpdbf from s390-tools:

Timestamp : ...
Area : HBA
Subarea : 00
Level : 3
Exception : -
CPU ID : ...
Caller : 0x...
Record ID : 5 ZFCP_DBF_HBA_FCES
Tag : fsfcesp FSF FC Endpoint Security port
Request ID : 0x...
Request status : 0x00000010
FSF cmnd : 0x00000005 FSF_QTCB_OPEN_PORT_WITH_DID
FSF sequence no: 0x...
FSF issued : ...
FSF stat : 0x00000000 FSF_GOOD
FSF stat qual : n/a
Prot stat : n/a
Prot stat qual : n/a
Port handle : 0x...
WWPN : 0x500507630401120c WWPN
FCES old : 0x00000000 old FC Endpoint Security
FCES new : 0x00000004 new FC Endpoint Security

Link: https://lore.kernel.org/r/20200312174505.51294-9-maier@linux.ibm.com
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Jens Remus and committed by
Martin K. Petersen
616da39e f0d26ae8

+100 -8
+43 -1
drivers/s390/scsi/zfcp_dbf.c
··· 4 4 * 5 5 * Debug traces for zfcp. 6 6 * 7 - * Copyright IBM Corp. 2002, 2018 7 + * Copyright IBM Corp. 2002, 2020 8 8 */ 9 9 10 10 #define KMSG_COMPONENT "zfcp" ··· 98 98 rec->pl_len = q_head->log_length; 99 99 zfcp_dbf_pl_write(dbf, (char *)q_pref + q_head->log_start, 100 100 rec->pl_len, "fsf_res", req->req_id); 101 + 102 + debug_event(dbf->hba, level, rec, sizeof(*rec)); 103 + spin_unlock_irqrestore(&dbf->hba_lock, flags); 104 + } 105 + 106 + /** 107 + * zfcp_dbf_hba_fsf_fces - trace event for fsf responses related to 108 + * FC Endpoint Security (FCES) 109 + * @tag: tag indicating which kind of FC Endpoint Security event has occurred 110 + * @req: request for which a response was received 111 + * @wwpn: remote port or ZFCP_DBF_INVALID_WWPN 112 + * @fc_security_old: old FC Endpoint Security of FCP device or connection 113 + * @fc_security_new: new FC Endpoint Security of FCP device or connection 114 + */ 115 + void zfcp_dbf_hba_fsf_fces(char *tag, const struct zfcp_fsf_req *req, u64 wwpn, 116 + u32 fc_security_old, u32 fc_security_new) 117 + { 118 + struct zfcp_dbf *dbf = req->adapter->dbf; 119 + struct fsf_qtcb_prefix *q_pref = &req->qtcb->prefix; 120 + struct fsf_qtcb_header *q_head = &req->qtcb->header; 121 + struct zfcp_dbf_hba *rec = &dbf->hba_buf; 122 + static int const level = 3; 123 + unsigned long flags; 124 + 125 + if (unlikely(!debug_level_enabled(dbf->hba, level))) 126 + return; 127 + 128 + spin_lock_irqsave(&dbf->hba_lock, flags); 129 + memset(rec, 0, sizeof(*rec)); 130 + 131 + memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); 132 + rec->id = ZFCP_DBF_HBA_FCES; 133 + rec->fsf_req_id = req->req_id; 134 + rec->fsf_req_status = req->status; 135 + rec->fsf_cmd = q_head->fsf_command; 136 + rec->fsf_seq_no = q_pref->req_seq_no; 137 + rec->u.fces.req_issued = req->issued; 138 + rec->u.fces.fsf_status = q_head->fsf_status; 139 + rec->u.fces.port_handle = q_head->port_handle; 140 + rec->u.fces.wwpn = wwpn; 141 + rec->u.fces.fc_security_old = fc_security_old; 142 + rec->u.fces.fc_security_new = fc_security_new; 101 143 102 144 debug_event(dbf->hba, level, rec, sizeof(*rec)); 103 145 spin_unlock_irqrestore(&dbf->hba_lock, flags);
+28 -4
drivers/s390/scsi/zfcp_dbf.h
··· 3 3 * zfcp device driver 4 4 * debug feature declarations 5 5 * 6 - * Copyright IBM Corp. 2008, 2017 6 + * Copyright IBM Corp. 2008, 2020 7 7 */ 8 8 9 9 #ifndef ZFCP_DBF_H ··· 16 16 17 17 #define ZFCP_DBF_TAG_LEN 7 18 18 19 + #define ZFCP_DBF_INVALID_WWPN 0x0000000000000000ull 19 20 #define ZFCP_DBF_INVALID_LUN 0xFFFFFFFFFFFFFFFFull 20 21 21 22 enum zfcp_dbf_pseudo_erp_act_type { ··· 159 158 } __packed; 160 159 161 160 /** 161 + * struct zfcp_dbf_hba_fces - trace record for FC Endpoint Security 162 + * @req_issued: timestamp when request was issued 163 + * @fsf_status: fsf status 164 + * @port_handle: handle for port 165 + * @wwpn: remote FC port WWPN 166 + * @fc_security_old: old FC Endpoint Security 167 + * @fc_security_new: new FC Endpoint Security 168 + * 169 + */ 170 + struct zfcp_dbf_hba_fces { 171 + u64 req_issued; 172 + u32 fsf_status; 173 + u32 port_handle; 174 + u64 wwpn; 175 + u32 fc_security_old; 176 + u32 fc_security_new; 177 + } __packed; 178 + 179 + /** 162 180 * enum zfcp_dbf_hba_id - HBA trace record identifier 163 181 * @ZFCP_DBF_HBA_RES: response trace record 164 182 * @ZFCP_DBF_HBA_USS: unsolicited status trace record 165 183 * @ZFCP_DBF_HBA_BIT: bit error trace record 166 184 * @ZFCP_DBF_HBA_BASIC: basic adapter event, only trace tag, no other data 185 + * @ZFCP_DBF_HBA_FCES: FC Endpoint Security trace record 167 186 */ 168 187 enum zfcp_dbf_hba_id { 169 188 ZFCP_DBF_HBA_RES = 1, 170 189 ZFCP_DBF_HBA_USS = 2, 171 190 ZFCP_DBF_HBA_BIT = 3, 172 191 ZFCP_DBF_HBA_BASIC = 4, 192 + ZFCP_DBF_HBA_FCES = 5, 173 193 }; 174 194 175 195 /** ··· 203 181 * @fsf_seq_no: fsf sequence number 204 182 * @pl_len: length of payload stored as zfcp_dbf_pay 205 183 * @u: record type specific data 206 - * @u.res: data for fsf responses 207 - * @u.uss: data for unsolicited status buffer 208 - * @u.be: data for bit error unsolicited status buffer 184 + * @u.res: data for fsf responses 185 + * @u.uss: data for unsolicited status buffer 186 + * @u.be: data for bit error unsolicited status buffer 187 + * @u.fces: data for FC Endpoint Security 209 188 */ 210 189 struct zfcp_dbf_hba { 211 190 u8 id; ··· 220 197 struct zfcp_dbf_hba_res res; 221 198 struct zfcp_dbf_hba_uss uss; 222 199 struct fsf_bit_error_payload be; 200 + struct zfcp_dbf_hba_fces fces; 223 201 } u; 224 202 } __packed; 225 203
+1
drivers/s390/scsi/zfcp_def.h
··· 159 159 u32 connection_features; /* host connection features */ 160 160 u32 hardware_version; /* of FCP channel */ 161 161 u32 fc_security_algorithms; /* of FCP channel */ 162 + u32 fc_security_algorithms_old; /* of FCP channel */ 162 163 u16 timer_ticks; /* time int for a tick */ 163 164 struct Scsi_Host *scsi_host; /* Pointer to mid-layer */ 164 165 struct list_head port_list; /* remote port list */
+3
drivers/s390/scsi/zfcp_ext.h
··· 44 44 extern void zfcp_dbf_rec_run_wka(char *, struct zfcp_fc_wka_port *, u64); 45 45 extern void zfcp_dbf_hba_fsf_uss(char *, struct zfcp_fsf_req *); 46 46 extern void zfcp_dbf_hba_fsf_res(char *, int, struct zfcp_fsf_req *); 47 + extern void zfcp_dbf_hba_fsf_fces(char *tag, const struct zfcp_fsf_req *req, 48 + u64 wwpn, u32 fc_security_old, 49 + u32 fc_security_new); 47 50 extern void zfcp_dbf_hba_bit_err(char *, struct zfcp_fsf_req *); 48 51 extern void zfcp_dbf_hba_def_err(struct zfcp_adapter *, u64, u16, void **); 49 52 extern void zfcp_dbf_hba_basic(char *, struct zfcp_adapter *);
+25 -3
drivers/s390/scsi/zfcp_fsf.c
··· 741 741 return len; 742 742 } 743 743 744 + static void zfcp_fsf_dbf_adapter_fc_security(struct zfcp_adapter *adapter, 745 + struct zfcp_fsf_req *req) 746 + { 747 + if (adapter->fc_security_algorithms == 748 + adapter->fc_security_algorithms_old) { 749 + /* no change, no trace */ 750 + return; 751 + } 752 + 753 + zfcp_dbf_hba_fsf_fces("fsfcesa", req, ZFCP_DBF_INVALID_WWPN, 754 + adapter->fc_security_algorithms_old, 755 + adapter->fc_security_algorithms); 756 + 757 + adapter->fc_security_algorithms_old = adapter->fc_security_algorithms; 758 + } 759 + 744 760 static void zfcp_fsf_exchange_port_evaluate(struct zfcp_fsf_req *req) 745 761 { 746 762 struct zfcp_adapter *adapter = req->adapter; ··· 779 763 bottom->fc_security_algorithms; 780 764 else 781 765 adapter->fc_security_algorithms = 0; 766 + zfcp_fsf_dbf_adapter_fc_security(adapter, req); 782 767 } 783 768 784 769 static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *req) ··· 1596 1579 return retval; 1597 1580 } 1598 1581 1599 - static void zfcp_fsf_log_port_fc_security(struct zfcp_port *port) 1582 + static void zfcp_fsf_log_port_fc_security(struct zfcp_port *port, 1583 + struct zfcp_fsf_req *req) 1600 1584 { 1601 1585 char mnemonic_old[ZFCP_FSF_MAX_FC_SECURITY_MNEMONIC_LENGTH]; 1602 1586 char mnemonic_new[ZFCP_FSF_MAX_FC_SECURITY_MNEMONIC_LENGTH]; 1603 1587 1604 1588 if (port->connection_info == port->connection_info_old) { 1605 - /* no change, no log */ 1589 + /* no change, no log nor trace */ 1606 1590 return; 1607 1591 } 1592 + 1593 + zfcp_dbf_hba_fsf_fces("fsfcesp", req, port->wwpn, 1594 + port->connection_info_old, 1595 + port->connection_info); 1608 1596 1609 1597 zfcp_fsf_scnprint_fc_security(mnemonic_old, sizeof(mnemonic_old), 1610 1598 port->connection_info_old, ··· 1685 1663 port->connection_info = bottom->connection_info; 1686 1664 else 1687 1665 port->connection_info = 0; 1688 - zfcp_fsf_log_port_fc_security(port); 1666 + zfcp_fsf_log_port_fc_security(port, req); 1689 1667 atomic_or(ZFCP_STATUS_COMMON_OPEN | 1690 1668 ZFCP_STATUS_PORT_PHYS_OPEN, &port->status); 1691 1669 atomic_andnot(ZFCP_STATUS_COMMON_ACCESS_BOXED,