Skip to content

Commit 7c7dc19

Browse files
Christof SchmittJames Bottomley
authored andcommitted
[SCSI] zfcp: Simplify handling of ct and els requests
Remove some redundancies in FC related code and trace: - drop redundant data from SAN trace (local s_id that only changes during link down, ls_code that is already part of payload, d_id in ct response trace that is always the same as in ct request trace) - use one common fsf struct to hold zfcp data for ct and els requests - leverage common fsf struct for FC passthrough job data, allocate it with dd_bsg_data for passthrough requests and unify common code for ct and els passthrough request - simplify callback handling in zfcp_fc Reviewed-by: Swen Schillig <[email protected]> Signed-off-by: Christof Schmitt <[email protected]> Signed-off-by: James Bottomley <[email protected]>
1 parent 800c0ca commit 7c7dc19

File tree

9 files changed

+160
-285
lines changed

9 files changed

+160
-285
lines changed

drivers/s390/scsi/zfcp_dbf.c

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ void _zfcp_dbf_hba_fsf_response(const char *tag2, int level,
179179
case FSF_QTCB_SEND_ELS:
180180
send_els = (struct zfcp_send_els *)fsf_req->data;
181181
response->u.els.d_id = ntoh24(qtcb->bottom.support.d_id);
182-
response->u.els.ls_code = send_els->ls_code >> 24;
183182
break;
184183

185184
case FSF_QTCB_ABORT_FCP_CMND:
@@ -349,7 +348,6 @@ static void zfcp_dbf_hba_view_response(char **p,
349348

350349
case FSF_QTCB_SEND_ELS:
351350
zfcp_dbf_out(p, "d_id", "0x%06x", r->u.els.d_id);
352-
zfcp_dbf_out(p, "ls_code", "0x%02x", r->u.els.ls_code);
353351
break;
354352

355353
case FSF_QTCB_ABORT_FCP_CMND:
@@ -678,12 +676,12 @@ void zfcp_dbf_rec_action(char *id2, struct zfcp_erp_action *erp_action)
678676
/**
679677
* zfcp_dbf_san_ct_request - trace event for issued CT request
680678
* @fsf_req: request containing issued CT data
679+
* @d_id: destination id where ct request is sent to
681680
*/
682-
void zfcp_dbf_san_ct_request(struct zfcp_fsf_req *fsf_req)
681+
void zfcp_dbf_san_ct_request(struct zfcp_fsf_req *fsf_req, u32 d_id)
683682
{
684-
struct zfcp_send_ct *ct = (struct zfcp_send_ct *)fsf_req->data;
685-
struct zfcp_fc_wka_port *wka_port = ct->wka_port;
686-
struct zfcp_adapter *adapter = wka_port->adapter;
683+
struct zfcp_fsf_ct_els *ct = (struct zfcp_fsf_ct_els *)fsf_req->data;
684+
struct zfcp_adapter *adapter = fsf_req->adapter;
687685
struct zfcp_dbf *dbf = adapter->dbf;
688686
struct fc_ct_hdr *hdr = sg_virt(ct->req);
689687
struct zfcp_dbf_san_record *r = &dbf->san_buf;
@@ -696,8 +694,7 @@ void zfcp_dbf_san_ct_request(struct zfcp_fsf_req *fsf_req)
696694
strncpy(r->tag, "octc", ZFCP_DBF_TAG_SIZE);
697695
r->fsf_reqid = fsf_req->req_id;
698696
r->fsf_seqno = fsf_req->seq_no;
699-
r->s_id = fc_host_port_id(adapter->scsi_host);
700-
r->d_id = wka_port->d_id;
697+
oct->d_id = d_id;
701698
oct->cmd_req_code = hdr->ct_cmd;
702699
oct->revision = hdr->ct_rev;
703700
oct->gs_type = hdr->ct_fs_type;
@@ -718,9 +715,8 @@ void zfcp_dbf_san_ct_request(struct zfcp_fsf_req *fsf_req)
718715
*/
719716
void zfcp_dbf_san_ct_response(struct zfcp_fsf_req *fsf_req)
720717
{
721-
struct zfcp_send_ct *ct = (struct zfcp_send_ct *)fsf_req->data;
722-
struct zfcp_fc_wka_port *wka_port = ct->wka_port;
723-
struct zfcp_adapter *adapter = wka_port->adapter;
718+
struct zfcp_fsf_ct_els *ct = (struct zfcp_fsf_ct_els *)fsf_req->data;
719+
struct zfcp_adapter *adapter = fsf_req->adapter;
724720
struct fc_ct_hdr *hdr = sg_virt(ct->resp);
725721
struct zfcp_dbf *dbf = adapter->dbf;
726722
struct zfcp_dbf_san_record *r = &dbf->san_buf;
@@ -733,8 +729,6 @@ void zfcp_dbf_san_ct_response(struct zfcp_fsf_req *fsf_req)
733729
strncpy(r->tag, "rctc", ZFCP_DBF_TAG_SIZE);
734730
r->fsf_reqid = fsf_req->req_id;
735731
r->fsf_seqno = fsf_req->seq_no;
736-
r->s_id = wka_port->d_id;
737-
r->d_id = fc_host_port_id(adapter->scsi_host);
738732
rct->cmd_rsp_code = hdr->ct_cmd;
739733
rct->revision = hdr->ct_rev;
740734
rct->reason_code = hdr->ct_reason;
@@ -750,8 +744,8 @@ void zfcp_dbf_san_ct_response(struct zfcp_fsf_req *fsf_req)
750744
}
751745

752746
static void zfcp_dbf_san_els(const char *tag, int level,
753-
struct zfcp_fsf_req *fsf_req, u32 s_id, u32 d_id,
754-
u8 ls_code, void *buffer, int buflen)
747+
struct zfcp_fsf_req *fsf_req, u32 d_id,
748+
void *buffer, int buflen)
755749
{
756750
struct zfcp_adapter *adapter = fsf_req->adapter;
757751
struct zfcp_dbf *dbf = adapter->dbf;
@@ -763,9 +757,7 @@ static void zfcp_dbf_san_els(const char *tag, int level,
763757
strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE);
764758
rec->fsf_reqid = fsf_req->req_id;
765759
rec->fsf_seqno = fsf_req->seq_no;
766-
rec->s_id = s_id;
767-
rec->d_id = d_id;
768-
rec->u.els.ls_code = ls_code;
760+
rec->u.els.d_id = d_id;
769761
debug_event(dbf->san, level, rec, sizeof(*rec));
770762
zfcp_dbf_hexdump(dbf->san, rec, sizeof(*rec), level,
771763
buffer, min(buflen, ZFCP_DBF_SAN_MAX_PAYLOAD));
@@ -778,12 +770,11 @@ static void zfcp_dbf_san_els(const char *tag, int level,
778770
*/
779771
void zfcp_dbf_san_els_request(struct zfcp_fsf_req *fsf_req)
780772
{
781-
struct zfcp_send_els *els = (struct zfcp_send_els *)fsf_req->data;
773+
struct zfcp_fsf_ct_els *els = (struct zfcp_fsf_ct_els *)fsf_req->data;
774+
u32 d_id = ntoh24(fsf_req->qtcb->bottom.support.d_id);
782775

783-
zfcp_dbf_san_els("oels", 2, fsf_req,
784-
fc_host_port_id(els->adapter->scsi_host),
785-
els->d_id, *(u8 *) sg_virt(els->req),
786-
sg_virt(els->req), els->req->length);
776+
zfcp_dbf_san_els("oels", 2, fsf_req, d_id,
777+
sg_virt(els->req), els->req->length);
787778
}
788779

789780
/**
@@ -792,12 +783,11 @@ void zfcp_dbf_san_els_request(struct zfcp_fsf_req *fsf_req)
792783
*/
793784
void zfcp_dbf_san_els_response(struct zfcp_fsf_req *fsf_req)
794785
{
795-
struct zfcp_send_els *els = (struct zfcp_send_els *)fsf_req->data;
786+
struct zfcp_fsf_ct_els *els = (struct zfcp_fsf_ct_els *)fsf_req->data;
787+
u32 d_id = ntoh24(fsf_req->qtcb->bottom.support.d_id);
796788

797-
zfcp_dbf_san_els("rels", 2, fsf_req, els->d_id,
798-
fc_host_port_id(els->adapter->scsi_host),
799-
*(u8 *)sg_virt(els->req), sg_virt(els->resp),
800-
els->resp->length);
789+
zfcp_dbf_san_els("rels", 2, fsf_req, d_id,
790+
sg_virt(els->resp), els->resp->length);
801791
}
802792

803793
/**
@@ -806,16 +796,13 @@ void zfcp_dbf_san_els_response(struct zfcp_fsf_req *fsf_req)
806796
*/
807797
void zfcp_dbf_san_incoming_els(struct zfcp_fsf_req *fsf_req)
808798
{
809-
struct zfcp_adapter *adapter = fsf_req->adapter;
810799
struct fsf_status_read_buffer *buf =
811800
(struct fsf_status_read_buffer *)fsf_req->data;
812801
int length = (int)buf->length -
813802
(int)((void *)&buf->payload - (void *)buf);
814803

815804
zfcp_dbf_san_els("iels", 1, fsf_req, ntoh24(buf->d_id),
816-
fc_host_port_id(adapter->scsi_host),
817-
buf->payload.data[0], (void *)buf->payload.data,
818-
length);
805+
(void *)buf->payload.data, length);
819806
}
820807

821808
static int zfcp_dbf_san_view_format(debug_info_t *id, struct debug_view *view,
@@ -830,11 +817,10 @@ static int zfcp_dbf_san_view_format(debug_info_t *id, struct debug_view *view,
830817
zfcp_dbf_tag(&p, "tag", r->tag);
831818
zfcp_dbf_out(&p, "fsf_reqid", "0x%0Lx", r->fsf_reqid);
832819
zfcp_dbf_out(&p, "fsf_seqno", "0x%08x", r->fsf_seqno);
833-
zfcp_dbf_out(&p, "s_id", "0x%06x", r->s_id);
834-
zfcp_dbf_out(&p, "d_id", "0x%06x", r->d_id);
835820

836821
if (strncmp(r->tag, "octc", ZFCP_DBF_TAG_SIZE) == 0) {
837822
struct zfcp_dbf_san_record_ct_request *ct = &r->u.ct_req;
823+
zfcp_dbf_out(&p, "d_id", "0x%06x", ct->d_id);
838824
zfcp_dbf_out(&p, "cmd_req_code", "0x%04x", ct->cmd_req_code);
839825
zfcp_dbf_out(&p, "revision", "0x%02x", ct->revision);
840826
zfcp_dbf_out(&p, "gs_type", "0x%02x", ct->gs_type);
@@ -853,7 +839,7 @@ static int zfcp_dbf_san_view_format(debug_info_t *id, struct debug_view *view,
853839
strncmp(r->tag, "rels", ZFCP_DBF_TAG_SIZE) == 0 ||
854840
strncmp(r->tag, "iels", ZFCP_DBF_TAG_SIZE) == 0) {
855841
struct zfcp_dbf_san_record_els *els = &r->u.els;
856-
zfcp_dbf_out(&p, "ls_code", "0x%02x", els->ls_code);
842+
zfcp_dbf_out(&p, "d_id", "0x%06x", els->d_id);
857843
}
858844
return p - out_buf;
859845
}

drivers/s390/scsi/zfcp_dbf.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ struct zfcp_dbf_hba_record_response {
123123
} unit;
124124
struct {
125125
u32 d_id;
126-
u8 ls_code;
127126
} els;
128127
} u;
129128
} __attribute__ ((packed));
@@ -167,6 +166,7 @@ struct zfcp_dbf_san_record_ct_request {
167166
u8 options;
168167
u16 max_res_size;
169168
u32 len;
169+
u32 d_id;
170170
} __attribute__ ((packed));
171171

172172
struct zfcp_dbf_san_record_ct_response {
@@ -180,16 +180,13 @@ struct zfcp_dbf_san_record_ct_response {
180180
} __attribute__ ((packed));
181181

182182
struct zfcp_dbf_san_record_els {
183-
u8 ls_code;
184-
u32 len;
183+
u32 d_id;
185184
} __attribute__ ((packed));
186185

187186
struct zfcp_dbf_san_record {
188187
u8 tag[ZFCP_DBF_TAG_SIZE];
189188
u64 fsf_reqid;
190189
u32 fsf_seqno;
191-
u32 s_id;
192-
u32 d_id;
193190
union {
194191
struct zfcp_dbf_san_record_ct_request ct_req;
195192
struct zfcp_dbf_san_record_ct_response ct_resp;

drivers/s390/scsi/zfcp_def.h

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -132,52 +132,6 @@ struct zfcp_adapter_mempool {
132132
mempool_t *qtcb_pool;
133133
};
134134

135-
/**
136-
* struct zfcp_send_ct - used to pass parameters to function zfcp_fsf_send_ct
137-
* @wka_port: port where the request is sent to
138-
* @req: scatter-gather list for request
139-
* @resp: scatter-gather list for response
140-
* @handler: handler function (called for response to the request)
141-
* @handler_data: data passed to handler function
142-
* @completion: completion for synchronization purposes
143-
* @status: used to pass error status to calling function
144-
*/
145-
struct zfcp_send_ct {
146-
struct zfcp_fc_wka_port *wka_port;
147-
struct scatterlist *req;
148-
struct scatterlist *resp;
149-
void (*handler)(unsigned long);
150-
unsigned long handler_data;
151-
struct completion *completion;
152-
int status;
153-
};
154-
155-
/**
156-
* struct zfcp_send_els - used to pass parameters to function zfcp_fsf_send_els
157-
* @adapter: adapter where request is sent from
158-
* @port: port where ELS is destinated (port reference count has to be increased)
159-
* @d_id: destiniation id of port where request is sent to
160-
* @req: scatter-gather list for request
161-
* @resp: scatter-gather list for response
162-
* @handler: handler function (called for response to the request)
163-
* @handler_data: data passed to handler function
164-
* @completion: completion for synchronization purposes
165-
* @ls_code: hex code of ELS command
166-
* @status: used to pass error status to calling function
167-
*/
168-
struct zfcp_send_els {
169-
struct zfcp_adapter *adapter;
170-
struct zfcp_port *port;
171-
u32 d_id;
172-
struct scatterlist *req;
173-
struct scatterlist *resp;
174-
void (*handler)(unsigned long);
175-
unsigned long handler_data;
176-
struct completion *completion;
177-
int ls_code;
178-
int status;
179-
};
180-
181135
struct zfcp_qdio_queue {
182136
struct qdio_buffer *sbal[QDIO_MAX_BUFFERS_PER_Q];
183137
u8 first; /* index of next free bfr in queue */

drivers/s390/scsi/zfcp_ext.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/types.h>
1313
#include <scsi/fc/fc_els.h>
1414
#include "zfcp_def.h"
15+
#include "zfcp_fc.h"
1516

1617
/* zfcp_aux.c */
1718
extern struct zfcp_unit *zfcp_get_unit_by_lun(struct zfcp_port *, u64);
@@ -55,7 +56,7 @@ extern void _zfcp_dbf_hba_fsf_unsol(const char *, int level, struct zfcp_dbf *,
5556
struct fsf_status_read_buffer *);
5657
extern void zfcp_dbf_hba_qdio(struct zfcp_dbf *, unsigned int, int, int);
5758
extern void zfcp_dbf_hba_berr(struct zfcp_dbf *, struct zfcp_fsf_req *);
58-
extern void zfcp_dbf_san_ct_request(struct zfcp_fsf_req *);
59+
extern void zfcp_dbf_san_ct_request(struct zfcp_fsf_req *, u32);
5960
extern void zfcp_dbf_san_ct_response(struct zfcp_fsf_req *);
6061
extern void zfcp_dbf_san_els_request(struct zfcp_fsf_req *);
6162
extern void zfcp_dbf_san_els_response(struct zfcp_fsf_req *);
@@ -106,8 +107,7 @@ extern void zfcp_fc_link_test_work(struct work_struct *);
106107
extern void zfcp_fc_wka_ports_force_offline(struct zfcp_fc_wka_ports *);
107108
extern int zfcp_fc_gs_setup(struct zfcp_adapter *);
108109
extern void zfcp_fc_gs_destroy(struct zfcp_adapter *);
109-
extern int zfcp_fc_execute_els_fc_job(struct fc_bsg_job *);
110-
extern int zfcp_fc_execute_ct_fc_job(struct fc_bsg_job *);
110+
extern int zfcp_fc_exec_bsg_job(struct fc_bsg_job *);
111111

112112
/* zfcp_fsf.c */
113113
extern int zfcp_fsf_open_port(struct zfcp_erp_action *);
@@ -128,8 +128,10 @@ extern struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *,
128128
extern void zfcp_fsf_req_dismiss_all(struct zfcp_adapter *);
129129
extern int zfcp_fsf_status_read(struct zfcp_qdio *);
130130
extern int zfcp_status_read_refill(struct zfcp_adapter *adapter);
131-
extern int zfcp_fsf_send_ct(struct zfcp_send_ct *, mempool_t *);
132-
extern int zfcp_fsf_send_els(struct zfcp_send_els *);
131+
extern int zfcp_fsf_send_ct(struct zfcp_fc_wka_port *, struct zfcp_fsf_ct_els *,
132+
mempool_t *);
133+
extern int zfcp_fsf_send_els(struct zfcp_adapter *, u32,
134+
struct zfcp_fsf_ct_els *);
133135
extern int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *,
134136
struct scsi_cmnd *);
135137
extern void zfcp_fsf_req_free(struct zfcp_fsf_req *);

0 commit comments

Comments
 (0)