* Re: [PATCH net-next v5 2/2] net: thunderx: add timestamping support
From: Joe Perches @ 2017-12-12 19:47 UTC (permalink / raw)
To: Richard Cochran, Aleksey Makarov
Cc: netdev, linux-arm-kernel, linux-kernel, Goutham, Sunil,
Radoslaw Biernacki, Robert Richter, David Daney,
Philippe Ombredanne, Sunil Goutham
In-Reply-To: <20171211233641.cs7zdw34qkngicmj@localhost>
On Mon, 2017-12-11 at 15:36 -0800, Richard Cochran wrote:
> On Mon, Dec 11, 2017 at 05:14:31PM +0300, Aleksey Makarov wrote:
> > @@ -880,6 +889,46 @@ static void nic_pause_frame(struct nicpf *nic, int vf, struct pfc *cfg)
> > }
> > }
> >
> > +/* Enable or disable HW timestamping by BGX for pkts received on a LMAC */
> > +static void nic_config_timestamp(struct nicpf *nic, int vf, struct set_ptp *ptp)
> > +{
> > + struct pkind_cfg *pkind;
> > + u8 lmac, bgx_idx;
> > + u64 pkind_val, pkind_idx;
> > +
> > + if (vf >= nic->num_vf_en)
> > + return;
> > +
> > + bgx_idx = NIC_GET_BGX_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]);
> > + lmac = NIC_GET_LMAC_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]);
> > +
> > + pkind_idx = lmac + bgx_idx * MAX_LMAC_PER_BGX;
> > + pkind_val = nic_reg_read(nic, NIC_PF_PKIND_0_15_CFG | (pkind_idx << 3));
> > + pkind = (struct pkind_cfg *)&pkind_val;
> > +
> > + if (ptp->enable && !pkind->hdr_sl) {
> > + /* Skiplen to exclude 8byte timestamp while parsing pkt
> > + * If not configured, will result in L2 errors.
> > + */
> > + pkind->hdr_sl = 4;
> > + /* Adjust max packet length allowed */
> > + pkind->maxlen += (pkind->hdr_sl * 2);
Are all compilers smart enough to set this to 8?
I rather doubt a compiler is even allowed to.
^ permalink raw reply
* Re: [RFC][PATCH] new byteorder primitives - ..._{replace,get}_bits()
From: Jakub Kicinski @ 2017-12-12 20:04 UTC (permalink / raw)
To: Al Viro; +Cc: Linus Torvalds, netdev, linux-kernel
In-Reply-To: <20171212194532.GA7062@ZenIV.linux.org.uk>
On Tue, 12 Dec 2017 19:45:32 +0000, Al Viro wrote:
> On Tue, Dec 12, 2017 at 06:20:02AM +0000, Al Viro wrote:
>
> > Umm... What's wrong with
> >
> > #define FIELD_FOO 0,4
> > #define FIELD_BAR 6,12
> > #define FIELD_BAZ 18,14
> >
> > A macro can bloody well expand to any sequence of tokens - le32_get_bits(v, FIELD_BAZ)
> > will become le32_get_bits(v, 18, 14) just fine. What's the problem with that?
>
> FWIW, if you want to use the mask, __builtin_ffsll() is not the only way to do
> it - you don't need the shift. Multiplier would do just as well, and that can
> be had easier. If mask = (2*a + 1)<<n = ((2*a)<<n) ^ (1<<n), then
> mask - 1 = ((2*a) << n) + ((1<<n) - 1) = ((2*n) << n) ^ ((1<<n) - 1)
> mask ^ (mask - 1) = (1<<n) + ((1<<n) - 1)
> and
> mask & (mask ^ (mask - 1)) = 1<<n.
>
> IOW, with
>
> static __always_inline u64 mask_to_multiplier(u64 mask)
> {
> return mask & (mask ^ (mask - 1));
> }
>
> we could do
>
> static __always_inline __le64 le64_replace_bits(__le64 old, u64 v, u64 mask)
> {
> __le64 m = cpu_to_le64(mask);
> return (old & ~m) | (cpu_to_le64(v * mask_to_multiplier(mask)) & m);
> }
>
> static __always_inline u64 le64_get_bits(__le64 v, u64 mask)
> {
> return (le64_to_cpu(v) & mask) / mask_to_multiplier(mask);
> }
>
> etc. Compiler will turn those into shifts... I can live with either calling
> conventions.
>
> Comments?
Very nice! The compilation-time check if the value can fit in a field
covered by the mask (if they're both known) did help me catch bugs
early a few times over the years, so if it could be preserved we can
maybe even drop the FIELD_* macros and just use this approach?
^ permalink raw reply
* Re: [PATCH v2 2/3] dt-bindings: Add optional nvmem BD address bindings to ti,wlink-st
From: Rob Herring @ 2017-12-12 20:09 UTC (permalink / raw)
To: David Lechner
Cc: devicetree, linux-bluetooth, Mark Rutland, Marcel Holtmann,
Gustavo Padovan, Johan Hedberg, netdev, linux-kernel
In-Reply-To: <1512701860-8321-3-git-send-email-david@lechnology.com>
On Thu, Dec 07, 2017 at 08:57:39PM -0600, David Lechner wrote:
> This adds optional nvmem consumer properties to the ti,wlink-st device tree
> bindings to allow specifying the BD address.
>
> Signed-off-by: David Lechner <david@lechnology.com>
> ---
>
> v2 changes:
> * Renamed "mac-address" to "bd-address"
> * Fixed typos in example
> * Specify byte order of "bd-address"
>
> Documentation/devicetree/bindings/net/ti,wilink-st.txt | 5 +++++
> 1 file changed, 5 insertions(+)
Reviewed-by: Rob Herring <robh@kernel.org>
^ permalink raw reply
* Re: [PATCH v3 29/33] dt-bindings: nds32 CPU Bindings
From: Rob Herring @ 2017-12-12 20:10 UTC (permalink / raw)
To: Greentime Hu
Cc: greentime, linux-kernel, arnd, linux-arch, tglx, jason,
marc.zyngier, netdev, deanbo422, devicetree, viro, dhowells,
will.deacon, daniel.lezcano, linux-serial, geert.uytterhoeven,
linus.walleij, mark.rutland, greg, Vincent Chen, Rick Chen,
Zong Li
In-Reply-To: <b082ead87b647f6f0797e51d3ceeaf6c87038dd1.1512723245.git.green.hu@gmail.com>
On Fri, Dec 08, 2017 at 05:12:12PM +0800, Greentime Hu wrote:
> From: Greentime Hu <greentime@andestech.com>
>
> This patch adds nds32 CPU binding documents.
>
> Signed-off-by: Vincent Chen <vincentc@andestech.com>
> Signed-off-by: Rick Chen <rick@andestech.com>
> Signed-off-by: Zong Li <zong@andestech.com>
> Signed-off-by: Greentime Hu <greentime@andestech.com>
> ---
> Documentation/devicetree/bindings/nds32/cpus.txt | 37 ++++++++++++++++++++++
> 1 file changed, 37 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/nds32/cpus.txt
Reviewed-by: Rob Herring <robh@kernel.org>
^ permalink raw reply
* Re: [PATCH v3 30/33] dt-bindings: nds32 SoC Bindings
From: Rob Herring @ 2017-12-12 20:12 UTC (permalink / raw)
To: Greentime Hu
Cc: greentime, linux-kernel, arnd, linux-arch, tglx, jason,
marc.zyngier, netdev, deanbo422, devicetree, viro, dhowells,
will.deacon, daniel.lezcano, linux-serial, geert.uytterhoeven,
linus.walleij, mark.rutland, greg
In-Reply-To: <4c33141ec34c73abe4a9106cbe71f2a97621958e.1512723245.git.green.hu@gmail.com>
On Fri, Dec 08, 2017 at 05:12:13PM +0800, Greentime Hu wrote:
> From: Greentime Hu <greentime@andestech.com>
>
> This patch adds nds32 SoC(AE3XX and AG101P) binding documents.
>
> Signed-off-by: Greentime Hu <greentime@andestech.com>
> ---
> .../devicetree/bindings/nds32/andestech-boards | 40 ++++++++++++++++++++
> 1 file changed, 40 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/nds32/andestech-boards
Reviewed-by: Rob Herring <robh@kernel.org>
^ permalink raw reply
* Re: [PATCH iproute2] tc: bash-completion: add missing 'classid' keyword
From: Stephen Hemminger @ 2017-12-12 20:13 UTC (permalink / raw)
To: Davide Caratti; +Cc: netdev, Yotam Gigi
In-Reply-To: <ac3526fab2d89589212e701a3ceb6f9e6c716731.1513092905.git.dcaratti@redhat.com>
On Tue, 12 Dec 2017 16:45:15 +0100
Davide Caratti <dcaratti@redhat.com> wrote:
> users of 'matchall' filter can specify a value for the class id: update
> bash-completion accordingly.
>
> Fixes: b32c0b64fa2b ("tc: bash-completion: Add support for matchall")
> Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Looks good applied. Thanks Davide
^ permalink raw reply
* Re: [PATCH iproute2 net-next v2 0/4] Abstract columns, properly space and wrap fields
From: Stephen Hemminger @ 2017-12-12 20:13 UTC (permalink / raw)
To: Stefano Brivio; +Cc: netdev, Sabrina Dubroca
In-Reply-To: <cover.1513039237.git.sbrivio@redhat.com>
On Tue, 12 Dec 2017 01:46:29 +0100
Stefano Brivio <sbrivio@redhat.com> wrote:
> Currently, 'ss' simply subdivides the whole available screen width
> between available columns, starting from a set of hardcoded amount
> of spacing and growing column widths.
>
> This makes the output unreadable in several cases, as it doesn't take
> into account the actual content width.
>
> Fix this by introducing a simple abstraction for columns, buffering
> the output, measuring the width of the fields, grouping fields into
> lines as they fit, equally distributing any remaining whitespace, and
> finally rendering the result. Some examples are reported below [1].
>
> This implementation doesn't seem to cause any significant performance
> issues, as reported in 3/4.
>
> Patch 1/4 replaces all relevant printf() calls by the out() helper,
> which simply consists of the usual printf() implementation.
>
> Patch 2/4 implements column abstraction, with configurable column
> width and delimiters, and 3/4 splits buffering and rendering phases,
> employing a simple buffering mechanism with chunked allocation and
> introducing a rendering function.
>
> Up to this point, the output is still unchanged.
>
> Finally, 4/4 introduces field width calculation based on content
> length measured while buffering, in order to split fields onto
> multiple lines and equally space them within the single lines.
>
> Now that column behaviour is well-defined and more easily
> configurable, it should be easier to further improve the output by
> splitting logically separable information (e.g. TCP details) into
> additional columns. However, this patchset keeps the full "extended"
> information into a single column, for the moment being.
>
>
> v2: rebase after conflict with 00ac78d39c29 ("ss: print tcpi_rcv_ssthresh")
>
>
> [1]
>
> - 80 columns terminal, ss -Z -f netlink
> * before:
> Recv-Q Send-Q Local Address:Port Peer Address:Port
>
> 0 0 rtnl:evolution-calen/2075 * pr
> oc_ctx=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
> 0 0 rtnl:abrt-applet/32700 * pr
> oc_ctx=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
> 0 0 rtnl:firefox/21619 * pr
> oc_ctx=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
> 0 0 rtnl:evolution-calen/32639 * p
> roc_ctx=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
> [...]
>
> * after:
> Recv-Q Send-Q Local Address:Port Peer Address:Port
> 0 0 rtnl:evolution-calen/2075 *
> proc_ctx=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
> 0 0 rtnl:abrt-applet/32700 *
> proc_ctx=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
> 0 0 rtnl:firefox/21619 *
> proc_ctx=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
> 0 0 rtnl:evolution-calen/32639 *
> proc_ctx=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
> [...]
>
> - 80 columns terminal, ss -tunpl
> * before:
> Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
> udp UNCONN 0 0 *:37732 *:*
> udp UNCONN 0 0 *:5353 *:*
> udp UNCONN 0 0 192.168.122.1:53 *:*
> udp UNCONN 0 0 *%virbr0:67 *:*
> [...]
>
> * after:
> Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
> udp UNCONN 0 0 *:37732 *:*
> udp UNCONN 0 0 *:5353 *:*
> udp UNCONN 0 0 192.168.122.1:53 *:*
> udp UNCONN 0 0 *%virbr0:67 *:*
> [...]
>
> - 66 columns terminal, ss -tunpl
> * before:
> Netid State Recv-Q Send-Q Local Address:Port P
> eer Address:Port
> udp UNCONN 0 0 *:37732 *:*
>
> udp UNCONN 0 0 *:5353 *:*
>
> udp UNCONN 0 0 192.168.122.1:53
> *:*
> udp UNCONN 0 0 *%virbr0:67 *:*
> [...]
>
> * after:
> Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
> udp UNCONN 0 0 *:37732 *:*
> udp UNCONN 0 0 *:5353 *:*
> udp UNCONN 0 0 192.168.122.1:53 *:*
> udp UNCONN 0 0 *%virbr0:67 *:*
> [...]
>
>
> Stefano Brivio (4):
> ss: Replace printf() calls for "main" output by calls to helper
> ss: Introduce columns lightweight abstraction
> ss: Buffer raw fields first, then render them as a table
> ss: Implement automatic column width calculation
This looks so good, I went ahead and applied to current release (not net-next)
Thanks Stefano
^ permalink raw reply
* [PATCH v3 0/3] ethtool: add ETHTOOL_RESET support via --reset command
From: Scott Branden @ 2017-12-12 20:20 UTC (permalink / raw)
To: John W. Linville
Cc: BCM Kernel Feedback, Steve Lin, Michael Chan, netdev,
Paul Greenwalt, Stephen Hemminger, Scott Branden
Patch series to add ETHTOOL_RESET support to ethtool userspace tool.
Include:
- revert custom change to ethtool-copy.h that is not in linux kernel
- sync ethtool-copy.h with ethtool.h in linux kernel net-next
- add ETHTOOL_RESET support with up to date ethtool.h reset defines
Changes from v2:
- update commit message to indicate support for ap
- add symbolic support for parsing of -shared added to each component specified
- cleaned up reset print information to indicate which components have and have not been reset
Scott Branden (3):
Revert "ethtool: Add DMA Coalescing support"
ethtool-copy.h: sync with net-next
ethtool: Add ETHTOOL_RESET support via --reset command
ethtool-copy.h | 68 ++++++++++++++++++++++++++++----
ethtool.8.in | 68 +++++++++++++++++++++++++++++++-
ethtool.c | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
3 files changed, 241 insertions(+), 16 deletions(-)
--
2.5.0
^ permalink raw reply
* [PATCH v3 1/3] Revert "ethtool: Add DMA Coalescing support"
From: Scott Branden @ 2017-12-12 20:20 UTC (permalink / raw)
To: John W. Linville
Cc: BCM Kernel Feedback, Steve Lin, Michael Chan, netdev,
Paul Greenwalt, Stephen Hemminger, Scott Branden
In-Reply-To: <1513110003-10543-1-git-send-email-scott.branden@broadcom.com>
This reverts commit 5dd7bfbc5079cb375876e4e76191263fc28ae1a6.
As Stephen Hemminger mentioned
there is an ABI compatibility issue with this patch:
https://patchwork.ozlabs.org/patch/806049/#1757846
Signed-off-by: Scott Branden <scott.branden@broadcom.com>
---
ethtool-copy.h | 2 --
ethtool.8.in | 1 -
ethtool.c | 8 +-------
3 files changed, 1 insertion(+), 10 deletions(-)
diff --git a/ethtool-copy.h b/ethtool-copy.h
index 4bb91eb..06fc04c 100644
--- a/ethtool-copy.h
+++ b/ethtool-copy.h
@@ -400,7 +400,6 @@ struct ethtool_modinfo {
* a TX interrupt, when the packet rate is above @pkt_rate_high.
* @rate_sample_interval: How often to do adaptive coalescing packet rate
* sampling, measured in seconds. Must not be zero.
- * @dmac: How many usecs to store packets before moving to host memory.
*
* Each pair of (usecs, max_frames) fields specifies that interrupts
* should be coalesced until
@@ -451,7 +450,6 @@ struct ethtool_coalesce {
__u32 tx_coalesce_usecs_high;
__u32 tx_max_coalesced_frames_high;
__u32 rate_sample_interval;
- __u32 dmac;
};
/**
diff --git a/ethtool.8.in b/ethtool.8.in
index 6ad3065..90ead41 100644
--- a/ethtool.8.in
+++ b/ethtool.8.in
@@ -165,7 +165,6 @@ ethtool \- query or control network driver and hardware settings
.BN tx\-usecs\-high
.BN tx\-frames\-high
.BN sample\-interval
-.BN dmac
.HP
.B ethtool \-g|\-\-show\-ring
.I devname
diff --git a/ethtool.c b/ethtool.c
index 1a2b7cc..c89b660 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -1337,7 +1337,6 @@ static int dump_coalesce(const struct ethtool_coalesce *ecoal)
"sample-interval: %u\n"
"pkt-rate-low: %u\n"
"pkt-rate-high: %u\n"
- "dmac: %u\n"
"\n"
"rx-usecs: %u\n"
"rx-frames: %u\n"
@@ -1363,7 +1362,6 @@ static int dump_coalesce(const struct ethtool_coalesce *ecoal)
ecoal->rate_sample_interval,
ecoal->pkt_rate_low,
ecoal->pkt_rate_high,
- ecoal->dmac,
ecoal->rx_coalesce_usecs,
ecoal->rx_max_coalesced_frames,
@@ -2071,7 +2069,6 @@ static int do_scoalesce(struct cmd_context *ctx)
int coal_adaptive_rx_wanted = -1;
int coal_adaptive_tx_wanted = -1;
s32 coal_sample_rate_wanted = -1;
- s32 coal_dmac_wanted = -1;
s32 coal_pkt_rate_low_wanted = -1;
s32 coal_pkt_rate_high_wanted = -1;
s32 coal_rx_usec_wanted = -1;
@@ -2097,8 +2094,6 @@ static int do_scoalesce(struct cmd_context *ctx)
&ecoal.use_adaptive_tx_coalesce },
{ "sample-interval", CMDL_S32, &coal_sample_rate_wanted,
&ecoal.rate_sample_interval },
- { "dmac", CMDL_S32, &coal_dmac_wanted,
- &ecoal.dmac },
{ "stats-block-usecs", CMDL_S32, &coal_stats_wanted,
&ecoal.stats_block_coalesce_usecs },
{ "pkt-rate-low", CMDL_S32, &coal_pkt_rate_low_wanted,
@@ -4794,8 +4789,7 @@ static const struct option {
" [rx-frames-high N]\n"
" [tx-usecs-high N]\n"
" [tx-frames-high N]\n"
- " [sample-interval N]\n"
- " [dmac N]\n" },
+ " [sample-interval N]\n" },
{ "-g|--show-ring", 1, do_gring, "Query RX/TX ring parameters" },
{ "-G|--set-ring", 1, do_sring, "Set RX/TX ring parameters",
" [ rx N ]\n"
--
2.5.0
^ permalink raw reply related
* [PATCH v3 2/3] ethtool-copy.h: sync with net-next
From: Scott Branden @ 2017-12-12 20:20 UTC (permalink / raw)
To: John W. Linville
Cc: BCM Kernel Feedback, Steve Lin, Michael Chan, netdev,
Paul Greenwalt, Stephen Hemminger, Scott Branden
In-Reply-To: <1513110003-10543-1-git-send-email-scott.branden@broadcom.com>
This covers kernel changes up to:
commit 40e44a1e669d078946f46853808a60d29e6f0885
Author: Scott Branden <scott.branden@broadcom.com>
Date: Thu Nov 30 11:35:59 2017 -0800
net: ethtool: add support for reset of AP inside NIC interface.
Add ETH_RESET_AP to reset the application processor(s) inside the NIC
interface.
Current ETH_RESET_MGMT supports a management processor inside this NIC.
This is typically used for remote NIC management purposes.
Application processors exist inside some SmartNICs to run various
applications inside the NIC processor - be it a simple algorithm without
an OS to as complex as hosting multiple VMs.
Signed-off-by: Scott Branden <scott.branden@broadcom.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Scott Branden <scott.branden@broadcom.com>
---
ethtool-copy.h | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 61 insertions(+), 5 deletions(-)
diff --git a/ethtool-copy.h b/ethtool-copy.h
index 06fc04c..f4e7bb2 100644
--- a/ethtool-copy.h
+++ b/ethtool-copy.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
* ethtool.h: Defines for Linux ethtool.
*
@@ -1236,6 +1237,47 @@ struct ethtool_per_queue_op {
char data[];
};
+/**
+ * struct ethtool_fecparam - Ethernet forward error correction(fec) parameters
+ * @cmd: Command number = %ETHTOOL_GFECPARAM or %ETHTOOL_SFECPARAM
+ * @active_fec: FEC mode which is active on porte
+ * @fec: Bitmask of supported/configured FEC modes
+ * @rsvd: Reserved for future extensions. i.e FEC bypass feature.
+ *
+ * Drivers should reject a non-zero setting of @autoneg when
+ * autoneogotiation is disabled (or not supported) for the link.
+ *
+ */
+struct ethtool_fecparam {
+ __u32 cmd;
+ /* bitmask of FEC modes */
+ __u32 active_fec;
+ __u32 fec;
+ __u32 reserved;
+};
+
+/**
+ * enum ethtool_fec_config_bits - flags definition of ethtool_fec_configuration
+ * @ETHTOOL_FEC_NONE: FEC mode configuration is not supported
+ * @ETHTOOL_FEC_AUTO: Default/Best FEC mode provided by driver
+ * @ETHTOOL_FEC_OFF: No FEC Mode
+ * @ETHTOOL_FEC_RS: Reed-Solomon Forward Error Detection mode
+ * @ETHTOOL_FEC_BASER: Base-R/Reed-Solomon Forward Error Detection mode
+ */
+enum ethtool_fec_config_bits {
+ ETHTOOL_FEC_NONE_BIT,
+ ETHTOOL_FEC_AUTO_BIT,
+ ETHTOOL_FEC_OFF_BIT,
+ ETHTOOL_FEC_RS_BIT,
+ ETHTOOL_FEC_BASER_BIT,
+};
+
+#define ETHTOOL_FEC_NONE (1 << ETHTOOL_FEC_NONE_BIT)
+#define ETHTOOL_FEC_AUTO (1 << ETHTOOL_FEC_AUTO_BIT)
+#define ETHTOOL_FEC_OFF (1 << ETHTOOL_FEC_OFF_BIT)
+#define ETHTOOL_FEC_RS (1 << ETHTOOL_FEC_RS_BIT)
+#define ETHTOOL_FEC_BASER (1 << ETHTOOL_FEC_BASER_BIT)
+
/* CMDs currently supported */
#define ETHTOOL_GSET 0x00000001 /* DEPRECATED, Get settings.
* Please use ETHTOOL_GLINKSETTINGS
@@ -1328,6 +1370,8 @@ struct ethtool_per_queue_op {
#define ETHTOOL_SLINKSETTINGS 0x0000004d /* Set ethtool_link_settings */
#define ETHTOOL_PHY_GTUNABLE 0x0000004e /* Get PHY tunable configuration */
#define ETHTOOL_PHY_STUNABLE 0x0000004f /* Set PHY tunable configuration */
+#define ETHTOOL_GFECPARAM 0x00000050 /* Get FEC settings */
+#define ETHTOOL_SFECPARAM 0x00000051 /* Set FEC settings */
/* compatibility with older code */
#define SPARC_ETH_GSET ETHTOOL_GSET
@@ -1382,9 +1426,12 @@ enum ethtool_link_mode_bit_indices {
ETHTOOL_LINK_MODE_10000baseLR_Full_BIT = 44,
ETHTOOL_LINK_MODE_10000baseLRM_Full_BIT = 45,
ETHTOOL_LINK_MODE_10000baseER_Full_BIT = 46,
- ETHTOOL_LINK_MODE_2500baseT_Full_BIT = 47,
- ETHTOOL_LINK_MODE_5000baseT_Full_BIT = 48,
+ ETHTOOL_LINK_MODE_2500baseT_Full_BIT = 47,
+ ETHTOOL_LINK_MODE_5000baseT_Full_BIT = 48,
+ ETHTOOL_LINK_MODE_FEC_NONE_BIT = 49,
+ ETHTOOL_LINK_MODE_FEC_RS_BIT = 50,
+ ETHTOOL_LINK_MODE_FEC_BASER_BIT = 51,
/* Last allowed bit for __ETHTOOL_LINK_MODE_LEGACY_MASK is bit
* 31. Please do NOT define any SUPPORTED_* or ADVERTISED_*
@@ -1393,7 +1440,7 @@ enum ethtool_link_mode_bit_indices {
*/
__ETHTOOL_LINK_MODE_LAST
- = ETHTOOL_LINK_MODE_5000baseT_Full_BIT,
+ = ETHTOOL_LINK_MODE_FEC_BASER_BIT,
};
#define __ETHTOOL_LINK_MODE_LEGACY_MASK(base_name) \
@@ -1484,13 +1531,17 @@ enum ethtool_link_mode_bit_indices {
* it was forced up into this mode or autonegotiated.
*/
-/* The forced speed, in units of 1Mb. All values 0 to INT_MAX are legal. */
+/* The forced speed, in units of 1Mb. All values 0 to INT_MAX are legal.
+ * Update drivers/net/phy/phy.c:phy_speed_to_str() and
+ * drivers/net/bonding/bond_3ad.c:__get_link_speed() when adding new values.
+ */
#define SPEED_10 10
#define SPEED_100 100
#define SPEED_1000 1000
#define SPEED_2500 2500
#define SPEED_5000 5000
#define SPEED_10000 10000
+#define SPEED_14000 14000
#define SPEED_20000 20000
#define SPEED_25000 25000
#define SPEED_40000 40000
@@ -1633,6 +1684,7 @@ enum ethtool_reset_flags {
ETH_RESET_PHY = 1 << 6, /* Transceiver/PHY */
ETH_RESET_RAM = 1 << 7, /* RAM shared between
* multiple components */
+ ETH_RESET_AP = 1 << 8, /* Application processor */
ETH_RESET_DEDICATED = 0x0000ffff, /* All components dedicated to
* this interface */
@@ -1701,6 +1753,8 @@ enum ethtool_reset_flags {
* %ethtool_link_mode_bit_indices for the link modes, and other
* link features that the link partner advertised through
* autonegotiation; 0 if unknown or not applicable. Read-only.
+ * @transceiver: Used to distinguish different possible PHY types,
+ * reported consistently by PHYLIB. Read-only.
*
* If autonegotiation is disabled, the speed and @duplex represent the
* fixed link mode and are writable if the driver supports multiple
@@ -1752,7 +1806,9 @@ struct ethtool_link_settings {
__u8 eth_tp_mdix;
__u8 eth_tp_mdix_ctrl;
__s8 link_mode_masks_nwords;
- __u32 reserved[8];
+ __u8 transceiver;
+ __u8 reserved1[3];
+ __u32 reserved[7];
__u32 link_mode_masks[0];
/* layout of link_mode_masks fields:
* __u32 map_supported[link_mode_masks_nwords];
--
2.5.0
^ permalink raw reply related
* [PATCH v3 3/3] ethtool: Add ETHTOOL_RESET support via --reset command
From: Scott Branden @ 2017-12-12 20:20 UTC (permalink / raw)
To: John W. Linville
Cc: BCM Kernel Feedback, Steve Lin, Michael Chan, netdev,
Paul Greenwalt, Stephen Hemminger, Scott Branden
In-Reply-To: <1513110003-10543-1-git-send-email-scott.branden@broadcom.com>
Add ETHTOOL_RESET support via --reset command.
ie. ethtool --reset DEVNAME <flagname(s)>
flagnames currently match the ETH_RESET_xxx names:
mgmt,irq,dma,filter,offload,mac,phy,ram,ap,dedicated,all
Add -shared onto end of components to specified shared version.
Alternatively, you can specific component bitfield directly using
ethtool --reset DEVNAME flags %x
Signed-off-by: Scott Branden <scott.branden@broadcom.com>
---
ethtool.8.in | 67 ++++++++++++++++++++++++++++++++++-
ethtool.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 179 insertions(+), 1 deletion(-)
diff --git a/ethtool.8.in b/ethtool.8.in
index 90ead41..7ca8bfe 100644
--- a/ethtool.8.in
+++ b/ethtool.8.in
@@ -354,6 +354,30 @@ ethtool \- query or control network driver and hardware settings
.B ethtool \-\-get\-phy\-tunable
.I devname
.RB [ downshift ]
+.HP
+.B ethtool \-\-reset
+.I devname
+.BN flags
+.RB [ mgmt ]
+.RB [ mgmt-shared ]
+.RB [ irq ]
+.RB [ irq-shared ]
+.RB [ dma ]
+.RB [ dma-shared ]
+.RB [ filter ]
+.RB [ filter-shared ]
+.RB [ offload ]
+.RB [ offload-shared ]
+.RB [ mac ]
+.RB [ mac-shared ]
+.RB [ phy ]
+.RB [ phy-shared ]
+.RB [ ram ]
+.RB [ ram-shared ]
+.RB [ ap ]
+.RB [ ap-shared ]
+.RB [ dedicated ]
+.RB [ all ]
.
.\" Adjust lines (i.e. full justification) and hyphenate.
.ad
@@ -1006,6 +1030,46 @@ Downshift is useful where cable does not have the 4 pairs instance.
Gets the PHY downshift count/status.
.RE
+.TP
+.B \-\-reset
+Reset hardware components specified by flags and components listed below
+.RS 4
+.TP
+.BI flags \ N
+Resets the components based on direct flags mask
+.TP
+.B mgmt
+Management processor
+.TP
+.B irq
+Interrupt requester
+.TP
+.B dma
+DMA engine
+.TP
+.B filter
+Filtering/flow direction
+.TP
+.B offload
+Protocol offload
+.TP
+.B mac
+Media access controller
+.TP
+.B phy
+Transceiver/PHY
+.TP
+.B ram
+RAM shared between multiple components
+.B ap
+Application Processor
+.TP
+.B dedicated
+All components dedicated to this interface
+.TP
+.B all
+All components used by this interface, even if shared
+.RE
.SH BUGS
Not supported (in part or whole) on all network drivers.
.SH AUTHOR
@@ -1023,7 +1087,8 @@ Andi Kleen,
Alexander Duyck,
Sucheta Chakraborty,
Jesse Brandeburg,
-Ben Hutchings.
+Ben Hutchings,
+Scott Branden.
.SH AVAILABILITY
.B ethtool
is available from
diff --git a/ethtool.c b/ethtool.c
index c89b660..09bcf91 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -4636,6 +4636,97 @@ static int do_get_phy_tunable(struct cmd_context *ctx)
return err;
}
+static __u32 parse_reset(char *val, __u32 bitset, char *arg, __u32 *data)
+{
+ __u32 bitval = 0;
+ int i;
+
+ /* Check for component match */
+ for (i = 0; val[i] != '\0'; i++)
+ if (arg[i] != val[i])
+ return 0;
+
+ /* Check if component has -shared specified or not */
+ if (arg[i] == '\0')
+ bitval = bitset;
+ else if (!strcmp(arg+i, "-shared"))
+ bitval = bitset << ETH_RESET_SHARED_SHIFT;
+
+ if (bitval) {
+ *data |= bitval;
+ return 1;
+ }
+ return 0;
+}
+
+static int do_reset(struct cmd_context *ctx)
+{
+ struct ethtool_value resetinfo;
+ __u32 data;
+ int argc = ctx->argc;
+ char **argp = ctx->argp;
+ int i;
+
+ if (argc == 0)
+ exit_bad_args();
+
+ data = 0;
+
+ for (i = 0; i < argc; i++) {
+ if (!strcmp(argp[i], "flags")) {
+ __u32 flags;
+
+ i++;
+ if (i >= argc)
+ exit_bad_args();
+ flags = strtoul(argp[i], NULL, 0);
+ if (flags == 0)
+ exit_bad_args();
+ else
+ data |= flags;
+ } else if (parse_reset("mgmt", ETH_RESET_MGMT,
+ argp[i], &data)) {
+ } else if (parse_reset("irq", ETH_RESET_IRQ,
+ argp[i], &data)) {
+ } else if (parse_reset("dma", ETH_RESET_DMA,
+ argp[i], &data)) {
+ } else if (parse_reset("filter", ETH_RESET_FILTER,
+ argp[i], &data)) {
+ } else if (parse_reset("offload", ETH_RESET_OFFLOAD,
+ argp[i], &data)) {
+ } else if (parse_reset("mac", ETH_RESET_MAC,
+ argp[i], &data)) {
+ } else if (parse_reset("phy", ETH_RESET_PHY,
+ argp[i], &data)) {
+ } else if (parse_reset("ram", ETH_RESET_RAM,
+ argp[i], &data)) {
+ } else if (parse_reset("ap", ETH_RESET_AP,
+ argp[i], &data)) {
+ } else if (!strcmp(argp[i], "dedicated")) {
+ data |= ETH_RESET_DEDICATED;
+ } else if (!strcmp(argp[i], "all")) {
+ data |= ETH_RESET_ALL;
+ } else {
+ exit_bad_args();
+ }
+ }
+
+ resetinfo.cmd = ETHTOOL_RESET;
+ resetinfo.data = data;
+ fprintf(stdout, "ETHTOOL_RESET 0x%x\n", resetinfo.data);
+
+ if (send_ioctl(ctx, &resetinfo)) {
+ perror("Cannot issue ETHTOOL_RESET");
+ return 1;
+ }
+
+ fprintf(stdout, "Components reset: 0x%x\n", data & ~resetinfo.data);
+ if (resetinfo.data)
+ fprintf(stdout, "Components not reset: 0x%x\n", resetinfo.data);
+
+ return 0;
+}
+
static int parse_named_bool(struct cmd_context *ctx, const char *name, u8 *on)
{
if (ctx->argc < 2)
@@ -4898,6 +4989,28 @@ static const struct option {
" [ downshift on|off [count N] ]\n"},
{ "--get-phy-tunable", 1, do_get_phy_tunable, "Get PHY tunable",
" [ downshift ]\n"},
+ { "--reset", 1, do_reset, "Reset components",
+ " [ flags %x ]\n"
+ " [ mgmt ]\n"
+ " [ mgmt-shared ]\n"
+ " [ irq ]\n"
+ " [ irq-shared ]\n"
+ " [ dma ]\n"
+ " [ dma-shared ]\n"
+ " [ filter ]\n"
+ " [ filter-shared ]\n"
+ " [ offload ]\n"
+ " [ offload-shared ]\n"
+ " [ mac ]\n"
+ " [ mac-shared ]\n"
+ " [ phy ]\n"
+ " [ phy-shared ]\n"
+ " [ ram ]\n"
+ " [ ram-shared ]\n"
+ " [ ap ]\n"
+ " [ ap-shared ]\n"
+ " [ dedicated ]\n"
+ " [ all ]\n"},
{ "-h|--help", 0, show_usage, "Show this help" },
{ "--version", 0, do_version, "Show version number" },
{}
--
2.5.0
^ permalink raw reply related
* [PATCH iproute2] Show 'external' link mode in output
From: Phil Dibowitz @ 2017-12-12 20:23 UTC (permalink / raw)
To: netdev; +Cc: phild
Recently `external` support was added to the tunnel drivers, but there is no way
to introspect this from userspace. This adds support for that.
Now `ip -details link` shows it:
```
7: tunl60@NONE: <NOARP> mtu 1452 qdisc noop state DOWN mode DEFAULT group
default qlen 1
link/tunnel6 :: brd :: promiscuity 0
ip6tnl external any remote :: local :: encaplimit 0 hoplimit 0 tclass 0x00 flowlabel 0x00000 (flowinfo 0x00000000) addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
```
Signed-off-by: Phil Dibowitz <phil@ipom.com>
---
ip/link_ip6tnl.c | 3 +++
ip/link_iptnl.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/ip/link_ip6tnl.c b/ip/link_ip6tnl.c
index 43287ab..5d0efc8 100644
--- a/ip/link_ip6tnl.c
+++ b/ip/link_ip6tnl.c
@@ -345,6 +345,9 @@ static void ip6tunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb
if (!tb)
return;
+ if (tb[IFLA_IPTUN_COLLECT_METADATA])
+ print_bool(PRINT_ANY, "external", "external ", true);
+
if (tb[IFLA_IPTUN_FLAGS])
flags = rta_getattr_u32(tb[IFLA_IPTUN_FLAGS]);
diff --git a/ip/link_iptnl.c b/ip/link_iptnl.c
index 4940b8b..e345b5c 100644
--- a/ip/link_iptnl.c
+++ b/ip/link_iptnl.c
@@ -393,6 +393,9 @@ static void iptunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[
if (!tb)
return;
+ if (tb[IFLA_IPTUN_COLLECT_METADATA])
+ print_bool(PRINT_ANY, "external", "external ", true);
+
if (tb[IFLA_IPTUN_REMOTE]) {
unsigned int addr = rta_getattr_u32(tb[IFLA_IPTUN_REMOTE]);
--
2.9.5
^ permalink raw reply related
* Re: [PATCHv2 1/3] dt-bindings: net: Add DT bindings for Socionext Netsec
From: Andrew Lunn @ 2017-12-12 20:37 UTC (permalink / raw)
To: jassisinghbrar-Re5JQEeQqe8AvxtiuMwx3w
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA,
davem-fT/PcQaiUtIeIZ0/mPfg9Q,
arnd.bergmann-QSEj5FYQhm4dnm+yROfE0A,
ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
Jassi Brar
In-Reply-To: <1513098921-21042-1-git-send-email-jassisinghbrar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
On Tue, Dec 12, 2017 at 10:45:21PM +0530, jassisinghbrar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
> From: Jassi Brar <jassisinghbrar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>
> This patch adds documentation for Device-Tree bindings for the
> Socionext NetSec Controller driver.
>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> Signed-off-by: Jassi Brar <jaswinder.singh-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
> .../devicetree/bindings/net/socionext-netsec.txt | 43 ++++++++++++++++++++++
> 1 file changed, 43 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/net/socionext-netsec.txt
>
> diff --git a/Documentation/devicetree/bindings/net/socionext-netsec.txt b/Documentation/devicetree/bindings/net/socionext-netsec.txt
> new file mode 100644
> index 0000000..4695969
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/socionext-netsec.txt
> @@ -0,0 +1,45 @@
> +* Socionext NetSec Ethernet Controller IP
> +
> +Required properties:
> +- compatible: Should be "socionext,synquacer-netsec"
> +- reg: Address and length of the control register area, followed by the
> + address and length of the EEPROM holding the MAC address and
> + microengine firmware
> +- interrupts: Should contain ethernet controller interrupt
> +- clocks: phandle to the PHY reference clock, and any other clocks to be
> + switched by runtime_pm
> +- clock-names: Required only if more than a single clock is listed in 'clocks'.
> + The PHY reference clock must be named 'phy_refclk'
> +- phy-mode: See ethernet.txt file in the same directory
> +- phy-handle: phandle to select child phy
> +
> +Optional properties: (See ethernet.txt file in the same directory)
> +- dma-coherent: Boolean property, must only be present if memory
> + accesses performed by the device are cache coherent
> +- local-mac-address
> +- mac-address
> +- max-speed
> +- max-frame-size
> +
> +Required properties for the child phy:
> +- reg: phy address
Hi Jassi
Just reference phy.txt
> +
> +Example:
> + eth0: netsec@522D0000 {
> + compatible = "socionext,synquacer-netsec";
> + reg = <0 0x522D0000 0x0 0x10000>, <0 0x10000000 0x0 0x10000>;
> + interrupts = <GIC_SPI 176 IRQ_TYPE_LEVEL_HIGH>;
> + clocks = <&clk_netsec>;
> + phy-mode = "rgmii";
> + max-speed = <1000>;
> + max-frame-size = <9000>;
> + phy-handle = <ðphy0>;
> +
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
Please add an mdio node here, and list all the phys and possibly
Ethernet switches as children of it.
Andrew
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCHv2 2/3] net: socionext: Add Synquacer NetSec driver
From: Andrew Lunn @ 2017-12-12 20:44 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: Jassi Brar,
<netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
David S. Miller, Arnd Bergmann, Rob Herring, Mark Rutland,
Jassi Brar
In-Reply-To: <CAKv+Gu-6gb10VromMaTJkzpu1DovDO7B5-GWEQPs04qAG=2ksw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
> > +static int netsec_register_mdio(struct netsec_priv *priv, u32 phy_addr)
> > +{
> > + struct mii_bus *bus;
> > + int ret;
> > +
> > + bus = devm_mdiobus_alloc(priv->dev);
> > + if (!bus)
> > + return -ENOMEM;
> > +
> > + snprintf(bus->id, MII_BUS_ID_SIZE, "%s", dev_name(priv->dev));
> > + bus->priv = priv;
> > + bus->name = "SNI NETSEC MDIO";
> > + bus->read = netsec_phy_read;
> > + bus->write = netsec_phy_write;
> > + bus->parent = priv->dev;
> > + priv->mii_bus = bus;
> > +
> > + if (dev_of_node(priv->dev)) {
> > + ret = of_mdiobus_register(bus, dev_of_node(priv->dev));
> > + if (ret) {
> > + dev_err(priv->dev, "mdiobus register err(%d)\n", ret);
> > + return ret;
> > + }
> > + } else {
> > + /* Mask out all PHYs from auto probing. */
> > + bus->phy_mask = ~0;
> > + ret = mdiobus_register(bus);
> > + if (ret) {
> > + dev_err(priv->dev, "mdiobus register err(%d)\n", ret);
> > + return ret;
> > + }
> > +
> > + priv->phydev = get_phy_device(priv->mii_bus, phy_addr, false);
> > + if (IS_ERR(priv->phydev)) {
> > + ret = PTR_ERR(priv->phydev);
> > + dev_err(priv->dev, "get_phy_device err(%d)\n", ret);
> > + priv->phydev = NULL;
> > + return -ENODEV;
> > + }
> > +
> > + ret = phy_device_register(priv->phydev);
> > + if (ret)
> > + dev_err(priv->dev,
> > + "phy_device_register err(%d)\n", ret);
You should unregister the mdio bus here.
> > + }
> > +
> > + return ret;
> > +}
Andrew
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCHv2 2/3] net: socionext: Add Synquacer NetSec driver
From: Andrew Lunn @ 2017-12-12 20:48 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: Jassi Brar,
<netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
David S. Miller, Arnd Bergmann, Rob Herring, Mark Rutland,
Jassi Brar
In-Reply-To: <CAKv+Gu-6gb10VromMaTJkzpu1DovDO7B5-GWEQPs04qAG=2ksw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
> > +static int netsec_mac_update_to_phy_state(struct netsec_priv *priv)
> > +{
> > + struct phy_device *phydev = priv->ndev->phydev;
> > + u32 value = 0;
> > +
> > + value = phydev->duplex ? NETSEC_GMAC_MCR_REG_FULL_DUPLEX_COMMON :
> > + NETSEC_GMAC_MCR_REG_HALF_DUPLEX_COMMON;
> > +
> > + if (phydev->speed != SPEED_1000)
> > + value |= NETSEC_MCR_PS;
> > +
> > + if (priv->phy_interface != PHY_INTERFACE_MODE_GMII &&
> > + phydev->speed == SPEED_100)
> > + value |= NETSEC_GMAC_MCR_REG_FES;
> > +
> > + value |= NETSEC_GMAC_MCR_REG_CST | NETSEC_GMAC_MCR_REG_JE;
> > +
> > + if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII)
> > + value |= NETSEC_GMAC_MCR_REG_IBN;
phy_interface_mode_is_rgmii() ??
Andrew
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH net-next] net: dsa: lan9303: Introduce lan9303_read_wait
From: Egil Hjelmeland @ 2017-12-12 20:59 UTC (permalink / raw)
To: Vivien Didelot, andrew, f.fainelli, netdev, linux-kernel
In-Reply-To: <87o9n34y5j.fsf@weeman.i-did-not-set--mail-host-address--so-tickle-me>
Hi Vivien.
Den 12. des. 2017 19:08, skrev Vivien Didelot:
> Hi Egil,
>
> Egil Hjelmeland <privat@egil-hjelmeland.no> writes:
>
>> Simplify lan9303_indirect_phy_wait_for_completion()
>> and lan9303_switch_wait_for_completion() by using a new function
>> lan9303_read_wait()
>>
>> Signed-off-by: Egil Hjelmeland <privat@egil-hjelmeland.no>
>> ---
>> drivers/net/dsa/lan9303-core.c | 59 +++++++++++++++++++-----------------------
>> 1 file changed, 27 insertions(+), 32 deletions(-)
>>
>> diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
>> index c1b004fa64d9..96ccce0939d3 100644
>> --- a/drivers/net/dsa/lan9303-core.c
>> +++ b/drivers/net/dsa/lan9303-core.c
>> @@ -249,6 +249,29 @@ static int lan9303_read(struct regmap *regmap, unsigned int offset, u32 *reg)
>> return -EIO;
>> }
>>
>> +/* Wait a while until mask & reg == value. Otherwise return timeout. */
>> +static int lan9303_read_wait(struct lan9303 *chip, int offset, int mask,
>> + char value)
>> +{
>> + int i;
>> +
>> + for (i = 0; i < 25; i++) {
>> + u32 reg;
>> + int ret;
>> +
>> + ret = lan9303_read(chip->regmap, offset, ®);
>> + if (ret) {
>> + dev_err(chip->dev, "%s failed to read offset %d: %d\n",
>> + __func__, offset, ret);
>> + return ret;
>> + }
>> + if ((reg & mask) == value)
>> + return 0;
>
> That is weird to mix int, u32 and char for mask checking. I suggest you
> to use the u32 type as well for both mask and value.
>
Good catch. Will fix that. Same with lan9303_csr_reg_wait() then.
> Looking at how lan9303_read_wait is called, the value argument doesn't
> seem necessary. You can directly return 0 if (!(reg & mask)).
>
The idea was to make in more general usable, in case one need to wait
for a bit to be set. But I don't have any example from the datasheet
that needs it, so I could take "value" away.
>> + usleep_range(1000, 2000);
>> + }
>> + return -ETIMEDOUT;
>
> A newline before the return statment would be appreciated.
>
Ok.
>> +}
>> +
>> static int lan9303_virt_phy_reg_read(struct lan9303 *chip, int regnum)
>> {
>> int ret;
>> @@ -274,22 +297,8 @@ static int lan9303_virt_phy_reg_write(struct lan9303 *chip, int regnum, u16 val)
>>
>> static int lan9303_indirect_phy_wait_for_completion(struct lan9303 *chip)
>> {
>> - int ret, i;
>> - u32 reg;
>> -
>> - for (i = 0; i < 25; i++) {
>> - ret = lan9303_read(chip->regmap, LAN9303_PMI_ACCESS, ®);
>> - if (ret) {
>> - dev_err(chip->dev,
>> - "Failed to read pmi access status: %d\n", ret);
>> - return ret;
>> - }
>> - if (!(reg & LAN9303_PMI_ACCESS_MII_BUSY))
>> - return 0;
>> - usleep_range(1000, 2000);
>> - }
>> -
>> - return -EIO;
>> + return lan9303_read_wait(chip, LAN9303_PMI_ACCESS,
>> + LAN9303_PMI_ACCESS_MII_BUSY, 0);
>> }
>>
>> static int lan9303_indirect_phy_read(struct lan9303 *chip, int addr, int regnum)
>> @@ -366,22 +375,8 @@ EXPORT_SYMBOL_GPL(lan9303_indirect_phy_ops);
>>
>> static int lan9303_switch_wait_for_completion(struct lan9303 *chip)
>> {
>> - int ret, i;
>> - u32 reg;
>> -
>> - for (i = 0; i < 25; i++) {
>> - ret = lan9303_read(chip->regmap, LAN9303_SWITCH_CSR_CMD, ®);
>> - if (ret) {
>> - dev_err(chip->dev,
>> - "Failed to read csr command status: %d\n", ret);
>> - return ret;
>> - }
>> - if (!(reg & LAN9303_SWITCH_CSR_CMD_BUSY))
>> - return 0;
>> - usleep_range(1000, 2000);
>> - }
>> -
>> - return -EIO;
>> + return lan9303_read_wait(chip, LAN9303_SWITCH_CSR_CMD,
>> + LAN9303_SWITCH_CSR_CMD_BUSY, 0);
>> }
>>
>> static int lan9303_write_switch_reg(struct lan9303 *chip, u16 regnum, u32 val)
>
>
> Thanks,
>
> Vivien
>
Thanks, Egil
^ permalink raw reply
* Re: KASAN: stack-out-of-bounds Read in xfrm_state_find (3)
From: Eric Biggers @ 2017-12-12 21:00 UTC (permalink / raw)
To: Steffen Klassert
Cc: syzbot, davem, herbert, linux-kernel, netdev, syzkaller-bugs
In-Reply-To: <20171201072743.47ztbmrql7ub327u@gauss3.secunet.de>
Hi Steffen,
On Fri, Dec 01, 2017 at 08:27:43AM +0100, Steffen Klassert wrote:
> On Wed, Nov 22, 2017 at 08:05:00AM -0800, syzbot wrote:
> > syzkaller has found reproducer for the following crash on
> > 0c86a6bd85ff0629cd2c5141027fc1c8bb6cde9c
> > git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/master
> > compiler: gcc (GCC) 7.1.1 20170620
> > .config is attached
> > Raw console output is attached.
> > C reproducer is attached
> > syzkaller reproducer is attached. See https://goo.gl/kgGztJ
> > for information about syzkaller reproducers
> >
> >
> > BUG: KASAN: stack-out-of-bounds in xfrm_state_find+0x30fc/0x3230
> > net/xfrm/xfrm_state.c:1051
> > Read of size 4 at addr ffff8801ccaa7af8 by task syzkaller231684/3045
>
> The patch below should fix this. I plan to apply it to the ipsec tree
> after some advanced testing.
>
> Subject: [PATCH RFC] xfrm: Fix stack-out-of-bounds with misconfigured transport
> mode policies.
>
Are you still planning to apply this? syzbot is still hitting this bug.
Eric
^ permalink raw reply
* [PATCH v3 net-next] net: ethernet: ti: cpdma: correct error handling for chan create
From: Ivan Khoronzhuk @ 2017-12-12 21:06 UTC (permalink / raw)
To: grygorii.strashko
Cc: netdev, davem, linux-omap, linux-kernel, Ivan Khoronzhuk
It's not correct to return NULL when that is actually an error and
function returns errors in any other wrong case. In the same time,
the cpsw driver and davinci emac doesn't check error case while
creating channel and it can miss actual error. Also remove WARNs
replacing them on dev_err msgs.
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
drivers/net/ethernet/ti/cpsw.c | 12 +++++++++---
drivers/net/ethernet/ti/davinci_cpdma.c | 2 +-
drivers/net/ethernet/ti/davinci_emac.c | 11 +++++++++--
3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index a60a378..3c85a08 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -3065,10 +3065,16 @@ static int cpsw_probe(struct platform_device *pdev)
}
cpsw->txv[0].ch = cpdma_chan_create(cpsw->dma, 0, cpsw_tx_handler, 0);
+ if (IS_ERR(cpsw->txv[0].ch)) {
+ dev_err(priv->dev, "error initializing tx dma channel\n");
+ ret = PTR_ERR(cpsw->txv[0].ch);
+ goto clean_dma_ret;
+ }
+
cpsw->rxv[0].ch = cpdma_chan_create(cpsw->dma, 0, cpsw_rx_handler, 1);
- if (WARN_ON(!cpsw->rxv[0].ch || !cpsw->txv[0].ch)) {
- dev_err(priv->dev, "error initializing dma channels\n");
- ret = -ENOMEM;
+ if (IS_ERR(cpsw->rxv[0].ch)) {
+ dev_err(priv->dev, "error initializing rx dma channel\n");
+ ret = PTR_ERR(cpsw->rxv[0].ch);
goto clean_dma_ret;
}
diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c
index e4d6edf..6f9173f 100644
--- a/drivers/net/ethernet/ti/davinci_cpdma.c
+++ b/drivers/net/ethernet/ti/davinci_cpdma.c
@@ -893,7 +893,7 @@ struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num,
chan_num = rx_type ? rx_chan_num(chan_num) : tx_chan_num(chan_num);
if (__chan_linear(chan_num) >= ctlr->num_chan)
- return NULL;
+ return ERR_PTR(-EINVAL);
chan = devm_kzalloc(ctlr->dev, sizeof(*chan), GFP_KERNEL);
if (!chan)
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index f58c0c6..abceea8 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -1870,10 +1870,17 @@ static int davinci_emac_probe(struct platform_device *pdev)
priv->txchan = cpdma_chan_create(priv->dma, EMAC_DEF_TX_CH,
emac_tx_handler, 0);
+ if (IS_ERR(priv->txchan)) {
+ dev_err(&pdev->dev, "error initializing tx dma channel\n");
+ rc = PTR_ERR(priv->txchan);
+ goto no_cpdma_chan;
+ }
+
priv->rxchan = cpdma_chan_create(priv->dma, EMAC_DEF_RX_CH,
emac_rx_handler, 1);
- if (WARN_ON(!priv->txchan || !priv->rxchan)) {
- rc = -ENOMEM;
+ if (IS_ERR(priv->rxchan)) {
+ dev_err(&pdev->dev, "error initializing rx dma channel\n");
+ rc = PTR_ERR(priv->rxchan);
goto no_cpdma_chan;
}
--
2.7.4
^ permalink raw reply related
* [PATH net-next] tcp: pause Fast Open globally after third consecutive timeout
From: Yuchung Cheng @ 2017-12-12 21:10 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, ncardwell, weiwan, cpaasch, ddamjanovic,
mcmanus, Yuchung Cheng
Prior to this patch, active Fast Open is paused on a specific
destination IP address if the previous connections to the
IP address have experienced recurring timeouts . But recent
experiments by Microsoft (https://goo.gl/cykmn7) and Mozilla
browsers indicate the isssue is often caused by broken middle-boxes
sitting close to the client. Therefore it is much better user
experience if Fast Open is disabled out-right globally to avoid
experiencing further timeouts on connections toward other
destinations.
This patch changes the destination-IP disablement to global
disablement if a connection experiencing recurring timeouts
or aborts due to timeout. Repeated incidents would still
exponentially increase the pause time, starting from an hour.
This is extremely conservative but an unfortunate compromise to
minimize bad experience due to broken middle-boxes.
Reported-by: Dragana Damjanovic <ddamjanovic@mozilla.com>
Reported-by: Patrick McManus <mcmanus@ducksong.com>
Signed-off-by: Yuchung Cheng <ycheng@google.com>
Reviewed-by: Wei Wang <weiwan@google.com>
Reviewed-by: Neal Cardwell <ncardwell@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
---
Documentation/networking/ip-sysctl.txt | 1 +
include/net/tcp.h | 5 ++---
net/ipv4/tcp_fastopen.c | 30 ++++++++++++++++++++----------
net/ipv4/tcp_metrics.c | 5 +----
net/ipv4/tcp_timer.c | 17 +----------------
5 files changed, 25 insertions(+), 33 deletions(-)
diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
index 46c7e1085efc..3f2c40d8e6aa 100644
--- a/Documentation/networking/ip-sysctl.txt
+++ b/Documentation/networking/ip-sysctl.txt
@@ -606,6 +606,7 @@ tcp_fastopen_blackhole_timeout_sec - INTEGER
This time period will grow exponentially when more blackhole issues
get detected right after Fastopen is re-enabled and will reset to
initial value when the blackhole issue goes away.
+ 0 to disable the blackhole detection.
By default, it is set to 1hr.
tcp_syn_retries - INTEGER
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 3c3744e52cd1..6939e69d3c37 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1507,8 +1507,7 @@ int tcp_md5_hash_key(struct tcp_md5sig_pool *hp,
/* From tcp_fastopen.c */
void tcp_fastopen_cache_get(struct sock *sk, u16 *mss,
- struct tcp_fastopen_cookie *cookie, int *syn_loss,
- unsigned long *last_syn_loss);
+ struct tcp_fastopen_cookie *cookie);
void tcp_fastopen_cache_set(struct sock *sk, u16 mss,
struct tcp_fastopen_cookie *cookie, bool syn_lost,
u16 try_exp);
@@ -1546,7 +1545,7 @@ extern unsigned int sysctl_tcp_fastopen_blackhole_timeout;
void tcp_fastopen_active_disable(struct sock *sk);
bool tcp_fastopen_active_should_disable(struct sock *sk);
void tcp_fastopen_active_disable_ofo_check(struct sock *sk);
-void tcp_fastopen_active_timeout_reset(void);
+void tcp_fastopen_active_detect_blackhole(struct sock *sk, bool expired);
/* Latencies incurred by various limits for a sender. They are
* chronograph-like stats that are mutually exclusive.
diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
index 78c192ee03a4..018a48477355 100644
--- a/net/ipv4/tcp_fastopen.c
+++ b/net/ipv4/tcp_fastopen.c
@@ -379,18 +379,9 @@ struct sock *tcp_try_fastopen(struct sock *sk, struct sk_buff *skb,
bool tcp_fastopen_cookie_check(struct sock *sk, u16 *mss,
struct tcp_fastopen_cookie *cookie)
{
- unsigned long last_syn_loss = 0;
const struct dst_entry *dst;
- int syn_loss = 0;
- tcp_fastopen_cache_get(sk, mss, cookie, &syn_loss, &last_syn_loss);
-
- /* Recurring FO SYN losses: no cookie or data in SYN */
- if (syn_loss > 1 &&
- time_before(jiffies, last_syn_loss + (60*HZ << syn_loss))) {
- cookie->len = -1;
- return false;
- }
+ tcp_fastopen_cache_get(sk, mss, cookie);
/* Firewall blackhole issue check */
if (tcp_fastopen_active_should_disable(sk)) {
@@ -448,6 +439,8 @@ EXPORT_SYMBOL(tcp_fastopen_defer_connect);
* following circumstances:
* 1. client side TFO socket receives out of order FIN
* 2. client side TFO socket receives out of order RST
+ * 3. client side TFO socket has timed out three times consecutively during
+ * or after handshake
* We disable active side TFO globally for 1hr at first. Then if it
* happens again, we disable it for 2h, then 4h, 8h, ...
* And we reset the timeout back to 1hr when we see a successful active
@@ -524,3 +517,20 @@ void tcp_fastopen_active_disable_ofo_check(struct sock *sk)
dst_release(dst);
}
}
+
+void tcp_fastopen_active_detect_blackhole(struct sock *sk, bool expired)
+{
+ u32 timeouts = inet_csk(sk)->icsk_retransmits;
+ struct tcp_sock *tp = tcp_sk(sk);
+
+ /* Broken middle-boxes may black-hole Fast Open connection during or
+ * even after the handshake. Be extremely conservative and pause
+ * Fast Open globally after hitting the third consecutive timeout or
+ * exceeding the configured timeout limit.
+ */
+ if ((tp->syn_fastopen || tp->syn_data || tp->syn_data_acked) &&
+ (timeouts == 2 || (timeouts < 2 && expired))) {
+ tcp_fastopen_active_disable(sk);
+ NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPFASTOPENACTIVEFAIL);
+ }
+}
diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
index 7097f92d16e5..759e6bc8327b 100644
--- a/net/ipv4/tcp_metrics.c
+++ b/net/ipv4/tcp_metrics.c
@@ -546,8 +546,7 @@ bool tcp_peer_is_proven(struct request_sock *req, struct dst_entry *dst)
static DEFINE_SEQLOCK(fastopen_seqlock);
void tcp_fastopen_cache_get(struct sock *sk, u16 *mss,
- struct tcp_fastopen_cookie *cookie,
- int *syn_loss, unsigned long *last_syn_loss)
+ struct tcp_fastopen_cookie *cookie)
{
struct tcp_metrics_block *tm;
@@ -564,8 +563,6 @@ void tcp_fastopen_cache_get(struct sock *sk, u16 *mss,
*cookie = tfom->cookie;
if (cookie->len <= 0 && tfom->try_exp == 1)
cookie->exp = true;
- *syn_loss = tfom->syn_loss;
- *last_syn_loss = *syn_loss ? tfom->last_syn_loss : 0;
} while (read_seqretry(&fastopen_seqlock, seq));
}
rcu_read_unlock();
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 16df6dd44b98..c9a63417af48 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -183,11 +183,6 @@ static int tcp_write_timeout(struct sock *sk)
if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) {
if (icsk->icsk_retransmits) {
dst_negative_advice(sk);
- if (tp->syn_fastopen || tp->syn_data)
- tcp_fastopen_cache_set(sk, 0, NULL, true, 0);
- if (tp->syn_data && icsk->icsk_retransmits == 1)
- NET_INC_STATS(sock_net(sk),
- LINUX_MIB_TCPFASTOPENACTIVEFAIL);
} else if (!tp->syn_data && !tp->syn_fastopen) {
sk_rethink_txhash(sk);
}
@@ -195,17 +190,6 @@ static int tcp_write_timeout(struct sock *sk)
expired = icsk->icsk_retransmits >= retry_until;
} else {
if (retransmits_timed_out(sk, net->ipv4.sysctl_tcp_retries1, 0)) {
- /* Some middle-boxes may black-hole Fast Open _after_
- * the handshake. Therefore we conservatively disable
- * Fast Open on this path on recurring timeouts after
- * successful Fast Open.
- */
- if (tp->syn_data_acked) {
- tcp_fastopen_cache_set(sk, 0, NULL, true, 0);
- if (icsk->icsk_retransmits == net->ipv4.sysctl_tcp_retries1)
- NET_INC_STATS(sock_net(sk),
- LINUX_MIB_TCPFASTOPENACTIVEFAIL);
- }
/* Black hole detection */
tcp_mtu_probing(icsk, sk);
@@ -228,6 +212,7 @@ static int tcp_write_timeout(struct sock *sk)
expired = retransmits_timed_out(sk, retry_until,
icsk->icsk_user_timeout);
}
+ tcp_fastopen_active_detect_blackhole(sk, expired);
if (expired) {
/* Has it gone just too far? */
tcp_write_err(sk);
--
2.15.1.424.g9478a66081-goog
^ permalink raw reply related
* Re: [PATCH] veth: Optionally pad packets to minimum Ethernet length
From: Cong Wang @ 2017-12-12 21:11 UTC (permalink / raw)
To: Ed Swierk
Cc: Linux Kernel Network Developers, Benjamin Warren, Keith Holleman
In-Reply-To: <1513095191-127313-1-git-send-email-eswierk@skyportsystems.com>
On Tue, Dec 12, 2017 at 8:13 AM, Ed Swierk <eswierk@skyportsystems.com> wrote:
> Most physical Ethernet devices pad short packets to the minimum length
> of 64 bytes (including FCS) on transmit. It can be useful to simulate
> this behavior when debugging a problem that results from it (such as
> incorrect L4 checksum calculation).
>
> Padding is unnecessary for most applications so leave it off by
> default. Enable padding only when the otherwise unused IFF_AUTOMEDIA
> flag is set (e.g. by writing 0x5003 to flags in sysfs).
This doesn't make sense, why should veth hot path be punished for
such an unusual flag which it doesn't care? Also, why should we allow
setting this flag via sysfs for veth from the beginning?
^ permalink raw reply
* Re: [REGRESSION][4.13.y][4.14.y][v4.15.y] net: reduce skb_warn_bad_offload() noise
From: Greg KH @ 2017-12-12 21:18 UTC (permalink / raw)
To: David Miller
Cc: willemdebruijn.kernel, joseph.salisbury, edumazet, dvyukov,
willemb, daniel, jakub.kicinski, linux, john.fastabend, me,
idosch, netdev, linux-kernel, stable, 1715609
In-Reply-To: <20171212.091011.185992457624793318.davem@davemloft.net>
On Tue, Dec 12, 2017 at 09:10:11AM -0500, David Miller wrote:
> From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
> Date: Mon, 11 Dec 2017 16:56:56 -0500
>
> > On Mon, Dec 11, 2017 at 4:44 PM, Greg Kroah-Hartman
> > <gregkh@linuxfoundation.org> wrote:
> >> On Mon, Dec 11, 2017 at 04:25:26PM -0500, Willem de Bruijn wrote:
> >>> Note that UFO was removed in 4.14 and that skb_warn_bad_offload
> >>> can happen for various types of packets, so there may be multiple
> >>> independent bug reports. I'm investigating two other non-UFO reports
> >>> just now.
> >>
> >> Meta-comment, now that UFO is gone from mainline, I'm wondering if I
> >> should just delete it from 4.4 and 4.9 as well. Any objections for
> >> that? I'd like to make it easy to maintain these kernels for a while,
> >> and having them diverge like this, with all of the issues around UFO,
> >> seems like it will just make life harder for myself if I leave it in.
> >>
> >> Any opinions?
> >
> > Some of that removal had to be reverted with commit 0c19f846d582
> > ("net: accept UFO datagrams from tuntap and packet") for VM live
> > migration between kernels.
> >
> > Any backports probably should squash that in at the least. Just today
> > another thread discussed that that patch may not address all open
> > issues still, so it may be premature to backport at this point.
> > http://lkml.kernel.org/r/<d71df64e-e65f-4db4-6f2e-c002c15fcbe4@01019freenet.de>
>
> I would probably discourage backporting the UFO removal, at least for
> now.
Ok, thanks for letting me know, I'll ask again in 6 months or so :)
greg k-h
^ permalink raw reply
* Re: [PATCH 2/4] sctp: Add ip option support
From: Paul Moore @ 2017-12-12 21:33 UTC (permalink / raw)
To: Marcelo Ricardo Leitner, Richard Haines
Cc: selinux, netdev, linux-sctp, linux-security-module, Vlad Yasevich,
nhorman, Stephen Smalley, Eric Paris
In-Reply-To: <20171212160800.GE3532@localhost.localdomain>
On Tue, Dec 12, 2017 at 11:08 AM, Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
> Hi Richard,
>
> On Mon, Nov 27, 2017 at 07:31:21PM +0000, Richard Haines wrote:
> ...
>> --- a/net/sctp/socket.c
>> +++ b/net/sctp/socket.c
>> @@ -3123,8 +3123,10 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, unsigned
>>
>> if (asoc) {
>> if (val == 0) {
>> + struct sctp_af *af = sp->pf->af;
>> val = asoc->pathmtu;
>> - val -= sp->pf->af->net_header_len;
>> + val -= af->ip_options_len(asoc->base.sk);
>> + val -= af->net_header_len;
>> val -= sizeof(struct sctphdr) +
>> sizeof(struct sctp_data_chunk);
>> }
>
> Right below here there is a call to sctp_frag_point(). That function
> also needs this tweak.
>
> Yes, we should simplify all these calculations. I have a patch to use
> sctp_frag_point on where it is currently recalculating it on
> sctp_datamsg_from_user(), but probably should include other places as
> well.
FYI: Richard let me know he is occupied with another project at the
moment and likely won't be able to do another respin until next week
at the earliest.
--
paul moore
www.paul-moore.com
^ permalink raw reply
* Re: [PATCH v3 net-next] net: ethernet: ti: cpdma: correct error handling for chan create
From: Grygorii Strashko @ 2017-12-12 21:41 UTC (permalink / raw)
To: Ivan Khoronzhuk; +Cc: netdev, davem, linux-omap, linux-kernel
In-Reply-To: <1513112795-20045-1-git-send-email-ivan.khoronzhuk@linaro.org>
On 12/12/2017 03:06 PM, Ivan Khoronzhuk wrote:
> It's not correct to return NULL when that is actually an error and
> function returns errors in any other wrong case. In the same time,
> the cpsw driver and davinci emac doesn't check error case while
> creating channel and it can miss actual error. Also remove WARNs
> replacing them on dev_err msgs.
>
> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
> ---
> drivers/net/ethernet/ti/cpsw.c | 12 +++++++++---
> drivers/net/ethernet/ti/davinci_cpdma.c | 2 +-
> drivers/net/ethernet/ti/davinci_emac.c | 11 +++++++++--
> 3 files changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
> index a60a378..3c85a08 100644
> --- a/drivers/net/ethernet/ti/cpsw.c
> +++ b/drivers/net/ethernet/ti/cpsw.c
> @@ -3065,10 +3065,16 @@ static int cpsw_probe(struct platform_device *pdev)
> }
>
> cpsw->txv[0].ch = cpdma_chan_create(cpsw->dma, 0, cpsw_tx_handler, 0);
> + if (IS_ERR(cpsw->txv[0].ch)) {
> + dev_err(priv->dev, "error initializing tx dma channel\n");
> + ret = PTR_ERR(cpsw->txv[0].ch);
> + goto clean_dma_ret;
> + }
> +
> cpsw->rxv[0].ch = cpdma_chan_create(cpsw->dma, 0, cpsw_rx_handler, 1);
> - if (WARN_ON(!cpsw->rxv[0].ch || !cpsw->txv[0].ch)) {
> - dev_err(priv->dev, "error initializing dma channels\n");
> - ret = -ENOMEM;
> + if (IS_ERR(cpsw->rxv[0].ch)) {
> + dev_err(priv->dev, "error initializing rx dma channel\n");
> + ret = PTR_ERR(cpsw->rxv[0].ch);
> goto clean_dma_ret;
> }
>
> diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c
> index e4d6edf..6f9173f 100644
> --- a/drivers/net/ethernet/ti/davinci_cpdma.c
> +++ b/drivers/net/ethernet/ti/davinci_cpdma.c
> @@ -893,7 +893,7 @@ struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num,
> chan_num = rx_type ? rx_chan_num(chan_num) : tx_chan_num(chan_num);
>
> if (__chan_linear(chan_num) >= ctlr->num_chan)
> - return NULL;
> + return ERR_PTR(-EINVAL);
>
> chan = devm_kzalloc(ctlr->dev, sizeof(*chan), GFP_KERNEL);
> if (!chan)
> diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
> index f58c0c6..abceea8 100644
> --- a/drivers/net/ethernet/ti/davinci_emac.c
> +++ b/drivers/net/ethernet/ti/davinci_emac.c
> @@ -1870,10 +1870,17 @@ static int davinci_emac_probe(struct platform_device *pdev)
>
> priv->txchan = cpdma_chan_create(priv->dma, EMAC_DEF_TX_CH,
> emac_tx_handler, 0);
> + if (IS_ERR(priv->txchan)) {
> + dev_err(&pdev->dev, "error initializing tx dma channel\n");
> + rc = PTR_ERR(priv->txchan);
> + goto no_cpdma_chan;
> + }
> +
> priv->rxchan = cpdma_chan_create(priv->dma, EMAC_DEF_RX_CH,
> emac_rx_handler, 1);
> - if (WARN_ON(!priv->txchan || !priv->rxchan)) {
> - rc = -ENOMEM;
> + if (IS_ERR(priv->rxchan)) {
> + dev_err(&pdev->dev, "error initializing rx dma channel\n");
> + rc = PTR_ERR(priv->rxchan);
> goto no_cpdma_chan;
> }
>
>
--
regards,
-grygorii
^ permalink raw reply
* [PATCH v2] [iproute] Show 'external' link mode in output
From: Phil Dibowitz @ 2017-12-12 21:54 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
Recently `external` support was added to the tunnel drivers, but there is no way
to introspect this from userspace. This adds support for that.
Now `ip -details link` shows it:
```
7: tunl60@NONE: <NOARP> mtu 1452 qdisc noop state DOWN mode DEFAULT group
default qlen 1
link/tunnel6 :: brd :: promiscuity 0
ip6tnl external any remote :: local :: encaplimit 0 hoplimit 0 tclass 0x00 flowlabel 0x00000 (flowinfo 0x00000000) addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
```
Signed-off-by: Phil Dibowitz <phil@ipom.com>
---
ip/link_ip6tnl.c | 3 +++
ip/link_iptnl.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/ip/link_ip6tnl.c b/ip/link_ip6tnl.c
index 43287ab..af796c3 100644
--- a/ip/link_ip6tnl.c
+++ b/ip/link_ip6tnl.c
@@ -345,6 +345,9 @@ static void ip6tunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb
if (!tb)
return;
+ if (tb[IFLA_IPTUN_COLLECT_METADATA])
+ print_bool(PRINT_ANY, "external", "external ", true);
+
if (tb[IFLA_IPTUN_FLAGS])
flags = rta_getattr_u32(tb[IFLA_IPTUN_FLAGS]);
diff --git a/ip/link_iptnl.c b/ip/link_iptnl.c
index 4940b8b..2804b8f 100644
--- a/ip/link_iptnl.c
+++ b/ip/link_iptnl.c
@@ -393,6 +393,9 @@ static void iptunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[
if (!tb)
return;
+ if (tb[IFLA_IPTUN_COLLECT_METADATA])
+ print_bool(PRINT_ANY, "external", "external ", true);
+
if (tb[IFLA_IPTUN_REMOTE]) {
unsigned int addr = rta_getattr_u32(tb[IFLA_IPTUN_REMOTE]);
--
2.9.5
^ permalink raw reply related
* Re: [PATCH 2/4] sctp: Add ip option support
From: Marcelo Ricardo Leitner @ 2017-12-12 21:56 UTC (permalink / raw)
To: Paul Moore
Cc: Richard Haines, selinux, netdev, linux-sctp,
linux-security-module, Vlad Yasevich, nhorman, Stephen Smalley,
Eric Paris
In-Reply-To: <CAHC9VhR+WoO3UtdXLp+9mQ=c=avpEQ5-W8vTkEWfxXH1EkUS8A@mail.gmail.com>
On Tue, Dec 12, 2017 at 04:33:03PM -0500, Paul Moore wrote:
> On Tue, Dec 12, 2017 at 11:08 AM, Marcelo Ricardo Leitner
> <marcelo.leitner@gmail.com> wrote:
> > Hi Richard,
> >
> > On Mon, Nov 27, 2017 at 07:31:21PM +0000, Richard Haines wrote:
> > ...
> >> --- a/net/sctp/socket.c
> >> +++ b/net/sctp/socket.c
> >> @@ -3123,8 +3123,10 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, unsigned
> >>
> >> if (asoc) {
> >> if (val == 0) {
> >> + struct sctp_af *af = sp->pf->af;
> >> val = asoc->pathmtu;
> >> - val -= sp->pf->af->net_header_len;
> >> + val -= af->ip_options_len(asoc->base.sk);
> >> + val -= af->net_header_len;
> >> val -= sizeof(struct sctphdr) +
> >> sizeof(struct sctp_data_chunk);
> >> }
> >
> > Right below here there is a call to sctp_frag_point(). That function
> > also needs this tweak.
> >
> > Yes, we should simplify all these calculations. I have a patch to use
> > sctp_frag_point on where it is currently recalculating it on
> > sctp_datamsg_from_user(), but probably should include other places as
> > well.
>
> FYI: Richard let me know he is occupied with another project at the
> moment and likely won't be able to do another respin until next week
> at the earliest.
Okay, thanks. I can do a follow-up patch if it helps.
Marcelo
^ 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