netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] myri10ge: define some previously hardwired firmware constants
       [not found] <44E0DA08.9080304@myri.com>
@ 2006-08-14 21:52 ` Brice Goglin
  2006-08-14 21:53 ` [PATCH 2/3] myri10ge: allow to disable link status change reporting Brice Goglin
  2006-08-14 21:53 ` [PATCH 3/3] myri10ge: convert to netdev_alloc_skb Brice Goglin
  2 siblings, 0 replies; 6+ messages in thread
From: Brice Goglin @ 2006-08-14 21:52 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: netdev

Define some previously hardwired firmware constants.

Signed-off-by: Brice Goglin <brice@myri.com>
---
 drivers/net/myri10ge/myri10ge.c     |   17 ++++++++++-------
 drivers/net/myri10ge/myri10ge_mcp.h |   14 +++++++++++++-
 2 files changed, 23 insertions(+), 8 deletions(-)

Index: linux-mm/drivers/net/myri10ge/myri10ge.c
===================================================================
--- linux-mm.orig/drivers/net/myri10ge/myri10ge.c	2006-08-14 14:21:47.000000000 -0400
+++ linux-mm/drivers/net/myri10ge/myri10ge.c	2006-08-14 14:21:57.000000000 -0400
@@ -271,7 +271,7 @@
 	struct mcp_cmd *buf;
 	char buf_bytes[sizeof(*buf) + 8];
 	struct mcp_cmd_response *response = mgp->cmd;
-	char __iomem *cmd_addr = mgp->sram + MXGEFW_CMD_OFFSET;
+	char __iomem *cmd_addr = mgp->sram + MXGEFW_ETH_CMD;
 	u32 dma_low, dma_high, result, value;
 	int sleep_total = 0;
 
@@ -404,7 +404,7 @@
 	buf[4] = htonl(dma_low);	/* dummy addr LSW */
 	buf[5] = htonl(enable);	/* enable? */
 
-	submit = mgp->sram + 0xfc01c0;
+	submit = mgp->sram + MXGEFW_BOOT_DUMMY_RDMA;
 
 	myri10ge_pio_copy(submit, &buf, sizeof(buf));
 	for (i = 0; mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA && i < 20; i++)
@@ -600,7 +600,7 @@
 	buf[5] = htonl(8);	/* where to copy to */
 	buf[6] = htonl(0);	/* where to jump to */
 
-	submit = mgp->sram + 0xfc0000;
+	submit = mgp->sram + MXGEFW_BOOT_HANDOFF;
 
 	myri10ge_pio_copy(submit, &buf, sizeof(buf));
 	mb();
@@ -1648,9 +1648,11 @@
 	}
 
 	if (mgp->mtrr >= 0) {
-		mgp->tx.wc_fifo = (u8 __iomem *) mgp->sram + 0x200000;
-		mgp->rx_small.wc_fifo = (u8 __iomem *) mgp->sram + 0x300000;
-		mgp->rx_big.wc_fifo = (u8 __iomem *) mgp->sram + 0x340000;
+		mgp->tx.wc_fifo = (u8 __iomem *) mgp->sram + MXGEFW_ETH_SEND_4;
+		mgp->rx_small.wc_fifo =
+		    (u8 __iomem *) mgp->sram + MXGEFW_ETH_RECV_SMALL;
+		mgp->rx_big.wc_fifo =
+		    (u8 __iomem *) mgp->sram + MXGEFW_ETH_RECV_BIG;
 	} else {
 		mgp->tx.wc_fifo = NULL;
 		mgp->rx_small.wc_fifo = NULL;
@@ -1841,7 +1843,8 @@
 	if (cnt > 0) {
 		/* pad it to 64 bytes.  The src is 64 bytes bigger than it
 		 * needs to be so that we don't overrun it */
-		myri10ge_pio_copy(tx->wc_fifo + (cnt << 18), src, 64);
+		myri10ge_pio_copy(tx->wc_fifo + MXGEFW_ETH_SEND_OFFSET(cnt),
+				  src, 64);
 		mb();
 	}
 }
Index: linux-mm/drivers/net/myri10ge/myri10ge_mcp.h
===================================================================
--- linux-mm.orig/drivers/net/myri10ge/myri10ge_mcp.h	2006-08-14 14:21:47.000000000 -0400
+++ linux-mm/drivers/net/myri10ge/myri10ge_mcp.h	2006-08-14 14:21:57.000000000 -0400
@@ -91,7 +91,19 @@
 
 /* Commands */
 
-#define MXGEFW_CMD_OFFSET 0xf80000
+#define	MXGEFW_BOOT_HANDOFF	0xfc0000
+#define	MXGEFW_BOOT_DUMMY_RDMA	0xfc01c0
+
+#define	MXGEFW_ETH_CMD		0xf80000
+#define	MXGEFW_ETH_SEND_4	0x200000
+#define	MXGEFW_ETH_SEND_1	0x240000
+#define	MXGEFW_ETH_SEND_2	0x280000
+#define	MXGEFW_ETH_SEND_3	0x2c0000
+#define	MXGEFW_ETH_RECV_SMALL	0x300000
+#define	MXGEFW_ETH_RECV_BIG	0x340000
+
+#define	MXGEFW_ETH_SEND(n)		(0x200000 + (((n) & 0x03) * 0x40000))
+#define	MXGEFW_ETH_SEND_OFFSET(n)	(MXGEFW_ETH_SEND(n) - MXGEFW_ETH_SEND_4)
 
 enum myri10ge_mcp_cmd_type {
 	MXGEFW_CMD_NONE = 0,



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/3] myri10ge: allow to disable link status change reporting
       [not found] <44E0DA08.9080304@myri.com>
  2006-08-14 21:52 ` [PATCH 1/3] myri10ge: define some previously hardwired firmware constants Brice Goglin
@ 2006-08-14 21:53 ` Brice Goglin
  2006-08-14 22:02   ` Jeff Garzik
  2006-08-14 21:53 ` [PATCH 3/3] myri10ge: convert to netdev_alloc_skb Brice Goglin
  2 siblings, 1 reply; 6+ messages in thread
From: Brice Goglin @ 2006-08-14 21:53 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: netdev

Add myri10ge_verbose module parameter to disable reporting of
link status change since some Ethernet switches seem to generate
a lot of status changes under some circumstances and some people
want to avoid useless flooding in the logs.

Also add a counter for link status changes to statistics.

Signed-off-by: Brice Goglin <brice@myri.com>
---
 drivers/net/myri10ge/myri10ge.c |   26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

Index: linux-mm/drivers/net/myri10ge/myri10ge.c
===================================================================
--- linux-mm.orig/drivers/net/myri10ge/myri10ge.c	2006-08-14 14:22:07.000000000 -0400
+++ linux-mm/drivers/net/myri10ge/myri10ge.c	2006-08-14 14:30:50.000000000 -0400
@@ -192,6 +192,7 @@
 	u32 read_dma;
 	u32 write_dma;
 	u32 read_write_dma;
+	u32 link_changes;
 };
 
 static char *myri10ge_fw_unaligned = "myri10ge_ethp_z8e.dat";
@@ -257,6 +258,10 @@
 MODULE_PARM_DESC(myri10ge_max_irq_loops,
 		 "Set stuck legacy IRQ detection threshold\n");
 
+static int myri10ge_verbose = 1;
+module_param(myri10ge_verbose, int, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(myri10ge_verbose, "Enable verbose printing\n");
+
 #define MYRI10GE_FW_OFFSET 1024*1024
 #define MYRI10GE_HIGHPART_TO_U32(X) \
 (sizeof (X) == 8) ? ((u32)((u64)(X) >> 32)) : (0)
@@ -764,6 +769,7 @@
 	mgp->rx_small.cnt = 0;
 	mgp->rx_done.idx = 0;
 	mgp->rx_done.cnt = 0;
+	mgp->link_changes = 0;
 	status = myri10ge_update_mac_address(mgp, mgp->dev->dev_addr);
 	myri10ge_change_promisc(mgp, 0, 0);
 	myri10ge_change_pause(mgp, mgp->pause);
@@ -1085,13 +1091,19 @@
 		if (mgp->link_state != stats->link_up) {
 			mgp->link_state = stats->link_up;
 			if (mgp->link_state) {
-				printk(KERN_INFO "myri10ge: %s: link up\n",
-				       mgp->dev->name);
+				if (myri10ge_verbose)
+					printk(KERN_INFO
+					       "myri10ge: %s: link up\n",
+					       mgp->dev->name);
 				netif_carrier_on(mgp->dev);
+				mgp->link_changes++;
 			} else {
-				printk(KERN_INFO "myri10ge: %s: link down\n",
-				       mgp->dev->name);
+				if (myri10ge_verbose)
+					printk(KERN_INFO
+					       "myri10ge: %s: link down\n",
+					       mgp->dev->name);
 				netif_carrier_off(mgp->dev);
+				mgp->link_changes++;
 			}
 		}
 		if (mgp->rdma_tags_available !=
@@ -1293,8 +1305,9 @@
 	"serial_number", "tx_pkt_start", "tx_pkt_done",
 	"tx_req", "tx_done", "rx_small_cnt", "rx_big_cnt",
 	"wake_queue", "stop_queue", "watchdog_resets", "tx_linearized",
-	"link_up", "dropped_link_overflow", "dropped_link_error_or_filtered",
-	"dropped_runt", "dropped_overrun", "dropped_no_small_buffer",
+	"link_changes", "link_up", "dropped_link_overflow",
+	"dropped_link_error_or_filtered", "dropped_runt",
+	"dropped_overrun", "dropped_no_small_buffer",
 	"dropped_no_big_buffer"
 };
 
@@ -1345,6 +1358,7 @@
 	data[i++] = (unsigned int)mgp->stop_queue;
 	data[i++] = (unsigned int)mgp->watchdog_resets;
 	data[i++] = (unsigned int)mgp->tx_linearized;
+	data[i++] = (unsigned int)mgp->link_changes;
 	data[i++] = (unsigned int)ntohl(mgp->fw_stats->link_up);
 	data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_link_overflow);
 	data[i++] =



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3/3] myri10ge: convert to netdev_alloc_skb
       [not found] <44E0DA08.9080304@myri.com>
  2006-08-14 21:52 ` [PATCH 1/3] myri10ge: define some previously hardwired firmware constants Brice Goglin
  2006-08-14 21:53 ` [PATCH 2/3] myri10ge: allow to disable link status change reporting Brice Goglin
@ 2006-08-14 21:53 ` Brice Goglin
  2 siblings, 0 replies; 6+ messages in thread
