Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4fd64dd0 authored by Stephen Hemminger's avatar Stephen Hemminger
Browse files

beceem: add network device message level control



Provide standard interface to control verbosity of debug messages

Signed-off-by: default avatarStephen Hemminger <shemminger@vyatta.com>
parent e39e3be6
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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;
+52 −14
Original line number Diff line number Diff line
#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);
	}
	}

	return 0;
}

static INT bcm_close(struct net_device *dev)
{
	if (!netif_queue_stopped(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);

+3 −1
Original line number Diff line number Diff line
@@ -2137,6 +2137,8 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adap
								netif_carrier_on(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);
+1 −6
Original line number Diff line number Diff line
@@ -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.
+9 −9
Original line number Diff line number Diff line
@@ -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 (netif_msg_link(Adapter))
		pr_notice(DRV_NAME "%s: protocol reset\n", Adapter->dev->name);

	if(NULL != Adapter->dev)
	{
	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));
	}
}