Netdev List
 help / color / mirror / Atom feed
* [PATCH 0/3] netdev/phy/of: Improve 10G Ethernet PHY support.
From: David Daney @ 2011-10-12 18:06 UTC (permalink / raw)
  To: devicetree-discuss, grant.likely, linux-kernel, netdev, davem
  Cc: afleming, David Daney

The PHY driver core needs a couple of adjustments to be able to
support 10G PHYs.  The main issue being that they use a different MDIO
bus protocol (IEEE802.3 clause 45).

The changes are not large:

1) The addr argument to get_phy_id() and get_phy_device() can be
   flagged to indicate clause 45 addressing.

2) The device tree helper of_mdiobus_register() uses a new
   "compatible" value to hook up the 10G phys.

3) A driver for the BCM8706 which makes use of it all.

David Daney (3):
  netdev/phy: Handle IEEE802.3 clause 45 Ethernet PHYs
  netdev/phy/of: Handle IEEE802.3 clause 45 Ethernet PHYs in
    of_mdiobus_register()
  netdev/phy: Add driver for Broadcom BCM8706 10G Ethernet PHY

 .../devicetree/bindings/net/broadcom-bcm8706.txt   |   28 +++
 Documentation/devicetree/bindings/net/phy.txt      |   12 +-
 drivers/net/phy/Kconfig                            |    5 +
 drivers/net/phy/Makefile                           |    1 +
 drivers/net/phy/bcm8706.c                          |  212 ++++++++++++++++++++
 drivers/net/phy/phy_device.c                       |   25 ++-
 drivers/of/of_mdio.c                               |    4 +
 include/linux/brcmphy.h                            |    1 +
 include/linux/phy.h                                |    3 +
 9 files changed, 287 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/broadcom-bcm8706.txt
 create mode 100644 drivers/net/phy/bcm8706.c

-- 
1.7.2.3

^ permalink raw reply

* Re: Seamless Service Restart / Port Takeover
From: Rick Jones @ 2011-10-12 17:14 UTC (permalink / raw)
  To: Olaf van der Spek; +Cc: netdev
In-Reply-To: <CAGVGHmuVnsw4mdsxO=93yaYRgGaj20gR0+nNB_iaS=nTM_BThw@mail.gmail.com>

On 10/12/2011 09:53 AM, Olaf van der Spek wrote:
> Hi,
>
> When restarting a service, a webserver for example, you'd like this to
> be seamless for clients. Often, first a signal is send to the old
> process to close listening sockets, then the new process is started.
> This has both a race condition (sometimes 'avoided' with a sleep in
> between) and service interruption.
> Wouldn't it be possible to introduce mv / move like behaviour, where
> the socket can be rebound without races and without interruption?

I believe you can do that today if you write the application such that 
the old instance, before it closes the listen endpoint and terminates, 
instead passes access to it to the new instance via a Unix domain socket 
between the two.

rick jones

^ permalink raw reply

* Seamless Service Restart / Port Takeover
From: Olaf van der Spek @ 2011-10-12 16:53 UTC (permalink / raw)
  To: netdev

Hi,

When restarting a service, a webserver for example, you'd like this to
be seamless for clients. Often, first a signal is send to the old
process to close listening sockets, then the new process is started.
This has both a race condition (sometimes 'avoided' with a sleep in
between) and service interruption.
Wouldn't it be possible to introduce mv / move like behaviour, where
the socket can be rebound without races and without interruption?

Olaf

^ permalink raw reply

* Re: [PATCH] IPVS netns shutdown/startup dead-lock
From: Pablo Neira Ayuso @ 2011-10-12 16:33 UTC (permalink / raw)
  To: Simon Horman
  Cc: Patrick McHardy, lvs-devel, netdev, netfilter-devel,
	Wensong Zhang, Julian Anastasov, David Miller, Hans Schillstrom
In-Reply-To: <1318298075-23501-2-git-send-email-horms@verge.net.au>

On Tue, Oct 11, 2011 at 10:54:35AM +0900, Simon Horman wrote:
> From: Hans Schillstrom <hans@schillstrom.com>
> 
> ip_vs_mutext is used by both netns shutdown code and startup
> and both implicit uses sk_lock-AF_INET mutex.
> 
> cleanup CPU-1         startup CPU-2
> ip_vs_dst_event()     ip_vs_genl_set_cmd()
>  sk_lock-AF_INET     __ip_vs_mutex
>                      sk_lock-AF_INET
> __ip_vs_mutex
> * DEAD LOCK *
> 
> A new mutex placed in ip_vs netns struct called sync_mutex is added.
> 
> Comments from Julian and Simon added.
> This patch has been running for more than 3 month now and it seems to work.
> 
> Ver. 3
>     IP_VS_SO_GET_DAEMON in do_ip_vs_get_ctl protected by sync_mutex
>     instead of __ip_vs_mutex as sugested by Julian.

Applied, thanks Simon.

http://1984.lsi.us.es/git/?p=net/.git;a=shortlog;h=refs/heads/nf

^ permalink raw reply

* [PATCH net-next 3/5] igbvf: Convert printks to pr_<level>
From: Joe Perches @ 2011-10-12 16:18 UTC (permalink / raw)
  To: Jeff Kirsher, linux-kernel
  Cc: netdev, Jesse Brandeburg, Bruce Allan, Carolyn Wyborny,
	Don Skidmore, Greg Rose, Peter P Waskiewicz Jr, Alex Duyck,
	John Ronciak, e1000-devel
In-Reply-To: <cover.1318436085.git.joe@perches.com>

Use current logging styles.

Prefix all output via #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
Neaten link status dev_info.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/ethernet/intel/igbvf/netdev.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c
index b3d760b..952ffcd 100644
--- a/drivers/net/ethernet/intel/igbvf/netdev.c
+++ b/drivers/net/ethernet/intel/igbvf/netdev.c
@@ -25,6 +25,8 @@
 
 *******************************************************************************/
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/init.h>
@@ -51,7 +53,7 @@ const char igbvf_driver_version[] = DRV_VERSION;
 static const char igbvf_driver_string[] =
 				"Intel(R) Virtual Function Network Driver";
 static const char igbvf_copyright[] =
-				"Copyright (c) 2009 - 2010 Intel Corporation.";
+				"Copyright (c) 2009 - 2010 Intel Corporation";
 
 static int igbvf_poll(struct napi_struct *napi, int budget);
 static void igbvf_reset(struct igbvf_adapter *);
@@ -1746,10 +1748,9 @@ void igbvf_update_stats(struct igbvf_adapter *adapter)
 
 static void igbvf_print_link_info(struct igbvf_adapter *adapter)
 {
-	dev_info(&adapter->pdev->dev, "Link is Up %d Mbps %s\n",
+	dev_info(&adapter->pdev->dev, "Link is Up %d Mbps %s Duplex\n",
 	         adapter->link_speed,
-	         ((adapter->link_duplex == FULL_DUPLEX) ?
-	          "Full Duplex" : "Half Duplex"));
+	         adapter->link_duplex == FULL_DUPLEX ? "Full" : "Half");
 }
 
 static bool igbvf_has_link(struct igbvf_adapter *adapter)
@@ -2825,9 +2826,8 @@ static struct pci_driver igbvf_driver = {
 static int __init igbvf_init_module(void)
 {
 	int ret;
-	printk(KERN_INFO "%s - version %s\n",
-	       igbvf_driver_string, igbvf_driver_version);
-	printk(KERN_INFO "%s\n", igbvf_copyright);
+	pr_info("%s - version %s\n", igbvf_driver_string, igbvf_driver_version);
+	pr_info("%s\n", igbvf_copyright);
 
 	ret = pci_register_driver(&igbvf_driver);
 
-- 
1.7.6.405.gc1be0

^ permalink raw reply related

* [PATCH net-next 5/5] igb: Convert bare printk to pr_notice
From: Joe Perches @ 2011-10-12 16:18 UTC (permalink / raw)
  To: Jeff Kirsher, linux-kernel
  Cc: netdev, Jesse Brandeburg, Bruce Allan, Carolyn Wyborny,
	Don Skidmore, Greg Rose, Peter P Waskiewicz Jr, Alex Duyck,
	John Ronciak, e1000-devel
In-Reply-To: <cover.1318436085.git.joe@perches.com>

printks should use KERN_ levels.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/ethernet/intel/igb/e1000_82575.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/e1000_82575.c b/drivers/net/ethernet/intel/igb/e1000_82575.c
index c0857bd..e0acfff 100644
--- a/drivers/net/ethernet/intel/igb/e1000_82575.c
+++ b/drivers/net/ethernet/intel/igb/e1000_82575.c
@@ -29,6 +29,8 @@
  * e1000_82576
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/types.h>
 #include <linux/if_ether.h>
 
@@ -248,8 +250,7 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
 	 * Check for invalid size
 	 */
 	if ((hw->mac.type == e1000_82576) && (size > 15)) {
-		printk("igb: The NVM size is not valid, "
-			"defaulting to 32K.\n");
+		pr_notice("The NVM size is not valid, defaulting to 32K\n");
 		size = 15;
 	}
 	nvm->word_size = 1 << size;
-- 
1.7.6.405.gc1be0

^ permalink raw reply related

* [PATCH net-next 4/5] igb: Convert printks to pr_<level>
From: Joe Perches @ 2011-10-12 16:18 UTC (permalink / raw)
  To: Jeff Kirsher, linux-kernel
  Cc: netdev, Jesse Brandeburg, Bruce Allan, Carolyn Wyborny,
	Don Skidmore, Greg Rose, Peter P Waskiewicz Jr, Alex Duyck,
	John Ronciak, e1000-devel
In-Reply-To: <cover.1318436085.git.joe@perches.com>

Use the current logging styles.

pr_<level> conversions are now prefixed with "igb: "

Correct a defect where the trailing NTU may have been printed
on a separate line because of an interleaving hex_dump.

Remove unnecessary uses of KERN_CONT and use single pr_info()s
to avoid any possible output interleaving from other modules.

Coalesce formats as appropriate.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/ethernet/intel/igb/igb_main.c |  155 +++++++++++++---------------
 1 files changed, 72 insertions(+), 83 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 10670f9..37c0000 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -25,6 +25,8 @@
 
 *******************************************************************************/
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/init.h>
@@ -65,7 +67,7 @@ char igb_driver_name[] = "igb";
 char igb_driver_version[] = DRV_VERSION;
 static const char igb_driver_string[] =
 				"Intel(R) Gigabit Ethernet Network Driver";
-static const char igb_copyright[] = "Copyright (c) 2007-2011 Intel Corporation.";
+static const char igb_copyright[] = "Copyright (c) 2007-2011 Intel Corporation";
 
 static const struct e1000_info *igb_info_tbl[] = {
 	[board_82575] = &e1000_82575_info,
@@ -318,16 +320,14 @@ static void igb_regdump(struct e1000_hw *hw, struct igb_reg_info *reginfo)
 			regs[n] = rd32(E1000_TXDCTL(n));
 		break;
 	default:
-		printk(KERN_INFO "%-15s %08x\n",
+		pr_info("%-15s %08x\n",
 			reginfo->name, rd32(reginfo->ofs));
 		return;
 	}
 
 	snprintf(rname, 16, "%s%s", reginfo->name, "[0-3]");
-	printk(KERN_INFO "%-15s ", rname);
-	for (n = 0; n < 4; n++)
-		printk(KERN_CONT "%08x ", regs[n]);
-	printk(KERN_CONT "\n");
+	pr_info("%-15s %08x %08x %08x %08x\n",
+		rname, regs[0], regs[1], regs[2], regs[3]);
 }
 
 /*
@@ -352,18 +352,17 @@ static void igb_dump(struct igb_adapter *adapter)
 	/* Print netdevice Info */
 	if (netdev) {
 		dev_info(&adapter->pdev->dev, "Net device Info\n");
-		printk(KERN_INFO "Device Name     state            "
-			"trans_start      last_rx\n");
-		printk(KERN_INFO "%-15s %016lX %016lX %016lX\n",
-		netdev->name,
-		netdev->state,
-		netdev->trans_start,
-		netdev->last_rx);
+		pr_info("Device Name     state            trans_start      last_rx\n");
+		pr_info("%-15s %016lX %016lX %016lX\n",
+			netdev->name,
+			netdev->state,
+			netdev->trans_start,
+			netdev->last_rx);
 	}
 
 	/* Print Registers */
 	dev_info(&adapter->pdev->dev, "Register Dump\n");
-	printk(KERN_INFO " Register Name   Value\n");
+	pr_info(" Register Name   Value\n");
 	for (reginfo = (struct igb_reg_info *)igb_reg_info_tbl;
 	     reginfo->name; reginfo++) {
 		igb_regdump(hw, reginfo);
@@ -374,18 +373,17 @@ static void igb_dump(struct igb_adapter *adapter)
 		goto exit;
 
 	dev_info(&adapter->pdev->dev, "TX Rings Summary\n");
-	printk(KERN_INFO "Queue [NTU] [NTC] [bi(ntc)->dma  ]"
-		" leng ntw timestamp\n");
+	pr_info("Queue [NTU] [NTC] [bi(ntc)->dma  ] leng ntw timestamp\n");
 	for (n = 0; n < adapter->num_tx_queues; n++) {
 		struct igb_tx_buffer *buffer_info;
 		tx_ring = adapter->tx_ring[n];
 		buffer_info = &tx_ring->tx_buffer_info[tx_ring->next_to_clean];
-		printk(KERN_INFO " %5d %5X %5X %016llX %04X %p %016llX\n",
-			   n, tx_ring->next_to_use, tx_ring->next_to_clean,
-			   (u64)buffer_info->dma,
-			   buffer_info->length,
-			   buffer_info->next_to_watch,
-			   (u64)buffer_info->time_stamp);
+		pr_info(" %5d %5X %5X %016llX %04X %p %016llX\n",
+			n, tx_ring->next_to_use, tx_ring->next_to_clean,
+			(u64)buffer_info->dma,
+			buffer_info->length,
+			buffer_info->next_to_watch,
+			(u64)buffer_info->time_stamp);
 	}
 
 	/* Print TX Rings */
@@ -407,36 +405,37 @@ static void igb_dump(struct igb_adapter *adapter)
 
 	for (n = 0; n < adapter->num_tx_queues; n++) {
 		tx_ring = adapter->tx_ring[n];
-		printk(KERN_INFO "------------------------------------\n");
-		printk(KERN_INFO "TX QUEUE INDEX = %d\n", tx_ring->queue_index);
-		printk(KERN_INFO "------------------------------------\n");
-		printk(KERN_INFO "T [desc]     [address 63:0  ] "
-			"[PlPOCIStDDM Ln] [bi->dma       ] "
-			"leng  ntw timestamp        bi->skb\n");
+		pr_info("------------------------------------\n");
+		pr_info("TX QUEUE INDEX = %d\n", tx_ring->queue_index);
+		pr_info("------------------------------------\n");
+		pr_info("T [desc]     [address 63:0  ] [PlPOCIStDDM Ln] [bi->dma       ] leng  ntw timestamp        bi->skb\n");
 
 		for (i = 0; tx_ring->desc && (i < tx_ring->count); i++) {
+			const char *next_desc;
 			struct igb_tx_buffer *buffer_info;
 			tx_desc = IGB_TX_DESC(tx_ring, i);
 			buffer_info = &tx_ring->tx_buffer_info[i];
 			u0 = (struct my_u0 *)tx_desc;
-			printk(KERN_INFO "T [0x%03X]    %016llX %016llX %016llX"
-				" %04X  %p %016llX %p", i,
+			if (i == tx_ring->next_to_use &&
+			    i == tx_ring->next_to_clean)
+				next_desc = " NTC/U";
+			else if (i == tx_ring->next_to_use)
+				next_desc = " NTU";
+			else if (i == tx_ring->next_to_clean)
+				next_desc = " NTC";
+			else
+				next_desc = "";
+
+			pr_info("T [0x%03X]    %016llX %016llX %016llX"
+				" %04X  %p %016llX %p%s\n",
+				i,
 				le64_to_cpu(u0->a),
 				le64_to_cpu(u0->b),
 				(u64)buffer_info->dma,
 				buffer_info->length,
 				buffer_info->next_to_watch,
 				(u64)buffer_info->time_stamp,
-				buffer_info->skb);
-			if (i == tx_ring->next_to_use &&
-				i == tx_ring->next_to_clean)
-				printk(KERN_CONT " NTC/U\n");
-			else if (i == tx_ring->next_to_use)
-				printk(KERN_CONT " NTU\n");
-			else if (i == tx_ring->next_to_clean)
-				printk(KERN_CONT " NTC\n");
-			else
-				printk(KERN_CONT "\n");
+				buffer_info->skb, next_desc);
 
 			if (netif_msg_pktdata(adapter) && buffer_info->dma != 0)
 				print_hex_dump(KERN_INFO, "",
@@ -449,11 +448,11 @@ static void igb_dump(struct igb_adapter *adapter)
 	/* Print RX Rings Summary */
 rx_ring_summary:
 	dev_info(&adapter->pdev->dev, "RX Rings Summary\n");
-	printk(KERN_INFO "Queue [NTU] [NTC]\n");
+	pr_info("Queue [NTU] [NTC]\n");
 	for (n = 0; n < adapter->num_rx_queues; n++) {
 		rx_ring = adapter->rx_ring[n];
-		printk(KERN_INFO " %5d %5X %5X\n", n,
-			   rx_ring->next_to_use, rx_ring->next_to_clean);
+		pr_info(" %5d %5X %5X\n",
+			n, rx_ring->next_to_use, rx_ring->next_to_clean);
 	}
 
 	/* Print RX Rings */
@@ -485,36 +484,41 @@ rx_ring_summary:
 
 	for (n = 0; n < adapter->num_rx_queues; n++) {
 		rx_ring = adapter->rx_ring[n];
-		printk(KERN_INFO "------------------------------------\n");
-		printk(KERN_INFO "RX QUEUE INDEX = %d\n", rx_ring->queue_index);
-		printk(KERN_INFO "------------------------------------\n");
-		printk(KERN_INFO "R  [desc]      [ PktBuf     A0] "
-			"[  HeadBuf   DD] [bi->dma       ] [bi->skb] "
-			"<-- Adv Rx Read format\n");
-		printk(KERN_INFO "RWB[desc]      [PcsmIpSHl PtRs] "
-			"[vl er S cks ln] ---------------- [bi->skb] "
-			"<-- Adv Rx Write-Back format\n");
+		pr_info("------------------------------------\n");
+		pr_info("RX QUEUE INDEX = %d\n", rx_ring->queue_index);
+		pr_info("------------------------------------\n");
+		pr_info("R  [desc]      [ PktBuf     A0] [  HeadBuf   DD] [bi->dma       ] [bi->skb] <-- Adv Rx Read format\n");
+		pr_info("RWB[desc]      [PcsmIpSHl PtRs] [vl er S cks ln] ---------------- [bi->skb] <-- Adv Rx Write-Back format\n");
 
 		for (i = 0; i < rx_ring->count; i++) {
+			const char *next_desc;
 			struct igb_rx_buffer *buffer_info;
 			buffer_info = &rx_ring->rx_buffer_info[i];
 			rx_desc = IGB_RX_DESC(rx_ring, i);
 			u0 = (struct my_u0 *)rx_desc;
 			staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
+
+			if (i == rx_ring->next_to_use)
+				next_desc = " NTU";
+			else if (i == rx_ring->next_to_clean)
+				next_desc = " NTC";
+			else
+				next_desc = "";
+
 			if (staterr & E1000_RXD_STAT_DD) {
 				/* Descriptor Done */
-				printk(KERN_INFO "RWB[0x%03X]     %016llX "
-					"%016llX ---------------- %p", i,
+				pr_info("%s[0x%03X]     %016llX %016llX ---------------- %p%s\n",
+					"RWB", i,
 					le64_to_cpu(u0->a),
 					le64_to_cpu(u0->b),
-					buffer_info->skb);
+					buffer_info->skb, next_desc);
 			} else {
-				printk(KERN_INFO "R  [0x%03X]     %016llX "
-					"%016llX %016llX %p", i,
+				pr_info("%s[0x%03X]     %016llX %016llX %016llX %p%s\n",
+					"R  ", i,
 					le64_to_cpu(u0->a),
 					le64_to_cpu(u0->b),
 					(u64)buffer_info->dma,
-					buffer_info->skb);
+					buffer_info->skb, next_desc);
 
 				if (netif_msg_pktdata(adapter)) {
 					print_hex_dump(KERN_INFO, "",
@@ -531,14 +535,6 @@ rx_ring_summary:
 					  PAGE_SIZE/2, true);
 				}
 			}
-
-			if (i == rx_ring->next_to_use)
-				printk(KERN_CONT " NTU\n");
-			else if (i == rx_ring->next_to_clean)
-				printk(KERN_CONT " NTC\n");
-			else
-				printk(KERN_CONT "\n");
-
 		}
 	}
 
@@ -592,10 +588,10 @@ struct net_device *igb_get_hw_dev(struct e1000_hw *hw)
 static int __init igb_init_module(void)
 {
 	int ret;
-	printk(KERN_INFO "%s - version %s\n",
+	pr_info("%s - version %s\n",
 	       igb_driver_string, igb_driver_version);
 
-	printk(KERN_INFO "%s\n", igb_copyright);
+	pr_info("%s\n", igb_copyright);
 
 #ifdef CONFIG_IGB_DCA
 	dca_register_notify(&dca_notifier);
@@ -3676,23 +3672,19 @@ static void igb_watchdog_task(struct work_struct *work)
 
 			ctrl = rd32(E1000_CTRL);
 			/* Links status message must follow this format */
-			printk(KERN_INFO "igb: %s NIC Link is Up %d Mbps %s, "
-				 "Flow Control: %s\n",
+			printk(KERN_INFO "igb: %s NIC Link is Up %d Mbps %s Duplex, Flow Control: %s\n",
 			       netdev->name,
 			       adapter->link_speed,
 			       adapter->link_duplex == FULL_DUPLEX ?
-				 "Full Duplex" : "Half Duplex",
-			       ((ctrl & E1000_CTRL_TFCE) &&
-			        (ctrl & E1000_CTRL_RFCE)) ? "RX/TX" :
-			       ((ctrl & E1000_CTRL_RFCE) ?  "RX" :
-			       ((ctrl & E1000_CTRL_TFCE) ?  "TX" : "None")));
+			       "Full" : "Half",
+			       (ctrl & E1000_CTRL_TFCE) &&
+			       (ctrl & E1000_CTRL_RFCE) ? "RX/TX" :
+			       (ctrl & E1000_CTRL_RFCE) ?  "RX" :
+			       (ctrl & E1000_CTRL_TFCE) ?  "TX" : "None");
 
 			/* check for thermal sensor event */
 			if (igb_thermal_sensor_event(hw, E1000_THSTAT_LINK_THROTTLE)) {
-				printk(KERN_INFO "igb: %s The network adapter "
-						 "link speed was downshifted "
-						 "because it overheated.\n",
-						 netdev->name);
+				netdev_info(netdev, "The network adapter link speed was downshifted because it overheated\n");
 			}
 
 			/* adjust timeout factor according to speed/duplex */
@@ -3723,10 +3715,7 @@ static void igb_watchdog_task(struct work_struct *work)
 
 			/* check for thermal sensor event */
 			if (igb_thermal_sensor_event(hw, E1000_THSTAT_PWR_DOWN)) {
-				printk(KERN_ERR "igb: %s The network adapter "
-						"was stopped because it "
-						"overheated.\n",
-						netdev->name);
+				netdev_err(netdev, "The network adapter was stopped because it overheated\n");
 			}
 
 			/* Links status message must follow this format */
-- 
1.7.6.405.gc1be0

^ permalink raw reply related

* [PATCH net-next 2/5] ixgbevf: Convert printks to pr_<level>
From: Joe Perches @ 2011-10-12 16:18 UTC (permalink / raw)
  To: Jeff Kirsher, linux-kernel
  Cc: netdev, Jesse Brandeburg, Bruce Allan, Carolyn Wyborny,
	Don Skidmore, Greg Rose, Peter P Waskiewicz Jr, Alex Duyck,
	John Ronciak, e1000-devel
In-Reply-To: <cover.1318436085.git.joe@perches.com>

Use the current logging styles, prefix output with "ixgbevf: "

Add #define pr_fmt
Coalesce formats.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/ethernet/intel/ixgbevf/ethtool.c      |    6 +++-
 drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c |   26 ++++++++++----------
 2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbevf/ethtool.c b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
index e29ba45..c9c084b 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
@@ -27,6 +27,8 @@
 
 /* ethtool support for ixgbevf */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/types.h>
 #include <linux/module.h>
 #include <linux/slab.h>
@@ -549,8 +551,8 @@ static const u32 register_test_patterns[] = {
 	writel((W & M), (adapter->hw.hw_addr + R));                           \
 	val = readl(adapter->hw.hw_addr + R);                                 \
 	if ((W & M) != (val & M)) {                                           \
-		printk(KERN_ERR "set/check reg %04X test failed: got 0x%08X " \
-				 "expected 0x%08X\n", R, (val & M), (W & M)); \
+		pr_err("set/check reg %04X test failed: got 0x%08X expected 0x%08X\n", \
+		       R, (val & M), (W & M));                                \
 		*data = R;                                                    \
 		writel(before, (adapter->hw.hw_addr + R));                    \
 		return 1;                                                     \
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index 4930c46..51e944d 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -29,6 +29,9 @@
 /******************************************************************************
  Copyright (c)2006 - 2007 Myricom, Inc. for some LRO specific code
 ******************************************************************************/
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/types.h>
 #include <linux/bitops.h>
 #include <linux/module.h>
@@ -1437,7 +1440,7 @@ static int ixgbevf_write_uc_addr_list(struct net_device *netdev)
 	int count = 0;
 
 	if ((netdev_uc_count(netdev)) > 10) {
-		printk(KERN_ERR "Too many unicast filters - No Space\n");
+		pr_err("Too many unicast filters - No Space\n");
 		return -ENOSPC;
 	}
 
@@ -2135,7 +2138,7 @@ static int ixgbevf_init_interrupt_scheme(struct ixgbevf_adapter *adapter)
 
 	err = ixgbevf_alloc_queues(adapter);
 	if (err) {
-		printk(KERN_ERR "Unable to allocate memory for queues\n");
+		pr_err("Unable to allocate memory for queues\n");
 		goto err_alloc_queues;
 	}
 
@@ -2189,7 +2192,7 @@ static int __devinit ixgbevf_sw_init(struct ixgbevf_adapter *adapter)
 	} else {
 		err = hw->mac.ops.init_hw(hw);
 		if (err) {
-			printk(KERN_ERR "init_shared_code failed: %d\n", err);
+			pr_err("init_shared_code failed: %d\n", err);
 			goto out;
 		}
 	}
@@ -2630,8 +2633,7 @@ static int ixgbevf_open(struct net_device *netdev)
 		 * the vf can't start. */
 		if (hw->adapter_stopped) {
 			err = IXGBE_ERR_MBX;
-			printk(KERN_ERR "Unable to start - perhaps the PF"
-			       " Driver isn't up yet\n");
+			pr_err("Unable to start - perhaps the PF Driver isn't up yet\n");
 			goto err_setup_reset;
 		}
 	}
@@ -2842,10 +2844,8 @@ static bool ixgbevf_tx_csum(struct ixgbevf_adapter *adapter,
 				break;
 			default:
 				if (unlikely(net_ratelimit())) {
-					printk(KERN_WARNING
-					       "partial checksum but "
-					       "proto=%x!\n",
-					       skb->protocol);
+					pr_warn("partial checksum but proto=%x!\n",
+						skb->protocol);
 				}
 				break;
 			}
@@ -3414,7 +3414,7 @@ static int __devinit ixgbevf_probe(struct pci_dev *pdev,
 	memcpy(netdev->perm_addr, adapter->hw.mac.addr, netdev->addr_len);
 
 	if (!is_valid_ether_addr(netdev->dev_addr)) {
-		printk(KERN_ERR "invalid MAC address\n");
+		pr_err("invalid MAC address\n");
 		err = -EIO;
 		goto err_sw_init;
 	}
@@ -3535,10 +3535,10 @@ static struct pci_driver ixgbevf_driver = {
 static int __init ixgbevf_init_module(void)
 {
 	int ret;
-	printk(KERN_INFO "ixgbevf: %s - version %s\n", ixgbevf_driver_string,
-	       ixgbevf_driver_version);
+	pr_info("%s - version %s\n",
+		ixgbevf_driver_string, ixgbevf_driver_version);
 
-	printk(KERN_INFO "%s\n", ixgbevf_copyright);
+	pr_info("%s\n", ixgbevf_copyright);
 
 	ret = pci_register_driver(&ixgbevf_driver);
 	return ret;
-- 
1.7.6.405.gc1be0

^ permalink raw reply related

* [PATCH net-next 1/5] e1000e: Convert printks to pr_<level>
From: Joe Perches @ 2011-10-12 16:18 UTC (permalink / raw)
  To: Jeff Kirsher, linux-kernel
  Cc: netdev, Jesse Brandeburg, Bruce Allan, Carolyn Wyborny,
	Don Skidmore, Greg Rose, Peter P Waskiewicz Jr, Alex Duyck,
	John Ronciak, e1000-devel
In-Reply-To: <cover.1318436085.git.joe@perches.com>

Use the current logging styles.

pr_<level> conversions are now prefixed with "e1000e:"

Correct a couple of defects where the trailing NTU may have
been printed on a separate line because of an interleaving
hex_dump.

Remove unnecessary uses of KERN_CONT and use single pr_info()s
to avoid any possible output interleaving from other modules.

Coalesce formats as appropriate.

Remove an extra space from a broken across lines
coalescing of "Link Status " and " Change".

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/ethernet/intel/e1000e/netdev.c |  232 ++++++++++++----------------
 1 files changed, 102 insertions(+), 130 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index 78c5d21..40fcbee 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -163,16 +163,13 @@ static void e1000_regdump(struct e1000_hw *hw, struct e1000_reg_info *reginfo)
 			regs[n] = __er32(hw, E1000_TARC(n));
 		break;
 	default:
-		printk(KERN_INFO "%-15s %08x\n",
-		       reginfo->name, __er32(hw, reginfo->ofs));
+		pr_info("%-15s %08x\n",
+			reginfo->name, __er32(hw, reginfo->ofs));
 		return;
 	}
 
 	snprintf(rname, 16, "%s%s", reginfo->name, "[0-1]");
-	printk(KERN_INFO "%-15s ", rname);
-	for (n = 0; n < 2; n++)
-		printk(KERN_CONT "%08x ", regs[n]);
-	printk(KERN_CONT "\n");
+	pr_info("%-15s %08x %08x\n", rname, regs[0], regs[1]);
 }
 
 /*
@@ -208,16 +205,15 @@ static void e1000e_dump(struct e1000_adapter *adapter)
 	/* Print netdevice Info */
 	if (netdev) {
 		dev_info(&adapter->pdev->dev, "Net device Info\n");
-		printk(KERN_INFO "Device Name     state            "
-		       "trans_start      last_rx\n");
-		printk(KERN_INFO "%-15s %016lX %016lX %016lX\n",
-		       netdev->name, netdev->state, netdev->trans_start,
-		       netdev->last_rx);
+		pr_info("Device Name     state            trans_start      last_rx\n");
+		pr_info("%-15s %016lX %016lX %016lX\n",
+			netdev->name, netdev->state, netdev->trans_start,
+			netdev->last_rx);
 	}
 
 	/* Print Registers */
 	dev_info(&adapter->pdev->dev, "Register Dump\n");
-	printk(KERN_INFO " Register Name   Value\n");
+	pr_info(" Register Name   Value\n");
 	for (reginfo = (struct e1000_reg_info *)e1000_reg_info_tbl;
 	     reginfo->name; reginfo++) {
 		e1000_regdump(hw, reginfo);
@@ -228,15 +224,14 @@ static void e1000e_dump(struct e1000_adapter *adapter)
 		goto exit;
 
 	dev_info(&adapter->pdev->dev, "Tx Ring Summary\n");
-	printk(KERN_INFO "Queue [NTU] [NTC] [bi(ntc)->dma  ]"
-	       " leng ntw timestamp\n");
+	pr_info("Queue [NTU] [NTC] [bi(ntc)->dma  ] leng ntw timestamp\n");
 	buffer_info = &tx_ring->buffer_info[tx_ring->next_to_clean];
-	printk(KERN_INFO " %5d %5X %5X %016llX %04X %3X %016llX\n",
-	       0, tx_ring->next_to_use, tx_ring->next_to_clean,
-	       (unsigned long long)buffer_info->dma,
-	       buffer_info->length,
-	       buffer_info->next_to_watch,
-	       (unsigned long long)buffer_info->time_stamp);
+	pr_info(" %5d %5X %5X %016llX %04X %3X %016llX\n",
+		0, tx_ring->next_to_use, tx_ring->next_to_clean,
+		(unsigned long long)buffer_info->dma,
+		buffer_info->length,
+		buffer_info->next_to_watch,
+		(unsigned long long)buffer_info->time_stamp);
 
 	/* Print Tx Ring */
 	if (!netif_msg_tx_done(adapter))
@@ -271,37 +266,32 @@ static void e1000e_dump(struct e1000_adapter *adapter)
 	 *   +----------------------------------------------------------------+
 	 *   63       48 47     40 39  36 35    32 31     24 23  20 19        0
 	 */
-	printk(KERN_INFO "Tl[desc]     [address 63:0  ] [SpeCssSCmCsLen]"
-	       " [bi->dma       ] leng  ntw timestamp        bi->skb "
-	       "<-- Legacy format\n");
-	printk(KERN_INFO "Tc[desc]     [Ce CoCsIpceCoS] [MssHlRSCm0Plen]"
-	       " [bi->dma       ] leng  ntw timestamp        bi->skb "
-	       "<-- Ext Context format\n");
-	printk(KERN_INFO "Td[desc]     [address 63:0  ] [VlaPoRSCm1Dlen]"
-	       " [bi->dma       ] leng  ntw timestamp        bi->skb "
-	       "<-- Ext Data format\n");
+	pr_info("Tl[desc]     [address 63:0  ] [SpeCssSCmCsLen] [bi->dma       ] leng  ntw timestamp        bi->skb <-- Legacy format\n");
+	pr_info("Tc[desc]     [Ce CoCsIpceCoS] [MssHlRSCm0Plen] [bi->dma       ] leng  ntw timestamp        bi->skb <-- Ext Context format\n");
+	pr_info("Td[desc]     [address 63:0  ] [VlaPoRSCm1Dlen] [bi->dma       ] leng  ntw timestamp        bi->skb <-- Ext Data format\n");
 	for (i = 0; tx_ring->desc && (i < tx_ring->count); i++) {
+		const char *next_desc;
 		tx_desc = E1000_TX_DESC(*tx_ring, i);
 		buffer_info = &tx_ring->buffer_info[i];
 		u0 = (struct my_u0 *)tx_desc;
-		printk(KERN_INFO "T%c[0x%03X]    %016llX %016llX %016llX "
-		       "%04X  %3X %016llX %p",
-		       (!(le64_to_cpu(u0->b) & (1 << 29)) ? 'l' :
-			((le64_to_cpu(u0->b) & (1 << 20)) ? 'd' : 'c')), i,
-		       (unsigned long long)le64_to_cpu(u0->a),
-		       (unsigned long long)le64_to_cpu(u0->b),
-		       (unsigned long long)buffer_info->dma,
-		       buffer_info->length, buffer_info->next_to_watch,
-		       (unsigned long long)buffer_info->time_stamp,
-		       buffer_info->skb);
 		if (i == tx_ring->next_to_use && i == tx_ring->next_to_clean)
-			printk(KERN_CONT " NTC/U\n");
+			next_desc = " NTC/U";
 		else if (i == tx_ring->next_to_use)
-			printk(KERN_CONT " NTU\n");
+			next_desc = " NTU";
 		else if (i == tx_ring->next_to_clean)
-			printk(KERN_CONT " NTC\n");
+			next_desc = " NTC";
 		else
-			printk(KERN_CONT "\n");
+			next_desc = "";
+		pr_info("T%c[0x%03X]    %016llX %016llX %016llX %04X  %3X %016llX %p%s\n",
+			(!(le64_to_cpu(u0->b) & (1 << 29)) ? 'l' :
+			 ((le64_to_cpu(u0->b) & (1 << 20)) ? 'd' : 'c')),
+			i,
+			(unsigned long long)le64_to_cpu(u0->a),
+			(unsigned long long)le64_to_cpu(u0->b),
+			(unsigned long long)buffer_info->dma,
+			buffer_info->length, buffer_info->next_to_watch,
+			(unsigned long long)buffer_info->time_stamp,
+			buffer_info->skb, next_desc);
 
 		if (netif_msg_pktdata(adapter) && buffer_info->dma != 0)
 			print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS,
@@ -312,9 +302,9 @@ static void e1000e_dump(struct e1000_adapter *adapter)
 	/* Print Rx Ring Summary */
 rx_ring_summary:
 	dev_info(&adapter->pdev->dev, "Rx Ring Summary\n");
-	printk(KERN_INFO "Queue [NTU] [NTC]\n");
-	printk(KERN_INFO " %5d %5X %5X\n", 0,
-	       rx_ring->next_to_use, rx_ring->next_to_clean);
+	pr_info("Queue [NTU] [NTC]\n");
+	pr_info(" %5d %5X %5X\n",
+		0, rx_ring->next_to_use, rx_ring->next_to_clean);
 
 	/* Print Rx Ring */
 	if (!netif_msg_rx_status(adapter))
@@ -337,10 +327,7 @@ rx_ring_summary:
 		 * 24 |                Buffer Address 3 [63:0]              |
 		 *    +-----------------------------------------------------+
 		 */
-		printk(KERN_INFO "R  [desc]      [buffer 0 63:0 ] "
-		       "[buffer 1 63:0 ] "
-		       "[buffer 2 63:0 ] [buffer 3 63:0 ] [bi->dma       ] "
-		       "[bi->skb] <-- Ext Pkt Split format\n");
+		pr_info("R  [desc]      [buffer 0 63:0 ] [buffer 1 63:0 ] [buffer 2 63:0 ] [buffer 3 63:0 ] [bi->dma       ] [bi->skb] <-- Ext Pkt Split format\n");
 		/* [Extended] Receive Descriptor (Write-Back) Format
 		 *
 		 *   63       48 47    32 31     13 12    8 7    4 3        0
@@ -352,35 +339,40 @@ rx_ring_summary:
 		 *   +------------------------------------------------------+
 		 *   63       48 47    32 31            20 19               0
 		 */
-		printk(KERN_INFO "RWB[desc]      [ck ipid mrqhsh] "
-		       "[vl   l0 ee  es] "
-		       "[ l3  l2  l1 hs] [reserved      ] ---------------- "
-		       "[bi->skb] <-- Ext Rx Write-Back format\n");
+		pr_info("RWB[desc]      [ck ipid mrqhsh] [vl   l0 ee  es] [ l3  l2  l1 hs] [reserved      ] ---------------- [bi->skb] <-- Ext Rx Write-Back format\n");
 		for (i = 0; i < rx_ring->count; i++) {
+			const char *next_desc;
 			buffer_info = &rx_ring->buffer_info[i];
 			rx_desc_ps = E1000_RX_DESC_PS(*rx_ring, i);
 			u1 = (struct my_u1 *)rx_desc_ps;
 			staterr =
 			    le32_to_cpu(rx_desc_ps->wb.middle.status_error);
+
+			if (i == rx_ring->next_to_use)
+				next_desc = " NTU";
+			else if (i == rx_ring->next_to_clean)
+				next_desc = " NTC";
+			else
+				next_desc = "";
+
 			if (staterr & E1000_RXD_STAT_DD) {
 				/* Descriptor Done */
-				printk(KERN_INFO "RWB[0x%03X]     %016llX "
-				       "%016llX %016llX %016llX "
-				       "---------------- %p", i,
-				       (unsigned long long)le64_to_cpu(u1->a),
-				       (unsigned long long)le64_to_cpu(u1->b),
-				       (unsigned long long)le64_to_cpu(u1->c),
-				       (unsigned long long)le64_to_cpu(u1->d),
-				       buffer_info->skb);
+				pr_info("%s[0x%03X]     %016llX %016llX %016llX %016llX ---------------- %p%s\n",
+					"RWB", i,
+					(unsigned long long)le64_to_cpu(u1->a),
+					(unsigned long long)le64_to_cpu(u1->b),
+					(unsigned long long)le64_to_cpu(u1->c),
+					(unsigned long long)le64_to_cpu(u1->d),
+					buffer_info->skb, next_desc);
 			} else {
-				printk(KERN_INFO "R  [0x%03X]     %016llX "
-				       "%016llX %016llX %016llX %016llX %p", i,
-				       (unsigned long long)le64_to_cpu(u1->a),
-				       (unsigned long long)le64_to_cpu(u1->b),
-				       (unsigned long long)le64_to_cpu(u1->c),
-				       (unsigned long long)le64_to_cpu(u1->d),
-				       (unsigned long long)buffer_info->dma,
-				       buffer_info->skb);
+				pr_info("%s[0x%03X]     %016llX %016llX %016llX %016llX %016llX %p%s\n",
+					"R  ", i,
+					(unsigned long long)le64_to_cpu(u1->a),
+					(unsigned long long)le64_to_cpu(u1->b),
+					(unsigned long long)le64_to_cpu(u1->c),
+					(unsigned long long)le64_to_cpu(u1->d),
+					(unsigned long long)buffer_info->dma,
+					buffer_info->skb, next_desc);
 
 				if (netif_msg_pktdata(adapter))
 					print_hex_dump(KERN_INFO, "",
@@ -388,13 +380,6 @@ rx_ring_summary:
 						phys_to_virt(buffer_info->dma),
 						adapter->rx_ps_bsize0, true);
 			}
-
-			if (i == rx_ring->next_to_use)
-				printk(KERN_CONT " NTU\n");
-			else if (i == rx_ring->next_to_clean)
-				printk(KERN_CONT " NTC\n");
-			else
-				printk(KERN_CONT "\n");
 		}
 		break;
 	default:
@@ -407,9 +392,7 @@ rx_ring_summary:
 		 * 8 |                      Reserved                       |
 		 *   +-----------------------------------------------------+
 		 */
-		printk(KERN_INFO "R  [desc]      [buf addr 63:0 ] "
-		       "[reserved 63:0 ] [bi->dma       ] "
-		       "[bi->skb] <-- Ext (Read) format\n");
+		pr_info("R  [desc]      [buf addr 63:0 ] [reserved 63:0 ] [bi->dma       ] [bi->skb] <-- Ext (Read) format\n");
 		/* Extended Receive Descriptor (Write-Back) Format
 		 *
 		 *   63       48 47    32 31    24 23            4 3        0
@@ -423,29 +406,37 @@ rx_ring_summary:
 		 *   +------------------------------------------------------+
 		 *   63       48 47    32 31            20 19               0
 		 */
-		printk(KERN_INFO "RWB[desc]      [cs ipid    mrq] "
-		       "[vt   ln xe  xs] "
-		       "[bi->skb] <-- Ext (Write-Back) format\n");
+		pr_info("RWB[desc]      [cs ipid    mrq] [vt   ln xe  xs] [bi->skb] <-- Ext (Write-Back) format\n");
 
 		for (i = 0; i < rx_ring->count; i++) {
+			const char *next_desc;
+
 			buffer_info = &rx_ring->buffer_info[i];
 			rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
 			u1 = (struct my_u1 *)rx_desc;
 			staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
+
+			if (i == rx_ring->next_to_use)
+				next_desc = " NTU";
+			else if (i == rx_ring->next_to_clean)
+				next_desc = " NTC";
+			else
+				next_desc = "";
+
 			if (staterr & E1000_RXD_STAT_DD) {
 				/* Descriptor Done */
-				printk(KERN_INFO "RWB[0x%03X]     %016llX "
-				       "%016llX ---------------- %p", i,
-				       (unsigned long long)le64_to_cpu(u1->a),
-				       (unsigned long long)le64_to_cpu(u1->b),
-				       buffer_info->skb);
+				pr_info("%s[0x%03X]     %016llX %016llX ---------------- %p%s\n",
+					"RWB", i,
+					(unsigned long long)le64_to_cpu(u1->a),
+					(unsigned long long)le64_to_cpu(u1->b),
+					buffer_info->skb, next_desc);
 			} else {
-				printk(KERN_INFO "R  [0x%03X]     %016llX "
-				       "%016llX %016llX %p", i,
-				       (unsigned long long)le64_to_cpu(u1->a),
-				       (unsigned long long)le64_to_cpu(u1->b),
-				       (unsigned long long)buffer_info->dma,
-				       buffer_info->skb);
+				pr_info("%s[0x%03X]     %016llX %016llX %016llX %p%s\n",
+					"R  ", i,
+					(unsigned long long)le64_to_cpu(u1->a),
+					(unsigned long long)le64_to_cpu(u1->b),
+					(unsigned long long)buffer_info->dma,
+					buffer_info->skb, next_desc);
 
 				if (netif_msg_pktdata(adapter))
 					print_hex_dump(KERN_INFO, "",
@@ -456,13 +447,6 @@ rx_ring_summary:
 						       adapter->rx_buffer_len,
 						       true);
 			}
-
-			if (i == rx_ring->next_to_use)
-				printk(KERN_CONT " NTU\n");
-			else if (i == rx_ring->next_to_clean)
-				printk(KERN_CONT " NTC\n");
-			else
-				printk(KERN_CONT "\n");
 		}
 	}
 
@@ -1222,8 +1206,7 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
 			adapter->flags2 |= FLAG2_IS_DISCARDING;
 
 		if (adapter->flags2 & FLAG2_IS_DISCARDING) {
-			e_dbg("Packet Split buffers didn't pick up the full "
-			      "packet\n");
+			e_dbg("Packet Split buffers didn't pick up the full packet\n");
 			dev_kfree_skb_irq(skb);
 			if (staterr & E1000_RXD_STAT_EOP)
 				adapter->flags2 &= ~FLAG2_IS_DISCARDING;
@@ -1238,8 +1221,7 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
 		length = le16_to_cpu(rx_desc->wb.middle.length0);
 
 		if (!length) {
-			e_dbg("Last part of the packet spanning multiple "
-			      "descriptors\n");
+			e_dbg("Last part of the packet spanning multiple descriptors\n");
 			dev_kfree_skb_irq(skb);
 			goto next_desc;
 		}
@@ -1917,8 +1899,7 @@ void e1000e_set_interrupt_capability(struct e1000_adapter *adapter)
 					return;
 			}
 			/* MSI-X failed, so fall through and try MSI */
-			e_err("Failed to initialize MSI-X interrupts.  "
-			      "Falling back to MSI interrupts.\n");
+			e_err("Failed to initialize MSI-X interrupts.  Falling back to MSI interrupts.\n");
 			e1000e_reset_interrupt_capability(adapter);
 		}
 		adapter->int_mode = E1000E_INT_MODE_MSI;
@@ -1928,8 +1909,7 @@ void e1000e_set_interrupt_capability(struct e1000_adapter *adapter)
 			adapter->flags |= FLAG_MSI_ENABLED;
 		} else {
 			adapter->int_mode = E1000E_INT_MODE_LEGACY;
-			e_err("Failed to initialize MSI interrupts.  Falling "
-			      "back to legacy interrupts.\n");
+			e_err("Failed to initialize MSI interrupts.  Falling back to legacy interrupts.\n");
 		}
 		/* Fall through */
 	case E1000E_INT_MODE_LEGACY:
@@ -4168,16 +4148,13 @@ static void e1000_print_link_info(struct e1000_adapter *adapter)
 	u32 ctrl = er32(CTRL);
 
 	/* Link status message must follow this format for user tools */
-	printk(KERN_INFO "e1000e: %s NIC Link is Up %d Mbps %s, "
-	       "Flow Control: %s\n",
-	       adapter->netdev->name,
-	       adapter->link_speed,
-	       (adapter->link_duplex == FULL_DUPLEX) ?
-	       "Full Duplex" : "Half Duplex",
-	       ((ctrl & E1000_CTRL_TFCE) && (ctrl & E1000_CTRL_RFCE)) ?
-	       "Rx/Tx" :
-	       ((ctrl & E1000_CTRL_RFCE) ? "Rx" :
-		((ctrl & E1000_CTRL_TFCE) ? "Tx" : "None")));
+	printk(KERN_INFO "e1000e: %s NIC Link is Up %d Mbps %s Duplex, Flow Control: %s\n",
+		adapter->netdev->name,
+		adapter->link_speed,
+		adapter->link_duplex == FULL_DUPLEX ? "Full" : "Half",
+		(ctrl & E1000_CTRL_TFCE) && (ctrl & E1000_CTRL_RFCE) ? "Rx/Tx" :
+		(ctrl & E1000_CTRL_RFCE) ? "Rx" :
+		(ctrl & E1000_CTRL_TFCE) ? "Tx" : "None");
 }
 
 static bool e1000e_has_link(struct e1000_adapter *adapter)
@@ -4323,10 +4300,7 @@ static void e1000_watchdog_task(struct work_struct *work)
 				e1e_rphy(hw, PHY_AUTONEG_EXP, &autoneg_exp);
 
 				if (!(autoneg_exp & NWAY_ER_LP_NWAY_CAPS))
-					e_info("Autonegotiated half duplex but"
-					       " link partner cannot autoneg. "
-					       " Try forcing full duplex if "
-					       "link gets many collisions.\n");
+					e_info("Autonegotiated half duplex but link partner cannot autoneg.  Try forcing full duplex if link gets many collisions.\n");
 			}
 
 			/* adjust timeout factor according to speed/duplex */
@@ -5110,8 +5084,7 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
 	if ((adapter->hw.mac.type == e1000_pch2lan) &&
 	    !(adapter->flags2 & FLAG2_CRC_STRIPPING) &&
 	    (new_mtu > ETH_DATA_LEN)) {
-		e_err("Jumbo Frames not supported on 82579 when CRC "
-		      "stripping is disabled.\n");
+		e_err("Jumbo Frames not supported on 82579 when CRC stripping is disabled.\n");
 		return -EINVAL;
 	}
 
@@ -5527,8 +5500,8 @@ static int __e1000_resume(struct pci_dev *pdev)
 				phy_data & E1000_WUS_MC ? "Multicast Packet" :
 				phy_data & E1000_WUS_BC ? "Broadcast Packet" :
 				phy_data & E1000_WUS_MAG ? "Magic Packet" :
-				phy_data & E1000_WUS_LNKC ? "Link Status "
-				" Change" : "other");
+				phy_data & E1000_WUS_LNKC ? "Link Status Change" :
+			       "other");
 		}
 		e1e_wphy(&adapter->hw, BM_WUS, ~0);
 	} else {
@@ -5949,8 +5922,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
 			err = dma_set_coherent_mask(&pdev->dev,
 						    DMA_BIT_MASK(32));
 			if (err) {
-				dev_err(&pdev->dev, "No usable DMA "
-					"configuration, aborting\n");
+				dev_err(&pdev->dev, "No usable DMA configuration, aborting\n");
 				goto err_dma;
 			}
 		}
@@ -6412,7 +6384,7 @@ static int __init e1000_init_module(void)
 	int ret;
 	pr_info("Intel(R) PRO/1000 Network Driver - %s\n",
 		e1000e_driver_version);
-	pr_info("Copyright(c) 1999 - 2011 Intel Corporation.\n");
+	pr_info("Copyright(c) 1999 - 2011 Intel Corporation\n");
 	ret = pci_register_driver(&e1000_driver);
 
 	return ret;
-- 
1.7.6.405.gc1be0

^ permalink raw reply related

* [PATCH net-next 0/5] intel: Logging cleanups
From: Joe Perches @ 2011-10-12 16:18 UTC (permalink / raw)
  To: Jeff Kirsher; +Cc: netdev, e1000-devel, linux-kernel

Just some conversions of printks to pr_<level>
and some trivial defect corrections.

Joe Perches (5):
  e1000e: Convert printks to pr_<level>
  ixgbevf: Convert printks to pr_<level>
  igbvf: Convert printks to pr_<level>
  igb: Convert printks to pr_<level>
  igb: Convert bare printk to pr_notice

 drivers/net/ethernet/intel/e1000e/netdev.c        |  232 +++++++++------------
 drivers/net/ethernet/intel/igb/e1000_82575.c      |    5 +-
 drivers/net/ethernet/intel/igb/igb_main.c         |  155 +++++++--------
 drivers/net/ethernet/intel/igbvf/netdev.c         |   14 +-
 drivers/net/ethernet/intel/ixgbevf/ethtool.c      |    6 +-
 drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c |   26 ++--
 6 files changed, 201 insertions(+), 237 deletions(-)

-- 
1.7.6.405.gc1be0

^ permalink raw reply

* Re: [PATCH v3] net-netlink: Add a new attribute to expose TOS values via netlink
From: Stephen Hemminger @ 2011-10-12 15:52 UTC (permalink / raw)
  To: Muraliraja Muniraju
  Cc: David S. Miller, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy, linux-kernel, netdev
In-Reply-To: <1318382887-31824-1-git-send-email-muralira@google.com>

On Tue, 11 Oct 2011 18:28:07 -0700
Muraliraja Muniraju <muralira@google.com> wrote:

> +/* INET_DIAG_TOS */
> +
> +struct inet_diag_tos {
> +	__u8	idiag_tos;
> +};
> +

This structure is not used.

^ permalink raw reply

* Re: [PATCH] dev: use ifindex hash for dev_seq_ops
From: Stephen Hemminger @ 2011-10-12 15:50 UTC (permalink / raw)
  To: Mihai Maruseac
  Cc: davem, eric.dumazet, mirq-linux, therbert, jpirko, netdev,
	linux-kernel, dbaluta, Mihai Maruseac
In-Reply-To: <1318413446-22258-1-git-send-email-mmaruseac@ixiacom.com>

On Wed, 12 Oct 2011 12:57:26 +0300
Mihai Maruseac <mihai.maruseac@gmail.com> wrote:

It looks like you lost the ability to seek back and read the header
(start token).  How is the header handled, is possible to rewind
the file and read it over again?


> +static inline struct net_device *next_dev(struct seq_file *seq, loff_t *pos)
> +{
> +	struct dev_iter_state *state = seq->private;
> +	struct net *net = seq_file_net(seq);
> +	struct net_device *dev = NULL;
> +	loff_t off;
> +
> +	++*pos;
> +	dev = dev_get_by_index_rcu(net, state->ifindex);

Looks good a couple of minor nits.

1. The function should not be inline, since it is in no way performance
   critical. The compiler will probably inline it anyway.

2. dev does not have to be initialized since it is assigned a few
   lines later.  Most programmers are trained now to always initialize
   variables, but often it is unnecessary.

3. The name next_dev() is a little generic; maybe a better name.

^ permalink raw reply

* ip6/ip6 tunnel add/change failure
From: Andras Takacs @ 2011-10-12 15:10 UTC (permalink / raw)
  To: netdev; +Cc: József Kovacs, Emmanuel Thierry, Virág László

[-- Attachment #1: Type: text/plain, Size: 15562 bytes --]

Dear All,

We're using Mobile IPv6 Daemon (mip6d) on Linux 2.6.35.14. Previously we have used 2.6.22 without any kernel-related issues. Unfortunately this kernel version produces a very annoying problem with the IP6/IP6 tunnels. We're having two tunnels, which are linked to two different eth interfaces. 

The issue: All of the packets, independently from the tunnel interface leaves the box via eth1 with the correct source address. Instead of the expected way, when the packets sent via ip6tnl1 go out on eth1, and the others (sent via ip6tnl2) go out on eth2. 

We tried to reproduce this issue without mip6d, only with the ip command. I attached the setup and the test scripts. In this case, the routing works fine.

After a lot of debugging we found the following difference: mip6d creates the tunnel with remote address A. Later, it changes it to B. We found that somewhere here is the key.

1) The following data shows the internals of ip6tnl1 device's net_device structure. we dumped it from the rtnl_fill_ifinfo, which was triggered by ip -6 link ls:

Breakpoint 3, 0xc0399069 in rtnl_fill_ifinfo (skb=0xcee55300, dev=0xcede7000, type=16, pid=537, seq=1318434857, change=0, flags=2)
    at /mnt/hgfs/svnOnMyMac/SZTAKI/ITSSv6/trunk/kernel/linux-2.6.35.14/net/core/rtnetlink.c:1014
1014			if (tb[IFLA_ADDRESS] &&
(gdb) p *dev
$7 = {name = "ip6tnl1\000\000\000\000\000\000\000\000", pm_qos_req = 0x0, name_hlist = {next = 0x0, pprev = 0xcf95fac8}, ifalias = 0x0, mem_end = 0, mem_start = 0, base_addr = 0, 
  irq = 0, if_port = 0 '\0', dma = 0 '\0', state = 3, dev_list = {next = 0xcfbd1838, prev = 0xcec1d038}, napi_list = {next = 0xcede7040, prev = 0xcede7040}, unreg_list = {
    next = 0xcede7048, prev = 0xcede7048}, features = 8192, ifindex = 7, iflink = 4, stats = {rx_packets = 0, tx_packets = 2, rx_bytes = 0, tx_bytes = 176, rx_errors = 0, 
    tx_errors = 0, rx_dropped = 0, tx_dropped = 0, multicast = 0, collisions = 0, rx_length_errors = 0, rx_over_errors = 0, rx_crc_errors = 0, rx_frame_errors = 0, rx_fifo_errors = 0, 
    rx_missed_errors = 0, tx_aborted_errors = 0, tx_carrier_errors = 0, tx_fifo_errors = 0, tx_heartbeat_errors = 0, tx_window_errors = 0, rx_compressed = 0, tx_compressed = 0}, 
  netdev_ops = 0xc0461c78, ethtool_ops = 0x0, header_ops = 0x0, flags = 145, gflags = 0, priv_flags = 1024, padded = 0, operstate = 0 '\0', link_mode = 0 '\0', mtu = 1460, type = 769, 
  hard_header_len = 54, needed_headroom = 0, needed_tailroom = 0, master = 0x0, perm_addr = '\0' <repeats 31 times>, addr_len = 16 '\020', dev_id = 0, addr_list_lock = {{rlock = {
        raw_lock = {slock = 1}, magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffff, dep_map = {key = 0xc0b979dc, class_cache = 0xc072dd30, 
          name = 0xc057b8d5 "_xmit_TUNNEL6"}}, {__padding = "\001\000\000\000?N??????????", dep_map = {key = 0xc0b979dc, class_cache = 0xc072dd30, 
          name = 0xc057b8d5 "_xmit_TUNNEL6"}}}}, uc = {list = {next = 0xcede7120, prev = 0xcede7120}, count = 0}, mc = {list = {next = 0xcede712c, prev = 0xcede712c}, count = 0}, 
  uc_promisc = 0, promiscuity = 0, allmulti = 0, atalk_ptr = 0x0, ip_ptr = 0xceeb5800, dn_ptr = 0x0, ip6_ptr = 0xceeb5e00, ec_ptr = 0x0, ax25_ptr = 0x0, ieee80211_ptr = 0x0, 
  last_rx = 0, dev_addr = 0xced57588 " \001\a8\0200\020\005PT", dev_addrs = {list = {next = 0xced57580, prev = 0xced57580}, count = 1}, 
  broadcast = " \001\a8\0200\000\001\000\000\000\000\000\000\020", '\0' <repeats 16 times>, rx_queue = {dev = 0xcede7000, qdisc = 0xc05e16cc, state = 0, qdisc_sleeping = 0xc05e16cc, 
    _xmit_lock = {{rlock = {raw_lock = {slock = 1}, magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffff, dep_map = {key = 0xc0b97bb4, class_cache = 0x0, 
            name = 0xc057b8d5 "_xmit_TUNNEL6"}}, {__padding = "\001\000\000\000?N??????????", dep_map = {key = 0xc0b97bb4, class_cache = 0x0, name = 0xc057b8d5 "_xmit_TUNNEL6"}}}}, 
    xmit_lock_owner = -1, trans_start = 0, tx_bytes = 0, tx_packets = 0, tx_dropped = 0}, _tx = 0xced57dc0, num_tx_queues = 1, real_num_tx_queues = 1, qdisc = 0xc05e176c, 
  tx_queue_len = 0, tx_global_lock = {{rlock = {raw_lock = {slock = 1}, magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffff, dep_map = {key = 0xc0b978dc, class_cache = 0x0, 
          name = 0xc057b3df "&(&dev->tx_global_lock)->rlock"}}, {__padding = "\001\000\000\000?N??????????", dep_map = {key = 0xc0b978dc, class_cache = 0x0, 
          name = 0xc057b3df "&(&dev->tx_global_lock)->rlock"}}}}, trans_start = 0, watchdog_timeo = 0, watchdog_timer = {entry = {next = 0x0, prev = 0x0}, expires = 0, 
    base = 0xc06609c0, function = 0xc039eb7f <dev_watchdog>, data = 3470684160, slack = -1, start_site = 0x0, start_comm = '\0' <repeats 15 times>, start_pid = -1, lockdep_map = {
      key = 0xc0b98144, class_cache = 0x0, name = 0xc057ca77 "&dev->watchdog_timer"}}, refcnt = {counter = 13}, todo_list = {next = 0x0, prev = 0x0}, index_hlist = {next = 0x0, 
    pprev = 0xcf95fc1c}, link_watch_list = {next = 0xcede7260, prev = 0xcede7260}, reg_state = NETREG_REGISTERED, rtnl_link_state = RTNL_LINK_INITIALIZED, 
  destructor = 0xc038f1b1 <free_netdev>, ml_priv = 0x0, br_port = 0x0, macvlan_port = 0x0, garp_port = 0x0, dev = {parent = 0x0, p = 0xcedfe600, kobj = {name = 0xcfb24ae0 "ip6tnl1", 
      entry = {next = 0xcfbd1a8c, prev = 0xcf80e7fc}, parent = 0xcf99edc0, kset = 0xcf8142a0, ktype = 0xc05d414c, sd = 0xced575c0, kref = {refcount = {counter = 2}}, 
      state_initialized = 1, state_in_sysfs = 1, state_add_uevent_sent = 1, state_remove_uevent_sent = 0, uevent_suppress = 0}, init_name = 0x0, type = 0x0, mutex = {count = {
        counter = 1}, wait_lock = {{rlock = {raw_lock = {slock = 1}, magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffff, dep_map = {key = 0xc0661d9c, class_cache = 0x0, 
              name = 0xc051d978 "&(&lock->wait_lock)->rlock"}}, {__padding = "\001\000\000\000?N??????????", dep_map = {key = 0xc0661d9c, class_cache = 0x0, 
              name = 0xc051d978 "&(&lock->wait_lock)->rlock"}}}}, wait_list = {next = 0xcede72d4, prev = 0xcede72d4}, owner = 0x0, name = 0x0, magic = 0xcede72b4, dep_map = {
        key = 0xc066e010, class_cache = 0x0, name = 0xc05493c7 "&__lockdep_no_validate__"}}, bus = 0x0, driver = 0x0, platform_data = 0xcede7000, power = {power_state = {event = 0}, 
      can_wakeup = 0, should_wakeup = 0, async_suspend = 0, status = DPM_INVALID}, dma_mask = 0x0, coherent_dma_mask = 0, dma_parms = 0x0, dma_pools = {next = 0xcede731c, 
      prev = 0xcede731c}, dma_mem = 0x0, archdata = {acpi_handle = 0x0}, devt = 0, devres_lock = {{rlock = {raw_lock = {slock = 1}, magic = 3735899821, owner_cpu = 4294967295, 
          owner = 0xffffffff, dep_map = {key = 0xc0b92e54, class_cache = 0x0, name = 0xc05493e0 "&(&dev->devres_lock)->rlock"}}, {__padding = "\001\000\000\000?N??????????", 
          dep_map = {key = 0xc0b92e54, class_cache = 0x0, name = 0xc05493e0 "&(&dev->devres_lock)->rlock"}}}}, devres_head = {next = 0xcede734c, prev = 0xcede734c}, knode_class = {
      n_klist = 0xcf9aca4c, n_node = {next = 0xcfbd1b58, prev = 0xcec1d358}, n_ref = {refcount = {counter = 1}}}, class = 0xc05e1008, groups = 0xcede7370, release = 0}, 
  sysfs_groups = {0xc05e1044, 0x0, 0x0, 0x0}, rtnl_link_ops = 0x0, vlan_features = 0, gso_max_size = 65536, ethtool_ntuple_list = {list = {next = 0xcede738c, prev = 0xcede738c}, 
    count = 0}}

I would highlight the ifindex and the iflink values! (ifindex = 7, iflink = 4)

2) Next, we duped out the same for the tunnels, which was created by ip -6 tunnel add. We found the following:

Breakpoint 4, 0xc0399069 in rtnl_fill_ifinfo (skb=0xced2d300, dev=0xceeb4800, type=16, pid=568, seq=1318435116, change=0, flags=2)
    at /mnt/hgfs/svnOnMyMac/SZTAKI/ITSSv6/trunk/kernel/linux-2.6.35.14/net/core/rtnetlink.c:1014
1014			if (tb[IFLA_ADDRESS] &&
(gdb) p *dev
$15 = {name = "ip6test1\000\000\000\000\000\000\000", pm_qos_req = 0x0, name_hlist = {next = 0x0, pprev = 0xcf95f974}, ifalias = 0x0, mem_end = 0, mem_start = 0, base_addr = 0, 
  irq = 0, if_port = 0 '\0', dma = 0 '\0', state = 3, dev_list = {next = 0xceeb6838, prev = 0xcec1d038}, napi_list = {next = 0xceeb4840, prev = 0xceeb4840}, unreg_list = {
    next = 0xceeb4848, prev = 0xceeb4848}, features = 8192, ifindex = 7, iflink = 7, stats = {rx_packets = 0, tx_packets = 0, rx_bytes = 0, tx_bytes = 0, rx_errors = 0, tx_errors = 0, 
    rx_dropped = 0, tx_dropped = 0, multicast = 0, collisions = 0, rx_length_errors = 0, rx_over_errors = 0, rx_crc_errors = 0, rx_frame_errors = 0, rx_fifo_errors = 0, 
    rx_missed_errors = 0, tx_aborted_errors = 0, tx_carrier_errors = 0, tx_fifo_errors = 0, tx_heartbeat_errors = 0, tx_window_errors = 0, rx_compressed = 0, tx_compressed = 0}, 
  netdev_ops = 0xc0461c78, ethtool_ops = 0x0, header_ops = 0x0, flags = 145, gflags = 0, priv_flags = 1024, padded = 0, operstate = 0 '\0', link_mode = 0 '\0', mtu = 1460, type = 769, 
  hard_header_len = 54, needed_headroom = 0, needed_tailroom = 0, master = 0x0, perm_addr = '\0' <repeats 31 times>, addr_len = 16 '\020', dev_id = 0, addr_list_lock = {{rlock = {
        raw_lock = {slock = 1}, magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffff, dep_map = {key = 0xc0b979dc, class_cache = 0xc072c2a0, 
          name = 0xc057b8d5 "_xmit_TUNNEL6"}}, {__padding = "\001\000\000\000?N??????????", dep_map = {key = 0xc0b979dc, class_cache = 0xc072c2a0, 
          name = 0xc057b8d5 "_xmit_TUNNEL6"}}}}, uc = {list = {next = 0xceeb4920, prev = 0xceeb4920}, count = 0}, mc = {list = {next = 0xceeb492c, prev = 0xceeb492c}, count = 0}, 
  uc_promisc = 0, promiscuity = 0, allmulti = 0, atalk_ptr = 0x0, ip_ptr = 0xced77400, dn_ptr = 0x0, ip6_ptr = 0xced77e00, ec_ptr = 0x0, ax25_ptr = 0x0, ieee80211_ptr = 0x0, 
  last_rx = 0, dev_addr = 0xced58c88 " \001\a8\0200\020\004PT", dev_addrs = {list = {next = 0xced58c80, prev = 0xced58c80}, count = 1}, 
  broadcast = " \001\a8\0200\000\001\000\000\000\000\000\000\020", '\0' <repeats 16 times>, rx_queue = {dev = 0xceeb4800, qdisc = 0xc05e16cc, state = 0, qdisc_sleeping = 0xc05e16cc, 
    _xmit_lock = {{rlock = {raw_lock = {slock = 1}, magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffff, dep_map = {key = 0xc0b97bb4, class_cache = 0x0, 
            name = 0xc057b8d5 "_xmit_TUNNEL6"}}, {__padding = "\001\000\000\000?N??????????", dep_map = {key = 0xc0b97bb4, class_cache = 0x0, name = 0xc057b8d5 "_xmit_TUNNEL6"}}}}, 
    xmit_lock_owner = -1, trans_start = 0, tx_bytes = 0, tx_packets = 0, tx_dropped = 0}, _tx = 0xced58c40, num_tx_queues = 1, real_num_tx_queues = 1, qdisc = 0xc05e176c, 
  tx_queue_len = 0, tx_global_lock = {{rlock = {raw_lock = {slock = 1}, magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffff, dep_map = {key = 0xc0b978dc, class_cache = 0x0, 
          name = 0xc057b3df "&(&dev->tx_global_lock)->rlock"}}, {__padding = "\001\000\000\000?N??????????", dep_map = {key = 0xc0b978dc, class_cache = 0x0, 
          name = 0xc057b3df "&(&dev->tx_global_lock)->rlock"}}}}, trans_start = 0, watchdog_timeo = 0, watchdog_timer = {entry = {next = 0x0, prev = 0x0}, expires = 0, 
    base = 0xc06609c0, function = 0xc039eb7f <dev_watchdog>, data = 3471525888, slack = -1, start_site = 0x0, start_comm = '\0' <repeats 15 times>, start_pid = -1, lockdep_map = {
      key = 0xc0b98144, class_cache = 0x0, name = 0xc057ca77 "&dev->watchdog_timer"}}, refcnt = {counter = 11}, todo_list = {next = 0x0, prev = 0x0}, index_hlist = {next = 0x0, 
    pprev = 0xcf95fc1c}, link_watch_list = {next = 0xceeb4a60, prev = 0xceeb4a60}, reg_state = NETREG_REGISTERED, rtnl_link_state = RTNL_LINK_INITIALIZED, 
  destructor = 0xc038f1b1 <free_netdev>, ml_priv = 0x0, br_port = 0x0, macvlan_port = 0x0, garp_port = 0x0, dev = {parent = 0x0, p = 0xceea7380, kobj = {name = 0xcfb54780 "ip6test1", 
      entry = {next = 0xceeb6a8c, prev = 0xcf80d7fc}, parent = 0xcf99fdc0, kset = 0xcf8142a0, ktype = 0xc05d414c, sd = 0xced58780, kref = {refcount = {counter = 2}}, 
      state_initialized = 1, state_in_sysfs = 1, state_add_uevent_sent = 1, state_remove_uevent_sent = 0, uevent_suppress = 0}, init_name = 0x0, type = 0x0, mutex = {count = {
        counter = 1}, wait_lock = {{rlock = {raw_lock = {slock = 1}, magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffff, dep_map = {key = 0xc0661d9c, class_cache = 0x0, 
              name = 0xc051d978 "&(&lock->wait_lock)->rlock"}}, {__padding = "\001\000\000\000?N??????????", dep_map = {key = 0xc0661d9c, class_cache = 0x0, 
              name = 0xc051d978 "&(&lock->wait_lock)->rlock"}}}}, wait_list = {next = 0xceeb4ad4, prev = 0xceeb4ad4}, owner = 0x0, name = 0x0, magic = 0xceeb4ab4, dep_map = {
        key = 0xc066e010, class_cache = 0x0, name = 0xc05493c7 "&__lockdep_no_validate__"}}, bus = 0x0, driver = 0x0, platform_data = 0xceeb4800, power = {power_state = {event = 0}, 
      can_wakeup = 0, should_wakeup = 0, async_suspend = 0, status = DPM_INVALID}, dma_mask = 0x0, coherent_dma_mask = 0, dma_parms = 0x0, dma_pools = {next = 0xceeb4b1c, 
      prev = 0xceeb4b1c}, dma_mem = 0x0, archdata = {acpi_handle = 0x0}, devt = 0, devres_lock = {{rlock = {raw_lock = {slock = 1}, magic = 3735899821, owner_cpu = 4294967295, 
          owner = 0xffffffff, dep_map = {key = 0xc0b92e54, class_cache = 0x0, name = 0xc05493e0 "&(&dev->devres_lock)->rlock"}}, {__padding = "\001\000\000\000?N??????????", 
          dep_map = {key = 0xc0b92e54, class_cache = 0x0, name = 0xc05493e0 "&(&dev->devres_lock)->rlock"}}}}, devres_head = {next = 0xceeb4b4c, prev = 0xceeb4b4c}, knode_class = {
      n_klist = 0xcf9ada4c, n_node = {next = 0xceeb6b58, prev = 0xcec1d358}, n_ref = {refcount = {counter = 1}}}, class = 0xc05e1008, groups = 0xceeb4b70, release = 0}, 
  sysfs_groups = {0xc05e1044, 0x0, 0x0, 0x0}, rtnl_link_ops = 0x0, vlan_features = 0, gso_max_size = 65536, ethtool_ntuple_list = {list = {next = 0xceeb4b8c, prev = 0xceeb4b8c}, 
    count = 0}}

Highlight again: ifindex = 7 iflink = 7. I would like to repeat, that it is the working version, and the mip6d version is the wrong from the usage's point-of-view.

3) What we see from userspace? The ip -6 addr ls is a good help.
If we just added the interface we see:

7: ip6test1: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1460
    inet6 2001:738:1030:1::3/128 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fe12:3459/64 scope link
       valid_lft forever preferred_lft forever

If it has been changed (by mip6d or with the ip -6 tunnel change command):

7: ip6tnl1@eth1: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1460 
    inet6 2001:738:1030:1::3/128 scope global home nodad 
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fe12:3459/64 scope link 
       valid_lft forever preferred_lft forever

The '@' signs that the ifindex and the iflink values are different.

4) One more addition (maybe it helps): The link-local address all of the tunnels are the same, and equals the LL address of eth0. It is quite interesting, because any of the tunnels linked to eth0. (The tunnels are linked to eth1 and eth2).

--- --- --- --- --

We would like to fix this issue very much, but we don't know what was the concept of the existing code. We're sure that the exisiting mechanism is wrong, when the change method procedures a totally different result that the add. We would appreciate any help or comment!


Thank you very much!



Regards,
András




[-- Attachment #2: test-ip6-tnls.sh --]
[-- Type: application/octet-stream, Size: 3799 bytes --]

#!/bin/sh

###
# You should edit these lines

COA_PREFIXLEN=64
HA_ADDR=2001:738:1030:1::1000
HOA_ADDR=2001:738:1030:1::3
HOA_PREFIXLEN=128
MNP_PREFIX=2001:738:1030:2003::
MNP_PREFIXLEN=64

TEST1_PEER=2a01:270:d003::1
TEST2_PEER=2a01:1450:4001:c01::93

###
# You may edit these lines
IF1=eth1
IF2=eth2
TNL1=ip6test1
TNL2=ip6test2
IF1_RR_LLADDR=fe80::20c:29ff:fe3b:4d16
IF2_RR_LLADDR=fe80::20c:29ff:fe3b:4d20

###
# Please do not edit these lines

case "$1" in
"init")
	echo "Initializing"

	IF1_ADDR=`ip -6 a show dev $IF1 scope global | sed -ne 's/^[ ]*inet6 \([0-f0-9:/]\+\) scope global .*$/\1/p'`
	IF2_ADDR=`ip -6 a show dev $IF2 scope global | sed -ne 's/^[ ]*inet6 \([0-f0-9:/]\+\) scope global .*$/\1/p'`
	PREFIXLEN=`expr \( 128 - $COA_PREFIXLEN \) / 8 / 2`
	IF1_PREFIX="`ip -6 a show dev $IF1 scope global | sed -ne "s/^[ ]*inet6 \(\([a-f0-9]\+:\)\{$PREFIXLEN\}\)[a-f0-9:/]\+ scope global .*\$/\1/p"`:"
	IF2_PREFIX="`ip -6 a show dev $IF2 scope global | sed -ne "s/^[ ]*inet6 \(\([a-f0-9]\+:\)\{$PREFIXLEN\}\)[a-f0-9:/]\+ scope global .*\$/\1/p"`:"
	if [ "x$IF1_RR_LLADDR" = "x" ]; then
		IF1_RR_LLADDR=`ip -6 neigh ls | sed -ne "s/^\([a-f0-9:]\+\) dev $IF1 lladdr .*\$/\1/p"`
	fi
	if [ "x$IF2_RR_LLADDR" = "x" ]; then
		IF2_RR_LLADDR=`ip -6 neigh ls | sed -ne "s/^\([a-f0-9:]\+\) dev $IF2 lladdr .*\$/\1/p"`
	fi

	echo "$IF1 address: $IF1_ADDR"
	echo "$IF2 address: $IF2_ADDR"
	echo "$IF1 prefix: $IF1_PREFIX"
	echo "$IF2 prefix: $IF2_PREFIX"
	echo "$IF1 router's LL address: $IF1_RR_LLADDR"
	echo "$IF2 router's LL address: $IF2_RR_LLADDR"

	ip -6 r add default via $IF1_RR_LLADDR dev $IF1
	ip -6 r add default via $IF2_RR_LLADDR dev $IF2

	if [ "x`ip -6 tunnel ls | grep $TNL1`" != "x" ]; then
		ip -6 tunnel del $TNL1
	fi
	if [ "x`ip -6 tunnel ls | grep $TNL1`" != "x" ]; then
		ip -6 tunnel del $TNL2
	fi
	ip -6 tunnel add $TNL1 mode ip6ip6 remote $HA_ADDR local $IF1_ADDR dev $IF1 encaplimit none hoplimit 64 tclass 0x00 flowlabel 0x00000000
	ip -6 tunnel add $TNL2 mode ip6ip6 remote $HA_ADDR local $IF2_ADDR dev $IF2 encaplimit none hoplimit 64 tclass 0x00 flowlabel 0x00000000
	ip l set $TNL1 up
	ip l set $TNL2 up

	ip -6 a add $HOA_ADDR/$HOA_PREFIXLEN dev $TNL1
	ip -6 a add $HOA_ADDR/$HOA_PREFIXLEN dev $TNL2

	# Note: the $MNP_PREFIX/$MNP_PREFIXLEN rules for forwarded packets from MNN
	ip -6 rule add from all to $MNP_PREFIX/$MNP_PREFIXLEN lookup main pref 1000
	ip -6 rule add from $HOA_ADDR fwmark 0x64 lookup 100 pref 1001
	ip -6 rule add from $HOA_ADDR fwmark 0xc8 lookup 200 pref 1001
	ip -6 rule add from $HOA_ADDR lookup 100 pref 1002
	ip -6 rule add from fe80::/64 lookup main pref 1003
	ip -6 rule add from 2001:738:1030:1004::/64 lookup main pref 1003
	ip -6 rule add from 2001:738:1030:1005::/64 lookup main pref 1003
	ip -6 rule add from $HOA_ADDR blackhole pref 1004
	ip -6 rule add from $MNP_PREFIX/$MNP_PREFIXLEN fwmark 0x64 lookup 100 pref 1006
	ip -6 rule add from $MNP_PREFIX/$MNP_PREFIXLEN fwmark 0xc8 lookup 200 pref 1006
	ip -6 rule add from $MNP_PREFIX/$MNP_PREFIXLEN lookup 100 pref 1007

	ip -6 r add default dev $TNL1 table 100
	ip -6 r add default from $MNP_PREFIX/$MNP_PREFIXLEN dev $TNL1 table 100

	ip -6 r add default dev $TNL2 table 200
	ip -6 r add default from $MNP_PREFIX/$MNP_PREFIXLEN dev $TNL2 table 200

	ip6tables -t mangle -A OUTPUT -d $TEST1_PEER -j MARK --set-xmark 0x64/0xffffffff 
	ip6tables -t mangle -A OUTPUT -d $TEST2_PEER -j MARK --set-xmark 0xc8/0xffffffff 

	;;
"test1")
	echo "Test1 with $TEST1_PEER"
	echo "It should marked with 100"
	echo "It should sent via $TNL1 via $IF1"

	ping -I $HOA_ADDR $TEST1_PEER
	;;
"test2")
	echo "Test2 with $TEST2_PEER"
	echo "It should marked with 200"
	echo "It should sent via $TNL2 via $IF2"
	
	ping -I $HOA_ADDR $TEST2_PEER
	;;
*)
	echo "Usage: $0 [init|test1|test2]"
	exit 1
	;;
esac




[-- Attachment #3: Type: text/plain, Size: 195 bytes --]




András Takács

MTA SZTAKI
Computer and Automation Research Institute
Hungarian Academy of Sciences

Email: andras.takacs@sztaki.hu
Office: +36-1-279-6288
Mobile: +36-70-282-5316


^ permalink raw reply

* Re: bridge: HSR support
From: Arvid Brodin @ 2011-10-12 14:24 UTC (permalink / raw)
  To: David Lamparter; +Cc: netdev, Stephen Hemminger, Lennert Buytenhek
In-Reply-To: <20111012132822.GJ2840382@jupiter.n2.diac24.net>


David Lamparter wrote:
> On Wed, Oct 12, 2011 at 01:51:22AM +0200, Arvid Brodin wrote:
>> Stephen Hemminger wrote:
>>>> I want to add support for HSR ("High-availability Seamless Redundancy",
>>>> IEC-62439-3) to the bridge code. With HSR, all connected units have two network
>>>> ports and are connected in a ring. All new Ethernet packets are sent on both
>>>> ports (or passed through if the current unit is not the originating unit).
> 
> 
>>>> The same packet is never passed twice.
> 
> How does the bridge decide whether a packet is arriving the second time?
> Is the ring pre-resolved to stop things or does this happen per-packet?

It happens per-packet. I believe a combination of source MAC address and the HSR
sequence tag is used to identify duplicates.

-- 
Arvid Brodin
Enea Services Stockholm AB

^ permalink raw reply

* [net-next 2/5] stmmac: allow mtu bigger than 1500 in case of normal desc (V2).
From: Giuseppe CAVALLARO @ 2011-10-12 13:38 UTC (permalink / raw)
  To: netdev; +Cc: davem, Giuseppe Cavallaro, Deepak SIKRI
In-Reply-To: <1318426688-9419-1-git-send-email-peppe.cavallaro@st.com>

This patch allows to set the mtu bigger than 1500
in case of normal descriptors.
This is helping some SPEAr customers.

Signed-off-by: Deepak SIKRI <deepak.sikri@st.com>
Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index ba7af2c..de3e536 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1357,17 +1357,17 @@ static void stmmac_set_rx_mode(struct net_device *dev)
 static int stmmac_change_mtu(struct net_device *dev, int new_mtu)
 {
 	struct stmmac_priv *priv = netdev_priv(dev);
-	int max_mtu;
+	int max_mtu = ETH_DATA_LEN;
 
 	if (netif_running(dev)) {
 		pr_err("%s: must be stopped to change its MTU\n", dev->name);
 		return -EBUSY;
 	}
 
-	if (priv->plat->has_gmac)
+	if (priv->plat->enh_desc)
 		max_mtu = JUMBO_LEN;
 	else
-		max_mtu = ETH_DATA_LEN;
+		max_mtu = BUF_SIZE_4KiB;
 
 	if ((new_mtu < 46) || (new_mtu > max_mtu)) {
 		pr_err("%s: invalid MTU, max MTU is: %d\n", dev->name, max_mtu);
-- 
1.7.4.4

^ permalink raw reply related

* [net-next 5/5] stmmac: update the driver version and doc (V2)
From: Giuseppe CAVALLARO @ 2011-10-12 13:38 UTC (permalink / raw)
  To: netdev; +Cc: davem, Giuseppe Cavallaro
In-Reply-To: <1318426688-9419-1-git-send-email-peppe.cavallaro@st.com>

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 Documentation/networking/stmmac.txt          |   11 ++++++++++-
 drivers/net/ethernet/stmicro/stmmac/stmmac.h |    2 +-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/Documentation/networking/stmmac.txt b/Documentation/networking/stmmac.txt
index 40ec92c..8d67980 100644
--- a/Documentation/networking/stmmac.txt
+++ b/Documentation/networking/stmmac.txt
@@ -76,7 +76,16 @@ core.
 
 4.5) DMA descriptors
 Driver handles both normal and enhanced descriptors. The latter has been only
-tested on DWC Ether MAC 10/100/1000 Universal version 3.41a.
+tested on DWC Ether MAC 10/100/1000 Universal version 3.41a and later.
+
+STMMAC supports DMA descriptor to operate both in dual buffer (RING)
+and linked-list(CHAINED) mode. In RING each descriptor points to two
+data buffer pointers whereas in CHAINED mode they point to only one data
+buffer pointer. RING mode is the default.
+
+In CHAINED mode each descriptor will have pointer to next descriptor in
+the list, hence creating the explicit chaining in the descriptor itself,
+whereas such explicit chaining is not possible in RING mode.
 
 4.6) Ethtool support
 Ethtool is supported. Driver statistics and internal errors can be taken using:
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index 50e95d8..49a4af3 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -20,7 +20,7 @@
   Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
 *******************************************************************************/
 
-#define DRV_MODULE_VERSION	"Aug_2011"
+#define DRV_MODULE_VERSION	"Oct_2011"
 #include <linux/stmmac.h>
 
 #include "common.h"
-- 
1.7.4.4

^ permalink raw reply related

* [net-next 4/5] stmmac: Stop advertising 1000Base capabilties for non GMII iface (V2).
From: Giuseppe CAVALLARO @ 2011-10-12 13:38 UTC (permalink / raw)
  To: netdev; +Cc: davem, Srinivas Kandagatla, Giuseppe Cavallaro
In-Reply-To: <1318426688-9419-1-git-send-email-peppe.cavallaro@st.com>

From: Srinivas Kandagatla <srinivas.kandagatla@st.com>

This patch stops advertising 1000Base capablities if GMAC is either
configured for MII or RMII mode and on board there is a GPHY plugged on.
Without this patch if an GBit switch is connected on MII interface,
Ethernet stops working at all.

Discovered as part of
https://bugzilla.stlinux.com/show_bug.cgi?id=14148 triage

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com>
Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 7b3b6c9..08dc116 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -314,7 +314,7 @@ static int stmmac_init_phy(struct net_device *dev)
 	struct phy_device *phydev;
 	char phy_id[MII_BUS_ID_SIZE + 3];
 	char bus_id[MII_BUS_ID_SIZE];
-
+	int interface = priv->plat->interface;
 	priv->oldlink = 0;
 	priv->speed = 0;
 	priv->oldduplex = -1;
@@ -324,14 +324,21 @@ static int stmmac_init_phy(struct net_device *dev)
 		 priv->plat->phy_addr);
 	pr_debug("stmmac_init_phy:  trying to attach to %s\n", phy_id);
 
-	phydev = phy_connect(dev, phy_id, &stmmac_adjust_link, 0,
-			     priv->plat->interface);
+	phydev = phy_connect(dev, phy_id, &stmmac_adjust_link, 0, interface);
 
 	if (IS_ERR(phydev)) {
 		pr_err("%s: Could not attach to PHY\n", dev->name);
 		return PTR_ERR(phydev);
 	}
 
+	/* Stop Advertising 1000BASE Capability if interface is not GMII */
+	if ((interface == PHY_INTERFACE_MODE_MII) ||
+	    (interface == PHY_INTERFACE_MODE_RMII)) {
+		phydev->supported &= (PHY_BASIC_FEATURES | SUPPORTED_Pause |
+				      SUPPORTED_Asym_Pause);
+		priv->phydev->advertising = priv->phydev->supported;
+	}
+
 	/*
 	 * Broken HW is sometimes missing the pull-up resistor on the
 	 * MDIO line, which results in reads to non-existent devices returning
-- 
1.7.4.4

^ permalink raw reply related

* [net-next 3/5] stmmac: protect tx process with lock (V2)
From: Giuseppe CAVALLARO @ 2011-10-12 13:38 UTC (permalink / raw)
  To: netdev; +Cc: davem, Giuseppe Cavallaro
In-Reply-To: <1318426688-9419-1-git-send-email-peppe.cavallaro@st.com>

This patch fixes a problem raised on Orly ARM SMP platform
where, in case of fragmented frames, the descriptors
in the TX ring resulted broken. This was due to a missing lock
protection in the tx process.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Tested-by: Srinivas Kandagatla <srinivas.kandagatla@st.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac.h      |    1 +
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |    8 ++++++++
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index 1434bdb..50e95d8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -70,6 +70,7 @@ struct stmmac_priv {
 
 	u32 msg_enable;
 	spinlock_t lock;
+	spinlock_t tx_lock;
 	int wolopts;
 	int wolenabled;
 	int wol_irq;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index de3e536..7b3b6c9 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -590,6 +590,8 @@ static void stmmac_tx(struct stmmac_priv *priv)
 {
 	unsigned int txsize = priv->dma_tx_size;
 
+	spin_lock(&priv->tx_lock);
+
 	while (priv->dirty_tx != priv->cur_tx) {
 		int last;
 		unsigned int entry = priv->dirty_tx % txsize;
@@ -652,6 +654,7 @@ static void stmmac_tx(struct stmmac_priv *priv)
 		}
 		netif_tx_unlock(priv->dev);
 	}
+	spin_unlock(&priv->tx_lock);
 }
 
 static inline void stmmac_enable_irq(struct stmmac_priv *priv)
@@ -1038,6 +1041,8 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 		return NETDEV_TX_BUSY;
 	}
 
+	spin_lock(&priv->tx_lock);
+
 	entry = priv->cur_tx % txsize;
 
 #ifdef STMMAC_XMIT_DEBUG
@@ -1126,6 +1131,8 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	priv->hw->dma->enable_dma_transmission(priv->ioaddr);
 
+	spin_unlock(&priv->tx_lock);
+
 	return NETDEV_TX_OK;
 }
 
@@ -1690,6 +1697,7 @@ static int stmmac_probe(struct net_device *dev)
 			"please, use ifconfig or nwhwconfig!\n");
 
 	spin_lock_init(&priv->lock);
+	spin_lock_init(&priv->tx_lock);
 
 	ret = register_netdev(dev);
 	if (ret) {
-- 
1.7.4.4

^ permalink raw reply related

* [net-next 1/5] stmmac: add CHAINED descriptor mode support (V2)
From: Giuseppe CAVALLARO @ 2011-10-12 13:38 UTC (permalink / raw)
  To: netdev; +Cc: davem, Giuseppe Cavallaro, Rayagond Kokatanur
In-Reply-To: <1318426688-9419-1-git-send-email-peppe.cavallaro@st.com>

This patch enhances the STMMAC driver to support CHAINED mode of
descriptor (useful also on validation side).

STMMAC supports DMA descriptor to operate both in dual buffer(RING)
and linked-list(CHAINED) mode. In RING mode (default) each descriptor
points to two data buffer pointers whereas in CHAINED mode they point
to only one data buffer pointer.

In CHAINED mode each descriptor will have pointer to next descriptor in
the list, hence creating the explicit chaining in the descriptor itself,
whereas such explicit chaining is not possible in RING mode.

First version of this work has been done by Rayagond; I've reworked
the whole support and added a new header file to implement the
helper routines specialised for chained/ring modes (as D. Miller
suggested).

Signed-off-by: Rayagond Kokatanur <rayagond@vayavyalabs.com>
Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 drivers/net/ethernet/stmicro/stmmac/Kconfig       |   18 +
 drivers/net/ethernet/stmicro/stmmac/common.h      |   19 +
 drivers/net/ethernet/stmicro/stmmac/enh_desc.c    |   51 ---
 drivers/net/ethernet/stmicro/stmmac/norm_desc.c   |   42 --
 drivers/net/ethernet/stmicro/stmmac/ring_mode.h   |  450 +++++++++++++++++++++
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |  121 ++----
 6 files changed, 531 insertions(+), 170 deletions(-)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/ring_mode.h

diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
index 8cd9dde..ac6f190 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
+++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
@@ -63,4 +63,22 @@ config STMMAC_RTC_TIMER
 
 endchoice
 
+choice
+	prompt "Select the DMA TX/RX descriptor operating modes"
+	depends on STMMAC_ETH
+	---help---
+	  This driver supports DMA descriptor to operate both in dual buffer
+	  (RING) and linked-list(CHAINED) mode. In RING mode each descriptor
+	  points to two data buffer pointers whereas in CHAINED mode they
+	  points to only one data buffer pointer.
+
+config STMMAC_RING
+	bool "Enable Descriptor Ring Mode"
+
+config STMMAC_CHAINED
+	bool "Enable Descriptor Chained Mode"
+
+endchoice
+
+
 endif
diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index 22c61b2..90ba81a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -152,6 +152,7 @@ struct dma_features {
 #define BUF_SIZE_8KiB 8192
 #define BUF_SIZE_4KiB 4096
 #define BUF_SIZE_2KiB 2048
+#define DMA_BUFFER_SIZE	BUF_SIZE_2KiB
 
 /* Power Down and WOL */
 #define PMT_NOT_SUPPORTED 0
@@ -261,6 +262,7 @@ struct mac_device_info {
 	const struct stmmac_ops		*mac;
 	const struct stmmac_desc_ops	*desc;
 	const struct stmmac_dma_ops	*dma;
+	const struct stmmac_ring_mode_ops	*ring;
 	struct mii_regs mii;	/* MII register Addresses */
 	struct mac_link link;
 	unsigned int synopsys_uid;
@@ -274,3 +276,20 @@ extern void stmmac_set_mac_addr(void __iomem *ioaddr, u8 addr[6],
 extern void stmmac_get_mac_addr(void __iomem *ioaddr, unsigned char *addr,
 				unsigned int high, unsigned int low);
 extern void dwmac_dma_flush_tx_fifo(void __iomem *ioaddr);
+
+extern void ndesc_init_rx_desc(struct dma_desc *p, unsigned int ring_size,
+			       int disable_rx_ic);
+extern void enh_desc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len,
+				     int csum_flag);
+extern void enh_desc_release_tx_desc(struct dma_desc *p);
+extern void enh_desc_init_tx_desc(struct dma_desc *p, unsigned int ring_size);
+extern void enh_desc_init_rx_desc(struct dma_desc *p, unsigned int ring_size,
+				  int disable_rx_ic);
+extern void ndesc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len,
+				  int csum_flag);
+extern void ndesc_release_tx_desc(struct dma_desc *p);
+extern void ndesc_init_tx_desc(struct dma_desc *p, unsigned int ring_size);
+extern void ndesc_init_rx_desc(struct dma_desc *p, unsigned int ring_size,
+			       int disable_rx_ic);
+
+
diff --git a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
index e5dfb6a..f378b3b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
+++ b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
@@ -226,35 +226,6 @@ static int enh_desc_get_rx_status(void *data, struct stmmac_extra_stats *x,
 	return ret;
 }
 
-static void enh_desc_init_rx_desc(struct dma_desc *p, unsigned int ring_size,
-				  int disable_rx_ic)
-{
-	int i;
-	for (i = 0; i < ring_size; i++) {
-		p->des01.erx.own = 1;
-		p->des01.erx.buffer1_size = BUF_SIZE_8KiB - 1;
-		/* To support jumbo frames */
-		p->des01.erx.buffer2_size = BUF_SIZE_8KiB - 1;
-		if (i == ring_size - 1)
-			p->des01.erx.end_ring = 1;
-		if (disable_rx_ic)
-			p->des01.erx.disable_ic = 1;
-		p++;
-	}
-}
-
-static void enh_desc_init_tx_desc(struct dma_desc *p, unsigned int ring_size)
-{
-	int i;
-
-	for (i = 0; i < ring_size; i++) {
-		p->des01.etx.own = 0;
-		if (i == ring_size - 1)
-			p->des01.etx.end_ring = 1;
-		p++;
-	}
-}
-
 static int enh_desc_get_tx_owner(struct dma_desc *p)
 {
 	return p->des01.etx.own;
@@ -280,28 +251,6 @@ static int enh_desc_get_tx_ls(struct dma_desc *p)
 	return p->des01.etx.last_segment;
 }
 
-static void enh_desc_release_tx_desc(struct dma_desc *p)
-{
-	int ter = p->des01.etx.end_ring;
-
-	memset(p, 0, offsetof(struct dma_desc, des2));
-	p->des01.etx.end_ring = ter;
-}
-
-static void enh_desc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len,
-				     int csum_flag)
-{
-	p->des01.etx.first_segment = is_fs;
-	if (unlikely(len > BUF_SIZE_4KiB)) {
-		p->des01.etx.buffer1_size = BUF_SIZE_4KiB;
-		p->des01.etx.buffer2_size = len - BUF_SIZE_4KiB;
-	} else {
-		p->des01.etx.buffer1_size = len;
-	}
-	if (likely(csum_flag))
-		p->des01.etx.checksum_insertion = cic_full;
-}
-
 static void enh_desc_clear_tx_ic(struct dma_desc *p)
 {
 	p->des01.etx.interrupt = 0;
diff --git a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
index 029c2a2..1cd985f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
+++ b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
@@ -119,32 +119,6 @@ static int ndesc_get_rx_status(void *data, struct stmmac_extra_stats *x,
 	return ret;
 }
 
-static void ndesc_init_rx_desc(struct dma_desc *p, unsigned int ring_size,
-			       int disable_rx_ic)
-{
-	int i;
-	for (i = 0; i < ring_size; i++) {
-		p->des01.rx.own = 1;
-		p->des01.rx.buffer1_size = BUF_SIZE_2KiB - 1;
-		if (i == ring_size - 1)
-			p->des01.rx.end_ring = 1;
-		if (disable_rx_ic)
-			p->des01.rx.disable_ic = 1;
-		p++;
-	}
-}
-
-static void ndesc_init_tx_desc(struct dma_desc *p, unsigned int ring_size)
-{
-	int i;
-	for (i = 0; i < ring_size; i++) {
-		p->des01.tx.own = 0;
-		if (i == ring_size - 1)
-			p->des01.tx.end_ring = 1;
-		p++;
-	}
-}
-
 static int ndesc_get_tx_owner(struct dma_desc *p)
 {
 	return p->des01.tx.own;
@@ -170,22 +144,6 @@ static int ndesc_get_tx_ls(struct dma_desc *p)
 	return p->des01.tx.last_segment;
 }
 
-static void ndesc_release_tx_desc(struct dma_desc *p)
-{
-	int ter = p->des01.tx.end_ring;
-
-	memset(p, 0, offsetof(struct dma_desc, des2));
-	/* set termination field */
-	p->des01.tx.end_ring = ter;
-}
-
-static void ndesc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len,
-				  int csum_flag)
-{
-	p->des01.tx.first_segment = is_fs;
-	p->des01.tx.buffer1_size = len;
-}
-
 static void ndesc_clear_tx_ic(struct dma_desc *p)
 {
 	p->des01.tx.interrupt = 0;
diff --git a/drivers/net/ethernet/stmicro/stmmac/ring_mode.h b/drivers/net/ethernet/stmicro/stmmac/ring_mode.h
new file mode 100644
index 0000000..32fe688
--- /dev/null
+++ b/drivers/net/ethernet/stmicro/stmmac/ring_mode.h
@@ -0,0 +1,450 @@
+/*******************************************************************************
+  Header File to describe the DMA descriptor ring/chain(s)
+
+  Copyright(C) 2011  STMicroelectronics Ltd
+
+  It defines all the functions used to handle the normal/enhanced
+  descriptors in case of the DMA is configured to work in chained or
+  in ring mode.
+
+  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.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+  Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
+*******************************************************************************/
+
+#if defined(CONFIG_STMMAC_RING)
+
+static unsigned int stmmac_jumbo_frm(struct stmmac_priv *priv,
+				     struct sk_buff *skb, int csum_insertion)
+{
+	unsigned int txsize = priv->dma_tx_size;
+	unsigned int entry = priv->cur_tx % txsize;
+	struct dma_desc *desc = priv->dma_tx + entry;
+	unsigned int nopaged_len = skb_headlen(skb);
+	unsigned int buf_max_size, len;
+
+	if (priv->plat->enh_desc)
+		buf_max_size = BUF_SIZE_8KiB;
+	else
+		buf_max_size = BUF_SIZE_2KiB;
+
+	len = nopaged_len - buf_max_size;
+
+	if (nopaged_len > BUF_SIZE_8KiB) {
+
+		desc->des2 = dma_map_single(priv->device, skb->data,
+					    buf_max_size, DMA_TO_DEVICE);
+		desc->des3 = desc->des2 + BUF_SIZE_4KiB;
+		priv->hw->desc->prepare_tx_desc(desc, 1, buf_max_size,
+						csum_insertion);
+
+		entry = (++priv->cur_tx) % txsize;
+		desc = priv->dma_tx + entry;
+
+		desc->des2 = dma_map_single(priv->device,
+					    skb->data + buf_max_size,
+					    len, DMA_TO_DEVICE);
+		desc->des3 = desc->des2 + BUF_SIZE_4KiB;
+		priv->hw->desc->prepare_tx_desc(desc, 0, len, csum_insertion);
+		priv->hw->desc->set_tx_owner(desc);
+		priv->tx_skbuff[entry] = NULL;
+	} else {
+		desc->des2 = dma_map_single(priv->device, skb->data,
+					    nopaged_len, DMA_TO_DEVICE);
+		desc->des3 = desc->des2 + BUF_SIZE_4KiB;
+		priv->hw->desc->prepare_tx_desc(desc, 1, nopaged_len,
+						csum_insertion);
+	}
+
+	return entry;
+}
+
+static unsigned int stmmac_is_jumbo_frame(struct stmmac_priv *priv,
+					  struct sk_buff *skb,
+					  int csum, struct dma_desc *desc)
+{
+	unsigned int ret = 0;
+
+	if (unlikely(skb->len >= BUF_SIZE_4KiB)) {
+		unsigned int entry = stmmac_jumbo_frm(priv, skb, csum);
+		desc = priv->dma_tx + entry;
+		ret = 1;
+	}
+
+	return ret;
+}
+
+static void stmmac_refill_desc3(int bfsize, struct dma_desc *p)
+{
+	/* Fill DES3 in case of RING mode */
+	if (bfsize >= BUF_SIZE_8KiB)
+		p->des3 = p->des2 + BUF_SIZE_8KiB;
+}
+
+/* In ring mode we need to fill the desc3 because it is used
+ * as buffer */
+static void stmmac_init_desc3(int des3_as_data_buf, struct dma_desc *p)
+{
+	if (unlikely(des3_as_data_buf))
+		p->des3 = p->des2 + BUF_SIZE_8KiB;
+}
+
+static void stmmac_init_dma_chain(struct dma_desc *des, dma_addr_t phy_addr,
+				  unsigned int size)
+{
+}
+
+static void stmmac_clean_desc3(struct dma_desc *p)
+{
+	if (unlikely(p->des3))
+		p->des3 = 0;
+}
+
+static int stmmac_set_bfsize(int mtu, int bufsize)
+{
+	int ret = bufsize;
+
+	if (unlikely(mtu >= BUF_SIZE_8KiB))
+		ret = BUF_SIZE_16KiB;
+	else if (unlikely(mtu >= BUF_SIZE_4KiB))
+		ret = BUF_SIZE_8KiB;
+	else if (unlikely(mtu >= BUF_SIZE_2KiB))
+		ret = BUF_SIZE_4KiB;
+	else if (unlikely(mtu >= DMA_BUFFER_SIZE))
+		ret = BUF_SIZE_2KiB;
+	else
+		ret = DMA_BUFFER_SIZE;
+
+	return ret;
+}
+
+/* Normal/enhanced descriptor functions for RING mode */
+
+inline void enh_desc_init_rx_desc(struct dma_desc *p, unsigned int ring_size,
+				  int disable_rx_ic)
+{
+	int i;
+	for (i = 0; i < ring_size; i++) {
+		p->des01.erx.own = 1;
+		p->des01.erx.buffer1_size = BUF_SIZE_8KiB - 1;
+		/* To support jumbo frames */
+		p->des01.erx.buffer2_size = BUF_SIZE_8KiB - 1;
+		if (i == (ring_size - 1))
+			p->des01.erx.end_ring = 1;
+		if (disable_rx_ic)
+			p->des01.erx.disable_ic = 1;
+		p++;
+	}
+}
+
+inline void enh_desc_init_tx_desc(struct dma_desc *p, unsigned int ring_size)
+{
+	int i;
+
+	for (i = 0; i < ring_size; i++) {
+		p->des01.etx.own = 0;
+		if (i == (ring_size - 1))
+			p->des01.etx.end_ring = 1;
+		p++;
+	}
+}
+
+inline void enh_desc_release_tx_desc(struct dma_desc *p)
+{
+	int ter = p->des01.etx.end_ring;
+
+	memset(p, 0, offsetof(struct dma_desc, des2));
+	p->des01.etx.end_ring = ter;
+}
+
+inline void enh_desc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len,
+				     int csum_flag)
+{
+	p->des01.etx.first_segment = is_fs;
+
+	if (unlikely(len > BUF_SIZE_4KiB)) {
+		p->des01.etx.buffer1_size = BUF_SIZE_4KiB;
+		p->des01.etx.buffer2_size = len - BUF_SIZE_4KiB;
+	} else
+		p->des01.etx.buffer1_size = len;
+
+	if (likely(csum_flag))
+		p->des01.etx.checksum_insertion = cic_full;
+}
+
+inline void ndesc_init_rx_desc(struct dma_desc *p, unsigned int ring_size,
+			       int disable_rx_ic)
+{
+	int i;
+	for (i = 0; i < ring_size; i++) {
+		p->des01.rx.own = 1;
+		p->des01.rx.buffer1_size = BUF_SIZE_2KiB - 1;
+		p->des01.rx.buffer2_size = BUF_SIZE_2KiB - 1;
+		if (i == (ring_size - 1))
+			p->des01.rx.end_ring = 1;
+		if (disable_rx_ic)
+			p->des01.rx.disable_ic = 1;
+		p++;
+	}
+}
+
+inline void ndesc_init_tx_desc(struct dma_desc *p, unsigned int ring_size)
+{
+	int i;
+	for (i = 0; i < ring_size; i++) {
+		p->des01.tx.own = 0;
+		if (i == (ring_size - 1))
+			p->des01.tx.end_ring = 1;
+		p++;
+	}
+}
+
+inline void ndesc_release_tx_desc(struct dma_desc *p)
+{
+	int ter = p->des01.tx.end_ring;
+
+	memset(p, 0, offsetof(struct dma_desc, des2));
+	/* set termination field */
+	p->des01.tx.end_ring = ter;
+}
+
+inline void ndesc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len,
+				  int csum_flag)
+{
+	p->des01.tx.first_segment = is_fs;
+
+	if (unlikely(len > BUF_SIZE_2KiB)) {
+		p->des01.etx.buffer1_size = BUF_SIZE_2KiB - 1;
+		p->des01.etx.buffer2_size = len - p->des01.etx.buffer1_size;
+	} else
+		p->des01.tx.buffer1_size = len;
+}
+
+#else
+
+/* Chained mode functions */
+
+static unsigned int stmmac_jumbo_frm(struct stmmac_priv *priv,
+				     struct sk_buff *skb, int csum_insertion)
+{
+	unsigned int txsize = priv->dma_tx_size;
+	unsigned int entry = priv->cur_tx % txsize;
+	struct dma_desc *desc = priv->dma_tx + entry;
+	unsigned int nopaged_len = skb_headlen(skb);
+	unsigned int buf_max_size;
+	unsigned int i = 1, len;
+
+	if (priv->plat->enh_desc)
+		buf_max_size = BUF_SIZE_8KiB;
+	else
+		buf_max_size = BUF_SIZE_2KiB;
+
+	len = nopaged_len - buf_max_size;
+
+	desc->des2 = dma_map_single(priv->device, skb->data,
+				    buf_max_size, DMA_TO_DEVICE);
+	priv->hw->desc->prepare_tx_desc(desc, 1, buf_max_size, csum_insertion);
+
+	while (len != 0) {
+		entry = (++priv->cur_tx) % txsize;
+		desc = priv->dma_tx + entry;
+
+		if (len > buf_max_size) {
+			desc->des2 = dma_map_single(priv->device,
+						    (skb->data +
+						     buf_max_size * i),
+						    buf_max_size,
+						    DMA_TO_DEVICE);
+			priv->hw->desc->prepare_tx_desc(desc, 0, buf_max_size,
+							csum_insertion);
+			priv->hw->desc->set_tx_owner(desc);
+			priv->tx_skbuff[entry] = NULL;
+			len -= buf_max_size;
+			i++;
+		} else {
+			desc->des2 = dma_map_single(priv->device,
+						    (skb->data +
+						     buf_max_size * i), len,
+						    DMA_TO_DEVICE);
+			priv->hw->desc->prepare_tx_desc(desc, 0, len,
+							csum_insertion);
+			priv->hw->desc->set_tx_owner(desc);
+			priv->tx_skbuff[entry] = NULL;
+			len = 0;
+		}
+	}
+	return entry;
+}
+
+static unsigned int stmmac_is_jumbo_frame(struct stmmac_priv *priv,
+					  struct sk_buff *skb,
+					  int csum, struct dma_desc *desc)
+{
+	unsigned int ret = 0;
+
+	if ((priv->plat->enh_desc && unlikely(skb->len > BUF_SIZE_8KiB)) ||
+	    (!priv->plat->enh_desc && unlikely(skb->len > BUF_SIZE_2KiB))) {
+		unsigned int entry = stmmac_jumbo_frm(priv, skb, csum);
+		desc = priv->dma_tx + entry;
+		ret = 1;
+	}
+
+	return ret;
+}
+
+static void stmmac_refill_desc3(int bfsize, struct dma_desc *p)
+{
+}
+
+static void stmmac_init_desc3(int des3_as_data_buf, struct dma_desc *p)
+{
+}
+
+static void stmmac_clean_desc3(struct dma_desc *p)
+{
+}
+
+/* In chained mode des3 points to the next element in the ring.
+ * The latest element has to point to the head.
+ */
+static void stmmac_init_dma_chain(struct dma_desc *des, dma_addr_t phy_addr,
+				  unsigned int size)
+{
+	int i;
+	struct dma_desc *p = des;
+	dma_addr_t dma_phy = phy_addr;
+
+	for (i = 0; i < (size - 1); i++) {
+		dma_phy += sizeof(struct dma_desc);
+		p->des3 = (unsigned int)dma_phy;
+		p++;
+	}
+	p->des3 = (unsigned int)phy_addr;
+}
+
+static int stmmac_set_bfsize(int mtu, int bufsize)
+{
+	int ret = bufsize;
+
+	if (unlikely(mtu >= BUF_SIZE_4KiB))
+		ret = BUF_SIZE_8KiB;
+	else if (unlikely(mtu >= BUF_SIZE_2KiB))
+		ret = BUF_SIZE_4KiB;
+	else if (unlikely(mtu >= DMA_BUFFER_SIZE))
+		ret = BUF_SIZE_2KiB;
+	else
+		ret = DMA_BUFFER_SIZE;
+
+	return ret;
+}
+
+/* Normal/enhanced descriptor functions for RING mode */
+
+inline void enh_desc_init_rx_desc(struct dma_desc *p, unsigned int ring_size,
+				  int disable_rx_ic)
+{
+	int i;
+	for (i = 0; i < ring_size; i++) {
+		p->des01.erx.own = 1;
+		p->des01.erx.buffer1_size = BUF_SIZE_8KiB - 1;
+		/* To support jumbo frames */
+		p->des01.erx.second_address_chained = 1;
+		if (disable_rx_ic)
+			p->des01.erx.disable_ic = 1;
+		p++;
+	}
+}
+
+inline void enh_desc_init_tx_desc(struct dma_desc *p, unsigned int ring_size)
+{
+	int i;
+
+	for (i = 0; i < ring_size; i++) {
+		p->des01.etx.own = 0;
+		p->des01.etx.second_address_chained = 1;
+		p++;
+	}
+}
+
+inline void enh_desc_release_tx_desc(struct dma_desc *p)
+{
+	memset(p, 0, offsetof(struct dma_desc, des2));
+	p->des01.etx.second_address_chained = 1;
+}
+
+inline void enh_desc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len,
+				     int csum_flag)
+{
+	p->des01.etx.first_segment = is_fs;
+	p->des01.etx.buffer1_size = len;
+
+	if (likely(csum_flag))
+		p->des01.etx.checksum_insertion = cic_full;
+}
+
+inline void ndesc_init_rx_desc(struct dma_desc *p, unsigned int ring_size,
+			       int disable_rx_ic)
+{
+	int i;
+	for (i = 0; i < ring_size; i++) {
+		p->des01.rx.own = 1;
+		p->des01.rx.buffer1_size = BUF_SIZE_2KiB - 1;
+		p->des01.rx.buffer2_size = BUF_SIZE_2KiB - 1;
+		if (i == (ring_size - 1))
+			p->des01.rx.end_ring = 1;
+		if (disable_rx_ic)
+			p->des01.rx.disable_ic = 1;
+		p++;
+	}
+}
+
+inline void ndesc_init_tx_desc(struct dma_desc *p, unsigned int ring_size)
+{
+	int i;
+	for (i = 0; i < ring_size; i++) {
+		p->des01.tx.own = 0;
+		if (i == (ring_size - 1))
+			p->des01.tx.end_ring = 1;
+		p++;
+	}
+}
+
+inline void ndesc_release_tx_desc(struct dma_desc *p)
+{
+	memset(p, 0, offsetof(struct dma_desc, des2));
+	p->des01.tx.second_address_chained = 1;
+}
+
+inline void ndesc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len,
+				  int csum_flag)
+{
+	p->des01.tx.first_segment = is_fs;
+	p->des01.tx.buffer1_size = len;
+}
+#endif
+
+struct stmmac_ring_mode_ops {
+	unsigned int (*is_jumbo_frame) (struct stmmac_priv *priv,
+					struct sk_buff *skb,
+					int csum, struct dma_desc *desc);
+	void (*refill_desc3) (int bfsize, struct dma_desc *p);
+	void (*init_desc3) (int des3_as_data_buf, struct dma_desc *p);
+	void (*init_dma_chain) (struct dma_desc *des, dma_addr_t phy_addr,
+				unsigned int size);
+	void (*clean_desc3) (struct dma_desc *p);
+	int (*set_bfsize) (int mtu, int bufsize);
+};
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index c0ee6b6..ba7af2c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2,7 +2,7 @@
   This is the driver for the ST MAC 10/100/1000 on-chip Ethernet controllers.
   ST Ethernet IPs are built around a Synopsys IP Core.
 
-  Copyright (C) 2007-2009  STMicroelectronics Ltd
+	Copyright(C) 2007-2011 STMicroelectronics Ltd
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
@@ -47,11 +47,12 @@
 #include <linux/dma-mapping.h>
 #include <linux/slab.h>
 #include <linux/prefetch.h>
-#include "stmmac.h"
 #ifdef CONFIG_STMMAC_DEBUG_FS
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
 #endif
+#include "stmmac.h"
+#include "ring_mode.h"
 
 #define STMMAC_RESOURCE_NAME	"stmmaceth"
 
@@ -131,7 +132,6 @@ module_param(tmrate, int, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(tmrate, "External timer freq. (default: 256Hz)");
 #endif
 
-#define DMA_BUFFER_SIZE	BUF_SIZE_2KiB
 static int buf_sz = DMA_BUFFER_SIZE;
 module_param(buf_sz, int, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(buf_sz, "DMA buffer size");
@@ -142,6 +142,16 @@ static const u32 default_msg_level = (NETIF_MSG_DRV | NETIF_MSG_PROBE |
 
 static irqreturn_t stmmac_interrupt(int irq, void *dev_id);
 
+/* Functions used for chained/ring modes */
+static const struct stmmac_ring_mode_ops ring_mode_ops = {
+	.is_jumbo_frame = stmmac_is_jumbo_frame,
+	.refill_desc3 = stmmac_refill_desc3,
+	.init_desc3 = stmmac_init_desc3,
+	.init_dma_chain = stmmac_init_dma_chain,
+	.clean_desc3 = stmmac_clean_desc3,
+	.set_bfsize = stmmac_set_bfsize,
+};
+
 /**
  * stmmac_verify_args - verify the driver parameters.
  * Description: it verifies if some wrong parameter is passed to the driver.
@@ -385,7 +395,8 @@ static void display_ring(struct dma_desc *p, int size)
  * init_dma_desc_rings - init the RX/TX descriptor rings
  * @dev: net device structure
  * Description:  this function initializes the DMA RX/TX descriptors
- * and allocates the socket buffers.
+ * and allocates the socket buffers. It suppors the chained and ring
+ * modes.
  */
 static void init_dma_desc_rings(struct net_device *dev)
 {
@@ -394,31 +405,22 @@ static void init_dma_desc_rings(struct net_device *dev)
 	struct sk_buff *skb;
 	unsigned int txsize = priv->dma_tx_size;
 	unsigned int rxsize = priv->dma_rx_size;
-	unsigned int bfsize = priv->dma_buf_sz;
-	int buff2_needed = 0, dis_ic = 0;
+	unsigned int bfsize;
+	int dis_ic = 0;
+	int des3_as_data_buf = 0;
 
-	/* Set the Buffer size according to the MTU;
-	 * indeed, in case of jumbo we need to bump-up the buffer sizes.
-	 */
-	if (unlikely(dev->mtu >= BUF_SIZE_8KiB))
-		bfsize = BUF_SIZE_16KiB;
-	else if (unlikely(dev->mtu >= BUF_SIZE_4KiB))
-		bfsize = BUF_SIZE_8KiB;
-	else if (unlikely(dev->mtu >= BUF_SIZE_2KiB))
-		bfsize = BUF_SIZE_4KiB;
-	else if (unlikely(dev->mtu >= DMA_BUFFER_SIZE))
-		bfsize = BUF_SIZE_2KiB;
-	else
-		bfsize = DMA_BUFFER_SIZE;
+	/* Set the max buffer size according to the DESC mode used
+	 * and the MTU. */
+	bfsize = priv->hw->ring->set_bfsize(dev->mtu, priv->dma_buf_sz);
+
+	if (bfsize == BUF_SIZE_16KiB)
+		des3_as_data_buf = 1;
 
 #ifdef CONFIG_STMMAC_TIMER
 	/* Disable interrupts on completion for the reception if timer is on */
 	if (likely(priv->tm->enable))
 		dis_ic = 1;
 #endif
-	/* If the MTU exceeds 8k so use the second buffer in the chain */
-	if (bfsize >= BUF_SIZE_8KiB)
-		buff2_needed = 1;
 
 	DBG(probe, INFO, "stmmac: txsize %d, rxsize %d, bfsize %d\n",
 	    txsize, rxsize, bfsize);
@@ -446,7 +448,7 @@ static void init_dma_desc_rings(struct net_device *dev)
 		return;
 	}
 
-	DBG(probe, INFO, "stmmac (%s) DMA desc rings: virt addr (Rx %p, "
+	DBG(probe, INFO, "stmmac (%s) DMA desc: virt addr (Rx %p, "
 	    "Tx %p)\n\tDMA phy addr (Rx 0x%08x, Tx 0x%08x)\n",
 	    dev->name, priv->dma_rx, priv->dma_tx,
 	    (unsigned int)priv->dma_rx_phy, (unsigned int)priv->dma_tx_phy);
@@ -468,8 +470,9 @@ static void init_dma_desc_rings(struct net_device *dev)
 						bfsize, DMA_FROM_DEVICE);
 
 		p->des2 = priv->rx_skbuff_dma[i];
-		if (unlikely(buff2_needed))
-			p->des3 = p->des2 + BUF_SIZE_8KiB;
+
+		priv->hw->ring->init_desc3(des3_as_data_buf, p);
+
 		DBG(probe, INFO, "[%p]\t[%p]\t[%x]\n", priv->rx_skbuff[i],
 			priv->rx_skbuff[i]->data, priv->rx_skbuff_dma[i]);
 	}
@@ -483,6 +486,12 @@ static void init_dma_desc_rings(struct net_device *dev)
 		priv->tx_skbuff[i] = NULL;
 		priv->dma_tx[i].des2 = 0;
 	}
+
+	/* In case of Chained mode this sets the des3 to the next
+	 * element in the chain */
+	priv->hw->ring->init_dma_chain(priv->dma_rx, priv->dma_rx_phy, rxsize);
+	priv->hw->ring->init_dma_chain(priv->dma_tx, priv->dma_tx_phy, txsize);
+
 	priv->dirty_tx = 0;
 	priv->cur_tx = 0;
 
@@ -611,8 +620,7 @@ static void stmmac_tx(struct stmmac_priv *priv)
 			dma_unmap_single(priv->device, p->des2,
 					 priv->hw->desc->get_tx_len(p),
 					 DMA_TO_DEVICE);
-		if (unlikely(p->des3))
-			p->des3 = 0;
+		priv->hw->ring->clean_desc3(p);
 
 		if (likely(skb != NULL)) {
 			/*
@@ -1005,47 +1013,6 @@ static int stmmac_release(struct net_device *dev)
 	return 0;
 }
 
-static unsigned int stmmac_handle_jumbo_frames(struct sk_buff *skb,
-					       struct net_device *dev,
-					       int csum_insertion)
-{
-	struct stmmac_priv *priv = netdev_priv(dev);
-	unsigned int nopaged_len = skb_headlen(skb);
-	unsigned int txsize = priv->dma_tx_size;
-	unsigned int entry = priv->cur_tx % txsize;
-	struct dma_desc *desc = priv->dma_tx + entry;
-
-	if (nopaged_len > BUF_SIZE_8KiB) {
-
-		int buf2_size = nopaged_len - BUF_SIZE_8KiB;
-
-		desc->des2 = dma_map_single(priv->device, skb->data,
-					    BUF_SIZE_8KiB, DMA_TO_DEVICE);
-		desc->des3 = desc->des2 + BUF_SIZE_4KiB;
-		priv->hw->desc->prepare_tx_desc(desc, 1, BUF_SIZE_8KiB,
-						csum_insertion);
-
-		entry = (++priv->cur_tx) % txsize;
-		desc = priv->dma_tx + entry;
-
-		desc->des2 = dma_map_single(priv->device,
-					skb->data + BUF_SIZE_8KiB,
-					buf2_size, DMA_TO_DEVICE);
-		desc->des3 = desc->des2 + BUF_SIZE_4KiB;
-		priv->hw->desc->prepare_tx_desc(desc, 0, buf2_size,
-						csum_insertion);
-		priv->hw->desc->set_tx_owner(desc);
-		priv->tx_skbuff[entry] = NULL;
-	} else {
-		desc->des2 = dma_map_single(priv->device, skb->data,
-					nopaged_len, DMA_TO_DEVICE);
-		desc->des3 = desc->des2 + BUF_SIZE_4KiB;
-		priv->hw->desc->prepare_tx_desc(desc, 1, nopaged_len,
-						csum_insertion);
-	}
-	return entry;
-}
-
 /**
  *  stmmac_xmit:
  *  @skb : the socket buffer
@@ -1094,10 +1061,10 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 		       skb->len, skb_headlen(skb), nfrags, skb->ip_summed);
 #endif
 	priv->tx_skbuff[entry] = skb;
-	if (unlikely(skb->len >= BUF_SIZE_4KiB)) {
-		entry = stmmac_handle_jumbo_frames(skb, dev, csum_insertion);
-		desc = priv->dma_tx + entry;
-	} else {
+
+	/* Manage Jumbo frames depending on the descriptor mode
+	 * actually used (chained or ring). */
+	if (!priv->hw->ring->is_jumbo_frame(priv, skb, csum_insertion, desc)) {
 		unsigned int nopaged_len = skb_headlen(skb);
 		desc->des2 = dma_map_single(priv->device, skb->data,
 					nopaged_len, DMA_TO_DEVICE);
@@ -1187,11 +1154,10 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv)
 					   DMA_FROM_DEVICE);
 
 			(p + entry)->des2 = priv->rx_skbuff_dma[entry];
-			if (unlikely(priv->plat->has_gmac)) {
-				if (bfsize >= BUF_SIZE_8KiB)
-					(p + entry)->des3 =
-					    (p + entry)->des2 + BUF_SIZE_8KiB;
-			}
+
+			if (unlikely(priv->plat->has_gmac))
+				priv->hw->ring->refill_desc3(bfsize, p + entry);
+
 			RX_DBG(KERN_INFO "\trefill entry #%d\n", entry);
 		}
 		wmb();
