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>
This commit is contained in:
Robert Love 2009-06-10 15:31:05 -07:00 committed by James Bottomley
parent d5488eb9cd
commit 650bd12b9e

View File

@ -56,15 +56,28 @@ static void fcoe_ctlr_recv_work(struct work_struct *);
static u8 fcoe_all_fcfs[ETH_ALEN] = FIP_ALL_FCF_MACS; static u8 fcoe_all_fcfs[ETH_ALEN] = FIP_ALL_FCF_MACS;
static u32 fcoe_ctlr_debug; /* 1 for basic, 2 for noisy debug */ unsigned int libfcoe_debug_logging;
module_param_named(debug_logging, libfcoe_debug_logging, int, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(debug_logging, "a bit mask of logging levels");
#define FIP_DBG_LVL(level, fmt, args...) \ #define LIBFCOE_LOGGING 0x01 /* General logging, not categorized */
#define LIBFCOE_FIP_LOGGING 0x02 /* FIP logging */
#define LIBFCOE_CHECK_LOGGING(LEVEL, CMD) \
do { \ do { \
if (fcoe_ctlr_debug >= (level)) \ if (unlikely(libfcoe_debug_logging & LEVEL)) \
FC_DBG(fmt, ##args); \ do { \
} while (0) CMD; \
} while (0); \
} while (0);
#define FIP_DBG(fmt, args...) FIP_DBG_LVL(1, fmt, ##args) #define LIBFCOE_DBG(fmt, args...) \
LIBFCOE_CHECK_LOGGING(LIBFCOE_LOGGING, \
printk(KERN_INFO "libfcoe: " fmt, ##args);)
#define LIBFCOE_FIP_DBG(fmt, args...) \
LIBFCOE_CHECK_LOGGING(LIBFCOE_FIP_LOGGING, \
printk(KERN_INFO "fip: " fmt, ##args);)
/* /*
* Return non-zero if FCF fcoe_size has been validated. * Return non-zero if FCF fcoe_size has been validated.
@ -243,7 +256,7 @@ void fcoe_ctlr_link_up(struct fcoe_ctlr *fip)
fip->last_link = 1; fip->last_link = 1;
fip->link = 1; fip->link = 1;
spin_unlock_bh(&fip->lock); spin_unlock_bh(&fip->lock);
FIP_DBG("%s", "setting AUTO mode.\n"); LIBFCOE_FIP_DBG("%s", "setting AUTO mode.\n");
fc_linkup(fip->lp); fc_linkup(fip->lp);
fcoe_ctlr_solicit(fip, NULL); fcoe_ctlr_solicit(fip, NULL);
} else } else
@ -614,7 +627,8 @@ static int fcoe_ctlr_parse_adv(struct sk_buff *skb, struct fcoe_fcf *fcf)
((struct fip_mac_desc *)desc)->fd_mac, ((struct fip_mac_desc *)desc)->fd_mac,
ETH_ALEN); ETH_ALEN);
if (!is_valid_ether_addr(fcf->fcf_mac)) { if (!is_valid_ether_addr(fcf->fcf_mac)) {
FIP_DBG("invalid MAC addr in FIP adv\n"); LIBFCOE_FIP_DBG("Invalid MAC address "
"in FIP adv\n");
return -EINVAL; return -EINVAL;
} }
break; break;
@ -647,8 +661,8 @@ static int fcoe_ctlr_parse_adv(struct sk_buff *skb, struct fcoe_fcf *fcf)
case FIP_DT_LOGO: case FIP_DT_LOGO:
case FIP_DT_ELP: case FIP_DT_ELP:
default: default:
FIP_DBG("unexpected descriptor type %x in FIP adv\n", LIBFCOE_FIP_DBG("unexpected descriptor type %x "
desc->fip_dtype); "in FIP adv\n", desc->fip_dtype);
/* standard says ignore unknown descriptors >= 128 */ /* standard says ignore unknown descriptors >= 128 */
if (desc->fip_dtype < FIP_DT_VENDOR_BASE) if (desc->fip_dtype < FIP_DT_VENDOR_BASE)
return -EINVAL; return -EINVAL;
@ -664,7 +678,7 @@ static int fcoe_ctlr_parse_adv(struct sk_buff *skb, struct fcoe_fcf *fcf)
return 0; return 0;
len_err: len_err:
FIP_DBG("FIP length error in descriptor type %x len %zu\n", LIBFCOE_FIP_DBG("FIP length error in descriptor type %x len %zu\n",
desc->fip_dtype, dlen); desc->fip_dtype, dlen);
return -EINVAL; return -EINVAL;
} }
@ -728,9 +742,10 @@ static void fcoe_ctlr_recv_adv(struct fcoe_ctlr *fip, struct sk_buff *skb)
} }
mtu_valid = fcoe_ctlr_mtu_valid(fcf); mtu_valid = fcoe_ctlr_mtu_valid(fcf);
fcf->time = jiffies; fcf->time = jiffies;
FIP_DBG_LVL(found ? 2 : 1, "%s FCF for fab %llx map %x val %d\n", if (!found) {
found ? "old" : "new", LIBFCOE_FIP_DBG("New FCF for fab %llx map %x val %d\n",
fcf->fabric_name, fcf->fc_map, mtu_valid); fcf->fabric_name, fcf->fc_map, mtu_valid);
}
/* /*
* If this advertisement is not solicited and our max receive size * 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)
((struct fip_mac_desc *)desc)->fd_mac, ((struct fip_mac_desc *)desc)->fd_mac,
ETH_ALEN); ETH_ALEN);
if (!is_valid_ether_addr(granted_mac)) { if (!is_valid_ether_addr(granted_mac)) {
FIP_DBG("invalid MAC addrs in FIP ELS\n"); LIBFCOE_FIP_DBG("Invalid MAC address "
"in FIP ELS\n");
goto drop; goto drop;
} }
break; break;
@ -825,7 +841,7 @@ static void fcoe_ctlr_recv_els(struct fcoe_ctlr *fip, struct sk_buff *skb)
els_dtype = desc->fip_dtype; els_dtype = desc->fip_dtype;
break; break;
default: default:
FIP_DBG("unexpected descriptor type %x " LIBFCOE_FIP_DBG("unexpected descriptor type %x "
"in FIP adv\n", desc->fip_dtype); "in FIP adv\n", desc->fip_dtype);
/* standard says ignore unknown descriptors >= 128 */ /* standard says ignore unknown descriptors >= 128 */
if (desc->fip_dtype < FIP_DT_VENDOR_BASE) if (desc->fip_dtype < FIP_DT_VENDOR_BASE)
@ -867,7 +883,7 @@ static void fcoe_ctlr_recv_els(struct fcoe_ctlr *fip, struct sk_buff *skb)
return; return;
len_err: len_err:
FIP_DBG("FIP length error in descriptor type %x len %zu\n", LIBFCOE_FIP_DBG("FIP length error in descriptor type %x len %zu\n",
desc->fip_dtype, dlen); desc->fip_dtype, dlen);
drop: drop:
kfree_skb(skb); kfree_skb(skb);
@ -894,7 +910,7 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip,
struct fc_lport *lp = fip->lp; struct fc_lport *lp = fip->lp;
u32 desc_mask; u32 desc_mask;
FIP_DBG("Clear Virtual Link received\n"); LIBFCOE_FIP_DBG("Clear Virtual Link received\n");
if (!fcf) if (!fcf)
return; return;
if (!fcf || !fc_host_port_id(lp->host)) if (!fcf || !fc_host_port_id(lp->host))
@ -952,9 +968,9 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip,
* reset only if all required descriptors were present and valid. * reset only if all required descriptors were present and valid.
*/ */
if (desc_mask) { if (desc_mask) {
FIP_DBG("missing descriptors mask %x\n", desc_mask); LIBFCOE_FIP_DBG("missing descriptors mask %x\n", desc_mask);
} else { } else {
FIP_DBG("performing Clear Virtual Link\n"); LIBFCOE_FIP_DBG("performing Clear Virtual Link\n");
fcoe_ctlr_reset(fip, FIP_ST_ENABLED); fcoe_ctlr_reset(fip, FIP_ST_ENABLED);
} }
} }
@ -1002,10 +1018,6 @@ static int fcoe_ctlr_recv_handler(struct fcoe_ctlr *fip, struct sk_buff *skb)
op = ntohs(fiph->fip_op); op = ntohs(fiph->fip_op);
sub = fiph->fip_subcode; sub = fiph->fip_subcode;
FIP_DBG_LVL(2, "ver %x op %x/%x dl %x fl %x\n",
FIP_VER_DECAPS(fiph->fip_ver), op, sub,
ntohs(fiph->fip_dl_len), ntohs(fiph->fip_flags));
if (FIP_VER_DECAPS(fiph->fip_ver) != FIP_VER) if (FIP_VER_DECAPS(fiph->fip_ver) != FIP_VER)
goto drop; goto drop;
if (ntohs(fiph->fip_dl_len) * FIP_BPW + sizeof(*fiph) > skb->len) 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)
fip->map_dest = 0; fip->map_dest = 0;
fip->state = FIP_ST_ENABLED; fip->state = FIP_ST_ENABLED;
state = FIP_ST_ENABLED; state = FIP_ST_ENABLED;
FIP_DBG("using FIP mode\n"); LIBFCOE_FIP_DBG("Using FIP mode\n");
} }
spin_unlock_bh(&fip->lock); spin_unlock_bh(&fip->lock);
if (state != FIP_ST_ENABLED) if (state != FIP_ST_ENABLED)
@ -1052,14 +1064,15 @@ static void fcoe_ctlr_select(struct fcoe_ctlr *fip)
struct fcoe_fcf *best = NULL; struct fcoe_fcf *best = NULL;
list_for_each_entry(fcf, &fip->fcfs, list) { list_for_each_entry(fcf, &fip->fcfs, list) {
FIP_DBG("consider FCF for fab %llx VFID %d map %x val %d\n", LIBFCOE_FIP_DBG("consider FCF for fab %llx VFID %d map %x "
fcf->fabric_name, fcf->vfid, "val %d\n", fcf->fabric_name, fcf->vfid,
fcf->fc_map, fcoe_ctlr_mtu_valid(fcf)); fcf->fc_map, fcoe_ctlr_mtu_valid(fcf));
if (!fcoe_ctlr_fcf_usable(fcf)) { if (!fcoe_ctlr_fcf_usable(fcf)) {
FIP_DBG("FCF for fab %llx map %x %svalid %savailable\n", LIBFCOE_FIP_DBG("FCF for fab %llx map %x %svalid "
fcf->fabric_name, fcf->fc_map, "%savailable\n", fcf->fabric_name,
(fcf->flags & FIP_FL_SOL) ? "" : "in", fcf->fc_map, (fcf->flags & FIP_FL_SOL)
(fcf->flags & FIP_FL_AVAIL) ? "" : "un"); ? "" : "in", (fcf->flags & FIP_FL_AVAIL)
? "" : "un");
continue; continue;
} }
if (!best) { if (!best) {
@ -1069,7 +1082,8 @@ static void fcoe_ctlr_select(struct fcoe_ctlr *fip)
if (fcf->fabric_name != best->fabric_name || if (fcf->fabric_name != best->fabric_name ||
fcf->vfid != best->vfid || fcf->vfid != best->vfid ||
fcf->fc_map != best->fc_map) { fcf->fc_map != best->fc_map) {
FIP_DBG("conflicting fabric, VFID, or FC-MAP\n"); LIBFCOE_FIP_DBG("Conflicting fabric, VFID, "
"or FC-MAP\n");
return; return;
} }
if (fcf->pri < best->pri) if (fcf->pri < best->pri)
@ -1113,7 +1127,7 @@ static void fcoe_ctlr_timeout(unsigned long arg)
if (sel != fcf) { if (sel != fcf) {
fcf = sel; /* the old FCF may have been freed */ fcf = sel; /* the old FCF may have been freed */
if (sel) { if (sel) {
printk(KERN_INFO "host%d: FIP selected " printk(KERN_INFO "libfcoe: host%d: FIP selected "
"Fibre-Channel Forwarder MAC %s\n", "Fibre-Channel Forwarder MAC %s\n",
fip->lp->host->host_no, fip->lp->host->host_no,
print_mac(buf, sel->fcf_mac)); print_mac(buf, sel->fcf_mac));
@ -1123,7 +1137,7 @@ static void fcoe_ctlr_timeout(unsigned long arg)
fip->ctlr_ka_time = jiffies + sel->fka_period; fip->ctlr_ka_time = jiffies + sel->fka_period;
fip->link = 1; fip->link = 1;
} else { } else {
printk(KERN_NOTICE "host%d: " printk(KERN_NOTICE "libfcoe: host%d: "
"FIP Fibre-Channel Forwarder timed out. " "FIP Fibre-Channel Forwarder timed out. "
"Starting FCF discovery.\n", "Starting FCF discovery.\n",
fip->lp->host->host_no); fip->lp->host->host_no);
@ -1247,7 +1261,7 @@ int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *fip, struct fc_frame *fp, u8 *sa)
return -EINVAL; return -EINVAL;
} }
fip->state = FIP_ST_NON_FIP; fip->state = FIP_ST_NON_FIP;
FIP_DBG("received FLOGI LS_ACC using non-FIP mode\n"); LIBFCOE_FIP_DBG("received FLOGI LS_ACC using non-FIP mode\n");
/* /*
* FLOGI accepted. * FLOGI accepted.
@ -1276,7 +1290,7 @@ int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *fip, struct fc_frame *fp, u8 *sa)
memcpy(fip->dest_addr, sa, ETH_ALEN); memcpy(fip->dest_addr, sa, ETH_ALEN);
fip->map_dest = 0; fip->map_dest = 0;
if (fip->state == FIP_ST_NON_FIP) if (fip->state == FIP_ST_NON_FIP)
FIP_DBG("received FLOGI REQ, " LIBFCOE_FIP_DBG("received FLOGI REQ, "
"using non-FIP mode\n"); "using non-FIP mode\n");
fip->state = FIP_ST_NON_FIP; fip->state = FIP_ST_NON_FIP;
} }