From d6759172415ebd5daddb8d11f2d536a1235da063 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 8 May 2019 11:22:09 +0100 Subject: net: dsa: lantiq: fix spelling mistake "brigde" -> "bridge" There are several spelling mistakes in dev_err messages. Fix these. Signed-off-by: Colin Ian King Signed-off-by: David S. Miller --- drivers/net/dsa/lantiq_gswip.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c index 553831df58fe..4e64835deac2 100644 --- a/drivers/net/dsa/lantiq_gswip.c +++ b/drivers/net/dsa/lantiq_gswip.c @@ -1235,7 +1235,7 @@ static void gswip_port_fast_age(struct dsa_switch *ds, int port) err = gswip_pce_table_entry_read(priv, &mac_bridge); if (err) { - dev_err(priv->dev, "failed to read mac brigde: %d\n", + dev_err(priv->dev, "failed to read mac bridge: %d\n", err); return; } @@ -1252,7 +1252,7 @@ static void gswip_port_fast_age(struct dsa_switch *ds, int port) mac_bridge.valid = false; err = gswip_pce_table_entry_write(priv, &mac_bridge); if (err) { - dev_err(priv->dev, "failed to write mac brigde: %d\n", + dev_err(priv->dev, "failed to write mac bridge: %d\n", err); return; } @@ -1328,7 +1328,7 @@ static int gswip_port_fdb(struct dsa_switch *ds, int port, err = gswip_pce_table_entry_write(priv, &mac_bridge); if (err) - dev_err(priv->dev, "failed to write mac brigde: %d\n", err); + dev_err(priv->dev, "failed to write mac bridge: %d\n", err); return err; } @@ -1360,7 +1360,7 @@ static int gswip_port_fdb_dump(struct dsa_switch *ds, int port, err = gswip_pce_table_entry_read(priv, &mac_bridge); if (err) { - dev_err(priv->dev, "failed to write mac brigde: %d\n", + dev_err(priv->dev, "failed to write mac bridge: %d\n", err); return err; } -- cgit v1.2.3-70-g09d2 From c264ed44d857c50f43be08572668afa374bf6a48 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 8 May 2019 11:51:35 +0100 Subject: net: hns3: remove redundant assignment of l2_hdr to itself The pointer l2_hdr is being assigned to itself, this is redundant and can be removed. Addresses-Coverity: ("Evaluation order violation") Signed-off-by: Colin Ian King Reviewed-by: Yunsheng Lin Signed-off-by: David S. Miller --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 18711e0f9bdf..196a3d780dcf 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -810,7 +810,7 @@ static int hns3_set_l2l3l4(struct sk_buff *skb, u8 ol4_proto, u8 il4_proto, u32 *type_cs_vlan_tso, u32 *ol_type_vlan_len_msec) { - unsigned char *l2_hdr = l2_hdr = skb->data; + unsigned char *l2_hdr = skb->data; u32 l4_proto = ol4_proto; union l4_hdr_info l4; union l3_hdr_info l3; -- cgit v1.2.3-70-g09d2 From 86dc59e39031fb0d366d5b1f92db015b24bef70b Mon Sep 17 00:00:00 2001 From: Wang Hai Date: Wed, 8 May 2019 21:43:26 +0800 Subject: net: dsa: sja1105: Make 'sja1105et_regs' and 'sja1105pqrs_regs' static drivers/net/dsa/sja1105/sja1105_spi.c:486:21: warning: symbol 'sja1105et_regs' was not declared. Should it be static? drivers/net/dsa/sja1105/sja1105_spi.c:511:21: warning: symbol 'sja1105pqrs_regs' was not declared. Should it be static? Fixes: 8aa9ebccae87 ("net: dsa: Introduce driver for NXP SJA1105 5-port L2 switch") Reported-by: Hulk Robot Signed-off-by: Wang Hai Signed-off-by: David S. Miller --- drivers/net/dsa/sja1105/sja1105_spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/net/dsa/sja1105/sja1105_spi.c b/drivers/net/dsa/sja1105/sja1105_spi.c index 244a94ccfc18..6848d82e423a 100644 --- a/drivers/net/dsa/sja1105/sja1105_spi.c +++ b/drivers/net/dsa/sja1105/sja1105_spi.c @@ -483,7 +483,7 @@ out: return rc; } -struct sja1105_regs sja1105et_regs = { +static struct sja1105_regs sja1105et_regs = { .device_id = 0x0, .prod_id = 0x100BC3, .status = 0x1, @@ -508,7 +508,7 @@ struct sja1105_regs sja1105et_regs = { .rmii_ext_tx_clk = {0x100018, 0x10001F, 0x100026, 0x10002D, 0x100034}, }; -struct sja1105_regs sja1105pqrs_regs = { +static struct sja1105_regs sja1105pqrs_regs = { .device_id = 0x0, .prod_id = 0x100BC3, .status = 0x1, -- cgit v1.2.3-70-g09d2 From 5425711b6dd0f7283202729863d9210e7a1c7cd2 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 8 May 2019 14:30:41 +0100 Subject: net: dsa: sja1105: fix check on while loop exit The while-loop exit condition check is not correct; the loop should continue if the returns from the function calls are negative or the CRC status returns are invalid. Currently it is ignoring the returns from the function calls. Fix this by removing the status return checks and only break from the loop at the very end when we know that all the success condtions have been met. Kudos to Dan Carpenter for describing the correct fix and Vladimir Oltean for noting the change to the check on the number of retries. Addresses-Coverity: ("Uninitialized scalar variable") Fixes: 8aa9ebccae87 ("net: dsa: Introduce driver for NXP SJA1105 5-port L2 switch") Signed-off-by: Colin Ian King Tested-by: Vladimir Oltean Signed-off-by: David S. Miller --- drivers/net/dsa/sja1105/sja1105_spi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/net/dsa/sja1105/sja1105_spi.c b/drivers/net/dsa/sja1105/sja1105_spi.c index 6848d82e423a..2eb70b8acfc3 100644 --- a/drivers/net/dsa/sja1105/sja1105_spi.c +++ b/drivers/net/dsa/sja1105/sja1105_spi.c @@ -466,14 +466,15 @@ int sja1105_static_config_upload(struct sja1105_private *priv) "invalid, retrying...\n"); continue; } - } while (--retries && (status.crcchkl == 1 || status.crcchkg == 1 || - status.configs == 0 || status.ids == 1)); + /* Success! */ + break; + } while (--retries); if (!retries) { rc = -EIO; dev_err(dev, "Failed to upload config to device, giving up\n"); goto out; - } else if (retries != RETRIES - 1) { + } else if (retries != RETRIES) { dev_info(dev, "Succeeded after %d tried\n", RETRIES - retries); } -- cgit v1.2.3-70-g09d2 From 3b2c4f4d63a554739a32dc709b617f2d2acc2ad0 Mon Sep 17 00:00:00 2001 From: Vladimir Oltean Date: Wed, 8 May 2019 23:32:25 +0300 Subject: net: dsa: sja1105: Don't return a negative in u8 sja1105_stp_state_get Dan Carpenter says: The patch 640f763f98c2: "net: dsa: sja1105: Add support for Spanning Tree Protocol" from May 5, 2019, leads to the following static checker warning: drivers/net/dsa/sja1105/sja1105_main.c:1073 sja1105_stp_state_get() warn: signedness bug returning '(-22)' The caller doesn't check for negative errors anyway. Fixes: 640f763f98c2: ("net: dsa: sja1105: Add support for Spanning Tree Protocol") Reported-by: Dan Carpenter Signed-off-by: Vladimir Oltean Signed-off-by: David S. Miller --- drivers/net/dsa/sja1105/sja1105_main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 50ff625c85d6..0663b78a2f6c 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1070,7 +1070,11 @@ static u8 sja1105_stp_state_get(struct sja1105_private *priv, int port) return BR_STATE_LEARNING; if (mac[port].ingress && mac[port].egress && mac[port].dyn_learn) return BR_STATE_FORWARDING; - return -EINVAL; + /* This is really an error condition if the MAC was in none of the STP + * states above. But treating the port as disabled does nothing, which + * is adequate, and it also resets the MAC to a known state later on. + */ + return BR_STATE_DISABLED; } /* For situations where we need to change a setting at runtime that is only -- cgit v1.2.3-70-g09d2 From f81dadbcf7fd067baf184b63c179fc392bdb226e Mon Sep 17 00:00:00 2001 From: Serge Semin Date: Thu, 9 May 2019 00:51:15 +0300 Subject: net: phy: realtek: Add rtl8211e rx/tx delays config There are two chip pins named TXDLY and RXDLY which actually adds the 2ns delays to TXC and RXC for TXD/RXD latching. Alas this is the only documented info regarding the RGMII timing control configurations the PHY provides. It turns out the same settings can be setup via MDIO registers hidden in the extension pages layout. Particularly the extension page 0xa4 provides a register 0x1c, which bits 1 and 2 control the described delays. They are used to implement the "rgmii-{id,rxid,txid}" phy-mode. The hidden RGMII configs register utilization was found in the rtl8211e U-boot driver: https://elixir.bootlin.com/u-boot/v2019.01/source/drivers/net/phy/realtek.c#L99 There is also a freebsd-folks discussion regarding this register: https://reviews.freebsd.org/D13591 It confirms that the register bits field must control the so called configuration pins described in the table 12-13 of the official PHY datasheet: 8:6 = PHY Address 5:4 = Auto-Negotiation 3 = Interface Mode Select 2 = RX Delay 1 = TX Delay 0 = SELRGV Reviewed-by: Andrew Lunn Signed-off-by: Serge Semin Signed-off-by: David S. Miller --- drivers/net/phy/realtek.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'drivers') diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index d6a10f323117..cfbc0ca61123 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -23,11 +23,15 @@ #define RTL821x_INSR 0x13 +#define RTL821x_EXT_PAGE_SELECT 0x1e #define RTL821x_PAGE_SELECT 0x1f #define RTL8211F_INSR 0x1d #define RTL8211F_TX_DELAY BIT(8) +#define RTL8211E_TX_DELAY BIT(1) +#define RTL8211E_RX_DELAY BIT(2) +#define RTL8211E_MODE_MII_GMII BIT(3) #define RTL8201F_ISR 0x1e #define RTL8201F_IER 0x13 @@ -167,6 +171,52 @@ static int rtl8211f_config_init(struct phy_device *phydev) return phy_modify_paged(phydev, 0xd08, 0x11, RTL8211F_TX_DELAY, val); } +static int rtl8211e_config_init(struct phy_device *phydev) +{ + int ret = 0, oldpage; + u16 val; + + /* enable TX/RX delay for rgmii-* modes, and disable them for rgmii. */ + switch (phydev->interface) { + case PHY_INTERFACE_MODE_RGMII: + val = 0; + break; + case PHY_INTERFACE_MODE_RGMII_ID: + val = RTL8211E_TX_DELAY | RTL8211E_RX_DELAY; + break; + case PHY_INTERFACE_MODE_RGMII_RXID: + val = RTL8211E_RX_DELAY; + break; + case PHY_INTERFACE_MODE_RGMII_TXID: + val = RTL8211E_TX_DELAY; + break; + default: /* the rest of the modes imply leaving delays as is. */ + return 0; + } + + /* According to a sample driver there is a 0x1c config register on the + * 0xa4 extension page (0x7) layout. It can be used to disable/enable + * the RX/TX delays otherwise controlled by RXDLY/TXDLY pins. It can + * also be used to customize the whole configuration register: + * 8:6 = PHY Address, 5:4 = Auto-Negotiation, 3 = Interface Mode Select, + * 2 = RX Delay, 1 = TX Delay, 0 = SELRGV (see original PHY datasheet + * for details). + */ + oldpage = phy_select_page(phydev, 0x7); + if (oldpage < 0) + goto err_restore_page; + + ret = phy_write(phydev, RTL821x_EXT_PAGE_SELECT, 0xa4); + if (ret) + goto err_restore_page; + + ret = phy_modify(phydev, 0x1c, RTL8211E_TX_DELAY | RTL8211E_RX_DELAY, + val); + +err_restore_page: + return phy_restore_page(phydev, oldpage, ret); +} + static int rtl8211b_suspend(struct phy_device *phydev) { phy_write(phydev, MII_MMD_DATA, BIT(9)); @@ -239,6 +289,7 @@ static struct phy_driver realtek_drvs[] = { }, { PHY_ID_MATCH_EXACT(0x001cc915), .name = "RTL8211E Gigabit Ethernet", + .config_init = &rtl8211e_config_init, .ack_interrupt = &rtl821x_ack_interrupt, .config_intr = &rtl8211e_config_intr, .suspend = genphy_suspend, -- cgit v1.2.3-70-g09d2 From 1da7756e6616c7795c8a104fde0a66f212ef659d Mon Sep 17 00:00:00 2001 From: Serge Semin Date: Thu, 9 May 2019 00:51:17 +0300 Subject: net: phy: realtek: Change TX-delay setting for RGMII modes only It's prone to problems if delay is cleared out for other than RGMII modes. So lets set/clear the TX-delay in the config register only if actually RGMII-like interface mode is requested. This only concerns rtl8211f chips. Signed-off-by: Serge Semin Signed-off-by: David S. Miller --- drivers/net/phy/realtek.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index cfbc0ca61123..761ce3b1e7bd 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -161,12 +161,23 @@ static int rtl8211c_config_init(struct phy_device *phydev) static int rtl8211f_config_init(struct phy_device *phydev) { - u16 val = 0; + u16 val; - /* enable TX-delay for rgmii-id and rgmii-txid, otherwise disable it */ - if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || - phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) + /* enable TX-delay for rgmii-{id,txid}, and disable it for rgmii and + * rgmii-rxid. The RX-delay can be enabled by the external RXDLY pin. + */ + switch (phydev->interface) { + case PHY_INTERFACE_MODE_RGMII: + case PHY_INTERFACE_MODE_RGMII_RXID: + val = 0; + break; + case PHY_INTERFACE_MODE_RGMII_ID: + case PHY_INTERFACE_MODE_RGMII_TXID: val = RTL8211F_TX_DELAY; + break; + default: /* the rest of the modes imply leaving delay as is. */ + return 0; + } return phy_modify_paged(phydev, 0xd08, 0x11, RTL8211F_TX_DELAY, val); } -- cgit v1.2.3-70-g09d2 From 1e966763e256393965c78aa09b89027fac6b8bf1 Mon Sep 17 00:00:00 2001 From: Pieter Jansen van Vuuren Date: Wed, 8 May 2019 15:52:56 -0700 Subject: nfp: reintroduce ndo_get_port_parent_id for representor ports NFP does not register devlink ports for representors (without the "devlink: expose PF and VF representors as ports" series there are no port flavours to expose them as). Commit c25f08ac65e4 ("nfp: remove ndo_get_port_parent_id implementation") went to far in removing ndo_get_port_parent_id for representors. This causes redirection offloads to fail, and switch_id attribute missing. Reintroduce the ndo_get_port_parent_id callback for representor ports. Fixes: c25f08ac65e4 ("nfp: remove ndo_get_port_parent_id implementation") Signed-off-by: Pieter Jansen van Vuuren Signed-off-by: Jakub Kicinski Signed-off-by: David S. Miller --- drivers/net/ethernet/netronome/nfp/nfp_net_repr.c | 1 + drivers/net/ethernet/netronome/nfp/nfp_port.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) (limited to 'drivers') diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c index 036edcc1fa18..1eef446036d6 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c @@ -273,6 +273,7 @@ const struct net_device_ops nfp_repr_netdev_ops = { .ndo_fix_features = nfp_repr_fix_features, .ndo_set_features = nfp_port_set_features, .ndo_set_mac_address = eth_mac_addr, + .ndo_get_port_parent_id = nfp_port_get_port_parent_id, .ndo_get_devlink_port = nfp_devlink_get_devlink_port, }; diff --git a/drivers/net/ethernet/netronome/nfp/nfp_port.c b/drivers/net/ethernet/netronome/nfp/nfp_port.c index fcd16877e6e0..93c5bfc0510b 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_port.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_port.c @@ -30,6 +30,22 @@ struct nfp_port *nfp_port_from_netdev(struct net_device *netdev) return NULL; } +int nfp_port_get_port_parent_id(struct net_device *netdev, + struct netdev_phys_item_id *ppid) +{ + struct nfp_port *port; + const u8 *serial; + + port = nfp_port_from_netdev(netdev); + if (!port) + return -EOPNOTSUPP; + + ppid->id_len = nfp_cpp_serial(port->app->cpp, &serial); + memcpy(&ppid->id, serial, ppid->id_len); + + return 0; +} + int nfp_port_setup_tc(struct net_device *netdev, enum tc_setup_type type, void *type_data) { -- cgit v1.2.3-70-g09d2 From 7f4399ba405b6201fb318b43091703a34b1489ab Mon Sep 17 00:00:00 2001 From: Claudiu Manoil Date: Thu, 9 May 2019 03:07:12 +0000 Subject: ptp_qoriq: fix NULL access if ptp dt node missing Make sure ptp dt node exists before accessing it in case of NULL pointer call trace. Signed-off-by: Claudiu Manoil Signed-off-by: Yangbo Lu Acked-by: Richard Cochran Signed-off-by: David S. Miller --- drivers/ptp/ptp_qoriq.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers') diff --git a/drivers/ptp/ptp_qoriq.c b/drivers/ptp/ptp_qoriq.c index 53775362aac6..e10642403b25 100644 --- a/drivers/ptp/ptp_qoriq.c +++ b/drivers/ptp/ptp_qoriq.c @@ -467,6 +467,9 @@ int ptp_qoriq_init(struct ptp_qoriq *ptp_qoriq, void __iomem *base, unsigned long flags; u32 tmr_ctrl; + if (!node) + return -ENODEV; + ptp_qoriq->base = base; ptp_qoriq->caps = *caps; -- cgit v1.2.3-70-g09d2 From 68a5cde9f02e690206e41c2d5aba88461a8829f1 Mon Sep 17 00:00:00 2001 From: Cheng Han Date: Thu, 9 May 2019 11:13:41 +0800 Subject: dwmac4_prog_mtl_tx_algorithms() missing write operation net: ethernet: stmmac: dwmac4_prog_mtl_tx_algorithms() missing write operation The value of MTL_OPERATION_MODE is not written back Signed-off-by: Cheng Han Signed-off-by: David S. Miller --- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index 7e5d5db0d516..b4bb5629de38 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -192,6 +192,8 @@ static void dwmac4_prog_mtl_tx_algorithms(struct mac_device_info *hw, default: break; } + + writel(value, ioaddr + MTL_OPERATION_MODE); } static void dwmac4_set_mtl_tx_queue_weight(struct mac_device_info *hw, -- cgit v1.2.3-70-g09d2 From a35d310f03a692bf4798eb309a1950a06a150620 Mon Sep 17 00:00:00 2001 From: Jason Wang Date: Wed, 8 May 2019 23:20:17 -0400 Subject: tuntap: fix dividing by zero in ebpf queue selection We need check if tun->numqueues is zero (e.g for the persist device) before trying to use it for modular arithmetic. Reported-by: Eric Dumazet Fixes: 96f84061620c6("tun: add eBPF based queue selection method") Signed-off-by: Jason Wang Reviewed-by: Eric Dumazet Signed-off-by: David S. Miller --- drivers/net/tun.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 9d72f8c76c15..a52bd47e7aa2 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -596,13 +596,18 @@ static u16 tun_automq_select_queue(struct tun_struct *tun, struct sk_buff *skb) static u16 tun_ebpf_select_queue(struct tun_struct *tun, struct sk_buff *skb) { struct tun_prog *prog; + u32 numqueues; u16 ret = 0; + numqueues = READ_ONCE(tun->numqueues); + if (!numqueues) + return 0; + prog = rcu_dereference(tun->steering_prog); if (prog) ret = bpf_prog_run_clear_cb(prog->prog, skb); - return ret % tun->numqueues; + return ret % numqueues; } static u16 tun_select_queue(struct net_device *dev, struct sk_buff *skb, -- cgit v1.2.3-70-g09d2 From 9871a9e47a2646fe30ae7fd2e67668a8d30912f6 Mon Sep 17 00:00:00 2001 From: Jason Wang Date: Wed, 8 May 2019 23:20:18 -0400 Subject: tuntap: synchronize through tfiles array instead of tun->numqueues When a queue(tfile) is detached through __tun_detach(), we move the last enabled tfile to the position where detached one sit but don't NULL out last position. We expect to synchronize the datapath through tun->numqueues. Unfortunately, this won't work since we're lacking sufficient mechanism to order or synchronize the access to tun->numqueues. To fix this, NULL out the last position during detaching and check RCU protected tfile against NULL instead of checking tun->numqueues in datapath. Cc: YueHaibing Cc: Cong Wang Cc: weiyongjun (A) Cc: Eric Dumazet Fixes: c8d68e6be1c3b ("tuntap: multiqueue support") Signed-off-by: Jason Wang Reviewed-by: Wei Yongjun Signed-off-by: David S. Miller --- drivers/net/tun.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/tun.c b/drivers/net/tun.c index a52bd47e7aa2..abae165dcca5 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -704,6 +704,8 @@ static void __tun_detach(struct tun_file *tfile, bool clean) tun->tfiles[tun->numqueues - 1]); ntfile = rtnl_dereference(tun->tfiles[index]); ntfile->queue_index = index; + rcu_assign_pointer(tun->tfiles[tun->numqueues - 1], + NULL); --tun->numqueues; if (clean) { @@ -1086,7 +1088,7 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev) tfile = rcu_dereference(tun->tfiles[txq]); /* Drop packet if interface is not attached */ - if (txq >= tun->numqueues) + if (!tfile) goto drop; if (!rcu_dereference(tun->steering_prog)) @@ -1309,6 +1311,7 @@ static int tun_xdp_xmit(struct net_device *dev, int n, rcu_read_lock(); +resample: numqueues = READ_ONCE(tun->numqueues); if (!numqueues) { rcu_read_unlock(); @@ -1317,6 +1320,8 @@ static int tun_xdp_xmit(struct net_device *dev, int n, tfile = rcu_dereference(tun->tfiles[smp_processor_id() % numqueues]); + if (unlikely(!tfile)) + goto resample; spin_lock(&tfile->tx_ring.producer_lock); for (i = 0; i < n; i++) { -- cgit v1.2.3-70-g09d2 From 6c2ea9ebafa79eea9098a134a422391638879f45 Mon Sep 17 00:00:00 2001 From: Hangbin Liu Date: Thu, 9 May 2019 14:54:08 +0800 Subject: macvlan: disable SIOCSHWTSTAMP in container Miroslav pointed that with NET_ADMIN enabled in container, a normal user could be mapped to root and is able to change the real device's rx filter via ioctl on macvlan, which would affect the other ptp process on host. Fix it by disabling SIOCSHWTSTAMP in container. Fixes: 254c0a2bfedb ("macvlan: pass get_ts_info and SIOC[SG]HWTSTAMP ioctl to real device") Signed-off-by: Hangbin Liu Acked-by: Richard Cochran Signed-off-by: David S. Miller --- drivers/net/macvlan.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index b395423b19bc..92efa93649f0 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -836,6 +836,8 @@ static int macvlan_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) switch (cmd) { case SIOCSHWTSTAMP: + if (!net_eq(dev_net(dev), &init_net)) + break; case SIOCGHWTSTAMP: if (netif_device_present(real_dev) && ops->ndo_do_ioctl) err = ops->ndo_do_ioctl(real_dev, &ifrr, cmd); -- cgit v1.2.3-70-g09d2 From b8b277525e9df2fd2dc3d1f4fe01c6796bb107fc Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Thu, 9 May 2019 11:08:16 +0200 Subject: aqc111: fix endianness issue in aqc111_change_mtu If the MTU is large enough, the first write to the device is just repeated. On BE architectures, however, the first word of the command will be swapped a second time and garbage will be written. Avoid that. Signed-off-by: Oliver Neukum Signed-off-by: David S. Miller --- drivers/net/usb/aqc111.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index aff995be2a31..408df2d335e3 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -453,6 +453,8 @@ static int aqc111_change_mtu(struct net_device *net, int new_mtu) reg16 = 0x1420; else if (dev->net->mtu <= 16334) reg16 = 0x1A20; + else + return 0; aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_PAUSE_WATERLVL_LOW, 2, ®16); -- cgit v1.2.3-70-g09d2 From 369b46e9fbcfa5136f2cb5f486c90e5f7fa92630 Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Thu, 9 May 2019 11:08:17 +0200 Subject: aqc111: fix writing to the phy on BE When writing to the phy on BE architectures an internal data structure was directly given, leading to it being byte swapped in the wrong way for the CPU in 50% of all cases. A temporary buffer must be used. Signed-off-by: Oliver Neukum Signed-off-by: David S. Miller --- drivers/net/usb/aqc111.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index 408df2d335e3..599d560a8450 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -320,6 +320,7 @@ static int aqc111_get_link_ksettings(struct net_device *net, static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed) { struct aqc111_data *aqc111_data = dev->driver_priv; + u32 phy_on_the_wire; aqc111_data->phy_cfg &= ~AQ_ADV_MASK; aqc111_data->phy_cfg |= AQ_PAUSE; @@ -361,7 +362,8 @@ static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed) } } - aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, &aqc111_data->phy_cfg); + phy_on_the_wire = aqc111_data->phy_cfg; + aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, &phy_on_the_wire); } static int aqc111_set_link_ksettings(struct net_device *net, @@ -755,6 +757,7 @@ static void aqc111_unbind(struct usbnet *dev, struct usb_interface *intf) { struct aqc111_data *aqc111_data = dev->driver_priv; u16 reg16; + u32 phy_on_the_wire; /* Force bz */ reg16 = SFR_PHYPWR_RSTCTL_BZ; @@ -768,8 +771,9 @@ static void aqc111_unbind(struct usbnet *dev, struct usb_interface *intf) aqc111_data->phy_cfg &= ~AQ_ADV_MASK; aqc111_data->phy_cfg |= AQ_LOW_POWER; aqc111_data->phy_cfg &= ~AQ_PHY_POWER_EN; + phy_on_the_wire = aqc111_data->phy_cfg; aqc111_write32_cmd_nopm(dev, AQ_PHY_OPS, 0, 0, - &aqc111_data->phy_cfg); + &phy_on_the_wire); kfree(aqc111_data); } @@ -992,6 +996,7 @@ static int aqc111_reset(struct usbnet *dev) { struct aqc111_data *aqc111_data = dev->driver_priv; u8 reg8 = 0; + u32 phy_on_the_wire; dev->rx_urb_size = URB_SIZE; @@ -1004,8 +1009,9 @@ static int aqc111_reset(struct usbnet *dev) /* Power up ethernet PHY */ aqc111_data->phy_cfg = AQ_PHY_POWER_EN; + phy_on_the_wire = aqc111_data->phy_cfg; aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, - &aqc111_data->phy_cfg); + &phy_on_the_wire); /* Set the MAC address */ aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_NODE_ID, ETH_ALEN, @@ -1036,6 +1042,7 @@ static int aqc111_stop(struct usbnet *dev) { struct aqc111_data *aqc111_data = dev->driver_priv; u16 reg16 = 0; + u32 phy_on_the_wire; aqc111_read16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, 2, ®16); @@ -1047,8 +1054,9 @@ static int aqc111_stop(struct usbnet *dev) /* Put PHY to low power*/ aqc111_data->phy_cfg |= AQ_LOW_POWER; + phy_on_the_wire = aqc111_data->phy_cfg; aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, - &aqc111_data->phy_cfg); + &phy_on_the_wire); netif_carrier_off(dev->net); @@ -1324,6 +1332,7 @@ static int aqc111_suspend(struct usb_interface *intf, pm_message_t message) u16 temp_rx_ctrl = 0x00; u16 reg16; u8 reg8; + u32 phy_on_the_wire; usbnet_suspend(intf, message); @@ -1395,12 +1404,14 @@ static int aqc111_suspend(struct usb_interface *intf, pm_message_t message) aqc111_write_cmd(dev, AQ_WOL_CFG, 0, 0, WOL_CFG_SIZE, &wol_cfg); + phy_on_the_wire = aqc111_data->phy_cfg; aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, - &aqc111_data->phy_cfg); + &phy_on_the_wire); } else { aqc111_data->phy_cfg |= AQ_LOW_POWER; + phy_on_the_wire = aqc111_data->phy_cfg; aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, - &aqc111_data->phy_cfg); + &phy_on_the_wire); /* Disable RX path */ aqc111_read16_cmd_nopm(dev, AQ_ACCESS_MAC, -- cgit v1.2.3-70-g09d2 From 2cf672709beb005f6e90cb4edbed6f2218ba953e Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Thu, 9 May 2019 11:08:18 +0200 Subject: aqc111: fix double endianness swap on BE If you are using a function that does a swap in place, you cannot just reuse the buffer on the assumption that it has not been changed. Signed-off-by: Oliver Neukum Signed-off-by: David S. Miller --- drivers/net/usb/aqc111.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index 599d560a8450..b86c5ce9a92a 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -1428,7 +1428,7 @@ static int aqc111_resume(struct usb_interface *intf) { struct usbnet *dev = usb_get_intfdata(intf); struct aqc111_data *aqc111_data = dev->driver_priv; - u16 reg16; + u16 reg16, oldreg16; u8 reg8; netif_carrier_off(dev->net); @@ -1444,9 +1444,11 @@ static int aqc111_resume(struct usb_interface *intf) /* Configure RX control register => start operation */ reg16 = aqc111_data->rxctl; reg16 &= ~SFR_RX_CTL_START; + /* needs to be saved in case endianness is swapped */ + oldreg16 = reg16; aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, ®16); - reg16 |= SFR_RX_CTL_START; + reg16 = oldreg16 | SFR_RX_CTL_START; aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, ®16); aqc111_set_phy_speed(dev, aqc111_data->autoneg, -- cgit v1.2.3-70-g09d2 From 70610c922bae2f3f974eef955ef254defb7755ce Mon Sep 17 00:00:00 2001 From: Kefeng Wang Date: Thu, 9 May 2019 23:32:35 +0800 Subject: net: aquantia: fix undefined devm_hwmon_device_register_with_info reference drivers/net/ethernet/aquantia/atlantic/aq_drvinfo.o: In function `aq_drvinfo_init': aq_drvinfo.c:(.text+0xe8): undefined reference to `devm_hwmon_device_register_with_info' Fix it by using #if IS_REACHABLE(CONFIG_HWMON). Reported-by: Hulk Robot Signed-off-by: Kefeng Wang Signed-off-by: David S. Miller --- drivers/net/ethernet/aquantia/atlantic/aq_drvinfo.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers') diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_drvinfo.c b/drivers/net/ethernet/aquantia/atlantic/aq_drvinfo.c index f5a92b2a5cd6..adad6a7acabe 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_drvinfo.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_drvinfo.c @@ -13,6 +13,7 @@ #include "aq_drvinfo.h" +#if IS_REACHABLE(CONFIG_HWMON) static int aq_hwmon_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, long *value) { @@ -123,3 +124,7 @@ int aq_drvinfo_init(struct net_device *ndev) return err; } + +#else +int aq_drvinfo_init(struct net_device *ndev) { return 0; } +#endif -- cgit v1.2.3-70-g09d2 From 69e168ebdcfcb87ce7252d4857d570f99996fa27 Mon Sep 17 00:00:00 2001 From: Jiong Wang Date: Tue, 7 May 2019 17:41:30 +0100 Subject: nfp: bpf: fix static check error through tightening shift amount adjustment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NFP shift instruction has something special. If shift direction is left then shift amount of 1 to 31 is specified as 32 minus the amount to shift. But no need to do this for indirect shift which has shift amount be 0. Even after we do this subtraction, shift amount 0 will be turned into 32 which will eventually be encoded the same as 0 because only low 5 bits are encoded, but shift amount be 32 will fail the FIELD_PREP check done later on shift mask (0x1f), due to 32 is out of mask range. Such error has been observed when compiling nfp/bpf/jit.c using gcc 8.3 + O3. This issue has started when indirect shift support added after which the incoming shift amount to __emit_shf could be 0, therefore it is at that time shift amount adjustment inside __emit_shf should have been tightened. Fixes: 991f5b3651f6 ("nfp: bpf: support logic indirect shifts (BPF_[L|R]SH | BPF_X)") Reported-by: Oleksandr Natalenko Reported-by: Pablo Cascón Reviewed-by: Jakub Kicinski Signed-off-by: Jiong Wang Signed-off-by: Alexei Starovoitov --- drivers/net/ethernet/netronome/nfp/bpf/jit.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/ethernet/netronome/nfp/bpf/jit.c b/drivers/net/ethernet/netronome/nfp/bpf/jit.c index f272247d1708..d4bf0e694541 100644 --- a/drivers/net/ethernet/netronome/nfp/bpf/jit.c +++ b/drivers/net/ethernet/netronome/nfp/bpf/jit.c @@ -328,7 +328,18 @@ __emit_shf(struct nfp_prog *nfp_prog, u16 dst, enum alu_dst_ab dst_ab, return; } - if (sc == SHF_SC_L_SHF) + /* NFP shift instruction has something special. If shift direction is + * left then shift amount of 1 to 31 is specified as 32 minus the amount + * to shift. + * + * But no need to do this for indirect shift which has shift amount be + * 0. Even after we do this subtraction, shift amount 0 will be turned + * into 32 which will eventually be encoded the same as 0 because only + * low 5 bits are encoded, but shift amount be 32 will fail the + * FIELD_PREP check done later on shift mask (0x1f), due to 32 is out of + * mask range. + */ + if (sc == SHF_SC_L_SHF && shift) shift = 32 - shift; insn = OP_SHF_BASE | -- cgit v1.2.3-70-g09d2 From 6c9f05441477e29783e8391d06c067e4a3b23d47 Mon Sep 17 00:00:00 2001 From: Jakub Kicinski Date: Thu, 9 May 2019 16:19:34 -0700 Subject: nfp: add missing kdoc Add missing kdoc for app member. Signed-off-by: Jakub Kicinski Reviewed-by: Dirk van der Merwe Signed-off-by: David S. Miller --- drivers/net/ethernet/netronome/nfp/ccm.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/net/ethernet/netronome/nfp/ccm.h b/drivers/net/ethernet/netronome/nfp/ccm.h index e2fe4b867958..ac963b128203 100644 --- a/drivers/net/ethernet/netronome/nfp/ccm.h +++ b/drivers/net/ethernet/netronome/nfp/ccm.h @@ -54,6 +54,8 @@ static inline unsigned int nfp_ccm_get_tag(struct sk_buff *skb) /** * struct nfp_ccm - common control message handling + * @app: APP handle + * * @tag_allocator: bitmap of control message tags in use * @tag_alloc_next: next tag bit to allocate * @tag_alloc_last: next tag bit to be freed -- cgit v1.2.3-70-g09d2