aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libfc/fc_disc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/libfc/fc_disc.c')
-rw-r--r--drivers/scsi/libfc/fc_disc.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c
index c7985da88099..32f67c4b03fc 100644
--- a/drivers/scsi/libfc/fc_disc.c
+++ b/drivers/scsi/libfc/fc_disc.c
@@ -63,27 +63,25 @@ static void fc_disc_restart(struct fc_disc *);
63void fc_disc_stop_rports(struct fc_disc *disc) 63void fc_disc_stop_rports(struct fc_disc *disc)
64{ 64{
65 struct fc_lport *lport; 65 struct fc_lport *lport;
66 struct fc_rport_priv *rdata, *next; 66 struct fc_rport_priv *rdata;
67 67
68 lport = disc->lport; 68 lport = fc_disc_lport(disc);
69 69
70 mutex_lock(&disc->disc_mutex); 70 mutex_lock(&disc->disc_mutex);
71 list_for_each_entry_safe(rdata, next, &disc->rports, peers) 71 list_for_each_entry_rcu(rdata, &disc->rports, peers)
72 lport->tt.rport_logoff(rdata); 72 lport->tt.rport_logoff(rdata);
73 mutex_unlock(&disc->disc_mutex); 73 mutex_unlock(&disc->disc_mutex);
74} 74}
75 75
76/** 76/**
77 * fc_disc_recv_rscn_req() - Handle Registered State Change Notification (RSCN) 77 * fc_disc_recv_rscn_req() - Handle Registered State Change Notification (RSCN)
78 * @sp: The sequence of the RSCN exchange 78 * @disc: The discovery object to which the RSCN applies
79 * @fp: The RSCN frame 79 * @fp: The RSCN frame
80 * @lport: The local port that the request will be sent on
81 * 80 *
82 * Locking Note: This function expects that the disc_mutex is locked 81 * Locking Note: This function expects that the disc_mutex is locked
83 * before it is called. 82 * before it is called.
84 */ 83 */
85static void fc_disc_recv_rscn_req(struct fc_seq *sp, struct fc_frame *fp, 84static void fc_disc_recv_rscn_req(struct fc_disc *disc, struct fc_frame *fp)
86 struct fc_disc *disc)
87{ 85{
88 struct fc_lport *lport; 86 struct fc_lport *lport;
89 struct fc_els_rscn *rp; 87 struct fc_els_rscn *rp;
@@ -96,7 +94,7 @@ static void fc_disc_recv_rscn_req(struct fc_seq *sp, struct fc_frame *fp,
96 LIST_HEAD(disc_ports); 94 LIST_HEAD(disc_ports);
97 struct fc_disc_port *dp, *next; 95 struct fc_disc_port *dp, *next;
98 96
99 lport = disc->lport; 97 lport = fc_disc_lport(disc);
100 98
101 FC_DISC_DBG(disc, "Received an RSCN event\n"); 99 FC_DISC_DBG(disc, "Received an RSCN event\n");
102 100
@@ -151,7 +149,7 @@ static void fc_disc_recv_rscn_req(struct fc_seq *sp, struct fc_frame *fp,
151 break; 149 break;
152 } 150 }
153 } 151 }
154 lport->tt.seq_els_rsp_send(sp, ELS_LS_ACC, NULL); 152 lport->tt.seq_els_rsp_send(fp, ELS_LS_ACC, NULL);
155 153
156 /* 154 /*
157 * If not doing a complete rediscovery, do GPN_ID on 155 * If not doing a complete rediscovery, do GPN_ID on
@@ -177,25 +175,22 @@ static void fc_disc_recv_rscn_req(struct fc_seq *sp, struct fc_frame *fp,
177 return; 175 return;
178reject: 176reject:
179 FC_DISC_DBG(disc, "Received a bad RSCN frame\n"); 177 FC_DISC_DBG(disc, "Received a bad RSCN frame\n");
180 rjt_data.fp = NULL;
181 rjt_data.reason = ELS_RJT_LOGIC; 178 rjt_data.reason = ELS_RJT_LOGIC;
182 rjt_data.explan = ELS_EXPL_NONE; 179 rjt_data.explan = ELS_EXPL_NONE;
183 lport->tt.seq_els_rsp_send(sp, ELS_LS_RJT, &rjt_data); 180 lport->tt.seq_els_rsp_send(fp, ELS_LS_RJT, &rjt_data);
184 fc_frame_free(fp); 181 fc_frame_free(fp);
185} 182}
186 183
187/** 184/**
188 * fc_disc_recv_req() - Handle incoming requests 185 * fc_disc_recv_req() - Handle incoming requests
189 * @sp: The sequence of the request exchange
190 * @fp: The request frame
191 * @lport: The local port receiving the request 186 * @lport: The local port receiving the request
187 * @fp: The request frame
192 * 188 *
193 * Locking Note: This function is called from the EM and will lock 189 * Locking Note: This function is called from the EM and will lock
194 * the disc_mutex before calling the handler for the 190 * the disc_mutex before calling the handler for the
195 * request. 191 * request.
196 */ 192 */
197static void fc_disc_recv_req(struct fc_seq *sp, struct fc_frame *fp, 193static void fc_disc_recv_req(struct fc_lport *lport, struct fc_frame *fp)
198 struct fc_lport *lport)
199{ 194{
200 u8 op; 195 u8 op;
201 struct fc_disc *disc = &lport->disc; 196 struct fc_disc *disc = &lport->disc;
@@ -204,7 +199,7 @@ static void fc_disc_recv_req(struct fc_seq *sp, struct fc_frame *fp,
204 switch (op) { 199 switch (op) {
205 case ELS_RSCN: 200 case ELS_RSCN:
206 mutex_lock(&disc->disc_mutex); 201 mutex_lock(&disc->disc_mutex);
207 fc_disc_recv_rscn_req(sp, fp, disc); 202 fc_disc_recv_rscn_req(disc, fp);
208 mutex_unlock(&disc->disc_mutex); 203 mutex_unlock(&disc->disc_mutex);
209 break; 204 break;
210 default: 205 default:
@@ -275,7 +270,7 @@ static void fc_disc_start(void (*disc_callback)(struct fc_lport *,
275 */ 270 */
276static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event) 271static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event)
277{ 272{
278 struct fc_lport *lport = disc->lport; 273 struct fc_lport *lport = fc_disc_lport(disc);
279 struct fc_rport_priv *rdata; 274 struct fc_rport_priv *rdata;
280 275
281 FC_DISC_DBG(disc, "Discovery complete\n"); 276 FC_DISC_DBG(disc, "Discovery complete\n");
@@ -292,7 +287,7 @@ static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event)
292 * Skip ports which were never discovered. These are the dNS port 287 * Skip ports which were never discovered. These are the dNS port
293 * and ports which were created by PLOGI. 288 * and ports which were created by PLOGI.
294 */ 289 */
295 list_for_each_entry(rdata, &disc->rports, peers) { 290 list_for_each_entry_rcu(rdata, &disc->rports, peers) {
296 if (!rdata->disc_id) 291 if (!rdata->disc_id)
297 continue; 292 continue;
298 if (rdata->disc_id == disc->disc_id) 293 if (rdata->disc_id == disc->disc_id)
@@ -313,7 +308,7 @@ static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event)
313 */ 308 */
314static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp) 309static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp)
315{ 310{
316 struct fc_lport *lport = disc->lport; 311 struct fc_lport *lport = fc_disc_lport(disc);
317 unsigned long delay = 0; 312 unsigned long delay = 0;
318 313
319 FC_DISC_DBG(disc, "Error %ld, retries %d/%d\n", 314 FC_DISC_DBG(disc, "Error %ld, retries %d/%d\n",
@@ -353,7 +348,7 @@ static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp)
353static void fc_disc_gpn_ft_req(struct fc_disc *disc) 348static void fc_disc_gpn_ft_req(struct fc_disc *disc)
354{ 349{
355 struct fc_frame *fp; 350 struct fc_frame *fp;
356 struct fc_lport *lport = disc->lport; 351 struct fc_lport *lport = fc_disc_lport(disc);
357 352
358 WARN_ON(!fc_lport_test_ready(lport)); 353 WARN_ON(!fc_lport_test_ready(lport));
359 354
@@ -396,7 +391,7 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
396 struct fc_rport_identifiers ids; 391 struct fc_rport_identifiers ids;
397 struct fc_rport_priv *rdata; 392 struct fc_rport_priv *rdata;
398 393
399 lport = disc->lport; 394 lport = fc_disc_lport(disc);
400 disc->seq_count++; 395 disc->seq_count++;
401 396
402 /* 397 /*
@@ -733,7 +728,7 @@ int fc_disc_init(struct fc_lport *lport)
733 mutex_init(&disc->disc_mutex); 728 mutex_init(&disc->disc_mutex);
734 INIT_LIST_HEAD(&disc->rports); 729 INIT_LIST_HEAD(&disc->rports);
735 730
736 disc->lport = lport; 731 disc->priv = lport;
737 732
738 return 0; 733 return 0;
739} 734}