aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libfc
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/libfc')
-rw-r--r--drivers/scsi/libfc/fc_disc.c83
-rw-r--r--drivers/scsi/libfc/fc_exch.c58
-rw-r--r--drivers/scsi/libfc/fc_fcp.c97
-rw-r--r--drivers/scsi/libfc/fc_lport.c156
-rw-r--r--drivers/scsi/libfc/fc_rport.c120
5 files changed, 235 insertions, 279 deletions
diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c
index 4c880656990b..6fabf66972b9 100644
--- a/drivers/scsi/libfc/fc_disc.c
+++ b/drivers/scsi/libfc/fc_disc.c
@@ -45,14 +45,6 @@
45 45
46#define FC_DISC_DELAY 3 46#define FC_DISC_DELAY 3
47 47
48static int fc_disc_debug;
49
50#define FC_DEBUG_DISC(fmt...) \
51 do { \
52 if (fc_disc_debug) \
53 FC_DBG(fmt); \
54 } while (0)
55
56static void fc_disc_gpn_ft_req(struct fc_disc *); 48static void fc_disc_gpn_ft_req(struct fc_disc *);
57static void fc_disc_gpn_ft_resp(struct fc_seq *, struct fc_frame *, void *); 49static void fc_disc_gpn_ft_resp(struct fc_seq *, struct fc_frame *, void *);
58static int fc_disc_new_target(struct fc_disc *, struct fc_rport *, 50static int fc_disc_new_target(struct fc_disc *, struct fc_rport *,
@@ -137,8 +129,8 @@ static void fc_disc_rport_callback(struct fc_lport *lport,
137 struct fc_rport_libfc_priv *rdata = rport->dd_data; 129 struct fc_rport_libfc_priv *rdata = rport->dd_data;
138 struct fc_disc *disc = &lport->disc; 130 struct fc_disc *disc = &lport->disc;
139 131
140 FC_DEBUG_DISC("Received a %d event for port (%6x)\n", event, 132 FC_DISC_DBG(disc, "Received a %d event for port (%6x)\n", event,
141 rport->port_id); 133 rport->port_id);
142 134
143 switch (event) { 135 switch (event) {
144 case RPORT_EV_CREATED: 136 case RPORT_EV_CREATED:
@@ -191,8 +183,7 @@ static void fc_disc_recv_rscn_req(struct fc_seq *sp, struct fc_frame *fp,
191 183
192 lport = disc->lport; 184 lport = disc->lport;
193 185
194 FC_DEBUG_DISC("Received an RSCN event on port (%6x)\n", 186 FC_DISC_DBG(disc, "Received an RSCN event\n");
195 fc_host_port_id(lport->host));
196 187
197 /* make sure the frame contains an RSCN message */ 188 /* make sure the frame contains an RSCN message */
198 rp = fc_frame_payload_get(fp, sizeof(*rp)); 189 rp = fc_frame_payload_get(fp, sizeof(*rp));
@@ -225,8 +216,8 @@ static void fc_disc_recv_rscn_req(struct fc_seq *sp, struct fc_frame *fp,
225 */ 216 */
226 switch (fmt) { 217 switch (fmt) {
227 case ELS_ADDR_FMT_PORT: 218 case ELS_ADDR_FMT_PORT:
228 FC_DEBUG_DISC("Port address format for port (%6x)\n", 219 FC_DISC_DBG(disc, "Port address format for port "
229 ntoh24(pp->rscn_fid)); 220 "(%6x)\n", ntoh24(pp->rscn_fid));
230 dp = kzalloc(sizeof(*dp), GFP_KERNEL); 221 dp = kzalloc(sizeof(*dp), GFP_KERNEL);
231 if (!dp) { 222 if (!dp) {
232 redisc = 1; 223 redisc = 1;
@@ -243,19 +234,19 @@ static void fc_disc_recv_rscn_req(struct fc_seq *sp, struct fc_frame *fp,
243 case ELS_ADDR_FMT_DOM: 234 case ELS_ADDR_FMT_DOM:
244 case ELS_ADDR_FMT_FAB: 235 case ELS_ADDR_FMT_FAB:
245 default: 236 default:
246 FC_DEBUG_DISC("Address format is (%d)\n", fmt); 237 FC_DISC_DBG(disc, "Address format is (%d)\n", fmt);
247 redisc = 1; 238 redisc = 1;
248 break; 239 break;
249 } 240 }
250 } 241 }
251 lport->tt.seq_els_rsp_send(sp, ELS_LS_ACC, NULL); 242 lport->tt.seq_els_rsp_send(sp, ELS_LS_ACC, NULL);
252 if (redisc) { 243 if (redisc) {
253 FC_DEBUG_DISC("RSCN received: rediscovering\n"); 244 FC_DISC_DBG(disc, "RSCN received: rediscovering\n");
254 fc_disc_restart(disc); 245 fc_disc_restart(disc);
255 } else { 246 } else {
256 FC_DEBUG_DISC("RSCN received: not rediscovering. " 247 FC_DISC_DBG(disc, "RSCN received: not rediscovering. "
257 "redisc %d state %d in_prog %d\n", 248 "redisc %d state %d in_prog %d\n",
258 redisc, lport->state, disc->pending); 249 redisc, lport->state, disc->pending);
259 list_for_each_entry_safe(dp, next, &disc_ports, peers) { 250 list_for_each_entry_safe(dp, next, &disc_ports, peers) {
260 list_del(&dp->peers); 251 list_del(&dp->peers);
261 rport = lport->tt.rport_lookup(lport, dp->ids.port_id); 252 rport = lport->tt.rport_lookup(lport, dp->ids.port_id);
@@ -270,7 +261,7 @@ static void fc_disc_recv_rscn_req(struct fc_seq *sp, struct fc_frame *fp,
270 fc_frame_free(fp); 261 fc_frame_free(fp);
271 return; 262 return;
272reject: 263reject:
273 FC_DEBUG_DISC("Received a bad RSCN frame\n"); 264 FC_DISC_DBG(disc, "Received a bad RSCN frame\n");
274 rjt_data.fp = NULL; 265 rjt_data.fp = NULL;
275 rjt_data.reason = ELS_RJT_LOGIC; 266 rjt_data.reason = ELS_RJT_LOGIC;
276 rjt_data.explan = ELS_EXPL_NONE; 267 rjt_data.explan = ELS_EXPL_NONE;
@@ -302,7 +293,8 @@ static void fc_disc_recv_req(struct fc_seq *sp, struct fc_frame *fp,
302 mutex_unlock(&disc->disc_mutex); 293 mutex_unlock(&disc->disc_mutex);
303 break; 294 break;
304 default: 295 default:
305 FC_DBG("Received an unsupported request. opcode (%x)\n", op); 296 FC_DISC_DBG(disc, "Received an unsupported request, "
297 "the opcode is (%x)\n", op);
306 break; 298 break;
307 } 299 }
308} 300}
@@ -320,12 +312,10 @@ static void fc_disc_restart(struct fc_disc *disc)
320 struct fc_rport_libfc_priv *rdata, *next; 312 struct fc_rport_libfc_priv *rdata, *next;
321 struct fc_lport *lport = disc->lport; 313 struct fc_lport *lport = disc->lport;
322 314
323 FC_DEBUG_DISC("Restarting discovery for port (%6x)\n", 315 FC_DISC_DBG(disc, "Restarting discovery\n");
324 fc_host_port_id(lport->host));
325 316
326 list_for_each_entry_safe(rdata, next, &disc->rports, peers) { 317 list_for_each_entry_safe(rdata, next, &disc->rports, peers) {
327 rport = PRIV_TO_RPORT(rdata); 318 rport = PRIV_TO_RPORT(rdata);
328 FC_DEBUG_DISC("list_del(%6x)\n", rport->port_id);
329 list_del(&rdata->peers); 319 list_del(&rdata->peers);
330 lport->tt.rport_logoff(rport); 320 lport->tt.rport_logoff(rport);
331 } 321 }
@@ -485,8 +475,7 @@ static void fc_disc_done(struct fc_disc *disc)
485 struct fc_lport *lport = disc->lport; 475 struct fc_lport *lport = disc->lport;
486 enum fc_disc_event event; 476 enum fc_disc_event event;
487 477
488 FC_DEBUG_DISC("Discovery complete for port (%6x)\n", 478 FC_DISC_DBG(disc, "Discovery complete\n");
489 fc_host_port_id(lport->host));
490 479
491 event = disc->event; 480 event = disc->event;
492 disc->event = DISC_EV_NONE; 481 disc->event = DISC_EV_NONE;
@@ -510,10 +499,10 @@ static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp)
510{ 499{
511 struct fc_lport *lport = disc->lport; 500 struct fc_lport *lport = disc->lport;
512 unsigned long delay = 0; 501 unsigned long delay = 0;
513 if (fc_disc_debug) 502
514 FC_DBG("Error %ld, retries %d/%d\n", 503 FC_DISC_DBG(disc, "Error %ld, retries %d/%d\n",
515 PTR_ERR(fp), disc->retry_count, 504 PTR_ERR(fp), disc->retry_count,
516 FC_DISC_RETRY_LIMIT); 505 FC_DISC_RETRY_LIMIT);
517 506
518 if (!fp || PTR_ERR(fp) == -FC_EX_TIMEOUT) { 507 if (!fp || PTR_ERR(fp) == -FC_EX_TIMEOUT) {
519 /* 508 /*
@@ -649,9 +638,9 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
649 &disc->rogue_rports); 638 &disc->rogue_rports);
650 lport->tt.rport_login(rport); 639 lport->tt.rport_login(rport);
651 } else 640 } else
652 FC_DBG("Failed to allocate memory for " 641 printk(KERN_WARNING "libfc: Failed to allocate "
653 "the newly discovered port (%6x)\n", 642 "memory for the newly discovered port "
654 dp.ids.port_id); 643 "(%6x)\n", dp.ids.port_id);
655 } 644 }
656 645
657 if (np->fp_flags & FC_NS_FID_LAST) { 646 if (np->fp_flags & FC_NS_FID_LAST) {
@@ -671,9 +660,8 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
671 */ 660 */
672 if (error == 0 && len > 0 && len < sizeof(*np)) { 661 if (error == 0 && len > 0 && len < sizeof(*np)) {
673 if (np != &disc->partial_buf) { 662 if (np != &disc->partial_buf) {
674 FC_DEBUG_DISC("Partial buffer remains " 663 FC_DISC_DBG(disc, "Partial buffer remains "
675 "for discovery by (%6x)\n", 664 "for discovery\n");
676 fc_host_port_id(lport->host));
677 memcpy(&disc->partial_buf, np, len); 665 memcpy(&disc->partial_buf, np, len);
678 } 666 }
679 disc->buf_len = (unsigned char) len; 667 disc->buf_len = (unsigned char) len;
@@ -721,8 +709,7 @@ static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp,
721 int error; 709 int error;
722 710
723 mutex_lock(&disc->disc_mutex); 711 mutex_lock(&disc->disc_mutex);
724 FC_DEBUG_DISC("Received a GPN_FT response on port (%6x)\n", 712 FC_DISC_DBG(disc, "Received a GPN_FT response\n");
725 fc_host_port_id(disc->lport->host));
726 713
727 if (IS_ERR(fp)) { 714 if (IS_ERR(fp)) {
728 fc_disc_error(disc, fp); 715 fc_disc_error(disc, fp);
@@ -738,30 +725,30 @@ static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp,
738 disc->seq_count == 0) { 725 disc->seq_count == 0) {
739 cp = fc_frame_payload_get(fp, sizeof(*cp)); 726 cp = fc_frame_payload_get(fp, sizeof(*cp));
740 if (!cp) { 727 if (!cp) {
741 FC_DBG("GPN_FT response too short, len %d\n", 728 FC_DISC_DBG(disc, "GPN_FT response too short, len %d\n",
742 fr_len(fp)); 729 fr_len(fp));
743 } else if (ntohs(cp->ct_cmd) == FC_FS_ACC) { 730 } else if (ntohs(cp->ct_cmd) == FC_FS_ACC) {
744 731
745 /* Accepted, parse the response. */ 732 /* Accepted, parse the response. */
746 buf = cp + 1; 733 buf = cp + 1;
747 len -= sizeof(*cp); 734 len -= sizeof(*cp);
748 } else if (ntohs(cp->ct_cmd) == FC_FS_RJT) { 735 } else if (ntohs(cp->ct_cmd) == FC_FS_RJT) {
749 FC_DBG("GPN_FT rejected reason %x exp %x " 736 FC_DISC_DBG(disc, "GPN_FT rejected reason %x exp %x "
750 "(check zoning)\n", cp->ct_reason, 737 "(check zoning)\n", cp->ct_reason,
751 cp->ct_explan); 738 cp->ct_explan);
752 disc->event = DISC_EV_FAILED; 739 disc->event = DISC_EV_FAILED;
753 fc_disc_done(disc); 740 fc_disc_done(disc);
754 } else { 741 } else {
755 FC_DBG("GPN_FT unexpected response code %x\n", 742 FC_DISC_DBG(disc, "GPN_FT unexpected response code "
756 ntohs(cp->ct_cmd)); 743 "%x\n", ntohs(cp->ct_cmd));
757 } 744 }
758 } else if (fr_sof(fp) == FC_SOF_N3 && 745 } else if (fr_sof(fp) == FC_SOF_N3 &&
759 seq_cnt == disc->seq_count) { 746 seq_cnt == disc->seq_count) {
760 buf = fh + 1; 747 buf = fh + 1;
761 } else { 748 } else {
762 FC_DBG("GPN_FT unexpected frame - out of sequence? " 749 FC_DISC_DBG(disc, "GPN_FT unexpected frame - out of sequence? "
763 "seq_cnt %x expected %x sof %x eof %x\n", 750 "seq_cnt %x expected %x sof %x eof %x\n",
764 seq_cnt, disc->seq_count, fr_sof(fp), fr_eof(fp)); 751 seq_cnt, disc->seq_count, fr_sof(fp), fr_eof(fp));
765 } 752 }
766 if (buf) { 753 if (buf) {
767 error = fc_disc_gpn_ft_parse(disc, buf, len); 754 error = fc_disc_gpn_ft_parse(disc, buf, len);
diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
index 7af9bceb8aa9..2bc22be5f849 100644
--- a/drivers/scsi/libfc/fc_exch.c
+++ b/drivers/scsi/libfc/fc_exch.c
@@ -32,18 +32,7 @@
32#include <scsi/libfc.h> 32#include <scsi/libfc.h>
33#include <scsi/fc_encode.h> 33#include <scsi/fc_encode.h>
34 34
35/* 35static struct kmem_cache *fc_em_cachep; /* cache for exchanges */
36 * fc_exch_debug can be set in debugger or at compile time to get more logs.
37 */
38static int fc_exch_debug;
39
40#define FC_DEBUG_EXCH(fmt...) \
41 do { \
42 if (fc_exch_debug) \
43 FC_DBG(fmt); \
44 } while (0)
45
46static struct kmem_cache *fc_em_cachep; /* cache for exchanges */
47 36
48/* 37/*
49 * Structure and function definitions for managing Fibre Channel Exchanges 38 * Structure and function definitions for managing Fibre Channel Exchanges
@@ -333,8 +322,8 @@ static inline void fc_exch_timer_set_locked(struct fc_exch *ep,
333 if (ep->state & (FC_EX_RST_CLEANUP | FC_EX_DONE)) 322 if (ep->state & (FC_EX_RST_CLEANUP | FC_EX_DONE))
334 return; 323 return;
335 324
336 FC_DEBUG_EXCH("Exchange (%4x) timed out, notifying the upper layer\n", 325 FC_EXCH_DBG(ep, "Exchange timed out, notifying the upper layer\n");
337 ep->xid); 326
338 if (schedule_delayed_work(&ep->timeout_work, 327 if (schedule_delayed_work(&ep->timeout_work,
339 msecs_to_jiffies(timer_msec))) 328 msecs_to_jiffies(timer_msec)))
340 fc_exch_hold(ep); /* hold for timer */ 329 fc_exch_hold(ep); /* hold for timer */
@@ -545,7 +534,7 @@ struct fc_exch *fc_exch_alloc(struct fc_exch_mgr *mp,
545 /* alloc a new xid */ 534 /* alloc a new xid */
546 xid = fc_em_alloc_xid(mp, fp); 535 xid = fc_em_alloc_xid(mp, fp);
547 if (!xid) { 536 if (!xid) {
548 printk(KERN_ERR "fc_em_alloc_xid() failed\n"); 537 printk(KERN_WARNING "libfc: Failed to allocate an exhange\n");
549 goto err; 538 goto err;
550 } 539 }
551 } 540 }
@@ -820,8 +809,8 @@ static struct fc_seq *fc_seq_start_next_locked(struct fc_seq *sp)
820 struct fc_exch *ep = fc_seq_exch(sp); 809 struct fc_exch *ep = fc_seq_exch(sp);
821 810
822 sp = fc_seq_alloc(ep, ep->seq_id++); 811 sp = fc_seq_alloc(ep, ep->seq_id++);
823 FC_DEBUG_EXCH("exch %4x f_ctl %6x seq %2x\n", 812 FC_EXCH_DBG(ep, "f_ctl %6x seq %2x\n",
824 ep->xid, ep->f_ctl, sp->id); 813 ep->f_ctl, sp->id);
825 return sp; 814 return sp;
826} 815}
827/* 816/*
@@ -901,7 +890,7 @@ void fc_seq_els_rsp_send(struct fc_seq *sp, enum fc_els_cmd els_cmd,
901 fc_exch_els_rec(sp, els_data->fp); 890 fc_exch_els_rec(sp, els_data->fp);
902 break; 891 break;
903 default: 892 default:
904 FC_DBG("Invalid ELS CMD:%x\n", els_cmd); 893 FC_EXCH_DBG(fc_seq_exch(sp), "Invalid ELS CMD:%x\n", els_cmd);
905 } 894 }
906} 895}
907EXPORT_SYMBOL(fc_seq_els_rsp_send); 896EXPORT_SYMBOL(fc_seq_els_rsp_send);
@@ -1134,7 +1123,7 @@ static void fc_exch_recv_req(struct fc_lport *lp, struct fc_exch_mgr *mp,
1134 lp->tt.lport_recv(lp, sp, fp); 1123 lp->tt.lport_recv(lp, sp, fp);
1135 fc_exch_release(ep); /* release from lookup */ 1124 fc_exch_release(ep); /* release from lookup */
1136 } else { 1125 } else {
1137 FC_DEBUG_EXCH("exch/seq lookup failed: reject %x\n", reject); 1126 FC_EM_DBG(mp, "exch/seq lookup failed: reject %x\n", reject);
1138 fc_frame_free(fp); 1127 fc_frame_free(fp);
1139 } 1128 }
1140} 1129}
@@ -1242,10 +1231,10 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
1242 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */ 1231 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
1243 if (!sp) { 1232 if (!sp) {
1244 atomic_inc(&mp->stats.xid_not_found); 1233 atomic_inc(&mp->stats.xid_not_found);
1245 FC_DEBUG_EXCH("seq lookup failed\n"); 1234 FC_EM_DBG(mp, "seq lookup failed\n");
1246 } else { 1235 } else {
1247 atomic_inc(&mp->stats.non_bls_resp); 1236 atomic_inc(&mp->stats.non_bls_resp);
1248 FC_DEBUG_EXCH("non-BLS response to sequence"); 1237 FC_EM_DBG(mp, "non-BLS response to sequence");
1249 } 1238 }
1250 fc_frame_free(fp); 1239 fc_frame_free(fp);
1251} 1240}
@@ -1266,8 +1255,8 @@ static void fc_exch_abts_resp(struct fc_exch *ep, struct fc_frame *fp)
1266 int rc = 1, has_rec = 0; 1255 int rc = 1, has_rec = 0;
1267 1256
1268 fh = fc_frame_header_get(fp); 1257 fh = fc_frame_header_get(fp);
1269 FC_DEBUG_EXCH("exch: BLS rctl %x - %s\n", 1258 FC_EXCH_DBG(ep, "exch: BLS rctl %x - %s\n", fh->fh_r_ctl,
1270 fh->fh_r_ctl, fc_exch_rctl_name(fh->fh_r_ctl)); 1259 fc_exch_rctl_name(fh->fh_r_ctl));
1271 1260
1272 if (cancel_delayed_work_sync(&ep->timeout_work)) 1261 if (cancel_delayed_work_sync(&ep->timeout_work))
1273 fc_exch_release(ep); /* release from pending timer hold */ 1262 fc_exch_release(ep); /* release from pending timer hold */
@@ -1359,9 +1348,9 @@ static void fc_exch_recv_bls(struct fc_exch_mgr *mp, struct fc_frame *fp)
1359 case FC_RCTL_ACK_0: 1348 case FC_RCTL_ACK_0:
1360 break; 1349 break;
1361 default: 1350 default:
1362 FC_DEBUG_EXCH("BLS rctl %x - %s received", 1351 FC_EXCH_DBG(ep, "BLS rctl %x - %s received",
1363 fh->fh_r_ctl, 1352 fh->fh_r_ctl,
1364 fc_exch_rctl_name(fh->fh_r_ctl)); 1353 fc_exch_rctl_name(fh->fh_r_ctl));
1365 break; 1354 break;
1366 } 1355 }
1367 fc_frame_free(fp); 1356 fc_frame_free(fp);
@@ -1599,7 +1588,8 @@ static void fc_exch_rrq_resp(struct fc_seq *sp, struct fc_frame *fp, void *arg)
1599 1588
1600 if (err == -FC_EX_CLOSED || err == -FC_EX_TIMEOUT) 1589 if (err == -FC_EX_CLOSED || err == -FC_EX_TIMEOUT)
1601 goto cleanup; 1590 goto cleanup;
1602 FC_DBG("Cannot process RRQ, because of frame error %d\n", err); 1591 FC_EXCH_DBG(aborted_ep, "Cannot process RRQ, "
1592 "frame error %d\n", err);
1603 return; 1593 return;
1604 } 1594 }
1605 1595
@@ -1608,12 +1598,13 @@ static void fc_exch_rrq_resp(struct fc_seq *sp, struct fc_frame *fp, void *arg)
1608 1598
1609 switch (op) { 1599 switch (op) {
1610 case ELS_LS_RJT: 1600 case ELS_LS_RJT:
1611 FC_DBG("LS_RJT for RRQ"); 1601 FC_EXCH_DBG(aborted_ep, "LS_RJT for RRQ");
1612 /* fall through */ 1602 /* fall through */
1613 case ELS_LS_ACC: 1603 case ELS_LS_ACC:
1614 goto cleanup; 1604 goto cleanup;
1615 default: 1605 default:
1616 FC_DBG("unexpected response op %x for RRQ", op); 1606 FC_EXCH_DBG(aborted_ep, "unexpected response op %x "
1607 "for RRQ", op);
1617 return; 1608 return;
1618 } 1609 }
1619 1610
@@ -1740,8 +1731,8 @@ struct fc_exch_mgr *fc_exch_mgr_alloc(struct fc_lport *lp,
1740 size_t len; 1731 size_t len;
1741 1732
1742 if (max_xid <= min_xid || min_xid == 0 || max_xid == FC_XID_UNKNOWN) { 1733 if (max_xid <= min_xid || min_xid == 0 || max_xid == FC_XID_UNKNOWN) {
1743 FC_DBG("Invalid min_xid 0x:%x and max_xid 0x:%x\n", 1734 FC_LPORT_DBG(lp, "Invalid min_xid 0x:%x and max_xid 0x:%x\n",
1744 min_xid, max_xid); 1735 min_xid, max_xid);
1745 return NULL; 1736 return NULL;
1746 } 1737 }
1747 1738
@@ -1878,7 +1869,8 @@ void fc_exch_recv(struct fc_lport *lp, struct fc_exch_mgr *mp,
1878 1869
1879 /* lport lock ? */ 1870 /* lport lock ? */
1880 if (!lp || !mp || (lp->state == LPORT_ST_NONE)) { 1871 if (!lp || !mp || (lp->state == LPORT_ST_NONE)) {
1881 FC_DBG("fc_lport or EM is not allocated and configured"); 1872 FC_LPORT_DBG(lp, "Receiving frames for an lport that "
1873 "has not been initialized correctly\n");
1882 fc_frame_free(fp); 1874 fc_frame_free(fp);
1883 return; 1875 return;
1884 } 1876 }
@@ -1904,7 +1896,7 @@ void fc_exch_recv(struct fc_lport *lp, struct fc_exch_mgr *mp,
1904 fc_exch_recv_req(lp, mp, fp); 1896 fc_exch_recv_req(lp, mp, fp);
1905 break; 1897 break;
1906 default: 1898 default:
1907 FC_DBG("dropping invalid frame (eof %x)", fr_eof(fp)); 1899 FC_EM_DBG(mp, "dropping invalid frame (eof %x)", fr_eof(fp));
1908 fc_frame_free(fp); 1900 fc_frame_free(fp);
1909 break; 1901 break;
1910 } 1902 }
diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c
index ad8b747837b0..e303e0d12c4b 100644
--- a/drivers/scsi/libfc/fc_fcp.c
+++ b/drivers/scsi/libfc/fc_fcp.c
@@ -43,13 +43,9 @@ MODULE_AUTHOR("Open-FCoE.org");
43MODULE_DESCRIPTION("libfc"); 43MODULE_DESCRIPTION("libfc");
44MODULE_LICENSE("GPL v2"); 44MODULE_LICENSE("GPL v2");
45 45
46static int fc_fcp_debug; 46unsigned int fc_debug_logging;
47 47module_param_named(debug_logging, fc_debug_logging, int, S_IRUGO|S_IWUSR);
48#define FC_DEBUG_FCP(fmt...) \ 48MODULE_PARM_DESC(debug_logging, "a bit mask of logging levels");
49 do { \
50 if (fc_fcp_debug) \
51 FC_DBG(fmt); \
52 } while (0)
53 49
54static struct kmem_cache *scsi_pkt_cachep; 50static struct kmem_cache *scsi_pkt_cachep;
55 51
@@ -347,8 +343,8 @@ static void fc_fcp_recv_data(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
347 if ((fr_flags(fp) & FCPHF_CRC_UNCHECKED) && 343 if ((fr_flags(fp) & FCPHF_CRC_UNCHECKED) &&
348 fc_frame_crc_check(fp)) 344 fc_frame_crc_check(fp))
349 goto crc_err; 345 goto crc_err;
350 FC_DEBUG_FCP("data received past end. len %zx offset %zx " 346 FC_FCP_DBG(fsp, "data received past end. len %zx offset %zx "
351 "data_len %x\n", len, offset, fsp->data_len); 347 "data_len %x\n", len, offset, fsp->data_len);
352 fc_fcp_retry_cmd(fsp); 348 fc_fcp_retry_cmd(fsp);
353 return; 349 return;
354 } 350 }
@@ -411,7 +407,8 @@ crc_err:
411 stats->ErrorFrames++; 407 stats->ErrorFrames++;
412 /* FIXME - per cpu count, not total count! */ 408 /* FIXME - per cpu count, not total count! */
413 if (stats->InvalidCRCCount++ < 5) 409 if (stats->InvalidCRCCount++ < 5)
414 printk(KERN_WARNING "CRC error on data frame for port (%6x)\n", 410 printk(KERN_WARNING "libfc: CRC error on data "
411 "frame for port (%6x)\n",
415 fc_host_port_id(lp->host)); 412 fc_host_port_id(lp->host));
416 /* 413 /*
417 * Assume the frame is total garbage. 414 * Assume the frame is total garbage.
@@ -475,14 +472,14 @@ static int fc_fcp_send_data(struct fc_fcp_pkt *fsp, struct fc_seq *seq,
475 WARN_ON(seq_blen <= 0); 472 WARN_ON(seq_blen <= 0);
476 if (unlikely(offset + seq_blen > fsp->data_len)) { 473 if (unlikely(offset + seq_blen > fsp->data_len)) {
477 /* this should never happen */ 474 /* this should never happen */
478 FC_DEBUG_FCP("xfer-ready past end. seq_blen %zx offset %zx\n", 475 FC_FCP_DBG(fsp, "xfer-ready past end. seq_blen %zx "
479 seq_blen, offset); 476 "offset %zx\n", seq_blen, offset);
480 fc_fcp_send_abort(fsp); 477 fc_fcp_send_abort(fsp);
481 return 0; 478 return 0;
482 } else if (offset != fsp->xfer_len) { 479 } else if (offset != fsp->xfer_len) {
483 /* Out of Order Data Request - no problem, but unexpected. */ 480 /* Out of Order Data Request - no problem, but unexpected. */
484 FC_DEBUG_FCP("xfer-ready non-contiguous. " 481 FC_FCP_DBG(fsp, "xfer-ready non-contiguous. "
485 "seq_blen %zx offset %zx\n", seq_blen, offset); 482 "seq_blen %zx offset %zx\n", seq_blen, offset);
486 } 483 }
487 484
488 /* 485 /*
@@ -493,7 +490,7 @@ static int fc_fcp_send_data(struct fc_fcp_pkt *fsp, struct fc_seq *seq,
493 t_blen = fsp->max_payload; 490 t_blen = fsp->max_payload;
494 if (lp->seq_offload) { 491 if (lp->seq_offload) {
495 t_blen = min(seq_blen, (size_t)lp->lso_max); 492 t_blen = min(seq_blen, (size_t)lp->lso_max);
496 FC_DEBUG_FCP("fsp=%p:lso:blen=%zx lso_max=0x%x t_blen=%zx\n", 493 FC_FCP_DBG(fsp, "fsp=%p:lso:blen=%zx lso_max=0x%x t_blen=%zx\n",
497 fsp, seq_blen, lp->lso_max, t_blen); 494 fsp, seq_blen, lp->lso_max, t_blen);
498 } 495 }
499 496
@@ -694,7 +691,7 @@ static void fc_fcp_reduce_can_queue(struct fc_lport *lp)
694 if (!can_queue) 691 if (!can_queue)
695 can_queue = 1; 692 can_queue = 1;
696 lp->host->can_queue = can_queue; 693 lp->host->can_queue = can_queue;
697 shost_printk(KERN_ERR, lp->host, "Could not allocate frame.\n" 694 shost_printk(KERN_ERR, lp->host, "libfc: Could not allocate frame.\n"
698 "Reducing can_queue to %d.\n", can_queue); 695 "Reducing can_queue to %d.\n", can_queue);
699done: 696done:
700 spin_unlock_irqrestore(lp->host->host_lock, flags); 697 spin_unlock_irqrestore(lp->host->host_lock, flags);
@@ -768,7 +765,7 @@ static void fc_fcp_recv(struct fc_seq *seq, struct fc_frame *fp, void *arg)
768 765
769 fc_fcp_resp(fsp, fp); 766 fc_fcp_resp(fsp, fp);
770 } else { 767 } else {
771 FC_DBG("unexpected frame. r_ctl %x\n", r_ctl); 768 FC_FCP_DBG(fsp, "unexpected frame. r_ctl %x\n", r_ctl);
772 } 769 }
773unlock: 770unlock:
774 fc_fcp_unlock_pkt(fsp); 771 fc_fcp_unlock_pkt(fsp);
@@ -877,17 +874,17 @@ static void fc_fcp_resp(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
877 return; 874 return;
878 } 875 }
879 fsp->status_code = FC_DATA_OVRRUN; 876 fsp->status_code = FC_DATA_OVRRUN;
880 FC_DBG("tgt %6x xfer len %zx greater than expected len %x. " 877 FC_FCP_DBG(fsp, "tgt %6x xfer len %zx greater than expected, "
881 "data len %x\n", 878 "len %x, data len %x\n",
882 fsp->rport->port_id, 879 fsp->rport->port_id,
883 fsp->xfer_len, expected_len, fsp->data_len); 880 fsp->xfer_len, expected_len, fsp->data_len);
884 } 881 }
885 fc_fcp_complete_locked(fsp); 882 fc_fcp_complete_locked(fsp);
886 return; 883 return;
887 884
888len_err: 885len_err:
889 FC_DBG("short FCP response. flags 0x%x len %u respl %u snsl %u\n", 886 FC_FCP_DBG(fsp, "short FCP response. flags 0x%x len %u respl %u "
890 flags, fr_len(fp), respl, snsl); 887 "snsl %u\n", flags, fr_len(fp), respl, snsl);
891err: 888err:
892 fsp->status_code = FC_ERROR; 889 fsp->status_code = FC_ERROR;
893 fc_fcp_complete_locked(fsp); 890 fc_fcp_complete_locked(fsp);
@@ -1107,13 +1104,11 @@ static void fc_fcp_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
1107 if (fc_fcp_lock_pkt(fsp)) 1104 if (fc_fcp_lock_pkt(fsp))
1108 return; 1105 return;
1109 1106
1110 switch (error) { 1107 if (error == -FC_EX_CLOSED) {
1111 case -FC_EX_CLOSED:
1112 fc_fcp_retry_cmd(fsp); 1108 fc_fcp_retry_cmd(fsp);
1113 goto unlock; 1109 goto unlock;
1114 default:
1115 FC_DBG("unknown error %ld\n", PTR_ERR(fp));
1116 } 1110 }
1111
1117 /* 1112 /*
1118 * clear abort pending, because the lower layer 1113 * clear abort pending, because the lower layer
1119 * decided to force completion. 1114 * decided to force completion.
@@ -1145,10 +1140,10 @@ static int fc_fcp_pkt_abort(struct fc_lport *lp, struct fc_fcp_pkt *fsp)
1145 fsp->wait_for_comp = 0; 1140 fsp->wait_for_comp = 0;
1146 1141
1147 if (!rc) { 1142 if (!rc) {
1148 FC_DBG("target abort cmd failed\n"); 1143 FC_FCP_DBG(fsp, "target abort cmd failed\n");
1149 rc = FAILED; 1144 rc = FAILED;
1150 } else if (fsp->state & FC_SRB_ABORTED) { 1145 } else if (fsp->state & FC_SRB_ABORTED) {
1151 FC_DBG("target abort cmd passed\n"); 1146 FC_FCP_DBG(fsp, "target abort cmd passed\n");
1152 rc = SUCCESS; 1147 rc = SUCCESS;
1153 fc_fcp_complete_locked(fsp); 1148 fc_fcp_complete_locked(fsp);
1154 } 1149 }
@@ -1213,7 +1208,7 @@ static int fc_lun_reset(struct fc_lport *lp, struct fc_fcp_pkt *fsp,
1213 spin_unlock_bh(&fsp->scsi_pkt_lock); 1208 spin_unlock_bh(&fsp->scsi_pkt_lock);
1214 1209
1215 if (!rc) { 1210 if (!rc) {
1216 FC_DBG("lun reset failed\n"); 1211 FC_SCSI_DBG(lp, "lun reset failed\n");
1217 return FAILED; 1212 return FAILED;
1218 } 1213 }
1219 1214
@@ -1221,7 +1216,7 @@ static int fc_lun_reset(struct fc_lport *lp, struct fc_fcp_pkt *fsp,
1221 if (fsp->cdb_status != FCP_TMF_CMPL) 1216 if (fsp->cdb_status != FCP_TMF_CMPL)
1222 return FAILED; 1217 return FAILED;
1223 1218
1224 FC_DBG("lun reset to lun %u completed\n", lun); 1219 FC_SCSI_DBG(lp, "lun reset to lun %u completed\n", lun);
1225 fc_fcp_cleanup_each_cmd(lp, id, lun, FC_CMD_ABORTED); 1220 fc_fcp_cleanup_each_cmd(lp, id, lun, FC_CMD_ABORTED);
1226 return SUCCESS; 1221 return SUCCESS;
1227} 1222}
@@ -1388,13 +1383,13 @@ static void fc_fcp_rec_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg)
1388 rjt = fc_frame_payload_get(fp, sizeof(*rjt)); 1383 rjt = fc_frame_payload_get(fp, sizeof(*rjt));
1389 switch (rjt->er_reason) { 1384 switch (rjt->er_reason) {
1390 default: 1385 default:
1391 FC_DEBUG_FCP("device %x unexpected REC reject " 1386 FC_FCP_DBG(fsp, "device %x unexpected REC reject "
1392 "reason %d expl %d\n", 1387 "reason %d expl %d\n",
1393 fsp->rport->port_id, rjt->er_reason, 1388 fsp->rport->port_id, rjt->er_reason,
1394 rjt->er_explan); 1389 rjt->er_explan);
1395 /* fall through */ 1390 /* fall through */
1396 case ELS_RJT_UNSUP: 1391 case ELS_RJT_UNSUP:
1397 FC_DEBUG_FCP("device does not support REC\n"); 1392 FC_FCP_DBG(fsp, "device does not support REC\n");
1398 rp = fsp->rport->dd_data; 1393 rp = fsp->rport->dd_data;
1399 /* 1394 /*
1400 * if we do not spport RECs or got some bogus 1395 * if we do not spport RECs or got some bogus
@@ -1514,8 +1509,8 @@ static void fc_fcp_rec_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
1514 break; 1509 break;
1515 1510
1516 default: 1511 default:
1517 FC_DBG("REC %p fid %x error unexpected error %d\n", 1512 FC_FCP_DBG(fsp, "REC %p fid %x error unexpected error %d\n",
1518 fsp, fsp->rport->port_id, error); 1513 fsp, fsp->rport->port_id, error);
1519 fsp->status_code = FC_CMD_PLOGO; 1514 fsp->status_code = FC_CMD_PLOGO;
1520 /* fall through */ 1515 /* fall through */
1521 1516
@@ -1524,9 +1519,9 @@ static void fc_fcp_rec_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
1524 * Assume REC or LS_ACC was lost. 1519 * Assume REC or LS_ACC was lost.
1525 * The exchange manager will have aborted REC, so retry. 1520 * The exchange manager will have aborted REC, so retry.
1526 */ 1521 */
1527 FC_DBG("REC fid %x error error %d retry %d/%d\n", 1522 FC_FCP_DBG(fsp, "REC fid %x error error %d retry %d/%d\n",
1528 fsp->rport->port_id, error, fsp->recov_retry, 1523 fsp->rport->port_id, error, fsp->recov_retry,
1529 FC_MAX_RECOV_RETRY); 1524 FC_MAX_RECOV_RETRY);
1530 if (fsp->recov_retry++ < FC_MAX_RECOV_RETRY) 1525 if (fsp->recov_retry++ < FC_MAX_RECOV_RETRY)
1531 fc_fcp_rec(fsp); 1526 fc_fcp_rec(fsp);
1532 else 1527 else
@@ -2011,9 +2006,11 @@ int fc_eh_device_reset(struct scsi_cmnd *sc_cmd)
2011 if (lp->state != LPORT_ST_READY) 2006 if (lp->state != LPORT_ST_READY)
2012 return rc; 2007 return rc;
2013 2008
2009 FC_SCSI_DBG(lp, "Resetting rport (%6x)\n", rport->port_id);
2010
2014 fsp = fc_fcp_pkt_alloc(lp, GFP_NOIO); 2011 fsp = fc_fcp_pkt_alloc(lp, GFP_NOIO);
2015 if (fsp == NULL) { 2012 if (fsp == NULL) {
2016 FC_DBG("could not allocate scsi_pkt\n"); 2013 printk(KERN_WARNING "libfc: could not allocate scsi_pkt\n");
2017 sc_cmd->result = DID_NO_CONNECT << 16; 2014 sc_cmd->result = DID_NO_CONNECT << 16;
2018 goto out; 2015 goto out;
2019 } 2016 }
@@ -2048,17 +2045,21 @@ int fc_eh_host_reset(struct scsi_cmnd *sc_cmd)
2048 struct fc_lport *lp = shost_priv(shost); 2045 struct fc_lport *lp = shost_priv(shost);
2049 unsigned long wait_tmo; 2046 unsigned long wait_tmo;
2050 2047
2048 FC_SCSI_DBG(lp, "Resetting host\n");
2049
2051 lp->tt.lport_reset(lp); 2050 lp->tt.lport_reset(lp);
2052 wait_tmo = jiffies + FC_HOST_RESET_TIMEOUT; 2051 wait_tmo = jiffies + FC_HOST_RESET_TIMEOUT;
2053 while (!fc_fcp_lport_queue_ready(lp) && time_before(jiffies, wait_tmo)) 2052 while (!fc_fcp_lport_queue_ready(lp) && time_before(jiffies, wait_tmo))
2054 msleep(1000); 2053 msleep(1000);
2055 2054
2056 if (fc_fcp_lport_queue_ready(lp)) { 2055 if (fc_fcp_lport_queue_ready(lp)) {
2057 shost_printk(KERN_INFO, shost, "Host reset succeeded.\n"); 2056 shost_printk(KERN_INFO, shost, "libfc: Host reset succeeded "
2057 "on port (%6x)\n", fc_host_port_id(lp->host));
2058 return SUCCESS; 2058 return SUCCESS;
2059 } else { 2059 } else {
2060 shost_printk(KERN_INFO, shost, "Host reset failed. " 2060 shost_printk(KERN_INFO, shost, "libfc: Host reset failed, "
2061 "lport not ready.\n"); 2061 "port (%6x) is not ready.\n",
2062 fc_host_port_id(lp->host));
2062 return FAILED; 2063 return FAILED;
2063 } 2064 }
2064} 2065}
@@ -2117,7 +2118,8 @@ void fc_fcp_destroy(struct fc_lport *lp)
2117 struct fc_fcp_internal *si = fc_get_scsi_internal(lp); 2118 struct fc_fcp_internal *si = fc_get_scsi_internal(lp);
2118 2119
2119 if (!list_empty(&si->scsi_pkt_queue)) 2120 if (!list_empty(&si->scsi_pkt_queue))
2120 printk(KERN_ERR "Leaked scsi packets.\n"); 2121 printk(KERN_ERR "libfc: Leaked SCSI packets when destroying "
2122 "port (%6x)\n", fc_host_port_id(lp->host));
2121 2123
2122 mempool_destroy(si->scsi_pkt_pool); 2124 mempool_destroy(si->scsi_pkt_pool);
2123 kfree(si); 2125 kfree(si);
@@ -2166,7 +2168,8 @@ static int __init libfc_init(void)
2166 sizeof(struct fc_fcp_pkt), 2168 sizeof(struct fc_fcp_pkt),
2167 0, SLAB_HWCACHE_ALIGN, NULL); 2169 0, SLAB_HWCACHE_ALIGN, NULL);
2168 if (scsi_pkt_cachep == NULL) { 2170 if (scsi_pkt_cachep == NULL) {
2169 FC_DBG("Unable to allocate SRB cache...module load failed!"); 2171 printk(KERN_ERR "libfc: Unable to allocate SRB cache, "
2172 "module load failed!");
2170 return -ENOMEM; 2173 return -ENOMEM;
2171 } 2174 }
2172 2175
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index e0c247724d2b..745fa5555d6a 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -101,14 +101,6 @@
101 101
102#define DNS_DELAY 3 /* Discovery delay after RSCN (in seconds)*/ 102#define DNS_DELAY 3 /* Discovery delay after RSCN (in seconds)*/
103 103
104static int fc_lport_debug;
105
106#define FC_DEBUG_LPORT(fmt...) \
107 do { \
108 if (fc_lport_debug) \
109 FC_DBG(fmt); \
110 } while (0)
111
112static void fc_lport_error(struct fc_lport *, struct fc_frame *); 104static void fc_lport_error(struct fc_lport *, struct fc_frame *);
113 105
114static void fc_lport_enter_reset(struct fc_lport *); 106static void fc_lport_enter_reset(struct fc_lport *);
@@ -151,8 +143,8 @@ static void fc_lport_rport_callback(struct fc_lport *lport,
151 struct fc_rport *rport, 143 struct fc_rport *rport,
152 enum fc_rport_event event) 144 enum fc_rport_event event)
153{ 145{
154 FC_DEBUG_LPORT("Received a %d event for port (%6x)\n", event, 146 FC_LPORT_DBG(lport, "Received a %d event for port (%6x)\n", event,
155 rport->port_id); 147 rport->port_id);
156 148
157 switch (event) { 149 switch (event) {
158 case RPORT_EV_CREATED: 150 case RPORT_EV_CREATED:
@@ -162,19 +154,19 @@ static void fc_lport_rport_callback(struct fc_lport *lport,
162 lport->dns_rp = rport; 154 lport->dns_rp = rport;
163 fc_lport_enter_rpn_id(lport); 155 fc_lport_enter_rpn_id(lport);
164 } else { 156 } else {
165 FC_DEBUG_LPORT("Received an CREATED event on " 157 FC_LPORT_DBG(lport, "Received an CREATED event "
166 "port (%6x) for the directory " 158 "on port (%6x) for the directory "
167 "server, but the lport is not " 159 "server, but the lport is not "
168 "in the DNS state, it's in the " 160 "in the DNS state, it's in the "
169 "%d state", rport->port_id, 161 "%d state", rport->port_id,
170 lport->state); 162 lport->state);
171 lport->tt.rport_logoff(rport); 163 lport->tt.rport_logoff(rport);
172 } 164 }
173 mutex_unlock(&lport->lp_mutex); 165 mutex_unlock(&lport->lp_mutex);
174 } else 166 } else
175 FC_DEBUG_LPORT("Received an event for port (%6x) " 167 FC_LPORT_DBG(lport, "Received an event for port (%6x) "
176 "which is not the directory server\n", 168 "which is not the directory server\n",
177 rport->port_id); 169 rport->port_id);
178 break; 170 break;
179 case RPORT_EV_LOGO: 171 case RPORT_EV_LOGO:
180 case RPORT_EV_FAILED: 172 case RPORT_EV_FAILED:
@@ -185,9 +177,9 @@ static void fc_lport_rport_callback(struct fc_lport *lport,
185 mutex_unlock(&lport->lp_mutex); 177 mutex_unlock(&lport->lp_mutex);
186 178
187 } else 179 } else
188 FC_DEBUG_LPORT("Received an event for port (%6x) " 180 FC_LPORT_DBG(lport, "Received an event for port (%6x) "
189 "which is not the directory server\n", 181 "which is not the directory server\n",
190 rport->port_id); 182 rport->port_id);
191 break; 183 break;
192 case RPORT_EV_NONE: 184 case RPORT_EV_NONE:
193 break; 185 break;
@@ -363,8 +355,8 @@ static void fc_lport_add_fc4_type(struct fc_lport *lport, enum fc_fh_type type)
363static void fc_lport_recv_rlir_req(struct fc_seq *sp, struct fc_frame *fp, 355static void fc_lport_recv_rlir_req(struct fc_seq *sp, struct fc_frame *fp,
364 struct fc_lport *lport) 356 struct fc_lport *lport)
365{ 357{
366 FC_DEBUG_LPORT("Received RLIR request while in state %s\n", 358 FC_LPORT_DBG(lport, "Received RLIR request while in state %s\n",
367 fc_lport_state(lport)); 359 fc_lport_state(lport));
368 360
369 lport->tt.seq_els_rsp_send(sp, ELS_LS_ACC, NULL); 361 lport->tt.seq_els_rsp_send(sp, ELS_LS_ACC, NULL);
370 fc_frame_free(fp); 362 fc_frame_free(fp);
@@ -389,8 +381,8 @@ static void fc_lport_recv_echo_req(struct fc_seq *sp, struct fc_frame *in_fp,
389 void *dp; 381 void *dp;
390 u32 f_ctl; 382 u32 f_ctl;
391 383
392 FC_DEBUG_LPORT("Received RLIR request while in state %s\n", 384 FC_LPORT_DBG(lport, "Received RLIR request while in state %s\n",
393 fc_lport_state(lport)); 385 fc_lport_state(lport));
394 386
395 len = fr_len(in_fp) - sizeof(struct fc_frame_header); 387 len = fr_len(in_fp) - sizeof(struct fc_frame_header);
396 pp = fc_frame_payload_get(in_fp, len); 388 pp = fc_frame_payload_get(in_fp, len);
@@ -437,8 +429,8 @@ static void fc_lport_recv_rnid_req(struct fc_seq *sp, struct fc_frame *in_fp,
437 size_t len; 429 size_t len;
438 u32 f_ctl; 430 u32 f_ctl;
439 431
440 FC_DEBUG_LPORT("Received RNID request while in state %s\n", 432 FC_LPORT_DBG(lport, "Received RNID request while in state %s\n",
441 fc_lport_state(lport)); 433 fc_lport_state(lport));
442 434
443 req = fc_frame_payload_get(in_fp, sizeof(*req)); 435 req = fc_frame_payload_get(in_fp, sizeof(*req));
444 if (!req) { 436 if (!req) {
@@ -498,8 +490,8 @@ static void fc_lport_recv_adisc_req(struct fc_seq *sp, struct fc_frame *in_fp,
498 size_t len; 490 size_t len;
499 u32 f_ctl; 491 u32 f_ctl;
500 492
501 FC_DEBUG_LPORT("Received ADISC request while in state %s\n", 493 FC_LPORT_DBG(lport, "Received ADISC request while in state %s\n",
502 fc_lport_state(lport)); 494 fc_lport_state(lport));
503 495
504 req = fc_frame_payload_get(in_fp, sizeof(*req)); 496 req = fc_frame_payload_get(in_fp, sizeof(*req));
505 if (!req) { 497 if (!req) {
@@ -574,8 +566,8 @@ EXPORT_SYMBOL(fc_fabric_login);
574 */ 566 */
575void fc_linkup(struct fc_lport *lport) 567void fc_linkup(struct fc_lport *lport)
576{ 568{
577 FC_DEBUG_LPORT("Link is up for port (%6x)\n", 569 printk(KERN_INFO "libfc: Link up on port (%6x)\n",
578 fc_host_port_id(lport->host)); 570 fc_host_port_id(lport->host));
579 571
580 mutex_lock(&lport->lp_mutex); 572 mutex_lock(&lport->lp_mutex);
581 if (!lport->link_up) { 573 if (!lport->link_up) {
@@ -595,8 +587,8 @@ EXPORT_SYMBOL(fc_linkup);
595void fc_linkdown(struct fc_lport *lport) 587void fc_linkdown(struct fc_lport *lport)
596{ 588{
597 mutex_lock(&lport->lp_mutex); 589 mutex_lock(&lport->lp_mutex);
598 FC_DEBUG_LPORT("Link is down for port (%6x)\n", 590 printk(KERN_INFO "libfc: Link down on port (%6x)\n",
599 fc_host_port_id(lport->host)); 591 fc_host_port_id(lport->host));
600 592
601 if (lport->link_up) { 593 if (lport->link_up) {
602 lport->link_up = 0; 594 lport->link_up = 0;
@@ -701,12 +693,11 @@ void fc_lport_disc_callback(struct fc_lport *lport, enum fc_disc_event event)
701{ 693{
702 switch (event) { 694 switch (event) {
703 case DISC_EV_SUCCESS: 695 case DISC_EV_SUCCESS:
704 FC_DEBUG_LPORT("Got a SUCCESS event for port (%6x)\n", 696 FC_LPORT_DBG(lport, "Discovery succeeded\n");
705 fc_host_port_id(lport->host));
706 break; 697 break;
707 case DISC_EV_FAILED: 698 case DISC_EV_FAILED:
708 FC_DEBUG_LPORT("Got a FAILED event for port (%6x)\n", 699 printk(KERN_ERR "libfc: Discovery failed for port (%6x)\n",
709 fc_host_port_id(lport->host)); 700 fc_host_port_id(lport->host));
710 mutex_lock(&lport->lp_mutex); 701 mutex_lock(&lport->lp_mutex);
711 fc_lport_enter_reset(lport); 702 fc_lport_enter_reset(lport);
712 mutex_unlock(&lport->lp_mutex); 703 mutex_unlock(&lport->lp_mutex);
@@ -726,8 +717,8 @@ void fc_lport_disc_callback(struct fc_lport *lport, enum fc_disc_event event)
726 */ 717 */
727static void fc_lport_enter_ready(struct fc_lport *lport) 718static void fc_lport_enter_ready(struct fc_lport *lport)
728{ 719{
729 FC_DEBUG_LPORT("Port (%6x) entered Ready from state %s\n", 720 FC_LPORT_DBG(lport, "Entered READY from state %s\n",
730 fc_host_port_id(lport->host), fc_lport_state(lport)); 721 fc_lport_state(lport));
731 722
732 fc_lport_state_enter(lport, LPORT_ST_READY); 723 fc_lport_state_enter(lport, LPORT_ST_READY);
733 724
@@ -762,8 +753,8 @@ static void fc_lport_recv_flogi_req(struct fc_seq *sp_in,
762 u32 local_fid; 753 u32 local_fid;
763 u32 f_ctl; 754 u32 f_ctl;
764 755
765 FC_DEBUG_LPORT("Received FLOGI request while in state %s\n", 756 FC_LPORT_DBG(lport, "Received FLOGI request while in state %s\n",
766 fc_lport_state(lport)); 757 fc_lport_state(lport));
767 758
768 fh = fc_frame_header_get(rx_fp); 759 fh = fc_frame_header_get(rx_fp);
769 remote_fid = ntoh24(fh->fh_s_id); 760 remote_fid = ntoh24(fh->fh_s_id);
@@ -772,12 +763,11 @@ static void fc_lport_recv_flogi_req(struct fc_seq *sp_in,
772 goto out; 763 goto out;
773 remote_wwpn = get_unaligned_be64(&flp->fl_wwpn); 764 remote_wwpn = get_unaligned_be64(&flp->fl_wwpn);
774 if (remote_wwpn == lport->wwpn) { 765 if (remote_wwpn == lport->wwpn) {
775 FC_DBG("FLOGI from port with same WWPN %llx " 766 printk(KERN_WARNING "libfc: Received FLOGI from port "
776 "possible configuration error\n", 767 "with same WWPN %llx\n", remote_wwpn);
777 (unsigned long long)remote_wwpn);
778 goto out; 768 goto out;
779 } 769 }
780 FC_DBG("FLOGI from port WWPN %llx\n", (unsigned long long)remote_wwpn); 770 FC_LPORT_DBG(lport, "FLOGI from port WWPN %llx\n", remote_wwpn);
781 771
782 /* 772 /*
783 * XXX what is the right thing to do for FIDs? 773 * XXX what is the right thing to do for FIDs?
@@ -909,7 +899,8 @@ static void fc_lport_recv_req(struct fc_lport *lport, struct fc_seq *sp,
909 } 899 }
910 } 900 }
911 } else { 901 } else {
912 FC_DBG("dropping invalid frame (eof %x)\n", fr_eof(fp)); 902 FC_LPORT_DBG(lport, "dropping invalid frame (eof %x)\n",
903 fr_eof(fp));
913 fc_frame_free(fp); 904 fc_frame_free(fp);
914 } 905 }
915 mutex_unlock(&lport->lp_mutex); 906 mutex_unlock(&lport->lp_mutex);
@@ -947,8 +938,8 @@ EXPORT_SYMBOL(fc_lport_reset);
947 */ 938 */
948static void fc_lport_enter_reset(struct fc_lport *lport) 939static void fc_lport_enter_reset(struct fc_lport *lport)
949{ 940{
950 FC_DEBUG_LPORT("Port (%6x) entered RESET state from %s state\n", 941 FC_LPORT_DBG(lport, "Entered RESET state from %s state\n",
951 fc_host_port_id(lport->host), fc_lport_state(lport)); 942 fc_lport_state(lport));
952 943
953 fc_lport_state_enter(lport, LPORT_ST_RESET); 944 fc_lport_state_enter(lport, LPORT_ST_RESET);
954 945
@@ -982,9 +973,9 @@ static void fc_lport_enter_reset(struct fc_lport *lport)
982static void fc_lport_error(struct fc_lport *lport, struct fc_frame *fp) 973static void fc_lport_error(struct fc_lport *lport, struct fc_frame *fp)
983{ 974{
984 unsigned long delay = 0; 975 unsigned long delay = 0;
985 FC_DEBUG_LPORT("Error %ld in state %s, retries %d\n", 976 FC_LPORT_DBG(lport, "Error %ld in state %s, retries %d\n",
986 PTR_ERR(fp), fc_lport_state(lport), 977 PTR_ERR(fp), fc_lport_state(lport),
987 lport->retry_count); 978 lport->retry_count);
988 979
989 if (!fp || PTR_ERR(fp) == -FC_EX_TIMEOUT) { 980 if (!fp || PTR_ERR(fp) == -FC_EX_TIMEOUT) {
990 /* 981 /*
@@ -1040,11 +1031,11 @@ static void fc_lport_rft_id_resp(struct fc_seq *sp, struct fc_frame *fp,
1040 1031
1041 mutex_lock(&lport->lp_mutex); 1032 mutex_lock(&lport->lp_mutex);
1042 1033
1043 FC_DEBUG_LPORT("Received a RFT_ID response\n"); 1034 FC_LPORT_DBG(lport, "Received a RFT_ID response\n");
1044 1035
1045 if (lport->state != LPORT_ST_RFT_ID) { 1036 if (lport->state != LPORT_ST_RFT_ID) {
1046 FC_DBG("Received a RFT_ID response, but in state %s\n", 1037 FC_LPORT_DBG(lport, "Received a RFT_ID response, but in state "
1047 fc_lport_state(lport)); 1038 "%s\n", fc_lport_state(lport));
1048 if (IS_ERR(fp)) 1039 if (IS_ERR(fp))
1049 goto err; 1040 goto err;
1050 goto out; 1041 goto out;
@@ -1094,11 +1085,11 @@ static void fc_lport_rpn_id_resp(struct fc_seq *sp, struct fc_frame *fp,
1094 1085
1095 mutex_lock(&lport->lp_mutex); 1086 mutex_lock(&lport->lp_mutex);
1096 1087
1097 FC_DEBUG_LPORT("Received a RPN_ID response\n"); 1088 FC_LPORT_DBG(lport, "Received a RPN_ID response\n");
1098 1089
1099 if (lport->state != LPORT_ST_RPN_ID) { 1090 if (lport->state != LPORT_ST_RPN_ID) {
1100 FC_DBG("Received a RPN_ID response, but in state %s\n", 1091 FC_LPORT_DBG(lport, "Received a RPN_ID response, but in state "
1101 fc_lport_state(lport)); 1092 "%s\n", fc_lport_state(lport));
1102 if (IS_ERR(fp)) 1093 if (IS_ERR(fp))
1103 goto err; 1094 goto err;
1104 goto out; 1095 goto out;
@@ -1146,11 +1137,11 @@ static void fc_lport_scr_resp(struct fc_seq *sp, struct fc_frame *fp,
1146 1137
1147 mutex_lock(&lport->lp_mutex); 1138 mutex_lock(&lport->lp_mutex);
1148 1139
1149 FC_DEBUG_LPORT("Received a SCR response\n"); 1140 FC_LPORT_DBG(lport, "Received a SCR response\n");
1150 1141
1151 if (lport->state != LPORT_ST_SCR) { 1142 if (lport->state != LPORT_ST_SCR) {
1152 FC_DBG("Received a SCR response, but in state %s\n", 1143 FC_LPORT_DBG(lport, "Received a SCR response, but in state "
1153 fc_lport_state(lport)); 1144 "%s\n", fc_lport_state(lport));
1154 if (IS_ERR(fp)) 1145 if (IS_ERR(fp))
1155 goto err; 1146 goto err;
1156 goto out; 1147 goto out;
@@ -1184,8 +1175,8 @@ static void fc_lport_enter_scr(struct fc_lport *lport)
1184{ 1175{
1185 struct fc_frame *fp; 1176 struct fc_frame *fp;
1186 1177
1187 FC_DEBUG_LPORT("Port (%6x) entered SCR state from %s state\n", 1178 FC_LPORT_DBG(lport, "Entered SCR state from %s state\n",
1188 fc_host_port_id(lport->host), fc_lport_state(lport)); 1179 fc_lport_state(lport));
1189 1180
1190 fc_lport_state_enter(lport, LPORT_ST_SCR); 1181 fc_lport_state_enter(lport, LPORT_ST_SCR);
1191 1182
@@ -1213,8 +1204,8 @@ static void fc_lport_enter_rft_id(struct fc_lport *lport)
1213 struct fc_ns_fts *lps; 1204 struct fc_ns_fts *lps;
1214 int i; 1205 int i;
1215 1206
1216 FC_DEBUG_LPORT("Port (%6x) entered RFT_ID state from %s state\n", 1207 FC_LPORT_DBG(lport, "Entered RFT_ID state from %s state\n",
1217 fc_host_port_id(lport->host), fc_lport_state(lport)); 1208 fc_lport_state(lport));
1218 1209
1219 fc_lport_state_enter(lport, LPORT_ST_RFT_ID); 1210 fc_lport_state_enter(lport, LPORT_ST_RFT_ID);
1220 1211
@@ -1253,8 +1244,8 @@ static void fc_lport_enter_rpn_id(struct fc_lport *lport)
1253{ 1244{
1254 struct fc_frame *fp; 1245 struct fc_frame *fp;
1255 1246
1256 FC_DEBUG_LPORT("Port (%6x) entered RPN_ID state from %s state\n", 1247 FC_LPORT_DBG(lport, "Entered RPN_ID state from %s state\n",
1257 fc_host_port_id(lport->host), fc_lport_state(lport)); 1248 fc_lport_state(lport));
1258 1249
1259 fc_lport_state_enter(lport, LPORT_ST_RPN_ID); 1250 fc_lport_state_enter(lport, LPORT_ST_RPN_ID);
1260 1251
@@ -1294,8 +1285,8 @@ static void fc_lport_enter_dns(struct fc_lport *lport)
1294 dp.ids.roles = FC_RPORT_ROLE_UNKNOWN; 1285 dp.ids.roles = FC_RPORT_ROLE_UNKNOWN;
1295 dp.lp = lport; 1286 dp.lp = lport;
1296 1287
1297 FC_DEBUG_LPORT("Port (%6x) entered DNS state from %s state\n", 1288 FC_LPORT_DBG(lport, "Entered DNS state from %s state\n",
1298 fc_host_port_id(lport->host), fc_lport_state(lport)); 1289 fc_lport_state(lport));
1299 1290
1300 fc_lport_state_enter(lport, LPORT_ST_DNS); 1291 fc_lport_state_enter(lport, LPORT_ST_DNS);
1301 1292
@@ -1374,11 +1365,11 @@ static void fc_lport_logo_resp(struct fc_seq *sp, struct fc_frame *fp,
1374 1365
1375 mutex_lock(&lport->lp_mutex); 1366 mutex_lock(&lport->lp_mutex);
1376 1367
1377 FC_DEBUG_LPORT("Received a LOGO response\n"); 1368 FC_LPORT_DBG(lport, "Received a LOGO response\n");
1378 1369
1379 if (lport->state != LPORT_ST_LOGO) { 1370 if (lport->state != LPORT_ST_LOGO) {
1380 FC_DBG("Received a LOGO response, but in state %s\n", 1371 FC_LPORT_DBG(lport, "Received a LOGO response, but in state "
1381 fc_lport_state(lport)); 1372 "%s\n", fc_lport_state(lport));
1382 if (IS_ERR(fp)) 1373 if (IS_ERR(fp))
1383 goto err; 1374 goto err;
1384 goto out; 1375 goto out;
@@ -1413,8 +1404,8 @@ static void fc_lport_enter_logo(struct fc_lport *lport)
1413 struct fc_frame *fp; 1404 struct fc_frame *fp;
1414 struct fc_els_logo *logo; 1405 struct fc_els_logo *logo;
1415 1406
1416 FC_DEBUG_LPORT("Port (%6x) entered LOGO state from %s state\n", 1407 FC_LPORT_DBG(lport, "Entered LOGO state from %s state\n",
1417 fc_host_port_id(lport->host), fc_lport_state(lport)); 1408 fc_lport_state(lport));
1418 1409
1419 fc_lport_state_enter(lport, LPORT_ST_LOGO); 1410 fc_lport_state_enter(lport, LPORT_ST_LOGO);
1420 1411
@@ -1456,11 +1447,11 @@ static void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp,
1456 1447
1457 mutex_lock(&lport->lp_mutex); 1448 mutex_lock(&lport->lp_mutex);
1458 1449
1459 FC_DEBUG_LPORT("Received a FLOGI response\n"); 1450 FC_LPORT_DBG(lport, "Received a FLOGI response\n");
1460 1451
1461 if (lport->state != LPORT_ST_FLOGI) { 1452 if (lport->state != LPORT_ST_FLOGI) {
1462 FC_DBG("Received a FLOGI response, but in state %s\n", 1453 FC_LPORT_DBG(lport, "Received a FLOGI response, but in state "
1463 fc_lport_state(lport)); 1454 "%s\n", fc_lport_state(lport));
1464 if (IS_ERR(fp)) 1455 if (IS_ERR(fp))
1465 goto err; 1456 goto err;
1466 goto out; 1457 goto out;
@@ -1475,7 +1466,8 @@ static void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp,
1475 did = ntoh24(fh->fh_d_id); 1466 did = ntoh24(fh->fh_d_id);
1476 if (fc_frame_payload_op(fp) == ELS_LS_ACC && did != 0) { 1467 if (fc_frame_payload_op(fp) == ELS_LS_ACC && did != 0) {
1477 1468
1478 FC_DEBUG_LPORT("Assigned fid %x\n", did); 1469 printk(KERN_INFO "libfc: Assigned FID (%6x) in FLOGI response\n",
1470 did);
1479 fc_host_port_id(lport->host) = did; 1471 fc_host_port_id(lport->host) = did;
1480 1472
1481 flp = fc_frame_payload_get(fp, sizeof(*flp)); 1473 flp = fc_frame_payload_get(fp, sizeof(*flp));
@@ -1494,7 +1486,8 @@ static void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp,
1494 if (e_d_tov > lport->e_d_tov) 1486 if (e_d_tov > lport->e_d_tov)
1495 lport->e_d_tov = e_d_tov; 1487 lport->e_d_tov = e_d_tov;
1496 lport->r_a_tov = 2 * e_d_tov; 1488 lport->r_a_tov = 2 * e_d_tov;
1497 FC_DBG("Point-to-Point mode\n"); 1489 printk(KERN_INFO "libfc: Port (%6x) entered "
1490 "point to point mode\n", did);
1498 fc_lport_ptp_setup(lport, ntoh24(fh->fh_s_id), 1491 fc_lport_ptp_setup(lport, ntoh24(fh->fh_s_id),
1499 get_unaligned_be64( 1492 get_unaligned_be64(
1500 &flp->fl_wwpn), 1493 &flp->fl_wwpn),
@@ -1517,7 +1510,7 @@ static void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp,
1517 } 1510 }
1518 } 1511 }
1519 } else { 1512 } else {
1520 FC_DBG("bad FLOGI response\n"); 1513 FC_LPORT_DBG(lport, "Bad FLOGI response\n");
1521 } 1514 }
1522 1515
1523out: 1516out:
@@ -1537,7 +1530,8 @@ void fc_lport_enter_flogi(struct fc_lport *lport)
1537{ 1530{
1538 struct fc_frame *fp; 1531 struct fc_frame *fp;
1539 1532
1540 FC_DEBUG_LPORT("Processing FLOGI state\n"); 1533 FC_LPORT_DBG(lport, "Entered FLOGI state from %s state\n",
1534 fc_lport_state(lport));
1541 1535
1542 fc_lport_state_enter(lport, LPORT_ST_FLOGI); 1536 fc_lport_state_enter(lport, LPORT_ST_FLOGI);
1543 1537
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index 7bfbff7e0efb..7162385f52eb 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -55,14 +55,6 @@
55#include <scsi/libfc.h> 55#include <scsi/libfc.h>
56#include <scsi/fc_encode.h> 56#include <scsi/fc_encode.h>
57 57
58static int fc_rport_debug;
59
60#define FC_DEBUG_RPORT(fmt...) \
61 do { \
62 if (fc_rport_debug) \
63 FC_DBG(fmt); \
64 } while (0)
65
66struct workqueue_struct *rport_event_queue; 58struct workqueue_struct *rport_event_queue;
67 59
68static void fc_rport_enter_plogi(struct fc_rport *); 60static void fc_rport_enter_plogi(struct fc_rport *);
@@ -97,7 +89,7 @@ static const char *fc_rport_state_names[] = {
97static void fc_rport_rogue_destroy(struct device *dev) 89static void fc_rport_rogue_destroy(struct device *dev)
98{ 90{
99 struct fc_rport *rport = dev_to_rport(dev); 91 struct fc_rport *rport = dev_to_rport(dev);
100 FC_DEBUG_RPORT("Destroying rogue rport (%6x)\n", rport->port_id); 92 FC_RPORT_DBG(rport, "Destroying rogue rport\n");
101 kfree(rport); 93 kfree(rport);
102} 94}
103 95
@@ -263,8 +255,8 @@ static void fc_rport_work(struct work_struct *work)
263 255
264 fc_rport_state_enter(new_rport, RPORT_ST_READY); 256 fc_rport_state_enter(new_rport, RPORT_ST_READY);
265 } else { 257 } else {
266 FC_DBG("Failed to create the rport for port " 258 printk(KERN_WARNING "libfc: Failed to allocate "
267 "(%6x).\n", ids.port_id); 259 " memory for rport (%6x)\n", ids.port_id);
268 event = RPORT_EV_FAILED; 260 event = RPORT_EV_FAILED;
269 } 261 }
270 if (rport->port_id != FC_FID_DIR_SERV) 262 if (rport->port_id != FC_FID_DIR_SERV)
@@ -309,7 +301,7 @@ int fc_rport_login(struct fc_rport *rport)
309 301
310 mutex_lock(&rdata->rp_mutex); 302 mutex_lock(&rdata->rp_mutex);
311 303
312 FC_DEBUG_RPORT("Login to port (%6x)\n", rport->port_id); 304 FC_RPORT_DBG(rport, "Login to port\n");
313 305
314 fc_rport_enter_plogi(rport); 306 fc_rport_enter_plogi(rport);
315 307
@@ -329,16 +321,13 @@ int fc_rport_login(struct fc_rport *rport)
329int fc_rport_logoff(struct fc_rport *rport) 321int fc_rport_logoff(struct fc_rport *rport)
330{ 322{
331 struct fc_rport_libfc_priv *rdata = rport->dd_data; 323 struct fc_rport_libfc_priv *rdata = rport->dd_data;
332 struct fc_lport *lport = rdata->local_port;
333 324
334 mutex_lock(&rdata->rp_mutex); 325 mutex_lock(&rdata->rp_mutex);
335 326
336 FC_DEBUG_RPORT("Remove port (%6x)\n", rport->port_id); 327 FC_RPORT_DBG(rport, "Remove port\n");
337 328
338 if (rdata->rp_state == RPORT_ST_NONE) { 329 if (rdata->rp_state == RPORT_ST_NONE) {
339 FC_DEBUG_RPORT("(%6x): Port (%6x) in NONE state," 330 FC_RPORT_DBG(rport, "Port in NONE state, not removing\n");
340 " not removing", fc_host_port_id(lport->host),
341 rport->port_id);
342 mutex_unlock(&rdata->rp_mutex); 331 mutex_unlock(&rdata->rp_mutex);
343 goto out; 332 goto out;
344 } 333 }
@@ -379,7 +368,7 @@ static void fc_rport_enter_ready(struct fc_rport *rport)
379 368
380 fc_rport_state_enter(rport, RPORT_ST_READY); 369 fc_rport_state_enter(rport, RPORT_ST_READY);
381 370
382 FC_DEBUG_RPORT("Port (%6x) is Ready\n", rport->port_id); 371 FC_RPORT_DBG(rport, "Port is Ready\n");
383 372
384 rdata->event = RPORT_EV_CREATED; 373 rdata->event = RPORT_EV_CREATED;
385 queue_work(rport_event_queue, &rdata->event_work); 374 queue_work(rport_event_queue, &rdata->event_work);
@@ -436,8 +425,8 @@ static void fc_rport_error(struct fc_rport *rport, struct fc_frame *fp)
436{ 425{
437 struct fc_rport_libfc_priv *rdata = rport->dd_data; 426 struct fc_rport_libfc_priv *rdata = rport->dd_data;
438 427
439 FC_DEBUG_RPORT("Error %ld in state %s, retries %d\n", 428 FC_RPORT_DBG(rport, "Error %ld in state %s, retries %d\n",
440 PTR_ERR(fp), fc_rport_state(rport), rdata->retries); 429 PTR_ERR(fp), fc_rport_state(rport), rdata->retries);
441 430
442 switch (rdata->rp_state) { 431 switch (rdata->rp_state) {
443 case RPORT_ST_PLOGI: 432 case RPORT_ST_PLOGI:
@@ -479,8 +468,8 @@ static void fc_rport_error_retry(struct fc_rport *rport, struct fc_frame *fp)
479 return fc_rport_error(rport, fp); 468 return fc_rport_error(rport, fp);
480 469
481 if (rdata->retries < rdata->local_port->max_rport_retry_count) { 470 if (rdata->retries < rdata->local_port->max_rport_retry_count) {
482 FC_DEBUG_RPORT("Error %ld in state %s, retrying\n", 471 FC_RPORT_DBG(rport, "Error %ld in state %s, retrying\n",
483 PTR_ERR(fp), fc_rport_state(rport)); 472 PTR_ERR(fp), fc_rport_state(rport));
484 rdata->retries++; 473 rdata->retries++;
485 /* no additional delay on exchange timeouts */ 474 /* no additional delay on exchange timeouts */
486 if (PTR_ERR(fp) == -FC_EX_TIMEOUT) 475 if (PTR_ERR(fp) == -FC_EX_TIMEOUT)
@@ -517,12 +506,11 @@ static void fc_rport_plogi_resp(struct fc_seq *sp, struct fc_frame *fp,
517 506
518 mutex_lock(&rdata->rp_mutex); 507 mutex_lock(&rdata->rp_mutex);
519 508
520 FC_DEBUG_RPORT("Received a PLOGI response from port (%6x)\n", 509 FC_RPORT_DBG(rport, "Received a PLOGI response\n");
521 rport->port_id);
522 510
523 if (rdata->rp_state != RPORT_ST_PLOGI) { 511 if (rdata->rp_state != RPORT_ST_PLOGI) {
524 FC_DBG("Received a PLOGI response, but in state %s\n", 512 FC_RPORT_DBG(rport, "Received a PLOGI response, but in state "
525 fc_rport_state(rport)); 513 "%s\n", fc_rport_state(rport));
526 if (IS_ERR(fp)) 514 if (IS_ERR(fp))
527 goto err; 515 goto err;
528 goto out; 516 goto out;
@@ -583,8 +571,8 @@ static void fc_rport_enter_plogi(struct fc_rport *rport)
583 struct fc_lport *lport = rdata->local_port; 571 struct fc_lport *lport = rdata->local_port;
584 struct fc_frame *fp; 572 struct fc_frame *fp;
585 573
586 FC_DEBUG_RPORT("Port (%6x) entered PLOGI state from %s state\n", 574 FC_RPORT_DBG(rport, "Port entered PLOGI state from %s state\n",
587 rport->port_id, fc_rport_state(rport)); 575 fc_rport_state(rport));
588 576
589 fc_rport_state_enter(rport, RPORT_ST_PLOGI); 577 fc_rport_state_enter(rport, RPORT_ST_PLOGI);
590 578
@@ -628,12 +616,11 @@ static void fc_rport_prli_resp(struct fc_seq *sp, struct fc_frame *fp,
628 616
629 mutex_lock(&rdata->rp_mutex); 617 mutex_lock(&rdata->rp_mutex);
630 618
631 FC_DEBUG_RPORT("Received a PRLI response from port (%6x)\n", 619 FC_RPORT_DBG(rport, "Received a PRLI response\n");
632 rport->port_id);
633 620
634 if (rdata->rp_state != RPORT_ST_PRLI) { 621 if (rdata->rp_state != RPORT_ST_PRLI) {
635 FC_DBG("Received a PRLI response, but in state %s\n", 622 FC_RPORT_DBG(rport, "Received a PRLI response, but in state "
636 fc_rport_state(rport)); 623 "%s\n", fc_rport_state(rport));
637 if (IS_ERR(fp)) 624 if (IS_ERR(fp))
638 goto err; 625 goto err;
639 goto out; 626 goto out;
@@ -663,7 +650,7 @@ static void fc_rport_prli_resp(struct fc_seq *sp, struct fc_frame *fp,
663 fc_rport_enter_rtv(rport); 650 fc_rport_enter_rtv(rport);
664 651
665 } else { 652 } else {
666 FC_DBG("Bad ELS response\n"); 653 FC_RPORT_DBG(rport, "Bad ELS response for PRLI command\n");
667 rdata->event = RPORT_EV_FAILED; 654 rdata->event = RPORT_EV_FAILED;
668 fc_rport_state_enter(rport, RPORT_ST_NONE); 655 fc_rport_state_enter(rport, RPORT_ST_NONE);
669 queue_work(rport_event_queue, &rdata->event_work); 656 queue_work(rport_event_queue, &rdata->event_work);
@@ -695,12 +682,11 @@ static void fc_rport_logo_resp(struct fc_seq *sp, struct fc_frame *fp,
695 682
696 mutex_lock(&rdata->rp_mutex); 683 mutex_lock(&rdata->rp_mutex);
697 684
698 FC_DEBUG_RPORT("Received a LOGO response from port (%6x)\n", 685 FC_RPORT_DBG(rport, "Received a LOGO response\n");
699 rport->port_id);
700 686
701 if (rdata->rp_state != RPORT_ST_LOGO) { 687 if (rdata->rp_state != RPORT_ST_LOGO) {
702 FC_DEBUG_RPORT("Received a LOGO response, but in state %s\n", 688 FC_RPORT_DBG(rport, "Received a LOGO response, but in state "
703 fc_rport_state(rport)); 689 "%s\n", fc_rport_state(rport));
704 if (IS_ERR(fp)) 690 if (IS_ERR(fp))
705 goto err; 691 goto err;
706 goto out; 692 goto out;
@@ -715,7 +701,7 @@ static void fc_rport_logo_resp(struct fc_seq *sp, struct fc_frame *fp,
715 if (op == ELS_LS_ACC) { 701 if (op == ELS_LS_ACC) {
716 fc_rport_enter_rtv(rport); 702 fc_rport_enter_rtv(rport);
717 } else { 703 } else {
718 FC_DBG("Bad ELS response\n"); 704 FC_RPORT_DBG(rport, "Bad ELS response for LOGO command\n");
719 rdata->event = RPORT_EV_LOGO; 705 rdata->event = RPORT_EV_LOGO;
720 fc_rport_state_enter(rport, RPORT_ST_NONE); 706 fc_rport_state_enter(rport, RPORT_ST_NONE);
721 queue_work(rport_event_queue, &rdata->event_work); 707 queue_work(rport_event_queue, &rdata->event_work);
@@ -745,8 +731,8 @@ static void fc_rport_enter_prli(struct fc_rport *rport)
745 } *pp; 731 } *pp;
746 struct fc_frame *fp; 732 struct fc_frame *fp;
747 733
748 FC_DEBUG_RPORT("Port (%6x) entered PRLI state from %s state\n", 734 FC_RPORT_DBG(rport, "Port entered PRLI state from %s state\n",
749 rport->port_id, fc_rport_state(rport)); 735 fc_rport_state(rport));
750 736
751 fc_rport_state_enter(rport, RPORT_ST_PRLI); 737 fc_rport_state_enter(rport, RPORT_ST_PRLI);
752 738
@@ -784,12 +770,11 @@ static void fc_rport_rtv_resp(struct fc_seq *sp, struct fc_frame *fp,
784 770
785 mutex_lock(&rdata->rp_mutex); 771 mutex_lock(&rdata->rp_mutex);
786 772
787 FC_DEBUG_RPORT("Received a RTV response from port (%6x)\n", 773 FC_RPORT_DBG(rport, "Received a RTV response\n");
788 rport->port_id);
789 774
790 if (rdata->rp_state != RPORT_ST_RTV) { 775 if (rdata->rp_state != RPORT_ST_RTV) {
791 FC_DBG("Received a RTV response, but in state %s\n", 776 FC_RPORT_DBG(rport, "Received a RTV response, but in state "
792 fc_rport_state(rport)); 777 "%s\n", fc_rport_state(rport));
793 if (IS_ERR(fp)) 778 if (IS_ERR(fp))
794 goto err; 779 goto err;
795 goto out; 780 goto out;
@@ -844,8 +829,8 @@ static void fc_rport_enter_rtv(struct fc_rport *rport)
844 struct fc_rport_libfc_priv *rdata = rport->dd_data; 829 struct fc_rport_libfc_priv *rdata = rport->dd_data;
845 struct fc_lport *lport = rdata->local_port; 830 struct fc_lport *lport = rdata->local_port;
846 831
847 FC_DEBUG_RPORT("Port (%6x) entered RTV state from %s state\n", 832 FC_RPORT_DBG(rport, "Port entered RTV state from %s state\n",
848 rport->port_id, fc_rport_state(rport)); 833 fc_rport_state(rport));
849 834
850 fc_rport_state_enter(rport, RPORT_ST_RTV); 835 fc_rport_state_enter(rport, RPORT_ST_RTV);
851 836
@@ -875,8 +860,8 @@ static void fc_rport_enter_logo(struct fc_rport *rport)
875 struct fc_lport *lport = rdata->local_port; 860 struct fc_lport *lport = rdata->local_port;
876 struct fc_frame *fp; 861 struct fc_frame *fp;
877 862
878 FC_DEBUG_RPORT("Port (%6x) entered LOGO state from %s state\n", 863 FC_RPORT_DBG(rport, "Port entered LOGO state from %s state\n",
879 rport->port_id, fc_rport_state(rport)); 864 fc_rport_state(rport));
880 865
881 fc_rport_state_enter(rport, RPORT_ST_LOGO); 866 fc_rport_state_enter(rport, RPORT_ST_LOGO);
882 867
@@ -983,14 +968,13 @@ static void fc_rport_recv_plogi_req(struct fc_rport *rport,
983 968
984 fh = fc_frame_header_get(fp); 969 fh = fc_frame_header_get(fp);
985 970
986 FC_DEBUG_RPORT("Received PLOGI request from port (%6x) " 971 FC_RPORT_DBG(rport, "Received PLOGI request while in state %s\n",
987 "while in state %s\n", ntoh24(fh->fh_s_id), 972 fc_rport_state(rport));
988 fc_rport_state(rport));
989 973
990 sid = ntoh24(fh->fh_s_id); 974 sid = ntoh24(fh->fh_s_id);
991 pl = fc_frame_payload_get(fp, sizeof(*pl)); 975 pl = fc_frame_payload_get(fp, sizeof(*pl));
992 if (!pl) { 976 if (!pl) {
993 FC_DBG("incoming PLOGI from %x too short\n", sid); 977 FC_RPORT_DBG(rport, "Received PLOGI too short\n");
994 WARN_ON(1); 978 WARN_ON(1);
995 /* XXX TBD: send reject? */ 979 /* XXX TBD: send reject? */
996 fc_frame_free(fp); 980 fc_frame_free(fp);
@@ -1012,26 +996,26 @@ static void fc_rport_recv_plogi_req(struct fc_rport *rport,
1012 */ 996 */
1013 switch (rdata->rp_state) { 997 switch (rdata->rp_state) {
1014 case RPORT_ST_INIT: 998 case RPORT_ST_INIT:
1015 FC_DEBUG_RPORT("incoming PLOGI from %6x wwpn %llx state INIT " 999 FC_RPORT_DBG(rport, "Received PLOGI, wwpn %llx state INIT "
1016 "- reject\n", sid, (unsigned long long)wwpn); 1000 "- reject\n", (unsigned long long)wwpn);
1017 reject = ELS_RJT_UNSUP; 1001 reject = ELS_RJT_UNSUP;
1018 break; 1002 break;
1019 case RPORT_ST_PLOGI: 1003 case RPORT_ST_PLOGI:
1020 FC_DEBUG_RPORT("incoming PLOGI from %x in PLOGI state %d\n", 1004 FC_RPORT_DBG(rport, "Received PLOGI in PLOGI state %d\n",
1021 sid, rdata->rp_state); 1005 rdata->rp_state);
1022 if (wwpn < lport->wwpn) 1006 if (wwpn < lport->wwpn)
1023 reject = ELS_RJT_INPROG; 1007 reject = ELS_RJT_INPROG;
1024 break; 1008 break;
1025 case RPORT_ST_PRLI: 1009 case RPORT_ST_PRLI:
1026 case RPORT_ST_READY: 1010 case RPORT_ST_READY:
1027 FC_DEBUG_RPORT("incoming PLOGI from %x in logged-in state %d " 1011 FC_RPORT_DBG(rport, "Received PLOGI in logged-in state %d "
1028 "- ignored for now\n", sid, rdata->rp_state); 1012 "- ignored for now\n", rdata->rp_state);
1029 /* XXX TBD - should reset */ 1013 /* XXX TBD - should reset */
1030 break; 1014 break;
1031 case RPORT_ST_NONE: 1015 case RPORT_ST_NONE:
1032 default: 1016 default:
1033 FC_DEBUG_RPORT("incoming PLOGI from %x in unexpected " 1017 FC_RPORT_DBG(rport, "Received PLOGI in unexpected "
1034 "state %d\n", sid, rdata->rp_state); 1018 "state %d\n", rdata->rp_state);
1035 fc_frame_free(fp); 1019 fc_frame_free(fp);
1036 return; 1020 return;
1037 break; 1021 break;
@@ -1115,9 +1099,8 @@ static void fc_rport_recv_prli_req(struct fc_rport *rport,
1115 1099
1116 fh = fc_frame_header_get(rx_fp); 1100 fh = fc_frame_header_get(rx_fp);
1117 1101
1118 FC_DEBUG_RPORT("Received PRLI request from port (%6x) " 1102 FC_RPORT_DBG(rport, "Received PRLI request while in state %s\n",
1119 "while in state %s\n", ntoh24(fh->fh_s_id), 1103 fc_rport_state(rport));
1120 fc_rport_state(rport));
1121 1104
1122 switch (rdata->rp_state) { 1105 switch (rdata->rp_state) {
1123 case RPORT_ST_PRLI: 1106 case RPORT_ST_PRLI:
@@ -1252,9 +1235,8 @@ static void fc_rport_recv_prlo_req(struct fc_rport *rport, struct fc_seq *sp,
1252 1235
1253 fh = fc_frame_header_get(fp); 1236 fh = fc_frame_header_get(fp);
1254 1237
1255 FC_DEBUG_RPORT("Received PRLO request from port (%6x) " 1238 FC_RPORT_DBG(rport, "Received PRLO request while in state %s\n",
1256 "while in state %s\n", ntoh24(fh->fh_s_id), 1239 fc_rport_state(rport));
1257 fc_rport_state(rport));
1258 1240
1259 if (rdata->rp_state == RPORT_ST_NONE) { 1241 if (rdata->rp_state == RPORT_ST_NONE) {
1260 fc_frame_free(fp); 1242 fc_frame_free(fp);
@@ -1286,9 +1268,8 @@ static void fc_rport_recv_logo_req(struct fc_rport *rport, struct fc_seq *sp,
1286 1268
1287 fh = fc_frame_header_get(fp); 1269 fh = fc_frame_header_get(fp);
1288 1270
1289 FC_DEBUG_RPORT("Received LOGO request from port (%6x) " 1271 FC_RPORT_DBG(rport, "Received LOGO request while in state %s\n",
1290 "while in state %s\n", ntoh24(fh->fh_s_id), 1272 fc_rport_state(rport));
1291 fc_rport_state(rport));
1292 1273
1293 if (rdata->rp_state == RPORT_ST_NONE) { 1274 if (rdata->rp_state == RPORT_ST_NONE) {
1294 fc_frame_free(fp); 1275 fc_frame_free(fp);
@@ -1308,7 +1289,6 @@ static void fc_rport_flush_queue(void)
1308 flush_workqueue(rport_event_queue); 1289 flush_workqueue(rport_event_queue);
1309} 1290}
1310 1291
1311
1312int fc_rport_init(struct fc_lport *lport) 1292int fc_rport_init(struct fc_lport *lport)
1313{ 1293{
1314 if (!lport->tt.rport_create) 1294 if (!lport->tt.rport_create)