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) Missing device reference in IPSEC input path results in crashes
during device unregistration. From Subash Abhinov Kasiviswanathan.

2) Per-queue ISR register writes not being done properly in macb
driver, from Cyrille Pitchen.

3) Stats accounting bugs in bcmgenet, from Patri Gynther.

4) Lightweight tunnel's TTL and TOS were swapped in netlink dumps, from
Quentin Armitage.

5) SXGBE driver has off-by-one in probe error paths, from Rasmus
Villemoes.

6) Fix race in save/swap/delete options in netfilter ipset, from
Vishwanath Pai.

7) Ageing time of bridge not set properly when not operating over a
switchdev device. Fix from Haishuang Yan.

8) Fix GRO regression wrt nested FOU/GUE based tunnels, from Alexander
Duyck.

9) IPV6 UDP code bumps wrong stats, from Eric Dumazet.

10) FEC driver should only access registers that actually exist on the
given chipset, fix from Fabio Estevam.

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (73 commits)
net: mvneta: fix changing MTU when using per-cpu processing
stmmac: fix MDIO settings
Revert "stmmac: Fix 'eth0: No PHY found' regression"
stmmac: fix TX normal DESC
net: mvneta: use cache_line_size() to get cacheline size
net: mvpp2: use cache_line_size() to get cacheline size
net: mvpp2: fix maybe-uninitialized warning
tun, bpf: fix suspicious RCU usage in tun_{attach, detach}_filter
net: usb: cdc_ncm: adding Telit LE910 V2 mobile broadband card
rtnl: fix msg size calculation in if_nlmsg_size()
fec: Do not access unexisting register in Coldfire
net: mvneta: replace MVNETA_CPU_D_CACHE_LINE_SIZE with L1_CACHE_BYTES
net: mvpp2: replace MVPP2_CPU_D_CACHE_LINE_SIZE with L1_CACHE_BYTES
net: dsa: mv88e6xxx: Clear the PDOWN bit on setup
net: dsa: mv88e6xxx: Introduce _mv88e6xxx_phy_page_{read, write}
bpf: make padding in bpf_tunnel_key explicit
ipv6: udp: fix UDP_MIB_IGNOREDMULTI updates
bnxt_en: Fix ethtool -a reporting.
bnxt_en: Fix typo in bnxt_hwrm_set_pause_common().
bnxt_en: Implement proper firmware message padding.
...

+826 -612
+1 -1
Documentation/networking/switchdev.txt
··· 386 386 memory allocation, etc. The goal is to handle the stuff that is not unlikely 387 387 to fail here. The second phase is to "commit" the actual changes. 388 388 389 - Switchdev provides an inftrastructure for sharing items (for example memory 389 + Switchdev provides an infrastructure for sharing items (for example memory 390 390 allocations) between the two phases. 391 391 392 392 The object created by a driver in "prepare" phase and it is queued up by:
+10 -5
drivers/isdn/hisax/isac.c
··· 215 215 if (count == 0) 216 216 count = 32; 217 217 isac_empty_fifo(cs, count); 218 - if ((count = cs->rcvidx) > 0) { 218 + count = cs->rcvidx; 219 + if (count > 0) { 219 220 cs->rcvidx = 0; 220 - if (!(skb = alloc_skb(count, GFP_ATOMIC))) 221 + skb = alloc_skb(count, GFP_ATOMIC); 222 + if (!skb) 221 223 printk(KERN_WARNING "HiSax: D receive out of memory\n"); 222 224 else { 223 225 memcpy(skb_put(skb, count), cs->rcvbuf, count); ··· 253 251 cs->tx_skb = NULL; 254 252 } 255 253 } 256 - if ((cs->tx_skb = skb_dequeue(&cs->sq))) { 254 + cs->tx_skb = skb_dequeue(&cs->sq); 255 + if (cs->tx_skb) { 257 256 cs->tx_cnt = 0; 258 257 isac_fill_fifo(cs); 259 258 } else ··· 316 313 #if ARCOFI_USE 317 314 if (v1 & 0x08) { 318 315 if (!cs->dc.isac.mon_rx) { 319 - if (!(cs->dc.isac.mon_rx = kmalloc(MAX_MON_FRAME, GFP_ATOMIC))) { 316 + cs->dc.isac.mon_rx = kmalloc(MAX_MON_FRAME, GFP_ATOMIC); 317 + if (!cs->dc.isac.mon_rx) { 320 318 if (cs->debug & L1_DEB_WARN) 321 319 debugl1(cs, "ISAC MON RX out of memory!"); 322 320 cs->dc.isac.mocr &= 0xf0; ··· 347 343 afterMONR0: 348 344 if (v1 & 0x80) { 349 345 if (!cs->dc.isac.mon_rx) { 350 - if (!(cs->dc.isac.mon_rx = kmalloc(MAX_MON_FRAME, GFP_ATOMIC))) { 346 + cs->dc.isac.mon_rx = kmalloc(MAX_MON_FRAME, GFP_ATOMIC); 347 + if (!cs->dc.isac.mon_rx) { 351 348 if (cs->debug & L1_DEB_WARN) 352 349 debugl1(cs, "ISAC MON RX out of memory!"); 353 350 cs->dc.isac.mocr &= 0x0f;
+72 -13
drivers/net/dsa/mv88e6xxx.c
··· 2264 2264 mutex_unlock(&ps->smi_mutex); 2265 2265 } 2266 2266 2267 + static int _mv88e6xxx_phy_page_write(struct dsa_switch *ds, int port, int page, 2268 + int reg, int val) 2269 + { 2270 + int ret; 2271 + 2272 + ret = _mv88e6xxx_phy_write_indirect(ds, port, 0x16, page); 2273 + if (ret < 0) 2274 + goto restore_page_0; 2275 + 2276 + ret = _mv88e6xxx_phy_write_indirect(ds, port, reg, val); 2277 + restore_page_0: 2278 + _mv88e6xxx_phy_write_indirect(ds, port, 0x16, 0x0); 2279 + 2280 + return ret; 2281 + } 2282 + 2283 + static int _mv88e6xxx_phy_page_read(struct dsa_switch *ds, int port, int page, 2284 + int reg) 2285 + { 2286 + int ret; 2287 + 2288 + ret = _mv88e6xxx_phy_write_indirect(ds, port, 0x16, page); 2289 + if (ret < 0) 2290 + goto restore_page_0; 2291 + 2292 + ret = _mv88e6xxx_phy_read_indirect(ds, port, reg); 2293 + restore_page_0: 2294 + _mv88e6xxx_phy_write_indirect(ds, port, 0x16, 0x0); 2295 + 2296 + return ret; 2297 + } 2298 + 2299 + static int mv88e6xxx_power_on_serdes(struct dsa_switch *ds) 2300 + { 2301 + int ret; 2302 + 2303 + ret = _mv88e6xxx_phy_page_read(ds, REG_FIBER_SERDES, PAGE_FIBER_SERDES, 2304 + MII_BMCR); 2305 + if (ret < 0) 2306 + return ret; 2307 + 2308 + if (ret & BMCR_PDOWN) { 2309 + ret &= ~BMCR_PDOWN; 2310 + ret = _mv88e6xxx_phy_page_write(ds, REG_FIBER_SERDES, 2311 + PAGE_FIBER_SERDES, MII_BMCR, 2312 + ret); 2313 + } 2314 + 2315 + return ret; 2316 + } 2317 + 2267 2318 static int mv88e6xxx_setup_port(struct dsa_switch *ds, int port) 2268 2319 { 2269 2320 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); ··· 2416 2365 PORT_CONTROL, reg); 2417 2366 if (ret) 2418 2367 goto abort; 2368 + } 2369 + 2370 + /* If this port is connected to a SerDes, make sure the SerDes is not 2371 + * powered down. 2372 + */ 2373 + if (mv88e6xxx_6352_family(ds)) { 2374 + ret = _mv88e6xxx_reg_read(ds, REG_PORT(port), PORT_STATUS); 2375 + if (ret < 0) 2376 + goto abort; 2377 + ret &= PORT_STATUS_CMODE_MASK; 2378 + if ((ret == PORT_STATUS_CMODE_100BASE_X) || 2379 + (ret == PORT_STATUS_CMODE_1000BASE_X) || 2380 + (ret == PORT_STATUS_CMODE_SGMII)) { 2381 + ret = mv88e6xxx_power_on_serdes(ds); 2382 + if (ret < 0) 2383 + goto abort; 2384 + } 2419 2385 } 2420 2386 2421 2387 /* Port Control 2: don't force a good FCS, set the maximum frame size to ··· 2782 2714 int ret; 2783 2715 2784 2716 mutex_lock(&ps->smi_mutex); 2785 - ret = _mv88e6xxx_phy_write_indirect(ds, port, 0x16, page); 2786 - if (ret < 0) 2787 - goto error; 2788 - ret = _mv88e6xxx_phy_read_indirect(ds, port, reg); 2789 - error: 2790 - _mv88e6xxx_phy_write_indirect(ds, port, 0x16, 0x0); 2717 + ret = _mv88e6xxx_phy_page_read(ds, port, page, reg); 2791 2718 mutex_unlock(&ps->smi_mutex); 2719 + 2792 2720 return ret; 2793 2721 } 2794 2722 ··· 2795 2731 int ret; 2796 2732 2797 2733 mutex_lock(&ps->smi_mutex); 2798 - ret = _mv88e6xxx_phy_write_indirect(ds, port, 0x16, page); 2799 - if (ret < 0) 2800 - goto error; 2801 - 2802 - ret = _mv88e6xxx_phy_write_indirect(ds, port, reg, val); 2803 - error: 2804 - _mv88e6xxx_phy_write_indirect(ds, port, 0x16, 0x0); 2734 + ret = _mv88e6xxx_phy_page_write(ds, port, page, reg, val); 2805 2735 mutex_unlock(&ps->smi_mutex); 2736 + 2806 2737 return ret; 2807 2738 } 2808 2739
+8
drivers/net/dsa/mv88e6xxx.h
··· 28 28 #define SMI_CMD_OP_45_READ_DATA_INC ((3 << 10) | SMI_CMD_BUSY) 29 29 #define SMI_DATA 0x01 30 30 31 + /* Fiber/SERDES Registers are located at SMI address F, page 1 */ 32 + #define REG_FIBER_SERDES 0x0f 33 + #define PAGE_FIBER_SERDES 0x01 34 + 31 35 #define REG_PORT(p) (0x10 + (p)) 32 36 #define PORT_STATUS 0x00 33 37 #define PORT_STATUS_PAUSE_EN BIT(15) ··· 49 45 #define PORT_STATUS_MGMII BIT(6) /* 6185 */ 50 46 #define PORT_STATUS_TX_PAUSED BIT(5) 51 47 #define PORT_STATUS_FLOW_CTRL BIT(4) 48 + #define PORT_STATUS_CMODE_MASK 0x0f 49 + #define PORT_STATUS_CMODE_100BASE_X 0x8 50 + #define PORT_STATUS_CMODE_1000BASE_X 0x9 51 + #define PORT_STATUS_CMODE_SGMII 0xa 52 52 #define PORT_PCS_CTRL 0x01 53 53 #define PORT_PCS_CTRL_RGMII_DELAY_RXCLK BIT(15) 54 54 #define PORT_PCS_CTRL_RGMII_DELAY_TXCLK BIT(14)
+7 -3
drivers/net/ethernet/broadcom/bnxt/bnxt.c
··· 2653 2653 /* Write request msg to hwrm channel */ 2654 2654 __iowrite32_copy(bp->bar0, data, msg_len / 4); 2655 2655 2656 - for (i = msg_len; i < HWRM_MAX_REQ_LEN; i += 4) 2656 + for (i = msg_len; i < BNXT_HWRM_MAX_REQ_LEN; i += 4) 2657 2657 writel(0, bp->bar0 + i); 2658 2658 2659 2659 /* currently supports only one outstanding message */ ··· 3391 3391 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; 3392 3392 struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; 3393 3393 3394 + cpr->cp_doorbell = bp->bar1 + i * 0x80; 3394 3395 rc = hwrm_ring_alloc_send_msg(bp, ring, HWRM_RING_ALLOC_CMPL, i, 3395 3396 INVALID_STATS_CTX_ID); 3396 3397 if (rc) 3397 3398 goto err_out; 3398 - cpr->cp_doorbell = bp->bar1 + i * 0x80; 3399 3399 BNXT_CP_DB(cpr->cp_doorbell, cpr->cp_raw_cons); 3400 3400 bp->grp_info[i].cp_fw_ring_id = ring->fw_ring_id; 3401 3401 } ··· 3830 3830 struct hwrm_ver_get_input req = {0}; 3831 3831 struct hwrm_ver_get_output *resp = bp->hwrm_cmd_resp_addr; 3832 3832 3833 + bp->hwrm_max_req_len = HWRM_MAX_REQ_LEN; 3833 3834 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_VER_GET, -1, -1); 3834 3835 req.hwrm_intf_maj = HWRM_VERSION_MAJOR; 3835 3836 req.hwrm_intf_min = HWRM_VERSION_MINOR; ··· 3855 3854 bp->hwrm_cmd_timeout = le16_to_cpu(resp->def_req_timeout); 3856 3855 if (!bp->hwrm_cmd_timeout) 3857 3856 bp->hwrm_cmd_timeout = DFLT_HWRM_CMD_TIMEOUT; 3857 + 3858 + if (resp->hwrm_intf_maj >= 1) 3859 + bp->hwrm_max_req_len = le16_to_cpu(resp->max_req_win_len); 3858 3860 3859 3861 hwrm_ver_get_exit: 3860 3862 mutex_unlock(&bp->hwrm_cmd_lock); ··· 4559 4555 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_RX) 4560 4556 req->auto_pause |= PORT_PHY_CFG_REQ_AUTO_PAUSE_RX; 4561 4557 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_TX) 4562 - req->auto_pause |= PORT_PHY_CFG_REQ_AUTO_PAUSE_RX; 4558 + req->auto_pause |= PORT_PHY_CFG_REQ_AUTO_PAUSE_TX; 4563 4559 req->enables |= 4564 4560 cpu_to_le32(PORT_PHY_CFG_REQ_ENABLES_AUTO_PAUSE); 4565 4561 } else {
+2
drivers/net/ethernet/broadcom/bnxt/bnxt.h
··· 477 477 #define RING_CMP(idx) ((idx) & bp->cp_ring_mask) 478 478 #define NEXT_CMP(idx) RING_CMP(ADV_RAW_CMP(idx, 1)) 479 479 480 + #define BNXT_HWRM_MAX_REQ_LEN (bp->hwrm_max_req_len) 480 481 #define DFLT_HWRM_CMD_TIMEOUT 500 481 482 #define HWRM_CMD_TIMEOUT (bp->hwrm_cmd_timeout) 482 483 #define HWRM_RESET_TIMEOUT ((HWRM_CMD_TIMEOUT) * 4) ··· 954 953 dma_addr_t hw_tx_port_stats_map; 955 954 int hw_port_stats_size; 956 955 956 + u16 hwrm_max_req_len; 957 957 int hwrm_cmd_timeout; 958 958 struct mutex hwrm_cmd_lock; /* serialize hwrm messages */ 959 959 struct hwrm_ver_get_output ver_resp;
+2 -4
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
··· 855 855 if (BNXT_VF(bp)) 856 856 return; 857 857 epause->autoneg = !!(link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL); 858 - epause->rx_pause = 859 - ((link_info->auto_pause_setting & BNXT_LINK_PAUSE_RX) != 0); 860 - epause->tx_pause = 861 - ((link_info->auto_pause_setting & BNXT_LINK_PAUSE_TX) != 0); 858 + epause->rx_pause = !!(link_info->req_flow_ctrl & BNXT_LINK_PAUSE_RX); 859 + epause->tx_pause = !!(link_info->req_flow_ctrl & BNXT_LINK_PAUSE_TX); 862 860 } 863 861 864 862 static int bnxt_set_pauseparam(struct net_device *dev,
+11 -5
drivers/net/ethernet/broadcom/genet/bcmgenet.c
··· 1171 1171 struct enet_cb *tx_cb_ptr; 1172 1172 struct netdev_queue *txq; 1173 1173 unsigned int pkts_compl = 0; 1174 + unsigned int bytes_compl = 0; 1174 1175 unsigned int c_index; 1175 1176 unsigned int txbds_ready; 1176 1177 unsigned int txbds_processed = 0; ··· 1194 1193 tx_cb_ptr = &priv->tx_cbs[ring->clean_ptr]; 1195 1194 if (tx_cb_ptr->skb) { 1196 1195 pkts_compl++; 1197 - dev->stats.tx_packets++; 1198 - dev->stats.tx_bytes += tx_cb_ptr->skb->len; 1196 + bytes_compl += GENET_CB(tx_cb_ptr->skb)->bytes_sent; 1199 1197 dma_unmap_single(&dev->dev, 1200 1198 dma_unmap_addr(tx_cb_ptr, dma_addr), 1201 1199 dma_unmap_len(tx_cb_ptr, dma_len), 1202 1200 DMA_TO_DEVICE); 1203 1201 bcmgenet_free_cb(tx_cb_ptr); 1204 1202 } else if (dma_unmap_addr(tx_cb_ptr, dma_addr)) { 1205 - dev->stats.tx_bytes += 1206 - dma_unmap_len(tx_cb_ptr, dma_len); 1207 1203 dma_unmap_page(&dev->dev, 1208 1204 dma_unmap_addr(tx_cb_ptr, dma_addr), 1209 1205 dma_unmap_len(tx_cb_ptr, dma_len), ··· 1217 1219 1218 1220 ring->free_bds += txbds_processed; 1219 1221 ring->c_index = (ring->c_index + txbds_processed) & DMA_C_INDEX_MASK; 1222 + 1223 + dev->stats.tx_packets += pkts_compl; 1224 + dev->stats.tx_bytes += bytes_compl; 1220 1225 1221 1226 if (ring->free_bds > (MAX_SKB_FRAGS + 1)) { 1222 1227 txq = netdev_get_tx_queue(dev, ring->queue); ··· 1297 1296 1298 1297 tx_cb_ptr->skb = skb; 1299 1298 1300 - skb_len = skb_headlen(skb) < ETH_ZLEN ? ETH_ZLEN : skb_headlen(skb); 1299 + skb_len = skb_headlen(skb); 1301 1300 1302 1301 mapping = dma_map_single(kdev, skb->data, skb_len, DMA_TO_DEVICE); 1303 1302 ret = dma_mapping_error(kdev, mapping); ··· 1464 1463 ret = NETDEV_TX_OK; 1465 1464 goto out; 1466 1465 } 1466 + 1467 + /* Retain how many bytes will be sent on the wire, without TSB inserted 1468 + * by transmit checksum offload 1469 + */ 1470 + GENET_CB(skb)->bytes_sent = skb->len; 1467 1471 1468 1472 /* set the SKB transmit checksum */ 1469 1473 if (priv->desc_64b_en) {
+6
drivers/net/ethernet/broadcom/genet/bcmgenet.h
··· 531 531 u32 flags; 532 532 }; 533 533 534 + struct bcmgenet_skb_cb { 535 + unsigned int bytes_sent; /* bytes on the wire (no TSB) */ 536 + }; 537 + 538 + #define GENET_CB(skb) ((struct bcmgenet_skb_cb *)((skb)->cb)) 539 + 534 540 struct bcmgenet_tx_ring { 535 541 spinlock_t lock; /* ring lock */ 536 542 struct napi_struct napi; /* NAPI per tx queue */
+55 -14
drivers/net/ethernet/cadence/macb.c
··· 917 917 unsigned int frag_len = bp->rx_buffer_size; 918 918 919 919 if (offset + frag_len > len) { 920 - BUG_ON(frag != last_frag); 920 + if (unlikely(frag != last_frag)) { 921 + dev_kfree_skb_any(skb); 922 + return -1; 923 + } 921 924 frag_len = len - offset; 922 925 } 923 926 skb_copy_to_linear_data_offset(skb, offset, ··· 948 945 return 0; 949 946 } 950 947 948 + static inline void macb_init_rx_ring(struct macb *bp) 949 + { 950 + dma_addr_t addr; 951 + int i; 952 + 953 + addr = bp->rx_buffers_dma; 954 + for (i = 0; i < RX_RING_SIZE; i++) { 955 + bp->rx_ring[i].addr = addr; 956 + bp->rx_ring[i].ctrl = 0; 957 + addr += bp->rx_buffer_size; 958 + } 959 + bp->rx_ring[RX_RING_SIZE - 1].addr |= MACB_BIT(RX_WRAP); 960 + } 961 + 951 962 static int macb_rx(struct macb *bp, int budget) 952 963 { 964 + bool reset_rx_queue = false; 953 965 int received = 0; 954 966 unsigned int tail; 955 967 int first_frag = -1; ··· 990 972 991 973 if (ctrl & MACB_BIT(RX_EOF)) { 992 974 int dropped; 993 - BUG_ON(first_frag == -1); 975 + 976 + if (unlikely(first_frag == -1)) { 977 + reset_rx_queue = true; 978 + continue; 979 + } 994 980 995 981 dropped = macb_rx_frame(bp, first_frag, tail); 996 982 first_frag = -1; 983 + if (unlikely(dropped < 0)) { 984 + reset_rx_queue = true; 985 + continue; 986 + } 997 987 if (!dropped) { 998 988 received++; 999 989 budget--; 1000 990 } 1001 991 } 992 + } 993 + 994 + if (unlikely(reset_rx_queue)) { 995 + unsigned long flags; 996 + u32 ctrl; 997 + 998 + netdev_err(bp->dev, "RX queue corruption: reset it\n"); 999 + 1000 + spin_lock_irqsave(&bp->lock, flags); 1001 + 1002 + ctrl = macb_readl(bp, NCR); 1003 + macb_writel(bp, NCR, ctrl & ~MACB_BIT(RE)); 1004 + 1005 + macb_init_rx_ring(bp); 1006 + macb_writel(bp, RBQP, bp->rx_ring_dma); 1007 + 1008 + macb_writel(bp, NCR, ctrl | MACB_BIT(RE)); 1009 + 1010 + spin_unlock_irqrestore(&bp->lock, flags); 1011 + return received; 1002 1012 } 1003 1013 1004 1014 if (first_frag != -1) ··· 1146 1100 macb_writel(bp, NCR, ctrl | MACB_BIT(RE)); 1147 1101 1148 1102 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE) 1149 - macb_writel(bp, ISR, MACB_BIT(RXUBR)); 1103 + queue_writel(queue, ISR, MACB_BIT(RXUBR)); 1150 1104 } 1151 1105 1152 1106 if (status & MACB_BIT(ISR_ROVR)) { ··· 1569 1523 static void macb_init_rings(struct macb *bp) 1570 1524 { 1571 1525 int i; 1572 - dma_addr_t addr; 1573 1526 1574 - addr = bp->rx_buffers_dma; 1575 - for (i = 0; i < RX_RING_SIZE; i++) { 1576 - bp->rx_ring[i].addr = addr; 1577 - bp->rx_ring[i].ctrl = 0; 1578 - addr += bp->rx_buffer_size; 1579 - } 1580 - bp->rx_ring[RX_RING_SIZE - 1].addr |= MACB_BIT(RX_WRAP); 1527 + macb_init_rx_ring(bp); 1581 1528 1582 1529 for (i = 0; i < TX_RING_SIZE; i++) { 1583 1530 bp->queues[0].tx_ring[i].addr = 0; ··· 2996 2957 phy_node = of_get_next_available_child(np, NULL); 2997 2958 if (phy_node) { 2998 2959 int gpio = of_get_named_gpio(phy_node, "reset-gpios", 0); 2999 - if (gpio_is_valid(gpio)) 2960 + if (gpio_is_valid(gpio)) { 3000 2961 bp->reset_gpio = gpio_to_desc(gpio); 3001 - gpiod_direction_output(bp->reset_gpio, 1); 2962 + gpiod_direction_output(bp->reset_gpio, 1); 2963 + } 3002 2964 } 3003 2965 of_node_put(phy_node); 3004 2966 ··· 3069 3029 mdiobus_free(bp->mii_bus); 3070 3030 3071 3031 /* Shutdown the PHY if there is a GPIO reset */ 3072 - gpiod_set_value(bp->reset_gpio, 0); 3032 + if (bp->reset_gpio) 3033 + gpiod_set_value(bp->reset_gpio, 0); 3073 3034 3074 3035 unregister_netdev(dev); 3075 3036 clk_disable_unprepare(bp->tx_clk);
+1 -1
drivers/net/ethernet/freescale/fec_main.c
··· 943 943 else 944 944 val &= ~FEC_RACC_OPTIONS; 945 945 writel(val, fep->hwp + FEC_RACC); 946 + writel(PKT_MAXBUF_SIZE, fep->hwp + FEC_FTRL); 946 947 } 947 - writel(PKT_MAXBUF_SIZE, fep->hwp + FEC_FTRL); 948 948 #endif 949 949 950 950 /*
+1 -1
drivers/net/ethernet/hisilicon/hns/hnae.h
··· 469 469 u32 *tx_usecs, u32 *rx_usecs); 470 470 void (*get_rx_max_coalesced_frames)(struct hnae_handle *handle, 471 471 u32 *tx_frames, u32 *rx_frames); 472 - void (*set_coalesce_usecs)(struct hnae_handle *handle, u32 timeout); 472 + int (*set_coalesce_usecs)(struct hnae_handle *handle, u32 timeout); 473 473 int (*set_coalesce_frames)(struct hnae_handle *handle, 474 474 u32 coalesce_frames); 475 475 void (*set_promisc_mode)(struct hnae_handle *handle, u32 en);
+23 -41
drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
··· 159 159 ae_handle->qs[i]->tx_ring.q = ae_handle->qs[i]; 160 160 161 161 ring_pair_cb->used_by_vf = 1; 162 - if (port_idx < DSAF_SERVICE_PORT_NUM_PER_DSAF) 163 - ring_pair_cb->port_id_in_dsa = port_idx; 164 - else 165 - ring_pair_cb->port_id_in_dsa = 0; 166 - 167 162 ring_pair_cb++; 168 163 } 169 164 ··· 448 453 static void hns_ae_get_coalesce_usecs(struct hnae_handle *handle, 449 454 u32 *tx_usecs, u32 *rx_usecs) 450 455 { 451 - int port; 456 + struct ring_pair_cb *ring_pair = 457 + container_of(handle->qs[0], struct ring_pair_cb, q); 452 458 453 - port = hns_ae_map_eport_to_dport(handle->eport_id); 454 - 455 - *tx_usecs = hns_rcb_get_coalesce_usecs( 456 - hns_ae_get_dsaf_dev(handle->dev), 457 - hns_dsaf_get_comm_idx_by_port(port)); 458 - *rx_usecs = hns_rcb_get_coalesce_usecs( 459 - hns_ae_get_dsaf_dev(handle->dev), 460 - hns_dsaf_get_comm_idx_by_port(port)); 459 + *tx_usecs = hns_rcb_get_coalesce_usecs(ring_pair->rcb_common, 460 + ring_pair->port_id_in_comm); 461 + *rx_usecs = hns_rcb_get_coalesce_usecs(ring_pair->rcb_common, 462 + ring_pair->port_id_in_comm); 461 463 } 462 464 463 465 static void hns_ae_get_rx_max_coalesced_frames(struct hnae_handle *handle, 464 466 u32 *tx_frames, u32 *rx_frames) 465 467 { 466 - int port; 468 + struct ring_pair_cb *ring_pair = 469 + container_of(handle->qs[0], struct ring_pair_cb, q); 467 470 468 - assert(handle); 469 - 470 - port = hns_ae_map_eport_to_dport(handle->eport_id); 471 - 472 - *tx_frames = hns_rcb_get_coalesced_frames( 473 - hns_ae_get_dsaf_dev(handle->dev), port); 474 - *rx_frames = hns_rcb_get_coalesced_frames( 475 - hns_ae_get_dsaf_dev(handle->dev), port); 471 + *tx_frames = hns_rcb_get_coalesced_frames(ring_pair->rcb_common, 472 + ring_pair->port_id_in_comm); 473 + *rx_frames = hns_rcb_get_coalesced_frames(ring_pair->rcb_common, 474 + ring_pair->port_id_in_comm); 476 475 } 477 476 478 - static void hns_ae_set_coalesce_usecs(struct hnae_handle *handle, 479 - u32 timeout) 477 + static int hns_ae_set_coalesce_usecs(struct hnae_handle *handle, 478 + u32 timeout) 480 479 { 481 - int port; 480 + struct ring_pair_cb *ring_pair = 481 + container_of(handle->qs[0], struct ring_pair_cb, q); 482 482 483 - assert(handle); 484 - 485 - port = hns_ae_map_eport_to_dport(handle->eport_id); 486 - 487 - hns_rcb_set_coalesce_usecs(hns_ae_get_dsaf_dev(handle->dev), 488 - port, timeout); 483 + return hns_rcb_set_coalesce_usecs( 484 + ring_pair->rcb_common, ring_pair->port_id_in_comm, timeout); 489 485 } 490 486 491 487 static int hns_ae_set_coalesce_frames(struct hnae_handle *handle, 492 488 u32 coalesce_frames) 493 489 { 494 - int port; 495 - int ret; 490 + struct ring_pair_cb *ring_pair = 491 + container_of(handle->qs[0], struct ring_pair_cb, q); 496 492 497 - assert(handle); 498 - 499 - port = hns_ae_map_eport_to_dport(handle->eport_id); 500 - 501 - ret = hns_rcb_set_coalesced_frames(hns_ae_get_dsaf_dev(handle->dev), 502 - port, coalesce_frames); 503 - return ret; 493 + return hns_rcb_set_coalesced_frames( 494 + ring_pair->rcb_common, 495 + ring_pair->port_id_in_comm, coalesce_frames); 504 496 } 505 497 506 498 void hns_ae_update_stats(struct hnae_handle *handle,
+2 -1
drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c
··· 664 664 return; 665 665 666 666 for (i = 0; i < ARRAY_SIZE(g_gmac_stats_string); i++) { 667 - snprintf(buff, ETH_GSTRING_LEN, g_gmac_stats_string[i].desc); 667 + snprintf(buff, ETH_GSTRING_LEN, "%s", 668 + g_gmac_stats_string[i].desc); 668 669 buff = buff + ETH_GSTRING_LEN; 669 670 } 670 671 }
+6 -6
drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
··· 2219 2219 /* dsaf onode registers */ 2220 2220 for (i = 0; i < DSAF_XOD_NUM; i++) { 2221 2221 p[311 + i] = dsaf_read_dev(ddev, 2222 - DSAF_XOD_ETS_TSA_TC0_TC3_CFG_0_REG + j * 0x90); 2222 + DSAF_XOD_ETS_TSA_TC0_TC3_CFG_0_REG + i * 0x90); 2223 2223 p[319 + i] = dsaf_read_dev(ddev, 2224 - DSAF_XOD_ETS_TSA_TC4_TC7_CFG_0_REG + j * 0x90); 2224 + DSAF_XOD_ETS_TSA_TC4_TC7_CFG_0_REG + i * 0x90); 2225 2225 p[327 + i] = dsaf_read_dev(ddev, 2226 - DSAF_XOD_ETS_BW_TC0_TC3_CFG_0_REG + j * 0x90); 2226 + DSAF_XOD_ETS_BW_TC0_TC3_CFG_0_REG + i * 0x90); 2227 2227 p[335 + i] = dsaf_read_dev(ddev, 2228 - DSAF_XOD_ETS_BW_TC4_TC7_CFG_0_REG + j * 0x90); 2228 + DSAF_XOD_ETS_BW_TC4_TC7_CFG_0_REG + i * 0x90); 2229 2229 p[343 + i] = dsaf_read_dev(ddev, 2230 - DSAF_XOD_ETS_BW_OFFSET_CFG_0_REG + j * 0x90); 2230 + DSAF_XOD_ETS_BW_OFFSET_CFG_0_REG + i * 0x90); 2231 2231 p[351 + i] = dsaf_read_dev(ddev, 2232 - DSAF_XOD_ETS_TOKEN_CFG_0_REG + j * 0x90); 2232 + DSAF_XOD_ETS_TOKEN_CFG_0_REG + i * 0x90); 2233 2233 } 2234 2234 2235 2235 p[359] = dsaf_read_dev(ddev, DSAF_XOD_PFS_CFG_0_0_REG + port * 0x90);
+24 -20
drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
··· 244 244 */ 245 245 phy_interface_t hns_mac_get_phy_if(struct hns_mac_cb *mac_cb) 246 246 { 247 - u32 hilink3_mode; 248 - u32 hilink4_mode; 247 + u32 mode; 248 + u32 reg; 249 + u32 shift; 250 + bool is_ver1 = AE_IS_VER1(mac_cb->dsaf_dev->dsaf_ver); 249 251 void __iomem *sys_ctl_vaddr = mac_cb->sys_ctl_vaddr; 250 - int dev_id = mac_cb->mac_id; 252 + int mac_id = mac_cb->mac_id; 251 253 phy_interface_t phy_if = PHY_INTERFACE_MODE_NA; 252 254 253 - hilink3_mode = dsaf_read_reg(sys_ctl_vaddr, HNS_MAC_HILINK3_REG); 254 - hilink4_mode = dsaf_read_reg(sys_ctl_vaddr, HNS_MAC_HILINK4_REG); 255 - if (dev_id >= 0 && dev_id <= 3) { 256 - if (hilink4_mode == 0) 257 - phy_if = PHY_INTERFACE_MODE_SGMII; 258 - else 259 - phy_if = PHY_INTERFACE_MODE_XGMII; 260 - } else if (dev_id >= 4 && dev_id <= 5) { 261 - if (hilink3_mode == 0) 262 - phy_if = PHY_INTERFACE_MODE_SGMII; 263 - else 264 - phy_if = PHY_INTERFACE_MODE_XGMII; 265 - } else { 255 + if (is_ver1 && (mac_id >= 6 && mac_id <= 7)) { 266 256 phy_if = PHY_INTERFACE_MODE_SGMII; 257 + } else if (mac_id >= 0 && mac_id <= 3) { 258 + reg = is_ver1 ? HNS_MAC_HILINK4_REG : HNS_MAC_HILINK4V2_REG; 259 + mode = dsaf_read_reg(sys_ctl_vaddr, reg); 260 + /* mac_id 0, 1, 2, 3 ---> hilink4 lane 0, 1, 2, 3 */ 261 + shift = is_ver1 ? 0 : mac_id; 262 + if (dsaf_get_bit(mode, shift)) 263 + phy_if = PHY_INTERFACE_MODE_XGMII; 264 + else 265 + phy_if = PHY_INTERFACE_MODE_SGMII; 266 + } else if (mac_id >= 4 && mac_id <= 7) { 267 + reg = is_ver1 ? HNS_MAC_HILINK3_REG : HNS_MAC_HILINK3V2_REG; 268 + mode = dsaf_read_reg(sys_ctl_vaddr, reg); 269 + /* mac_id 4, 5, 6, 7 ---> hilink3 lane 2, 3, 0, 1 */ 270 + shift = is_ver1 ? 0 : mac_id <= 5 ? mac_id - 2 : mac_id - 6; 271 + if (dsaf_get_bit(mode, shift)) 272 + phy_if = PHY_INTERFACE_MODE_XGMII; 273 + else 274 + phy_if = PHY_INTERFACE_MODE_SGMII; 267 275 } 268 - 269 - dev_dbg(mac_cb->dev, 270 - "hilink3_mode=%d, hilink4_mode=%d dev_id=%d, phy_if=%d\n", 271 - hilink3_mode, hilink4_mode, dev_id, phy_if); 272 276 return phy_if; 273 277 } 274 278
+92 -104
drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c
··· 215 215 dsaf_write_dev(q, RCB_RING_RX_RING_BD_LEN_REG, 216 216 bd_size_type); 217 217 dsaf_write_dev(q, RCB_RING_RX_RING_BD_NUM_REG, 218 - ring_pair->port_id_in_dsa); 218 + ring_pair->port_id_in_comm); 219 219 dsaf_write_dev(q, RCB_RING_RX_RING_PKTLINE_REG, 220 - ring_pair->port_id_in_dsa); 220 + ring_pair->port_id_in_comm); 221 221 } else { 222 222 dsaf_write_dev(q, RCB_RING_TX_RING_BASEADDR_L_REG, 223 223 (u32)dma); ··· 227 227 dsaf_write_dev(q, RCB_RING_TX_RING_BD_LEN_REG, 228 228 bd_size_type); 229 229 dsaf_write_dev(q, RCB_RING_TX_RING_BD_NUM_REG, 230 - ring_pair->port_id_in_dsa); 230 + ring_pair->port_id_in_comm); 231 231 dsaf_write_dev(q, RCB_RING_TX_RING_PKTLINE_REG, 232 - ring_pair->port_id_in_dsa); 232 + ring_pair->port_id_in_comm); 233 233 } 234 234 } 235 235 ··· 256 256 desc_cnt); 257 257 } 258 258 259 - /** 260 - *hns_rcb_set_port_coalesced_frames - set rcb port coalesced frames 261 - *@rcb_common: rcb_common device 262 - *@port_idx:port index 263 - *@coalesced_frames:BD num for coalesced frames 264 - */ 265 - static int hns_rcb_set_port_coalesced_frames(struct rcb_common_cb *rcb_common, 266 - u32 port_idx, 267 - u32 coalesced_frames) 259 + static void hns_rcb_set_port_timeout( 260 + struct rcb_common_cb *rcb_common, u32 port_idx, u32 timeout) 268 261 { 269 - if (coalesced_frames >= rcb_common->desc_num || 270 - coalesced_frames > HNS_RCB_MAX_COALESCED_FRAMES) 271 - return -EINVAL; 272 - 273 - dsaf_write_dev(rcb_common, RCB_CFG_PKTLINE_REG + port_idx * 4, 274 - coalesced_frames); 275 - return 0; 276 - } 277 - 278 - /** 279 - *hns_rcb_get_port_coalesced_frames - set rcb port coalesced frames 280 - *@rcb_common: rcb_common device 281 - *@port_idx:port index 282 - * return coaleseced frames value 283 - */ 284 - static u32 hns_rcb_get_port_coalesced_frames(struct rcb_common_cb *rcb_common, 285 - u32 port_idx) 286 - { 287 - if (port_idx >= HNS_RCB_SERVICE_NW_ENGINE_NUM) 288 - port_idx = 0; 289 - 290 - return dsaf_read_dev(rcb_common, 291 - RCB_CFG_PKTLINE_REG + port_idx * 4); 292 - } 293 - 294 - /** 295 - *hns_rcb_set_timeout - set rcb port coalesced time_out 296 - *@rcb_common: rcb_common device 297 - *@time_out:time for coalesced time_out 298 - */ 299 - static void hns_rcb_set_timeout(struct rcb_common_cb *rcb_common, 300 - u32 timeout) 301 - { 302 - dsaf_write_dev(rcb_common, RCB_CFG_OVERTIME_REG, timeout); 262 + if (AE_IS_VER1(rcb_common->dsaf_dev->dsaf_ver)) 263 + dsaf_write_dev(rcb_common, RCB_CFG_OVERTIME_REG, 264 + timeout * HNS_RCB_CLK_FREQ_MHZ); 265 + else 266 + dsaf_write_dev(rcb_common, 267 + RCB_PORT_CFG_OVERTIME_REG + port_idx * 4, 268 + timeout); 303 269 } 304 270 305 271 static int hns_rcb_common_get_port_num(struct rcb_common_cb *rcb_common) ··· 327 361 328 362 for (i = 0; i < port_num; i++) { 329 363 hns_rcb_set_port_desc_cnt(rcb_common, i, rcb_common->desc_num); 330 - (void)hns_rcb_set_port_coalesced_frames( 331 - rcb_common, i, rcb_common->coalesced_frames); 364 + (void)hns_rcb_set_coalesced_frames( 365 + rcb_common, i, HNS_RCB_DEF_COALESCED_FRAMES); 366 + hns_rcb_set_port_timeout( 367 + rcb_common, i, HNS_RCB_DEF_COALESCED_USECS); 332 368 } 333 - hns_rcb_set_timeout(rcb_common, rcb_common->timeout); 334 369 335 370 dsaf_write_dev(rcb_common, RCB_COM_CFG_ENDIAN_REG, 336 371 HNS_RCB_COMMON_ENDIAN); ··· 427 460 hns_rcb_ring_get_cfg(&ring_pair_cb->q, TX_RING); 428 461 } 429 462 430 - static int hns_rcb_get_port(struct rcb_common_cb *rcb_common, int ring_idx) 463 + static int hns_rcb_get_port_in_comm( 464 + struct rcb_common_cb *rcb_common, int ring_idx) 431 465 { 432 466 int comm_index = rcb_common->comm_index; 433 467 int port; ··· 438 470 q_num = (int)rcb_common->max_q_per_vf * rcb_common->max_vfn; 439 471 port = ring_idx / q_num; 440 472 } else { 441 - port = HNS_RCB_SERVICE_NW_ENGINE_NUM + comm_index - 1; 473 + port = 0; /* config debug-ports port_id_in_comm to 0*/ 442 474 } 443 475 444 476 return port; ··· 486 518 ring_pair_cb->index = i; 487 519 ring_pair_cb->q.io_base = 488 520 RCB_COMM_BASE_TO_RING_BASE(rcb_common->io_base, i); 489 - ring_pair_cb->port_id_in_dsa = hns_rcb_get_port(rcb_common, i); 521 + ring_pair_cb->port_id_in_comm = 522 + hns_rcb_get_port_in_comm(rcb_common, i); 490 523 ring_pair_cb->virq[HNS_RCB_IRQ_IDX_TX] = 491 524 is_ver1 ? irq_of_parse_and_map(np, base_irq_idx + i * 2) : 492 525 platform_get_irq(pdev, base_irq_idx + i * 3 + 1); ··· 503 534 /** 504 535 *hns_rcb_get_coalesced_frames - get rcb port coalesced frames 505 536 *@rcb_common: rcb_common device 506 - *@comm_index:port index 507 - *return coalesced_frames 537 + *@port_idx:port id in comm 538 + * 539 + *Returns: coalesced_frames 508 540 */ 509 - u32 hns_rcb_get_coalesced_frames(struct dsaf_device *dsaf_dev, int port) 541 + u32 hns_rcb_get_coalesced_frames( 542 + struct rcb_common_cb *rcb_common, u32 port_idx) 510 543 { 511 - int comm_index = hns_dsaf_get_comm_idx_by_port(port); 512 - struct rcb_common_cb *rcb_comm = dsaf_dev->rcb_common[comm_index]; 513 - 514 - return hns_rcb_get_port_coalesced_frames(rcb_comm, port); 544 + return dsaf_read_dev(rcb_common, RCB_CFG_PKTLINE_REG + port_idx * 4); 515 545 } 516 546 517 547 /** 518 548 *hns_rcb_get_coalesce_usecs - get rcb port coalesced time_out 519 549 *@rcb_common: rcb_common device 520 - *@comm_index:port index 521 - *return time_out 550 + *@port_idx:port id in comm 551 + * 552 + *Returns: time_out 522 553 */ 523 - u32 hns_rcb_get_coalesce_usecs(struct dsaf_device *dsaf_dev, int comm_index) 554 + u32 hns_rcb_get_coalesce_usecs( 555 + struct rcb_common_cb *rcb_common, u32 port_idx) 524 556 { 525 - struct rcb_common_cb *rcb_comm = dsaf_dev->rcb_common[comm_index]; 526 - 527 - return rcb_comm->timeout; 557 + if (AE_IS_VER1(rcb_common->dsaf_dev->dsaf_ver)) 558 + return dsaf_read_dev(rcb_common, RCB_CFG_OVERTIME_REG) / 559 + HNS_RCB_CLK_FREQ_MHZ; 560 + else 561 + return dsaf_read_dev(rcb_common, 562 + RCB_PORT_CFG_OVERTIME_REG + port_idx * 4); 528 563 } 529 564 530 565 /** 531 566 *hns_rcb_set_coalesce_usecs - set rcb port coalesced time_out 532 567 *@rcb_common: rcb_common device 533 - *@comm_index: comm :index 534 - *@etx_usecs:tx time for coalesced time_out 535 - *@rx_usecs:rx time for coalesced time_out 568 + *@port_idx:port id in comm 569 + *@timeout:tx/rx time for coalesced time_out 570 + * 571 + * Returns: 572 + * Zero for success, or an error code in case of failure 536 573 */ 537 - void hns_rcb_set_coalesce_usecs(struct dsaf_device *dsaf_dev, 538 - int port, u32 timeout) 574 + int hns_rcb_set_coalesce_usecs( 575 + struct rcb_common_cb *rcb_common, u32 port_idx, u32 timeout) 539 576 { 540 - int comm_index = hns_dsaf_get_comm_idx_by_port(port); 541 - struct rcb_common_cb *rcb_comm = dsaf_dev->rcb_common[comm_index]; 577 + u32 old_timeout = hns_rcb_get_coalesce_usecs(rcb_common, port_idx); 542 578 543 - if (rcb_comm->timeout == timeout) 544 - return; 579 + if (timeout == old_timeout) 580 + return 0; 545 581 546 - if (comm_index == HNS_DSAF_COMM_SERVICE_NW_IDX) { 547 - dev_err(dsaf_dev->dev, 548 - "error: not support coalesce_usecs setting!\n"); 549 - return; 582 + if (AE_IS_VER1(rcb_common->dsaf_dev->dsaf_ver)) { 583 + if (rcb_common->comm_index == HNS_DSAF_COMM_SERVICE_NW_IDX) { 584 + dev_err(rcb_common->dsaf_dev->dev, 585 + "error: not support coalesce_usecs setting!\n"); 586 + return -EINVAL; 587 + } 550 588 } 551 - rcb_comm->timeout = timeout; 552 - hns_rcb_set_timeout(rcb_comm, rcb_comm->timeout); 589 + if (timeout > HNS_RCB_MAX_COALESCED_USECS) { 590 + dev_err(rcb_common->dsaf_dev->dev, 591 + "error: not support coalesce %dus!\n", timeout); 592 + return -EINVAL; 593 + } 594 + hns_rcb_set_port_timeout(rcb_common, port_idx, timeout); 595 + return 0; 553 596 } 554 597 555 598 /** 556 599 *hns_rcb_set_coalesced_frames - set rcb coalesced frames 557 600 *@rcb_common: rcb_common device 558 - *@tx_frames:tx BD num for coalesced frames 559 - *@rx_frames:rx BD num for coalesced frames 560 - *Return 0 on success, negative on failure 601 + *@port_idx:port id in comm 602 + *@coalesced_frames:tx/rx BD num for coalesced frames 603 + * 604 + * Returns: 605 + * Zero for success, or an error code in case of failure 561 606 */ 562 - int hns_rcb_set_coalesced_frames(struct dsaf_device *dsaf_dev, 563 - int port, u32 coalesced_frames) 607 + int hns_rcb_set_coalesced_frames( 608 + struct rcb_common_cb *rcb_common, u32 port_idx, u32 coalesced_frames) 564 609 { 565 - int comm_index = hns_dsaf_get_comm_idx_by_port(port); 566 - struct rcb_common_cb *rcb_comm = dsaf_dev->rcb_common[comm_index]; 567 - u32 coalesced_reg_val; 568 - int ret; 610 + u32 old_waterline = hns_rcb_get_coalesced_frames(rcb_common, port_idx); 569 611 570 - coalesced_reg_val = hns_rcb_get_port_coalesced_frames(rcb_comm, port); 571 - 572 - if (coalesced_reg_val == coalesced_frames) 612 + if (coalesced_frames == old_waterline) 573 613 return 0; 574 614 575 - if (coalesced_frames >= HNS_RCB_MIN_COALESCED_FRAMES) { 576 - ret = hns_rcb_set_port_coalesced_frames(rcb_comm, port, 577 - coalesced_frames); 578 - return ret; 579 - } else { 615 + if (coalesced_frames >= rcb_common->desc_num || 616 + coalesced_frames > HNS_RCB_MAX_COALESCED_FRAMES || 617 + coalesced_frames < HNS_RCB_MIN_COALESCED_FRAMES) { 618 + dev_err(rcb_common->dsaf_dev->dev, 619 + "error: not support coalesce_frames setting!\n"); 580 620 return -EINVAL; 581 621 } 622 + 623 + dsaf_write_dev(rcb_common, RCB_CFG_PKTLINE_REG + port_idx * 4, 624 + coalesced_frames); 625 + return 0; 582 626 } 583 627 584 628 /** ··· 731 749 rcb_common->dsaf_dev = dsaf_dev; 732 750 733 751 rcb_common->desc_num = dsaf_dev->desc_num; 734 - rcb_common->coalesced_frames = HNS_RCB_DEF_COALESCED_FRAMES; 735 - rcb_common->timeout = HNS_RCB_MAX_TIME_OUT; 736 752 737 753 hns_rcb_get_queue_mode(dsaf_mode, comm_index, &max_vfn, &max_q_per_vf); 738 754 rcb_common->max_vfn = max_vfn; ··· 931 951 void hns_rcb_get_common_regs(struct rcb_common_cb *rcb_com, void *data) 932 952 { 933 953 u32 *regs = data; 954 + bool is_ver1 = AE_IS_VER1(rcb_com->dsaf_dev->dsaf_ver); 955 + bool is_dbg = (rcb_com->comm_index != HNS_DSAF_COMM_SERVICE_NW_IDX); 956 + u32 reg_tmp; 957 + u32 reg_num_tmp; 934 958 u32 i = 0; 935 959 936 960 /*rcb common registers */ ··· 988 1004 = dsaf_read_dev(rcb_com, RCB_CFG_PKTLINE_REG + 4 * i); 989 1005 } 990 1006 991 - regs[70] = dsaf_read_dev(rcb_com, RCB_CFG_OVERTIME_REG); 992 - regs[71] = dsaf_read_dev(rcb_com, RCB_CFG_PKTLINE_INT_NUM_REG); 993 - regs[72] = dsaf_read_dev(rcb_com, RCB_CFG_OVERTIME_INT_NUM_REG); 1007 + reg_tmp = is_ver1 ? RCB_CFG_OVERTIME_REG : RCB_PORT_CFG_OVERTIME_REG; 1008 + reg_num_tmp = (is_ver1 || is_dbg) ? 1 : 6; 1009 + for (i = 0; i < reg_num_tmp; i++) 1010 + regs[70 + i] = dsaf_read_dev(rcb_com, reg_tmp); 1011 + 1012 + regs[76] = dsaf_read_dev(rcb_com, RCB_CFG_PKTLINE_INT_NUM_REG); 1013 + regs[77] = dsaf_read_dev(rcb_com, RCB_CFG_OVERTIME_INT_NUM_REG); 994 1014 995 1015 /* mark end of rcb common regs */ 996 - for (i = 73; i < 80; i++) 1016 + for (i = 78; i < 80; i++) 997 1017 regs[i] = 0xcccccccc; 998 1018 } 999 1019
+12 -11
drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h
··· 38 38 #define HNS_RCB_MAX_COALESCED_FRAMES 1023 39 39 #define HNS_RCB_MIN_COALESCED_FRAMES 1 40 40 #define HNS_RCB_DEF_COALESCED_FRAMES 50 41 - #define HNS_RCB_MAX_TIME_OUT 0x500 41 + #define HNS_RCB_CLK_FREQ_MHZ 350 42 + #define HNS_RCB_MAX_COALESCED_USECS 0x3ff 43 + #define HNS_RCB_DEF_COALESCED_USECS 3 42 44 43 45 #define HNS_RCB_COMMON_ENDIAN 1 44 46 ··· 84 82 85 83 int virq[HNS_RCB_IRQ_NUM_PER_QUEUE]; 86 84 87 - u8 port_id_in_dsa; 85 + u8 port_id_in_comm; 88 86 u8 used_by_vf; 89 87 90 88 struct hns_ring_hw_stats hw_stats; ··· 99 97 100 98 u8 comm_index; 101 99 u32 ring_num; 102 - u32 coalesced_frames; /* frames threshold of rx interrupt */ 103 - u32 timeout; /* time threshold of rx interrupt */ 104 100 u32 desc_num; /* desc num per queue*/ 105 101 106 102 struct ring_pair_cb ring_pair_cb[0]; ··· 125 125 void hns_rcb_init_hw(struct ring_pair_cb *ring); 126 126 void hns_rcb_reset_ring_hw(struct hnae_queue *q); 127 127 void hns_rcb_wait_fbd_clean(struct hnae_queue **qs, int q_num, u32 flag); 128 - 129 - u32 hns_rcb_get_coalesced_frames(struct dsaf_device *dsaf_dev, int comm_index); 130 - u32 hns_rcb_get_coalesce_usecs(struct dsaf_device *dsaf_dev, int comm_index); 131 - void hns_rcb_set_coalesce_usecs(struct dsaf_device *dsaf_dev, 132 - int comm_index, u32 timeout); 133 - int hns_rcb_set_coalesced_frames(struct dsaf_device *dsaf_dev, 134 - int comm_index, u32 coalesce_frames); 128 + u32 hns_rcb_get_coalesced_frames( 129 + struct rcb_common_cb *rcb_common, u32 port_idx); 130 + u32 hns_rcb_get_coalesce_usecs( 131 + struct rcb_common_cb *rcb_common, u32 port_idx); 132 + int hns_rcb_set_coalesce_usecs( 133 + struct rcb_common_cb *rcb_common, u32 port_idx, u32 timeout); 134 + int hns_rcb_set_coalesced_frames( 135 + struct rcb_common_cb *rcb_common, u32 port_idx, u32 coalesced_frames); 135 136 void hns_rcb_update_stats(struct hnae_queue *queue); 136 137 137 138 void hns_rcb_get_stats(struct hnae_queue *queue, u64 *data);
+3
drivers/net/ethernet/hisilicon/hns/hns_dsaf_reg.h
··· 103 103 /*serdes offset**/ 104 104 #define HNS_MAC_HILINK3_REG DSAF_SUB_SC_HILINK3_CRG_CTRL0_REG 105 105 #define HNS_MAC_HILINK4_REG DSAF_SUB_SC_HILINK4_CRG_CTRL0_REG 106 + #define HNS_MAC_HILINK3V2_REG DSAF_SUB_SC_HILINK3_CRG_CTRL1_REG 107 + #define HNS_MAC_HILINK4V2_REG DSAF_SUB_SC_HILINK4_CRG_CTRL1_REG 106 108 #define HNS_MAC_LANE0_CTLEDFE_REG 0x000BFFCCULL 107 109 #define HNS_MAC_LANE1_CTLEDFE_REG 0x000BFFBCULL 108 110 #define HNS_MAC_LANE2_CTLEDFE_REG 0x000BFFACULL ··· 406 404 #define RCB_CFG_OVERTIME_REG 0x9300 407 405 #define RCB_CFG_PKTLINE_INT_NUM_REG 0x9304 408 406 #define RCB_CFG_OVERTIME_INT_NUM_REG 0x9308 407 + #define RCB_PORT_CFG_OVERTIME_REG 0x9430 409 408 410 409 #define RCB_RING_RX_RING_BASEADDR_L_REG 0x00000 411 410 #define RCB_RING_RX_RING_BASEADDR_H_REG 0x00004
+7 -9
drivers/net/ethernet/hisilicon/hns/hns_enet.c
··· 913 913 static void hns_nic_tx_fini_pro(struct hns_nic_ring_data *ring_data) 914 914 { 915 915 struct hnae_ring *ring = ring_data->ring; 916 - int head = ring->next_to_clean; 917 - 918 - /* for hardware bug fixed */ 919 - head = readl_relaxed(ring->io_base + RCB_REG_HEAD); 916 + int head = readl_relaxed(ring->io_base + RCB_REG_HEAD); 920 917 921 918 if (head != ring->next_to_clean) { 922 919 ring_data->ring->q->handle->dev->ops->toggle_ring_irq( ··· 956 959 napi_complete(napi); 957 960 ring_data->ring->q->handle->dev->ops->toggle_ring_irq( 958 961 ring_data->ring, 0); 959 - 960 - ring_data->fini_process(ring_data); 962 + if (ring_data->fini_process) 963 + ring_data->fini_process(ring_data); 961 964 return 0; 962 965 } 963 966 ··· 1720 1723 { 1721 1724 struct hnae_handle *h = priv->ae_handle; 1722 1725 struct hns_nic_ring_data *rd; 1726 + bool is_ver1 = AE_IS_VER1(priv->enet_ver); 1723 1727 int i; 1724 1728 1725 1729 if (h->q_num > NIC_MAX_Q_PER_VF) { ··· 1738 1740 rd->queue_index = i; 1739 1741 rd->ring = &h->qs[i]->tx_ring; 1740 1742 rd->poll_one = hns_nic_tx_poll_one; 1741 - rd->fini_process = hns_nic_tx_fini_pro; 1743 + rd->fini_process = is_ver1 ? hns_nic_tx_fini_pro : NULL; 1742 1744 1743 1745 netif_napi_add(priv->netdev, &rd->napi, 1744 1746 hns_nic_common_poll, NIC_TX_CLEAN_MAX_NUM); ··· 1750 1752 rd->ring = &h->qs[i - h->q_num]->rx_ring; 1751 1753 rd->poll_one = hns_nic_rx_poll_one; 1752 1754 rd->ex_process = hns_nic_rx_up_pro; 1753 - rd->fini_process = hns_nic_rx_fini_pro; 1755 + rd->fini_process = is_ver1 ? hns_nic_rx_fini_pro : NULL; 1754 1756 1755 1757 netif_napi_add(priv->netdev, &rd->napi, 1756 1758 hns_nic_common_poll, NIC_RX_CLEAN_MAX_NUM); ··· 1814 1816 h = hnae_get_handle(&priv->netdev->dev, 1815 1817 priv->ae_node, priv->port_id, NULL); 1816 1818 if (IS_ERR_OR_NULL(h)) { 1817 - ret = PTR_ERR(h); 1819 + ret = -ENODEV; 1818 1820 dev_dbg(priv->dev, "has not handle, register notifier!\n"); 1819 1821 goto out; 1820 1822 }
+6 -4
drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
··· 794 794 (!ops->set_coalesce_frames)) 795 795 return -ESRCH; 796 796 797 - ops->set_coalesce_usecs(priv->ae_handle, 798 - ec->rx_coalesce_usecs); 797 + ret = ops->set_coalesce_usecs(priv->ae_handle, 798 + ec->rx_coalesce_usecs); 799 + if (ret) 800 + return ret; 799 801 800 802 ret = ops->set_coalesce_frames( 801 803 priv->ae_handle, ··· 1015 1013 struct phy_device *phy_dev = priv->phy; 1016 1014 1017 1015 retval = phy_write(phy_dev, HNS_PHY_PAGE_REG, HNS_PHY_PAGE_LED); 1018 - retval = phy_write(phy_dev, HNS_LED_FC_REG, value); 1019 - retval = phy_write(phy_dev, HNS_PHY_PAGE_REG, HNS_PHY_PAGE_COPPER); 1016 + retval |= phy_write(phy_dev, HNS_LED_FC_REG, value); 1017 + retval |= phy_write(phy_dev, HNS_PHY_PAGE_REG, HNS_PHY_PAGE_COPPER); 1020 1018 if (retval) { 1021 1019 netdev_err(netdev, "mdiobus_write fail !\n"); 1022 1020 return retval;
+5 -5
drivers/net/ethernet/intel/ixgbe/ixgbe.h
··· 661 661 #define IXGBE_FLAG2_RSS_FIELD_IPV6_UDP (u32)(1 << 9) 662 662 #define IXGBE_FLAG2_PTP_PPS_ENABLED (u32)(1 << 10) 663 663 #define IXGBE_FLAG2_PHY_INTERRUPT (u32)(1 << 11) 664 - #ifdef CONFIG_IXGBE_VXLAN 665 664 #define IXGBE_FLAG2_VXLAN_REREG_NEEDED BIT(12) 666 - #endif 667 665 #define IXGBE_FLAG2_VLAN_PROMISC BIT(13) 668 666 669 667 /* Tx fast path data */ ··· 672 674 /* Rx fast path data */ 673 675 int num_rx_queues; 674 676 u16 rx_itr_setting; 677 + 678 + /* Port number used to identify VXLAN traffic */ 679 + __be16 vxlan_port; 675 680 676 681 /* TX */ 677 682 struct ixgbe_ring *tx_ring[MAX_TX_QUEUES] ____cacheline_aligned_in_smp; ··· 783 782 u32 timer_event_accumulator; 784 783 u32 vferr_refcount; 785 784 struct ixgbe_mac_addr *mac_table; 786 - #ifdef CONFIG_IXGBE_VXLAN 787 - u16 vxlan_port; 788 - #endif 789 785 struct kobject *info_kobj; 790 786 #ifdef CONFIG_IXGBE_HWMON 791 787 struct hwmon_buff *ixgbe_hwmon_buff; ··· 877 879 extern char ixgbe_default_device_descr[]; 878 880 #endif /* IXGBE_FCOE */ 879 881 882 + int ixgbe_open(struct net_device *netdev); 883 + int ixgbe_close(struct net_device *netdev); 880 884 void ixgbe_up(struct ixgbe_adapter *adapter); 881 885 void ixgbe_down(struct ixgbe_adapter *adapter); 882 886 void ixgbe_reinit_locked(struct ixgbe_adapter *adapter);
+2 -2
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
··· 2053 2053 2054 2054 if (if_running) 2055 2055 /* indicate we're in test mode */ 2056 - dev_close(netdev); 2056 + ixgbe_close(netdev); 2057 2057 else 2058 2058 ixgbe_reset(adapter); 2059 2059 ··· 2091 2091 /* clear testing bit and return adapter to previous state */ 2092 2092 clear_bit(__IXGBE_TESTING, &adapter->state); 2093 2093 if (if_running) 2094 - dev_open(netdev); 2094 + ixgbe_open(netdev); 2095 2095 else if (hw->mac.ops.disable_tx_laser) 2096 2096 hw->mac.ops.disable_tx_laser(hw); 2097 2097 } else {
+76 -89
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
··· 4531 4531 case ixgbe_mac_X550: 4532 4532 case ixgbe_mac_X550EM_x: 4533 4533 IXGBE_WRITE_REG(&adapter->hw, IXGBE_VXLANCTRL, 0); 4534 - #ifdef CONFIG_IXGBE_VXLAN 4535 4534 adapter->vxlan_port = 0; 4536 - #endif 4537 4535 break; 4538 4536 default: 4539 4537 break; ··· 5992 5994 * handler is registered with the OS, the watchdog timer is started, 5993 5995 * and the stack is notified that the interface is ready. 5994 5996 **/ 5995 - static int ixgbe_open(struct net_device *netdev) 5997 + int ixgbe_open(struct net_device *netdev) 5996 5998 { 5997 5999 struct ixgbe_adapter *adapter = netdev_priv(netdev); 5998 6000 struct ixgbe_hw *hw = &adapter->hw; ··· 6094 6096 * needs to be disabled. A global MAC reset is issued to stop the 6095 6097 * hardware, and all transmit and receive resources are freed. 6096 6098 **/ 6097 - static int ixgbe_close(struct net_device *netdev) 6099 + int ixgbe_close(struct net_device *netdev) 6098 6100 { 6099 6101 struct ixgbe_adapter *adapter = netdev_priv(netdev); 6100 6102 ··· 7558 7560 struct ipv6hdr *ipv6; 7559 7561 } hdr; 7560 7562 struct tcphdr *th; 7563 + unsigned int hlen; 7561 7564 struct sk_buff *skb; 7562 - #ifdef CONFIG_IXGBE_VXLAN 7563 - u8 encap = false; 7564 - #endif /* CONFIG_IXGBE_VXLAN */ 7565 7565 __be16 vlan_id; 7566 + int l4_proto; 7566 7567 7567 7568 /* if ring doesn't have a interrupt vector, cannot perform ATR */ 7568 7569 if (!q_vector) ··· 7573 7576 7574 7577 ring->atr_count++; 7575 7578 7579 + /* currently only IPv4/IPv6 with TCP is supported */ 7580 + if ((first->protocol != htons(ETH_P_IP)) && 7581 + (first->protocol != htons(ETH_P_IPV6))) 7582 + return; 7583 + 7576 7584 /* snag network header to get L4 type and address */ 7577 7585 skb = first->skb; 7578 7586 hdr.network = skb_network_header(skb); 7579 - if (!skb->encapsulation) { 7580 - th = tcp_hdr(skb); 7581 - } else { 7582 7587 #ifdef CONFIG_IXGBE_VXLAN 7588 + if (skb->encapsulation && 7589 + first->protocol == htons(ETH_P_IP) && 7590 + hdr.ipv4->protocol != IPPROTO_UDP) { 7583 7591 struct ixgbe_adapter *adapter = q_vector->adapter; 7584 7592 7585 - if (!adapter->vxlan_port) 7586 - return; 7587 - if (first->protocol != htons(ETH_P_IP) || 7588 - hdr.ipv4->version != IPVERSION || 7589 - hdr.ipv4->protocol != IPPROTO_UDP) { 7590 - return; 7591 - } 7592 - if (ntohs(udp_hdr(skb)->dest) != adapter->vxlan_port) 7593 - return; 7594 - encap = true; 7595 - hdr.network = skb_inner_network_header(skb); 7596 - th = inner_tcp_hdr(skb); 7597 - #else 7598 - return; 7599 - #endif /* CONFIG_IXGBE_VXLAN */ 7593 + /* verify the port is recognized as VXLAN */ 7594 + if (adapter->vxlan_port && 7595 + udp_hdr(skb)->dest == adapter->vxlan_port) 7596 + hdr.network = skb_inner_network_header(skb); 7600 7597 } 7598 + #endif /* CONFIG_IXGBE_VXLAN */ 7601 7599 7602 7600 /* Currently only IPv4/IPv6 with TCP is supported */ 7603 7601 switch (hdr.ipv4->version) { 7604 7602 case IPVERSION: 7605 - if (hdr.ipv4->protocol != IPPROTO_TCP) 7606 - return; 7603 + /* access ihl as u8 to avoid unaligned access on ia64 */ 7604 + hlen = (hdr.network[0] & 0x0F) << 2; 7605 + l4_proto = hdr.ipv4->protocol; 7607 7606 break; 7608 7607 case 6: 7609 - if (likely((unsigned char *)th - hdr.network == 7610 - sizeof(struct ipv6hdr))) { 7611 - if (hdr.ipv6->nexthdr != IPPROTO_TCP) 7612 - return; 7613 - } else { 7614 - __be16 frag_off; 7615 - u8 l4_hdr; 7616 - 7617 - ipv6_skip_exthdr(skb, hdr.network - skb->data + 7618 - sizeof(struct ipv6hdr), 7619 - &l4_hdr, &frag_off); 7620 - if (unlikely(frag_off)) 7621 - return; 7622 - if (l4_hdr != IPPROTO_TCP) 7623 - return; 7624 - } 7608 + hlen = hdr.network - skb->data; 7609 + l4_proto = ipv6_find_hdr(skb, &hlen, IPPROTO_TCP, NULL, NULL); 7610 + hlen -= hdr.network - skb->data; 7625 7611 break; 7626 7612 default: 7627 7613 return; 7628 7614 } 7629 7615 7630 - /* skip this packet since it is invalid or the socket is closing */ 7631 - if (!th || th->fin) 7616 + if (l4_proto != IPPROTO_TCP) 7617 + return; 7618 + 7619 + th = (struct tcphdr *)(hdr.network + hlen); 7620 + 7621 + /* skip this packet since the socket is closing */ 7622 + if (th->fin) 7632 7623 return; 7633 7624 7634 7625 /* sample on all syn packets or once every atr sample count */ ··· 7667 7682 break; 7668 7683 } 7669 7684 7670 - #ifdef CONFIG_IXGBE_VXLAN 7671 - if (encap) 7685 + if (hdr.network != skb_network_header(skb)) 7672 7686 input.formatted.flow_type |= IXGBE_ATR_L4TYPE_TUNNEL_MASK; 7673 - #endif /* CONFIG_IXGBE_VXLAN */ 7674 7687 7675 7688 /* This assumes the Rx queue and Tx queue are bound to the same CPU */ 7676 7689 ixgbe_fdir_add_signature_filter_82599(&q_vector->adapter->hw, ··· 8192 8209 static int ixgbe_delete_clsu32(struct ixgbe_adapter *adapter, 8193 8210 struct tc_cls_u32_offload *cls) 8194 8211 { 8212 + u32 uhtid = TC_U32_USERHTID(cls->knode.handle); 8213 + u32 loc; 8195 8214 int err; 8196 8215 8216 + if ((uhtid != 0x800) && (uhtid >= IXGBE_MAX_LINK_HANDLE)) 8217 + return -EINVAL; 8218 + 8219 + loc = cls->knode.handle & 0xfffff; 8220 + 8197 8221 spin_lock(&adapter->fdir_perfect_lock); 8198 - err = ixgbe_update_ethtool_fdir_entry(adapter, NULL, cls->knode.handle); 8222 + err = ixgbe_update_ethtool_fdir_entry(adapter, NULL, loc); 8199 8223 spin_unlock(&adapter->fdir_perfect_lock); 8200 8224 return err; 8201 8225 } ··· 8211 8221 __be16 protocol, 8212 8222 struct tc_cls_u32_offload *cls) 8213 8223 { 8224 + u32 uhtid = TC_U32_USERHTID(cls->hnode.handle); 8225 + 8226 + if (uhtid >= IXGBE_MAX_LINK_HANDLE) 8227 + return -EINVAL; 8228 + 8214 8229 /* This ixgbe devices do not support hash tables at the moment 8215 8230 * so abort when given hash tables. 8216 8231 */ 8217 8232 if (cls->hnode.divisor > 0) 8218 8233 return -EINVAL; 8219 8234 8220 - set_bit(TC_U32_USERHTID(cls->hnode.handle), &adapter->tables); 8235 + set_bit(uhtid - 1, &adapter->tables); 8221 8236 return 0; 8222 8237 } 8223 8238 8224 8239 static int ixgbe_configure_clsu32_del_hnode(struct ixgbe_adapter *adapter, 8225 8240 struct tc_cls_u32_offload *cls) 8226 8241 { 8227 - clear_bit(TC_U32_USERHTID(cls->hnode.handle), &adapter->tables); 8242 + u32 uhtid = TC_U32_USERHTID(cls->hnode.handle); 8243 + 8244 + if (uhtid >= IXGBE_MAX_LINK_HANDLE) 8245 + return -EINVAL; 8246 + 8247 + clear_bit(uhtid - 1, &adapter->tables); 8228 8248 return 0; 8229 8249 } 8230 8250 ··· 8252 8252 #endif 8253 8253 int i, err = 0; 8254 8254 u8 queue; 8255 - u32 handle; 8255 + u32 uhtid, link_uhtid; 8256 8256 8257 8257 memset(&mask, 0, sizeof(union ixgbe_atr_input)); 8258 - handle = cls->knode.handle; 8258 + uhtid = TC_U32_USERHTID(cls->knode.handle); 8259 + link_uhtid = TC_U32_USERHTID(cls->knode.link_handle); 8259 8260 8260 - /* At the moment cls_u32 jumps to transport layer and skips past 8261 + /* At the moment cls_u32 jumps to network layer and skips past 8261 8262 * L2 headers. The canonical method to match L2 frames is to use 8262 8263 * negative values. However this is error prone at best but really 8263 8264 * just broken because there is no way to "know" what sort of hdr 8264 - * is in front of the transport layer. Fix cls_u32 to support L2 8265 + * is in front of the network layer. Fix cls_u32 to support L2 8265 8266 * headers when needed. 8266 8267 */ 8267 8268 if (protocol != htons(ETH_P_IP)) 8268 8269 return -EINVAL; 8269 8270 8270 - if (cls->knode.link_handle || 8271 - cls->knode.link_handle >= IXGBE_MAX_LINK_HANDLE) { 8271 + if (link_uhtid) { 8272 8272 struct ixgbe_nexthdr *nexthdr = ixgbe_ipv4_jumps; 8273 - u32 uhtid = TC_U32_USERHTID(cls->knode.link_handle); 8274 8273 8275 - if (!test_bit(uhtid, &adapter->tables)) 8274 + if (link_uhtid >= IXGBE_MAX_LINK_HANDLE) 8275 + return -EINVAL; 8276 + 8277 + if (!test_bit(link_uhtid - 1, &adapter->tables)) 8276 8278 return -EINVAL; 8277 8279 8278 8280 for (i = 0; nexthdr[i].jump; i++) { ··· 8290 8288 nexthdr->mask != cls->knode.sel->keys[0].mask) 8291 8289 return -EINVAL; 8292 8290 8293 - if (uhtid >= IXGBE_MAX_LINK_HANDLE) 8294 - return -EINVAL; 8295 - 8296 - adapter->jump_tables[uhtid] = nexthdr->jump; 8291 + adapter->jump_tables[link_uhtid] = nexthdr->jump; 8297 8292 } 8298 8293 return 0; 8299 8294 } ··· 8307 8308 * To add support for new nodes update ixgbe_model.h parse structures 8308 8309 * this function _should_ be generic try not to hardcode values here. 8309 8310 */ 8310 - if (TC_U32_USERHTID(handle) == 0x800) { 8311 + if (uhtid == 0x800) { 8311 8312 field_ptr = adapter->jump_tables[0]; 8312 8313 } else { 8313 - if (TC_U32_USERHTID(handle) >= ARRAY_SIZE(adapter->jump_tables)) 8314 + if (uhtid >= IXGBE_MAX_LINK_HANDLE) 8314 8315 return -EINVAL; 8315 8316 8316 - field_ptr = adapter->jump_tables[TC_U32_USERHTID(handle)]; 8317 + field_ptr = adapter->jump_tables[uhtid]; 8317 8318 } 8318 8319 8319 8320 if (!field_ptr) ··· 8331 8332 int j; 8332 8333 8333 8334 for (j = 0; field_ptr[j].val; j++) { 8334 - if (field_ptr[j].off == off && 8335 - field_ptr[j].mask == m) { 8335 + if (field_ptr[j].off == off) { 8336 8336 field_ptr[j].val(input, &mask, val, m); 8337 8337 input->filter.formatted.flow_type |= 8338 8338 field_ptr[j].type; ··· 8391 8393 return -EINVAL; 8392 8394 } 8393 8395 8394 - int __ixgbe_setup_tc(struct net_device *dev, u32 handle, __be16 proto, 8395 - struct tc_to_netdev *tc) 8396 + static int __ixgbe_setup_tc(struct net_device *dev, u32 handle, __be16 proto, 8397 + struct tc_to_netdev *tc) 8396 8398 { 8397 8399 struct ixgbe_adapter *adapter = netdev_priv(dev); 8398 8400 ··· 8552 8554 { 8553 8555 struct ixgbe_adapter *adapter = netdev_priv(dev); 8554 8556 struct ixgbe_hw *hw = &adapter->hw; 8555 - u16 new_port = ntohs(port); 8556 8557 8557 8558 if (!(adapter->flags & IXGBE_FLAG_VXLAN_OFFLOAD_CAPABLE)) 8558 8559 return; ··· 8559 8562 if (sa_family == AF_INET6) 8560 8563 return; 8561 8564 8562 - if (adapter->vxlan_port == new_port) 8565 + if (adapter->vxlan_port == port) 8563 8566 return; 8564 8567 8565 8568 if (adapter->vxlan_port) { 8566 8569 netdev_info(dev, 8567 8570 "Hit Max num of VXLAN ports, not adding port %d\n", 8568 - new_port); 8571 + ntohs(port)); 8569 8572 return; 8570 8573 } 8571 8574 8572 - adapter->vxlan_port = new_port; 8573 - IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, new_port); 8575 + adapter->vxlan_port = port; 8576 + IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, ntohs(port)); 8574 8577 } 8575 8578 8576 8579 /** ··· 8583 8586 __be16 port) 8584 8587 { 8585 8588 struct ixgbe_adapter *adapter = netdev_priv(dev); 8586 - u16 new_port = ntohs(port); 8587 8589 8588 8590 if (!(adapter->flags & IXGBE_FLAG_VXLAN_OFFLOAD_CAPABLE)) 8589 8591 return; ··· 8590 8594 if (sa_family == AF_INET6) 8591 8595 return; 8592 8596 8593 - if (adapter->vxlan_port != new_port) { 8597 + if (adapter->vxlan_port != port) { 8594 8598 netdev_info(dev, "Port %d was not found, not deleting\n", 8595 - new_port); 8599 + ntohs(port)); 8596 8600 return; 8597 8601 } 8598 8602 ··· 9261 9265 netdev->priv_flags |= IFF_UNICAST_FLT; 9262 9266 netdev->priv_flags |= IFF_SUPP_NOFCS; 9263 9267 9264 - #ifdef CONFIG_IXGBE_VXLAN 9265 - switch (adapter->hw.mac.type) { 9266 - case ixgbe_mac_X550: 9267 - case ixgbe_mac_X550EM_x: 9268 - netdev->hw_enc_features |= NETIF_F_RXCSUM; 9269 - break; 9270 - default: 9271 - break; 9272 - } 9273 - #endif /* CONFIG_IXGBE_VXLAN */ 9274 - 9275 9268 #ifdef CONFIG_IXGBE_DCB 9276 9269 netdev->dcbnl_ops = &dcbnl_ops; 9277 9270 #endif ··· 9314 9329 goto err_sw_init; 9315 9330 } 9316 9331 9332 + /* Set hw->mac.addr to permanent MAC address */ 9333 + ether_addr_copy(hw->mac.addr, hw->mac.perm_addr); 9317 9334 ixgbe_mac_set_default_filter(adapter); 9318 9335 9319 9336 setup_timer(&adapter->service_timer, &ixgbe_service_timer,
+6 -15
drivers/net/ethernet/intel/ixgbe/ixgbe_model.h
··· 32 32 33 33 struct ixgbe_mat_field { 34 34 unsigned int off; 35 - unsigned int mask; 36 35 int (*val)(struct ixgbe_fdir_filter *input, 37 36 union ixgbe_atr_input *mask, 38 37 u32 val, u32 m); ··· 57 58 } 58 59 59 60 static struct ixgbe_mat_field ixgbe_ipv4_fields[] = { 60 - { .off = 12, .mask = -1, .val = ixgbe_mat_prgm_sip, 61 + { .off = 12, .val = ixgbe_mat_prgm_sip, 61 62 .type = IXGBE_ATR_FLOW_TYPE_IPV4}, 62 - { .off = 16, .mask = -1, .val = ixgbe_mat_prgm_dip, 63 + { .off = 16, .val = ixgbe_mat_prgm_dip, 63 64 .type = IXGBE_ATR_FLOW_TYPE_IPV4}, 64 65 { .val = NULL } /* terminal node */ 65 66 }; 66 67 67 - static inline int ixgbe_mat_prgm_sport(struct ixgbe_fdir_filter *input, 68 + static inline int ixgbe_mat_prgm_ports(struct ixgbe_fdir_filter *input, 68 69 union ixgbe_atr_input *mask, 69 70 u32 val, u32 m) 70 71 { 71 72 input->filter.formatted.src_port = val & 0xffff; 72 73 mask->formatted.src_port = m & 0xffff; 73 - return 0; 74 - }; 74 + input->filter.formatted.dst_port = val >> 16; 75 + mask->formatted.dst_port = m >> 16; 75 76 76 - static inline int ixgbe_mat_prgm_dport(struct ixgbe_fdir_filter *input, 77 - union ixgbe_atr_input *mask, 78 - u32 val, u32 m) 79 - { 80 - input->filter.formatted.dst_port = val & 0xffff; 81 - mask->formatted.dst_port = m & 0xffff; 82 77 return 0; 83 78 }; 84 79 85 80 static struct ixgbe_mat_field ixgbe_tcp_fields[] = { 86 - {.off = 0, .mask = 0xffff, .val = ixgbe_mat_prgm_sport, 87 - .type = IXGBE_ATR_FLOW_TYPE_TCPV4}, 88 - {.off = 2, .mask = 0xffff, .val = ixgbe_mat_prgm_dport, 81 + {.off = 0, .val = ixgbe_mat_prgm_ports, 89 82 .type = IXGBE_ATR_FLOW_TYPE_TCPV4}, 90 83 { .val = NULL } /* terminal node */ 91 84 };
+1 -1
drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
··· 355 355 command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL); 356 356 if (!(command & IXGBE_SB_IOSF_CTRL_BUSY)) 357 357 break; 358 - usleep_range(10, 20); 358 + udelay(10); 359 359 } 360 360 if (ctrl) 361 361 *ctrl = command;
+2 -2
drivers/net/ethernet/intel/ixgbevf/ethtool.c
··· 680 680 681 681 if (if_running) 682 682 /* indicate we're in test mode */ 683 - dev_close(netdev); 683 + ixgbevf_close(netdev); 684 684 else 685 685 ixgbevf_reset(adapter); 686 686 ··· 692 692 693 693 clear_bit(__IXGBEVF_TESTING, &adapter->state); 694 694 if (if_running) 695 - dev_open(netdev); 695 + ixgbevf_open(netdev); 696 696 } else { 697 697 hw_dbg(&adapter->hw, "online testing starting\n"); 698 698 /* Online tests */
+2
drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
··· 486 486 extern const char ixgbevf_driver_name[]; 487 487 extern const char ixgbevf_driver_version[]; 488 488 489 + int ixgbevf_open(struct net_device *netdev); 490 + int ixgbevf_close(struct net_device *netdev); 489 491 void ixgbevf_up(struct ixgbevf_adapter *adapter); 490 492 void ixgbevf_down(struct ixgbevf_adapter *adapter); 491 493 void ixgbevf_reinit_locked(struct ixgbevf_adapter *adapter);
+10 -6
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
··· 3122 3122 * handler is registered with the OS, the watchdog timer is started, 3123 3123 * and the stack is notified that the interface is ready. 3124 3124 **/ 3125 - static int ixgbevf_open(struct net_device *netdev) 3125 + int ixgbevf_open(struct net_device *netdev) 3126 3126 { 3127 3127 struct ixgbevf_adapter *adapter = netdev_priv(netdev); 3128 3128 struct ixgbe_hw *hw = &adapter->hw; ··· 3205 3205 * needs to be disabled. A global MAC reset is issued to stop the 3206 3206 * hardware, and all transmit and receive resources are freed. 3207 3207 **/ 3208 - static int ixgbevf_close(struct net_device *netdev) 3208 + int ixgbevf_close(struct net_device *netdev) 3209 3209 { 3210 3210 struct ixgbevf_adapter *adapter = netdev_priv(netdev); 3211 3211 ··· 3692 3692 struct ixgbevf_adapter *adapter = netdev_priv(netdev); 3693 3693 struct ixgbe_hw *hw = &adapter->hw; 3694 3694 struct sockaddr *addr = p; 3695 + int err; 3695 3696 3696 3697 if (!is_valid_ether_addr(addr->sa_data)) 3697 3698 return -EADDRNOTAVAIL; 3698 3699 3699 - ether_addr_copy(netdev->dev_addr, addr->sa_data); 3700 - ether_addr_copy(hw->mac.addr, addr->sa_data); 3701 - 3702 3700 spin_lock_bh(&adapter->mbx_lock); 3703 3701 3704 - hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0); 3702 + err = hw->mac.ops.set_rar(hw, 0, addr->sa_data, 0); 3705 3703 3706 3704 spin_unlock_bh(&adapter->mbx_lock); 3705 + 3706 + if (err) 3707 + return -EPERM; 3708 + 3709 + ether_addr_copy(hw->mac.addr, addr->sa_data); 3710 + ether_addr_copy(netdev->dev_addr, addr->sa_data); 3707 3711 3708 3712 return 0; 3709 3713 }
+3 -1
drivers/net/ethernet/intel/ixgbevf/vf.c
··· 408 408 409 409 /* if nacked the address was rejected, use "perm_addr" */ 410 410 if (!ret_val && 411 - (msgbuf[0] == (IXGBE_VF_SET_MAC_ADDR | IXGBE_VT_MSGTYPE_NACK))) 411 + (msgbuf[0] == (IXGBE_VF_SET_MAC_ADDR | IXGBE_VT_MSGTYPE_NACK))) { 412 412 ixgbevf_get_mac_addr_vf(hw, hw->mac.addr); 413 + return IXGBE_ERR_MBX; 414 + } 413 415 414 416 return ret_val; 415 417 }
+17 -23
drivers/net/ethernet/marvell/mvneta.c
··· 260 260 261 261 #define MVNETA_VLAN_TAG_LEN 4 262 262 263 - #define MVNETA_CPU_D_CACHE_LINE_SIZE 32 264 263 #define MVNETA_TX_CSUM_DEF_SIZE 1600 265 264 #define MVNETA_TX_CSUM_MAX_SIZE 9800 266 265 #define MVNETA_ACC_MODE_EXT1 1 ··· 299 300 #define MVNETA_RX_PKT_SIZE(mtu) \ 300 301 ALIGN((mtu) + MVNETA_MH_SIZE + MVNETA_VLAN_TAG_LEN + \ 301 302 ETH_HLEN + ETH_FCS_LEN, \ 302 - MVNETA_CPU_D_CACHE_LINE_SIZE) 303 + cache_line_size()) 303 304 304 305 #define IS_TSO_HEADER(txq, addr) \ 305 306 ((addr >= txq->tso_hdrs_phys) && \ ··· 2763 2764 if (rxq->descs == NULL) 2764 2765 return -ENOMEM; 2765 2766 2766 - BUG_ON(rxq->descs != 2767 - PTR_ALIGN(rxq->descs, MVNETA_CPU_D_CACHE_LINE_SIZE)); 2768 - 2769 2767 rxq->last_desc = rxq->size - 1; 2770 2768 2771 2769 /* Set Rx descriptors queue starting address */ ··· 2832 2836 &txq->descs_phys, GFP_KERNEL); 2833 2837 if (txq->descs == NULL) 2834 2838 return -ENOMEM; 2835 - 2836 - /* Make sure descriptor address is cache line size aligned */ 2837 - BUG_ON(txq->descs != 2838 - PTR_ALIGN(txq->descs, MVNETA_CPU_D_CACHE_LINE_SIZE)); 2839 2839 2840 2840 txq->last_desc = txq->size - 1; 2841 2841 ··· 3042 3050 return mtu; 3043 3051 } 3044 3052 3053 + static void mvneta_percpu_enable(void *arg) 3054 + { 3055 + struct mvneta_port *pp = arg; 3056 + 3057 + enable_percpu_irq(pp->dev->irq, IRQ_TYPE_NONE); 3058 + } 3059 + 3060 + static void mvneta_percpu_disable(void *arg) 3061 + { 3062 + struct mvneta_port *pp = arg; 3063 + 3064 + disable_percpu_irq(pp->dev->irq); 3065 + } 3066 + 3045 3067 /* Change the device mtu */ 3046 3068 static int mvneta_change_mtu(struct net_device *dev, int mtu) 3047 3069 { ··· 3080 3074 * reallocation of the queues 3081 3075 */ 3082 3076 mvneta_stop_dev(pp); 3077 + on_each_cpu(mvneta_percpu_disable, pp, true); 3083 3078 3084 3079 mvneta_cleanup_txqs(pp); 3085 3080 mvneta_cleanup_rxqs(pp); ··· 3104 3097 return ret; 3105 3098 } 3106 3099 3100 + on_each_cpu(mvneta_percpu_enable, pp, true); 3107 3101 mvneta_start_dev(pp); 3108 3102 mvneta_port_up(pp); 3109 3103 ··· 3256 3248 { 3257 3249 phy_disconnect(pp->phy_dev); 3258 3250 pp->phy_dev = NULL; 3259 - } 3260 - 3261 - static void mvneta_percpu_enable(void *arg) 3262 - { 3263 - struct mvneta_port *pp = arg; 3264 - 3265 - enable_percpu_irq(pp->dev->irq, IRQ_TYPE_NONE); 3266 - } 3267 - 3268 - static void mvneta_percpu_disable(void *arg) 3269 - { 3270 - struct mvneta_port *pp = arg; 3271 - 3272 - disable_percpu_irq(pp->dev->irq); 3273 3251 } 3274 3252 3275 3253 /* Electing a CPU must be done in an atomic way: it should be done
+4 -14
drivers/net/ethernet/marvell/mvpp2.c
··· 321 321 /* Lbtd 802.3 type */ 322 322 #define MVPP2_IP_LBDT_TYPE 0xfffa 323 323 324 - #define MVPP2_CPU_D_CACHE_LINE_SIZE 32 325 324 #define MVPP2_TX_CSUM_MAX_SIZE 9800 326 325 327 326 /* Timeout constants */ ··· 376 377 377 378 #define MVPP2_RX_PKT_SIZE(mtu) \ 378 379 ALIGN((mtu) + MVPP2_MH_SIZE + MVPP2_VLAN_TAG_LEN + \ 379 - ETH_HLEN + ETH_FCS_LEN, MVPP2_CPU_D_CACHE_LINE_SIZE) 380 + ETH_HLEN + ETH_FCS_LEN, cache_line_size()) 380 381 381 382 #define MVPP2_RX_BUF_SIZE(pkt_size) ((pkt_size) + NET_SKB_PAD) 382 383 #define MVPP2_RX_TOTAL_SIZE(buf_size) ((buf_size) + MVPP2_SKB_SHINFO_SIZE) ··· 4492 4493 if (!aggr_txq->descs) 4493 4494 return -ENOMEM; 4494 4495 4495 - /* Make sure descriptor address is cache line size aligned */ 4496 - BUG_ON(aggr_txq->descs != 4497 - PTR_ALIGN(aggr_txq->descs, MVPP2_CPU_D_CACHE_LINE_SIZE)); 4498 - 4499 4496 aggr_txq->last_desc = aggr_txq->size - 1; 4500 4497 4501 4498 /* Aggr TXQ no reset WA */ ··· 4520 4525 &rxq->descs_phys, GFP_KERNEL); 4521 4526 if (!rxq->descs) 4522 4527 return -ENOMEM; 4523 - 4524 - BUG_ON(rxq->descs != 4525 - PTR_ALIGN(rxq->descs, MVPP2_CPU_D_CACHE_LINE_SIZE)); 4526 4528 4527 4529 rxq->last_desc = rxq->size - 1; 4528 4530 ··· 4607 4615 &txq->descs_phys, GFP_KERNEL); 4608 4616 if (!txq->descs) 4609 4617 return -ENOMEM; 4610 - 4611 - /* Make sure descriptor address is cache line size aligned */ 4612 - BUG_ON(txq->descs != 4613 - PTR_ALIGN(txq->descs, MVPP2_CPU_D_CACHE_LINE_SIZE)); 4614 4618 4615 4619 txq->last_desc = txq->size - 1; 4616 4620 ··· 6047 6059 6048 6060 /* Map physical Rx queue to port's logical Rx queue */ 6049 6061 rxq = devm_kzalloc(dev, sizeof(*rxq), GFP_KERNEL); 6050 - if (!rxq) 6062 + if (!rxq) { 6063 + err = -ENOMEM; 6051 6064 goto err_free_percpu; 6065 + } 6052 6066 /* Map this Rx queue to a physical queue */ 6053 6067 rxq->id = port->first_rxq + queue; 6054 6068 rxq->port = port->id;
+1 -1
drivers/net/ethernet/qlogic/qed/qed_int.c
··· 2750 2750 int qed_int_igu_enable(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, 2751 2751 enum qed_int_mode int_mode) 2752 2752 { 2753 - int rc; 2753 + int rc = 0; 2754 2754 2755 2755 /* Configure AEU signal change to produce attentions */ 2756 2756 qed_wr(p_hwfn, p_ptt, IGU_REG_ATTENTION_ENABLE, 0);
+1 -1
drivers/net/ethernet/qlogic/qlge/qlge.h
··· 18 18 */ 19 19 #define DRV_NAME "qlge" 20 20 #define DRV_STRING "QLogic 10 Gigabit PCI-E Ethernet Driver " 21 - #define DRV_VERSION "1.00.00.34" 21 + #define DRV_VERSION "1.00.00.35" 22 22 23 23 #define WQ_ADDR_ALIGN 0x3 /* 4 byte alignment */ 24 24
+1 -1
drivers/net/ethernet/renesas/ravb_main.c
··· 1377 1377 1378 1378 /* TAG and timestamp required flag */ 1379 1379 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; 1380 - skb_tx_timestamp(skb); 1381 1380 desc->tagh_tsr = (ts_skb->tag >> 4) | TX_TSR; 1382 1381 desc->ds_tagl |= le16_to_cpu(ts_skb->tag << 12); 1383 1382 } 1384 1383 1384 + skb_tx_timestamp(skb); 1385 1385 /* Descriptor type must be set after all the above writes */ 1386 1386 dma_wmb(); 1387 1387 desc->die_dt = DT_FEND;
+2 -2
drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c
··· 155 155 return 0; 156 156 157 157 err_rx_irq_unmap: 158 - while (--i) 158 + while (i--) 159 159 irq_dispose_mapping(priv->rxq[i]->irq_no); 160 160 i = SXGBE_TX_QUEUES; 161 161 err_tx_irq_unmap: 162 - while (--i) 162 + while (i--) 163 163 irq_dispose_mapping(priv->txq[i]->irq_no); 164 164 irq_dispose_mapping(priv->irq); 165 165 err_drv_remove:
+8 -8
drivers/net/ethernet/stmicro/stmmac/norm_desc.c
··· 199 199 { 200 200 unsigned int tdes1 = p->des1; 201 201 202 - if (mode == STMMAC_CHAIN_MODE) 203 - norm_set_tx_desc_len_on_chain(p, len); 204 - else 205 - norm_set_tx_desc_len_on_ring(p, len); 206 - 207 202 if (is_fs) 208 203 tdes1 |= TDES1_FIRST_SEGMENT; 209 204 else ··· 212 217 if (ls) 213 218 tdes1 |= TDES1_LAST_SEGMENT; 214 219 215 - if (tx_own) 216 - tdes1 |= TDES0_OWN; 217 - 218 220 p->des1 = tdes1; 221 + 222 + if (mode == STMMAC_CHAIN_MODE) 223 + norm_set_tx_desc_len_on_chain(p, len); 224 + else 225 + norm_set_tx_desc_len_on_ring(p, len); 226 + 227 + if (tx_own) 228 + p->des0 |= TDES0_OWN; 219 229 } 220 230 221 231 static void ndesc_set_tx_ic(struct dma_desc *p)
+5 -11
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 278 278 */ 279 279 bool stmmac_eee_init(struct stmmac_priv *priv) 280 280 { 281 - char *phy_bus_name = priv->plat->phy_bus_name; 282 281 unsigned long flags; 283 282 bool ret = false; 284 283 ··· 289 290 goto out; 290 291 291 292 /* Never init EEE in case of a switch is attached */ 292 - if (phy_bus_name && (!strcmp(phy_bus_name, "fixed"))) 293 + if (priv->phydev->is_pseudo_fixed_link) 293 294 goto out; 294 295 295 296 /* MAC core supports the EEE feature. */ ··· 826 827 phydev = of_phy_connect(dev, priv->plat->phy_node, 827 828 &stmmac_adjust_link, 0, interface); 828 829 } else { 829 - if (priv->plat->phy_bus_name) 830 - snprintf(bus_id, MII_BUS_ID_SIZE, "%s-%x", 831 - priv->plat->phy_bus_name, priv->plat->bus_id); 832 - else 833 - snprintf(bus_id, MII_BUS_ID_SIZE, "stmmac-%x", 834 - priv->plat->bus_id); 830 + snprintf(bus_id, MII_BUS_ID_SIZE, "stmmac-%x", 831 + priv->plat->bus_id); 835 832 836 833 snprintf(phy_id_fmt, MII_BUS_ID_SIZE + 3, PHY_ID_FMT, bus_id, 837 834 priv->plat->phy_addr); ··· 866 871 } 867 872 868 873 /* If attached to a switch, there is no reason to poll phy handler */ 869 - if (priv->plat->phy_bus_name) 870 - if (!strcmp(priv->plat->phy_bus_name, "fixed")) 871 - phydev->irq = PHY_IGNORE_INTERRUPT; 874 + if (phydev->is_pseudo_fixed_link) 875 + phydev->irq = PHY_IGNORE_INTERRUPT; 872 876 873 877 pr_debug("stmmac_init_phy: %s: attached to PHY (UID 0x%x)" 874 878 " Link = %d\n", dev->name, phydev->phy_id, phydev->link);
+1 -9
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
··· 198 198 struct mii_bus *new_bus; 199 199 struct stmmac_priv *priv = netdev_priv(ndev); 200 200 struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data; 201 - int addr, found; 202 201 struct device_node *mdio_node = priv->plat->mdio_node; 202 + int addr, found; 203 203 204 204 if (!mdio_bus_data) 205 205 return 0; 206 - 207 - if (IS_ENABLED(CONFIG_OF)) { 208 - if (mdio_node) { 209 - netdev_dbg(ndev, "FOUND MDIO subnode\n"); 210 - } else { 211 - netdev_warn(ndev, "No MDIO subnode found\n"); 212 - } 213 - } 214 206 215 207 new_bus = mdiobus_alloc(); 216 208 if (new_bus == NULL)
+66 -25
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
··· 132 132 } 133 133 134 134 /** 135 + * stmmac_dt_phy - parse device-tree driver parameters to allocate PHY resources 136 + * @plat: driver data platform structure 137 + * @np: device tree node 138 + * @dev: device pointer 139 + * Description: 140 + * The mdio bus will be allocated in case of a phy transceiver is on board; 141 + * it will be NULL if the fixed-link is configured. 142 + * If there is the "snps,dwmac-mdio" sub-node the mdio will be allocated 143 + * in any case (for DSA, mdio must be registered even if fixed-link). 144 + * The table below sums the supported configurations: 145 + * ------------------------------- 146 + * snps,phy-addr | Y 147 + * ------------------------------- 148 + * phy-handle | Y 149 + * ------------------------------- 150 + * fixed-link | N 151 + * ------------------------------- 152 + * snps,dwmac-mdio | 153 + * even if | Y 154 + * fixed-link | 155 + * ------------------------------- 156 + * 157 + * It returns 0 in case of success otherwise -ENODEV. 158 + */ 159 + static int stmmac_dt_phy(struct plat_stmmacenet_data *plat, 160 + struct device_node *np, struct device *dev) 161 + { 162 + bool mdio = true; 163 + 164 + /* If phy-handle property is passed from DT, use it as the PHY */ 165 + plat->phy_node = of_parse_phandle(np, "phy-handle", 0); 166 + if (plat->phy_node) 167 + dev_dbg(dev, "Found phy-handle subnode\n"); 168 + 169 + /* If phy-handle is not specified, check if we have a fixed-phy */ 170 + if (!plat->phy_node && of_phy_is_fixed_link(np)) { 171 + if ((of_phy_register_fixed_link(np) < 0)) 172 + return -ENODEV; 173 + 174 + dev_dbg(dev, "Found fixed-link subnode\n"); 175 + plat->phy_node = of_node_get(np); 176 + mdio = false; 177 + } 178 + 179 + /* If snps,dwmac-mdio is passed from DT, always register the MDIO */ 180 + for_each_child_of_node(np, plat->mdio_node) { 181 + if (of_device_is_compatible(plat->mdio_node, "snps,dwmac-mdio")) 182 + break; 183 + } 184 + 185 + if (plat->mdio_node) { 186 + dev_dbg(dev, "Found MDIO subnode\n"); 187 + mdio = true; 188 + } 189 + 190 + if (mdio) 191 + plat->mdio_bus_data = 192 + devm_kzalloc(dev, sizeof(struct stmmac_mdio_bus_data), 193 + GFP_KERNEL); 194 + return 0; 195 + } 196 + 197 + /** 135 198 * stmmac_probe_config_dt - parse device-tree driver parameters 136 199 * @pdev: platform_device structure 137 200 * @plat: driver data platform structure ··· 209 146 struct device_node *np = pdev->dev.of_node; 210 147 struct plat_stmmacenet_data *plat; 211 148 struct stmmac_dma_cfg *dma_cfg; 212 - struct device_node *child_node = NULL; 213 149 214 150 plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL); 215 151 if (!plat) ··· 228 166 /* Default to phy auto-detection */ 229 167 plat->phy_addr = -1; 230 168 231 - /* If we find a phy-handle property, use it as the PHY */ 232 - plat->phy_node = of_parse_phandle(np, "phy-handle", 0); 233 - 234 - /* If phy-handle is not specified, check if we have a fixed-phy */ 235 - if (!plat->phy_node && of_phy_is_fixed_link(np)) { 236 - if ((of_phy_register_fixed_link(np) < 0)) 237 - return ERR_PTR(-ENODEV); 238 - 239 - plat->phy_node = of_node_get(np); 240 - } 241 - 242 - for_each_child_of_node(np, child_node) 243 - if (of_device_is_compatible(child_node, "snps,dwmac-mdio")) { 244 - plat->mdio_node = child_node; 245 - break; 246 - } 247 - 248 169 /* "snps,phy-addr" is not a standard property. Mark it as deprecated 249 170 * and warn of its use. Remove this when phy node support is added. 250 171 */ 251 172 if (of_property_read_u32(np, "snps,phy-addr", &plat->phy_addr) == 0) 252 173 dev_warn(&pdev->dev, "snps,phy-addr property is deprecated\n"); 253 174 254 - if ((plat->phy_node && !of_phy_is_fixed_link(np)) || !plat->mdio_node) 255 - plat->mdio_bus_data = NULL; 256 - else 257 - plat->mdio_bus_data = 258 - devm_kzalloc(&pdev->dev, 259 - sizeof(struct stmmac_mdio_bus_data), 260 - GFP_KERNEL); 175 + /* To Configure PHY by using all device-tree supported properties */ 176 + if (stmmac_dt_phy(plat, np, &pdev->dev)) 177 + return ERR_PTR(-ENODEV); 261 178 262 179 of_property_read_u32(np, "tx-fifo-depth", &plat->tx_fifo_size); 263 180
+4
drivers/net/phy/bcm7xxx.c
··· 339 339 BCM7XXX_28NM_GPHY(PHY_ID_BCM7439, "Broadcom BCM7439"), 340 340 BCM7XXX_28NM_GPHY(PHY_ID_BCM7439_2, "Broadcom BCM7439 (2)"), 341 341 BCM7XXX_28NM_GPHY(PHY_ID_BCM7445, "Broadcom BCM7445"), 342 + BCM7XXX_40NM_EPHY(PHY_ID_BCM7346, "Broadcom BCM7346"), 343 + BCM7XXX_40NM_EPHY(PHY_ID_BCM7362, "Broadcom BCM7362"), 342 344 BCM7XXX_40NM_EPHY(PHY_ID_BCM7425, "Broadcom BCM7425"), 343 345 BCM7XXX_40NM_EPHY(PHY_ID_BCM7429, "Broadcom BCM7429"), 344 346 BCM7XXX_40NM_EPHY(PHY_ID_BCM7435, "Broadcom BCM7435"), ··· 350 348 { PHY_ID_BCM7250, 0xfffffff0, }, 351 349 { PHY_ID_BCM7364, 0xfffffff0, }, 352 350 { PHY_ID_BCM7366, 0xfffffff0, }, 351 + { PHY_ID_BCM7346, 0xfffffff0, }, 352 + { PHY_ID_BCM7362, 0xfffffff0, }, 353 353 { PHY_ID_BCM7425, 0xfffffff0, }, 354 354 { PHY_ID_BCM7429, 0xfffffff0, }, 355 355 { PHY_ID_BCM7439, 0xfffffff0, },
+5
drivers/net/team/team.c
··· 1198 1198 goto err_dev_open; 1199 1199 } 1200 1200 1201 + dev_uc_sync_multiple(port_dev, dev); 1202 + dev_mc_sync_multiple(port_dev, dev); 1203 + 1201 1204 err = vlan_vids_add_by_dev(port_dev, dev); 1202 1205 if (err) { 1203 1206 netdev_err(dev, "Failed to add vlan ids to device %s\n", ··· 1264 1261 vlan_vids_del_by_dev(port_dev, dev); 1265 1262 1266 1263 err_vids_add: 1264 + dev_uc_unsync(port_dev, dev); 1265 + dev_mc_unsync(port_dev, dev); 1267 1266 dev_close(port_dev); 1268 1267 1269 1268 err_dev_open:
+5 -3
drivers/net/tun.c
··· 622 622 623 623 /* Re-attach the filter to persist device */ 624 624 if (!skip_filter && (tun->filter_attached == true)) { 625 - err = sk_attach_filter(&tun->fprog, tfile->socket.sk); 625 + err = __sk_attach_filter(&tun->fprog, tfile->socket.sk, 626 + lockdep_rtnl_is_held()); 626 627 if (!err) 627 628 goto out; 628 629 } ··· 1823 1822 1824 1823 for (i = 0; i < n; i++) { 1825 1824 tfile = rtnl_dereference(tun->tfiles[i]); 1826 - sk_detach_filter(tfile->socket.sk); 1825 + __sk_detach_filter(tfile->socket.sk, lockdep_rtnl_is_held()); 1827 1826 } 1828 1827 1829 1828 tun->filter_attached = false; ··· 1836 1835 1837 1836 for (i = 0; i < tun->numqueues; i++) { 1838 1837 tfile = rtnl_dereference(tun->tfiles[i]); 1839 - ret = sk_attach_filter(&tun->fprog, tfile->socket.sk); 1838 + ret = __sk_attach_filter(&tun->fprog, tfile->socket.sk, 1839 + lockdep_rtnl_is_held()); 1840 1840 if (ret) { 1841 1841 tun_detach_filter(tun, i); 1842 1842 return ret;
+7
drivers/net/usb/cdc_ncm.c
··· 1626 1626 .driver_info = (unsigned long) &wwan_info, 1627 1627 }, 1628 1628 1629 + /* Telit LE910 V2 */ 1630 + { USB_DEVICE_AND_INTERFACE_INFO(0x1bc7, 0x0036, 1631 + USB_CLASS_COMM, 1632 + USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE), 1633 + .driver_info = (unsigned long)&wwan_noarp_info, 1634 + }, 1635 + 1629 1636 /* DW5812 LTE Verizon Mobile Broadband Card 1630 1637 * Unlike DW5550 this device requires FLAG_NOARP 1631 1638 */
+1 -1
drivers/net/usb/plusb.c
··· 38 38 * HEADS UP: this handshaking isn't all that robust. This driver 39 39 * gets confused easily if you unplug one end of the cable then 40 40 * try to connect it again; you'll need to restart both ends. The 41 - * "naplink" software (used by some PlayStation/2 deveopers) does 41 + * "naplink" software (used by some PlayStation/2 developers) does 42 42 * the handshaking much better! Also, sometimes this hardware 43 43 * seems to get wedged under load. Prolific docs are weak, and 44 44 * don't identify differences between PL2301 and PL2302, much less
+1
drivers/net/usb/qmi_wwan.c
··· 844 844 {QMI_FIXED_INTF(0x19d2, 0x1426, 2)}, /* ZTE MF91 */ 845 845 {QMI_FIXED_INTF(0x19d2, 0x1428, 2)}, /* Telewell TW-LTE 4G v2 */ 846 846 {QMI_FIXED_INTF(0x19d2, 0x2002, 4)}, /* ZTE (Vodafone) K3765-Z */ 847 + {QMI_FIXED_INTF(0x2001, 0x7e19, 4)}, /* D-Link DWM-221 B1 */ 847 848 {QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)}, /* Sierra Wireless MC7700 */ 848 849 {QMI_FIXED_INTF(0x114f, 0x68a2, 8)}, /* Sierra Wireless MC7750 */ 849 850 {QMI_FIXED_INTF(0x1199, 0x68a2, 8)}, /* Sierra Wireless MC7710 in QMI mode */
+2
include/linux/brcmphy.h
··· 24 24 #define PHY_ID_BCM7250 0xae025280 25 25 #define PHY_ID_BCM7364 0xae025260 26 26 #define PHY_ID_BCM7366 0x600d8490 27 + #define PHY_ID_BCM7346 0x600d8650 28 + #define PHY_ID_BCM7362 0x600d84b0 27 29 #define PHY_ID_BCM7425 0x600d86b0 28 30 #define PHY_ID_BCM7429 0x600d8730 29 31 #define PHY_ID_BCM7435 0x600d8750
+4
include/linux/filter.h
··· 465 465 void bpf_prog_destroy(struct bpf_prog *fp); 466 466 467 467 int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk); 468 + int __sk_attach_filter(struct sock_fprog *fprog, struct sock *sk, 469 + bool locked); 468 470 int sk_attach_bpf(u32 ufd, struct sock *sk); 469 471 int sk_reuseport_attach_filter(struct sock_fprog *fprog, struct sock *sk); 470 472 int sk_reuseport_attach_bpf(u32 ufd, struct sock *sk); 471 473 int sk_detach_filter(struct sock *sk); 474 + int __sk_detach_filter(struct sock *sk, bool locked); 475 + 472 476 int sk_get_filter(struct sock *sk, struct sock_filter __user *filter, 473 477 unsigned int len); 474 478
+4
include/linux/netfilter/ipset/ip_set.h
··· 234 234 spinlock_t lock; 235 235 /* References to the set */ 236 236 u32 ref; 237 + /* References to the set for netlink events like dump, 238 + * ref can be swapped out by ip_set_swap 239 + */ 240 + u32 ref_netlink; 237 241 /* The core set type */ 238 242 struct ip_set_type *type; 239 243 /* The type variant doing the real job */
-1
include/linux/stmmac.h
··· 108 108 }; 109 109 110 110 struct plat_stmmacenet_data { 111 - char *phy_bus_name; 112 111 int bus_id; 113 112 int phy_addr; 114 113 int interface;
+1
include/uapi/linux/bpf.h
··· 375 375 }; 376 376 __u8 tunnel_tos; 377 377 __u8 tunnel_ttl; 378 + __u16 tunnel_ext; 378 379 __u32 tunnel_label; 379 380 }; 380 381
+4 -2
kernel/bpf/syscall.c
··· 137 137 "map_type:\t%u\n" 138 138 "key_size:\t%u\n" 139 139 "value_size:\t%u\n" 140 - "max_entries:\t%u\n", 140 + "max_entries:\t%u\n" 141 + "map_flags:\t%#x\n", 141 142 map->map_type, 142 143 map->key_size, 143 144 map->value_size, 144 - map->max_entries); 145 + map->max_entries, 146 + map->map_flags); 145 147 } 146 148 #endif 147 149
+1 -1
net/bridge/br_stp.c
··· 582 582 int err; 583 583 584 584 err = switchdev_port_attr_set(br->dev, &attr); 585 - if (err) 585 + if (err && err != -EOPNOTSUPP) 586 586 return err; 587 587 588 588 br->ageing_time = t;
+4
net/bridge/netfilter/ebtables.c
··· 1521 1521 if (copy_from_user(&tmp, user, sizeof(tmp))) 1522 1522 return -EFAULT; 1523 1523 1524 + tmp.name[sizeof(tmp.name) - 1] = '\0'; 1525 + 1524 1526 t = find_table_lock(net, tmp.name, &ret, &ebt_mutex); 1525 1527 if (!t) 1526 1528 return ret; ··· 2333 2331 2334 2332 if (copy_from_user(&tmp, user, sizeof(tmp))) 2335 2333 return -EFAULT; 2334 + 2335 + tmp.name[sizeof(tmp.name) - 1] = '\0'; 2336 2336 2337 2337 t = find_table_lock(net, tmp.name, &ret, &ebt_mutex); 2338 2338 if (!t)
+10 -10
net/bridge/netfilter/nft_reject_bridge.c
··· 40 40 /* We cannot use oldskb->dev, it can be either bridge device (NF_BRIDGE INPUT) 41 41 * or the bridge port (NF_BRIDGE PREROUTING). 42 42 */ 43 - static void nft_reject_br_send_v4_tcp_reset(struct sk_buff *oldskb, 43 + static void nft_reject_br_send_v4_tcp_reset(struct net *net, 44 + struct sk_buff *oldskb, 44 45 const struct net_device *dev, 45 46 int hook) 46 47 { ··· 49 48 struct iphdr *niph; 50 49 const struct tcphdr *oth; 51 50 struct tcphdr _oth; 52 - struct net *net = sock_net(oldskb->sk); 53 51 54 52 if (!nft_bridge_iphdr_validate(oldskb)) 55 53 return; ··· 75 75 br_deliver(br_port_get_rcu(dev), nskb); 76 76 } 77 77 78 - static void nft_reject_br_send_v4_unreach(struct sk_buff *oldskb, 78 + static void nft_reject_br_send_v4_unreach(struct net *net, 79 + struct sk_buff *oldskb, 79 80 const struct net_device *dev, 80 81 int hook, u8 code) 81 82 { ··· 87 86 void *payload; 88 87 __wsum csum; 89 88 u8 proto; 90 - struct net *net = sock_net(oldskb->sk); 91 89 92 90 if (oldskb->csum_bad || !nft_bridge_iphdr_validate(oldskb)) 93 91 return; ··· 273 273 case htons(ETH_P_IP): 274 274 switch (priv->type) { 275 275 case NFT_REJECT_ICMP_UNREACH: 276 - nft_reject_br_send_v4_unreach(pkt->skb, pkt->in, 277 - pkt->hook, 276 + nft_reject_br_send_v4_unreach(pkt->net, pkt->skb, 277 + pkt->in, pkt->hook, 278 278 priv->icmp_code); 279 279 break; 280 280 case NFT_REJECT_TCP_RST: 281 - nft_reject_br_send_v4_tcp_reset(pkt->skb, pkt->in, 282 - pkt->hook); 281 + nft_reject_br_send_v4_tcp_reset(pkt->net, pkt->skb, 282 + pkt->in, pkt->hook); 283 283 break; 284 284 case NFT_REJECT_ICMPX_UNREACH: 285 - nft_reject_br_send_v4_unreach(pkt->skb, pkt->in, 286 - pkt->hook, 285 + nft_reject_br_send_v4_unreach(pkt->net, pkt->skb, 286 + pkt->in, pkt->hook, 287 287 nft_reject_icmp_code(priv->icmp_code)); 288 288 break; 289 289 }
+25 -13
net/core/filter.c
··· 1149 1149 } 1150 1150 EXPORT_SYMBOL_GPL(bpf_prog_destroy); 1151 1151 1152 - static int __sk_attach_prog(struct bpf_prog *prog, struct sock *sk) 1152 + static int __sk_attach_prog(struct bpf_prog *prog, struct sock *sk, 1153 + bool locked) 1153 1154 { 1154 1155 struct sk_filter *fp, *old_fp; 1155 1156 ··· 1166 1165 return -ENOMEM; 1167 1166 } 1168 1167 1169 - old_fp = rcu_dereference_protected(sk->sk_filter, 1170 - sock_owned_by_user(sk)); 1168 + old_fp = rcu_dereference_protected(sk->sk_filter, locked); 1171 1169 rcu_assign_pointer(sk->sk_filter, fp); 1172 - 1173 1170 if (old_fp) 1174 1171 sk_filter_uncharge(sk, old_fp); 1175 1172 ··· 1246 1247 * occurs or there is insufficient memory for the filter a negative 1247 1248 * errno code is returned. On success the return is zero. 1248 1249 */ 1249 - int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk) 1250 + int __sk_attach_filter(struct sock_fprog *fprog, struct sock *sk, 1251 + bool locked) 1250 1252 { 1251 1253 struct bpf_prog *prog = __get_filter(fprog, sk); 1252 1254 int err; ··· 1255 1255 if (IS_ERR(prog)) 1256 1256 return PTR_ERR(prog); 1257 1257 1258 - err = __sk_attach_prog(prog, sk); 1258 + err = __sk_attach_prog(prog, sk, locked); 1259 1259 if (err < 0) { 1260 1260 __bpf_prog_release(prog); 1261 1261 return err; ··· 1263 1263 1264 1264 return 0; 1265 1265 } 1266 - EXPORT_SYMBOL_GPL(sk_attach_filter); 1266 + EXPORT_SYMBOL_GPL(__sk_attach_filter); 1267 + 1268 + int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk) 1269 + { 1270 + return __sk_attach_filter(fprog, sk, sock_owned_by_user(sk)); 1271 + } 1267 1272 1268 1273 int sk_reuseport_attach_filter(struct sock_fprog *fprog, struct sock *sk) 1269 1274 { ··· 1314 1309 if (IS_ERR(prog)) 1315 1310 return PTR_ERR(prog); 1316 1311 1317 - err = __sk_attach_prog(prog, sk); 1312 + err = __sk_attach_prog(prog, sk, sock_owned_by_user(sk)); 1318 1313 if (err < 0) { 1319 1314 bpf_prog_put(prog); 1320 1315 return err; ··· 1769 1764 if (unlikely(size != sizeof(struct bpf_tunnel_key))) { 1770 1765 switch (size) { 1771 1766 case offsetof(struct bpf_tunnel_key, tunnel_label): 1767 + case offsetof(struct bpf_tunnel_key, tunnel_ext): 1772 1768 goto set_compat; 1773 1769 case offsetof(struct bpf_tunnel_key, remote_ipv6[1]): 1774 1770 /* Fixup deprecated structure layouts here, so we have ··· 1855 1849 if (unlikely(size != sizeof(struct bpf_tunnel_key))) { 1856 1850 switch (size) { 1857 1851 case offsetof(struct bpf_tunnel_key, tunnel_label): 1852 + case offsetof(struct bpf_tunnel_key, tunnel_ext): 1858 1853 case offsetof(struct bpf_tunnel_key, remote_ipv6[1]): 1859 1854 /* Fixup deprecated structure layouts here, so we have 1860 1855 * a common path later on. ··· 1868 1861 return -EINVAL; 1869 1862 } 1870 1863 } 1871 - if (unlikely(!(flags & BPF_F_TUNINFO_IPV6) && from->tunnel_label)) 1864 + if (unlikely((!(flags & BPF_F_TUNINFO_IPV6) && from->tunnel_label) || 1865 + from->tunnel_ext)) 1872 1866 return -EINVAL; 1873 1867 1874 1868 skb_dst_drop(skb); ··· 2255 2247 } 2256 2248 late_initcall(register_sk_filter_ops); 2257 2249 2258 - int sk_detach_filter(struct sock *sk) 2250 + int __sk_detach_filter(struct sock *sk, bool locked) 2259 2251 { 2260 2252 int ret = -ENOENT; 2261 2253 struct sk_filter *filter; ··· 2263 2255 if (sock_flag(sk, SOCK_FILTER_LOCKED)) 2264 2256 return -EPERM; 2265 2257 2266 - filter = rcu_dereference_protected(sk->sk_filter, 2267 - sock_owned_by_user(sk)); 2258 + filter = rcu_dereference_protected(sk->sk_filter, locked); 2268 2259 if (filter) { 2269 2260 RCU_INIT_POINTER(sk->sk_filter, NULL); 2270 2261 sk_filter_uncharge(sk, filter); ··· 2272 2265 2273 2266 return ret; 2274 2267 } 2275 - EXPORT_SYMBOL_GPL(sk_detach_filter); 2268 + EXPORT_SYMBOL_GPL(__sk_detach_filter); 2269 + 2270 + int sk_detach_filter(struct sock *sk) 2271 + { 2272 + return __sk_detach_filter(sk, sock_owned_by_user(sk)); 2273 + } 2276 2274 2277 2275 int sk_get_filter(struct sock *sk, struct sock_filter __user *ubuf, 2278 2276 unsigned int len)
+2 -1
net/core/netpoll.c
··· 603 603 const struct net_device_ops *ops; 604 604 int err; 605 605 606 - np->dev = ndev; 607 606 strlcpy(np->dev_name, ndev->name, IFNAMSIZ); 608 607 INIT_WORK(&np->cleanup_work, netpoll_async_cleanup); 609 608 ··· 669 670 goto unlock; 670 671 } 671 672 dev_hold(ndev); 673 + np->dev = ndev; 672 674 673 675 if (netdev_master_upper_dev_get(ndev)) { 674 676 np_err(np, "%s is a slave device, aborting\n", np->dev_name); ··· 770 770 return 0; 771 771 772 772 put: 773 + np->dev = NULL; 773 774 dev_put(ndev); 774 775 unlock: 775 776 rtnl_unlock();
+1
net/core/rtnetlink.c
··· 909 909 + rtnl_link_get_af_size(dev, ext_filter_mask) /* IFLA_AF_SPEC */ 910 910 + nla_total_size(MAX_PHYS_ITEM_ID_LEN) /* IFLA_PHYS_PORT_ID */ 911 911 + nla_total_size(MAX_PHYS_ITEM_ID_LEN) /* IFLA_PHYS_SWITCH_ID */ 912 + + nla_total_size(IFNAMSIZ) /* IFLA_PHYS_PORT_NAME */ 912 913 + nla_total_size(1); /* IFLA_PROTO_DOWN */ 913 914 914 915 }
+16
net/ipv4/fou.c
··· 195 195 u8 proto = NAPI_GRO_CB(skb)->proto; 196 196 const struct net_offload **offloads; 197 197 198 + /* We can clear the encap_mark for FOU as we are essentially doing 199 + * one of two possible things. We are either adding an L4 tunnel 200 + * header to the outer L3 tunnel header, or we are are simply 201 + * treating the GRE tunnel header as though it is a UDP protocol 202 + * specific header such as VXLAN or GENEVE. 203 + */ 204 + NAPI_GRO_CB(skb)->encap_mark = 0; 205 + 198 206 rcu_read_lock(); 199 207 offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads; 200 208 ops = rcu_dereference(offloads[proto]); ··· 359 351 continue; 360 352 } 361 353 } 354 + 355 + /* We can clear the encap_mark for GUE as we are essentially doing 356 + * one of two possible things. We are either adding an L4 tunnel 357 + * header to the outer L3 tunnel header, or we are are simply 358 + * treating the GRE tunnel header as though it is a UDP protocol 359 + * specific header such as VXLAN or GENEVE. 360 + */ 361 + NAPI_GRO_CB(skb)->encap_mark = 0; 362 362 363 363 rcu_read_lock(); 364 364 offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
+2 -2
net/ipv4/ip_tunnel_core.c
··· 372 372 if (nla_put_be64(skb, LWTUNNEL_IP6_ID, tun_info->key.tun_id) || 373 373 nla_put_in6_addr(skb, LWTUNNEL_IP6_DST, &tun_info->key.u.ipv6.dst) || 374 374 nla_put_in6_addr(skb, LWTUNNEL_IP6_SRC, &tun_info->key.u.ipv6.src) || 375 - nla_put_u8(skb, LWTUNNEL_IP6_HOPLIMIT, tun_info->key.tos) || 376 - nla_put_u8(skb, LWTUNNEL_IP6_TC, tun_info->key.ttl) || 375 + nla_put_u8(skb, LWTUNNEL_IP6_TC, tun_info->key.tos) || 376 + nla_put_u8(skb, LWTUNNEL_IP6_HOPLIMIT, tun_info->key.ttl) || 377 377 nla_put_be16(skb, LWTUNNEL_IP6_FLAGS, tun_info->key.tun_flags)) 378 378 return -ENOMEM; 379 379
+23 -20
net/ipv4/netfilter/arp_tables.c
··· 359 359 } 360 360 361 361 /* All zeroes == unconditional rule. */ 362 - static inline bool unconditional(const struct arpt_arp *arp) 362 + static inline bool unconditional(const struct arpt_entry *e) 363 363 { 364 364 static const struct arpt_arp uncond; 365 365 366 - return memcmp(arp, &uncond, sizeof(uncond)) == 0; 366 + return e->target_offset == sizeof(struct arpt_entry) && 367 + memcmp(&e->arp, &uncond, sizeof(uncond)) == 0; 367 368 } 368 369 369 370 /* Figures out from what hook each rule can be called: returns 0 if ··· 403 402 |= ((1 << hook) | (1 << NF_ARP_NUMHOOKS)); 404 403 405 404 /* Unconditional return/END. */ 406 - if ((e->target_offset == sizeof(struct arpt_entry) && 405 + if ((unconditional(e) && 407 406 (strcmp(t->target.u.user.name, 408 407 XT_STANDARD_TARGET) == 0) && 409 - t->verdict < 0 && unconditional(&e->arp)) || 410 - visited) { 408 + t->verdict < 0) || visited) { 411 409 unsigned int oldpos, size; 412 410 413 411 if ((strcmp(t->target.u.user.name, ··· 474 474 return 1; 475 475 } 476 476 477 - static inline int check_entry(const struct arpt_entry *e, const char *name) 477 + static inline int check_entry(const struct arpt_entry *e) 478 478 { 479 479 const struct xt_entry_target *t; 480 480 481 - if (!arp_checkentry(&e->arp)) { 482 - duprintf("arp_tables: arp check failed %p %s.\n", e, name); 481 + if (!arp_checkentry(&e->arp)) 483 482 return -EINVAL; 484 - } 485 483 486 484 if (e->target_offset + sizeof(struct xt_entry_target) > e->next_offset) 487 485 return -EINVAL; ··· 520 522 struct xt_target *target; 521 523 int ret; 522 524 523 - ret = check_entry(e, name); 524 - if (ret) 525 - return ret; 526 - 527 525 e->counters.pcnt = xt_percpu_counter_alloc(); 528 526 if (IS_ERR_VALUE(e->counters.pcnt)) 529 527 return -ENOMEM; ··· 551 557 const struct xt_entry_target *t; 552 558 unsigned int verdict; 553 559 554 - if (!unconditional(&e->arp)) 560 + if (!unconditional(e)) 555 561 return false; 556 562 t = arpt_get_target_c(e); 557 563 if (strcmp(t->u.user.name, XT_STANDARD_TARGET) != 0) ··· 570 576 unsigned int valid_hooks) 571 577 { 572 578 unsigned int h; 579 + int err; 573 580 574 581 if ((unsigned long)e % __alignof__(struct arpt_entry) != 0 || 575 - (unsigned char *)e + sizeof(struct arpt_entry) >= limit) { 582 + (unsigned char *)e + sizeof(struct arpt_entry) >= limit || 583 + (unsigned char *)e + e->next_offset > limit) { 576 584 duprintf("Bad offset %p\n", e); 577 585 return -EINVAL; 578 586 } ··· 586 590 return -EINVAL; 587 591 } 588 592 593 + err = check_entry(e); 594 + if (err) 595 + return err; 596 + 589 597 /* Check hooks & underflows */ 590 598 for (h = 0; h < NF_ARP_NUMHOOKS; h++) { 591 599 if (!(valid_hooks & (1 << h))) ··· 598 598 newinfo->hook_entry[h] = hook_entries[h]; 599 599 if ((unsigned char *)e - base == underflows[h]) { 600 600 if (!check_underflow(e)) { 601 - pr_err("Underflows must be unconditional and " 602 - "use the STANDARD target with " 603 - "ACCEPT/DROP\n"); 601 + pr_debug("Underflows must be unconditional and " 602 + "use the STANDARD target with " 603 + "ACCEPT/DROP\n"); 604 604 return -EINVAL; 605 605 } 606 606 newinfo->underflow[h] = underflows[h]; ··· 969 969 sizeof(struct arpt_get_entries) + get.size); 970 970 return -EINVAL; 971 971 } 972 + get.name[sizeof(get.name) - 1] = '\0'; 972 973 973 974 t = xt_find_table_lock(net, NFPROTO_ARP, get.name); 974 975 if (!IS_ERR_OR_NULL(t)) { ··· 1234 1233 1235 1234 duprintf("check_compat_entry_size_and_hooks %p\n", e); 1236 1235 if ((unsigned long)e % __alignof__(struct compat_arpt_entry) != 0 || 1237 - (unsigned char *)e + sizeof(struct compat_arpt_entry) >= limit) { 1236 + (unsigned char *)e + sizeof(struct compat_arpt_entry) >= limit || 1237 + (unsigned char *)e + e->next_offset > limit) { 1238 1238 duprintf("Bad offset %p, limit = %p\n", e, limit); 1239 1239 return -EINVAL; 1240 1240 } ··· 1248 1246 } 1249 1247 1250 1248 /* For purposes of check_entry casting the compat entry is fine */ 1251 - ret = check_entry((struct arpt_entry *)e, name); 1249 + ret = check_entry((struct arpt_entry *)e); 1252 1250 if (ret) 1253 1251 return ret; 1254 1252 ··· 1664 1662 *len, sizeof(get) + get.size); 1665 1663 return -EINVAL; 1666 1664 } 1665 + get.name[sizeof(get.name) - 1] = '\0'; 1667 1666 1668 1667 xt_compat_lock(NFPROTO_ARP); 1669 1668 t = xt_find_table_lock(net, NFPROTO_ARP, get.name);
+25 -23
net/ipv4/netfilter/ip_tables.c
··· 168 168 169 169 /* All zeroes == unconditional rule. */ 170 170 /* Mildly perf critical (only if packet tracing is on) */ 171 - static inline bool unconditional(const struct ipt_ip *ip) 171 + static inline bool unconditional(const struct ipt_entry *e) 172 172 { 173 173 static const struct ipt_ip uncond; 174 174 175 - return memcmp(ip, &uncond, sizeof(uncond)) == 0; 175 + return e->target_offset == sizeof(struct ipt_entry) && 176 + memcmp(&e->ip, &uncond, sizeof(uncond)) == 0; 176 177 #undef FWINV 177 178 } 178 179 ··· 230 229 } else if (s == e) { 231 230 (*rulenum)++; 232 231 233 - if (s->target_offset == sizeof(struct ipt_entry) && 232 + if (unconditional(s) && 234 233 strcmp(t->target.u.kernel.target->name, 235 234 XT_STANDARD_TARGET) == 0 && 236 - t->verdict < 0 && 237 - unconditional(&s->ip)) { 235 + t->verdict < 0) { 238 236 /* Tail of chains: STANDARD target (return/policy) */ 239 237 *comment = *chainname == hookname 240 238 ? comments[NF_IP_TRACE_COMMENT_POLICY] ··· 476 476 e->comefrom |= ((1 << hook) | (1 << NF_INET_NUMHOOKS)); 477 477 478 478 /* Unconditional return/END. */ 479 - if ((e->target_offset == sizeof(struct ipt_entry) && 479 + if ((unconditional(e) && 480 480 (strcmp(t->target.u.user.name, 481 481 XT_STANDARD_TARGET) == 0) && 482 - t->verdict < 0 && unconditional(&e->ip)) || 483 - visited) { 482 + t->verdict < 0) || visited) { 484 483 unsigned int oldpos, size; 485 484 486 485 if ((strcmp(t->target.u.user.name, ··· 568 569 } 569 570 570 571 static int 571 - check_entry(const struct ipt_entry *e, const char *name) 572 + check_entry(const struct ipt_entry *e) 572 573 { 573 574 const struct xt_entry_target *t; 574 575 575 - if (!ip_checkentry(&e->ip)) { 576 - duprintf("ip check failed %p %s.\n", e, name); 576 + if (!ip_checkentry(&e->ip)) 577 577 return -EINVAL; 578 - } 579 578 580 579 if (e->target_offset + sizeof(struct xt_entry_target) > 581 580 e->next_offset) ··· 663 666 struct xt_mtchk_param mtpar; 664 667 struct xt_entry_match *ematch; 665 668 666 - ret = check_entry(e, name); 667 - if (ret) 668 - return ret; 669 - 670 669 e->counters.pcnt = xt_percpu_counter_alloc(); 671 670 if (IS_ERR_VALUE(e->counters.pcnt)) 672 671 return -ENOMEM; ··· 714 721 const struct xt_entry_target *t; 715 722 unsigned int verdict; 716 723 717 - if (!unconditional(&e->ip)) 724 + if (!unconditional(e)) 718 725 return false; 719 726 t = ipt_get_target_c(e); 720 727 if (strcmp(t->u.user.name, XT_STANDARD_TARGET) != 0) ··· 734 741 unsigned int valid_hooks) 735 742 { 736 743 unsigned int h; 744 + int err; 737 745 738 746 if ((unsigned long)e % __alignof__(struct ipt_entry) != 0 || 739 - (unsigned char *)e + sizeof(struct ipt_entry) >= limit) { 747 + (unsigned char *)e + sizeof(struct ipt_entry) >= limit || 748 + (unsigned char *)e + e->next_offset > limit) { 740 749 duprintf("Bad offset %p\n", e); 741 750 return -EINVAL; 742 751 } ··· 750 755 return -EINVAL; 751 756 } 752 757 758 + err = check_entry(e); 759 + if (err) 760 + return err; 761 + 753 762 /* Check hooks & underflows */ 754 763 for (h = 0; h < NF_INET_NUMHOOKS; h++) { 755 764 if (!(valid_hooks & (1 << h))) ··· 762 763 newinfo->hook_entry[h] = hook_entries[h]; 763 764 if ((unsigned char *)e - base == underflows[h]) { 764 765 if (!check_underflow(e)) { 765 - pr_err("Underflows must be unconditional and " 766 - "use the STANDARD target with " 767 - "ACCEPT/DROP\n"); 766 + pr_debug("Underflows must be unconditional and " 767 + "use the STANDARD target with " 768 + "ACCEPT/DROP\n"); 768 769 return -EINVAL; 769 770 } 770 771 newinfo->underflow[h] = underflows[h]; ··· 1156 1157 *len, sizeof(get) + get.size); 1157 1158 return -EINVAL; 1158 1159 } 1160 + get.name[sizeof(get.name) - 1] = '\0'; 1159 1161 1160 1162 t = xt_find_table_lock(net, AF_INET, get.name); 1161 1163 if (!IS_ERR_OR_NULL(t)) { ··· 1493 1493 1494 1494 duprintf("check_compat_entry_size_and_hooks %p\n", e); 1495 1495 if ((unsigned long)e % __alignof__(struct compat_ipt_entry) != 0 || 1496 - (unsigned char *)e + sizeof(struct compat_ipt_entry) >= limit) { 1496 + (unsigned char *)e + sizeof(struct compat_ipt_entry) >= limit || 1497 + (unsigned char *)e + e->next_offset > limit) { 1497 1498 duprintf("Bad offset %p, limit = %p\n", e, limit); 1498 1499 return -EINVAL; 1499 1500 } ··· 1507 1506 } 1508 1507 1509 1508 /* For purposes of check_entry casting the compat entry is fine */ 1510 - ret = check_entry((struct ipt_entry *)e, name); 1509 + ret = check_entry((struct ipt_entry *)e); 1511 1510 if (ret) 1512 1511 return ret; 1513 1512 ··· 1936 1935 *len, sizeof(get) + get.size); 1937 1936 return -EINVAL; 1938 1937 } 1938 + get.name[sizeof(get.name) - 1] = '\0'; 1939 1939 1940 1940 xt_compat_lock(AF_INET); 1941 1941 t = xt_find_table_lock(net, AF_INET, get.name);
+28 -26
net/ipv4/netfilter/ipt_SYNPROXY.c
··· 18 18 #include <net/netfilter/nf_conntrack_synproxy.h> 19 19 20 20 static struct iphdr * 21 - synproxy_build_ip(struct sk_buff *skb, __be32 saddr, __be32 daddr) 21 + synproxy_build_ip(struct net *net, struct sk_buff *skb, __be32 saddr, 22 + __be32 daddr) 22 23 { 23 24 struct iphdr *iph; 24 - struct net *net = sock_net(skb->sk); 25 25 26 26 skb_reset_network_header(skb); 27 27 iph = (struct iphdr *)skb_put(skb, sizeof(*iph)); ··· 40 40 } 41 41 42 42 static void 43 - synproxy_send_tcp(const struct synproxy_net *snet, 43 + synproxy_send_tcp(struct net *net, 44 44 const struct sk_buff *skb, struct sk_buff *nskb, 45 45 struct nf_conntrack *nfct, enum ip_conntrack_info ctinfo, 46 46 struct iphdr *niph, struct tcphdr *nth, 47 47 unsigned int tcp_hdr_size) 48 48 { 49 - struct net *net = nf_ct_net(snet->tmpl); 50 - 51 49 nth->check = ~tcp_v4_check(tcp_hdr_size, niph->saddr, niph->daddr, 0); 52 50 nskb->ip_summed = CHECKSUM_PARTIAL; 53 51 nskb->csum_start = (unsigned char *)nth - nskb->head; ··· 70 72 } 71 73 72 74 static void 73 - synproxy_send_client_synack(const struct synproxy_net *snet, 75 + synproxy_send_client_synack(struct net *net, 74 76 const struct sk_buff *skb, const struct tcphdr *th, 75 77 const struct synproxy_options *opts) 76 78 { ··· 89 91 return; 90 92 skb_reserve(nskb, MAX_TCP_HEADER); 91 93 92 - niph = synproxy_build_ip(nskb, iph->daddr, iph->saddr); 94 + niph = synproxy_build_ip(net, nskb, iph->daddr, iph->saddr); 93 95 94 96 skb_reset_transport_header(nskb); 95 97 nth = (struct tcphdr *)skb_put(nskb, tcp_hdr_size); ··· 107 109 108 110 synproxy_build_options(nth, opts); 109 111 110 - synproxy_send_tcp(snet, skb, nskb, skb->nfct, IP_CT_ESTABLISHED_REPLY, 112 + synproxy_send_tcp(net, skb, nskb, skb->nfct, IP_CT_ESTABLISHED_REPLY, 111 113 niph, nth, tcp_hdr_size); 112 114 } 113 115 114 116 static void 115 - synproxy_send_server_syn(const struct synproxy_net *snet, 117 + synproxy_send_server_syn(struct net *net, 116 118 const struct sk_buff *skb, const struct tcphdr *th, 117 119 const struct synproxy_options *opts, u32 recv_seq) 118 120 { 121 + struct synproxy_net *snet = synproxy_pernet(net); 119 122 struct sk_buff *nskb; 120 123 struct iphdr *iph, *niph; 121 124 struct tcphdr *nth; ··· 131 132 return; 132 133 skb_reserve(nskb, MAX_TCP_HEADER); 133 134 134 - niph = synproxy_build_ip(nskb, iph->saddr, iph->daddr); 135 + niph = synproxy_build_ip(net, nskb, iph->saddr, iph->daddr); 135 136 136 137 skb_reset_transport_header(nskb); 137 138 nth = (struct tcphdr *)skb_put(nskb, tcp_hdr_size); ··· 152 153 153 154 synproxy_build_options(nth, opts); 154 155 155 - synproxy_send_tcp(snet, skb, nskb, &snet->tmpl->ct_general, IP_CT_NEW, 156 + synproxy_send_tcp(net, skb, nskb, &snet->tmpl->ct_general, IP_CT_NEW, 156 157 niph, nth, tcp_hdr_size); 157 158 } 158 159 159 160 static void 160 - synproxy_send_server_ack(const struct synproxy_net *snet, 161 + synproxy_send_server_ack(struct net *net, 161 162 const struct ip_ct_tcp *state, 162 163 const struct sk_buff *skb, const struct tcphdr *th, 163 164 const struct synproxy_options *opts) ··· 176 177 return; 177 178 skb_reserve(nskb, MAX_TCP_HEADER); 178 179 179 - niph = synproxy_build_ip(nskb, iph->daddr, iph->saddr); 180 + niph = synproxy_build_ip(net, nskb, iph->daddr, iph->saddr); 180 181 181 182 skb_reset_transport_header(nskb); 182 183 nth = (struct tcphdr *)skb_put(nskb, tcp_hdr_size); ··· 192 193 193 194 synproxy_build_options(nth, opts); 194 195 195 - synproxy_send_tcp(snet, skb, nskb, NULL, 0, niph, nth, tcp_hdr_size); 196 + synproxy_send_tcp(net, skb, nskb, NULL, 0, niph, nth, tcp_hdr_size); 196 197 } 197 198 198 199 static void 199 - synproxy_send_client_ack(const struct synproxy_net *snet, 200 + synproxy_send_client_ack(struct net *net, 200 201 const struct sk_buff *skb, const struct tcphdr *th, 201 202 const struct synproxy_options *opts) 202 203 { ··· 214 215 return; 215 216 skb_reserve(nskb, MAX_TCP_HEADER); 216 217 217 - niph = synproxy_build_ip(nskb, iph->saddr, iph->daddr); 218 + niph = synproxy_build_ip(net, nskb, iph->saddr, iph->daddr); 218 219 219 220 skb_reset_transport_header(nskb); 220 221 nth = (struct tcphdr *)skb_put(nskb, tcp_hdr_size); ··· 230 231 231 232 synproxy_build_options(nth, opts); 232 233 233 - synproxy_send_tcp(snet, skb, nskb, skb->nfct, IP_CT_ESTABLISHED_REPLY, 234 + synproxy_send_tcp(net, skb, nskb, skb->nfct, IP_CT_ESTABLISHED_REPLY, 234 235 niph, nth, tcp_hdr_size); 235 236 } 236 237 237 238 static bool 238 - synproxy_recv_client_ack(const struct synproxy_net *snet, 239 + synproxy_recv_client_ack(struct net *net, 239 240 const struct sk_buff *skb, const struct tcphdr *th, 240 241 struct synproxy_options *opts, u32 recv_seq) 241 242 { 243 + struct synproxy_net *snet = synproxy_pernet(net); 242 244 int mss; 243 245 244 246 mss = __cookie_v4_check(ip_hdr(skb), th, ntohl(th->ack_seq) - 1); ··· 255 255 if (opts->options & XT_SYNPROXY_OPT_TIMESTAMP) 256 256 synproxy_check_timestamp_cookie(opts); 257 257 258 - synproxy_send_server_syn(snet, skb, th, opts, recv_seq); 258 + synproxy_send_server_syn(net, skb, th, opts, recv_seq); 259 259 return true; 260 260 } 261 261 ··· 263 263 synproxy_tg4(struct sk_buff *skb, const struct xt_action_param *par) 264 264 { 265 265 const struct xt_synproxy_info *info = par->targinfo; 266 - struct synproxy_net *snet = synproxy_pernet(par->net); 266 + struct net *net = par->net; 267 + struct synproxy_net *snet = synproxy_pernet(net); 267 268 struct synproxy_options opts = {}; 268 269 struct tcphdr *th, _th; 269 270 ··· 293 292 XT_SYNPROXY_OPT_SACK_PERM | 294 293 XT_SYNPROXY_OPT_ECN); 295 294 296 - synproxy_send_client_synack(snet, skb, th, &opts); 295 + synproxy_send_client_synack(net, skb, th, &opts); 297 296 return NF_DROP; 298 297 299 298 } else if (th->ack && !(th->fin || th->rst || th->syn)) { 300 299 /* ACK from client */ 301 - synproxy_recv_client_ack(snet, skb, th, &opts, ntohl(th->seq)); 300 + synproxy_recv_client_ack(net, skb, th, &opts, ntohl(th->seq)); 302 301 return NF_DROP; 303 302 } 304 303 ··· 309 308 struct sk_buff *skb, 310 309 const struct nf_hook_state *nhs) 311 310 { 312 - struct synproxy_net *snet = synproxy_pernet(nhs->net); 311 + struct net *net = nhs->net; 312 + struct synproxy_net *snet = synproxy_pernet(net); 313 313 enum ip_conntrack_info ctinfo; 314 314 struct nf_conn *ct; 315 315 struct nf_conn_synproxy *synproxy; ··· 367 365 * therefore we need to add 1 to make the SYN sequence 368 366 * number match the one of first SYN. 369 367 */ 370 - if (synproxy_recv_client_ack(snet, skb, th, &opts, 368 + if (synproxy_recv_client_ack(net, skb, th, &opts, 371 369 ntohl(th->seq) + 1)) 372 370 this_cpu_inc(snet->stats->cookie_retrans); 373 371 ··· 393 391 XT_SYNPROXY_OPT_SACK_PERM); 394 392 395 393 swap(opts.tsval, opts.tsecr); 396 - synproxy_send_server_ack(snet, state, skb, th, &opts); 394 + synproxy_send_server_ack(net, state, skb, th, &opts); 397 395 398 396 nf_ct_seqadj_init(ct, ctinfo, synproxy->isn - ntohl(th->seq)); 399 397 400 398 swap(opts.tsval, opts.tsecr); 401 - synproxy_send_client_ack(snet, skb, th, &opts); 399 + synproxy_send_client_ack(net, skb, th, &opts); 402 400 403 401 consume_skb(skb); 404 402 return NF_STOLEN;
+25 -23
net/ipv6/netfilter/ip6_tables.c
··· 198 198 199 199 /* All zeroes == unconditional rule. */ 200 200 /* Mildly perf critical (only if packet tracing is on) */ 201 - static inline bool unconditional(const struct ip6t_ip6 *ipv6) 201 + static inline bool unconditional(const struct ip6t_entry *e) 202 202 { 203 203 static const struct ip6t_ip6 uncond; 204 204 205 - return memcmp(ipv6, &uncond, sizeof(uncond)) == 0; 205 + return e->target_offset == sizeof(struct ip6t_entry) && 206 + memcmp(&e->ipv6, &uncond, sizeof(uncond)) == 0; 206 207 } 207 208 208 209 static inline const struct xt_entry_target * ··· 259 258 } else if (s == e) { 260 259 (*rulenum)++; 261 260 262 - if (s->target_offset == sizeof(struct ip6t_entry) && 261 + if (unconditional(s) && 263 262 strcmp(t->target.u.kernel.target->name, 264 263 XT_STANDARD_TARGET) == 0 && 265 - t->verdict < 0 && 266 - unconditional(&s->ipv6)) { 264 + t->verdict < 0) { 267 265 /* Tail of chains: STANDARD target (return/policy) */ 268 266 *comment = *chainname == hookname 269 267 ? comments[NF_IP6_TRACE_COMMENT_POLICY] ··· 488 488 e->comefrom |= ((1 << hook) | (1 << NF_INET_NUMHOOKS)); 489 489 490 490 /* Unconditional return/END. */ 491 - if ((e->target_offset == sizeof(struct ip6t_entry) && 491 + if ((unconditional(e) && 492 492 (strcmp(t->target.u.user.name, 493 493 XT_STANDARD_TARGET) == 0) && 494 - t->verdict < 0 && 495 - unconditional(&e->ipv6)) || visited) { 494 + t->verdict < 0) || visited) { 496 495 unsigned int oldpos, size; 497 496 498 497 if ((strcmp(t->target.u.user.name, ··· 580 581 } 581 582 582 583 static int 583 - check_entry(const struct ip6t_entry *e, const char *name) 584 + check_entry(const struct ip6t_entry *e) 584 585 { 585 586 const struct xt_entry_target *t; 586 587 587 - if (!ip6_checkentry(&e->ipv6)) { 588 - duprintf("ip_tables: ip check failed %p %s.\n", e, name); 588 + if (!ip6_checkentry(&e->ipv6)) 589 589 return -EINVAL; 590 - } 591 590 592 591 if (e->target_offset + sizeof(struct xt_entry_target) > 593 592 e->next_offset) ··· 676 679 struct xt_mtchk_param mtpar; 677 680 struct xt_entry_match *ematch; 678 681 679 - ret = check_entry(e, name); 680 - if (ret) 681 - return ret; 682 - 683 682 e->counters.pcnt = xt_percpu_counter_alloc(); 684 683 if (IS_ERR_VALUE(e->counters.pcnt)) 685 684 return -ENOMEM; ··· 726 733 const struct xt_entry_target *t; 727 734 unsigned int verdict; 728 735 729 - if (!unconditional(&e->ipv6)) 736 + if (!unconditional(e)) 730 737 return false; 731 738 t = ip6t_get_target_c(e); 732 739 if (strcmp(t->u.user.name, XT_STANDARD_TARGET) != 0) ··· 746 753 unsigned int valid_hooks) 747 754 { 748 755 unsigned int h; 756 + int err; 749 757 750 758 if ((unsigned long)e % __alignof__(struct ip6t_entry) != 0 || 751 - (unsigned char *)e + sizeof(struct ip6t_entry) >= limit) { 759 + (unsigned char *)e + sizeof(struct ip6t_entry) >= limit || 760 + (unsigned char *)e + e->next_offset > limit) { 752 761 duprintf("Bad offset %p\n", e); 753 762 return -EINVAL; 754 763 } ··· 762 767 return -EINVAL; 763 768 } 764 769 770 + err = check_entry(e); 771 + if (err) 772 + return err; 773 + 765 774 /* Check hooks & underflows */ 766 775 for (h = 0; h < NF_INET_NUMHOOKS; h++) { 767 776 if (!(valid_hooks & (1 << h))) ··· 774 775 newinfo->hook_entry[h] = hook_entries[h]; 775 776 if ((unsigned char *)e - base == underflows[h]) { 776 777 if (!check_underflow(e)) { 777 - pr_err("Underflows must be unconditional and " 778 - "use the STANDARD target with " 779 - "ACCEPT/DROP\n"); 778 + pr_debug("Underflows must be unconditional and " 779 + "use the STANDARD target with " 780 + "ACCEPT/DROP\n"); 780 781 return -EINVAL; 781 782 } 782 783 newinfo->underflow[h] = underflows[h]; ··· 1168 1169 *len, sizeof(get) + get.size); 1169 1170 return -EINVAL; 1170 1171 } 1172 + get.name[sizeof(get.name) - 1] = '\0'; 1171 1173 1172 1174 t = xt_find_table_lock(net, AF_INET6, get.name); 1173 1175 if (!IS_ERR_OR_NULL(t)) { ··· 1505 1505 1506 1506 duprintf("check_compat_entry_size_and_hooks %p\n", e); 1507 1507 if ((unsigned long)e % __alignof__(struct compat_ip6t_entry) != 0 || 1508 - (unsigned char *)e + sizeof(struct compat_ip6t_entry) >= limit) { 1508 + (unsigned char *)e + sizeof(struct compat_ip6t_entry) >= limit || 1509 + (unsigned char *)e + e->next_offset > limit) { 1509 1510 duprintf("Bad offset %p, limit = %p\n", e, limit); 1510 1511 return -EINVAL; 1511 1512 } ··· 1519 1518 } 1520 1519 1521 1520 /* For purposes of check_entry casting the compat entry is fine */ 1522 - ret = check_entry((struct ip6t_entry *)e, name); 1521 + ret = check_entry((struct ip6t_entry *)e); 1523 1522 if (ret) 1524 1523 return ret; 1525 1524 ··· 1945 1944 *len, sizeof(get) + get.size); 1946 1945 return -EINVAL; 1947 1946 } 1947 + get.name[sizeof(get.name) - 1] = '\0'; 1948 1948 1949 1949 xt_compat_lock(AF_INET6); 1950 1950 t = xt_find_table_lock(net, AF_INET6, get.name);
+2 -2
net/ipv6/udp.c
··· 843 843 flush_stack(stack, count, skb, count - 1); 844 844 } else { 845 845 if (!inner_flushed) 846 - UDP_INC_STATS_BH(net, UDP_MIB_IGNOREDMULTI, 847 - proto == IPPROTO_UDPLITE); 846 + UDP6_INC_STATS_BH(net, UDP_MIB_IGNOREDMULTI, 847 + proto == IPPROTO_UDPLITE); 848 848 consume_skb(skb); 849 849 } 850 850 return 0;
+1 -1
net/netfilter/ipset/ip_set_bitmap_gen.h
··· 95 95 if (!nested) 96 96 goto nla_put_failure; 97 97 if (mtype_do_head(skb, map) || 98 - nla_put_net32(skb, IPSET_ATTR_REFERENCES, htonl(set->ref - 1)) || 98 + nla_put_net32(skb, IPSET_ATTR_REFERENCES, htonl(set->ref)) || 99 99 nla_put_net32(skb, IPSET_ATTR_MEMSIZE, htonl(memsize))) 100 100 goto nla_put_failure; 101 101 if (unlikely(ip_set_put_flags(skb, set)))
+28 -5
net/netfilter/ipset/ip_set_core.c
··· 497 497 write_unlock_bh(&ip_set_ref_lock); 498 498 } 499 499 500 + /* set->ref can be swapped out by ip_set_swap, netlink events (like dump) need 501 + * a separate reference counter 502 + */ 503 + static inline void 504 + __ip_set_get_netlink(struct ip_set *set) 505 + { 506 + write_lock_bh(&ip_set_ref_lock); 507 + set->ref_netlink++; 508 + write_unlock_bh(&ip_set_ref_lock); 509 + } 510 + 511 + static inline void 512 + __ip_set_put_netlink(struct ip_set *set) 513 + { 514 + write_lock_bh(&ip_set_ref_lock); 515 + BUG_ON(set->ref_netlink == 0); 516 + set->ref_netlink--; 517 + write_unlock_bh(&ip_set_ref_lock); 518 + } 519 + 500 520 /* Add, del and test set entries from kernel. 501 521 * 502 522 * The set behind the index must exist and must be referenced ··· 1022 1002 if (!attr[IPSET_ATTR_SETNAME]) { 1023 1003 for (i = 0; i < inst->ip_set_max; i++) { 1024 1004 s = ip_set(inst, i); 1025 - if (s && s->ref) { 1005 + if (s && (s->ref || s->ref_netlink)) { 1026 1006 ret = -IPSET_ERR_BUSY; 1027 1007 goto out; 1028 1008 } ··· 1044 1024 if (!s) { 1045 1025 ret = -ENOENT; 1046 1026 goto out; 1047 - } else if (s->ref) { 1027 + } else if (s->ref || s->ref_netlink) { 1048 1028 ret = -IPSET_ERR_BUSY; 1049 1029 goto out; 1050 1030 } ··· 1191 1171 from->family == to->family)) 1192 1172 return -IPSET_ERR_TYPE_MISMATCH; 1193 1173 1174 + if (from->ref_netlink || to->ref_netlink) 1175 + return -EBUSY; 1176 + 1194 1177 strncpy(from_name, from->name, IPSET_MAXNAMELEN); 1195 1178 strncpy(from->name, to->name, IPSET_MAXNAMELEN); 1196 1179 strncpy(to->name, from_name, IPSET_MAXNAMELEN); ··· 1229 1206 if (set->variant->uref) 1230 1207 set->variant->uref(set, cb, false); 1231 1208 pr_debug("release set %s\n", set->name); 1232 - __ip_set_put_byindex(inst, index); 1209 + __ip_set_put_netlink(set); 1233 1210 } 1234 1211 return 0; 1235 1212 } ··· 1351 1328 if (!cb->args[IPSET_CB_ARG0]) { 1352 1329 /* Start listing: make sure set won't be destroyed */ 1353 1330 pr_debug("reference set\n"); 1354 - set->ref++; 1331 + set->ref_netlink++; 1355 1332 } 1356 1333 write_unlock_bh(&ip_set_ref_lock); 1357 1334 nlh = start_msg(skb, NETLINK_CB(cb->skb).portid, ··· 1419 1396 if (set->variant->uref) 1420 1397 set->variant->uref(set, cb, false); 1421 1398 pr_debug("release set %s\n", set->name); 1422 - __ip_set_put_byindex(inst, index); 1399 + __ip_set_put_netlink(set); 1423 1400 cb->args[IPSET_CB_ARG0] = 0; 1424 1401 } 1425 1402 out:
+1 -1
net/netfilter/ipset/ip_set_hash_gen.h
··· 1082 1082 if (nla_put_u32(skb, IPSET_ATTR_MARKMASK, h->markmask)) 1083 1083 goto nla_put_failure; 1084 1084 #endif 1085 - if (nla_put_net32(skb, IPSET_ATTR_REFERENCES, htonl(set->ref - 1)) || 1085 + if (nla_put_net32(skb, IPSET_ATTR_REFERENCES, htonl(set->ref)) || 1086 1086 nla_put_net32(skb, IPSET_ATTR_MEMSIZE, htonl(memsize))) 1087 1087 goto nla_put_failure; 1088 1088 if (unlikely(ip_set_put_flags(skb, set)))
+1 -1
net/netfilter/ipset/ip_set_list_set.c
··· 458 458 if (!nested) 459 459 goto nla_put_failure; 460 460 if (nla_put_net32(skb, IPSET_ATTR_SIZE, htonl(map->size)) || 461 - nla_put_net32(skb, IPSET_ATTR_REFERENCES, htonl(set->ref - 1)) || 461 + nla_put_net32(skb, IPSET_ATTR_REFERENCES, htonl(set->ref)) || 462 462 nla_put_net32(skb, IPSET_ATTR_MEMSIZE, 463 463 htonl(sizeof(*map) + n * set->dsize))) 464 464 goto nla_put_failure;
+3 -1
net/openvswitch/Kconfig
··· 7 7 depends on INET 8 8 depends on !NF_CONNTRACK || \ 9 9 (NF_CONNTRACK && ((!NF_DEFRAG_IPV6 || NF_DEFRAG_IPV6) && \ 10 - (!NF_NAT || NF_NAT))) 10 + (!NF_NAT || NF_NAT) && \ 11 + (!NF_NAT_IPV4 || NF_NAT_IPV4) && \ 12 + (!NF_NAT_IPV6 || NF_NAT_IPV6))) 11 13 select LIBCRC32C 12 14 select MPLS 13 15 select NET_MPLS_GSO
+13 -11
net/openvswitch/conntrack.c
··· 535 535 switch (ctinfo) { 536 536 case IP_CT_RELATED: 537 537 case IP_CT_RELATED_REPLY: 538 - if (skb->protocol == htons(ETH_P_IP) && 538 + if (IS_ENABLED(CONFIG_NF_NAT_IPV4) && 539 + skb->protocol == htons(ETH_P_IP) && 539 540 ip_hdr(skb)->protocol == IPPROTO_ICMP) { 540 541 if (!nf_nat_icmp_reply_translation(skb, ct, ctinfo, 541 542 hooknum)) 542 543 err = NF_DROP; 543 544 goto push; 544 - #if IS_ENABLED(CONFIG_NF_NAT_IPV6) 545 - } else if (skb->protocol == htons(ETH_P_IPV6)) { 545 + } else if (IS_ENABLED(CONFIG_NF_NAT_IPV6) && 546 + skb->protocol == htons(ETH_P_IPV6)) { 546 547 __be16 frag_off; 547 548 u8 nexthdr = ipv6_hdr(skb)->nexthdr; 548 549 int hdrlen = ipv6_skip_exthdr(skb, ··· 558 557 err = NF_DROP; 559 558 goto push; 560 559 } 561 - #endif 562 560 } 563 561 /* Non-ICMP, fall thru to initialize if needed. */ 564 562 case IP_CT_NEW: ··· 664 664 665 665 /* Determine NAT type. 666 666 * Check if the NAT type can be deduced from the tracked connection. 667 - * Make sure expected traffic is NATted only when committing. 667 + * Make sure new expected connections (IP_CT_RELATED) are NATted only 668 + * when committing. 668 669 */ 669 670 if (info->nat & OVS_CT_NAT && ctinfo != IP_CT_NEW && 670 671 ct->status & IPS_NAT_MASK && 671 - (!(ct->status & IPS_EXPECTED_BIT) || info->commit)) { 672 + (ctinfo != IP_CT_RELATED || info->commit)) { 672 673 /* NAT an established or related connection like before. */ 673 674 if (CTINFO2DIR(ctinfo) == IP_CT_DIR_REPLY) 674 675 /* This is the REPLY direction for a connection ··· 969 968 break; 970 969 971 970 case OVS_NAT_ATTR_IP_MIN: 972 - nla_memcpy(&info->range.min_addr, a, nla_len(a)); 971 + nla_memcpy(&info->range.min_addr, a, 972 + sizeof(info->range.min_addr)); 973 973 info->range.flags |= NF_NAT_RANGE_MAP_IPS; 974 974 break; 975 975 ··· 1240 1238 } 1241 1239 1242 1240 if (info->range.flags & NF_NAT_RANGE_MAP_IPS) { 1243 - if (info->family == NFPROTO_IPV4) { 1241 + if (IS_ENABLED(CONFIG_NF_NAT_IPV4) && 1242 + info->family == NFPROTO_IPV4) { 1244 1243 if (nla_put_in_addr(skb, OVS_NAT_ATTR_IP_MIN, 1245 1244 info->range.min_addr.ip) || 1246 1245 (info->range.max_addr.ip ··· 1249 1246 (nla_put_in_addr(skb, OVS_NAT_ATTR_IP_MAX, 1250 1247 info->range.max_addr.ip)))) 1251 1248 return false; 1252 - #if IS_ENABLED(CONFIG_NF_NAT_IPV6) 1253 - } else if (info->family == NFPROTO_IPV6) { 1249 + } else if (IS_ENABLED(CONFIG_NF_NAT_IPV6) && 1250 + info->family == NFPROTO_IPV6) { 1254 1251 if (nla_put_in6_addr(skb, OVS_NAT_ATTR_IP_MIN, 1255 1252 &info->range.min_addr.in6) || 1256 1253 (memcmp(&info->range.max_addr.in6, ··· 1259 1256 (nla_put_in6_addr(skb, OVS_NAT_ATTR_IP_MAX, 1260 1257 &info->range.max_addr.in6)))) 1261 1258 return false; 1262 - #endif 1263 1259 } else { 1264 1260 return false; 1265 1261 }
+3 -3
net/sctp/output.c
··· 401 401 sk = chunk->skb->sk; 402 402 403 403 /* Allocate the new skb. */ 404 - nskb = alloc_skb(packet->size + MAX_HEADER, GFP_ATOMIC); 404 + nskb = alloc_skb(packet->size + MAX_HEADER, gfp); 405 405 if (!nskb) 406 406 goto nomem; 407 407 ··· 523 523 */ 524 524 if (auth) 525 525 sctp_auth_calculate_hmac(asoc, nskb, 526 - (struct sctp_auth_chunk *)auth, 527 - GFP_ATOMIC); 526 + (struct sctp_auth_chunk *)auth, 527 + gfp); 528 528 529 529 /* 2) Calculate the Adler-32 checksum of the whole packet, 530 530 * including the SCTP common header and all the
+1 -1
net/switchdev/switchdev.c
··· 1079 1079 * @filter_dev: filter device 1080 1080 * @idx: 1081 1081 * 1082 - * Delete FDB entry from switch device. 1082 + * Dump FDB entries from switch device. 1083 1083 */ 1084 1084 int switchdev_port_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb, 1085 1085 struct net_device *dev,
+3
net/xfrm/xfrm_input.c
··· 292 292 XFRM_SKB_CB(skb)->seq.input.hi = seq_hi; 293 293 294 294 skb_dst_force(skb); 295 + dev_hold(skb->dev); 295 296 296 297 nexthdr = x->type->input(x, skb); 297 298 298 299 if (nexthdr == -EINPROGRESS) 299 300 return 0; 300 301 resume: 302 + dev_put(skb->dev); 303 + 301 304 spin_lock(&x->lock); 302 305 if (nexthdr <= 0) { 303 306 if (nexthdr == -EBADMSG) {