Pull networking fixes from David Miller: 1) The netlink attribute passed in to dev_set_alias() is not necessarily NULL terminated, don't use strlcpy() on it. From Alexander Potapenko. 2) Fix implementation of atomics in arm64 bpf JIT, from Daniel Borkmann. 3) Correct the release of netdevs and driver private data in certain circumstances. 4) Sanitize netlink message length properly in decnet, from Mateusz Jurczyk. 5) Don't leak kernel data in rtnl_fill_vfinfo() netlink blobs. From Yuval Mintz. 6) Hash secret is never initialized in ipv6 ILA translation code, from Arnd Bergmann. I guess those clang warnings about unused inline functions are useful for something! 7) Fix endian selection in bpf_endian.h, from Daniel Borkmann. 8) Sanitize sockaddr length before dereferncing any fields in AF_UNIX and CAIF. From Mateusz Jurczyk. 9) Fix timestamping for GMAC3 chips in stmmac driver, from Mario Molitor. 10) Do not leak netdev on dev_alloc_name() errors in mac80211, from Johannes Berg. 11) Fix locking in sctp_for_each_endpoint(), from Xin Long. 12) Fix wrong memset size on 32-bit in snmp6, from Christian Perle. 13) Fix use after free in ip_mc_clear_src(), from WANG Cong. 14) Fix regressions caused by ICMP rate limiting changes in 4.11, from Jesper Dangaard Brouer. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (91 commits) i40e: Fix a sleep-in-atomic bug net: don't global ICMP rate limit packets originating from loopback net/act_pedit: fix an error code net: update undefined ->ndo_change_mtu() comment net_sched: move tcf_lock down after gen_replace_estimator() caif: Add sockaddr length check before accessing sa_family in connect handler qed: fix dump of context data qmi_wwan: new Telewell and Sierra device IDs net: phy: Fix MDIO_THUNDER dependencies netconsole: Remove duplicate "netconsole: " logging prefix igmp: acquire pmc lock for ip_mc_clear_src() r8152: give the device version net: rps: fix uninitialized symbol warning mac80211: don't send SMPS action frame in AP mode when not needed mac80211/wpa: use constant time memory comparison for MACs mac80211: set bss_info data before configuring the channel mac80211: remove 5/10 MHz rate code from station MLME mac80211: Fix incorrect condition when checking rx timestamp mac80211: don't look at the PM bit of BAR frames i40e: fix handling of HW ATR eviction ...
Unified · Split
| @@ -122,7 +122,7 @@ associated flow of the packet. The hash is either provided by hardware · 121 unmodified lines | ||
| 122 | 122 | or will be computed in the stack. Capable hardware can pass the hash in |
| 123 | 123 | the receive descriptor for the packet; this would usually be the same |
| 124 | 124 | hash used for RSS (e.g. computed Toeplitz hash). The hash is saved in |
| 125 | −skb->rx_hash and can be used elsewhere in the stack as a hash of the | |
| 125 | +skb->hash and can be used elsewhere in the stack as a hash of the | |
| 126 | 126 | packet’s flow. |
| 127 | 127 | |
| 128 | 128 | Each receive hardware queue has an associated list of CPUs to which |
| @@ -36,6 +36,7 @@ int bpf_jit_enable __read_mostly; · 35 unmodified lines | ||
| 36 | 36 | #define TMP_REG_1 (MAX_BPF_JIT_REG + 0) |
| 37 | 37 | #define TMP_REG_2 (MAX_BPF_JIT_REG + 1) |
| 38 | 38 | #define TCALL_CNT (MAX_BPF_JIT_REG + 2) |
| 39 | +#define TMP_REG_3 (MAX_BPF_JIT_REG + 3) | |
| 39 | 40 | |
| 40 | 41 | /* Map BPF registers to A64 registers */ |
| 41 | 42 | static const int bpf2a64[] = { |
| @@ -57,6 +58,7 @@ static const int bpf2a64[] = { · 15 unmodified lines | ||
| 57 | 58 | /* temporary registers for internal BPF JIT */ |
| 58 | 59 | [TMP_REG_1] = A64_R(10), |
| 59 | 60 | [TMP_REG_2] = A64_R(11), |
| 61 | + [TMP_REG_3] = A64_R(12), | |
| 60 | 62 | /* tail_call_cnt */ |
| 61 | 63 | [TCALL_CNT] = A64_R(26), |
| 62 | 64 | /* temporary register for blinding constants */ |
| @@ -319,6 +321,7 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx) · 256 unmodified lines | ||
| 319 | 321 | const u8 src = bpf2a64[insn->src_reg]; |
| 320 | 322 | const u8 tmp = bpf2a64[TMP_REG_1]; |
| 321 | 323 | const u8 tmp2 = bpf2a64[TMP_REG_2]; |
| 324 | + const u8 tmp3 = bpf2a64[TMP_REG_3]; | |
| 322 | 325 | const s16 off = insn->off; |
| 323 | 326 | const s32 imm = insn->imm; |
| 324 | 327 | const int i = insn - ctx->prog->insnsi; |
| @@ -689,10 +692,10 @@ emit_cond_jmp: · 364 unmodified lines | ||
| 689 | 692 | emit(A64_PRFM(tmp, PST, L1, STRM), ctx); |
| 690 | 693 | emit(A64_LDXR(isdw, tmp2, tmp), ctx); |
| 691 | 694 | emit(A64_ADD(isdw, tmp2, tmp2, src), ctx); |
| 692 | − emit(A64_STXR(isdw, tmp2, tmp, tmp2), ctx); | |
| 695 | + emit(A64_STXR(isdw, tmp2, tmp, tmp3), ctx); | |
| 693 | 696 | jmp_offset = -3; |
| 694 | 697 | check_imm19(jmp_offset); |
| 695 | − emit(A64_CBNZ(0, tmp2, jmp_offset), ctx); | |
| 698 | + emit(A64_CBNZ(0, tmp3, jmp_offset), ctx); | |
| 696 | 699 | break; |
| 697 | 700 | |
| 698 | 701 | /* R0 = ntohx(*(size *)(((struct sk_buff *)R6)->data + imm)) */ |
| @@ -1066,7 +1066,7 @@ static void ssip_pn_setup(struct net_device *dev) · 1065 unmodified lines | ||
| 1066 | 1066 | dev->addr_len = 1; |
| 1067 | 1067 | dev->tx_queue_len = SSIP_TXQUEUE_LEN; |
| 1068 | 1068 | |
| 1069 | − dev->destructor = free_netdev; | |
| 1069 | + dev->needs_free_netdev = true; | |
| 1070 | 1070 | dev->header_ops = &phonet_header_ops; |
| 1071 | 1071 | } |
| 1072 | 1072 | |
| @@ -90,10 +90,13 @@ enum ad_link_speed_type { · 89 unmodified lines | ||
| 90 | 90 | AD_LINK_SPEED_100MBPS, |
| 91 | 91 | AD_LINK_SPEED_1000MBPS, |
| 92 | 92 | AD_LINK_SPEED_2500MBPS, |
| 93 | + AD_LINK_SPEED_5000MBPS, | |
| 93 | 94 | AD_LINK_SPEED_10000MBPS, |
| 95 | + AD_LINK_SPEED_14000MBPS, | |
| 94 | 96 | AD_LINK_SPEED_20000MBPS, |
| 95 | 97 | AD_LINK_SPEED_25000MBPS, |
| 96 | 98 | AD_LINK_SPEED_40000MBPS, |
| 99 | + AD_LINK_SPEED_50000MBPS, | |
| 97 | 100 | AD_LINK_SPEED_56000MBPS, |
| 98 | 101 | AD_LINK_SPEED_100000MBPS, |
| 99 | 102 | }; |
| @@ -259,10 +262,13 @@ static inline int __check_agg_selection_timer(struct port *port) · 159 unmodified lines | ||
| 259 | 262 | * %AD_LINK_SPEED_100MBPS, |
| 260 | 263 | * %AD_LINK_SPEED_1000MBPS, |
| 261 | 264 | * %AD_LINK_SPEED_2500MBPS, |
| 265 | + * %AD_LINK_SPEED_5000MBPS, | |
| 262 | 266 | * %AD_LINK_SPEED_10000MBPS |
| 267 | + * %AD_LINK_SPEED_14000MBPS, | |
| 263 | 268 | * %AD_LINK_SPEED_20000MBPS |
| 264 | 269 | * %AD_LINK_SPEED_25000MBPS |
| 265 | 270 | * %AD_LINK_SPEED_40000MBPS |
| 271 | + * %AD_LINK_SPEED_50000MBPS | |
| 266 | 272 | * %AD_LINK_SPEED_56000MBPS |
| 267 | 273 | * %AD_LINK_SPEED_100000MBPS |
| 268 | 274 | */ |
| @@ -296,10 +302,18 @@ static u16 __get_link_speed(struct port *port) · 27 unmodified lines | ||
| 296 | 302 | speed = AD_LINK_SPEED_2500MBPS; |
| 297 | 303 | break; |
| 298 | 304 | |
| 305 | + case SPEED_5000: | |
| 306 | + speed = AD_LINK_SPEED_5000MBPS; | |
| 307 | + break; | |
| 308 | + | |
| 299 | 309 | case SPEED_10000: |
| 300 | 310 | speed = AD_LINK_SPEED_10000MBPS; |
| 301 | 311 | break; |
| 302 | 312 | |
| 313 | + case SPEED_14000: | |
| 314 | + speed = AD_LINK_SPEED_14000MBPS; | |
| 315 | + break; | |
| 316 | + | |
| 303 | 317 | case SPEED_20000: |
| 304 | 318 | speed = AD_LINK_SPEED_20000MBPS; |
| 305 | 319 | break; |
| @@ -312,6 +326,10 @@ static u16 __get_link_speed(struct port *port) · 6 unmodified lines | ||
| 312 | 326 | speed = AD_LINK_SPEED_40000MBPS; |
| 313 | 327 | break; |
| 314 | 328 | |
| 329 | + case SPEED_50000: | |
| 330 | + speed = AD_LINK_SPEED_50000MBPS; | |
| 331 | + break; | |
| 332 | + | |
| 315 | 333 | case SPEED_56000: |
| 316 | 334 | speed = AD_LINK_SPEED_56000MBPS; |
| 317 | 335 | break; |
| @@ -707,9 +725,15 @@ static u32 __get_agg_bandwidth(struct aggregator *aggregator) · 389 unmodified lines | ||
| 707 | 725 | case AD_LINK_SPEED_2500MBPS: |
| 708 | 726 | bandwidth = nports * 2500; |
| 709 | 727 | break; |
| 728 | + case AD_LINK_SPEED_5000MBPS: | |
| 729 | + bandwidth = nports * 5000; | |
| 730 | + break; | |
| 710 | 731 | case AD_LINK_SPEED_10000MBPS: |
| 711 | 732 | bandwidth = nports * 10000; |
| 712 | 733 | break; |
| 734 | + case AD_LINK_SPEED_14000MBPS: | |
| 735 | + bandwidth = nports * 14000; | |
| 736 | + break; | |
| 713 | 737 | case AD_LINK_SPEED_20000MBPS: |
| 714 | 738 | bandwidth = nports * 20000; |
| 715 | 739 | break; |
| @@ -719,6 +743,9 @@ static u32 __get_agg_bandwidth(struct aggregator *aggregator) · 3 unmodified lines | ||
| 719 | 743 | case AD_LINK_SPEED_40000MBPS: |
| 720 | 744 | bandwidth = nports * 40000; |
| 721 | 745 | break; |
| 746 | + case AD_LINK_SPEED_50000MBPS: | |
| 747 | + bandwidth = nports * 50000; | |
| 748 | + break; | |
| 722 | 749 | case AD_LINK_SPEED_56000MBPS: |
| 723 | 750 | bandwidth = nports * 56000; |
| 724 | 751 | break; |
| @@ -4192,7 +4192,6 @@ static void bond_destructor(struct net_device *bond_dev) · 4191 unmodified lines | ||
| 4192 | 4192 | struct bonding *bond = netdev_priv(bond_dev); |
| 4193 | 4193 | if (bond->wq) |
| 4194 | 4194 | destroy_workqueue(bond->wq); |
| 4195 | − free_netdev(bond_dev); | |
| 4196 | 4195 | } |
| 4197 | 4196 | |
| 4198 | 4197 | void bond_setup(struct net_device *bond_dev) |
| @@ -4212,7 +4211,8 @@ void bond_setup(struct net_device *bond_dev) · 13 unmodified lines | ||
| 4212 | 4211 | bond_dev->netdev_ops = &bond_netdev_ops; |
| 4213 | 4212 | bond_dev->ethtool_ops = &bond_ethtool_ops; |
| 4214 | 4213 | |
| 4215 | − bond_dev->destructor = bond_destructor; | |
| 4214 | + bond_dev->needs_free_netdev = true; | |
| 4215 | + bond_dev->priv_destructor = bond_destructor; | |
| 4216 | 4216 | |
| 4217 | 4217 | SET_NETDEV_DEVTYPE(bond_dev, &bond_type); |
| 4218 | 4218 | |
| @@ -4736,7 +4736,7 @@ int bond_create(struct net *net, const char *name) · 517 unmodified lines | ||
| 4736 | 4736 | |
| 4737 | 4737 | rtnl_unlock(); |
| 4738 | 4738 | if (res < 0) |
| 4739 | − bond_destructor(bond_dev); | |
| 4739 | + free_netdev(bond_dev); | |
| 4740 | 4740 | return res; |
| 4741 | 4741 | } |
| 4742 | 4742 | |
| @@ -1121,7 +1121,7 @@ static void cfhsi_setup(struct net_device *dev) · 1120 unmodified lines | ||
| 1121 | 1121 | dev->flags = IFF_POINTOPOINT | IFF_NOARP; |
| 1122 | 1122 | dev->mtu = CFHSI_MAX_CAIF_FRAME_SZ; |
| 1123 | 1123 | dev->priv_flags |= IFF_NO_QUEUE; |
| 1124 | − dev->destructor = free_netdev; | |
| 1124 | + dev->needs_free_netdev = true; | |
| 1125 | 1125 | dev->netdev_ops = &cfhsi_netdevops; |
| 1126 | 1126 | for (i = 0; i < CFHSI_PRIO_LAST; ++i) |
| 1127 | 1127 | skb_queue_head_init(&cfhsi->qhead[i]); |
| @@ -428,7 +428,7 @@ static void caifdev_setup(struct net_device *dev) · 427 unmodified lines | ||
| 428 | 428 | dev->flags = IFF_POINTOPOINT | IFF_NOARP; |
| 429 | 429 | dev->mtu = CAIF_MAX_MTU; |
| 430 | 430 | dev->priv_flags |= IFF_NO_QUEUE; |
| 431 | − dev->destructor = free_netdev; | |
| 431 | + dev->needs_free_netdev = true; | |
| 432 | 432 | skb_queue_head_init(&serdev->head); |
| 433 | 433 | serdev->common.link_select = CAIF_LINK_LOW_LATENCY; |
| 434 | 434 | serdev->common.use_frag = true; |
| @@ -712,7 +712,7 @@ static void cfspi_setup(struct net_device *dev) · 711 unmodified lines | ||
| 712 | 712 | dev->flags = IFF_NOARP | IFF_POINTOPOINT; |
| 713 | 713 | dev->priv_flags |= IFF_NO_QUEUE; |
| 714 | 714 | dev->mtu = SPI_MAX_PAYLOAD_SIZE; |
| 715 | − dev->destructor = free_netdev; | |
| 715 | + dev->needs_free_netdev = true; | |
| 716 | 716 | skb_queue_head_init(&cfspi->qhead); |
| 717 | 717 | skb_queue_head_init(&cfspi->chead); |
| 718 | 718 | cfspi->cfdev.link_select = CAIF_LINK_HIGH_BANDW; |
| @@ -617,7 +617,7 @@ static void cfv_netdev_setup(struct net_device *netdev) · 616 unmodified lines | ||
| 617 | 617 | netdev->tx_queue_len = 100; |
| 618 | 618 | netdev->flags = IFF_POINTOPOINT | IFF_NOARP; |
| 619 | 619 | netdev->mtu = CFV_DEF_MTU_SIZE; |
| 620 | − netdev->destructor = free_netdev; | |
| 620 | + netdev->needs_free_netdev = true; | |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | /* Create debugfs counters for the device */ |
| @@ -391,6 +391,9 @@ void can_change_state(struct net_device *dev, struct can_frame *cf, · 390 unmodified lines | ||
| 391 | 391 | can_update_state_error_stats(dev, new_state); |
| 392 | 392 | priv->state = new_state; |
| 393 | 393 | |
| 394 | + if (!cf) | |
| 395 | + return; | |
| 396 | + | |
| 394 | 397 | if (unlikely(new_state == CAN_STATE_BUS_OFF)) { |
| 395 | 398 | cf->can_id |= CAN_ERR_BUSOFF; |
| 396 | 399 | return; |
| @@ -489,7 +489,7 @@ int peak_canfd_handle_msgs_list(struct peak_canfd_priv *priv, · 488 unmodified lines | ||
| 489 | 489 | struct pucan_rx_msg *msg_list, int msg_count) |
| 490 | 490 | { |
| 491 | 491 | void *msg_ptr = msg_list; |
| 492 | − int i, msg_size; | |
| 492 | + int i, msg_size = 0; | |
| 493 | 493 | |
| 494 | 494 | for (i = 0; i < msg_count; i++) { |
| 495 | 495 | msg_size = peak_canfd_handle_msg(priv, msg_ptr); |
| @@ -417,7 +417,7 @@ static int slc_open(struct net_device *dev) · 416 unmodified lines | ||
| 417 | 417 | static void slc_free_netdev(struct net_device *dev) |
| 418 | 418 | { |
| 419 | 419 | int i = dev->base_addr; |
| 420 | − free_netdev(dev); | |
| 420 | + | |
| 421 | 421 | slcan_devs[i] = NULL; |
| 422 | 422 | } |
| 423 | 423 | |
| @@ -436,7 +436,8 @@ static const struct net_device_ops slc_netdev_ops = { · 12 unmodified lines | ||
| 436 | 436 | static void slc_setup(struct net_device *dev) |
| 437 | 437 | { |
| 438 | 438 | dev->netdev_ops = &slc_netdev_ops; |
| 439 | − dev->destructor = slc_free_netdev; | |
| 439 | + dev->needs_free_netdev = true; | |
| 440 | + dev->priv_destructor = slc_free_netdev; | |
| 440 | 441 | |
| 441 | 442 | dev->hard_header_len = 0; |
| 442 | 443 | dev->addr_len = 0; |
| @@ -761,8 +762,6 @@ static void __exit slcan_exit(void) · 318 unmodified lines | ||
| 761 | 762 | if (sl->tty) { |
| 762 | 763 | printk(KERN_ERR "%s: tty discipline still running\n", |
| 763 | 764 | dev->name); |
| 764 | − /* Intentionally leak the control block. */ | |
| 765 | − dev->destructor = NULL; | |
| 766 | 765 | } |
| 767 | 766 | |
| 768 | 767 | unregister_netdev(dev); |
| @@ -265,6 +265,8 @@ static int gs_cmd_reset(struct gs_usb *gsusb, struct gs_can *gsdev) · 264 unmodified lines | ||
| 265 | 265 | sizeof(*dm), |
| 266 | 266 | 1000); |
| 267 | 267 | |
| 268 | + kfree(dm); | |
| 269 | + | |
| 268 | 270 | return rc; |
| 269 | 271 | } |
| 270 | 272 | |
| @@ -908,8 +908,6 @@ static int peak_usb_probe(struct usb_interface *intf, · 907 unmodified lines | ||
| 908 | 908 | const struct peak_usb_adapter *peak_usb_adapter = NULL; |
| 909 | 909 | int i, err = -ENOMEM; |
| 910 | 910 | |
| 911 | − usb_dev = interface_to_usbdev(intf); | |
| 912 | − | |
| 913 | 911 | /* get corresponding PCAN-USB adapter */ |
| 914 | 912 | for (i = 0; i < ARRAY_SIZE(peak_usb_adapters_list); i++) |
| 915 | 913 | if (peak_usb_adapters_list[i]->device_id == usb_id_product) { |
| @@ -920,7 +918,7 @@ static int peak_usb_probe(struct usb_interface *intf, · 4 unmodified lines | ||
| 920 | 918 | if (!peak_usb_adapter) { |
| 921 | 919 | /* should never come except device_id bad usage in this file */ |
| 922 | 920 | pr_err("%s: didn't find device id. 0x%x in devices list\n", |
| 923 | − PCAN_USB_DRIVER_NAME, usb_dev->descriptor.idProduct); | |
| 921 | + PCAN_USB_DRIVER_NAME, usb_id_product); | |
| 924 | 922 | return -ENODEV; |
| 925 | 923 | } |
| 926 | 924 | |
| @@ -152,7 +152,7 @@ static const struct net_device_ops vcan_netdev_ops = { · 151 unmodified lines | ||
| 152 | 152 | static void vcan_setup(struct net_device *dev) |
| 153 | 153 | { |
| 154 | 154 | dev->type = ARPHRD_CAN; |
| 155 | − dev->mtu = CAN_MTU; | |
| 155 | + dev->mtu = CANFD_MTU; | |
| 156 | 156 | dev->hard_header_len = 0; |
| 157 | 157 | dev->addr_len = 0; |
| 158 | 158 | dev->tx_queue_len = 0; |
| @@ -163,7 +163,7 @@ static void vcan_setup(struct net_device *dev) · 4 unmodified lines | ||
| 163 | 163 | dev->flags |= IFF_ECHO; |
| 164 | 164 | |
| 165 | 165 | dev->netdev_ops = &vcan_netdev_ops; |
| 166 | − dev->destructor = free_netdev; | |
| 166 | + dev->needs_free_netdev = true; | |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | static struct rtnl_link_ops vcan_link_ops __read_mostly = { |
| @@ -150,13 +150,13 @@ static const struct net_device_ops vxcan_netdev_ops = { · 149 unmodified lines | ||
| 150 | 150 | static void vxcan_setup(struct net_device *dev) |
| 151 | 151 | { |
| 152 | 152 | dev->type = ARPHRD_CAN; |
| 153 | − dev->mtu = CAN_MTU; | |
| 153 | + dev->mtu = CANFD_MTU; | |
| 154 | 154 | dev->hard_header_len = 0; |
| 155 | 155 | dev->addr_len = 0; |
| 156 | 156 | dev->tx_queue_len = 0; |
| 157 | 157 | dev->flags = (IFF_NOARP|IFF_ECHO); |
| 158 | 158 | dev->netdev_ops = &vxcan_netdev_ops; |
| 159 | − dev->destructor = free_netdev; | |
| 159 | + dev->needs_free_netdev = true; | |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /* forward declaration for rtnl_create_link() */ |
| @@ -328,7 +328,6 @@ static void dummy_free_netdev(struct net_device *dev) · 327 unmodified lines | ||
| 328 | 328 | struct dummy_priv *priv = netdev_priv(dev); |
| 329 | 329 | |
| 330 | 330 | kfree(priv->vfinfo); |
| 331 | − free_netdev(dev); | |
| 332 | 331 | } |
| 333 | 332 | |
| 334 | 333 | static void dummy_setup(struct net_device *dev) |
| @@ -338,7 +337,8 @@ static void dummy_setup(struct net_device *dev) · 3 unmodified lines | ||
| 338 | 337 | /* Initialize the device structure. */ |
| 339 | 338 | dev->netdev_ops = &dummy_netdev_ops; |
| 340 | 339 | dev->ethtool_ops = &dummy_ethtool_ops; |
| 341 | − dev->destructor = dummy_free_netdev; | |
| 340 | + dev->needs_free_netdev = true; | |
| 341 | + dev->priv_destructor = dummy_free_netdev; | |
| 342 | 342 | |
| 343 | 343 | /* Fill in device structure with ethernet-generic values. */ |
| 344 | 344 | dev->flags |= IFF_NOARP; |
| @@ -61,6 +61,8 @@ · 60 unmodified lines | ||
| 61 | 61 | |
| 62 | 62 | #define ENA_MMIO_READ_TIMEOUT 0xFFFFFFFF |
| 63 | 63 | |
| 64 | +#define ENA_REGS_ADMIN_INTR_MASK 1 | |
| 65 | + | |
| 64 | 66 | /*****************************************************************************/ |
| 65 | 67 | /*****************************************************************************/ |
| 66 | 68 | /*****************************************************************************/ |
| @@ -232,11 +234,9 @@ static struct ena_comp_ctx *__ena_com_submit_admin_cmd(struct ena_com_admin_queu · 165 unmodified lines | ||
| 232 | 234 | tail_masked = admin_queue->sq.tail & queue_size_mask; |
| 233 | 235 | |
| 234 | 236 | /* In case of queue FULL */ |
| 235 | − cnt = admin_queue->sq.tail - admin_queue->sq.head; | |
| 237 | + cnt = atomic_read(&admin_queue->outstanding_cmds); | |
| 236 | 238 | if (cnt >= admin_queue->q_depth) { |
| 237 | − pr_debug("admin queue is FULL (tail %d head %d depth: %d)\n", | |
| 238 | − admin_queue->sq.tail, admin_queue->sq.head, | |
| 239 | − admin_queue->q_depth); | |
| 239 | + pr_debug("admin queue is full.\n"); | |
| 240 | 240 | admin_queue->stats.out_of_space++; |
| 241 | 241 | return ERR_PTR(-ENOSPC); |
| 242 | 242 | } |
| @@ -508,15 +508,20 @@ static int ena_com_comp_status_to_errno(u8 comp_status) · 265 unmodified lines | ||
| 508 | 508 | static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_ctx, |
| 509 | 509 | struct ena_com_admin_queue *admin_queue) |
| 510 | 510 | { |
| 511 | − unsigned long flags; | |
| 512 | − u32 start_time; | |
| 511 | + unsigned long flags, timeout; | |
| 513 | 512 | int ret; |
| 514 | 513 | |
| 515 | − start_time = ((u32)jiffies_to_usecs(jiffies)); | |
| 514 | + timeout = jiffies + ADMIN_CMD_TIMEOUT_US; | |
| 515 | + | |
| 516 | + while (1) { | |
| 517 | + spin_lock_irqsave(&admin_queue->q_lock, flags); | |
| 518 | + ena_com_handle_admin_completion(admin_queue); | |
| 519 | + spin_unlock_irqrestore(&admin_queue->q_lock, flags); | |
| 520 | + | |
| 521 | + if (comp_ctx->status != ENA_CMD_SUBMITTED) | |
| 522 | + break; | |
| 516 | 523 | |
| 517 | − while (comp_ctx->status == ENA_CMD_SUBMITTED) { | |
| 518 | − if ((((u32)jiffies_to_usecs(jiffies)) - start_time) > | |
| 519 | − ADMIN_CMD_TIMEOUT_US) { | |
| 524 | + if (time_is_before_jiffies(timeout)) { | |
| 520 | 525 | pr_err("Wait for completion (polling) timeout\n"); |
| 521 | 526 | /* ENA didn't have any completion */ |
| 522 | 527 | spin_lock_irqsave(&admin_queue->q_lock, flags); |
| @@ -528,10 +533,6 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c · 5 unmodified lines | ||
| 528 | 533 | goto err; |
| 529 | 534 | } |
| 530 | 535 | |
| 531 | − spin_lock_irqsave(&admin_queue->q_lock, flags); | |
| 532 | − ena_com_handle_admin_completion(admin_queue); | |
| 533 | − spin_unlock_irqrestore(&admin_queue->q_lock, flags); | |
| 534 | − | |
| 535 | 536 | msleep(100); |
| 536 | 537 | } |
| 537 | 538 | |
| @@ -1455,6 +1456,12 @@ void ena_com_admin_destroy(struct ena_com_dev *ena_dev) · 917 unmodified lines | ||
| 1455 | 1456 | |
| 1456 | 1457 | void ena_com_set_admin_polling_mode(struct ena_com_dev *ena_dev, bool polling) |
| 1457 | 1458 | { |
| 1459 | + u32 mask_value = 0; | |
| 1460 | + | |
| 1461 | + if (polling) | |
| 1462 | + mask_value = ENA_REGS_ADMIN_INTR_MASK; | |
| 1463 | + | |
| 1464 | + writel(mask_value, ena_dev->reg_bar + ENA_REGS_INTR_MASK_OFF); | |
| 1458 | 1465 | ena_dev->admin_queue.polling = polling; |
| 1459 | 1466 | } |
| 1460 | 1467 | |
| @@ -80,7 +80,6 @@ static const struct ena_stats ena_stats_tx_strings[] = { · 79 unmodified lines | ||
| 80 | 80 | ENA_STAT_TX_ENTRY(tx_poll), |
| 81 | 81 | ENA_STAT_TX_ENTRY(doorbells), |
| 82 | 82 | ENA_STAT_TX_ENTRY(prepare_ctx_err), |
| 83 | − ENA_STAT_TX_ENTRY(missing_tx_comp), | |
| 84 | 83 | ENA_STAT_TX_ENTRY(bad_req_id), |
| 85 | 84 | }; |
| 86 | 85 | |
| @@ -94,6 +93,7 @@ static const struct ena_stats ena_stats_rx_strings[] = { · 7 unmodified lines | ||
| 94 | 93 | ENA_STAT_RX_ENTRY(dma_mapping_err), |
| 95 | 94 | ENA_STAT_RX_ENTRY(bad_desc_num), |
| 96 | 95 | ENA_STAT_RX_ENTRY(rx_copybreak_pkt), |
| 96 | + ENA_STAT_RX_ENTRY(empty_rx_ring), | |
| 97 | 97 | }; |
| 98 | 98 | |
| 99 | 99 | static const struct ena_stats ena_stats_ena_com_strings[] = { |
| @@ -190,6 +190,7 @@ static void ena_init_io_rings(struct ena_adapter *adapter) · 189 unmodified lines | ||
| 190 | 190 | rxr->sgl_size = adapter->max_rx_sgl_size; |
| 191 | 191 | rxr->smoothed_interval = |
| 192 | 192 | ena_com_get_nonadaptive_moderation_interval_rx(ena_dev); |
| 193 | + rxr->empty_rx_queue = 0; | |
| 193 | 194 | } |
| 194 | 195 | } |
| 195 | 196 | |
| @@ -1078,6 +1079,26 @@ inline void ena_adjust_intr_moderation(struct ena_ring *rx_ring, · 882 unmodified lines | ||
| 1078 | 1079 | rx_ring->per_napi_bytes = 0; |
| 1079 | 1080 | } |
| 1080 | 1081 | |
| 1082 | +static inline void ena_unmask_interrupt(struct ena_ring *tx_ring, | |
| 1083 | + struct ena_ring *rx_ring) | |
| 1084 | +{ | |
| 1085 | + struct ena_eth_io_intr_reg intr_reg; | |
| 1086 | + | |
| 1087 | + /* Update intr register: rx intr delay, | |
| 1088 | + * tx intr delay and interrupt unmask | |
| 1089 | + */ | |
| 1090 | + ena_com_update_intr_reg(&intr_reg, | |
| 1091 | + rx_ring->smoothed_interval, | |
| 1092 | + tx_ring->smoothed_interval, | |
| 1093 | + true); | |
| 1094 | + | |
| 1095 | + /* It is a shared MSI-X. | |
| 1096 | + * Tx and Rx CQ have pointer to it. | |
| 1097 | + * So we use one of them to reach the intr reg | |
| 1098 | + */ | |
| 1099 | + ena_com_unmask_intr(rx_ring->ena_com_io_cq, &intr_reg); | |
| 1100 | +} | |
| 1101 | + | |
| 1081 | 1102 | static inline void ena_update_ring_numa_node(struct ena_ring *tx_ring, |
| 1082 | 1103 | struct ena_ring *rx_ring) |
| 1083 | 1104 | { |
| @@ -1108,7 +1129,6 @@ static int ena_io_poll(struct napi_struct *napi, int budget) · 24 unmodified lines | ||
| 1108 | 1129 | { |
| 1109 | 1130 | struct ena_napi *ena_napi = container_of(napi, struct ena_napi, napi); |
| 1110 | 1131 | struct ena_ring *tx_ring, *rx_ring; |
| 1111 | − struct ena_eth_io_intr_reg intr_reg; | |
| 1112 | 1132 | |
| 1113 | 1133 | u32 tx_work_done; |
| 1114 | 1134 | u32 rx_work_done; |
| @@ -1149,22 +1169,9 @@ static int ena_io_poll(struct napi_struct *napi, int budget) · 34 unmodified lines | ||
| 1149 | 1169 | if (ena_com_get_adaptive_moderation_enabled(rx_ring->ena_dev)) |
| 1150 | 1170 | ena_adjust_intr_moderation(rx_ring, tx_ring); |
| 1151 | 1171 | |
| 1152 | − /* Update intr register: rx intr delay, | |
| 1153 | − * tx intr delay and interrupt unmask | |
| 1154 | − */ | |
| 1155 | − ena_com_update_intr_reg(&intr_reg, | |
| 1156 | − rx_ring->smoothed_interval, | |
| 1157 | − tx_ring->smoothed_interval, | |
| 1158 | − true); | |
| 1159 | − | |
| 1160 | − /* It is a shared MSI-X. | |
| 1161 | − * Tx and Rx CQ have pointer to it. | |
| 1162 | − * So we use one of them to reach the intr reg | |
| 1163 | − */ | |
| 1164 | − ena_com_unmask_intr(rx_ring->ena_com_io_cq, &intr_reg); | |
| 1172 | + ena_unmask_interrupt(tx_ring, rx_ring); | |
| 1165 | 1173 | } |
| 1166 | 1174 | |
| 1167 | − | |
| 1168 | 1175 | ena_update_ring_numa_node(tx_ring, rx_ring); |
| 1169 | 1176 | |
| 1170 | 1177 | ret = rx_work_done; |
| @@ -1485,6 +1492,11 @@ static int ena_up_complete(struct ena_adapter *adapter) · 314 unmodified lines | ||
| 1485 | 1492 | |
| 1486 | 1493 | ena_napi_enable_all(adapter); |
| 1487 | 1494 | |
| 1495 | + /* Enable completion queues interrupt */ | |
| 1496 | + for (i = 0; i < adapter->num_queues; i++) | |
| 1497 | + ena_unmask_interrupt(&adapter->tx_ring[i], | |
| 1498 | + &adapter->rx_ring[i]); | |
| 1499 | + | |
| 1488 | 1500 | /* schedule napi in case we had pending packets |
| 1489 | 1501 | * from the last time we disable napi |
| 1490 | 1502 | */ |
| @@ -1532,6 +1544,7 @@ static int ena_create_io_tx_queue(struct ena_adapter *adapter, int qid) · 41 unmodified lines | ||
| 1532 | 1544 | "Failed to get TX queue handlers. TX queue num %d rc: %d\n", |
| 1533 | 1545 | qid, rc); |
| 1534 | 1546 | ena_com_destroy_io_queue(ena_dev, ena_qid); |
| 1547 | + return rc; | |
| 1535 | 1548 | } |
| 1536 | 1549 | |
| 1537 | 1550 | ena_com_update_numa_node(tx_ring->ena_com_io_cq, ctx.numa_node); |
| @@ -1596,6 +1609,7 @@ static int ena_create_io_rx_queue(struct ena_adapter *adapter, int qid) · 58 unmodified lines | ||
| 1596 | 1609 | "Failed to get RX queue handlers. RX queue num %d rc: %d\n", |
| 1597 | 1610 | qid, rc); |
| 1598 | 1611 | ena_com_destroy_io_queue(ena_dev, ena_qid); |
| 1612 | + return rc; | |
| 1599 | 1613 | } |
| 1600 | 1614 | |
| 1601 | 1615 | ena_com_update_numa_node(rx_ring->ena_com_io_cq, ctx.numa_node); |
| @@ -1981,6 +1995,7 @@ static netdev_tx_t ena_start_xmit(struct sk_buff *skb, struct net_device *dev) · 379 unmodified lines | ||
| 1981 | 1995 | |
| 1982 | 1996 | tx_info->tx_descs = nb_hw_desc; |
| 1983 | 1997 | tx_info->last_jiffies = jiffies; |
| 1998 | + tx_info->print_once = 0; | |
| 1984 | 1999 | |
| 1985 | 2000 | tx_ring->next_to_use = ENA_TX_RING_IDX_NEXT(next_to_use, |
| 1986 | 2001 | tx_ring->ring_size); |
| @@ -2550,13 +2565,44 @@ err: · 563 unmodified lines | ||
| 2550 | 2565 | "Reset attempt failed. Can not reset the device\n"); |
| 2551 | 2566 | } |
| 2552 | 2567 | |
| 2553 | −static void check_for_missing_tx_completions(struct ena_adapter *adapter) | |
| 2568 | +static int check_missing_comp_in_queue(struct ena_adapter *adapter, | |
| 2569 | + struct ena_ring *tx_ring) | |
| 2554 | 2570 | { |
| 2555 | 2571 | struct ena_tx_buffer *tx_buf; |
| 2556 | 2572 | unsigned long last_jiffies; |
| 2573 | + u32 missed_tx = 0; | |
| 2574 | + int i; | |
| 2575 | + | |
| 2576 | + for (i = 0; i < tx_ring->ring_size; i++) { | |
| 2577 | + tx_buf = &tx_ring->tx_buffer_info[i]; | |
| 2578 | + last_jiffies = tx_buf->last_jiffies; | |
| 2579 | + if (unlikely(last_jiffies && | |
| 2580 | + time_is_before_jiffies(last_jiffies + TX_TIMEOUT))) { | |
| 2581 | + if (!tx_buf->print_once) | |
| 2582 | + netif_notice(adapter, tx_err, adapter->netdev, | |
| 2583 | + "Found a Tx that wasn't completed on time, qid %d, index %d.\n", | |
| 2584 | + tx_ring->qid, i); | |
| 2585 | + | |
| 2586 | + tx_buf->print_once = 1; | |
| 2587 | + missed_tx++; | |
| 2588 | + | |
| 2589 | + if (unlikely(missed_tx > MAX_NUM_OF_TIMEOUTED_PACKETS)) { | |
| 2590 | + netif_err(adapter, tx_err, adapter->netdev, | |
| 2591 | + "The number of lost tx completions is above the threshold (%d > %d). Reset the device\n", | |
| 2592 | + missed_tx, MAX_NUM_OF_TIMEOUTED_PACKETS); | |
| 2593 | + set_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags); | |
| 2594 | + return -EIO; | |
| 2595 | + } | |
| 2596 | + } | |
| 2597 | + } | |
| 2598 | + | |
| 2599 | + return 0; | |
| 2600 | +} | |
| 2601 | + | |
| 2602 | +static void check_for_missing_tx_completions(struct ena_adapter *adapter) | |
| 2603 | +{ | |
| 2557 | 2604 | struct ena_ring *tx_ring; |
| 2558 | − int i, j, budget; | |
| 2559 | − u32 missed_tx; | |
| 2605 | + int i, budget, rc; | |
| 2560 | 2606 | |
| 2561 | 2607 | /* Make sure the driver doesn't turn the device in other process */ |
| 2562 | 2608 | smp_rmb(); |
| @@ -2572,31 +2618,9 @@ static void check_for_missing_tx_completions(struct ena_adapter *adapter) · 9 unmodified lines | ||
| 2572 | 2618 | for (i = adapter->last_monitored_tx_qid; i < adapter->num_queues; i++) { |
| 2573 | 2619 | tx_ring = &adapter->tx_ring[i]; |
| 2574 | 2620 | |
| 2575 | − for (j = 0; j < tx_ring->ring_size; j++) { | |
| 2576 | − tx_buf = &tx_ring->tx_buffer_info[j]; | |
| 2577 | − last_jiffies = tx_buf->last_jiffies; | |
| 2578 | − if (unlikely(last_jiffies && time_is_before_jiffies(last_jiffies + TX_TIMEOUT))) { | |
| 2579 | − netif_notice(adapter, tx_err, adapter->netdev, | |
| 2580 | − "Found a Tx that wasn't completed on time, qid %d, index %d.\n", | |
| 2581 | − tx_ring->qid, j); | |
| 2582 | − | |
| 2583 | − u64_stats_update_begin(&tx_ring->syncp); | |
| 2584 | − missed_tx = tx_ring->tx_stats.missing_tx_comp++; | |
| 2585 | − u64_stats_update_end(&tx_ring->syncp); | |
| 2586 | − | |
| 2587 | − /* Clear last jiffies so the lost buffer won't | |
| 2588 | − * be counted twice. | |
| 2589 | − */ | |
| 2590 | − tx_buf->last_jiffies = 0; | |
| 2591 | − | |
| 2592 | − if (unlikely(missed_tx > MAX_NUM_OF_TIMEOUTED_PACKETS)) { | |
| 2593 | − netif_err(adapter, tx_err, adapter->netdev, | |
| 2594 | − "The number of lost tx completion is above the threshold (%d > %d). Reset the device\n", | |
| 2595 | − missed_tx, MAX_NUM_OF_TIMEOUTED_PACKETS); | |
| 2596 | − set_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags); | |
| 2597 | − } | |
| 2598 | − } | |
| 2599 | − } | |
| 2621 | + rc = check_missing_comp_in_queue(adapter, tx_ring); | |
| 2622 | + if (unlikely(rc)) | |
| 2623 | + return; | |
| 2600 | 2624 | |
| 2601 | 2625 | budget--; |
| 2602 | 2626 | if (!budget) |
| @@ -2606,6 +2630,58 @@ static void check_for_missing_tx_completions(struct ena_adapter *adapter) · 3 unmodified lines | ||
| 2606 | 2630 | adapter->last_monitored_tx_qid = i % adapter->num_queues; |
| 2607 | 2631 | } |
| 2608 | 2632 | |
| 2633 | +/* trigger napi schedule after 2 consecutive detections */ | |
| 2634 | +#define EMPTY_RX_REFILL 2 | |
| 2635 | +/* For the rare case where the device runs out of Rx descriptors and the | |
| 2636 | + * napi handler failed to refill new Rx descriptors (due to a lack of memory | |
| 2637 | + * for example). | |
| 2638 | + * This case will lead to a deadlock: | |
| 2639 | + * The device won't send interrupts since all the new Rx packets will be dropped | |
| 2640 | + * The napi handler won't allocate new Rx descriptors so the device will be | |
| 2641 | + * able to send new packets. | |
| 2642 | + * | |
| 2643 | + * This scenario can happen when the kernel's vm.min_free_kbytes is too small. | |
| 2644 | + * It is recommended to have at least 512MB, with a minimum of 128MB for | |
| 2645 | + * constrained environment). | |
| 2646 | + * | |
| 2647 | + * When such a situation is detected - Reschedule napi | |
| 2648 | + */ | |
| 2649 | +static void check_for_empty_rx_ring(struct ena_adapter *adapter) | |
| 2650 | +{ | |
| 2651 | + struct ena_ring *rx_ring; | |
| 2652 | + int i, refill_required; | |
| 2653 | + | |
| 2654 | + if (!test_bit(ENA_FLAG_DEV_UP, &adapter->flags)) | |
| 2655 | + return; | |
| 2656 | + | |
| 2657 | + if (test_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags)) | |
| 2658 | + return; | |
| 2659 | + | |
| 2660 | + for (i = 0; i < adapter->num_queues; i++) { | |
| 2661 | + rx_ring = &adapter->rx_ring[i]; | |
| 2662 | + | |
| 2663 | + refill_required = | |
| 2664 | + ena_com_sq_empty_space(rx_ring->ena_com_io_sq); | |
| 2665 | + if (unlikely(refill_required == (rx_ring->ring_size - 1))) { | |
| 2666 | + rx_ring->empty_rx_queue++; | |
| 2667 | + | |
| 2668 | + if (rx_ring->empty_rx_queue >= EMPTY_RX_REFILL) { | |
| 2669 | + u64_stats_update_begin(&rx_ring->syncp); | |
| 2670 | + rx_ring->rx_stats.empty_rx_ring++; | |
| 2671 | + u64_stats_update_end(&rx_ring->syncp); | |
| 2672 | + | |
| 2673 | + netif_err(adapter, drv, adapter->netdev, | |
| 2674 | + "trigger refill for ring %d\n", i); | |
| 2675 | + | |
| 2676 | + napi_schedule(rx_ring->napi); | |
| 2677 | + rx_ring->empty_rx_queue = 0; | |
| 2678 | + } | |
| 2679 | + } else { | |
| 2680 | + rx_ring->empty_rx_queue = 0; | |
| 2681 | + } | |
| 2682 | + } | |
| 2683 | +} | |
| 2684 | + | |
| 2609 | 2685 | /* Check for keep alive expiration */ |
| 2610 | 2686 | static void check_for_missing_keep_alive(struct ena_adapter *adapter) |
| 2611 | 2687 | { |
| @@ -2660,6 +2736,8 @@ static void ena_timer_service(unsigned long data) · 48 unmodified lines | ||
| 2660 | 2736 | |
| 2661 | 2737 | check_for_missing_tx_completions(adapter); |
| 2662 | 2738 | |
| 2739 | + check_for_empty_rx_ring(adapter); | |
| 2740 | + | |
| 2663 | 2741 | if (debug_area) |
| 2664 | 2742 | ena_dump_stats_to_buf(adapter, debug_area); |
| 2665 | 2743 | |
| @@ -2840,6 +2918,11 @@ static void ena_release_bars(struct ena_com_dev *ena_dev, struct pci_dev *pdev) · 174 unmodified lines | ||
| 2840 | 2918 | { |
| 2841 | 2919 | int release_bars; |
| 2842 | 2920 | |
| 2921 | + if (ena_dev->mem_bar) | |
| 2922 | + devm_iounmap(&pdev->dev, ena_dev->mem_bar); | |
| 2923 | + | |
| 2924 | + devm_iounmap(&pdev->dev, ena_dev->reg_bar); | |
| 2925 | + | |
| 2843 | 2926 | release_bars = pci_select_bars(pdev, IORESOURCE_MEM) & ENA_BAR_MASK; |
| 2844 | 2927 | pci_release_selected_regions(pdev, release_bars); |
| 2845 | 2928 | } |
| @@ -2927,8 +3010,9 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 81 unmodified lines | ||
| 2927 | 3010 | goto err_free_ena_dev; |
| 2928 | 3011 | } |
| 2929 | 3012 | |
| 2930 | − ena_dev->reg_bar = ioremap(pci_resource_start(pdev, ENA_REG_BAR), | |
| 2931 | − pci_resource_len(pdev, ENA_REG_BAR)); | |
| 3013 | + ena_dev->reg_bar = devm_ioremap(&pdev->dev, | |
| 3014 | + pci_resource_start(pdev, ENA_REG_BAR), | |
| 3015 | + pci_resource_len(pdev, ENA_REG_BAR)); | |
| 2932 | 3016 | if (!ena_dev->reg_bar) { |
| 2933 | 3017 | dev_err(&pdev->dev, "failed to remap regs bar\n"); |
| 2934 | 3018 | rc = -EFAULT; |
| @@ -2948,8 +3032,9 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 13 unmodified lines | ||
| 2948 | 3032 | ena_set_push_mode(pdev, ena_dev, &get_feat_ctx); |
| 2949 | 3033 | |
| 2950 | 3034 | if (ena_dev->tx_mem_queue_type == ENA_ADMIN_PLACEMENT_POLICY_DEV) { |
| 2951 | − ena_dev->mem_bar = ioremap_wc(pci_resource_start(pdev, ENA_MEM_BAR), | |
| 2952 | − pci_resource_len(pdev, ENA_MEM_BAR)); | |
| 3035 | + ena_dev->mem_bar = devm_ioremap_wc(&pdev->dev, | |
| 3036 | + pci_resource_start(pdev, ENA_MEM_BAR), | |
| 3037 | + pci_resource_len(pdev, ENA_MEM_BAR)); | |
| 2953 | 3038 | if (!ena_dev->mem_bar) { |
| 2954 | 3039 | rc = -EFAULT; |
| 2955 | 3040 | goto err_device_destroy; |
| @@ -45,7 +45,7 @@ · 44 unmodified lines | ||
| 45 | 45 | |
| 46 | 46 | #define DRV_MODULE_VER_MAJOR 1 |
| 47 | 47 | #define DRV_MODULE_VER_MINOR 1 |
| 48 | −#define DRV_MODULE_VER_SUBMINOR 2 | |
| 48 | +#define DRV_MODULE_VER_SUBMINOR 7 | |
| 49 | 49 | |
| 50 | 50 | #define DRV_MODULE_NAME "ena" |
| 51 | 51 | #ifndef DRV_MODULE_VERSION |
| @@ -146,7 +146,18 @@ struct ena_tx_buffer { · 94 unmodified lines | ||
| 146 | 146 | u32 tx_descs; |
| 147 | 147 | /* num of buffers used by this skb */ |
| 148 | 148 | u32 num_of_bufs; |
| 149 | − /* Save the last jiffies to detect missing tx packets */ | |
| 149 | + | |
| 150 | + /* Used for detect missing tx packets to limit the number of prints */ | |
| 151 | + u32 print_once; | |
| 152 | + /* Save the last jiffies to detect missing tx packets | |
| 153 | + * | |
| 154 | + * sets to non zero value on ena_start_xmit and set to zero on | |
| 155 | + * napi and timer_Service_routine. | |
| 156 | + * | |
| 157 | + * while this value is not protected by lock, | |
| 158 | + * a given packet is not expected to be handled by ena_start_xmit | |
| 159 | + * and by napi/timer_service at the same time. | |
| 160 | + */ | |
| 150 | 161 | unsigned long last_jiffies; |
| 151 | 162 | struct ena_com_buf bufs[ENA_PKT_MAX_BUFS]; |
| 152 | 163 | } ____cacheline_aligned; |
| @@ -170,7 +181,6 @@ struct ena_stats_tx { · 17 unmodified lines | ||
| 170 | 181 | u64 napi_comp; |
| 171 | 182 | u64 tx_poll; |
| 172 | 183 | u64 doorbells; |
| 173 | − u64 missing_tx_comp; | |
| 174 | 184 | u64 bad_req_id; |
| 175 | 185 | }; |
| 176 | 186 | |
| @@ -184,6 +194,7 @@ struct ena_stats_rx { · 7 unmodified lines | ||
| 184 | 194 | u64 dma_mapping_err; |
| 185 | 195 | u64 bad_desc_num; |
| 186 | 196 | u64 rx_copybreak_pkt; |
| 197 | + u64 empty_rx_ring; | |
| 187 | 198 | }; |
| 188 | 199 | |
| 189 | 200 | struct ena_ring { |
| @@ -231,6 +242,7 @@ struct ena_ring { · 41 unmodified lines | ||
| 231 | 242 | struct ena_stats_tx tx_stats; |
| 232 | 243 | struct ena_stats_rx rx_stats; |
| 233 | 244 | }; |
| 245 | + int empty_rx_queue; | |
| 234 | 246 | } ____cacheline_aligned; |
| 235 | 247 | |
| 236 | 248 | struct ena_stats_dev { |
| @@ -193,9 +193,6 @@ int hw_atl_utils_hw_get_regs(struct aq_hw_s *self, · 192 unmodified lines | ||
| 193 | 193 | struct aq_hw_caps_s *aq_hw_caps, |
| 194 | 194 | u32 *regs_buff); |
| 195 | 195 | |
| 196 | −int hw_atl_utils_hw_get_settings(struct aq_hw_s *self, | |
| 197 | − struct ethtool_cmd *cmd); | |
| 198 | − | |
| 199 | 196 | int hw_atl_utils_hw_set_power(struct aq_hw_s *self, |
| 200 | 197 | unsigned int power_state); |
| 201 | 198 | |
| @@ -3883,15 +3883,26 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev) · 3882 unmodified lines | ||
| 3883 | 3883 | /* when transmitting in a vf, start bd must hold the ethertype |
| 3884 | 3884 | * for fw to enforce it |
| 3885 | 3885 | */ |
| 3886 | + u16 vlan_tci = 0; | |
| 3886 | 3887 | #ifndef BNX2X_STOP_ON_ERROR |
| 3887 | − if (IS_VF(bp)) | |
| 3888 | + if (IS_VF(bp)) { | |
| 3888 | 3889 | #endif |
| 3889 | − tx_start_bd->vlan_or_ethertype = | |
| 3890 | − cpu_to_le16(ntohs(eth->h_proto)); | |
| 3890 | + /* Still need to consider inband vlan for enforced */ | |
| 3891 | + if (__vlan_get_tag(skb, &vlan_tci)) { | |
| 3892 | + tx_start_bd->vlan_or_ethertype = | |
| 3893 | + cpu_to_le16(ntohs(eth->h_proto)); | |
| 3894 | + } else { | |
| 3895 | + tx_start_bd->bd_flags.as_bitfield |= | |
| 3896 | + (X_ETH_INBAND_VLAN << | |
| 3897 | + ETH_TX_BD_FLAGS_VLAN_MODE_SHIFT); | |
| 3898 | + tx_start_bd->vlan_or_ethertype = | |
| 3899 | + cpu_to_le16(vlan_tci); | |
| 3900 | + } | |
| 3891 | 3901 | #ifndef BNX2X_STOP_ON_ERROR |
| 3892 | − else | |
| 3902 | + } else { | |
| 3893 | 3903 | /* used by FW for packet accounting */ |
| 3894 | 3904 | tx_start_bd->vlan_or_ethertype = cpu_to_le16(pkt_prod); |
| 3905 | + } | |
| 3895 | 3906 | #endif |
| 3896 | 3907 | } |
| 3897 | 3908 | |
| @@ -901,6 +901,8 @@ static void bnx2x_vf_flr(struct bnx2x *bp, struct bnx2x_virtf *vf) · 900 unmodified lines | ||
| 901 | 901 | /* release VF resources */ |
| 902 | 902 | bnx2x_vf_free_resc(bp, vf); |
| 903 | 903 | |
| 904 | + vf->malicious = false; | |
| 905 | + | |
| 904 | 906 | /* re-open the mailbox */ |
| 905 | 907 | bnx2x_vf_enable_mbx(bp, vf->abs_vfid); |
| 906 | 908 | return; |
| @@ -1822,9 +1824,11 @@ get_vf: · 915 unmodified lines | ||
| 1822 | 1824 | vf->abs_vfid, qidx); |
| 1823 | 1825 | bnx2x_vf_handle_rss_update_eqe(bp, vf); |
| 1824 | 1826 | case EVENT_RING_OPCODE_VF_FLR: |
| 1825 | − case EVENT_RING_OPCODE_MALICIOUS_VF: | |
| 1826 | 1827 | /* Do nothing for now */ |
| 1827 | 1828 | return 0; |
| 1829 | + case EVENT_RING_OPCODE_MALICIOUS_VF: | |
| 1830 | + vf->malicious = true; | |
| 1831 | + return 0; | |
| 1828 | 1832 | } |
| 1829 | 1833 | |
| 1830 | 1834 | return 0; |
| @@ -1905,6 +1909,13 @@ void bnx2x_iov_adjust_stats_req(struct bnx2x *bp) · 74 unmodified lines | ||
| 1905 | 1909 | continue; |
| 1906 | 1910 | } |
| 1907 | 1911 | |
| 1912 | + if (vf->malicious) { | |
| 1913 | + DP_AND((BNX2X_MSG_IOV | BNX2X_MSG_STATS), | |
| 1914 | + "vf %d malicious so no stats for it\n", | |
| 1915 | + vf->abs_vfid); | |
| 1916 | + continue; | |
| 1917 | + } | |
| 1918 | + | |
| 1908 | 1919 | DP_AND((BNX2X_MSG_IOV | BNX2X_MSG_STATS), |
| 1909 | 1920 | "add addresses for vf %d\n", vf->abs_vfid); |
| 1910 | 1921 | for_each_vfq(vf, j) { |
| @@ -3042,7 +3053,7 @@ void bnx2x_vf_pci_dealloc(struct bnx2x *bp) · 1131 unmodified lines | ||
| 3042 | 3053 | { |
| 3043 | 3054 | BNX2X_PCI_FREE(bp->vf2pf_mbox, bp->vf2pf_mbox_mapping, |
| 3044 | 3055 | sizeof(struct bnx2x_vf_mbx_msg)); |
| 3045 | − BNX2X_PCI_FREE(bp->vf2pf_mbox, bp->pf2vf_bulletin_mapping, | |
| 3056 | + BNX2X_PCI_FREE(bp->pf2vf_bulletin, bp->pf2vf_bulletin_mapping, | |
| 3046 | 3057 | sizeof(union pf_vf_bulletin)); |
| 3047 | 3058 | } |
| 3048 | 3059 | |
| @@ -141,6 +141,7 @@ struct bnx2x_virtf { · 140 unmodified lines | ||
| 141 | 141 | #define VF_RESET 3 /* VF FLR'd, pending cleanup */ |
| 142 | 142 | |
| 143 | 143 | bool flr_clnup_stage; /* true during flr cleanup */ |
| 144 | + bool malicious; /* true if FW indicated so, until FLR */ | |
| 144 | 145 | |
| 145 | 146 | /* dma */ |
| 146 | 147 | dma_addr_t fw_stat_map; |
| @@ -4525,7 +4525,7 @@ static void dummy_setup(struct net_device *dev) · 4524 unmodified lines | ||
| 4525 | 4525 | /* Initialize the device structure. */ |
| 4526 | 4526 | dev->netdev_ops = &cxgb4_mgmt_netdev_ops; |
| 4527 | 4527 | dev->ethtool_ops = &cxgb4_mgmt_ethtool_ops; |
| 4528 | − dev->destructor = free_netdev; | |
| 4528 | + dev->needs_free_netdev = true; | |
| 4529 | 4529 | } |
| 4530 | 4530 | |
| 4531 | 4531 | static int config_mgmt_dev(struct pci_dev *pdev) |
| @@ -343,6 +343,7 @@ static int emac_reset(struct emac_instance *dev) · 342 unmodified lines | ||
| 343 | 343 | { |
| 344 | 344 | struct emac_regs __iomem *p = dev->emacp; |
| 345 | 345 | int n = 20; |
| 346 | + bool __maybe_unused try_internal_clock = false; | |
| 346 | 347 | |
| 347 | 348 | DBG(dev, "reset" NL); |
| 348 | 349 | |
| @@ -355,6 +356,7 @@ static int emac_reset(struct emac_instance *dev) · 6 unmodified lines | ||
| 355 | 356 | } |
| 356 | 357 | |
| 357 | 358 | #ifdef CONFIG_PPC_DCR_NATIVE |
| 359 | +do_retry: | |
| 358 | 360 | /* |
| 359 | 361 | * PPC460EX/GT Embedded Processor Advanced User's Manual |
| 360 | 362 | * section 28.10.1 Mode Register 0 (EMACx_MR0) states: |
| @@ -362,10 +364,19 @@ static int emac_reset(struct emac_instance *dev) · 1 unmodified line | ||
| 362 | 364 | * of the EMAC. If none is present, select the internal clock |
| 363 | 365 | * (SDR0_ETH_CFG[EMACx_PHY_CLK] = 1). |
| 364 | 366 | * After a soft reset, select the external clock. |
| 367 | + * | |
| 368 | + * The AR8035-A PHY Meraki MR24 does not provide a TX Clk if the | |
| 369 | + * ethernet cable is not attached. This causes the reset to timeout | |
| 370 | + * and the PHY detection code in emac_init_phy() is unable to | |
| 371 | + * communicate and detect the AR8035-A PHY. As a result, the emac | |
| 372 | + * driver bails out early and the user has no ethernet. | |
| 373 | + * In order to stay compatible with existing configurations, the | |
| 374 | + * driver will temporarily switch to the internal clock, after | |
| 375 | + * the first reset fails. | |
| 365 | 376 | */ |
| 366 | 377 | if (emac_has_feature(dev, EMAC_FTR_460EX_PHY_CLK_FIX)) { |
| 367 | − if (dev->phy_address == 0xffffffff && | |
| 368 | − dev->phy_map == 0xffffffff) { | |
| 378 | + if (try_internal_clock || (dev->phy_address == 0xffffffff && | |
| 379 | + dev->phy_map == 0xffffffff)) { | |
| 369 | 380 | /* No PHY: select internal loop clock before reset */ |
| 370 | 381 | dcri_clrset(SDR0, SDR0_ETH_CFG, |
| 371 | 382 | 0, SDR0_ETH_CFG_ECS << dev->cell_index); |
| @@ -383,8 +394,15 @@ static int emac_reset(struct emac_instance *dev) · 11 unmodified lines | ||
| 383 | 394 | |
| 384 | 395 | #ifdef CONFIG_PPC_DCR_NATIVE |
| 385 | 396 | if (emac_has_feature(dev, EMAC_FTR_460EX_PHY_CLK_FIX)) { |
| 386 | − if (dev->phy_address == 0xffffffff && | |
| 387 | − dev->phy_map == 0xffffffff) { | |
| 397 | + if (!n && !try_internal_clock) { | |
| 398 | + /* first attempt has timed out. */ | |
| 399 | + n = 20; | |
| 400 | + try_internal_clock = true; | |
| 401 | + goto do_retry; | |
| 402 | + } | |
| 403 | + | |
| 404 | + if (try_internal_clock || (dev->phy_address == 0xffffffff && | |
| 405 | + dev->phy_map == 0xffffffff)) { | |
| 388 | 406 | /* No PHY: restore external clock source after reset */ |
| 389 | 407 | dcri_clrset(SDR0, SDR0_ETH_CFG, |
| 390 | 408 | SDR0_ETH_CFG_ECS << dev->cell_index, 0); |
| @@ -2460,20 +2478,24 @@ static int emac_mii_bus_reset(struct mii_bus *bus) · 2069 unmodified lines | ||
| 2460 | 2478 | return emac_reset(dev); |
| 2461 | 2479 | } |
| 2462 | 2480 | |
| 2481 | +static int emac_mdio_phy_start_aneg(struct mii_phy *phy, | |
| 2482 | + struct phy_device *phy_dev) | |
| 2483 | +{ | |
| 2484 | + phy_dev->autoneg = phy->autoneg; | |
| 2485 | + phy_dev->speed = phy->speed; | |
| 2486 | + phy_dev->duplex = phy->duplex; | |
| 2487 | + phy_dev->advertising = phy->advertising; | |
| 2488 | + return phy_start_aneg(phy_dev); | |
| 2489 | +} | |
| 2490 | + | |
| 2463 | 2491 | static int emac_mdio_setup_aneg(struct mii_phy *phy, u32 advertise) |
| 2464 | 2492 | { |
| 2465 | 2493 | struct net_device *ndev = phy->dev; |
| 2466 | 2494 | struct emac_instance *dev = netdev_priv(ndev); |
| 2467 | 2495 | |
| 2468 | − dev->phy.autoneg = AUTONEG_ENABLE; | |
| 2469 | − dev->phy.speed = SPEED_1000; | |
| 2470 | − dev->phy.duplex = DUPLEX_FULL; | |
| 2471 | − dev->phy.advertising = advertise; | |
| 2472 | 2496 | phy->autoneg = AUTONEG_ENABLE; |
| 2473 | − phy->speed = dev->phy.speed; | |
| 2474 | − phy->duplex = dev->phy.duplex; | |
| 2475 | 2497 | phy->advertising = advertise; |
| 2476 | − return phy_start_aneg(dev->phy_dev); | |
| 2498 | + return emac_mdio_phy_start_aneg(phy, dev->phy_dev); | |
| 2477 | 2499 | } |
| 2478 | 2500 | |
| 2479 | 2501 | static int emac_mdio_setup_forced(struct mii_phy *phy, int speed, int fd) |
| @@ -2481,13 +2503,10 @@ static int emac_mdio_setup_forced(struct mii_phy *phy, int speed, int fd) · 1 unmodified line | ||
| 2481 | 2503 | struct net_device *ndev = phy->dev; |
| 2482 | 2504 | struct emac_instance *dev = netdev_priv(ndev); |
| 2483 | 2505 | |
| 2484 | − dev->phy.autoneg = AUTONEG_DISABLE; | |
| 2485 | − dev->phy.speed = speed; | |
| 2486 | − dev->phy.duplex = fd; | |
| 2487 | 2506 | phy->autoneg = AUTONEG_DISABLE; |
| 2488 | 2507 | phy->speed = speed; |
| 2489 | 2508 | phy->duplex = fd; |
| 2490 | − return phy_start_aneg(dev->phy_dev); | |
| 2509 | + return emac_mdio_phy_start_aneg(phy, dev->phy_dev); | |
| 2491 | 2510 | } |
| 2492 | 2511 | |
| 2493 | 2512 | static int emac_mdio_poll_link(struct mii_phy *phy) |
| @@ -2509,16 +2528,17 @@ static int emac_mdio_read_link(struct mii_phy *phy) · 15 unmodified lines | ||
| 2509 | 2528 | { |
| 2510 | 2529 | struct net_device *ndev = phy->dev; |
| 2511 | 2530 | struct emac_instance *dev = netdev_priv(ndev); |
| 2531 | + struct phy_device *phy_dev = dev->phy_dev; | |
| 2512 | 2532 | int res; |
| 2513 | 2533 | |
| 2514 | − res = phy_read_status(dev->phy_dev); | |
| 2534 | + res = phy_read_status(phy_dev); | |
| 2515 | 2535 | if (res) |
| 2516 | 2536 | return res; |
| 2517 | 2537 | |
| 2518 | − dev->phy.speed = phy->speed; | |
| 2519 | − dev->phy.duplex = phy->duplex; | |
| 2520 | − dev->phy.pause = phy->pause; | |
| 2521 | − dev->phy.asym_pause = phy->asym_pause; | |
| 2538 | + phy->speed = phy_dev->speed; | |
| 2539 | + phy->duplex = phy_dev->duplex; | |
| 2540 | + phy->pause = phy_dev->pause; | |
| 2541 | + phy->asym_pause = phy_dev->asym_pause; | |
| 2522 | 2542 | return 0; |
| 2523 | 2543 | } |
| 2524 | 2544 | |
| @@ -2528,13 +2548,6 @@ static int emac_mdio_init_phy(struct mii_phy *phy) · 3 unmodified lines | ||
| 2528 | 2548 | struct emac_instance *dev = netdev_priv(ndev); |
| 2529 | 2549 | |
| 2530 | 2550 | phy_start(dev->phy_dev); |
| 2531 | − dev->phy.autoneg = phy->autoneg; | |
| 2532 | − dev->phy.speed = phy->speed; | |
| 2533 | − dev->phy.duplex = phy->duplex; | |
| 2534 | − dev->phy.advertising = phy->advertising; | |
| 2535 | − dev->phy.pause = phy->pause; | |
| 2536 | − dev->phy.asym_pause = phy->asym_pause; | |
| 2537 | − | |
| 2538 | 2551 | return phy_init_hw(dev->phy_dev); |
| 2539 | 2552 | } |
| 2540 | 2553 | |
| @@ -1468,6 +1468,11 @@ static void ibmvnic_netpoll_controller(struct net_device *dev) · 1467 unmodified lines | ||
| 1468 | 1468 | } |
| 1469 | 1469 | #endif |
| 1470 | 1470 | |
| 1471 | +static int ibmvnic_change_mtu(struct net_device *netdev, int new_mtu) | |
| 1472 | +{ | |
| 1473 | + return -EOPNOTSUPP; | |
| 1474 | +} | |
| 1475 | + | |
| 1471 | 1476 | static const struct net_device_ops ibmvnic_netdev_ops = { |
| 1472 | 1477 | .ndo_open = ibmvnic_open, |
| 1473 | 1478 | .ndo_stop = ibmvnic_close, |
| @@ -1479,6 +1484,7 @@ static const struct net_device_ops ibmvnic_netdev_ops = { · 5 unmodified lines | ||
| 1479 | 1484 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 1480 | 1485 | .ndo_poll_controller = ibmvnic_netpoll_controller, |
| 1481 | 1486 | #endif |
| 1487 | + .ndo_change_mtu = ibmvnic_change_mtu, | |
| 1482 | 1488 | }; |
| 1483 | 1489 | |
| 1484 | 1490 | /* ethtool functions */ |
| @@ -399,6 +399,7 @@ struct i40e_pf { · 398 unmodified lines | ||
| 399 | 399 | #define I40E_FLAG_RX_CSUM_ENABLED BIT_ULL(1) |
| 400 | 400 | #define I40E_FLAG_MSI_ENABLED BIT_ULL(2) |
| 401 | 401 | #define I40E_FLAG_MSIX_ENABLED BIT_ULL(3) |
| 402 | +#define I40E_FLAG_HW_ATR_EVICT_ENABLED BIT_ULL(4) | |
| 402 | 403 | #define I40E_FLAG_RSS_ENABLED BIT_ULL(6) |
| 403 | 404 | #define I40E_FLAG_VMDQ_ENABLED BIT_ULL(7) |
| 404 | 405 | #define I40E_FLAG_IWARP_ENABLED BIT_ULL(10) |
| @@ -224,7 +224,7 @@ static const struct i40e_priv_flags i40e_gstrings_priv_flags[] = { · 223 unmodified lines | ||
| 224 | 224 | I40E_PRIV_FLAG("LinkPolling", I40E_FLAG_LINK_POLLING_ENABLED, 0), |
| 225 | 225 | I40E_PRIV_FLAG("flow-director-atr", I40E_FLAG_FD_ATR_ENABLED, 0), |
| 226 | 226 | I40E_PRIV_FLAG("veb-stats", I40E_FLAG_VEB_STATS_ENABLED, 0), |
| 227 | − I40E_PRIV_FLAG("hw-atr-eviction", I40E_FLAG_HW_ATR_EVICT_CAPABLE, 0), | |
| 227 | + I40E_PRIV_FLAG("hw-atr-eviction", I40E_FLAG_HW_ATR_EVICT_ENABLED, 0), | |
| 228 | 228 | I40E_PRIV_FLAG("legacy-rx", I40E_FLAG_LEGACY_RX, 0), |
| 229 | 229 | }; |
| 230 | 230 | |
| @@ -4092,7 +4092,7 @@ flags_complete: · 3861 unmodified lines | ||
| 4092 | 4092 | |
| 4093 | 4093 | /* Only allow ATR evict on hardware that is capable of handling it */ |
| 4094 | 4094 | if (pf->flags & I40E_FLAG_HW_ATR_EVICT_CAPABLE) |
| 4095 | − pf->flags &= ~I40E_FLAG_HW_ATR_EVICT_CAPABLE; | |
| 4095 | + pf->flags &= ~I40E_FLAG_HW_ATR_EVICT_ENABLED; | |
| 4096 | 4096 | |
| 4097 | 4097 | if (changed_flags & I40E_FLAG_TRUE_PROMISC_SUPPORT) { |
| 4098 | 4098 | u16 sw_flags = 0, valid_flags = 0; |
| @@ -8821,11 +8821,12 @@ static int i40e_sw_init(struct i40e_pf *pf) · 8820 unmodified lines | ||
| 8821 | 8821 | (pf->hw.aq.api_min_ver > 4))) { |
| 8822 | 8822 | /* Supported in FW API version higher than 1.4 */ |
| 8823 | 8823 | pf->flags |= I40E_FLAG_GENEVE_OFFLOAD_CAPABLE; |
| 8824 | − pf->flags = I40E_FLAG_HW_ATR_EVICT_CAPABLE; | |
| 8825 | − } else { | |
| 8826 | − pf->flags = I40E_FLAG_HW_ATR_EVICT_CAPABLE; | |
| 8827 | 8824 | } |
| 8828 | 8825 | |
| 8826 | + /* Enable HW ATR eviction if possible */ | |
| 8827 | + if (pf->flags & I40E_FLAG_HW_ATR_EVICT_CAPABLE) | |
| 8828 | + pf->flags |= I40E_FLAG_HW_ATR_EVICT_ENABLED; | |
| 8829 | + | |
| 8829 | 8830 | pf->eeprom_version = 0xDEAD; |
| 8830 | 8831 | pf->lan_veb = I40E_NO_VEB; |
| 8831 | 8832 | pf->lan_vsi = I40E_NO_VSI; |
| @@ -2341,7 +2341,7 @@ static void i40e_atr(struct i40e_ring *tx_ring, struct sk_buff *skb, · 2340 unmodified lines | ||
| 2341 | 2341 | /* Due to lack of space, no more new filters can be programmed */ |
| 2342 | 2342 | if (th->syn && (pf->flags & I40E_FLAG_FD_ATR_AUTO_DISABLED)) |
| 2343 | 2343 | return; |
| 2344 | − if (pf->flags & I40E_FLAG_HW_ATR_EVICT_CAPABLE) { | |
| 2344 | + if (pf->flags & I40E_FLAG_HW_ATR_EVICT_ENABLED) { | |
| 2345 | 2345 | /* HW ATR eviction will take care of removing filters on FIN |
| 2346 | 2346 | * and RST packets. |
| 2347 | 2347 | */ |
| @@ -2403,7 +2403,7 @@ static void i40e_atr(struct i40e_ring *tx_ring, struct sk_buff *skb, · 55 unmodified lines | ||
| 2403 | 2403 | I40E_TXD_FLTR_QW1_CNTINDEX_SHIFT) & |
| 2404 | 2404 | I40E_TXD_FLTR_QW1_CNTINDEX_MASK; |
| 2405 | 2405 | |
| 2406 | − if (pf->flags & I40E_FLAG_HW_ATR_EVICT_CAPABLE) | |
| 2406 | + if (pf->flags & I40E_FLAG_HW_ATR_EVICT_ENABLED) | |
| 2407 | 2407 | dtype_cmd |= I40E_TXD_FLTR_QW1_ATR_MASK; |
| 2408 | 2408 | |
| 2409 | 2409 | fdir_desc->qindex_flex_ptype_vsi = cpu_to_le32(flex_ptype); |
| @@ -3017,10 +3017,12 @@ int i40e_ndo_set_vf_port_vlan(struct net_device *netdev, int vf_id, · 3016 unmodified lines | ||
| 3017 | 3017 | VLAN_VID_MASK)); |
| 3018 | 3018 | } |
| 3019 | 3019 | |
| 3020 | + spin_unlock_bh(&vsi->mac_filter_hash_lock); | |
| 3020 | 3021 | if (vlan_id || qos) |
| 3021 | 3022 | ret = i40e_vsi_add_pvid(vsi, vlanprio); |
| 3022 | 3023 | else |
| 3023 | 3024 | i40e_vsi_remove_pvid(vsi); |
| 3025 | + spin_lock_bh(&vsi->mac_filter_hash_lock); | |
| 3024 | 3026 | |
| 3025 | 3027 | if (vlan_id) { |
| 3026 | 3028 | dev_info(&pf->pdev->dev, "Setting VLAN %d, QOS 0x%x on VF %d\n", |
| @@ -3719,7 +3719,7 @@ static void mvpp2_bm_bufs_get_addrs(struct device *dev, struct mvpp2 *priv, · 3718 unmodified lines | ||
| 3719 | 3719 | dma_addr_t *dma_addr, |
| 3720 | 3720 | phys_addr_t *phys_addr) |
| 3721 | 3721 | { |
| 3722 | − int cpu = smp_processor_id(); | |
| 3722 | + int cpu = get_cpu(); | |
| 3723 | 3723 | |
| 3724 | 3724 | *dma_addr = mvpp2_percpu_read(priv, cpu, |
| 3725 | 3725 | MVPP2_BM_PHY_ALLOC_REG(bm_pool->id)); |
| @@ -3740,6 +3740,8 @@ static void mvpp2_bm_bufs_get_addrs(struct device *dev, struct mvpp2 *priv, · 14 unmodified lines | ||
| 3740 | 3740 | if (sizeof(phys_addr_t) == 8) |
| 3741 | 3741 | *phys_addr |= (u64)phys_addr_highbits << 32; |
| 3742 | 3742 | } |
| 3743 | + | |
| 3744 | + put_cpu(); | |
| 3743 | 3745 | } |
| 3744 | 3746 | |
| 3745 | 3747 | /* Free all buffers from the pool */ |
| @@ -3920,18 +3922,12 @@ static inline u32 mvpp2_bm_cookie_pool_set(u32 cookie, int pool) · 174 unmodified lines | ||
| 3920 | 3922 | return bm; |
| 3921 | 3923 | } |
| 3922 | 3924 | |
| 3923 | −/* Get pool number from a BM cookie */ | |
| 3924 | −static inline int mvpp2_bm_cookie_pool_get(unsigned long cookie) | |
| 3925 | −{ | |
| 3926 | − return (cookie >> MVPP2_BM_COOKIE_POOL_OFFS) & 0xFF; | |
| 3927 | −} | |
| 3928 | − | |
| 3929 | 3925 | /* Release buffer to BM */ |
| 3930 | 3926 | static inline void mvpp2_bm_pool_put(struct mvpp2_port *port, int pool, |
| 3931 | 3927 | dma_addr_t buf_dma_addr, |
| 3932 | 3928 | phys_addr_t buf_phys_addr) |
| 3933 | 3929 | { |
| 3934 | − int cpu = smp_processor_id(); | |
| 3930 | + int cpu = get_cpu(); | |
| 3935 | 3931 | |
| 3936 | 3932 | if (port->priv->hw_version == MVPP22) { |
| 3937 | 3933 | u32 val = 0; |
| @@ -3958,15 +3954,15 @@ static inline void mvpp2_bm_pool_put(struct mvpp2_port *port, int pool, · 20 unmodified lines | ||
| 3958 | 3954 | MVPP2_BM_VIRT_RLS_REG, buf_phys_addr); |
| 3959 | 3955 | mvpp2_percpu_write(port->priv, cpu, |
| 3960 | 3956 | MVPP2_BM_PHY_RLS_REG(pool), buf_dma_addr); |
| 3957 | + | |
| 3958 | + put_cpu(); | |
| 3961 | 3959 | } |
| 3962 | 3960 | |
| 3963 | 3961 | /* Refill BM pool */ |
| 3964 | −static void mvpp2_pool_refill(struct mvpp2_port *port, u32 bm, | |
| 3962 | +static void mvpp2_pool_refill(struct mvpp2_port *port, int pool, | |
| 3965 | 3963 | dma_addr_t dma_addr, |
| 3966 | 3964 | phys_addr_t phys_addr) |
| 3967 | 3965 | { |
| 3968 | − int pool = mvpp2_bm_cookie_pool_get(bm); | |
| 3969 | − | |
| 3970 | 3966 | mvpp2_bm_pool_put(port, pool, dma_addr, phys_addr); |
| 3971 | 3967 | } |
| 3972 | 3968 | |
| @@ -4186,8 +4182,6 @@ static void mvpp22_port_mii_set(struct mvpp2_port *port) · 213 unmodified lines | ||
| 4186 | 4182 | { |
| 4187 | 4183 | u32 val; |
| 4188 | 4184 | |
| 4189 | − return; | |
| 4190 | − | |
| 4191 | 4185 | /* Only GOP port 0 has an XLG MAC */ |
| 4192 | 4186 | if (port->gop_id == 0) { |
| 4193 | 4187 | val = readl(port->base + MVPP22_XLG_CTRL3_REG); |
| @@ -4515,21 +4509,6 @@ static void mvpp2_rxq_offset_set(struct mvpp2_port *port, · 321 unmodified lines | ||
| 4515 | 4509 | mvpp2_write(port->priv, MVPP2_RXQ_CONFIG_REG(prxq), val); |
| 4516 | 4510 | } |
| 4517 | 4511 | |
| 4518 | −/* Obtain BM cookie information from descriptor */ | |
| 4519 | −static u32 mvpp2_bm_cookie_build(struct mvpp2_port *port, | |
| 4520 | − struct mvpp2_rx_desc *rx_desc) | |
| 4521 | −{ | |
| 4522 | − int cpu = smp_processor_id(); | |
| 4523 | − int pool; | |
| 4524 | − | |
| 4525 | − pool = (mvpp2_rxdesc_status_get(port, rx_desc) & | |
| 4526 | − MVPP2_RXD_BM_POOL_ID_MASK) >> | |
| 4527 | − MVPP2_RXD_BM_POOL_ID_OFFS; | |
| 4528 | − | |
| 4529 | − return ((pool & 0xFF) << MVPP2_BM_COOKIE_POOL_OFFS) | | |
| 4530 | − ((cpu & 0xFF) << MVPP2_BM_COOKIE_CPU_OFFS); | |
| 4531 | −} | |
| 4532 | − | |
| 4533 | 4512 | /* Tx descriptors helper methods */ |
| 4534 | 4513 | |
| 4535 | 4514 | /* Get pointer to next Tx descriptor to be processed (send) by HW */ |
| @@ -4757,7 +4736,7 @@ static void mvpp2_txp_max_tx_size_set(struct mvpp2_port *port) · 221 unmodified lines | ||
| 4757 | 4736 | static void mvpp2_rx_pkts_coal_set(struct mvpp2_port *port, |
| 4758 | 4737 | struct mvpp2_rx_queue *rxq) |
| 4759 | 4738 | { |
| 4760 | − int cpu = smp_processor_id(); | |
| 4739 | + int cpu = get_cpu(); | |
| 4761 | 4740 | |
| 4762 | 4741 | if (rxq->pkts_coal > MVPP2_OCCUPIED_THRESH_MASK) |
| 4763 | 4742 | rxq->pkts_coal = MVPP2_OCCUPIED_THRESH_MASK; |
| @@ -4765,6 +4744,8 @@ static void mvpp2_rx_pkts_coal_set(struct mvpp2_port *port, · 1 unmodified line | ||
| 4765 | 4744 | mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_NUM_REG, rxq->id); |
| 4766 | 4745 | mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_THRESH_REG, |
| 4767 | 4746 | rxq->pkts_coal); |
| 4747 | + | |
| 4748 | + put_cpu(); | |
| 4768 | 4749 | } |
| 4769 | 4750 | |
| 4770 | 4751 | static u32 mvpp2_usec_to_cycles(u32 usec, unsigned long clk_hz) |
| @@ -4945,7 +4926,7 @@ static int mvpp2_rxq_init(struct mvpp2_port *port, · 174 unmodified lines | ||
| 4945 | 4926 | mvpp2_write(port->priv, MVPP2_RXQ_STATUS_REG(rxq->id), 0); |
| 4946 | 4927 | |
| 4947 | 4928 | /* Set Rx descriptors queue starting address - indirect access */ |
| 4948 | − cpu = smp_processor_id(); | |
| 4929 | + cpu = get_cpu(); | |
| 4949 | 4930 | mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_NUM_REG, rxq->id); |
| 4950 | 4931 | if (port->priv->hw_version == MVPP21) |
| 4951 | 4932 | rxq_dma = rxq->descs_dma; |
| @@ -4954,6 +4935,7 @@ static int mvpp2_rxq_init(struct mvpp2_port *port, · 2 unmodified lines | ||
| 4954 | 4935 | mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_DESC_ADDR_REG, rxq_dma); |
| 4955 | 4936 | mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_DESC_SIZE_REG, rxq->size); |
| 4956 | 4937 | mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_INDEX_REG, 0); |
| 4938 | + put_cpu(); | |
| 4957 | 4939 | |
| 4958 | 4940 | /* Set Offset */ |
| 4959 | 4941 | mvpp2_rxq_offset_set(port, rxq->id, NET_SKB_PAD); |
| @@ -4980,9 +4962,13 @@ static void mvpp2_rxq_drop_pkts(struct mvpp2_port *port, · 20 unmodified lines | ||
| 4980 | 4962 | |
| 4981 | 4963 | for (i = 0; i < rx_received; i++) { |
| 4982 | 4964 | struct mvpp2_rx_desc *rx_desc = mvpp2_rxq_next_desc_get(rxq); |
| 4983 | − u32 bm = mvpp2_bm_cookie_build(port, rx_desc); | |
| 4965 | + u32 status = mvpp2_rxdesc_status_get(port, rx_desc); | |
| 4966 | + int pool; | |
| 4967 | + | |
| 4968 | + pool = (status & MVPP2_RXD_BM_POOL_ID_MASK) >> | |
| 4969 | + MVPP2_RXD_BM_POOL_ID_OFFS; | |
| 4984 | 4970 | |
| 4985 | − mvpp2_pool_refill(port, bm, | |
| 4971 | + mvpp2_pool_refill(port, pool, | |
| 4986 | 4972 | mvpp2_rxdesc_dma_addr_get(port, rx_desc), |
| 4987 | 4973 | mvpp2_rxdesc_cookie_get(port, rx_desc)); |
| 4988 | 4974 | } |
| @@ -5012,10 +4998,11 @@ static void mvpp2_rxq_deinit(struct mvpp2_port *port, · 23 unmodified lines | ||
| 5012 | 4998 | * free descriptor number |
| 5013 | 4999 | */ |
| 5014 | 5000 | mvpp2_write(port->priv, MVPP2_RXQ_STATUS_REG(rxq->id), 0); |
| 5015 | − cpu = smp_processor_id(); | |
| 5001 | + cpu = get_cpu(); | |
| 5016 | 5002 | mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_NUM_REG, rxq->id); |
| 5017 | 5003 | mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_DESC_ADDR_REG, 0); |
| 5018 | 5004 | mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_DESC_SIZE_REG, 0); |
| 5005 | + put_cpu(); | |
| 5019 | 5006 | } |
| 5020 | 5007 | |
| 5021 | 5008 | /* Create and initialize a Tx queue */ |
| @@ -5038,7 +5025,7 @@ static int mvpp2_txq_init(struct mvpp2_port *port, · 16 unmodified lines | ||
| 5038 | 5025 | txq->last_desc = txq->size - 1; |
| 5039 | 5026 | |
| 5040 | 5027 | /* Set Tx descriptors queue starting address - indirect access */ |
| 5041 | − cpu = smp_processor_id(); | |
| 5028 | + cpu = get_cpu(); | |
| 5042 | 5029 | mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_NUM_REG, txq->id); |
| 5043 | 5030 | mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_DESC_ADDR_REG, |
| 5044 | 5031 | txq->descs_dma); |
| @@ -5063,6 +5050,7 @@ static int mvpp2_txq_init(struct mvpp2_port *port, · 18 unmodified lines | ||
| 5063 | 5050 | mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_PREF_BUF_REG, |
| 5064 | 5051 | MVPP2_PREF_BUF_PTR(desc) | MVPP2_PREF_BUF_SIZE_16 | |
| 5065 | 5052 | MVPP2_PREF_BUF_THRESH(desc_per_txq / 2)); |
| 5053 | + put_cpu(); | |
| 5066 | 5054 | |
| 5067 | 5055 | /* WRR / EJP configuration - indirect access */ |
| 5068 | 5056 | tx_port_num = mvpp2_egress_port(port); |
| @@ -5133,10 +5121,11 @@ static void mvpp2_txq_deinit(struct mvpp2_port *port, · 64 unmodified lines | ||
| 5133 | 5121 | mvpp2_write(port->priv, MVPP2_TXQ_SCHED_TOKEN_CNTR_REG(txq->id), 0); |
| 5134 | 5122 | |
| 5135 | 5123 | /* Set Tx descriptors queue starting address and size */ |
| 5136 | − cpu = smp_processor_id(); | |
| 5124 | + cpu = get_cpu(); | |
| 5137 | 5125 | mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_NUM_REG, txq->id); |
| 5138 | 5126 | mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_DESC_ADDR_REG, 0); |
| 5139 | 5127 | mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_DESC_SIZE_REG, 0); |
| 5128 | + put_cpu(); | |
| 5140 | 5129 | } |
| 5141 | 5130 | |
| 5142 | 5131 | /* Cleanup Tx ports */ |
| @@ -5146,7 +5135,7 @@ static void mvpp2_txq_clean(struct mvpp2_port *port, struct mvpp2_tx_queue *txq) · 3 unmodified lines | ||
| 5146 | 5135 | int delay, pending, cpu; |
| 5147 | 5136 | u32 val; |
| 5148 | 5137 | |
| 5149 | − cpu = smp_processor_id(); | |
| 5138 | + cpu = get_cpu(); | |
| 5150 | 5139 | mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_NUM_REG, txq->id); |
| 5151 | 5140 | val = mvpp2_percpu_read(port->priv, cpu, MVPP2_TXQ_PREF_BUF_REG); |
| 5152 | 5141 | val |= MVPP2_TXQ_DRAIN_EN_MASK; |
| @@ -5173,6 +5162,7 @@ static void mvpp2_txq_clean(struct mvpp2_port *port, struct mvpp2_tx_queue *txq) · 20 unmodified lines | ||
| 5173 | 5162 | |
| 5174 | 5163 | val &= ~MVPP2_TXQ_DRAIN_EN_MASK; |
| 5175 | 5164 | mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_PREF_BUF_REG, val); |
| 5165 | + put_cpu(); | |
| 5176 | 5166 | |
| 5177 | 5167 | for_each_present_cpu(cpu) { |
| 5178 | 5168 | txq_pcpu = per_cpu_ptr(txq->pcpu, cpu); |
| @@ -5420,7 +5410,7 @@ static void mvpp2_rx_csum(struct mvpp2_port *port, u32 status, · 241 unmodified lines | ||
| 5420 | 5410 | |
| 5421 | 5411 | /* Reuse skb if possible, or allocate a new skb and add it to BM pool */ |
| 5422 | 5412 | static int mvpp2_rx_refill(struct mvpp2_port *port, |
| 5423 | − struct mvpp2_bm_pool *bm_pool, u32 bm) | |
| 5413 | + struct mvpp2_bm_pool *bm_pool, int pool) | |
| 5424 | 5414 | { |
| 5425 | 5415 | dma_addr_t dma_addr; |
| 5426 | 5416 | phys_addr_t phys_addr; |
| @@ -5432,7 +5422,7 @@ static int mvpp2_rx_refill(struct mvpp2_port *port, · 5 unmodified lines | ||
| 5432 | 5422 | if (!buf) |
| 5433 | 5423 | return -ENOMEM; |
| 5434 | 5424 | |
| 5435 | − mvpp2_pool_refill(port, bm, dma_addr, phys_addr); | |
| 5425 | + mvpp2_pool_refill(port, pool, dma_addr, phys_addr); | |
| 5436 | 5426 | |
| 5437 | 5427 | return 0; |
| 5438 | 5428 | } |
| @@ -5490,7 +5480,7 @@ static int mvpp2_rx(struct mvpp2_port *port, int rx_todo, · 51 unmodified lines | ||
| 5490 | 5480 | unsigned int frag_size; |
| 5491 | 5481 | dma_addr_t dma_addr; |
| 5492 | 5482 | phys_addr_t phys_addr; |
| 5493 | − u32 bm, rx_status; | |
| 5483 | + u32 rx_status; | |
| 5494 | 5484 | int pool, rx_bytes, err; |
| 5495 | 5485 | void *data; |
| 5496 | 5486 | |
| @@ -5502,8 +5492,8 @@ static int mvpp2_rx(struct mvpp2_port *port, int rx_todo, · 5 unmodified lines | ||
| 5502 | 5492 | phys_addr = mvpp2_rxdesc_cookie_get(port, rx_desc); |
| 5503 | 5493 | data = (void *)phys_to_virt(phys_addr); |
| 5504 | 5494 | |
| 5505 | − bm = mvpp2_bm_cookie_build(port, rx_desc); | |
| 5506 | − pool = mvpp2_bm_cookie_pool_get(bm); | |
| 5495 | + pool = (rx_status & MVPP2_RXD_BM_POOL_ID_MASK) >> | |
| 5496 | + MVPP2_RXD_BM_POOL_ID_OFFS; | |
| 5507 | 5497 | bm_pool = &port->priv->bm_pools[pool]; |
| 5508 | 5498 | |
| 5509 | 5499 | /* In case of an error, release the requested buffer pointer |
| @@ -5516,7 +5506,7 @@ err_drop_frame: · 6 unmodified lines | ||
| 5516 | 5506 | dev->stats.rx_errors++; |
| 5517 | 5507 | mvpp2_rx_error(port, rx_desc); |
| 5518 | 5508 | /* Return the buffer to the pool */ |
| 5519 | − mvpp2_pool_refill(port, bm, dma_addr, phys_addr); | |
| 5509 | + mvpp2_pool_refill(port, pool, dma_addr, phys_addr); | |
| 5520 | 5510 | continue; |
| 5521 | 5511 | } |
| 5522 | 5512 | |
| @@ -5531,7 +5521,7 @@ err_drop_frame: · 8 unmodified lines | ||
| 5531 | 5521 | goto err_drop_frame; |
| 5532 | 5522 | } |
| 5533 | 5523 | |
| 5534 | − err = mvpp2_rx_refill(port, bm_pool, bm); | |
| 5524 | + err = mvpp2_rx_refill(port, bm_pool, pool); | |
| 5535 | 5525 | if (err) { |
| 5536 | 5526 | netdev_err(port->dev, "failed to refill BM pools\n"); |
| 5537 | 5527 | goto err_drop_frame; |
| @@ -458,13 +458,15 @@ struct mlx5e_mpw_info { · 457 unmodified lines | ||
| 458 | 458 | |
| 459 | 459 | struct mlx5e_rx_am_stats { |
| 460 | 460 | int ppms; /* packets per msec */ |
| 461 | + int bpms; /* bytes per msec */ | |
| 461 | 462 | int epms; /* events per msec */ |
| 462 | 463 | }; |
| 463 | 464 | |
| 464 | 465 | struct mlx5e_rx_am_sample { |
| 465 | − ktime_t time; | |
| 466 | − unsigned int pkt_ctr; | |
| 467 | − u16 event_ctr; | |
| 466 | + ktime_t time; | |
| 467 | + u32 pkt_ctr; | |
| 468 | + u32 byte_ctr; | |
| 469 | + u16 event_ctr; | |
| 468 | 470 | }; |
| 469 | 471 | |
| 470 | 472 | struct mlx5e_rx_am { /* Adaptive Moderation */ |
| @@ -183,28 +183,27 @@ static void mlx5e_am_exit_parking(struct mlx5e_rx_am *am) · 182 unmodified lines | ||
| 183 | 183 | mlx5e_am_step(am); |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | +#define IS_SIGNIFICANT_DIFF(val, ref) \ | |
| 187 | + (((100 * abs((val) - (ref))) / (ref)) > 10) /* more than 10% difference */ | |
| 188 | + | |
| 186 | 189 | static int mlx5e_am_stats_compare(struct mlx5e_rx_am_stats *curr, |
| 187 | 190 | struct mlx5e_rx_am_stats *prev) |
| 188 | 191 | { |
| 189 | − int diff; | |
| 190 | − | |
| 191 | − if (!prev->ppms) | |
| 192 | − return curr->ppms ? MLX5E_AM_STATS_BETTER : | |
| 192 | + if (!prev->bpms) | |
| 193 | + return curr->bpms ? MLX5E_AM_STATS_BETTER : | |
| 193 | 194 | MLX5E_AM_STATS_SAME; |
| 194 | 195 | |
| 195 | − diff = curr->ppms - prev->ppms; | |
| 196 | − if (((100 * abs(diff)) / prev->ppms) > 10) /* more than 10% diff */ | |
| 197 | − return (diff > 0) ? MLX5E_AM_STATS_BETTER : | |
| 198 | − MLX5E_AM_STATS_WORSE; | |
| 196 | + if (IS_SIGNIFICANT_DIFF(curr->bpms, prev->bpms)) | |
| 197 | + return (curr->bpms > prev->bpms) ? MLX5E_AM_STATS_BETTER : | |
| 198 | + MLX5E_AM_STATS_WORSE; | |
| 199 | 199 | |
| 200 | − if (!prev->epms) | |
| 201 | − return curr->epms ? MLX5E_AM_STATS_WORSE : | |
| 202 | − MLX5E_AM_STATS_SAME; | |
| 200 | + if (IS_SIGNIFICANT_DIFF(curr->ppms, prev->ppms)) | |
| 201 | + return (curr->ppms > prev->ppms) ? MLX5E_AM_STATS_BETTER : | |
| 202 | + MLX5E_AM_STATS_WORSE; | |
| 203 | 203 | |
| 204 | − diff = curr->epms - prev->epms; | |
| 205 | − if (((100 * abs(diff)) / prev->epms) > 10) /* more than 10% diff */ | |
| 206 | − return (diff < 0) ? MLX5E_AM_STATS_BETTER : | |
| 207 | − MLX5E_AM_STATS_WORSE; | |
| 204 | + if (IS_SIGNIFICANT_DIFF(curr->epms, prev->epms)) | |
| 205 | + return (curr->epms < prev->epms) ? MLX5E_AM_STATS_BETTER : | |
| 206 | + MLX5E_AM_STATS_WORSE; | |
| 208 | 207 | |
| 209 | 208 | return MLX5E_AM_STATS_SAME; |
| 210 | 209 | } |
| @@ -266,10 +265,13 @@ static void mlx5e_am_sample(struct mlx5e_rq *rq, · 55 unmodified lines | ||
| 266 | 265 | { |
| 267 | 266 | s->time = ktime_get(); |
| 268 | 267 | s->pkt_ctr = rq->stats.packets; |
| 268 | + s->byte_ctr = rq->stats.bytes; | |
| 269 | 269 | s->event_ctr = rq->cq.event_ctr; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | #define MLX5E_AM_NEVENTS 64 |
| 273 | +#define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE) | |
| 274 | +#define BIT_GAP(bits, end, start) ((((end) - (start)) + BIT_ULL(bits)) & (BIT_ULL(bits) - 1)) | |
| 273 | 275 | |
| 274 | 276 | static void mlx5e_am_calc_stats(struct mlx5e_rx_am_sample *start, |
| 275 | 277 | struct mlx5e_rx_am_sample *end, |
| @@ -277,13 +279,17 @@ static void mlx5e_am_calc_stats(struct mlx5e_rx_am_sample *start, · 1 unmodified line | ||
| 277 | 279 | { |
| 278 | 280 | /* u32 holds up to 71 minutes, should be enough */ |
| 279 | 281 | u32 delta_us = ktime_us_delta(end->time, start->time); |
| 280 | − unsigned int npkts = end->pkt_ctr - start->pkt_ctr; | |
| 282 | + u32 npkts = BIT_GAP(BITS_PER_TYPE(u32), end->pkt_ctr, start->pkt_ctr); | |
| 283 | + u32 nbytes = BIT_GAP(BITS_PER_TYPE(u32), end->byte_ctr, | |
| 284 | + start->byte_ctr); | |
| 281 | 285 | |
| 282 | 286 | if (!delta_us) |
| 283 | 287 | return; |
| 284 | 288 | |
| 285 | − curr_stats->ppms = (npkts * USEC_PER_MSEC) / delta_us; | |
| 286 | − curr_stats->epms = (MLX5E_AM_NEVENTS * USEC_PER_MSEC) / delta_us; | |
| 289 | + curr_stats->ppms = DIV_ROUND_UP(npkts * USEC_PER_MSEC, delta_us); | |
| 290 | + curr_stats->bpms = DIV_ROUND_UP(nbytes * USEC_PER_MSEC, delta_us); | |
| 291 | + curr_stats->epms = DIV_ROUND_UP(MLX5E_AM_NEVENTS * USEC_PER_MSEC, | |
| 292 | + delta_us); | |
| 287 | 293 | } |
| 288 | 294 | |
| 289 | 295 | void mlx5e_rx_am_work(struct work_struct *work) |
| @@ -308,7 +314,8 @@ void mlx5e_rx_am(struct mlx5e_rq *rq) · 18 unmodified lines | ||
| 308 | 314 | |
| 309 | 315 | switch (am->state) { |
| 310 | 316 | case MLX5E_AM_MEASURE_IN_PROGRESS: |
| 311 | − nevents = rq->cq.event_ctr - am->start_sample.event_ctr; | |
| 317 | + nevents = BIT_GAP(BITS_PER_TYPE(u16), rq->cq.event_ctr, | |
| 318 | + am->start_sample.event_ctr); | |
| 312 | 319 | if (nevents < MLX5E_AM_NEVENTS) |
| 313 | 320 | break; |
| 314 | 321 | mlx5e_am_sample(rq, &end_sample); |
| @@ -417,20 +417,13 @@ struct mlx5e_stats { · 416 unmodified lines | ||
| 417 | 417 | }; |
| 418 | 418 | |
| 419 | 419 | static const struct counter_desc mlx5e_pme_status_desc[] = { |
| 420 | − { "module_plug", 0 }, | |
| 421 | 420 | { "module_unplug", 8 }, |
| 422 | 421 | }; |
| 423 | 422 | |
| 424 | 423 | static const struct counter_desc mlx5e_pme_error_desc[] = { |
| 425 | − { "module_pwr_budget_exd", 0 }, /* power budget exceed */ | |
| 426 | − { "module_long_range", 8 }, /* long range for non MLNX cable */ | |
| 427 | − { "module_bus_stuck", 16 }, /* bus stuck (I2C or data shorted) */ | |
| 428 | − { "module_no_eeprom", 24 }, /* no eeprom/retry time out */ | |
| 429 | − { "module_enforce_part", 32 }, /* enforce part number list */ | |
| 430 | − { "module_unknown_id", 40 }, /* unknown identifier */ | |
| 431 | − { "module_high_temp", 48 }, /* high temperature */ | |
| 424 | + { "module_bus_stuck", 16 }, /* bus stuck (I2C or data shorted) */ | |
| 425 | + { "module_high_temp", 48 }, /* high temperature */ | |
| 432 | 426 | { "module_bad_shorted", 56 }, /* bad or shorted cable/module */ |
| 433 | − { "module_unknown_status", 64 }, | |
| 434 | 427 | }; |
| 435 | 428 | |
| 436 | 429 | #endif /* __MLX5_EN_STATS_H__ */ |
| @@ -862,7 +862,7 @@ struct mlx5_flow_table *mlx5_create_vport_flow_table(struct mlx5_flow_namespace · 861 unmodified lines | ||
| 862 | 862 | ft_attr.level = level; |
| 863 | 863 | ft_attr.prio = prio; |
| 864 | 864 | |
| 865 | − return __mlx5_create_flow_table(ns, &ft_attr, FS_FT_OP_MOD_NORMAL, 0); | |
| 865 | + return __mlx5_create_flow_table(ns, &ft_attr, FS_FT_OP_MOD_NORMAL, vport); | |
| 866 | 866 | } |
| 867 | 867 | |
| 868 | 868 | struct mlx5_flow_table* |
| @@ -275,10 +275,8 @@ static void poll_health(unsigned long data) · 274 unmodified lines | ||
| 275 | 275 | struct mlx5_core_health *health = &dev->priv.health; |
| 276 | 276 | u32 count; |
| 277 | 277 | |
| 278 | − if (dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) { | |
| 279 | − mod_timer(&health->timer, get_next_poll_jiffies()); | |
| 280 | − return; | |
| 281 | − } | |
| 278 | + if (dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) | |
| 279 | + goto out; | |
| 282 | 280 | |
| 283 | 281 | count = ioread32be(health->health_counter); |
| 284 | 282 | if (count == health->prev) |
| @@ -290,8 +288,6 @@ static void poll_health(unsigned long data) · 5 unmodified lines | ||
| 290 | 288 | if (health->miss_counter == MAX_MISSES) { |
| 291 | 289 | dev_err(&dev->pdev->dev, "device's health compromised - reached miss count\n"); |
| 292 | 290 | print_health_info(dev); |
| 293 | − } else { | |
| 294 | − mod_timer(&health->timer, get_next_poll_jiffies()); | |
| 295 | 291 | } |
| 296 | 292 | |
| 297 | 293 | if (in_fatal(dev) && !health->sick) { |
| @@ -305,6 +301,9 @@ static void poll_health(unsigned long data) · 7 unmodified lines | ||
| 305 | 301 | "new health works are not permitted at this stage\n"); |
| 306 | 302 | spin_unlock(&health->wq_lock); |
| 307 | 303 | } |
| 304 | + | |
| 305 | +out: | |
| 306 | + mod_timer(&health->timer, get_next_poll_jiffies()); | |
| 308 | 307 | } |
| 309 | 308 | |
| 310 | 309 | void mlx5_start_health_poll(struct mlx5_core_dev *dev) |
| @@ -537,8 +537,10 @@ static int handle_hca_cap(struct mlx5_core_dev *dev) · 536 unmodified lines | ||
| 537 | 537 | /* disable cmdif checksum */ |
| 538 | 538 | MLX5_SET(cmd_hca_cap, set_hca_cap, cmdif_checksum, 0); |
| 539 | 539 | |
| 540 | − /* If the HCA supports 4K UARs use it */ | |
| 541 | − if (MLX5_CAP_GEN_MAX(dev, uar_4k)) | |
| 540 | + /* Enable 4K UAR only when HCA supports it and page size is bigger | |
| 541 | + * than 4K. | |
| 542 | + */ | |
| 543 | + if (MLX5_CAP_GEN_MAX(dev, uar_4k) && PAGE_SIZE > 4096) | |
| 542 | 544 | MLX5_SET(cmd_hca_cap, set_hca_cap, uar_4k, 1); |
| 543 | 545 | |
| 544 | 546 | MLX5_SET(cmd_hca_cap, set_hca_cap, log_uar_page_sz, PAGE_SHIFT - 12); |
| @@ -2956,7 +2956,7 @@ static u32 qed_grc_dump_ctx_data(struct qed_hwfn *p_hwfn, · 2955 unmodified lines | ||
| 2956 | 2956 | qed_wr(p_hwfn, |
| 2957 | 2957 | p_ptt, |
| 2958 | 2958 | s_storm_defs[storm_id].cm_ctx_wr_addr, |
| 2959 | − BIT(9) | lid); | |
| 2959 | + (i << 9) | lid); | |
| 2960 | 2960 | *(dump_buf + offset) = qed_rd(p_hwfn, |
| 2961 | 2961 | p_ptt, |
| 2962 | 2962 | rd_reg_addr); |
| @@ -214,13 +214,13 @@ static int dwmac4_wrback_get_tx_timestamp_status(struct dma_desc *p) · 213 unmodified lines | ||
| 214 | 214 | { |
| 215 | 215 | /* Context type from W/B descriptor must be zero */ |
| 216 | 216 | if (le32_to_cpu(p->des3) & TDES3_CONTEXT_TYPE) |
| 217 | − return -EINVAL; | |
| 217 | + return 0; | |
| 218 | 218 | |
| 219 | 219 | /* Tx Timestamp Status is 1 so des0 and des1'll have valid values */ |
| 220 | 220 | if (le32_to_cpu(p->des3) & TDES3_TIMESTAMP_STATUS) |
| 221 | − return 0; | |
| 221 | + return 1; | |
| 222 | 222 | |
| 223 | − return 1; | |
| 223 | + return 0; | |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | static inline u64 dwmac4_get_timestamp(void *desc, u32 ats) |
| @@ -282,7 +282,10 @@ static int dwmac4_wrback_get_rx_timestamp_status(void *desc, u32 ats) · 55 unmodified lines | ||
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | 284 | exit: |
| 285 | − return ret; | |
| 285 | + if (likely(ret == 0)) | |
| 286 | + return 1; | |
| 287 | + | |
| 288 | + return 0; | |
| 286 | 289 | } |
| 287 | 290 | |
| 288 | 291 | static void dwmac4_rd_init_rx_desc(struct dma_desc *p, int disable_rx_ic, |
| @@ -434,14 +434,14 @@ static void stmmac_get_tx_hwtstamp(struct stmmac_priv *priv, · 433 unmodified lines | ||
| 434 | 434 | return; |
| 435 | 435 | |
| 436 | 436 | /* check tx tstamp status */ |
| 437 | − if (!priv->hw->desc->get_tx_timestamp_status(p)) { | |
| 437 | + if (priv->hw->desc->get_tx_timestamp_status(p)) { | |
| 438 | 438 | /* get the valid tstamp */ |
| 439 | 439 | ns = priv->hw->desc->get_timestamp(p, priv->adv_ts); |
| 440 | 440 | |
| 441 | 441 | memset(&shhwtstamp, 0, sizeof(struct skb_shared_hwtstamps)); |
| 442 | 442 | shhwtstamp.hwtstamp = ns_to_ktime(ns); |
| 443 | 443 | |
| 444 | − netdev_info(priv->dev, "get valid TX hw timestamp %llu\n", ns); | |
| 444 | + netdev_dbg(priv->dev, "get valid TX hw timestamp %llu\n", ns); | |
| 445 | 445 | /* pass tstamp to stack */ |
| 446 | 446 | skb_tstamp_tx(skb, &shhwtstamp); |
| 447 | 447 | } |
| @@ -468,19 +468,19 @@ static void stmmac_get_rx_hwtstamp(struct stmmac_priv *priv, struct dma_desc *p, · 20 unmodified lines | ||
| 468 | 468 | return; |
| 469 | 469 | |
| 470 | 470 | /* Check if timestamp is available */ |
| 471 | − if (!priv->hw->desc->get_rx_timestamp_status(p, priv->adv_ts)) { | |
| 471 | + if (priv->hw->desc->get_rx_timestamp_status(p, priv->adv_ts)) { | |
| 472 | 472 | /* For GMAC4, the valid timestamp is from CTX next desc. */ |
| 473 | 473 | if (priv->plat->has_gmac4) |
| 474 | 474 | ns = priv->hw->desc->get_timestamp(np, priv->adv_ts); |
| 475 | 475 | else |
| 476 | 476 | ns = priv->hw->desc->get_timestamp(p, priv->adv_ts); |
| 477 | 477 | |
| 478 | − netdev_info(priv->dev, "get valid RX hw timestamp %llu\n", ns); | |
| 478 | + netdev_dbg(priv->dev, "get valid RX hw timestamp %llu\n", ns); | |
| 479 | 479 | shhwtstamp = skb_hwtstamps(skb); |
| 480 | 480 | memset(shhwtstamp, 0, sizeof(struct skb_shared_hwtstamps)); |
| 481 | 481 | shhwtstamp->hwtstamp = ns_to_ktime(ns); |
| 482 | 482 | } else { |
| 483 | − netdev_err(priv->dev, "cannot get RX hw timestamp\n"); | |
| 483 | + netdev_dbg(priv->dev, "cannot get RX hw timestamp\n"); | |
| 484 | 484 | } |
| 485 | 485 | } |
| 486 | 486 | |
| @@ -546,7 +546,10 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr) · 59 unmodified lines | ||
| 546 | 546 | /* PTP v1, UDP, any kind of event packet */ |
| 547 | 547 | config.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT; |
| 548 | 548 | /* take time stamp for all event messages */ |
| 549 | − snap_type_sel = PTP_TCR_SNAPTYPSEL_1; | |
| 549 | + if (priv->plat->has_gmac4) | |
| 550 | + snap_type_sel = PTP_GMAC4_TCR_SNAPTYPSEL_1; | |
| 551 | + else | |
| 552 | + snap_type_sel = PTP_TCR_SNAPTYPSEL_1; | |
| 550 | 553 | |
| 551 | 554 | ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA; |
| 552 | 555 | ptp_over_ipv6_udp = PTP_TCR_TSIPV6ENA; |
| @@ -578,7 +581,10 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr) · 25 unmodified lines | ||
| 578 | 581 | config.rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT; |
| 579 | 582 | ptp_v2 = PTP_TCR_TSVER2ENA; |
| 580 | 583 | /* take time stamp for all event messages */ |
| 581 | − snap_type_sel = PTP_TCR_SNAPTYPSEL_1; | |
| 584 | + if (priv->plat->has_gmac4) | |
| 585 | + snap_type_sel = PTP_GMAC4_TCR_SNAPTYPSEL_1; | |
| 586 | + else | |
| 587 | + snap_type_sel = PTP_TCR_SNAPTYPSEL_1; | |
| 582 | 588 | |
| 583 | 589 | ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA; |
| 584 | 590 | ptp_over_ipv6_udp = PTP_TCR_TSIPV6ENA; |
| @@ -612,7 +618,10 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr) · 27 unmodified lines | ||
| 612 | 618 | config.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; |
| 613 | 619 | ptp_v2 = PTP_TCR_TSVER2ENA; |
| 614 | 620 | /* take time stamp for all event messages */ |
| 615 | − snap_type_sel = PTP_TCR_SNAPTYPSEL_1; | |
| 621 | + if (priv->plat->has_gmac4) | |
| 622 | + snap_type_sel = PTP_GMAC4_TCR_SNAPTYPSEL_1; | |
| 623 | + else | |
| 624 | + snap_type_sel = PTP_TCR_SNAPTYPSEL_1; | |
| 616 | 625 | |
| 617 | 626 | ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA; |
| 618 | 627 | ptp_over_ipv6_udp = PTP_TCR_TSIPV6ENA; |
| @@ -59,7 +59,8 @@ · 58 unmodified lines | ||
| 59 | 59 | /* Enable Snapshot for Messages Relevant to Master */ |
| 60 | 60 | #define PTP_TCR_TSMSTRENA BIT(15) |
| 61 | 61 | /* Select PTP packets for Taking Snapshots */ |
| 62 | −#define PTP_TCR_SNAPTYPSEL_1 GENMASK(17, 16) | |
| 62 | +#define PTP_TCR_SNAPTYPSEL_1 BIT(16) | |
| 63 | +#define PTP_GMAC4_TCR_SNAPTYPSEL_1 GENMASK(17, 16) | |
| 63 | 64 | /* Enable MAC address for PTP Frame Filtering */ |
| 64 | 65 | #define PTP_TCR_TSENMACADDR BIT(18) |
| 65 | 66 | |
| @@ -1007,7 +1007,7 @@ static void geneve_setup(struct net_device *dev) · 1006 unmodified lines | ||
| 1007 | 1007 | |
| 1008 | 1008 | dev->netdev_ops = &geneve_netdev_ops; |
| 1009 | 1009 | dev->ethtool_ops = &geneve_ethtool_ops; |
| 1010 | − dev->destructor = free_netdev; | |
| 1010 | + dev->needs_free_netdev = true; | |
| 1011 | 1011 | |
| 1012 | 1012 | SET_NETDEV_DEVTYPE(dev, &geneve_type); |
| 1013 | 1013 | |
| @@ -611,7 +611,7 @@ static const struct net_device_ops gtp_netdev_ops = { · 610 unmodified lines | ||
| 611 | 611 | static void gtp_link_setup(struct net_device *dev) |
| 612 | 612 | { |
| 613 | 613 | dev->netdev_ops = >p_netdev_ops; |
| 614 | − dev->destructor = free_netdev; | |
| 614 | + dev->needs_free_netdev = true; | |
| 615 | 615 | |
| 616 | 616 | dev->hard_header_len = 0; |
| 617 | 617 | dev->addr_len = 0; |
| @@ -311,7 +311,7 @@ static void sp_setup(struct net_device *dev) · 310 unmodified lines | ||
| 311 | 311 | { |
| 312 | 312 | /* Finish setting up the DEVICE info. */ |
| 313 | 313 | dev->netdev_ops = &sp_netdev_ops; |
| 314 | − dev->destructor = free_netdev; | |
| 314 | + dev->needs_free_netdev = true; | |
| 315 | 315 | dev->mtu = SIXP_MTU; |
| 316 | 316 | dev->hard_header_len = AX25_MAX_HEADER_LEN; |
| 317 | 317 | dev->header_ops = &ax25_header_ops; |
| @@ -476,7 +476,7 @@ static const struct net_device_ops bpq_netdev_ops = { · 475 unmodified lines | ||
| 476 | 476 | static void bpq_setup(struct net_device *dev) |
| 477 | 477 | { |
| 478 | 478 | dev->netdev_ops = &bpq_netdev_ops; |
| 479 | − dev->destructor = free_netdev; | |
| 479 | + dev->needs_free_netdev = true; | |
| 480 | 480 | |
| 481 | 481 | memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN); |
| 482 | 482 | memcpy(dev->dev_addr, &ax25_defaddr, AX25_ADDR_LEN); |
| @@ -171,6 +171,8 @@ struct rndis_device { · 170 unmodified lines | ||
| 171 | 171 | spinlock_t request_lock; |
| 172 | 172 | struct list_head req_list; |
| 173 | 173 | |
| 174 | + struct work_struct mcast_work; | |
| 175 | + | |
| 174 | 176 | u8 hw_mac_adr[ETH_ALEN]; |
| 175 | 177 | u8 rss_key[NETVSC_HASH_KEYLEN]; |
| 176 | 178 | u16 ind_table[ITAB_NUM]; |
| @@ -201,6 +203,7 @@ int rndis_filter_open(struct netvsc_device *nvdev); · 24 unmodified lines | ||
| 201 | 203 | int rndis_filter_close(struct netvsc_device *nvdev); |
| 202 | 204 | int rndis_filter_device_add(struct hv_device *dev, |
| 203 | 205 | struct netvsc_device_info *info); |
| 206 | +void rndis_filter_update(struct netvsc_device *nvdev); | |
| 204 | 207 | void rndis_filter_device_remove(struct hv_device *dev, |
| 205 | 208 | struct netvsc_device *nvdev); |
| 206 | 209 | int rndis_filter_set_rss_param(struct rndis_device *rdev, |
| @@ -211,7 +214,6 @@ int rndis_filter_receive(struct net_device *ndev, · 4 unmodified lines | ||
| 211 | 214 | struct vmbus_channel *channel, |
| 212 | 215 | void *data, u32 buflen); |
| 213 | 216 | |
| 214 | −int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter); | |
| 215 | 217 | int rndis_filter_set_device_mac(struct net_device *ndev, char *mac); |
| 216 | 218 | |
| 217 | 219 | void netvsc_switch_datapath(struct net_device *nv_dev, bool vf); |
| @@ -696,7 +698,6 @@ struct net_device_context { · 478 unmodified lines | ||
| 696 | 698 | /* list protection */ |
| 697 | 699 | spinlock_t lock; |
| 698 | 700 | |
| 699 | − struct work_struct work; | |
| 700 | 701 | u32 msg_enable; /* debug level */ |
| 701 | 702 | |
| 702 | 703 | u32 tx_checksum_mask; |
| @@ -56,37 +56,12 @@ static int debug = -1; · 55 unmodified lines | ||
| 56 | 56 | module_param(debug, int, S_IRUGO); |
| 57 | 57 | MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); |
| 58 | 58 | |
| 59 | −static void do_set_multicast(struct work_struct *w) | |
| 60 | −{ | |
| 61 | − struct net_device_context *ndevctx = | |
| 62 | − container_of(w, struct net_device_context, work); | |
| 63 | − struct hv_device *device_obj = ndevctx->device_ctx; | |
| 64 | − struct net_device *ndev = hv_get_drvdata(device_obj); | |
| 65 | − struct netvsc_device *nvdev = rcu_dereference(ndevctx->nvdev); | |
| 66 | − struct rndis_device *rdev; | |
| 67 | − | |
| 68 | − if (!nvdev) | |
| 69 | − return; | |
| 70 | − | |
| 71 | − rdev = nvdev->extension; | |
| 72 | − if (rdev == NULL) | |
| 73 | − return; | |
| 74 | − | |
| 75 | − if (ndev->flags & IFF_PROMISC) | |
| 76 | − rndis_filter_set_packet_filter(rdev, | |
| 77 | − NDIS_PACKET_TYPE_PROMISCUOUS); | |
| 78 | − else | |
| 79 | − rndis_filter_set_packet_filter(rdev, | |
| 80 | − NDIS_PACKET_TYPE_BROADCAST | | |
| 81 | − NDIS_PACKET_TYPE_ALL_MULTICAST | | |
| 82 | − NDIS_PACKET_TYPE_DIRECTED); | |
| 83 | −} | |
| 84 | − | |
| 85 | 59 | static void netvsc_set_multicast_list(struct net_device *net) |
| 86 | 60 | { |
| 87 | 61 | struct net_device_context *net_device_ctx = netdev_priv(net); |
| 62 | + struct netvsc_device *nvdev = rtnl_dereference(net_device_ctx->nvdev); | |
| 88 | 63 | |
| 89 | − schedule_work(&net_device_ctx->work); | |
| 64 | + rndis_filter_update(nvdev); | |
| 90 | 65 | } |
| 91 | 66 | |
| 92 | 67 | static int netvsc_open(struct net_device *net) |
| @@ -123,8 +98,6 @@ static int netvsc_close(struct net_device *net) · 30 unmodified lines | ||
| 123 | 98 | |
| 124 | 99 | netif_tx_disable(net); |
| 125 | 100 | |
| 126 | − /* Make sure netvsc_set_multicast_list doesn't re-enable filter! */ | |
| 127 | − cancel_work_sync(&net_device_ctx->work); | |
| 128 | 101 | ret = rndis_filter_close(nvdev); |
| 129 | 102 | if (ret != 0) { |
| 130 | 103 | netdev_err(net, "unable to close device (ret %d).\n", ret); |
| @@ -1028,7 +1001,7 @@ static const struct { · 897 unmodified lines | ||
| 1028 | 1001 | static int netvsc_get_sset_count(struct net_device *dev, int string_set) |
| 1029 | 1002 | { |
| 1030 | 1003 | struct net_device_context *ndc = netdev_priv(dev); |
| 1031 | − struct netvsc_device *nvdev = rcu_dereference(ndc->nvdev); | |
| 1004 | + struct netvsc_device *nvdev = rtnl_dereference(ndc->nvdev); | |
| 1032 | 1005 | |
| 1033 | 1006 | if (!nvdev) |
| 1034 | 1007 | return -ENODEV; |
| @@ -1158,11 +1131,22 @@ netvsc_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info, · 123 unmodified lines | ||
| 1158 | 1131 | } |
| 1159 | 1132 | |
| 1160 | 1133 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 1161 | −static void netvsc_poll_controller(struct net_device *net) | |
| 1134 | +static void netvsc_poll_controller(struct net_device *dev) | |
| 1162 | 1135 | { |
| 1163 | − /* As netvsc_start_xmit() works synchronous we don't have to | |
| 1164 | − * trigger anything here. | |
| 1165 | − */ | |
| 1136 | + struct net_device_context *ndc = netdev_priv(dev); | |
| 1137 | + struct netvsc_device *ndev; | |
| 1138 | + int i; | |
| 1139 | + | |
| 1140 | + rcu_read_lock(); | |
| 1141 | + ndev = rcu_dereference(ndc->nvdev); | |
| 1142 | + if (ndev) { | |
| 1143 | + for (i = 0; i < ndev->num_chn; i++) { | |
| 1144 | + struct netvsc_channel *nvchan = &ndev->chan_table[i]; | |
| 1145 | + | |
| 1146 | + napi_schedule(&nvchan->napi); | |
| 1147 | + } | |
| 1148 | + } | |
| 1149 | + rcu_read_unlock(); | |
| 1166 | 1150 | } |
| 1167 | 1151 | #endif |
| 1168 | 1152 | |
| @@ -1552,7 +1536,6 @@ static int netvsc_probe(struct hv_device *dev, · 383 unmodified lines | ||
| 1552 | 1536 | hv_set_drvdata(dev, net); |
| 1553 | 1537 | |
| 1554 | 1538 | INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_link_change); |
| 1555 | − INIT_WORK(&net_device_ctx->work, do_set_multicast); | |
| 1556 | 1539 | |
| 1557 | 1540 | spin_lock_init(&net_device_ctx->lock); |
| 1558 | 1541 | INIT_LIST_HEAD(&net_device_ctx->reconfig_events); |
| @@ -1622,7 +1605,6 @@ static int netvsc_remove(struct hv_device *dev) · 63 unmodified lines | ||
| 1622 | 1605 | netif_device_detach(net); |
| 1623 | 1606 | |
| 1624 | 1607 | cancel_delayed_work_sync(&ndev_ctx->dwork); |
| 1625 | − cancel_work_sync(&ndev_ctx->work); | |
| 1626 | 1608 | |
| 1627 | 1609 | /* |
| 1628 | 1610 | * Call to the vsc driver to let it know that the device is being |
| @@ -31,6 +31,7 @@ · 30 unmodified lines | ||
| 31 | 31 | |
| 32 | 32 | #include "hyperv_net.h" |
| 33 | 33 | |
| 34 | +static void rndis_set_multicast(struct work_struct *w); | |
| 34 | 35 | |
| 35 | 36 | #define RNDIS_EXT_LEN PAGE_SIZE |
| 36 | 37 | struct rndis_request { |
| @@ -76,6 +77,7 @@ static struct rndis_device *get_rndis_device(void) · 39 unmodified lines | ||
| 76 | 77 | spin_lock_init(&device->request_lock); |
| 77 | 78 | |
| 78 | 79 | INIT_LIST_HEAD(&device->req_list); |
| 80 | + INIT_WORK(&device->mcast_work, rndis_set_multicast); | |
| 79 | 81 | |
| 80 | 82 | device->state = RNDIS_DEV_UNINITIALIZED; |
| 81 | 83 | |
| @@ -815,7 +817,8 @@ static int rndis_filter_query_link_speed(struct rndis_device *dev) · 733 unmodified lines | ||
| 815 | 817 | return ret; |
| 816 | 818 | } |
| 817 | 819 | |
| 818 | −int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter) | |
| 820 | +static int rndis_filter_set_packet_filter(struct rndis_device *dev, | |
| 821 | + u32 new_filter) | |
| 819 | 822 | { |
| 820 | 823 | struct rndis_request *request; |
| 821 | 824 | struct rndis_set_request *set; |
| @@ -846,6 +849,28 @@ int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter) · 24 unmodified lines | ||
| 846 | 849 | return ret; |
| 847 | 850 | } |
| 848 | 851 | |
| 852 | +static void rndis_set_multicast(struct work_struct *w) | |
| 853 | +{ | |
| 854 | + struct rndis_device *rdev | |
| 855 | + = container_of(w, struct rndis_device, mcast_work); | |
| 856 | + | |
| 857 | + if (rdev->ndev->flags & IFF_PROMISC) | |
| 858 | + rndis_filter_set_packet_filter(rdev, | |
| 859 | + NDIS_PACKET_TYPE_PROMISCUOUS); | |
| 860 | + else | |
| 861 | + rndis_filter_set_packet_filter(rdev, | |
| 862 | + NDIS_PACKET_TYPE_BROADCAST | | |
| 863 | + NDIS_PACKET_TYPE_ALL_MULTICAST | | |
| 864 | + NDIS_PACKET_TYPE_DIRECTED); | |
| 865 | +} | |
| 866 | + | |
| 867 | +void rndis_filter_update(struct netvsc_device *nvdev) | |
| 868 | +{ | |
| 869 | + struct rndis_device *rdev = nvdev->extension; | |
| 870 | + | |
| 871 | + schedule_work(&rdev->mcast_work); | |
| 872 | +} | |
| 873 | + | |
| 849 | 874 | static int rndis_filter_init_device(struct rndis_device *dev) |
| 850 | 875 | { |
| 851 | 876 | struct rndis_request *request; |
| @@ -973,6 +998,9 @@ static int rndis_filter_close_device(struct rndis_device *dev) · 121 unmodified lines | ||
| 973 | 998 | if (dev->state != RNDIS_DEV_DATAINITIALIZED) |
| 974 | 999 | return 0; |
| 975 | 1000 | |
| 1001 | + /* Make sure rndis_set_multicast doesn't re-enable filter! */ | |
| 1002 | + cancel_work_sync(&dev->mcast_work); | |
| 1003 | + | |
| 976 | 1004 | ret = rndis_filter_set_packet_filter(dev, 0); |
| 977 | 1005 | if (ret == -ENODEV) |
| 978 | 1006 | ret = 0; |
| @@ -207,7 +207,6 @@ static void ifb_dev_free(struct net_device *dev) · 206 unmodified lines | ||
| 207 | 207 | __skb_queue_purge(&txp->tq); |
| 208 | 208 | } |
| 209 | 209 | kfree(dp->tx_private); |
| 210 | − free_netdev(dev); | |
| 211 | 210 | } |
| 212 | 211 | |
| 213 | 212 | static void ifb_setup(struct net_device *dev) |
| @@ -230,7 +229,8 @@ static void ifb_setup(struct net_device *dev) · 16 unmodified lines | ||
| 230 | 229 | dev->priv_flags &= ~IFF_TX_SKB_SHARING; |
| 231 | 230 | netif_keep_dst(dev); |
| 232 | 231 | eth_hw_addr_random(dev); |
| 233 | − dev->destructor = ifb_dev_free; | |
| 232 | + dev->needs_free_netdev = true; | |
| 233 | + dev->priv_destructor = ifb_dev_free; | |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | static netdev_tx_t ifb_xmit(struct sk_buff *skb, struct net_device *dev) |
| @@ -632,7 +632,7 @@ void ipvlan_link_setup(struct net_device *dev) · 631 unmodified lines | ||
| 632 | 632 | dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING); |
| 633 | 633 | dev->priv_flags |= IFF_UNICAST_FLT | IFF_NO_QUEUE; |
| 634 | 634 | dev->netdev_ops = &ipvlan_netdev_ops; |
| 635 | − dev->destructor = free_netdev; | |
| 635 | + dev->needs_free_netdev = true; | |
| 636 | 636 | dev->header_ops = &ipvlan_header_ops; |
| 637 | 637 | dev->ethtool_ops = &ipvlan_ethtool_ops; |
| 638 | 638 | } |
| @@ -159,7 +159,6 @@ static void loopback_dev_free(struct net_device *dev) · 158 unmodified lines | ||
| 159 | 159 | { |
| 160 | 160 | dev_net(dev)->loopback_dev = NULL; |
| 161 | 161 | free_percpu(dev->lstats); |
| 162 | − free_netdev(dev); | |
| 163 | 162 | } |
| 164 | 163 | |
| 165 | 164 | static const struct net_device_ops loopback_ops = { |
| @@ -196,7 +195,8 @@ static void loopback_setup(struct net_device *dev) · 30 unmodified lines | ||
| 196 | 195 | dev->ethtool_ops = &loopback_ethtool_ops; |
| 197 | 196 | dev->header_ops = ð_header_ops; |
| 198 | 197 | dev->netdev_ops = &loopback_ops; |
| 199 | − dev->destructor = loopback_dev_free; | |
| 198 | + dev->needs_free_netdev = true; | |
| 199 | + dev->priv_destructor = loopback_dev_free; | |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /* Setup and register the loopback device. */ |
| @@ -2996,7 +2996,6 @@ static void macsec_free_netdev(struct net_device *dev) · 2995 unmodified lines | ||
| 2996 | 2996 | free_percpu(macsec->secy.tx_sc.stats); |
| 2997 | 2997 | |
| 2998 | 2998 | dev_put(real_dev); |
| 2999 | − free_netdev(dev); | |
| 3000 | 2999 | } |
| 3001 | 3000 | |
| 3002 | 3001 | static void macsec_setup(struct net_device *dev) |
| @@ -3006,7 +3005,8 @@ static void macsec_setup(struct net_device *dev) · 3 unmodified lines | ||
| 3006 | 3005 | dev->max_mtu = ETH_MAX_MTU; |
| 3007 | 3006 | dev->priv_flags |= IFF_NO_QUEUE; |
| 3008 | 3007 | dev->netdev_ops = &macsec_netdev_ops; |
| 3009 | − dev->destructor = macsec_free_netdev; | |
| 3008 | + dev->needs_free_netdev = true; | |
| 3009 | + dev->priv_destructor = macsec_free_netdev; | |
| 3010 | 3010 | SET_NETDEV_DEVTYPE(dev, &macsec_type); |
| 3011 | 3011 | |
| 3012 | 3012 | eth_zero_addr(dev->broadcast); |
| @@ -1092,7 +1092,7 @@ void macvlan_common_setup(struct net_device *dev) · 1091 unmodified lines | ||
| 1092 | 1092 | netif_keep_dst(dev); |
| 1093 | 1093 | dev->priv_flags |= IFF_UNICAST_FLT; |
| 1094 | 1094 | dev->netdev_ops = &macvlan_netdev_ops; |
| 1095 | − dev->destructor = free_netdev; | |
| 1095 | + dev->needs_free_netdev = true; | |
| 1096 | 1096 | dev->header_ops = &macvlan_hard_header_ops; |
| 1097 | 1097 | dev->ethtool_ops = &macvlan_ethtool_ops; |
| 1098 | 1098 | } |
| @@ -358,7 +358,7 @@ static ssize_t enabled_store(struct config_item *item, · 357 unmodified lines | ||
| 358 | 358 | if (err) |
| 359 | 359 | goto out_unlock; |
| 360 | 360 | |
| 361 | − pr_info("netconsole: network logging started\n"); | |
| 361 | + pr_info("network logging started\n"); | |
| 362 | 362 | } else { /* false */ |
| 363 | 363 | /* We need to disable the netconsole before cleaning it up |
| 364 | 364 | * otherwise we might end up in write_msg() with |
| @@ -113,7 +113,7 @@ static void nlmon_setup(struct net_device *dev) · 112 unmodified lines | ||
| 113 | 113 | |
| 114 | 114 | dev->netdev_ops = &nlmon_ops; |
| 115 | 115 | dev->ethtool_ops = &nlmon_ethtool_ops; |
| 116 | − dev->destructor = free_netdev; | |
| 116 | + dev->needs_free_netdev = true; | |
| 117 | 117 | |
| 118 | 118 | dev->features = NETIF_F_SG | NETIF_F_FRAGLIST | |
| 119 | 119 | NETIF_F_HIGHDMA | NETIF_F_LLTX; |
| @@ -127,6 +127,7 @@ config MDIO_THUNDER · 126 unmodified lines | ||
| 127 | 127 | tristate "ThunderX SOCs MDIO buses" |
| 128 | 128 | depends on 64BIT |
| 129 | 129 | depends on PCI |
| 130 | + depends on !(MDIO_DEVICE=y && PHYLIB=m) | |
| 130 | 131 | select MDIO_CAVIUM |
| 131 | 132 | help |
| 132 | 133 | This driver supports the MDIO interfaces found on Cavium |
| @@ -54,6 +54,8 @@ static const char *phy_speed_to_str(int speed) · 53 unmodified lines | ||
| 54 | 54 | return "5Gbps"; |
| 55 | 55 | case SPEED_10000: |
| 56 | 56 | return "10Gbps"; |
| 57 | + case SPEED_14000: | |
| 58 | + return "14Gbps"; | |
| 57 | 59 | case SPEED_20000: |
| 58 | 60 | return "20Gbps"; |
| 59 | 61 | case SPEED_25000: |
| @@ -629,7 +629,7 @@ static void sl_uninit(struct net_device *dev) · 628 unmodified lines | ||
| 629 | 629 | static void sl_free_netdev(struct net_device *dev) |
| 630 | 630 | { |
| 631 | 631 | int i = dev->base_addr; |
| 632 | − free_netdev(dev); | |
| 632 | + | |
| 633 | 633 | slip_devs[i] = NULL; |
| 634 | 634 | } |
| 635 | 635 | |
| @@ -651,7 +651,8 @@ static const struct net_device_ops sl_netdev_ops = { · 15 unmodified lines | ||
| 651 | 651 | static void sl_setup(struct net_device *dev) |
| 652 | 652 | { |
| 653 | 653 | dev->netdev_ops = &sl_netdev_ops; |
| 654 | − dev->destructor = sl_free_netdev; | |
| 654 | + dev->needs_free_netdev = true; | |
| 655 | + dev->priv_destructor = sl_free_netdev; | |
| 655 | 656 | |
| 656 | 657 | dev->hard_header_len = 0; |
| 657 | 658 | dev->addr_len = 0; |
| @@ -1369,8 +1370,6 @@ static void __exit slip_exit(void) · 711 unmodified lines | ||
| 1369 | 1370 | if (sl->tty) { |
| 1370 | 1371 | printk(KERN_ERR "%s: tty discipline still running\n", |
| 1371 | 1372 | dev->name); |
| 1372 | − /* Intentionally leak the control block. */ | |
| 1373 | − dev->destructor = NULL; | |
| 1374 | 1373 | } |
| 1375 | 1374 | |
| 1376 | 1375 | unregister_netdev(dev); |
| @@ -1643,7 +1643,6 @@ static void team_destructor(struct net_device *dev) · 1642 unmodified lines | ||
| 1643 | 1643 | struct team *team = netdev_priv(dev); |
| 1644 | 1644 | |
| 1645 | 1645 | free_percpu(team->pcpu_stats); |
| 1646 | − free_netdev(dev); | |
| 1647 | 1646 | } |
| 1648 | 1647 | |
| 1649 | 1648 | static int team_open(struct net_device *dev) |
| @@ -2079,7 +2078,8 @@ static void team_setup(struct net_device *dev) · 429 unmodified lines | ||
| 2079 | 2078 | |
| 2080 | 2079 | dev->netdev_ops = &team_netdev_ops; |
| 2081 | 2080 | dev->ethtool_ops = &team_ethtool_ops; |
| 2082 | − dev->destructor = team_destructor; | |
| 2081 | + dev->needs_free_netdev = true; | |
| 2082 | + dev->priv_destructor = team_destructor; | |
| 2083 | 2083 | dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING); |
| 2084 | 2084 | dev->priv_flags |= IFF_NO_QUEUE; |
| 2085 | 2085 | dev->priv_flags |= IFF_TEAM; |
| @@ -1560,7 +1560,6 @@ static void tun_free_netdev(struct net_device *dev) · 1559 unmodified lines | ||
| 1560 | 1560 | free_percpu(tun->pcpu_stats); |
| 1561 | 1561 | tun_flow_uninit(tun); |
| 1562 | 1562 | security_tun_dev_free_security(tun->security); |
| 1563 | − free_netdev(dev); | |
| 1564 | 1563 | } |
| 1565 | 1564 | |
| 1566 | 1565 | static void tun_setup(struct net_device *dev) |
| @@ -1571,7 +1570,8 @@ static void tun_setup(struct net_device *dev) · 4 unmodified lines | ||
| 1571 | 1570 | tun->group = INVALID_GID; |
| 1572 | 1571 | |
| 1573 | 1572 | dev->ethtool_ops = &tun_ethtool_ops; |
| 1574 | − dev->destructor = tun_free_netdev; | |
| 1573 | + dev->needs_free_netdev = true; | |
| 1574 | + dev->priv_destructor = tun_free_netdev; | |
| 1575 | 1575 | /* We prefer our own queue length */ |
| 1576 | 1576 | dev->tx_queue_len = TUN_READQ_SIZE; |
| 1577 | 1577 | } |
| @@ -298,7 +298,7 @@ static void usbpn_setup(struct net_device *dev) · 297 unmodified lines | ||
| 298 | 298 | dev->addr_len = 1; |
| 299 | 299 | dev->tx_queue_len = 3; |
| 300 | 300 | |
| 301 | − dev->destructor = free_netdev; | |
| 301 | + dev->needs_free_netdev = true; | |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /* |
| @@ -123,7 +123,7 @@ static void qmimux_setup(struct net_device *dev) · 122 unmodified lines | ||
| 123 | 123 | dev->addr_len = 0; |
| 124 | 124 | dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST; |
| 125 | 125 | dev->netdev_ops = &qmimux_netdev_ops; |
| 126 | − dev->destructor = free_netdev; | |
| 126 | + dev->needs_free_netdev = true; | |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | static struct net_device *qmimux_find_dev(struct usbnet *dev, u8 mux_id) |
| @@ -1192,6 +1192,8 @@ static const struct usb_device_id products[] = { · 1062 unmodified lines | ||
| 1192 | 1192 | {QMI_FIXED_INTF(0x1199, 0x9056, 8)}, /* Sierra Wireless Modem */ |
| 1193 | 1193 | {QMI_FIXED_INTF(0x1199, 0x9057, 8)}, |
| 1194 | 1194 | {QMI_FIXED_INTF(0x1199, 0x9061, 8)}, /* Sierra Wireless Modem */ |
| 1195 | + {QMI_FIXED_INTF(0x1199, 0x9063, 8)}, /* Sierra Wireless EM7305 */ | |
| 1196 | + {QMI_FIXED_INTF(0x1199, 0x9063, 10)}, /* Sierra Wireless EM7305 */ | |
| 1195 | 1197 | {QMI_FIXED_INTF(0x1199, 0x9071, 8)}, /* Sierra Wireless MC74xx */ |
| 1196 | 1198 | {QMI_FIXED_INTF(0x1199, 0x9071, 10)}, /* Sierra Wireless MC74xx */ |
| 1197 | 1199 | {QMI_FIXED_INTF(0x1199, 0x9079, 8)}, /* Sierra Wireless EM74xx */ |
| @@ -1206,6 +1208,8 @@ static const struct usb_device_id products[] = { · 8 unmodified lines | ||
| 1206 | 1208 | {QMI_FIXED_INTF(0x1bc7, 0x1100, 3)}, /* Telit ME910 */ |
| 1207 | 1209 | {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */ |
| 1208 | 1210 | {QMI_QUIRK_SET_DTR(0x1bc7, 0x1201, 2)}, /* Telit LE920, LE920A4 */ |
| 1211 | + {QMI_FIXED_INTF(0x1c9e, 0x9801, 3)}, /* Telewell TW-3G HSPA+ */ | |
| 1212 | + {QMI_FIXED_INTF(0x1c9e, 0x9803, 4)}, /* Telewell TW-3G HSPA+ */ | |
| 1209 | 1213 | {QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)}, /* XS Stick W100-2 from 4G Systems */ |
| 1210 | 1214 | {QMI_FIXED_INTF(0x0b3c, 0xc000, 4)}, /* Olivetti Olicard 100 */ |
| 1211 | 1215 | {QMI_FIXED_INTF(0x0b3c, 0xc001, 4)}, /* Olivetti Olicard 120 */ |
| @@ -4368,6 +4368,8 @@ static u8 rtl_get_version(struct usb_interface *intf) · 4367 unmodified lines | ||
| 4368 | 4368 | break; |
| 4369 | 4369 | } |
| 4370 | 4370 | |
| 4371 | + dev_dbg(&intf->dev, "Detected version 0x%04x\n", version); | |
| 4372 | + | |
| 4371 | 4373 | return version; |
| 4372 | 4374 | } |
| 4373 | 4375 | |
| @@ -222,7 +222,6 @@ static int veth_dev_init(struct net_device *dev) · 221 unmodified lines | ||
| 222 | 222 | static void veth_dev_free(struct net_device *dev) |
| 223 | 223 | { |
| 224 | 224 | free_percpu(dev->vstats); |
| 225 | − free_netdev(dev); | |
| 226 | 225 | } |
| 227 | 226 | |
| 228 | 227 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| @@ -317,7 +316,8 @@ static void veth_setup(struct net_device *dev) · 88 unmodified lines | ||
| 317 | 316 | NETIF_F_HW_VLAN_STAG_TX | |
| 318 | 317 | NETIF_F_HW_VLAN_CTAG_RX | |
| 319 | 318 | NETIF_F_HW_VLAN_STAG_RX); |
| 320 | − dev->destructor = veth_dev_free; | |
| 319 | + dev->needs_free_netdev = true; | |
| 320 | + dev->priv_destructor = veth_dev_free; | |
| 321 | 321 | dev->max_mtu = ETH_MAX_MTU; |
| 322 | 322 | |
| 323 | 323 | dev->hw_features = VETH_FEATURES; |
| @@ -36,12 +36,14 @@ · 35 unmodified lines | ||
| 36 | 36 | #include <net/addrconf.h> |
| 37 | 37 | #include <net/l3mdev.h> |
| 38 | 38 | #include <net/fib_rules.h> |
| 39 | +#include <net/netns/generic.h> | |
| 39 | 40 | |
| 40 | 41 | #define DRV_NAME "vrf" |
| 41 | 42 | #define DRV_VERSION "1.0" |
| 42 | 43 | |
| 43 | 44 | #define FIB_RULE_PREF 1000 /* default preference for FIB rules */ |
| 44 | −static bool add_fib_rules = true; | |
| 45 | + | |
| 46 | +static unsigned int vrf_net_id; | |
| 45 | 47 | |
| 46 | 48 | struct net_vrf { |
| 47 | 49 | struct rtable __rcu *rth; |
| @@ -1348,7 +1350,7 @@ static void vrf_setup(struct net_device *dev) · 1300 unmodified lines | ||
| 1348 | 1350 | dev->netdev_ops = &vrf_netdev_ops; |
| 1349 | 1351 | dev->l3mdev_ops = &vrf_l3mdev_ops; |
| 1350 | 1352 | dev->ethtool_ops = &vrf_ethtool_ops; |
| 1351 | − dev->destructor = free_netdev; | |
| 1353 | + dev->needs_free_netdev = true; | |
| 1352 | 1354 | |
| 1353 | 1355 | /* Fill in device structure with ethernet-generic values. */ |
| 1354 | 1356 | eth_hw_addr_random(dev); |
| @@ -1394,6 +1396,8 @@ static int vrf_newlink(struct net *src_net, struct net_device *dev, · 39 unmodified lines | ||
| 1394 | 1396 | struct nlattr *tb[], struct nlattr *data[]) |
| 1395 | 1397 | { |
| 1396 | 1398 | struct net_vrf *vrf = netdev_priv(dev); |
| 1399 | + bool *add_fib_rules; | |
| 1400 | + struct net *net; | |
| 1397 | 1401 | int err; |
| 1398 | 1402 | |
| 1399 | 1403 | if (!data || !data[IFLA_VRF_TABLE]) |
| @@ -1409,13 +1413,15 @@ static int vrf_newlink(struct net *src_net, struct net_device *dev, · 9 unmodified lines | ||
| 1409 | 1413 | if (err) |
| 1410 | 1414 | goto out; |
| 1411 | 1415 | |
| 1412 | − if (add_fib_rules) { | |
| 1416 | + net = dev_net(dev); | |
| 1417 | + add_fib_rules = net_generic(net, vrf_net_id); | |
| 1418 | + if (*add_fib_rules) { | |
| 1413 | 1419 | err = vrf_add_fib_rules(dev); |
| 1414 | 1420 | if (err) { |
| 1415 | 1421 | unregister_netdevice(dev); |
| 1416 | 1422 | goto out; |
| 1417 | 1423 | } |
| 1418 | − add_fib_rules = false; | |
| 1424 | + *add_fib_rules = false; | |
| 1419 | 1425 | } |
| 1420 | 1426 | |
| 1421 | 1427 | out: |
| @@ -1498,16 +1504,38 @@ static struct notifier_block vrf_notifier_block __read_mostly = { · 76 unmodified lines | ||
| 1498 | 1504 | .notifier_call = vrf_device_event, |
| 1499 | 1505 | }; |
| 1500 | 1506 | |
| 1507 | +/* Initialize per network namespace state */ | |
| 1508 | +static int __net_init vrf_netns_init(struct net *net) | |
| 1509 | +{ | |
| 1510 | + bool *add_fib_rules = net_generic(net, vrf_net_id); | |
| 1511 | + | |
| 1512 | + *add_fib_rules = true; | |
| 1513 | + | |
| 1514 | + return 0; | |
| 1515 | +} | |
| 1516 | + | |
| 1517 | +static struct pernet_operations vrf_net_ops __net_initdata = { | |
| 1518 | + .init = vrf_netns_init, | |
| 1519 | + .id = &vrf_net_id, | |
| 1520 | + .size = sizeof(bool), | |
| 1521 | +}; | |
| 1522 | + | |
| 1501 | 1523 | static int __init vrf_init_module(void) |
| 1502 | 1524 | { |
| 1503 | 1525 | int rc; |
| 1504 | 1526 | |
| 1505 | 1527 | register_netdevice_notifier(&vrf_notifier_block); |
| 1506 | 1528 | |
| 1507 | − rc = rtnl_link_register(&vrf_link_ops); | |
| 1529 | + rc = register_pernet_subsys(&vrf_net_ops); | |
| 1508 | 1530 | if (rc < 0) |
| 1509 | 1531 | goto error; |
| 1510 | 1532 | |
| 1533 | + rc = rtnl_link_register(&vrf_link_ops); | |
| 1534 | + if (rc < 0) { | |
| 1535 | + unregister_pernet_subsys(&vrf_net_ops); | |
| 1536 | + goto error; | |
| 1537 | + } | |
| 1538 | + | |
| 1511 | 1539 | return 0; |
| 1512 | 1540 | |
| 1513 | 1541 | error: |
| @@ -135,7 +135,7 @@ static void vsockmon_setup(struct net_device *dev) · 134 unmodified lines | ||
| 135 | 135 | |
| 136 | 136 | dev->netdev_ops = &vsockmon_ops; |
| 137 | 137 | dev->ethtool_ops = &vsockmon_ethtool_ops; |
| 138 | − dev->destructor = free_netdev; | |
| 138 | + dev->needs_free_netdev = true; | |
| 139 | 139 | |
| 140 | 140 | dev->features = NETIF_F_SG | NETIF_F_FRAGLIST | |
| 141 | 141 | NETIF_F_HIGHDMA | NETIF_F_LLTX; |
| @@ -2611,7 +2611,7 @@ static void vxlan_setup(struct net_device *dev) · 2610 unmodified lines | ||
| 2611 | 2611 | eth_hw_addr_random(dev); |
| 2612 | 2612 | ether_setup(dev); |
| 2613 | 2613 | |
| 2614 | − dev->destructor = free_netdev; | |
| 2614 | + dev->needs_free_netdev = true; | |
| 2615 | 2615 | SET_NETDEV_DEVTYPE(dev, &vxlan_type); |
| 2616 | 2616 | |
| 2617 | 2617 | dev->features |= NETIF_F_LLTX; |
| @@ -475,7 +475,7 @@ static void dlci_setup(struct net_device *dev) · 474 unmodified lines | ||
| 475 | 475 | dev->flags = 0; |
| 476 | 476 | dev->header_ops = &dlci_header_ops; |
| 477 | 477 | dev->netdev_ops = &dlci_netdev_ops; |
| 478 | − dev->destructor = free_netdev; | |
| 478 | + dev->needs_free_netdev = true; | |
| 479 | 479 | |
| 480 | 480 | dlp->receive = dlci_receive; |
| 481 | 481 | |
| @@ -1106,7 +1106,7 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type) · 1105 unmodified lines | ||
| 1106 | 1106 | return -EIO; |
| 1107 | 1107 | } |
| 1108 | 1108 | |
| 1109 | − dev->destructor = free_netdev; | |
| 1109 | + dev->needs_free_netdev = true; | |
| 1110 | 1110 | *get_dev_p(pvc, type) = dev; |
| 1111 | 1111 | if (!used) { |
| 1112 | 1112 | state(hdlc)->dce_changed = 1; |
| @@ -306,7 +306,7 @@ static const struct net_device_ops lapbeth_netdev_ops = { · 305 unmodified lines | ||
| 306 | 306 | static void lapbeth_setup(struct net_device *dev) |
| 307 | 307 | { |
| 308 | 308 | dev->netdev_ops = &lapbeth_netdev_ops; |
| 309 | − dev->destructor = free_netdev; | |
| 309 | + dev->needs_free_netdev = true; | |
| 310 | 310 | dev->type = ARPHRD_X25; |
| 311 | 311 | dev->hard_header_len = 3; |
| 312 | 312 | dev->mtu = 1000; |
| @@ -1287,7 +1287,7 @@ void init_netdev(struct net_device *dev) · 1286 unmodified lines | ||
| 1287 | 1287 | struct ath6kl *ar = ath6kl_priv(dev); |
| 1288 | 1288 | |
| 1289 | 1289 | dev->netdev_ops = &ath6kl_netdev_ops; |
| 1290 | − dev->destructor = free_netdev; | |
| 1290 | + dev->needs_free_netdev = true; | |
| 1291 | 1291 | dev->watchdog_timeo = ATH6KL_TX_TIMEOUT; |
| 1292 | 1292 | |
| 1293 | 1293 | dev->needed_headroom = ETH_HLEN; |
| @@ -5225,7 +5225,6 @@ void brcmf_cfg80211_free_netdev(struct net_device *ndev) · 5224 unmodified lines | ||
| 5225 | 5225 | |
| 5226 | 5226 | if (vif) |
| 5227 | 5227 | brcmf_free_vif(vif); |
| 5228 | − free_netdev(ndev); | |
| 5229 | 5228 | } |
| 5230 | 5229 | |
| 5231 | 5230 | static bool brcmf_is_linkup(const struct brcmf_event_msg *e) |
| @@ -624,7 +624,8 @@ struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bsscfgidx, s32 ifidx, · 623 unmodified lines | ||
| 624 | 624 | if (!ndev) |
| 625 | 625 | return ERR_PTR(-ENOMEM); |
| 626 | 626 | |
| 627 | − ndev->destructor = brcmf_cfg80211_free_netdev; | |
| 627 | + ndev->needs_free_netdev = true; | |
| 628 | + ndev->priv_destructor = brcmf_cfg80211_free_netdev; | |
| 628 | 629 | ifp = netdev_priv(ndev); |
| 629 | 630 | ifp->ndev = ndev; |
| 630 | 631 | /* store mapping ifidx to bsscfgidx */ |
| @@ -73,7 +73,7 @@ struct net_device * hostap_add_interface(struct local_info *local, · 72 unmodified lines | ||
| 73 | 73 | dev->mem_end = mdev->mem_end; |
| 74 | 74 | |
| 75 | 75 | hostap_setup_dev(dev, local, type); |
| 76 | − dev->destructor = free_netdev; | |
| 76 | + dev->needs_free_netdev = true; | |
| 77 | 77 | |
| 78 | 78 | sprintf(dev->name, "%s%s", prefix, name); |
| 79 | 79 | if (!rtnl_locked) |
| @@ -2861,7 +2861,7 @@ static const struct net_device_ops hwsim_netdev_ops = { · 2860 unmodified lines | ||
| 2861 | 2861 | static void hwsim_mon_setup(struct net_device *dev) |
| 2862 | 2862 | { |
| 2863 | 2863 | dev->netdev_ops = &hwsim_netdev_ops; |
| 2864 | − dev->destructor = free_netdev; | |
| 2864 | + dev->needs_free_netdev = true; | |
| 2865 | 2865 | ether_setup(dev); |
| 2866 | 2866 | dev->priv_flags |= IFF_NO_QUEUE; |
| 2867 | 2867 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| @@ -1280,7 +1280,7 @@ void mwifiex_init_priv_params(struct mwifiex_private *priv, · 1279 unmodified lines | ||
| 1280 | 1280 | struct net_device *dev) |
| 1281 | 1281 | { |
| 1282 | 1282 | dev->netdev_ops = &mwifiex_netdev_ops; |
| 1283 | − dev->destructor = free_netdev; | |
| 1283 | + dev->needs_free_netdev = true; | |
| 1284 | 1284 | /* Initialize private structure */ |
| 1285 | 1285 | priv->current_key_index = 0; |
| 1286 | 1286 | priv->media_connected = false; |
| @@ -1954,7 +1954,6 @@ static void netiucv_free_netdevice(struct net_device *dev) · 1953 unmodified lines | ||
| 1954 | 1954 | privptr->conn = NULL; privptr->fsm = NULL; |
| 1955 | 1955 | /* privptr gets freed by free_netdev() */ |
| 1956 | 1956 | } |
| 1957 | − free_netdev(dev); | |
| 1958 | 1957 | } |
| 1959 | 1958 | |
| 1960 | 1959 | /** |
| @@ -1972,7 +1971,8 @@ static void netiucv_setup_netdevice(struct net_device *dev) · 11 unmodified lines | ||
| 1972 | 1971 | dev->mtu = NETIUCV_MTU_DEFAULT; |
| 1973 | 1972 | dev->min_mtu = 576; |
| 1974 | 1973 | dev->max_mtu = NETIUCV_MTU_MAX; |
| 1975 | − dev->destructor = netiucv_free_netdevice; | |
| 1974 | + dev->needs_free_netdev = true; | |
| 1975 | + dev->priv_destructor = netiucv_free_netdevice; | |
| 1976 | 1976 | dev->hard_header_len = NETIUCV_HDRLEN; |
| 1977 | 1977 | dev->addr_len = 0; |
| 1978 | 1978 | dev->type = ARPHRD_SLIP; |
| @@ -152,7 +152,7 @@ static const struct net_device_ops mon_netdev_ops = { · 151 unmodified lines | ||
| 152 | 152 | static void mon_setup(struct net_device *dev) |
| 153 | 153 | { |
| 154 | 154 | dev->netdev_ops = &mon_netdev_ops; |
| 155 | − dev->destructor = free_netdev; | |
| 155 | + dev->needs_free_netdev = true; | |
| 156 | 156 | ether_setup(dev); |
| 157 | 157 | dev->priv_flags |= IFF_NO_QUEUE; |
| 158 | 158 | dev->type = ARPHRD_IEEE80211; |
| @@ -2667,7 +2667,8 @@ static int rtw_cfg80211_add_monitor_if (struct adapter *padapter, char *name, st · 2666 unmodified lines | ||
| 2667 | 2667 | mon_ndev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 2668 | 2668 | strncpy(mon_ndev->name, name, IFNAMSIZ); |
| 2669 | 2669 | mon_ndev->name[IFNAMSIZ - 1] = 0; |
| 2670 | − mon_ndev->destructor = rtw_ndev_destructor; | |
| 2670 | + mon_ndev->needs_free_netdev = true; | |
| 2671 | + mon_ndev->priv_destructor = rtw_ndev_destructor; | |
| 2671 | 2672 | |
| 2672 | 2673 | mon_ndev->netdev_ops = &rtw_cfg80211_monitor_if_ops; |
| 2673 | 2674 | |
| @@ -1207,8 +1207,6 @@ void rtw_ndev_destructor(struct net_device *ndev) · 1206 unmodified lines | ||
| 1207 | 1207 | |
| 1208 | 1208 | if (ndev->ieee80211_ptr) |
| 1209 | 1209 | kfree((u8 *)ndev->ieee80211_ptr); |
| 1210 | − | |
| 1211 | − free_netdev(ndev); | |
| 1212 | 1210 | } |
| 1213 | 1211 | |
| 1214 | 1212 | void rtw_dev_unload(struct adapter *padapter) |
| @@ -281,7 +281,7 @@ static void pn_net_setup(struct net_device *dev) · 280 unmodified lines | ||
| 281 | 281 | dev->tx_queue_len = 1; |
| 282 | 282 | |
| 283 | 283 | dev->netdev_ops = &pn_netdev_ops; |
| 284 | − dev->destructor = free_netdev; | |
| 284 | + dev->needs_free_netdev = true; | |
| 285 | 285 | dev->header_ops = &phonet_header_ops; |
| 286 | 286 | } |
| 287 | 287 | |
| @@ -914,8 +914,7 @@ struct xfrmdev_ops { · 913 unmodified lines | ||
| 914 | 914 | * |
| 915 | 915 | * int (*ndo_change_mtu)(struct net_device *dev, int new_mtu); |
| 916 | 916 | * Called when a user wants to change the Maximum Transfer Unit |
| 917 | − * of a device. If not defined, any request to change MTU will | |
| 918 | − * will return an error. | |
| 917 | + * of a device. | |
| 919 | 918 | * |
| 920 | 919 | * void (*ndo_tx_timeout)(struct net_device *dev); |
| 921 | 920 | * Callback used when the transmitter has not made any progress |
| @@ -1596,8 +1595,8 @@ enum netdev_priv_flags { · 674 unmodified lines | ||
| 1596 | 1595 | * @rtnl_link_state: This enum represents the phases of creating |
| 1597 | 1596 | * a new link |
| 1598 | 1597 | * |
| 1599 | − * @destructor: Called from unregister, | |
| 1600 | − * can be used to call free_netdev | |
| 1598 | + * @needs_free_netdev: Should unregister perform free_netdev? | |
| 1599 | + * @priv_destructor: Called from unregister | |
| 1601 | 1600 | * @npinfo: XXX: need comments on this one |
| 1602 | 1601 | * @nd_net: Network namespace this network device is inside |
| 1603 | 1602 | * |
| @@ -1858,7 +1857,8 @@ struct net_device { · 254 unmodified lines | ||
| 1858 | 1857 | RTNL_LINK_INITIALIZING, |
| 1859 | 1858 | } rtnl_link_state:16; |
| 1860 | 1859 | |
| 1861 | − void (*destructor)(struct net_device *dev); | |
| 1860 | + bool needs_free_netdev; | |
| 1861 | + void (*priv_destructor)(struct net_device *dev); | |
| 1862 | 1862 | |
| 1863 | 1863 | #ifdef CONFIG_NETPOLL |
| 1864 | 1864 | struct netpoll_info __rcu *npinfo; |
| @@ -4261,6 +4261,11 @@ static inline const char *netdev_name(const struct net_device *dev) · 2396 unmodified lines | ||
| 4261 | 4261 | return dev->name; |
| 4262 | 4262 | } |
| 4263 | 4263 | |
| 4264 | +static inline bool netdev_unregistering(const struct net_device *dev) | |
| 4265 | +{ | |
| 4266 | + return dev->reg_state == NETREG_UNREGISTERING; | |
| 4267 | +} | |
| 4268 | + | |
| 4264 | 4269 | static inline const char *netdev_reg_state(const struct net_device *dev) |
| 4265 | 4270 | { |
| 4266 | 4271 | switch (dev->reg_state) { |
| @@ -1486,8 +1486,10 @@ enum ethtool_link_mode_bit_indices { · 1485 unmodified lines | ||
| 1486 | 1486 | * it was forced up into this mode or autonegotiated. |
| 1487 | 1487 | */ |
| 1488 | 1488 | |
| 1489 | −/* The forced speed, in units of 1Mb. All values 0 to INT_MAX are legal. */ | |
| 1490 | −/* Update drivers/net/phy/phy.c:phy_speed_to_str() when adding new values */ | |
| 1489 | +/* The forced speed, in units of 1Mb. All values 0 to INT_MAX are legal. | |
| 1490 | + * Update drivers/net/phy/phy.c:phy_speed_to_str() and | |
| 1491 | + * drivers/net/bonding/bond_3ad.c:__get_link_speed() when adding new values. | |
| 1492 | + */ | |
| 1491 | 1493 | #define SPEED_10 10 |
| 1492 | 1494 | #define SPEED_100 100 |
| 1493 | 1495 | #define SPEED_1000 1000 |
| @@ -343,6 +343,7 @@ enum ovs_key_attr { · 342 unmodified lines | ||
| 343 | 343 | #define OVS_KEY_ATTR_MAX (__OVS_KEY_ATTR_MAX - 1) |
| 344 | 344 | |
| 345 | 345 | enum ovs_tunnel_key_attr { |
| 346 | + /* OVS_TUNNEL_KEY_ATTR_NONE, standard nl API requires this attribute! */ | |
| 346 | 347 | OVS_TUNNEL_KEY_ATTR_ID, /* be64 Tunnel ID */ |
| 347 | 348 | OVS_TUNNEL_KEY_ATTR_IPV4_SRC, /* be32 src IP address. */ |
| 348 | 349 | OVS_TUNNEL_KEY_ATTR_IPV4_DST, /* be32 dst IP address. */ |
| @@ -813,7 +813,6 @@ static void vlan_dev_free(struct net_device *dev) · 812 unmodified lines | ||
| 813 | 813 | |
| 814 | 814 | free_percpu(vlan->vlan_pcpu_stats); |
| 815 | 815 | vlan->vlan_pcpu_stats = NULL; |
| 816 | − free_netdev(dev); | |
| 817 | 816 | } |
| 818 | 817 | |
| 819 | 818 | void vlan_setup(struct net_device *dev) |
| @@ -826,7 +825,8 @@ void vlan_setup(struct net_device *dev) · 6 unmodified lines | ||
| 826 | 825 | netif_keep_dst(dev); |
| 827 | 826 | |
| 828 | 827 | dev->netdev_ops = &vlan_netdev_ops; |
| 829 | − dev->destructor = vlan_dev_free; | |
| 828 | + dev->needs_free_netdev = true; | |
| 829 | + dev->priv_destructor = vlan_dev_free; | |
| 830 | 830 | dev->ethtool_ops = &vlan_ethtool_ops; |
| 831 | 831 | |
| 832 | 832 | dev->min_mtu = 0; |
| @@ -1064,8 +1064,9 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv, · 1063 unmodified lines | ||
| 1064 | 1064 | |
| 1065 | 1065 | skb_new->protocol = eth_type_trans(skb_new, soft_iface); |
| 1066 | 1066 | |
| 1067 | − soft_iface->stats.rx_packets++; | |
| 1068 | − soft_iface->stats.rx_bytes += skb->len + ETH_HLEN + hdr_size; | |
| 1067 | + batadv_inc_counter(bat_priv, BATADV_CNT_RX); | |
| 1068 | + batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES, | |
| 1069 | + skb->len + ETH_HLEN + hdr_size); | |
| 1069 | 1070 | |
| 1070 | 1071 | netif_rx(skb_new); |
| 1071 | 1072 | batadv_dbg(BATADV_DBG_DAT, bat_priv, "ARP request replied locally\n"); |
| @@ -987,7 +987,7 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, · 986 unmodified lines | ||
| 987 | 987 | batadv_dbg(BATADV_DBG_BLA, bat_priv, |
| 988 | 988 | "recv_unicast_packet(): Dropped unicast pkt received from another backbone gw %pM.\n", |
| 989 | 989 | orig_addr_gw); |
| 990 | − return NET_RX_DROP; | |
| 990 | + goto free_skb; | |
| 991 | 991 | } |
| 992 | 992 | } |
| 993 | 993 | |
| @@ -1034,8 +1034,6 @@ static void batadv_softif_free(struct net_device *dev) · 1033 unmodified lines | ||
| 1034 | 1034 | * netdev and its private data (bat_priv) |
| 1035 | 1035 | */ |
| 1036 | 1036 | rcu_barrier(); |
| 1037 | − | |
| 1038 | − free_netdev(dev); | |
| 1039 | 1037 | } |
| 1040 | 1038 | |
| 1041 | 1039 | /** |
| @@ -1047,7 +1045,8 @@ static void batadv_softif_init_early(struct net_device *dev) · 5 unmodified lines | ||
| 1047 | 1045 | ether_setup(dev); |
| 1048 | 1046 | |
| 1049 | 1047 | dev->netdev_ops = &batadv_netdev_ops; |
| 1050 | − dev->destructor = batadv_softif_free; | |
| 1048 | + dev->needs_free_netdev = true; | |
| 1049 | + dev->priv_destructor = batadv_softif_free; | |
| 1051 | 1050 | dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_NETNS_LOCAL; |
| 1052 | 1051 | dev->priv_flags |= IFF_NO_QUEUE; |
| 1053 | 1052 | |
| @@ -598,7 +598,7 @@ static void netdev_setup(struct net_device *dev) · 597 unmodified lines | ||
| 598 | 598 | |
| 599 | 599 | dev->netdev_ops = &netdev_ops; |
| 600 | 600 | dev->header_ops = &header_ops; |
| 601 | − dev->destructor = free_netdev; | |
| 601 | + dev->needs_free_netdev = true; | |
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | static struct device_type bt_type = { |
| @@ -379,7 +379,7 @@ void br_dev_setup(struct net_device *dev) · 378 unmodified lines | ||
| 379 | 379 | ether_setup(dev); |
| 380 | 380 | |
| 381 | 381 | dev->netdev_ops = &br_netdev_ops; |
| 382 | − dev->destructor = free_netdev; | |
| 382 | + dev->needs_free_netdev = true; | |
| 383 | 383 | dev->ethtool_ops = &br_ethtool_ops; |
| 384 | 384 | SET_NETDEV_DEVTYPE(dev, &br_type); |
| 385 | 385 | dev->priv_flags = IFF_EBRIDGE | IFF_NO_QUEUE; |
| @@ -754,6 +754,10 @@ static int caif_connect(struct socket *sock, struct sockaddr *uaddr, · 753 unmodified lines | ||
| 754 | 754 | |
| 755 | 755 | lock_sock(sk); |
| 756 | 756 | |
| 757 | + err = -EINVAL; | |
| 758 | + if (addr_len < offsetofend(struct sockaddr, sa_family)) | |
| 759 | + goto out; | |
| 760 | + | |
| 757 | 761 | err = -EAFNOSUPPORT; |
| 758 | 762 | if (uaddr->sa_family != AF_CAIF) |
| 759 | 763 | goto out; |
| @@ -81,11 +81,7 @@ static struct cfpkt *cfpkt_create_pfx(u16 len, u16 pfx) · 80 unmodified lines | ||
| 81 | 81 | { |
| 82 | 82 | struct sk_buff *skb; |
| 83 | 83 | |
| 84 | − if (likely(in_interrupt())) | |
| 85 | − skb = alloc_skb(len + pfx, GFP_ATOMIC); | |
| 86 | − else | |
| 87 | − skb = alloc_skb(len + pfx, GFP_KERNEL); | |
| 88 | − | |
| 84 | + skb = alloc_skb(len + pfx, GFP_ATOMIC); | |
| 89 | 85 | if (unlikely(skb == NULL)) |
| 90 | 86 | return NULL; |
| 91 | 87 | |
| @@ -392,14 +392,14 @@ static void chnl_net_destructor(struct net_device *dev) · 391 unmodified lines | ||
| 392 | 392 | { |
| 393 | 393 | struct chnl_net *priv = netdev_priv(dev); |
| 394 | 394 | caif_free_client(&priv->chnl); |
| 395 | − free_netdev(dev); | |
| 396 | 395 | } |
| 397 | 396 | |
| 398 | 397 | static void ipcaif_net_setup(struct net_device *dev) |
| 399 | 398 | { |
| 400 | 399 | struct chnl_net *priv; |
| 401 | 400 | dev->netdev_ops = &netdev_ops; |
| 402 | − dev->destructor = chnl_net_destructor; | |
| 401 | + dev->needs_free_netdev = true; | |
| 402 | + dev->priv_destructor = chnl_net_destructor; | |
| 403 | 403 | dev->flags |= IFF_NOARP; |
| 404 | 404 | dev->flags |= IFF_POINTOPOINT; |
| 405 | 405 | dev->mtu = GPRS_PDP_MTU; |
| @@ -872,8 +872,7 @@ static int can_notifier(struct notifier_block *nb, unsigned long msg, · 871 unmodified lines | ||
| 872 | 872 | |
| 873 | 873 | static int can_pernet_init(struct net *net) |
| 874 | 874 | { |
| 875 | − net->can.can_rcvlists_lock = | |
| 876 | − __SPIN_LOCK_UNLOCKED(net->can.can_rcvlists_lock); | |
| 875 | + spin_lock_init(&net->can.can_rcvlists_lock); | |
| 877 | 876 | net->can.can_rx_alldev_list = |
| 878 | 877 | kzalloc(sizeof(struct dev_rcv_lists), GFP_KERNEL); |
| 879 | 878 | |
| @@ -1253,8 +1253,9 @@ int dev_set_alias(struct net_device *dev, const char *alias, size_t len) · 1252 unmodified lines | ||
| 1253 | 1253 | if (!new_ifalias) |
| 1254 | 1254 | return -ENOMEM; |
| 1255 | 1255 | dev->ifalias = new_ifalias; |
| 1256 | + memcpy(dev->ifalias, alias, len); | |
| 1257 | + dev->ifalias[len] = 0; | |
| 1256 | 1258 | |
| 1257 | − strlcpy(dev->ifalias, alias, len+1); | |
| 1258 | 1259 | return len; |
| 1259 | 1260 | } |
| 1260 | 1261 | |
| @@ -4948,6 +4949,19 @@ __sum16 __skb_gro_checksum_complete(struct sk_buff *skb) · 3687 unmodified lines | ||
| 4948 | 4949 | } |
| 4949 | 4950 | EXPORT_SYMBOL(__skb_gro_checksum_complete); |
| 4950 | 4951 | |
| 4952 | +static void net_rps_send_ipi(struct softnet_data *remsd) | |
| 4953 | +{ | |
| 4954 | +#ifdef CONFIG_RPS | |
| 4955 | + while (remsd) { | |
| 4956 | + struct softnet_data *next = remsd->rps_ipi_next; | |
| 4957 | + | |
| 4958 | + if (cpu_online(remsd->cpu)) | |
| 4959 | + smp_call_function_single_async(remsd->cpu, &remsd->csd); | |
| 4960 | + remsd = next; | |
| 4961 | + } | |
| 4962 | +#endif | |
| 4963 | +} | |
| 4964 | + | |
| 4951 | 4965 | /* |
| 4952 | 4966 | * net_rps_action_and_irq_enable sends any pending IPI's for rps. |
| 4953 | 4967 | * Note: called with local irq disabled, but exits with local irq enabled. |
| @@ -4963,14 +4977,7 @@ static void net_rps_action_and_irq_enable(struct softnet_data *sd) · 9 unmodified lines | ||
| 4963 | 4977 | local_irq_enable(); |
| 4964 | 4978 | |
| 4965 | 4979 | /* Send pending IPI's to kick RPS processing on remote cpus. */ |
| 4966 | − while (remsd) { | |
| 4967 | − struct softnet_data *next = remsd->rps_ipi_next; | |
| 4968 | − | |
| 4969 | − if (cpu_online(remsd->cpu)) | |
| 4970 | − smp_call_function_single_async(remsd->cpu, | |
| 4971 | − &remsd->csd); | |
| 4972 | − remsd = next; | |
| 4973 | − } | |
| 4980 | + net_rps_send_ipi(remsd); | |
| 4974 | 4981 | } else |
| 4975 | 4982 | #endif |
| 4976 | 4983 | local_irq_enable(); |
| @@ -7501,6 +7508,8 @@ out: · 2524 unmodified lines | ||
| 7501 | 7508 | err_uninit: |
| 7502 | 7509 | if (dev->netdev_ops->ndo_uninit) |
| 7503 | 7510 | dev->netdev_ops->ndo_uninit(dev); |
| 7511 | + if (dev->priv_destructor) | |
| 7512 | + dev->priv_destructor(dev); | |
| 7504 | 7513 | goto out; |
| 7505 | 7514 | } |
| 7506 | 7515 | EXPORT_SYMBOL(register_netdevice); |
| @@ -7708,8 +7717,10 @@ void netdev_run_todo(void) · 201 unmodified lines | ||
| 7708 | 7717 | WARN_ON(rcu_access_pointer(dev->ip6_ptr)); |
| 7709 | 7718 | WARN_ON(dev->dn_ptr); |
| 7710 | 7719 | |
| 7711 | − if (dev->destructor) | |
| 7712 | − dev->destructor(dev); | |
| 7720 | + if (dev->priv_destructor) | |
| 7721 | + dev->priv_destructor(dev); | |
| 7722 | + if (dev->needs_free_netdev) | |
| 7723 | + free_netdev(dev); | |
| 7713 | 7724 | |
| 7714 | 7725 | /* Report a network device has been unregistered */ |
| 7715 | 7726 | rtnl_lock(); |
| @@ -8192,7 +8203,7 @@ static int dev_cpu_dead(unsigned int oldcpu) · 476 unmodified lines | ||
| 8192 | 8203 | struct sk_buff **list_skb; |
| 8193 | 8204 | struct sk_buff *skb; |
| 8194 | 8205 | unsigned int cpu; |
| 8195 | − struct softnet_data *sd, *oldsd; | |
| 8206 | + struct softnet_data *sd, *oldsd, *remsd = NULL; | |
| 8196 | 8207 | |
| 8197 | 8208 | local_irq_disable(); |
| 8198 | 8209 | cpu = smp_processor_id(); |
| @@ -8233,6 +8244,13 @@ static int dev_cpu_dead(unsigned int oldcpu) · 34 unmodified lines | ||
| 8233 | 8244 | raise_softirq_irqoff(NET_TX_SOFTIRQ); |
| 8234 | 8245 | local_irq_enable(); |
| 8235 | 8246 | |
| 8247 | +#ifdef CONFIG_RPS | |
| 8248 | + remsd = oldsd->rps_ipi_list; | |
| 8249 | + oldsd->rps_ipi_list = NULL; | |
| 8250 | +#endif | |
| 8251 | + /* send out pending IPI's on offline CPU */ | |
| 8252 | + net_rps_send_ipi(remsd); | |
| 8253 | + | |
| 8236 | 8254 | /* Process offline CPU's input_pkt_queue */ |
| 8237 | 8255 | while ((skb = __skb_dequeue(&oldsd->process_queue))) { |
| 8238 | 8256 | netif_rx_ni(skb); |
| @@ -469,6 +469,20 @@ static int dst_dev_event(struct notifier_block *this, unsigned long event, · 468 unmodified lines | ||
| 469 | 469 | spin_lock_bh(&dst_garbage.lock); |
| 470 | 470 | dst = dst_garbage.list; |
| 471 | 471 | dst_garbage.list = NULL; |
| 472 | + /* The code in dst_ifdown places a hold on the loopback device. | |
| 473 | + * If the gc entry processing is set to expire after a lengthy | |
| 474 | + * interval, this hold can cause netdev_wait_allrefs() to hang | |
| 475 | + * out and wait for a long time -- until the the loopback | |
| 476 | + * interface is released. If we're really unlucky, it'll emit | |
| 477 | + * pr_emerg messages to console too. Reset the interval here, | |
| 478 | + * so dst cleanups occur in a more timely fashion. | |
| 479 | + */ | |
| 480 | + if (dst_garbage.timer_inc > DST_GC_INC) { | |
| 481 | + dst_garbage.timer_inc = DST_GC_INC; | |
| 482 | + dst_garbage.timer_expires = DST_GC_MIN; | |
| 483 | + mod_delayed_work(system_wq, &dst_gc_work, | |
| 484 | + dst_garbage.timer_expires); | |
| 485 | + } | |
| 472 | 486 | spin_unlock_bh(&dst_garbage.lock); |
| 473 | 487 | |
| 474 | 488 | if (last) |
| @@ -1124,6 +1124,8 @@ static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb, · 1123 unmodified lines | ||
| 1124 | 1124 | struct ifla_vf_mac vf_mac; |
| 1125 | 1125 | struct ifla_vf_info ivi; |
| 1126 | 1126 | |
| 1127 | + memset(&ivi, 0, sizeof(ivi)); | |
| 1128 | + | |
| 1127 | 1129 | /* Not all SR-IOV capable drivers support the |
| 1128 | 1130 | * spoofcheck and "RSS query enable" query. Preset to |
| 1129 | 1131 | * -1 so the user space tool can detect that the driver |
| @@ -1132,7 +1134,6 @@ static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb, · 2 unmodified lines | ||
| 1132 | 1134 | ivi.spoofchk = -1; |
| 1133 | 1135 | ivi.rss_query_en = -1; |
| 1134 | 1136 | ivi.trusted = -1; |
| 1135 | − memset(ivi.mac, 0, sizeof(ivi.mac)); | |
| 1136 | 1137 | /* The default value for VF link state is "auto" |
| 1137 | 1138 | * IFLA_VF_LINK_STATE_AUTO which equals zero |
| 1138 | 1139 | */ |
| @@ -102,7 +102,9 @@ static inline void dnrmg_receive_user_skb(struct sk_buff *skb) · 101 unmodified lines | ||
| 102 | 102 | { |
| 103 | 103 | struct nlmsghdr *nlh = nlmsg_hdr(skb); |
| 104 | 104 | |
| 105 | − if (nlh->nlmsg_len < sizeof(*nlh) || skb->len < nlh->nlmsg_len) | |
| 105 | + if (skb->len < sizeof(*nlh) || | |
| 106 | + nlh->nlmsg_len < sizeof(*nlh) || | |
| 107 | + skb->len < nlh->nlmsg_len) | |
| 106 | 108 | return; |
| 107 | 109 | |
| 108 | 110 | if (!netlink_capable(skb, CAP_NET_ADMIN)) |
| @@ -378,7 +378,6 @@ static void hsr_dev_destroy(struct net_device *hsr_dev) · 377 unmodified lines | ||
| 378 | 378 | del_timer_sync(&hsr->announce_timer); |
| 379 | 379 | |
| 380 | 380 | synchronize_rcu(); |
| 381 | − free_netdev(hsr_dev); | |
| 382 | 381 | } |
| 383 | 382 | |
| 384 | 383 | static const struct net_device_ops hsr_device_ops = { |
| @@ -404,7 +403,8 @@ void hsr_dev_setup(struct net_device *dev) · 19 unmodified lines | ||
| 404 | 403 | SET_NETDEV_DEVTYPE(dev, &hsr_type); |
| 405 | 404 | dev->priv_flags |= IFF_NO_QUEUE; |
| 406 | 405 | |
| 407 | − dev->destructor = hsr_dev_destroy; | |
| 406 | + dev->needs_free_netdev = true; | |
| 407 | + dev->priv_destructor = hsr_dev_destroy; | |
| 408 | 408 | |
| 409 | 409 | dev->hw_features = NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA | |
| 410 | 410 | NETIF_F_GSO_MASK | NETIF_F_HW_CSUM | |
| @@ -324,8 +324,7 @@ static int hsr_fill_frame_info(struct hsr_frame_info *frame, · 323 unmodified lines | ||
| 324 | 324 | unsigned long irqflags; |
| 325 | 325 | |
| 326 | 326 | frame->is_supervision = is_supervision_frame(port->hsr, skb); |
| 327 | − frame->node_src = hsr_get_node(&port->hsr->node_db, skb, | |
| 328 | − frame->is_supervision); | |
| 327 | + frame->node_src = hsr_get_node(port, skb, frame->is_supervision); | |
| 329 | 328 | if (frame->node_src == NULL) |
| 330 | 329 | return -1; /* Unknown node and !is_supervision, or no mem */ |
| 331 | 330 | |
| @@ -158,9 +158,10 @@ struct hsr_node *hsr_add_node(struct list_head *node_db, unsigned char addr[], · 157 unmodified lines | ||
| 158 | 158 | |
| 159 | 159 | /* Get the hsr_node from which 'skb' was sent. |
| 160 | 160 | */ |
| 161 | −struct hsr_node *hsr_get_node(struct list_head *node_db, struct sk_buff *skb, | |
| 161 | +struct hsr_node *hsr_get_node(struct hsr_port *port, struct sk_buff *skb, | |
| 162 | 162 | bool is_sup) |
| 163 | 163 | { |
| 164 | + struct list_head *node_db = &port->hsr->node_db; | |
| 164 | 165 | struct hsr_node *node; |
| 165 | 166 | struct ethhdr *ethhdr; |
| 166 | 167 | u16 seq_out; |
| @@ -186,7 +187,11 @@ struct hsr_node *hsr_get_node(struct list_head *node_db, struct sk_buff *skb, · 19 unmodified lines | ||
| 186 | 187 | */ |
| 187 | 188 | seq_out = hsr_get_skb_sequence_nr(skb) - 1; |
| 188 | 189 | } else { |
| 189 | − WARN_ONCE(1, "%s: Non-HSR frame\n", __func__); | |
| 190 | + /* this is called also for frames from master port and | |
| 191 | + * so warn only for non master ports | |
| 192 | + */ | |
| 193 | + if (port->type != HSR_PT_MASTER) | |
| 194 | + WARN_ONCE(1, "%s: Non-HSR frame\n", __func__); | |
| 190 | 195 | seq_out = HSR_SEQNR_START; |
| 191 | 196 | } |
| 192 | 197 | |
| @@ -18,7 +18,7 @@ struct hsr_node; · 17 unmodified lines | ||
| 18 | 18 | |
| 19 | 19 | struct hsr_node *hsr_add_node(struct list_head *node_db, unsigned char addr[], |
| 20 | 20 | u16 seq_out); |
| 21 | −struct hsr_node *hsr_get_node(struct list_head *node_db, struct sk_buff *skb, | |
| 21 | +struct hsr_node *hsr_get_node(struct hsr_port *port, struct sk_buff *skb, | |
| 22 | 22 | bool is_sup); |
| 23 | 23 | void hsr_handle_sup_frame(struct sk_buff *skb, struct hsr_node *node_curr, |
| 24 | 24 | struct hsr_port *port); |
| @@ -107,7 +107,7 @@ static void lowpan_setup(struct net_device *ldev) · 106 unmodified lines | ||
| 107 | 107 | |
| 108 | 108 | ldev->netdev_ops = &lowpan_netdev_ops; |
| 109 | 109 | ldev->header_ops = &lowpan_header_ops; |
| 110 | − ldev->destructor = free_netdev; | |
| 110 | + ldev->needs_free_netdev = true; | |
| 111 | 111 | ldev->features |= NETIF_F_NETNS_LOCAL; |
| 112 | 112 | } |
| 113 | 113 | |
| @@ -657,8 +657,12 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) · 656 unmodified lines | ||
| 657 | 657 | /* Needed by both icmp_global_allow and icmp_xmit_lock */ |
| 658 | 658 | local_bh_disable(); |
| 659 | 659 | |
| 660 | − /* Check global sysctl_icmp_msgs_per_sec ratelimit */ | |
| 661 | − if (!icmpv4_global_allow(net, type, code)) | |
| 660 | + /* Check global sysctl_icmp_msgs_per_sec ratelimit, unless | |
| 661 | + * incoming dev is loopback. If outgoing dev change to not be | |
| 662 | + * loopback, then peer ratelimit still work (in icmpv4_xrlim_allow) | |
| 663 | + */ | |
| 664 | + if (!(skb_in->dev && (skb_in->dev->flags&IFF_LOOPBACK)) && | |
| 665 | + !icmpv4_global_allow(net, type, code)) | |
| 662 | 666 | goto out_bh_enable; |
| 663 | 667 | |
| 664 | 668 | sk = icmp_xmit_lock(net); |
| @@ -2071,21 +2071,26 @@ static int ip_mc_add_src(struct in_device *in_dev, __be32 *pmca, int sfmode, · 2070 unmodified lines | ||
| 2071 | 2071 | |
| 2072 | 2072 | static void ip_mc_clear_src(struct ip_mc_list *pmc) |
| 2073 | 2073 | { |
| 2074 | − struct ip_sf_list *psf, *nextpsf; | |
| 2074 | + struct ip_sf_list *psf, *nextpsf, *tomb, *sources; | |
| 2075 | 2075 | |
| 2076 | − for (psf = pmc->tomb; psf; psf = nextpsf) { | |
| 2076 | + spin_lock_bh(&pmc->lock); | |
| 2077 | + tomb = pmc->tomb; | |
| 2078 | + pmc->tomb = NULL; | |
| 2079 | + sources = pmc->sources; | |
| 2080 | + pmc->sources = NULL; | |
| 2081 | + pmc->sfmode = MCAST_EXCLUDE; | |
| 2082 | + pmc->sfcount[MCAST_INCLUDE] = 0; | |
| 2083 | + pmc->sfcount[MCAST_EXCLUDE] = 1; | |
| 2084 | + spin_unlock_bh(&pmc->lock); | |
| 2085 | + | |
| 2086 | + for (psf = tomb; psf; psf = nextpsf) { | |
| 2077 | 2087 | nextpsf = psf->sf_next; |
| 2078 | 2088 | kfree(psf); |
| 2079 | 2089 | } |
| 2080 | − pmc->tomb = NULL; | |
| 2081 | − for (psf = pmc->sources; psf; psf = nextpsf) { | |
| 2090 | + for (psf = sources; psf; psf = nextpsf) { | |
| 2082 | 2091 | nextpsf = psf->sf_next; |
| 2083 | 2092 | kfree(psf); |
| 2084 | 2093 | } |
| 2085 | − pmc->sources = NULL; | |
| 2086 | − pmc->sfmode = MCAST_EXCLUDE; | |
| 2087 | − pmc->sfcount[MCAST_INCLUDE] = 0; | |
| 2088 | − pmc->sfcount[MCAST_EXCLUDE] = 1; | |
| 2089 | 2094 | } |
| 2090 | 2095 | |
| 2091 | 2096 | /* Join a multicast group |
| @@ -967,7 +967,6 @@ static void ip_tunnel_dev_free(struct net_device *dev) · 966 unmodified lines | ||
| 967 | 967 | gro_cells_destroy(&tunnel->gro_cells); |
| 968 | 968 | dst_cache_destroy(&tunnel->dst_cache); |
| 969 | 969 | free_percpu(dev->tstats); |
| 970 | − free_netdev(dev); | |
| 971 | 970 | } |
| 972 | 971 | |
| 973 | 972 | void ip_tunnel_dellink(struct net_device *dev, struct list_head *head) |
| @@ -1155,7 +1154,8 @@ int ip_tunnel_init(struct net_device *dev) · 181 unmodified lines | ||
| 1155 | 1154 | struct iphdr *iph = &tunnel->parms.iph; |
| 1156 | 1155 | int err; |
| 1157 | 1156 | |
| 1158 | − dev->destructor = ip_tunnel_dev_free; | |
| 1157 | + dev->needs_free_netdev = true; | |
| 1158 | + dev->priv_destructor = ip_tunnel_dev_free; | |
| 1159 | 1159 | dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); |
| 1160 | 1160 | if (!dev->tstats) |
| 1161 | 1161 | return -ENOMEM; |
| @@ -101,8 +101,8 @@ static struct mr_table *ipmr_new_table(struct net *net, u32 id); · 100 unmodified lines | ||
| 101 | 101 | static void ipmr_free_table(struct mr_table *mrt); |
| 102 | 102 | |
| 103 | 103 | static void ip_mr_forward(struct net *net, struct mr_table *mrt, |
| 104 | − struct sk_buff *skb, struct mfc_cache *cache, | |
| 105 | − int local); | |
| 104 | + struct net_device *dev, struct sk_buff *skb, | |
| 105 | + struct mfc_cache *cache, int local); | |
| 106 | 106 | static int ipmr_cache_report(struct mr_table *mrt, |
| 107 | 107 | struct sk_buff *pkt, vifi_t vifi, int assert); |
| 108 | 108 | static int __ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb, |
| @@ -501,7 +501,7 @@ static void reg_vif_setup(struct net_device *dev) · 392 unmodified lines | ||
| 501 | 501 | dev->mtu = ETH_DATA_LEN - sizeof(struct iphdr) - 8; |
| 502 | 502 | dev->flags = IFF_NOARP; |
| 503 | 503 | dev->netdev_ops = ®_vif_netdev_ops; |
| 504 | − dev->destructor = free_netdev; | |
| 504 | + dev->needs_free_netdev = true; | |
| 505 | 505 | dev->features |= NETIF_F_NETNS_LOCAL; |
| 506 | 506 | } |
| 507 | 507 | |
| @@ -988,7 +988,7 @@ static void ipmr_cache_resolve(struct net *net, struct mr_table *mrt, · 480 unmodified lines | ||
| 988 | 988 | |
| 989 | 989 | rtnl_unicast(skb, net, NETLINK_CB(skb).portid); |
| 990 | 990 | } else { |
| 991 | − ip_mr_forward(net, mrt, skb, c, 0); | |
| 991 | + ip_mr_forward(net, mrt, skb->dev, skb, c, 0); | |
| 992 | 992 | } |
| 993 | 993 | } |
| 994 | 994 | } |
| @@ -1073,7 +1073,7 @@ static int ipmr_cache_report(struct mr_table *mrt, · 78 unmodified lines | ||
| 1073 | 1073 | |
| 1074 | 1074 | /* Queue a packet for resolution. It gets locked cache entry! */ |
| 1075 | 1075 | static int ipmr_cache_unresolved(struct mr_table *mrt, vifi_t vifi, |
| 1076 | − struct sk_buff *skb) | |
| 1076 | + struct sk_buff *skb, struct net_device *dev) | |
| 1077 | 1077 | { |
| 1078 | 1078 | const struct iphdr *iph = ip_hdr(skb); |
| 1079 | 1079 | struct mfc_cache *c; |
| @@ -1130,6 +1130,10 @@ static int ipmr_cache_unresolved(struct mr_table *mrt, vifi_t vifi, · 50 unmodified lines | ||
| 1130 | 1130 | kfree_skb(skb); |
| 1131 | 1131 | err = -ENOBUFS; |
| 1132 | 1132 | } else { |
| 1133 | + if (dev) { | |
| 1134 | + skb->dev = dev; | |
| 1135 | + skb->skb_iif = dev->ifindex; | |
| 1136 | + } | |
| 1133 | 1137 | skb_queue_tail(&c->mfc_un.unres.unresolved, skb); |
| 1134 | 1138 | err = 0; |
| 1135 | 1139 | } |
| @@ -1828,10 +1832,10 @@ static int ipmr_find_vif(struct mr_table *mrt, struct net_device *dev) · 692 unmodified lines | ||
| 1828 | 1832 | |
| 1829 | 1833 | /* "local" means that we should preserve one skb (for local delivery) */ |
| 1830 | 1834 | static void ip_mr_forward(struct net *net, struct mr_table *mrt, |
| 1831 | − struct sk_buff *skb, struct mfc_cache *cache, | |
| 1832 | − int local) | |
| 1835 | + struct net_device *dev, struct sk_buff *skb, | |
| 1836 | + struct mfc_cache *cache, int local) | |
| 1833 | 1837 | { |
| 1834 | − int true_vifi = ipmr_find_vif(mrt, skb->dev); | |
| 1838 | + int true_vifi = ipmr_find_vif(mrt, dev); | |
| 1835 | 1839 | int psend = -1; |
| 1836 | 1840 | int vif, ct; |
| 1837 | 1841 | |
| @@ -1853,13 +1857,7 @@ static void ip_mr_forward(struct net *net, struct mr_table *mrt, · 15 unmodified lines | ||
| 1853 | 1857 | } |
| 1854 | 1858 | |
| 1855 | 1859 | /* Wrong interface: drop packet and (maybe) send PIM assert. */ |
| 1856 | − if (mrt->vif_table[vif].dev != skb->dev) { | |
| 1857 | − struct net_device *mdev; | |
| 1858 | − | |
| 1859 | − mdev = l3mdev_master_dev_rcu(mrt->vif_table[vif].dev); | |
| 1860 | − if (mdev == skb->dev) | |
| 1861 | − goto forward; | |
| 1862 | − | |
| 1860 | + if (mrt->vif_table[vif].dev != dev) { | |
| 1863 | 1861 | if (rt_is_output_route(skb_rtable(skb))) { |
| 1864 | 1862 | /* It is our own packet, looped back. |
| 1865 | 1863 | * Very complicated situation... |
| @@ -2053,7 +2051,7 @@ int ip_mr_input(struct sk_buff *skb) · 187 unmodified lines | ||
| 2053 | 2051 | read_lock(&mrt_lock); |
| 2054 | 2052 | vif = ipmr_find_vif(mrt, dev); |
| 2055 | 2053 | if (vif >= 0) { |
| 2056 | − int err2 = ipmr_cache_unresolved(mrt, vif, skb); | |
| 2054 | + int err2 = ipmr_cache_unresolved(mrt, vif, skb, dev); | |
| 2057 | 2055 | read_unlock(&mrt_lock); |
| 2058 | 2056 | |
| 2059 | 2057 | return err2; |
| @@ -2064,7 +2062,7 @@ int ip_mr_input(struct sk_buff *skb) · 4 unmodified lines | ||
| 2064 | 2062 | } |
| 2065 | 2063 | |
| 2066 | 2064 | read_lock(&mrt_lock); |
| 2067 | − ip_mr_forward(net, mrt, skb, cache, local); | |
| 2065 | + ip_mr_forward(net, mrt, dev, skb, cache, local); | |
| 2068 | 2066 | read_unlock(&mrt_lock); |
| 2069 | 2067 | |
| 2070 | 2068 | if (local) |
| @@ -2238,7 +2236,7 @@ int ipmr_get_route(struct net *net, struct sk_buff *skb, · 167 unmodified lines | ||
| 2238 | 2236 | iph->saddr = saddr; |
| 2239 | 2237 | iph->daddr = daddr; |
| 2240 | 2238 | iph->version = 0; |
| 2241 | − err = ipmr_cache_unresolved(mrt, vif, skb2); | |
| 2239 | + err = ipmr_cache_unresolved(mrt, vif, skb2, dev); | |
| 2242 | 2240 | read_unlock(&mrt_lock); |
| 2243 | 2241 | rcu_read_unlock(); |
| 2244 | 2242 | return err; |
| @@ -491,7 +491,7 @@ static void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, · 490 unmodified lines | ||
| 491 | 491 | local_bh_disable(); |
| 492 | 492 | |
| 493 | 493 | /* Check global sysctl_icmp_msgs_per_sec ratelimit */ |
| 494 | − if (!icmpv6_global_allow(type)) | |
| 494 | + if (!(skb->dev->flags&IFF_LOOPBACK) && !icmpv6_global_allow(type)) | |
| 495 | 495 | goto out_bh_enable; |
| 496 | 496 | |
| 497 | 497 | mip6_addr_swap(skb); |
| @@ -62,6 +62,7 @@ static inline u32 ila_locator_hash(struct ila_locator loc) · 61 unmodified lines | ||
| 62 | 62 | { |
| 63 | 63 | u32 *v = (u32 *)loc.v32; |
| 64 | 64 | |
| 65 | + __ila_hash_secret_init(); | |
| 65 | 66 | return jhash_2words(v[0], v[1], hashrnd); |
| 66 | 67 | } |
| 67 | 68 | |
| @@ -991,13 +991,13 @@ static void ip6gre_dev_free(struct net_device *dev) · 990 unmodified lines | ||
| 991 | 991 | |
| 992 | 992 | dst_cache_destroy(&t->dst_cache); |
| 993 | 993 | free_percpu(dev->tstats); |
| 994 | − free_netdev(dev); | |
| 995 | 994 | } |
| 996 | 995 | |
| 997 | 996 | static void ip6gre_tunnel_setup(struct net_device *dev) |
| 998 | 997 | { |
| 999 | 998 | dev->netdev_ops = &ip6gre_netdev_ops; |
| 1000 | − dev->destructor = ip6gre_dev_free; | |
| 999 | + dev->needs_free_netdev = true; | |
| 1000 | + dev->priv_destructor = ip6gre_dev_free; | |
| 1001 | 1001 | |
| 1002 | 1002 | dev->type = ARPHRD_IP6GRE; |
| 1003 | 1003 | |
| @@ -1148,7 +1148,7 @@ static int __net_init ip6gre_init_net(struct net *net) · 144 unmodified lines | ||
| 1148 | 1148 | return 0; |
| 1149 | 1149 | |
| 1150 | 1150 | err_reg_dev: |
| 1151 | − ip6gre_dev_free(ign->fb_tunnel_dev); | |
| 1151 | + free_netdev(ign->fb_tunnel_dev); | |
| 1152 | 1152 | err_alloc_dev: |
| 1153 | 1153 | return err; |
| 1154 | 1154 | } |
| @@ -1300,7 +1300,8 @@ static void ip6gre_tap_setup(struct net_device *dev) · 145 unmodified lines | ||
| 1300 | 1300 | ether_setup(dev); |
| 1301 | 1301 | |
| 1302 | 1302 | dev->netdev_ops = &ip6gre_tap_netdev_ops; |
| 1303 | − dev->destructor = ip6gre_dev_free; | |
| 1303 | + dev->needs_free_netdev = true; | |
| 1304 | + dev->priv_destructor = ip6gre_dev_free; | |
| 1304 | 1305 | |
| 1305 | 1306 | dev->features |= NETIF_F_NETNS_LOCAL; |
| 1306 | 1307 | dev->priv_flags &= ~IFF_TX_SKB_SHARING; |
| @@ -254,7 +254,6 @@ static void ip6_dev_free(struct net_device *dev) · 253 unmodified lines | ||
| 254 | 254 | gro_cells_destroy(&t->gro_cells); |
| 255 | 255 | dst_cache_destroy(&t->dst_cache); |
| 256 | 256 | free_percpu(dev->tstats); |
| 257 | − free_netdev(dev); | |
| 258 | 257 | } |
| 259 | 258 | |
| 260 | 259 | static int ip6_tnl_create2(struct net_device *dev) |
| @@ -322,7 +321,7 @@ static struct ip6_tnl *ip6_tnl_create(struct net *net, struct __ip6_tnl_parm *p) · 61 unmodified lines | ||
| 322 | 321 | return t; |
| 323 | 322 | |
| 324 | 323 | failed_free: |
| 325 | − ip6_dev_free(dev); | |
| 324 | + free_netdev(dev); | |
| 326 | 325 | failed: |
| 327 | 326 | return ERR_PTR(err); |
| 328 | 327 | } |
| @@ -1777,7 +1776,8 @@ static const struct net_device_ops ip6_tnl_netdev_ops = { · 1448 unmodified lines | ||
| 1777 | 1776 | static void ip6_tnl_dev_setup(struct net_device *dev) |
| 1778 | 1777 | { |
| 1779 | 1778 | dev->netdev_ops = &ip6_tnl_netdev_ops; |
| 1780 | − dev->destructor = ip6_dev_free; | |
| 1779 | + dev->needs_free_netdev = true; | |
| 1780 | + dev->priv_destructor = ip6_dev_free; | |
| 1781 | 1781 | |
| 1782 | 1782 | dev->type = ARPHRD_TUNNEL6; |
| 1783 | 1783 | dev->flags |= IFF_NOARP; |
| @@ -2224,7 +2224,7 @@ static int __net_init ip6_tnl_init_net(struct net *net) · 440 unmodified lines | ||
| 2224 | 2224 | return 0; |
| 2225 | 2225 | |
| 2226 | 2226 | err_register: |
| 2227 | − ip6_dev_free(ip6n->fb_tnl_dev); | |
| 2227 | + free_netdev(ip6n->fb_tnl_dev); | |
| 2228 | 2228 | err_alloc_dev: |
| 2229 | 2229 | return err; |
| 2230 | 2230 | } |
| @@ -180,7 +180,6 @@ vti6_tnl_unlink(struct vti6_net *ip6n, struct ip6_tnl *t) · 179 unmodified lines | ||
| 180 | 180 | static void vti6_dev_free(struct net_device *dev) |
| 181 | 181 | { |
| 182 | 182 | free_percpu(dev->tstats); |
| 183 | − free_netdev(dev); | |
| 184 | 183 | } |
| 185 | 184 | |
| 186 | 185 | static int vti6_tnl_create2(struct net_device *dev) |
| @@ -235,7 +234,7 @@ static struct ip6_tnl *vti6_tnl_create(struct net *net, struct __ip6_tnl_parm *p · 48 unmodified lines | ||
| 235 | 234 | return t; |
| 236 | 235 | |
| 237 | 236 | failed_free: |
| 238 | − vti6_dev_free(dev); | |
| 237 | + free_netdev(dev); | |
| 239 | 238 | failed: |
| 240 | 239 | return NULL; |
| 241 | 240 | } |
| @@ -842,7 +841,8 @@ static const struct net_device_ops vti6_netdev_ops = { · 600 unmodified lines | ||
| 842 | 841 | static void vti6_dev_setup(struct net_device *dev) |
| 843 | 842 | { |
| 844 | 843 | dev->netdev_ops = &vti6_netdev_ops; |
| 845 | − dev->destructor = vti6_dev_free; | |
| 844 | + dev->needs_free_netdev = true; | |
| 845 | + dev->priv_destructor = vti6_dev_free; | |
| 846 | 846 | |
| 847 | 847 | dev->type = ARPHRD_TUNNEL6; |
| 848 | 848 | dev->hard_header_len = LL_MAX_HEADER + sizeof(struct ipv6hdr); |
| @@ -1100,7 +1100,7 @@ static int __net_init vti6_init_net(struct net *net) · 251 unmodified lines | ||
| 1100 | 1100 | return 0; |
| 1101 | 1101 | |
| 1102 | 1102 | err_register: |
| 1103 | − vti6_dev_free(ip6n->fb_tnl_dev); | |
| 1103 | + free_netdev(ip6n->fb_tnl_dev); | |
| 1104 | 1104 | err_alloc_dev: |
| 1105 | 1105 | return err; |
| 1106 | 1106 | } |
| @@ -733,7 +733,7 @@ static void reg_vif_setup(struct net_device *dev) · 732 unmodified lines | ||
| 733 | 733 | dev->mtu = 1500 - sizeof(struct ipv6hdr) - 8; |
| 734 | 734 | dev->flags = IFF_NOARP; |
| 735 | 735 | dev->netdev_ops = ®_vif_netdev_ops; |
| 736 | − dev->destructor = free_netdev; | |
| 736 | + dev->needs_free_netdev = true; | |
| 737 | 737 | dev->features |= NETIF_F_NETNS_LOCAL; |
| 738 | 738 | } |
| 739 | 739 | |
| @@ -219,7 +219,7 @@ static void snmp6_seq_show_item64(struct seq_file *seq, void __percpu *mib, · 218 unmodified lines | ||
| 219 | 219 | u64 buff64[SNMP_MIB_MAX]; |
| 220 | 220 | int i; |
| 221 | 221 | |
| 222 | − memset(buff64, 0, sizeof(unsigned long) * SNMP_MIB_MAX); | |
| 222 | + memset(buff64, 0, sizeof(u64) * SNMP_MIB_MAX); | |
| 223 | 223 | |
| 224 | 224 | snmp_get_cpu_field64_batch(buff64, itemlist, mib, syncpoff); |
| 225 | 225 | for (i = 0; itemlist[i].name; i++) |
| @@ -2804,6 +2804,7 @@ static int fib6_ifdown(struct rt6_info *rt, void *arg) · 2803 unmodified lines | ||
| 2804 | 2804 | if ((rt->dst.dev == dev || !dev) && |
| 2805 | 2805 | rt != adn->net->ipv6.ip6_null_entry && |
| 2806 | 2806 | (rt->rt6i_nsiblings == 0 || |
| 2807 | + (dev && netdev_unregistering(dev)) || | |
| 2807 | 2808 | !rt->rt6i_idev->cnf.ignore_routes_with_linkdown)) |
| 2808 | 2809 | return -1; |
| 2809 | 2810 | |
| @@ -265,7 +265,7 @@ static struct ip_tunnel *ipip6_tunnel_locate(struct net *net, · 264 unmodified lines | ||
| 265 | 265 | return nt; |
| 266 | 266 | |
| 267 | 267 | failed_free: |
| 268 | − ipip6_dev_free(dev); | |
| 268 | + free_netdev(dev); | |
| 269 | 269 | failed: |
| 270 | 270 | return NULL; |
| 271 | 271 | } |
| @@ -1336,7 +1336,6 @@ static void ipip6_dev_free(struct net_device *dev) · 1064 unmodified lines | ||
| 1336 | 1336 | |
| 1337 | 1337 | dst_cache_destroy(&tunnel->dst_cache); |
| 1338 | 1338 | free_percpu(dev->tstats); |
| 1339 | − free_netdev(dev); | |
| 1340 | 1339 | } |
| 1341 | 1340 | |
| 1342 | 1341 | #define SIT_FEATURES (NETIF_F_SG | \ |
| @@ -1351,7 +1350,8 @@ static void ipip6_tunnel_setup(struct net_device *dev) · 8 unmodified lines | ||
| 1351 | 1350 | int t_hlen = tunnel->hlen + sizeof(struct iphdr); |
| 1352 | 1351 | |
| 1353 | 1352 | dev->netdev_ops = &ipip6_netdev_ops; |
| 1354 | − dev->destructor = ipip6_dev_free; | |
| 1353 | + dev->needs_free_netdev = true; | |
| 1354 | + dev->priv_destructor = ipip6_dev_free; | |
| 1355 | 1355 | |
| 1356 | 1356 | dev->type = ARPHRD_SIT; |
| 1357 | 1357 | dev->hard_header_len = LL_MAX_HEADER + t_hlen; |
| @@ -65,7 +65,7 @@ static void irlan_eth_setup(struct net_device *dev) · 64 unmodified lines | ||
| 65 | 65 | ether_setup(dev); |
| 66 | 66 | |
| 67 | 67 | dev->netdev_ops = &irlan_eth_netdev_ops; |
| 68 | − dev->destructor = free_netdev; | |
| 68 | + dev->needs_free_netdev = true; | |
| 69 | 69 | dev->min_mtu = 0; |
| 70 | 70 | dev->max_mtu = ETH_MAX_MTU; |
| 71 | 71 | |
| @@ -114,12 +114,13 @@ static void l2tp_eth_get_stats64(struct net_device *dev, · 113 unmodified lines | ||
| 114 | 114 | { |
| 115 | 115 | struct l2tp_eth *priv = netdev_priv(dev); |
| 116 | 116 | |
| 117 | − stats->tx_bytes = atomic_long_read(&priv->tx_bytes); | |
| 118 | − stats->tx_packets = atomic_long_read(&priv->tx_packets); | |
| 119 | − stats->tx_dropped = atomic_long_read(&priv->tx_dropped); | |
| 120 | − stats->rx_bytes = atomic_long_read(&priv->rx_bytes); | |
| 121 | − stats->rx_packets = atomic_long_read(&priv->rx_packets); | |
| 122 | − stats->rx_errors = atomic_long_read(&priv->rx_errors); | |
| 117 | + stats->tx_bytes = (unsigned long) atomic_long_read(&priv->tx_bytes); | |
| 118 | + stats->tx_packets = (unsigned long) atomic_long_read(&priv->tx_packets); | |
| 119 | + stats->tx_dropped = (unsigned long) atomic_long_read(&priv->tx_dropped); | |
| 120 | + stats->rx_bytes = (unsigned long) atomic_long_read(&priv->rx_bytes); | |
| 121 | + stats->rx_packets = (unsigned long) atomic_long_read(&priv->rx_packets); | |
| 122 | + stats->rx_errors = (unsigned long) atomic_long_read(&priv->rx_errors); | |
| 123 | + | |
| 123 | 124 | } |
| 124 | 125 | |
| 125 | 126 | static const struct net_device_ops l2tp_eth_netdev_ops = { |
| @@ -141,7 +142,7 @@ static void l2tp_eth_dev_setup(struct net_device *dev) · 15 unmodified lines | ||
| 141 | 142 | dev->priv_flags &= ~IFF_TX_SKB_SHARING; |
| 142 | 143 | dev->features |= NETIF_F_LLTX; |
| 143 | 144 | dev->netdev_ops = &l2tp_eth_netdev_ops; |
| 144 | − dev->destructor = free_netdev; | |
| 145 | + dev->needs_free_netdev = true; | |
| 145 | 146 | } |
| 146 | 147 | |
| 147 | 148 | static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb, int data_len) |
| @@ -902,6 +902,8 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev, · 901 unmodified lines | ||
| 902 | 902 | default: |
| 903 | 903 | return -EINVAL; |
| 904 | 904 | } |
| 905 | + sdata->u.ap.req_smps = sdata->smps_mode; | |
| 906 | + | |
| 905 | 907 | sdata->needed_rx_chains = sdata->local->rx_chains; |
| 906 | 908 | |
| 907 | 909 | sdata->vif.bss_conf.beacon_int = params->beacon_interval; |
| @@ -1531,7 +1531,7 @@ ieee80211_have_rx_timestamp(struct ieee80211_rx_status *status) · 1530 unmodified lines | ||
| 1531 | 1531 | return true; |
| 1532 | 1532 | /* can't handle non-legacy preamble yet */ |
| 1533 | 1533 | if (status->flag & RX_FLAG_MACTIME_PLCP_START && |
| 1534 | − status->encoding != RX_ENC_LEGACY) | |
| 1534 | + status->encoding == RX_ENC_LEGACY) | |
| 1535 | 1535 | return true; |
| 1536 | 1536 | return false; |
| 1537 | 1537 | } |
| @@ -1213,7 +1213,6 @@ static const struct net_device_ops ieee80211_monitorif_ops = { · 1212 unmodified lines | ||
| 1213 | 1213 | static void ieee80211_if_free(struct net_device *dev) |
| 1214 | 1214 | { |
| 1215 | 1215 | free_percpu(dev->tstats); |
| 1216 | − free_netdev(dev); | |
| 1217 | 1216 | } |
| 1218 | 1217 | |
| 1219 | 1218 | static void ieee80211_if_setup(struct net_device *dev) |
| @@ -1221,7 +1220,8 @@ static void ieee80211_if_setup(struct net_device *dev) · 1 unmodified line | ||
| 1221 | 1220 | ether_setup(dev); |
| 1222 | 1221 | dev->priv_flags &= ~IFF_TX_SKB_SHARING; |
| 1223 | 1222 | dev->netdev_ops = &ieee80211_dataif_ops; |
| 1224 | − dev->destructor = ieee80211_if_free; | |
| 1223 | + dev->needs_free_netdev = true; | |
| 1224 | + dev->priv_destructor = ieee80211_if_free; | |
| 1225 | 1225 | } |
| 1226 | 1226 | |
| 1227 | 1227 | static void ieee80211_if_setup_no_queue(struct net_device *dev) |
| @@ -1816,6 +1816,7 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name, · 588 unmodified lines | ||
| 1816 | 1816 | ret = dev_alloc_name(ndev, ndev->name); |
| 1817 | 1817 | if (ret < 0) { |
| 1818 | 1818 | ieee80211_if_free(ndev); |
| 1819 | + free_netdev(ndev); | |
| 1819 | 1820 | return ret; |
| 1820 | 1821 | } |
| 1821 | 1822 | |
| @@ -1905,7 +1906,7 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name, · 83 unmodified lines | ||
| 1905 | 1906 | |
| 1906 | 1907 | ret = register_netdevice(ndev); |
| 1907 | 1908 | if (ret) { |
| 1908 | − ieee80211_if_free(ndev); | |
| 1909 | + free_netdev(ndev); | |
| 1909 | 1910 | return ret; |
| 1910 | 1911 | } |
| 1911 | 1912 | } |
| @@ -601,7 +601,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) · 600 unmodified lines | ||
| 601 | 601 | struct ieee80211_supported_band *sband; |
| 602 | 602 | struct ieee80211_chanctx_conf *chanctx_conf; |
| 603 | 603 | struct ieee80211_channel *chan; |
| 604 | − u32 rate_flags, rates = 0; | |
| 604 | + u32 rates = 0; | |
| 605 | 605 | |
| 606 | 606 | sdata_assert_lock(sdata); |
| 607 | 607 | |
| @@ -612,7 +612,6 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) · 4 unmodified lines | ||
| 612 | 612 | return; |
| 613 | 613 | } |
| 614 | 614 | chan = chanctx_conf->def.chan; |
| 615 | − rate_flags = ieee80211_chandef_rate_flags(&chanctx_conf->def); | |
| 616 | 615 | rcu_read_unlock(); |
| 617 | 616 | sband = local->hw.wiphy->bands[chan->band]; |
| 618 | 617 | shift = ieee80211_vif_get_shift(&sdata->vif); |
| @@ -636,9 +635,6 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) · 17 unmodified lines | ||
| 636 | 635 | */ |
| 637 | 636 | rates_len = 0; |
| 638 | 637 | for (i = 0; i < sband->n_bitrates; i++) { |
| 639 | − if ((rate_flags & sband->bitrates[i].flags) | |
| 640 | − != rate_flags) | |
| 641 | − continue; | |
| 642 | 638 | rates |= BIT(i); |
| 643 | 639 | rates_len++; |
| 644 | 640 | } |
| @@ -2818,7 +2814,7 @@ static void ieee80211_get_rates(struct ieee80211_supported_band *sband, · 2173 unmodified lines | ||
| 2818 | 2814 | u32 *rates, u32 *basic_rates, |
| 2819 | 2815 | bool *have_higher_than_11mbit, |
| 2820 | 2816 | int *min_rate, int *min_rate_index, |
| 2821 | − int shift, u32 rate_flags) | |
| 2817 | + int shift) | |
| 2822 | 2818 | { |
| 2823 | 2819 | int i, j; |
| 2824 | 2820 | |
| @@ -2846,8 +2842,6 @@ static void ieee80211_get_rates(struct ieee80211_supported_band *sband, · 21 unmodified lines | ||
| 2846 | 2842 | int brate; |
| 2847 | 2843 | |
| 2848 | 2844 | br = &sband->bitrates[j]; |
| 2849 | − if ((rate_flags & br->flags) != rate_flags) | |
| 2850 | − continue; | |
| 2851 | 2845 | |
| 2852 | 2846 | brate = DIV_ROUND_UP(br->bitrate, (1 << shift) * 5); |
| 2853 | 2847 | if (brate == rate) { |
| @@ -4398,40 +4392,32 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata, · 1544 unmodified lines | ||
| 4398 | 4392 | return -ENOMEM; |
| 4399 | 4393 | } |
| 4400 | 4394 | |
| 4401 | − if (new_sta || override) { | |
| 4402 | − err = ieee80211_prep_channel(sdata, cbss); | |
| 4403 | − if (err) { | |
| 4404 | − if (new_sta) | |
| 4405 | − sta_info_free(local, new_sta); | |
| 4406 | − return -EINVAL; | |
| 4407 | − } | |
| 4408 | − } | |
| 4409 | − | |
| 4395 | + /* | |
| 4396 | + * Set up the information for the new channel before setting the | |
| 4397 | + * new channel. We can't - completely race-free - change the basic | |
| 4398 | + * rates bitmap and the channel (sband) that it refers to, but if | |
| 4399 | + * we set it up before we at least avoid calling into the driver's | |
| 4400 | + * bss_info_changed() method with invalid information (since we do | |
| 4401 | + * call that from changing the channel - only for IDLE and perhaps | |
| 4402 | + * some others, but ...). | |
| 4403 | + * | |
| 4404 | + * So to avoid that, just set up all the new information before the | |
| 4405 | + * channel, but tell the driver to apply it only afterwards, since | |
| 4406 | + * it might need the new channel for that. | |
| 4407 | + */ | |
| 4410 | 4408 | if (new_sta) { |
| 4411 | 4409 | u32 rates = 0, basic_rates = 0; |
| 4412 | 4410 | bool have_higher_than_11mbit; |
| 4413 | 4411 | int min_rate = INT_MAX, min_rate_index = -1; |
| 4414 | − struct ieee80211_chanctx_conf *chanctx_conf; | |
| 4415 | 4412 | const struct cfg80211_bss_ies *ies; |
| 4416 | 4413 | int shift = ieee80211_vif_get_shift(&sdata->vif); |
| 4417 | − u32 rate_flags; | |
| 4418 | − | |
| 4419 | − rcu_read_lock(); | |
| 4420 | − chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | |
| 4421 | − if (WARN_ON(!chanctx_conf)) { | |
| 4422 | − rcu_read_unlock(); | |
| 4423 | − sta_info_free(local, new_sta); | |
| 4424 | − return -EINVAL; | |
| 4425 | − } | |
| 4426 | − rate_flags = ieee80211_chandef_rate_flags(&chanctx_conf->def); | |
| 4427 | − rcu_read_unlock(); | |
| 4428 | 4414 | |
| 4429 | 4415 | ieee80211_get_rates(sband, bss->supp_rates, |
| 4430 | 4416 | bss->supp_rates_len, |
| 4431 | 4417 | &rates, &basic_rates, |
| 4432 | 4418 | &have_higher_than_11mbit, |
| 4433 | 4419 | &min_rate, &min_rate_index, |
| 4434 | − shift, rate_flags); | |
| 4420 | + shift); | |
| 4435 | 4421 | |
| 4436 | 4422 | /* |
| 4437 | 4423 | * This used to be a workaround for basic rates missing |
| @@ -4489,8 +4475,22 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata, · 51 unmodified lines | ||
| 4489 | 4475 | sdata->vif.bss_conf.sync_dtim_count = 0; |
| 4490 | 4476 | } |
| 4491 | 4477 | rcu_read_unlock(); |
| 4478 | + } | |
| 4492 | 4479 | |
| 4493 | − /* tell driver about BSSID, basic rates and timing */ | |
| 4480 | + if (new_sta || override) { | |
| 4481 | + err = ieee80211_prep_channel(sdata, cbss); | |
| 4482 | + if (err) { | |
| 4483 | + if (new_sta) | |
| 4484 | + sta_info_free(local, new_sta); | |
| 4485 | + return -EINVAL; | |
| 4486 | + } | |
| 4487 | + } | |
| 4488 | + | |
| 4489 | + if (new_sta) { | |
| 4490 | + /* | |
| 4491 | + * tell driver about BSSID, basic rates and timing | |
| 4492 | + * this was set up above, before setting the channel | |
| 4493 | + */ | |
| 4494 | 4494 | ieee80211_bss_info_change_notify(sdata, |
| 4495 | 4495 | BSS_CHANGED_BSSID | BSS_CHANGED_BASIC_RATES | |
| 4496 | 4496 | BSS_CHANGED_BEACON_INT); |
| @@ -1613,12 +1613,16 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) · 1612 unmodified lines | ||
| 1613 | 1613 | */ |
| 1614 | 1614 | if (!ieee80211_hw_check(&sta->local->hw, AP_LINK_PS) && |
| 1615 | 1615 | !ieee80211_has_morefrags(hdr->frame_control) && |
| 1616 | + !ieee80211_is_back_req(hdr->frame_control) && | |
| 1616 | 1617 | !(status->rx_flags & IEEE80211_RX_DEFERRED_RELEASE) && |
| 1617 | 1618 | (rx->sdata->vif.type == NL80211_IFTYPE_AP || |
| 1618 | 1619 | rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) && |
| 1619 | − /* PM bit is only checked in frames where it isn't reserved, | |
| 1620 | + /* | |
| 1621 | + * PM bit is only checked in frames where it isn't reserved, | |
| 1620 | 1622 | * in AP mode it's reserved in non-bufferable management frames |
| 1621 | 1623 | * (cf. IEEE 802.11-2012 8.2.4.1.7 Power Management field) |
| 1624 | + * BAR frames should be ignored as specified in | |
| 1625 | + * IEEE 802.11-2012 10.2.1.2. | |
| 1622 | 1626 | */ |
| 1623 | 1627 | (!ieee80211_is_mgmt(hdr->frame_control) || |
| 1624 | 1628 | ieee80211_is_bufferable_mmpdu(hdr->frame_control))) { |
| @@ -17,6 +17,7 @@ · 16 unmodified lines | ||
| 17 | 17 | #include <asm/unaligned.h> |
| 18 | 18 | #include <net/mac80211.h> |
| 19 | 19 | #include <crypto/aes.h> |
| 20 | +#include <crypto/algapi.h> | |
| 20 | 21 | |
| 21 | 22 | #include "ieee80211_i.h" |
| 22 | 23 | #include "michael.h" |
| @@ -153,7 +154,7 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx) · 130 unmodified lines | ||
| 153 | 154 | data_len = skb->len - hdrlen - MICHAEL_MIC_LEN; |
| 154 | 155 | key = &rx->key->conf.key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY]; |
| 155 | 156 | michael_mic(key, hdr, data, data_len, mic); |
| 156 | − if (memcmp(mic, data + data_len, MICHAEL_MIC_LEN) != 0) | |
| 157 | + if (crypto_memneq(mic, data + data_len, MICHAEL_MIC_LEN)) | |
| 157 | 158 | goto mic_fail; |
| 158 | 159 | |
| 159 | 160 | /* remove Michael MIC from payload */ |
| @@ -1048,7 +1049,7 @@ ieee80211_crypto_aes_cmac_decrypt(struct ieee80211_rx_data *rx) · 888 unmodified lines | ||
| 1048 | 1049 | bip_aad(skb, aad); |
| 1049 | 1050 | ieee80211_aes_cmac(key->u.aes_cmac.tfm, aad, |
| 1050 | 1051 | skb->data + 24, skb->len - 24, mic); |
| 1051 | − if (memcmp(mic, mmie->mic, sizeof(mmie->mic)) != 0) { | |
| 1052 | + if (crypto_memneq(mic, mmie->mic, sizeof(mmie->mic))) { | |
| 1052 | 1053 | key->u.aes_cmac.icverrors++; |
| 1053 | 1054 | return RX_DROP_UNUSABLE; |
| 1054 | 1055 | } |
| @@ -1098,7 +1099,7 @@ ieee80211_crypto_aes_cmac_256_decrypt(struct ieee80211_rx_data *rx) · 43 unmodified lines | ||
| 1098 | 1099 | bip_aad(skb, aad); |
| 1099 | 1100 | ieee80211_aes_cmac_256(key->u.aes_cmac.tfm, aad, |
| 1100 | 1101 | skb->data + 24, skb->len - 24, mic); |
| 1101 | − if (memcmp(mic, mmie->mic, sizeof(mmie->mic)) != 0) { | |
| 1102 | + if (crypto_memneq(mic, mmie->mic, sizeof(mmie->mic))) { | |
| 1102 | 1103 | key->u.aes_cmac.icverrors++; |
| 1103 | 1104 | return RX_DROP_UNUSABLE; |
| 1104 | 1105 | } |
| @@ -1202,7 +1203,7 @@ ieee80211_crypto_aes_gmac_decrypt(struct ieee80211_rx_data *rx) · 97 unmodified lines | ||
| 1202 | 1203 | if (ieee80211_aes_gmac(key->u.aes_gmac.tfm, aad, nonce, |
| 1203 | 1204 | skb->data + 24, skb->len - 24, |
| 1204 | 1205 | mic) < 0 || |
| 1205 | − memcmp(mic, mmie->mic, sizeof(mmie->mic)) != 0) { | |
| 1206 | + crypto_memneq(mic, mmie->mic, sizeof(mmie->mic))) { | |
| 1206 | 1207 | key->u.aes_gmac.icverrors++; |
| 1207 | 1208 | return RX_DROP_UNUSABLE; |
| 1208 | 1209 | } |
| @@ -526,8 +526,6 @@ static void mac802154_wpan_free(struct net_device *dev) · 525 unmodified lines | ||
| 526 | 526 | struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); |
| 527 | 527 | |
| 528 | 528 | mac802154_llsec_destroy(&sdata->sec); |
| 529 | − | |
| 530 | − free_netdev(dev); | |
| 531 | 529 | } |
| 532 | 530 | |
| 533 | 531 | static void ieee802154_if_setup(struct net_device *dev) |
| @@ -593,7 +591,8 @@ ieee802154_setup_sdata(struct ieee802154_sub_if_data *sdata, · 59 unmodified lines | ||
| 593 | 591 | sdata->dev->dev_addr); |
| 594 | 592 | |
| 595 | 593 | sdata->dev->header_ops = &mac802154_header_ops; |
| 596 | − sdata->dev->destructor = mac802154_wpan_free; | |
| 594 | + sdata->dev->needs_free_netdev = true; | |
| 595 | + sdata->dev->priv_destructor = mac802154_wpan_free; | |
| 597 | 596 | sdata->dev->netdev_ops = &mac802154_wpan_ops; |
| 598 | 597 | sdata->dev->ml_priv = &mac802154_mlme_wpan; |
| 599 | 598 | wpan_dev->promiscuous_mode = false; |
| @@ -608,7 +607,7 @@ ieee802154_setup_sdata(struct ieee802154_sub_if_data *sdata, · 8 unmodified lines | ||
| 608 | 607 | |
| 609 | 608 | break; |
| 610 | 609 | case NL802154_IFTYPE_MONITOR: |
| 611 | − sdata->dev->destructor = free_netdev; | |
| 610 | + sdata->dev->needs_free_netdev = true; | |
| 612 | 611 | sdata->dev->netdev_ops = &mac802154_monitor_ops; |
| 613 | 612 | wpan_dev->promiscuous_mode = true; |
| 614 | 613 | break; |
| @@ -94,7 +94,6 @@ static void internal_dev_destructor(struct net_device *dev) · 93 unmodified lines | ||
| 94 | 94 | struct vport *vport = ovs_internal_dev_get_vport(dev); |
| 95 | 95 | |
| 96 | 96 | ovs_vport_free(vport); |
| 97 | − free_netdev(dev); | |
| 98 | 97 | } |
| 99 | 98 | |
| 100 | 99 | static void |
| @@ -156,7 +155,8 @@ static void do_setup(struct net_device *netdev) · 55 unmodified lines | ||
| 156 | 155 | netdev->priv_flags &= ~IFF_TX_SKB_SHARING; |
| 157 | 156 | netdev->priv_flags |= IFF_LIVE_ADDR_CHANGE | IFF_OPENVSWITCH | |
| 158 | 157 | IFF_PHONY_HEADROOM | IFF_NO_QUEUE; |
| 159 | − netdev->destructor = internal_dev_destructor; | |
| 158 | + netdev->needs_free_netdev = true; | |
| 159 | + netdev->priv_destructor = internal_dev_destructor; | |
| 160 | 160 | netdev->ethtool_ops = &internal_dev_ethtool_ops; |
| 161 | 161 | netdev->rtnl_link_ops = &internal_dev_link_ops; |
| 162 | 162 | |
| @@ -236,7 +236,7 @@ static void gprs_setup(struct net_device *dev) · 235 unmodified lines | ||
| 236 | 236 | dev->tx_queue_len = 10; |
| 237 | 237 | |
| 238 | 238 | dev->netdev_ops = &gprs_netdev_ops; |
| 239 | − dev->destructor = free_netdev; | |
| 239 | + dev->needs_free_netdev = true; | |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /* |
| @@ -94,8 +94,10 @@ static struct tcf_pedit_key_ex *tcf_pedit_keys_ex_parse(struct nlattr *nla, · 93 unmodified lines | ||
| 94 | 94 | k++; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | − if (n) | |
| 97 | + if (n) { | |
| 98 | + err = -EINVAL; | |
| 98 | 99 | goto err_out; |
| 100 | + } | |
| 99 | 101 | |
| 100 | 102 | return keys_ex; |
| 101 | 103 | |
| @@ -132,21 +132,21 @@ static int tcf_act_police_init(struct net *net, struct nlattr *nla, · 131 unmodified lines | ||
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | − spin_lock_bh(&police->tcf_lock); | |
| 136 | 135 | if (est) { |
| 137 | 136 | err = gen_replace_estimator(&police->tcf_bstats, NULL, |
| 138 | 137 | &police->tcf_rate_est, |
| 139 | 138 | &police->tcf_lock, |
| 140 | 139 | NULL, est); |
| 141 | 140 | if (err) |
| 142 | − goto failure_unlock; | |
| 141 | + goto failure; | |
| 143 | 142 | } else if (tb[TCA_POLICE_AVRATE] && |
| 144 | 143 | (ret == ACT_P_CREATED || |
| 145 | 144 | !gen_estimator_active(&police->tcf_rate_est))) { |
| 146 | 145 | err = -EINVAL; |
| 147 | − goto failure_unlock; | |
| 146 | + goto failure; | |
| 148 | 147 | } |
| 149 | 148 | |
| 149 | + spin_lock_bh(&police->tcf_lock); | |
| 150 | 150 | /* No failure allowed after this point */ |
| 151 | 151 | police->tcfp_mtu = parm->mtu; |
| 152 | 152 | if (police->tcfp_mtu == 0) { |
| @@ -192,8 +192,6 @@ static int tcf_act_police_init(struct net *net, struct nlattr *nla, · 39 unmodified lines | ||
| 192 | 192 | |
| 193 | 193 | return ret; |
| 194 | 194 | |
| 195 | −failure_unlock: | |
| 196 | − spin_unlock_bh(&police->tcf_lock); | |
| 197 | 195 | failure: |
| 198 | 196 | qdisc_put_rtab(P_tab); |
| 199 | 197 | qdisc_put_rtab(R_tab); |
| @@ -4622,13 +4622,13 @@ int sctp_for_each_endpoint(int (*cb)(struct sctp_endpoint *, void *), · 4621 unmodified lines | ||
| 4622 | 4622 | |
| 4623 | 4623 | for (head = sctp_ep_hashtable; hash < sctp_ep_hashsize; |
| 4624 | 4624 | hash++, head++) { |
| 4625 | − read_lock(&head->lock); | |
| 4625 | + read_lock_bh(&head->lock); | |
| 4626 | 4626 | sctp_for_each_hentry(epb, &head->chain) { |
| 4627 | 4627 | err = cb(sctp_ep(epb), p); |
| 4628 | 4628 | if (err) |
| 4629 | 4629 | break; |
| 4630 | 4630 | } |
| 4631 | − read_unlock(&head->lock); | |
| 4631 | + read_unlock_bh(&head->lock); | |
| 4632 | 4632 | } |
| 4633 | 4633 | |
| 4634 | 4634 | return err; |
| @@ -508,7 +508,7 @@ bool tipc_msg_reverse(u32 own_node, struct sk_buff **skb, int err) · 507 unmodified lines | ||
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | if (skb_cloned(_skb) && |
| 511 | − pskb_expand_head(_skb, BUF_HEADROOM, BUF_TAILROOM, GFP_KERNEL)) | |
| 511 | + pskb_expand_head(_skb, BUF_HEADROOM, BUF_TAILROOM, GFP_ATOMIC)) | |
| 512 | 512 | goto exit; |
| 513 | 513 | |
| 514 | 514 | /* Now reverse the concerned fields */ |
| @@ -999,7 +999,8 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) · 998 unmodified lines | ||
| 999 | 999 | struct path path = { }; |
| 1000 | 1000 | |
| 1001 | 1001 | err = -EINVAL; |
| 1002 | − if (sunaddr->sun_family != AF_UNIX) | |
| 1002 | + if (addr_len < offsetofend(struct sockaddr_un, sun_family) || | |
| 1003 | + sunaddr->sun_family != AF_UNIX) | |
| 1003 | 1004 | goto out; |
| 1004 | 1005 | |
| 1005 | 1006 | if (addr_len == sizeof(short)) { |
| @@ -1110,6 +1111,10 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr, · 104 unmodified lines | ||
| 1110 | 1111 | unsigned int hash; |
| 1111 | 1112 | int err; |
| 1112 | 1113 | |
| 1114 | + err = -EINVAL; | |
| 1115 | + if (alen < offsetofend(struct sockaddr, sa_family)) | |
| 1116 | + goto out; | |
| 1117 | + | |
| 1113 | 1118 | if (addr->sa_family != AF_UNSPEC) { |
| 1114 | 1119 | err = unix_mkname(sunaddr, alen, &hash); |
| 1115 | 1120 | if (err < 0) |
| @@ -1,23 +1,42 @@ | ||
| 1 | 1 | #ifndef __BPF_ENDIAN__ |
| 2 | 2 | #define __BPF_ENDIAN__ |
| 3 | 3 | |
| 4 | −#include <asm/byteorder.h> | |
| 4 | +#include <linux/swab.h> | |
| 5 | 5 | |
| 6 | −#if __BYTE_ORDER == __LITTLE_ENDIAN | |
| 7 | −# define __bpf_ntohs(x) __builtin_bswap16(x) | |
| 8 | −# define __bpf_htons(x) __builtin_bswap16(x) | |
| 9 | −#elif __BYTE_ORDER == __BIG_ENDIAN | |
| 10 | −# define __bpf_ntohs(x) (x) | |
| 11 | −# define __bpf_htons(x) (x) | |
| 6 | +/* LLVM's BPF target selects the endianness of the CPU | |
| 7 | + * it compiles on, or the user specifies (bpfel/bpfeb), | |
| 8 | + * respectively. The used __BYTE_ORDER__ is defined by | |
| 9 | + * the compiler, we cannot rely on __BYTE_ORDER from | |
| 10 | + * libc headers, since it doesn't reflect the actual | |
| 11 | + * requested byte order. | |
| 12 | + * | |
| 13 | + * Note, LLVM's BPF target has different __builtin_bswapX() | |
| 14 | + * semantics. It does map to BPF_ALU | BPF_END | BPF_TO_BE | |
| 15 | + * in bpfel and bpfeb case, which means below, that we map | |
| 16 | + * to cpu_to_be16(). We could use it unconditionally in BPF | |
| 17 | + * case, but better not rely on it, so that this header here | |
| 18 | + * can be used from application and BPF program side, which | |
| 19 | + * use different targets. | |
| 20 | + */ | |
| 21 | +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ | |
| 22 | +# define __bpf_ntohs(x) __builtin_bswap16(x) | |
| 23 | +# define __bpf_htons(x) __builtin_bswap16(x) | |
| 24 | +# define __bpf_constant_ntohs(x) ___constant_swab16(x) | |
| 25 | +# define __bpf_constant_htons(x) ___constant_swab16(x) | |
| 26 | +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ | |
| 27 | +# define __bpf_ntohs(x) (x) | |
| 28 | +# define __bpf_htons(x) (x) | |
| 29 | +# define __bpf_constant_ntohs(x) (x) | |
| 30 | +# define __bpf_constant_htons(x) (x) | |
| 12 | 31 | #else |
| 13 | −# error "Fix your __BYTE_ORDER?!" | |
| 32 | +# error "Fix your compiler's __BYTE_ORDER__?!" | |
| 14 | 33 | #endif |
| 15 | 34 | |
| 16 | 35 | #define bpf_htons(x) \ |
| 17 | 36 | (__builtin_constant_p(x) ? \ |
| 18 | − __constant_htons(x) : __bpf_htons(x)) | |
| 37 | + __bpf_constant_htons(x) : __bpf_htons(x)) | |
| 19 | 38 | #define bpf_ntohs(x) \ |
| 20 | 39 | (__builtin_constant_p(x) ? \ |
| 21 | − __constant_ntohs(x) : __bpf_ntohs(x)) | |
| 40 | + __bpf_constant_ntohs(x) : __bpf_ntohs(x)) | |
| 22 | 41 | |
| 23 | −#endif | |
| 42 | +#endif /* __BPF_ENDIAN__ */ | |