beceem: add network device message level control
authorStephen Hemminger <stephen.hemminger@vyatta.com>
Mon, 1 Nov 2010 16:12:31 +0000 (12:12 -0400)
committerStephen Hemminger <stephen.hemminger@vyatta.com>
Mon, 1 Nov 2010 16:12:31 +0000 (12:12 -0400)
Provide standard interface to control verbosity of debug messages

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
drivers/staging/bcm/Adapter.h
drivers/staging/bcm/Bcmnet.c
drivers/staging/bcm/CmHost.c
drivers/staging/bcm/InterfaceInit.c
drivers/staging/bcm/Misc.c

index c2161036d5ac1eb4dbb8194f49454080f496bf54..e5aaec508bf9d66e46212a6d0e47f6ca82b3743e 100644 (file)
@@ -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;
index 3525f5cf5358695e404b64e190c942e3618f6907..641f3c88a2d95ffd747a967f2d4ffe8c702b4ee7 100644 (file)
@@ -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);
 
index c8d73d524852af028fd9106c221a033cd7a4ed24..e19f7936d6f0d2cd604c4d4642cd3ee957f50bd6 100644 (file)
@@ -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);
index 161141d14565f3606947e5f2b3077a2f683dd50c..3529ea517dab2f4f72e1a96f6a725f3d25858602 100644 (file)
@@ -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.
index 11e78eccb2eef2ac700f1d41ccacdd6dae7b615d..1b29744e4cab7241e92bdeef754c24d72d5f9274 100644 (file)
@@ -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));
        }
 }