* [PATCH net-next] netlink: Warn on unordered or illegal nla_nest_cancel() or nlmsg_cancel()
From: Thomas Graf @ 2015-01-06 0:04 UTC (permalink / raw)
To: davem; +Cc: netdev
Calling nla_nest_cancel() in a different order as the nesting was
built up can lead to negative offsets being calculated which
results in skb_trim() being called with an underflowed unsigned
int. Warn if mark < skb->data as it's definitely a bug.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
---
include/net/netlink.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/net/netlink.h b/include/net/netlink.h
index 6415835..d5869b9 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -520,8 +520,10 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
*/
static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
{
- if (mark)
+ if (mark) {
+ WARN_ON((unsigned char *) mark < skb->data);
skb_trim(skb, (unsigned char *) mark - skb->data);
+ }
}
/**
--
1.9.3
^ permalink raw reply related
* Re: route/max_size sysctl in ipv4
From: David Miller @ 2015-01-06 0:36 UTC (permalink / raw)
To: ani; +Cc: netdev
In-Reply-To: <CAOxq_8NdxBScZ182bXs5KmTZLKRMeF3AVt+DJNFUff42gaZG4w@mail.gmail.com>
From: Ani Sinha <ani@arista.com>
Date: Mon, 5 Jan 2015 15:48:11 -0800
> I am looking at the code and it looks like since the route cache for
> ipv4 was removed from the kernel, this sysctl parameter no longer
> serves the same purpose. It does not look like it is even used in the
> ipv4/route.c module. Is there an equivalent sysctl parameter limiting
> the number of route entries in the kernel? Or is there now no
> mechanism to limit the number of route entries?
There is nothing to limit, since the cache was removed.
^ permalink raw reply
* Re: route/max_size sysctl in ipv4
From: Ani Sinha @ 2015-01-06 0:43 UTC (permalink / raw)
To: David Miller; +Cc: netdev@vger.kernel.org
In-Reply-To: <20150105.193614.1827024424476781168.davem@davemloft.net>
On Mon, Jan 5, 2015 at 4:36 PM, David Miller <davem@davemloft.net> wrote:
> From: Ani Sinha <ani@arista.com>
> Date: Mon, 5 Jan 2015 15:48:11 -0800
>
>> I am looking at the code and it looks like since the route cache for
>> ipv4 was removed from the kernel, this sysctl parameter no longer
>> serves the same purpose. It does not look like it is even used in the
>> ipv4/route.c module. Is there an equivalent sysctl parameter limiting
>> the number of route entries in the kernel? Or is there now no
>> mechanism to limit the number of route entries?
>
> There is nothing to limit, since the cache was removed.
Shouldn't the documentation be updated to reflect that? Also what's
the point of having a dummy variable that does nothing? Should we not
simply remove it?
^ permalink raw reply
* Re: [net-next PATCH v1 01/11] net: flow_table: create interface for hw match/action tables
From: John Fastabend @ 2015-01-06 0:45 UTC (permalink / raw)
To: Thomas Graf; +Cc: sfeldma, jiri, jhs, simon.horman, netdev, davem, andy
In-Reply-To: <54AADEFF.3090306@gmail.com>
[...]
>>> +/**
>>> + * @struct net_flow_field_ref
>>> + * @brief uniquely identify field as header:field tuple
>>> + */
>>> +struct net_flow_field_ref {
>>> + int instance;
>>> + int header;
>>> + int field;
>>> + int mask_type;
>>> + int type;
>>> + union { /* Are these all the required data types */
>>> + __u8 value_u8;
>>> + __u16 value_u16;
>>> + __u32 value_u32;
>>> + __u64 value_u64;
>>> + };
>>> + union { /* Are these all the required data types */
>>> + __u8 mask_u8;
>>> + __u16 mask_u16;
>>> + __u32 mask_u32;
>>> + __u64 mask_u64;
>>> + };
>>> +};
>>
>> Does it make sense to write this as follows?
>
> Yes. I'll make this update it helps make it clear value/mask pairs are
> needed.
>
>>
>> union {
>> struct {
>> __u8 value_u8;
>> __u8 mask_u8;
>> };
>> struct {
>> __u16 value_u16;
>> __u16 mask_u16;
>> };
>> ...
>> };
Another thought is to pull this entirely out of the structure and hide
it from the UAPI so we can add more value/mask types as needed without
having to spin versions of net_flow_field_ref. On the other hand I've
been able to fit all my fields in these types so far and I can't think
of any additions we need at the moment.
>>
>>> +#define NET_FLOW_TABLE_EGRESS_ROOT 1
>>> +#define NET_FLOW_TABLE_INGRESS_ROOT 2
>>
>> Tab/space mix.
>>
>
[...]
--
John Fastabend Intel Corporation
^ permalink raw reply
* Re: route/max_size sysctl in ipv4
From: David Miller @ 2015-01-06 0:51 UTC (permalink / raw)
To: ani; +Cc: netdev
In-Reply-To: <CAOxq_8OtQ0WD-PKBd4kX0JwZiaStqJ-cQiQRhWnTAK9Q0JquxA@mail.gmail.com>
From: Ani Sinha <ani@arista.com>
Date: Mon, 5 Jan 2015 16:43:30 -0800
> On Mon, Jan 5, 2015 at 4:36 PM, David Miller <davem@davemloft.net> wrote:
>> From: Ani Sinha <ani@arista.com>
>> Date: Mon, 5 Jan 2015 15:48:11 -0800
>>
>>> I am looking at the code and it looks like since the route cache for
>>> ipv4 was removed from the kernel, this sysctl parameter no longer
>>> serves the same purpose. It does not look like it is even used in the
>>> ipv4/route.c module. Is there an equivalent sysctl parameter limiting
>>> the number of route entries in the kernel? Or is there now no
>>> mechanism to limit the number of route entries?
>>
>> There is nothing to limit, since the cache was removed.
>
> Shouldn't the documentation be updated to reflect that? Also what's
> the point of having a dummy variable that does nothing? Should we not
> simply remove it?
There is nothing to update, the behavior is completely transparent.
Absolutely no cache entries exist, therefore the limit cannot be
reached.
The sysctl is kept so that scripts reading it don't suddenly stop
working. We can't just remove sysctl values.
^ permalink raw reply
* [PATCH 1/1] bridge: remove BR_GROUPFWD_RESTRICTED for arbitrary forwarding of reserved addresses
From: Bernhard Thaler @ 2015-01-06 0:56 UTC (permalink / raw)
To: stephen, davem; +Cc: netdev, bridge, Bernhard Thaler
BR_GROUPFWD_RESTRICTED bitmask restricts users from setting values to
/sys/class/net/brX/bridge/group_fwd_mask that allow forwarding of
some IEEE 802.1D Table 7-10 Reserved addresses:
(MAC Control) 802.3 01-80-C2-00-00-01
(Link Aggregation) 802.3 01-80-C2-00-00-02
802.1AB LLDP 01-80-C2-00-00-0E
BR_GROUPFWD_RESTRICTED may have been set as an extra protection against
forwarding these control frames as forwarding 802.1X PAE (01-80-C2-00-00-03)
in 802.1X setups satisfies most common use-cases.
Other situations, such as placing a software based bridge as a "TAP" between two
devices may require to forward e.g. LLDP frames while debugging network problems
or actively changing/filtering traffic with ebtables.
This patch allows to set e.g.:
echo 65535 > /sys/class/net/brX/bridge/group_fwd_mask
which sets no restrictions on the forwardable reserved addresses.
- the default value 0 will still comply with 802.1D and not forward any
reserved addresses
- values such as 8 for forwarding 802.1X related frames will behave the
same way as with BR_GROUPFWD_RESTRICTED currently in place, so backward
compatibility to current scripts using group_fwd_masks shoudl be possible
Administrators and network engineers however will be able to arbitrarily
forward any reserved addresses without BR_GROUPFWD_RESTRICTED. This will
be non-standard compliant behavior, but forwarding of any reserved address
right from the beginning is. Users should be aware of this anyway and
know what/why they are doing when setting values such as 65535, 32768, 16384,
4, 2 for group_fwd_mask
This patch was tested on a bridge with two interfaces created with bridge-utils.
Signed-off-by: Bernhard Thaler <bernhard.thaler@wvnet.at>
---
net/bridge/br_input.c | 8 ++++++--
net/bridge/br_private.h | 2 --
net/bridge/br_sysfs_br.c | 3 ---
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index 1f1de71..e44fe38 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -262,8 +262,12 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb)
goto forward;
break;
- case 0x01: /* IEEE MAC (Pause) */
- goto drop;
+ case 0x01: /* IEEE MAC (Pause) */
+ fwd_mask |= p->br->group_fwd_mask;
+ if (fwd_mask & (1u << dest[5]))
+ goto forward;
+ else
+ goto drop;
default:
/* Allow selective forwarding for most other protocols */
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index aea3d13..9b548754 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -33,8 +33,6 @@
/* Control of forwarding link local multicast */
#define BR_GROUPFWD_DEFAULT 0
-/* Don't allow forwarding control protocols like STP and LLDP */
-#define BR_GROUPFWD_RESTRICTED 0x4007u
/* The Nearest Customer Bridge Group Address, 01-80-C2-00-00-[00,0B,0C,0D,0F] */
#define BR_GROUPFWD_8021AD 0xB801u
diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
index 4c97fc5..7f04d8b 100644
--- a/net/bridge/br_sysfs_br.c
+++ b/net/bridge/br_sysfs_br.c
@@ -171,9 +171,6 @@ static ssize_t group_fwd_mask_store(struct device *d,
if (endp == buf)
return -EINVAL;
- if (val & BR_GROUPFWD_RESTRICTED)
- return -EINVAL;
-
br->group_fwd_mask = val;
return len;
--
1.7.10.4
^ permalink raw reply related
* Re: route/max_size sysctl in ipv4
From: Ani Sinha @ 2015-01-06 0:56 UTC (permalink / raw)
To: David Miller; +Cc: netdev@vger.kernel.org
In-Reply-To: <20150105.195128.794605376092864881.davem@davemloft.net>
On Mon, Jan 5, 2015 at 4:51 PM, David Miller <davem@davemloft.net> wrote:
> From: Ani Sinha <ani@arista.com>
> Date: Mon, 5 Jan 2015 16:43:30 -0800
>
>> On Mon, Jan 5, 2015 at 4:36 PM, David Miller <davem@davemloft.net> wrote:
>>> From: Ani Sinha <ani@arista.com>
>>> Date: Mon, 5 Jan 2015 15:48:11 -0800
>>>
>>>> I am looking at the code and it looks like since the route cache for
>>>> ipv4 was removed from the kernel, this sysctl parameter no longer
>>>> serves the same purpose. It does not look like it is even used in the
>>>> ipv4/route.c module. Is there an equivalent sysctl parameter limiting
>>>> the number of route entries in the kernel? Or is there now no
>>>> mechanism to limit the number of route entries?
>>>
>>> There is nothing to limit, since the cache was removed.
>>
>> Shouldn't the documentation be updated to reflect that? Also what's
>> the point of having a dummy variable that does nothing? Should we not
>> simply remove it?
>
> There is nothing to update, the behavior is completely transparent.
> Absolutely no cache entries exist, therefore the limit cannot be
> reached.
I disagree. You are advertising a feature in an official documentation
that simply does not exist for ipv4. This is very confusing. If I did
not dig into the code, I wouldn't know that this particular knob is a
noop since the time the route cache was removed.
>
> The sysctl is kept so that scripts reading it don't suddenly stop
> working. We can't just remove sysctl values.
>
^ permalink raw reply
* Re: [PATCH/RFC rocker-net-next 1/6] net: flow: Cancel innermost nested attribute first
From: Simon Horman @ 2015-01-06 1:03 UTC (permalink / raw)
To: David Miller; +Cc: john.fastabend, netdev
In-Reply-To: <20150105.161725.1765207203472571760.davem@davemloft.net>
On Mon, Jan 05, 2015 at 04:17:25PM -0500, David Miller wrote:
> From: Simon Horman <simon.horman@netronome.com>
> Date: Mon, 5 Jan 2015 15:50:05 +0900
>
> > Cancel innermost nested attribute first on error when putting flow actions.
> >
> > Signed-off-by: Simon Horman <simon.horman@netronome.com>
> >
> > ---
> >
> > Its unclear to me if this makes any difference.
> > But it seems more logical to me.
>
> Hmmm. Be careful here. nla_nest_cancel() is just rolling back
> the length of the SKB to right before the netlink attribute being
> given as the cancellation point.
>
> So you really have to cancel attributes in exactly the reverse order
> in which they were added. Otherwise we'll make a trim call with a
> negative adjustment that actually expands the SKB past an already
> cancelled attribute.
Thanks for clarifying that.
The aim of my patch is to perform the roll back in reverse order
which I now know is required.
^ permalink raw reply
* Re: [PATCH/RFC rocker-net-next 2/6] net: flow: Handle error when putting a field while putting a flow
From: Simon Horman @ 2015-01-06 1:04 UTC (permalink / raw)
To: John Fastabend; +Cc: netdev
In-Reply-To: <54AAC9AE.4010104@gmail.com>
On Mon, Jan 05, 2015 at 09:28:14AM -0800, John Fastabend wrote:
> On 01/04/2015 10:50 PM, Simon Horman wrote:
> >Signed-off-by: Simon Horman <simon.horman@netronome.com>
> >---
> > net/core/flow_table.c | 9 +++++++--
> > 1 file changed, 7 insertions(+), 2 deletions(-)
> >
> >diff --git a/net/core/flow_table.c b/net/core/flow_table.c
> >index 2af831e..753ebe0 100644
> >--- a/net/core/flow_table.c
> >+++ b/net/core/flow_table.c
> >@@ -981,8 +981,9 @@ done:
> >
> > int net_flow_put_flow(struct sk_buff *skb, struct net_flow_flow *flow)
> > {
> >- struct nlattr *flows, *matches;
> >+ struct nlattr *flows;
> > struct nlattr *actions = NULL; /* must be null to unwind */
> >+ struct nlattr *matches = NULL; /* must be null to unwind */
>
> Actually we don't need to initialize to NULL now. That was some crazy
> unwind scheme I had in place initially.
>
> Now we only ever do a nla_nest_cancel on nested attributes that have
> been initialized with nla_nest_start(). So I can simplify this to
>
> struct nlattr *flows, *matches, *actions;
Thanks, that does seem much nicer :)
>
> > int err, j, i = 0;
> >
> > flows = nla_nest_start(skb, NET_FLOW_FLOW);
> >@@ -1005,7 +1006,11 @@ int net_flow_put_flow(struct sk_buff *skb, struct net_flow_flow *flow)
> > if (!f->header)
> > continue;
> >
> >- nla_put(skb, NET_FLOW_FIELD_REF, sizeof(*f), f);
> >+ err = nla_put(skb, NET_FLOW_FIELD_REF, sizeof(*f), f);
>
> Great thanks. I missed this one.
>
> >+ if (err) {
> >+ nla_nest_cancel(skb, matches);
> >+ goto flows_put_failure;
> >+ }
> > }
> > nla_nest_end(skb, matches);
> > }
> >
>
> I'll fold this into the series and resubmit thanks.
>
> .John
>
> --
> John Fastabend Intel Corporation
^ permalink raw reply
* Re: [PATCH/RFC rocker-net-next 6/6] net: flow: Limit checking of ndo_flow_{set,del}_flows
From: Simon Horman @ 2015-01-06 1:07 UTC (permalink / raw)
To: John Fastabend; +Cc: netdev
In-Reply-To: <54AACA92.5030800@gmail.com>
On Mon, Jan 05, 2015 at 09:32:02AM -0800, John Fastabend wrote:
> On 01/04/2015 10:50 PM, Simon Horman wrote:
> >Only check for availability of ndo_flow_{set,del}_flows when
> >they are to be be used.
> >
>
> I went ahead and merged this but, I'm not sure does it make
> sense to allow a user to add a flow that can't be deleted? Or
> delete a flow that wasn't ever added? I guess if the driver has
> a reason to do this it doesn't hurt to allow it and I think the
> code looks neater this way.
>
> Also thanks for the other fixes I pulled the other 5 in as well
> I'll re-submit the series after running some basic tests.
I don't have any strong opinions on this but it
sounds like policy that doesn't belong in flow_table.c.
> >Signed-off-by: Simon Horman <simon.horman@netronome.com>
> >---
> > net/core/flow_table.c | 15 +++++++++++++--
> > 1 file changed, 13 insertions(+), 2 deletions(-)
> >
> >diff --git a/net/core/flow_table.c b/net/core/flow_table.c
> >index bfc984f..6d620d4 100644
> >--- a/net/core/flow_table.c
> >+++ b/net/core/flow_table.c
> >@@ -1206,9 +1206,20 @@ static int net_flow_table_cmd_flows(struct sk_buff *recv_skb,
> > if (!dev)
> > return -EINVAL;
> >
> >- if (!dev->netdev_ops->ndo_flow_set_flows ||
> >- !dev->netdev_ops->ndo_flow_del_flows)
> >+ switch (cmd) {
> >+ case NET_FLOW_TABLE_CMD_SET_FLOWS:
> >+ if (!dev->netdev_ops->ndo_flow_set_flows)
> >+ goto out;
> >+ break;
> >+
> >+ case NET_FLOW_TABLE_CMD_DEL_FLOWS:
> >+ if (!dev->netdev_ops->ndo_flow_del_flows)
> >+ goto out;
> >+ break;
> >+
> >+ default:
> > goto out;
> >+ }
> >
> > if (!info->attrs[NET_FLOW_IDENTIFIER_TYPE] ||
> > !info->attrs[NET_FLOW_IDENTIFIER] ||
> >
>
>
> --
> John Fastabend Intel Corporation
^ permalink raw reply
* Re: [net-next PATCH v1 01/11] net: flow_table: create interface for hw match/action tables
From: Simon Horman @ 2015-01-06 1:09 UTC (permalink / raw)
To: John Fastabend; +Cc: Thomas Graf, sfeldma, jiri, jhs, netdev, davem, andy
In-Reply-To: <54AB303E.3000601@gmail.com>
On Mon, Jan 05, 2015 at 04:45:50PM -0800, John Fastabend wrote:
> [...]
>
> >>>+/**
> >>>+ * @struct net_flow_field_ref
> >>>+ * @brief uniquely identify field as header:field tuple
> >>>+ */
> >>>+struct net_flow_field_ref {
> >>>+ int instance;
> >>>+ int header;
> >>>+ int field;
> >>>+ int mask_type;
> >>>+ int type;
> >>>+ union { /* Are these all the required data types */
> >>>+ __u8 value_u8;
> >>>+ __u16 value_u16;
> >>>+ __u32 value_u32;
> >>>+ __u64 value_u64;
> >>>+ };
> >>>+ union { /* Are these all the required data types */
> >>>+ __u8 mask_u8;
> >>>+ __u16 mask_u16;
> >>>+ __u32 mask_u32;
> >>>+ __u64 mask_u64;
> >>>+ };
> >>>+};
> >>
> >>Does it make sense to write this as follows?
> >
> >Yes. I'll make this update it helps make it clear value/mask pairs are
> >needed.
> >
> >>
> >>union {
> >> struct {
> >> __u8 value_u8;
> >> __u8 mask_u8;
> >> };
> >> struct {
> >> __u16 value_u16;
> >> __u16 mask_u16;
> >> };
> >> ...
> >>};
>
> Another thought is to pull this entirely out of the structure and hide
> it from the UAPI so we can add more value/mask types as needed without
> having to spin versions of net_flow_field_ref. On the other hand I've
> been able to fit all my fields in these types so far and I can't think
> of any additions we need at the moment.
FWIW, I think it would be cleaner to break both field_ref and action_args
out into attributes and not expose the structures to user-space. But
perhaps there is an advantage to dealing with structures directly that
I am missing.
^ permalink raw reply
* Re: [PATCH] crypto: aesni-intel - avoid IPsec re-ordering
From: Sunderam K @ 2015-01-06 1:05 UTC (permalink / raw)
To: netdev
In-Reply-To: <20141120080205.GA29710@gondor.apana.org.au>
Herbert Xu <herbert <at> gondor.apana.org.au> writes:
>
> On Thu, Nov 20, 2014 at 08:59:44AM +0100, Steffen Klassert wrote:
> >
> > Sure, but could be an option if this is really a rare case.
>
> Well it's rare but when it does hit it'll probably be there all
> the time for that system. IOW you either have no apps using the
> FPU, but when you do, it's probably going to be hogging it.
>
> > Anyway, I don't mind too much about the solution as long as we
> > get it to work :)
>
> :)
>
> Cheers,
Hi Herbert
Is there an official "blessed" patch for this re-ordering problem?
I saw some issues raised in the thread with the patch that Ming Liu had
provided?
Thanks
-sunderam
^ permalink raw reply
* Re: [net-next PATCH v1 01/11] net: flow_table: create interface for hw match/action tables
From: John Fastabend @ 2015-01-06 1:19 UTC (permalink / raw)
To: Simon Horman; +Cc: Thomas Graf, sfeldma, jiri, jhs, netdev, davem, andy
In-Reply-To: <20150106010942.GD14077@vergenet.net>
On 01/05/2015 05:09 PM, Simon Horman wrote:
> On Mon, Jan 05, 2015 at 04:45:50PM -0800, John Fastabend wrote:
>> [...]
>>
>>>>> +/**
>>>>> + * @struct net_flow_field_ref
>>>>> + * @brief uniquely identify field as header:field tuple
>>>>> + */
>>>>> +struct net_flow_field_ref {
>>>>> + int instance;
>>>>> + int header;
>>>>> + int field;
>>>>> + int mask_type;
>>>>> + int type;
>>>>> + union { /* Are these all the required data types */
>>>>> + __u8 value_u8;
>>>>> + __u16 value_u16;
>>>>> + __u32 value_u32;
>>>>> + __u64 value_u64;
>>>>> + };
>>>>> + union { /* Are these all the required data types */
>>>>> + __u8 mask_u8;
>>>>> + __u16 mask_u16;
>>>>> + __u32 mask_u32;
>>>>> + __u64 mask_u64;
>>>>> + };
>>>>> +};
>>>>
>>>> Does it make sense to write this as follows?
>>>
>>> Yes. I'll make this update it helps make it clear value/mask pairs are
>>> needed.
>>>
>>>>
>>>> union {
>>>> struct {
>>>> __u8 value_u8;
>>>> __u8 mask_u8;
>>>> };
>>>> struct {
>>>> __u16 value_u16;
>>>> __u16 mask_u16;
>>>> };
>>>> ...
>>>> };
>>
>> Another thought is to pull this entirely out of the structure and hide
>> it from the UAPI so we can add more value/mask types as needed without
>> having to spin versions of net_flow_field_ref. On the other hand I've
>> been able to fit all my fields in these types so far and I can't think
>> of any additions we need at the moment.
>
> FWIW, I think it would be cleaner to break both field_ref and action_args
> out into attributes and not expose the structures to user-space. But
> perhaps there is an advantage to dealing with structures directly that
> I am missing.
>
I came to the same conclusion just now as well. I'm reworking it now
for v2.
--
John Fastabend Intel Corporation
^ permalink raw reply
* [PATCH V2] net: eth: xgene: change APM X-Gene SoC platform ethernet to support ACPI
From: Feng Kan @ 2015-01-06 1:42 UTC (permalink / raw)
To: patches, davem, netdev, linux-kernel; +Cc: Feng Kan
This adds support for APM X-Gene ethernet driver to use ACPI table to derive
ethernet driver parameter.
Signed-off-by: Feng Kan <fkan@apm.com>
---
V2:
- remove NO_MAC define
drivers/net/ethernet/apm/xgene/xgene_enet_hw.c | 94 +++++++++++++++++------
drivers/net/ethernet/apm/xgene/xgene_enet_main.c | 95 +++++++++++++++++++-----
drivers/net/ethernet/apm/xgene/xgene_enet_main.h | 3 +
3 files changed, 149 insertions(+), 43 deletions(-)
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
index 7ba83ff..869d97f 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
@@ -593,10 +593,12 @@ static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
if (!xgene_ring_mgr_init(pdata))
return -ENODEV;
- clk_prepare_enable(pdata->clk);
- clk_disable_unprepare(pdata->clk);
- clk_prepare_enable(pdata->clk);
- xgene_enet_ecc_init(pdata);
+ if (!efi_enabled(EFI_BOOT)) {
+ clk_prepare_enable(pdata->clk);
+ clk_disable_unprepare(pdata->clk);
+ clk_prepare_enable(pdata->clk);
+ xgene_enet_ecc_init(pdata);
+ }
xgene_enet_config_ring_if_assoc(pdata);
/* Enable auto-incr for scanning */
@@ -663,15 +665,20 @@ static int xgene_enet_phy_connect(struct net_device *ndev)
struct phy_device *phy_dev;
struct device *dev = &pdata->pdev->dev;
- phy_np = of_parse_phandle(dev->of_node, "phy-handle", 0);
- if (!phy_np) {
- netdev_dbg(ndev, "No phy-handle found\n");
- return -ENODEV;
+ if (dev->of_node) {
+ phy_np = of_parse_phandle(dev->of_node, "phy-handle", 0);
+ if (!phy_np) {
+ netdev_dbg(ndev, "No phy-handle found in DT\n");
+ return -ENODEV;
+ }
+ pdata->phy_dev = of_phy_find_device(phy_np);
}
- phy_dev = of_phy_connect(ndev, phy_np, &xgene_enet_adjust_link,
- 0, pdata->phy_mode);
- if (!phy_dev) {
+ phy_dev = pdata->phy_dev;
+
+ if (!phy_dev ||
+ phy_connect_direct(ndev, phy_dev, &xgene_enet_adjust_link,
+ pdata->phy_mode)) {
netdev_err(ndev, "Could not connect to PHY\n");
return -ENODEV;
}
@@ -681,32 +688,71 @@ static int xgene_enet_phy_connect(struct net_device *ndev)
~SUPPORTED_100baseT_Half &
~SUPPORTED_1000baseT_Half;
phy_dev->advertising = phy_dev->supported;
- pdata->phy_dev = phy_dev;
return 0;
}
-int xgene_enet_mdio_config(struct xgene_enet_pdata *pdata)
+static int xgene_mdiobus_register(struct xgene_enet_pdata *pdata,
+ struct mii_bus *mdio)
{
- struct net_device *ndev = pdata->ndev;
struct device *dev = &pdata->pdev->dev;
+ struct net_device *ndev = pdata->ndev;
+ struct phy_device *phy;
struct device_node *child_np;
struct device_node *mdio_np = NULL;
- struct mii_bus *mdio_bus;
int ret;
+ u32 phy_id;
+
+ if (dev->of_node) {
+ for_each_child_of_node(dev->of_node, child_np) {
+ if (of_device_is_compatible(child_np,
+ "apm,xgene-mdio")) {
+ mdio_np = child_np;
+ break;
+ }
+ }
- for_each_child_of_node(dev->of_node, child_np) {
- if (of_device_is_compatible(child_np, "apm,xgene-mdio")) {
- mdio_np = child_np;
- break;
+ if (!mdio_np) {
+ netdev_dbg(ndev, "No mdio node in the dts\n");
+ return -ENXIO;
}
- }
- if (!mdio_np) {
- netdev_dbg(ndev, "No mdio node in the dts\n");
- return -ENXIO;
+ return of_mdiobus_register(mdio, mdio_np);
}
+ /* Mask out all PHYs from auto probing. */
+ mdio->phy_mask = ~0;
+
+ /* Register the MDIO bus */
+ ret = mdiobus_register(mdio);
+ if (ret)
+ return ret;
+
+ ret = device_property_read_u32(dev, "phy-channel", &phy_id);
+ if (ret)
+ ret = device_property_read_u32(dev, "phy-addr", &phy_id);
+ if (ret)
+ return -EINVAL;
+
+ phy = get_phy_device(mdio, phy_id, true);
+ if (!phy || IS_ERR(phy))
+ return -EIO;
+
+ ret = phy_device_register(phy);
+ if (ret)
+ phy_device_free(phy);
+ else
+ pdata->phy_dev = phy;
+
+ return ret;
+}
+
+int xgene_enet_mdio_config(struct xgene_enet_pdata *pdata)
+{
+ struct net_device *ndev = pdata->ndev;
+ struct mii_bus *mdio_bus;
+ int ret;
+
mdio_bus = mdiobus_alloc();
if (!mdio_bus)
return -ENOMEM;
@@ -720,7 +766,7 @@ int xgene_enet_mdio_config(struct xgene_enet_pdata *pdata)
mdio_bus->priv = pdata;
mdio_bus->parent = &ndev->dev;
- ret = of_mdiobus_register(mdio_bus, mdio_np);
+ ret = xgene_mdiobus_register(pdata, mdio_bus);
if (ret) {
netdev_err(ndev, "Failed to register MDIO bus\n");
mdiobus_free(mdio_bus);
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
index 83a5028..ba579c2 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
@@ -24,6 +24,10 @@
#include "xgene_enet_sgmac.h"
#include "xgene_enet_xgmac.h"
+#define RES_ENET_CSR 0
+#define RES_RING_CSR 1
+#define RES_RING_CMD 2
+
static void xgene_enet_init_bufpool(struct xgene_enet_desc_ring *buf_pool)
{
struct xgene_enet_raw_desc16 *raw_desc;
@@ -746,6 +750,41 @@ static const struct net_device_ops xgene_ndev_ops = {
.ndo_set_mac_address = xgene_enet_set_mac_address,
};
+static int xgene_get_mac_address(struct device *dev,
+ unsigned char *addr)
+{
+ int ret;
+
+ ret = device_property_read_u8_array(dev, "local-mac-address", addr, 6);
+ if (ret)
+ ret = device_property_read_u8_array(dev, "mac-address",
+ addr, 6);
+ if (ret)
+ return -ENODEV;
+
+ return ETH_ALEN;
+}
+
+static int xgene_get_phy_mode(struct device *dev)
+{
+ int i, ret;
+ char *modestr;
+
+ ret = device_property_read_string(dev, "phy-connection-type",
+ (const char **)&modestr);
+ if (ret)
+ ret = device_property_read_string(dev, "phy-mode",
+ (const char **)&modestr);
+ if (ret)
+ return -ENODEV;
+
+ for (i = 0; i < PHY_INTERFACE_MODE_MAX; i++) {
+ if (!strcasecmp(modestr, phy_modes(i)))
+ return i;
+ }
+ return -ENODEV;
+}
+
static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
{
struct platform_device *pdev;
@@ -753,29 +792,42 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
struct device *dev;
struct resource *res;
void __iomem *base_addr;
- const char *mac;
int ret;
pdev = pdata->pdev;
dev = &pdev->dev;
ndev = pdata->ndev;
- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "enet_csr");
- pdata->base_addr = devm_ioremap_resource(dev, res);
+ res = platform_get_resource(pdev, IORESOURCE_MEM, RES_ENET_CSR);
+ if (!res) {
+ dev_err(dev, "Resource enet_csr not defined\n");
+ return -ENODEV;
+ }
+ pdata->base_addr = devm_ioremap(dev, res->start, resource_size(res));
if (IS_ERR(pdata->base_addr)) {
dev_err(dev, "Unable to retrieve ENET Port CSR region\n");
return PTR_ERR(pdata->base_addr);
}
- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ring_csr");
- pdata->ring_csr_addr = devm_ioremap_resource(dev, res);
+ res = platform_get_resource(pdev, IORESOURCE_MEM, RES_RING_CSR);
+ if (!res) {
+ dev_err(dev, "Resource ring_csr not defined\n");
+ return -ENODEV;
+ }
+ pdata->ring_csr_addr = devm_ioremap(dev, res->start,
+ resource_size(res));
if (IS_ERR(pdata->ring_csr_addr)) {
dev_err(dev, "Unable to retrieve ENET Ring CSR region\n");
return PTR_ERR(pdata->ring_csr_addr);
}
- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ring_cmd");
- pdata->ring_cmd_addr = devm_ioremap_resource(dev, res);
+ res = platform_get_resource(pdev, IORESOURCE_MEM, RES_RING_CMD);
+ if (!res) {
+ dev_err(dev, "Resource ring_cmd not defined\n");
+ return -ENODEV;
+ }
+ pdata->ring_cmd_addr = devm_ioremap(dev, res->start,
+ resource_size(res));
if (IS_ERR(pdata->ring_cmd_addr)) {
dev_err(dev, "Unable to retrieve ENET Ring command region\n");
return PTR_ERR(pdata->ring_cmd_addr);
@@ -789,14 +841,12 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
}
pdata->rx_irq = ret;
- mac = of_get_mac_address(dev->of_node);
- if (mac)
- memcpy(ndev->dev_addr, mac, ndev->addr_len);
- else
+ if (xgene_get_mac_address(dev, ndev->dev_addr) != ETH_ALEN)
eth_hw_addr_random(ndev);
+
memcpy(ndev->perm_addr, ndev->dev_addr, ndev->addr_len);
- pdata->phy_mode = of_get_phy_mode(pdev->dev.of_node);
+ pdata->phy_mode = xgene_get_phy_mode(dev);
if (pdata->phy_mode < 0) {
dev_err(dev, "Unable to get phy-connection-type\n");
return pdata->phy_mode;
@@ -809,11 +859,9 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
}
pdata->clk = devm_clk_get(&pdev->dev, NULL);
- ret = IS_ERR(pdata->clk);
if (IS_ERR(pdata->clk)) {
- dev_err(&pdev->dev, "can't get clock\n");
- ret = PTR_ERR(pdata->clk);
- return ret;
+ /* Firmware may have set up the clock already. */
+ pdata->clk = NULL;
}
base_addr = pdata->base_addr;
@@ -924,7 +972,7 @@ static int xgene_enet_probe(struct platform_device *pdev)
goto err;
}
- ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
+ ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(64));
if (ret) {
netdev_err(ndev, "No usable DMA configuration\n");
goto err;
@@ -972,7 +1020,15 @@ static int xgene_enet_remove(struct platform_device *pdev)
return 0;
}
-static struct of_device_id xgene_enet_match[] = {
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id xgene_enet_acpi_match[] = {
+ { "APMC0D05", },
+ { }
+};
+MODULE_DEVICE_TABLE(acpi, xgene_enet_acpi_match);
+#endif
+
+static struct of_device_id xgene_enet_of_match[] = {
{.compatible = "apm,xgene-enet",},
{},
};
@@ -982,7 +1038,8 @@ MODULE_DEVICE_TABLE(of, xgene_enet_match);
static struct platform_driver xgene_enet_driver = {
.driver = {
.name = "xgene-enet",
- .of_match_table = xgene_enet_match,
+ .of_match_table = of_match_ptr(xgene_enet_of_match),
+ .acpi_match_table = ACPI_PTR(xgene_enet_acpi_match),
},
.probe = xgene_enet_probe,
.remove = xgene_enet_remove,
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.h b/drivers/net/ethernet/apm/xgene/xgene_enet_main.h
index f9958fa..c2d465c 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.h
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.h
@@ -22,7 +22,10 @@
#ifndef __XGENE_ENET_MAIN_H__
#define __XGENE_ENET_MAIN_H__
+#include <linux/acpi.h>
#include <linux/clk.h>
+#include <linux/efi.h>
+#include <linux/io.h>
#include <linux/of_platform.h>
#include <linux/of_net.h>
#include <linux/of_mdio.h>
--
1.9.1
^ permalink raw reply related
* Re: [net-next PATCH v1 01/11] net: flow_table: create interface for hw match/action tables
From: Simon Horman @ 2015-01-06 2:05 UTC (permalink / raw)
To: John Fastabend; +Cc: Thomas Graf, sfeldma, jiri, jhs, netdev, davem, andy
In-Reply-To: <54AB381E.3010009@gmail.com>
On Mon, Jan 05, 2015 at 05:19:26PM -0800, John Fastabend wrote:
> On 01/05/2015 05:09 PM, Simon Horman wrote:
> >On Mon, Jan 05, 2015 at 04:45:50PM -0800, John Fastabend wrote:
> >>[...]
> >>
> >>>>>+/**
> >>>>>+ * @struct net_flow_field_ref
> >>>>>+ * @brief uniquely identify field as header:field tuple
> >>>>>+ */
> >>>>>+struct net_flow_field_ref {
> >>>>>+ int instance;
> >>>>>+ int header;
> >>>>>+ int field;
> >>>>>+ int mask_type;
> >>>>>+ int type;
> >>>>>+ union { /* Are these all the required data types */
> >>>>>+ __u8 value_u8;
> >>>>>+ __u16 value_u16;
> >>>>>+ __u32 value_u32;
> >>>>>+ __u64 value_u64;
> >>>>>+ };
> >>>>>+ union { /* Are these all the required data types */
> >>>>>+ __u8 mask_u8;
> >>>>>+ __u16 mask_u16;
> >>>>>+ __u32 mask_u32;
> >>>>>+ __u64 mask_u64;
> >>>>>+ };
> >>>>>+};
> >>>>
> >>>>Does it make sense to write this as follows?
> >>>
> >>>Yes. I'll make this update it helps make it clear value/mask pairs are
> >>>needed.
> >>>
> >>>>
> >>>>union {
> >>>> struct {
> >>>> __u8 value_u8;
> >>>> __u8 mask_u8;
> >>>> };
> >>>> struct {
> >>>> __u16 value_u16;
> >>>> __u16 mask_u16;
> >>>> };
> >>>> ...
> >>>>};
> >>
> >>Another thought is to pull this entirely out of the structure and hide
> >>it from the UAPI so we can add more value/mask types as needed without
> >>having to spin versions of net_flow_field_ref. On the other hand I've
> >>been able to fit all my fields in these types so far and I can't think
> >>of any additions we need at the moment.
> >
> >FWIW, I think it would be cleaner to break both field_ref and action_args
> >out into attributes and not expose the structures to user-space. But
> >perhaps there is an advantage to dealing with structures directly that
> >I am missing.
> >
>
> I came to the same conclusion just now as well. I'm reworking it now
> for v2.
Thanks.
BTW, I think there are a few problems with net_flow_put_flow_action().
I am not quite to the bottom of it but it seems that:
* It loops over a->args[i] and then calls net_flow_put_act_types()
which performs a similar loop. This outer-loop appears to be incorrect.
* It passes a[i].args instead of a->args[i] to net_flow_put_act_types()
I can post a fix once I've got it working to my satisfaction.
But if you are reworking that code anyway perhaps it is easier for
you to handle it then.
^ permalink raw reply
* Re: [net-next PATCH v1 00/11] A flow API
From: Scott Feldman @ 2015-01-06 2:42 UTC (permalink / raw)
To: John Fastabend
Cc: Thomas Graf, Jiří Pírko, Jamal Hadi Salim,
simon.horman@netronome.com, Netdev, David S. Miller,
Andy Gospodarek
In-Reply-To: <20141231194057.31070.5244.stgit@nitbit.x32>
On Wed, Dec 31, 2014 at 11:45 AM, John Fastabend
<john.fastabend@gmail.com> wrote:
>
> Finally I have more patches to add support for creating and destroying
> tables. This allows users to define the pipeline at runtime rather
> than statically as rocker does now. After this set gets some traction
> I'll look at pushing them in a next round. However it likely requires
> adding another "world" to rocker.
Yes, it would require another "world" to be added to rocker. It would
be cool if someone could work on this. Currently, the only world
rocker supports is OF-DPA, which is based on Broadcom's published
OF-DPA spec. OF-DPA is a fixed pipeline with predefined tables. I'd
like to see a "universal machine" world added to rocker that presents
a programmable pipeline and programmable tables. The nice thing is
most of the rocker device and driver code gets reused fro this new
world. Nothing changes about the port interface, or the DMA/MSI/PCI
interfaces, or the I/O, cmd, and event paths, so much is reused.
> Another piece that I want to add is
> a description of the actions and metadata. This way user space can
> "learn" what an action is and how metadata interacts with the system.
> This work is under development.
^ permalink raw reply
* [PATCH net-next v2 0/8] net: extend ethtool link mode bitmaps to 48 bits
From: David Decotigny @ 2015-01-06 2:54 UTC (permalink / raw)
To: Amir Vadai, Florian Fainelli, netdev, linux-kernel, linux-api
Cc: David Decotigny, David S. Miller, Jason Wang, Michael S. Tsirkin,
Herbert Xu, Al Viro, Ben Hutchings, Masatake YAMATO, Xi Wang,
Neil Horman, WANG Cong, Flavio Leitner, Tom Gundersen, Jiri Pirko,
Vlad Yasevich, Eric W. Biederman, Saeed Mahameed, Venkata Duvvuru,
Govindarajulu Varadarajan
From: David Decotigny <decot@googlers.com>
History:
v2:
- added ethtool_ops::get_compat_flags() to be able to check user
parameters in generic ethtool layer when a driver does not
support a new feature.
- in generic ethtool code, EINVAL when userspace sets a link mode
with bits 32..47 set, unless driver explicitly indicates that it
supports it (get_compat_flags). also print a warning once (per
lifetime, not per-interface) if driver sets bits 32..47 of link
mode, unless it explicitly indicated that it supports 48bit link
modes.
- don't update phydev->advertising too early (ie. keep original behavior)
v1:
initial draft
This patch series increases the width of the supported/advertising
ethtool masks from 32 bits to 48. This should allow to breathe for a
couple more years (or... months?).
It should not cause any backward compatibility issues for
now. However, if user-space passed non-0 to previously-reserved fields
to ethtool_set_settings or ethtool_set_eee, they will be rejected by
non-updated (ie. no get_compat_flags) drivers. Updated drivers will
handle the new expanded link mode masks appropriately. It is
recommended we gradually adopt the new get/set API, and provide the
associated get_compat_flags(), in order to correctly support future
link modes. See ethtool.h for details.
I updated a couple drivers (mlx4, veth, tun), and some shared code in
drivers/net (phy, mii, mdio). It might be overkill for phy/mii/mdio,
and I might have missed other shared code in drivers/net. Please let
me know.
I used the compiler on my private copy to 1/ track where the
ethtool_cmd/ethtool_eee link mode fields were used 2/ track where the
link mode bitmaps are used and updated. So I believe that there is
some sort of transitive closure for the code I updated. Maybe tools
like coccinelle or clang could allow to automate these processes (1/
would probably be easy-ish, but 2/ seems a bit more complex)? I
reverted these internal "tracking" tricks for this version to minimize
impact on uapi/ethtool.h. The main resulting visible artifact of those
tricks is the new ethtool_link_mode_mask_t typedef (aka. u64). I kept
this trivial typedef here to help future refactoring, but I'd be happy
to rename it as plain "u64" if you prefer.
I can send updates to other drivers, even though it's rather pointless
to update 1G drivers at this point for example. Please let me know,
but I'd prefer to do this in follow-up patches outside this first
patch series.
############################################
# Patch Set Summary:
David Decotigny (8):
net: ethtool: internal compatibility flags to reject non-zero reserved
fields
net: ethtool: extend link mode support to 48 bits
net: phy: extend link mode support to 48 bits
net: mii: extend link mode support to 48 bits
net: mdio: extend link mode support to 48 bits
net: veth: extend link mode support to 48 bits
net: tun: extend link mode support to 48 bits
net: mlx4_en: extend link mode support to 48 bits
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 73 ++++++++-----
drivers/net/mdio.c | 59 +++++-----
drivers/net/mii.c | 52 +++++----
drivers/net/phy/phy.c | 30 +++---
drivers/net/phy/phy_device.c | 4 +-
drivers/net/tun.c | 4 +-
drivers/net/veth.c | 4 +-
include/linux/ethtool.h | 25 ++++-
include/linux/mdio.h | 15 +--
include/linux/mii.h | 31 +++---
include/linux/phy.h | 10 +-
include/uapi/linux/ethtool.h | 137 ++++++++++++++++++++----
net/core/ethtool.c | 44 ++++++++
13 files changed, 343 insertions(+), 145 deletions(-)
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply
* [PATCH net-next v2 1/8] net: ethtool: internal compatibility flags to reject non-zero reserved fields
From: David Decotigny @ 2015-01-06 2:54 UTC (permalink / raw)
To: Amir Vadai, Florian Fainelli, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-api-u79uwXL29TY76Z2rM5mHXA
Cc: David Decotigny, David S. Miller, Jason Wang, Michael S. Tsirkin,
Herbert Xu, Al Viro, Ben Hutchings, Masatake YAMATO, Xi Wang,
Neil Horman, WANG Cong, Flavio Leitner, Tom Gundersen, Jiri Pirko,
Vlad Yasevich, Eric W. Biederman, Saeed Mahameed, Venkata Duvvuru,
Govindarajulu Varadarajan
In-Reply-To: <1420512850-24699-1-git-send-email-ddecotig-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
From: David Decotigny <decot-Ypc/8FJVVoBWk0Htik3J/w@public.gmane.org>
The public ethtool API progressively shrinks "reserved" fields to
expand some other fields (eg. link mode masks). This patch allows
drivers to declare that they fully support expanded fields. When they
don't do so, the generic ethtool layer may reject (-EINVAL) userspace
requests that assign values utilizing the newly allocated areas in
these expanded fields (ie. when some reserved field receives != 0).
Signed-off-by: David Decotigny <decot-Ypc/8FJVVoBWk0Htik3J/w@public.gmane.org>
---
include/linux/ethtool.h | 19 +++++++++++++++++--
include/uapi/linux/ethtool.h | 6 +++++-
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 653dc9c..dcb08c1 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -44,6 +44,17 @@ extern int __ethtool_get_settings(struct net_device *dev,
struct ethtool_cmd *cmd);
/**
+ * enum ethtool_compat_flags - bit indices used for %get_compat_flags() bitmaps
+ * @__ETHTOOL_COMPAT_PLACEHOLDER_BIT: to avoid a compiler error,
+ * superseded by next patches
+ */
+enum ethtool_compat_flags {
+ __ETHTOOL_COMPAT_PLACEHOLDER_BIT,
+};
+
+#define __ETH_COMPAT_MASK(name) (1UL << (ETHTOOL_COMPAT_ ## name ## _BIT))
+
+/**
* enum ethtool_phys_id_state - indicator state for physical identification
* @ETHTOOL_ID_INACTIVE: Physical ID indicator should be deactivated
* @ETHTOOL_ID_ACTIVE: Physical ID indicator should be activated
@@ -99,6 +110,11 @@ static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings)
/**
* struct ethtool_ops - optional netdev operations
+ * @get_compat_flags: Internal function. Returns the internal ethtool
+ * compatibility flags: in the absence of this method, or of
+ * specific compatilibilty flags, the generic layer enforces
+ * additional constraints on the user space values before
+ * calling the callbacks below.
* @get_settings: Get various device settings including Ethernet link
* settings. The @cmd parameter is expected to have been cleared
* before get_settings is called. Returns a negative error code or
@@ -279,7 +295,6 @@ struct ethtool_ops {
const struct ethtool_tunable *, void *);
int (*set_tunable)(struct net_device *,
const struct ethtool_tunable *, const void *);
-
-
+ u32 (*get_compat_flags)(struct net_device *);
};
#endif /* _LINUX_ETHTOOL_H */
diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index 5f66d9c..d063368 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -88,7 +88,8 @@
* other than @cmd that are not described as read-only or deprecated,
* and must ignore all fields described as read-only.
*
- * Deprecated fields should be ignored by both users and drivers.
+ * Deprecated and reserved fields should be ignored by both users and
+ * drivers. If reserved fields must be set, store the value 0 in them.
*/
struct ethtool_cmd {
__u32 cmd;
@@ -300,6 +301,9 @@ struct ethtool_eeprom {
* @tx_lpi_timer: Time in microseconds the interface delays prior to asserting
* its tx lpi (after reaching 'idle' state). Effective only when eee
* was negotiated and tx_lpi_enabled was set.
+ *
+ * Deprecated and reserved fields should be ignored by both users and
+ * drivers. If reserved fields must be set, store the value 0 in them.
*/
struct ethtool_eee {
__u32 cmd;
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply related
* [PATCH net-next v2 2/8] net: ethtool: extend link mode support to 48 bits
From: David Decotigny @ 2015-01-06 2:54 UTC (permalink / raw)
To: Amir Vadai, Florian Fainelli, netdev, linux-kernel, linux-api
Cc: David Decotigny, David S. Miller, Jason Wang, Michael S. Tsirkin,
Herbert Xu, Al Viro, Ben Hutchings, Masatake YAMATO, Xi Wang,
Neil Horman, WANG Cong, Flavio Leitner, Tom Gundersen, Jiri Pirko,
Vlad Yasevich, Eric W. Biederman, Saeed Mahameed, Venkata Duvvuru,
Govindarajulu Varadarajan
In-Reply-To: <1420512850-24699-1-git-send-email-ddecotig@gmail.com>
From: David Decotigny <decot@googlers.com>
This patch also ensures that requests from userspace asking to
advertise >= 32b link mode masks will be rejected, unless the driver
explicitly supports this.
Signed-off-by: David Decotigny <decot@googlers.com>
---
include/linux/ethtool.h | 12 +++-
include/uapi/linux/ethtool.h | 131 ++++++++++++++++++++++++++++++++++++-------
net/core/ethtool.c | 44 +++++++++++++++
3 files changed, 164 insertions(+), 23 deletions(-)
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index dcb08c1..9baa80f 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -45,15 +45,21 @@ extern int __ethtool_get_settings(struct net_device *dev,
/**
* enum ethtool_compat_flags - bit indices used for %get_compat_flags() bitmaps
- * @__ETHTOOL_COMPAT_PLACEHOLDER_BIT: to avoid a compiler error,
- * superseded by next patches
+ * @ETHTOOL_COMPAT_SUPPORT_LINK_MODE_48b_BIT: when set, the driver
+ * handles 48-bit link mode requests from userspace. In its
+ * absence, the generic %ethtool_set_settings/%ethtool_set_eee
+ * ioctl handlers will reject the request if user passed an
+ * advertising link mode with any of the bits 32..47 set.
*/
enum ethtool_compat_flags {
- __ETHTOOL_COMPAT_PLACEHOLDER_BIT,
+ ETHTOOL_COMPAT_SUPPORT_LINK_MODE_48b_BIT,
};
#define __ETH_COMPAT_MASK(name) (1UL << (ETHTOOL_COMPAT_ ## name ## _BIT))
+#define ETH_COMPAT_SUPPORT_LINK_MODE_48b \
+ __ETH_COMPAT_MASK(SUPPORT_LINK_MODE_48b)
+
/**
* enum ethtool_phys_id_state - indicator state for physical identification
* @ETHTOOL_ID_INACTIVE: Physical ID indicator should be deactivated
diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index d063368..ab7c11d 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -23,14 +23,16 @@
/**
* struct ethtool_cmd - link control and status
* @cmd: Command number = %ETHTOOL_GSET or %ETHTOOL_SSET
- * @supported: Bitmask of %SUPPORTED_* flags for the link modes,
- * physical connectors and other link features for which the
- * interface supports autonegotiation or auto-detection.
- * Read-only.
- * @advertising: Bitmask of %ADVERTISED_* flags for the link modes,
- * physical connectors and other link features that are
- * advertised through autonegotiation or enabled for
- * auto-detection.
+ * @supported: Low bits of bitmask of %SUPPORTED_* flags for the link
+ * modes, physical connectors and other link features for which
+ * the interface supports autonegotiation or auto-detection.
+ * Read-only. Please do not access this field directly, use the
+ * %ethtool_cmd_supported_* family of functions instead.
+ * @advertising: Low bits of bitmask of %ADVERTISED_* flags for the
+ * link modes, physical connectors and other link features that
+ * are advertised through autonegotiation or enabled for
+ * auto-detection. Please do not access this field directly, use
+ * the %ethtool_cmd_advertising_* family of functions instead.
* @speed: Low bits of the speed
* @duplex: Duplex mode; one of %DUPLEX_*
* @port: Physical connector type; one of %PORT_*
@@ -56,10 +58,22 @@
* yield %ETH_TP_MDI_INVALID and writes may be ignored or rejected.
* When written successfully, the link should be renegotiated if
* necessary.
- * @lp_advertising: Bitmask of %ADVERTISED_* flags for the link modes
- * and other link features that the link partner advertised
- * through autonegotiation; 0 if unknown or not applicable.
- * Read-only.
+ * @lp_advertising: Low bits of bitmask of %ADVERTISED_* flags for the
+ * link modes and other link features that the link partner
+ * advertised through autonegotiation; 0 if unknown or not
+ * applicable. Read-only. Please do not access this field
+ * directly, use the %ethtool_cmd_lp_advertising_* family of
+ * functions instead.
+ * @supported_hi: High bits of bitmask of %SUPPORTED_* flags. See
+ * %supported. Read-only. Please do not access this field directly,
+ * use the %ethtool_cmd_supported_* family of functions instead.
+ * @advertising_hi: High bits of bitmask of %ADVERTISING_* flags. See
+ * %advertising. Please do not access this field directly, use the
+ * %ethtool_cmd_advertising_* family of functions instead.
+ * @lp_advertising_hi: High bits of bitmask of %ADVERTISING_* flags.
+ * See %lp_advertising. Read-only. Please do not access this
+ * field directly, use the %ethtool_cmd_lp_advertising_* family
+ * of functions instead.
*
* The link speed in Mbps is split between @speed and @speed_hi. Use
* the ethtool_cmd_speed() and ethtool_cmd_speed_set() functions to
@@ -108,7 +122,10 @@ struct ethtool_cmd {
__u8 eth_tp_mdix;
__u8 eth_tp_mdix_ctrl;
__u32 lp_advertising;
- __u32 reserved[2];
+ __u16 supported_hi;
+ __u16 advertising_hi;
+ __u16 lp_advertising_hi;
+ __u16 reserved;
};
static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
@@ -124,6 +141,45 @@ static inline __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep)
return (ep->speed_hi << 16) | ep->speed;
}
+/**
+ * ETHTOOL_MAKE_LINK_MODE_ACCESSORS - create the link_mode accessors
+ * Macro to generate the %ethtool_cmd_supported_*,
+ * %ethtool_cmd_advertising_*, %ethtool_cmd_lp_advertising_*,
+ * %ethtool_eee_supported_*, %ethtool_eee_advertised_*,
+ * %ethtool_eee_lp_advertised_* families of functions.
+ *
+ * @struct_name: either %ethtool_cmd or %ethtool_eee
+ * @field_name: name of the fields in %struct_name to
+ * access. supported/advertising/lp_advertising for ethtool_cmd,
+ * supported/advertised/lp_advertised for ethtool_eee
+ *
+ * Generates the following static functions:
+ * ethtool_cmd_supported(const struct ethtool_cmd*): returns
+ * the 64b value of %supported fields (the upper bits 63..48 are 0)
+ * ethtool_cmd_supported_set(struct ethtool_cmd*,
+ * ethtool_link_mode_mask_t value): set the %supported fields to
+ * given %value (only the lower 48 bits used, upper bits 63..48
+ * ignored)
+ *
+ * Same doc for all the other functions.
+ */
+#define ETHTOOL_MAKE_LINK_MODE_ACCESSORS(struct_name, field_name) \
+ static inline ethtool_link_mode_mask_t \
+ struct_name ## _ ## field_name(const struct struct_name *cmd) \
+ { ethtool_link_mode_mask_t r = cmd->field_name; \
+ r |= ((__u64)cmd->field_name ## _hi) << 32; return r; } \
+ static inline void \
+ struct_name ## _ ## field_name ## _set(struct struct_name *cmd, \
+ ethtool_link_mode_mask_t mask) \
+ { cmd->field_name = mask & 0xffffffff; \
+ cmd->field_name ## _hi = (mask >> 32) & 0xffff; }
+
+typedef __u64 ethtool_link_mode_mask_t;
+
+ETHTOOL_MAKE_LINK_MODE_ACCESSORS(ethtool_cmd, supported);
+ETHTOOL_MAKE_LINK_MODE_ACCESSORS(ethtool_cmd, advertising);
+ETHTOOL_MAKE_LINK_MODE_ACCESSORS(ethtool_cmd, lp_advertising);
+
/* Device supports clause 22 register access to PHY or peripherals
* using the interface defined in <linux/mii.h>. This should not be
* set if there are known to be no such peripherals present or if
@@ -288,12 +344,18 @@ struct ethtool_eeprom {
/**
* struct ethtool_eee - Energy Efficient Ethernet information
* @cmd: ETHTOOL_{G,S}EEE
- * @supported: Mask of %SUPPORTED_* flags for the speed/duplex combinations
- * for which there is EEE support.
- * @advertised: Mask of %ADVERTISED_* flags for the speed/duplex combinations
- * advertised as eee capable.
- * @lp_advertised: Mask of %ADVERTISED_* flags for the speed/duplex
- * combinations advertised by the link partner as eee capable.
+ * @supported: Low bits of mask of %SUPPORTED_* flags for the
+ * speed/duplex combinations for which there is EEE
+ * support. Please do not access this field directly, use the
+ * %ethtool_eee_supported_* family of functions instead.
+ * @advertised: Low bits of mask of %ADVERTISED_* flags for the
+ * speed/duplex combinations advertised as eee capable. Please do
+ * not access this field directly, use the
+ * %ethtool_eee_advertised_* family of functions instead.
+ * @lp_advertised: Low bits of mask of %ADVERTISED_* flags for the
+ * speed/duplex combinations advertised by the link partner as
+ * eee capable. Please do not access this field directly, use
+ * the %ethtool_eee_lp_advertised_* family of functions instead.
* @eee_active: Result of the eee auto negotiation.
* @eee_enabled: EEE configured mode (enabled/disabled).
* @tx_lpi_enabled: Whether the interface should assert its tx lpi, given
@@ -301,6 +363,16 @@ struct ethtool_eeprom {
* @tx_lpi_timer: Time in microseconds the interface delays prior to asserting
* its tx lpi (after reaching 'idle' state). Effective only when eee
* was negotiated and tx_lpi_enabled was set.
+ * @supported_hi: High bits of mask of %SUPPORTED_* flags. See
+ * %supported. Please do not access this field directly, use the
+ * %ethtool_eee_supported_* family of functions instead.
+ * @advertised_hi: High bits of mask of %ADVERTISING_* flags. See
+ * %advertising. Please do not access this field directly, use
+ * the %ethtool_eee_advertising_* family of functions instead.
+ * @lp_advertised_hi: High bits of mask of %ADVERTISING_* flags.
+ * See %lp_advertising. Please do not access this field directly,
+ * use the %ethtool_eee_lp_advertising_* family of functions
+ * instead.
*
* Deprecated and reserved fields should be ignored by both users and
* drivers. If reserved fields must be set, store the value 0 in them.
@@ -314,9 +386,17 @@ struct ethtool_eee {
__u32 eee_enabled;
__u32 tx_lpi_enabled;
__u32 tx_lpi_timer;
- __u32 reserved[2];
+ __u16 supported_hi;
+ __u16 advertised_hi;
+ __u16 lp_advertised_hi;
+ __u16 reserved;
};
+ETHTOOL_MAKE_LINK_MODE_ACCESSORS(ethtool_eee, supported);
+ETHTOOL_MAKE_LINK_MODE_ACCESSORS(ethtool_eee, advertised);
+ETHTOOL_MAKE_LINK_MODE_ACCESSORS(ethtool_eee, lp_advertised);
+
+
/**
* struct ethtool_modinfo - plugin module eeprom information
* @cmd: %ETHTOOL_GMODULEINFO
@@ -1196,6 +1276,11 @@ enum ethtool_sfeatures_retval_bits {
#define SPARC_ETH_GSET ETHTOOL_GSET
#define SPARC_ETH_SSET ETHTOOL_SSET
+/*
+ * Do not use the following macros directly to update
+ * ethtool_cmd::supported, ethtool_eee::supported. Please use
+ * ethtool_(cmd|eee)_supported(|_set) instead.
+ */
#define SUPPORTED_10baseT_Half (1 << 0)
#define SUPPORTED_10baseT_Full (1 << 1)
#define SUPPORTED_100baseT_Half (1 << 2)
@@ -1228,6 +1313,12 @@ enum ethtool_sfeatures_retval_bits {
#define SUPPORTED_56000baseSR4_Full (1 << 29)
#define SUPPORTED_56000baseLR4_Full (1 << 30)
+/*
+ * Do not use the following macros directly to update
+ * ethtool_cmd::advertising, ethtool_cmd::lp_advertising,
+ * ethtool_eee::advertised, ethtool_eee::lp_advertised. Please use
+ * ethtool_(cmd|eee)_*(|_set).
+ */
#define ADVERTISED_10baseT_Half (1 << 0)
#define ADVERTISED_10baseT_Full (1 << 1)
#define ADVERTISED_100baseT_Half (1 << 2)
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 550892c..462a8f4 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -362,6 +362,19 @@ static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
if (err < 0)
return err;
+ /* Log a warning if driver reports high link mode bits when
+ * it's not officially supporting them
+ */
+ if (!dev->ethtool_ops->get_compat_flags ||
+ !(dev->ethtool_ops->get_compat_flags(dev)
+ & ETH_COMPAT_SUPPORT_LINK_MODE_48b)) {
+ WARN_ONCE((0 != cmd.supported_hi) ||
+ (0 != cmd.advertising_hi) ||
+ (0 != cmd.lp_advertising_hi),
+ "%s: using ethtool link mode high bits",
+ netdev_name(dev));
+ }
+
if (copy_to_user(useraddr, &cmd, sizeof(cmd)))
return -EFAULT;
return 0;
@@ -377,6 +390,15 @@ static int ethtool_set_settings(struct net_device *dev, void __user *useraddr)
if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
return -EFAULT;
+ /* Reject the high advertising bits if driver doesn't support
+ * them
+ */
+ if (cmd.advertising_hi &&
+ (!dev->ethtool_ops->get_compat_flags ||
+ !(dev->ethtool_ops->get_compat_flags(dev)
+ & ETH_COMPAT_SUPPORT_LINK_MODE_48b)))
+ return -EINVAL;
+
return dev->ethtool_ops->set_settings(dev, &cmd);
}
@@ -955,6 +977,19 @@ static int ethtool_get_eee(struct net_device *dev, char __user *useraddr)
if (rc)
return rc;
+ /* Log a warning if driver reports high link mode bits when
+ * it's not officially supporting them
+ */
+ if (!dev->ethtool_ops->get_compat_flags ||
+ !(dev->ethtool_ops->get_compat_flags(dev)
+ & ETH_COMPAT_SUPPORT_LINK_MODE_48b)) {
+ WARN_ONCE((0 != edata.supported_hi) ||
+ (0 != edata.advertised_hi) ||
+ (0 != edata.lp_advertised_hi),
+ "%s: using ethtool EEE link mode high bits",
+ netdev_name(dev));
+ }
+
if (copy_to_user(useraddr, &edata, sizeof(edata)))
return -EFAULT;
@@ -971,6 +1006,15 @@ static int ethtool_set_eee(struct net_device *dev, char __user *useraddr)
if (copy_from_user(&edata, useraddr, sizeof(edata)))
return -EFAULT;
+ /* Reject the high advertising bits if driver doesn't support
+ * them
+ */
+ if (edata.advertised_hi &&
+ (!dev->ethtool_ops->get_compat_flags ||
+ !(dev->ethtool_ops->get_compat_flags(dev)
+ & ETH_COMPAT_SUPPORT_LINK_MODE_48b)))
+ return -EINVAL;
+
return dev->ethtool_ops->set_eee(dev, &edata);
}
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply related
* [PATCH net-next v2 3/8] net: phy: extend link mode support to 48 bits
From: David Decotigny @ 2015-01-06 2:54 UTC (permalink / raw)
To: Amir Vadai, Florian Fainelli, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-api-u79uwXL29TY76Z2rM5mHXA
Cc: David Decotigny, David S. Miller, Jason Wang, Michael S. Tsirkin,
Herbert Xu, Al Viro, Ben Hutchings, Masatake YAMATO, Xi Wang,
Neil Horman, WANG Cong, Flavio Leitner, Tom Gundersen, Jiri Pirko,
Vlad Yasevich, Eric W. Biederman, Saeed Mahameed, Venkata Duvvuru,
Govindarajulu Varadarajan
In-Reply-To: <1420512850-24699-1-git-send-email-ddecotig-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
From: David Decotigny <decot-Ypc/8FJVVoBWk0Htik3J/w@public.gmane.org>
Signed-off-by: David Decotigny <decot-Ypc/8FJVVoBWk0Htik3J/w@public.gmane.org>
---
drivers/net/phy/phy.c | 30 ++++++++++++++++--------------
drivers/net/phy/phy_device.c | 4 ++--
include/linux/phy.h | 10 +++++-----
3 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 767cd11..77d4eb9 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -132,7 +132,7 @@ static inline int phy_aneg_done(struct phy_device *phydev)
struct phy_setting {
int speed;
int duplex;
- u32 setting;
+ ethtool_link_mode_mask_t setting;
};
/* A mapping of all SUPPORTED settings to speed/duplex */
@@ -227,7 +227,8 @@ static inline unsigned int phy_find_setting(int speed, int duplex)
* the mask in features. Returns the index of the last setting
* if nothing else matches.
*/
-static inline unsigned int phy_find_valid(unsigned int idx, u32 features)
+static inline unsigned int phy_find_valid(unsigned int idx,
+ ethtool_link_mode_mask_t features)
{
while (idx < MAX_NUM_SETTINGS && !(settings[idx].setting & features))
idx++;
@@ -245,7 +246,7 @@ static inline unsigned int phy_find_valid(unsigned int idx, u32 features)
*/
static void phy_sanitize_settings(struct phy_device *phydev)
{
- u32 features = phydev->supported;
+ ethtool_link_mode_mask_t features = phydev->supported;
unsigned int idx;
/* Sanitize settings based on PHY capabilities */
@@ -274,18 +275,19 @@ static void phy_sanitize_settings(struct phy_device *phydev)
int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd)
{
u32 speed = ethtool_cmd_speed(cmd);
+ ethtool_link_mode_mask_t eth_adv = ethtool_cmd_advertising(cmd);
if (cmd->phy_address != phydev->addr)
return -EINVAL;
/* We make sure that we don't pass unsupported values in to the PHY */
- cmd->advertising &= phydev->supported;
+ eth_adv &= phydev->supported;
/* Verify the settings we care about. */
if (cmd->autoneg != AUTONEG_ENABLE && cmd->autoneg != AUTONEG_DISABLE)
return -EINVAL;
- if (cmd->autoneg == AUTONEG_ENABLE && cmd->advertising == 0)
+ if (cmd->autoneg == AUTONEG_ENABLE && eth_adv == 0)
return -EINVAL;
if (cmd->autoneg == AUTONEG_DISABLE &&
@@ -300,7 +302,7 @@ int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd)
phydev->speed = speed;
- phydev->advertising = cmd->advertising;
+ phydev->advertising = eth_adv;
if (AUTONEG_ENABLE == cmd->autoneg)
phydev->advertising |= ADVERTISED_Autoneg;
@@ -318,10 +320,10 @@ EXPORT_SYMBOL(phy_ethtool_sset);
int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd)
{
- cmd->supported = phydev->supported;
+ ethtool_cmd_supported_set(cmd, phydev->supported);
- cmd->advertising = phydev->advertising;
- cmd->lp_advertising = phydev->lp_advertising;
+ ethtool_cmd_advertising_set(cmd, phydev->advertising);
+ ethtool_cmd_lp_advertising_set(cmd, phydev->lp_advertising);
ethtool_cmd_speed_set(cmd, phydev->speed);
cmd->duplex = phydev->duplex;
@@ -1040,7 +1042,7 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable)
(phydev->interface == PHY_INTERFACE_MODE_RGMII) ||
phy_is_internal(phydev))) {
int eee_lp, eee_cap, eee_adv;
- u32 lp, cap, adv;
+ ethtool_link_mode_mask_t cap, adv, lp;
int status;
unsigned int idx;
@@ -1132,21 +1134,21 @@ int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_eee *data)
MDIO_MMD_PCS, phydev->addr);
if (val < 0)
return val;
- data->supported = mmd_eee_cap_to_ethtool_sup_t(val);
+ ethtool_eee_supported_set(data, mmd_eee_cap_to_ethtool_sup_t(val));
/* Get advertisement EEE */
val = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_ADV,
MDIO_MMD_AN, phydev->addr);
if (val < 0)
return val;
- data->advertised = mmd_eee_adv_to_ethtool_adv_t(val);
+ ethtool_eee_advertised_set(data, mmd_eee_adv_to_ethtool_adv_t(val));
/* Get LP advertisement EEE */
val = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_LPABLE,
MDIO_MMD_AN, phydev->addr);
if (val < 0)
return val;
- data->lp_advertised = mmd_eee_adv_to_ethtool_adv_t(val);
+ ethtool_eee_lp_advertised_set(data, mmd_eee_adv_to_ethtool_adv_t(val));
return 0;
}
@@ -1161,7 +1163,7 @@ EXPORT_SYMBOL(phy_ethtool_get_eee);
*/
int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
{
- int val = ethtool_adv_to_mmd_eee_adv_t(data->advertised);
+ int val = ethtool_adv_to_mmd_eee_adv_t(ethtool_eee_advertised(data));
phy_write_mmd_indirect(phydev, MDIO_AN_EEE_ADV, MDIO_MMD_AN,
phydev->addr, val);
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 3fc91e8..4391dc7 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -734,7 +734,7 @@ EXPORT_SYMBOL(phy_resume);
*/
static int genphy_config_advert(struct phy_device *phydev)
{
- u32 advertise;
+ ethtool_link_mode_mask_t advertise;
int oldadv, adv, bmsr;
int err, changed = 0;
@@ -1086,7 +1086,7 @@ EXPORT_SYMBOL(genphy_soft_reset);
int genphy_config_init(struct phy_device *phydev)
{
int val;
- u32 features;
+ ethtool_link_mode_mask_t features;
features = (SUPPORTED_TP | SUPPORTED_MII
| SUPPORTED_AUI | SUPPORTED_FIBRE |
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 22af8f8..aabf808 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -390,10 +390,10 @@ struct phy_device {
u32 interrupts;
/* Union of PHY and Attached devices' supported modes */
- /* See mii.h for more info */
- u32 supported;
- u32 advertising;
- u32 lp_advertising;
+ /* See ethtool.h for more info */
+ ethtool_link_mode_mask_t supported;
+ ethtool_link_mode_mask_t advertising;
+ ethtool_link_mode_mask_t lp_advertising;
int autoneg;
@@ -447,7 +447,7 @@ struct phy_driver {
u32 phy_id;
char *name;
unsigned int phy_id_mask;
- u32 features;
+ ethtool_link_mode_mask_t features;
u32 flags;
const void *driver_data;
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply related
* [PATCH net-next v2 4/8] net: mii: extend link mode support to 48 bits
From: David Decotigny @ 2015-01-06 2:54 UTC (permalink / raw)
To: Amir Vadai, Florian Fainelli, netdev, linux-kernel, linux-api
Cc: David Decotigny, David S. Miller, Jason Wang, Michael S. Tsirkin,
Herbert Xu, Al Viro, Ben Hutchings, Masatake YAMATO, Xi Wang,
Neil Horman, WANG Cong, Flavio Leitner, Tom Gundersen, Jiri Pirko,
Vlad Yasevich, Eric W. Biederman, Saeed Mahameed, Venkata Duvvuru,
Govindarajulu Varadarajan
In-Reply-To: <1420512850-24699-1-git-send-email-ddecotig@gmail.com>
From: David Decotigny <decot@googlers.com>
Signed-off-by: David Decotigny <decot@googlers.com>
---
drivers/net/mii.c | 52 +++++++++++++++++++++++++++++-----------------------
include/linux/mii.h | 31 ++++++++++++++++---------------
2 files changed, 45 insertions(+), 38 deletions(-)
diff --git a/drivers/net/mii.c b/drivers/net/mii.c
index 4a99c39..2be59ba 100644
--- a/drivers/net/mii.c
+++ b/drivers/net/mii.c
@@ -33,7 +33,7 @@
#include <linux/ethtool.h>
#include <linux/mii.h>
-static u32 mii_get_an(struct mii_if_info *mii, u16 addr)
+static ethtool_link_mode_mask_t mii_get_an(struct mii_if_info *mii, u16 addr)
{
int advert;
@@ -56,14 +56,15 @@ int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
{
struct net_device *dev = mii->dev;
u16 bmcr, bmsr, ctrl1000 = 0, stat1000 = 0;
- u32 nego;
+ ethtool_link_mode_mask_t supported_link_modes, advertising_link_modes;
+ ethtool_link_mode_mask_t nego;
- ecmd->supported =
+ supported_link_modes =
(SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII);
if (mii->supports_gmii)
- ecmd->supported |= SUPPORTED_1000baseT_Half |
+ supported_link_modes |= SUPPORTED_1000baseT_Half |
SUPPORTED_1000baseT_Full;
/* only supports twisted-pair */
@@ -76,7 +77,7 @@ int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
ecmd->phy_address = mii->phy_id;
ecmd->mdio_support = ETH_MDIO_SUPPORTS_C22;
- ecmd->advertising = ADVERTISED_TP | ADVERTISED_MII;
+ advertising_link_modes = ADVERTISED_TP | ADVERTISED_MII;
bmcr = mii->mdio_read(dev, mii->phy_id, MII_BMCR);
bmsr = mii->mdio_read(dev, mii->phy_id, MII_BMSR);
@@ -85,23 +86,25 @@ int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
stat1000 = mii->mdio_read(dev, mii->phy_id, MII_STAT1000);
}
if (bmcr & BMCR_ANENABLE) {
- ecmd->advertising |= ADVERTISED_Autoneg;
+ ethtool_link_mode_mask_t lp_adv;
+
+ advertising_link_modes |= ADVERTISED_Autoneg;
ecmd->autoneg = AUTONEG_ENABLE;
- ecmd->advertising |= mii_get_an(mii, MII_ADVERTISE);
+ advertising_link_modes |= mii_get_an(mii, MII_ADVERTISE);
if (mii->supports_gmii)
- ecmd->advertising |=
+ advertising_link_modes |=
mii_ctrl1000_to_ethtool_adv_t(ctrl1000);
if (bmsr & BMSR_ANEGCOMPLETE) {
- ecmd->lp_advertising = mii_get_an(mii, MII_LPA);
- ecmd->lp_advertising |=
- mii_stat1000_to_ethtool_lpa_t(stat1000);
+ lp_adv = mii_get_an(mii, MII_LPA);
+ lp_adv |= mii_stat1000_to_ethtool_lpa_t(stat1000);
} else {
- ecmd->lp_advertising = 0;
+ lp_adv = 0;
}
- nego = ecmd->advertising & ecmd->lp_advertising;
+ ethtool_cmd_lp_advertising_set(ecmd, lp_adv);
+ nego = advertising_link_modes & lp_adv;
if (nego & (ADVERTISED_1000baseT_Full |
ADVERTISED_1000baseT_Half)) {
@@ -128,6 +131,8 @@ int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
}
mii->full_duplex = ecmd->duplex;
+ ethtool_cmd_supported_set(ecmd, supported_link_modes);
+ ethtool_cmd_advertising_set(ecmd, advertising_link_modes);
/* ignore maxtxpkt, maxrxpkt for now */
@@ -168,13 +173,15 @@ int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
if (ecmd->autoneg == AUTONEG_ENABLE) {
u32 bmcr, advert, tmp;
u32 advert2 = 0, tmp2 = 0;
-
- if ((ecmd->advertising & (ADVERTISED_10baseT_Half |
- ADVERTISED_10baseT_Full |
- ADVERTISED_100baseT_Half |
- ADVERTISED_100baseT_Full |
- ADVERTISED_1000baseT_Half |
- ADVERTISED_1000baseT_Full)) == 0)
+ ethtool_link_mode_mask_t ethtool_adv;
+
+ ethtool_adv = ethtool_cmd_advertising(ecmd);
+ if ((ethtool_adv & (ADVERTISED_10baseT_Half |
+ ADVERTISED_10baseT_Full |
+ ADVERTISED_100baseT_Half |
+ ADVERTISED_100baseT_Full |
+ ADVERTISED_1000baseT_Half |
+ ADVERTISED_1000baseT_Full)) == 0)
return -EINVAL;
/* advertise only what has been requested */
@@ -184,11 +191,10 @@ int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
advert2 = mii->mdio_read(dev, mii->phy_id, MII_CTRL1000);
tmp2 = advert2 & ~(ADVERTISE_1000HALF | ADVERTISE_1000FULL);
}
- tmp |= ethtool_adv_to_mii_adv_t(ecmd->advertising);
+ tmp |= ethtool_adv_to_mii_adv_t(ethtool_adv);
if (mii->supports_gmii)
- tmp2 |=
- ethtool_adv_to_mii_ctrl1000_t(ecmd->advertising);
+ tmp2 |= ethtool_adv_to_mii_ctrl1000_t(ethtool_adv);
if (advert != tmp) {
mii->mdio_write(dev, mii->phy_id, MII_ADVERTISE, tmp);
mii->advertising = tmp;
diff --git a/include/linux/mii.h b/include/linux/mii.h
index 47492c9..6f5336c 100644
--- a/include/linux/mii.h
+++ b/include/linux/mii.h
@@ -106,7 +106,7 @@ static inline unsigned int mii_duplex (unsigned int duplex_lock,
* settings to phy autonegotiation advertisements for the
* MII_ADVERTISE register.
*/
-static inline u32 ethtool_adv_to_mii_adv_t(u32 ethadv)
+static inline u32 ethtool_adv_to_mii_adv_t(ethtool_link_mode_mask_t ethadv)
{
u32 result = 0;
@@ -133,9 +133,9 @@ static inline u32 ethtool_adv_to_mii_adv_t(u32 ethadv)
* A small helper function that translates MII_ADVERTISE bits
* to ethtool advertisement settings.
*/
-static inline u32 mii_adv_to_ethtool_adv_t(u32 adv)
+static inline ethtool_link_mode_mask_t mii_adv_to_ethtool_adv_t(u32 adv)
{
- u32 result = 0;
+ ethtool_link_mode_mask_t result = 0;
if (adv & ADVERTISE_10HALF)
result |= ADVERTISED_10baseT_Half;
@@ -161,7 +161,8 @@ static inline u32 mii_adv_to_ethtool_adv_t(u32 adv)
* settings to phy autonegotiation advertisements for the
* MII_CTRL1000 register when in 1000T mode.
*/
-static inline u32 ethtool_adv_to_mii_ctrl1000_t(u32 ethadv)
+static inline u32
+ethtool_adv_to_mii_ctrl1000_t(ethtool_link_mode_mask_t ethadv)
{
u32 result = 0;
@@ -181,9 +182,9 @@ static inline u32 ethtool_adv_to_mii_ctrl1000_t(u32 ethadv)
* bits, when in 1000Base-T mode, to ethtool
* advertisement settings.
*/
-static inline u32 mii_ctrl1000_to_ethtool_adv_t(u32 adv)
+static inline ethtool_link_mode_mask_t mii_ctrl1000_to_ethtool_adv_t(u32 adv)
{
- u32 result = 0;
+ ethtool_link_mode_mask_t result = 0;
if (adv & ADVERTISE_1000HALF)
result |= ADVERTISED_1000baseT_Half;
@@ -201,9 +202,9 @@ static inline u32 mii_ctrl1000_to_ethtool_adv_t(u32 adv)
* bits, when in 1000Base-T mode, to ethtool
* LP advertisement settings.
*/
-static inline u32 mii_lpa_to_ethtool_lpa_t(u32 lpa)
+static inline ethtool_link_mode_mask_t mii_lpa_to_ethtool_lpa_t(u32 lpa)
{
- u32 result = 0;
+ ethtool_link_mode_mask_t result = 0;
if (lpa & LPA_LPACK)
result |= ADVERTISED_Autoneg;
@@ -219,9 +220,9 @@ static inline u32 mii_lpa_to_ethtool_lpa_t(u32 lpa)
* bits, when in 1000Base-T mode, to ethtool
* advertisement settings.
*/
-static inline u32 mii_stat1000_to_ethtool_lpa_t(u32 lpa)
+static inline ethtool_link_mode_mask_t mii_stat1000_to_ethtool_lpa_t(u32 lpa)
{
- u32 result = 0;
+ ethtool_link_mode_mask_t result = 0;
if (lpa & LPA_1000HALF)
result |= ADVERTISED_1000baseT_Half;
@@ -239,7 +240,7 @@ static inline u32 mii_stat1000_to_ethtool_lpa_t(u32 lpa)
* settings to phy autonegotiation advertisements for the
* MII_CTRL1000 register when in 1000Base-X mode.
*/
-static inline u32 ethtool_adv_to_mii_adv_x(u32 ethadv)
+static inline u32 ethtool_adv_to_mii_adv_x(ethtool_link_mode_mask_t ethadv)
{
u32 result = 0;
@@ -263,9 +264,9 @@ static inline u32 ethtool_adv_to_mii_adv_x(u32 ethadv)
* bits, when in 1000Base-X mode, to ethtool
* advertisement settings.
*/
-static inline u32 mii_adv_to_ethtool_adv_x(u32 adv)
+static inline ethtool_link_mode_mask_t mii_adv_to_ethtool_adv_x(u32 adv)
{
- u32 result = 0;
+ ethtool_link_mode_mask_t result = 0;
if (adv & ADVERTISE_1000XHALF)
result |= ADVERTISED_1000baseT_Half;
@@ -287,9 +288,9 @@ static inline u32 mii_adv_to_ethtool_adv_x(u32 adv)
* bits, when in 1000Base-X mode, to ethtool
* LP advertisement settings.
*/
-static inline u32 mii_lpa_to_ethtool_lpa_x(u32 lpa)
+static inline ethtool_link_mode_mask_t mii_lpa_to_ethtool_lpa_x(u32 lpa)
{
- u32 result = 0;
+ ethtool_link_mode_mask_t result = 0;
if (lpa & LPA_LPACK)
result |= ADVERTISED_Autoneg;
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply related
* [PATCH net-next v2 5/8] net: mdio: extend link mode support to 48 bits
From: David Decotigny @ 2015-01-06 2:54 UTC (permalink / raw)
To: Amir Vadai, Florian Fainelli, netdev, linux-kernel, linux-api
Cc: David Decotigny, David S. Miller, Jason Wang, Michael S. Tsirkin,
Herbert Xu, Al Viro, Ben Hutchings, Masatake YAMATO, Xi Wang,
Neil Horman, WANG Cong, Flavio Leitner, Tom Gundersen, Jiri Pirko,
Vlad Yasevich, Eric W. Biederman, Saeed Mahameed, Venkata Duvvuru,
Govindarajulu Varadarajan
In-Reply-To: <1420512850-24699-1-git-send-email-ddecotig@gmail.com>
From: David Decotigny <decot@googlers.com>
Signed-off-by: David Decotigny <decot@googlers.com>
---
drivers/net/mdio.c | 59 +++++++++++++++++++++++++++++-----------------------
include/linux/mdio.h | 15 +++++++------
2 files changed, 42 insertions(+), 32 deletions(-)
diff --git a/drivers/net/mdio.c b/drivers/net/mdio.c
index 3e027ed..5cac2ac 100644
--- a/drivers/net/mdio.c
+++ b/drivers/net/mdio.c
@@ -148,9 +148,10 @@ int mdio45_nway_restart(const struct mdio_if_info *mdio)
}
EXPORT_SYMBOL(mdio45_nway_restart);
-static u32 mdio45_get_an(const struct mdio_if_info *mdio, u16 addr)
+static ethtool_link_mode_mask_t
+mdio45_get_an(const struct mdio_if_info *mdio, u16 addr)
{
- u32 result = 0;
+ ethtool_link_mode_mask_t result = 0;
int reg;
reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_AN, addr);
@@ -185,9 +186,11 @@ static u32 mdio45_get_an(const struct mdio_if_info *mdio, u16 addr)
*/
void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio,
struct ethtool_cmd *ecmd,
- u32 npage_adv, u32 npage_lpa)
+ ethtool_link_mode_mask_t npage_adv,
+ ethtool_link_mode_mask_t npage_lpa)
{
int reg;
+ ethtool_link_mode_mask_t supported_link_modes, advertising_link_modes;
u32 speed;
BUILD_BUG_ON(MDIO_SUPPORTS_C22 != ETH_MDIO_SUPPORTS_C22);
@@ -206,64 +209,64 @@ void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio,
case MDIO_PMA_CTRL2_100BTX:
case MDIO_PMA_CTRL2_10BT:
ecmd->port = PORT_TP;
- ecmd->supported = SUPPORTED_TP;
+ supported_link_modes = SUPPORTED_TP;
reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
MDIO_SPEED);
if (reg & MDIO_SPEED_10G)
- ecmd->supported |= SUPPORTED_10000baseT_Full;
+ supported_link_modes |= SUPPORTED_10000baseT_Full;
if (reg & MDIO_PMA_SPEED_1000)
- ecmd->supported |= (SUPPORTED_1000baseT_Full |
+ supported_link_modes |= (SUPPORTED_1000baseT_Full |
SUPPORTED_1000baseT_Half);
if (reg & MDIO_PMA_SPEED_100)
- ecmd->supported |= (SUPPORTED_100baseT_Full |
+ supported_link_modes |= (SUPPORTED_100baseT_Full |
SUPPORTED_100baseT_Half);
if (reg & MDIO_PMA_SPEED_10)
- ecmd->supported |= (SUPPORTED_10baseT_Full |
+ supported_link_modes |= (SUPPORTED_10baseT_Full |
SUPPORTED_10baseT_Half);
- ecmd->advertising = ADVERTISED_TP;
+ advertising_link_modes = ADVERTISED_TP;
break;
case MDIO_PMA_CTRL2_10GBCX4:
ecmd->port = PORT_OTHER;
- ecmd->supported = 0;
- ecmd->advertising = 0;
+ supported_link_modes = 0;
+ advertising_link_modes = 0;
break;
case MDIO_PMA_CTRL2_10GBKX4:
case MDIO_PMA_CTRL2_10GBKR:
case MDIO_PMA_CTRL2_1000BKX:
ecmd->port = PORT_OTHER;
- ecmd->supported = SUPPORTED_Backplane;
+ supported_link_modes = SUPPORTED_Backplane;
reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
MDIO_PMA_EXTABLE);
if (reg & MDIO_PMA_EXTABLE_10GBKX4)
- ecmd->supported |= SUPPORTED_10000baseKX4_Full;
+ supported_link_modes |= SUPPORTED_10000baseKX4_Full;
if (reg & MDIO_PMA_EXTABLE_10GBKR)
- ecmd->supported |= SUPPORTED_10000baseKR_Full;
+ supported_link_modes |= SUPPORTED_10000baseKR_Full;
if (reg & MDIO_PMA_EXTABLE_1000BKX)
- ecmd->supported |= SUPPORTED_1000baseKX_Full;
+ supported_link_modes |= SUPPORTED_1000baseKX_Full;
reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
MDIO_PMA_10GBR_FECABLE);
if (reg & MDIO_PMA_10GBR_FECABLE_ABLE)
- ecmd->supported |= SUPPORTED_10000baseR_FEC;
- ecmd->advertising = ADVERTISED_Backplane;
+ supported_link_modes |= SUPPORTED_10000baseR_FEC;
+ advertising_link_modes = ADVERTISED_Backplane;
break;
/* All the other defined modes are flavours of optical */
default:
ecmd->port = PORT_FIBRE;
- ecmd->supported = SUPPORTED_FIBRE;
- ecmd->advertising = ADVERTISED_FIBRE;
+ supported_link_modes = SUPPORTED_FIBRE;
+ advertising_link_modes = ADVERTISED_FIBRE;
break;
}
if (mdio->mmds & MDIO_DEVS_AN) {
- ecmd->supported |= SUPPORTED_Autoneg;
+ supported_link_modes |= SUPPORTED_Autoneg;
reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_AN,
MDIO_CTRL1);
if (reg & MDIO_AN_CTRL1_ENABLE) {
ecmd->autoneg = AUTONEG_ENABLE;
- ecmd->advertising |=
+ advertising_link_modes |=
ADVERTISED_Autoneg |
mdio45_get_an(mdio, MDIO_AN_ADVERTISE) |
npage_adv;
@@ -275,21 +278,22 @@ void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio,
}
if (ecmd->autoneg) {
- u32 modes = 0;
+ ethtool_link_mode_mask_t modes = 0;
int an_stat = mdio->mdio_read(mdio->dev, mdio->prtad,
MDIO_MMD_AN, MDIO_STAT1);
/* If AN is complete and successful, report best common
* mode, otherwise report best advertised mode. */
if (an_stat & MDIO_AN_STAT1_COMPLETE) {
- ecmd->lp_advertising =
+ ethtool_link_mode_mask_t lp_adv =
mdio45_get_an(mdio, MDIO_AN_LPA) | npage_lpa;
if (an_stat & MDIO_AN_STAT1_LPABLE)
- ecmd->lp_advertising |= ADVERTISED_Autoneg;
- modes = ecmd->advertising & ecmd->lp_advertising;
+ lp_adv |= ADVERTISED_Autoneg;
+ ethtool_cmd_lp_advertising_set(ecmd, lp_adv);
+ modes = advertising_link_modes & lp_adv;
}
if ((modes & ~ADVERTISED_Autoneg) == 0)
- modes = ecmd->advertising;
+ modes = advertising_link_modes;
if (modes & (ADVERTISED_10000baseT_Full |
ADVERTISED_10000baseKX4_Full |
@@ -338,6 +342,9 @@ void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio,
break;
}
}
+
+ ethtool_cmd_supported_set(ecmd, supported_link_modes);
+ ethtool_cmd_advertising_set(ecmd, advertising_link_modes);
}
EXPORT_SYMBOL(mdio45_ethtool_gset_npage);
diff --git a/include/linux/mdio.h b/include/linux/mdio.h
index b42963b..18c649a 100644
--- a/include/linux/mdio.h
+++ b/include/linux/mdio.h
@@ -69,7 +69,8 @@ extern int mdio45_links_ok(const struct mdio_if_info *mdio, u32 mmds);
extern int mdio45_nway_restart(const struct mdio_if_info *mdio);
extern void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio,
struct ethtool_cmd *ecmd,
- u32 npage_adv, u32 npage_lpa);
+ ethtool_link_mode_mask_t npage_adv,
+ ethtool_link_mode_mask_t npage_lpa);
/**
* mdio45_ethtool_gset - get settings for ETHTOOL_GSET
@@ -97,9 +98,10 @@ extern int mdio_mii_ioctl(const struct mdio_if_info *mdio,
* A small helper function that translates MMD EEE Capability (3.20) bits
* to ethtool supported settings.
*/
-static inline u32 mmd_eee_cap_to_ethtool_sup_t(u16 eee_cap)
+static inline ethtool_link_mode_mask_t
+mmd_eee_cap_to_ethtool_sup_t(u16 eee_cap)
{
- u32 supported = 0;
+ ethtool_link_mode_mask_t supported = 0;
if (eee_cap & MDIO_EEE_100TX)
supported |= SUPPORTED_100baseT_Full;
@@ -125,9 +127,10 @@ static inline u32 mmd_eee_cap_to_ethtool_sup_t(u16 eee_cap)
* and MMD EEE Link Partner Ability (7.61) bits to ethtool advertisement
* settings.
*/
-static inline u32 mmd_eee_adv_to_ethtool_adv_t(u16 eee_adv)
+static inline ethtool_link_mode_mask_t
+mmd_eee_adv_to_ethtool_adv_t(u16 eee_adv)
{
- u32 adv = 0;
+ ethtool_link_mode_mask_t adv = 0;
if (eee_adv & MDIO_EEE_100TX)
adv |= ADVERTISED_100baseT_Full;
@@ -153,7 +156,7 @@ static inline u32 mmd_eee_adv_to_ethtool_adv_t(u16 eee_adv)
* to EEE advertisements for the MMD EEE Advertisement (7.60) and
* MMD EEE Link Partner Ability (7.61) registers.
*/
-static inline u16 ethtool_adv_to_mmd_eee_adv_t(u32 adv)
+static inline u16 ethtool_adv_to_mmd_eee_adv_t(ethtool_link_mode_mask_t adv)
{
u16 reg = 0;
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply related
* [PATCH net-next v2 6/8] net: veth: extend link mode support to 48 bits
From: David Decotigny @ 2015-01-06 2:54 UTC (permalink / raw)
To: Amir Vadai, Florian Fainelli, netdev, linux-kernel, linux-api
Cc: David Decotigny, David S. Miller, Jason Wang, Michael S. Tsirkin,
Herbert Xu, Al Viro, Ben Hutchings, Masatake YAMATO, Xi Wang,
Neil Horman, WANG Cong, Flavio Leitner, Tom Gundersen, Jiri Pirko,
Vlad Yasevich, Eric W. Biederman, Saeed Mahameed, Venkata Duvvuru,
Govindarajulu Varadarajan
In-Reply-To: <1420512850-24699-1-git-send-email-ddecotig@gmail.com>
From: David Decotigny <decot@googlers.com>
Signed-off-by: David Decotigny <decot@googlers.com>
---
drivers/net/veth.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 8ad5965..902e127 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -49,8 +49,8 @@ static struct {
static int veth_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
- cmd->supported = 0;
- cmd->advertising = 0;
+ ethtool_cmd_supported_set(cmd, 0);
+ ethtool_cmd_advertising_set(cmd, 0);
ethtool_cmd_speed_set(cmd, SPEED_10000);
cmd->duplex = DUPLEX_FULL;
cmd->port = PORT_TP;
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply related
* [PATCH net-next v2 8/8] net: mlx4_en: extend link mode support to 48 bits
From: David Decotigny @ 2015-01-06 2:54 UTC (permalink / raw)
To: Amir Vadai, Florian Fainelli, netdev, linux-kernel, linux-api
Cc: David Decotigny, David S. Miller, Jason Wang, Michael S. Tsirkin,
Herbert Xu, Al Viro, Ben Hutchings, Masatake YAMATO, Xi Wang,
Neil Horman, WANG Cong, Flavio Leitner, Tom Gundersen, Jiri Pirko,
Vlad Yasevich, Eric W. Biederman, Saeed Mahameed, Venkata Duvvuru,
Govindarajulu Varadarajan
In-Reply-To: <1420512850-24699-1-git-send-email-ddecotig@gmail.com>
From: David Decotigny <decot@googlers.com>
Signed-off-by: David Decotigny <decot@googlers.com>
---
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 73 ++++++++++++++++---------
1 file changed, 46 insertions(+), 27 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
index 90e0f04..8ccbe3f 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
@@ -46,6 +46,11 @@
#define EN_ETHTOOL_SHORT_MASK cpu_to_be16(0xffff)
#define EN_ETHTOOL_WORD_MASK cpu_to_be32(0xffffffff)
+static u32 mlx4_en_get_compat_flags(struct net_device *unused_netdev)
+{
+ return ETH_COMPAT_SUPPORT_LINK_MODE_48b;
+}
+
static int mlx4_en_moderation_update(struct mlx4_en_priv *priv)
{
int i;
@@ -388,7 +393,8 @@ static u32 mlx4_en_autoneg_get(struct net_device *dev)
return autoneg;
}
-static u32 ptys_get_supported_port(struct mlx4_ptys_reg *ptys_reg)
+static ethtool_link_mode_mask_t
+ptys_get_supported_port(struct mlx4_ptys_reg *ptys_reg)
{
u32 eth_proto = be32_to_cpu(ptys_reg->eth_proto_cap);
@@ -465,7 +471,7 @@ enum ethtool_report {
};
/* Translates mlx4 link mode to equivalent ethtool Link modes/speed */
-static u32 ptys2ethtool_map[MLX4_LINK_MODES_SZ][3] = {
+static u64 ptys2ethtool_map[MLX4_LINK_MODES_SZ][3] = {
[MLX4_100BASE_TX] = {
SUPPORTED_100baseT_Full,
ADVERTISED_100baseT_Full,
@@ -558,10 +564,11 @@ static u32 ptys2ethtool_map[MLX4_LINK_MODES_SZ][3] = {
},
};
-static u32 ptys2ethtool_link_modes(u32 eth_proto, enum ethtool_report report)
+static ethtool_link_mode_mask_t
+ptys2ethtool_link_modes(u32 eth_proto, enum ethtool_report report)
{
int i;
- u32 link_modes = 0;
+ ethtool_link_mode_mask_t link_modes = 0;
for (i = 0; i < MLX4_LINK_MODES_SZ; i++) {
if (eth_proto & MLX4_PROT_MASK(i))
@@ -570,7 +577,8 @@ static u32 ptys2ethtool_link_modes(u32 eth_proto, enum ethtool_report report)
return link_modes;
}
-static u32 ethtool2ptys_link_modes(u32 link_modes, enum ethtool_report report)
+static u32 ethtool2ptys_link_modes(ethtool_link_mode_mask_t link_modes,
+ enum ethtool_report report)
{
int i;
u32 ptys_modes = 0;
@@ -601,6 +609,9 @@ static int ethtool_get_ptys_settings(struct net_device *dev,
struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_ptys_reg ptys_reg;
u32 eth_proto;
+ ethtool_link_mode_mask_t eth_supported;
+ ethtool_link_mode_mask_t eth_advertising;
+ ethtool_link_mode_mask_t eth_lp_advertising;
int ret;
memset(&ptys_reg, 0, sizeof(ptys_reg));
@@ -624,41 +635,44 @@ static int ethtool_get_ptys_settings(struct net_device *dev,
en_dbg(DRV, priv, "ptys_reg.eth_proto_lp_adv %x\n",
be32_to_cpu(ptys_reg.eth_proto_lp_adv));
- cmd->supported = 0;
- cmd->advertising = 0;
+ eth_supported = 0;
+ eth_advertising = 0;
- cmd->supported |= ptys_get_supported_port(&ptys_reg);
+ eth_supported |= ptys_get_supported_port(&ptys_reg);
eth_proto = be32_to_cpu(ptys_reg.eth_proto_cap);
- cmd->supported |= ptys2ethtool_link_modes(eth_proto, SUPPORTED);
+ eth_supported |= ptys2ethtool_link_modes(eth_proto, SUPPORTED);
eth_proto = be32_to_cpu(ptys_reg.eth_proto_admin);
- cmd->advertising |= ptys2ethtool_link_modes(eth_proto, ADVERTISED);
+ eth_advertising |= ptys2ethtool_link_modes(eth_proto, ADVERTISED);
- cmd->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
- cmd->advertising |= (priv->prof->tx_pause) ? ADVERTISED_Pause : 0;
+ eth_supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
+ eth_advertising |= (priv->prof->tx_pause) ? ADVERTISED_Pause : 0;
- cmd->advertising |= (priv->prof->tx_pause ^ priv->prof->rx_pause) ?
+ eth_advertising |= (priv->prof->tx_pause ^ priv->prof->rx_pause) ?
ADVERTISED_Asym_Pause : 0;
cmd->port = ptys_get_active_port(&ptys_reg);
- cmd->transceiver = (SUPPORTED_TP & cmd->supported) ?
+ cmd->transceiver = (SUPPORTED_TP & eth_supported) ?
XCVR_EXTERNAL : XCVR_INTERNAL;
if (mlx4_en_autoneg_get(dev)) {
- cmd->supported |= SUPPORTED_Autoneg;
- cmd->advertising |= ADVERTISED_Autoneg;
+ eth_supported |= SUPPORTED_Autoneg;
+ eth_advertising |= ADVERTISED_Autoneg;
}
cmd->autoneg = (priv->port_state.flags & MLX4_EN_PORT_ANC) ?
AUTONEG_ENABLE : AUTONEG_DISABLE;
eth_proto = be32_to_cpu(ptys_reg.eth_proto_lp_adv);
- cmd->lp_advertising = ptys2ethtool_link_modes(eth_proto, ADVERTISED);
+ eth_lp_advertising = ptys2ethtool_link_modes(eth_proto, ADVERTISED);
- cmd->lp_advertising |= (priv->port_state.flags & MLX4_EN_PORT_ANC) ?
+ eth_lp_advertising |= (priv->port_state.flags & MLX4_EN_PORT_ANC) ?
ADVERTISED_Autoneg : 0;
+ ethtool_cmd_supported_set(cmd, eth_supported);
+ ethtool_cmd_advertising_set(cmd, eth_advertising);
+ ethtool_cmd_lp_advertising_set(cmd, eth_lp_advertising);
cmd->phy_address = 0;
cmd->mdio_support = 0;
cmd->maxtxpkt = 0;
@@ -673,27 +687,30 @@ static void ethtool_get_default_settings(struct net_device *dev,
struct ethtool_cmd *cmd)
{
struct mlx4_en_priv *priv = netdev_priv(dev);
+ ethtool_link_mode_mask_t eth_supported, eth_advertising;
int trans_type;
cmd->autoneg = AUTONEG_DISABLE;
- cmd->supported = SUPPORTED_10000baseT_Full;
- cmd->advertising = ADVERTISED_10000baseT_Full;
+ eth_supported = SUPPORTED_10000baseT_Full;
+ eth_advertising = ADVERTISED_10000baseT_Full;
trans_type = priv->port_state.transceiver;
if (trans_type > 0 && trans_type <= 0xC) {
cmd->port = PORT_FIBRE;
cmd->transceiver = XCVR_EXTERNAL;
- cmd->supported |= SUPPORTED_FIBRE;
- cmd->advertising |= ADVERTISED_FIBRE;
+ eth_supported |= SUPPORTED_FIBRE;
+ eth_advertising |= ADVERTISED_FIBRE;
} else if (trans_type == 0x80 || trans_type == 0) {
cmd->port = PORT_TP;
cmd->transceiver = XCVR_INTERNAL;
- cmd->supported |= SUPPORTED_TP;
- cmd->advertising |= ADVERTISED_TP;
+ eth_supported |= SUPPORTED_TP;
+ eth_advertising |= ADVERTISED_TP;
} else {
cmd->port = -1;
cmd->transceiver = -1;
}
+ ethtool_cmd_supported_set(cmd, eth_supported);
+ ethtool_cmd_advertising_set(cmd, eth_advertising);
}
static int mlx4_en_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
@@ -747,13 +764,14 @@ static int mlx4_en_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_ptys_reg ptys_reg;
__be32 proto_admin;
+ const ethtool_link_mode_mask_t eth_adv = ethtool_cmd_advertising(cmd);
int ret;
- u32 ptys_adv = ethtool2ptys_link_modes(cmd->advertising, ADVERTISED);
+ u32 ptys_adv = ethtool2ptys_link_modes(eth_adv, ADVERTISED);
int speed = ethtool_cmd_speed(cmd);
- en_dbg(DRV, priv, "Set Speed=%d adv=0x%x autoneg=%d duplex=%d\n",
- speed, cmd->advertising, cmd->autoneg, cmd->duplex);
+ en_dbg(DRV, priv, "Set Speed=%d adv=0x%llx autoneg=%d duplex=%d\n",
+ speed, eth_adv, cmd->autoneg, cmd->duplex);
if (!(priv->mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ETH_PROT_CTRL) ||
(cmd->duplex == DUPLEX_HALF))
@@ -1821,6 +1839,7 @@ static int mlx4_en_get_module_eeprom(struct net_device *dev,
}
const struct ethtool_ops mlx4_en_ethtool_ops = {
+ .get_compat_flags = mlx4_en_get_compat_flags,
.get_drvinfo = mlx4_en_get_drvinfo,
.get_settings = mlx4_en_get_settings,
.set_settings = mlx4_en_set_settings,
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply related
* [PATCH net-next v2 7/8] net: tun: extend link mode support to 48 bits
From: David Decotigny @ 2015-01-06 2:54 UTC (permalink / raw)
To: Amir Vadai, Florian Fainelli, netdev, linux-kernel, linux-api
Cc: David Decotigny, David S. Miller, Jason Wang, Michael S. Tsirkin,
Herbert Xu, Al Viro, Ben Hutchings, Masatake YAMATO, Xi Wang,
Neil Horman, WANG Cong, Flavio Leitner, Tom Gundersen, Jiri Pirko,
Vlad Yasevich, Eric W. Biederman, Saeed Mahameed, Venkata Duvvuru,
Govindarajulu Varadarajan
In-Reply-To: <1420512850-24699-1-git-send-email-ddecotig@gmail.com>
From: David Decotigny <decot@googlers.com>
Signed-off-by: David Decotigny <decot@googlers.com>
---
drivers/net/tun.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index c0df872..88f9078 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -2257,8 +2257,8 @@ static struct miscdevice tun_miscdev = {
static int tun_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
- cmd->supported = 0;
- cmd->advertising = 0;
+ ethtool_cmd_supported_set(cmd, 0);
+ ethtool_cmd_advertising_set(cmd, 0);
ethtool_cmd_speed_set(cmd, SPEED_10);
cmd->duplex = DUPLEX_FULL;
cmd->port = PORT_TP;
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox