Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net

Pull networking fixes from David Miller:

1) sunhme driver lacks DMA mapping error checks, based upon a report by
Meelis Roos.

2) Fix memory leak in mvpp2 driver, from Sudip Mukherjee.

3) DMA memory allocation sizes are wrong in systemport ethernet driver,
fix from Florian Fainelli.

4) Fix use after free in mac80211 defragmentation code, from Johannes
Berg.

5) Some networking uapi headers missing from Kbuild file, from Stephen
Hemminger.

6) TUN driver gets csum_start offset wrong when VLAN accel is enabled,
and macvtap has a similar bug, from Herbert Xu.

7) Adjust several tunneling drivers to set dev->iflink after registry,
because registry sets that to -1 overwriting whatever we did. From
Steffen Klassert.

8) Geneve forgets to set inner tunneling type, causing GSO segmentation
to fail on some NICs. From Jesse Gross.

9) Fix several locking bugs in stmmac driver, from Fabrice Gasnier and
Giuseppe CAVALLARO.

10) Fix spurious timeouts with NewReno on low traffic connections, from
Marcelo Leitner.

11) Fix descriptor updates in enic driver, from Govindarajulu
Varadarajan.

12) PPP calls bpf_prog_create() with locks held, which isn't kosher.
Fix from Takashi Iwai.

13) Fix NULL deref in SCTP with malformed INIT packets, from Daniel
Borkmann.

14) psock_fanout selftest accesses past the end of the mmap ring, fix
from Shuah Khan.

15) Fix PTP timestamping for VLAN packets, from Richard Cochran.

16) netlink_unbind() calls in netlink pass wrong initial argument, from
Hiroaki SHIMODA.

17) vxlan socket reuse accidently reuses a socket when the address
family is different, so we have to explicitly check this, from
Marcelo Lietner.

18) Fix missing include in nft_reject_bridge.c breaking the build on ppc
and other architectures, from Guenter Roeck.

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (75 commits)
vxlan: Do not reuse sockets for a different address family
smsc911x: power-up phydev before doing a software reset.
lib: rhashtable - Remove weird non-ASCII characters from comments
net/smsc911x: Fix delays in the PHY enable/disable routines
net/smsc911x: Fix rare soft reset timeout issue due to PHY power-down mode
netlink: Properly unbind in error conditions.
net: ptp: fix time stamp matching logic for VLAN packets.
cxgb4 : dcb open-lldp interop fixes
selftests/net: psock_fanout seg faults in sock_fanout_read_ring()
net: bcmgenet: apply MII configuration in bcmgenet_open()
net: bcmgenet: connect and disconnect from the PHY state machine
net: qualcomm: Fix dependency
ixgbe: phy: fix uninitialized status in ixgbe_setup_phy_link_tnx
net: phy: Correctly handle MII ioctl which changes autonegotiation.
ipv6: fix IPV6_PKTINFO with v4 mapped
net: sctp: fix memory leak in auth key management
net: sctp: fix NULL pointer dereference in af->from_addr_param on malformed packet
net: ppp: Don't call bpf_prog_create() in ppp_lock
net/mlx4_en: Advertize encapsulation offloads features only when VXLAN tunnel is set
cxgb4 : Fix bug in DCB app deletion
...

