Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libfc: Add runtime debugging with debug_logging module parameter

This patch adds the /sys/module/libfc/parameters/debug_logging
file to sysfs as a module parameter. It accepts an integer
bitmask for logging. Currently it supports:

bit
LSB 0 = general libfc debugging
1 = lport debugging
2 = disc debugging
3 = rport debugging
4 = fcp debugging
5 = EM debugging
6 = exch/seq debugging
7 = scsi logging (mostly error handling)

the other bits are not used at this time.

The patch converts all of the libfc source files to use
these new macros and removes the old FC_DBG macro.

Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>

authored by

Robert Love and committed by
James Bottomley
7414705e 650bd12b

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