* Re: Your Loan Firm
From: EMRAH GLOBAL LOAN FIRM @ 2018-10-28 19:32 UTC (permalink / raw)
To: Recipients
Are you searching for a Genuine Loan? At an affordable interest rate? Get back to us with your Name and Phone Number
Best Regards,
Emrah Global Loan
^ permalink raw reply
* Re: [PATCH 1/1] macsec: reflect the master interface state
From: Radu Rendec @ 2018-10-28 21:14 UTC (permalink / raw)
To: Sabrina Dubroca; +Cc: netdev, davem, ptalbert
In-Reply-To: <20181001125240.GA8219@bistromath.localdomain>
On Mon, 2018-10-01 at 14:52 +0200, Sabrina Dubroca wrote:
> 2018-09-19, 12:44:41 -0400, Radu Rendec wrote:
> > Hello,
>
> Gah, sorry, this fell into the "week-end" crack and I forgot to answer :(
No worries. I was on vacation in the meantime, hence my late reply.
> > On Wed, Sep 19, 2018 at 11:24 AM Sabrina Dubroca <sd@queasysnail.net> wrote:
> > > 2018-09-18, 20:16:12 -0400, Radu Rendec wrote:
> > > > This patch makes macsec interfaces reflect the state of the underlying
> > > > interface: if the master interface changes state to up/down, the macsec
> > > > interface changes its state accordingly.
> > >
> > > Yes, that's a bit unfortunate. I was wondering if we should just allow
> > > setting the device up, and let link state handle the rest.
> >
> > Yes, that could work. It would also be consistent with the idea of
> > propagating only the link state.
>
> Do you want to handle it, or should I?
Too late. I saw your patches this morning. Thanks for sending them out
and sorry for not looking into this sooner.
> > > It's missing small parts of link state handling that I have been
> > > testing, mainly when creating a new device.
> >
> > Can you please be more specific? I've just looked at macsec_newlink()
> > and I didn't notice anything related to link state handling.
>
> Yes, that's actually the problem. For example,
> macvlan_common_newlink() does:
>
> netif_stacked_transfer_operstate(lowerdev, dev);
> linkwatch_fire_event(dev);
>
> If you try to create a macsec device UP with its lowerdev UP:
>
> ip link set $lower up
> ip link add link $lower up type macsec
>
>
> You'll get:
>
> macsec0@$lower: <BROADCAST,MULTICAST,UP,LOWER_UP> [...] state UNKNOWN [...]
>
> and you want "state UP".
That makes sense. Thanks for taking the time to explain this!
> > > I don't like that this completely ignores whether the device was done
> > > independently of the lower link. Maybe the administrator actually
> > > wants the macsec device down, regardless of state changes on the lower
> > > device.
> >
> > I thought about that too and I don't like it either. Perhaps the vlan
> > approach of having a "loose binding" flag is worth considering. Then the
> > admin can decice for themselves.
>
> Do you have a use case where you'd want that? If that solves some
> problem for you (a problem that can't be solved just by fixing the
> current bug), then ok, we can consider it. I prefer to avoid adding
> obscure options and more code unless they're necessary.
I do have a use case, but with the current bugs fixed, it can be
implemented at the application level by setting the admin state on both
the underlying interface and the macsec interface at the same time.
There is no need to implement this in the kernel and complicate the
macsec code unnecessarily.
> And sorry for the delay in answering :/
No need to apologize. I had a huge delay myself in getting back.
Best regards,
Radu Rendec
^ permalink raw reply
* Re: [PATCH net] rtnetlink: Disallow FDB configuration for non-Ethernet device
From: David Ahern @ 2018-10-28 21:37 UTC (permalink / raw)
To: Ido Schimmel, netdev@vger.kernel.org; +Cc: davem@davemloft.net, Vlad Yasevich
In-Reply-To: <20181027203819.7333-1-idosch@mellanox.com>
On 10/27/18 2:39 PM, Ido Schimmel wrote:
> When an FDB entry is configured, the address is validated to have the
> length of an Ethernet address, but the device for which the address is
> configured can be of any type.
>
> The above can result in the use of uninitialized memory when the address
> is later compared against existing addresses since 'dev->addr_len' is
> used and it may be greater than ETH_ALEN, as with ip6tnl devices.
>
> Fix this by making sure that FDB entries are only configured for
> Ethernet devices.
...
>
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index f679c7a7d761..728a97f9f700 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -3600,6 +3600,11 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
> return -EINVAL;
> }
>
> + if (dev->type != ARPHRD_ETHER) {
> + NL_SET_ERR_MSG(extack, "invalid device type");
If only Ethernet devices are supported, then the error message can be
more specific: "FDB add only support for Ethernet devices"
> + return -EINVAL;
> + }
> +
> addr = nla_data(tb[NDA_LLADDR]);
>
> err = fdb_vid_parse(tb[NDA_VLAN], &vid, extack);
> @@ -3704,6 +3709,11 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
> return -EINVAL;
> }
>
> + if (dev->type != ARPHRD_ETHER) {
> + NL_SET_ERR_MSG(extack, "invalid device type");
same here.
> + return -EINVAL;
> + }
> +
> addr = nla_data(tb[NDA_LLADDR]);
>
> err = fdb_vid_parse(tb[NDA_VLAN], &vid, extack);
>
^ permalink raw reply
* Re: WARNING in __debug_object_init (3)
From: Song Liu @ 2018-10-29 6:47 UTC (permalink / raw)
To: eric.dumazet
Cc: dvyukov, syzbot+6e682caa546b7c96c859, edumazet,
Alexei Starovoitov, Daniel Borkmann, David S . Miller, open list,
Networking, syzkaller-bugs
In-Reply-To: <64bc75ce-336d-2115-1016-b10bc920539f@gmail.com>
On Sun, Oct 28, 2018 at 10:45 AM Eric Dumazet <eric.dumazet@gmail.com> wrote:
>
>
>
> On 10/28/2018 08:13 AM, Dmitry Vyukov wrote:
> > On Sun, Oct 28, 2018 at 3:18 AM, syzbot
> > <syzbot+6e682caa546b7c96c859@syzkaller.appspotmail.com> wrote:
> >> Hello,
> >>
> >> syzbot found the following crash on:
> >>
> >> HEAD commit: 8c60c36d0b8c Add linux-next specific files for 20181019
> >> git tree: linux-next
> >> console output: https://syzkaller.appspot.com/x/log.txt?x=100feec5400000
> >> kernel config: https://syzkaller.appspot.com/x/.config?x=8b6d7c4c81535e89
> >> dashboard link: https://syzkaller.appspot.com/bug?extid=6e682caa546b7c96c859
> >> compiler: gcc (GCC) 8.0.1 20180413 (experimental)
> >> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13579abd400000
> >> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13654f6b400000
> >>
> >> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> >> Reported-by: syzbot+6e682caa546b7c96c859@syzkaller.appspotmail.com
> >
> > +Eric knows what's wrong here. Something about "bpf: add tests for
> > direct packet access from CGROUP_SKB" commit. Was is amended to fix a
> > bug?
> >
>
> I know little.
>
> It seems that this linux-next tree contains a (buggy) pre-version of
> this commit :
>
> commit 2cb494a36c98279c5c6ce8e99cf9776f15449ade
> Author: Song Liu <songliubraving@fb.com>
> Date: Fri Oct 19 09:57:58 2018 -0700
>
> bpf: add tests for direct packet access from CGROUP_SKB
>
> Tests are added to make sure CGROUP_SKB cannot access:
> tc_classid, data_meta, flow_keys
>
> and can read and write:
> mark, prority, and cb[0-4]
>
> and can read other fields.
>
> To make selftest with skb->sk work, a dummy sk is added in
> bpf_prog_test_run_skb().
>
> Signed-off-by: Song Liu <songliubraving@fb.com>
> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
>
> Maybe bpf maintainers chose to pre-submit a buggy patch and rebased their tree.
>
> The buggy patch in linux-next was :
>
> commit 75079847e9d05d4cc1b7e09b29e22cbc8318a6b7
> Author: Song Liu <songliubraving@fb.com>
> Date: Thu Oct 18 09:06:49 2018 -0700
>
> bpf: add tests for direct packet access from CGROUP_SKB
>
> Tests are added to make sure CGROUP_SKB cannot access:
> tc_classid, data_meta, flow_keys
>
> and can read and write:
> mark, prority, and cb[0-4]
>
> and can read other fields.
>
> To make selftest with skb->sk work, a dummy sk is added in
> bpf_prog_test_run_skb().
>
> Signed-off-by: Song Liu <songliubraving@fb.com>
> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
>
Thanks Eric.
Yeah, the version in the linux-next tree was a buggy version. The one
in Linus' tree is correct. I confirmed that this issue doesn't repro in Linus'
tree.
Song
^ permalink raw reply
* Re: KASAN: slab-out-of-bounds Read in sctp_getsockopt
From: Xin Long @ 2018-10-29 6:50 UTC (permalink / raw)
To: Marcelo Ricardo Leitner
Cc: syzbot+5da0d0a72a9e7d791748, davem, LKML, linux-sctp, network dev,
Neil Horman, syzkaller-bugs, Vlad Yasevich
In-Reply-To: <20181028175325.GQ6634@localhost.localdomain>
On Mon, Oct 29, 2018 at 2:53 AM Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
>
> On Sat, Oct 27, 2018 at 02:58:33PM +0900, Xin Long wrote:
> > On Sat, Oct 27, 2018 at 1:38 AM syzbot
> > <syzbot+5da0d0a72a9e7d791748@syzkaller.appspotmail.com> wrote:
> > >
> > > Hello,
> > >
> > > syzbot found the following crash on:
> > >
> > > HEAD commit: bd6bf7c10484 Merge tag 'pci-v4.20-changes' of git://git.ke..
> > > git tree: upstream
> > > console output: https://syzkaller.appspot.com/x/log.txt?x=16fd6bcb400000
> > > kernel config: https://syzkaller.appspot.com/x/.config?x=2dd8629d56664133
> > > dashboard link: https://syzkaller.appspot.com/bug?extid=5da0d0a72a9e7d791748
> > > compiler: gcc (GCC) 8.0.1 20180413 (experimental)
> > > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16b3ea33400000
> > > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17f9f1bd400000
> > >
> > > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > > Reported-by: syzbot+5da0d0a72a9e7d791748@syzkaller.appspotmail.com
> > >
> > > ==================================================================
> > > BUG: KASAN: slab-out-of-bounds in sctp_getsockopt_pr_streamstatus
> > > net/sctp/socket.c:7174 [inline]
> > Forgot to change to use "&" in sctp_getsockopt_pr_streamstatus() in
> > "sctp: get pr_assoc and pr_stream all status with SCTP_PR_SCTP_ALL instead"
> >
> > @@ -7158,7 +7158,7 @@ static int
> > sctp_getsockopt_pr_streamstatus(struct sock *sk, int len,
> > goto out;
> > }
> >
> > - if (policy == SCTP_PR_SCTP_ALL) {
> > + if (policy & SCTP_PR_SCTP_ALL) {
>
> Hmmm. This is trying to avoid the
> streamoute->abandoned_unsent[__SCTP_PR_INDEX(policy)]
> with possibly large 'policy' as policy may be SCTP_PR_SCTP_ALL | SCTP_PR_SCTP_MASK
>
> That said, I don't think this is a good fix because the input
> parameter was bogus and we would be trying to make some sense out of
> it. So I suggest something along these lines:
>
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index fc0386e8ff23..b816956c69f5 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -7144,6 +7144,8 @@ static int sctp_getsockopt_pr_streamstatus(struct sock *sk, int len,
> policy = params.sprstat_policy;
> if (!policy || (policy & ~(SCTP_PR_SCTP_MASK | SCTP_PR_SCTP_ALL)))
> goto out;
> + if (policy & SCTP_PR_SCTP_ALL && policy & ~SCTP_PR_SCTP_ALL)
> + goto out;
sure, will change to:
@@ -7142,7 +7148,8 @@ static int
sctp_getsockopt_pr_streamstatus(struct sock *sk, int len,
}
policy = params.sprstat_policy;
- if (!policy || (policy & ~(SCTP_PR_SCTP_MASK | SCTP_PR_SCTP_ALL)))
+ if (!policy || (policy & ~(SCTP_PR_SCTP_MASK | SCTP_PR_SCTP_ALL)) ||
+ ((policy & SCTP_PR_SCTP_ALL) && (policy & SCTP_PR_SCTP_MASK)))
goto out;
including the one in sctp_getsockopt_pr_assocstatus(), thanks.
>
> asoc = sctp_id2assoc(sk, params.sprstat_assoc_id);
> if (!asoc || params.sprstat_sid >= asoc->stream.outcnt)
>
> To bail out if ALL is specificied together with anything else.
> (the if condition probably could be optimized somehow)
>
> >
> > > BUG: KASAN: slab-out-of-bounds in sctp_getsockopt+0x7516/0x7cc2
> > > net/sctp/socket.c:7582
> > > Read of size 8 at addr ffff8801d89f0968 by task syz-executor278/5330
> > >
> > > CPU: 1 PID: 5330 Comm: syz-executor278 Not tainted 4.19.0+ #303
> > > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> > > Google 01/01/2011
> > > Call Trace:
> > > __dump_stack lib/dump_stack.c:77 [inline]
> > > dump_stack+0x244/0x39d lib/dump_stack.c:113
> > > print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
> > > kasan_report_error mm/kasan/report.c:354 [inline]
> > > kasan_report.cold.8+0x242/0x309 mm/kasan/report.c:412
> > > __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
> > > sctp_getsockopt_pr_streamstatus net/sctp/socket.c:7174 [inline]
> > > sctp_getsockopt+0x7516/0x7cc2 net/sctp/socket.c:7582
> > > sock_common_getsockopt+0x9a/0xe0 net/core/sock.c:2937
> > > __sys_getsockopt+0x1ad/0x390 net/socket.c:1939
> > > __do_sys_getsockopt net/socket.c:1950 [inline]
> > > __se_sys_getsockopt net/socket.c:1947 [inline]
> > > __x64_sys_getsockopt+0xbe/0x150 net/socket.c:1947
> > > do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
> > > entry_SYSCALL_64_after_hwframe+0x49/0xbe
> > > RIP: 0033:0x445789
> > > Code: e8 6c b6 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7
> > > 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff
> > > ff 0f 83 2b 12 fc ff c3 66 2e 0f 1f 84 00 00 00 00
> > > RSP: 002b:00007effdb293db8 EFLAGS: 00000246 ORIG_RAX: 0000000000000037
> > > RAX: ffffffffffffffda RBX: 00000000006dac48 RCX: 0000000000445789
> > > RDX: 0000000000000074 RSI: 0000000000000084 RDI: 0000000000000003
> > > RBP: 00000000006dac40 R08: 0000000020000040 R09: 0000000000000000
> > > R10: 0000000020000080 R11: 0000000000000246 R12: 00000000006dac4c
> > > R13: 00007ffcfc408c6f R14: 00007effdb2949c0 R15: 00000000006dad2c
> > >
> > > Allocated by task 5329:
> > > save_stack+0x43/0xd0 mm/kasan/kasan.c:448
> > > set_track mm/kasan/kasan.c:460 [inline]
> > > kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
> > > kmem_cache_alloc_trace+0x152/0x750 mm/slab.c:3620
> > > kmalloc include/linux/slab.h:513 [inline]
> > > kzalloc include/linux/slab.h:707 [inline]
> > > sctp_stream_init_ext+0x4f/0xf0 net/sctp/stream.c:237
> > > sctp_sendmsg_to_asoc+0x1308/0x1a20 net/sctp/socket.c:1896
> > > sctp_sendmsg+0x13c2/0x1da0 net/sctp/socket.c:2113
> > > inet_sendmsg+0x1a1/0x690 net/ipv4/af_inet.c:798
> > > sock_sendmsg_nosec net/socket.c:621 [inline]
> > > sock_sendmsg+0xd5/0x120 net/socket.c:631
> > > __sys_sendto+0x3d7/0x670 net/socket.c:1788
> > > __do_sys_sendto net/socket.c:1800 [inline]
> > > __se_sys_sendto net/socket.c:1796 [inline]
> > > __x64_sys_sendto+0xe1/0x1a0 net/socket.c:1796
> > > do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
> > > entry_SYSCALL_64_after_hwframe+0x49/0xbe
> > >
> > > Freed by task 3223:
> > > save_stack+0x43/0xd0 mm/kasan/kasan.c:448
> > > set_track mm/kasan/kasan.c:460 [inline]
> > > __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
> > > kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
> > > __cache_free mm/slab.c:3498 [inline]
> > > kfree+0xcf/0x230 mm/slab.c:3813
> > > kzfree+0x28/0x30 mm/slab_common.c:1543
> > > aa_free_file_ctx security/apparmor/include/file.h:76 [inline]
> > > apparmor_file_free_security+0x133/0x1a0 security/apparmor/lsm.c:448
> > > security_file_free+0x4a/0x80 security/security.c:900
> > > file_free fs/file_table.c:54 [inline]
> > > __fput+0x4e8/0xa30 fs/file_table.c:294
> > > ____fput+0x15/0x20 fs/file_table.c:309
> > > task_work_run+0x1e8/0x2a0 kernel/task_work.c:113
> > > tracehook_notify_resume include/linux/tracehook.h:188 [inline]
> > > exit_to_usermode_loop+0x318/0x380 arch/x86/entry/common.c:166
> > > prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline]
> > > syscall_return_slowpath arch/x86/entry/common.c:268 [inline]
> > > do_syscall_64+0x6be/0x820 arch/x86/entry/common.c:293
> > > entry_SYSCALL_64_after_hwframe+0x49/0xbe
> > >
> > > The buggy address belongs to the object at ffff8801d89f0900
> > > which belongs to the cache kmalloc-96 of size 96
> > > The buggy address is located 8 bytes to the right of
> > > 96-byte region [ffff8801d89f0900, ffff8801d89f0960)
> > > The buggy address belongs to the page:
> > > page:ffffea0007627c00 count:1 mapcount:0 mapping:ffff8801da8004c0 index:0x0
> > > flags: 0x2fffc0000000100(slab)
> > > raw: 02fffc0000000100 ffffea0007646748 ffffea0007613488 ffff8801da8004c0
> > > raw: 0000000000000000 ffff8801d89f0000 0000000100000020 0000000000000000
> > > page dumped because: kasan: bad access detected
> > >
> > > Memory state around the buggy address:
> > > ffff8801d89f0800: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
> > > ffff8801d89f0880: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
> > > > ffff8801d89f0900: 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc
> > > ^
> > > ffff8801d89f0980: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
> > > ffff8801d89f0a00: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
> > > ==================================================================
> > >
> > >
> > > ---
> > > This bug is generated by a bot. It may contain errors.
> > > See https://goo.gl/tpsmEJ for more information about syzbot.
> > > syzbot engineers can be reached at syzkaller@googlegroups.com.
> > >
> > > syzbot will keep track of this bug report. See:
> > > https://goo.gl/tpsmEJ#bug-status-tracking for how to communicate with
> > > syzbot.
> > > syzbot can test patches for this bug, for details see:
> > > https://goo.gl/tpsmEJ#testing-patches
^ permalink raw reply
* Re: [PATCH 1/3] i2c: sh_mobile: Remove dummy runtime PM callbacks
From: Wolfram Sang @ 2018-10-28 22:22 UTC (permalink / raw)
To: Jarkko Nikula
Cc: linux-pm, linux-i2c, Wolfram Sang, netdev, David S . Miller,
Sergei Shtylyov, linux-renesas-soc, linux-usb, Yoshihiro Shimoda
In-Reply-To: <20181024135134.28456-2-jarkko.nikula@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 609 bytes --]
On Wed, Oct 24, 2018 at 04:51:32PM +0300, Jarkko Nikula wrote:
> Platform drivers don't need dummy runtime PM callbacks that just return
> success and non-NULL pm pointer in their struct device_driver in order
> to have runtime PM happening. This has changed since following commits:
>
> 05aa55dddb9e ("PM / Runtime: Lenient generic runtime pm callbacks")
> 543f2503a956 ("PM / platform_bus: Allow runtime PM by default")
> 8b313a38ecff ("PM / Platform: Use generic runtime PM callbacks directly")
>
> Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply
* [PATCH net] net: diag: document swapped src/dst in udp_dump_one.
From: Lorenzo Colitti @ 2018-10-29 0:15 UTC (permalink / raw)
To: netdev; +Cc: davem, zenczykowski, xemul, dsahern, Lorenzo Colitti
Since its inception, udp_dump_one has had a bug where userspace
needs to swap src and dst addresses and ports in order to find
the socket it wants. This is because it passes the socket source
address to __udp[46]_lib_lookup's saddr argument, but those
functions are intended to find local sockets matching received
packets, so saddr is the remote address, not the local address.
This can no longer be fixed for backwards compatibility reasons,
so add a brief comment explaining that this is the case. This
will avoid confusion and help ensure SOCK_DIAG implementations
of new protocols don't have the same problem.
Fixes: a925aa00a55 ("udp_diag: Implement the get_exact dumping functionality")
Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
---
net/ipv4/udp_diag.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/ipv4/udp_diag.c b/net/ipv4/udp_diag.c
index d9ad986c7b..5cbb9be052 100644
--- a/net/ipv4/udp_diag.c
+++ b/net/ipv4/udp_diag.c
@@ -42,6 +42,7 @@ static int udp_dump_one(struct udp_table *tbl, struct sk_buff *in_skb,
rcu_read_lock();
if (req->sdiag_family == AF_INET)
+ /* src and dst are swapped for historical reasons */
sk = __udp4_lib_lookup(net,
req->id.idiag_src[0], req->id.idiag_sport,
req->id.idiag_dst[0], req->id.idiag_dport,
--
2.19.1.568.g152ad8e336-goog
^ permalink raw reply related
* [PATCH net] Documentation: ip-sysctl.txt: Document tcp_fwmark_accept
From: Lorenzo Colitti @ 2018-10-29 0:30 UTC (permalink / raw)
To: netdev; +Cc: davem, zenczykowski, Lorenzo Colitti
This patch documents the tcp_fwmark_accept sysctl that was
added in 3.15.
Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
---
Documentation/networking/ip-sysctl.txt | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
index 163b5ff107..32b21571ad 100644
--- a/Documentation/networking/ip-sysctl.txt
+++ b/Documentation/networking/ip-sysctl.txt
@@ -316,6 +316,17 @@ tcp_frto - INTEGER
By default it's enabled with a non-zero value. 0 disables F-RTO.
+tcp_fwmark_accept - BOOLEAN
+ If set, incoming connections to listening sockets that do not have a
+ socket mark will set the mark of the accepting socket to the fwmark of
+ the incoming SYN packet. This will cause all packets on that connection
+ (starting from the first SYNACK) to be sent with that fwmark. The
+ listening socket's mark is unchanged. Listening sockets that already
+ have a fwmark set via setsockopt(SOL_SOCKET, SO_MARK, ...) are
+ unaffected.
+
+ Default: 0
+
tcp_invalid_ratelimit - INTEGER
Limit the maximal rate for sending duplicate acknowledgments
in response to incoming TCP packets that are for an existing
--
2.19.1.568.g152ad8e336-goog
^ permalink raw reply related
* Re: [Patch V3 net 05/11] net: hns3: remove unnecessary queue reset in the hns3_uninit_all_ring()
From: tanhuazhong @ 2018-10-29 0:54 UTC (permalink / raw)
To: Sergei Shtylyov, davem
Cc: netdev, linuxarm, salil.mehta, yisen.zhuang, lipeng321,
linyunsheng
In-Reply-To: <cd3e9a2a-e6ef-ceb0-6863-85eaf36841ee@cogentembedded.com>
On 2018/10/28 16:09, Sergei Shtylyov wrote:
> Hello!
>
> On 28.10.2018 6:34, Huazhong Tan wrote:
>
>> It is not necessary to reset the queue in the hns3_uninit_all_ring(),
>> since the queue is stopped in the down operation, and will be reset
>> in the up operaton. And the judgment of the HCLGE_STATE_RST_HANDLING
>
> Operation.
>
yes, sorry for my poor spelling
>> flag in the hclge_reset_tqp() is not correct, because we need to reset
>> tqp during pf reset, otherwise it may cause queue not be reset to
>
> Not being reset?
>
yes, thanks.
>> working state problem.
>>
>> Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver
>> for hip08 SoC")
>> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
> [...]
>
> MBR, Sergei
>
Greeting.
Huazhong
>
^ permalink raw reply
* Re: [PATCH 1/2] net:stmmac: dwmac-mediatek: add support for mt2712
From: Corentin Labbe @ 2018-10-29 10:08 UTC (permalink / raw)
To: Biao Huang
Cc: davem, robh+dt, mark.rutland, devicetree, nelson.chang, andrew,
netdev, sean.wang, liguo.zhang, linux-kernel, matthias.bgg,
joabreu, linux-mediatek, honghui.zhang, yt.shen, linux-arm-kernel
In-Reply-To: <1540782294-27721-2-git-send-email-biao.huang@mediatek.com>
Hello
I have some minor comments below
On Mon, Oct 29, 2018 at 11:04:53AM +0800, Biao Huang wrote:
> Add Ethernet support for MediaTek SoCs from the mt2712 family
>
> Signed-off-by: Biao Huang <biao.huang@mediatek.com>
> ---
> drivers/net/ethernet/stmicro/stmmac/Kconfig | 8 +
> drivers/net/ethernet/stmicro/stmmac/Makefile | 1 +
> .../net/ethernet/stmicro/stmmac/dwmac-mediatek.c | 364 ++++++++++++++++++++
> 3 files changed, 373 insertions(+)
> create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
> index edf2036..76d779e 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
> +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
> @@ -75,6 +75,14 @@ config DWMAC_LPC18XX
> ---help---
> Support for NXP LPC18xx/43xx DWMAC Ethernet.
>
> +config DWMAC_MEDIATEK
> + tristate "MediaTek MT27xx GMAC support"
> + depends on OF
You should add something like && (COMPILE_TEST || ARCH_MEDIATEK)
[...]
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
> new file mode 100644
> index 0000000..9ccf3a5
> --- /dev/null
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
> @@ -0,0 +1,364 @@
> +// SPDX-License-Identifier: GPL-2.0
> +//
> +// Copyright (c) 2018 MediaTek Inc.
Only SPDX can use the // comment style, the rest should use /**/
[...]
> +static int mt2712_set_interface(struct mediatek_dwmac_plat_data *plat)
> +{
> + int rmii_rxc = plat->rmii_rxc ? RMII_CLK_SRC_RXC : 0;
> + u32 intf_val = 0;
> +
> + /* select phy interface in top control domain */
> + switch (plat->phy_mode) {
> + case PHY_INTERFACE_MODE_MII:
> + intf_val |= PHY_INTF_MII_GMII;
> + break;
> + case PHY_INTERFACE_MODE_RMII:
> + intf_val |= PHY_INTF_RMII;
> + intf_val |= rmii_rxc;
> + break;
> + case PHY_INTERFACE_MODE_RGMII:
> + case PHY_INTERFACE_MODE_RGMII_TXID:
> + case PHY_INTERFACE_MODE_RGMII_RXID:
> + case PHY_INTERFACE_MODE_RGMII_ID:
> + intf_val |= PHY_INTF_RGMII;
> + break;
> + default:
> + pr_err("phy interface not support\n");
I think you could use dev_err() instead.
And I think it is better spelled "not supported".
[...]
> +static int mediatek_dwmac_probe(struct platform_device *pdev)
> +{
> + int ret = 0;
> + struct plat_stmmacenet_data *plat_dat;
> + struct stmmac_resources stmmac_res;
> + struct mediatek_dwmac_plat_data *priv_plat;
> +
> + priv_plat = devm_kzalloc(&pdev->dev, sizeof(*priv_plat), GFP_KERNEL);
> + if (!priv_plat)
> + return -ENOMEM;
> +
> + priv_plat->variant = of_device_get_match_data(&pdev->dev);
> + if (!priv_plat->variant) {
> + dev_err(&pdev->dev, "Missing dwmac-mediatek variant\n");
> + return -EINVAL;
> + }
> +
> + priv_plat->dev = &pdev->dev;
> + priv_plat->np = pdev->dev.of_node;
> + priv_plat->phy_mode = of_get_phy_mode(priv_plat->np);
> +
> + ret = mediatek_dwmac_config_dt(priv_plat);
> + if (ret)
> + return ret;
> +
> + ret = stmmac_get_platform_resources(pdev, &stmmac_res);
> + if (ret)
> + return ret;
> +
> + plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
> + if (IS_ERR(plat_dat))
> + return PTR_ERR(plat_dat);
> +
> + plat_dat->interface = priv_plat->phy_mode;
> + /* clk_csr_i = 250-300MHz & MDC = clk_csr_i/124 */
> + plat_dat->clk_csr = 5;
> + plat_dat->has_gmac4 = 1;
> + plat_dat->has_gmac = 0;
> + plat_dat->pmt = 0;
> + plat_dat->maxmtu = 1500;
ETH_DATA_LEN ?
Regards
^ permalink raw reply
* Re: [PATCH net] net: bridge: remove ipv6 zero address check in mcast queries
From: Hangbin Liu @ 2018-10-29 1:33 UTC (permalink / raw)
To: Nikolay Aleksandrov; +Cc: netdev, roopa, davem, yinxu, bridge
In-Reply-To: <20181027090747.22104-1-nikolay@cumulusnetworks.com>
On Sat, Oct 27, 2018 at 12:07:47PM +0300, Nikolay Aleksandrov wrote:
> Recently a check was added which prevents marking of routers with zero
> source address, but for IPv6 that cannot happen as the relevant RFCs
> actually forbid such packets:
> RFC 2710 (MLDv1):
> "To be valid, the Query message MUST
> come from a link-local IPv6 Source Address, be at least 24 octets
> long, and have a correct MLD checksum."
>
> Same goes for RFC 3810.
>
> And also it can be seen as a requirement in ipv6_mc_check_mld_query()
> which is used by the bridge to validate the message before processing
> it. Thus any queries with :: source address won't be processed anyway.
> So just remove the check for zero IPv6 source address from the query
> processing function.
>
> Fixes: 5a2de63fd1a5 ("bridge: do not add port to router list when receives query with source 0.0.0.0")
> Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Opps.. Sorry for the mistake and thank you for your fix.
Regards
Hangbin
> ---
> net/bridge/br_multicast.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
> index 41cdafbf2ebe..6bac0d6b7b94 100644
> --- a/net/bridge/br_multicast.c
> +++ b/net/bridge/br_multicast.c
> @@ -1428,8 +1428,7 @@ static void br_multicast_query_received(struct net_bridge *br,
> * is 0.0.0.0 should not be added to router port list.
> */
> if ((saddr->proto == htons(ETH_P_IP) && saddr->u.ip4) ||
> - (saddr->proto == htons(ETH_P_IPV6) &&
> - !ipv6_addr_any(&saddr->u.ip6)))
> + saddr->proto == htons(ETH_P_IPV6))
> br_multicast_mark_router(br, port);
> }
>
> --
> 2.17.2
>
^ permalink raw reply
* [PATCH] hinic: Fix l4_type parameter in hinic_task_set_tunnel_l4
From: Nathan Chancellor @ 2018-10-29 10:51 UTC (permalink / raw)
To: Aviad Krawczyk, David S. Miller
Cc: netdev, linux-kernel, Nick Desaulniers, Nathan Chancellor
Clang warns:
drivers/net/ethernet/huawei/hinic/hinic_tx.c:392:34: error: implicit
conversion from enumeration type 'enum hinic_l4_tunnel_type' to
different enumeration type 'enum hinic_l4_offload_type'
[-Werror,-Wenum-conversion]
hinic_task_set_tunnel_l4(task, TUNNEL_UDP_NO_CSUM,
~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~
1 error generated.
It seems that hinic_task_set_tunnel_l4 was meant to take an enum of type
hinic_l4_tunnel_type, not hinic_l4_offload_type, given both the name of
the functions and the values used.
Fixes: cc18a7543d2f ("net-next/hinic: add checksum offload and TSO support")
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
drivers/net/ethernet/huawei/hinic/hinic_hw_qp.c | 2 +-
drivers/net/ethernet/huawei/hinic/hinic_hw_qp.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hw_qp.c b/drivers/net/ethernet/huawei/hinic/hinic_hw_qp.c
index 967c993d5303..bbf9bdd0ee3e 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_hw_qp.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_hw_qp.c
@@ -532,7 +532,7 @@ void hinic_task_set_inner_l3(struct hinic_sq_task *task,
}
void hinic_task_set_tunnel_l4(struct hinic_sq_task *task,
- enum hinic_l4_offload_type l4_type,
+ enum hinic_l4_tunnel_type l4_type,
u32 tunnel_len)
{
task->pkt_info2 |= HINIC_SQ_TASK_INFO2_SET(l4_type, TUNNEL_L4TYPE) |
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hw_qp.h b/drivers/net/ethernet/huawei/hinic/hinic_hw_qp.h
index a0dc63a4bfc7..038522e202b6 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_hw_qp.h
+++ b/drivers/net/ethernet/huawei/hinic/hinic_hw_qp.h
@@ -160,7 +160,7 @@ void hinic_task_set_inner_l3(struct hinic_sq_task *task,
u32 network_len);
void hinic_task_set_tunnel_l4(struct hinic_sq_task *task,
- enum hinic_l4_offload_type l4_type,
+ enum hinic_l4_tunnel_type l4_type,
u32 tunnel_len);
void hinic_set_cs_inner_l4(struct hinic_sq_task *task,
--
2.19.1
^ permalink raw reply related
* Re: [PATCH net] net: sched: gred: pass the right attribute to gred_change_table_def()
From: David Miller @ 2018-10-29 2:24 UTC (permalink / raw)
To: jakub.kicinski; +Cc: tgraf, jhs, xiyou.wangcong, netdev, oss-drivers
In-Reply-To: <20181026225106.5510-1-jakub.kicinski@netronome.com>
From: Jakub Kicinski <jakub.kicinski@netronome.com>
Date: Fri, 26 Oct 2018 15:51:06 -0700
> gred_change_table_def() takes a pointer to TCA_GRED_DPS attribute,
> and expects it will be able to interpret its contents as
> struct tc_gred_sopt. Pass the correct gred attribute, instead of
> TCA_OPTIONS.
>
> This bug meant the table definition could never be changed after
> Qdisc was initialized (unless whatever TCA_OPTIONS contained both
> passed netlink validation and was a valid struct tc_gred_sopt...).
...
> Fixes: f62d6b936df5 ("[PKT_SCHED]: GRED: Use central VQ change procedure")
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Quite an ancient bug :-)
Applied and queued up for -stable, thanks!
^ permalink raw reply
* Re: [PATCH net 0/2] macsec: linkstate fixes
From: David Miller @ 2018-10-29 2:26 UTC (permalink / raw)
To: sd; +Cc: netdev, radu.rendec, ptalbert
In-Reply-To: <cover.1540714256.git.sd@queasysnail.net>
From: Sabrina Dubroca <sd@queasysnail.net>
Date: Sun, 28 Oct 2018 09:33:08 +0100
> This series fixes issues with handling administrative and operstate of
> macsec devices.
>
> Radu Rendec proposed another version of the first patch [0] but I'd
> rather not follow the behavior of vlan devices, going with macvlan
> does instead. Patrick Talbert also reported the same issue to me.
>
> The second patch is a follow-up. The restriction on setting the device
> up is a bit unreasonable, and operstate provides the information we
> need in this case.
>
> [0] https://patchwork.ozlabs.org/patch/971374/
Series applied, thank you.
^ permalink raw reply
* Re: [PATCH net] net: diag: document swapped src/dst in udp_dump_one.
From: David Miller @ 2018-10-29 2:27 UTC (permalink / raw)
To: lorenzo; +Cc: netdev, zenczykowski, xemul, dsahern
In-Reply-To: <20181029001522.54391-1-lorenzo@google.com>
From: Lorenzo Colitti <lorenzo@google.com>
Date: Mon, 29 Oct 2018 09:15:22 +0900
> Since its inception, udp_dump_one has had a bug where userspace
> needs to swap src and dst addresses and ports in order to find
> the socket it wants. This is because it passes the socket source
> address to __udp[46]_lib_lookup's saddr argument, but those
> functions are intended to find local sockets matching received
> packets, so saddr is the remote address, not the local address.
>
> This can no longer be fixed for backwards compatibility reasons,
> so add a brief comment explaining that this is the case. This
> will avoid confusion and help ensure SOCK_DIAG implementations
> of new protocols don't have the same problem.
>
> Fixes: a925aa00a55 ("udp_diag: Implement the get_exact dumping functionality")
> Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
Applied, thanks.
^ permalink raw reply
* [PATCH] kselftests/bpf: use ping6 as the default ipv6 ping binary if it exists
From: Li Zhijian @ 2018-10-29 11:14 UTC (permalink / raw)
To: shuah, netdev, linux-kselftest; +Cc: linux-kernel, ast, daniel, Li Zhijian
ping binary on some distros doesn't support "ping -6" anymore.
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
---
tools/testing/selftests/bpf/test_skb_cgroup_id.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/bpf/test_skb_cgroup_id.sh b/tools/testing/selftests/bpf/test_skb_cgroup_id.sh
index 42544a9..a9bc6f8 100755
--- a/tools/testing/selftests/bpf/test_skb_cgroup_id.sh
+++ b/tools/testing/selftests/bpf/test_skb_cgroup_id.sh
@@ -10,7 +10,7 @@ wait_for_ip()
echo -n "Wait for testing link-local IP to become available "
for _i in $(seq ${MAX_PING_TRIES}); do
echo -n "."
- if ping -6 -q -c 1 -W 1 ff02::1%${TEST_IF} >/dev/null 2>&1; then
+ if $PING6 -c 1 -W 1 ff02::1%${TEST_IF} >/dev/null 2>&1; then
echo " OK"
return
fi
@@ -58,5 +58,6 @@ BPF_PROG_OBJ="${DIR}/test_skb_cgroup_id_kern.o"
BPF_PROG_SECTION="cgroup_id_logger"
BPF_PROG_ID=0
PROG="${DIR}/test_skb_cgroup_id_user"
+type ping6 >/dev/null 2>&1 && PING6="ping6" || PING6="ping -6"
main
--
2.7.4
^ permalink raw reply related
* Re: [PATCH v3 2/2] net: qcom/emac: add phy-handle support for ACPI
From: Wang, Dongsheng @ 2018-10-29 2:39 UTC (permalink / raw)
To: Andrew Lunn
Cc: Timur Tabi, Zheng, Joey, f.fainelli@gmail.com,
netdev@vger.kernel.org, robert.moore@intel.com, rjw@rjwysocki.net,
linux-acpi@vger.kernel.org
In-Reply-To: <20181026131301.GC30093@lunn.ch>
On 2018/10/26 21:12, Andrew Lunn wrote:
> On Fri, Oct 26, 2018 at 03:04:25AM +0000, Wang, Dongsheng wrote:
>> On 2018/10/26 10:37, Timur Tabi wrote:
>>> On 10/25/18 9:18 PM, Wang, Dongsheng wrote:
>>>> But when I was reading Documentation/acpi/DSD-properties-rules.txt, my
>>>> understanding is we should try to conform to DT bindings. So maybe ACPI
>>>> doesn't have such a document, just DT bindings.
>>> There was an attempt to document DSDs, but it was abandoned after a while.
>>>
>>> https://github.com/ahs3/dsd
>>>
>> Yes, here's a database concept, and I asked some Intel guys, the answer
>> I got was there is no such database or document. :(
> Hi Dongsheng
>
> If there is no clear documentation for ACPI, it becomes even more
> important that the xgene code is refactored into a central location,
> and you make use of it. We really need to avoid every ACPI ethernet
> driver doing its own thing.
However, without a document specifying MDIO and phy-handle, it is almost
difficult for us to do this. Because maybe the ACPI device or property
corresponding to each platform is different.
Just like APM looks different to us. APM's MDIO adev doesn't describe
the concept of port, and our platform does. Besides, I cannot get the
ACPI table of APM or other manufacturers.
The table of ACPI cannot be obtained from kernel source as easily as DT.
We can't know without a platform to do ACPI dump. Unless some of the
manufacturers have pushed the table to upstream.
So I think we might have a hard time doing this without a document. And
it's likely that this work involves code modifications by BIOS vendors.
Cheers,
Dongsheng
^ permalink raw reply
* Re: [PATCH] net/packet: fix packet drop as of virtio gso
From: Jason Wang @ 2018-10-29 2:40 UTC (permalink / raw)
To: Jianfeng Tan, netdev; +Cc: davem, mst
In-Reply-To: <a74d414f-bee1-9754-8735-81cb07dc430b@linux.alibaba.com>
On 2018/10/28 上午7:42, Jianfeng Tan wrote:
>
> On 10/8/2018 11:14 AM, Jason Wang wrote:
>>
>>
>> On 2018年09月29日 23:41, Jianfeng Tan wrote:
>>> When we use raw socket as the vhost backend, a packet from virito with
>>> gso offloading information, cannot be sent out in later validaton at
>>> xmit path, as we did not set correct skb->protocol which is further
>>> used
>>> for looking up the gso function.
>>
>> Hi:
>>
>> May I ask the reason for using raw socket for vhost? It was not a
>> common setup with little care in the past few years. And it was slow
>> since it lacks some recent improvements. Can it be replaced with e.g
>> macvtap?
>
> Hi Jason,
>
> Apologize for late response. We are in container environment, in which
> case veth is used mostly. Either tap or macvtap cannot be put into an
> isolated netns.
I think it can? See 17af2bce88d31e65ed73d638bb752d2e13c66ced.
> Another thing could be macvlan as the backend of vhost, which is not
> supported either. So unfortunately, improving raw socket is the only
> choice I suppose.
Btw, you can setup macvtap on top of veth. Does this help?
Thanks
>
> Thanks,
> Jianfeng
^ permalink raw reply
* Re: [PATCH] net/packet: support vhost mrg_rxbuf
From: Jason Wang @ 2018-10-29 2:54 UTC (permalink / raw)
To: Jianfeng Tan, netdev; +Cc: davem, mst
In-Reply-To: <20181027120445.21552-1-jianfeng.tan@linux.alibaba.com>
On 2018/10/27 下午8:04, Jianfeng Tan wrote:
> Previouly, virtio net header size is hardcoded to be 10, which makes
> the feature mrg_rxbuf not available.
>
> We redefine PACKET_VNET_HDR ioctl which treats user input as boolean,
> but now as int, 0, 10, 12, or everything else be treated as 10.
>
> There will be one case which is treated differently: if user input is
> 12, previously, the header size will be 10; but now it's 12.
>
> Signed-off-by: Jianfeng Tan <jianfeng.tan@linux.alibaba.com>
This should go for net-next which is closed. You may consider to
re-submit when it was open.
> ---
> net/packet/af_packet.c | 97 ++++++++++++++++++++++++++----------------
> net/packet/diag.c | 2 +-
> net/packet/internal.h | 2 +-
> 3 files changed, 63 insertions(+), 38 deletions(-)
>
> diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
> index ec3095f13aae..1bd7f4cdcc80 100644
> --- a/net/packet/af_packet.c
> +++ b/net/packet/af_packet.c
> @@ -1999,18 +1999,24 @@ static unsigned int run_filter(struct sk_buff *skb,
> }
>
> static int packet_rcv_vnet(struct msghdr *msg, const struct sk_buff *skb,
> - size_t *len)
> + size_t *len, int vnet_hdr_len)
> {
> + int res;
> struct virtio_net_hdr vnet_hdr;
>
> - if (*len < sizeof(vnet_hdr))
> + if (*len < vnet_hdr_len)
> return -EINVAL;
> - *len -= sizeof(vnet_hdr);
> + *len -= vnet_hdr_len;
>
> if (virtio_net_hdr_from_skb(skb, &vnet_hdr, vio_le(), true, 0))
> return -EINVAL;
>
> - return memcpy_to_msg(msg, (void *)&vnet_hdr, sizeof(vnet_hdr));
> + res = memcpy_to_msg(msg, (void *)&vnet_hdr, sizeof(vnet_hdr));
> + if (res == 0)
> + iov_iter_advance(&msg->msg_iter,
> + vnet_hdr_len - sizeof(vnet_hdr));
> +
> + return res;
> }
>
> /*
> @@ -2206,11 +2212,13 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
> po->tp_reserve;
> } else {
> unsigned int maclen = skb_network_offset(skb);
> + int vnet_hdr_sz = READ_ONCE(po->vnet_hdr_sz);
> +
> netoff = TPACKET_ALIGN(po->tp_hdrlen +
> (maclen < 16 ? 16 : maclen)) +
> po->tp_reserve;
> - if (po->has_vnet_hdr) {
> - netoff += sizeof(struct virtio_net_hdr);
> + if (vnet_hdr_sz) {
> + netoff += vnet_hdr_sz;
> do_vnet = true;
> }
> macoff = netoff - maclen;
> @@ -2429,19 +2437,6 @@ static int __packet_snd_vnet_parse(struct virtio_net_hdr *vnet_hdr, size_t len)
> return 0;
> }
>
> -static int packet_snd_vnet_parse(struct msghdr *msg, size_t *len,
> - struct virtio_net_hdr *vnet_hdr)
> -{
> - if (*len < sizeof(*vnet_hdr))
> - return -EINVAL;
> - *len -= sizeof(*vnet_hdr);
> -
> - if (!copy_from_iter_full(vnet_hdr, sizeof(*vnet_hdr), &msg->msg_iter))
> - return -EFAULT;
> -
> - return __packet_snd_vnet_parse(vnet_hdr, *len);
> -}
> -
> static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
> void *frame, struct net_device *dev, void *data, int tp_len,
> __be16 proto, unsigned char *addr, int hlen, int copylen,
> @@ -2609,6 +2604,7 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
> int len_sum = 0;
> int status = TP_STATUS_AVAILABLE;
> int hlen, tlen, copylen = 0;
> + int vnet_hdr_sz;
>
> mutex_lock(&po->pg_vec_lock);
>
> @@ -2648,7 +2644,8 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
> size_max = po->tx_ring.frame_size
> - (po->tp_hdrlen - sizeof(struct sockaddr_ll));
>
> - if ((size_max > dev->mtu + reserve + VLAN_HLEN) && !po->has_vnet_hdr)
> + vnet_hdr_sz = READ_ONCE(po->vnet_hdr_sz);
> + if ((size_max > dev->mtu + reserve + VLAN_HLEN) && !vnet_hdr_sz)
> size_max = dev->mtu + reserve + VLAN_HLEN;
>
> do {
> @@ -2668,10 +2665,10 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
> status = TP_STATUS_SEND_REQUEST;
> hlen = LL_RESERVED_SPACE(dev);
> tlen = dev->needed_tailroom;
> - if (po->has_vnet_hdr) {
> + if (vnet_hdr_sz) {
> vnet_hdr = data;
> - data += sizeof(*vnet_hdr);
> - tp_len -= sizeof(*vnet_hdr);
> + data += vnet_hdr_sz;
> + tp_len -= vnet_hdr_sz;
> if (tp_len < 0 ||
> __packet_snd_vnet_parse(vnet_hdr, tp_len)) {
> tp_len = -EINVAL;
> @@ -2696,7 +2693,7 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
> addr, hlen, copylen, &sockc);
> if (likely(tp_len >= 0) &&
> tp_len > dev->mtu + reserve &&
> - !po->has_vnet_hdr &&
> + !vnet_hdr_sz &&
> !packet_extra_vlan_len_allowed(dev, skb))
> tp_len = -EMSGSIZE;
>
> @@ -2715,7 +2712,7 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
> }
> }
>
> - if (po->has_vnet_hdr) {
> + if (vnet_hdr_sz) {
> if (virtio_net_hdr_to_skb(skb, vnet_hdr, vio_le())) {
> tp_len = -EINVAL;
> goto tpacket_error;
> @@ -2802,9 +2799,9 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
> int err, reserve = 0;
> struct sockcm_cookie sockc;
> struct virtio_net_hdr vnet_hdr = { 0 };
> + int vnet_hdr_sz;
> int offset = 0;
> struct packet_sock *po = pkt_sk(sk);
> - bool has_vnet_hdr = false;
> int hlen, tlen, linear;
> int extra_len = 0;
>
> @@ -2844,11 +2841,29 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
>
> if (sock->type == SOCK_RAW)
> reserve = dev->hard_header_len;
> - if (po->has_vnet_hdr) {
> - err = packet_snd_vnet_parse(msg, &len, &vnet_hdr);
> - if (err)
> +
> + vnet_hdr_sz = READ_ONCE(po->vnet_hdr_sz);
> + if (vnet_hdr_sz) {
> + if (len < vnet_hdr_sz) {
> + err = -EINVAL;
> goto out_unlock;
> - has_vnet_hdr = true;
> + }
> + len -= vnet_hdr_sz;
> +
> + if (!copy_from_iter_full(&vnet_hdr, sizeof(vnet_hdr),
> + &msg->msg_iter)) {
> + err = -EFAULT;
> + goto out_unlock;
> + }
> +
> + if (__packet_snd_vnet_parse(&vnet_hdr, len)) {
> + err = -EINVAL;
> + goto out_unlock;
> + }
Any reason to open code packet_snd_vnet_parse() here?
> +
> + /* TODO: check hdr_len with len? */
> +
> + iov_iter_advance(&msg->msg_iter, vnet_hdr_sz - sizeof(vnet_hdr));
> }
>
> if (unlikely(sock_flag(sk, SOCK_NOFCS))) {
> @@ -2912,7 +2927,7 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
> skb->mark = sockc.mark;
> skb->tstamp = sockc.transmit_time;
>
> - if (has_vnet_hdr) {
> + if (vnet_hdr_sz) {
> err = virtio_net_hdr_to_skb(skb, &vnet_hdr, vio_le());
> if (err)
> goto out_free;
> @@ -3307,11 +3322,11 @@ static int packet_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
> if (pkt_sk(sk)->pressure)
> packet_rcv_has_room(pkt_sk(sk), NULL);
>
> - if (pkt_sk(sk)->has_vnet_hdr) {
> - err = packet_rcv_vnet(msg, skb, &len);
> + vnet_hdr_len = READ_ONCE(pkt_sk(sk)->vnet_hdr_sz);
> + if (vnet_hdr_len) {
> + err = packet_rcv_vnet(msg, skb, &len, vnet_hdr_len);
> if (err)
> goto out_free;
> - vnet_hdr_len = sizeof(struct virtio_net_hdr);
> }
>
> /* You lose any data beyond the buffer you gave. If it worries
> @@ -3772,7 +3787,17 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv
> if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) {
> ret = -EBUSY;
> } else {
> - po->has_vnet_hdr = !!val;
> + /* Previouly we treat user input as boolean (!!val),
> + * now we treat it as int. After the below correction,
> + * the only violation case is 12, which results in
> + * vnet header size of 12 instead of 10.
> + */
> + if (val &&
> + val != sizeof(struct virtio_net_hdr) &&
> + val != sizeof(struct virtio_net_hdr_mrg_rxbuf))
> + val = sizeof(struct virtio_net_hdr);
> +
> + po->vnet_hdr_sz = val;
> ret = 0;
> }
> release_sock(sk);
> @@ -3903,7 +3928,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
> val = po->origdev;
> break;
> case PACKET_VNET_HDR:
> - val = po->has_vnet_hdr;
> + val = po->vnet_hdr_sz;
So the change here is noticeable by userspace. Maybe we need a new opt
for this?
Thanks
> break;
> case PACKET_VERSION:
> val = po->tp_version;
> diff --git a/net/packet/diag.c b/net/packet/diag.c
> index 7ef1c881ae74..950015b6704f 100644
> --- a/net/packet/diag.c
> +++ b/net/packet/diag.c
> @@ -26,7 +26,7 @@ static int pdiag_put_info(const struct packet_sock *po, struct sk_buff *nlskb)
> pinfo.pdi_flags |= PDI_AUXDATA;
> if (po->origdev)
> pinfo.pdi_flags |= PDI_ORIGDEV;
> - if (po->has_vnet_hdr)
> + if (po->vnet_hdr_sz)
> pinfo.pdi_flags |= PDI_VNETHDR;
> if (po->tp_loss)
> pinfo.pdi_flags |= PDI_LOSS;
> diff --git a/net/packet/internal.h b/net/packet/internal.h
> index 3bb7c5fb3bff..11bc75950f28 100644
> --- a/net/packet/internal.h
> +++ b/net/packet/internal.h
> @@ -115,9 +115,9 @@ struct packet_sock {
> unsigned int running; /* bind_lock must be held */
> unsigned int auxdata:1, /* writer must hold sock lock */
> origdev:1,
> - has_vnet_hdr:1,
> tp_loss:1,
> tp_tx_has_off:1;
> + int vnet_hdr_sz;
> int pressure;
> int ifindex; /* bound device */
> __be16 num;
^ permalink raw reply
* [v2, PATCH 0/2] add Ethernet driver support for mt2712
From: Biao Huang @ 2018-10-29 3:04 UTC (permalink / raw)
To: davem, robh+dt
Cc: honghui.zhang, yt.shen, liguo.zhang, mark.rutland, sean.wang,
nelson.chang, matthias.bgg, biao.huang, netdev, devicetree,
linux-kernel, linux-arm-kernel, linux-mediatek, joabreu, andrew
The mt2712 Ethernet IP is from Synopsys, so extend stmmac to support mt2712.
^ permalink raw reply
* [PATCH 1/2] net:stmmac: dwmac-mediatek: add support for mt2712
From: Biao Huang @ 2018-10-29 3:04 UTC (permalink / raw)
To: davem, robh+dt
Cc: honghui.zhang, yt.shen, liguo.zhang, mark.rutland, sean.wang,
nelson.chang, matthias.bgg, biao.huang, netdev, devicetree,
linux-kernel, linux-arm-kernel, linux-mediatek, joabreu, andrew
In-Reply-To: <1540782294-27721-1-git-send-email-biao.huang@mediatek.com>
Add Ethernet support for MediaTek SoCs from the mt2712 family
Signed-off-by: Biao Huang <biao.huang@mediatek.com>
---
drivers/net/ethernet/stmicro/stmmac/Kconfig | 8 +
drivers/net/ethernet/stmicro/stmmac/Makefile | 1 +
.../net/ethernet/stmicro/stmmac/dwmac-mediatek.c | 364 ++++++++++++++++++++
3 files changed, 373 insertions(+)
create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
index edf2036..76d779e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
+++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
@@ -75,6 +75,14 @@ config DWMAC_LPC18XX
---help---
Support for NXP LPC18xx/43xx DWMAC Ethernet.
+config DWMAC_MEDIATEK
+ tristate "MediaTek MT27xx GMAC support"
+ depends on OF
+ help
+ Support for MediaTek GMAC Ethernet controller.
+
+ This selects the MT2712 SoC support for the stmmac driver.
+
config DWMAC_MESON
tristate "Amlogic Meson dwmac support"
default ARCH_MESON
diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile
index 99967a8..bf09701 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Makefile
+++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_STMMAC_PLATFORM) += stmmac-platform.o
obj-$(CONFIG_DWMAC_ANARION) += dwmac-anarion.o
obj-$(CONFIG_DWMAC_IPQ806X) += dwmac-ipq806x.o
obj-$(CONFIG_DWMAC_LPC18XX) += dwmac-lpc18xx.o
+obj-$(CONFIG_DWMAC_MEDIATEK) += dwmac-mediatek.o
obj-$(CONFIG_DWMAC_MESON) += dwmac-meson.o dwmac-meson8b.o
obj-$(CONFIG_DWMAC_OXNAS) += dwmac-oxnas.o
obj-$(CONFIG_DWMAC_ROCKCHIP) += dwmac-rk.o
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
new file mode 100644
index 0000000..9ccf3a5
--- /dev/null
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
@@ -0,0 +1,364 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// Copyright (c) 2018 MediaTek Inc.
+#include <linux/io.h>
+#include <linux/mfd/syscon.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_net.h>
+#include <linux/regmap.h>
+#include <linux/stmmac.h>
+
+#include "stmmac.h"
+#include "stmmac_platform.h"
+
+/* Peri Configuration register */
+#define PERI_ETH_PHY_INTF_SEL 0x418
+#define PHY_INTF_MII_GMII 0
+#define PHY_INTF_RGMII 1
+#define PHY_INTF_RMII 4
+#define RMII_CLK_SRC_RXC BIT(4)
+#define RMII_CLK_SRC_INTERNAL BIT(5)
+
+#define PERI_ETH_PHY_DLY 0x428
+#define PHY_DLY_GTXC_INV BIT(6)
+#define PHY_DLY_GTXC_ENABLE BIT(5)
+#define PHY_DLY_GTXC_STAGES GENMASK(4, 0)
+#define PHY_DLY_TXC_INV BIT(20)
+#define PHY_DLY_TXC_ENABLE BIT(19)
+#define PHY_DLY_TXC_STAGES GENMASK(18, 14)
+#define PHY_DLY_TXC_SHIFT 14
+#define PHY_DLY_RXC_INV BIT(13)
+#define PHY_DLY_RXC_ENABLE BIT(12)
+#define PHY_DLY_RXC_STAGES GENMASK(11, 7)
+#define PHY_DLY_RXC_SHIFT 7
+
+#define PERI_ETH_DLY_FINE 0x800
+#define ETH_RMII_DLY_TX_INV BIT(2)
+#define ETH_FINE_DLY_GTXC BIT(1)
+#define ETH_FINE_DLY_RXC BIT(0)
+
+enum dwmac_clks_map {
+ DWMAC_CLK_AXI_DRAM,
+ DWMAC_CLK_APB_REG,
+ DWMAC_CLK_MAC_EXT,
+ DWMAC_CLK_MAC_PARENT,
+ DWMAC_CLK_PTP_REF,
+ DWMAC_CLK_PTP_PARENT,
+ DWMAC_CLK_PTP_TOP,
+ DWMAC_CLK_MAX
+};
+
+struct mac_delay_struct {
+ u32 tx_delay;
+ u32 rx_delay;
+ u32 tx_inv;
+ u32 rx_inv;
+};
+
+struct mediatek_dwmac_plat_data {
+ struct device *dev;
+ struct regmap *peri_regmap;
+ struct clk *clks[DWMAC_CLK_MAX];
+ struct device_node *np;
+ int phy_mode;
+ struct mac_delay_struct mac_delay;
+ const struct mediatek_dwmac_variant *variant;
+ int fine_tune;
+ int rmii_rxc;
+};
+
+struct mediatek_dwmac_variant {
+ int (*dwmac_config_dt)(struct mediatek_dwmac_plat_data *plat);
+ int (*dwmac_enable_clks)(struct mediatek_dwmac_plat_data *plat);
+ void (*dwmac_disable_clks)(struct mediatek_dwmac_plat_data *plat);
+};
+
+static const char * const mediatek_dwmac_clks_name[] = {
+ "axi", "apb", "mac_ext", "mac_parent", "ptp_ref", "ptp_parent", "ptp_top"
+};
+
+static int mt2712_set_interface(struct mediatek_dwmac_plat_data *plat)
+{
+ int rmii_rxc = plat->rmii_rxc ? RMII_CLK_SRC_RXC : 0;
+ u32 intf_val = 0;
+
+ /* select phy interface in top control domain */
+ switch (plat->phy_mode) {
+ case PHY_INTERFACE_MODE_MII:
+ intf_val |= PHY_INTF_MII_GMII;
+ break;
+ case PHY_INTERFACE_MODE_RMII:
+ intf_val |= PHY_INTF_RMII;
+ intf_val |= rmii_rxc;
+ break;
+ case PHY_INTERFACE_MODE_RGMII:
+ case PHY_INTERFACE_MODE_RGMII_TXID:
+ case PHY_INTERFACE_MODE_RGMII_RXID:
+ case PHY_INTERFACE_MODE_RGMII_ID:
+ intf_val |= PHY_INTF_RGMII;
+ break;
+ default:
+ pr_err("phy interface not support\n");
+ return -EINVAL;
+ }
+
+ regmap_write(plat->peri_regmap, PERI_ETH_PHY_INTF_SEL, intf_val);
+
+ return 0;
+}
+
+static int mt2712_set_delay(struct mediatek_dwmac_plat_data *plat)
+{
+ struct mac_delay_struct *mac_delay = &plat->mac_delay;
+ u32 delay_val = 0;
+ u32 fine_val = 0;
+
+ switch (plat->phy_mode) {
+ case PHY_INTERFACE_MODE_MII:
+ delay_val |= mac_delay->tx_delay ? PHY_DLY_TXC_ENABLE : 0;
+ delay_val |= (mac_delay->tx_delay << PHY_DLY_TXC_SHIFT) &
+ PHY_DLY_TXC_STAGES;
+ delay_val |= mac_delay->tx_inv ? PHY_DLY_TXC_INV : 0;
+ delay_val |= mac_delay->rx_delay ? PHY_DLY_RXC_ENABLE : 0;
+ delay_val |= (mac_delay->rx_delay << PHY_DLY_RXC_SHIFT) &
+ PHY_DLY_RXC_STAGES;
+ delay_val |= mac_delay->rx_inv ? PHY_DLY_RXC_INV : 0;
+ break;
+ case PHY_INTERFACE_MODE_RMII:
+ if (plat->rmii_rxc) {
+ delay_val |= mac_delay->rx_delay ?
+ PHY_DLY_RXC_ENABLE : 0;
+ delay_val |= (mac_delay->rx_delay <<
+ PHY_DLY_RXC_SHIFT) & PHY_DLY_RXC_STAGES;
+ delay_val |= mac_delay->rx_inv ? PHY_DLY_RXC_INV : 0;
+ fine_val |= mac_delay->tx_inv ?
+ ETH_RMII_DLY_TX_INV : 0;
+ } else {
+ delay_val |= mac_delay->tx_delay ?
+ PHY_DLY_TXC_ENABLE : 0;
+ delay_val |= (mac_delay->tx_delay <<
+ PHY_DLY_TXC_SHIFT) & PHY_DLY_TXC_STAGES;
+ delay_val |= mac_delay->tx_inv ? PHY_DLY_TXC_INV : 0;
+ fine_val |= mac_delay->rx_inv ?
+ ETH_RMII_DLY_TX_INV : 0;
+ }
+ break;
+ case PHY_INTERFACE_MODE_RGMII:
+ fine_val = plat->fine_tune ?
+ (ETH_FINE_DLY_GTXC | ETH_FINE_DLY_RXC) : 0;
+ delay_val |= mac_delay->tx_delay ? PHY_DLY_GTXC_ENABLE : 0;
+ delay_val |= mac_delay->tx_delay & PHY_DLY_GTXC_STAGES;
+ delay_val |= mac_delay->tx_inv ? PHY_DLY_GTXC_INV : 0;
+ delay_val |= mac_delay->rx_delay ? PHY_DLY_RXC_ENABLE : 0;
+ delay_val |= (mac_delay->rx_delay << PHY_DLY_RXC_SHIFT) &
+ PHY_DLY_RXC_STAGES;
+ delay_val |= mac_delay->rx_inv ? PHY_DLY_RXC_INV : 0;
+ break;
+ case PHY_INTERFACE_MODE_RGMII_TXID:
+ fine_val = plat->fine_tune ? ETH_FINE_DLY_RXC : 0;
+ delay_val |= mac_delay->rx_delay ? PHY_DLY_RXC_ENABLE : 0;
+ delay_val |= (mac_delay->rx_delay << PHY_DLY_RXC_SHIFT) &
+ PHY_DLY_RXC_STAGES;
+ delay_val |= mac_delay->rx_inv ? PHY_DLY_RXC_INV : 0;
+ break;
+ case PHY_INTERFACE_MODE_RGMII_RXID:
+ fine_val = plat->fine_tune ? ETH_FINE_DLY_GTXC : 0;
+ delay_val |= mac_delay->tx_delay ? PHY_DLY_GTXC_ENABLE : 0;
+ delay_val |= mac_delay->tx_delay & PHY_DLY_GTXC_STAGES;
+ delay_val |= mac_delay->tx_inv ? PHY_DLY_GTXC_INV : 0;
+ break;
+ case PHY_INTERFACE_MODE_RGMII_ID:
+ break;
+ default:
+ pr_err("phy interface not support\n");
+ return -EINVAL;
+ }
+ regmap_write(plat->peri_regmap, PERI_ETH_PHY_DLY, delay_val);
+ regmap_write(plat->peri_regmap, PERI_ETH_DLY_FINE, fine_val);
+
+ return 0;
+}
+
+static int mt2712_get_clks(struct mediatek_dwmac_plat_data *plat)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(plat->clks); i++) {
+ plat->clks[i] = devm_clk_get(plat->dev,
+ mediatek_dwmac_clks_name[i]);
+ if (IS_ERR(plat->clks[i]))
+ return PTR_ERR(plat->clks[i]);
+ }
+
+ return 0;
+}
+
+static int mt2712_enable_clks(struct mediatek_dwmac_plat_data *plat)
+{
+ int clk, ret;
+
+ for (clk = 0; clk < DWMAC_CLK_MAX ; clk++) {
+ ret = clk_prepare_enable(plat->clks[clk]);
+ if (ret)
+ goto err_disable_clks;
+ }
+
+ ret = clk_set_parent(plat->clks[DWMAC_CLK_MAC_EXT], plat->clks[DWMAC_CLK_MAC_PARENT]);
+ if (ret)
+ goto err_disable_clks;
+
+ ret = clk_set_parent(plat->clks[DWMAC_CLK_PTP_REF], plat->clks[DWMAC_CLK_PTP_PARENT]);
+ if (ret)
+ goto err_disable_clks;
+
+ return 0;
+
+err_disable_clks:
+ while (--clk >= 0)
+ clk_disable_unprepare(plat->clks[clk]);
+
+ return ret;
+}
+
+static void mt2712_disable_clks(struct mediatek_dwmac_plat_data *plat)
+{
+ int clk;
+
+ for (clk = DWMAC_CLK_MAX - 1; clk >= 0; clk--)
+ clk_disable_unprepare(plat->clks[clk]);
+}
+
+static int mt2712_config_dt(struct mediatek_dwmac_plat_data *plat)
+{
+ u32 mac_timings[4];
+
+ plat->peri_regmap = syscon_regmap_lookup_by_compatible("mediatek,mt2712-pericfg");
+ if (IS_ERR(plat->peri_regmap)) {
+ dev_err(plat->dev, "Failed to get pericfg syscon\n");
+ return PTR_ERR(plat->peri_regmap);
+ }
+
+ if (!of_property_read_u32_array(plat->np, "mac-delay", mac_timings,
+ ARRAY_SIZE(mac_timings))) {
+ plat->mac_delay.tx_delay = mac_timings[0];
+ plat->mac_delay.rx_delay = mac_timings[1];
+ plat->mac_delay.tx_inv = mac_timings[2];
+ plat->mac_delay.rx_inv = mac_timings[3];
+ }
+
+ plat->fine_tune = of_property_read_bool(plat->np, "fine-tune");
+
+ plat->rmii_rxc = of_property_read_bool(plat->np, "rmii-rxc");
+
+ mt2712_set_interface(plat);
+
+ mt2712_set_delay(plat);
+
+ return mt2712_get_clks(plat);
+}
+
+static const struct mediatek_dwmac_variant mt2712_gmac_variant = {
+ .dwmac_config_dt = mt2712_config_dt,
+ .dwmac_enable_clks = mt2712_enable_clks,
+ .dwmac_disable_clks = mt2712_disable_clks,
+};
+
+static int mediatek_dwmac_config_dt(struct mediatek_dwmac_plat_data *plat)
+{
+ const struct mediatek_dwmac_variant *variant = plat->variant;
+
+ /* Set the DMA mask, 4GB mode enabled */
+ dma_set_mask_and_coherent(plat->dev, DMA_BIT_MASK(33));
+
+ return variant->dwmac_config_dt(plat);
+}
+
+static int mediatek_dwmac_init(struct platform_device *pdev, void *priv)
+{
+ struct mediatek_dwmac_plat_data *plat = priv;
+ const struct mediatek_dwmac_variant *variant = plat->variant;
+
+ return variant->dwmac_enable_clks(plat);
+}
+
+static void mediatek_dwmac_exit(struct platform_device *pdev, void *priv)
+{
+ struct mediatek_dwmac_plat_data *plat = priv;
+ const struct mediatek_dwmac_variant *variant = plat->variant;
+
+ variant->dwmac_disable_clks(plat);
+}
+
+static int mediatek_dwmac_probe(struct platform_device *pdev)
+{
+ int ret = 0;
+ struct plat_stmmacenet_data *plat_dat;
+ struct stmmac_resources stmmac_res;
+ struct mediatek_dwmac_plat_data *priv_plat;
+
+ priv_plat = devm_kzalloc(&pdev->dev, sizeof(*priv_plat), GFP_KERNEL);
+ if (!priv_plat)
+ return -ENOMEM;
+
+ priv_plat->variant = of_device_get_match_data(&pdev->dev);
+ if (!priv_plat->variant) {
+ dev_err(&pdev->dev, "Missing dwmac-mediatek variant\n");
+ return -EINVAL;
+ }
+
+ priv_plat->dev = &pdev->dev;
+ priv_plat->np = pdev->dev.of_node;
+ priv_plat->phy_mode = of_get_phy_mode(priv_plat->np);
+
+ ret = mediatek_dwmac_config_dt(priv_plat);
+ if (ret)
+ return ret;
+
+ ret = stmmac_get_platform_resources(pdev, &stmmac_res);
+ if (ret)
+ return ret;
+
+ plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
+ if (IS_ERR(plat_dat))
+ return PTR_ERR(plat_dat);
+
+ plat_dat->interface = priv_plat->phy_mode;
+ /* clk_csr_i = 250-300MHz & MDC = clk_csr_i/124 */
+ plat_dat->clk_csr = 5;
+ plat_dat->has_gmac4 = 1;
+ plat_dat->has_gmac = 0;
+ plat_dat->pmt = 0;
+ plat_dat->maxmtu = 1500;
+ plat_dat->bsp_priv = priv_plat;
+ plat_dat->init = mediatek_dwmac_init;
+ plat_dat->exit = mediatek_dwmac_exit;
+ mediatek_dwmac_init(pdev, priv_plat);
+
+ ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
+ if (ret) {
+ stmmac_remove_config_dt(pdev, plat_dat);
+ return ret;
+ }
+
+ return 0;
+}
+
+static const struct of_device_id mediatek_dwmac_match[] = {
+ { .compatible = "mediatek,mt2712-gmac",
+ .data = &mt2712_gmac_variant },
+ { }
+};
+
+MODULE_DEVICE_TABLE(of, mediatek_dwmac_match);
+
+static struct platform_driver mediatek_dwmac_driver = {
+ .probe = mediatek_dwmac_probe,
+ .remove = stmmac_pltfr_remove,
+ .driver = {
+ .name = "dwmac-mediatek",
+ .pm = &stmmac_pltfr_pm_ops,
+ .of_match_table = mediatek_dwmac_match,
+ },
+};
+module_platform_driver(mediatek_dwmac_driver);
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH 1/2] net:stmmac: dwmac-mediatek: add support for mt2712
From: Andrew Lunn @ 2018-10-29 12:27 UTC (permalink / raw)
To: Biao Huang
Cc: davem, robh+dt, honghui.zhang, yt.shen, liguo.zhang, mark.rutland,
sean.wang, nelson.chang, matthias.bgg, netdev, devicetree,
linux-kernel, linux-arm-kernel, linux-mediatek, joabreu
In-Reply-To: <1540782294-27721-2-git-send-email-biao.huang@mediatek.com>
> +static int mt2712_config_dt(struct mediatek_dwmac_plat_data *plat)
> +{
> + u32 mac_timings[4];
> +
> + plat->peri_regmap = syscon_regmap_lookup_by_compatible("mediatek,mt2712-pericfg");
> + if (IS_ERR(plat->peri_regmap)) {
> + dev_err(plat->dev, "Failed to get pericfg syscon\n");
> + return PTR_ERR(plat->peri_regmap);
> + }
> +
> + if (!of_property_read_u32_array(plat->np, "mac-delay", mac_timings,
> + ARRAY_SIZE(mac_timings))) {
> + plat->mac_delay.tx_delay = mac_timings[0];
> + plat->mac_delay.rx_delay = mac_timings[1];
> + plat->mac_delay.tx_inv = mac_timings[2];
> + plat->mac_delay.rx_inv = mac_timings[3];
> + }
> +
> + plat->fine_tune = of_property_read_bool(plat->np, "fine-tune");
> +
> + plat->rmii_rxc = of_property_read_bool(plat->np, "rmii-rxc");
Please add document for these properties in the binding.
Ideally, you should reuse the binding that some of the other stmmac
glue layer uses. e.g. there is already allwinner,tx-delay-ps,
allwinner,rx-delay-ps.
Thanks
Andrew
^ permalink raw reply
* Re: [PATCH] net/packet: fix packet drop as of virtio gso
From: Jianfeng Tan @ 2018-10-29 3:51 UTC (permalink / raw)
To: Jason Wang, netdev; +Cc: davem, mst
In-Reply-To: <7e894134-0178-e9e0-c584-8c607a270901@redhat.com>
On 10/29/2018 10:40 AM, Jason Wang wrote:
>
> On 2018/10/28 上午7:42, Jianfeng Tan wrote:
>>
>> On 10/8/2018 11:14 AM, Jason Wang wrote:
>>>
>>>
>>> On 2018年09月29日 23:41, Jianfeng Tan wrote:
>>>> When we use raw socket as the vhost backend, a packet from virito with
>>>> gso offloading information, cannot be sent out in later validaton at
>>>> xmit path, as we did not set correct skb->protocol which is further
>>>> used
>>>> for looking up the gso function.
>>>
>>> Hi:
>>>
>>> May I ask the reason for using raw socket for vhost? It was not a
>>> common setup with little care in the past few years. And it was slow
>>> since it lacks some recent improvements. Can it be replaced with e.g
>>> macvtap?
>>
>> Hi Jason,
>>
>> Apologize for late response. We are in container environment, in
>> which case veth is used mostly. Either tap or macvtap cannot be put
>> into an isolated netns.
>
>
> I think it can? See 17af2bce88d31e65ed73d638bb752d2e13c66ced.
This commit gives an example of creating a macvtap on to of a veth
interface, which is interesting to try. The shortcoming, if I understand
it correctly, it still needs the network plugin to create the macvtap
interface for containers.
>
>
>> Another thing could be macvlan as the backend of vhost, which is not
>> supported either. So unfortunately, improving raw socket is the only
>> choice I suppose.
>
>
> Btw, you can setup macvtap on top of veth. Does this help?
Good idea. Will have a try.
Thanks,
Jianfeng
>
> Thanks
>
>
>>
>> Thanks,
>> Jianfeng
^ permalink raw reply
* HOPING TO HEAR FROM YOU SOONEST!!
From: Mrs. Diane Archimbaud @ 2018-10-29 4:00 UTC (permalink / raw)
My Sincere Greetings,
I am MRS. DIANE ARCHIMBAUD, I decided to donate what I have to you for
investment towards the good work of charity organization, and also to
help the motherless and the less privileged ones and to carry out a
charitable works in your Country and around the World on my Behalf.
I am diagnosing of throat Cancer, hospitalize for good 2 years and
some months now and quite obvious that I have few days to live, and I
am a Widow no child; I decided to will/donate the sum of $5.5 million
to you for the good work of God, and also to help the motherless and
less privilege and also forth assistance of the widows. At the moment
I cannot take any telephone calls right now due to the fact that my
relatives (that have squandered the funds for this purpose before) are
around me and my health status also. I have adjusted my will and my
lawyer is aware.
I have willed those properties to you by quoting my Personal File
Routing and Account Information. And I have also notified the bank
that I am willing that properties to you for a good, effective and
prudent work. I know I don't know you but I have been directed to do
this by God. I will be going in for a surgery soon and I want to make
sure that I make this donation before undergoing this surgery.
I will need your support to make this dream come through, could you
let me know your interest to enable me give you further information.
And I hereby advice to contact me by this email address
(diane.archim@yahoo.com)
Yours Faithfully,
Mrs. Diane Archimbaud.
^ permalink raw reply
* [PATCH v2 bpf-next] bpf: Extend the sk_lookup() helper to XDP hookpoint.
From: Nitin Hande @ 2018-10-29 4:02 UTC (permalink / raw)
To: daniel
Cc: Alexei Starovoitov, Joe Stringer, Martin Lau,
netdev@vger.kernel.org, Jesper Dangaard Brouer, John Fastabend
This patch proposes to extend the sk_lookup() BPF API to the
XDP hookpoint. The sk_lookup() helper supports a lookup
on incoming packet to find the corresponding socket that will
receive this packet. Current support for this BPF API is
at the tc hookpoint. This patch will extend this API at XDP
hookpoint. A XDP program can map the incoming packet to the
5-tuple parameter and invoke the API to find the corresponding
socket structure.
Signed-off-by: Nitin Hande <Nitin.Hande@gmail.com>
---
v1->v2
- For sockets with reuseport socket option, there was a case
where the sk returned by the helper can vary due to the
absence of skb at XDP hookpoint as compared to TC. v2 removes
that variance by passing NULL for skb from both TC and XDP
hookpoint. As a result, for reuseport sockets, the helper
will now consistently return the same sk from reuse->socks[]
using the hash of the packet after being invoked from either
TC or XDP hookpoint. This also makes the helper stateless,
else there are certain scenarios where upper layer records
skb.
- Add relevant documentation to the helper.
---
include/uapi/linux/bpf.h | 4 ++
net/core/filter.c | 105 ++++++++++++++++++++++++++++++++-------
2 files changed, 90 insertions(+), 19 deletions(-)
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index 852dc17ab47a..47d606d744cc 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -2201,6 +2201,8 @@ union bpf_attr {
* **CONFIG_NET** configuration option.
* Return
* Pointer to *struct bpf_sock*, or NULL in case of failure.
+ * For sockets with reuseport option, *struct bpf_sock*
+ * return is from reuse->socks[] using hash of the packet.
*
* struct bpf_sock *bpf_sk_lookup_udp(void *ctx, struct bpf_sock_tuple *tuple, u32 tuple_size, u32 netns, u64 flags)
* Description
@@ -2233,6 +2235,8 @@ union bpf_attr {
* **CONFIG_NET** configuration option.
* Return
* Pointer to *struct bpf_sock*, or NULL in case of failure.
+ * For sockets with reuseport option, *struct bpf_sock*
+ * return is from reuse->socks[] using hash of the packet.
*
* int bpf_sk_release(struct bpf_sock *sk)
* Description
diff --git a/net/core/filter.c b/net/core/filter.c
index 35c6933c2622..bc20b5bfcaf1 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -4825,38 +4825,32 @@ static const struct bpf_func_proto bpf_lwt_seg6_adjust_srh_proto = {
#ifdef CONFIG_INET
static struct sock *sk_lookup(struct net *net, struct bpf_sock_tuple *tuple,
- struct sk_buff *skb, u8 family, u8 proto)
+ int dif, int sdif, u8 family, u8 proto)
{
bool refcounted = false;
struct sock *sk = NULL;
- int dif = 0;
-
- if (skb->dev)
- dif = skb->dev->ifindex;
if (family == AF_INET) {
__be32 src4 = tuple->ipv4.saddr;
__be32 dst4 = tuple->ipv4.daddr;
- int sdif = inet_sdif(skb);
if (proto == IPPROTO_TCP)
- sk = __inet_lookup(net, &tcp_hashinfo, skb, 0,
+ sk = __inet_lookup(net, &tcp_hashinfo, NULL, 0,
src4, tuple->ipv4.sport,
dst4, tuple->ipv4.dport,
dif, sdif, &refcounted);
else
sk = __udp4_lib_lookup(net, src4, tuple->ipv4.sport,
dst4, tuple->ipv4.dport,
- dif, sdif, &udp_table, skb);
+ dif, sdif, &udp_table, NULL);
#if IS_ENABLED(CONFIG_IPV6)
} else {
struct in6_addr *src6 = (struct in6_addr *)&tuple->ipv6.saddr;
struct in6_addr *dst6 = (struct in6_addr *)&tuple->ipv6.daddr;
u16 hnum = ntohs(tuple->ipv6.dport);
- int sdif = inet6_sdif(skb);
if (proto == IPPROTO_TCP)
- sk = __inet6_lookup(net, &tcp_hashinfo, skb, 0,
+ sk = __inet6_lookup(net, &tcp_hashinfo, NULL, 0,
src6, tuple->ipv6.sport,
dst6, hnum,
dif, sdif, &refcounted);
@@ -4865,7 +4859,7 @@ static struct sock *sk_lookup(struct net *net, struct bpf_sock_tuple *tuple,
src6, tuple->ipv6.sport,
dst6, hnum,
dif, sdif,
- &udp_table, skb);
+ &udp_table, NULL);
#endif
}
@@ -4882,31 +4876,33 @@ static struct sock *sk_lookup(struct net *net, struct bpf_sock_tuple *tuple,
* callers to satisfy BPF_CALL declarations.
*/
static unsigned long
-bpf_sk_lookup(struct sk_buff *skb, struct bpf_sock_tuple *tuple, u32 len,
- u8 proto, u64 netns_id, u64 flags)
+__bpf_sk_lookup(struct sk_buff *skb, struct bpf_sock_tuple *tuple, u32 len,
+ struct net *caller_net, u32 ifindex, u8 proto, u64 netns_id,
+ u64 flags)
{
- struct net *caller_net;
struct sock *sk = NULL;
u8 family = AF_UNSPEC;
struct net *net;
+ int sdif;
family = len == sizeof(tuple->ipv4) ? AF_INET : AF_INET6;
if (unlikely(family == AF_UNSPEC || netns_id > U32_MAX || flags))
goto out;
- if (skb->dev)
- caller_net = dev_net(skb->dev);
+ if (family == AF_INET)
+ sdif = inet_sdif(skb);
else
- caller_net = sock_net(skb->sk);
+ sdif = inet6_sdif(skb);
+
if (netns_id) {
net = get_net_ns_by_id(caller_net, netns_id);
if (unlikely(!net))
goto out;
- sk = sk_lookup(net, tuple, skb, family, proto);
+ sk = sk_lookup(net, tuple, ifindex, sdif, family, proto);
put_net(net);
} else {
net = caller_net;
- sk = sk_lookup(net, tuple, skb, family, proto);
+ sk = sk_lookup(net, tuple, ifindex, sdif, family, proto);
}
if (sk)
@@ -4915,6 +4911,25 @@ bpf_sk_lookup(struct sk_buff *skb, struct bpf_sock_tuple *tuple, u32 len,
return (unsigned long) sk;
}
+static unsigned long
+bpf_sk_lookup(struct sk_buff *skb, struct bpf_sock_tuple *tuple, u32 len,
+ u8 proto, u64 netns_id, u64 flags)
+{
+ struct net *caller_net;
+ int ifindex;
+
+ if (skb->dev) {
+ caller_net = dev_net(skb->dev);
+ ifindex = skb->dev->ifindex;
+ } else {
+ caller_net = sock_net(skb->sk);
+ ifindex = 0;
+ }
+
+ return __bpf_sk_lookup(skb, tuple, len, caller_net, ifindex,
+ proto, netns_id, flags);
+}
+
BPF_CALL_5(bpf_sk_lookup_tcp, struct sk_buff *, skb,
struct bpf_sock_tuple *, tuple, u32, len, u64, netns_id, u64, flags)
{
@@ -4964,6 +4979,50 @@ static const struct bpf_func_proto bpf_sk_release_proto = {
.ret_type = RET_INTEGER,
.arg1_type = ARG_PTR_TO_SOCKET,
};
+
+BPF_CALL_5(bpf_xdp_sk_lookup_udp, struct xdp_buff *, ctx,
+ struct bpf_sock_tuple *, tuple, u32, len, u32, netns_id, u64, flags)
+{
+ struct net *caller_net = dev_net(ctx->rxq->dev);
+ int ifindex = ctx->rxq->dev->ifindex;
+
+ return __bpf_sk_lookup(NULL, tuple, len, caller_net, ifindex,
+ IPPROTO_UDP, netns_id, flags);
+}
+
+static const struct bpf_func_proto bpf_xdp_sk_lookup_udp_proto = {
+ .func = bpf_xdp_sk_lookup_udp,
+ .gpl_only = false,
+ .pkt_access = true,
+ .ret_type = RET_PTR_TO_SOCKET_OR_NULL,
+ .arg1_type = ARG_PTR_TO_CTX,
+ .arg2_type = ARG_PTR_TO_MEM,
+ .arg3_type = ARG_CONST_SIZE,
+ .arg4_type = ARG_ANYTHING,
+ .arg5_type = ARG_ANYTHING,
+};
+
+BPF_CALL_5(bpf_xdp_sk_lookup_tcp, struct xdp_buff *, ctx,
+ struct bpf_sock_tuple *, tuple, u32, len, u32, netns_id, u64, flags)
+{
+ struct net *caller_net = dev_net(ctx->rxq->dev);
+ int ifindex = ctx->rxq->dev->ifindex;
+
+ return __bpf_sk_lookup(NULL, tuple, len, caller_net, ifindex,
+ IPPROTO_TCP, netns_id, flags);
+}
+
+static const struct bpf_func_proto bpf_xdp_sk_lookup_tcp_proto = {
+ .func = bpf_xdp_sk_lookup_tcp,
+ .gpl_only = false,
+ .pkt_access = true,
+ .ret_type = RET_PTR_TO_SOCKET_OR_NULL,
+ .arg1_type = ARG_PTR_TO_CTX,
+ .arg2_type = ARG_PTR_TO_MEM,
+ .arg3_type = ARG_CONST_SIZE,
+ .arg4_type = ARG_ANYTHING,
+ .arg5_type = ARG_ANYTHING,
+};
#endif /* CONFIG_INET */
bool bpf_helper_changes_pkt_data(void *func)
@@ -5214,6 +5273,14 @@ xdp_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
return &bpf_xdp_adjust_tail_proto;
case BPF_FUNC_fib_lookup:
return &bpf_xdp_fib_lookup_proto;
+#ifdef CONFIG_INET
+ case BPF_FUNC_sk_lookup_udp:
+ return &bpf_xdp_sk_lookup_udp_proto;
+ case BPF_FUNC_sk_lookup_tcp:
+ return &bpf_xdp_sk_lookup_tcp_proto;
+ case BPF_FUNC_sk_release:
+ return &bpf_sk_release_proto;
+#endif
default:
return bpf_base_func_proto(func_id);
}
--
2.19.1
^ 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