* Re: [PATCHv2 net-next] vxlan: add ttl inherit support
From: Hangbin Liu @ 2018-04-18 2:15 UTC (permalink / raw)
To: David Miller; +Cc: netdev, jbenc, lucien.xin, sbrivio
In-Reply-To: <20180417.151627.1849186462841531455.davem@davemloft.net>
On Tue, Apr 17, 2018 at 03:16:27PM -0400, David Miller wrote:
> From: Hangbin Liu <liuhangbin@gmail.com>
> Date: Tue, 17 Apr 2018 20:52:54 +0800
>
> > Like tos inherit, ttl inherit should also means inherit the inner protocol's
> > ttl values, which actually not implemented in vxlan yet.
> >
> > But we could not treat ttl == 0 as "use the inner TTL", because that would be
> > used also when the "ttl" option is not specified and that would be a behavior
> > change, and breaking real use cases.
> >
> > So add a different attribute IFLA_VXLAN_TTL_INHERIT when "ttl inherit" is
> > specified.
> >
> > ---
> > v2: As suggested by Stefano, clean up function ip_tunnel_get_ttl().
> >
> > Suggested-by: Jiri Benc <jbenc@redhat.com>
> > Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
>
> I already applied V1 of your patch.
>
> Furthermore, this commit message would cause your signoffs and other tags
> to be removed due to the "---" deliminator.
>
> I generally encourage people to leave the change history text _in_ the
> commit message anyways. It is useful information for the future.
Thanks for the reminding. I will keep this in mind.
Cheers
Hangbin
^ permalink raw reply
* Re: [PATCH bpf-next 09/10] [bpf]: make tun compatible w/ bpf_xdp_adjust_tail
From: Jason Wang @ 2018-04-18 2:16 UTC (permalink / raw)
To: Nikita V. Shirokov, Alexei Starovoitov, Daniel Borkmann, mst; +Cc: netdev
In-Reply-To: <20180417065131.3632-10-tehnerd@tehnerd.com>
On 2018年04月17日 14:51, Nikita V. Shirokov wrote:
> w/ bpf_xdp_adjust_tail helper xdp's data_end pointer could be changed as
> well (only "decrease" of pointer's location is going to be supported).
> changing of this pointer will change packet's size.
> for tun driver we need to adjust XDP_PASS handling by recalculating
> length of the packet if it was passed to the TCP/IP stack
> (in case if after xdp's prog run data_end pointer was adjusted)
>
> Signed-off-by: Nikita V. Shirokov <tehnerd@tehnerd.com>
> ---
> drivers/net/tun.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 28583aa0c17d..0b488a958076 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -1688,6 +1688,7 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun,
> return NULL;
> case XDP_PASS:
> delta = orig_data - xdp.data;
> + len = xdp.data_end - xdp.data;
> break;
> default:
> bpf_warn_invalid_xdp_action(act);
> @@ -1708,7 +1709,7 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun,
> }
>
> skb_reserve(skb, pad - delta);
> - skb_put(skb, len + delta);
> + skb_put(skb, len);
> get_page(alloc_frag->page);
> alloc_frag->offset += buflen;
>
Reviewed-by: Jason Wang <jasowang@redhat.com>
^ permalink raw reply
* Re: [PATCH bpf-next 10/10] [bpf]: make virtio compatible w/ bpf_xdp_adjust_tail
From: Jason Wang @ 2018-04-18 2:16 UTC (permalink / raw)
To: Nikita V. Shirokov, Alexei Starovoitov, Daniel Borkmann; +Cc: netdev
In-Reply-To: <20180417065131.3632-11-tehnerd@tehnerd.com>
On 2018年04月17日 14:51, Nikita V. Shirokov wrote:
> w/ bpf_xdp_adjust_tail helper xdp's data_end pointer could be changed as
> well (only "decrease" of pointer's location is going to be supported).
> changing of this pointer will change packet's size.
> for virtio driver we need to adjust XDP_PASS handling by recalculating
> length of the packet if it was passed to the TCP/IP stack
>
> Signed-off-by: Nikita V. Shirokov <tehnerd@tehnerd.com>
> ---
> drivers/net/virtio_net.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 7b187ec7411e..115d85f7360a 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -604,6 +604,7 @@ static struct sk_buff *receive_small(struct net_device *dev,
> case XDP_PASS:
> /* Recalculate length in case bpf program changed it */
> delta = orig_data - xdp.data;
> + len = xdp.data_end - xdp.data;
> break;
> case XDP_TX:
> sent = __virtnet_xdp_xmit(vi, &xdp);
> @@ -637,7 +638,7 @@ static struct sk_buff *receive_small(struct net_device *dev,
> goto err;
> }
> skb_reserve(skb, headroom - delta);
> - skb_put(skb, len + delta);
> + skb_put(skb, len);
> if (!delta) {
> buf += header_offset;
> memcpy(skb_vnet_hdr(skb), buf, vi->hdr_len);
> @@ -752,6 +753,10 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
> offset = xdp.data -
> page_address(xdp_page) - vi->hdr_len;
>
> + /* recalculate len if xdp.data or xdp.data_end were
> + * adjusted
> + */
> + len = xdp.data_end - xdp.data;
> /* We can only create skb based on xdp_page. */
> if (unlikely(xdp_page != page)) {
> rcu_read_unlock();
Reviewed-by: Jason Wang <jasowang@redhat.com>
^ permalink raw reply
* Re: [PATCH RFC net-next 00/11] udp gso
From: Samudrala, Sridhar @ 2018-04-18 2:25 UTC (permalink / raw)
To: Willem de Bruijn, Sowmini Varadhan; +Cc: Network Development, Willem de Bruijn
In-Reply-To: <CAF=yD-+psRcT+666fCgh8f2r8Raq_D4yCsEycKrNpW-tan1-Yw@mail.gmail.com>
On 4/17/2018 2:07 PM, Willem de Bruijn wrote:
> On Tue, Apr 17, 2018 at 4:48 PM, Sowmini Varadhan
> <sowmini.varadhan@oracle.com> wrote:
>> On (04/17/18 16:23), Willem de Bruijn wrote:
>>> Assuming IPv4 with an MTU of 1500 and the maximum segment
>>> size of 1472, the receiver will see three datagrams with MSS of
>>> 1472B, 528B and 512B.
>> so the recvmsg will also pass up 1472, 526, 512, right?
> That's right.
>
>> If yes, how will the recvmsg differentiate between the case
>> (2000 byte message followed by 512 byte message) and
>> (1472 byte message, 526 byte message, then 512 byte message),
>> in other words, how are UDP message boundary semantics preserved?
> They aren't. This is purely an optimization to amortize the cost of
> repeated tx stack traversal. Unlike UFO, which would preserve the
> boundaries of the original larger than MTU datagram.
Doesn't this break UDP applications that expect message boundary
preservation semantics? Is it possible to negotiate this feature?
>
> A prime use case is bulk transfer of data. Think video streaming
> with QUIC. It must send MTU sized or smaller packets, but has
> no application-layer requirement to reconstruct large packets on
> the peer.
>
> That said, for negotiated flows an inverse GRO feature could
> conceivably be implemented to reduce rx stack traversal, too.
> Though due to interleaving of packets on the wire, it aggregation
> would be best effort, similar to TCP TSO and GRO using the
> PSH bit as packetization signal.
^ permalink raw reply
* Re: [PATCH] PCI: Add PCIe to pcie_print_link_status() messages
From: Jakub Kicinski @ 2018-04-18 2:33 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: oss-drivers, Tal Gilboa, Tariq Toukan, Jacob Keller,
Ganesh Goudar, Jeff Kirsher, intel-wired-lan, netdev,
linux-kernel, linux-pci
In-Reply-To: <20180413181638.6424-1-jakub.kicinski@netronome.com>
On Fri, 13 Apr 2018 11:16:38 -0700, Jakub Kicinski wrote:
> Currently the pcie_print_link_status() will print PCIe bandwidth
> and link width information but does not mention it is pertaining
> to the PCIe. Since this and related functions are used exclusively
> by networking drivers today users may get confused into thinking
> that it's the NIC bandwidth that is being talked about. Insert a
> "PCIe" into the messages.
>
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Hi Bjorn!
Could this small change still make it into 4.17 or are you planning to
apply it in 4.18 cycle? IMHO the message clarification may be worth
considering for 4.17..
> drivers/pci/pci.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index aa86e904f93c..73a0a4993f6a 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -5273,11 +5273,11 @@ void pcie_print_link_status(struct pci_dev *dev)
> bw_avail = pcie_bandwidth_available(dev, &limiting_dev, &speed, &width);
>
> if (bw_avail >= bw_cap)
> - pci_info(dev, "%u.%03u Gb/s available bandwidth (%s x%d link)\n",
> + pci_info(dev, "%u.%03u Gb/s available PCIe bandwidth (%s x%d link)\n",
> bw_cap / 1000, bw_cap % 1000,
> PCIE_SPEED2STR(speed_cap), width_cap);
> else
> - pci_info(dev, "%u.%03u Gb/s available bandwidth, limited by %s x%d link at %s (capable of %u.%03u Gb/s with %s x%d link)\n",
> + pci_info(dev, "%u.%03u Gb/s available PCIe bandwidth, limited by %s x%d link at %s (capable of %u.%03u Gb/s with %s x%d link)\n",
> bw_avail / 1000, bw_avail % 1000,
> PCIE_SPEED2STR(speed), width,
> limiting_dev ? pci_name(limiting_dev) : "<unknown>",
^ permalink raw reply
* Re: [PATCH net-next 3/5] ipv4: support sport, dport and ip protocol in RTM_GETROUTE
From: Roopa Prabhu @ 2018-04-18 2:41 UTC (permalink / raw)
To: Ido Schimmel; +Cc: David Miller, netdev, David Ahern
In-Reply-To: <20180417081052.GA30335@splinter>
On Tue, Apr 17, 2018 at 1:10 AM, Ido Schimmel <idosch@idosch.org> wrote:
> On Mon, Apr 16, 2018 at 01:41:36PM -0700, Roopa Prabhu wrote:
>> @@ -2757,6 +2796,12 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
>> fl4.flowi4_oif = tb[RTA_OIF] ? nla_get_u32(tb[RTA_OIF]) : 0;
>> fl4.flowi4_mark = mark;
>> fl4.flowi4_uid = uid;
>> + if (sport)
>> + fl4.fl4_sport = sport;
>> + if (dport)
>> + fl4.fl4_dport = dport;
>> + if (ip_proto)
>> + fl4.flowi4_proto = ip_proto;
>
> Hi Roopa,
>
> This info isn't set in the synthesized skb, but only in the flow info
> and therefore not used for input routes. I see you added a test case,
> but it's only for output routes. I believe an input route test case will
> fail.
yep. I made a note for myself to work thru the input case and missed before
i sent the series.
>
> Also, note that the skb as synthesized now is invalid - iph->ihl is 0
> for example - so the flow dissector will spit it out. It effectively
> means that route get is broken when L4 hashing is used. It also affects
> output routes because since commit 3765d35ed8b9 ("net: ipv4: Convert
> inet_rtm_getroute to rcu versions of route lookup") the skb is used to
> calculate the multipath hash.
yep, remember that. will look. thanks Ido.
^ permalink raw reply
* [PATCH bpf-next] tools: bpftool: make it easier to feed hex bytes to bpftool
From: Jakub Kicinski @ 2018-04-18 2:46 UTC (permalink / raw)
To: alexei.starovoitov, daniel; +Cc: oss-drivers, netdev, Quentin Monnet
From: Quentin Monnet <quentin.monnet@netronome.com>
bpftool uses hexadecimal values when it dumps map contents:
# bpftool map dump id 1337
key: ff 13 37 ff value: a1 b2 c3 d4 ff ff ff ff
Found 1 element
In order to lookup or update values with bpftool, the natural reflex is
then to copy and paste the values to the command line, and to try to run
something like:
# bpftool map update id 1337 key ff 13 37 ff \
value 00 00 00 00 00 00 1a 2b
Error: error parsing byte: ff
bpftool complains, because it uses strtoul() with a 0 base to parse the
bytes, and that without a "0x" prefix, the bytes are considered as
decimal values (or even octal if they start with "0").
To feed hexadecimal values instead, one needs to add "0x" prefixes
everywhere necessary:
# bpftool map update id 1337 key 0xff 0x13 0x37 0xff \
value 0 0 0 0 0 0 0x1a 0x2b
To make it easier to use hexadecimal values, add an optional "hex"
keyword to put after "key" or "value" to tell bpftool to consider the
digits as hexadecimal. We can now do:
# bpftool map update id 1337 key hex ff 13 37 ff \
value hex 0 0 0 0 0 0 1a 2b
Without the "hex" keyword, the bytes are still parsed according to
normal integer notation (decimal if no prefix, or hexadecimal or octal
if "0x" or "0" prefix is used, respectively).
The patch also add related documentation and bash completion for the
"hex" keyword.
Suggested-by: Daniel Borkmann <daniel@iogearbox.net>
Suggested-by: David Beckett <david.beckett@netronome.com>
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
tools/bpf/bpftool/Documentation/bpftool-map.rst | 29 +++++++++++++++++--------
tools/bpf/bpftool/bash-completion/bpftool | 8 ++++---
tools/bpf/bpftool/map.c | 17 ++++++++++-----
3 files changed, 36 insertions(+), 18 deletions(-)
diff --git a/tools/bpf/bpftool/Documentation/bpftool-map.rst b/tools/bpf/bpftool/Documentation/bpftool-map.rst
index 457e868bd32f..5f512b14bff9 100644
--- a/tools/bpf/bpftool/Documentation/bpftool-map.rst
+++ b/tools/bpf/bpftool/Documentation/bpftool-map.rst
@@ -23,10 +23,10 @@ MAP COMMANDS
| **bpftool** **map { show | list }** [*MAP*]
| **bpftool** **map dump** *MAP*
-| **bpftool** **map update** *MAP* **key** *BYTES* **value** *VALUE* [*UPDATE_FLAGS*]
-| **bpftool** **map lookup** *MAP* **key** *BYTES*
-| **bpftool** **map getnext** *MAP* [**key** *BYTES*]
-| **bpftool** **map delete** *MAP* **key** *BYTES*
+| **bpftool** **map update** *MAP* **key** [**hex**] *BYTES* **value** [**hex**] *VALUE* [*UPDATE_FLAGS*]
+| **bpftool** **map lookup** *MAP* **key** [**hex**] *BYTES*
+| **bpftool** **map getnext** *MAP* [**key** [**hex**] *BYTES*]
+| **bpftool** **map delete** *MAP* **key** [**hex**] *BYTES*
| **bpftool** **map pin** *MAP* *FILE*
| **bpftool** **map help**
|
@@ -48,20 +48,26 @@ DESCRIPTION
**bpftool map dump** *MAP*
Dump all entries in a given *MAP*.
- **bpftool map update** *MAP* **key** *BYTES* **value** *VALUE* [*UPDATE_FLAGS*]
+ **bpftool map update** *MAP* **key** [**hex**] *BYTES* **value** [**hex**] *VALUE* [*UPDATE_FLAGS*]
Update map entry for a given *KEY*.
*UPDATE_FLAGS* can be one of: **any** update existing entry
or add if doesn't exit; **exist** update only if entry already
exists; **noexist** update only if entry doesn't exist.
- **bpftool map lookup** *MAP* **key** *BYTES*
+ If the **hex** keyword is provided in front of the bytes
+ sequence, the bytes are parsed as hexadeximal values, even if
+ no "0x" prefix is added. If the keyword is not provided, then
+ the bytes are parsed as decimal values, unless a "0x" prefix
+ (for hexadecimal) or a "0" prefix (for octal) is provided.
+
+ **bpftool map lookup** *MAP* **key** [**hex**] *BYTES*
Lookup **key** in the map.
- **bpftool map getnext** *MAP* [**key** *BYTES*]
+ **bpftool map getnext** *MAP* [**key** [**hex**] *BYTES*]
Get next key. If *key* is not specified, get first key.
- **bpftool map delete** *MAP* **key** *BYTES*
+ **bpftool map delete** *MAP* **key** [**hex**] *BYTES*
Remove entry from the map.
**bpftool map pin** *MAP* *FILE*
@@ -98,7 +104,12 @@ EXAMPLES
10: hash name some_map flags 0x0
key 4B value 8B max_entries 2048 memlock 167936B
-**# bpftool map update id 10 key 13 00 07 00 value 02 00 00 00 01 02 03 04**
+The following three commands are equivalent:
+
+|
+| **# bpftool map update id 10 key hex 20 c4 b7 00 value hex 0f ff ff ab 01 02 03 4c**
+| **# bpftool map update id 10 key 0x20 0xc4 0xb7 0x00 value 0x0f 0xff 0xff 0xab 0x01 0x02 0x03 0x4c**
+| **# bpftool map update id 10 key 32 196 183 0 value 15 255 255 171 1 2 3 76**
**# bpftool map lookup id 10 key 0 1 2 3**
diff --git a/tools/bpf/bpftool/bash-completion/bpftool b/tools/bpf/bpftool/bash-completion/bpftool
index 490811b45fa7..71cc5dec3685 100644
--- a/tools/bpf/bpftool/bash-completion/bpftool
+++ b/tools/bpf/bpftool/bash-completion/bpftool
@@ -147,7 +147,7 @@ _bpftool()
# Deal with simplest keywords
case $prev in
- help|key|opcodes|visual)
+ help|hex|opcodes|visual)
return 0
;;
tag)
@@ -283,7 +283,7 @@ _bpftool()
return 0
;;
key)
- return 0
+ COMPREPLY+=( $( compgen -W 'hex' -- "$cur" ) )
;;
*)
_bpftool_once_attr 'key'
@@ -302,7 +302,7 @@ _bpftool()
return 0
;;
key)
- return 0
+ COMPREPLY+=( $( compgen -W 'hex' -- "$cur" ) )
;;
value)
# We can have bytes, or references to a prog or a
@@ -321,6 +321,8 @@ _bpftool()
return 0
;;
*)
+ COMPREPLY+=( $( compgen -W 'hex' \
+ -- "$cur" ) )
return 0
;;
esac
diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
index f509c86faede..a6cdb640a0d7 100644
--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -283,11 +283,16 @@ static void print_entry_plain(struct bpf_map_info *info, unsigned char *key,
static char **parse_bytes(char **argv, const char *name, unsigned char *val,
unsigned int n)
{
- unsigned int i = 0;
+ unsigned int i = 0, base = 0;
char *endptr;
+ if (is_prefix(*argv, "hex")) {
+ base = 16;
+ argv++;
+ }
+
while (i < n && argv[i]) {
- val[i] = strtoul(argv[i], &endptr, 0);
+ val[i] = strtoul(argv[i], &endptr, base);
if (*endptr) {
p_err("error parsing byte: %s", argv[i]);
return NULL;
@@ -869,10 +874,10 @@ static int do_help(int argc, char **argv)
fprintf(stderr,
"Usage: %s %s { show | list } [MAP]\n"
" %s %s dump MAP\n"
- " %s %s update MAP key BYTES value VALUE [UPDATE_FLAGS]\n"
- " %s %s lookup MAP key BYTES\n"
- " %s %s getnext MAP [key BYTES]\n"
- " %s %s delete MAP key BYTES\n"
+ " %s %s update MAP key [hex] BYTES value [hex] VALUE [UPDATE_FLAGS]\n"
+ " %s %s lookup MAP key [hex] BYTES\n"
+ " %s %s getnext MAP [key [hex] BYTES]\n"
+ " %s %s delete MAP key [hex] BYTES\n"
" %s %s pin MAP FILE\n"
" %s %s help\n"
"\n"
--
2.16.2
^ permalink raw reply related
* Fw: [Bug 199429] New: smc_shutdown(net/smc/af_smc.c) has a UAF causing null pointer vulnerability.
From: Stephen Hemminger @ 2018-04-18 2:56 UTC (permalink / raw)
To: Ursula Braun; +Cc: netdev
This may already be fixed.
Begin forwarded message:
Date: Wed, 18 Apr 2018 01:52:59 +0000
From: bugzilla-daemon@bugzilla.kernel.org
To: stephen@networkplumber.org
Subject: [Bug 199429] New: smc_shutdown(net/smc/af_smc.c) has a UAF causing null pointer vulnerability.
https://bugzilla.kernel.org/show_bug.cgi?id=199429
Bug ID: 199429
Summary: smc_shutdown(net/smc/af_smc.c) has a UAF causing null
pointer vulnerability.
Product: Networking
Version: 2.5
Kernel Version: 4.16.0-rc7
Hardware: All
OS: Linux
Tree: Mainline
Status: NEW
Severity: normal
Priority: P1
Component: Other
Assignee: stephen@networkplumber.org
Reporter: 1773876454@qq.com
Regression: No
Created attachment 275431
--> https://bugzilla.kernel.org/attachment.cgi?id=275431&action=edit
POC
Syzkaller hit 'general protection fault in kernel_sock_shutdown' bug.
NET: Registered protocol family 43
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] SMP KASAN PTI
Dumping ftrace buffer:
(ftrace buffer empty)
Modules linked in: smc ib_core binfmt_misc joydev hid_generic snd_pcm snd_timer
snd usbmouse usbhid soundcore psmouse e1000 hid pcspkr parport_pc input_leds
i2c_piix4 parport serio_raw floppy qemu_fw_cfg evbug mac_hid
CPU: 1 PID: 1751 Comm: syzkaller252340 Not tainted 4.16.0-rc7+ #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1
04/01/2014
RIP: 0010:kernel_sock_shutdown+0x29/0x70 net/socket.c:3255
RSP: 0018:ffff88000666fcf8 EFLAGS: 00010206
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff829206e4
RDX: 0000000000000005 RSI: 0000000000000000 RDI: 0000000000000028
RBP: ffff88003b43a0d2 R08: 0000000000000003 R09: 000000000002b3c0
R10: 0000000000000ae7 R11: 00000000000000eb R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
FS: 000000000225b880(0000) GS:ffff88003fc00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f5b85800000 CR3: 000000003bcde004 CR4: 00000000001606e0
Call Trace:
smc_shutdown+0x431/0x4a0 [smc]
SYSC_shutdown net/socket.c:1901 [inline]
SyS_shutdown+0x140/0x250 net/socket.c:1892
do_syscall_64+0x2ee/0x580 arch/x86/entry/common.c:287
entry_SYSCALL_64_after_hwframe+0x3d/0xa2
RIP: 0033:0x4431a9
RSP: 002b:00007ffcccb77758 EFLAGS: 00000217 ORIG_RAX: 0000000000000030
RAX: ffffffffffffffda RBX: 00000000004003d0 RCX: 00000000004431a9
RDX: 00000000004431a9 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 0000000000401800 R08: 00000000004003d0 R09: 00000000004003d0
R10: 00000000004003d0 R11: 0000000000000217 R12: 0000000000401890
R13: 0000000000000000 R14: 00000000006b1018 R15: 0000000000000000
Code: 00 00 0f 1f 44 00 00 41 54 55 41 89 f4 53 48 89 fb e8 4c bd ad fe 48 8d
7b 28 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <80> 3c 02 00 74 05 e8
7c 62 e0 fe 48 8b 6b 28 48 b8 00 00 00 00
RIP: kernel_sock_shutdown+0x29/0x70 net/socket.c:3255 RSP: ffff88000666fcf8
---[ end trace ac1ba3c5e5bfa977 ]---
0xffffffffa02d1a82 1258 rc =
smc_close_active(smc);
Dump of assembler code from 0xffffffffa02d1a82 to 0xffffffffa02d1a8c:
=> 0xffffffffa02d1a82 <smc_shutdown+1010>: call 0xffffffffa02f3c50
<smc_close_active>
0xffffffffa02d1a87 <smc_shutdown+1015>: mov r13d,eax
0xffffffffa02d1a8a <smc_shutdown+1018>: call 0xffffffff813fc430
End of assembler dump.
rax 0xffff88005a6217c0 -131939878955072
rbx 0xffff88005be55b40 -131939853575360
rcx 0xffffffffa02d1a7f -1607656833
rdx 0x0 0
rsi 0xfffffe01 4294966785
rdi 0xffff88005be55b40 -131939853575360
rbp 0xffff88005be55b52 0xffff88005be55b52
rsp 0xffff88005e887d18 0xffff88005e887d18
r8 0xffff88005f9d0258 -131939791207848
r9 0xffff880060e2bc00 -131939769861120
r10 0xffff88005f9e7340 -131939791113408
r11 0xb9ed 47597
r12 0x0 0
r13 0x0 0
r14 0x0 0
r15 0x0 0
rip 0xffffffffa02d1a82 0xffffffffa02d1a82 <smc_shutdown+1010>
eflags 0x293 [ CF AF SF IF ]
cs 0x10 16
ss 0x18 24
ds 0x0 0
es 0x0 0
fs 0x0 0
gs 0x0 0
ni:3: Error in sourced command file:
Could not fetch register "fs_base"; remote failure reply 'E14'
(gdb) b *0xffffffffa02d1a87
Breakpoint 36 at 0xffffffffa02d1a87: file ../net/smc/af_smc.c, line 1258.
(gdb) c
Continuing.
[Switching to Thread 4]
Thread 4 hit Hardware watchpoint 34: ((struct smc_sock*)
0xffff88005be55b40)->clcsock
Old value = (struct socket *) 0xffff880058fa5100
New value = (struct socket *) 0x0
smc_tcp_listen_work (work=0xffff88005be55f90) at ../net/smc/af_smc.c:980
980 release_sock(lsk);
(gdb) bt
#0 smc_tcp_listen_work (work=0xffff88005be55f90) at ../net/smc/af_smc.c:980
#1 0xffffffff811dd957 in ?? ()
#2 0xffff880060faf300 in ?? ()
#3 0x000000000be15ecf in ?? ()
#4 0xffff88005f7f5990 in ?? ()
#5 0x1ffff1000be15ed7 in ?? ()
#6 0xffff88005f7f5998 in ?? ()
#7 0xffff88005f7f59a8 in ?? ()
#8 0xffffffff00000000 in ?? ()
#9 0xffff88005f7f59d0 in ?? ()
#10 0xffffffff83000194 in ?? ()
#11 0xffffffff830001a0 in ?? ()
#12 0xffffffff83000194 in ?? ()
#13 0x0000000041b58ab3 in ?? ()
#14 0xffffffff83a0dee0 in ?? ()
#15 0xffffffff811dce50 in ?? ()
#16 0xffffffff83000194 in ?? ()
#17 0xffffffff00000000 in ?? ()
#18 0xffffffff83000194 in ?? ()
#19 0xffffffff830001a0 in ?? ()
#20 0xffffffff83000194 in ?? ()
#21 0xffffffff830001a0 in ?? ()
#22 0xffffffff83000194 in ?? ()
#23 0xffffffff830001a0 in ?? ()
#24 0xcc8f7df19c7e2900 in ?? ()
#25 0xffff880060faf305 in ?? ()
#26 0xffff88005fb88040 in ?? ()
#27 0xffff880057c60040 in ?? ()
#28 0x0000000000000000 in ?? ()
(gdb) file vmlinux
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Load new symbol table from "vmlinux"? (y or n) y
Reading symbols from vmlinux...done.
warning: File "/home/sdk/linux/scripts/gdb/vmlinux-gdb.py" auto-loading has
been declined by your `auto-load safe-path' set to
"$debugdir:$datadir/auto-load".
(gdb) bt
#0 smc_tcp_listen_work (work=0xffff88005be55f90) at ../net/smc/af_smc.c:980
#1 0xffffffff811dd957 in process_one_work (worker=0xffff88005f7f5988,
work=0xffff88005be55f90) at ../kernel/workqueue.c:2113
#2 0xffffffff811def0d in worker_thread (__worker=0xffff88005f7f5988) at
../kernel/workqueue.c:2247
#3 0xffffffff811f4f5f in kthread (_create=<optimized out>) at
../kernel/kthread.c:238
#4 0xffffffff83000205 in ret_from_fork () at ../arch/x86/entry/entry_64.S:406
#5 0x0000000000000000 in ?? ()
(gdb) bt
#0 smc_tcp_listen_work (work=0xffff88005be55f90) at ../net/smc/af_smc.c:980
#1 0xffffffff811dd957 in process_one_work (worker=0xffff88005f7f5988,
work=0xffff88005be55f90) at ../kernel/workqueue.c:2113
#2 0xffffffff811def0d in worker_thread (__worker=0xffff88005f7f5988) at
../kernel/workqueue.c:2247
#3 0xffffffff811f4f5f in kthread (_create=<optimized out>) at
../kernel/kthread.c:238
#4 0xffffffff83000205 in ret_from_fork () at ../arch/x86/entry/entry_64.S:406
#5 0x0000000000000000 in ?? ()
(gdb) disas $rip,+0x10
Dump of assembler code from 0xffffffffa02d4304 to 0xffffffffa02d4314:
=> 0xffffffffa02d4304 <smc_tcp_listen_work+2724>: call
0xffffffff813fc430 <__sanitizer_cov_trace_pc>
0xffffffffa02d4309 <smc_tcp_listen_work+2729>: mov rdi,r12
0xffffffffa02d430c <smc_tcp_listen_work+2732>: call
0xffffffff82937820 <release_sock>
0xffffffffa02d4311 <smc_tcp_listen_work+2737>: lock dec DWORD PTR
[rbp-0x3d0]
End of assembler dump.
(gdb) c
Continuing.
[Switching to Thread 3]
Thread 3 hit Breakpoint 36, 0xffffffffa02d1a87 in smc_shutdown (sock=<optimized
out>, how=0) at ../net/smc/af_smc.c:1258
1258 rc = smc_close_active(smc);
(gdb) disas $rip,+0x10
Dump of assembler code from 0xffffffffa02d1a87 to 0xffffffffa02d1a97:
=> 0xffffffffa02d1a87 <smc_shutdown+1015>: mov r13d,eax
0xffffffffa02d1a8a <smc_shutdown+1018>: call 0xffffffff813fc430
<__sanitizer_cov_trace_pc>
0xffffffffa02d1a8f <smc_shutdown+1023>: lea rdi,[rbx+0x2c8]
0xffffffffa02d1a96 <smc_shutdown+1030>: movabs rax,0xdffffc0000000000
End of assembler dump.
(gdb) so ni
1264 rc1 = kernel_sock_shutdown(smc->clcsock, how);
Dump of assembler code from 0xffffffffa02d1a8a to 0xffffffffa02d1a94:
=> 0xffffffffa02d1a8a <smc_shutdown+1018>: call 0xffffffff813fc430
<__sanitizer_cov_trace_pc>
0xffffffffa02d1a8f <smc_shutdown+1023>: lea rdi,[rbx+0x2c8]
End of assembler dump.
rax 0x0 0
rbx 0xffff88005be55b40 -131939853575360
rcx 0xffffffffa02f482b -1607514069
rdx 0x0 0
rsi 0x0 0
rdi 0xffff88005be55c50 -131939853575088
rbp 0xffff88005be55b52 0xffff88005be55b52
rsp 0xffff88005e887d18 0xffff88005e887d18
r8 0x88 136
r9 0xffff880060f2bc00 -131939768812544
r10 0xffff88005e17f2f8 -131939816705288
r11 0xb839 47161
r12 0x0 0
r13 0x0 0
r14 0x0 0
r15 0x0 0
rip 0xffffffffa02d1a8a 0xffffffffa02d1a8a <smc_shutdown+1018>
eflags 0x282 [ SF IF ]
cs 0x10 16
ss 0x18 24
ds 0x0 0
es 0x0 0
fs 0x0 0
gs 0x0 0
ni:3: Error in sourced command file:
Could not fetch register "fs_base"; remote failure reply 'E14'
(gdb)
0xffffffffa02d1a8f 1264 rc1 =
kernel_sock_shutdown(smc->clcsock, how);
Dump of assembler code from 0xffffffffa02d1a8f to 0xffffffffa02d1a99:
=> 0xffffffffa02d1a8f <smc_shutdown+1023>: lea rdi,[rbx+0x2c8]
0xffffffffa02d1a96 <smc_shutdown+1030>: movabs rax,0xdffffc0000000000
End of assembler dump.
rax 0xffff88005a6217c0 -131939878955072
rbx 0xffff88005be55b40 -131939853575360
rcx 0xffffffffa02d1a8f -1607656817
rdx 0x0 0
rsi 0x0 0
rdi 0xffff88005be55c50 -131939853575088
rbp 0xffff88005be55b52 0xffff88005be55b52
rsp 0xffff88005e887d18 0xffff88005e887d18
r8 0x88 136
r9 0xffff880060f2bc00 -131939768812544
r10 0xffff88005e17f2f8 -131939816705288
r11 0xb839 47161
r12 0x0 0
r13 0x0 0
r14 0x0 0
r15 0x0 0
rip 0xffffffffa02d1a8f 0xffffffffa02d1a8f <smc_shutdown+1023>
eflags 0x293 [ CF AF SF IF ]
cs 0x10 16
ss 0x18 24
ds 0x0 0
es 0x0 0
fs 0x0 0
gs 0x0 0
ni:3: Error in sourced command file:
Could not fetch register "fs_base"; remote failure reply 'E14'
(gdb)
0xffffffffa02d1a96 1264 rc1 =
kernel_sock_shutdown(smc->clcsock, how);
Dump of assembler code from 0xffffffffa02d1a96 to 0xffffffffa02d1aa0:
=> 0xffffffffa02d1a96 <smc_shutdown+1030>: movabs rax,0xdffffc0000000000
End of assembler dump.
rax 0xffff88005a6217c0 -131939878955072
rbx 0xffff88005be55b40 -131939853575360
rcx 0xffffffffa02d1a8f -1607656817
rdx 0x0 0
rsi 0x0 0
rdi 0xffff88005be55e08 -131939853574648
rbp 0xffff88005be55b52 0xffff88005be55b52
rsp 0xffff88005e887d18 0xffff88005e887d18
r8 0x88 136
r9 0xffff880060f2bc00 -131939768812544
r10 0xffff88005e17f2f8 -131939816705288
r11 0xb839 47161
r12 0x0 0
r13 0x0 0
r14 0x0 0
r15 0x0 0
rip 0xffffffffa02d1a96 0xffffffffa02d1a96 <smc_shutdown+1030>
eflags 0x293 [ CF AF SF IF ]
cs 0x10 16
ss 0x18 24
ds 0x0 0
es 0x0 0
fs 0x0 0
gs 0x0 0
ni:3: Error in sourced command file:
Could not fetch register "fs_base"; remote failure reply 'E14'
(gdb)
0xffffffffa02d1aa0 1264 rc1 =
kernel_sock_shutdown(smc->clcsock, how);
Dump of assembler code from 0xffffffffa02d1aa0 to 0xffffffffa02d1aaa:
=> 0xffffffffa02d1aa0 <smc_shutdown+1040>: mov rdx,rdi
0xffffffffa02d1aa3 <smc_shutdown+1043>: shr rdx,0x3
0xffffffffa02d1aa7 <smc_shutdown+1047>: cmp BYTE PTR [rdx+rax*1],0x0
End of assembler dump.
rax 0xdffffc0000000000 -2305847407260205056
rbx 0xffff88005be55b40 -131939853575360
rcx 0xffffffffa02d1a8f -1607656817
rdx 0x0 0
rsi 0x0 0
rdi 0xffff88005be55e08 -131939853574648
rbp 0xffff88005be55b52 0xffff88005be55b52
rsp 0xffff88005e887d18 0xffff88005e887d18
r8 0x88 136
r9 0xffff880060f2bc00 -131939768812544
r10 0xffff88005e17f2f8 -131939816705288
r11 0xb839 47161
r12 0x0 0
r13 0x0 0
r14 0x0 0
r15 0x0 0
rip 0xffffffffa02d1aa0 0xffffffffa02d1aa0 <smc_shutdown+1040>
eflags 0x293 [ CF AF SF IF ]
cs 0x10 16
ss 0x18 24
ds 0x0 0
es 0x0 0
fs 0x0 0
gs 0x0 0
ni:3: Error in sourced command file:
Could not fetch register "fs_base"; remote failure reply 'E14'
(gdb)
0xffffffffa02d1aa3 1264 rc1 =
kernel_sock_shutdown(smc->clcsock, how);
Dump of assembler code from 0xffffffffa02d1aa3 to 0xffffffffa02d1aad:
=> 0xffffffffa02d1aa3 <smc_shutdown+1043>: shr rdx,0x3
0xffffffffa02d1aa7 <smc_shutdown+1047>: cmp BYTE PTR [rdx+rax*1],0x0
0xffffffffa02d1aab <smc_shutdown+1051>: je 0xffffffffa02d1ab2
<smc_shutdown+1058>
End of assembler dump.
rax 0xdffffc0000000000 -2305847407260205056
rbx 0xffff88005be55b40 -131939853575360
rcx 0xffffffffa02d1a8f -1607656817
rdx 0xffff88005be55e08 -131939853574648
rsi 0x0 0
rdi 0xffff88005be55e08 -131939853574648
rbp 0xffff88005be55b52 0xffff88005be55b52
rsp 0xffff88005e887d18 0xffff88005e887d18
r8 0x88 136
r9 0xffff880060f2bc00 -131939768812544
r10 0xffff88005e17f2f8 -131939816705288
r11 0xb839 47161
r12 0x0 0
r13 0x0 0
r14 0x0 0
r15 0x0 0
rip 0xffffffffa02d1aa3 0xffffffffa02d1aa3 <smc_shutdown+1043>
eflags 0x293 [ CF AF SF IF ]
cs 0x10 16
ss 0x18 24
ds 0x0 0
es 0x0 0
fs 0x0 0
gs 0x0 0
ni:3: Error in sourced command file:
Could not fetch register "fs_base"; remote failure reply 'E14'
(gdb)
0xffffffffa02d1aa7 1264 rc1 =
kernel_sock_shutdown(smc->clcsock, how);
Dump of assembler code from 0xffffffffa02d1aa7 to 0xffffffffa02d1ab1:
=> 0xffffffffa02d1aa7 <smc_shutdown+1047>: cmp BYTE PTR [rdx+rax*1],0x0
0xffffffffa02d1aab <smc_shutdown+1051>: je 0xffffffffa02d1ab2
<smc_shutdown+1058>
0xffffffffa02d1aad <smc_shutdown+1053>: call 0xffffffff81726980
<__asan_report_load8_noabort>
End of assembler dump.
rax 0xdffffc0000000000 -2305847407260205056
rbx 0xffff88005be55b40 -131939853575360
rcx 0xffffffffa02d1a8f -1607656817
rdx 0x1ffff1000b7cabc1 2305826516731997121
rsi 0x0 0
rdi 0xffff88005be55e08 -131939853574648
rbp 0xffff88005be55b52 0xffff88005be55b52
rsp 0xffff88005e887d18 0xffff88005e887d18
r8 0x88 136
r9 0xffff880060f2bc00 -131939768812544
r10 0xffff88005e17f2f8 -131939816705288
r11 0xb839 47161
r12 0x0 0
r13 0x0 0
r14 0x0 0
r15 0x0 0
rip 0xffffffffa02d1aa7 0xffffffffa02d1aa7 <smc_shutdown+1047>
eflags 0x202 [ IF ]
cs 0x10 16
ss 0x18 24
ds 0x0 0
es 0x0 0
fs 0x0 0
gs 0x0 0
ni:3: Error in sourced command file:
Could not fetch register "fs_base"; remote failure reply 'E14'
(gdb)
0xffffffffa02d1aab 1264 rc1 =
kernel_sock_shutdown(smc->clcsock, how);
Dump of assembler code from 0xffffffffa02d1aab to 0xffffffffa02d1ab5:
=> 0xffffffffa02d1aab <smc_shutdown+1051>: je 0xffffffffa02d1ab2
<smc_shutdown+1058>
0xffffffffa02d1aad <smc_shutdown+1053>: call 0xffffffff81726980
<__asan_report_load8_noabort>
0xffffffffa02d1ab2 <smc_shutdown+1058>: mov rdi,QWORD PTR
[rbx+0x2c8]
End of assembler dump.
rax 0xdffffc0000000000 -2305847407260205056
rbx 0xffff88005be55b40 -131939853575360
rcx 0xffffffffa02d1a8f -1607656817
rdx 0x1ffff1000b7cabc1 2305826516731997121
rsi 0x0 0
rdi 0xffff88005be55e08 -131939853574648
rbp 0xffff88005be55b52 0xffff88005be55b52
rsp 0xffff88005e887d18 0xffff88005e887d18
r8 0x88 136
r9 0xffff880060f2bc00 -131939768812544
r10 0xffff88005e17f2f8 -131939816705288
r11 0xb839 47161
r12 0x0 0
r13 0x0 0
r14 0x0 0
r15 0x0 0
rip 0xffffffffa02d1aab 0xffffffffa02d1aab <smc_shutdown+1051>
eflags 0x246 [ PF ZF IF ]
cs 0x10 16
ss 0x18 24
ds 0x0 0
es 0x0 0
fs 0x0 0
gs 0x0 0
ni:3: Error in sourced command file:
Could not fetch register "fs_base"; remote failure reply 'E14'
(gdb)
Thread 3 hit Breakpoint 32, 0xffffffffa02d1ab2 in smc_shutdown (sock=<optimized
out>, how=0) at ../net/smc/af_smc.c:1264
1264 rc1 = kernel_sock_shutdown(smc->clcsock, how);
Dump of assembler code from 0xffffffffa02d1ab2 to 0xffffffffa02d1abc:
=> 0xffffffffa02d1ab2 <smc_shutdown+1058>: mov rdi,QWORD PTR
[rbx+0x2c8]
0xffffffffa02d1ab9 <smc_shutdown+1065>: mov esi,r12d
End of assembler dump.
rax 0xdffffc0000000000 -2305847407260205056
rbx 0xffff88005be55b40 -131939853575360
rcx 0xffffffffa02d1a8f -1607656817
rdx 0x1ffff1000b7cabc1 2305826516731997121
rsi 0x0 0
rdi 0xffff88005be55e08 -131939853574648
rbp 0xffff88005be55b52 0xffff88005be55b52
rsp 0xffff88005e887d18 0xffff88005e887d18
r8 0x88 136
r9 0xffff880060f2bc00 -131939768812544
r10 0xffff88005e17f2f8 -131939816705288
r11 0xb839 47161
r12 0x0 0
r13 0x0 0
r14 0x0 0
r15 0x0 0
rip 0xffffffffa02d1ab2 0xffffffffa02d1ab2 <smc_shutdown+1058>
eflags 0x246 [ PF ZF IF ]
cs 0x10 16
ss 0x18 24
ds 0x0 0
es 0x0 0
fs 0x0 0
gs 0x0 0
ni:3: Error in sourced command file:
Could not fetch register "fs_base"; remote failure reply 'E14'
(gdb)
0xffffffffa02d1ab9 1264 rc1 =
kernel_sock_shutdown(smc->clcsock, how);
Dump of assembler code from 0xffffffffa02d1ab9 to 0xffffffffa02d1ac3:
=> 0xffffffffa02d1ab9 <smc_shutdown+1065>: mov esi,r12d
0xffffffffa02d1abc <smc_shutdown+1068>: call 0xffffffff829206d0
<kernel_sock_shutdown>
0xffffffffa02d1ac1 <smc_shutdown+1073>: lea rdi,[rbx+0x24a]
End of assembler dump.
rax 0xdffffc0000000000 -2305847407260205056
rbx 0xffff88005be55b40 -131939853575360
rcx 0xffffffffa02d1a8f -1607656817
rdx 0x1ffff1000b7cabc1 2305826516731997121
rsi 0x0 0
rdi 0x0 0
rbp 0xffff88005be55b52 0xffff88005be55b52
rsp 0xffff88005e887d18 0xffff88005e887d18
r8 0x88 136
r9 0xffff880060f2bc00 -131939768812544
r10 0xffff88005e17f2f8 -131939816705288
r11 0xb839 47161
r12 0x0 0
r13 0x0 0
r14 0x0 0
r15 0x0 0
rip 0xffffffffa02d1ab9 0xffffffffa02d1ab9 <smc_shutdown+1065>
eflags 0x246 [ PF ZF IF ]
cs 0x10 16
ss 0x18 24
ds 0x0 0
es 0x0 0
fs 0x0 0
gs 0x0 0
ni:3: Error in sourced command file:
Could not fetch register "fs_base"; remote failure reply 'E14'
(gdb)
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply
* Re: [PATCH RFC net-next 06/11] udp: add gso support to virtual devices
From: Willem de Bruijn @ 2018-04-18 3:27 UTC (permalink / raw)
To: Dimitris Michailidis; +Cc: netdev, Willem de Bruijn
In-Reply-To: <CAG76SjaKJZj8gPnc=u02fBjEs-E-bRX8AQuGFpG+2+YYqep_hQ@mail.gmail.com>
On Tue, Apr 17, 2018 at 8:43 PM, Dimitris Michailidis
<dmichail@google.com> wrote:
> On Tue, Apr 17, 2018 at 1:00 PM, Willem de Bruijn
> <willemdebruijn.kernel@gmail.com> wrote:
>> From: Willem de Bruijn <willemb@google.com>
>>
>> Virtual devices such as tunnels and bonding can handle large packets.
>> Only segment packets when reaching a physical or loopback device.
>>
>> Signed-off-by: Willem de Bruijn <willemb@google.com>
>> ---
>> include/linux/netdev_features.h | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h
>> index 35b79f47a13d..1e4883bb02a7 100644
>> --- a/include/linux/netdev_features.h
>> +++ b/include/linux/netdev_features.h
>> @@ -80,6 +80,7 @@ enum {
>>
>> NETIF_F_GRO_HW_BIT, /* Hardware Generic receive offload */
>> NETIF_F_HW_TLS_RECORD_BIT, /* Offload TLS record */
>> + NETIF_F_GSO_UDP_L4_BIT, /* UDP payload GSO (not UFO) */
>
> Please add an entry for the new flag to
> net/core/ethtool.c:netdev_features_strings
> and a description to Documentation/networking/netdev-features.txt.
Will do. I initially wrote this as a transparent kernel-internal feature,
but indeed it should be observable and configurable.
^ permalink raw reply
* Re: [PATCH RFC net-next 00/11] udp gso
From: Willem de Bruijn @ 2018-04-18 3:33 UTC (permalink / raw)
To: Samudrala, Sridhar
Cc: Sowmini Varadhan, Network Development, Willem de Bruijn
In-Reply-To: <74f0b490-de65-f05a-6332-6deaeb0fac2a@intel.com>
On Tue, Apr 17, 2018 at 10:25 PM, Samudrala, Sridhar
<sridhar.samudrala@intel.com> wrote:
>
> On 4/17/2018 2:07 PM, Willem de Bruijn wrote:
>>
>> On Tue, Apr 17, 2018 at 4:48 PM, Sowmini Varadhan
>> <sowmini.varadhan@oracle.com> wrote:
>>>
>>> On (04/17/18 16:23), Willem de Bruijn wrote:
>>>>
>>>> Assuming IPv4 with an MTU of 1500 and the maximum segment
>>>> size of 1472, the receiver will see three datagrams with MSS of
>>>> 1472B, 528B and 512B.
>>>
>>> so the recvmsg will also pass up 1472, 526, 512, right?
>>
>> That's right.
>>
>>> If yes, how will the recvmsg differentiate between the case
>>> (2000 byte message followed by 512 byte message) and
>>> (1472 byte message, 526 byte message, then 512 byte message),
>>> in other words, how are UDP message boundary semantics preserved?
>>
>> They aren't. This is purely an optimization to amortize the cost of
>> repeated tx stack traversal. Unlike UFO, which would preserve the
>> boundaries of the original larger than MTU datagram.
>
>
> Doesn't this break UDP applications that expect message boundary
> preservation semantics? Is it possible to negotiate this feature?
A process has to explicitly request the feature with socket option
or cmsg UDP_SEGMENT. By setting that to gso size is signals
its intent to send multiple datagrams in one call.
Or were you responding to the hypothetical GRO example below?
Yes, that clearly would have to be limited to negotiated flows, not
unlike how foo-over-udp tunneling is detected. It is also not a serious
suggestion at this point.
>> A prime use case is bulk transfer of data. Think video streaming
>> with QUIC. It must send MTU sized or smaller packets, but has
>> no application-layer requirement to reconstruct large packets on
>> the peer.
>>
>> That said, for negotiated flows an inverse GRO feature could
>> conceivably be implemented to reduce rx stack traversal, too.
>> Though due to interleaving of packets on the wire, it aggregation
>> would be best effort, similar to TCP TSO and GRO using the
>> PSH bit as packetization signal.
^ permalink raw reply
* Re: [PATCH v2] net: change the comment of dev_mc_init
From: David Miller @ 2018-04-18 3:39 UTC (permalink / raw)
To: sunlw.fnst; +Cc: netdev
In-Reply-To: <111096cf-2afc-4d81-78e6-0a3ca53403f4@cn.fujitsu.com>
From: sunlianwen <sunlw.fnst@cn.fujitsu.com>
Date: Wed, 18 Apr 2018 08:29:52 +0800
> The comment of dev_mc_init() is wrong. which use dev_mc_flush
> instead of dev_mc_init.
>
> Signed-off-by: Lianwen Sun <sunlw.fnst@cn.fujitsu.com>
Patch is still corrupted by your email client.
> - * dev_mc_flush - Init multicast address list
> + * dev_mc_init - Init multicast address list
The character after "*" is a TAB yet it is a sequence of SPACES
in your patch.
Your email client is doing this.
Please do not resend this patch to the mailing list until you can
successfully email the patch to yourself and apply the patch cleanly.
^ permalink raw reply
* Re: [PATCH 04/10] net: ax88796: Add block_input/output hooks to ax_plat_data
From: Michael Schmitz @ 2018-04-18 3:39 UTC (permalink / raw)
To: Andrew Lunn
Cc: kbuild test robot, kbuild-all, netdev, Linux/m68k,
Michael Karcher, Michael Karcher
In-Reply-To: <20180418011901.GC22103@lunn.ch>
Hi Andrew,
ax88796 includes it via linux/netdevice.h. mac-anubis.c doesn't.
Michael Karcher's patches have added forward derclarations for struct
netdevice and struct platform_data already - I'll add struct sk_buff
as suggested by Finn.
Cheers,
Michael
On Wed, Apr 18, 2018 at 1:19 PM, Andrew Lunn <andrew@lunn.ch> wrote:
> On Wed, Apr 18, 2018 at 12:53:21PM +1200, Michael Schmitz wrote:
>> I think this is a false positive - we're encouraged to provide the
>> full parameter list for functions, so the sreuct sk_buff* can't be
>> avoided.
>
> Hi Michael
>
> How is <linux/skbuff.h> being included?
>
> You probably want to build using the .config file and see.
>
> Andrew
^ permalink raw reply
* Re: [PATCH net-next v2 00/21] net/ipv6: Separate data structures for FIB and data path
From: David Miller @ 2018-04-18 3:45 UTC (permalink / raw)
To: dsahern; +Cc: netdev, idosch, roopa, eric.dumazet, weiwan, kafai, yoshfuji
In-Reply-To: <20180418003327.19992-1-dsahern@gmail.com>
From: David Ahern <dsahern@gmail.com>
Date: Tue, 17 Apr 2018 17:33:06 -0700
> IPv6 uses the same data struct for both control plane (FIB entries) and
> data path (dst entries). This struct has elements needed for both paths
> adding memory overhead and complexity (taking a dst hold in most places
> but an additional reference on rt6i_ref in a few). Furthermore, because
> of the dst_alloc tie, all FIB entries are allocated with GFP_ATOMIC.
>
> This patch set separates FIB entries from dst entries, better aligning
> IPv6 code with IPv4, simplifying the reference counting and allowing
> FIB entries added by userspace (not autoconf) to use GFP_KERNEL. It is
> first step to a number of performance and scalability changes.
>
> The end result of this patch set:
> - FIB entries (fib6_info):
> /* size: 208, cachelines: 4, members: 25 */
> /* sum members: 207, holes: 1, sum holes: 1 */
>
> - dst entries (rt6_info)
> /* size: 240, cachelines: 4, members: 11 */
>
> Versus the the single rt6_info struct today for both paths:
> /* size: 320, cachelines: 5, members: 28 */
>
> This amounts to a 35% reduction in memory use for FIB entries and a
> 25% reduction for dst entries.
Looks great, series applied, thanks David!
^ permalink raw reply
* Re: [PATCH 04/10] net: ax88796: Add block_input/output hooks to ax_plat_data
From: Michael Schmitz @ 2018-04-18 3:46 UTC (permalink / raw)
To: Finn Thain
Cc: kbuild test robot, kbuild-all, netdev, Linux/m68k,
Michael Karcher, Michael Karcher
In-Reply-To: <alpine.LNX.2.21.1804181109040.8@nippy.intranet>
Hi Finn,
On Wed, Apr 18, 2018 at 1:23 PM, Finn Thain <fthain@telegraphics.com.au> wrote:
> On Wed, 18 Apr 2018, Michael Schmitz wrote:
>
>> I think this is a false positive - we're encouraged to provide the
>> full parameter list for functions, so the sreuct sk_buff* can't be
>> avoided.
>>
>
> I don't think it's a false positive. I think ax88796.h would need to
> #include <linux/skbuff.h>.
>
> You may be able to get away with a forward declaration, as in,
> struct skbuff;
> but I'm not sure about that. I would have to build mach-anubis.c to check.
I've added a forward declaration for now - worked for struct
net_device as well (would have been missing from the mach-anubis.c
build as well because of the missing netdevice header).
> But why do you need to pass an skbuff pointer here? xs100_block_input()
> only accesses skb->data.
I'm forced to use the same interface as ax_block_input()
(xs100_block_input is a plug-in replacement for that). But both could
be changed. Let's leave that for later please.
> BTW, this patch has an unrelated whitespace change.
Fixed, thanks.
Cheers,
Michael
>
> --
>
>> Cheers,
>>
>> Michael
>>
>>
>> On Wed, Apr 18, 2018 at 6:46 AM, kbuild test robot <lkp@intel.com> wrote:
>> > Hi Michael,
>> >
>> > I love your patch! Perhaps something to improve:
>> >
>> > [auto build test WARNING on v4.16]
>> > [cannot apply to net-next/master net/master v4.17-rc1 next-20180417]
>> > [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>> >
>> > url: https://github.com/0day-ci/linux/commits/Michael-Schmitz/New-network-driver-for-Amiga-X-Surf-100-m68k/20180417-141150
>> > config: arm-samsung (attached as .config)
>> > compiler: arm-linux-gnueabi-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=arm
>> >
>> > All warnings (new ones prefixed by >>):
>> >
>> > In file included from arch/arm/mach-s3c24xx/mach-anubis.c:42:0:
>> >>> include/net/ax88796.h:35:11: warning: 'struct sk_buff' declared inside parameter list will not be visible outside of this definition or declaration
>> > struct sk_buff *skb, int ring_offset);
>> > ^~~~~~~
>> >
>> > vim +35 include/net/ax88796.h
>> >
>> > 20
>> > 21 struct ax_plat_data {
>> > 22 unsigned int flags;
>> > 23 unsigned char wordlength; /* 1 or 2 */
>> > 24 unsigned char dcr_val; /* default value for DCR */
>> > 25 unsigned char rcr_val; /* default value for RCR */
>> > 26 unsigned char gpoc_val; /* default value for GPOC */
>> > 27 u32 *reg_offsets; /* register offsets */
>> > 28 u8 *mac_addr; /* MAC addr (only used when
>> > 29 AXFLG_MAC_FROMPLATFORM is used */
>> > 30
>> > 31 /* uses default ax88796 buffer if set to NULL */
>> > 32 void (*block_output)(struct net_device *dev, int count,
>> > 33 const unsigned char *buf, int star_page);
>> > 34 void (*block_input)(struct net_device *dev, int count,
>> > > 35 struct sk_buff *skb, int ring_offset);
>> > 36 };
>> > 37
>> >
>> > ---
>> > 0-DAY kernel test infrastructure Open Source Technology Center
>> > https://lists.01.org/pipermail/kbuild-all Intel Corporation
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH] VSOCK: make af_vsock.ko removable again
From: Stefan Hajnoczi @ 2018-04-18 4:14 UTC (permalink / raw)
To: David Miller; +Cc: netdev, xiyou.wangcong, jhansen
In-Reply-To: <20180417.094512.321362741144442657.davem@davemloft.net>
[-- Attachment #1: Type: text/plain, Size: 1210 bytes --]
On Tue, Apr 17, 2018 at 09:45:12AM -0400, David Miller wrote:
> From: Stefan Hajnoczi <stefanha@redhat.com>
> Date: Tue, 17 Apr 2018 14:25:58 +0800
>
> > Commit c1eef220c1760762753b602c382127bfccee226d ("vsock: always call
> > vsock_init_tables()") introduced a module_init() function without a
> > corresponding module_exit() function.
> >
> > Modules with an init function can only be removed if they also have an
> > exit function. Therefore the vsock module was considered "permanent"
> > and could not be removed.
> >
> > This patch adds an empty module_exit() function so that "rmmod vsock"
> > works. No explicit cleanup is required because:
> >
> > 1. Transports call vsock_core_exit() upon exit and cannot be removed
> > while sockets are still alive.
> > 2. vsock_diag.ko does not perform any action that requires cleanup by
> > vsock.ko.
> >
> > Reported-by: Xiumei Mu <xmu@redhat.com>
> > Cc: Cong Wang <xiyou.wangcong@gmail.com>
> > Cc: Jorgen Hansen <jhansen@vmware.com>
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
>
> Applied, but please provide a proper Fixes: tag next time. I added it
> for you this time.
Will do. Thanks!
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
^ permalink raw reply
* [PATCH v3 2/9] net: ax88796: Fix MAC address reading
From: Michael Schmitz @ 2018-04-18 4:26 UTC (permalink / raw)
To: netdev
Cc: andrew, fthain, geert, f.fainelli, linux-m68k, Michael.Karcher,
Michael Karcher, Michael Schmitz
In-Reply-To: <1523930895-6973-1-git-send-email-schmitzmic@gmail.com>
From: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
To read the MAC address from the (virtual) SAprom, the remote DMA
unit needs to be set up like for every other process access to card-local
memory.
Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
drivers/net/ethernet/8390/ax88796.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index 2455547..2a256aa 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -671,10 +671,16 @@ static int ax_init_dev(struct net_device *dev)
if (ax->plat->flags & AXFLG_HAS_EEPROM) {
unsigned char SA_prom[32];
+ ei_outb(6, ioaddr + EN0_RCNTLO);
+ ei_outb(0, ioaddr + EN0_RCNTHI);
+ ei_outb(0, ioaddr + EN0_RSARLO);
+ ei_outb(0, ioaddr + EN0_RSARHI);
+ ei_outb(E8390_RREAD + E8390_START, ioaddr + NE_CMD);
for (i = 0; i < sizeof(SA_prom); i += 2) {
SA_prom[i] = ei_inb(ioaddr + NE_DATAPORT);
SA_prom[i + 1] = ei_inb(ioaddr + NE_DATAPORT);
}
+ ei_outb(ENISR_RDC, ioaddr + EN0_ISR); /* Ack intr. */
if (ax->plat->wordlength == 2)
for (i = 0; i < 16; i++)
--
1.7.0.4
^ permalink raw reply related
* [PATCH v3 4/9] net: ax88796: Do not free IRQ in ax_remove() (already freed in ax_close()).
From: Michael Schmitz @ 2018-04-18 4:26 UTC (permalink / raw)
To: netdev
Cc: andrew, fthain, geert, f.fainelli, linux-m68k, Michael.Karcher,
Michael Karcher, Michael Schmitz
In-Reply-To: <1523930895-6973-1-git-send-email-schmitzmic@gmail.com>
From: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
This complements the fix in 82533ad9a1c ("net: ethernet: ax88796:
don't call free_irq without request_irq first") that removed the
free_irq call in the error path of probe, to also not call free_irq
when remove is called to revert the effects of probe.
Fixes: 82533ad9a1c (net: ethernet: ax88796: don't call free_irq without request_irq first)
Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/net/ethernet/8390/ax88796.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index 83e59ae..ecf104c 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -793,7 +793,6 @@ static int ax_remove(struct platform_device *pdev)
struct resource *mem;
unregister_netdev(dev);
- free_irq(dev->irq, dev);
iounmap(ei_local->mem);
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
--
1.7.0.4
^ permalink raw reply related
* [PATCH v3 00/10] New network driver for Amiga X-Surf 100 (m68k)
From: Michael Schmitz @ 2018-04-18 4:26 UTC (permalink / raw)
To: netdev; +Cc: andrew, fthain, geert, f.fainelli, linux-m68k, Michael.Karcher
In-Reply-To: <1523930895-6973-1-git-send-email-schmitzmic@gmail.com>
This patch series adds support for the Individual Computers X-Surf 100
network card for m68k Amiga, a network adapter based on the AX88796 chip set.
The driver was originally written for kernel version 3.19 by Michael Karcher
(see CC:), and adapted to 4.16 for submission to netdev by me. Questions
regarding motivation for some of the changes are probably best directed at
Michael Karcher.
The driver has been tested by Adrian <glaubitz@physik.fu-berlin.de> who will
send his Tested-by tag separately.
A few changes to the ax88796 driver were required:
- to read the MAC address, some setup of the ax99796 chip must be done,
- attach to the MII bus only on device open to allow module unloading,
- allow to supersede ax_block_input/ax_block_output by card-specific
optimized code,
- use an optional interrupt status callback to allow easier sharing of the
card interrupt,
- set IRQF_SHARED if platform IRQ resource is marked shareable,
The Asix Electronix PHY used on the X-Surf 100 is buggy, and causes the
software reset to hang if the previous command sent to the PHY was also
a soft reset. This bug requires addition of a PHY driver for Asix PHYs
to provide a fixed .soft_reset function, included in this series.
Some additional cleanup:
- do not attempt to free IRQ in ax_remove (complements 82533ad9a1c),
- clear platform drvdata on probe fail and module remove.
Changes since v1:
Raised in review by Andrew Lunn:
- move MII code around to avoid need for forward declaration
- combine patches 2 and 7 to add cleanup in error path
Changes since v2:
- corrected authorship attribution to Michael Karcher
Suggested by Geert Uytterhoeven:
- use ei_local->reset_8390() instead of duplicating ax_reset_8390()
- use %pR to format struct resource pointers
- assign pdev and xs100 pointers in declaration
- don't split error messages
- change Kconfig logic to only require XSURF100 set on Amiga
Suggested by Andrew Lunn:
- add COMPILE_TEST to ax88796 Kconfig options
- use new Asix PHY driver for X-Surf 100
Suggested by Andrew Lunn/Finn Thain:
- declare struct sk_buff in ax88796.h
- correct whitespace error in ax88796.h
This series' patches, in order:
1/9 net: phy: new Asix Electronics PHY driver
2/9 net: ax88796: Fix MAC address reading
3/9 net: ax88796: Attach MII bus only when open
4/9 net: ax88796: Do not free IRQ in ax_remove() (already freed in ax_close()).
5/9 net: ax88796: Add block_input/output hooks to ax_plat_data
6/9 net: ax88796: add interrupt status callback to platform data
7/9 net: ax88796: set IRQF_SHARED flag when IRQ resource is marked as shareable
8/9 net: ax88796: release platform device drvdata on probe error and module remove
9/9 net: New ax88796 platform driver for Amiga X-Surf 100 Zorro board (m68k)
drivers/net/ethernet/8390/Kconfig | 17 ++-
drivers/net/ethernet/8390/Makefile | 1 +
drivers/net/ethernet/8390/ax88796.c | 228 ++++++++++++--------
drivers/net/ethernet/8390/xsurf100.c | 381 ++++++++++++++++++++++++++++++++++
drivers/net/phy/Kconfig | 6 +
drivers/net/phy/Makefile | 1 +
drivers/net/phy/asix.c | 65 ++++++
drivers/net/phy/phy_device.c | 3 +-
include/linux/phy.h | 1 +
include/net/ax88796.h | 14 ++
10 files changed, 621 insertions(+), 96 deletions(-)
Cheers,
Michael
^ permalink raw reply
* [PATCH v3 1/9] net: phy: new Asix Electronics PHY driver
From: Michael Schmitz @ 2018-04-18 4:26 UTC (permalink / raw)
To: netdev
Cc: andrew, fthain, geert, f.fainelli, linux-m68k, Michael.Karcher,
Michael Schmitz
In-Reply-To: <1523930895-6973-1-git-send-email-schmitzmic@gmail.com>
The Asix Electronics PHY found on the X-Surf 100 Amiga Zorro network
card by Individual Computers is buggy, and needs the reset bit toggled
as workaround to make a PHY soft reset succed.
Add workaround driver just for this special case. Export phy_poll_reset()
from core phy_device driver to avoid code duplication.
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
drivers/net/phy/Kconfig | 6 ++++
drivers/net/phy/Makefile | 1 +
drivers/net/phy/asix.c | 65 ++++++++++++++++++++++++++++++++++++++++++
drivers/net/phy/phy_device.c | 3 +-
include/linux/phy.h | 1 +
5 files changed, 75 insertions(+), 1 deletions(-)
create mode 100644 drivers/net/phy/asix.c
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index bdfbabb..f5b484c 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -218,6 +218,12 @@ config AQUANTIA_PHY
---help---
Currently supports the Aquantia AQ1202, AQ2104, AQR105, AQR405
+config ASIX_PHY
+ tristate "Asix PHYs"
+ ---help---
+ Currently supports the Asix Electronics PHY found in the X-Surf 100
+ AX88796 package.
+
config AT803X_PHY
tristate "AT803X PHYs"
---help---
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 01acbcb..701ca0b 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -45,6 +45,7 @@ obj-y += $(sfp-obj-y) $(sfp-obj-m)
obj-$(CONFIG_AMD_PHY) += amd.o
obj-$(CONFIG_AQUANTIA_PHY) += aquantia.o
+obj-$(CONFIG_ASIX_PHY) += asix.o
obj-$(CONFIG_AT803X_PHY) += at803x.o
obj-$(CONFIG_BCM63XX_PHY) += bcm63xx.o
obj-$(CONFIG_BCM7XXX_PHY) += bcm7xxx.o
diff --git a/drivers/net/phy/asix.c b/drivers/net/phy/asix.c
new file mode 100644
index 0000000..15e8a0e
--- /dev/null
+++ b/drivers/net/phy/asix.c
@@ -0,0 +1,65 @@
+/*
+ * Driver for Asix PHYs
+ *
+ * Author: Michael Schmitz <schmitzmic@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ */
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/mii.h>
+#include <linux/phy.h>
+
+#define PHY_ID_ASIX 0x003b1841
+
+MODULE_DESCRIPTION("Asix PHY driver");
+MODULE_AUTHOR("Michael Schmitz <schmitzmic@gmail.com>");
+MODULE_LICENSE("GPL");
+
+/**
+ * asix_soft_reset - software reset the PHY via BMCR_RESET bit
+ * @phydev: target phy_device struct
+ *
+ * Description: Perform a software PHY reset using the standard
+ * BMCR_RESET bit and poll for the reset bit to be cleared.
+ * Toggle BMCR_RESET bit off to accomodate broken PHY implementations
+ * such as used on the Individual Computers' X-Surf 100 Zorro card.
+ *
+ * Returns: 0 on success, < 0 on failure
+ */
+static int asix_soft_reset(struct phy_device *phydev)
+{
+ int ret;
+
+ /* Asix PHY won't reset unless reset bit toggles */
+ ret = phy_write(phydev, MII_BMCR, 0);
+ if (ret < 0)
+ return ret;
+
+ phy_write(phydev, MII_BMCR, BMCR_RESET);
+
+ return phy_poll_reset(phydev);
+}
+
+static struct phy_driver asix_driver[] = { {
+ .phy_id = PHY_ID_ASIX,
+ .name = "Asix Electronics",
+ .phy_id_mask = 0xfffffff0,
+ .features = PHY_BASIC_FEATURES,
+ .soft_reset = asix_soft_reset,
+} };
+
+module_phy_driver(asix_driver);
+
+static struct mdio_device_id __maybe_unused asix_tbl[] = {
+ { PHY_ID_ASIX, 0xfffffff0 },
+ { }
+};
+
+MODULE_DEVICE_TABLE(mdio, asix_tbl);
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 777912b..fb8c13b 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -833,7 +833,7 @@ void phy_disconnect(struct phy_device *phydev)
* standard phy_init_hw() which will zero all the other bits in the BMCR
* and reapply all driver-specific and board-specific fixups.
*/
-static int phy_poll_reset(struct phy_device *phydev)
+int phy_poll_reset(struct phy_device *phydev)
{
/* Poll until the reset bit clears (50ms per retry == 0.6 sec) */
unsigned int retries = 12;
@@ -854,6 +854,7 @@ static int phy_poll_reset(struct phy_device *phydev)
msleep(1);
return 0;
}
+EXPORT_SYMBOL(phy_poll_reset);
int phy_init_hw(struct phy_device *phydev)
{
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 7c4c237..fa0c4fd 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -980,6 +980,7 @@ void phy_attached_print(struct phy_device *phydev, const char *fmt, ...)
int genphy_resume(struct phy_device *phydev);
int genphy_loopback(struct phy_device *phydev, bool enable);
int genphy_soft_reset(struct phy_device *phydev);
+int phy_poll_reset(struct phy_device *phydev);
static inline int genphy_no_soft_reset(struct phy_device *phydev)
{
return 0;
--
1.7.0.4
^ permalink raw reply related
* [PATCH v3 3/9] net: ax88796: Attach MII bus only when open
From: Michael Schmitz @ 2018-04-18 4:26 UTC (permalink / raw)
To: netdev
Cc: andrew, fthain, geert, f.fainelli, linux-m68k, Michael.Karcher,
Michael Karcher, Michael Schmitz
In-Reply-To: <1523930895-6973-1-git-send-email-schmitzmic@gmail.com>
From: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Call ax_mii_init in ax_open(), and unregister/remove mdiobus resources
in ax_close().
This is needed to be able to unload the module, as the module is busy
while the MII bus is attached.
Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
drivers/net/ethernet/8390/ax88796.c | 183 ++++++++++++++++++-----------------
1 files changed, 95 insertions(+), 88 deletions(-)
diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index 2a256aa..83e59ae 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -389,6 +389,90 @@ static void ax_phy_switch(struct net_device *dev, int on)
ei_outb(reg_gpoc, ei_local->mem + EI_SHIFT(0x17));
}
+static void ax_bb_mdc(struct mdiobb_ctrl *ctrl, int level)
+{
+ struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
+
+ if (level)
+ ax->reg_memr |= AX_MEMR_MDC;
+ else
+ ax->reg_memr &= ~AX_MEMR_MDC;
+
+ ei_outb(ax->reg_memr, ax->addr_memr);
+}
+
+static void ax_bb_dir(struct mdiobb_ctrl *ctrl, int output)
+{
+ struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
+
+ if (output)
+ ax->reg_memr &= ~AX_MEMR_MDIR;
+ else
+ ax->reg_memr |= AX_MEMR_MDIR;
+
+ ei_outb(ax->reg_memr, ax->addr_memr);
+}
+
+static void ax_bb_set_data(struct mdiobb_ctrl *ctrl, int value)
+{
+ struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
+
+ if (value)
+ ax->reg_memr |= AX_MEMR_MDO;
+ else
+ ax->reg_memr &= ~AX_MEMR_MDO;
+
+ ei_outb(ax->reg_memr, ax->addr_memr);
+}
+
+static int ax_bb_get_data(struct mdiobb_ctrl *ctrl)
+{
+ struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
+ int reg_memr = ei_inb(ax->addr_memr);
+
+ return reg_memr & AX_MEMR_MDI ? 1 : 0;
+}
+
+static const struct mdiobb_ops bb_ops = {
+ .owner = THIS_MODULE,
+ .set_mdc = ax_bb_mdc,
+ .set_mdio_dir = ax_bb_dir,
+ .set_mdio_data = ax_bb_set_data,
+ .get_mdio_data = ax_bb_get_data,
+};
+
+static int ax_mii_init(struct net_device *dev)
+{
+ struct platform_device *pdev = to_platform_device(dev->dev.parent);
+ struct ei_device *ei_local = netdev_priv(dev);
+ struct ax_device *ax = to_ax_dev(dev);
+ int err;
+
+ ax->bb_ctrl.ops = &bb_ops;
+ ax->addr_memr = ei_local->mem + AX_MEMR;
+ ax->mii_bus = alloc_mdio_bitbang(&ax->bb_ctrl);
+ if (!ax->mii_bus) {
+ err = -ENOMEM;
+ goto out;
+ }
+
+ ax->mii_bus->name = "ax88796_mii_bus";
+ ax->mii_bus->parent = dev->dev.parent;
+ snprintf(ax->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
+ pdev->name, pdev->id);
+
+ err = mdiobus_register(ax->mii_bus);
+ if (err)
+ goto out_free_mdio_bitbang;
+
+ return 0;
+
+ out_free_mdio_bitbang:
+ free_mdio_bitbang(ax->mii_bus);
+ out:
+ return err;
+}
+
static int ax_open(struct net_device *dev)
{
struct ax_device *ax = to_ax_dev(dev);
@@ -396,6 +480,10 @@ static int ax_open(struct net_device *dev)
netdev_dbg(dev, "open\n");
+ ret = ax_mii_init(dev);
+ if (ret)
+ goto failed_mii;
+
ret = request_irq(dev->irq, ax_ei_interrupt, ax->irqflags,
dev->name, dev);
if (ret)
@@ -423,6 +511,10 @@ static int ax_open(struct net_device *dev)
ax_phy_switch(dev, 0);
free_irq(dev->irq, dev);
failed_request_irq:
+ /* unregister mdiobus */
+ mdiobus_unregister(ax->mii_bus);
+ free_mdio_bitbang(ax->mii_bus);
+ failed_mii:
return ret;
}
@@ -442,6 +534,9 @@ static int ax_close(struct net_device *dev)
phy_disconnect(dev->phydev);
free_irq(dev->irq, dev);
+
+ mdiobus_unregister(ax->mii_bus);
+ free_mdio_bitbang(ax->mii_bus);
return 0;
}
@@ -541,92 +636,8 @@ static void ax_eeprom_register_write(struct eeprom_93cx6 *eeprom)
#endif
};
-static void ax_bb_mdc(struct mdiobb_ctrl *ctrl, int level)
-{
- struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
-
- if (level)
- ax->reg_memr |= AX_MEMR_MDC;
- else
- ax->reg_memr &= ~AX_MEMR_MDC;
-
- ei_outb(ax->reg_memr, ax->addr_memr);
-}
-
-static void ax_bb_dir(struct mdiobb_ctrl *ctrl, int output)
-{
- struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
-
- if (output)
- ax->reg_memr &= ~AX_MEMR_MDIR;
- else
- ax->reg_memr |= AX_MEMR_MDIR;
-
- ei_outb(ax->reg_memr, ax->addr_memr);
-}
-
-static void ax_bb_set_data(struct mdiobb_ctrl *ctrl, int value)
-{
- struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
-
- if (value)
- ax->reg_memr |= AX_MEMR_MDO;
- else
- ax->reg_memr &= ~AX_MEMR_MDO;
-
- ei_outb(ax->reg_memr, ax->addr_memr);
-}
-
-static int ax_bb_get_data(struct mdiobb_ctrl *ctrl)
-{
- struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
- int reg_memr = ei_inb(ax->addr_memr);
-
- return reg_memr & AX_MEMR_MDI ? 1 : 0;
-}
-
-static const struct mdiobb_ops bb_ops = {
- .owner = THIS_MODULE,
- .set_mdc = ax_bb_mdc,
- .set_mdio_dir = ax_bb_dir,
- .set_mdio_data = ax_bb_set_data,
- .get_mdio_data = ax_bb_get_data,
-};
-
/* setup code */
-static int ax_mii_init(struct net_device *dev)
-{
- struct platform_device *pdev = to_platform_device(dev->dev.parent);
- struct ei_device *ei_local = netdev_priv(dev);
- struct ax_device *ax = to_ax_dev(dev);
- int err;
-
- ax->bb_ctrl.ops = &bb_ops;
- ax->addr_memr = ei_local->mem + AX_MEMR;
- ax->mii_bus = alloc_mdio_bitbang(&ax->bb_ctrl);
- if (!ax->mii_bus) {
- err = -ENOMEM;
- goto out;
- }
-
- ax->mii_bus->name = "ax88796_mii_bus";
- ax->mii_bus->parent = dev->dev.parent;
- snprintf(ax->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
- pdev->name, pdev->id);
-
- err = mdiobus_register(ax->mii_bus);
- if (err)
- goto out_free_mdio_bitbang;
-
- return 0;
-
- out_free_mdio_bitbang:
- free_mdio_bitbang(ax->mii_bus);
- out:
- return err;
-}
-
static void ax_initial_setup(struct net_device *dev, struct ei_device *ei_local)
{
void __iomem *ioaddr = ei_local->mem;
@@ -758,10 +769,6 @@ static int ax_init_dev(struct net_device *dev)
dev->netdev_ops = &ax_netdev_ops;
dev->ethtool_ops = &ax_ethtool_ops;
- ret = ax_mii_init(dev);
- if (ret)
- goto err_out;
-
ax_NS8390_init(dev, 0);
ret = register_netdev(dev);
--
1.7.0.4
^ permalink raw reply related
* [PATCH v3 5/9] net: ax88796: Add block_input/output hooks to ax_plat_data
From: Michael Schmitz @ 2018-04-18 4:26 UTC (permalink / raw)
To: netdev
Cc: andrew, fthain, geert, f.fainelli, linux-m68k, Michael.Karcher,
Michael Karcher, Michael Schmitz
In-Reply-To: <1523930895-6973-1-git-send-email-schmitzmic@gmail.com>
From: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Add platform specific hooks for block transfer reads/writes of packet
buffer data, superseding the default provided ax_block_input/output.
Currently used for m68k Amiga XSurf100.
Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
Changes in v3:
Suggested by Andrew Lunn/Finn Thain:
- declare struct sk_buff in ax88796.h
- correct whitespace error
---
drivers/net/ethernet/8390/ax88796.c | 10 ++++++++--
include/net/ax88796.h | 9 +++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index ecf104c..29cde38 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -760,8 +760,14 @@ static int ax_init_dev(struct net_device *dev)
#endif
ei_local->reset_8390 = &ax_reset_8390;
- ei_local->block_input = &ax_block_input;
- ei_local->block_output = &ax_block_output;
+ if (ax->plat->block_input)
+ ei_local->block_input = ax->plat->block_input;
+ else
+ ei_local->block_input = &ax_block_input;
+ if (ax->plat->block_output)
+ ei_local->block_output = ax->plat->block_output;
+ else
+ ei_local->block_output = &ax_block_output;
ei_local->get_8390_hdr = &ax_get_8390_hdr;
ei_local->priv = 0;
ei_local->msg_enable = ax_msg_enable;
diff --git a/include/net/ax88796.h b/include/net/ax88796.h
index b9a3bec..363b0ca 100644
--- a/include/net/ax88796.h
+++ b/include/net/ax88796.h
@@ -12,6 +12,9 @@
#ifndef __NET_AX88796_PLAT_H
#define __NET_AX88796_PLAT_H
+struct sk_buff;
+struct net_device;
+
#define AXFLG_HAS_EEPROM (1<<0)
#define AXFLG_MAC_FROMDEV (1<<1) /* device already has MAC */
#define AXFLG_HAS_93CX6 (1<<2) /* use eeprom_93cx6 driver */
@@ -26,6 +29,12 @@ struct ax_plat_data {
u32 *reg_offsets; /* register offsets */
u8 *mac_addr; /* MAC addr (only used when
AXFLG_MAC_FROMPLATFORM is used */
+
+ /* uses default ax88796 buffer if set to NULL */
+ void (*block_output)(struct net_device *dev, int count,
+ const unsigned char *buf, int star_page);
+ void (*block_input)(struct net_device *dev, int count,
+ struct sk_buff *skb, int ring_offset);
};
#endif /* __NET_AX88796_PLAT_H */
--
1.7.0.4
^ permalink raw reply related
* [PATCH v3 7/9] net: ax88796: set IRQF_SHARED flag when IRQ resource is marked as shareable
From: Michael Schmitz @ 2018-04-18 4:26 UTC (permalink / raw)
To: netdev
Cc: andrew, fthain, geert, f.fainelli, linux-m68k, Michael.Karcher,
Michael Karcher, Michael Schmitz
In-Reply-To: <1523930895-6973-1-git-send-email-schmitzmic@gmail.com>
From: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
On the Amiga X-Surf100, the network card interrupt is shared with many
other interrupt sources, so requires the IRQF_SHARED flag to register.
Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
drivers/net/ethernet/8390/ax88796.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index c799441..a72dfbc 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -875,6 +875,9 @@ static int ax_probe(struct platform_device *pdev)
dev->irq = irq->start;
ax->irqflags = irq->flags & IRQF_TRIGGER_MASK;
+ if (irq->flags & IORESOURCE_IRQ_SHAREABLE)
+ ax->irqflags |= IRQF_SHARED;
+
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!mem) {
dev_err(&pdev->dev, "no MEM specified\n");
--
1.7.0.4
^ permalink raw reply related
* [PATCH v3 6/9] net: ax88796: add interrupt status callback to platform data
From: Michael Schmitz @ 2018-04-18 4:26 UTC (permalink / raw)
To: netdev
Cc: andrew, fthain, geert, f.fainelli, linux-m68k, Michael.Karcher,
Michael Karcher, Michael Schmitz
In-Reply-To: <1523930895-6973-1-git-send-email-schmitzmic@gmail.com>
From: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
To be able to tell the ax88796 driver whether it is sensible to enter
the 8390 interrupt handler, an "is this interrupt caused by the 88796"
callback has been added to the ax_plat_data structure (with NULL being
compatible to the previous behaviour).
Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
drivers/net/ethernet/8390/ax88796.c | 23 +++++++++++++++++++++--
include/net/ax88796.h | 5 +++++
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index 29cde38..c799441 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -165,6 +165,21 @@ static void ax_reset_8390(struct net_device *dev)
ei_outb(ENISR_RESET, addr + EN0_ISR); /* Ack intr. */
}
+/* Wrapper for __ei_interrupt for platforms that have a platform-specific
+ * way to find out whether the interrupt request might be caused by
+ * the ax88796 chip.
+ */
+static irqreturn_t ax_ei_interrupt_filtered(int irq, void *dev_id)
+{
+ struct net_device *dev = dev_id;
+ struct ax_device *ax = to_ax_dev(dev);
+ struct platform_device *pdev = to_platform_device(dev->dev.parent);
+
+ if (!ax->plat->check_irq(pdev))
+ return IRQ_NONE;
+
+ return ax_ei_interrupt(irq, dev_id);
+}
static void ax_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
int ring_page)
@@ -484,8 +499,12 @@ static int ax_open(struct net_device *dev)
if (ret)
goto failed_mii;
- ret = request_irq(dev->irq, ax_ei_interrupt, ax->irqflags,
- dev->name, dev);
+ if (ax->plat->check_irq)
+ ret = request_irq(dev->irq, ax_ei_interrupt_filtered,
+ ax->irqflags, dev->name, dev);
+ else
+ ret = request_irq(dev->irq, ax_ei_interrupt, ax->irqflags,
+ dev->name, dev);
if (ret)
goto failed_request_irq;
diff --git a/include/net/ax88796.h b/include/net/ax88796.h
index 363b0ca..84b3785 100644
--- a/include/net/ax88796.h
+++ b/include/net/ax88796.h
@@ -14,6 +14,7 @@
struct sk_buff;
struct net_device;
+struct platform_device;
#define AXFLG_HAS_EEPROM (1<<0)
#define AXFLG_MAC_FROMDEV (1<<1) /* device already has MAC */
@@ -35,6 +36,10 @@ struct ax_plat_data {
const unsigned char *buf, int star_page);
void (*block_input)(struct net_device *dev, int count,
struct sk_buff *skb, int ring_offset);
+ /* returns nonzero if a pending interrupt request might by caused by
+ * the ax88786. Handles all interrupts if set to NULL
+ */
+ int (*check_irq)(struct platform_device *pdev);
};
#endif /* __NET_AX88796_PLAT_H */
--
1.7.0.4
^ permalink raw reply related
* [PATCH v3 8/9] net: ax88796: release platform device drvdata on probe error and module remove
From: Michael Schmitz @ 2018-04-18 4:26 UTC (permalink / raw)
To: netdev
Cc: andrew, fthain, geert, f.fainelli, linux-m68k, Michael.Karcher,
Michael Schmitz
In-Reply-To: <1523930895-6973-1-git-send-email-schmitzmic@gmail.com>
The net device struct pointer is stored as platform device drvdata on
module probe - clear the drvdata entry on probe fail there, as well as
when unloading the module.
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
drivers/net/ethernet/8390/ax88796.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index a72dfbc..eb72282 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -829,6 +829,7 @@ static int ax_remove(struct platform_device *pdev)
release_mem_region(mem->start, resource_size(mem));
}
+ platform_set_drvdata(pdev, NULL);
free_netdev(dev);
return 0;
@@ -962,6 +963,7 @@ static int ax_probe(struct platform_device *pdev)
release_mem_region(mem->start, mem_size);
exit_mem:
+ platform_set_drvdata(pdev, NULL);
free_netdev(dev);
return ret;
--
1.7.0.4
^ permalink raw reply related
* [PATCH v3 9/9] net: New ax88796 platform driver for Amiga X-Surf 100 Zorro board (m68k)
From: Michael Schmitz @ 2018-04-18 4:26 UTC (permalink / raw)
To: netdev
Cc: andrew, fthain, geert, f.fainelli, linux-m68k, Michael.Karcher,
Michael Karcher, Michael Schmitz
In-Reply-To: <1523930895-6973-1-git-send-email-schmitzmic@gmail.com>
From: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Add platform device driver to populate the ax88796 platform data from
information provided by the XSurf100 zorro device driver. The ax88796
module will be loaded through this module's probe function.
Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
Changes in v3:
Suggested by Geert Uytterhoeven:
- use ei_local->reset_8390() instead of duplicating ax_reset_8390()
- use %pR to format struct resource pointers
- assign pdev and xs100 pointers in declaration
- don't split error messages
- change Kconfig logic to only require XSURF100 set on Amiga
Suggested by Andrew Lunn:
- add COMPILE_TEST to ax88796 Kconfig options
- use new Asix PHY driver for X-Surf 100
---
drivers/net/ethernet/8390/Kconfig | 17 ++-
drivers/net/ethernet/8390/Makefile | 1 +
drivers/net/ethernet/8390/xsurf100.c | 381 ++++++++++++++++++++++++++++++++++
3 files changed, 397 insertions(+), 2 deletions(-)
create mode 100644 drivers/net/ethernet/8390/xsurf100.c
diff --git a/drivers/net/ethernet/8390/Kconfig b/drivers/net/ethernet/8390/Kconfig
index fdc6734..607dc00 100644
--- a/drivers/net/ethernet/8390/Kconfig
+++ b/drivers/net/ethernet/8390/Kconfig
@@ -29,8 +29,8 @@ config PCMCIA_AXNET
called axnet_cs. If unsure, say N.
config AX88796
- tristate "ASIX AX88796 NE2000 clone support"
- depends on (ARM || MIPS || SUPERH)
+ tristate "ASIX AX88796 NE2000 clone support" if !ZORRO
+ depends on (ARM || MIPS || SUPERH || ZORRO || COMPILE_TEST)
select CRC32
select PHYLIB
select MDIO_BITBANG
@@ -45,6 +45,19 @@ config AX88796_93CX6
---help---
Select this if your platform comes with an external 93CX6 eeprom.
+config XSURF100
+ tristate "Amiga XSurf 100 AX88796/NE2000 clone support"
+ depends on ZORRO
+ select AX88796
+ select ASIX_PHY
+ ---help---
+ This driver is for the Individual Computers X-Surf 100 Ethernet
+ card (based on the Asix AX88796 chip). If you have such a card,
+ say Y. Otherwise, say N.
+
+ To compile this driver as a module, choose M here: the module
+ will be called xsurf100.
+
config HYDRA
tristate "Hydra support"
depends on ZORRO
diff --git a/drivers/net/ethernet/8390/Makefile b/drivers/net/ethernet/8390/Makefile
index f975c2f..3715f8d 100644
--- a/drivers/net/ethernet/8390/Makefile
+++ b/drivers/net/ethernet/8390/Makefile
@@ -16,4 +16,5 @@ obj-$(CONFIG_PCMCIA_PCNET) += pcnet_cs.o 8390.o
obj-$(CONFIG_STNIC) += stnic.o 8390.o
obj-$(CONFIG_ULTRA) += smc-ultra.o 8390.o
obj-$(CONFIG_WD80x3) += wd.o 8390.o
+obj-$(CONFIG_XSURF100) += xsurf100.o
obj-$(CONFIG_ZORRO8390) += zorro8390.o 8390.o
diff --git a/drivers/net/ethernet/8390/xsurf100.c b/drivers/net/ethernet/8390/xsurf100.c
new file mode 100644
index 0000000..7ab5ca0
--- /dev/null
+++ b/drivers/net/ethernet/8390/xsurf100.c
@@ -0,0 +1,381 @@
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/platform_device.h>
+#include <linux/zorro.h>
+#include <net/ax88796.h>
+#include <asm/amigaints.h>
+
+#define ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF100 \
+ ZORRO_ID(INDIVIDUAL_COMPUTERS, 0x64, 0)
+
+#define XS100_IRQSTATUS_BASE 0x40
+#define XS100_8390_BASE 0x800
+
+/* Longword-access area. Translated to 2 16-bit access cycles by the
+ * X-Surf 100 FPGA
+ */
+#define XS100_8390_DATA32_BASE 0x8000
+#define XS100_8390_DATA32_SIZE 0x2000
+/* Sub-Areas for fast data register access; addresses relative to area begin */
+#define XS100_8390_DATA_READ32_BASE 0x0880
+#define XS100_8390_DATA_WRITE32_BASE 0x0C80
+#define XS100_8390_DATA_AREA_SIZE 0x80
+
+#define __NS8390_init ax_NS8390_init
+
+/* force unsigned long back to 'void __iomem *' */
+#define ax_convert_addr(_a) ((void __force __iomem *)(_a))
+
+#define ei_inb(_a) z_readb(ax_convert_addr(_a))
+#define ei_outb(_v, _a) z_writeb(_v, ax_convert_addr(_a))
+
+#define ei_inw(_a) z_readw(ax_convert_addr(_a))
+#define ei_outw(_v, _a) z_writew(_v, ax_convert_addr(_a))
+
+#define ei_inb_p(_a) ei_inb(_a)
+#define ei_outb_p(_v, _a) ei_outb(_v, _a)
+
+/* define EI_SHIFT() to take into account our register offsets */
+#define EI_SHIFT(x) (ei_local->reg_offset[(x)])
+
+/* Ensure we have our RCR base value */
+#define AX88796_PLATFORM
+
+static unsigned char version[] =
+ "ax88796.c: Copyright 2005,2007 Simtec Electronics\n";
+
+#include "lib8390.c"
+
+/* from ne.c */
+#define NE_CMD EI_SHIFT(0x00)
+#define NE_RESET EI_SHIFT(0x1f)
+#define NE_DATAPORT EI_SHIFT(0x10)
+
+struct xsurf100_ax_plat_data {
+ struct ax_plat_data ax;
+ void __iomem *base_regs;
+ void __iomem *data_area;
+};
+
+static int is_xsurf100_network_irq(struct platform_device *pdev)
+{
+ struct xsurf100_ax_plat_data *xs100 = dev_get_platdata(&pdev->dev);
+
+ return (readw(xs100->base_regs + XS100_IRQSTATUS_BASE) & 0xaaaa) != 0;
+}
+
+/* These functions guarantee that the iomem is accessed with 32 bit
+ * cycles only. z_memcpy_fromio / z_memcpy_toio don't
+ */
+static void z_memcpy_fromio32(void *dst, const void __iomem *src, size_t bytes)
+{
+ while (bytes > 32) {
+ asm __volatile__
+ ("movem.l (%0)+,%%d0-%%d7\n"
+ "movem.l %%d0-%%d7,(%1)\n"
+ "adda.l #32,%1" : "=a"(src), "=a"(dst)
+ : "0"(src), "1"(dst) : "d0", "d1", "d2", "d3", "d4",
+ "d5", "d6", "d7", "memory");
+ bytes -= 32;
+ }
+ while (bytes) {
+ *(uint32_t *)dst = z_readl(src);
+ src += 4;
+ dst += 4;
+ bytes -= 4;
+ }
+}
+
+static void z_memcpy_toio32(void __iomem *dst, const void *src, size_t bytes)
+{
+ while (bytes) {
+ z_writel(*(const uint32_t *)src, dst);
+ src += 4;
+ dst += 4;
+ bytes -= 4;
+ }
+}
+
+static void xs100_write(struct net_device *dev, const void *src,
+ unsigned int count)
+{
+ struct ei_device *ei_local = netdev_priv(dev);
+ struct platform_device *pdev = to_platform_device(dev->dev.parent);
+ struct xsurf100_ax_plat_data *xs100 = dev_get_platdata(&pdev->dev);
+
+ /* copy whole blocks */
+ while (count > XS100_8390_DATA_AREA_SIZE) {
+ z_memcpy_toio32(xs100->data_area +
+ XS100_8390_DATA_WRITE32_BASE, src,
+ XS100_8390_DATA_AREA_SIZE);
+ src += XS100_8390_DATA_AREA_SIZE;
+ count -= XS100_8390_DATA_AREA_SIZE;
+ }
+ /* copy whole dwords */
+ z_memcpy_toio32(xs100->data_area + XS100_8390_DATA_WRITE32_BASE,
+ src, count & ~3);
+ src += count & ~3;
+ if (count & 2) {
+ ei_outw(*(uint16_t *)src, ei_local->mem + NE_DATAPORT);
+ src += 2;
+ }
+ if (count & 1)
+ ei_outb(*(uint8_t *)src, ei_local->mem + NE_DATAPORT);
+}
+
+static void xs100_read(struct net_device *dev, void *dst, unsigned int count)
+{
+ struct ei_device *ei_local = netdev_priv(dev);
+ struct platform_device *pdev = to_platform_device(dev->dev.parent);
+ struct xsurf100_ax_plat_data *xs100 = dev_get_platdata(&pdev->dev);
+
+ /* copy whole blocks */
+ while (count > XS100_8390_DATA_AREA_SIZE) {
+ z_memcpy_fromio32(dst, xs100->data_area +
+ XS100_8390_DATA_READ32_BASE,
+ XS100_8390_DATA_AREA_SIZE);
+ dst += XS100_8390_DATA_AREA_SIZE;
+ count -= XS100_8390_DATA_AREA_SIZE;
+ }
+ /* copy whole dwords */
+ z_memcpy_fromio32(dst, xs100->data_area + XS100_8390_DATA_READ32_BASE,
+ count & ~3);
+ dst += count & ~3;
+ if (count & 2) {
+ *(uint16_t *)dst = ei_inw(ei_local->mem + NE_DATAPORT);
+ dst += 2;
+ }
+ if (count & 1)
+ *(uint8_t *)dst = ei_inb(ei_local->mem + NE_DATAPORT);
+}
+
+/* Block input and output, similar to the Crynwr packet driver. If
+ * you are porting to a new ethercard, look at the packet driver
+ * source for hints. The NEx000 doesn't share the on-board packet
+ * memory -- you have to put the packet out through the "remote DMA"
+ * dataport using ei_outb.
+ */
+static void xs100_block_input(struct net_device *dev, int count,
+ struct sk_buff *skb, int ring_offset)
+{
+ struct ei_device *ei_local = netdev_priv(dev);
+ void __iomem *nic_base = ei_local->mem;
+ char *buf = skb->data;
+
+ if (ei_local->dmaing) {
+ netdev_err(dev,
+ "DMAing conflict in %s [DMAstat:%d][irqlock:%d]\n",
+ __func__,
+ ei_local->dmaing, ei_local->irqlock);
+ return;
+ }
+
+ ei_local->dmaing |= 0x01;
+
+ ei_outb(E8390_NODMA + E8390_PAGE0 + E8390_START, nic_base + NE_CMD);
+ ei_outb(count & 0xff, nic_base + EN0_RCNTLO);
+ ei_outb(count >> 8, nic_base + EN0_RCNTHI);
+ ei_outb(ring_offset & 0xff, nic_base + EN0_RSARLO);
+ ei_outb(ring_offset >> 8, nic_base + EN0_RSARHI);
+ ei_outb(E8390_RREAD + E8390_START, nic_base + NE_CMD);
+
+ xs100_read(dev, buf, count);
+
+ ei_local->dmaing &= ~1;
+}
+
+static void xs100_block_output(struct net_device *dev, int count,
+ const unsigned char *buf, const int start_page)
+{
+ struct ei_device *ei_local = netdev_priv(dev);
+ void __iomem *nic_base = ei_local->mem;
+ unsigned long dma_start;
+
+ /* Round the count up for word writes. Do we need to do this?
+ * What effect will an odd byte count have on the 8390? I
+ * should check someday.
+ */
+ if (ei_local->word16 && (count & 0x01))
+ count++;
+
+ /* This *shouldn't* happen. If it does, it's the last thing
+ * you'll see
+ */
+ if (ei_local->dmaing) {
+ netdev_err(dev,
+ "DMAing conflict in %s [DMAstat:%d][irqlock:%d]\n",
+ __func__,
+ ei_local->dmaing, ei_local->irqlock);
+ return;
+ }
+
+ ei_local->dmaing |= 0x01;
+ /* We should already be in page 0, but to be safe... */
+ ei_outb(E8390_PAGE0 + E8390_START + E8390_NODMA, nic_base + NE_CMD);
+
+ ei_outb(ENISR_RDC, nic_base + EN0_ISR);
+
+ /* Now the normal output. */
+ ei_outb(count & 0xff, nic_base + EN0_RCNTLO);
+ ei_outb(count >> 8, nic_base + EN0_RCNTHI);
+ ei_outb(0x00, nic_base + EN0_RSARLO);
+ ei_outb(start_page, nic_base + EN0_RSARHI);
+
+ ei_outb(E8390_RWRITE + E8390_START, nic_base + NE_CMD);
+
+ xs100_write(dev, buf, count);
+
+ dma_start = jiffies;
+
+ while ((ei_inb(nic_base + EN0_ISR) & ENISR_RDC) == 0) {
+ if (jiffies - dma_start > 2 * HZ / 100) { /* 20ms */
+ netdev_warn(dev, "timeout waiting for Tx RDC.\n");
+ ei_local->reset_8390(dev);
+ ax_NS8390_init(dev, 1);
+ break;
+ }
+ }
+
+ ei_outb(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */
+ ei_local->dmaing &= ~0x01;
+}
+
+static int xsurf100_probe(struct zorro_dev *zdev,
+ const struct zorro_device_id *ent)
+{
+ struct platform_device *pdev;
+ struct xsurf100_ax_plat_data ax88796_data;
+ struct resource res[2] = {
+ DEFINE_RES_NAMED(IRQ_AMIGA_PORTS, 1, NULL,
+ IORESOURCE_IRQ | IORESOURCE_IRQ_SHAREABLE),
+ DEFINE_RES_MEM(zdev->resource.start + XS100_8390_BASE,
+ 4 * 0x20)
+ };
+ int reg;
+ /* This table is referenced in the device structure, so it must
+ * outlive the scope of xsurf100_probe.
+ */
+ static u32 reg_offsets[32];
+ int ret = 0;
+
+ /* X-Surf 100 control and 32 bit ring buffer data access areas.
+ * These resources are not used by the ax88796 driver, so must
+ * be requested here and passed via platform data.
+ */
+
+ if (!request_mem_region(zdev->resource.start, 0x100, zdev->name)) {
+ dev_err(&zdev->dev, "cannot reserve X-Surf 100 control registers\n");
+ return -ENXIO;
+ }
+
+ if (!request_mem_region(zdev->resource.start +
+ XS100_8390_DATA32_BASE,
+ XS100_8390_DATA32_SIZE,
+ "X-Surf 100 32-bit data access")) {
+ dev_err(&zdev->dev, "cannot reserve 32-bit area\n");
+ ret = -ENXIO;
+ goto exit_req;
+ }
+
+ for (reg = 0; reg < 0x20; reg++)
+ reg_offsets[reg] = 4 * reg;
+
+ memset(&ax88796_data, 0, sizeof(ax88796_data));
+ ax88796_data.ax.flags = AXFLG_HAS_EEPROM;
+ ax88796_data.ax.wordlength = 2;
+ ax88796_data.ax.dcr_val = 0x48;
+ ax88796_data.ax.rcr_val = 0x40;
+ ax88796_data.ax.reg_offsets = reg_offsets;
+ ax88796_data.ax.check_irq = is_xsurf100_network_irq;
+ ax88796_data.base_regs = ioremap(zdev->resource.start, 0x100);
+
+ /* error handling for ioremap regs */
+ if (!ax88796_data.base_regs) {
+ dev_err(&zdev->dev, "Cannot ioremap area %pR (registers)\n",
+ &zdev->resource);
+
+ ret = -ENXIO;
+ goto exit_req2;
+ }
+
+ ax88796_data.data_area = ioremap(zdev->resource.start +
+ XS100_8390_DATA32_BASE, XS100_8390_DATA32_SIZE);
+
+ /* error handling for ioremap data */
+ if (!ax88796_data.data_area) {
+ dev_err(&zdev->dev,
+ "Cannot ioremap area %pR offset %x (32-bit access)\n",
+ &zdev->resource, XS100_8390_DATA32_BASE);
+
+ ret = -ENXIO;
+ goto exit_mem;
+ }
+
+ ax88796_data.ax.block_output = xs100_block_output;
+ ax88796_data.ax.block_input = xs100_block_input;
+
+ pdev = platform_device_register_resndata(&zdev->dev, "ax88796",
+ zdev->slotaddr, res, 2,
+ &ax88796_data,
+ sizeof(ax88796_data));
+
+ if (IS_ERR(pdev)) {
+ dev_err(&zdev->dev, "cannot register platform device\n");
+ ret = -ENXIO;
+ goto exit_mem2;
+ }
+
+ zorro_set_drvdata(zdev, pdev);
+
+ if (!ret)
+ return 0;
+
+ exit_mem2:
+ iounmap(ax88796_data.data_area);
+
+ exit_mem:
+ iounmap(ax88796_data.base_regs);
+
+ exit_req2:
+ release_mem_region(zdev->resource.start + XS100_8390_DATA32_BASE,
+ XS100_8390_DATA32_SIZE);
+
+ exit_req:
+ release_mem_region(zdev->resource.start, 0x100);
+
+ return ret;
+}
+
+static void xsurf100_remove(struct zorro_dev *zdev)
+{
+ struct platform_device *pdev = zorro_get_drvdata(zdev);
+ struct xsurf100_ax_plat_data *xs100 = dev_get_platdata(&pdev->dev);
+
+ platform_device_unregister(pdev);
+
+ iounmap(xs100->base_regs);
+ release_mem_region(zdev->resource.start, 0x100);
+ iounmap(xs100->data_area);
+ release_mem_region(zdev->resource.start + XS100_8390_DATA32_BASE,
+ XS100_8390_DATA32_SIZE);
+}
+
+static const struct zorro_device_id xsurf100_zorro_tbl[] = {
+ { ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF100, },
+ { 0 }
+};
+
+MODULE_DEVICE_TABLE(zorro, xsurf100_zorro_tbl);
+
+static struct zorro_driver xsurf100_driver = {
+ .name = "xsurf100",
+ .id_table = xsurf100_zorro_tbl,
+ .probe = xsurf100_probe,
+ .remove = xsurf100_remove,
+};
+
+module_driver(xsurf100_driver, zorro_register_driver, zorro_unregister_driver);
+
+MODULE_DESCRIPTION("X-Surf 100 driver");
+MODULE_AUTHOR("Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>");
+MODULE_LICENSE("GPL v2");
--
1.7.0.4
^ 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