All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Love <robert.w.love@intel.com>
To: james.bottomley@hansenpartnership.com, linux-scsi@vger.kernel.org
Cc: Robert Love <robert.w.love@intel.com>
Subject: [PATCH 07/17] fcoe: runtime debugging with debug_logging module parameter
Date: Fri, 06 Feb 2009 10:56:27 -0800	[thread overview]
Message-ID: <20090206185626.26188.52021.stgit@fritz> (raw)
In-Reply-To: <20090206185548.26188.51580.stgit@fritz>

This patch adds runtime debugging so that the user
can echo into /sys/module/fcoe/parameters/debug_logging
to enable or disable debug logging for fcoe.

Currently only on(non-zero)/off(zero) is supported by
this parameter.

This patch adds the drivers/scsi/fcoe/fcoe.h file for
shared fcoe defines. Currently only the logging code
is there, but later it may be used for other common
code.

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

 drivers/scsi/fcoe/fcoe.h    |   31 ++++++++++++++++++++++++++++
 drivers/scsi/fcoe/fcoe_sw.c |   16 ++++++++------
 drivers/scsi/fcoe/libfcoe.c |   48 +++++++++++++++++++++----------------------
 3 files changed, 63 insertions(+), 32 deletions(-)
 create mode 100644 drivers/scsi/fcoe/fcoe.h

diff --git a/drivers/scsi/fcoe/fcoe.h b/drivers/scsi/fcoe/fcoe.h
new file mode 100644
index 0000000..d15355f
--- /dev/null
+++ b/drivers/scsi/fcoe/fcoe.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright(c) 2009 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Maintained at www.Open-FCoE.org
+ */
+
+#ifndef _FCOE_H_
+#define _FCOE_H_
+
+extern unsigned int debug_logging;
+
+#define FCOE_DBG(fmt, args...)				       \
+do {							       \
+	if (unlikely(debug_logging))			       \
+		printk(KERN_INFO "%s " fmt, __func__, ##args); \
+} while (0)
+
+#endif /* _FCOE_H_ */
diff --git a/drivers/scsi/fcoe/fcoe_sw.c b/drivers/scsi/fcoe/fcoe_sw.c
index cf83675..e861c36 100644
--- a/drivers/scsi/fcoe/fcoe_sw.c
+++ b/drivers/scsi/fcoe/fcoe_sw.c
@@ -38,6 +38,8 @@
 #include <scsi/libfcoe.h>
 #include <scsi/fc_transport_fcoe.h>
 
+#include "fcoe.h"
+
 #define FCOE_SW_VERSION	"0.1"
 #define	FCOE_SW_NAME	"fcoesw"
 #define	FCOE_SW_VENDOR	"Open-FCoE.org"
@@ -251,7 +253,7 @@ static int fcoe_sw_shost_config(struct fc_lport *lp, struct Scsi_Host *shost,
 	/* add the new host to the SCSI-ml */
 	rc = scsi_add_host(lp->host, dev);
 	if (rc) {
-		FC_DBG("fcoe_sw_shost_config:error on scsi_add_host\n");
+		FCOE_DBG("fcoe_sw_shost_config:error on scsi_add_host\n");
 		return rc;
 	}
 	sprintf(fc_host_symbolic_name(lp->host), "%s v%s over %s",
@@ -381,7 +383,7 @@ static int fcoe_sw_create(struct net_device *netdev)
 	shost = fcoe_host_alloc(&fcoe_sw_shost_template,
 				sizeof(struct fcoe_softc));
 	if (!shost) {
-		FC_DBG("Could not allocate host structure\n");
+		FCOE_DBG("Could not allocate host structure\n");
 		return -ENOMEM;
 	}
 	lp = shost_priv(shost);
@@ -390,35 +392,35 @@ static int fcoe_sw_create(struct net_device *netdev)
 	/* configure fc_lport, e.g., em */
 	rc = fcoe_sw_lport_config(lp);
 	if (rc) {
-		FC_DBG("Could not configure lport\n");
+		FCOE_DBG("Could not configure lport\n");
 		goto out_host_put;
 	}
 
 	/* configure lport network properties */
 	rc = fcoe_sw_netdev_config(lp, netdev);
 	if (rc) {
-		FC_DBG("Could not configure netdev for lport\n");
+		FCOE_DBG("Could not configure netdev for lport\n");
 		goto out_host_put;
 	}
 
 	/* configure lport scsi host properties */
 	rc = fcoe_sw_shost_config(lp, shost, &netdev->dev);
 	if (rc) {
-		FC_DBG("Could not configure shost for lport\n");
+		FCOE_DBG("Could not configure shost for lport\n");
 		goto out_host_put;
 	}
 
 	/* lport exch manager allocation */
 	rc = fcoe_sw_em_config(lp);
 	if (rc) {
-		FC_DBG("Could not configure em for lport\n");
+		FCOE_DBG("Could not configure em for lport\n");
 		goto out_host_put;
 	}
 
 	/* Initialize the library */
 	rc = fcoe_libfc_config(lp, &fcoe_sw_libfc_fcn_templ);
 	if (rc) {
-		FC_DBG("Could not configure libfc for lport!\n");
+		FCOE_DBG("Could not configure libfc for lport!\n");
 		goto out_lp_destroy;
 	}
 
diff --git a/drivers/scsi/fcoe/libfcoe.c b/drivers/scsi/fcoe/libfcoe.c
index 2960710..594295b 100644
--- a/drivers/scsi/fcoe/libfcoe.c
+++ b/drivers/scsi/fcoe/libfcoe.c
@@ -46,7 +46,7 @@
 #include <scsi/libfcoe.h>
 #include <scsi/fc_transport_fcoe.h>
 
-static int debug_fcoe;
+#include "fcoe.h"
 
 #define FCOE_MAX_QUEUE_DEPTH  256
 
@@ -60,13 +60,16 @@ MODULE_AUTHOR("Open-FCoE.org");
 MODULE_DESCRIPTION("FCoE");
 MODULE_LICENSE("GPL");
 
+unsigned int debug_logging;
+module_param(debug_logging, int, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(debug_logging, "a bit mask of logging levels");
+
 /* fcoe host list */
 LIST_HEAD(fcoe_hostlist);
 DEFINE_RWLOCK(fcoe_hostlist_lock);
 DEFINE_TIMER(fcoe_timer, NULL, 0, 0);
 struct fcoe_percpu_s *fcoe_percpu[NR_CPUS];
 
-
 /* Function Prototyes */
 static int fcoe_check_wait_queue(struct fc_lport *);
 static void fcoe_insert_wait_queue_head(struct fc_lport *, struct sk_buff *);
@@ -191,22 +194,19 @@ int fcoe_rcv(struct sk_buff *skb, struct net_device *dev,
 	fc = container_of(ptype, struct fcoe_softc, fcoe_packet_type);
 	lp = fc->lp;
 	if (unlikely(lp == NULL)) {
-		FC_DBG("cannot find hba structure");
+		FCOE_DBG("cannot find hba structure");
 		goto err2;
 	}
 
-	if (unlikely(debug_fcoe)) {
-		FC_DBG("skb_info: len:%d data_len:%d head:%p data:%p tail:%p "
-		       "end:%p sum:%d dev:%s", skb->len, skb->data_len,
-		       skb->head, skb->data, skb_tail_pointer(skb),
-		       skb_end_pointer(skb), skb->csum,
-		       skb->dev ? skb->dev->name : "<NULL>");
-
-	}
+	FCOE_DBG("skb_info: len:%d data_len:%d head:%p data:%p tail:%p "
+		 "end:%p sum:%d dev:%s", skb->len, skb->data_len,
+		 skb->head, skb->data, skb_tail_pointer(skb),
+		 skb_end_pointer(skb), skb->csum,
+		 skb->dev ? skb->dev->name : "<NULL>");
 
 	/* check for FCOE packet type */
 	if (unlikely(eth_hdr(skb)->h_proto != htons(ETH_P_FCOE))) {
-		FC_DBG("wrong FC type frame");
+		FCOE_DBG("wrong FC type frame");
 		goto err;
 	}
 
@@ -551,21 +551,19 @@ int fcoe_percpu_receive_thread(void *arg)
 		fr = fcoe_dev_from_skb(skb);
 		lp = fr->fr_dev;
 		if (unlikely(lp == NULL)) {
-			FC_DBG("invalid HBA Structure");
+			FCOE_DBG("invalid HBA Structure");
 			kfree_skb(skb);
 			continue;
 		}
 
 		stats = lp->dev_stats[smp_processor_id()];
 
-		if (unlikely(debug_fcoe)) {
-			FC_DBG("skb_info: len:%d data_len:%d head:%p data:%p "
-			       "tail:%p end:%p sum:%d dev:%s",
-			       skb->len, skb->data_len,
-			       skb->head, skb->data, skb_tail_pointer(skb),
-			       skb_end_pointer(skb), skb->csum,
-			       skb->dev ? skb->dev->name : "<NULL>");
-		}
+		FCOE_DBG("skb_info: len:%d data_len:%d head:%p data:%p "
+			 "tail:%p end:%p sum:%d dev:%s",
+			 skb->len, skb->data_len,
+			 skb->head, skb->data, skb_tail_pointer(skb),
+			 skb_end_pointer(skb), skb->csum,
+			 skb->dev ? skb->dev->name : "<NULL>");
 
 		/*
 		 * Save source MAC address before discarding header.
@@ -587,8 +585,8 @@ int fcoe_percpu_receive_thread(void *arg)
 		if (unlikely(FC_FCOE_DECAPS_VER(hp) != FC_FCOE_VER)) {
 			if (stats) {
 				if (stats->ErrorFrames < 5)
-					FC_DBG("unknown FCoE version %x",
-					       FC_FCOE_DECAPS_VER(hp));
+					FCOE_DBG("unknown FCoE version %x",
+						 FC_FCOE_DECAPS_VER(hp));
 				stats->ErrorFrames++;
 			}
 			kfree_skb(skb);
@@ -639,7 +637,7 @@ int fcoe_percpu_receive_thread(void *arg)
 		if (fr_flags(fp) & FCPHF_CRC_UNCHECKED) {
 			if (le32_to_cpu(fr_crc(fp)) !=
 			    ~crc32(~0, skb->data, fr_len)) {
-				if (debug_fcoe || stats->InvalidCRCCount < 5)
+				if (debug_logging || stats->InvalidCRCCount < 5)
 					printk(KERN_WARNING "fcoe: dropping "
 					       "frame with CRC error\n");
 				stats->InvalidCRCCount++;
@@ -908,7 +906,7 @@ static int fcoe_device_notification(struct notifier_block *notifier,
 	case NETDEV_REGISTER:
 		break;
 	default:
-		FC_DBG("unknown event %ld call", event);
+		FCOE_DBG("unknown event %ld call", event);
 	}
 	if (lp->link_up != new_link_up) {
 		if (new_link_up)


  parent reply	other threads:[~2009-02-06 18:56 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-06 18:55 [PATCH 00/17] Open-FCoE Updates Robert Love
2009-02-06 18:55 ` [PATCH 01/17] libfc: fixed a read IO data integrity issue when a IO data frame lost Robert Love
2009-02-06 18:55 ` [PATCH 02/17] fcoe: exch mgr is freed while lport still retrying sequences Robert Love
2009-02-06 18:56 ` [PATCH 03/17] libfc: Don't violate transport template for rogue port creation Robert Love
2009-02-06 18:56 ` [PATCH 04/17] libfc: correct RPORT_TO_PRIV usage Robert Love
2009-02-06 18:56 ` [PATCH 05/17] libfc: rename rp to rdata in fc_disc_new_target() Robert Love
2009-02-06 18:56 ` [PATCH 06/17] libfc: check for err when recv and state is incorrect Robert Love
2009-02-06 18:56 ` Robert Love [this message]
2009-02-06 18:56 ` [PATCH 08/17] fcoe: Logging review changes Robert Love
2009-02-06 18:56 ` [PATCH 09/17] libfc: runtime debugging with debug_logging module parameter Robert Love
2009-02-06 18:56 ` [PATCH 10/17] libfc: Logging review changes Robert Love
2009-02-06 18:56 ` [PATCH 11/17] libfc: Cleanup libfc_function_template comments Robert Love
2009-02-06 18:56 ` [PATCH 12/17] libfc, fcoe: Fix kerneldoc comments Robert Love
2009-02-06 18:56 ` [PATCH 13/17] libfc, fcoe: Cleanup function formatting and minor typos Robert Love
2009-02-06 18:57 ` [PATCH 14/17] libfc, fcoe: Remove unnecessary cast by removing inline wrapper Robert Love
2009-02-06 18:57 ` [PATCH 15/17] fcoe: Use setup_timer() and mod_timer() Robert Love
2009-02-06 18:57 ` [PATCH 16/17] fcoe: Correct fcoe_transports initialization vs. registration Robert Love
2009-02-06 18:57 ` [PATCH 17/17] [SCSI] fcoe: fix kfree(skb) Robert Love
2009-02-26  2:49 ` [PATCH 00/17] Open-FCoE Updates Mike Christie
2009-02-26 18:29   ` Robert Love
2009-02-26 19:05     ` James Bottomley
2009-02-26 19:54       ` Love, Robert W
2009-03-02 22:24       ` Love, Robert W

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090206185626.26188.52021.stgit@fritz \
    --to=robert.w.love@intel.com \
    --cc=james.bottomley@hansenpartnership.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.