* Re: [PATCH v2 net-next 5/8] net/ncsi: Dump NCSI packet statistics
From: Gavin Shan @ 2017-04-18 0:22 UTC (permalink / raw)
To: Joe Perches; +Cc: Gavin Shan, netdev, davem
In-Reply-To: <1492137045.28586.26.camel@perches.com>
On Thu, Apr 13, 2017 at 07:30:45PM -0700, Joe Perches wrote:
>On Thu, 2017-04-13 at 17:48 +1000, Gavin Shan wrote:
>> This creates /sys/kernel/debug/ncsi/<eth0>/stats to dump the NCSI
>> packets sent and received over all packages and channels. It's useful
>> to diagnose NCSI problems, especially when NCSI packages and channels
>> aren't probed properly. The statistics can be gained from debugfs file
>> as below:
>>
>> # cat /sys/kernel/debug/ncsi/eth0/stats
>>
>> CMD OK TIMEOUT ERROR
>> =======================================
>> CIS 32 29 0
>> SP 10 7 0
>> DP 17 14 0
>> EC 1 0 0
>> ECNT 1 0 0
>> AE 1 0 0
>> GLS 11 0 0
>> SMA 1 0 0
>> EBF 1 0 0
>> GVI 2 0 0
>> GC 2 0 0
>
>more trivia:
>
>> diff --git a/net/ncsi/ncsi-debug.c b/net/ncsi/ncsi-debug.c
>[]
>> @@ -23,6 +23,235 @@
>> #include "ncsi-pkt.h"
>>
>> static struct dentry *ncsi_dentry;
>> +static struct ncsi_pkt_handler {
>> + unsigned char type;
>> + const char *name;
>> +} ncsi_pkt_handlers[] = {
>> + { NCSI_PKT_CMD_CIS, "CIS" },
>> + { NCSI_PKT_CMD_SP, "SP" },
>> + { NCSI_PKT_CMD_DP, "DP" },
>> + { NCSI_PKT_CMD_EC, "EC" },
>> + { NCSI_PKT_CMD_DC, "DC" },
>> + { NCSI_PKT_CMD_RC, "RC" },
>> + { NCSI_PKT_CMD_ECNT, "ECNT" },
>> + { NCSI_PKT_CMD_DCNT, "DCNT" },
>> + { NCSI_PKT_CMD_AE, "AE" },
>> + { NCSI_PKT_CMD_SL, "SL" },
>> + { NCSI_PKT_CMD_GLS, "GLS" },
>> + { NCSI_PKT_CMD_SVF, "SVF" },
>> + { NCSI_PKT_CMD_EV, "EV" },
>> + { NCSI_PKT_CMD_DV, "DV" },
>> + { NCSI_PKT_CMD_SMA, "SMA" },
>> + { NCSI_PKT_CMD_EBF, "EBF" },
>> + { NCSI_PKT_CMD_DBF, "DBF" },
>> + { NCSI_PKT_CMD_EGMF, "EGMF" },
>> + { NCSI_PKT_CMD_DGMF, "DGMF" },
>> + { NCSI_PKT_CMD_SNFC, "SNFC" },
>> + { NCSI_PKT_CMD_GVI, "GVI" },
>> + { NCSI_PKT_CMD_GC, "GC" },
>> + { NCSI_PKT_CMD_GP, "GP" },
>> + { NCSI_PKT_CMD_GCPS, "GCPS" },
>> + { NCSI_PKT_CMD_GNS, "GNS" },
>> + { NCSI_PKT_CMD_GNPTS, "GNPTS" },
>> + { NCSI_PKT_CMD_GPS, "GPS" },
>> + { NCSI_PKT_CMD_OEM, "OEM" },
>> + { NCSI_PKT_CMD_PLDM, "PLDM" },
>> + { NCSI_PKT_CMD_GPUUID, "GPUUID" },
>
>I don't know how common these are and how
>intelligible these acronyms are to knowledgeable
>developer/users, but maybe it'd be better to
>spell out what these are instead of having to
>look up what the acronyms stand for
>
> CIS - Clear Initial State
> SP - Select Package
> etc...
>
>Maybe copy the descriptions from the ncsi-pkt.h file
>
Joe, good question. As these decriptive strings are part of
the output from ncsi/eth0/stats and input to ncsi/eth0/pkt,
I intended to keep them short enough. Also, this debugging
interface would service developers who knows NCSI protocol
and perhaps know the meanings of these acronyms.
Thanks,
Gavin
>#define NCSI_PKT_CMD_CIS 0x00 /* Clear Initial State */
>#define NCSI_PKT_CMD_SP 0x01 /* Select Package */
>#define NCSI_PKT_CMD_DP 0x02 /* Deselect Package */
>#define NCSI_PKT_CMD_EC 0x03 /* Enable Channel */
>#define NCSI_PKT_CMD_DC 0x04 /* Disable Channel */
>#define NCSI_PKT_CMD_RC 0x05 /* Reset Channel */
>#define NCSI_PKT_CMD_ECNT 0x06 /* Enable Channel Network Tx */
>#define NCSI_PKT_CMD_DCNT 0x07 /* Disable Channel Network Tx */
>#define NCSI_PKT_CMD_AE 0x08 /* AEN Enable */
>#define NCSI_PKT_CMD_SL 0x09 /* Set Link */
>#define NCSI_PKT_CMD_GLS 0x0a /* Get Link */
>#define NCSI_PKT_CMD_SVF 0x0b /* Set VLAN Filter */
>#define NCSI_PKT_CMD_EV 0x0c /* Enable VLAN */
>#define NCSI_PKT_CMD_DV 0x0d /* Disable VLAN */
>#define NCSI_PKT_CMD_SMA 0x0e /* Set MAC address */
>#define NCSI_PKT_CMD_EBF 0x10 /* Enable Broadcast Filter */
>#define NCSI_PKT_CMD_DBF 0x11 /* Disable Broadcast Filter */
>#define NCSI_PKT_CMD_EGMF 0x12 /* Enable Global Multicast Filter */
>#define NCSI_PKT_CMD_DGMF 0x13 /* Disable Global Multicast Filter */
>#define NCSI_PKT_CMD_SNFC 0x14 /* Set NCSI Flow Control */
>#define NCSI_PKT_CMD_GVI 0x15 /* Get Version ID */
>#define NCSI_PKT_CMD_GC 0x16 /* Get Capabilities */
>#define NCSI_PKT_CMD_GP 0x17 /* Get Parameters */
>#define NCSI_PKT_CMD_GCPS 0x18 /* Get Controller Packet Statistics */
>#define NCSI_PKT_CMD_GNS 0x19 /* Get NCSI Statistics */
>#define NCSI_PKT_CMD_GNPTS 0x1a /* Get NCSI Pass-throu Statistics */
>#define NCSI_PKT_CMD_GPS 0x1b /* Get package status */
>#define NCSI_PKT_CMD_OEM 0x50 /* OEM */
>#define NCSI_PKT_CMD_PLDM 0x51 /* PLDM request over NCSI over RBT */
>#define NCSI_PKT_CMD_GPUUID 0x52 /* Get package UUID */
>
^ permalink raw reply
* linux-next: manual merge of the net-next tree with the net tree
From: Stephen Rothwell @ 2017-04-18 0:18 UTC (permalink / raw)
To: David Miller, Networking
Cc: Linux-Next Mailing List, Linux Kernel Mailing List,
Daniel Borkmann, Alexei Starovoitov
Hi all,
Today's linux-next merge of the net-next tree got a conflict in:
kernel/bpf/syscall.c
between commits:
6b1bb01bcc5b ("bpf: fix cb access in socket filter programs on tail calls")
c2002f983767 ("bpf: fix checking xdp_adjust_head on tail calls")
from the net tree and commit:
e245c5c6a565 ("bpf: move fixup_bpf_calls() function")
79741b3bdec0 ("bpf: refactor fixup_bpf_calls()")
from the net-next tree.
I fixed it up (the latter moved and changed teh code modified by the
former - I added the following fix up patch) and can carry the fix as
necessary. This is now fixed as far as linux-next is concerned, but any
non trivial conflicts should be mentioned to your upstream maintainer
when your tree is submitted for merging. You may also want to consider
cooperating with the maintainer of the conflicting tree to minimise any
particularly complex conflicts.
From: Stephen Rothwell <sfr@canb.auug.org.au>
Date: Tue, 18 Apr 2017 10:16:03 +1000
Subject: [PATCH] bpf: merge fix for move of fixup_bpf_calls()
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
---
kernel/bpf/verifier.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 62e1e447ded9..5939b4c81fe1 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -3349,6 +3349,14 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env)
if (insn->imm == BPF_FUNC_xdp_adjust_head)
prog->xdp_adjust_head = 1;
if (insn->imm == BPF_FUNC_tail_call) {
+ /* If we tail call into other programs, we
+ * cannot make any assumptions since they
+ * can be replaced dynamically during runtime
+ * in the program array.
+ */
+ prog->cb_access = 1;
+ prog->xdp_adjust_head = 1;
+
/* mark bpf_tail_call as different opcode to avoid
* conditional branch in the interpeter for every normal
* call and to prevent accidental JITing by JIT compiler
--
2.11.0
--
Cheers,
Stephen Rothwell
^ permalink raw reply related
* Re: [PATCH v2 net-next 5/8] net/ncsi: Dump NCSI packet statistics
From: Gavin Shan @ 2017-04-18 0:14 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: Gavin Shan, netdev, joe, davem
In-Reply-To: <20170413185042.0e69cb71@cakuba.lan>
On Thu, Apr 13, 2017 at 06:50:42PM -0700, Jakub Kicinski wrote:
>On Thu, 13 Apr 2017 17:48:18 +1000, Gavin Shan wrote:
>> This creates /sys/kernel/debug/ncsi/<eth0>/stats to dump the NCSI
>> packets sent and received over all packages and channels. It's useful
>> to diagnose NCSI problems, especially when NCSI packages and channels
>> aren't probed properly. The statistics can be gained from debugfs file
>> as below:
>>
>> # cat /sys/kernel/debug/ncsi/eth0/stats
>>
>> CMD OK TIMEOUT ERROR
>> =======================================
>> CIS 32 29 0
>> SP 10 7 0
>> DP 17 14 0
>> EC 1 0 0
>> ECNT 1 0 0
>> AE 1 0 0
>> GLS 11 0 0
>> SMA 1 0 0
>> EBF 1 0 0
>> GVI 2 0 0
>> GC 2 0 0
>>
>> RSP OK TIMEOUT ERROR
>> =======================================
>> CIS 3 0 0
>> SP 3 0 0
>> DP 2 0 1
>> EC 1 0 0
>> ECNT 1 0 0
>> AE 1 0 0
>> GLS 11 0 0
>> SMA 1 0 0
>> EBF 1 0 0
>> GVI 0 0 2
>> GC 2 0 0
>>
>> AEN OK TIMEOUT ERROR
>> =======================================
>>
>> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
>
>I'm not familiar with NC-SI but these look like some standard stats.
>Would it make sense to provide a proper netlink API for them?
>
>[...]
>> +#ifdef CONFIG_NET_NCSI_DEBUG
>> + ndp->stats.aen[h->type][NCSI_PKT_STAT_ERROR]++;
>> +#endif
>
>In any case, did you consider creating a macro or inline helper to
>limit the number of #ifdefs?
>
Jakub, thanks for the comments. NCSI does have standard statistics
about the packets passed to peer (NIC) or NCSI packets handled by
hardware. I have some patches (not posted yet and won't post in
this merge window) to create debugfs file ncsi/eth0/p0/c0/stats
and dump them there.
This debugfs tracks NCSI packets sent and received by software
in order to see if the software has obvious bugs.
Yeah, it's definitely worthy to eliminate the #ifdef's. I'll do
in next respin.
Thanks,
Gavin
^ permalink raw reply
* Re: [PATCH] net/ncsi: fix checksum validation in response packet
From: Gavin Shan @ 2017-04-18 0:06 UTC (permalink / raw)
To: David Miller; +Cc: clg, gwshan, joel, netdev, linux-kernel
In-Reply-To: <20170417.133619.1515025171498720534.davem@davemloft.net>
On Mon, Apr 17, 2017 at 01:36:19PM -0400, David Miller wrote:
>From: Cédric Le Goater <clg@kaod.org>
>Date: Fri, 14 Apr 2017 10:56:37 +0200
>
>> htonl was used instead of ntohl. Surely a typo.
>>
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>
>I don't think so, "checksum" is of type "u32" thus is in host byte
>order. Therefore "htonl()" is correct.
>
Yeah, "htonl()" is correct here. "*pchecksum" is in big-endian.
I want to know how Cédric thinks it's a problem. I guess he might
encounter the issue on the emulated NCSI channel by QEMU. On BCM5718
or BCM5719, the checksum in AEN and response packet are zero'd, meaning
the software shouldn't validate it at all.
Thanks,
Gavin
^ permalink raw reply
* RE: [PATCH net-next v2] net: ipv6: Fix UDP early demux lookup with udp_l3mdev_accept=0
From: YUAN Linyu @ 2017-04-17 23:51 UTC (permalink / raw)
To: Subash Abhinov Kasiviswanathan, dsa@cumulusnetworks.com,
davem@davemloft.net, netdev@vger.kernel.org, rshearma@brocade.com,
eric.dumazet@gmail.com
Cc: Eric Dumazet
In-Reply-To: <1492471495-13073-1-git-send-email-subashab@codeaurora.org>
> -----Original Message-----
> From: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org]
> On Behalf Of Subash Abhinov Kasiviswanathan
> Sent: Tuesday, April 18, 2017 7:25 AM
> To: dsa@cumulusnetworks.com; davem@davemloft.net;
> netdev@vger.kernel.org; rshearma@brocade.com; eric.dumazet@gmail.com
> Cc: Subash Abhinov Kasiviswanathan; Eric Dumazet
> Subject: [PATCH net-next v2] net: ipv6: Fix UDP early demux lookup with
> udp_l3mdev_accept=0
>
> - return sk;
> + udp_portaddr_for_each_entry_rcu(sk, &hslot2->head) {
> + if (INET6_MATCH(sk, net, rmt_addr, loc_addr, ports, dif))
> + return sk;
> + break;
I think break here should remove ?
> + }
> + return NULL;
> }
> --
> 1.9.1
^ permalink raw reply
* [PATCH v2 net-next] drivers: net: xgene-v2: Extend ethtool statistics
From: Iyappan Subramanian @ 2017-04-17 23:47 UTC (permalink / raw)
To: davem, netdev; +Cc: kchudgar, patches, linux-arm-kernel, Iyappan Subramanian
This patch adds extended statistics reporting to ethtool.
In summary, this patch,
- adds ethtool.h with the statistics register definitions
- adds 'struct xge_gstrings_extd_stats' to gather extended stats
- modifies xge_get_strings(), get_sset_count() and
get_ethtool_stats() accordingly
- moves 'struct xge_gstrings_stats' to ethtool.h
Signed-off-by: Iyappan Subramanian <isubramanian@apm.com>
---
v2: Address review comments from v1
- removed duplicate statistics counters that were reported by
xge_get_stats64()
v1:
- Initial version
---
drivers/net/ethernet/apm/xgene-v2/ethtool.c | 78 ++++++++++++++++++++++++++---
drivers/net/ethernet/apm/xgene-v2/ethtool.h | 78 +++++++++++++++++++++++++++++
drivers/net/ethernet/apm/xgene-v2/mac.h | 3 --
drivers/net/ethernet/apm/xgene-v2/main.h | 2 +-
4 files changed, 151 insertions(+), 10 deletions(-)
create mode 100644 drivers/net/ethernet/apm/xgene-v2/ethtool.h
diff --git a/drivers/net/ethernet/apm/xgene-v2/ethtool.c b/drivers/net/ethernet/apm/xgene-v2/ethtool.c
index 0c426f5..b6666e4 100644
--- a/drivers/net/ethernet/apm/xgene-v2/ethtool.c
+++ b/drivers/net/ethernet/apm/xgene-v2/ethtool.c
@@ -21,12 +21,13 @@
#include "main.h"
-struct xge_gstrings_stats {
- char name[ETH_GSTRING_LEN];
- int offset;
-};
-
#define XGE_STAT(m) { #m, offsetof(struct xge_pdata, stats.m) }
+#define XGE_EXTD_STAT(m, n) \
+ { \
+ #m, \
+ n, \
+ 0 \
+ }
static const struct xge_gstrings_stats gstrings_stats[] = {
XGE_STAT(rx_packets),
@@ -36,7 +37,62 @@ struct xge_gstrings_stats {
XGE_STAT(rx_errors)
};
+static struct xge_gstrings_extd_stats gstrings_extd_stats[] = {
+ XGE_EXTD_STAT(tx_rx_64b_frame_cntr, TR64),
+ XGE_EXTD_STAT(tx_rx_127b_frame_cntr, TR127),
+ XGE_EXTD_STAT(tx_rx_255b_frame_cntr, TR255),
+ XGE_EXTD_STAT(tx_rx_511b_frame_cntr, TR511),
+ XGE_EXTD_STAT(tx_rx_1023b_frame_cntr, TR1K),
+ XGE_EXTD_STAT(tx_rx_1518b_frame_cntr, TRMAX),
+ XGE_EXTD_STAT(tx_rx_1522b_frame_cntr, TRMGV),
+ XGE_EXTD_STAT(rx_fcs_error_cntr, RFCS),
+ XGE_EXTD_STAT(rx_multicast_pkt_cntr, RMCA),
+ XGE_EXTD_STAT(rx_broadcast_pkt_cntr, RBCA),
+ XGE_EXTD_STAT(rx_ctrl_frame_pkt_cntr, RXCF),
+ XGE_EXTD_STAT(rx_pause_frame_pkt_cntr, RXPF),
+ XGE_EXTD_STAT(rx_unk_opcode_cntr, RXUO),
+ XGE_EXTD_STAT(rx_align_err_cntr, RALN),
+ XGE_EXTD_STAT(rx_frame_len_err_cntr, RFLR),
+ XGE_EXTD_STAT(rx_code_err_cntr, RCDE),
+ XGE_EXTD_STAT(rx_carrier_sense_err_cntr, RCSE),
+ XGE_EXTD_STAT(rx_undersize_pkt_cntr, RUND),
+ XGE_EXTD_STAT(rx_oversize_pkt_cntr, ROVR),
+ XGE_EXTD_STAT(rx_fragments_cntr, RFRG),
+ XGE_EXTD_STAT(rx_jabber_cntr, RJBR),
+ XGE_EXTD_STAT(rx_dropped_pkt_cntr, RDRP),
+ XGE_EXTD_STAT(tx_multicast_pkt_cntr, TMCA),
+ XGE_EXTD_STAT(tx_broadcast_pkt_cntr, TBCA),
+ XGE_EXTD_STAT(tx_pause_ctrl_frame_cntr, TXPF),
+ XGE_EXTD_STAT(tx_defer_pkt_cntr, TDFR),
+ XGE_EXTD_STAT(tx_excv_defer_pkt_cntr, TEDF),
+ XGE_EXTD_STAT(tx_single_col_pkt_cntr, TSCL),
+ XGE_EXTD_STAT(tx_multi_col_pkt_cntr, TMCL),
+ XGE_EXTD_STAT(tx_late_col_pkt_cntr, TLCL),
+ XGE_EXTD_STAT(tx_excv_col_pkt_cntr, TXCL),
+ XGE_EXTD_STAT(tx_total_col_cntr, TNCL),
+ XGE_EXTD_STAT(tx_pause_frames_hnrd_cntr, TPFH),
+ XGE_EXTD_STAT(tx_drop_frame_cntr, TDRP),
+ XGE_EXTD_STAT(tx_jabber_frame_cntr, TJBR),
+ XGE_EXTD_STAT(tx_fcs_error_cntr, TFCS),
+ XGE_EXTD_STAT(tx_ctrl_frame_cntr, TXCF),
+ XGE_EXTD_STAT(tx_oversize_frame_cntr, TOVR),
+ XGE_EXTD_STAT(tx_undersize_frame_cntr, TUND),
+ XGE_EXTD_STAT(tx_fragments_cntr, TFRG)
+};
+
#define XGE_STATS_LEN ARRAY_SIZE(gstrings_stats)
+#define XGE_EXTD_STATS_LEN ARRAY_SIZE(gstrings_extd_stats)
+
+static void xge_mac_get_extd_stats(struct xge_pdata *pdata)
+{
+ u32 data;
+ int i;
+
+ for (i = 0; i < XGE_EXTD_STATS_LEN; i++) {
+ data = xge_rd_csr(pdata, gstrings_extd_stats[i].addr);
+ gstrings_extd_stats[i].value += data;
+ }
+}
static void xge_get_drvinfo(struct net_device *ndev,
struct ethtool_drvinfo *info)
@@ -62,6 +118,11 @@ static void xge_get_strings(struct net_device *ndev, u32 stringset, u8 *data)
memcpy(p, gstrings_stats[i].name, ETH_GSTRING_LEN);
p += ETH_GSTRING_LEN;
}
+
+ for (i = 0; i < XGE_EXTD_STATS_LEN; i++) {
+ memcpy(p, gstrings_extd_stats[i].name, ETH_GSTRING_LEN);
+ p += ETH_GSTRING_LEN;
+ }
}
static int xge_get_sset_count(struct net_device *ndev, int sset)
@@ -69,7 +130,7 @@ static int xge_get_sset_count(struct net_device *ndev, int sset)
if (sset != ETH_SS_STATS)
return -EINVAL;
- return XGE_STATS_LEN;
+ return XGE_STATS_LEN + XGE_EXTD_STATS_LEN;
}
static void xge_get_ethtool_stats(struct net_device *ndev,
@@ -81,6 +142,11 @@ static void xge_get_ethtool_stats(struct net_device *ndev,
for (i = 0; i < XGE_STATS_LEN; i++)
*data++ = *(u64 *)(pdata + gstrings_stats[i].offset);
+
+ xge_mac_get_extd_stats(pdata);
+
+ for (i = 0; i < XGE_EXTD_STATS_LEN; i++)
+ *data++ = gstrings_extd_stats[i].value;
}
static int xge_get_link_ksettings(struct net_device *ndev,
diff --git a/drivers/net/ethernet/apm/xgene-v2/ethtool.h b/drivers/net/ethernet/apm/xgene-v2/ethtool.h
new file mode 100644
index 0000000..54b48d5
--- /dev/null
+++ b/drivers/net/ethernet/apm/xgene-v2/ethtool.h
@@ -0,0 +1,78 @@
+/*
+ * Applied Micro X-Gene SoC Ethernet v2 Driver
+ *
+ * Copyright (c) 2017, Applied Micro Circuits Corporation
+ * Author(s): Iyappan Subramanian <isubramanian@apm.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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __XGENE_ENET_V2_ETHTOOL_H__
+#define __XGENE_ENET_V2_ETHTOOL_H__
+
+struct xge_gstrings_stats {
+ char name[ETH_GSTRING_LEN];
+ int offset;
+};
+
+struct xge_gstrings_extd_stats {
+ char name[ETH_GSTRING_LEN];
+ u32 addr;
+ u32 value;
+};
+
+#define TR64 0xa080
+#define TR127 0xa084
+#define TR255 0xa088
+#define TR511 0xa08c
+#define TR1K 0xa090
+#define TRMAX 0xa094
+#define TRMGV 0xa098
+#define RFCS 0xa0a4
+#define RMCA 0xa0a8
+#define RBCA 0xa0ac
+#define RXCF 0xa0b0
+#define RXPF 0xa0b4
+#define RXUO 0xa0b8
+#define RALN 0xa0bc
+#define RFLR 0xa0c0
+#define RCDE 0xa0c4
+#define RCSE 0xa0c8
+#define RUND 0xa0cc
+#define ROVR 0xa0d0
+#define RFRG 0xa0d4
+#define RJBR 0xa0d8
+#define RDRP 0xa0dc
+#define TMCA 0xa0e8
+#define TBCA 0xa0ec
+#define TXPF 0xa0f0
+#define TDFR 0xa0f4
+#define TEDF 0xa0f8
+#define TSCL 0xa0fc
+#define TMCL 0xa100
+#define TLCL 0xa104
+#define TXCL 0xa108
+#define TNCL 0xa10c
+#define TPFH 0xa110
+#define TDRP 0xa114
+#define TJBR 0xa118
+#define TFCS 0xa11c
+#define TXCF 0xa120
+#define TOVR 0xa124
+#define TUND 0xa128
+#define TFRG 0xa12c
+
+void xge_set_ethtool_ops(struct net_device *ndev);
+
+#endif /* __XGENE_ENET_V2_ETHTOOL_H__ */
diff --git a/drivers/net/ethernet/apm/xgene-v2/mac.h b/drivers/net/ethernet/apm/xgene-v2/mac.h
index 18a9c9d..3c83fa6 100644
--- a/drivers/net/ethernet/apm/xgene-v2/mac.h
+++ b/drivers/net/ethernet/apm/xgene-v2/mac.h
@@ -34,9 +34,6 @@
#define INTERFACE_CONTROL 0xa038
#define STATION_ADDR0 0xa040
#define STATION_ADDR1 0xa044
-#define RBYT 0xa09c
-#define RPKT 0xa0a0
-#define RFCS 0xa0a4
#define RGMII_REG_0 0x27e0
#define ICM_CONFIG0_REG_0 0x2c00
diff --git a/drivers/net/ethernet/apm/xgene-v2/main.h b/drivers/net/ethernet/apm/xgene-v2/main.h
index db1178e..969b258 100644
--- a/drivers/net/ethernet/apm/xgene-v2/main.h
+++ b/drivers/net/ethernet/apm/xgene-v2/main.h
@@ -38,6 +38,7 @@
#include "mac.h"
#include "enet.h"
#include "ring.h"
+#include "ethtool.h"
#define XGENE_ENET_V2_VERSION "v1.0"
#define XGENE_ENET_STD_MTU 1536
@@ -75,6 +76,5 @@ struct xge_pdata {
int xge_mdio_config(struct net_device *ndev);
void xge_mdio_remove(struct net_device *ndev);
-void xge_set_ethtool_ops(struct net_device *ndev);
#endif /* __XGENE_ENET_V2_MAIN_H__ */
--
1.9.1
^ permalink raw reply related
* Re: [PATCH v3 net-next RFC] Generic XDP
From: Daniel Borkmann @ 2017-04-17 23:33 UTC (permalink / raw)
To: Alexei Starovoitov, David Miller; +Cc: brouer, kubakici, netdev, xdp-newbies
In-Reply-To: <20170417230436.GA96258@ast-mbp.thefacebook.com>
On 04/18/2017 01:04 AM, Alexei Starovoitov wrote:
> On Mon, Apr 17, 2017 at 03:49:55PM -0400, David Miller wrote:
>> From: Jesper Dangaard Brouer <brouer@redhat.com>
>> Date: Sun, 16 Apr 2017 22:26:01 +0200
>>
>>> The bpf tail-call use-case is a very good example of why the
>>> verifier cannot deduct the needed HEADROOM upfront.
>>
>> This brings up a very interesting question for me.
>>
>> I notice that tail calls are implemented by JITs largely by skipping
>> over the prologue of that destination program.
>>
>> However, many JITs preload cached SKB values into fixed registers in
>> the prologue. But they only do this if the program being JITed needs
>> those values.
>>
>> So how can it work properly if a program that does not need the SKB
>> values tail calls into one that does?
>
> For x86 JIT it's fine, since caching of skb values is not part of the prologue:
> emit_prologue(&prog);
> if (seen_ld_abs)
> emit_load_skb_data_hlen(&prog);
> and tail_call jumps into the next program as:
> EMIT4(0x48, 0x83, 0xC0, PROLOGUE_SIZE); /* add rax, prologue_size */
> EMIT2(0xFF, 0xE0); /* jmp rax */
> whereas inside emit_prologue() we have:
> B UILD_BUG_ON(cnt != PROLOGUE_SIZE);
>
> arm64 has similar proplogue skipping code and it's even
> simpler than x86, since it doesn't try to optimize LD_ABS/IND in assembler
> and instead calls into bpf_load_pointer() from generated code,
> so no caching of skb values at all.
>
> s390 jit has partial skipping of prologue, since bunch
> of registers are save/restored during tail_call and it looks fine
> to me as well.
And ppc64 does unwinding/tearing down the stack of the prog before
jumping into the other program. Thus, no skipping of others prologue;
looks fine, too.
> It's very hard to extend test_bpf.ko with tail_calls, since maps need
> to be allocated and populated with file descriptors which are
> not feasible to do from .ko. Instead we need a user space based test for it.
> We've started building one in tools/testing/selftests/bpf/test_progs.c
> much more tests need to be added. Thorough testing of tail_calls
> is on the todo list.
^ permalink raw reply
* Re: [PATCH RFC] sparc64: eBPF JIT
From: Alexei Starovoitov @ 2017-04-17 23:27 UTC (permalink / raw)
To: David Miller; +Cc: sparclinux, netdev, ast, daniel
In-Reply-To: <20170416.233825.1748421481008153466.davem@davemloft.net>
On Sun, Apr 16, 2017 at 11:38:25PM -0400, David Miller wrote:
>
> There are a bunch of things I want to do still, and I know that I have
> to attend to sparc32 more cleanly, but I wanted to post this now that
> I have it passing the BPF testsuite completely:
>
> [24174.315421] test_bpf: Summary: 305 PASSED, 0 FAILED, [297/297 JIT'ed]
Nice!
> +static void build_prologue(struct jit_ctx *ctx)
> +{
> + s32 stack_needed = 176;
> +
> + if (ctx->saw_frame_pointer)
> + stack_needed += MAX_BPF_STACK;
> +
> + /* save %sp, -176, %sp */
> + emit(SAVE | IMMED | RS1(SP) | S13(-stack_needed) | RD(SP), ctx);
> +
> + if (ctx->saw_ld_abs_ind) {
> + load_skb_regs(ctx, bpf2sparc[BPF_REG_1]);
> + } else {
> + emit_nop(ctx);
> + emit_nop(ctx);
> + emit_nop(ctx);
> + emit_nop(ctx);
why 4 nops? to keep prologue size constant w/ and w/o caching ?
does it help somehow? I'm assuming that's prep for next step
of tail_call.
> + if (insn->src_reg == BPF_REG_FP || insn->dst_reg == BPF_REG_FP) {
> + ctx->saw_frame_pointer = true;
> + if (BPF_CLASS(code) == BPF_ALU ||
> + BPF_CLASS(code) == BPF_ALU64) {
> + pr_err_once("ALU op on FP not supported by JIT\n");
> + return -EINVAL;
That should be fine. The verifier checks for that:
/* check whether register used as dest operand can be written to */
if (regno == BPF_REG_FP) {
verbose("frame pointer is read only\n");
return -EACCES;
}
> + /* dst = imm64 */
> + case BPF_LD | BPF_IMM | BPF_DW:
> + {
> + const struct bpf_insn insn1 = insn[1];
> + u64 imm64;
> +
> + if (insn1.code != 0 || insn1.src_reg != 0 ||
> + insn1.dst_reg != 0 || insn1.off != 0) {
> + /* Note: verifier in BPF core must catch invalid
> + * instructions.
> + */
> + pr_err_once("Invalid BPF_LD_IMM64 instruction\n");
> + return -EINVAL;
verifier should catch that too, but extra check doesn't hurt.
> + /* STX XADD: lock *(u32 *)(dst + off) += src */
> + case BPF_STX | BPF_XADD | BPF_W: {
> + const u8 tmp = bpf2sparc[TMP_REG_1];
> + const u8 tmp2 = bpf2sparc[TMP_REG_2];
> + const u8 tmp3 = bpf2sparc[TMP_REG_3];
> + s32 real_off = off;
> +
> + ctx->tmp_1_used = true;
> + ctx->tmp_2_used = true;
> + ctx->tmp_3_used = true;
> + if (dst == FP)
> + real_off += STACK_BIAS;
> + emit_loadimm(real_off, tmp, ctx);
> + emit_alu3(ADD, dst, tmp, tmp, ctx);
> +
> + emit(LD32 | RS1(tmp) | RS2(G0) | RD(tmp2), ctx);
> + emit_alu3(ADD, tmp2, src, tmp3, ctx);
> + emit(CAS | ASI(ASI_P) | RS1(tmp) | RS2(tmp2) | RD(tmp3), ctx);
> + emit_cmp(tmp2, tmp3, ctx);
> + emit_branch(BNE, 4, 0, ctx);
> + emit_nop(ctx);
loops in bpf code! run for your life ;)
> + if (bpf_jit_enable > 1)
> + bpf_jit_dump(prog->len, image_size, 2, ctx.image);
> + bpf_flush_icache(ctx.image, ctx.image + image_size);
> +
> + bpf_jit_binary_lock_ro(header);
all looks great to me.
Thanks!
^ permalink raw reply
* [PATCH net-next v2] net: ipv6: Fix UDP early demux lookup with udp_l3mdev_accept=0
From: Subash Abhinov Kasiviswanathan @ 2017-04-17 23:24 UTC (permalink / raw)
To: dsa, davem, netdev, rshearma, eric.dumazet
Cc: Subash Abhinov Kasiviswanathan, Eric Dumazet
David Ahern reported that 5425077d73e0c ("net: ipv6: Add early demux
handler for UDP unicast") breaks udp_l3mdev_accept=0 since early
demux for IPv6 UDP was doing a generic socket lookup which does not
require an exact match. Fix this by making UDPv6 early demux match
connected sockets only.
v1->v2: Take reference to socket after match as suggested by Eric
Fixes: 5425077d73e0c ("net: ipv6: Add early demux handler for UDP unicast")
Reported-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
Cc: Eric Dumazet <edumazet@google.com>
---
net/ipv6/udp.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index b793ed1..5a4504b 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -46,6 +46,7 @@
#include <net/tcp_states.h>
#include <net/ip6_checksum.h>
#include <net/xfrm.h>
+#include <net/inet_hashtables.h>
#include <net/inet6_hashtables.h>
#include <net/busy_poll.h>
#include <net/sock_reuseport.h>
@@ -864,21 +865,25 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
return 0;
}
+
static struct sock *__udp6_lib_demux_lookup(struct net *net,
__be16 loc_port, const struct in6_addr *loc_addr,
__be16 rmt_port, const struct in6_addr *rmt_addr,
int dif)
{
+ unsigned short hnum = ntohs(loc_port);
+ unsigned int hash2 = udp6_portaddr_hash(net, loc_addr, hnum);
+ unsigned int slot2 = hash2 & udp_table.mask;
+ struct udp_hslot *hslot2 = &udp_table.hash2[slot2];
+ const __portpair ports = INET_COMBINED_PORTS(rmt_port, hnum);
struct sock *sk;
- rcu_read_lock();
- sk = __udp6_lib_lookup(net, rmt_addr, rmt_port, loc_addr, loc_port,
- dif, &udp_table, NULL);
- if (sk && !atomic_inc_not_zero(&sk->sk_refcnt))
- sk = NULL;
- rcu_read_unlock();
-
- return sk;
+ udp_portaddr_for_each_entry_rcu(sk, &hslot2->head) {
+ if (INET6_MATCH(sk, net, rmt_addr, loc_addr, ports, dif))
+ return sk;
+ break;
+ }
+ return NULL;
}
static void udp_v6_early_demux(struct sk_buff *skb)
@@ -903,7 +908,7 @@ static void udp_v6_early_demux(struct sk_buff *skb)
else
return;
- if (!sk)
+ if (!sk || !atomic_inc_not_zero_hint(&sk->sk_refcnt, 2))
return;
skb->sk = sk;
--
1.9.1
^ permalink raw reply related
* Re: [PATCH v2 net-next 5/8] net/ncsi: Dump NCSI packet statistics
From: Gavin Shan @ 2017-04-17 23:23 UTC (permalink / raw)
To: Joe Perches; +Cc: Gavin Shan, netdev, davem
In-Reply-To: <1492080640.28586.15.camel@perches.com>
On Thu, Apr 13, 2017 at 03:50:40AM -0700, Joe Perches wrote:
>On Thu, 2017-04-13 at 17:48 +1000, Gavin Shan wrote:
>> This creates /sys/kernel/debug/ncsi/<eth0>/stats to dump the NCSI
>> packets sent and received over all packages and channels. It's useful
>> to diagnose NCSI problems, especially when NCSI packages and channels
>> aren't probed properly.
>
>trivia:
>
>> diff --git a/net/ncsi/ncsi-debug.c b/net/ncsi/ncsi-debug.c
>> index 6c00e9b..29c233c 100644
>> --- a/net/ncsi/ncsi-debug.c
>> +++ b/net/ncsi/ncsi-debug.c
>> @@ -23,6 +23,235 @@
>> #include "ncsi-pkt.h"
>>
>> static struct dentry *ncsi_dentry;
>> +static struct ncsi_pkt_handler {
>
>static const struct etc...
>
Yes.
>> + unsigned char type;
>> + const char *name;
>> +} ncsi_pkt_handlers[] = {
>> + { NCSI_PKT_CMD_CIS, "CIS" },
>[]
>> +static bool ncsi_dev_stats_index(struct ncsi_dev_priv *ndp, loff_t pos,
>> + unsigned long *type, unsigned long *index,
>> + unsigned long *entries)
>> +{
>> + int i;
>> + unsigned long ranges[3][2] = {
>> + { 1,
>> + ARRAY_SIZE(ndp->stats.cmd) - 1 },
>> + { ranges[0][1] + 2,
>> + ranges[1][0] + ARRAY_SIZE(ndp->stats.rsp) - 1 },
>> + { ranges[1][1] + 2,
>> + ranges[2][0] + ARRAY_SIZE(ndp->stats.aen) - 1 }
>> + };
>
>const?
>
Yes. I will modify in next respin.
Thanks,
Gavin
^ permalink raw reply
* Re: [PATCH v2 net-next 4/8] net/ncsi: Add debugging infrastructurre
From: Gavin Shan @ 2017-04-17 23:22 UTC (permalink / raw)
To: Joe Perches; +Cc: Gavin Shan, netdev, davem
In-Reply-To: <1492080106.28586.13.camel@perches.com>
On Thu, Apr 13, 2017 at 03:41:46AM -0700, Joe Perches wrote:
>On Thu, 2017-04-13 at 17:48 +1000, Gavin Shan wrote:
>> This creates debugfs directories as NCSI debugging infrastructure.
>> With the patch applied, We will see below debugfs directories. Every
>> NCSI package and channel has one corresponding directory. Other than
>> presenting the NCSI topology, No real function has been achieved
>> through these debugfs directories so far.
>>
>> /sys/kernel/debug/ncsi/eth0
>> /sys/kernel/debug/ncsi/eth0/p0
>> /sys/kernel/debug/ncsi/eth0/p0/c0
>> /sys/kernel/debug/ncsi/eth0/p0/c1
>
>[]
>
>> diff --git a/net/ncsi/ncsi-debug.c b/net/ncsi/ncsi-debug.c
>[]
>> +int ncsi_dev_init_debug(struct ncsi_dev_priv *ndp)
>> +{
>> + if (WARN_ON_ONCE(ndp->dentry))
>> + return 0;
>> +
>> + if (!ncsi_dentry) {
>> + ncsi_dentry = debugfs_create_dir("ncsi", NULL);
>> + if (!ncsi_dentry) {
>> + pr_warn("NCSI: Cannot create /sys/kernel/debug/ncsi\n");
>> + return -ENOENT;
>
>debugfs does not have a fixed path.
>
>Most error messages for this just use something like
> pr_<level>("Failed to create debugfs directory '%s'\n", foo)
>And most failures don't emit any error message at all.
>
Thanks, Joe. I will correct in next respin.
Thanks,
Gavin
^ permalink raw reply
* Re: [PATCH v3 net-next RFC] Generic XDP
From: Alexei Starovoitov @ 2017-04-17 23:04 UTC (permalink / raw)
To: David Miller; +Cc: brouer, kubakici, netdev, xdp-newbies
In-Reply-To: <20170417.154955.1624611510140672627.davem@davemloft.net>
On Mon, Apr 17, 2017 at 03:49:55PM -0400, David Miller wrote:
> From: Jesper Dangaard Brouer <brouer@redhat.com>
> Date: Sun, 16 Apr 2017 22:26:01 +0200
>
> > The bpf tail-call use-case is a very good example of why the
> > verifier cannot deduct the needed HEADROOM upfront.
>
> This brings up a very interesting question for me.
>
> I notice that tail calls are implemented by JITs largely by skipping
> over the prologue of that destination program.
>
> However, many JITs preload cached SKB values into fixed registers in
> the prologue. But they only do this if the program being JITed needs
> those values.
>
> So how can it work properly if a program that does not need the SKB
> values tail calls into one that does?
For x86 JIT it's fine, since caching of skb values is not part of the prologue:
emit_prologue(&prog);
if (seen_ld_abs)
emit_load_skb_data_hlen(&prog);
and tail_call jumps into the next program as:
EMIT4(0x48, 0x83, 0xC0, PROLOGUE_SIZE); /* add rax, prologue_size */
EMIT2(0xFF, 0xE0); /* jmp rax */
whereas inside emit_prologue() we have:
B UILD_BUG_ON(cnt != PROLOGUE_SIZE);
arm64 has similar proplogue skipping code and it's even
simpler than x86, since it doesn't try to optimize LD_ABS/IND in assembler
and instead calls into bpf_load_pointer() from generated code,
so no caching of skb values at all.
s390 jit has partial skipping of prologue, since bunch
of registers are save/restored during tail_call and it looks fine
to me as well.
It's very hard to extend test_bpf.ko with tail_calls, since maps need
to be allocated and populated with file descriptors which are
not feasible to do from .ko. Instead we need a user space based test for it.
We've started building one in tools/testing/selftests/bpf/test_progs.c
much more tests need to be added. Thorough testing of tail_calls
is on the todo list.
^ permalink raw reply
* [PATCH] nl80211: Fix enum type of variable in nl80211_put_sta_rate()
From: Matthias Kaehlcke @ 2017-04-17 22:59 UTC (permalink / raw)
To: Johannes Berg, David S . Miller, Simon Wunderlich
Cc: linux-wireless, netdev, linux-kernel, Grant Grundler,
Greg Hackmann, Michael Davidson, Matthias Kaehlcke
rate_flg is of type 'enum nl80211_attrs', however it is assigned with
'enum nl80211_rate_info' values. Change the type of rate_flg accordingly.
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
net/wireless/nl80211.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 2312dc2ffdb9..9af21a21ea6b 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -4151,7 +4151,7 @@ static bool nl80211_put_sta_rate(struct sk_buff *msg, struct rate_info *info,
struct nlattr *rate;
u32 bitrate;
u16 bitrate_compat;
- enum nl80211_attrs rate_flg;
+ enum nl80211_rate_info rate_flg;
rate = nla_nest_start(msg, attr);
if (!rate)
--
2.12.2.762.g0e3151a226-goog
^ permalink raw reply related
* [PATCH v3 6/9] ftgmac100: Allow configuration of phy interface via device-tree
From: Benjamin Herrenschmidt @ 2017-04-17 22:37 UTC (permalink / raw)
To: netdev; +Cc: Benjamin Herrenschmidt
In-Reply-To: <20170417223706.16483-1-benh@kernel.crashing.org>
This uses the standard phy-mode property
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
drivers/net/ethernet/faraday/ftgmac100.c | 42 +++++++++++++++++++++++++++++---
1 file changed, 39 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index f76765e..7721c2a 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -34,6 +34,7 @@
#include <linux/property.h>
#include <linux/crc32.h>
#include <linux/if_vlan.h>
+#include <linux/of_net.h>
#include <net/ip.h>
#include <net/ncsi.h>
@@ -1051,7 +1052,7 @@ static void ftgmac100_adjust_link(struct net_device *netdev)
schedule_work(&priv->reset_task);
}
-static int ftgmac100_mii_probe(struct ftgmac100 *priv)
+static int ftgmac100_mii_probe(struct ftgmac100 *priv, phy_interface_t intf)
{
struct net_device *netdev = priv->netdev;
struct phy_device *phydev;
@@ -1063,7 +1064,7 @@ static int ftgmac100_mii_probe(struct ftgmac100 *priv)
}
phydev = phy_connect(netdev, phydev_name(phydev),
- &ftgmac100_adjust_link, PHY_INTERFACE_MODE_GMII);
+ &ftgmac100_adjust_link, intf);
if (IS_ERR(phydev)) {
netdev_err(netdev, "%s: Could not attach to PHY\n", netdev->name);
@@ -1618,6 +1619,8 @@ static int ftgmac100_setup_mdio(struct net_device *netdev)
{
struct ftgmac100 *priv = netdev_priv(netdev);
struct platform_device *pdev = to_platform_device(priv->dev);
+ int phy_intf = PHY_INTERFACE_MODE_RGMII;
+ struct device_node *np = pdev->dev.of_node;
int i, err = 0;
u32 reg;
@@ -1633,6 +1636,39 @@ static int ftgmac100_setup_mdio(struct net_device *netdev)
iowrite32(reg, priv->base + FTGMAC100_OFFSET_REVR);
};
+ /* Get PHY mode from device-tree */
+ if (np) {
+ /* Default to RGMII. It's a gigabit part after all */
+ phy_intf = of_get_phy_mode(np);
+ if (phy_intf < 0)
+ phy_intf = PHY_INTERFACE_MODE_RGMII;
+
+ /* Aspeed only supports these. I don't know about other IP
+ * block vendors so I'm going to just let them through for
+ * now. Note that this is only a warning if for some obscure
+ * reason the DT really means to lie about it or it's a newer
+ * part we don't know about.
+ *
+ * On the Aspeed SoC there are additionally straps and SCU
+ * control bits that could tell us what the interface is
+ * (or allow us to configure it while the IP block is held
+ * in reset). For now I chose to keep this driver away from
+ * those SoC specific bits and assume the device-tree is
+ * right and the SCU has been configured properly by pinmux
+ * or the firmware.
+ */
+ if (priv->is_aspeed &&
+ phy_intf != PHY_INTERFACE_MODE_RMII &&
+ phy_intf != PHY_INTERFACE_MODE_RGMII &&
+ phy_intf != PHY_INTERFACE_MODE_RGMII_ID &&
+ phy_intf != PHY_INTERFACE_MODE_RGMII_RXID &&
+ phy_intf != PHY_INTERFACE_MODE_RGMII_TXID) {
+ netdev_warn(netdev,
+ "Unsupported PHY mode %s !\n",
+ phy_modes(phy_intf));
+ }
+ }
+
priv->mii_bus->name = "ftgmac100_mdio";
snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%d",
pdev->name, pdev->id);
@@ -1649,7 +1685,7 @@ static int ftgmac100_setup_mdio(struct net_device *netdev)
goto err_register_mdiobus;
}
- err = ftgmac100_mii_probe(priv);
+ err = ftgmac100_mii_probe(priv, phy_intf);
if (err) {
dev_err(priv->dev, "MII Probe failed!\n");
goto err_mii_probe;
--
2.9.3
^ permalink raw reply related
* [PATCH v3 8/9] ftgmac100: Fix potential ordering issue in NAPI poll
From: Benjamin Herrenschmidt @ 2017-04-17 22:37 UTC (permalink / raw)
To: netdev; +Cc: Benjamin Herrenschmidt
In-Reply-To: <20170417223706.16483-1-benh@kernel.crashing.org>
We need to ensure the loads from the descriptor are done after the
MMIO store clearing the interrupts has completed, otherwise we
might still miss work.
A read back from the MMIO register will "push" the posted store and
ioread32 has a barrier on weakly aordered architectures that will
order subsequent accesses.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
drivers/net/ethernet/faraday/ftgmac100.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 45b8267..95bf5e8 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1349,6 +1349,13 @@ static int ftgmac100_poll(struct napi_struct *napi, int budget)
*/
iowrite32(FTGMAC100_INT_RXTX,
priv->base + FTGMAC100_OFFSET_ISR);
+
+ /* Push the above (and provides a barrier vs. subsequent
+ * reads of the descriptor).
+ */
+ ioread32(priv->base + FTGMAC100_OFFSET_ISR);
+
+ /* Check RX and TX descriptors for more work to do */
if (ftgmac100_check_rx(priv) ||
ftgmac100_tx_buf_cleanable(priv))
return budget;
--
2.9.3
^ permalink raw reply related
* [PATCH v3 9/9] ftgmac100: Document device-tree binding
From: Benjamin Herrenschmidt @ 2017-04-17 22:37 UTC (permalink / raw)
To: netdev; +Cc: Benjamin Herrenschmidt
In-Reply-To: <20170417223706.16483-1-benh@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
--
v3. - Update supported values for phy-mode
---
.../devicetree/bindings/net/ftgmac100.txt | 37 ++++++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100644 Documentation/devicetree/bindings/net/ftgmac100.txt
diff --git a/Documentation/devicetree/bindings/net/ftgmac100.txt b/Documentation/devicetree/bindings/net/ftgmac100.txt
new file mode 100644
index 0000000..fceeede
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/ftgmac100.txt
@@ -0,0 +1,37 @@
+* Faraday Technology FTGMAC100 gigabit ethernet controller
+
+Required properties:
+- compatible: "faraday,ftgmac100"
+
+ Must also contain one of these if used as part of an Aspeed AST2400
+ or 2500 family SoC as they have some subtle tweaks to the
+ implementation:
+
+ - "aspeed,ast2400-mac"
+ - "aspeed,ast2500-mac"
+
+- reg: Address and length of the register set for the device
+- interrupts: Should contain ethernet controller interrupt
+
+Optional properties:
+- phy-mode: See ethernet.txt file in the same directory. If the property is
+ absent, "rgmii" is assumed. Supported values are "rgmii*" and "rmii" for
+ aspeed parts. Other (unknown) parts will accept any value.
+- use-ncsi: Use the NC-SI stack instead of an MDIO PHY. Currently assumes
+ rmii (100bT) but kept as a separate property in case NC-SI grows support
+ for a gigabit link.
+- no-hw-checksum: Used to disable HW checksum support. Here for backward
+ compatibility as the driver now should have correct defaults based on
+ the SoC.
+
+Example:
+
+ mac0: ethernet@1e660000 {
+ compatible = "aspeed,ast2500-mac", "faraday,ftgmac100";
+ reg = <0x1e660000 0x180>;
+ interrupts = <2>;
+ status = "okay";
+ use-ncsi;
+ };
+
+
--
2.9.3
^ permalink raw reply related
* [PATCH v3 7/9] ftgmac100: Display the discovered PHY device info
From: Benjamin Herrenschmidt @ 2017-04-17 22:37 UTC (permalink / raw)
To: netdev; +Cc: Benjamin Herrenschmidt
In-Reply-To: <20170417223706.16483-1-benh@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
drivers/net/ethernet/faraday/ftgmac100.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 7721c2a..45b8267 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1077,6 +1077,9 @@ static int ftgmac100_mii_probe(struct ftgmac100 *priv, phy_interface_t intf)
phydev->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
phydev->advertising = phydev->supported;
+ /* Display what we found */
+ phy_attached_info(phydev);
+
return 0;
}
--
2.9.3
^ permalink raw reply related
* [PATCH v3 5/9] ftgmac100: Add netpoll support
From: Benjamin Herrenschmidt @ 2017-04-17 22:37 UTC (permalink / raw)
To: netdev; +Cc: Benjamin Herrenschmidt
In-Reply-To: <20170417223706.16483-1-benh@kernel.crashing.org>
Just call the interrupt handler with interrupts locally disabled
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
drivers/net/ethernet/faraday/ftgmac100.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 40a03d5..f76765e 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1588,6 +1588,17 @@ static int ftgmac100_set_features(struct net_device *netdev,
return 0;
}
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static void ftgmac100_poll_controller(struct net_device *netdev)
+{
+ unsigned long flags;
+
+ local_irq_save(flags);
+ ftgmac100_interrupt(netdev->irq, netdev);
+ local_irq_restore(flags);
+}
+#endif
+
static const struct net_device_ops ftgmac100_netdev_ops = {
.ndo_open = ftgmac100_open,
.ndo_stop = ftgmac100_stop,
@@ -1598,6 +1609,9 @@ static const struct net_device_ops ftgmac100_netdev_ops = {
.ndo_tx_timeout = ftgmac100_tx_timeout,
.ndo_set_rx_mode = ftgmac100_set_rx_mode,
.ndo_set_features = ftgmac100_set_features,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .ndo_poll_controller = ftgmac100_poll_controller,
+#endif
};
static int ftgmac100_setup_mdio(struct net_device *netdev)
--
2.9.3
^ permalink raw reply related
* [PATCH v3 4/9] ftgmac100: Add vlan HW offload
From: Benjamin Herrenschmidt @ 2017-04-17 22:37 UTC (permalink / raw)
To: netdev; +Cc: Benjamin Herrenschmidt
In-Reply-To: <20170417223706.16483-1-benh@kernel.crashing.org>
The chip supports HW vlan tag insertion and extraction. Add support
for it.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
drivers/net/ethernet/faraday/ftgmac100.c | 46 +++++++++++++++++++++++++++++++-
1 file changed, 45 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index f4db6e2..40a03d5 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -33,6 +33,7 @@
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/crc32.h>
+#include <linux/if_vlan.h>
#include <net/ip.h>
#include <net/ncsi.h>
@@ -335,6 +336,10 @@ static void ftgmac100_start_hw(struct ftgmac100 *priv)
else if (netdev_mc_count(priv->netdev))
maccr |= FTGMAC100_MACCR_HT_MULTI_EN;
+ /* Vlan filtering enabled */
+ if (priv->netdev->features & NETIF_F_HW_VLAN_CTAG_RX)
+ maccr |= FTGMAC100_MACCR_RM_VLAN;
+
/* Hit the HW */
iowrite32(maccr, priv->base + FTGMAC100_OFFSET_MACCR);
}
@@ -530,6 +535,12 @@ static bool ftgmac100_rx_packet(struct ftgmac100 *priv, int *processed)
/* Transfer received size to skb */
skb_put(skb, size);
+ /* Extract vlan tag */
+ if ((netdev->features & NETIF_F_HW_VLAN_CTAG_RX) &&
+ (csum_vlan & FTGMAC100_RXDES1_VLANTAG_AVAIL))
+ __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
+ csum_vlan & 0xffff);
+
/* Tear down DMA mapping, do necessary cache management */
map = le32_to_cpu(rxdes->rxdes3);
@@ -754,6 +765,13 @@ static int ftgmac100_hard_start_xmit(struct sk_buff *skb,
if (skb->ip_summed == CHECKSUM_PARTIAL &&
!ftgmac100_prep_tx_csum(skb, &csum_vlan))
goto drop;
+
+ /* Add VLAN tag */
+ if (skb_vlan_tag_present(skb)) {
+ csum_vlan |= FTGMAC100_TXDES1_INS_VLANTAG;
+ csum_vlan |= skb_vlan_tag_get(skb) & 0xffff;
+ }
+
txdes->txdes1 = cpu_to_le32(csum_vlan);
/* Next descriptor */
@@ -1546,6 +1564,30 @@ static void ftgmac100_tx_timeout(struct net_device *netdev)
schedule_work(&priv->reset_task);
}
+static int ftgmac100_set_features(struct net_device *netdev,
+ netdev_features_t features)
+{
+ struct ftgmac100 *priv = netdev_priv(netdev);
+ netdev_features_t changed = netdev->features ^ features;
+
+ if (!netif_running(netdev))
+ return 0;
+
+ /* Update the vlan filtering bit */
+ if (changed & NETIF_F_HW_VLAN_CTAG_RX) {
+ u32 maccr;
+
+ maccr = ioread32(priv->base + FTGMAC100_OFFSET_MACCR);
+ if (priv->netdev->features & NETIF_F_HW_VLAN_CTAG_RX)
+ maccr |= FTGMAC100_MACCR_RM_VLAN;
+ else
+ maccr &= ~FTGMAC100_MACCR_RM_VLAN;
+ iowrite32(maccr, priv->base + FTGMAC100_OFFSET_MACCR);
+ }
+
+ return 0;
+}
+
static const struct net_device_ops ftgmac100_netdev_ops = {
.ndo_open = ftgmac100_open,
.ndo_stop = ftgmac100_stop,
@@ -1555,6 +1597,7 @@ static const struct net_device_ops ftgmac100_netdev_ops = {
.ndo_do_ioctl = ftgmac100_do_ioctl,
.ndo_tx_timeout = ftgmac100_tx_timeout,
.ndo_set_rx_mode = ftgmac100_set_rx_mode,
+ .ndo_set_features = ftgmac100_set_features,
};
static int ftgmac100_setup_mdio(struct net_device *netdev)
@@ -1730,7 +1773,8 @@ static int ftgmac100_probe(struct platform_device *pdev)
/* Base feature set */
netdev->hw_features = NETIF_F_RXCSUM | NETIF_F_HW_CSUM |
- NETIF_F_GRO | NETIF_F_SG;
+ NETIF_F_GRO | NETIF_F_SG | NETIF_F_HW_VLAN_CTAG_RX |
+ NETIF_F_HW_VLAN_CTAG_TX;
/* AST2400 doesn't have working HW checksum generation */
if (np && (of_device_is_compatible(np, "aspeed,ast2400-mac")))
--
2.9.3
^ permalink raw reply related
* [PATCH v3 3/9] ftgmac100: Add ndo_set_rx_mode() and support for multicast & promisc
From: Benjamin Herrenschmidt @ 2017-04-17 22:37 UTC (permalink / raw)
To: netdev; +Cc: Benjamin Herrenschmidt
In-Reply-To: <20170417223706.16483-1-benh@kernel.crashing.org>
This adds the ndo_set_rx_mode() callback to configure the
multicast filters, promisc and allmulti options.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
--
v3. - Rebase to fix conflict with #include changes
---
drivers/net/ethernet/faraday/ftgmac100.c | 52 ++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 949b48c..f4db6e2 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -32,6 +32,7 @@
#include <linux/phy.h>
#include <linux/platform_device.h>
#include <linux/property.h>
+#include <linux/crc32.h>
#include <net/ip.h>
#include <net/ncsi.h>
@@ -99,6 +100,10 @@ struct ftgmac100 {
int cur_duplex;
bool use_ncsi;
+ /* Multicast filter settings */
+ u32 maht0;
+ u32 maht1;
+
/* Flow control settings */
bool tx_pause;
bool rx_pause;
@@ -266,6 +271,10 @@ static void ftgmac100_init_hw(struct ftgmac100 *priv)
/* Write MAC address */
ftgmac100_write_mac_addr(priv, priv->netdev->dev_addr);
+ /* Write multicast filter */
+ iowrite32(priv->maht0, priv->base + FTGMAC100_OFFSET_MAHT0);
+ iowrite32(priv->maht1, priv->base + FTGMAC100_OFFSET_MAHT1);
+
/* Configure descriptor sizes and increase burst sizes according
* to values in Aspeed SDK. The FIFO arbitration is enabled and
* the thresholds set based on the recommended values in the
@@ -319,6 +328,12 @@ static void ftgmac100_start_hw(struct ftgmac100 *priv)
/* Add other bits as needed */
if (priv->cur_duplex == DUPLEX_FULL)
maccr |= FTGMAC100_MACCR_FULLDUP;
+ if (priv->netdev->flags & IFF_PROMISC)
+ maccr |= FTGMAC100_MACCR_RX_ALL;
+ if (priv->netdev->flags & IFF_ALLMULTI)
+ maccr |= FTGMAC100_MACCR_RX_MULTIPKT;
+ else if (netdev_mc_count(priv->netdev))
+ maccr |= FTGMAC100_MACCR_HT_MULTI_EN;
/* Hit the HW */
iowrite32(maccr, priv->base + FTGMAC100_OFFSET_MACCR);
@@ -329,6 +344,42 @@ static void ftgmac100_stop_hw(struct ftgmac100 *priv)
iowrite32(0, priv->base + FTGMAC100_OFFSET_MACCR);
}
+static void ftgmac100_calc_mc_hash(struct ftgmac100 *priv)
+{
+ struct netdev_hw_addr *ha;
+
+ priv->maht1 = 0;
+ priv->maht0 = 0;
+ netdev_for_each_mc_addr(ha, priv->netdev) {
+ u32 crc_val = ether_crc_le(ETH_ALEN, ha->addr);
+
+ crc_val = (~(crc_val >> 2)) & 0x3f;
+ if (crc_val >= 32)
+ priv->maht1 |= 1ul << (crc_val - 32);
+ else
+ priv->maht0 |= 1ul << (crc_val);
+ }
+}
+
+static void ftgmac100_set_rx_mode(struct net_device *netdev)
+{
+ struct ftgmac100 *priv = netdev_priv(netdev);
+
+ /* Setup the hash filter */
+ ftgmac100_calc_mc_hash(priv);
+
+ /* Interface down ? that's all there is to do */
+ if (!netif_running(netdev))
+ return;
+
+ /* Update the HW */
+ iowrite32(priv->maht0, priv->base + FTGMAC100_OFFSET_MAHT0);
+ iowrite32(priv->maht1, priv->base + FTGMAC100_OFFSET_MAHT1);
+
+ /* Reconfigure MACCR */
+ ftgmac100_start_hw(priv);
+}
+
static int ftgmac100_alloc_rx_buf(struct ftgmac100 *priv, unsigned int entry,
struct ftgmac100_rxdes *rxdes, gfp_t gfp)
{
@@ -1503,6 +1554,7 @@ static const struct net_device_ops ftgmac100_netdev_ops = {
.ndo_validate_addr = eth_validate_addr,
.ndo_do_ioctl = ftgmac100_do_ioctl,
.ndo_tx_timeout = ftgmac100_tx_timeout,
+ .ndo_set_rx_mode = ftgmac100_set_rx_mode,
};
static int ftgmac100_setup_mdio(struct net_device *netdev)
--
2.9.3
^ permalink raw reply related
* [PATCH v3 2/9] ftgmac100: Add pause frames configuration and support
From: Benjamin Herrenschmidt @ 2017-04-17 22:36 UTC (permalink / raw)
To: netdev; +Cc: Benjamin Herrenschmidt
In-Reply-To: <20170417223706.16483-1-benh@kernel.crashing.org>
Hopefully my understanding of how the hardware works is correct,
as the documentation isn't completely clear. So far I have seen
no obvious issue. Pause seem to also work with NC-SI.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
drivers/net/ethernet/faraday/ftgmac100.c | 96 +++++++++++++++++++++++++++++++-
drivers/net/ethernet/faraday/ftgmac100.h | 7 +++
2 files changed, 102 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 4cdd25a..949b48c 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -99,6 +99,11 @@ struct ftgmac100 {
int cur_duplex;
bool use_ncsi;
+ /* Flow control settings */
+ bool tx_pause;
+ bool rx_pause;
+ bool aneg_pause;
+
/* Misc */
bool need_mac_restart;
bool is_aspeed;
@@ -219,6 +224,23 @@ static int ftgmac100_set_mac_addr(struct net_device *dev, void *p)
return 0;
}
+static void ftgmac100_config_pause(struct ftgmac100 *priv)
+{
+ u32 fcr = FTGMAC100_FCR_PAUSE_TIME(16);
+
+ /* Throttle tx queue when receiving pause frames */
+ if (priv->rx_pause)
+ fcr |= FTGMAC100_FCR_FC_EN;
+
+ /* Enables sending pause frames when the RX queue is past a
+ * certain threshold.
+ */
+ if (priv->tx_pause)
+ fcr |= FTGMAC100_FCR_FCTHR_EN;
+
+ iowrite32(fcr, priv->base + FTGMAC100_OFFSET_FCR);
+}
+
static void ftgmac100_init_hw(struct ftgmac100 *priv)
{
u32 reg, rfifo_sz, tfifo_sz;
@@ -912,6 +934,7 @@ static void ftgmac100_adjust_link(struct net_device *netdev)
{
struct ftgmac100 *priv = netdev_priv(netdev);
struct phy_device *phydev = netdev->phydev;
+ bool tx_pause, rx_pause;
int new_speed;
/* We store "no link" as speed 0 */
@@ -920,8 +943,21 @@ static void ftgmac100_adjust_link(struct net_device *netdev)
else
new_speed = phydev->speed;
+ /* Grab pause settings from PHY if configured to do so */
+ if (priv->aneg_pause) {
+ rx_pause = tx_pause = phydev->pause;
+ if (phydev->asym_pause)
+ tx_pause = !rx_pause;
+ } else {
+ rx_pause = priv->rx_pause;
+ tx_pause = priv->tx_pause;
+ }
+
+ /* Link hasn't changed, do nothing */
if (phydev->speed == priv->cur_speed &&
- phydev->duplex == priv->cur_duplex)
+ phydev->duplex == priv->cur_duplex &&
+ rx_pause == priv->rx_pause &&
+ tx_pause == priv->tx_pause)
return;
/* Print status if we have a link or we had one and just lost it,
@@ -932,6 +968,8 @@ static void ftgmac100_adjust_link(struct net_device *netdev)
priv->cur_speed = new_speed;
priv->cur_duplex = phydev->duplex;
+ priv->rx_pause = rx_pause;
+ priv->tx_pause = tx_pause;
/* Link is down, do nothing else */
if (!new_speed)
@@ -963,6 +1001,12 @@ static int ftgmac100_mii_probe(struct ftgmac100 *priv)
return PTR_ERR(phydev);
}
+ /* Indicate that we support PAUSE frames (see comment in
+ * Documentation/networking/phy.txt)
+ */
+ phydev->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
+ phydev->advertising = phydev->supported;
+
return 0;
}
@@ -1078,6 +1122,48 @@ static int ftgmac100_set_ringparam(struct net_device *netdev,
return 0;
}
+static void ftgmac100_get_pauseparam(struct net_device *netdev,
+ struct ethtool_pauseparam *pause)
+{
+ struct ftgmac100 *priv = netdev_priv(netdev);
+
+ pause->autoneg = priv->aneg_pause;
+ pause->tx_pause = priv->tx_pause;
+ pause->rx_pause = priv->rx_pause;
+}
+
+static int ftgmac100_set_pauseparam(struct net_device *netdev,
+ struct ethtool_pauseparam *pause)
+{
+ struct ftgmac100 *priv = netdev_priv(netdev);
+ struct phy_device *phydev = netdev->phydev;
+
+ priv->aneg_pause = pause->autoneg;
+ priv->tx_pause = pause->tx_pause;
+ priv->rx_pause = pause->rx_pause;
+
+ if (phydev) {
+ phydev->advertising &= ~ADVERTISED_Pause;
+ phydev->advertising &= ~ADVERTISED_Asym_Pause;
+
+ if (pause->rx_pause) {
+ phydev->advertising |= ADVERTISED_Pause;
+ phydev->advertising |= ADVERTISED_Asym_Pause;
+ }
+
+ if (pause->tx_pause)
+ phydev->advertising ^= ADVERTISED_Asym_Pause;
+ }
+ if (netif_running(netdev)) {
+ if (phydev && priv->aneg_pause)
+ phy_start_aneg(phydev);
+ else
+ ftgmac100_config_pause(priv);
+ }
+
+ return 0;
+}
+
static const struct ethtool_ops ftgmac100_ethtool_ops = {
.get_drvinfo = ftgmac100_get_drvinfo,
.get_link = ethtool_op_get_link,
@@ -1086,6 +1172,8 @@ static const struct ethtool_ops ftgmac100_ethtool_ops = {
.nway_reset = phy_ethtool_nway_reset,
.get_ringparam = ftgmac100_get_ringparam,
.set_ringparam = ftgmac100_set_ringparam,
+ .get_pauseparam = ftgmac100_get_pauseparam,
+ .set_pauseparam = ftgmac100_set_pauseparam,
};
static irqreturn_t ftgmac100_interrupt(int irq, void *dev_id)
@@ -1217,6 +1305,7 @@ static int ftgmac100_init_all(struct ftgmac100 *priv, bool ignore_alloc_err)
/* Reinit and restart HW */
ftgmac100_init_hw(priv);
+ ftgmac100_config_pause(priv);
ftgmac100_start_hw(priv);
/* Re-enable the device */
@@ -1546,6 +1635,11 @@ static int ftgmac100_probe(struct platform_device *pdev)
netdev->irq = irq;
+ /* Enable pause */
+ priv->tx_pause = true;
+ priv->rx_pause = true;
+ priv->aneg_pause = true;
+
/* MAC address from chip or random one */
ftgmac100_initial_mac(priv);
diff --git a/drivers/net/ethernet/faraday/ftgmac100.h b/drivers/net/ethernet/faraday/ftgmac100.h
index 97912c4..0653d81 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.h
+++ b/drivers/net/ethernet/faraday/ftgmac100.h
@@ -199,6 +199,13 @@
#define FTGMAC100_PHYDATA_MIIRDATA(phydata) (((phydata) >> 16) & 0xffff)
/*
+ * Flow control register
+ */
+#define FTGMAC100_FCR_FC_EN (1 << 0)
+#define FTGMAC100_FCR_FCTHR_EN (1 << 2)
+#define FTGMAC100_FCR_PAUSE_TIME(x) (((x) & 0xffff) << 16)
+
+/*
* Transmit descriptor, aligned to 16 bytes
*/
struct ftgmac100_txdes {
--
2.9.3
^ permalink raw reply related
* [PATCH v3 1/9] ftgmac100: Add ethtool n-way reset call
From: Benjamin Herrenschmidt @ 2017-04-17 22:36 UTC (permalink / raw)
To: netdev; +Cc: Benjamin Herrenschmidt
In-Reply-To: <20170417223706.16483-1-benh@kernel.crashing.org>
A non-wired up implementation accidentally made its way in
a previous patch (Make ring sizes configurable via ethtool).
This removes it and wires up the generic phy_ethtool_nway_reset
instead.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
--
v2. - Use phy_ethtool_nway_reset() instead of custom implementation
---
drivers/net/ethernet/faraday/ftgmac100.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 2153c5b..4cdd25a 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1045,13 +1045,6 @@ static void ftgmac100_get_drvinfo(struct net_device *netdev,
strlcpy(info->bus_info, dev_name(&netdev->dev), sizeof(info->bus_info));
}
-static int ftgmac100_nway_reset(struct net_device *ndev)
-{
- if (!ndev->phydev)
- return -ENXIO;
- return phy_start_aneg(ndev->phydev);
-}
-
static void ftgmac100_get_ringparam(struct net_device *netdev,
struct ethtool_ringparam *ering)
{
@@ -1090,6 +1083,7 @@ static const struct ethtool_ops ftgmac100_ethtool_ops = {
.get_link = ethtool_op_get_link,
.get_link_ksettings = phy_ethtool_get_link_ksettings,
.set_link_ksettings = phy_ethtool_set_link_ksettings,
+ .nway_reset = phy_ethtool_nway_reset,
.get_ringparam = ftgmac100_get_ringparam,
.set_ringparam = ftgmac100_set_ringparam,
};
--
2.9.3
^ permalink raw reply related
* [PATCH v3 0/9] ftgmac100: Rework batch 5 - Features
From: Benjamin Herrenschmidt @ 2017-04-17 22:36 UTC (permalink / raw)
To: netdev
This is the third spin of the fifth and last batch of
updates to the ftgmac100 driver.
This contains a few additional "features" such as:
- Support for ethtool n-way reset
- Multicast filtering & promisc support
- Vlan offload
- netpoll
And a couple of misc bits. This also adds the device-tree binding
documentation.
v2. - Addresses review comments and adds a new patch fixing a
theorical ordering issue in my new NAPI poll implementation
- Add a bug fix (Patch 8/9) for a potential ordering issue
in the new NAPI poll code.
v3. - Rebase on net-next (fix conflict with an unrelated #include
change series)
- Update DT bindings better describing accepted phy-mode values
^ permalink raw reply
* Re: [PATCH net-next] net: ipv6: Fix UDP early demux lookup with udp_l3mdev_accept=0
From: Eric Dumazet @ 2017-04-17 21:52 UTC (permalink / raw)
To: Subash Abhinov Kasiviswanathan; +Cc: dsa, davem, netdev, rshearma
In-Reply-To: <1492463503-3351-1-git-send-email-subashab@codeaurora.org>
On Mon, 2017-04-17 at 15:11 -0600, Subash Abhinov Kasiviswanathan wrote:
> David Ahern reported that 5425077d73e0c ("net: ipv6: Add early demux
> handler for UDP unicast") breaks udp_l3mdev_accept=0 since early
> demux for IPv6 UDP was doing a generic socket lookup which does not
> require an exact match. Fix this by making UDPv6 early demux match
> connected sockets only.
>
> Fixes: 5425077d73e0c ("net: ipv6: Add early demux handler for UDP unicast")
> Reported-by: David Ahern <dsa@cumulusnetworks.com>
> Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
> ---
> net/ipv6/udp.c | 21 +++++++++++++--------
> 1 file changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
> index b793ed1..0e307e5 100644
> --- a/net/ipv6/udp.c
> +++ b/net/ipv6/udp.c
> @@ -46,6 +46,7 @@
> #include <net/tcp_states.h>
> #include <net/ip6_checksum.h>
> #include <net/xfrm.h>
> +#include <net/inet_hashtables.h>
> #include <net/inet6_hashtables.h>
> #include <net/busy_poll.h>
> #include <net/sock_reuseport.h>
> @@ -864,21 +865,25 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
> return 0;
> }
>
> +
> static struct sock *__udp6_lib_demux_lookup(struct net *net,
> __be16 loc_port, const struct in6_addr *loc_addr,
> __be16 rmt_port, const struct in6_addr *rmt_addr,
> int dif)
> {
> + unsigned short hnum = ntohs(loc_port);
> + unsigned int hash2 = udp6_portaddr_hash(net, loc_addr, hnum);
> + unsigned int slot2 = hash2 & udp_table.mask;
> + struct udp_hslot *hslot2 = &udp_table.hash2[slot2];
> + const __portpair ports = INET_COMBINED_PORTS(rmt_port, hnum);
> struct sock *sk;
>
> - rcu_read_lock();
> - sk = __udp6_lib_lookup(net, rmt_addr, rmt_port, loc_addr, loc_port,
> - dif, &udp_table, NULL);
> - if (sk && !atomic_inc_not_zero(&sk->sk_refcnt))
> - sk = NULL;
> - rcu_read_unlock();
> -
> - return sk;
> + udp_portaddr_for_each_entry_rcu(sk, &hslot2->head) {
> + if (INET6_MATCH(sk, net, rmt_addr, loc_addr, ports, dif))
> + return sk;
> + break;
> + }
> + return NULL;
> }
>
> static void udp_v6_early_demux(struct sk_buff *skb)
This can not be right.
You removed the atomic_inc_not_zero() call, meaning that this code will
release a live socket.
^ permalink raw reply
* Re: IGMP on IPv6
From: Cong Wang @ 2017-04-17 21:38 UTC (permalink / raw)
To: Murali Karicheri
Cc: Hangbin Liu, open list:TI NETCP ETHERNET DRIVER, David Miller
In-Reply-To: <58EFA913.5060604@ti.com>
Hello,
On Thu, Apr 13, 2017 at 9:36 AM, Murali Karicheri <m-karicheri2@ti.com> wrote:
> On 03/22/2017 11:04 AM, Murali Karicheri wrote:
>> This is going directly to the slave Ethernet interface.
>>
>> When I put a WARN_ONCE, I found this is coming directly from
>> mld_ifc_timer_expire() -> mld_sendpack() -> ip6_output()
>>
>> Do you think this is fixed in latest kernel at master? If so, could
>> you point me to some commits.
>>
>>
> Ping... I see this behavior is also seen on v4.9.x Kernel. Any clue if
> this is fixed by some commit or I need to debug? I see IGMPv6 has some
> fixes on the list to make it similar to IGMPv4. So can someone clarify this is
> is a bug at IGMPv6 code or I need to look into the HSR driver code?
> Since IGMPv4 is going over the HSR interface I am assuming this is a
> bug in the IGMPv6 code. But since I have not experience with this code
> can some expert comment please?
>
How did you configure your network interfaces and IPv4/IPv6 multicast?
IOW, how did you reproduce this? For example, did you change your
HSR setup when this happened since you mentioned
NETDEV_CHANGEUPPER?
^ 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