* Re: [PATCH 0/2] sh_eth: E-MAC interrupt handler cleanups
From: David Miller @ 2017-01-04 18:48 UTC (permalink / raw)
To: sergei.shtylyov; +Cc: netdev, linux-renesas-soc
In-Reply-To: <64514012.uUvlhX0YRQ@wasted.cogentembedded.com>
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Date: Wed, 04 Jan 2017 15:09:36 +0300
> Here's a set of 3 patches against DaveM's 'net-next.git' repo. I'm cleaning
> up the E-MAC interrupt handling with the main goal of factoring out the E-MAC
> interrupt handler into a separate function.
>
> [1/3] sh_eth: handle only enabled E-MAC interrupts
> [2/3] sh_eth: no need for *else* after *goto*
> [3/3] sh_eth: factor out sh_eth_emac_interrupt()
Series applied to net-next, thanks.
^ permalink raw reply
* Re: [PATCH net-next] net/hyperv: remove use of VLAN_TAG_PRESENT
From: Stephen Hemminger @ 2017-01-04 18:47 UTC (permalink / raw)
To: Michał Mirosław; +Cc: netdev, Haiyang Zhang, devel
In-Reply-To: <85c211f16e696607c9f61f96b8234684a2a2385b.1483487888.git.mirq-linux@rere.qmqm.pl>
On Wed, 4 Jan 2017 01:07:58 +0100 (CET)
Michał Mirosław <mirq-linux@rere.qmqm.pl> wrote:
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
I have a cleaner way of handling this in the receive path for hyperv.
Rather than passing vlan_tci, pass the vlan info
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply
* [PATCH v3 net-next 2/2] tools: psock_tpacket: block Rx until socket filter has been added and socket has been bound to loopback.
From: Sowmini Varadhan @ 2017-01-04 18:45 UTC (permalink / raw)
To: linux-kselftest, netdev, sowmini.varadhan; +Cc: daniel, willemb, davem, shuah
In-Reply-To: <cover.1483555162.git.sowmini.varadhan@oracle.com>
Packets from any/all interfaces may be queued up on the PF_PACKET socket
before it is bound to the loopback interface by psock_tpacket, and
when these are passed up by the kernel, they could interfere
with the Rx tests.
Avoid interference from spurious packet by blocking Rx until the
socket filter has been set up, and the packet has been bound to the
desired (lo) interface. The effective sequence is
socket(PF_PACKET, SOCK_RAW, 0);
set up ring
Invoke SO_ATTACH_FILTER
bind to sll_protocol set to ETH_P_ALL, sll_ifindex for lo
After this sequence, the only packets that will be passed up are
those received on loopback that pass the attached filter.
Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
---
v2: patch reworked based on comments from Willem de Bruijn
tools/testing/selftests/net/psock_tpacket.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/net/psock_tpacket.c b/tools/testing/selftests/net/psock_tpacket.c
index 4a1bc64..7f6cd9f 100644
--- a/tools/testing/selftests/net/psock_tpacket.c
+++ b/tools/testing/selftests/net/psock_tpacket.c
@@ -110,7 +110,7 @@ struct block_desc {
static int pfsocket(int ver)
{
- int ret, sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
+ int ret, sock = socket(PF_PACKET, SOCK_RAW, 0);
if (sock == -1) {
perror("socket");
exit(1);
@@ -239,7 +239,6 @@ static void walk_v1_v2_rx(int sock, struct ring *ring)
bug_on(ring->type != PACKET_RX_RING);
pair_udp_open(udp_sock, PORT_BASE);
- pair_udp_setfilter(sock);
memset(&pfd, 0, sizeof(pfd));
pfd.fd = sock;
@@ -601,7 +600,6 @@ static void walk_v3_rx(int sock, struct ring *ring)
bug_on(ring->type != PACKET_RX_RING);
pair_udp_open(udp_sock, PORT_BASE);
- pair_udp_setfilter(sock);
memset(&pfd, 0, sizeof(pfd));
pfd.fd = sock;
@@ -741,6 +739,8 @@ static void bind_ring(int sock, struct ring *ring)
{
int ret;
+ pair_udp_setfilter(sock);
+
ring->ll.sll_family = PF_PACKET;
ring->ll.sll_protocol = htons(ETH_P_ALL);
ring->ll.sll_ifindex = if_nametoindex("lo");
--
1.7.1
^ permalink raw reply related
* [PATCH v3 net-next 1/2] tools: psock_lib: tighten conditions checked in sock_setfilter
From: Sowmini Varadhan @ 2017-01-04 18:45 UTC (permalink / raw)
To: linux-kselftest, netdev, sowmini.varadhan; +Cc: daniel, willemb, davem, shuah
In-Reply-To: <cover.1483555162.git.sowmini.varadhan@oracle.com>
The bpf_prog used in sock_setfilter() only attempts to check for
ip pktlen, and verifies that the contents of the 80'th packet in
the ethernet frame is 'a' or 'b'. Thus many non-udp packets
could incorrectly pass through this filter and cause incorrect
test results.
This commit hardens the conditions checked by the filter so
that only UDP/IPv4 packets with the matching length and test-character
will be permitted by the filter. The filter has been cleaned up
to explicitly use the BPF macros to make it more readable.
Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Acked-by: Willem de Bruijn <willemb@google.com>
---
v2: commit comment edited based on Willem de Bruijn review
v3: Shuah Khan nit.
tools/testing/selftests/net/psock_lib.h | 29 ++++++++++++++++++++++-------
1 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/net/psock_lib.h b/tools/testing/selftests/net/psock_lib.h
index 24bc7ec..9e5553a 100644
--- a/tools/testing/selftests/net/psock_lib.h
+++ b/tools/testing/selftests/net/psock_lib.h
@@ -27,6 +27,7 @@
#include <string.h>
#include <arpa/inet.h>
#include <unistd.h>
+#include <netinet/udp.h>
#define DATA_LEN 100
#define DATA_CHAR 'a'
@@ -40,14 +41,28 @@
static __maybe_unused void sock_setfilter(int fd, int lvl, int optnum)
{
+ uint16_t ip_len = DATA_LEN +
+ sizeof(struct iphdr) +
+ sizeof(struct udphdr);
+ /* the filter below checks for all of the following conditions that
+ * are based on the contents of create_payload()
+ * ether type 0x800 and
+ * ip proto udp and
+ * ip len == ip_len and
+ * udp[38] == 'a' or udp[38] == 'b'
+ */
struct sock_filter bpf_filter[] = {
- { 0x80, 0, 0, 0x00000000 }, /* LD pktlen */
- { 0x35, 0, 4, DATA_LEN }, /* JGE DATA_LEN [f goto nomatch]*/
- { 0x30, 0, 0, 0x00000050 }, /* LD ip[80] */
- { 0x15, 1, 0, DATA_CHAR }, /* JEQ DATA_CHAR [t goto match]*/
- { 0x15, 0, 1, DATA_CHAR_1}, /* JEQ DATA_CHAR_1 [t goto match]*/
- { 0x06, 0, 0, 0x00000060 }, /* RET match */
- { 0x06, 0, 0, 0x00000000 }, /* RET no match */
+ BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 12), /* LD ethertype */
+ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, ETH_P_IP, 0, 8),
+ BPF_STMT(BPF_LD|BPF_B|BPF_ABS, 23), /* LD ip_proto */
+ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, IPPROTO_UDP, 0, 6),
+ BPF_STMT(BPF_LD|BPF_H|BPF_ABS, 16), /* LD ip_len */
+ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, ip_len, 0, 4),
+ BPF_STMT(BPF_LD|BPF_B|BPF_ABS, 80), /* LD udp[38] */
+ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, DATA_CHAR, 1, 0),
+ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, DATA_CHAR_1, 0, 1),
+ BPF_STMT(BPF_RET | BPF_K, ~0), /* match */
+ BPF_STMT(BPF_RET | BPF_K, 0) /* no match */
};
struct sock_fprog bpf_prog;
--
1.7.1
^ permalink raw reply related
* [PATCH v3 net-next 0/2] tools: psock_tpacket bug fixes
From: Sowmini Varadhan @ 2017-01-04 18:45 UTC (permalink / raw)
To: linux-kselftest, netdev, sowmini.varadhan; +Cc: daniel, willemb, davem, shuah
This patchset includes fixes to psock_tpacket for false-negatives
sporadically reported by the test when it was run concurrently with
other heavy network traffic (e.g., over an ssh session, as opposed
to running the test from the console of the test machine). The
test sometimes failed with errors reporting more recvd packets than
expected (e.g., "walk_v0_rx: received 201 out of 100 pkts") or
the reception of non-IP packets (e.g., ARP packets).
There are 2 sources of network interference that can disrupt the test:
1. set_sockfilter() can use some hardening (currently passes up packets
based on ip length field, and payload signature but this may potentially
match other network traffic on the test machine)
2. There is a race-window between packet_create() and packet_do_bind()
in which packets from any interface (e.g., eth0) will get queued
for Rx on the test socket.
Patch 1 fixes the first issue by cleaing up set_sockfilter() and
hardening it to make sure that it only permits UDP/IPv4 packets.
Patch 2 fixes the second issue by making sure we open the PF_PACKET
socket with protocol 0 to reject all packets, and make sure the
BPF filter is set up before binding the socket to ETH_P_ALL and lo.
v2: patch 2 reworked based on review comments.
v3: Shuah Khan nit.
Sowmini Varadhan (2):
tools: psock_lib: tighten conditions checked in sock_setfilter
tools: psock_tpacket: block Rx until socket filter has been added and
socket has been bound to loopback.
tools/testing/selftests/net/psock_lib.h | 29 ++++++++++++++++++++------
tools/testing/selftests/net/psock_tpacket.c | 6 ++--
2 files changed, 25 insertions(+), 10 deletions(-)
^ permalink raw reply
* Re: [PATCH 0/2] dpaa_eth: a couple of fixes
From: David Miller @ 2017-01-04 18:45 UTC (permalink / raw)
To: madalin.bucur; +Cc: netdev, linuxppc-dev, linux-kernel
In-Reply-To: <1483528890-8621-1-git-send-email-madalin.bucur@nxp.com>
From: Madalin Bucur <madalin.bucur@nxp.com>
Date: Wed, 4 Jan 2017 13:21:28 +0200
> Add cleanup on PHY initialization failure path, avoid using
> uninitialized memory at CGR init.
Series applied, thanks.
^ permalink raw reply
* Re: [PATCH net-next] net: phy: add extension of phy-mode for XLGMII
From: David Miller @ 2017-01-04 18:42 UTC (permalink / raw)
To: Jie.Deng1; +Cc: f.fainelli, netdev, linux-kernel
In-Reply-To: <b5378ab79043fe46027756546c17e0a54df4a9f0.1483505550.git.jiedeng@synopsys.com>
From: Jie Deng <Jie.Deng1@synopsys.com>
Date: Wed, 4 Jan 2017 13:04:04 +0800
> The Synopsys DWC_xlgmac core provides a multiplexed 40-Gigabit
> Media-Independent Interface (XLGMII, an IEEE 802.3 Clause 81
> compliant reconciliation sub-layer) for communication with
> the 100/50/40/25-Gigabit PHY and 10-Gigabit Media-Independent
> Interface (XGMII, an IEEE 802.3 Clause 46 compliant reconciliation
> sub-layer) for communication with the 10-Gigabit PHY.
>
> Currently, There are only interface mode definitions for "xgmii".
> This patch adds the definitions for the PHY layer to recognize
> "xlgmii" as a valid PHY interface.
>
> Signed-off-by: Jie Deng <jiedeng@synopsys.com>
It makes no sense to add these definitions unless you also submit
uses of them alongside at the same time.
Thanks.
^ permalink raw reply
* Re: [PATCH net 0/2] net: systemport: Fix padding vs. TSB insertion
From: David Miller @ 2017-01-04 18:34 UTC (permalink / raw)
To: f.fainelli; +Cc: netdev
In-Reply-To: <20170104003449.27078-1-f.fainelli@gmail.com>
From: Florian Fainelli <f.fainelli@gmail.com>
Date: Tue, 3 Jan 2017 16:34:47 -0800
> This patch series fixes how we pad the packets submitted to the SYSTEMPORT
> adapter, and how the transmit status block (prepended 8 bytes) fits in the
> picture. The first patch is not technically a bug fix, but is required for the
> second path to be applied and to greatly simplify the skb length calculation.
Series applied with the typo in the commit message of patch #2 fixed.
Happy new year.
^ permalink raw reply
* Re: [PATCH next v1] ipvlan: assign unique dev-id for each slave device.
From: David Miller @ 2017-01-04 18:30 UTC (permalink / raw)
To: mahesh; +Cc: edumazet, netdev, maheshb
In-Reply-To: <20170103204716.9436-1-mahesh@bandewar.net>
From: Mahesh Bandewar <mahesh@bandewar.net>
Date: Tue, 3 Jan 2017 12:47:16 -0800
> From: Mahesh Bandewar <maheshb@google.com>
>
> IPvlan setup uses one mac-address (of master). The IPv6 link-local
> addresses are derived using the mac-address on the link. Lack of
> dev-ids makes these link-local addresses same for all slaves including
> that of master device. dev-ids are necessary to add differentiation
> when L2 address is shared.
>
> Signed-off-by: Mahesh Bandewar <maheshb@google.com>
Applied, thanks.
^ permalink raw reply
* Re: [PATCH net-next v2] net: dsa: remove out label in dsa_switch_setup_one
From: David Miller @ 2017-01-04 18:29 UTC (permalink / raw)
To: vivien.didelot; +Cc: netdev, linux-kernel, kernel, f.fainelli, andrew
In-Reply-To: <20170103193149.4169-1-vivien.didelot@savoirfairelinux.com>
From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Date: Tue, 3 Jan 2017 14:31:49 -0500
> The "out" label in dsa_switch_setup_one() is useless, thus remove it.
>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Applied.
^ permalink raw reply
* Re: [PATCH net-next] liquidio: remove PTP support in 23XX adapters
From: David Miller @ 2017-01-04 18:28 UTC (permalink / raw)
To: felix.manlunas; +Cc: netdev, raghu.vatsavayi, derek.chickles, satananda.burla
In-Reply-To: <20170103192733.GA4979@felix.cavium.com>
From: Felix Manlunas <felix.manlunas@cavium.com>
Date: Tue, 3 Jan 2017 11:27:33 -0800
> From: Prasad Kanneganti <prasad.kanneganti@cavium.com>
>
> liquidio driver incorrectly indicates that PTP is supported in 23XX
> adapters; this patch fixes that. PTP is supported in 66XX and 68XX
> adapters, and the driver correctly indicates that.
>
> Signed-off-by: Prasad Kanneganti <prasad.kanneganti@cavium.com>
> Signed-off-by: Felix Manlunas <felix.manlunas@cavium.com>
> Signed-off-by: Derek Chickles <derek.chickles@cavium.com>
> Signed-off-by: Satanand Burla <satananda.burla@cavium.com>
Applied.
^ permalink raw reply
* Re: [PATCH] LiquidIO VF: s/select/imply/ for PTP_1588_CLOCK
From: David Miller @ 2017-01-04 18:27 UTC (permalink / raw)
To: nicolas.pitre; +Cc: richardcochran, rvatsavayi, netdev
In-Reply-To: <alpine.LFD.2.20.1701031331450.21662@knanqh.ubzr>
From: Nicolas Pitre <nicolas.pitre@linaro.org>
Date: Tue, 3 Jan 2017 13:57:00 -0500 (EST)
> Fix a minor fallout from the merge of the timers and the networking
> trees. The following error may result if the PTP_1588_CLOCK
> prerequisites are not available:
>
> drivers/built-in.o: In function `ptp_clock_unregister':
> (.text+0x40e0a5): undefined reference to `pps_unregister_source'
> drivers/built-in.o: In function `ptp_clock_unregister':
> (.text+0x40e0cc): undefined reference to `posix_clock_unregister'
> drivers/built-in.o: In function `ptp_clock_event':
> (.text+0x40e249): undefined reference to `pps_event'
> drivers/built-in.o: In function `ptp_clock_register':
> (.text+0x40e5e1): undefined reference to `pps_register_source'
> drivers/built-in.o: In function `ptp_clock_register':
> (.text+0x40e62c): undefined reference to `posix_clock_register'
> drivers/built-in.o: In function `ptp_clock_register':
> (.text+0x40e68d): undefined reference to `pps_unregister_source'
>
> Signed-off-by: Nicolas Pitre <nico@linaro.org>
Applied, thanks.
^ permalink raw reply
* Re: [PATCH net] libcxgb: fix error check for ip6_route_output()
From: David Miller @ 2017-01-04 18:26 UTC (permalink / raw)
To: varun; +Cc: netdev, swise, indranil
In-Reply-To: <1483458948-13765-1-git-send-email-varun@chelsio.com>
From: Varun Prakash <varun@chelsio.com>
Date: Tue, 3 Jan 2017 21:25:48 +0530
> ip6_route_output() never returns NULL so
> check dst->error instead of !dst.
>
> Signed-off-by: Varun Prakash <varun@chelsio.com>
Applied, thanks.
^ permalink raw reply
* Re: [PATCH v2 net-next 1/2] tools: psock_lib: tighten conditions checked in sock_setfilter
From: Shuah Khan @ 2017-01-04 18:15 UTC (permalink / raw)
To: Sowmini Varadhan, linux-kselftest, netdev
Cc: daniel, willemb, davem, Shuah Khan, Shuah Khan
In-Reply-To: <89e7eb1f8ce517e769ed37260d9d4ae5bef83812.1483549208.git.sowmini.varadhan@oracle.com>
Hi Sowmini,
Thanks for the patch.
On 01/04/2017 10:33 AM, Sowmini Varadhan wrote:
> The bpf_prog used in sock_setfilter() only attempts to check for
> ip pktlen, and verifies that the contents of the 80'th packet in
> the ethernet frame is 'a' or 'b'. Thus many non-udp packets
> could incorrectly pass through this filter and cause incorrect
> test results.
>
> This commit hardens the conditions checked by the filter so
> that only UDP/IPv4 packets with the matching length and test-character
> will be permitted by the filter. The filter has been cleaned up
> to explicitly use the BPF macros to make it more readable.
>
> Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
> Acked-by: Willem de Bruijn <willemb@google.com>
> ---
> v2: commit comment edited based on review
>
> tools/testing/selftests/net/psock_lib.h | 28 +++++++++++++++++++++-------
> 1 files changed, 21 insertions(+), 7 deletions(-)
>
> diff --git a/tools/testing/selftests/net/psock_lib.h b/tools/testing/selftests/net/psock_lib.h
> index 24bc7ec..e62540e 100644
> --- a/tools/testing/selftests/net/psock_lib.h
> +++ b/tools/testing/selftests/net/psock_lib.h
> @@ -27,6 +27,7 @@
> #include <string.h>
> #include <arpa/inet.h>
> #include <unistd.h>
> +#include <netinet/udp.h>
>
> #define DATA_LEN 100
> #define DATA_CHAR 'a'
> @@ -40,14 +41,27 @@
>
> static __maybe_unused void sock_setfilter(int fd, int lvl, int optnum)
> {
> + uint16_t ip_len = DATA_LEN +
> + sizeof(struct iphdr) + sizeof(struct udphdr);
This following will improve readability.
uint16_t ip_len = DATA_LEN +
sizeof(struct iphdr) +
sizeof(struct udphdr);
> + /* the filter below checks for all of the following conditions that
Change the above to the following. Makes it easier to read.
/*
* the filter below checks for all of the following conditions that
> + * are based on the contents of create_payload()
> + * ether type 0x800 and
> + * ip proto udp and
> + * ip len == ip_len and
> + * udp[38] == 'a' or udp[38] == 'b'
> + */
> struct sock_filter bpf_filter[] = {
> - { 0x80, 0, 0, 0x00000000 }, /* LD pktlen */
> - { 0x35, 0, 4, DATA_LEN }, /* JGE DATA_LEN [f goto nomatch]*/
> - { 0x30, 0, 0, 0x00000050 }, /* LD ip[80] */
> - { 0x15, 1, 0, DATA_CHAR }, /* JEQ DATA_CHAR [t goto match]*/
> - { 0x15, 0, 1, DATA_CHAR_1}, /* JEQ DATA_CHAR_1 [t goto match]*/
> - { 0x06, 0, 0, 0x00000060 }, /* RET match */
> - { 0x06, 0, 0, 0x00000000 }, /* RET no match */
> + BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 12), /* LD ethertype */
> + BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, ETH_P_IP, 0, 8),
> + BPF_STMT(BPF_LD|BPF_B|BPF_ABS, 23), /* LD ip_proto */
> + BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, IPPROTO_UDP, 0, 6),
> + BPF_STMT(BPF_LD|BPF_H|BPF_ABS, 16), /* LD ip_len */
> + BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, ip_len, 0, 4),
> + BPF_STMT(BPF_LD|BPF_B|BPF_ABS, 80), /* LD udp[38] */
> + BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, DATA_CHAR, 1, 0),
> + BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, DATA_CHAR_1, 0, 1),
> + BPF_STMT(BPF_RET | BPF_K, ~0), /* match */
> + BPF_STMT(BPF_RET | BPF_K, 0) /* no match */
> };
> struct sock_fprog bpf_prog;
>
>
thanks,
-- Shuah
^ permalink raw reply
* Re: [PATCH] scm: remove use CMSG{_COMPAT}_ALIGN(sizeof(struct {compat_}cmsghdr))
From: David Miller @ 2017-01-04 18:24 UTC (permalink / raw)
To: cugyly; +Cc: netdev, Linyu.Yuan
In-Reply-To: <1483447337-4976-1-git-send-email-cugyly@163.com>
From: yuan linyu <cugyly@163.com>
Date: Tue, 3 Jan 2017 20:42:17 +0800
> From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
>
> sizeof(struct cmsghdr) and sizeof(struct compat_cmsghdr) already aligned.
> remove use CMSG_ALIGN(sizeof(struct cmsghdr)) and
> CMSG_COMPAT_ALIGN(sizeof(struct compat_cmsghdr)) keep code consistent.
>
> Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
Applied, and I added the following commit which will make sure our
analysis is accurate.
====================
[PATCH] net: Assert at build time the assumptions we make about the CMSG header.
It must always be the case that CMSG_ALIGN(sizeof(hdr)) == sizeof(hdr).
Otherwise there are missing adjustments in the various calculations
that parse and build these things.
Signed-off-by: David S. Miller <davem@davemloft.net>
---
net/compat.c | 3 +++
net/socket.c | 2 ++
2 files changed, 5 insertions(+)
diff --git a/net/compat.c b/net/compat.c
index 4e27dd1..ba3ac72 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -130,6 +130,9 @@ int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, struct sock *sk,
__kernel_size_t kcmlen, tmp;
int err = -EFAULT;
+ BUILD_BUG_ON(sizeof(struct compat_cmsghdr) !=
+ CMSG_COMPAT_ALIGN(sizeof(struct compat_cmsghdr)));
+
kcmlen = 0;
kcmsg_base = kcmsg = (struct cmsghdr *)stackbuf;
ucmsg = CMSG_COMPAT_FIRSTHDR(kmsg);
diff --git a/net/socket.c b/net/socket.c
index 8487bf1..5f3b5a2 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1948,6 +1948,8 @@ static int ___sys_sendmsg(struct socket *sock, struct user_msghdr __user *msg,
ctl_buf = msg_sys->msg_control;
ctl_len = msg_sys->msg_controllen;
} else if (ctl_len) {
+ BUILD_BUG_ON(sizeof(struct cmsghdr) !=
+ CMSG_ALIGN(sizeof(struct cmsghdr)));
if (ctl_len > sizeof(ctl)) {
ctl_buf = sock_kmalloc(sock->sk, ctl_len, GFP_KERNEL);
if (ctl_buf == NULL)
--
2.4.11
^ permalink raw reply related
* Re: [PATCH 1/1] net: usb: asix_devices: add .reset_resume for USB PM
From: David Miller @ 2017-01-04 18:03 UTC (permalink / raw)
To: peter.chen; +Cc: robert.foss, linux-usb, netdev
In-Reply-To: <1483435340-20371-1-git-send-email-peter.chen@nxp.com>
From: Peter Chen <peter.chen@nxp.com>
Date: Tue, 3 Jan 2017 17:22:20 +0800
> The USB core may call reset_resume when it fails to resume asix device.
> And USB core can recovery this abnormal resume at low level driver,
> the same .resume at asix driver can work too. Add .reset_resume can
> avoid disconnecting after backing from system resume, and NFS can
> still be mounted after this commit.
>
> Signed-off-by: Peter Chen <peter.chen@nxp.com>
Applied, thank you.
^ permalink raw reply
* Re: [PATCH net] openvswitch: upcall: Fix vlan handling.
From: Jiri Benc @ 2017-01-04 17:39 UTC (permalink / raw)
To: Pravin B Shelar; +Cc: netdev, Jarno Rajahalme
In-Reply-To: <1482769887-8022-1-git-send-email-pshelar@ovn.org>
On Mon, 26 Dec 2016 08:31:27 -0800, Pravin B Shelar wrote:
> Networking stack accelerate vlan tag handling by
> keeping topmost vlan header in skb. This works as
> long as packet remains in OVS datapath. But during
> OVS upcall vlan header is pushed on to the packet.
> When such packet is sent back to OVS datapath, core
> networking stack might not handle it correctly. Following
> patch avoids this issue by accelerating the vlan tag
> during flow key extract. This simplifies datapath by
> bringing uniform packet processing for packets from
> all code paths.
Sorry for the late review, I was off at the end of December. Just
wanted to say that the patch looks great.
Thanks!
Jiri
^ permalink raw reply
* [PATCH v2 net-next 2/2] tools: psock_tpacket: block Rx until socket filter has been added and socket has been bound to loopback.
From: Sowmini Varadhan @ 2017-01-04 17:33 UTC (permalink / raw)
To: linux-kselftest, netdev, sowmini.varadhan; +Cc: daniel, willemb, davem, shuah
In-Reply-To: <cover.1483549208.git.sowmini.varadhan@oracle.com>
Packets from any/all interfaces may be queued up on the PF_PACKET socket
before it is bound to the loopback interface by psock_tpacket, and
when these are passed up by the kernel, they could interfere
with the Rx tests.
Avoid interference from spurious packet by blocking Rx until the
socket filter has been set up, and the packet has been bound to the
desired (lo) interface. The effective sequence is
socket(PF_PACKET, SOCK_RAW, 0)
set up ring
Invoke SO_ATTACH_FILTER
bind to sll_protocol set to ETH_P_ALL, sll_ifindex for lo
After this sequence, the only packets that will be passed up are
those received on loopback that pass the attached filter.
Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
---
v2: patch reworked based on comments from Willem de Bruijn
tools/testing/selftests/net/psock_tpacket.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/net/psock_tpacket.c b/tools/testing/selftests/net/psock_tpacket.c
index 4a1bc64..7f6cd9f 100644
--- a/tools/testing/selftests/net/psock_tpacket.c
+++ b/tools/testing/selftests/net/psock_tpacket.c
@@ -110,7 +110,7 @@ struct block_desc {
static int pfsocket(int ver)
{
- int ret, sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
+ int ret, sock = socket(PF_PACKET, SOCK_RAW, 0);
if (sock == -1) {
perror("socket");
exit(1);
@@ -239,7 +239,6 @@ static void walk_v1_v2_rx(int sock, struct ring *ring)
bug_on(ring->type != PACKET_RX_RING);
pair_udp_open(udp_sock, PORT_BASE);
- pair_udp_setfilter(sock);
memset(&pfd, 0, sizeof(pfd));
pfd.fd = sock;
@@ -601,7 +600,6 @@ static void walk_v3_rx(int sock, struct ring *ring)
bug_on(ring->type != PACKET_RX_RING);
pair_udp_open(udp_sock, PORT_BASE);
- pair_udp_setfilter(sock);
memset(&pfd, 0, sizeof(pfd));
pfd.fd = sock;
@@ -741,6 +739,8 @@ static void bind_ring(int sock, struct ring *ring)
{
int ret;
+ pair_udp_setfilter(sock);
+
ring->ll.sll_family = PF_PACKET;
ring->ll.sll_protocol = htons(ETH_P_ALL);
ring->ll.sll_ifindex = if_nametoindex("lo");
--
1.7.1
^ permalink raw reply related
* [PATCH v2 net-next 1/2] tools: psock_lib: tighten conditions checked in sock_setfilter
From: Sowmini Varadhan @ 2017-01-04 17:33 UTC (permalink / raw)
To: linux-kselftest, netdev, sowmini.varadhan; +Cc: daniel, willemb, davem, shuah
In-Reply-To: <cover.1483549208.git.sowmini.varadhan@oracle.com>
The bpf_prog used in sock_setfilter() only attempts to check for
ip pktlen, and verifies that the contents of the 80'th packet in
the ethernet frame is 'a' or 'b'. Thus many non-udp packets
could incorrectly pass through this filter and cause incorrect
test results.
This commit hardens the conditions checked by the filter so
that only UDP/IPv4 packets with the matching length and test-character
will be permitted by the filter. The filter has been cleaned up
to explicitly use the BPF macros to make it more readable.
Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Acked-by: Willem de Bruijn <willemb@google.com>
---
v2: commit comment edited based on review
tools/testing/selftests/net/psock_lib.h | 28 +++++++++++++++++++++-------
1 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/net/psock_lib.h b/tools/testing/selftests/net/psock_lib.h
index 24bc7ec..e62540e 100644
--- a/tools/testing/selftests/net/psock_lib.h
+++ b/tools/testing/selftests/net/psock_lib.h
@@ -27,6 +27,7 @@
#include <string.h>
#include <arpa/inet.h>
#include <unistd.h>
+#include <netinet/udp.h>
#define DATA_LEN 100
#define DATA_CHAR 'a'
@@ -40,14 +41,27 @@
static __maybe_unused void sock_setfilter(int fd, int lvl, int optnum)
{
+ uint16_t ip_len = DATA_LEN +
+ sizeof(struct iphdr) + sizeof(struct udphdr);
+ /* the filter below checks for all of the following conditions that
+ * are based on the contents of create_payload()
+ * ether type 0x800 and
+ * ip proto udp and
+ * ip len == ip_len and
+ * udp[38] == 'a' or udp[38] == 'b'
+ */
struct sock_filter bpf_filter[] = {
- { 0x80, 0, 0, 0x00000000 }, /* LD pktlen */
- { 0x35, 0, 4, DATA_LEN }, /* JGE DATA_LEN [f goto nomatch]*/
- { 0x30, 0, 0, 0x00000050 }, /* LD ip[80] */
- { 0x15, 1, 0, DATA_CHAR }, /* JEQ DATA_CHAR [t goto match]*/
- { 0x15, 0, 1, DATA_CHAR_1}, /* JEQ DATA_CHAR_1 [t goto match]*/
- { 0x06, 0, 0, 0x00000060 }, /* RET match */
- { 0x06, 0, 0, 0x00000000 }, /* RET no match */
+ BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 12), /* LD ethertype */
+ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, ETH_P_IP, 0, 8),
+ BPF_STMT(BPF_LD|BPF_B|BPF_ABS, 23), /* LD ip_proto */
+ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, IPPROTO_UDP, 0, 6),
+ BPF_STMT(BPF_LD|BPF_H|BPF_ABS, 16), /* LD ip_len */
+ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, ip_len, 0, 4),
+ BPF_STMT(BPF_LD|BPF_B|BPF_ABS, 80), /* LD udp[38] */
+ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, DATA_CHAR, 1, 0),
+ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, DATA_CHAR_1, 0, 1),
+ BPF_STMT(BPF_RET | BPF_K, ~0), /* match */
+ BPF_STMT(BPF_RET | BPF_K, 0) /* no match */
};
struct sock_fprog bpf_prog;
--
1.7.1
^ permalink raw reply related
* [PATCH v2 net-next 0/2] tools: psock_tpacket bug fixes
From: Sowmini Varadhan @ 2017-01-04 17:33 UTC (permalink / raw)
To: linux-kselftest, netdev, sowmini.varadhan; +Cc: daniel, willemb, davem, shuah
This patchset includes fixes to psock_tpacket for false-negatives
sporadically reported by the test when it was run concurrently with
other heavy network traffic (e.g., over an ssh session, as opposed
to running the test from the console of the test machine). The
test sometimes failed with errors reporting more recvd packets than
expected (e.g., "walk_v0_rx: received 201 out of 100 pkts") or
the reception of non-IP packets (e.g., ARP packets).
There are 2 sources of network interference that can disrupt the test:
1. set_sockfilter() can use some hardening (currently passes up packets
based on ip length field, and payload signature but this may potentially
match other network traffic on the test machine)
2. There is a race-window between packet_create() and packet_do_bind()
in which packets from any interface (e.g., eth0) will get queued
for Rx on the test socket.
Patch 1 fixes the first issue by cleaing up set_sockfilter() and
hardening it to make sure that it only permits UDP/IPv4 packets.
Patch 2 fixes the second issue by making sure we open the PF_PACKET
socket with protocol 0 to reject all packets, and make sure the
BPF filter is set up before binding the socket to ETH_P_ALL and lo.
Changes from v2: patch 2 reworked based on review comments.
Sowmini Varadhan (2):
tools: tighten conditions checked in sock_setfilter
tools: psock_tpacket: block Rx until socket filter has been added and
socket has been bound to loopback.
tools/testing/selftests/net/psock_lib.h | 28 ++++++++++++++++++++------
tools/testing/selftests/net/psock_tpacket.c | 6 ++--
2 files changed, 24 insertions(+), 10 deletions(-)
^ permalink raw reply
* Re: [PATCH] ethtool: add one ethtool option to set relax ordering mode
From: Alexander Duyck @ 2017-01-04 16:50 UTC (permalink / raw)
To: maowenan
Cc: netdev@vger.kernel.org, jeffrey.t.kirsher@intel.com,
Stephen Hemminger, weiyongjun (A), Dingtianhong, Wangzhou (B)
In-Reply-To: <F95AC9340317A84688A5F0DF0246F3F2015240E0@szxeml504-mbs.china.huawei.com>
On Wed, Jan 4, 2017 at 1:02 AM, maowenan <maowenan@huawei.com> wrote:
>
>
>> -----Original Message-----
>> From: maowenan
>> Sent: Monday, December 26, 2016 4:33 PM
>> To: maowenan; 'Alexander Duyck'
>> Cc: 'Jeff Kirsher'; 'Stephen Hemminger'; 'netdev@vger.kernel.org'; weiyongjun
>> (A); Dingtianhong; Wangzhou (B)
>> Subject: RE: [PATCH] ethtool: add one ethtool option to set relax ordering mode
>>
>>
>>
>> > -----Original Message-----
>> > From: maowenan
>> > Sent: Saturday, December 24, 2016 4:30 PM
>> > To: 'Alexander Duyck'
>> > Cc: Jeff Kirsher; Stephen Hemminger; netdev@vger.kernel.org;
>> > weiyongjun (A); Dingtianhong; Wangzhou (B)
>> > Subject: RE: [PATCH] ethtool: add one ethtool option to set relax
>> > ordering mode
>> >
>> >
>> >
>> > > -----Original Message-----
>> > > From: Alexander Duyck [mailto:alexander.duyck@gmail.com]
>> > > Sent: Friday, December 23, 2016 11:43 PM
>> > > To: maowenan
>> > > Cc: Jeff Kirsher; Stephen Hemminger; netdev@vger.kernel.org;
>> > > weiyongjun (A); Dingtianhong
>> > > Subject: Re: [PATCH] ethtool: add one ethtool option to set relax
>> > > ordering mode
>> > >
>> > > On Thu, Dec 22, 2016 at 10:14 PM, maowenan <maowenan@huawei.com>
>> > > wrote:
>> > > >
>> > > >
>> > > >> -----Original Message-----
>> > > >> From: Jeff Kirsher [mailto:jeffrey.t.kirsher@intel.com]
>> > > >> Sent: Friday, December 23, 2016 9:07 AM
>> > > >> To: maowenan; Alexander Duyck
>> > > >> Cc: Stephen Hemminger; netdev@vger.kernel.org; weiyongjun (A);
>> > > >> Dingtianhong
>> > > >> Subject: Re: [PATCH] ethtool: add one ethtool option to set relax
>> > > >> ordering mode
>> > > >>
>> > > >> On Fri, 2016-12-23 at 00:40 +0000, maowenan wrote:
>> > > >> > > -----Original Message-----
>> > > >> > > From: Alexander Duyck [mailto:alexander.duyck@gmail.com]
>> > > >> > > Sent: Thursday, December 22, 2016 11:54 PM
>> > > >> > > To: maowenan
>> > > >> > > Cc: Stephen Hemminger; netdev@vger.kernel.org;
>> > > jeffrey.t.kirsher@intel.
>> > > >> > > com;
>> > > >> > > weiyongjun (A); Dingtianhong
>> > > >> > > Subject: Re: [PATCH] ethtool: add one ethtool option to set
>> > > >> > > relax ordering mode
>> > > >> > >
>> > > >> > > On Wed, Dec 21, 2016 at 5:39 PM, maowenan
>> > > <maowenan@huawei.com>
>> > > >> > > wrote:
>> > > >> > > >
>> > > >> > > >
>> > > >> > > > > -----Original Message-----
>> > > >> > > > > From: Stephen Hemminger
>> > > >> > > > > [mailto:stephen@networkplumber.org]
>> > > >> > > > > Sent: Thursday, December 22, 2016 9:28 AM
>> > > >> > > > > To: maowenan
>> > > >> > > > > Cc: netdev@vger.kernel.org; jeffrey.t.kirsher@intel.com
>> > > >> > > > > Subject: Re: [PATCH] ethtool: add one ethtool option to
>> > > >> > > > > set relax ordering mode
>> > > >> > > > >
>> > > >> > > > > On Thu, 8 Dec 2016 14:51:38 +0800 Mao Wenan
>> > > >> > > > > <maowenan@huawei.com> wrote:
>> > > >> > > > >
>> > > >> > > > > > This patch provides one way to set/unset IXGBE NIC TX
>> > > >> > > > > > and RX relax ordering mode, which can be set by ethtool.
>> > > >> > > > > > Relax ordering is one mode of 82599 NIC, to enable this
>> > > >> > > > > > mode can enhance the performance for some cpu architecure.
>> > > >> > > > >
>> > > >> > > > > Then it should be done by CPU architecture specific
>> > > >> > > > > quirks (preferably in PCI
>> > > >> > > > > layer) so that all users get the option without having to
>> > > >> > > > > do manual
>> > > >> > >
>> > > >> > > intervention.
>> > > >> > > > >
>> > > >> > > > > > example:
>> > > >> > > > > > ethtool -s enp1s0f0 relaxorder off ethtool -s enp1s0f0
>> > > >> > > > > > relaxorder on
>> > > >> > > > >
>> > > >> > > > > Doing it via ethtool is a developer API (for testing) not
>> > > >> > > > > something that makes sense in production.
>> > > >> > > >
>> > > >> > > >
>> > > >> > > > This feature is not mandatory for all users, acturally
>> > > >> > > > relax ordering default configuration of 82599 is 'disable',
>> > > >> > > > So this patch gives one way to
>> > > >> > >
>> > > >> > > enable relax ordering to be selected in some performance condition.
>> > > >> > >
>> > > >> > > That isn't quite true. The default for Sparc systems is to
>> > > >> > > have it enabled.
>> > > >> > >
>> > > >> > > Really this is something that is platform specific. I agree
>> > > >> > > with Stephen that it would work better if this was handled as
>> > > >> > > a series of platform specific quirks handled at something
>> > > >> > > like the PCI layer rather than be a switch the user can toggle on and
>> off.
>> > > >> > >
>> > > >> > > With that being said there are changes being made that should
>> > > >> > > help to improve the situation. Specifically I am looking at
>> > > >> > > adding support for the DMA_ATTR_WEAK_ORDERING which may
>> also
>> > > >> > > allow us to identify cases where you might be able to specify
>> > > >> > > the DMA behavior via the DMA mapping instead of having to
>> > > >> > > make the final decision in the device itself.
>> > > >> > >
>> > > >> > > - Alex
>> > > >> >
>> > > >> > Yes, Sparc is a special case. From the NIC driver point of
>> > > >> > view, It is no need for some ARCHs to do particular operation
>> > > >> > and compiling branch, ethtool is a flexible method for user to
>> > > >> > make decision whether
>> > > >> > on|off this feature.
>> > > >> > I think Jeff as maintainer of 82599 has some comments about this.
>> > > >>
>> > > >> My original comment/objection was that you attempted to do this
>> > > >> change as a module parameter to the ixgbe driver, where I
>> > > >> directed you to use ethtool so that other drivers could benefit
>> > > >> from the ability to enable/disable relaxed ordering. As far as
>> > > >> how it gets implemented in ethtool or PCI layer, makes little
>> > > >> difference to me, I only had issues with the driver specific
>> > > >> module parameter implementation,
>> > > which is not acceptable.
>> > > >
>> > > >
>> > > > Thank you Jeff and Alex.
>> > > > And then I have gone through mail thread about "i40e: enable PCIe
>> > > > relax ordering for SPARC", It only works for SPARC, any other ARCH
>> > > > who wants to enable DMA_ATTR_WEAK_ORDERING feature, should
>> define
>> > > > the
>> > > new macro, recompile the driver module.
>> > > >
>> > > > Because of the above reasons, we implement in ethtool to give the
>> > > > final user a convenient way to on|off special feature, no need
>> > > > define new macro, easy to extend the new features, and also good
>> > > > benefit for other
>> > > driver as Jeff referred.
>> > > >
>> > >
>> > > I think the point is we shouldn't base the decision on user input.
>> > > The fact is the PCIe device control register should have a bit that
>> > > indicates if the device is allowed to enable relaxed ordering or not.
>> > > If we can guarantee that the bit is set in all the cases where it
>> > > should be set, and cleared in all the cases where it should not then
>> > > we could use something like that to determine if the device is
>> > > supposed to enable relaxed ordering instead of trying to make the
>> > > decision
>> > ourselves.
>> > >
>> > > - Alex
>> >
>> > ok. We are focusing on the register.
>> > And yes, to enable relax ordering for 82599 should be set by one or
>> > more bits of Rx/TX DCA Control Register, these bits should be set in
>> > many cpu architectures, such as arm64, sparc, and so on, and should be
>> cleared in other ARCHs.
>> > By the way, how do you enable SPARC macro, how and where to define
>> > this compiling macro when user one to enable relax ordering under SPARC
>> system?
>> > #ifndef CONFIG_SPARC
>> >
>> >
>>
>>
>> Hi, Alex,
>> Have you already sent out the patches about DMA_ATTR_WEAK_ORDERING?
>> We want to get you how to enable DMA_ATTR_WEAK_ORDERING by PCIe layer,
>> and we can refer to that.
>
> I have verified DMA_ATTR_WEAK_ORDERING is not usable for our system(arm64 and 82599),
> We should enable relax ordering in 82599 DCA control register to improve performance.
> As Stephen Hemminger do not suggest use ethtool to set relax ordering feature,
> @Jeff, do you agree with using erratum config to enable RO mode in 82599.
> Codes like below:
> In Kconfig:
> +config HI_ERRATUM_xxxx
>
> In ixgbe_82599.c
> #if !defined (CONFIG_SPARC) || !defined(HI_ERRATUM_xxxx)
> /* Disable relaxed ordering */
> for (i = 0; ((i < hw->mac.max_tx_queues) &&
> (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) {
> regval = IXGBE_READ_REG(hw, IXGBE_DCA_TXCTRL(i));
> regval &= ~IXGBE_DCA_TXCTRL_DESC_WRO_EN;
> IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL(i), regval);
> }
>
> for (i = 0; ((i < hw->mac.max_rx_queues) &&
> (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) {
> regval = IXGBE_READ_REG(hw, IXGBE_DCA_RXCTRL(i));
> regval &= ~(IXGBE_DCA_RXCTRL_DATA_WRO_EN |
> IXGBE_DCA_RXCTRL_HEAD_WRO_EN);
> IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(i), regval);
> }
> #endif
Instead of having the driver add a flag per architecture maybe it
would be worthwhile to look at adding a config flag that can be set
specifically for the architectures that need it. Maybe something like
a "ARCH_WANT_RO_DMA" that then drivers could modify their relaxed
ordering flag based on. Then you could just add the flag to the SPARC
and your arm64 kconfig options and not have to involve the other
architectures.
- Alex
^ permalink raw reply
* Re: [PATCH] MIPS: NI 169445 board support
From: Nathan Sullivan @ 2017-01-04 16:38 UTC (permalink / raw)
To: Ralf Baechle, linux-mips; +Cc: davem, netdev, linux-kernel
In-Reply-To: <20161220163434.GA15962@linux-mips.org>
On Tue, Dec 20, 2016 at 05:34:34PM +0100, Ralf Baechle wrote:
> On Fri, Dec 02, 2016 at 09:42:09AM -0600, Nathan Sullivan wrote:
> > Date: Fri, 2 Dec 2016 09:42:09 -0600
> > From: Nathan Sullivan <nathan.sullivan@ni.com>
> > To: ralf@linux-mips.org, mark.rutland@arm.com, robh+dt@kernel.org
> > CC: linux-mips@linux-mips.org, devicetree@vger.kernel.org,
> > linux-kernel@vger.kernel.org, Nathan Sullivan <nathan.sullivan@ni.com>
> > Subject: [PATCH] MIPS: NI 169445 board support
> > Content-Type: text/plain
> >
> > Support the National Instruments 169445 board.
>
> Nathan,
>
> I assume you're going to repost the changes Rob asked for in
> https://patchwork.linux-mips.org/patch/14641/#26924 and resubmit?
>
> Thanks,
>
> Ralf
Hmm, I found the issue with the generic MIPS config and dwc_eth_qos. The NIC
driver attempts to cache align a descriptor ring using the ___cacheline_aligned
attribute on the descriptor struct, in combination with a "skip" feature in
hardware. However, the skip feature only has a three bit field, and the generic
MIPS config selects MIPS_L1_CACHE_SHIFT_7. So, the line size is 128, and with a
64-bit bus, that means the NIC descriptor skip field would need to be set to
14 to align the 16-byte descriptors...
I guess it makes sense for a generic MIPS kernel to align everything for 128 byte
cache lines, and for me to fix the dwc_eth_qos driver to handle cases where the
line size is too big for the hardware skip feature, right?
Thanks,
Nathan
^ permalink raw reply
* Re: [PATCH v3 3/3] stmmac: adding new glue driver dwmac-dwc-qos-eth
From: Joao Pinto @ 2017-01-04 16:36 UTC (permalink / raw)
To: Niklas Cassel, Joao Pinto, davem; +Cc: larper, swarren, treding, netdev
In-Reply-To: <e3081bf2-e1ca-7e29-07d0-b31eb2823762@axis.com>
Às 4:31 PM de 1/4/2017, Niklas Cassel escreveu:
> I think you accidentally removed the Reviewed-by from Lars.
I took it off because the driver was changed after the first review (v1->v2).
Lars, could you please confirm that everything is fine for you?
Thanks.
>
> On 01/04/2017 05:22 PM, Joao Pinto wrote:
>> This patch adds a new glue driver called dwmac-dwc-qos-eth which
>> was based in the dwc_eth_qos as is. To assure retro-compatibility a slight
>> tweak was also added to stmmac_platform.
>>
>> Signed-off-by: Joao Pinto <jpinto@synopsys.com>
>> ---
>> changes v2 -> v3:
>> - Nothing changed, just to keep up patch set version
>> changes v1 -> v2:
>> - WOL was not declared in the new glue driver
>> - clocks were switched and now fixed (apb_pclk and phy_ref_clk)
>>
>> .../bindings/net/snps,dwc-qos-ethernet.txt | 3 +
>> drivers/net/ethernet/stmicro/stmmac/Kconfig | 9 +
>> drivers/net/ethernet/stmicro/stmmac/Makefile | 1 +
>> .../ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 200 +++++++++++++++++++++
>> .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 15 +-
>> 5 files changed, 225 insertions(+), 3 deletions(-)
>> create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
>>
>> diff --git a/Documentation/devicetree/bindings/net/snps,dwc-qos-ethernet.txt b/Documentation/devicetree/bindings/net/snps,dwc-qos-ethernet.txt
>> index d93f71c..21d27aa 100644
>> --- a/Documentation/devicetree/bindings/net/snps,dwc-qos-ethernet.txt
>> +++ b/Documentation/devicetree/bindings/net/snps,dwc-qos-ethernet.txt
>> @@ -1,5 +1,8 @@
>> * Synopsys DWC Ethernet QoS IP version 4.10 driver (GMAC)
>>
>> +This binding is deprecated, but it continues to be supported, but new
>> +features should be preferably added to the stmmac binding document.
>> +
>> This binding supports the Synopsys Designware Ethernet QoS (Quality Of Service)
>> IP block. The IP supports multiple options for bus type, clocking and reset
>> structure, and feature list. Consequently, a number of properties and list
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
>> index ab66248..99594e3 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
>> +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
>> @@ -29,6 +29,15 @@ config STMMAC_PLATFORM
>>
>> if STMMAC_PLATFORM
>>
>> +config DWMAC_DWC_QOS_ETH
>> + tristate "Support for snps,dwc-qos-ethernet.txt DT binding."
>> + select PHYLIB
>> + select CRC32
>> + select MII
>> + depends on OF && HAS_DMA
>> + help
>> + Support for chips using the snps,dwc-qos-ethernet.txt DT binding.
>> +
>> config DWMAC_GENERIC
>> tristate "Generic driver for DWMAC"
>> default STMMAC_PLATFORM
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile
>> index 8f83a86..700c603 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/Makefile
>> +++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
>> @@ -16,6 +16,7 @@ obj-$(CONFIG_DWMAC_SOCFPGA) += dwmac-altr-socfpga.o
>> obj-$(CONFIG_DWMAC_STI) += dwmac-sti.o
>> obj-$(CONFIG_DWMAC_STM32) += dwmac-stm32.o
>> obj-$(CONFIG_DWMAC_SUNXI) += dwmac-sunxi.o
>> +obj-$(CONFIG_DWMAC_DWC_QOS_ETH) += dwmac-dwc-qos-eth.o
>> obj-$(CONFIG_DWMAC_GENERIC) += dwmac-generic.o
>> stmmac-platform-objs:= stmmac_platform.o
>> dwmac-altr-socfpga-objs := altr_tse_pcs.o dwmac-socfpga.o
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
>> new file mode 100644
>> index 0000000..4532a7c
>> --- /dev/null
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
>> @@ -0,0 +1,200 @@
>> +/*
>> + * Synopsys DWC Ethernet Quality-of-Service v4.10a linux driver
>> + *
>> + * Copyright (C) 2016 Joao Pinto <jpinto@synopsys.com>
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * along with this program. If not, see <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.gnu.org_licenses_&d=DgIC-g&c=DPL6_X_6JkXFx7AXWqB0tg&r=s2fO0hii0OGNOv9qQy_HRXy-xAJUD1NNoEcc3io_kx0&m=jmoFmglB-YKlIAGvraqqQjZI2mrDkiGUcJ1ThAvxT28&s=iOOZn_X7Atdgfy9ybDRxGhRY08ZpsS1_Z-Q_OHPiSnE&e= >.
>> + */
>> +
>> +#include <linux/clk.h>
>> +#include <linux/clk-provider.h>
>> +#include <linux/device.h>
>> +#include <linux/ethtool.h>
>> +#include <linux/io.h>
>> +#include <linux/ioport.h>
>> +#include <linux/module.h>
>> +#include <linux/of_net.h>
>> +#include <linux/mfd/syscon.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/stmmac.h>
>> +
>> +#include "stmmac_platform.h"
>> +
>> +static int dwc_eth_dwmac_config_dt(struct platform_device *pdev,
>> + struct plat_stmmacenet_data *plat_dat)
>> +{
>> + struct device_node *np = pdev->dev.of_node;
>> + u32 burst_map = 0;
>> + u32 bit_index = 0;
>> + u32 a_index = 0;
>> +
>> + if (!plat_dat->axi) {
>> + plat_dat->axi = kzalloc(sizeof(struct stmmac_axi), GFP_KERNEL);
>> +
>> + if (!plat_dat->axi)
>> + return -ENOMEM;
>> + }
>> +
>> + plat_dat->axi->axi_lpi_en = of_property_read_bool(np, "snps,en-lpi");
>> + if (of_property_read_u32(np, "snps,write-requests",
>> + &plat_dat->axi->axi_wr_osr_lmt)) {
>> + /**
>> + * Since the register has a reset value of 1, if property
>> + * is missing, default to 1.
>> + */
>> + plat_dat->axi->axi_wr_osr_lmt = 1;
>> + } else {
>> + /**
>> + * If property exists, to keep the behavior from dwc_eth_qos,
>> + * subtract one after parsing.
>> + */
>> + plat_dat->axi->axi_wr_osr_lmt--;
>> + }
>> +
>> + if (of_property_read_u32(np, "read,read-requests",
>> + &plat_dat->axi->axi_rd_osr_lmt)) {
>> + /**
>> + * Since the register has a reset value of 1, if property
>> + * is missing, default to 1.
>> + */
>> + plat_dat->axi->axi_rd_osr_lmt = 1;
>> + } else {
>> + /**
>> + * If property exists, to keep the behavior from dwc_eth_qos,
>> + * subtract one after parsing.
>> + */
>> + plat_dat->axi->axi_rd_osr_lmt--;
>> + }
>> + of_property_read_u32(np, "snps,burst-map", &burst_map);
>> +
>> + /* converts burst-map bitmask to burst array */
>> + for (bit_index = 0; bit_index < 7; bit_index++) {
>> + if (burst_map & (1 << bit_index)) {
>> + switch (bit_index) {
>> + case 0:
>> + plat_dat->axi->axi_blen[a_index] = 4; break;
>> + case 1:
>> + plat_dat->axi->axi_blen[a_index] = 8; break;
>> + case 2:
>> + plat_dat->axi->axi_blen[a_index] = 16; break;
>> + case 3:
>> + plat_dat->axi->axi_blen[a_index] = 32; break;
>> + case 4:
>> + plat_dat->axi->axi_blen[a_index] = 64; break;
>> + case 5:
>> + plat_dat->axi->axi_blen[a_index] = 128; break;
>> + case 6:
>> + plat_dat->axi->axi_blen[a_index] = 256; break;
>> + default:
>> + break;
>> + }
>> + a_index++;
>> + }
>> + }
>> +
>> + /* dwc-qos needs GMAC4, AAL, TSO and PMT */
>> + plat_dat->has_gmac4 = 1;
>> + plat_dat->dma_cfg->aal = 1;
>> + plat_dat->tso_en = 1;
>> + plat_dat->pmt = 1;
>> +
>> + return 0;
>> +}
>> +
>> +static int dwc_eth_dwmac_probe(struct platform_device *pdev)
>> +{
>> + struct plat_stmmacenet_data *plat_dat;
>> + struct stmmac_resources stmmac_res;
>> + struct resource *res;
>> + int ret;
>> +
>> + /**
>> + * Since stmmac_platform supports name IRQ only, basic platform
>> + * resource initialization is done in the glue logic.
>> + */
>> + stmmac_res.irq = platform_get_irq(pdev, 0);
>> + if (stmmac_res.irq < 0) {
>> + if (stmmac_res.irq != -EPROBE_DEFER) {
>> + dev_err(&pdev->dev,
>> + "IRQ configuration information not found\n");
>> + }
>> + return stmmac_res.irq;
>> + }
>> + stmmac_res.wol_irq = stmmac_res.irq;
>> +
>> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> + stmmac_res.addr = devm_ioremap_resource(&pdev->dev, res);
>> + if (IS_ERR(stmmac_res.addr))
>> + return PTR_ERR(stmmac_res.addr);
>> +
>> + plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
>> + if (IS_ERR(plat_dat))
>> + return PTR_ERR(plat_dat);
>> +
>> + plat_dat->stmmac_clk = devm_clk_get(&pdev->dev, "apb_pclk");
>> + if (IS_ERR(plat_dat->stmmac_clk)) {
>> + dev_err(&pdev->dev, "apb_pclk clock not found.\n");
>> + ret = PTR_ERR(plat_dat->stmmac_clk);
>> + plat_dat->stmmac_clk = NULL;
>> + goto err_remove_config_dt;
>> + }
>> + clk_prepare_enable(plat_dat->stmmac_clk);
>> +
>> + plat_dat->pclk = devm_clk_get(&pdev->dev, "phy_ref_clk");
>> + if (IS_ERR(plat_dat->pclk)) {
>> + dev_err(&pdev->dev, "phy_ref_clk clock not found.\n");
>> + ret = PTR_ERR(plat_dat->pclk);
>> + plat_dat->pclk = NULL;
>> + goto err_out_clk_dis_phy;
>> + }
>> + clk_prepare_enable(plat_dat->pclk);
>> +
>> + ret = dwc_eth_dwmac_config_dt(pdev, plat_dat);
>> + if (ret)
>> + goto err_out_clk_dis_aper;
>> +
>> + ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
>> + if (ret)
>> + goto err_out_clk_dis_aper;
>> +
>> + return 0;
>> +
>> +err_out_clk_dis_aper:
>> + clk_disable_unprepare(plat_dat->pclk);
>> +err_out_clk_dis_phy:
>> + clk_disable_unprepare(plat_dat->stmmac_clk);
>> +err_remove_config_dt:
>> + stmmac_remove_config_dt(pdev, plat_dat);
>> +
>> + return ret;
>> +}
>> +
>> +static int dwc_eth_dwmac_remove(struct platform_device *pdev)
>> +{
>> + return stmmac_pltfr_remove(pdev);
>> +}
>> +
>> +static const struct of_device_id dwc_eth_dwmac_match[] = {
>> + { .compatible = "snps,dwc-qos-ethernet-4.10", },
>> + { }
>> +};
>> +MODULE_DEVICE_TABLE(of, dwc_eth_dwmac_match);
>> +
>> +static struct platform_driver dwc_eth_dwmac_driver = {
>> + .probe = dwc_eth_dwmac_probe,
>> + .remove = dwc_eth_dwmac_remove,
>> + .driver = {
>> + .name = "dwc-eth-dwmac",
>> + .of_match_table = dwc_eth_dwmac_match,
>> + },
>> +};
>> +module_platform_driver(dwc_eth_dwmac_driver);
>> +
>> +MODULE_AUTHOR("Joao Pinto <jpinto@synopsys.com>");
>> +MODULE_DESCRIPTION("Synopsys DWC Ethernet Quality-of-Service v4.10a driver");
>> +MODULE_LICENSE("GPL v2");
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>> index 4e44f9c..00c0f8d 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>> @@ -181,10 +181,19 @@ static int stmmac_dt_phy(struct plat_stmmacenet_data *plat,
>> mdio = false;
>> }
>>
>> - /* If snps,dwmac-mdio is passed from DT, always register the MDIO */
>> - for_each_child_of_node(np, plat->mdio_node) {
>> - if (of_device_is_compatible(plat->mdio_node, "snps,dwmac-mdio"))
>> + /* exception for dwmac-dwc-qos-eth glue logic */
>> + if (of_device_is_compatible(np, "snps,dwc-qos-ethernet-4.10")) {
>> + plat->mdio_node = of_get_child_by_name(np, "mdio");
>> + } else {
>> + /**
>> + * If snps,dwmac-mdio is passed from DT, always register
>> + * the MDIO
>> + */
>> + for_each_child_of_node(np, plat->mdio_node) {
>> + if (of_device_is_compatible(plat->mdio_node,
>> + "snps,dwmac-mdio"))
>> break;
>> + }
>> }
>>
>> if (plat->mdio_node) {
>
^ permalink raw reply
* [SIDE DISCUSSION] Re: [PATCH] phy state machine: failsafe leave invalid RUNNING state
From: Matthias May @ 2017-01-04 16:24 UTC (permalink / raw)
To: Andrew Lunn; +Cc: Zefir Kurtisi, Florian Fainelli, netdev
In-Reply-To: <20170104161615.GF5517@lunn.ch>
On 04/01/17 17:16, Andrew Lunn wrote:
>> The setup is as follows:
>> mv88e6321:
>> * ports 0+1 connected to fibre-optics transceivers at fixed 100 Mbps
>> * port 4 is CPU port
>> * custom phy driver (replacement for marvell.ko) only populated with
>> * .config_init to
>> * set fixed speed for ports 0+1 (when in FO mode)
>> * run genphy_config_init() for all other modes (here: CPU port)
>> * .config_aneg=genphy_config_aneg, .read_status=genphy_read_status
>
> Kicking off a side discussion:
>
> Why do a custom PHY driver? What cannot you do with the current DSA
> code? I've got boards with two FO ports, and using fixed-phy is all i
> need to make them work on a 6352.
>
> Andrew
>
We make two FO boards for 100Mbps and Gbit with different transceivers.
These different transceivers need each their own drive strength.
As Zefir wrote it's basically just a remap to the genphy functions with
some additional hardware specific register writes when the POR values
for FO configuration are detected on a port.
BR
Matthias
^ permalink raw reply
* Re: [PATCH v3 3/3] stmmac: adding new glue driver dwmac-dwc-qos-eth
From: Niklas Cassel @ 2017-01-04 16:31 UTC (permalink / raw)
To: Joao Pinto, davem; +Cc: larper, swarren, treding, netdev
In-Reply-To: <f72953efa2d6a42975b553a6b517c63480f4650b.1483546363.git.jpinto@synopsys.com>
I think you accidentally removed the Reviewed-by from Lars.
On 01/04/2017 05:22 PM, Joao Pinto wrote:
> This patch adds a new glue driver called dwmac-dwc-qos-eth which
> was based in the dwc_eth_qos as is. To assure retro-compatibility a slight
> tweak was also added to stmmac_platform.
>
> Signed-off-by: Joao Pinto <jpinto@synopsys.com>
> ---
> changes v2 -> v3:
> - Nothing changed, just to keep up patch set version
> changes v1 -> v2:
> - WOL was not declared in the new glue driver
> - clocks were switched and now fixed (apb_pclk and phy_ref_clk)
>
> .../bindings/net/snps,dwc-qos-ethernet.txt | 3 +
> drivers/net/ethernet/stmicro/stmmac/Kconfig | 9 +
> drivers/net/ethernet/stmicro/stmmac/Makefile | 1 +
> .../ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 200 +++++++++++++++++++++
> .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 15 +-
> 5 files changed, 225 insertions(+), 3 deletions(-)
> create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
>
> diff --git a/Documentation/devicetree/bindings/net/snps,dwc-qos-ethernet.txt b/Documentation/devicetree/bindings/net/snps,dwc-qos-ethernet.txt
> index d93f71c..21d27aa 100644
> --- a/Documentation/devicetree/bindings/net/snps,dwc-qos-ethernet.txt
> +++ b/Documentation/devicetree/bindings/net/snps,dwc-qos-ethernet.txt
> @@ -1,5 +1,8 @@
> * Synopsys DWC Ethernet QoS IP version 4.10 driver (GMAC)
>
> +This binding is deprecated, but it continues to be supported, but new
> +features should be preferably added to the stmmac binding document.
> +
> This binding supports the Synopsys Designware Ethernet QoS (Quality Of Service)
> IP block. The IP supports multiple options for bus type, clocking and reset
> structure, and feature list. Consequently, a number of properties and list
> diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
> index ab66248..99594e3 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
> +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
> @@ -29,6 +29,15 @@ config STMMAC_PLATFORM
>
> if STMMAC_PLATFORM
>
> +config DWMAC_DWC_QOS_ETH
> + tristate "Support for snps,dwc-qos-ethernet.txt DT binding."
> + select PHYLIB
> + select CRC32
> + select MII
> + depends on OF && HAS_DMA
> + help
> + Support for chips using the snps,dwc-qos-ethernet.txt DT binding.
> +
> config DWMAC_GENERIC
> tristate "Generic driver for DWMAC"
> default STMMAC_PLATFORM
> diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile
> index 8f83a86..700c603 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/Makefile
> +++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
> @@ -16,6 +16,7 @@ obj-$(CONFIG_DWMAC_SOCFPGA) += dwmac-altr-socfpga.o
> obj-$(CONFIG_DWMAC_STI) += dwmac-sti.o
> obj-$(CONFIG_DWMAC_STM32) += dwmac-stm32.o
> obj-$(CONFIG_DWMAC_SUNXI) += dwmac-sunxi.o
> +obj-$(CONFIG_DWMAC_DWC_QOS_ETH) += dwmac-dwc-qos-eth.o
> obj-$(CONFIG_DWMAC_GENERIC) += dwmac-generic.o
> stmmac-platform-objs:= stmmac_platform.o
> dwmac-altr-socfpga-objs := altr_tse_pcs.o dwmac-socfpga.o
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> new file mode 100644
> index 0000000..4532a7c
> --- /dev/null
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> @@ -0,0 +1,200 @@
> +/*
> + * Synopsys DWC Ethernet Quality-of-Service v4.10a linux driver
> + *
> + * Copyright (C) 2016 Joao Pinto <jpinto@synopsys.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program. If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/clk-provider.h>
> +#include <linux/device.h>
> +#include <linux/ethtool.h>
> +#include <linux/io.h>
> +#include <linux/ioport.h>
> +#include <linux/module.h>
> +#include <linux/of_net.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/platform_device.h>
> +#include <linux/stmmac.h>
> +
> +#include "stmmac_platform.h"
> +
> +static int dwc_eth_dwmac_config_dt(struct platform_device *pdev,
> + struct plat_stmmacenet_data *plat_dat)
> +{
> + struct device_node *np = pdev->dev.of_node;
> + u32 burst_map = 0;
> + u32 bit_index = 0;
> + u32 a_index = 0;
> +
> + if (!plat_dat->axi) {
> + plat_dat->axi = kzalloc(sizeof(struct stmmac_axi), GFP_KERNEL);
> +
> + if (!plat_dat->axi)
> + return -ENOMEM;
> + }
> +
> + plat_dat->axi->axi_lpi_en = of_property_read_bool(np, "snps,en-lpi");
> + if (of_property_read_u32(np, "snps,write-requests",
> + &plat_dat->axi->axi_wr_osr_lmt)) {
> + /**
> + * Since the register has a reset value of 1, if property
> + * is missing, default to 1.
> + */
> + plat_dat->axi->axi_wr_osr_lmt = 1;
> + } else {
> + /**
> + * If property exists, to keep the behavior from dwc_eth_qos,
> + * subtract one after parsing.
> + */
> + plat_dat->axi->axi_wr_osr_lmt--;
> + }
> +
> + if (of_property_read_u32(np, "read,read-requests",
> + &plat_dat->axi->axi_rd_osr_lmt)) {
> + /**
> + * Since the register has a reset value of 1, if property
> + * is missing, default to 1.
> + */
> + plat_dat->axi->axi_rd_osr_lmt = 1;
> + } else {
> + /**
> + * If property exists, to keep the behavior from dwc_eth_qos,
> + * subtract one after parsing.
> + */
> + plat_dat->axi->axi_rd_osr_lmt--;
> + }
> + of_property_read_u32(np, "snps,burst-map", &burst_map);
> +
> + /* converts burst-map bitmask to burst array */
> + for (bit_index = 0; bit_index < 7; bit_index++) {
> + if (burst_map & (1 << bit_index)) {
> + switch (bit_index) {
> + case 0:
> + plat_dat->axi->axi_blen[a_index] = 4; break;
> + case 1:
> + plat_dat->axi->axi_blen[a_index] = 8; break;
> + case 2:
> + plat_dat->axi->axi_blen[a_index] = 16; break;
> + case 3:
> + plat_dat->axi->axi_blen[a_index] = 32; break;
> + case 4:
> + plat_dat->axi->axi_blen[a_index] = 64; break;
> + case 5:
> + plat_dat->axi->axi_blen[a_index] = 128; break;
> + case 6:
> + plat_dat->axi->axi_blen[a_index] = 256; break;
> + default:
> + break;
> + }
> + a_index++;
> + }
> + }
> +
> + /* dwc-qos needs GMAC4, AAL, TSO and PMT */
> + plat_dat->has_gmac4 = 1;
> + plat_dat->dma_cfg->aal = 1;
> + plat_dat->tso_en = 1;
> + plat_dat->pmt = 1;
> +
> + return 0;
> +}
> +
> +static int dwc_eth_dwmac_probe(struct platform_device *pdev)
> +{
> + struct plat_stmmacenet_data *plat_dat;
> + struct stmmac_resources stmmac_res;
> + struct resource *res;
> + int ret;
> +
> + /**
> + * Since stmmac_platform supports name IRQ only, basic platform
> + * resource initialization is done in the glue logic.
> + */
> + stmmac_res.irq = platform_get_irq(pdev, 0);
> + if (stmmac_res.irq < 0) {
> + if (stmmac_res.irq != -EPROBE_DEFER) {
> + dev_err(&pdev->dev,
> + "IRQ configuration information not found\n");
> + }
> + return stmmac_res.irq;
> + }
> + stmmac_res.wol_irq = stmmac_res.irq;
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + stmmac_res.addr = devm_ioremap_resource(&pdev->dev, res);
> + if (IS_ERR(stmmac_res.addr))
> + return PTR_ERR(stmmac_res.addr);
> +
> + plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
> + if (IS_ERR(plat_dat))
> + return PTR_ERR(plat_dat);
> +
> + plat_dat->stmmac_clk = devm_clk_get(&pdev->dev, "apb_pclk");
> + if (IS_ERR(plat_dat->stmmac_clk)) {
> + dev_err(&pdev->dev, "apb_pclk clock not found.\n");
> + ret = PTR_ERR(plat_dat->stmmac_clk);
> + plat_dat->stmmac_clk = NULL;
> + goto err_remove_config_dt;
> + }
> + clk_prepare_enable(plat_dat->stmmac_clk);
> +
> + plat_dat->pclk = devm_clk_get(&pdev->dev, "phy_ref_clk");
> + if (IS_ERR(plat_dat->pclk)) {
> + dev_err(&pdev->dev, "phy_ref_clk clock not found.\n");
> + ret = PTR_ERR(plat_dat->pclk);
> + plat_dat->pclk = NULL;
> + goto err_out_clk_dis_phy;
> + }
> + clk_prepare_enable(plat_dat->pclk);
> +
> + ret = dwc_eth_dwmac_config_dt(pdev, plat_dat);
> + if (ret)
> + goto err_out_clk_dis_aper;
> +
> + ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
> + if (ret)
> + goto err_out_clk_dis_aper;
> +
> + return 0;
> +
> +err_out_clk_dis_aper:
> + clk_disable_unprepare(plat_dat->pclk);
> +err_out_clk_dis_phy:
> + clk_disable_unprepare(plat_dat->stmmac_clk);
> +err_remove_config_dt:
> + stmmac_remove_config_dt(pdev, plat_dat);
> +
> + return ret;
> +}
> +
> +static int dwc_eth_dwmac_remove(struct platform_device *pdev)
> +{
> + return stmmac_pltfr_remove(pdev);
> +}
> +
> +static const struct of_device_id dwc_eth_dwmac_match[] = {
> + { .compatible = "snps,dwc-qos-ethernet-4.10", },
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, dwc_eth_dwmac_match);
> +
> +static struct platform_driver dwc_eth_dwmac_driver = {
> + .probe = dwc_eth_dwmac_probe,
> + .remove = dwc_eth_dwmac_remove,
> + .driver = {
> + .name = "dwc-eth-dwmac",
> + .of_match_table = dwc_eth_dwmac_match,
> + },
> +};
> +module_platform_driver(dwc_eth_dwmac_driver);
> +
> +MODULE_AUTHOR("Joao Pinto <jpinto@synopsys.com>");
> +MODULE_DESCRIPTION("Synopsys DWC Ethernet Quality-of-Service v4.10a driver");
> +MODULE_LICENSE("GPL v2");
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> index 4e44f9c..00c0f8d 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> @@ -181,10 +181,19 @@ static int stmmac_dt_phy(struct plat_stmmacenet_data *plat,
> mdio = false;
> }
>
> - /* If snps,dwmac-mdio is passed from DT, always register the MDIO */
> - for_each_child_of_node(np, plat->mdio_node) {
> - if (of_device_is_compatible(plat->mdio_node, "snps,dwmac-mdio"))
> + /* exception for dwmac-dwc-qos-eth glue logic */
> + if (of_device_is_compatible(np, "snps,dwc-qos-ethernet-4.10")) {
> + plat->mdio_node = of_get_child_by_name(np, "mdio");
> + } else {
> + /**
> + * If snps,dwmac-mdio is passed from DT, always register
> + * the MDIO
> + */
> + for_each_child_of_node(np, plat->mdio_node) {
> + if (of_device_is_compatible(plat->mdio_node,
> + "snps,dwmac-mdio"))
> break;
> + }
> }
>
> if (plat->mdio_node) {
^ permalink raw reply
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