Netdev List
 help / color / mirror / Atom feed
* [PATCH next v4 6/6] bonding: Implement user key part of port_key in an AD system.
From: Mahesh Bandewar @ 2015-02-18  7:17 UTC (permalink / raw)
  To: Jay Vosburgh, Andy Gospodarek, Veaceslav Falico,
	Nikolay Aleksandrov, David Miller
  Cc: Mahesh Bandewar, Maciej Zenczykowski, netdev, Eric Dumazet

The port key has three components - user-key, speed-part, and duplex-part.
The LSBit is for the duplex-part, next 5 bits are for the speed while the
remaining 10 bits are the user defined key bits. Get these 10 bits
from the user-space (through the SysFs interface) and use it to form the
admin port-key. Allowed range for the user-key is 0 - 1023 (10 bits). If
it is not provided then use zero for the user-key-bits (default).

It can set using following example code -

   # modprobe bonding mode=4
   # usr_port_key=$(( RANDOM & 0x3FF ))
   # echo $usr_port_key > /sys/class/net/bond0/bonding/ad_user_port_key
   # echo +eth1 > /sys/class/net/bond0/bonding/slaves
   ...
   # ip link set bond0 up

Signed-off-by: Mahesh Bandewar <maheshb@google.com>
---
v1:
  Initial version
v2:
  Renamed ad_actor_user_port_key ad_user_port_key
v3-v4:
  Rebase

 Documentation/networking/bonding.txt | 62 ++++++++++++++++++++++++++++++++++++
 drivers/net/bonding/bond_3ad.c       | 14 ++++----
 drivers/net/bonding/bond_main.c      | 10 ++++++
 drivers/net/bonding/bond_options.c   | 26 +++++++++++++++
 drivers/net/bonding/bond_sysfs.c     | 15 +++++++++
 include/net/bond_options.h           |  1 +
 include/net/bonding.h                |  1 +
 7 files changed, 122 insertions(+), 7 deletions(-)

diff --git a/Documentation/networking/bonding.txt b/Documentation/networking/bonding.txt
index f0d93c58cdb0..da22956b408f 100644
--- a/Documentation/networking/bonding.txt
+++ b/Documentation/networking/bonding.txt
@@ -51,6 +51,7 @@ Table of Contents
 3.4	Configuring Bonding Manually via Sysfs
 3.5	Configuration with Interfaces Support
 3.6	Overriding Configuration for Special Cases
+3.7 Configuring LACP for 802.3ad mode in a more secure way
 
 4. Querying Bonding Configuration
 4.1	Bonding Configuration
@@ -241,6 +242,21 @@ ad_select
 
 	This option was added in bonding version 3.4.0.
 
+ad_user_port_key
+
+	In an AD system, the port-key has three parts as shown below -
+
+	   Bits   Use
+	   00     Duplex
+	   01-05  Speed
+	   06-15  User-defined
+
+	This defines the upper 10 bits of the port key. The values can be
+	from 0 - 1023. If not given, the system defaults to 0.
+
+	This paramter has effect only in 802.3ad mode and is available through
+	SysFs interface.
+
 all_slaves_active
 
 	Specifies that duplicate frames (received on inactive ports) should be
@@ -1643,6 +1659,52 @@ output port selection.
 This feature first appeared in bonding driver version 3.7.0 and support for
 output slave selection was limited to round-robin and active-backup modes.
 
+3.7 Configuring LACP for 802.3ad mode in a more secure way
+----------------------------------------------------------
+
+When using 802.3ad bonding mode, the Actor (host) and Partner (switch)
+exchange LACPDUs.  These LACPDUs cannot be sniffed, because they are
+destined to link local mac addresses (which switches/bridges are not
+supposed to forward).  However, most of the values are easily predictable
+or are simply the machine's MAC address (which is trivially known to all
+other hosts in the same L2).  This implies that other machines in the L2
+domain can spoof LACPDU packets from other hosts to the switch and potentially
+cause mayhem by joining (from the point of view of the switch) another
+machine's aggregate, thus receiving a portion of that hosts incoming
+traffic and / or spoofing traffic from that machine themselves (potentially
+even successfully terminating some portion of flows). Though this is not
+a likely scenario, one could avoid this possibility by simply configuring
+few bonding parameters:
+
+   (a) ad_actor_system : You can set a random mac-address that can be used for
+       these LACPDU exchanges. The value can not be either NULL or Multicast.
+       Also it's preferable to set the local-admin bit. This can be done using
+       the following shell code -
+
+       # sys_mac_addr=$(printf '%02x:%02x:%02x:%02x:%02x:%02x' \
+                                $(( (RANDOM & 0xFE) | 0x02 )) \
+                                $(( RANDOM & 0xFF )) \
+                                $(( RANDOM & 0xFF )) \
+                                $(( RANDOM & 0xFF )) \
+                                $(( RANDOM & 0xFF )) \
+                                $(( RANDOM & 0xFF )))
+       # echo $sys_mac_addr > /sys/class/net/bond0/bonding/ad_actor_system
+
+   (b) ad_actor_sys_prio : Randomize the system priority. The default value
+       is 65535, but system can take the value from 1 - 65535. You can do this
+       this using the following shell code -
+
+       # sys_prio=$(( 1 + RANDOM + RANDOM ))
+       # echo $sys_prio > /sys/class/net/bond0/bonding/ad_actor_sys_prio
+
+   (c) ad_user_port_key : Use the user portion of the port-key. The default
+       keeps this empty. These the upper 10 bits of the port-key and value
+       ranges from 0 - 1023. You can do this using the following shell code -
+
+       # usr_port_key=$(( RANDOM & 0x3FF ))
+       # echo $usr_port_key > /sys/class/net/bond0/bonding/ad_user_port_key
+
+
 4 Querying Bonding Configuration
 =================================
 
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index d5eacac7daba..cac1aa249626 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -75,10 +75,10 @@
 /* Port Key definitions
  * key is determined according to the link speed, duplex and
  * user key (which is yet not supported)
- * --------------------------------------------------------------
- * Port key :	| User key	| Speed		| Duplex	|
- * --------------------------------------------------------------
- * 16		  6		  1		  0
+ *           --------------------------------------------------------------
+ * Port key  | User key (10 bits)           | Speed (5 bits)      | Duplex|
+ *           --------------------------------------------------------------
+ *           |15                           6|5                   1|0
  */
 #define  AD_DUPLEX_KEY_MASKS    0x1
 #define  AD_SPEED_KEY_MASKS     0x3E
@@ -1955,10 +1955,10 @@ void bond_3ad_bind_slave(struct slave *slave)
 
 		port->slave = slave;
 		port->actor_port_number = SLAVE_AD_INFO(slave)->id;
-		/* key is determined according to the link speed, duplex and user key(which
-		 * is yet not supported)
+		/* key is determined according to the link speed, duplex and
+		 * user key
 		 */
-		port->actor_admin_port_key = 0;
+		port->actor_admin_port_key = bond->params.ad_user_port_key << 6;
 		port->actor_admin_port_key |= __get_duplex(port);
 		port->actor_admin_port_key |= (__get_link_speed(port) << 1);
 		port->actor_oper_port_key = port->actor_admin_port_key;
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 45c148431595..ce543df28eee 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4137,6 +4137,7 @@ static int bond_check_params(struct bond_params *params)
 	const struct bond_opt_value *valptr;
 	int arp_all_targets_value;
 	u16 ad_actor_sys_prio = 0;
+	u16 ad_user_port_key = 0;
 
 	/* Convert string parameters. */
 	if (mode) {
@@ -4441,6 +4442,14 @@ static int bond_check_params(struct bond_params *params)
 			return -EINVAL;
 		}
 		ad_actor_sys_prio = valptr->value;
+
+		valptr = bond_opt_parse(bond_opt_get(BOND_OPT_AD_USER_PORT_KEY),
+					&newval);
+		if (!valptr) {
+			pr_err("Error: No ad_user_port_key default value");
+			return -EINVAL;
+		}
+		ad_user_port_key = valptr->value;
 	}
 
 	if (lp_interval == 0) {
@@ -4473,6 +4482,7 @@ static int bond_check_params(struct bond_params *params)
 	params->tlb_dynamic_lb = 1; /* Default value */
 	params->ad_actor_sys_prio = ad_actor_sys_prio;
 	eth_zero_addr(params->ad_actor_system);
+	params->ad_user_port_key = ad_user_port_key;
 	if (packets_per_slave > 0) {
 		params->reciprocal_packets_per_slave =
 			reciprocal_value(packets_per_slave);
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index f2c011b3ea33..eb0a8e9fafe7 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -74,6 +74,8 @@ static int bond_option_ad_actor_sys_prio_set(struct bonding *bond,
 				  const struct bond_opt_value *newval);
 static int bond_option_ad_actor_system_set(struct bonding *bond,
 				  const struct bond_opt_value *newval);
+static int bond_option_ad_user_port_key_set(struct bonding *bond,
+				  const struct bond_opt_value *newval);
 
 
 static const struct bond_opt_value bond_mode_tbl[] = {
@@ -196,6 +198,12 @@ static const struct bond_opt_value bond_ad_actor_sys_prio_tbl[] = {
 	{ NULL,      -1,    0},
 };
 
+static const struct bond_opt_value bond_ad_user_port_key_tbl[] = {
+	{ "minval",  0,     BOND_VALFLAG_MIN | BOND_VALFLAG_DEFAULT},
+	{ "maxval",  1023,  BOND_VALFLAG_MAX},
+	{ NULL,      -1,    0},
+};
+
 static const struct bond_option bond_opts[BOND_OPT_LAST] = {
 	[BOND_OPT_MODE] = {
 		.id = BOND_OPT_MODE,
@@ -405,6 +413,14 @@ static const struct bond_option bond_opts[BOND_OPT_LAST] = {
 		.flags = BOND_OPTFLAG_RAWVAL | BOND_OPTFLAG_IFDOWN,
 		.set = bond_option_ad_actor_system_set,
 	},
+	[BOND_OPT_AD_USER_PORT_KEY] = {
+		.id = BOND_OPT_AD_USER_PORT_KEY,
+		.name = "ad_user_port_key",
+		.unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)),
+		.flags = BOND_OPTFLAG_IFDOWN,
+		.values = bond_ad_user_port_key_tbl,
+		.set = bond_option_ad_user_port_key_set,
+	}
 };
 
 /* Searches for an option by name */
@@ -1405,3 +1421,13 @@ static int bond_option_ad_actor_system_set(struct bonding *bond,
 
 	return 0;
 }
+
+static int bond_option_ad_user_port_key_set(struct bonding *bond,
+					    const struct bond_opt_value *newval)
+{
+	netdev_info(bond->dev, "Setting ad_user_port_key to (%llu)\n",
+		    newval->value);
+
+	bond->params.ad_user_port_key = newval->value;
+	return 0;
+}
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index efa994243a2d..a6950647d99d 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -720,6 +720,20 @@ static ssize_t bonding_show_ad_actor_system(struct device *d,
 static DEVICE_ATTR(ad_actor_system, S_IRUGO | S_IWUSR,
 		   bonding_show_ad_actor_system, bonding_sysfs_store_option);
 
+static ssize_t bonding_show_ad_user_port_key(struct device *d,
+					     struct device_attribute *attr,
+					     char *buf)
+{
+	struct bonding *bond = to_bond(d);
+
+	if (BOND_MODE(bond) == BOND_MODE_8023AD)
+		return sprintf(buf, "%hu\n", bond->params.ad_user_port_key);
+
+	return 0;
+}
+static DEVICE_ATTR(ad_user_port_key, S_IRUGO | S_IWUSR,
+		   bonding_show_ad_user_port_key, bonding_sysfs_store_option);
+
 static struct attribute *per_bond_attrs[] = {
 	&dev_attr_slaves.attr,
 	&dev_attr_mode.attr,
@@ -755,6 +769,7 @@ static struct attribute *per_bond_attrs[] = {
 	&dev_attr_tlb_dynamic_lb.attr,
 	&dev_attr_ad_actor_sys_prio.attr,
 	&dev_attr_ad_actor_system.attr,
+	&dev_attr_ad_user_port_key.attr,
 	NULL,
 };
 
diff --git a/include/net/bond_options.h b/include/net/bond_options.h
index eeeefa1d3cd8..c28aca25320e 100644
--- a/include/net/bond_options.h
+++ b/include/net/bond_options.h
@@ -65,6 +65,7 @@ enum {
 	BOND_OPT_TLB_DYNAMIC_LB,
 	BOND_OPT_AD_ACTOR_SYS_PRIO,
 	BOND_OPT_AD_ACTOR_SYSTEM,
+	BOND_OPT_AD_USER_PORT_KEY,
 	BOND_OPT_LAST
 };
 
diff --git a/include/net/bonding.h b/include/net/bonding.h
index f24f9862cea9..0ac45b4f7f2a 100644
--- a/include/net/bonding.h
+++ b/include/net/bonding.h
@@ -144,6 +144,7 @@ struct bond_params {
 	int tlb_dynamic_lb;
 	struct reciprocal_value reciprocal_packets_per_slave;
 	u16 ad_actor_sys_prio;
+	u16 ad_user_port_key;
 	u8 ad_actor_system[ETH_ALEN];
 };
 
-- 
2.2.0.rc0.207.ga3a616c

^ permalink raw reply related

* [PATCH next v4 2/6] bonding: implement bond_poll_controller()
From: Mahesh Bandewar @ 2015-02-18  7:17 UTC (permalink / raw)
  To: Jay Vosburgh, Andy Gospodarek, Veaceslav Falico,
	Nikolay Aleksandrov, David Miller
  Cc: Mahesh Bandewar, Maciej Zenczykowski, netdev, Eric Dumazet

This patches implements the poll_controller support for all
bonding driver. If the slaves have poll_controller net_op defined,
this implementation calls them. This is mode agnostic implementation
and iterates through all slaves (based on mode) and calls respective
handler.

Signed-off-by: Mahesh Bandewar <maheshb@google.com>
---
v1:
   Initial version
v2:
   Eliminate bool variable.
v3:
   Rebase
v4:
   Removed 3AD port_operational check

 drivers/net/bonding/bond_main.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index b979c265fc51..f6bdaae7519d 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -928,6 +928,37 @@ static inline void slave_disable_netpoll(struct slave *slave)
 
 static void bond_poll_controller(struct net_device *bond_dev)
 {
+	struct bonding *bond = netdev_priv(bond_dev);
+	struct slave *slave = NULL;
+	struct list_head *iter;
+	struct ad_info ad_info;
+	struct netpoll_info *ni;
+	const struct net_device_ops *ops;
+
+	if (BOND_MODE(bond) == BOND_MODE_8023AD)
+		if (bond_3ad_get_active_agg_info(bond, &ad_info))
+			return;
+
+	bond_for_each_slave(bond, slave, iter) {
+		ops = slave->dev->netdev_ops;
+		if (!bond_slave_is_up(slave) || !ops->ndo_poll_controller)
+			continue;
+
+		if (BOND_MODE(bond) == BOND_MODE_8023AD) {
+			struct aggregator *agg =
+			    SLAVE_AD_INFO(slave)->port.aggregator;
+
+			if (agg && agg->aggregator_identifier !=
+				   ad_info.aggregator_id)
+				continue;
+		}
+
+		ni = rcu_dereference_bh(slave->dev->npinfo);
+		if (down_trylock(&ni->dev_lock))
+			continue;
+		ops->ndo_poll_controller(slave->dev);
+		up(&ni->dev_lock);
+	}
 }
 
 static void bond_netpoll_cleanup(struct net_device *bond_dev)
-- 
2.2.0.rc0.207.ga3a616c

^ permalink raw reply related

* [PATCH] ethernet/ixp4xx: prevent allmulti from clobbering promisc
From: Derrick Pallas @ 2015-02-18  8:50 UTC (permalink / raw)
  To: Krzysztof Halasa; +Cc: netdev, Derrick Pallas

If both promisc and allmulti are set, promisc should trump allmulti and
disable the MAC filter; otherwise, the interface is not really promisc.

Previously, this code checked IFF_ALLMULTI prior to and without regard for
IFF_PROMISC; if both were set, only multicast and direct unicast traffic
would make it through the filter.

Signed-off-by: Derrick Pallas <pallas@meraki.com>
---
 drivers/net/ethernet/xscale/ixp4xx_eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index f7e0f0f..9e16a28 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -938,7 +938,7 @@ static void eth_set_mcast_list(struct net_device *dev)
 	int i;
 	static const u8 allmulti[] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 };
 
-	if (dev->flags & IFF_ALLMULTI) {
+	if ((dev->flags & IFF_ALLMULTI) && !(dev->flags & IFF_PROMISC)) {
 		for (i = 0; i < ETH_ALEN; i++) {
 			__raw_writel(allmulti[i], &port->regs->mcast_addr[i]);
 			__raw_writel(allmulti[i], &port->regs->mcast_mask[i]);
-- 
2.1.0

^ permalink raw reply related

* Re: [PATCH v2 1/3] Ethernet packet sniffer: Device tree binding and vendor prefix
From: Stathis Voukelatos @ 2015-02-18  9:40 UTC (permalink / raw)
  To: Mark Rutland
  Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	netdev@vger.kernel.org, abrestic@chromium.org
In-Reply-To: <20150217173000.GT8994@leverpostej>



On 17/02/15 17:30, Mark Rutland wrote:

>> It is the frequency of the timestamp values supplied to the sniffer
>> module. It is used by the driver to convert to nanoseconds.
>> I was trying to be somewhat generic here and not assume that it
>> is necessarily the same as the 'tstamp' clock below, in which case we
>> could indeed obtain it using the common clock framework.
>
> In what cases would it _not_ be the same? From your description this is
> that clock, no?
>

Counters can often have a divider applied to their input clock and
therefore run at a scaled down frequency. This is not the case in the
first SoC where the sniffer is used, so for simplicity I can modify as
you suggest and remove that field from the DT.

>> Most networking driver use hard-coded values for that, but in my case
>> I did not want to assume a certain fixed clock frequency. I will remove
>> it from the DT and generate it dynamically. There is a kernel function
>> clocks_calc_mult_shift() to do it but unfortunately it is not exported,
>> so I guess I will need to replicate the code.
>
> Or submit a patch exporting it, along with the rationale for doing so?
>

Will do that.

>> Yes, but the sniffer module is hard-wired to a certain Ethernet Mii
>> interface. We can add an entry to tie it to an Ethernet controller, but
>> apart of a sanity check I am not sure what else the S/W can do.
>
> Fundamentally, the use-case for this is monitoring an ethernet
> interface. So regardless of which kernel framework this plumbs into,
> there needs to be a way to go from ethN to whatever this is exposed as.
>
> Exposing a completely separate interface makes no sense. Singleton stuff
> like that inevitably gets broken as someone later builds a board with
> multiple instances of some similar IP block.
>
> So I would imagine that either the link between interface and monitoring
> interface would be described somewhere in the filesystem, or there'd be
> a syscall/ioctl/whatever to go from an interface to the appropriate
> monitoring interface.
>
> That all depends on exactly how this gets exposed in the end, however.
>

After the first version of the patch was submitted, the feedback from 
the netdev list was to expose it as a network interface as this would
allow it to be accessed by standard user space monitoring tools.
It definitely makes sense to link it to the associated ethernet netdev,
but I am not sure if there is a framework in the kernel to do it at
the driver level?

> Thanks,
> Mark.
> --

Thank you,
Stathis

^ permalink raw reply

* RE: [PATCH 3.12 065/122] lib/checksum.c: fix carry in csum_tcpudp_nofold
From: David Laight @ 2015-02-18  9:40 UTC (permalink / raw)
  To: 'Karl Beldan'
  Cc: 'Jiri Slaby', stable@vger.kernel.org,
	linux-kernel@vger.kernel.org, Karl Beldan, Al Viro, Eric Dumazet,
	Arnd Bergmann, Mike Frysinger, netdev@vger.kernel.org,
	Eric Dumazet, David S. Miller
In-Reply-To: <20150217195717.GA6779@magnum.frso.rivierawaves.com>

From: Karl Beldan 
> On Tue, Feb 17, 2015 at 12:04:22PM +0000, David Laight wrote:
> > > +static inline u32 from64to32(u64 x)
> > > +{
> > > +	/* add up 32-bit and 32-bit for 32+c bit */
> > > +	x = (x & 0xffffffff) + (x >> 32);
> > > +	/* add up carry.. */
> > > +	x = (x & 0xffffffff) + (x >> 32);
> > > +	return (u32)x;
> > > +}
> >
> > As a matter of interest, does the compiler optimise away the
> > second (x & 0xffffffff) ?
> > The code could just be:
> > 	x = (x & 0xffffffff) + (x >> 32);
> > 	return x + (x >> 32);
> >
>
> On my side, from what I've seen so far, your version results in better
> assembly, esp. with clang, but my first version
> http://article.gmane.org/gmane.linux.kernel/1875407:
>         x += (x << 32) + (x >> 32);
> 	return (__force __wsum)(x >> 32);
> resulted in even better assembly, I just verified with gcc/clang,
> x86_64/ARM and -O1,2,3.

The latter looks to have a shorter dependency chain as well.
Although I'd definitely include a comment saying that it is equivalent
to the two lines in the current patch.

Does either compiler manage to use a rotate for the two shifts?
Using '(x << 32) | (x >> 32)' might convince it to do so.
That would reduce it to three 'real' instructions and a register rename.

	David


^ permalink raw reply

* [PATCH] net: Initialize all members in skb_gro_remcsum_init()
From: Geert Uytterhoeven @ 2015-02-18 10:38 UTC (permalink / raw)
  To: David S. Miller, Tom Herbert; +Cc: netdev, linux-kernel, Geert Uytterhoeven

skb_gro_remcsum_init() initializes the gro_remcsum.delta member only,
leading to compiler warnings about a possibly uninitialized
gro_remcsum.offset member:

drivers/net/vxlan.c: In function ‘vxlan_gro_receive’:
drivers/net/vxlan.c:602: warning: ‘grc.offset’ may be used uninitialized in this function
net/ipv4/fou.c: In function ‘gue_gro_receive’:
net/ipv4/fou.c:262: warning: ‘grc.offset’ may be used uninitialized in this function

While these are harmless for now:
  - skb_gro_remcsum_process() sets offset before changing delta,
  - skb_gro_remcsum_cleanup() checks if delta is non-zero before
    accessing offset,
it's safer to let the initialization function initialize all members.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 include/linux/netdevice.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 5897b4ea5a3f9e0f..429d1790a27e85f3 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2342,6 +2342,7 @@ struct gro_remcsum {
 
 static inline void skb_gro_remcsum_init(struct gro_remcsum *grc)
 {
+	grc->offset = 0;
 	grc->delta = 0;
 }
 
-- 
1.9.1

^ permalink raw reply related

* [PATCH] net: macb: Add big endian CPU support
From: Arun Chandran @ 2015-02-18 11:29 UTC (permalink / raw)
  To: Nicolas Ferre, netdev, linux-kernel; +Cc: Arun Chandran

This patch converts all __raw_readl and __raw_writel function calls
to their corresponding readl_relaxed and writel_relaxed variants.

It also tells the driver to set ahb_endian_swp_mgmt_en bit in dma_cfg
when the CPU is configured in big endian mode.

Signed-off-by: Arun Chandran <achandran@mvista.com>
---
	This patch is tested on xilinx ZC702 evaluation board with
	CONFIG_CPU_BIG_ENDIAN=y and booting NFS rootfs
---
---
 drivers/net/ethernet/cadence/macb.c | 18 ++++++++++++------
 drivers/net/ethernet/cadence/macb.h | 15 ++++++++-------
 2 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index ad76b8e..05fb36d 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -449,7 +449,7 @@ static void macb_update_stats(struct macb *bp)
 	WARN_ON((unsigned long)(end - p - 1) != (MACB_TPF - MACB_PFR) / 4);
 
 	for(; p < end; p++, reg++)
-		*p += __raw_readl(reg);
+		*p += readl_relaxed(reg);
 }
 
 static int macb_halt_tx(struct macb *bp)
@@ -1585,7 +1585,11 @@ static void macb_configure_dma(struct macb *bp)
 		if (bp->dma_burst_length)
 			dmacfg = GEM_BFINS(FBLDO, bp->dma_burst_length, dmacfg);
 		dmacfg |= GEM_BIT(TXPBMS) | GEM_BF(RXBMS, -1L);
-		dmacfg &= ~GEM_BIT(ENDIA);
+		dmacfg &= ~GEM_BIT(ENDIA_PKT);
+		/* Tell the chip to byteswap descriptors on big-endian hosts */
+#ifdef __BIG_ENDIAN
+		dmacfg |= GEM_BIT(ENDIA_DESC);
+#endif
 		if (bp->dev->features & NETIF_F_HW_CSUM)
 			dmacfg |= GEM_BIT(TXCOEN);
 		else
@@ -1832,14 +1836,14 @@ static void gem_update_stats(struct macb *bp)
 
 	for (i = 0; i < GEM_STATS_LEN; ++i, ++p) {
 		u32 offset = gem_statistics[i].offset;
-		u64 val = __raw_readl(bp->regs + offset);
+		u64 val = readl_relaxed(bp->regs + offset);
 
 		bp->ethtool_stats[i] += val;
 		*p += val;
 
 		if (offset == GEM_OCTTXL || offset == GEM_OCTRXL) {
 			/* Add GEM_OCTTXH, GEM_OCTRXH */
-			val = __raw_readl(bp->regs + offset + 4);
+			val = readl_relaxed(bp->regs + offset + 4);
 			bp->ethtool_stats[i] += ((u64)val) << 32;
 			*(++p) += val;
 		}
@@ -2191,12 +2195,14 @@ static void macb_probe_queues(void __iomem *mem,
 	*num_queues = 1;
 
 	/* is it macb or gem ? */
-	mid = __raw_readl(mem + MACB_MID);
+	mid = readl_relaxed(mem + MACB_MID);
+
 	if (MACB_BFEXT(IDNUM, mid) != 0x2)
 		return;
 
 	/* bit 0 is never set but queue 0 always exists */
-	*queue_mask = __raw_readl(mem + GEM_DCFG6) & 0xff;
+	*queue_mask = readl_relaxed(mem + GEM_DCFG6) & 0xff;
+
 	*queue_mask |= 0x1;
 
 	for (hw_q = 1; hw_q < MACB_MAX_QUEUES; ++hw_q)
diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index 31dc080..57f0a1a 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -229,7 +229,8 @@
 /* Bitfields in DMACFG. */
 #define GEM_FBLDO_OFFSET	0 /* fixed burst length for DMA */
 #define GEM_FBLDO_SIZE		5
-#define GEM_ENDIA_OFFSET	7 /* endian swap mode for packet data access */
+#define GEM_ENDIA_DESC_OFFSET	6 /* endian swap mode for management descriptor access */
+#define GEM_ENDIA_PKT_OFFSET	7 /* endian swap mode for packet data access */
 #define GEM_ENDIA_SIZE		1
 #define GEM_RXBMS_OFFSET	8 /* RX packet buffer memory size select */
 #define GEM_RXBMS_SIZE		2
@@ -423,17 +424,17 @@
 
 /* Register access macros */
 #define macb_readl(port,reg)				\
-	__raw_readl((port)->regs + MACB_##reg)
+	readl_relaxed((port)->regs + MACB_##reg)
 #define macb_writel(port,reg,value)			\
-	__raw_writel((value), (port)->regs + MACB_##reg)
+	writel_relaxed((value), (port)->regs + MACB_##reg)
 #define gem_readl(port, reg)				\
-	__raw_readl((port)->regs + GEM_##reg)
+	readl_relaxed((port)->regs + GEM_##reg)
 #define gem_writel(port, reg, value)			\
-	__raw_writel((value), (port)->regs + GEM_##reg)
+	writel_relaxed((value), (port)->regs + GEM_##reg)
 #define queue_readl(queue, reg)				\
-	__raw_readl((queue)->bp->regs + (queue)->reg)
+	readl_relaxed((queue)->bp->regs + (queue)->reg)
 #define queue_writel(queue, reg, value)			\
-	__raw_writel((value), (queue)->bp->regs + (queue)->reg)
+	writel_relaxed((value), (queue)->bp->regs + (queue)->reg)
 
 /* Conditional GEM/MACB macros.  These perform the operation to the correct
  * register dependent on whether the device is a GEM or a MACB.  For registers
-- 
1.9.1

^ permalink raw reply related

* Re: [PATCH v2 1/3] Ethernet packet sniffer: Device tree binding and vendor prefix
From: Mark Rutland @ 2015-02-18 12:11 UTC (permalink / raw)
  To: Stathis Voukelatos
  Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	netdev@vger.kernel.org, abrestic@chromium.org
In-Reply-To: <54E45E06.2020609@linn.co.uk>

On Wed, Feb 18, 2015 at 09:40:22AM +0000, Stathis Voukelatos wrote:
> 
> 
> On 17/02/15 17:30, Mark Rutland wrote:
> 
> >> It is the frequency of the timestamp values supplied to the sniffer
> >> module. It is used by the driver to convert to nanoseconds.
> >> I was trying to be somewhat generic here and not assume that it
> >> is necessarily the same as the 'tstamp' clock below, in which case we
> >> could indeed obtain it using the common clock framework.
> >
> > In what cases would it _not_ be the same? From your description this is
> > that clock, no?
> >
> 
> Counters can often have a divider applied to their input clock and
> therefore run at a scaled down frequency. This is not the case in the
> first SoC where the sniffer is used, so for simplicity I can modify as
> you suggest and remove that field from the DT.

The common clock bindings have fixed-factor-clock for handling dividers,
so I believe you should be able to use that.

You mentioned that the counter was a block external to the sniffer. Does
it have any configuration interface (e.g. to reset the counter)? We may
need to model it in the DT if so (and describe the clock as feeding into
it rather than into the sniffer).

> >> Yes, but the sniffer module is hard-wired to a certain Ethernet Mii
> >> interface. We can add an entry to tie it to an Ethernet controller, but
> >> apart of a sanity check I am not sure what else the S/W can do.
> >
> > Fundamentally, the use-case for this is monitoring an ethernet
> > interface. So regardless of which kernel framework this plumbs into,
> > there needs to be a way to go from ethN to whatever this is exposed as.
> >
> > Exposing a completely separate interface makes no sense. Singleton stuff
> > like that inevitably gets broken as someone later builds a board with
> > multiple instances of some similar IP block.
> >
> > So I would imagine that either the link between interface and monitoring
> > interface would be described somewhere in the filesystem, or there'd be
> > a syscall/ioctl/whatever to go from an interface to the appropriate
> > monitoring interface.
> >
> > That all depends on exactly how this gets exposed in the end, however.
> >
> 
> After the first version of the patch was submitted, the feedback from 
> the netdev list was to expose it as a network interface as this would
> allow it to be accessed by standard user space monitoring tools.
> It definitely makes sense to link it to the associated ethernet netdev,
> but I am not sure if there is a framework in the kernel to do it at
> the driver level?

Unfortunately I'm not familiar enough with the net code; hopefully
someone else can point us in the right direction.

Thanks,
Mark.

^ permalink raw reply

* RX performance bottleneck on i.MX6Q with KSZ9031
From: Clemens Gruber @ 2015-02-18 12:25 UTC (permalink / raw)
  To: netdev

Hi,

we are developing an IO board with a TQMa6Q module, which in turn is
using the i.MX6Q. As ethernet PHY we are using the Micrel KSZ9031RNX.
We run Linux 3.19 and are experiencing poor receive throughput when
testing with iperf. However, this also occured on 3.16 and before.

Transmit performance is OK (about 350-400 Mbit/s), but when receiving
data, there seems to be an upper bound of 135 Mbit/s.

I am aware of the Freescale ERR004512, which explains the bottleneck for
TX but not for RX. I am of course testing this separately.

What's also odd is that when I am pinging the embedded board from my
Linux Desktop, I get the following result:
35 packets transmitted, 35 received, 0% packet loss, time 34043ms
rtt min/avg/max/mdev = 0.467/38.600/79.556/23.740 ms
But when pinging my desktop from the embedded board, I get a much lower RTT:
35 packets transmitted, 35 packets received, 0% packet loss
round-trip min/avg/max = 0.216/0.283/0.336 ms

ethtool eth0 reports the following:
Supported ports: [ TP MII ]
Supported link modes:   10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full 1000baseT/Full
Supported pause frame use: Symmetric
Supports auto-negotiation: Yes
Advertised link modes:  10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full 1000baseT/Full
Advertised pause frame use: Symmetric
Advertised auto-negotiation: Yes
Link partner advertised link modes:  10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full 1000baseT/Full
Link partner advertised pause frame use: No
Link partner advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: MII
PHYAD: 3
Transceiver: external
Auto-negotiation: on
Link detected: yes

Can anyone confirm poor ethernet RX performance when using the i.MX6
processor and/or the KSZ9031RNX PHY?
Any ideas what the cause or bottleneck might be? fec driver, phy, mac?

Do you have any tips on how to debug this further and improve the
performance?

Best regards,
Clemens

^ permalink raw reply

* Re: [PATCH next v4 2/6] bonding: implement bond_poll_controller()
From: Nikolay Aleksandrov @ 2015-02-18 12:35 UTC (permalink / raw)
  To: Mahesh Bandewar, Jay Vosburgh, Andy Gospodarek, Veaceslav Falico,
	David Miller
  Cc: Maciej Zenczykowski, netdev, Eric Dumazet
In-Reply-To: <1424243869-27029-1-git-send-email-maheshb@google.com>

On 02/18/2015 08:17 AM, Mahesh Bandewar wrote:
> This patches implements the poll_controller support for all
> bonding driver. If the slaves have poll_controller net_op defined,
> this implementation calls them. This is mode agnostic implementation
> and iterates through all slaves (based on mode) and calls respective
> handler.
> 
> Signed-off-by: Mahesh Bandewar <maheshb@google.com>
> ---
> v1:
>    Initial version
> v2:
>    Eliminate bool variable.
> v3:
>    Rebase
> v4:
>    Removed 3AD port_operational check
> 
>  drivers/net/bonding/bond_main.c | 31 +++++++++++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
> 
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index b979c265fc51..f6bdaae7519d 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -928,6 +928,37 @@ static inline void slave_disable_netpoll(struct slave *slave)
>  
>  static void bond_poll_controller(struct net_device *bond_dev)
>  {
> +	struct bonding *bond = netdev_priv(bond_dev);
> +	struct slave *slave = NULL;
> +	struct list_head *iter;
> +	struct ad_info ad_info;
> +	struct netpoll_info *ni;
> +	const struct net_device_ops *ops;
> +
> +	if (BOND_MODE(bond) == BOND_MODE_8023AD)
> +		if (bond_3ad_get_active_agg_info(bond, &ad_info))
> +			return;
> +
> +	bond_for_each_slave(bond, slave, iter) {
        ^^^^^^^^^^
This version of bond_for_each_slave requires RTNL to be held.


> +		ops = slave->dev->netdev_ops;
> +		if (!bond_slave_is_up(slave) || !ops->ndo_poll_controller)
> +			continue;
> +
> +		if (BOND_MODE(bond) == BOND_MODE_8023AD) {
> +			struct aggregator *agg =
> +			    SLAVE_AD_INFO(slave)->port.aggregator;
> +
> +			if (agg && agg->aggregator_identifier !=
> +				   ad_info.aggregator_id)
> +				continue;
> +		}
> +
> +		ni = rcu_dereference_bh(slave->dev->npinfo);
> +		if (down_trylock(&ni->dev_lock))
> +			continue;
> +		ops->ndo_poll_controller(slave->dev);
> +		up(&ni->dev_lock);
> +	}
>  }
>  
>  static void bond_netpoll_cleanup(struct net_device *bond_dev)
> 

^ permalink raw reply

* Re: [PATCH next v4 3/6] bonding: Implement port churn-machine (AD standard 43.4.17).
From: Nikolay Aleksandrov @ 2015-02-18 12:41 UTC (permalink / raw)
  To: Mahesh Bandewar, Jay Vosburgh, Andy Gospodarek, Veaceslav Falico,
	David Miller
  Cc: Maciej Zenczykowski, netdev, Eric Dumazet
In-Reply-To: <1424243872-27071-1-git-send-email-maheshb@google.com>

On 02/18/2015 08:17 AM, Mahesh Bandewar wrote:
> The Churn Detection machines detect the situation where a port is operable,
> but the Actor and Partner have not attached the link to an Aggregator and
> brought the link into operation within a bound time period. Under normal
> operation of the LACP, agreement between Actor and Partner should be reached
> very rapidly. Continued failure to reach agreement can be symptomatic of
> device failure.
> 
> Actor-churn-detection state-machine
> ===================================
> 
> BEGIN=True + PortEnable=False
>            |
>            v
>  +------------------------+   ActorPort.Sync=True  +------------------+
>  |   ACTOR_CHURN_MONITOR  | ---------------------> |  NO_ACTOR_CHURN  |
>  |========================|                        |==================|
>  |    ActorChurn=False    |  ActorPort.Sync=False  | ActorChurn=False |
>  | ActorChurn.Timer=Start | <--------------------- |                  |
>  +------------------------+                        +------------------+
>            |                                                ^
>            |                                                |
>   ActorChurn.Timer=Expired                                  |
>            |                                       ActorPort.Sync=True
>            |                                                |
>            |                +-----------------+             |
>            |                |   ACTOR_CHURN   |             |
>            |                |=================|             |
>            +--------------> | ActorChurn=True | ------------+
>                             |                 |
>                             +-----------------+
> 
> Similar for the Partner-churn-detection.
> 
> Signed-off-by: Mahesh Bandewar <maheshb@google.com>
> ---
> v1:
>   Initial version
> v2-v4:
>   Rebase
> 
>  drivers/net/bonding/bond_3ad.c    | 56 +++++++++++++++++++++++++++++++++++++--
>  drivers/net/bonding/bond_procfs.c | 40 +++++++++++++++++++++++++---
>  include/net/bond_3ad.h            | 29 ++++++++++++++++++++
>  3 files changed, 119 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
> index 9b436696b95e..c728ece78154 100644
> --- a/drivers/net/bonding/bond_3ad.c
> +++ b/drivers/net/bonding/bond_3ad.c
> @@ -38,6 +38,7 @@
>  #define AD_STANDBY                 0x2
>  #define AD_MAX_TX_IN_SECOND        3
>  #define AD_COLLECTOR_MAX_DELAY     0
> +#define AD_MONITOR_CHURNED         0x1000
>  
>  /* Timer definitions (43.4.4 in the 802.3ad standard) */
>  #define AD_FAST_PERIODIC_TIME      1
> @@ -1013,16 +1014,19 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
>  	/* check if state machine should change state */
>  
>  	/* first, check if port was reinitialized */
> -	if (port->sm_vars & AD_PORT_BEGIN)
> +	if (port->sm_vars & AD_PORT_BEGIN) {
>  		port->sm_rx_state = AD_RX_INITIALIZE;
> +		port->sm_vars |= AD_MONITOR_CHURNED;
>  	/* check if port is not enabled */
> -	else if (!(port->sm_vars & AD_PORT_BEGIN)
> +	} else if (!(port->sm_vars & AD_PORT_BEGIN)
>  		 && !port->is_enabled && !(port->sm_vars & AD_PORT_MOVED))
>  		port->sm_rx_state = AD_RX_PORT_DISABLED;
>  	/* check if new lacpdu arrived */
>  	else if (lacpdu && ((port->sm_rx_state == AD_RX_EXPIRED) ||
>  		 (port->sm_rx_state == AD_RX_DEFAULTED) ||
>  		 (port->sm_rx_state == AD_RX_CURRENT))) {
> +		if (port->sm_rx_state != AD_RX_CURRENT)
> +			port->sm_vars |= AD_MONITOR_CHURNED;
>  		port->sm_rx_timer_counter = 0;
>  		port->sm_rx_state = AD_RX_CURRENT;
>  	} else {
> @@ -1100,9 +1104,11 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
>  			 */
>  			port->partner_oper.port_state &= ~AD_STATE_SYNCHRONIZATION;
>  			port->sm_vars &= ~AD_PORT_MATCHED;
> +			port->partner_oper.port_state |= AD_STATE_LACP_TIMEOUT;
>  			port->partner_oper.port_state |= AD_STATE_LACP_ACTIVITY;
>  			port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(AD_SHORT_TIMEOUT));
>  			port->actor_oper_port_state |= AD_STATE_EXPIRED;
> +			port->sm_vars |= AD_MONITOR_CHURNED;
>  			break;
>  		case AD_RX_DEFAULTED:
>  			__update_default_selected(port);
> @@ -1131,6 +1137,44 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
>  	}
>  }
>  
> +/* ad_churn_machine - handle port churn's state machine
> + * @port: the port we're looking at
> + *
> + */
> +static void ad_churn_machine(struct port *port)
> +{
> +	if (port->sm_vars & AD_MONITOR_CHURNED) {
> +		port->sm_vars &= ~AD_MONITOR_CHURNED;
> +		port->sm_churn_actor_state = AD_CHURN_MONITOR;
> +		port->sm_churn_partner_state = AD_CHURN_MONITOR;
> +		port->sm_churn_actor_timer_counter =
> +			__ad_timer_to_ticks(AD_ACTOR_CHURN_TIMER, 0);
> +		 port->sm_churn_partner_timer_counter =
> +			 __ad_timer_to_ticks(AD_PARTNER_CHURN_TIMER, 0);
> +		return;
> +	}
> +	if (port->sm_churn_actor_timer_counter &&
> +		!(--port->sm_churn_actor_timer_counter) &&
> +		(port->sm_churn_actor_state == AD_CHURN_MONITOR)) {
^^^^^^^
These are too indented, also you can drop the () around:
(port->sm_churn_actor_state == AD_CHURN_MONITOR)

> +		if (port->actor_oper_port_state & AD_STATE_SYNCHRONIZATION) {
> +			port->sm_churn_actor_state = AD_NO_CHURN;
> +		} else {
> +			port->churn_actor_count++;
> +			port->sm_churn_actor_state = AD_CHURN;
> +		}
> +	}
> +	if (port->sm_churn_partner_timer_counter &&
> +		!(--port->sm_churn_partner_timer_counter) &&
> +		(port->sm_churn_partner_state == AD_CHURN_MONITOR)) {
^^^^^^^
Same here.

> +		if (port->partner_oper.port_state & AD_STATE_SYNCHRONIZATION) {
> +			port->sm_churn_partner_state = AD_NO_CHURN;
> +		} else {
> +			port->churn_partner_count++;
> +			port->sm_churn_partner_state = AD_CHURN;
> +		}
> +	}
> +}
> +
>  /**
>   * ad_tx_machine - handle a port's tx state machine
>   * @port: the port we're looking at
> @@ -1745,6 +1789,13 @@ static void ad_initialize_port(struct port *port, int lacp_fast)
>  		port->next_port_in_aggregator = NULL;
>  		port->transaction_id = 0;
>  
> +		port->sm_churn_actor_timer_counter = 0;
> +		port->sm_churn_actor_state = 0;
> +		port->churn_actor_count = 0;
> +		port->sm_churn_partner_timer_counter = 0;
> +		port->sm_churn_partner_state = 0;
> +		port->churn_partner_count = 0;
> +
>  		memcpy(&port->lacpdu, &lacpdu, sizeof(lacpdu));
>  	}
>  }
> @@ -2164,6 +2215,7 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
>  		ad_port_selection_logic(port, &update_slave_arr);
>  		ad_mux_machine(port, &update_slave_arr);
>  		ad_tx_machine(port);
> +		ad_churn_machine(port);
>  
>  		/* turn off the BEGIN bit, since we already handled it */
>  		if (port->sm_vars & AD_PORT_BEGIN)
> diff --git a/drivers/net/bonding/bond_procfs.c b/drivers/net/bonding/bond_procfs.c
> index 976f5ad2a0f2..83095a0b4b90 100644
> --- a/drivers/net/bonding/bond_procfs.c
> +++ b/drivers/net/bonding/bond_procfs.c
> @@ -178,13 +178,45 @@ static void bond_info_show_slave(struct seq_file *seq,
>  	seq_printf(seq, "Permanent HW addr: %pM\n", slave->perm_hwaddr);
>  
>  	if (BOND_MODE(bond) == BOND_MODE_8023AD) {
> -		const struct aggregator *agg
> -			= SLAVE_AD_INFO(slave)->port.aggregator;
> +		const struct port *port = &SLAVE_AD_INFO(slave)->port;
> +		const struct aggregator *agg = port->aggregator;
>  
> -		if (agg)
> +		if (agg) {
>  			seq_printf(seq, "Aggregator ID: %d\n",
>  				   agg->aggregator_identifier);
> -		else
> +			seq_printf(seq, "Actor Churn State: %s\n",
> +				   bond_3ad_churn_desc(port->sm_churn_actor_state));
> +			seq_printf(seq, "Partner Churn State: %s\n",
> +				   bond_3ad_churn_desc(port->sm_churn_partner_state));
> +			seq_printf(seq, "Actor Churned Count: %d\n",
> +				   port->churn_actor_count);
> +			seq_printf(seq, "Partner Churned Count: %d\n",
> +				   port->churn_partner_count);
> +
> +			seq_puts(seq, "details actor lacp pdu:\n");
> +			seq_printf(seq, "    system priority: %d\n",
> +				   port->actor_system_priority);
> +			seq_printf(seq, "    port key: %d\n",
> +				   port->actor_oper_port_key);
> +			seq_printf(seq, "    port priority: %d\n",
> +				   port->actor_port_priority);
> +			seq_printf(seq, "    port number: %d\n",
> +				   port->actor_port_number);
> +			seq_printf(seq, "    port state: %d\n",
> +				   port->actor_oper_port_state);
> +
> +			seq_puts(seq, "details partner lacp pdu:\n");
> +			seq_printf(seq, "    system priority: %d\n",
> +				   port->partner_oper.system_priority);
> +			seq_printf(seq, "    oper key: %d\n",
> +				   port->partner_oper.key);
> +			seq_printf(seq, "    port priority: %d\n",
> +				   port->partner_oper.port_priority);
> +			seq_printf(seq, "    port number: %d\n",
> +				   port->partner_oper.port_number);
> +			seq_printf(seq, "    port state: %d\n",
> +				   port->partner_oper.port_state);
> +		} else
>  			seq_puts(seq, "Aggregator ID: N/A\n");
^^^^^^^^^^^^^^^^^^^^
"else" part should also have curly braces.

>  	}
>  	seq_printf(seq, "Slave queue ID: %d\n", slave->queue_id);
> diff --git a/include/net/bond_3ad.h b/include/net/bond_3ad.h
> index f04cdbb7848e..22ac75dd8bd5 100644
> --- a/include/net/bond_3ad.h
> +++ b/include/net/bond_3ad.h
> @@ -82,6 +82,13 @@ typedef enum {
>  	AD_TRANSMIT		/* tx Machine */
>  } tx_states_t;
>  
> +/* churn machine states(43.4.17 in the 802.3ad standard) */
> +typedef enum {
> +	 AD_CHURN_MONITOR, /* monitoring for churn */
> +	 AD_CHURN,         /* churn detected (error) */
> +	 AD_NO_CHURN       /* no churn (no error) */
> +} churn_state_t;
> +
>  /* rx indication types */
>  typedef enum {
>  	AD_TYPE_LACPDU = 1,	/* type lacpdu */
> @@ -229,6 +236,12 @@ typedef struct port {
>  	u16 sm_mux_timer_counter;	/* state machine mux timer counter */
>  	tx_states_t sm_tx_state;	/* state machine tx state */
>  	u16 sm_tx_timer_counter;	/* state machine tx timer counter(allways on - enter to transmit state 3 time per second) */
> +	u16 sm_churn_actor_timer_counter;
> +	u16 sm_churn_partner_timer_counter;
> +	u32 churn_actor_count;
> +	u32 churn_partner_count;
> +	churn_state_t sm_churn_actor_state;
> +	churn_state_t sm_churn_partner_state;
>  	struct slave *slave;		/* pointer to the bond slave that this port belongs to */
>  	struct aggregator *aggregator;	/* pointer to an aggregator that this port related to */
>  	struct port *next_port_in_aggregator;	/* Next port on the linked list of the parent aggregator */
> @@ -262,6 +275,22 @@ struct ad_slave_info {
>  	u16 id;
>  };
>  
> +static inline const char *bond_3ad_churn_desc(churn_state_t state)
> +{
> +	static const char *const churn_description[] =
> +		{ "monitoring",
> +		  "churned",
> +		  "none",
> +		  "unknown"
> +		};
> +	int max_size = sizeof(churn_description) / sizeof(churn_description[0]);
> +
> +	if (state >= max_size)
> +		state = max_size - 1;
> +
> +	return churn_description[state];
> +}
> +
>  /* ========== AD Exported functions to the main bonding code ========== */
>  void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution);
>  void bond_3ad_bind_slave(struct slave *slave);
> 

^ permalink raw reply

* Re: [PATCH next v4 4/6] bonding: Allow userspace to set actors' system_priority in AD system
From: Nikolay Aleksandrov @ 2015-02-18 12:50 UTC (permalink / raw)
  To: Mahesh Bandewar, Jay Vosburgh, Andy Gospodarek, Veaceslav Falico,
	David Miller
  Cc: Maciej Zenczykowski, netdev, Eric Dumazet
In-Reply-To: <1424243874-27109-1-git-send-email-maheshb@google.com>

On 02/18/2015 08:17 AM, Mahesh Bandewar wrote:
> This patch allows user to randomize the system-priority in an ad-system.
> The allowed range is 1 - 0xFFFF while default value is 0xFFFF. If user
> does not specify this value, the system defaults to 0xFFFF, which is
> what it was before this patch.
> 
> Following example code could set the value -
>     # modprobe bonding mode=4
>     # sys_prio=$(( 1 + RANDOM + RANDOM ))
>     # echo $sys_prio > /sys/class/net/bond0/bonding/ad_actor_sys_prio
>     # echo +eth1 > /sys/class/net/bond0/bonding/slaves
>     ...
>     # ip link set bond0 up
> 
> Signed-off-by: Mahesh Bandewar <maheshb@google.com>
> ---
> v1:
>   Initial version
> v2:
>   Rename ad_actor_system_priority to ad_actor_sys_prio
> v3-v4:
>   Rebase
> 
>  Documentation/networking/bonding.txt |  9 +++++++++
>  drivers/net/bonding/bond_3ad.c       |  5 ++++-
>  drivers/net/bonding/bond_main.c      | 14 ++++++++++++++
>  drivers/net/bonding/bond_options.c   | 29 ++++++++++++++++++++++++++++-
>  drivers/net/bonding/bond_procfs.c    |  2 ++
>  drivers/net/bonding/bond_sysfs.c     | 15 +++++++++++++++
>  include/net/bond_options.h           |  1 +
>  include/net/bonding.h                |  1 +
>  8 files changed, 74 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/networking/bonding.txt b/Documentation/networking/bonding.txt
> index 83bf4986baea..f19d888651b8 100644
> --- a/Documentation/networking/bonding.txt
> +++ b/Documentation/networking/bonding.txt
> @@ -178,6 +178,15 @@ active_slave
>  	active slave, or the empty string if there is no active slave or
>  	the current mode does not use an active slave.
>  
> +ad_actor_sys_prio
> +
> +	In an AD system, this specifies the system priority. The allowed range
> +	is 1 - 65535. If the value is not specified, it takes 65535 as the
> +	default value.
> +
> +	This paramter has effect only in 802.3ad mode and is available through
^^^^^^^^^^^^^^^^^^^^^
s/paramter/parameter/

> +	SysFs interface.
> +

^ permalink raw reply

* Re: [PATCH next v4 5/6] bonding: Allow userspace to set actors' macaddr in an AD-system.
From: Nikolay Aleksandrov @ 2015-02-18 12:52 UTC (permalink / raw)
  To: Mahesh Bandewar, Jay Vosburgh, Andy Gospodarek, Veaceslav Falico,
	David Miller
  Cc: Maciej Zenczykowski, netdev, Eric Dumazet
In-Reply-To: <1424243876-27174-1-git-send-email-maheshb@google.com>

On 02/18/2015 08:17 AM, Mahesh Bandewar wrote:
> In an AD system, the communication between actor and partner is the
> business between these two entities. In the current setup anyone on the
> same L2 can "guess" the LACPDU contents and then possibly send the
> spoofed LACPDUs and trick the partner causing connectivity issues for
> the AD system. This patch allows to use a random mac-address obscuring
> it's identity making it harder for someone in the L2 is do the same thing.
> 
> This patch allows user-space to choose the mac-address for the AD-system.
> This mac-address can not be NULL or a Multicast. If the mac-address is set
> from user-space; kernel will honor it and will not overwrite it. In the
> absence (value from user space); the logic will default to using the
> masters' mac as the mac-address for the AD-system.
> 
> It can be set using example code below -
> 
>    # modprobe bonding mode=4
>    # sys_mac_addr=$(printf '%02x:%02x:%02x:%02x:%02x:%02x' \
>                     $(( (RANDOM & 0xFE) | 0x02 )) \
>                     $(( RANDOM & 0xFF )) \
>                     $(( RANDOM & 0xFF )) \
>                     $(( RANDOM & 0xFF )) \
>                     $(( RANDOM & 0xFF )) \
>                     $(( RANDOM & 0xFF )))
>    # echo $sys_mac_addr > /sys/class/net/bond0/bonding/ad_actor_system
>    # echo +eth1 > /sys/class/net/bond0/bonding/slaves
>    ...
>    # ip link set bond0 up
> 
> Signed-off-by: Mahesh Bandewar <maheshb@google.com>
> ---
> v1:
>   Initial version
> v2:
>   Renamed ad_actor_system_mac_address to ad_actor_system
> v3:
>   Fixed commit message.
> v4:
>   Rebase
> 
>  Documentation/networking/bonding.txt | 12 ++++++++++++
>  drivers/net/bonding/bond_3ad.c       |  7 ++++++-
>  drivers/net/bonding/bond_main.c      |  1 +
>  drivers/net/bonding/bond_options.c   | 29 +++++++++++++++++++++++++++++
>  drivers/net/bonding/bond_procfs.c    |  6 ++++++
>  drivers/net/bonding/bond_sysfs.c     | 15 +++++++++++++++
>  include/net/bond_options.h           |  1 +
>  include/net/bonding.h                |  1 +
>  8 files changed, 71 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/networking/bonding.txt b/Documentation/networking/bonding.txt
> index f19d888651b8..f0d93c58cdb0 100644
> --- a/Documentation/networking/bonding.txt
> +++ b/Documentation/networking/bonding.txt
> @@ -187,6 +187,18 @@ ad_actor_sys_prio
>  	This paramter has effect only in 802.3ad mode and is available through
>  	SysFs interface.
>  
> +ad_actor_system
> +
> +	In an AD system, this specifies the mac-address for the actor in
> +	protocol packet exchanges (LACPDUs). The value cannot be NULL or
> +	multicast. It is preferred to have the local-admin bit set for this
> +	mac but driver does not enforce it. If the value is not given then
> +	system defaults to using the masters' mac address as actors' system
> +	address.
> +
> +	This paramter has effect only in 802.3ad mode and is available through
s/paramter/parameter/

> +	SysFs interface.
> +

^ permalink raw reply

* Re: [PATCH next v4 6/6] bonding: Implement user key part of port_key in an AD system.
From: Nikolay Aleksandrov @ 2015-02-18 12:56 UTC (permalink / raw)
  To: Mahesh Bandewar, Jay Vosburgh, Andy Gospodarek, Veaceslav Falico,
	David Miller
  Cc: Maciej Zenczykowski, netdev, Eric Dumazet
In-Reply-To: <1424243878-27212-1-git-send-email-maheshb@google.com>

On 02/18/2015 08:17 AM, Mahesh Bandewar wrote:
> The port key has three components - user-key, speed-part, and duplex-part.
> The LSBit is for the duplex-part, next 5 bits are for the speed while the
> remaining 10 bits are the user defined key bits. Get these 10 bits
> from the user-space (through the SysFs interface) and use it to form the
> admin port-key. Allowed range for the user-key is 0 - 1023 (10 bits). If
> it is not provided then use zero for the user-key-bits (default).
> 
> It can set using following example code -
> 
>    # modprobe bonding mode=4
>    # usr_port_key=$(( RANDOM & 0x3FF ))
>    # echo $usr_port_key > /sys/class/net/bond0/bonding/ad_user_port_key
>    # echo +eth1 > /sys/class/net/bond0/bonding/slaves
>    ...
>    # ip link set bond0 up
> 
> Signed-off-by: Mahesh Bandewar <maheshb@google.com>
> ---
> v1:
>   Initial version
> v2:
>   Renamed ad_actor_user_port_key ad_user_port_key
> v3-v4:
>   Rebase
> 
>  Documentation/networking/bonding.txt | 62 ++++++++++++++++++++++++++++++++++++
>  drivers/net/bonding/bond_3ad.c       | 14 ++++----
>  drivers/net/bonding/bond_main.c      | 10 ++++++
>  drivers/net/bonding/bond_options.c   | 26 +++++++++++++++
>  drivers/net/bonding/bond_sysfs.c     | 15 +++++++++
>  include/net/bond_options.h           |  1 +
>  include/net/bonding.h                |  1 +
>  7 files changed, 122 insertions(+), 7 deletions(-)
> 
> diff --git a/Documentation/networking/bonding.txt b/Documentation/networking/bonding.txt
> index f0d93c58cdb0..da22956b408f 100644
> --- a/Documentation/networking/bonding.txt
> +++ b/Documentation/networking/bonding.txt
> @@ -51,6 +51,7 @@ Table of Contents
>  3.4	Configuring Bonding Manually via Sysfs
>  3.5	Configuration with Interfaces Support
>  3.6	Overriding Configuration for Special Cases
> +3.7 Configuring LACP for 802.3ad mode in a more secure way
>  
>  4. Querying Bonding Configuration
>  4.1	Bonding Configuration
> @@ -241,6 +242,21 @@ ad_select
>  
>  	This option was added in bonding version 3.4.0.
>  
> +ad_user_port_key
> +
> +	In an AD system, the port-key has three parts as shown below -
> +
> +	   Bits   Use
> +	   00     Duplex
> +	   01-05  Speed
> +	   06-15  User-defined
> +
> +	This defines the upper 10 bits of the port key. The values can be
> +	from 0 - 1023. If not given, the system defaults to 0.
> +
> +	This paramter has effect only in 802.3ad mode and is available through
^^^^^^^^^^^
s/paramter/parameter/

> +	SysFs interface.
> +
>  all_slaves_active
>  
>  	Specifies that duplicate frames (received on inactive ports) should be
> @@ -1643,6 +1659,52 @@ output port selection.
>  This feature first appeared in bonding driver version 3.7.0 and support for
>  output slave selection was limited to round-robin and active-backup modes.
>  
> +3.7 Configuring LACP for 802.3ad mode in a more secure way
> +----------------------------------------------------------
> +
> +When using 802.3ad bonding mode, the Actor (host) and Partner (switch)
> +exchange LACPDUs.  These LACPDUs cannot be sniffed, because they are
> +destined to link local mac addresses (which switches/bridges are not
> +supposed to forward).  However, most of the values are easily predictable
> +or are simply the machine's MAC address (which is trivially known to all
> +other hosts in the same L2).  This implies that other machines in the L2
> +domain can spoof LACPDU packets from other hosts to the switch and potentially
> +cause mayhem by joining (from the point of view of the switch) another
> +machine's aggregate, thus receiving a portion of that hosts incoming
> +traffic and / or spoofing traffic from that machine themselves (potentially
> +even successfully terminating some portion of flows). Though this is not
> +a likely scenario, one could avoid this possibility by simply configuring
> +few bonding parameters:
> +
> +   (a) ad_actor_system : You can set a random mac-address that can be used for
> +       these LACPDU exchanges. The value can not be either NULL or Multicast.
> +       Also it's preferable to set the local-admin bit. This can be done using
> +       the following shell code -
> +
> +       # sys_mac_addr=$(printf '%02x:%02x:%02x:%02x:%02x:%02x' \
> +                                $(( (RANDOM & 0xFE) | 0x02 )) \
> +                                $(( RANDOM & 0xFF )) \
> +                                $(( RANDOM & 0xFF )) \
> +                                $(( RANDOM & 0xFF )) \
> +                                $(( RANDOM & 0xFF )) \
> +                                $(( RANDOM & 0xFF )))
> +       # echo $sys_mac_addr > /sys/class/net/bond0/bonding/ad_actor_system
> +
> +   (b) ad_actor_sys_prio : Randomize the system priority. The default value
> +       is 65535, but system can take the value from 1 - 65535. You can do this
> +       this using the following shell code -
> +
> +       # sys_prio=$(( 1 + RANDOM + RANDOM ))
> +       # echo $sys_prio > /sys/class/net/bond0/bonding/ad_actor_sys_prio
> +
> +   (c) ad_user_port_key : Use the user portion of the port-key. The default
> +       keeps this empty. These the upper 10 bits of the port-key and value
                            ^^^^^^^^^^^^^^^^^^
These are ?

> +       ranges from 0 - 1023. You can do this using the following shell code -
> +
> +       # usr_port_key=$(( RANDOM & 0x3FF ))
> +       # echo $usr_port_key > /sys/class/net/bond0/bonding/ad_user_port_key
> +
> +

^ permalink raw reply

* Re: [PATCH next v4 1/6] bonding: Verify RX LACPDU has proper dest mac-addr
From: Nikolay Aleksandrov @ 2015-02-18 12:58 UTC (permalink / raw)
  To: Mahesh Bandewar, Jay Vosburgh, Andy Gospodarek, Veaceslav Falico,
	David Miller
  Cc: Maciej Zenczykowski, netdev, Eric Dumazet
In-Reply-To: <1424243866-26989-1-git-send-email-maheshb@google.com>

On 02/18/2015 08:17 AM, Mahesh Bandewar wrote:
> The 802.1AX standard states:
> "The DA in LACPDUs is the Slow_Protocols_Multicast address."
> 
> This patch enforces that and drops LACPDUs with destination MAC
> addresses other than Slow_Protocols_Multicast address
> 
> Signed-off-by: Mahesh Bandewar <maheshb@google.com>
> ---
> v1:
>    Initial version
> v2-v4:
>    Rebase
> 
>  drivers/net/bonding/bond_3ad.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
> index cfc4a9c1000a..9b436696b95e 100644
> --- a/drivers/net/bonding/bond_3ad.c
> +++ b/drivers/net/bonding/bond_3ad.c
> @@ -2485,6 +2485,9 @@ int bond_3ad_lacpdu_recv(const struct sk_buff *skb, struct bonding *bond,
>  	if (skb->protocol != PKT_TYPE_LACPDU)
>  		return RX_HANDLER_ANOTHER;
>  
> +	if (!MAC_ADDRESS_EQUAL(eth_hdr(skb)->h_dest, lacpdu_mcast_addr))
> +		return RX_HANDLER_ANOTHER;
> +
>  	lacpdu = skb_header_pointer(skb, 0, sizeof(_lacpdu), &_lacpdu);
>  	if (!lacpdu)
>  		return RX_HANDLER_ANOTHER;
> 

Reviewed-by: Nikolay Aleksandrov <nikolay@redhat.com>

^ permalink raw reply

* Re: [PATCH next v4 2/6] bonding: implement bond_poll_controller()
From: Nikolay Aleksandrov @ 2015-02-18 13:40 UTC (permalink / raw)
  To: Mahesh Bandewar, Jay Vosburgh, Andy Gospodarek, Veaceslav Falico,
	David Miller
  Cc: Maciej Zenczykowski, netdev, Eric Dumazet
In-Reply-To: <1424243869-27029-1-git-send-email-maheshb@google.com>

On 02/18/2015 08:17 AM, Mahesh Bandewar wrote:
> This patches implements the poll_controller support for all
> bonding driver. If the slaves have poll_controller net_op defined,
> this implementation calls them. This is mode agnostic implementation
> and iterates through all slaves (based on mode) and calls respective
> handler.
> 
> Signed-off-by: Mahesh Bandewar <maheshb@google.com>
> ---
> v1:
>    Initial version
> v2:
>    Eliminate bool variable.
> v3:
>    Rebase
> v4:
>    Removed 3AD port_operational check
> 
>  drivers/net/bonding/bond_main.c | 31 +++++++++++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
> 
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index b979c265fc51..f6bdaae7519d 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -928,6 +928,37 @@ static inline void slave_disable_netpoll(struct slave *slave)
>  
>  static void bond_poll_controller(struct net_device *bond_dev)
>  {
> +	struct bonding *bond = netdev_priv(bond_dev);
> +	struct slave *slave = NULL;
> +	struct list_head *iter;
> +	struct ad_info ad_info;
> +	struct netpoll_info *ni;
> +	const struct net_device_ops *ops;
> +
> +	if (BOND_MODE(bond) == BOND_MODE_8023AD)
> +		if (bond_3ad_get_active_agg_info(bond, &ad_info))
> +			return;
> +
> +	bond_for_each_slave(bond, slave, iter) {
> +		ops = slave->dev->netdev_ops;
> +		if (!bond_slave_is_up(slave) || !ops->ndo_poll_controller)
> +			continue;
> +
> +		if (BOND_MODE(bond) == BOND_MODE_8023AD) {
> +			struct aggregator *agg =
> +			    SLAVE_AD_INFO(slave)->port.aggregator;
> +
> +			if (agg && agg->aggregator_identifier !=
> +				   ad_info.aggregator_id)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Please move the second half on its own line without breaking it like
this.

> +				continue;
> +		}
> +
> +		ni = rcu_dereference_bh(slave->dev->npinfo);
> +		if (down_trylock(&ni->dev_lock))
> +			continue;
> +		ops->ndo_poll_controller(slave->dev);
> +		up(&ni->dev_lock);
> +	}
>  }
>  
>  static void bond_netpoll_cleanup(struct net_device *bond_dev)
> 

^ permalink raw reply

* [PATCH net] sock: sock_dequeue_err_skb() needs hard irq safety
From: Eric Dumazet @ 2015-02-18 13:47 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Willem de Bruijn

From: Eric Dumazet <edumazet@google.com>

Non NAPI drivers can call skb_tstamp_tx() and then sock_queue_err_skb()
from hard IRQ context.

Therefore, sock_dequeue_err_skb() needs to block hard irq or
corruptions or hangs can happen.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Fixes: 364a9e93243d1 ("sock: deduplicate errqueue dequeue")
Fixes: cb820f8e4b7f7 ("net: Provide a generic socket error queue delivery method for Tx time stamps.")
---
 net/core/skbuff.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 88c613eab142..f80507823531 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3621,13 +3621,14 @@ struct sk_buff *sock_dequeue_err_skb(struct sock *sk)
 {
 	struct sk_buff_head *q = &sk->sk_error_queue;
 	struct sk_buff *skb, *skb_next;
+	unsigned long flags;
 	int err = 0;
 
-	spin_lock_bh(&q->lock);
+	spin_lock_irqsave(&q->lock, flags);
 	skb = __skb_dequeue(q);
 	if (skb && (skb_next = skb_peek(q)))
 		err = SKB_EXT_ERR(skb_next)->ee.ee_errno;
-	spin_unlock_bh(&q->lock);
+	spin_unlock_irqrestore(&q->lock, flags);
 
 	sk->sk_err = err;
 	if (err)

^ permalink raw reply related

* Re: [PATCH RFC 1/2] net: dsa: integrate with SWITCHDEV for HW bridging
From: Andrew Lunn @ 2015-02-18 13:49 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Guenter Roeck, netdev, David Miller, Vivien Didelot,
	jerome.oufella, Chris Healy
In-Reply-To: <CAGVrzcZNEz6+peBAaSfadFf+wf9p=8EJ0yqBVZqAmnfEaPDFPA@mail.gmail.com>

> I have put a v2 here which addresses that by retaining which bridge
> the port was added to and comparing that against the bridge net_device
> we want to join:
> 
> https://github.com/ffainelli/linux/tree/dsa-hw-bridge-v2

Hi Florian

This looks O.K.

If we ever get a switch which does not allow disjoint sets of ports,
it will need some changes, but lets not over engineer it now.

   Andrew

^ permalink raw reply

* Re: [PATCH v2 1/3] Ethernet packet sniffer: Device tree binding and vendor prefix
From: Stathis Voukelatos @ 2015-02-18 13:56 UTC (permalink / raw)
  To: Mark Rutland
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	abrestic-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org
In-Reply-To: <20150218121150.GA29429@leverpostej>


Hi Mark,

On 18/02/15 12:11, Mark Rutland wrote:
>>
>> Counters can often have a divider applied to their input clock and
>> therefore run at a scaled down frequency. This is not the case in the
>> first SoC where the sniffer is used, so for simplicity I can modify as
>> you suggest and remove that field from the DT.
>
> The common clock bindings have fixed-factor-clock for handling dividers,
> so I believe you should be able to use that.
>
> You mentioned that the counter was a block external to the sniffer. Does
> it have any configuration interface (e.g. to reset the counter)? We may
> need to model it in the DT if so (and describe the clock as feeding into
> it rather than into the sniffer).
>

The sniffer module is designed so that it receives a Gray encoded
timestamp from another module of the SoC that it is integrated in.
The first integration that we have is in the IMG Pistachio SoC.
There the timestamp counter is part of the Event Timer module
and its source is one of the system clocks of the chip (configurable)
That module will eventually have it's own device-tree node when a
driver becomes available for it.

The 'tstamp' clock given in the sniffer DT node should be such
that when it is enabled it will start the counter and its parent clock,
so that it can start counting.

> Thanks,
> Mark.
>

Stathis
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH RFC 1/2] net: dsa: integrate with SWITCHDEV for HW bridging
From: Guenter Roeck @ 2015-02-18 14:05 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli
  Cc: netdev, David Miller, Vivien Didelot, jerome.oufella, Chris Healy
In-Reply-To: <20150218134937.GI10224@lunn.ch>

On 02/18/2015 05:49 AM, Andrew Lunn wrote:
>> I have put a v2 here which addresses that by retaining which bridge
>> the port was added to and comparing that against the bridge net_device
>> we want to join:
>>
>> https://github.com/ffainelli/linux/tree/dsa-hw-bridge-v2
>
> Hi Florian
>
> This looks O.K.
>
> If we ever get a switch which does not allow disjoint sets of ports,
> it will need some changes, but lets not over engineer it now.
>

Good point. The driver for that chip would have to detect the situation,
maybe by storing the bridge mask, and reject to configure the port
if there is a bridge mask mismatch. So I think this could work with the
current API.

Guenter

^ permalink raw reply

* Re: [PATCH] net: Initialize all members in skb_gro_remcsum_init()
From: Tom Herbert @ 2015-02-18 15:28 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: David S. Miller, Linux Netdev List, LKML
In-Reply-To: <1424255886-20330-1-git-send-email-geert@linux-m68k.org>

On Wed, Feb 18, 2015 at 2:38 AM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> skb_gro_remcsum_init() initializes the gro_remcsum.delta member only,
> leading to compiler warnings about a possibly uninitialized
> gro_remcsum.offset member:
>
> drivers/net/vxlan.c: In function ‘vxlan_gro_receive’:
> drivers/net/vxlan.c:602: warning: ‘grc.offset’ may be used uninitialized in this function
> net/ipv4/fou.c: In function ‘gue_gro_receive’:
> net/ipv4/fou.c:262: warning: ‘grc.offset’ may be used uninitialized in this function
>
> While these are harmless for now:
>   - skb_gro_remcsum_process() sets offset before changing delta,
>   - skb_gro_remcsum_cleanup() checks if delta is non-zero before
>     accessing offset,
> it's safer to let the initialization function initialize all members.
>

Acked-by: Tom Herbert <therbert@google.com>

> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
>  include/linux/netdevice.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 5897b4ea5a3f9e0f..429d1790a27e85f3 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -2342,6 +2342,7 @@ struct gro_remcsum {
>
>  static inline void skb_gro_remcsum_init(struct gro_remcsum *grc)
>  {
> +       grc->offset = 0;
>         grc->delta = 0;
>  }
>
> --
> 1.9.1
>

^ permalink raw reply

* Re: Stable inclusion request: recvmsg/sendmsg userspace regression fix
From: Luis Henriques @ 2015-02-18 15:37 UTC (permalink / raw)
  To: Michal Marek
  Cc: Linux Kernel Network Developers, Ani Sinha, David S. Miller,
	Stable Tree
In-Reply-To: <54CBA338.1000207@suse.cz>

On Fri, Jan 30, 2015 at 04:28:56PM +0100, Michal Marek wrote:
> Hi,
> 
> please include
> 
> commit 6a2a2b3ae0759843b22c929881cc184b00cc63ff
> Author: Ani Sinha <ani@arista.com>
> Date:   Mon Sep 8 14:49:59 2014 -0700
> 
>     net:socket: set msg_namelen to 0 if msg_name is passed as NULL in
> msghdr struct from userland.
> 
> to 3.14.y and older trees, since it fixes a userspace regression caused
> by commit dbb490b9 ("net: socket: error on a negative msg_namelen"). The
> patch applies cleanly to all trees down to 2.6.32.y.
> 

I'm queuing this for the 3.16 kernel as well.  Thanks!

Cheers,
--
Luís

> Thanks,
> Michal
> --
> To unsubscribe from this list: send the line "unsubscribe stable" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH v2 2/3] Packet sniffer core framework
From: Daniel Borkmann @ 2015-02-18 15:42 UTC (permalink / raw)
  To: Stathis Voukelatos, linux-kernel, devicetree, netdev
  Cc: abrestic, richardcochran
In-Reply-To: <9202ff9a629935ada672415bf071a1cf31ac09b6.1424181053.git.stathis.voukelatos@linn.co.uk>

On 02/17/2015 03:03 PM, Stathis Voukelatos wrote:
> The framework registers each backend sniffer channel as a netdev,
> which can be accessed from user space through a raw packet socket.
> Packets received from user space are treated as a command string
> configuration. Each match event from the backend driver will
> generate a packet with the matching bytes plus an optional
> timestamp, if configured by the command string.
>
> Signed-off-by: Stathis Voukelatos <stathis.voukelatos@linn.co.uk>
> ---
>   MAINTAINERS                             |   6 +
>   drivers/net/Kconfig                     |   2 +
>   drivers/net/Makefile                    |   2 +
>   drivers/net/pkt-sniffer/Kconfig         |   8 +
>   drivers/net/pkt-sniffer/Makefile        |   3 +
>   drivers/net/pkt-sniffer/core/module.c   |  37 +++++
>   drivers/net/pkt-sniffer/core/netdev.c   | 254 ++++++++++++++++++++++++++++++++
>   drivers/net/pkt-sniffer/core/snf_core.h |  60 ++++++++
>   include/uapi/linux/pkt_sniffer.h        |  33 +++++
>   9 files changed, 405 insertions(+)
>   create mode 100644 drivers/net/pkt-sniffer/Kconfig
>   create mode 100644 drivers/net/pkt-sniffer/Makefile
>   create mode 100644 drivers/net/pkt-sniffer/core/module.c
>   create mode 100644 drivers/net/pkt-sniffer/core/netdev.c
>   create mode 100644 drivers/net/pkt-sniffer/core/snf_core.h
>   create mode 100644 include/uapi/linux/pkt_sniffer.h
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index aaa039d..7d882de 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -5754,6 +5754,12 @@ M:	Sasha Levin <sasha.levin@oracle.com>
>   S:	Maintained
>   F:	tools/lib/lockdep/
>
> +LINN PACKET SNIFFER DRIVER
> +M: Stathis Voukelatos <stathis.voukelatos@linn.co.uk>
> +S: Maintained
> +F: drivers/net/pkt-sniffer/
> +F: Documentation/devicetree/bindings/net/linn-ether-packet-sniffer.txt

This whole framework really looks like only tailored to your specific
driver, I have no idea who else should reuse that?! So, I don't think
putting this under drivers/net/pkt-sniffer/ is a good idea.

Also it looks slightly confusing as if I understand you correctly, your
module's purpose is to pass down some "packet pattern" to the hardware
and match that in order to get a precise timestamp in return?

Might perhaps be better to have everything vendor-specific under something
like drivers/net/ethernet/linn/ and have the framework squashed into the
driver itself (if parts cannot be generalized in net/packet/).

It would be good if you can also avoid the extra uapi export. Perhaps
it's possible to reuse at least some of the existing timestamping
infrastructure?

^ permalink raw reply

* Re: Setting RPS affinities from network driver
From: Tom Herbert @ 2015-02-18 15:44 UTC (permalink / raw)
  To: Sunil Kovvuri; +Cc: Linux Netdev List, David S. Miller
In-Reply-To: <CA+sq2CeC89YfaTM18JR9dFOoNAbohGk=gFXSkM_4q2oySB12GA@mail.gmail.com>

On Tue, Feb 17, 2015 at 10:16 PM, Sunil Kovvuri <sunil.kovvuri@gmail.com> wrote:
> Hi,
>
> I am writing a network driver for a multicore SOC with a on-board
> network interface and would like to set RPS affinities from driver by
> default. So that the network performance is good with whatever driver
> supplied. Ofcourse these can be further adjusted from userspace
> anyways.
>
> Is there a way to set RPS settings from driver itself ?
> The only issue i am seeing is while setting 'rps_needed' key.
>
There is nothing to prevent this, but it would be really cool to make
this into a library function that drivers can call to initialize RPS
in some sane way (you might want to look at cpu_rmap).

> static_key_slow_inc(&rps_needed);
>
> Currently this is not exported, so having issues while compiling
> driver as module.
>
> If i export this symbol, will it be acceptable ?
>
Seems okay to me.

Thanks,
Tom

>
> Thanks,
> Sunil.
> --
> 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: Setting RPS affinities from network driver
From: Sunil Kovvuri @ 2015-02-18 15:47 UTC (permalink / raw)
  To: Tom Herbert; +Cc: Linux Netdev List, David S. Miller
In-Reply-To: <CA+mtBx9qHdEeXmEGbbWSr_OL3aAQJ37eTbC0mUY_XrTNoZ6iXw@mail.gmail.com>

Thanks Tom,

Will try to implement something like a library function which can be used
by any driver.

Regards,
Sunil.

On Wed, Feb 18, 2015 at 9:14 PM, Tom Herbert <therbert@google.com> wrote:
> On Tue, Feb 17, 2015 at 10:16 PM, Sunil Kovvuri <sunil.kovvuri@gmail.com> wrote:
>> Hi,
>>
>> I am writing a network driver for a multicore SOC with a on-board
>> network interface and would like to set RPS affinities from driver by
>> default. So that the network performance is good with whatever driver
>> supplied. Ofcourse these can be further adjusted from userspace
>> anyways.
>>
>> Is there a way to set RPS settings from driver itself ?
>> The only issue i am seeing is while setting 'rps_needed' key.
>>
> There is nothing to prevent this, but it would be really cool to make
> this into a library function that drivers can call to initialize RPS
> in some sane way (you might want to look at cpu_rmap).
>
>> static_key_slow_inc(&rps_needed);
>>
>> Currently this is not exported, so having issues while compiling
>> driver as module.
>>
>> If i export this symbol, will it be acceptable ?
>>
> Seems okay to me.
>
> Thanks,
> Tom
>
>>
>> Thanks,
>> Sunil.
>> --
>> 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


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