+784 -376
+14
Documentation/networking/ip-sysctl.txt
··· 56 56 0 - disabled 57 57 1 - enabled 58 58 59 + fwmark_reflect - BOOLEAN 60 + Controls the fwmark of kernel-generated IPv4 reply packets that are not 61 + associated with a socket for example, TCP RSTs or ICMP echo replies). 62 + If unset, these packets have a fwmark of zero. If set, they have the 63 + fwmark of the packet they are replying to. 64 + Default: 0 65 + 59 66 route/max_size - INTEGER 60 67 Maximum number of routes allowed in the kernel. Increase 61 68 this when using large numbers of interfaces and/or routes. ··· 1207 1200 1208 1201 proxy_ndp - BOOLEAN 1209 1202 Do proxy ndp. 1203 + 1204 + fwmark_reflect - BOOLEAN 1205 + Controls the fwmark of kernel-generated IPv6 reply packets that are not 1206 + associated with a socket for example, TCP RSTs or ICMPv6 echo replies). 1207 + If unset, these packets have a fwmark of zero. If set, they have the 1208 + fwmark of the packet they are replying to. 1209 + Default: 0 1210 1210 1211 1211 conf/interface/*: 1212 1212 Change special settings per interface.
+5 -5
arch/arm64/boot/dts/apm-storm.dtsi
··· 599 599 compatible = "apm,xgene-enet"; 600 600 status = "disabled"; 601 601 reg = <0x0 0x17020000 0x0 0xd100>, 602 - <0x0 0X17030000 0x0 0X400>, 602 + <0x0 0X17030000 0x0 0Xc300>, 603 603 <0x0 0X10000000 0x0 0X200>; 604 604 reg-names = "enet_csr", "ring_csr", "ring_cmd"; 605 605 interrupts = <0x0 0x3c 0x4>; ··· 624 624 sgenet0: ethernet@1f210000 { 625 625 compatible = "apm,xgene-enet"; 626 626 status = "disabled"; 627 - reg = <0x0 0x1f210000 0x0 0x10000>, 628 - <0x0 0x1f200000 0x0 0X10000>, 629 - <0x0 0x1B000000 0x0 0X20000>; 627 + reg = <0x0 0x1f210000 0x0 0xd100>, 628 + <0x0 0x1f200000 0x0 0Xc300>, 629 + <0x0 0x1B000000 0x0 0X200>; 630 630 reg-names = "enet_csr", "ring_csr", "ring_cmd"; 631 631 interrupts = <0x0 0xA0 0x4>; 632 632 dma-coherent; ··· 639 639 compatible = "apm,xgene-enet"; 640 640 status = "disabled"; 641 641 reg = <0x0 0x1f610000 0x0 0xd100>, 642 - <0x0 0x1f600000 0x0 0X400>, 642 + <0x0 0x1f600000 0x0 0Xc300>, 643 643 <0x0 0x18000000 0x0 0X200>; 644 644 reg-names = "enet_csr", "ring_csr", "ring_cmd"; 645 645 interrupts = <0x0 0x60 0x4>;
+17 -1
drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
··· 575 575 xgene_enet_wr_mcx_mac(pdata, MAC_CONFIG_1_ADDR, data & ~TX_EN); 576 576 } 577 577 578 - static void xgene_enet_reset(struct xgene_enet_pdata *pdata) 578 + bool xgene_ring_mgr_init(struct xgene_enet_pdata *p) 579 + { 580 + if (!ioread32(p->ring_csr_addr + CLKEN_ADDR)) 581 + return false; 582 + 583 + if (ioread32(p->ring_csr_addr + SRST_ADDR)) 584 + return false; 585 + 586 + return true; 587 + } 588 + 589 + static int xgene_enet_reset(struct xgene_enet_pdata *pdata) 579 590 { 580 591 u32 val; 592 + 593 + if (!xgene_ring_mgr_init(pdata)) 594 + return -ENODEV; 581 595 582 596 clk_prepare_enable(pdata->clk); 583 597 clk_disable_unprepare(pdata->clk); ··· 604 590 val |= SCAN_AUTO_INCR; 605 591 MGMT_CLOCK_SEL_SET(&val, 1); 606 592 xgene_enet_wr_mcx_mac(pdata, MII_MGMT_CONFIG_ADDR, val); 593 + 594 + return 0; 607 595 } 608 596 609 597 static void xgene_gport_shutdown(struct xgene_enet_pdata *pdata)
+4
drivers/net/ethernet/apm/xgene/xgene_enet_hw.h
··· 104 104 #define BLOCK_ETH_MAC_OFFSET 0x0000 105 105 #define BLOCK_ETH_MAC_CSR_OFFSET 0x2800 106 106 107 + #define CLKEN_ADDR 0xc208 108 + #define SRST_ADDR 0xc200 109 + 107 110 #define MAC_ADDR_REG_OFFSET 0x00 108 111 #define MAC_COMMAND_REG_OFFSET 0x04 109 112 #define MAC_WRITE_REG_OFFSET 0x08 ··· 321 318 322 319 int xgene_enet_mdio_config(struct xgene_enet_pdata *pdata); 323 320 void xgene_enet_mdio_remove(struct xgene_enet_pdata *pdata); 321 + bool xgene_ring_mgr_init(struct xgene_enet_pdata *p); 324 322 325 323 extern struct xgene_mac_ops xgene_gmac_ops; 326 324 extern struct xgene_port_ops xgene_gport_ops;
+7 -4
drivers/net/ethernet/apm/xgene/xgene_enet_main.c
··· 639 639 struct device *dev = ndev_to_dev(ndev); 640 640 struct xgene_enet_desc_ring *rx_ring, *tx_ring, *cp_ring; 641 641 struct xgene_enet_desc_ring *buf_pool = NULL; 642 - u8 cpu_bufnum = 0, eth_bufnum = 0; 643 - u8 bp_bufnum = 0x20; 644 - u16 ring_id, ring_num = 0; 642 + u8 cpu_bufnum = 0, eth_bufnum = START_ETH_BUFNUM; 643 + u8 bp_bufnum = START_BP_BUFNUM; 644 + u16 ring_id, ring_num = START_RING_NUM; 645 645 int ret; 646 646 647 647 /* allocate rx descriptor ring */ ··· 852 852 u16 dst_ring_num; 853 853 int ret; 854 854 855 - pdata->port_ops->reset(pdata); 855 + ret = pdata->port_ops->reset(pdata); 856 + if (ret) 857 + return ret; 856 858 857 859 ret = xgene_enet_create_desc_rings(ndev); 858 860 if (ret) { ··· 956 954 957 955 return ret; 958 956 err: 957 + unregister_netdev(ndev); 959 958 free_netdev(ndev); 960 959 return ret; 961 960 }
+4 -1
drivers/net/ethernet/apm/xgene/xgene_enet_main.h
··· 38 38 #define SKB_BUFFER_SIZE (XGENE_ENET_MAX_MTU - NET_IP_ALIGN) 39 39 #define NUM_PKT_BUF 64 40 40 #define NUM_BUFPOOL 32 41 + #define START_ETH_BUFNUM 2 42 + #define START_BP_BUFNUM 0x22 43 + #define START_RING_NUM 8 41 44 42 45 #define PHY_POLL_LINK_ON (10 * HZ) 43 46 #define PHY_POLL_LINK_OFF (PHY_POLL_LINK_ON / 5) ··· 86 83 }; 87 84 88 85 struct xgene_port_ops { 89 - void (*reset)(struct xgene_enet_pdata *pdata); 86 + int (*reset)(struct xgene_enet_pdata *pdata); 90 87 void (*cle_bypass)(struct xgene_enet_pdata *pdata, 91 88 u32 dst_ring_num, u16 bufpool_id); 92 89 void (*shutdown)(struct xgene_enet_pdata *pdata);
+6 -1
drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
··· 311 311 xgene_sgmac_rxtx(p, TX_EN, false); 312 312 } 313 313 314 - static void xgene_enet_reset(struct xgene_enet_pdata *p) 314 + static int xgene_enet_reset(struct xgene_enet_pdata *p) 315 315 { 316 + if (!xgene_ring_mgr_init(p)) 317 + return -ENODEV; 318 + 316 319 clk_prepare_enable(p->clk); 317 320 clk_disable_unprepare(p->clk); 318 321 clk_prepare_enable(p->clk); 319 322 320 323 xgene_enet_ecc_init(p); 321 324 xgene_enet_config_ring_if_assoc(p); 325 + 326 + return 0; 322 327 } 323 328 324 329 static void xgene_enet_cle_bypass(struct xgene_enet_pdata *p,
+6 -1
drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c
··· 252 252 xgene_enet_wr_mac(pdata, AXGMAC_CONFIG_1, data & ~HSTTFEN); 253 253 } 254 254 255 - static void xgene_enet_reset(struct xgene_enet_pdata *pdata) 255 + static int xgene_enet_reset(struct xgene_enet_pdata *pdata) 256 256 { 257 + if (!xgene_ring_mgr_init(pdata)) 258 + return -ENODEV; 259 + 257 260 clk_prepare_enable(pdata->clk); 258 261 clk_disable_unprepare(pdata->clk); 259 262 clk_prepare_enable(pdata->clk); 260 263 261 264 xgene_enet_ecc_init(pdata); 262 265 xgene_enet_config_ring_if_assoc(pdata); 266 + 267 + return 0; 263 268 } 264 269 265 270 static void xgene_enet_xgcle_bypass(struct xgene_enet_pdata *pdata,
+11 -2
drivers/net/ethernet/broadcom/bcmsysport.c
··· 1110 1110 /* We just need one DMA descriptor which is DMA-able, since writing to 1111 1111 * the port will allocate a new descriptor in its internal linked-list 1112 1112 */ 1113 - p = dma_zalloc_coherent(kdev, 1, &ring->desc_dma, GFP_KERNEL); 1113 + p = dma_zalloc_coherent(kdev, sizeof(struct dma_desc), &ring->desc_dma, 1114 + GFP_KERNEL); 1114 1115 if (!p) { 1115 1116 netif_err(priv, hw, priv->netdev, "DMA alloc failed\n"); 1116 1117 return -ENOMEM; ··· 1175 1174 if (!(reg & TDMA_DISABLED)) 1176 1175 netdev_warn(priv->netdev, "TDMA not stopped!\n"); 1177 1176 1177 + /* ring->cbs is the last part in bcm_sysport_init_tx_ring which could 1178 + * fail, so by checking this pointer we know whether the TX ring was 1179 + * fully initialized or not. 1180 + */ 1181 + if (!ring->cbs) 1182 + return; 1183 + 1178 1184 napi_disable(&ring->napi); 1179 1185 netif_napi_del(&ring->napi); 1180 1186 ··· 1191 1183 ring->cbs = NULL; 1192 1184 1193 1185 if (ring->desc_dma) { 1194 - dma_free_coherent(kdev, 1, ring->desc_cpu, ring->desc_dma); 1186 + dma_free_coherent(kdev, sizeof(struct dma_desc), 1187 + ring->desc_cpu, ring->desc_dma); 1195 1188 ring->desc_dma = 0; 1196 1189 } 1197 1190 ring->size = 0;
+10 -1
drivers/net/ethernet/broadcom/genet/bcmgenet.c
··· 2140 2140 goto err_irq0; 2141 2141 } 2142 2142 2143 + /* Re-configure the port multiplexer towards the PHY device */ 2144 + bcmgenet_mii_config(priv->dev, false); 2145 + 2146 + phy_connect_direct(dev, priv->phydev, bcmgenet_mii_setup, 2147 + priv->phy_interface); 2148 + 2143 2149 bcmgenet_netif_start(dev); 2144 2150 2145 2151 return 0; ··· 2189 2183 netif_dbg(priv, ifdown, dev, "bcmgenet_close\n"); 2190 2184 2191 2185 bcmgenet_netif_stop(dev); 2186 + 2187 + /* Really kill the PHY state machine and disconnect from it */ 2188 + phy_disconnect(priv->phydev); 2192 2189 2193 2190 /* Disable MAC receive */ 2194 2191 umac_enable_set(priv, CMD_RX_EN, false); ··· 2694 2685 2695 2686 phy_init_hw(priv->phydev); 2696 2687 /* Speed settings must be restored */ 2697 - bcmgenet_mii_config(priv->dev); 2688 + bcmgenet_mii_config(priv->dev, false); 2698 2689 2699 2690 /* disable ethernet MAC while updating its registers */ 2700 2691 umac_enable_set(priv, CMD_TX_EN | CMD_RX_EN, false);
+2 -1
drivers/net/ethernet/broadcom/genet/bcmgenet.h
··· 617 617 618 618 /* MDIO routines */ 619 619 int bcmgenet_mii_init(struct net_device *dev); 620 - int bcmgenet_mii_config(struct net_device *dev); 620 + int bcmgenet_mii_config(struct net_device *dev, bool init); 621 621 void bcmgenet_mii_exit(struct net_device *dev); 622 622 void bcmgenet_mii_reset(struct net_device *dev); 623 + void bcmgenet_mii_setup(struct net_device *dev); 623 624 624 625 /* Wake-on-LAN routines */ 625 626 void bcmgenet_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol);
+5 -4
drivers/net/ethernet/broadcom/genet/bcmmii.c
··· 77 77 /* setup netdev link state when PHY link status change and 78 78 * update UMAC and RGMII block when link up 79 79 */ 80 - static void bcmgenet_mii_setup(struct net_device *dev) 80 + void bcmgenet_mii_setup(struct net_device *dev) 81 81 { 82 82 struct bcmgenet_priv *priv = netdev_priv(dev); 83 83 struct phy_device *phydev = priv->phydev; ··· 211 211 bcmgenet_sys_writel(priv, reg, SYS_PORT_CTRL); 212 212 } 213 213 214 - int bcmgenet_mii_config(struct net_device *dev) 214 + int bcmgenet_mii_config(struct net_device *dev, bool init) 215 215 { 216 216 struct bcmgenet_priv *priv = netdev_priv(dev); 217 217 struct phy_device *phydev = priv->phydev; ··· 298 298 return -EINVAL; 299 299 } 300 300 301 - dev_info(kdev, "configuring instance for %s\n", phy_name); 301 + if (init) 302 + dev_info(kdev, "configuring instance for %s\n", phy_name); 302 303 303 304 return 0; 304 305 } ··· 351 350 * PHY speed which is needed for bcmgenet_mii_config() to configure 352 351 * things appropriately. 353 352 */ 354 - ret = bcmgenet_mii_config(dev); 353 + ret = bcmgenet_mii_config(dev, true); 355 354 if (ret) { 356 355 phy_disconnect(priv->phydev); 357 356 return ret;
+21 -10
drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
··· 79 79 app.protocol = dcb->app_priority[i].protocolid; 80 80 81 81 if (dcb->dcb_version == FW_PORT_DCB_VER_IEEE) { 82 + app.priority = dcb->app_priority[i].user_prio_map; 82 83 app.selector = dcb->app_priority[i].sel_field + 1; 83 - err = dcb_ieee_setapp(dev, &app); 84 + err = dcb_ieee_delapp(dev, &app); 84 85 } else { 85 86 app.selector = !!(dcb->app_priority[i].sel_field); 86 87 err = dcb_setapp(dev, &app); ··· 123 122 case CXGB4_DCB_INPUT_FW_ENABLED: { 124 123 /* we're going to use Firmware DCB */ 125 124 dcb->state = CXGB4_DCB_STATE_FW_INCOMPLETE; 126 - dcb->supported = CXGB4_DCBX_FW_SUPPORT; 125 + dcb->supported = DCB_CAP_DCBX_LLD_MANAGED; 126 + if (dcb->dcb_version == FW_PORT_DCB_VER_IEEE) 127 + dcb->supported |= DCB_CAP_DCBX_VER_IEEE; 128 + else 129 + dcb->supported |= DCB_CAP_DCBX_VER_CEE; 127 130 break; 128 131 } 129 132 ··· 441 436 *up_tc_map = (1 << tc); 442 437 443 438 /* prio_type is link strict */ 444 - *prio_type = 0x2; 439 + if (*pgid != 0xF) 440 + *prio_type = 0x2; 445 441 } 446 442 447 443 static void cxgb4_getpgtccfg_tx(struct net_device *dev, int tc, 448 444 u8 *prio_type, u8 *pgid, u8 *bw_per, 449 445 u8 *up_tc_map) 450 446 { 451 - return cxgb4_getpgtccfg(dev, tc, prio_type, pgid, bw_per, up_tc_map, 1); 447 + /* tc 0 is written at MSB position */ 448 + return cxgb4_getpgtccfg(dev, (7 - tc), prio_type, pgid, bw_per, 449 + up_tc_map, 1); 452 450 } 453 451 454 452 ··· 459 451 u8 *prio_type, u8 *pgid, u8 *bw_per, 460 452 u8 *up_tc_map) 461 453 { 462 - return cxgb4_getpgtccfg(dev, tc, prio_type, pgid, bw_per, up_tc_map, 0); 454 + /* tc 0 is written at MSB position */ 455 + return cxgb4_getpgtccfg(dev, (7 - tc), prio_type, pgid, bw_per, 456 + up_tc_map, 0); 463 457 } 464 458 465 459 static void cxgb4_setpgtccfg_tx(struct net_device *dev, int tc, ··· 471 461 struct fw_port_cmd pcmd; 472 462 struct port_info *pi = netdev2pinfo(dev); 473 463 struct adapter *adap = pi->adapter; 464 + int fw_tc = 7 - tc; 474 465 u32 _pgid; 475 466 int err; 476 467 ··· 490 479 } 491 480 492 481 _pgid = be32_to_cpu(pcmd.u.dcb.pgid.pgid); 493 - _pgid &= ~(0xF << (tc * 4)); 494 - _pgid |= pgid << (tc * 4); 482 + _pgid &= ~(0xF << (fw_tc * 4)); 483 + _pgid |= pgid << (fw_tc * 4); 495 484 pcmd.u.dcb.pgid.pgid = cpu_to_be32(_pgid); 496 485 497 486 INIT_PORT_DCB_WRITE_CMD(pcmd, pi->port_id); ··· 604 593 priority >= CXGB4_MAX_PRIORITY) 605 594 *pfccfg = 0; 606 595 else 607 - *pfccfg = (pi->dcb.pfcen >> priority) & 1; 596 + *pfccfg = (pi->dcb.pfcen >> (7 - priority)) & 1; 608 597 } 609 598 610 599 /* Enable/disable Priority Pause Frames for the specified Traffic Class ··· 629 618 pcmd.u.dcb.pfc.pfcen = pi->dcb.pfcen; 630 619 631 620 if (pfccfg) 632 - pcmd.u.dcb.pfc.pfcen |= (1 << priority); 621 + pcmd.u.dcb.pfc.pfcen |= (1 << (7 - priority)); 633 622 else 634 - pcmd.u.dcb.pfc.pfcen &= (~(1 << priority)); 623 + pcmd.u.dcb.pfc.pfcen &= (~(1 << (7 - priority))); 635 624 636 625 err = t4_wr_mbox(adap, adap->mbox, &pcmd, sizeof(pcmd), &pcmd); 637 626 if (err != FW_PORT_DCB_CFG_SUCCESS) {
+27 -3
drivers/net/ethernet/chelsio/cxgb4/sge.c
··· 2914 2914 int t4_sge_init(struct adapter *adap) 2915 2915 { 2916 2916 struct sge *s = &adap->sge; 2917 - u32 sge_control, sge_conm_ctrl; 2917 + u32 sge_control, sge_control2, sge_conm_ctrl; 2918 + unsigned int ingpadboundary, ingpackboundary; 2918 2919 int ret, egress_threshold; 2919 2920 2920 2921 /* ··· 2925 2924 sge_control = t4_read_reg(adap, SGE_CONTROL); 2926 2925 s->pktshift = PKTSHIFT_GET(sge_control); 2927 2926 s->stat_len = (sge_control & EGRSTATUSPAGESIZE_MASK) ? 128 : 64; 2928 - s->fl_align = 1 << (INGPADBOUNDARY_GET(sge_control) + 2929 - X_INGPADBOUNDARY_SHIFT); 2927 + 2928 + /* T4 uses a single control field to specify both the PCIe Padding and 2929 + * Packing Boundary. T5 introduced the ability to specify these 2930 + * separately. The actual Ingress Packet Data alignment boundary 2931 + * within Packed Buffer Mode is the maximum of these two 2932 + * specifications. 2933 + */ 2934 + ingpadboundary = 1 << (INGPADBOUNDARY_GET(sge_control) + 2935 + X_INGPADBOUNDARY_SHIFT); 2936 + if (is_t4(adap->params.chip)) { 2937 + s->fl_align = ingpadboundary; 2938 + } else { 2939 + /* T5 has a different interpretation of one of the PCIe Packing 2940 + * Boundary values. 2941 + */ 2942 + sge_control2 = t4_read_reg(adap, SGE_CONTROL2_A); 2943 + ingpackboundary = INGPACKBOUNDARY_G(sge_control2); 2944 + if (ingpackboundary == INGPACKBOUNDARY_16B_X) 2945 + ingpackboundary = 16; 2946 + else 2947 + ingpackboundary = 1 << (ingpackboundary + 2948 + INGPACKBOUNDARY_SHIFT_X); 2949 + 2950 + s->fl_align = max(ingpadboundary, ingpackboundary); 2951 + } 2930 2952 2931 2953 if (adap->flags & USING_SOFT_PARAMS) 2932 2954 ret = t4_sge_init_soft(adap);
+45 -6
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
··· 3129 3129 HOSTPAGESIZEPF6(sge_hps) | 3130 3130 HOSTPAGESIZEPF7(sge_hps)); 3131 3131 3132 - t4_set_reg_field(adap, SGE_CONTROL, 3133 - INGPADBOUNDARY_MASK | 3134 - EGRSTATUSPAGESIZE_MASK, 3135 - INGPADBOUNDARY(fl_align_log - 5) | 3136 - EGRSTATUSPAGESIZE(stat_len != 64)); 3137 - 3132 + if (is_t4(adap->params.chip)) { 3133 + t4_set_reg_field(adap, SGE_CONTROL, 3134 + INGPADBOUNDARY_MASK | 3135 + EGRSTATUSPAGESIZE_MASK, 3136 + INGPADBOUNDARY(fl_align_log - 5) | 3137 + EGRSTATUSPAGESIZE(stat_len != 64)); 3138 + } else { 3139 + /* T5 introduced the separation of the Free List Padding and 3140 + * Packing Boundaries. Thus, we can select a smaller Padding 3141 + * Boundary to avoid uselessly chewing up PCIe Link and Memory 3142 + * Bandwidth, and use a Packing Boundary which is large enough 3143 + * to avoid false sharing between CPUs, etc. 3144 + * 3145 + * For the PCI Link, the smaller the Padding Boundary the 3146 + * better. For the Memory Controller, a smaller Padding 3147 + * Boundary is better until we cross under the Memory Line 3148 + * Size (the minimum unit of transfer to/from Memory). If we 3149 + * have a Padding Boundary which is smaller than the Memory 3150 + * Line Size, that'll involve a Read-Modify-Write cycle on the 3151 + * Memory Controller which is never good. For T5 the smallest 3152 + * Padding Boundary which we can select is 32 bytes which is 3153 + * larger than any known Memory Controller Line Size so we'll 3154 + * use that. 3155 + * 3156 + * T5 has a different interpretation of the "0" value for the 3157 + * Packing Boundary. This corresponds to 16 bytes instead of 3158 + * the expected 32 bytes. We never have a Packing Boundary 3159 + * less than 32 bytes so we can't use that special value but 3160 + * on the other hand, if we wanted 32 bytes, the best we can 3161 + * really do is 64 bytes. 3162 + */ 3163 + if (fl_align <= 32) { 3164 + fl_align = 64; 3165 + fl_align_log = 6; 3166 + } 3167 + t4_set_reg_field(adap, SGE_CONTROL, 3168 + INGPADBOUNDARY_MASK | 3169 + EGRSTATUSPAGESIZE_MASK, 3170 + INGPADBOUNDARY(INGPCIEBOUNDARY_32B_X) | 3171 + EGRSTATUSPAGESIZE(stat_len != 64)); 3172 + t4_set_reg_field(adap, SGE_CONTROL2_A, 3173 + INGPACKBOUNDARY_V(INGPACKBOUNDARY_M), 3174 + INGPACKBOUNDARY_V(fl_align_log - 3175 + INGPACKBOUNDARY_SHIFT_X)); 3176 + } 3138 3177 /* 3139 3178 * Adjust various SGE Free List Host Buffer Sizes. 3140 3179 *
+10
drivers/net/ethernet/chelsio/cxgb4/t4_regs.h
··· 95 95 #define X_INGPADBOUNDARY_SHIFT 5 96 96 97 97 #define SGE_CONTROL 0x1008 98 + #define SGE_CONTROL2_A 0x1124 98 99 #define DCASYSTYPE 0x00080000U 99 100 #define RXPKTCPLMODE_MASK 0x00040000U 100 101 #define RXPKTCPLMODE_SHIFT 18 ··· 107 106 #define PKTSHIFT_SHIFT 10 108 107 #define PKTSHIFT(x) ((x) << PKTSHIFT_SHIFT) 109 108 #define PKTSHIFT_GET(x) (((x) & PKTSHIFT_MASK) >> PKTSHIFT_SHIFT) 109 + #define INGPCIEBOUNDARY_32B_X 0 110 110 #define INGPCIEBOUNDARY_MASK 0x00000380U 111 111 #define INGPCIEBOUNDARY_SHIFT 7 112 112 #define INGPCIEBOUNDARY(x) ((x) << INGPCIEBOUNDARY_SHIFT) ··· 116 114 #define INGPADBOUNDARY(x) ((x) << INGPADBOUNDARY_SHIFT) 117 115 #define INGPADBOUNDARY_GET(x) (((x) & INGPADBOUNDARY_MASK) \ 118 116 >> INGPADBOUNDARY_SHIFT) 117 + #define INGPACKBOUNDARY_16B_X 0 118 + #define INGPACKBOUNDARY_SHIFT_X 5 119 + 120 + #define INGPACKBOUNDARY_S 16 121 + #define INGPACKBOUNDARY_M 0x7U 122 + #define INGPACKBOUNDARY_V(x) ((x) << INGPACKBOUNDARY_S) 123 + #define INGPACKBOUNDARY_G(x) (((x) >> INGPACKBOUNDARY_S) \ 124 + & INGPACKBOUNDARY_M) 119 125 #define EGRPCIEBOUNDARY_MASK 0x0000000eU 120 126 #define EGRPCIEBOUNDARY_SHIFT 1 121 127 #define EGRPCIEBOUNDARY(x) ((x) << EGRPCIEBOUNDARY_SHIFT)
+8
drivers/net/ethernet/chelsio/cxgb4vf/adapter.h
··· 299 299 u16 timer_val[SGE_NTIMERS]; /* interrupt holdoff timer array */ 300 300 u8 counter_val[SGE_NCOUNTERS]; /* interrupt RX threshold array */ 301 301 302 + /* Decoded Adapter Parameters. 303 + */ 304 + u32 fl_pg_order; /* large page allocation size */ 305 + u32 stat_len; /* length of status page at ring end */ 306 + u32 pktshift; /* padding between CPL & packet data */ 307 + u32 fl_align; /* response queue message alignment */ 308 + u32 fl_starve_thres; /* Free List starvation threshold */ 309 + 302 310 /* 303 311 * Reverse maps from Absolute Queue IDs to associated queue pointers. 304 312 * The absolute Queue IDs are in a compact range which start at a
+90 -46
drivers/net/ethernet/chelsio/cxgb4vf/sge.c
··· 51 51 #include "../cxgb4/t4_msg.h" 52 52 53 53 /* 54 - * Decoded Adapter Parameters. 55 - */ 56 - static u32 FL_PG_ORDER; /* large page allocation size */ 57 - static u32 STAT_LEN; /* length of status page at ring end */ 58 - static u32 PKTSHIFT; /* padding between CPL and packet data */ 59 - static u32 FL_ALIGN; /* response queue message alignment */ 60 - 61 - /* 62 54 * Constants ... 63 55 */ 64 56 enum { ··· 92 100 */ 93 101 TX_QCHECK_PERIOD = (HZ / 2), 94 102 MAX_TIMER_TX_RECLAIM = 100, 95 - 96 - /* 97 - * An FL with <= FL_STARVE_THRES buffers is starving and a periodic 98 - * timer will attempt to refill it. 99 - */ 100 - FL_STARVE_THRES = 4, 101 103 102 104 /* 103 105 * Suspend an Ethernet TX queue with fewer available descriptors than ··· 250 264 251 265 /** 252 266 * fl_starving - return whether a Free List is starving. 267 + * @adapter: pointer to the adapter 253 268 * @fl: the Free List 254 269 * 255 270 * Tests specified Free List to see whether the number of buffers 256 271 * available to the hardware has falled below our "starvation" 257 272 * threshold. 258 273 */ 259 - static inline bool fl_starving(const struct sge_fl *fl) 274 + static inline bool fl_starving(const struct adapter *adapter, 275 + const struct sge_fl *fl) 260 276 { 261 - return fl->avail - fl->pend_cred <= FL_STARVE_THRES; 277 + const struct sge *s = &adapter->sge; 278 + 279 + return fl->avail - fl->pend_cred <= s->fl_starve_thres; 262 280 } 263 281 264 282 /** ··· 447 457 448 458 /** 449 459 * get_buf_size - return the size of an RX Free List buffer. 460 + * @adapter: pointer to the associated adapter 450 461 * @sdesc: pointer to the software buffer descriptor 451 462 */ 452 - static inline int get_buf_size(const struct rx_sw_desc *sdesc) 463 + static inline int get_buf_size(const struct adapter *adapter, 464 + const struct rx_sw_desc *sdesc) 453 465 { 454 - return FL_PG_ORDER > 0 && (sdesc->dma_addr & RX_LARGE_BUF) 455 - ? (PAGE_SIZE << FL_PG_ORDER) 456 - : PAGE_SIZE; 466 + const struct sge *s = &adapter->sge; 467 + 468 + return (s->fl_pg_order > 0 && (sdesc->dma_addr & RX_LARGE_BUF) 469 + ? (PAGE_SIZE << s->fl_pg_order) : PAGE_SIZE); 457 470 } 458 471 459 472 /** ··· 476 483 477 484 if (is_buf_mapped(sdesc)) 478 485 dma_unmap_page(adapter->pdev_dev, get_buf_addr(sdesc), 479 - get_buf_size(sdesc), PCI_DMA_FROMDEVICE); 486 + get_buf_size(adapter, sdesc), 487 + PCI_DMA_FROMDEVICE); 480 488 put_page(sdesc->page); 481 489 sdesc->page = NULL; 482 490 if (++fl->cidx == fl->size) ··· 505 511 506 512 if (is_buf_mapped(sdesc)) 507 513 dma_unmap_page(adapter->pdev_dev, get_buf_addr(sdesc), 508 - get_buf_size(sdesc), PCI_DMA_FROMDEVICE); 514 + get_buf_size(adapter, sdesc), 515 + PCI_DMA_FROMDEVICE); 509 516 sdesc->page = NULL; 510 517 if (++fl->cidx == fl->size) 511 518 fl->cidx = 0; ··· 584 589 static unsigned int refill_fl(struct adapter *adapter, struct sge_fl *fl, 585 590 int n, gfp_t gfp) 586 591 { 592 + struct sge *s = &adapter->sge; 587 593 struct page *page; 588 594 dma_addr_t dma_addr; 589 595 unsigned int cred = fl->avail; ··· 604 608 * If we don't support large pages, drop directly into the small page 605 609 * allocation code. 606 610 */ 607 - if (FL_PG_ORDER == 0) 611 + if (s->fl_pg_order == 0) 608 612 goto alloc_small_pages; 609 613 610 614 while (n) { 611 615 page = alloc_pages(gfp | __GFP_COMP | __GFP_NOWARN, 612 - FL_PG_ORDER); 616 + s->fl_pg_order); 613 617 if (unlikely(!page)) { 614 618 /* 615 619 * We've failed inour attempt to allocate a "large ··· 619 623 fl->large_alloc_failed++; 620 624 break; 621 625 } 622 - poison_buf(page, PAGE_SIZE << FL_PG_ORDER); 626 + poison_buf(page, PAGE_SIZE << s->fl_pg_order); 623 627 624 628 dma_addr = dma_map_page(adapter->pdev_dev, page, 0, 625 - PAGE_SIZE << FL_PG_ORDER, 629 + PAGE_SIZE << s->fl_pg_order, 626 630 PCI_DMA_FROMDEVICE); 627 631 if (unlikely(dma_mapping_error(adapter->pdev_dev, dma_addr))) { 628 632 /* ··· 633 637 * because DMA mapping resources are typically 634 638 * critical resources once they become scarse. 635 639 */ 636 - __free_pages(page, FL_PG_ORDER); 640 + __free_pages(page, s->fl_pg_order); 637 641 goto out; 638 642 } 639 643 dma_addr |= RX_LARGE_BUF; ··· 689 693 fl->pend_cred += cred; 690 694 ring_fl_db(adapter, fl); 691 695 692 - if (unlikely(fl_starving(fl))) { 696 + if (unlikely(fl_starving(adapter, fl))) { 693 697 smp_wmb(); 694 698 set_bit(fl->cntxt_id, adapter->sge.starving_fl); 695 699 } ··· 1464 1468 static void do_gro(struct sge_eth_rxq *rxq, const struct pkt_gl *gl, 1465 1469 const struct cpl_rx_pkt *pkt) 1466 1470 { 1471 + struct adapter *adapter = rxq->rspq.adapter; 1472 + struct sge *s = &adapter->sge; 1467 1473 int ret; 1468 1474 struct sk_buff *skb; 1469 1475 ··· 1476 1478 return; 1477 1479 } 1478 1480 1479 - copy_frags(skb, gl, PKTSHIFT); 1480 - skb->len = gl->tot_len - PKTSHIFT; 1481 + copy_frags(skb, gl, s->pktshift); 1482 + skb->len = gl->tot_len - s->pktshift; 1481 1483 skb->data_len = skb->len; 1482 1484 skb->truesize += skb->data_len; 1483 1485 skb->ip_summed = CHECKSUM_UNNECESSARY; ··· 1514 1516 bool csum_ok = pkt->csum_calc && !pkt->err_vec && 1515 1517 (rspq->netdev->features & NETIF_F_RXCSUM); 1516 1518 struct sge_eth_rxq *rxq = container_of(rspq, struct sge_eth_rxq, rspq); 1519 + struct adapter *adapter = rspq->adapter; 1520 + struct sge *s = &adapter->sge; 1517 1521 1518 1522 /* 1519 1523 * If this is a good TCP packet and we have Generic Receive Offload ··· 1537 1537 rxq->stats.rx_drops++; 1538 1538 return 0; 1539 1539 } 1540 - __skb_pull(skb, PKTSHIFT); 1540 + __skb_pull(skb, s->pktshift); 1541 1541 skb->protocol = eth_type_trans(skb, rspq->netdev); 1542 1542 skb_record_rx_queue(skb, rspq->idx); 1543 1543 rxq->stats.pkts++; ··· 1648 1648 static int process_responses(struct sge_rspq *rspq, int budget) 1649 1649 { 1650 1650 struct sge_eth_rxq *rxq = container_of(rspq, struct sge_eth_rxq, rspq); 1651 + struct adapter *adapter = rspq->adapter; 1652 + struct sge *s = &adapter->sge; 1651 1653 int budget_left = budget; 1652 1654 1653 1655 while (likely(budget_left)) { ··· 1699 1697 BUG_ON(frag >= MAX_SKB_FRAGS); 1700 1698 BUG_ON(rxq->fl.avail == 0); 1701 1699 sdesc = &rxq->fl.sdesc[rxq->fl.cidx]; 1702 - bufsz = get_buf_size(sdesc); 1700 + bufsz = get_buf_size(adapter, sdesc); 1703 1701 fp->page = sdesc->page; 1704 1702 fp->offset = rspq->offset; 1705 1703 fp->size = min(bufsz, len); ··· 1728 1726 */ 1729 1727 ret = rspq->handler(rspq, rspq->cur_desc, &gl); 1730 1728 if (likely(ret == 0)) 1731 - rspq->offset += ALIGN(fp->size, FL_ALIGN); 1729 + rspq->offset += ALIGN(fp->size, s->fl_align); 1732 1730 else 1733 1731 restore_rx_bufs(&gl, &rxq->fl, frag); 1734 1732 } else if (likely(rsp_type == RSP_TYPE_CPL)) { ··· 1965 1963 * schedule napi but the FL is no longer starving. 1966 1964 * No biggie. 1967 1965 */ 1968 - if (fl_starving(fl)) { 1966 + if (fl_starving(adapter, fl)) { 1969 1967 struct sge_eth_rxq *rxq; 1970 1968 1971 1969 rxq = container_of(fl, struct sge_eth_rxq, fl); ··· 2049 2047 int intr_dest, 2050 2048 struct sge_fl *fl, rspq_handler_t hnd) 2051 2049 { 2050 + struct sge *s = &adapter->sge; 2052 2051 struct port_info *pi = netdev_priv(dev); 2053 2052 struct fw_iq_cmd cmd, rpl; 2054 2053 int ret, iqandst, flsz = 0; ··· 2120 2117 fl->size = roundup(fl->size, FL_PER_EQ_UNIT); 2121 2118 fl->desc = alloc_ring(adapter->pdev_dev, fl->size, 2122 2119 sizeof(__be64), sizeof(struct rx_sw_desc), 2123 - &fl->addr, &fl->sdesc, STAT_LEN); 2120 + &fl->addr, &fl->sdesc, s->stat_len); 2124 2121 if (!fl->desc) { 2125 2122 ret = -ENOMEM; 2126 2123 goto err; ··· 2132 2129 * free list ring) in Egress Queue Units. 2133 2130 */ 2134 2131 flsz = (fl->size / FL_PER_EQ_UNIT + 2135 - STAT_LEN / EQ_UNIT); 2132 + s->stat_len / EQ_UNIT); 2136 2133 2137 2134 /* 2138 2135 * Fill in all the relevant firmware Ingress Queue Command ··· 2220 2217 struct net_device *dev, struct netdev_queue *devq, 2221 2218 unsigned int iqid) 2222 2219 { 2220 + struct sge *s = &adapter->sge; 2223 2221 int ret, nentries; 2224 2222 struct fw_eq_eth_cmd cmd, rpl; 2225 2223 struct port_info *pi = netdev_priv(dev); ··· 2229 2225 * Calculate the size of the hardware TX Queue (including the Status 2230 2226 * Page on the end of the TX Queue) in units of TX Descriptors. 2231 2227 */ 2232 - nentries = txq->q.size + STAT_LEN / sizeof(struct tx_desc); 2228 + nentries = txq->q.size + s->stat_len / sizeof(struct tx_desc); 2233 2229 2234 2230 /* 2235 2231 * Allocate the hardware ring for the TX ring (with space for its ··· 2238 2234 txq->q.desc = alloc_ring(adapter->pdev_dev, txq->q.size, 2239 2235 sizeof(struct tx_desc), 2240 2236 sizeof(struct tx_sw_desc), 2241 - &txq->q.phys_addr, &txq->q.sdesc, STAT_LEN); 2237 + &txq->q.phys_addr, &txq->q.sdesc, s->stat_len); 2242 2238 if (!txq->q.desc) 2243 2239 return -ENOMEM; 2244 2240 ··· 2311 2307 */ 2312 2308 static void free_txq(struct adapter *adapter, struct sge_txq *tq) 2313 2309 { 2310 + struct sge *s = &adapter->sge; 2311 + 2314 2312 dma_free_coherent(adapter->pdev_dev, 2315 - tq->size * sizeof(*tq->desc) + STAT_LEN, 2313 + tq->size * sizeof(*tq->desc) + s->stat_len, 2316 2314 tq->desc, tq->phys_addr); 2317 2315 tq->cntxt_id = 0; 2318 2316 tq->sdesc = NULL; ··· 2328 2322 static void free_rspq_fl(struct adapter *adapter, struct sge_rspq *rspq, 2329 2323 struct sge_fl *fl) 2330 2324 { 2325 + struct sge *s = &adapter->sge; 2331 2326 unsigned int flid = fl ? fl->cntxt_id : 0xffff; 2332 2327 2333 2328 t4vf_iq_free(adapter, FW_IQ_TYPE_FL_INT_CAP, ··· 2344 2337 if (fl) { 2345 2338 free_rx_bufs(adapter, fl, fl->avail); 2346 2339 dma_free_coherent(adapter->pdev_dev, 2347 - fl->size * sizeof(*fl->desc) + STAT_LEN, 2340 + fl->size * sizeof(*fl->desc) + s->stat_len, 2348 2341 fl->desc, fl->addr); 2349 2342 kfree(fl->sdesc); 2350 2343 fl->sdesc = NULL; ··· 2430 2423 u32 fl0 = sge_params->sge_fl_buffer_size[0]; 2431 2424 u32 fl1 = sge_params->sge_fl_buffer_size[1]; 2432 2425 struct sge *s = &adapter->sge; 2426 + unsigned int ingpadboundary, ingpackboundary; 2433 2427 2434 2428 /* 2435 2429 * Start by vetting the basic SGE parameters which have been set up by ··· 2451 2443 * Now translate the adapter parameters into our internal forms. 2452 2444 */ 2453 2445 if (fl1) 2454 - FL_PG_ORDER = ilog2(fl1) - PAGE_SHIFT; 2455 - STAT_LEN = ((sge_params->sge_control & EGRSTATUSPAGESIZE_MASK) 2456 - ? 128 : 64); 2457 - PKTSHIFT = PKTSHIFT_GET(sge_params->sge_control); 2458 - FL_ALIGN = 1 << (INGPADBOUNDARY_GET(sge_params->sge_control) + 2459 - SGE_INGPADBOUNDARY_SHIFT); 2446 + s->fl_pg_order = ilog2(fl1) - PAGE_SHIFT; 2447 + s->stat_len = ((sge_params->sge_control & EGRSTATUSPAGESIZE_MASK) 2448 + ? 128 : 64); 2449 + s->pktshift = PKTSHIFT_GET(sge_params->sge_control); 2450 + 2451 + /* T4 uses a single control field to specify both the PCIe Padding and 2452 + * Packing Boundary. T5 introduced the ability to specify these 2453 + * separately. The actual Ingress Packet Data alignment boundary 2454 + * within Packed Buffer Mode is the maximum of these two 2455 + * specifications. (Note that it makes no real practical sense to 2456 + * have the Pading Boudary be larger than the Packing Boundary but you 2457 + * could set the chip up that way and, in fact, legacy T4 code would 2458 + * end doing this because it would initialize the Padding Boundary and 2459 + * leave the Packing Boundary initialized to 0 (16 bytes).) 2460 + */ 2461 + ingpadboundary = 1 << (INGPADBOUNDARY_GET(sge_params->sge_control) + 2462 + X_INGPADBOUNDARY_SHIFT); 2463 + if (is_t4(adapter->params.chip)) { 2464 + s->fl_align = ingpadboundary; 2465 + } else { 2466 + /* T5 has a different interpretation of one of the PCIe Packing 2467 + * Boundary values. 2468 + */ 2469 + ingpackboundary = INGPACKBOUNDARY_G(sge_params->sge_control2); 2470 + if (ingpackboundary == INGPACKBOUNDARY_16B_X) 2471 + ingpackboundary = 16; 2472 + else 2473 + ingpackboundary = 1 << (ingpackboundary + 2474 + INGPACKBOUNDARY_SHIFT_X); 2475 + 2476 + s->fl_align = max(ingpadboundary, ingpackboundary); 2477 + } 2478 + 2479 + /* A FL with <= fl_starve_thres buffers is starving and a periodic 2480 + * timer will attempt to refill it. This needs to be larger than the 2481 + * SGE's Egress Congestion Threshold. If it isn't, then we can get 2482 + * stuck waiting for new packets while the SGE is waiting for us to 2483 + * give it more Free List entries. (Note that the SGE's Egress 2484 + * Congestion Threshold is in units of 2 Free List pointers.) 2485 + */ 2486 + s->fl_starve_thres 2487 + = EGRTHRESHOLD_GET(sge_params->sge_congestion_control)*2 + 1; 2460 2488 2461 2489 /* 2462 2490 * Set up tasklet timers.
+2
drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h
··· 134 134 */ 135 135 struct sge_params { 136 136 u32 sge_control; /* padding, boundaries, lengths, etc. */ 137 + u32 sge_control2; /* T5: more of the same */ 137 138 u32 sge_host_page_size; /* RDMA page sizes */ 138 139 u32 sge_queues_per_page; /* RDMA queues/page */ 139 140 u32 sge_user_mode_limits; /* limits for BAR2 user mode accesses */ 140 141 u32 sge_fl_buffer_size[16]; /* free list buffer sizes */ 141 142 u32 sge_ingress_rx_threshold; /* RX counter interrupt threshold[4] */ 143 + u32 sge_congestion_control; /* congestion thresholds, etc. */ 142 144 u32 sge_timer_value_0_and_1; /* interrupt coalescing timer values */ 143 145 u32 sge_timer_value_2_and_3; 144 146 u32 sge_timer_value_4_and_5;
+27 -1
drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
··· 468 468 sge_params->sge_timer_value_2_and_3 = vals[5]; 469 469 sge_params->sge_timer_value_4_and_5 = vals[6]; 470 470 471 + /* T4 uses a single control field to specify both the PCIe Padding and 472 + * Packing Boundary. T5 introduced the ability to specify these 473 + * separately with the Padding Boundary in SGE_CONTROL and and Packing 474 + * Boundary in SGE_CONTROL2. So for T5 and later we need to grab 475 + * SGE_CONTROL in order to determine how ingress packet data will be 476 + * laid out in Packed Buffer Mode. Unfortunately, older versions of 477 + * the firmware won't let us retrieve SGE_CONTROL2 so if we get a 478 + * failure grabbing it we throw an error since we can't figure out the 479 + * right value. 480 + */ 481 + if (!is_t4(adapter->params.chip)) { 482 + params[0] = (FW_PARAMS_MNEM(FW_PARAMS_MNEM_REG) | 483 + FW_PARAMS_PARAM_XYZ(SGE_CONTROL2_A)); 484 + v = t4vf_query_params(adapter, 1, params, vals); 485 + if (v != FW_SUCCESS) { 486 + dev_err(adapter->pdev_dev, 487 + "Unable to get SGE Control2; " 488 + "probably old firmware.\n"); 489 + return v; 490 + } 491 + sge_params->sge_control2 = vals[0]; 492 + } 493 + 471 494 params[0] = (FW_PARAMS_MNEM(FW_PARAMS_MNEM_REG) | 472 495 FW_PARAMS_PARAM_XYZ(SGE_INGRESS_RX_THRESHOLD)); 473 - v = t4vf_query_params(adapter, 1, params, vals); 496 + params[1] = (FW_PARAMS_MNEM(FW_PARAMS_MNEM_REG) | 497 + FW_PARAMS_PARAM_XYZ(SGE_CONM_CTRL)); 498 + v = t4vf_query_params(adapter, 2, params, vals); 474 499 if (v) 475 500 return v; 476 501 sge_params->sge_ingress_rx_threshold = vals[0]; 502 + sge_params->sge_congestion_control = vals[1]; 477 503 478 504 return 0; 479 505 }
+8 -12
drivers/net/ethernet/cisco/enic/enic_main.c
··· 940 940 struct vnic_rq_buf *buf = rq->to_use; 941 941 942 942 if (buf->os_buf) { 943 - buf = buf->next; 944 - rq->to_use = buf; 945 - rq->ring.desc_avail--; 946 - if ((buf->index & VNIC_RQ_RETURN_RATE) == 0) { 947 - /* Adding write memory barrier prevents compiler and/or 948 - * CPU reordering, thus avoiding descriptor posting 949 - * before descriptor is initialized. Otherwise, hardware 950 - * can read stale descriptor fields. 951 - */ 952 - wmb(); 953 - iowrite32(buf->index, &rq->ctrl->posted_index); 954 - } 943 + enic_queue_rq_desc(rq, buf->os_buf, os_buf_index, buf->dma_addr, 944 + buf->len); 955 945 956 946 return 0; 957 947 } ··· 1027 1037 enic->rq_truncated_pkts++; 1028 1038 } 1029 1039 1040 + pci_unmap_single(enic->pdev, buf->dma_addr, buf->len, 1041 + PCI_DMA_FROMDEVICE); 1030 1042 dev_kfree_skb_any(skb); 1043 + buf->os_buf = NULL; 1031 1044 1032 1045 return; 1033 1046 } ··· 1081 1088 /* Buffer overflow 1082 1089 */ 1083 1090 1091 + pci_unmap_single(enic->pdev, buf->dma_addr, buf->len, 1092 + PCI_DMA_FROMDEVICE); 1084 1093 dev_kfree_skb_any(skb); 1094 + buf->os_buf = NULL; 1085 1095 } 1086 1096 } 1087 1097
+27 -12
drivers/net/ethernet/freescale/fec_main.c
··· 298 298 return bufaddr; 299 299 } 300 300 301 + static void swap_buffer2(void *dst_buf, void *src_buf, int len) 302 + { 303 + int i; 304 + unsigned int *src = src_buf; 305 + unsigned int *dst = dst_buf; 306 + 307 + for (i = 0; i < len; i += 4, src++, dst++) 308 + *dst = swab32p(src); 309 + } 310 + 301 311 static void fec_dump(struct net_device *ndev) 302 312 { 303 313 struct fec_enet_private *fep = netdev_priv(ndev); ··· 1317 1307 } 1318 1308 1319 1309 static bool fec_enet_copybreak(struct net_device *ndev, struct sk_buff **skb, 1320 - struct bufdesc *bdp, u32 length) 1310 + struct bufdesc *bdp, u32 length, bool swap) 1321 1311 { 1322 1312 struct fec_enet_private *fep = netdev_priv(ndev); 1323 1313 struct sk_buff *new_skb; ··· 1332 1322 dma_sync_single_for_cpu(&fep->pdev->dev, bdp->cbd_bufaddr, 1333 1323 FEC_ENET_RX_FRSIZE - fep->rx_align, 1334 1324 DMA_FROM_DEVICE); 1335 - memcpy(new_skb->data, (*skb)->data, length); 1325 + if (!swap) 1326 + memcpy(new_skb->data, (*skb)->data, length); 1327 + else 1328 + swap_buffer2(new_skb->data, (*skb)->data, length); 1336 1329 *skb = new_skb; 1337 1330 1338 1331 return true; ··· 1365 1352 u16 vlan_tag; 1366 1353 int index = 0; 1367 1354 bool is_copybreak; 1355 + bool need_swap = id_entry->driver_data & FEC_QUIRK_SWAP_FRAME; 1368 1356 1369 1357 #ifdef CONFIG_M532x 1370 1358 flush_cache_all(); ··· 1429 1415 * include that when passing upstream as it messes up 1430 1416 * bridging applications. 1431 1417 */ 1432 - is_copybreak = fec_enet_copybreak(ndev, &skb, bdp, pkt_len - 4); 1418 + is_copybreak = fec_enet_copybreak(ndev, &skb, bdp, pkt_len - 4, 1419 + need_swap); 1433 1420 if (!is_copybreak) { 1434 1421 skb_new = netdev_alloc_skb(ndev, FEC_ENET_RX_FRSIZE); 1435 1422 if (unlikely(!skb_new)) { ··· 1445 1430 prefetch(skb->data - NET_IP_ALIGN); 1446 1431 skb_put(skb, pkt_len - 4); 1447 1432 data = skb->data; 1448 - if (id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) 1433 + if (!is_copybreak && need_swap) 1449 1434 swap_buffer(data, pkt_len); 1450 1435 1451 1436 /* Extract the enhanced buffer descriptor */ ··· 3358 3343 netif_device_detach(ndev); 3359 3344 netif_tx_unlock_bh(ndev); 3360 3345 fec_stop(ndev); 3346 + fec_enet_clk_enable(ndev, false); 3347 + pinctrl_pm_select_sleep_state(&fep->pdev->dev); 3361 3348 } 3362 3349 rtnl_unlock(); 3363 - 3364 - fec_enet_clk_enable(ndev, false); 3365 - pinctrl_pm_select_sleep_state(&fep->pdev->dev); 3366 3350 3367 3351 if (fep->reg_phy) 3368 3352 regulator_disable(fep->reg_phy); ··· 3381 3367 return ret; 3382 3368 } 3383 3369 3384 - pinctrl_pm_select_default_state(&fep->pdev->dev); 3385 - ret = fec_enet_clk_enable(ndev, true); 3386 - if (ret) 3387 - goto failed_clk; 3388 - 3389 3370 rtnl_lock(); 3390 3371 if (netif_running(ndev)) { 3372 + pinctrl_pm_select_default_state(&fep->pdev->dev); 3373 + ret = fec_enet_clk_enable(ndev, true); 3374 + if (ret) { 3375 + rtnl_unlock(); 3376 + goto failed_clk; 3377 + } 3391 3378 fec_restart(ndev); 3392 3379 netif_tx_lock_bh(ndev); 3393 3380 netif_device_attach(ndev);
+1 -3
drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
··· 635 635 **/ 636 636 s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw) 637 637 { 638 - s32 status; 639 638 u16 autoneg_reg = IXGBE_MII_AUTONEG_REG; 640 639 bool autoneg = false; 641 640 ixgbe_link_speed speed; ··· 699 700 700 701 hw->phy.ops.write_reg(hw, MDIO_CTRL1, 701 702 MDIO_MMD_AN, autoneg_reg); 702 - 703 - return status; 703 + return 0; 704 704 } 705 705 706 706 /**
+10 -8
drivers/net/ethernet/marvell/mv643xx_eth.c
··· 1047 1047 int tx_index; 1048 1048 struct tx_desc *desc; 1049 1049 u32 cmd_sts; 1050 - struct sk_buff *skb; 1051 1050 1052 1051 tx_index = txq->tx_used_desc; 1053 1052 desc = &txq->tx_desc_area[tx_index]; ··· 1065 1066 reclaimed++; 1066 1067 txq->tx_desc_count--; 1067 1068 1068 - skb = NULL; 1069 - if (cmd_sts & TX_LAST_DESC) 1070 - skb = __skb_dequeue(&txq->tx_skb); 1069 + if (!IS_TSO_HEADER(txq, desc->buf_ptr)) 1070 + dma_unmap_single(mp->dev->dev.parent, desc->buf_ptr, 1071 + desc->byte_cnt, DMA_TO_DEVICE); 1072 + 1073 + if (cmd_sts & TX_ENABLE_INTERRUPT) { 1074 + struct sk_buff *skb = __skb_dequeue(&txq->tx_skb); 1075 + 1076 + if (!WARN_ON(!skb)) 1077 + dev_kfree_skb(skb); 1078 + } 1071 1079 1072 1080 if (cmd_sts & ERROR_SUMMARY) { 1073 1081 netdev_info(mp->dev, "tx error\n"); 1074 1082 mp->dev->stats.tx_errors++; 1075 1083 } 1076 1084 1077 - if (!IS_TSO_HEADER(txq, desc->buf_ptr)) 1078 - dma_unmap_single(mp->dev->dev.parent, desc->buf_ptr, 1079 - desc->byte_cnt, DMA_TO_DEVICE); 1080 - dev_kfree_skb(skb); 1081 1085 } 1082 1086 1083 1087 __netif_tx_unlock_bh(nq);
+18 -9
drivers/net/ethernet/marvell/mvpp2.c
··· 1692 1692 { 1693 1693 struct mvpp2_prs_entry *pe; 1694 1694 int tid_aux, tid; 1695 + int ret = 0; 1695 1696 1696 1697 pe = mvpp2_prs_vlan_find(priv, tpid, ai); 1697 1698 ··· 1724 1723 break; 1725 1724 } 1726 1725 1727 - if (tid <= tid_aux) 1728 - return -EINVAL; 1726 + if (tid <= tid_aux) { 1727 + ret = -EINVAL; 1728 + goto error; 1729 + } 1729 1730 1730 1731 memset(pe, 0 , sizeof(struct mvpp2_prs_entry)); 1731 1732 mvpp2_prs_tcam_lu_set(pe, MVPP2_PRS_LU_VLAN); ··· 1759 1756 1760 1757 mvpp2_prs_hw_write(priv, pe); 1761 1758 1759 + error: 1762 1760 kfree(pe); 1763 1761 1764 - return 0; 1762 + return ret; 1765 1763 } 1766 1764 1767 1765 /* Get first free double vlan ai number */ ··· 1825 1821 unsigned int port_map) 1826 1822 { 1827 1823 struct mvpp2_prs_entry *pe; 1828 - int tid_aux, tid, ai; 1824 + int tid_aux, tid, ai, ret = 0; 1829 1825 1830 1826 pe = mvpp2_prs_double_vlan_find(priv, tpid1, tpid2); 1831 1827 ··· 1842 1838 1843 1839 /* Set ai value for new double vlan entry */ 1844 1840 ai = mvpp2_prs_double_vlan_ai_free_get(priv); 1845 - if (ai < 0) 1846 - return ai; 1841 + if (ai < 0) { 1842 + ret = ai; 1843 + goto error; 1844 + } 1847 1845 1848 1846 /* Get first single/triple vlan tid */ 1849 1847 for (tid_aux = MVPP2_PE_FIRST_FREE_TID; ··· 1865 1859 break; 1866 1860 } 1867 1861 1868 - if (tid >= tid_aux) 1869 - return -ERANGE; 1862 + if (tid >= tid_aux) { 1863 + ret = -ERANGE; 1864 + goto error; 1865 + } 1870 1866 1871 1867 memset(pe, 0, sizeof(struct mvpp2_prs_entry)); 1872 1868 mvpp2_prs_tcam_lu_set(pe, MVPP2_PRS_LU_VLAN); ··· 1895 1887 mvpp2_prs_tcam_port_map_set(pe, port_map); 1896 1888 mvpp2_prs_hw_write(priv, pe); 1897 1889 1890 + error: 1898 1891 kfree(pe); 1899 - return 0; 1892 + return ret; 1900 1893 } 1901 1894 1902 1895 /* IPv4 header parsing for fragmentation and L4 offset */
+14 -8
drivers/net/ethernet/mellanox/mlx4/en_netdev.c
··· 2281 2281 ret = mlx4_SET_PORT_VXLAN(priv->mdev->dev, priv->port, 2282 2282 VXLAN_STEER_BY_OUTER_MAC, 1); 2283 2283 out: 2284 - if (ret) 2284 + if (ret) { 2285 2285 en_err(priv, "failed setting L2 tunnel configuration ret %d\n", ret); 2286 + return; 2287 + } 2288 + 2289 + /* set offloads */ 2290 + priv->dev->hw_enc_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM | 2291 + NETIF_F_TSO | NETIF_F_GSO_UDP_TUNNEL; 2292 + priv->dev->hw_features |= NETIF_F_GSO_UDP_TUNNEL; 2293 + priv->dev->features |= NETIF_F_GSO_UDP_TUNNEL; 2286 2294 } 2287 2295 2288 2296 static void mlx4_en_del_vxlan_offloads(struct work_struct *work) ··· 2298 2290 int ret; 2299 2291 struct mlx4_en_priv *priv = container_of(work, struct mlx4_en_priv, 2300 2292 vxlan_del_task); 2293 + /* unset offloads */ 2294 + priv->dev->hw_enc_features &= ~(NETIF_F_IP_CSUM | NETIF_F_RXCSUM | 2295 + NETIF_F_TSO | NETIF_F_GSO_UDP_TUNNEL); 2296 + priv->dev->hw_features &= ~NETIF_F_GSO_UDP_TUNNEL; 2297 + priv->dev->features &= ~NETIF_F_GSO_UDP_TUNNEL; 2301 2298 2302 2299 ret = mlx4_SET_PORT_VXLAN(priv->mdev->dev, priv->port, 2303 2300 VXLAN_STEER_BY_OUTER_MAC, 0); ··· 2580 2567 2581 2568 if (mdev->dev->caps.steering_mode != MLX4_STEERING_MODE_A0) 2582 2569 dev->priv_flags |= IFF_UNICAST_FLT; 2583 - 2584 - if (mdev->dev->caps.tunnel_offload_mode == MLX4_TUNNEL_OFFLOAD_MODE_VXLAN) { 2585 - dev->hw_enc_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM | 2586 - NETIF_F_TSO | NETIF_F_GSO_UDP_TUNNEL; 2587 - dev->hw_features |= NETIF_F_GSO_UDP_TUNNEL; 2588 - dev->features |= NETIF_F_GSO_UDP_TUNNEL; 2589 - } 2590 2570 2591 2571 mdev->pndev[port] = dev; 2592 2572
+3 -4
drivers/net/ethernet/mellanox/mlx5/core/eq.c
··· 374 374 snprintf(eq->name, MLX5_MAX_EQ_NAME, "%s@pci:%s", 375 375 name, pci_name(dev->pdev)); 376 376 eq->eqn = out.eq_number; 377 + eq->irqn = vecidx; 378 + eq->dev = dev; 379 + eq->doorbell = uar->map + MLX5_EQ_DOORBEL_OFFSET; 377 380 err = request_irq(table->msix_arr[vecidx].vector, mlx5_msix_handler, 0, 378 381 eq->name, eq); 379 382 if (err) 380 383 goto err_eq; 381 - 382 - eq->irqn = vecidx; 383 - eq->dev = dev; 384 - eq->doorbell = uar->map + MLX5_EQ_DOORBEL_OFFSET; 385 384 386 385 err = mlx5_debug_eq_add(dev, eq); 387 386 if (err)
+2 -2
drivers/net/ethernet/mellanox/mlx5/core/main.c
··· 864 864 dev->profile = &profile[prof_sel]; 865 865 dev->event = mlx5_core_event; 866 866 867 + INIT_LIST_HEAD(&priv->ctx_list); 868 + spin_lock_init(&priv->ctx_lock); 867 869 err = mlx5_dev_init(dev, pdev); 868 870 if (err) { 869 871 dev_err(&pdev->dev, "mlx5_dev_init failed %d\n", err); 870 872 goto out; 871 873 } 872 874 873 - INIT_LIST_HEAD(&priv->ctx_list); 874 - spin_lock_init(&priv->ctx_lock); 875 875 err = mlx5_register_device(dev); 876 876 if (err) { 877 877 dev_err(&pdev->dev, "mlx5_register_device failed %d\n", err);
+2 -1
drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
··· 2762 2762 if (test_bit(__NX_RESETTING, &adapter->state)) 2763 2763 goto reschedule; 2764 2764 2765 - if (test_bit(__NX_DEV_UP, &adapter->state)) { 2765 + if (test_bit(__NX_DEV_UP, &adapter->state) && 2766 + !(adapter->capabilities & NX_FW_CAPABILITY_LINK_NOTIFICATION)) { 2766 2767 if (!adapter->has_link_events) { 2767 2768 2768 2769 netxen_nic_handle_phy_intr(adapter);
+1 -2
drivers/net/ethernet/qualcomm/Kconfig
··· 5 5 config NET_VENDOR_QUALCOMM 6 6 bool "Qualcomm devices" 7 7 default y 8 - depends on SPI_MASTER && OF_GPIO 9 8 ---help--- 10 9 If you have a network (Ethernet) card belonging to this class, say Y 11 10 and read the Ethernet-HOWTO, available from ··· 19 20 20 21 config QCA7000 21 22 tristate "Qualcomm Atheros QCA7000 support" 22 - depends on SPI_MASTER && OF_GPIO 23 + depends on SPI_MASTER && OF 23 24 ---help--- 24 25 This SPI protocol driver supports the Qualcomm Atheros QCA7000. 25 26
+2 -1
drivers/net/ethernet/sfc/ef10.c
··· 180 180 EFX_MAX_CHANNELS, 181 181 resource_size(&efx->pci_dev->resource[EFX_MEM_BAR]) / 182 182 (EFX_VI_PAGE_SIZE * EFX_TXQ_TYPES)); 183 - BUG_ON(efx->max_channels == 0); 183 + if (WARN_ON(efx->max_channels == 0)) 184 + return -EIO; 184 185 185 186 nic_data = kzalloc(sizeof(*nic_data), GFP_KERNEL); 186 187 if (!nic_data)
+12 -8
drivers/net/ethernet/smsc/smc91x.c
··· 2243 2243 const struct of_device_id *match = NULL; 2244 2244 struct smc_local *lp; 2245 2245 struct net_device *ndev; 2246 - struct resource *res, *ires; 2246 + struct resource *res; 2247 2247 unsigned int __iomem *addr; 2248 2248 unsigned long irq_flags = SMC_IRQ_FLAGS; 2249 + unsigned long irq_resflags; 2249 2250 int ret; 2250 2251 2251 2252 ndev = alloc_etherdev(sizeof(struct smc_local)); ··· 2338 2337 goto out_free_netdev; 2339 2338 } 2340 2339 2341 - ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 2342 - if (!ires) { 2340 + ndev->irq = platform_get_irq(pdev, 0); 2341 + if (ndev->irq <= 0) { 2343 2342 ret = -ENODEV; 2344 2343 goto out_release_io; 2345 2344 } 2346 - 2347 - ndev->irq = ires->start; 2348 - 2349 - if (irq_flags == -1 || ires->flags & IRQF_TRIGGER_MASK) 2350 - irq_flags = ires->flags & IRQF_TRIGGER_MASK; 2345 + /* 2346 + * If this platform does not specify any special irqflags, or if 2347 + * the resource supplies a trigger, override the irqflags with 2348 + * the trigger flags from the resource. 2349 + */ 2350 + irq_resflags = irqd_get_trigger_type(irq_get_irq_data(ndev->irq)); 2351 + if (irq_flags == -1 || irq_resflags & IRQF_TRIGGER_MASK) 2352 + irq_flags = irq_resflags & IRQF_TRIGGER_MASK; 2351 2353 2352 2354 ret = smc_request_attrib(pdev, ndev); 2353 2355 if (ret)
+50 -11
drivers/net/ethernet/smsc/smsc911x.c
··· 1342 1342 spin_unlock(&pdata->mac_lock); 1343 1343 } 1344 1344 1345 + static int smsc911x_phy_general_power_up(struct smsc911x_data *pdata) 1346 + { 1347 + int rc = 0; 1348 + 1349 + if (!pdata->phy_dev) 1350 + return rc; 1351 + 1352 + /* If the internal PHY is in General Power-Down mode, all, except the 1353 + * management interface, is powered-down and stays in that condition as 1354 + * long as Phy register bit 0.11 is HIGH. 1355 + * 1356 + * In that case, clear the bit 0.11, so the PHY powers up and we can 1357 + * access to the phy registers. 1358 + */ 1359 + rc = phy_read(pdata->phy_dev, MII_BMCR); 1360 + if (rc < 0) { 1361 + SMSC_WARN(pdata, drv, "Failed reading PHY control reg"); 1362 + return rc; 1363 + } 1364 + 1365 + /* If the PHY general power-down bit is not set is not necessary to 1366 + * disable the general power down-mode. 1367 + */ 1368 + if (rc & BMCR_PDOWN) { 1369 + rc = phy_write(pdata->phy_dev, MII_BMCR, rc & ~BMCR_PDOWN); 1370 + if (rc < 0) { 1371 + SMSC_WARN(pdata, drv, "Failed writing PHY control reg"); 1372 + return rc; 1373 + } 1374 + 1375 + usleep_range(1000, 1500); 1376 + } 1377 + 1378 + return 0; 1379 + } 1380 + 1345 1381 static int smsc911x_phy_disable_energy_detect(struct smsc911x_data *pdata) 1346 1382 { 1347 1383 int rc = 0; ··· 1392 1356 return rc; 1393 1357 } 1394 1358 1395 - /* 1396 - * If energy is detected the PHY is already awake so is not necessary 1397 - * to disable the energy detect power-down mode. 1398 - */ 1399 - if ((rc & MII_LAN83C185_EDPWRDOWN) && 1400 - !(rc & MII_LAN83C185_ENERGYON)) { 1359 + /* Only disable if energy detect mode is already enabled */ 1360 + if (rc & MII_LAN83C185_EDPWRDOWN) { 1401 1361 /* Disable energy detect mode for this SMSC Transceivers */ 1402 1362 rc = phy_write(pdata->phy_dev, MII_LAN83C185_CTRL_STATUS, 1403 1363 rc & (~MII_LAN83C185_EDPWRDOWN)); ··· 1402 1370 SMSC_WARN(pdata, drv, "Failed writing PHY control reg"); 1403 1371 return rc; 1404 1372 } 1405 - 1406 - mdelay(1); 1373 + /* Allow PHY to wakeup */ 1374 + mdelay(2); 1407 1375 } 1408 1376 1409 1377 return 0; ··· 1425 1393 1426 1394 /* Only enable if energy detect mode is already disabled */ 1427 1395 if (!(rc & MII_LAN83C185_EDPWRDOWN)) { 1428 - mdelay(100); 1429 1396 /* Enable energy detect mode for this SMSC Transceivers */ 1430 1397 rc = phy_write(pdata->phy_dev, MII_LAN83C185_CTRL_STATUS, 1431 1398 rc | MII_LAN83C185_EDPWRDOWN); ··· 1433 1402 SMSC_WARN(pdata, drv, "Failed writing PHY control reg"); 1434 1403 return rc; 1435 1404 } 1436 - 1437 - mdelay(1); 1438 1405 } 1439 1406 return 0; 1440 1407 } ··· 1442 1413 unsigned int timeout; 1443 1414 unsigned int temp; 1444 1415 int ret; 1416 + 1417 + /* 1418 + * Make sure to power-up the PHY chip before doing a reset, otherwise 1419 + * the reset fails. 1420 + */ 1421 + ret = smsc911x_phy_general_power_up(pdata); 1422 + if (ret) { 1423 + SMSC_WARN(pdata, drv, "Failed to power-up the PHY chip"); 1424 + return ret; 1425 + } 1445 1426 1446 1427 /* 1447 1428 * LAN9210/LAN9211/LAN9220/LAN9221 chips have an internal PHY that
+29 -23
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 276 276 bool stmmac_eee_init(struct stmmac_priv *priv) 277 277 { 278 278 char *phy_bus_name = priv->plat->phy_bus_name; 279 + unsigned long flags; 279 280 bool ret = false; 280 281 281 282 /* Using PCS we cannot dial with the phy registers at this stage ··· 301 300 * changed). 302 301 * In that case the driver disable own timers. 303 302 */ 303 + spin_lock_irqsave(&priv->lock, flags); 304 304 if (priv->eee_active) { 305 305 pr_debug("stmmac: disable EEE\n"); 306 306 del_timer_sync(&priv->eee_ctrl_timer); ··· 309 307 tx_lpi_timer); 310 308 } 311 309 priv->eee_active = 0; 310 + spin_unlock_irqrestore(&priv->lock, flags); 312 311 goto out; 313 312 } 314 313 /* Activate the EEE and start timers */ 314 + spin_lock_irqsave(&priv->lock, flags); 315 315 if (!priv->eee_active) { 316 316 priv->eee_active = 1; 317 317 init_timer(&priv->eee_ctrl_timer); ··· 329 325 /* Set HW EEE according to the speed */ 330 326 priv->hw->mac->set_eee_pls(priv->hw, priv->phydev->link); 331 327 332 - pr_debug("stmmac: Energy-Efficient Ethernet initialized\n"); 333 - 334 328 ret = true; 329 + spin_unlock_irqrestore(&priv->lock, flags); 330 + 331 + pr_debug("stmmac: Energy-Efficient Ethernet initialized\n"); 335 332 } 336 333 out: 337 334 return ret; ··· 765 760 if (new_state && netif_msg_link(priv)) 766 761 phy_print_status(phydev); 767 762 763 + spin_unlock_irqrestore(&priv->lock, flags); 764 + 768 765 /* At this stage, it could be needed to setup the EEE or adjust some 769 766 * MAC related HW registers. 770 767 */ 771 768 priv->eee_enabled = stmmac_eee_init(priv); 772 - 773 - spin_unlock_irqrestore(&priv->lock, flags); 774 769 } 775 770 776 771 /** ··· 964 959 } 965 960 966 961 static int stmmac_init_rx_buffers(struct stmmac_priv *priv, struct dma_desc *p, 967 - int i) 962 + int i, gfp_t flags) 968 963 { 969 964 struct sk_buff *skb; 970 965 971 966 skb = __netdev_alloc_skb(priv->dev, priv->dma_buf_sz + NET_IP_ALIGN, 972 - GFP_KERNEL); 967 + flags); 973 968 if (!skb) { 974 969 pr_err("%s: Rx init fails; skb is NULL\n", __func__); 975 970 return -ENOMEM; ··· 1011 1006 * and allocates the socket buffers. It suppors the chained and ring 1012 1007 * modes. 1013 1008 */ 1014 - static int init_dma_desc_rings(struct net_device *dev) 1009 + static int init_dma_desc_rings(struct net_device *dev, gfp_t flags) 1015 1010 { 1016 1011 int i; 1017 1012 struct stmmac_priv *priv = netdev_priv(dev); ··· 1046 1041 else 1047 1042 p = priv->dma_rx + i; 1048 1043 1049 - ret = stmmac_init_rx_buffers(priv, p, i); 1044 + ret = stmmac_init_rx_buffers(priv, p, i, flags); 1050 1045 if (ret) 1051 1046 goto err_init_rx_buffers; 1052 1047 ··· 1652 1647 struct stmmac_priv *priv = netdev_priv(dev); 1653 1648 int ret; 1654 1649 1655 - ret = init_dma_desc_rings(dev); 1656 - if (ret < 0) { 1657 - pr_err("%s: DMA descriptors initialization failed\n", __func__); 1658 - return ret; 1659 - } 1660 1650 /* DMA initialization and SW reset */ 1661 1651 ret = stmmac_init_dma_engine(priv); 1662 1652 if (ret < 0) { ··· 1705 1705 } 1706 1706 priv->tx_lpi_timer = STMMAC_DEFAULT_TWT_LS; 1707 1707 1708 - priv->eee_enabled = stmmac_eee_init(priv); 1709 - 1710 - stmmac_init_tx_coalesce(priv); 1711 - 1712 1708 if ((priv->use_riwt) && (priv->hw->dma->rx_watchdog)) { 1713 1709 priv->rx_riwt = MAX_DMA_RIWT; 1714 1710 priv->hw->dma->rx_watchdog(priv->ioaddr, MAX_DMA_RIWT); ··· 1757 1761 goto dma_desc_error; 1758 1762 } 1759 1763 1764 + ret = init_dma_desc_rings(dev, GFP_KERNEL); 1765 + if (ret < 0) { 1766 + pr_err("%s: DMA descriptors initialization failed\n", __func__); 1767 + goto init_error; 1768 + } 1769 + 1760 1770 ret = stmmac_hw_setup(dev); 1761 1771 if (ret < 0) { 1762 1772 pr_err("%s: Hw setup failed\n", __func__); 1763 1773 goto init_error; 1764 1774 } 1775 + 1776 + stmmac_init_tx_coalesce(priv); 1765 1777 1766 1778 if (priv->phydev) 1767 1779 phy_start(priv->phydev); ··· 1898 1894 unsigned int nopaged_len = skb_headlen(skb); 1899 1895 unsigned int enh_desc = priv->plat->enh_desc; 1900 1896 1897 + spin_lock(&priv->tx_lock); 1898 + 1901 1899 if (unlikely(stmmac_tx_avail(priv) < nfrags + 1)) { 1900 + spin_unlock(&priv->tx_lock); 1902 1901 if (!netif_queue_stopped(dev)) { 1903 1902 netif_stop_queue(dev); 1904 1903 /* This is a hard error, log it. */ ··· 1909 1902 } 1910 1903 return NETDEV_TX_BUSY; 1911 1904 } 1912 - 1913 - spin_lock(&priv->tx_lock); 1914 1905 1915 1906 if (priv->tx_path_in_lpi_mode) 1916 1907 stmmac_disable_eee_mode(priv); ··· 2030 2025 return NETDEV_TX_OK; 2031 2026 2032 2027 dma_map_err: 2028 + spin_unlock(&priv->tx_lock); 2033 2029 dev_err(priv->device, "Tx dma map failed\n"); 2034 2030 dev_kfree_skb(skb); 2035 2031 priv->dev->stats.tx_dropped++; ··· 2287 2281 { 2288 2282 struct stmmac_priv *priv = netdev_priv(dev); 2289 2283 2290 - spin_lock(&priv->lock); 2291 2284 priv->hw->mac->set_filter(priv->hw, dev); 2292 - spin_unlock(&priv->lock); 2293 2285 } 2294 2286 2295 2287 /** ··· 2954 2950 stmmac_set_mac(priv->ioaddr, false); 2955 2951 pinctrl_pm_select_sleep_state(priv->device); 2956 2952 /* Disable clock in case of PWM is off */ 2957 - clk_disable_unprepare(priv->stmmac_clk); 2953 + clk_disable(priv->stmmac_clk); 2958 2954 } 2959 2955 spin_unlock_irqrestore(&priv->lock, flags); 2960 2956 ··· 2986 2982 } else { 2987 2983 pinctrl_pm_select_default_state(priv->device); 2988 2984 /* enable the clk prevously disabled */ 2989 - clk_prepare_enable(priv->stmmac_clk); 2985 + clk_enable(priv->stmmac_clk); 2990 2986 /* reset the phy so that it's ready */ 2991 2987 if (priv->mii) 2992 2988 stmmac_mdio_reset(priv->mii); ··· 2994 2990 2995 2991 netif_device_attach(ndev); 2996 2992 2993 + init_dma_desc_rings(ndev, GFP_ATOMIC); 2997 2994 stmmac_hw_setup(ndev); 2995 + stmmac_init_tx_coalesce(priv); 2998 2996 2999 2997 napi_enable(&priv->napi); 3000 2998
+57 -5
drivers/net/ethernet/sun/sunhme.c
··· 1262 1262 HMD(("init rxring, ")); 1263 1263 for (i = 0; i < RX_RING_SIZE; i++) { 1264 1264 struct sk_buff *skb; 1265 + u32 mapping; 1265 1266 1266 1267 skb = happy_meal_alloc_skb(RX_BUF_ALLOC_SIZE, GFP_ATOMIC); 1267 1268 if (!skb) { ··· 1273 1272 1274 1273 /* Because we reserve afterwards. */ 1275 1274 skb_put(skb, (ETH_FRAME_LEN + RX_OFFSET + 4)); 1275 + mapping = dma_map_single(hp->dma_dev, skb->data, RX_BUF_ALLOC_SIZE, 1276 + DMA_FROM_DEVICE); 1277 + if (dma_mapping_error(hp->dma_dev, mapping)) { 1278 + dev_kfree_skb_any(skb); 1279 + hme_write_rxd(hp, &hb->happy_meal_rxd[i], 0, 0); 1280 + continue; 1281 + } 1276 1282 hme_write_rxd(hp, &hb->happy_meal_rxd[i], 1277 1283 (RXFLAG_OWN | ((RX_BUF_ALLOC_SIZE - RX_OFFSET) << 16)), 1278 - dma_map_single(hp->dma_dev, skb->data, RX_BUF_ALLOC_SIZE, 1279 - DMA_FROM_DEVICE)); 1284 + mapping); 1280 1285 skb_reserve(skb, RX_OFFSET); 1281 1286 } 1282 1287 ··· 2027 2020 skb = hp->rx_skbs[elem]; 2028 2021 if (len > RX_COPY_THRESHOLD) { 2029 2022 struct sk_buff *new_skb; 2023 + u32 mapping; 2030 2024 2031 2025 /* Now refill the entry, if we can. */ 2032 2026 new_skb = happy_meal_alloc_skb(RX_BUF_ALLOC_SIZE, GFP_ATOMIC); ··· 2035 2027 drops++; 2036 2028 goto drop_it; 2037 2029 } 2030 + skb_put(new_skb, (ETH_FRAME_LEN + RX_OFFSET + 4)); 2031 + mapping = dma_map_single(hp->dma_dev, new_skb->data, 2032 + RX_BUF_ALLOC_SIZE, 2033 + DMA_FROM_DEVICE); 2034 + if (unlikely(dma_mapping_error(hp->dma_dev, mapping))) { 2035 + dev_kfree_skb_any(new_skb); 2036 + drops++; 2037 + goto drop_it; 2038 + } 2039 + 2038 2040 dma_unmap_single(hp->dma_dev, dma_addr, RX_BUF_ALLOC_SIZE, DMA_FROM_DEVICE); 2039 2041 hp->rx_skbs[elem] = new_skb; 2040 - skb_put(new_skb, (ETH_FRAME_LEN + RX_OFFSET + 4)); 2041 2042 hme_write_rxd(hp, this, 2042 2043 (RXFLAG_OWN|((RX_BUF_ALLOC_SIZE-RX_OFFSET)<<16)), 2043 - dma_map_single(hp->dma_dev, new_skb->data, RX_BUF_ALLOC_SIZE, 2044 - DMA_FROM_DEVICE)); 2044 + mapping); 2045 2045 skb_reserve(new_skb, RX_OFFSET); 2046 2046 2047 2047 /* Trim the original skb for the netif. */ ··· 2264 2248 netif_wake_queue(dev); 2265 2249 } 2266 2250 2251 + static void unmap_partial_tx_skb(struct happy_meal *hp, u32 first_mapping, 2252 + u32 first_len, u32 first_entry, u32 entry) 2253 + { 2254 + struct happy_meal_txd *txbase = &hp->happy_block->happy_meal_txd[0]; 2255 + 2256 + dma_unmap_single(hp->dma_dev, first_mapping, first_len, DMA_TO_DEVICE); 2257 + 2258 + first_entry = NEXT_TX(first_entry); 2259 + while (first_entry != entry) { 2260 + struct happy_meal_txd *this = &txbase[first_entry]; 2261 + u32 addr, len; 2262 + 2263 + addr = hme_read_desc32(hp, &this->tx_addr); 2264 + len = hme_read_desc32(hp, &this->tx_flags); 2265 + len &= TXFLAG_SIZE; 2266 + dma_unmap_page(hp->dma_dev, addr, len, DMA_TO_DEVICE); 2267 + } 2268 + } 2269 + 2267 2270 static netdev_tx_t happy_meal_start_xmit(struct sk_buff *skb, 2268 2271 struct net_device *dev) 2269 2272 { ··· 2319 2284 2320 2285 len = skb->len; 2321 2286 mapping = dma_map_single(hp->dma_dev, skb->data, len, DMA_TO_DEVICE); 2287 + if (unlikely(dma_mapping_error(hp->dma_dev, mapping))) 2288 + goto out_dma_error; 2322 2289 tx_flags |= (TXFLAG_SOP | TXFLAG_EOP); 2323 2290 hme_write_txd(hp, &hp->happy_block->happy_meal_txd[entry], 2324 2291 (tx_flags | (len & TXFLAG_SIZE)), ··· 2336 2299 first_len = skb_headlen(skb); 2337 2300 first_mapping = dma_map_single(hp->dma_dev, skb->data, first_len, 2338 2301 DMA_TO_DEVICE); 2302 + if (unlikely(dma_mapping_error(hp->dma_dev, first_mapping))) 2303 + goto out_dma_error; 2339 2304 entry = NEXT_TX(entry); 2340 2305 2341 2306 for (frag = 0; frag < skb_shinfo(skb)->nr_frags; frag++) { ··· 2347 2308 len = skb_frag_size(this_frag); 2348 2309 mapping = skb_frag_dma_map(hp->dma_dev, this_frag, 2349 2310 0, len, DMA_TO_DEVICE); 2311 + if (unlikely(dma_mapping_error(hp->dma_dev, mapping))) { 2312 + unmap_partial_tx_skb(hp, first_mapping, first_len, 2313 + first_entry, entry); 2314 + goto out_dma_error; 2315 + } 2350 2316 this_txflags = tx_flags; 2351 2317 if (frag == skb_shinfo(skb)->nr_frags - 1) 2352 2318 this_txflags |= TXFLAG_EOP; ··· 2376 2332 spin_unlock_irq(&hp->happy_lock); 2377 2333 2378 2334 tx_add_log(hp, TXLOG_ACTION_TXMIT, 0); 2335 + return NETDEV_TX_OK; 2336 + 2337 + out_dma_error: 2338 + hp->tx_skbs[hp->tx_new] = NULL; 2339 + spin_unlock_irq(&hp->happy_lock); 2340 + 2341 + dev_kfree_skb_any(skb); 2342 + dev->stats.tx_dropped++; 2379 2343 return NETDEV_TX_OK; 2380 2344 } 2381 2345
-1
drivers/net/ethernet/ti/cpsw_ale.c
··· 785 785 { 786 786 if (!ale) 787 787 return -EINVAL; 788 - cpsw_ale_stop(ale); 789 788 cpsw_ale_control_set(ale, 0, ALE_ENABLE, 0); 790 789 kfree(ale); 791 790 return 0;
+1 -1
drivers/net/ethernet/ti/cpts.c
··· 264 264 265 265 switch (ptp_class & PTP_CLASS_PMASK) { 266 266 case PTP_CLASS_IPV4: 267 - offset += ETH_HLEN + IPV4_HLEN(data) + UDP_HLEN; 267 + offset += ETH_HLEN + IPV4_HLEN(data + offset) + UDP_HLEN; 268 268 break; 269 269 case PTP_CLASS_IPV6: 270 270 offset += ETH_HLEN + IP6_HLEN + UDP_HLEN;
+2
drivers/net/macvtap.c
··· 629 629 if (skb->ip_summed == CHECKSUM_PARTIAL) { 630 630 vnet_hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM; 631 631 vnet_hdr->csum_start = skb_checksum_start_offset(skb); 632 + if (vlan_tx_tag_present(skb)) 633 + vnet_hdr->csum_start += VLAN_HLEN; 632 634 vnet_hdr->csum_offset = skb->csum_offset; 633 635 } else if (skb->ip_summed == CHECKSUM_UNNECESSARY) { 634 636 vnet_hdr->flags = VIRTIO_NET_HDR_F_DATA_VALID;
+2 -2
drivers/net/phy/dp83640.c
··· 791 791 792 792 switch (type & PTP_CLASS_PMASK) { 793 793 case PTP_CLASS_IPV4: 794 - offset += ETH_HLEN + IPV4_HLEN(data) + UDP_HLEN; 794 + offset += ETH_HLEN + IPV4_HLEN(data + offset) + UDP_HLEN; 795 795 break; 796 796 case PTP_CLASS_IPV6: 797 797 offset += ETH_HLEN + IP6_HLEN + UDP_HLEN; ··· 934 934 935 935 switch (type & PTP_CLASS_PMASK) { 936 936 case PTP_CLASS_IPV4: 937 - offset += ETH_HLEN + IPV4_HLEN(data) + UDP_HLEN; 937 + offset += ETH_HLEN + IPV4_HLEN(data + offset) + UDP_HLEN; 938 938 break; 939 939 case PTP_CLASS_IPV6: 940 940 offset += ETH_HLEN + IP6_HLEN + UDP_HLEN;
+24 -12
drivers/net/phy/phy.c
··· 352 352 { 353 353 struct mii_ioctl_data *mii_data = if_mii(ifr); 354 354 u16 val = mii_data->val_in; 355 + bool change_autoneg = false; 355 356 356 357 switch (cmd) { 357 358 case SIOCGMIIPHY: ··· 368 367 if (mii_data->phy_id == phydev->addr) { 369 368 switch (mii_data->reg_num) { 370 369 case MII_BMCR: 371 - if ((val & (BMCR_RESET | BMCR_ANENABLE)) == 0) 370 + if ((val & (BMCR_RESET | BMCR_ANENABLE)) == 0) { 371 + if (phydev->autoneg == AUTONEG_ENABLE) 372 + change_autoneg = true; 372 373 phydev->autoneg = AUTONEG_DISABLE; 373 - else 374 + if (val & BMCR_FULLDPLX) 375 + phydev->duplex = DUPLEX_FULL; 376 + else 377 + phydev->duplex = DUPLEX_HALF; 378 + if (val & BMCR_SPEED1000) 379 + phydev->speed = SPEED_1000; 380 + else if (val & BMCR_SPEED100) 381 + phydev->speed = SPEED_100; 382 + else phydev->speed = SPEED_10; 383 + } 384 + else { 385 + if (phydev->autoneg == AUTONEG_DISABLE) 386 + change_autoneg = true; 374 387 phydev->autoneg = AUTONEG_ENABLE; 375 - if (!phydev->autoneg && (val & BMCR_FULLDPLX)) 376 - phydev->duplex = DUPLEX_FULL; 377 - else 378 - phydev->duplex = DUPLEX_HALF; 379 - if (!phydev->autoneg && (val & BMCR_SPEED1000)) 380 - phydev->speed = SPEED_1000; 381 - else if (!phydev->autoneg && 382 - (val & BMCR_SPEED100)) 383 - phydev->speed = SPEED_100; 388 + } 384 389 break; 385 390 case MII_ADVERTISE: 386 - phydev->advertising = val; 391 + phydev->advertising = mii_adv_to_ethtool_adv_t(val); 392 + change_autoneg = true; 387 393 break; 388 394 default: 389 395 /* do nothing */ ··· 404 396 if (mii_data->reg_num == MII_BMCR && 405 397 val & BMCR_RESET) 406 398 return phy_init_hw(phydev); 399 + 400 + if (change_autoneg) 401 + return phy_start_aneg(phydev); 402 + 407 403 return 0; 408 404 409 405 case SIOCSHWTSTAMP:
+20 -20
drivers/net/ppp/ppp_generic.c
··· 755 755 756 756 err = get_filter(argp, &code); 757 757 if (err >= 0) { 758 + struct bpf_prog *pass_filter = NULL; 758 759 struct sock_fprog_kern fprog = { 759 760 .len = err, 760 761 .filter = code, 761 762 }; 762 763 763 - ppp_lock(ppp); 764 - if (ppp->pass_filter) { 765 - bpf_prog_destroy(ppp->pass_filter); 766 - ppp->pass_filter = NULL; 764 + err = 0; 765 + if (fprog.filter) 766 + err = bpf_prog_create(&pass_filter, &fprog); 767 + if (!err) { 768 + ppp_lock(ppp); 769 + if (ppp->pass_filter) 770 + bpf_prog_destroy(ppp->pass_filter); 771 + ppp->pass_filter = pass_filter; 772 + ppp_unlock(ppp); 767 773 } 768 - if (fprog.filter != NULL) 769 - err = bpf_prog_create(&ppp->pass_filter, 770 - &fprog); 771 - else 772 - err = 0; 773 774 kfree(code); 774 - ppp_unlock(ppp); 775 775 } 776 776 break; 777 777 } ··· 781 781 782 782 err = get_filter(argp, &code); 783 783 if (err >= 0) { 784 + struct bpf_prog *active_filter = NULL; 784 785 struct sock_fprog_kern fprog = { 785 786 .len = err, 786 787 .filter = code, 787 788 }; 788 789 789 - ppp_lock(ppp); 790 - if (ppp->active_filter) { 791 - bpf_prog_destroy(ppp->active_filter); 792 - ppp->active_filter = NULL; 790 + err = 0; 791 + if (fprog.filter) 792 + err = bpf_prog_create(&active_filter, &fprog); 793 + if (!err) { 794 + ppp_lock(ppp); 795 + if (ppp->active_filter) 796 + bpf_prog_destroy(ppp->active_filter); 797 + ppp->active_filter = active_filter; 798 + ppp_unlock(ppp); 793 799 } 794 - if (fprog.filter != NULL) 795 - err = bpf_prog_create(&ppp->active_filter, 796 - &fprog); 797 - else 798 - err = 0; 799 800 kfree(code); 800 - ppp_unlock(ppp); 801 801 } 802 802 break; 803 803 }
+17 -11
drivers/net/tun.c
··· 1235 1235 struct tun_pi pi = { 0, skb->protocol }; 1236 1236 ssize_t total = 0; 1237 1237 int vlan_offset = 0, copied; 1238 + int vlan_hlen = 0; 1239 + int vnet_hdr_sz = 0; 1240 + 1241 + if (vlan_tx_tag_present(skb)) 1242 + vlan_hlen = VLAN_HLEN; 1243 + 1244 + if (tun->flags & TUN_VNET_HDR) 1245 + vnet_hdr_sz = tun->vnet_hdr_sz; 1238 1246 1239 1247 if (!(tun->flags & TUN_NO_PI)) { 1240 1248 if ((len -= sizeof(pi)) < 0) 1241 1249 return -EINVAL; 1242 1250 1243 - if (len < skb->len) { 1251 + if (len < skb->len + vlan_hlen + vnet_hdr_sz) { 1244 1252 /* Packet will be striped */ 1245 1253 pi.flags |= TUN_PKT_STRIP; 1246 1254 } ··· 1258 1250 total += sizeof(pi); 1259 1251 } 1260 1252 1261 - if (tun->flags & TUN_VNET_HDR) { 1253 + if (vnet_hdr_sz) { 1262 1254 struct virtio_net_hdr gso = { 0 }; /* no info leak */ 1263 - if ((len -= tun->vnet_hdr_sz) < 0) 1255 + if ((len -= vnet_hdr_sz) < 0) 1264 1256 return -EINVAL; 1265 1257 1266 1258 if (skb_is_gso(skb)) { ··· 1292 1284 1293 1285 if (skb->ip_summed == CHECKSUM_PARTIAL) { 1294 1286 gso.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM; 1295 - gso.csum_start = skb_checksum_start_offset(skb); 1287 + gso.csum_start = skb_checksum_start_offset(skb) + 1288 + vlan_hlen; 1296 1289 gso.csum_offset = skb->csum_offset; 1297 1290 } else if (skb->ip_summed == CHECKSUM_UNNECESSARY) { 1298 1291 gso.flags = VIRTIO_NET_HDR_F_DATA_VALID; ··· 1302 1293 if (unlikely(memcpy_toiovecend(iv, (void *)&gso, total, 1303 1294 sizeof(gso)))) 1304 1295 return -EFAULT; 1305 - total += tun->vnet_hdr_sz; 1296 + total += vnet_hdr_sz; 1306 1297 } 1307 1298 1308 1299 copied = total; 1309 - total += skb->len; 1310 - if (!vlan_tx_tag_present(skb)) { 1311 - len = min_t(int, skb->len, len); 1312 - } else { 1300 + len = min_t(int, skb->len + vlan_hlen, len); 1301 + total += skb->len + vlan_hlen; 1302 + if (vlan_hlen) { 1313 1303 int copy, ret; 1314 1304 struct { 1315 1305 __be16 h_vlan_proto; ··· 1319 1311 veth.h_vlan_TCI = htons(vlan_tx_tag_get(skb)); 1320 1312 1321 1313 vlan_offset = offsetof(struct vlan_ethhdr, h_vlan_proto); 1322 - len = min_t(int, skb->len + VLAN_HLEN, len); 1323 - total += VLAN_HLEN; 1324 1314 1325 1315 copy = min_t(int, vlan_offset, len); 1326 1316 ret = skb_copy_datagram_const_iovec(skb, 0, iv, copied, copy);
+1 -13
drivers/net/usb/asix_devices.c
··· 465 465 return ret; 466 466 } 467 467 468 - ret = asix_sw_reset(dev, AX_SWRESET_IPPD | AX_SWRESET_PRL); 469 - if (ret < 0) 470 - return ret; 471 - 472 - msleep(150); 473 - 474 - ret = asix_sw_reset(dev, AX_SWRESET_CLEAR); 475 - if (ret < 0) 476 - return ret; 477 - 478 - msleep(150); 479 - 480 - ret = asix_sw_reset(dev, embd_phy ? AX_SWRESET_IPRL : AX_SWRESET_PRTE); 468 + ax88772_reset(dev); 481 469 482 470 /* Read PHYID register *AFTER* the PHY was reset properly */ 483 471 phyid = asix_get_phyid(dev);
+21 -10
drivers/net/vxlan.c
··· 275 275 return list_first_entry(&fdb->remotes, struct vxlan_rdst, list); 276 276 } 277 277 278 - /* Find VXLAN socket based on network namespace and UDP port */ 279 - static struct vxlan_sock *vxlan_find_sock(struct net *net, __be16 port) 278 + /* Find VXLAN socket based on network namespace, address family and UDP port */ 279 + static struct vxlan_sock *vxlan_find_sock(struct net *net, 280 + sa_family_t family, __be16 port) 280 281 { 281 282 struct vxlan_sock *vs; 282 283 283 284 hlist_for_each_entry_rcu(vs, vs_head(net, port), hlist) { 284 - if (inet_sk(vs->sock->sk)->inet_sport == port) 285 + if (inet_sk(vs->sock->sk)->inet_sport == port && 286 + inet_sk(vs->sock->sk)->sk.sk_family == family) 285 287 return vs; 286 288 } 287 289 return NULL; ··· 302 300 } 303 301 304 302 /* Look up VNI in a per net namespace table */ 305 - static struct vxlan_dev *vxlan_find_vni(struct net *net, u32 id, __be16 port) 303 + static struct vxlan_dev *vxlan_find_vni(struct net *net, u32 id, 304 + sa_family_t family, __be16 port) 306 305 { 307 306 struct vxlan_sock *vs; 308 307 309 - vs = vxlan_find_sock(net, port); 308 + vs = vxlan_find_sock(net, family, port); 310 309 if (!vs) 311 310 return NULL; 312 311 ··· 623 620 __be16 type; 624 621 int vxlan_len = sizeof(struct vxlanhdr) + sizeof(struct ethhdr); 625 622 int err = -ENOSYS; 623 + 624 + udp_tunnel_gro_complete(skb, nhoff); 626 625 627 626 eh = (struct ethhdr *)(skb->data + nhoff + sizeof(struct vxlanhdr)); 628 627 type = eh->h_proto; ··· 1776 1771 struct vxlan_dev *dst_vxlan; 1777 1772 1778 1773 ip_rt_put(rt); 1779 - dst_vxlan = vxlan_find_vni(vxlan->net, vni, dst_port); 1774 + dst_vxlan = vxlan_find_vni(vxlan->net, vni, 1775 + dst->sa.sa_family, dst_port); 1780 1776 if (!dst_vxlan) 1781 1777 goto tx_error; 1782 1778 vxlan_encap_bypass(skb, vxlan, dst_vxlan); ··· 1831 1825 struct vxlan_dev *dst_vxlan; 1832 1826 1833 1827 dst_release(ndst); 1834 - dst_vxlan = vxlan_find_vni(vxlan->net, vni, dst_port); 1828 + dst_vxlan = vxlan_find_vni(vxlan->net, vni, 1829 + dst->sa.sa_family, dst_port); 1835 1830 if (!dst_vxlan) 1836 1831 goto tx_error; 1837 1832 vxlan_encap_bypass(skb, vxlan, dst_vxlan); ··· 1992 1985 struct vxlan_dev *vxlan = netdev_priv(dev); 1993 1986 struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id); 1994 1987 struct vxlan_sock *vs; 1988 + bool ipv6 = vxlan->flags & VXLAN_F_IPV6; 1995 1989 1996 1990 dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); 1997 1991 if (!dev->tstats) 1998 1992 return -ENOMEM; 1999 1993 2000 1994 spin_lock(&vn->sock_lock); 2001 - vs = vxlan_find_sock(vxlan->net, vxlan->dst_port); 1995 + vs = vxlan_find_sock(vxlan->net, ipv6 ? AF_INET6 : AF_INET, 1996 + vxlan->dst_port); 2002 1997 if (vs) { 2003 1998 /* If we have a socket with same port already, reuse it */ 2004 1999 atomic_inc(&vs->refcnt); ··· 2391 2382 { 2392 2383 struct vxlan_net *vn = net_generic(net, vxlan_net_id); 2393 2384 struct vxlan_sock *vs; 2385 + bool ipv6 = flags & VXLAN_F_IPV6; 2394 2386 2395 2387 vs = vxlan_socket_create(net, port, rcv, data, flags); 2396 2388 if (!IS_ERR(vs)) ··· 2401 2391 return vs; 2402 2392 2403 2393 spin_lock(&vn->sock_lock); 2404 - vs = vxlan_find_sock(net, port); 2394 + vs = vxlan_find_sock(net, ipv6 ? AF_INET6 : AF_INET, port); 2405 2395 if (vs) { 2406 2396 if (vs->rcv == rcv) 2407 2397 atomic_inc(&vs->refcnt); ··· 2560 2550 nla_get_u8(data[IFLA_VXLAN_UDP_ZERO_CSUM6_RX])) 2561 2551 vxlan->flags |= VXLAN_F_UDP_ZERO_CSUM6_RX; 2562 2552 2563 - if (vxlan_find_vni(net, vni, vxlan->dst_port)) { 2553 + if (vxlan_find_vni(net, vni, use_ipv6 ? AF_INET6 : AF_INET, 2554 + vxlan->dst_port)) { 2564 2555 pr_info("duplicate VNI %u\n", vni); 2565 2556 return -EEXIST; 2566 2557 }
+9 -1
drivers/net/wireless/iwlwifi/mvm/fw.c
··· 284 284 285 285 lockdep_assert_held(&mvm->mutex); 286 286 287 - if (WARN_ON_ONCE(mvm->init_ucode_complete)) 287 + if (WARN_ON_ONCE(mvm->init_ucode_complete || mvm->calibrating)) 288 288 return 0; 289 289 290 290 iwl_init_notification_wait(&mvm->notif_wait, ··· 334 334 goto out; 335 335 } 336 336 337 + mvm->calibrating = true; 338 + 337 339 /* Send TX valid antennas before triggering calibrations */ 338 340 ret = iwl_send_tx_ant_cfg(mvm, mvm->fw->valid_tx_ant); 339 341 if (ret) ··· 360 358 MVM_UCODE_CALIB_TIMEOUT); 361 359 if (!ret) 362 360 mvm->init_ucode_complete = true; 361 + 362 + if (ret && iwl_mvm_is_radio_killed(mvm)) { 363 + IWL_DEBUG_RF_KILL(mvm, "RFKILL while calibrating.\n"); 364 + ret = 1; 365 + } 363 366 goto out; 364 367 365 368 error: 366 369 iwl_remove_notification(&mvm->notif_wait, &calib_wait); 367 370 out: 371 + mvm->calibrating = false; 368 372 if (iwlmvm_mod_params.init_dbg && !mvm->nvm_data) { 369 373 /* we want to debug INIT and we have no NVM - fake */ 370 374 mvm->nvm_data = kzalloc(sizeof(struct iwl_nvm_data) +
+1
drivers/net/wireless/iwlwifi/mvm/mac80211.c
··· 788 788 789 789 mvm->scan_status = IWL_MVM_SCAN_NONE; 790 790 mvm->ps_disabled = false; 791 + mvm->calibrating = false; 791 792 792 793 /* just in case one was running */ 793 794 ieee80211_remain_on_channel_expired(mvm->hw);
+1
drivers/net/wireless/iwlwifi/mvm/mvm.h
··· 548 548 enum iwl_ucode_type cur_ucode; 549 549 bool ucode_loaded; 550 550 bool init_ucode_complete; 551 + bool calibrating; 551 552 u32 error_event_table; 552 553 u32 log_event_table; 553 554 u32 umac_error_event_table;
+11 -1
drivers/net/wireless/iwlwifi/mvm/ops.c
··· 424 424 } 425 425 mvm->sf_state = SF_UNINIT; 426 426 mvm->low_latency_agg_frame_limit = 6; 427 + mvm->cur_ucode = IWL_UCODE_INIT; 427 428 428 429 mutex_init(&mvm->mutex); 429 430 mutex_init(&mvm->d0i3_suspend_mutex); ··· 753 752 static bool iwl_mvm_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state) 754 753 { 755 754 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); 755 + bool calibrating = ACCESS_ONCE(mvm->calibrating); 756 756 757 757 if (state) 758 758 set_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status); ··· 762 760 763 761 wiphy_rfkill_set_hw_state(mvm->hw->wiphy, iwl_mvm_is_radio_killed(mvm)); 764 762 765 - return state && mvm->cur_ucode != IWL_UCODE_INIT; 763 + /* iwl_run_init_mvm_ucode is waiting for results, abort it */ 764 + if (calibrating) 765 + iwl_abort_notification_waits(&mvm->notif_wait); 766 + 767 + /* 768 + * Stop the device if we run OPERATIONAL firmware or if we are in the 769 + * middle of the calibrations. 770 + */ 771 + return state && (mvm->cur_ucode != IWL_UCODE_INIT || calibrating); 766 772 } 767 773 768 774 static void iwl_mvm_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb)
+2 -2
drivers/net/wireless/iwlwifi/pcie/trans.c
··· 915 915 * restart. So don't process again if the device is 916 916 * already dead. 917 917 */ 918 - if (test_bit(STATUS_DEVICE_ENABLED, &trans->status)) { 918 + if (test_and_clear_bit(STATUS_DEVICE_ENABLED, &trans->status)) { 919 + IWL_DEBUG_INFO(trans, "DEVICE_ENABLED bit was set and is now cleared\n"); 919 920 iwl_pcie_tx_stop(trans); 920 921 iwl_pcie_rx_stop(trans); 921 922 ··· 946 945 /* clear all status bits */ 947 946 clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status); 948 947 clear_bit(STATUS_INT_ENABLED, &trans->status); 949 - clear_bit(STATUS_DEVICE_ENABLED, &trans->status); 950 948 clear_bit(STATUS_TPOWER_PMI, &trans->status); 951 949 clear_bit(STATUS_RFKILL, &trans->status); 952 950
+3 -1
drivers/net/wireless/mac80211_hwsim.c
··· 1987 1987 if (err != 0) { 1988 1988 printk(KERN_DEBUG "mac80211_hwsim: device_bind_driver failed (%d)\n", 1989 1989 err); 1990 - goto failed_hw; 1990 + goto failed_bind; 1991 1991 } 1992 1992 1993 1993 skb_queue_head_init(&data->pending); ··· 2183 2183 return idx; 2184 2184 2185 2185 failed_hw: 2186 + device_release_driver(data->dev); 2187 + failed_bind: 2186 2188 device_unregister(data->dev); 2187 2189 failed_drvdata: 2188 2190 ieee80211_free_hw(hw);
+1 -1
include/linux/socket.h
··· 256 256 #define MSG_EOF MSG_FIN 257 257 258 258 #define MSG_FASTOPEN 0x20000000 /* Send data in TCP SYN */ 259 - #define MSG_CMSG_CLOEXEC 0x40000000 /* Set close_on_exit for file 259 + #define MSG_CMSG_CLOEXEC 0x40000000 /* Set close_on_exec for file 260 260 descriptor received through 261 261 SCM_RIGHTS */ 262 262 #if defined(CONFIG_COMPAT)
-1
include/net/9p/transport.h
··· 34 34 * @list: used to maintain a list of currently available transports 35 35 * @name: the human-readable name of the transport 36 36 * @maxsize: transport provided maximum packet size 37 - * @pref: Preferences of this transport 38 37 * @def: set if this transport should be considered the default 39 38 * @create: member function to create a new connection on this transport 40 39 * @close: member function to discard a connection on this transport
+9
include/net/udp_tunnel.h
··· 100 100 return iptunnel_handle_offloads(skb, udp_csum, type); 101 101 } 102 102 103 + static inline void udp_tunnel_gro_complete(struct sk_buff *skb, int nhoff) 104 + { 105 + struct udphdr *uh; 106 + 107 + uh = (struct udphdr *)(skb->data + nhoff - sizeof(struct udphdr)); 108 + skb_shinfo(skb)->gso_type |= uh->check ? 109 + SKB_GSO_UDP_TUNNEL_CSUM : SKB_GSO_UDP_TUNNEL; 110 + } 111 + 103 112 static inline void udp_tunnel_encap_enable(struct socket *sock) 104 113 { 105 114 #if IS_ENABLED(CONFIG_IPV6)
+4
include/uapi/linux/Kbuild
··· 125 125 header-y += firewire-cdev.h 126 126 header-y += firewire-constants.h 127 127 header-y += flat.h 128 + header-y += fou.h 128 129 header-y += fs.h 129 130 header-y += fsl_hypervisor.h 130 131 header-y += fuse.h ··· 142 141 header-y += hiddev.h 143 142 header-y += hidraw.h 144 143 header-y += hpet.h 144 + header-y += hsr_netlink.h 145 145 header-y += hyperv.h 146 146 header-y += hysdn_if.h 147 147 header-y += i2c-dev.h ··· 253 251 header-y += minix_fs.h 254 252 header-y += mman.h 255 253 header-y += mmtimer.h 254 + header-y += mpls.h 256 255 header-y += mqueue.h 257 256 header-y += mroute.h 258 257 header-y += mroute6.h ··· 427 424 header-y += virtio_pci.h 428 425 header-y += virtio_ring.h 429 426 header-y += virtio_rng.h 427 + header=y += vm_sockets.h 430 428 header-y += vt.h 431 429 header-y += wait.h 432 430 header-y += wanrouter.h
+1
include/uapi/linux/if_bridge.h
··· 15 15 16 16 #include <linux/types.h> 17 17 #include <linux/if_ether.h> 18 + #include <linux/in6.h> 18 19 19 20 #define SYSFS_BRIDGE_ATTR "bridge" 20 21 #define SYSFS_BRIDGE_FDB "brforward"
+5 -5
lib/rhashtable.c
··· 230 230 ht->shift++; 231 231 232 232 /* For each new bucket, search the corresponding old bucket 233 - * for the first entry that hashes to the new bucket, and 233 + * for the first entry that hashes to the new bucket, and 234 234 * link the new bucket to that entry. Since all the entries 235 235 * which will end up in the new bucket appear in the same 236 236 * old bucket, this constructs an entirely valid new hash ··· 248 248 } 249 249 250 250 /* Publish the new table pointer. Lookups may now traverse 251 - * the new table, but they will not benefit from any 252 - * additional efficiency until later steps unzip the buckets. 251 + * the new table, but they will not benefit from any 252 + * additional efficiency until later steps unzip the buckets. 253 253 */ 254 254 rcu_assign_pointer(ht->tbl, new_tbl); 255 255 ··· 306 306 307 307 ht->shift--; 308 308 309 - /* Link each bucket in the new table to the first bucket 309 + /* Link each bucket in the new table to the first bucket 310 310 * in the old table that contains entries which will hash 311 311 * to the new bucket. 312 312 */ 313 313 for (i = 0; i < ntbl->size; i++) { 314 314 ntbl->buckets[i] = tbl->buckets[i]; 315 315 316 - /* Link each bucket in the new table to the first bucket 316 + /* Link each bucket in the new table to the first bucket 317 317 * in the old table that contains entries which will hash 318 318 * to the new bucket. 319 319 */
+1
net/bridge/netfilter/nft_reject_bridge.c
··· 18 18 #include <net/netfilter/ipv6/nf_reject.h> 19 19 #include <linux/ip.h> 20 20 #include <net/ip.h> 21 + #include <net/ip6_checksum.h> 21 22 #include <linux/netfilter_bridge.h> 22 23 #include "../br_private.h" 23 24
+5 -2
net/dsa/slave.c
··· 489 489 /* We could not connect to a designated PHY, so use the switch internal 490 490 * MDIO bus instead 491 491 */ 492 - if (!p->phy) 492 + if (!p->phy) { 493 493 p->phy = ds->slave_mii_bus->phy_map[p->port]; 494 - else 494 + phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link, 495 + p->phy_interface); 496 + } else { 495 497 pr_info("attached PHY at address %d [%s]\n", 496 498 p->phy->addr, p->phy->drv->name); 499 + } 497 500 } 498 501 499 502 int dsa_slave_suspend(struct net_device *slave_dev)
+2
net/ipv4/fou.c
··· 133 133 int err = -ENOSYS; 134 134 const struct net_offload **offloads; 135 135 136 + udp_tunnel_gro_complete(skb, nhoff); 137 + 136 138 rcu_read_lock(); 137 139 offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads; 138 140 ops = rcu_dereference(offloads[proto]);
+3
net/ipv4/geneve.c
··· 144 144 gnvh = (struct genevehdr *)__skb_push(skb, sizeof(*gnvh) + opt_len); 145 145 geneve_build_header(gnvh, tun_flags, vni, opt_len, opt); 146 146 147 + skb_set_inner_protocol(skb, htons(ETH_P_TEB)); 148 + 147 149 return udp_tunnel_xmit_skb(gs->sock, rt, skb, src, dst, 148 150 tos, ttl, df, src_port, dst_port, xnet); 149 151 } ··· 366 364 static void __exit geneve_cleanup_module(void) 367 365 { 368 366 destroy_workqueue(geneve_wq); 367 + unregister_pernet_subsys(&geneve_net_ops); 369 368 } 370 369 module_exit(geneve_cleanup_module); 371 370
+1 -1
net/ipv4/ip_sockglue.c
··· 195 195 for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) { 196 196 if (!CMSG_OK(msg, cmsg)) 197 197 return -EINVAL; 198 - #if defined(CONFIG_IPV6) 198 + #if IS_ENABLED(CONFIG_IPV6) 199 199 if (allow_ipv6 && 200 200 cmsg->cmsg_level == SOL_IPV6 && 201 201 cmsg->cmsg_type == IPV6_PKTINFO) {
+31 -29
net/ipv4/tcp_input.c
··· 2315 2315 2316 2316 /* Undo procedures. */ 2317 2317 2318 + /* We can clear retrans_stamp when there are no retransmissions in the 2319 + * window. It would seem that it is trivially available for us in 2320 + * tp->retrans_out, however, that kind of assumptions doesn't consider 2321 + * what will happen if errors occur when sending retransmission for the 2322 + * second time. ...It could the that such segment has only 2323 + * TCPCB_EVER_RETRANS set at the present time. It seems that checking 2324 + * the head skb is enough except for some reneging corner cases that 2325 + * are not worth the effort. 2326 + * 2327 + * Main reason for all this complexity is the fact that connection dying 2328 + * time now depends on the validity of the retrans_stamp, in particular, 2329 + * that successive retransmissions of a segment must not advance 2330 + * retrans_stamp under any conditions. 2331 + */ 2332 + static bool tcp_any_retrans_done(const struct sock *sk) 2333 + { 2334 + const struct tcp_sock *tp = tcp_sk(sk); 2335 + struct sk_buff *skb; 2336 + 2337 + if (tp->retrans_out) 2338 + return true; 2339 + 2340 + skb = tcp_write_queue_head(sk); 2341 + if (unlikely(skb && TCP_SKB_CB(skb)->sacked & TCPCB_EVER_RETRANS)) 2342 + return true; 2343 + 2344 + return false; 2345 + } 2346 + 2318 2347 #if FASTRETRANS_DEBUG > 1 2319 2348 static void DBGUNDO(struct sock *sk, const char *msg) 2320 2349 { ··· 2439 2410 * is ACKed. For Reno it is MUST to prevent false 2440 2411 * fast retransmits (RFC2582). SACK TCP is safe. */ 2441 2412 tcp_moderate_cwnd(tp); 2413 + if (!tcp_any_retrans_done(sk)) 2414 + tp->retrans_stamp = 0; 2442 2415 return true; 2443 2416 } 2444 2417 tcp_set_ca_state(sk, TCP_CA_Open); ··· 2458 2427 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPDSACKUNDO); 2459 2428 return true; 2460 2429 } 2461 - return false; 2462 - } 2463 - 2464 - /* We can clear retrans_stamp when there are no retransmissions in the 2465 - * window. It would seem that it is trivially available for us in 2466 - * tp->retrans_out, however, that kind of assumptions doesn't consider 2467 - * what will happen if errors occur when sending retransmission for the 2468 - * second time. ...It could the that such segment has only 2469 - * TCPCB_EVER_RETRANS set at the present time. It seems that checking 2470 - * the head skb is enough except for some reneging corner cases that 2471 - * are not worth the effort. 2472 - * 2473 - * Main reason for all this complexity is the fact that connection dying 2474 - * time now depends on the validity of the retrans_stamp, in particular, 2475 - * that successive retransmissions of a segment must not advance 2476 - * retrans_stamp under any conditions. 2477 - */ 2478 - static bool tcp_any_retrans_done(const struct sock *sk) 2479 - { 2480 - const struct tcp_sock *tp = tcp_sk(sk); 2481 - struct sk_buff *skb; 2482 - 2483 - if (tp->retrans_out) 2484 - return true; 2485 - 2486 - skb = tcp_write_queue_head(sk); 2487 - if (unlikely(skb && TCP_SKB_CB(skb)->sacked & TCPCB_EVER_RETRANS)) 2488 - return true; 2489 - 2490 2430 return false; 2491 2431 } 2492 2432
+3 -2
net/ipv6/ip6_gre.c
··· 961 961 else 962 962 dev->flags &= ~IFF_POINTOPOINT; 963 963 964 - dev->iflink = p->link; 965 - 966 964 /* Precalculate GRE options length */ 967 965 if (t->parms.o_flags&(GRE_CSUM|GRE_KEY|GRE_SEQ)) { 968 966 if (t->parms.o_flags&GRE_CSUM) ··· 1270 1272 u64_stats_init(&ip6gre_tunnel_stats->syncp); 1271 1273 } 1272 1274 1275 + dev->iflink = tunnel->parms.link; 1273 1276 1274 1277 return 0; 1275 1278 } ··· 1479 1480 dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); 1480 1481 if (!dev->tstats) 1481 1482 return -ENOMEM; 1483 + 1484 + dev->iflink = tunnel->parms.link; 1482 1485 1483 1486 return 0; 1484 1487 }
+1 -9
net/ipv6/ip6_tunnel.c
··· 272 272 int err; 273 273 274 274 t = netdev_priv(dev); 275 - err = ip6_tnl_dev_init(dev); 276 - if (err < 0) 277 - goto out; 278 275 279 276 err = register_netdevice(dev); 280 277 if (err < 0) ··· 1459 1462 1460 1463 1461 1464 static const struct net_device_ops ip6_tnl_netdev_ops = { 1465 + .ndo_init = ip6_tnl_dev_init, 1462 1466 .ndo_uninit = ip6_tnl_dev_uninit, 1463 1467 .ndo_start_xmit = ip6_tnl_xmit, 1464 1468 .ndo_do_ioctl = ip6_tnl_ioctl, ··· 1544 1546 struct ip6_tnl *t = netdev_priv(dev); 1545 1547 struct net *net = dev_net(dev); 1546 1548 struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); 1547 - int err = ip6_tnl_dev_init_gen(dev); 1548 - 1549 - if (err) 1550 - return err; 1551 1549 1552 1550 t->parms.proto = IPPROTO_IPV6; 1553 1551 dev_hold(dev); 1554 - 1555 - ip6_tnl_link_config(t); 1556 1552 1557 1553 rcu_assign_pointer(ip6n->tnls_wc[0], t); 1558 1554 return 0;
+1 -10
net/ipv6/ip6_vti.c
··· 172 172 struct vti6_net *ip6n = net_generic(net, vti6_net_id); 173 173 int err; 174 174 175 - err = vti6_dev_init(dev); 176 - if (err < 0) 177 - goto out; 178 - 179 175 err = register_netdevice(dev); 180 176 if (err < 0) 181 177 goto out; ··· 779 783 } 780 784 781 785 static const struct net_device_ops vti6_netdev_ops = { 786 + .ndo_init = vti6_dev_init, 782 787 .ndo_uninit = vti6_dev_uninit, 783 788 .ndo_start_xmit = vti6_tnl_xmit, 784 789 .ndo_do_ioctl = vti6_ioctl, ··· 849 852 struct ip6_tnl *t = netdev_priv(dev); 850 853 struct net *net = dev_net(dev); 851 854 struct vti6_net *ip6n = net_generic(net, vti6_net_id); 852 - int err = vti6_dev_init_gen(dev); 853 - 854 - if (err) 855 - return err; 856 855 857 856 t->parms.proto = IPPROTO_IPV6; 858 857 dev_hold(dev); 859 - 860 - vti6_link_config(t); 861 858 862 859 rcu_assign_pointer(ip6n->tnls_wc[0], t); 863 860 return 0;
+6 -9
net/ipv6/sit.c
··· 195 195 struct sit_net *sitn = net_generic(net, sit_net_id); 196 196 int err; 197 197 198 - err = ipip6_tunnel_init(dev); 199 - if (err < 0) 200 - goto out; 201 - ipip6_tunnel_clone_6rd(dev, sitn); 198 + memcpy(dev->dev_addr, &t->parms.iph.saddr, 4); 199 + memcpy(dev->broadcast, &t->parms.iph.daddr, 4); 202 200 203 201 if ((__force u16)t->parms.i_flags & SIT_ISATAP) 204 202 dev->priv_flags |= IFF_ISATAP; ··· 205 207 if (err < 0) 206 208 goto out; 207 209 208 - strcpy(t->parms.name, dev->name); 210 + ipip6_tunnel_clone_6rd(dev, sitn); 211 + 209 212 dev->rtnl_link_ops = &sit_link_ops; 210 213 211 214 dev_hold(dev); ··· 1329 1330 } 1330 1331 1331 1332 static const struct net_device_ops ipip6_netdev_ops = { 1333 + .ndo_init = ipip6_tunnel_init, 1332 1334 .ndo_uninit = ipip6_tunnel_uninit, 1333 1335 .ndo_start_xmit = sit_tunnel_xmit, 1334 1336 .ndo_do_ioctl = ipip6_tunnel_ioctl, ··· 1378 1378 1379 1379 tunnel->dev = dev; 1380 1380 tunnel->net = dev_net(dev); 1381 - 1382 - memcpy(dev->dev_addr, &tunnel->parms.iph.saddr, 4); 1383 - memcpy(dev->broadcast, &tunnel->parms.iph.daddr, 4); 1381 + strcpy(tunnel->parms.name, dev->name); 1384 1382 1385 1383 ipip6_tunnel_bind_dev(dev); 1386 1384 dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); ··· 1403 1405 1404 1406 tunnel->dev = dev; 1405 1407 tunnel->net = dev_net(dev); 1406 - strcpy(tunnel->parms.name, dev->name); 1407 1408 1408 1409 iph->version = 4; 1409 1410 iph->protocol = IPPROTO_IPV6;
+1 -1
net/mac80211/ibss.c
··· 805 805 806 806 memset(&params, 0, sizeof(params)); 807 807 memset(&csa_ie, 0, sizeof(csa_ie)); 808 - err = ieee80211_parse_ch_switch_ie(sdata, elems, beacon, 808 + err = ieee80211_parse_ch_switch_ie(sdata, elems, 809 809 ifibss->chandef.chan->band, 810 810 sta_flags, ifibss->bssid, &csa_ie); 811 811 /* can't switch to destination channel, fail */
+1 -2
net/mac80211/ieee80211_i.h
··· 1642 1642 * ieee80211_parse_ch_switch_ie - parses channel switch IEs 1643 1643 * @sdata: the sdata of the interface which has received the frame 1644 1644 * @elems: parsed 802.11 elements received with the frame 1645 - * @beacon: indicates if the frame was a beacon or probe response 1646 1645 * @current_band: indicates the current band 1647 1646 * @sta_flags: contains information about own capabilities and restrictions 1648 1647 * to decide which channel switch announcements can be accepted. Only the ··· 1655 1656 * Return: 0 on success, <0 on error and >0 if there is nothing to parse. 1656 1657 */ 1657 1658 int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata, 1658 - struct ieee802_11_elems *elems, bool beacon, 1659 + struct ieee802_11_elems *elems, 1659 1660 enum ieee80211_band current_band, 1660 1661 u32 sta_flags, u8 *bssid, 1661 1662 struct ieee80211_csa_ie *csa_ie);
+12 -6
net/mac80211/iface.c
··· 766 766 int i, flushed; 767 767 struct ps_data *ps; 768 768 struct cfg80211_chan_def chandef; 769 + bool cancel_scan; 769 770 770 771 clear_bit(SDATA_STATE_RUNNING, &sdata->state); 771 772 772 - if (rcu_access_pointer(local->scan_sdata) == sdata) 773 + cancel_scan = rcu_access_pointer(local->scan_sdata) == sdata; 774 + if (cancel_scan) 773 775 ieee80211_scan_cancel(local); 774 776 775 777 /* ··· 900 898 list_del(&sdata->u.vlan.list); 901 899 mutex_unlock(&local->mtx); 902 900 RCU_INIT_POINTER(sdata->vif.chanctx_conf, NULL); 901 + /* see comment in the default case below */ 902 + ieee80211_free_keys(sdata, true); 903 903 /* no need to tell driver */ 904 904 break; 905 905 case NL80211_IFTYPE_MONITOR: ··· 927 923 /* 928 924 * When we get here, the interface is marked down. 929 925 * Free the remaining keys, if there are any 930 - * (shouldn't be, except maybe in WDS mode?) 926 + * (which can happen in AP mode if userspace sets 927 + * keys before the interface is operating, and maybe 928 + * also in WDS mode) 931 929 * 932 930 * Force the key freeing to always synchronize_net() 933 931 * to wait for the RX path in case it is using this 934 - * interface enqueuing frames * at this very time on 932 + * interface enqueuing frames at this very time on 935 933 * another CPU. 936 934 */ 937 935 ieee80211_free_keys(sdata, true); 938 - 939 - /* fall through */ 940 - case NL80211_IFTYPE_AP: 941 936 skb_queue_purge(&sdata->skb_queue); 942 937 } 943 938 ··· 993 990 } 994 991 995 992 ieee80211_recalc_ps(local, -1); 993 + 994 + if (cancel_scan) 995 + flush_delayed_work(&local->scan_work); 996 996 997 997 if (local->open_count == 0) { 998 998 ieee80211_stop_device(local);
+1 -1
net/mac80211/mesh.c
··· 874 874 875 875 memset(&params, 0, sizeof(params)); 876 876 memset(&csa_ie, 0, sizeof(csa_ie)); 877 - err = ieee80211_parse_ch_switch_ie(sdata, elems, beacon, band, 877 + err = ieee80211_parse_ch_switch_ie(sdata, elems, band, 878 878 sta_flags, sdata->vif.addr, 879 879 &csa_ie); 880 880 if (err < 0)
+3 -2
net/mac80211/mlme.c
··· 1072 1072 1073 1073 current_band = cbss->channel->band; 1074 1074 memset(&csa_ie, 0, sizeof(csa_ie)); 1075 - res = ieee80211_parse_ch_switch_ie(sdata, elems, beacon, current_band, 1075 + res = ieee80211_parse_ch_switch_ie(sdata, elems, current_band, 1076 1076 ifmgd->flags, 1077 1077 ifmgd->associated->bssid, &csa_ie); 1078 1078 if (res < 0) ··· 1168 1168 ieee80211_queue_work(&local->hw, &ifmgd->chswitch_work); 1169 1169 else 1170 1170 mod_timer(&ifmgd->chswitch_timer, 1171 - TU_TO_EXP_TIME(csa_ie.count * cbss->beacon_interval)); 1171 + TU_TO_EXP_TIME((csa_ie.count - 1) * 1172 + cbss->beacon_interval)); 1172 1173 } 1173 1174 1174 1175 static bool
+7 -7
net/mac80211/rx.c
··· 1678 1678 sc = le16_to_cpu(hdr->seq_ctrl); 1679 1679 frag = sc & IEEE80211_SCTL_FRAG; 1680 1680 1681 - if (likely((!ieee80211_has_morefrags(fc) && frag == 0) || 1682 - is_multicast_ether_addr(hdr->addr1))) { 1683 - /* not fragmented */ 1681 + if (likely(!ieee80211_has_morefrags(fc) && frag == 0)) 1682 + goto out; 1683 + 1684 + if (is_multicast_ether_addr(hdr->addr1)) { 1685 + rx->local->dot11MulticastReceivedFrameCount++; 1684 1686 goto out; 1685 1687 } 1688 + 1686 1689 I802_DEBUG_INC(rx->local->rx_handlers_fragments); 1687 1690 1688 1691 if (skb_linearize(rx->skb)) ··· 1778 1775 out: 1779 1776 if (rx->sta) 1780 1777 rx->sta->rx_packets++; 1781 - if (is_multicast_ether_addr(hdr->addr1)) 1782 - rx->local->dot11MulticastReceivedFrameCount++; 1783 - else 1784 - ieee80211_led_rx(rx->local); 1778 + ieee80211_led_rx(rx->local); 1785 1779 return RX_CONTINUE; 1786 1780 } 1787 1781
+6 -12
net/mac80211/spectmgmt.c
··· 22 22 #include "wme.h" 23 23 24 24 int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata, 25 - struct ieee802_11_elems *elems, bool beacon, 25 + struct ieee802_11_elems *elems, 26 26 enum ieee80211_band current_band, 27 27 u32 sta_flags, u8 *bssid, 28 28 struct ieee80211_csa_ie *csa_ie) ··· 91 91 return -EINVAL; 92 92 } 93 93 94 - if (!beacon && sec_chan_offs) { 94 + if (sec_chan_offs) { 95 95 secondary_channel_offset = sec_chan_offs->sec_chan_offs; 96 - } else if (beacon && ht_oper) { 97 - secondary_channel_offset = 98 - ht_oper->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET; 99 96 } else if (!(sta_flags & IEEE80211_STA_DISABLE_HT)) { 100 - /* If it's not a beacon, HT is enabled and the IE not present, 101 - * it's 20 MHz, 802.11-2012 8.5.2.6: 102 - * This element [the Secondary Channel Offset Element] is 103 - * present when switching to a 40 MHz channel. It may be 104 - * present when switching to a 20 MHz channel (in which 105 - * case the secondary channel offset is set to SCN). 106 - */ 97 + /* If the secondary channel offset IE is not present, 98 + * we can't know what's the post-CSA offset, so the 99 + * best we can do is use 20MHz. 100 + */ 107 101 secondary_channel_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE; 108 102 } 109 103
+3 -2
net/netlink/af_netlink.c
··· 1440 1440 return; 1441 1441 1442 1442 for (undo = 0; undo < group; undo++) 1443 - if (test_bit(group, &groups)) 1443 + if (test_bit(undo, &groups)) 1444 1444 nlk->netlink_unbind(undo); 1445 1445 } 1446 1446 ··· 1492 1492 netlink_insert(sk, net, nladdr->nl_pid) : 1493 1493 netlink_autobind(sock); 1494 1494 if (err) { 1495 - netlink_unbind(nlk->ngroups - 1, groups, nlk); 1495 + netlink_unbind(nlk->ngroups, groups, nlk); 1496 1496 return err; 1497 1497 } 1498 1498 } ··· 2509 2509 nl_table[unit].module = module; 2510 2510 if (cfg) { 2511 2511 nl_table[unit].bind = cfg->bind; 2512 + nl_table[unit].unbind = cfg->unbind; 2512 2513 nl_table[unit].flags = cfg->flags; 2513 2514 if (cfg->compare) 2514 2515 nl_table[unit].compare = cfg->compare;
-2
net/sctp/auth.c
··· 862 862 list_add(&cur_key->key_list, sh_keys); 863 863 864 864 cur_key->key = key; 865 - sctp_auth_key_hold(key); 866 - 867 865 return 0; 868 866 nomem: 869 867 if (!replace)
+3
net/sctp/sm_make_chunk.c
··· 2609 2609 addr_param = param.v + sizeof(sctp_addip_param_t); 2610 2610 2611 2611 af = sctp_get_af_specific(param_type2af(param.p->type)); 2612 + if (af == NULL) 2613 + break; 2614 + 2612 2615 af->from_addr_param(&addr, addr_param, 2613 2616 htons(asoc->peer.port), 0); 2614 2617
+1 -1
tools/testing/selftests/net/psock_fanout.c
··· 128 128 struct tpacket2_hdr *header = ring; 129 129 int count = 0; 130 130 131 - while (header->tp_status & TP_STATUS_USER && count < RING_NUM_FRAMES) { 131 + while (count < RING_NUM_FRAMES && header->tp_status & TP_STATUS_USER) { 132 132 count++; 133 133 header = ring + (count * getpagesize()); 134 134 }