From: Brice Goglin @ 2006-08-14 21:53 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: netdev

Convert the myri10ge driver to use netdev_alloc_skb instead of dev_alloc_skb,
which requires to propagate the net_device across several functions.

Signed-off-by: Brice Goglin <brice@myri.com>
---
 drivers/net/myri10ge/myri10ge.c |   37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

Index: linux-mm/drivers/net/myri10ge/myri10ge.c
===================================================================
--- linux-mm.orig/drivers/net/myri10ge/myri10ge.c	2006-08-14 14:21:57.000000000 -0400
+++ linux-mm/drivers/net/myri10ge/myri10ge.c	2006-08-14 14:22:07.000000000 -0400
@@ -798,12 +798,13 @@
  * pages directly and building a fraglist in the near future.
  */
 
-static inline struct sk_buff *myri10ge_alloc_big(int bytes)
+static inline struct sk_buff *myri10ge_alloc_big(struct net_device *dev,
+						 int bytes)
 {
 	struct sk_buff *skb;
 	unsigned long data, roundup;
 
-	skb = dev_alloc_skb(bytes + 4096 + MXGEFW_PAD);
+	skb = netdev_alloc_skb(dev, bytes + 4096 + MXGEFW_PAD);
 	if (skb == NULL)
 		return NULL;
 
@@ -821,12 +822,13 @@
 
 /* Allocate 2x as much space as required and use whichever portion
  * does not cross a 4KB boundary */
-static inline struct sk_buff *myri10ge_alloc_small_safe(unsigned int bytes)
+static inline struct sk_buff *myri10ge_alloc_small_safe(struct net_device *dev,
+							unsigned int bytes)
 {
 	struct sk_buff *skb;
 	unsigned long data, boundary;
 
-	skb = dev_alloc_skb(2 * (bytes + MXGEFW_PAD) - 1);
+	skb = netdev_alloc_skb(dev, 2 * (bytes + MXGEFW_PAD) - 1);
 	if (unlikely(skb == NULL))
 		return NULL;
 
@@ -847,12 +849,13 @@
 
 /* Allocate just enough space, and verify that the allocated
  * space does not cross a 4KB boundary */
-static inline struct sk_buff *myri10ge_alloc_small(int bytes)
+static inline struct sk_buff *myri10ge_alloc_small(struct net_device *dev,
+						   int bytes)
 {
 	struct sk_buff *skb;
 	unsigned long roundup, data, end;
 
-	skb = dev_alloc_skb(bytes + 16 + MXGEFW_PAD);
+	skb = netdev_alloc_skb(dev, bytes + 16 + MXGEFW_PAD);
 	if (unlikely(skb == NULL))
 		return NULL;
 
@@ -868,15 +871,17 @@
 		       "myri10ge_alloc_small: small skb crossed 4KB boundary\n");
 		myri10ge_skb_cross_4k = 1;
 		dev_kfree_skb_any(skb);
-		skb = myri10ge_alloc_small_safe(bytes);
+		skb = myri10ge_alloc_small_safe(dev, bytes);
 	}
 	return skb;
 }
 
 static inline int
