diff options
Diffstat (limited to 'drivers/scsi/libfc/fc_exch.c')
-rw-r--r-- | drivers/scsi/libfc/fc_exch.c | 58 |
1 files changed, 25 insertions, 33 deletions
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 | /* | 35 | static 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 | */ | ||
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 */ | ||
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 | } |
907 | EXPORT_SYMBOL(fc_seq_els_rsp_send); | 896 | EXPORT_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 | } |