* [PATCH net-next v3 3/4] net-next: mediatek: add support for MediaTek MT7622 SoC
From: sean.wang @ 2017-07-31 10:05 UTC (permalink / raw)
To: john, davem
Cc: nbd, netdev, linux-kernel, linux-mediatek, keyhaede, Sean Wang
In-Reply-To: <cover.1501494522.git.sean.wang@mediatek.com>
From: Sean Wang <sean.wang@mediatek.com>
This patch adds the driver for ethernet controller on MT7622 SoC. It has
the similar handling logic as the previously MT7623 does, but there are
additions against with MT7623 SoC, the shared SGMII given for the dual
GMACs and including 5-ports 10/100 embedded switch support (ESW) as the
GMAC1 option, thus more clocks consumers for the extra feature are
introduced here. So for ease portability and maintenance, those
differences all are being kept inside the platform data as other drivers
usually do. Currently testing successfully is done with those patches for
the conditions such as GMAC2 with IP1001 PHY via RGMII and GMAC1/2 with
RTL8211F PHY via SGMII.
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 67 ++++++++++++++++++++++++++++-
drivers/net/ethernet/mediatek/mtk_eth_soc.h | 54 ++++++++++++++++++++++-
2 files changed, 117 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index ad48623..9f44246 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -52,7 +52,8 @@ static const struct mtk_ethtool_stats {
};
static const char * const mtk_clks_source_name[] = {
- "ethif", "esw", "gp1", "gp2", "trgpll"
+ "ethif", "esw", "gp0", "gp1", "gp2", "trgpll", "sgmii_tx250m",
+ "sgmii_rx250m", "sgmii_cdr_ref", "sgmii_cdr_fb", "sgmii_ck", "eth2pll"
};
void mtk_w32(struct mtk_eth *eth, u32 val, unsigned reg)
@@ -162,6 +163,47 @@ static void mtk_gmac0_rgmii_adjust(struct mtk_eth *eth, int speed)
mtk_w32(eth, val, TRGMII_TCK_CTRL);
}
+static void mtk_gmac_sgmii_hw_setup(struct mtk_eth *eth, int mac_id)
+{
+ u32 val;
+
+ /* Setup the link timer and QPHY power up inside SGMIISYS */
+ regmap_write(eth->sgmiisys, SGMSYS_PCS_LINK_TIMER,
+ SGMII_LINK_TIMER_DEFAULT);
+
+ regmap_read(eth->sgmiisys, SGMSYS_SGMII_MODE, &val);
+ val |= SGMII_REMOTE_FAULT_DIS;
+ regmap_write(eth->sgmiisys, SGMSYS_SGMII_MODE, val);
+
+ regmap_read(eth->sgmiisys, SGMSYS_PCS_CONTROL_1, &val);
+ val |= SGMII_AN_RESTART;
+ regmap_write(eth->sgmiisys, SGMSYS_PCS_CONTROL_1, val);
+
+ regmap_read(eth->sgmiisys, SGMSYS_QPHY_PWR_STATE_CTRL, &val);
+ val &= ~SGMII_PHYA_PWD;
+ regmap_write(eth->sgmiisys, SGMSYS_QPHY_PWR_STATE_CTRL, val);
+
+ /* Determine MUX for which GMAC uses the SGMII interface */
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_DUAL_GMAC_SHARED_SGMII)) {
+ regmap_read(eth->ethsys, ETHSYS_SYSCFG0, &val);
+ val &= ~SYSCFG0_SGMII_MASK;
+ val |= !mac_id ? SYSCFG0_SGMII_GMAC1 : SYSCFG0_SGMII_GMAC2;
+ regmap_write(eth->ethsys, ETHSYS_SYSCFG0, val);
+
+ dev_info(eth->dev, "setup shared sgmii for gmac=%d\n",
+ mac_id);
+ }
+
+ /* Setup the GMAC1 going through SGMII path when SoC also support
+ * ESW on GMAC1
+ */
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_GMAC1_ESW | MTK_GMAC1_SGMII) &&
+ !mac_id) {
+ mtk_w32(eth, 0, MTK_MAC_MISC);
+ dev_info(eth->dev, "setup gmac1 going through sgmii");
+ }
+}
+
static void mtk_phy_link_adjust(struct net_device *dev)
{
struct mtk_mac *mac = netdev_priv(dev);
@@ -269,6 +311,7 @@ static int mtk_phy_connect(struct net_device *dev)
if (!np)
return -ENODEV;
+ mac->ge_mode = 0;
switch (of_get_phy_mode(np)) {
case PHY_INTERFACE_MODE_TRGMII:
mac->trgmii = true;
@@ -276,7 +319,10 @@ static int mtk_phy_connect(struct net_device *dev)
case PHY_INTERFACE_MODE_RGMII_RXID:
case PHY_INTERFACE_MODE_RGMII_ID:
case PHY_INTERFACE_MODE_RGMII:
- mac->ge_mode = 0;
+ break;
+ case PHY_INTERFACE_MODE_SGMII:
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_SGMII))
+ mtk_gmac_sgmii_hw_setup(eth, mac->id);
break;
case PHY_INTERFACE_MODE_MII:
mac->ge_mode = 1;
@@ -2421,6 +2467,7 @@ static int mtk_get_chip_id(struct mtk_eth *eth, u32 *chip_id)
static bool mtk_is_hwlro_supported(struct mtk_eth *eth)
{
switch (eth->chip_id) {
+ case MT7622_ETH:
case MT7623_ETH:
return true;
}
@@ -2460,6 +2507,16 @@ static int mtk_probe(struct platform_device *pdev)
return PTR_ERR(eth->ethsys);
}
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_SGMII)) {
+ eth->sgmiisys =
+ syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
+ "mediatek,sgmiisys");
+ if (IS_ERR(eth->sgmiisys)) {
+ dev_err(&pdev->dev, "no sgmiisys regmap found\n");
+ return PTR_ERR(eth->sgmiisys);
+ }
+ }
+
eth->pctl = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
"mediatek,pctl");
if (IS_ERR(eth->pctl)) {
@@ -2593,6 +2650,11 @@ static const struct mtk_soc_data mt2701_data = {
.required_clks = MT7623_CLKS_BITMAP
};
+static const struct mtk_soc_data mt7622_data = {
+ .caps = MTK_DUAL_GMAC_SHARED_SGMII | MTK_GMAC1_ESW,
+ .required_clks = MT7622_CLKS_BITMAP
+};
+
static const struct mtk_soc_data mt7623_data = {
.caps = MTK_GMAC1_TRGMII,
.required_clks = MT7623_CLKS_BITMAP
@@ -2600,6 +2662,7 @@ static const struct mtk_soc_data mt7623_data = {
const struct of_device_id of_mtk_match[] = {
{ .compatible = "mediatek,mt2701-eth", .data = &mt2701_data},
+ { .compatible = "mediatek,mt7622-eth", .data = &mt7622_data},
{ .compatible = "mediatek,mt7623-eth", .data = &mt7623_data},
{},
};
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
index 8ade23df..4594862 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
@@ -302,6 +302,9 @@
#define PHY_IAC_REG_SHIFT 25
#define PHY_IAC_TIMEOUT HZ
+#define MTK_MAC_MISC 0x1000c
+#define MTK_MUX_TO_ESW BIT(0)
+
/* Mac control registers */
#define MTK_MAC_MCR(x) (0x10100 + (x * 0x100))
#define MAC_MCR_MAX_RX_1536 BIT(24)
@@ -357,11 +360,15 @@
#define ETHSYS_CHIPID0_3 0x0
#define ETHSYS_CHIPID4_7 0x4
#define MT7623_ETH 7623
+#define MT7622_ETH 7622
/* ethernet subsystem config register */
#define ETHSYS_SYSCFG0 0x14
#define SYSCFG0_GE_MASK 0x3
#define SYSCFG0_GE_MODE(x, y) (x << (12 + (y * 2)))
+#define SYSCFG0_SGMII_MASK (3 << 8)
+#define SYSCFG0_SGMII_GMAC1 ((2 << 8) & GENMASK(9, 8))
+#define SYSCFG0_SGMII_GMAC2 ((3 << 8) & GENMASK(9, 8))
/* ethernet subsystem clock register */
#define ETHSYS_CLKCFG0 0x2c
@@ -372,6 +379,23 @@
#define RSTCTRL_FE BIT(6)
#define RSTCTRL_PPE BIT(31)
+/* SGMII subsystem config registers */
+/* Register to auto-negotiation restart */
+#define SGMSYS_PCS_CONTROL_1 0x0
+#define SGMII_AN_RESTART BIT(9)
+
+/* Register to programmable link timer, the unit in 2 * 8ns */
+#define SGMSYS_PCS_LINK_TIMER 0x18
+#define SGMII_LINK_TIMER_DEFAULT (0x186a0 & GENMASK(19, 0))
+
+/* Register to control remote fault */
+#define SGMSYS_SGMII_MODE 0x20
+#define SGMII_REMOTE_FAULT_DIS BIT(8)
+
+/* Register to power up QPHY */
+#define SGMSYS_QPHY_PWR_STATE_CTRL 0xe8
+#define SGMII_PHYA_PWD BIT(4)
+
struct mtk_rx_dma {
unsigned int rxd1;
unsigned int rxd2;
@@ -437,15 +461,31 @@ enum mtk_tx_flags {
enum mtk_clks_map {
MTK_CLK_ETHIF,
MTK_CLK_ESW,
+ MTK_CLK_GP0,
MTK_CLK_GP1,
MTK_CLK_GP2,
MTK_CLK_TRGPLL,
+ MTK_CLK_SGMII_TX_250M,
+ MTK_CLK_SGMII_RX_250M,
+ MTK_CLK_SGMII_CDR_REF,
+ MTK_CLK_SGMII_CDR_FB,
+ MTK_CLK_SGMII_CK,
+ MTK_CLK_ETH2PLL,
MTK_CLK_MAX
};
#define MT7623_CLKS_BITMAP (BIT(MTK_CLK_ETHIF) | BIT(MTK_CLK_ESW) | \
BIT(MTK_CLK_GP1) | BIT(MTK_CLK_GP2) | \
BIT(MTK_CLK_TRGPLL))
+#define MT7622_CLKS_BITMAP (BIT(MTK_CLK_ETHIF) | BIT(MTK_CLK_ESW) | \
+ BIT(MTK_CLK_GP0) | BIT(MTK_CLK_GP1) | \
+ BIT(MTK_CLK_GP2) | \
+ BIT(MTK_CLK_SGMII_TX_250M) | \
+ BIT(MTK_CLK_SGMII_RX_250M) | \
+ BIT(MTK_CLK_SGMII_CDR_REF) | \
+ BIT(MTK_CLK_SGMII_CDR_FB) | \
+ BIT(MTK_CLK_SGMII_CK) | \
+ BIT(MTK_CLK_ETH2PLL))
enum mtk_dev_state {
MTK_HW_INIT,
MTK_RESETTING
@@ -516,9 +556,16 @@ struct mtk_rx_ring {
#define MTK_TRGMII BIT(0)
#define MTK_GMAC1_TRGMII (BIT(1) | MTK_TRGMII)
+#define MTK_ESW BIT(4)
+#define MTK_GMAC1_ESW (BIT(5) | MTK_ESW)
+#define MTK_SGMII BIT(8)
+#define MTK_GMAC1_SGMII (BIT(9) | MTK_SGMII)
+#define MTK_GMAC2_SGMII (BIT(10) | MTK_SGMII)
+#define MTK_DUAL_GMAC_SHARED_SGMII (BIT(11) | MTK_GMAC1_SGMII | \
+ MTK_GMAC2_SGMII)
#define MTK_HAS_CAPS(caps, _x) (((caps) & (_x)) == (_x))
-/* struct mtk_soc_data - This is the structure holding all differences
+/* struct mtk_eth_data - This is the structure holding all differences
* among various plaforms
* @caps Flags shown the extra capability for the SoC
* @required_clks Flags shown the bitmap for required clocks on
@@ -547,6 +594,8 @@ struct mtk_soc_data {
* @msg_enable: Ethtool msg level
* @ethsys: The register map pointing at the range used to setup
* MII modes
+ * @sgmiisys: The register map pointing at the range used to setup
+ * SGMII modes
* @pctl: The register map pointing at the range used to setup
* GMAC port drive/slew values
* @dma_refcnt: track how many netdevs are using the DMA engine
@@ -560,7 +609,7 @@ struct mtk_soc_data {
* @clks: clock array for all clocks required
* @mii_bus: If there is a bus we need to create an instance for it
* @pending_work: The workqueue used to reset the dma ring
- * @state Initialization and runtime state of the device
+ * @state: Initialization and runtime state of the device
* @soc: Holding specific data among vaious SoCs
*/
@@ -577,6 +626,7 @@ struct mtk_eth {
u32 msg_enable;
unsigned long sysclk;
struct regmap *ethsys;
+ struct regmap *sgmiisys;
struct regmap *pctl;
u32 chip_id;
bool hwlro;
--
2.7.4
^ permalink raw reply related
* [PATCH net-next v3 4/4] MAINTAINERS: add Sean/Nelson as MediaTek ethernet maintainers
From: sean.wang-NuS5LvNUpcJWk0Htik3J/w @ 2017-07-31 10:05 UTC (permalink / raw)
To: john-Pj+rj9U5foFAfugRpC6u6w, davem-fT/PcQaiUtIeIZ0/mPfg9Q
Cc: nbd-p3rKhJxN3npAfugRpC6u6w, keyhaede-Re5JQEeQqe8AvxtiuMwx3w,
Nelson Chang, netdev-u79uwXL29TY76Z2rM5mHXA, Sean Wang,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
In-Reply-To: <cover.1501494522.git.sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
Sean and Nelson work for MediaTek on maintaining the MediaTek ethernet
driver for the existing SoCs and adding support for the following SoCs.
In the past, Sean has been active at making most of the qualifications
, stress test and submitting a lot of patches for the driver while
Nelson was looking into the aspects more on hardware additions and details
such as introducing PDMA with Hardware LRO to the driver. Also update
John's up-to-date mail address in the patch.
Cc: John Crispin <john-Pj+rj9U5foFAfugRpC6u6w@public.gmane.org>
Signed-off-by: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
Signed-off-by: Nelson Chang <nelson.chang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
---
MAINTAINERS | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index bd22d07..22faf704 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8431,7 +8431,9 @@ F: include/uapi/linux/uvcvideo.h
MEDIATEK ETHERNET DRIVER
M: Felix Fietkau <nbd-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
-M: John Crispin <blogic-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
+M: John Crispin <john-Pj+rj9U5foFAfugRpC6u6w@public.gmane.org>
+M: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
+M: Nelson Chang <nelson.chang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
L: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
S: Maintained
F: drivers/net/ethernet/mediatek/
--
2.7.4
^ permalink raw reply related
* Re: [RFC] net: make net.core.{r,w}mem_{default,max} namespaced
From: Eric Dumazet @ 2017-07-31 10:07 UTC (permalink / raw)
To: Matteo Croce; +Cc: netdev
In-Reply-To: <20170726170333.24580-1-mcroce@redhat.com>
On Wed, 2017-07-26 at 19:03 +0200, Matteo Croce wrote:
> The following sysctl are global and can't be read or set from a netns:
>
> net.core.rmem_default
> net.core.rmem_max
> net.core.wmem_default
> net.core.wmem_max
>
> Make the following sysctl parameters available from within a network
> namespace, allowing to set unique values per network namespace.
>
> My concern is about the initial value of this sysctl in the newly
> creates netns: I'm not sure if is better to copy them from the init
> namespace or set them to the default values.
>
> Setting them to the default value has the advantage that a new namespace
> behaves like a freshly booted system, while copying them from the init
> netns has the advantage of keeping the current behaviour as the values
> from the init netns are used.
>
> Signed-off-by: Matteo Croce <mcroce@redhat.com>
> ---
It looks that these sysctls were giving some kind of isolation.
If we make them per namespace, a malicious usage could eat all memory
and hurt other namespaces.
^ permalink raw reply
* [PATCH net] ppp: Fix a scheduling-while-atomic bug in del_chan
From: gfree.wind @ 2017-07-31 10:07 UTC (permalink / raw)
To: xeb, davem, netdev; +Cc: Gao Feng
From: Gao Feng <gfree.wind@vip.163.com>
The PPTP set the pptp_sock_destruct as the sock's sk_destruct, it would
trigger this bug when __sk_free is invoked in atomic context, because of
the call path pptp_sock_destruct->del_chan->synchronize_rcu.
Now move the synchronize_rcu to pptp_release from del_chan. This is the
only one case which would free the sock and need the synchronize_rcu.
The following is the panic I met with kernel 3.3.8, but this issue should
exist in current kernel too according to the codes.
BUG: scheduling while atomic
__schedule_bug+0x5e/0x64
__schedule+0x55/0x580
? ppp_unregister_channel+0x1cd5/0x1de0 [ppp_generic]
? dev_hard_start_xmit+0x423/0x530
? sch_direct_xmit+0x73/0x170
__cond_resched+0x16/0x30
_cond_resched+0x22/0x30
wait_for_common+0x18/0x110
? call_rcu_bh+0x10/0x10
wait_for_completion+0x12/0x20
wait_rcu_gp+0x34/0x40
? wait_rcu_gp+0x40/0x40
synchronize_sched+0x1e/0x20
0xf8417298
0xf8417484
? sock_queue_rcv_skb+0x109/0x130
__sk_free+0x16/0x110
? udp_queue_rcv_skb+0x1f2/0x290
sk_free+0x16/0x20
__udp4_lib_rcv+0x3b8/0x650
Signed-off-by: Gao Feng <gfree.wind@vip.163.com>
---
drivers/net/ppp/pptp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
index eac499c..6dde9a0 100644
--- a/drivers/net/ppp/pptp.c
+++ b/drivers/net/ppp/pptp.c
@@ -131,7 +131,6 @@ static void del_chan(struct pppox_sock *sock)
clear_bit(sock->proto.pptp.src_addr.call_id, callid_bitmap);
RCU_INIT_POINTER(callid_sock[sock->proto.pptp.src_addr.call_id], NULL);
spin_unlock(&chan_lock);
- synchronize_rcu();
}
static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
@@ -520,6 +519,7 @@ static int pptp_release(struct socket *sock)
po = pppox_sk(sk);
del_chan(po);
+ synchronize_rcu();
pppox_unbind_sock(sk);
sk->sk_state = PPPOX_DEAD;
--
1.9.1
^ permalink raw reply related
* [PATCH] netfilter: fix stringop-overflow warning with UBSAN
From: Arnd Bergmann @ 2017-07-31 10:09 UTC (permalink / raw)
To: Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
David S. Miller
Cc: Arnd Bergmann, Johannes Berg, Alexey Dobriyan, Aaron Conole,
netfilter-devel, coreteam, netdev, linux-kernel
Using gcc-7 with UBSAN enabled, we get this false-positive warning:
net/netfilter/ipset/ip_set_core.c: In function 'ip_set_sockfn_get':
net/netfilter/ipset/ip_set_core.c:1998:3: error: 'strncpy' writing 32 bytes into a region of size 2 overflows the destination [-Werror=stringop-overflow=]
strncpy(req_get->set.name, set ? set->name : "",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sizeof(req_get->set.name));
~~~~~~~~~~~~~~~~~~~~~~~~~~
This seems completely bogus, and I could not find a nice workaround.
To work around it in a less elegant way, I change the ?: operator
into an if()/else() construct.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
net/netfilter/ipset/ip_set_core.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index e495b5e484b1..d7ebb021003b 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -1995,8 +1995,12 @@ ip_set_sockfn_get(struct sock *sk, int optval, void __user *user, int *len)
}
nfnl_lock(NFNL_SUBSYS_IPSET);
set = ip_set(inst, req_get->set.index);
- strncpy(req_get->set.name, set ? set->name : "",
- IPSET_MAXNAMELEN);
+ if (set)
+ strncpy(req_get->set.name, set->name,
+ sizeof(req_get->set.name));
+ else
+ memset(req_get->set.name, '\0',
+ sizeof(req_get->set.name));
nfnl_unlock(NFNL_SUBSYS_IPSET);
goto copy;
}
--
2.9.0
^ permalink raw reply related
* Re: [PATCH 1/2] ipv6: constify inet6_protocol structures
From: Julia Lawall @ 2017-07-31 10:10 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David S. Miller, bhumirks, netdev
In-Reply-To: <1501495011.1876.12.camel@edumazet-glaptop3.roam.corp.google.com>
On Mon, 31 Jul 2017, Eric Dumazet wrote:
> On Fri, 2017-07-28 at 22:18 +0200, Julia Lawall wrote:
> > The inet6_protocol structure is only passed as the first argument to
> > inet6_add_protocol or inet6_del_protocol, both of which are declared as
> > const. Thus the inet6_protocol structure itself can be const.
> >
> > Also drop __read_mostly where present on the newly const structures.
> >
> > Done with the help of Coccinelle.
> >
> > Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> >
> > ---
> > net/ipv6/ip6_gre.c | 2 +-
> > net/ipv6/tcp_ipv6.c | 2 +-
> > net/ipv6/udp.c | 2 +-
> > 3 files changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
> > index 67ff2aa..33865d6 100644
> > --- a/net/ipv6/ip6_gre.c
> > +++ b/net/ipv6/ip6_gre.c
> > @@ -1080,7 +1080,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
> > }
> >
> >
> > -static struct inet6_protocol ip6gre_protocol __read_mostly = {
> > +static const struct inet6_protocol ip6gre_protocol = {
> > .handler = gre_rcv,
> > .err_handler = ip6gre_err,
> > .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
> > diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
> > index 90a3257..2968a33 100644
> > --- a/net/ipv6/tcp_ipv6.c
> > +++ b/net/ipv6/tcp_ipv6.c
> > @@ -1945,7 +1945,7 @@ struct proto tcpv6_prot = {
> > .diag_destroy = tcp_abort,
> > };
> >
> > -static struct inet6_protocol tcpv6_protocol = {
> > +static const struct inet6_protocol tcpv6_protocol = {
> > .early_demux = tcp_v6_early_demux,
> > .early_demux_handler = tcp_v6_early_demux,
> > .handler = tcp_v6_rcv,
> > diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
> > index 4a3e656..5f8b8d7 100644
> > --- a/net/ipv6/udp.c
> > +++ b/net/ipv6/udp.c
> > @@ -1448,7 +1448,7 @@ int compat_udpv6_getsockopt(struct sock *sk, int level, int optname,
> > }
> > #endif
> >
> > -static struct inet6_protocol udpv6_protocol = {
> > +static const struct inet6_protocol udpv6_protocol = {
> > .early_demux = udp_v6_early_demux,
> > .early_demux_handler = udp_v6_early_demux,
> > .handler = udpv6_rcv,
> >
>
> This change breaks the kernel if one of these sysctls are changed:
> tcp_early_demux, udp_early_demux
Thanks for the feedback. The structure is passed to:
int inet6_add_protocol(const struct inet6_protocol *prot, unsigned char
protocol)
{
return !cmpxchg((const struct inet6_protocol **)&inet6_protos[protocol],
NULL, prot) ? 0 : -1;
}
I guess that things go wrong because inet6_protos does not really contain
const structures, as hinted by the cast? And the purpose of declaring a
parameter as const when it is not is to allow things that actually are
able to be const to be passed in here?
thanks,
julia
>
> Check commit dddb64bcb346 ("net: Add sysctl to toggle early demux for
> tcp and udp") why at least 2 structures were no longer const.
>
> (none):~# echo 0 >/proc/sys/net/ipv4/udp_early_demux
> [ 101.746108] BUG: unable to handle kernel paging request at ffffffffb98cf5c0
> [ 101.753093] IP: proc_udp_early_demux+0x46/0x60
> [ 101.757565] PGD 13f540a067
> [ 101.757565] P4D 13f540a067
> [ 101.760372] PUD 13f540b063
> [ 101.763171] PMD 80000013f50001e1
> [ 101.765960]
> [ 101.770790] Oops: 0003 [#1] SMP
> [ 101.774376] gsmi: Log Shutdown Reason 0x03
> [ 101.778473] Modules linked in: w1_therm wire cdc_acm ehci_pci ehci_hcd mlx4_en ib_uverbs mlx4_ib ib_core mlx4_core
> [ 101.788890] CPU: 3 PID: 8819 Comm: bash Not tainted 4.13.0-smp-DEV #290
> [ 101.795549] Hardware name: Intel RML,PCH/Iota_QC_19, BIOS 2.40.0 06/22/2016
> [ 101.802517] task: ffff8e733b9c4140 task.stack: ffffa43548cd0000
> [ 101.808445] RIP: 0010:proc_udp_early_demux+0x46/0x60
> [ 101.813445] RSP: 0018:ffffa43548cd3e60 EFLAGS: 00010246
> [ 101.818676] RAX: 0000000000000000 RBX: 0000000000000001 RCX: 0000000000000000
> [ 101.825816] RDX: ffffffffb98cf5c0 RSI: 0000000000000000 RDI: ffff8e733f400100
> [ 101.832957] RBP: ffffa43548cd3e68 R08: 0000000000000000 R09: 0000000000000001
> [ 101.840096] R10: 0000000000000008 R11: f000000000000000 R12: 0000000000000001
> [ 101.847260] R13: ffffffffffffffea R14: 0000000000000002 R15: ffffffffb9d00380
> [ 101.854434] FS: 00007f7e1f34a700(0000) GS:ffff8e733f8c0000(0000) knlGS:0000000000000000
> [ 101.862518] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [ 101.868263] CR2: ffffffffb98cf5c0 CR3: 000000100f0c8000 CR4: 00000000001406e0
> [ 101.875439] Call Trace:
> [ 101.877888] proc_sys_call_handler+0xf3/0x190
> [ 101.882260] proc_sys_write+0x14/0x20
> [ 101.885944] vfs_write+0xc8/0x1e0
> [ 101.889261] SyS_write+0x48/0xa0
> [ 101.892520] entry_SYSCALL_64_fastpath+0x13/0x94
> [ 101.897137] RIP: 0033:0x7f7e1ebd64a0
> [ 101.900707] RSP: 002b:00007ffcbb851c58 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
> [ 101.908306] RAX: ffffffffffffffda RBX: 000000000232aba8 RCX: 00007f7e1ebd64a0
> [ 101.915437] RDX: 0000000000000002 RSI: 00000000022ea808 RDI: 0000000000000001
> [ 101.922567] RBP: 00007ffcbb851c50 R08: 00007f7e1ef691b0 R09: 00007f7e1f34a700
> [ 101.929698] R10: 000000000048926a R11: 0000000000000246 R12: 000000000232b288
> [ 101.936871] R13: 0000000002325e28 R14: 00000000022f0ce8 R15: 0000000000000000
> [ 101.944012] Code: 15 e8 07 84 00 8b 0d 9a 3c 7d 00 48 85 d2 74 09 31 f6 85 c9 75 21 48 89 32 48 8b 15 4d 30 84 00 48 85 d2 74 09 31 f6 85 c9 75 06 <48> 89 32 5b 5d c3 48 8b 72 08 eb f4 48 8b 72 08 eb d9 0f 1f 84
> [ 101.962907] RIP: proc_udp_early_demux+0x46/0x60 RSP: ffffa43548cd3e60
> [ 101.969353] CR2: ffffffffb98cf5c0
> [ 101.972680] ---[ end trace 116c0975bf9e19dd ]---
> [ 101.977307] Kernel panic - not syncing: Fatal exception
> [ 101.982590] Kernel Offset: 0x37e00000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
>
>
>
^ permalink raw reply
* C O N G R A T U L A T I O N S
From: WESTERN UNION ASIA @ 2017-07-31 10:00 UTC (permalink / raw)
To: Recipients
If You Are Still Using This E-mail :
- YOU WON $500,000.00 USD -
For More Details, Contact -
Name: MELISSA BINTI MUBARAK
E-mail: westernunion.melissamubarak@gmail.com
^ permalink raw reply
* Re: [PATCH] ss: Enclose IPv6 address in brackets
From: Phil Sutter @ 2017-07-31 10:30 UTC (permalink / raw)
To: Florian Lehner; +Cc: netdev, Stephen Hemminger
In-Reply-To: <fc81757c-8dbb-dbed-7a24-7011cb8bb9e0@der-flo.net>
On Sat, Jul 29, 2017 at 02:29:10PM +0200, Florian Lehner wrote:
> 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);
> if (est_len <= addr_width)
> est_len = addr_width;
Note that this will enclosed resolved hostnames in brackets as well, not
sure if that's intended. Looks like fixing that is not exactly trivial:
Hostname resolution is buried in format_host() which resides in
lib/utils.c so is shared code with ip, tc, etc. Hence, adding the
brackets in rt_addr_n2a_r() is not an option, either. Adding a 'bool *'
param to format_host() and format_host_r() indicating that name
resolution has happened might help here.
Cheers, Phil
^ permalink raw reply
* Re: [PATCH net-next v3 4/4] MAINTAINERS: add Sean/Nelson as MediaTek ethernet maintainers
From: John Crispin @ 2017-07-31 11:27 UTC (permalink / raw)
To: sean.wang, davem
Cc: nbd, netdev, linux-kernel, linux-mediatek, keyhaede, Nelson Chang
In-Reply-To: <68f201bdb4a45d376611b036b611a1d6bbdbe336.1501494522.git.sean.wang@mediatek.com>
On 31/07/17 12:05, sean.wang@mediatek.com wrote:
> From: Sean Wang <sean.wang@mediatek.com>
>
> Sean and Nelson work for MediaTek on maintaining the MediaTek ethernet
> driver for the existing SoCs and adding support for the following SoCs.
> In the past, Sean has been active at making most of the qualifications
> , stress test and submitting a lot of patches for the driver while
> Nelson was looking into the aspects more on hardware additions and details
> such as introducing PDMA with Hardware LRO to the driver. Also update
> John's up-to-date mail address in the patch.
>
> Cc: John Crispin <john@phrozen.org>
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> Signed-off-by: Nelson Chang <nelson.chang@mediatek.com>
Acked-by: John Crispin <john@phrozen.org>
> ---
> MAINTAINERS | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index bd22d07..22faf704 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -8431,7 +8431,9 @@ F: include/uapi/linux/uvcvideo.h
>
> MEDIATEK ETHERNET DRIVER
> M: Felix Fietkau <nbd@openwrt.org>
> -M: John Crispin <blogic@openwrt.org>
> +M: John Crispin <john@phrozen.org>
> +M: Sean Wang <sean.wang@mediatek.com>
> +M: Nelson Chang <nelson.chang@mediatek.com>
> L: netdev@vger.kernel.org
> S: Maintained
> F: drivers/net/ethernet/mediatek/
^ permalink raw reply
* [PATCH net-next 0/2] Refactor lan9303_xxx_packet_processing
From: Egil Hjelmeland @ 2017-07-31 11:33 UTC (permalink / raw)
To: andrew, vivien.didelot, f.fainelli, netdev, linux-kernel, kernel
Cc: Egil Hjelmeland
First patch:
Change lan9303_enable_packet_processing,
lan9303_disable_packet_processing():
Pass port number (0,1,2) as parameter instead of port offset.
Plus replaced a constant 0x400 with LAN9303_SWITCH_PORT_REG()
Second patch: Simplify accordingly.
Comments welcome!
Egil Hjelmeland (2):
net: dsa: lan9303: Refactor lan9303_xxx_packet_processing()
net: dsa: lan9303: Simplify lan9303_xxx_packet_processing() usage
drivers/net/dsa/lan9303-core.c | 73 ++++++++++++++++++++----------------------
1 file changed, 35 insertions(+), 38 deletions(-)
--
2.11.0
^ permalink raw reply
* [PATCH net-next 1/2] net: dsa: lan9303: Refactor lan9303_xxx_packet_processing()
From: Egil Hjelmeland @ 2017-07-31 11:33 UTC (permalink / raw)
To: andrew, vivien.didelot, f.fainelli, netdev, linux-kernel, kernel
Cc: Egil Hjelmeland
In-Reply-To: <20170731113355.4284-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.
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 | 59 +++++++++++++++++++++---------------------
1 file changed, 30 insertions(+), 29 deletions(-)
diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
index 8e430d1ee297..4d2bb8144c15 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
@@ -458,24 +456,25 @@ 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_reg(
+ chip,
+ LAN9303_SWITCH_PORT_REG(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_reg(
+ chip,
+ LAN9303_SWITCH_PORT_REG(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 +483,21 @@ 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_reg(
+ chip,
+ LAN9303_SWITCH_PORT_REG(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_reg(
+ chip,
+ LAN9303_SWITCH_PORT_REG(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 +561,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 +637,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 +707,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 +760,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 +779,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 net-next 2/2] net: dsa: lan9303: Simplify lan9303_xxx_packet_processing() usage
From: Egil Hjelmeland @ 2017-07-31 11:33 UTC (permalink / raw)
To: andrew, vivien.didelot, f.fainelli, netdev, linux-kernel, kernel
Cc: Egil Hjelmeland
In-Reply-To: <20170731113355.4284-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 4d2bb8144c15..705267a1d2ba 100644
--- a/drivers/net/dsa/lan9303-core.c
+++ b/drivers/net/dsa/lan9303-core.c
@@ -559,15 +559,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 <= 2; p++) {
+ int ret;
+
+ ret = lan9303_disable_packet_processing(chip, p);
+ if (ret)
+ return ret;
+ }
+ return 0;
}
static int lan9303_check_device(struct lan9303 *chip)
@@ -760,7 +761,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:
@@ -779,13 +779,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
* RE: [PATCH net-next 4/4] net: dsa: lan9303: MDIO access phy registers directly
From: David Laight @ 2017-07-31 11:44 UTC (permalink / raw)
To: 'Florian Fainelli', Vivien Didelot, Egil Hjelmeland,
andrew@lunn.ch, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, kernel@pengutronix.de
In-Reply-To: <1250382a-1c17-8e82-8c5c-fe14786c84db@gmail.com>
From: Florian Fainelli
> Sent: 28 July 2017 18:05
...
> >>>> +EXPORT_SYMBOL(lan9303_indirect_phy_ops);
> >>>
> >>> Isn't EXPORT_SYMBOL_GPL prefered over EXPORT_SYMBOL?
> >>
> >> I have no opinion. I just used the same variant as the other EXPORTS
> >> in the file.
> >
> > If there is no concern from others about this, LGTM too:
>
> Since the kernel module license is GPL, EXPORT_SYMBOL_GPL() would seem
> to be appropriate, which can be done as a subsequent patch.
It depends on whether the function needs to be usable by 'out of tree'
non-GPL modules.
This looks like a 'private' export between related modules.
The problems arise with functions like put_ns() and put_pid()
which can easily be needed by non-GPL code.
David
^ permalink raw reply
* Re: [RFC PATCH v1] net: ethernet: nb8800: Reset HW block in ndo_open
From: Mason @ 2017-07-31 11:49 UTC (permalink / raw)
To: Florian Fainelli, Mans Rullgard; +Cc: Marc Gonzalez, netdev, Linux ARM
In-Reply-To: <4ff343de-41c7-c309-04dc-983b5fe3e066@gmail.com>
On 29/07/2017 17:18, Florian Fainelli wrote:
> On 07/29/2017 05:02 AM, Mason wrote:
>
>> I have identified a 100% reproducible flaw.
>> I have proposed a work-around that brings this down to 0
>> (tested 1000 cycles of link up / ping / link down).
>
> Can you also try to get help from your HW resources to eventually help
> you find out what is going on here?
The patch I proposed /is/ based on the feedback from the HW team :-(
"Just reset the HW block, and everything will work as expected."
>> In my opinion, upstream should consider this work-around
>> for inclusion. I'd like to hear David's and Florian's
>> opinion on the topic. It's always a pain to maintain
>> out-of-tree patches.
>
> I have to agree with Mans here that the commit message explanation is
> not good enough to understand how the RX path is hosed after a call to
> ndo_stop() it would be good, both for you and for the people maintaining
> this driver to understand what happens exactly so the fix is correct,
> understood and maintainable. The patch itself looks reasonable with the
> limited description given, but it's the description itself that needs
> changing.
I have logged all register reads/writes occurring while
nb8800_stop() is executing.
1) BOARD A -- EVERYTHING WORKS AS EXPECTED
# test_eth.sh
[ 13.293669] nb8800 26000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
172.27.64.1 : xmt/rcv/%loss = 1/1/0%, min/avg/max = 0.41/0.41/0.41
[ 15.874627] nb8800_stop from __dev_close_many
[ 15.879044] ++ETH++ gw32 reg=f0026020 val=00920000
[ 15.883900] ++ETH++ gw32 reg=f0026020 val=80920000
[ 15.888969] ++ETH++ gr32 reg=f0026024 val=0000ec00
[ 15.893809] ++ETH++ gw32 reg=f0026020 val=04920000
[ 15.898697] ++ETH++ gw32 reg=f0026020 val=84920000
[ 15.903582] ++ETH++ gw32 reg=f0026020 val=00930000
[ 15.908423] ++ETH++ gw32 reg=f0026020 val=80930000
[ 15.913272] ++ETH++ gr32 reg=f0026024 val=00000000
[ 15.918160] ++ETH++ gr8 reg=f0026004 val=2b
[ 15.922459] ++ETH++ gw8 reg=f0026004 val=0b
[ 15.926782] ++ETH++ gr8 reg=f0026044 val=81
[ 15.931123] ++ETH++ gw8 reg=f0026044 val=85
[ 15.935457] ++ETH++ gw32 reg=f002610c val=9de74000
[ 15.940317] ++ETH++ gw32 reg=f0026100 val=005c0aff
[ 15.945187] ENTER nb8800_irq
[ 15.948077] ++ETH++ gr32 reg=f0026104 val=00000004
[ 15.952887] ++ETH++ gw32 reg=f0026104 val=00000004
[ 15.957697] ++ETH++ gr32 reg=f0026204 val=00000004
[ 15.962507] ++ETH++ gw32 reg=f0026204 val=00000004
[ 15.967316] ++ETH++ gw32 reg=f0026218 val=003cc4a4
[ 15.972149] ENTER nb8800_irq
[ 15.975039] ++ETH++ gr32 reg=f0026104 val=00000001
[ 15.979848] ++ETH++ gw32 reg=f0026104 val=00000001
[ 15.984658] ++ETH++ gr32 reg=f0026204 val=00000000
[ 16.045509] ++ETH++ gw32 reg=f002610c val=9de74000
[ 16.050329] ++ETH++ gw32 reg=f0026100 val=005c0aff
[ 16.055150] ENTER nb8800_irq
[ 16.058042] ++ETH++ gr32 reg=f0026104 val=00000004
[ 16.062852] ++ETH++ gw32 reg=f0026104 val=00000004
[ 16.067662] ++ETH++ gr32 reg=f0026204 val=00000004
[ 16.072470] ++ETH++ gw32 reg=f0026204 val=00000004
[ 16.077279] ++ETH++ gw32 reg=f0026218 val=003cc4a4
[ 16.082100] ENTER nb8800_irq
[ 16.084993] ++ETH++ gr32 reg=f0026104 val=00000001
[ 16.089802] ++ETH++ gw32 reg=f0026104 val=00000001
[ 16.094611] ++ETH++ gr32 reg=f0026204 val=00000000
[ 16.099454] ++ETH++ gr8 reg=f0026004 val=0b
[ 16.103752] ++ETH++ gw8 reg=f0026004 val=2b
[ 16.108057] ++ETH++ gr8 reg=f0026044 val=85
[ 16.112353] ++ETH++ gw8 reg=f0026044 val=81
[ 16.116699] ++ETH++ gw32 reg=f002620c val=9f7b2000
[ 16.121528] ++ETH++ gr8 reg=f0026004 val=2b
[ 16.125827] ++ETH++ gw8 reg=f0026004 val=2a
[ 16.130126] ++ETH++ gr32 reg=f0026100 val=00080afe
[ 16.134945] ++ETH++ gr8 reg=f0026000 val=1d
[ 16.139238] ++ETH++ gw8 reg=f0026000 val=1c
[ 16.143534] ++ETH++ gw32 reg=f0026020 val=00920000
[ 16.148363] ++ETH++ gw32 reg=f0026020 val=80920000
[ 16.153209] ++ETH++ gr32 reg=f0026024 val=00000000
[ 16.158027] ++ETH++ gw32 reg=f0026020 val=04920000
[ 16.162856] ++ETH++ gw32 reg=f0026020 val=84920000
[ 16.167702] ++ETH++ gw32 reg=f0026020 val=00930000
[ 16.172531] ++ETH++ gw32 reg=f0026020 val=80930000
[ 16.177377] ++ETH++ gr32 reg=f0026024 val=00000000
[ 16.182338] nb8800 26000.ethernet eth0: Link is Down
[ 16.187361] ++ETH++ gw32 reg=f0026020 val=00920000
[ 16.192194] ++ETH++ gw32 reg=f0026020 val=80920000
[ 16.197052] ++ETH++ gr32 reg=f0026024 val=00000000
[ 16.201887] ++ETH++ gw32 reg=f0026020 val=00920000
[ 16.206717] ++ETH++ gw32 reg=f0026020 val=80920000
[ 16.211575] ++ETH++ gr32 reg=f0026024 val=00000000
[ 16.216394] ++ETH++ gw32 reg=f0026020 val=00800000
[ 16.221235] ++ETH++ gw32 reg=f0026020 val=80800000
[ 16.226084] ++ETH++ gr32 reg=f0026024 val=00001000
[ 16.230913] ++ETH++ gw32 reg=f0026020 val=04801800
[ 16.235742] ++ETH++ gw32 reg=f0026020 val=84801800
[ 16.240620] ++ETH++ gw32 reg=f0026020 val=00920000
[ 16.245451] ++ETH++ gw32 reg=f0026020 val=80920000
[ 16.250310] ++ETH++ gr32 reg=f0026024 val=00000000
[ 16.255134] ++ETH++ gw32 reg=f0026020 val=00920000
[ 16.259964] ++ETH++ gw32 reg=f0026020 val=80920000
[ 16.264821] ++ETH++ gr32 reg=f0026024 val=00000000
[ 16.269642] ++ETH++ gw32 reg=f0026020 val=00800000
[ 16.274470] ++ETH++ gw32 reg=f0026020 val=80800000
[ 16.279316] ++ETH++ gr32 reg=f0026024 val=00001800
[ 16.284134] ++ETH++ gw32 reg=f0026020 val=04801800
[ 16.288963] ++ETH++ gw32 reg=f0026020 val=84801800
[ 16.293872] EXIT nb8800_stop
[ 20.087916] nb8800 26000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
172.27.64.1 : xmt/rcv/%loss = 1/1/0%, min/avg/max = 0.27/0.27/0.27
1) BOARD B -- RX WEDGED AFTER nb8800_stop
# test_eth.sh
[ 26.369255] nb8800 26000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
172.27.64.1 : xmt/rcv/%loss = 1/1/0%, min/avg/max = 0.34/0.34/0.34
[ 28.907583] nb8800_stop from __dev_close_many
[ 28.911997] ++ETH++ gw32 reg=f0026020 val=00920000
[ 28.916856] ++ETH++ gw32 reg=f0026020 val=80920000
[ 28.921732] ++ETH++ gr32 reg=f0026024 val=0000ec00
[ 28.926565] ++ETH++ gw32 reg=f0026020 val=04920000
[ 28.931422] ++ETH++ gw32 reg=f0026020 val=84920000
[ 28.936285] ++ETH++ gw32 reg=f0026020 val=00930000
[ 28.941134] ++ETH++ gw32 reg=f0026020 val=80930000
[ 28.945993] ++ETH++ gr32 reg=f0026024 val=00000000
[ 28.950857] ++ETH++ gr8 reg=f0026004 val=2b
[ 28.955161] ++ETH++ gw8 reg=f0026004 val=0b
[ 28.959463] ++ETH++ gr8 reg=f0026044 val=81
[ 28.963767] ++ETH++ gw8 reg=f0026044 val=85
[ 28.968067] ++ETH++ gw32 reg=f002610c val=9eed8000
[ 28.972896] ++ETH++ gw32 reg=f0026100 val=005c0aff
[ 28.977731] ENTER nb8800_irq
[ 28.980632] ++ETH++ gr32 reg=f0026104 val=00000004
[ 28.985450] ++ETH++ gw32 reg=f0026104 val=00000004
[ 28.990268] ++ETH++ gr32 reg=f0026204 val=00000004
[ 28.995085] ++ETH++ gw32 reg=f0026204 val=00000004
[ 28.999903] ++ETH++ gw32 reg=f0026218 val=003cc4a4
[ 29.004730] ENTER nb8800_irq
[ 29.007625] ++ETH++ gr32 reg=f0026104 val=00000001
[ 29.012442] ++ETH++ gw32 reg=f0026104 val=00000001
[ 29.017259] ++ETH++ gr32 reg=f0026204 val=00000000
[ 29.077759] ++ETH++ gw32 reg=f002610c val=9eed8000
[ 29.082590] ++ETH++ gw32 reg=f0026100 val=005c0aff
[ 29.087422] ENTER nb8800_irq
[ 29.090322] ++ETH++ gr32 reg=f0026104 val=00000004
[ 29.095140] ++ETH++ gw32 reg=f0026104 val=00000004
[ 29.099958] ++ETH++ gr32 reg=f0026204 val=00000004
[ 29.104774] ++ETH++ gw32 reg=f0026204 val=00000004
[ 29.109591] ++ETH++ gw32 reg=f0026218 val=003cc4a4
[ 29.114415] ENTER nb8800_irq
[ 29.117311] ++ETH++ gr32 reg=f0026104 val=00000001
[ 29.122127] ++ETH++ gw32 reg=f0026104 val=00000001
[ 29.126944] ++ETH++ gr32 reg=f0026204 val=00000000
[ 29.187460] ++ETH++ gw32 reg=f002610c val=9eed8000
[ 29.192291] ++ETH++ gw32 reg=f0026100 val=005c0aff
[ 29.197123] ENTER nb8800_irq
[ 29.198119] ++ETH++ gr8 reg=f0026004 val=0b
[ 29.198121] ++ETH++ gw8 reg=f0026004 val=2b
[ 29.198123] ++ETH++ gr8 reg=f0026044 val=85
[ 29.198125] ++ETH++ gw8 reg=f0026044 val=81
[ 29.198139] ++ETH++ gw32 reg=f002620c val=9d818000
[ 29.198141] ++ETH++ gr8 reg=f0026004 val=2b
[ 29.198143] ++ETH++ gw8 reg=f0026004 val=2a
[ 29.198145] ++ETH++ gr32 reg=f0026100 val=00080afe
[ 29.198147] ++ETH++ gr8 reg=f0026000 val=1d
[ 29.198148] ++ETH++ gw8 reg=f0026000 val=1c
[ 29.198151] ++ETH++ gw32 reg=f0026020 val=00920000
[ 29.198163] ++ETH++ gw32 reg=f0026020 val=80920000
[ 29.198193] ++ETH++ gr32 reg=f0026024 val=00000000
[ 29.198195] ++ETH++ gw32 reg=f0026020 val=04920000
[ 29.198207] ++ETH++ gw32 reg=f0026020 val=84920000
[ 29.198237] ++ETH++ gw32 reg=f0026020 val=00930000
[ 29.198249] ++ETH++ gw32 reg=f0026020 val=80930000
[ 29.198279] ++ETH++ gr32 reg=f0026024 val=00000000
[ 29.282484] ++ETH++ gr32 reg=f0026104 val=00000005
[ 29.287301] ++ETH++ gw32 reg=f0026104 val=00000005
[ 29.292118] ++ETH++ gr32 reg=f0026204 val=00000004
[ 29.296935] ++ETH++ gw32 reg=f0026204 val=00000004
[ 29.301752] ++ETH++ gw32 reg=f0026218 val=003cc4a4
[ 29.306640] nb8800 26000.ethernet eth0: Link is Down
[ 29.311664] ++ETH++ gw32 reg=f0026020 val=00920000
[ 29.316508] ++ETH++ gw32 reg=f0026020 val=80920000
[ 29.321363] ++ETH++ gr32 reg=f0026024 val=00000000
[ 29.326193] ++ETH++ gw32 reg=f0026020 val=00920000
[ 29.331031] ++ETH++ gw32 reg=f0026020 val=80920000
[ 29.335885] ++ETH++ gr32 reg=f0026024 val=00000000
[ 29.340712] ++ETH++ gw32 reg=f0026020 val=00800000
[ 29.345550] ++ETH++ gw32 reg=f0026020 val=80800000
[ 29.350405] ++ETH++ gr32 reg=f0026024 val=00001000
[ 29.355234] ++ETH++ gw32 reg=f0026020 val=04801800
[ 29.360069] ++ETH++ gw32 reg=f0026020 val=84801800
[ 29.364940] ++ETH++ gw32 reg=f0026020 val=00920000
[ 29.369777] ++ETH++ gw32 reg=f0026020 val=80920000
[ 29.374635] ++ETH++ gr32 reg=f0026024 val=00000000
[ 29.379462] ++ETH++ gw32 reg=f0026020 val=00920000
[ 29.384300] ++ETH++ gw32 reg=f0026020 val=80920000
[ 29.389153] ++ETH++ gr32 reg=f0026024 val=00000000
[ 29.393982] ++ETH++ gw32 reg=f0026020 val=00800000
[ 29.398817] ++ETH++ gw32 reg=f0026020 val=80800000
[ 29.403674] ++ETH++ gr32 reg=f0026024 val=00001800
[ 29.408499] ++ETH++ gw32 reg=f0026020 val=04801800
[ 29.413337] ++ETH++ gw32 reg=f0026020 val=84801800
[ 29.418245] EXIT nb8800_stop
[ 33.644357] nb8800 26000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
172.27.64.1 : xmt/rcv/%loss = 1/0/100%
There are only small differences between these two logs.
1) Different TRANSMIT_DESCRIPTOR_ADDRESS (0x2610c)
=> Not unexpected
2) On BOARD B, an additional
[ 29.187460] ++ETH++ gw32 reg=f002610c val=9eed8000
[ 29.192291] ++ETH++ gw32 reg=f0026100 val=005c0aff
[ 29.197123] ENTER nb8800_irq
=> Is it possible for the ISR to be running simultaneously on two cores?
0x26100 = TRANSMIT_CHANNEL_CONTROL
3) Different RECEIVE_DESCRIPTOR_ADDRESS (0x2620c)
=> Not unexpected
4) ON BOARD B, an additional
[ 29.282484] ++ETH++ gr32 reg=f0026104 val=00000005
[ 29.287301] ++ETH++ gw32 reg=f0026104 val=00000005
[ 29.292118] ++ETH++ gr32 reg=f0026204 val=00000004
[ 29.296935] ++ETH++ gw32 reg=f0026204 val=00000004
[ 29.301752] ++ETH++ gw32 reg=f0026218 val=003cc4a4
0x26104 = TRANSMIT_CHANNEL_STATUS
0x26204 = RECEIVE_CHANNEL_STATUS
0x26218 = RECEIVE_INTERRUPT_TIME
=> BOARD A didn't have to deal with two TX interrupts at the same time,
though it did deal with 1 and 4 separately.
I need to look if some of these register accesses are
racing on different cores.
Regards.
^ permalink raw reply
* Re: [RFC PATCH v1] net: ethernet: nb8800: Reset HW block in ndo_open
From: Måns Rullgård @ 2017-07-31 11:59 UTC (permalink / raw)
To: Mason; +Cc: Florian Fainelli, Marc Gonzalez, netdev, Linux ARM
In-Reply-To: <a5ef2294-2adf-743b-f877-144a8f3958b4@free.fr>
Mason <slash.tmp@free.fr> writes:
> On 29/07/2017 17:18, Florian Fainelli wrote:
>
>> On 07/29/2017 05:02 AM, Mason wrote:
>>
>>> I have identified a 100% reproducible flaw.
>>> I have proposed a work-around that brings this down to 0
>>> (tested 1000 cycles of link up / ping / link down).
>>
>> Can you also try to get help from your HW resources to eventually help
>> you find out what is going on here?
>
> The patch I proposed /is/ based on the feedback from the HW team :-(
> "Just reset the HW block, and everything will work as expected."
Nobody is saying a reset won't recover the lockup. The problem is that
we don't know what caused it to lock up in the first place. How do we
know it can't happen during normal operation? If we knew the cause, it
might also be possible to avoid the situation entirely.
--
Måns Rullgård
^ permalink raw reply
* Re: [PATCH net-next v12 1/4] net netlink: Add new type NLA_BITFIELD32
From: Jamal Hadi Salim @ 2017-07-31 12:03 UTC (permalink / raw)
To: Jiri Pirko; +Cc: davem, netdev, xiyou.wangcong, eric.dumazet, horms, dsahern
In-Reply-To: <20170731063833.GB1883@nanopsycho>
On 17-07-31 02:38 AM, Jiri Pirko wrote:
> Sun, Jul 30, 2017 at 09:59:10PM CEST, jhs@mojatatu.com wrote:
>> Jiri,
>>
>> This is getting exhausting, seriously.
>> I posted the code you are commenting one two days ago so i dont have to
>> repost.
>
> And I commented on the "*u32 = *u32" thing. But you ignored it. Pardon
> me for mentioning that again now :/
>
You commented on *u32 assignment from *void which i fixed. I
intentionally selected the different assignment names to reflect
meaning. Had you commented earlier - although I would have found
it disagreable - I would have fixed that too. Jiri, you need to be
more tolerant so progress can be made at times.
>
>>
>> On D. Ahern: I dont think we are disagreeing anymore on the need to
>> generalize the check. He is saying it should be a helper and I already
>> had the validation data; either works. I dont see the gapping need
>> to remove the validation data.
>
> DavidA? Your opinion.
>
With DavidA(reading his response) - the issue is one of taste.
Again either approach is fine. You can call helpers for every user
or make them invoked behind the scenes.
Again - like all your comments on code taste which I addressed, I
would have made that change if the comment had come in earlier. I got
exhausted. Imagine how a newbie corporate guy wouldve felt after this.
cheers,
jamal
^ permalink raw reply
* Re: [PATCH net-next v12 0/4] net sched actions: improve dump performance
From: Jamal Hadi Salim @ 2017-07-31 12:06 UTC (permalink / raw)
To: David Miller
Cc: netdev, jiri, xiyou.wangcong, eric.dumazet, horms, dsahern,
Stephen Hemminger
In-Reply-To: <20170730.192836.370680005861016480.davem@davemloft.net>
[-- Attachment #1: Type: text/plain, Size: 232 bytes --]
On 17-07-30 10:28 PM, David Miller wrote:
>
> Series applied, thanks.
>
Thanks David.
Attaching the iproute2 patch. I will submit an official one with
man page changes later. Stephen - you take net-next changes?
cheers,
jamal
[-- Attachment #2: large-dump-patch --]
[-- Type: text/plain, Size: 13793 bytes --]
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 3a53b9a..f4fc9c9 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -1,5 +1,5 @@
-#ifndef __LINUX_NETLINK_H
-#define __LINUX_NETLINK_H
+#ifndef _UAPI__LINUX_NETLINK_H
+#define _UAPI__LINUX_NETLINK_H
#include <linux/kernel.h>
#include <linux/socket.h> /* for __kernel_sa_family_t */
@@ -143,8 +143,10 @@ enum nlmsgerr_attrs {
#define NETLINK_PKTINFO 3
#define NETLINK_BROADCAST_ERROR 4
#define NETLINK_NO_ENOBUFS 5
+#ifndef __KERNEL__
#define NETLINK_RX_RING 6
#define NETLINK_TX_RING 7
+#endif
#define NETLINK_LISTEN_ALL_NSID 8
#define NETLINK_LIST_MEMBERSHIPS 9
#define NETLINK_CAP_ACK 10
@@ -171,6 +173,7 @@ struct nl_mmap_hdr {
__u32 nm_gid;
};
+#ifndef __KERNEL__
enum nl_mmap_status {
NL_MMAP_STATUS_UNUSED,
NL_MMAP_STATUS_RESERVED,
@@ -182,6 +185,7 @@ enum nl_mmap_status {
#define NL_MMAP_MSG_ALIGNMENT NLMSG_ALIGNTO
#define NL_MMAP_MSG_ALIGN(sz) __ALIGN_KERNEL(sz, NL_MMAP_MSG_ALIGNMENT)
#define NL_MMAP_HDRLEN NL_MMAP_MSG_ALIGN(sizeof(struct nl_mmap_hdr))
+#endif
#define NET_MAJOR 36 /* Major 36 is reserved for networking */
@@ -222,5 +226,22 @@ struct nlattr {
#define NLA_ALIGN(len) (((len) + NLA_ALIGNTO - 1) & ~(NLA_ALIGNTO - 1))
#define NLA_HDRLEN ((int) NLA_ALIGN(sizeof(struct nlattr)))
+/* Generic 32 bitflags attribute content sent to the kernel.
+ *
+ * The value is a bitmap that defines the values being set
+ * The selector is a bitmask that defines which value is legit
+ *
+ * Examples:
+ * value = 0x0, and selector = 0x1
+ * implies we are selecting bit 1 and we want to set its value to 0.
+ *
+ * value = 0x2, and selector = 0x2
+ * implies we are selecting bit 2 and we want to set its value to 1.
+ *
+ */
+struct nla_bitfield32 {
+ __u32 value;
+ __u32 selector;
+};
-#endif /* __LINUX_NETLINK_H */
+#endif /* _UAPI__LINUX_NETLINK_H */
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 1d62dad..dab7dad 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -1,5 +1,5 @@
-#ifndef __LINUX_RTNETLINK_H
-#define __LINUX_RTNETLINK_H
+#ifndef _UAPI__LINUX_RTNETLINK_H
+#define _UAPI__LINUX_RTNETLINK_H
#include <linux/types.h>
#include <linux/netlink.h>
@@ -586,6 +586,7 @@ enum {
#define NDUSEROPT_MAX (__NDUSEROPT_MAX - 1)
+#ifndef __KERNEL__
/* RTnetlink multicast groups - backwards compatibility for userspace */
#define RTMGRP_LINK 1
#define RTMGRP_NOTIFY 2
@@ -606,6 +607,7 @@ enum {
#define RTMGRP_DECnet_ROUTE 0x4000
#define RTMGRP_IPV6_PREFIX 0x20000
+#endif
/* RTnetlink multicast groups */
enum rtnetlink_groups {
@@ -681,10 +683,29 @@ struct tcamsg {
unsigned char tca__pad1;
unsigned short tca__pad2;
};
+
+enum {
+ TCA_ROOT_UNSPEC,
+ TCA_ROOT_TAB,
+#define TCA_ACT_TAB TCA_ROOT_TAB
+#define TCAA_MAX TCA_ROOT_TAB
+ TCA_ROOT_FLAGS,
+ TCA_ROOT_COUNT,
+ TCA_ROOT_TIME_DELTA, /* in msecs */
+ __TCA_ROOT_MAX,
+#define TCA_ROOT_MAX (__TCA_ROOT_MAX - 1)
+};
+
#define TA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcamsg))))
#define TA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcamsg))
-#define TCA_ACT_TAB 1 /* attr type must be >=1 */
-#define TCAA_MAX 1
+/* tcamsg flags stored in attribute TCA_ROOT_FLAGS
+ *
+ * TCA_FLAG_LARGE_DUMP_ON user->kernel to request for larger than TCA_ACT_MAX_PRIO
+ * actions in a dump. All dump responses will contain the number of actions
+ * being dumped stored in for user app's consumption in TCA_ROOT_COUNT
+ *
+ */
+#define TCA_FLAG_LARGE_DUMP_ON (1 << 0)
/* New extended info filters for IFLA_EXT_MASK */
#define RTEXT_FILTER_VF (1 << 0)
@@ -696,4 +717,4 @@ struct tcamsg {
-#endif /* __LINUX_RTNETLINK_H */
+#endif /* _UAPI__LINUX_RTNETLINK_H */
diff --git a/tc/f_basic.c b/tc/f_basic.c
index d663668..8370ea6 100644
--- a/tc/f_basic.c
+++ b/tc/f_basic.c
@@ -135,7 +135,7 @@ static int basic_print_opt(struct filter_util *qu, FILE *f,
}
if (tb[TCA_BASIC_ACT]) {
- tc_print_action(f, tb[TCA_BASIC_ACT]);
+ tc_print_action(f, tb[TCA_BASIC_ACT], 0);
}
return 0;
diff --git a/tc/f_bpf.c b/tc/f_bpf.c
index 2f8d12a..c115409 100644
--- a/tc/f_bpf.c
+++ b/tc/f_bpf.c
@@ -239,7 +239,7 @@ static int bpf_print_opt(struct filter_util *qu, FILE *f,
}
if (tb[TCA_BPF_ACT])
- tc_print_action(f, tb[TCA_BPF_ACT]);
+ tc_print_action(f, tb[TCA_BPF_ACT], 0);
return 0;
}
diff --git a/tc/f_cgroup.c b/tc/f_cgroup.c
index ecf9909..633700e 100644
--- a/tc/f_cgroup.c
+++ b/tc/f_cgroup.c
@@ -102,7 +102,7 @@ static int cgroup_print_opt(struct filter_util *qu, FILE *f,
}
if (tb[TCA_CGROUP_ACT])
- tc_print_action(f, tb[TCA_CGROUP_ACT]);
+ tc_print_action(f, tb[TCA_CGROUP_ACT], 0);
return 0;
}
diff --git a/tc/f_flow.c b/tc/f_flow.c
index 09ddcaa..b157104 100644
--- a/tc/f_flow.c
+++ b/tc/f_flow.c
@@ -347,7 +347,7 @@ static int flow_print_opt(struct filter_util *fu, FILE *f, struct rtattr *opt,
tc_print_police(f, tb[TCA_FLOW_POLICE]);
if (tb[TCA_FLOW_ACT]) {
fprintf(f, "\n");
- tc_print_action(f, tb[TCA_FLOW_ACT]);
+ tc_print_action(f, tb[TCA_FLOW_ACT], 0);
}
return 0;
}
diff --git a/tc/f_flower.c b/tc/f_flower.c
index 5be693a..934832e 100644
--- a/tc/f_flower.c
+++ b/tc/f_flower.c
@@ -1316,7 +1316,7 @@ static int flower_print_opt(struct filter_util *qu, FILE *f,
}
if (tb[TCA_FLOWER_ACT])
- tc_print_action(f, tb[TCA_FLOWER_ACT]);
+ tc_print_action(f, tb[TCA_FLOWER_ACT], 0);
return 0;
}
diff --git a/tc/f_fw.c b/tc/f_fw.c
index 790bef9..c39789b 100644
--- a/tc/f_fw.c
+++ b/tc/f_fw.c
@@ -160,7 +160,7 @@ static int fw_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u
if (tb[TCA_FW_ACT]) {
fprintf(f, "\n");
- tc_print_action(f, tb[TCA_FW_ACT]);
+ tc_print_action(f, tb[TCA_FW_ACT], 0);
}
return 0;
}
diff --git a/tc/f_matchall.c b/tc/f_matchall.c
index 5a51e75..d78660e 100644
--- a/tc/f_matchall.c
+++ b/tc/f_matchall.c
@@ -145,7 +145,7 @@ static int matchall_print_opt(struct filter_util *qu, FILE *f,
}
if (tb[TCA_MATCHALL_ACT])
- tc_print_action(f, tb[TCA_MATCHALL_ACT]);
+ tc_print_action(f, tb[TCA_MATCHALL_ACT], 0);
return 0;
}
diff --git a/tc/f_route.c b/tc/f_route.c
index 30514c4..e88313f 100644
--- a/tc/f_route.c
+++ b/tc/f_route.c
@@ -168,7 +168,7 @@ static int route_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt,
if (tb[TCA_ROUTE4_POLICE])
tc_print_police(f, tb[TCA_ROUTE4_POLICE]);
if (tb[TCA_ROUTE4_ACT])
- tc_print_action(f, tb[TCA_ROUTE4_ACT]);
+ tc_print_action(f, tb[TCA_ROUTE4_ACT], 0);
return 0;
}
diff --git a/tc/f_rsvp.c b/tc/f_rsvp.c
index 94bfbef..65caeb4 100644
--- a/tc/f_rsvp.c
+++ b/tc/f_rsvp.c
@@ -402,7 +402,7 @@ static int rsvp_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, _
}
if (tb[TCA_RSVP_ACT]) {
- tc_print_action(f, tb[TCA_RSVP_ACT]);
+ tc_print_action(f, tb[TCA_RSVP_ACT], 0);
}
if (tb[TCA_RSVP_POLICE])
tc_print_police(f, tb[TCA_RSVP_POLICE]);
diff --git a/tc/f_tcindex.c b/tc/f_tcindex.c
index 784c890..dd1cb47 100644
--- a/tc/f_tcindex.c
+++ b/tc/f_tcindex.c
@@ -173,7 +173,7 @@ static int tcindex_print_opt(struct filter_util *qu, FILE *f,
}
if (tb[TCA_TCINDEX_ACT]) {
fprintf(f, "\n");
- tc_print_action(f, tb[TCA_TCINDEX_ACT]);
+ tc_print_action(f, tb[TCA_TCINDEX_ACT], 0);
}
return 0;
}
diff --git a/tc/f_u32.c b/tc/f_u32.c
index b272c2c..5815be9 100644
--- a/tc/f_u32.c
+++ b/tc/f_u32.c
@@ -1337,7 +1337,7 @@ static int u32_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt,
}
if (tb[TCA_U32_ACT])
- tc_print_action(f, tb[TCA_U32_ACT]);
+ tc_print_action(f, tb[TCA_U32_ACT], 0);
return 0;
}
diff --git a/tc/m_action.c b/tc/m_action.c
index 6ebe85e..123295c 100644
--- a/tc/m_action.c
+++ b/tc/m_action.c
@@ -346,21 +346,24 @@ tc_print_action_flush(FILE *f, const struct rtattr *arg)
}
int
-tc_print_action(FILE *f, const struct rtattr *arg)
+tc_print_action(FILE *f, const struct rtattr *arg, unsigned short tot_acts)
{
int i;
- struct rtattr *tb[TCA_ACT_MAX_PRIO + 1];
if (arg == NULL)
return 0;
- parse_rtattr_nested(tb, TCA_ACT_MAX_PRIO, arg);
+ if (!tot_acts)
+ tot_acts = TCA_ACT_MAX_PRIO;
+
+ struct rtattr *tb[tot_acts + 1];
+ parse_rtattr_nested(tb, tot_acts, arg);
if (tab_flush && NULL != tb[0] && NULL == tb[1])
return tc_print_action_flush(f, tb[0]);
- for (i = 0; i < TCA_ACT_MAX_PRIO; i++) {
+ for (i = 0; i < tot_acts; i++) {
if (tb[i]) {
fprintf(f, "\n\taction order %d: ", i);
if (tc_print_one_action(f, tb[i]) < 0) {
@@ -380,7 +383,8 @@ int print_action(const struct sockaddr_nl *who,
FILE *fp = (FILE *)arg;
struct tcamsg *t = NLMSG_DATA(n);
int len = n->nlmsg_len;
- struct rtattr *tb[TCAA_MAX+1];
+ __u32 *tot_acts = NULL;
+ struct rtattr *tb[TCA_ROOT_MAX+1];
len -= NLMSG_LENGTH(sizeof(*t));
@@ -389,8 +393,12 @@ int print_action(const struct sockaddr_nl *who,
return -1;
}
- parse_rtattr(tb, TCAA_MAX, TA_RTA(t), len);
+ parse_rtattr(tb, TCA_ROOT_MAX, TA_RTA(t), len);
+
+ if (tb[TCA_ROOT_COUNT])
+ tot_acts = RTA_DATA(tb[TCA_ROOT_COUNT]);
+ fprintf(fp, "total acts %d \n", tot_acts?*tot_acts:0);
if (tb[TCA_ACT_TAB] == NULL) {
if (n->nlmsg_type != RTM_GETACTION)
fprintf(stderr, "print_action: NULL kind\n");
@@ -414,7 +422,9 @@ int print_action(const struct sockaddr_nl *who,
fprintf(fp, "Replaced action ");
}
}
- tc_print_action(fp, tb[TCA_ACT_TAB]);
+
+
+ tc_print_action(fp, tb[TCA_ACT_TAB], tot_acts?*tot_acts:0);
return 0;
}
@@ -427,7 +437,7 @@ static int tc_action_gd(int cmd, unsigned int flags, int *argc_p, char ***argv_p
char **argv = *argv_p;
int prio = 0;
int ret = 0;
- __u32 i;
+ __u32 i = 0;
struct rtattr *tail;
struct rtattr *tail2;
struct nlmsghdr *ans = NULL;
@@ -498,7 +508,8 @@ static int tc_action_gd(int cmd, unsigned int flags, int *argc_p, char ***argv_p
tail2 = NLMSG_TAIL(&req.n);
addattr_l(&req.n, MAX_MSG, ++prio, NULL, 0);
addattr_l(&req.n, MAX_MSG, TCA_ACT_KIND, k, strlen(k) + 1);
- addattr32(&req.n, MAX_MSG, TCA_ACT_INDEX, i);
+ if (i > 0)
+ addattr32(&req.n, MAX_MSG, TCA_ACT_INDEX, i);
tail2->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail2;
}
@@ -561,12 +572,16 @@ static int tc_action_modify(int cmd, unsigned int flags, int *argc_p, char ***ar
return ret;
}
-static int tc_act_list_or_flush(int argc, char **argv, int event)
+static int tc_act_list_or_flush(int *argc_p, char ***argv_p, int event)
{
+ struct rtattr *tail, *tail2, *tail3, *tail4;
int ret = 0, prio = 0, msg_size = 0;
- char k[16];
- struct rtattr *tail, *tail2;
struct action_util *a = NULL;
+ struct nla_bitfield32 flag_select = { 0 };
+ char **argv = *argv_p;
+ __u32 msec_since = 0;
+ int argc = *argc_p;
+ char k[16];
struct {
struct nlmsghdr n;
struct tcamsg t;
@@ -597,11 +612,40 @@ static int tc_act_list_or_flush(int argc, char **argv, int event)
}
strncpy(k, *argv, sizeof(k) - 1);
+ argc -= 1;
+ argv += 1;
+
+ if (argc && (strcmp(*argv, "since") == 0)) {
+ NEXT_ARG();
+ if (get_u32(&msec_since, *argv, 0))
+ invarg("dump time \"since\" is invalid", *argv);
+ }
+
addattr_l(&req.n, MAX_MSG, ++prio, NULL, 0);
addattr_l(&req.n, MAX_MSG, TCA_ACT_KIND, k, strlen(k) + 1);
tail2->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail2;
tail->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail;
+ tail3 = NLMSG_TAIL(&req.n);
+#if 1
+ flag_select.value |= TCA_FLAG_LARGE_DUMP_ON;
+ flag_select.selector |= TCA_FLAG_LARGE_DUMP_ON;
+#endif
+#if 0
+ flag_select.value |= 8; /* test rejection */
+ flag_select.selector |= 8; /* test rejection */
+ flag_select.value = 0; /* test rejection */
+ flag_select.selector |= TCA_FLAG_LARGE_DUMP_ON; /* test rejection */
+#endif
+ addattr_l(&req.n, MAX_MSG, TCA_ROOT_FLAGS, &flag_select,
+ sizeof(struct nla_bitfield32));
+ tail3->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail3;
+ if (msec_since) {
+ fprintf(stderr, "XXX: since %d\n", msec_since);
+ tail4 = NLMSG_TAIL(&req.n);
+ addattr32(&req.n, MAX_MSG, TCA_ROOT_TIME_DELTA, msec_since);
+ tail4->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail4;
+ }
msg_size = NLMSG_ALIGN(req.n.nlmsg_len) - NLMSG_ALIGN(sizeof(struct nlmsghdr));
if (event == RTM_GETACTION) {
@@ -626,6 +670,8 @@ static int tc_act_list_or_flush(int argc, char **argv, int event)
bad_val:
+ *argc_p = argc;
+ *argv_p = argv;
return ret;
}
@@ -655,13 +701,21 @@ int do_action(int argc, char **argv)
act_usage();
return -1;
}
- return tc_act_list_or_flush(argc-2, argv+2, RTM_GETACTION);
+
+ argc -= 2;
+ argv += 2;
+ return tc_act_list_or_flush(&argc, &argv,
+ RTM_GETACTION);
} else if (matches(*argv, "flush") == 0) {
if (argc <= 2) {
act_usage();
return -1;
}
- return tc_act_list_or_flush(argc-2, argv+2, RTM_DELACTION);
+
+ argc -= 2;
+ argv += 2;
+ return tc_act_list_or_flush(&argc, &argv,
+ RTM_DELACTION);
} else if (matches(*argv, "help") == 0) {
act_usage();
return -1;
diff --git a/tc/tc_util.h b/tc/tc_util.h
index 5c54ad3..583a21a 100644
--- a/tc/tc_util.h
+++ b/tc/tc_util.h
@@ -113,7 +113,7 @@ int act_parse_police(struct action_util *a, int *argc_p,
char ***argv_p, int tca_id, struct nlmsghdr *n);
int print_police(struct action_util *a, FILE *f, struct rtattr *tb);
int police_print_xstats(struct action_util *a, FILE *f, struct rtattr *tb);
-int tc_print_action(FILE *f, const struct rtattr *tb);
+int tc_print_action(FILE *f, const struct rtattr *tb, unsigned short tot_acts);
int tc_print_ipt(FILE *f, const struct rtattr *tb);
int parse_action(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n);
void print_tm(FILE *f, const struct tcf_t *tm);
^ permalink raw reply related
* Re: [patch net-next 04/20] net: sched: use tcf_exts_has_actions in tcf_exts_exec
From: Jamal Hadi Salim @ 2017-07-31 12:09 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev, davem, xiyou.wangcong, daniel, mlxsw
In-Reply-To: <20170731063613.GA1883@nanopsycho>
On 17-07-31 02:36 AM, Jiri Pirko wrote:
> Sun, Jul 30, 2017 at 09:48:24PM CEST, jhs@mojatatu.com wrote:
>> I am probably missing something. All those changes to just
>> replace "if (exts->nr_actions)" with "if (tcf_exts_has_actions(exts))" ?
>
> That is what the description says :)
>
I meant I wouldve expected few liners added/removed.
cheers,
jamal
^ permalink raw reply
* [PATCH-net-next] net: add skb_frag_foreach_page and use with kmap_atomic
From: Willem de Bruijn @ 2017-07-31 12:15 UTC (permalink / raw)
To: netdev; +Cc: davem, Willem de Bruijn
From: Willem de Bruijn <willemb@google.com>
Skb frags may contain compound pages. Various operations map frags
temporarily using kmap_atomic, but this function works on single
pages, not whole compound pages. The distinction is only relevant
for high mem pages that require temporary mappings.
Introduce a looping mechanism that for compound highmem pages maps
one page at a time, does not change behavior on other pages.
Use the loop in the kmap_atomic callers in net/core/skbuff.c.
Verified by triggering skb_copy_bits with
tcpdump -n -c 100 -i ${DEV} -w /dev/null &
netperf -t TCP_STREAM -H ${HOST}
and by triggering __skb_checksum with
ethtool -K ${DEV} tx off
repeated the tests with looping on a non-highmem platform
(x86_64) by making skb_frag_must_loop always return true.
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
Changes
RFC -> v1: rebased only
---
include/linux/skbuff.h | 36 +++++++++++++++++++++
net/core/skbuff.c | 88 +++++++++++++++++++++++++++++++++-----------------
2 files changed, 95 insertions(+), 29 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 4093552be1de..e8c855be453a 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -345,6 +345,42 @@ static inline void skb_frag_size_sub(skb_frag_t *frag, int delta)
frag->size -= delta;
}
+static inline bool skb_frag_must_loop(struct page *p)
+{
+#if defined(CONFIG_HIGHMEM)
+ if (PageHighMem(p))
+ return true;
+#endif
+ return false;
+}
+
+/**
+ * skb_frag_foreach_page - loop over pages in a fragment
+ *
+ * @f: skb frag to operate on
+ * @f_off: offset from start of f->page.p
+ * @f_len: length from f_off to loop over
+ * @p: (temp var) current page
+ * @p_off: (temp var) offset from start of current page,
+ * non-zero only on first page.
+ * @p_len: (temp var) length in current page,
+ * < PAGE_SIZE only on first and last page.
+ * @copied: (temp var) length so far, excluding current p_len.
+ *
+ * A fragment can hold a compound page, in which case per-page
+ * operations, notably kmap_atomic, must be called for each
+ * regular page.
+ */
+#define skb_frag_foreach_page(f, f_off, f_len, p, p_off, p_len, copied) \
+ for (p = skb_frag_page(f) + ((f_off) >> PAGE_SHIFT), \
+ p_off = (f_off) & (PAGE_SIZE - 1), \
+ p_len = skb_frag_must_loop(p) ? \
+ min_t(u32, f_len, PAGE_SIZE - p_off) : f_len, \
+ copied = 0; \
+ copied < f_len; \
+ copied += p_len, p++, p_off = 0, \
+ p_len = min_t(u32, f_len - copied, PAGE_SIZE)) \
+
#define HAVE_HW_TIME_STAMP
/**
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index c27da51d14e4..fe4ebbaed8c4 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -938,8 +938,10 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask)
struct ubuf_info *uarg = skb_shinfo(skb)->destructor_arg;
for (i = 0; i < num_frags; i++) {
- u8 *vaddr;
skb_frag_t *f = &skb_shinfo(skb)->frags[i];
+ u32 p_off, p_len, copied;
+ struct page *p;
+ u8 *vaddr;
page = alloc_page(gfp_mask);
if (!page) {
@@ -950,10 +952,15 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask)
}
return -ENOMEM;
}
- vaddr = kmap_atomic(skb_frag_page(f));
- memcpy(page_address(page),
- vaddr + f->page_offset, skb_frag_size(f));
- kunmap_atomic(vaddr);
+
+ skb_frag_foreach_page(f, f->page_offset, skb_frag_size(f),
+ p, p_off, p_len, copied) {
+ vaddr = kmap_atomic(p);
+ memcpy(page_address(page) + copied, vaddr + p_off,
+ p_len);
+ kunmap_atomic(vaddr);
+ }
+
set_page_private(page, (unsigned long)head);
head = page;
}
@@ -1753,16 +1760,20 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len)
end = start + skb_frag_size(f);
if ((copy = end - offset) > 0) {
+ u32 p_off, p_len, copied;
+ struct page *p;
u8 *vaddr;
if (copy > len)
copy = len;
- vaddr = kmap_atomic(skb_frag_page(f));
- memcpy(to,
- vaddr + f->page_offset + offset - start,
- copy);
- kunmap_atomic(vaddr);
+ skb_frag_foreach_page(f,
+ f->page_offset + offset - start,
+ copy, p, p_off, p_len, copied) {
+ vaddr = kmap_atomic(p);
+ memcpy(to + copied, vaddr + p_off, p_len);
+ kunmap_atomic(vaddr);
+ }
if ((len -= copy) == 0)
return 0;
@@ -2021,15 +2032,20 @@ int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len)
end = start + skb_frag_size(frag);
if ((copy = end - offset) > 0) {
+ u32 p_off, p_len, copied;
+ struct page *p;
u8 *vaddr;
if (copy > len)
copy = len;
- vaddr = kmap_atomic(skb_frag_page(frag));
- memcpy(vaddr + frag->page_offset + offset - start,
- from, copy);
- kunmap_atomic(vaddr);
+ skb_frag_foreach_page(frag,
+ frag->page_offset + offset - start,
+ copy, p, p_off, p_len, copied) {
+ vaddr = kmap_atomic(p);
+ memcpy(vaddr + p_off, from + copied, p_len);
+ kunmap_atomic(vaddr);
+ }
if ((len -= copy) == 0)
return 0;
@@ -2094,20 +2110,27 @@ __wsum __skb_checksum(const struct sk_buff *skb, int offset, int len,
end = start + skb_frag_size(frag);
if ((copy = end - offset) > 0) {
+ u32 p_off, p_len, copied;
+ struct page *p;
__wsum csum2;
u8 *vaddr;
if (copy > len)
copy = len;
- vaddr = kmap_atomic(skb_frag_page(frag));
- csum2 = ops->update(vaddr + frag->page_offset +
- offset - start, copy, 0);
- kunmap_atomic(vaddr);
- csum = ops->combine(csum, csum2, pos, copy);
+
+ skb_frag_foreach_page(frag,
+ frag->page_offset + offset - start,
+ copy, p, p_off, p_len, copied) {
+ vaddr = kmap_atomic(p);
+ csum2 = ops->update(vaddr + p_off, p_len, 0);
+ kunmap_atomic(vaddr);
+ csum = ops->combine(csum, csum2, pos, p_len);
+ pos += p_len;
+ }
+
if (!(len -= copy))
return csum;
offset += copy;
- pos += copy;
}
start = end;
}
@@ -2180,24 +2203,31 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
end = start + skb_frag_size(&skb_shinfo(skb)->frags[i]);
if ((copy = end - offset) > 0) {
+ skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
+ u32 p_off, p_len, copied;
+ struct page *p;
__wsum csum2;
u8 *vaddr;
- skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
if (copy > len)
copy = len;
- vaddr = kmap_atomic(skb_frag_page(frag));
- csum2 = csum_partial_copy_nocheck(vaddr +
- frag->page_offset +
- offset - start, to,
- copy, 0);
- kunmap_atomic(vaddr);
- csum = csum_block_add(csum, csum2, pos);
+
+ skb_frag_foreach_page(frag,
+ frag->page_offset + offset - start,
+ copy, p, p_off, p_len, copied) {
+ vaddr = kmap_atomic(p);
+ csum2 = csum_partial_copy_nocheck(vaddr + p_off,
+ to + copied,
+ p_len, 0);
+ kunmap_atomic(vaddr);
+ csum = csum_block_add(csum, csum2, pos);
+ pos += p_len;
+ }
+
if (!(len -= copy))
return csum;
offset += copy;
to += copy;
- pos += copy;
}
start = end;
}
--
2.14.0.rc0.400.g1c36432dff-goog
^ permalink raw reply related
* Re: [PATCH 0/3] net-next: stmmac: support future possible different internal phy mode
From: Chen-Yu Tsai @ 2017-07-31 12:19 UTC (permalink / raw)
To: Corentin Labbe
Cc: Florian Fainelli, Andrew Lunn, Rob Herring, Mark Rutland,
Maxime Ripard, Chen-Yu Tsai, Russell King, Giuseppe Cavallaro,
alexandre.torgue-qxv4g6HH51o, devicetree, netdev, linux-kernel,
linux-sunxi, linux-arm-kernel, Icenowy Zheng
In-Reply-To: <20170729064815.GA2024@Red>
On Sat, Jul 29, 2017 at 2:48 PM, Corentin Labbe
<clabbe.montjoie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> On Fri, Jul 28, 2017 at 10:54:30AM -0700, Florian Fainelli wrote:
>> On 07/28/2017 07:44 AM, Corentin Labbe wrote:
>> > On Fri, Jul 28, 2017 at 04:36:00PM +0200, Andrew Lunn wrote:
>> >>>> I've probably asked this before: Does the internal PHY use a different
>> >>>> PHY ID in registers 2 and 3?
>> >>>>
>> >>>
>> >>> yes
>> >>>
>> >>> reg2: 0x0044
>> >>> reg3: 0X1500
>> >
>> > Copy/paste error, its 1400
>> >
>> >>
>> >> So this is not about loading the correct PHY driver. You can already
>> >> do this based on the PHY IDs...
>> >>
>> >> This is about selecting which PHY to use. Internal or External?
>> >>
>> >> Andrew
>> >
>> > It is too late when we know the PHY ID.
>>
>> > We need to set a syscon for choosing external/internal PHY.
>> > So we can rely only on DT.
>>
>> Since the Device Tree needs to be correct to identify which PHY to use
>> (internal or external), if you use the standard compatible string for
>> the PHY that contains its OUI, e.g:
>>
>> compatible = "ethernet-phy-id0044.1400", "ethernet-phy-ieee802.3-c22"
>>
>> then you can have your Ethernet MAC identify whether this is an internal
>> PHY by having a list of compatible strings to match against.
>
> So basicly, I replace sun8i-h3-ephy by ethernet-phy-id0044.1400 and it is good ?
IIRC you mentioned some time ago the PHY in the AC200 also has this ID?
Do you remember if this is true?
If someone were crazy enough to hook that up to the H3, then we still
wouldn't be able to tell if it's the internal or external one.
ChenYu
>
>>
>> Corentin, can you make sure you copy netdev, Andrew and myself on the
>> next submissions so we don't have to keep track of seemingly identical
>> threads (this one + the rockchip dwmac changes) and we can work towards
>> one solution?
>
> Ok
>
> Thanks
> Corentin Labbe
--
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 v12 1/4] net netlink: Add new type NLA_BITFIELD32
From: Jiri Pirko @ 2017-07-31 12:21 UTC (permalink / raw)
To: Jamal Hadi Salim
Cc: davem, netdev, xiyou.wangcong, eric.dumazet, horms, dsahern
In-Reply-To: <fa171203-adab-9950-8241-dd5b3a70fe0a@mojatatu.com>
Mon, Jul 31, 2017 at 02:03:55PM CEST, jhs@mojatatu.com wrote:
>On 17-07-31 02:38 AM, Jiri Pirko wrote:
>> Sun, Jul 30, 2017 at 09:59:10PM CEST, jhs@mojatatu.com wrote:
>> > Jiri,
>> >
>> > This is getting exhausting, seriously.
>> > I posted the code you are commenting one two days ago so i dont have to
>> > repost.
>>
>> And I commented on the "*u32 = *u32" thing. But you ignored it. Pardon
>> me for mentioning that again now :/
>>
>
>You commented on *u32 assignment from *void which i fixed. I
>intentionally selected the different assignment names to reflect
>meaning. Had you commented earlier - although I would have found
Yep, I don't understand why the function arg cannot have the desired
name right away. Also, I don't understand why you don't just have u32
instead of pointer as a local variable, if you really needed this local
variable. Ok, I admit that ":)" is probably not intuitive comment.
Will be more blunt next time.
>it disagreable - I would have fixed that too. Jiri, you need to be
>more tolerant so progress can be made at times.
I don't think so. I believe that it is really important that code can be
read nicely. If we don't do it, it will be just mess (like it is in lot
of net/sched/ places).
>
>>
>> >
>> > On D. Ahern: I dont think we are disagreeing anymore on the need to
>> > generalize the check. He is saying it should be a helper and I already
>> > had the validation data; either works. I dont see the gapping need
>> > to remove the validation data.
>>
>> DavidA? Your opinion.
>>
>
>With DavidA(reading his response) - the issue is one of taste.
>Again either approach is fine. You can call helpers for every user
>or make them invoked behind the scenes.
>Again - like all your comments on code taste which I addressed, I
>would have made that change if the comment had come in earlier. I got
>exhausted. Imagine how a newbie corporate guy wouldve felt after this.
That's how it is.
^ permalink raw reply
* Re: [patch net-next 04/20] net: sched: use tcf_exts_has_actions in tcf_exts_exec
From: Jiri Pirko @ 2017-07-31 12:23 UTC (permalink / raw)
To: Jamal Hadi Salim; +Cc: netdev, davem, xiyou.wangcong, daniel, mlxsw
In-Reply-To: <01a0f827-1a9d-d8fa-f2b1-1c3ab65c4352@mojatatu.com>
Mon, Jul 31, 2017 at 02:09:22PM CEST, jhs@mojatatu.com wrote:
>On 17-07-31 02:36 AM, Jiri Pirko wrote:
>> Sun, Jul 30, 2017 at 09:48:24PM CEST, jhs@mojatatu.com wrote:
>> > I am probably missing something. All those changes to just
>> > replace "if (exts->nr_actions)" with "if (tcf_exts_has_actions(exts))" ?
>>
>> That is what the description says :)
>>
>
>I meant I wouldve expected few liners added/removed.
one actually. But the function tcf_exts_exec had to be moved since
tcf_exts_has_actions was defined after originaly
>
>cheers,
>jamal
^ permalink raw reply
* Re: [PATCH 0/3] net-next: stmmac: support future possible different internal phy mode
From: Corentin Labbe @ 2017-07-31 12:26 UTC (permalink / raw)
To: Chen-Yu Tsai
Cc: Florian Fainelli, Andrew Lunn, Rob Herring, Mark Rutland,
Maxime Ripard, Russell King, Giuseppe Cavallaro,
alexandre.torgue-qxv4g6HH51o, devicetree, netdev, linux-kernel,
linux-sunxi, linux-arm-kernel, Icenowy Zheng
In-Reply-To: <CAGb2v6626KDmww5u_-ogMJHgfdxTHQLCnUF4bmcUt35f2JJgLg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On Mon, Jul 31, 2017 at 08:19:40PM +0800, Chen-Yu Tsai wrote:
> On Sat, Jul 29, 2017 at 2:48 PM, Corentin Labbe
> <clabbe.montjoie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > On Fri, Jul 28, 2017 at 10:54:30AM -0700, Florian Fainelli wrote:
> >> On 07/28/2017 07:44 AM, Corentin Labbe wrote:
> >> > On Fri, Jul 28, 2017 at 04:36:00PM +0200, Andrew Lunn wrote:
> >> >>>> I've probably asked this before: Does the internal PHY use a different
> >> >>>> PHY ID in registers 2 and 3?
> >> >>>>
> >> >>>
> >> >>> yes
> >> >>>
> >> >>> reg2: 0x0044
> >> >>> reg3: 0X1500
> >> >
> >> > Copy/paste error, its 1400
> >> >
> >> >>
> >> >> So this is not about loading the correct PHY driver. You can already
> >> >> do this based on the PHY IDs...
> >> >>
> >> >> This is about selecting which PHY to use. Internal or External?
> >> >>
> >> >> Andrew
> >> >
> >> > It is too late when we know the PHY ID.
> >>
> >> > We need to set a syscon for choosing external/internal PHY.
> >> > So we can rely only on DT.
> >>
> >> Since the Device Tree needs to be correct to identify which PHY to use
> >> (internal or external), if you use the standard compatible string for
> >> the PHY that contains its OUI, e.g:
> >>
> >> compatible = "ethernet-phy-id0044.1400", "ethernet-phy-ieee802.3-c22"
> >>
> >> then you can have your Ethernet MAC identify whether this is an internal
> >> PHY by having a list of compatible strings to match against.
> >
> > So basicly, I replace sun8i-h3-ephy by ethernet-phy-id0044.1400 and it is good ?
>
> IIRC you mentioned some time ago the PHY in the AC200 also has this ID?
> Do you remember if this is true?
Yes it's certainly a AC200 PHY in the H3.
>
> If someone were crazy enough to hook that up to the H3, then we still
> wouldn't be able to tell if it's the internal or external one.
>
Why someone would put the same external PHY than the internal one ?
Yeah its totally crazy and I think we are safe by saying "it's not supported".
Regards
^ permalink raw reply
* Re: [PATCH net-next 0/2] Refactor lan9303_xxx_packet_processing
From: Andrew Lunn @ 2017-07-31 13:22 UTC (permalink / raw)
To: Egil Hjelmeland; +Cc: vivien.didelot, f.fainelli, netdev, linux-kernel, kernel
In-Reply-To: <20170731113355.4284-1-privat@egil-hjelmeland.no>
On Mon, Jul 31, 2017 at 01:33:53PM +0200, Egil Hjelmeland wrote:
> First patch:
> Change lan9303_enable_packet_processing,
> lan9303_disable_packet_processing():
> Pass port number (0,1,2) as parameter instead of port offset.
> Plus replaced a constant 0x400 with LAN9303_SWITCH_PORT_REG()
Hi Egil
The cover note and the commit message should concentrate on the Why,
not the What. I can see the What by reading the patch.
Why do you want to pass port numbers?
Note that for netdev, the cover note also ends up in git as part of
the history.
Andrew
^ permalink raw reply
* Re: Performance regression with virtio_net
From: Michael S. Tsirkin @ 2017-07-31 13:26 UTC (permalink / raw)
To: Euan Kemp; +Cc: seth.forshee, netdev
In-Reply-To: <20170730222552.4fxxnx3jxg4yv65g@multivac.euank.com>
On Sun, Jul 30, 2017 at 03:25:52PM -0700, Euan Kemp wrote:
> I've also observed this performance regression.
>
> The minimal fix for me is removing the two
> > if (unlikely(len > (unsigned long)ctx))
> checks added in 680557c.
>
> After digging a little more, the reason that check can fail appears to
> be that add_recvbuf_mergeable sometimes includes a hole at the end,
> which is included in len but not ctx.
>
> I'd send a patch removing those conditions, but I'm not certain
> whether "truesize" in receive_mergeable should also be changed back to
> be the max of len/ctx, or should remain as-is.
>
> - Euan
Thanks a lot for looking into it!
I kept this around unchanged from
ab7db91705e95ed1bba1304388936fccfa58c992. That commit had an internal
reason not to account for that space: not enough bits to do it. No
longer true so let's account for length exactly. I'll send a proper
patch after a bit of testing, would appreciate reports reports of
whether this helps very much.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index f41ab0e..782c33f 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -889,7 +889,6 @@ static int add_recvbuf_mergeable(struct virtnet_info *vi,
buf = (char *)page_address(alloc_frag->page) + alloc_frag->offset;
buf += headroom; /* advance address leaving hole at front of pkt */
- ctx = (void *)(unsigned long)len;
get_page(alloc_frag->page);
alloc_frag->offset += len + headroom;
hole = alloc_frag->size - alloc_frag->offset;
@@ -904,6 +903,7 @@ static int add_recvbuf_mergeable(struct virtnet_info *vi,
}
sg_init_one(rq->sg, buf, len);
+ ctx = (void *)(unsigned long)len;
err = virtqueue_add_inbuf_ctx(rq->vq, rq->sg, 1, buf, ctx, gfp);
if (err < 0)
put_page(virt_to_head_page(buf));
--
MST
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox