Netdev List
 help / color / mirror / Atom feed
* [PATCH v2 4/5] net:  Support sending frame with specified FCS.
From: greearb @ 2011-06-18 20:47 UTC (permalink / raw)
  To: netdev; +Cc: Ben Greear
In-Reply-To: <1308430045-24816-1-git-send-email-greearb@candelatech.com>

From: Ben Greear <greearb@candelatech.com>

This allows user-space to send a packet with the
ethernet FCS appended to the end.  Supporting NICs
will know to disable their own FCS calculations and
send frame as is.

This is useful for injecting bad frames on a network
for testing.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
:100644 100644 06edfef... 655fbe7... M	arch/alpha/include/asm/socket.h
:100644 100644 90ffd04... 4aa1c92... M	arch/arm/include/asm/socket.h
:100644 100644 c8d1fae... b70cfa3... M	arch/avr32/include/asm/socket.h
:100644 100644 1a4a619... 54d2d2b... M	arch/cris/include/asm/socket.h
:100644 100644 a6b2688... c77015c... M	arch/frv/include/asm/socket.h
:100644 100644 04c0f45... 5c8a75d... M	arch/h8300/include/asm/socket.h
:100644 100644 51427ea... f0062e6... M	arch/ia64/include/asm/socket.h
:100644 100644 469787c3.. a259a66... M	arch/m32r/include/asm/socket.h
:100644 100644 9bf49c8... 2442b97... M	arch/m68k/include/asm/socket.h
:100644 100644 9de5190... 9b1fe294.. M	arch/mips/include/asm/socket.h
:100644 100644 4e60c42... 1eb5bf5... M	arch/mn10300/include/asm/socket.h
:100644 100644 225b7d6... 22538f0... M	arch/parisc/include/asm/socket.h
:100644 100644 866f760... d1ecf79... M	arch/powerpc/include/asm/socket.h
:100644 100644 fdff1e9... c4ab6ea... M	arch/s390/include/asm/socket.h
:100644 100644 9d3fefc... af8b622... M	arch/sparc/include/asm/socket.h
:100644 100644 cbdf2ff... 4c0cf9c... M	arch/xtensa/include/asm/socket.h
:100644 100644 9a6115e... 22193a2... M	include/asm-generic/socket.h
:100644 100644 c0a4f3a... 05b15be... M	include/linux/skbuff.h
:100644 100644 f2046e4... d7e0d88... M	include/net/sock.h
:100644 100644 46cbd28... a552560... M	net/core/skbuff.c
:100644 100644 6e81978... 0c5f827... M	net/core/sock.c
:100644 100644 c0c3cda... 7b39092... M	net/packet/af_packet.c
 arch/alpha/include/asm/socket.h   |    1 +
 arch/arm/include/asm/socket.h     |    1 +
 arch/avr32/include/asm/socket.h   |    1 +
 arch/cris/include/asm/socket.h    |    1 +
 arch/frv/include/asm/socket.h     |    1 +
 arch/h8300/include/asm/socket.h   |    1 +
 arch/ia64/include/asm/socket.h    |    1 +
 arch/m32r/include/asm/socket.h    |    1 +
 arch/m68k/include/asm/socket.h    |    1 +
 arch/mips/include/asm/socket.h    |    1 +
 arch/mn10300/include/asm/socket.h |    1 +
 arch/parisc/include/asm/socket.h  |    1 +
 arch/powerpc/include/asm/socket.h |    1 +
 arch/s390/include/asm/socket.h    |    1 +
 arch/sparc/include/asm/socket.h   |    1 +
 arch/xtensa/include/asm/socket.h  |    1 +
 include/asm-generic/socket.h      |    7 +++++++
 include/linux/skbuff.h            |    5 ++++-
 include/net/sock.h                |    6 ++++++
 net/core/skbuff.c                 |    1 +
 net/core/sock.c                   |    7 +++++++
 net/packet/af_packet.c            |   18 ++++++++++++++++--
 22 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/arch/alpha/include/asm/socket.h b/arch/alpha/include/asm/socket.h
index 06edfef..655fbe7 100644
--- a/arch/alpha/include/asm/socket.h
+++ b/arch/alpha/include/asm/socket.h
@@ -68,6 +68,7 @@
 #define SCM_TIMESTAMPING	SO_TIMESTAMPING
 
 #define SO_RXQ_OVFL             40
+#define SO_NOFCS		41
 
 /* O_NONBLOCK clashes with the bits used for socket types.  Therefore we
  * have to define SOCK_NONBLOCK to a different value here.
diff --git a/arch/arm/include/asm/socket.h b/arch/arm/include/asm/socket.h
index 90ffd04..4aa1c92 100644
--- a/arch/arm/include/asm/socket.h
+++ b/arch/arm/include/asm/socket.h
@@ -61,5 +61,6 @@
 #define SO_DOMAIN		39
 
 #define SO_RXQ_OVFL             40
+#define SO_NOFCS		41
 
 #endif /* _ASM_SOCKET_H */
diff --git a/arch/avr32/include/asm/socket.h b/arch/avr32/include/asm/socket.h
index c8d1fae..b70cfa3 100644
--- a/arch/avr32/include/asm/socket.h
+++ b/arch/avr32/include/asm/socket.h
@@ -61,5 +61,6 @@
 #define SO_DOMAIN		39
 
 #define SO_RXQ_OVFL             40
+#define SO_NOFCS		41
 
 #endif /* __ASM_AVR32_SOCKET_H */
diff --git a/arch/cris/include/asm/socket.h b/arch/cris/include/asm/socket.h
index 1a4a619..54d2d2b 100644
--- a/arch/cris/include/asm/socket.h
+++ b/arch/cris/include/asm/socket.h
@@ -63,6 +63,7 @@
 #define SO_DOMAIN		39
 
 #define SO_RXQ_OVFL             40
+#define SO_NOFCS		41
 
 #endif /* _ASM_SOCKET_H */
 
diff --git a/arch/frv/include/asm/socket.h b/arch/frv/include/asm/socket.h
index a6b2688..c77015c 100644
--- a/arch/frv/include/asm/socket.h
+++ b/arch/frv/include/asm/socket.h
@@ -61,6 +61,7 @@
 #define SO_DOMAIN		39
 
 #define SO_RXQ_OVFL             40
+#define SO_NOFCS		41
 
 #endif /* _ASM_SOCKET_H */
 
diff --git a/arch/h8300/include/asm/socket.h b/arch/h8300/include/asm/socket.h
index 04c0f45..5c8a75d 100644
--- a/arch/h8300/include/asm/socket.h
+++ b/arch/h8300/include/asm/socket.h
@@ -61,5 +61,6 @@
 #define SO_DOMAIN		39
 
 #define SO_RXQ_OVFL             40
+#define SO_NOFCS		41
 
 #endif /* _ASM_SOCKET_H */
diff --git a/arch/ia64/include/asm/socket.h b/arch/ia64/include/asm/socket.h
index 51427ea..f0062e6 100644
--- a/arch/ia64/include/asm/socket.h
+++ b/arch/ia64/include/asm/socket.h
@@ -70,5 +70,6 @@
 #define SO_DOMAIN		39
 
 #define SO_RXQ_OVFL             40
+#define SO_NOFCS		41
 
 #endif /* _ASM_IA64_SOCKET_H */
diff --git a/arch/m32r/include/asm/socket.h b/arch/m32r/include/asm/socket.h
index 469787c3..a259a66 100644
--- a/arch/m32r/include/asm/socket.h
+++ b/arch/m32r/include/asm/socket.h
@@ -61,5 +61,6 @@
 #define SO_DOMAIN		39
 
 #define SO_RXQ_OVFL             40
+#define SO_NOFCS		41
 
 #endif /* _ASM_M32R_SOCKET_H */
diff --git a/arch/m68k/include/asm/socket.h b/arch/m68k/include/asm/socket.h
index 9bf49c8..2442b97 100644
--- a/arch/m68k/include/asm/socket.h
+++ b/arch/m68k/include/asm/socket.h
@@ -61,5 +61,6 @@
 #define SO_DOMAIN		39
 
 #define SO_RXQ_OVFL             40
+#define SO_NOFCS		41
 
 #endif /* _ASM_SOCKET_H */
diff --git a/arch/mips/include/asm/socket.h b/arch/mips/include/asm/socket.h
index 9de5190..9b1fe294 100644
--- a/arch/mips/include/asm/socket.h
+++ b/arch/mips/include/asm/socket.h
@@ -81,6 +81,7 @@ To add: #define SO_REUSEPORT 0x0200	/* Allow local address and port reuse.  */
 #define SCM_TIMESTAMPING	SO_TIMESTAMPING
 
 #define SO_RXQ_OVFL             40
+#define SO_NOFCS		41
 
 #ifdef __KERNEL__
 
diff --git a/arch/mn10300/include/asm/socket.h b/arch/mn10300/include/asm/socket.h
index 4e60c42..1eb5bf5 100644
--- a/arch/mn10300/include/asm/socket.h
+++ b/arch/mn10300/include/asm/socket.h
@@ -61,5 +61,6 @@
 #define SO_DOMAIN		39
 
 #define SO_RXQ_OVFL             40
+#define SO_NOFCS		41
 
 #endif /* _ASM_SOCKET_H */
diff --git a/arch/parisc/include/asm/socket.h b/arch/parisc/include/asm/socket.h
index 225b7d6..22538f0 100644
--- a/arch/parisc/include/asm/socket.h
+++ b/arch/parisc/include/asm/socket.h
@@ -60,6 +60,7 @@
 #define SCM_TIMESTAMPING	SO_TIMESTAMPING
 
 #define SO_RXQ_OVFL             0x4021
+#define SO_NOFCS		0x4022
 
 /* O_NONBLOCK clashes with the bits used for socket types.  Therefore we
  * have to define SOCK_NONBLOCK to a different value here.
diff --git a/arch/powerpc/include/asm/socket.h b/arch/powerpc/include/asm/socket.h
index 866f760..d1ecf79 100644
--- a/arch/powerpc/include/asm/socket.h
+++ b/arch/powerpc/include/asm/socket.h
@@ -68,5 +68,6 @@
 #define SO_DOMAIN		39
 
 #define SO_RXQ_OVFL             40
+#define SO_NOFCS		41
 
 #endif	/* _ASM_POWERPC_SOCKET_H */
diff --git a/arch/s390/include/asm/socket.h b/arch/s390/include/asm/socket.h
index fdff1e9..c4ab6ea 100644
--- a/arch/s390/include/asm/socket.h
+++ b/arch/s390/include/asm/socket.h
@@ -69,5 +69,6 @@
 #define SO_DOMAIN		39
 
 #define SO_RXQ_OVFL             40
+#define SO_NOFCS		41
 
 #endif /* _ASM_SOCKET_H */
diff --git a/arch/sparc/include/asm/socket.h b/arch/sparc/include/asm/socket.h
index 9d3fefc..af8b622 100644
--- a/arch/sparc/include/asm/socket.h
+++ b/arch/sparc/include/asm/socket.h
@@ -57,6 +57,7 @@
 #define SCM_TIMESTAMPING	SO_TIMESTAMPING
 
 #define SO_RXQ_OVFL             0x0024
+#define SO_NOFCS		0x0025
 
 /* Security levels - as per NRL IPv6 - don't actually do anything */
 #define SO_SECURITY_AUTHENTICATION		0x5001
diff --git a/arch/xtensa/include/asm/socket.h b/arch/xtensa/include/asm/socket.h
index cbdf2ff..4c0cf9c 100644
--- a/arch/xtensa/include/asm/socket.h
+++ b/arch/xtensa/include/asm/socket.h
@@ -72,5 +72,6 @@
 #define SO_DOMAIN		39
 
 #define SO_RXQ_OVFL             40
+#define SO_NOFCS		41
 
 #endif	/* _XTENSA_SOCKET_H */
diff --git a/include/asm-generic/socket.h b/include/asm-generic/socket.h
index 9a6115e..22193a2 100644
--- a/include/asm-generic/socket.h
+++ b/include/asm-generic/socket.h
@@ -64,4 +64,11 @@
 #define SO_DOMAIN		39
 
 #define SO_RXQ_OVFL             40
+
+/* Instruct lower device to not calculate the frame
+ * checksum.  Useful for generating Ethernet frames
+ * with custom checksums.
+ */
+#define SO_NOFCS		41
+
 #endif /* __ASM_GENERIC_SOCKET_H */
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index c0a4f3a..05b15be 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -307,6 +307,8 @@ typedef unsigned char *sk_buff_data_t;
  *	@peeked: this packet has been seen already, so stats have been
  *		done for it, don't do them again
  *	@nf_trace: netfilter packet trace flag
+ *	@use_specified_ether_crc: skb is Ethernet frame with FCS already
+ *		appended.  Use that FCS.  Requires special support in NIC.
  *	@nfctinfo: Relationship of this skb to the connection
  *	@nfct_reasm: netfilter conntrack re-assembly pointer
  *	@nf_bridge: Saved data about a bridged frame - see br_netfilter.c
@@ -396,7 +398,8 @@ struct sk_buff {
 #ifdef CONFIG_IPV6_NDISC_NODETYPE
 	__u8			ndisc_nodetype:2;
 #endif
-	__u8			ooo_okay:1;
+	__u8			ooo_okay:1,
+				use_specified_ether_crc:1;
 	kmemcheck_bitfield_end(flags2);
 
 	/* 0/13 bit hole */
diff --git a/include/net/sock.h b/include/net/sock.h
index f2046e4..d7e0d88 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -563,6 +563,12 @@ enum sock_flags {
 	SOCK_TIMESTAMPING_SYS_HARDWARE, /* %SOF_TIMESTAMPING_SYS_HARDWARE */
 	SOCK_FASYNC, /* fasync() active */
 	SOCK_RXQ_OVFL,
+	SOCK_DONT_DO_LL_FCS, /* Tell NIC not to do the Ethernet FCS.
+			      * Will use last 4 bytes of packet sent from
+			      * user-space instead.  Requires special
+			      * support in NIC.
+			      */
+
 };
 
 static inline void sock_copy_flags(struct sock *nsk, struct sock *osk)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 46cbd28..a552560 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -541,6 +541,7 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
 	new->tc_verd		= old->tc_verd;
 #endif
 #endif
+	new->use_specified_ether_crc = old->use_specified_ether_crc;
 	new->vlan_tci		= old->vlan_tci;
 
 	skb_copy_secmark(new, old);
diff --git a/net/core/sock.c b/net/core/sock.c
index 6e81978..0c5f827 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -641,6 +641,13 @@ set_rcvbuf:
 		sock_warn_obsolete_bsdism("setsockopt");
 		break;
 
+	case SO_NOFCS:
+		if (valbool)
+			sk->sk_flags |= SOCK_DONT_DO_LL_FCS;
+		else
+			sk->sk_flags &= ~(SOCK_DONT_DO_LL_FCS);
+		break;
+
 	case SO_PASSCRED:
 		if (valbool)
 			set_bit(SOCK_PASSCRED, &sock->flags);
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index c0c3cda..7b39092 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -430,6 +430,10 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
 	struct net_device *dev;
 	__be16 proto = 0;
 	int err;
+	int fcs_len = 0;
+
+	if (unlikely(sk->sk_flags & SOCK_DONT_DO_LL_FCS))
+		fcs_len = 4; /* We're doing our own FCS */
 
 	/*
 	 *	Get and verify the address.
@@ -465,7 +469,7 @@ retry:
 	 */
 
 	err = -EMSGSIZE;
-	if (len > dev->mtu + dev->hard_header_len + VLAN_HLEN)
+	if (len > dev->mtu + dev->hard_header_len + VLAN_HLEN + fcs_len)
 		goto out_unlock;
 
 	if (!skb) {
@@ -518,6 +522,9 @@ retry:
 	if (err < 0)
 		goto out_unlock;
 
+	if (unlikely(sk->sk_flags & SOCK_DONT_DO_LL_FCS))
+		skb->use_specified_ether_crc = 1;
+
 	dev_queue_xmit(skb);
 	rcu_read_unlock();
 	return len;
@@ -1134,6 +1141,10 @@ static int packet_snd(struct socket *sock,
 	int vnet_hdr_len;
 	struct packet_sock *po = pkt_sk(sk);
 	unsigned short gso_type = 0;
+	int fcs_len = 0;
+
+	if (unlikely(sk->sk_flags & SOCK_DONT_DO_LL_FCS))
+		fcs_len = 4; /* We're doing our own Ethernet FCS */
 
 	/*
 	 *	Get and verify the address.
@@ -1215,7 +1226,7 @@ static int packet_snd(struct socket *sock,
 	}
 
 	err = -EMSGSIZE;
-	if (!gso_type && (len > dev->mtu + reserve + VLAN_HLEN))
+	if (!gso_type && (len > dev->mtu + reserve + VLAN_HLEN + fcs_len))
 		goto out_unlock;
 
 	err = -ENOBUFS;
@@ -1278,6 +1289,9 @@ static int packet_snd(struct socket *sock,
 		len += vnet_hdr_len;
 	}
 
+	if (unlikely(sk->sk_flags & SOCK_DONT_DO_LL_FCS))
+		skb->use_specified_ether_crc = 1;
+
 	/*
 	 *	Now send it
 	 */
-- 
1.7.3.4


^ permalink raw reply related

* [PATCH v2 5/5] e1000e:  Support sending frame with custom FCS.
From: greearb @ 2011-06-18 20:47 UTC (permalink / raw)
  To: netdev; +Cc: Ben Greear
In-Reply-To: <1308430045-24816-1-git-send-email-greearb@candelatech.com>

From: Ben Greear <greearb@candelatech.com>

This is good for testing by injecting frames with invalid
FCS onto a network.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
:100644 100644 3310c3d... 011a95f... M	drivers/net/e1000e/netdev.c
 drivers/net/e1000e/netdev.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 3310c3d..011a95f 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -4417,6 +4417,7 @@ link_up:
 #define E1000_TX_FLAGS_VLAN		0x00000002
 #define E1000_TX_FLAGS_TSO		0x00000004
 #define E1000_TX_FLAGS_IPV4		0x00000008
+#define E1000_TX_FLAGS_NO_FCS		0x00000010
 #define E1000_TX_FLAGS_VLAN_MASK	0xffff0000
 #define E1000_TX_FLAGS_VLAN_SHIFT	16
 
@@ -4681,6 +4682,9 @@ static void e1000_tx_queue(struct e1000_adapter *adapter,
 		txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK);
 	}
 
+	if (unlikely(tx_flags & E1000_TX_FLAGS_NO_FCS))
+		txd_lower &= ~(E1000_TXD_CMD_IFCS);
+
 	i = tx_ring->next_to_use;
 
 	do {
@@ -4698,6 +4702,10 @@ static void e1000_tx_queue(struct e1000_adapter *adapter,
 
 	tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
 
+	/* txd_cmd re-enables FCS, so we'll re-disable it here as desired. */
+	if (unlikely(tx_flags & E1000_TX_FLAGS_NO_FCS))
+		tx_desc->lower.data &= ~(cpu_to_le32(E1000_TXD_CMD_IFCS));
+
 	/*
 	 * Force memory writes to complete before letting h/w
 	 * know there are new descriptors to fetch.  (Only
@@ -4900,6 +4908,9 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
 	if (skb->protocol == htons(ETH_P_IP))
 		tx_flags |= E1000_TX_FLAGS_IPV4;
 
+	if (unlikely(skb->use_specified_ether_crc))
+		tx_flags |= E1000_TX_FLAGS_NO_FCS;
+
 	/* if count is 0 then mapping error has occurred */
 	count = e1000_tx_map(adapter, skb, first, max_per_txd, nr_frags, mss);
 	if (count) {
-- 
1.7.3.4


^ permalink raw reply related

* [PATCH v2 1/2] ethtool:  Support get/set rx-save-fcs flag.
From: greearb @ 2011-06-18 20:58 UTC (permalink / raw)
  To: netdev; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

This allows users to receive the Ethernet frame checksum
on supported drivers.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---

v2:  Fix typo in man-page description.

:100644 100644 c7a18f7... c059852... M	ethtool-copy.h
:100644 100644 7b1cdf5... e2eca31... M	ethtool.8.in
:100644 100644 c189c78... b97552c... M	ethtool.c
 ethtool-copy.h |    2 ++
 ethtool.8.in   |   18 ++++++++++++++++++
 ethtool.c      |   55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 74 insertions(+), 1 deletions(-)

diff --git a/ethtool-copy.h b/ethtool-copy.h
index c7a18f7..c059852 100644
--- a/ethtool-copy.h
+++ b/ethtool-copy.h
@@ -751,6 +751,8 @@ enum ethtool_sfeatures_retval_bits {
 #define ETHTOOL_SET_DUMP	0x0000003e /* Set dump settings */
 #define ETHTOOL_GET_DUMP_FLAG	0x0000003f /* Get dump settings */
 #define ETHTOOL_GET_DUMP_DATA	0x00000040 /* Get dump data */
+#define ETHTOOL_GET_SAVE_RXFCS	0x00000041 /* Get RX Save Frame Checksum */
+#define ETHTOOL_SET_SAVE_RXFCS	0x00000042 /* Set RX Save Frame Checksum */
 
 /* compatibility with older code */
 #define SPARC_ETH_GSET		ETHTOOL_GSET
diff --git a/ethtool.8.in b/ethtool.8.in
index 7b1cdf5..e2eca31 100644
--- a/ethtool.8.in
+++ b/ethtool.8.in
@@ -274,6 +274,13 @@ ethtool \- query or control network driver and hardware settings
 .IR W1
 .RB ...\ ]
 .HP
+.B ethtool \-z|\-\-get\-save\-rxfcs
+.I ethX
+.HP
+.B ethtool\ \-Z|\-\-set\-save\-rxfcs
+.I ethX
+.BI \ N
+.HP
 .B ethtool \-f|\-\-flash
 .I ethX
 .RI FILE
@@ -630,6 +637,17 @@ Sets the receive flow hash indirection table to spread flows between
 receive queues according to the given weights.  The sum of the weights
 must be non-zero and must not exceed the size of the indirection table.
 .TP
+.B \-z \-\-show\-save\-rxfcs
+Retrieves the receive frame checksum flag.
+.TP
+.B \-Z \-\-set\-save\-rxcfs
+Configures the receive frame checksum flag.
+.TP
+.B N
+1 means enable, 0 means disable.  When enabled, the 4-byte
+Frame Checksum will be appended to the end of the packet.  This
+can be useful when sniffing packets.
+.TP
 .B \-f \-\-flash \ FILE
 Flash firmware image from the specified file to a region on the adapter.
 By default this will flash all the regions on the adapter.
diff --git a/ethtool.c b/ethtool.c
index c189c78..b97552c 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -99,6 +99,8 @@ static int do_flash(int fd, struct ifreq *ifr);
 static int do_permaddr(int fd, struct ifreq *ifr);
 static int do_getfwdump(int fd, struct ifreq *ifr);
 static int do_setfwdump(int fd, struct ifreq *ifr);
+static int do_set_save_rxfcs(int fd, struct ifreq *ifr);
+static int do_get_save_rxfcs(int fd, struct ifreq *ifr);
 
 static int send_ioctl(int fd, struct ifreq *ifr);
 
@@ -133,6 +135,8 @@ static enum {
 	MODE_PERMADDR,
 	MODE_SET_DUMP,
 	MODE_GET_DUMP,
+	MODE_SET_SAVE_RXFCS,
+	MODE_GET_SAVE_RXFCS,
 } mode = MODE_GSET;
 
 static struct option {
@@ -266,6 +270,11 @@ static struct option {
     { "-W", "--set-dump", MODE_SET_DUMP,
 		"Set dump flag of the device",
 		"		N\n"},
+    { "-z", "--get-save-rxfcs", MODE_GET_SAVE_RXFCS,
+		"Get Save RX-FCS flag" },
+    { "-Z", "--set-save-rxfcs", MODE_SET_SAVE_RXFCS,
+		"Set Save RX-FCS flag of the device",
+		"		N\n"},
     { "-h", "--help", MODE_HELP, "Show this help" },
     { NULL, "--version", MODE_VERSION, "Show version number" },
     {}
@@ -398,6 +407,7 @@ static u32 msglvl_wanted = 0;
 static u32 msglvl_mask = 0;
 static u32 dump_flag;
 static char *dump_file = NULL;
+static u32 save_rxfcs_flag;
 
 static int rx_class_rule_get = -1;
 static int rx_class_rule_del = -1;
@@ -792,7 +802,9 @@ static void parse_cmdline(int argc, char **argp)
 			    (mode == MODE_FLASHDEV) ||
 			    (mode == MODE_PERMADDR) ||
 			    (mode == MODE_SET_DUMP) ||
-			    (mode == MODE_GET_DUMP)) {
+			    (mode == MODE_GET_DUMP) ||
+			    (mode == MODE_SET_SAVE_RXFCS) ||
+			    (mode == MODE_GET_SAVE_RXFCS)) {
 				devname = argp[i];
 				break;
 			}
@@ -817,6 +829,9 @@ static void parse_cmdline(int argc, char **argp)
 			} else if (mode == MODE_SET_DUMP) {
 				dump_flag = get_u32(argp[i], 0);
 				break;
+			} else if (mode == MODE_SET_SAVE_RXFCS) {
+				save_rxfcs_flag = get_u32(argp[i], 0);
+				break;
 			}
 			/* fallthrough */
 		default:
@@ -1935,6 +1950,10 @@ static int doit(void)
 		return do_getfwdump(fd, &ifr);
 	} else if (mode == MODE_SET_DUMP) {
 		return do_setfwdump(fd, &ifr);
+	} else if (mode == MODE_GET_SAVE_RXFCS) {
+		return do_get_save_rxfcs(fd, &ifr);
+	} else if (mode == MODE_SET_SAVE_RXFCS) {
+		return do_set_save_rxfcs(fd, &ifr);
 	}
 
 	return 69;
@@ -3322,6 +3341,40 @@ static int do_setfwdump(int fd, struct ifreq *ifr)
 	return 0;
 }
 
+static int do_set_save_rxfcs(int fd, struct ifreq *ifr)
+{
+	int err;
+	struct ethtool_value edata;
+
+	edata.cmd = ETHTOOL_SET_SAVE_RXFCS;
+	edata.data = save_rxfcs_flag;
+	ifr->ifr_data = (caddr_t)&edata;
+	err = send_ioctl(fd, ifr);
+	if (err < 0) {
+		perror("Can not set Save RX FCS level\n");
+		return 1;
+	}
+	return 0;
+}
+
+static int do_get_save_rxfcs(int fd, struct ifreq *ifr)
+{
+	int err;
+	struct ethtool_value edata;
+
+	edata.cmd = ETHTOOL_GET_SAVE_RXFCS;
+	ifr->ifr_data = (caddr_t)&edata;
+	err = send_ioctl(fd, ifr);
+	if (err == 0) {
+		fprintf(stdout, "	Save RX-FCS %s\n",
+			edata.data ? "Enabled" : "Disabled");
+		return 0;
+	} else {
+		perror("Can not get Save RX FCS flag\n");
+		return 1;
+	}
+}
+
 static int send_ioctl(int fd, struct ifreq *ifr)
 {
 	return ioctl(fd, SIOCETHTOOL, ifr);
-- 
1.7.3.4


^ permalink raw reply related

* [PATCH v2 2/2] ethtool:  Support enabling rx of errored frames.
From: greearb @ 2011-06-18 20:58 UTC (permalink / raw)
  To: netdev; +Cc: Ben Greear
In-Reply-To: <1308430723-25028-1-git-send-email-greearb@candelatech.com>

From: Ben Greear <greearb@candelatech.com>

This can be useful when sniffing dodgy networks.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
:100644 100644 c059852... 91ad2e6... M	ethtool-copy.h
:100644 100644 e2eca31... ca146fb... M	ethtool.8.in
:100644 100644 b97552c... 3179ad8... M	ethtool.c
 ethtool-copy.h |    2 ++
 ethtool.8.in   |   19 +++++++++++++++++++
 ethtool.c      |   55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 75 insertions(+), 1 deletions(-)

diff --git a/ethtool-copy.h b/ethtool-copy.h
index c059852..91ad2e6 100644
--- a/ethtool-copy.h
+++ b/ethtool-copy.h
@@ -753,6 +753,8 @@ enum ethtool_sfeatures_retval_bits {
 #define ETHTOOL_GET_DUMP_DATA	0x00000040 /* Get dump data */
 #define ETHTOOL_GET_SAVE_RXFCS	0x00000041 /* Get RX Save Frame Checksum */
 #define ETHTOOL_SET_SAVE_RXFCS	0x00000042 /* Set RX Save Frame Checksum */
+#define ETHTOOL_GET_SAVE_RXERR	0x00000043 /* Get RX Save Errored Frames */
+#define ETHTOOL_SET_SAVE_RXERR	0x00000044 /* Set RX Save Errored Frames */
 
 /* compatibility with older code */
 #define SPARC_ETH_GSET		ETHTOOL_GSET
diff --git a/ethtool.8.in b/ethtool.8.in
index e2eca31..ca146fb 100644
--- a/ethtool.8.in
+++ b/ethtool.8.in
@@ -281,6 +281,13 @@ ethtool \- query or control network driver and hardware settings
 .I ethX
 .BI \ N
 .HP
+.B ethtool \-b|\-\-get\-save\-rxerr
+.I ethX
+.HP
+.B ethtool\ \-B|\-\-set\-save\-rxerr
+.I ethX
+.BI \ N
+.HP
 .B ethtool \-f|\-\-flash
 .I ethX
 .RI FILE
@@ -648,6 +655,18 @@ Configures the receive frame checksum flag.
 Frame Checksum will be appended to the end of the packet.  This
 can be useful when sniffing packets.
 .TP
+.B \-b \-\-show\-save\-rxerr
+Retrieves the receive save errored frames flag.
+.TP
+.B \-B \-\-set\-save\-rxerr
+Configures the receive save errored frames flag.
+.TP
+.B N
+1 means enable, 0 means disable.  When enabled, the NIC should
+receive all possible frames and pass them up the stack, including
+frames with bad Ethernet checksums, bad length, etc.
+This can be useful when sniffing packets.
+.TP
 .B \-f \-\-flash \ FILE
 Flash firmware image from the specified file to a region on the adapter.
 By default this will flash all the regions on the adapter.
diff --git a/ethtool.c b/ethtool.c
index b97552c..3179ad8 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -101,6 +101,8 @@ static int do_getfwdump(int fd, struct ifreq *ifr);
 static int do_setfwdump(int fd, struct ifreq *ifr);
 static int do_set_save_rxfcs(int fd, struct ifreq *ifr);
 static int do_get_save_rxfcs(int fd, struct ifreq *ifr);
+static int do_set_save_rxerr(int fd, struct ifreq *ifr);
+static int do_get_save_rxerr(int fd, struct ifreq *ifr);
 
 static int send_ioctl(int fd, struct ifreq *ifr);
 
@@ -137,6 +139,8 @@ static enum {
 	MODE_GET_DUMP,
 	MODE_SET_SAVE_RXFCS,
 	MODE_GET_SAVE_RXFCS,
+	MODE_SET_SAVE_RXERR,
+	MODE_GET_SAVE_RXERR,
 } mode = MODE_GSET;
 
 static struct option {
@@ -275,6 +279,11 @@ static struct option {
     { "-Z", "--set-save-rxfcs", MODE_SET_SAVE_RXFCS,
 		"Set Save RX-FCS flag of the device",
 		"		N\n"},
+    { "-b", "--get-save-rxerr", MODE_GET_SAVE_RXERR,
+		"Get Save RX-ERR flag" },
+    { "-B", "--set-save-rxerr", MODE_SET_SAVE_RXERR,
+		"Set Save RX-ERR flag of the device",
+		"		N\n"},
     { "-h", "--help", MODE_HELP, "Show this help" },
     { NULL, "--version", MODE_VERSION, "Show version number" },
     {}
@@ -408,6 +417,7 @@ static u32 msglvl_mask = 0;
 static u32 dump_flag;
 static char *dump_file = NULL;
 static u32 save_rxfcs_flag;
+static u32 save_rxerr_flag;
 
 static int rx_class_rule_get = -1;
 static int rx_class_rule_del = -1;
@@ -804,7 +814,9 @@ static void parse_cmdline(int argc, char **argp)
 			    (mode == MODE_SET_DUMP) ||
 			    (mode == MODE_GET_DUMP) ||
 			    (mode == MODE_SET_SAVE_RXFCS) ||
-			    (mode == MODE_GET_SAVE_RXFCS)) {
+			    (mode == MODE_GET_SAVE_RXFCS) ||
+			    (mode == MODE_SET_SAVE_RXERR) ||
+			    (mode == MODE_GET_SAVE_RXERR)) {
 				devname = argp[i];
 				break;
 			}
@@ -832,6 +844,9 @@ static void parse_cmdline(int argc, char **argp)
 			} else if (mode == MODE_SET_SAVE_RXFCS) {
 				save_rxfcs_flag = get_u32(argp[i], 0);
 				break;
+			} else if (mode == MODE_SET_SAVE_RXERR) {
+				save_rxerr_flag = get_u32(argp[i], 0);
+				break;
 			}
 			/* fallthrough */
 		default:
@@ -1954,6 +1969,10 @@ static int doit(void)
 		return do_get_save_rxfcs(fd, &ifr);
 	} else if (mode == MODE_SET_SAVE_RXFCS) {
 		return do_set_save_rxfcs(fd, &ifr);
+	} else if (mode == MODE_GET_SAVE_RXERR) {
+		return do_get_save_rxerr(fd, &ifr);
+	} else if (mode == MODE_SET_SAVE_RXERR) {
+		return do_set_save_rxerr(fd, &ifr);
 	}
 
 	return 69;
@@ -3375,6 +3394,40 @@ static int do_get_save_rxfcs(int fd, struct ifreq *ifr)
 	}
 }
 
+static int do_set_save_rxerr(int fd, struct ifreq *ifr)
+{
+	int err;
+	struct ethtool_value edata;
+
+	edata.cmd = ETHTOOL_SET_SAVE_RXERR;
+	edata.data = save_rxerr_flag;
+	ifr->ifr_data = (caddr_t)&edata;
+	err = send_ioctl(fd, ifr);
+	if (err < 0) {
+		perror("Can not set Save RX ERR flag.\n");
+		return 1;
+	}
+	return 0;
+}
+
+static int do_get_save_rxerr(int fd, struct ifreq *ifr)
+{
+	int err;
+	struct ethtool_value edata;
+
+	edata.cmd = ETHTOOL_GET_SAVE_RXERR;
+	ifr->ifr_data = (caddr_t)&edata;
+	err = send_ioctl(fd, ifr);
+	if (err == 0) {
+		fprintf(stdout, "	Save RX-ERR %s\n",
+			edata.data ? "Enabled" : "Disabled");
+		return 0;
+	} else {
+		perror("Can not get Save RX ERR flag\n");
+		return 1;
+	}
+}
+
 static int send_ioctl(int fd, struct ifreq *ifr)
 {
 	return ioctl(fd, SIOCETHTOOL, ifr);
-- 
1.7.3.4


^ permalink raw reply related

* Re: [PATCH v2 1/5] net:  Support ethtool ops for rx of errored frames.
From: Francois Romieu @ 2011-06-18 21:34 UTC (permalink / raw)
  To: greearb; +Cc: netdev
In-Reply-To: <1308430045-24816-2-git-send-email-greearb@candelatech.com>

greearb@candelatech.com <greearb@candelatech.com> :
[...]
> This can be useful when sniffing dodgy networks.

Do you plan to add something similar - i.e. not per packet - for the Tx path ?

-- 
Ueimor

^ permalink raw reply

* Re: [PATCH #3 net-next 0/4] Pull request for 'davem-next.r8169' branch
From: David Miller @ 2011-06-18 23:41 UTC (permalink / raw)
  To: romieu; +Cc: netdev, nic_swsd, hayeswang, ben
In-Reply-To: <20110618112605.GA2573@electric-eye.fr.zoreil.com>

From: Francois Romieu <romieu@fr.zoreil.com>
Date: Sat, 18 Jun 2011 13:26:05 +0200

> Please pull from branch 'davem-next.r8169' in repository
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/romieu/netdev-2.6.git davem-next.r8169
> 
> to get the changes below.

Pulled, thanks!

^ permalink raw reply

* Re: [PATCH 2/3] net/fec: add device tree support
From: Grant Likely @ 2011-06-19  0:24 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: patches-QSEj5FYQhm4dnm+yROfE0A, netdev-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jason Liu,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, David S. Miller,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
In-Reply-To: <201106182027.22974.arnd-r2nGTMty4D4@public.gmane.org>

On Sat, Jun 18, 2011 at 12:27 PM, Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> wrote:
> On Saturday 18 June 2011 17:19:13 Shawn Guo wrote:
>> diff --git a/Documentation/devicetree/bindings/net/fsl-fec.txt b/Documentation/devicetree/bindings/net/fsl-fec.txt
>> new file mode 100644
>> index 0000000..705111d
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/net/fsl-fec.txt
>> @@ -0,0 +1,14 @@
>> +* Freescale Fast Ethernet Controller (FEC)
>> +
>> +Required properties:
>> +- compatible : should be "fsl,<soc>-fec", "fsl,fec"
>> +- reg : address and length of the register set for the device
>> +- interrupts : should contain fec interrupt
>> +
>> +Example:
>> +
>> +fec@83fec000 {
>> +     compatible = "fsl,imx51-fec", "fsl,fec";
>> +     reg = <0x83fec000 0x4000>;
>> +     interrupts = <87>;
>> +};
>
> How about also adding device_type="network" as required here, so you
> inherit the attributes like "local-mac-address".

local-mac-address should be used regardless.  "device_type" only makes
sense when a platform uses real OpenFirmware with the runtime services
api.  It should not be used with the flat tree.

> I would also suggest adding a call to of_get_mac_address() so you
> can read the address out of the device tree when it is not configured
> in hardware. Today, the driver relies on a module parameter or
> platform_data on hardware with a mac address set.

Yes, of_get_mac_address() is the right thing to do.

g.

^ permalink raw reply

* Ethernet low-level frame debugging support
From: Mark Smith @ 2011-06-19  1:14 UTC (permalink / raw)
  To: netdev; +Cc: greearb

Hi,

Firstly, I think this is a potentially quite useful feature for
networking people and that I hope it makes it into the kernel proper.

One thing I've thought is that perhaps it might be made and named a bit
more generally, as NICs will also drop frames for other reasons other
than FCs failures e.g. runt frames. So perhaps something like "true
promiscuous" or "full promiscuous" might be a more general name, and if
it is enabled, then all NIC error checking that can be switched off is
switched off. Looking at the chipset data sheets for a few NICs that I
have / have had (netgear FA312 (natsemi ns83815), smc epic100, ne2000),
they all seem to have registers which allow switching off many if not
all of the NIC error checking settings.

The other thing I've thought could be useful would be to be able to
send runts by not padding the frames when they're less then 64 bytes.
I've been able to test if this is possible with the netgear FA312, as
the chipset does the padding. I connected it back to back with an
e1000e I have, switched off the chipset automatic padding on the FA312,
sent small traffic, and then saw that the e1000e's internal
rx_short_length_errors counter correspondingly increased. Of course I
can't see them with tcpdump on the e1000e because it is dropping them. 

Regards,
Mark.

^ permalink raw reply

* Re: [PATCH 1/3] serial/imx: add device tree support
From: Wolfram Sang @ 2011-06-19  7:02 UTC (permalink / raw)
  To: Grant Likely
  Cc: Shawn Guo, patches, netdev, devicetree-discuss, Jason Liu,
	linux-kernel, Jeremy Kerr, Sascha Hauer, linux-arm-kernel
In-Reply-To: <20110618161934.GH8195@ponder.secretlab.ca>

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

On Sat, Jun 18, 2011 at 10:19:34AM -0600, Grant Likely wrote:
> On Sat, Jun 18, 2011 at 11:19:12PM +0800, Shawn Guo wrote:
> > It adds device tree data parsing support for imx tty/serial driver.
> > 
> > Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
> > Signed-off-by: Jason Liu <jason.hui@linaro.org>
> > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> > Cc: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> >  .../bindings/tty/serial/fsl-imx-uart.txt           |   21 +++++
> >  drivers/tty/serial/imx.c                           |   81 +++++++++++++++++---
> >  2 files changed, 92 insertions(+), 10 deletions(-)
> >  create mode 100644 Documentation/devicetree/bindings/tty/serial/fsl-imx-uart.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/tty/serial/fsl-imx-uart.txt b/Documentation/devicetree/bindings/tty/serial/fsl-imx-uart.txt
> > new file mode 100644
> > index 0000000..7648e17
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/tty/serial/fsl-imx-uart.txt
> > @@ -0,0 +1,21 @@
> > +* Freescale i.MX Universal Asynchronous Receiver/Transmitter (UART)
> > +
> > +Required properties:
> > +- compatible : should be "fsl,<soc>-uart", "fsl,imx-uart"
> 
> I'd make this "fsl,<soc>-uart", "fsl,imx51-uart"
> 
> It's better to anchor these things on real silicon, or a real ip block
> specification rather than something pseudo-generic.  Subsequent chips,
> like the imx53, should simply claim compatibility with the older
> fsl,imx51-uart.
> 
> (in essence, "fsl,imx51-uart" becomes the generic string without the
> downside of having no obvious recourse when new silicon shows up that
> is an imx part, but isn't compatible with the imx51 uart.

Shouldn't that be the oldest SoC this core showed up? It might be an academic
question, but it would look a bit funny if mx27 got dt-support and would have a
imx51-uart? The first imx to have this core is the mx1. (Although there are
some cpu_is_mx1() calls used in the driver, but they are still available, or?)

Regards,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply

* Re: [PATCH 1/3] serial/imx: add device tree support
From: Shawn Guo @ 2011-06-19  7:30 UTC (permalink / raw)
  To: Grant Likely
  Cc: patches, netdev, devicetree-discuss, Jason Liu, linux-kernel,
	Jeremy Kerr, Shawn Guo, Sascha Hauer, linux-arm-kernel
In-Reply-To: <20110618161934.GH8195@ponder.secretlab.ca>

On Sat, Jun 18, 2011 at 10:19:34AM -0600, Grant Likely wrote:
> On Sat, Jun 18, 2011 at 11:19:12PM +0800, Shawn Guo wrote:
> > It adds device tree data parsing support for imx tty/serial driver.
> > 
> > Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
> > Signed-off-by: Jason Liu <jason.hui@linaro.org>
> > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> > Cc: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> >  .../bindings/tty/serial/fsl-imx-uart.txt           |   21 +++++
> >  drivers/tty/serial/imx.c                           |   81 +++++++++++++++++---
> >  2 files changed, 92 insertions(+), 10 deletions(-)
> >  create mode 100644 Documentation/devicetree/bindings/tty/serial/fsl-imx-uart.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/tty/serial/fsl-imx-uart.txt b/Documentation/devicetree/bindings/tty/serial/fsl-imx-uart.txt
> > new file mode 100644
> > index 0000000..7648e17
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/tty/serial/fsl-imx-uart.txt
> > @@ -0,0 +1,21 @@
> > +* Freescale i.MX Universal Asynchronous Receiver/Transmitter (UART)
> > +
> > +Required properties:
> > +- compatible : should be "fsl,<soc>-uart", "fsl,imx-uart"
> 
> I'd make this "fsl,<soc>-uart", "fsl,imx51-uart"
> 
> It's better to anchor these things on real silicon, or a real ip block
> specification rather than something pseudo-generic.  Subsequent chips,
> like the imx53, should simply claim compatibility with the older
> fsl,imx51-uart.

It is a real IP block on all imx silicons (except imx23 and imx28
which are known as former stmp).

> 
> (in essence, "fsl,imx51-uart" becomes the generic string without the
> downside of having no obvious recourse when new silicon shows up that
> is an imx part, but isn't compatible with the imx51 uart.
> 
In this case, should imx1 the ancestor of imx family than imx51
becomes part of that generic string?  Claiming uart of imx1, imx21
and imx31 (senior than imx51) compatible with the imx51 uart seems
odd to me.

That said, IMO, "fsl,imx-uart" stands a real IP block specification
here and can be a perfect generic compatibility string to tell the
recourse of any imx silicon using this IP.

> > +- reg : address and length of the register set for the device
> > +- interrupts : should contain uart interrupt
> > +- id : should be the port ID defined by soc
> > +
> > +Optional properties:
> > +- fsl,has-rts-cts : indicate it has rts-cts
> > +- fsl,irda-mode : support irda mode
> > +
> > +Example:
> > +
> > +uart@73fbc000 {
> > +	compatible = "fsl,imx51-uart", "fsl,imx-uart";
> > +	reg = <0x73fbc000 0x4000>;
> > +	interrupts = <31>;
> > +	id = <1>;
> > +	fsl,has-rts-cts;
> > +};
> > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> > index a544731..2769353 100644
> > --- a/drivers/tty/serial/imx.c
> > +++ b/drivers/tty/serial/imx.c
> > @@ -45,6 +45,8 @@
> >  #include <linux/delay.h>
> >  #include <linux/rational.h>
> >  #include <linux/slab.h>
> > +#include <linux/of.h>
> > +#include <linux/of_address.h>
> >  
> >  #include <asm/io.h>
> >  #include <asm/irq.h>
> > @@ -1223,6 +1225,63 @@ static int serial_imx_resume(struct platform_device *dev)
> >  	return 0;
> >  }
> >  
> > +#ifdef CONFIG_OF
> > +static int serial_imx_probe_dt(struct imx_port *sport,
> > +		struct platform_device *pdev)
> > +{
> > +	struct device_node *node = pdev->dev.of_node;
> > +	const __be32 *line;
> > +
> > +	if (!node)
> > +		return -ENODEV;
> > +
> > +	line = of_get_property(node, "id", NULL);
> > +	if (!line)
> > +		return -ENODEV;
> > +
> > +	sport->port.line = be32_to_cpup(line) - 1;
> 
> Hmmm, I really would like to be rid of this.  Instead, if uarts must
> be enumerated, the driver should look for a /aliases/uart* property
> that matches the of_node.  Doing it that way is already established in
> the OpenFirmware documentation, and it ensures there are no overlaps
> in the global namespace.
> 

I just gave one more try to avoid using 'aliases', and you gave a
'no' again.  Now, I know how hard you are on this.  Okay, I start
thinking about your suggestion seriously :)

> We do need some infrastructure to make that easier though.  Would you
> have time to help put that together?
> 
Ok, I will give it a try.

-- 
Regards,
Shawn

^ permalink raw reply

* Re: [PATCH 1/3] serial/imx: add device tree support
From: Shawn Guo @ 2011-06-19  7:40 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: patches-QSEj5FYQhm4dnm+yROfE0A, netdev-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jason Liu,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Jeremy Kerr, Sascha Hauer,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
In-Reply-To: <201106181821.46574.arnd-r2nGTMty4D4@public.gmane.org>

On Sat, Jun 18, 2011 at 06:21:46PM +0200, Arnd Bergmann wrote:
> On Saturday 18 June 2011 17:19:12 Shawn Guo wrote:
> >
> > +Required properties:
> > +- compatible : should be "fsl,<soc>-uart", "fsl,imx-uart"
> > +- reg : address and length of the register set for the device
> > +- interrupts : should contain uart interrupt
> > +- id : should be the port ID defined by soc
> > +
> > +Optional properties:
> > +- fsl,has-rts-cts : indicate it has rts-cts
> > +- fsl,irda-mode : support irda mode
> > +
> > +Example:
> > +
> > +uart@73fbc000 {
> > +	compatible = "fsl,imx51-uart", "fsl,imx-uart";
> > +	reg = <0x73fbc000 0x4000>;
> > +	interrupts = <31>;
> > +	id = <1>;
> > +	fsl,has-rts-cts;
> > +};
> 
> Should this also support the "clock-frequency" property that 8250-style
> serial ports support [1]?
> 
I would ignore it for a while until we have common clock api and
corresponding binding settled.  For now, I would have nothing clock
related parsed from device tree.

-- 
Regards,
Shawn

^ permalink raw reply

* Re: [PATCH 1/3] serial/imx: add device tree support
From: Shawn Guo @ 2011-06-19  7:41 UTC (permalink / raw)
  To: Grant Likely
  Cc: Arnd Bergmann, patches, netdev, devicetree-discuss, Jason Liu,
	linux-kernel, Jeremy Kerr, Sascha Hauer, linux-arm-kernel
In-Reply-To: <20110618162655.GK8195@ponder.secretlab.ca>

On Sat, Jun 18, 2011 at 10:26:55AM -0600, Grant Likely wrote:
> On Sat, Jun 18, 2011 at 06:21:46PM +0200, Arnd Bergmann wrote:
> > On Saturday 18 June 2011 17:19:12 Shawn Guo wrote:
> > >
> > > +Required properties:
> > > +- compatible : should be "fsl,<soc>-uart", "fsl,imx-uart"
> > > +- reg : address and length of the register set for the device
> > > +- interrupts : should contain uart interrupt
> > > +- id : should be the port ID defined by soc
> > > +
> > > +Optional properties:
> > > +- fsl,has-rts-cts : indicate it has rts-cts
> > > +- fsl,irda-mode : support irda mode
> > > +
> > > +Example:
> > > +
> > > +uart@73fbc000 {
> > > +	compatible = "fsl,imx51-uart", "fsl,imx-uart";
> > > +	reg = <0x73fbc000 0x4000>;
> > > +	interrupts = <31>;
> > > +	id = <1>;
> > > +	fsl,has-rts-cts;
> > > +};
> > 
> > Should this also support the "clock-frequency" property that 8250-style
> > serial ports support [1]?
> > 
> > For the flow-control properties, should we name that more generic? The
> > same property certainly makes sense for other serial-ports if it does
> > here. OTOH, I'm not sure it's actually reliable, because it also depends
> > on whether the other side of the connection and the cable support hw flow
> > control.
> 
> I'd like to see a few use cases before defining a common property.
> That said, has-rts-cts does sound like a useful generic property.
> Or maybe named "uart-has-rts-cts" to make it clear that it is a uart
> specific binding?
> 
I would keep the name as it is if you do not mind, since it's been
under uart node.

-- 
Regards,
Shawn

^ permalink raw reply

* Re: [PATCH 2/3] net/fec: add device tree support
From: Shawn Guo @ 2011-06-19  7:46 UTC (permalink / raw)
  To: Grant Likely
  Cc: patches-QSEj5FYQhm4dnm+yROfE0A, netdev-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jason Liu,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, David S. Miller,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
In-Reply-To: <20110618162220.GI8195-e0URQFbLeQY2iJbIjFUEsiwD8/FfD2ys@public.gmane.org>

On Sat, Jun 18, 2011 at 10:22:20AM -0600, Grant Likely wrote:
> On Sat, Jun 18, 2011 at 11:19:13PM +0800, Shawn Guo wrote:
> > It adds device tree data parsing support for fec driver.
> > 
> > Signed-off-by: Jason Liu <jason.hui-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> > Signed-off-by: Shawn Guo <shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> > Cc: David S. Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
> > ---
> >  Documentation/devicetree/bindings/net/fsl-fec.txt |   14 ++++++++++
> >  drivers/net/fec.c                                 |   28 +++++++++++++++++++++
> >  2 files changed, 42 insertions(+), 0 deletions(-)
> >  create mode 100644 Documentation/devicetree/bindings/net/fsl-fec.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/net/fsl-fec.txt b/Documentation/devicetree/bindings/net/fsl-fec.txt
> > new file mode 100644
> > index 0000000..705111d
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/net/fsl-fec.txt
> > @@ -0,0 +1,14 @@
> > +* Freescale Fast Ethernet Controller (FEC)
> > +
> > +Required properties:
> > +- compatible : should be "fsl,<soc>-fec", "fsl,fec"
> 
> Ditto to comment on last patch.  "fsl,fec" is to generic.
> "fsl,imx51-soc" should be the generic value.
> 

Ditto to the feedback on the last comment.  "fsl,imx51-fec" is not
a good one to be the compatibility string for imx27 and imx35 fec.

> Otherwise looks okay to me, and I don't see any problem with queueing
> it up for v3.1 with that change since it doesn't depend on any other
> patches.
> 
> Acked-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
> 

-- 
Regards,
Shawn

^ permalink raw reply

* Re: [PATCH 2/3] net/fec: add device tree support
From: Shawn Guo @ 2011-06-19  7:55 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arm-kernel, Shawn Guo, patches, netdev, devicetree-discuss,
	Jason Liu, linux-kernel, David S. Miller
In-Reply-To: <201106182027.22974.arnd@arndb.de>

On Sat, Jun 18, 2011 at 08:27:22PM +0200, Arnd Bergmann wrote:
> On Saturday 18 June 2011 17:19:13 Shawn Guo wrote:
> > diff --git a/Documentation/devicetree/bindings/net/fsl-fec.txt b/Documentation/devicetree/bindings/net/fsl-fec.txt
> > new file mode 100644
> > index 0000000..705111d
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/net/fsl-fec.txt
> > @@ -0,0 +1,14 @@
> > +* Freescale Fast Ethernet Controller (FEC)
> > +
> > +Required properties:
> > +- compatible : should be "fsl,<soc>-fec", "fsl,fec"
> > +- reg : address and length of the register set for the device
> > +- interrupts : should contain fec interrupt
> > +
> > +Example:
> > +
> > +fec@83fec000 {
> > +	compatible = "fsl,imx51-fec", "fsl,fec";
> > +	reg = <0x83fec000 0x4000>;
> > +	interrupts = <87>;
> > +};
> 
> How about also adding device_type="network" as required here, so you
> inherit the attributes like "local-mac-address".
> 
> I would also suggest adding a call to of_get_mac_address() so you
> can read the address out of the device tree when it is not configured
> in hardware. Today, the driver relies on a module parameter or
> platform_data on hardware with a mac address set.
> 
> The other information that is currently encoded in platform_data
> is the phy mode. How about adding a property that enables RMII mode
> when present?
> 
Ah, yes.  I missed that.  Will add support for local-mac-address and
phy-mode.  Thanks, Arnd.

-- 
Regards,
Shawn


^ permalink raw reply

* Re: [PATCHv2 RFC 0/4] virtio and vhost-net capacity handling
From: Michael S. Tsirkin @ 2011-06-19  8:53 UTC (permalink / raw)
  To: Krishna Kumar2
  Cc: habanero-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8,
	lguest-uLR06cmDAlY/bJ5BZ2RsiQ, Shirley Ma,
	kvm-u79uwXL29TY76Z2rM5mHXA, Carsten Otte,
	linux-s390-u79uwXL29TY76Z2rM5mHXA, Heiko Carstens,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	steved-r/Jw6+rmf7HQT0dZR+AlfA, Christian Borntraeger,
	Tom Lendacky, netdev-u79uwXL29TY76Z2rM5mHXA, Martin Schwidefsky,
	linux390-tA70FqPdS9bQT0dZR+AlfA
In-Reply-To: <OFE36F9C2B.43D9DB04-ON652578AE.0048E1AB-652578AE.004A1462-xthvdsQ13ZrQT0dZR+AlfA@public.gmane.org>

On Mon, Jun 13, 2011 at 07:02:27PM +0530, Krishna Kumar2 wrote:
> "Michael S. Tsirkin" <mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote on 06/07/2011 09:38:30 PM:
> 
> > > This is on top of the patches applied by Rusty.
> > >
> > > Warning: untested. Posting now to give people chance to
> > > comment on the API.
> >
> > OK, this seems to have survived some testing so far,
> > after I dropped patch 4 and fixed build for patch 3
> > (build fixup patch sent in reply to the original).
> >
> > I'll be mostly offline until Sunday, would appreciate
> > testing reports.
> 
> Hi Michael,
> 
> I ran the latest patches with 1K I/O (guest->local host) and
> the results are (60 sec run for each test case):
> 
> ______________________________
> #sessions   BW%       SD%
> ______________________________
> 1           -25.6     47.0
> 2           -29.3     22.9
> 4              .8     1.6
> 8             1.6     0
> 16          -1.6      4.1
> 32          -5.3      2.1
> 48           11.3    -7.8
> 64          -2.8      .7
> 96          -6.2      .6
> 128         -10.6     12.7
> ______________________________
> BW: -4.8     SD: 5.4
> 
> I tested it again to see if the regression is fleeting (since
> the numbers vary quite a bit for 1K I/O even between guest->
> local host), but:
> 
> ______________________________
> #sessions  BW%     SD%
> ______________________________
> 1          14.0    -17.3
> 2          19.9    -11.1
> 4          7.9     -15.3
> 8          9.6     -13.1
> 16         1.2     -7.3
> 32        -.6      -13.5
> 48        -28.7     10.0
> 64        -5.7     -.7
> 96        -9.4     -8.1
> 128       -9.4      .7
> ______________________________
> BW: -3.7     SD: -2.0
> 
> 
> With 16K, there was an improvement in SD, but
> higher sessions seem to slightly degrade BW/SD:
> 
> ______________________________
> #sessions  BW%      SD%
> ______________________________
> 1          30.9    -25.0
> 2          16.5    -19.4
> 4         -1.3      7.9
> 8          1.4      6.2
> 16         3.9     -5.4
> 32         0        4.3
> 48        -.5        .1
> 64         32.1    -1.5
> 96        -2.1      23.2
> 128       -7.4      3.8
> ______________________________
> BW: 5.0          SD: 7.5
> 
> 
> Thanks,
> 
> - KK

I think I see one scenario where we do extra work:
when TX ring overflows, the first attempt to
add buf will fail, so the work to format the s/g
list is then wasted. So it might make sense to
free up buffers up to capacity first thing after all,
which will still do nothing typically, add buf afterwards.

-- 
MST

^ permalink raw reply

* RFT: virtio_net: limit xmit polling
From: Michael S. Tsirkin @ 2011-06-19 10:27 UTC (permalink / raw)
  To: Krishna Kumar2
  Cc: habanero-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8,
	lguest-uLR06cmDAlY/bJ5BZ2RsiQ, Shirley Ma,
	kvm-u79uwXL29TY76Z2rM5mHXA, Carsten Otte,
	linux-s390-u79uwXL29TY76Z2rM5mHXA, Heiko Carstens,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	steved-r/Jw6+rmf7HQT0dZR+AlfA, Christian Borntraeger,
	Tom Lendacky, netdev-u79uwXL29TY76Z2rM5mHXA, Martin Schwidefsky,
	linux390-tA70FqPdS9bQT0dZR+AlfA, roprabhu-FYB4Gu1CFyUAvxtiuMwx3w

OK, different people seem to test different trees.  In the hope to get
everyone on the same page, I created several variants of this patch so
they can be compared. Whoever's interested, please check out the
following, and tell me how these compare:

kernel:

git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git

virtio-net-limit-xmit-polling/base - this is net-next baseline to test against
virtio-net-limit-xmit-polling/v0 - fixes checks on out of capacity
virtio-net-limit-xmit-polling/v1 - previous revision of the patch
		this does xmit,free,xmit,2*free,free
virtio-net-limit-xmit-polling/v2 - new revision of the patch
		this does free,xmit,2*free,free

There's also this on top:
virtio-net-limit-xmit-polling/v3 -> don't delay avail index update
I don't think it's important to test this one, yet

Userspace to use: event index work is not yet merged upstream
so the revision to use is still this:
git://git.kernel.org/pub/scm/linux/kernel/git/mst/qemu-kvm.git
virtio-net-event-idx-v3

-- 
MST

^ permalink raw reply

* [PATCH 00/11] net: expand time stamping, batch #2
From: Richard Cochran @ 2011-06-19 11:19 UTC (permalink / raw)
  To: netdev; +Cc: David Miller

This patch series represents a continuation of the effort to get
better coverage of the SO_TIMESTAMPING socket API in the Ethernet
drivers.  Adding time stamping support to a given driver solves two
separate issues, namely software transmit time stamping and hardware
time stamping in PHY devices.

This second batch adds the hooks into all remaining (?) arm and
powerpc MAC drivers using phylib. The first patch exports the receive
hook for use by non-NAPI drivers when compiled as modules. Patch #5
has been tested on real hardware, but the rest have only been compile
tested.

Richard Cochran (11):
  net: export the receive time stamping hook for non-NAPI drivers
  lib8390: enable transmit and receive time stamping.
  emaclite: enable transmit and receive time stamping.
  ll_temac: enable transmit and receive time stamping.
  fec_mpc52xx: enable transmit and receive time stamping.
  macb: enable transmit time stamping.
  fs_enet: enable transmit time stamping.
  smsc911x: enable transmit time stamping.
  pxa168_eth: enable transmit time stamping.
  mv643xx_eth: enable transmit time stamping.
  ucc_geth: enable transmit time stamping.

 drivers/net/fec_mpc52xx.c          |    4 +++-
 drivers/net/fs_enet/fs_enet-main.c |    2 ++
 drivers/net/lib8390.c              |    5 +++--
 drivers/net/ll_temac_main.c        |    5 ++++-
 drivers/net/macb.c                 |    2 ++
 drivers/net/mv643xx_eth.c          |    2 ++
 drivers/net/pxa168_eth.c           |    1 +
 drivers/net/smsc911x.c             |    1 +
 drivers/net/ucc_geth.c             |    1 +
 drivers/net/xilinx_emaclite.c      |    9 +++++++--
 net/core/timestamping.c            |    1 +
 11 files changed, 27 insertions(+), 6 deletions(-)


^ permalink raw reply

* [PATCH 01/11] net: export the receive time stamping hook for non-NAPI drivers
From: Richard Cochran @ 2011-06-19 11:19 UTC (permalink / raw)
  To: netdev; +Cc: David Miller
In-Reply-To: <cover.1308481491.git.richard.cochran@omicron.at>

Ethernet MAC drivers based on phylib (but not using NAPI) can
enable hardware time stamping in phy devices by calling netif_rx()
conditionally based on a call to skb_defer_rx_timestamp().

This commit exports that function so that drivers calling it may
be compiled as modules.

Signed-off-by: Richard Cochran <richard.cochran@omicron.at>
---
 net/core/timestamping.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/net/core/timestamping.c b/net/core/timestamping.c
index 3b00a6b..98a5264 100644
--- a/net/core/timestamping.c
+++ b/net/core/timestamping.c
@@ -122,6 +122,7 @@ bool skb_defer_rx_timestamp(struct sk_buff *skb)
 
 	return false;
 }
+EXPORT_SYMBOL_GPL(skb_defer_rx_timestamp);
 
 void __init skb_timestamping_init(void)
 {
-- 
1.7.0.4


^ permalink raw reply related

* [PATCH 02/11] lib8390: enable transmit and receive time stamping.
From: Richard Cochran @ 2011-06-19 11:19 UTC (permalink / raw)
  To: netdev; +Cc: David Miller
In-Reply-To: <cover.1308481491.git.richard.cochran@omicron.at>

This patch enables software (and phy device) time stamping. This file is
included by drivers/net/ax88796.c, which is based on phylib. So, this
patch makes hardware time stamping in the PHY possible.

Compile tested only.

Signed-off-by: Richard Cochran <richard.cochran@omicron.at>
---
 drivers/net/lib8390.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/lib8390.c b/drivers/net/lib8390.c
index 17b75e5..70eb207 100644
--- a/drivers/net/lib8390.c
+++ b/drivers/net/lib8390.c
@@ -410,7 +410,7 @@ static netdev_tx_t __ei_start_xmit(struct sk_buff *skb,
 
 	spin_unlock(&ei_local->page_lock);
 	enable_irq_lockdep_irqrestore(dev->irq, &flags);
-
+	skb_tx_timestamp(skb);
 	dev_kfree_skb (skb);
 	dev->stats.tx_bytes += send_length;
 
@@ -758,7 +758,8 @@ static void ei_receive(struct net_device *dev)
 				skb_put(skb, pkt_len);	/* Make room */
 				ei_block_input(dev, pkt_len, skb, current_offset + sizeof(rx_frame));
 				skb->protocol=eth_type_trans(skb,dev);
-				netif_rx(skb);
+				if (!skb_defer_rx_timestamp(skb))
+					netif_rx(skb);
 				dev->stats.rx_packets++;
 				dev->stats.rx_bytes += pkt_len;
 				if (pkt_stat & ENRSR_PHY)
-- 
1.7.0.4


^ permalink raw reply related

* [PATCH 03/11] emaclite: enable transmit and receive time stamping.
From: Richard Cochran @ 2011-06-19 11:19 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, John Linn
In-Reply-To: <cover.1308481491.git.richard.cochran@omicron.at>

This patch enables software (and phy device) time stamping. Since this
MAC uses phylib, adding the hooks make hardware time stamping in the phy
possible.

Compile tested only.

Cc: John Linn <john.linn@xilinx.com>
Signed-off-by: Richard Cochran <richard.cochran@omicron.at>
---
 drivers/net/xilinx_emaclite.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c
index 372572c..ae029d0 100644
--- a/drivers/net/xilinx_emaclite.c
+++ b/drivers/net/xilinx_emaclite.c
@@ -647,7 +647,8 @@ static void xemaclite_rx_handler(struct net_device *dev)
 	dev->stats.rx_packets++;
 	dev->stats.rx_bytes += len;
 
-	netif_rx(skb);		/* Send the packet upstream */
+	if (!skb_defer_rx_timestamp(skb))
+		netif_rx(skb);	/* Send the packet upstream */
 }
 
 /**
@@ -1029,15 +1030,19 @@ static int xemaclite_send(struct sk_buff *orig_skb, struct net_device *dev)
 	spin_lock_irqsave(&lp->reset_lock, flags);
 	if (xemaclite_send_data(lp, (u8 *) new_skb->data, len) != 0) {
 		/* If the Emaclite Tx buffer is busy, stop the Tx queue and
-		 * defer the skb for transmission at a later point when the
+		 * defer the skb for transmission during the ISR, after the
 		 * current transmission is complete */
 		netif_stop_queue(dev);
 		lp->deferred_skb = new_skb;
 		spin_unlock_irqrestore(&lp->reset_lock, flags);
+		/* Take the time stamp now, since we can't do this in an ISR. */
+		skb_tx_timestamp(new_skb);
 		return 0;
 	}
 	spin_unlock_irqrestore(&lp->reset_lock, flags);
 
+	skb_tx_timestamp(new_skb);
+
 	dev->stats.tx_bytes += len;
 	dev_kfree_skb(new_skb);
 
-- 
1.7.0.4


^ permalink raw reply related

* [PATCH 04/11] ll_temac: enable transmit and receive time stamping.
From: Richard Cochran @ 2011-06-19 11:20 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Grant Likely
In-Reply-To: <cover.1308481491.git.richard.cochran@omicron.at>

This patch enables software (and phy device) time stamping. Since this MAC
is based on phylib, adding the hooks makes hardware time stamping in the
phy possible.

Compile tested only.

Cc: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Richard Cochran <richard.cochran@omicron.at>
---
 drivers/net/ll_temac_main.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/net/ll_temac_main.c b/drivers/net/ll_temac_main.c
index b7948cc..eabc378 100644
--- a/drivers/net/ll_temac_main.c
+++ b/drivers/net/ll_temac_main.c
@@ -730,6 +730,8 @@ static int temac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
 	/* Kick off the transfer */
 	lp->dma_out(lp, TX_TAILDESC_PTR, tail_p); /* DMA start */
 
+	skb_tx_timestamp(skb);
+
 	return NETDEV_TX_OK;
 }
 
@@ -772,7 +774,8 @@ static void ll_temac_recv(struct net_device *ndev)
 			skb->ip_summed = CHECKSUM_COMPLETE;
 		}
 
-		netif_rx(skb);
+		if (!skb_defer_rx_timestamp(skb))
+			netif_rx(skb);
 
 		ndev->stats.rx_packets++;
 		ndev->stats.rx_bytes += length;
-- 
1.7.0.4


^ permalink raw reply related

* [PATCH 05/11] fec_mpc52xx: enable transmit and receive time stamping.
From: Richard Cochran @ 2011-06-19 11:20 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Grant Likely
In-Reply-To: <cover.1308481491.git.richard.cochran@omicron.at>

This patch enables software (and phy device) time stamping. Software
time stamping using the SO_TIMESTAMPING API was tested and found to be
working on the LITE5200B board.

Cc: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Richard Cochran <richard.cochran@omicron.at>
---
 drivers/net/fec_mpc52xx.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c
index 9f81b1a..102bdbc 100644
--- a/drivers/net/fec_mpc52xx.c
+++ b/drivers/net/fec_mpc52xx.c
@@ -337,6 +337,7 @@ static int mpc52xx_fec_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	bcom_submit_next_buffer(priv->tx_dmatsk, skb);
 	spin_unlock_irqrestore(&priv->lock, flags);
+	skb_tx_timestamp(skb);
 
 	if (bcom_queue_full(priv->tx_dmatsk)) {
 		netif_stop_queue(dev);
@@ -434,7 +435,8 @@ static irqreturn_t mpc52xx_fec_rx_interrupt(int irq, void *dev_id)
 		length = status & BCOM_FEC_RX_BD_LEN_MASK;
 		skb_put(rskb, length - 4);	/* length without CRC32 */
 		rskb->protocol = eth_type_trans(rskb, dev);
-		netif_rx(rskb);
+		if (!skb_defer_rx_timestamp(skb))
+			netif_rx(rskb);
 
 		spin_lock(&priv->lock);
 	}
-- 
1.7.0.4


^ permalink raw reply related

* [PATCH 06/11] macb: enable transmit time stamping.
From: Richard Cochran @ 2011-06-19 11:20 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Nicolas Ferre
In-Reply-To: <cover.1308481491.git.richard.cochran@omicron.at>

This patch enables software (and phy device) transmit time stamping
Compile tested only.

Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Richard Cochran <richard.cochran@omicron.at>
---
 drivers/net/macb.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 6c6a028..6944478 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -676,6 +676,8 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	spin_unlock_irqrestore(&bp->lock, flags);
 
+	skb_tx_timestamp(skb);
+
 	return NETDEV_TX_OK;
 }
 
-- 
1.7.0.4


^ permalink raw reply related

* [PATCH 07/11] fs_enet: enable transmit time stamping.
From: Richard Cochran @ 2011-06-19 11:20 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Pantelis Antoniou, Vitaly Bordug
In-Reply-To: <cover.1308481491.git.richard.cochran@omicron.at>

This patch enables software (and phy device) transmit time stamping.
Compile tested only.

Cc: Pantelis Antoniou <pantelis.antoniou@gmail.com>
Cc: Vitaly Bordug <vbordug@ru.mvista.com>
Signed-off-by: Richard Cochran <richard.cochran@omicron.at>
---
 drivers/net/fs_enet/fs_enet-main.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index 21abb5c..8dcb272 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -701,6 +701,8 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	spin_unlock_irqrestore(&fep->tx_lock, flags);
 
+	skb_tx_timestamp(skb);
+
 	return NETDEV_TX_OK;
 }
 
-- 
1.7.0.4


^ permalink raw reply related

* [PATCH 08/11] smsc911x: enable transmit time stamping.
From: Richard Cochran @ 2011-06-19 11:20 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Steve Glendinning
In-Reply-To: <cover.1308481491.git.richard.cochran@omicron.at>

This patch enables software (and phy device) transmit time stamping.
Compile tested only.

Cc: Steve Glendinning <steve.glendinning@smsc.com>
Signed-off-by: Richard Cochran <richard.cochran@omicron.at>
---
 drivers/net/smsc911x.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/net/smsc911x.c b/drivers/net/smsc911x.c
index c6d47d1..6d08b0f 100644
--- a/drivers/net/smsc911x.c
+++ b/drivers/net/smsc911x.c
@@ -1473,6 +1473,7 @@ static int smsc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	pdata->ops->tx_writefifo(pdata, (unsigned int *)bufp, wrsz);
 	freespace -= (skb->len + 32);
+	skb_tx_timestamp(skb);
 	dev_kfree_skb(skb);
 
 	if (unlikely(smsc911x_tx_get_txstatcount(pdata) >= 30))
-- 
1.7.0.4


^ permalink raw reply related


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