hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/s390/scsi/zfcp_fsf.c
....@@ -4,13 +4,15 @@
44 *
55 * Implementation of FSF commands.
66 *
7
- * Copyright IBM Corp. 2002, 2018
7
+ * Copyright IBM Corp. 2002, 2020
88 */
99
1010 #define KMSG_COMPONENT "zfcp"
1111 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
1212
1313 #include <linux/blktrace_api.h>
14
+#include <linux/jiffies.h>
15
+#include <linux/types.h>
1416 #include <linux/slab.h>
1517 #include <scsi/fc/fc_els.h>
1618 #include "zfcp_ext.h"
....@@ -18,6 +20,12 @@
1820 #include "zfcp_dbf.h"
1921 #include "zfcp_qdio.h"
2022 #include "zfcp_reqlist.h"
23
+#include "zfcp_diag.h"
24
+
25
+/* timeout for FSF requests sent during scsi_eh: abort or FCP TMF */
26
+#define ZFCP_FSF_SCSI_ER_TIMEOUT (10*HZ)
27
+/* timeout for: exchange config/port data outside ERP, or open/close WKA port */
28
+#define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ)
2129
2230 struct kmem_cache *zfcp_fsf_qtcb_cache;
2331
....@@ -79,18 +87,18 @@
7987
8088 /**
8189 * zfcp_fsf_req_free - free memory used by fsf request
82
- * @fsf_req: pointer to struct zfcp_fsf_req
90
+ * @req: pointer to struct zfcp_fsf_req
8391 */
8492 void zfcp_fsf_req_free(struct zfcp_fsf_req *req)
8593 {
8694 if (likely(req->pool)) {
87
- if (likely(req->qtcb))
95
+ if (likely(!zfcp_fsf_req_is_status_read_buffer(req)))
8896 mempool_free(req->qtcb, req->adapter->pool.qtcb_pool);
8997 mempool_free(req, req->pool);
9098 return;
9199 }
92100
93
- if (likely(req->qtcb))
101
+ if (likely(!zfcp_fsf_req_is_status_read_buffer(req)))
94102 kmem_cache_free(zfcp_fsf_qtcb_cache, req->qtcb);
95103 kfree(req);
96104 }
....@@ -112,6 +120,27 @@
112120 read_unlock_irqrestore(&adapter->port_list_lock, flags);
113121 }
114122
123
+void zfcp_fsf_fc_host_link_down(struct zfcp_adapter *adapter)
124
+{
125
+ struct Scsi_Host *shost = adapter->scsi_host;
126
+
127
+ adapter->hydra_version = 0;
128
+ adapter->peer_wwpn = 0;
129
+ adapter->peer_wwnn = 0;
130
+ adapter->peer_d_id = 0;
131
+
132
+ /* if there is no shost yet, we have nothing to zero-out */
133
+ if (shost == NULL)
134
+ return;
135
+
136
+ fc_host_port_id(shost) = 0;
137
+ fc_host_fabric_name(shost) = 0;
138
+ fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
139
+ fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
140
+ snprintf(fc_host_model(shost), FC_SYMBOLIC_NAME_SIZE, "0x%04x", 0);
141
+ memset(fc_host_active_fc4s(shost), 0, FC_FC4_LIST_SIZE);
142
+}
143
+
115144 static void zfcp_fsf_link_down_info_eval(struct zfcp_fsf_req *req,
116145 struct fsf_link_down_info *link_down)
117146 {
....@@ -123,6 +152,8 @@
123152 atomic_or(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, &adapter->status);
124153
125154 zfcp_scsi_schedule_rports_block(adapter);
155
+
156
+ zfcp_fsf_fc_host_link_down(adapter);
126157
127158 if (!link_down)
128159 goto out;
....@@ -389,16 +420,21 @@
389420
390421 /**
391422 * zfcp_fsf_req_complete - process completion of a FSF request
392
- * @fsf_req: The FSF request that has been completed.
423
+ * @req: The FSF request that has been completed.
393424 *
394425 * When a request has been completed either from the FCP adapter,
395426 * or it has been dismissed due to a queue shutdown, this function
396427 * is called to process the completion status and trigger further
397428 * events related to the FSF request.
429
+ * Caller must ensure that the request has been removed from
430
+ * adapter->req_list, to protect against concurrent modification
431
+ * by zfcp_erp_strategy_check_fsfreq().
398432 */
399433 static void zfcp_fsf_req_complete(struct zfcp_fsf_req *req)
400434 {
401
- if (unlikely(req->fsf_command == FSF_QTCB_UNSOLICITED_STATUS)) {
435
+ struct zfcp_erp_action *erp_action;
436
+
437
+ if (unlikely(zfcp_fsf_req_is_status_read_buffer(req))) {
402438 zfcp_fsf_status_read_handler(req);
403439 return;
404440 }
....@@ -408,8 +444,9 @@
408444 zfcp_fsf_fsfstatus_eval(req);
409445 req->handler(req);
410446
411
- if (req->erp_action)
412
- zfcp_erp_notify(req->erp_action, 0);
447
+ erp_action = req->erp_action;
448
+ if (erp_action)
449
+ zfcp_erp_notify(erp_action, 0);
413450
414451 if (likely(req->status & ZFCP_STATUS_FSFREQ_CLEANUP))
415452 zfcp_fsf_req_free(req);
....@@ -452,7 +489,7 @@
452489 #define ZFCP_FSF_PORTSPEED_128GBIT (1 << 8)
453490 #define ZFCP_FSF_PORTSPEED_NOT_NEGOTIATED (1 << 15)
454491
455
-static u32 zfcp_fsf_convert_portspeed(u32 fsf_speed)
492
+u32 zfcp_fsf_convert_portspeed(u32 fsf_speed)
456493 {
457494 u32 fdmi_speed = 0;
458495 if (fsf_speed & ZFCP_FSF_PORTSPEED_1GBIT)
....@@ -482,39 +519,23 @@
482519 {
483520 struct fsf_qtcb_bottom_config *bottom = &req->qtcb->bottom.config;
484521 struct zfcp_adapter *adapter = req->adapter;
485
- struct Scsi_Host *shost = adapter->scsi_host;
486
- struct fc_els_flogi *nsp, *plogi;
522
+ struct fc_els_flogi *plogi;
487523
488524 /* adjust pointers for missing command code */
489
- nsp = (struct fc_els_flogi *) ((u8 *)&bottom->nport_serv_param
490
- - sizeof(u32));
491525 plogi = (struct fc_els_flogi *) ((u8 *)&bottom->plogi_payload
492526 - sizeof(u32));
493527
494528 if (req->data)
495529 memcpy(req->data, bottom, sizeof(*bottom));
496530
497
- fc_host_port_name(shost) = be64_to_cpu(nsp->fl_wwpn);
498
- fc_host_node_name(shost) = be64_to_cpu(nsp->fl_wwnn);
499
- fc_host_supported_classes(shost) = FC_COS_CLASS2 | FC_COS_CLASS3;
500
-
501531 adapter->timer_ticks = bottom->timer_interval & ZFCP_FSF_TIMER_INT_MASK;
502532 adapter->stat_read_buf_num = max(bottom->status_read_buf_num,
503533 (u16)FSF_STATUS_READS_RECOM);
504
-
505
- if (fc_host_permanent_port_name(shost) == -1)
506
- fc_host_permanent_port_name(shost) = fc_host_port_name(shost);
507
-
508
- zfcp_scsi_set_prot(adapter);
509534
510535 /* no error return above here, otherwise must fix call chains */
511536 /* do not evaluate invalid fields */
512537 if (req->qtcb->header.fsf_status == FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE)
513538 return 0;
514
-
515
- fc_host_port_id(shost) = ntoh24(bottom->s_id);
516
- fc_host_speed(shost) =
517
- zfcp_fsf_convert_portspeed(bottom->fc_link_speed);
518539
519540 adapter->hydra_version = bottom->adapter_type;
520541
....@@ -523,17 +544,10 @@
523544 adapter->peer_d_id = ntoh24(bottom->peer_d_id);
524545 adapter->peer_wwpn = be64_to_cpu(plogi->fl_wwpn);
525546 adapter->peer_wwnn = be64_to_cpu(plogi->fl_wwnn);
526
- fc_host_port_type(shost) = FC_PORTTYPE_PTP;
527547 break;
528548 case FSF_TOPO_FABRIC:
529
- if (bottom->connection_features & FSF_FEATURE_NPIV_MODE)
530
- fc_host_port_type(shost) = FC_PORTTYPE_NPIV;
531
- else
532
- fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
533549 break;
534550 case FSF_TOPO_AL:
535
- fc_host_port_type(shost) = FC_PORTTYPE_NLPORT;
536
- /* fall through */
537551 default:
538552 dev_err(&adapter->ccw_device->dev,
539553 "Unknown or unsupported arbitrated loop "
....@@ -548,9 +562,10 @@
548562 static void zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *req)
549563 {
550564 struct zfcp_adapter *adapter = req->adapter;
565
+ struct zfcp_diag_header *const diag_hdr =
566
+ &adapter->diagnostics->config_data.header;
551567 struct fsf_qtcb *qtcb = req->qtcb;
552568 struct fsf_qtcb_bottom_config *bottom = &qtcb->bottom.config;
553
- struct Scsi_Host *shost = adapter->scsi_host;
554569
555570 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
556571 return;
....@@ -564,6 +579,13 @@
564579
565580 switch (qtcb->header.fsf_status) {
566581 case FSF_GOOD:
582
+ /*
583
+ * usually we wait with an update till the cache is too old,
584
+ * but because we have the data available, update it anyway
585
+ */
586
+ zfcp_diag_update_xdata(diag_hdr, bottom, false);
587
+
588
+ zfcp_scsi_shost_update_config_data(adapter, bottom, false);
567589 if (zfcp_fsf_exchange_config_evaluate(req))
568590 return;
569591
....@@ -579,12 +601,8 @@
579601 &adapter->status);
580602 break;
581603 case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE:
582
- fc_host_node_name(shost) = 0;
583
- fc_host_port_name(shost) = 0;
584
- fc_host_port_id(shost) = 0;
585
- fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
586
- fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
587
- adapter->hydra_version = 0;
604
+ zfcp_diag_update_xdata(diag_hdr, bottom, true);
605
+ req->status |= ZFCP_STATUS_FSFREQ_XDATAINCOMPLETE;
588606
589607 /* avoids adapter shutdown to be able to recognize
590608 * events such as LINK UP */
....@@ -592,6 +610,8 @@
592610 &adapter->status);
593611 zfcp_fsf_link_down_info_eval(req,
594612 &qtcb->header.fsf_status_qual.link_down_info);
613
+
614
+ zfcp_scsi_shost_update_config_data(adapter, bottom, true);
595615 if (zfcp_fsf_exchange_config_evaluate(req))
596616 return;
597617 break;
....@@ -600,13 +620,8 @@
600620 return;
601621 }
602622
603
- if (adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT) {
623
+ if (adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT)
604624 adapter->hardware_version = bottom->hardware_version;
605
- memcpy(fc_host_serial_number(shost), bottom->serial_number,
606
- min(FC_SERIAL_NUMBER_SIZE, 17));
607
- EBCASC(fc_host_serial_number(shost),
608
- min(FC_SERIAL_NUMBER_SIZE, 17));
609
- }
610625
611626 if (FSF_QTCB_CURRENT_VERSION < bottom->low_qtcb_version) {
612627 dev_err(&adapter->ccw_device->dev,
....@@ -623,43 +638,145 @@
623638 }
624639 }
625640
641
+/*
642
+ * Mapping of FC Endpoint Security flag masks to mnemonics
643
+ *
644
+ * NOTE: Update macro ZFCP_FSF_MAX_FC_SECURITY_MNEMONIC_LENGTH when making any
645
+ * changes.
646
+ */
647
+static const struct {
648
+ u32 mask;
649
+ char *name;
650
+} zfcp_fsf_fc_security_mnemonics[] = {
651
+ { FSF_FC_SECURITY_AUTH, "Authentication" },
652
+ { FSF_FC_SECURITY_ENC_FCSP2 |
653
+ FSF_FC_SECURITY_ENC_ERAS, "Encryption" },
654
+};
655
+
656
+/* maximum strlen(zfcp_fsf_fc_security_mnemonics[...].name) + 1 */
657
+#define ZFCP_FSF_MAX_FC_SECURITY_MNEMONIC_LENGTH 15
658
+
659
+/**
660
+ * zfcp_fsf_scnprint_fc_security() - translate FC Endpoint Security flags into
661
+ * mnemonics and place in a buffer
662
+ * @buf : the buffer to place the translated FC Endpoint Security flag(s)
663
+ * into
664
+ * @size : the size of the buffer, including the trailing null space
665
+ * @fc_security: one or more FC Endpoint Security flags, or zero
666
+ * @fmt : specifies whether a list or a single item is to be put into the
667
+ * buffer
668
+ *
669
+ * The Fibre Channel (FC) Endpoint Security flags are translated into mnemonics.
670
+ * If the FC Endpoint Security flags are zero "none" is placed into the buffer.
671
+ *
672
+ * With ZFCP_FSF_PRINT_FMT_LIST the mnemonics are placed as a list separated by
673
+ * a comma followed by a space into the buffer. If one or more FC Endpoint
674
+ * Security flags cannot be translated into a mnemonic, as they are undefined
675
+ * in zfcp_fsf_fc_security_mnemonics, their bitwise ORed value in hexadecimal
676
+ * representation is placed into the buffer.
677
+ *
678
+ * With ZFCP_FSF_PRINT_FMT_SINGLEITEM only one single mnemonic is placed into
679
+ * the buffer. If the FC Endpoint Security flag cannot be translated, as it is
680
+ * undefined in zfcp_fsf_fc_security_mnemonics, its value in hexadecimal
681
+ * representation is placed into the buffer. If more than one FC Endpoint
682
+ * Security flag was specified, their value in hexadecimal representation is
683
+ * placed into the buffer. The macro ZFCP_FSF_MAX_FC_SECURITY_MNEMONIC_LENGTH
684
+ * can be used to define a buffer that is large enough to hold one mnemonic.
685
+ *
686
+ * Return: The number of characters written into buf not including the trailing
687
+ * '\0'. If size is == 0 the function returns 0.
688
+ */
689
+ssize_t zfcp_fsf_scnprint_fc_security(char *buf, size_t size, u32 fc_security,
690
+ enum zfcp_fsf_print_fmt fmt)
691
+{
692
+ const char *prefix = "";
693
+ ssize_t len = 0;
694
+ int i;
695
+
696
+ if (fc_security == 0)
697
+ return scnprintf(buf, size, "none");
698
+ if (fmt == ZFCP_FSF_PRINT_FMT_SINGLEITEM && hweight32(fc_security) != 1)
699
+ return scnprintf(buf, size, "0x%08x", fc_security);
700
+
701
+ for (i = 0; i < ARRAY_SIZE(zfcp_fsf_fc_security_mnemonics); i++) {
702
+ if (!(fc_security & zfcp_fsf_fc_security_mnemonics[i].mask))
703
+ continue;
704
+
705
+ len += scnprintf(buf + len, size - len, "%s%s", prefix,
706
+ zfcp_fsf_fc_security_mnemonics[i].name);
707
+ prefix = ", ";
708
+ fc_security &= ~zfcp_fsf_fc_security_mnemonics[i].mask;
709
+ }
710
+
711
+ if (fc_security != 0)
712
+ len += scnprintf(buf + len, size - len, "%s0x%08x",
713
+ prefix, fc_security);
714
+
715
+ return len;
716
+}
717
+
718
+static void zfcp_fsf_dbf_adapter_fc_security(struct zfcp_adapter *adapter,
719
+ struct zfcp_fsf_req *req)
720
+{
721
+ if (adapter->fc_security_algorithms ==
722
+ adapter->fc_security_algorithms_old) {
723
+ /* no change, no trace */
724
+ return;
725
+ }
726
+
727
+ zfcp_dbf_hba_fsf_fces("fsfcesa", req, ZFCP_DBF_INVALID_WWPN,
728
+ adapter->fc_security_algorithms_old,
729
+ adapter->fc_security_algorithms);
730
+
731
+ adapter->fc_security_algorithms_old = adapter->fc_security_algorithms;
732
+}
733
+
626734 static void zfcp_fsf_exchange_port_evaluate(struct zfcp_fsf_req *req)
627735 {
628736 struct zfcp_adapter *adapter = req->adapter;
629737 struct fsf_qtcb_bottom_port *bottom = &req->qtcb->bottom.port;
630
- struct Scsi_Host *shost = adapter->scsi_host;
631738
632739 if (req->data)
633740 memcpy(req->data, bottom, sizeof(*bottom));
634741
635
- if (adapter->connection_features & FSF_FEATURE_NPIV_MODE) {
636
- fc_host_permanent_port_name(shost) = bottom->wwpn;
637
- } else
638
- fc_host_permanent_port_name(shost) = fc_host_port_name(shost);
639
- fc_host_maxframe_size(shost) = bottom->maximum_frame_size;
640
- fc_host_supported_speeds(shost) =
641
- zfcp_fsf_convert_portspeed(bottom->supported_speed);
642
- memcpy(fc_host_supported_fc4s(shost), bottom->supported_fc4_types,
643
- FC_FC4_LIST_SIZE);
644
- memcpy(fc_host_active_fc4s(shost), bottom->active_fc4_types,
645
- FC_FC4_LIST_SIZE);
742
+ if (adapter->adapter_features & FSF_FEATURE_FC_SECURITY)
743
+ adapter->fc_security_algorithms =
744
+ bottom->fc_security_algorithms;
745
+ else
746
+ adapter->fc_security_algorithms = 0;
747
+ zfcp_fsf_dbf_adapter_fc_security(adapter, req);
646748 }
647749
648750 static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *req)
649751 {
752
+ struct zfcp_diag_header *const diag_hdr =
753
+ &req->adapter->diagnostics->port_data.header;
650754 struct fsf_qtcb *qtcb = req->qtcb;
755
+ struct fsf_qtcb_bottom_port *bottom = &qtcb->bottom.port;
651756
652757 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
653758 return;
654759
655760 switch (qtcb->header.fsf_status) {
656761 case FSF_GOOD:
762
+ /*
763
+ * usually we wait with an update till the cache is too old,
764
+ * but because we have the data available, update it anyway
765
+ */
766
+ zfcp_diag_update_xdata(diag_hdr, bottom, false);
767
+
768
+ zfcp_scsi_shost_update_port_data(req->adapter, bottom);
657769 zfcp_fsf_exchange_port_evaluate(req);
658770 break;
659771 case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE:
660
- zfcp_fsf_exchange_port_evaluate(req);
772
+ zfcp_diag_update_xdata(diag_hdr, bottom, true);
773
+ req->status |= ZFCP_STATUS_FSFREQ_XDATAINCOMPLETE;
774
+
661775 zfcp_fsf_link_down_info_eval(req,
662776 &qtcb->header.fsf_status_qual.link_down_info);
777
+
778
+ zfcp_scsi_shost_update_port_data(req->adapter, bottom);
779
+ zfcp_fsf_exchange_port_evaluate(req);
663780 break;
664781 }
665782 }
....@@ -715,7 +832,6 @@
715832 init_completion(&req->completion);
716833
717834 req->adapter = adapter;
718
- req->fsf_command = fsf_cmd;
719835 req->req_id = adapter->req_no;
720836
721837 if (likely(fsf_cmd != FSF_QTCB_UNSOLICITED_STATUS)) {
....@@ -730,14 +846,13 @@
730846 return ERR_PTR(-ENOMEM);
731847 }
732848
733
- req->seq_no = adapter->fsf_req_seq_no;
734849 req->qtcb->prefix.req_seq_no = adapter->fsf_req_seq_no;
735850 req->qtcb->prefix.req_id = req->req_id;
736851 req->qtcb->prefix.ulp_info = 26;
737
- req->qtcb->prefix.qtcb_type = fsf_qtcb_type[req->fsf_command];
852
+ req->qtcb->prefix.qtcb_type = fsf_qtcb_type[fsf_cmd];
738853 req->qtcb->prefix.qtcb_version = FSF_QTCB_CURRENT_VERSION;
739854 req->qtcb->header.req_handle = req->req_id;
740
- req->qtcb->header.fsf_command = req->fsf_command;
855
+ req->qtcb->header.fsf_command = fsf_cmd;
741856 }
742857
743858 zfcp_qdio_req_init(adapter->qdio, &req->qdio_req, req->req_id, sbtype,
....@@ -748,10 +863,10 @@
748863
749864 static int zfcp_fsf_req_send(struct zfcp_fsf_req *req)
750865 {
866
+ const bool is_srb = zfcp_fsf_req_is_status_read_buffer(req);
751867 struct zfcp_adapter *adapter = req->adapter;
752868 struct zfcp_qdio *qdio = adapter->qdio;
753
- int with_qtcb = (req->qtcb != NULL);
754
- int req_id = req->req_id;
869
+ unsigned long req_id = req->req_id;
755870
756871 zfcp_reqlist_add(adapter->req_list, req);
757872
....@@ -765,8 +880,20 @@
765880 return -EIO;
766881 }
767882
883
+ /*
884
+ * NOTE: DO NOT TOUCH ASYNC req PAST THIS POINT.
885
+ * ONLY TOUCH SYNC req AGAIN ON req->completion.
886
+ *
887
+ * The request might complete and be freed concurrently at any point
888
+ * now. This is not protected by the QDIO-lock (req_q_lock). So any
889
+ * uncontrolled access after this might result in an use-after-free bug.
890
+ * Only if the request doesn't have ZFCP_STATUS_FSFREQ_CLEANUP set, and
891
+ * when it is completed via req->completion, is it safe to use req
892
+ * again.
893
+ */
894
+
768895 /* Don't increase for unsolicited status */
769
- if (with_qtcb)
896
+ if (!is_srb)
770897 adapter->fsf_req_seq_no++;
771898 adapter->req_no++;
772899
....@@ -775,8 +902,7 @@
775902
776903 /**
777904 * zfcp_fsf_status_read - send status read request
778
- * @adapter: pointer to struct zfcp_adapter
779
- * @req_flags: request flags
905
+ * @qdio: pointer to struct zfcp_qdio
780906 * Returns: 0 on success, ERROR otherwise
781907 */
782908 int zfcp_fsf_status_read(struct zfcp_qdio *qdio)
....@@ -814,6 +940,7 @@
814940 retval = zfcp_fsf_req_send(req);
815941 if (retval)
816942 goto failed_req_send;
943
+ /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
817944
818945 goto out;
819946
....@@ -873,7 +1000,7 @@
8731000 switch (fsq->word[0]) {
8741001 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
8751002 zfcp_fc_test_link(zfcp_sdev->port);
876
- /* fall through */
1003
+ fallthrough;
8771004 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
8781005 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
8791006 break;
....@@ -922,9 +1049,11 @@
9221049 req->qtcb->header.port_handle = zfcp_sdev->port->handle;
9231050 req->qtcb->bottom.support.req_handle = (u64) old_req_id;
9241051
925
- zfcp_fsf_start_timer(req, ZFCP_SCSI_ER_TIMEOUT);
926
- if (!zfcp_fsf_req_send(req))
1052
+ zfcp_fsf_start_timer(req, ZFCP_FSF_SCSI_ER_TIMEOUT);
1053
+ if (!zfcp_fsf_req_send(req)) {
1054
+ /* NOTE: DO NOT TOUCH req, UNTIL IT COMPLETES! */
9271055 goto out;
1056
+ }
9281057
9291058 out_error_free:
9301059 zfcp_fsf_req_free(req);
....@@ -966,7 +1095,7 @@
9661095 break;
9671096 case FSF_PORT_HANDLE_NOT_VALID:
9681097 zfcp_erp_adapter_reopen(adapter, 0, "fsscth1");
969
- /* fall through */
1098
+ fallthrough;
9701099 case FSF_GENERIC_COMMAND_REJECTED:
9711100 case FSF_PAYLOAD_SIZE_MISMATCH:
9721101 case FSF_REQUEST_SIZE_TOO_LARGE:
....@@ -1067,8 +1196,10 @@
10671196
10681197 /**
10691198 * zfcp_fsf_send_ct - initiate a Generic Service request (FC-GS)
1199
+ * @wka_port: pointer to zfcp WKA port to send CT/GS to
10701200 * @ct: pointer to struct zfcp_send_ct with data for request
10711201 * @pool: if non-null this mempool is used to allocate struct zfcp_fsf_req
1202
+ * @timeout: timeout that hardware should use, and a later software timeout
10721203 */
10731204 int zfcp_fsf_send_ct(struct zfcp_fc_wka_port *wka_port,
10741205 struct zfcp_fsf_ct_els *ct, mempool_t *pool,
....@@ -1105,6 +1236,7 @@
11051236 ret = zfcp_fsf_req_send(req);
11061237 if (ret)
11071238 goto failed_send;
1239
+ /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
11081240
11091241 goto out;
11101242
....@@ -1149,7 +1281,7 @@
11491281 break;
11501282 case FSF_SBAL_MISMATCH:
11511283 /* should never occur, avoided in zfcp_fsf_send_els */
1152
- /* fall through */
1284
+ fallthrough;
11531285 default:
11541286 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
11551287 break;
....@@ -1161,7 +1293,10 @@
11611293
11621294 /**
11631295 * zfcp_fsf_send_els - initiate an ELS command (FC-FS)
1296
+ * @adapter: pointer to zfcp adapter
1297
+ * @d_id: N_Port_ID to send ELS to
11641298 * @els: pointer to struct zfcp_send_els with data for the command
1299
+ * @timeout: timeout that hardware should use, and a later software timeout
11651300 */
11661301 int zfcp_fsf_send_els(struct zfcp_adapter *adapter, u32 d_id,
11671302 struct zfcp_fsf_ct_els *els, unsigned int timeout)
....@@ -1202,6 +1337,7 @@
12021337 ret = zfcp_fsf_req_send(req);
12031338 if (ret)
12041339 goto failed_send;
1340
+ /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
12051341
12061342 goto out;
12071343
....@@ -1236,7 +1372,9 @@
12361372
12371373 req->qtcb->bottom.config.feature_selection =
12381374 FSF_FEATURE_NOTIFICATION_LOST |
1239
- FSF_FEATURE_UPDATE_ALERT;
1375
+ FSF_FEATURE_UPDATE_ALERT |
1376
+ FSF_FEATURE_REQUEST_SFP_DATA |
1377
+ FSF_FEATURE_FC_SECURITY;
12401378 req->erp_action = erp_action;
12411379 req->handler = zfcp_fsf_exchange_config_data_handler;
12421380 erp_action->fsf_req_id = req->req_id;
....@@ -1247,11 +1385,25 @@
12471385 zfcp_fsf_req_free(req);
12481386 erp_action->fsf_req_id = 0;
12491387 }
1388
+ /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
12501389 out:
12511390 spin_unlock_irq(&qdio->req_q_lock);
12521391 return retval;
12531392 }
12541393
1394
+
1395
+/**
1396
+ * zfcp_fsf_exchange_config_data_sync() - Request information about FCP channel.
1397
+ * @qdio: pointer to the QDIO-Queue to use for sending the command.
1398
+ * @data: pointer to the QTCB-Bottom for storing the result of the command,
1399
+ * might be %NULL.
1400
+ *
1401
+ * Returns:
1402
+ * * 0 - Exchange Config Data was successful, @data is complete
1403
+ * * -EIO - Exchange Config Data was not successful, @data is invalid
1404
+ * * -EAGAIN - @data contains incomplete data
1405
+ * * -ENOMEM - Some memory allocation failed along the way
1406
+ */
12551407 int zfcp_fsf_exchange_config_data_sync(struct zfcp_qdio *qdio,
12561408 struct fsf_qtcb_bottom_config *data)
12571409 {
....@@ -1275,7 +1427,9 @@
12751427
12761428 req->qtcb->bottom.config.feature_selection =
12771429 FSF_FEATURE_NOTIFICATION_LOST |
1278
- FSF_FEATURE_UPDATE_ALERT;
1430
+ FSF_FEATURE_UPDATE_ALERT |
1431
+ FSF_FEATURE_REQUEST_SFP_DATA |
1432
+ FSF_FEATURE_FC_SECURITY;
12791433
12801434 if (data)
12811435 req->data = data;
....@@ -1283,8 +1437,17 @@
12831437 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
12841438 retval = zfcp_fsf_req_send(req);
12851439 spin_unlock_irq(&qdio->req_q_lock);
1286
- if (!retval)
1440
+
1441
+ if (!retval) {
1442
+ /* NOTE: ONLY TOUCH SYNC req AGAIN ON req->completion. */
12871443 wait_for_completion(&req->completion);
1444
+
1445
+ if (req->status &
1446
+ (ZFCP_STATUS_FSFREQ_ERROR | ZFCP_STATUS_FSFREQ_DISMISSED))
1447
+ retval = -EIO;
1448
+ else if (req->status & ZFCP_STATUS_FSFREQ_XDATAINCOMPLETE)
1449
+ retval = -EAGAIN;
1450
+ }
12881451
12891452 zfcp_fsf_req_free(req);
12901453 return retval;
....@@ -1334,16 +1497,24 @@
13341497 zfcp_fsf_req_free(req);
13351498 erp_action->fsf_req_id = 0;
13361499 }
1500
+ /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
13371501 out:
13381502 spin_unlock_irq(&qdio->req_q_lock);
13391503 return retval;
13401504 }
13411505
13421506 /**
1343
- * zfcp_fsf_exchange_port_data_sync - request information about local port
1344
- * @qdio: pointer to struct zfcp_qdio
1345
- * @data: pointer to struct fsf_qtcb_bottom_port
1346
- * Returns: 0 on success, error otherwise
1507
+ * zfcp_fsf_exchange_port_data_sync() - Request information about local port.
1508
+ * @qdio: pointer to the QDIO-Queue to use for sending the command.
1509
+ * @data: pointer to the QTCB-Bottom for storing the result of the command,
1510
+ * might be %NULL.
1511
+ *
1512
+ * Returns:
1513
+ * * 0 - Exchange Port Data was successful, @data is complete
1514
+ * * -EIO - Exchange Port Data was not successful, @data is invalid
1515
+ * * -EAGAIN - @data contains incomplete data
1516
+ * * -ENOMEM - Some memory allocation failed along the way
1517
+ * * -EOPNOTSUPP - This operation is not supported
13471518 */
13481519 int zfcp_fsf_exchange_port_data_sync(struct zfcp_qdio *qdio,
13491520 struct fsf_qtcb_bottom_port *data)
....@@ -1376,11 +1547,18 @@
13761547 retval = zfcp_fsf_req_send(req);
13771548 spin_unlock_irq(&qdio->req_q_lock);
13781549
1379
- if (!retval)
1550
+ if (!retval) {
1551
+ /* NOTE: ONLY TOUCH SYNC req AGAIN ON req->completion. */
13801552 wait_for_completion(&req->completion);
13811553
1382
- zfcp_fsf_req_free(req);
1554
+ if (req->status &
1555
+ (ZFCP_STATUS_FSFREQ_ERROR | ZFCP_STATUS_FSFREQ_DISMISSED))
1556
+ retval = -EIO;
1557
+ else if (req->status & ZFCP_STATUS_FSFREQ_XDATAINCOMPLETE)
1558
+ retval = -EAGAIN;
1559
+ }
13831560
1561
+ zfcp_fsf_req_free(req);
13841562 return retval;
13851563
13861564 out_unlock:
....@@ -1388,10 +1566,117 @@
13881566 return retval;
13891567 }
13901568
1569
+static void zfcp_fsf_log_port_fc_security(struct zfcp_port *port,
1570
+ struct zfcp_fsf_req *req)
1571
+{
1572
+ char mnemonic_old[ZFCP_FSF_MAX_FC_SECURITY_MNEMONIC_LENGTH];
1573
+ char mnemonic_new[ZFCP_FSF_MAX_FC_SECURITY_MNEMONIC_LENGTH];
1574
+
1575
+ if (port->connection_info == port->connection_info_old) {
1576
+ /* no change, no log nor trace */
1577
+ return;
1578
+ }
1579
+
1580
+ zfcp_dbf_hba_fsf_fces("fsfcesp", req, port->wwpn,
1581
+ port->connection_info_old,
1582
+ port->connection_info);
1583
+
1584
+ zfcp_fsf_scnprint_fc_security(mnemonic_old, sizeof(mnemonic_old),
1585
+ port->connection_info_old,
1586
+ ZFCP_FSF_PRINT_FMT_SINGLEITEM);
1587
+ zfcp_fsf_scnprint_fc_security(mnemonic_new, sizeof(mnemonic_new),
1588
+ port->connection_info,
1589
+ ZFCP_FSF_PRINT_FMT_SINGLEITEM);
1590
+
1591
+ if (strncmp(mnemonic_old, mnemonic_new,
1592
+ ZFCP_FSF_MAX_FC_SECURITY_MNEMONIC_LENGTH) == 0) {
1593
+ /* no change in string representation, no log */
1594
+ goto out;
1595
+ }
1596
+
1597
+ if (port->connection_info_old == 0) {
1598
+ /* activation */
1599
+ dev_info(&port->adapter->ccw_device->dev,
1600
+ "FC Endpoint Security of connection to remote port 0x%16llx enabled: %s\n",
1601
+ port->wwpn, mnemonic_new);
1602
+ } else if (port->connection_info == 0) {
1603
+ /* deactivation */
1604
+ dev_warn(&port->adapter->ccw_device->dev,
1605
+ "FC Endpoint Security of connection to remote port 0x%16llx disabled: was %s\n",
1606
+ port->wwpn, mnemonic_old);
1607
+ } else {
1608
+ /* change */
1609
+ dev_warn(&port->adapter->ccw_device->dev,
1610
+ "FC Endpoint Security of connection to remote port 0x%16llx changed: from %s to %s\n",
1611
+ port->wwpn, mnemonic_old, mnemonic_new);
1612
+ }
1613
+
1614
+out:
1615
+ port->connection_info_old = port->connection_info;
1616
+}
1617
+
1618
+static void zfcp_fsf_log_security_error(const struct device *dev, u32 fsf_sqw0,
1619
+ u64 wwpn)
1620
+{
1621
+ switch (fsf_sqw0) {
1622
+
1623
+ /*
1624
+ * Open Port command error codes
1625
+ */
1626
+
1627
+ case FSF_SQ_SECURITY_REQUIRED:
1628
+ dev_warn_ratelimited(dev,
1629
+ "FC Endpoint Security error: FC security is required but not supported or configured on remote port 0x%016llx\n",
1630
+ wwpn);
1631
+ break;
1632
+ case FSF_SQ_SECURITY_TIMEOUT:
1633
+ dev_warn_ratelimited(dev,
1634
+ "FC Endpoint Security error: a timeout prevented opening remote port 0x%016llx\n",
1635
+ wwpn);
1636
+ break;
1637
+ case FSF_SQ_SECURITY_KM_UNAVAILABLE:
1638
+ dev_warn_ratelimited(dev,
1639
+ "FC Endpoint Security error: opening remote port 0x%016llx failed because local and external key manager cannot communicate\n",
1640
+ wwpn);
1641
+ break;
1642
+ case FSF_SQ_SECURITY_RKM_UNAVAILABLE:
1643
+ dev_warn_ratelimited(dev,
1644
+ "FC Endpoint Security error: opening remote port 0x%016llx failed because it cannot communicate with the external key manager\n",
1645
+ wwpn);
1646
+ break;
1647
+ case FSF_SQ_SECURITY_AUTH_FAILURE:
1648
+ dev_warn_ratelimited(dev,
1649
+ "FC Endpoint Security error: the device could not verify the identity of remote port 0x%016llx\n",
1650
+ wwpn);
1651
+ break;
1652
+
1653
+ /*
1654
+ * Send FCP command error codes
1655
+ */
1656
+
1657
+ case FSF_SQ_SECURITY_ENC_FAILURE:
1658
+ dev_warn_ratelimited(dev,
1659
+ "FC Endpoint Security error: FC connection to remote port 0x%016llx closed because encryption broke down\n",
1660
+ wwpn);
1661
+ break;
1662
+
1663
+ /*
1664
+ * Unknown error codes
1665
+ */
1666
+
1667
+ default:
1668
+ dev_warn_ratelimited(dev,
1669
+ "FC Endpoint Security error: the device issued an unknown error code 0x%08x related to the FC connection to remote port 0x%016llx\n",
1670
+ fsf_sqw0, wwpn);
1671
+ }
1672
+}
1673
+
13911674 static void zfcp_fsf_open_port_handler(struct zfcp_fsf_req *req)
13921675 {
1676
+ struct zfcp_adapter *adapter = req->adapter;
13931677 struct zfcp_port *port = req->data;
13941678 struct fsf_qtcb_header *header = &req->qtcb->header;
1679
+ struct fsf_qtcb_bottom_support *bottom = &req->qtcb->bottom.support;
13951680 struct fc_els_flogi *plogi;
13961681
13971682 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
....@@ -1401,7 +1686,7 @@
14011686 case FSF_PORT_ALREADY_OPEN:
14021687 break;
14031688 case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED:
1404
- dev_warn(&req->adapter->ccw_device->dev,
1689
+ dev_warn(&adapter->ccw_device->dev,
14051690 "Not enough FCP adapter resources to open "
14061691 "remote port 0x%016Lx\n",
14071692 (unsigned long long)port->wwpn);
....@@ -1409,11 +1694,17 @@
14091694 ZFCP_STATUS_COMMON_ERP_FAILED);
14101695 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
14111696 break;
1697
+ case FSF_SECURITY_ERROR:
1698
+ zfcp_fsf_log_security_error(&req->adapter->ccw_device->dev,
1699
+ header->fsf_status_qual.word[0],
1700
+ port->wwpn);
1701
+ req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1702
+ break;
14121703 case FSF_ADAPTER_STATUS_AVAILABLE:
14131704 switch (header->fsf_status_qual.word[0]) {
14141705 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
14151706 /* no zfcp_fc_test_link() with failed open port */
1416
- /* fall through */
1707
+ fallthrough;
14171708 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
14181709 case FSF_SQ_NO_RETRY_POSSIBLE:
14191710 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
....@@ -1422,6 +1713,11 @@
14221713 break;
14231714 case FSF_GOOD:
14241715 port->handle = header->port_handle;
1716
+ if (adapter->adapter_features & FSF_FEATURE_FC_SECURITY)
1717
+ port->connection_info = bottom->connection_info;
1718
+ else
1719
+ port->connection_info = 0;
1720
+ zfcp_fsf_log_port_fc_security(port, req);
14251721 atomic_or(ZFCP_STATUS_COMMON_OPEN |
14261722 ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
14271723 atomic_andnot(ZFCP_STATUS_COMMON_ACCESS_BOXED,
....@@ -1441,10 +1737,9 @@
14411737 * another GID_PN straight after a port has been opened.
14421738 * Alternately, an ADISC/PDISC ELS should suffice, as well.
14431739 */
1444
- plogi = (struct fc_els_flogi *) req->qtcb->bottom.support.els;
1445
- if (req->qtcb->bottom.support.els1_length >=
1446
- FSF_PLOGI_MIN_LEN)
1447
- zfcp_fc_plogi_evaluate(port, plogi);
1740
+ plogi = (struct fc_els_flogi *) bottom->els;
1741
+ if (bottom->els1_length >= FSF_PLOGI_MIN_LEN)
1742
+ zfcp_fc_plogi_evaluate(port, plogi);
14481743 break;
14491744 case FSF_UNKNOWN_OP_SUBTYPE:
14501745 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
....@@ -1497,6 +1792,7 @@
14971792 erp_action->fsf_req_id = 0;
14981793 put_device(&port->dev);
14991794 }
1795
+ /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
15001796 out:
15011797 spin_unlock_irq(&qdio->req_q_lock);
15021798 return retval;
....@@ -1561,6 +1857,7 @@
15611857 zfcp_fsf_req_free(req);
15621858 erp_action->fsf_req_id = 0;
15631859 }
1860
+ /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
15641861 out:
15651862 spin_unlock_irq(&qdio->req_q_lock);
15661863 return retval;
....@@ -1580,19 +1877,19 @@
15801877 case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED:
15811878 dev_warn(&req->adapter->ccw_device->dev,
15821879 "Opening WKA port 0x%x failed\n", wka_port->d_id);
1583
- /* fall through */
1880
+ fallthrough;
15841881 case FSF_ADAPTER_STATUS_AVAILABLE:
15851882 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
15861883 wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE;
15871884 break;
15881885 case FSF_GOOD:
15891886 wka_port->handle = header->port_handle;
1590
- /* fall through */
1887
+ fallthrough;
15911888 case FSF_PORT_ALREADY_OPEN:
15921889 wka_port->status = ZFCP_FC_WKA_PORT_ONLINE;
15931890 }
15941891 out:
1595
- wake_up(&wka_port->completion_wq);
1892
+ wake_up(&wka_port->opened);
15961893 }
15971894
15981895 /**
....@@ -1633,6 +1930,7 @@
16331930 retval = zfcp_fsf_req_send(req);
16341931 if (retval)
16351932 zfcp_fsf_req_free(req);
1933
+ /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
16361934 out:
16371935 spin_unlock_irq(&qdio->req_q_lock);
16381936 if (!retval)
....@@ -1650,7 +1948,7 @@
16501948 }
16511949
16521950 wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE;
1653
- wake_up(&wka_port->completion_wq);
1951
+ wake_up(&wka_port->closed);
16541952 }
16551953
16561954 /**
....@@ -1691,6 +1989,7 @@
16911989 retval = zfcp_fsf_req_send(req);
16921990 if (retval)
16931991 zfcp_fsf_req_free(req);
1992
+ /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
16941993 out:
16951994 spin_unlock_irq(&qdio->req_q_lock);
16961995 if (!retval)
....@@ -1728,7 +2027,6 @@
17282027 case FSF_ADAPTER_STATUS_AVAILABLE:
17292028 switch (header->fsf_status_qual.word[0]) {
17302029 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
1731
- /* fall through */
17322030 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
17332031 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
17342032 break;
....@@ -1786,6 +2084,7 @@
17862084 zfcp_fsf_req_free(req);
17872085 erp_action->fsf_req_id = 0;
17882086 }
2087
+ /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
17892088 out:
17902089 spin_unlock_irq(&qdio->req_q_lock);
17912090 return retval;
....@@ -1812,7 +2111,7 @@
18122111
18132112 case FSF_PORT_HANDLE_NOT_VALID:
18142113 zfcp_erp_adapter_reopen(adapter, 0, "fsouh_1");
1815
- /* fall through */
2114
+ fallthrough;
18162115 case FSF_LUN_ALREADY_OPEN:
18172116 break;
18182117 case FSF_PORT_BOXED:
....@@ -1825,7 +2124,7 @@
18252124 case FSF_LUN_SHARING_VIOLATION:
18262125 if (qual->word[0])
18272126 dev_warn(&zfcp_sdev->port->adapter->ccw_device->dev,
1828
- "LUN 0x%Lx on port 0x%Lx is already in "
2127
+ "LUN 0x%016Lx on port 0x%016Lx is already in "
18292128 "use by CSS%d, MIF Image ID %x\n",
18302129 zfcp_scsi_dev_lun(sdev),
18312130 (unsigned long long)zfcp_sdev->port->wwpn,
....@@ -1843,7 +2142,7 @@
18432142 (unsigned long long)zfcp_scsi_dev_lun(sdev),
18442143 (unsigned long long)zfcp_sdev->port->wwpn);
18452144 zfcp_erp_set_lun_status(sdev, ZFCP_STATUS_COMMON_ERP_FAILED);
1846
- /* fall through */
2145
+ fallthrough;
18472146 case FSF_INVALID_COMMAND_OPTION:
18482147 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
18492148 break;
....@@ -1851,7 +2150,7 @@
18512150 switch (header->fsf_status_qual.word[0]) {
18522151 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
18532152 zfcp_fc_test_link(zfcp_sdev->port);
1854
- /* fall through */
2153
+ fallthrough;
18552154 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
18562155 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
18572156 break;
....@@ -1909,6 +2208,7 @@
19092208 zfcp_fsf_req_free(req);
19102209 erp_action->fsf_req_id = 0;
19112210 }
2211
+ /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
19122212 out:
19132213 spin_unlock_irq(&qdio->req_q_lock);
19142214 return retval;
....@@ -1944,7 +2244,7 @@
19442244 switch (req->qtcb->header.fsf_status_qual.word[0]) {
19452245 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
19462246 zfcp_fc_test_link(zfcp_sdev->port);
1947
- /* fall through */
2247
+ fallthrough;
19482248 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
19492249 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
19502250 break;
....@@ -1997,12 +2297,13 @@
19972297 zfcp_fsf_req_free(req);
19982298 erp_action->fsf_req_id = 0;
19992299 }
2300
+ /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
20002301 out:
20012302 spin_unlock_irq(&qdio->req_q_lock);
20022303 return retval;
20032304 }
20042305
2005
-static void zfcp_fsf_update_lat(struct fsf_latency_record *lat_rec, u32 lat)
2306
+static void zfcp_fsf_update_lat(struct zfcp_latency_record *lat_rec, u32 lat)
20062307 {
20072308 lat_rec->sum += lat;
20082309 lat_rec->min = min(lat_rec->min, lat);
....@@ -2012,7 +2313,7 @@
20122313 static void zfcp_fsf_req_trace(struct zfcp_fsf_req *req, struct scsi_cmnd *scsi)
20132314 {
20142315 struct fsf_qual_latency_info *lat_in;
2015
- struct latency_cont *lat = NULL;
2316
+ struct zfcp_latency_cont *lat = NULL;
20162317 struct zfcp_scsi_dev *zfcp_sdev;
20172318 struct zfcp_blk_drv_data blktrc;
20182319 int ticks = req->adapter->timer_ticks;
....@@ -2126,6 +2427,13 @@
21262427 if (header->fsf_status_qual.word[0] ==
21272428 FSF_SQ_INVOKE_LINK_TEST_PROCEDURE)
21282429 zfcp_fc_test_link(zfcp_sdev->port);
2430
+ req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2431
+ break;
2432
+ case FSF_SECURITY_ERROR:
2433
+ zfcp_fsf_log_security_error(&req->adapter->ccw_device->dev,
2434
+ header->fsf_status_qual.word[0],
2435
+ zfcp_sdev->port->wwpn);
2436
+ zfcp_erp_port_forced_reopen(zfcp_sdev->port, 0, "fssfch7");
21292437 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
21302438 break;
21312439 }
....@@ -2309,6 +2617,7 @@
23092617 retval = zfcp_fsf_req_send(req);
23102618 if (unlikely(retval))
23112619 goto failed_scsi_cmnd;
2620
+ /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
23122621
23132622 goto out;
23142623
....@@ -2382,9 +2691,11 @@
23822691 fcp_cmnd = &req->qtcb->bottom.io.fcp_cmnd.iu;
23832692 zfcp_fc_fcp_tm(fcp_cmnd, sdev, tm_flags);
23842693
2385
- zfcp_fsf_start_timer(req, ZFCP_SCSI_ER_TIMEOUT);
2386
- if (!zfcp_fsf_req_send(req))
2694
+ zfcp_fsf_start_timer(req, ZFCP_FSF_SCSI_ER_TIMEOUT);
2695
+ if (!zfcp_fsf_req_send(req)) {
2696
+ /* NOTE: DO NOT TOUCH req, UNTIL IT COMPLETES! */
23872697 goto out;
2698
+ }
23882699
23892700 zfcp_fsf_req_free(req);
23902701 req = NULL;
....@@ -2395,7 +2706,7 @@
23952706
23962707 /**
23972708 * zfcp_fsf_reqid_check - validate req_id contained in SBAL returned by QDIO
2398
- * @adapter: pointer to struct zfcp_adapter
2709
+ * @qdio: pointer to struct zfcp_qdio
23992710 * @sbal_idx: response queue index of SBAL to be processed
24002711 */
24012712 void zfcp_fsf_reqid_check(struct zfcp_qdio *qdio, int sbal_idx)
....@@ -2410,7 +2721,7 @@
24102721 for (idx = 0; idx < QDIO_MAX_ELEMENTS_PER_BUFFER; idx++) {
24112722
24122723 sbale = &sbal->element[idx];
2413
- req_id = (unsigned long) sbale->addr;
2724
+ req_id = sbale->addr;
24142725 fsf_req = zfcp_reqlist_find_rm(adapter->req_list, req_id);
24152726
24162727 if (!fsf_req) {