@@ -1767,6 +1733,7 @@ static int stmmac_mac_device_setup(struct net_device *dev)
 		device->desc = &ndesc_ops;
 
 	priv->hw = device;
+	priv->hw->ring = &ring_mode_ops;
 
 	if (device_can_wakeup(priv->device)) {
 		priv->wolopts = WAKE_MAGIC; /* Magic Frame as default */
-- 
1.7.4.4

^ permalink raw reply related

* [net-next 0/5] stmmac: update to Oct 2011 version (V2)
From: Giuseppe CAVALLARO @ 2011-10-12 13:38 UTC (permalink / raw)
  To: netdev; +Cc: davem, Giuseppe Cavallaro

This patches update the driver adding the chained
descriptor mode and some new useful fixes.
Chained / Ring modes have been reworked after D. Miller
advice and removing the ifdef selection within the C
code.

Giuseppe Cavallaro (4):
  stmmac: add CHAINED descriptor mode support
  stmmac: allow mtu bigger than 1500 in case of normal desc.
  stmmac: protect tx process with lock
  stmmac: update the driver version and doc

Srinivas Kandagatla (1):
  stmmac: Stop advertising 1000Base capabilties for non GMII iface
    (v2).

 Documentation/networking/stmmac.txt               |   11 +-
 drivers/net/ethernet/stmicro/stmmac/Kconfig       |   18 +
 drivers/net/ethernet/stmicro/stmmac/common.h      |   19 +
 drivers/net/ethernet/stmicro/stmmac/enh_desc.c    |   51 ---
 drivers/net/ethernet/stmicro/stmmac/norm_desc.c   |   42 --
 drivers/net/ethernet/stmicro/stmmac/ring_mode.h   |  450 +++++++++++++++++++++
 drivers/net/ethernet/stmicro/stmmac/stmmac.h      |    3 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |  148 +++----
 8 files changed, 564 insertions(+), 178 deletions(-)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/ring_mode.h

-- 
1.7.4.4

^ permalink raw reply

* Re: bridge: HSR support
From: David Lamparter @ 2011-10-12 13:28 UTC (permalink / raw)
  To: Arvid Brodin; +Cc: netdev, Stephen Hemminger, Lennert Buytenhek
In-Reply-To: <4E94D67A.9060207@enea.com>

On Wed, Oct 12, 2011 at 01:51:22AM +0200, Arvid Brodin wrote:
> Stephen Hemminger wrote:
> >> I want to add support for HSR ("High-availability Seamless Redundancy",
> >> IEC-62439-3) to the bridge code. With HSR, all connected units have two network
> >> ports and are connected in a ring. All new Ethernet packets are sent on both
> >> ports (or passed through if the current unit is not the originating unit).


> >> The same packet is never passed twice.

How does the bridge decide whether a packet is arriving the second time?
Is the ring pre-resolved to stop things or does this happen per-packet?


-David

^ permalink raw reply

* Re: [PATCH v2] netconsole: enable netconsole can make net_device refcnt incorrent
From: Flavio Leitner @ 2011-10-12 13:23 UTC (permalink / raw)
  To: Gao feng; +Cc: netdev, davem, eric.dumazet
In-Reply-To: <1318385291-15483-1-git-send-email-gaofeng@cn.fujitsu.com>

On Wed, 12 Oct 2011 10:08:11 +0800
Gao feng <gaofeng@cn.fujitsu.com> wrote:

> There is no check if netconsole is enabled current.
> so when exec echo 1 > enabled;
> the reference of net_device will increment always.
> 
> Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
> ---
>  drivers/net/netconsole.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)

Looks better, thanks!
Acked-by: Flavio Leitner <fbl@redhat.com>

fbl

^ permalink raw reply

* [PATCH] smsc911x: Add support for SMSC LAN89218
From: Phil Edworthy @ 2011-10-12 12:29 UTC (permalink / raw)
  To: netdev; +Cc: Steve Glendinning, Phil Edworthy

LAN89218 is register compatible with LAN911x.

Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
---
 drivers/net/smsc911x.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/net/smsc911x.c b/drivers/net/smsc911x.c
index b9016a3..c90ddb6 100644
--- a/drivers/net/smsc911x.c
+++ b/drivers/net/smsc911x.c
@@ -26,6 +26,7 @@
  *   LAN9215, LAN9216, LAN9217, LAN9218
  *   LAN9210, LAN9211
  *   LAN9220, LAN9221
+ *   LAN89218
  *
  */
 
@@ -1983,6 +1984,7 @@ static int __devinit smsc911x_init(struct net_device *dev)
 	case 0x01170000:
 	case 0x01160000:
 	case 0x01150000:
+	case 0x218A0000:
 		/* LAN911[5678] family */
 		pdata->generation = pdata->idrev & 0x0000FFFF;
 		break;
-- 
1.7.0.4

^ permalink raw reply related

* Re: about phonet pipe controller
From: Rémi Denis-Courmont @ 2011-10-12 11:08 UTC (permalink / raw)
  To: netdev@vger.kernel.org
In-Reply-To: <81C3A93C17462B4BBD7E272753C105791EAACAEA43@EXDCVYMBSTM005.EQ1STM.local>

Le Mercredi 12 Octobre 2011 12:58:08 ext Hemant-vilas RAMDASI a écrit :
> Yes, I agree that build-time option is not required..But what are those
> corner cases?

This is old stuff. I don't remember the details, nor did I investigate the 
whole thing. But the code seemed to assume that userspace are fully trusted, 
the remote Phonet nodes also. That does not work.

Protocol-level race conditions, API level race conditions, crashed remote 
peers, crashing user space processes, invalid API use, etc. All that needs to 
be dealt with safely. This is kernel code!

-- 
Rémi Denis-Courmont
http://www.remlab.net/

^ permalink raw reply

* RE: about phonet pipe controller
From: Hemant-vilas RAMDASI @ 2011-10-12 10:58 UTC (permalink / raw)
  To: Rémi Denis-Courmont; +Cc: Srinidhi KASAGAR, netdev@vger.kernel.org
In-Reply-To: <3025840.a3oI7lSnik@leon.remlab.net>

Hi,

> -----Original Message-----
> From: Rémi Denis-Courmont [mailto:remi.denis-courmont@nokia.com]
> Sent: Wednesday, October 12, 2011 1:28 PM
> To: Hemant-vilas RAMDASI
> Cc: Srinidhi KASAGAR; netdev@vger.kernel.org
> Subject: Re: about phonet pipe controller
> 
> Le Mercredi 12 Octobre 2011 09:25:01 ext Hemant-vilas RAMDASI a écrit :
> > You have mentioned in the
> > "a015f6f: Phonet: kill the ST-Ericsson pipe controller Kconfig",
> > that "Support for manually enabling the pipe flow is removed as it
> > did not work properly, does not fit well with the socket API, and
> > I am not aware of any use at the moment.."
> >
> > On STE U8500 modem, you must first create pipe in disabled state,
> then do
> > local link configuration (does't work when pipe is enabled) & then
> enable
> > pipe.
> 
> The Kconfig option broke support for existing hardware (Nokia N900 as a
> USB
> gadget) and userspace (namely the oFono ISI driver). We cannot expect
> distributions to provide two different kernel builds for different
> flavors of ISI
> modems.
> 
> > Because of this connect() cannot be used anymore and it needs to be
> modified
> > to reintroduce pipe-controller functionality again.
> 
> As far as I can tell, that code NEVER worked properly. Not only the use
> of a
> build-time option is inappropriate, but the code did not deal with a
> number of
> new corner cases that it introduced.
> 
Yes, I agree that build-time option is not required..But what are those corner cases?

> > Do you have any suggestions?
> 
> I'm sorry but I don't really get where you're trying to get. The code
> had more
> bugs than I could fix by myself, especially when I don't have the
> hardware and
> the specification.
>
As far as I know, connect() API was not there initially. It was implemented as part 
of pipe-controller after your feedback.
We would like to modify connect to create pipe in disabled mode and enable it in 
setsockopt call. 
Basically the problem with current implementation is that there is no way today for 
anyone to disable/enable pipe.

Regards,
Hemant
 

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox