Netdev List
 help / color / mirror / Atom feed
* [PATCH net 0/4] mlx4 misc fixes
From: Tariq Toukan @ 2017-08-01 13:43 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Eran Ben Elisha, Tariq Toukan

Hi Dave,

This patchset contains misc bug fixes from the team
to the mlx4 Core and Eth drivers.

Patch 1 by Inbar fixes a wrong ethtool indication for Wake-on-LAN.
The other 3 patches by Jack add a missing capability description,
and fixes the off-by-1 misalignment for the following capabilities
descriptions.

Series generated against net commit:
cc75f8514db6 samples/bpf: fix bpf tunnel cleanup

Thanks,
Tariq.


Inbar Karmy (1):
  net/mlx4_en: Fix wrong indication of Wake-on-LAN (WoL) support

Jack Morgenstein (3):
  net/mlx4_core: Fix sl_to_vl_change bit offset in flags2 dump
  net/mlx4_core: Fix namespace misalignment in QinQ VST support commit
  net/mlx4_core: Fixes missing capability bit in flags2 capability dump

 drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 15 ++++++++-------
 drivers/net/ethernet/mellanox/mlx4/fw.c         |  9 +++++++--
 drivers/net/ethernet/mellanox/mlx4/fw.h         |  1 +
 drivers/net/ethernet/mellanox/mlx4/main.c       |  2 ++
 include/linux/mlx4/device.h                     |  1 +
 5 files changed, 19 insertions(+), 9 deletions(-)

-- 
1.8.3.1

^ permalink raw reply

* [PATCH net 1/4] net/mlx4_en: Fix wrong indication of Wake-on-LAN (WoL) support
From: Tariq Toukan @ 2017-08-01 13:43 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Eran Ben Elisha, Inbar Karmy, Tariq Toukan
In-Reply-To: <1501595026-32368-1-git-send-email-tariqt@mellanox.com>

From: Inbar Karmy <inbark@mellanox.com>

Currently when WoL is supported but disabled, ethtool reports:
"Supports Wake-on: d".
Fix the indication of Wol support, so that the indication
remains "g" all the time if the NIC supports WoL.

Tested:
As accepted, when NIC supports WoL- ethtool reports:
	Supports Wake-on: g
	Wake-on: d
when NIC doesn't support WoL- ethtool reports:
        Supports Wake-on: d
        Wake-on: d

Fixes: 14c07b1358ed ("mlx4: Wake on LAN support")
Signed-off-by: Inbar Karmy <inbark@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 15 ++++++++-------
 drivers/net/ethernet/mellanox/mlx4/fw.c         |  4 ++++
 drivers/net/ethernet/mellanox/mlx4/fw.h         |  1 +
 drivers/net/ethernet/mellanox/mlx4/main.c       |  2 ++
 include/linux/mlx4/device.h                     |  1 +
 5 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
index c751a1d434ad..3d4e4a5d00d1 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
@@ -223,6 +223,7 @@ static void mlx4_en_get_wol(struct net_device *netdev,
 			    struct ethtool_wolinfo *wol)
 {
 	struct mlx4_en_priv *priv = netdev_priv(netdev);
+	struct mlx4_caps *caps = &priv->mdev->dev->caps;
 	int err = 0;
 	u64 config = 0;
 	u64 mask;
@@ -235,24 +236,24 @@ static void mlx4_en_get_wol(struct net_device *netdev,
 	mask = (priv->port == 1) ? MLX4_DEV_CAP_FLAG_WOL_PORT1 :
 		MLX4_DEV_CAP_FLAG_WOL_PORT2;
 
-	if (!(priv->mdev->dev->caps.flags & mask)) {
+	if (!(caps->flags & mask)) {
 		wol->supported = 0;
 		wol->wolopts = 0;
 		return;
 	}
 
+	if (caps->wol_port[priv->port])
+		wol->supported = WAKE_MAGIC;
+	else
+		wol->supported = 0;
+
 	err = mlx4_wol_read(priv->mdev->dev, &config, priv->port);
 	if (err) {
 		en_err(priv, "Failed to get WoL information\n");
 		return;
 	}
 
-	if (config & MLX4_EN_WOL_MAGIC)
-		wol->supported = WAKE_MAGIC;
-	else
-		wol->supported = 0;
-
-	if (config & MLX4_EN_WOL_ENABLED)
+	if ((config & MLX4_EN_WOL_ENABLED) && (config & MLX4_EN_WOL_MAGIC))
 		wol->wolopts = WAKE_MAGIC;
 	else
 		wol->wolopts = 0;
diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c
index 37e84a59e751..c165f16623a9 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -764,6 +764,7 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
 #define QUERY_DEV_CAP_CQ_TS_SUPPORT_OFFSET	0x3e
 #define QUERY_DEV_CAP_MAX_PKEY_OFFSET		0x3f
 #define QUERY_DEV_CAP_EXT_FLAGS_OFFSET		0x40
+#define QUERY_DEV_CAP_WOL_OFFSET		0x43
 #define QUERY_DEV_CAP_FLAGS_OFFSET		0x44
 #define QUERY_DEV_CAP_RSVD_UAR_OFFSET		0x48
 #define QUERY_DEV_CAP_UAR_SZ_OFFSET		0x49
@@ -920,6 +921,9 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
 	MLX4_GET(ext_flags, outbox, QUERY_DEV_CAP_EXT_FLAGS_OFFSET);
 	MLX4_GET(flags, outbox, QUERY_DEV_CAP_FLAGS_OFFSET);
 	dev_cap->flags = flags | (u64)ext_flags << 32;
+	MLX4_GET(field, outbox, QUERY_DEV_CAP_WOL_OFFSET);
+	dev_cap->wol_port[1] = !!(field & 0x20);
+	dev_cap->wol_port[2] = !!(field & 0x40);
 	MLX4_GET(field, outbox, QUERY_DEV_CAP_RSVD_UAR_OFFSET);
 	dev_cap->reserved_uars = field >> 4;
 	MLX4_GET(field, outbox, QUERY_DEV_CAP_UAR_SZ_OFFSET);
diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.h b/drivers/net/ethernet/mellanox/mlx4/fw.h
index 5343a0599253..b52ba01aa486 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.h
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.h
@@ -129,6 +129,7 @@ struct mlx4_dev_cap {
 	u32 dmfs_high_rate_qpn_range;
 	struct mlx4_rate_limit_caps rl_caps;
 	struct mlx4_port_cap port_cap[MLX4_MAX_PORTS + 1];
+	bool wol_port[MLX4_MAX_PORTS + 1];
 };
 
 struct mlx4_func_cap {
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index a27c9c13a36e..09b9bc17bce9 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -424,6 +424,8 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
 	dev->caps.stat_rate_support  = dev_cap->stat_rate_support;
 	dev->caps.max_gso_sz	     = dev_cap->max_gso_sz;
 	dev->caps.max_rss_tbl_sz     = dev_cap->max_rss_tbl_sz;
+	dev->caps.wol_port[1]          = dev_cap->wol_port[1];
+	dev->caps.wol_port[2]          = dev_cap->wol_port[2];
 
 	/* Save uar page shift */
 	if (!mlx4_is_slave(dev)) {
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index aad5d81dfb44..b54517c05e9a 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -620,6 +620,7 @@ struct mlx4_caps {
 	u32			dmfs_high_rate_qpn_base;
 	u32			dmfs_high_rate_qpn_range;
 	u32			vf_caps;
+	bool			wol_port[MLX4_MAX_PORTS + 1];
 	struct mlx4_rate_limit_caps rl_caps;
 };
 
-- 
1.8.3.1

^ permalink raw reply related

* [PATCH net 4/4] net/mlx4_core: Fixes missing capability bit in flags2 capability dump
From: Tariq Toukan @ 2017-08-01 13:43 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Eran Ben Elisha, Jack Morgenstein, Tariq Toukan
In-Reply-To: <1501595026-32368-1-git-send-email-tariqt@mellanox.com>

From: Jack Morgenstein <jackm@dev.mellanox.co.il>

The cited commit introduced the following new enum value in file
include/linux/mlx4/device.h:

    QUERY_DEV_CAP_DIAG_RPRT_PER_PORT

However, it failed to introduce a corresponding entry in function
dump_dev_cap_flags2() for outputting a line in the message log
when this capability bit is set.

The change here fixes that omission.

Fixes: c7c122ed67e4 ("net/mlx4: Add diagnostic counters capability bit")
Reported-by: Mukesh Kacker <mukesh.kacker@oracle.com>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/fw.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c
index 7c9502bae1cc..041c0ed65929 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -159,6 +159,7 @@ static void dump_dev_cap_flags2(struct mlx4_dev *dev, u64 flags)
 		[32] = "Loopback source checks support",
 		[33] = "RoCEv2 support",
 		[34] = "DMFS Sniffer support (UC & MC)",
+		[35] = "Diag counters per port",
 		[36] = "QinQ VST mode support",
 		[37] = "sl to vl mapping table change event support",
 	};
-- 
1.8.3.1

^ permalink raw reply related

* [PATCH net 2/4] net/mlx4_core: Fix sl_to_vl_change bit offset in flags2 dump
From: Tariq Toukan @ 2017-08-01 13:43 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Eran Ben Elisha, Jack Morgenstein, Tariq Toukan
In-Reply-To: <1501595026-32368-1-git-send-email-tariqt@mellanox.com>

From: Jack Morgenstein <jackm@dev.mellanox.co.il>

The index value in function dump_dev_cap_flags2() for outputting
"sl to vl mapping table change event support" needs to be
consistent with the value of the enumerated constant
MLX4_DEV_CAP_FLAG2_SL_TO_VL_CHANGE_EVENT defined in file
include/linux/mlx4_device.h

The change here restores that consistency.

Fixes: fd10ed8e6f42 ("IB/mlx4: Fix possible vl/sl field mismatch in LRH header in QP1 packets")
Reported-by: Mukesh Kacker <mukesh.kacker@oracle.com>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/fw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c
index c165f16623a9..009dd03466d6 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -160,7 +160,7 @@ static void dump_dev_cap_flags2(struct mlx4_dev *dev, u64 flags)
 		[33] = "RoCEv2 support",
 		[34] = "DMFS Sniffer support (UC & MC)",
 		[35] = "QinQ VST mode support",
-		[36] = "sl to vl mapping table change event support"
+		[37] = "sl to vl mapping table change event support",
 	};
 	int i;
 
-- 
1.8.3.1

^ permalink raw reply related

* [PATCH net 3/4] net/mlx4_core: Fix namespace misalignment in QinQ VST support commit
From: Tariq Toukan @ 2017-08-01 13:43 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Eran Ben Elisha, Jack Morgenstein, Tariq Toukan
In-Reply-To: <1501595026-32368-1-git-send-email-tariqt@mellanox.com>

From: Jack Morgenstein <jackm@dev.mellanox.co.il>

The cited commit introduced the following new enum value in file
include/linux/mlx4/device.h:

    MLX4_DEV_CAP_FLAG2_SVLAN_BY_QP

However the value of MLX4_DEV_CAP_FLAG2_SVLAN_BY_QP needs to stay
consistent with the value used in another namespace in
function dump_dev_cap_flags2(), which is manually kept in sync.
The change here restores that consistency.

Fixes: 7c3d21c8153c ("net/mlx4_core: Preparation for VF vlan protocol 802.1ad")
Reported-by: Mukesh Kacker <mukesh.kacker@oracle.com>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/fw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c
index 009dd03466d6..7c9502bae1cc 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -159,7 +159,7 @@ static void dump_dev_cap_flags2(struct mlx4_dev *dev, u64 flags)
 		[32] = "Loopback source checks support",
 		[33] = "RoCEv2 support",
 		[34] = "DMFS Sniffer support (UC & MC)",
-		[35] = "QinQ VST mode support",
+		[36] = "QinQ VST mode support",
 		[37] = "sl to vl mapping table change event support",
 	};
 	int i;
-- 
1.8.3.1

^ permalink raw reply related

* Re: [PATCH v2 net-next 1/3] net: dsa: lan9303: Refactor lan9303_xxx_packet_processing()
From: Andrew Lunn @ 2017-08-01 13:39 UTC (permalink / raw)
  To: Egil Hjelmeland; +Cc: vivien.didelot, f.fainelli, netdev, linux-kernel, kernel
In-Reply-To: <20170801111439.1143-2-privat@egil-hjelmeland.no>

> @@ -704,7 +710,7 @@ static void lan9303_get_ethtool_stats(struct dsa_switch *ds, int port,
>  	unsigned int u, poff;
>  	int ret;
>  
> -	poff = port * 0x400;
> +	poff = LAN9303_SWITCH_PORT_REG(port, 0);
>  
>  	for (u = 0; u < ARRAY_SIZE(lan9303_mib); u++) {
>  		ret = lan9303_read_switch_reg(chip,

So the actual code is:

	for (u = 0; u < ARRAY_SIZE(lan9303_mib); u++) {
       		ret = lan9303_read_switch_reg(chip,
			      		      lan9303_mib[u].offset + poff,
					      &reg);

Could this be written as

	for (u = 0; u < ARRAY_SIZE(lan9303_mib); u++) {
		ret = lan9303_read_switch_port(chip, port, lan9303_mib[u].offset, &reg);

It is then clear you are reading the statistics from a port register.

   Andrew

^ permalink raw reply

* Re: [PATCH v2 net-next 2/3] net: dsa: lan9303: define LAN9303_NUM_PORTS 3
From: Andrew Lunn @ 2017-08-01 13:27 UTC (permalink / raw)
  To: Egil Hjelmeland
  Cc: Juergen Borleis, kernel, vivien.didelot, f.fainelli, netdev,
	linux-kernel
In-Reply-To: <10b6b9fc-d2f9-1761-802f-724d9f6b3df1@egil-hjelmeland.no>

On Tue, Aug 01, 2017 at 02:31:44PM +0200, Egil Hjelmeland wrote:
> On 01. aug. 2017 13:49, Juergen Borleis wrote:
> >Hi Egil,
> >
> >On Tuesday 01 August 2017 13:14:38 Egil Hjelmeland wrote:
> >>Will be used instead of '3' in upcomming patches.
> >>
> >>
> >>+#define LAN9303_NUM_PORTS 3
> >>+
> >
> >Maybe we should put this macro into a shared location because
> >in "net/dsa/tag_lan9303.c" there is already a "#define LAN9303_MAX_PORTS
> >3".
> >
> >jb
> >
> 
> Is there any suitable shared location for such driver specific
> definitions?
> I could change the name to LAN9303_MAX_PORTS so it the same.
> Rhymes better with DSA_MAX_PORTS too.

Hi Egil, Juergen

The other tag drivers do:

        if (source_port >= ds->num_ports || !ds->ports[source_port].netdev)
                return NULL;

or just

        if (!ds->ports[port].netdev)
                return NULL;

The first version is the safest, since a malicious switch could return
port 42, and you are accessing way off the end of ds->ports[]. It does
however require you call dsa_switch_alloc() with the correct number of
ports.

     Andrew

^ permalink raw reply

* Re: [PATCH v3 2/2] ravb: add workaround for clock when resuming with WoL enabled
From: Sergei Shtylyov @ 2017-08-01 13:27 UTC (permalink / raw)
  To: Niklas Söderlund; +Cc: Geert Uytterhoeven, netdev, linux-renesas-soc
In-Reply-To: <20170801101437.9020-3-niklas.soderlund+renesas@ragnatech.se>

On 08/01/2017 01:14 PM, Niklas Söderlund wrote:

> The renesas-cpg-mssr clock driver are not yet aware of PSCI sleep where
> power is cut to the SoC. When resuming from this state with WoL enabled
> the enable count of the ravb clock is 1 and the clock driver thinks the
> clock is already on when PM core enables the clock and increments the
> enable count to 2. This will result in the ravb driver failing to talk
> to the hardware since the module clock is off. Work around this by
> forcing the enable count to 0 and then back to 2 when resuming with WoL
> enabled.
> 
> This workaround should be reverted once the renesas-cpg-mssr clock
> driver becomes aware of this PSCI sleep behavior.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

Acked-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

MBR, Sergei

^ permalink raw reply

* Re: [PATCH v3 1/2] ravb: add wake-on-lan support via magic packet
From: Sergei Shtylyov @ 2017-08-01 13:25 UTC (permalink / raw)
  To: Niklas Söderlund; +Cc: Geert Uytterhoeven, netdev, linux-renesas-soc
In-Reply-To: <20170801101437.9020-2-niklas.soderlund+renesas@ragnatech.se>

Hello!

On 08/01/2017 01:14 PM, Niklas Söderlund wrote:

> WoL is enabled in the suspend callback by setting MagicPacket detection
> and disabling all interrupts expect MagicPacket. In the resume path the
> driver needs to reset the hardware to rearm the WoL logic, this prevents
> the driver from simply restoring the registers and to take advantage of
> that ravb was not suspended to reduce resume time. To reset the
> hardware the driver closes the device, sets it in reset mode and reopens
> the device just like it would do in a normal suspend/resume scenario
> without WoL enabled, but it both closes and opens the device in the
> resume callback since the device needs to be reset for WoL to work.
> 
> One quirk needed for WoL is that the module clock needs to be prevented
> from being switched off by Runtime PM. To keep the clock alive the
> suspend callback need to call clk_enable() directly to increase the
> usage count of the clock. Then when Runtime PM decreases the clock usage
> count it won't reach 0 and be switched off.

> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

[...]

Acked-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

MBR, Sergei

^ permalink raw reply

* Re: [PATCH v2 net-next 2/3] net: dsa: lan9303: define LAN9303_NUM_PORTS 3
From: Egil Hjelmeland @ 2017-08-01 12:31 UTC (permalink / raw)
  To: Juergen Borleis, kernel
  Cc: andrew, vivien.didelot, f.fainelli, netdev, linux-kernel
In-Reply-To: <201708011349.52529.jbe@pengutronix.de>

On 01. aug. 2017 13:49, Juergen Borleis wrote:
> Hi Egil,
> 
> On Tuesday 01 August 2017 13:14:38 Egil Hjelmeland wrote:
>> Will be used instead of '3' in upcomming patches.
>>
>>
>> +#define LAN9303_NUM_PORTS 3
>> +
> 
> Maybe we should put this macro into a shared location because
> in "net/dsa/tag_lan9303.c" there is already a "#define LAN9303_MAX_PORTS
> 3".
> 
> jb
> 

Is there any suitable shared location for such driver specific
definitions?
I could change the name to LAN9303_MAX_PORTS so it the same.
Rhymes better with DSA_MAX_PORTS too.

Let's hear what other mean.

Egil

^ permalink raw reply

* RE: [PATCH net 3/3] tcp: fix xmit timer to only be reset if data ACKed/SACKed
From: maowenan @ 2017-08-01 12:20 UTC (permalink / raw)
  To: Neal Cardwell, David Miller
  Cc: netdev@vger.kernel.org, Yuchung Cheng, Nandita Dukkipati
In-Reply-To: <20170801025814.31206-4-ncardwell@google.com>



> -----Original Message-----
> From: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org]
> On Behalf Of Neal Cardwell
> Sent: Tuesday, August 01, 2017 10:58 AM
> To: David Miller
> Cc: netdev@vger.kernel.org; Neal Cardwell; Yuchung Cheng; Nandita Dukkipati
> Subject: [PATCH net 3/3] tcp: fix xmit timer to only be reset if data
> ACKed/SACKed
> 
> Fix a TCP loss recovery performance bug raised recently on the netdev list, in
> two threads:
> 
> (i)  July 26, 2017: netdev thread "TCP fast retransmit issues"
> (ii) July 26, 2017: netdev thread:
>      "[PATCH V2 net-next] TLP: Don't reschedule PTO when there's one
>      outstanding TLP retransmission"
> 
> The basic problem is that incoming TCP packets that did not indicate forward
> progress could cause the xmit timer (TLP or RTO) to be rearmed and pushed
> back in time. In certain corner cases this could result in the following problems
> noted in these threads:
> 
>  - Repeated ACKs coming in with bogus SACKs corrupted by middleboxes
>    could cause TCP to repeatedly schedule TLPs forever. We kept
>    sending TLPs after every ~200ms, which elicited bogus SACKs, which
>    caused more TLPs, ad infinitum; we never fired an RTO to fill in
>    the holes.
> 
>  - Incoming data segments could, in some cases, cause us to reschedule
>    our RTO or TLP timer further out in time, for no good reason. This
>    could cause repeated inbound data to result in stalls in outbound
>    data, in the presence of packet loss.
> 
> This commit fixes these bugs by changing the TLP and RTO ACK processing to:
> 
>  (a) Only reschedule the xmit timer once per ACK.
> 
>  (b) Only reschedule the xmit timer if tcp_clean_rtx_queue() deems the
>      ACK indicates sufficient forward progress (a packet was
>      cumulatively ACKed, or we got a SACK for a packet that was sent
>      before the most recent retransmit of the write queue head).
> 
> This brings us back into closer compliance with the RFCs, since, as the
> comment for tcp_rearm_rto() notes, we should only restart the RTO timer
> after forward progress on the connection. Previously we were restarting the
> xmit timer even in these cases where there was no forward progress.
> 
> As a side benefit, this commit simplifies and speeds up the TCP timer arming
> logic. We had been calling inet_csk_reset_xmit_timer() three times on normal
> ACKs that cumulatively acknowledged some data:
> 
> 1) Once near the top of tcp_ack() to switch from TLP timer to RTO:
>         if (icsk->icsk_pending == ICSK_TIME_LOSS_PROBE)
>                tcp_rearm_rto(sk);
> 
> 2) Once in tcp_clean_rtx_queue(), to update the RTO:
>         if (flag & FLAG_ACKED) {
>                tcp_rearm_rto(sk);
> 
> 3) Once in tcp_ack() after tcp_fastretrans_alert() to switch from RTO
>    to TLP:
>         if (icsk->icsk_pending == ICSK_TIME_RETRANS)
>                tcp_schedule_loss_probe(sk);
> 
> This commit, by only rescheduling the xmit timer once per ACK, simplifies the
> code and reduces CPU overhead.
> 
> This commit was tested in an A/B test with Google web server traffic. SNMP
> stats and request latency metrics were within noise levels, substantiating that
> for normal web traffic patterns this is a rare issue. This commit was also tested
> with packetdrill tests to verify that it fixes the timer behavior in the corner
> cases discussed in the netdev threads mentioned above.
> 
> This patch is a bug fix patch intended to be queued for -stable relases.
> 
> Fixes: 6ba8a3b19e76 ("tcp: Tail loss probe (TLP)")
> Reported-by: Klavs Klavsen <kl@vsen.dk>
> Reported-by: Mao Wenan <maowenan@huawei.com>
> Signed-off-by: Neal Cardwell <ncardwell@google.com>
> Signed-off-by: Yuchung Cheng <ycheng@google.com>
> Signed-off-by: Nandita Dukkipati <nanditad@google.com>
> ---
>  net/ipv4/tcp_input.c  | 25 ++++++++++++++++---------
> net/ipv4/tcp_output.c |  9 ---------
>  2 files changed, 16 insertions(+), 18 deletions(-)
> 
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index
> 345febf0a46e..3e777cfbba56 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -107,6 +107,7 @@ int sysctl_tcp_invalid_ratelimit __read_mostly = HZ/2;
>  #define FLAG_ORIG_SACK_ACKED	0x200 /* Never retransmitted data are
> (s)acked	*/
>  #define FLAG_SND_UNA_ADVANCED	0x400 /* Snd_una was changed (!=
> FLAG_DATA_ACKED) */
>  #define FLAG_DSACKING_ACK	0x800 /* SACK blocks contained D-SACK info
> */
> +#define FLAG_SET_XMIT_TIMER	0x1000 /* Set TLP or RTO timer */
>  #define FLAG_SACK_RENEGING	0x2000 /* snd_una advanced to a sacked
> seq */
>  #define FLAG_UPDATE_TS_RECENT	0x4000 /* tcp_replace_ts_recent() */
>  #define FLAG_NO_CHALLENGE_ACK	0x8000 /* do not call
> tcp_send_challenge_ack()	*/
> @@ -3016,6 +3017,13 @@ void tcp_rearm_rto(struct sock *sk)
>  	}
>  }
> 
> +/* Try to schedule a loss probe; if that doesn't work, then schedule an
> +RTO. */ static void tcp_set_xmit_timer(struct sock *sk) {
> +	if (!tcp_schedule_loss_probe(sk))
> +		tcp_rearm_rto(sk);
> +}
> +
>  /* If we get here, the whole TSO packet has not been acked. */  static u32
> tcp_tso_acked(struct sock *sk, struct sk_buff *skb)  { @@ -3177,7 +3185,7
> @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets,
>  					ca_rtt_us, sack->rate);
> 
>  	if (flag & FLAG_ACKED) {
> -		tcp_rearm_rto(sk);
> +		flag |= FLAG_SET_XMIT_TIMER;  /* set TLP or RTO timer */
>  		if (unlikely(icsk->icsk_mtup.probe_size &&
>  			     !after(tp->mtu_probe.probe_seq_end, tp->snd_una))) {
>  			tcp_mtup_probe_success(sk);
> @@ -3205,7 +3213,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, int
> prior_fackets,
>  		 * after when the head was last (re)transmitted. Otherwise the
>  		 * timeout may continue to extend in loss recovery.
>  		 */
> -		tcp_rearm_rto(sk);
> +		flag |= FLAG_SET_XMIT_TIMER;  /* set TLP or RTO timer */
>  	}
> 
>  	if (icsk->icsk_ca_ops->pkts_acked) {
> @@ -3577,9 +3585,6 @@ static int tcp_ack(struct sock *sk, const struct
> sk_buff *skb, int flag)
>  	if (after(ack, tp->snd_nxt))
>  		goto invalid_ack;
> 
> -	if (icsk->icsk_pending == ICSK_TIME_LOSS_PROBE)
> -		tcp_rearm_rto(sk);
> -
>  	if (after(ack, prior_snd_una)) {
>  		flag |= FLAG_SND_UNA_ADVANCED;
>  		icsk->icsk_retransmits = 0;
> @@ -3644,18 +3649,20 @@ static int tcp_ack(struct sock *sk, const struct
> sk_buff *skb, int flag)
>  	flag |= tcp_clean_rtx_queue(sk, prior_fackets, prior_snd_una, &acked,
>  				    &sack_state);
> 
> +	if (tp->tlp_high_seq)
> +		tcp_process_tlp_ack(sk, ack, flag);
> +	/* If needed, reset TLP/RTO timer; RACK may later override this. */
[Mao Wenan] I have question about RACK, if there is no RACK feature in lower version, who can clear this flag:FLAG_SET_XMIT_TIMER?
 
> +	if (flag & FLAG_SET_XMIT_TIMER)
> +		tcp_set_xmit_timer(sk);
> +
>  	if (tcp_ack_is_dubious(sk, flag)) {
>  		is_dupack = !(flag & (FLAG_SND_UNA_ADVANCED |
> FLAG_NOT_DUP));
>  		tcp_fastretrans_alert(sk, acked, is_dupack, &flag, &rexmit);
>  	}
> -	if (tp->tlp_high_seq)
> -		tcp_process_tlp_ack(sk, ack, flag);
> 
>  	if ((flag & FLAG_FORWARD_PROGRESS) || !(flag & FLAG_NOT_DUP))
>  		sk_dst_confirm(sk);
> 
> -	if (icsk->icsk_pending == ICSK_TIME_RETRANS)
> -		tcp_schedule_loss_probe(sk);
>  	delivered = tp->delivered - delivered;	/* freshly ACKed or SACKed */
>  	lost = tp->lost - lost;			/* freshly marked lost */
>  	tcp_rate_gen(sk, delivered, lost, sack_state.rate); diff --git
> a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index
> 0ae6b5d176c0..c99cba897b9c 100644
> --- a/net/ipv4/tcp_output.c
> +++ b/net/ipv4/tcp_output.c
> @@ -2380,21 +2380,12 @@ bool tcp_schedule_loss_probe(struct sock *sk)
>  	u32 rtt = usecs_to_jiffies(tp->srtt_us >> 3);
>  	u32 timeout, rto_delta_us;
> 
> -	/* No consecutive loss probes. */
> -	if (WARN_ON(icsk->icsk_pending == ICSK_TIME_LOSS_PROBE)) {
> -		tcp_rearm_rto(sk);
> -		return false;
> -	}
>  	/* Don't do any loss probe on a Fast Open connection before 3WHS
>  	 * finishes.
>  	 */
>  	if (tp->fastopen_rsk)
>  		return false;
> 
> -	/* TLP is only scheduled when next timer event is RTO. */
> -	if (icsk->icsk_pending != ICSK_TIME_RETRANS)
> -		return false;
> -
>  	/* Schedule a loss probe in 2*RTT for SACK capable connections
>  	 * in Open state, that are either limited by cwnd or application.
>  	 */
> --
> 2.14.0.rc0.400.g1c36432dff-goog

^ permalink raw reply

* [PATCH net-next] net: bcmgenet: drop COMPILE_TEST dependency
From: Arnd Bergmann @ 2017-08-01 11:50 UTC (permalink / raw)
  To: David S. Miller, Florian Fainelli
  Cc: Arnd Bergmann, Michael Chan, Sathya Perla, netdev, linux-kernel

The last patch added the dependency on 'OF && HAS_IOMEM' but left
COMPILE_TEST as an alternative, which kind of defeats the purpose
of adding the dependency, we still get randconfig build warnings:

warning: (NET_DSA_BCM_SF2 && BCMGENET) selects MDIO_BCM_UNIMAC which has unmet direct dependencies (NETDEVICES && MDIO_BUS && HAS_IOMEM && OF_MDIO)

For compile-testing purposes, we don't really need this anyway,
as CONFIG_OF can be enabled on all architectures, and HAS_IOMEM
is present on all architectures we do meaningful compile-testing on
(the exception being arch/um).

This makes both OF and HAS_IOMEM hard dependencies.

Fixes: 5af74bb4fcf8 ("net: bcmgenet: Add dependency on HAS_IOMEM && OF")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/ethernet/broadcom/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/Kconfig b/drivers/net/ethernet/broadcom/Kconfig
index 45775399cab6..1456cb18f830 100644
--- a/drivers/net/ethernet/broadcom/Kconfig
+++ b/drivers/net/ethernet/broadcom/Kconfig
@@ -61,7 +61,7 @@ config BCM63XX_ENET
 
 config BCMGENET
 	tristate "Broadcom GENET internal MAC support"
-	depends on (OF && HAS_IOMEM) || COMPILE_TEST
+	depends on OF && HAS_IOMEM
 	select MII
 	select PHYLIB
 	select FIXED_PHY
-- 
2.9.0

^ permalink raw reply related

* Re: [PATCH v2 net-next 2/3] net: dsa: lan9303: define LAN9303_NUM_PORTS 3
From: Juergen Borleis @ 2017-08-01 11:49 UTC (permalink / raw)
  To: kernel
  Cc: Egil Hjelmeland, andrew, vivien.didelot, f.fainelli, netdev,
	linux-kernel
In-Reply-To: <20170801111439.1143-3-privat@egil-hjelmeland.no>

Hi Egil,

On Tuesday 01 August 2017 13:14:38 Egil Hjelmeland wrote:
> Will be used instead of '3' in upcomming patches.
>
> Signed-off-by: Egil Hjelmeland <privat@egil-hjelmeland.no>
> ---
>  drivers/net/dsa/lan9303-core.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/dsa/lan9303-core.c
> b/drivers/net/dsa/lan9303-core.c index 4c514d3b9f68..2a3c6bf473dd 100644
> --- a/drivers/net/dsa/lan9303-core.c
> +++ b/drivers/net/dsa/lan9303-core.c
> @@ -20,6 +20,8 @@
>
>  #include "lan9303.h"
>
> +#define LAN9303_NUM_PORTS 3
> +
>  /* 13.2 System Control and Status Registers
>   * Multiply register number by 4 to get address offset.
>   */

Maybe we should put this macro into a shared location because 
in "net/dsa/tag_lan9303.c" there is already a "#define LAN9303_MAX_PORTS 
3".

jb

-- 
Pengutronix e.K.                             | Juergen Borleis             |
Industrial Linux Solutions                   | http://www.pengutronix.de/  |

^ permalink raw reply

* [PATCH v2 net-next 3/3] net: dsa: lan9303: Simplify lan9303_xxx_packet_processing() usage
From: Egil Hjelmeland @ 2017-08-01 11:14 UTC (permalink / raw)
  To: andrew, vivien.didelot, f.fainelli, netdev, linux-kernel, kernel
  Cc: Egil Hjelmeland
In-Reply-To: <20170801111439.1143-1-privat@egil-hjelmeland.no>

Simplify usage of lan9303_enable_packet_processing,
lan9303_disable_packet_processing()

Signed-off-by: Egil Hjelmeland <privat@egil-hjelmeland.no>
---
 drivers/net/dsa/lan9303-core.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
index 2a3c6bf473dd..4da580c43751 100644
--- a/drivers/net/dsa/lan9303-core.c
+++ b/drivers/net/dsa/lan9303-core.c
@@ -564,15 +564,16 @@ static int lan9303_handle_reset(struct lan9303 *chip)
 /* stop processing packets for all ports */
 static int lan9303_disable_processing(struct lan9303 *chip)
 {
-	int ret;
+	int p;
 
-	ret = lan9303_disable_packet_processing(chip, 0);
-	if (ret)
-		return ret;
-	ret = lan9303_disable_packet_processing(chip, 1);
-	if (ret)
-		return ret;
-	return lan9303_disable_packet_processing(chip, 2);
+	for (p = 0; p < LAN9303_NUM_PORTS; p++) {
+		int ret = lan9303_disable_packet_processing(chip, p);
+
+		if (ret)
+			return ret;
+	}
+
+	return 0;
 }
 
 static int lan9303_check_device(struct lan9303 *chip)
@@ -765,7 +766,6 @@ static int lan9303_port_enable(struct dsa_switch *ds, int port,
 	/* enable internal packet processing */
 	switch (port) {
 	case 1:
-		return lan9303_enable_packet_processing(chip, port);
 	case 2:
 		return lan9303_enable_packet_processing(chip, port);
 	default:
@@ -784,13 +784,9 @@ static void lan9303_port_disable(struct dsa_switch *ds, int port,
 	/* disable internal packet processing */
 	switch (port) {
 	case 1:
-		lan9303_disable_packet_processing(chip, port);
-		lan9303_phy_write(ds, chip->phy_addr_sel_strap + 1,
-				  MII_BMCR, BMCR_PDOWN);
-		break;
 	case 2:
 		lan9303_disable_packet_processing(chip, port);
-		lan9303_phy_write(ds, chip->phy_addr_sel_strap + 2,
+		lan9303_phy_write(ds, chip->phy_addr_sel_strap + port,
 				  MII_BMCR, BMCR_PDOWN);
 		break;
 	default:
-- 
2.11.0

^ permalink raw reply related

* [PATCH v2 net-next 2/3] net: dsa: lan9303: define LAN9303_NUM_PORTS 3
From: Egil Hjelmeland @ 2017-08-01 11:14 UTC (permalink / raw)
  To: andrew, vivien.didelot, f.fainelli, netdev, linux-kernel, kernel
  Cc: Egil Hjelmeland
In-Reply-To: <20170801111439.1143-1-privat@egil-hjelmeland.no>

Will be used instead of '3' in upcomming patches.

Signed-off-by: Egil Hjelmeland <privat@egil-hjelmeland.no>
---
 drivers/net/dsa/lan9303-core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
index 4c514d3b9f68..2a3c6bf473dd 100644
--- a/drivers/net/dsa/lan9303-core.c
+++ b/drivers/net/dsa/lan9303-core.c
@@ -20,6 +20,8 @@
 
 #include "lan9303.h"
 
+#define LAN9303_NUM_PORTS 3
+
 /* 13.2 System Control and Status Registers
  * Multiply register number by 4 to get address offset.
  */
-- 
2.11.0

^ permalink raw reply related

* [PATCH v2 net-next 1/3] net: dsa: lan9303: Refactor lan9303_xxx_packet_processing()
From: Egil Hjelmeland @ 2017-08-01 11:14 UTC (permalink / raw)
  To: andrew, vivien.didelot, f.fainelli, netdev, linux-kernel, kernel
  Cc: Egil Hjelmeland
In-Reply-To: <20170801111439.1143-1-privat@egil-hjelmeland.no>

lan9303_enable_packet_processing, lan9303_disable_packet_processing()
Pass port number (0,1,2) as parameter instead of port offset.
Because other functions in the module pass port numbers.
And to enable simplifications in following patch.

Plus replaced a constant 0x400 with LAN9303_SWITCH_PORT_REG().

Signed-off-by: Egil Hjelmeland <privat@egil-hjelmeland.no>
---
 drivers/net/dsa/lan9303-core.c | 62 ++++++++++++++++++++++--------------------
 1 file changed, 33 insertions(+), 29 deletions(-)

diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
index 8e430d1ee297..4c514d3b9f68 100644
--- a/drivers/net/dsa/lan9303-core.c
+++ b/drivers/net/dsa/lan9303-core.c
@@ -159,9 +159,7 @@
 # define LAN9303_BM_EGRSS_PORT_TYPE_SPECIAL_TAG_PORT1 (BIT(9) | BIT(8))
 # define LAN9303_BM_EGRSS_PORT_TYPE_SPECIAL_TAG_PORT0 (BIT(1) | BIT(0))
 
-#define LAN9303_PORT_0_OFFSET 0x400
-#define LAN9303_PORT_1_OFFSET 0x800
-#define LAN9303_PORT_2_OFFSET 0xc00
+#define LAN9303_SWITCH_PORT_REG(port, reg0) (0x400 * (port) + (reg0))
 
 /* the built-in PHYs are of type LAN911X */
 #define MII_LAN911X_SPECIAL_MODES 0x12
@@ -428,6 +426,13 @@ static int lan9303_read_switch_reg(struct lan9303 *chip, u16 regnum, u32 *val)
 	return ret;
 }
 
+static int lan9303_write_switch_port(
+	struct lan9303 *chip, unsigned int port, u16 regnum, u32 val)
+{
+	return lan9303_write_switch_reg(
+		chip, LAN9303_SWITCH_PORT_REG(port, regnum), val);
+}
+
 static int lan9303_detect_phy_setup(struct lan9303 *chip)
 {
 	int reg;
@@ -458,24 +463,23 @@ static int lan9303_detect_phy_setup(struct lan9303 *chip)
 	return 0;
 }
 
-#define LAN9303_MAC_RX_CFG_OFFS (LAN9303_MAC_RX_CFG_0 - LAN9303_PORT_0_OFFSET)
-#define LAN9303_MAC_TX_CFG_OFFS (LAN9303_MAC_TX_CFG_0 - LAN9303_PORT_0_OFFSET)
-
 static int lan9303_disable_packet_processing(struct lan9303 *chip,
 					     unsigned int port)
 {
 	int ret;
 
 	/* disable RX, but keep register reset default values else */
-	ret = lan9303_write_switch_reg(chip, LAN9303_MAC_RX_CFG_OFFS + port,
-				       LAN9303_MAC_RX_CFG_X_REJECT_MAC_TYPES);
+	ret = lan9303_write_switch_port(
+			chip, port, LAN9303_MAC_RX_CFG_0,
+			LAN9303_MAC_RX_CFG_X_REJECT_MAC_TYPES);
 	if (ret)
 		return ret;
 
 	/* disable TX, but keep register reset default values else */
-	return lan9303_write_switch_reg(chip, LAN9303_MAC_TX_CFG_OFFS + port,
-				LAN9303_MAC_TX_CFG_X_TX_IFG_CONFIG_DEFAULT |
-				LAN9303_MAC_TX_CFG_X_TX_PAD_ENABLE);
+	return lan9303_write_switch_port(
+			chip, port, LAN9303_MAC_TX_CFG_0,
+			LAN9303_MAC_TX_CFG_X_TX_IFG_CONFIG_DEFAULT |
+			LAN9303_MAC_TX_CFG_X_TX_PAD_ENABLE);
 }
 
 static int lan9303_enable_packet_processing(struct lan9303 *chip,
@@ -484,17 +488,19 @@ static int lan9303_enable_packet_processing(struct lan9303 *chip,
 	int ret;
 
 	/* enable RX and keep register reset default values else */
-	ret = lan9303_write_switch_reg(chip, LAN9303_MAC_RX_CFG_OFFS + port,
-				       LAN9303_MAC_RX_CFG_X_REJECT_MAC_TYPES |
-				       LAN9303_MAC_RX_CFG_X_RX_ENABLE);
+	ret = lan9303_write_switch_port(
+			chip, port, LAN9303_MAC_RX_CFG_0,
+			LAN9303_MAC_RX_CFG_X_REJECT_MAC_TYPES |
+			LAN9303_MAC_RX_CFG_X_RX_ENABLE);
 	if (ret)
 		return ret;
 
 	/* enable TX and keep register reset default values else */
-	return lan9303_write_switch_reg(chip, LAN9303_MAC_TX_CFG_OFFS + port,
-				LAN9303_MAC_TX_CFG_X_TX_IFG_CONFIG_DEFAULT |
-				LAN9303_MAC_TX_CFG_X_TX_PAD_ENABLE |
-				LAN9303_MAC_TX_CFG_X_TX_ENABLE);
+	return lan9303_write_switch_port(
+			chip, port, LAN9303_MAC_TX_CFG_0,
+			LAN9303_MAC_TX_CFG_X_TX_IFG_CONFIG_DEFAULT |
+			LAN9303_MAC_TX_CFG_X_TX_PAD_ENABLE |
+			LAN9303_MAC_TX_CFG_X_TX_ENABLE);
 }
 
 /* We want a special working switch:
@@ -558,13 +564,13 @@ static int lan9303_disable_processing(struct lan9303 *chip)
 {
 	int ret;
 
-	ret = lan9303_disable_packet_processing(chip, LAN9303_PORT_0_OFFSET);
+	ret = lan9303_disable_packet_processing(chip, 0);
 	if (ret)
 		return ret;
-	ret = lan9303_disable_packet_processing(chip, LAN9303_PORT_1_OFFSET);
+	ret = lan9303_disable_packet_processing(chip, 1);
 	if (ret)
 		return ret;
-	return lan9303_disable_packet_processing(chip, LAN9303_PORT_2_OFFSET);
+	return lan9303_disable_packet_processing(chip, 2);
 }
 
 static int lan9303_check_device(struct lan9303 *chip)
@@ -634,7 +640,7 @@ static int lan9303_setup(struct dsa_switch *ds)
 	if (ret)
 		dev_err(chip->dev, "failed to separate ports %d\n", ret);
 
-	ret = lan9303_enable_packet_processing(chip, LAN9303_PORT_0_OFFSET);
+	ret = lan9303_enable_packet_processing(chip, 0);
 	if (ret)
 		dev_err(chip->dev, "failed to re-enable switching %d\n", ret);
 
@@ -704,7 +710,7 @@ static void lan9303_get_ethtool_stats(struct dsa_switch *ds, int port,
 	unsigned int u, poff;
 	int ret;
 
-	poff = port * 0x400;
+	poff = LAN9303_SWITCH_PORT_REG(port, 0);
 
 	for (u = 0; u < ARRAY_SIZE(lan9303_mib); u++) {
 		ret = lan9303_read_switch_reg(chip,
@@ -757,11 +763,9 @@ static int lan9303_port_enable(struct dsa_switch *ds, int port,
 	/* enable internal packet processing */
 	switch (port) {
 	case 1:
-		return lan9303_enable_packet_processing(chip,
-							LAN9303_PORT_1_OFFSET);
+		return lan9303_enable_packet_processing(chip, port);
 	case 2:
-		return lan9303_enable_packet_processing(chip,
-							LAN9303_PORT_2_OFFSET);
+		return lan9303_enable_packet_processing(chip, port);
 	default:
 		dev_dbg(chip->dev,
 			"Error: request to power up invalid port %d\n", port);
@@ -778,12 +782,12 @@ static void lan9303_port_disable(struct dsa_switch *ds, int port,
 	/* disable internal packet processing */
 	switch (port) {
 	case 1:
-		lan9303_disable_packet_processing(chip, LAN9303_PORT_1_OFFSET);
+		lan9303_disable_packet_processing(chip, port);
 		lan9303_phy_write(ds, chip->phy_addr_sel_strap + 1,
 				  MII_BMCR, BMCR_PDOWN);
 		break;
 	case 2:
-		lan9303_disable_packet_processing(chip, LAN9303_PORT_2_OFFSET);
+		lan9303_disable_packet_processing(chip, port);
 		lan9303_phy_write(ds, chip->phy_addr_sel_strap + 2,
 				  MII_BMCR, BMCR_PDOWN);
 		break;
-- 
2.11.0

^ permalink raw reply related

* [PATCH v2 net-next 0/3] Refactor lan9303_xxx_packet_processing
From: Egil Hjelmeland @ 2017-08-01 11:14 UTC (permalink / raw)
  To: andrew, vivien.didelot, f.fainelli, netdev, linux-kernel, kernel
  Cc: Egil Hjelmeland

This series is purely non functional. It changes the 
lan9303_enable_packet_processing,
lan9303_disable_packet_processing() to pass port number (0,1,2) as
parameter instead of port offset. This aligns them with
other functions in the module, and makes it possible to simplify the code.

First patch: Change lan9303_xxx_packet_processing parameter:
 - Pass port number (0,1,2) as parameter.
 - Introduced lan9303_write_switch_port() 
 - Plus replaced a constant 0x400 with LAN9303_SWITCH_PORT_REG()

Second patch: Introduce LAN9303_NUM_PORTS=3, used in next patch.

Third patch: Simplify lan9303_xxx_packet_processing usage.

Comments welcome!

Changes v1 -> v2:
 - introduced lan9303_write_switch_port() in first patch
 - inserted LAN9303_NUM_PORTS patch
 - Use LAN9303_NUM_PORTS in last patch. Plus whitespace change.  

Egil Hjelmeland (3):
  net: dsa: lan9303: Refactor lan9303_xxx_packet_processing()
  net: dsa: lan9303: define LAN9303_NUM_PORTS 3
  net: dsa: lan9303: Simplify lan9303_xxx_packet_processing() usage

 drivers/net/dsa/lan9303-core.c | 78 ++++++++++++++++++++++--------------------
 1 file changed, 40 insertions(+), 38 deletions(-)

-- 
2.11.0

^ permalink raw reply

* Re: [PATCH 1/6] [net-next]net: sched: act_mirred: Extend redirect action to accept a traffic class
From: Jiri Pirko @ 2017-08-01 11:12 UTC (permalink / raw)
  To: Amritha Nambiar
  Cc: intel-wired-lan, jeffrey.t.kirsher, alexander.h.duyck,
	kiran.patil, netdev, mitch.a.williams, alexander.duyck,
	neerav.parikh, sridhar.samudrala, carolyn.wyborny
In-Reply-To: <150154785793.4135.15194023552358061083.stgit@anamdev.jf.intel.com>

Tue, Aug 01, 2017 at 02:37:37AM CEST, amritha.nambiar@intel.com wrote:
>The Mirred/redirect action is extended to forward to a traffic
>class on the device. The traffic class index needs to be
>provided in addition to the device's ifindex.
>
>Example:
># tc filter add dev eth0 protocol ip parent ffff: prio 1 flower\
>  dst_ip 192.168.1.1/32 ip_proto udp dst_port 22\
>  skip_sw indev eth0 action mirred ingress redirect dev eth0 tc 1

You need to make sure that the current offloaders fill forbid to add
this rule, not just silently ignore the tc value.


>
>Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
>---
> include/net/tc_act/tc_mirred.h        |    7 +++++++
> include/uapi/linux/tc_act/tc_mirred.h |    5 +++++
> net/sched/act_mirred.c                |   17 +++++++++++++++++
> 3 files changed, 29 insertions(+)
>
>diff --git a/include/net/tc_act/tc_mirred.h b/include/net/tc_act/tc_mirred.h
>index 604bc31..60058c4 100644
>--- a/include/net/tc_act/tc_mirred.h
>+++ b/include/net/tc_act/tc_mirred.h
>@@ -9,6 +9,8 @@ struct tcf_mirred {
> 	int			tcfm_eaction;
> 	int			tcfm_ifindex;
> 	bool			tcfm_mac_header_xmit;
>+	u8			tcfm_tc;
>+	u32			flags;
> 	struct net_device __rcu	*tcfm_dev;
> 	struct list_head	tcfm_list;
> };
>@@ -37,4 +39,9 @@ static inline int tcf_mirred_ifindex(const struct tc_action *a)
> 	return to_mirred(a)->tcfm_ifindex;
> }
> 
>+static inline int tcf_mirred_tc(const struct tc_action *a)
>+{
>+	return to_mirred(a)->tcfm_tc;
>+}
>+
> #endif /* __NET_TC_MIR_H */
>diff --git a/include/uapi/linux/tc_act/tc_mirred.h b/include/uapi/linux/tc_act/tc_mirred.h
>index 3d7a2b3..8ff4d76 100644
>--- a/include/uapi/linux/tc_act/tc_mirred.h
>+++ b/include/uapi/linux/tc_act/tc_mirred.h
>@@ -9,6 +9,10 @@
> #define TCA_EGRESS_MIRROR 2 /* mirror packet to EGRESS */
> #define TCA_INGRESS_REDIR 3  /* packet redirect to INGRESS*/
> #define TCA_INGRESS_MIRROR 4 /* mirror packet to INGRESS */
>+
>+#define MIRRED_F_TC_MAP		0x1
>+#define MIRRED_TC_MAP_MAX	0x10
>+#define MIRRED_TC_MAP_MASK	0xF

I'm completely lost. Why do you have these values here? and in fact one
twice?


>                                                                                 
> struct tc_mirred {
> 	tc_gen;
>@@ -21,6 +25,7 @@ enum {
> 	TCA_MIRRED_TM,
> 	TCA_MIRRED_PARMS,
> 	TCA_MIRRED_PAD,
>+	TCA_MIRRED_TC_MAP,
> 	__TCA_MIRRED_MAX
> };
> #define TCA_MIRRED_MAX (__TCA_MIRRED_MAX - 1)
>diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
>index 1b5549a..f9801de 100644
>--- a/net/sched/act_mirred.c
>+++ b/net/sched/act_mirred.c
>@@ -67,6 +67,7 @@ static void tcf_mirred_release(struct tc_action *a, int bind)
> 
> static const struct nla_policy mirred_policy[TCA_MIRRED_MAX + 1] = {
> 	[TCA_MIRRED_PARMS]	= { .len = sizeof(struct tc_mirred) },
>+	[TCA_MIRRED_TC_MAP]	= { .type = NLA_U8 },
> };
> 
> static unsigned int mirred_net_id;
>@@ -83,6 +84,8 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
> 	struct tcf_mirred *m;
> 	struct net_device *dev;
> 	bool exists = false;
>+	u8 *tc_map = NULL;
>+	u32 flags = 0;
> 	int ret;
> 
> 	if (nla == NULL)
>@@ -92,6 +95,14 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
> 		return ret;
> 	if (tb[TCA_MIRRED_PARMS] == NULL)
> 		return -EINVAL;
>+
>+	if (tb[TCA_MIRRED_TC_MAP]) {
>+		tc_map = nla_data(tb[TCA_MIRRED_TC_MAP]);
>+		if (*tc_map >= MIRRED_TC_MAP_MAX)
>+			return -EINVAL;
>+		flags |= MIRRED_F_TC_MAP;
>+	}
>+
> 	parm = nla_data(tb[TCA_MIRRED_PARMS]);
> 
> 	exists = tcf_hash_check(tn, parm->index, a, bind);
>@@ -139,6 +150,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
> 	ASSERT_RTNL();
> 	m->tcf_action = parm->action;
> 	m->tcfm_eaction = parm->eaction;
>+	m->flags = flags;
> 	if (dev != NULL) {
> 		m->tcfm_ifindex = parm->ifindex;
> 		if (ret != ACT_P_CREATED)
>@@ -146,6 +158,8 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
> 		dev_hold(dev);
> 		rcu_assign_pointer(m->tcfm_dev, dev);
> 		m->tcfm_mac_header_xmit = mac_header_xmit;
>+		if (flags & MIRRED_F_TC_MAP)
>+			m->tcfm_tc = *tc_map & MIRRED_TC_MAP_MASK;
> 	}
> 
> 	if (ret == ACT_P_CREATED) {
>@@ -259,6 +273,9 @@ static int tcf_mirred_dump(struct sk_buff *skb, struct tc_action *a, int bind,
> 
> 	if (nla_put(skb, TCA_MIRRED_PARMS, sizeof(opt), &opt))
> 		goto nla_put_failure;
>+	if ((m->flags & MIRRED_F_TC_MAP) &&
>+	    nla_put_u8(skb, TCA_MIRRED_TC_MAP, m->tcfm_tc))
>+		goto nla_put_failure;
> 
> 	tcf_tm_dump(&t, &m->tcf_tm);
> 	if (nla_put_64bit(skb, TCA_MIRRED_TM, sizeof(t), &t, TCA_MIRRED_PAD))
>

^ permalink raw reply

* RE: [PATCH] ss: Enclose IPv6 address in brackets
From: David Laight @ 2017-08-01 11:11 UTC (permalink / raw)
  To: 'Florian Lehner', netdev@vger.kernel.org
In-Reply-To: <fc81757c-8dbb-dbed-7a24-7011cb8bb9e0@der-flo.net>

From: Florian Lehner
> Sent: 29 July 2017 13:29
> This patch adds support for RFC2732 IPv6 address format with brackets
> for the tool ss. So output for ss changes from
> 2a00:1450:400a:804::200e:443 to [2a00:1450:400a:804::200e]:443 for IPv6
> addresses with attached port number.
> 
> Signed-off-by: Lehner Florian <dev@der-flo.net>
> ---
>  misc/ss.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/misc/ss.c b/misc/ss.c
> index 12763c9..db39c93 100644
> --- a/misc/ss.c
> +++ b/misc/ss.c
> @@ -1059,7 +1059,11 @@ static void inet_addr_print(const inet_prefix *a,
> int port, unsigned int ifindex
>  			ap = format_host(AF_INET, 4, a->data);
>  		}
>  	} else {
> -		ap = format_host(a->family, 16, a->data);
> +		if (a->family == AF_INET6) {
> +			sprintf(buf, "[%s]", format_host(a->family, 16, a->data));
> +		} else {
> +			ap = format_host(a->family, 16, a->data);
> +		}
>  		est_len = strlen(ap);
...

There are some strange things going on with global variables if this works at all.
The text form of the address is in buf[] in one path and *ap in the other.

One option might be to call format_host() then use strchr(ap, ':')
to add [] if the string contains any ':'.

	David


^ permalink raw reply

* Re: [PATCH net-next v12 0/4] net sched actions: improve dump performance
From: Jamal Hadi Salim @ 2017-08-01 11:05 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: David Miller, netdev, jiri, xiyou.wangcong, eric.dumazet, horms,
	dsahern
In-Reply-To: <20170731205419.6710fe11@xeon-e3>

On 17-07-31 11:54 PM, Stephen Hemminger wrote:
> On Mon, 31 Jul 2017 08:06:42 -0400
> Jamal Hadi Salim <jhs@mojatatu.com> wrote:
> 

[..]
> Please cleanup and resubmit for net-next.
>

Will do.

> The header files have been updated in iproute2 net-next branch.
> 

When does net-next show up? I noticed some changes - example Jiri's
multi-table changes are not in the tree (I believe they were submitted
as part of net-next).

> It is not clear to me that the new code is backward compatiable
> Will new versions of tc work on old kernels and vice/versa?
> 

AFAIK and tested it is.

> 
> Also, no #ifdef's

Those will go away. The intention was to test things which will be
rejected (in case some other app in the future uses this feature).

cheers,
jamal

^ permalink raw reply

* Re: [PATCH 6/6] [net-next]net: i40e: Enable cloud filters in i40e via tc/flower classifier
From: Jamal Hadi Salim @ 2017-08-01 10:56 UTC (permalink / raw)
  To: Amritha Nambiar, intel-wired-lan, jeffrey.t.kirsher
  Cc: alexander.h.duyck, kiran.patil, netdev, mitch.a.williams,
	alexander.duyck, neerav.parikh, sridhar.samudrala,
	carolyn.wyborny, Or Gerlitz
In-Reply-To: <150154788503.4135.7051219373661945937.stgit@anamdev.jf.intel.com>

On 17-07-31 08:38 PM, Amritha Nambiar wrote:
> This patch enables tc-flower based hardware offloads. tc/flower
> filter provided by the kernel is configured as driver specific
> cloud filter. The patch implements functions and admin queue
> commands needed to support cloud filters in the driver and
> adds cloud filters to configure these tc-flower filters.
> 
> The only action supported is to redirect packets to a traffic class
> on the same device.
> 
> # tc qdisc add dev eth0 ingress
> # ethtool -K eth0 hw-tc-offload on
> 
> # tc filter add dev eth0 protocol ip parent ffff:\
>    prio 1 flower dst_mac 3c:fd:fe:a0:d6:70 skip_sw indev eth0\
>    action mirred ingress redirect dev eth0 tc 0
> 

Out of curiosity - did you need to say "indev eth0" there?
Also: Is it possible to add an skbmark? Example something like
these that directs two flows to the same queue but different
skb marks:

# tc filter add dev eth0 protocol ip parent ffff: \
   prio 2 flower dst_ip 192.168.3.5/32 \
   ip_proto udp dst_port 2a skip_sw \
   action skbedit mark 11 \
   action mirred ingress redirect dev eth0 tcqueue 1

# tc filter add dev eth0 protocol ip parent ffff: \
     prio 1 flower dst_mac 3c:fd:fe:a0:d6:70 skip_sw \
     action skbedit mark 12 \
     action mirred ingress redirect dev eth0 tcqueue 1

cheers,
jamal

^ permalink raw reply

* Re: [PATCH 3/6] [net-next]net: i40e: Extend set switch config command to accept cloud filter mode
From: Jamal Hadi Salim @ 2017-08-01 10:48 UTC (permalink / raw)
  To: Amritha Nambiar, intel-wired-lan, jeffrey.t.kirsher
  Cc: alexander.h.duyck, kiran.patil, netdev, mitch.a.williams,
	alexander.duyck, neerav.parikh, sridhar.samudrala,
	carolyn.wyborny
In-Reply-To: <150154786980.4135.7459136530514071209.stgit@anamdev.jf.intel.com>

On 17-07-31 08:37 PM, Amritha Nambiar wrote:
> Add definitions for L4 filters and switch modes based on cloud filters
> modes and extend the set switch config command to include the
> additional cloud filter mode.
> 

"Cloud filters"? Seriously? Is "enteprise" the next one? ;->

cheers,
jamal

^ permalink raw reply

* [PATCH nf-next] netfilter: constify nf_loginfo structures
From: Julia Lawall @ 2017-08-01 10:48 UTC (permalink / raw)
  To: David S. Miller
  Cc: kernel-janitors, linux-kernel, netdev, coreteam, netfilter-devel,
	Florian Westphal, Jozsef Kadlecsik, Pablo Neira Ayuso,
	Alexey Kuznetsov, Hideaki YOSHIFUJI

The nf_loginfo structures are only passed as the seventh argument to
nf_log_trace, which is declared as const or stored in a local const
variable.  Thus the nf_loginfo structures themselves can be const.

Done with the help of Coccinelle.

// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct nf_loginfo i@p = { ... };

@ok1@
identifier r.i;
expression list[6] es;
position p;
@@
 nf_log_trace(es,&i@p,...)

@ok2@
identifier r.i;
const struct nf_loginfo *e;
position p;
@@
 e = &i@p

@bad@
position p != {r.p,ok1.p,ok2.p};
identifier r.i;
struct nf_loginfo e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct nf_loginfo i = { ... };
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 net/ipv4/netfilter/ip_tables.c   |    2 +-
 net/ipv4/netfilter/nf_log_arp.c  |    2 +-
 net/ipv4/netfilter/nf_log_ipv4.c |    2 +-
 net/ipv6/netfilter/ip6_tables.c  |    2 +-
 net/ipv6/netfilter/nf_log_ipv6.c |    2 +-
 net/netfilter/nf_tables_core.c   |    2 +-
 net/netfilter/nfnetlink_log.c    |    2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/net/netfilter/nf_tables_core.c b/net/netfilter/nf_tables_core.c
index c5bab08..dfd0bf3 100644
--- a/net/netfilter/nf_tables_core.c
+++ b/net/netfilter/nf_tables_core.c
@@ -29,7 +29,7 @@
 	[NFT_TRACETYPE_RULE]	= "rule",
 };
 
-static struct nf_loginfo trace_loginfo = {
+static const struct nf_loginfo trace_loginfo = {
 	.type = NF_LOG_TYPE_LOG,
 	.u = {
 		.log = {
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index c684ba9..cad6498 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -606,7 +606,7 @@ static void nfulnl_instance_free_rcu(struct rcu_head *head)
 	return -1;
 }
 
-static struct nf_loginfo default_loginfo = {
+static const struct nf_loginfo default_loginfo = {
 	.type =		NF_LOG_TYPE_ULOG,
 	.u = {
 		.ulog = {
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 2a55a40..96a289c 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -151,7 +151,7 @@ enum nf_ip_trace_comments {
 	[NF_IP_TRACE_COMMENT_POLICY]	= "policy",
 };
 
-static struct nf_loginfo trace_loginfo = {
+static const struct nf_loginfo trace_loginfo = {
 	.type = NF_LOG_TYPE_LOG,
 	.u = {
 		.log = {
diff --git a/net/ipv4/netfilter/nf_log_arp.c b/net/ipv4/netfilter/nf_log_arp.c
index 2f3895d..df5c2a2 100644
--- a/net/ipv4/netfilter/nf_log_arp.c
+++ b/net/ipv4/netfilter/nf_log_arp.c
@@ -25,7 +25,7 @@
 #include <linux/netfilter/xt_LOG.h>
 #include <net/netfilter/nf_log.h>
 
-static struct nf_loginfo default_loginfo = {
+static const struct nf_loginfo default_loginfo = {
 	.type	= NF_LOG_TYPE_LOG,
 	.u = {
 		.log = {
diff --git a/net/ipv4/netfilter/nf_log_ipv4.c b/net/ipv4/netfilter/nf_log_ipv4.c
index c83a996..4388de0 100644
--- a/net/ipv4/netfilter/nf_log_ipv4.c
+++ b/net/ipv4/netfilter/nf_log_ipv4.c
@@ -24,7 +24,7 @@
 #include <linux/netfilter/xt_LOG.h>
 #include <net/netfilter/nf_log.h>
 
-static struct nf_loginfo default_loginfo = {
+static const struct nf_loginfo default_loginfo = {
 	.type	= NF_LOG_TYPE_LOG,
 	.u = {
 		.log = {
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 1f90644..9f66449 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -176,7 +176,7 @@ enum nf_ip_trace_comments {
 	[NF_IP6_TRACE_COMMENT_POLICY]	= "policy",
 };
 
-static struct nf_loginfo trace_loginfo = {
+static const struct nf_loginfo trace_loginfo = {
 	.type = NF_LOG_TYPE_LOG,
 	.u = {
 		.log = {
diff --git a/net/ipv6/netfilter/nf_log_ipv6.c b/net/ipv6/netfilter/nf_log_ipv6.c
index 97c7242..b397a8f 100644
--- a/net/ipv6/netfilter/nf_log_ipv6.c
+++ b/net/ipv6/netfilter/nf_log_ipv6.c
@@ -25,7 +25,7 @@
 #include <linux/netfilter/xt_LOG.h>
 #include <net/netfilter/nf_log.h>
 
-static struct nf_loginfo default_loginfo = {
+static const struct nf_loginfo default_loginfo = {
 	.type	= NF_LOG_TYPE_LOG,
 	.u = {
 		.log = {

^ permalink raw reply related

* Re: [PATCH net] mcs7780: Silence uninitialized variable warning
From: Dan Carpenter @ 2017-08-01 10:45 UTC (permalink / raw)
  To: David Miller; +Cc: samuel, netdev, kernel-janitors
In-Reply-To: <20170731.103716.2203333144439591434.davem@davemloft.net>

On Mon, Jul 31, 2017 at 10:37:16AM -0700, David Miller wrote:
> From: Dan Carpenter <dan.carpenter@oracle.com>
> Date: Mon, 31 Jul 2017 10:41:40 +0300
> 
> > On Sat, Jul 29, 2017 at 11:28:55PM -0700, David Miller wrote:
> >> From: Dan Carpenter <dan.carpenter@oracle.com>
> >> Date: Fri, 28 Jul 2017 17:45:11 +0300
> >> 
> >> > -	__u16 rval;
> >> > +	__u16 rval = -1;
> >> 
> >> Fixing a bogus warning by assigning a signed constant to an
> >> unsigned variable doesn't really make me all that happy.
> >> 
> >> I don't think I'll apply this, sorry.
> > 
> > There's no guarantee that small kmallocs will always succeed in future
> > kernels so it's not *totally* bogus.
> 
> Perhaps the burdon of initializing the value belongs in
> mcs_get_reg(), and you can set it properly to 0xffff
> instead of -1.
> 
> Ok?

Sure.  I will resend.

thanks,
dan carpenter

^ permalink raw reply

* Re: [PATCH 1/6] [net-next]net: sched: act_mirred: Extend redirect action to accept a traffic class
From: Jamal Hadi Salim @ 2017-08-01 10:44 UTC (permalink / raw)
  To: Amritha Nambiar, intel-wired-lan, jeffrey.t.kirsher
  Cc: alexander.h.duyck, kiran.patil, netdev, mitch.a.williams,
	alexander.duyck, neerav.parikh, sridhar.samudrala,
	carolyn.wyborny
In-Reply-To: <150154785793.4135.15194023552358061083.stgit@anamdev.jf.intel.com>

On 17-07-31 08:37 PM, Amritha Nambiar wrote:
> The Mirred/redirect action is extended to forward to a traffic
> class on the device. The traffic class index needs to be
> provided in addition to the device's ifindex.
> 
> Example:
> # tc filter add dev eth0 protocol ip parent ffff: prio 1 flower\
>    dst_ip 192.168.1.1/32 ip_proto udp dst_port 22\
>    skip_sw indev eth0 action mirred ingress redirect dev eth0 tc 1
> 
> Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
> ---
>   include/net/tc_act/tc_mirred.h        |    7 +++++++
>   include/uapi/linux/tc_act/tc_mirred.h |    5 +++++
>   net/sched/act_mirred.c                |   17 +++++++++++++++++
>   3 files changed, 29 insertions(+)
> 
> diff --git a/include/net/tc_act/tc_mirred.h b/include/net/tc_act/tc_mirred.h
> index 604bc31..60058c4 100644
> --- a/include/net/tc_act/tc_mirred.h
> +++ b/include/net/tc_act/tc_mirred.h
> @@ -9,6 +9,8 @@ struct tcf_mirred {
>   	int			tcfm_eaction;
>   	int			tcfm_ifindex;
>   	bool			tcfm_mac_header_xmit;
> +	u8			tcfm_tc;
> +	u32			flags;
>   	struct net_device __rcu	*tcfm_dev;
>   	struct list_head	tcfm_list;
>   };
> @@ -37,4 +39,9 @@ static inline int tcf_mirred_ifindex(const struct tc_action *a)
>   	return to_mirred(a)->tcfm_ifindex;
>   }
>   
> +static inline int tcf_mirred_tc(const struct tc_action *a)
> +{
> +	return to_mirred(a)->tcfm_tc;
> +}
> +
>   #endif /* __NET_TC_MIR_H */
> diff --git a/include/uapi/linux/tc_act/tc_mirred.h b/include/uapi/linux/tc_act/tc_mirred.h
> index 3d7a2b3..8ff4d76 100644
> --- a/include/uapi/linux/tc_act/tc_mirred.h
> +++ b/include/uapi/linux/tc_act/tc_mirred.h
> @@ -9,6 +9,10 @@
>   #define TCA_EGRESS_MIRROR 2 /* mirror packet to EGRESS */
>   #define TCA_INGRESS_REDIR 3  /* packet redirect to INGRESS*/
>   #define TCA_INGRESS_MIRROR 4 /* mirror packet to INGRESS */
> +
> +#define MIRRED_F_TC_MAP		0x1
> +#define MIRRED_TC_MAP_MAX	0x10
> +#define MIRRED_TC_MAP_MASK	0xF
>                                                                                   
>   struct tc_mirred {
>   	tc_gen;
> @@ -21,6 +25,7 @@ enum {
>   	TCA_MIRRED_TM,
>   	TCA_MIRRED_PARMS,
>   	TCA_MIRRED_PAD,
> +	TCA_MIRRED_TC_MAP,
>   	__TCA_MIRRED_MAX
>   };
>   #define TCA_MIRRED_MAX (__TCA_MIRRED_MAX - 1)
> diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
> index 1b5549a..f9801de 100644
> --- a/net/sched/act_mirred.c
> +++ b/net/sched/act_mirred.c
> @@ -67,6 +67,7 @@ static void tcf_mirred_release(struct tc_action *a, int bind)
>   
>   static const struct nla_policy mirred_policy[TCA_MIRRED_MAX + 1] = {
>   	[TCA_MIRRED_PARMS]	= { .len = sizeof(struct tc_mirred) },
> +	[TCA_MIRRED_TC_MAP]	= { .type = NLA_U8 },
>   };
>   
>   static unsigned int mirred_net_id;
> @@ -83,6 +84,8 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
>   	struct tcf_mirred *m;
>   	struct net_device *dev;
>   	bool exists = false;
> +	u8 *tc_map = NULL;
> +	u32 flags = 0;
>   	int ret;
>   
>   	if (nla == NULL)
> @@ -92,6 +95,14 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
>   		return ret;
>   	if (tb[TCA_MIRRED_PARMS] == NULL)
>   		return -EINVAL;
> +
> +	if (tb[TCA_MIRRED_TC_MAP]) {
> +		tc_map = nla_data(tb[TCA_MIRRED_TC_MAP]);
> +		if (*tc_map >= MIRRED_TC_MAP_MAX)
> +			return -EINVAL;
> +		flags |= MIRRED_F_TC_MAP;


> +	}
> +
>   	parm = nla_data(tb[TCA_MIRRED_PARMS]);
>   
>   	exists = tcf_hash_check(tn, parm->index, a, bind);
> @@ -139,6 +150,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
>   	ASSERT_RTNL();
>   	m->tcf_action = parm->action;
>   	m->tcfm_eaction = parm->eaction;
> +	m->flags = flags;
>   	if (dev != NULL) {
>   		m->tcfm_ifindex = parm->ifindex;
>   		if (ret != ACT_P_CREATED)
> @@ -146,6 +158,8 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
>   		dev_hold(dev);
>   		rcu_assign_pointer(m->tcfm_dev, dev);
>   		m->tcfm_mac_header_xmit = mac_header_xmit;
> +		if (flags & MIRRED_F_TC_MAP)
> +			m->tcfm_tc = *tc_map & MIRRED_TC_MAP_MASK;
>   	}
>   
Is the mask a hardware limit. I dont know how these queues are
allocated - I am assuming each of these "tc queues" maps to a rx
DMA ring?

>   	if (ret == ACT_P_CREATED) {
> @@ -259,6 +273,9 @@ static int tcf_mirred_dump(struct sk_buff *skb, struct tc_action *a, int bind,
>   
>   	if (nla_put(skb, TCA_MIRRED_PARMS, sizeof(opt), &opt))
>   		goto nla_put_failure;
> +	if ((m->flags & MIRRED_F_TC_MAP) &&
> +	    nla_put_u8(skb, TCA_MIRRED_TC_MAP, m->tcfm_tc))
> +		goto nla_put_failure;
>

If you have m->tcfm_tc then I dont think you need the flags; so i would
remove it from the struct altogether.

cheers,
jamal

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox