Netdev List
 help / color / mirror / Atom feed
* RE: phy/micrel: KSZ8031RNL RMII clock reconfiguration bug
From: Bruno Thomsen @ 2014-11-17 14:56 UTC (permalink / raw)
  To: Johan Hovold
  Cc: netdev@vger.kernel.org, f.fainelli@gmail.com,
	s.hauer@pengutronix.de, bruno.thomsen@gmail.com,
	linux-kernel@vger.kernel.org
In-Reply-To: <20141115141804.GA24633@localhost>


> Did you specify a led-mode as well, or was the Operation Mode Strap Override (OMSO) write the first access after the soft reset?
No led-mode was specified so OMSO was the first write.

> Did you try any other workarounds besides setting the clock mode before doing the OMSO write?
I spend around 2 weeks hunting down the bug.
During which I tried many things in both the Freescale FEC MAC driver and the Micrel PHY driver.
Changing the init and the probe flow as well as adding a lot of extra debug traces.

> And REF_CLK (pin 16) is not connected? 
Yes, pin 16 is floating.

> Would you able to test my series on your setup, and possibly a couple of diagnostic patches on top?
Sure, I can try later this week.

/Bruno

^ permalink raw reply

* Re: [net-next 03/12] i40e: Handle a single mss packet with more than 8 frags
From: Eric Dumazet @ 2014-11-17 14:55 UTC (permalink / raw)
  To: David Laight
  Cc: Jeff Kirsher, davem@davemloft.net, Serey Kong,
	netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
	jogreene@redhat.com, Shannon Nelson
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D1C9F1E87@AcuExch.aculab.com>

On Mon, 2014-11-17 at 14:40 +0000, David Laight wrote:

> Not that one.
> IIRC is was done to reduce the number of fragments through xennet.
> 
> You really want to try to keep some of the old fragments, just adding
> new ones to merge short sections.
> 
> OTOH 8 fragments isn't enough if the MAC supports TSO (dunno if it does).

I40 is a 40Gb NIC, it supports TSO, obviously.

> The skb_linearize() is only likely to fail for TSO anyway.
> Or rather, if it can't allocate a 4k page you are already stuffed.

So far, nobody wrote the code for this.

Page frag are allocated from pages, so if you cannot allocate a 4k page,
this function has no guarantee to succeed no matter how hard you tried.

alloc_skb_with_frags() was already _much_ better than a single
allocation of order-5 page. But if you feel you can do better, why don't
you provide the code ?

^ permalink raw reply

* RE: [net-next 03/12] i40e: Handle a single mss packet with more than 8 frags
From: David Laight @ 2014-11-17 14:40 UTC (permalink / raw)
  To: 'Eric Dumazet'
  Cc: Jeff Kirsher, davem@davemloft.net, Serey Kong,
	netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
	jogreene@redhat.com, Shannon Nelson
In-Reply-To: <1416234687.5102.2.camel@edumazet-glaptop2.roam.corp.google.com>

From: Eric 
> On Mon, 2014-11-17 at 14:15 +0000, David Laight wrote:
> 
> > Didn't someone write a function that significantly reduces the
> > number of fragments without actually requiring a single linear block?
> 
> I presume you refer to alloc_skb_with_frags() : It does the allocation,
> but I was expecting some kind soul to continue my work and provide the
> companion code to do the copy.

Not that one.
IIRC is was done to reduce the number of fragments through xennet.

You really want to try to keep some of the old fragments, just adding
new ones to merge short sections.

OTOH 8 fragments isn't enough if the MAC supports TSO (dunno if it does).
The skb_linearize() is only likely to fail for TSO anyway.
Or rather, if it can't allocate a 4k page you are already stuffed.

	David.


^ permalink raw reply

* pull-request: can-next 2014-11-17
From: Marc Kleine-Budde @ 2014-11-17 14:41 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, linux-can@vger.kernel.org, kernel@pengutronix.de

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

Hello David,

this is a pull request of 9 patches for net-next/master.

All 9 patches are by Roger Quadros and update the c_can platform
driver. First by improving the initialization sequence of the message
RAM, making use of syscon/regmap. In the later patches support for
various TI SoCs is added.

Marc

---
The following changes since commit 65622ed40eef5ce2732365077b22416593fec4c8:

  Merge branch 'rss_key_fill' (2014-11-16 15:59:19 -0500)

are available in the git repository at:

  git://gitorious.org/linux-can/linux-can-next.git tags/linux-can-next-for-3.19-20141117

for you to fetch changes up to f2bf2589834faec7af8c02c3949c90788d21b790:

  net: can: c_can: Add support for TI am4372 DCAN (2014-11-17 15:32:10 +0100)

----------------------------------------------------------------
linux-can-next-for-3.19-20141117

----------------------------------------------------------------
Roger Quadros (9):
      can: c_can: Add timeout to c_can_hw_raminit_ti()
      can: c_can: Introduce c_can_driver_data structure
      can: c_can: Add RAMINIT register information to driver data
      can: c_can: Add syscon/regmap RAMINIT mechanism
      can: c_can: Add support for START pulse in RAMINIT sequence
      can: c_can: Disable pins when CAN interface is down
      can: c_can: Add support for TI DRA7 DCAN
      can: c_can: Add support for TI am3352 DCAN
      net: can: c_can: Add support for TI am4372 DCAN

 .../devicetree/bindings/net/can/c_can.txt          |   5 +
 drivers/net/can/c_can/c_can.c                      |  13 ++
 drivers/net/can/c_can/c_can.h                      |  25 ++-
 drivers/net/can/c_can/c_can_platform.c             | 201 ++++++++++++++-------
 4 files changed, 181 insertions(+), 63 deletions(-)

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


















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

^ permalink raw reply

* Re: [net-next 03/12] i40e: Handle a single mss packet with more than 8 frags
From: Eric Dumazet @ 2014-11-17 14:31 UTC (permalink / raw)
  To: David Laight
  Cc: Jeff Kirsher, davem@davemloft.net, Serey Kong,
	netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
	jogreene@redhat.com, Shannon Nelson
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D1C9F1E54@AcuExch.aculab.com>

On Mon, 2014-11-17 at 14:15 +0000, David Laight wrote:

> Didn't someone write a function that significantly reduces the
> number of fragments without actually requiring a single linear block?

I presume you refer to alloc_skb_with_frags() : It does the allocation,
but I was expecting some kind soul to continue my work and provide the
companion code to do the copy.

http://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/commit/?id=2e4e44107176d552f8bb1bb76053e850e3809841

So far nobody took care of it.

^ permalink raw reply

* RE: [net-next 03/12] i40e: Handle a single mss packet with more than 8 frags
From: David Laight @ 2014-11-17 14:15 UTC (permalink / raw)
  To: 'Eric Dumazet', Jeff Kirsher
  Cc: davem@davemloft.net, Serey Kong, netdev@vger.kernel.org,
	nhorman@redhat.com, sassmann@redhat.com, jogreene@redhat.com,
	Shannon Nelson
In-Reply-To: <1416075695.17262.86.camel@edumazet-glaptop2.roam.corp.google.com>

From: Eric Dumazet
> > This handles the case where a single packet with more than 8 data
> > descriptors triggers a Malicious Driver Detect event in the device.

Whose bright idea was that?

> > @@ -2129,10 +2129,16 @@ static void i40e_tx_map(struct i40e_ring *tx_ring, struct sk_buff *skb,
> >  			 I40E_TX_FLAGS_VLAN_SHIFT;
> >  	}
> >
> > -	if (tx_flags & (I40E_TX_FLAGS_TSO | I40E_TX_FLAGS_FSO))
> > +	if (tx_flags & (I40E_TX_FLAGS_TSO | I40E_TX_FLAGS_FSO)) {
> >  		gso_segs = skb_shinfo(skb)->gso_segs;
> > -	else
> > +	} else {
> >  		gso_segs = 1;
> > +		if (skb_shinfo(skb)->nr_frags >= I40E_MAX_BUFFER_TXD)
> > +			skb_linearize(skb);
> 
> What exactly happens if skb_linearize() fails ?

Didn't someone write a function that significantly reduces the
number of fragments without actually requiring a single linear block?

	David


^ permalink raw reply

* Re: [PATCH 1/1 net-next] wireless: remove unnecessary sizeof(u8)
From: John W. Linville @ 2014-11-17 13:36 UTC (permalink / raw)
  To: Fabian Frederick
  Cc: Julian Calaby, Johannes Berg, linux-wireless, Larry Finger,
	Chaoming Li, netdev, linux-kernel@vger.kernel.org,
	Emmanuel Grumbach, b43-dev, Stefano Brivio, Intel Linux Wireless
In-Reply-To: <828430032.148603.1416203787175.open-xchange@webmail.nmp.skynet.be>

On Mon, Nov 17, 2014 at 06:56:27AM +0100, Fabian Frederick wrote:
> 
> 
> > On 16 November 2014 at 23:33 Julian Calaby <julian.calaby@gmail.com> wrote:
> >
> >
> > Hi Fabian,
> >
> > On Sat, Nov 15, 2014 at 7:55 AM, Fabian Frederick <fabf@skynet.be> wrote:
> > > sizeof(u8) is always 1.
> >
> > I thought that sizeof(*variable) was preferred over sizeof(type), so
> > shouldn't these be switched to that format instead?
> >
> > (I know that this is all no-op, but it should reduce the potential for
> > highly unlikely bugs in the future. Also, the extra processing is
> > compile-time not run-time.)
> >
> > Thanks,
> 
> Hi Julian,
> 
> Of course but char/u8/s8... allocations never use it and result would be the
> same:
> factor 1 multiplication.
> 
> Those rare occurrences (+- 30 in the whole kernel) where we have
> sizeof(u8/s8) is ambiguous.
> 
> Having a patch removing it gives a pointer...
> If the developer meant something else, he will be able to fix it.
> 
> Regards,
> Fabian

sizeof(*variable) still seems safer.  Are the compilers unable to
optimize-away a "multiply by one"?

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

^ permalink raw reply

* Re: [PATCH] net: team: expose sysfs attributes for each team option
From: Jiri Pirko @ 2014-11-17 13:02 UTC (permalink / raw)
  To: Hamad Kadmany; +Cc: netdev
In-Reply-To: <93856491220bda9aede41a9571fb1ac1.squirrel@www.codeaurora.org>

Mon, Nov 17, 2014 at 11:11:31AM CET, hkadmany@codeaurora.org wrote:
>Current code provides only netlink API for user space
>to read/write options. Exposing sysfs API is useful for
>systems that don't have the required netlink
>user space support.
>
>Upon registration of team option, corresponding
>sysfs attribute is created.

Nak.

I don't like this patch. The plan for team was keep things simple and to
have single userspace api using netlink, as that is the correct way to
deal with things. Sysfs for this use-case is not. Please, use netlink api.

>
>Signed-off-by: Hamad Kadmany <hkadmany@codeaurora.org>
>---
> drivers/net/team/team.c | 282 ++++++++++++++++++++++++++++++++++++++++++++++--
> include/linux/if_team.h |   3 +
> 2 files changed, 278 insertions(+), 7 deletions(-)
>
>diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
>index 1222229..afd2f8f 100644
>--- a/drivers/net/team/team.c
>+++ b/drivers/net/team/team.c
>@@ -110,8 +110,198 @@ struct team_option_inst { /* One for each option instance */
> 	struct team_option_inst_info info;
> 	bool changed;
> 	bool removed;
>+	bool dev_attr_file_exist;
>+	struct device_attribute dev_attr; /* corresponding sysfs attribute */
> };
>
>+static struct attribute *team_sysfs_attrs[] = {
>+	NULL,
>+};
>+
>+static struct attribute_group team_sysfs_attr_group = {
>+	.attrs = team_sysfs_attrs,
>+};
>+
>+/* Device attributes (sysfs) */
>+
>+static ssize_t show_attribute(struct device *dev,
>+			      struct device_attribute *attr,
>+			      char *buf)
>+{
>+	struct team *team = dev_get_drvdata(dev);
>+	struct team_option_inst *opt_inst;
>+	ssize_t ret;
>+	struct team_option *option;
>+	struct team_gsetter_ctx ctx;
>+
>+	if (mutex_lock_interruptible(&team->lock))
>+		return -ERESTARTSYS;
>+
>+	opt_inst = container_of(attr, struct team_option_inst, dev_attr);
>+	option = opt_inst->option;
>+	if (!option->getter) {
>+		ret = -EOPNOTSUPP;
>+		netdev_err(team->dev,
>+			   "Option %s is write only\n", attr->attr.name);
>+		goto exit;
>+	}
>+
>+	ctx.info = &opt_inst->info;
>+	/* let the option getter do its job */
>+	ret = option->getter(team, &ctx);
>+	if (ret)
>+		goto exit;
>+
>+	/* translate option's output into sysfs output */
>+	switch (option->type) {
>+	case TEAM_OPTION_TYPE_U32:
>+		ret = scnprintf(buf, PAGE_SIZE, "%u\n", ctx.data.u32_val);
>+		break;
>+	case TEAM_OPTION_TYPE_STRING:
>+		ret = scnprintf(buf, PAGE_SIZE, "%s\n", ctx.data.str_val);
>+		break;
>+	case TEAM_OPTION_TYPE_BINARY:
>+		if (ctx.data.bin_val.len > PAGE_SIZE) {
>+			netdev_err(team->dev,
>+				   "Option output is too long (%d)\n",
>+				   ctx.data.bin_val.len);
>+			break;
>+		}
>+
>+		memcpy(buf, ctx.data.bin_val.ptr, ctx.data.bin_val.len);
>+		ret = ctx.data.bin_val.len;
>+		break;
>+	case TEAM_OPTION_TYPE_BOOL:
>+		ret = scnprintf(buf, PAGE_SIZE, "%d\n", ctx.data.bool_val);
>+		break;
>+	case TEAM_OPTION_TYPE_S32:
>+		ret = scnprintf(buf, PAGE_SIZE, "%d\n", ctx.data.s32_val);
>+		break;
>+	default:
>+		BUG();
>+	}
>+
>+exit:
>+	mutex_unlock(&team->lock);
>+
>+	return ret;
>+}
>+
>+static int team_nl_send_event_options_get(struct team *team,
>+					  struct list_head *sel_opt_inst_list);
>+
>+static ssize_t set_attribute(struct device *dev,
>+			     struct device_attribute *attr,
>+			     const char *buf, size_t count)
>+{
>+	struct team_option_inst *opt_inst;
>+	struct team *team = dev_get_drvdata(dev);
>+	int err = 0;
>+	struct team_option *option = NULL;
>+	struct team_gsetter_ctx ctx;
>+
>+	LIST_HEAD(opt_inst_list);
>+
>+	if (mutex_lock_interruptible(&team->lock))
>+		return -ERESTARTSYS;
>+
>+	opt_inst = container_of(attr, struct team_option_inst, dev_attr);
>+	option = opt_inst->option;
>+	if (!option->setter) {
>+		netdev_err(team->dev,
>+			   "Option %s is read only\n", attr->attr.name);
>+		err = -EOPNOTSUPP;
>+		goto exit;
>+	}
>+
>+	ctx.info = &opt_inst->info;
>+
>+	/* translate sysfs input into option's input */
>+	switch (option->type) {
>+	case TEAM_OPTION_TYPE_U32:
>+		err = kstrtoint(buf, 0, &ctx.data.u32_val);
>+		break;
>+	case TEAM_OPTION_TYPE_STRING:
>+		if (count > TEAM_STRING_MAX_LEN) {
>+			netdev_err(team->dev,
>+				   "Input buffer too long (%zu)\n", count);
>+			err = -EINVAL;
>+			break;
>+		}
>+		ctx.data.str_val = buf;
>+		break;
>+	case TEAM_OPTION_TYPE_BINARY:
>+		ctx.data.bin_val.len = count;
>+		ctx.data.bin_val.ptr = buf;
>+		break;
>+	case TEAM_OPTION_TYPE_BOOL:
>+		err = strtobool(buf, &ctx.data.bool_val);
>+		break;
>+	case TEAM_OPTION_TYPE_S32:
>+		err = kstrtoint(buf, 0, &ctx.data.s32_val);
>+		break;
>+	default:
>+		BUG();
>+	}
>+
>+	if (err) {
>+		netdev_err(team->dev, "Failed to translate input buffer\n");
>+		goto exit;
>+	}
>+
>+	/* let the option setter do its job */
>+	err = option->setter(team, &ctx);
>+	if (err)
>+		goto exit;
>+
>+	/* propagate option changed event */
>+	opt_inst->changed = true;
>+	list_add(&opt_inst->tmp_list, &opt_inst_list);
>+	err = team_nl_send_event_options_get(team, &opt_inst_list);
>+	if (err == -ESRCH) /* no listeners, not a real error */
>+		err = 0;
>+
>+exit:
>+	mutex_unlock(&team->lock);
>+
>+	if (!err)
>+		err = count;
>+	return err;
>+}
>+
>+/* create sysfs attribute for each option that is being registered */
>+static int __team_option_add_sysfs_attr(struct team *team,
>+					struct team_option_inst *opt_inst,
>+					bool create_sysfs_file)
>+{
>+	int err = 0;
>+	struct device_attribute *new_dev_attr = &opt_inst->dev_attr;
>+
>+	new_dev_attr->attr.name = opt_inst->option->name;
>+	new_dev_attr->attr.mode = S_IRUGO | S_IWUSR;
>+	new_dev_attr->show = show_attribute;
>+	new_dev_attr->store = set_attribute;
>+
>+	if (create_sysfs_file) {
>+		err = sysfs_create_file(&team->dev->dev.kobj,
>+					&new_dev_attr->attr);
>+		if (err)
>+			netdev_err(team->dev,
>+				   "Failed to create sysfs attribute %s\n",
>+				   new_dev_attr->attr.name);
>+	}
>+
>+	return err;
>+}
>+
>+static void __team_option_del_sysfs_attr(struct team *team,
>+					 struct team_option_inst *opt_inst)
>+{
>+	if (opt_inst->dev_attr_file_exist)
>+		sysfs_remove_file(&team->dev->dev.kobj,
>+				  &opt_inst->dev_attr.attr);
>+}
>+
> static struct team_option *__team_find_option(struct team *team,
> 					      const char *opt_name)
> {
>@@ -124,8 +314,10 @@ static struct team_option *__team_find_option(struct team *team,
> 	return NULL;
> }
>
>-static void __team_option_inst_del(struct team_option_inst *opt_inst)
>+static void __team_option_inst_del(struct team *team,
>+				   struct team_option_inst *opt_inst)
> {
>+	__team_option_del_sysfs_attr(team, opt_inst);
> 	list_del(&opt_inst->list);
> 	kfree(opt_inst);
> }
>@@ -137,7 +329,7 @@ static void __team_option_inst_del_option(struct team *team,
>
> 	list_for_each_entry_safe(opt_inst, tmp, &team->option_inst_list, list) {
> 		if (opt_inst->option == option)
>-			__team_option_inst_del(opt_inst);
>+			__team_option_inst_del(team, opt_inst);
> 	}
> }
>
>@@ -162,6 +354,7 @@ static int __team_option_inst_add(struct team *team, struct team_option *option,
> 		opt_inst->info.array_index = i;
> 		opt_inst->changed = true;
> 		opt_inst->removed = false;
>+		opt_inst->dev_attr_file_exist = false;
> 		list_add_tail(&opt_inst->list, &team->option_inst_list);
> 		if (option->init) {
> 			err = option->init(team, &opt_inst->info);
>@@ -170,6 +363,20 @@ static int __team_option_inst_add(struct team *team, struct team_option *option,
> 		}
>
> 	}
>+
>+	/* add sysfs attribute. per-port and array options are skipped */
>+	if (!option->per_port && !option->array_size) {
>+		/* create the sysfs file only if our state allows it */
>+		bool create_sysfs_file = device_is_registered(&team->dev->dev);
>+
>+		err = __team_option_add_sysfs_attr(team, opt_inst,
>+						   create_sysfs_file);
>+		if (err)
>+			return err;
>+
>+		opt_inst->dev_attr_file_exist = true;
>+	}
>+
> 	return 0;
> }
>
>@@ -218,7 +425,7 @@ static void __team_option_inst_del_port(struct team *team,
> 	list_for_each_entry_safe(opt_inst, tmp, &team->option_inst_list, list) {
> 		if (opt_inst->option->per_port &&
> 		    opt_inst->info.port == port)
>-			__team_option_inst_del(opt_inst);
>+			__team_option_inst_del(team, opt_inst);
> 	}
> }
>
>@@ -337,6 +544,51 @@ static void __team_options_unregister(struct team *team,
>
> static void __team_options_change_check(struct team *team);
>
>+static void team_attr_grp_free(struct team *team)
>+{
>+	kfree(team->attr_grp.attrs);
>+}
>+
>+/* allocate attribute group for creating sysfs for team's own options */
>+static int team_attr_grp_alloc(struct team *team)
>+{
>+	struct attribute **attributes;
>+	struct team_option_inst *opt_inst;
>+	int num_attr = 0;
>+	struct team_option *option;
>+
>+	list_for_each_entry(opt_inst, &team->option_inst_list, list) {
>+		option = opt_inst->option;
>+		/* per-port and array options currently not supported as
>+		 * sysfs attributes
>+		 */
>+		if (option->per_port || option->array_size)
>+			continue;
>+
>+		num_attr++;
>+	}
>+
>+	/* +1 for having NULL as last item in the array */
>+	attributes = kzalloc((num_attr + 1) * sizeof(*attributes), GFP_KERNEL);
>+	if (!attributes)
>+		return -ENOMEM;
>+	team->attr_grp.attrs = attributes;
>+
>+	num_attr = 0;
>+	list_for_each_entry(opt_inst, &team->option_inst_list, list) {
>+		option = opt_inst->option;
>+		/* per-port and array options currently not supported as
>+		 * sysfs attributes
>+		 */
>+		if (option->per_port || option->array_size)
>+			continue;
>+
>+		attributes[num_attr++] = &opt_inst->dev_attr.attr;
>+	}
>+
>+	return 0;
>+}
>+
> int team_options_register(struct team *team,
> 			  const struct team_option *option,
> 			  size_t option_count)
>@@ -1380,15 +1632,28 @@ static int team_init(struct net_device *dev)
>
> 	INIT_LIST_HEAD(&team->option_list);
> 	INIT_LIST_HEAD(&team->option_inst_list);
>-	err = team_options_register(team, team_options, ARRAY_SIZE(team_options));
>+
>+	err = team_options_register(team, team_options,
>+				    ARRAY_SIZE(team_options));
> 	if (err)
> 		goto err_options_register;
> 	netif_carrier_off(dev);
>
> 	team_set_lockdep_class(dev);
>
>+	/* store team context, to be used by Device attributes getter/setter */
>+	dev_set_drvdata(&dev->dev, team);
>+
>+	/* allocate and register sysfs attributes for team's own options */
>+	err = team_attr_grp_alloc(team);
>+	if (err)
>+		goto err_grp_alloc;
>+	dev->sysfs_groups[0] = &team->attr_grp;
>+
> 	return 0;
>
>+err_grp_alloc:
>+	team_options_unregister(team, team_options, ARRAY_SIZE(team_options));
> err_options_register:
> 	team_queue_override_fini(team);
> err_team_queue_override_init:
>@@ -1407,9 +1672,15 @@ static void team_uninit(struct net_device *dev)
> 	list_for_each_entry_safe(port, tmp, &team->port_list, list)
> 		team_port_del(team, port->dev);
>
>+	sysfs_remove_group(&team->dev->dev.kobj, &team->attr_grp);
>+	team_attr_grp_free(team);
>+	/* set to dummy group to avoid double free by core */
>+	dev->sysfs_groups[0] = &team_sysfs_attr_group;
>+
> 	__team_change_mode(team, NULL); /* cleanup */
> 	__team_options_unregister(team, team_options, ARRAY_SIZE(team_options));
> 	team_queue_override_fini(team);
>+
> 	mutex_unlock(&team->lock);
> }
>
>@@ -2194,9 +2465,6 @@ static int team_nl_cmd_options_get(struct sk_buff *skb, struct genl_info *info)
> 	return err;
> }
>
>-static int team_nl_send_event_options_get(struct team *team,
>-					  struct list_head *sel_opt_inst_list);
>-
> static int team_nl_cmd_options_set(struct sk_buff *skb, struct genl_info *info)
> {
> 	struct team *team;
>diff --git a/include/linux/if_team.h b/include/linux/if_team.h
>index 25b8b15..2e9fb2a 100644
>--- a/include/linux/if_team.h
>+++ b/include/linux/if_team.h
>@@ -188,6 +188,9 @@ struct team {
> 	struct list_head option_list;
> 	struct list_head option_inst_list; /* list of option instances */
>
>+	/* attribute group for registering team's own options at init */
>+	struct attribute_group attr_grp;
>+
> 	const struct team_mode *mode;
> 	struct team_mode_ops ops;
> 	bool user_carrier_enabled;
>-- 
>1.8.5.2
>-- 
>Qualcomm Israel, on behalf of Qualcomm Innovation Center, Inc.
>The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
>a Linux Foundation Collaborative Project
>

^ permalink raw reply

* [BNX2] A Netdev Watchdog with kernel stable 3.4
From: Rui Xiang @ 2014-11-17 12:42 UTC (permalink / raw)
  To: Michael Chan; +Cc: netdev

Hi Michael,

On a system that was running stable 3.4.87, I got the below stack.
That was a NETDEV WATCHDOG. And we could also see watchdog timeouts with the 
BNX2. (After the stack, an oops occurred while running ifconfig. I think it 
would be related to this timeout.)

Otherwises, the bnx2_dump_state and bnx2_dump_mcp_state have printed the states. 
Through these states info, can we got the real situation of NIC1.
Or can we see what resulted the WATCHDOG, a bnx2 device fault or other reasons.

Thanks.


*The stack*:

 WARNING: at /usr/src/packages/BUILD/kernel-default-3.4.87/linux-3.4/net/sched/sch_generic.c:256 dev_watchdog+0x256/0x260()
 NETDEV WATCHDOG: NIC1 (bnx2): transmit queue 3 timed out
 Modules linked in: smb3_failover(O) smb2(O) smb(O) smb_manager(O) nfs(O) nfs_acl(O) nfsd(O) lockd(O) nal(O) auth_rpcgss(O) 
scsi_dh_hp_sw scsi_dh_alua scsi_dh_emc scsi_dh_rdac scsi_dh scsi_mod [last unloaded: ipmi_msghandler]
 Pid: 0, comm: swapper/0 Tainted: P        W  O 3.4.87-default #1
 Call Trace:
  <IRQ>  [<ffffffff8103fcea>] warn_slowpath_common+0x7a/0xb0
  [<ffffffff8103fdc1>] warn_slowpath_fmt+0x41/0x50
  [<ffffffff81047749>] ? raise_softirq_irqoff+0x9/0x30
  [<ffffffff813ae0f6>] dev_watchdog+0x256/0x260
  [<ffffffff813adea0>] ? dev_deactivate_queue.constprop.30+0x70/0x70
  [<ffffffff8104edc7>] run_timer_softirq+0x147/0x340
  [<ffffffff810470d8>] __do_softirq+0xc8/0x1e0
  [<ffffffff8109250f>] ? tick_program_event+0x1f/0x30
  [<ffffffff81460a6c>] call_softirq+0x1c/0x30
  [<ffffffff8100417d>] do_softirq+0x9d/0xd0
  [<ffffffff810474a5>] irq_exit+0xb5/0xc0
  [<ffffffff81021b49>] smp_apic_timer_interrupt+0x69/0xa0
  [<ffffffff8146006f>] apic_timer_interrupt+0x6f/0x80
  <EOI>  [<ffffffff81457bdd>] ? retint_restore_args+0x13/0x13
  [<ffffffff81360149>] ? poll_idle+0x49/0x90
  [<ffffffff8136011f>] ? poll_idle+0x1f/0x90
  [<ffffffff8135fcc9>] cpuidle_enter+0x19/0x20
  [<ffffffff813602f2>] cpuidle_idle_call+0xa2/0x250
  [<ffffffff8100b08f>] cpu_idle+0x6f/0xe0
  [<ffffffff81915960>] ? rawsock_init+0x12/0x12
  [<ffffffff814331c9>] rest_init+0x6d/0x74
  [<ffffffff818d3be5>] start_kernel+0x3a2/0x3af
  [<ffffffff818d3642>] ? repair_env_string+0x5e/0x5e
  [<ffffffff818d332a>] x86_64_start_reservations+0x131/0x135
  [<ffffffff818d342e>] x86_64_start_kernel+0x100/0x10f
 ---[ end trace 497e24e681e0c02d ]---
 bnx2 0000:05:00.1: NIC1: DEBUG: intr_sem[0] PCI_CMD[00100002]
 bnx2 0000:05:00.1: NIC1: DEBUG: PCI_PM[19002008] PCI_MISC_CFG[92000088]
 bnx2 0000:05:00.1: NIC1: DEBUG: EMAC_TX_STATUS[00000008] EMAC_RX_STATUS[00000000]
 bnx2 0000:05:00.1: NIC1: DEBUG: RPM_MGMT_PKT_CTRL[40000088]
 bnx2 0000:05:00.1: NIC1: DEBUG: HC_STATS_INTERRUPT_STATUS[01ff0000]
 bnx2 0000:05:00.1: NIC1: DEBUG: PBA[00000000]
 bnx2 0000:05:00.1: NIC1: <--- start MCP states dump --->
 bnx2 0000:05:00.1: NIC1: DEBUG: MCP_STATE_P0[0003e10e] MCP_STATE_P1[0003e10e]
 bnx2 0000:05:00.1: NIC1: DEBUG: MCP mode[0000b800] state[80008000] evt_mask[00000500]
 bnx2 0000:05:00.1: NIC1: DEBUG: pc[08008f60] pc[0800d21c] instr[00051080]
 bnx2 0000:05:00.1: NIC1: DEBUG: shmem states:
 bnx2 0000:05:00.1: NIC1: DEBUG: drv_mb[01030003] fw_mb[00000003] link_status[0000006f] drv_pulse_mb[0000073d]
 bnx2 0000:05:00.1: NIC1: DEBUG: dev_info_signature[44564907] reset_type[01005254] condition[0003e10e]
 bnx2 0000:05:00.1: NIC1: DEBUG: 000003cc: 00000000 00000000 00000000 00000000
 bnx2 0000:05:00.1: NIC1: DEBUG: 000003dc: 00000000 00000000 00000000 00000000
 bnx2 0000:05:00.1: NIC1: DEBUG: 000003ec: 00000000 00000000 00000000 00000000
 bnx2 0000:05:00.1: NIC1: DEBUG: 0x3fc[00000000]
 bnx2 0000:05:00.1: NIC1: <--- end MCP states dump --->

^ permalink raw reply

* Re: [PATCH v4 3/8] net: can: c_can: Add RAMINIT register information to driver data
From: Roger Quadros @ 2014-11-17 11:29 UTC (permalink / raw)
  To: Marc Kleine-Budde, wg
  Cc: wsa, tony, tglx, mugunthanvnm, george.cherian, balbi, nsekhar, nm,
	sergei.shtylyov, linux-omap, linux-can, netdev
In-Reply-To: <5469DA69.7030602@pengutronix.de>

On 11/17/2014 01:22 PM, Marc Kleine-Budde wrote:
> On 11/17/2014 12:17 PM, Roger Quadros wrote:
>>> I'll send an updated series.
>>
>> Looks better. Thanks.
> 
> Can you make a quick test with the new series on real hardware.

Yes. I'll let you know in a while and respond on the v8 thread.

cheers,
-roger

^ permalink raw reply

* Re: [PATCH v4 3/8] net: can: c_can: Add RAMINIT register information to driver data
From: Marc Kleine-Budde @ 2014-11-17 11:22 UTC (permalink / raw)
  To: Roger Quadros, wg
  Cc: wsa, tony, tglx, mugunthanvnm, george.cherian, balbi, nsekhar, nm,
	sergei.shtylyov, linux-omap, linux-can, netdev
In-Reply-To: <5469D964.8020804@ti.com>

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

On 11/17/2014 12:17 PM, Roger Quadros wrote:
>> I'll send an updated series.
> 
> Looks better. Thanks.

Can you make a quick test with the new series on real hardware.

Thanks,
Marc

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


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

^ permalink raw reply

* Re: [PATCH v4 3/8] net: can: c_can: Add RAMINIT register information to driver data
From: Roger Quadros @ 2014-11-17 11:17 UTC (permalink / raw)
  To: Marc Kleine-Budde, wg
  Cc: wsa, tony, tglx, mugunthanvnm, george.cherian, balbi, nsekhar, nm,
	sergei.shtylyov, linux-omap, linux-can, netdev
In-Reply-To: <54664212.8080206@pengutronix.de>

On 11/14/2014 07:55 PM, Marc Kleine-Budde wrote:
> On 11/07/2014 03:49 PM, Roger Quadros wrote:
>> Some platforms (e.g. TI) need special RAMINIT register handling.
>> Provide a way to store RAMINIT register description in driver data.
>>
>> Signed-off-by: Roger Quadros <rogerq@ti.com>
>> ---
>>  drivers/net/can/c_can/c_can.h          | 6 ++++++
>>  drivers/net/can/c_can/c_can_platform.c | 1 +
>>  2 files changed, 7 insertions(+)
>>
>> diff --git a/drivers/net/can/c_can/c_can.h b/drivers/net/can/c_can/c_can.h
>> index 26c975d..3c305a1 100644
>> --- a/drivers/net/can/c_can/c_can.h
>> +++ b/drivers/net/can/c_can/c_can.h
>> @@ -171,6 +171,12 @@ enum c_can_dev_id {
>>  
>>  struct c_can_driver_data {
>>  	enum c_can_dev_id id;
>> +
>> +	/* RAMINIT register description. Optional. */
>> +	u8 num_can;		/* Number of CAN instances on the SoC */
>> +	u8 *raminit_start_bits;	/* Array of START bit positions */
>> +	u8 *raminit_done_bits;	/* Array of DONE bit positions */
> 
> What do you think about making this a struct:
> 
> +struct raminit_bits {
> +       u8 start;
> +       u8 done;
> +};
> 
>  struct c_can_driver_data {
>         enum c_can_dev_id id;
> +
> +       /* RAMINIT register description. Optional. */
> +       const struct raminit_bits *raminit_bits; /* Array of START/DONE bit positions */
> +       u8 raminit_num;         /* Number of CAN instances on the SoC */
> +       bool raminit_pulse;     /* If set, sets and clears START bit (pulse) */
>  };
> 
> The driver data looks like this:
> 
> +static const struct raminit_bits dra7_raminit_bits[] = {
> +       [0] = { .start = 3, .done = 1, },
> +       [1] = { .start = 5, .done = 2, },
> +};
> +
> +static const struct c_can_driver_data dra7_dcan_drvdata = {
> +       .id = BOSCH_D_CAN,
> +       .raminit_num = ARRAY_SIZE(dra7_raminit_bits),
> +       .raminit_bits = dra7_raminit_bits,
> +       .raminit_pulse = true,
> +};
> 
> I'll send an updated series.

Looks better. Thanks.

cheers,
-roger

^ permalink raw reply

* Investment and Management
From: Mrs.Suzanne Mubarak @ 2014-11-17  9:49 UTC (permalink / raw)



Mrs.Suzanne Mubarak
Email: famsuz_mubarak@draze.com
Address:34, Misr Helwan
Maadi,Cairo Egypt

http://www.bbc.co.uk/news/world-africa-13398644
http://www.bbc.co.uk/news/world-middle-east-25446660
http://www.bbc.co.uk/news/world-middle-east-23801010

Re: Investment and Management of 25 million united states.for my  
family in Abroad

N.B. All you need to do is to send your details-telephone,Full name  
and fax number to my lawyer Barrister Alex Thomas on email:
barralexthomas@outlook.com or telephone number+17862540754. He will be  
the one to give you details on the procedure to follow.

Yours faithfully,
MRS SUZANNE MUBARAK

^ permalink raw reply

* RE: [PATCH 0/8] net: fec: assorted cleanup patches
From: fugang.duan @ 2014-11-17 10:52 UTC (permalink / raw)
  To: Lothar Waßmann, David S. Miller
  Cc: netdev@vger.kernel.org, Frank.Li@freescale.com, Russell King
In-Reply-To: <1416217884-20911-1-git-send-email-LW@KARO-electronics.de>

From: Lothar Waßmann <LW@KARO-electronics.de> Sent: Monday, November 17, 2014 5:51 PM
>To: David S. Miller
>Cc: Lothar Waßmann; netdev@vger.kernel.org; Li Frank-B20596; Duan Fugang-
>B38611; Russell King
>Subject: [PATCH 0/8] net: fec: assorted cleanup patches
>
>This patch series is a followup to:
><1415350967-2238-1-git-send-email-LW@KARO-electronics.de>
>[PATCHv4 1/1] net: fec: fix regression on i.MX28 introduced by
>rx_copybreak support to apply the cleanup patches that were originally
>sent along with the bugfix patch.

Thanks for your code clean!

Acked-by: Fugang Duan <B38611@freescale.com>

Regards,
Andy

^ permalink raw reply

* Re: /proc/net/sockstat invalid memory accounting or memory leak in latest kernels? (trying to debug)
From: Denys Fedoryshchenko @ 2014-11-17 10:22 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: Neal Cardwell, Yuchung Cheng, netdev
In-Reply-To: <1416200496.24093.5.camel@edumazet-glaptop2.roam.corp.google.com>

On 2014-11-17 07:01, Eric Dumazet wrote:
> On Sun, 2014-11-16 at 12:16 -0800, Eric Dumazet wrote:
> 
>> Thanks Denys !
>> 
>> Could you try following patch ?
>> 
>> Thanks !
> 
> Hmm.... I have an updated patch, sorry.
> 
> (A memcpy_fromiovec() has to be memcpy_fromiovecend() )
> 
> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> index a3d453b94747..c2bbfcd9c0db 100644
> --- a/net/ipv4/tcp_output.c
> +++ b/net/ipv4/tcp_output.c
> @@ -2998,7 +2998,7 @@ static int tcp_send_syn_data(struct sock *sk,
> struct sk_buff *syn)
>  {
>  	struct tcp_sock *tp = tcp_sk(sk);
>  	struct tcp_fastopen_request *fo = tp->fastopen_req;
> -	int syn_loss = 0, space, i, err = 0, iovlen = fo->data->msg_iovlen;
> +	int syn_loss = 0, space, err = 0;
>  	struct sk_buff *syn_data = NULL, *data;
>  	unsigned long last_syn_loss = 0;
> 
> @@ -3031,25 +3031,19 @@ static int tcp_send_syn_data(struct sock *sk,
> struct sk_buff *syn)
>  	/* limit to order-0 allocations */
>  	space = min_t(size_t, space, SKB_MAX_HEAD(MAX_TCP_HEADER));
> 
> -	syn_data = skb_copy_expand(syn, MAX_TCP_HEADER, space,
> -				   sk->sk_allocation);
> -	if (syn_data == NULL)
> +	syn_data = sk_stream_alloc_skb(sk, space, sk->sk_allocation);
> +	if (!syn_data)
>  		goto fallback;
> 
> -	for (i = 0; i < iovlen && syn_data->len < space; ++i) {
> -		struct iovec *iov = &fo->data->msg_iov[i];
> -		unsigned char __user *from = iov->iov_base;
> -		int len = iov->iov_len;
> -
> -		if (syn_data->len + len > space)
> -			len = space - syn_data->len;
> -		else if (i + 1 == iovlen)
> -			/* No more data pending in inet_wait_for_connect() */
> -			fo->data = NULL;
> +	syn_data->ip_summed = CHECKSUM_PARTIAL;
> +	memcpy(syn_data->cb, syn->cb, sizeof(syn->cb));
> +	if (memcpy_fromiovecend(skb_put(syn_data, space),
> +				fo->data->msg_iov, 0, space))
> +		goto fallback;
> 
> -		if (skb_add_data(syn_data, from, len))
> -			goto fallback;
> -	}
> +	/* No more data pending in inet_wait_for_connect() */
> +	if (space == fo->size)
> +		fo->data = NULL;
> 
>  	/* Queue a data-only packet after the regular SYN for retransmission 
> */
>  	data = pskb_copy(syn_data, sk->sk_allocation);
> @@ -3101,13 +3095,10 @@ int tcp_connect(struct sock *sk)
>  		return 0;
>  	}
> 
> -	buff = alloc_skb_fclone(MAX_TCP_HEADER + 15, sk->sk_allocation);
> -	if (unlikely(buff == NULL))
> +	buff = sk_stream_alloc_skb(sk, 0, sk->sk_allocation);
> +	if (unlikely(!buff))
>  		return -ENOBUFS;
> 
> -	/* Reserve space for headers. */
> -	skb_reserve(buff, MAX_TCP_HEADER);
> -
>  	tcp_init_nondata_skb(buff, tp->write_seq++, TCPHDR_SYN);
>  	tp->retrans_stamp = tcp_time_stamp;
>  	tcp_connect_queue_skb(sk, buff);

Installed patch, but will have to wait a while (usually at least 
24hours), to be sure if it is stable.

Thanks a lot!

^ permalink raw reply

* [PATCH] net: team: expose sysfs attributes for each team option
From: Hamad Kadmany @ 2014-11-17 10:11 UTC (permalink / raw)
  To: jiri; +Cc: netdev

Current code provides only netlink API for user space
to read/write options. Exposing sysfs API is useful for
systems that don't have the required netlink
user space support.

Upon registration of team option, corresponding
sysfs attribute is created.

Signed-off-by: Hamad Kadmany <hkadmany@codeaurora.org>
---
 drivers/net/team/team.c | 282 ++++++++++++++++++++++++++++++++++++++++++++++--
 include/linux/if_team.h |   3 +
 2 files changed, 278 insertions(+), 7 deletions(-)

diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 1222229..afd2f8f 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -110,8 +110,198 @@ struct team_option_inst { /* One for each option instance */
 	struct team_option_inst_info info;
 	bool changed;
 	bool removed;
+	bool dev_attr_file_exist;
+	struct device_attribute dev_attr; /* corresponding sysfs attribute */
 };

+static struct attribute *team_sysfs_attrs[] = {
+	NULL,
+};
+
+static struct attribute_group team_sysfs_attr_group = {
+	.attrs = team_sysfs_attrs,
+};
+
+/* Device attributes (sysfs) */
+
+static ssize_t show_attribute(struct device *dev,
+			      struct device_attribute *attr,
+			      char *buf)
+{
+	struct team *team = dev_get_drvdata(dev);
+	struct team_option_inst *opt_inst;
+	ssize_t ret;
+	struct team_option *option;
+	struct team_gsetter_ctx ctx;
+
+	if (mutex_lock_interruptible(&team->lock))
+		return -ERESTARTSYS;
+
+	opt_inst = container_of(attr, struct team_option_inst, dev_attr);
+	option = opt_inst->option;
+	if (!option->getter) {
+		ret = -EOPNOTSUPP;
+		netdev_err(team->dev,
+			   "Option %s is write only\n", attr->attr.name);
+		goto exit;
+	}
+
+	ctx.info = &opt_inst->info;
+	/* let the option getter do its job */
+	ret = option->getter(team, &ctx);
+	if (ret)
+		goto exit;
+
+	/* translate option's output into sysfs output */
+	switch (option->type) {
+	case TEAM_OPTION_TYPE_U32:
+		ret = scnprintf(buf, PAGE_SIZE, "%u\n", ctx.data.u32_val);
+		break;
+	case TEAM_OPTION_TYPE_STRING:
+		ret = scnprintf(buf, PAGE_SIZE, "%s\n", ctx.data.str_val);
+		break;
+	case TEAM_OPTION_TYPE_BINARY:
+		if (ctx.data.bin_val.len > PAGE_SIZE) {
+			netdev_err(team->dev,
+				   "Option output is too long (%d)\n",
+				   ctx.data.bin_val.len);
+			break;
+		}
+
+		memcpy(buf, ctx.data.bin_val.ptr, ctx.data.bin_val.len);
+		ret = ctx.data.bin_val.len;
+		break;
+	case TEAM_OPTION_TYPE_BOOL:
+		ret = scnprintf(buf, PAGE_SIZE, "%d\n", ctx.data.bool_val);
+		break;
+	case TEAM_OPTION_TYPE_S32:
+		ret = scnprintf(buf, PAGE_SIZE, "%d\n", ctx.data.s32_val);
+		break;
+	default:
+		BUG();
+	}
+
+exit:
+	mutex_unlock(&team->lock);
+
+	return ret;
+}
+
+static int team_nl_send_event_options_get(struct team *team,
+					  struct list_head *sel_opt_inst_list);
+
+static ssize_t set_attribute(struct device *dev,
+			     struct device_attribute *attr,
+			     const char *buf, size_t count)
+{
+	struct team_option_inst *opt_inst;
+	struct team *team = dev_get_drvdata(dev);
+	int err = 0;
+	struct team_option *option = NULL;
+	struct team_gsetter_ctx ctx;
+
+	LIST_HEAD(opt_inst_list);
+
+	if (mutex_lock_interruptible(&team->lock))
+		return -ERESTARTSYS;
+
+	opt_inst = container_of(attr, struct team_option_inst, dev_attr);
+	option = opt_inst->option;
+	if (!option->setter) {
+		netdev_err(team->dev,
+			   "Option %s is read only\n", attr->attr.name);
+		err = -EOPNOTSUPP;
+		goto exit;
+	}
+
+	ctx.info = &opt_inst->info;
+
+	/* translate sysfs input into option's input */
+	switch (option->type) {
+	case TEAM_OPTION_TYPE_U32:
+		err = kstrtoint(buf, 0, &ctx.data.u32_val);
+		break;
+	case TEAM_OPTION_TYPE_STRING:
+		if (count > TEAM_STRING_MAX_LEN) {
+			netdev_err(team->dev,
+				   "Input buffer too long (%zu)\n", count);
+			err = -EINVAL;
+			break;
+		}
+		ctx.data.str_val = buf;
+		break;
+	case TEAM_OPTION_TYPE_BINARY:
+		ctx.data.bin_val.len = count;
+		ctx.data.bin_val.ptr = buf;
+		break;
+	case TEAM_OPTION_TYPE_BOOL:
+		err = strtobool(buf, &ctx.data.bool_val);
+		break;
+	case TEAM_OPTION_TYPE_S32:
+		err = kstrtoint(buf, 0, &ctx.data.s32_val);
+		break;
+	default:
+		BUG();
+	}
+
+	if (err) {
+		netdev_err(team->dev, "Failed to translate input buffer\n");
+		goto exit;
+	}
+
+	/* let the option setter do its job */
+	err = option->setter(team, &ctx);
+	if (err)
+		goto exit;
+
+	/* propagate option changed event */
+	opt_inst->changed = true;
+	list_add(&opt_inst->tmp_list, &opt_inst_list);
+	err = team_nl_send_event_options_get(team, &opt_inst_list);
+	if (err == -ESRCH) /* no listeners, not a real error */
+		err = 0;
+
+exit:
+	mutex_unlock(&team->lock);
+
+	if (!err)
+		err = count;
+	return err;
+}
+
+/* create sysfs attribute for each option that is being registered */
+static int __team_option_add_sysfs_attr(struct team *team,
+					struct team_option_inst *opt_inst,
+					bool create_sysfs_file)
+{
+	int err = 0;
+	struct device_attribute *new_dev_attr = &opt_inst->dev_attr;
+
+	new_dev_attr->attr.name = opt_inst->option->name;
+	new_dev_attr->attr.mode = S_IRUGO | S_IWUSR;
+	new_dev_attr->show = show_attribute;
+	new_dev_attr->store = set_attribute;
+
+	if (create_sysfs_file) {
+		err = sysfs_create_file(&team->dev->dev.kobj,
+					&new_dev_attr->attr);
+		if (err)
+			netdev_err(team->dev,
+				   "Failed to create sysfs attribute %s\n",
+				   new_dev_attr->attr.name);
+	}
+
+	return err;
+}
+
+static void __team_option_del_sysfs_attr(struct team *team,
+					 struct team_option_inst *opt_inst)
+{
+	if (opt_inst->dev_attr_file_exist)
+		sysfs_remove_file(&team->dev->dev.kobj,
+				  &opt_inst->dev_attr.attr);
+}
+
 static struct team_option *__team_find_option(struct team *team,
 					      const char *opt_name)
 {
@@ -124,8 +314,10 @@ static struct team_option *__team_find_option(struct team *team,
 	return NULL;
 }

-static void __team_option_inst_del(struct team_option_inst *opt_inst)
+static void __team_option_inst_del(struct team *team,
+				   struct team_option_inst *opt_inst)
 {
+	__team_option_del_sysfs_attr(team, opt_inst);
 	list_del(&opt_inst->list);
 	kfree(opt_inst);
 }
@@ -137,7 +329,7 @@ static void __team_option_inst_del_option(struct team *team,

 	list_for_each_entry_safe(opt_inst, tmp, &team->option_inst_list, list) {
 		if (opt_inst->option == option)
-			__team_option_inst_del(opt_inst);
+			__team_option_inst_del(team, opt_inst);
 	}
 }

@@ -162,6 +354,7 @@ static int __team_option_inst_add(struct team *team, struct team_option *option,
 		opt_inst->info.array_index = i;
 		opt_inst->changed = true;
 		opt_inst->removed = false;
+		opt_inst->dev_attr_file_exist = false;
 		list_add_tail(&opt_inst->list, &team->option_inst_list);
 		if (option->init) {
 			err = option->init(team, &opt_inst->info);
@@ -170,6 +363,20 @@ static int __team_option_inst_add(struct team *team, struct team_option *option,
 		}

 	}
+
+	/* add sysfs attribute. per-port and array options are skipped */
+	if (!option->per_port && !option->array_size) {
+		/* create the sysfs file only if our state allows it */
+		bool create_sysfs_file = device_is_registered(&team->dev->dev);
+
+		err = __team_option_add_sysfs_attr(team, opt_inst,
+						   create_sysfs_file);
+		if (err)
+			return err;
+
+		opt_inst->dev_attr_file_exist = true;
+	}
+
 	return 0;
 }

@@ -218,7 +425,7 @@ static void __team_option_inst_del_port(struct team *team,
 	list_for_each_entry_safe(opt_inst, tmp, &team->option_inst_list, list) {
 		if (opt_inst->option->per_port &&
 		    opt_inst->info.port == port)
-			__team_option_inst_del(opt_inst);
+			__team_option_inst_del(team, opt_inst);
 	}
 }

@@ -337,6 +544,51 @@ static void __team_options_unregister(struct team *team,

 static void __team_options_change_check(struct team *team);

+static void team_attr_grp_free(struct team *team)
+{
+	kfree(team->attr_grp.attrs);
+}
+
+/* allocate attribute group for creating sysfs for team's own options */
+static int team_attr_grp_alloc(struct team *team)
+{
+	struct attribute **attributes;
+	struct team_option_inst *opt_inst;
+	int num_attr = 0;
+	struct team_option *option;
+
+	list_for_each_entry(opt_inst, &team->option_inst_list, list) {
+		option = opt_inst->option;
+		/* per-port and array options currently not supported as
+		 * sysfs attributes
+		 */
+		if (option->per_port || option->array_size)
+			continue;
+
+		num_attr++;
+	}
+
+	/* +1 for having NULL as last item in the array */
+	attributes = kzalloc((num_attr + 1) * sizeof(*attributes), GFP_KERNEL);
+	if (!attributes)
+		return -ENOMEM;
+	team->attr_grp.attrs = attributes;
+
+	num_attr = 0;
+	list_for_each_entry(opt_inst, &team->option_inst_list, list) {
+		option = opt_inst->option;
+		/* per-port and array options currently not supported as
+		 * sysfs attributes
+		 */
+		if (option->per_port || option->array_size)
+			continue;
+
+		attributes[num_attr++] = &opt_inst->dev_attr.attr;
+	}
+
+	return 0;
+}
+
 int team_options_register(struct team *team,
 			  const struct team_option *option,
 			  size_t option_count)
@@ -1380,15 +1632,28 @@ static int team_init(struct net_device *dev)

 	INIT_LIST_HEAD(&team->option_list);
 	INIT_LIST_HEAD(&team->option_inst_list);
-	err = team_options_register(team, team_options, ARRAY_SIZE(team_options));
+
+	err = team_options_register(team, team_options,
+				    ARRAY_SIZE(team_options));
 	if (err)
 		goto err_options_register;
 	netif_carrier_off(dev);

 	team_set_lockdep_class(dev);

+	/* store team context, to be used by Device attributes getter/setter */
+	dev_set_drvdata(&dev->dev, team);
+
+	/* allocate and register sysfs attributes for team's own options */
+	err = team_attr_grp_alloc(team);
+	if (err)
+		goto err_grp_alloc;
+	dev->sysfs_groups[0] = &team->attr_grp;
+
 	return 0;

+err_grp_alloc:
+	team_options_unregister(team, team_options, ARRAY_SIZE(team_options));
 err_options_register:
 	team_queue_override_fini(team);
 err_team_queue_override_init:
@@ -1407,9 +1672,15 @@ static void team_uninit(struct net_device *dev)
 	list_for_each_entry_safe(port, tmp, &team->port_list, list)
 		team_port_del(team, port->dev);

+	sysfs_remove_group(&team->dev->dev.kobj, &team->attr_grp);
+	team_attr_grp_free(team);
+	/* set to dummy group to avoid double free by core */
+	dev->sysfs_groups[0] = &team_sysfs_attr_group;
+
 	__team_change_mode(team, NULL); /* cleanup */
 	__team_options_unregister(team, team_options, ARRAY_SIZE(team_options));
 	team_queue_override_fini(team);
+
 	mutex_unlock(&team->lock);
 }

@@ -2194,9 +2465,6 @@ static int team_nl_cmd_options_get(struct sk_buff *skb, struct genl_info *info)
 	return err;
 }

-static int team_nl_send_event_options_get(struct team *team,
-					  struct list_head *sel_opt_inst_list);
-
 static int team_nl_cmd_options_set(struct sk_buff *skb, struct genl_info *info)
 {
 	struct team *team;
diff --git a/include/linux/if_team.h b/include/linux/if_team.h
index 25b8b15..2e9fb2a 100644
--- a/include/linux/if_team.h
+++ b/include/linux/if_team.h
@@ -188,6 +188,9 @@ struct team {
 	struct list_head option_list;
 	struct list_head option_inst_list; /* list of option instances */

+	/* attribute group for registering team's own options at init */
+	struct attribute_group attr_grp;
+
 	const struct team_mode *mode;
 	struct team_mode_ops ops;
 	bool user_carrier_enabled;
-- 
1.8.5.2
-- 
Qualcomm Israel, on behalf of Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply related

* [PATCH 0/8] net: fec: assorted cleanup patches
From: Lothar Waßmann @ 2014-11-17  9:51 UTC (permalink / raw)
  To: David S. Miller
  Cc: Lothar Waßmann, netdev, Frank Li, Fugang Duan, Russell King

This patch series is a followup to:
<1415350967-2238-1-git-send-email-LW@KARO-electronics.de>
[PATCHv4 1/1] net: fec: fix regression on i.MX28 introduced by rx_copybreak support
to apply the cleanup patches that were originally sent along with the
bugfix patch.

^ permalink raw reply

* [PATCH 7/8] net: fec: simplify loop counter handling in swap_buffer()
From: Lothar Waßmann @ 2014-11-17  9:51 UTC (permalink / raw)
  To: David S. Miller
  Cc: Lothar Waßmann, netdev, Frank Li, Fugang Duan, Russell King
In-Reply-To: <1416217884-20911-1-git-send-email-LW@KARO-electronics.de>

Eliminate the DIV_ROUND_UP() and change the loop counter increment to
4 instead. This results in saving 6 instructions in the functions
assembly code.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
 drivers/net/ethernet/freescale/fec_main.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index f73fee7..dbccdf3 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -292,7 +292,7 @@ static void *swap_buffer(void *bufaddr, int len)
 	int i;
 	unsigned int *buf = bufaddr;
 
-	for (i = 0; i < DIV_ROUND_UP(len, 4); i++, buf++)
+	for (i = 0; i < len; i += 4, buf++)
 		swab32s(buf);
 
 	return bufaddr;
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 8/8] net: fec: remove unused return value from swap_buffer()
From: Lothar Waßmann @ 2014-11-17  9:51 UTC (permalink / raw)
  To: David S. Miller
  Cc: Lothar Waßmann, netdev, Frank Li, Fugang Duan, Russell King
In-Reply-To: <1416217884-20911-1-git-send-email-LW@KARO-electronics.de>

The return value of swap_buffer() is not used by any caller, thus
remove it.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
 drivers/net/ethernet/freescale/fec_main.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index dbccdf3..1b6d26b 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -287,15 +287,13 @@ static int fec_enet_get_free_txdesc_num(struct fec_enet_private *fep,
 	return entries > 0 ? entries : entries + txq->tx_ring_size;
 }
 
-static void *swap_buffer(void *bufaddr, int len)
+static void swap_buffer(void *bufaddr, int len)
 {
 	int i;
 	unsigned int *buf = bufaddr;
 
 	for (i = 0; i < len; i += 4, buf++)
 		swab32s(buf);
-
-	return bufaddr;
 }
 
 static void swap_buffer2(void *dst_buf, void *src_buf, int len)
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 2/8] net: fec: consistently use lower case chars as hex digits
From: Lothar Waßmann @ 2014-11-17  9:51 UTC (permalink / raw)
  To: David S. Miller
  Cc: Lothar Waßmann, netdev, Frank Li, Fugang Duan, Russell King
In-Reply-To: <1416217884-20911-1-git-send-email-LW@KARO-electronics.de>


Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
 drivers/net/ethernet/freescale/fec.h |   88 +++++++++++++++++-----------------
 1 file changed, 44 insertions(+), 44 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index 3047db4..e778b9e 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -38,9 +38,9 @@
 #define FEC_ADDR_LOW		0x0e4 /* Low 32bits MAC address */
 #define FEC_ADDR_HIGH		0x0e8 /* High 16bits MAC address */
 #define FEC_OPD			0x0ec /* Opcode + Pause duration */
-#define FEC_TXIC0		0xF0  /* Tx Interrupt Coalescing for ring 0 */
-#define FEC_TXIC1		0xF4  /* Tx Interrupt Coalescing for ring 1 */
-#define FEC_TXIC2		0xF8  /* Tx Interrupt Coalescing for ring 2 */
+#define FEC_TXIC0		0x0f0 /* Tx Interrupt Coalescing for ring 0 */
+#define FEC_TXIC1		0x0f4 /* Tx Interrupt Coalescing for ring 1 */
+#define FEC_TXIC2		0x0f8 /* Tx Interrupt Coalescing for ring 2 */
 #define FEC_RXIC0		0x100 /* Rx Interrupt Coalescing for ring 0 */
 #define FEC_RXIC1		0x104 /* Rx Interrupt Coalescing for ring 1 */
 #define FEC_RXIC2		0x108 /* Rx Interrupt Coalescing for ring 2 */
@@ -62,7 +62,7 @@
 #define FEC_R_FIFO_RSEM		0x194 /* Receive FIFO section empty threshold */
 #define FEC_R_FIFO_RAEM		0x198 /* Receive FIFO almost empty threshold */
 #define FEC_R_FIFO_RAFL		0x19c /* Receive FIFO almost full threshold */
-#define FEC_RACC		0x1C4 /* Receive Accelerator function */
+#define FEC_RACC		0x1c4 /* Receive Accelerator function */
 #define FEC_RCMR_1		0x1c8 /* Receive classification match ring 1 */
 #define FEC_RCMR_2		0x1cc /* Receive classification match ring 2 */
 #define FEC_DMA_CFG_1		0x1d8 /* DMA class configuration for ring 1 */
@@ -82,57 +82,57 @@
 #define RMON_T_DROP		0x200 /* Count of frames not cntd correctly */
 #define RMON_T_PACKETS		0x204 /* RMON TX packet count */
 #define RMON_T_BC_PKT		0x208 /* RMON TX broadcast pkts */
-#define RMON_T_MC_PKT		0x20C /* RMON TX multicast pkts */
+#define RMON_T_MC_PKT		0x20c /* RMON TX multicast pkts */
 #define RMON_T_CRC_ALIGN	0x210 /* RMON TX pkts with CRC align err */
 #define RMON_T_UNDERSIZE	0x214 /* RMON TX pkts < 64 bytes, good CRC */
 #define RMON_T_OVERSIZE		0x218 /* RMON TX pkts > MAX_FL bytes good CRC */
-#define RMON_T_FRAG		0x21C /* RMON TX pkts < 64 bytes, bad CRC */
+#define RMON_T_FRAG		0x21c /* RMON TX pkts < 64 bytes, bad CRC */
 #define RMON_T_JAB		0x220 /* RMON TX pkts > MAX_FL bytes, bad CRC */
 #define RMON_T_COL		0x224 /* RMON TX collision count */
 #define RMON_T_P64		0x228 /* RMON TX 64 byte pkts */
-#define RMON_T_P65TO127		0x22C /* RMON TX 65 to 127 byte pkts */
+#define RMON_T_P65TO127		0x22c /* RMON TX 65 to 127 byte pkts */
 #define RMON_T_P128TO255	0x230 /* RMON TX 128 to 255 byte pkts */
 #define RMON_T_P256TO511	0x234 /* RMON TX 256 to 511 byte pkts */
 #define RMON_T_P512TO1023	0x238 /* RMON TX 512 to 1023 byte pkts */
-#define RMON_T_P1024TO2047	0x23C /* RMON TX 1024 to 2047 byte pkts */
+#define RMON_T_P1024TO2047	0x23c /* RMON TX 1024 to 2047 byte pkts */
 #define RMON_T_P_GTE2048	0x240 /* RMON TX pkts > 2048 bytes */
 #define RMON_T_OCTETS		0x244 /* RMON TX octets */
 #define IEEE_T_DROP		0x248 /* Count of frames not counted crtly */
-#define IEEE_T_FRAME_OK		0x24C /* Frames tx'd OK */
+#define IEEE_T_FRAME_OK		0x24c /* Frames tx'd OK */
 #define IEEE_T_1COL		0x250 /* Frames tx'd with single collision */
 #define IEEE_T_MCOL		0x254 /* Frames tx'd with multiple collision */
 #define IEEE_T_DEF		0x258 /* Frames tx'd after deferral delay */
-#define IEEE_T_LCOL		0x25C /* Frames tx'd with late collision */
+#define IEEE_T_LCOL		0x25c /* Frames tx'd with late collision */
 #define IEEE_T_EXCOL		0x260 /* Frames tx'd with excesv collisions */
 #define IEEE_T_MACERR		0x264 /* Frames tx'd with TX FIFO underrun */
 #define IEEE_T_CSERR		0x268 /* Frames tx'd with carrier sense err */
-#define IEEE_T_SQE		0x26C /* Frames tx'd with SQE err */
+#define IEEE_T_SQE		0x26c /* Frames tx'd with SQE err */
 #define IEEE_T_FDXFC		0x270 /* Flow control pause frames tx'd */
 #define IEEE_T_OCTETS_OK	0x274 /* Octet count for frames tx'd w/o err */
 #define RMON_R_PACKETS		0x284 /* RMON RX packet count */
 #define RMON_R_BC_PKT		0x288 /* RMON RX broadcast pkts */
-#define RMON_R_MC_PKT		0x28C /* RMON RX multicast pkts */
+#define RMON_R_MC_PKT		0x28c /* RMON RX multicast pkts */
 #define RMON_R_CRC_ALIGN	0x290 /* RMON RX pkts with CRC alignment err */
 #define RMON_R_UNDERSIZE	0x294 /* RMON RX pkts < 64 bytes, good CRC */
 #define RMON_R_OVERSIZE		0x298 /* RMON RX pkts > MAX_FL bytes good CRC */
-#define RMON_R_FRAG		0x29C /* RMON RX pkts < 64 bytes, bad CRC */
-#define RMON_R_JAB		0x2A0 /* RMON RX pkts > MAX_FL bytes, bad CRC */
-#define RMON_R_RESVD_O		0x2A4 /* Reserved */
-#define RMON_R_P64		0x2A8 /* RMON RX 64 byte pkts */
-#define RMON_R_P65TO127		0x2AC /* RMON RX 65 to 127 byte pkts */
-#define RMON_R_P128TO255	0x2B0 /* RMON RX 128 to 255 byte pkts */
-#define RMON_R_P256TO511	0x2B4 /* RMON RX 256 to 511 byte pkts */
-#define RMON_R_P512TO1023	0x2B8 /* RMON RX 512 to 1023 byte pkts */
-#define RMON_R_P1024TO2047	0x2BC /* RMON RX 1024 to 2047 byte pkts */
-#define RMON_R_P_GTE2048	0x2C0 /* RMON RX pkts > 2048 bytes */
-#define RMON_R_OCTETS		0x2C4 /* RMON RX octets */
-#define IEEE_R_DROP		0x2C8 /* Count frames not counted correctly */
-#define IEEE_R_FRAME_OK		0x2CC /* Frames rx'd OK */
-#define IEEE_R_CRC		0x2D0 /* Frames rx'd with CRC err */
-#define IEEE_R_ALIGN		0x2D4 /* Frames rx'd with alignment err */
-#define IEEE_R_MACERR		0x2D8 /* Receive FIFO overflow count */
-#define IEEE_R_FDXFC		0x2DC /* Flow control pause frames rx'd */
-#define IEEE_R_OCTETS_OK	0x2E0 /* Octet cnt for frames rx'd w/o err */
+#define RMON_R_FRAG		0x29c /* RMON RX pkts < 64 bytes, bad CRC */
+#define RMON_R_JAB		0x2a0 /* RMON RX pkts > MAX_FL bytes, bad CRC */
+#define RMON_R_RESVD_O		0x2a4 /* Reserved */
+#define RMON_R_P64		0x2a8 /* RMON RX 64 byte pkts */
+#define RMON_R_P65TO127		0x2ac /* RMON RX 65 to 127 byte pkts */
+#define RMON_R_P128TO255	0x2b0 /* RMON RX 128 to 255 byte pkts */
+#define RMON_R_P256TO511	0x2b4 /* RMON RX 256 to 511 byte pkts */
+#define RMON_R_P512TO1023	0x2b8 /* RMON RX 512 to 1023 byte pkts */
+#define RMON_R_P1024TO2047	0x2bc /* RMON RX 1024 to 2047 byte pkts */
+#define RMON_R_P_GTE2048	0x2c0 /* RMON RX pkts > 2048 bytes */
+#define RMON_R_OCTETS		0x2c4 /* RMON RX octets */
+#define IEEE_R_DROP		0x2c8 /* Count frames not counted correctly */
+#define IEEE_R_FRAME_OK		0x2cc /* Frames rx'd OK */
+#define IEEE_R_CRC		0x2d0 /* Frames rx'd with CRC err */
+#define IEEE_R_ALIGN		0x2d4 /* Frames rx'd with alignment err */
+#define IEEE_R_MACERR		0x2d8 /* Receive FIFO overflow count */
+#define IEEE_R_FDXFC		0x2dc /* Flow control pause frames rx'd */
+#define IEEE_R_OCTETS_OK	0x2e0 /* Octet cnt for frames rx'd w/o err */
 
 #else
 
@@ -170,16 +170,16 @@
 /* Not existed in real chip
  * Just for pass build.
  */
-#define FEC_RCMR_1		0xFFF
-#define FEC_RCMR_2		0xFFF
-#define FEC_DMA_CFG_1		0xFFF
-#define FEC_DMA_CFG_2		0xFFF
-#define FEC_TXIC0		0xFFF
-#define FEC_TXIC1		0xFFF
-#define FEC_TXIC2		0xFFF
-#define FEC_RXIC0		0xFFF
-#define FEC_RXIC1		0xFFF
-#define FEC_RXIC2		0xFFF
+#define FEC_RCMR_1		0xfff
+#define FEC_RCMR_2		0xfff
+#define FEC_DMA_CFG_1		0xfff
+#define FEC_DMA_CFG_2		0xfff
+#define FEC_TXIC0		0xfff
+#define FEC_TXIC1		0xfff
+#define FEC_TXIC2		0xfff
+#define FEC_RXIC0		0xfff
+#define FEC_RXIC1		0xfff
+#define FEC_RXIC2		0xfff
 #endif /* CONFIG_M5272 */
 
 
@@ -296,7 +296,7 @@ struct bufdesc_ex {
 
 #define DMA_CLASS_EN		(1 << 16)
 #define FEC_RCMR(X)		((X == 2) ? FEC_RCMR_2 : FEC_RCMR_1)
-#define IDLE_SLOPE_MASK		0xFFFF
+#define IDLE_SLOPE_MASK		0xffff
 #define IDLE_SLOPE_1		0x200 /* BW fraction: 0.5 */
 #define IDLE_SLOPE_2		0x200 /* BW fraction: 0.5 */
 #define IDLE_SLOPE(X)		((X == 1) ? (IDLE_SLOPE_1 & IDLE_SLOPE_MASK) : \
@@ -308,7 +308,7 @@ struct bufdesc_ex {
 #define RCMR_CMP_2		(RCMR_CMP_CFG(4, 0) | RCMR_CMP_CFG(5, 1) | \
 				RCMR_CMP_CFG(6, 2) | RCMR_CMP_CFG(7, 3))
 #define RCMR_CMP(X)		((X == 1) ? RCMR_CMP_1 : RCMR_CMP_2)
-#define FEC_TX_BD_FTYPE(X)	((X & 0xF) << 20)
+#define FEC_TX_BD_FTYPE(X)	((X & 0xf) << 20)
 
 /* The number of Tx and Rx buffers.  These are allocated from the page
  * pool.  The code may assume these are power of two, so it it best
@@ -359,8 +359,8 @@ struct bufdesc_ex {
 /* ENET interrupt coalescing macro define */
 #define FEC_ITR_CLK_SEL		(0x1 << 30)
 #define FEC_ITR_EN		(0x1 << 31)
-#define FEC_ITR_ICFT(X)		((X & 0xFF) << 20)
-#define FEC_ITR_ICTT(X)		((X) & 0xFFFF)
+#define FEC_ITR_ICFT(X)		((X & 0xff) << 20)
+#define FEC_ITR_ICTT(X)		((X) & 0xffff)
 #define FEC_ITR_ICFT_DEFAULT	200  /* Set 200 frame count threshold */
 #define FEC_ITR_ICTT_DEFAULT	1000 /* Set 1000us timer threshold */
 
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 5/8] net: fec: improve access to quirk flags by copying them into fec_enet_private struct
From: Lothar Waßmann @ 2014-11-17  9:51 UTC (permalink / raw)
  To: David S. Miller
  Cc: Lothar Waßmann, netdev, Frank Li, Fugang Duan, Russell King
In-Reply-To: <1416217884-20911-1-git-send-email-LW@KARO-electronics.de>


Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
 drivers/net/ethernet/freescale/fec.h      |    1 +
 drivers/net/ethernet/freescale/fec_main.c |  106 +++++++++++------------------
 2 files changed, 39 insertions(+), 68 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index 1418813..7aa9388 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -504,6 +504,7 @@ struct fec_enet_private {
 	int	irq[FEC_IRQ_NUM];
 	bool	bufdesc_ex;
 	int	pause_flag;
+	u32	quirks;
 
 	struct	napi_struct napi;
 	int	csum_flags;
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index f3a6379..3884dd9 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -361,8 +361,6 @@ fec_enet_txq_submit_frag_skb(struct fec_enet_priv_tx_q *txq,
 			     struct net_device *ndev)
 {
 	struct fec_enet_private *fep = netdev_priv(ndev);
-	const struct platform_device_id *id_entry =
-				platform_get_device_id(fep->pdev);
 	struct bufdesc *bdp = txq->cur_tx;
 	struct bufdesc_ex *ebdp;
 	int nr_frags = skb_shinfo(skb)->nr_frags;
@@ -398,7 +396,7 @@ fec_enet_txq_submit_frag_skb(struct fec_enet_priv_tx_q *txq,
 		}
 
 		if (fep->bufdesc_ex) {
-			if (id_entry->driver_data & FEC_QUIRK_HAS_AVB)
+			if (fep->quirks & FEC_QUIRK_HAS_AVB)
 				estatus |= FEC_TX_BD_FTYPE(queue);
 			if (skb->ip_summed == CHECKSUM_PARTIAL)
 				estatus |= BD_ENET_TX_PINS | BD_ENET_TX_IINS;
@@ -410,11 +408,11 @@ fec_enet_txq_submit_frag_skb(struct fec_enet_priv_tx_q *txq,
 
 		index = fec_enet_get_bd_index(txq->tx_bd_base, bdp, fep);
 		if (((unsigned long) bufaddr) & fep->tx_align ||
-			id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) {
+			fep->quirks & FEC_QUIRK_SWAP_FRAME) {
 			memcpy(txq->tx_bounce[index], bufaddr, frag_len);
 			bufaddr = txq->tx_bounce[index];
 
-			if (id_entry->driver_data & FEC_QUIRK_SWAP_FRAME)
+			if (fep->quirks & FEC_QUIRK_SWAP_FRAME)
 				swap_buffer(bufaddr, frag_len);
 		}
 
@@ -450,8 +448,6 @@ static int fec_enet_txq_submit_skb(struct fec_enet_priv_tx_q *txq,
 				   struct sk_buff *skb, struct net_device *ndev)
 {
 	struct fec_enet_private *fep = netdev_priv(ndev);
-	const struct platform_device_id *id_entry =
-				platform_get_device_id(fep->pdev);
 	int nr_frags = skb_shinfo(skb)->nr_frags;
 	struct bufdesc *bdp, *last_bdp;
 	void *bufaddr;
@@ -490,11 +486,11 @@ static int fec_enet_txq_submit_skb(struct fec_enet_priv_tx_q *txq,
 	queue = skb_get_queue_mapping(skb);
 	index = fec_enet_get_bd_index(txq->tx_bd_base, bdp, fep);
 	if (((unsigned long) bufaddr) & fep->tx_align ||
-		id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) {
+		fep->quirks & FEC_QUIRK_SWAP_FRAME) {
 		memcpy(txq->tx_bounce[index], skb->data, buflen);
 		bufaddr = txq->tx_bounce[index];
 
-		if (id_entry->driver_data & FEC_QUIRK_SWAP_FRAME)
+		if (fep->quirks & FEC_QUIRK_SWAP_FRAME)
 			swap_buffer(bufaddr, buflen);
 	}
 
@@ -529,7 +525,7 @@ static int fec_enet_txq_submit_skb(struct fec_enet_priv_tx_q *txq,
 			fep->hwts_tx_en))
 			skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
 
-		if (id_entry->driver_data & FEC_QUIRK_HAS_AVB)
+		if (fep->quirks & FEC_QUIRK_HAS_AVB)
 			estatus |= FEC_TX_BD_FTYPE(queue);
 
 		if (skb->ip_summed == CHECKSUM_PARTIAL)
@@ -573,8 +569,6 @@ fec_enet_txq_put_data_tso(struct fec_enet_priv_tx_q *txq, struct sk_buff *skb,
 			  int size, bool last_tcp, bool is_last)
 {
 	struct fec_enet_private *fep = netdev_priv(ndev);
-	const struct platform_device_id *id_entry =
-				platform_get_device_id(fep->pdev);
 	struct bufdesc_ex *ebdp = container_of(bdp, struct bufdesc_ex, desc);
 	unsigned short queue = skb_get_queue_mapping(skb);
 	unsigned short status;
@@ -587,11 +581,11 @@ fec_enet_txq_put_data_tso(struct fec_enet_priv_tx_q *txq, struct sk_buff *skb,
 	status |= (BD_ENET_TX_TC | BD_ENET_TX_READY);
 
 	if (((unsigned long) data) & fep->tx_align ||
-		id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) {
+		fep->quirks & FEC_QUIRK_SWAP_FRAME) {
 		memcpy(txq->tx_bounce[index], data, size);
 		data = txq->tx_bounce[index];
 
-		if (id_entry->driver_data & FEC_QUIRK_SWAP_FRAME)
+		if (fep->quirks & FEC_QUIRK_SWAP_FRAME)
 			swap_buffer(data, size);
 	}
 
@@ -607,7 +601,7 @@ fec_enet_txq_put_data_tso(struct fec_enet_priv_tx_q *txq, struct sk_buff *skb,
 	bdp->cbd_bufaddr = addr;
 
 	if (fep->bufdesc_ex) {
-		if (id_entry->driver_data & FEC_QUIRK_HAS_AVB)
+		if (fep->quirks & FEC_QUIRK_HAS_AVB)
 			estatus |= FEC_TX_BD_FTYPE(queue);
 		if (skb->ip_summed == CHECKSUM_PARTIAL)
 			estatus |= BD_ENET_TX_PINS | BD_ENET_TX_IINS;
@@ -635,8 +629,6 @@ fec_enet_txq_put_hdr_tso(struct fec_enet_priv_tx_q *txq,
 			 struct bufdesc *bdp, int index)
 {
 	struct fec_enet_private *fep = netdev_priv(ndev);
-	const struct platform_device_id *id_entry =
-				platform_get_device_id(fep->pdev);
 	int hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
 	struct bufdesc_ex *ebdp = container_of(bdp, struct bufdesc_ex, desc);
 	unsigned short queue = skb_get_queue_mapping(skb);
@@ -652,11 +644,11 @@ fec_enet_txq_put_hdr_tso(struct fec_enet_priv_tx_q *txq,
 	bufaddr = txq->tso_hdrs + index * TSO_HEADER_SIZE;
 	dmabuf = txq->tso_hdrs_dma + index * TSO_HEADER_SIZE;
 	if (((unsigned long)bufaddr) & fep->tx_align ||
-		id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) {
+		fep->quirks & FEC_QUIRK_SWAP_FRAME) {
 		memcpy(txq->tx_bounce[index], skb->data, hdr_len);
 		bufaddr = txq->tx_bounce[index];
 
-		if (id_entry->driver_data & FEC_QUIRK_SWAP_FRAME)
+		if (fep->quirks & FEC_QUIRK_SWAP_FRAME)
 			swap_buffer(bufaddr, hdr_len);
 
 		dmabuf = dma_map_single(&fep->pdev->dev, bufaddr,
@@ -673,7 +665,7 @@ fec_enet_txq_put_hdr_tso(struct fec_enet_priv_tx_q *txq,
 	bdp->cbd_datlen = hdr_len;
 
 	if (fep->bufdesc_ex) {
-		if (id_entry->driver_data & FEC_QUIRK_HAS_AVB)
+		if (fep->quirks & FEC_QUIRK_HAS_AVB)
 			estatus |= FEC_TX_BD_FTYPE(queue);
 		if (skb->ip_summed == CHECKSUM_PARTIAL)
 			estatus |= BD_ENET_TX_PINS | BD_ENET_TX_IINS;
@@ -698,8 +690,6 @@ static int fec_enet_txq_submit_tso(struct fec_enet_priv_tx_q *txq,
 	struct tso_t tso;
 	unsigned int index = 0;
 	int ret;
-	const struct platform_device_id *id_entry =
-				platform_get_device_id(fep->pdev);
 
 	if (tso_count_descs(skb) >= fec_enet_get_free_txdesc_num(fep, txq)) {
 		dev_kfree_skb_any(skb);
@@ -761,7 +751,7 @@ static int fec_enet_txq_submit_tso(struct fec_enet_priv_tx_q *txq,
 	txq->cur_tx = bdp;
 
 	/* Trigger transmission start */
-	if (!(id_entry->driver_data & FEC_QUIRK_ERR007885) ||
+	if (!(fep->quirks & FEC_QUIRK_ERR007885) ||
 	    !readl(fep->hwp + FEC_X_DES_ACTIVE(queue)) ||
 	    !readl(fep->hwp + FEC_X_DES_ACTIVE(queue)) ||
 	    !readl(fep->hwp + FEC_X_DES_ACTIVE(queue)) ||
@@ -924,8 +914,6 @@ static void
 fec_restart(struct net_device *ndev)
 {
 	struct fec_enet_private *fep = netdev_priv(ndev);
-	const struct platform_device_id *id_entry =
-				platform_get_device_id(fep->pdev);
 	u32 val;
 	u32 temp_mac[2];
 	u32 rcntl = OPT_FRAME_SIZE | 0x04;
@@ -935,7 +923,7 @@ fec_restart(struct net_device *ndev)
 	 * For i.MX6SX SOC, enet use AXI bus, we use disable MAC
 	 * instead of reset MAC itself.
 	 */
-	if (id_entry && id_entry->driver_data & FEC_QUIRK_HAS_AVB) {
+	if (fep->quirks & FEC_QUIRK_HAS_AVB) {
 		writel(0, fep->hwp + FEC_ECNTRL);
 	} else {
 		writel(1, fep->hwp + FEC_ECNTRL);
@@ -946,7 +934,7 @@ fec_restart(struct net_device *ndev)
 	 * enet-mac reset will reset mac address registers too,
 	 * so need to reconfigure it.
 	 */
-	if (id_entry->driver_data & FEC_QUIRK_ENET_MAC) {
+	if (fep->quirks & FEC_QUIRK_ENET_MAC) {
 		memcpy(&temp_mac, ndev->dev_addr, ETH_ALEN);
 		writel(cpu_to_be32(temp_mac[0]), fep->hwp + FEC_ADDR_LOW);
 		writel(cpu_to_be32(temp_mac[1]), fep->hwp + FEC_ADDR_HIGH);
@@ -992,7 +980,7 @@ fec_restart(struct net_device *ndev)
 	 * The phy interface and speed need to get configured
 	 * differently on enet-mac.
 	 */
-	if (id_entry->driver_data & FEC_QUIRK_ENET_MAC) {
+	if (fep->quirks & FEC_QUIRK_ENET_MAC) {
 		/* Enable flow control and length check */
 		rcntl |= 0x40000000 | 0x00000020;
 
@@ -1015,7 +1003,7 @@ fec_restart(struct net_device *ndev)
 		}
 	} else {
 #ifdef FEC_MIIGSK_ENR
-		if (id_entry->driver_data & FEC_QUIRK_USE_GASKET) {
+		if (fep->quirks & FEC_QUIRK_USE_GASKET) {
 			u32 cfgr;
 			/* disable the gasket and wait */
 			writel(0, fep->hwp + FEC_MIIGSK_ENR);
@@ -1068,7 +1056,7 @@ fec_restart(struct net_device *ndev)
 	writel(0, fep->hwp + FEC_HASH_TABLE_LOW);
 #endif
 
-	if (id_entry->driver_data & FEC_QUIRK_ENET_MAC) {
+	if (fep->quirks & FEC_QUIRK_ENET_MAC) {
 		/* enable ENET endian swap */
 		ecntl |= (1 << 8);
 		/* enable ENET store and forward mode */
@@ -1102,8 +1090,6 @@ static void
 fec_stop(struct net_device *ndev)
 {
 	struct fec_enet_private *fep = netdev_priv(ndev);
-	const struct platform_device_id *id_entry =
-				platform_get_device_id(fep->pdev);
 	u32 rmii_mode = readl(fep->hwp + FEC_R_CNTRL) & (1 << 8);
 
 	/* We cannot expect a graceful transmit stop without link !!! */
@@ -1118,7 +1104,7 @@ fec_stop(struct net_device *ndev)
 	 * For i.MX6SX SOC, enet use AXI bus, we use disable MAC
 	 * instead of reset MAC itself.
 	 */
-	if (id_entry && id_entry->driver_data & FEC_QUIRK_HAS_AVB) {
+	if (fep->quirks & FEC_QUIRK_HAS_AVB) {
 		writel(0, fep->hwp + FEC_ECNTRL);
 	} else {
 		writel(1, fep->hwp + FEC_ECNTRL);
@@ -1128,7 +1114,7 @@ fec_stop(struct net_device *ndev)
 	writel(FEC_DEFAULT_IMASK, fep->hwp + FEC_IMASK);
 
 	/* We have to keep ENET enabled to have MII interrupt stay working */
-	if (id_entry->driver_data & FEC_QUIRK_ENET_MAC) {
+	if (fep->quirks & FEC_QUIRK_ENET_MAC) {
 		writel(2, fep->hwp + FEC_ECNTRL);
 		writel(rmii_mode, fep->hwp + FEC_R_CNTRL);
 	}
@@ -1350,8 +1336,6 @@ static int
 fec_enet_rx_queue(struct net_device *ndev, int budget, u16 queue_id)
 {
 	struct fec_enet_private *fep = netdev_priv(ndev);
-	const struct platform_device_id *id_entry =
-				platform_get_device_id(fep->pdev);
 	struct fec_enet_priv_rx_q *rxq;
 	struct bufdesc *bdp;
 	unsigned short status;
@@ -1365,7 +1349,7 @@ fec_enet_rx_queue(struct net_device *ndev, int budget, u16 queue_id)
 	u16	vlan_tag;
 	int	index = 0;
 	bool	is_copybreak;
-	bool	need_swap = id_entry->driver_data & FEC_QUIRK_SWAP_FRAME;
+	bool	need_swap = fep->quirks & FEC_QUIRK_SWAP_FRAME;
 
 #ifdef CONFIG_M532x
 	flush_cache_all();
@@ -1880,8 +1864,6 @@ failed_clk_ipg:
 static int fec_enet_mii_probe(struct net_device *ndev)
 {
 	struct fec_enet_private *fep = netdev_priv(ndev);
-	const struct platform_device_id *id_entry =
-				platform_get_device_id(fep->pdev);
 	struct phy_device *phy_dev = NULL;
 	char mdio_bus_id[MII_BUS_ID_SIZE];
 	char phy_name[MII_BUS_ID_SIZE + 3];
@@ -1927,7 +1909,7 @@ static int fec_enet_mii_probe(struct net_device *ndev)
 	}
 
 	/* mask with MAC supported features */
-	if (id_entry->driver_data & FEC_QUIRK_HAS_GBIT) {
+	if (fep->quirks & FEC_QUIRK_HAS_GBIT) {
 		phy_dev->supported &= PHY_GBIT_FEATURES;
 		phy_dev->supported &= ~SUPPORTED_1000baseT_Half;
 #if !defined(CONFIG_M5272)
@@ -1955,8 +1937,6 @@ static int fec_enet_mii_init(struct platform_device *pdev)
 	static struct mii_bus *fec0_mii_bus;
 	struct net_device *ndev = platform_get_drvdata(pdev);
 	struct fec_enet_private *fep = netdev_priv(ndev);
-	const struct platform_device_id *id_entry =
-				platform_get_device_id(fep->pdev);
 	struct device_node *node;
 	int err = -ENXIO, i;
 
@@ -1976,7 +1956,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)
 	 * mdio interface in board design, and need to be configured by
 	 * fec0 mii_bus.
 	 */
-	if ((id_entry->driver_data & FEC_QUIRK_ENET_MAC) && fep->dev_id > 0) {
+	if ((fep->quirks & FEC_QUIRK_ENET_MAC) && fep->dev_id > 0) {
 		/* fec1 uses fec0 mii_bus */
 		if (mii_cnt && fec0_mii_bus) {
 			fep->mii_bus = fec0_mii_bus;
@@ -1997,7 +1977,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)
 	 * document.
 	 */
 	fep->phy_speed = DIV_ROUND_UP(clk_get_rate(fep->clk_ipg), 5000000);
-	if (id_entry->driver_data & FEC_QUIRK_ENET_MAC)
+	if (fep->quirks & FEC_QUIRK_ENET_MAC)
 		fep->phy_speed--;
 	fep->phy_speed <<= 1;
 	writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
@@ -2039,7 +2019,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)
 	mii_cnt++;
 
 	/* save fec0 mii_bus */
-	if (id_entry->driver_data & FEC_QUIRK_ENET_MAC)
+	if (fep->quirks & FEC_QUIRK_ENET_MAC)
 		fec0_mii_bus = fep->mii_bus;
 
 	return 0;
@@ -2308,11 +2288,9 @@ static int fec_enet_us_to_itr_clock(struct net_device *ndev, int us)
 static void fec_enet_itr_coal_set(struct net_device *ndev)
 {
 	struct fec_enet_private *fep = netdev_priv(ndev);
-	const struct platform_device_id *id_entry =
-				platform_get_device_id(fep->pdev);
 	int rx_itr, tx_itr;
 
-	if (!(id_entry->driver_data & FEC_QUIRK_HAS_AVB))
+	if (!(fep->quirks & FEC_QUIRK_HAS_AVB))
 		return;
 
 	/* Must be greater than zero to avoid unpredictable behavior */
@@ -2347,10 +2325,8 @@ static int
 fec_enet_get_coalesce(struct net_device *ndev, struct ethtool_coalesce *ec)
 {
 	struct fec_enet_private *fep = netdev_priv(ndev);
-	const struct platform_device_id *id_entry =
-				platform_get_device_id(fep->pdev);
 
-	if (!(id_entry->driver_data & FEC_QUIRK_HAS_AVB))
+	if (!(fep->quirks & FEC_QUIRK_HAS_AVB))
 		return -EOPNOTSUPP;
 
 	ec->rx_coalesce_usecs = fep->rx_time_itr;
@@ -2366,12 +2342,9 @@ static int
 fec_enet_set_coalesce(struct net_device *ndev, struct ethtool_coalesce *ec)
 {
 	struct fec_enet_private *fep = netdev_priv(ndev);
-	const struct platform_device_id *id_entry =
-				platform_get_device_id(fep->pdev);
-
 	unsigned int cycle;
 
-	if (!(id_entry->driver_data & FEC_QUIRK_HAS_AVB))
+	if (!(fep->quirks & FEC_QUIRK_HAS_AVB))
 		return -EOPNOTSUPP;
 
 	if (ec->rx_max_coalesced_frames > 255) {
@@ -2951,8 +2924,6 @@ static const struct net_device_ops fec_netdev_ops = {
 static int fec_enet_init(struct net_device *ndev)
 {
 	struct fec_enet_private *fep = netdev_priv(ndev);
-	const struct platform_device_id *id_entry =
-				platform_get_device_id(fep->pdev);
 	struct fec_enet_priv_tx_q *txq;
 	struct fec_enet_priv_rx_q *rxq;
 	struct bufdesc *cbd_base;
@@ -3031,11 +3002,11 @@ static int fec_enet_init(struct net_device *ndev)
 	writel(FEC_RX_DISABLED_IMASK, fep->hwp + FEC_IMASK);
 	netif_napi_add(ndev, &fep->napi, fec_enet_rx_napi, NAPI_POLL_WEIGHT);
 
-	if (id_entry->driver_data & FEC_QUIRK_HAS_VLAN)
+	if (fep->quirks & FEC_QUIRK_HAS_VLAN)
 		/* enable hw VLAN support */
 		ndev->features |= NETIF_F_HW_VLAN_CTAG_RX;
 
-	if (id_entry->driver_data & FEC_QUIRK_HAS_CSUM) {
+	if (fep->quirks & FEC_QUIRK_HAS_CSUM) {
 		ndev->gso_max_segs = FEC_MAX_TSO_SEGS;
 
 		/* enable hw accelerator */
@@ -3044,7 +3015,7 @@ static int fec_enet_init(struct net_device *ndev)
 		fep->csum_flags |= FLAG_RX_CSUM_ENABLED;
 	}
 
-	if (id_entry->driver_data & FEC_QUIRK_HAS_AVB) {
+	if (fep->quirks & FEC_QUIRK_HAS_AVB) {
 		fep->tx_align = 0;
 		fep->rx_align = 0x3f;
 	}
@@ -3144,10 +3115,6 @@ fec_probe(struct platform_device *pdev)
 	int num_tx_qs;
 	int num_rx_qs;
 
-	of_id = of_match_device(fec_dt_ids, &pdev->dev);
-	if (of_id)
-		pdev->id_entry = of_id->data;
-
 	fec_enet_get_queue_num(pdev, &num_tx_qs, &num_rx_qs);
 
 	/* Init network device */
@@ -3161,13 +3128,17 @@ fec_probe(struct platform_device *pdev)
 	/* setup board info structure */
 	fep = netdev_priv(ndev);
 
+	of_id = of_match_device(fec_dt_ids, &pdev->dev);
+	if (of_id)
+		pdev->id_entry = of_id->data;
+	fep->quirks = pdev->id_entry->driver_data;
+
 	fep->num_rx_queues = num_rx_qs;
 	fep->num_tx_queues = num_tx_qs;
 
 #if !defined(CONFIG_M5272)
 	/* default enable pause frame auto negotiation */
-	if (pdev->id_entry &&
-	    (pdev->id_entry->driver_data & FEC_QUIRK_HAS_GBIT))
+	if (fep->quirks & FEC_QUIRK_HAS_GBIT)
 		fep->pause_flag |= FEC_PAUSE_FLAG_AUTONEG;
 #endif
 
@@ -3236,9 +3207,8 @@ fec_probe(struct platform_device *pdev)
 	if (IS_ERR(fep->clk_ref))
 		fep->clk_ref = NULL;
 
+	fep->bufdesc_ex = fep->quirks & FEC_QUIRK_HAS_BUFDESC_EX;
 	fep->clk_ptp = devm_clk_get(&pdev->dev, "ptp");
-	fep->bufdesc_ex =
-		pdev->id_entry->driver_data & FEC_QUIRK_HAS_BUFDESC_EX;
 	if (IS_ERR(fep->clk_ptp)) {
 		fep->clk_ptp = NULL;
 		fep->bufdesc_ex = false;
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 1/8] net: fec: indentation cleanup
From: Lothar Waßmann @ 2014-11-17  9:51 UTC (permalink / raw)
  To: David S. Miller
  Cc: Lothar Waßmann, netdev, Frank Li, Fugang Duan, Russell King
In-Reply-To: <1416217884-20911-1-git-send-email-LW@KARO-electronics.de>

consistently use TABs for indentation

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
 drivers/net/ethernet/freescale/fec.h |  108 +++++++++++++++++-----------------
 1 file changed, 54 insertions(+), 54 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index 9af296a..3047db4 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -213,60 +213,60 @@ struct bufdesc_ex {
  *	The following definitions courtesy of commproc.h, which where
  *	Copyright (c) 1997 Dan Malek (dmalek@jlc.net).
  */
-#define BD_SC_EMPTY     ((ushort)0x8000)        /* Receive is empty */
-#define BD_SC_READY     ((ushort)0x8000)        /* Transmit is ready */
-#define BD_SC_WRAP      ((ushort)0x2000)        /* Last buffer descriptor */
-#define BD_SC_INTRPT    ((ushort)0x1000)        /* Interrupt on change */
-#define BD_SC_CM        ((ushort)0x0200)        /* Continuous mode */
-#define BD_SC_ID        ((ushort)0x0100)        /* Rec'd too many idles */
-#define BD_SC_P         ((ushort)0x0100)        /* xmt preamble */
-#define BD_SC_BR        ((ushort)0x0020)        /* Break received */
-#define BD_SC_FR        ((ushort)0x0010)        /* Framing error */
-#define BD_SC_PR        ((ushort)0x0008)        /* Parity error */
-#define BD_SC_OV        ((ushort)0x0002)        /* Overrun */
-#define BD_SC_CD        ((ushort)0x0001)        /* ?? */
+#define BD_SC_EMPTY	((ushort)0x8000)	/* Receive is empty */
+#define BD_SC_READY	((ushort)0x8000)	/* Transmit is ready */
+#define BD_SC_WRAP	((ushort)0x2000)	/* Last buffer descriptor */
+#define BD_SC_INTRPT	((ushort)0x1000)	/* Interrupt on change */
+#define BD_SC_CM	((ushort)0x0200)	/* Continuous mode */
+#define BD_SC_ID	((ushort)0x0100)	/* Rec'd too many idles */
+#define BD_SC_P		((ushort)0x0100)	/* xmt preamble */
+#define BD_SC_BR	((ushort)0x0020)	/* Break received */
+#define BD_SC_FR	((ushort)0x0010)	/* Framing error */
+#define BD_SC_PR	((ushort)0x0008)	/* Parity error */
+#define BD_SC_OV	((ushort)0x0002)	/* Overrun */
+#define BD_SC_CD	((ushort)0x0001)	/* ?? */
 
 /* Buffer descriptor control/status used by Ethernet receive.
-*/
-#define BD_ENET_RX_EMPTY        ((ushort)0x8000)
-#define BD_ENET_RX_WRAP         ((ushort)0x2000)
-#define BD_ENET_RX_INTR         ((ushort)0x1000)
-#define BD_ENET_RX_LAST         ((ushort)0x0800)
-#define BD_ENET_RX_FIRST        ((ushort)0x0400)
-#define BD_ENET_RX_MISS         ((ushort)0x0100)
-#define BD_ENET_RX_LG           ((ushort)0x0020)
-#define BD_ENET_RX_NO           ((ushort)0x0010)
-#define BD_ENET_RX_SH           ((ushort)0x0008)
-#define BD_ENET_RX_CR           ((ushort)0x0004)
-#define BD_ENET_RX_OV           ((ushort)0x0002)
-#define BD_ENET_RX_CL           ((ushort)0x0001)
-#define BD_ENET_RX_STATS        ((ushort)0x013f)        /* All status bits */
+ */
+#define BD_ENET_RX_EMPTY	((ushort)0x8000)
+#define BD_ENET_RX_WRAP		((ushort)0x2000)
+#define BD_ENET_RX_INTR		((ushort)0x1000)
+#define BD_ENET_RX_LAST		((ushort)0x0800)
+#define BD_ENET_RX_FIRST	((ushort)0x0400)
+#define BD_ENET_RX_MISS		((ushort)0x0100)
+#define BD_ENET_RX_LG		((ushort)0x0020)
+#define BD_ENET_RX_NO		((ushort)0x0010)
+#define BD_ENET_RX_SH		((ushort)0x0008)
+#define BD_ENET_RX_CR		((ushort)0x0004)
+#define BD_ENET_RX_OV		((ushort)0x0002)
+#define BD_ENET_RX_CL		((ushort)0x0001)
+#define BD_ENET_RX_STATS	((ushort)0x013f)	/* All status bits */
 
 /* Enhanced buffer descriptor control/status used by Ethernet receive */
-#define BD_ENET_RX_VLAN         0x00000004
+#define BD_ENET_RX_VLAN		0x00000004
 
 /* Buffer descriptor control/status used by Ethernet transmit.
-*/
-#define BD_ENET_TX_READY        ((ushort)0x8000)
-#define BD_ENET_TX_PAD          ((ushort)0x4000)
-#define BD_ENET_TX_WRAP         ((ushort)0x2000)
-#define BD_ENET_TX_INTR         ((ushort)0x1000)
-#define BD_ENET_TX_LAST         ((ushort)0x0800)
-#define BD_ENET_TX_TC           ((ushort)0x0400)
-#define BD_ENET_TX_DEF          ((ushort)0x0200)
-#define BD_ENET_TX_HB           ((ushort)0x0100)
-#define BD_ENET_TX_LC           ((ushort)0x0080)
-#define BD_ENET_TX_RL           ((ushort)0x0040)
-#define BD_ENET_TX_RCMASK       ((ushort)0x003c)
-#define BD_ENET_TX_UN           ((ushort)0x0002)
-#define BD_ENET_TX_CSL          ((ushort)0x0001)
-#define BD_ENET_TX_STATS        ((ushort)0x0fff)        /* All status bits */
-
-/*enhanced buffer descriptor control/status used by Ethernet transmit*/
-#define BD_ENET_TX_INT          0x40000000
-#define BD_ENET_TX_TS           0x20000000
-#define BD_ENET_TX_PINS         0x10000000
-#define BD_ENET_TX_IINS         0x08000000
+ */
+#define BD_ENET_TX_READY	((ushort)0x8000)
+#define BD_ENET_TX_PAD		((ushort)0x4000)
+#define BD_ENET_TX_WRAP		((ushort)0x2000)
+#define BD_ENET_TX_INTR		((ushort)0x1000)
+#define BD_ENET_TX_LAST		((ushort)0x0800)
+#define BD_ENET_TX_TC		((ushort)0x0400)
+#define BD_ENET_TX_DEF		((ushort)0x0200)
+#define BD_ENET_TX_HB		((ushort)0x0100)
+#define BD_ENET_TX_LC		((ushort)0x0080)
+#define BD_ENET_TX_RL		((ushort)0x0040)
+#define BD_ENET_TX_RCMASK	((ushort)0x003c)
+#define BD_ENET_TX_UN		((ushort)0x0002)
+#define BD_ENET_TX_CSL		((ushort)0x0001)
+#define BD_ENET_TX_STATS	((ushort)0x0fff)	/* All status bits */
+
+/* enhanced buffer descriptor control/status used by Ethernet transmit */
+#define BD_ENET_TX_INT		0x40000000
+#define BD_ENET_TX_TS		0x20000000
+#define BD_ENET_TX_PINS		0x10000000
+#define BD_ENET_TX_IINS		0x08000000
 
 
 /* This device has up to three irqs on some platforms */
@@ -301,7 +301,7 @@ struct bufdesc_ex {
 #define IDLE_SLOPE_2		0x200 /* BW fraction: 0.5 */
 #define IDLE_SLOPE(X)		((X == 1) ? (IDLE_SLOPE_1 & IDLE_SLOPE_MASK) : \
 				(IDLE_SLOPE_2 & IDLE_SLOPE_MASK))
-#define RCMR_MATCHEN            (0x1 << 16)
+#define RCMR_MATCHEN		(0x1 << 16)
 #define RCMR_CMP_CFG(v, n)	((v & 0x7) <<  (n << 2))
 #define RCMR_CMP_1		(RCMR_CMP_CFG(0, 0) | RCMR_CMP_CFG(1, 1) | \
 				RCMR_CMP_CFG(2, 2) | RCMR_CMP_CFG(3, 3))
@@ -326,8 +326,8 @@ struct bufdesc_ex {
 #define TX_RING_SIZE		512	/* Must be power of two */
 #define TX_RING_MOD_MASK	511	/*   for this to work */
 
-#define BD_ENET_RX_INT          0x00800000
-#define BD_ENET_RX_PTP          ((ushort)0x0400)
+#define BD_ENET_RX_INT		0x00800000
+#define BD_ENET_RX_PTP		((ushort)0x0400)
 #define BD_ENET_RX_ICE		0x00000020
 #define BD_ENET_RX_PCR		0x00000010
 #define FLAG_RX_CSUM_ENABLED	(BD_ENET_RX_ICE | BD_ENET_RX_PCR)
@@ -364,8 +364,8 @@ struct bufdesc_ex {
 #define FEC_ITR_ICFT_DEFAULT	200  /* Set 200 frame count threshold */
 #define FEC_ITR_ICTT_DEFAULT	1000 /* Set 1000us timer threshold */
 
-#define FEC_VLAN_TAG_LEN       0x04
-#define FEC_ETHTYPE_LEN                0x02
+#define FEC_VLAN_TAG_LEN	0x04
+#define FEC_ETHTYPE_LEN		0x02
 
 /* Controller is ENET-MAC */
 #define FEC_QUIRK_ENET_MAC		(1 << 0)
@@ -390,7 +390,7 @@ struct bufdesc_ex {
  * frames not being transmitted until there is a 0-to-1 transition on
  * ENET_TDAR[TDAR].
  */
-#define FEC_QUIRK_ERR006358            (1 << 7)
+#define FEC_QUIRK_ERR006358		(1 << 7)
 /* ENET IP hw AVB
  *
  * i.MX6SX ENET IP add Audio Video Bridging (AVB) feature support.
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 4/8] net: fec: change type of 'bufdesc_ex' to bool
From: Lothar Waßmann @ 2014-11-17  9:51 UTC (permalink / raw)
  To: David S. Miller
  Cc: Lothar Waßmann, netdev, Frank Li, Fugang Duan, Russell King
In-Reply-To: <1416217884-20911-1-git-send-email-LW@KARO-electronics.de>

fep->bufdesc_ex is treated as a boolean value, thus declare it as
such.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
 drivers/net/ethernet/freescale/fec.h      |    2 +-
 drivers/net/ethernet/freescale/fec_main.c |    4 +---
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index 27e75cf..1418813 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -502,7 +502,7 @@ struct fec_enet_private {
 	int	speed;
 	struct	completion mdio_done;
 	int	irq[FEC_IRQ_NUM];
-	int	bufdesc_ex;
+	bool	bufdesc_ex;
 	int	pause_flag;
 
 	struct	napi_struct napi;
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 3dca494..f3a6379 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -3184,8 +3184,6 @@ fec_probe(struct platform_device *pdev)
 	fep->pdev = pdev;
 	fep->dev_id = dev_id++;
 
-	fep->bufdesc_ex = 0;
-
 	platform_set_drvdata(pdev, ndev);
 
 	phy_node = of_parse_phandle(np, "phy-handle", 0);
@@ -3243,7 +3241,7 @@ fec_probe(struct platform_device *pdev)
 		pdev->id_entry->driver_data & FEC_QUIRK_HAS_BUFDESC_EX;
 	if (IS_ERR(fep->clk_ptp)) {
 		fep->clk_ptp = NULL;
-		fep->bufdesc_ex = 0;
+		fep->bufdesc_ex = false;
 	}
 
 	ret = fec_enet_clk_enable(ndev, true);
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 3/8] net: fec: properly parenthesize macro args
From: Lothar Waßmann @ 2014-11-17  9:51 UTC (permalink / raw)
  To: David S. Miller
  Cc: Lothar Waßmann, netdev, Frank Li, Fugang Duan, Russell King
In-Reply-To: <1416217884-20911-1-git-send-email-LW@KARO-electronics.de>


Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
 drivers/net/ethernet/freescale/fec.h |   31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index e778b9e..27e75cf 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -279,36 +279,37 @@ struct bufdesc_ex {
 #define FEC_ENET_MAX_TX_QS	3
 #define FEC_ENET_MAX_RX_QS	3
 
-#define FEC_R_DES_START(X)	((X == 1) ? FEC_R_DES_START_1 : \
-				((X == 2) ? \
+#define FEC_R_DES_START(X)	(((X) == 1) ? FEC_R_DES_START_1 : \
+				(((X) == 2) ? \
 					FEC_R_DES_START_2 : FEC_R_DES_START_0))
-#define FEC_X_DES_START(X)	((X == 1) ? FEC_X_DES_START_1 : \
-				((X == 2) ? \
+#define FEC_X_DES_START(X)	(((X) == 1) ? FEC_X_DES_START_1 : \
+				(((X) == 2) ? \
 					FEC_X_DES_START_2 : FEC_X_DES_START_0))
-#define FEC_R_DES_ACTIVE(X)	((X == 1) ? FEC_R_DES_ACTIVE_1 : \
-				((X == 2) ? \
+#define FEC_R_DES_ACTIVE(X)	(((X) == 1) ? FEC_R_DES_ACTIVE_1 : \
+				(((X) == 2) ? \
 				   FEC_R_DES_ACTIVE_2 : FEC_R_DES_ACTIVE_0))
-#define FEC_X_DES_ACTIVE(X)	((X == 1) ? FEC_X_DES_ACTIVE_1 : \
-				((X == 2) ? \
+#define FEC_X_DES_ACTIVE(X)	(((X) == 1) ? FEC_X_DES_ACTIVE_1 : \
+				(((X) == 2) ? \
 				   FEC_X_DES_ACTIVE_2 : FEC_X_DES_ACTIVE_0))
 
-#define FEC_DMA_CFG(X)		((X == 2) ? FEC_DMA_CFG_2 : FEC_DMA_CFG_1)
+#define FEC_DMA_CFG(X)		(((X) == 2) ? FEC_DMA_CFG_2 : FEC_DMA_CFG_1)
 
 #define DMA_CLASS_EN		(1 << 16)
-#define FEC_RCMR(X)		((X == 2) ? FEC_RCMR_2 : FEC_RCMR_1)
+#define FEC_RCMR(X)		(((X) == 2) ? FEC_RCMR_2 : FEC_RCMR_1)
 #define IDLE_SLOPE_MASK		0xffff
 #define IDLE_SLOPE_1		0x200 /* BW fraction: 0.5 */
 #define IDLE_SLOPE_2		0x200 /* BW fraction: 0.5 */
-#define IDLE_SLOPE(X)		((X == 1) ? (IDLE_SLOPE_1 & IDLE_SLOPE_MASK) : \
+#define IDLE_SLOPE(X)		(((X) == 1) ?				\
+				(IDLE_SLOPE_1 & IDLE_SLOPE_MASK) :	\
 				(IDLE_SLOPE_2 & IDLE_SLOPE_MASK))
 #define RCMR_MATCHEN		(0x1 << 16)
-#define RCMR_CMP_CFG(v, n)	((v & 0x7) <<  (n << 2))
+#define RCMR_CMP_CFG(v, n)	(((v) & 0x7) <<  (n << 2))
 #define RCMR_CMP_1		(RCMR_CMP_CFG(0, 0) | RCMR_CMP_CFG(1, 1) | \
 				RCMR_CMP_CFG(2, 2) | RCMR_CMP_CFG(3, 3))
 #define RCMR_CMP_2		(RCMR_CMP_CFG(4, 0) | RCMR_CMP_CFG(5, 1) | \
 				RCMR_CMP_CFG(6, 2) | RCMR_CMP_CFG(7, 3))
-#define RCMR_CMP(X)		((X == 1) ? RCMR_CMP_1 : RCMR_CMP_2)
-#define FEC_TX_BD_FTYPE(X)	((X & 0xf) << 20)
+#define RCMR_CMP(X)		(((X) == 1) ? RCMR_CMP_1 : RCMR_CMP_2)
+#define FEC_TX_BD_FTYPE(X)	(((X) & 0xf) << 20)
 
 /* The number of Tx and Rx buffers.  These are allocated from the page
  * pool.  The code may assume these are power of two, so it it best
@@ -359,7 +360,7 @@ struct bufdesc_ex {
 /* ENET interrupt coalescing macro define */
 #define FEC_ITR_CLK_SEL		(0x1 << 30)
 #define FEC_ITR_EN		(0x1 << 31)
-#define FEC_ITR_ICFT(X)		((X & 0xff) << 20)
+#define FEC_ITR_ICFT(X)		(((X) & 0xff) << 20)
 #define FEC_ITR_ICTT(X)		((X) & 0xffff)
 #define FEC_ITR_ICFT_DEFAULT	200  /* Set 200 frame count threshold */
 #define FEC_ITR_ICTT_DEFAULT	1000 /* Set 1000us timer threshold */
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 6/8] net: fec: use swab32s() instead of cpu_to_be32()
From: Lothar Waßmann @ 2014-11-17  9:51 UTC (permalink / raw)
  To: David S. Miller
  Cc: Lothar Waßmann, netdev, Frank Li, Fugang Duan, Russell King
In-Reply-To: <1416217884-20911-1-git-send-email-LW@KARO-electronics.de>

when swap_buffer() is being called, we know for sure, that we need to
byte swap the data. Furthermore, this function is called for swapping
data in both directions. Thus cpu_to_be32() is semantically not
correct for all use cases. Use swab32s() to reflect this.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
 drivers/net/ethernet/freescale/fec_main.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 3884dd9..f73fee7 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -293,7 +293,7 @@ static void *swap_buffer(void *bufaddr, int len)
 	unsigned int *buf = bufaddr;
 
 	for (i = 0; i < DIV_ROUND_UP(len, 4); i++, buf++)
-		*buf = cpu_to_be32(*buf);
+		swab32s(buf);
 
 	return bufaddr;
 }
-- 
1.7.10.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