[PATCH 036/510] beceem: add network device message level control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Stephen Hemminger <stephen.hemminger@xxxxxxxxxx>

Provide standard interface to control verbosity of debug messages

Signed-off-by: Stephen Hemminger <shemminger@xxxxxxxxxx>
---
 drivers/staging/bcm/Adapter.h       |    3 +-
 drivers/staging/bcm/Bcmnet.c        |   66 +++++++++++++++++++++++++++-------
 drivers/staging/bcm/CmHost.c        |    4 ++-
 drivers/staging/bcm/InterfaceInit.c |    7 +---
 drivers/staging/bcm/Misc.c          |   18 +++++-----
 5 files changed, 67 insertions(+), 31 deletions(-)

diff --git a/drivers/staging/bcm/Adapter.h b/drivers/staging/bcm/Adapter.h
index c216103..e5aaec5 100644
--- a/drivers/staging/bcm/Adapter.h
+++ b/drivers/staging/bcm/Adapter.h
@@ -382,6 +382,8 @@ Driver adapter data structure
 struct _MINI_ADAPTER
 {
 	struct _MINI_ADAPTER *next;
+	struct net_device	*dev;
+	u32			msg_enable;
 
 	CHAR                *caDsxReqResp;
 	atomic_t		ApplicationRunning;
@@ -437,7 +439,6 @@ struct _MINI_ADAPTER
 	BOOLEAN			    AutoLinkUp;
 	BOOLEAN			    AutoSyncup;
 
-	struct net_device	*dev;
 	int				major;
 	int				minor;
 	wait_queue_head_t 	tx_packet_wait_queue;
diff --git a/drivers/staging/bcm/Bcmnet.c b/drivers/staging/bcm/Bcmnet.c
index 3525f5c..641f3c8 100644
--- a/drivers/staging/bcm/Bcmnet.c
+++ b/drivers/staging/bcm/Bcmnet.c
@@ -1,19 +1,35 @@
 #include "headers.h"
 
+static int debug = -1;
+module_param(debug, uint, 0600);
+MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
+
+static const u32 default_msg =
+    NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK
+    | NETIF_MSG_TIMER | NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR
+    | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN;
+
 struct net_device *gblpnetdev;
 
 static INT bcm_open(struct net_device *dev)
 {
 	PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
 
-	if (Adapter->fw_download_done == FALSE)
-		return -EINVAL;
+	if (Adapter->fw_download_done == FALSE) {
+		pr_notice(DRV_NAME "%s: link up failed (download in progress)\n",
+			  dev->name);
+		return -EBUSY;
+	}
+
+	if (netif_msg_ifup(Adapter))
+		pr_info(DRV_NAME "%s: enabling interface\n", dev->name);
+
+	if (Adapter->LinkUpStatus) {
+		if (netif_msg_link(Adapter))
+			pr_info(DRV_NAME "%s: link up\n", dev->name);
 
-	if (Adapter->LinkUpStatus == 1) {
-		if (netif_queue_stopped(Adapter->dev)) {
-			netif_carrier_on(Adapter->dev);
-			netif_start_queue(Adapter->dev);
-		}
+		netif_carrier_on(Adapter->dev);
+		netif_start_queue(Adapter->dev);
 	}
 
 	return 0;
@@ -21,10 +37,14 @@ static INT bcm_open(struct net_device *dev)
 
 static INT bcm_close(struct net_device *dev)
 {
-	if (!netif_queue_stopped(dev)) {
-		netif_carrier_off(dev);
-		netif_stop_queue(dev);
-	}
+	PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
+
+	if (netif_msg_ifdown(Adapter))
+		pr_info(DRV_NAME "%s: disabling interface\n", dev->name);
+
+	netif_carrier_off(dev);
+	netif_stop_queue(dev);
+
 	return 0;
 }
 
@@ -70,6 +90,7 @@ static netdev_tx_t bcm_transmit(struct sk_buff *skb, struct net_device *dev)
 	PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
 	u16 qindex = skb_get_queue_mapping(skb);
 
+
 	if (Adapter->device_removed || !Adapter->LinkUpStatus)
 		goto drop;
 
@@ -84,9 +105,9 @@ static netdev_tx_t bcm_transmit(struct sk_buff *skb, struct net_device *dev)
 		return NETDEV_TX_BUSY;
 
 	/* Now Enqueue the packet */
-	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,
-			"bcm_transmit Enqueueing the Packet To Queue %d",
-			qindex);
+	if (netif_msg_tx_queued(Adapter))
+		pr_info(DRV_NAME "%s: enqueueing packet to queue %d\n",
+			dev->name, qindex);
 
 	spin_lock(&Adapter->PackInfo[qindex].SFQueueLock);
 	Adapter->PackInfo[qindex].uiCurrentBytesOnHost += skb->len;
@@ -168,10 +189,26 @@ static u32 bcm_get_link(struct net_device *dev)
 	return Adapter->LinkUpStatus;
 }
 
+static u32 bcm_get_msglevel (struct net_device *dev)
+{
+	PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
+
+	return Adapter->msg_enable;
+}
+
+static void bcm_set_msglevel (struct net_device *dev, u32 level)
+{
+	PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
+
+	Adapter->msg_enable = level;
+}
+
 static const struct ethtool_ops bcm_ethtool_ops = {
 	.get_settings	= bcm_get_settings,
 	.get_drvinfo	= bcm_get_drvinfo,
 	.get_link 	= bcm_get_link,
+	.get_msglevel	= bcm_get_msglevel,
+	.set_msglevel	= bcm_set_msglevel,
 };
 
 int register_networkdev(PMINI_ADAPTER Adapter)
@@ -185,6 +222,7 @@ int register_networkdev(PMINI_ADAPTER Adapter)
 	net->tx_queue_len = TX_QLEN;
 	net->flags |= IFF_NOARP;
 	net->flags &= ~(IFF_BROADCAST | IFF_MULTICAST);
+	Adapter->msg_enable = netif_msg_init(debug, default_msg);
 
 	netif_carrier_off(net);
 
diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c
index c8d73d5..e19f793 100644
--- a/drivers/staging/bcm/CmHost.c
+++ b/drivers/staging/bcm/CmHost.c
@@ -2135,8 +2135,10 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter,  /**<Pointer to the Adap
 							if(!Adapter->LinkUpStatus)
 							{
 								netif_carrier_on(Adapter->dev);
-    							netif_start_queue(Adapter->dev);
+								netif_start_queue(Adapter->dev);
 								Adapter->LinkUpStatus = 1;
+								if (netif_msg_link(Adapter))
+									pr_info(DRV_NAME "%s: link up\n", Adapter->dev->name);
 								do_gettimeofday(&tv);
 
 								atomic_set(&Adapter->TxPktAvail, 1);
diff --git a/drivers/staging/bcm/InterfaceInit.c b/drivers/staging/bcm/InterfaceInit.c
index 161141d..3529ea5 100644
--- a/drivers/staging/bcm/InterfaceInit.c
+++ b/drivers/staging/bcm/InterfaceInit.c
@@ -11,11 +11,6 @@ static struct usb_device_id InterfaceUsbtable[] = {
 };
 MODULE_DEVICE_TABLE(usb, InterfaceUsbtable);
 
-static unsigned int debug_level = DBG_LVL_CURR;
-module_param(debug_level, uint, 0644);
-MODULE_PARM_DESC(debug_level, "Debug level (0=none,...,7=all)");
-
-
 VOID InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter)
 {
 	INT i = 0;
@@ -164,7 +159,7 @@ usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id)
 
     /* Init default driver debug state */
 
-	psAdapter->stDebugState.debug_level = debug_level;
+	psAdapter->stDebugState.debug_level = DBG_LVL_CURR;
 	psAdapter->stDebugState.type = DBG_TYPE_INITEXIT;
 
     /* Technically, one can start using BCM_DEBUG_PRINT after this point.
diff --git a/drivers/staging/bcm/Misc.c b/drivers/staging/bcm/Misc.c
index 11e78ec..1b29744 100644
--- a/drivers/staging/bcm/Misc.c
+++ b/drivers/staging/bcm/Misc.c
@@ -1913,13 +1913,13 @@ void flush_queue(PMINI_ADAPTER Adapter, UINT iQIndex)
 
 void beceem_protocol_reset (PMINI_ADAPTER Adapter)
 {
-	int i =0;
+	int i;
 
-	if(NULL != Adapter->dev)
-	{
-		netif_carrier_off(Adapter->dev);
-		netif_stop_queue(Adapter->dev);
-	}
+	if (netif_msg_link(Adapter))
+		pr_notice(DRV_NAME "%s: protocol reset\n", Adapter->dev->name);
+
+	netif_carrier_off(Adapter->dev);
+	netif_stop_queue(Adapter->dev);
 
 	Adapter->IdleMode = FALSE;
 	Adapter->LinkUpStatus = FALSE;
@@ -1937,14 +1937,14 @@ void beceem_protocol_reset (PMINI_ADAPTER Adapter)
 		Adapter->TimerActive = FALSE;
 
 	memset(Adapter->astFragmentedPktClassifierTable, 0,
-			sizeof(S_FRAGMENTED_PACKET_INFO) *
-			MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES);
+	       sizeof(S_FRAGMENTED_PACKET_INFO) * MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES);
 
 	for(i = 0;i<HiPriority;i++)
 	{
 		//resetting only the first size (S_MIBS_SERVICEFLOW_TABLE) for the SF.
 		// It is same between MIBs and SF.
-		memset((PVOID)&Adapter->PackInfo[i],0,sizeof(S_MIBS_SERVICEFLOW_TABLE));
+		memset(&Adapter->PackInfo[i].stMibsExtServiceFlowTable,
+		       0, sizeof(S_MIBS_EXTSERVICEFLOW_PARAMETERS));
 	}
 }
 
-- 
1.7.3.2

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux