* [PATCH net-next 1/8] r8169: remove unneeded call to __rtl8169_set_features in rtl_open
From: Heiner Kallweit @ 2018-04-28 20:19 UTC (permalink / raw)
To: David Miller, Realtek linux nic maintainers; +Cc: netdev@vger.kernel.org
In-Reply-To: <9b5f541e-8725-46ca-4466-0c3295229252@gmail.com>
RxChkSum and RxVlan aren't touched outside __rtl8169_set_features
(except in probe), so they are always in sync with dev->features.
And the RxConfig flags are set in rtl_set_rx_mode() which is
called via dev_set_rx_mode() from __dev_open().
Therefore we can safely remove this call.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/realtek/r8169.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index a5d00ee9..d2656224 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -7637,8 +7637,6 @@ static int rtl_open(struct net_device *dev)
rtl8169_init_phy(dev, tp);
- __rtl8169_set_features(dev, dev->features);
-
rtl_pll_power_up(tp);
rtl_hw_start(tp);
--
2.17.0
^ permalink raw reply related
* [PATCH net-next 0/8] r8169: further improvements w/o functional change
From: Heiner Kallweit @ 2018-04-28 20:06 UTC (permalink / raw)
To: David Miller, Realtek linux nic maintainers; +Cc: netdev@vger.kernel.org
This series aims at further improving and simplifying the code w/o
any intended functional changes.
Series was tested on: RTL8169sb, RTL8168d, RTL8168e-vl
Heiner Kallweit (8):
r8169: remove unneeded call to __rtl8169_set_features in rtl_open
r8169: improve rtl8169_set_features
r8169: replace magic number for INTT mask with a constant
r8169: improve CPlusCmd handling
r8169: improve handling of CPCMD quirk mask
r8169: simplify rtl_hw_start_8169
r8169: remove calls to rtl_set_rx_mode
r8169: move common initializations to tp->hw_start
drivers/net/ethernet/realtek/r8169.c | 184 ++++++---------------------
1 file changed, 42 insertions(+), 142 deletions(-)
--
2.17.0
^ permalink raw reply
* Re: [PATCH bpf-next v8 09/10] tools/bpf: add a test for bpf_get_stack with raw tracepoint prog
From: Yonghong Song @ 2018-04-28 20:02 UTC (permalink / raw)
To: Alexei Starovoitov, Y Song
Cc: Alexei Starovoitov, Daniel Borkmann, netdev, kernel-team
In-Reply-To: <20180428190622.7cxrsqmxwn33cscf@ast-mbp>
On 4/28/18 12:06 PM, Alexei Starovoitov wrote:
> On Sat, Apr 28, 2018 at 11:17:30AM -0700, Y Song wrote:
>> On Sat, Apr 28, 2018 at 9:56 AM, Alexei Starovoitov
>> <alexei.starovoitov@gmail.com> wrote:
>>> On Sat, Apr 28, 2018 at 12:02:04AM -0700, Yonghong Song wrote:
>>>> The test attached a raw_tracepoint program to sched/sched_switch.
>>>> It tested to get stack for user space, kernel space and user
>>>> space with build_id request. It also tested to get user
>>>> and kernel stack into the same buffer with back-to-back
>>>> bpf_get_stack helper calls.
>>>>
>>>> Whenever the kernel stack is available, the user space
>>>> application will check to ensure that the kernel function
>>>> for raw_tracepoint ___bpf_prog_run is part of the stack.
>>>>
>>>> Signed-off-by: Yonghong Song <yhs@fb.com>
>>> ...
>>>> +static int get_stack_print_output(void *data, int size)
>>>> +{
>>>> + bool good_kern_stack = false, good_user_stack = false;
>>>> + const char *expected_func = "___bpf_prog_run";
>>>
>>> so the test works with interpreter only?
>>> I guess that's ok for now, but needs to fixed for
>>> configs with CONFIG_BPF_JIT_ALWAYS_ON=y
>>
>> I did not test CONFIG_BPF_JIT_ALWAYS_ON=y.
>> I can have a followup patch for this if the patch set does not need respin.
>
> I was thinking to apply the set and do the fix in the follow up,
> but testing it with jit_enable=1 I don't see it's failing,
> so something is wrong with the test.
Yes, it is because the return value test
if (CHECK(err < 0, "perf_event_poller", "err %d errno %d\n", err,
...
the "err < 0" is not right as all the return values are nonnegative.
> Also get_stack_raw_tp_action() keeps spawning new 'dd' in the background
> which is not killed after test stops.
> Please fix both issues in respin.
I will fix both and resend the patch.
^ permalink raw reply
* Re: [PATCH net-next v2 4/7] net: mscc: Add initial Ocelot switch support
From: kbuild test robot @ 2018-04-28 19:42 UTC (permalink / raw)
To: Alexandre Belloni
Cc: kbuild-all, David S . Miller, Allan Nielsen, razvan.stefanescu,
po.liu, Thomas Petazzoni, Andrew Lunn, Florian Fainelli, netdev,
devicetree, linux-kernel, linux-mips, Alexandre Belloni
In-Reply-To: <20180426195931.5393-5-alexandre.belloni@bootlin.com>
[-- Attachment #1: Type: text/plain, Size: 19662 bytes --]
Hi Alexandre,
I love your patch! Perhaps something to improve:
[auto build test WARNING on net-next/master]
url: https://github.com/0day-ci/linux/commits/Alexandre-Belloni/Microsemi-Ocelot-Ethernet-switch-support/20180429-024136
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sh
All warnings (new ones prefixed by >>):
In file included from include/linux/swab.h:5:0,
from include/uapi/linux/byteorder/little_endian.h:13,
from include/linux/byteorder/little_endian.h:5,
from arch/sh/include/uapi/asm/byteorder.h:6,
from arch/sh/include/asm/bitops.h:12,
from include/linux/bitops.h:38,
from include/linux/kernel.h:11,
from include/linux/interrupt.h:6,
from drivers/net/ethernet/mscc/ocelot_board.c:7:
drivers/net/ethernet/mscc/ocelot_board.c: In function 'ocelot_parse_ifh':
drivers/net/ethernet/mscc/ocelot_board.c:23:27: error: '_be32' undeclared (first use in this function); did you mean '__be32'?
ifh[i] = ntohl((__force _be32)ifh[i]);
^
include/uapi/linux/swab.h:117:32: note: in definition of macro '__swab32'
(__builtin_constant_p((__u32)(x)) ? \
^
include/linux/byteorder/generic.h:136:21: note: in expansion of macro '__be32_to_cpu'
#define ___ntohl(x) __be32_to_cpu(x)
^~~~~~~~~~~~~
include/linux/byteorder/generic.h:140:18: note: in expansion of macro '___ntohl'
#define ntohl(x) ___ntohl(x)
^~~~~~~~
drivers/net/ethernet/mscc/ocelot_board.c:23:12: note: in expansion of macro 'ntohl'
ifh[i] = ntohl((__force _be32)ifh[i]);
^~~~~
drivers/net/ethernet/mscc/ocelot_board.c:23:27: note: each undeclared identifier is reported only once for each function it appears in
ifh[i] = ntohl((__force _be32)ifh[i]);
^
include/uapi/linux/swab.h:117:32: note: in definition of macro '__swab32'
(__builtin_constant_p((__u32)(x)) ? \
^
include/linux/byteorder/generic.h:136:21: note: in expansion of macro '__be32_to_cpu'
#define ___ntohl(x) __be32_to_cpu(x)
^~~~~~~~~~~~~
include/linux/byteorder/generic.h:140:18: note: in expansion of macro '___ntohl'
#define ntohl(x) ___ntohl(x)
^~~~~~~~
drivers/net/ethernet/mscc/ocelot_board.c:23:12: note: in expansion of macro 'ntohl'
ifh[i] = ntohl((__force _be32)ifh[i]);
^~~~~
drivers/net/ethernet/mscc/ocelot_board.c:23:33: error: expected ')' before 'ifh'
ifh[i] = ntohl((__force _be32)ifh[i]);
^
include/uapi/linux/swab.h:117:32: note: in definition of macro '__swab32'
(__builtin_constant_p((__u32)(x)) ? \
^
include/linux/byteorder/generic.h:136:21: note: in expansion of macro '__be32_to_cpu'
#define ___ntohl(x) __be32_to_cpu(x)
^~~~~~~~~~~~~
include/linux/byteorder/generic.h:140:18: note: in expansion of macro '___ntohl'
#define ntohl(x) ___ntohl(x)
^~~~~~~~
drivers/net/ethernet/mscc/ocelot_board.c:23:12: note: in expansion of macro 'ntohl'
ifh[i] = ntohl((__force _be32)ifh[i]);
^~~~~
drivers/net/ethernet/mscc/ocelot_board.c:23:33: error: expected ')' before 'ifh'
ifh[i] = ntohl((__force _be32)ifh[i]);
^
include/uapi/linux/swab.h:18:12: note: in definition of macro '___constant_swab32'
(((__u32)(x) & (__u32)0x000000ffUL) << 24) | \
^
>> include/uapi/linux/byteorder/little_endian.h:40:26: note: in expansion of macro '__swab32'
#define __be32_to_cpu(x) __swab32((__force __u32)(__be32)(x))
^~~~~~~~
include/linux/byteorder/generic.h:136:21: note: in expansion of macro '__be32_to_cpu'
#define ___ntohl(x) __be32_to_cpu(x)
^~~~~~~~~~~~~
include/linux/byteorder/generic.h:140:18: note: in expansion of macro '___ntohl'
#define ntohl(x) ___ntohl(x)
^~~~~~~~
drivers/net/ethernet/mscc/ocelot_board.c:23:12: note: in expansion of macro 'ntohl'
ifh[i] = ntohl((__force _be32)ifh[i]);
^~~~~
drivers/net/ethernet/mscc/ocelot_board.c:23:33: error: expected ')' before 'ifh'
ifh[i] = ntohl((__force _be32)ifh[i]);
^
include/uapi/linux/swab.h:19:12: note: in definition of macro '___constant_swab32'
(((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \
^
>> include/uapi/linux/byteorder/little_endian.h:40:26: note: in expansion of macro '__swab32'
#define __be32_to_cpu(x) __swab32((__force __u32)(__be32)(x))
^~~~~~~~
include/linux/byteorder/generic.h:136:21: note: in expansion of macro '__be32_to_cpu'
#define ___ntohl(x) __be32_to_cpu(x)
^~~~~~~~~~~~~
include/linux/byteorder/generic.h:140:18: note: in expansion of macro '___ntohl'
#define ntohl(x) ___ntohl(x)
^~~~~~~~
drivers/net/ethernet/mscc/ocelot_board.c:23:12: note: in expansion of macro 'ntohl'
ifh[i] = ntohl((__force _be32)ifh[i]);
^~~~~
drivers/net/ethernet/mscc/ocelot_board.c:23:33: error: expected ')' before 'ifh'
ifh[i] = ntohl((__force _be32)ifh[i]);
^
include/uapi/linux/swab.h:20:12: note: in definition of macro '___constant_swab32'
(((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \
^
>> include/uapi/linux/byteorder/little_endian.h:40:26: note: in expansion of macro '__swab32'
#define __be32_to_cpu(x) __swab32((__force __u32)(__be32)(x))
^~~~~~~~
include/linux/byteorder/generic.h:136:21: note: in expansion of macro '__be32_to_cpu'
#define ___ntohl(x) __be32_to_cpu(x)
^~~~~~~~~~~~~
include/linux/byteorder/generic.h:140:18: note: in expansion of macro '___ntohl'
#define ntohl(x) ___ntohl(x)
^~~~~~~~
drivers/net/ethernet/mscc/ocelot_board.c:23:12: note: in expansion of macro 'ntohl'
ifh[i] = ntohl((__force _be32)ifh[i]);
^~~~~
drivers/net/ethernet/mscc/ocelot_board.c:23:33: error: expected ')' before 'ifh'
ifh[i] = ntohl((__force _be32)ifh[i]);
^
include/uapi/linux/swab.h:21:12: note: in definition of macro '___constant_swab32'
(((__u32)(x) & (__u32)0xff000000UL) >> 24)))
^
>> include/uapi/linux/byteorder/little_endian.h:40:26: note: in expansion of macro '__swab32'
#define __be32_to_cpu(x) __swab32((__force __u32)(__be32)(x))
^~~~~~~~
include/linux/byteorder/generic.h:136:21: note: in expansion of macro '__be32_to_cpu'
#define ___ntohl(x) __be32_to_cpu(x)
^~~~~~~~~~~~~
include/linux/byteorder/generic.h:140:18: note: in expansion of macro '___ntohl'
#define ntohl(x) ___ntohl(x)
^~~~~~~~
drivers/net/ethernet/mscc/ocelot_board.c:23:12: note: in expansion of macro 'ntohl'
ifh[i] = ntohl((__force _be32)ifh[i]);
^~~~~
drivers/net/ethernet/mscc/ocelot_board.c:23:33: error: expected ')' before 'ifh'
ifh[i] = ntohl((__force _be32)ifh[i]);
^
include/uapi/linux/swab.h:119:12: note: in definition of macro '__swab32'
__fswab32(x))
^
include/linux/byteorder/generic.h:136:21: note: in expansion of macro '__be32_to_cpu'
#define ___ntohl(x) __be32_to_cpu(x)
^~~~~~~~~~~~~
include/linux/byteorder/generic.h:140:18: note: in expansion of macro '___ntohl'
#define ntohl(x) ___ntohl(x)
^~~~~~~~
drivers/net/ethernet/mscc/ocelot_board.c:23:12: note: in expansion of macro 'ntohl'
ifh[i] = ntohl((__force _be32)ifh[i]);
^~~~~
--
In file included from include/linux/swab.h:5:0,
from include/uapi/linux/byteorder/little_endian.h:13,
from include/linux/byteorder/little_endian.h:5,
from arch/sh/include/uapi/asm/byteorder.h:6,
from arch/sh/include/asm/bitops.h:12,
from include/linux/bitops.h:38,
from include/linux/kernel.h:11,
from include/linux/interrupt.h:6,
from drivers/net//ethernet/mscc/ocelot_board.c:7:
drivers/net//ethernet/mscc/ocelot_board.c: In function 'ocelot_parse_ifh':
drivers/net//ethernet/mscc/ocelot_board.c:23:27: error: '_be32' undeclared (first use in this function); did you mean '__be32'?
ifh[i] = ntohl((__force _be32)ifh[i]);
^
include/uapi/linux/swab.h:117:32: note: in definition of macro '__swab32'
(__builtin_constant_p((__u32)(x)) ? \
^
include/linux/byteorder/generic.h:136:21: note: in expansion of macro '__be32_to_cpu'
#define ___ntohl(x) __be32_to_cpu(x)
^~~~~~~~~~~~~
include/linux/byteorder/generic.h:140:18: note: in expansion of macro '___ntohl'
#define ntohl(x) ___ntohl(x)
^~~~~~~~
drivers/net//ethernet/mscc/ocelot_board.c:23:12: note: in expansion of macro 'ntohl'
ifh[i] = ntohl((__force _be32)ifh[i]);
^~~~~
drivers/net//ethernet/mscc/ocelot_board.c:23:27: note: each undeclared identifier is reported only once for each function it appears in
ifh[i] = ntohl((__force _be32)ifh[i]);
^
include/uapi/linux/swab.h:117:32: note: in definition of macro '__swab32'
(__builtin_constant_p((__u32)(x)) ? \
^
include/linux/byteorder/generic.h:136:21: note: in expansion of macro '__be32_to_cpu'
#define ___ntohl(x) __be32_to_cpu(x)
^~~~~~~~~~~~~
include/linux/byteorder/generic.h:140:18: note: in expansion of macro '___ntohl'
#define ntohl(x) ___ntohl(x)
^~~~~~~~
drivers/net//ethernet/mscc/ocelot_board.c:23:12: note: in expansion of macro 'ntohl'
ifh[i] = ntohl((__force _be32)ifh[i]);
^~~~~
drivers/net//ethernet/mscc/ocelot_board.c:23:33: error: expected ')' before 'ifh'
ifh[i] = ntohl((__force _be32)ifh[i]);
^
include/uapi/linux/swab.h:117:32: note: in definition of macro '__swab32'
(__builtin_constant_p((__u32)(x)) ? \
^
include/linux/byteorder/generic.h:136:21: note: in expansion of macro '__be32_to_cpu'
#define ___ntohl(x) __be32_to_cpu(x)
^~~~~~~~~~~~~
include/linux/byteorder/generic.h:140:18: note: in expansion of macro '___ntohl'
#define ntohl(x) ___ntohl(x)
^~~~~~~~
drivers/net//ethernet/mscc/ocelot_board.c:23:12: note: in expansion of macro 'ntohl'
ifh[i] = ntohl((__force _be32)ifh[i]);
^~~~~
drivers/net//ethernet/mscc/ocelot_board.c:23:33: error: expected ')' before 'ifh'
ifh[i] = ntohl((__force _be32)ifh[i]);
^
include/uapi/linux/swab.h:18:12: note: in definition of macro '___constant_swab32'
(((__u32)(x) & (__u32)0x000000ffUL) << 24) | \
^
>> include/uapi/linux/byteorder/little_endian.h:40:26: note: in expansion of macro '__swab32'
#define __be32_to_cpu(x) __swab32((__force __u32)(__be32)(x))
^~~~~~~~
include/linux/byteorder/generic.h:136:21: note: in expansion of macro '__be32_to_cpu'
#define ___ntohl(x) __be32_to_cpu(x)
^~~~~~~~~~~~~
include/linux/byteorder/generic.h:140:18: note: in expansion of macro '___ntohl'
#define ntohl(x) ___ntohl(x)
^~~~~~~~
drivers/net//ethernet/mscc/ocelot_board.c:23:12: note: in expansion of macro 'ntohl'
ifh[i] = ntohl((__force _be32)ifh[i]);
^~~~~
drivers/net//ethernet/mscc/ocelot_board.c:23:33: error: expected ')' before 'ifh'
ifh[i] = ntohl((__force _be32)ifh[i]);
^
include/uapi/linux/swab.h:19:12: note: in definition of macro '___constant_swab32'
(((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \
^
>> include/uapi/linux/byteorder/little_endian.h:40:26: note: in expansion of macro '__swab32'
#define __be32_to_cpu(x) __swab32((__force __u32)(__be32)(x))
^~~~~~~~
include/linux/byteorder/generic.h:136:21: note: in expansion of macro '__be32_to_cpu'
#define ___ntohl(x) __be32_to_cpu(x)
^~~~~~~~~~~~~
include/linux/byteorder/generic.h:140:18: note: in expansion of macro '___ntohl'
#define ntohl(x) ___ntohl(x)
^~~~~~~~
drivers/net//ethernet/mscc/ocelot_board.c:23:12: note: in expansion of macro 'ntohl'
ifh[i] = ntohl((__force _be32)ifh[i]);
^~~~~
drivers/net//ethernet/mscc/ocelot_board.c:23:33: error: expected ')' before 'ifh'
ifh[i] = ntohl((__force _be32)ifh[i]);
^
include/uapi/linux/swab.h:20:12: note: in definition of macro '___constant_swab32'
(((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \
^
>> include/uapi/linux/byteorder/little_endian.h:40:26: note: in expansion of macro '__swab32'
#define __be32_to_cpu(x) __swab32((__force __u32)(__be32)(x))
^~~~~~~~
include/linux/byteorder/generic.h:136:21: note: in expansion of macro '__be32_to_cpu'
#define ___ntohl(x) __be32_to_cpu(x)
^~~~~~~~~~~~~
include/linux/byteorder/generic.h:140:18: note: in expansion of macro '___ntohl'
#define ntohl(x) ___ntohl(x)
^~~~~~~~
drivers/net//ethernet/mscc/ocelot_board.c:23:12: note: in expansion of macro 'ntohl'
ifh[i] = ntohl((__force _be32)ifh[i]);
^~~~~
drivers/net//ethernet/mscc/ocelot_board.c:23:33: error: expected ')' before 'ifh'
ifh[i] = ntohl((__force _be32)ifh[i]);
^
include/uapi/linux/swab.h:21:12: note: in definition of macro '___constant_swab32'
(((__u32)(x) & (__u32)0xff000000UL) >> 24)))
^
>> include/uapi/linux/byteorder/little_endian.h:40:26: note: in expansion of macro '__swab32'
#define __be32_to_cpu(x) __swab32((__force __u32)(__be32)(x))
^~~~~~~~
include/linux/byteorder/generic.h:136:21: note: in expansion of macro '__be32_to_cpu'
#define ___ntohl(x) __be32_to_cpu(x)
^~~~~~~~~~~~~
include/linux/byteorder/generic.h:140:18: note: in expansion of macro '___ntohl'
#define ntohl(x) ___ntohl(x)
^~~~~~~~
drivers/net//ethernet/mscc/ocelot_board.c:23:12: note: in expansion of macro 'ntohl'
ifh[i] = ntohl((__force _be32)ifh[i]);
^~~~~
drivers/net//ethernet/mscc/ocelot_board.c:23:33: error: expected ')' before 'ifh'
ifh[i] = ntohl((__force _be32)ifh[i]);
^
include/uapi/linux/swab.h:119:12: note: in definition of macro '__swab32'
__fswab32(x))
^
include/linux/byteorder/generic.h:136:21: note: in expansion of macro '__be32_to_cpu'
#define ___ntohl(x) __be32_to_cpu(x)
^~~~~~~~~~~~~
include/linux/byteorder/generic.h:140:18: note: in expansion of macro '___ntohl'
#define ntohl(x) ___ntohl(x)
^~~~~~~~
drivers/net//ethernet/mscc/ocelot_board.c:23:12: note: in expansion of macro 'ntohl'
ifh[i] = ntohl((__force _be32)ifh[i]);
^~~~~
vim +/__swab32 +40 include/uapi/linux/byteorder/little_endian.h
5921e6f8 David Howells 2012-10-13 14
5921e6f8 David Howells 2012-10-13 15 #define __constant_htonl(x) ((__force __be32)___constant_swab32((x)))
5921e6f8 David Howells 2012-10-13 16 #define __constant_ntohl(x) ___constant_swab32((__force __be32)(x))
5921e6f8 David Howells 2012-10-13 17 #define __constant_htons(x) ((__force __be16)___constant_swab16((x)))
5921e6f8 David Howells 2012-10-13 18 #define __constant_ntohs(x) ___constant_swab16((__force __be16)(x))
5921e6f8 David Howells 2012-10-13 19 #define __constant_cpu_to_le64(x) ((__force __le64)(__u64)(x))
5921e6f8 David Howells 2012-10-13 20 #define __constant_le64_to_cpu(x) ((__force __u64)(__le64)(x))
5921e6f8 David Howells 2012-10-13 21 #define __constant_cpu_to_le32(x) ((__force __le32)(__u32)(x))
5921e6f8 David Howells 2012-10-13 22 #define __constant_le32_to_cpu(x) ((__force __u32)(__le32)(x))
5921e6f8 David Howells 2012-10-13 23 #define __constant_cpu_to_le16(x) ((__force __le16)(__u16)(x))
5921e6f8 David Howells 2012-10-13 24 #define __constant_le16_to_cpu(x) ((__force __u16)(__le16)(x))
5921e6f8 David Howells 2012-10-13 25 #define __constant_cpu_to_be64(x) ((__force __be64)___constant_swab64((x)))
5921e6f8 David Howells 2012-10-13 26 #define __constant_be64_to_cpu(x) ___constant_swab64((__force __u64)(__be64)(x))
5921e6f8 David Howells 2012-10-13 27 #define __constant_cpu_to_be32(x) ((__force __be32)___constant_swab32((x)))
5921e6f8 David Howells 2012-10-13 28 #define __constant_be32_to_cpu(x) ___constant_swab32((__force __u32)(__be32)(x))
5921e6f8 David Howells 2012-10-13 29 #define __constant_cpu_to_be16(x) ((__force __be16)___constant_swab16((x)))
5921e6f8 David Howells 2012-10-13 30 #define __constant_be16_to_cpu(x) ___constant_swab16((__force __u16)(__be16)(x))
5921e6f8 David Howells 2012-10-13 31 #define __cpu_to_le64(x) ((__force __le64)(__u64)(x))
5921e6f8 David Howells 2012-10-13 32 #define __le64_to_cpu(x) ((__force __u64)(__le64)(x))
5921e6f8 David Howells 2012-10-13 33 #define __cpu_to_le32(x) ((__force __le32)(__u32)(x))
5921e6f8 David Howells 2012-10-13 34 #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
5921e6f8 David Howells 2012-10-13 35 #define __cpu_to_le16(x) ((__force __le16)(__u16)(x))
5921e6f8 David Howells 2012-10-13 36 #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
5921e6f8 David Howells 2012-10-13 37 #define __cpu_to_be64(x) ((__force __be64)__swab64((x)))
5921e6f8 David Howells 2012-10-13 38 #define __be64_to_cpu(x) __swab64((__force __u64)(__be64)(x))
5921e6f8 David Howells 2012-10-13 39 #define __cpu_to_be32(x) ((__force __be32)__swab32((x)))
5921e6f8 David Howells 2012-10-13 @40 #define __be32_to_cpu(x) __swab32((__force __u32)(__be32)(x))
5921e6f8 David Howells 2012-10-13 41 #define __cpu_to_be16(x) ((__force __be16)__swab16((x)))
5921e6f8 David Howells 2012-10-13 42 #define __be16_to_cpu(x) __swab16((__force __u16)(__be16)(x))
5921e6f8 David Howells 2012-10-13 43
:::::: The code at line 40 was first introduced by commit
:::::: 5921e6f8809b1616932ca4afd40fe449faa8fd88 UAPI: (Scripted) Disintegrate include/linux/byteorder
:::::: TO: David Howells <dhowells@redhat.com>
:::::: CC: David Howells <dhowells@redhat.com>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 47791 bytes --]
^ permalink raw reply
* [PATCH net-next 2/2 v4] netns: restrict uevents
From: Christian Brauner @ 2018-04-28 19:20 UTC (permalink / raw)
To: ebiederm, davem, netdev, linux-kernel
Cc: avagin, ktkhai, serge, gregkh, Christian Brauner
In-Reply-To: <20180428192025.2075-1-christian.brauner@ubuntu.com>
commit 07e98962fa77 ("kobject: Send hotplug events in all network namespaces")
enabled sending hotplug events into all network namespaces back in 2010.
Over time the set of uevents that get sent into all network namespaces has
shrunk. We have now reached the point where hotplug events for all devices
that carry a namespace tag are filtered according to that namespace.
Specifically, they are filtered whenever the namespace tag of the kobject
does not match the namespace tag of the netlink socket.
Currently, only network devices carry namespace tags (i.e. network
namespace tags). Hence, uevents for network devices only show up in the
network namespace such devices are created in or moved to.
However, any uevent for a kobject that does not have a namespace tag
associated with it will not be filtered and we will broadcast it into all
network namespaces. This behavior stopped making sense when user namespaces
were introduced.
This patch simplifies and fixes couple of things:
- Split codepath for sending uevents by kobject namespace tags:
1. Untagged kobjects - uevent_net_broadcast_untagged():
Untagged kobjects will be broadcast into all uevent sockets recorded
in uevent_sock_list, i.e. into all network namespacs owned by the
intial user namespace.
2. Tagged kobjects - uevent_net_broadcast_tagged():
Tagged kobjects will only be broadcast into the network namespace they
were tagged with.
Handling of tagged kobjects in 2. does not cause any semantic changes.
This is just splitting out the filtering logic that was handled by
kobj_bcast_filter() before.
Handling of untagged kobjects in 1. will cause a semantic change. The
reasons why this is needed and ok have been discussed in [1]. Here is a
short summary:
- Userspace ignores uevents from network namespaces that are not owned by
the intial user namespace:
Uevents are filtered by userspace in a user namespace because the
received uid != 0. Instead the uid associated with the event will be
65534 == "nobody" because the global root uid is not mapped.
This means we can safely and without introducing regressions modify the
kernel to not send uevents into all network namespaces whose owning
user namespace is not the initial user namespace because we know that
userspace will ignore the message because of the uid anyway.
I have a) verified that is is true for every udev implementation out
there b) that this behavior has been present in all udev
implementations from the very beginning.
- Thundering herd:
Broadcasting uevents into all network namespaces introduces significant
overhead.
All processes that listen to uevents running in non-initial user
namespaces will end up responding to uevents that will be meaningless
to them. Mainly, because non-initial user namespaces cannot easily
manage devices unless they have a privileged host-process helping them
out. This means that there will be a thundering herd of activity when
there shouldn't be any.
- Removing needless overhead/Increasing performance:
Currently, the uevent socket for each network namespace is added to the
global variable uevent_sock_list. The list itself needs to be protected
by a mutex. So everytime a uevent is generated the mutex is taken on
the list. The mutex is held *from the creation of the uevent (memory
allocation, string creation etc. until all uevent sockets have been
handled*. This is aggravated by the fact that for each uevent socket
that has listeners the mc_list must be walked as well which means we're
talking O(n^2) here. Given that a standard Linux workload usually has
quite a lot of network namespaces and - in the face of containers - a
lot of user namespaces this quickly becomes a performance problem (see
"Thundering herd" above). By just recording uevent sockets of network
namespaces that are owned by the initial user namespace we
significantly increase performance in this codepath.
- Injecting uevents:
There's a valid argument that containers might be interested in
receiving device events especially if they are delegated to them by a
privileged userspace process. One prime example are SR-IOV enabled
devices that are explicitly designed to be handed of to other users
such as VMs or containers.
This use-case can now be correctly handled since
commit 692ec06d7c92 ("netns: send uevent messages"). This commit
introduced the ability to send uevents from userspace. As such we can
let a sufficiently privileged (CAP_SYS_ADMIN in the owning user
namespace of the network namespace of the netlink socket) userspace
process make a decision what uevents should be sent. This removes the
need to blindly broadcast uevents into all user namespaces and provides
a performant and safe solution to this problem.
- Filtering logic:
This patch filters by *owning user namespace of the network namespace a
given task resides in* and not by user namespace of the task per se.
This means if the user namespace of a given task is unshared but the
network namespace is kept and is owned by the initial user namespace a
listener that is opening the uevent socket in that network namespace
can still listen to uevents.
- Fix permission for tagged kobjects:
Network devices that are created or moved into a network namespace that
is owned by a non-initial user namespace currently are send with
INVALID_{G,U}ID in their credentials. This means that all current udev
implementations in userspace will ignore the uevent they receive for
them. This has lead to weird bugs whereby new devices showing up in such
network namespaces were not recognized and did not get IPs assigned etc.
This patch adjusts the permission to the appropriate {g,u}id in the
respective user namespace. This way udevd is able to correctly handle
such devices.
- Simplify filtering logic:
do_one_broadcast() already ensures that only listeners in mc_list receive
uevents that have the same network namespace as the uevent socket itself.
So the filtering logic in kobj_bcast_filter is not needed (see [3]). This
patch therefore removes kobj_bcast_filter() and replaces
netlink_broadcast_filtered() with the simpler netlink_broadcast()
everywhere.
[1]: https://lkml.org/lkml/2018/4/4/739
[2]: https://lkml.org/lkml/2018/4/26/767
[3]: https://lkml.org/lkml/2018/4/26/738
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
---
v3->v4:
* patch unchanged
v2->v3:
* new approach: patch added
v1->v2:
* old approach: different patchset
v0->v1:
* old approach: different patchset
---
lib/kobject_uevent.c | 139 ++++++++++++++++++++++++++++++-------------
1 file changed, 97 insertions(+), 42 deletions(-)
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 649bf60a9440..d5300056bc0c 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -232,30 +232,6 @@ int kobject_synth_uevent(struct kobject *kobj, const char *buf, size_t count)
return r;
}
-#ifdef CONFIG_NET
-static int kobj_bcast_filter(struct sock *dsk, struct sk_buff *skb, void *data)
-{
- struct kobject *kobj = data, *ksobj;
- const struct kobj_ns_type_operations *ops;
-
- ops = kobj_ns_ops(kobj);
- if (!ops && kobj->kset) {
- ksobj = &kobj->kset->kobj;
- if (ksobj->parent != NULL)
- ops = kobj_ns_ops(ksobj->parent);
- }
-
- if (ops && ops->netlink_ns && kobj->ktype->namespace) {
- const void *sock_ns, *ns;
- ns = kobj->ktype->namespace(kobj);
- sock_ns = ops->netlink_ns(dsk);
- return sock_ns != ns;
- }
-
- return 0;
-}
-#endif
-
#ifdef CONFIG_UEVENT_HELPER
static int kobj_usermode_filter(struct kobject *kobj)
{
@@ -327,17 +303,14 @@ static struct sk_buff *alloc_uevent_skb(struct kobj_uevent_env *env,
return skb;
}
-#endif
-static int kobject_uevent_net_broadcast(struct kobject *kobj,
- struct kobj_uevent_env *env,
- const char *action_string,
- const char *devpath)
+static int uevent_net_broadcast_untagged(struct kobj_uevent_env *env,
+ const char *action_string,
+ const char *devpath)
{
- int retval = 0;
-#if defined(CONFIG_NET)
struct sk_buff *skb = NULL;
struct uevent_sock *ue_sk;
+ int retval = 0;
/* send netlink message */
list_for_each_entry(ue_sk, &uevent_sock_list, list) {
@@ -353,19 +326,95 @@ static int kobject_uevent_net_broadcast(struct kobject *kobj,
continue;
}
- retval = netlink_broadcast_filtered(uevent_sock, skb_get(skb),
- 0, 1, GFP_KERNEL,
- kobj_bcast_filter,
- kobj);
+ retval = netlink_broadcast(uevent_sock, skb_get(skb), 0, 1,
+ GFP_KERNEL);
/* ENOBUFS should be handled in userspace */
if (retval == -ENOBUFS || retval == -ESRCH)
retval = 0;
}
consume_skb(skb);
-#endif
+
return retval;
}
+static int uevent_net_broadcast_tagged(struct sock *usk,
+ struct kobj_uevent_env *env,
+ const char *action_string,
+ const char *devpath)
+{
+ struct user_namespace *owning_user_ns = sock_net(usk)->user_ns;
+ struct sk_buff *skb = NULL;
+ int ret = 0;
+
+ skb = alloc_uevent_skb(env, action_string, devpath);
+ if (!skb)
+ return -ENOMEM;
+
+ /* fix credentials */
+ if (owning_user_ns != &init_user_ns) {
+ struct netlink_skb_parms *parms = &NETLINK_CB(skb);
+ kuid_t root_uid;
+ kgid_t root_gid;
+
+ /* fix uid */
+ root_uid = make_kuid(owning_user_ns, 0);
+ if (!uid_valid(root_uid))
+ root_uid = GLOBAL_ROOT_UID;
+ parms->creds.uid = root_uid;
+
+ /* fix gid */
+ root_gid = make_kgid(owning_user_ns, 0);
+ if (!gid_valid(root_gid))
+ root_gid = GLOBAL_ROOT_GID;
+ parms->creds.gid = root_gid;
+ }
+
+ ret = netlink_broadcast(usk, skb, 0, 1, GFP_KERNEL);
+ /* ENOBUFS should be handled in userspace */
+ if (ret == -ENOBUFS || ret == -ESRCH)
+ ret = 0;
+
+ return ret;
+}
+#endif
+
+static int kobject_uevent_net_broadcast(struct kobject *kobj,
+ struct kobj_uevent_env *env,
+ const char *action_string,
+ const char *devpath)
+{
+ int ret = 0;
+
+#ifdef CONFIG_NET
+ const struct kobj_ns_type_operations *ops;
+ const struct net *net = NULL;
+
+ ops = kobj_ns_ops(kobj);
+ if (!ops && kobj->kset) {
+ struct kobject *ksobj = &kobj->kset->kobj;
+ if (ksobj->parent != NULL)
+ ops = kobj_ns_ops(ksobj->parent);
+ }
+
+ /* kobjects currently only carry network namespace tags and they
+ * are the only tag relevant here since we want to decide which
+ * network namespaces to broadcast the uevent into.
+ */
+ if (ops && ops->netlink_ns && kobj->ktype->namespace)
+ if (ops->type == KOBJ_NS_TYPE_NET)
+ net = kobj->ktype->namespace(kobj);
+
+ if (!net)
+ ret = uevent_net_broadcast_untagged(env, action_string,
+ devpath);
+ else
+ ret = uevent_net_broadcast_tagged(net->uevent_sock->sk, env,
+ action_string, devpath);
+#endif
+
+ return ret;
+}
+
static void zap_modalias_env(struct kobj_uevent_env *env)
{
static const char modalias_prefix[] = "MODALIAS=";
@@ -724,9 +773,13 @@ static int uevent_net_init(struct net *net)
net->uevent_sock = ue_sk;
- mutex_lock(&uevent_sock_mutex);
- list_add_tail(&ue_sk->list, &uevent_sock_list);
- mutex_unlock(&uevent_sock_mutex);
+ /* Restrict uevents to initial user namespace. */
+ if (sock_net(ue_sk->sk)->user_ns == &init_user_ns) {
+ mutex_lock(&uevent_sock_mutex);
+ list_add_tail(&ue_sk->list, &uevent_sock_list);
+ mutex_unlock(&uevent_sock_mutex);
+ }
+
return 0;
}
@@ -734,9 +787,11 @@ static void uevent_net_exit(struct net *net)
{
struct uevent_sock *ue_sk = net->uevent_sock;
- mutex_lock(&uevent_sock_mutex);
- list_del(&ue_sk->list);
- mutex_unlock(&uevent_sock_mutex);
+ if (sock_net(ue_sk->sk)->user_ns == &init_user_ns) {
+ mutex_lock(&uevent_sock_mutex);
+ list_del(&ue_sk->list);
+ mutex_unlock(&uevent_sock_mutex);
+ }
netlink_kernel_release(ue_sk->sk);
kfree(ue_sk);
--
2.17.0
^ permalink raw reply related
* [PATCH net-next 1/2 v4] uevent: add alloc_uevent_skb() helper
From: Christian Brauner @ 2018-04-28 19:20 UTC (permalink / raw)
To: ebiederm, davem, netdev, linux-kernel
Cc: avagin, ktkhai, serge, gregkh, Christian Brauner
In-Reply-To: <20180428192025.2075-1-christian.brauner@ubuntu.com>
This patch adds alloc_uevent_skb() in preparation for follow up patches.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
---
v3->v4:
* non-functional changes:
initialize some variables again explicitly to make it obvious to
readers that they are correctly set
v2->v3:
* new approach: patch added
v1->v2:
* different approach in different patchset
v0->v1:
* different approach in different patchset
---
lib/kobject_uevent.c | 47 ++++++++++++++++++++++++++++++++------------
1 file changed, 34 insertions(+), 13 deletions(-)
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 15ea216a67ce..649bf60a9440 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -22,6 +22,7 @@
#include <linux/socket.h>
#include <linux/skbuff.h>
#include <linux/netlink.h>
+#include <linux/uidgid.h>
#include <linux/uuid.h>
#include <linux/ctype.h>
#include <net/sock.h>
@@ -296,6 +297,38 @@ static void cleanup_uevent_env(struct subprocess_info *info)
}
#endif
+#ifdef CONFIG_NET
+static struct sk_buff *alloc_uevent_skb(struct kobj_uevent_env *env,
+ const char *action_string,
+ const char *devpath)
+{
+ struct netlink_skb_parms *parms;
+ struct sk_buff *skb = NULL;
+ char *scratch;
+ size_t len;
+
+ /* allocate message with maximum possible size */
+ len = strlen(action_string) + strlen(devpath) + 2;
+ skb = alloc_skb(len + env->buflen, GFP_KERNEL);
+ if (!skb)
+ return NULL;
+
+ /* add header */
+ scratch = skb_put(skb, len);
+ sprintf(scratch, "%s@%s", action_string, devpath);
+
+ skb_put_data(skb, env->buf, env->buflen);
+
+ parms = &NETLINK_CB(skb);
+ parms->creds.uid = GLOBAL_ROOT_UID;
+ parms->creds.gid = GLOBAL_ROOT_GID;
+ parms->dst_group = 1;
+ parms->portid = 0;
+
+ return skb;
+}
+#endif
+
static int kobject_uevent_net_broadcast(struct kobject *kobj,
struct kobj_uevent_env *env,
const char *action_string,
@@ -314,22 +347,10 @@ static int kobject_uevent_net_broadcast(struct kobject *kobj,
continue;
if (!skb) {
- /* allocate message with the maximum possible size */
- size_t len = strlen(action_string) + strlen(devpath) + 2;
- char *scratch;
-
retval = -ENOMEM;
- skb = alloc_skb(len + env->buflen, GFP_KERNEL);
+ skb = alloc_uevent_skb(env, action_string, devpath);
if (!skb)
continue;
-
- /* add header */
- scratch = skb_put(skb, len);
- sprintf(scratch, "%s@%s", action_string, devpath);
-
- skb_put_data(skb, env->buf, env->buflen);
-
- NETLINK_CB(skb).dst_group = 1;
}
retval = netlink_broadcast_filtered(uevent_sock, skb_get(skb),
--
2.17.0
^ permalink raw reply related
* [PATCH net-next 0/2 v4] netns: uevent filtering
From: Christian Brauner @ 2018-04-28 19:20 UTC (permalink / raw)
To: ebiederm, davem, netdev, linux-kernel
Cc: avagin, ktkhai, serge, gregkh, Christian Brauner
Hey everyone,
This is the new approach to uevent filtering as discussed (see the
threads in [1], [2], and [3]). It only contains *non-functional
changes*.
This series deals with with fixing up uevent filtering logic:
- uevent filtering logic is simplified
- locking time on uevent_sock_list is minimized
- tagged and untagged kobjects are handled in separate codepaths
- permissions for userspace are fixed for network device uevents in
network namespaces owned by non-initial user namespaces
Udev is now able to see those events correctly which it wasn't before.
For example, moving a physical device into a network namespace not
owned by the initial user namespaces before gave:
root@xen1:~# udevadm --debug monitor -k
calling: monitor
monitor will print the received events for:
KERNEL - the kernel uevent
sender uid=65534, message ignored
sender uid=65534, message ignored
sender uid=65534, message ignored
sender uid=65534, message ignored
sender uid=65534, message ignored
and now after the discussion and solution in [3] correctly gives:
root@xen1:~# udevadm --debug monitor -k
calling: monitor
monitor will print the received events for:
KERNEL - the kernel uevent
KERNEL[625.301042] add /devices/pci0000:00/0000:00:02.0/0000:01:00.1/net/enp1s0f1 (net)
KERNEL[625.301109] move /devices/pci0000:00/0000:00:02.0/0000:01:00.1/net/enp1s0f1 (net)
KERNEL[625.301138] move /devices/pci0000:00/0000:00:02.0/0000:01:00.1/net/eth1 (net)
KERNEL[655.333272] remove /devices/pci0000:00/0000:00:02.0/0000:01:00.1/net/eth1 (net)
Thanks!
Christian
[1]: https://lkml.org/lkml/2018/4/4/739
[2]: https://lkml.org/lkml/2018/4/26/767
[3]: https://lkml.org/lkml/2018/4/26/738
Christian Brauner (2):
uevent: add alloc_uevent_skb() helper
netns: restrict uevents
lib/kobject_uevent.c | 180 ++++++++++++++++++++++++++++++-------------
1 file changed, 128 insertions(+), 52 deletions(-)
--
2.17.0
^ permalink raw reply
* Re: [PATCH net-next 2/2 v3] netns: restrict uevents
From: Christian Brauner @ 2018-04-28 19:13 UTC (permalink / raw)
To: Eric W. Biederman
Cc: davem, netdev, linux-kernel, avagin, ktkhai, serge, gregkh
In-Reply-To: <87po2k7gt9.fsf@xmission.com>
On Fri, Apr 27, 2018 at 11:30:26AM -0500, Eric W. Biederman wrote:
> Christian Brauner <christian.brauner@ubuntu.com> writes:
> > ---
> > lib/kobject_uevent.c | 140 ++++++++++++++++++++++++++++++-------------
> > 1 file changed, 99 insertions(+), 41 deletions(-)
> >
> > diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
> > index c3cb110f663b..d8ce5e6d83af 100644
> > --- a/lib/kobject_uevent.c
> > +++ b/lib/kobject_uevent.c
> >
> > +static int uevent_net_broadcast_tagged(struct sock *usk,
> > + struct kobj_uevent_env *env,
> > + const char *action_string,
> > + const char *devpath)
> > +{
> > + struct user_namespace *owning_user_ns = sock_net(usk)->user_ns;
> > + struct sk_buff *skb = NULL;
> > + int ret;
> > +
> > + skb = alloc_uevent_skb(env, action_string, devpath);
> > + if (!skb)
> > + return -ENOMEM;
> > +
> > + /* fix credentials */
> > + if (owning_user_ns != &init_user_ns) {
>
> Nit: This test is just a performance optimization as such is not
> necessary. That is we can safely unconditionally set the
> credentials this way.
alloc_uevent_skb() will now set
parms = &NETLINK_CB(skb);
parms->creds.uid = GLOBAL_ROOT_UID;
parms->creds.gid = GLOBAL_ROOT_GID;
parms->dst_group = 1;
parms->portid = 0;
explicitly. So repeating that initialization unconditionally here does
not make sense to me. Also, this hits map_uid_down() in user_namespace.c
which is a known-hotpath (Remember the extensive testing we did back for
uidmap limit bumping from 5 to 340.). And even though it might not
matter much in this case there's no need to hit this code. The condition
also make it obvious that only non-initial user namespace uevent sockets
need fixing.
Christian
>
> > + struct netlink_skb_parms *parms = &NETLINK_CB(skb);
> > + kuid_t root_uid;
> > + kgid_t root_gid;
> > +
> > + /* fix uid */
> > + root_uid = make_kuid(owning_user_ns, 0);
> > + if (!uid_valid(root_uid))
> > + root_uid = GLOBAL_ROOT_UID;
> > + parms->creds.uid = root_uid;
> > +
> > + /* fix gid */
> > + root_gid = make_kgid(owning_user_ns, 0);
> > + if (!gid_valid(root_gid))
> > + root_gid = GLOBAL_ROOT_GID;
> > + parms->creds.gid = root_gid;
> > + }
> > +
> > + ret = netlink_broadcast(usk, skb, 0, 1, GFP_KERNEL);
> > + /* ENOBUFS should be handled in userspace */
> > + if (ret == -ENOBUFS || ret == -ESRCH)
> > + ret = 0;
> > +
> > + return ret;
> > +}
> > +#endif
^ permalink raw reply
* Re: [PATCH net-next 1/2 v3] uevent: add alloc_uevent_skb() helper
From: Christian Brauner @ 2018-04-28 19:09 UTC (permalink / raw)
To: Eric W. Biederman
Cc: davem, netdev, linux-kernel, avagin, ktkhai, serge, gregkh
In-Reply-To: <878t987gdr.fsf@xmission.com>
On Fri, Apr 27, 2018 at 11:39:44AM -0500, Eric W. Biederman wrote:
> Christian Brauner <christian.brauner@ubuntu.com> writes:
>
> > This patch adds alloc_uevent_skb() in preparation for follow up patches.
> >
> > Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
> > ---
> > lib/kobject_uevent.c | 39 ++++++++++++++++++++++++++-------------
> > 1 file changed, 26 insertions(+), 13 deletions(-)
> >
> > diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
> > index 15ea216a67ce..c3cb110f663b 100644
> > --- a/lib/kobject_uevent.c
> > +++ b/lib/kobject_uevent.c
> > @@ -296,6 +296,31 @@ static void cleanup_uevent_env(struct subprocess_info *info)
> > }
> > #endif
> >
> > +static struct sk_buff *alloc_uevent_skb(struct kobj_uevent_env *env,
> > + const char *action_string,
> > + const char *devpath)
> > +{
> > + struct sk_buff *skb = NULL;
> > + char *scratch;
> > + size_t len;
> > +
> > + /* allocate message with maximum possible size */
> > + len = strlen(action_string) + strlen(devpath) + 2;
> > + skb = alloc_skb(len + env->buflen, GFP_KERNEL);
> > + if (!skb)
> > + return NULL;
> > +
> > + /* add header */
> > + scratch = skb_put(skb, len);
> > + sprintf(scratch, "%s@%s", action_string, devpath);
> > +
> > + skb_put_data(skb, env->buf, env->buflen);
> > +
> > + NETLINK_CB(skb).dst_group = 1;
>
> nit:
> We might want to explicitly set NETLINK_CB(skb).portid to 0 and
> NETLINK_CB(skb).creds.uid to GLOBAL_ROOT_UID and
> NETLINK_CB(skb).creds.gid to GLOBAL_ROOT_GID here
> just to make it clear this is happening.
>
> It is not a problem because they __alloc_skb memsets to 0 the
> fields of struct sk_buff that it does not initialize. And these
> are the zero values.
>
> Still it would be nice to be able to look at the code and quickly
> see these are the values being set.
Don't really mind adding it. Ok, non-functional changes added to the new
version. But then let's set "portid" too:
parms = &NETLINK_CB(skb);
parms->creds.uid = GLOBAL_ROOT_UID;
parms->creds.gid = GLOBAL_ROOT_GID;
parms->dst_group = 1;
parms->portid = 0;
Christian
^ permalink raw reply
* Re: [PATCH bpf-next v8 09/10] tools/bpf: add a test for bpf_get_stack with raw tracepoint prog
From: Alexei Starovoitov @ 2018-04-28 19:06 UTC (permalink / raw)
To: Y Song
Cc: Yonghong Song, Alexei Starovoitov, Daniel Borkmann, netdev,
kernel-team
In-Reply-To: <CAH3MdRVpmJE9gqz=41fddmxjRw_ZF0sAqiewEHnYxWYij0jfew@mail.gmail.com>
On Sat, Apr 28, 2018 at 11:17:30AM -0700, Y Song wrote:
> On Sat, Apr 28, 2018 at 9:56 AM, Alexei Starovoitov
> <alexei.starovoitov@gmail.com> wrote:
> > On Sat, Apr 28, 2018 at 12:02:04AM -0700, Yonghong Song wrote:
> >> The test attached a raw_tracepoint program to sched/sched_switch.
> >> It tested to get stack for user space, kernel space and user
> >> space with build_id request. It also tested to get user
> >> and kernel stack into the same buffer with back-to-back
> >> bpf_get_stack helper calls.
> >>
> >> Whenever the kernel stack is available, the user space
> >> application will check to ensure that the kernel function
> >> for raw_tracepoint ___bpf_prog_run is part of the stack.
> >>
> >> Signed-off-by: Yonghong Song <yhs@fb.com>
> > ...
> >> +static int get_stack_print_output(void *data, int size)
> >> +{
> >> + bool good_kern_stack = false, good_user_stack = false;
> >> + const char *expected_func = "___bpf_prog_run";
> >
> > so the test works with interpreter only?
> > I guess that's ok for now, but needs to fixed for
> > configs with CONFIG_BPF_JIT_ALWAYS_ON=y
>
> I did not test CONFIG_BPF_JIT_ALWAYS_ON=y.
> I can have a followup patch for this if the patch set does not need respin.
I was thinking to apply the set and do the fix in the follow up,
but testing it with jit_enable=1 I don't see it's failing,
so something is wrong with the test.
Also get_stack_raw_tp_action() keeps spawning new 'dd' in the background
which is not killed after test stops.
Please fix both issues in respin.
^ permalink raw reply
* Re: [PATCH 1/1] tg3: fix meaningless hw_stats reading after tg3_halt memset 0 hw_stats
From: Michael Chan @ 2018-04-28 18:36 UTC (permalink / raw)
To: Zumeng Chen
Cc: Netdev, open list, Siva Reddy Kallam, michael.chan@broadcom.com,
prashant.sreedharan@broadcom.com, David Miller
In-Reply-To: <20180428031544.210054-1-zumeng.chen@gmail.com>
On Fri, Apr 27, 2018 at 8:15 PM, Zumeng Chen <zumeng.chen@gmail.com> wrote:
> diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
> index 3b5e98e..6727d93 100644
> --- a/drivers/net/ethernet/broadcom/tg3.h
> +++ b/drivers/net/ethernet/broadcom/tg3.h
> @@ -3352,6 +3352,7 @@ struct tg3 {
> struct pci_dev *pdev_peer;
>
> struct tg3_hw_stats *hw_stats;
> + bool hw_stats_flag;
You can just add another bit to enum TG3_FLAGS for this purpose.
While this scheme will probably work, I think a better and more
elegant way to fix this is to use RCU.
> dma_addr_t stats_mapping;
> struct work_struct reset_task;
>
> --
> 2.9.3
>
^ permalink raw reply
* Re: [PATCH bpf-next v8 09/10] tools/bpf: add a test for bpf_get_stack with raw tracepoint prog
From: Y Song @ 2018-04-28 18:17 UTC (permalink / raw)
To: Alexei Starovoitov
Cc: Yonghong Song, Alexei Starovoitov, Daniel Borkmann, netdev,
kernel-team
In-Reply-To: <20180428165643.qnfvcc34pgnwgn2e@ast-mbp>
On Sat, Apr 28, 2018 at 9:56 AM, Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
> On Sat, Apr 28, 2018 at 12:02:04AM -0700, Yonghong Song wrote:
>> The test attached a raw_tracepoint program to sched/sched_switch.
>> It tested to get stack for user space, kernel space and user
>> space with build_id request. It also tested to get user
>> and kernel stack into the same buffer with back-to-back
>> bpf_get_stack helper calls.
>>
>> Whenever the kernel stack is available, the user space
>> application will check to ensure that the kernel function
>> for raw_tracepoint ___bpf_prog_run is part of the stack.
>>
>> Signed-off-by: Yonghong Song <yhs@fb.com>
> ...
>> +static int get_stack_print_output(void *data, int size)
>> +{
>> + bool good_kern_stack = false, good_user_stack = false;
>> + const char *expected_func = "___bpf_prog_run";
>
> so the test works with interpreter only?
> I guess that's ok for now, but needs to fixed for
> configs with CONFIG_BPF_JIT_ALWAYS_ON=y
I did not test CONFIG_BPF_JIT_ALWAYS_ON=y.
I can have a followup patch for this if the patch set does not need respin.
^ permalink raw reply
* Re: [PATCH bpf-next v8 09/10] tools/bpf: add a test for bpf_get_stack with raw tracepoint prog
From: Alexei Starovoitov @ 2018-04-28 16:56 UTC (permalink / raw)
To: Yonghong Song; +Cc: ast, daniel, netdev, kernel-team
In-Reply-To: <20180428070205.1059628-10-yhs@fb.com>
On Sat, Apr 28, 2018 at 12:02:04AM -0700, Yonghong Song wrote:
> The test attached a raw_tracepoint program to sched/sched_switch.
> It tested to get stack for user space, kernel space and user
> space with build_id request. It also tested to get user
> and kernel stack into the same buffer with back-to-back
> bpf_get_stack helper calls.
>
> Whenever the kernel stack is available, the user space
> application will check to ensure that the kernel function
> for raw_tracepoint ___bpf_prog_run is part of the stack.
>
> Signed-off-by: Yonghong Song <yhs@fb.com>
...
> +static int get_stack_print_output(void *data, int size)
> +{
> + bool good_kern_stack = false, good_user_stack = false;
> + const char *expected_func = "___bpf_prog_run";
so the test works with interpreter only?
I guess that's ok for now, but needs to fixed for
configs with CONFIG_BPF_JIT_ALWAYS_ON=y
^ permalink raw reply
* Re: [PATCH bpf-next v8 05/10] bpf/verifier: improve register value range tracking with ARSH
From: Alexei Starovoitov @ 2018-04-28 16:52 UTC (permalink / raw)
To: Yonghong Song; +Cc: ast, daniel, netdev, kernel-team
In-Reply-To: <20180428070205.1059628-6-yhs@fb.com>
On Sat, Apr 28, 2018 at 12:02:00AM -0700, Yonghong Song wrote:
> When helpers like bpf_get_stack returns an int value
> and later on used for arithmetic computation, the LSH and ARSH
> operations are often required to get proper sign extension into
> 64-bit. For example, without this patch:
> 54: R0=inv(id=0,umax_value=800)
> 54: (bf) r8 = r0
> 55: R0=inv(id=0,umax_value=800) R8_w=inv(id=0,umax_value=800)
> 55: (67) r8 <<= 32
> 56: R8_w=inv(id=0,umax_value=3435973836800,var_off=(0x0; 0x3ff00000000))
> 56: (c7) r8 s>>= 32
> 57: R8=inv(id=0)
> With this patch:
> 54: R0=inv(id=0,umax_value=800)
> 54: (bf) r8 = r0
> 55: R0=inv(id=0,umax_value=800) R8_w=inv(id=0,umax_value=800)
> 55: (67) r8 <<= 32
> 56: R8_w=inv(id=0,umax_value=3435973836800,var_off=(0x0; 0x3ff00000000))
> 56: (c7) r8 s>>= 32
> 57: R8=inv(id=0, umax_value=800,var_off=(0x0; 0x3ff))
> With better range of "R8", later on when "R8" is added to other register,
> e.g., a map pointer or scalar-value register, the better register
> range can be derived and verifier failure may be avoided.
>
> In our later example,
> ......
> usize = bpf_get_stack(ctx, raw_data, max_len, BPF_F_USER_STACK);
> if (usize < 0)
> return 0;
> ksize = bpf_get_stack(ctx, raw_data + usize, max_len - usize, 0);
> ......
> Without improving ARSH value range tracking, the register representing
> "max_len - usize" will have smin_value equal to S64_MIN and will be
> rejected by verifier.
>
> Signed-off-by: Yonghong Song <yhs@fb.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
^ permalink raw reply
* Re: [PATCH net-next v5] Add Common Applications Kept Enhanced (cake) qdisc
From: Toke Høiland-Jørgensen @ 2018-04-28 16:05 UTC (permalink / raw)
To: netdev; +Cc: cake, Dave Taht
In-Reply-To: <20180427193901.8057-1-toke@toke.dk>
Toke Høiland-Jørgensen <toke@toke.dk> writes:
> +static inline struct tcphdr *cake_get_tcphdr(struct sk_buff *skb)
> +{
> + struct ipv6hdr *ipv6h;
> + struct iphdr *iph;
> + struct tcphdr *th;
> +
> +
> + switch (skb->protocol) {
> + case cpu_to_be16(ETH_P_IP):
As someone was kind enough to point out off-list, skb->protocol doesn't
actually contain the protocol number of the inner protocol, so this
doesn't work for 6in4 encapsulation. Will try again...
-Toke
^ permalink raw reply
* Re: [Cake] [PATCH iproute2-next v7] Add support for cake qdisc
From: Toke Høiland-Jørgensen @ 2018-04-28 15:27 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, cake
In-Reply-To: <20180427180356.56455652@xeon-e3>
Stephen Hemminger <stephen@networkplumber.org> writes:
> On Fri, 27 Apr 2018 21:57:20 +0200
> Toke Høiland-Jørgensen <toke@toke.dk> wrote:
>
>> sch_cake is intended to squeeze the most bandwidth and latency out of even
>> the slowest ISP links and routers, while presenting an API simple enough
>> that even an ISP can configure it.
>>
>> Example of use on a cable ISP uplink:
>>
>> tc qdisc add dev eth0 cake bandwidth 20Mbit nat docsis ack-filter
>>
>> To shape a cable download link (ifb and tc-mirred setup elided)
>>
>> tc qdisc add dev ifb0 cake bandwidth 200mbit nat docsis ingress wash besteffort
>>
>> Cake is filled with:
>>
>> * A hybrid Codel/Blue AQM algorithm, "Cobalt", tied to an FQ_Codel
>> derived Flow Queuing system, which autoconfigures based on the bandwidth.
>> * A novel "triple-isolate" mode (the default) which balances per-host
>> and per-flow FQ even through NAT.
>> * An deficit based shaper, that can also be used in an unlimited mode.
>> * 8 way set associative hashing to reduce flow collisions to a minimum.
>> * A reasonable interpretation of various diffserv latency/loss tradeoffs.
>> * Support for zeroing diffserv markings for entering and exiting traffic.
>> * Support for interacting well with Docsis 3.0 shaper framing.
>> * Support for DSL framing types and shapers.
>> * Support for ack filtering.
>> * Extensive statistics for measuring, loss, ecn markings, latency variation.
>>
>> Various versions baking have been available as an out of tree build for
>> kernel versions going back to 3.10, as the embedded router world has been
>> running a few years behind mainline Linux. A stable version has been
>> generally available on lede-17.01 and later.
>>
>> sch_cake replaces a combination of iptables, tc filter, htb and fq_codel
>> in the sqm-scripts, with sane defaults and vastly simpler configuration.
>>
>> Cake's principal author is Jonathan Morton, with contributions from
>> Kevin Darbyshire-Bryant, Toke Høiland-Jørgensen, Sebastian Moeller,
>> Ryan Mounce, Guido Sarducci, Dean Scarff, Nils Andreas Svee, Dave Täht,
>> and Loganaden Velvindron.
>>
>> Testing from Pete Heist, Georgios Amanakis, and the many other members of
>> the cake@lists.bufferbloat.net mailing list.
>>
>> Signed-off-by: Dave Taht <dave.taht@gmail.com>
>> Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
>> ---
>> Changelog:
>> v7:
>> - Move the target/interval presets to a table and check that only
>> one is passed.
>>
>> v6:
>> - Identical to v5 because apparently I don't git so well... :/
>>
>> v5:
>> - Print the SPLIT_GSO flag
>> - Switch to print_u64() for JSON output
>> - Fix a format string for mpu option output
>>
>> v4:
>> - Switch stats parsing to use nested netlink attributes
>> - Tweaks to JSON stats output keys
>>
>> v3:
>> - Remove accidentally included test flag
>>
>> v2:
>> - Updated netlink config ABI
>> - Remove diffserv-llt mode
>> - Various tweaks and clean-ups of stats output
>> man/man8/tc-cake.8 | 632 ++++++++++++++++++++++++++++++++++++++
>> man/man8/tc.8 | 1 +
>> tc/Makefile | 1 +
>> tc/q_cake.c | 748 +++++++++++++++++++++++++++++++++++++++++++++
>> 4 files changed, 1382 insertions(+)
>> create mode 100644 man/man8/tc-cake.8
>> create mode 100644 tc/q_cake.c
>
> Looks good to me, when cake makes it into net-next.
Awesome, thanks!
-Toke
^ permalink raw reply
* Re: [PATCH bpf-next] bpf: Allow bpf_current_task_under_cgroup in interrupt
From: Alexei Starovoitov @ 2018-04-28 15:03 UTC (permalink / raw)
To: Teng Qin, netdev; +Cc: ast, daniel, yhs, kernel-team
In-Reply-To: <20180428073235.3917719-1-qinteng@fb.com>
On 4/28/18 12:32 AM, Teng Qin wrote:
> Currently, the bpf_current_task_under_cgroup helper has a check where if
> the BPF program is running in_interrupt(), it will return -EINVAL. This
> prevents the helper to be used in many useful scenarios, particularly
> BPF programs attached to Perf Events.
>
> This commit removes the check. Tested a few NMI (Perf Event) and some
> softirq context, the helper returns the correct result.
> ---
> kernel/trace/bpf_trace.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
> index 56ba0f2..f94890c 100644
> --- a/kernel/trace/bpf_trace.c
> +++ b/kernel/trace/bpf_trace.c
> @@ -474,8 +474,6 @@ BPF_CALL_2(bpf_current_task_under_cgroup, struct bpf_map *, map, u32, idx)
> struct bpf_array *array = container_of(map, struct bpf_array, map);
> struct cgroup *cgrp;
>
> - if (unlikely(in_interrupt()))
> - return -EINVAL;
> if (unlikely(idx >= array->map.max_entries))
> return -E2BIG;
>
looks good, but SOB is missing. Please respin.
^ permalink raw reply
* Re: Re: [PATCH 1/5] dt-bindings: allow dwmac-sun8i to use other devices' exported regmap
From: Chen-Yu Tsai @ 2018-04-28 13:42 UTC (permalink / raw)
To: Rob Herring
Cc: linux-arm-kernel, devicetree, Maxime Ripard, netdev, linux-sunxi,
linux-kernel, Corentin Labbe, Giuseppe Cavallaro, Icenowy Zheng
In-Reply-To: <04C9F795-2680-4220-A39A-7B7D5FD74C4A-h8G6r0blFSE@public.gmane.org>
Hi Rob,
On Tue, Apr 17, 2018 at 7:17 AM, Icenowy Zheng <icenowy-h8G6r0blFSE@public.gmane.org> wrote:
>
>
> 于 2018年4月17日 GMT+08:00 上午2:47:45, Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> 写到:
>>On Wed, Apr 11, 2018 at 10:16:37PM +0800, Icenowy Zheng wrote:
>>> On some Allwinner SoCs the EMAC clock register needed by dwmac-sun8i
>>is
>>> in another device's memory space. In this situation dwmac-sun8i can
>>use
>>> a regmap exported by the other device with only the EMAC clock
>>register.
>>
>>If this is a clock, then why not use the clock binding?
>
> EMAC clock register is only the datasheet name. It contains
> MII mode selection and delay chain configuration.
As Icenowy already mentioned, this is likely a misnomer.
The register contains controls on how to route the TX and RX clock
lines, and also what interface mode to use. The former includes things
like the delays mentioned in the device tree binding, and also whether
to invert the signals or not. The latter influences whether the TXC
line is an input or an output (or maybe what decoding module to send
all the signals to). On the H3/H5, it even contains controls for the
embedded PHY.
The settings only make sense to the MAC. To expose it as a generic
clock line would not be a good fit. You can look at what we did for
sun7i-a20-gmac, which is not pretty. All other DWMAC platforms that
were introduced after sun7i-a20-gmac also use a syscon, instead of
clocks, even though they probably cover the same set of RXC/TXC
controls.
ChenYu
>>
>>>
>>> Document this situation in the dwmac-sun8i device tree binding
>>> documentation.
>>>
>>> Signed-off-by: Icenowy Zheng <icenowy-h8G6r0blFSE@public.gmane.org>
>>> ---
>>> Documentation/devicetree/bindings/net/dwmac-sun8i.txt | 5 +++--
>>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/Documentation/devicetree/bindings/net/dwmac-sun8i.txt
>>b/Documentation/devicetree/bindings/net/dwmac-sun8i.txt
>>> index 3d6d5fa0c4d5..0c5f63a80617 100644
>>> --- a/Documentation/devicetree/bindings/net/dwmac-sun8i.txt
>>> +++ b/Documentation/devicetree/bindings/net/dwmac-sun8i.txt
>>> @@ -20,8 +20,9 @@ Required properties:
>>> - phy-handle: See ethernet.txt
>>> - #address-cells: shall be 1
>>> - #size-cells: shall be 0
>>> -- syscon: A phandle to the syscon of the SoC with one of the
>>following
>>> - compatible string:
>>> +- syscon: A phandle to a device which exports the EMAC clock
>>register as a
>>> + regmap or to the syscon of the SoC with one of the following
>>compatible
>>> + string:
>>> - allwinner,sun8i-h3-system-controller
>>> - allwinner,sun8i-v3s-system-controller
>>> - allwinner,sun50i-a64-system-controller
>>> --
>>> 2.15.1
>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe devicetree"
>>in
>>> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
>>_______________________________________________
>>linux-arm-kernel mailing list
>>linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
>>http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
> --
> You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply
* [PATCH v2 2/2] net: stmmac: dwmac-meson: extend phy mode setting
From: Yixun Lan @ 2018-04-28 10:21 UTC (permalink / raw)
To: David S. Miller, netdev
Cc: Yixun Lan, Kevin Hilman, Carlo Caione, Rob Herring, Jerome Brunet,
Martin Blumenstingl, linux-amlogic, linux-arm-kernel,
linux-kernel
In-Reply-To: <20180428102111.18384-1-yixun.lan@amlogic.com>
In the Meson-AXG SoC, the phy mode setting of PRG_ETH0 in the glue layer
is extended from bit[0] to bit[2:0].
There is no problem if we configure it to the RGMII 1000M PHY mode,
since the register setting is coincidentally compatible with previous one,
but for the RMII 100M PHY mode, the configuration need to be changed to
value - b100.
This patch was verified with a RTL8201F 100M ethernet PHY.
Signed-off-by: Yixun Lan <yixun.lan@amlogic.com>
---
.../ethernet/stmicro/stmmac/dwmac-meson8b.c | 120 +++++++++++++++---
1 file changed, 104 insertions(+), 16 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
index 7cb794094a70..4ff231df7322 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
@@ -18,6 +18,7 @@
#include <linux/io.h>
#include <linux/ioport.h>
#include <linux/module.h>
+#include <linux/of_device.h>
#include <linux/of_net.h>
#include <linux/mfd/syscon.h>
#include <linux/platform_device.h>
@@ -29,6 +30,10 @@
#define PRG_ETH0_RGMII_MODE BIT(0)
+#define PRG_ETH0_EXT_PHY_MODE_MASK GENMASK(2, 0)
+#define PRG_ETH0_EXT_RGMII_MODE 1
+#define PRG_ETH0_EXT_RMII_MODE 4
+
/* mux to choose between fclk_div2 (bit unset) and mpll2 (bit set) */
#define PRG_ETH0_CLK_M250_SEL_SHIFT 4
#define PRG_ETH0_CLK_M250_SEL_MASK GENMASK(4, 4)
@@ -47,12 +52,20 @@
#define MUX_CLK_NUM_PARENTS 2
+struct meson8b_dwmac;
+
+struct meson8b_dwmac_data {
+ int (*set_phy_mode)(struct meson8b_dwmac *dwmac);
+};
+
struct meson8b_dwmac {
- struct device *dev;
- void __iomem *regs;
- phy_interface_t phy_mode;
- struct clk *rgmii_tx_clk;
- u32 tx_delay_ns;
+ struct device *dev;
+ void __iomem *regs;
+
+ const struct meson8b_dwmac_data *data;
+ phy_interface_t phy_mode;
+ struct clk *rgmii_tx_clk;
+ u32 tx_delay_ns;
};
struct meson8b_dwmac_clk_configs {
@@ -171,6 +184,59 @@ static int meson8b_init_rgmii_tx_clk(struct meson8b_dwmac *dwmac)
return 0;
}
+static int meson8b_set_phy_mode(struct meson8b_dwmac *dwmac)
+{
+ switch (dwmac->phy_mode) {
+ case PHY_INTERFACE_MODE_RGMII:
+ case PHY_INTERFACE_MODE_RGMII_RXID:
+ case PHY_INTERFACE_MODE_RGMII_ID:
+ case PHY_INTERFACE_MODE_RGMII_TXID:
+ /* enable RGMII mode */
+ meson8b_dwmac_mask_bits(dwmac, PRG_ETH0,
+ PRG_ETH0_RGMII_MODE,
+ PRG_ETH0_RGMII_MODE);
+ break;
+ case PHY_INTERFACE_MODE_RMII:
+ /* disable RGMII mode -> enables RMII mode */
+ meson8b_dwmac_mask_bits(dwmac, PRG_ETH0,
+ PRG_ETH0_RGMII_MODE, 0);
+ break;
+ default:
+ dev_err(dwmac->dev, "fail to set phy-mode %s\n",
+ phy_modes(dwmac->phy_mode));
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int meson_axg_set_phy_mode(struct meson8b_dwmac *dwmac)
+{
+ switch (dwmac->phy_mode) {
+ case PHY_INTERFACE_MODE_RGMII:
+ case PHY_INTERFACE_MODE_RGMII_RXID:
+ case PHY_INTERFACE_MODE_RGMII_ID:
+ case PHY_INTERFACE_MODE_RGMII_TXID:
+ /* enable RGMII mode */
+ meson8b_dwmac_mask_bits(dwmac, PRG_ETH0,
+ PRG_ETH0_EXT_PHY_MODE_MASK,
+ PRG_ETH0_EXT_RGMII_MODE);
+ break;
+ case PHY_INTERFACE_MODE_RMII:
+ /* disable RGMII mode -> enables RMII mode */
+ meson8b_dwmac_mask_bits(dwmac, PRG_ETH0,
+ PRG_ETH0_EXT_PHY_MODE_MASK,
+ PRG_ETH0_EXT_RMII_MODE);
+ break;
+ default:
+ dev_err(dwmac->dev, "fail to set phy-mode %s\n",
+ phy_modes(dwmac->phy_mode));
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac)
{
int ret;
@@ -188,10 +254,6 @@ static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac)
case PHY_INTERFACE_MODE_RGMII_ID:
case PHY_INTERFACE_MODE_RGMII_TXID:
- /* enable RGMII mode */
- meson8b_dwmac_mask_bits(dwmac, PRG_ETH0, PRG_ETH0_RGMII_MODE,
- PRG_ETH0_RGMII_MODE);
-
/* only relevant for RMII mode -> disable in RGMII mode */
meson8b_dwmac_mask_bits(dwmac, PRG_ETH0,
PRG_ETH0_INVERTED_RMII_CLK, 0);
@@ -224,10 +286,6 @@ static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac)
break;
case PHY_INTERFACE_MODE_RMII:
- /* disable RGMII mode -> enables RMII mode */
- meson8b_dwmac_mask_bits(dwmac, PRG_ETH0, PRG_ETH0_RGMII_MODE,
- 0);
-
/* invert internal clk_rmii_i to generate 25/2.5 tx_rx_clk */
meson8b_dwmac_mask_bits(dwmac, PRG_ETH0,
PRG_ETH0_INVERTED_RMII_CLK,
@@ -274,6 +332,11 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
goto err_remove_config_dt;
}
+ dwmac->data = (const struct meson8b_dwmac_data *)
+ of_device_get_match_data(&pdev->dev);
+ if (!dwmac->data)
+ return -EINVAL;
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
dwmac->regs = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(dwmac->regs)) {
@@ -298,6 +361,10 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
if (ret)
goto err_remove_config_dt;
+ ret = dwmac->data->set_phy_mode(dwmac);
+ if (ret)
+ goto err_remove_config_dt;
+
ret = meson8b_init_prg_eth(dwmac);
if (ret)
goto err_remove_config_dt;
@@ -316,10 +383,31 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
return ret;
}
+static const struct meson8b_dwmac_data meson8b_dwmac_data = {
+ .set_phy_mode = meson8b_set_phy_mode,
+};
+
+static const struct meson8b_dwmac_data meson_axg_dwmac_data = {
+ .set_phy_mode = meson_axg_set_phy_mode,
+};
+
static const struct of_device_id meson8b_dwmac_match[] = {
- { .compatible = "amlogic,meson8b-dwmac" },
- { .compatible = "amlogic,meson8m2-dwmac" },
- { .compatible = "amlogic,meson-gxbb-dwmac" },
+ {
+ .compatible = "amlogic,meson8b-dwmac",
+ .data = &meson8b_dwmac_data,
+ },
+ {
+ .compatible = "amlogic,meson8m2-dwmac",
+ .data = &meson8b_dwmac_data,
+ },
+ {
+ .compatible = "amlogic,meson-gxbb-dwmac",
+ .data = &meson8b_dwmac_data,
+ },
+ {
+ .compatible = "amlogic,meson-axg-dwmac",
+ .data = &meson_axg_dwmac_data,
+ },
{ }
};
MODULE_DEVICE_TABLE(of, meson8b_dwmac_match);
--
2.17.0
^ permalink raw reply related
* [PATCH v2 1/2] dt-bindings: net: meson-dwmac: new compatible name for AXG SoC
From: Yixun Lan @ 2018-04-28 10:21 UTC (permalink / raw)
To: David S. Miller, netdev
Cc: Yixun Lan, Kevin Hilman, Carlo Caione, Rob Herring, Jerome Brunet,
Martin Blumenstingl, linux-amlogic, linux-arm-kernel,
linux-kernel, devicetree
In-Reply-To: <20180428102111.18384-1-yixun.lan@amlogic.com>
We need to introduce a new compatible name for the Meson-AXG SoC
in order to support the RMII 100M ethernet PHY, since the PRG_ETH0
register of the dwmac glue layer is changed from previous old SoC.
Signed-off-by: Yixun Lan <yixun.lan@amlogic.com>
---
Documentation/devicetree/bindings/net/meson-dwmac.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/net/meson-dwmac.txt b/Documentation/devicetree/bindings/net/meson-dwmac.txt
index 61cada22ae6c..1321bb194ed9 100644
--- a/Documentation/devicetree/bindings/net/meson-dwmac.txt
+++ b/Documentation/devicetree/bindings/net/meson-dwmac.txt
@@ -11,6 +11,7 @@ Required properties on all platforms:
- "amlogic,meson8b-dwmac"
- "amlogic,meson8m2-dwmac"
- "amlogic,meson-gxbb-dwmac"
+ - "amlogic,meson-axg-dwmac"
Additionally "snps,dwmac" and any applicable more
detailed version number described in net/stmmac.txt
should be used.
--
2.17.0
^ permalink raw reply related
* [PATCH v2 0/2] net: stmmac: dwmac-meson: 100M phy mode support for AXG SoC
From: Yixun Lan @ 2018-04-28 10:21 UTC (permalink / raw)
To: David S. Miller, netdev
Cc: Yixun Lan, Kevin Hilman, Carlo Caione, Rob Herring, Jerome Brunet,
Martin Blumenstingl, linux-amlogic, linux-arm-kernel,
linux-kernel, devicetree
Due to the dwmac glue layer register changed, we need to
introduce a new compatible name for the Meson-AXG SoC
to support for the RMII 100M ethernet PHY.
Change since v1 at [1]:
- implement set_phy_mode() for each SoC
[1] https://lkml.kernel.org/r/20180426160508.29380-1-yixun.lan@amlogic.com
Yixun Lan (2):
dt-bindings: net: meson-dwmac: new compatible name for AXG SoC
net: stmmac: dwmac-meson: extend phy mode setting
.../devicetree/bindings/net/meson-dwmac.txt | 1 +
.../ethernet/stmicro/stmmac/dwmac-meson8b.c | 120 +++++++++++++++---
2 files changed, 105 insertions(+), 16 deletions(-)
--
2.17.0
^ permalink raw reply
* Re: [net-next] ipv6: sr: Extract the right key values for "seg6_make_flowlabel"
From: Ahmed Abdelsalam @ 2018-04-28 10:20 UTC (permalink / raw)
To: David Miller; +Cc: dav.lebrun, netdev, linux-kernel
In-Reply-To: <20180427.135907.1528151032821602074.davem@davemloft.net>
On Fri, 27 Apr 2018 13:59:07 -0400 (EDT)
David Miller <davem@davemloft.net> wrote:
> From: Ahmed Abdelsalam <amsalam20@gmail.com>
> Date: Thu, 26 Apr 2018 16:11:11 +0200
>
> > @@ -119,6 +119,9 @@ int seg6_do_srh_encap(struct sk_buff *skb, struct ipv6_sr_hdr *osrh, int proto)
> > int hdrlen, tot_len, err;
> > __be32 flowlabel;
> >
> > + inner_hdr = ipv6_hdr(skb);
>
> You have to make this assignment after, not before, the skb_cow_header()
> call. Otherwise this point can be pointing to freed up memory.
Ok!
I fixed and sent you a v2 of the patch.
--
Ahmed Abdelsalam <amsalam20@gmail.com>
^ permalink raw reply
* [net-next v2] ipv6: sr: extract the right key values for "seg6_make_flowlabel"
From: Ahmed Abdelsalam @ 2018-04-28 10:18 UTC (permalink / raw)
To: davem, dav.lebrun, netdev, linux-kernel; +Cc: Ahmed Abdelsalam
The seg6_make_flowlabel() is used by seg6_do_srh_encap() to compute the
flowlabel from a given skb. It relies on skb_get_hash() which eventually
calls __skb_flow_dissect() to extract the flow_keys struct values from
the skb.
In case of IPv4 traffic, calling seg6_make_flowlabel() after skb_push(),
skb_reset_network_header(), and skb_mac_header_rebuild() will results in
flow_keys struct of all key values set to zero.
This patch calls seg6_make_flowlabel() before resetting the headers of skb
to get the right key values.
Extracted Key values are based on the type inner packet as follows:
1) IPv6 traffic: src_IP, dst_IP, L4 proto, and flowlabel of inner packet.
2) IPv4 traffic: src_IP, dst_IP, L4 proto, src_port, and dst_port
3) L2 traffic: depends on what kind of traffic carried into the L2
frame. IPv6 and IPv4 traffic works as discussed 1) and 2)
Here a hex_dump of struct flow_keys for IPv4 and IPv6 traffic
10.100.1.100: 47302 > 30.0.0.2: 5001
00000000: 14 00 02 00 00 00 00 00 08 00 11 00 00 00 00 00
00000010: 00 00 00 00 00 00 00 00 13 89 b8 c6 1e 00 00 02
00000020: 0a 64 01 64
fc00:a1:a > b2::2
00000000: 28 00 03 00 00 00 00 00 86 dd 11 00 99 f9 02 00
00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 b2 00 00
00000020: 00 00 00 00 00 00 00 00 00 00 00 02 fc 00 00 a1
00000030: 00 00 00 00 00 00 00 00 00 00 00 0a
Signed-off-by: Ahmed Abdelsalam <amsalam20@gmail.com>
---
net/ipv6/seg6_iptunnel.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv6/seg6_iptunnel.c b/net/ipv6/seg6_iptunnel.c
index 9898926..eab39bd 100644
--- a/net/ipv6/seg6_iptunnel.c
+++ b/net/ipv6/seg6_iptunnel.c
@@ -127,6 +127,7 @@ int seg6_do_srh_encap(struct sk_buff *skb, struct ipv6_sr_hdr *osrh, int proto)
return err;
inner_hdr = ipv6_hdr(skb);
+ flowlabel = seg6_make_flowlabel(net, skb, inner_hdr);
skb_push(skb, tot_len);
skb_reset_network_header(skb);
@@ -138,7 +139,6 @@ int seg6_do_srh_encap(struct sk_buff *skb, struct ipv6_sr_hdr *osrh, int proto)
* decapsulation will overwrite inner hlim with outer hlim
*/
- flowlabel = seg6_make_flowlabel(net, skb, inner_hdr);
if (skb->protocol == htons(ETH_P_IPV6)) {
ip6_flow_hdr(hdr, ip6_tclass(ip6_flowinfo(inner_hdr)),
flowlabel);
--
2.1.4
^ permalink raw reply related
* Re: [PATCHv2 net] bridge: check iface upper dev when setting master via ioctl
From: Nikolay Aleksandrov @ 2018-04-28 10:06 UTC (permalink / raw)
To: Hangbin Liu, netdev; +Cc: Dmitry Vyukov, syzbot, David Miller
In-Reply-To: <1524833964-674-1-git-send-email-liuhangbin@gmail.com>
On 27/04/18 15:59, Hangbin Liu wrote:
> When we set a bond slave's master to bridge via ioctl, we only check
> the IFF_BRIDGE_PORT flag. Although we will find the slave's real master
> at netdev_master_upper_dev_link() later, it already does some settings
> and allocates some resources. It would be better to return as early
> as possible.
>
> v1 -> v2:
> use netdev_master_upper_dev_get() instead of netdev_has_any_upper_dev()
> to check if we have a master, because not all upper devs are masters,
> e.g. vlan device.
>
> Reported-by: syzbot+de73361ee4971b6e6f75@syzkaller.appspotmail.com
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> ---
> net/bridge/br_if.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
> index 82c1a6f..5bb6681 100644
> --- a/net/bridge/br_if.c
> +++ b/net/bridge/br_if.c
> @@ -518,8 +518,8 @@ int br_add_if(struct net_bridge *br, struct net_device *dev,
> return -ELOOP;
> }
>
> - /* Device is already being bridged */
> - if (br_port_exists(dev))
> + /* Device has master upper dev */
> + if (netdev_master_upper_dev_get(dev))
> return -EBUSY;
>
> /* No bridging devices that dislike that (e.g. wireless) */
>
Acked-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
^ permalink raw reply
* [PATCH] net: ethernet: ucc: fix spelling mistake: "tx-late-collsion" -> "tx-late-collision"
From: Colin King @ 2018-04-28 9:57 UTC (permalink / raw)
To: Li Yang, netdev, linuxppc-dev; +Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Trivial fix to spelling mistake in tx_fw_stat_gstrings text
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/net/ethernet/freescale/ucc_geth_ethtool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/freescale/ucc_geth_ethtool.c b/drivers/net/ethernet/freescale/ucc_geth_ethtool.c
index 4df282ed22c7..0beee2cc2ddd 100644
--- a/drivers/net/ethernet/freescale/ucc_geth_ethtool.c
+++ b/drivers/net/ethernet/freescale/ucc_geth_ethtool.c
@@ -61,7 +61,7 @@ static const char hw_stat_gstrings[][ETH_GSTRING_LEN] = {
static const char tx_fw_stat_gstrings[][ETH_GSTRING_LEN] = {
"tx-single-collision",
"tx-multiple-collision",
- "tx-late-collsion",
+ "tx-late-collision",
"tx-aborted-frames",
"tx-lost-frames",
"tx-carrier-sense-errors",
--
2.17.0
^ 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