Skip to content

Commit bd0072e

Browse files
Christof SchmittJames Bottomley
authored andcommitted
[SCSI] zfcp: Move WKA port to zfcp FC code
The well-known-address (WKA) port handling code is part of the FC code in zfcp. Move everything WKA related to the zfcp_fc files and use the common zfcp_fc prefix for structs and functions. Drop the unused key management service while renaming the struct, no request could ever reach this service in zfcp and it is obsolete anyway. Reviewed-by: Swen Schillig <[email protected]> Signed-off-by: Christof Schmitt <[email protected]> Signed-off-by: James Bottomley <[email protected]>
1 parent dbf5dfe commit bd0072e

File tree

6 files changed

+90
-68
lines changed

6 files changed

+90
-68
lines changed

drivers/s390/scsi/zfcp_dbf.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <asm/debug.h>
1414
#include "zfcp_dbf.h"
1515
#include "zfcp_ext.h"
16+
#include "zfcp_fc.h"
1617

1718
static u32 dbfsize = 4;
1819

@@ -681,7 +682,7 @@ void zfcp_dbf_rec_action(char *id2, struct zfcp_erp_action *erp_action)
681682
void zfcp_dbf_san_ct_request(struct zfcp_fsf_req *fsf_req)
682683
{
683684
struct zfcp_send_ct *ct = (struct zfcp_send_ct *)fsf_req->data;
684-
struct zfcp_wka_port *wka_port = ct->wka_port;
685+
struct zfcp_fc_wka_port *wka_port = ct->wka_port;
685686
struct zfcp_adapter *adapter = wka_port->adapter;
686687
struct zfcp_dbf *dbf = adapter->dbf;
687688
struct fc_ct_hdr *hdr = sg_virt(ct->req);
@@ -718,7 +719,7 @@ void zfcp_dbf_san_ct_request(struct zfcp_fsf_req *fsf_req)
718719
void zfcp_dbf_san_ct_response(struct zfcp_fsf_req *fsf_req)
719720
{
720721
struct zfcp_send_ct *ct = (struct zfcp_send_ct *)fsf_req->data;
721-
struct zfcp_wka_port *wka_port = ct->wka_port;
722+
struct zfcp_fc_wka_port *wka_port = ct->wka_port;
722723
struct zfcp_adapter *adapter = wka_port->adapter;
723724
struct fc_ct_hdr *hdr = sg_virt(ct->resp);
724725
struct zfcp_dbf *dbf = adapter->dbf;

drivers/s390/scsi/zfcp_def.h

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,6 @@
104104
#define ZFCP_STATUS_PORT_PHYS_OPEN 0x00000001
105105
#define ZFCP_STATUS_PORT_LINK_TEST 0x00000002
106106

107-
/* well known address (WKA) port status*/
108-
enum zfcp_wka_status {
109-
ZFCP_WKA_PORT_OFFLINE,
110-
ZFCP_WKA_PORT_CLOSING,
111-
ZFCP_WKA_PORT_OPENING,
112-
ZFCP_WKA_PORT_ONLINE,
113-
};
114-
115107
/* logical unit status */
116108
#define ZFCP_STATUS_UNIT_SHARED 0x00000004
117109
#define ZFCP_STATUS_UNIT_READONLY 0x00000008
@@ -155,7 +147,7 @@ struct zfcp_adapter_mempool {
155147
* @status: used to pass error status to calling function
156148
*/
157149
struct zfcp_send_ct {
158-
struct zfcp_wka_port *wka_port;
150+
struct zfcp_fc_wka_port *wka_port;
159151
struct scatterlist *req;
160152
struct scatterlist *resp;
161153
void (*handler)(unsigned long);
@@ -190,25 +182,6 @@ struct zfcp_send_els {
190182
int status;
191183
};
192184

193-
struct zfcp_wka_port {
194-
struct zfcp_adapter *adapter;
195-
wait_queue_head_t completion_wq;
196-
enum zfcp_wka_status status;
197-
atomic_t refcount;
198-
u32 d_id;
199-
u32 handle;
200-
struct mutex mutex;
201-
struct delayed_work work;
202-
};
203-
204-
struct zfcp_wka_ports {
205-
struct zfcp_wka_port ms; /* management service */
206-
struct zfcp_wka_port ts; /* time service */
207-
struct zfcp_wka_port ds; /* directory service */
208-
struct zfcp_wka_port as; /* alias service */
209-
struct zfcp_wka_port ks; /* key distribution service */
210-
};
211-
212185
struct zfcp_qdio_queue {
213186
struct qdio_buffer *sbal[QDIO_MAX_BUFFERS_PER_Q];
214187
u8 first; /* index of next free bfr in queue */
@@ -309,7 +282,7 @@ struct zfcp_adapter {
309282
u32 erp_low_mem_count; /* nr of erp actions waiting
310283
for memory */
311284
struct task_struct *erp_thread;
312-
struct zfcp_wka_ports *gs; /* generic services */
285+
struct zfcp_fc_wka_ports *gs; /* generic services */
313286
struct zfcp_dbf *dbf; /* debug traces */
314287
struct zfcp_adapter_mempool pool; /* Adapter memory pools */
315288
struct fc_host_statistics *fc_stats;

drivers/s390/scsi/zfcp_ext.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,16 @@ extern void zfcp_fc_trigger_did_lookup(struct zfcp_port *);
103103
extern void zfcp_fc_plogi_evaluate(struct zfcp_port *, struct fc_els_flogi *);
104104
extern void zfcp_fc_test_link(struct zfcp_port *);
105105
extern void zfcp_fc_link_test_work(struct work_struct *);
106-
extern void zfcp_fc_wka_ports_force_offline(struct zfcp_wka_ports *);
106+
extern void zfcp_fc_wka_ports_force_offline(struct zfcp_fc_wka_ports *);
107107
extern int zfcp_fc_gs_setup(struct zfcp_adapter *);
108108
extern void zfcp_fc_gs_destroy(struct zfcp_adapter *);
109109
extern int zfcp_fc_execute_els_fc_job(struct fc_bsg_job *);
110110
extern int zfcp_fc_execute_ct_fc_job(struct fc_bsg_job *);
111111

112112
/* zfcp_fsf.c */
113113
extern int zfcp_fsf_open_port(struct zfcp_erp_action *);
114-
extern int zfcp_fsf_open_wka_port(struct zfcp_wka_port *);
115-
extern int zfcp_fsf_close_wka_port(struct zfcp_wka_port *);
114+
extern int zfcp_fsf_open_wka_port(struct zfcp_fc_wka_port *);
115+
extern int zfcp_fsf_close_wka_port(struct zfcp_fc_wka_port *);
116116
extern int zfcp_fsf_close_port(struct zfcp_erp_action *);
117117
extern int zfcp_fsf_close_physical_port(struct zfcp_erp_action *);
118118
extern int zfcp_fsf_open_unit(struct zfcp_erp_action *);

drivers/s390/scsi/zfcp_fc.c

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,25 @@ struct zfcp_fc_ns_handler_data {
2828
unsigned long handler_data;
2929
};
3030

31-
static int zfcp_fc_wka_port_get(struct zfcp_wka_port *wka_port)
31+
static int zfcp_fc_wka_port_get(struct zfcp_fc_wka_port *wka_port)
3232
{
3333
if (mutex_lock_interruptible(&wka_port->mutex))
3434
return -ERESTARTSYS;
3535

36-
if (wka_port->status == ZFCP_WKA_PORT_OFFLINE ||
37-
wka_port->status == ZFCP_WKA_PORT_CLOSING) {
38-
wka_port->status = ZFCP_WKA_PORT_OPENING;
36+
if (wka_port->status == ZFCP_FC_WKA_PORT_OFFLINE ||
37+
wka_port->status == ZFCP_FC_WKA_PORT_CLOSING) {
38+
wka_port->status = ZFCP_FC_WKA_PORT_OPENING;
3939
if (zfcp_fsf_open_wka_port(wka_port))
40-
wka_port->status = ZFCP_WKA_PORT_OFFLINE;
40+
wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE;
4141
}
4242

4343
mutex_unlock(&wka_port->mutex);
4444

4545
wait_event(wka_port->completion_wq,
46-
wka_port->status == ZFCP_WKA_PORT_ONLINE ||
47-
wka_port->status == ZFCP_WKA_PORT_OFFLINE);
46+
wka_port->status == ZFCP_FC_WKA_PORT_ONLINE ||
47+
wka_port->status == ZFCP_FC_WKA_PORT_OFFLINE);
4848

49-
if (wka_port->status == ZFCP_WKA_PORT_ONLINE) {
49+
if (wka_port->status == ZFCP_FC_WKA_PORT_ONLINE) {
5050
atomic_inc(&wka_port->refcount);
5151
return 0;
5252
}
@@ -56,62 +56,61 @@ static int zfcp_fc_wka_port_get(struct zfcp_wka_port *wka_port)
5656
static void zfcp_fc_wka_port_offline(struct work_struct *work)
5757
{
5858
struct delayed_work *dw = to_delayed_work(work);
59-
struct zfcp_wka_port *wka_port =
60-
container_of(dw, struct zfcp_wka_port, work);
59+
struct zfcp_fc_wka_port *wka_port =
60+
container_of(dw, struct zfcp_fc_wka_port, work);
6161

6262
mutex_lock(&wka_port->mutex);
6363
if ((atomic_read(&wka_port->refcount) != 0) ||
64-
(wka_port->status != ZFCP_WKA_PORT_ONLINE))
64+
(wka_port->status != ZFCP_FC_WKA_PORT_ONLINE))
6565
goto out;
6666

67-
wka_port->status = ZFCP_WKA_PORT_CLOSING;
67+
wka_port->status = ZFCP_FC_WKA_PORT_CLOSING;
6868
if (zfcp_fsf_close_wka_port(wka_port)) {
69-
wka_port->status = ZFCP_WKA_PORT_OFFLINE;
69+
wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE;
7070
wake_up(&wka_port->completion_wq);
7171
}
7272
out:
7373
mutex_unlock(&wka_port->mutex);
7474
}
7575

76-
static void zfcp_fc_wka_port_put(struct zfcp_wka_port *wka_port)
76+
static void zfcp_fc_wka_port_put(struct zfcp_fc_wka_port *wka_port)
7777
{
7878
if (atomic_dec_return(&wka_port->refcount) != 0)
7979
return;
8080
/* wait 10 milliseconds, other reqs might pop in */
8181
schedule_delayed_work(&wka_port->work, HZ / 100);
8282
}
8383

84-
static void zfcp_fc_wka_port_init(struct zfcp_wka_port *wka_port, u32 d_id,
84+
static void zfcp_fc_wka_port_init(struct zfcp_fc_wka_port *wka_port, u32 d_id,
8585
struct zfcp_adapter *adapter)
8686
{
8787
init_waitqueue_head(&wka_port->completion_wq);
8888

8989
wka_port->adapter = adapter;
9090
wka_port->d_id = d_id;
9191

92-
wka_port->status = ZFCP_WKA_PORT_OFFLINE;
92+
wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE;
9393
atomic_set(&wka_port->refcount, 0);
9494
mutex_init(&wka_port->mutex);
9595
INIT_DELAYED_WORK(&wka_port->work, zfcp_fc_wka_port_offline);
9696
}
9797

98-
static void zfcp_fc_wka_port_force_offline(struct zfcp_wka_port *wka)
98+
static void zfcp_fc_wka_port_force_offline(struct zfcp_fc_wka_port *wka)
9999
{
100100
cancel_delayed_work_sync(&wka->work);
101101
mutex_lock(&wka->mutex);
102-
wka->status = ZFCP_WKA_PORT_OFFLINE;
102+
wka->status = ZFCP_FC_WKA_PORT_OFFLINE;
103103
mutex_unlock(&wka->mutex);
104104
}
105105

106-
void zfcp_fc_wka_ports_force_offline(struct zfcp_wka_ports *gs)
106+
void zfcp_fc_wka_ports_force_offline(struct zfcp_fc_wka_ports *gs)
107107
{
108108
if (!gs)
109109
return;
110110
zfcp_fc_wka_port_force_offline(&gs->ms);
111111
zfcp_fc_wka_port_force_offline(&gs->ts);
112112
zfcp_fc_wka_port_force_offline(&gs->ds);
113113
zfcp_fc_wka_port_force_offline(&gs->as);
114-
zfcp_fc_wka_port_force_offline(&gs->ks);
115114
}
116115

117116
static void _zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req, u32 range,
@@ -834,9 +833,9 @@ int zfcp_fc_execute_ct_fc_job(struct fc_bsg_job *job)
834833

835834
int zfcp_fc_gs_setup(struct zfcp_adapter *adapter)
836835
{
837-
struct zfcp_wka_ports *wka_ports;
836+
struct zfcp_fc_wka_ports *wka_ports;
838837

839-
wka_ports = kzalloc(sizeof(struct zfcp_wka_ports), GFP_KERNEL);
838+
wka_ports = kzalloc(sizeof(struct zfcp_fc_wka_ports), GFP_KERNEL);
840839
if (!wka_ports)
841840
return -ENOMEM;
842841

@@ -845,7 +844,6 @@ int zfcp_fc_gs_setup(struct zfcp_adapter *adapter)
845844
zfcp_fc_wka_port_init(&wka_ports->ts, FC_FID_TIME_SERV, adapter);
846845
zfcp_fc_wka_port_init(&wka_ports->ds, FC_FID_DIR_SERV, adapter);
847846
zfcp_fc_wka_port_init(&wka_ports->as, FC_FID_ALIASES, adapter);
848-
zfcp_fc_wka_port_init(&wka_ports->ks, FC_FID_SEC_KEY, adapter);
849847

850848
return 0;
851849
}

drivers/s390/scsi/zfcp_fc.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,56 @@ struct zfcp_fc_els_adisc {
111111
struct fc_els_adisc adisc_resp;
112112
};
113113

114+
/**
115+
* enum zfcp_fc_wka_status - FC WKA port status in zfcp
116+
* @ZFCP_FC_WKA_PORT_OFFLINE: Port is closed and not in use
117+
* @ZFCP_FC_WKA_PORT_CLOSING: The FSF "close port" request is pending
118+
* @ZFCP_FC_WKA_PORT_OPENING: The FSF "open port" request is pending
119+
* @ZFCP_FC_WKA_PORT_ONLINE: The port is open and the port handle is valid
120+
*/
121+
enum zfcp_fc_wka_status {
122+
ZFCP_FC_WKA_PORT_OFFLINE,
123+
ZFCP_FC_WKA_PORT_CLOSING,
124+
ZFCP_FC_WKA_PORT_OPENING,
125+
ZFCP_FC_WKA_PORT_ONLINE,
126+
};
127+
128+
/**
129+
* struct zfcp_fc_wka_port - representation of well-known-address (WKA) FC port
130+
* @adapter: Pointer to adapter structure this WKA port belongs to
131+
* @completion_wq: Wait for completion of open/close command
132+
* @status: Current status of WKA port
133+
* @refcount: Reference count to keep port open as long as it is in use
134+
* @d_id: FC destination id or well-known-address
135+
* @handle: FSF handle for the open WKA port
136+
* @mutex: Mutex used during opening/closing state changes
137+
* @work: For delaying the closing of the WKA port
138+
*/
139+
struct zfcp_fc_wka_port {
140+
struct zfcp_adapter *adapter;
141+
wait_queue_head_t completion_wq;
142+
enum zfcp_fc_wka_status status;
143+
atomic_t refcount;
144+
u32 d_id;
145+
u32 handle;
146+
struct mutex mutex;
147+
struct delayed_work work;
148+
};
149+
150+
/**
151+
* struct zfcp_fc_wka_ports - Data structures for FC generic services
152+
* @ms: FC Management service
153+
* @ts: FC time service
154+
* @ds: FC directory service
155+
* @as: FC alias service
156+
*/
157+
struct zfcp_fc_wka_ports {
158+
struct zfcp_fc_wka_port ms;
159+
struct zfcp_fc_wka_port ts;
160+
struct zfcp_fc_wka_port ds;
161+
struct zfcp_fc_wka_port as;
162+
};
163+
114164
/**
115165
* zfcp_fc_scsi_to_fcp - setup FCP command with data from scsi_cmnd
116166
* @fcp: fcp_cmnd to setup

drivers/s390/scsi/zfcp_fsf.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ static int zfcp_fsf_setup_ct_els(struct zfcp_fsf_req *req,
10961096
*/
10971097
int zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool)
10981098
{
1099-
struct zfcp_wka_port *wka_port = ct->wka_port;
1099+
struct zfcp_fc_wka_port *wka_port = ct->wka_port;
11001100
struct zfcp_qdio *qdio = wka_port->adapter->qdio;
11011101
struct zfcp_fsf_req *req;
11021102
int ret = -EIO;
@@ -1610,11 +1610,11 @@ int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
16101610

16111611
static void zfcp_fsf_open_wka_port_handler(struct zfcp_fsf_req *req)
16121612
{
1613-
struct zfcp_wka_port *wka_port = req->data;
1613+
struct zfcp_fc_wka_port *wka_port = req->data;
16141614
struct fsf_qtcb_header *header = &req->qtcb->header;
16151615

16161616
if (req->status & ZFCP_STATUS_FSFREQ_ERROR) {
1617-
wka_port->status = ZFCP_WKA_PORT_OFFLINE;
1617+
wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE;
16181618
goto out;
16191619
}
16201620

@@ -1627,24 +1627,24 @@ static void zfcp_fsf_open_wka_port_handler(struct zfcp_fsf_req *req)
16271627
req->status |= ZFCP_STATUS_FSFREQ_ERROR;
16281628
/* fall through */
16291629
case FSF_ACCESS_DENIED:
1630-
wka_port->status = ZFCP_WKA_PORT_OFFLINE;
1630+
wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE;
16311631
break;
16321632
case FSF_GOOD:
16331633
wka_port->handle = header->port_handle;
16341634
/* fall through */
16351635
case FSF_PORT_ALREADY_OPEN:
1636-
wka_port->status = ZFCP_WKA_PORT_ONLINE;
1636+
wka_port->status = ZFCP_FC_WKA_PORT_ONLINE;
16371637
}
16381638
out:
16391639
wake_up(&wka_port->completion_wq);
16401640
}
16411641

16421642
/**
16431643
* zfcp_fsf_open_wka_port - create and send open wka-port request
1644-
* @wka_port: pointer to struct zfcp_wka_port
1644+
* @wka_port: pointer to struct zfcp_fc_wka_port
16451645
* Returns: 0 on success, error otherwise
16461646
*/
1647-
int zfcp_fsf_open_wka_port(struct zfcp_wka_port *wka_port)
1647+
int zfcp_fsf_open_wka_port(struct zfcp_fc_wka_port *wka_port)
16481648
{
16491649
struct qdio_buffer_element *sbale;
16501650
struct zfcp_qdio *qdio = wka_port->adapter->qdio;
@@ -1683,23 +1683,23 @@ int zfcp_fsf_open_wka_port(struct zfcp_wka_port *wka_port)
16831683

16841684
static void zfcp_fsf_close_wka_port_handler(struct zfcp_fsf_req *req)
16851685
{
1686-
struct zfcp_wka_port *wka_port = req->data;
1686+
struct zfcp_fc_wka_port *wka_port = req->data;
16871687

16881688
if (req->qtcb->header.fsf_status == FSF_PORT_HANDLE_NOT_VALID) {
16891689
req->status |= ZFCP_STATUS_FSFREQ_ERROR;
16901690
zfcp_erp_adapter_reopen(wka_port->adapter, 0, "fscwph1", req);
16911691
}
16921692

1693-
wka_port->status = ZFCP_WKA_PORT_OFFLINE;
1693+
wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE;
16941694
wake_up(&wka_port->completion_wq);
16951695
}
16961696

16971697
/**
16981698
* zfcp_fsf_close_wka_port - create and send close wka port request
1699-
* @erp_action: pointer to struct zfcp_erp_action
1699+
* @wka_port: WKA port to open
17001700
* Returns: 0 on success, error otherwise
17011701
*/
1702-
int zfcp_fsf_close_wka_port(struct zfcp_wka_port *wka_port)
1702+
int zfcp_fsf_close_wka_port(struct zfcp_fc_wka_port *wka_port)
17031703
{
17041704
struct qdio_buffer_element *sbale;
17051705
struct zfcp_qdio *qdio = wka_port->adapter->qdio;

0 commit comments

Comments
 (0)