-myri10ge_getbuf(struct myri10ge_rx_buf *rx, struct pci_dev *pdev, int bytes,
-		int idx)
+myri10ge_getbuf(struct myri10ge_rx_buf *rx, struct myri10ge_priv *mgp,
+		int bytes, int idx)
 {
+	struct net_device *dev = mgp->dev;
+	struct pci_dev *pdev = mgp->pdev;
 	struct sk_buff *skb;
 	dma_addr_t bus;
 	int len, retval = 0;
@@ -884,11 +889,11 @@
 	bytes += VLAN_HLEN;	/* account for 802.1q vlan tag */
 
 	if ((bytes + MXGEFW_PAD) > (4096 - 16) /* linux overhead */ )
-		skb = myri10ge_alloc_big(bytes);
+		skb = myri10ge_alloc_big(dev, bytes);
 	else if (myri10ge_skb_cross_4k)
-		skb = myri10ge_alloc_small_safe(bytes);
+		skb = myri10ge_alloc_small_safe(dev, bytes);
 	else
-		skb = myri10ge_alloc_small(bytes);
+		skb = myri10ge_alloc_small(dev, bytes);
 
 	if (unlikely(skb == NULL)) {
 		rx->alloc_fail++;
@@ -951,7 +956,7 @@
 	unmap_len = pci_unmap_len(&rx->info[idx], len);
 
 	/* try to replace the received skb */
-	if (myri10ge_getbuf(rx, mgp->pdev, bytes, idx)) {
+	if (myri10ge_getbuf(rx, mgp, bytes, idx)) {
 		/* drop the frame -- the old skbuf is re-cycled */
 		mgp->stats.rx_dropped += 1;
 		return 0;
@@ -968,7 +973,6 @@
 	skb_put(skb, len);
 
 	skb->protocol = eth_type_trans(skb, mgp->dev);
-	skb->dev = mgp->dev;
 	if (mgp->csum_flag) {
 		if ((skb->protocol == ntohs(ETH_P_IP)) ||
 		    (skb->protocol == ntohs(ETH_P_IPV6))) {
@@ -1439,7 +1443,7 @@
 	/* Fill the receive rings */
 
 	for (i = 0; i <= mgp->rx_small.mask; i++) {
-		status = myri10ge_getbuf(&mgp->rx_small, mgp->pdev,
+		status = myri10ge_getbuf(&mgp->rx_small, mgp,
 					 mgp->small_bytes, i);
 		if (status) {
 			printk(KERN_ERR
@@ -1451,8 +1455,7 @@
 
 	for (i = 0; i <= mgp->rx_big.mask; i++) {
 		status =
-		    myri10ge_getbuf(&mgp->rx_big, mgp->pdev,
-				    dev->mtu + ETH_HLEN, i);
+		    myri10ge_getbuf(&mgp->rx_big, mgp, dev->mtu + ETH_HLEN, i);
 		if (status) {
 			printk(KERN_ERR
 			       "myri10ge: %s: alloced only %d big bufs\n",



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] myri10ge: allow to disable link status change reporting
  2006-08-14 21:53 ` [PATCH 2/3] myri10ge: allow to disable link status change reporting Brice Goglin
@ 2006-08-14 22:02   ` Jeff Garzik
  2006-08-15 12:46     ` Brice Goglin
  0 siblings, 1 reply; 6+ messages in thread
From: Jeff Garzik @ 2006-08-14 22:02 UTC (permalink / raw)
  To: Brice Goglin; +Cc: netdev

Brice Goglin wrote:
> Add myri10ge_verbose module parameter to disable reporting of
> link status change since some Ethernet switches seem to generate
> a lot of status changes under some circumstances and some people
> want to avoid useless flooding in the logs.
> 
> Also add a counter for link status changes to statistics.
> 
> Signed-off-by: Brice Goglin <brice@myri.com>

NAK - use the standard netif_msg_xxx and the msg_enable style variable 
found in many drivers.  No need for a module parameter, ethtool already 
covers this type of need.

	Jeff




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] myri10ge: allow to disable link status change reporting
  2006-08-14 22:02   ` Jeff Garzik
@ 2006-08-15 12:46     ` Brice Goglin
  2006-08-15 12:49       ` Brice Goglin
  0 siblings, 1 reply; 6+ messages in thread
From: Brice Goglin @ 2006-08-15 12:46 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: netdev

Jeff Garzik wrote:

> Brice Goglin wrote:
>> Add myri10ge_verbose module parameter to disable reporting of
>> link status change since some Ethernet switches seem to generate
>> a lot of status changes under some circumstances and some people
>> want to avoid useless flooding in the logs.
>>
>> Also add a counter for link status changes to statistics.
>>
>> Signed-off-by: Brice Goglin <brice@myri.com>
>
> NAK - use the standard netif_msg_xxx and the msg_enable style variable
> found in many drivers.  No need for a module parameter, ethtool
> already covers this type of need.

Oh right, didn't know that, thanks.
Actually, most of the drivers I looked at also define an additional
module parameter "debug" (to initialize their "msg_enable") :) I
copied-pasted and did the same in the following patch. Would it be ok?
Once this is commited, we will probably use the other netif_msg_xxx()
later to disable/enable some other messages.

>From Brice Goglin <brice@myri.com>

[PATCH] myri10ge: use netif_msg_link

Add msg_enable and use netif_msg_link to enable/disable reporting
of link status changes since some Ethernet switches seem to generate
a lot of status changes under some circumstances and some people
want to avoid useless flooding in the logs.

Also add a counter for link status changes to statistics.
---
 drivers/net/myri10ge/myri10ge.c |   46 +++++++++++++++++++++++++++++++++-------
 1 file changed, 39 insertions(+), 7 deletions(-)

Index: linux-mm/drivers/net/myri10ge/myri10ge.c
===================================================================
--- linux-mm.orig/drivers/net/myri10ge/myri10ge.c	2006-08-14 21:48:14.000000000 -0400
+++ linux-mm/drivers/net/myri10ge/myri10ge.c	2006-08-14 22:13:17.000000000 -0400
@@ -192,6 +192,8 @@
 	u32 read_dma;
 	u32 write_dma;
 	u32 read_write_dma;
+	u32 link_changes;
+	u32 msg_enable;
 };
 
 static char *myri10ge_fw_unaligned = "myri10ge_ethp_z8e.dat";
@@ -257,6 +259,12 @@
 MODULE_PARM_DESC(myri10ge_max_irq_loops,
 		 "Set stuck legacy IRQ detection threshold\n");
 
+#define MYRI10GE_MSG_DEFAULT NETIF_MSG_LINK
+
+static int myri10ge_debug = -1;		/* defaults above */
+module_param(myri10ge_debug, int, 0);
+MODULE_PARM_DESC(myri10ge_debug, "Debug level (0=none,...,16=all)");
+
 #define MYRI10GE_FW_OFFSET 1024*1024
 #define MYRI10GE_HIGHPART_TO_U32(X) \
 (sizeof (X) == 8) ? ((u32)((u64)(X) >> 32)) : (0)
@@ -764,6 +772,7 @@
 	mgp->rx_small.cnt = 0;
 	mgp->rx_done.idx = 0;
 	mgp->rx_done.cnt = 0;
+	mgp->link_changes = 0;
 	status = myri10ge_update_mac_address(mgp, mgp->dev->dev_addr);
 	myri10ge_change_promisc(mgp, 0, 0);
 	myri10ge_change_pause(mgp, mgp->pause);
@@ -1085,13 +1094,19 @@
 		if (mgp->link_state != stats->link_up) {
 			mgp->link_state = stats->link_up;
 			if (mgp->link_state) {
-				printk(KERN_INFO "myri10ge: %s: link up\n",
-				       mgp->dev->name);
+				if (netif_msg_link(mgp))
+					printk(KERN_INFO
+					       "myri10ge: %s: link up\n",
+					       mgp->dev->name);
 				netif_carrier_on(mgp->dev);
+				mgp->link_changes++;
 			} else {
-				printk(KERN_INFO "myri10ge: %s: link down\n",
-				       mgp->dev->name);
+				if (netif_msg_link(mgp))
+					printk(KERN_INFO
+					       "myri10ge: %s: link down\n",
+					       mgp->dev->name);
 				netif_carrier_off(mgp->dev);
+				mgp->link_changes++;
 			}
 		}
 		if (mgp->rdma_tags_available !=
@@ -1293,8 +1308,9 @@
 	"serial_number", "tx_pkt_start", "tx_pkt_done",
 	"tx_req", "tx_done", "rx_small_cnt", "rx_big_cnt",
 	"wake_queue", "stop_queue", "watchdog_resets", "tx_linearized",
-	"link_up", "dropped_link_overflow", "dropped_link_error_or_filtered",
-	"dropped_runt", "dropped_overrun", "dropped_no_small_buffer",
+	"link_changes", "link_up", "dropped_link_overflow",
+	"dropped_link_error_or_filtered", "dropped_runt",
+	"dropped_overrun", "dropped_no_small_buffer",
 	"dropped_no_big_buffer"
 };
 
@@ -1345,6 +1361,7 @@
 	data[i++] = (unsigned int)mgp->stop_queue;
 	data[i++] = (unsigned int)mgp->watchdog_resets;
 	data[i++] = (unsigned int)mgp->tx_linearized;
+	data[i++] = (unsigned int)mgp->link_changes;
 	data[i++] = (unsigned int)ntohl(mgp->fw_stats->link_up);
 	data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_link_overflow);
 	data[i++] =
@@ -1355,6 +1372,18 @@
 	data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_no_big_buffer);
 }
 
+static void myri10ge_set_msglevel(struct net_device *netdev, u32 value)
+{
+	struct myri10ge_priv *mgp = netdev_priv(netdev);
+	mgp->msg_enable = value;
+}
+
+static u32 myri10ge_get_msglevel(struct net_device *netdev)
+{
+	struct myri10ge_priv *mgp = netdev_priv(netdev);
+	return mgp->msg_enable;
+}
+
 static struct ethtool_ops myri10ge_ethtool_ops = {
 	.get_settings = myri10ge_get_settings,
 	.get_drvinfo = myri10ge_get_drvinfo,
@@ -1375,7 +1404,9 @@
 #endif
 	.get_strings = myri10ge_get_strings,
 	.get_stats_count = myri10ge_get_stats_count,
-	.get_ethtool_stats = myri10ge_get_ethtool_stats
+	.get_ethtool_stats = myri10ge_get_ethtool_stats,
+	.set_msglevel = myri10ge_set_msglevel,
+	.get_msglevel = myri10ge_get_msglevel
 };
 
 static int myri10ge_allocate_rings(struct net_device *dev)
@@ -2580,6 +2611,7 @@
 	mgp->csum_flag = MXGEFW_FLAGS_CKSUM;
 	mgp->pause = myri10ge_flow_control;
 	mgp->intr_coal_delay = myri10ge_intr_coal_delay;
+	mgp->msg_enable = netif_msg_init(myri10ge_debug, MYRI10GE_MSG_DEFAULT);
 	init_waitqueue_head(&mgp->down_wq);
 
 	if (pci_enable_device(pdev)) {



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] myri10ge: allow to disable link status change reporting
  2006-08-15 12:46     ` Brice Goglin
@ 2006-08-15 12:49       ` Brice Goglin
  0 siblings, 0 replies; 6+ messages in thread
From: Brice Goglin @ 2006-08-15 12:49 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: netdev

Brice Goglin wrote:

> From Brice Goglin <brice@myri.com>
>
> [PATCH] myri10ge: use netif_msg_link
>
> Add msg_enable and use netif_msg_link to enable/disable reporting
> of link status changes since some Ethernet switches seem to generate
> a lot of status changes under some circumstances and some people
> want to avoid useless flooding in the logs.
>
> Also add a counter for link status changes to statistics.
>   

Signed-off-by: Brice Goglin <brice@myri.com>

> ---
>  drivers/net/myri10ge/myri10ge.c |   46 +++++++++++++++++++++++++++++++++-------
>  1 file changed, 39 insertions(+), 7 deletions(-)
>
> Index: linux-mm/drivers/net/myri10ge/myri10ge.c
> ===================================================================
> --- linux-mm.orig/drivers/net/myri10ge/myri10ge.c	2006-08-14 21:48:14.000000000 -0400
> +++ linux-mm/drivers/net/myri10ge/myri10ge.c	2006-08-14 22:13:17.000000000 -0400
> @@ -192,6 +192,8 @@
>  	u32 read_dma;
>  	u32 write_dma;
>  	u32 read_write_dma;
> +	u32 link_changes;
> +	u32 msg_enable;
>  };
>  
>  static char *myri10ge_fw_unaligned = "myri10ge_ethp_z8e.dat";
> @@ -257,6 +259,12 @@
>  MODULE_PARM_DESC(myri10ge_max_irq_loops,
>  		 "Set stuck legacy IRQ detection threshold\n");
>  
> +#define MYRI10GE_MSG_DEFAULT NETIF_MSG_LINK
> +
> +static int myri10ge_debug = -1;		/* defaults above */
> +module_param(myri10ge_debug, int, 0);
> +MODULE_PARM_DESC(myri10ge_debug, "Debug level (0=none,...,16=all)");
> +
>  #define MYRI10GE_FW_OFFSET 1024*1024
>  #define MYRI10GE_HIGHPART_TO_U32(X) \
>  (sizeof (X) == 8) ? ((u32)((u64)(X) >> 32)) : (0)
> @@ -764,6 +772,7 @@
>  	mgp->rx_small.cnt = 0;
>  	mgp->rx_done.idx = 0;
>  	mgp->rx_done.cnt = 0;
> +	mgp->link_changes = 0;
>  	status = myri10ge_update_mac_address(mgp, mgp->dev->dev_addr);
>  	myri10ge_change_promisc(mgp, 0, 0);
>  	myri10ge_change_pause(mgp, mgp->pause);
> @@ -1085,13 +1094,19 @@
>  		if (mgp->link_state != stats->link_up) {
>  			mgp->link_state = stats->link_up;
>  			if (mgp->link_state) {
> -				printk(KERN_INFO "myri10ge: %s: link up\n",
> -				       mgp->dev->name);
> +				if (netif_msg_link(mgp))
> +					printk(KERN_INFO
> +					       "myri10ge: %s: link up\n",
> +					       mgp->dev->name);
>  				netif_carrier_on(mgp->dev);
> +				mgp->link_changes++;
>  			} else {
> -				printk(KERN_INFO "myri10ge: %s: link down\n",
> -				       mgp->dev->name);
> +				if (netif_msg_link(mgp))
> +					printk(KERN_INFO
> +					       "myri10ge: %s: link down\n",
> +					       mgp->dev->name);
>  				netif_carrier_off(mgp->dev);
> +				mgp->link_changes++;
>  			}
>  		}
>  		if (mgp->rdma_tags_available !=
> @@ -1293,8 +1308,9 @@
>  	"serial_number", "tx_pkt_start", "tx_pkt_done",
>  	"tx_req", "tx_done", "rx_small_cnt", "rx_big_cnt",
>  	"wake_queue", "stop_queue", "watchdog_resets", "tx_linearized",
> -	"link_up", "dropped_link_overflow", "dropped_link_error_or_filtered",
> -	"dropped_runt", "dropped_overrun", "dropped_no_small_buffer",
> +	"link_changes", "link_up", "dropped_link_overflow",
> +	"dropped_link_error_or_filtered", "dropped_runt",
> +	"dropped_overrun", "dropped_no_small_buffer",
>  	"dropped_no_big_buffer"
>  };
>  
> @@ -1345,6 +1361,7 @@
>  	data[i++] = (unsigned int)mgp->stop_queue;
>  	data[i++] = (unsigned int)mgp->watchdog_resets;
>  	data[i++] = (unsigned int)mgp->tx_linearized;
> +	data[i++] = (unsigned int)mgp->link_changes;
>  	data[i++] = (unsigned int)ntohl(mgp->fw_stats->link_up);
>  	data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_link_overflow);
>  	data[i++] =
> @@ -1355,6 +1372,18 @@
>  	data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_no_big_buffer);
>  }
>  
> +static void myri10ge_set_msglevel(struct net_device *netdev, u32 value)
> +{
> +	struct myri10ge_priv *mgp = netdev_priv(netdev);
> +	mgp->msg_enable = value;
> +}
> +
> +static u32 myri10ge_get_msglevel(struct net_device *netdev)
> +{
> +	struct myri10ge_priv *mgp = netdev_priv(netdev);
> +	return mgp->msg_enable;
> +}
> +
>  static struct ethtool_ops myri10ge_ethtool_ops = {
>  	.get_settings = myri10ge_get_settings,
>  	.get_drvinfo = myri10ge_get_drvinfo,
> @@ -1375,7 +1404,9 @@
>  #endif
>  	.get_strings = myri10ge_get_strings,
>  	.get_stats_count = myri10ge_get_stats_count,
> -	.get_ethtool_stats = myri10ge_get_ethtool_stats
> +	.get_ethtool_stats = myri10ge_get_ethtool_stats,
> +	.set_msglevel = myri10ge_set_msglevel,
> +	.get_msglevel = myri10ge_get_msglevel
>  };
>  
>  static int myri10ge_allocate_rings(struct net_device *dev)
> @@ -2580,6 +2611,7 @@
>  	mgp->csum_flag = MXGEFW_FLAGS_CKSUM;
>  	mgp->pause = myri10ge_flow_control;
>  	mgp->intr_coal_delay = myri10ge_intr_coal_delay;
> +	mgp->msg_enable = netif_msg_init(myri10ge_debug, MYRI10GE_MSG_DEFAULT);
>  	init_waitqueue_head(&mgp->down_wq);
>  
>  	if (pci_enable_device(pdev)) {
>
>
>
>   


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-08-15 12:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <44E0DA08.9080304@myri.com>
2006-08-14 21:52 ` [PATCH 1/3] myri10ge: define some previously hardwired firmware constants Brice Goglin
2006-08-14 21:53 ` [PATCH 2/3] myri10ge: allow to disable link status change reporting Brice Goglin
2006-08-14 22:02   ` Jeff Garzik
2006-08-15 12:46     ` Brice Goglin
2006-08-15 12:49       ` Brice Goglin
2006-08-14 21:53 ` [PATCH 3/3] myri10ge: convert to netdev_alloc_skb Brice Goglin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).