Netdev List
 help / color / mirror / Atom feed
* RE: Bug#614622: linux-image-2.6.37-1-686: atl2 NIC claims NO CARRIER after suspend/resume; rmmod+insmod fixes the problem
From: Xiong Huang @ 2011-02-23  1:22 UTC (permalink / raw)
  To: Ben Hutchings, Jay Cliburn, Chris Snook, Jie Yang
  Cc: 614622@bugs.debian.org, netdev, Daniel Kahn Gillmor
In-Reply-To: <1298423651.2211.496.camel@localhost>

after the onboard NIC claims NO Carrier after resuming from suspend-to-RAM, how about it if unplug then re-plug the cable ?


best regards
Xiong
-----Original Message-----
From: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org] On Behalf Of Ben Hutchings
Sent: Wednesday, February 23, 2011 9:14
To: Jay Cliburn; Chris Snook; Jie Yang
Cc: 614622@bugs.debian.org; netdev; Daniel Kahn Gillmor
Subject: Re: Bug#614622: linux-image-2.6.37-1-686: atl2 NIC claims NO CARRIER after suspend/resume; rmmod+insmod fixes the problem

This bug report was made against Debian's package of Linux 2.6.37:

On Tue, 2011-02-22 at 13:08 -0500, Daniel Kahn Gillmor wrote:
> Package: linux-2.6
> Version: 2.6.37-1
> Severity: normal
> 
> I recently switched from 2.6.37-trunk-686 to 2.6.37-1-686.
> 
> after the switch, i find that sometimes my atl2.ko-driven onboard NIC 
> persistently claims NO CARRIER after resuming from suspend-to-RAM, 
> even when plugged into a legitimate ethernet port.  This is not 
> entirely reliable, but maybe 50% of the time.
> 
> if i remove and re-load atl2.ko, the interface can properly detect the 
> ethernet.
> 
> i'm happy to help debug this further if there is any information you 
> want me to gather on this hardware.  Please let me know.

I don't see any changes to this driver between 2.6.37-rc4 (the first version we built as '2.6.37-trunk-686') and 2.6.37, so I think Daniel just had good luck with the earlier versions.

> ** Kernel log:
[...]
> [67880.276036] PM: suspend of devices complete after 147.583 msecs 
> [67880.292274] PM: late suspend of devices complete after 16.227 msecs 
> [67880.292426] ACPI: Preparing to enter system sleep state S3 
> [67880.316648] PM: Saving platform NVS memory [67880.357927] Disabling 
> non-boot CPUs ...
> [67880.357927] Back to C!
> [67880.357927] PM: Restoring platform NVS memory [67880.357927] Force 
> enabled HPET at resume [67880.357927] ACPI: Waking up from system 
> sleep state S3 [67880.400865] HDA Intel 0000:00:1b.0: restoring config 
> space at offset 0x1 (was 0x100006, writing 0x100002) [67880.400904] 
> pci 0000:00:1c.0: restoring config space at offset 0x9 (was 0x1fff1, 
> writing 0x3fc13fb1) [67880.400913] pci 0000:00:1c.0: restoring config 
> space at offset 0x8 (was 0xfff0, writing 0x3fa03f90) [67880.400923] 
> pci 0000:00:1c.0: restoring config space at offset 0x7 (was 0xf0, 
> writing 0x1010) [67880.400937] pci 0000:00:1c.0: restoring config 
> space at offset 0x1 (was 0x100104, writing 0x100107) [67880.400976] 
> pci 0000:00:1c.1: restoring config space at offset 0x9 (was 0x1fff1, 
> writing 0x3fe13fd1) [67880.400987] pci 0000:00:1c.1: restoring config 
> space at offset 0x7 (was 0xf0, writing 0x2020) [67880.401001] pci 
> 0000:00:1c.1: restoring config space at offset 0x1 (was 0x100106, 
> writing 0x100107) [67880.401042] pci 0000:00:1c.2: restoring config 
> space at offset 0x7 (was 0xf0, writing 0x3030) [67880.401056] pci 
> 0000:00:1c.2: restoring config space at offset 0x1 (was 0x100106, 
> writing 0x100107) [67880.401099] uhci_hcd 0000:00:1d.0: restoring 
> config space at offset 0x1 (was 0x2800005, writing 0x2800001) 
> [67880.401132] uhci_hcd 0000:00:1d.1: restoring config space at offset 
> 0x1 (was 0x2800005, writing 0x2800001) [67880.401165] uhci_hcd 
> 0000:00:1d.2: restoring config space at offset 0x1 (was 0x2800005, 
> writing 0x2800001) [67880.401197] uhci_hcd 0000:00:1d.3: restoring 
> config space at offset 0x1 (was 0x2800005, writing 0x2800001) 
> [67880.401239] ehci_hcd 0000:00:1d.7: restoring config space at offset 
> 0x1 (was 0x2900006, writing 0x2900002) [67880.401265] pci 
> 0000:00:1e.0: restoring config space at offset 0xf (was 0x60000, 
> writing 0x600ff) [67880.401538] PM: early resume of devices complete 
> after 0.795 msecs [67880.406036] HDA Intel 0000:00:1b.0: PCI INT A -> 
> GSI 16 (level, low) -> IRQ 16 [67880.406048] HDA Intel 0000:00:1b.0: 
> setting latency timer to 64 [67880.406093] HDA Intel 0000:00:1b.0: irq 
> 40 for MSI/MSI-X [67880.406136] pci 0000:00:1c.0: PCI INT A -> GSI 16 
> (level, low) -> IRQ 16 [67880.406143] pci 0000:00:1c.0: setting 
> latency timer to 64 [67880.406156] pci 0000:00:1c.1: PCI INT B -> GSI 
> 17 (level, low) -> IRQ 17 [67880.406163] pci 0000:00:1c.1: setting 
> latency timer to 64 [67880.406176] pci 0000:00:1c.2: PCI INT C -> GSI 
> 18 (level, low) -> IRQ 18 [67880.406183] pci 0000:00:1c.2: setting 
> latency timer to 64 [67880.406198] uhci_hcd 0000:00:1d.0: PCI INT A -> 
> GSI 23 (level, low) -> IRQ 23 [67880.406208] uhci_hcd 0000:00:1d.0: 
> setting latency timer to 64 [67880.406234] usb usb2: root hub lost 
> power or was reset [67880.406253] uhci_hcd 0000:00:1d.1: PCI INT B -> 
> GSI 19 (level, low) -> IRQ 19 [67880.406262] uhci_hcd 0000:00:1d.1: 
> setting latency timer to 64 [67880.406287] usb usb3: root hub lost 
> power or was reset [67880.406303] uhci_hcd 0000:00:1d.2: PCI INT C -> 
> GSI 18 (level, low) -> IRQ 18 [67880.406313] uhci_hcd 0000:00:1d.2: 
> setting latency timer to 64 [67880.406337] usb usb4: root hub lost 
> power or was reset [67880.406354] uhci_hcd 0000:00:1d.3: PCI INT D -> 
> GSI 16 (level, low) -> IRQ 16 [67880.406363] uhci_hcd 0000:00:1d.3: 
> setting latency timer to 64 [67880.406387] usb usb5: root hub lost 
> power or was reset [67880.406405] ehci_hcd 0000:00:1d.7: PCI INT A -> 
> GSI 23 (level, low) -> IRQ 23 [67880.406415] ehci_hcd 0000:00:1d.7: 
> setting latency timer to 64 [67880.406486] pci 0000:00:1e.0: setting 
> latency timer to 64 [67880.406505] ata_piix 0000:00:1f.2: PCI INT B -> 
> GSI 19 (level, low) -> IRQ 19 [67880.406513] ata_piix 0000:00:1f.2: 
> setting latency timer to 64 [67880.406543] atl2 0000:03:00.0: PCI INT 
> A -> GSI 17 (level, low) -> IRQ 17 [67880.406551] atl2 0000:03:00.0: 
> setting latency timer to 64 [67880.411177] i915 0000:00:02.0: PCI INT 
> A -> GSI 16 (level, low) -> IRQ 16 [67880.411186] i915 0000:00:02.0: setting latency timer to 64 [67880.413110] sd 0:0:0:0: [sda] Starting disk [67880.652031] usb 1-5: reset high speed USB device using ehci_hcd and address 2 [67880.896031] usb 1-8: reset high speed USB device using ehci_hcd and address 3 [67882.532200] ata1.00: ACPI cmd ef/03:45:00:00:00:a0 (SET FEATURES) filtered out [67882.532209] ata1.00: ACPI cmd ef/03:0c:00:00:00:a0 (SET FEATURES) filtered out [67882.548191] ata1.00: configured for UDMA/133 [67882.548697] PM: resume of devices complete after 2147.034 msecs [67882.549278] PM: Finishing wakeup.
> [67882.549283] Restarting tasks ... done.
> [67882.549761] video LNXVIDEO:00: Restoring backlight state 
> [67882.980083] usb 3-2: new low speed USB device using uhci_hcd and 
> address 5 [67883.150414] atl2 0000:03:00.0: irq 41 for MSI/MSI-X 
> [67883.151364] ADDRCONF(NETDEV_UP): eth0: link is not ready 
> [67883.159163] usb 3-2: New USB device found, idVendor=0973, 
> idProduct=0001 [67883.159174] usb 3-2: New USB device strings: Mfr=1, 
> Product=2, SerialNumber=0 [67883.159181] usb 3-2: Product: 
> SchlumbergerSema Cryptoflex e-gate [67883.159187] usb 3-2: 
> Manufacturer: SchlumbergerSema

I assume this is where Daniel reloads the driver:

> [67977.344181] atl2 0000:03:00.0: PCI INT A disabled [67977.379792] 
> Atheros(R) L2 Ethernet Driver - version 2.2.3 [67977.379802] Copyright 
> (c) 2007 Atheros Corporation.
> [67977.379870] atl2 0000:03:00.0: PCI INT A -> GSI 17 (level, low) -> 
> IRQ 17 [67977.379892] atl2 0000:03:00.0: setting latency timer to 64 
> [67993.948723] atl2 0000:03:00.0: irq 41 for MSI/MSI-X [67993.949268] 
> ADDRCONF(NETDEV_UP): eth0: link is not ready [67994.154327] atl2: eth0 
> NIC Link is Up<100 Mbps Full Duplex> [67994.154739] 
> ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

[...]
> ** PCI devices:
[...]
> 03:00.0 Ethernet controller [0200]: Atheros Communications L2 Fast Ethernet [1969:2048] (rev a0)
>         Subsystem: ASUSTeK Computer Inc. Device [1043:8233]
>         Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
>         Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
>         Latency: 0, Cache Line Size: 16 bytes
>         Interrupt: pin A routed to IRQ 41
>         Region 0: Memory at fbfc0000 (64-bit, non-prefetchable) [size=256K]
>         Expansion ROM at fbfa0000 [disabled] [size=128K]
>         Capabilities: <access denied>
>         Kernel driver in use: atl2
[...]

Ben.

--
Ben Hutchings
Once a job is fouled up, anything done to improve it makes it worse.

^ permalink raw reply

* [PATCH] e1000: power off PHY after reset when interface is down
From: prasanna.panchamukhi @ 2011-02-23  1:25 UTC (permalink / raw)
  To: bruce.w.allan, jeffrey.t.kirsher, jeffrey.e.pieper
  Cc: e1000-devel, netdev, prasanna.panchamukhi

From: Prasanna S. Panchamukhi <prasanna.panchamukhi@riverbed.com>

Some Phys supported by the e1000 driver do not remain powered off across
a reset of the device when the interface is down, e.g. on 82546.
This patch powers down (only when WoL is disabled) the PHY after reset if
the interface is down and ethtool diagnostics are not currently running.

Similar problem was see on 82571 controller and was fixed in e1000e driver
by Bruce Allan.
Please refer commit 31dbe5b4ac6fca72dec946e4d0fa7f0913f1d9b1 for details.

Signed-off-by: Prasanna S. Panchamukhi <prasanna.panchamukhi@riverbed.com>
---
 drivers/net/e1000/e1000_ethtool.c |   27 +++++++++++++++++++--------
 drivers/net/e1000/e1000_main.c    |    7 +++++++
 2 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index f4d0922..d3f18f5 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -1554,6 +1554,15 @@ static void e1000_diag_test(struct net_device *netdev,
 	bool if_running = netif_running(netdev);
 
 	set_bit(__E1000_TESTING, &adapter->flags);
+
+	if (!if_running) {
+		e1000_power_up_phy(adapter);
+
+		adapter->hw.wait_autoneg_complete = 1;
+		e1000_reset(adapter);
+		adapter->hw.wait_autoneg_complete = 0;
+	}
+
 	if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
 		/* Offline tests */
 
@@ -1572,8 +1581,6 @@ static void e1000_diag_test(struct net_device *netdev,
 		if (if_running)
 			/* indicate we're in test mode */
 			dev_close(netdev);
-		else
-			e1000_reset(adapter);
 
 		if (e1000_reg_test(adapter, &data[0]))
 			eth_test->flags |= ETH_TEST_FL_FAILED;
@@ -1587,8 +1594,6 @@ static void e1000_diag_test(struct net_device *netdev,
 			eth_test->flags |= ETH_TEST_FL_FAILED;
 
 		e1000_reset(adapter);
-		/* make sure the phy is powered up */
-		e1000_power_up_phy(adapter);
 		if (e1000_loopback_test(adapter, &data[3]))
 			eth_test->flags |= ETH_TEST_FL_FAILED;
 
@@ -1602,19 +1607,25 @@ static void e1000_diag_test(struct net_device *netdev,
 		if (if_running)
 			dev_open(netdev);
 	} else {
-		e_info(hw, "online testing starting\n");
 		/* Online tests */
-		if (e1000_link_test(adapter, &data[4]))
-			eth_test->flags |= ETH_TEST_FL_FAILED;
 
-		/* Online tests aren't run; pass by default */
+		e_info(hw, "online testing starting\n");
+
+		/* register, eeprom, intr and loopback tests not run online */
 		data[0] = 0;
 		data[1] = 0;
 		data[2] = 0;
 		data[3] = 0;
 
+		if (e1000_link_test(adapter, &data[4]))
+			eth_test->flags |= ETH_TEST_FL_FAILED;
+
 		clear_bit(__E1000_TESTING, &adapter->flags);
 	}
+
+	if (!if_running)
+		e1000_reset(adapter);
+
 	msleep_interruptible(4 * 1000);
 }
 
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index bfab140..beec573 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -704,6 +704,13 @@ void e1000_reset(struct e1000_adapter *adapter)
 	ew32(VET, ETHERNET_IEEE_VLAN_TYPE);
 
 	e1000_reset_adaptive(hw);
+
+	if (!netif_running(adapter->netdev) &&
+	    !test_bit(__E1000_TESTING, &adapter->flags)) {
+		e1000_power_down_phy(adapter);
+		return;
+	}
+
 	e1000_phy_get_info(hw, &adapter->phy_info);
 
 	e1000_release_manageability(adapter);
-- 
1.7.0.4


------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel&#174; Ethernet, visit http://communities.intel.com/community/wired

^ permalink raw reply related

* Re: Bug#614622: linux-image-2.6.37-1-686: atl2 NIC claims NO CARRIER after suspend/resume; rmmod+insmod fixes the problem
From: Ben Hutchings @ 2011-02-23  1:14 UTC (permalink / raw)
  To: Jay Cliburn, Chris Snook, Jie Yang; +Cc: 614622, netdev, Daniel Kahn Gillmor
In-Reply-To: <20110222180821.5217.2375.reportbug@localhost.localdomain>

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

This bug report was made against Debian's package of Linux 2.6.37:

On Tue, 2011-02-22 at 13:08 -0500, Daniel Kahn Gillmor wrote:
> Package: linux-2.6
> Version: 2.6.37-1
> Severity: normal
> 
> I recently switched from 2.6.37-trunk-686 to 2.6.37-1-686.
> 
> after the switch, i find that sometimes my atl2.ko-driven onboard NIC
> persistently claims NO CARRIER after resuming from suspend-to-RAM,
> even when plugged into a legitimate ethernet port.  This is not
> entirely reliable, but maybe 50% of the time.
> 
> if i remove and re-load atl2.ko, the interface can properly detect the
> ethernet.
> 
> i'm happy to help debug this further if there is any information you
> want me to gather on this hardware.  Please let me know.

I don't see any changes to this driver between 2.6.37-rc4 (the first
version we built as '2.6.37-trunk-686') and 2.6.37, so I think Daniel
just had good luck with the earlier versions.

> ** Kernel log:
[...]
> [67880.276036] PM: suspend of devices complete after 147.583 msecs
> [67880.292274] PM: late suspend of devices complete after 16.227 msecs
> [67880.292426] ACPI: Preparing to enter system sleep state S3
> [67880.316648] PM: Saving platform NVS memory
> [67880.357927] Disabling non-boot CPUs ...
> [67880.357927] Back to C!
> [67880.357927] PM: Restoring platform NVS memory
> [67880.357927] Force enabled HPET at resume
> [67880.357927] ACPI: Waking up from system sleep state S3
> [67880.400865] HDA Intel 0000:00:1b.0: restoring config space at offset 0x1 (was 0x100006, writing 0x100002)
> [67880.400904] pci 0000:00:1c.0: restoring config space at offset 0x9 (was 0x1fff1, writing 0x3fc13fb1)
> [67880.400913] pci 0000:00:1c.0: restoring config space at offset 0x8 (was 0xfff0, writing 0x3fa03f90)
> [67880.400923] pci 0000:00:1c.0: restoring config space at offset 0x7 (was 0xf0, writing 0x1010)
> [67880.400937] pci 0000:00:1c.0: restoring config space at offset 0x1 (was 0x100104, writing 0x100107)
> [67880.400976] pci 0000:00:1c.1: restoring config space at offset 0x9 (was 0x1fff1, writing 0x3fe13fd1)
> [67880.400987] pci 0000:00:1c.1: restoring config space at offset 0x7 (was 0xf0, writing 0x2020)
> [67880.401001] pci 0000:00:1c.1: restoring config space at offset 0x1 (was 0x100106, writing 0x100107)
> [67880.401042] pci 0000:00:1c.2: restoring config space at offset 0x7 (was 0xf0, writing 0x3030)
> [67880.401056] pci 0000:00:1c.2: restoring config space at offset 0x1 (was 0x100106, writing 0x100107)
> [67880.401099] uhci_hcd 0000:00:1d.0: restoring config space at offset 0x1 (was 0x2800005, writing 0x2800001)
> [67880.401132] uhci_hcd 0000:00:1d.1: restoring config space at offset 0x1 (was 0x2800005, writing 0x2800001)
> [67880.401165] uhci_hcd 0000:00:1d.2: restoring config space at offset 0x1 (was 0x2800005, writing 0x2800001)
> [67880.401197] uhci_hcd 0000:00:1d.3: restoring config space at offset 0x1 (was 0x2800005, writing 0x2800001)
> [67880.401239] ehci_hcd 0000:00:1d.7: restoring config space at offset 0x1 (was 0x2900006, writing 0x2900002)
> [67880.401265] pci 0000:00:1e.0: restoring config space at offset 0xf (was 0x60000, writing 0x600ff)
> [67880.401538] PM: early resume of devices complete after 0.795 msecs
> [67880.406036] HDA Intel 0000:00:1b.0: PCI INT A -> GSI 16 (level, low) -> IRQ 16
> [67880.406048] HDA Intel 0000:00:1b.0: setting latency timer to 64
> [67880.406093] HDA Intel 0000:00:1b.0: irq 40 for MSI/MSI-X
> [67880.406136] pci 0000:00:1c.0: PCI INT A -> GSI 16 (level, low) -> IRQ 16
> [67880.406143] pci 0000:00:1c.0: setting latency timer to 64
> [67880.406156] pci 0000:00:1c.1: PCI INT B -> GSI 17 (level, low) -> IRQ 17
> [67880.406163] pci 0000:00:1c.1: setting latency timer to 64
> [67880.406176] pci 0000:00:1c.2: PCI INT C -> GSI 18 (level, low) -> IRQ 18
> [67880.406183] pci 0000:00:1c.2: setting latency timer to 64
> [67880.406198] uhci_hcd 0000:00:1d.0: PCI INT A -> GSI 23 (level, low) -> IRQ 23
> [67880.406208] uhci_hcd 0000:00:1d.0: setting latency timer to 64
> [67880.406234] usb usb2: root hub lost power or was reset
> [67880.406253] uhci_hcd 0000:00:1d.1: PCI INT B -> GSI 19 (level, low) -> IRQ 19
> [67880.406262] uhci_hcd 0000:00:1d.1: setting latency timer to 64
> [67880.406287] usb usb3: root hub lost power or was reset
> [67880.406303] uhci_hcd 0000:00:1d.2: PCI INT C -> GSI 18 (level, low) -> IRQ 18
> [67880.406313] uhci_hcd 0000:00:1d.2: setting latency timer to 64
> [67880.406337] usb usb4: root hub lost power or was reset
> [67880.406354] uhci_hcd 0000:00:1d.3: PCI INT D -> GSI 16 (level, low) -> IRQ 16
> [67880.406363] uhci_hcd 0000:00:1d.3: setting latency timer to 64
> [67880.406387] usb usb5: root hub lost power or was reset
> [67880.406405] ehci_hcd 0000:00:1d.7: PCI INT A -> GSI 23 (level, low) -> IRQ 23
> [67880.406415] ehci_hcd 0000:00:1d.7: setting latency timer to 64
> [67880.406486] pci 0000:00:1e.0: setting latency timer to 64
> [67880.406505] ata_piix 0000:00:1f.2: PCI INT B -> GSI 19 (level, low) -> IRQ 19
> [67880.406513] ata_piix 0000:00:1f.2: setting latency timer to 64
> [67880.406543] atl2 0000:03:00.0: PCI INT A -> GSI 17 (level, low) -> IRQ 17
> [67880.406551] atl2 0000:03:00.0: setting latency timer to 64
> [67880.411177] i915 0000:00:02.0: PCI INT A -> GSI 16 (level, low) -> IRQ 16
> [67880.411186] i915 0000:00:02.0: setting latency timer to 64
> [67880.413110] sd 0:0:0:0: [sda] Starting disk
> [67880.652031] usb 1-5: reset high speed USB device using ehci_hcd and address 2
> [67880.896031] usb 1-8: reset high speed USB device using ehci_hcd and address 3
> [67882.532200] ata1.00: ACPI cmd ef/03:45:00:00:00:a0 (SET FEATURES) filtered out
> [67882.532209] ata1.00: ACPI cmd ef/03:0c:00:00:00:a0 (SET FEATURES) filtered out
> [67882.548191] ata1.00: configured for UDMA/133
> [67882.548697] PM: resume of devices complete after 2147.034 msecs
> [67882.549278] PM: Finishing wakeup.
> [67882.549283] Restarting tasks ... done.
> [67882.549761] video LNXVIDEO:00: Restoring backlight state
> [67882.980083] usb 3-2: new low speed USB device using uhci_hcd and address 5
> [67883.150414] atl2 0000:03:00.0: irq 41 for MSI/MSI-X
> [67883.151364] ADDRCONF(NETDEV_UP): eth0: link is not ready
> [67883.159163] usb 3-2: New USB device found, idVendor=0973, idProduct=0001
> [67883.159174] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
> [67883.159181] usb 3-2: Product: SchlumbergerSema Cryptoflex e-gate
> [67883.159187] usb 3-2: Manufacturer: SchlumbergerSema

I assume this is where Daniel reloads the driver:

> [67977.344181] atl2 0000:03:00.0: PCI INT A disabled
> [67977.379792] Atheros(R) L2 Ethernet Driver - version 2.2.3
> [67977.379802] Copyright (c) 2007 Atheros Corporation.
> [67977.379870] atl2 0000:03:00.0: PCI INT A -> GSI 17 (level, low) -> IRQ 17
> [67977.379892] atl2 0000:03:00.0: setting latency timer to 64
> [67993.948723] atl2 0000:03:00.0: irq 41 for MSI/MSI-X
> [67993.949268] ADDRCONF(NETDEV_UP): eth0: link is not ready
> [67994.154327] atl2: eth0 NIC Link is Up<100 Mbps Full Duplex>
> [67994.154739] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

[...]
> ** PCI devices:
[...]
> 03:00.0 Ethernet controller [0200]: Atheros Communications L2 Fast Ethernet [1969:2048] (rev a0)
>         Subsystem: ASUSTeK Computer Inc. Device [1043:8233]
>         Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
>         Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
>         Latency: 0, Cache Line Size: 16 bytes
>         Interrupt: pin A routed to IRQ 41
>         Region 0: Memory at fbfc0000 (64-bit, non-prefetchable) [size=256K]
>         Expansion ROM at fbfa0000 [disabled] [size=128K]
>         Capabilities: <access denied>
>         Kernel driver in use: atl2
[...]

Ben.

-- 
Ben Hutchings
Once a job is fouled up, anything done to improve it makes it worse.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply

* Re: [PATCH v2] ethtool : Add option -L | --set-common to set common flags.
From: Mahesh Bandewar @ 2011-02-23  0:41 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: David Miller, Tom Herbert, Laurent Chavey, netdev
In-Reply-To: <1298304057.2608.39.camel@bwh-desktop>

That makes sense! The corresponding kernel patch -

http://patchwork.ozlabs.org/patch/77815/

is in RFC state. So what does that state mean?

Thanks,
--mahesh..

On Mon, Feb 21, 2011 at 8:00 AM, Ben Hutchings
<bhutchings@solarflare.com> wrote:
>
> On Tue, 2011-01-18 at 14:37 -0800, Mahesh Bandewar wrote:
> > This patch adds -L | --set-common option to add / remove common flags which
> > includes loopback flag. The -l | --show-common displays the current values
> > for these common flags.
> [...]
>
> I haven't forgotten this, but I won't apply it until the corresponding
> kernel change is applied.
>
> Ben.
>
> --
> Ben Hutchings, Senior Software Engineer, Solarflare Communications
> Not speaking for my employer; that's the marketing department's job.
> They asked us to note that Solarflare product names are trademarked.
>

^ permalink raw reply

* Re: [PATCH] ipvs: fix dst_lock locking on dest update
From: Simon Horman @ 2011-02-23  0:26 UTC (permalink / raw)
  To: Julian Anastasov; +Cc: David S. Miller, netdev, lvs-devel
In-Reply-To: <alpine.LFD.2.00.1102220949510.2388@ja.ssi.bg>

On Tue, Feb 22, 2011 at 10:40:25AM +0200, Julian Anastasov wrote:
> 
> 	Fix dst_lock usage in __ip_vs_update_dest. We need
> _bh locking because destination is updated in user context.
> Can cause lockups on frequent destination updates.
> Problem reported by Simon Kirby. Bug was introduced
> in 2.6.37 from the "ipvs: changes for local real server"
> change.
> 
> Signed-off-by: Julian Anastasov <ja@ssi.bg>

Acked-by: Simon Horman <horms@verge.net.au>

> ---
> 
> 	Dave, please apply to net-2.6.
> Patch is for 2.6.37+ and applies to 2.6.38-rc6. There is
> little fuzz when applying to net-next, let me know if
> I should provide patch for other trees.
> 
> --- linux-2.6.37/net/netfilter/ipvs/ip_vs_ctl.c	2011-01-06 00:01:23.600069161 +0200
> +++ linux/net/netfilter/ipvs/ip_vs_ctl.c	2011-02-19 23:14:44.463250743 +0200
> @@ -810,9 +810,9 @@ __ip_vs_update_dest(struct ip_vs_service
>  	dest->u_threshold = udest->u_threshold;
>  	dest->l_threshold = udest->l_threshold;
> 
> -	spin_lock(&dest->dst_lock);
> +	spin_lock_bh(&dest->dst_lock);
>  	ip_vs_dst_reset(dest);
> -	spin_unlock(&dest->dst_lock);
> +	spin_unlock_bh(&dest->dst_lock);
> 
>  	if (add)
>  		ip_vs_new_estimator(&dest->stats);
> 

^ permalink raw reply

* Re: net: update Documentation/networking/00-INDEX
From: Rob Landley @ 2011-02-23  0:09 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: netdev, davem, Mariusz Kozlowski, LKML, linux-doc
In-Reply-To: <20110222142343.f3318134.rdunlap@xenotime.net>

On 02/22/2011 04:23 PM, Randy Dunlap wrote:
> From: Randy Dunlap <randy.dunlap@oracle.com>
> 
> Clean up entries in 00-INDEX: drop files that have been removed.
> 
> Reported-by: Rob Landley <rlandley@parallels.com>
> Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>

Acked-by: Rob Landley <rlandley@parallels.com>

^ permalink raw reply

* Re: [PATCH] ipvs: use hlist instead of list
From: Simon Horman @ 2011-02-22  6:45 UTC (permalink / raw)
  To: Changli Gao
  Cc: David S. Miller, Patrick McHardy, Wensong Zhang, Julian Anastasov,
	netdev, lvs-devel, netfilter-devel
In-Reply-To: <1298109908-29272-1-git-send-email-xiaosuo@gmail.com>

Thanks, I have queued this change.

On Sat, Feb 19, 2011 at 06:05:08PM +0800, Changli Gao wrote:
> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
> ---
>  include/net/ip_vs.h             |    2 -
>  net/netfilter/ipvs/ip_vs_conn.c |   52 ++++++++++++++++++++++------------------
>  2 files changed, 30 insertions(+), 24 deletions(-)
> diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
> index e80ffb7..2078a47 100644
> --- a/include/net/ip_vs.h
> +++ b/include/net/ip_vs.h
> @@ -494,7 +494,7 @@ struct ip_vs_conn_param {
>   *	IP_VS structure allocated for each dynamically scheduled connection
>   */
>  struct ip_vs_conn {
> -	struct list_head        c_list;         /* hashed list heads */
> +	struct hlist_node	c_list;         /* hashed list heads */
>  #ifdef CONFIG_NET_NS
>  	struct net              *net;           /* Name space */
>  #endif
> diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
> index 83233fe..9c2a517 100644
> --- a/net/netfilter/ipvs/ip_vs_conn.c
> +++ b/net/netfilter/ipvs/ip_vs_conn.c
> @@ -59,7 +59,7 @@ static int ip_vs_conn_tab_mask __read_mostly;
>  /*
>   *  Connection hash table: for input and output packets lookups of IPVS
>   */
> -static struct list_head *ip_vs_conn_tab __read_mostly;
> +static struct hlist_head *ip_vs_conn_tab __read_mostly;
>  
>  /*  SLAB cache for IPVS connections */
>  static struct kmem_cache *ip_vs_conn_cachep __read_mostly;
> @@ -201,7 +201,7 @@ static inline int ip_vs_conn_hash(struct ip_vs_conn *cp)
>  	spin_lock(&cp->lock);
>  
>  	if (!(cp->flags & IP_VS_CONN_F_HASHED)) {
> -		list_add(&cp->c_list, &ip_vs_conn_tab[hash]);
> +		hlist_add_head(&cp->c_list, &ip_vs_conn_tab[hash]);
>  		cp->flags |= IP_VS_CONN_F_HASHED;
>  		atomic_inc(&cp->refcnt);
>  		ret = 1;
> @@ -234,7 +234,7 @@ static inline int ip_vs_conn_unhash(struct ip_vs_conn *cp)
>  	spin_lock(&cp->lock);
>  
>  	if (cp->flags & IP_VS_CONN_F_HASHED) {
> -		list_del(&cp->c_list);
> +		hlist_del(&cp->c_list);
>  		cp->flags &= ~IP_VS_CONN_F_HASHED;
>  		atomic_dec(&cp->refcnt);
>  		ret = 1;
> @@ -259,12 +259,13 @@ __ip_vs_conn_in_get(const struct ip_vs_conn_param *p)
>  {
>  	unsigned hash;
>  	struct ip_vs_conn *cp;
> +	struct hlist_node *n;
>  
>  	hash = ip_vs_conn_hashkey_param(p, false);
>  
>  	ct_read_lock(hash);
>  
> -	list_for_each_entry(cp, &ip_vs_conn_tab[hash], c_list) {
> +	hlist_for_each_entry(cp, n, &ip_vs_conn_tab[hash], c_list) {
>  		if (cp->af == p->af &&
>  		    p->cport == cp->cport && p->vport == cp->vport &&
>  		    ip_vs_addr_equal(p->af, p->caddr, &cp->caddr) &&
> @@ -345,12 +346,13 @@ struct ip_vs_conn *ip_vs_ct_in_get(const struct ip_vs_conn_param *p)
>  {
>  	unsigned hash;
>  	struct ip_vs_conn *cp;
> +	struct hlist_node *n;
>  
>  	hash = ip_vs_conn_hashkey_param(p, false);
>  
>  	ct_read_lock(hash);
>  
> -	list_for_each_entry(cp, &ip_vs_conn_tab[hash], c_list) {
> +	hlist_for_each_entry(cp, n, &ip_vs_conn_tab[hash], c_list) {
>  		if (!ip_vs_conn_net_eq(cp, p->net))
>  			continue;
>  		if (p->pe_data && p->pe->ct_match) {
> @@ -394,6 +396,7 @@ struct ip_vs_conn *ip_vs_conn_out_get(const struct ip_vs_conn_param *p)
>  {
>  	unsigned hash;
>  	struct ip_vs_conn *cp, *ret=NULL;
> +	struct hlist_node *n;
>  
>  	/*
>  	 *	Check for "full" addressed entries
> @@ -402,7 +405,7 @@ struct ip_vs_conn *ip_vs_conn_out_get(const struct ip_vs_conn_param *p)
>  
>  	ct_read_lock(hash);
>  
> -	list_for_each_entry(cp, &ip_vs_conn_tab[hash], c_list) {
> +	hlist_for_each_entry(cp, n, &ip_vs_conn_tab[hash], c_list) {
>  		if (cp->af == p->af &&
>  		    p->vport == cp->cport && p->cport == cp->dport &&
>  		    ip_vs_addr_equal(p->af, p->vaddr, &cp->caddr) &&
> @@ -818,7 +821,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
>  		return NULL;
>  	}
>  
> -	INIT_LIST_HEAD(&cp->c_list);
> +	INIT_HLIST_NODE(&cp->c_list);
>  	setup_timer(&cp->timer, ip_vs_conn_expire, (unsigned long)cp);
>  	ip_vs_conn_net_set(cp, p->net);
>  	cp->af		   = p->af;
> @@ -894,8 +897,8 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
>   */
>  #ifdef CONFIG_PROC_FS
>  struct ip_vs_iter_state {
> -	struct seq_net_private p;
> -	struct list_head *l;
> +	struct seq_net_private	p;
> +	struct hlist_head	*l;
>  };
>  
>  static void *ip_vs_conn_array(struct seq_file *seq, loff_t pos)
> @@ -903,13 +906,14 @@ static void *ip_vs_conn_array(struct seq_file *seq, loff_t pos)
>  	int idx;
>  	struct ip_vs_conn *cp;
>  	struct ip_vs_iter_state *iter = seq->private;
> +	struct hlist_node *n;
>  
>  	for (idx = 0; idx < ip_vs_conn_tab_size; idx++) {
>  		ct_read_lock_bh(idx);
> -		list_for_each_entry(cp, &ip_vs_conn_tab[idx], c_list) {
> +		hlist_for_each_entry(cp, n, &ip_vs_conn_tab[idx], c_list) {
>  			if (pos-- == 0) {
>  				iter->l = &ip_vs_conn_tab[idx];
> -			return cp;
> +				return cp;
>  			}
>  		}
>  		ct_read_unlock_bh(idx);
> @@ -930,7 +934,8 @@ static void *ip_vs_conn_seq_next(struct seq_file *seq, void *v, loff_t *pos)
>  {
>  	struct ip_vs_conn *cp = v;
>  	struct ip_vs_iter_state *iter = seq->private;
> -	struct list_head *e, *l = iter->l;
> +	struct hlist_node *e;
> +	struct hlist_head *l = iter->l;
>  	int idx;
>  
>  	++*pos;
> @@ -938,15 +943,15 @@ static void *ip_vs_conn_seq_next(struct seq_file *seq, void *v, loff_t *pos)
>  		return ip_vs_conn_array(seq, 0);
>  
>  	/* more on same hash chain? */
> -	if ((e = cp->c_list.next) != l)
> -		return list_entry(e, struct ip_vs_conn, c_list);
> +	if ((e = cp->c_list.next))
> +		return hlist_entry(e, struct ip_vs_conn, c_list);
>  
>  	idx = l - ip_vs_conn_tab;
>  	ct_read_unlock_bh(idx);
>  
>  	while (++idx < ip_vs_conn_tab_size) {
>  		ct_read_lock_bh(idx);
> -		list_for_each_entry(cp, &ip_vs_conn_tab[idx], c_list) {
> +		hlist_for_each_entry(cp, e, &ip_vs_conn_tab[idx], c_list) {
>  			iter->l = &ip_vs_conn_tab[idx];
>  			return cp;
>  		}
> @@ -959,7 +964,7 @@ static void *ip_vs_conn_seq_next(struct seq_file *seq, void *v, loff_t *pos)
>  static void ip_vs_conn_seq_stop(struct seq_file *seq, void *v)
>  {
>  	struct ip_vs_iter_state *iter = seq->private;
> -	struct list_head *l = iter->l;
> +	struct hlist_head *l = iter->l;
>  
>  	if (l)
>  		ct_read_unlock_bh(l - ip_vs_conn_tab);
> @@ -1148,13 +1153,14 @@ void ip_vs_random_dropentry(struct net *net)
>  	 */
>  	for (idx = 0; idx < (ip_vs_conn_tab_size>>5); idx++) {
>  		unsigned hash = net_random() & ip_vs_conn_tab_mask;
> +		struct hlist_node *n;
>  
>  		/*
>  		 *  Lock is actually needed in this loop.
>  		 */
>  		ct_write_lock_bh(hash);
>  
> -		list_for_each_entry(cp, &ip_vs_conn_tab[hash], c_list) {
> +		hlist_for_each_entry(cp, n, &ip_vs_conn_tab[hash], c_list) {
>  			if (cp->flags & IP_VS_CONN_F_TEMPLATE)
>  				/* connection template */
>  				continue;
> @@ -1202,12 +1208,14 @@ static void ip_vs_conn_flush(struct net *net)
>  
>  flush_again:
>  	for (idx = 0; idx < ip_vs_conn_tab_size; idx++) {
> +		struct hlist_node *n;
> +
>  		/*
>  		 *  Lock is actually needed in this loop.
>  		 */
>  		ct_write_lock_bh(idx);
>  
> -		list_for_each_entry(cp, &ip_vs_conn_tab[idx], c_list) {
> +		hlist_for_each_entry(cp, n, &ip_vs_conn_tab[idx], c_list) {
>  			if (!ip_vs_conn_net_eq(cp, net))
>  				continue;
>  			IP_VS_DBG(4, "del connection\n");
> @@ -1265,8 +1273,7 @@ int __init ip_vs_conn_init(void)
>  	/*
>  	 * Allocate the connection hash table and initialize its list heads
>  	 */
> -	ip_vs_conn_tab = vmalloc(ip_vs_conn_tab_size *
> -				 sizeof(struct list_head));
> +	ip_vs_conn_tab = vmalloc(ip_vs_conn_tab_size * sizeof(*ip_vs_conn_tab));
>  	if (!ip_vs_conn_tab)
>  		return -ENOMEM;
>  
> @@ -1286,9 +1293,8 @@ int __init ip_vs_conn_init(void)
>  	IP_VS_DBG(0, "Each connection entry needs %Zd bytes at least\n",
>  		  sizeof(struct ip_vs_conn));
>  
> -	for (idx = 0; idx < ip_vs_conn_tab_size; idx++) {
> -		INIT_LIST_HEAD(&ip_vs_conn_tab[idx]);
> -	}
> +	for (idx = 0; idx < ip_vs_conn_tab_size; idx++)
> +		INIT_HLIST_HEAD(&ip_vs_conn_tab[idx]);
>  
>  	for (idx = 0; idx < CT_LOCKARRAY_SIZE; idx++)  {
>  		rwlock_init(&__ip_vs_conntbl_lock_array[idx].l);
> --
> To unsubscribe from this list: send the line "unsubscribe lvs-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply

* Re: [PATCH v2] ipvs: unify the formula to estimate the overhead of processing connections
From: Simon Horman @ 2011-02-22  5:56 UTC (permalink / raw)
  To: Changli Gao
  Cc: David S. Miller, Patrick McHardy, Wensong Zhang, Julian Anastasov,
	netdev, lvs-devel, netfilter-devel
In-Reply-To: <1298107948-9224-1-git-send-email-xiaosuo@gmail.com>

On Sat, Feb 19, 2011 at 05:32:28PM +0800, Changli Gao wrote:
> lc and wlc use the same formula, but lblc and lblcr use another one. There
> is no reason for using two different formulas for the lc variants.
> 
> The formula used by lc is used by all the lc variants in this patch.

Wensong, are you ok with this version of the patch?

> 
> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
> ---
> v2: use ip_vs_dest_conn_overhead() instead.
>  include/net/ip_vs.h              |   14 ++++++++++++++
>  net/netfilter/ipvs/ip_vs_lblc.c  |   13 +++----------
>  net/netfilter/ipvs/ip_vs_lblcr.c |   25 +++++++------------------
>  net/netfilter/ipvs/ip_vs_lc.c    |   18 +-----------------
>  net/netfilter/ipvs/ip_vs_wlc.c   |   20 ++------------------
>  5 files changed, 27 insertions(+), 63 deletions(-)
> diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
> index 5d75fea..e80ffb7 100644
> --- a/include/net/ip_vs.h
> +++ b/include/net/ip_vs.h
> @@ -1241,6 +1241,20 @@ static inline void ip_vs_conn_drop_conntrack(struct ip_vs_conn *cp)
>  /* CONFIG_IP_VS_NFCT */
>  #endif
>  
> +static inline unsigned int
> +ip_vs_dest_conn_overhead(struct ip_vs_dest *dest)
> +{
> +	/*
> +	 * We think the overhead of processing active connections is 256
> +	 * times higher than that of inactive connections in average. (This
> +	 * 256 times might not be accurate, we will change it later) We
> +	 * use the following formula to estimate the overhead now:
> +	 *		  dest->activeconns*256 + dest->inactconns
> +	 */
> +	return (atomic_read(&dest->activeconns) << 8) +
> +		atomic_read(&dest->inactconns);
> +}
> +
>  #endif /* __KERNEL__ */
>  
>  #endif	/* _NET_IP_VS_H */
> diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
> index 00b5ffa..58ae403 100644
> --- a/net/netfilter/ipvs/ip_vs_lblc.c
> +++ b/net/netfilter/ipvs/ip_vs_lblc.c
> @@ -389,12 +389,7 @@ __ip_vs_lblc_schedule(struct ip_vs_service *svc)
>  	int loh, doh;
>  
>  	/*
> -	 * We think the overhead of processing active connections is fifty
> -	 * times higher than that of inactive connections in average. (This
> -	 * fifty times might not be accurate, we will change it later.) We
> -	 * use the following formula to estimate the overhead:
> -	 *                dest->activeconns*50 + dest->inactconns
> -	 * and the load:
> +	 * We use the following formula to estimate the load:
>  	 *                (dest overhead) / dest->weight
>  	 *
>  	 * Remember -- no floats in kernel mode!!!
> @@ -410,8 +405,7 @@ __ip_vs_lblc_schedule(struct ip_vs_service *svc)
>  			continue;
>  		if (atomic_read(&dest->weight) > 0) {
>  			least = dest;
> -			loh = atomic_read(&least->activeconns) * 50
> -				+ atomic_read(&least->inactconns);
> +			loh = ip_vs_dest_conn_overhead(least);
>  			goto nextstage;
>  		}
>  	}
> @@ -425,8 +419,7 @@ __ip_vs_lblc_schedule(struct ip_vs_service *svc)
>  		if (dest->flags & IP_VS_DEST_F_OVERLOAD)
>  			continue;
>  
> -		doh = atomic_read(&dest->activeconns) * 50
> -			+ atomic_read(&dest->inactconns);
> +		doh = ip_vs_dest_conn_overhead(dest);
>  		if (loh * atomic_read(&dest->weight) >
>  		    doh * atomic_read(&least->weight)) {
>  			least = dest;
> diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
> index bfa25f1..2ddefe8 100644
> --- a/net/netfilter/ipvs/ip_vs_lblcr.c
> +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
> @@ -178,8 +178,7 @@ static inline struct ip_vs_dest *ip_vs_dest_set_min(struct ip_vs_dest_set *set)
>  
>  		if ((atomic_read(&least->weight) > 0)
>  		    && (least->flags & IP_VS_DEST_F_AVAILABLE)) {
> -			loh = atomic_read(&least->activeconns) * 50
> -				+ atomic_read(&least->inactconns);
> +			loh = ip_vs_dest_conn_overhead(least);
>  			goto nextstage;
>  		}
>  	}
> @@ -192,8 +191,7 @@ static inline struct ip_vs_dest *ip_vs_dest_set_min(struct ip_vs_dest_set *set)
>  		if (dest->flags & IP_VS_DEST_F_OVERLOAD)
>  			continue;
>  
> -		doh = atomic_read(&dest->activeconns) * 50
> -			+ atomic_read(&dest->inactconns);
> +		doh = ip_vs_dest_conn_overhead(dest);
>  		if ((loh * atomic_read(&dest->weight) >
>  		     doh * atomic_read(&least->weight))
>  		    && (dest->flags & IP_VS_DEST_F_AVAILABLE)) {
> @@ -228,8 +226,7 @@ static inline struct ip_vs_dest *ip_vs_dest_set_max(struct ip_vs_dest_set *set)
>  	list_for_each_entry(e, &set->list, list) {
>  		most = e->dest;
>  		if (atomic_read(&most->weight) > 0) {
> -			moh = atomic_read(&most->activeconns) * 50
> -				+ atomic_read(&most->inactconns);
> +			moh = ip_vs_dest_conn_overhead(most);
>  			goto nextstage;
>  		}
>  	}
> @@ -239,8 +236,7 @@ static inline struct ip_vs_dest *ip_vs_dest_set_max(struct ip_vs_dest_set *set)
>    nextstage:
>  	list_for_each_entry(e, &set->list, list) {
>  		dest = e->dest;
> -		doh = atomic_read(&dest->activeconns) * 50
> -			+ atomic_read(&dest->inactconns);
> +		doh = ip_vs_dest_conn_overhead(dest);
>  		/* moh/mw < doh/dw ==> moh*dw < doh*mw, where mw,dw>0 */
>  		if ((moh * atomic_read(&dest->weight) <
>  		     doh * atomic_read(&most->weight))
> @@ -563,12 +559,7 @@ __ip_vs_lblcr_schedule(struct ip_vs_service *svc)
>  	int loh, doh;
>  
>  	/*
> -	 * We think the overhead of processing active connections is fifty
> -	 * times higher than that of inactive connections in average. (This
> -	 * fifty times might not be accurate, we will change it later.) We
> -	 * use the following formula to estimate the overhead:
> -	 *                dest->activeconns*50 + dest->inactconns
> -	 * and the load:
> +	 * We use the following formula to estimate the load:
>  	 *                (dest overhead) / dest->weight
>  	 *
>  	 * Remember -- no floats in kernel mode!!!
> @@ -585,8 +576,7 @@ __ip_vs_lblcr_schedule(struct ip_vs_service *svc)
>  
>  		if (atomic_read(&dest->weight) > 0) {
>  			least = dest;
> -			loh = atomic_read(&least->activeconns) * 50
> -				+ atomic_read(&least->inactconns);
> +			loh = ip_vs_dest_conn_overhead(least);
>  			goto nextstage;
>  		}
>  	}
> @@ -600,8 +590,7 @@ __ip_vs_lblcr_schedule(struct ip_vs_service *svc)
>  		if (dest->flags & IP_VS_DEST_F_OVERLOAD)
>  			continue;
>  
> -		doh = atomic_read(&dest->activeconns) * 50
> -			+ atomic_read(&dest->inactconns);
> +		doh = ip_vs_dest_conn_overhead(dest);
>  		if (loh * atomic_read(&dest->weight) >
>  		    doh * atomic_read(&least->weight)) {
>  			least = dest;
> diff --git a/net/netfilter/ipvs/ip_vs_lc.c b/net/netfilter/ipvs/ip_vs_lc.c
> index 4f69db1..160cb80 100644
> --- a/net/netfilter/ipvs/ip_vs_lc.c
> +++ b/net/netfilter/ipvs/ip_vs_lc.c
> @@ -22,22 +22,6 @@
>  
>  #include <net/ip_vs.h>
>  
> -
> -static inline unsigned int
> -ip_vs_lc_dest_overhead(struct ip_vs_dest *dest)
> -{
> -	/*
> -	 * We think the overhead of processing active connections is 256
> -	 * times higher than that of inactive connections in average. (This
> -	 * 256 times might not be accurate, we will change it later) We
> -	 * use the following formula to estimate the overhead now:
> -	 *		  dest->activeconns*256 + dest->inactconns
> -	 */
> -	return (atomic_read(&dest->activeconns) << 8) +
> -		atomic_read(&dest->inactconns);
> -}
> -
> -
>  /*
>   *	Least Connection scheduling
>   */
> @@ -62,7 +46,7 @@ ip_vs_lc_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
>  		if ((dest->flags & IP_VS_DEST_F_OVERLOAD) ||
>  		    atomic_read(&dest->weight) == 0)
>  			continue;
> -		doh = ip_vs_lc_dest_overhead(dest);
> +		doh = ip_vs_dest_conn_overhead(dest);
>  		if (!least || doh < loh) {
>  			least = dest;
>  			loh = doh;
> diff --git a/net/netfilter/ipvs/ip_vs_wlc.c b/net/netfilter/ipvs/ip_vs_wlc.c
> index bbddfdb..db751f5 100644
> --- a/net/netfilter/ipvs/ip_vs_wlc.c
> +++ b/net/netfilter/ipvs/ip_vs_wlc.c
> @@ -27,22 +27,6 @@
>  
>  #include <net/ip_vs.h>
>  
> -
> -static inline unsigned int
> -ip_vs_wlc_dest_overhead(struct ip_vs_dest *dest)
> -{
> -	/*
> -	 * We think the overhead of processing active connections is 256
> -	 * times higher than that of inactive connections in average. (This
> -	 * 256 times might not be accurate, we will change it later) We
> -	 * use the following formula to estimate the overhead now:
> -	 *		  dest->activeconns*256 + dest->inactconns
> -	 */
> -	return (atomic_read(&dest->activeconns) << 8) +
> -		atomic_read(&dest->inactconns);
> -}
> -
> -
>  /*
>   *	Weighted Least Connection scheduling
>   */
> @@ -71,7 +55,7 @@ ip_vs_wlc_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
>  		if (!(dest->flags & IP_VS_DEST_F_OVERLOAD) &&
>  		    atomic_read(&dest->weight) > 0) {
>  			least = dest;
> -			loh = ip_vs_wlc_dest_overhead(least);
> +			loh = ip_vs_dest_conn_overhead(least);
>  			goto nextstage;
>  		}
>  	}
> @@ -85,7 +69,7 @@ ip_vs_wlc_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
>  	list_for_each_entry_continue(dest, &svc->destinations, n_list) {
>  		if (dest->flags & IP_VS_DEST_F_OVERLOAD)
>  			continue;
> -		doh = ip_vs_wlc_dest_overhead(dest);
> +		doh = ip_vs_dest_conn_overhead(dest);
>  		if (loh * atomic_read(&dest->weight) >
>  		    doh * atomic_read(&least->weight)) {
>  			least = dest;
> 

^ permalink raw reply

* net: update Documentation/networking/00-INDEX
From: Randy Dunlap @ 2011-02-22 22:23 UTC (permalink / raw)
  To: netdev, davem; +Cc: Rob Landley, Mariusz Kozlowski, LKML, linux-doc
In-Reply-To: <20110221120303.48106f6c.rdunlap@xenotime.net>

From: Randy Dunlap <randy.dunlap@oracle.com>

Clean up entries in 00-INDEX: drop files that have been removed.

Reported-by: Rob Landley <rlandley@parallels.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
---
 Documentation/networking/00-INDEX |    6 ------
 1 file changed, 6 deletions(-)

--- linux-next-20110222.orig/Documentation/networking/00-INDEX
+++ linux-next-20110222/Documentation/networking/00-INDEX
@@ -40,8 +40,6 @@ decnet.txt
 	- info on using the DECnet networking layer in Linux.
 depca.txt
 	- the Digital DEPCA/EtherWORKS DE1?? and DE2?? LANCE Ethernet driver
-dgrs.txt
-	- the Digi International RightSwitch SE-X Ethernet driver
 dmfe.txt
 	- info on the Davicom DM9102(A)/DM9132/DM9801 fast ethernet driver.
 e100.txt
@@ -50,8 +48,6 @@ e1000.txt
 	- info on Intel's E1000 line of gigabit ethernet boards
 eql.txt
 	- serial IP load balancing
-ethertap.txt
-	- the Ethertap user space packet reception and transmission driver
 ewrk3.txt
 	- the Digital EtherWORKS 3 DE203/4/5 Ethernet driver
 filter.txt
@@ -104,8 +100,6 @@ tuntap.txt
 	- TUN/TAP device driver, allowing user space Rx/Tx of packets.
 vortex.txt
 	- info on using 3Com Vortex (3c590, 3c592, 3c595, 3c597) Ethernet cards.
-wavelan.txt
-	- AT&T GIS (nee NCR) WaveLAN card: An Ethernet-like radio transceiver
 x25.txt
 	- general info on X.25 development.
 x25-iface.txt

^ permalink raw reply

* Re: [PATCH] ax88796: depend on HAS_IOMEM not on individual ARCHs
From: David Miller @ 2011-02-22 22:01 UTC (permalink / raw)
  To: mkl; +Cc: netdev
In-Reply-To: <4D642DC6.2010307@pengutronix.de>

From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: Tue, 22 Feb 2011 22:42:30 +0100

> On 02/22/2011 09:37 PM, David Miller wrote:
>> I know it's going to cause allmodconfig build errors on sparc64,
>> for example.
> 
> How to fix?
>> drivers/net/ax88796.c:195: error: implicit declaration of function 'readsw'
>> drivers/net/ax88796.c:198: error: implicit declaration of function 'readsb'
> 
> Use "ioreadX_rep" or add a "!SPARC64" to Kconfig?

Make sparc64 provide the necessary interface.

^ permalink raw reply

* pull request: wireless-next-2.6 2011-02-22
From: John W. Linville @ 2011-02-22 21:52 UTC (permalink / raw)
  To: davem; +Cc: linux-wireless, netdev

Dave,

Here is the latest batch of wireless bits intended for 2.6.39.  It seems
I neglected to send a pull request last week, so this one is a bit big
-- I apologize!

This includes a rather large batch of bluetooth bits by way of Gustavo.
It looks like a variety of bits, including some code refactoring, some
protocol support enhancements, some bugfixes, etc. -- nothing too
unusual.

Other items of interest include a new driver from Realtek, some ssb
support enhancements, and the usual sort of updates for mac80211 and a
variety of drivers.  Also included is a wireless-2.6 pull to resolve
some build breakage.

Please let me know if there are problems!

John

---

The following changes since commit db62983a1e4b2af9e79c97af768f0c8b80bd93f0:

  Merge branch 'net/ax88796' of git://git.pengutronix.de/git/mkl/linux-2.6 (2011-02-22 11:15:29 -0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6.git for-davem

Andrei Emeltchenko (3):
      Bluetooth: Use non-flushable by default L2CAP data packets
      Bluetooth: Do not use assignments in IF conditions
      Bluetooth: fix crash by disabling tasklet in sock accept

Andrei Warkentin (1):
      Bluetooth: Make hci a child of the corresponding tty device.

Bala Shanmugam (1):
      Bluetooth: Add firmware support for Atheros 3012

Ben Greear (7):
      ath9k: Print channel-type in chan-change dbg message.
      mac80211: Properly set work-item channel-type.
      mac80211: Allow scanning on existing channel-type.
      mac80211: Allow work items to use existing channel type.
      ath9k: Add debug info for configuring power level.
      mac80211: Ensure power-level set properly for scanning.
      mac80211: Add power to debugfs.

Bob Copeland (1):
      ath5k: move external function definitions to a header file

Cho, Yu-Chen (1):
      Bluetooth: Add Atheros BT AR5BBU12 fw supported

Christian Lamparter (6):
      p54: sort channel list by frequency instead of channel index
      p54: p54_generate_band cleanup
      p54: enhance rssi->dBm database import
      p54spi: update sample eeprom
      p54: implement flush callback
      ar9170usb: mark the old driver as obsolete

Claudio Takahasi (3):
      Bluetooth: Add LE signaling commands handling
      Bluetooth: Add connection parameter update response
      Bluetooth: Send LE Connection Update Command

Eliad Peller (4):
      wl12xx: mcp2.5 - add config_ps acx
      wl12xx: move to new firmware (6.1.3.50.49)
      wl12xx: use the conf struct instead of macros for memory configuration
      wl12xx: set supported_rates after association

George (9):
      rtlwifi: Add usb driver
      rtlwifi: Add headers for rtl8187cu
      rtlwifi: rtl8192cu: Add routines dm, fw, led and sw
      rtlwifi: rtl8192cu: Add routine hw
      rtlwifi: rtl8192cu: Add routine mac
      rtlwifi: rtl8192cu: Add routine phy
      rtlwifi: rtl8192cu: Add routine rf
      rtlwifi: rtl8192cu: Add routine table
      rtlwifi: rtl8192cu: Add routine trx

Gustavo F. Padovan (27):
      Merge branch 'master' of git://git.kernel.org/.../padovan/bluetooth-2.6 into wireless
      Bluetooth: Fix setting of MTU for ERTM and Streaming Mode
      Bluetooth: Rename l2cap.c to l2cap_core.c
      Bluetooth: Initial work for L2CAP split.
      Bluetooth: move l2cap_sock_ops to l2cap_sock.c
      Bluetooth: move l2cap_sock_release() to l2cap_sock.c
      Bluetooth: move l2cap_sock_bind()/listen() to l2cap_sock.c
      Bluetooth: move l2cap_sock_accept() to l2cap_sock.c
      Bluetooth: move l2cap_sock_getname() to l2cap_sock.c
      Bluetooth: move l2cap_sock_setsockopt() to l2cap_sock.c
      Bluetooth: move l2cap_sock_getsockopt() to l2cap_sock.c
      Bluetooth: move l2cap_sock_connect() to l2cap_sock.c
      Bluetooth: move l2cap_sock_recvmsg() to l2cap_sock.c
      Bluetooth: move l2cap_sock_shutdown() to l2cap_sock.c
      Bluetooth: move l2cap_sock_sendmsg() to l2cap_sock.c
      Bluetooth: move L2CAP sock timers function to l2cap_sock.c
      Bluetooth: move l2cap_sock_kill() to l2cap_sock.c
      Bluetooth: move __l2cap_sock_close() to l2cap_sock.c
      Bluetooth: update Bluetooth daemon name in Kconfig help
      Bluetooth: Merge L2CAP and SCO modules into bluetooth.ko
      Bluetooth: remove l2cap_load() hack
      Bluetooth: Add L2CAP mode to debugfs output
      Bluetooth: Use usb_fill_int_urb()
      Bluetooth: Fix crash when ioctl(HCIUARTSETPROTO) fails
      Bluetooth: fix errors reported by checkpatch.pl
      Bluetooth: Fix errors reported by checkpatch.pl
      Bluetooth: fix checkpatch errors in af_bluetooth.c

Helmut Schaa (4):
      mac80211: Remove superfluous if clause
      rt2x00: Minor optimization for devices with RTS/CTS offload
      Revert "rt2x00 : avoid timestamp for monitor injected frame."
      rt2x00: Remove superfluos empty line

Henry Ptasinski (1):
      wireless-next-2.6: brcm80211: fix compile issue

Jan Beulich (1):
      small adjustment to net/mac80211/Kconfig

Jesper Juhl (1):
      Bluetooth: Fix failure to release lock in read_index_list()

Johan Hedberg (25):
      Bluetooth: Implement automatic setup procedure for local adapters
      Bluetooth: Add support for management powered event
      Bluetooth: Add support for set_powered management command
      Bluetooth: Add support for set_discoverable management command
      Bluetooth: Add set_connectable management command
      Bluetooth: Unify mode related management messages to a single struct
      Bluetooth: Add flag to track managment controlled adapters
      Bluetooth: Add send_mode_rsp convenience function for mgmt.c
      Bluetooth: Implement set_pairable managment command
      Bluetooth: Implement UUID handling through the management interface
      Bluetooth: Implement debugfs support for listing UUIDs
      Bluetooth: Reject pairing requests when in non-pairable mode
      Bluetooth: Add special handling with __hci_request and HCI_INIT
      Bluetooth: Add controller side link key clearing to hci_init_req
      Bluetooth: Remove page timeout setting from HCI init sequence
      Bluetooth: Implement a more complete adapter initialization sequence
      Bluetooth: Add class of device control to the management interface
      Bluetooth: Implement link key handling for the management interface
      Bluetooth: Add connected/disconnected management events
      Bluetooth: Add disconnect managment command
      Bluetooth: Add support for connect failed management event
      Bluetooth: Add get_connections managment interface command
      Bluetooth: Create common cmd_complete function for mgmt.c
      Bluetooth: Add support for PIN code handling in the management interface
      Bluetooth: Add set_io_capability management command

Johannes Berg (2):
      mac80211: reply to directed probes in IBSS
      mac80211: fix 2.4 GHz 40 MHz disabling

John W. Linville (5):
      Merge branch 'for-linville' of git://git.kernel.org/.../luca/wl12xx
      Merge branch 'master' of git://git.kernel.org/.../padovan/bluetooth-2.6
      Merge branch 'master' of git://git.kernel.org/.../padovan/bluetooth-next-2.6
      Merge ssh://master.kernel.org/.../linville/wireless-2.6
      Merge branch 'master' of git://git.kernel.org/.../linville/wireless-next-2.6 into for-davem

Jussi Kivilinna (4):
      zd1211rw: correct use of usb_bulk_msg on interrupt endpoints
      zd1211rw: use async urb for write command
      zd1211rw: move async iowrite16v up to callers
      zd1211rw: add unlikely to ZD_ASSERT

Larry Finger (13):
      rtlwifi: Modify core routines
      rtlwifi: rtl8192ce: Refactor rtl8192ce/dm
      rtlwifi: rtl8192ce: Refactor rtl8192ce/fw
      rtlwifi: rtl8192ce: Rework rtl8192ce/phy.c
      p54: Fix compile warning
      rtlwifi: Make changes in rtlwifi/rtl8192ce/reg.h to support rtl8192cu
      rtlwifi: Make changes in rtlwifi/rtl8192ce/def.h to support rtl8192cu
      rtlwifi: Modify some rtl8192ce routines for merging rtl8192cu
      rtlwifi: Modify wifi.h for rtl8192cu
      rtlwifi: Move common parts of rtl8192ce/phy.c
      rtlwifi: Modify build system for rtl8192cu
      rtlwifi: rtl8192ce: Fix endian warnings
      rtlwifi: Remove obsolete/unused macros

Michael Buesch (1):
      ssb: Make ssb_wait_bit multi-bit safe

Mohammed Shafi Shajakhan (1):
      ath9k: Fix ath9k prevents CPU to enter C3 states

Nikolay Ledovskikh (1):
      ath5k: Correct channel setting for AR2317 chip

Oliver Neukum (1):
      Bluetooth: fix crash with quirky dongles doing sound

RA-Jay Hung (2):
      rt2x00: Add antenna setting for RT3070/RT3090/RT3390 with RX antenna diversity support
      rt2x00: Fix rt2800 txpower setting to correct value

RA-Shiang Tu (1):
      rt2x00: Add support for RT5390 chip

Rafał Miłecki (5):
      ssb: extract boardflags2 for SPROMs rev 4 and 5
      ssb: trivial: fix SPROM extract warning formatting
      ssb: remove invalid define SSB_TMSLOW_PHYCLK
      ssb: when needed, reject IM input while disabling device
      ssb: reset device only if it was enabled

Rajkumar Manoharan (1):
      ath9k: disable beaconing before stopping beacon queue

Randy Dunlap (1):
      wl12xx: fix sdio_test kconfig/build errors

Rogério Brito (1):
      Bluetooth: ath3k: Avoid duplication of code

Seth Forshee (1):
      rt2x00: Check for errors from skb_pad() calls

Shiang Tu (2):
      rt2x00: Add/Modify protection related register definitions
      rt2x00: Add/Modify the GPIO register definition

Stanislaw Gruszka (4):
      iwlwifi: cleanup iwl_recover_from_statistics
      iwlwifi: cleanup iwl_good_ack_health
      iwlwifi: fix ack health for WiFi/BT combo devices
      mac80211: fix conn_mon_timer running after disassociate

Steve Brown (1):
      ath9k: Remove redundant beacon_interval

Sujith Manoharan (1):
      ath9k_hw: Fix power on reset

Szymon Janc (5):
      Bluetooth: Use #include <linux/uaccess.h> instead of <asm/uaccess.h>
      Bluetooth: Clean up hci_sniff_subrate_evt function
      Bluetooth: Fix some code style issues in hci_core.h
      Bluetooth: Fix some code style issues in hci_core.c
      Bluetooth: Fix some code style issues in hci_event.c

Vasanthakumar Thiagarajan (1):
      ath9k: Implement op_flush()

Vasiliy Kulikov (3):
      Bluetooth: l2cap: fix 1 byte infoleak to userspace
      Bluetooth: bnep: fix buffer overflow
      Bluetooth: sco: fix information leak to userspace

Ville Tervo (9):
      Bluetooth: Add low energy commands and events
      Bluetooth: Add LE connect support
      Bluetooth: Use LE buffers for LE traffic
      Bluetooth: Add LE connection support to L2CAP
      Bluetooth: Add server socket support for LE connection
      Bluetooth: Do not send disconn comand over LE links
      Bluetooth: Treat LE and ACL links separately on timeout
      Bluetooth: Add SMP command structures
      Bluetooth: Use proper timer for hci command timout

Vinicius Costa Gomes (1):
      Bluetooth: Fix initiated LE connections

Vivek Natarajan (3):
      ath9k_htc: Fix a compilation warning.
      ath9k_hw: Updates for AR9485 1.1 chipsets.
      mac80211: Clear PS related flag on disabling power save.

Vladislav P (1):
      Bluetooth: Release BTM while sleeping to avoid deadlock

Wey-Yi Guy (2):
      iwlagn: donot process bt update when bt coex disable
      iwlagn: handle bt defer work in 2000 series

Wojciech Dubowik (1):
      ath5k: Enable AR2315 chipset recognition

Xose Vazquez Perez (1):
      wireless: rt2x00: rt2800pci.c: add two ids

 Documentation/feature-removal-schedule.txt         |   11 +
 MAINTAINERS                                        |    2 +-
 drivers/bluetooth/ath3k.c                          |  290 +++-
 drivers/bluetooth/btusb.c                          |   20 +-
 drivers/bluetooth/hci_ldisc.c                      |    1 +
 drivers/net/wireless/ath/ar9170/Kconfig            |    4 +-
 drivers/net/wireless/ath/ath5k/ath5k.h             |   20 +
 drivers/net/wireless/ath/ath5k/attach.c            |    3 +-
 drivers/net/wireless/ath/ath5k/mac80211-ops.c      |   17 -
 drivers/net/wireless/ath/ath5k/phy.c               |    1 +
 drivers/net/wireless/ath/ath9k/ar9003_hw.c         |  112 +-
 drivers/net/wireless/ath/ath9k/ar9485_initvals.h   | 1141 +++++++++
 drivers/net/wireless/ath/ath9k/ath9k.h             |   13 +-
 drivers/net/wireless/ath/ath9k/beacon.c            |   43 +-
 drivers/net/wireless/ath/ath9k/htc_drv_main.c      |    2 +-
 drivers/net/wireless/ath/ath9k/hw.c                |    1 -
 drivers/net/wireless/ath/ath9k/init.c              |    8 -
 drivers/net/wireless/ath/ath9k/main.c              |  124 +-
 drivers/net/wireless/ath/ath9k/reg.h               |    4 +
 drivers/net/wireless/ath/ath9k/xmit.c              |   30 +-
 drivers/net/wireless/iwlwifi/iwl-2000.c            |    3 +-
 drivers/net/wireless/iwlwifi/iwl-agn-lib.c         |   12 +-
 drivers/net/wireless/iwlwifi/iwl-agn.c             |   74 +-
 drivers/net/wireless/iwlwifi/iwl-rx.c              |   37 +-
 drivers/net/wireless/p54/eeprom.c                  |  208 ++-
 drivers/net/wireless/p54/eeprom.h                  |    7 +
 drivers/net/wireless/p54/fwio.c                    |   12 +-
 drivers/net/wireless/p54/lmac.h                    |    1 +
 drivers/net/wireless/p54/main.c                    |   47 +-
 drivers/net/wireless/p54/p54.h                     |    6 +-
 drivers/net/wireless/p54/p54spi_eeprom.h           |    9 +-
 drivers/net/wireless/p54/txrx.c                    |    6 +-
 drivers/net/wireless/rt2x00/Kconfig                |   12 +
 drivers/net/wireless/rt2x00/rt2800.h               |  129 +-
 drivers/net/wireless/rt2x00/rt2800lib.c            |  747 +++++--
 drivers/net/wireless/rt2x00/rt2800pci.c            |   12 +
 drivers/net/wireless/rt2x00/rt2x00.h               |    4 +
 drivers/net/wireless/rt2x00/rt2x00ht.c             |    1 -
 drivers/net/wireless/rt2x00/rt2x00mac.c            |    6 +-
 drivers/net/wireless/rt2x00/rt2x00queue.c          |    9 +-
 drivers/net/wireless/rt2x00/rt61pci.c              |   12 +-
 drivers/net/wireless/rt2x00/rt73usb.c              |   12 +-
 drivers/net/wireless/rtlwifi/Kconfig               |   17 +-
 drivers/net/wireless/rtlwifi/Makefile              |    6 +-
 drivers/net/wireless/rtlwifi/base.c                |   76 +-
 drivers/net/wireless/rtlwifi/base.h                |   39 +-
 drivers/net/wireless/rtlwifi/core.c                |   14 +-
 drivers/net/wireless/rtlwifi/debug.h               |    1 +
 drivers/net/wireless/rtlwifi/pci.c                 |  148 +-
 drivers/net/wireless/rtlwifi/pci.h                 |   12 +-
 drivers/net/wireless/rtlwifi/ps.c                  |   58 +-
 drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c  | 1388 +++++++++++
 drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c | 2049 ++++++++++++++++
 drivers/net/wireless/rtlwifi/rtl8192ce/Makefile    |    2 +
 drivers/net/wireless/rtlwifi/rtl8192ce/def.h       |  144 ++
 drivers/net/wireless/rtlwifi/rtl8192ce/dm.c        | 1361 +-----------
 drivers/net/wireless/rtlwifi/rtl8192ce/dm.h        |    1 +
 drivers/net/wireless/rtlwifi/rtl8192ce/fw.c        |   59 +-
 drivers/net/wireless/rtlwifi/rtl8192ce/hw.c        |  153 +-
 drivers/net/wireless/rtlwifi/rtl8192ce/led.c       |    6 +-
 drivers/net/wireless/rtlwifi/rtl8192ce/phy.c       | 2072 +----------------
 drivers/net/wireless/rtlwifi/rtl8192ce/phy.h       |    7 +-
 drivers/net/wireless/rtlwifi/rtl8192ce/reg.h       |   73 +-
 drivers/net/wireless/rtlwifi/rtl8192ce/sw.c        |    7 +-
 drivers/net/wireless/rtlwifi/rtl8192ce/sw.h        |    2 +
 drivers/net/wireless/rtlwifi/rtl8192ce/trx.c       |  170 +-
 drivers/net/wireless/rtlwifi/rtl8192ce/trx.h       |  464 ++--
 drivers/net/wireless/rtlwifi/rtl8192cu/Makefile    |   15 +
 drivers/net/wireless/rtlwifi/rtl8192cu/def.h       |   62 +
 drivers/net/wireless/rtlwifi/rtl8192cu/dm.c        |  116 +
 drivers/net/wireless/rtlwifi/rtl8192cu/dm.h        |   32 +
 drivers/net/wireless/rtlwifi/rtl8192cu/fw.c        |   30 +
 drivers/net/wireless/rtlwifi/rtl8192cu/fw.h        |   30 +
 drivers/net/wireless/rtlwifi/rtl8192cu/hw.c        | 2505 ++++++++++++++++++++
 drivers/net/wireless/rtlwifi/rtl8192cu/hw.h        |  107 +
 drivers/net/wireless/rtlwifi/rtl8192cu/led.c       |  142 ++
 drivers/net/wireless/rtlwifi/rtl8192cu/led.h       |   37 +
 drivers/net/wireless/rtlwifi/rtl8192cu/mac.c       | 1144 +++++++++
 drivers/net/wireless/rtlwifi/rtl8192cu/mac.h       |  180 ++
 drivers/net/wireless/rtlwifi/rtl8192cu/phy.c       |  611 +++++
 drivers/net/wireless/rtlwifi/rtl8192cu/phy.h       |   34 +
 drivers/net/wireless/rtlwifi/rtl8192cu/reg.h       |   30 +
 drivers/net/wireless/rtlwifi/rtl8192cu/rf.c        |  493 ++++
 drivers/net/wireless/rtlwifi/rtl8192cu/rf.h        |   30 +
 drivers/net/wireless/rtlwifi/rtl8192cu/sw.c        |  327 +++
 drivers/net/wireless/rtlwifi/rtl8192cu/sw.h        |   35 +
 drivers/net/wireless/rtlwifi/rtl8192cu/table.c     | 1888 +++++++++++++++
 drivers/net/wireless/rtlwifi/rtl8192cu/table.h     |   71 +
 drivers/net/wireless/rtlwifi/rtl8192cu/trx.c       |  684 ++++++
 drivers/net/wireless/rtlwifi/rtl8192cu/trx.h       |  430 ++++
 drivers/net/wireless/rtlwifi/usb.c                 | 1035 ++++++++
 drivers/net/wireless/rtlwifi/usb.h                 |  164 ++
 drivers/net/wireless/rtlwifi/wifi.h                |  667 ++++--
 drivers/net/wireless/wl12xx/Kconfig                |    2 +-
 drivers/net/wireless/wl12xx/acx.c                  |   86 +-
 drivers/net/wireless/wl12xx/acx.h                  |   41 +-
 drivers/net/wireless/wl12xx/cmd.c                  |   10 +-
 drivers/net/wireless/wl12xx/cmd.h                  |   14 +-
 drivers/net/wireless/wl12xx/conf.h                 |   49 +
 drivers/net/wireless/wl12xx/event.c                |   14 -
 drivers/net/wireless/wl12xx/event.h                |    2 -
 drivers/net/wireless/wl12xx/init.c                 |   13 +
 drivers/net/wireless/wl12xx/main.c                 |  143 +-
 drivers/net/wireless/wl12xx/ps.c                   |    6 +-
 drivers/net/wireless/wl12xx/rx.c                   |    6 +-
 drivers/net/wireless/wl12xx/rx.h                   |    2 +-
 drivers/net/wireless/wl12xx/tx.c                   |   22 -
 drivers/net/wireless/wl12xx/wl12xx.h               |   66 +-
 drivers/net/wireless/zd1211rw/zd_chip.c            |   35 +-
 drivers/net/wireless/zd1211rw/zd_def.h             |    2 +-
 drivers/net/wireless/zd1211rw/zd_usb.c             |  177 ++-
 drivers/net/wireless/zd1211rw/zd_usb.h             |    9 +-
 drivers/ssb/main.c                                 |   44 +-
 drivers/ssb/pci.c                                  |    6 +-
 drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c   |    4 +-
 include/linux/ssb/ssb_regs.h                       |    7 +-
 include/net/bluetooth/bluetooth.h                  |   33 +
 include/net/bluetooth/hci.h                        |  122 +
 include/net/bluetooth/hci_core.h                   |  152 +-
 include/net/bluetooth/l2cap.h                      |   53 +-
 include/net/bluetooth/mgmt.h                       |  142 ++
 include/net/bluetooth/smp.h                        |   76 +
 net/bluetooth/Kconfig                              |   16 +-
 net/bluetooth/Makefile                             |    4 +-
 net/bluetooth/af_bluetooth.c                       |   53 +-
 net/bluetooth/bnep/core.c                          |    2 -
 net/bluetooth/bnep/sock.c                          |    1 +
 net/bluetooth/cmtp/capi.c                          |    3 +-
 net/bluetooth/cmtp/core.c                          |   11 +-
 net/bluetooth/hci_conn.c                           |   78 +-
 net/bluetooth/hci_core.c                           |  345 +++-
 net/bluetooth/hci_event.c                          |  622 +++++-
 net/bluetooth/hci_sock.c                           |    6 +-
 net/bluetooth/hci_sysfs.c                          |   58 +-
 net/bluetooth/hidp/core.c                          |   11 +-
 net/bluetooth/{l2cap.c => l2cap_core.c}            | 1722 ++++----------
 net/bluetooth/l2cap_sock.c                         | 1156 +++++++++
 net/bluetooth/mgmt.c                               | 1312 ++++++++++-
 net/bluetooth/rfcomm/core.c                        |    2 -
 net/bluetooth/rfcomm/tty.c                         |    2 +
 net/bluetooth/sco.c                                |   17 +-
 net/mac80211/Kconfig                               |    2 +-
 net/mac80211/cfg.c                                 |    1 +
 net/mac80211/debugfs.c                             |    6 +
 net/mac80211/ibss.c                                |   11 +-
 net/mac80211/ieee80211_i.h                         |    2 -
 net/mac80211/main.c                                |   33 +-
 net/mac80211/mlme.c                                |    8 +
 net/mac80211/rx.c                                  |   12 +-
 net/mac80211/scan.c                                |   15 +-
 net/mac80211/tx.c                                  |    1 +
 net/mac80211/util.c                                |    6 -
 net/mac80211/work.c                                |   59 +-
 153 files changed, 22844 insertions(+), 6512 deletions(-)
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/Makefile
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/def.h
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/dm.c
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/dm.h
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/fw.c
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/fw.h
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/hw.h
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/led.c
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/led.h
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/mac.h
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/phy.c
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/phy.h
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/reg.h
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/rf.c
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/rf.h
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/sw.h
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/table.c
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/table.h
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
 create mode 100644 drivers/net/wireless/rtlwifi/rtl8192cu/trx.h
 create mode 100644 drivers/net/wireless/rtlwifi/usb.c
 create mode 100644 drivers/net/wireless/rtlwifi/usb.h
 create mode 100644 include/net/bluetooth/smp.h
 rename net/bluetooth/{l2cap.c => l2cap_core.c} (76%)
 create mode 100644 net/bluetooth/l2cap_sock.c

Omnibus patch available here:

	http://www.kernel.org/pub/linux/kernel/people/linville/wireless-next-2.6-2011-02-22.patch.bz2

-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply

* Re: [PATCH] TX timestamp IPv6 support
From: Anders Berggren @ 2011-02-22 21:50 UTC (permalink / raw)
  To: David Miller; +Cc: netdev
In-Reply-To: <20110222.093633.193722951.davem@davemloft.net>

> Please submit your change properly, as per Documentation/SubmittingPatches,
> in particular you need to provide a proper Signed-off-by: tag for your
> change.

Thank you. I made a second try:

http://marc.info/?l=linux-netdev&m=129841103607145&w=2

^ permalink raw reply

* Re: [PATCH ethtool 5/5] ethtool: Add --version option
From: Ben Hutchings @ 2011-02-22 21:49 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Eric Dumazet, Stephen Hemminger, netdev
In-Reply-To: <4D642C14.6020505@garzik.org>

On Tue, 2011-02-22 at 16:35 -0500, Jeff Garzik wrote:
> On 02/22/2011 08:05 AM, Eric Dumazet wrote:
> > Le mardi 22 février 2011 à 12:37 +0000, Ben Hutchings a écrit :
> >> On Mon, 2011-02-21 at 22:16 -0800, Stephen Hemminger wrote:
> >> [...]
> >>> The standard convention is to use -V for short form of version option.
> >>
> >> This is not anywhere near standard.
> >>
> >> $ cp -V
> >> cp: invalid option -- 'V'
> >> Try `cp --help' for more information.
> >> $ bash -V
> >> bash: -V: invalid option
> >> [...]
> >> $ emacs -V
> >> [opens window]
> >> $ vim -V
> >> chdir(/usr/share/vim)
> >> fchdir() to previous dir
> >> sourcing "$VIM/vimrc"
> >> [...looks like that meant 'verbose'...]
> >
> > Now try with networking tools, many use -V
> >
> > (As a matter of fact, ethtool -h already is used to display help)
> >
> > # ping -V
> > ping utility, iputils-sss20071127
> > # tc -V
> > tc utility, iproute2-ss100823
> > # ssh -V
> > OpenSSH_5.1p1 Debian-5, OpenSSL 0.9.8g 19 Oct 2007
> 
> Stephen is correct, "-V" is a common standard (but by no means 
> universal).  The following is what using argp ("info argp") generates 
> for any program by default:
[...]

Well, it's my bikeshed now. :-)  I don't think it's worth using one of
the few remaining letters on this.

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


^ permalink raw reply

* [PATCH] net: TX timestamps for IPv6 UDP packets
From: Anders Berggren @ 2011-02-22 21:43 UTC (permalink / raw)
  To: John Ronciak; +Cc: netdev

Enabling TX timestamps (SO_TIMESTAMPING) for IPv6 UDP packets, in 
the same fashion as for IPv4. Necessary in order for NICs such as
Intel 82580 to timestamp IPv6 packets.

Signed-off-by: Anders Berggren <anders@halon.se>
---

diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 94b5bf1..74d9343 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1115,6 +1115,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
 	int err;
 	int offset = 0;
 	int csummode = CHECKSUM_NONE;
+	__u8 tx_flags = 0;
 
 	if (flags&MSG_PROBE)
 		return 0;
@@ -1199,6 +1200,13 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
 		}
 	}
 
+	/* For UDP, check if TX timestamp is enabled */
+	if (sk->sk_type == SOCK_DGRAM) {
+		err = sock_tx_timestamp(sk, &tx_flags);
+		if (err)
+			goto error;
+	}
+
 	/*
 	 * Let's try using as much space as possible.
 	 * Use MTU if total length of the message fits into the MTU.
@@ -1303,6 +1311,10 @@ alloc_new_skb:
 							   sk->sk_allocation);
 				if (unlikely(skb == NULL))
 					err = -ENOBUFS;
+				else
+					/* only the initial fragment is
+					   time stamped */
+					tx_flags = 0;
 			}
 			if (skb == NULL)
 				goto error;
@@ -1314,6 +1326,9 @@ alloc_new_skb:
 			/* reserve for fragmentation */
 			skb_reserve(skb, hh_len+sizeof(struct frag_hdr));
 
+			if (sk->sk_type == SOCK_DGRAM)
+				skb_shinfo(skb)->tx_flags = tx_flags;
+
 			/*
 			 *	Find where to start putting bytes
 			 */

^ permalink raw reply related

* Re: [PATCH] ax88796: depend on HAS_IOMEM not on individual ARCHs
From: Marc Kleine-Budde @ 2011-02-22 21:42 UTC (permalink / raw)
  To: David Miller; +Cc: netdev
In-Reply-To: <20110222.123732.70186533.davem@davemloft.net>

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

On 02/22/2011 09:37 PM, David Miller wrote:
> I know it's going to cause allmodconfig build errors on sparc64,
> for example.

How to fix?
> drivers/net/ax88796.c:195: error: implicit declaration of function 'readsw'
> drivers/net/ax88796.c:198: error: implicit declaration of function 'readsb'

Use "ioreadX_rep" or add a "!SPARC64" to Kconfig?

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply

* Re: [PATCH ethtool 5/5] ethtool: Add --version option
From: Jeff Garzik @ 2011-02-22 21:35 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: Eric Dumazet, Stephen Hemminger, netdev
In-Reply-To: <1298379945.2861.7.camel@edumazet-laptop>

On 02/22/2011 08:05 AM, Eric Dumazet wrote:
> Le mardi 22 février 2011 à 12:37 +0000, Ben Hutchings a écrit :
>> On Mon, 2011-02-21 at 22:16 -0800, Stephen Hemminger wrote:
>> [...]
>>> The standard convention is to use -V for short form of version option.
>>
>> This is not anywhere near standard.
>>
>> $ cp -V
>> cp: invalid option -- 'V'
>> Try `cp --help' for more information.
>> $ bash -V
>> bash: -V: invalid option
>> [...]
>> $ emacs -V
>> [opens window]
>> $ vim -V
>> chdir(/usr/share/vim)
>> fchdir() to previous dir
>> sourcing "$VIM/vimrc"
>> [...looks like that meant 'verbose'...]
>
> Now try with networking tools, many use -V
>
> (As a matter of fact, ethtool -h already is used to display help)
>
> # ping -V
> ping utility, iputils-sss20071127
> # tc -V
> tc utility, iproute2-ss100823
> # ssh -V
> OpenSSH_5.1p1 Debian-5, OpenSSL 0.9.8g 19 Oct 2007

Stephen is correct, "-V" is a common standard (but by no means 
universal).  The following is what using argp ("info argp") generates 
for any program by default:

> Usage: myprog [OPTION...]
> myprog - a program that does something
>
> [...]
>
>   -?, --help                 Give this help list
>       --usage                Give a short usage message
>   -V, --version              Print program version
>
> Mandatory or optional arguments to long options are also mandatory or optional for any corresponding short options.

Regards,

	Jeff



^ permalink raw reply

* [PATCHv2 2/2] DM9000B: Fix PHY power for network down/up
From: Henry Nestler @ 2011-02-22 21:29 UTC (permalink / raw)
  To: netdev; +Cc: akpm, linux-arm-kernel
In-Reply-To: <20110222.102410.260079835.davem@davemloft.net>

DM9000 revision B needs 1 ms delay after PHY power-on.
PHY must be powered on by writing 0 into register DM9000_GPR before
all other settings will change (see Davicom spec and example code).

Remember, that register DM9000_GPR was not changed by reset sequence.

Without this fix the FIFO is out of sync and sends wrong data after
sequence of "ifconfig ethX down ; ifconfig ethX up".
---
Kernel version 2.6.38-rc5

 drivers/net/dm9000.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index 2d4c4fc..5925569 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -802,10 +802,7 @@ dm9000_init_dm9000(struct net_device *dev)
 	/* Checksum mode */
 	dm9000_set_rx_csum_unlocked(dev, db->rx_csum);

-	/* GPIO0 on pre-activate PHY */
-	iow(db, DM9000_GPR, 0);	/* REG_1F bit0 activate phyxcer */
 	iow(db, DM9000_GPCR, GPCR_GEP_CNTL);	/* Let GPIO0 output */
-	iow(db, DM9000_GPR, 0);	/* Enable PHY */

 	ncr = (db->flags & DM9000_PLATF_EXT_PHY) ? NCR_EXT_PHY : 0;

@@ -1194,6 +1191,10 @@ dm9000_open(struct net_device *dev)
 	if (request_irq(dev->irq, dm9000_interrupt, irqflags, dev->name, dev))
 		return -EAGAIN;

+	/* GPIO0 on pre-activate PHY, Reg 1F is not set by reset */
+	iow(db, DM9000_GPR, 0);	/* REG_1F bit0 activate phyxcer */
+	mdelay(1); /* delay needs by DM9000B */
+
 	/* Initialize DM9000 board */
 	dm9000_reset(db);
 	dm9000_init_dm9000(dev);

^ permalink raw reply related

* Re: [PATCH net-next-2.6] bonding: fix user-controlled queuing issues
From: Andy Gospodarek @ 2011-02-22 21:24 UTC (permalink / raw)
  To: Phil Oester; +Cc: Andy Gospodarek, netdev, Ben Hutchings, Jay Vosburgh
In-Reply-To: <20110222164836.GA15040@linuxace.com>

On Tue, Feb 22, 2011 at 08:48:36AM -0800, Phil Oester wrote:
> On Tue, Feb 22, 2011 at 11:19:41AM -0500, Andy Gospodarek wrote:
> > Phil,
> > 
> > Can you send me the minimal set of tc rules that selects output queue 16
> > and the output of /proc/net/bonding/bond0?
> > 
> > Private email is fine if you do not want to post it to the list.
> > 
> > Thanks,
> > 
> > -andy
> 
> I have no tc rules which select output queue 16 (I have no tc rules at all
> in fact). 
> 
> Output of /proc/net/bonding/bond0 below.  The bond consists of two Intel
> igb nics, which only have 8 queues.  Note, however, that eth0 is an ixgbe,
> which has 16 queues:
> 
> ixgbe 0000:0b:00.0: Multiqueue Enabled: Rx Queue count = 16, Tx Queue count = 16
> 
> which may answer your question as to what is selecting queue 16.  
> 
> Phil 
> 

OK, I've got it now!  I can reproduce this when I recieve frames from a
device not in the bond and transmit those frames out of the bond device.
I suspect that is what you are doing.  That was a case I did not
consider with the original patch.

I will test all of this and post this as a 2-part series with the first
patch being one that should apply to stable as well, so you and others
can have it there.


^ permalink raw reply

* Re: [PATCH ethtool 2/3] ethtool: Regularise handling of offload flags
From: Michał Mirosław @ 2011-02-22 21:17 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: netdev
In-Reply-To: <1298307548.2608.50.camel@bwh-desktop>

On Mon, Feb 21, 2011 at 04:59:08PM +0000, Ben Hutchings wrote:
> Use the new ETHTOOL_{G,S}FEATURES operations where available, and
> use the new structure and netif feature flags in any case.
[...]
> --- a/ethtool.c
> +++ b/ethtool.c
[...]
> +static int dump_offload(const struct ethtool_get_features_block *features)
>  {
[...]
> +	u32 value;
> +	int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(off_feature_def); i++) {
> +		value = off_feature_def[i].value;
> +		printf("%s: %s%s%s\n",
> +		       off_feature_def[i].long_name,
> +		       (features->active & value) ? "on" : "off",
> +		       (features->requested & ~features->active & value) ?
> +		       " [requested on]" : "",
> +		       (~features->available & value) ? " [unchangeable]" : "");
> +	}

This would be clearer if '[requested XXX]' part was shown only when the
offload's state is different than requested.

Best Regards,
Michał Mirosław 

^ permalink raw reply

* Re: [PATCH] rt2x00: Use ops name instead of device name
From: Steven Rostedt @ 2011-02-22 21:08 UTC (permalink / raw)
  To: John W. Linville
  Cc: Ivo Van Doorn, Ben Hutchings, LKML, netdev, Felix Fietkau,
	abogani
In-Reply-To: <20110222194724.GG12153@tuxdriver.com>

On Tue, 2011-02-22 at 14:47 -0500, John W. Linville wrote:

> I completely missed this series -- please be sure to Cc:
> linux-wireless@vger.kernel.org if you resend, and/or resend the series
> directly to me?

Hi John,

Not sure which series you were talking about. I sent out a single patch
and Cc'd you on it. But I should have sent it to linux-wireless, instead
of the net-dev list.

I don't plan on sending out any new patches. This should fix the issue.

Thanks,

-- Steve

^ permalink raw reply

* [RFC PATCH 10/10] staging: octeon_ethernet: Convert to use device tree.
From: David Daney @ 2011-02-22 20:57 UTC (permalink / raw)
  To: linux-mips-6z/3iImG2C8G8FEW9MqTrA, ralf-6z/3iImG2C8G8FEW9MqTrA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	grant.likely-s3s/WqlpOiPyB63q8FvJNQ,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, David Daney, David S. Miller
In-Reply-To: <1298408274-20856-1-git-send-email-ddaney-M3mlKVOIwJVv6pq1l3V1OdBPR1lH4CV8@public.gmane.org>

Get MAC address and PHY connection from the device tree.

Signed-off-by: David Daney <ddaney-M3mlKVOIwJVv6pq1l3V1OdBPR1lH4CV8@public.gmane.org>
Cc: "David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
---
 drivers/staging/octeon/ethernet-mdio.c   |   27 +++++----
 drivers/staging/octeon/ethernet.c        |  101 +++++++++++++++++++-----------
 drivers/staging/octeon/octeon-ethernet.h |    3 +
 3 files changed, 82 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/octeon/ethernet-mdio.c b/drivers/staging/octeon/ethernet-mdio.c
index 0e5dab7..38a0153 100644
--- a/drivers/staging/octeon/ethernet-mdio.c
+++ b/drivers/staging/octeon/ethernet-mdio.c
@@ -27,6 +27,7 @@
 #include <linux/kernel.h>
 #include <linux/ethtool.h>
 #include <linux/phy.h>
+#include <linux/of_mdio.h>
 
 #include <net/dst.h>
 
@@ -162,22 +163,24 @@ static void cvm_oct_adjust_link(struct net_device *dev)
 int cvm_oct_phy_setup_device(struct net_device *dev)
 {
 	struct octeon_ethernet *priv = netdev_priv(dev);
+	struct device_node *phy_node;
 
-	int phy_addr = cvmx_helper_board_get_mii_address(priv->port);
-	if (phy_addr != -1) {
-		char phy_id[20];
+	if (!priv->of_node)
+		return 0;
 
-		snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT, "0", phy_addr);
+	phy_node = of_parse_phandle(priv->of_node, "phy-handle", 0);
+	if (!phy_node)
+		return 0;
 
-		priv->phydev = phy_connect(dev, phy_id, cvm_oct_adjust_link, 0,
-					PHY_INTERFACE_MODE_GMII);
+	priv->phydev = of_phy_connect(dev, phy_node, cvm_oct_adjust_link, 0,
+				      PHY_INTERFACE_MODE_GMII);
 
-		if (IS_ERR(priv->phydev)) {
-			priv->phydev = NULL;
-			return -1;
-		}
-		priv->last_link = 0;
-		phy_start_aneg(priv->phydev);
+	if (IS_ERR(priv->phydev)) {
+		priv->phydev = NULL;
+		return -1;
 	}
+	priv->last_link = 0;
+	phy_start_aneg(priv->phydev);
+
 	return 0;
 }
diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
index 042adf7..87f8956 100644
--- a/drivers/staging/octeon/ethernet.c
+++ b/drivers/staging/octeon/ethernet.c
@@ -31,6 +31,7 @@
 #include <linux/etherdevice.h>
 #include <linux/phy.h>
 #include <linux/slab.h>
+#include <linux/of_net.h>
 
 #include <net/dst.h>
 
@@ -112,15 +113,6 @@ int rx_napi_weight = 32;
 module_param(rx_napi_weight, int, 0444);
 MODULE_PARM_DESC(rx_napi_weight, "The NAPI WEIGHT parameter.");
 
-/*
- * The offset from mac_addr_base that should be used for the next port
- * that is configured.  By convention, if any mgmt ports exist on the
- * chip, they get the first mac addresses, The ports controlled by
- * this driver are numbered sequencially following any mgmt addresses
- * that may exist.
- */
-static unsigned int cvm_oct_mac_addr_offset;
-
 /**
  * cvm_oct_poll_queue - Workqueue for polling operations.
  */
@@ -447,26 +439,13 @@ static int cvm_oct_common_set_mac_address(struct net_device *dev, void *addr)
 int cvm_oct_common_init(struct net_device *dev)
 {
 	struct octeon_ethernet *priv = netdev_priv(dev);
-	struct sockaddr sa;
-	u64 mac = ((u64)(octeon_bootinfo->mac_addr_base[0] & 0xff) << 40) |
-		((u64)(octeon_bootinfo->mac_addr_base[1] & 0xff) << 32) |
-		((u64)(octeon_bootinfo->mac_addr_base[2] & 0xff) << 24) |
-		((u64)(octeon_bootinfo->mac_addr_base[3] & 0xff) << 16) |
-		((u64)(octeon_bootinfo->mac_addr_base[4] & 0xff) << 8) |
-		(u64)(octeon_bootinfo->mac_addr_base[5] & 0xff);
-
-	mac += cvm_oct_mac_addr_offset;
-	sa.sa_data[0] = (mac >> 40) & 0xff;
-	sa.sa_data[1] = (mac >> 32) & 0xff;
-	sa.sa_data[2] = (mac >> 24) & 0xff;
-	sa.sa_data[3] = (mac >> 16) & 0xff;
-	sa.sa_data[4] = (mac >> 8) & 0xff;
-	sa.sa_data[5] = mac & 0xff;
-
-	if (cvm_oct_mac_addr_offset >= octeon_bootinfo->mac_addr_count)
-		printk(KERN_DEBUG "%s: Using MAC outside of the assigned range:"
-			" %pM\n", dev->name, sa.sa_data);
-	cvm_oct_mac_addr_offset++;
+	struct sockaddr sa = {0};
+
+	if (priv->of_node) {
+		const u8 *mac = of_get_mac_address(priv->of_node);
+		if (mac)
+			memcpy(sa.sa_data, mac, 6);
+	}
 
 	/*
 	 * Force the interface to use the POW send if always_use_pow
@@ -594,22 +573,68 @@ static const struct net_device_ops cvm_oct_pow_netdev_ops = {
 
 extern void octeon_mdiobus_force_mod_depencency(void);
 
+static struct device_node * __init cvm_oct_of_get_child(const struct device_node *parent,
+							int reg_val)
+{
+	struct device_node *node = NULL;
+	int size;
+	const __be32 *addr;
+
+	for (;;) {
+		node = of_get_next_child(parent, node);
+		if (!node)
+			break;
+		addr = of_get_property(node, "reg", &size);
+		if (addr && (be32_to_cpu(*addr) == reg_val))
+			break;
+	}
+	return node;
+}
+
+static struct device_node * __init cvm_oct_node_for_port(struct device_node *pip,
+							 int interface, int port)
+{
+	struct device_node *ni, *np;
+
+	ni = cvm_oct_of_get_child(pip, interface);
+	if (!ni)
+		return NULL;
+
+	np = cvm_oct_of_get_child(ni, port);
+	of_node_put(ni);
+
+	return np;
+}
+
 static int __init cvm_oct_init_module(void)
 {
 	int num_interfaces;
 	int interface;
 	int fau = FAU_NUM_PACKET_BUFFERS_TO_FREE;
 	int qos;
+	struct device_node *aliases;
+	const char *node_path;
+	struct device_node *pip;
 
 	octeon_mdiobus_force_mod_depencency();
 	pr_notice("cavium-ethernet %s\n", OCTEON_ETHERNET_VERSION);
 
-	if (OCTEON_IS_MODEL(OCTEON_CN52XX))
-		cvm_oct_mac_addr_offset = 2; /* First two are the mgmt ports. */
-	else if (OCTEON_IS_MODEL(OCTEON_CN56XX))
-		cvm_oct_mac_addr_offset = 1; /* First one is the mgmt port. */
-	else
-		cvm_oct_mac_addr_offset = 0;
+
+	aliases = of_find_node_by_path("/aliases");
+	if (!aliases) {
+		pr_err("Error: No /aliases node in device tree.");
+		return -EINVAL;
+	}
+	node_path = of_get_property(aliases, "pip", NULL);
+	if (!node_path) {
+		pr_err("Error: No /aliases/pip node in device tree.");
+		return -EINVAL;
+	}
+	pip = of_find_node_by_path(node_path);
+	if (!pip) {
+		pr_err("Error: No %s in device tree.", node_path);
+		return -EINVAL;
+	}
 
 	cvm_oct_poll_queue = create_singlethread_workqueue("octeon-ethernet");
 	if (cvm_oct_poll_queue == NULL) {
@@ -688,10 +713,11 @@ static int __init cvm_oct_init_module(void)
 		    cvmx_helper_interface_get_mode(interface);
 		int num_ports = cvmx_helper_ports_on_interface(interface);
 		int port;
+		int port_index;
 
-		for (port = cvmx_helper_get_ipd_port(interface, 0);
+		for (port_index = 0, port = cvmx_helper_get_ipd_port(interface, 0);
 		     port < cvmx_helper_get_ipd_port(interface, num_ports);
-		     port++) {
+		     port_index++, port++) {
 			struct octeon_ethernet *priv;
 			struct net_device *dev =
 			    alloc_etherdev(sizeof(struct octeon_ethernet));
@@ -702,6 +728,7 @@ static int __init cvm_oct_init_module(void)
 
 			/* Initialize the device private structure. */
 			priv = netdev_priv(dev);
+			priv->of_node = cvm_oct_node_for_port(pip, interface, port_index);
 
 			INIT_DELAYED_WORK(&priv->port_periodic_work,
 					  cvm_oct_periodic_worker);
diff --git a/drivers/staging/octeon/octeon-ethernet.h b/drivers/staging/octeon/octeon-ethernet.h
index d581925..9360e22 100644
--- a/drivers/staging/octeon/octeon-ethernet.h
+++ b/drivers/staging/octeon/octeon-ethernet.h
@@ -31,6 +31,8 @@
 #ifndef OCTEON_ETHERNET_H
 #define OCTEON_ETHERNET_H
 
+#include <linux/of.h>
+
 /**
  * This is the definition of the Ethernet driver's private
  * driver state stored in netdev_priv(dev).
@@ -59,6 +61,7 @@ struct octeon_ethernet {
 	void (*poll) (struct net_device *dev);
 	struct delayed_work	port_periodic_work;
 	struct work_struct	port_work;	/* may be unused. */
+	struct device_node	*of_node;
 };
 
 int cvm_oct_free_work(void *work_queue_entry);
-- 
1.7.2.3

^ permalink raw reply related

* [RFC PATCH 09/10] netdev: octeon_mgmt: Convert to use device tree.
From: David Daney @ 2011-02-22 20:57 UTC (permalink / raw)
  To: linux-mips, ralf, devicetree-discuss, grant.likely, linux-kernel
  Cc: David Daney, David S. Miller, netdev
In-Reply-To: <1298408274-20856-1-git-send-email-ddaney@caviumnetworks.com>

The device tree will supply the register bank base addresses, make
register addressing relative to those.  PHY connection is now
described by the device tree.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
---
 arch/mips/cavium-octeon/octeon-platform.c |   62 -------
 drivers/net/octeon/octeon_mgmt.c          |  265 +++++++++++++++++------------
 2 files changed, 160 insertions(+), 167 deletions(-)

diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c
index a33dcf9..3a3867b 100644
--- a/arch/mips/cavium-octeon/octeon-platform.c
+++ b/arch/mips/cavium-octeon/octeon-platform.c
@@ -166,68 +166,6 @@ out:
 }
 device_initcall(octeon_rng_device_init);
 
-/* Octeon mgmt port Ethernet interface.  */
-static int __init octeon_mgmt_device_init(void)
-{
-	struct platform_device *pd;
-	int ret = 0;
-	int port, num_ports;
-
-	struct resource mgmt_port_resource = {
-		.flags	= IORESOURCE_IRQ,
-		.start	= -1,
-		.end	= -1
-	};
-
-	if (!OCTEON_IS_MODEL(OCTEON_CN56XX) && !OCTEON_IS_MODEL(OCTEON_CN52XX))
-		return 0;
-
-	if (OCTEON_IS_MODEL(OCTEON_CN56XX))
-		num_ports = 1;
-	else
-		num_ports = 2;
-
-	for (port = 0; port < num_ports; port++) {
-		pd = platform_device_alloc("octeon_mgmt", port);
-		if (!pd) {
-			ret = -ENOMEM;
-			goto out;
-		}
-		/* No DMA restrictions */
-		pd->dev.coherent_dma_mask = DMA_BIT_MASK(64);
-		pd->dev.dma_mask = &pd->dev.coherent_dma_mask;
-
-		switch (port) {
-		case 0:
-			mgmt_port_resource.start = OCTEON_IRQ_MII0;
-			break;
-		case 1:
-			mgmt_port_resource.start = OCTEON_IRQ_MII1;
-			break;
-		default:
-			BUG();
-		}
-		mgmt_port_resource.end = mgmt_port_resource.start;
-
-		ret = platform_device_add_resources(pd, &mgmt_port_resource, 1);
-
-		if (ret)
-			goto fail;
-
-		ret = platform_device_add(pd);
-		if (ret)
-			goto fail;
-	}
-	return ret;
-fail:
-	platform_device_put(pd);
-
-out:
-	return ret;
-
-}
-device_initcall(octeon_mgmt_device_init);
-
 #ifdef CONFIG_USB
 
 static int __init octeon_ehci_device_init(void)
diff --git a/drivers/net/octeon/octeon_mgmt.c b/drivers/net/octeon/octeon_mgmt.c
index b264f0f..6c301c7 100644
--- a/drivers/net/octeon/octeon_mgmt.c
+++ b/drivers/net/octeon/octeon_mgmt.c
@@ -6,16 +6,21 @@
  * Copyright (C) 2009 Cavium Networks
  */
 
-#include <linux/capability.h>
-#include <linux/dma-mapping.h>
-#include <linux/init.h>
 #include <linux/platform_device.h>
-#include <linux/netdevice.h>
+#include <linux/dma-mapping.h>
 #include <linux/etherdevice.h>
+#include <linux/of_platform.h>
+#include <linux/capability.h>
+#include <linux/of_address.h>
+#include <linux/netdevice.h>
+#include <linux/spinlock.h>
 #include <linux/if_vlan.h>
+#include <linux/of_mdio.h>
+#include <linux/of_irq.h>
+#include <linux/of_net.h>
+#include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/phy.h>
-#include <linux/spinlock.h>
 
 #include <asm/octeon/octeon.h>
 #include <asm/octeon/cvmx-mixx-defs.h>
@@ -55,8 +60,56 @@ union mgmt_port_ring_entry {
 	} s;
 };
 
+#define MIX_ORING1	0x0
+#define MIX_ORING2	0x8
+#define MIX_IRING1	0x10
+#define MIX_IRING2	0x18
+#define MIX_CTL		0x20
+#define MIX_IRHWM	0x28
+#define MIX_IRCNT	0x30
+#define MIX_ORHWM	0x38
+#define MIX_ORCNT	0x40
+#define MIX_ISR		0x48
+#define MIX_INTENA	0x50
+#define MIX_REMCNT	0x58
+#define MIX_BIST	0x78
+
+#define AGL_GMX_PRT_CFG			0x10
+#define AGL_GMX_RX_FRM_CTL		0x18
+#define AGL_GMX_RX_FRM_MAX		0x30
+#define AGL_GMX_RX_JABBER		0x38
+#define AGL_GMX_RX_STATS_CTL		0x50
+
+#define AGL_GMX_RX_STATS_PKTS_DRP	0xb0
+#define AGL_GMX_RX_STATS_OCTS_DRP	0xb8
+#define AGL_GMX_RX_STATS_PKTS_BAD	0xc0
+
+#define AGL_GMX_RX_ADR_CTL		0x100
+#define AGL_GMX_RX_ADR_CAM_EN		0x108
+#define AGL_GMX_RX_ADR_CAM0		0x180
+#define AGL_GMX_RX_ADR_CAM1		0x188
+#define AGL_GMX_RX_ADR_CAM2		0x190
+#define AGL_GMX_RX_ADR_CAM3		0x198
+#define AGL_GMX_RX_ADR_CAM4		0x1a0
+#define AGL_GMX_RX_ADR_CAM5		0x1a8
+
+#define AGL_GMX_TX_STATS_CTL		0x268
+#define AGL_GMX_TX_CTL			0x270
+#define AGL_GMX_TX_STAT0		0x280
+#define AGL_GMX_TX_STAT1		0x288
+#define AGL_GMX_TX_STAT2		0x290
+#define AGL_GMX_TX_STAT3		0x298
+#define AGL_GMX_TX_STAT4		0x2a0
+#define AGL_GMX_TX_STAT5		0x2a8
+#define AGL_GMX_TX_STAT6		0x2b0
+#define AGL_GMX_TX_STAT7		0x2b8
+#define AGL_GMX_TX_STAT8		0x2c0
+#define AGL_GMX_TX_STAT9		0x2c8
+
 struct octeon_mgmt {
 	struct net_device *netdev;
+	u64 mix;
+	u64 agl;
 	int port;
 	int irq;
 	u64 *tx_ring;
@@ -82,31 +135,30 @@ struct octeon_mgmt {
 	struct napi_struct napi;
 	struct tasklet_struct tx_clean_tasklet;
 	struct phy_device *phydev;
+	struct device_node *phy_np;
 };
 
 static void octeon_mgmt_set_rx_irq(struct octeon_mgmt *p, int enable)
 {
-	int port = p->port;
 	union cvmx_mixx_intena mix_intena;
 	unsigned long flags;
 
 	spin_lock_irqsave(&p->lock, flags);
-	mix_intena.u64 = cvmx_read_csr(CVMX_MIXX_INTENA(port));
+	mix_intena.u64 = cvmx_read_csr(p->mix + MIX_INTENA);
 	mix_intena.s.ithena = enable ? 1 : 0;
-	cvmx_write_csr(CVMX_MIXX_INTENA(port), mix_intena.u64);
+	cvmx_write_csr(p->mix + MIX_INTENA, mix_intena.u64);
 	spin_unlock_irqrestore(&p->lock, flags);
 }
 
 static void octeon_mgmt_set_tx_irq(struct octeon_mgmt *p, int enable)
 {
-	int port = p->port;
 	union cvmx_mixx_intena mix_intena;
 	unsigned long flags;
 
 	spin_lock_irqsave(&p->lock, flags);
-	mix_intena.u64 = cvmx_read_csr(CVMX_MIXX_INTENA(port));
+	mix_intena.u64 = cvmx_read_csr(p->mix + MIX_INTENA);
 	mix_intena.s.othena = enable ? 1 : 0;
-	cvmx_write_csr(CVMX_MIXX_INTENA(port), mix_intena.u64);
+	cvmx_write_csr(p->mix + MIX_INTENA, mix_intena.u64);
 	spin_unlock_irqrestore(&p->lock, flags);
 }
 
@@ -143,7 +195,6 @@ static unsigned int ring_size_to_bytes(unsigned int ring_size)
 static void octeon_mgmt_rx_fill_ring(struct net_device *netdev)
 {
 	struct octeon_mgmt *p = netdev_priv(netdev);
-	int port = p->port;
 
 	while (p->rx_current_fill < ring_max_fill(OCTEON_MGMT_RX_RING_SIZE)) {
 		unsigned int size;
@@ -174,24 +225,23 @@ static void octeon_mgmt_rx_fill_ring(struct net_device *netdev)
 			(p->rx_next_fill + 1) % OCTEON_MGMT_RX_RING_SIZE;
 		p->rx_current_fill++;
 		/* Ring the bell.  */
-		cvmx_write_csr(CVMX_MIXX_IRING2(port), 1);
+		cvmx_write_csr(p->mix + MIX_IRING2, 1);
 	}
 }
 
 static void octeon_mgmt_clean_tx_buffers(struct octeon_mgmt *p)
 {
-	int port = p->port;
 	union cvmx_mixx_orcnt mix_orcnt;
 	union mgmt_port_ring_entry re;
 	struct sk_buff *skb;
 	int cleaned = 0;
 	unsigned long flags;
 
-	mix_orcnt.u64 = cvmx_read_csr(CVMX_MIXX_ORCNT(port));
+	mix_orcnt.u64 = cvmx_read_csr(p->mix + MIX_ORCNT);
 	while (mix_orcnt.s.orcnt) {
 		spin_lock_irqsave(&p->tx_list.lock, flags);
 
-		mix_orcnt.u64 = cvmx_read_csr(CVMX_MIXX_ORCNT(port));
+		mix_orcnt.u64 = cvmx_read_csr(p->mix + MIX_ORCNT);
 
 		if (mix_orcnt.s.orcnt == 0) {
 			spin_unlock_irqrestore(&p->tx_list.lock, flags);
@@ -211,7 +261,7 @@ static void octeon_mgmt_clean_tx_buffers(struct octeon_mgmt *p)
 		mix_orcnt.s.orcnt = 1;
 
 		/* Acknowledge to hardware that we have the buffer.  */
-		cvmx_write_csr(CVMX_MIXX_ORCNT(port), mix_orcnt.u64);
+		cvmx_write_csr(p->mix + MIX_ORCNT, mix_orcnt.u64);
 		p->tx_current_fill--;
 
 		spin_unlock_irqrestore(&p->tx_list.lock, flags);
@@ -221,7 +271,7 @@ static void octeon_mgmt_clean_tx_buffers(struct octeon_mgmt *p)
 		dev_kfree_skb_any(skb);
 		cleaned++;
 
-		mix_orcnt.u64 = cvmx_read_csr(CVMX_MIXX_ORCNT(port));
+		mix_orcnt.u64 = cvmx_read_csr(p->mix + MIX_ORCNT);
 	}
 
 	if (cleaned && netif_queue_stopped(p->netdev))
@@ -238,13 +288,12 @@ static void octeon_mgmt_clean_tx_tasklet(unsigned long arg)
 static void octeon_mgmt_update_rx_stats(struct net_device *netdev)
 {
 	struct octeon_mgmt *p = netdev_priv(netdev);
-	int port = p->port;
 	unsigned long flags;
 	u64 drop, bad;
 
 	/* These reads also clear the count registers.  */
-	drop = cvmx_read_csr(CVMX_AGL_GMX_RXX_STATS_PKTS_DRP(port));
-	bad = cvmx_read_csr(CVMX_AGL_GMX_RXX_STATS_PKTS_BAD(port));
+	drop = cvmx_read_csr(p->agl + AGL_GMX_RX_STATS_PKTS_DRP);
+	bad = cvmx_read_csr(p->agl + AGL_GMX_RX_STATS_PKTS_BAD);
 
 	if (drop || bad) {
 		/* Do an atomic update. */
@@ -258,15 +307,14 @@ static void octeon_mgmt_update_rx_stats(struct net_device *netdev)
 static void octeon_mgmt_update_tx_stats(struct net_device *netdev)
 {
 	struct octeon_mgmt *p = netdev_priv(netdev);
-	int port = p->port;
 	unsigned long flags;
 
 	union cvmx_agl_gmx_txx_stat0 s0;
 	union cvmx_agl_gmx_txx_stat1 s1;
 
 	/* These reads also clear the count registers.  */
-	s0.u64 = cvmx_read_csr(CVMX_AGL_GMX_TXX_STAT0(port));
-	s1.u64 = cvmx_read_csr(CVMX_AGL_GMX_TXX_STAT1(port));
+	s0.u64 = cvmx_read_csr(p->agl + AGL_GMX_TX_STAT0);
+	s1.u64 = cvmx_read_csr(p->agl + AGL_GMX_TX_STAT1);
 
 	if (s0.s.xsdef || s0.s.xscol || s1.s.scol || s1.s.mcol) {
 		/* Do an atomic update. */
@@ -305,7 +353,6 @@ static u64 octeon_mgmt_dequeue_rx_buffer(struct octeon_mgmt *p,
 
 static int octeon_mgmt_receive_one(struct octeon_mgmt *p)
 {
-	int port = p->port;
 	struct net_device *netdev = p->netdev;
 	union cvmx_mixx_ircnt mix_ircnt;
 	union mgmt_port_ring_entry re;
@@ -378,18 +425,17 @@ done:
 	/* Tell the hardware we processed a packet.  */
 	mix_ircnt.u64 = 0;
 	mix_ircnt.s.ircnt = 1;
-	cvmx_write_csr(CVMX_MIXX_IRCNT(port), mix_ircnt.u64);
+	cvmx_write_csr(p->mix + MIX_IRCNT, mix_ircnt.u64);
 	return rc;
 }
 
 static int octeon_mgmt_receive_packets(struct octeon_mgmt *p, int budget)
 {
-	int port = p->port;
 	unsigned int work_done = 0;
 	union cvmx_mixx_ircnt mix_ircnt;
 	int rc;
 
-	mix_ircnt.u64 = cvmx_read_csr(CVMX_MIXX_IRCNT(port));
+	mix_ircnt.u64 = cvmx_read_csr(p->mix + MIX_IRCNT);
 	while (work_done < budget && mix_ircnt.s.ircnt) {
 
 		rc = octeon_mgmt_receive_one(p);
@@ -397,7 +443,7 @@ static int octeon_mgmt_receive_packets(struct octeon_mgmt *p, int budget)
 			work_done++;
 
 		/* Check for more packets. */
-		mix_ircnt.u64 = cvmx_read_csr(CVMX_MIXX_IRCNT(port));
+		mix_ircnt.u64 = cvmx_read_csr(p->mix + MIX_IRCNT);
 	}
 
 	octeon_mgmt_rx_fill_ring(p->netdev);
@@ -431,16 +477,16 @@ static void octeon_mgmt_reset_hw(struct octeon_mgmt *p)
 	union cvmx_agl_gmx_bist agl_gmx_bist;
 
 	mix_ctl.u64 = 0;
-	cvmx_write_csr(CVMX_MIXX_CTL(p->port), mix_ctl.u64);
+	cvmx_write_csr(p->mix + MIX_CTL, mix_ctl.u64);
 	do {
-		mix_ctl.u64 = cvmx_read_csr(CVMX_MIXX_CTL(p->port));
+		mix_ctl.u64 = cvmx_read_csr(p->mix + MIX_CTL);
 	} while (mix_ctl.s.busy);
 	mix_ctl.s.reset = 1;
-	cvmx_write_csr(CVMX_MIXX_CTL(p->port), mix_ctl.u64);
-	cvmx_read_csr(CVMX_MIXX_CTL(p->port));
+	cvmx_write_csr(p->mix + MIX_CTL, mix_ctl.u64);
+	cvmx_read_csr(p->mix + MIX_CTL);
 	cvmx_wait(64);
 
-	mix_bist.u64 = cvmx_read_csr(CVMX_MIXX_BIST(p->port));
+	mix_bist.u64 = cvmx_read_csr(p->mix + MIX_BIST);
 	if (mix_bist.u64)
 		dev_warn(p->dev, "MIX failed BIST (0x%016llx)\n",
 			(unsigned long long)mix_bist.u64);
@@ -471,7 +517,6 @@ static void octeon_mgmt_cam_state_add(struct octeon_mgmt_cam_state *cs,
 static void octeon_mgmt_set_rx_filtering(struct net_device *netdev)
 {
 	struct octeon_mgmt *p = netdev_priv(netdev);
-	int port = p->port;
 	union cvmx_agl_gmx_rxx_adr_ctl adr_ctl;
 	union cvmx_agl_gmx_prtx_cfg agl_gmx_prtx;
 	unsigned long flags;
@@ -517,29 +562,29 @@ static void octeon_mgmt_set_rx_filtering(struct net_device *netdev)
 	spin_lock_irqsave(&p->lock, flags);
 
 	/* Disable packet I/O. */
-	agl_gmx_prtx.u64 = cvmx_read_csr(CVMX_AGL_GMX_PRTX_CFG(port));
+	agl_gmx_prtx.u64 = cvmx_read_csr(p->agl + AGL_GMX_PRT_CFG);
 	prev_packet_enable = agl_gmx_prtx.s.en;
 	agl_gmx_prtx.s.en = 0;
-	cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port), agl_gmx_prtx.u64);
+	cvmx_write_csr(p->agl + AGL_GMX_PRT_CFG, agl_gmx_prtx.u64);
 
 	adr_ctl.u64 = 0;
 	adr_ctl.s.cam_mode = cam_mode;
 	adr_ctl.s.mcst = multicast_mode;
 	adr_ctl.s.bcst = 1;     /* Allow broadcast */
 
-	cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CTL(port), adr_ctl.u64);
+	cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CTL, adr_ctl.u64);
 
-	cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM0(port), cam_state.cam[0]);
-	cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM1(port), cam_state.cam[1]);
-	cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM2(port), cam_state.cam[2]);
-	cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM3(port), cam_state.cam[3]);
-	cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM4(port), cam_state.cam[4]);
-	cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM5(port), cam_state.cam[5]);
-	cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM_EN(port), cam_state.cam_mask);
+	cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM0, cam_state.cam[0]);
+	cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM1, cam_state.cam[1]);
+	cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM2, cam_state.cam[2]);
+	cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM3, cam_state.cam[3]);
+	cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM4, cam_state.cam[4]);
+	cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM5, cam_state.cam[5]);
+	cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM_EN, cam_state.cam_mask);
 
 	/* Restore packet I/O. */
 	agl_gmx_prtx.s.en = prev_packet_enable;
-	cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port), agl_gmx_prtx.u64);
+	cvmx_write_csr(p->agl + AGL_GMX_PRT_CFG, agl_gmx_prtx.u64);
 
 	spin_unlock_irqrestore(&p->lock, flags);
 }
@@ -561,7 +606,6 @@ static int octeon_mgmt_set_mac_address(struct net_device *netdev, void *addr)
 static int octeon_mgmt_change_mtu(struct net_device *netdev, int new_mtu)
 {
 	struct octeon_mgmt *p = netdev_priv(netdev);
-	int port = p->port;
 	int size_without_fcs = new_mtu + OCTEON_MGMT_RX_HEADROOM;
 
 	/*
@@ -577,8 +621,8 @@ static int octeon_mgmt_change_mtu(struct net_device *netdev, int new_mtu)
 
 	netdev->mtu = new_mtu;
 
-	cvmx_write_csr(CVMX_AGL_GMX_RXX_FRM_MAX(port), size_without_fcs);
-	cvmx_write_csr(CVMX_AGL_GMX_RXX_JABBER(port),
+	cvmx_write_csr(p->agl + AGL_GMX_RX_FRM_MAX, size_without_fcs);
+	cvmx_write_csr(p->agl + AGL_GMX_RX_JABBER,
 		       (size_without_fcs + 7) & 0xfff8);
 
 	return 0;
@@ -588,14 +632,13 @@ static irqreturn_t octeon_mgmt_interrupt(int cpl, void *dev_id)
 {
 	struct net_device *netdev = dev_id;
 	struct octeon_mgmt *p = netdev_priv(netdev);
-	int port = p->port;
 	union cvmx_mixx_isr mixx_isr;
 
-	mixx_isr.u64 = cvmx_read_csr(CVMX_MIXX_ISR(port));
+	mixx_isr.u64 = cvmx_read_csr(p->mix + MIX_ISR);
 
 	/* Clear any pending interrupts */
-	cvmx_write_csr(CVMX_MIXX_ISR(port), mixx_isr.u64);
-	cvmx_read_csr(CVMX_MIXX_ISR(port));
+	cvmx_write_csr(p->mix + MIX_ISR, mixx_isr.u64);
+	cvmx_read_csr(p->mix + MIX_ISR);
 
 	if (mixx_isr.s.irthresh) {
 		octeon_mgmt_disable_rx_irq(p);
@@ -626,7 +669,6 @@ static int octeon_mgmt_ioctl(struct net_device *netdev,
 static void octeon_mgmt_adjust_link(struct net_device *netdev)
 {
 	struct octeon_mgmt *p = netdev_priv(netdev);
-	int port = p->port;
 	union cvmx_agl_gmx_prtx_cfg prtx_cfg;
 	unsigned long flags;
 	int link_changed = 0;
@@ -637,11 +679,9 @@ static void octeon_mgmt_adjust_link(struct net_device *netdev)
 			link_changed = 1;
 		if (p->last_duplex != p->phydev->duplex) {
 			p->last_duplex = p->phydev->duplex;
-			prtx_cfg.u64 =
-				cvmx_read_csr(CVMX_AGL_GMX_PRTX_CFG(port));
+			prtx_cfg.u64 = cvmx_read_csr(p->agl + AGL_GMX_PRT_CFG);
 			prtx_cfg.s.duplex = p->phydev->duplex;
-			cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port),
-				       prtx_cfg.u64);
+			cvmx_write_csr(p->agl + AGL_GMX_PRT_CFG, prtx_cfg.u64);
 		}
 	} else {
 		if (p->last_link)
@@ -667,18 +707,16 @@ static void octeon_mgmt_adjust_link(struct net_device *netdev)
 static int octeon_mgmt_init_phy(struct net_device *netdev)
 {
 	struct octeon_mgmt *p = netdev_priv(netdev);
-	char phy_id[20];
 
-	if (octeon_is_simulation()) {
+	if (octeon_is_simulation() || p->phy_np == NULL) {
 		/* No PHYs in the simulator. */
 		netif_carrier_on(netdev);
 		return 0;
 	}
 
-	snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT, "0", p->port);
-
-	p->phydev = phy_connect(netdev, phy_id, octeon_mgmt_adjust_link, 0,
-				PHY_INTERFACE_MODE_MII);
+	p->phydev = of_phy_connect(netdev, p->phy_np,
+				   octeon_mgmt_adjust_link, 0,
+				   PHY_INTERFACE_MODE_MII);
 
 	if (IS_ERR(p->phydev)) {
 		p->phydev = NULL;
@@ -734,14 +772,14 @@ static int octeon_mgmt_open(struct net_device *netdev)
 
 	octeon_mgmt_reset_hw(p);
 
-	mix_ctl.u64 = cvmx_read_csr(CVMX_MIXX_CTL(port));
+	mix_ctl.u64 = cvmx_read_csr(p->mix + MIX_CTL);
 
 	/* Bring it out of reset if needed. */
 	if (mix_ctl.s.reset) {
 		mix_ctl.s.reset = 0;
-		cvmx_write_csr(CVMX_MIXX_CTL(port), mix_ctl.u64);
+		cvmx_write_csr(p->mix + MIX_CTL, mix_ctl.u64);
 		do {
-			mix_ctl.u64 = cvmx_read_csr(CVMX_MIXX_CTL(port));
+			mix_ctl.u64 = cvmx_read_csr(p->mix + MIX_CTL);
 		} while (mix_ctl.s.reset);
 	}
 
@@ -752,17 +790,17 @@ static int octeon_mgmt_open(struct net_device *netdev)
 	oring1.u64 = 0;
 	oring1.s.obase = p->tx_ring_handle >> 3;
 	oring1.s.osize = OCTEON_MGMT_TX_RING_SIZE;
-	cvmx_write_csr(CVMX_MIXX_ORING1(port), oring1.u64);
+	cvmx_write_csr(p->mix + MIX_ORING1, oring1.u64);
 
 	iring1.u64 = 0;
 	iring1.s.ibase = p->rx_ring_handle >> 3;
 	iring1.s.isize = OCTEON_MGMT_RX_RING_SIZE;
-	cvmx_write_csr(CVMX_MIXX_IRING1(port), iring1.u64);
+	cvmx_write_csr(p->mix + MIX_IRING1, iring1.u64);
 
 	/* Disable packet I/O. */
-	prtx_cfg.u64 = cvmx_read_csr(CVMX_AGL_GMX_PRTX_CFG(port));
+	prtx_cfg.u64 = cvmx_read_csr(p->agl + AGL_GMX_PRT_CFG);
 	prtx_cfg.s.en = 0;
-	cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port), prtx_cfg.u64);
+	cvmx_write_csr(p->agl + AGL_GMX_PRT_CFG, prtx_cfg.u64);
 
 	memcpy(sa.sa_data, netdev->dev_addr, ETH_ALEN);
 	octeon_mgmt_set_mac_address(netdev, &sa);
@@ -779,7 +817,7 @@ static int octeon_mgmt_open(struct net_device *netdev)
 	mix_ctl.s.nbtarb = 0;       /* Arbitration mode */
 	/* MII CB-request FIFO programmable high watermark */
 	mix_ctl.s.mrq_hwm = 1;
-	cvmx_write_csr(CVMX_MIXX_CTL(port), mix_ctl.u64);
+	cvmx_write_csr(p->mix + MIX_CTL, mix_ctl.u64);
 
 	if (OCTEON_IS_MODEL(OCTEON_CN56XX_PASS1_X)
 	    || OCTEON_IS_MODEL(OCTEON_CN52XX_PASS1_X)) {
@@ -806,16 +844,16 @@ static int octeon_mgmt_open(struct net_device *netdev)
 
 	/* Clear statistics. */
 	/* Clear on read. */
-	cvmx_write_csr(CVMX_AGL_GMX_RXX_STATS_CTL(port), 1);
-	cvmx_write_csr(CVMX_AGL_GMX_RXX_STATS_PKTS_DRP(port), 0);
-	cvmx_write_csr(CVMX_AGL_GMX_RXX_STATS_PKTS_BAD(port), 0);
+	cvmx_write_csr(p->agl + AGL_GMX_RX_STATS_CTL, 1);
+	cvmx_write_csr(p->agl + AGL_GMX_RX_STATS_PKTS_DRP, 0);
+	cvmx_write_csr(p->agl + AGL_GMX_RX_STATS_PKTS_BAD, 0);
 
-	cvmx_write_csr(CVMX_AGL_GMX_TXX_STATS_CTL(port), 1);
-	cvmx_write_csr(CVMX_AGL_GMX_TXX_STAT0(port), 0);
-	cvmx_write_csr(CVMX_AGL_GMX_TXX_STAT1(port), 0);
+	cvmx_write_csr(p->agl + AGL_GMX_TX_STATS_CTL, 1);
+	cvmx_write_csr(p->agl + AGL_GMX_TX_STAT0, 0);
+	cvmx_write_csr(p->agl + AGL_GMX_TX_STAT1, 0);
 
 	/* Clear any pending interrupts */
-	cvmx_write_csr(CVMX_MIXX_ISR(port), cvmx_read_csr(CVMX_MIXX_ISR(port)));
+	cvmx_write_csr(p->mix + MIX_ISR, cvmx_read_csr(p->mix + MIX_ISR));
 
 	if (request_irq(p->irq, octeon_mgmt_interrupt, 0, netdev->name,
 			netdev)) {
@@ -826,18 +864,18 @@ static int octeon_mgmt_open(struct net_device *netdev)
 	/* Interrupt every single RX packet */
 	mix_irhwm.u64 = 0;
 	mix_irhwm.s.irhwm = 0;
-	cvmx_write_csr(CVMX_MIXX_IRHWM(port), mix_irhwm.u64);
+	cvmx_write_csr(p->mix + MIX_IRHWM, mix_irhwm.u64);
 
 	/* Interrupt when we have 1 or more packets to clean.  */
 	mix_orhwm.u64 = 0;
 	mix_orhwm.s.orhwm = 1;
-	cvmx_write_csr(CVMX_MIXX_ORHWM(port), mix_orhwm.u64);
+	cvmx_write_csr(p->mix + MIX_ORHWM, mix_orhwm.u64);
 
 	/* Enable receive and transmit interrupts */
 	mix_intena.u64 = 0;
 	mix_intena.s.ithena = 1;
 	mix_intena.s.othena = 1;
-	cvmx_write_csr(CVMX_MIXX_INTENA(port), mix_intena.u64);
+	cvmx_write_csr(p->mix + MIX_INTENA, mix_intena.u64);
 
 
 	/* Enable packet I/O. */
@@ -868,7 +906,7 @@ static int octeon_mgmt_open(struct net_device *netdev)
 	 * frame.  GMX checks that the PREAMBLE is sent correctly.
 	 */
 	rxx_frm_ctl.s.pre_chk = 1;
-	cvmx_write_csr(CVMX_AGL_GMX_RXX_FRM_CTL(port), rxx_frm_ctl.u64);
+	cvmx_write_csr(p->agl + AGL_GMX_RX_FRM_CTL, rxx_frm_ctl.u64);
 
 	/* Enable the AGL block */
 	agl_gmx_inf_mode.u64 = 0;
@@ -876,13 +914,13 @@ static int octeon_mgmt_open(struct net_device *netdev)
 	cvmx_write_csr(CVMX_AGL_GMX_INF_MODE, agl_gmx_inf_mode.u64);
 
 	/* Configure the port duplex and enables */
-	prtx_cfg.u64 = cvmx_read_csr(CVMX_AGL_GMX_PRTX_CFG(port));
+	prtx_cfg.u64 = cvmx_read_csr(p->agl + AGL_GMX_PRT_CFG);
 	prtx_cfg.s.tx_en = 1;
 	prtx_cfg.s.rx_en = 1;
 	prtx_cfg.s.en = 1;
 	p->last_duplex = 1;
 	prtx_cfg.s.duplex = p->last_duplex;
-	cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port), prtx_cfg.u64);
+	cvmx_write_csr(p->agl + AGL_GMX_PRT_CFG, prtx_cfg.u64);
 
 	p->last_link = 0;
 	netif_carrier_off(netdev);
@@ -946,7 +984,6 @@ static int octeon_mgmt_stop(struct net_device *netdev)
 static int octeon_mgmt_xmit(struct sk_buff *skb, struct net_device *netdev)
 {
 	struct octeon_mgmt *p = netdev_priv(netdev);
-	int port = p->port;
 	union mgmt_port_ring_entry re;
 	unsigned long flags;
 	int rv = NETDEV_TX_BUSY;
@@ -990,7 +1027,7 @@ static int octeon_mgmt_xmit(struct sk_buff *skb, struct net_device *netdev)
 	netdev->stats.tx_bytes += skb->len;
 
 	/* Ring the bell.  */
-	cvmx_write_csr(CVMX_MIXX_ORING2(port), 1);
+	cvmx_write_csr(p->mix + MIX_ORING2, 1);
 
 	rv = NETDEV_TX_OK;
 out:
@@ -1067,12 +1104,14 @@ static const struct net_device_ops octeon_mgmt_ops = {
 #endif
 };
 
-static int __devinit octeon_mgmt_probe(struct platform_device *pdev)
+static int __devinit octeon_mgmt_probe(struct platform_device *pdev,
+				       const struct of_device_id *match)
 {
-	struct resource *res_irq;
 	struct net_device *netdev;
 	struct octeon_mgmt *p;
-	int i;
+	const __be32 *data;
+	const u8 *mac;
+	int len;
 
 	netdev = alloc_etherdev(sizeof(struct octeon_mgmt));
 	if (netdev == NULL)
@@ -1086,14 +1125,21 @@ static int __devinit octeon_mgmt_probe(struct platform_device *pdev)
 	p->netdev = netdev;
 	p->dev = &pdev->dev;
 
-	p->port = pdev->id;
+	data = of_get_property(pdev->dev.of_node, "unit-number", &len);
+	if (data && len == sizeof(*data))
+		p->port = be32_to_cpup(data);
+	else
+		p->port = 0;
+
 	snprintf(netdev->name, IFNAMSIZ, "mgmt%d", p->port);
 
-	res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (!res_irq)
+	p->irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
+	if (!p->irq)
 		goto err;
 
-	p->irq = res_irq->start;
+	p->mix = (u64)of_iomap(pdev->dev.of_node, 0);
+	p->agl = (u64)of_iomap(pdev->dev.of_node, 1);
+
 	spin_lock_init(&p->lock);
 
 	skb_queue_head_init(&p->tx_list);
@@ -1104,15 +1150,15 @@ static int __devinit octeon_mgmt_probe(struct platform_device *pdev)
 	netdev->netdev_ops = &octeon_mgmt_ops;
 	netdev->ethtool_ops = &octeon_mgmt_ethtool_ops;
 
-	/* The mgmt ports get the first N MACs.  */
-	for (i = 0; i < 6; i++)
-		netdev->dev_addr[i] = octeon_bootinfo->mac_addr_base[i];
-	netdev->dev_addr[5] += p->port;
+	mac = of_get_mac_address(pdev->dev.of_node);
+
+	if (mac)
+		memcpy(netdev->dev_addr, mac, 6);
 
-	if (p->port >= octeon_bootinfo->mac_addr_count)
-		dev_err(&pdev->dev,
-			"Error %s: Using MAC outside of the assigned range: %pM\n",
-			netdev->name, netdev->dev_addr);
+	p->phy_np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
+
+	pdev->dev.coherent_dma_mask = DMA_BIT_MASK(64);
+	pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
 
 	if (register_netdev(netdev))
 		goto err;
@@ -1133,10 +1179,19 @@ static int __devexit octeon_mgmt_remove(struct platform_device *pdev)
 	return 0;
 }
 
-static struct platform_driver octeon_mgmt_driver = {
+static struct of_device_id octeon_mgmt_match[] = {
+	{
+		.compatible = "octeon,mgmt",
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, octeon_mgmt_match);
+
+static struct of_platform_driver octeon_mgmt_driver = {
 	.driver = {
 		.name		= "octeon_mgmt",
 		.owner		= THIS_MODULE,
+		.of_match_table = octeon_mgmt_match,
 	},
 	.probe		= octeon_mgmt_probe,
 	.remove		= __devexit_p(octeon_mgmt_remove),
@@ -1148,12 +1203,12 @@ static int __init octeon_mgmt_mod_init(void)
 {
 	/* Force our mdiobus driver module to be loaded first. */
 	octeon_mdiobus_force_mod_depencency();
-	return platform_driver_register(&octeon_mgmt_driver);
+	return of_register_platform_driver(&octeon_mgmt_driver);
 }
 
 static void __exit octeon_mgmt_mod_exit(void)
 {
-	platform_driver_unregister(&octeon_mgmt_driver);
+	of_unregister_platform_driver(&octeon_mgmt_driver);
 }
 
 module_init(octeon_mgmt_mod_init);
-- 
1.7.2.3

^ permalink raw reply related

* [RFC PATCH 08/10] netdev: mdio-octeon.c: Convert to use device tree.
From: David Daney @ 2011-02-22 20:57 UTC (permalink / raw)
  To: linux-mips-6z/3iImG2C8G8FEW9MqTrA, ralf-6z/3iImG2C8G8FEW9MqTrA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	grant.likely-s3s/WqlpOiPyB63q8FvJNQ,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, David Daney, David S. Miller
In-Reply-To: <1298408274-20856-1-git-send-email-ddaney-M3mlKVOIwJVv6pq1l3V1OdBPR1lH4CV8@public.gmane.org>

Get the MDIO bus controller addresses from the device tree.

Signed-off-by: David Daney <ddaney-M3mlKVOIwJVv6pq1l3V1OdBPR1lH4CV8@public.gmane.org>
Cc: "David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
---
 arch/mips/cavium-octeon/octeon-platform.c |   30 ------------
 drivers/net/phy/mdio-octeon.c             |   73 +++++++++++++++++------------
 2 files changed, 43 insertions(+), 60 deletions(-)

diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c
index f148324..a33dcf9 100644
--- a/arch/mips/cavium-octeon/octeon-platform.c
+++ b/arch/mips/cavium-octeon/octeon-platform.c
@@ -166,36 +166,6 @@ out:
 }
 device_initcall(octeon_rng_device_init);
 
-/* Octeon SMI/MDIO interface.  */
-static int __init octeon_mdiobus_device_init(void)
-{
-	struct platform_device *pd;
-	int ret = 0;
-
-	if (octeon_is_simulation())
-		return 0; /* No mdio in the simulator. */
-
-	/* The bus number is the platform_device id.  */
-	pd = platform_device_alloc("mdio-octeon", 0);
-	if (!pd) {
-		ret = -ENOMEM;
-		goto out;
-	}
-
-	ret = platform_device_add(pd);
-	if (ret)
-		goto fail;
-
-	return ret;
-fail:
-	platform_device_put(pd);
-
-out:
-	return ret;
-
-}
-device_initcall(octeon_mdiobus_device_init);
-
 /* Octeon mgmt port Ethernet interface.  */
 static int __init octeon_mgmt_device_init(void)
 {
diff --git a/drivers/net/phy/mdio-octeon.c b/drivers/net/phy/mdio-octeon.c
index bd12ba9..b04c18c 100644
--- a/drivers/net/phy/mdio-octeon.c
+++ b/drivers/net/phy/mdio-octeon.c
@@ -6,10 +6,14 @@
  * Copyright (C) 2009 Cavium Networks
  */
 
-#include <linux/gfp.h>
-#include <linux/init.h>
-#include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/of_platform.h>
+#include <linux/of_address.h>
+#include <linux/of_mdio.h>
+#include <linux/delay.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/gfp.h>
 #include <linux/phy.h>
 
 #include <asm/octeon/octeon.h>
@@ -18,9 +22,15 @@
 #define DRV_VERSION "1.0"
 #define DRV_DESCRIPTION "Cavium Networks Octeon SMI/MDIO driver"
 
+#define SMI_CMD		0x0
+#define SMI_WR_DAT	0x8
+#define SMI_RD_DAT	0x10
+#define SMI_CLK		0x18
+#define SMI_EN		0x20
+
 struct octeon_mdiobus {
 	struct mii_bus *mii_bus;
-	int unit;
+	u64 register_base;
 	int phy_irq[PHY_MAX_ADDR];
 };
 
@@ -35,15 +45,15 @@ static int octeon_mdiobus_read(struct mii_bus *bus, int phy_id, int regnum)
 	smi_cmd.s.phy_op = 1; /* MDIO_CLAUSE_22_READ */
 	smi_cmd.s.phy_adr = phy_id;
 	smi_cmd.s.reg_adr = regnum;
-	cvmx_write_csr(CVMX_SMIX_CMD(p->unit), smi_cmd.u64);
+	cvmx_write_csr(p->register_base + SMI_CMD, smi_cmd.u64);
 
 	do {
 		/*
 		 * Wait 1000 clocks so we don't saturate the RSL bus
 		 * doing reads.
 		 */
-		cvmx_wait(1000);
-		smi_rd.u64 = cvmx_read_csr(CVMX_SMIX_RD_DAT(p->unit));
+		__delay(1000);
+		smi_rd.u64 = cvmx_read_csr(p->register_base + SMI_RD_DAT);
 	} while (smi_rd.s.pending && --timeout);
 
 	if (smi_rd.s.val)
@@ -62,21 +72,21 @@ static int octeon_mdiobus_write(struct mii_bus *bus, int phy_id,
 
 	smi_wr.u64 = 0;
 	smi_wr.s.dat = val;
-	cvmx_write_csr(CVMX_SMIX_WR_DAT(p->unit), smi_wr.u64);
+	cvmx_write_csr(p->register_base + SMI_WR_DAT, smi_wr.u64);
 
 	smi_cmd.u64 = 0;
 	smi_cmd.s.phy_op = 0; /* MDIO_CLAUSE_22_WRITE */
 	smi_cmd.s.phy_adr = phy_id;
 	smi_cmd.s.reg_adr = regnum;
-	cvmx_write_csr(CVMX_SMIX_CMD(p->unit), smi_cmd.u64);
+	cvmx_write_csr(p->register_base + SMI_CMD, smi_cmd.u64);
 
 	do {
 		/*
 		 * Wait 1000 clocks so we don't saturate the RSL bus
 		 * doing reads.
 		 */
-		cvmx_wait(1000);
-		smi_wr.u64 = cvmx_read_csr(CVMX_SMIX_WR_DAT(p->unit));
+		__delay(1000);
+		smi_wr.u64 = cvmx_read_csr(p->register_base + SMI_WR_DAT);
 	} while (smi_wr.s.pending && --timeout);
 
 	if (timeout <= 0)
@@ -85,11 +95,11 @@ static int octeon_mdiobus_write(struct mii_bus *bus, int phy_id,
 	return 0;
 }
 
-static int __devinit octeon_mdiobus_probe(struct platform_device *pdev)
+static int __devinit octeon_mdiobus_probe(struct platform_device *pdev,
+					  const struct of_device_id *match)
 {
 	struct octeon_mdiobus *bus;
 	union cvmx_smix_en smi_en;
-	int i;
 	int err = -ENOENT;
 
 	bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL);
@@ -97,8 +107,7 @@ static int __devinit octeon_mdiobus_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	/* The platform_device id is our unit number.  */
-	bus->unit = pdev->id;
-
+	bus->register_base = (u64)of_iomap(pdev->dev.of_node, 0);
 	bus->mii_bus = mdiobus_alloc();
 
 	if (!bus->mii_bus)
@@ -106,19 +115,13 @@ static int __devinit octeon_mdiobus_probe(struct platform_device *pdev)
 
 	smi_en.u64 = 0;
 	smi_en.s.en = 1;
-	cvmx_write_csr(CVMX_SMIX_EN(bus->unit), smi_en.u64);
+	cvmx_write_csr(bus->register_base + SMI_EN, smi_en.u64);
 
-	/*
-	 * Standard Octeon evaluation boards don't support phy
-	 * interrupts, we need to poll.
-	 */
-	for (i = 0; i < PHY_MAX_ADDR; i++)
-		bus->phy_irq[i] = PHY_POLL;
 
 	bus->mii_bus->priv = bus;
 	bus->mii_bus->irq = bus->phy_irq;
 	bus->mii_bus->name = "mdio-octeon";
-	snprintf(bus->mii_bus->id, MII_BUS_ID_SIZE, "%x", bus->unit);
+	snprintf(bus->mii_bus->id, MII_BUS_ID_SIZE, "%llx", bus->register_base);
 	bus->mii_bus->parent = &pdev->dev;
 
 	bus->mii_bus->read = octeon_mdiobus_read;
@@ -126,7 +129,7 @@ static int __devinit octeon_mdiobus_probe(struct platform_device *pdev)
 
 	dev_set_drvdata(&pdev->dev, bus);
 
-	err = mdiobus_register(bus->mii_bus);
+	err = of_mdiobus_register(bus->mii_bus, pdev->dev.of_node);
 	if (err)
 		goto err_register;
 
@@ -137,9 +140,9 @@ err_register:
 	mdiobus_free(bus->mii_bus);
 
 err:
-	devm_kfree(&pdev->dev, bus);
 	smi_en.u64 = 0;
-	cvmx_write_csr(CVMX_SMIX_EN(bus->unit), smi_en.u64);
+	cvmx_write_csr(bus->register_base + SMI_EN, smi_en.u64);
+	devm_kfree(&pdev->dev, bus);
 	return err;
 }
 
@@ -153,14 +156,24 @@ static int __devexit octeon_mdiobus_remove(struct platform_device *pdev)
 	mdiobus_unregister(bus->mii_bus);
 	mdiobus_free(bus->mii_bus);
 	smi_en.u64 = 0;
-	cvmx_write_csr(CVMX_SMIX_EN(bus->unit), smi_en.u64);
+	cvmx_write_csr(bus->register_base + SMI_EN, smi_en.u64);
+	devm_kfree(&pdev->dev, bus);
 	return 0;
 }
 
-static struct platform_driver octeon_mdiobus_driver = {
+static struct of_device_id octeon_mdiobus_match[] = {
+	{
+		.compatible = "octeon,mdio",
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, octeon_mdiobus_match);
+
+static struct of_platform_driver octeon_mdiobus_driver = {
 	.driver = {
 		.name		= "mdio-octeon",
 		.owner		= THIS_MODULE,
+		.of_match_table = octeon_mdiobus_match,
 	},
 	.probe		= octeon_mdiobus_probe,
 	.remove		= __devexit_p(octeon_mdiobus_remove),
@@ -174,12 +187,12 @@ EXPORT_SYMBOL(octeon_mdiobus_force_mod_depencency);
 
 static int __init octeon_mdiobus_mod_init(void)
 {
-	return platform_driver_register(&octeon_mdiobus_driver);
+	return of_register_platform_driver(&octeon_mdiobus_driver);
 }
 
 static void __exit octeon_mdiobus_mod_exit(void)
 {
-	platform_driver_unregister(&octeon_mdiobus_driver);
+	of_unregister_platform_driver(&octeon_mdiobus_driver);
 }
 
 module_init(octeon_mdiobus_mod_init);
-- 
1.7.2.3

^ permalink raw reply related

* Re: [ethtool PATCH 2/2] Add RX packet classification interface
From: Alexander Duyck @ 2011-02-22 20:52 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: Santwona Behera, netdev@vger.kernel.org
In-Reply-To: <1298302841.2608.35.camel@bwh-desktop>

I've included my response to your comments below.

Thanks,

Alex

On 2/21/2011 7:40 AM, Ben Hutchings wrote:
> On Thu, 2011-02-10 at 17:18 -0800, Alexander Duyck wrote:
>> From: Santwona Behera<santwona.behera@sun.com>
>>
>> This patch was originally introduced as:
>>    [PATCH 1/3] [ethtool] Add rx pkt classification interface
>>    Signed-off-by: Santwona Behera<santwona.behera@sun.com>
>>    http://patchwork.ozlabs.org/patch/23223/
>>
>> I have updated it to address a number of issues.  As a result I removed the
>> local caching of rules due to the fact that there were memory leaks in this
>> code and the rule manager would consume over 1Mb of space for an 8K table
>> when all that was needed was 1K in order to store which rules were active
>> and which were not.
>>
>> In addition I dropped the use of regions as there were multiple issue found
>> including the fact that the regions were not properly expanding beyond 2
>> and the fact that the regions required reading all of the rules in order to
>> correctly expand beyond 2.  By dropping the regions from the rule manager
>> it is possible to write a much cleaner interface leaving region management
>> to be done by either the driver or by external management scripts.
>>
>> I also added an ethtool bitops interface to allow for simple bit set and
>> test activities since the rule manager can most efficiently store the list
>> of active rules via a bitmap.
> [...]
>> diff --git a/ethtool-bitops.h b/ethtool-bitops.h
>> new file mode 100644
>> index 0000000..7101056
>> --- /dev/null
>> +++ b/ethtool-bitops.h
>> @@ -0,0 +1,25 @@
>> +#ifndef ETHTOOL_BITOPS_H__
>> +#define ETHTOOL_BITOPS_H__
>> +
>> +#define BITS_PER_LONG                __WORDSIZE
>
> This seems to be a glibc-internal macro and I don't think we should use
> it.
>
>> +#define BITS_PER_BYTE                8
>> +#define DIV_ROUND_UP(n, d)   (((n) + (d) - 1) / (d))
>> +#define BITS_TO_LONGS(nr)    DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
>
> In fact I notice you don't use it here...

Yeah, as I recall I don't think I trusted that definition of 
BITS_PER_LONG all that much anyway.  I will replace it with 
BITS_PER_BYTE * sizeof(long).

>> +static inline void set_bit(int nr, unsigned long *addr)
>> +{
>> +     addr[nr / BITS_PER_LONG] |= 1UL<<  (nr % BITS_PER_LONG);
>> +}
>> +
>> +static inline void clear_bit(int nr, unsigned long *addr)
>> +{
>> +     addr[nr / BITS_PER_LONG]&= ~(1UL<<  (nr % BITS_PER_LONG));
>> +}
>> +
>> +static __always_inline int test_bit(unsigned int nr, const unsigned long *addr)
>> +{
>> +     return ((1UL<<  (nr % BITS_PER_LONG))&
>> +             (((unsigned long *)addr)[nr / BITS_PER_LONG])) != 0UL;
>> +}
>> +
>> +#endif
>> diff --git a/ethtool-util.h b/ethtool-util.h
>> index f053028..e9300e2 100644
>> --- a/ethtool-util.h
>> +++ b/ethtool-util.h
>> @@ -103,4 +103,17 @@ int sfc_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
>>   int st_mac100_dump_regs(struct ethtool_drvinfo *info,
>>                        struct ethtool_regs *regs);
>>   int st_gmac_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
>> +
>> +/* Rx flow classification */
>> +#include<sys/ioctl.h>
>> +#include<net/if.h>
>
> Put #includes at the top of the file, please.

That will be updated in the next patch.

>> +int rxclass_parse_ruleopts(char **optstr, int opt_cnt,
>> +                        struct ethtool_rx_flow_spec *fsp, __u8 *loc_valid);
>> +int rxclass_rule_getall(int fd, struct ifreq *ifr);
>> +int rxclass_rule_get(int fd, struct ifreq *ifr, __u32 loc);
>> +int rxclass_rule_ins(int fd, struct ifreq *ifr,
>> +                  struct ethtool_rx_flow_spec *fsp, __u8 loc_valid);
>> +int rxclass_rule_del(int fd, struct ifreq *ifr, __u32 loc);
>> +
>>   #endif
>> diff --git a/ethtool.8.in b/ethtool.8.in
>> index 133825b..c183a3d 100644
>> --- a/ethtool.8.in
>> +++ b/ethtool.8.in
>> @@ -40,21 +40,36 @@
>>   [\\fB\\$1\\fP\ \\fIN\\fP]
>>   ..
>>   .\"
>> +.\"  .BM - same as above but has a mask field for format "[value N [m N]]"
>> +.\"
>> +.de BM
>> +[\\fB\\$1\\fP\ \\fIN\\fP\ [\\fBm\\fP\ \\fIN\\fP]]
>> +..
>> +.\"
>>   .\"  \(*MA - mac address
>>   .\"
>>   .ds MA \fIxx\fP\fB:\fP\fIyy\fP\fB:\fP\fIzz\fP\fB:\fP\fIaa\fP\fB:\fP\fIbb\fP\fB:\fP\fIcc\fP
>>   .\"
>> +.\"  \(*PA - IP address
>> +.\"
>> +.ds PA \fIx\fP\fB.\fP\fIx\fP\fB.\fP\fIx\fP\fB.\fP\fIx\fP
>> +.\"
>>   .\"  \(*WO - wol flags
>>   .\"
>>   .ds WO \fBp\fP|\fBu\fP|\fBm\fP|\fBb\fP|\fBa\fP|\fBg\fP|\fBs\fP|\fBd\fP...
>>   .\"
>>   .\"  \(*FL - flow type values
>>   .\"
>> -.ds FL \fBtcp4\fP|\fBudp4\fP|\fBah4\fP|\fBsctp4\fP|\fBtcp6\fP|\fBudp6\fP|\fBah6\fP|\fBsctp6\fP
>> +.ds FL \fBtcp4\fP|\fBudp4\fP|\fBah4\fP||\fBesp4\fP|\fBsctp4\fP|\fBtcp6\fP|\fBudp6\fP|\fBah6\fP|\fBesp6\fP|\fBsctp6\fP
>
> This adds two '|' characters between 'ah4' and 'esp4'.

I'll have this fixed for the next patch.

>>   .\"
>>   .\"  \(*HO - hash options
>>   .\"
>>   .ds HO \fBm\fP|\fBv\fP|\fBt\fP|\fBs\fP|\fBd\fP|\fBf\fP|\fBn\fP|\fBr\fP...
>> +.\"
>> +.\"  \(*L4 - L4 proto options
>> +.\"
>> +.ds L4 \fBtcp\fP|\fBudp\fP|\fBsctp\fP|\fBah\fP|\fBesp\fP|\fIN\fP
>> +.\"
>>   .\" Start URL.
>>   .de UR
>>   .  ds m1 \\$1\"
>> @@ -224,11 +239,27 @@ ethtool \- query or control network driver and hardware settings
>>   .B ethtool \-n
>>   .I ethX
>>   .RB [ rx-flow-hash \ \*(FL]
>> +.RB [ rx-rings ]
>> +.RB [ rx-class-rule-all ]
>> +.RB [ rx-class-rule
>> +.IR N ]
>
> Should use '.BN'.

It'll be in the next patch.

> [...]
>> diff --git a/ethtool.c b/ethtool.c
>> index 1afdfe4..b624980 100644
>> --- a/ethtool.c
>> +++ b/ethtool.c
>> @@ -6,6 +6,7 @@
>>    * Kernel 2.4 update Copyright 2001 Jeff Garzik<jgarzik@mandrakesoft.com>
>>    * Wake-on-LAN,natsemi,misc support by Tim Hockin<thockin@sun.com>
>>    * Portions Copyright 2002 Intel
>> + * Portions Copyright (C) Sun Microsystems 2008
>>    * do_test support by Eli Kupermann<eli.kupermann@intel.com>
>>    * ETHTOOL_PHYS_ID support by Chris Leech<christopher.leech@intel.com>
>>    * e1000 support by Scott Feldman<scott.feldman@intel.com>
>> @@ -14,6 +15,7 @@
>>    * amd8111e support by Reeja John<reeja.john@amd.com>
>>    * long arguments by Andi Kleen.
>>    * SMSC LAN911x support by Steve Glendinning<steve.glendinning@smsc.com>
>> + * Rx Network Flow Control configuration support<santwona.behera@sun.com>
>>    * Various features by Ben Hutchings<bhutchings@solarflare.com>;
>>    *   Copyright 2009, 2010 Solarflare Communications
>>    *
>> @@ -32,7 +34,7 @@
>>   #include<sys/ioctl.h>
>>   #include<sys/stat.h>
>>   #include<stdio.h>
>> -#include<string.h>
>> +#include<strings.h>
>
> No,<string.h>  is standard.

That's fine.  The original patch included this so I just carried it 
forward.  However there are two includes of string.h in this file so 
odds are the second one can just be dropped then.

> [...]
>> @@ -408,6 +425,14 @@ static int msglvl_changed;
>>   static u32 msglvl_wanted = 0;
>>   static u32 msglvl_mask = 0;
>>
>> +static int rx_rings_get = 0;
>> +static int rx_class_rule_get = -1;
>> +static int rx_class_rule_getall = 0;
>> +static int rx_class_rule_del = -1;
>> +static int rx_class_rule_added = 0;
>> +static struct ethtool_rx_flow_spec rx_rule_fs;
>> +static u8 rxclass_loc_valid = 0;
>> +
>>   static enum {
>>        ONLINE=0,
>>        OFFLINE,
> [...]
>> @@ -945,6 +974,23 @@ static void parse_cmdline(int argc, char **argp)
>>                                                rxflow_str_to_type(argp[i]);
>>                                        if (!rx_fhash_get)
>>                                                show_usage(1);
>> +                             } else if (!strcmp(argp[i], "rx-rings")) {
>> +                                     i += 1;
>> +                                     rx_rings_get = 1;
>
> I'm not convinced of the value of a separate rx-rings option/keyword.
> However it's probably worth displaying the number of rings/queues when
> showing other flow hashing and steering/filtering information (the -x
> option does this).

My thought was that it would be useful for determining the number of 
rings prior to adding a rule.  Especially if we have any kind of scripts 
running on top of ethtool so that we can avoid rules that will fail due 
to ring values being greater than the actual number of rings.  I might 
try looking into adding it to the display options for the filters.

>> +                             } else if (!strcmp(argp[i],
>> +                                                "rx-class-rule-all")) {
>> +                                     i += 1;
>> +                                     rx_class_rule_getall = 1;
>> +                             } else if (!strcmp(argp[i], "rx-class-rule")) {
>> +                                     i += 1;
>> +                                     if (i>= argc) {
>> +                                             show_usage(1);
>> +                                             break;
>> +                                     }
>> +                                     rx_class_rule_get =
>> +                                             strtol(argp[i], NULL, 0);
>> +                                     if (rx_class_rule_get<  0)
>> +                                             show_usage(1);
>
> Use get_uint_range(argp[i], 0, INT_MAX).

It'll be in the next patch.

>>                                } else
>>                                        show_usage(1);
>>                                break;
>
> I don't think the same options (-n, -N) should be used both for flow
> hashing and n-tuple flow steering/filtering.  This command-line
> interface and the structure used in the ethtool API just seem to reflect
> the implementation in the niu driver.
>
> (In fact I would much prefer it if the -u and -U options could be used
> for both the rxnfc and rxntuple interfaces.  But I haven't thought about
> how the differences in functionality would be exposed to or hidden from
> the user.)

I was kind of thinking about merging the two interfaces too, but I was 
looking at it more from the perspective of moving away from ntuple more 
towards this newer interface.  My main motivation being that the filter 
display option is so badly broken for ntuple that it would be easier to 
make ntuple a subset of the flow classifier instead of the other way around.

What would you think of using the "flow-type" keyword to indicate legacy 
ntuple support, and then adding something like "class-rule-add", and 
"class-rule-del" to add support for the network flow classifier calls?

Then for display we could add "ntuple-all", "class-rule-all", and 
"class-rule %d" as display options with the default being to go through 
and do both "ntuple-all" and "class-rule-all" if neither are specified. 
  Do you think something like that would work?

>> @@ -978,8 +1024,37 @@ static void parse_cmdline(int argc, char **argp)
>>                                                show_usage(1);
>>                                        else
>>                                                rx_fhash_changed = 1;
>> -                             } else
>> +                             } else if (!strcmp(argp[i],
>> +                                                "rx-class-rule-del")) {
>> +                                     i += 1;
>> +                                     if (i>= argc) {
>> +                                             show_usage(1);
>> +                                             break;
>> +                                     }
>> +                                     rx_class_rule_del =
>> +                                             strtol(argp[i], NULL, 0);
>> +                                     if (rx_class_rule_del<  0)
>> +                                             show_usage(1);
>
> Use get_uint_range(argp[i], 0, INT_MAX).

Will be fixed in the next patch.

>> +                             } else if (!strcmp(argp[i],
>> +                                                "rx-class-rule-add")) {
>> +                                     i += 1;
>> +                                     if (i>= argc) {
>> +                                             show_usage(1);
>> +                                             break;
>> +                                     }
>> +                                     if (rxclass_parse_ruleopts(&argp[i],
>> +                                                                argc - i,
>> +&rx_rule_fs,
>> +&rxclass_loc_valid)<  0) {
>> +                                             show_usage(1);
>> +                                     } else {
>> +                                             i = argc;
>> +                                             rx_class_rule_added = 1;
>> +                                     }
>> +                             } else {
>>                                        show_usage(1);
>> +                             }
>> +
>>                                break;
>>                        }
>>                        if (mode == MODE_SRXFHINDIR) {
>> @@ -1917,9 +1992,12 @@ static int dump_rxfhash(int fhash, u64 val)
>>        case SCTP_V4_FLOW:
>>                fprintf(stdout, "SCTP over IPV4 flows");
>>                break;
>> -     case AH_ESP_V4_FLOW:
>
> I believe this is still a valid type for flow hashing.
>

I just looked and it is since this is something from the original patch. 
  I'm not even really sure why the patch modified this piece except for 
maybe to try and correct the fact that AH and ESP being merged makes it 
much more difficult to separate.  For now what I think I will do is spin 
this off into a separate patch that will add support for displaying 
AH_V4/6_FLOW and add support for setting and displaying ESP_V4/6_FLOW.

>> +     case AH_V4_FLOW:
>>                fprintf(stdout, "IPSEC AH over IPV4 flows");
>>                break;
>> +     case ESP_V4_FLOW:
>> +             fprintf(stdout, "IPSEC ESP over IPV4 flows");
>> +             break;
>>        case TCP_V6_FLOW:
>>                fprintf(stdout, "TCP over IPV6 flows");
>>                break;
>> @@ -1929,9 +2007,12 @@ static int dump_rxfhash(int fhash, u64 val)
>>        case SCTP_V6_FLOW:
>>                fprintf(stdout, "SCTP over IPV6 flows");
>>                break;
>> -     case AH_ESP_V6_FLOW:
>
> Same as for AH_ESP_V4_FLOW.
>

I will just leave the value in for the next patch.

>> +     case AH_V6_FLOW:
>>                fprintf(stdout, "IPSEC AH over IPV6 flows");
>>                break;
>> +     case ESP_V6_FLOW:
>> +             fprintf(stdout, "IPSEC ESP over IPV6 flows");
>> +             break;
>>        default:
>>                break;
>>        }
>> @@ -2911,14 +2992,12 @@ static int do_gstats(int fd, struct ifreq *ifr)
>>        return 0;
>>   }
>>
>> -
>>   static int do_srxclass(int fd, struct ifreq *ifr)
>>   {
>>        int err;
>> +     struct ethtool_rxnfc nfccmd;
>>
>>        if (rx_fhash_changed) {
>> -             struct ethtool_rxnfc nfccmd;
>> -
>>                nfccmd.cmd = ETHTOOL_SRXFH;
>>                nfccmd.flow_type = rx_fhash_set;
>>                nfccmd.data = rx_fhash_val;
>> @@ -2930,6 +3009,20 @@ static int do_srxclass(int fd, struct ifreq *ifr)
>>
>>        }
>>
>> +     if (rx_class_rule_added) {
>> +             err = rxclass_rule_ins(fd, ifr,&rx_rule_fs,
>> +                                    rxclass_loc_valid);
>> +             if (err<  0)
>> +                     fprintf(stderr, "Cannot insert RX classification rule\n");
>> +     }
>> +
>> +     if (rx_class_rule_del>= 0) {
>> +             err = rxclass_rule_del(fd, ifr, rx_class_rule_del);
>> +
>> +             if (err<  0)
>> +                     fprintf(stderr, "Cannot delete RX classification rule\n");
>> +     }
>> +
>>        return 0;
>>   }
>
> This needs to return 1 on error (I know that's an existing bug, but
> don't compound it).
>

This will be fixed for the next patch.

>> @@ -2950,6 +3043,31 @@ static int do_grxclass(int fd, struct ifreq *ifr)
>>                        dump_rxfhash(rx_fhash_get, nfccmd.data);
>>        }
>>
>> +     if (rx_rings_get) {
>> +             struct ethtool_rxnfc nfccmd;
>> +
>> +             nfccmd.cmd = ETHTOOL_GRXRINGS;
>> +             ifr->ifr_data = (caddr_t)&nfccmd;
>> +             err = ioctl(fd, SIOCETHTOOL, ifr);
>> +             if (err<  0)
>> +                     perror("Cannot get RX rings");
>> +             else
>> +                     fprintf(stdout, "%d RX rings available\n",
>> +                             (int)nfccmd.data);
>> +     }
>> +
>> +     if (rx_class_rule_get>= 0) {
>> +             err = rxclass_rule_get(fd, ifr, rx_class_rule_get);
>> +             if (err<  0)
>> +                     fprintf(stderr, "Cannot get RX classification rule\n");
>> +     }
>> +
>> +     if (rx_class_rule_getall) {
>> +             err = rxclass_rule_getall(fd, ifr);
>> +             if (err<  0)
>> +                     fprintf(stderr, "RX classification rule retrieval failed\n");
>> +     }
>> +
>>        return 0;
>>   }
>
> Ditto for this.
>

I'll have it fixed for the next patch.

>> diff --git a/rxclass.c b/rxclass.c
>> new file mode 100644
>> index 0000000..fd01a32
>> --- /dev/null
>> +++ b/rxclass.c
>> @@ -0,0 +1,809 @@
>> +/*
>> + * Copyright (C) 2008 Sun Microsystems, Inc. All rights reserved.
>> + */
>> +#include<stdio.h>
>> +#include<stdint.h>
>> +#include<stddef.h>
>> +#include<stdlib.h>
>> +#include<string.h>
>> +#include<strings.h>
>> +
>> +#include<linux/sockios.h>
>> +#include<arpa/inet.h>
>> +#include "ethtool-util.h"
>> +#include "ethtool-bitops.h"
>> +
>> +/*
>> + * This is a rule manager implementation for ordering rx flow
>> + * classification rules in a longest prefix first match order.
>> + * The assumption is that this rule manager is the only one adding rules to
>> + * the device's hardware classifier.
>> + */
>> +
>> +struct rmgr_ctrl {
>> +     /* slot contains a bitmap indicating which filters are valid */
>> +     unsigned long           *slot;
>> +     __u32                   n_rules;
>> +     __u32                   size;
>> +};
>> +
>> +static struct rmgr_ctrl rmgr;
>> +static int rmgr_init_done = 0;
>> +
>> +#ifndef SIOCETHTOOL
>> +#define SIOCETHTOOL     0x8946
>> +#endif
>
> This definition ought to be moved to ethtool-util.h rather than
> duplicated.

It will be moved in the next patch.

>> +static void rmgr_print_ipv4_rule(struct ethtool_rx_flow_spec *fsp)
>> +{
>> +     char            chan[16];
>> +     char            l4_proto[16];
>> +     __u32           sip, dip, sipm, dipm;
>> +
>> +     sip = ntohl(fsp->h_u.tcp_ip4_spec.ip4src);
>> +     dip = ntohl(fsp->h_u.tcp_ip4_spec.ip4dst);
>> +     sipm = ntohl(fsp->m_u.tcp_ip4_spec.ip4src);
>> +     dipm = ntohl(fsp->m_u.tcp_ip4_spec.ip4dst);
>> +
>> +     if (fsp->ring_cookie != RX_CLS_FLOW_DISC)
>> +             sprintf(chan, "Rx Ring [%d]", (int)fsp->ring_cookie);
>> +     else
>> +             sprintf(chan, "Discard");
>> +
>> +     switch (fsp->flow_type) {
>> +     case TCP_V4_FLOW:
>> +     case UDP_V4_FLOW:
>> +     case SCTP_V4_FLOW:
>> +     case AH_V4_FLOW:
>> +     case ESP_V4_FLOW:
>> +     case IP_USER_FLOW:
>> +             fprintf(stdout,
>> +                     "      IPv4 Rule:  ID[%d] Target[%s]\n"
>> +                     "      IP src addr[%d.%d.%d.%d] mask[%d.%d.%d.%d]\n"
>> +                     "      IP dst addr[%d.%d.%d.%d] mask[%d.%d.%d.%d]\n"
>> +                     "      IP TOS[0x%x] mask[0x%x]\n",
>
> To be consistent with other ethtool output, this should use colons
> rather than square brackets to separate field names and values.
>

I'll have that updated for the next patch.

> [...]
>> +int rxclass_parse_ruleopts(char **optstr, int opt_cnt,
>> +                        struct ethtool_rx_flow_spec *fsp,
>> +                        u_int8_t *loc_valid)
>> +{
>> +     int i = 0;
>> +
>> +     u_int8_t discard, ring_set;
>> +     u_int32_t ipsa, ipsm, ipda, ipdm, spi, spim;
>> +     u_int16_t sp, spm, dp, dpm;
>> +     u_int8_t ip_ver, proto, tos, tm;
>> +     struct in_addr in_addr;
>> +
>> +     if (*optstr == NULL || **optstr == '\0' || opt_cnt<  2) {
>> +             fprintf(stdout, "Add rule, invalid syntax\n");
>> +             return -1;
>> +     }
>> +
>> +     bzero(fsp, sizeof(struct ethtool_rx_flow_spec));
>> +     ipsa = ipda = ipsm = ipdm = spi = spim = 0x0;
>> +     sp = dp = spm = dpm = 0x0;
>> +     ip_ver = proto = tos = tm = 0x0;
>> +     discard = ring_set = 0;
>> +
>> +     if (!strcmp(optstr[i], "ip4")) {
>> +             ip_ver = ETH_RX_NFC_IP4;
>> +     } else if (!strcmp(optstr[i], "ip6")) {
>> +             fprintf(stdout, "IPv6 not yet implemented\n");
>> +             return -1;
>> +     } else {
>> +             fprintf(stdout, "Add rule, invalid syntax for IP version\n");
>> +             return -1;
>> +     }
>> +
>> +     i++;
>> +
>> +     switch (ip_ver) {
>> +     case ETH_RX_NFC_IP4:
>> +             if (!strcmp(optstr[i], "tcp"))
>> +                     fsp->flow_type = TCP_V4_FLOW;
>> +             else if (!strcmp(optstr[i], "udp"))
>> +                     fsp->flow_type = UDP_V4_FLOW;
>> +             else if (!strcmp(optstr[i], "sctp"))
>> +                     fsp->flow_type = SCTP_V4_FLOW;
>> +             else if (!strcmp(optstr[i], "ah"))
>> +                     fsp->flow_type = AH_V4_FLOW;
>> +             else if (!strcmp(optstr[i], "esp"))
>> +                     fsp->flow_type = ESP_V4_FLOW;
>> +             break;
>> +     default:
>> +             fprintf(stdout, "Add rule, Invalid IP version %d\n", ip_ver);
>> +                     return -1;
>> +     }
>> +
>> +     if (fsp->flow_type == 0) {
>> +             proto = (u_int8_t)strtoul(optstr[i], (char **)NULL, 0);
>> +             if (proto != 0) {
>> +                     fprintf(stdout, "Add rule, user defined proto %d\n",
>> +                             proto);
>> +                     fsp->flow_type = IP_USER_FLOW;
>> +                     fsp->h_u.usr_ip4_spec.proto = proto;
>> +                     fsp->h_u.usr_ip4_spec.ip_ver = ip_ver;
>> +             } else {
>> +                     fprintf(stdout, "Add rule, invalid IP proto %s\n",
>> +                             optstr[i]);
>> +                     return -1;
>> +             }
>> +     }
>> +
>> +     for (i = 2; i<  opt_cnt;) {
>> +             if (!strcmp(optstr[i], "tos")) {
>> +                     tos = (u_int8_t)strtoul(optstr[i+1], (char **)NULL,
>> +                                              0);
>> +                     tm = 0xff;
>> +                     fsp->h_u.tcp_ip4_spec.tos = tos;
>> +
>> +                     i += 2;
>> +                     if (opt_cnt>  (i+1)) {
>> +                             if (!strcmp(optstr[i], "m")) {
>> +                                     tm = (u_int8_t)strtoul(optstr[i+1],
>> +                                                            (char **)NULL,
>> +                                                            16);
>> +                                     i += 2;
>> +                             }
>> +                     }
>> +                     fsp->m_u.tcp_ip4_spec.tos = tm;
>> +             } else if (!strcmp(optstr[i], "sip")) {
> [...]
>
> These keyword names must be made consistent with those used for the -U
> (--config-ntuple) option.
>

I will update the names to be consistent with the ntuple options, 
however I would prefer to keep the option of short-cutting the mask via 
the "m" value.  It will not be hard to make it support both since the 
pattern would be to test for either "m" or "%s-mask".

> Also, they can be parsed much more concisely using the new option types
> I defined a while back for struct cmdline_info.
>

I'm already looking into using something like the cmdline_info to do the 
parsing, however one thing I would like to retain is the mask setting as 
a part of setting the value.  Also since rxclass is being passed a 
pointer it is going to have to work with relative offsets instead of 
fixed values for the location of the fields within the structure.

> Ben.
>
> --
> Ben Hutchings, Senior Software Engineer, Solarflare Communications
> Not speaking for my employer; that's the marketing department's job.
> They asked us to note that Solarflare product names are trademarked.
>


^ permalink raw reply

* Re: [PATCH] ax88796: depend on HAS_IOMEM not on individual ARCHs
From: David Miller @ 2011-02-22 20:37 UTC (permalink / raw)
  To: mkl; +Cc: netdev
In-Reply-To: <1298405998-6214-1-git-send-email-mkl@pengutronix.de>

From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: Tue, 22 Feb 2011 21:19:58 +0100

> Reported-by: David Miller <davem@davemloft.net>
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
> 
> Hello David,
> 
> this patch is available in the git repository at:
>   git://git.pengutronix.de/git/mkl/linux-2.6.git net/ax88796
> 
> based on the patches already merged into net-next.

I would like you to actually build test this.

I know it's going to cause allmodconfig build errors on sparc64,
for example.

^ 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