aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorRobert Love <robert.w.love@intel.com>2009-06-10 18:31:05 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2009-06-21 12:07:06 -0400
commit650bd12b9e31ec51d7ad0df3c4f94d863b827976 (patch)
treecacba1840f5e7e146f8da22cd9e5cd807061040f /drivers/scsi
parentd5488eb9cd2b06f7dcca7053274edb337987c67c (diff)
libfcoe: Add runtime debugging with module param debug_logging
This patch adds a 'debug_logging' module parameter to libfcoe.ko. It is an unsigned int that represents a bitmask of available debug logging levels, each of which can be tuned at runtime. Currently there are only two logging levels for this module- bit LSB 0 = libfcoe general logging 1 = FIP logging Signed-off-by: Robert Love <robert.w.love@intel.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/fcoe/libfcoe.c94
1 files changed, 54 insertions, 40 deletions
diff --git a/drivers/scsi/fcoe/libfcoe.c b/drivers/scsi/fcoe/libfcoe.c
index 2f5bc7fd3fa9..f544340d318b 100644
--- a/drivers/scsi/fcoe/libfcoe.c
+++ b/drivers/scsi/fcoe/libfcoe.c
@@ -56,15 +56,28 @@ static void fcoe_ctlr_recv_work(struct work_struct *);
56 56
57static u8 fcoe_all_fcfs[ETH_ALEN] = FIP_ALL_FCF_MACS; 57static u8 fcoe_all_fcfs[ETH_ALEN] = FIP_ALL_FCF_MACS;
58 58
59static u32 fcoe_ctlr_debug; /* 1 for basic, 2 for noisy debug */ 59unsigned int libfcoe_debug_logging;
60module_param_named(debug_logging, libfcoe_debug_logging, int, S_IRUGO|S_IWUSR);
61MODULE_PARM_DESC(debug_logging, "a bit mask of logging levels");
60 62
61#define FIP_DBG_LVL(level, fmt, args...) \ 63#define LIBFCOE_LOGGING 0x01 /* General logging, not categorized */
64#define LIBFCOE_FIP_LOGGING 0x02 /* FIP logging */
65
66#define LIBFCOE_CHECK_LOGGING(LEVEL, CMD) \
67do { \
68 if (unlikely(libfcoe_debug_logging & LEVEL)) \
62 do { \ 69 do { \
63 if (fcoe_ctlr_debug >= (level)) \ 70 CMD; \
64 FC_DBG(fmt, ##args); \ 71 } while (0); \
65 } while (0) 72} while (0);
73
74#define LIBFCOE_DBG(fmt, args...) \
75 LIBFCOE_CHECK_LOGGING(LIBFCOE_LOGGING, \
76 printk(KERN_INFO "libfcoe: " fmt, ##args);)
66 77
67#define FIP_DBG(fmt, args...) FIP_DBG_LVL(1, fmt, ##args) 78#define LIBFCOE_FIP_DBG(fmt, args...) \
79 LIBFCOE_CHECK_LOGGING(LIBFCOE_FIP_LOGGING, \
80 printk(KERN_INFO "fip: " fmt, ##args);)
68 81
69/* 82/*
70 * Return non-zero if FCF fcoe_size has been validated. 83 * Return non-zero if FCF fcoe_size has been validated.
@@ -243,7 +256,7 @@ void fcoe_ctlr_link_up(struct fcoe_ctlr *fip)
243 fip->last_link = 1; 256 fip->last_link = 1;
244 fip->link = 1; 257 fip->link = 1;
245 spin_unlock_bh(&fip->lock); 258 spin_unlock_bh(&fip->lock);
246 FIP_DBG("%s", "setting AUTO mode.\n"); 259 LIBFCOE_FIP_DBG("%s", "setting AUTO mode.\n");
247 fc_linkup(fip->lp); 260 fc_linkup(fip->lp);
248 fcoe_ctlr_solicit(fip, NULL); 261 fcoe_ctlr_solicit(fip, NULL);
249 } else 262 } else
@@ -614,7 +627,8 @@ static int fcoe_ctlr_parse_adv(struct sk_buff *skb, struct fcoe_fcf *fcf)
614 ((struct fip_mac_desc *)desc)->fd_mac, 627 ((struct fip_mac_desc *)desc)->fd_mac,
615 ETH_ALEN); 628 ETH_ALEN);
616 if (!is_valid_ether_addr(fcf->fcf_mac)) { 629 if (!is_valid_ether_addr(fcf->fcf_mac)) {
617 FIP_DBG("invalid MAC addr in FIP adv\n"); 630 LIBFCOE_FIP_DBG("Invalid MAC address "
631 "in FIP adv\n");
618 return -EINVAL; 632 return -EINVAL;
619 } 633 }
620 break; 634 break;
@@ -647,8 +661,8 @@ static int fcoe_ctlr_parse_adv(struct sk_buff *skb, struct fcoe_fcf *fcf)
647 case FIP_DT_LOGO: 661 case FIP_DT_LOGO:
648 case FIP_DT_ELP: 662 case FIP_DT_ELP:
649 default: 663 default:
650 FIP_DBG("unexpected descriptor type %x in FIP adv\n", 664 LIBFCOE_FIP_DBG("unexpected descriptor type %x "
651 desc->fip_dtype); 665 "in FIP adv\n", desc->fip_dtype);
652 /* standard says ignore unknown descriptors >= 128 */ 666 /* standard says ignore unknown descriptors >= 128 */
653 if (desc->fip_dtype < FIP_DT_VENDOR_BASE) 667 if (desc->fip_dtype < FIP_DT_VENDOR_BASE)
654 return -EINVAL; 668 return -EINVAL;
@@ -664,8 +678,8 @@ static int fcoe_ctlr_parse_adv(struct sk_buff *skb, struct fcoe_fcf *fcf)
664 return 0; 678 return 0;
665 679
666len_err: 680len_err:
667 FIP_DBG("FIP length error in descriptor type %x len %zu\n", 681 LIBFCOE_FIP_DBG("FIP length error in descriptor type %x len %zu\n",
668 desc->fip_dtype, dlen); 682 desc->fip_dtype, dlen);
669 return -EINVAL; 683 return -EINVAL;
670} 684}
671 685
@@ -728,9 +742,10 @@ static void fcoe_ctlr_recv_adv(struct fcoe_ctlr *fip, struct sk_buff *skb)
728 } 742 }
729 mtu_valid = fcoe_ctlr_mtu_valid(fcf); 743 mtu_valid = fcoe_ctlr_mtu_valid(fcf);
730 fcf->time = jiffies; 744 fcf->time = jiffies;
731 FIP_DBG_LVL(found ? 2 : 1, "%s FCF for fab %llx map %x val %d\n", 745 if (!found) {
732 found ? "old" : "new", 746 LIBFCOE_FIP_DBG("New FCF for fab %llx map %x val %d\n",
733 fcf->fabric_name, fcf->fc_map, mtu_valid); 747 fcf->fabric_name, fcf->fc_map, mtu_valid);
748 }
734 749
735 /* 750 /*
736 * If this advertisement is not solicited and our max receive size 751 * If this advertisement is not solicited and our max receive size
@@ -807,7 +822,8 @@ static void fcoe_ctlr_recv_els(struct fcoe_ctlr *fip, struct sk_buff *skb)
807 ((struct fip_mac_desc *)desc)->fd_mac, 822 ((struct fip_mac_desc *)desc)->fd_mac,
808 ETH_ALEN); 823 ETH_ALEN);
809 if (!is_valid_ether_addr(granted_mac)) { 824 if (!is_valid_ether_addr(granted_mac)) {
810 FIP_DBG("invalid MAC addrs in FIP ELS\n"); 825 LIBFCOE_FIP_DBG("Invalid MAC address "
826 "in FIP ELS\n");
811 goto drop; 827 goto drop;
812 } 828 }
813 break; 829 break;
@@ -825,8 +841,8 @@ static void fcoe_ctlr_recv_els(struct fcoe_ctlr *fip, struct sk_buff *skb)
825 els_dtype = desc->fip_dtype; 841 els_dtype = desc->fip_dtype;
826 break; 842 break;
827 default: 843 default:
828 FIP_DBG("unexpected descriptor type %x " 844 LIBFCOE_FIP_DBG("unexpected descriptor type %x "
829 "in FIP adv\n", desc->fip_dtype); 845 "in FIP adv\n", desc->fip_dtype);
830 /* standard says ignore unknown descriptors >= 128 */ 846 /* standard says ignore unknown descriptors >= 128 */
831 if (desc->fip_dtype < FIP_DT_VENDOR_BASE) 847 if (desc->fip_dtype < FIP_DT_VENDOR_BASE)
832 goto drop; 848 goto drop;
@@ -867,8 +883,8 @@ static void fcoe_ctlr_recv_els(struct fcoe_ctlr *fip, struct sk_buff *skb)
867 return; 883 return;
868 884
869len_err: 885len_err:
870 FIP_DBG("FIP length error in descriptor type %x len %zu\n", 886 LIBFCOE_FIP_DBG("FIP length error in descriptor type %x len %zu\n",
871 desc->fip_dtype, dlen); 887 desc->fip_dtype, dlen);
872drop: 888drop:
873 kfree_skb(skb); 889 kfree_skb(skb);
874} 890}
@@ -894,7 +910,7 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip,
894 struct fc_lport *lp = fip->lp; 910 struct fc_lport *lp = fip->lp;
895 u32 desc_mask; 911 u32 desc_mask;
896 912
897 FIP_DBG("Clear Virtual Link received\n"); 913 LIBFCOE_FIP_DBG("Clear Virtual Link received\n");
898 if (!fcf) 914 if (!fcf)
899 return; 915 return;
900 if (!fcf || !fc_host_port_id(lp->host)) 916 if (!fcf || !fc_host_port_id(lp->host))
@@ -952,9 +968,9 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip,
952 * reset only if all required descriptors were present and valid. 968 * reset only if all required descriptors were present and valid.
953 */ 969 */
954 if (desc_mask) { 970 if (desc_mask) {
955 FIP_DBG("missing descriptors mask %x\n", desc_mask); 971 LIBFCOE_FIP_DBG("missing descriptors mask %x\n", desc_mask);
956 } else { 972 } else {
957 FIP_DBG("performing Clear Virtual Link\n"); 973 LIBFCOE_FIP_DBG("performing Clear Virtual Link\n");
958 fcoe_ctlr_reset(fip, FIP_ST_ENABLED); 974 fcoe_ctlr_reset(fip, FIP_ST_ENABLED);
959 } 975 }
960} 976}
@@ -1002,10 +1018,6 @@ static int fcoe_ctlr_recv_handler(struct fcoe_ctlr *fip, struct sk_buff *skb)
1002 op = ntohs(fiph->fip_op); 1018 op = ntohs(fiph->fip_op);
1003 sub = fiph->fip_subcode; 1019 sub = fiph->fip_subcode;
1004 1020
1005 FIP_DBG_LVL(2, "ver %x op %x/%x dl %x fl %x\n",
1006 FIP_VER_DECAPS(fiph->fip_ver), op, sub,
1007 ntohs(fiph->fip_dl_len), ntohs(fiph->fip_flags));
1008
1009 if (FIP_VER_DECAPS(fiph->fip_ver) != FIP_VER) 1021 if (FIP_VER_DECAPS(fiph->fip_ver) != FIP_VER)
1010 goto drop; 1022 goto drop;
1011 if (ntohs(fiph->fip_dl_len) * FIP_BPW + sizeof(*fiph) > skb->len) 1023 if (ntohs(fiph->fip_dl_len) * FIP_BPW + sizeof(*fiph) > skb->len)
@@ -1017,7 +1029,7 @@ static int fcoe_ctlr_recv_handler(struct fcoe_ctlr *fip, struct sk_buff *skb)
1017 fip->map_dest = 0; 1029 fip->map_dest = 0;
1018 fip->state = FIP_ST_ENABLED; 1030 fip->state = FIP_ST_ENABLED;
1019 state = FIP_ST_ENABLED; 1031 state = FIP_ST_ENABLED;
1020 FIP_DBG("using FIP mode\n"); 1032 LIBFCOE_FIP_DBG("Using FIP mode\n");
1021 } 1033 }
1022 spin_unlock_bh(&fip->lock); 1034 spin_unlock_bh(&fip->lock);
1023 if (state != FIP_ST_ENABLED) 1035 if (state != FIP_ST_ENABLED)
@@ -1052,14 +1064,15 @@ static void fcoe_ctlr_select(struct fcoe_ctlr *fip)
1052 struct fcoe_fcf *best = NULL; 1064 struct fcoe_fcf *best = NULL;
1053 1065
1054 list_for_each_entry(fcf, &fip->fcfs, list) { 1066 list_for_each_entry(fcf, &fip->fcfs, list) {
1055 FIP_DBG("consider FCF for fab %llx VFID %d map %x val %d\n", 1067 LIBFCOE_FIP_DBG("consider FCF for fab %llx VFID %d map %x "
1056 fcf->fabric_name, fcf->vfid, 1068 "val %d\n", fcf->fabric_name, fcf->vfid,
1057 fcf->fc_map, fcoe_ctlr_mtu_valid(fcf)); 1069 fcf->fc_map, fcoe_ctlr_mtu_valid(fcf));
1058 if (!fcoe_ctlr_fcf_usable(fcf)) { 1070 if (!fcoe_ctlr_fcf_usable(fcf)) {
1059 FIP_DBG("FCF for fab %llx map %x %svalid %savailable\n", 1071 LIBFCOE_FIP_DBG("FCF for fab %llx map %x %svalid "
1060 fcf->fabric_name, fcf->fc_map, 1072 "%savailable\n", fcf->fabric_name,
1061 (fcf->flags & FIP_FL_SOL) ? "" : "in", 1073 fcf->fc_map, (fcf->flags & FIP_FL_SOL)
1062 (fcf->flags & FIP_FL_AVAIL) ? "" : "un"); 1074 ? "" : "in", (fcf->flags & FIP_FL_AVAIL)
1075 ? "" : "un");
1063 continue; 1076 continue;
1064 } 1077 }
1065 if (!best) { 1078 if (!best) {
@@ -1069,7 +1082,8 @@ static void fcoe_ctlr_select(struct fcoe_ctlr *fip)
1069 if (fcf->fabric_name != best->fabric_name || 1082 if (fcf->fabric_name != best->fabric_name ||
1070 fcf->vfid != best->vfid || 1083 fcf->vfid != best->vfid ||
1071 fcf->fc_map != best->fc_map) { 1084 fcf->fc_map != best->fc_map) {
1072 FIP_DBG("conflicting fabric, VFID, or FC-MAP\n"); 1085 LIBFCOE_FIP_DBG("Conflicting fabric, VFID, "
1086 "or FC-MAP\n");
1073 return; 1087 return;
1074 } 1088 }
1075 if (fcf->pri < best->pri) 1089 if (fcf->pri < best->pri)
@@ -1113,7 +1127,7 @@ static void fcoe_ctlr_timeout(unsigned long arg)
1113 if (sel != fcf) { 1127 if (sel != fcf) {
1114 fcf = sel; /* the old FCF may have been freed */ 1128 fcf = sel; /* the old FCF may have been freed */
1115 if (sel) { 1129 if (sel) {
1116 printk(KERN_INFO "host%d: FIP selected " 1130 printk(KERN_INFO "libfcoe: host%d: FIP selected "
1117 "Fibre-Channel Forwarder MAC %s\n", 1131 "Fibre-Channel Forwarder MAC %s\n",
1118 fip->lp->host->host_no, 1132 fip->lp->host->host_no,
1119 print_mac(buf, sel->fcf_mac)); 1133 print_mac(buf, sel->fcf_mac));
@@ -1123,7 +1137,7 @@ static void fcoe_ctlr_timeout(unsigned long arg)
1123 fip->ctlr_ka_time = jiffies + sel->fka_period; 1137 fip->ctlr_ka_time = jiffies + sel->fka_period;
1124 fip->link = 1; 1138 fip->link = 1;
1125 } else { 1139 } else {
1126 printk(KERN_NOTICE "host%d: " 1140 printk(KERN_NOTICE "libfcoe: host%d: "
1127 "FIP Fibre-Channel Forwarder timed out. " 1141 "FIP Fibre-Channel Forwarder timed out. "
1128 "Starting FCF discovery.\n", 1142 "Starting FCF discovery.\n",
1129 fip->lp->host->host_no); 1143 fip->lp->host->host_no);
@@ -1247,7 +1261,7 @@ int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *fip, struct fc_frame *fp, u8 *sa)
1247 return -EINVAL; 1261 return -EINVAL;
1248 } 1262 }
1249 fip->state = FIP_ST_NON_FIP; 1263 fip->state = FIP_ST_NON_FIP;
1250 FIP_DBG("received FLOGI LS_ACC using non-FIP mode\n"); 1264 LIBFCOE_FIP_DBG("received FLOGI LS_ACC using non-FIP mode\n");
1251 1265
1252 /* 1266 /*
1253 * FLOGI accepted. 1267 * FLOGI accepted.
@@ -1276,7 +1290,7 @@ int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *fip, struct fc_frame *fp, u8 *sa)
1276 memcpy(fip->dest_addr, sa, ETH_ALEN); 1290 memcpy(fip->dest_addr, sa, ETH_ALEN);
1277 fip->map_dest = 0; 1291 fip->map_dest = 0;
1278 if (fip->state == FIP_ST_NON_FIP) 1292 if (fip->state == FIP_ST_NON_FIP)
1279 FIP_DBG("received FLOGI REQ, " 1293 LIBFCOE_FIP_DBG("received FLOGI REQ, "
1280 "using non-FIP mode\n"); 1294 "using non-FIP mode\n");
1281 fip->state = FIP_ST_NON_FIP; 1295 fip->state = FIP_ST_NON_FIP;
1282 } 1296 }