* [PATCH] Add support for iPhone 5, iPad 2 GSM/CDMA, iPad 3 GSM/CDMA to ipheth.
From: Jay Purohit @ 2012-10-11 22:32 UTC (permalink / raw)
To: netdev
This patch introduces support for all devices which
officially/unofficially support
tethering over the USB connection.
This is a revision of the iPhone 5 ipheth support patch.
Signed-off-by: Jay Purohit <jspurohit@velocitylimitless.com>
diff -uprN ../old/linux-3.6.1/drivers/net/usb/ipheth.c
./drivers/net/usb/ipheth.c
--- ../old/linux-3.6.1/drivers/net/usb/ipheth.c 2012-10-07
10:41:28.000000000 -0500
+++ ./drivers/net/usb/ipheth.c 2012-10-11 17:28:39.862329304 -0500
@@ -55,13 +55,28 @@
#include <linux/workqueue.h>
#define USB_VENDOR_APPLE 0x05ac
+
+/*
+ * Please add the supported VID/PID for devices that support tethering here.
+ *
+ * Note: iPod touches starting with the 3G do actually support USB ethernet,
+ * however implementing support for it in this driver would be useless,
+ * as there is no external interface for it to bridge with on device.
+ */
+
#define USB_PRODUCT_IPHONE 0x1290
#define USB_PRODUCT_IPHONE_3G 0x1292
#define USB_PRODUCT_IPHONE_3GS 0x1294
#define USB_PRODUCT_IPHONE_4 0x1297
-#define USB_PRODUCT_IPAD 0x129a
#define USB_PRODUCT_IPHONE_4_VZW 0x129c
#define USB_PRODUCT_IPHONE_4S 0x12a0
+#define USB_PRODUCT_IPHONE_5 0x12a8
+
+#define USB_PRODUCT_IPAD 0x129a
+#define USB_PRODUCT_IPAD_2_GSM 0x12a2
+#define USB_PRODUCT_IPAD_2_CDMA 0x12a3
+#define USB_PRODUCT_IPAD_3_GSM 0x12a4
+#define USB_PRODUCT_IPAD_3_CDMA 0x12a5
#define IPHETH_USBINTF_CLASS 255
#define IPHETH_USBINTF_SUBCLASS 253
@@ -106,6 +121,22 @@ static struct usb_device_id ipheth_table
IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
IPHETH_USBINTF_PROTO) },
{ USB_DEVICE_AND_INTERFACE_INFO(
+ USB_VENDOR_APPLE, USB_PRODUCT_IPAD_2_GSM,
+ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
+ IPHETH_USBINTF_PROTO) },
+ { USB_DEVICE_AND_INTERFACE_INFO(
+ USB_VENDOR_APPLE, USB_PRODUCT_IPAD_2_CDMA,
+ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
+ IPHETH_USBINTF_PROTO) },
+ { USB_DEVICE_AND_INTERFACE_INFO(
+ USB_VENDOR_APPLE, USB_PRODUCT_IPAD_3_GSM,
+ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
+ IPHETH_USBINTF_PROTO) },
+ { USB_DEVICE_AND_INTERFACE_INFO(
+ USB_VENDOR_APPLE, USB_PRODUCT_IPAD_3_CDMA,
+ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
+ IPHETH_USBINTF_PROTO) },
+ { USB_DEVICE_AND_INTERFACE_INFO(
USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4_VZW,
IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
IPHETH_USBINTF_PROTO) },
@@ -113,6 +144,10 @@ static struct usb_device_id ipheth_table
USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4S,
IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
IPHETH_USBINTF_PROTO) },
+ { USB_DEVICE_AND_INTERFACE_INFO(
+ USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_5,
+ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
+ IPHETH_USBINTF_PROTO) },
{ }
};
MODULE_DEVICE_TABLE(usb, ipheth_table);
^ permalink raw reply
* Re: [STABLE REQUEST] add: e1000: fix lockdep splat in shutdown handler
From: David Miller @ 2012-10-11 22:22 UTC (permalink / raw)
To: rostedt
Cc: ben, linux-kernel, netdev, tglx, stable, jesse.brandeburg,
jeffrey.t.kirsher
In-Reply-To: <1349993385.24256.79.camel@gandalf.local.home>
From: Steven Rostedt <rostedt@goodmis.org>
Date: Thu, 11 Oct 2012 18:09:45 -0400
> Can you add this to the 3.2 stable tree.
>
> commit 3a3847e007aae732d64d8fd1374126393e9879a3
> Author: Jesse Brandeburg <jesse.brandeburg@intel.com>
> Date: Wed Jan 4 20:23:33 2012 +0000
>
> e1000: fix lockdep splat in shutdown handler
Acked-by: David S. Miller <davem@davemloft.net>
^ permalink raw reply
* [STABLE REQUEST] add: e1000: fix lockdep splat in shutdown handler
From: Steven Rostedt @ 2012-10-11 22:09 UTC (permalink / raw)
To: Ben Hutchings
Cc: LKML, netdev, David S. Miller, Thomas Gleixner, stable,
Jesse Brandeburg, Jeff Kirsher
Ben, David,
I posted before a lockdep splat that showed a possible deadlock that was
later fixed by Jesse. I'm now hitting this deadlock on my box while
testing the 3.2-rt kernel.
Please stand by while rebooting the system...
<5>sd 0:0:0:0: [sda] Synchronizing SCSI cache
<3>INFO: task kworker/0:2:633 blocked for more than 120 seconds.
<3>"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
<6>kworker/0:2 D<c> 0000000000000000 <c> 0 633 2 0x00000000
<c> ffff880074bcbc40<c> 0000000000000046<c> 0000000000000000<c> ffffffff81c11020<c>
<c> 0000000000000000<c> ffff880074bcbfd8<c> 0000000000010440<c> ffff880074bcbfd8<c>
<c> 0000000000010440<c> ffff880075a04540<c> ffff8800713c6650<c> 00000001713c6650<c>
Call Trace:
[<ffffffff8175ff0e>] schedule+0x75/0x92
[<ffffffff81760adc>] __rt_mutex_slowlock+0x96/0xde
[<ffffffff81760c11>] rt_mutex_slowlock+0xed/0x153
[<ffffffff8106ba4f>] rt_mutex_fastlock.constprop.15+0x35/0x37
[<ffffffff81760c8c>] rt_mutex_lock+0x15/0x17
[<ffffffff81761234>] _mutex_lock+0xe/0x10
[<ffffffff814d7e7b>] e1000_watchdog+0x54/0x4a2
[<ffffffff814d7e27>] ? e1000_update_stats+0x92c/0x92c
[<ffffffff810548fc>] process_one_work+0x181/0x2c8
[<ffffffff81055ae2>] worker_thread+0xe3/0x16c
[<ffffffff810559ff>] ? manage_workers.isra.24+0x180/0x180
[<ffffffff81059491>] kthread+0x84/0x8c
[<ffffffff8102e32a>] ? finish_task_switch+0x57/0x9a
[<ffffffff817691b4>] kernel_thread_helper+0x4/0x10
[<ffffffff817617ce>] ? retint_restore_args+0xe/0xe
[<ffffffff8105940d>] ? rcu_read_unlock_sched_notrace+0x25/0x25
[<ffffffff817691b0>] ? gs_change+0xb/0xb
<3>INFO: task reboot:1646 blocked for more than 120 seconds.
<3>"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
<6>reboot D<c> 0000000000000000 <c> 0 1646 1 0x00000000
<c> ffff880073eb3a88<c> 0000000000000086<c> 0000000000000000<c> ffff8800774d2380<c>
<c> 0000000000000000<c> ffff880073eb3fd8<c> 0000000000010440<c> ffff880073eb3fd8<c>
<c> 0000000000010440<c> ffff880071ab4100<c> 0000000000000001<c> 0000000100000001<c>
Call Trace:
[<ffffffff8175ff0e>] schedule+0x75/0x92
[<ffffffff8176021b>] schedule_timeout+0x34/0xd9
[<ffffffff8103250c>] ? get_parent_ip+0xf/0x40
[<ffffffff81764133>] ? sub_preempt_count+0x94/0xa8
[<ffffffff8103647e>] ? migrate_enable+0x153/0x165
[<ffffffff8175fd7f>] wait_for_common+0xa2/0x106
[<ffffffff810361fd>] ? try_to_wake_up+0x2ba/0x2ba
[<ffffffff8175fe97>] wait_for_completion+0x1d/0x1f
[<ffffffff81053e22>] wait_on_cpu_work+0xc9/0xd9
[<ffffffff81053586>] ? rcu_read_unlock_sched_notrace+0x25/0x25
[<ffffffff81053e75>] wait_on_work+0x43/0x6b
[<ffffffff81054ccb>] __cancel_work_timer+0xc7/0x10c
[<ffffffff81054d22>] cancel_delayed_work_sync+0x12/0x14
[<ffffffff814d489f>] e1000_down_and_stop+0x39/0x55
[<ffffffff814d6de2>] e1000_down+0x123/0x183
[<ffffffff814d873d>] __e1000_shutdown+0x81/0x1f9
[<ffffffff814d88cf>] e1000_shutdown+0x1a/0x43
[<ffffffff812a1fa9>] pci_device_shutdown+0x29/0x3d
[<ffffffff81484387>] device_shutdown+0xc6/0x10b
[<ffffffff8105071e>] kernel_restart_prepare+0x31/0x38
[<ffffffff81050739>] kernel_restart+0x14/0x51
[<ffffffff810508dd>] sys_reboot+0x155/0x1ae
[<ffffffff8103647e>] ? migrate_enable+0x153/0x165
[<ffffffff8111cef4>] ? vfsmount_lock_local_unlock+0x2e/0x33
[<ffffffff8111dfa5>] ? mntput_no_expire+0x2c/0xd5
[<ffffffff8111e074>] ? mntput+0x26/0x28
[<ffffffff81106abf>] ? fput+0x1b3/0x1c2
[<ffffffff810a73a8>] ? trace_hardirqs_on_caller+0xe/0x22
[<ffffffff8128ef66>] ? trace_hardirqs_on_thunk+0x3a/0x3c
[<ffffffff8176706b>] system_call_fastpath+0x16/0x1b
Can you add this to the 3.2 stable tree.
commit 3a3847e007aae732d64d8fd1374126393e9879a3
Author: Jesse Brandeburg <jesse.brandeburg@intel.com>
Date: Wed Jan 4 20:23:33 2012 +0000
e1000: fix lockdep splat in shutdown handler
Thanks!
-- Steve
^ permalink raw reply
* [PATCH] ipv6: Enable enough of the code to handle GSO when disabled.
From: Vlad Yasevich @ 2012-10-11 21:48 UTC (permalink / raw)
To: netdev; +Cc: davem, Vlad Yasevich
In-Reply-To: <507739A1.3000201@hp.com>
When a guest using virtio is attempting to use IPv6 on a host where
IPv6 module is administratively disabled, the tcp bulk thransfer rate
drops down to 10kbps. The problem is that when IPv6 is disabled,
none of the protocol handlers are registered. When the guest
attempts to send an IPv6 packet with GSO (which is the default), this
packet is dropped by the host stack because there are no gso handlers
registered. Thus a retransmit is triggerd for ever GSO packet, reducing
the transfer rate.
This patch attempts to solve this by enabling just enough code that GSO
is correctly processed. However, I should point out that if IPv6 is
simply blacklisted or not build for the kernel, this problem will
still persist.
This problem also exists for AF_PACKET sockets, so it is not limited
to guests using virtio.
Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
---
include/linux/ipv6.h | 1 +
include/net/ipv6.h | 5 +++
net/ipv6/af_inet6.c | 69 +++++++++++++++++++++++++++++++++++++++++++++---
net/ipv6/ip6_input.c | 5 +++
net/ipv6/reassembly.c | 11 +++++--
net/ipv6/tcp_ipv6.c | 9 +++++-
net/ipv6/udp.c | 6 +++-
7 files changed, 95 insertions(+), 11 deletions(-)
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index 0b94e91..1d5e061 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -176,6 +176,7 @@ struct ipv6_devconf {
};
struct ipv6_params {
+ __s32 disable_ipv6_mod;
__s32 disable_ipv6;
__s32 autoconf;
};
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 979bf6c..cda75b4 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -550,6 +550,11 @@ extern int ipv6_rcv(struct sk_buff *skb,
struct packet_type *pt,
struct net_device *orig_dev);
+extern int ipv6_rcv_stub(struct sk_buff *skb,
+ struct net_device *dev,
+ struct packet_type *pt,
+ struct net_device *orig_dev);
+
extern int ip6_rcv_finish(struct sk_buff *skb);
/*
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index a974247..1fd0d73 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -74,13 +74,13 @@ static struct list_head inetsw6[SOCK_MAX];
static DEFINE_SPINLOCK(inetsw6_lock);
struct ipv6_params ipv6_defaults = {
+ .disable_ipv6_mod = 0,
.disable_ipv6 = 0,
.autoconf = 1,
};
-static int disable_ipv6_mod;
-module_param_named(disable, disable_ipv6_mod, int, 0444);
+module_param_named(disable, ipv6_defaults.disable_ipv6_mod, int, 0444);
MODULE_PARM_DESC(disable, "Disable IPv6 module such that it is non-functional");
module_param_named(disable_ipv6, ipv6_defaults.disable_ipv6, int, 0444);
@@ -1048,6 +1048,53 @@ static struct pernet_operations inet6_net_ops = {
.exit = inet6_net_exit,
};
+/* This function is called when IPv6 is administratively disabled.
+ * Its sole purpose is to set up enough of IPv6 that GSO/TSO will work
+ * for any outgoing IPv6 packets that may have been generated by
+ * guest or AF_PACKET sockets.
+ */
+static int inet6_init_disabled(void)
+{
+ int err = 0;
+
+ /* Init v6 extension headers. */
+ err = ipv6_exthdrs_init();
+ if (err)
+ goto out;
+
+ err = ipv6_frag_init();
+ if (err)
+ goto ipv6_frag_fail;
+
+ /* Init v6 transport protocols. UDP-light doesn't support GSO so
+ * it is omitted
+ */
+ err = udpv6_init();
+ if (err)
+ goto udpv6_fail;
+
+ err = tcpv6_init();
+ if (err)
+ goto tcpv6_fail;
+
+ err = ipv6_packet_init();
+ if (err)
+ goto ipv6_packet_fail;
+
+ return 0;
+
+ipv6_packet_fail:
+ tcpv6_exit();
+tcpv6_fail:
+ udpv6_exit();
+udpv6_fail:
+ ipv6_frag_exit();
+ipv6_frag_fail:
+ ipv6_exthdrs_exit();
+out:
+ return err;
+}
+
static int __init inet6_init(void)
{
struct sk_buff *dummy_skb;
@@ -1060,8 +1107,9 @@ static int __init inet6_init(void)
for (r = &inetsw6[0]; r < &inetsw6[SOCK_MAX]; ++r)
INIT_LIST_HEAD(r);
- if (disable_ipv6_mod) {
+ if (ipv6_defaults.disable_ipv6_mod) {
pr_info("Loaded, but administratively disabled, reboot required to enable\n");
+ err = inet6_init_disabled();
goto out;
}
@@ -1238,11 +1286,22 @@ out_unregister_tcp_proto:
}
module_init(inet6_init);
+static void __exit inet6_exit_disabled(void)
+{
+ ipv6_packet_cleanup();
+ ipv6_frag_exit();
+ ipv6_exthdrs_exit();
+ udpv6_exit();
+ tcpv6_exit();
+}
+
static void __exit inet6_exit(void)
{
- if (disable_ipv6_mod)
+ if (ipv6_defaults.disable_ipv6_mod) {
+ inet6_exit_disabled();
return;
-
+ }
+
/* First of all disallow new sockets creation. */
sock_unregister(PF_INET6);
/* Disallow any further netlink messages */
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index a52d864..3e86ec3 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -74,6 +74,11 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
return NET_RX_DROP;
}
+ if (ipv6_defaults.disable_ipv6_mod) {
+ kfree_skb(skb);
+ return NET_RX_DROP;
+ }
+
rcu_read_lock();
idev = __in6_dev_get(skb->dev);
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index da8a4e3..71a0e61 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -705,6 +705,9 @@ int __init ipv6_frag_init(void)
if (ret)
goto out;
+ if (ipv6_defaults.disable_ipv6_mod)
+ goto out;
+
ret = ip6_frags_sysctl_register();
if (ret)
goto err_sysctl;
@@ -734,8 +737,10 @@ err_sysctl:
void ipv6_frag_exit(void)
{
- inet_frags_fini(&ip6_frags);
- ip6_frags_sysctl_unregister();
- unregister_pernet_subsys(&ip6_frags_ops);
+ if (!ipv6_defaults.disable_ipv6_mod) {
+ inet_frags_fini(&ip6_frags);
+ ip6_frags_sysctl_unregister();
+ unregister_pernet_subsys(&ip6_frags_ops);
+ }
inet6_del_protocol(&frag_protocol, IPPROTO_FRAGMENT);
}
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 49c8903..ebb297c 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -2109,6 +2109,9 @@ int __init tcpv6_init(void)
if (ret)
goto out;
+ if (ipv6_defaults.disable_ipv6_mod)
+ goto out;
+
/* register inet6 protocol */
ret = inet6_register_protosw(&tcpv6_protosw);
if (ret)
@@ -2129,7 +2132,9 @@ out_tcpv6_protosw:
void tcpv6_exit(void)
{
- unregister_pernet_subsys(&tcpv6_net_ops);
- inet6_unregister_protosw(&tcpv6_protosw);
+ if (!ipv6_defaults.disable_ipv6_mod) {
+ unregister_pernet_subsys(&tcpv6_net_ops);
+ inet6_unregister_protosw(&tcpv6_protosw);
+ }
inet6_del_protocol(&tcpv6_protocol, IPPROTO_TCP);
}
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index fc99972..2e8dddb 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -1569,6 +1569,9 @@ int __init udpv6_init(void)
if (ret)
goto out;
+ if (ipv6_defaults.disable_ipv6_mod)
+ goto out;
+
ret = inet6_register_protosw(&udpv6_protosw);
if (ret)
goto out_udpv6_protocol;
@@ -1582,6 +1585,7 @@ out_udpv6_protocol:
void udpv6_exit(void)
{
- inet6_unregister_protosw(&udpv6_protosw);
+ if (!ipv6_defaults.disable_ipv6_mod)
+ inet6_unregister_protosw(&udpv6_protosw);
inet6_del_protocol(&udpv6_protocol, IPPROTO_UDP);
}
--
1.7.7.6
^ permalink raw reply related
* Re: [PATCH v2 1/4] net: mvneta: driver for Marvell Armada 370/XP network unit
From: Francois Romieu @ 2012-10-11 21:26 UTC (permalink / raw)
To: Thomas Petazzoni
Cc: David S. Miller, Lennert Buytenhek, netdev, linux-arm-kernel,
Jason Cooper, Andrew Lunn, Gregory Clement, Lior Amsalem,
Maen Suleiman, Rami Rosen
In-Reply-To: <1349969282-12676-2-git-send-email-thomas.petazzoni@free-electrons.com>
Thomas Petazzoni <thomas.petazzoni@free-electrons.com> :
[...]
> diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
> new file mode 100644
> index 0000000..4f7fe08
> --- /dev/null
> +++ b/drivers/net/ethernet/marvell/mvneta.c
[...]
> +struct mvneta_port {
> + /* Packet size in bytes */
> + int pkt_size;
> +
> + /* Base virtual address of the Ethernet controller registers */
> + void __iomem *base;
> +
> + /* Array of RX queues */
> + struct mvneta_rx_queue *rxqs;
> +
> + /* Array of TX queues */
> + struct mvneta_tx_queue *txqs;
> +
> + /* Timer */
> + struct timer_list tx_done_timer;
> +
> + /* Back pointer to the Linux network interface device */
> + struct net_device *dev;
You can avoid five comments.
> +
> + u32 cause_rx_tx[CONFIG_NR_CPUS];
> + struct napi_struct napi;
> +
> + /* Flags */
> + unsigned long flags;
> +#define MVNETA_F_TX_DONE_TIMER_BIT 0
> +
> + /* Napi weight */
> + int weight;
> +
> + /* Core clock [Hz] */
> + unsigned int clk_rate;
clk_rate_hz
[...]
> +/* Get System Network Statistics */
> +struct rtnl_link_stats64 *mvneta_get_stats64(struct net_device *dev,
> + struct rtnl_link_stats64 *stats)
> +{
> + struct mvneta_port *pp = netdev_priv(dev);
> + unsigned int start;
> +
> + memset(stats, 0, sizeof(struct rtnl_link_stats64));
> +
> + do {
> + start = u64_stats_fetch_begin_bh(&pp->rx_stats.syncp);
> + stats->rx_packets = pp->rx_stats.packets;
> + stats->rx_bytes = pp->rx_stats.bytes;
> + } while (u64_stats_fetch_retry_bh(&pp->rx_stats.syncp, start));
> +
> +
> + do {
> + start = u64_stats_fetch_begin_bh(&pp->tx_stats.syncp);
> + stats->tx_packets = pp->tx_stats.packets;
> + stats->tx_bytes = pp->tx_stats.bytes;
> + } while (u64_stats_fetch_retry_bh(&pp->tx_stats.syncp, start));
> +
> + stats->rx_errors = dev->stats.rx_errors;
> + stats->rx_dropped = dev->stats.rx_dropped;
> +
> + stats->tx_dropped = dev->stats.tx_dropped;
> +
> + return stats;
> +
> +}
Excess empty line.
[...]
> +static void mvneta_rxq_desc_num_update(struct mvneta_port *pp,
> + struct mvneta_rx_queue *rxq,
> + int rx_done, int rx_filled)
> +{
> + u32 val;
> +
> + if ((rx_done <= 0xff) && (rx_filled <= 0xff)) {
> + val = rx_done |
> + (rx_filled << MVNETA_RXQ_ADD_NON_OCCUPIED_SHIFT);
> + mvreg_write(pp, MVNETA_RXQ_STATUS_UPDATE_REG(rxq->id), val);
> + return;
> + }
> +
> + /* Only 255 descriptors can be added at once */
> + while ((rx_done > 0) || (rx_filled > 0)) {
> + if (rx_done <= 0xff) {
> + val = rx_done;
> + rx_done = 0;
> + } else {
> + val = 0xff;
> + rx_done -= 0xff;
> + }
> + if (rx_filled <= 0xff) {
> + val |= rx_filled
> + << MVNETA_RXQ_ADD_NON_OCCUPIED_SHIFT;
val |= rx_filled << MVNETA_RXQ_ADD_NON_OCCUPIED_SHIFT;
> + rx_filled = 0;
> + } else {
> + val |= 0xff << MVNETA_RXQ_ADD_NON_OCCUPIED_SHIFT;
> + rx_filled -= 0xff;
> + }
> + mvreg_write(pp, MVNETA_RXQ_STATUS_UPDATE_REG(rxq->id), val);
> + }
> +}
> +
> +/* Get pointer to next RX descriptor to be processed by SW */
> +static struct mvneta_rx_desc *
> +mvneta_rxq_next_desc_get(struct mvneta_rx_queue *rxq)
> +{
> + int rx_desc = rxq->next_desc_to_proc;
> +
> + rxq->next_desc_to_proc =
> + MVNETA_QUEUE_NEXT_DESC(rxq, rx_desc);
rxq->next_desc_to_proc = MVNETA_QUEUE_NEXT_DESC(rxq, rx_desc);
> +
> + return rxq->descs + rx_desc;
> +}
> +
> +/* Change maximum receive size of the port. */
> +static void mvneta_max_rx_size_set(struct mvneta_port *pp, int max_rx_size)
> +{
> + u32 val;
> +
> + val = mvreg_read(pp, MVNETA_GMAC_CTRL_0);
> + val &= ~MVNETA_GMAC_MAX_RX_SIZE_MASK;
> + val |= (((max_rx_size - MVNETA_MH_SIZE) / 2)
> + << MVNETA_GMAC_MAX_RX_SIZE_SHIFT);
Excess parenthesis.
Operator on start of line.
[...]
> +static struct mvneta_tx_desc *
> +mvneta_txq_next_desc_get(struct mvneta_tx_queue *txq)
> +{
> + int tx_desc = txq->next_desc_to_proc;
> + txq->next_desc_to_proc =
> + MVNETA_QUEUE_NEXT_DESC(txq, tx_desc);
int tx_desc = txq->next_desc_to_proc;
txq->next_desc_to_proc = MVNETA_QUEUE_NEXT_DESC(txq, tx_desc);
[...]
> +static void mvneta_port_up(struct mvneta_port *pp)
> +{
> + int queue;
> + u32 q_map;
> +
> + /* Enable all initialized TXs. */
> + mvneta_mib_counters_clear(pp);
> + q_map = 0;
> + for (queue = 0; queue < mvneta_txq_number; queue++) {
> + struct mvneta_tx_queue *txq = &pp->txqs[queue];
> + if (txq->descs != NULL)
> + q_map |= (1 << queue);
> + }
> + mvreg_write(pp, MVNETA_TXQ_CMD, q_map);
> +
> + /* Enable all initialized RXQs. */
> + q_map = 0;
> + for (queue = 0; queue < mvneta_rxq_number; queue++) {
> + struct mvneta_rx_queue *rxq = &pp->rxqs[queue];
> + if (rxq->descs != NULL)
> + q_map |= (1 << queue);
> + }
> +
> + mvreg_write(pp, MVNETA_RXQ_CMD, q_map);
> +}
> +
> +/* Stop the Ethernet port activity */
> +static void mvneta_port_down(struct mvneta_port *pp)
> +{
> + u32 val;
> + int count;
> +
> + /* Stop Rx port activity. Check port Rx activity. */
> + val = (mvreg_read(pp, MVNETA_RXQ_CMD))
> + & MVNETA_RXQ_ENABLE_MASK;
val = mvreg_read(pp, MVNETA_RXQ_CMD) & MVNETA_RXQ_ENABLE_MASK;
> + /* Issue stop command for active channels only */
> + if (val != 0)
> + mvreg_write(pp, MVNETA_RXQ_CMD,
> + val << MVNETA_RXQ_DISABLE_SHIFT);
Too bad "val" isn't one character shorter.
> +
> + /* Wait for all Rx activity to terminate. */
> + count = 0;
> + do {
> + if (count >= MVNETA_RX_DISABLE_TIMEOUT_MSEC) {
> + netdev_warn(pp->dev,
> + "TIMEOUT for RX stopped ! rx_queue_cmd: 0x08%x\n",
> + val);
> + break;
> + }
> + mdelay(1);
> + count++;
> +
> + val = mvreg_read(pp, MVNETA_RXQ_CMD);
> + } while (val & 0xff);
You can test "if (count++ >= MVNETA_RX_DISABLE_TIMEOUT_MSEC) {". Nobody
will notice.
> +
> + /* Stop Tx port activity. Check port Tx activity. Issue stop
> + command for active channels only */
> + val = (mvreg_read(pp, MVNETA_TXQ_CMD)) & MVNETA_TXQ_ENABLE_MASK;
> +
> + if (val != 0)
> + mvreg_write(pp, MVNETA_TXQ_CMD,
> + (val << MVNETA_TXQ_DISABLE_SHIFT));
> +
> + /* Wait for all Tx activity to terminate. */
> + count = 0;
> + do {
> + if (count >= MVNETA_TX_DISABLE_TIMEOUT_MSEC) {
> + netdev_warn(pp->dev,
> + "TIMEOUT for TX stopped tx_queue_cmd - 0x%08x\n",
> + val);
> + break;
> + }
> + mdelay(1);
> + count++;
> +
> + /* Check TX Command reg that all Txqs are stopped */
> + val = mvreg_read(pp, MVNETA_TXQ_CMD);
> +
> + } while (val & 0xff);
> +
> + /* Double check to verify that TX FIFO is empty */
> + count = 0;
> + do {
> + if (count >= MVNETA_TX_FIFO_EMPTY_TIMEOUT) {
> + netdev_warn(pp->dev,
> + "TX FIFO empty timeout status=0x08%x",
> + val);
"TX FIFO empty timeout status=0x08%x", val);
> + break;
> + }
> + mdelay(1);
> + count++;
> +
> + val = mvreg_read(pp, MVNETA_PORT_STATUS);
> + } while (!(val & MVNETA_TX_FIFO_EMPTY) &&
> + (val & MVNETA_TX_IN_PRGRS));
> +
> + udelay(200);
> +}
> +
> +/* Enable the port by setting the port enable bit of the MAC control register */
> +static void mvneta_port_enable(struct mvneta_port *pp)
> +{
> + u32 val;
> +
> + /* Enable port */
> + val = mvreg_read(pp, MVNETA_GMAC_CTRL_0);
> + val |= MVNETA_GMAC0_PORT_ENABLE;
> + mvreg_write(pp, MVNETA_GMAC_CTRL_0, val);
> +}
> +
> +/* Disable the port and wait for about 200 usec before retuning */
> +static void mvneta_port_disable(struct mvneta_port *pp)
> +{
> + u32 val;
> +
> + /* Reset the Enable bit in the Serial Control Register */
> + val = mvreg_read(pp, MVNETA_GMAC_CTRL_0);
> + val &= ~(MVNETA_GMAC0_PORT_ENABLE);
Excess parenthesis.
> + mvreg_write(pp, MVNETA_GMAC_CTRL_0, val);
> +
> + udelay(200);
> +}
> +
> +/* Multicast tables methods */
> +
> +/* Set all entries in Unicast MAC Table; queue==-1 means reject all */
> +static void mvneta_set_ucast_table(struct mvneta_port *pp, int queue)
> +{
> + int offset;
> + u32 val;
> +
> + if (queue == -1) {
> + val = 0;
> + } else {
> + val = (((0x01 | (queue << 1)) << 0) |
> + ((0x01 | (queue << 1)) << 8) |
> + ((0x01 | (queue << 1)) << 16) |
> + ((0x01 | (queue << 1)) << 24));
val = (0x01 | (queue << 1)) |
((0x01 | (queue << 1)) << 8) |
((0x01 | (queue << 1)) << 16) |
((0x01 | (queue << 1)) << 24);
val = 0x01 | (queue << 1);
val |= (val << 24) | (val << 16) | (val << 8);
> + }
> +
> + for (offset = 0; offset <= 0xc; offset += 4)
> + mvreg_write(pp, MVNETA_DA_FILT_UCAST_BASE + offset, val);
> +}
> +
> +/* Set all entries in Special Multicast MAC Table; queue==-1 means reject all */
> +static void mvneta_set_special_mcast_table(struct mvneta_port *pp, int queue)
> +{
> + int offs;
> + u32 val;
> +
> + if (queue == -1) {
> + val = 0;
> + } else {
> + val = (((0x01 | (queue << 1)) << 0) |
> + ((0x01 | (queue << 1)) << 8) |
> + ((0x01 | (queue << 1)) << 16) |
> + ((0x01 | (queue << 1)) << 24));
Bis.
> + }
> +
> + for (offs = 0; offs <= 0xfc; offs += 4)
> + mvreg_write(pp, (MVNETA_DA_FILT_SPEC_MCAST + offs), val);
> +
> +}
> +
> +/* Set all entries in Other Multicast MAC Table. queue==-1 means reject all */
> +static void mvneta_set_other_mcast_table(struct mvneta_port *pp, int queue)
> +{
> + int offset;
> + u32 val;
> +
> + if (queue == -1) {
> + memset(pp->mcast_count, 0, sizeof(pp->mcast_count));
> + val = 0;
> + } else {
> + memset(pp->mcast_count, 1, sizeof(pp->mcast_count));
> + val = (((0x01 | (queue << 1)) << 0) |
> + ((0x01 | (queue << 1)) << 8) |
> + ((0x01 | (queue << 1)) << 16) |
> + ((0x01 | (queue << 1)) << 24));
Ter.
[...]
> +static void mvneta_rx_pkts_coal_set(struct mvneta_port *pp,
> + struct mvneta_rx_queue *rxq, u32 value)
> +{
> + mvreg_write(pp, MVNETA_RXQ_THRESHOLD_REG(rxq->id),
> + (value | MVNETA_RXQ_NON_OCCUPIED(0)));
Excess parenthesis.
> + rxq->pkts_coal = value;
> +}
> +
> +/*
> + * Set the time delay in usec before
> + * RX interrupt will be generated by HW.
> + */
> +static void mvneta_rx_time_coal_set(struct mvneta_port *pp,
> + struct mvneta_rx_queue *rxq, u32 value)
> +{
> + u32 val = (pp->clk_rate / 1000000) * value;
> +
> + mvreg_write(pp, MVNETA_RXQ_TIME_COAL_REG(rxq->id), val);
> + rxq->time_coal = value;
> +}
> +
> +/* Set threshold for TX_DONE pkts coalescing */
> +static void mvneta_tx_done_pkts_coal_set(struct mvneta_port *pp,
> + struct mvneta_tx_queue *txq, u32 value)
> +{
> + u32 val;
> +
> + val = mvreg_read(pp, MVNETA_TXQ_SIZE_REG(txq->id));
> +
> + val &= ~MVNETA_TXQ_SENT_THRESH_ALL_MASK;
> + val |= MVNETA_TXQ_SENT_THRESH_MASK(value);
> +
> + mvreg_write(pp, MVNETA_TXQ_SIZE_REG(txq->id), val);
> +
> + txq->done_pkts_coal = value;
> +}
> +
> +/* Trigger tx done timer in MVNETA_TX_DONE_TIMER_PERIOD msecs */
> +static void mvneta_add_tx_done_timer(struct mvneta_port *pp)
> +{
> + if (test_and_set_bit(MVNETA_F_TX_DONE_TIMER_BIT, &pp->flags) == 0) {
> + pp->tx_done_timer.expires = jiffies +
> + msecs_to_jiffies(MVNETA_TX_DONE_TIMER_PERIOD);
> + add_timer(&pp->tx_done_timer);
> + }
> +}
> +
> +
> +/* Handle rx descriptor fill by setting buf_cookie and buf_phys_addr */
> +static void mvneta_rx_desc_fill(struct mvneta_rx_desc *rx_desc,
> + u32 phys_addr, u32 cookie)
> +{
> + rx_desc->buf_cookie = cookie;
> + rx_desc->buf_phys_addr = phys_addr;
> +}
> +
> +/* Decrement sent descriptors counter */
> +static void mvneta_txq_sent_desc_dec(struct mvneta_port *pp,
> + struct mvneta_tx_queue *txq,
> + int sent_desc)
> +{
> + u32 val;
> +
> + /* Only 255 TX descriptors can be updated at once */
> + while (sent_desc > 0xff) {
> + val = (0xff << MVNETA_TXQ_DEC_SENT_SHIFT);
Parenthesis.
> + mvreg_write(pp, MVNETA_TXQ_UPDATE_REG(txq->id), val);
> + sent_desc = sent_desc - 0xff;
> + }
> +
> + val = (sent_desc << MVNETA_TXQ_DEC_SENT_SHIFT);
Parenthesis.
[...]
> +static u32 mvneta_txq_desc_csum(int l3_offs, int l3_proto,
> + int ip_hdr_len, int l4_proto)
> +{
> + u32 command;
> +
> + /* Fields: L3_offset, IP_hdrlen, L3_type, G_IPv4_chk,
> + G_L4_chk, L4_type; required only for checksum
> + calculation */
> + command = (l3_offs << MVNETA_TX_L3_OFF_SHIFT);
> + command |= (ip_hdr_len << MVNETA_TX_IP_HLEN_SHIFT);
Parenthesis.
> +
> + if (l3_proto == swab16(ETH_P_IP))
> + command |= MVNETA_TXD_IP_CSUM;
> + else
> + command |= MVNETA_TX_L3_IP6;
> +
> + if (l4_proto == IPPROTO_TCP)
> + command |= MVNETA_TX_L4_CSUM_FULL;
> + else if (l4_proto == IPPROTO_UDP)
> + command |= (MVNETA_TX_L4_UDP | MVNETA_TX_L4_CSUM_FULL);
> + else
> + command |= MVNETA_TX_L4_CSUM_NOT;
> +
> + return command;
> +}
> +
> +/* Display more error info */
> +static void mvneta_rx_error(struct mvneta_port *pp,
> + struct mvneta_rx_desc *rx_desc)
> +{
> + u32 status = rx_desc->status;
> +
> + if ((status & MVNETA_RXD_FIRST_LAST_DESC)
> + != MVNETA_RXD_FIRST_LAST_DESC) {
if ((status & MVNETA_RXD_FIRST_LAST_DESC) !=
MVNETA_RXD_FIRST_LAST_DESC) {
The length of the MVNETA prefix is a self inflicted pain.
(...]
> +static struct mvneta_tx_queue *mvneta_tx_done_policy(struct mvneta_port *pp,
> + u32 cause)
> +{
> + int queue;
> + queue = fls(cause) - 1;
> + if (queue < 0 || queue >= mvneta_txq_number)
> + return NULL;
> + return &pp->txqs[queue];
return (q < 0 || q >= mvneta_txq_number) ? NULL : &pp->txqs[q]; ?
(I admit it will obviously not resurrect an unicorn)
> +}
> +
> +/* Free tx queue skbuffs */
> +static void mvneta_txq_bufs_free(struct mvneta_port *pp,
> + struct mvneta_tx_queue *txq, int num)
> +{
> + struct sk_buff *skb;
> + int i;
> + struct mvneta_tx_desc *tx_desc;
int i;
> + for (i = 0; i < num; i++) {
> + skb = txq->tx_skb[txq->txq_get_index];
> + tx_desc = txq->descs + txq->txq_get_index;
struct mvneta_tx_desc *tx_desc = txq->descs + txq->txq_get_index;
struct sk_buff *skb = txq->tx_skb[txq->txq_get_index];
> +
> + mvneta_txq_inc_get(txq);
> +
> + if (!skb)
> + continue;
> + if (tx_desc) {
> + dma_unmap_single(pp->dev->dev.parent,
> + tx_desc->buf_phys_addr,
> + tx_desc->data_size,
> + DMA_TO_DEVICE);
> + dev_kfree_skb_any(skb);
if (!(skb && txd))
continue;
dma_unmap_single(pp->dev->dev.parent, tx_desc->buf_phys_addr,
tx_desc->data_size, DMA_TO_DEVICE);
> + }
> + }
> +}
> +
> +/* Handle end of transmission */
> +static int mvneta_txq_done(struct mvneta_port *pp,
> + struct mvneta_tx_queue *txq)
> +{
> + int tx_done;
> +
> + tx_done = mvneta_txq_sent_desc_proc(pp, txq);
> + if (tx_done == 0)
> + return tx_done;
> + mvneta_txq_bufs_free(pp, txq, tx_done);
> +
> + txq->count -= tx_done;
> +
> + return tx_done;
> +}
> +
> +/* Refill processing */
> +static int mvneta_rx_refill(struct mvneta_port *pp,
> + struct mvneta_rx_desc *rx_desc)
> +
> +{
> + unsigned long phys_addr;
dma_addr_t phys_addr;
> + struct sk_buff *skb;
> +
> + skb = netdev_alloc_skb(pp->dev, pp->pkt_size);
> + if (!skb)
> + return 1;
> +
> + phys_addr = dma_map_single(pp->dev->dev.parent, skb->head,
> + MVNETA_RX_BUF_SIZE(pp->pkt_size),
> + DMA_FROM_DEVICE);
> + if (unlikely(dma_mapping_error(pp->dev->dev.parent,
> + phys_addr))) {
> + dev_kfree_skb_irq(skb);
dev_kfree_skb in softirq context.
[...]
> +static struct mvneta_rx_queue *mvneta_rx_policy(struct mvneta_port *pp,
> + u32 cause)
> +{
> + int queue = fls(cause >> 8) - 1;
> + if (queue < 0 || queue >= mvneta_rxq_number)
> + return NULL;
> + return &pp->rxqs[queue];
> +}
> +
> +/* Drop packets received by the RXQ and free buffers */
> +static void mvneta_rxq_drop_pkts(struct mvneta_port *pp,
> + struct mvneta_rx_queue *rxq)
> +{
> + struct mvneta_rx_desc *rx_desc;
> + struct sk_buff *skb;
Variable scope.
> + int rx_done, i;
> +
> + rx_done = mvneta_rxq_busy_desc_num_get(pp, rxq);
> + for (i = 0; i < rxq->size; i++) {
> + rx_desc = rxq->descs + i;
> + skb = (struct sk_buff *)rx_desc->buf_cookie;
> + dev_kfree_skb_any(skb);
> + dma_unmap_single(pp->dev->dev.parent, rx_desc->buf_phys_addr,
> + rx_desc->data_size, DMA_FROM_DEVICE);
> +
> +
> + }
> + if (rx_done)
> + mvneta_rxq_desc_num_update(pp, rxq, rx_done, rx_done);
> +}
> +
> +
> +/* Main rx processing */
> +static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
> + struct mvneta_rx_queue *rxq)
> +{
> + struct net_device *dev = pp->dev;
> +
> + int rx_done, rx_filled, err;
> + struct mvneta_rx_desc *rx_desc;
Variable scope.
> + u32 rx_status;
> + int rx_bytes;
> + struct sk_buff *skb;
> +
> + /* Get number of received packets */
> + rx_done = mvneta_rxq_busy_desc_num_get(pp, rxq);
> +
> + if (rx_todo > rx_done)
> + rx_todo = rx_done;
> +
> + rx_done = 0;
> + rx_filled = 0;
> +
> + /* Fairness NAPI loop */
> + while (rx_done < rx_todo) {
> + rx_desc = mvneta_rxq_next_desc_get(rxq);
> + prefetch(rx_desc);
> + rx_done++;
> + rx_filled++;
> + rx_status = rx_desc->status;
> + skb = (struct sk_buff *)rx_desc->buf_cookie;
> +
> + if (((rx_status & MVNETA_RXD_FIRST_LAST_DESC)
> + != MVNETA_RXD_FIRST_LAST_DESC)
> + || (rx_status & MVNETA_RXD_ERR_SUMMARY)) {
...
> + dev->stats.rx_errors++;
> + mvneta_rx_error(pp, rx_desc);
> + mvneta_rx_desc_fill(rx_desc, rx_desc->buf_phys_addr,
> + (u32)skb);
> + continue;
> + }
> +
> + dma_unmap_single(pp->dev->dev.parent, rx_desc->buf_phys_addr,
> + rx_desc->data_size, DMA_FROM_DEVICE);
> +
> + rx_bytes = rx_desc->data_size -
> + (MVNETA_ETH_CRC_SIZE + MVNETA_MH_SIZE);
> + u64_stats_update_begin(&pp->rx_stats.syncp);
> + pp->rx_stats.packets++;
> + pp->rx_stats.bytes += rx_bytes;
> + u64_stats_update_end(&pp->rx_stats.syncp);
> +
> + /* Linux processing */
> + skb->data += MVNETA_MH_SIZE;
> + skb->tail += (rx_bytes + MVNETA_MH_SIZE);
skb_reserve + skb_put would be more idiomatic imho.
> + skb->len = rx_bytes;
> +
> + skb->protocol = eth_type_trans(skb, dev);
> +
> + mvneta_rx_csum(pp, rx_desc, skb);
> +
> + if (dev->features & NETIF_F_GRO)
> + napi_gro_receive(&pp->napi, skb);
> + else
> + netif_receive_skb(skb);
No test. Go for straight napi_gro_receive.
> +
> + /* Refill processing */
> + err = mvneta_rx_refill(pp, rx_desc);
> + if (err) {
> + netdev_err(pp->dev, "Linux processing - Can't refill\n");
> + rxq->missed++;
> + rx_filled--;
> + }
> + }
> +
> + /* Update rxq management counters */
> + mvneta_rxq_desc_num_update(pp, rxq, rx_done, rx_filled);
> +
> + return rx_done;
> +}
> +
> +/* Handle tx fragmentation processing */
> +static int mvneta_tx_frag_process(struct mvneta_port *pp, struct sk_buff *skb,
> + struct mvneta_tx_queue *txq)
> +{
> + int i, j;
> + struct mvneta_tx_desc *tx_desc;
> + skb_frag_t *frag;
struct device *d = pp->dev->dev.parent;
struct mvneta_tx_desc *tx_desc;
int i, j;
> +
> + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
> + frag = &skb_shinfo(skb)->frags[i];
skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
void *addr = page_address(frag->page.p) + frag->page_offset;
> +
> + tx_desc = mvneta_txq_next_desc_get(txq);
> + tx_desc->data_size = frag->size;
> +
> + tx_desc->buf_phys_addr =
> + dma_map_single(pp->dev->dev.parent,
> + page_address(frag->page.p) +
> + frag->page_offset, tx_desc->data_size,
> + DMA_TO_DEVICE);
tx_desc->buf_phys_addr = dma_map_single(d, addr, frag->size,
DMA_TO_DEVICE);
[...]
> +static int mvneta_tx(struct sk_buff *skb, struct net_device *dev)
> +{
> + struct mvneta_port *pp = netdev_priv(dev);
> + int frags = 0;
> + int res = NETDEV_TX_OK;
> + u32 tx_cmd;
> + struct mvneta_tx_queue *txq = &pp->txqs[mvneta_txq_def];
> + struct mvneta_tx_desc *tx_desc;
Longer first.
> +
> + if (!netif_running(dev))
> + goto out;
> +
> + frags = skb_shinfo(skb)->nr_frags + 1;
> +
> + /* Are there enough TX descriptors to send packet ? */
Never. You must disable queueing before it's too late.
> + if ((txq->count + frags) >= txq->size) {
> + frags = 0;
> + res = NETDEV_TX_BUSY;
> + goto out;
> + }
> +
> + /* Get a descriptor for the first part of the packet */
> + tx_desc = mvneta_txq_next_desc_get(txq);
> +
> + tx_cmd = mvneta_skb_tx_csum(pp, skb);
> +
> + tx_desc->data_size = skb_headlen(skb);
> +
> + tx_desc->buf_phys_addr = dma_map_single(dev->dev.parent, skb->data,
> + tx_desc->data_size,
> + DMA_TO_DEVICE);
> + if (unlikely(dma_mapping_error(dev->dev.parent,
> + tx_desc->buf_phys_addr))) {
> + mvneta_txq_desc_put(txq);
> + frags = 0;
> + res = NETDEV_TX_BUSY;
Neither. You drop the packet, update the stats and return ok.
> + goto out;
> + }
> +
> + if (frags == 1) {
> + /* First and Last descriptor */
> + tx_cmd |= MVNETA_TXD_FLZ_DESC;
> + tx_desc->command = tx_cmd;
> + txq->tx_skb[txq->txq_put_index] = skb;
> + mvneta_txq_inc_put(txq);
> + } else {
> + /* First but not Last */
> + tx_cmd |= MVNETA_TXD_F_DESC;
> + txq->tx_skb[txq->txq_put_index] = NULL;
> + mvneta_txq_inc_put(txq);
> + tx_desc->command = tx_cmd;
> + /* Continue with other skb fragments */
> + if (mvneta_tx_frag_process(pp, skb, txq)) {
> + dma_unmap_single(dev->dev.parent,
> + tx_desc->buf_phys_addr,
> + tx_desc->data_size,
> + DMA_TO_DEVICE);
> + mvneta_txq_desc_put(txq);
> + frags = 0;
> + res = NETDEV_TX_BUSY;
Sic.
[...]
> +/* handle tx done - called from tx done timer callback */
> +static u32 mvneta_tx_done_gbe(struct mvneta_port *pp, u32 cause_tx_done,
> + int *tx_todo)
Why is it not done in napi context ?
--
Ueimor
^ permalink raw reply
* Re: [PATCH] ipv6: Enable enough of the code to handle GOS when disabled.
From: Rami Rosen @ 2012-10-11 21:30 UTC (permalink / raw)
To: Vlad Yasevich; +Cc: netdev, davem
In-Reply-To: <1349990103-29689-1-git-send-email-vyasevic@redhat.com>
Hi,
Typo:
It should be "handle GSO" and not "handle GOS" in the patch title.
regards,
Rami Rosen
On Thu, Oct 11, 2012 at 11:15 PM, Vlad Yasevich <vyasevic@redhat.com> wrote:
> When a guest using virtio is attempting to use IPv6 on a host where
> IPv6 module is administratively disabled, the tcp bulk thransfer rate
> drops down to 10kbps. The problem is that when IPv6 is disabled,
> none of the protocol handlers are registered. When the guest
> attempts to send an IPv6 packet with GSO (which is the default), this
> packet is dropped by the host stack because there are no gso handlers
> registered. Thus a retransmit is triggerd for ever GSO packet, reducing
> the transfer rate.
>
> This patch attempts to solve this by enabling just enough code that GSO
> is correctly processed. However, I should point out that if IPv6 is
> simply blacklisted or not build for the kernel, this problem will
> still persist.
>
> This problem also exists for AF_PACKET sockets, so it is not limited
> to guests using virtio.
>
> Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
> ---
> include/linux/ipv6.h | 1 +
> include/net/ipv6.h | 5 +++
> net/ipv6/af_inet6.c | 69 +++++++++++++++++++++++++++++++++++++++++++++---
> net/ipv6/ip6_input.c | 5 +++
> net/ipv6/reassembly.c | 11 +++++--
> net/ipv6/tcp_ipv6.c | 9 +++++-
> net/ipv6/udp.c | 6 +++-
> 7 files changed, 95 insertions(+), 11 deletions(-)
>
> diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
> index 0b94e91..1d5e061 100644
> --- a/include/linux/ipv6.h
> +++ b/include/linux/ipv6.h
> @@ -176,6 +176,7 @@ struct ipv6_devconf {
> };
>
> struct ipv6_params {
> + __s32 disable_ipv6_mod;
> __s32 disable_ipv6;
> __s32 autoconf;
> };
> diff --git a/include/net/ipv6.h b/include/net/ipv6.h
> index 979bf6c..cda75b4 100644
> --- a/include/net/ipv6.h
> +++ b/include/net/ipv6.h
> @@ -550,6 +550,11 @@ extern int ipv6_rcv(struct sk_buff *skb,
> struct packet_type *pt,
> struct net_device *orig_dev);
>
> +extern int ipv6_rcv_stub(struct sk_buff *skb,
> + struct net_device *dev,
> + struct packet_type *pt,
> + struct net_device *orig_dev);
> +
> extern int ip6_rcv_finish(struct sk_buff *skb);
>
> /*
> diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
> index a974247..1fd0d73 100644
> --- a/net/ipv6/af_inet6.c
> +++ b/net/ipv6/af_inet6.c
> @@ -74,13 +74,13 @@ static struct list_head inetsw6[SOCK_MAX];
> static DEFINE_SPINLOCK(inetsw6_lock);
>
> struct ipv6_params ipv6_defaults = {
> + .disable_ipv6_mod = 0,
> .disable_ipv6 = 0,
> .autoconf = 1,
> };
>
> -static int disable_ipv6_mod;
>
> -module_param_named(disable, disable_ipv6_mod, int, 0444);
> +module_param_named(disable, ipv6_defaults.disable_ipv6_mod, int, 0444);
> MODULE_PARM_DESC(disable, "Disable IPv6 module such that it is non-functional");
>
> module_param_named(disable_ipv6, ipv6_defaults.disable_ipv6, int, 0444);
> @@ -1048,6 +1048,53 @@ static struct pernet_operations inet6_net_ops = {
> .exit = inet6_net_exit,
> };
>
> +/* This function is called when IPv6 is administratively disabled.
> + * Its sole purpose is to set up enough of IPv6 that GSO/TSO will work
> + * for any outgoing IPv6 packets that may have been generated by
> + * guest or AF_PACKET sockets.
> + */
> +static int inet6_init_disabled(void)
> +{
> + int err = 0;
> +
> + /* Init v6 extension headers. */
> + err = ipv6_exthdrs_init();
> + if (err)
> + goto out;
> +
> + err = ipv6_frag_init();
> + if (err)
> + goto ipv6_frag_fail;
> +
> + /* Init v6 transport protocols. UDP-light doesn't support GSO so
> + * it is omitted
> + */
> + err = udpv6_init();
> + if (err)
> + goto udpv6_fail;
> +
> + err = tcpv6_init();
> + if (err)
> + goto tcpv6_fail;
> +
> + err = ipv6_packet_init();
> + if (err)
> + goto ipv6_packet_fail;
> +
> + return 0;
> +
> +ipv6_packet_fail:
> + tcpv6_exit();
> +tcpv6_fail:
> + udpv6_exit();
> +udpv6_fail:
> + ipv6_frag_exit();
> +ipv6_frag_fail:
> + ipv6_exthdrs_exit();
> +out:
> + return err;
> +}
> +
> static int __init inet6_init(void)
> {
> struct sk_buff *dummy_skb;
> @@ -1060,8 +1107,9 @@ static int __init inet6_init(void)
> for (r = &inetsw6[0]; r < &inetsw6[SOCK_MAX]; ++r)
> INIT_LIST_HEAD(r);
>
> - if (disable_ipv6_mod) {
> + if (ipv6_defaults.disable_ipv6_mod) {
> pr_info("Loaded, but administratively disabled, reboot required to enable\n");
> + err = inet6_init_disabled();
> goto out;
> }
>
> @@ -1238,11 +1286,22 @@ out_unregister_tcp_proto:
> }
> module_init(inet6_init);
>
> +static void __exit inet6_exit_disabled(void)
> +{
> + ipv6_packet_cleanup();
> + ipv6_frag_exit();
> + ipv6_exthdrs_exit();
> + udpv6_exit();
> + tcpv6_exit();
> +}
> +
> static void __exit inet6_exit(void)
> {
> - if (disable_ipv6_mod)
> + if (ipv6_defaults.disable_ipv6_mod) {
> + inet6_exit_disabled();
> return;
> -
> + }
> +
> /* First of all disallow new sockets creation. */
> sock_unregister(PF_INET6);
> /* Disallow any further netlink messages */
> diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
> index a52d864..3e86ec3 100644
> --- a/net/ipv6/ip6_input.c
> +++ b/net/ipv6/ip6_input.c
> @@ -74,6 +74,11 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
> return NET_RX_DROP;
> }
>
> + if (ipv6_defaults.disable_ipv6_mod) {
> + kfree_skb(skb);
> + return NET_RX_DROP;
> + }
> +
> rcu_read_lock();
>
> idev = __in6_dev_get(skb->dev);
> diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
> index da8a4e3..71a0e61 100644
> --- a/net/ipv6/reassembly.c
> +++ b/net/ipv6/reassembly.c
> @@ -705,6 +705,9 @@ int __init ipv6_frag_init(void)
> if (ret)
> goto out;
>
> + if (ipv6_defaults.disable_ipv6_mod)
> + goto out;
> +
> ret = ip6_frags_sysctl_register();
> if (ret)
> goto err_sysctl;
> @@ -734,8 +737,10 @@ err_sysctl:
>
> void ipv6_frag_exit(void)
> {
> - inet_frags_fini(&ip6_frags);
> - ip6_frags_sysctl_unregister();
> - unregister_pernet_subsys(&ip6_frags_ops);
> + if (!ipv6_defaults.disable_ipv6_mod) {
> + inet_frags_fini(&ip6_frags);
> + ip6_frags_sysctl_unregister();
> + unregister_pernet_subsys(&ip6_frags_ops);
> + }
> inet6_del_protocol(&frag_protocol, IPPROTO_FRAGMENT);
> }
> diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
> index 49c8903..ebb297c 100644
> --- a/net/ipv6/tcp_ipv6.c
> +++ b/net/ipv6/tcp_ipv6.c
> @@ -2109,6 +2109,9 @@ int __init tcpv6_init(void)
> if (ret)
> goto out;
>
> + if (ipv6_defaults.disable_ipv6_mod)
> + goto out;
> +
> /* register inet6 protocol */
> ret = inet6_register_protosw(&tcpv6_protosw);
> if (ret)
> @@ -2129,7 +2132,9 @@ out_tcpv6_protosw:
>
> void tcpv6_exit(void)
> {
> - unregister_pernet_subsys(&tcpv6_net_ops);
> - inet6_unregister_protosw(&tcpv6_protosw);
> + if (!ipv6_defaults.disable_ipv6_mod) {
> + unregister_pernet_subsys(&tcpv6_net_ops);
> + inet6_unregister_protosw(&tcpv6_protosw);
> + }
> inet6_del_protocol(&tcpv6_protocol, IPPROTO_TCP);
> }
> diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
> index fc99972..2e8dddb 100644
> --- a/net/ipv6/udp.c
> +++ b/net/ipv6/udp.c
> @@ -1569,6 +1569,9 @@ int __init udpv6_init(void)
> if (ret)
> goto out;
>
> + if (ipv6_defaults.disable_ipv6_mod)
> + goto out;
> +
> ret = inet6_register_protosw(&udpv6_protosw);
> if (ret)
> goto out_udpv6_protocol;
> @@ -1582,6 +1585,7 @@ out_udpv6_protocol:
>
> void udpv6_exit(void)
> {
> - inet6_unregister_protosw(&udpv6_protosw);
> + if (!ipv6_defaults.disable_ipv6_mod)
> + inet6_unregister_protosw(&udpv6_protosw);
> inet6_del_protocol(&udpv6_protocol, IPPROTO_UDP);
> }
> --
> 1.7.7.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" 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: amd64, v3.6.0: Kernel panic + BUG at net/netfilter/nf_conntrack_core.c:220!
From: Borislav Petkov @ 2012-10-11 21:27 UTC (permalink / raw)
To: Ian Applegate; +Cc: linux-kernel, netfilter-devel, netfilter, coreteam, netdev
In-Reply-To: <CAEcaRjj-xBqEAz_6UHbTZWrvjHB7QUvUUmEvmtuyPJU+iudxkQ@mail.gmail.com>
On Thu, Oct 11, 2012 at 12:13:33PM -0700, Ian Applegate wrote:
> On machines serving mainly http traffic we are seeing the following
> panic, which is not yet reproducible.
Must be this BUG_ON:
if (!nf_ct_is_confirmed(ct)) {
BUG_ON(hlist_nulls_unhashed(&ct->tuplehash[IP_CT_DIR_ORIGINAL].hnnode));
hlist_nulls_del_rcu(&ct->tuplehash[IP_CT_DIR_ORIGINAL].hnnode);
}
Spamming some more lists and leaving the rest for reference.
>
>
> [180926.566743] ------------[ cut here ]------------
> [180926.572034] kernel BUG at net/netfilter/nf_conntrack_core.c:220!
> [180926.578873] invalid opcode: 0000 [#1] SMP
> [180926.583594] Modules linked in: xfs exportfs ipmi_devintf ipmi_si
> ipmi_msghandler dm_mod md_mod nf_conntr
> ack_ipv6 nf_defrag_ipv6 ip6table_filter ip6table_raw ip6_tables
> nf_conntrack_ipv4 nf_defrag_ipv4 xt_tcpudp x
> t_conntrack xt_multiport iptable_filter xt_NOTRACK nf_conntrack
> iptable_raw ip_tables x_tables nfsv4 auth_rp
> cgss fuse nfsv3 nfs_acl nfs fscache lockd sunrpc sfc mtd i2c_algo_bit
> i2c_core mdio igb dca uhci_hcd coretem
> p acpi_cpufreq kvm_intel kvm crc32c_intel aesni_intel ablk_helper
> cryptd aes_x86_64 aes_generic evdev sd_mod
> crc_t10dif mperf snd_pcm ahci snd_timer tpm_tis microcode snd tpm
> libahci tpm_bios soundcore libata snd_pag
> e_alloc pcspkr ehci_hcd lpc_ich usbcore mfd_core hpsa scsi_mod
> usb_common button processor thermal_sys
> [180926.657762] CPU 12
> [180926.660008] Pid: 5948, comm: nginx-fl Not tainted 3.6.0-cloudflare
> #1 HP ProLiant DL180 G6
> [180926.669820] RIP: 0010:[<ffffffffa02ccdd1>] [<ffffffffa02ccdd1>]
> destroy_conntrack+0x55/0xa9 [nf_conntrack]
> [180926.680871] RSP: 0018:ffff8805bd73fbb8 EFLAGS: 00010246
> [180926.686930] RAX: 0000000000000000 RBX: ffff8806b6f56c30 RCX:
> ffff8805bd73fc48
> [180926.695055] RDX: 0000000000000000 RSI: 0000000000000006 RDI:
> ffff8806b6f56c30
> [180926.703179] RBP: ffffffff81651780 R08: 00000000000172e0 R09:
> ffffffff812cef91
> [180926.711304] R10: dead000000200200 R11: dead000000100100 R12:
> ffff8806b6f56c30
> [180926.727451] R13: 0000000000000000 R14: ffffffffa02d6030 R15:
> 0000000000000000
> [180926.735575] FS: 00007f382cdb2710(0000) GS:ffff880627cc0000(0000)
> knlGS:0000000000000000
> [180926.744766] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [180926.751312] CR2: ffffffffff600400 CR3: 00000005bd8d3000 CR4:
> 00000000000007e0
> [180926.759436] DR0: 0000000000000000 DR1: 0000000000000000 DR2:
> 0000000000000000
> [180926.767560] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7:
> 0000000000000400
> [180926.775686] Process nginx-fl (pid: 5948, threadinfo
> ffff8805bd73e000, task ffff8805c9755960)
> [180926.785265] Stack:
> [180926.787634] 0000000000000000 ffffffff81651780 ffff8802720c2900
> ffffffffa02cde78
> [180926.796087] ffffffff81651ec0 ffffffffa02d6030 00000000bff0efab
> ffff8805ffffffff
> [180926.804532] 0002880500000002 0000000300000014 0000001400000003
> 06ff880600000002
> [180926.812985] Call Trace:
> [180926.815845] [<ffffffffa02cde78>] ? nf_conntrack_in+0x4ed/0x5bc
> [nf_conntrack]
> [180926.824069] [<ffffffff812ac195>] ? nf_iterate+0x41/0x77
> [180926.830131] [<ffffffff812b3820>] ? ip_options_echo+0x2ed/0x2ed
> [180926.836873] [<ffffffff812ac2ee>] ? nf_hook_slow+0x68/0xfd
> [180926.843127] [<ffffffff812b3820>] ? ip_options_echo+0x2ed/0x2ed
> [180926.849866] [<ffffffff812b55a8>] ? __ip_local_out+0x98/0x9d
> [180926.856315] [<ffffffff812b55b6>] ? ip_local_out+0x9/0x19
> [180926.862465] [<ffffffff812c7582>] ? tcp_transmit_skb+0x7ae/0x7f1
> [180926.869305] [<ffffffff810fff4c>] ? virt_to_head_page+0x9/0x2c
> [180926.875949] [<ffffffff812c78a6>] ? tcp_send_active_reset+0xd5/0x101
> [180926.883175] [<ffffffff812bc38f>] ? tcp_close+0x118/0x354
> [180926.889334] [<ffffffff812dbdc2>] ? inet_release+0x75/0x7b
> [180926.895591] [<ffffffff81278bff>] ? sock_release+0x19/0x73
> [180926.901845] [<ffffffff81278c7b>] ? sock_close+0x22/0x27
> [180926.907906] [<ffffffff81109de8>] ? __fput+0xe9/0x1ae
> [180926.913677] [<ffffffff81057157>] ? task_work_run+0x53/0x67
> [180926.920031] [<ffffffff8100e50c>] ? do_notify_resume+0x79/0x8d
> [180926.926673] [<ffffffff8134e5b2>] ? int_signal+0x12/0x17
> [180926.932732] Code: 05 48 89 df ff d0 48 c7 c7 30 66 2d a0 e8 11 b0
> 07 e1 48 89 df e8 72 25 00 00 48 8b 43
> 78 a8 08 75 2a 48 8b 53 10 48 85 d2 75 04 <0f> 0b eb fe 48 8b 43 08
> 48 89 02 a8 01 75 04 48 89 50 08 48 be
> [180926.954788] RIP [<ffffffffa02ccdd1>] destroy_conntrack+0x55/0xa9
> [nf_conntrack]
> [180926.963217] RSP <ffff8805bd73fbb8>
> [180926.967700] ---[ end trace 54a660a52afd5820 ]---
> [180926.973038] Kernel panic - not syncing: Fatal exception in interrupt
>
> ---
> Ian Applegate
> CloudFlare
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
Regards/Gruss,
Boris.
^ permalink raw reply
* Re: [PATCH] iPhone 5 support for ipheth.
From: David Miller @ 2012-10-11 21:15 UTC (permalink / raw)
To: jspurohit; +Cc: netdev
In-Reply-To: <CADx9NEdOWe1m2PnUcnr6VD7d-Cohr2mNu1FMih80hDD5Lic2BQ@mail.gmail.com>
From: Jay Purohit <jspurohit@velocitylimitless.com>
Date: Thu, 11 Oct 2012 16:08:09 -0500
> I noticed that the iPhone ethernet driver did not support
> iPhone 5. I quickly added support to it in my kernel, here's
> a patch.
>
> Signed-off-by: Jay Purohit <jspurohit@velocitylimitless.com>
> Acked-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
>
> --- linux-3.6.1/drivers/net/usb/ipheth.c 2012-10-07
> 10:41:28.000000000 -0500
> +++ new/linux-3.6.1/drivers/net/usb/ipheth.c 2012-10-11
> 11:38:17.242000596 -0500
Patch corrupted by your email client, please fix this up and resend
after you've verified that you can email yourself this patch and
apply the patch that you receive in the email just fine.
^ permalink raw reply
* [PATCH] ipv6: Enable enough of the code to handle GOS when disabled.
From: Vlad Yasevich @ 2012-10-11 21:15 UTC (permalink / raw)
To: netdev; +Cc: davem, Vlad Yasevich
When a guest using virtio is attempting to use IPv6 on a host where
IPv6 module is administratively disabled, the tcp bulk thransfer rate
drops down to 10kbps. The problem is that when IPv6 is disabled,
none of the protocol handlers are registered. When the guest
attempts to send an IPv6 packet with GSO (which is the default), this
packet is dropped by the host stack because there are no gso handlers
registered. Thus a retransmit is triggerd for ever GSO packet, reducing
the transfer rate.
This patch attempts to solve this by enabling just enough code that GSO
is correctly processed. However, I should point out that if IPv6 is
simply blacklisted or not build for the kernel, this problem will
still persist.
This problem also exists for AF_PACKET sockets, so it is not limited
to guests using virtio.
Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
---
include/linux/ipv6.h | 1 +
include/net/ipv6.h | 5 +++
net/ipv6/af_inet6.c | 69 +++++++++++++++++++++++++++++++++++++++++++++---
net/ipv6/ip6_input.c | 5 +++
net/ipv6/reassembly.c | 11 +++++--
net/ipv6/tcp_ipv6.c | 9 +++++-
net/ipv6/udp.c | 6 +++-
7 files changed, 95 insertions(+), 11 deletions(-)
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index 0b94e91..1d5e061 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -176,6 +176,7 @@ struct ipv6_devconf {
};
struct ipv6_params {
+ __s32 disable_ipv6_mod;
__s32 disable_ipv6;
__s32 autoconf;
};
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 979bf6c..cda75b4 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -550,6 +550,11 @@ extern int ipv6_rcv(struct sk_buff *skb,
struct packet_type *pt,
struct net_device *orig_dev);
+extern int ipv6_rcv_stub(struct sk_buff *skb,
+ struct net_device *dev,
+ struct packet_type *pt,
+ struct net_device *orig_dev);
+
extern int ip6_rcv_finish(struct sk_buff *skb);
/*
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index a974247..1fd0d73 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -74,13 +74,13 @@ static struct list_head inetsw6[SOCK_MAX];
static DEFINE_SPINLOCK(inetsw6_lock);
struct ipv6_params ipv6_defaults = {
+ .disable_ipv6_mod = 0,
.disable_ipv6 = 0,
.autoconf = 1,
};
-static int disable_ipv6_mod;
-module_param_named(disable, disable_ipv6_mod, int, 0444);
+module_param_named(disable, ipv6_defaults.disable_ipv6_mod, int, 0444);
MODULE_PARM_DESC(disable, "Disable IPv6 module such that it is non-functional");
module_param_named(disable_ipv6, ipv6_defaults.disable_ipv6, int, 0444);
@@ -1048,6 +1048,53 @@ static struct pernet_operations inet6_net_ops = {
.exit = inet6_net_exit,
};
+/* This function is called when IPv6 is administratively disabled.
+ * Its sole purpose is to set up enough of IPv6 that GSO/TSO will work
+ * for any outgoing IPv6 packets that may have been generated by
+ * guest or AF_PACKET sockets.
+ */
+static int inet6_init_disabled(void)
+{
+ int err = 0;
+
+ /* Init v6 extension headers. */
+ err = ipv6_exthdrs_init();
+ if (err)
+ goto out;
+
+ err = ipv6_frag_init();
+ if (err)
+ goto ipv6_frag_fail;
+
+ /* Init v6 transport protocols. UDP-light doesn't support GSO so
+ * it is omitted
+ */
+ err = udpv6_init();
+ if (err)
+ goto udpv6_fail;
+
+ err = tcpv6_init();
+ if (err)
+ goto tcpv6_fail;
+
+ err = ipv6_packet_init();
+ if (err)
+ goto ipv6_packet_fail;
+
+ return 0;
+
+ipv6_packet_fail:
+ tcpv6_exit();
+tcpv6_fail:
+ udpv6_exit();
+udpv6_fail:
+ ipv6_frag_exit();
+ipv6_frag_fail:
+ ipv6_exthdrs_exit();
+out:
+ return err;
+}
+
static int __init inet6_init(void)
{
struct sk_buff *dummy_skb;
@@ -1060,8 +1107,9 @@ static int __init inet6_init(void)
for (r = &inetsw6[0]; r < &inetsw6[SOCK_MAX]; ++r)
INIT_LIST_HEAD(r);
- if (disable_ipv6_mod) {
+ if (ipv6_defaults.disable_ipv6_mod) {
pr_info("Loaded, but administratively disabled, reboot required to enable\n");
+ err = inet6_init_disabled();
goto out;
}
@@ -1238,11 +1286,22 @@ out_unregister_tcp_proto:
}
module_init(inet6_init);
+static void __exit inet6_exit_disabled(void)
+{
+ ipv6_packet_cleanup();
+ ipv6_frag_exit();
+ ipv6_exthdrs_exit();
+ udpv6_exit();
+ tcpv6_exit();
+}
+
static void __exit inet6_exit(void)
{
- if (disable_ipv6_mod)
+ if (ipv6_defaults.disable_ipv6_mod) {
+ inet6_exit_disabled();
return;
-
+ }
+
/* First of all disallow new sockets creation. */
sock_unregister(PF_INET6);
/* Disallow any further netlink messages */
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index a52d864..3e86ec3 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -74,6 +74,11 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
return NET_RX_DROP;
}
+ if (ipv6_defaults.disable_ipv6_mod) {
+ kfree_skb(skb);
+ return NET_RX_DROP;
+ }
+
rcu_read_lock();
idev = __in6_dev_get(skb->dev);
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index da8a4e3..71a0e61 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -705,6 +705,9 @@ int __init ipv6_frag_init(void)
if (ret)
goto out;
+ if (ipv6_defaults.disable_ipv6_mod)
+ goto out;
+
ret = ip6_frags_sysctl_register();
if (ret)
goto err_sysctl;
@@ -734,8 +737,10 @@ err_sysctl:
void ipv6_frag_exit(void)
{
- inet_frags_fini(&ip6_frags);
- ip6_frags_sysctl_unregister();
- unregister_pernet_subsys(&ip6_frags_ops);
+ if (!ipv6_defaults.disable_ipv6_mod) {
+ inet_frags_fini(&ip6_frags);
+ ip6_frags_sysctl_unregister();
+ unregister_pernet_subsys(&ip6_frags_ops);
+ }
inet6_del_protocol(&frag_protocol, IPPROTO_FRAGMENT);
}
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 49c8903..ebb297c 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -2109,6 +2109,9 @@ int __init tcpv6_init(void)
if (ret)
goto out;
+ if (ipv6_defaults.disable_ipv6_mod)
+ goto out;
+
/* register inet6 protocol */
ret = inet6_register_protosw(&tcpv6_protosw);
if (ret)
@@ -2129,7 +2132,9 @@ out_tcpv6_protosw:
void tcpv6_exit(void)
{
- unregister_pernet_subsys(&tcpv6_net_ops);
- inet6_unregister_protosw(&tcpv6_protosw);
+ if (!ipv6_defaults.disable_ipv6_mod) {
+ unregister_pernet_subsys(&tcpv6_net_ops);
+ inet6_unregister_protosw(&tcpv6_protosw);
+ }
inet6_del_protocol(&tcpv6_protocol, IPPROTO_TCP);
}
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index fc99972..2e8dddb 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -1569,6 +1569,9 @@ int __init udpv6_init(void)
if (ret)
goto out;
+ if (ipv6_defaults.disable_ipv6_mod)
+ goto out;
+
ret = inet6_register_protosw(&udpv6_protosw);
if (ret)
goto out_udpv6_protocol;
@@ -1582,6 +1585,7 @@ out_udpv6_protocol:
void udpv6_exit(void)
{
- inet6_unregister_protosw(&udpv6_protosw);
+ if (!ipv6_defaults.disable_ipv6_mod)
+ inet6_unregister_protosw(&udpv6_protosw);
inet6_del_protocol(&udpv6_protocol, IPPROTO_UDP);
}
--
1.7.7.6
^ permalink raw reply related
* [PATCH] iPhone 5 support for ipheth.
From: Jay Purohit @ 2012-10-11 21:08 UTC (permalink / raw)
To: netdev
In-Reply-To: <CADx9NEeyPUNrOiWHn97eOTp5skBqa7D9t8m_90QDAgs+kKtybg@mail.gmail.com>
I noticed that the iPhone ethernet driver did not support
iPhone 5. I quickly added support to it in my kernel, here's
a patch.
Signed-off-by: Jay Purohit <jspurohit@velocitylimitless.com>
Acked-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
--- linux-3.6.1/drivers/net/usb/ipheth.c 2012-10-07
10:41:28.000000000 -0500
+++ new/linux-3.6.1/drivers/net/usb/ipheth.c 2012-10-11
11:38:17.242000596 -0500
@@ -62,6 +62,8 @@
#define USB_PRODUCT_IPAD 0x129a
#define USB_PRODUCT_IPHONE_4_VZW 0x129c
#define USB_PRODUCT_IPHONE_4S 0x12a0
+#define USB_PRODUCT_IPHONE_5 0x12a8
+
#define IPHETH_USBINTF_CLASS 255
#define IPHETH_USBINTF_SUBCLASS 253
@@ -113,6 +115,10 @@
USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4S,
IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
IPHETH_USBINTF_PROTO) },
+ { USB_DEVICE_AND_INTERFACE_INFO(
+ USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_5,
+ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
+ IPHETH_USBINTF_PROTO) },
{ }
};
MODULE_DEVICE_TABLE(usb, ipheth_table);
^ permalink raw reply
* [PATCH RFC 7/7] cpsw: use the time stamping capabilities of the cpts
From: Richard Cochran @ 2012-10-11 20:27 UTC (permalink / raw)
To: netdev
Cc: linux-arm-kernel, David Miller, Cyril Chemparathy, Mugunthan V N,
Sriramakrishnan A G
In-Reply-To: <cover.1349985570.git.richardcochran@gmail.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
drivers/net/ethernet/ti/cpsw.c | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 5a7ed50..32a52ec 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -35,6 +35,7 @@
#include <linux/platform_data/cpsw.h>
#include "cpsw_ale.h"
+#include "cpts.h"
#include "davinci_cpdma.h"
#define CPSW_DEBUG (NETIF_MSG_HW | NETIF_MSG_WOL | \
@@ -238,6 +239,7 @@ struct cpsw_priv {
/* snapshot of IRQ numbers */
u32 irqs_table[4];
u32 num_irqs;
+ struct cpts cpts;
};
#define napi_to_priv(napi) container_of(napi, struct cpsw_priv, napi)
@@ -274,6 +276,7 @@ void cpsw_tx_handler(void *token, int len, int status)
if (unlikely(netif_queue_stopped(ndev)))
netif_start_queue(ndev);
+ cpts_tx_timestamp(&priv->cpts, skb);
priv->stats.tx_packets++;
priv->stats.tx_bytes += len;
dev_kfree_skb_any(skb);
@@ -294,6 +297,7 @@ void cpsw_rx_handler(void *token, int len, int status)
}
if (likely(status >= 0)) {
skb_put(skb, len);
+ cpts_rx_timestamp(&priv->cpts, skb);
skb->protocol = eth_type_trans(skb, ndev);
netif_receive_skb(skb);
priv->stats.rx_bytes += len;
@@ -612,6 +616,11 @@ static netdev_tx_t cpsw_ndo_start_xmit(struct sk_buff *skb,
return NETDEV_TX_OK;
}
+ if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP && priv->cpts.tx_enable)
+ skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
+
+ skb_tx_timestamp(skb);
+
ret = cpdma_chan_submit(priv->txch, skb, skb->data,
skb->len, GFP_KERNEL);
if (unlikely(ret != 0)) {
@@ -649,6 +658,21 @@ static void cpsw_ndo_change_rx_flags(struct net_device *ndev, int flags)
dev_err(&ndev->dev, "multicast traffic cannot be filtered!\n");
}
+static int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
+{
+ struct cpsw_priv *priv = netdev_priv(dev);
+
+ if (!netif_running(dev))
+ return -EINVAL;
+
+ switch (cmd) {
+ case SIOCSHWTSTAMP:
+ return cpts_hwtstamp_ioctl(&priv->cpts, req);
+ }
+
+ return -ENOTSUPP;
+}
+
static void cpsw_ndo_tx_timeout(struct net_device *ndev)
{
struct cpsw_priv *priv = netdev_priv(ndev);
@@ -689,6 +713,7 @@ static const struct net_device_ops cpsw_netdev_ops = {
.ndo_stop = cpsw_ndo_stop,
.ndo_start_xmit = cpsw_ndo_start_xmit,
.ndo_change_rx_flags = cpsw_ndo_change_rx_flags,
+ .ndo_do_ioctl = cpsw_ndo_ioctl,
.ndo_validate_addr = eth_validate_addr,
.ndo_change_mtu = eth_change_mtu,
.ndo_tx_timeout = cpsw_ndo_tx_timeout,
@@ -978,6 +1003,8 @@ static int __devinit cpsw_probe(struct platform_device *pdev)
priv->regs = regs;
priv->host_port = data->host_port_num;
priv->host_port_regs = regs + data->host_port_reg_ofs;
+ priv->cpts.reg = regs + data->cpts_reg_ofs;
+ priv->cpts.tsp = regs + priv->data.slave_data[0].slave_reg_ofs;
priv->cpsw_ss_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (!priv->cpsw_ss_res) {
@@ -1099,6 +1126,11 @@ static int __devinit cpsw_probe(struct platform_device *pdev)
goto clean_irq_ret;
}
+ if (cpts_register(&pdev->dev, &priv->cpts))
+ dev_err(priv->dev, "error registering cpts device\n");
+
+ __raw_writel(ETH_P_1588, &priv->regs->ts_ltype);
+
cpsw_notice(priv, probe, "initialized device (regs %x, irq %d)\n",
priv->cpsw_res->start, ndev->irq);
@@ -1138,6 +1170,7 @@ static int __devexit cpsw_remove(struct platform_device *pdev)
pr_info("removing device");
platform_set_drvdata(pdev, NULL);
+ cpts_unregister(&priv->cpts);
free_irq(ndev->irq, priv);
cpsw_ale_destroy(priv->ale);
cpdma_chan_destroy(priv->txch);
--
1.7.2.5
^ permalink raw reply related
* [PATCH RFC 6/7] cpsw: add a DT field for the cpts offset
From: Richard Cochran @ 2012-10-11 20:27 UTC (permalink / raw)
To: netdev
Cc: linux-arm-kernel, David Miller, Cyril Chemparathy, Mugunthan V N,
Sriramakrishnan A G
In-Reply-To: <cover.1349985570.git.richardcochran@gmail.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
Documentation/devicetree/bindings/net/cpsw.txt | 3 +++
drivers/net/ethernet/ti/cpsw.c | 7 +++++++
include/linux/platform_data/cpsw.h | 1 +
3 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/Documentation/devicetree/bindings/net/cpsw.txt b/Documentation/devicetree/bindings/net/cpsw.txt
index 3af47b7..dba014f 100644
--- a/Documentation/devicetree/bindings/net/cpsw.txt
+++ b/Documentation/devicetree/bindings/net/cpsw.txt
@@ -16,6 +16,7 @@ Required properties:
- ale_entries : Specifies No of entries ALE can hold
- host_port_reg_ofs : Specifies host port register offset
- hw_stats_reg_ofs : Specifies hardware statistics register offset
+- cpts_reg_ofs : Specifies the offset of the CPTS registers
- bd_ram_ofs : Specifies internal desciptor RAM offset
- bd_ram_size : Specifies internal descriptor RAM size
- rx_descs : Specifies number of Rx descriptors
@@ -52,6 +53,7 @@ Examples:
ale_entries = <1024>;
host_port_reg_ofs = <0x108>;
hw_stats_reg_ofs = <0x900>;
+ cpts_reg_ofs = <0xc00>;
bd_ram_ofs = <0x2000>;
bd_ram_size = <0x2000>;
no_bd_ram = <0>;
@@ -86,6 +88,7 @@ Examples:
ale_entries = <1024>;
host_port_reg_ofs = <0x108>;
hw_stats_reg_ofs = <0x900>;
+ cpts_reg_ofs = <0xc00>;
bd_ram_ofs = <0x2000>;
bd_ram_size = <0x2000>;
no_bd_ram = <0>;
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 600699e..5a7ed50 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -819,6 +819,13 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
}
data->hw_stats_reg_ofs = prop;
+ if (of_property_read_u32(node, "cpts_reg_ofs", &prop)) {
+ pr_err("Missing cpts_reg_ofs property in the DT.\n");
+ ret = -EINVAL;
+ goto error_ret;
+ }
+ data->cpts_reg_ofs = prop;
+
if (of_property_read_u32(node, "bd_ram_ofs", &prop)) {
pr_err("Missing bd_ram_ofs property in the DT.\n");
ret = -EINVAL;
diff --git a/include/linux/platform_data/cpsw.h b/include/linux/platform_data/cpsw.h
index c4e23d0..a052b1d 100644
--- a/include/linux/platform_data/cpsw.h
+++ b/include/linux/platform_data/cpsw.h
@@ -41,6 +41,7 @@ struct cpsw_platform_data {
u32 host_port_num; /* The port number for the host port */
u32 hw_stats_reg_ofs; /* cpsw hardware statistics counters */
+ u32 cpts_reg_ofs; /* cpts registers */
u32 bd_ram_ofs; /* embedded buffer descriptor RAM offset*/
u32 bd_ram_size; /*buffer descriptor ram size */
--
1.7.2.5
^ permalink raw reply related
* [PATCH RFC 5/7] cpts: introduce time stamping code and a PTP hardware clock.
From: Richard Cochran @ 2012-10-11 20:27 UTC (permalink / raw)
To: netdev
Cc: linux-arm-kernel, David Miller, Cyril Chemparathy, Mugunthan V N,
Sriramakrishnan A G
In-Reply-To: <cover.1349985570.git.richardcochran@gmail.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
drivers/net/ethernet/ti/Kconfig | 8 +
drivers/net/ethernet/ti/Makefile | 2 +-
drivers/net/ethernet/ti/cpts.c | 469 ++++++++++++++++++++++++++++++++++++++
drivers/net/ethernet/ti/cpts.h | 148 ++++++++++++
4 files changed, 626 insertions(+), 1 deletions(-)
create mode 100644 drivers/net/ethernet/ti/cpts.c
create mode 100644 drivers/net/ethernet/ti/cpts.h
diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig
index b26cbda..cbc3905 100644
--- a/drivers/net/ethernet/ti/Kconfig
+++ b/drivers/net/ethernet/ti/Kconfig
@@ -60,6 +60,14 @@ config TI_CPSW
To compile this driver as a module, choose M here: the module
will be called cpsw.
+config TI_CPTS
+ boolean "TI Common Platform Time Sync (CPTS) Support"
+ depends on TI_CPSW && PTP_1588_CLOCK && !(TI_CPSW=y && PTP_1588_CLOCK=m)
+ ---help---
+ This driver supports the Common Platform Time Sync unit of
+ the CPSW Ethernet Switch. The unit can time stamp PTP UDP/IPv4
+ and Layer 2 packets, and the driver offers a PTP Hardware Clock.
+
config TLAN
tristate "TI ThunderLAN support"
depends on (PCI || EISA)
diff --git a/drivers/net/ethernet/ti/Makefile b/drivers/net/ethernet/ti/Makefile
index 91bd8bb..c65148e 100644
--- a/drivers/net/ethernet/ti/Makefile
+++ b/drivers/net/ethernet/ti/Makefile
@@ -8,4 +8,4 @@ obj-$(CONFIG_TI_DAVINCI_EMAC) += davinci_emac.o
obj-$(CONFIG_TI_DAVINCI_MDIO) += davinci_mdio.o
obj-$(CONFIG_TI_DAVINCI_CPDMA) += davinci_cpdma.o
obj-$(CONFIG_TI_CPSW) += ti_cpsw.o
-ti_cpsw-y := cpsw_ale.o cpsw.o
+ti_cpsw-y := cpsw_ale.o cpsw.o cpts.o
diff --git a/drivers/net/ethernet/ti/cpts.c b/drivers/net/ethernet/ti/cpts.c
new file mode 100644
index 0000000..b7547db
--- /dev/null
+++ b/drivers/net/ethernet/ti/cpts.c
@@ -0,0 +1,469 @@
+/*
+ * TI Common Platform Time Sync
+ *
+ * Copyright (C) 2012 Richard Cochran <richardcochran@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include <linux/err.h>
+#include <linux/if.h>
+#include <linux/hrtimer.h>
+#include <linux/module.h>
+#include <linux/net_tstamp.h>
+#include <linux/ptp_classify.h>
+#include <linux/time.h>
+#include <linux/uaccess.h>
+#include <linux/workqueue.h>
+
+#include <plat/clock.h>
+
+#include "cpts.h"
+
+#ifdef CONFIG_TI_CPTS
+
+static struct sock_filter ptp_filter[] = {
+ PTP_FILTER
+};
+
+#define cpts_read32(c, r) __raw_readl(&c->reg->r)
+#define cpts_write32(c, v, r) __raw_writel(v, &c->reg->r)
+#define port_read32(c, r) __raw_readl(&c->tsp->r)
+#define port_write32(c, v, r) __raw_writel(v, &c->tsp->r)
+
+static int event_expired(struct cpts_event *event)
+{
+ return time_after(jiffies, event->tmo);
+}
+
+static int event_type(struct cpts_event *event)
+{
+ return (event->high >> EVENT_TYPE_SHIFT) & EVENT_TYPE_MASK;
+}
+
+static int cpts_fifo_pop(struct cpts *cpts, u32 *high, u32 *low)
+{
+ u32 r = cpts_read32(cpts, intstat_raw);
+
+ if (r & TS_PEND_RAW) {
+ *high = cpts_read32(cpts, event_high);
+ *low = cpts_read32(cpts, event_low);
+ cpts_write32(cpts, EVENT_POP, event_pop);
+ return 0;
+ }
+ return -1;
+}
+
+/*
+ * Returns zero if matching event type was found.
+ */
+static int cpts_fifo_read(struct cpts *cpts, int match)
+{
+ int i, type = -1;
+ u32 hi, lo;
+ struct cpts_event *event;
+
+ for (i = 0; i < CPTS_FIFO_DEPTH; i++) {
+ if (cpts_fifo_pop(cpts, &hi, &lo))
+ break;
+ if (list_empty(&cpts->pool)) {
+ pr_err("cpts: event pool is empty\n");
+ return -1;
+ }
+ event = list_first_entry(&cpts->pool, struct cpts_event, list);
+ event->tmo = jiffies + 2;
+ event->high = hi;
+ event->low = lo;
+ type = event_type(event);
+ switch (type) {
+ case CPTS_EV_PUSH:
+ case CPTS_EV_RX:
+ case CPTS_EV_TX:
+ list_del_init(&event->list);
+ list_add_tail(&event->list, &cpts->events);
+ break;
+ case CPTS_EV_ROLL:
+ case CPTS_EV_HALF:
+ case CPTS_EV_HW:
+ break;
+ default:
+ pr_err("cpts: unkown event type\n");
+ break;
+ }
+ if (type == match)
+ break;
+ }
+ return type == match ? 0 : -1;
+}
+
+static cycle_t cpts_systim_read(const struct cyclecounter *cc)
+{
+ u64 val = 0;
+ struct cpts_event *event;
+ struct list_head *this, *next;
+ struct cpts *cpts = container_of(cc, struct cpts, cc);
+
+ cpts_write32(cpts, TS_PUSH, ts_push);
+ if (cpts_fifo_read(cpts, CPTS_EV_PUSH))
+ pr_err("cpts: unable to obtain a time stamp\n");
+
+ list_for_each_safe(this, next, &cpts->events) {
+ event = list_entry(this, struct cpts_event, list);
+ if (event_type(event) == CPTS_EV_PUSH) {
+ list_del_init(&event->list);
+ list_add(&event->list, &cpts->pool);
+ val = event->low;
+ break;
+ }
+ }
+
+ return val;
+}
+
+/* PTP clock operations */
+
+static int cpts_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
+{
+ return 0;
+}
+
+static int cpts_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
+{
+ s64 now;
+ unsigned long flags;
+ struct cpts *cpts = container_of(ptp, struct cpts, info);
+
+ spin_lock_irqsave(&cpts->lock, flags);
+ now = timecounter_read(&cpts->tc);
+ now += delta;
+ timecounter_init(&cpts->tc, &cpts->cc, now);
+ spin_unlock_irqrestore(&cpts->lock, flags);
+
+ return 0;
+}
+
+static int cpts_ptp_gettime(struct ptp_clock_info *ptp, struct timespec *ts)
+{
+ u64 ns;
+ u32 remainder;
+ unsigned long flags;
+ struct cpts *cpts = container_of(ptp, struct cpts, info);
+
+ spin_lock_irqsave(&cpts->lock, flags);
+ ns = timecounter_read(&cpts->tc);
+ spin_unlock_irqrestore(&cpts->lock, flags);
+
+ ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder);
+ ts->tv_nsec = remainder;
+
+ return 0;
+}
+
+static int cpts_ptp_settime(struct ptp_clock_info *ptp,
+ const struct timespec *ts)
+{
+ u64 ns;
+ unsigned long flags;
+ struct cpts *cpts = container_of(ptp, struct cpts, info);
+
+ ns = ts->tv_sec * 1000000000ULL;
+ ns += ts->tv_nsec;
+
+ spin_lock_irqsave(&cpts->lock, flags);
+ timecounter_init(&cpts->tc, &cpts->cc, ns);
+ spin_unlock_irqrestore(&cpts->lock, flags);
+
+ return 0;
+}
+
+static int cpts_ptp_enable(struct ptp_clock_info *ptp,
+ struct ptp_clock_request *rq, int on)
+{
+ return -EOPNOTSUPP;
+}
+
+static struct ptp_clock_info cpts_info = {
+ .owner = THIS_MODULE,
+ .name = "CTPS timer",
+ .max_adj = 1,
+ .n_ext_ts = 0,
+ .pps = 0,
+ .adjfreq = cpts_ptp_adjfreq,
+ .adjtime = cpts_ptp_adjtime,
+ .gettime = cpts_ptp_gettime,
+ .settime = cpts_ptp_settime,
+ .enable = cpts_ptp_enable,
+};
+
+static void cpts_overflow_check(struct work_struct *work)
+{
+ struct timespec ts;
+ struct cpts *cpts = container_of(work, struct cpts, overflow_work.work);
+
+ cpts_write32(cpts, CPTS_EN, control);
+ cpts_write32(cpts, TS_PEND_EN, int_enable);
+ cpts_ptp_gettime(&cpts->info, &ts);
+ pr_debug("cpts overflow check at %ld.%09lu\n", ts.tv_sec, ts.tv_nsec);
+ schedule_delayed_work(&cpts->overflow_work, CPTS_OVERFLOW_PERIOD);
+}
+
+#define CPTS_REF_CLOCK_NAME "cpsw_cpts_rft_clk"
+
+static void cpts_clk_init(struct cpts *cpts)
+{
+ cpts->refclk = clk_get(NULL, CPTS_REF_CLOCK_NAME);
+ if (IS_ERR(cpts->refclk)) {
+ pr_err("Failed to clk_get %s\n", CPTS_REF_CLOCK_NAME);
+ cpts->refclk = NULL;
+ return;
+ }
+ clk_enable(cpts->refclk);
+ cpts->freq = cpts->refclk->recalc(cpts->refclk);
+ pr_err("freq = %lu\n", cpts->freq);
+}
+
+static void cpts_clk_release(struct cpts *cpts)
+{
+ clk_disable(cpts->refclk);
+ clk_put(cpts->refclk);
+}
+
+static int cpts_match(struct sk_buff *skb, unsigned int ptp_class,
+ u16 ts_seqid, u8 ts_msgtype)
+{
+ u16 *seqid;
+ unsigned int offset;
+ u8 *msgtype, *data = skb->data;
+
+ switch (ptp_class) {
+ case PTP_CLASS_V1_IPV4:
+ case PTP_CLASS_V2_IPV4:
+ offset = ETH_HLEN + IPV4_HLEN(data) + UDP_HLEN;
+ break;
+ case PTP_CLASS_V1_IPV6:
+ case PTP_CLASS_V2_IPV6:
+ offset = OFF_PTP6;
+ break;
+ case PTP_CLASS_V2_L2:
+ offset = ETH_HLEN;
+ break;
+ case PTP_CLASS_V2_VLAN:
+ offset = ETH_HLEN + VLAN_HLEN;
+ break;
+ default:
+ return 0;
+ }
+
+ if (skb->len + ETH_HLEN < offset + OFF_PTP_SEQUENCE_ID + sizeof(*seqid))
+ return 0;
+
+ if (unlikely(ptp_class & PTP_CLASS_V1))
+ msgtype = data + offset + OFF_PTP_CONTROL;
+ else
+ msgtype = data + offset;
+
+ seqid = (u16 *)(data + offset + OFF_PTP_SEQUENCE_ID);
+
+ return (ts_msgtype == (*msgtype & 0xf) && ts_seqid == ntohs(*seqid));
+}
+
+static u64 cpts_find_ts(struct cpts *cpts, struct sk_buff *skb, int ev_type)
+{
+ u64 ns = 0;
+ struct cpts_event *event;
+ struct list_head *this, *next;
+ unsigned int class = sk_run_filter(skb, ptp_filter);
+ unsigned long flags;
+ u16 seqid;
+ u8 mtype;
+
+ if (class == PTP_CLASS_NONE)
+ return 0;
+
+ spin_lock_irqsave(&cpts->lock, flags);
+ cpts_fifo_read(cpts, CPTS_EV_PUSH);
+ list_for_each_safe(this, next, &cpts->events) {
+ event = list_entry(this, struct cpts_event, list);
+ if (event_expired(event)) {
+ list_del_init(&event->list);
+ list_add(&event->list, &cpts->pool);
+ continue;
+ }
+ mtype = (event->high >> MESSAGE_TYPE_SHIFT) & MESSAGE_TYPE_MASK;
+ seqid = (event->high >> SEQUENCE_ID_SHIFT) & SEQUENCE_ID_MASK;
+ if (ev_type == event_type(event) &&
+ cpts_match(skb, class, seqid, mtype)) {
+ ns = timecounter_cyc2time(&cpts->tc, event->low);
+ list_del_init(&event->list);
+ list_add(&event->list, &cpts->pool);
+ break;
+ }
+ }
+ spin_unlock_irqrestore(&cpts->lock, flags);
+
+ return ns;
+}
+
+void cpts_rx_timestamp(struct cpts *cpts, struct sk_buff *skb)
+{
+ u64 ns;
+ struct skb_shared_hwtstamps *ssh;
+
+ if (!cpts->rx_enable)
+ return;
+ ns = cpts_find_ts(cpts, skb, CPTS_EV_RX);
+ if (!ns)
+ return;
+ ssh = skb_hwtstamps(skb);
+ memset(ssh, 0, sizeof(*ssh));
+ ssh->hwtstamp = ns_to_ktime(ns);
+}
+
+void cpts_tx_timestamp(struct cpts *cpts, struct sk_buff *skb)
+{
+ u64 ns;
+ struct skb_shared_hwtstamps ssh;
+
+ if (!(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS))
+ return;
+ ns = cpts_find_ts(cpts, skb, CPTS_EV_TX);
+ if (!ns)
+ return;
+ memset(&ssh, 0, sizeof(ssh));
+ ssh.hwtstamp = ns_to_ktime(ns);
+ skb_tstamp_tx(skb, &ssh);
+}
+
+#endif /*CONFIG_TI_CPTS*/
+
+int cpts_hwtstamp_ioctl(struct cpts *cpts, struct ifreq *ifr)
+{
+#ifdef CONFIG_TI_CPTS
+ struct hwtstamp_config cfg;
+ u32 ctrl, mtype;
+
+ if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg)))
+ return -EFAULT;
+
+ /* reserved for future extensions */
+ if (cfg.flags)
+ return -EINVAL;
+
+ ctrl = port_read32(cpts, control);
+ ctrl &= ~CTRL_ALL_TS_MASK;
+
+ switch (cfg.tx_type) {
+ case HWTSTAMP_TX_OFF:
+ cpts->tx_enable = 0;
+ break;
+ case HWTSTAMP_TX_ON:
+ cpts->tx_enable = 1;
+ ctrl |= CTRL_TX_TS_BITS;
+ break;
+ default:
+ return -ERANGE;
+ }
+
+ switch (cfg.rx_filter) {
+ case HWTSTAMP_FILTER_NONE:
+ cpts->rx_enable = 0;
+ break;
+ case HWTSTAMP_FILTER_ALL:
+ case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
+ case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
+ case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
+ return -ERANGE;
+ case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
+ case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
+ case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
+ case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
+ case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
+ case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
+ case HWTSTAMP_FILTER_PTP_V2_EVENT:
+ case HWTSTAMP_FILTER_PTP_V2_SYNC:
+ case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
+ cpts->rx_enable = 1;
+ cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
+ ctrl |= CTRL_RX_TS_BITS;
+ break;
+ default:
+ return -ERANGE;
+ }
+
+ mtype = (30 << TS_SEQ_ID_OFFSET_SHIFT) | EVENT_MSG_BITS;
+ port_write32(cpts, mtype, ts_seq_mtype);
+ port_write32(cpts, ctrl, control);
+
+ return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0;
+#else
+ return -EOPNOTSUPP;
+#endif
+}
+
+int cpts_register(struct device *dev, struct cpts *cpts)
+{
+#ifdef CONFIG_TI_CPTS
+ int err, i;
+ unsigned long flags;
+
+ if (ptp_filter_init(ptp_filter, ARRAY_SIZE(ptp_filter))) {
+ pr_err("cpts: bad ptp filter\n");
+ return -EINVAL;
+ }
+ cpts->info = cpts_info;
+ cpts->clock = ptp_clock_register(&cpts->info, dev);
+ if (IS_ERR(cpts->clock)) {
+ err = PTR_ERR(cpts->clock);
+ cpts->clock = NULL;
+ return err;
+ }
+ spin_lock_init(&cpts->lock);
+
+ cpts->cc.read = cpts_systim_read;
+ cpts->cc.mask = CLOCKSOURCE_MASK(32);
+ cpts->cc.mult = 4;
+ cpts->cc.shift = 0;
+
+ INIT_LIST_HEAD(&cpts->events);
+ INIT_LIST_HEAD(&cpts->pool);
+ for (i = 0; i < CPTS_MAX_EVENTS; i++)
+ list_add(&cpts->pool_data[i].list, &cpts->pool);
+
+ cpts_clk_init(cpts);
+ cpts_write32(cpts, CPTS_EN, control);
+ cpts_write32(cpts, TS_PEND_EN, int_enable);
+
+ spin_lock_irqsave(&cpts->lock, flags);
+ timecounter_init(&cpts->tc, &cpts->cc, ktime_to_ns(ktime_get_real()));
+ spin_unlock_irqrestore(&cpts->lock, flags);
+
+ INIT_DELAYED_WORK(&cpts->overflow_work, cpts_overflow_check);
+ schedule_delayed_work(&cpts->overflow_work, CPTS_OVERFLOW_PERIOD);
+
+ cpts->phc_index = ptp_clock_index(cpts->clock);
+#endif
+ return 0;
+}
+
+void cpts_unregister(struct cpts *cpts)
+{
+#ifdef CONFIG_TI_CPTS
+ if (cpts->clock) {
+ ptp_clock_unregister(cpts->clock);
+ cancel_delayed_work_sync(&cpts->overflow_work);
+ }
+ if (cpts->refclk)
+ cpts_clk_release(cpts);
+#endif
+}
diff --git a/drivers/net/ethernet/ti/cpts.h b/drivers/net/ethernet/ti/cpts.h
new file mode 100644
index 0000000..86e45ff
--- /dev/null
+++ b/drivers/net/ethernet/ti/cpts.h
@@ -0,0 +1,148 @@
+/*
+ * TI Common Platform Time Sync
+ *
+ * Copyright (C) 2012 Richard Cochran <richardcochran@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef _TI_CPTS_H_
+#define _TI_CPTS_H_
+
+#include <linux/clk.h>
+#include <linux/clkdev.h>
+#include <linux/clocksource.h>
+#include <linux/device.h>
+#include <linux/list.h>
+#include <linux/ptp_clock_kernel.h>
+#include <linux/skbuff.h>
+
+#include "cpsw_reg.h"
+
+struct cpsw_cpts {
+ u32 idver; /* Identification and version */
+ u32 control; /* Time sync control */
+ u32 res1;
+ u32 ts_push; /* Time stamp event push */
+ u32 ts_load_val; /* Time stamp load value */
+ u32 ts_load_en; /* Time stamp load enable */
+ u32 res2[2];
+ u32 intstat_raw; /* Time sync interrupt status raw */
+ u32 intstat_masked; /* Time sync interrupt status masked */
+ u32 int_enable; /* Time sync interrupt enable */
+ u32 res3;
+ u32 event_pop; /* Event interrupt pop */
+ u32 event_low; /* 32 Bit Event Time Stamp */
+ u32 event_high; /* Event Type Fields */
+};
+
+/* Bit definitions for the IDVER register */
+#define TX_IDENT_SHIFT (16) /* TX Identification Value */
+#define TX_IDENT_MASK (0xffff)
+#define RTL_VER_SHIFT (11) /* RTL Version Value */
+#define RTL_VER_MASK (0x1f)
+#define MAJOR_VER_SHIFT (8) /* Major Version Value */
+#define MAJOR_VER_MASK (0x7)
+#define MINOR_VER_SHIFT (0) /* Minor Version Value */
+#define MINOR_VER_MASK (0xff)
+
+/* Bit definitions for the CONTROL register */
+#define HW4_TS_PUSH_EN (1<<11) /* Hardware push 4 enable */
+#define HW3_TS_PUSH_EN (1<<10) /* Hardware push 3 enable */
+#define HW2_TS_PUSH_EN (1<<9) /* Hardware push 2 enable */
+#define HW1_TS_PUSH_EN (1<<8) /* Hardware push 1 enable */
+#define INT_TEST (1<<1) /* Interrupt Test */
+#define CPTS_EN (1<<0) /* Time Sync Enable */
+
+/*
+ * Definitions for the single bit resisters:
+ * TS_PUSH TS_LOAD_EN INTSTAT_RAW INTSTAT_MASKED INT_ENABLE EVENT_POP
+ */
+#define TS_PUSH (1<<0) /* Time stamp event push */
+#define TS_LOAD_EN (1<<0) /* Time Stamp Load */
+#define TS_PEND_RAW (1<<0) /* int read (before enable) */
+#define TS_PEND (1<<0) /* masked interrupt read (after enable) */
+#define TS_PEND_EN (1<<0) /* masked interrupt enable */
+#define EVENT_POP (1<<0) /* writing discards one event */
+
+/* Bit definitions for the EVENT_HIGH register */
+#define PORT_NUMBER_SHIFT (24) /* Indicates Ethernet port or HW pin */
+#define PORT_NUMBER_MASK (0x1f)
+#define EVENT_TYPE_SHIFT (20) /* Time sync event type */
+#define EVENT_TYPE_MASK (0xf)
+#define MESSAGE_TYPE_SHIFT (16) /* PTP message type */
+#define MESSAGE_TYPE_MASK (0xf)
+#define SEQUENCE_ID_SHIFT (0) /* PTP message sequence ID */
+#define SEQUENCE_ID_MASK (0xffff)
+
+enum {
+ CPTS_EV_PUSH, /* Time Stamp Push Event */
+ CPTS_EV_ROLL, /* Time Stamp Rollover Event */
+ CPTS_EV_HALF, /* Time Stamp Half Rollover Event */
+ CPTS_EV_HW, /* Hardware Time Stamp Push Event */
+ CPTS_EV_RX, /* Ethernet Receive Event */
+ CPTS_EV_TX, /* Ethernet Transmit Event */
+};
+
+/* This covers any input clock up to about 500 MHz. */
+#define CPTS_OVERFLOW_PERIOD (HZ * 8)
+
+#define CPTS_FIFO_DEPTH 16
+#define CPTS_MAX_EVENTS 32
+
+struct cpts_event {
+ struct list_head list;
+ unsigned long tmo;
+ u32 high;
+ u32 low;
+};
+
+struct cpts {
+ struct cpsw_cpts __iomem *reg;
+ struct cpsw_port __iomem *tsp;
+ int tx_enable;
+#ifdef CONFIG_TI_CPTS
+ int rx_enable;
+ struct ptp_clock_info info;
+ struct ptp_clock *clock;
+ spinlock_t lock; /* protects time registers */
+ struct cyclecounter cc;
+ struct timecounter tc;
+ struct delayed_work overflow_work;
+ int phc_index;
+ struct clk *refclk;
+ unsigned long freq;
+ struct list_head events;
+ struct list_head pool;
+ struct cpts_event pool_data[CPTS_MAX_EVENTS];
+#endif
+};
+
+#ifdef CONFIG_TI_CPTS
+extern void cpts_rx_timestamp(struct cpts *cpts, struct sk_buff *skb);
+extern void cpts_tx_timestamp(struct cpts *cpts, struct sk_buff *skb);
+#else
+static inline void cpts_rx_timestamp(struct cpts *cpts, struct sk_buff *skb)
+{
+}
+static inline void cpts_tx_timestamp(struct cpts *cpts, struct sk_buff *skb)
+{
+}
+#endif
+
+extern int cpts_hwtstamp_ioctl(struct cpts *cpts, struct ifreq *ifr);
+extern int cpts_register(struct device *dev, struct cpts *cpts);
+extern void cpts_unregister(struct cpts *cpts);
+
+#endif
--
1.7.2.5
^ permalink raw reply related
* [PATCH RFC 4/7] cpsw: add a common header file for regsiter declarations
From: Richard Cochran @ 2012-10-11 20:27 UTC (permalink / raw)
To: netdev
Cc: linux-arm-kernel, David Miller, Cyril Chemparathy, Mugunthan V N,
Sriramakrishnan A G
In-Reply-To: <cover.1349985570.git.richardcochran@gmail.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
drivers/net/ethernet/ti/cpsw_reg.h | 81 ++++++++++++++++++++++++++++++++++++
1 files changed, 81 insertions(+), 0 deletions(-)
create mode 100644 drivers/net/ethernet/ti/cpsw_reg.h
diff --git a/drivers/net/ethernet/ti/cpsw_reg.h b/drivers/net/ethernet/ti/cpsw_reg.h
new file mode 100644
index 0000000..88fb15f
--- /dev/null
+++ b/drivers/net/ethernet/ti/cpsw_reg.h
@@ -0,0 +1,81 @@
+/*
+ * Common CPSW register declarations
+ *
+ * Copyright (C) 2012 Richard Cochran <richardcochran@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef _TI_CPSW_REG_H_
+#define _TI_CPSW_REG_H_
+
+struct cpsw_port {
+ u32 control; /* Control Register */
+ u32 res1;
+ u32 max_blks; /* Maximum FIFO Blocks */
+ u32 blk_cnt; /* FIFO Block Usage Count (Read Only) */
+ u32 tx_in_ctl; /* Transmit FIFO Control */
+ u32 port_vlan; /* VLAN Register */
+ u32 tx_pri_map; /* Tx Header Priority to Switch Pri Map */
+ u32 ts_seq_mtype; /* Time Sync Seq ID Offset and Msg Type */
+ u32 sa_lo; /* CPGMAC_SL Source Address Low */
+ u32 sa_hi; /* CPGMAC_SL Source Address High */
+ u32 send_percent; /* Transmit Queue Send Percentages */
+ u32 res2;
+ u32 rx_dscp_pri_map0; /* Rx DSCP Priority to Rx Packet Mapping */
+ u32 rx_dscp_pri_map1; /* Rx DSCP Priority to Rx Packet Mapping */
+ u32 rx_dscp_pri_map2; /* Rx DSCP Priority to Rx Packet Mapping */
+ u32 rx_dscp_pri_map3; /* Rx DSCP Priority to Rx Packet Mapping */
+ u32 rx_dscp_pri_map4; /* Rx DSCP Priority to Rx Packet Mapping */
+ u32 rx_dscp_pri_map5; /* Rx DSCP Priority to Rx Packet Mapping */
+ u32 rx_dscp_pri_map6; /* Rx DSCP Priority to Rx Packet Mapping */
+ u32 rx_dscp_pri_map7; /* Rx DSCP Priority to Rx Packet Mapping */
+};
+
+/* Bit definitions for the CONTROL register */
+#define PASS_PRI_TAGGED (1<<24) /* Pass Priority Tagged */
+#define VLAN_LTYPE2_EN (1<<21) /* VLAN LTYPE 2 enable */
+#define VLAN_LTYPE1_EN (1<<20) /* VLAN LTYPE 1 enable */
+#define DSCP_PRI_EN (1<<16) /* DSCP Priority Enable */
+#define TS_320 (1<<14) /* Time Sync Dest Port 320 enable */
+#define TS_319 (1<<13) /* Time Sync Dest Port 319 enable */
+#define TS_132 (1<<12) /* Time Sync Dest IP Addr 132 enable */
+#define TS_131 (1<<11) /* Time Sync Dest IP Addr 131 enable */
+#define TS_130 (1<<10) /* Time Sync Dest IP Addr 130 enable */
+#define TS_129 (1<<9) /* Time Sync Dest IP Addr 129 enable */
+#define TS_BIT8 (1<<8) /* ts_ttl_nonzero? */
+#define TS_ANNEX_D_EN (1<<4) /* Time Sync Annex D enable */
+#define TS_LTYPE2_EN (1<<3) /* Time Sync LTYPE 2 enable */
+#define TS_LTYPE1_EN (1<<2) /* Time Sync LTYPE 1 enable */
+#define TS_TX_EN (1<<1) /* Time Sync Transmit Enable */
+#define TS_RX_EN (1<<0) /* Time Sync Receive Enable */
+
+#define CTRL_TS_BITS \
+ (TS_320 | TS_319 | TS_132 | TS_131 | TS_130 | TS_129 | TS_BIT8 | \
+ TS_ANNEX_D_EN | TS_LTYPE2_EN | TS_LTYPE1_EN)
+
+#define CTRL_ALL_TS_MASK (CTRL_TS_BITS | TS_TX_EN | TS_RX_EN)
+#define CTRL_TX_TS_BITS (CTRL_TS_BITS | TS_TX_EN)
+#define CTRL_RX_TS_BITS (CTRL_TS_BITS | TS_RX_EN)
+
+/* Bit definitions for the TS_SEQ_MTYPE register */
+#define TS_SEQ_ID_OFFSET_SHIFT (16) /* Time Sync Sequence ID Offset */
+#define TS_SEQ_ID_OFFSET_MASK (0x3f)
+#define TS_MSG_TYPE_EN_SHIFT (0) /* Time Sync Message Type Enable */
+#define TS_MSG_TYPE_EN_MASK (0xffff)
+
+/* The PTP event messages - Sync, Delay_Req, Pdelay_Req, and Pdelay_Resp. */
+#define EVENT_MSG_BITS ((1<<0) | (1<<1) | (1<<2) | (1<<3))
+
+#endif
--
1.7.2.5
^ permalink raw reply related
* [PATCH RFC 3/7] cpsw: correct the CPSW_PORT register bank declaration
From: Richard Cochran @ 2012-10-11 20:27 UTC (permalink / raw)
To: netdev
Cc: linux-arm-kernel, David Miller, Cyril Chemparathy, Mugunthan V N,
Sriramakrishnan A G
In-Reply-To: <cover.1349985570.git.richardcochran@gmail.com>
This commit corrects and expands the slave port register bank
according to TI's Technical Reference Manual.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
Documentation/devicetree/bindings/net/cpsw.txt | 8 ++++----
drivers/net/ethernet/ti/cpsw.c | 14 +++++++++++++-
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/Documentation/devicetree/bindings/net/cpsw.txt b/Documentation/devicetree/bindings/net/cpsw.txt
index dcaabe9..3af47b7 100644
--- a/Documentation/devicetree/bindings/net/cpsw.txt
+++ b/Documentation/devicetree/bindings/net/cpsw.txt
@@ -59,14 +59,14 @@ Examples:
mac_control = <0x20>;
slaves = <2>;
cpsw_emac0: slave@0 {
- slave_reg_ofs = <0x208>;
+ slave_reg_ofs = <0x200>;
sliver_reg_ofs = <0xd80>;
phy_id = "davinci_mdio.16:00";
/* Filled in by U-Boot */
mac-address = [ 00 00 00 00 00 00 ];
};
cpsw_emac1: slave@1 {
- slave_reg_ofs = <0x308>;
+ slave_reg_ofs = <0x300>;
sliver_reg_ofs = <0xdc0>;
phy_id = "davinci_mdio.16:01";
/* Filled in by U-Boot */
@@ -93,14 +93,14 @@ Examples:
mac_control = <0x20>;
slaves = <2>;
cpsw_emac0: slave@0 {
- slave_reg_ofs = <0x208>;
+ slave_reg_ofs = <0x200>;
sliver_reg_ofs = <0xd80>;
phy_id = "davinci_mdio.16:00";
/* Filled in by U-Boot */
mac-address = [ 00 00 00 00 00 00 ];
};
cpsw_emac1: slave@1 {
- slave_reg_ofs = <0x308>;
+ slave_reg_ofs = <0x300>;
sliver_reg_ofs = <0xdc0>;
phy_id = "davinci_mdio.16:01";
/* Filled in by U-Boot */
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 24304e8..600699e 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -157,9 +157,11 @@ struct cpsw_ss_regs {
};
struct cpsw_slave_regs {
+ u32 control;
+ u32 res1;
u32 max_blks;
u32 blk_cnt;
- u32 flow_thresh;
+ u32 tx_in_ctl;
u32 port_vlan;
u32 tx_pri_map;
u32 ts_ctl;
@@ -167,6 +169,16 @@ struct cpsw_slave_regs {
u32 ts_vlan;
u32 sa_lo;
u32 sa_hi;
+ u32 send_percent;
+ u32 res2;
+ u32 rx_dscp_pri_map0;
+ u32 rx_dscp_pri_map1;
+ u32 rx_dscp_pri_map2;
+ u32 rx_dscp_pri_map3;
+ u32 rx_dscp_pri_map4;
+ u32 rx_dscp_pri_map5;
+ u32 rx_dscp_pri_map6;
+ u32 rx_dscp_pri_map7;
};
struct cpsw_host_regs {
--
1.7.2.5
^ permalink raw reply related
* [PATCH RFC 2/7] cpsw: add missing fields to the CPSW_SS register bank.
From: Richard Cochran @ 2012-10-11 20:27 UTC (permalink / raw)
To: netdev
Cc: linux-arm-kernel, David Miller, Cyril Chemparathy, Mugunthan V N,
Sriramakrishnan A G
In-Reply-To: <cover.1349985570.git.richardcochran@gmail.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
drivers/net/ethernet/ti/cpsw.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index a996188..24304e8 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -146,6 +146,14 @@ struct cpsw_ss_regs {
u32 soft_reset;
u32 stat_port_en;
u32 ptype;
+ u32 soft_idle;
+ u32 thru_rate;
+ u32 gap_thresh;
+ u32 tx_start_wds;
+ u32 flow_control;
+ u32 vlan_ltype;
+ u32 ts_ltype;
+ u32 dlr_ltype;
};
struct cpsw_slave_regs {
--
1.7.2.5
^ permalink raw reply related
* [PATCH RFC 1/7] cpsw: rename register banks to match the reference manual
From: Richard Cochran @ 2012-10-11 20:27 UTC (permalink / raw)
To: netdev
Cc: linux-arm-kernel, David Miller, Cyril Chemparathy, Mugunthan V N,
Sriramakrishnan A G
In-Reply-To: <cover.1349985570.git.richardcochran@gmail.com>
The code mixes up the CPSW_SS and the CPSW_WR register naming. This patch
changes the names to conform to the published Technical Reference Manual
from TI, in order to make working on the code less confusing.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
drivers/net/ethernet/ti/cpsw.c | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index df55e24..a996188 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -129,7 +129,7 @@ static int rx_packet_max = CPSW_MAX_PACKET_SIZE;
module_param(rx_packet_max, int, 0);
MODULE_PARM_DESC(rx_packet_max, "maximum receive packet size (bytes)");
-struct cpsw_ss_regs {
+struct cpsw_wr_regs {
u32 id_ver;
u32 soft_reset;
u32 control;
@@ -140,7 +140,7 @@ struct cpsw_ss_regs {
u32 misc_en;
};
-struct cpsw_regs {
+struct cpsw_ss_regs {
u32 id_ver;
u32 control;
u32 soft_reset;
@@ -202,8 +202,8 @@ struct cpsw_priv {
struct napi_struct napi;
struct device *dev;
struct cpsw_platform_data data;
- struct cpsw_regs __iomem *regs;
- struct cpsw_ss_regs __iomem *ss_regs;
+ struct cpsw_ss_regs __iomem *regs;
+ struct cpsw_wr_regs __iomem *wr_regs;
struct cpsw_host_regs __iomem *host_port_regs;
u32 msg_enable;
struct net_device_stats stats;
@@ -230,8 +230,8 @@ struct cpsw_priv {
static void cpsw_intr_enable(struct cpsw_priv *priv)
{
- __raw_writel(0xFF, &priv->ss_regs->tx_en);
- __raw_writel(0xFF, &priv->ss_regs->rx_en);
+ __raw_writel(0xFF, &priv->wr_regs->tx_en);
+ __raw_writel(0xFF, &priv->wr_regs->rx_en);
cpdma_ctlr_int_ctrl(priv->dma, true);
return;
@@ -239,8 +239,8 @@ static void cpsw_intr_enable(struct cpsw_priv *priv)
static void cpsw_intr_disable(struct cpsw_priv *priv)
{
- __raw_writel(0, &priv->ss_regs->tx_en);
- __raw_writel(0, &priv->ss_regs->rx_en);
+ __raw_writel(0, &priv->wr_regs->tx_en);
+ __raw_writel(0, &priv->wr_regs->rx_en);
cpdma_ctlr_int_ctrl(priv->dma, false);
return;
@@ -972,7 +972,7 @@ static int __devinit cpsw_probe(struct platform_device *pdev)
dev_err(priv->dev, "unable to map i/o region\n");
goto clean_cpsw_ss_iores_ret;
}
- priv->ss_regs = regs;
+ priv->wr_regs = regs;
for_each_slave(priv, cpsw_slave_init, priv);
--
1.7.2.5
^ permalink raw reply related
* [PATCH RFC 0/7] support the cpts found on am335x devices
From: Richard Cochran @ 2012-10-11 20:27 UTC (permalink / raw)
To: netdev
Cc: linux-arm-kernel, David Miller, Cyril Chemparathy, Mugunthan V N,
Sriramakrishnan A G
This patch series, based on today's mainline master 12250d8, is a RFC
adding support for the Common Platform Time Sync (CPTS) found on the
popular BeagleBone. The code enables hardware time stamping and a PTP
Hardware Clock.
Due to DT problems with the most current CPSW driver, this work has
been compiled and booted, but not tested. However, I have tested work
similar to this, based on the AM335XPSP_04.06.00.08 branch in TI's
arago repo, and found it to work well.
There are two open issue with this driver, which will hopefully soon
be resolved.
1. ATM it is not possible to adjust the clock frequency. I heard a
rumor that the fractional multipliers on the am335x do not work
when changed, but I have not yet verified this myself. Even if it
turns out to be true, still the driver will be useful for 802.1AS
applications, since they will typically use a free running clock.
2. Time stamping only works on UDP packets. Although Layer 2 is
supposed to work according to the TRM, I have not yet figured out
how. The UDP only works when setting an undocumented bit, so maybe
someone from TI can fill me in on this.
Thanks,
Richard
Richard Cochran (7):
cpsw: rename register banks to match the reference manual
cpsw: add missing fields to the CPSW_SS register bank.
cpsw: correct the CPSW_PORT register bank declaration
cpsw: add a common header file for regsiter declarations
cpts: introduce time stamping code and a PTP hardware clock.
cpsw: add a DT field for the cpts offset
cpsw: use the time stamping capabilities of the cpts
Documentation/devicetree/bindings/net/cpsw.txt | 11 +-
drivers/net/ethernet/ti/Kconfig | 8 +
drivers/net/ethernet/ti/Makefile | 2 +-
drivers/net/ethernet/ti/cpsw.c | 80 ++++-
drivers/net/ethernet/ti/cpsw_reg.h | 81 ++++
drivers/net/ethernet/ti/cpts.c | 469 ++++++++++++++++++++++++
drivers/net/ethernet/ti/cpts.h | 148 ++++++++
include/linux/platform_data/cpsw.h | 1 +
8 files changed, 785 insertions(+), 15 deletions(-)
create mode 100644 drivers/net/ethernet/ti/cpsw_reg.h
create mode 100644 drivers/net/ethernet/ti/cpts.c
create mode 100644 drivers/net/ethernet/ti/cpts.h
--
1.7.2.5
^ permalink raw reply
* Re: [PATCH net-next? V2] pktgen: Use simpler test for non-zero ipv6 address
From: David Miller @ 2012-10-11 19:20 UTC (permalink / raw)
To: joe; +Cc: eric.dumazet, netdev, linux-kernel, brian.haley
In-Reply-To: <1349897005.2035.24.camel@joe-AO722>
From: Joe Perches <joe@perches.com>
Date: Wed, 10 Oct 2012 12:23:25 -0700
> Reduces object size and should be slightly faster.
>
> allyesconfig:
> $ size net/core/pktgen.o*
> text data bss dec hex filename
> 52284 4321 11840 68445 10b5d net/core/pktgen.o.new
> 52310 4293 11848 68451 10b63 net/core/pktgen.o.old
>
> Signed-off-by: Joe Perches <joe@perches.com>
Please resubmit when net-next opens.
^ permalink raw reply
* Re: [PATCH] net/ethernet/jme: disable ASPM
From: David Miller @ 2012-10-11 19:20 UTC (permalink / raw)
To: kevin.baradon; +Cc: mjg59, cooldavid, netdev
In-Reply-To: <20121010225049.024c94cb@laptop-kevin.kbaradon.com>
From: Kevin Baradon <kevin.baradon@gmail.com>
Date: Wed, 10 Oct 2012 22:50:49 +0200
> Subject: [PATCH] net/ethernet/jme: disable ASPM
>
> Based on patch from Matthew Garrett <mjg@redhat.com> (https://lkml.org/lkml/2011/11/11/168).
>
> http://driveragent.com/archive/30421/7-0-14 indicates that ASPM is
> disabled on the 250 and 260. Duplicate for sanity.
>
> Fixes random RX engine hangs I experienced with JMC250 on Clevo W270HU.
>
> Signed-off-by: Kevin Baradon <kevin.baradon@gmail.com>
Applied.
^ permalink raw reply
* Re: [PATCH] Add CDC-ACM support for the CX93010-2x UCMxx USB Modem
From: David Miller @ 2012-10-11 19:20 UTC (permalink / raw)
To: jc; +Cc: netdev, oneukum
In-Reply-To: <1349909342-13379-1-git-send-email-jc@eclis.ch>
From: Jean-Christian de Rivaz <jc@eclis.ch>
Date: Thu, 11 Oct 2012 00:49:02 +0200
> This USB V.92/V.32bis Controllered Modem have the USB vendor ID 0x0572
> and device ID 0x1340. It need the NO_UNION_NORMAL quirk to be recognized.
>
> Reference:
> http://www.conexant.com/servlets/DownloadServlet/DSH-201723-005.pdf?docid=1725&revid=5
> See idVendor and idProduct in table 6-1. Device Descriptors
>
> Signed-off-by: Jean-Christian de Rivaz <jc@eclis.ch>
Applied.
^ permalink raw reply
* Re: [PATCH] usbnet: Support devices reporting idleness
From: David Miller @ 2012-10-11 19:20 UTC (permalink / raw)
To: oliver; +Cc: netdev, oneukum
In-Reply-To: <1349959810-16607-1-git-send-email-oliver@neukum.org>
From: Oliver Neukum <oliver@neukum.org>
Date: Thu, 11 Oct 2012 14:50:10 +0200
> Some device types support a form of power management in which
> the device suggests to the host that the device may be suspended
> now. Support for that is best located in usbnet.
>
> Signed-off-by: Oliver Neukum <oneukum@suse.de>
Applied, but:
> +void usbnet_device_suggests_idle(struct usbnet *dev)
> +{
> + if (!test_and_set_bit(EVENT_DEVICE_REPORT_IDLE, &dev->flags)) {
> + dev->intf->needs_remote_wakeup = 1;
> + usb_autopm_put_interface_async(dev->intf);
> + }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Trailing whitespace.
^ permalink raw reply
* Re: [PATCH] mcs7830: Fix link state detection
From: David Miller @ 2012-10-11 19:20 UTC (permalink / raw)
To: linux; +Cc: andi, gregkh, lkml20120218, netdev, linux-kernel
In-Reply-To: <201210111233.28652.linux@rainbow-software.org>
From: Ondrej Zary <linux@rainbow-software.org>
Date: Thu, 11 Oct 2012 12:33:28 +0200
> The device had an undocumented "feature": it can provide a sequence of
> spurious link-down status data even if the link is up all the time.
> A sequence of 10 was seen so update the link state only after the device
> reports the same link state 20 times.
>
> Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
> Reported-by: Michael Leun <lkml20120218@newton.leun.net>
> Tested-by: Michael Leun <lkml20120218@newton.leun.net>
You've been given feedback on this patch, and also it doesn't apply
cleanly. Perhaps it was corrupted by your email client.
^ permalink raw reply
* Re: [GIT PULL] Disintegrate UAPI for wimax
From: David Miller @ 2012-10-11 19:15 UTC (permalink / raw)
To: dhowells; +Cc: linux-wimax, linux-kernel, inaky.perez-gonzalez, netdev
In-Reply-To: <11849.1349942872@warthog.procyon.org.uk>
From: David Howells <dhowells@redhat.com>
Date: Thu, 11 Oct 2012 09:07:52 +0100
> Can you pull wimax as well?
>
> Sorry about this, but it seems like the majority of the non-arch trees need to
> go through the networking tree.
Done.
^ permalink raw reply
* Re: [PATCH] tcp: sysctl interface leaks 16 bytes of kernel memory
From: David Miller @ 2012-10-11 19:13 UTC (permalink / raw)
To: alan; +Cc: netdev
In-Reply-To: <20121011162407.2590.40301.stgit@bob.linux.org.uk>
From: Alan Cox <alan@lxorguk.ukuu.org.uk>
Date: Thu, 11 Oct 2012 17:24:14 +0100
> From: Alan Cox <alan@linux.intel.com>
>
> If the rc_dereference of tcp_fastopen_ctx ever fails then we copy 16 bytes
> of kernel stack into the proc result.
>
> Signed-off-by: Alan Cox <alan@linux.intel.com>
Applied and queued up for -stable.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox